var Datepicker;import"./calendar.js";export default window.Datepicker=Datepicker=class extends React.Component{constructor(e){var t,a,n,l,i;super(e),i=null,console.log("datepicker_typeof",typeof e.value,e.value),null!=(l=e.value)&&""!==l&&"0000-00-00"!==l&&"0"!==l&&0!==l&&(i=3===(n=l.toString().split("-")).length?new Date(n[0],n[1]-1,n[2]):new Date(1e3*parseInt(l))),this.state={name:null!=(t=e.name)?t:"",value:i,placeholder:null!=(a=e.placeholder)?a:"",timepicker:!0===e.timepicker},this.input=null,this.calendar=null,this.onCancel=this.onCancel.bind(this),this.onSubmit=this.onSubmit.bind(this),this.openCalendar=this.openCalendar.bind(this)}openCalendar(){return this.calendar.open()}getValue(){var e,t,a,n,l;return l="",null!=(t="undefined"!=typeof value&&null!==value?value:this.state.value)&&""!==t?(a=(e=t.getDate())<10?"0"+e:e,n=(e=t.getMonth()+1)<10?"0"+e:e,l=[t.getFullYear(),n,a].join("-"),this.state.timepicker&&(l=t.getTime()/1e3)):(l="0000-00-00",this.state.timepicker&&(l=0)),l}onCancel(){return this.calendar.close()}onSubmit(e){return this.setState({value:e}),null!=e&&(this.input.value=this.formatValue(e)),this.calendar.close()}formatValue(e){var t,a,n;return a=null!=e&&void 0!==e?e:this.state.value,console.log("formatValue",e,this.state.value),n="",null!=a&&""!==a&&(n=[(t=a.getDate())<10?"0"+t:t,(t=a.getMonth()+1)<10?"0"+t:t,a.getFullYear()].join("."),this.state.timepicker&&(n+=" "+((t=a.getHours())<10?"0"+t:t)+":"+((t=a.getHours())<10?"0"+t:t))),n}render(){var e,t,a,n,l=this;return({name:e,placeholder:t,timepicker:a}=this.state),n=this.formatValue(),React.createElement("div",null,React.createElement("input",{ref:function(e){return l.input=e},type:"text",name:e,value:n,placeholder:t,className:"i",autoComplete:"off",onClick:this.openCalendar}),React.createElement(Calendar,{onCancel:this.onCancel,onSubmit:this.onSubmit,value:this.getValue(),timepicker:a,ref:function(e){return l.calendar=e}}))}}; //# sourceMappingURL=datepicker.min.js.map