"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2);exports.default=wrapPicker;var _react=require("react"),React=_interopRequireWildcard(_react),_Panel=require("../time-picker/rc-time-picker/Panel"),_Panel2=_interopRequireDefault(_Panel),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_LocaleReceiver=require("../locale-provider/LocaleReceiver"),_LocaleReceiver2=_interopRequireDefault(_LocaleReceiver),_timePicker=require("../time-picker"),_default=require("../locale-provider/default"),_default2=_interopRequireDefault(_default);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var defaultLocale=_default2.default.DatePicker;function getColumns(e){var r=0;return e.showHour&&(r+=1),e.showMinute&&(r+=1),e.showSecond&&(r+=1),e.use12Hours&&(r+=1),r}function wrapPicker(d,e){var r,t;return t=React.Component,(0,_inherits3.default)(a,t),(0,_createClass3.default)(a,[{key:"componentDidMount",value:function(){var e=this.props,r=e.autoFocus,t=e.disabled;r&&!t&&this.focus()}},{key:"focus",value:function(){this.picker.focus()}},{key:"blur",value:function(){this.picker.blur()}},{key:"render",value:function(){return React.createElement(_LocaleReceiver2.default,{componentName:"DatePicker",defaultLocale:this.getDefaultLocale},this.renderPicker)}}]),(r=a).defaultProps={format:e||"YYYY-MM-DD",transitionName:"slide-up",popupStyle:{},onChange:function(){},onOk:function(){},onOpenChange:function(){},locale:{},prefixCls:"dt-calendar",inputPrefixCls:"dt-input"},r;function a(){(0,_classCallCheck3.default)(this,a);var f=(0,_possibleConstructorReturn3.default)(this,(a.__proto__||Object.getPrototypeOf(a)).apply(this,arguments));return f.handleOpenChange=function(e){(0,f.props.onOpenChange)(e)},f.handleFocus=function(e){var r=f.props.onFocus;r&&r(e)},f.handleBlur=function(e){var r=f.props.onBlur;r&&r(e)},f.savePicker=function(e){f.picker=e},f.getDefaultLocale=function(){var e=(0,_extends3.default)({},defaultLocale,f.props.locale);return e.lang=(0,_extends3.default)({},e.lang,(f.props.locale||{}).lang),e},f.renderPicker=function(e,r){var t,a=f.props,l=a.prefixCls,i=a.inputPrefixCls,n=(0,_classnames2.default)(l+"-picker",(0,_defineProperty3.default)({},l+"-picker-"+a.size,!!a.size)),u=(0,_classnames2.default)(l+"-picker-input",i,(t={},(0,_defineProperty3.default)(t,i+"-lg","large"===a.size),(0,_defineProperty3.default)(t,i+"-sm","small"===a.size),(0,_defineProperty3.default)(t,i+"-disabled",a.disabled),t)),o=a.showTime&&a.showTime.format||"HH:mm:ss",s=(0,_extends3.default)({},(0,_timePicker.generateShowHourMinuteSecond)(o),{format:o,use12Hours:a.showTime&&a.showTime.use12Hours}),c=l+"-time-picker-column-"+getColumns(s),p=a.showTime?React.createElement(_Panel2.default,(0,_extends3.default)({},s,a.showTime,{prefixCls:l+"-time-picker",className:c,placeholder:e.timePickerLocale.placeholder,transitionName:"slide-up"})):null;return React.createElement(d,(0,_extends3.default)({},a,{ref:f.savePicker,pickerClass:n,pickerInputClass:u,locale:e,localeCode:r,timePicker:p,onOpenChange:f.handleOpenChange,onFocus:f.handleFocus,onBlur:f.handleBlur}))},f}}module.exports=exports.default;