"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.generateShowHourMinuteSecond=generateShowHourMinuteSecond;var _react=require("react"),React=_interopRequireWildcard(_react),_moment=require("moment"),moment=_interopRequireWildcard(_moment),_rcTimePicker=require("./rc-time-picker"),_rcTimePicker2=_interopRequireDefault(_rcTimePicker),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_LocaleReceiver=require("../locale-provider/LocaleReceiver"),_LocaleReceiver2=_interopRequireDefault(_LocaleReceiver),_default=require("../locale-provider/default"),_default2=_interopRequireDefault(_default),_button=require("../button"),_button2=_interopRequireDefault(_button);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}}function generateShowHourMinuteSecond(e){return{showHour:-1<e.indexOf("H")||-1<e.indexOf("h")||-1<e.indexOf("k"),showMinute:-1<e.indexOf("m"),showSecond:-1<e.indexOf("s")}}var TimePicker=function(e){function t(e){(0,_classCallCheck3.default)(this,t);var n=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));n.handleChange=function(e){"value"in n.props||n.setState({value:e});var r=n.props,t=r.onChange,a=r.format,i=void 0===a?"HH:mm:ss":a;t&&t(e,e&&e.format&&e.format(i)||"")},n.handleOpenClose=function(e){var r=e.open,t=n.props.onOpenChange;t&&t(r)},n.saveTimePicker=function(e){n.timePickerRef=e},n.renderTimePicker=function(e){var t=(0,_extends3.default)({},n.props);delete t.defaultValue;var r=n.getDefaultFormat(),a=(0,_classnames2.default)(t.className,(0,_defineProperty3.default)({},t.prefixCls+"-"+t.size,!!t.size));return React.createElement(_rcTimePicker2.default,(0,_extends3.default)({},generateShowHourMinuteSecond(r),t,{ref:n.saveTimePicker,format:r,className:a,value:n.state.value,placeholder:void 0===t.placeholder?e.placeholder:t.placeholder,onChange:n.handleChange,onOpen:n.handleOpenClose,onClose:n.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(_button2.default,{onClick:r,type:"primary",size:"small"},"确定")):null}}))};var r=e.value||e.defaultValue;if(Array.isArray(r))r.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(r&&!moment.isMoment(r))throw new Error("The value/defaultValue of TimePicker must be a moment object after `dtd@2.0`, see: #");return n.state={value:r},n}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(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,r=e.format,t=e.use12Hours;return r||(t?"h:mm:ss a":"HH:mm:ss")}},{key:"render",value:function(){return React.createElement(_LocaleReceiver2.default,{componentName:"TimePicker",defaultLocale:_default2.default.TimePicker},this.renderTimePicker)}}]),t}(React.Component);(exports.default=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};