import*as React from"react";import createReactClass from"create-react-class";import*as PropTypes from"prop-types";import KeyCode from"rc-util/es/KeyCode";import CalendarHeader from"./calendar/CalendarHeader";import CalendarFooter from"./calendar/CalendarFooter";import CalendarMixin from"./mixin/CalendarMixin";import CommonMixin from"./mixin/CommonMixin";var MonthCalendar=createReactClass({displayName:"MonthCalendar",propTypes:{monthCellRender:PropTypes.func,dateCellRender:PropTypes.func},mixins:[CommonMixin,CalendarMixin],getInitialState:function(){return{mode:"month"}},onKeyDown:function(e){var a=e.keyCode,t=e.ctrlKey||e.metaKey,n=this.state.value,r=this.props.disabledDate,o=n;switch(a){case KeyCode.DOWN:(o=n.clone()).add(3,"months");break;case KeyCode.UP:(o=n.clone()).add(-3,"months");break;case KeyCode.LEFT:o=n.clone(),t?o.add(-1,"years"):o.add(-1,"months");break;case KeyCode.RIGHT:o=n.clone(),t?o.add(1,"years"):o.add(1,"months");break;case KeyCode.ENTER:return r&&r(n)||this.onSelect(n),e.preventDefault(),1;default:return}if(o!==n)return this.setValue(o),e.preventDefault(),1},handlePanelChange:function(e,a){"date"!==a&&this.setState({mode:a})},render:function(){var e=this.props,a=this.state,t=a.mode,n=a.value,r=React.createElement("div",{className:e.prefixCls+"-month-calendar-content"},React.createElement("div",{className:e.prefixCls+"-month-header-wrap"},React.createElement(CalendarHeader,{prefixCls:e.prefixCls,mode:t,value:n,locale:e.locale,disabledMonth:e.disabledDate,monthCellRender:e.monthCellRender,monthCellContentRender:e.monthCellContentRender,onMonthSelect:this.onSelect,onValueChange:this.setValue,onPanelChange:this.handlePanelChange})),React.createElement(CalendarFooter,{prefixCls:e.prefixCls,renderFooter:e.renderFooter}));return this.renderRoot({className:e.prefixCls+"-month-calendar",children:r})}});export default MonthCalendar;