commit | author | age
|
d76f7b
|
1 |
/* |
033119
|
2 |
react-datetime v2.10.2 |
be9654
|
3 |
https://github.com/YouCanBookMe/react-datetime |
SE |
4 |
MIT: https://github.com/YouCanBookMe/react-datetime/raw/master/LICENSE |
d76f7b
|
5 |
*/ |
M |
6 |
(function webpackUniversalModuleDefinition(root, factory) { |
|
7 |
if(typeof exports === 'object' && typeof module === 'object') |
be31e2
|
8 |
module.exports = factory(require("React"), require("moment"), require("ReactDOM")); |
d76f7b
|
9 |
else if(typeof define === 'function' && define.amd) |
be31e2
|
10 |
define(["React", "moment", "ReactDOM"], factory); |
d76f7b
|
11 |
else if(typeof exports === 'object') |
be31e2
|
12 |
exports["Datetime"] = factory(require("React"), require("moment"), require("ReactDOM")); |
d76f7b
|
13 |
else |
be31e2
|
14 |
root["Datetime"] = factory(root["React"], root["moment"], root["ReactDOM"]); |
JB |
15 |
})(this, function(__WEBPACK_EXTERNAL_MODULE_12__, __WEBPACK_EXTERNAL_MODULE_16__, __WEBPACK_EXTERNAL_MODULE_20__) { |
d76f7b
|
16 |
return /******/ (function(modules) { // webpackBootstrap |
M |
17 |
/******/ // The module cache |
|
18 |
/******/ var installedModules = {}; |
|
19 |
|
|
20 |
/******/ // The require function |
|
21 |
/******/ function __webpack_require__(moduleId) { |
|
22 |
|
|
23 |
/******/ // Check if module is in cache |
|
24 |
/******/ if(installedModules[moduleId]) |
|
25 |
/******/ return installedModules[moduleId].exports; |
|
26 |
|
|
27 |
/******/ // Create a new module (and put it into the cache) |
|
28 |
/******/ var module = installedModules[moduleId] = { |
|
29 |
/******/ exports: {}, |
|
30 |
/******/ id: moduleId, |
|
31 |
/******/ loaded: false |
|
32 |
/******/ }; |
|
33 |
|
|
34 |
/******/ // Execute the module function |
|
35 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
36 |
|
|
37 |
/******/ // Flag the module as loaded |
|
38 |
/******/ module.loaded = true; |
|
39 |
|
|
40 |
/******/ // Return the exports of the module |
|
41 |
/******/ return module.exports; |
|
42 |
/******/ } |
|
43 |
|
|
44 |
|
|
45 |
/******/ // expose the modules object (__webpack_modules__) |
|
46 |
/******/ __webpack_require__.m = modules; |
|
47 |
|
|
48 |
/******/ // expose the module cache |
|
49 |
/******/ __webpack_require__.c = installedModules; |
|
50 |
|
|
51 |
/******/ // __webpack_public_path__ |
|
52 |
/******/ __webpack_require__.p = ""; |
|
53 |
|
|
54 |
/******/ // Load entry module and return exports |
|
55 |
/******/ return __webpack_require__(0); |
|
56 |
/******/ }) |
|
57 |
/************************************************************************/ |
|
58 |
/******/ ([ |
|
59 |
/* 0 */ |
7392ed
|
60 |
/***/ (function(module, exports, __webpack_require__) { |
d76f7b
|
61 |
|
be9654
|
62 |
'use strict'; |
SE |
63 |
|
|
64 |
var assign = __webpack_require__(1), |
833531
|
65 |
PropTypes = __webpack_require__(2), |
8f6f33
|
66 |
createClass = __webpack_require__(11), |
be31e2
|
67 |
moment = __webpack_require__(16), |
JB |
68 |
React = __webpack_require__(12), |
|
69 |
CalendarContainer = __webpack_require__(17) |
8f6f33
|
70 |
; |
be9654
|
71 |
|
be31e2
|
72 |
var TYPES = PropTypes; |
JB |
73 |
var Datetime = createClass({ |
be9654
|
74 |
propTypes: { |
SE |
75 |
// value: TYPES.object | TYPES.string, |
|
76 |
// defaultValue: TYPES.object | TYPES.string, |
|
77 |
onFocus: TYPES.func, |
|
78 |
onBlur: TYPES.func, |
|
79 |
onChange: TYPES.func, |
833531
|
80 |
onViewModeChange: TYPES.func, |
be9654
|
81 |
locale: TYPES.string, |
SE |
82 |
utc: TYPES.bool, |
|
83 |
input: TYPES.bool, |
|
84 |
// dateFormat: TYPES.string | TYPES.bool, |
|
85 |
// timeFormat: TYPES.string | TYPES.bool, |
|
86 |
inputProps: TYPES.object, |
|
87 |
timeConstraints: TYPES.object, |
|
88 |
viewMode: TYPES.oneOf(['years', 'months', 'days', 'time']), |
|
89 |
isValidDate: TYPES.func, |
|
90 |
open: TYPES.bool, |
|
91 |
strictParsing: TYPES.bool, |
|
92 |
closeOnSelect: TYPES.bool, |
|
93 |
closeOnTab: TYPES.bool |
|
94 |
}, |
|
95 |
|
|
96 |
getDefaultProps: function() { |
|
97 |
var nof = function() {}; |
|
98 |
return { |
|
99 |
className: '', |
|
100 |
defaultValue: '', |
|
101 |
inputProps: {}, |
|
102 |
input: true, |
|
103 |
onFocus: nof, |
|
104 |
onBlur: nof, |
|
105 |
onChange: nof, |
833531
|
106 |
onViewModeChange: nof, |
be9654
|
107 |
timeFormat: true, |
SE |
108 |
timeConstraints: {}, |
|
109 |
dateFormat: true, |
|
110 |
strictParsing: true, |
|
111 |
closeOnSelect: false, |
|
112 |
closeOnTab: true, |
|
113 |
utc: false |
|
114 |
}; |
|
115 |
}, |
|
116 |
|
|
117 |
getInitialState: function() { |
|
118 |
var state = this.getStateFromProps( this.props ); |
|
119 |
|
|
120 |
if ( state.open === undefined ) |
|
121 |
state.open = !this.props.input; |
|
122 |
|
|
123 |
state.currentView = this.props.dateFormat ? (this.props.viewMode || state.updateOn || 'days') : 'time'; |
|
124 |
|
|
125 |
return state; |
|
126 |
}, |
|
127 |
|
|
128 |
getStateFromProps: function( props ) { |
|
129 |
var formats = this.getFormats( props ), |
|
130 |
date = props.value || props.defaultValue, |
|
131 |
selectedDate, viewDate, updateOn, inputValue |
8f6f33
|
132 |
; |
be9654
|
133 |
|
SE |
134 |
if ( date && typeof date === 'string' ) |
|
135 |
selectedDate = this.localMoment( date, formats.datetime ); |
|
136 |
else if ( date ) |
|
137 |
selectedDate = this.localMoment( date ); |
|
138 |
|
|
139 |
if ( selectedDate && !selectedDate.isValid() ) |
|
140 |
selectedDate = null; |
|
141 |
|
|
142 |
viewDate = selectedDate ? |
|
143 |
selectedDate.clone().startOf('month') : |
|
144 |
this.localMoment().startOf('month') |
|
145 |
; |
|
146 |
|
|
147 |
updateOn = this.getUpdateOn(formats); |
|
148 |
|
|
149 |
if ( selectedDate ) |
|
150 |
inputValue = selectedDate.format(formats.datetime); |
|
151 |
else if ( date.isValid && !date.isValid() ) |
|
152 |
inputValue = ''; |
|
153 |
else |
|
154 |
inputValue = date || ''; |
|
155 |
|
|
156 |
return { |
|
157 |
updateOn: updateOn, |
|
158 |
inputFormat: formats.datetime, |
|
159 |
viewDate: viewDate, |
|
160 |
selectedDate: selectedDate, |
|
161 |
inputValue: inputValue, |
|
162 |
open: props.open |
|
163 |
}; |
|
164 |
}, |
|
165 |
|
|
166 |
getUpdateOn: function( formats ) { |
8f6f33
|
167 |
if ( formats.date.match(/[lLD]/) ) { |
be9654
|
168 |
return 'days'; |
833531
|
169 |
} else if ( formats.date.indexOf('M') !== -1 ) { |
be9654
|
170 |
return 'months'; |
833531
|
171 |
} else if ( formats.date.indexOf('Y') !== -1 ) { |
be9654
|
172 |
return 'years'; |
SE |
173 |
} |
|
174 |
|
|
175 |
return 'days'; |
|
176 |
}, |
|
177 |
|
|
178 |
getFormats: function( props ) { |
|
179 |
var formats = { |
|
180 |
date: props.dateFormat || '', |
|
181 |
time: props.timeFormat || '' |
|
182 |
}, |
|
183 |
locale = this.localMoment( props.date, null, props ).localeData() |
8f6f33
|
184 |
; |
be9654
|
185 |
|
SE |
186 |
if ( formats.date === true ) { |
|
187 |
formats.date = locale.longDateFormat('L'); |
|
188 |
} |
|
189 |
else if ( this.getUpdateOn(formats) !== 'days' ) { |
|
190 |
formats.time = ''; |
|
191 |
} |
|
192 |
|
|
193 |
if ( formats.time === true ) { |
|
194 |
formats.time = locale.longDateFormat('LT'); |
|
195 |
} |
|
196 |
|
|
197 |
formats.datetime = formats.date && formats.time ? |
|
198 |
formats.date + ' ' + formats.time : |
|
199 |
formats.date || formats.time |
|
200 |
; |
|
201 |
|
|
202 |
return formats; |
|
203 |
}, |
|
204 |
|
|
205 |
componentWillReceiveProps: function( nextProps ) { |
|
206 |
var formats = this.getFormats( nextProps ), |
|
207 |
updatedState = {} |
|
208 |
; |
|
209 |
|
|
210 |
if ( nextProps.value !== this.props.value || |
|
211 |
formats.datetime !== this.getFormats( this.props ).datetime ) { |
|
212 |
updatedState = this.getStateFromProps( nextProps ); |
|
213 |
} |
|
214 |
|
|
215 |
if ( updatedState.open === undefined ) { |
a6752b
|
216 |
if ( this.props.closeOnSelect && this.state.currentView !== 'time' ) { |
SE |
217 |
updatedState.open = false; |
7750ac
|
218 |
} else { |
a6752b
|
219 |
updatedState.open = this.state.open; |
SE |
220 |
} |
be9654
|
221 |
} |
SE |
222 |
|
|
223 |
if ( nextProps.viewMode !== this.props.viewMode ) { |
|
224 |
updatedState.currentView = nextProps.viewMode; |
|
225 |
} |
|
226 |
|
|
227 |
if ( nextProps.locale !== this.props.locale ) { |
|
228 |
if ( this.state.viewDate ) { |
|
229 |
var updatedViewDate = this.state.viewDate.clone().locale( nextProps.locale ); |
|
230 |
updatedState.viewDate = updatedViewDate; |
|
231 |
} |
|
232 |
if ( this.state.selectedDate ) { |
|
233 |
var updatedSelectedDate = this.state.selectedDate.clone().locale( nextProps.locale ); |
|
234 |
updatedState.selectedDate = updatedSelectedDate; |
|
235 |
updatedState.inputValue = updatedSelectedDate.format( formats.datetime ); |
|
236 |
} |
|
237 |
} |
|
238 |
|
|
239 |
if ( nextProps.utc !== this.props.utc ) { |
|
240 |
if ( nextProps.utc ) { |
|
241 |
if ( this.state.viewDate ) |
|
242 |
updatedState.viewDate = this.state.viewDate.clone().utc(); |
|
243 |
if ( this.state.selectedDate ) { |
|
244 |
updatedState.selectedDate = this.state.selectedDate.clone().utc(); |
|
245 |
updatedState.inputValue = updatedState.selectedDate.format( formats.datetime ); |
|
246 |
} |
|
247 |
} else { |
|
248 |
if ( this.state.viewDate ) |
|
249 |
updatedState.viewDate = this.state.viewDate.clone().local(); |
|
250 |
if ( this.state.selectedDate ) { |
|
251 |
updatedState.selectedDate = this.state.selectedDate.clone().local(); |
|
252 |
updatedState.inputValue = updatedState.selectedDate.format(formats.datetime); |
|
253 |
} |
|
254 |
} |
|
255 |
} |
8f6f33
|
256 |
//we should only show a valid date if we are provided a isValidDate function. |
LA |
257 |
if (this.props.isValidDate) { |
|
258 |
updatedState.viewDate = updatedState.viewDate || this.state.viewDate; |
|
259 |
while (!this.props.isValidDate(updatedState.viewDate)) { |
|
260 |
updatedState.viewDate = updatedState.viewDate.add(1, 'day'); |
|
261 |
} |
|
262 |
} |
be9654
|
263 |
this.setState( updatedState ); |
SE |
264 |
}, |
|
265 |
|
|
266 |
onInputChange: function( e ) { |
|
267 |
var value = e.target === null ? e : e.target.value, |
|
268 |
localMoment = this.localMoment( value, this.state.inputFormat ), |
|
269 |
update = { inputValue: value } |
8f6f33
|
270 |
; |
be9654
|
271 |
|
SE |
272 |
if ( localMoment.isValid() && !this.props.value ) { |
|
273 |
update.selectedDate = localMoment; |
|
274 |
update.viewDate = localMoment.clone().startOf('month'); |
833531
|
275 |
} else { |
be9654
|
276 |
update.selectedDate = null; |
SE |
277 |
} |
|
278 |
|
|
279 |
return this.setState( update, function() { |
|
280 |
return this.props.onChange( localMoment.isValid() ? localMoment : this.state.inputValue ); |
|
281 |
}); |
|
282 |
}, |
|
283 |
|
|
284 |
onInputKey: function( e ) { |
|
285 |
if ( e.which === 9 && this.props.closeOnTab ) { |
|
286 |
this.closeCalendar(); |
|
287 |
} |
|
288 |
}, |
|
289 |
|
|
290 |
showView: function( view ) { |
|
291 |
var me = this; |
|
292 |
return function() { |
833531
|
293 |
me.state.currentView !== view && me.props.onViewModeChange( view ); |
be9654
|
294 |
me.setState({ currentView: view }); |
SE |
295 |
}; |
|
296 |
}, |
|
297 |
|
|
298 |
setDate: function( type ) { |
|
299 |
var me = this, |
|
300 |
nextViews = { |
|
301 |
month: 'days', |
|
302 |
year: 'months' |
|
303 |
} |
|
304 |
; |
|
305 |
return function( e ) { |
|
306 |
me.setState({ |
|
307 |
viewDate: me.state.viewDate.clone()[ type ]( parseInt(e.target.getAttribute('data-value'), 10) ).startOf( type ), |
|
308 |
currentView: nextViews[ type ] |
|
309 |
}); |
833531
|
310 |
me.props.onViewModeChange( nextViews[ type ] ); |
be9654
|
311 |
}; |
SE |
312 |
}, |
|
313 |
|
|
314 |
addTime: function( amount, type, toSelected ) { |
|
315 |
return this.updateTime( 'add', amount, type, toSelected ); |
|
316 |
}, |
|
317 |
|
|
318 |
subtractTime: function( amount, type, toSelected ) { |
|
319 |
return this.updateTime( 'subtract', amount, type, toSelected ); |
|
320 |
}, |
|
321 |
|
|
322 |
updateTime: function( op, amount, type, toSelected ) { |
|
323 |
var me = this; |
|
324 |
|
|
325 |
return function() { |
|
326 |
var update = {}, |
|
327 |
date = toSelected ? 'selectedDate' : 'viewDate' |
|
328 |
; |
|
329 |
|
|
330 |
update[ date ] = me.state[ date ].clone()[ op ]( amount, type ); |
|
331 |
|
|
332 |
me.setState( update ); |
|
333 |
}; |
|
334 |
}, |
|
335 |
|
|
336 |
allowedSetTime: ['hours', 'minutes', 'seconds', 'milliseconds'], |
|
337 |
setTime: function( type, value ) { |
|
338 |
var index = this.allowedSetTime.indexOf( type ) + 1, |
|
339 |
state = this.state, |
|
340 |
date = (state.selectedDate || state.viewDate).clone(), |
|
341 |
nextType |
8f6f33
|
342 |
; |
be9654
|
343 |
|
SE |
344 |
// It is needed to set all the time properties |
|
345 |
// to not to reset the time |
|
346 |
date[ type ]( value ); |
|
347 |
for (; index < this.allowedSetTime.length; index++) { |
|
348 |
nextType = this.allowedSetTime[index]; |
|
349 |
date[ nextType ]( date[nextType]() ); |
|
350 |
} |
|
351 |
|
|
352 |
if ( !this.props.value ) { |
|
353 |
this.setState({ |
|
354 |
selectedDate: date, |
|
355 |
inputValue: date.format( state.inputFormat ) |
|
356 |
}); |
|
357 |
} |
|
358 |
this.props.onChange( date ); |
|
359 |
}, |
|
360 |
|
|
361 |
updateSelectedDate: function( e, close ) { |
|
362 |
var target = e.target, |
|
363 |
modifier = 0, |
|
364 |
viewDate = this.state.viewDate, |
|
365 |
currentDate = this.state.selectedDate || viewDate, |
|
366 |
date |
8f6f33
|
367 |
; |
be9654
|
368 |
|
SE |
369 |
if (target.className.indexOf('rdtDay') !== -1) { |
|
370 |
if (target.className.indexOf('rdtNew') !== -1) |
|
371 |
modifier = 1; |
|
372 |
else if (target.className.indexOf('rdtOld') !== -1) |
|
373 |
modifier = -1; |
|
374 |
|
|
375 |
date = viewDate.clone() |
|
376 |
.month( viewDate.month() + modifier ) |
|
377 |
.date( parseInt( target.getAttribute('data-value'), 10 ) ); |
|
378 |
} else if (target.className.indexOf('rdtMonth') !== -1) { |
|
379 |
date = viewDate.clone() |
|
380 |
.month( parseInt( target.getAttribute('data-value'), 10 ) ) |
|
381 |
.date( currentDate.date() ); |
|
382 |
} else if (target.className.indexOf('rdtYear') !== -1) { |
|
383 |
date = viewDate.clone() |
|
384 |
.month( currentDate.month() ) |
|
385 |
.date( currentDate.date() ) |
|
386 |
.year( parseInt( target.getAttribute('data-value'), 10 ) ); |
|
387 |
} |
|
388 |
|
|
389 |
date.hours( currentDate.hours() ) |
|
390 |
.minutes( currentDate.minutes() ) |
|
391 |
.seconds( currentDate.seconds() ) |
|
392 |
.milliseconds( currentDate.milliseconds() ); |
|
393 |
|
|
394 |
if ( !this.props.value ) { |
7750ac
|
395 |
var open = !( this.props.closeOnSelect && close ); |
JM |
396 |
if ( !open ) { |
|
397 |
this.props.onBlur( date ); |
|
398 |
} |
|
399 |
|
be9654
|
400 |
this.setState({ |
SE |
401 |
selectedDate: date, |
|
402 |
viewDate: date.clone().startOf('month'), |
|
403 |
inputValue: date.format( this.state.inputFormat ), |
7750ac
|
404 |
open: open |
be9654
|
405 |
}); |
SE |
406 |
} else { |
7750ac
|
407 |
if ( this.props.closeOnSelect && close ) { |
be9654
|
408 |
this.closeCalendar(); |
SE |
409 |
} |
|
410 |
} |
|
411 |
|
|
412 |
this.props.onChange( date ); |
|
413 |
}, |
|
414 |
|
|
415 |
openCalendar: function() { |
|
416 |
if (!this.state.open) { |
|
417 |
this.setState({ open: true }, function() { |
|
418 |
this.props.onFocus(); |
|
419 |
}); |
|
420 |
} |
|
421 |
}, |
|
422 |
|
|
423 |
closeCalendar: function() { |
|
424 |
this.setState({ open: false }, function () { |
|
425 |
this.props.onBlur( this.state.selectedDate || this.state.inputValue ); |
|
426 |
}); |
|
427 |
}, |
|
428 |
|
|
429 |
handleClickOutside: function() { |
|
430 |
if ( this.props.input && this.state.open && !this.props.open ) { |
|
431 |
this.setState({ open: false }, function() { |
|
432 |
this.props.onBlur( this.state.selectedDate || this.state.inputValue ); |
|
433 |
}); |
|
434 |
} |
|
435 |
}, |
|
436 |
|
|
437 |
localMoment: function( date, format, props ) { |
|
438 |
props = props || this.props; |
|
439 |
var momentFn = props.utc ? moment.utc : moment; |
|
440 |
var m = momentFn( date, format, props.strictParsing ); |
|
441 |
if ( props.locale ) |
|
442 |
m.locale( props.locale ); |
|
443 |
return m; |
|
444 |
}, |
|
445 |
|
|
446 |
componentProps: { |
|
447 |
fromProps: ['value', 'isValidDate', 'renderDay', 'renderMonth', 'renderYear', 'timeConstraints'], |
|
448 |
fromState: ['viewDate', 'selectedDate', 'updateOn'], |
11612b
|
449 |
fromThis: ['setDate', 'setTime', 'showView', 'addTime', 'subtractTime', 'updateSelectedDate', 'localMoment', 'handleClickOutside'] |
be9654
|
450 |
}, |
SE |
451 |
|
|
452 |
getComponentProps: function() { |
|
453 |
var me = this, |
|
454 |
formats = this.getFormats( this.props ), |
|
455 |
props = {dateFormat: formats.date, timeFormat: formats.time} |
8f6f33
|
456 |
; |
be9654
|
457 |
|
SE |
458 |
this.componentProps.fromProps.forEach( function( name ) { |
|
459 |
props[ name ] = me.props[ name ]; |
|
460 |
}); |
|
461 |
this.componentProps.fromState.forEach( function( name ) { |
|
462 |
props[ name ] = me.state[ name ]; |
|
463 |
}); |
|
464 |
this.componentProps.fromThis.forEach( function( name ) { |
|
465 |
props[ name ] = me[ name ]; |
|
466 |
}); |
|
467 |
|
|
468 |
return props; |
|
469 |
}, |
|
470 |
|
|
471 |
render: function() { |
8f6f33
|
472 |
// TODO: Make a function or clean up this code, |
LA |
473 |
// logic right now is really hard to follow |
a50b2e
|
474 |
var className = 'rdt' + (this.props.className ? |
be9654
|
475 |
( Array.isArray( this.props.className ) ? |
SE |
476 |
' ' + this.props.className.join( ' ' ) : ' ' + this.props.className) : ''), |
8f6f33
|
477 |
children = []; |
be9654
|
478 |
|
SE |
479 |
if ( this.props.input ) { |
a50b2e
|
480 |
children = [ React.createElement('input', assign({ |
be9654
|
481 |
key: 'i', |
SE |
482 |
type: 'text', |
|
483 |
className: 'form-control', |
|
484 |
onFocus: this.openCalendar, |
|
485 |
onChange: this.onInputChange, |
|
486 |
onKeyDown: this.onInputKey, |
|
487 |
value: this.state.inputValue |
|
488 |
}, this.props.inputProps ))]; |
|
489 |
} else { |
|
490 |
className += ' rdtStatic'; |
|
491 |
} |
|
492 |
|
|
493 |
if ( this.state.open ) |
|
494 |
className += ' rdtOpen'; |
|
495 |
|
a50b2e
|
496 |
return React.createElement('div', {className: className}, children.concat( |
GL |
497 |
React.createElement('div', |
be9654
|
498 |
{ key: 'dt', className: 'rdtPicker' }, |
7750ac
|
499 |
React.createElement( CalendarContainer, {view: this.state.currentView, viewProps: this.getComponentProps(), onClickOutside: this.handleClickOutside }) |
be9654
|
500 |
) |
SE |
501 |
)); |
|
502 |
} |
|
503 |
}); |
|
504 |
|
|
505 |
// Make moment accessible through the Datetime class |
|
506 |
Datetime.moment = moment; |
|
507 |
|
|
508 |
module.exports = Datetime; |
|
509 |
|
d76f7b
|
510 |
|
7392ed
|
511 |
/***/ }), |
d76f7b
|
512 |
/* 1 */ |
7392ed
|
513 |
/***/ (function(module, exports) { |
d76f7b
|
514 |
|
be9654
|
515 |
'use strict'; |
SE |
516 |
var propIsEnumerable = Object.prototype.propertyIsEnumerable; |
|
517 |
|
|
518 |
function ToObject(val) { |
|
519 |
if (val == null) { |
|
520 |
throw new TypeError('Object.assign cannot be called with null or undefined'); |
|
521 |
} |
|
522 |
|
|
523 |
return Object(val); |
|
524 |
} |
|
525 |
|
|
526 |
function ownEnumerableKeys(obj) { |
|
527 |
var keys = Object.getOwnPropertyNames(obj); |
|
528 |
|
|
529 |
if (Object.getOwnPropertySymbols) { |
|
530 |
keys = keys.concat(Object.getOwnPropertySymbols(obj)); |
|
531 |
} |
|
532 |
|
|
533 |
return keys.filter(function (key) { |
|
534 |
return propIsEnumerable.call(obj, key); |
|
535 |
}); |
|
536 |
} |
|
537 |
|
|
538 |
module.exports = Object.assign || function (target, source) { |
|
539 |
var from; |
|
540 |
var keys; |
|
541 |
var to = ToObject(target); |
|
542 |
|
|
543 |
for (var s = 1; s < arguments.length; s++) { |
|
544 |
from = arguments[s]; |
|
545 |
keys = ownEnumerableKeys(Object(from)); |
|
546 |
|
|
547 |
for (var i = 0; i < keys.length; i++) { |
|
548 |
to[keys[i]] = from[keys[i]]; |
|
549 |
} |
|
550 |
} |
|
551 |
|
|
552 |
return to; |
|
553 |
}; |
|
554 |
|
d76f7b
|
555 |
|
7392ed
|
556 |
/***/ }), |
d76f7b
|
557 |
/* 2 */ |
7392ed
|
558 |
/***/ (function(module, exports, __webpack_require__) { |
d76f7b
|
559 |
|
be31e2
|
560 |
/* WEBPACK VAR INJECTION */(function(process) {/** |
JB |
561 |
* Copyright 2013-present, Facebook, Inc. |
|
562 |
* All rights reserved. |
|
563 |
* |
|
564 |
* This source code is licensed under the BSD-style license found in the |
|
565 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
566 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
567 |
*/ |
|
568 |
|
|
569 |
if (process.env.NODE_ENV !== 'production') { |
|
570 |
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && |
|
571 |
Symbol.for && |
|
572 |
Symbol.for('react.element')) || |
|
573 |
0xeac7; |
|
574 |
|
|
575 |
var isValidElement = function(object) { |
|
576 |
return typeof object === 'object' && |
|
577 |
object !== null && |
|
578 |
object.$$typeof === REACT_ELEMENT_TYPE; |
|
579 |
}; |
|
580 |
|
|
581 |
// By explicitly using `prop-types` you are opting into new development behavior. |
|
582 |
// http://fb.me/prop-types-in-prod |
|
583 |
var throwOnDirectAccess = true; |
|
584 |
module.exports = __webpack_require__(4)(isValidElement, throwOnDirectAccess); |
|
585 |
} else { |
|
586 |
// By explicitly using `prop-types` you are opting into new production behavior. |
|
587 |
// http://fb.me/prop-types-in-prod |
|
588 |
module.exports = __webpack_require__(10)(); |
|
589 |
} |
|
590 |
|
|
591 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) |
d76f7b
|
592 |
|
7392ed
|
593 |
/***/ }), |
d76f7b
|
594 |
/* 3 */ |
7392ed
|
595 |
/***/ (function(module, exports) { |
d76f7b
|
596 |
|
be31e2
|
597 |
// shim for using process in browser |
JB |
598 |
var process = module.exports = {}; |
|
599 |
|
|
600 |
// cached from whatever global is present so that test runners that stub it |
|
601 |
// don't break things. But we need to wrap it in a try catch in case it is |
|
602 |
// wrapped in strict mode code which doesn't define any globals. It's inside a |
|
603 |
// function because try/catches deoptimize in certain engines. |
|
604 |
|
|
605 |
var cachedSetTimeout; |
|
606 |
var cachedClearTimeout; |
|
607 |
|
|
608 |
function defaultSetTimout() { |
|
609 |
throw new Error('setTimeout has not been defined'); |
|
610 |
} |
|
611 |
function defaultClearTimeout () { |
|
612 |
throw new Error('clearTimeout has not been defined'); |
|
613 |
} |
|
614 |
(function () { |
|
615 |
try { |
|
616 |
if (typeof setTimeout === 'function') { |
|
617 |
cachedSetTimeout = setTimeout; |
|
618 |
} else { |
|
619 |
cachedSetTimeout = defaultSetTimout; |
|
620 |
} |
|
621 |
} catch (e) { |
|
622 |
cachedSetTimeout = defaultSetTimout; |
|
623 |
} |
|
624 |
try { |
|
625 |
if (typeof clearTimeout === 'function') { |
|
626 |
cachedClearTimeout = clearTimeout; |
|
627 |
} else { |
|
628 |
cachedClearTimeout = defaultClearTimeout; |
|
629 |
} |
|
630 |
} catch (e) { |
|
631 |
cachedClearTimeout = defaultClearTimeout; |
|
632 |
} |
|
633 |
} ()) |
|
634 |
function runTimeout(fun) { |
|
635 |
if (cachedSetTimeout === setTimeout) { |
|
636 |
//normal enviroments in sane situations |
|
637 |
return setTimeout(fun, 0); |
|
638 |
} |
|
639 |
// if setTimeout wasn't available but was latter defined |
|
640 |
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { |
|
641 |
cachedSetTimeout = setTimeout; |
|
642 |
return setTimeout(fun, 0); |
|
643 |
} |
|
644 |
try { |
|
645 |
// when when somebody has screwed with setTimeout but no I.E. maddness |
|
646 |
return cachedSetTimeout(fun, 0); |
|
647 |
} catch(e){ |
|
648 |
try { |
|
649 |
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
|
650 |
return cachedSetTimeout.call(null, fun, 0); |
|
651 |
} catch(e){ |
|
652 |
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error |
|
653 |
return cachedSetTimeout.call(this, fun, 0); |
|
654 |
} |
|
655 |
} |
|
656 |
|
|
657 |
|
|
658 |
} |
|
659 |
function runClearTimeout(marker) { |
|
660 |
if (cachedClearTimeout === clearTimeout) { |
|
661 |
//normal enviroments in sane situations |
|
662 |
return clearTimeout(marker); |
|
663 |
} |
|
664 |
// if clearTimeout wasn't available but was latter defined |
|
665 |
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { |
|
666 |
cachedClearTimeout = clearTimeout; |
|
667 |
return clearTimeout(marker); |
|
668 |
} |
|
669 |
try { |
|
670 |
// when when somebody has screwed with setTimeout but no I.E. maddness |
|
671 |
return cachedClearTimeout(marker); |
|
672 |
} catch (e){ |
|
673 |
try { |
|
674 |
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally |
|
675 |
return cachedClearTimeout.call(null, marker); |
|
676 |
} catch (e){ |
|
677 |
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. |
|
678 |
// Some versions of I.E. have different rules for clearTimeout vs setTimeout |
|
679 |
return cachedClearTimeout.call(this, marker); |
|
680 |
} |
|
681 |
} |
|
682 |
|
|
683 |
|
|
684 |
|
|
685 |
} |
|
686 |
var queue = []; |
|
687 |
var draining = false; |
|
688 |
var currentQueue; |
|
689 |
var queueIndex = -1; |
|
690 |
|
|
691 |
function cleanUpNextTick() { |
|
692 |
if (!draining || !currentQueue) { |
|
693 |
return; |
|
694 |
} |
|
695 |
draining = false; |
|
696 |
if (currentQueue.length) { |
|
697 |
queue = currentQueue.concat(queue); |
|
698 |
} else { |
|
699 |
queueIndex = -1; |
|
700 |
} |
|
701 |
if (queue.length) { |
|
702 |
drainQueue(); |
|
703 |
} |
|
704 |
} |
|
705 |
|
|
706 |
function drainQueue() { |
|
707 |
if (draining) { |
|
708 |
return; |
|
709 |
} |
|
710 |
var timeout = runTimeout(cleanUpNextTick); |
|
711 |
draining = true; |
|
712 |
|
|
713 |
var len = queue.length; |
|
714 |
while(len) { |
|
715 |
currentQueue = queue; |
|
716 |
queue = []; |
|
717 |
while (++queueIndex < len) { |
|
718 |
if (currentQueue) { |
|
719 |
currentQueue[queueIndex].run(); |
|
720 |
} |
|
721 |
} |
|
722 |
queueIndex = -1; |
|
723 |
len = queue.length; |
|
724 |
} |
|
725 |
currentQueue = null; |
|
726 |
draining = false; |
|
727 |
runClearTimeout(timeout); |
|
728 |
} |
|
729 |
|
|
730 |
process.nextTick = function (fun) { |
|
731 |
var args = new Array(arguments.length - 1); |
|
732 |
if (arguments.length > 1) { |
|
733 |
for (var i = 1; i < arguments.length; i++) { |
|
734 |
args[i - 1] = arguments[i]; |
|
735 |
} |
|
736 |
} |
|
737 |
queue.push(new Item(fun, args)); |
|
738 |
if (queue.length === 1 && !draining) { |
|
739 |
runTimeout(drainQueue); |
|
740 |
} |
|
741 |
}; |
|
742 |
|
|
743 |
// v8 likes predictible objects |
|
744 |
function Item(fun, array) { |
|
745 |
this.fun = fun; |
|
746 |
this.array = array; |
|
747 |
} |
|
748 |
Item.prototype.run = function () { |
|
749 |
this.fun.apply(null, this.array); |
|
750 |
}; |
|
751 |
process.title = 'browser'; |
|
752 |
process.browser = true; |
|
753 |
process.env = {}; |
|
754 |
process.argv = []; |
|
755 |
process.version = ''; // empty string to avoid regexp issues |
|
756 |
process.versions = {}; |
|
757 |
|
|
758 |
function noop() {} |
|
759 |
|
|
760 |
process.on = noop; |
|
761 |
process.addListener = noop; |
|
762 |
process.once = noop; |
|
763 |
process.off = noop; |
|
764 |
process.removeListener = noop; |
|
765 |
process.removeAllListeners = noop; |
|
766 |
process.emit = noop; |
a50b2e
|
767 |
process.prependListener = noop; |
GL |
768 |
process.prependOnceListener = noop; |
|
769 |
|
|
770 |
process.listeners = function (name) { return [] } |
be31e2
|
771 |
|
JB |
772 |
process.binding = function (name) { |
|
773 |
throw new Error('process.binding is not supported'); |
|
774 |
}; |
|
775 |
|
|
776 |
process.cwd = function () { return '/' }; |
|
777 |
process.chdir = function (dir) { |
|
778 |
throw new Error('process.chdir is not supported'); |
|
779 |
}; |
|
780 |
process.umask = function() { return 0; }; |
|
781 |
|
d76f7b
|
782 |
|
7392ed
|
783 |
/***/ }), |
d76f7b
|
784 |
/* 4 */ |
7392ed
|
785 |
/***/ (function(module, exports, __webpack_require__) { |
7750ac
|
786 |
|
be31e2
|
787 |
/* WEBPACK VAR INJECTION */(function(process) {/** |
JB |
788 |
* Copyright 2013-present, Facebook, Inc. |
|
789 |
* All rights reserved. |
|
790 |
* |
|
791 |
* This source code is licensed under the BSD-style license found in the |
|
792 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
793 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
794 |
*/ |
|
795 |
|
|
796 |
'use strict'; |
|
797 |
|
|
798 |
var emptyFunction = __webpack_require__(5); |
|
799 |
var invariant = __webpack_require__(6); |
|
800 |
var warning = __webpack_require__(7); |
|
801 |
|
|
802 |
var ReactPropTypesSecret = __webpack_require__(8); |
|
803 |
var checkPropTypes = __webpack_require__(9); |
|
804 |
|
|
805 |
module.exports = function(isValidElement, throwOnDirectAccess) { |
|
806 |
/* global Symbol */ |
|
807 |
var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; |
|
808 |
var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. |
|
809 |
|
|
810 |
/** |
|
811 |
* Returns the iterator method function contained on the iterable object. |
|
812 |
* |
|
813 |
* Be sure to invoke the function with the iterable as context: |
|
814 |
* |
|
815 |
* var iteratorFn = getIteratorFn(myIterable); |
|
816 |
* if (iteratorFn) { |
|
817 |
* var iterator = iteratorFn.call(myIterable); |
|
818 |
* ... |
|
819 |
* } |
|
820 |
* |
|
821 |
* @param {?object} maybeIterable |
|
822 |
* @return {?function} |
|
823 |
*/ |
|
824 |
function getIteratorFn(maybeIterable) { |
|
825 |
var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); |
|
826 |
if (typeof iteratorFn === 'function') { |
|
827 |
return iteratorFn; |
|
828 |
} |
|
829 |
} |
|
830 |
|
|
831 |
/** |
|
832 |
* Collection of methods that allow declaration and validation of props that are |
|
833 |
* supplied to React components. Example usage: |
|
834 |
* |
|
835 |
* var Props = require('ReactPropTypes'); |
|
836 |
* var MyArticle = React.createClass({ |
|
837 |
* propTypes: { |
|
838 |
* // An optional string prop named "description". |
|
839 |
* description: Props.string, |
|
840 |
* |
|
841 |
* // A required enum prop named "category". |
|
842 |
* category: Props.oneOf(['News','Photos']).isRequired, |
|
843 |
* |
|
844 |
* // A prop named "dialog" that requires an instance of Dialog. |
|
845 |
* dialog: Props.instanceOf(Dialog).isRequired |
|
846 |
* }, |
|
847 |
* render: function() { ... } |
|
848 |
* }); |
|
849 |
* |
|
850 |
* A more formal specification of how these methods are used: |
|
851 |
* |
|
852 |
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) |
|
853 |
* decl := ReactPropTypes.{type}(.isRequired)? |
|
854 |
* |
|
855 |
* Each and every declaration produces a function with the same signature. This |
|
856 |
* allows the creation of custom validation functions. For example: |
|
857 |
* |
|
858 |
* var MyLink = React.createClass({ |
|
859 |
* propTypes: { |
|
860 |
* // An optional string or URI prop named "href". |
|
861 |
* href: function(props, propName, componentName) { |
|
862 |
* var propValue = props[propName]; |
|
863 |
* if (propValue != null && typeof propValue !== 'string' && |
|
864 |
* !(propValue instanceof URI)) { |
|
865 |
* return new Error( |
|
866 |
* 'Expected a string or an URI for ' + propName + ' in ' + |
|
867 |
* componentName |
|
868 |
* ); |
|
869 |
* } |
|
870 |
* } |
|
871 |
* }, |
|
872 |
* render: function() {...} |
|
873 |
* }); |
|
874 |
* |
|
875 |
* @internal |
|
876 |
*/ |
|
877 |
|
|
878 |
var ANONYMOUS = '<<anonymous>>'; |
|
879 |
|
|
880 |
// Important! |
|
881 |
// Keep this list in sync with production version in `./factoryWithThrowingShims.js`. |
|
882 |
var ReactPropTypes = { |
|
883 |
array: createPrimitiveTypeChecker('array'), |
|
884 |
bool: createPrimitiveTypeChecker('boolean'), |
|
885 |
func: createPrimitiveTypeChecker('function'), |
|
886 |
number: createPrimitiveTypeChecker('number'), |
|
887 |
object: createPrimitiveTypeChecker('object'), |
|
888 |
string: createPrimitiveTypeChecker('string'), |
|
889 |
symbol: createPrimitiveTypeChecker('symbol'), |
|
890 |
|
|
891 |
any: createAnyTypeChecker(), |
|
892 |
arrayOf: createArrayOfTypeChecker, |
|
893 |
element: createElementTypeChecker(), |
|
894 |
instanceOf: createInstanceTypeChecker, |
|
895 |
node: createNodeChecker(), |
|
896 |
objectOf: createObjectOfTypeChecker, |
|
897 |
oneOf: createEnumTypeChecker, |
|
898 |
oneOfType: createUnionTypeChecker, |
|
899 |
shape: createShapeTypeChecker |
|
900 |
}; |
|
901 |
|
|
902 |
/** |
|
903 |
* inlined Object.is polyfill to avoid requiring consumers ship their own |
|
904 |
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is |
|
905 |
*/ |
|
906 |
/*eslint-disable no-self-compare*/ |
|
907 |
function is(x, y) { |
|
908 |
// SameValue algorithm |
|
909 |
if (x === y) { |
|
910 |
// Steps 1-5, 7-10 |
|
911 |
// Steps 6.b-6.e: +0 != -0 |
|
912 |
return x !== 0 || 1 / x === 1 / y; |
|
913 |
} else { |
|
914 |
// Step 6.a: NaN == NaN |
|
915 |
return x !== x && y !== y; |
|
916 |
} |
|
917 |
} |
|
918 |
/*eslint-enable no-self-compare*/ |
|
919 |
|
|
920 |
/** |
|
921 |
* We use an Error-like object for backward compatibility as people may call |
|
922 |
* PropTypes directly and inspect their output. However, we don't use real |
|
923 |
* Errors anymore. We don't inspect their stack anyway, and creating them |
|
924 |
* is prohibitively expensive if they are created too often, such as what |
|
925 |
* happens in oneOfType() for any type before the one that matched. |
|
926 |
*/ |
|
927 |
function PropTypeError(message) { |
|
928 |
this.message = message; |
|
929 |
this.stack = ''; |
|
930 |
} |
|
931 |
// Make `instanceof Error` still work for returned errors. |
|
932 |
PropTypeError.prototype = Error.prototype; |
|
933 |
|
|
934 |
function createChainableTypeChecker(validate) { |
|
935 |
if (process.env.NODE_ENV !== 'production') { |
|
936 |
var manualPropTypeCallCache = {}; |
7392ed
|
937 |
var manualPropTypeWarningCount = 0; |
be31e2
|
938 |
} |
JB |
939 |
function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { |
|
940 |
componentName = componentName || ANONYMOUS; |
|
941 |
propFullName = propFullName || propName; |
|
942 |
|
|
943 |
if (secret !== ReactPropTypesSecret) { |
|
944 |
if (throwOnDirectAccess) { |
|
945 |
// New behavior only for users of `prop-types` package |
|
946 |
invariant( |
|
947 |
false, |
|
948 |
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + |
|
949 |
'Use `PropTypes.checkPropTypes()` to call them. ' + |
|
950 |
'Read more at http://fb.me/use-check-prop-types' |
|
951 |
); |
|
952 |
} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') { |
|
953 |
// Old behavior for people using React.PropTypes |
|
954 |
var cacheKey = componentName + ':' + propName; |
7392ed
|
955 |
if ( |
SE |
956 |
!manualPropTypeCallCache[cacheKey] && |
|
957 |
// Avoid spamming the console because they are often not actionable except for lib authors |
|
958 |
manualPropTypeWarningCount < 3 |
|
959 |
) { |
be31e2
|
960 |
warning( |
JB |
961 |
false, |
|
962 |
'You are manually calling a React.PropTypes validation ' + |
|
963 |
'function for the `%s` prop on `%s`. This is deprecated ' + |
|
964 |
'and will throw in the standalone `prop-types` package. ' + |
|
965 |
'You may be seeing this warning due to a third-party PropTypes ' + |
|
966 |
'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', |
|
967 |
propFullName, |
|
968 |
componentName |
|
969 |
); |
|
970 |
manualPropTypeCallCache[cacheKey] = true; |
7392ed
|
971 |
manualPropTypeWarningCount++; |
be31e2
|
972 |
} |
JB |
973 |
} |
|
974 |
} |
|
975 |
if (props[propName] == null) { |
|
976 |
if (isRequired) { |
|
977 |
if (props[propName] === null) { |
|
978 |
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); |
|
979 |
} |
|
980 |
return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); |
|
981 |
} |
|
982 |
return null; |
|
983 |
} else { |
|
984 |
return validate(props, propName, componentName, location, propFullName); |
|
985 |
} |
|
986 |
} |
|
987 |
|
|
988 |
var chainedCheckType = checkType.bind(null, false); |
|
989 |
chainedCheckType.isRequired = checkType.bind(null, true); |
|
990 |
|
|
991 |
return chainedCheckType; |
|
992 |
} |
|
993 |
|
|
994 |
function createPrimitiveTypeChecker(expectedType) { |
|
995 |
function validate(props, propName, componentName, location, propFullName, secret) { |
|
996 |
var propValue = props[propName]; |
|
997 |
var propType = getPropType(propValue); |
|
998 |
if (propType !== expectedType) { |
|
999 |
// `propValue` being instance of, say, date/regexp, pass the 'object' |
|
1000 |
// check, but we can offer a more precise error message here rather than |
|
1001 |
// 'of type `object`'. |
|
1002 |
var preciseType = getPreciseType(propValue); |
|
1003 |
|
|
1004 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); |
|
1005 |
} |
|
1006 |
return null; |
|
1007 |
} |
|
1008 |
return createChainableTypeChecker(validate); |
|
1009 |
} |
|
1010 |
|
|
1011 |
function createAnyTypeChecker() { |
|
1012 |
return createChainableTypeChecker(emptyFunction.thatReturnsNull); |
|
1013 |
} |
|
1014 |
|
|
1015 |
function createArrayOfTypeChecker(typeChecker) { |
|
1016 |
function validate(props, propName, componentName, location, propFullName) { |
|
1017 |
if (typeof typeChecker !== 'function') { |
|
1018 |
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); |
|
1019 |
} |
|
1020 |
var propValue = props[propName]; |
|
1021 |
if (!Array.isArray(propValue)) { |
|
1022 |
var propType = getPropType(propValue); |
|
1023 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); |
|
1024 |
} |
|
1025 |
for (var i = 0; i < propValue.length; i++) { |
|
1026 |
var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); |
|
1027 |
if (error instanceof Error) { |
|
1028 |
return error; |
|
1029 |
} |
|
1030 |
} |
|
1031 |
return null; |
|
1032 |
} |
|
1033 |
return createChainableTypeChecker(validate); |
|
1034 |
} |
|
1035 |
|
|
1036 |
function createElementTypeChecker() { |
|
1037 |
function validate(props, propName, componentName, location, propFullName) { |
|
1038 |
var propValue = props[propName]; |
|
1039 |
if (!isValidElement(propValue)) { |
|
1040 |
var propType = getPropType(propValue); |
|
1041 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); |
|
1042 |
} |
|
1043 |
return null; |
|
1044 |
} |
|
1045 |
return createChainableTypeChecker(validate); |
|
1046 |
} |
|
1047 |
|
|
1048 |
function createInstanceTypeChecker(expectedClass) { |
|
1049 |
function validate(props, propName, componentName, location, propFullName) { |
|
1050 |
if (!(props[propName] instanceof expectedClass)) { |
|
1051 |
var expectedClassName = expectedClass.name || ANONYMOUS; |
|
1052 |
var actualClassName = getClassName(props[propName]); |
|
1053 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); |
|
1054 |
} |
|
1055 |
return null; |
|
1056 |
} |
|
1057 |
return createChainableTypeChecker(validate); |
|
1058 |
} |
|
1059 |
|
|
1060 |
function createEnumTypeChecker(expectedValues) { |
|
1061 |
if (!Array.isArray(expectedValues)) { |
|
1062 |
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; |
|
1063 |
return emptyFunction.thatReturnsNull; |
|
1064 |
} |
|
1065 |
|
|
1066 |
function validate(props, propName, componentName, location, propFullName) { |
|
1067 |
var propValue = props[propName]; |
|
1068 |
for (var i = 0; i < expectedValues.length; i++) { |
|
1069 |
if (is(propValue, expectedValues[i])) { |
|
1070 |
return null; |
|
1071 |
} |
|
1072 |
} |
|
1073 |
|
|
1074 |
var valuesString = JSON.stringify(expectedValues); |
|
1075 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); |
|
1076 |
} |
|
1077 |
return createChainableTypeChecker(validate); |
|
1078 |
} |
|
1079 |
|
|
1080 |
function createObjectOfTypeChecker(typeChecker) { |
|
1081 |
function validate(props, propName, componentName, location, propFullName) { |
|
1082 |
if (typeof typeChecker !== 'function') { |
|
1083 |
return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); |
|
1084 |
} |
|
1085 |
var propValue = props[propName]; |
|
1086 |
var propType = getPropType(propValue); |
|
1087 |
if (propType !== 'object') { |
|
1088 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); |
|
1089 |
} |
|
1090 |
for (var key in propValue) { |
|
1091 |
if (propValue.hasOwnProperty(key)) { |
|
1092 |
var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); |
|
1093 |
if (error instanceof Error) { |
|
1094 |
return error; |
|
1095 |
} |
|
1096 |
} |
|
1097 |
} |
|
1098 |
return null; |
|
1099 |
} |
|
1100 |
return createChainableTypeChecker(validate); |
|
1101 |
} |
|
1102 |
|
|
1103 |
function createUnionTypeChecker(arrayOfTypeCheckers) { |
|
1104 |
if (!Array.isArray(arrayOfTypeCheckers)) { |
|
1105 |
process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; |
|
1106 |
return emptyFunction.thatReturnsNull; |
|
1107 |
} |
|
1108 |
|
a50b2e
|
1109 |
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { |
GL |
1110 |
var checker = arrayOfTypeCheckers[i]; |
|
1111 |
if (typeof checker !== 'function') { |
|
1112 |
warning( |
|
1113 |
false, |
|
1114 |
'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' + |
|
1115 |
'received %s at index %s.', |
|
1116 |
getPostfixForTypeWarning(checker), |
|
1117 |
i |
|
1118 |
); |
|
1119 |
return emptyFunction.thatReturnsNull; |
|
1120 |
} |
|
1121 |
} |
|
1122 |
|
be31e2
|
1123 |
function validate(props, propName, componentName, location, propFullName) { |
JB |
1124 |
for (var i = 0; i < arrayOfTypeCheckers.length; i++) { |
|
1125 |
var checker = arrayOfTypeCheckers[i]; |
|
1126 |
if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { |
|
1127 |
return null; |
|
1128 |
} |
|
1129 |
} |
|
1130 |
|
|
1131 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); |
|
1132 |
} |
|
1133 |
return createChainableTypeChecker(validate); |
|
1134 |
} |
|
1135 |
|
|
1136 |
function createNodeChecker() { |
|
1137 |
function validate(props, propName, componentName, location, propFullName) { |
|
1138 |
if (!isNode(props[propName])) { |
|
1139 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); |
|
1140 |
} |
|
1141 |
return null; |
|
1142 |
} |
|
1143 |
return createChainableTypeChecker(validate); |
|
1144 |
} |
|
1145 |
|
|
1146 |
function createShapeTypeChecker(shapeTypes) { |
|
1147 |
function validate(props, propName, componentName, location, propFullName) { |
|
1148 |
var propValue = props[propName]; |
|
1149 |
var propType = getPropType(propValue); |
|
1150 |
if (propType !== 'object') { |
|
1151 |
return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); |
|
1152 |
} |
|
1153 |
for (var key in shapeTypes) { |
|
1154 |
var checker = shapeTypes[key]; |
|
1155 |
if (!checker) { |
|
1156 |
continue; |
|
1157 |
} |
|
1158 |
var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); |
|
1159 |
if (error) { |
|
1160 |
return error; |
|
1161 |
} |
|
1162 |
} |
|
1163 |
return null; |
|
1164 |
} |
|
1165 |
return createChainableTypeChecker(validate); |
|
1166 |
} |
|
1167 |
|
|
1168 |
function isNode(propValue) { |
|
1169 |
switch (typeof propValue) { |
|
1170 |
case 'number': |
|
1171 |
case 'string': |
|
1172 |
case 'undefined': |
|
1173 |
return true; |
|
1174 |
case 'boolean': |
|
1175 |
return !propValue; |
|
1176 |
case 'object': |
|
1177 |
if (Array.isArray(propValue)) { |
|
1178 |
return propValue.every(isNode); |
|
1179 |
} |
|
1180 |
if (propValue === null || isValidElement(propValue)) { |
|
1181 |
return true; |
|
1182 |
} |
|
1183 |
|
|
1184 |
var iteratorFn = getIteratorFn(propValue); |
|
1185 |
if (iteratorFn) { |
|
1186 |
var iterator = iteratorFn.call(propValue); |
|
1187 |
var step; |
|
1188 |
if (iteratorFn !== propValue.entries) { |
|
1189 |
while (!(step = iterator.next()).done) { |
|
1190 |
if (!isNode(step.value)) { |
|
1191 |
return false; |
|
1192 |
} |
|
1193 |
} |
|
1194 |
} else { |
|
1195 |
// Iterator will provide entry [k,v] tuples rather than values. |
|
1196 |
while (!(step = iterator.next()).done) { |
|
1197 |
var entry = step.value; |
|
1198 |
if (entry) { |
|
1199 |
if (!isNode(entry[1])) { |
|
1200 |
return false; |
|
1201 |
} |
|
1202 |
} |
|
1203 |
} |
|
1204 |
} |
|
1205 |
} else { |
|
1206 |
return false; |
|
1207 |
} |
|
1208 |
|
|
1209 |
return true; |
|
1210 |
default: |
|
1211 |
return false; |
|
1212 |
} |
|
1213 |
} |
|
1214 |
|
|
1215 |
function isSymbol(propType, propValue) { |
|
1216 |
// Native Symbol. |
|
1217 |
if (propType === 'symbol') { |
|
1218 |
return true; |
|
1219 |
} |
|
1220 |
|
|
1221 |
// 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' |
|
1222 |
if (propValue['@@toStringTag'] === 'Symbol') { |
|
1223 |
return true; |
|
1224 |
} |
|
1225 |
|
|
1226 |
// Fallback for non-spec compliant Symbols which are polyfilled. |
|
1227 |
if (typeof Symbol === 'function' && propValue instanceof Symbol) { |
|
1228 |
return true; |
|
1229 |
} |
|
1230 |
|
|
1231 |
return false; |
|
1232 |
} |
|
1233 |
|
|
1234 |
// Equivalent of `typeof` but with special handling for array and regexp. |
|
1235 |
function getPropType(propValue) { |
|
1236 |
var propType = typeof propValue; |
|
1237 |
if (Array.isArray(propValue)) { |
|
1238 |
return 'array'; |
|
1239 |
} |
|
1240 |
if (propValue instanceof RegExp) { |
|
1241 |
// Old webkits (at least until Android 4.0) return 'function' rather than |
|
1242 |
// 'object' for typeof a RegExp. We'll normalize this here so that /bla/ |
|
1243 |
// passes PropTypes.object. |
|
1244 |
return 'object'; |
|
1245 |
} |
|
1246 |
if (isSymbol(propType, propValue)) { |
|
1247 |
return 'symbol'; |
|
1248 |
} |
|
1249 |
return propType; |
|
1250 |
} |
|
1251 |
|
|
1252 |
// This handles more types than `getPropType`. Only used for error messages. |
|
1253 |
// See `createPrimitiveTypeChecker`. |
|
1254 |
function getPreciseType(propValue) { |
a50b2e
|
1255 |
if (typeof propValue === 'undefined' || propValue === null) { |
GL |
1256 |
return '' + propValue; |
|
1257 |
} |
be31e2
|
1258 |
var propType = getPropType(propValue); |
JB |
1259 |
if (propType === 'object') { |
|
1260 |
if (propValue instanceof Date) { |
|
1261 |
return 'date'; |
|
1262 |
} else if (propValue instanceof RegExp) { |
|
1263 |
return 'regexp'; |
|
1264 |
} |
|
1265 |
} |
|
1266 |
return propType; |
a50b2e
|
1267 |
} |
GL |
1268 |
|
|
1269 |
// Returns a string that is postfixed to a warning about an invalid type. |
|
1270 |
// For example, "undefined" or "of type array" |
|
1271 |
function getPostfixForTypeWarning(value) { |
|
1272 |
var type = getPreciseType(value); |
|
1273 |
switch (type) { |
|
1274 |
case 'array': |
|
1275 |
case 'object': |
|
1276 |
return 'an ' + type; |
|
1277 |
case 'boolean': |
|
1278 |
case 'date': |
|
1279 |
case 'regexp': |
|
1280 |
return 'a ' + type; |
|
1281 |
default: |
|
1282 |
return type; |
|
1283 |
} |
be31e2
|
1284 |
} |
JB |
1285 |
|
|
1286 |
// Returns class name of the object, if any. |
|
1287 |
function getClassName(propValue) { |
|
1288 |
if (!propValue.constructor || !propValue.constructor.name) { |
|
1289 |
return ANONYMOUS; |
|
1290 |
} |
|
1291 |
return propValue.constructor.name; |
|
1292 |
} |
|
1293 |
|
|
1294 |
ReactPropTypes.checkPropTypes = checkPropTypes; |
|
1295 |
ReactPropTypes.PropTypes = ReactPropTypes; |
|
1296 |
|
|
1297 |
return ReactPropTypes; |
|
1298 |
}; |
|
1299 |
|
|
1300 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) |
|
1301 |
|
7392ed
|
1302 |
/***/ }), |
be31e2
|
1303 |
/* 5 */ |
7392ed
|
1304 |
/***/ (function(module, exports) { |
be31e2
|
1305 |
|
JB |
1306 |
"use strict"; |
|
1307 |
|
|
1308 |
/** |
|
1309 |
* Copyright (c) 2013-present, Facebook, Inc. |
|
1310 |
* All rights reserved. |
|
1311 |
* |
|
1312 |
* This source code is licensed under the BSD-style license found in the |
|
1313 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1314 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1315 |
* |
|
1316 |
* |
|
1317 |
*/ |
|
1318 |
|
|
1319 |
function makeEmptyFunction(arg) { |
|
1320 |
return function () { |
|
1321 |
return arg; |
|
1322 |
}; |
|
1323 |
} |
|
1324 |
|
|
1325 |
/** |
|
1326 |
* This function accepts and discards inputs; it has no side effects. This is |
|
1327 |
* primarily useful idiomatically for overridable function endpoints which |
|
1328 |
* always need to be callable, since JS lacks a null-call idiom ala Cocoa. |
|
1329 |
*/ |
|
1330 |
var emptyFunction = function emptyFunction() {}; |
|
1331 |
|
|
1332 |
emptyFunction.thatReturns = makeEmptyFunction; |
|
1333 |
emptyFunction.thatReturnsFalse = makeEmptyFunction(false); |
|
1334 |
emptyFunction.thatReturnsTrue = makeEmptyFunction(true); |
|
1335 |
emptyFunction.thatReturnsNull = makeEmptyFunction(null); |
|
1336 |
emptyFunction.thatReturnsThis = function () { |
|
1337 |
return this; |
|
1338 |
}; |
|
1339 |
emptyFunction.thatReturnsArgument = function (arg) { |
|
1340 |
return arg; |
|
1341 |
}; |
|
1342 |
|
|
1343 |
module.exports = emptyFunction; |
|
1344 |
|
7392ed
|
1345 |
/***/ }), |
be31e2
|
1346 |
/* 6 */ |
7392ed
|
1347 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
1348 |
|
JB |
1349 |
/* WEBPACK VAR INJECTION */(function(process) {/** |
|
1350 |
* Copyright (c) 2013-present, Facebook, Inc. |
|
1351 |
* All rights reserved. |
|
1352 |
* |
|
1353 |
* This source code is licensed under the BSD-style license found in the |
|
1354 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1355 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1356 |
* |
|
1357 |
*/ |
|
1358 |
|
|
1359 |
'use strict'; |
|
1360 |
|
|
1361 |
/** |
|
1362 |
* Use invariant() to assert state which your program assumes to be true. |
|
1363 |
* |
|
1364 |
* Provide sprintf-style format (only %s is supported) and arguments |
|
1365 |
* to provide information about what broke and what you were |
|
1366 |
* expecting. |
|
1367 |
* |
|
1368 |
* The invariant message will be stripped in production, but the invariant |
|
1369 |
* will remain to ensure logic does not differ in production. |
|
1370 |
*/ |
|
1371 |
|
|
1372 |
var validateFormat = function validateFormat(format) {}; |
|
1373 |
|
|
1374 |
if (process.env.NODE_ENV !== 'production') { |
|
1375 |
validateFormat = function validateFormat(format) { |
|
1376 |
if (format === undefined) { |
|
1377 |
throw new Error('invariant requires an error message argument'); |
|
1378 |
} |
|
1379 |
}; |
|
1380 |
} |
|
1381 |
|
|
1382 |
function invariant(condition, format, a, b, c, d, e, f) { |
|
1383 |
validateFormat(format); |
|
1384 |
|
|
1385 |
if (!condition) { |
|
1386 |
var error; |
|
1387 |
if (format === undefined) { |
|
1388 |
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); |
|
1389 |
} else { |
|
1390 |
var args = [a, b, c, d, e, f]; |
|
1391 |
var argIndex = 0; |
|
1392 |
error = new Error(format.replace(/%s/g, function () { |
|
1393 |
return args[argIndex++]; |
|
1394 |
})); |
|
1395 |
error.name = 'Invariant Violation'; |
|
1396 |
} |
|
1397 |
|
|
1398 |
error.framesToPop = 1; // we don't care about invariant's own frame |
|
1399 |
throw error; |
|
1400 |
} |
|
1401 |
} |
|
1402 |
|
|
1403 |
module.exports = invariant; |
|
1404 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) |
|
1405 |
|
7392ed
|
1406 |
/***/ }), |
be31e2
|
1407 |
/* 7 */ |
7392ed
|
1408 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
1409 |
|
JB |
1410 |
/* WEBPACK VAR INJECTION */(function(process) {/** |
|
1411 |
* Copyright 2014-2015, Facebook, Inc. |
|
1412 |
* All rights reserved. |
|
1413 |
* |
|
1414 |
* This source code is licensed under the BSD-style license found in the |
|
1415 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1416 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1417 |
* |
|
1418 |
*/ |
|
1419 |
|
|
1420 |
'use strict'; |
|
1421 |
|
|
1422 |
var emptyFunction = __webpack_require__(5); |
|
1423 |
|
|
1424 |
/** |
|
1425 |
* Similar to invariant but only logs a warning if the condition is not met. |
|
1426 |
* This can be used to log issues in development environments in critical |
|
1427 |
* paths. Removing the logging code for production environments will keep the |
|
1428 |
* same logic and follow the same code paths. |
|
1429 |
*/ |
|
1430 |
|
|
1431 |
var warning = emptyFunction; |
|
1432 |
|
|
1433 |
if (process.env.NODE_ENV !== 'production') { |
eb8710
|
1434 |
var printWarning = function printWarning(format) { |
SE |
1435 |
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
1436 |
args[_key - 1] = arguments[_key]; |
|
1437 |
} |
|
1438 |
|
|
1439 |
var argIndex = 0; |
|
1440 |
var message = 'Warning: ' + format.replace(/%s/g, function () { |
|
1441 |
return args[argIndex++]; |
|
1442 |
}); |
|
1443 |
if (typeof console !== 'undefined') { |
|
1444 |
console.error(message); |
|
1445 |
} |
|
1446 |
try { |
|
1447 |
// --- Welcome to debugging React --- |
|
1448 |
// This error was thrown as a convenience so that you can use this stack |
|
1449 |
// to find the callsite that caused this warning to fire. |
|
1450 |
throw new Error(message); |
|
1451 |
} catch (x) {} |
|
1452 |
}; |
|
1453 |
|
|
1454 |
warning = function warning(condition, format) { |
|
1455 |
if (format === undefined) { |
|
1456 |
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); |
|
1457 |
} |
|
1458 |
|
|
1459 |
if (format.indexOf('Failed Composite propType: ') === 0) { |
|
1460 |
return; // Ignore CompositeComponent proptype check. |
|
1461 |
} |
|
1462 |
|
|
1463 |
if (!condition) { |
|
1464 |
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { |
|
1465 |
args[_key2 - 2] = arguments[_key2]; |
be31e2
|
1466 |
} |
JB |
1467 |
|
eb8710
|
1468 |
printWarning.apply(undefined, [format].concat(args)); |
SE |
1469 |
} |
|
1470 |
}; |
be31e2
|
1471 |
} |
JB |
1472 |
|
|
1473 |
module.exports = warning; |
|
1474 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) |
|
1475 |
|
7392ed
|
1476 |
/***/ }), |
be31e2
|
1477 |
/* 8 */ |
7392ed
|
1478 |
/***/ (function(module, exports) { |
be31e2
|
1479 |
|
JB |
1480 |
/** |
|
1481 |
* Copyright 2013-present, Facebook, Inc. |
|
1482 |
* All rights reserved. |
|
1483 |
* |
|
1484 |
* This source code is licensed under the BSD-style license found in the |
|
1485 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1486 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1487 |
*/ |
|
1488 |
|
|
1489 |
'use strict'; |
|
1490 |
|
|
1491 |
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; |
|
1492 |
|
|
1493 |
module.exports = ReactPropTypesSecret; |
|
1494 |
|
|
1495 |
|
7392ed
|
1496 |
/***/ }), |
be31e2
|
1497 |
/* 9 */ |
7392ed
|
1498 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
1499 |
|
JB |
1500 |
/* WEBPACK VAR INJECTION */(function(process) {/** |
|
1501 |
* Copyright 2013-present, Facebook, Inc. |
|
1502 |
* All rights reserved. |
|
1503 |
* |
|
1504 |
* This source code is licensed under the BSD-style license found in the |
|
1505 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1506 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1507 |
*/ |
|
1508 |
|
|
1509 |
'use strict'; |
|
1510 |
|
|
1511 |
if (process.env.NODE_ENV !== 'production') { |
|
1512 |
var invariant = __webpack_require__(6); |
|
1513 |
var warning = __webpack_require__(7); |
|
1514 |
var ReactPropTypesSecret = __webpack_require__(8); |
|
1515 |
var loggedTypeFailures = {}; |
|
1516 |
} |
|
1517 |
|
|
1518 |
/** |
|
1519 |
* Assert that the values match with the type specs. |
|
1520 |
* Error messages are memorized and will only be shown once. |
|
1521 |
* |
|
1522 |
* @param {object} typeSpecs Map of name to a ReactPropType |
|
1523 |
* @param {object} values Runtime values that need to be type-checked |
|
1524 |
* @param {string} location e.g. "prop", "context", "child context" |
|
1525 |
* @param {string} componentName Name of the component for error messages. |
|
1526 |
* @param {?Function} getStack Returns the component stack. |
|
1527 |
* @private |
|
1528 |
*/ |
|
1529 |
function checkPropTypes(typeSpecs, values, location, componentName, getStack) { |
|
1530 |
if (process.env.NODE_ENV !== 'production') { |
|
1531 |
for (var typeSpecName in typeSpecs) { |
|
1532 |
if (typeSpecs.hasOwnProperty(typeSpecName)) { |
|
1533 |
var error; |
|
1534 |
// Prop type validation may throw. In case they do, we don't want to |
|
1535 |
// fail the render phase where it didn't fail before. So we log it. |
|
1536 |
// After these have been cleaned up, we'll let them throw. |
|
1537 |
try { |
|
1538 |
// This is intentionally an invariant that gets caught. It's the same |
|
1539 |
// behavior as without this statement except with a better message. |
|
1540 |
invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName); |
|
1541 |
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); |
|
1542 |
} catch (ex) { |
|
1543 |
error = ex; |
|
1544 |
} |
|
1545 |
warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); |
|
1546 |
if (error instanceof Error && !(error.message in loggedTypeFailures)) { |
|
1547 |
// Only monitor this failure once because there tends to be a lot of the |
|
1548 |
// same error. |
|
1549 |
loggedTypeFailures[error.message] = true; |
|
1550 |
|
|
1551 |
var stack = getStack ? getStack() : ''; |
|
1552 |
|
|
1553 |
warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); |
|
1554 |
} |
|
1555 |
} |
|
1556 |
} |
|
1557 |
} |
|
1558 |
} |
|
1559 |
|
|
1560 |
module.exports = checkPropTypes; |
|
1561 |
|
|
1562 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) |
|
1563 |
|
7392ed
|
1564 |
/***/ }), |
be31e2
|
1565 |
/* 10 */ |
7392ed
|
1566 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
1567 |
|
JB |
1568 |
/** |
|
1569 |
* Copyright 2013-present, Facebook, Inc. |
|
1570 |
* All rights reserved. |
|
1571 |
* |
|
1572 |
* This source code is licensed under the BSD-style license found in the |
|
1573 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1574 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1575 |
*/ |
|
1576 |
|
|
1577 |
'use strict'; |
|
1578 |
|
|
1579 |
var emptyFunction = __webpack_require__(5); |
|
1580 |
var invariant = __webpack_require__(6); |
a50b2e
|
1581 |
var ReactPropTypesSecret = __webpack_require__(8); |
be31e2
|
1582 |
|
JB |
1583 |
module.exports = function() { |
a50b2e
|
1584 |
function shim(props, propName, componentName, location, propFullName, secret) { |
GL |
1585 |
if (secret === ReactPropTypesSecret) { |
|
1586 |
// It is still safe when called from React. |
|
1587 |
return; |
|
1588 |
} |
be31e2
|
1589 |
invariant( |
JB |
1590 |
false, |
|
1591 |
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + |
|
1592 |
'Use PropTypes.checkPropTypes() to call them. ' + |
|
1593 |
'Read more at http://fb.me/use-check-prop-types' |
|
1594 |
); |
|
1595 |
}; |
|
1596 |
shim.isRequired = shim; |
|
1597 |
function getShim() { |
|
1598 |
return shim; |
|
1599 |
}; |
a50b2e
|
1600 |
// Important! |
GL |
1601 |
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. |
be31e2
|
1602 |
var ReactPropTypes = { |
JB |
1603 |
array: shim, |
|
1604 |
bool: shim, |
|
1605 |
func: shim, |
|
1606 |
number: shim, |
|
1607 |
object: shim, |
|
1608 |
string: shim, |
|
1609 |
symbol: shim, |
|
1610 |
|
|
1611 |
any: shim, |
|
1612 |
arrayOf: getShim, |
|
1613 |
element: shim, |
|
1614 |
instanceOf: getShim, |
|
1615 |
node: shim, |
|
1616 |
objectOf: getShim, |
|
1617 |
oneOf: getShim, |
|
1618 |
oneOfType: getShim, |
|
1619 |
shape: getShim |
|
1620 |
}; |
|
1621 |
|
|
1622 |
ReactPropTypes.checkPropTypes = emptyFunction; |
|
1623 |
ReactPropTypes.PropTypes = ReactPropTypes; |
|
1624 |
|
|
1625 |
return ReactPropTypes; |
|
1626 |
}; |
|
1627 |
|
|
1628 |
|
7392ed
|
1629 |
/***/ }), |
be31e2
|
1630 |
/* 11 */ |
7392ed
|
1631 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
1632 |
|
JB |
1633 |
/** |
|
1634 |
* Copyright 2013-present, Facebook, Inc. |
|
1635 |
* All rights reserved. |
|
1636 |
* |
|
1637 |
* This source code is licensed under the BSD-style license found in the |
|
1638 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1639 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1640 |
* |
|
1641 |
*/ |
|
1642 |
|
|
1643 |
'use strict'; |
|
1644 |
|
|
1645 |
var React = __webpack_require__(12); |
|
1646 |
var factory = __webpack_require__(13); |
a50b2e
|
1647 |
|
GL |
1648 |
if (typeof React === 'undefined') { |
|
1649 |
throw Error( |
|
1650 |
'create-react-class could not find the React object. If you are using script tags, ' + |
|
1651 |
'make sure that React is being loaded before create-react-class.' |
|
1652 |
); |
|
1653 |
} |
be31e2
|
1654 |
|
JB |
1655 |
// Hack to grab NoopUpdateQueue from isomorphic React |
|
1656 |
var ReactNoopUpdateQueue = new React.Component().updater; |
|
1657 |
|
|
1658 |
module.exports = factory( |
|
1659 |
React.Component, |
|
1660 |
React.isValidElement, |
|
1661 |
ReactNoopUpdateQueue |
|
1662 |
); |
|
1663 |
|
|
1664 |
|
7392ed
|
1665 |
/***/ }), |
be31e2
|
1666 |
/* 12 */ |
7392ed
|
1667 |
/***/ (function(module, exports) { |
be31e2
|
1668 |
|
JB |
1669 |
module.exports = __WEBPACK_EXTERNAL_MODULE_12__; |
|
1670 |
|
7392ed
|
1671 |
/***/ }), |
be31e2
|
1672 |
/* 13 */ |
7392ed
|
1673 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
1674 |
|
JB |
1675 |
/* WEBPACK VAR INJECTION */(function(process) {/** |
|
1676 |
* Copyright 2013-present, Facebook, Inc. |
|
1677 |
* All rights reserved. |
|
1678 |
* |
|
1679 |
* This source code is licensed under the BSD-style license found in the |
|
1680 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
1681 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
1682 |
* |
|
1683 |
*/ |
|
1684 |
|
|
1685 |
'use strict'; |
|
1686 |
|
|
1687 |
var _assign = __webpack_require__(14); |
|
1688 |
|
|
1689 |
var emptyObject = __webpack_require__(15); |
|
1690 |
var _invariant = __webpack_require__(6); |
|
1691 |
|
|
1692 |
if (process.env.NODE_ENV !== 'production') { |
|
1693 |
var warning = __webpack_require__(7); |
|
1694 |
} |
|
1695 |
|
|
1696 |
var MIXINS_KEY = 'mixins'; |
|
1697 |
|
|
1698 |
// Helper function to allow the creation of anonymous functions which do not |
|
1699 |
// have .name set to the name of the variable being assigned to. |
|
1700 |
function identity(fn) { |
|
1701 |
return fn; |
|
1702 |
} |
|
1703 |
|
|
1704 |
var ReactPropTypeLocationNames; |
|
1705 |
if (process.env.NODE_ENV !== 'production') { |
|
1706 |
ReactPropTypeLocationNames = { |
|
1707 |
prop: 'prop', |
|
1708 |
context: 'context', |
a50b2e
|
1709 |
childContext: 'child context' |
be31e2
|
1710 |
}; |
JB |
1711 |
} else { |
|
1712 |
ReactPropTypeLocationNames = {}; |
|
1713 |
} |
|
1714 |
|
|
1715 |
function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { |
|
1716 |
/** |
|
1717 |
* Policies that describe methods in `ReactClassInterface`. |
|
1718 |
*/ |
|
1719 |
|
|
1720 |
var injectedMixins = []; |
|
1721 |
|
|
1722 |
/** |
|
1723 |
* Composite components are higher-level components that compose other composite |
|
1724 |
* or host components. |
|
1725 |
* |
|
1726 |
* To create a new type of `ReactClass`, pass a specification of |
|
1727 |
* your new class to `React.createClass`. The only requirement of your class |
|
1728 |
* specification is that you implement a `render` method. |
|
1729 |
* |
|
1730 |
* var MyComponent = React.createClass({ |
|
1731 |
* render: function() { |
|
1732 |
* return <div>Hello World</div>; |
|
1733 |
* } |
|
1734 |
* }); |
|
1735 |
* |
|
1736 |
* The class specification supports a specific protocol of methods that have |
|
1737 |
* special meaning (e.g. `render`). See `ReactClassInterface` for |
|
1738 |
* more the comprehensive protocol. Any other properties and methods in the |
|
1739 |
* class specification will be available on the prototype. |
|
1740 |
* |
|
1741 |
* @interface ReactClassInterface |
|
1742 |
* @internal |
|
1743 |
*/ |
|
1744 |
var ReactClassInterface = { |
|
1745 |
/** |
|
1746 |
* An array of Mixin objects to include when defining your component. |
|
1747 |
* |
|
1748 |
* @type {array} |
|
1749 |
* @optional |
|
1750 |
*/ |
|
1751 |
mixins: 'DEFINE_MANY', |
|
1752 |
|
|
1753 |
/** |
|
1754 |
* An object containing properties and methods that should be defined on |
|
1755 |
* the component's constructor instead of its prototype (static methods). |
|
1756 |
* |
|
1757 |
* @type {object} |
|
1758 |
* @optional |
|
1759 |
*/ |
|
1760 |
statics: 'DEFINE_MANY', |
|
1761 |
|
|
1762 |
/** |
|
1763 |
* Definition of prop types for this component. |
|
1764 |
* |
|
1765 |
* @type {object} |
|
1766 |
* @optional |
|
1767 |
*/ |
|
1768 |
propTypes: 'DEFINE_MANY', |
|
1769 |
|
|
1770 |
/** |
|
1771 |
* Definition of context types for this component. |
|
1772 |
* |
|
1773 |
* @type {object} |
|
1774 |
* @optional |
|
1775 |
*/ |
|
1776 |
contextTypes: 'DEFINE_MANY', |
|
1777 |
|
|
1778 |
/** |
|
1779 |
* Definition of context types this component sets for its children. |
|
1780 |
* |
|
1781 |
* @type {object} |
|
1782 |
* @optional |
|
1783 |
*/ |
|
1784 |
childContextTypes: 'DEFINE_MANY', |
|
1785 |
|
|
1786 |
// ==== Definition methods ==== |
|
1787 |
|
|
1788 |
/** |
|
1789 |
* Invoked when the component is mounted. Values in the mapping will be set on |
|
1790 |
* `this.props` if that prop is not specified (i.e. using an `in` check). |
|
1791 |
* |
|
1792 |
* This method is invoked before `getInitialState` and therefore cannot rely |
|
1793 |
* on `this.state` or use `this.setState`. |
|
1794 |
* |
|
1795 |
* @return {object} |
|
1796 |
* @optional |
|
1797 |
*/ |
|
1798 |
getDefaultProps: 'DEFINE_MANY_MERGED', |
|
1799 |
|
|
1800 |
/** |
|
1801 |
* Invoked once before the component is mounted. The return value will be used |
|
1802 |
* as the initial value of `this.state`. |
|
1803 |
* |
|
1804 |
* getInitialState: function() { |
|
1805 |
* return { |
|
1806 |
* isOn: false, |
|
1807 |
* fooBaz: new BazFoo() |
|
1808 |
* } |
|
1809 |
* } |
|
1810 |
* |
|
1811 |
* @return {object} |
|
1812 |
* @optional |
|
1813 |
*/ |
|
1814 |
getInitialState: 'DEFINE_MANY_MERGED', |
|
1815 |
|
|
1816 |
/** |
|
1817 |
* @return {object} |
|
1818 |
* @optional |
|
1819 |
*/ |
|
1820 |
getChildContext: 'DEFINE_MANY_MERGED', |
|
1821 |
|
|
1822 |
/** |
|
1823 |
* Uses props from `this.props` and state from `this.state` to render the |
|
1824 |
* structure of the component. |
|
1825 |
* |
|
1826 |
* No guarantees are made about when or how often this method is invoked, so |
|
1827 |
* it must not have side effects. |
|
1828 |
* |
|
1829 |
* render: function() { |
|
1830 |
* var name = this.props.name; |
|
1831 |
* return <div>Hello, {name}!</div>; |
|
1832 |
* } |
|
1833 |
* |
|
1834 |
* @return {ReactComponent} |
|
1835 |
* @required |
|
1836 |
*/ |
|
1837 |
render: 'DEFINE_ONCE', |
|
1838 |
|
|
1839 |
// ==== Delegate methods ==== |
|
1840 |
|
|
1841 |
/** |
|
1842 |
* Invoked when the component is initially created and about to be mounted. |
|
1843 |
* This may have side effects, but any external subscriptions or data created |
|
1844 |
* by this method must be cleaned up in `componentWillUnmount`. |
|
1845 |
* |
|
1846 |
* @optional |
|
1847 |
*/ |
|
1848 |
componentWillMount: 'DEFINE_MANY', |
|
1849 |
|
|
1850 |
/** |
|
1851 |
* Invoked when the component has been mounted and has a DOM representation. |
|
1852 |
* However, there is no guarantee that the DOM node is in the document. |
|
1853 |
* |
|
1854 |
* Use this as an opportunity to operate on the DOM when the component has |
|
1855 |
* been mounted (initialized and rendered) for the first time. |
|
1856 |
* |
|
1857 |
* @param {DOMElement} rootNode DOM element representing the component. |
|
1858 |
* @optional |
|
1859 |
*/ |
|
1860 |
componentDidMount: 'DEFINE_MANY', |
|
1861 |
|
|
1862 |
/** |
|
1863 |
* Invoked before the component receives new props. |
|
1864 |
* |
|
1865 |
* Use this as an opportunity to react to a prop transition by updating the |
|
1866 |
* state using `this.setState`. Current props are accessed via `this.props`. |
|
1867 |
* |
|
1868 |
* componentWillReceiveProps: function(nextProps, nextContext) { |
|
1869 |
* this.setState({ |
|
1870 |
* likesIncreasing: nextProps.likeCount > this.props.likeCount |
|
1871 |
* }); |
|
1872 |
* } |
|
1873 |
* |
|
1874 |
* NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop |
|
1875 |
* transition may cause a state change, but the opposite is not true. If you |
|
1876 |
* need it, you are probably looking for `componentWillUpdate`. |
|
1877 |
* |
|
1878 |
* @param {object} nextProps |
|
1879 |
* @optional |
|
1880 |
*/ |
|
1881 |
componentWillReceiveProps: 'DEFINE_MANY', |
|
1882 |
|
|
1883 |
/** |
|
1884 |
* Invoked while deciding if the component should be updated as a result of |
|
1885 |
* receiving new props, state and/or context. |
|
1886 |
* |
|
1887 |
* Use this as an opportunity to `return false` when you're certain that the |
|
1888 |
* transition to the new props/state/context will not require a component |
|
1889 |
* update. |
|
1890 |
* |
|
1891 |
* shouldComponentUpdate: function(nextProps, nextState, nextContext) { |
|
1892 |
* return !equal(nextProps, this.props) || |
|
1893 |
* !equal(nextState, this.state) || |
|
1894 |
* !equal(nextContext, this.context); |
|
1895 |
* } |
|
1896 |
* |
|
1897 |
* @param {object} nextProps |
|
1898 |
* @param {?object} nextState |
|
1899 |
* @param {?object} nextContext |
|
1900 |
* @return {boolean} True if the component should update. |
|
1901 |
* @optional |
|
1902 |
*/ |
|
1903 |
shouldComponentUpdate: 'DEFINE_ONCE', |
|
1904 |
|
|
1905 |
/** |
|
1906 |
* Invoked when the component is about to update due to a transition from |
|
1907 |
* `this.props`, `this.state` and `this.context` to `nextProps`, `nextState` |
|
1908 |
* and `nextContext`. |
|
1909 |
* |
|
1910 |
* Use this as an opportunity to perform preparation before an update occurs. |
|
1911 |
* |
|
1912 |
* NOTE: You **cannot** use `this.setState()` in this method. |
|
1913 |
* |
|
1914 |
* @param {object} nextProps |
|
1915 |
* @param {?object} nextState |
|
1916 |
* @param {?object} nextContext |
|
1917 |
* @param {ReactReconcileTransaction} transaction |
|
1918 |
* @optional |
|
1919 |
*/ |
|
1920 |
componentWillUpdate: 'DEFINE_MANY', |
|
1921 |
|
|
1922 |
/** |
|
1923 |
* Invoked when the component's DOM representation has been updated. |
|
1924 |
* |
|
1925 |
* Use this as an opportunity to operate on the DOM when the component has |
|
1926 |
* been updated. |
|
1927 |
* |
|
1928 |
* @param {object} prevProps |
|
1929 |
* @param {?object} prevState |
|
1930 |
* @param {?object} prevContext |
|
1931 |
* @param {DOMElement} rootNode DOM element representing the component. |
|
1932 |
* @optional |
|
1933 |
*/ |
|
1934 |
componentDidUpdate: 'DEFINE_MANY', |
|
1935 |
|
|
1936 |
/** |
|
1937 |
* Invoked when the component is about to be removed from its parent and have |
|
1938 |
* its DOM representation destroyed. |
|
1939 |
* |
|
1940 |
* Use this as an opportunity to deallocate any external resources. |
|
1941 |
* |
|
1942 |
* NOTE: There is no `componentDidUnmount` since your component will have been |
|
1943 |
* destroyed by that point. |
|
1944 |
* |
|
1945 |
* @optional |
|
1946 |
*/ |
|
1947 |
componentWillUnmount: 'DEFINE_MANY', |
|
1948 |
|
|
1949 |
// ==== Advanced methods ==== |
|
1950 |
|
|
1951 |
/** |
|
1952 |
* Updates the component's currently mounted DOM representation. |
|
1953 |
* |
|
1954 |
* By default, this implements React's rendering and reconciliation algorithm. |
|
1955 |
* Sophisticated clients may wish to override this. |
|
1956 |
* |
|
1957 |
* @param {ReactReconcileTransaction} transaction |
|
1958 |
* @internal |
|
1959 |
* @overridable |
|
1960 |
*/ |
|
1961 |
updateComponent: 'OVERRIDE_BASE' |
|
1962 |
}; |
|
1963 |
|
|
1964 |
/** |
|
1965 |
* Mapping from class specification keys to special processing functions. |
|
1966 |
* |
|
1967 |
* Although these are declared like instance properties in the specification |
|
1968 |
* when defining classes using `React.createClass`, they are actually static |
|
1969 |
* and are accessible on the constructor instead of the prototype. Despite |
|
1970 |
* being static, they must be defined outside of the "statics" key under |
|
1971 |
* which all other static methods are defined. |
|
1972 |
*/ |
|
1973 |
var RESERVED_SPEC_KEYS = { |
a50b2e
|
1974 |
displayName: function(Constructor, displayName) { |
be31e2
|
1975 |
Constructor.displayName = displayName; |
JB |
1976 |
}, |
a50b2e
|
1977 |
mixins: function(Constructor, mixins) { |
be31e2
|
1978 |
if (mixins) { |
JB |
1979 |
for (var i = 0; i < mixins.length; i++) { |
|
1980 |
mixSpecIntoComponent(Constructor, mixins[i]); |
|
1981 |
} |
|
1982 |
} |
|
1983 |
}, |
a50b2e
|
1984 |
childContextTypes: function(Constructor, childContextTypes) { |
be31e2
|
1985 |
if (process.env.NODE_ENV !== 'production') { |
JB |
1986 |
validateTypeDef(Constructor, childContextTypes, 'childContext'); |
|
1987 |
} |
a50b2e
|
1988 |
Constructor.childContextTypes = _assign( |
GL |
1989 |
{}, |
|
1990 |
Constructor.childContextTypes, |
|
1991 |
childContextTypes |
|
1992 |
); |
be31e2
|
1993 |
}, |
a50b2e
|
1994 |
contextTypes: function(Constructor, contextTypes) { |
be31e2
|
1995 |
if (process.env.NODE_ENV !== 'production') { |
JB |
1996 |
validateTypeDef(Constructor, contextTypes, 'context'); |
|
1997 |
} |
a50b2e
|
1998 |
Constructor.contextTypes = _assign( |
GL |
1999 |
{}, |
|
2000 |
Constructor.contextTypes, |
|
2001 |
contextTypes |
|
2002 |
); |
be31e2
|
2003 |
}, |
JB |
2004 |
/** |
|
2005 |
* Special case getDefaultProps which should move into statics but requires |
|
2006 |
* automatic merging. |
|
2007 |
*/ |
a50b2e
|
2008 |
getDefaultProps: function(Constructor, getDefaultProps) { |
be31e2
|
2009 |
if (Constructor.getDefaultProps) { |
a50b2e
|
2010 |
Constructor.getDefaultProps = createMergedResultFunction( |
GL |
2011 |
Constructor.getDefaultProps, |
|
2012 |
getDefaultProps |
|
2013 |
); |
be31e2
|
2014 |
} else { |
JB |
2015 |
Constructor.getDefaultProps = getDefaultProps; |
|
2016 |
} |
|
2017 |
}, |
a50b2e
|
2018 |
propTypes: function(Constructor, propTypes) { |
be31e2
|
2019 |
if (process.env.NODE_ENV !== 'production') { |
JB |
2020 |
validateTypeDef(Constructor, propTypes, 'prop'); |
|
2021 |
} |
|
2022 |
Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes); |
|
2023 |
}, |
a50b2e
|
2024 |
statics: function(Constructor, statics) { |
be31e2
|
2025 |
mixStaticSpecIntoComponent(Constructor, statics); |
JB |
2026 |
}, |
a50b2e
|
2027 |
autobind: function() {} |
GL |
2028 |
}; |
be31e2
|
2029 |
|
JB |
2030 |
function validateTypeDef(Constructor, typeDef, location) { |
|
2031 |
for (var propName in typeDef) { |
|
2032 |
if (typeDef.hasOwnProperty(propName)) { |
|
2033 |
// use a warning instead of an _invariant so components |
|
2034 |
// don't show up in prod but only in __DEV__ |
a50b2e
|
2035 |
if (process.env.NODE_ENV !== 'production') { |
GL |
2036 |
warning( |
|
2037 |
typeof typeDef[propName] === 'function', |
|
2038 |
'%s: %s type `%s` is invalid; it must be a function, usually from ' + |
|
2039 |
'React.PropTypes.', |
|
2040 |
Constructor.displayName || 'ReactClass', |
|
2041 |
ReactPropTypeLocationNames[location], |
|
2042 |
propName |
|
2043 |
); |
|
2044 |
} |
be31e2
|
2045 |
} |
JB |
2046 |
} |
|
2047 |
} |
|
2048 |
|
|
2049 |
function validateMethodOverride(isAlreadyDefined, name) { |
a50b2e
|
2050 |
var specPolicy = ReactClassInterface.hasOwnProperty(name) |
GL |
2051 |
? ReactClassInterface[name] |
|
2052 |
: null; |
be31e2
|
2053 |
|
JB |
2054 |
// Disallow overriding of base class methods unless explicitly allowed. |
|
2055 |
if (ReactClassMixin.hasOwnProperty(name)) { |
a50b2e
|
2056 |
_invariant( |
GL |
2057 |
specPolicy === 'OVERRIDE_BASE', |
|
2058 |
'ReactClassInterface: You are attempting to override ' + |
|
2059 |
'`%s` from your class specification. Ensure that your method names ' + |
|
2060 |
'do not overlap with React methods.', |
|
2061 |
name |
|
2062 |
); |
be31e2
|
2063 |
} |
JB |
2064 |
|
|
2065 |
// Disallow defining methods more than once unless explicitly allowed. |
|
2066 |
if (isAlreadyDefined) { |
a50b2e
|
2067 |
_invariant( |
GL |
2068 |
specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED', |
|
2069 |
'ReactClassInterface: You are attempting to define ' + |
|
2070 |
'`%s` on your component more than once. This conflict may be due ' + |
|
2071 |
'to a mixin.', |
|
2072 |
name |
|
2073 |
); |
be31e2
|
2074 |
} |
JB |
2075 |
} |
|
2076 |
|
|
2077 |
/** |
|
2078 |
* Mixin helper which handles policy validation and reserved |
|
2079 |
* specification keys when building React classes. |
|
2080 |
*/ |
|
2081 |
function mixSpecIntoComponent(Constructor, spec) { |
|
2082 |
if (!spec) { |
|
2083 |
if (process.env.NODE_ENV !== 'production') { |
|
2084 |
var typeofSpec = typeof spec; |
|
2085 |
var isMixinValid = typeofSpec === 'object' && spec !== null; |
|
2086 |
|
a50b2e
|
2087 |
if (process.env.NODE_ENV !== 'production') { |
GL |
2088 |
warning( |
|
2089 |
isMixinValid, |
|
2090 |
"%s: You're attempting to include a mixin that is either null " + |
|
2091 |
'or not an object. Check the mixins included by the component, ' + |
|
2092 |
'as well as any mixins they include themselves. ' + |
|
2093 |
'Expected object but got %s.', |
|
2094 |
Constructor.displayName || 'ReactClass', |
|
2095 |
spec === null ? null : typeofSpec |
|
2096 |
); |
|
2097 |
} |
be31e2
|
2098 |
} |
JB |
2099 |
|
|
2100 |
return; |
|
2101 |
} |
|
2102 |
|
a50b2e
|
2103 |
_invariant( |
GL |
2104 |
typeof spec !== 'function', |
|
2105 |
"ReactClass: You're attempting to " + |
|
2106 |
'use a component class or function as a mixin. Instead, just use a ' + |
|
2107 |
'regular object.' |
|
2108 |
); |
|
2109 |
_invariant( |
|
2110 |
!isValidElement(spec), |
|
2111 |
"ReactClass: You're attempting to " + |
|
2112 |
'use a component as a mixin. Instead, just use a regular object.' |
|
2113 |
); |
be31e2
|
2114 |
|
JB |
2115 |
var proto = Constructor.prototype; |
|
2116 |
var autoBindPairs = proto.__reactAutoBindPairs; |
|
2117 |
|
|
2118 |
// By handling mixins before any other properties, we ensure the same |
|
2119 |
// chaining order is applied to methods with DEFINE_MANY policy, whether |
|
2120 |
// mixins are listed before or after these methods in the spec. |
|
2121 |
if (spec.hasOwnProperty(MIXINS_KEY)) { |
|
2122 |
RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins); |
|
2123 |
} |
|
2124 |
|
|
2125 |
for (var name in spec) { |
|
2126 |
if (!spec.hasOwnProperty(name)) { |
|
2127 |
continue; |
|
2128 |
} |
|
2129 |
|
|
2130 |
if (name === MIXINS_KEY) { |
|
2131 |
// We have already handled mixins in a special case above. |
|
2132 |
continue; |
|
2133 |
} |
|
2134 |
|
|
2135 |
var property = spec[name]; |
|
2136 |
var isAlreadyDefined = proto.hasOwnProperty(name); |
|
2137 |
validateMethodOverride(isAlreadyDefined, name); |
|
2138 |
|
|
2139 |
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { |
|
2140 |
RESERVED_SPEC_KEYS[name](Constructor, property); |
|
2141 |
} else { |
|
2142 |
// Setup methods on prototype: |
|
2143 |
// The following member methods should not be automatically bound: |
|
2144 |
// 1. Expected ReactClass methods (in the "interface"). |
|
2145 |
// 2. Overridden methods (that were mixed in). |
|
2146 |
var isReactClassMethod = ReactClassInterface.hasOwnProperty(name); |
|
2147 |
var isFunction = typeof property === 'function'; |
a50b2e
|
2148 |
var shouldAutoBind = |
GL |
2149 |
isFunction && |
|
2150 |
!isReactClassMethod && |
|
2151 |
!isAlreadyDefined && |
|
2152 |
spec.autobind !== false; |
be31e2
|
2153 |
|
JB |
2154 |
if (shouldAutoBind) { |
|
2155 |
autoBindPairs.push(name, property); |
|
2156 |
proto[name] = property; |
|
2157 |
} else { |
|
2158 |
if (isAlreadyDefined) { |
|
2159 |
var specPolicy = ReactClassInterface[name]; |
|
2160 |
|
|
2161 |
// These cases should already be caught by validateMethodOverride. |
a50b2e
|
2162 |
_invariant( |
GL |
2163 |
isReactClassMethod && |
|
2164 |
(specPolicy === 'DEFINE_MANY_MERGED' || |
|
2165 |
specPolicy === 'DEFINE_MANY'), |
|
2166 |
'ReactClass: Unexpected spec policy %s for key %s ' + |
|
2167 |
'when mixing in component specs.', |
|
2168 |
specPolicy, |
|
2169 |
name |
|
2170 |
); |
be31e2
|
2171 |
|
JB |
2172 |
// For methods which are defined more than once, call the existing |
|
2173 |
// methods before calling the new property, merging if appropriate. |
|
2174 |
if (specPolicy === 'DEFINE_MANY_MERGED') { |
|
2175 |
proto[name] = createMergedResultFunction(proto[name], property); |
|
2176 |
} else if (specPolicy === 'DEFINE_MANY') { |
|
2177 |
proto[name] = createChainedFunction(proto[name], property); |
|
2178 |
} |
|
2179 |
} else { |
|
2180 |
proto[name] = property; |
|
2181 |
if (process.env.NODE_ENV !== 'production') { |
|
2182 |
// Add verbose displayName to the function, which helps when looking |
|
2183 |
// at profiling tools. |
|
2184 |
if (typeof property === 'function' && spec.displayName) { |
|
2185 |
proto[name].displayName = spec.displayName + '_' + name; |
|
2186 |
} |
|
2187 |
} |
|
2188 |
} |
|
2189 |
} |
|
2190 |
} |
|
2191 |
} |
|
2192 |
} |
|
2193 |
|
|
2194 |
function mixStaticSpecIntoComponent(Constructor, statics) { |
|
2195 |
if (!statics) { |
|
2196 |
return; |
|
2197 |
} |
|
2198 |
for (var name in statics) { |
|
2199 |
var property = statics[name]; |
|
2200 |
if (!statics.hasOwnProperty(name)) { |
|
2201 |
continue; |
|
2202 |
} |
|
2203 |
|
|
2204 |
var isReserved = name in RESERVED_SPEC_KEYS; |
a50b2e
|
2205 |
_invariant( |
GL |
2206 |
!isReserved, |
|
2207 |
'ReactClass: You are attempting to define a reserved ' + |
|
2208 |
'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + |
|
2209 |
'as an instance property instead; it will still be accessible on the ' + |
|
2210 |
'constructor.', |
|
2211 |
name |
|
2212 |
); |
be31e2
|
2213 |
|
JB |
2214 |
var isInherited = name in Constructor; |
a50b2e
|
2215 |
_invariant( |
GL |
2216 |
!isInherited, |
|
2217 |
'ReactClass: You are attempting to define ' + |
|
2218 |
'`%s` on your component more than once. This conflict may be ' + |
|
2219 |
'due to a mixin.', |
|
2220 |
name |
|
2221 |
); |
be31e2
|
2222 |
Constructor[name] = property; |
JB |
2223 |
} |
|
2224 |
} |
|
2225 |
|
|
2226 |
/** |
|
2227 |
* Merge two objects, but throw if both contain the same key. |
|
2228 |
* |
|
2229 |
* @param {object} one The first object, which is mutated. |
|
2230 |
* @param {object} two The second object |
|
2231 |
* @return {object} one after it has been mutated to contain everything in two. |
|
2232 |
*/ |
|
2233 |
function mergeIntoWithNoDuplicateKeys(one, two) { |
a50b2e
|
2234 |
_invariant( |
GL |
2235 |
one && two && typeof one === 'object' && typeof two === 'object', |
|
2236 |
'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.' |
|
2237 |
); |
be31e2
|
2238 |
|
JB |
2239 |
for (var key in two) { |
|
2240 |
if (two.hasOwnProperty(key)) { |
a50b2e
|
2241 |
_invariant( |
GL |
2242 |
one[key] === undefined, |
|
2243 |
'mergeIntoWithNoDuplicateKeys(): ' + |
|
2244 |
'Tried to merge two objects with the same key: `%s`. This conflict ' + |
|
2245 |
'may be due to a mixin; in particular, this may be caused by two ' + |
|
2246 |
'getInitialState() or getDefaultProps() methods returning objects ' + |
|
2247 |
'with clashing keys.', |
|
2248 |
key |
|
2249 |
); |
be31e2
|
2250 |
one[key] = two[key]; |
JB |
2251 |
} |
|
2252 |
} |
|
2253 |
return one; |
|
2254 |
} |
|
2255 |
|
|
2256 |
/** |
|
2257 |
* Creates a function that invokes two functions and merges their return values. |
|
2258 |
* |
|
2259 |
* @param {function} one Function to invoke first. |
|
2260 |
* @param {function} two Function to invoke second. |
|
2261 |
* @return {function} Function that invokes the two argument functions. |
|
2262 |
* @private |
|
2263 |
*/ |
|
2264 |
function createMergedResultFunction(one, two) { |
|
2265 |
return function mergedResult() { |
|
2266 |
var a = one.apply(this, arguments); |
|
2267 |
var b = two.apply(this, arguments); |
|
2268 |
if (a == null) { |
|
2269 |
return b; |
|
2270 |
} else if (b == null) { |
|
2271 |
return a; |
|
2272 |
} |
|
2273 |
var c = {}; |
|
2274 |
mergeIntoWithNoDuplicateKeys(c, a); |
|
2275 |
mergeIntoWithNoDuplicateKeys(c, b); |
|
2276 |
return c; |
|
2277 |
}; |
|
2278 |
} |
|
2279 |
|
|
2280 |
/** |
|
2281 |
* Creates a function that invokes two functions and ignores their return vales. |
|
2282 |
* |
|
2283 |
* @param {function} one Function to invoke first. |
|
2284 |
* @param {function} two Function to invoke second. |
|
2285 |
* @return {function} Function that invokes the two argument functions. |
|
2286 |
* @private |
|
2287 |
*/ |
|
2288 |
function createChainedFunction(one, two) { |
|
2289 |
return function chainedFunction() { |
|
2290 |
one.apply(this, arguments); |
|
2291 |
two.apply(this, arguments); |
|
2292 |
}; |
|
2293 |
} |
|
2294 |
|
|
2295 |
/** |
|
2296 |
* Binds a method to the component. |
|
2297 |
* |
|
2298 |
* @param {object} component Component whose method is going to be bound. |
|
2299 |
* @param {function} method Method to be bound. |
|
2300 |
* @return {function} The bound method. |
|
2301 |
*/ |
|
2302 |
function bindAutoBindMethod(component, method) { |
|
2303 |
var boundMethod = method.bind(component); |
|
2304 |
if (process.env.NODE_ENV !== 'production') { |
|
2305 |
boundMethod.__reactBoundContext = component; |
|
2306 |
boundMethod.__reactBoundMethod = method; |
|
2307 |
boundMethod.__reactBoundArguments = null; |
|
2308 |
var componentName = component.constructor.displayName; |
|
2309 |
var _bind = boundMethod.bind; |
a50b2e
|
2310 |
boundMethod.bind = function(newThis) { |
GL |
2311 |
for ( |
|
2312 |
var _len = arguments.length, |
|
2313 |
args = Array(_len > 1 ? _len - 1 : 0), |
|
2314 |
_key = 1; |
|
2315 |
_key < _len; |
|
2316 |
_key++ |
|
2317 |
) { |
be31e2
|
2318 |
args[_key - 1] = arguments[_key]; |
JB |
2319 |
} |
|
2320 |
|
|
2321 |
// User is trying to bind() an autobound method; we effectively will |
|
2322 |
// ignore the value of "this" that the user is trying to use, so |
|
2323 |
// let's warn. |
|
2324 |
if (newThis !== component && newThis !== null) { |
a50b2e
|
2325 |
if (process.env.NODE_ENV !== 'production') { |
GL |
2326 |
warning( |
|
2327 |
false, |
|
2328 |
'bind(): React component methods may only be bound to the ' + |
|
2329 |
'component instance. See %s', |
|
2330 |
componentName |
|
2331 |
); |
|
2332 |
} |
be31e2
|
2333 |
} else if (!args.length) { |
a50b2e
|
2334 |
if (process.env.NODE_ENV !== 'production') { |
GL |
2335 |
warning( |
|
2336 |
false, |
|
2337 |
'bind(): You are binding a component method to the component. ' + |
|
2338 |
'React does this for you automatically in a high-performance ' + |
|
2339 |
'way, so you can safely remove this call. See %s', |
|
2340 |
componentName |
|
2341 |
); |
|
2342 |
} |
be31e2
|
2343 |
return boundMethod; |
JB |
2344 |
} |
|
2345 |
var reboundMethod = _bind.apply(boundMethod, arguments); |
|
2346 |
reboundMethod.__reactBoundContext = component; |
|
2347 |
reboundMethod.__reactBoundMethod = method; |
|
2348 |
reboundMethod.__reactBoundArguments = args; |
|
2349 |
return reboundMethod; |
|
2350 |
}; |
|
2351 |
} |
|
2352 |
return boundMethod; |
|
2353 |
} |
|
2354 |
|
|
2355 |
/** |
|
2356 |
* Binds all auto-bound methods in a component. |
|
2357 |
* |
|
2358 |
* @param {object} component Component whose method is going to be bound. |
|
2359 |
*/ |
|
2360 |
function bindAutoBindMethods(component) { |
|
2361 |
var pairs = component.__reactAutoBindPairs; |
|
2362 |
for (var i = 0; i < pairs.length; i += 2) { |
|
2363 |
var autoBindKey = pairs[i]; |
|
2364 |
var method = pairs[i + 1]; |
|
2365 |
component[autoBindKey] = bindAutoBindMethod(component, method); |
|
2366 |
} |
|
2367 |
} |
|
2368 |
|
a50b2e
|
2369 |
var IsMountedPreMixin = { |
GL |
2370 |
componentDidMount: function() { |
be31e2
|
2371 |
this.__isMounted = true; |
a50b2e
|
2372 |
} |
GL |
2373 |
}; |
|
2374 |
|
|
2375 |
var IsMountedPostMixin = { |
|
2376 |
componentWillUnmount: function() { |
be31e2
|
2377 |
this.__isMounted = false; |
JB |
2378 |
} |
|
2379 |
}; |
|
2380 |
|
|
2381 |
/** |
|
2382 |
* Add more to the ReactClass base class. These are all legacy features and |
|
2383 |
* therefore not already part of the modern ReactComponent. |
|
2384 |
*/ |
|
2385 |
var ReactClassMixin = { |
|
2386 |
/** |
|
2387 |
* TODO: This will be deprecated because state should always keep a consistent |
|
2388 |
* type signature and the only use case for this, is to avoid that. |
|
2389 |
*/ |
a50b2e
|
2390 |
replaceState: function(newState, callback) { |
be31e2
|
2391 |
this.updater.enqueueReplaceState(this, newState, callback); |
JB |
2392 |
}, |
|
2393 |
|
|
2394 |
/** |
|
2395 |
* Checks whether or not this composite component is mounted. |
|
2396 |
* @return {boolean} True if mounted, false otherwise. |
|
2397 |
* @protected |
|
2398 |
* @final |
|
2399 |
*/ |
a50b2e
|
2400 |
isMounted: function() { |
be31e2
|
2401 |
if (process.env.NODE_ENV !== 'production') { |
a50b2e
|
2402 |
warning( |
GL |
2403 |
this.__didWarnIsMounted, |
|
2404 |
'%s: isMounted is deprecated. Instead, make sure to clean up ' + |
|
2405 |
'subscriptions and pending requests in componentWillUnmount to ' + |
|
2406 |
'prevent memory leaks.', |
|
2407 |
(this.constructor && this.constructor.displayName) || |
|
2408 |
this.name || |
|
2409 |
'Component' |
|
2410 |
); |
be31e2
|
2411 |
this.__didWarnIsMounted = true; |
JB |
2412 |
} |
|
2413 |
return !!this.__isMounted; |
|
2414 |
} |
|
2415 |
}; |
|
2416 |
|
a50b2e
|
2417 |
var ReactClassComponent = function() {}; |
GL |
2418 |
_assign( |
|
2419 |
ReactClassComponent.prototype, |
|
2420 |
ReactComponent.prototype, |
|
2421 |
ReactClassMixin |
|
2422 |
); |
be31e2
|
2423 |
|
JB |
2424 |
/** |
|
2425 |
* Creates a composite component class given a class specification. |
|
2426 |
* See https://facebook.github.io/react/docs/top-level-api.html#react.createclass |
|
2427 |
* |
|
2428 |
* @param {object} spec Class specification (which must define `render`). |
|
2429 |
* @return {function} Component constructor function. |
|
2430 |
* @public |
|
2431 |
*/ |
|
2432 |
function createClass(spec) { |
|
2433 |
// To keep our warnings more understandable, we'll use a little hack here to |
|
2434 |
// ensure that Constructor.name !== 'Constructor'. This makes sure we don't |
|
2435 |
// unnecessarily identify a class without displayName as 'Constructor'. |
a50b2e
|
2436 |
var Constructor = identity(function(props, context, updater) { |
be31e2
|
2437 |
// This constructor gets overridden by mocks. The argument is used |
JB |
2438 |
// by mocks to assert on what gets mounted. |
|
2439 |
|
|
2440 |
if (process.env.NODE_ENV !== 'production') { |
a50b2e
|
2441 |
warning( |
GL |
2442 |
this instanceof Constructor, |
|
2443 |
'Something is calling a React component directly. Use a factory or ' + |
|
2444 |
'JSX instead. See: https://fb.me/react-legacyfactory' |
|
2445 |
); |
be31e2
|
2446 |
} |
JB |
2447 |
|
|
2448 |
// Wire up auto-binding |
|
2449 |
if (this.__reactAutoBindPairs.length) { |
|
2450 |
bindAutoBindMethods(this); |
|
2451 |
} |
|
2452 |
|
|
2453 |
this.props = props; |
|
2454 |
this.context = context; |
|
2455 |
this.refs = emptyObject; |
|
2456 |
this.updater = updater || ReactNoopUpdateQueue; |
|
2457 |
|
|
2458 |
this.state = null; |
|
2459 |
|
|
2460 |
// ReactClasses doesn't have constructors. Instead, they use the |
|
2461 |
// getInitialState and componentWillMount methods for initialization. |
|
2462 |
|
|
2463 |
var initialState = this.getInitialState ? this.getInitialState() : null; |
|
2464 |
if (process.env.NODE_ENV !== 'production') { |
|
2465 |
// We allow auto-mocks to proceed as if they're returning null. |
a50b2e
|
2466 |
if ( |
GL |
2467 |
initialState === undefined && |
|
2468 |
this.getInitialState._isMockFunction |
|
2469 |
) { |
be31e2
|
2470 |
// This is probably bad practice. Consider warning here and |
JB |
2471 |
// deprecating this convenience. |
|
2472 |
initialState = null; |
|
2473 |
} |
|
2474 |
} |
a50b2e
|
2475 |
_invariant( |
GL |
2476 |
typeof initialState === 'object' && !Array.isArray(initialState), |
|
2477 |
'%s.getInitialState(): must return an object or null', |
|
2478 |
Constructor.displayName || 'ReactCompositeComponent' |
|
2479 |
); |
be31e2
|
2480 |
|
JB |
2481 |
this.state = initialState; |
|
2482 |
}); |
|
2483 |
Constructor.prototype = new ReactClassComponent(); |
|
2484 |
Constructor.prototype.constructor = Constructor; |
|
2485 |
Constructor.prototype.__reactAutoBindPairs = []; |
|
2486 |
|
|
2487 |
injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor)); |
|
2488 |
|
a50b2e
|
2489 |
mixSpecIntoComponent(Constructor, IsMountedPreMixin); |
be31e2
|
2490 |
mixSpecIntoComponent(Constructor, spec); |
a50b2e
|
2491 |
mixSpecIntoComponent(Constructor, IsMountedPostMixin); |
be31e2
|
2492 |
|
JB |
2493 |
// Initialize the defaultProps property after all mixins have been merged. |
|
2494 |
if (Constructor.getDefaultProps) { |
|
2495 |
Constructor.defaultProps = Constructor.getDefaultProps(); |
|
2496 |
} |
|
2497 |
|
|
2498 |
if (process.env.NODE_ENV !== 'production') { |
|
2499 |
// This is a tag to indicate that the use of these method names is ok, |
|
2500 |
// since it's used with createClass. If it's not, then it's likely a |
|
2501 |
// mistake so we'll warn you to use the static property, property |
|
2502 |
// initializer or constructor respectively. |
|
2503 |
if (Constructor.getDefaultProps) { |
|
2504 |
Constructor.getDefaultProps.isReactClassApproved = {}; |
|
2505 |
} |
|
2506 |
if (Constructor.prototype.getInitialState) { |
|
2507 |
Constructor.prototype.getInitialState.isReactClassApproved = {}; |
|
2508 |
} |
|
2509 |
} |
|
2510 |
|
a50b2e
|
2511 |
_invariant( |
GL |
2512 |
Constructor.prototype.render, |
|
2513 |
'createClass(...): Class specification must implement a `render` method.' |
|
2514 |
); |
be31e2
|
2515 |
|
JB |
2516 |
if (process.env.NODE_ENV !== 'production') { |
a50b2e
|
2517 |
warning( |
GL |
2518 |
!Constructor.prototype.componentShouldUpdate, |
|
2519 |
'%s has a method called ' + |
|
2520 |
'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + |
|
2521 |
'The name is phrased as a question because the function is ' + |
|
2522 |
'expected to return a value.', |
|
2523 |
spec.displayName || 'A component' |
|
2524 |
); |
|
2525 |
warning( |
|
2526 |
!Constructor.prototype.componentWillRecieveProps, |
|
2527 |
'%s has a method called ' + |
|
2528 |
'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', |
|
2529 |
spec.displayName || 'A component' |
|
2530 |
); |
be31e2
|
2531 |
} |
JB |
2532 |
|
|
2533 |
// Reduce time spent doing lookups by setting these on the prototype. |
|
2534 |
for (var methodName in ReactClassInterface) { |
|
2535 |
if (!Constructor.prototype[methodName]) { |
|
2536 |
Constructor.prototype[methodName] = null; |
|
2537 |
} |
|
2538 |
} |
|
2539 |
|
|
2540 |
return Constructor; |
|
2541 |
} |
|
2542 |
|
|
2543 |
return createClass; |
|
2544 |
} |
|
2545 |
|
|
2546 |
module.exports = factory; |
|
2547 |
|
|
2548 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) |
|
2549 |
|
7392ed
|
2550 |
/***/ }), |
be31e2
|
2551 |
/* 14 */ |
7392ed
|
2552 |
/***/ (function(module, exports) { |
be31e2
|
2553 |
|
JB |
2554 |
/* |
|
2555 |
object-assign |
|
2556 |
(c) Sindre Sorhus |
|
2557 |
@license MIT |
|
2558 |
*/ |
|
2559 |
|
|
2560 |
'use strict'; |
|
2561 |
/* eslint-disable no-unused-vars */ |
|
2562 |
var getOwnPropertySymbols = Object.getOwnPropertySymbols; |
|
2563 |
var hasOwnProperty = Object.prototype.hasOwnProperty; |
|
2564 |
var propIsEnumerable = Object.prototype.propertyIsEnumerable; |
|
2565 |
|
|
2566 |
function toObject(val) { |
|
2567 |
if (val === null || val === undefined) { |
|
2568 |
throw new TypeError('Object.assign cannot be called with null or undefined'); |
|
2569 |
} |
|
2570 |
|
|
2571 |
return Object(val); |
|
2572 |
} |
|
2573 |
|
|
2574 |
function shouldUseNative() { |
|
2575 |
try { |
|
2576 |
if (!Object.assign) { |
|
2577 |
return false; |
|
2578 |
} |
|
2579 |
|
|
2580 |
// Detect buggy property enumeration order in older V8 versions. |
|
2581 |
|
|
2582 |
// https://bugs.chromium.org/p/v8/issues/detail?id=4118 |
|
2583 |
var test1 = new String('abc'); // eslint-disable-line no-new-wrappers |
|
2584 |
test1[5] = 'de'; |
|
2585 |
if (Object.getOwnPropertyNames(test1)[0] === '5') { |
|
2586 |
return false; |
|
2587 |
} |
|
2588 |
|
|
2589 |
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 |
|
2590 |
var test2 = {}; |
|
2591 |
for (var i = 0; i < 10; i++) { |
|
2592 |
test2['_' + String.fromCharCode(i)] = i; |
|
2593 |
} |
|
2594 |
var order2 = Object.getOwnPropertyNames(test2).map(function (n) { |
|
2595 |
return test2[n]; |
|
2596 |
}); |
|
2597 |
if (order2.join('') !== '0123456789') { |
|
2598 |
return false; |
|
2599 |
} |
|
2600 |
|
|
2601 |
// https://bugs.chromium.org/p/v8/issues/detail?id=3056 |
|
2602 |
var test3 = {}; |
|
2603 |
'abcdefghijklmnopqrst'.split('').forEach(function (letter) { |
|
2604 |
test3[letter] = letter; |
|
2605 |
}); |
|
2606 |
if (Object.keys(Object.assign({}, test3)).join('') !== |
|
2607 |
'abcdefghijklmnopqrst') { |
|
2608 |
return false; |
|
2609 |
} |
|
2610 |
|
|
2611 |
return true; |
|
2612 |
} catch (err) { |
|
2613 |
// We don't expect any of the above to throw, but better to be safe. |
|
2614 |
return false; |
|
2615 |
} |
|
2616 |
} |
|
2617 |
|
|
2618 |
module.exports = shouldUseNative() ? Object.assign : function (target, source) { |
|
2619 |
var from; |
|
2620 |
var to = toObject(target); |
|
2621 |
var symbols; |
|
2622 |
|
|
2623 |
for (var s = 1; s < arguments.length; s++) { |
|
2624 |
from = Object(arguments[s]); |
|
2625 |
|
|
2626 |
for (var key in from) { |
|
2627 |
if (hasOwnProperty.call(from, key)) { |
|
2628 |
to[key] = from[key]; |
|
2629 |
} |
|
2630 |
} |
|
2631 |
|
|
2632 |
if (getOwnPropertySymbols) { |
|
2633 |
symbols = getOwnPropertySymbols(from); |
|
2634 |
for (var i = 0; i < symbols.length; i++) { |
|
2635 |
if (propIsEnumerable.call(from, symbols[i])) { |
|
2636 |
to[symbols[i]] = from[symbols[i]]; |
|
2637 |
} |
|
2638 |
} |
|
2639 |
} |
|
2640 |
} |
|
2641 |
|
|
2642 |
return to; |
|
2643 |
}; |
|
2644 |
|
|
2645 |
|
7392ed
|
2646 |
/***/ }), |
be31e2
|
2647 |
/* 15 */ |
7392ed
|
2648 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
2649 |
|
JB |
2650 |
/* WEBPACK VAR INJECTION */(function(process) {/** |
|
2651 |
* Copyright (c) 2013-present, Facebook, Inc. |
|
2652 |
* All rights reserved. |
|
2653 |
* |
|
2654 |
* This source code is licensed under the BSD-style license found in the |
|
2655 |
* LICENSE file in the root directory of this source tree. An additional grant |
|
2656 |
* of patent rights can be found in the PATENTS file in the same directory. |
|
2657 |
* |
|
2658 |
*/ |
|
2659 |
|
|
2660 |
'use strict'; |
|
2661 |
|
|
2662 |
var emptyObject = {}; |
|
2663 |
|
|
2664 |
if (process.env.NODE_ENV !== 'production') { |
|
2665 |
Object.freeze(emptyObject); |
|
2666 |
} |
|
2667 |
|
|
2668 |
module.exports = emptyObject; |
|
2669 |
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(3))) |
|
2670 |
|
7392ed
|
2671 |
/***/ }), |
be31e2
|
2672 |
/* 16 */ |
7392ed
|
2673 |
/***/ (function(module, exports) { |
be31e2
|
2674 |
|
JB |
2675 |
module.exports = __WEBPACK_EXTERNAL_MODULE_16__; |
|
2676 |
|
7392ed
|
2677 |
/***/ }), |
be31e2
|
2678 |
/* 17 */ |
7392ed
|
2679 |
/***/ (function(module, exports, __webpack_require__) { |
be31e2
|
2680 |
|
833531
|
2681 |
'use strict'; |
SE |
2682 |
|
be31e2
|
2683 |
var React = __webpack_require__(12), |
8f6f33
|
2684 |
createClass = __webpack_require__(11), |
LA |
2685 |
DaysView = __webpack_require__(18), |
|
2686 |
MonthsView = __webpack_require__(21), |
|
2687 |
YearsView = __webpack_require__(22), |
|
2688 |
TimeView = __webpack_require__(23) |
|
2689 |
; |
7750ac
|
2690 |
|
be31e2
|
2691 |
var CalendarContainer = createClass({ |
7750ac
|
2692 |
viewComponents: { |
JM |
2693 |
days: DaysView, |
|
2694 |
months: MonthsView, |
|
2695 |
years: YearsView, |
|
2696 |
time: TimeView |
|
2697 |
}, |
|
2698 |
|
8f6f33
|
2699 |
render: function() { |
LA |
2700 |
return React.createElement( this.viewComponents[ this.props.view ], this.props.viewProps ); |
|
2701 |
} |
11612b
|
2702 |
}); |
7750ac
|
2703 |
|
JM |
2704 |
module.exports = CalendarContainer; |
|
2705 |
|
|
2706 |
|
7392ed
|
2707 |
/***/ }), |
be31e2
|
2708 |
/* 18 */ |
7392ed
|
2709 |
/***/ (function(module, exports, __webpack_require__) { |
d76f7b
|
2710 |
|
be9654
|
2711 |
'use strict'; |
SE |
2712 |
|
be31e2
|
2713 |
var React = __webpack_require__(12), |
8f6f33
|
2714 |
createClass = __webpack_require__(11), |
be31e2
|
2715 |
moment = __webpack_require__(16), |
833531
|
2716 |
onClickOutside = __webpack_require__(19) |
8f6f33
|
2717 |
; |
be9654
|
2718 |
|
be31e2
|
2719 |
var DateTimePickerDays = onClickOutside( createClass({ |
be9654
|
2720 |
render: function() { |
SE |
2721 |
var footer = this.renderFooter(), |
|
2722 |
date = this.props.viewDate, |
|
2723 |
locale = date.localeData(), |
|
2724 |
tableChildren |
8f6f33
|
2725 |
; |
be9654
|
2726 |
|
SE |
2727 |
tableChildren = [ |
a50b2e
|
2728 |
React.createElement('thead', { key: 'th' }, [ |
GL |
2729 |
React.createElement('tr', { key: 'h' }, [ |
|
2730 |
React.createElement('th', { key: 'p', className: 'rdtPrev', onClick: this.props.subtractTime( 1, 'months' )}, React.createElement('span', {}, '‹' )), |
|
2731 |
React.createElement('th', { key: 's', className: 'rdtSwitch', onClick: this.props.showView( 'months' ), colSpan: 5, 'data-value': this.props.viewDate.month() }, locale.months( date ) + ' ' + date.year() ), |
|
2732 |
React.createElement('th', { key: 'n', className: 'rdtNext', onClick: this.props.addTime( 1, 'months' )}, React.createElement('span', {}, '›' )) |
be9654
|
2733 |
]), |
a50b2e
|
2734 |
React.createElement('tr', { key: 'd'}, this.getDaysOfWeek( locale ).map( function( day, index ) { return React.createElement('th', { key: day + index, className: 'dow'}, day ); }) ) |
be9654
|
2735 |
]), |
a50b2e
|
2736 |
React.createElement('tbody', { key: 'tb' }, this.renderDays()) |
be9654
|
2737 |
]; |
SE |
2738 |
|
|
2739 |
if ( footer ) |
|
2740 |
tableChildren.push( footer ); |
|
2741 |
|
a50b2e
|
2742 |
return React.createElement('div', { className: 'rdtDays' }, |
GL |
2743 |
React.createElement('table', {}, tableChildren ) |
be9654
|
2744 |
); |
SE |
2745 |
}, |
|
2746 |
|
|
2747 |
/** |
|
2748 |
* Get a list of the days of the week |
|
2749 |
* depending on the current locale |
|
2750 |
* @return {array} A list with the shortname of the days |
|
2751 |
*/ |
|
2752 |
getDaysOfWeek: function( locale ) { |
|
2753 |
var days = locale._weekdaysMin, |
|
2754 |
first = locale.firstDayOfWeek(), |
|
2755 |
dow = [], |
|
2756 |
i = 0 |
8f6f33
|
2757 |
; |
be9654
|
2758 |
|
SE |
2759 |
days.forEach( function( day ) { |
|
2760 |
dow[ (7 + ( i++ ) - first) % 7 ] = day; |
|
2761 |
}); |
|
2762 |
|
|
2763 |
return dow; |
|
2764 |
}, |
|
2765 |
|
|
2766 |
renderDays: function() { |
|
2767 |
var date = this.props.viewDate, |
|
2768 |
selected = this.props.selectedDate && this.props.selectedDate.clone(), |
|
2769 |
prevMonth = date.clone().subtract( 1, 'months' ), |
|
2770 |
currentYear = date.year(), |
|
2771 |
currentMonth = date.month(), |
|
2772 |
weeks = [], |
|
2773 |
days = [], |
|
2774 |
renderer = this.props.renderDay || this.renderDay, |
|
2775 |
isValid = this.props.isValidDate || this.alwaysValidDate, |
|
2776 |
classes, isDisabled, dayProps, currentDate |
8f6f33
|
2777 |
; |
be9654
|
2778 |
|
SE |
2779 |
// Go to the last week of the previous month |
|
2780 |
prevMonth.date( prevMonth.daysInMonth() ).startOf( 'week' ); |
|
2781 |
var lastDay = prevMonth.clone().add( 42, 'd' ); |
|
2782 |
|
|
2783 |
while ( prevMonth.isBefore( lastDay ) ) { |
|
2784 |
classes = 'rdtDay'; |
|
2785 |
currentDate = prevMonth.clone(); |
|
2786 |
|
|
2787 |
if ( ( prevMonth.year() === currentYear && prevMonth.month() < currentMonth ) || ( prevMonth.year() < currentYear ) ) |
|
2788 |
classes += ' rdtOld'; |
|
2789 |
else if ( ( prevMonth.year() === currentYear && prevMonth.month() > currentMonth ) || ( prevMonth.year() > currentYear ) ) |
|
2790 |
classes += ' rdtNew'; |
|
2791 |
|
|
2792 |
if ( selected && prevMonth.isSame( selected, 'day' ) ) |
|
2793 |
classes += ' rdtActive'; |
|
2794 |
|
7750ac
|
2795 |
if ( prevMonth.isSame( moment(), 'day' ) ) |
be9654
|
2796 |
classes += ' rdtToday'; |
SE |
2797 |
|
|
2798 |
isDisabled = !isValid( currentDate, selected ); |
|
2799 |
if ( isDisabled ) |
|
2800 |
classes += ' rdtDisabled'; |
|
2801 |
|
|
2802 |
dayProps = { |
|
2803 |
key: prevMonth.format( 'M_D' ), |
|
2804 |
'data-value': prevMonth.date(), |
|
2805 |
className: classes |
|
2806 |
}; |
|
2807 |
|
|
2808 |
if ( !isDisabled ) |
|
2809 |
dayProps.onClick = this.updateSelectedDate; |
|
2810 |
|
|
2811 |
days.push( renderer( dayProps, currentDate, selected ) ); |
|
2812 |
|
|
2813 |
if ( days.length === 7 ) { |
a50b2e
|
2814 |
weeks.push( React.createElement('tr', { key: prevMonth.format( 'M_D' )}, days ) ); |
be9654
|
2815 |
days = []; |
SE |
2816 |
} |
|
2817 |
|
|
2818 |
prevMonth.add( 1, 'd' ); |
|
2819 |
} |
|
2820 |
|
|
2821 |
return weeks; |
|
2822 |
}, |
|
2823 |
|
|
2824 |
updateSelectedDate: function( event ) { |
|
2825 |
this.props.updateSelectedDate( event, true ); |
|
2826 |
}, |
|
2827 |
|
|
2828 |
renderDay: function( props, currentDate ) { |
a50b2e
|
2829 |
return React.createElement('td', props, currentDate.date() ); |
be9654
|
2830 |
}, |
SE |
2831 |
|
|
2832 |
renderFooter: function() { |
|
2833 |
if ( !this.props.timeFormat ) |
|
2834 |
return ''; |
|
2835 |
|
|
2836 |
var date = this.props.selectedDate || this.props.viewDate; |
|
2837 |
|
a50b2e
|
2838 |
return React.createElement('tfoot', { key: 'tf'}, |
GL |
2839 |
React.createElement('tr', {}, |
|
2840 |
React.createElement('td', { onClick: this.props.showView( 'time' ), colSpan: 7, className: 'rdtTimeToggle' }, date.format( this.props.timeFormat )) |
be9654
|
2841 |
) |
SE |
2842 |
); |
|
2843 |
}, |
|
2844 |
|
|
2845 |
alwaysValidDate: function() { |
|
2846 |
return 1; |
11612b
|
2847 |
}, |
JM |
2848 |
|
8f6f33
|
2849 |
handleClickOutside: function() { |
LA |
2850 |
this.props.handleClickOutside(); |
|
2851 |
} |
11612b
|
2852 |
})); |
be9654
|
2853 |
|
SE |
2854 |
module.exports = DateTimePickerDays; |
|
2855 |
|
d76f7b
|
2856 |
|
7392ed
|
2857 |
/***/ }), |
be31e2
|
2858 |
/* 19 */ |
7392ed
|
2859 |
/***/ (function(module, exports, __webpack_require__) { |
d76f7b
|
2860 |
|
7750ac
|
2861 |
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** |
JM |
2862 |
* A higher-order-component for handling onClickOutside for React components. |
|
2863 |
*/ |
|
2864 |
(function(root) { |
be9654
|
2865 |
|
7750ac
|
2866 |
// administrative |
JM |
2867 |
var registeredComponents = []; |
|
2868 |
var handlers = []; |
|
2869 |
var IGNORE_CLASS = 'ignore-react-onclickoutside'; |
|
2870 |
var DEFAULT_EVENTS = ['mousedown', 'touchstart']; |
be9654
|
2871 |
|
7750ac
|
2872 |
/** |
JM |
2873 |
* Check whether some DOM node is our Component's node. |
|
2874 |
*/ |
|
2875 |
var isNodeFound = function(current, componentNode, ignoreClass) { |
|
2876 |
if (current === componentNode) { |
|
2877 |
return true; |
|
2878 |
} |
|
2879 |
// SVG <use/> elements do not technically reside in the rendered DOM, so |
|
2880 |
// they do not have classList directly, but they offer a link to their |
|
2881 |
// corresponding element, which can have classList. This extra check is for |
|
2882 |
// that case. |
|
2883 |
// See: http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGUseElement |
|
2884 |
// Discussion: https://github.com/Pomax/react-onclickoutside/pull/17 |
|
2885 |
if (current.correspondingElement) { |
|
2886 |
return current.correspondingElement.classList.contains(ignoreClass); |
|
2887 |
} |
|
2888 |
return current.classList.contains(ignoreClass); |
|
2889 |
}; |
be9654
|
2890 |
|
7750ac
|
2891 |
/** |
JM |
2892 |
* Try to find our node in a hierarchy of nodes, returning the document |
|
2893 |
* node as highest noode if our node is not found in the path up. |
|
2894 |
*/ |
|
2895 |
var findHighest = function(current, componentNode, ignoreClass) { |
|
2896 |
if (current === componentNode) { |
|
2897 |
return true; |
|
2898 |
} |
be9654
|
2899 |
|
7750ac
|
2900 |
// If source=local then this event came from 'somewhere' |
JM |
2901 |
// inside and should be ignored. We could handle this with |
|
2902 |
// a layered approach, too, but that requires going back to |
|
2903 |
// thinking in terms of Dom node nesting, running counter |
|
2904 |
// to React's 'you shouldn't care about the DOM' philosophy. |
|
2905 |
while(current.parentNode) { |
|
2906 |
if (isNodeFound(current, componentNode, ignoreClass)) { |
|
2907 |
return true; |
|
2908 |
} |
|
2909 |
current = current.parentNode; |
|
2910 |
} |
|
2911 |
return current; |
|
2912 |
}; |
be9654
|
2913 |
|
7750ac
|
2914 |
/** |
JM |
2915 |
* Check if the browser scrollbar was clicked |
|
2916 |
*/ |
|
2917 |
var clickedScrollbar = function(evt) { |
7d7b99
|
2918 |
return document.documentElement.clientWidth <= evt.clientX || document.documentElement.clientHeight <= evt.clientY; |
7750ac
|
2919 |
}; |
be9654
|
2920 |
|
7750ac
|
2921 |
/** |
JM |
2922 |
* Generate the event handler that checks whether a clicked DOM node |
|
2923 |
* is inside of, or lives outside of, our Component's node tree. |
|
2924 |
*/ |
|
2925 |
var generateOutsideCheck = function(componentNode, componentInstance, eventHandler, ignoreClass, excludeScrollbar, preventDefault, stopPropagation) { |
|
2926 |
return function(evt) { |
|
2927 |
if (preventDefault) { |
|
2928 |
evt.preventDefault(); |
|
2929 |
} |
|
2930 |
if (stopPropagation) { |
|
2931 |
evt.stopPropagation(); |
|
2932 |
} |
|
2933 |
var current = evt.target; |
|
2934 |
if((excludeScrollbar && clickedScrollbar(evt)) || (findHighest(current, componentNode, ignoreClass) !== document)) { |
|
2935 |
return; |
|
2936 |
} |
|
2937 |
eventHandler(evt); |
|
2938 |
}; |
|
2939 |
}; |
be9654
|
2940 |
|
7750ac
|
2941 |
/** |
JM |
2942 |
* This function generates the HOC function that you'll use |
|
2943 |
* in order to impart onOutsideClick listening to an |
|
2944 |
* arbitrary component. It gets called at the end of the |
|
2945 |
* bootstrapping code to yield an instance of the |
|
2946 |
* onClickOutsideHOC function defined inside setupHOC(). |
|
2947 |
*/ |
be31e2
|
2948 |
function setupHOC(root, React, ReactDOM, createReactClass) { |
be9654
|
2949 |
|
7750ac
|
2950 |
// The actual Component-wrapping HOC: |
JM |
2951 |
return function onClickOutsideHOC(Component, config) { |
be31e2
|
2952 |
var wrapComponentWithOnClickOutsideHandling = createReactClass({ |
7750ac
|
2953 |
statics: { |
JM |
2954 |
/** |
|
2955 |
* Access the wrapped Component's class. |
|
2956 |
*/ |
|
2957 |
getClass: function() { |
|
2958 |
if (Component.getClass) { |
|
2959 |
return Component.getClass(); |
|
2960 |
} |
|
2961 |
return Component; |
|
2962 |
} |
|
2963 |
}, |
be9654
|
2964 |
|
7750ac
|
2965 |
/** |
JM |
2966 |
* Access the wrapped Component's instance. |
|
2967 |
*/ |
|
2968 |
getInstance: function() { |
|
2969 |
return Component.prototype.isReactComponent ? this.refs.instance : this; |
|
2970 |
}, |
be9654
|
2971 |
|
7750ac
|
2972 |
// this is given meaning in componentDidMount |
JM |
2973 |
__outsideClickHandler: function() {}, |
7d7b99
|
2974 |
|
SE |
2975 |
getDefaultProps: function() { |
|
2976 |
return { |
|
2977 |
excludeScrollbar: config && config.excludeScrollbar |
|
2978 |
}; |
|
2979 |
}, |
be9654
|
2980 |
|
7750ac
|
2981 |
/** |
JM |
2982 |
* Add click listeners to the current document, |
|
2983 |
* linked to this component's state. |
|
2984 |
*/ |
|
2985 |
componentDidMount: function() { |
|
2986 |
// If we are in an environment without a DOM such |
|
2987 |
// as shallow rendering or snapshots then we exit |
|
2988 |
// early to prevent any unhandled errors being thrown. |
|
2989 |
if (typeof document === 'undefined' || !document.createElement){ |
|
2990 |
return; |
|
2991 |
} |
be9654
|
2992 |
|
7750ac
|
2993 |
var instance = this.getInstance(); |
JM |
2994 |
var clickOutsideHandler; |
be9654
|
2995 |
|
7750ac
|
2996 |
if(config && typeof config.handleClickOutside === 'function') { |
JM |
2997 |
clickOutsideHandler = config.handleClickOutside(instance); |
|
2998 |
if(typeof clickOutsideHandler !== 'function') { |
|
2999 |
throw new Error('Component lacks a function for processing outside click events specified by the handleClickOutside config option.'); |
|
3000 |
} |
|
3001 |
} else if(typeof instance.handleClickOutside === 'function') { |
|
3002 |
if (React.Component.prototype.isPrototypeOf(instance)) { |
|
3003 |
clickOutsideHandler = instance.handleClickOutside.bind(instance); |
|
3004 |
} else { |
|
3005 |
clickOutsideHandler = instance.handleClickOutside; |
|
3006 |
} |
|
3007 |
} else if(typeof instance.props.handleClickOutside === 'function') { |
|
3008 |
clickOutsideHandler = instance.props.handleClickOutside; |
|
3009 |
} else { |
|
3010 |
throw new Error('Component lacks a handleClickOutside(event) function for processing outside click events.'); |
|
3011 |
} |
|
3012 |
|
|
3013 |
var componentNode = ReactDOM.findDOMNode(instance); |
|
3014 |
if (componentNode === null) { |
|
3015 |
console.warn('Antipattern warning: there was no DOM node associated with the component that is being wrapped by outsideClick.'); |
|
3016 |
console.warn([ |
|
3017 |
'This is typically caused by having a component that starts life with a render function that', |
|
3018 |
'returns `null` (due to a state or props value), so that the component \'exist\' in the React', |
|
3019 |
'chain of components, but not in the DOM.\n\nInstead, you need to refactor your code so that the', |
|
3020 |
'decision of whether or not to show your component is handled by the parent, in their render()', |
|
3021 |
'function.\n\nIn code, rather than:\n\n A{render(){return check? <.../> : null;}\n B{render(){<A check=... />}\n\nmake sure that you', |
|
3022 |
'use:\n\n A{render(){return <.../>}\n B{render(){return <...>{ check ? <A/> : null }<...>}}\n\nThat is:', |
|
3023 |
'the parent is always responsible for deciding whether or not to render any of its children.', |
|
3024 |
'It is not the child\'s responsibility to decide whether a render instruction from above should', |
|
3025 |
'get ignored or not by returning `null`.\n\nWhen any component gets its render() function called,', |
|
3026 |
'that is the signal that it should be rendering its part of the UI. It may in turn decide not to', |
|
3027 |
'render all of *its* children, but it should never return `null` for itself. It is not responsible', |
|
3028 |
'for that decision.' |
|
3029 |
].join(' ')); |
|
3030 |
} |
|
3031 |
|
|
3032 |
var fn = this.__outsideClickHandler = generateOutsideCheck( |
|
3033 |
componentNode, |
|
3034 |
instance, |
|
3035 |
clickOutsideHandler, |
|
3036 |
this.props.outsideClickIgnoreClass || IGNORE_CLASS, |
7d7b99
|
3037 |
this.props.excludeScrollbar, // fallback not needed, prop always exists because of getDefaultProps |
7750ac
|
3038 |
this.props.preventDefault || false, |
JM |
3039 |
this.props.stopPropagation || false |
|
3040 |
); |
|
3041 |
|
|
3042 |
var pos = registeredComponents.length; |
|
3043 |
registeredComponents.push(this); |
|
3044 |
handlers[pos] = fn; |
|
3045 |
|
|
3046 |
// If there is a truthy disableOnClickOutside property for this |
|
3047 |
// component, don't immediately start listening for outside events. |
|
3048 |
if (!this.props.disableOnClickOutside) { |
|
3049 |
this.enableOnClickOutside(); |
|
3050 |
} |
|
3051 |
}, |
|
3052 |
|
|
3053 |
/** |
|
3054 |
* Track for disableOnClickOutside props changes and enable/disable click outside |
|
3055 |
*/ |
|
3056 |
componentWillReceiveProps: function(nextProps) { |
|
3057 |
if (this.props.disableOnClickOutside && !nextProps.disableOnClickOutside) { |
|
3058 |
this.enableOnClickOutside(); |
|
3059 |
} else if (!this.props.disableOnClickOutside && nextProps.disableOnClickOutside) { |
|
3060 |
this.disableOnClickOutside(); |
|
3061 |
} |
|
3062 |
}, |
|
3063 |
|
|
3064 |
/** |
|
3065 |
* Remove the document's event listeners |
|
3066 |
*/ |
|
3067 |
componentWillUnmount: function() { |
|
3068 |
this.disableOnClickOutside(); |
|
3069 |
this.__outsideClickHandler = false; |
|
3070 |
var pos = registeredComponents.indexOf(this); |
|
3071 |
if( pos>-1) { |
|
3072 |
// clean up so we don't leak memory |
|
3073 |
if (handlers[pos]) { handlers.splice(pos, 1); } |
|
3074 |
registeredComponents.splice(pos, 1); |
|
3075 |
} |
|
3076 |
}, |
|
3077 |
|
|
3078 |
/** |
|
3079 |
* Can be called to explicitly enable event listening |
|
3080 |
* for clicks and touches outside of this element. |
|
3081 |
*/ |
|
3082 |
enableOnClickOutside: function() { |
|
3083 |
var fn = this.__outsideClickHandler; |
|
3084 |
if (typeof document !== 'undefined') { |
|
3085 |
var events = this.props.eventTypes || DEFAULT_EVENTS; |
|
3086 |
if (!events.forEach) { |
|
3087 |
events = [events]; |
|
3088 |
} |
|
3089 |
events.forEach(function (eventName) { |
|
3090 |
document.addEventListener(eventName, fn); |
|
3091 |
}); |
|
3092 |
} |
|
3093 |
}, |
|
3094 |
|
|
3095 |
/** |
|
3096 |
* Can be called to explicitly disable event listening |
|
3097 |
* for clicks and touches outside of this element. |
|
3098 |
*/ |
|
3099 |
disableOnClickOutside: function() { |
|
3100 |
var fn = this.__outsideClickHandler; |
|
3101 |
if (typeof document !== 'undefined') { |
|
3102 |
var events = this.props.eventTypes || DEFAULT_EVENTS; |
|
3103 |
if (!events.forEach) { |
|
3104 |
events = [events]; |
|
3105 |
} |
|
3106 |
events.forEach(function (eventName) { |
|
3107 |
document.removeEventListener(eventName, fn); |
|
3108 |
}); |
|
3109 |
} |
|
3110 |
}, |
|
3111 |
|
|
3112 |
/** |
|
3113 |
* Pass-through render |
|
3114 |
*/ |
|
3115 |
render: function() { |
|
3116 |
var passedProps = this.props; |
|
3117 |
var props = {}; |
|
3118 |
Object.keys(this.props).forEach(function(key) { |
|
3119 |
if (key !== 'excludeScrollbar') { |
|
3120 |
props[key] = passedProps[key]; |
|
3121 |
} |
|
3122 |
}); |
|
3123 |
if (Component.prototype.isReactComponent) { |
|
3124 |
props.ref = 'instance'; |
|
3125 |
} |
|
3126 |
props.disableOnClickOutside = this.disableOnClickOutside; |
|
3127 |
props.enableOnClickOutside = this.enableOnClickOutside; |
|
3128 |
return React.createElement(Component, props); |
|
3129 |
} |
|
3130 |
}); |
|
3131 |
|
|
3132 |
// Add display name for React devtools |
|
3133 |
(function bindWrappedComponentName(c, wrapper) { |
|
3134 |
var componentName = c.displayName || c.name || 'Component'; |
|
3135 |
wrapper.displayName = 'OnClickOutside(' + componentName + ')'; |
|
3136 |
}(Component, wrapComponentWithOnClickOutsideHandling)); |
|
3137 |
|
|
3138 |
return wrapComponentWithOnClickOutsideHandling; |
|
3139 |
}; |
|
3140 |
} |
|
3141 |
|
|
3142 |
/** |
|
3143 |
* This function sets up the library in ways that |
|
3144 |
* work with the various modulde loading solutions |
|
3145 |
* used in JavaScript land today. |
|
3146 |
*/ |
|
3147 |
function setupBinding(root, factory) { |
|
3148 |
if (true) { |
|
3149 |
// AMD. Register as an anonymous module. |
be31e2
|
3150 |
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(12),__webpack_require__(20),__webpack_require__(11)], __WEBPACK_AMD_DEFINE_RESULT__ = function(React, ReactDom, createReactClass) { |
JB |
3151 |
if (!createReactClass) createReactClass = React.createClass; |
|
3152 |
return factory(root, React, ReactDom, createReactClass); |
7750ac
|
3153 |
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
JM |
3154 |
} else if (typeof exports === 'object') { |
|
3155 |
// Node. Note that this does not work with strict |
|
3156 |
// CommonJS, but only CommonJS-like environments |
|
3157 |
// that support module.exports |
be31e2
|
3158 |
module.exports = factory(root, require('react'), require('react-dom'), require('create-react-class')); |
7750ac
|
3159 |
} else { |
JM |
3160 |
// Browser globals (root is window) |
be31e2
|
3161 |
var createReactClass = React.createClass ? React.createClass : window.createReactClass; |
JB |
3162 |
root.onClickOutside = factory(root, React, ReactDOM, createReactClass); |
7750ac
|
3163 |
} |
JM |
3164 |
} |
|
3165 |
|
|
3166 |
// Make it all happen |
|
3167 |
setupBinding(root, setupHOC); |
|
3168 |
|
|
3169 |
}(this)); |
be9654
|
3170 |
|
d359eb
|
3171 |
|
7392ed
|
3172 |
/***/ }), |
be31e2
|
3173 |
/* 20 */ |
7392ed
|
3174 |
/***/ (function(module, exports) { |
d359eb
|
3175 |
|
be31e2
|
3176 |
module.exports = __WEBPACK_EXTERNAL_MODULE_20__; |
11612b
|
3177 |
|
7392ed
|
3178 |
/***/ }), |
be31e2
|
3179 |
/* 21 */ |
7392ed
|
3180 |
/***/ (function(module, exports, __webpack_require__) { |
11612b
|
3181 |
|
JM |
3182 |
'use strict'; |
|
3183 |
|
be31e2
|
3184 |
var React = __webpack_require__(12), |
8f6f33
|
3185 |
createClass = __webpack_require__(11), |
be31e2
|
3186 |
onClickOutside = __webpack_require__(19) |
8f6f33
|
3187 |
; |
11612b
|
3188 |
|
be31e2
|
3189 |
var DateTimePickerMonths = onClickOutside( createClass({ |
11612b
|
3190 |
render: function() { |
a50b2e
|
3191 |
return React.createElement('div', { className: 'rdtMonths' }, [ |
GL |
3192 |
React.createElement('table', { key: 'a' }, React.createElement('thead', {}, React.createElement('tr', {}, [ |
|
3193 |
React.createElement('th', { key: 'prev', className: 'rdtPrev', onClick: this.props.subtractTime( 1, 'years' )}, React.createElement('span', {}, '‹' )), |
|
3194 |
React.createElement('th', { key: 'year', className: 'rdtSwitch', onClick: this.props.showView( 'years' ), colSpan: 2, 'data-value': this.props.viewDate.year() }, this.props.viewDate.year() ), |
|
3195 |
React.createElement('th', { key: 'next', className: 'rdtNext', onClick: this.props.addTime( 1, 'years' )}, React.createElement('span', {}, '›' )) |
11612b
|
3196 |
]))), |
a50b2e
|
3197 |
React.createElement('table', { key: 'months' }, React.createElement('tbody', { key: 'b' }, this.renderMonths())) |
11612b
|
3198 |
]); |
JM |
3199 |
}, |
|
3200 |
|
|
3201 |
renderMonths: function() { |
|
3202 |
var date = this.props.selectedDate, |
|
3203 |
month = this.props.viewDate.month(), |
|
3204 |
year = this.props.viewDate.year(), |
|
3205 |
rows = [], |
|
3206 |
i = 0, |
|
3207 |
months = [], |
|
3208 |
renderer = this.props.renderMonth || this.renderMonth, |
|
3209 |
isValid = this.props.isValidDate || this.alwaysValidDate, |
|
3210 |
classes, props, currentMonth, isDisabled, noOfDaysInMonth, daysInMonth, validDay, |
|
3211 |
// Date is irrelevant because we're only interested in month |
|
3212 |
irrelevantDate = 1 |
8f6f33
|
3213 |
; |
11612b
|
3214 |
|
JM |
3215 |
while (i < 12) { |
|
3216 |
classes = 'rdtMonth'; |
|
3217 |
currentMonth = |
|
3218 |
this.props.viewDate.clone().set({ year: year, month: i, date: irrelevantDate }); |
|
3219 |
|
|
3220 |
noOfDaysInMonth = currentMonth.endOf( 'month' ).format( 'D' ); |
|
3221 |
daysInMonth = Array.from({ length: noOfDaysInMonth }, function( e, i ) { |
|
3222 |
return i + 1; |
|
3223 |
}); |
|
3224 |
|
|
3225 |
validDay = daysInMonth.find(function( d ) { |
|
3226 |
var day = currentMonth.clone().set( 'date', d ); |
|
3227 |
return isValid( day ); |
|
3228 |
}); |
|
3229 |
|
|
3230 |
isDisabled = ( validDay === undefined ); |
|
3231 |
|
|
3232 |
if ( isDisabled ) |
|
3233 |
classes += ' rdtDisabled'; |
|
3234 |
|
7d7b99
|
3235 |
if ( date && i === date.month() && year === date.year() ) |
11612b
|
3236 |
classes += ' rdtActive'; |
JM |
3237 |
|
|
3238 |
props = { |
|
3239 |
key: i, |
|
3240 |
'data-value': i, |
|
3241 |
className: classes |
|
3242 |
}; |
|
3243 |
|
|
3244 |
if ( !isDisabled ) |
|
3245 |
props.onClick = ( this.props.updateOn === 'months' ? |
|
3246 |
this.updateSelectedMonth : this.props.setDate( 'month' ) ); |
|
3247 |
|
|
3248 |
months.push( renderer( props, i, year, date && date.clone() ) ); |
|
3249 |
|
|
3250 |
if ( months.length === 4 ) { |
a50b2e
|
3251 |
rows.push( React.createElement('tr', { key: month + '_' + rows.length }, months ) ); |
11612b
|
3252 |
months = []; |
JM |
3253 |
} |
|
3254 |
|
|
3255 |
i++; |
|
3256 |
} |
|
3257 |
|
|
3258 |
return rows; |
|
3259 |
}, |
|
3260 |
|
|
3261 |
updateSelectedMonth: function( event ) { |
|
3262 |
this.props.updateSelectedDate( event ); |
|
3263 |
}, |
|
3264 |
|
|
3265 |
renderMonth: function( props, month ) { |
|
3266 |
var localMoment = this.props.viewDate; |
|
3267 |
var monthStr = localMoment.localeData().monthsShort( localMoment.month( month ) ); |
|
3268 |
var strLength = 3; |
|
3269 |
// Because some months are up to 5 characters long, we want to |
|
3270 |
// use a fixed string length for consistency |
|
3271 |
var monthStrFixedLength = monthStr.substring( 0, strLength ); |
a50b2e
|
3272 |
return React.createElement('td', props, capitalize( monthStrFixedLength ) ); |
11612b
|
3273 |
}, |
JM |
3274 |
|
|
3275 |
alwaysValidDate: function() { |
|
3276 |
return 1; |
|
3277 |
}, |
|
3278 |
|
8f6f33
|
3279 |
handleClickOutside: function() { |
LA |
3280 |
this.props.handleClickOutside(); |
|
3281 |
} |
11612b
|
3282 |
})); |
JM |
3283 |
|
|
3284 |
function capitalize( str ) { |
|
3285 |
return str.charAt( 0 ).toUpperCase() + str.slice( 1 ); |
|
3286 |
} |
|
3287 |
|
|
3288 |
module.exports = DateTimePickerMonths; |
|
3289 |
|
|
3290 |
|
7392ed
|
3291 |
/***/ }), |
be31e2
|
3292 |
/* 22 */ |
7392ed
|
3293 |
/***/ (function(module, exports, __webpack_require__) { |
11612b
|
3294 |
|
JM |
3295 |
'use strict'; |
|
3296 |
|
be31e2
|
3297 |
var React = __webpack_require__(12), |
8f6f33
|
3298 |
createClass = __webpack_require__(11), |
be31e2
|
3299 |
onClickOutside = __webpack_require__(19) |
8f6f33
|
3300 |
; |
a50b2e
|
3301 |
|
be31e2
|
3302 |
var DateTimePickerYears = onClickOutside( createClass({ |
11612b
|
3303 |
render: function() { |
JM |
3304 |
var year = parseInt( this.props.viewDate.year() / 10, 10 ) * 10; |
|
3305 |
|
a50b2e
|
3306 |
return React.createElement('div', { className: 'rdtYears' }, [ |
GL |
3307 |
React.createElement('table', { key: 'a' }, React.createElement('thead', {}, React.createElement('tr', {}, [ |
|
3308 |
React.createElement('th', { key: 'prev', className: 'rdtPrev', onClick: this.props.subtractTime( 10, 'years' )}, React.createElement('span', {}, '‹' )), |
|
3309 |
React.createElement('th', { key: 'year', className: 'rdtSwitch', onClick: this.props.showView( 'years' ), colSpan: 2 }, year + '-' + ( year + 9 ) ), |
|
3310 |
React.createElement('th', { key: 'next', className: 'rdtNext', onClick: this.props.addTime( 10, 'years' )}, React.createElement('span', {}, '›' )) |
8f6f33
|
3311 |
]))), |
a50b2e
|
3312 |
React.createElement('table', { key: 'years' }, React.createElement('tbody', {}, this.renderYears( year ))) |
11612b
|
3313 |
]); |
JM |
3314 |
}, |
|
3315 |
|
|
3316 |
renderYears: function( year ) { |
|
3317 |
var years = [], |
|
3318 |
i = -1, |
|
3319 |
rows = [], |
|
3320 |
renderer = this.props.renderYear || this.renderYear, |
|
3321 |
selectedDate = this.props.selectedDate, |
|
3322 |
isValid = this.props.isValidDate || this.alwaysValidDate, |
|
3323 |
classes, props, currentYear, isDisabled, noOfDaysInYear, daysInYear, validDay, |
|
3324 |
// Month and date are irrelevant here because |
|
3325 |
// we're only interested in the year |
|
3326 |
irrelevantMonth = 0, |
|
3327 |
irrelevantDate = 1 |
8f6f33
|
3328 |
; |
11612b
|
3329 |
|
JM |
3330 |
year--; |
|
3331 |
while (i < 11) { |
|
3332 |
classes = 'rdtYear'; |
|
3333 |
currentYear = this.props.viewDate.clone().set( |
|
3334 |
{ year: year, month: irrelevantMonth, date: irrelevantDate } ); |
|
3335 |
|
|
3336 |
// Not sure what 'rdtOld' is for, commenting out for now as it's not working properly |
|
3337 |
// if ( i === -1 | i === 10 ) |
|
3338 |
// classes += ' rdtOld'; |
|
3339 |
|
|
3340 |
noOfDaysInYear = currentYear.endOf( 'year' ).format( 'DDD' ); |
|
3341 |
daysInYear = Array.from({ length: noOfDaysInYear }, function( e, i ) { |
|
3342 |
return i + 1; |
|
3343 |
}); |
|
3344 |
|
|
3345 |
validDay = daysInYear.find(function( d ) { |
|
3346 |
var day = currentYear.clone().dayOfYear( d ); |
|
3347 |
return isValid( day ); |
|
3348 |
}); |
|
3349 |
|
|
3350 |
isDisabled = ( validDay === undefined ); |
|
3351 |
|
|
3352 |
if ( isDisabled ) |
|
3353 |
classes += ' rdtDisabled'; |
|
3354 |
|
|
3355 |
if ( selectedDate && selectedDate.year() === year ) |
|
3356 |
classes += ' rdtActive'; |
|
3357 |
|
|
3358 |
props = { |
|
3359 |
key: year, |
|
3360 |
'data-value': year, |
|
3361 |
className: classes |
|
3362 |
}; |
|
3363 |
|
|
3364 |
if ( !isDisabled ) |
|
3365 |
props.onClick = ( this.props.updateOn === 'years' ? |
|
3366 |
this.updateSelectedYear : this.props.setDate('year') ); |
|
3367 |
|
|
3368 |
years.push( renderer( props, year, selectedDate && selectedDate.clone() )); |
|
3369 |
|
|
3370 |
if ( years.length === 4 ) { |
a50b2e
|
3371 |
rows.push( React.createElement('tr', { key: i }, years ) ); |
11612b
|
3372 |
years = []; |
JM |
3373 |
} |
|
3374 |
|
|
3375 |
year++; |
|
3376 |
i++; |
|
3377 |
} |
|
3378 |
|
|
3379 |
return rows; |
|
3380 |
}, |
|
3381 |
|
|
3382 |
updateSelectedYear: function( event ) { |
|
3383 |
this.props.updateSelectedDate( event ); |
|
3384 |
}, |
|
3385 |
|
|
3386 |
renderYear: function( props, year ) { |
a50b2e
|
3387 |
return React.createElement('td', props, year ); |
11612b
|
3388 |
}, |
JM |
3389 |
|
|
3390 |
alwaysValidDate: function() { |
|
3391 |
return 1; |
|
3392 |
}, |
|
3393 |
|
8f6f33
|
3394 |
handleClickOutside: function() { |
LA |
3395 |
this.props.handleClickOutside(); |
|
3396 |
} |
11612b
|
3397 |
})); |
JM |
3398 |
|
|
3399 |
module.exports = DateTimePickerYears; |
|
3400 |
|
|
3401 |
|
7392ed
|
3402 |
/***/ }), |
be31e2
|
3403 |
/* 23 */ |
7392ed
|
3404 |
/***/ (function(module, exports, __webpack_require__) { |
11612b
|
3405 |
|
JM |
3406 |
'use strict'; |
|
3407 |
|
be31e2
|
3408 |
var React = __webpack_require__(12), |
8f6f33
|
3409 |
createClass = __webpack_require__(11), |
11612b
|
3410 |
assign = __webpack_require__(1), |
8f6f33
|
3411 |
onClickOutside = __webpack_require__(19) |
LA |
3412 |
; |
11612b
|
3413 |
|
be31e2
|
3414 |
var DateTimePickerTime = onClickOutside( createClass({ |
11612b
|
3415 |
getInitialState: function() { |
JM |
3416 |
return this.calculateState( this.props ); |
|
3417 |
}, |
|
3418 |
|
|
3419 |
calculateState: function( props ) { |
|
3420 |
var date = props.selectedDate || props.viewDate, |
|
3421 |
format = props.timeFormat, |
|
3422 |
counters = [] |
8f6f33
|
3423 |
; |
11612b
|
3424 |
|
JM |
3425 |
if ( format.toLowerCase().indexOf('h') !== -1 ) { |
|
3426 |
counters.push('hours'); |
|
3427 |
if ( format.indexOf('m') !== -1 ) { |
|
3428 |
counters.push('minutes'); |
|
3429 |
if ( format.indexOf('s') !== -1 ) { |
|
3430 |
counters.push('seconds'); |
|
3431 |
} |
|
3432 |
} |
|
3433 |
} |
|
3434 |
|
|
3435 |
var daypart = false; |
|
3436 |
if ( this.state !== null && this.props.timeFormat.toLowerCase().indexOf( ' a' ) !== -1 ) { |
|
3437 |
if ( this.props.timeFormat.indexOf( ' A' ) !== -1 ) { |
|
3438 |
daypart = ( this.state.hours >= 12 ) ? 'PM' : 'AM'; |
|
3439 |
} else { |
|
3440 |
daypart = ( this.state.hours >= 12 ) ? 'pm' : 'am'; |
|
3441 |
} |
|
3442 |
} |
|
3443 |
|
|
3444 |
return { |
|
3445 |
hours: date.format( 'H' ), |
|
3446 |
minutes: date.format( 'mm' ), |
|
3447 |
seconds: date.format( 'ss' ), |
|
3448 |
milliseconds: date.format( 'SSS' ), |
|
3449 |
daypart: daypart, |
|
3450 |
counters: counters |
|
3451 |
}; |
|
3452 |
}, |
|
3453 |
|
|
3454 |
renderCounter: function( type ) { |
|
3455 |
if ( type !== 'daypart' ) { |
|
3456 |
var value = this.state[ type ]; |
|
3457 |
if ( type === 'hours' && this.props.timeFormat.toLowerCase().indexOf( ' a' ) !== -1 ) { |
|
3458 |
value = ( value - 1 ) % 12 + 1; |
|
3459 |
|
|
3460 |
if ( value === 0 ) { |
|
3461 |
value = 12; |
|
3462 |
} |
|
3463 |
} |
a50b2e
|
3464 |
return React.createElement('div', { key: type, className: 'rdtCounter' }, [ |
GL |
3465 |
React.createElement('span', { key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'increase', type ) }, '▲' ), |
|
3466 |
React.createElement('div', { key: 'c', className: 'rdtCount' }, value ), |
|
3467 |
React.createElement('span', { key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'decrease', type ) }, '▼' ) |
11612b
|
3468 |
]); |
JM |
3469 |
} |
|
3470 |
return ''; |
|
3471 |
}, |
|
3472 |
|
|
3473 |
renderDayPart: function() { |
a50b2e
|
3474 |
return React.createElement('div', { key: 'dayPart', className: 'rdtCounter' }, [ |
GL |
3475 |
React.createElement('span', { key: 'up', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, '▲' ), |
|
3476 |
React.createElement('div', { key: this.state.daypart, className: 'rdtCount' }, this.state.daypart ), |
|
3477 |
React.createElement('span', { key: 'do', className: 'rdtBtn', onMouseDown: this.onStartClicking( 'toggleDayPart', 'hours') }, '▼' ) |
11612b
|
3478 |
]); |
JM |
3479 |
}, |
|
3480 |
|
|
3481 |
render: function() { |
|
3482 |
var me = this, |
|
3483 |
counters = [] |
|
3484 |
; |
|
3485 |
|
|
3486 |
this.state.counters.forEach( function( c ) { |
|
3487 |
if ( counters.length ) |
a50b2e
|
3488 |
counters.push( React.createElement('div', { key: 'sep' + counters.length, className: 'rdtCounterSeparator' }, ':' ) ); |
11612b
|
3489 |
counters.push( me.renderCounter( c ) ); |
JM |
3490 |
}); |
|
3491 |
|
|
3492 |
if ( this.state.daypart !== false ) { |
|
3493 |
counters.push( me.renderDayPart() ); |
|
3494 |
} |
|
3495 |
|
|
3496 |
if ( this.state.counters.length === 3 && this.props.timeFormat.indexOf( 'S' ) !== -1 ) { |
a50b2e
|
3497 |
counters.push( React.createElement('div', { className: 'rdtCounterSeparator', key: 'sep5' }, ':' ) ); |
11612b
|
3498 |
counters.push( |
a50b2e
|
3499 |
React.createElement('div', { className: 'rdtCounter rdtMilli', key: 'm' }, |
GL |
3500 |
React.createElement('input', { value: this.state.milliseconds, type: 'text', onChange: this.updateMilli } ) |
11612b
|
3501 |
) |
JM |
3502 |
); |
|
3503 |
} |
|
3504 |
|
a50b2e
|
3505 |
return React.createElement('div', { className: 'rdtTime' }, |
GL |
3506 |
React.createElement('table', {}, [ |
11612b
|
3507 |
this.renderHeader(), |
a50b2e
|
3508 |
React.createElement('tbody', { key: 'b'}, React.createElement('tr', {}, React.createElement('td', {}, |
GL |
3509 |
React.createElement('div', { className: 'rdtCounters' }, counters ) |
11612b
|
3510 |
))) |
JM |
3511 |
]) |
|
3512 |
); |
|
3513 |
}, |
|
3514 |
|
|
3515 |
componentWillMount: function() { |
|
3516 |
var me = this; |
|
3517 |
me.timeConstraints = { |
|
3518 |
hours: { |
|
3519 |
min: 0, |
|
3520 |
max: 23, |
|
3521 |
step: 1 |
|
3522 |
}, |
|
3523 |
minutes: { |
|
3524 |
min: 0, |
|
3525 |
max: 59, |
|
3526 |
step: 1 |
|
3527 |
}, |
|
3528 |
seconds: { |
|
3529 |
min: 0, |
|
3530 |
max: 59, |
|
3531 |
step: 1 |
|
3532 |
}, |
|
3533 |
milliseconds: { |
|
3534 |
min: 0, |
|
3535 |
max: 999, |
|
3536 |
step: 1 |
|
3537 |
} |
|
3538 |
}; |
|
3539 |
['hours', 'minutes', 'seconds', 'milliseconds'].forEach( function( type ) { |
|
3540 |
assign(me.timeConstraints[ type ], me.props.timeConstraints[ type ]); |
|
3541 |
}); |
|
3542 |
this.setState( this.calculateState( this.props ) ); |
|
3543 |
}, |
|
3544 |
|
|
3545 |
componentWillReceiveProps: function( nextProps ) { |
|
3546 |
this.setState( this.calculateState( nextProps ) ); |
|
3547 |
}, |
|
3548 |
|
|
3549 |
updateMilli: function( e ) { |
|
3550 |
var milli = parseInt( e.target.value, 10 ); |
|
3551 |
if ( milli === e.target.value && milli >= 0 && milli < 1000 ) { |
|
3552 |
this.props.setTime( 'milliseconds', milli ); |
|
3553 |
this.setState( { milliseconds: milli } ); |
|
3554 |
} |
|
3555 |
}, |
|
3556 |
|
|
3557 |
renderHeader: function() { |
|
3558 |
if ( !this.props.dateFormat ) |
|
3559 |
return null; |
|
3560 |
|
|
3561 |
var date = this.props.selectedDate || this.props.viewDate; |
a50b2e
|
3562 |
return React.createElement('thead', { key: 'h' }, React.createElement('tr', {}, |
GL |
3563 |
React.createElement('th', { className: 'rdtSwitch', colSpan: 4, onClick: this.props.showView( 'days' ) }, date.format( this.props.dateFormat ) ) |
11612b
|
3564 |
)); |
JM |
3565 |
}, |
|
3566 |
|
|
3567 |
onStartClicking: function( action, type ) { |
|
3568 |
var me = this; |
|
3569 |
|
|
3570 |
return function() { |
|
3571 |
var update = {}; |
|
3572 |
update[ type ] = me[ action ]( type ); |
|
3573 |
me.setState( update ); |
|
3574 |
|
|
3575 |
me.timer = setTimeout( function() { |
|
3576 |
me.increaseTimer = setInterval( function() { |
|
3577 |
update[ type ] = me[ action ]( type ); |
|
3578 |
me.setState( update ); |
|
3579 |
}, 70); |
|
3580 |
}, 500); |
|
3581 |
|
|
3582 |
me.mouseUpListener = function() { |
|
3583 |
clearTimeout( me.timer ); |
|
3584 |
clearInterval( me.increaseTimer ); |
|
3585 |
me.props.setTime( type, me.state[ type ] ); |
|
3586 |
document.body.removeEventListener( 'mouseup', me.mouseUpListener ); |
|
3587 |
}; |
|
3588 |
|
|
3589 |
document.body.addEventListener( 'mouseup', me.mouseUpListener ); |
|
3590 |
}; |
|
3591 |
}, |
|
3592 |
|
|
3593 |
padValues: { |
|
3594 |
hours: 1, |
|
3595 |
minutes: 2, |
|
3596 |
seconds: 2, |
|
3597 |
milliseconds: 3 |
|
3598 |
}, |
|
3599 |
|
|
3600 |
toggleDayPart: function( type ) { // type is always 'hours' |
|
3601 |
var value = parseInt( this.state[ type ], 10) + 12; |
|
3602 |
if ( value > this.timeConstraints[ type ].max ) |
|
3603 |
value = this.timeConstraints[ type ].min + ( value - ( this.timeConstraints[ type ].max + 1 ) ); |
|
3604 |
return this.pad( type, value ); |
|
3605 |
}, |
|
3606 |
|
|
3607 |
increase: function( type ) { |
|
3608 |
var value = parseInt( this.state[ type ], 10) + this.timeConstraints[ type ].step; |
|
3609 |
if ( value > this.timeConstraints[ type ].max ) |
|
3610 |
value = this.timeConstraints[ type ].min + ( value - ( this.timeConstraints[ type ].max + 1 ) ); |
|
3611 |
return this.pad( type, value ); |
|
3612 |
}, |
|
3613 |
|
|
3614 |
decrease: function( type ) { |
|
3615 |
var value = parseInt( this.state[ type ], 10) - this.timeConstraints[ type ].step; |
|
3616 |
if ( value < this.timeConstraints[ type ].min ) |
|
3617 |
value = this.timeConstraints[ type ].max + 1 - ( this.timeConstraints[ type ].min - value ); |
|
3618 |
return this.pad( type, value ); |
|
3619 |
}, |
|
3620 |
|
|
3621 |
pad: function( type, value ) { |
|
3622 |
var str = value + ''; |
|
3623 |
while ( str.length < this.padValues[ type ] ) |
|
3624 |
str = '0' + str; |
|
3625 |
return str; |
|
3626 |
}, |
|
3627 |
|
8f6f33
|
3628 |
handleClickOutside: function() { |
LA |
3629 |
this.props.handleClickOutside(); |
|
3630 |
} |
11612b
|
3631 |
})); |
JM |
3632 |
|
|
3633 |
module.exports = DateTimePickerTime; |
|
3634 |
|
d76f7b
|
3635 |
|
7392ed
|
3636 |
/***/ }) |
d76f7b
|
3637 |
/******/ ]) |
M |
3638 |
}); |
be9654
|
3639 |
; |