@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,425 +0,0 @@
1
- import moment from 'moment';
2
- import DateTimeAssertions from './date-time-assertions';
3
-
4
- describe('<DateTimeRangePicker />', () => {
5
- context('Display', () => {
6
- context('Default', () => {
7
- beforeEach(() => {
8
- cy.visitStory('v1/DateTimeRangePicker/Display', 'Default')
9
- .get('.DateTimePicker-start')
10
- .find('select')
11
- .as('startSelect')
12
- .get('.DateTimePicker-start')
13
- .find('input')
14
- .as('startInput')
15
- .get('.DateTimePicker-end')
16
- .find('select')
17
- .as('endSelect')
18
- .get('.DateTimePicker-end')
19
- .find('input')
20
- .as('endInput');
21
- });
22
-
23
- it('Renders properly', () => {
24
- cy.get('.DateTimeRangePicker')
25
- .should('have.class', 'DateTimeRangePicker')
26
- .get('@startSelect')
27
- .get('@startInput')
28
- .get('@endSelect')
29
- .get('@endInput');
30
- });
31
-
32
- it('Does not automatically bump the end date/time when start date/time are equal or after the end date/time.', () => {
33
- cy.get('.DateTimePicker-end')
34
- .find('input')
35
- .focus()
36
- .get('.DayPicker-Day--today')
37
- .click()
38
- .get('.DateTimePicker-end')
39
- .find('select')
40
- .select('11:00 PM')
41
- .get('.DateTimePicker-start')
42
- .find('select')
43
- .select('11:30 PM')
44
- .get('.DateTimePicker-start')
45
- .find('input')
46
- .focus()
47
- .get('.DayPicker-Day--today')
48
- .click()
49
- .get('.DateTimePicker-end')
50
- .find('select')
51
- .should('have.value', '11:00 PM');
52
- });
53
- });
54
-
55
- context('Classes', () => {
56
- it('Has custom class names', () => {
57
- cy.visitStory('v1/DateTimeRangePicker/Display', 'Classes')
58
- .get('.DateTimeRangePicker')
59
- .should('have.class', 'DateTimeRangePickerClasses')
60
- .should('have.class', 'DateTimeRangePickerClasses2');
61
- });
62
- });
63
-
64
- context('Labels and Names', () => {
65
- it('Has custom labels and field names', () => {
66
- cy.visitStory(
67
- 'v1/DateTimeRangePicker/Display',
68
- 'LabelsAndNames'
69
- )
70
- .get('.DateTimePicker-start .DatePicker .Label')
71
- .contains('Pick a start date yo')
72
- .get('.DateTimePicker-start .TimePicker .Label')
73
- .contains('Pick a start time yo')
74
- .get('.DateTimePicker-end .DatePicker .Label')
75
- .contains('Pick a end date yo')
76
- .get('.DateTimePicker-end .TimePicker .Label')
77
- .contains('Pick a end time yo')
78
- .get('.DateTimePicker-start .DatePicker .FormElement-item')
79
- .should('have.attr', 'name', 'start-date')
80
- .get('.DateTimePicker-start .TimePicker .FormElement-item')
81
- .should('have.attr', 'name', 'start-time')
82
- .get('.DateTimePicker-end .DatePicker .FormElement-item')
83
- .should('have.attr', 'name', 'end-date')
84
- .get('.DateTimePicker-end .TimePicker .FormElement-item')
85
- .should('have.attr', 'name', 'end-time');
86
- });
87
- });
88
-
89
- context('Selected Dates/Times', () => {
90
- it('Has pre-selected start date, start time, end date and end time', () => {
91
- cy.visitStory(
92
- 'v1/DateTimeRangePicker/Display',
93
- 'SelectedDateTime'
94
- )
95
- .get('.DateTimePicker-start .DatePicker .FormElement-item')
96
- .should('have.value', '01/01/2040')
97
- .get('.DateTimePicker-start .TimePicker .FormElement-item')
98
- .should('have.value', '11:30 AM')
99
- .get('.DateTimePicker-end .DatePicker .FormElement-item')
100
- .should('have.value', '01/01/2040')
101
- .get('.DateTimePicker-end .TimePicker .FormElement-item')
102
- .should('have.value', '01:30 PM');
103
- });
104
- });
105
-
106
- context('Disabled', () => {
107
- it('Has disabled form elements', () => {
108
- cy.visitStory('v1/DateTimeRangePicker/Display', 'Disabled')
109
- // Start DatePicker
110
- .get('.DateTimePicker-start .DatePicker .FormElement-item')
111
- .should('have.attr', 'disabled', 'disabled')
112
- // Start TimePicker
113
- .get('.DateTimePicker-start .TimePicker .FormElement-item')
114
- .should('have.attr', 'disabled', 'disabled')
115
- // End DatePicker
116
- .get('.DateTimePicker-end .DatePicker .FormElement-item')
117
- .should('have.attr', 'disabled', 'disabled')
118
- // End TimePicker
119
- .get('.DateTimePicker-end .TimePicker .FormElement-item')
120
- .should('have.attr', 'disabled', 'disabled');
121
- });
122
- });
123
-
124
- context('Separator', () => {
125
- it('Render properly', () => {
126
- cy.visitStory('v1/DateTimeRangePicker/Display', 'Separator')
127
- .contains('This comes in between dates')
128
- .should('exist');
129
- });
130
- });
131
- });
132
-
133
- context('Interaction', () => {
134
- context('Validation', () => {
135
- const today = moment();
136
- const dateTodayFormatted = today.format('MM/DD/YYYY');
137
-
138
- beforeEach(() => {
139
- cy.visitStory(
140
- 'v1/DateTimeRangePicker/Interaction',
141
- 'Validation',
142
- {
143
- onBeforeLoad: contentWindow => {
144
- contentWindow.onDateTimeRangePickerOnValid = ({
145
- startDate,
146
- startTime,
147
- endDate,
148
- endTime,
149
- startMoment,
150
- endMoment,
151
- isEndDayBeforeStartDay,
152
- isEndTimeSameOrBeforeStartTime,
153
- }) => {
154
- /* eslint-disable no-console */
155
- console.log('onValid values:', {
156
- startDate,
157
- startTime,
158
- endDate,
159
- endTime,
160
- startMoment,
161
- endMoment,
162
- isEndDayBeforeStartDay,
163
- isEndTimeSameOrBeforeStartTime,
164
- });
165
- /* eslint-enable no-console */
166
- };
167
-
168
- contentWindow.onDateTimeRangePickerOnInvalid = ({
169
- startDate,
170
- startTime,
171
- endDate,
172
- endTime,
173
- startMoment,
174
- endMoment,
175
- isEndDayBeforeStartDay,
176
- isEndTimeSameOrBeforeStartTime,
177
- }) => {
178
- /* eslint-disable no-console */
179
- console.log('onInvalid values:', {
180
- startDate,
181
- startTime,
182
- endDate,
183
- endTime,
184
- startMoment,
185
- endMoment,
186
- isEndDayBeforeStartDay,
187
- isEndTimeSameOrBeforeStartTime,
188
- });
189
- /* eslint-enable no-console */
190
- };
191
-
192
- cy.stub(
193
- contentWindow,
194
- 'onDateTimeRangePickerOnValid'
195
- ).as('onValid');
196
-
197
- cy.stub(
198
- contentWindow,
199
- 'onDateTimeRangePickerOnInvalid'
200
- ).as('onInvalid');
201
- },
202
- }
203
- )
204
- .get('.DateTimePicker-start')
205
- .find('select')
206
- .as('startSelect')
207
- .get('.DateTimePicker-start')
208
- .find('input')
209
- .as('startInput')
210
- .get('.DateTimePicker-end')
211
- .find('select')
212
- .as('endSelect')
213
- .get('.DateTimePicker-end')
214
- .find('input')
215
- .as('endInput');
216
- });
217
-
218
- it('Fires `onValid` properly', () => {
219
- cy.get('@startInput')
220
- .focus()
221
- .get('.DayPicker-Day--today')
222
- .click()
223
- .get('@startSelect')
224
- .select('03:00 AM')
225
- .get('@endInput')
226
- .focus()
227
- .get('.DayPicker-Day--today')
228
- .click()
229
- .get('@endSelect')
230
- .select('08:00 AM')
231
- .get('@onValid')
232
- .should(response => {
233
- const onValidCalls = response.getCalls();
234
-
235
- // remove difficult to compare moment objects from calls
236
- onValidCalls.forEach(call => {
237
- delete call.args[0].startMoment;
238
- delete call.args[0].endMoment;
239
- });
240
-
241
- // interactions above will cause 6 varying onValid calls with progressively more data returned
242
- expect(onValidCalls[0].args[0]).to.deep.equal({
243
- startDate: undefined, // eslint-disable-line no-undefined
244
- startTime: undefined, // eslint-disable-line no-undefined
245
- endDate: undefined, // eslint-disable-line no-undefined
246
- endTime: undefined, // eslint-disable-line no-undefined
247
- isEndDayBeforeStartDay: null,
248
- isEndTimeSameOrBeforeStartTime: null,
249
- });
250
- expect(onValidCalls[1].args[0]).to.deep.equal({
251
- startDate: dateTodayFormatted,
252
- startTime: undefined, // eslint-disable-line no-undefined
253
- endDate: undefined, // eslint-disable-line no-undefined
254
- endTime: undefined, // eslint-disable-line no-undefined
255
- isEndDayBeforeStartDay: null,
256
- isEndTimeSameOrBeforeStartTime: null,
257
- });
258
- expect(onValidCalls[2].args[0]).to.deep.equal({
259
- startDate: dateTodayFormatted,
260
- startTime: '03:00 AM',
261
- endDate: undefined, // eslint-disable-line no-undefined
262
- endTime: undefined, // eslint-disable-line no-undefined
263
- isEndDayBeforeStartDay: null,
264
- isEndTimeSameOrBeforeStartTime: null,
265
- });
266
- expect(onValidCalls[3].args[0]).to.deep.equal({
267
- startDate: dateTodayFormatted,
268
- startTime: '03:00 AM',
269
- endDate: dateTodayFormatted,
270
- endTime: undefined, // eslint-disable-line no-undefined
271
- isEndDayBeforeStartDay: null,
272
- isEndTimeSameOrBeforeStartTime: null,
273
- });
274
- expect(onValidCalls[4].args[0]).to.deep.equal({
275
- startDate: dateTodayFormatted,
276
- startTime: '03:00 AM',
277
- endDate: dateTodayFormatted,
278
- endTime: '08:00 AM',
279
- isEndDayBeforeStartDay: false,
280
- isEndTimeSameOrBeforeStartTime: false,
281
- });
282
- expect(onValidCalls[5].args[0]).to.deep.equal({
283
- startDate: dateTodayFormatted,
284
- startTime: '03:00 AM',
285
- endDate: dateTodayFormatted,
286
- endTime: '08:00 AM',
287
- isEndDayBeforeStartDay: false,
288
- isEndTimeSameOrBeforeStartTime: false,
289
- });
290
- });
291
- });
292
-
293
- let nextDayDateFormatted = null;
294
-
295
- it('Fires `onInvalid` properly', () => {
296
- cy.get('@endInput')
297
- .focus()
298
- .get('.DayPicker-Day--today')
299
- .click()
300
- .get('@endSelect')
301
- .select('03:00 AM')
302
- .get('@startSelect')
303
- .select('08:00 AM')
304
- .get('@startInput')
305
- .focus()
306
- .get('.DayPicker-Day--today')
307
- .then($todayElement => {
308
- if ($todayElement.next().length) {
309
- return $todayElement.next();
310
- } else {
311
- return $todayElement
312
- .parent()
313
- .next()
314
- .find('.DayPicker-Day')
315
- .first();
316
- }
317
- })
318
- .then($nextDay => {
319
- nextDayDateFormatted = moment(
320
- $nextDay.find('span')[0].getAttribute('data-date')
321
- ).format('MM/DD/YYYY');
322
-
323
- cy.wrap($nextDay).click();
324
- })
325
- .get('@onInvalid')
326
- .should(response => {
327
- const onInvalidCalls = response.getCalls();
328
-
329
- // remove difficult to compare moment objects from calls
330
- delete onInvalidCalls[0].args[0].startMoment;
331
- delete onInvalidCalls[0].args[0].endMoment;
332
-
333
- // interactions above result in one onInvalid call
334
- expect(onInvalidCalls[0].args[0]).to.deep.equal({
335
- startDate: nextDayDateFormatted,
336
- startTime: '08:00 AM',
337
- endDate: dateTodayFormatted,
338
- endTime: '03:00 AM',
339
- isEndDayBeforeStartDay: true,
340
- isEndTimeSameOrBeforeStartTime: true,
341
- });
342
- });
343
- });
344
- });
345
-
346
- context('All Fields Empty', () => {
347
- it('Has all the fields in the red error state', () => {
348
- cy.visitStory(
349
- 'v1/DateTimeRangePicker/Interaction',
350
- 'AllFieldsEmpty'
351
- )
352
- .get('.DateTimePicker-start')
353
- .should('have.class', 'DateTimePicker-error')
354
- .get('.DateTimePicker-end')
355
- .should('have.class', 'DateTimePicker-error');
356
- });
357
- });
358
-
359
- context('Auto Bump Invalid', () => {
360
- it('Automatically bumps the end date/time to be the start date/time plus 60 minutes.', () => {
361
- cy.visitStory(
362
- 'v1/DateTimeRangePicker/Interaction',
363
- 'AutoBumpInvalid'
364
- )
365
- .get('.DateTimePicker-end')
366
- .find('input')
367
- .focus()
368
- .get('.DayPicker-Day--today')
369
- .click()
370
- .get('.DateTimePicker-end')
371
- .find('select')
372
- .select('03:00 AM')
373
- .get('.DateTimePicker-start')
374
- .find('select')
375
- .select('08:00 AM')
376
- .get('.DateTimePicker-start')
377
- .find('input')
378
- .focus()
379
- .get('.DayPicker-Day--today')
380
- .click()
381
- .get('.DateTimePicker-end')
382
- .find('select')
383
- .should('have.value', '09:00 AM')
384
- .get('.DateTimePicker-end')
385
- .should('have.class', 'DateTimePicker-highlight');
386
- });
387
- });
388
-
389
- context('Enable/Disable Dates', () => {
390
- it('Enables dates in the past when disablePast is false', () => {
391
- cy.visitStory(
392
- 'v1/DateTimeRangePicker/Interaction',
393
- 'EnablePastDates'
394
- );
395
-
396
- DateTimeAssertions.pastDatesEnabled(
397
- '.DateTimePicker-start .DatePicker .FormElement-item'
398
- );
399
- DateTimeAssertions.pastDatesEnabled(
400
- '.DateTimePicker-end .DatePicker .FormElement-item'
401
- );
402
- });
403
-
404
- it('Disables dates and times before disableBefore and after disableAfter', () => {
405
- cy.visitStory(
406
- 'v1/DateTimeRangePicker/Interaction',
407
- 'DisableBeforeAfter'
408
- );
409
-
410
- DateTimeAssertions.datesDisabledBeforeAndAfter(
411
- '.DateTimePicker-start .DatePicker .FormElement-item'
412
- );
413
- DateTimeAssertions.datesDisabledBeforeAndAfter(
414
- '.DateTimePicker-end .DatePicker .FormElement-item'
415
- );
416
- DateTimeAssertions.timesDisabledBeforeAndAfter(
417
- '.DateTimePicker-start .TimePicker select'
418
- );
419
- DateTimeAssertions.timesDisabledBeforeAndAfter(
420
- '.DateTimePicker-end .TimePicker select'
421
- );
422
- });
423
- });
424
- });
425
- });
@@ -1,158 +0,0 @@
1
- import React, {Component} from 'react';
2
- import PropTypes from 'prop-types';
3
- import classNames from 'classnames';
4
- import moment from 'moment';
5
- import omit from 'lodash/omit';
6
- import IconClock from '@spothero/icons/clock';
7
- import TimeUtils from '@spothero/utils/time';
8
- import Select from '../Select/Select';
9
-
10
- export default class TimePicker extends Component {
11
- static propTypes = {
12
- /** Additional class(es) to add to the component. */
13
- className: PropTypes.string,
14
- /** A unique name which is used to identify this element. If belonging to a form this is used as the key for serialization and is required. */
15
- name: PropTypes.string,
16
- /** Whether to show the clock icon in the input field. */
17
- useIcon: PropTypes.bool,
18
- /** If using the icon, whether it should appear on the left or right side of the input field. */
19
- iconPosition: PropTypes.oneOf(['left', 'right']),
20
- /** A custom label (typically a Label component) to display above the input. */
21
- label: PropTypes.element,
22
- /** The placeholder text to show in the input before a selection is made. */
23
- placeholder: PropTypes.string,
24
- /** The <a href="https://momentjs.com/docs/#/displaying/format/" target="_blank">format</a> to display the time in. */
25
- displayFormat: PropTypes.string,
26
- /** A string in the format of 'hh:mm A' representing the time which should be selected. */
27
- selectedTime: PropTypes.string,
28
- /** The multiplier with which to create selectable times in the dropdown (in minutes). */
29
- step: PropTypes.number,
30
- /** A string in the format 'hh:mm A' representing the time where times before it should be disabled in the selector. */
31
- disableBefore: PropTypes.string,
32
- /** A string in the format 'hh:mm A' representing the time where times after it should be disabled in the selector. */
33
- disableAfter: PropTypes.string,
34
- /** Whether the component is disabled. */
35
- disabled: PropTypes.bool,
36
- /**
37
- * Function to execute when the selected time changes.
38
- *
39
- * @param {String} selectedTime - The selected time in the format 'hh:mm A'.
40
- */
41
- onChange: PropTypes.func,
42
- };
43
- static defaultProps = {
44
- useIcon: true,
45
- step: 30,
46
- iconPosition: 'right',
47
- displayFormat: 'hh:mm A',
48
- };
49
- state = {
50
- selectedTime: this.props.selectedTime,
51
- };
52
-
53
- constructor(props) {
54
- super(props);
55
-
56
- const {step, disableBefore, disableAfter, displayFormat} = props;
57
- const dayStart = moment().startOf('day');
58
- const timesParams = {
59
- step,
60
- };
61
-
62
- if (disableBefore) {
63
- timesParams.ignoreBefore = moment(disableBefore, 'hh:mm A').diff(
64
- dayStart,
65
- 'minutes'
66
- );
67
- }
68
-
69
- if (disableAfter) {
70
- timesParams.ignoreAfter = moment(disableAfter, 'hh:mm A').diff(
71
- dayStart,
72
- 'minutes'
73
- );
74
- }
75
-
76
- this._times = TimeUtils.getTimes(timesParams).map(({formatted}) => {
77
- return {
78
- value: formatted,
79
- label: displayFormat
80
- ? TimeUtils.getAsMoment(formatted).format(displayFormat)
81
- : formatted,
82
- };
83
- });
84
- }
85
-
86
- componentDidUpdate(prevProps, prevState) {
87
- const {onChange} = this.props;
88
- const {selectedTime} = this.state;
89
-
90
- if (selectedTime !== prevState.selectedTime && onChange) {
91
- onChange(selectedTime);
92
- }
93
- }
94
-
95
- _onSelectChange = ({value}) => {
96
- this.setState({
97
- selectedTime: value,
98
- });
99
- };
100
-
101
- /**
102
- * Getter for the select DOM element.
103
- *
104
- * @public
105
- * @returns {Element} - The select element.
106
- */
107
- get node() {
108
- return this._select.node;
109
- }
110
-
111
- render() {
112
- const {
113
- className,
114
- label,
115
- placeholder,
116
- useIcon,
117
- iconPosition,
118
- name,
119
- disabled,
120
- ...attrs
121
- } = this.props;
122
-
123
- const spreadProps = omit(attrs, [
124
- 'onChange',
125
- 'step',
126
- 'displayFormat',
127
- 'disableBefore',
128
- 'disableAfter',
129
- 'selectedTime',
130
- ]);
131
- const {selectedTime} = this.state;
132
- const classes = classNames(
133
- 'TimePicker',
134
- {'TimePicker-with-icon': useIcon},
135
- className
136
- );
137
-
138
- return (
139
- <div className={classes}>
140
- {label}
141
- <Select
142
- ref={node => {
143
- this._select = node;
144
- }}
145
- name={name}
146
- defaultValue={selectedTime}
147
- onChange={this._onSelectChange}
148
- items={this._times}
149
- disabled={disabled}
150
- icon={useIcon ? <IconClock className="Icon-clock" /> : null}
151
- iconPosition={iconPosition}
152
- placeholder={placeholder}
153
- {...spreadProps}
154
- />
155
- </div>
156
- );
157
- }
158
- }