@spothero/ui 15.1.0 → 15.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/package.json +2 -3
  2. package/styles/Alert/Alert.jsx +0 -45
  3. package/styles/Alert/Alert.spec.js +0 -85
  4. package/styles/AutoSuggestInput/AutoSuggestInput.jsx +0 -429
  5. package/styles/AutoSuggestInput/AutoSuggestInput.spec.js +0 -132
  6. package/styles/AutoSuggestInput/AutoSuggestItem.jsx +0 -61
  7. package/styles/AutoSuggestInput/AutoSuggestList.jsx +0 -85
  8. package/styles/Badge/Badge.jsx +0 -24
  9. package/styles/Badge/Badge.spec.js +0 -43
  10. package/styles/Chart/Chart.jsx +0 -185
  11. package/styles/Chart/Chart.spec.js +0 -369
  12. package/styles/Checkbox/Checkbox.jsx +0 -159
  13. package/styles/Checkbox/Checkbox.spec.js +0 -142
  14. package/styles/DateTime/DatePicker.jsx +0 -281
  15. package/styles/DateTime/DatePicker.spec.js +0 -186
  16. package/styles/DateTime/DatePickerCalendar.jsx +0 -170
  17. package/styles/DateTime/DatePickerCalendarNavigation.jsx +0 -44
  18. package/styles/DateTime/DatePickerCalendarWithRange.jsx +0 -218
  19. package/styles/DateTime/DateTimePicker.jsx +0 -266
  20. package/styles/DateTime/DateTimePicker.spec.js +0 -60
  21. package/styles/DateTime/DateTimeRangePicker.jsx +0 -629
  22. package/styles/DateTime/DateTimeRangePicker.spec.js +0 -425
  23. package/styles/DateTime/TimePicker.jsx +0 -158
  24. package/styles/DateTime/TimePicker.spec.js +0 -148
  25. package/styles/DateTime/date-time-assertions.js +0 -89
  26. package/styles/DateTime/index.js +0 -6
  27. package/styles/ErrorBoundary/ErrorBoundary.jsx +0 -76
  28. package/styles/ErrorBoundary/ErrorBoundary.spec.js +0 -72
  29. package/styles/Flyout/Flyout.jsx +0 -147
  30. package/styles/Flyout/Flyout.spec.js +0 -117
  31. package/styles/Form/Form.jsx +0 -151
  32. package/styles/Form/Form.spec.js +0 -148
  33. package/styles/Form/FormElementError.jsx +0 -18
  34. package/styles/Form/FormGroup.jsx +0 -32
  35. package/styles/Form/FormGroupError.jsx +0 -24
  36. package/styles/Form/index.js +0 -4
  37. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.jsx +0 -215
  38. package/styles/GooglePlacesSearchInput/GooglePlacesSearchInput.spec.js +0 -213
  39. package/styles/GooglePlacesSearchInput/PoweredByGoogle.jsx +0 -43
  40. package/styles/GooglePlacesSearchInput/index.js +0 -2
  41. package/styles/HorizontalRule/HorizontalRule.jsx +0 -36
  42. package/styles/HorizontalRule/HorizontalRule.spec.js +0 -94
  43. package/styles/Label/Label.jsx +0 -22
  44. package/styles/Label/Label.spec.js +0 -11
  45. package/styles/Notification/Notification.jsx +0 -117
  46. package/styles/Notification/Notification.spec.js +0 -154
  47. package/styles/Notification/NotificationContainer.jsx +0 -90
  48. package/styles/Notification/NotificationPropTypes.js +0 -20
  49. package/styles/Notification/index.js +0 -2
  50. package/styles/PasswordControl/PasswordControl.jsx +0 -197
  51. package/styles/PasswordControl/PasswordControl.spec.js +0 -236
  52. package/styles/Portal/Portal.jsx +0 -65
  53. package/styles/Portal/Portal.spec.js +0 -45
  54. package/styles/PulseLoader/PulseLoader.jsx +0 -71
  55. package/styles/PulseLoader/PulseLoader.spec.js +0 -63
  56. package/styles/Radio/Radio.jsx +0 -114
  57. package/styles/Radio/Radio.spec.js +0 -128
  58. package/styles/Radio/RadioGroup.jsx +0 -105
  59. package/styles/Radio/index.js +0 -2
  60. package/styles/RenderInBody/RenderInBody.jsx +0 -56
  61. package/styles/RenderInBody/RenderInBody.spec.js +0 -24
  62. package/styles/Select/Select.jsx +0 -251
  63. package/styles/Select/Select.spec.js +0 -254
  64. package/styles/Select/SelectItemPropTypes.js +0 -19
  65. package/styles/Select/index.js +0 -2
  66. package/styles/SelectControlled/SelectControlled.jsx +0 -250
  67. package/styles/SelectControlled/SelectControlled.spec.js +0 -290
  68. package/styles/SelectControlled/index.js +0 -1
  69. package/styles/Sprite/Sprite.jsx +0 -16
  70. package/styles/Sprite/Sprite.spec.js +0 -11
  71. package/styles/Tabs/Tab.jsx +0 -38
  72. package/styles/Tabs/TabContent.jsx +0 -46
  73. package/styles/Tabs/TabNavigation.jsx +0 -64
  74. package/styles/Tabs/TabPanel.jsx +0 -30
  75. package/styles/Tabs/Tabs.jsx +0 -87
  76. package/styles/Tabs/Tabs.spec.js +0 -201
  77. package/styles/Tabs/index.js +0 -5
  78. package/styles/TextArea/TextArea.jsx +0 -137
  79. package/styles/TextArea/TextArea.spec.js +0 -111
  80. package/styles/TextInput/TextInput.jsx +0 -159
  81. package/styles/TextInput/TextInput.spec.js +0 -263
  82. package/styles/TextInput/TextInputPropTypes.js +0 -88
  83. package/styles/TextInput/index.js +0 -2
  84. package/styles/Tooltip/Tooltip.jsx +0 -230
  85. package/styles/Tooltip/Tooltip.spec.js +0 -170
@@ -1,629 +0,0 @@
1
- import React, {Component} from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import uuidV4 from 'uuid/v4';
5
- import DateUtils from '@spothero/utils/date';
6
- import TimeUtils from '@spothero/utils/time';
7
- import DateTimePicker from './DateTimePicker';
8
-
9
- const TOOLTIP_TYPES = ['date', 'time', 'none'];
10
-
11
- export default class DateTimeRangePicker extends Component {
12
- static propTypes = {
13
- /** Additional class(es) to add to the component. */
14
- className: PropTypes.string,
15
- /** A unique ID which is used to identify the start picker for accessibility purposes on the client as well as the server. */
16
- startId: PropTypes.string.isRequired,
17
- /** A unique ID which is used to identify the end picker for accessibility purposes on the client as well as the server. */
18
- endId: PropTypes.string.isRequired,
19
- /** Whether to show the calendar and clock icons in the selectors. */
20
- useIcons: PropTypes.bool,
21
- /** If using the icons, whether they should appear on the left or right side of the input fields. */
22
- iconPosition: PropTypes.oneOf(['left', 'right']),
23
- /** A custom label (typically a Label component) to display above the start date input. */
24
- startDateLabel: PropTypes.node,
25
- /** A custom label (typically a Label component) to display above the start time selector. */
26
- startTimeLabel: PropTypes.node,
27
- /** A custom label (typically a Label component) to display above the end date input. */
28
- endDateLabel: PropTypes.node,
29
- /** A custom label (typically a Label component) to display above the end time selector. */
30
- endTimeLabel: PropTypes.node,
31
- /** A unique name which is used to identify the start date element. If belonging to a form this is used as the key for serialization and is required. */
32
- startDateName: PropTypes.string,
33
- /** A unique name which is used to identify the start time element. If belonging to a form this is used as the key for serialization and is required. */
34
- startTimeName: PropTypes.string,
35
- /** A unique name which is used to identify the end date element. If belonging to a form this is used as the key for serialization and is required. */
36
- endDateName: PropTypes.string,
37
- /** A unique name which is used to identify the end time element. If belonging to a form this is used as the key for serialization and is required. */
38
- endTimeName: PropTypes.string,
39
- /** The multiplier with which to create selectable times in the dropdown (in minutes). */
40
- timeStep: PropTypes.number,
41
- /** The amount of time (in minutes) the end time should bump up when the start date is after end date. Usually set to the same as timeStep. */
42
- endTimeBump: PropTypes.number,
43
- /** An element or string to separate the start date/time from the end date/time. */
44
- separator: PropTypes.node,
45
- /** A function that alters how the selected start date is displayed in the input field. Takes the date in MM/DD/YYYY format and should return a string with the new format. */
46
- startDateDisplayFormat: PropTypes.func,
47
- /** The <a href="https://momentjs.com/docs/#/displaying/format/" target="_blank">format</a> to display the start time in. */
48
- startTimeDisplayFormat: PropTypes.string,
49
- /** A function that alters how the selected end date is displayed in the input field. Takes the date in MM/DD/YYYY format and should return a string with the new format. */
50
- endDateDisplayFormat: PropTypes.func,
51
- /** The <a href="https://momentjs.com/docs/#/displaying/format/" target="_blank">format</a> to display the end time in. */
52
- endTimeDisplayFormat: PropTypes.string,
53
- /** A string in the format 'MM/DD/YYYY' representing the start date which should be selected. */
54
- startDate: PropTypes.string,
55
- /** A string in the format of 'hh:mm A' representing the start time which should be selected. */
56
- startTime: PropTypes.string,
57
- /** A string in the format 'MM/DD/YYYY' representing the end date which should be selected. */
58
- endDate: PropTypes.string,
59
- /** A string in the format of 'hh:mm A' representing the end time which should be selected. */
60
- endTime: PropTypes.string,
61
- /**
62
- * Function to execute when the selected start date and/or start time changes.
63
- *
64
- * @param {String} startDate - The start date in the format 'MM/DD/YYYY'.
65
- * @param {String} startTime - The start time in the format 'hh:mm A'.
66
- * @param {String} endDate - The end date in the format 'MM/DD/YYYY'.
67
- * @param {String} endTime - The end time in the format 'hh:mm A'.
68
- */
69
- onStartChange: PropTypes.func,
70
- /**
71
- * Function to execute when the selected end date and/or end time changes.
72
- *
73
- * @param {String} startDate - The start date in the format 'MM/DD/YYYY'.
74
- * @param {String} startTime - The start time in the format 'hh:mm A'.
75
- * @param {String} endDate - The end date in the format 'MM/DD/YYYY'.
76
- * @param {String} endTime - The end time in the format 'hh:mm A'.
77
- */
78
- onEndChange: PropTypes.func,
79
- /**
80
- * Where the applicable start tooltip should be anchored to.
81
- *
82
- * @deprecated Tooltip support was removed in v6.0.0.
83
- */
84
- startTooltipType: PropTypes.oneOf(TOOLTIP_TYPES),
85
- /**
86
- * Where the applicable end tooltip should be anchored to.
87
- *
88
- * @deprecated Tooltip support was removed in v6.0.0.
89
- */
90
- endTooltipType: PropTypes.oneOf(TOOLTIP_TYPES),
91
- /**
92
- * The message to display inside of the start tooltip.
93
- *
94
- * @deprecated Tooltip support was removed in v6.0.0.
95
- */
96
- startTooltipMessage: PropTypes.string,
97
- /**
98
- * The message to display inside of the end tooltip.
99
- *
100
- * @deprecated Tooltip support was removed in v6.0.0.
101
- */
102
- endTooltipMessage: PropTypes.string,
103
- /**
104
- * Where to position the tooltip in relation to the triggering element.
105
- *
106
- * @deprecated Tooltip support was removed in v6.0.0.
107
- */
108
- tooltipPosition: PropTypes.oneOf(['top', 'right', 'bottom', 'left']),
109
- /**
110
- * Whether to reposition the tooltip when it moves, be it via window resize or scrolling or whatever moves it.
111
- *
112
- * @deprecated Tooltip support was removed in v6.0.0.
113
- */
114
- updateTooltipPositionOnMove: PropTypes.bool,
115
- /** Whether to disable days before today in the start date selector. */
116
- disableStartPast: PropTypes.bool,
117
- /** A string in the format 'MM/DD/YYYY' representing the date where days before it should be disabled in the start calendar. */
118
- disableStartDateBefore: PropTypes.string,
119
- /** A string in the format 'MM/DD/YYYY' representing the date where days after it should be disabled in the start calendar. */
120
- disableStartDateAfter: PropTypes.string,
121
- /** A string in the format 'hh:mm A' representing the time where times before it should be disabled in the start selector. */
122
- disableStartTimeBefore: PropTypes.string,
123
- /** A string in the format 'hh:mm A' representing the time where times after it should be disabled in the start selector. */
124
- disableStartTimeAfter: PropTypes.string,
125
- /** Whether to disable days before today in the end date selector. */
126
- disableEndPast: PropTypes.bool,
127
- /** A string in the format 'MM/DD/YYYY' representing the date where days before it should be disabled in the end calendar. */
128
- disableEndDateBefore: PropTypes.string,
129
- /** A string in the format 'MM/DD/YYYY' representing the date where days after it should be disabled in the end calendar. */
130
- disableEndDateAfter: PropTypes.string,
131
- /** A string in the format 'hh:mm A' representing the time where times before it should be disabled in the end selector. */
132
- disableEndTimeBefore: PropTypes.string,
133
- /** A string in the format 'hh:mm A' representing the time where times after it should be disabled in the end selector. */
134
- disableEndTimeAfter: PropTypes.string,
135
- /** Whether to disable the Start DateTimePicker. */
136
- disableStartDateTimePicker: PropTypes.bool,
137
- /** Whether to disable the End DateTimePicker. */
138
- disableEndDateTimePicker: PropTypes.bool,
139
- /** Enables automatically bumping the end date/time to be the start date/time plus `endTimeBump`. If false, the fields will be marked invalid. */
140
- autoBumpInvalidEnabled: PropTypes.bool,
141
- /** Puts the calendar in the center of the page with a shim behind it. */
142
- useTetherShim: PropTypes.bool,
143
- /** Forces highlighting all the fields in the red error state. */
144
- areAllFieldsEmpty: PropTypes.bool,
145
- /**
146
- * Function to execute when the selected date(s) are valid.
147
- */
148
- onValid: PropTypes.func,
149
- /**
150
- * Function to execute when the selected date(s) are invalid.
151
- */
152
- onInvalid: PropTypes.func,
153
- };
154
- static defaultProps = {
155
- useIcons: true,
156
- timeStep: 30,
157
- endTimeBump: 30,
158
- disableStartPast: true,
159
- disableEndPast: true,
160
- iconPosition: 'right',
161
- };
162
-
163
- constructor(props) {
164
- super(props);
165
-
166
- const {
167
- startId,
168
- endId,
169
- startDate,
170
- startTime,
171
- endDate,
172
- endTime,
173
- disableEndTimeBefore,
174
- startTooltipType,
175
- startTooltipMessage,
176
- endTooltipType,
177
- endTooltipMessage,
178
- tooltipPosition,
179
- updateTooltipPositionOnMove,
180
- } = props;
181
-
182
- if (!startId || !endId) {
183
- throw new Error(
184
- `The props 'startId' and 'endId' are required to make DateTimeRangePicker accessible for users using assistive technologies such as screen readers. Check the render method of DateTimeRangePicker.`
185
- );
186
- }
187
-
188
- if (
189
- startTooltipType ||
190
- startTooltipMessage ||
191
- endTooltipType ||
192
- endTooltipMessage ||
193
- tooltipPosition ||
194
- updateTooltipPositionOnMove
195
- ) {
196
- throw new Error(
197
- 'Tooltip support inside of DateTimePicker was removed in v6.0.0. Use dateNode and timeNode getters in a parent component to add tooltips manually as necessary.'
198
- );
199
- }
200
-
201
- this.state = {
202
- startDate,
203
- startTime,
204
- endDate,
205
- endTime,
206
- disableEndTimeBefore,
207
- addErrorClass: false,
208
- addHighlightClass: false,
209
- endKey: uuidV4(),
210
- };
211
- }
212
-
213
- componentDidMount() {
214
- this._checkInitialTimeDisabling();
215
- }
216
-
217
- componentDidUpdate(prevProps, prevState) {
218
- const {onValid, onInvalid} = this.props;
219
- const {
220
- startDate,
221
- startTime,
222
- endDate,
223
- endTime,
224
- addHighlightClass,
225
- } = this.state;
226
- const {
227
- startDate: prevStartDate,
228
- startTime: prevStartTime,
229
- endDate: prevEndDate,
230
- endTime: prevEndTime,
231
- } = prevState;
232
- const startMoment =
233
- startDate && startTime
234
- ? this._getCombinedDate(startDate, startTime)
235
- : null;
236
- const endMoment =
237
- endDate && endTime ? this._getCombinedDate(endDate, endTime) : null;
238
- const validationState = {
239
- startDate,
240
- startTime,
241
- endDate,
242
- endTime,
243
- startMoment,
244
- endMoment,
245
- isEndDayBeforeStartDay:
246
- startMoment &&
247
- endMoment &&
248
- endMoment.isBefore(startMoment, 'day'),
249
- isEndTimeSameOrBeforeStartTime:
250
- startMoment &&
251
- endMoment &&
252
- endMoment.isSameOrBefore(startMoment, 'hour'),
253
- };
254
- let isValid = true;
255
-
256
- if (addHighlightClass) {
257
- // if the previous state of the component included the highlight class remove it here
258
- // so that next time it needs to highlight it can be re-added and the animation plays
259
- this._clearHighlightTimeout();
260
-
261
- this._removeHighlightTimeout = setTimeout(() => {
262
- this.setState({
263
- addHighlightClass: false,
264
- });
265
- }, 3000);
266
- }
267
-
268
- if (startDate && startTime && endDate && endTime) {
269
- if (
270
- startDate !== prevStartDate ||
271
- startTime !== prevStartTime ||
272
- endDate !== prevEndDate ||
273
- endTime !== prevEndTime
274
- ) {
275
- isValid = this._checkValidity();
276
- }
277
- }
278
-
279
- if (!isValid && onInvalid) {
280
- onInvalid(validationState);
281
- } else if (isValid && onValid) {
282
- onValid(validationState);
283
- }
284
- }
285
-
286
- componentWillUnmount() {
287
- this._clearHighlightTimeout();
288
- }
289
-
290
- _onStartChange = ({selectedDate, selectedTime}) => {
291
- const {onStartChange} = this.props;
292
- const {endDate, endTime} = this.state;
293
- const newData = {
294
- startDate: selectedDate,
295
- startTime: selectedTime,
296
- endDate,
297
- endTime,
298
- };
299
-
300
- this.setState({
301
- startDate: selectedDate,
302
- startTime: selectedTime,
303
- ...this._getDisableEndTimeBefore(newData),
304
- });
305
-
306
- if (onStartChange) {
307
- onStartChange(newData);
308
- }
309
- };
310
-
311
- _onEndChange = ({selectedDate, selectedTime}) => {
312
- const {onEndChange} = this.props;
313
- const {startDate, startTime} = this.state;
314
- const newData = {
315
- startDate,
316
- startTime,
317
- endDate: selectedDate,
318
- endTime: selectedTime,
319
- };
320
-
321
- this.setState({
322
- endDate: selectedDate,
323
- endTime: selectedTime,
324
- ...this._getDisableEndTimeBefore(newData),
325
- });
326
-
327
- if (onEndChange) {
328
- onEndChange(newData);
329
- }
330
- };
331
-
332
- _checkInitialTimeDisabling() {
333
- const {startDate, startTime, endDate, endTime} = this.state;
334
- const {disableEndTimeBefore, endKey} = this._getDisableEndTimeBefore({
335
- startDate,
336
- startTime,
337
- endDate,
338
- endTime,
339
- });
340
-
341
- this.setState({
342
- disableEndTimeBefore,
343
- endKey,
344
- });
345
- }
346
-
347
- _clearHighlightTimeout() {
348
- if (this._removeHighlightTimeout) {
349
- clearTimeout(this._removeHighlightTimeout);
350
- }
351
- }
352
-
353
- _getCombinedDate(date, time) {
354
- return DateUtils.combineDateAndTime(
355
- DateUtils.getAsMoment(date),
356
- TimeUtils.getAsMoment(time)
357
- );
358
- }
359
-
360
- _checkValidity() {
361
- const {autoBumpInvalidEnabled, endTimeBump, onEndChange} = this.props;
362
- const {startDate, startTime, endDate, endTime} = this.state;
363
- const start = this._getCombinedDate(startDate, startTime);
364
- const end = this._getCombinedDate(endDate, endTime);
365
- const newState = {
366
- addErrorClass: false,
367
- endDate,
368
- endTime,
369
- };
370
- let isValid = true;
371
-
372
- if (end.isSameOrBefore(start)) {
373
- isValid = false;
374
-
375
- if (autoBumpInvalidEnabled) {
376
- isValid = true;
377
-
378
- const newEnd = start.clone().add(endTimeBump, 'minutes');
379
-
380
- newState.endDate = newEnd.format('MM/DD/YYYY');
381
- newState.endTime = newEnd.format('hh:mm A');
382
- newState.addHighlightClass = true;
383
- newState.endKey = uuidV4();
384
-
385
- // check what times should be disabled based on newly selected values
386
- const {
387
- disableEndTimeBefore,
388
- endTime: newEndTime,
389
- } = this._getDisableEndTimeBefore({
390
- startDate,
391
- startTime,
392
- endDate: newState.endDate,
393
- endTime: newState.endTime,
394
- });
395
-
396
- newState.disableEndTimeBefore = disableEndTimeBefore;
397
-
398
- if (newEndTime) {
399
- newState.endTime = newEndTime;
400
- }
401
- } else {
402
- newState.addErrorClass = true;
403
- }
404
- }
405
-
406
- this.setState(newState);
407
-
408
- if (onEndChange) {
409
- onEndChange({
410
- startDate,
411
- startTime,
412
- endDate: newState.endDate,
413
- endTime: newState.endTime,
414
- });
415
- }
416
-
417
- return isValid;
418
- }
419
-
420
- _getDisableEndTimeBefore({startDate, startTime, endDate, endTime}) {
421
- const {
422
- timeStep,
423
- endTimeBump,
424
- autoBumpInvalidEnabled,
425
- disableEndTimeBefore: propDisableEndTimeBefore,
426
- } = this.props;
427
- const {disableEndTimeBefore, endKey} = this.state;
428
- const newState = {
429
- disableEndTimeBefore,
430
- endKey,
431
- };
432
-
433
- if (startDate && startTime && endDate && endTime) {
434
- const start = this._getCombinedDate(startDate, startTime);
435
- const end = this._getCombinedDate(endDate, endTime);
436
-
437
- if (start.isSame(end, 'day')) {
438
- newState.disableEndTimeBefore = start
439
- .clone()
440
- .add(timeStep, 'minutes')
441
- .format('hh:mm A');
442
- newState.endKey = uuidV4();
443
-
444
- if (
445
- start.isSameOrAfter(end, 'hour') &&
446
- autoBumpInvalidEnabled
447
- ) {
448
- // bump the end time because it will get bumped anyway due to the prior time not being in the list anymore
449
- newState.endTime = start
450
- .clone()
451
- .add(endTimeBump, 'minutes')
452
- .format('hh:mm A');
453
- newState.addHighlightClass = true;
454
- }
455
- } else if (
456
- newState.disableEndTimeBefore !== propDisableEndTimeBefore
457
- ) {
458
- newState.disableEndTimeBefore = propDisableEndTimeBefore;
459
- newState.endKey = uuidV4();
460
- }
461
- }
462
-
463
- return newState;
464
- }
465
-
466
- /**
467
- * Getter for the start date time picker.
468
- *
469
- * @public
470
- * @returns {Element} - The component reference.
471
- */
472
- get startDateTime() {
473
- return this._startDateTime;
474
- }
475
-
476
- /**
477
- * Getter for the end date time picker.
478
- *
479
- * @public
480
- * @returns {Element} - The component reference.
481
- */
482
- get endDateTime() {
483
- return this._endDateTime;
484
- }
485
-
486
- render() {
487
- const {
488
- className,
489
- startId,
490
- endId,
491
- useIcons,
492
- iconPosition,
493
- startDateLabel,
494
- startTimeLabel,
495
- endDateLabel,
496
- endTimeLabel,
497
- startDateName,
498
- startTimeName,
499
- endDateName,
500
- endTimeName,
501
- timeStep,
502
- separator,
503
- disableStartPast,
504
- disableStartDateBefore,
505
- disableStartDateAfter,
506
- disableStartTimeBefore,
507
- disableStartTimeAfter,
508
- disableEndPast,
509
- disableEndDateBefore,
510
- disableEndDateAfter,
511
- disableEndTimeAfter,
512
- disableStartDateTimePicker,
513
- disableEndDateTimePicker,
514
- areAllFieldsEmpty,
515
- useTetherShim,
516
- startDateDisplayFormat,
517
- startTimeDisplayFormat,
518
- endDateDisplayFormat,
519
- endTimeDisplayFormat,
520
- } = this.props;
521
- const {
522
- startDate,
523
- startTime,
524
- endDate,
525
- endTime,
526
- addErrorClass,
527
- disableEndTimeBefore,
528
- endKey,
529
- addHighlightClass,
530
- } = this.state;
531
- const classes = classNames('DateTimeRangePicker', className);
532
- const startClasses = classNames('DateTimePicker-start', {
533
- 'DateTimePicker-error': areAllFieldsEmpty,
534
- });
535
-
536
- const endClasses = classNames(
537
- 'DateTimePicker-end',
538
- {'DateTimePicker-highlight': addHighlightClass},
539
- {'DateTimePicker-error': addErrorClass || areAllFieldsEmpty}
540
- );
541
-
542
- const newDisableEndDateBefore = startDate
543
- ? startDate
544
- : disableEndDateBefore;
545
- let overrideInitialEndMonthWithSelected = true;
546
-
547
- // if the end picker has a date disabled whose month is after the end selected date, make sure the calendar starts with the first selectable month
548
- if (endDate && newDisableEndDateBefore) {
549
- const endMoment = DateUtils.getAsMoment(endDate);
550
- const endBeforeMoment = DateUtils.getAsMoment(
551
- newDisableEndDateBefore
552
- );
553
-
554
- overrideInitialEndMonthWithSelected = endMoment.isAfter(
555
- endBeforeMoment
556
- );
557
- }
558
-
559
- return (
560
- <div className={classes}>
561
- <DateTimePicker
562
- ref={node => {
563
- this._startDateTime = node;
564
- }}
565
- id={startId}
566
- dateName={startDateName}
567
- timeName={startTimeName}
568
- className={startClasses}
569
- calendarClassName="calendar-start"
570
- useIcons={useIcons}
571
- iconPosition={iconPosition}
572
- dateLabel={startDateLabel}
573
- timeLabel={startTimeLabel}
574
- timeStep={timeStep}
575
- selectedDate={startDate}
576
- selectedTime={startTime}
577
- dateDisplayFormat={startDateDisplayFormat}
578
- timeDisplayFormat={startTimeDisplayFormat}
579
- onChange={this._onStartChange}
580
- disablePast={disableStartPast}
581
- disableDateBefore={disableStartDateBefore}
582
- disableDateAfter={disableStartDateAfter}
583
- disableTimeBefore={disableStartTimeBefore}
584
- disableTimeAfter={disableStartTimeAfter}
585
- useTetherShim={useTetherShim}
586
- datePlaceholder="Start Date"
587
- timePlaceholder="Start Time"
588
- disabled={disableStartDateTimePicker}
589
- />
590
-
591
- {separator}
592
-
593
- <DateTimePicker
594
- key={endKey}
595
- ref={node => {
596
- this._endDateTime = node;
597
- }}
598
- id={endId}
599
- dateName={endDateName}
600
- timeName={endTimeName}
601
- className={endClasses}
602
- calendarClassName="calendar-end"
603
- useIcons={useIcons}
604
- iconPosition={iconPosition}
605
- dateLabel={endDateLabel}
606
- timeLabel={endTimeLabel}
607
- timeStep={timeStep}
608
- selectedDate={endDate}
609
- selectedTime={endTime}
610
- dateDisplayFormat={endDateDisplayFormat}
611
- timeDisplayFormat={endTimeDisplayFormat}
612
- overrideInitialMonthWithSelected={
613
- overrideInitialEndMonthWithSelected
614
- }
615
- onChange={this._onEndChange}
616
- disablePast={disableEndPast}
617
- disableDateBefore={newDisableEndDateBefore}
618
- disableDateAfter={disableEndDateAfter}
619
- disableTimeBefore={disableEndTimeBefore}
620
- disableTimeAfter={disableEndTimeAfter}
621
- useTetherShim={useTetherShim}
622
- datePlaceholder="End Date"
623
- timePlaceholder="End Time"
624
- disabled={disableEndDateTimePicker}
625
- />
626
- </div>
627
- );
628
- }
629
- }