import*as React from"react";import createReactClass from"create-react-class";import*as PropTypes from"prop-types";import cx from"classnames";import WeekConstants from"./WeekConstants";var WeekTbody=createReactClass({displayName:"WeekTbody",propTypes:{prefixCls:PropTypes.string,value:PropTypes.object,hoverValue:PropTypes.any},getDefaultProps:function(){return{hoverValue:[]}},getInitialState:function(){return{startTime:"",endTime:"",isHead:!1,isDown:!1}},mouseDown:function(e,t){this.setState({isHead:t,isDown:!0,startTime:e})},mouseUp:function(e,t){this.setState({isDown:!1,endTime:""}),this.state.startTime&&e&&this.props.onSelectTime&&this.state.isHead===t&&e>=this.state.startTime&&this.props.onSelectTime(this.state.startTime,e)},mouseMove:function(e){this.state.isDown&&this.setState({endTime:e})},render:function(){var e=this.props,t=e.prefixCls,s=e.weekTimes,o=void 0,i=void 0,a=t+"-time",r=t+"-time-cell",n=t+"-all-day",m=t+"-all-day-cell",l=t+"-selected-time",c=[],d=0,p=e.isDay?2:WeekConstants.DATE_COL_COUNT;for(o=0;o<WeekConstants.DATE_ROW_COUNT;o++){var h=[];for(i=0;i<p;i++){var u=a,T=void 0,f=void 0,v=void 0,y=void 0,D=void 0;o?(i?(f=(y=s[i-1].format("YYYY MM DD"))+" "+(o<=10?"0":"")+(o-1)+":00:00",v=y+" "+(o<=9?"0":"")+o+":00:00",D=!this.state.isHead&&f>=this.state.startTime&&v<=this.state.endTime):T=(o<=10?"0":"")+(o-1)+":00",h.push(React.createElement("td",{key:d,role:"gridcell",className:cx(u,T?"":r,D?l:""),onMouseDown:this.mouseDown.bind(this,f,!1),onMouseUp:this.mouseUp.bind(this,v,!1),onMouseMove:this.mouseMove.bind(this,v,!1)},T))):(i?(f=(y=s[i-1].format("YYYY MM DD"))+" 00:00:00",v=y+" 24:00:00",D=this.state.isHead&&f>=this.state.startTime&&v<=this.state.endTime):T="全天",h.push(React.createElement("td",{key:d,role:"gridcell",className:cx(u,"全天"===T?n:null,T?"":m,D?l:""),onMouseDown:this.mouseDown.bind(this,f,!0),onMouseUp:this.mouseUp.bind(this,v,!0),onMouseMove:this.mouseMove.bind(this,v,!0)},T))),d++}c.push(React.createElement("tr",{key:o,role:"row"},h))}return React.createElement("tbody",{className:t+"-tbody"},c)}});export default WeekTbody;