react-date-field
Version:
React DateField
2 lines • 39.4 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("moment")):"function"==typeof define&&define.amd?define(["React","moment"],e):"object"==typeof exports?exports.ReactDateField=e(require("React"),require("moment")):t.ReactDateField=e(t.React,t.moment)}(this,function(t,e){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}(function(t){for(var e in t)switch(typeof t[e]){case"number":t[e]=t[t[e]];break;case"object":t[e]=function(e){var n=e.slice(1),r=t[e[0]];return function(t,e,i){r.apply(null,[t,e,i].concat(n))}}(t[e])}return t}([function(t,e,n){"use strict";function r(){}var i=n(1),o=n(5),s=n(18),a=i.createFactory(n(17)),h=n(24),l=n(23),u=n(21),p=n(22),c=n(20),f=n(37);t.exports=i.createClass({displayName:"ReactDateField",mixins:[f],getInitialState:function(){return{defaultValue:this.props.defaultValue,pickerVisible:this.props.defaultPickerVisible}},getDefaultProps:function(){return{constrainTo:!0,validate:!0,calendarToolColor:"#a8a8a8",calendarToolOverColor:"#7F7C7C",calendarToolWidth:12,showPickerOnFocus:!0,dateFormat:c.dateFormat,strict:!0,defaultPickerFactory:a,defaultPickerStyle:{position:"absolute",left:0,top:"100%"}}},render:function(){this.toMoment=function(t,e){return l(t,this.props.dateFormat,e||{strict:this.props.strict})};var t=this.state,e=this.prepareProps(this.props,t),n=this.renderPicker(e,t),r=this.renderHiddenField(e,t);return i.createElement("div",i.__spread({},this.prepareWrapperProps(e,t)),r,i.createElement(s,i.__spread({},e.fieldProps),n))},renderPicker:function(t,e){return this._renderPicker(t,e)},renderHiddenField:function(t,e){return t.hiddenName?i.createElement("input",{type:"hidden",value:this.getValue(t,e),name:t.hiddenName}):null},format:function(t){return t.format(this.props.dateFormat)},prepareProps:function(t,e){var n={};return o(n,t),n.value=this.prepareValue(n,e),n.tools=this.renderTools,n.style=this.prepareStyle(n),n.fieldProps=this.prepareFieldProps(n,e),n.pickerProps=this.preparePickerProps(n),n},renderTools:function(t,e){var n=t.renderCalendarTool||this.renderCalendarTool;return[e,n(t)]},renderCalendarTool:function(t){var e=this.state,n=e.calendarToolMouseOver?t.calendarToolOverColor:t.calendarToolColor,r=t.calendarToolWidth,o={height:"100%",position:"relative",display:"flex",flexFlow:"column",alignItems:"stretch",cursor:"pointer",padding:"7px 5px 5px 5px",boxSizing:"border-box"},s={height:"100%",width:r,borderColor:n,borderStyle:"solid",borderWidth:"4px 2px 2px 2px",position:"relative"},a={borderColor:n,borderStyle:"solid",borderWidth:"0px 3px 0px 3px",height:5,right:1,left:1,top:-6,position:"absolute"},h={position:"absolute",bottom:2,right:2,width:4,height:4,background:n};return i.createElement("div",{style:o,onMouseEnter:this.handleCalendarToolMouseEnter,onMouseLeave:this.handleCalendarToolMouseLeave,onClick:this.handleCalendarToolClick,onMouseDown:this.handleCalendarToolMouseDown},i.createElement("div",{style:s},i.createElement("div",{style:a}),i.createElement("div",{style:h})))},handleCalendarToolMouseEnter:function(){this.setState({calendarToolMouseOver:!0})},handleCalendarToolMouseLeave:function(){this.setState({calendarToolMouseOver:!1})},handleCalendarToolClick:function(){this.togglePicker()},handleCalendarToolMouseDown:function(t){t.preventDefault()},prepareValue:function(t,e){var n=this.getValue(t,e);t.strictMoment=this.toMoment(n,{strict:!0}),t.moment=this.toMoment(t.strictMoment.isValid()?t.strictMoment:n),(u(n)||"number"==typeof n||p(n))&&(n=this.format(t.moment));var r=!0;return t.strictMoment.isValid()?n=this.format(t.moment):t.moment.isValid()||(r=!1),t.valid=r,n},preparePickerProps:function(t){var e=this._preparePickerProps(t);return t.valid&&(e.date=t.moment),e.onMouseDown=this.handlePickerMouseDown.bind(this,t,e),e.onChange=this.handlePickerChange.bind(this,t,e),e},handlePickerMouseDown:function(t,e,n){var r=this.props.pickerProps;r&&r.onMouseDown&&r.onMouseDown(n),n.preventDefault()},handlePickerChange:function(t,e,n,i){var o=this.props.pickerProps||{},s=[].slice.call(arguments,2);(o.onChange||r).apply(null,s),this.notify(i),this.setPickerVisible(!1)},prepareFieldProps:function(t,e){var n=this._prepareFieldProps(t,e);return n.value=t.value,n.validate===!0&&(n.validate=function(){return t.strictMoment.isValid()}),n},prepareStyle:function(t){var e={};return o(e,t.defaultStyle,t.style),e},getValue:function(t,e){return void 0===t.value?e.defaultValue:t.value},handleKeyDown:function(t,e){var n=e.key,r="handle"+h(n)+"KeyDown";this[r]&&this[r](t,e)},handleChange:function(t,e,n,i){if(!t.readOnly||!i||"input"!=i.type){var o=this.toMoment(e);void 0===this.props.value&&this.setState({defaultValue:e});var s=[e,o,i];(t.onChange||r).apply(null,s);var n=this.props.fieldProps||{};(n.onChange||r).apply(null,s)}},prepareWrapperProps:function(t){var e=this._prepareWrapperProps.apply(this,arguments);return e.style=this.prepareWrapperStyle(t,e),e},prepareWrapperStyle:function(t,e){var n=o({},e.style);return"absolute"!=n.position&&(n.position="relative"),n},notify:function(){return this._notify.apply(this,arguments)},focus:function(){return this._focus.apply(this,arguments)},getInput:function(){return this._getInput.apply(this,arguments)},isFocused:function(){return this._isFocused.apply(this,arguments)},handleFocus:function(t){this.props.showPickerOnFocus&&this.setPickerVisible(!0);var e=this.props.fieldProps;e&&e.onFocus&&e.onFocus(t),this.props.onFocus&&this.props.onFocus(t)},handleBlur:function(t){this.setPickerVisible(!1);var e=this.props.fieldProps;e&&e.onBlur&&e.onBlur(t),this.props.onBlur&&this.props.onBlur(t)},isPickerVisible:function(){return this._isPickerVisible()},setPickerVisible:function(t){if(t!=this.state.pickerVisible){var e=this.getValue(this.props,this.state),n=t?this.props.onPickerShow:this.props.onPickerHide;(n||r)(e),this.setState({pickerVisible:t})}},togglePicker:function(){this.setState({pickerVisible:!this.state.pickerVisible})}})},function(e){e.exports=t},function(t){t.exports=e},function(t,e,n){"use strict";var r=n(2),i=n(6);t.exports=function(t,e,n){var o=!(!n||!n.strict);return e=e||i.dateFormat,"string"==typeof t?r(t,e,o):r.isMoment(t)?t:r(null==t?new Date:t)}},function(t,e,n){"use strict";function r(t,e,n){return t&&n.forEach(function(n){e[n]=t[n]}),e}var i=n(5),o=n(6),s=Object.keys(o);t.exports=function(t,e){var n=s;return e&&(n=Object.keys(e)),e=e||o,t?r(t,i({},e),n):i({},e)}},function(t){"use strict";function e(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t){for(var n,r,i=e(t),o=1;o<arguments.length;o++){n=arguments[o],r=Object.keys(Object(n));for(var s=0;s<r.length;s++)i[r[s]]=n[r[s]]}return i}},function(t,e,n){"use strict";var r=n(10);t.exports={weekDayNames:r(),weekStartDay:0,dayFormat:"D",monthFormat:"MMMM",yearFormat:"YYYY",navPrev:"‹",navNext:"›",view:null,defaultView:"month",date:null,minDate:null,maxDate:null,viewDate:null,defaultViewDate:null,dateFormat:"YYYY-MM-DD"}},function(t,e,n){"use strict";function r(t,e){return o(t).format(e)}var i=n(6),o=n(3);t.exports={day:function(t,e){return r(t,e||i.dayFormat)},month:function(t,e){return r(t,e||i.monthFormat)},year:function(t,e){return r(t,e||i.yearFormat)}}},5,function(t,e,n){"use strict";var r=n(2);t.exports=function(t){return r.isMoment(t)}},function(t,e,n){"use strict";var r=n(2),i=1*r().startOf("week").format("d");t.exports=function(t){for(var e=r.weekdaysShort(),n=t||i;n>0;)e.push(e.shift()),n--;return e}},function(t){"use strict";function e(t,e){function n(r){function i(){var i=arguments.length,o=[].concat(r);return i&&o.push.apply(o,arguments),o.length<e?n(o):t.apply(this,o)}return i}return"number"!=typeof e&&(e=t.length),n([])}var n=Object.prototype.hasOwnProperty;t.exports=e(function(t,e){return n.call(t,e)})},function(t){"use strict";t.exports=function(t){var e=!0;return t.right<t.left&&(e=!1,t.right=t.left),t.bottom<t.top&&(e=!1,t.bottom=t.top),e}},function(t,e,n){"use strict";function r(){}var i,o=n(1),s=n(2),a=n(7),h=n(4),l=(n(3),o.createClass({displayName:"DecadeView",getDefaultProps:function(){return h()},getYearsInDecade:function(t){var e=s(t).get("year"),n=e%10;e=e-n-1;for(var r=[],i=0,o=s(e,"YYYY").startOf("year");12>i;i++)r.push(s(o)),o.add(1,"year");return r},render:function(){i=+s().startOf("day");var t=this.props.viewMoment=s(this.props.viewDate);this.props.date&&(this.props.moment=s(this.props.date).startOf("year"));var e=this.getYearsInDecade(t);return o.createElement("table",{className:"dp-table dp-decade-view"},o.createElement("tbody",null,this.renderYears(e)))},renderYears:function(t){for(var e=t.map(this.renderYear,this),n=t.length,r=[],i=Math.ceil(n/4),s=0;i>s;s++)r.push(e.slice(4*s,4*(s+1)));return r.map(function(t,e){return o.createElement("tr",{key:"row"+e},t)})},renderYear:function(t,e,n){var r=a.year(t),i=["dp-cell dp-year"],s=+t;return s==this.props.moment&&i.push("dp-value"),e||i.push("dp-prev"),e==n.length-1&&i.push("dp-next"),o.createElement("td",{key:r,className:i.join(" "),onClick:this.handleClick.bind(this,t)},r)},handleClick:function(t,e){e.target.value=t,(this.props.onSelect||r)(t,e)}}));l.getHeaderText=function(t){var e=s(t).get("year"),n=e%10;return e=e-n-1,e+" - "+(e+11)},t.exports=l},function(t,e,n){"use strict";var r=n(1),i=r.PropTypes;t.exports=r.createClass({displayName:"DatePickerHeader",propTypes:{onChange:i.func,onPrev:i.func,onNext:i.func,colspan:i.number,children:i.node},render:function(){var t=this.props;return r.createElement("div",{className:"dp-header"},r.createElement("table",{className:"dp-nav-table"},r.createElement("tbody",null,r.createElement("tr",{className:"dp-row"},r.createElement("td",{className:"dp-prev-nav dp-nav-cell dp-cell",onClick:t.onPrev},t.prevText),r.createElement("td",{className:"dp-nav-view dp-cell",colSpan:t.colspan,onClick:t.onChange},t.children),r.createElement("td",{className:"dp-next-nav dp-nav-cell dp-cell",onClick:t.onNext},t.nextText)))))}})},function(t,e,n){"use strict";function r(){}var i,o=n(1),s=n(2),a=n(7),h=n(4),l=n(3),u=o.createClass({displayName:"MonthView",formatAsDay:function(t,e){return t.format(e||"D")},getDefaultProps:function(){return h()},getWeekStartMoment:function(t){var e=s(t).startOf("week");return e},getDaysInMonth:function(t){var e=s(t).startOf("month"),n=this.getWeekStartMoment(e),r=[],i=0;for(e.add(-1,"days").isBefore(n)&&n.add(-1,"weeks");42>i;i++)r.push(s(n)),n.add(1,"days");return r},render:function(){i=+s().startOf("day");var t=this.props.viewMoment=l(this.props.viewDate,this.props.dateFormat);this.props.minDate&&(this.props.minDate=+l(this.props.minDate,this.props.dateFormat)),this.props.maxDate&&(this.props.maxDate=+l(this.props.maxDate,this.props.dateFormat)),this.monthFirst=s(t).startOf("month"),this.monthLast=s(t).endOf("month"),this.props.date&&(this.props.moment=s(this.props.date).startOf("day"));var e=this.getDaysInMonth(t);return o.createElement("table",{className:"dp-table dp-month-view"},o.createElement("tbody",null,this.renderWeekDayNames(),this.renderDays(e)))},renderDays:function(t){for(var e=t.map(this.renderDay,this),n=t.length,r=[],i=Math.ceil(n/7),s=0;i>s;s++)r.push(e.slice(7*s,7*(s+1)));return r.map(function(t,e){return o.createElement("tr",{key:"row"+e,className:"dp-week dp-row"},t)})},renderDay:function(t){var e=a.day(t),n=["dp-cell dp-day"],r=+t;r==i?n.push("dp-current"):r<this.monthFirst?n.push("dp-prev"):r>this.monthLast&&n.push("dp-next"),this.props.minDate&&t<this.props.minDate&&n.push("dp-disabled dp-before-min"),this.props.maxDate&&t>this.props.maxDate&&n.push("dp-disabled dp-after-max"),r==this.props.moment&&n.push("dp-value");var s={key:e,text:e,date:t,className:n.join(" "),style:{},onClick:this.handleClick.bind(this,t,r),children:e};"function"==typeof this.props.onRenderDay&&(s=this.props.onRenderDay(s));var h=o.DOM.td,l=this.props.renderDay||h,u=l(s);return void 0===u&&(u=h(s)),u},renderWeekDayNames:function(){var t=this.props.weekDayNames;return o.createElement("tr",{className:"dp-row dp-week-day-names"},t.map(function(t){return o.createElement("td",{key:t,className:"dp-cell dp-week-day-name"},t)}))},handleClick:function(t,e,n){this.props.minDate&&e<this.props.minDate||this.props.maxDate&&e>this.props.maxDate||(n.target.value=t,(this.props.onChange||r)(t,n))}});u.getHeaderText=function(t){return l(t).format("MMMM YYYY")},t.exports=u},function(t,e,n){"use strict";function r(){}var i,o=n(1),s=n(2),a=n(7),h=n(4),l=n(3),u=o.createClass({displayName:"YearView",getDefaultProps:function(){return h()},getMonthsInYear:function(t){for(var e=s(t).startOf("year"),n=[],r=0;12>r;r++)n.push(s(e)),e.add(1,"month");return n},render:function(){i=+s().startOf("day");var t=this.props.viewMoment=s(this.props.viewDate);this.props.date&&(this.props.moment=s(this.props.date).startOf("month"));var e=this.getMonthsInYear(t);return o.createElement("table",{className:"dp-table dp-year-view"},o.createElement("tbody",null,this.renderMonths(e)))},renderMonths:function(t){for(var e=t.map(this.renderMonth,this),n=t.length,r=[],i=Math.ceil(n/4),s=0;i>s;s++)r.push(e.slice(4*s,4*(s+1)));return r.map(function(t,e){return o.createElement("tr",{key:"row"+e},t)})},renderMonth:function(t){var e=a.month(t),n=["dp-cell dp-month"],r=+t;return r==this.props.moment&&n.push("dp-value"),o.createElement("td",{key:e,className:n.join(" "),onClick:this.handleClick.bind(this,t)},e)},handleClick:function(t,e){e.target.value=t,(this.props.onSelect||r)(t,e)}});u.getHeaderText=function(t){return l(t).format("YYYY")},t.exports=u},function(t,e,n){"use strict";function r(){}var i=n(1),o=n(2),s=n(4),a=n(5),h=n(15),l=n(16),u=n(13),p=n(14),c=n(3),f=(n(9),function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}),d={month:h,year:l,decade:u},m=(n(10),i.createClass({displayName:"DatePicker",propTypes:{todayText:i.PropTypes.string,gotoSelectedText:i.PropTypes.string,renderFooter:i.PropTypes.func,onChange:i.PropTypes.func,date:i.PropTypes.any,viewDate:i.PropTypes.any},getViewOrder:function(){return["month","year","decade"]},getDefaultProps:function(){var t=a({},s());return delete t.viewDate,delete t.date,t},getInitialState:function(){return{view:this.props.defaultView,viewDate:this.props.defaultViewDate}},getViewName:function(){return null!=this.props.view?this.props.view:this.state.view||"month"},addViewIndex:function(t){var e=this.getViewName(),n=this.getViewOrder(),r=n.indexOf(e);return r+=t,r%n.length},getNextViewName:function(){return this.getViewOrder()[this.addViewIndex(1)]},getPrevViewName:function(){return this.getViewOrder()[this.addViewIndex(-1)]},getView:function(){return d[this.getViewName()]||d.month},getViewFactory:function(){var t=this.getView();return i.createFactory&&(t.__factory=t.__factory||i.createFactory(t),t=t.__factory),t},getViewDate:function(){var t=f(this.props,"viewDate")?this.props.viewDate:this.state.viewDate;return t=this.toMoment(t||this.props.date||new Date)},render:function(){this.toMoment=function(t){return c(t,this.props.dateFormat)};var t=this.getViewFactory(),e=s(this.props);e.viewDate=this.getViewDate(),e.renderDay=this.props.renderDay,e.onRenderDay=this.props.onRenderDay,e.onChange=this.handleChange,e.onSelect=this.handleSelect;var n=(this.props.className||"")+" date-picker";return i.createElement("div",i.__spread({className:n},this.props),i.createElement("div",{className:"dp-inner"},this.renderHeader(t),i.createElement("div",{className:"dp-body"},i.createElement("div",{className:"dp-anim-target"},t(e))),this.renderFooter(e)))},renderFooter:function(t){if(!this.props.hideFooter){this.props.today&&console.warn('Please use "todayText" prop instead of "today"!'),this.props.gotoSelected&&console.warn('Please use "gotoSelectedText" prop instead of "gotoSelected"!');var e,n=this.props.todayText||"Today",r=this.props.gotoSelectedText||"Go to selected",o={todayText:n,gotoSelectedText:r,onTodayClick:this.gotoNow,onGotoSelectedClick:this.gotoSelected,date:t.date,viewDate:t.viewDate};return"function"==typeof this.props.renderFooter&&(e=this.props.renderFooter(o)),void 0!==e?e:i.createElement("div",{className:"dp-footer"},i.createElement("div",{className:"dp-footer-today",onClick:this.gotoNow},n),i.createElement("div",{className:"dp-footer-selected",onClick:this.gotoSelected},r))}},gotoNow:function(){this.gotoDate(+new Date)},gotoSelected:function(){this.gotoDate(this.props.date||+new Date)},gotoDate:function(t){this.setView("month"),this.setViewDate(t)},getViewColspan:function(){var t={month:5,year:2,decade:2};return t[this.getViewName()]},renderHeader:function(){var t=this.getViewDate(),e=this.getView().getHeaderText(t),n=this.getViewColspan(),r=this.props.navPrev,o=this.props.navNext;return i.createElement(p,{prevText:r,nextText:o,colspan:n,onPrev:this.handlePrevNav,onNext:this.handleNextNav,onChange:this.handleViewChange},e)},handleRenderDay:function(t){return(this.props.renderDay||r)(t)||[]},handleViewChange:function(){this.setView(this.getNextViewName())},setView:function(t){"function"==typeof this.props.onViewChange&&this.props.onViewChange(t),null==this.props.view&&this.setState({view:t})},setViewDate:function(t){t=this.toMoment(t);var e=this.props.onViewDateChange;if("function"==typeof e){var n=t.format(this.props.dateFormat),r=this.getViewName();e(t,n,r)}f(this.props,"viewDate")||this.setState({viewDate:t})},getNext:function(){var t=this.getViewDate();return{month:function(){return o(t).add(1,"month")},year:function(){return o(t).add(1,"year")},decade:function(){return o(t).add(10,"year")}}[this.getViewName()]()},getPrev:function(){var t=this.getViewDate();return{month:function(){return o(t).add(-1,"month")},year:function(){return o(t).add(-1,"year")},decade:function(){return o(t).add(-10,"year")}}[this.getViewName()]()},handleNavigation:function(t,e){var n=-1==t?this.getPrev():this.getNext();if(this.setViewDate(n),"function"==typeof this.props.onNav){var r=n.format(this.props.dateFormat),i=this.getViewName();this.props.onNav(n,r,i,t,e)}},handlePrevNav:function(t){this.handleNavigation(-1,t)},handleNextNav:function(t){this.handleNavigation(1,t)},handleChange:function(t,e){t=o(t);var n=t.format(this.props.dateFormat);(this.props.onChange||r)(t,n,e)},handleSelect:function(t,e){var n=this.getViewName(),r={decade:"year",year:"month"}[n],i=t.get(r),s=o(this.getViewDate()).set(r,i),a=this.getPrevViewName();if(this.setViewDate(s),this.setView(a),"function"==typeof this.props.onSelect){var h=s.format(this.props.dateFormat);this.props.onSelect(s,h,a,e)}}}));t.exports=m},function(t,e,n){"use strict";function r(){}var i=n(36),o=n(1),s={"true":{display:"inline-block"},"false":{cursor:"text",color:"transparent"}},a={displayName:"ReactInputField",propTypes:{validate:o.PropTypes.oneOfType([o.PropTypes.func,o.PropTypes.bool]),isEmpty:o.PropTypes.func,clearTool:o.PropTypes.bool},getInitialState:function(){return{defaultValue:this.props.defaultValue}},getDefaultProps:function(){return{focusOnClick:!0,defaultClearToolStyle:{fontSize:20,paddingRight:5,paddingLeft:5,alignSelf:"center",cursor:"pointer",userSelect:"none",boxSizing:"border-box"},clearToolColor:"#a8a8a8",clearToolOverColor:"#7F7C7C",defaultStyle:{display:"inline-flex",flexFlow:"row",alignItems:"stretch",border:"1px solid #a8a8a8",boxSizing:"border-box"},defaultInvalidStyle:{border:"1px solid rgb(248, 144, 144)"},defaultInputStyle:{flex:1,border:0,height:"100%",padding:"6px 2px",outline:"none",boxSizing:"border-box"},defaultInputInvalidStyle:{},emptyValue:"",inputClassName:"",inputProps:null,clearTool:!0,defaultClassName:"z-field",emptyClassName:"z-empty-value",invalidClassName:"z-invalid",toolsPosition:"right"}},render:function(){void 0===this.valid&&(this.valid=!0);var t=this.prepareProps(this.props,this.state);this.valid!==t.valid&&"function"==typeof t.onValidityChange&&setTimeout(function(){t.onValidityChange(t.valid,t.value,t)},0),this.valid=t.valid,t.children=this.renderChildren(t,this.state);var e=i({},t);return delete e.value,delete e.placeholder,o.createElement("div",o.__spread({},e))},renderChildren:function(t,e){var n=this.renderField(t,e),r=this.renderTools(t,e),i=[n,t.children];return"after"==t.toolsPosition||"right"==t.toolsPosition?i.push.apply(i,r):i=(r||[]).concat(n),i},renderField:function(t){var e=this.prepareInputProps(t);return e.ref="input",t.inputFactory?t.inputFactory(e,t):o.createElement("input",o.__spread({},e))},renderTools:function(t,e){var n=this.renderClearTool(t,e),r=[n];return"function"==typeof t.tools&&(r=t.tools(t,n)),r},renderClearTool:function(t,e){if(t.clearTool&&!t.readOnly&&!t.disabled){var n=!this.isEmpty(t),r=s[n],a=i({},r,this.prepareClearToolStyle(t,e));return n||i(a,r),o.createElement("div",{className:"z-clear-tool",onClick:this.handleClearToolClick,onMouseDown:this.handleClearToolMouseDown,onMouseOver:this.handleClearToolOver,onMouseOut:this.handleClearToolOut,style:a},"✖")}},handleClearToolMouseDown:function(t){t.preventDefault()},handleClearToolOver:function(){this.setState({clearToolOver:!0})},handleClearToolOut:function(){this.setState({clearToolOver:!1})},isEmpty:function(t){var e=this.getEmptyValue(t);return"function"==typeof t.isEmpty?t.isEmpty(t,e):t.value+""==e+""},getEmptyValue:function(t){var e=t.emptyValue;return"function"==typeof e&&(e=e(t)),e},isValid:function(t){var e=t.value,n=!0;return"function"==typeof t.validate&&(n=t.validate(e,t)!==!1),n},getInput:function(){return this.refs.input.getDOMNode()},focus:function(){var t=this.getInput();t&&"function"==typeof t.focus&&t.focus()},handleClick:function(){this.props.focusOnClick&&!this.isFocused()&&this.focus()},handleMouseDown:function(t){(this.props.onMouseDown||r)(t)},handleClearToolClick:function(t){this.notify(this.getEmptyValue(this.props),t)},handleChange:function(t){t.stopPropagation(),this.notify(t.target.value,t)},handleSelect:function(t){t.stopPropagation(),(this.props.onSelect||r)(t)},notify:function(t,e){void 0===this.props.value&&this.setState({defaultValue:t}),(this.props.onChange||r)(t,this.props,e)},prepareProps:function(t,e){var n={};return i(n,t),n.value=this.prepareValue(n,e),n.valid=this.isValid(n),n.onClick=this.handleClick,n.onMouseDown=this.handleMouseDown,n.className=this.prepareClassName(n),n.style=this.prepareStyle(n),n},prepareValue:function(t,e){var n=void 0===t.value?e.defaultValue:t.value;return n},prepareClassName:function(t){var e=[t.className,t.defaultClassName];return this.isEmpty(t)&&e.push(t.emptyClassName),t.valid||e.push(t.invalidClassName),e.join(" ")},prepareStyle:function(t){var e=i({},t.defaultStyle,t.style);return t.valid||i(e,t.defaultInvalidStyle,t.invalidStyle),e},prepareInputProps:function(t){var e={className:t.inputClassName};return i(e,t.defaultInputProps,t.inputProps),e.key="field",e.value=t.value,e.placeholder=t.placeholder,e.onChange=this.handleChange,e.onSelect=this.handleSelect,e.style=this.prepareInputStyle(t),e.onFocus=this.handleFocus,e.onBlur=this.handleBlur,e.name=t.name,e.disabled=t.disabled,e.readOnly=t.readOnly,e},handleFocus:function(){this._focused=!0},handleBlur:function(){this._focused=!1},isFocused:function(){return!!this._focused},prepareInputStyle:function(t){var e=t.inputProps?t.inputProps.style:null,n=i({},t.defaultInputStyle,t.inputStyle,e);return t.valid||i(n,t.defaultInputInvalidStyle,t.inputInvalidStyle),n},prepareClearToolStyle:function(t,e){var n,r,o;e&&e.clearToolOver&&(n=t.defaultClearToolOverStyle,r=t.clearToolOverStyle),t.clearToolColor&&(o={color:t.clearToolColor},e&&e.clearToolOver&&t.clearToolOverColor&&(o={color:t.clearToolOverColor}));var s=i({},t.defaultClearToolStyle,n,o,t.clearToolStyle,r);return s}},h=o.createClass(a);h.descriptor=a,t.exports=h},function(t){function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function r(t){return"number"==typeof t}function i(t){return"object"==typeof t&&null!==t}function o(t){return void 0===t}t.exports=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(t){if(!r(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},e.prototype.emit=function(t){var e,r,s,a,h,l;if(this._events||(this._events={}),"error"===t&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],o(r))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,a=new Array(s-1),h=1;s>h;h++)a[h-1]=arguments[h];r.apply(this,a)}else if(i(r)){for(s=arguments.length,a=new Array(s-1),h=1;s>h;h++)a[h-1]=arguments[h];for(l=r.slice(),s=l.length,h=0;s>h;h++)l[h].apply(this,a)}return!0},e.prototype.addListener=function(t,r){var s;if(!n(r))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(r.listener)?r.listener:r),this._events[t]?i(this._events[t])?this._events[t].push(r):this._events[t]=[this._events[t],r]:this._events[t]=r,i(this._events[t])&&!this._events[t].warned){var s;s=o(this._maxListeners)?e.defaultMaxListeners:this._maxListeners,s&&s>0&&this._events[t].length>s&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},e.prototype.removeListener=function(t,e){var r,o,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,o=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(i(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){o=a;break}if(0>o)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},e.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},e.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},e.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},function(t){"use strict";t.exports={dateFormat:"YYYY-MM-DD"}},function(t){"use strict";var e=Object.prototype.toString;t.exports=function(t){return"[object Date]"===e.apply(t)}},function(t,e,n){"use strict";t.exports=n(9)},function(t,e,n){"use strict";t.exports=n(3)},function(t){"use strict";t.exports=function(t){return t?t.charAt(0).toUpperCase()+t.substring(1):t}},function(t,e,n){"use strict";var r=n(26),i=(n(8),n(33));t.exports=function(t,e,n){var o;if(n===!0&&(o=r.getDocRegion()),!o&&"string"==typeof n){var s=i(n,this.getDOMNode());o=r.from(s)}o||"function"!=typeof n||(o=r.from(n()));var a=this.refs.field;if(a){var h=r.from(a.getDOMNode());if("function"==typeof t.constrainPicker)return void t.constrainPicker(e,h,o);if(o&&o instanceof r){var l=h.top-o.top,u=o.bottom-h.bottom,p=e.style;l>u&&(p.bottom="100%",delete p.top)}}}},function(t,e,n){t.exports=n(29)},function(t){t.exports=function(){"use strict";var t={};return function(e){if(!t[e]){for(var n=[],r=0;e>r;r++)n.push("a["+r+"]");t[e]=new Function("c","a","return new c("+n.join(",")+")")}return t[e]}}()},function(t,e,n){var r=n(27);t.exports=function(t,e){return r(e.length)(t,e)}},function(t,e,n){"use strict";function r(t,e,n){return t&&n.forEach(function(n){e[n]=t[n]}),e}var i=n(11),o=n(28),s=n(8),a=n(19).EventEmitter,h=n(30),l=n(12),u=Object.prototype.toString,p=function(t){return"[object Object]"===u.apply(t)},c={cy:"YCenter",cx:"XCenter",t:"Top",tc:"TopCenter",tl:"TopLeft",tr:"TopRight",b:"Bottom",bc:"BottomCenter",bl:"BottomLeft",br:"BottomRight",l:"Left",lc:"LeftCenter",r:"Right",rc:"RightCenter",c:"Center"},f=function(t,e,n,i){return this instanceof f?(a.call(this),p(t)?(r(t,this,["top","right","bottom","left"]),null==t.bottom&&null!=t.height&&(this.bottom=this.top+t.height),null==t.right&&null!=t.width&&(this.right=this.left+t.width),t.emitChangeEvents&&(this.emitChangeEvents=t.emitChangeEvents)):(this.top=t,this.right=e,this.bottom=n,this.left=i),this[0]=this.left,this[1]=this.top,void l(this)):o(f,arguments)};h(f,a),s(f.prototype,{emitChangeEvents:!1,getRegion:function(t){return t?this.clone():this},setRegion:function(t){return this.set(t instanceof f?t.get():t),this},validate:function(){return f.validate(this)},_before:function(){return this.emitChangeEvents?r(this,{},["left","top","bottom","right"]):void 0},_after:function(t){this.emitChangeEvents&&((this.top!=t.top||this.left!=t.left)&&this.emitPositionChange(),(this.right!=t.right||this.bottom!=t.bottom)&&this.emitSizeChange())},notifyPositionChange:function(){this.emit("changeposition",this)},emitPositionChange:function(){this.notifyPositionChange()},notifySizeChange:function(){this.emit("changesize",this)},emitSizeChange:function(){this.notifySizeChange()},add:function(t){var e,n=this._before();for(e in t)i(t,e)&&(this[e]+=t[e]);return this[0]=this.left,this[1]=this.top,this._after(n),this},substract:function(t){var e,n=this._before();for(e in t)i(t,e)&&(this[e]-=t[e]);return this[0]=this.left,this[1]=this.top,this._after(n),this},getSize:function(){return{width:this.width,height:this.height}},setPosition:function(t){var e=this.width,n=this.height;return void 0!=t.left&&(t.right=t.left+e),void 0!=t.top&&(t.bottom=t.top+n),this.set(t)},setSize:function(t){return void 0!=t.height&&void 0!=t.width?this.set({right:this.left+t.width,bottom:this.top+t.height}):(void 0!=t.width&&this.setWidth(t.width),void 0!=t.height&&this.setHeight(t.height),this)},setWidth:function(t){return this.set({right:this.left+t})},setHeight:function(t){return this.set({bottom:this.top+t})},set:function(t){var e=this._before();return r(t,this,["left","top","bottom","right"]),null==t.bottom&&null!=t.height&&(this.bottom=this.top+t.height),null==t.right&&null!=t.width&&(this.right=this.left+t.width),this[0]=this.left,this[1]=this.top,this._after(e),this},get:function(t){return t?this[t]:r(this,{},["left","right","top","bottom"])},shift:function(t){var e=this._before();return t.top&&(this.top+=t.top,this.bottom+=t.top),t.left&&(this.left+=t.left,this.right+=t.left),this[0]=this.left,this[1]=this.top,this._after(e),this},unshift:function(t){return t.top&&(t.top*=-1),t.left&&(t.left*=-1),this.shift(t)},equals:function(t){return this.equalsPosition(t)&&this.equalsSize(t)},equalsSize:function(t){var e=t instanceof f,n={width:null==t.width&&e?t.getWidth():t.width,height:null==t.height&&e?t.getHeight():t.height};return this.getWidth()==n.width&&this.getHeight()==n.height},equalsPosition:function(t){return this.top==t.top&&this.left==t.left},addLeft:function(t){var e=this._before();return this.left=this[0]=this.left+t,this._after(e),this},addTop:function(t){var e=this._before();return this.top=this[1]=this.top+t,this._after(e),this
},addBottom:function(t){var e=this._before();return this.bottom+=t,this._after(e),this},addRight:function(t){var e=this._before();return this.right+=t,this._after(e),this},minTop:function(){return this.expand({top:1})},maxBottom:function(){return this.expand({bottom:1})},minLeft:function(){return this.expand({left:1})},maxRight:function(){return this.expand({right:1})},expand:function(t,e){var n,o=e||f.getDocRegion(),s=[],a=this._before();for(n in t)i(t,n)&&s.push(n);return r(o,this,s),this[0]=this.left,this[1]=this.top,this._after(a),this},clone:function(){return new f({top:this.top,left:this.left,right:this.right,bottom:this.bottom})},containsPoint:function(t,e){return 1==arguments.length&&(e=t.y,t=t.x),this.left<=t&&t<=this.right&&this.top<=e&&e<=this.bottom},containsRegion:function(t){return this.containsPoint(t.left,t.top)&&this.containsPoint(t.right,t.bottom)},diffHeight:function(t){return this.diff(t,{top:!0,bottom:!0})},diffWidth:function(t){return this.diff(t,{left:!0,right:!0})},diff:function(t,e){var n,r={};for(n in e)i(e,n)&&(r[n]=this[n]-t[n]);return r},getPosition:function(){return{left:this.left,top:this.top}},getPoint:function(t,e){c[t]||console.warn("The position ",t," could not be found! Available options are tl, bl, tr, br, l, r, t, b.");var n="getPoint"+c[t],r=this[n]();return e?{left:r.x,top:r.y}:r},getPointYCenter:function(){return{x:null,y:this.top+this.getHeight()/2}},getPointXCenter:function(){return{x:this.left+this.getWidth()/2,y:null}},getPointTop:function(){return{x:null,y:this.top}},getPointTopCenter:function(){return{x:this.left+this.getWidth()/2,y:this.top}},getPointTopLeft:function(){return{x:this.left,y:this.top}},getPointTopRight:function(){return{x:this.right,y:this.top}},getPointBottom:function(){return{x:null,y:this.bottom}},getPointBottomCenter:function(){return{x:this.left+this.getWidth()/2,y:this.bottom}},getPointBottomLeft:function(){return{x:this.left,y:this.bottom}},getPointBottomRight:function(){return{x:this.right,y:this.bottom}},getPointLeft:function(){return{x:this.left,y:null}},getPointLeftCenter:function(){return{x:this.left,y:this.top+this.getHeight()/2}},getPointRight:function(){return{x:this.right,y:null}},getPointRightCenter:function(){return{x:this.right,y:this.top+this.getHeight()/2}},getPointCenter:function(){return{x:this.left+this.getWidth()/2,y:this.top+this.getHeight()/2}},getHeight:function(){return this.bottom-this.top},getWidth:function(){return this.right-this.left},getTop:function(){return this.top},getLeft:function(){return this.left},getBottom:function(){return this.bottom},getRight:function(){return this.right},getArea:function(){return this.getWidth()*this.getHeight()},constrainTo:function(t){var e,n=this.getIntersection(t);if(!n||!n.equals(this)){var r=t.getWidth(),i=t.getHeight();return this.getWidth()>r&&(this.left=t.left,this.setWidth(r)),this.getHeight()>i&&(this.top=t.top,this.setHeight(i)),e={},this.right>t.right&&(e.left=t.right-this.right),this.bottom>t.bottom&&(e.top=t.bottom-this.bottom),this.left<t.left&&(e.left=t.left-this.left),this.top<t.top&&(e.top=t.top-this.top),this.shift(e),!0}return!1},__IS_REGION:!0}),Object.defineProperties(f.prototype,{width:{get:function(){return this.getWidth()},set:function(t){return this.setWidth(t)}},height:{get:function(){return this.getHeight()},set:function(t){return this.setHeight(t)}}}),n(31)(f),t.exports=f},function(t){"use strict";t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}},function(t,e,n){"use strict";var r=n(11),i=n(12);t.exports=function(t){var e=Math.max,n=Math.min,o={init:function(){var e,n,i={getIntersection:!0,getIntersectionArea:!0,getIntersectionHeight:!0,getIntersectionWidth:!0,getUnion:!0},o=t.prototype,s=r(i);for(n in i)s(n)&&(e=i[n],"string"!=typeof e&&(e=n),function(e,n,r){e[n]=function(e){return t[r]||console.warn("cannot find method ",r," on ",t),t[r](this,e)}}(o,e,n))},validate:i,getDocRegion:function(){return t.fromDOM(document.documentElement)},from:function(e){if(e.__IS_REGION)return e;if("undefined"!=typeof document){if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return t.fromDOM(e);if(e.type&&"undefined"!=typeof e.pageX&&"undefined"!=typeof e.pageY)return t.fromEvent(e)}return t(e)},fromEvent:function(e){return t.fromPoint({x:e.pageX,y:e.pageY})},fromDOM:function(e){var n=e.getBoundingClientRect();return new t({top:n.top,left:n.left,bottom:n.bottom,right:n.right})},getIntersection:function(e,n){var r=this.getIntersectionArea(e,n);return r?new t(r):!1},getIntersectionWidth:function(t,r){var i=n(t.right,r.right),o=e(t.left,r.left);return i>o?i-o:0},getIntersectionHeight:function(t,r){var i=e(t.top,r.top),o=n(t.bottom,r.bottom);return o>i?o-i:0},getIntersectionArea:function(t,r){var i=e(t.top,r.top),o=n(t.right,r.right),s=n(t.bottom,r.bottom),a=e(t.left,r.left);return s>i&&o>a?{top:i,right:o,bottom:s,left:a,width:o-a,height:s-i}:!1},getUnion:function(r,i){var o=n(r.top,i.top),s=e(r.right,i.right),a=e(r.bottom,i.bottom),h=n(r.left,i.left);return new t(o,s,a,h)},getRegion:function(e){return t.from(e)},fromPoint:function(e){return new t({top:e.y,bottom:e.y,left:e.x,right:e.x})}};Object.keys(o).forEach(function(e){t[e]=o[e]}),t.init()}},function(t){"use strict";function e(t,e){function n(r){function i(){var i=arguments.length,o=[].concat(r);return i&&o.push.apply(o,arguments),o.length<e?n(o):t.apply(this,o)}return i}return"number"!=typeof e&&(e=t.length),n([])}t.exports=e},function(t,e,n){"use strict";var r=n(32),i=n(34);t.exports=r(function(t,e){for(;e=e.parentElement;)if(i.call(e,t))return e})},function(t){"use strict";var e=Element.prototype,n=e.matches||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector;t.exports=n},24,5,function(t,e,n){"use strict";function r(){}function i(t,e,n){Object.keys(t).forEach(function(t){s(n,t)&&(e[t]=n[t])})}var o=n(8),s=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a=(n(35),n(25)),h={style:!0,className:!0};t.exports={_prepareWrapperProps:function(t){var e=o({},t.wrapperProps);return i(h,e,t),e},_prepareFieldProps:function(t){var e=o({},t);return delete e.style,delete e.className,delete e.fieldProps,delete e.defaultStyle,delete e.readOnly,o(e,t.fieldProps),t.readOnly&&(e.inputProps=o({},e.inputProps),e.inputProps.style=o({cursor:"pointer"},e.inputProps.style)),e.ref="field",e.style=o({},t.fieldStyle,e.style),e.onFocus=this.handleFocus,e.onBlur=this.handleBlur,e.onKeyDown=(this.handleKeyDown||r).bind(this,t),e.onChange=(this.handleChange||r).bind(this,t),delete e.data,e},_preparePickerProps:function(t){var e=o({},t.pickerProps);return e.style=o({},t.defaultPickerStyle,t.pickerStyle,e.style),e.ref="picker",e},_constrainPicker:a,_renderPicker:function(t,e){var n=t.pickerProps,r=e.pickerVisible;r||(n.style.display="none"),r&&t.constrainTo&&(this.constrainPicker||this._constrainPicker)(t,n,t.constrainTo);var i=this.props.defaultPickerFactory,o=(t.pickerFactory||i)(n);return void 0===o&&(o=i(n)),o},_isFocused:function(){return this.refs.field.isFocused()},_getInput:function(){return this.refs.field?this.refs.field.getInput():null},_focus:function(){this.refs.field.focus()},_notify:function(t,e){this.refs.field.notify(t,e)},_isPickerVisible:function(){return null==this.props.pickerVisible?this.state.pickerVisible:this.props.pickerVisible}}}]))});