@instructure/ui-date-time-input 10.16.1-snapshot-0 → 10.16.1-snapshot-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.
- package/CHANGELOG.md +1 -1
- package/es/DateTimeInput/__new-tests__/DateTimeInput.test.js +88 -62
- package/es/DateTimeInput/index.js +79 -70
- package/lib/DateTimeInput/__new-tests__/DateTimeInput.test.js +152 -126
- package/lib/DateTimeInput/index.js +79 -71
- package/package.json +17 -17
- package/src/DateTimeInput/__new-tests__/DateTimeInput.test.tsx +0 -1
- package/src/DateTimeInput/index.tsx +1 -1
- package/src/DateTimeInput/props.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateTimeInput/__new-tests__/DateTimeInput.test.d.ts.map +1 -1
- package/types/DateTimeInput/index.d.ts +6 -6
- package/types/DateTimeInput/index.d.ts.map +1 -1
- package/types/DateTimeInput/props.d.ts +1 -1
- package/types/DateTimeInput/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [10.16.1-snapshot-
|
|
6
|
+
## [10.16.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.16.0...v10.16.1-snapshot-1) (2025-04-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-date-time-input
|
|
9
9
|
|
|
@@ -23,13 +23,13 @@ var _DateTimeInput, _DateTimeInput2, _DateTimeInput3;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import React from 'react';
|
|
27
26
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
28
27
|
import { vi } from 'vitest';
|
|
29
28
|
import userEvent from '@testing-library/user-event';
|
|
30
29
|
import '@testing-library/jest-dom';
|
|
31
30
|
import { DateTimeInput } from '../index';
|
|
32
31
|
import { ApplyLocale, DateTime } from '@instructure/ui-i18n';
|
|
32
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
33
33
|
describe('<DateTimeInput />', () => {
|
|
34
34
|
let consoleWarningMock;
|
|
35
35
|
let consoleErrorMock;
|
|
@@ -46,7 +46,7 @@ describe('<DateTimeInput />', () => {
|
|
|
46
46
|
const locale = 'en-US';
|
|
47
47
|
const timezone = 'US/Eastern';
|
|
48
48
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
49
|
-
render(
|
|
49
|
+
render(_jsx(DateTimeInput, {
|
|
50
50
|
description: "date_time",
|
|
51
51
|
prevMonthLabel: "Previous month",
|
|
52
52
|
nextMonthLabel: "Next month",
|
|
@@ -67,7 +67,7 @@ describe('<DateTimeInput />', () => {
|
|
|
67
67
|
const locale = 'en-US';
|
|
68
68
|
const timezone = 'US/Eastern';
|
|
69
69
|
const dateTime = DateTime.parse('2017-05-01T23:30Z', locale, timezone);
|
|
70
|
-
render(
|
|
70
|
+
render(_jsx(DateTimeInput, {
|
|
71
71
|
description: "date_time",
|
|
72
72
|
prevMonthLabel: "Previous month",
|
|
73
73
|
nextMonthLabel: "Next month",
|
|
@@ -90,7 +90,7 @@ describe('<DateTimeInput />', () => {
|
|
|
90
90
|
const value = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
91
91
|
const defaultValue = DateTime.parse('2016-04-01T17:00Z', locale, timezone);
|
|
92
92
|
const onChange = vi.fn();
|
|
93
|
-
render(
|
|
93
|
+
render(_jsx(DateTimeInput, {
|
|
94
94
|
description: "date_time",
|
|
95
95
|
prevMonthLabel: "Previous month",
|
|
96
96
|
nextMonthLabel: "Next month",
|
|
@@ -113,7 +113,7 @@ describe('<DateTimeInput />', () => {
|
|
|
113
113
|
const timezone = 'US/Eastern';
|
|
114
114
|
const dateObj = DateTime.parse('2017-04-01T18:30Z', locale, timezone);
|
|
115
115
|
const date = dateObj.toISOString().split('T')[0];
|
|
116
|
-
render(
|
|
116
|
+
render(_jsx(DateTimeInput, {
|
|
117
117
|
description: "date_time",
|
|
118
118
|
dateRenderLabel: "date-input",
|
|
119
119
|
prevMonthLabel: "Previous month",
|
|
@@ -131,7 +131,7 @@ describe('<DateTimeInput />', () => {
|
|
|
131
131
|
});
|
|
132
132
|
it('should call invalidDateTimeMessage if time is set w/o a date and is required', async () => {
|
|
133
133
|
const invalidDateTimeMessage = vi.fn(_rawd => 'whoops');
|
|
134
|
-
const _render = render(
|
|
134
|
+
const _render = render(_jsx(DateTimeInput, {
|
|
135
135
|
description: "date_time",
|
|
136
136
|
dateRenderLabel: "date-input",
|
|
137
137
|
prevMonthLabel: "Previous month",
|
|
@@ -153,7 +153,7 @@ describe('<DateTimeInput />', () => {
|
|
|
153
153
|
});
|
|
154
154
|
it('should not call invalidDateTimeMessage if time is set w/o a date', async () => {
|
|
155
155
|
const invalidDateTimeMessage = vi.fn(_rawd => 'whoops');
|
|
156
|
-
render(
|
|
156
|
+
render(_jsx(DateTimeInput, {
|
|
157
157
|
description: "date_time",
|
|
158
158
|
dateRenderLabel: "date-input",
|
|
159
159
|
prevMonthLabel: "Previous month",
|
|
@@ -176,7 +176,7 @@ describe('<DateTimeInput />', () => {
|
|
|
176
176
|
const locale = 'en-US';
|
|
177
177
|
const timezone = 'US/Eastern';
|
|
178
178
|
const defaultValue = DateTime.parse('2017-05-01T17:00', locale, timezone);
|
|
179
|
-
render(
|
|
179
|
+
render(_jsx(DateTimeInput, {
|
|
180
180
|
description: "date_time",
|
|
181
181
|
dateRenderLabel: "date-input",
|
|
182
182
|
prevMonthLabel: "Previous month",
|
|
@@ -205,7 +205,7 @@ describe('<DateTimeInput />', () => {
|
|
|
205
205
|
});
|
|
206
206
|
});
|
|
207
207
|
it('should show correct message when TimeInput value changes', () => {
|
|
208
|
-
const _render2 = render(_DateTimeInput || (_DateTimeInput =
|
|
208
|
+
const _render2 = render(_DateTimeInput || (_DateTimeInput = _jsx(DateTimeInput, {
|
|
209
209
|
description: "date_time",
|
|
210
210
|
dateRenderLabel: "date-input",
|
|
211
211
|
prevMonthLabel: "Previous month",
|
|
@@ -234,7 +234,7 @@ describe('<DateTimeInput />', () => {
|
|
|
234
234
|
const locale = 'en-US';
|
|
235
235
|
const timezone = 'US/Eastern';
|
|
236
236
|
const defaultValue = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
237
|
-
const _render3 = render(
|
|
237
|
+
const _render3 = render(_jsx(DateTimeInput, {
|
|
238
238
|
description: "date_time",
|
|
239
239
|
dateRenderLabel: "date-input",
|
|
240
240
|
prevMonthLabel: "Previous month",
|
|
@@ -252,7 +252,7 @@ describe('<DateTimeInput />', () => {
|
|
|
252
252
|
const timezone = 'US/Eastern';
|
|
253
253
|
const locale = 'fr';
|
|
254
254
|
const defaultValue = DateTime.parse('2017-05-01T17:30Z', locale, timezone);
|
|
255
|
-
const _render4 = render(
|
|
255
|
+
const _render4 = render(_jsx(DateTimeInput, {
|
|
256
256
|
description: "date_time",
|
|
257
257
|
dateRenderLabel: "date-input",
|
|
258
258
|
prevMonthLabel: "Previous month",
|
|
@@ -269,7 +269,7 @@ describe('<DateTimeInput />', () => {
|
|
|
269
269
|
it('should provide the html elements for date and time input', () => {
|
|
270
270
|
let dref;
|
|
271
271
|
let tref;
|
|
272
|
-
render(
|
|
272
|
+
render(_jsx(DateTimeInput, {
|
|
273
273
|
description: "date_time",
|
|
274
274
|
dateRenderLabel: "date-input",
|
|
275
275
|
prevMonthLabel: "Previous month",
|
|
@@ -307,13 +307,16 @@ describe('<DateTimeInput />', () => {
|
|
|
307
307
|
value: dateTime.toISOString(),
|
|
308
308
|
onChange
|
|
309
309
|
};
|
|
310
|
-
const _render5 = render(
|
|
310
|
+
const _render5 = render(_jsx(DateTimeInput, {
|
|
311
|
+
...props
|
|
312
|
+
})),
|
|
311
313
|
container = _render5.container,
|
|
312
314
|
rerender = _render5.rerender;
|
|
313
315
|
expect(container).toHaveTextContent('May 1, 2017 1:30 PM');
|
|
314
|
-
rerender(
|
|
316
|
+
rerender(_jsx(DateTimeInput, {
|
|
317
|
+
...props,
|
|
315
318
|
value: "2018-03-29T16:30Z"
|
|
316
|
-
}))
|
|
319
|
+
}));
|
|
317
320
|
expect(container).toHaveTextContent('March 29, 2018 12:30 PM');
|
|
318
321
|
});
|
|
319
322
|
it('should update message when locale changed', () => {
|
|
@@ -333,13 +336,16 @@ describe('<DateTimeInput />', () => {
|
|
|
333
336
|
onChange,
|
|
334
337
|
value: dateTime.toISOString()
|
|
335
338
|
};
|
|
336
|
-
const _render6 = render(
|
|
339
|
+
const _render6 = render(_jsx(DateTimeInput, {
|
|
340
|
+
...props
|
|
341
|
+
})),
|
|
337
342
|
container = _render6.container,
|
|
338
343
|
rerender = _render6.rerender;
|
|
339
344
|
expect(container).toHaveTextContent('May 1, 2017 1:30 PM');
|
|
340
|
-
rerender(
|
|
345
|
+
rerender(_jsx(DateTimeInput, {
|
|
346
|
+
...props,
|
|
341
347
|
locale: "fr"
|
|
342
|
-
}))
|
|
348
|
+
}));
|
|
343
349
|
expect(container).toHaveTextContent('1 mai 2017 13:30');
|
|
344
350
|
});
|
|
345
351
|
it('should update message when timezone changed', () => {
|
|
@@ -359,17 +365,20 @@ describe('<DateTimeInput />', () => {
|
|
|
359
365
|
onChange,
|
|
360
366
|
value: dateTime.toISOString()
|
|
361
367
|
};
|
|
362
|
-
const _render7 = render(
|
|
368
|
+
const _render7 = render(_jsx(DateTimeInput, {
|
|
369
|
+
...props
|
|
370
|
+
})),
|
|
363
371
|
container = _render7.container,
|
|
364
372
|
rerender = _render7.rerender;
|
|
365
373
|
expect(container).toHaveTextContent('May 1, 2017 1:30 PM');
|
|
366
|
-
rerender(
|
|
374
|
+
rerender(_jsx(DateTimeInput, {
|
|
375
|
+
...props,
|
|
367
376
|
timezone: "Europe/Paris"
|
|
368
|
-
}))
|
|
377
|
+
}));
|
|
369
378
|
expect(container).toHaveTextContent('May 1, 2017 7:30 PM');
|
|
370
379
|
});
|
|
371
380
|
it('should show error message if initial value is invalid', async () => {
|
|
372
|
-
const _render8 = render(_DateTimeInput2 || (_DateTimeInput2 =
|
|
381
|
+
const _render8 = render(_DateTimeInput2 || (_DateTimeInput2 = _jsx(DateTimeInput, {
|
|
373
382
|
description: "date_time",
|
|
374
383
|
dateRenderLabel: "date-input",
|
|
375
384
|
prevMonthLabel: "Previous month",
|
|
@@ -386,7 +395,7 @@ describe('<DateTimeInput />', () => {
|
|
|
386
395
|
});
|
|
387
396
|
});
|
|
388
397
|
it('should show error message if initial defaultValue is invalid', async () => {
|
|
389
|
-
const _render9 = render(_DateTimeInput3 || (_DateTimeInput3 =
|
|
398
|
+
const _render9 = render(_DateTimeInput3 || (_DateTimeInput3 = _jsx(DateTimeInput, {
|
|
390
399
|
description: "date_time",
|
|
391
400
|
dateRenderLabel: "date-input",
|
|
392
401
|
prevMonthLabel: "Previous month",
|
|
@@ -417,13 +426,16 @@ describe('<DateTimeInput />', () => {
|
|
|
417
426
|
timezone,
|
|
418
427
|
value: dateTime.toISOString()
|
|
419
428
|
};
|
|
420
|
-
const _render10 = render(
|
|
429
|
+
const _render10 = render(_jsx(DateTimeInput, {
|
|
430
|
+
...props
|
|
431
|
+
})),
|
|
421
432
|
container = _render10.container,
|
|
422
433
|
rerender = _render10.rerender;
|
|
423
434
|
expect(container).toHaveTextContent('May 1, 2017 1:30 PM');
|
|
424
|
-
rerender(
|
|
435
|
+
rerender(_jsx(DateTimeInput, {
|
|
436
|
+
...props,
|
|
425
437
|
value: "A very invalid date"
|
|
426
|
-
}))
|
|
438
|
+
}));
|
|
427
439
|
const dateInput = screen.getByLabelText('date-input');
|
|
428
440
|
fireEvent.blur(dateInput);
|
|
429
441
|
await waitFor(() => {
|
|
@@ -445,16 +457,19 @@ describe('<DateTimeInput />', () => {
|
|
|
445
457
|
timezone,
|
|
446
458
|
value: dateTime.toISOString()
|
|
447
459
|
};
|
|
448
|
-
const _render11 = render(
|
|
460
|
+
const _render11 = render(_jsx(DateTimeInput, {
|
|
461
|
+
...props
|
|
462
|
+
})),
|
|
449
463
|
container = _render11.container,
|
|
450
464
|
rerender = _render11.rerender;
|
|
451
465
|
expect(container).toHaveTextContent('May 1, 2017 1:30 PM');
|
|
452
|
-
rerender(
|
|
466
|
+
rerender(_jsx(DateTimeInput, {
|
|
467
|
+
...props,
|
|
453
468
|
messages: [{
|
|
454
469
|
text: 'message_text',
|
|
455
470
|
type: 'success'
|
|
456
471
|
}]
|
|
457
|
-
}))
|
|
472
|
+
}));
|
|
458
473
|
const dateInput = screen.getByLabelText('date-input');
|
|
459
474
|
fireEvent.blur(dateInput);
|
|
460
475
|
await waitFor(() => {
|
|
@@ -477,32 +492,35 @@ describe('<DateTimeInput />', () => {
|
|
|
477
492
|
timezone,
|
|
478
493
|
value: dateTime.toISOString()
|
|
479
494
|
};
|
|
480
|
-
const _render12 = render(
|
|
495
|
+
const _render12 = render(_jsx(DateTimeInput, {
|
|
496
|
+
...props,
|
|
481
497
|
showMessages: false
|
|
482
|
-
}))
|
|
498
|
+
})),
|
|
483
499
|
container = _render12.container,
|
|
484
500
|
rerender = _render12.rerender;
|
|
485
501
|
expect(container).not.toHaveTextContent('2017');
|
|
486
|
-
rerender(
|
|
502
|
+
rerender(_jsx(DateTimeInput, {
|
|
503
|
+
...props,
|
|
487
504
|
showMessages: false,
|
|
488
505
|
messages: [{
|
|
489
506
|
text: 'message_text',
|
|
490
507
|
type: 'success'
|
|
491
508
|
}]
|
|
492
|
-
}))
|
|
509
|
+
}));
|
|
493
510
|
const dateInput = screen.getByLabelText('date-input');
|
|
494
511
|
fireEvent.blur(dateInput);
|
|
495
512
|
await waitFor(() => {
|
|
496
513
|
expect(container).not.toHaveTextContent('2017');
|
|
497
514
|
expect(container).toHaveTextContent('message_text');
|
|
498
515
|
});
|
|
499
|
-
rerender(
|
|
516
|
+
rerender(_jsx(DateTimeInput, {
|
|
517
|
+
...props,
|
|
500
518
|
messages: [{
|
|
501
519
|
text: 'message_text',
|
|
502
520
|
type: 'success'
|
|
503
521
|
}],
|
|
504
522
|
showMessages: true
|
|
505
|
-
}))
|
|
523
|
+
}));
|
|
506
524
|
fireEvent.blur(screen.getByLabelText('date-input'));
|
|
507
525
|
await waitFor(() => {
|
|
508
526
|
expect(container).toHaveTextContent('2017');
|
|
@@ -513,21 +531,21 @@ describe('<DateTimeInput />', () => {
|
|
|
513
531
|
const onChange = vi.fn();
|
|
514
532
|
const dateTime = DateTime.parse('2017-05-01T17:30Z', 'en-US', 'GMT');
|
|
515
533
|
const _render13 = render(
|
|
516
|
-
/*#__PURE__*/
|
|
517
534
|
// Africa/Nairobi is GMT +3
|
|
518
|
-
|
|
535
|
+
_jsx(ApplyLocale, {
|
|
519
536
|
locale: "fr",
|
|
520
|
-
timezone: "Africa/Nairobi"
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
537
|
+
timezone: "Africa/Nairobi",
|
|
538
|
+
children: _jsx(DateTimeInput, {
|
|
539
|
+
description: "date_time",
|
|
540
|
+
dateRenderLabel: "date-input",
|
|
541
|
+
prevMonthLabel: "Previous month",
|
|
542
|
+
nextMonthLabel: "Next month",
|
|
543
|
+
timeRenderLabel: "time-input",
|
|
544
|
+
invalidDateTimeMessage: "whoops",
|
|
545
|
+
value: dateTime.toISOString(),
|
|
546
|
+
onChange: onChange
|
|
547
|
+
})
|
|
548
|
+
})),
|
|
531
549
|
container = _render13.container;
|
|
532
550
|
expect(container).toHaveTextContent('lundi 1 mai 2017 20:30');
|
|
533
551
|
});
|
|
@@ -544,15 +562,17 @@ describe('<DateTimeInput />', () => {
|
|
|
544
562
|
value: dateTime.toISOString(),
|
|
545
563
|
onChange
|
|
546
564
|
};
|
|
547
|
-
const _render14 = render(
|
|
565
|
+
const _render14 = render(_jsx(DateTimeInput, {
|
|
566
|
+
...props,
|
|
548
567
|
dateFormat: "l" // localized numeric date like 9/4/2017
|
|
549
|
-
}))
|
|
568
|
+
})),
|
|
550
569
|
rerender = _render14.rerender;
|
|
551
570
|
const dateInput = screen.getByLabelText('date-input');
|
|
552
571
|
expect(dateInput).toHaveValue('5/1/2017');
|
|
553
|
-
rerender(
|
|
572
|
+
rerender(_jsx(DateTimeInput, {
|
|
573
|
+
...props,
|
|
554
574
|
dateFormat: "yyyy MMMM"
|
|
555
|
-
}))
|
|
575
|
+
}));
|
|
556
576
|
fireEvent.blur(screen.getByLabelText('date-input'));
|
|
557
577
|
await waitFor(() => {
|
|
558
578
|
expect(dateInput).toHaveValue('2017 May');
|
|
@@ -573,13 +593,16 @@ describe('<DateTimeInput />', () => {
|
|
|
573
593
|
locale: 'en-US',
|
|
574
594
|
timezone: 'US/Eastern'
|
|
575
595
|
};
|
|
576
|
-
const _render15 = render(
|
|
596
|
+
const _render15 = render(_jsx(DateTimeInput, {
|
|
597
|
+
...props
|
|
598
|
+
})),
|
|
577
599
|
container = _render15.container,
|
|
578
600
|
rerender = _render15.rerender;
|
|
579
601
|
expect(container).toHaveTextContent('Monday, May 1, 2017 1:30 PM');
|
|
580
|
-
rerender(
|
|
602
|
+
rerender(_jsx(DateTimeInput, {
|
|
603
|
+
...props,
|
|
581
604
|
messageFormat: "l, LT"
|
|
582
|
-
}))
|
|
605
|
+
}));
|
|
583
606
|
fireEvent.blur(screen.getByLabelText('date-input'));
|
|
584
607
|
await waitFor(() => {
|
|
585
608
|
expect(container).toHaveTextContent('5/1/2017, 1:30 PM');
|
|
@@ -600,15 +623,18 @@ describe('<DateTimeInput />', () => {
|
|
|
600
623
|
timezone,
|
|
601
624
|
value: dateTime.toISOString()
|
|
602
625
|
};
|
|
603
|
-
const _render16 = render(
|
|
626
|
+
const _render16 = render(_jsx(DateTimeInput, {
|
|
627
|
+
...props
|
|
628
|
+
})),
|
|
604
629
|
container = _render16.container,
|
|
605
630
|
rerender = _render16.rerender;
|
|
606
631
|
expect(container).toHaveTextContent('May 1, 2017 1:30 PM');
|
|
607
632
|
const newDateStr = '2022-03-29T19:00Z';
|
|
608
633
|
const newDateTime = DateTime.parse(newDateStr, locale, timezone);
|
|
609
|
-
rerender(
|
|
634
|
+
rerender(_jsx(DateTimeInput, {
|
|
635
|
+
...props,
|
|
610
636
|
value: newDateStr
|
|
611
|
-
}))
|
|
637
|
+
}));
|
|
612
638
|
const dateInput = screen.getByLabelText('date-input');
|
|
613
639
|
const timeInput = screen.getByLabelText('time-input');
|
|
614
640
|
fireEvent.blur(dateInput);
|
|
@@ -619,7 +645,7 @@ describe('<DateTimeInput />', () => {
|
|
|
619
645
|
});
|
|
620
646
|
it("should throw warning if initialTimeForNewDate prop's value is not HH:MM", async () => {
|
|
621
647
|
const initialTimeForNewDate = 'WRONG_FORMAT';
|
|
622
|
-
render(
|
|
648
|
+
render(_jsx(DateTimeInput, {
|
|
623
649
|
description: "date_time",
|
|
624
650
|
dateRenderLabel: "date-input",
|
|
625
651
|
prevMonthLabel: "Previous month",
|
|
@@ -634,7 +660,7 @@ describe('<DateTimeInput />', () => {
|
|
|
634
660
|
});
|
|
635
661
|
it("should throw warning if date select and initialTimeForNewDate prop's value is not HH:MM", async () => {
|
|
636
662
|
const initialTimeForNewDate = 'WRONG_FORMAT';
|
|
637
|
-
render(
|
|
663
|
+
render(_jsx(DateTimeInput, {
|
|
638
664
|
description: "date_time",
|
|
639
665
|
dateRenderLabel: "date-input",
|
|
640
666
|
prevMonthLabel: "Previous month",
|
|
@@ -662,7 +688,7 @@ describe('<DateTimeInput />', () => {
|
|
|
662
688
|
});
|
|
663
689
|
it('should throw warning if initialTimeForNewDate prop hour and minute values are not in interval', async () => {
|
|
664
690
|
const initialTimeForNewDate = '99:99';
|
|
665
|
-
render(
|
|
691
|
+
render(_jsx(DateTimeInput, {
|
|
666
692
|
description: "date_time",
|
|
667
693
|
dateRenderLabel: "date-input",
|
|
668
694
|
prevMonthLabel: "Previous month",
|
|
@@ -693,7 +719,7 @@ describe('<DateTimeInput />', () => {
|
|
|
693
719
|
const timezone = 'US/Eastern';
|
|
694
720
|
const initialTimeForNewDate = '16:16';
|
|
695
721
|
const defaultValue = '2018-01-18T13:30';
|
|
696
|
-
const _render17 = render(
|
|
722
|
+
const _render17 = render(_jsx(DateTimeInput, {
|
|
697
723
|
description: "date_time",
|
|
698
724
|
dateRenderLabel: "date-input",
|
|
699
725
|
prevMonthLabel: "Previous month",
|
|
@@ -23,7 +23,7 @@ var _dec, _class, _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
|
23
23
|
* SOFTWARE.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import
|
|
26
|
+
import { Component } from 'react';
|
|
27
27
|
import { Locale, DateTime, ApplyLocaleContext } from '@instructure/ui-i18n';
|
|
28
28
|
import { FormFieldGroup } from '@instructure/ui-form-field';
|
|
29
29
|
import { DateInput } from '@instructure/ui-date-input';
|
|
@@ -41,6 +41,7 @@ import { error } from '@instructure/console';
|
|
|
41
41
|
category: components
|
|
42
42
|
---
|
|
43
43
|
**/
|
|
44
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
44
45
|
let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class DateTimeInput extends Component {
|
|
45
46
|
constructor(props) {
|
|
46
47
|
super(props);
|
|
@@ -374,8 +375,7 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class Da
|
|
|
374
375
|
}
|
|
375
376
|
return arr.map(date => {
|
|
376
377
|
const dateStr = date.toISOString();
|
|
377
|
-
return
|
|
378
|
-
key: dateStr,
|
|
378
|
+
return _jsx(DateInput.Day, {
|
|
379
379
|
date: dateStr,
|
|
380
380
|
isSelected: this.state.calendarSelectedDate ? date.isSame(this.state.calendarSelectedDate, 'day') : false,
|
|
381
381
|
isToday: date.isSame(DateTime.now(this.locale(), this.timezone()), 'day'),
|
|
@@ -383,8 +383,9 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class Da
|
|
|
383
383
|
label: date.format('D MMMM YYYY') // used by screen readers
|
|
384
384
|
,
|
|
385
385
|
onClick: this.handleDayClick,
|
|
386
|
-
interaction: this.isDisabledDate(date) ? 'disabled' : 'enabled'
|
|
387
|
-
|
|
386
|
+
interaction: this.isDisabledDate(date) ? 'disabled' : 'enabled',
|
|
387
|
+
children: date.format('DD')
|
|
388
|
+
}, dateStr);
|
|
388
389
|
});
|
|
389
390
|
}
|
|
390
391
|
|
|
@@ -396,40 +397,40 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class Da
|
|
|
396
397
|
}
|
|
397
398
|
const shortDayNames = DateTime.getLocalDayNamesOfTheWeek(this.locale(), 'short');
|
|
398
399
|
const longDayNames = DateTime.getLocalDayNamesOfTheWeek(this.locale(), 'long');
|
|
399
|
-
return [
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
},
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
},
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
},
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
},
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
},
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
},
|
|
400
|
+
return [_jsx(AccessibleContent, {
|
|
401
|
+
alt: longDayNames[0],
|
|
402
|
+
children: shortDayNames[0]
|
|
403
|
+
}, 1), _jsx(AccessibleContent, {
|
|
404
|
+
alt: longDayNames[1],
|
|
405
|
+
children: shortDayNames[1]
|
|
406
|
+
}, 2), _jsx(AccessibleContent, {
|
|
407
|
+
alt: longDayNames[2],
|
|
408
|
+
children: shortDayNames[2]
|
|
409
|
+
}, 3), _jsx(AccessibleContent, {
|
|
410
|
+
alt: longDayNames[3],
|
|
411
|
+
children: shortDayNames[3]
|
|
412
|
+
}, 4), _jsx(AccessibleContent, {
|
|
413
|
+
alt: longDayNames[4],
|
|
414
|
+
children: shortDayNames[4]
|
|
415
|
+
}, 5), _jsx(AccessibleContent, {
|
|
416
|
+
alt: longDayNames[5],
|
|
417
|
+
children: shortDayNames[5]
|
|
418
|
+
}, 6), _jsx(AccessibleContent, {
|
|
419
|
+
alt: longDayNames[6],
|
|
420
|
+
children: shortDayNames[6]
|
|
421
|
+
}, 7)];
|
|
421
422
|
}
|
|
422
423
|
renderNextPrevMonthButton(type) {
|
|
423
424
|
if (!this.state.isShowingCalendar) {
|
|
424
425
|
return;
|
|
425
426
|
}
|
|
426
|
-
return
|
|
427
|
+
return _jsx(IconButton, {
|
|
427
428
|
size: "small",
|
|
428
429
|
withBackground: false,
|
|
429
430
|
withBorder: false,
|
|
430
|
-
renderIcon: type === 'prev' ? _IconArrowOpenStartSo || (_IconArrowOpenStartSo =
|
|
431
|
+
renderIcon: type === 'prev' ? _IconArrowOpenStartSo || (_IconArrowOpenStartSo = _jsx(IconArrowOpenStartSolid, {
|
|
431
432
|
color: "primary"
|
|
432
|
-
})) : _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli =
|
|
433
|
+
})) : _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = _jsx(IconArrowOpenEndSolid, {
|
|
433
434
|
color: "primary"
|
|
434
435
|
})),
|
|
435
436
|
screenReaderLabel: type === 'prev' ? this.props.prevMonthLabel : this.props.nextMonthLabel
|
|
@@ -464,7 +465,7 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class Da
|
|
|
464
465
|
type: 'newError',
|
|
465
466
|
text: ''
|
|
466
467
|
}] : [];
|
|
467
|
-
return
|
|
468
|
+
return _jsxs(FormFieldGroup, {
|
|
468
469
|
description: description,
|
|
469
470
|
layout: layout,
|
|
470
471
|
rowSpacing: rowSpacing,
|
|
@@ -472,45 +473,53 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_DateTimeInput = class Da
|
|
|
472
473
|
vAlign: "top",
|
|
473
474
|
elementRef: this.handleRef,
|
|
474
475
|
isGroup: false,
|
|
475
|
-
messages: [...(showMessages && this.state.message ? [this.state.message] : []), ...(messages || [])]
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
476
|
+
messages: [...(showMessages && this.state.message ? [this.state.message] : []), ...(messages || [])],
|
|
477
|
+
children: [_jsx(DateInput, {
|
|
478
|
+
display: "block",
|
|
479
|
+
value: this.state.dateInputText,
|
|
480
|
+
onChange: this.handleDateTextChange,
|
|
481
|
+
onBlur: this.handleBlur,
|
|
482
|
+
inputRef: dateInputRef,
|
|
483
|
+
placeholder: datePlaceholder,
|
|
484
|
+
renderLabel: dateRenderLabel,
|
|
485
|
+
renderWeekdayLabels: renderWeekdayLabels ? renderWeekdayLabels : this.defaultWeekdays,
|
|
486
|
+
onRequestShowCalendar: this.handleShowCalendar,
|
|
487
|
+
onRequestHideCalendar: this.handleHideCalendar,
|
|
488
|
+
isShowingCalendar: this.state.isShowingCalendar,
|
|
489
|
+
renderNextMonthButton: this.renderNextPrevMonthButton('next'),
|
|
490
|
+
renderPrevMonthButton: this.renderNextPrevMonthButton('prev'),
|
|
491
|
+
onRequestSelectNextDay: this.handleSelectNextDay,
|
|
492
|
+
onRequestSelectPrevDay: this.handleSelectPrevDay,
|
|
493
|
+
onRequestRenderNextMonth: this.handleRenderNextMonth,
|
|
494
|
+
onRequestRenderPrevMonth: this.handleRenderPrevMonth,
|
|
495
|
+
isRequired: isRequired,
|
|
496
|
+
messages: subComponentMessages,
|
|
497
|
+
interaction: interaction,
|
|
498
|
+
renderNavigationLabel: _jsxs("span", {
|
|
499
|
+
children: [_jsx("div", {
|
|
500
|
+
children: this.state.renderedDate.format('MMMM')
|
|
501
|
+
}), _jsx("div", {
|
|
502
|
+
children: this.state.renderedDate.format('y')
|
|
503
|
+
})]
|
|
504
|
+
}),
|
|
505
|
+
children: this.renderDays()
|
|
506
|
+
}), _jsx(TimeSelect, {
|
|
507
|
+
value: this.state.timeSelectValue,
|
|
508
|
+
onChange: this.updateStateBasedOnTimeSelect,
|
|
509
|
+
placeholder: timePlaceholder,
|
|
510
|
+
onBlur: this.handleBlur,
|
|
511
|
+
renderLabel: timeRenderLabel,
|
|
512
|
+
locale: locale,
|
|
513
|
+
format: timeFormat,
|
|
514
|
+
step: timeStep,
|
|
515
|
+
timezone: timezone,
|
|
516
|
+
inputRef: timeInputRef,
|
|
517
|
+
interaction: interaction,
|
|
518
|
+
allowNonStepInput: allowNonStepInput,
|
|
519
|
+
isRequired: isRequired,
|
|
520
|
+
messages: subComponentMessages
|
|
521
|
+
})]
|
|
522
|
+
});
|
|
514
523
|
}
|
|
515
524
|
}, _DateTimeInput.displayName = "DateTimeInput", _DateTimeInput.DEFAULT_MESSAGE_FORMAT = 'LLLL', _DateTimeInput.propTypes = propTypes, _DateTimeInput.allowedProps = allowedProps, _DateTimeInput.defaultProps = {
|
|
516
525
|
layout: 'inline',
|