"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _react=require("react"),React=_interopRequireWildcard(_react),_createReactClass=require("create-react-class"),_createReactClass2=_interopRequireDefault(_createReactClass),_propTypes=require("prop-types"),PropTypes=_interopRequireWildcard(_propTypes),_DateTable=require("./date/DateTable"),_DateTable2=_interopRequireDefault(_DateTable),_WeekTable=require("./week/WeekTable"),_WeekTable2=_interopRequireDefault(_WeekTable),_CalendarMixin=require("./mixin/CalendarMixin"),_CalendarMixin2=_interopRequireDefault(_CalendarMixin),_CommonMixin=require("./mixin/CommonMixin"),_CommonMixin2=_interopRequireDefault(_CommonMixin),_moment=require("moment"),_moment2=_interopRequireDefault(_moment),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t.default=e,t}var FullCalendar=(0,_createReactClass2.default)({displayName:"FullCalendar",propTypes:{defaultType:PropTypes.string,type:PropTypes.string,prefixCls:PropTypes.string,locale:PropTypes.object,onTypeChange:PropTypes.func,fullscreen:PropTypes.bool,monthCellRender:PropTypes.func,showTypeSwitch:PropTypes.bool,Select:PropTypes.func.isRequired,disabledDate:PropTypes.func,weekTimes:PropTypes.array},mixins:[_CommonMixin2.default,_CalendarMixin2.default],getDefaultProps:function(){return{fullscreen:!1,showTypeSwitch:!0,onTypeChange:function(){}}},getInitialState:function(){return{type:this.props.type||"month"}},componentWillReceiveProps:function(e){"type"in e&&this.setState({type:e.type})},setType:function(e){this.weekTimes=[],"type"in this.props||this.setState({type:e}),this.props.onTypeChange(e)},goTargetDate:function(e){this.weekTimes=[];var t=this.props.value.clone(),a="month"===this.state.type?"months":"week"===this.state.type?"week":"day";t.add(e,a),this.props.onValueChange(t)},goToday:function(){var e=(0,_moment2.default)();this.props.onValueChange(e)},weekTimes:[],onChangeWeek:function(e){this.weekTimes.push(e.clone())},changeMonthElement:function(){var e=this.props,t=e.value,a=e.prefixCls,n=e.locale;return React.createElement("div",{style:{display:"inline-block"}},React.createElement("a",{key:"prev-month",className:a+"-prev-month",title:n.previousMonth,onClick:this.goTargetDate.bind(this,-1)}),React.createElement("a",{key:"today",className:(0,_classnames2.default)(a+"-today",t.year()===(0,_moment2.default)().year()&&t.month()===(0,_moment2.default)().month()&&t.date()===(0,_moment2.default)().date()?null:a+"-go-today"),onClick:this.goToday},"今天"),React.createElement("a",{key:"next-month",className:a+"-next-month",title:n.nextMonth,onClick:this.goTargetDate.bind(this,1)}))},changePanelElement:function(){var e=this.state,t=this.props.prefixCls,a=t+"-panel-btn";return React.createElement("div",{style:{display:"inline-block"}},React.createElement("a",{key:"day",className:(0,_classnames2.default)(a,"day"===e.type?t+"-select-panel":null),onClick:this.setType.bind(this,"day")},"日"),React.createElement("a",{key:"week",className:(0,_classnames2.default)(a,"week"===e.type?t+"-select-panel":null),onClick:this.setType.bind(this,"week")},"周"),React.createElement("a",{key:"month",className:(0,_classnames2.default)(a,"month"===e.type?t+"-select-panel":null),onClick:this.setType.bind(this,"month")},"月"))},render:function(){var e=this.props,t=e.locale,a=e.prefixCls,n=e.fullscreen,l=e.disabledDate,r=e.value,s=this.state.type,i="month"===s?React.createElement(_DateTable2.default,{dateRender:e.dateCellRender,contentRender:e.dateCellContentRender,locale:t,prefixCls:a,onSelect:this.onSelect,value:r,disabledDate:l}):React.createElement(_WeekTable2.default,{locale:t,prefixCls:a,onChangeWeek:this.onChangeWeek,value:r,onSelectTime:this.props.onSelectTime,weekTimes:this.weekTimes,disabledDate:l,isDay:"day"===s}),o=React.createElement("div",{key:"calendar-header",className:a+"-header"},React.createElement("div",{key:"calendar-current-date",className:a+"-current-date"},r.year()+"年"+(r.month()+1)+"月"),n&&React.createElement("div",{key:"calendar-filter-date",className:a+"-filter-date"},this.changeMonthElement(),this.changePanelElement())),c=React.createElement("div",{key:"calendar-body",className:a+"-calendar-body"},i),p=[a+"-full"];return n&&p.push(a+"-fullscreen"),this.renderRoot({children:[o,c],className:p.join(" ")})}});exports.default=FullCalendar,module.exports=exports.default;