react-datetime
Advanced tools
Comparing version 2.2.0 to 2.2.1
Changelog | ||
========= | ||
## 2.2.1 | ||
* Controlled datepicker now working for controlled datepickers | ||
## 2.2.0 | ||
@@ -4,0 +7,0 @@ * The picker can be used as a month or year picker just giving a format date without days/months |
@@ -95,3 +95,3 @@ 'use strict'; | ||
inputValue: selectedDate ? selectedDate.format( formats.datetime ) : (date || ''), | ||
open: props.open != undefined ? props.open : this.state && this.state.open | ||
open: props.open | ||
}; | ||
@@ -250,3 +250,3 @@ }, | ||
date | ||
; | ||
; | ||
@@ -283,9 +283,11 @@ if(target.className.indexOf("rdtDay") != -1){ | ||
viewDate: date.clone().startOf('month'), | ||
inputValue: date.format( this.state.inputFormat ) | ||
}, function () { | ||
if (this.props.closeOnSelect && close) { | ||
this.closeCalendar(); | ||
} | ||
inputValue: date.format( this.state.inputFormat ), | ||
open: !(this.props.closeOnSelect && close ) | ||
}); | ||
} | ||
else { | ||
if (this.props.closeOnSelect && close) { | ||
this.closeCalendar(); | ||
} | ||
} | ||
@@ -304,2 +306,3 @@ this.props.onChange( date ); | ||
this.setState({ open: false }); | ||
this.props.onBlur( this.state.selectedDate || this.state.inputValue ); | ||
}, | ||
@@ -306,0 +309,0 @@ |
/* | ||
react-datetime v2.1.0 | ||
react-datetime v2.2.1 | ||
https://github.com/arqex/react-datetime | ||
@@ -62,3 +62,3 @@ MIT: https://github.com/arqex/react-datetime/raw/master/LICENSE | ||
eval("'use strict';\n\nvar assign = __webpack_require__(1),\n\tReact = __webpack_require__(2),\n\tDaysView = __webpack_require__(3),\n\tMonthsView = __webpack_require__(5),\n\tYearsView = __webpack_require__(6),\n\tTimeView = __webpack_require__(7),\n\tmoment = __webpack_require__(4)\n;\n\nvar TYPES = React.PropTypes;\nvar Datetime = React.createClass({\n\tmixins: [\n\t\t__webpack_require__(8)\n\t],\n\tviewComponents: {\n\t\tdays: DaysView,\n\t\tmonths: MonthsView,\n\t\tyears: YearsView,\n\t\ttime: TimeView\n\t},\n\tpropTypes: {\n\t\t// value: TYPES.object | TYPES.string,\n\t\t// defaultValue: TYPES.object | TYPES.string,\n\t\tcloseOnSelect: TYPES.bool,\n\t\tonFocus: TYPES.func,\n\t\tonBlur: TYPES.func,\n\t\tonChange: TYPES.func,\n\t\tlocale: TYPES.string,\n\t\tinput: TYPES.bool,\n\t\t// dateFormat: TYPES.string | TYPES.bool,\n\t\t// timeFormat: TYPES.string | TYPES.bool,\n\t\tinputProps: TYPES.object,\n\t\tviewMode: TYPES.oneOf(['years', 'months', 'days', 'time']),\n\t\tisValidDate: TYPES.func,\n\t\topen: TYPES.bool,\n\t\tstrictParsing: TYPES.bool\n\t},\n\n\tgetDefaultProps: function() {\n\t\tvar nof = function(){};\n\t\treturn {\n\t\t\tclassName: '',\n\t\t\tdefaultValue: '',\n\t\t\tviewMode: 'days',\n\t\t\tinputProps: {},\n\t\t\tinput: true,\n\t\t\tonFocus: nof,\n\t\t\tonBlur: nof,\n\t\t\tonChange: nof,\n\t\t\ttimeFormat: true,\n\t\t\tdateFormat: true,\n\t\t\tstrictParsing: true\n\t\t};\n\t},\n\n\tgetInitialState: function() {\n\t\tvar state = this.getStateFromProps( this.props );\n\n\t\tif( state.open == undefined )\n\t\t\tstate.open = !this.props.input;\n\n\t\tstate.currentView = this.props.dateFormat ? this.props.viewMode : 'time';\n\n\t\treturn state;\n\t},\n\n\tgetStateFromProps: function( props ){\n\t\tvar formats = this.getFormats( props ),\n\t\t\tdate = props.value || props.defaultValue,\n\t\t\tselectedDate, viewDate, updateOn\n\t\t;\n\n\t\tif( date && typeof date == 'string' )\n\t\t\tselectedDate = this.localMoment( date, formats.datetime );\n\t\telse if( date )\n\t\t\tselectedDate = this.localMoment( date );\n\n\t\tif( selectedDate && !selectedDate.isValid() )\n\t\t\tselectedDate = null;\n\n\t\tviewDate = selectedDate ?\n\t\t\tselectedDate.clone().startOf(\"month\") :\n\t\t\tthis.localMoment().startOf(\"month\")\n\t\t;\n\n\t\tupdateOn = this.getUpdateOn(formats);\n\n\t\treturn {\n\t\t\tupdateOn: updateOn,\n\t\t\tinputFormat: formats.datetime,\n\t\t\tviewDate: viewDate,\n\t\t\tselectedDate: selectedDate,\n\t\t\tinputValue: selectedDate ? selectedDate.format( formats.datetime ) : (date || ''),\n\t\t\topen: props.open != undefined ? props.open : this.state && this.state.open\n\t\t};\n\t},\n\n\tgetUpdateOn: function(formats){\n\t\tif(formats.datetime.indexOf(\"D\") != -1){\n\t\t\treturn \"date\";\n\t\t}else if(formats.datetime.indexOf(\"M\") != -1){\n\t\t\treturn \"month\";\n\t\t}else if(formats.datetime.indexOf(\"Y\") != -1){\n\t\t\treturn \"year\";\n\t\t}\n\t},\n\n\tgetFormats: function( props ){\n\t\tvar formats = {\n\t\t\t\tdate: props.dateFormat || '',\n\t\t\t\ttime: props.timeFormat || ''\n\t\t\t},\n\t\t\tlocale = this.localMoment( props.date ).localeData()\n\t\t;\n\n\t\tif( formats.date === true ){\n\t\t\tformats.date = locale.longDateFormat('L');\n\t\t}\n\t\tif( formats.time === true ){\n\t\t\tformats.time = locale.longDateFormat('LT');\n\t\t}\n\n\t\tformats.datetime = formats.date && formats.time ?\n\t\t\tformats.date + ' ' + formats.time :\n\t\t\tformats.date || formats.time\n\t\t;\n\n\t\treturn formats;\n\t},\n\n\tcomponentWillReceiveProps: function(nextProps) {\n\t\tvar formats = this.getFormats( nextProps ),\n\t\t\tupdate = {}\n\t\t;\n\n\t\tif( nextProps.value != this.props.value ){\n\t\t\tupdate = this.getStateFromProps( nextProps );\n\t\t}\n\t\tif ( formats.datetime !== this.getFormats( this.props ).datetime ) {\n\t\t\tupdate.inputFormat = formats.datetime;\n\t\t}\n\n\t\tthis.setState( update );\n\t},\n\n\tonInputChange: function( e ) {\n\t\tvar value = e.target == null ? e : e.target.value,\n\t\t\tlocalMoment = this.localMoment( value, this.state.inputFormat ),\n\t\t\tupdate = { inputValue: value }\n\t\t;\n\n\t\tif ( localMoment.isValid() && !this.props.value ) {\n\t\t\tupdate.selectedDate = localMoment;\n\t\t\tupdate.viewDate = localMoment.clone().startOf(\"month\");\n\t\t}\n\t\telse {\n\t\t\tupdate.selectedDate = null;\n\t\t}\n\n\t\treturn this.setState( update, function() {\n\t\t\treturn this.props.onChange( localMoment.isValid() ? localMoment : this.state.inputValue );\n\t\t});\n\t},\n\n\tshowView: function( view ){\n\t\tvar me = this;\n\t\treturn function( e ){\n\t\t\tme.setState({ currentView: view });\n\t\t};\n\t},\n\n\tsetDate: function( type ){\n\t\tvar me = this,\n\t\t\tnextViews = {\n\t\t\t\tmonth: 'days',\n\t\t\t\tyear: 'months'\n\t\t\t}\n\t\t;\n\t\treturn function( e ){\n\t\t\tme.setState({\n\t\t\t\tviewDate: me.state.viewDate.clone()[ type ]( parseInt(e.target.getAttribute('data-value')) ).startOf( type ),\n\t\t\t\tcurrentView: nextViews[ type ]\n\t\t\t});\n\t\t};\n\t},\n\n\taddTime: function( amount, type, toSelected ){\n\t\treturn this.updateTime( 'add', amount, type, toSelected );\n\t},\n\n\tsubtractTime: function( amount, type, toSelected ){\n\t\treturn this.updateTime( 'subtract', amount, type, toSelected );\n\t},\n\n\tupdateTime: function( op, amount, type, toSelected ){\n\t\tvar me = this;\n\n\t\treturn function(){\n\t\t\tvar update = {},\n\t\t\t\tdate = toSelected ? 'selectedDate' : 'viewDate'\n\t\t\t;\n\n\t\t\tupdate[ date ] = me.state[ date ].clone()[ op ]( amount, type );\n\n\t\t\tme.setState( update );\n\t\t};\n\t},\n\n\tallowedSetTime: ['hours','minutes','seconds', 'milliseconds'],\n\tsetTime: function( type, value ){\n\t\tvar index = this.allowedSetTime.indexOf( type ) + 1,\n\t\t\tstate = this.state,\n\t\t\tdate = (state.selectedDate || state.viewDate).clone(),\n\t\t\tnextType\n\t\t;\n\n\t\t// It is needed to set all the time properties\n\t\t// to not to reset the time\n\t\tdate[ type ]( value );\n\t\tfor (; index < this.allowedSetTime.length; index++) {\n\t\t\tnextType = this.allowedSetTime[index];\n\t\t\tdate[ nextType ]( date[nextType]() );\n\t\t}\n\n\t\tif( !this.props.value ){\n\t\t\tthis.setState({\n\t\t\t\tselectedDate: date,\n\t\t\t\tinputValue: date.format( state.inputFormat )\n\t\t\t});\n\t\t}\n\t\tthis.props.onChange( date );\n\t},\n\n\tupdateSelectedDate: function( e, close ) {\n\t\tvar target = e.target,\n\t\t\tmodifier = 0,\n\t\t\tviewDate = this.state.viewDate,\n\t\t\tcurrentDate = this.state.selectedDate || viewDate,\n\t\t\tdate\n ;\n\n\t\tif(target.className.indexOf(\"rdtDay\") != -1){\n\t\t\tif(target.className.indexOf(\"rdtNew\") != -1)\n\t\t\t\tmodifier = 1;\n\t\t\telse if(target.className.indexOf(\"rdtOld\") != -1)\n\t\t\t\tmodifier = -1;\n\n\t\t\tdate = viewDate.clone()\n\t\t\t\t.month( viewDate.month() + modifier )\n\t\t\t\t.date( parseInt( target.getAttribute('data-value') ) )\n\t\t\t;\n\t\t}else if(target.className.indexOf(\"rdtMonth\") != -1){\n\t\t\tdate = viewDate.clone()\n\t\t\t\t.month( parseInt( target.getAttribute('data-value') ) )\n\t\t\t\t.date( currentDate.date() )\n\t\t}else if(target.className.indexOf(\"rdtYear\") != -1){\n\t\t\tdate = viewDate.clone()\n\t\t\t\t.month( currentDate.month() )\n\t\t\t\t.date( currentDate.date() )\n\t\t\t\t.year( parseInt( target.getAttribute('data-value') ) )\n\t\t}\n\n\t\tdate.hours( currentDate.hours() )\n\t\t\t.minutes( currentDate.minutes() )\n\t\t\t.seconds( currentDate.seconds() )\n\t\t\t.milliseconds( currentDate.milliseconds() )\n\n\t\tif( !this.props.value ){\n\t\t\tthis.setState({\n\t\t\t\tselectedDate: date,\n\t\t\t\tviewDate: date.clone().startOf('month'),\n\t\t\t\tinputValue: date.format( this.state.inputFormat )\n\t\t\t}, function () {\n\t\t\t\tif (this.props.closeOnSelect && close) {\n\t\t\t\t\tthis.closeCalendar();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tthis.props.onChange( date );\n\t},\n\n\topenCalendar: function() {\n\t\tif (!this.state.open) {\n\t\t\tthis.props.onFocus();\n\t\t\tthis.setState({ open: true });\n\t\t}\n\t},\n\n\tcloseCalendar: function() {\n\t\tthis.setState({ open: false });\n\t},\n\n\thandleClickOutside: function(){\n\t\tif( this.props.input && this.state.open && !this.props.open ){\n\t\t\tthis.setState({ open: false });\n\t\t\tthis.props.onBlur( this.state.selectedDate || this.state.inputValue );\n\t\t}\n\t},\n\n\tlocalMoment: function( date, format ){\n\t\tvar m = moment( date, format, this.props.strictParsing );\n\t\tif( this.props.locale )\n\t\t\tm.locale( this.props.locale );\n\t\treturn m;\n\t},\n\n\tcomponentProps: {\n\t\tfromProps: ['value', 'isValidDate', 'renderDay', 'renderMonth', 'renderYear'],\n\t\tfromState: ['viewDate', 'selectedDate', 'updateOn'],\n\t\tfromThis: ['setDate', 'setTime', 'showView', 'addTime', 'subtractTime', 'updateSelectedDate', 'localMoment']\n\t},\n\n\tgetComponentProps: function(){\n\t\tvar me = this,\n\t\t\tformats = this.getFormats( this.props ),\n\t\t\tprops = {dateFormat: formats.date, timeFormat: formats.time}\n\t\t;\n\n\t\tthis.componentProps.fromProps.forEach( function( name ){\n\t\t\tprops[ name ] = me.props[ name ];\n\t\t});\n\t\tthis.componentProps.fromState.forEach( function( name ){\n\t\t\tprops[ name ] = me.state[ name ];\n\t\t});\n\t\tthis.componentProps.fromThis.forEach( function( name ){\n\t\t\tprops[ name ] = me[ name ];\n\t\t});\n\n\t\treturn props;\n\t},\n\n\trender: function() {\n\t\tvar Component = this.viewComponents[ this.state.currentView ],\n\t\t\tDOM = React.DOM,\n\t\t\tclassName = 'rdt ' + this.props.className,\n\t\t\tchildren = []\n\t\t;\n\n\t\tif( this.props.input ){\n\t\t\tchildren = [ DOM.input( assign({\n\t\t\t\tkey: 'i',\n\t\t\t\ttype:'text',\n\t\t\t\tclassName: 'form-control',\n\t\t\t\tonFocus: this.openCalendar,\n\t\t\t\tonChange: this.onInputChange,\n\t\t\t\tvalue: this.state.inputValue\n\t\t\t}, this.props.inputProps ))];\n\t\t}\n\t\telse {\n\t\t\tclassName += ' rdtStatic';\n\t\t}\n\n\t\tif( this.state.open )\n\t\t\tclassName += ' rdtOpen';\n\n\t\treturn DOM.div({className: className}, children.concat(\n\t\t\tDOM.div(\n\t\t\t\t{ key: 'dt', className: 'rdtPicker' },\n\t\t\t\tReact.createElement( Component, this.getComponentProps())\n\t\t\t)\n\t\t));\n\t}\n});\n\n// Make moment accessible through the Datetime class\nDatetime.moment = moment;\n\nmodule.exports = Datetime;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./Datetime.js\n ** module id = 0\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./Datetime.js?"); | ||
eval("'use strict';\n\nvar assign = __webpack_require__(1),\n\tReact = __webpack_require__(2),\n\tDaysView = __webpack_require__(3),\n\tMonthsView = __webpack_require__(5),\n\tYearsView = __webpack_require__(6),\n\tTimeView = __webpack_require__(7),\n\tmoment = __webpack_require__(4)\n;\n\nvar TYPES = React.PropTypes;\nvar Datetime = React.createClass({\n\tmixins: [\n\t\t__webpack_require__(8)\n\t],\n\tviewComponents: {\n\t\tdays: DaysView,\n\t\tmonths: MonthsView,\n\t\tyears: YearsView,\n\t\ttime: TimeView\n\t},\n\tpropTypes: {\n\t\t// value: TYPES.object | TYPES.string,\n\t\t// defaultValue: TYPES.object | TYPES.string,\n\t\tcloseOnSelect: TYPES.bool,\n\t\tonFocus: TYPES.func,\n\t\tonBlur: TYPES.func,\n\t\tonChange: TYPES.func,\n\t\tlocale: TYPES.string,\n\t\tinput: TYPES.bool,\n\t\t// dateFormat: TYPES.string | TYPES.bool,\n\t\t// timeFormat: TYPES.string | TYPES.bool,\n\t\tinputProps: TYPES.object,\n\t\tviewMode: TYPES.oneOf(['years', 'months', 'days', 'time']),\n\t\tisValidDate: TYPES.func,\n\t\topen: TYPES.bool,\n\t\tstrictParsing: TYPES.bool\n\t},\n\n\tgetDefaultProps: function() {\n\t\tvar nof = function(){};\n\t\treturn {\n\t\t\tclassName: '',\n\t\t\tdefaultValue: '',\n\t\t\tinputProps: {},\n\t\t\tinput: true,\n\t\t\tonFocus: nof,\n\t\t\tonBlur: nof,\n\t\t\tonChange: nof,\n\t\t\ttimeFormat: true,\n\t\t\tdateFormat: true,\n\t\t\tstrictParsing: true\n\t\t};\n\t},\n\n\tgetInitialState: function() {\n\t\tvar state = this.getStateFromProps( this.props );\n\n\t\tif( state.open == undefined )\n\t\t\tstate.open = !this.props.input;\n\n\t\tstate.currentView = this.props.dateFormat ? (this.props.viewMode || state.updateOn || 'days') : 'time';\n\n\t\treturn state;\n\t},\n\n\tgetStateFromProps: function( props ){\n\t\tvar formats = this.getFormats( props ),\n\t\t\tdate = props.value || props.defaultValue,\n\t\t\tselectedDate, viewDate, updateOn\n\t\t;\n\n\t\tif( date && typeof date == 'string' )\n\t\t\tselectedDate = this.localMoment( date, formats.datetime );\n\t\telse if( date )\n\t\t\tselectedDate = this.localMoment( date );\n\n\t\tif( selectedDate && !selectedDate.isValid() )\n\t\t\tselectedDate = null;\n\n\t\tviewDate = selectedDate ?\n\t\t\tselectedDate.clone().startOf(\"month\") :\n\t\t\tthis.localMoment().startOf(\"month\")\n\t\t;\n\n\t\tupdateOn = this.getUpdateOn(formats);\n\n\t\treturn {\n\t\t\tupdateOn: updateOn,\n\t\t\tinputFormat: formats.datetime,\n\t\t\tviewDate: viewDate,\n\t\t\tselectedDate: selectedDate,\n\t\t\tinputValue: selectedDate ? selectedDate.format( formats.datetime ) : (date || ''),\n\t\t\topen: props.open\n\t\t};\n\t},\n\n\tgetUpdateOn: function(formats){\n\t\tif( formats.date.match(/[lLD]/) ){\n\t\t\treturn \"days\";\n\t\t}\n\t\telse if( formats.date.indexOf(\"M\") != -1 ){\n\t\t\treturn \"months\";\n\t\t}\n\t\telse if( formats.date.indexOf(\"Y\") != -1 ){\n\t\t\treturn \"years\";\n\t\t}\n\n\t\treturn 'days';\n\t},\n\n\tgetFormats: function( props ){\n\t\tvar formats = {\n\t\t\t\tdate: props.dateFormat || '',\n\t\t\t\ttime: props.timeFormat || ''\n\t\t\t},\n\t\t\tlocale = this.localMoment( props.date ).localeData()\n\t\t;\n\n\t\tif( formats.date === true ){\n\t\t\tformats.date = locale.longDateFormat('L');\n\t\t}\n\t\telse if( this.getUpdateOn(formats) !== 'days' ){\n\t\t\tformats.time = '';\n\t\t}\n\n\t\tif( formats.time === true ){\n\t\t\tformats.time = locale.longDateFormat('LT');\n\t\t}\n\n\t\tformats.datetime = formats.date && formats.time ?\n\t\t\tformats.date + ' ' + formats.time :\n\t\t\tformats.date || formats.time\n\t\t;\n\n\t\treturn formats;\n\t},\n\n\tcomponentWillReceiveProps: function(nextProps) {\n\t\tvar formats = this.getFormats( nextProps ),\n\t\t\tupdate = {}\n\t\t;\n\n\t\tif( nextProps.value != this.props.value ){\n\t\t\tupdate = this.getStateFromProps( nextProps );\n\t\t}\n\t\tif ( formats.datetime !== this.getFormats( this.props ).datetime ) {\n\t\t\tupdate.inputFormat = formats.datetime;\n\t\t}\n\n\t\tthis.setState( update );\n\t},\n\n\tonInputChange: function( e ) {\n\t\tvar value = e.target == null ? e : e.target.value,\n\t\t\tlocalMoment = this.localMoment( value, this.state.inputFormat ),\n\t\t\tupdate = { inputValue: value }\n\t\t;\n\n\t\tif ( localMoment.isValid() && !this.props.value ) {\n\t\t\tupdate.selectedDate = localMoment;\n\t\t\tupdate.viewDate = localMoment.clone().startOf(\"month\");\n\t\t}\n\t\telse {\n\t\t\tupdate.selectedDate = null;\n\t\t}\n\n\t\treturn this.setState( update, function() {\n\t\t\treturn this.props.onChange( localMoment.isValid() ? localMoment : this.state.inputValue );\n\t\t});\n\t},\n\n\tshowView: function( view ){\n\t\tvar me = this;\n\t\treturn function( e ){\n\t\t\tme.setState({ currentView: view });\n\t\t};\n\t},\n\n\tsetDate: function( type ){\n\t\tvar me = this,\n\t\t\tnextViews = {\n\t\t\t\tmonth: 'days',\n\t\t\t\tyear: 'months'\n\t\t\t}\n\t\t;\n\t\treturn function( e ){\n\t\t\tme.setState({\n\t\t\t\tviewDate: me.state.viewDate.clone()[ type ]( parseInt(e.target.getAttribute('data-value')) ).startOf( type ),\n\t\t\t\tcurrentView: nextViews[ type ]\n\t\t\t});\n\t\t};\n\t},\n\n\taddTime: function( amount, type, toSelected ){\n\t\treturn this.updateTime( 'add', amount, type, toSelected );\n\t},\n\n\tsubtractTime: function( amount, type, toSelected ){\n\t\treturn this.updateTime( 'subtract', amount, type, toSelected );\n\t},\n\n\tupdateTime: function( op, amount, type, toSelected ){\n\t\tvar me = this;\n\n\t\treturn function(){\n\t\t\tvar update = {},\n\t\t\t\tdate = toSelected ? 'selectedDate' : 'viewDate'\n\t\t\t;\n\n\t\t\tupdate[ date ] = me.state[ date ].clone()[ op ]( amount, type );\n\n\t\t\tme.setState( update );\n\t\t};\n\t},\n\n\tallowedSetTime: ['hours','minutes','seconds', 'milliseconds'],\n\tsetTime: function( type, value ){\n\t\tvar index = this.allowedSetTime.indexOf( type ) + 1,\n\t\t\tstate = this.state,\n\t\t\tdate = (state.selectedDate || state.viewDate).clone(),\n\t\t\tnextType\n\t\t;\n\n\t\t// It is needed to set all the time properties\n\t\t// to not to reset the time\n\t\tdate[ type ]( value );\n\t\tfor (; index < this.allowedSetTime.length; index++) {\n\t\t\tnextType = this.allowedSetTime[index];\n\t\t\tdate[ nextType ]( date[nextType]() );\n\t\t}\n\n\t\tif( !this.props.value ){\n\t\t\tthis.setState({\n\t\t\t\tselectedDate: date,\n\t\t\t\tinputValue: date.format( state.inputFormat )\n\t\t\t});\n\t\t}\n\t\tthis.props.onChange( date );\n\t},\n\n\tupdateSelectedDate: function( e, close ) {\n\t\tvar target = e.target,\n\t\t\tmodifier = 0,\n\t\t\tviewDate = this.state.viewDate,\n\t\t\tcurrentDate = this.state.selectedDate || viewDate,\n\t\t\tdate\n ;\n\n\t\tif(target.className.indexOf(\"rdtDay\") != -1){\n\t\t\tif(target.className.indexOf(\"rdtNew\") != -1)\n\t\t\t\tmodifier = 1;\n\t\t\telse if(target.className.indexOf(\"rdtOld\") != -1)\n\t\t\t\tmodifier = -1;\n\n\t\t\tdate = viewDate.clone()\n\t\t\t\t.month( viewDate.month() + modifier )\n\t\t\t\t.date( parseInt( target.getAttribute('data-value') ) )\n\t\t\t;\n\t\t}else if(target.className.indexOf(\"rdtMonth\") != -1){\n\t\t\tdate = viewDate.clone()\n\t\t\t\t.month( parseInt( target.getAttribute('data-value') ) )\n\t\t\t\t.date( currentDate.date() )\n\t\t}else if(target.className.indexOf(\"rdtYear\") != -1){\n\t\t\tdate = viewDate.clone()\n\t\t\t\t.month( currentDate.month() )\n\t\t\t\t.date( currentDate.date() )\n\t\t\t\t.year( parseInt( target.getAttribute('data-value') ) )\n\t\t}\n\n\t\tdate.hours( currentDate.hours() )\n\t\t\t.minutes( currentDate.minutes() )\n\t\t\t.seconds( currentDate.seconds() )\n\t\t\t.milliseconds( currentDate.milliseconds() )\n\n\t\tif( !this.props.value ){\n\t\t\tthis.setState({\n\t\t\t\tselectedDate: date,\n\t\t\t\tviewDate: date.clone().startOf('month'),\n\t\t\t\tinputValue: date.format( this.state.inputFormat ),\n\t\t\t\topen: !(this.props.closeOnSelect && close )\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tif (this.props.closeOnSelect && close) {\n\t\t\t\tthis.closeCalendar();\n\t\t\t}\n\t\t}\n\n\t\tthis.props.onChange( date );\n\t},\n\n\topenCalendar: function() {\n\t\tif (!this.state.open) {\n\t\t\tthis.props.onFocus();\n\t\t\tthis.setState({ open: true });\n\t\t}\n\t},\n\n\tcloseCalendar: function() {\n\t\tthis.setState({ open: false });\n\t\tthis.props.onBlur( this.state.selectedDate || this.state.inputValue );\n\t},\n\n\thandleClickOutside: function(){\n\t\tif( this.props.input && this.state.open && !this.props.open ){\n\t\t\tthis.setState({ open: false });\n\t\t\tthis.props.onBlur( this.state.selectedDate || this.state.inputValue );\n\t\t}\n\t},\n\n\tlocalMoment: function( date, format ){\n\t\tvar m = moment( date, format, this.props.strictParsing );\n\t\tif( this.props.locale )\n\t\t\tm.locale( this.props.locale );\n\t\treturn m;\n\t},\n\n\tcomponentProps: {\n\t\tfromProps: ['value', 'isValidDate', 'renderDay', 'renderMonth', 'renderYear'],\n\t\tfromState: ['viewDate', 'selectedDate', 'updateOn'],\n\t\tfromThis: ['setDate', 'setTime', 'showView', 'addTime', 'subtractTime', 'updateSelectedDate', 'localMoment']\n\t},\n\n\tgetComponentProps: function(){\n\t\tvar me = this,\n\t\t\tformats = this.getFormats( this.props ),\n\t\t\tprops = {dateFormat: formats.date, timeFormat: formats.time}\n\t\t;\n\n\t\tthis.componentProps.fromProps.forEach( function( name ){\n\t\t\tprops[ name ] = me.props[ name ];\n\t\t});\n\t\tthis.componentProps.fromState.forEach( function( name ){\n\t\t\tprops[ name ] = me.state[ name ];\n\t\t});\n\t\tthis.componentProps.fromThis.forEach( function( name ){\n\t\t\tprops[ name ] = me[ name ];\n\t\t});\n\n\t\treturn props;\n\t},\n\n\trender: function() {\n\t\tvar Component = this.viewComponents[ this.state.currentView ],\n\t\t\tDOM = React.DOM,\n\t\t\tclassName = 'rdt ' + this.props.className,\n\t\t\tchildren = []\n\t\t;\n\n\t\tif( this.props.input ){\n\t\t\tchildren = [ DOM.input( assign({\n\t\t\t\tkey: 'i',\n\t\t\t\ttype:'text',\n\t\t\t\tclassName: 'form-control',\n\t\t\t\tonFocus: this.openCalendar,\n\t\t\t\tonChange: this.onInputChange,\n\t\t\t\tvalue: this.state.inputValue\n\t\t\t}, this.props.inputProps ))];\n\t\t}\n\t\telse {\n\t\t\tclassName += ' rdtStatic';\n\t\t}\n\n\t\tif( this.state.open )\n\t\t\tclassName += ' rdtOpen';\n\n\t\treturn DOM.div({className: className}, children.concat(\n\t\t\tDOM.div(\n\t\t\t\t{ key: 'dt', className: 'rdtPicker' },\n\t\t\t\tReact.createElement( Component, this.getComponentProps())\n\t\t\t)\n\t\t));\n\t}\n});\n\n// Make moment accessible through the Datetime class\nDatetime.moment = moment;\n\nmodule.exports = Datetime;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./Datetime.js\n ** module id = 0\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./Datetime.js?"); | ||
@@ -81,3 +81,3 @@ /***/ }, | ||
eval("var React = __webpack_require__(2),\n\tmoment = __webpack_require__(4)\n;\n\nvar DOM = React.DOM;\nvar DateTimePickerDays = React.createClass({\n\n\trender: function() {\n\t\tvar footer = this.renderFooter(),\n\t\t\tdate = this.props.viewDate,\n\t\t\tlocale = date.localeData(),\n\t\t\ttableChildren\n\t\t;\n\n\t\ttableChildren = [\n\t\t\tDOM.thead({ key: 'th'}, [\n\t\t\t\tDOM.tr({ key: 'h'},[\n\t\t\t\t\tDOM.th({ key: 'p', className: 'rdtPrev' }, DOM.button({onClick: this.props.subtractTime(1, 'months'), type: 'button' }, '‹')),\n\t\t\t\t\tDOM.th({ key: 's', className: 'rdtSwitch', onClick: this.props.showView('months'), colSpan: 5, 'data-value': this.props.viewDate.month() }, locale.months( date ) + ' ' + date.year() ),\n\t\t\t\t\tDOM.th({ key: 'n', className: 'rdtNext' }, DOM.button({onClick: this.props.addTime(1, 'months'), type: 'button' }, '›'))\n\t\t\t\t]),\n\t\t\t\tDOM.tr({ key: 'd'}, this.getDaysOfWeek( locale ).map( function( day, index ){ return DOM.th({ key: day + index, className: 'dow'}, day ); }) )\n\t\t\t]),\n\t\t\tDOM.tbody({key: 'tb'}, this.renderDays())\n\t\t];\n\n\t\tif( footer )\n\t\t\ttableChildren.push( footer );\n\n\t\treturn DOM.div({ className: 'rdtDays' },\n\t\t\tDOM.table({}, tableChildren )\n\t\t);\n\t},\n\n\t/**\n\t * Get a list of the days of the week\n\t * depending on the current locale\n\t * @return {array} A list with the shortname of the days\n\t */\n\tgetDaysOfWeek: function( locale ){\n\t\tvar days = locale._weekdaysMin,\n\t\t\tfirst = locale.firstDayOfWeek(),\n\t\t\tdow = [],\n\t\t\ti = 0\n\t\t;\n\n\t\tdays.forEach( function( day ){\n\t\t\tdow[ (7 + (i++) - first) % 7 ] = day;\n\t\t});\n\n\t\treturn dow;\n\t},\n\n\trenderDays: function() {\n\t\tvar date = this.props.viewDate,\n\t\t\tselected = this.props.selectedDate && this.props.selectedDate.clone(),\n\t\t\tprevMonth = date.clone().subtract( 1, 'months' ),\n\t\t\tcurrentYear = date.year(),\n\t\t\tcurrentMonth = date.month(),\n\t\t\tweeks = [],\n\t\t\tdays = [],\n\t\t\trenderer = this.props.renderDay || this.renderDay,\n\t\t\tisValid = this.props.isValidDate || this.isValidDate,\n\t\t\tclasses, disabled, dayProps, currentDate\n\t\t;\n\n\t\t// Go to the last week of the previous month\n\t\tprevMonth.date( prevMonth.daysInMonth() ).startOf('week');\n\t\tvar lastDay = prevMonth.clone().add(42, 'd');\n\n\t\twhile( prevMonth.isBefore( lastDay ) ){\n\t\t\tclasses = 'rdtDay';\n\t\t\tcurrentDate = prevMonth.clone();\n\n\t\t\tif( ( prevMonth.year() == currentYear && prevMonth.month() < currentMonth ) || ( prevMonth.year() < currentYear ) )\n\t\t\t\tclasses += ' rdtOld';\n\t\t\telse if( ( prevMonth.year() == currentYear && prevMonth.month() > currentMonth ) || ( prevMonth.year() > currentYear ) )\n\t\t\t\tclasses += ' rdtNew';\n\n\t\t\tif( selected && prevMonth.isSame(selected, 'day') )\n\t\t\t\tclasses += ' rdtActive';\n\n\t\t\tif (prevMonth.isSame(moment(), 'day') )\n\t\t\t\tclasses += ' rdtToday';\n\n\t\t\tdisabled = !isValid( currentDate, selected );\n\t\t\tif( disabled )\n\t\t\t\tclasses += ' rdtDisabled';\n\n\t\t\tdayProps = {\n\t\t\t\tkey: prevMonth.format('M_D'),\n\t\t\t\t'data-value': prevMonth.date(),\n\t\t\t\tclassName: classes\n\t\t\t};\n\t\t\tif( !disabled )\n\t\t\t\tdayProps.onClick = this.updateSelectedDate;\n\n\t\t\tdays.push( renderer( dayProps, currentDate, selected ) );\n\n\t\t\tif( days.length == 7 ){\n\t\t\t\tweeks.push( DOM.tr( {key: prevMonth.format('M_D')}, days ) );\n\t\t\t\tdays = [];\n\t\t\t}\n\n\t\t\tprevMonth.add( 1, 'd' );\n\t\t}\n\n\t\treturn weeks;\n\t},\n\n\tupdateSelectedDate: function( event ) {\n\t\tthis.props.updateSelectedDate(event, true);\n\t},\n\n\trenderDay: function( props, currentDate, selectedDate ){\n\t\treturn DOM.td( props, currentDate.date() );\n\t},\n\n\trenderFooter: function(){\n\t\tif( !this.props.timeFormat )\n\t\t\treturn '';\n\n\t\tvar date = this.props.selectedDate || this.props.viewDate;\n\t\treturn DOM.tfoot({ key: 'tf'},\n\t\t\tDOM.tr({},\n\t\t\t\tDOM.td({ onClick: this.props.showView('time'), colSpan: 7, className: 'rdtTimeToggle'}, date.format( this.props.timeFormat ))\n\t\t\t)\n\t\t);\n\t},\n\tisValidDate: function(){ return 1; }\n});\n\nmodule.exports = DateTimePickerDays;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/DaysView.js\n ** module id = 3\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./src/DaysView.js?"); | ||
eval("var React = __webpack_require__(2),\n\tmoment = __webpack_require__(4)\n;\n\nvar DOM = React.DOM;\nvar DateTimePickerDays = React.createClass({\n\n\trender: function() {\n\t\tvar footer = this.renderFooter(),\n\t\t\tdate = this.props.viewDate,\n\t\t\tlocale = date.localeData(),\n\t\t\ttableChildren\n\t\t;\n\n\t\ttableChildren = [\n\t\t\tDOM.thead({ key: 'th'}, [\n\t\t\t\tDOM.tr({ key: 'h'},[\n\t\t\t\t\tDOM.th({ key: 'p', className: 'rdtPrev' }, DOM.button({onClick: this.props.subtractTime(1, 'months'), type: 'button' }, '‹')),\n\t\t\t\t\tDOM.th({ key: 's', className: 'rdtSwitch', onClick: this.props.showView('months'), colSpan: 5, 'data-value': this.props.viewDate.month() }, locale.months( date ) + ' ' + date.year() ),\n\t\t\t\t\tDOM.th({ key: 'n', className: 'rdtNext' }, DOM.button({onClick: this.props.addTime(1, 'months'), type: 'button' }, '›'))\n\t\t\t\t]),\n\t\t\t\tDOM.tr({ key: 'd'}, this.getDaysOfWeek( locale ).map( function( day, index ){ return DOM.th({ key: day + index, className: 'dow'}, day ); }) )\n\t\t\t]),\n\t\t\tDOM.tbody({key: 'tb'}, this.renderDays())\n\t\t];\n\n\t\tif( footer )\n\t\t\ttableChildren.push( footer );\n\n\t\treturn DOM.div({ className: 'rdtDays' },\n\t\t\tDOM.table({}, tableChildren )\n\t\t);\n\t},\n\n\t/**\n\t * Get a list of the days of the week\n\t * depending on the current locale\n\t * @return {array} A list with the shortname of the days\n\t */\n\tgetDaysOfWeek: function( locale ){\n\t\tvar days = locale._weekdaysMin,\n\t\t\tfirst = locale.firstDayOfWeek(),\n\t\t\tdow = [],\n\t\t\ti = 0\n\t\t;\n\n\t\tdays.forEach( function( day ){\n\t\t\tdow[ (7 + (i++) - first) % 7 ] = day;\n\t\t});\n\n\t\treturn dow;\n\t},\n\n\trenderDays: function() {\n\t\tvar date = this.props.viewDate,\n\t\t\tselected = this.props.selectedDate && this.props.selectedDate.clone(),\n\t\t\tprevMonth = date.clone().subtract( 1, 'months' ),\n\t\t\tcurrentYear = date.year(),\n\t\t\tcurrentMonth = date.month(),\n\t\t\tweeks = [],\n\t\t\tdays = [],\n\t\t\trenderer = this.props.renderDay || this.renderDay,\n\t\t\tisValid = this.props.isValidDate || this.isValidDate,\n\t\t\tclasses, disabled, dayProps, currentDate\n\t\t;\n\n\t\t// Go to the last week of the previous month\n\t\tprevMonth.date( prevMonth.daysInMonth() ).startOf('week');\n\t\tvar lastDay = prevMonth.clone().add(42, 'd');\n\n\t\twhile( prevMonth.isBefore( lastDay ) ){\n\t\t\tclasses = 'rdtDay';\n\t\t\tcurrentDate = prevMonth.clone();\n\n\t\t\tif( ( prevMonth.year() == currentYear && prevMonth.month() < currentMonth ) || ( prevMonth.year() < currentYear ) )\n\t\t\t\tclasses += ' rdtOld';\n\t\t\telse if( ( prevMonth.year() == currentYear && prevMonth.month() > currentMonth ) || ( prevMonth.year() > currentYear ) )\n\t\t\t\tclasses += ' rdtNew';\n\n\t\t\tif( selected && prevMonth.isSame(selected, 'day') )\n\t\t\t\tclasses += ' rdtActive';\n\n\t\t\tif (prevMonth.isSame(moment(), 'day') )\n\t\t\t\tclasses += ' rdtToday';\n\n\t\t\tdisabled = !isValid( currentDate, selected );\n\t\t\tif( disabled )\n\t\t\t\tclasses += ' rdtDisabled';\n\n\t\t\tdayProps = {\n\t\t\t\tkey: prevMonth.format('M_D'),\n\t\t\t\t'data-value': prevMonth.date(),\n\t\t\t\tclassName: classes\n\t\t\t};\n\t\t\tif( !disabled )\n\t\t\t\tdayProps.onClick = this.updateSelectedDate;\n\n\t\t\tdays.push( renderer( dayProps, currentDate, selected ) );\n\n\t\t\tif( days.length == 7 ){\n\t\t\t\tweeks.push( DOM.tr( {key: prevMonth.format('M_D')}, days ) );\n\t\t\t\tdays = [];\n\t\t\t}\n\n\t\t\tprevMonth.add( 1, 'd' );\n\t\t}\n\n\t\treturn weeks;\n\t},\n\n\tupdateSelectedDate: function( event ) {\n\t\tthis.props.updateSelectedDate(event, true);\n\t},\n\n\trenderDay: function( props, currentDate, selectedDate ){\n\t\treturn DOM.td( props, currentDate.date() );\n\t},\n\n\trenderFooter: function(){\n\t\tif( !this.props.timeFormat )\n\t\t\treturn '';\n\n\t\tvar date = this.props.selectedDate || this.props.viewDate;\n\t\t\n\t\treturn DOM.tfoot({ key: 'tf'},\n\t\t\tDOM.tr({},\n\t\t\t\tDOM.td({ onClick: this.props.showView('time'), colSpan: 7, className: 'rdtTimeToggle'}, date.format( this.props.timeFormat ))\n\t\t\t)\n\t\t);\n\t},\n\tisValidDate: function(){ return 1; }\n});\n\nmodule.exports = DateTimePickerDays;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/DaysView.js\n ** module id = 3\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./src/DaysView.js?"); | ||
@@ -94,3 +94,3 @@ /***/ }, | ||
eval("'use strict';\n\nvar React = __webpack_require__(2),\nmoment = __webpack_require__(4)\n;\n\nvar DOM = React.DOM;\nvar DateTimePickerMonths = React.createClass({\n\trender: function() {\n\t\treturn DOM.div({ className: 'rdtMonths' },[\n\t\t\tDOM.table({ key: 'a'}, DOM.thead({}, DOM.tr({},[\n\t\t\t\tDOM.th({ key: 'prev', className: 'rdtPrev' }, DOM.button({onClick: this.props.subtractTime(1, 'years'), type: 'button' }, '‹')),\n\t\t\t\tDOM.th({ key: 'year', className: 'rdtSwitch', onClick: this.props.showView('years'), colSpan: 2, 'data-value': this.props.viewDate.year()}, this.props.viewDate.year() ),\n\t\t\t\tDOM.th({ key: 'next', className: 'rdtNext' }, DOM.button({onClick: this.props.addTime(1, 'years'), type: 'button' }, '›'))\n\t\t\t]))),\n\t\t\tDOM.table({ key: 'months'}, DOM.tbody({ key: 'b'}, this.renderMonths()))\n\t\t]);\n\t},\n\n\trenderMonths: function() {\n\t\tvar date = this.props.selectedDate,\n\t\t\tmonth = this.props.viewDate.month(),\n\t\t\tyear = this.props.viewDate.year(),\n\t\t\trows = [],\n\t\t\ti = 0,\n\t\t\tmonths = [],\n\t\t\trenderer = this.props.renderMonth || this.renderMonth,\n\t\t\tclasses, props\n\t\t;\n\n\t\twhile (i < 12) {\n\t\t\tclasses = \"rdtMonth\";\n\t\t\tif( date && i === month && year === date.year() )\n\t\t\t\tclasses += \" rdtActive\";\n\n\t\t\tprops = {\n\t\t\t\tkey: i,\n\t\t\t\t'data-value': i,\n\t\t\t\tclassName: classes,\n\t\t\t\tonClick: this.props.updateOn==\"month\"?this.updateSelectedMonth:this.props.setDate('month')\n\t\t\t};\n\n\t\t\tmonths.push( renderer( props, i, year, date && date.clone() ));\n\n\t\t\tif( months.length == 4 ){\n\t\t\t\trows.push( DOM.tr({ key: month + '_' + rows.length }, months) );\n\t\t\t\tmonths = [];\n\t\t\t}\n\n\t\t\ti++;\n\t\t}\n\n\t\treturn rows;\n\t},\n\n\tupdateSelectedMonth: function( event ) {\n\t\tthis.props.updateSelectedDate(event, true);\n\t},\n\n\trenderMonth: function( props, month, year, selectedDate ) {\n\t\treturn DOM.td( props, this.props.viewDate.localeData()._monthsShort[ month ] );\n\t}\n});\n\nmodule.exports = DateTimePickerMonths;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/MonthsView.js\n ** module id = 5\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./src/MonthsView.js?"); | ||
eval("'use strict';\n\nvar React = __webpack_require__(2),\nmoment = __webpack_require__(4)\n;\n\nvar DOM = React.DOM;\nvar DateTimePickerMonths = React.createClass({\n\trender: function() {\n\t\treturn DOM.div({ className: 'rdtMonths' },[\n\t\t\tDOM.table({ key: 'a'}, DOM.thead({}, DOM.tr({},[\n\t\t\t\tDOM.th({ key: 'prev', className: 'rdtPrev' }, DOM.button({onClick: this.props.subtractTime(1, 'years'), type: 'button' }, '‹')),\n\t\t\t\tDOM.th({ key: 'year', className: 'rdtSwitch', onClick: this.props.showView('years'), colSpan: 2, 'data-value': this.props.viewDate.year()}, this.props.viewDate.year() ),\n\t\t\t\tDOM.th({ key: 'next', className: 'rdtNext' }, DOM.button({onClick: this.props.addTime(1, 'years'), type: 'button' }, '›'))\n\t\t\t]))),\n\t\t\tDOM.table({ key: 'months'}, DOM.tbody({ key: 'b'}, this.renderMonths()))\n\t\t]);\n\t},\n\n\trenderMonths: function() {\n\t\tvar date = this.props.selectedDate,\n\t\t\tmonth = this.props.viewDate.month(),\n\t\t\tyear = this.props.viewDate.year(),\n\t\t\trows = [],\n\t\t\ti = 0,\n\t\t\tmonths = [],\n\t\t\trenderer = this.props.renderMonth || this.renderMonth,\n\t\t\tclasses, props\n\t\t;\n\n\t\twhile (i < 12) {\n\t\t\tclasses = \"rdtMonth\";\n\t\t\tif( date && i === month && year === date.year() )\n\t\t\t\tclasses += \" rdtActive\";\n\n\t\t\tprops = {\n\t\t\t\tkey: i,\n\t\t\t\t'data-value': i,\n\t\t\t\tclassName: classes,\n\t\t\t\tonClick: this.props.updateOn==\"months\"? this.updateSelectedMonth : this.props.setDate('month')\n\t\t\t};\n\n\t\t\tmonths.push( renderer( props, i, year, date && date.clone() ));\n\n\t\t\tif( months.length == 4 ){\n\t\t\t\trows.push( DOM.tr({ key: month + '_' + rows.length }, months) );\n\t\t\t\tmonths = [];\n\t\t\t}\n\n\t\t\ti++;\n\t\t}\n\n\t\treturn rows;\n\t},\n\n\tupdateSelectedMonth: function( event ) {\n\t\tthis.props.updateSelectedDate(event, true);\n\t},\n\n\trenderMonth: function( props, month, year, selectedDate ) {\n\t\treturn DOM.td( props, this.props.viewDate.localeData()._monthsShort[ month ] );\n\t}\n});\n\nmodule.exports = DateTimePickerMonths;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/MonthsView.js\n ** module id = 5\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./src/MonthsView.js?"); | ||
@@ -101,3 +101,3 @@ /***/ }, | ||
eval("'use strict';\n\nvar React = __webpack_require__(2);\n\nvar DOM = React.DOM;\nvar DateTimePickerYears = React.createClass({\n\trender: function() {\n\t\tvar year = parseInt(this.props.viewDate.year() / 10, 10) * 10;\n\n\t\treturn DOM.div({ className: 'rdtYears' },[\n\t\t\tDOM.table({ key: 'a'}, DOM.thead({}, DOM.tr({},[\n\t\t\t\tDOM.th({ key: 'prev', className: 'rdtPrev' }, DOM.button({onClick: this.props.subtractTime(10, 'years'), type: 'button' }, '‹')),\n\t\t\t\tDOM.th({ key: 'year', className: 'rdtSwitch', onClick: this.props.showView('years'), colSpan: 2 }, year + '-' + (year + 9) ),\n\t\t\t\tDOM.th({ key: 'next', className: 'rdtNext'}, DOM.button({onClick: this.props.addTime(10, 'years'), type: 'button' }, '›'))\n\t\t\t\t]))),\n\t\t\tDOM.table({ key: 'years'}, DOM.tbody({}, this.renderYears( year )))\n\t\t]);\n\t},\n\n\trenderYears: function( year ) {\n\t\tvar years = [],\n\t\t\ti = -1,\n\t\t\trows = [],\n\t\t\trenderer = this.props.renderYear || this.renderYear,\n\t\t\tselectedDate = this.props.selectedDate,\n\t\t\tclasses, props\n\t\t;\n\n\t\tyear--;\n\t\twhile (i < 11) {\n\t\t\tclasses = 'rdtYear';\n\t\t\tif( i === -1 | i === 10 )\n\t\t\t\tclasses += ' rdtOld';\n\t\t\tif( selectedDate && selectedDate.year() === year )\n\t\t\t\tclasses += ' rdtActive';\n\n\t\t\tprops = {\n\t\t\t\tkey: year,\n\t\t\t\t'data-value': year,\n\t\t\t\tclassName: classes,\n\t\t\t\tonClick: this.props.updateOn==\"year\"?this.updateSelectedYear:this.props.setDate('year')\n\t\t\t};\n\n\t\t\tyears.push( renderer( props, year, selectedDate && selectedDate.clone() ));\n\n\t\t\tif( years.length == 4 ){\n\t\t\t\trows.push( DOM.tr({ key: i }, years ) );\n\t\t\t\tyears = [];\n\t\t\t}\n\n\t\t\tyear++;\n\t\t\ti++;\n\t\t}\n\n\t\treturn rows;\n\t},\n\n\tupdateSelectedYear: function( event ) {\n\t\tthis.props.updateSelectedDate(event, true);\n\t},\n\n\trenderYear: function( props, year, selectedDate ){\n\t\treturn DOM.td( props, year );\n\t}\n});\n\nmodule.exports = DateTimePickerYears;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/YearsView.js\n ** module id = 6\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./src/YearsView.js?"); | ||
eval("'use strict';\n\nvar React = __webpack_require__(2);\n\nvar DOM = React.DOM;\nvar DateTimePickerYears = React.createClass({\n\trender: function() {\n\t\tvar year = parseInt(this.props.viewDate.year() / 10, 10) * 10;\n\n\t\treturn DOM.div({ className: 'rdtYears' },[\n\t\t\tDOM.table({ key: 'a'}, DOM.thead({}, DOM.tr({},[\n\t\t\t\tDOM.th({ key: 'prev', className: 'rdtPrev' }, DOM.button({onClick: this.props.subtractTime(10, 'years'), type: 'button' }, '‹')),\n\t\t\t\tDOM.th({ key: 'year', className: 'rdtSwitch', onClick: this.props.showView('years'), colSpan: 2 }, year + '-' + (year + 9) ),\n\t\t\t\tDOM.th({ key: 'next', className: 'rdtNext'}, DOM.button({onClick: this.props.addTime(10, 'years'), type: 'button' }, '›'))\n\t\t\t\t]))),\n\t\t\tDOM.table({ key: 'years'}, DOM.tbody({}, this.renderYears( year )))\n\t\t]);\n\t},\n\n\trenderYears: function( year ) {\n\t\tvar years = [],\n\t\t\ti = -1,\n\t\t\trows = [],\n\t\t\trenderer = this.props.renderYear || this.renderYear,\n\t\t\tselectedDate = this.props.selectedDate,\n\t\t\tclasses, props\n\t\t;\n\n\t\tyear--;\n\t\twhile (i < 11) {\n\t\t\tclasses = 'rdtYear';\n\t\t\tif( i === -1 | i === 10 )\n\t\t\t\tclasses += ' rdtOld';\n\t\t\tif( selectedDate && selectedDate.year() === year )\n\t\t\t\tclasses += ' rdtActive';\n\n\t\t\tprops = {\n\t\t\t\tkey: year,\n\t\t\t\t'data-value': year,\n\t\t\t\tclassName: classes,\n\t\t\t\tonClick: this.props.updateOn==\"years\" ? this.updateSelectedYear : this.props.setDate('year')\n\t\t\t};\n\n\t\t\tyears.push( renderer( props, year, selectedDate && selectedDate.clone() ));\n\n\t\t\tif( years.length == 4 ){\n\t\t\t\trows.push( DOM.tr({ key: i }, years ) );\n\t\t\t\tyears = [];\n\t\t\t}\n\n\t\t\tyear++;\n\t\t\ti++;\n\t\t}\n\n\t\treturn rows;\n\t},\n\n\tupdateSelectedYear: function( event ) {\n\t\tthis.props.updateSelectedDate(event, true);\n\t},\n\n\trenderYear: function( props, year, selectedDate ){\n\t\treturn DOM.td( props, year );\n\t}\n});\n\nmodule.exports = DateTimePickerYears;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./src/YearsView.js\n ** module id = 6\n ** module chunks = 0\n **/\n//# sourceURL=webpack:///./src/YearsView.js?"); | ||
@@ -104,0 +104,0 @@ /***/ }, |
/* | ||
react-datetime v2.1.0 | ||
react-datetime v2.2.1 | ||
https://github.com/arqex/react-datetime | ||
MIT: https://github.com/arqex/react-datetime/raw/master/LICENSE | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("moment"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","moment","ReactDOM"],e):"object"==typeof exports?exports.Datetime=e(require("React"),require("moment"),require("ReactDOM")):t.Datetime=e(t.React,t.moment,t.ReactDOM)}(this,function(t,e,s){return function(t){function e(n){if(s[n])return s[n].exports;var r=s[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var s={};return e.m=t,e.c=s,e.p="",e(0)}([function(t,e,s){"use strict";var n=s(1),r=s(2),a=s(3),o=s(5),i=s(6),c=s(7),u=s(4),d=r.PropTypes,p=r.createClass({mixins:[s(8)],viewComponents:{days:a,months:o,years:i,time:c},propTypes:{closeOnSelect:d.bool,onFocus:d.func,onBlur:d.func,onChange:d.func,locale:d.string,input:d.bool,inputProps:d.object,viewMode:d.oneOf(["years","months","days","time"]),isValidDate:d.func,open:d.bool,strictParsing:d.bool},getDefaultProps:function(){var t=function(){};return{className:"",defaultValue:"",viewMode:"days",inputProps:{},input:!0,onFocus:t,onBlur:t,onChange:t,timeFormat:!0,dateFormat:!0,strictParsing:!0}},getInitialState:function(){var t=this.getStateFromProps(this.props);return void 0==t.open&&(t.open=!this.props.input),t.currentView=this.props.dateFormat?this.props.viewMode:"time",t},getStateFromProps:function(t){var e,s,n,r=this.getFormats(t),a=t.value||t.defaultValue;return a&&"string"==typeof a?e=this.localMoment(a,r.datetime):a&&(e=this.localMoment(a)),e&&!e.isValid()&&(e=null),s=e?e.clone().startOf("month"):this.localMoment().startOf("month"),n=this.getUpdateOn(r),{updateOn:n,inputFormat:r.datetime,viewDate:s,selectedDate:e,inputValue:e?e.format(r.datetime):a||"",open:void 0!=t.open?t.open:this.state&&this.state.open}},getUpdateOn:function(t){return-1!=t.datetime.indexOf("D")?"date":-1!=t.datetime.indexOf("M")?"month":-1!=t.datetime.indexOf("Y")?"year":void 0},getFormats:function(t){var e={date:t.dateFormat||"",time:t.timeFormat||""},s=this.localMoment(t.date).localeData();return e.date===!0&&(e.date=s.longDateFormat("L")),e.time===!0&&(e.time=s.longDateFormat("LT")),e.datetime=e.date&&e.time?e.date+" "+e.time:e.date||e.time,e},componentWillReceiveProps:function(t){var e=this.getFormats(t),s={};t.value!=this.props.value&&(s=this.getStateFromProps(t)),e.datetime!==this.getFormats(this.props).datetime&&(s.inputFormat=e.datetime),this.setState(s)},onInputChange:function(t){var e=null==t.target?t:t.target.value,s=this.localMoment(e,this.state.inputFormat),n={inputValue:e};return s.isValid()&&!this.props.value?(n.selectedDate=s,n.viewDate=s.clone().startOf("month")):n.selectedDate=null,this.setState(n,function(){return this.props.onChange(s.isValid()?s:this.state.inputValue)})},showView:function(t){var e=this;return function(s){e.setState({currentView:t})}},setDate:function(t){var e=this,s={month:"days",year:"months"};return function(n){e.setState({viewDate:e.state.viewDate.clone()[t](parseInt(n.target.getAttribute("data-value"))).startOf(t),currentView:s[t]})}},addTime:function(t,e,s){return this.updateTime("add",t,e,s)},subtractTime:function(t,e,s){return this.updateTime("subtract",t,e,s)},updateTime:function(t,e,s,n){var r=this;return function(){var a={},o=n?"selectedDate":"viewDate";a[o]=r.state[o].clone()[t](e,s),r.setState(a)}},allowedSetTime:["hours","minutes","seconds","milliseconds"],setTime:function(t,e){var s,n=this.allowedSetTime.indexOf(t)+1,r=this.state,a=(r.selectedDate||r.viewDate).clone();for(a[t](e);n<this.allowedSetTime.length;n++)s=this.allowedSetTime[n],a[s](a[s]());this.props.value||this.setState({selectedDate:a,inputValue:a.format(r.inputFormat)}),this.props.onChange(a)},updateSelectedDate:function(t,e){var s,n=t.target,r=0,a=this.state.viewDate,o=this.state.selectedDate||a;-1!=n.className.indexOf("rdtDay")?(-1!=n.className.indexOf("rdtNew")?r=1:-1!=n.className.indexOf("rdtOld")&&(r=-1),s=a.clone().month(a.month()+r).date(parseInt(n.getAttribute("data-value")))):-1!=n.className.indexOf("rdtMonth")?s=a.clone().month(parseInt(n.getAttribute("data-value"))).date(o.date()):-1!=n.className.indexOf("rdtYear")&&(s=a.clone().month(o.month()).date(o.date()).year(parseInt(n.getAttribute("data-value")))),s.hours(o.hours()).minutes(o.minutes()).seconds(o.seconds()).milliseconds(o.milliseconds()),this.props.value||this.setState({selectedDate:s,viewDate:s.clone().startOf("month"),inputValue:s.format(this.state.inputFormat)},function(){this.props.closeOnSelect&&e&&this.closeCalendar()}),this.props.onChange(s)},openCalendar:function(){this.state.open||(this.props.onFocus(),this.setState({open:!0}))},closeCalendar:function(){this.setState({open:!1})},handleClickOutside:function(){this.props.input&&this.state.open&&!this.props.open&&(this.setState({open:!1}),this.props.onBlur(this.state.selectedDate||this.state.inputValue))},localMoment:function(t,e){var s=u(t,e,this.props.strictParsing);return this.props.locale&&s.locale(this.props.locale),s},componentProps:{fromProps:["value","isValidDate","renderDay","renderMonth","renderYear"],fromState:["viewDate","selectedDate","updateOn"],fromThis:["setDate","setTime","showView","addTime","subtractTime","updateSelectedDate","localMoment"]},getComponentProps:function(){var t=this,e=this.getFormats(this.props),s={dateFormat:e.date,timeFormat:e.time};return this.componentProps.fromProps.forEach(function(e){s[e]=t.props[e]}),this.componentProps.fromState.forEach(function(e){s[e]=t.state[e]}),this.componentProps.fromThis.forEach(function(e){s[e]=t[e]}),s},render:function(){var t=this.viewComponents[this.state.currentView],e=r.DOM,s="rdt "+this.props.className,a=[];return this.props.input?a=[e.input(n({key:"i",type:"text",className:"form-control",onFocus:this.openCalendar,onChange:this.onInputChange,value:this.state.inputValue},this.props.inputProps))]:s+=" rdtStatic",this.state.open&&(s+=" rdtOpen"),e.div({className:s},a.concat(e.div({key:"dt",className:"rdtPicker"},r.createElement(t,this.getComponentProps()))))}});p.moment=u,t.exports=p},function(t,e){"use strict";function s(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function n(t){var e=Object.getOwnPropertyNames(t);return Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(t))),e.filter(function(e){return r.call(t,e)})}var r=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(t,e){for(var r,a,o=s(t),i=1;i<arguments.length;i++){r=arguments[i],a=n(Object(r));for(var c=0;c<a.length;c++)o[a[c]]=r[a[c]]}return o}},function(e,s){e.exports=t},function(t,e,s){var n=s(2),r=s(4),a=n.DOM,o=n.createClass({render:function(){var t,e=this.renderFooter(),s=this.props.viewDate,n=s.localeData();return t=[a.thead({key:"th"},[a.tr({key:"h"},[a.th({key:"p",className:"rdtPrev"},a.button({onClick:this.props.subtractTime(1,"months"),type:"button"},"‹")),a.th({key:"s",className:"rdtSwitch",onClick:this.props.showView("months"),colSpan:5,"data-value":this.props.viewDate.month()},n.months(s)+" "+s.year()),a.th({key:"n",className:"rdtNext"},a.button({onClick:this.props.addTime(1,"months"),type:"button"},"›"))]),a.tr({key:"d"},this.getDaysOfWeek(n).map(function(t,e){return a.th({key:t+e,className:"dow"},t)}))]),a.tbody({key:"tb"},this.renderDays())],e&&t.push(e),a.div({className:"rdtDays"},a.table({},t))},getDaysOfWeek:function(t){var e=t._weekdaysMin,s=t.firstDayOfWeek(),n=[],r=0;return e.forEach(function(t){n[(7+r++-s)%7]=t}),n},renderDays:function(){var t,e,s,n,o=this.props.viewDate,i=this.props.selectedDate&&this.props.selectedDate.clone(),c=o.clone().subtract(1,"months"),u=o.year(),d=o.month(),p=[],l=[],h=this.props.renderDay||this.renderDay,m=this.props.isValidDate||this.isValidDate;c.date(c.daysInMonth()).startOf("week");for(var f=c.clone().add(42,"d");c.isBefore(f);)t="rdtDay",n=c.clone(),c.year()==u&&c.month()<d||c.year()<u?t+=" rdtOld":(c.year()==u&&c.month()>d||c.year()>u)&&(t+=" rdtNew"),i&&c.isSame(i,"day")&&(t+=" rdtActive"),c.isSame(r(),"day")&&(t+=" rdtToday"),e=!m(n,i),e&&(t+=" rdtDisabled"),s={key:c.format("M_D"),"data-value":c.date(),className:t},e||(s.onClick=this.updateSelectedDate),l.push(h(s,n,i)),7==l.length&&(p.push(a.tr({key:c.format("M_D")},l)),l=[]),c.add(1,"d");return p},updateSelectedDate:function(t){this.props.updateSelectedDate(t,!0)},renderDay:function(t,e,s){return a.td(t,e.date())},renderFooter:function(){if(!this.props.timeFormat)return"";var t=this.props.selectedDate||this.props.viewDate;return a.tfoot({key:"tf"},a.tr({},a.td({onClick:this.props.showView("time"),colSpan:7,className:"rdtTimeToggle"},t.format(this.props.timeFormat))))},isValidDate:function(){return 1}});t.exports=o},function(t,s){t.exports=e},function(t,e,s){"use strict";var n=s(2),r=(s(4),n.DOM),a=n.createClass({render:function(){return r.div({className:"rdtMonths"},[r.table({key:"a"},r.thead({},r.tr({},[r.th({key:"prev",className:"rdtPrev"},r.button({onClick:this.props.subtractTime(1,"years"),type:"button"},"‹")),r.th({key:"year",className:"rdtSwitch",onClick:this.props.showView("years"),colSpan:2,"data-value":this.props.viewDate.year()},this.props.viewDate.year()),r.th({key:"next",className:"rdtNext"},r.button({onClick:this.props.addTime(1,"years"),type:"button"},"›"))]))),r.table({key:"months"},r.tbody({key:"b"},this.renderMonths()))])},renderMonths:function(){for(var t,e,s=this.props.selectedDate,n=this.props.viewDate.month(),a=this.props.viewDate.year(),o=[],i=0,c=[],u=this.props.renderMonth||this.renderMonth;12>i;)t="rdtMonth",s&&i===n&&a===s.year()&&(t+=" rdtActive"),e={key:i,"data-value":i,className:t,onClick:"month"==this.props.updateOn?this.updateSelectedMonth:this.props.setDate("month")},c.push(u(e,i,a,s&&s.clone())),4==c.length&&(o.push(r.tr({key:n+"_"+o.length},c)),c=[]),i++;return o},updateSelectedMonth:function(t){this.props.updateSelectedDate(t,!0)},renderMonth:function(t,e,s,n){return r.td(t,this.props.viewDate.localeData()._monthsShort[e])}});t.exports=a},function(t,e,s){"use strict";var n=s(2),r=n.DOM,a=n.createClass({render:function(){var t=10*parseInt(this.props.viewDate.year()/10,10);return r.div({className:"rdtYears"},[r.table({key:"a"},r.thead({},r.tr({},[r.th({key:"prev",className:"rdtPrev"},r.button({onClick:this.props.subtractTime(10,"years"),type:"button"},"‹")),r.th({key:"year",className:"rdtSwitch",onClick:this.props.showView("years"),colSpan:2},t+"-"+(t+9)),r.th({key:"next",className:"rdtNext"},r.button({onClick:this.props.addTime(10,"years"),type:"button"},"›"))]))),r.table({key:"years"},r.tbody({},this.renderYears(t)))])},renderYears:function(t){var e,s,n=[],a=-1,o=[],i=this.props.renderYear||this.renderYear,c=this.props.selectedDate;for(t--;11>a;)e="rdtYear",-1===a|10===a&&(e+=" rdtOld"),c&&c.year()===t&&(e+=" rdtActive"),s={key:t,"data-value":t,className:e,onClick:"year"==this.props.updateOn?this.updateSelectedYear:this.props.setDate("year")},n.push(i(s,t,c&&c.clone())),4==n.length&&(o.push(r.tr({key:a},n)),n=[]),t++,a++;return o},updateSelectedYear:function(t){this.props.updateSelectedDate(t,!0)},renderYear:function(t,e,s){return r.td(t,e)}});t.exports=a},function(t,e,s){"use strict";var n=s(2),r=n.DOM,a=n.createClass({getInitialState:function(){return this.calculateState(this.props)},calculateState:function(t){var e=t.selectedDate||t.viewDate,s=t.timeFormat,n=[];return-1==s.indexOf("H")&&-1==s.indexOf("h")||(n.push("hours"),-1!=s.indexOf("m")&&(n.push("minutes"),-1!=s.indexOf("s")&&n.push("seconds"))),{hours:e.format("H"),minutes:e.format("mm"),seconds:e.format("ss"),milliseconds:e.format("SSS"),counters:n}},renderCounter:function(t){return r.div({key:t,className:"rdtCounter"},[r.button({key:"up",className:"rdtBtn",onMouseDown:this.onStartClicking("increase",t),type:"button"},"▲"),r.div({key:"c",className:"rdtCount"},this.state[t]),r.button({key:"do",className:"rdtBtn",onMouseDown:this.onStartClicking("decrease",t),type:"button"},"▼")])},render:function(){var t=this,e=[];return this.state.counters.forEach(function(s){e.length&&e.push(r.div({key:"sep"+e.length,className:"rdtCounterSeparator"},":")),e.push(t.renderCounter(s))}),3==this.state.counters.length&&-1!=this.props.timeFormat.indexOf("S")&&(e.push(r.div({className:"rdtCounterSeparator",key:"sep5"},":")),e.push(r.div({className:"rdtCounter rdtMilli",key:"m"},r.input({value:this.state.milliseconds,type:"text",onChange:this.updateMilli})))),r.div({className:"rdtTime"},r.table({},[this.renderHeader(),r.tbody({key:"b"},r.tr({},r.td({},r.div({className:"rdtCounters"},e))))]))},componentWillReceiveProps:function(t,e){this.setState(this.calculateState(t))},updateMilli:function(t){var e=parseInt(t.target.value);e==t.target.value&&e>=0&&1e3>e&&(this.props.setTime("milliseconds",e),this.setState({milliseconds:e}))},renderHeader:function(){if(!this.props.dateFormat)return null;var t=this.props.selectedDate||this.props.viewDate;return r.thead({key:"h"},r.tr({},r.th({className:"rdtSwitch",colSpan:4,onClick:this.props.showView("days")},t.format(this.props.dateFormat))))},onStartClicking:function(t,e){var s=this;this.state[e];return function(){var n={};n[e]=s[t](e),s.setState(n),s.timer=setTimeout(function(){s.increaseTimer=setInterval(function(){n[e]=s[t](e),s.setState(n)},70)},500),s.mouseUpListener=function(){clearTimeout(s.timer),clearInterval(s.increaseTimer),s.props.setTime(e,s.state[e]),document.body.removeEventListener("mouseup",s.mouseUpListener)},document.body.addEventListener("mouseup",s.mouseUpListener)}},maxValues:{hours:23,minutes:59,seconds:59,milliseconds:999},padValues:{hours:1,minutes:2,seconds:2,milliseconds:3},increase:function(t){var e=parseInt(this.state[t])+1;return e>this.maxValues[t]&&(e=0),this.pad(t,e)},decrease:function(t){var e=parseInt(this.state[t])-1;return 0>e&&(e=this.maxValues[t]),this.pad(t,e)},pad:function(t,e){for(var s=e+"";s.length<this.padValues[t];)s="0"+s;return s}});t.exports=a},function(t,e,s){var n=s(2),r=n.version&&n.version.split(".");r&&(r[0]>0||r[1]>13)&&(n=s(9));var a=[],o=[],i="ignore-react-onclickoutside",c=function(t,e){return t===e?!0:t.correspondingElement?t.correspondingElement.classList.contains(i):t.classList.contains(i)};t.exports={componentDidMount:function(){if("function"!=typeof this.handleClickOutside)throw new Error("Component lacks a handleClickOutside(event) function for processing outside click events.");var t=this.__outsideClickHandler=function(t,e){return function(s){s.stopPropagation();for(var n=s.target,r=!1;n.parentNode;){if(r=c(n,t))return;n=n.parentNode}e(s)}}(n.findDOMNode(this),this.handleClickOutside),e=a.length;a.push(this),o[e]=t,this.props.disableOnClickOutside||this.enableOnClickOutside()},componentWillUnmount:function(){this.disableOnClickOutside(),this.__outsideClickHandler=!1;var t=a.indexOf(this);t>-1&&o[t]&&(o.splice(t,1),a.splice(t,1))},enableOnClickOutside:function(){var t=this.__outsideClickHandler;document.addEventListener("mousedown",t),document.addEventListener("touchstart",t)},disableOnClickOutside:function(){var t=this.__outsideClickHandler;document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}}},function(t,e){t.exports=s}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("React"),require("moment"),require("ReactDOM")):"function"==typeof define&&define.amd?define(["React","moment","ReactDOM"],e):"object"==typeof exports?exports.Datetime=e(require("React"),require("moment"),require("ReactDOM")):t.Datetime=e(t.React,t.moment,t.ReactDOM)}(this,function(t,e,s){return function(t){function e(n){if(s[n])return s[n].exports;var a=s[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var s={};return e.m=t,e.c=s,e.p="",e(0)}([function(t,e,s){"use strict";var n=s(1),a=s(2),r=s(3),o=s(5),i=s(6),c=s(7),u=s(4),d=a.PropTypes,p=a.createClass({mixins:[s(8)],viewComponents:{days:r,months:o,years:i,time:c},propTypes:{closeOnSelect:d.bool,onFocus:d.func,onBlur:d.func,onChange:d.func,locale:d.string,input:d.bool,inputProps:d.object,viewMode:d.oneOf(["years","months","days","time"]),isValidDate:d.func,open:d.bool,strictParsing:d.bool},getDefaultProps:function(){var t=function(){};return{className:"",defaultValue:"",inputProps:{},input:!0,onFocus:t,onBlur:t,onChange:t,timeFormat:!0,dateFormat:!0,strictParsing:!0}},getInitialState:function(){var t=this.getStateFromProps(this.props);return void 0==t.open&&(t.open=!this.props.input),t.currentView=this.props.dateFormat?this.props.viewMode||t.updateOn||"days":"time",t},getStateFromProps:function(t){var e,s,n,a=this.getFormats(t),r=t.value||t.defaultValue;return r&&"string"==typeof r?e=this.localMoment(r,a.datetime):r&&(e=this.localMoment(r)),e&&!e.isValid()&&(e=null),s=e?e.clone().startOf("month"):this.localMoment().startOf("month"),n=this.getUpdateOn(a),{updateOn:n,inputFormat:a.datetime,viewDate:s,selectedDate:e,inputValue:e?e.format(a.datetime):r||"",open:t.open}},getUpdateOn:function(t){return t.date.match(/[lLD]/)?"days":-1!=t.date.indexOf("M")?"months":-1!=t.date.indexOf("Y")?"years":"days"},getFormats:function(t){var e={date:t.dateFormat||"",time:t.timeFormat||""},s=this.localMoment(t.date).localeData();return e.date===!0?e.date=s.longDateFormat("L"):"days"!==this.getUpdateOn(e)&&(e.time=""),e.time===!0&&(e.time=s.longDateFormat("LT")),e.datetime=e.date&&e.time?e.date+" "+e.time:e.date||e.time,e},componentWillReceiveProps:function(t){var e=this.getFormats(t),s={};t.value!=this.props.value&&(s=this.getStateFromProps(t)),e.datetime!==this.getFormats(this.props).datetime&&(s.inputFormat=e.datetime),this.setState(s)},onInputChange:function(t){var e=null==t.target?t:t.target.value,s=this.localMoment(e,this.state.inputFormat),n={inputValue:e};return s.isValid()&&!this.props.value?(n.selectedDate=s,n.viewDate=s.clone().startOf("month")):n.selectedDate=null,this.setState(n,function(){return this.props.onChange(s.isValid()?s:this.state.inputValue)})},showView:function(t){var e=this;return function(s){e.setState({currentView:t})}},setDate:function(t){var e=this,s={month:"days",year:"months"};return function(n){e.setState({viewDate:e.state.viewDate.clone()[t](parseInt(n.target.getAttribute("data-value"))).startOf(t),currentView:s[t]})}},addTime:function(t,e,s){return this.updateTime("add",t,e,s)},subtractTime:function(t,e,s){return this.updateTime("subtract",t,e,s)},updateTime:function(t,e,s,n){var a=this;return function(){var r={},o=n?"selectedDate":"viewDate";r[o]=a.state[o].clone()[t](e,s),a.setState(r)}},allowedSetTime:["hours","minutes","seconds","milliseconds"],setTime:function(t,e){var s,n=this.allowedSetTime.indexOf(t)+1,a=this.state,r=(a.selectedDate||a.viewDate).clone();for(r[t](e);n<this.allowedSetTime.length;n++)s=this.allowedSetTime[n],r[s](r[s]());this.props.value||this.setState({selectedDate:r,inputValue:r.format(a.inputFormat)}),this.props.onChange(r)},updateSelectedDate:function(t,e){var s,n=t.target,a=0,r=this.state.viewDate,o=this.state.selectedDate||r;-1!=n.className.indexOf("rdtDay")?(-1!=n.className.indexOf("rdtNew")?a=1:-1!=n.className.indexOf("rdtOld")&&(a=-1),s=r.clone().month(r.month()+a).date(parseInt(n.getAttribute("data-value")))):-1!=n.className.indexOf("rdtMonth")?s=r.clone().month(parseInt(n.getAttribute("data-value"))).date(o.date()):-1!=n.className.indexOf("rdtYear")&&(s=r.clone().month(o.month()).date(o.date()).year(parseInt(n.getAttribute("data-value")))),s.hours(o.hours()).minutes(o.minutes()).seconds(o.seconds()).milliseconds(o.milliseconds()),this.props.value?this.props.closeOnSelect&&e&&this.closeCalendar():this.setState({selectedDate:s,viewDate:s.clone().startOf("month"),inputValue:s.format(this.state.inputFormat),open:!(this.props.closeOnSelect&&e)}),this.props.onChange(s)},openCalendar:function(){this.state.open||(this.props.onFocus(),this.setState({open:!0}))},closeCalendar:function(){this.setState({open:!1}),this.props.onBlur(this.state.selectedDate||this.state.inputValue)},handleClickOutside:function(){this.props.input&&this.state.open&&!this.props.open&&(this.setState({open:!1}),this.props.onBlur(this.state.selectedDate||this.state.inputValue))},localMoment:function(t,e){var s=u(t,e,this.props.strictParsing);return this.props.locale&&s.locale(this.props.locale),s},componentProps:{fromProps:["value","isValidDate","renderDay","renderMonth","renderYear"],fromState:["viewDate","selectedDate","updateOn"],fromThis:["setDate","setTime","showView","addTime","subtractTime","updateSelectedDate","localMoment"]},getComponentProps:function(){var t=this,e=this.getFormats(this.props),s={dateFormat:e.date,timeFormat:e.time};return this.componentProps.fromProps.forEach(function(e){s[e]=t.props[e]}),this.componentProps.fromState.forEach(function(e){s[e]=t.state[e]}),this.componentProps.fromThis.forEach(function(e){s[e]=t[e]}),s},render:function(){var t=this.viewComponents[this.state.currentView],e=a.DOM,s="rdt "+this.props.className,r=[];return this.props.input?r=[e.input(n({key:"i",type:"text",className:"form-control",onFocus:this.openCalendar,onChange:this.onInputChange,value:this.state.inputValue},this.props.inputProps))]:s+=" rdtStatic",this.state.open&&(s+=" rdtOpen"),e.div({className:s},r.concat(e.div({key:"dt",className:"rdtPicker"},a.createElement(t,this.getComponentProps()))))}});p.moment=u,t.exports=p},function(t,e){"use strict";function s(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function n(t){var e=Object.getOwnPropertyNames(t);return Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(t))),e.filter(function(e){return a.call(t,e)})}var a=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(t,e){for(var a,r,o=s(t),i=1;i<arguments.length;i++){a=arguments[i],r=n(Object(a));for(var c=0;c<r.length;c++)o[r[c]]=a[r[c]]}return o}},function(e,s){e.exports=t},function(t,e,s){var n=s(2),a=s(4),r=n.DOM,o=n.createClass({render:function(){var t,e=this.renderFooter(),s=this.props.viewDate,n=s.localeData();return t=[r.thead({key:"th"},[r.tr({key:"h"},[r.th({key:"p",className:"rdtPrev"},r.button({onClick:this.props.subtractTime(1,"months"),type:"button"},"‹")),r.th({key:"s",className:"rdtSwitch",onClick:this.props.showView("months"),colSpan:5,"data-value":this.props.viewDate.month()},n.months(s)+" "+s.year()),r.th({key:"n",className:"rdtNext"},r.button({onClick:this.props.addTime(1,"months"),type:"button"},"›"))]),r.tr({key:"d"},this.getDaysOfWeek(n).map(function(t,e){return r.th({key:t+e,className:"dow"},t)}))]),r.tbody({key:"tb"},this.renderDays())],e&&t.push(e),r.div({className:"rdtDays"},r.table({},t))},getDaysOfWeek:function(t){var e=t._weekdaysMin,s=t.firstDayOfWeek(),n=[],a=0;return e.forEach(function(t){n[(7+a++-s)%7]=t}),n},renderDays:function(){var t,e,s,n,o=this.props.viewDate,i=this.props.selectedDate&&this.props.selectedDate.clone(),c=o.clone().subtract(1,"months"),u=o.year(),d=o.month(),p=[],l=[],h=this.props.renderDay||this.renderDay,m=this.props.isValidDate||this.isValidDate;c.date(c.daysInMonth()).startOf("week");for(var f=c.clone().add(42,"d");c.isBefore(f);)t="rdtDay",n=c.clone(),c.year()==u&&c.month()<d||c.year()<u?t+=" rdtOld":(c.year()==u&&c.month()>d||c.year()>u)&&(t+=" rdtNew"),i&&c.isSame(i,"day")&&(t+=" rdtActive"),c.isSame(a(),"day")&&(t+=" rdtToday"),e=!m(n,i),e&&(t+=" rdtDisabled"),s={key:c.format("M_D"),"data-value":c.date(),className:t},e||(s.onClick=this.updateSelectedDate),l.push(h(s,n,i)),7==l.length&&(p.push(r.tr({key:c.format("M_D")},l)),l=[]),c.add(1,"d");return p},updateSelectedDate:function(t){this.props.updateSelectedDate(t,!0)},renderDay:function(t,e,s){return r.td(t,e.date())},renderFooter:function(){if(!this.props.timeFormat)return"";var t=this.props.selectedDate||this.props.viewDate;return r.tfoot({key:"tf"},r.tr({},r.td({onClick:this.props.showView("time"),colSpan:7,className:"rdtTimeToggle"},t.format(this.props.timeFormat))))},isValidDate:function(){return 1}});t.exports=o},function(t,s){t.exports=e},function(t,e,s){"use strict";var n=s(2),a=(s(4),n.DOM),r=n.createClass({render:function(){return a.div({className:"rdtMonths"},[a.table({key:"a"},a.thead({},a.tr({},[a.th({key:"prev",className:"rdtPrev"},a.button({onClick:this.props.subtractTime(1,"years"),type:"button"},"‹")),a.th({key:"year",className:"rdtSwitch",onClick:this.props.showView("years"),colSpan:2,"data-value":this.props.viewDate.year()},this.props.viewDate.year()),a.th({key:"next",className:"rdtNext"},a.button({onClick:this.props.addTime(1,"years"),type:"button"},"›"))]))),a.table({key:"months"},a.tbody({key:"b"},this.renderMonths()))])},renderMonths:function(){for(var t,e,s=this.props.selectedDate,n=this.props.viewDate.month(),r=this.props.viewDate.year(),o=[],i=0,c=[],u=this.props.renderMonth||this.renderMonth;12>i;)t="rdtMonth",s&&i===n&&r===s.year()&&(t+=" rdtActive"),e={key:i,"data-value":i,className:t,onClick:"months"==this.props.updateOn?this.updateSelectedMonth:this.props.setDate("month")},c.push(u(e,i,r,s&&s.clone())),4==c.length&&(o.push(a.tr({key:n+"_"+o.length},c)),c=[]),i++;return o},updateSelectedMonth:function(t){this.props.updateSelectedDate(t,!0)},renderMonth:function(t,e,s,n){return a.td(t,this.props.viewDate.localeData()._monthsShort[e])}});t.exports=r},function(t,e,s){"use strict";var n=s(2),a=n.DOM,r=n.createClass({render:function(){var t=10*parseInt(this.props.viewDate.year()/10,10);return a.div({className:"rdtYears"},[a.table({key:"a"},a.thead({},a.tr({},[a.th({key:"prev",className:"rdtPrev"},a.button({onClick:this.props.subtractTime(10,"years"),type:"button"},"‹")),a.th({key:"year",className:"rdtSwitch",onClick:this.props.showView("years"),colSpan:2},t+"-"+(t+9)),a.th({key:"next",className:"rdtNext"},a.button({onClick:this.props.addTime(10,"years"),type:"button"},"›"))]))),a.table({key:"years"},a.tbody({},this.renderYears(t)))])},renderYears:function(t){var e,s,n=[],r=-1,o=[],i=this.props.renderYear||this.renderYear,c=this.props.selectedDate;for(t--;11>r;)e="rdtYear",-1===r|10===r&&(e+=" rdtOld"),c&&c.year()===t&&(e+=" rdtActive"),s={key:t,"data-value":t,className:e,onClick:"years"==this.props.updateOn?this.updateSelectedYear:this.props.setDate("year")},n.push(i(s,t,c&&c.clone())),4==n.length&&(o.push(a.tr({key:r},n)),n=[]),t++,r++;return o},updateSelectedYear:function(t){this.props.updateSelectedDate(t,!0)},renderYear:function(t,e,s){return a.td(t,e)}});t.exports=r},function(t,e,s){"use strict";var n=s(2),a=n.DOM,r=n.createClass({getInitialState:function(){return this.calculateState(this.props)},calculateState:function(t){var e=t.selectedDate||t.viewDate,s=t.timeFormat,n=[];return(-1!=s.indexOf("H")||-1!=s.indexOf("h"))&&(n.push("hours"),-1!=s.indexOf("m")&&(n.push("minutes"),-1!=s.indexOf("s")&&n.push("seconds"))),{hours:e.format("H"),minutes:e.format("mm"),seconds:e.format("ss"),milliseconds:e.format("SSS"),counters:n}},renderCounter:function(t){return a.div({key:t,className:"rdtCounter"},[a.button({key:"up",className:"rdtBtn",onMouseDown:this.onStartClicking("increase",t),type:"button"},"▲"),a.div({key:"c",className:"rdtCount"},this.state[t]),a.button({key:"do",className:"rdtBtn",onMouseDown:this.onStartClicking("decrease",t),type:"button"},"▼")])},render:function(){var t=this,e=[];return this.state.counters.forEach(function(s){e.length&&e.push(a.div({key:"sep"+e.length,className:"rdtCounterSeparator"},":")),e.push(t.renderCounter(s))}),3==this.state.counters.length&&-1!=this.props.timeFormat.indexOf("S")&&(e.push(a.div({className:"rdtCounterSeparator",key:"sep5"},":")),e.push(a.div({className:"rdtCounter rdtMilli",key:"m"},a.input({value:this.state.milliseconds,type:"text",onChange:this.updateMilli})))),a.div({className:"rdtTime"},a.table({},[this.renderHeader(),a.tbody({key:"b"},a.tr({},a.td({},a.div({className:"rdtCounters"},e))))]))},componentWillReceiveProps:function(t,e){this.setState(this.calculateState(t))},updateMilli:function(t){var e=parseInt(t.target.value);e==t.target.value&&e>=0&&1e3>e&&(this.props.setTime("milliseconds",e),this.setState({milliseconds:e}))},renderHeader:function(){if(!this.props.dateFormat)return null;var t=this.props.selectedDate||this.props.viewDate;return a.thead({key:"h"},a.tr({},a.th({className:"rdtSwitch",colSpan:4,onClick:this.props.showView("days")},t.format(this.props.dateFormat))))},onStartClicking:function(t,e){var s=this;this.state[e];return function(){var n={};n[e]=s[t](e),s.setState(n),s.timer=setTimeout(function(){s.increaseTimer=setInterval(function(){n[e]=s[t](e),s.setState(n)},70)},500),s.mouseUpListener=function(){clearTimeout(s.timer),clearInterval(s.increaseTimer),s.props.setTime(e,s.state[e]),document.body.removeEventListener("mouseup",s.mouseUpListener)},document.body.addEventListener("mouseup",s.mouseUpListener)}},maxValues:{hours:23,minutes:59,seconds:59,milliseconds:999},padValues:{hours:1,minutes:2,seconds:2,milliseconds:3},increase:function(t){var e=parseInt(this.state[t])+1;return e>this.maxValues[t]&&(e=0),this.pad(t,e)},decrease:function(t){var e=parseInt(this.state[t])-1;return 0>e&&(e=this.maxValues[t]),this.pad(t,e)},pad:function(t,e){for(var s=e+"";s.length<this.padValues[t];)s="0"+s;return s}});t.exports=r},function(t,e,s){var n=s(2),a=n.version&&n.version.split(".");a&&(a[0]>0||a[1]>13)&&(n=s(9));var r=[],o=[],i="ignore-react-onclickoutside",c=function(t,e){return t===e?!0:t.correspondingElement?t.correspondingElement.classList.contains(i):t.classList.contains(i)};t.exports={componentDidMount:function(){if("function"!=typeof this.handleClickOutside)throw new Error("Component lacks a handleClickOutside(event) function for processing outside click events.");var t=this.__outsideClickHandler=function(t,e){return function(s){s.stopPropagation();for(var n=s.target,a=!1;n.parentNode;){if(a=c(n,t))return;n=n.parentNode}e(s)}}(n.findDOMNode(this),this.handleClickOutside),e=r.length;r.push(this),o[e]=t,this.props.disableOnClickOutside||this.enableOnClickOutside()},componentWillUnmount:function(){this.disableOnClickOutside(),this.__outsideClickHandler=!1;var t=r.indexOf(this);t>-1&&o[t]&&(o.splice(t,1),r.splice(t,1))},enableOnClickOutside:function(){var t=this.__outsideClickHandler;document.addEventListener("mousedown",t),document.addEventListener("touchstart",t)},disableOnClickOutside:function(){var t=this.__outsideClickHandler;document.removeEventListener("mousedown",t),document.removeEventListener("touchstart",t)}}},function(t,e){t.exports=s}])}); |
{ | ||
"name": "react-datetime", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A lightweight but complete datetime picker React.js component.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/arqex/react-datetime", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
111232
1863