import _defineProperty from"babel-runtime/helpers/defineProperty";import _extends from"babel-runtime/helpers/extends";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";import*as React from"react";import TimePickerPanel from"../time-picker/rc-time-picker/Panel";import classNames from"classnames";import LocaleReceiver from"../locale-provider/LocaleReceiver";import{generateShowHourMinuteSecond}from"../time-picker";import defaultLocales from"../locale-provider/default";var defaultLocale=defaultLocales.DatePicker;function getColumns(e){var r=e.showHour,o=e.showMinute,t=e.showSecond,n=e.use12Hours,i=0;return r&&(i+=1),o&&(i+=1),t&&(i+=1),n&&(i+=1),i}export default function wrapPicker(e,r){var o;return(o=function(r){function o(){_classCallCheck(this,o);var r=_possibleConstructorReturn(this,(o.__proto__||Object.getPrototypeOf(o)).apply(this,arguments));return r.handleOpenChange=function(e){(0,r.props.onOpenChange)(e)},r.handleFocus=function(e){var o=r.props.onFocus;o&&o(e)},r.handleBlur=function(e){var o=r.props.onBlur;o&&o(e)},r.savePicker=function(e){r.picker=e},r.getDefaultLocale=function(){var e=_extends({},defaultLocale,r.props.locale);return e.lang=_extends({},e.lang,(r.props.locale||{}).lang),e},r.renderPicker=function(o,t){var n,i=r.props,a=i.prefixCls,s=i.inputPrefixCls,l=classNames(a+"-picker",_defineProperty({},a+"-picker-"+i.size,!!i.size)),c=classNames(a+"-picker-input",s,(_defineProperty(n={},s+"-lg","large"===i.size),_defineProperty(n,s+"-sm","small"===i.size),_defineProperty(n,s+"-disabled",i.disabled),n)),u=i.showTime&&i.showTime.format||"HH:mm:ss",p=_extends({},generateShowHourMinuteSecond(u),{format:u,use12Hours:i.showTime&&i.showTime.use12Hours}),m=a+"-time-picker-column-"+getColumns(p),f=i.showTime?React.createElement(TimePickerPanel,_extends({},p,i.showTime,{prefixCls:a+"-time-picker",className:m,placeholder:o.timePickerLocale.placeholder,transitionName:"slide-up"})):null;return React.createElement(e,_extends({},i,{ref:r.savePicker,pickerClass:l,pickerInputClass:c,locale:o,localeCode:t,timePicker:f,onOpenChange:r.handleOpenChange,onFocus:r.handleFocus,onBlur:r.handleBlur}))},r}return _inherits(o,r),_createClass(o,[{key:"componentDidMount",value:function(){var e=this.props,r=e.autoFocus,o=e.disabled;r&&!o&&this.focus()}},{key:"focus",value:function(){this.picker.focus()}},{key:"blur",value:function(){this.picker.blur()}},{key:"render",value:function(){return React.createElement(LocaleReceiver,{componentName:"DatePicker",defaultLocale:this.getDefaultLocale},this.renderPicker)}}]),o}(React.Component)).defaultProps={format:r||"YYYY-MM-DD",transitionName:"slide-up",popupStyle:{},onChange:function(){},onOk:function(){},onOpenChange:function(){},locale:{},prefixCls:"dt-calendar",inputPrefixCls:"dt-input"},o};