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*as moment from"moment";import RcTimePicker from"./rc-time-picker";import classNames from"classnames";import LocaleReceiver from"../locale-provider/LocaleReceiver";import defaultLocals from"../locale-provider/default";import Button from"../button";export function generateShowHourMinuteSecond(e){return{showHour:e.indexOf("H")>-1||e.indexOf("h")>-1||e.indexOf("k")>-1,showMinute:e.indexOf("m")>-1,showSecond:e.indexOf("s")>-1}};var TimePicker=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));r.handleChange=function(e){"value"in r.props||r.setState({value:e});var t=r.props,o=t.onChange,a=t.format,i=void 0===a?"HH:mm:ss":a;o&&o(e,e&&e.format&&e.format(i)||"")},r.handleOpenClose=function(e){var t=e.open,o=r.props.onOpenChange;o&&o(t)},r.saveTimePicker=function(e){r.timePickerRef=e},r.renderTimePicker=function(e){var t=_extends({},r.props);delete t.defaultValue;var o=r.getDefaultFormat(),a=classNames(t.className,_defineProperty({},t.prefixCls+"-"+t.size,!!t.size));return React.createElement(RcTimePicker,_extends({},generateShowHourMinuteSecond(o),t,{ref:r.saveTimePicker,format:o,className:a,value:r.state.value,placeholder:void 0===t.placeholder?e.placeholder:t.placeholder,onChange:r.handleChange,onOpen:r.handleOpenClose,onClose:r.handleOpenClose,addon:function(e,r){return t.addon?React.createElement("div",{className:t.prefixCls+"-panel-addon"},t.addon(e,r)):t.multiple?React.createElement("div",{className:t.prefixCls+"-default-ok"},React.createElement(Button,{onClick:r,type:"primary",size:"small"},"确定")):null}}))};var o=e.value||e.defaultValue;if(Array.isArray(o))o.forEach(function(e){if(e&&!moment.isMoment(e))throw new Error("If value/defaultValue is typeof Array, each of them must be a moment object after `dtd@2.0`, ")});else if(o&&!moment.isMoment(o))throw new Error("The value/defaultValue of TimePicker must be a moment object after `dtd@2.0`, see: #");return r.state={value:o},r}return _inherits(t,e),_createClass(t,[{key:"componentWillReceiveProps",value:function(e){"value"in e&&this.setState({value:e.value})}},{key:"focus",value:function(){this.timePickerRef.focus()}},{key:"blur",value:function(){this.timePickerRef.blur()}},{key:"getDefaultFormat",value:function(){var e=this.props,t=e.format,r=e.use12Hours;return t||(r?"h:mm:ss a":"HH:mm:ss")}},{key:"render",value:function(){return React.createElement(LocaleReceiver,{componentName:"TimePicker",defaultLocale:defaultLocals.TimePicker},this.renderTimePicker)}}]),t}(React.Component);export default TimePicker;TimePicker.defaultProps={prefixCls:"dt-time-picker",align:{offset:[0,-0]},disabled:!1,disabledHours:void 0,disabledMinutes:void 0,disabledSeconds:void 0,hideDisabledOptions:!1,placement:"bottomLeft",transitionName:"slide-up",focusOnOpen:!0};