import _extends from"babel-runtime/helpers/extends";import _defineProperty from"babel-runtime/helpers/defineProperty";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";var __rest=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&(r[n[s]]=e[n[s]])}return r};import*as React from"react";import classNames from"classnames";import Input from"./Input";import Icon from"../icon";import Button from"../button";var Search=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.onSearch=function(){var t=e.props.onSearch;t&&t(e.input.input.value),e.input.focus()},e.saveInput=function(t){e.input=t},e}return _inherits(t,e),_createClass(t,[{key:"focus",value:function(){this.input.focus()}},{key:"blur",value:function(){this.input.blur()}},{key:"render",value:function(){var e,t=this.props,r=t.className,n=t.prefixCls,s=t.inputPrefixCls,o=t.size,i=t.enterButton,a=t.suffix,c=__rest(t,["className","prefixCls","inputPrefixCls","size","enterButton","suffix"]);delete c.onSearch;var p=i?React.createElement(Button,{className:n+"-button",type:"primary",size:o,onClick:this.onSearch,key:"enterButton"},!0===i?React.createElement(Icon,{type:"search"}):i):React.createElement(Icon,{className:n+"-icon",type:"search",key:"searchIcon"}),u=a?[a,p]:p,l=classNames(n,r,(_defineProperty(e={},n+"-enter-button",!!i),_defineProperty(e,n+"-"+o,!!o),e));return React.createElement(Input,_extends({onPressEnter:this.onSearch},c,{size:o,className:l,prefixCls:s,suffix:u,ref:this.saveInput}))}}]),t}(React.Component);export default Search;Search.defaultProps={inputPrefixCls:"dt-input",prefixCls:"dt-input-search",enterButton:!1};