"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _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),_react=require("react"),React=_interopRequireWildcard(_react),_propTypes=require("prop-types"),PropTypes=_interopRequireWildcard(_propTypes),_moment=require("moment"),moment=_interopRequireWildcard(_moment),_LocaleReceiver=require("../locale-provider/LocaleReceiver"),_LocaleReceiver2=_interopRequireDefault(_LocaleReceiver),_FullCalendar=require("../calendarbase/FullCalendar"),_FullCalendar2=_interopRequireDefault(_FullCalendar),_Constants=require("./Constants"),_callMoment=require("../_util/callMoment"),_callMoment2=_interopRequireDefault(_callMoment),_default=require("../locale-provider/default"),_default2=_interopRequireDefault(_default);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&(t[l]=e[l]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function noop(){return null}function zerofixed(e){return e<10?"0"+e:""+e}var Calendar=function(e){function l(e){(0,_classCallCheck3.default)(this,l);var f=(0,_possibleConstructorReturn3.default)(this,(l.__proto__||Object.getPrototypeOf(l)).call(this,e));f.dateCellRender=function(e){var t=f.props,l=t.prefixCls,r=t.dateCellRender,a=void 0===r?noop:r;return React.createElement("div",{className:l+"-date"},React.createElement("div",{className:l+"-value"},zerofixed(e.date())),React.createElement("div",{className:l+"-content"},a(e)))},f.setValue=function(e,t){f.setState({value:e}),"select"===t?f.props.onSelect&&f.props.onSelect(e):"changePanel"===t&&f.onPanelChange(e,f.state.mode)},f.setType=function(e){var t=e;f.state.mode!==t&&(f.setState({mode:t}),f.onPanelChange(f.state.value,t))},f.onHeaderValueChange=function(e){f.setValue(e,"changePanel")},f.onHeaderTypeChange=function(e){f.setType(e)},f.onSelect=function(e){f.setValue(e,"select")},f.renderCalendar=function(e,t){var l=f.state,r=f.props,a=l.value,n=l.mode;a&&t&&a.locale(t);var o=r.prefixCls,u=r.style,s=r.className,c=r.fullscreen,i=n,p=s||"";c&&(p+=" "+o+"-fullscreen");var d=r.dateFullCellRender||f.dateCellRender;return React.createElement("div",{className:p,style:u},React.createElement(_FullCalendar2.default,(0,_extends3.default)({},r,{Select:noop,locale:e.lang,type:i,prefixCls:o,value:a,dateCellRender:d,onSelect:f.onSelect,onValueChange:f.onHeaderValueChange,onTypeChange:f.onHeaderTypeChange,fullscreen:c})))};var t=e.value||e.defaultValue||(0,_callMoment2.default)(moment);if(!moment.isMoment(t))throw new Error("The value/defaultValue of Calendar must be a moment object after `dtd@2.0`, see: #");return f.state={value:t,mode:e.mode},f}return(0,_inherits3.default)(l,e),(0,_createClass3.default)(l,[{key:"componentWillReceiveProps",value:function(e){"value"in e&&this.setState({value:e.value}),"mode"in e&&e.mode!==this.props.mode&&this.setState({mode:e.mode})}},{key:"onPanelChange",value:function(e,t){var l=this.props.onPanelChange;l&&l(e,t)}},{key:"render",value:function(){return React.createElement(_LocaleReceiver2.default,{componentName:"Calendar",defaultLocale:_default2.default.Calendar},this.renderCalendar)}}]),l}(React.Component);(exports.default=Calendar).defaultProps={locale:{},fullscreen:!0,prefixCls:_Constants.PREFIX_CLS,mode:"month",onSelect:noop,onPanelChange:noop},Calendar.propTypes={monthCellRender:PropTypes.func,monthFullCellRender:PropTypes.func,dateCellRender:PropTypes.func,dateFullCellRender:PropTypes.func,fullscreen:PropTypes.bool,locale:PropTypes.object,prefixCls:PropTypes.string,className:PropTypes.string,style:PropTypes.object,onPanelChange:PropTypes.func,value:PropTypes.object,onSelect:PropTypes.func},module.exports=exports.default;