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,o){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var l=0;for(r=Object.getOwnPropertySymbols(e);l<r.length;l++)o.indexOf(r[l])<0&&(t[r[l]]=e[r[l]])}return t};import*as React from"react";import*as PropTypes from"prop-types";import RcSelect,{Option,OptGroup}from"rc-select";import classNames from"classnames";import LocaleReceiver from"../locale-provider/LocaleReceiver";import defaultLocale from"../locale-provider/default";import Icon from"../icon";var SelectPropTypes={prefixCls:PropTypes.string,className:PropTypes.string,size:PropTypes.oneOf(["default","large","small"]),combobox:PropTypes.bool,notFoundContent:PropTypes.any,showSearch:PropTypes.bool,optionLabelProp:PropTypes.string,transitionName:PropTypes.string,choiceTransitionName:PropTypes.string},Select=function(e){function o(){_classCallCheck(this,o);var e=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).apply(this,arguments));return e.saveSelect=function(o){e.rcSelect=o},e.renderSelect=function(o){var t,r=e.props,l=r.prefixCls,s=r.className,c=void 0===s?"":s,n=r.size,a=r.mode,p=r.removeIcon,i=r.clearIcon,m=__rest(r,["prefixCls","className","size","mode","removeIcon","clearIcon"]),u=classNames((_defineProperty(t={},l+"-lg","large"===n),_defineProperty(t,l+"-sm","small"===n),t),c),f=e.props.optionLabelProp,d="combobox"===a;d&&(f=f||"value");var b={multiple:"multiple"===a,tags:"tags"===a,combobox:d},y=p&&(React.isValidElement(p)?React.cloneElement(p,{className:classNames(p.props.className,l+"-remove-icon")}):p)||React.createElement(Icon,{type:"close",className:l+"-remove-icon"}),h=i&&(React.isValidElement(i)?React.cloneElement(i,{className:classNames(i.props.className,l+"-clear-icon")}):i)||React.createElement(Icon,{type:"close-circle",className:l+"-clear-icon"});return React.createElement(RcSelect,_extends({removeIcon:y,clearIcon:h},m,b,{prefixCls:l,className:u,optionLabelProp:f||"children",notFoundContent:e.getNotFoundContent(o),ref:e.saveSelect}))},e}return _inherits(o,e),_createClass(o,[{key:"focus",value:function(){this.rcSelect.focus()}},{key:"blur",value:function(){this.rcSelect.blur()}},{key:"getNotFoundContent",value:function(e){var o=this.props,t=o.notFoundContent;return"combobox"===o.mode?void 0===t?null:t:void 0===t?e.notFoundContent:t}},{key:"render",value:function(){return React.createElement(LocaleReceiver,{componentName:"Select",defaultLocale:defaultLocale.Select},this.renderSelect)}}]),o}(React.Component);export default Select;Select.Option=Option,Select.OptGroup=OptGroup,Select.defaultProps={prefixCls:"dt-select",showSearch:!1,transitionName:"slide-up",choiceTransitionName:"zoom"},Select.propTypes=SelectPropTypes;