45.chunk.js
4.68 KB
webpackJsonpecCom([45],{988:function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var u=n(6),o=a(u),s=n(1),l=a(s),i=n(3),r=a(i),c=n(4),p=a(c),h=n(5),f=a(h),d=n(2),y=a(d),m=n(7),S=n(29),v=a(S),g=n(12),k=a(g),V=n(10),C=a(V),w=n(9),K=a(w),N=K.default.getLabel,D=function(e){function t(e){(0,l.default)(this,t);var n=(0,p.default)(this,(t.__proto__||(0,o.default)(t)).call(this,e));return n.getAssociate=function(e,t){var a=n.props.associateUrl;a&&""!==a&&k.default.callApi(a,"POST",e).then(function(e){n.setState({hotkeys:e.result}),t&&t()})},n.inputChange=function(e){n.setState({previousInputValue:n.inputValue,inputValue:e,currentInputValue:e,isSearchSucess:!1}),n.searchDelay(e)},n.searchDelay=function(e){var t=n.state,a=t.previousInputValue,u=t.timeoutMarker;u&&window.clearTimeout(u),n.setState({timeoutMarker:setTimeout(function(){e&&""!==e&&a!=e&&n.getAssociate({key:e},function(){n.setState({showHotKeys:!0})}),e||(n.setState({showHotKeys:!1}),window.clearTimeout(u))},300)})},n.commonSearchFun=function(e){var t=n.state.inputValue;e.preventDefault();var a=ReactDOM.findDOMNode(n.refs.inputNode);n.setState({inputNode:ReactDOM.findDOMNode(n.refs.inputNode),selectionStart:a.selectionStart,selectionEnd:a.selectionEnd}),""!==t&&(n.props.searchFunc&&(0,v.default)(n.props.searchFunc)&&n.props.searchFunc(t),n.setState({showHotKeys:!1}))},n.myKeyDown=function(e){var t=n.state,a=t.myKey,u=t.hotkeys,o=t.showHotKeys,s=t.currentInputValue,l=void 0;13==e.keyCode?n.commonSearchFun(e):40==e.keyCode?o&&0!==u.length&&(a<u.length-1&&a>=-1?(l=u[a+1],n.setState({myKey:a+1,inputValue:u[a+1]})):(l=s,n.setState({myKey:-1,inputValue:s}))):38==e.keyCode&&(e.preventDefault(),o&&0!==u.length&&(a>0?(l=u[a-1],n.setState({myKey:a-1,inputValue:u[a-1]})):0==a?(l=s,n.setState({myKey:-1,inputValue:s})):(l=u[u.length-1],n.setState({myKey:u.length-1,inputValue:u[u.length-1]})))),n.onSearchChange(l)},n.onSearchChange=function(e){""==e&&""!=n.state.value&&n.props.onSearchChange&&(0,v.default)(n.props.onSearchChange)&&n.props.onSearchChange(e),e&&e!=n.state.inputValue&&n.props.onSearchChange&&(0,v.default)(n.props.onSearchChange)&&n.props.onSearchChange(e)},n.onSearch=function(e){n.props.onSearch&&(0,v.default)(n.props.onSearch)&&n.props.onSearch(e)},n.state={showHotKeys:!1,inputValue:e.inputValue||"",hotkeys:[],myKey:-1,currentInputValue:"",previousInputValue:"",timeoutMarker:null,inputNode:null,selectionStart:0,selectionEnd:0,searchInputWidth:0},n}return(0,f.default)(t,e),(0,r.default)(t,[{key:"componentDidMount",value:function(){var e=this.refs.searchInput.clientWidth,t=this.refs.inputText.clientWidth;this.setState({searchInputWidth:e-t+1})}},{key:"componentWillReceiveProps",value:function(e){e.inputValue&&e.inputValue!==this.props.inputValue&&e.inputValue!==this.state.inputValue&&this.setState({inputValue:e.inputValue})}},{key:"componentWillUnmount",value:function(){window.clearTimeout(this.state.timeoutMarker)}},{key:"render",value:function(){var e=this,t=this.props,n=t.text,a=void 0===n?N(197,"搜索"):n,u=t.searchFunc,o=t.placeHolder,s=void 0===o?"":o,l=t.hasIcon,i=t.icon,r=t.iconClickFunc,c=t.associateUrl,p=t.className,h=void 0===p?"":p,f=t.style,d=this.state,S=d.myKey,g=d.hotkeys,k=d.inputValue,V=d.showHotKeys,C=d.searchInputWidth,w=y.default.createElement("ul",{className:"input-hotkeys"},c&&""!==c&&g&&0!==g.length&&g.map(function(t,n){return y.default.createElement("li",{className:n==S?"hotkeys-background":"hotkeys-hide-background",style:{paddingLeft:l&&i?36:10},ref:"hotKey",key:n,onClick:function(){e.setState({inputValue:t,showHotKeys:!1}),e.onSearchChange(t),u&&(0,v.default)(u)&&u(t)}},t)}));return y.default.createElement("div",{className:"wea-search-input-search "+h,style:f,ref:"searchInput"},y.default.createElement(m.Popover,{visible:V,placement:"bottomLeft",content:w,trigger:"click",overlayClassName:"wea-search-input-hotkeys-popover",overlayStyle:{width:C},onVisibleChange:function(t){return e.setState({showHotKeys:""!=k&&t})}},y.default.createElement("input",{style:{paddingLeft:l&&i?36:10},ref:"inputNode",placeholder:s,className:"input",value:k,autoFocus:"autoFocus",onChange:function(t){e.inputChange(t.target.value),e.setState({myKey:-1}),e.onSearchChange(t.target.value)},onKeyDown:function(t){e.myKeyDown(t)}})),y.default.createElement("span",{ref:"inputText",className:"input-text",onClick:function(t){e.onSearch(k),e.commonSearchFun(t)},onMouseDown:function(e){e.preventDefault()}},a),l&&i&&y.default.createElement("span",{className:"input-left",onClick:function(){return r&&(0,v.default)(r)&&r()}},y.default.createElement("em",{className:i})))}}]),t}(y.default.Component),I=(0,C.default)(D,"WeaSearchInput");t.default=I}});
//# sourceMappingURL=45.chunk.js.map?v=017016a4