@react-aria/datepicker 3.0.0-nightly.3142 → 3.0.0-nightly.3167
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/dist/main.js +248 -135
- package/dist/main.js.map +1 -1
- package/dist/module.js +243 -132
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +66 -27
- package/dist/types.d.ts.map +1 -1
- package/package.json +16 -15
- package/src/index.ts +4 -4
- package/src/useDateField.ts +43 -8
- package/src/useDatePicker.ts +48 -9
- package/src/useDatePickerGroup.ts +31 -8
- package/src/useDateRangePicker.ts +63 -13
- package/src/useDateSegment.ts +44 -31
package/dist/module.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {createFocusManager as $cIPI0$createFocusManager,
|
|
1
|
+
import {createFocusManager as $cIPI0$createFocusManager, getFocusableTreeWalker as $cIPI0$getFocusableTreeWalker} from "@react-aria/focus";
|
|
2
2
|
import {useId as $cIPI0$useId, useDescription as $cIPI0$useDescription, mergeProps as $cIPI0$mergeProps, isMac as $cIPI0$isMac, scrollIntoView as $cIPI0$scrollIntoView, getScrollParent as $cIPI0$getScrollParent, useEvent as $cIPI0$useEvent, isIOS as $cIPI0$isIOS, useLabels as $cIPI0$useLabels} from "@react-aria/utils";
|
|
3
3
|
import {useField as $cIPI0$useField} from "@react-aria/label";
|
|
4
4
|
import {useMessageFormatter as $cIPI0$useMessageFormatter, useLocale as $cIPI0$useLocale, useDateFormatter as $cIPI0$useDateFormatter, useFilter as $cIPI0$useFilter} from "@react-aria/i18n";
|
|
5
5
|
import {usePress as $cIPI0$usePress, useFocusWithin as $cIPI0$useFocusWithin} from "@react-aria/interactions";
|
|
6
6
|
import {NumberParser as $cIPI0$NumberParser} from "@internationalized/number";
|
|
7
|
-
import $cIPI0$react, {useRef as $cIPI0$useRef, useMemo as $cIPI0$useMemo} from "react";
|
|
7
|
+
import $cIPI0$react, {useRef as $cIPI0$useRef, useMemo as $cIPI0$useMemo, useEffect as $cIPI0$useEffect} from "react";
|
|
8
8
|
import {useSpinButton as $cIPI0$useSpinButton} from "@react-aria/spinbutton";
|
|
9
9
|
import {MessageDictionary as $cIPI0$MessageDictionary} from "@internationalized/message";
|
|
10
10
|
|
|
@@ -14,9 +14,6 @@ function $parcel$interopDefault(a) {
|
|
|
14
14
|
function $parcel$export(e, n, v, s) {
|
|
15
15
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
16
16
|
}
|
|
17
|
-
var $6057a3d2a53a12fd$exports = {};
|
|
18
|
-
|
|
19
|
-
$parcel$export($6057a3d2a53a12fd$exports, "useDatePicker", () => $6057a3d2a53a12fd$export$42df105a73306d51);
|
|
20
17
|
|
|
21
18
|
var $204383cf4f6b0d06$exports = {};
|
|
22
19
|
var $f23889fffbde9058$exports = {};
|
|
@@ -196,7 +193,8 @@ $204383cf4f6b0d06$exports = {
|
|
|
196
193
|
|
|
197
194
|
|
|
198
195
|
|
|
199
|
-
|
|
196
|
+
|
|
197
|
+
function $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref1) {
|
|
200
198
|
// Open the popover on alt + arrow down
|
|
201
199
|
let onKeyDown = (e)=>{
|
|
202
200
|
if (e.altKey && e.key === 'ArrowDown' && 'setOpen' in state) {
|
|
@@ -207,12 +205,31 @@ function $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref) {
|
|
|
207
205
|
};
|
|
208
206
|
// Focus the first placeholder segment from the end on mouse down/touch up in the field.
|
|
209
207
|
let focusLast = ()=>{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
208
|
+
var ref;
|
|
209
|
+
// Try to find the segment prior to the element that was clicked on.
|
|
210
|
+
let target = (ref = window.event) === null || ref === void 0 ? void 0 : ref.target;
|
|
211
|
+
let walker = $cIPI0$getFocusableTreeWalker(ref1.current, {
|
|
212
|
+
tabbable: true
|
|
213
|
+
});
|
|
214
|
+
if (target) {
|
|
215
|
+
walker.currentNode = target;
|
|
216
|
+
target = walker.previousNode();
|
|
217
|
+
}
|
|
218
|
+
// If no target found, find the last element from the end.
|
|
219
|
+
if (!target) {
|
|
220
|
+
let last;
|
|
221
|
+
do {
|
|
222
|
+
last = walker.lastChild();
|
|
223
|
+
if (last) target = last;
|
|
224
|
+
}while (last)
|
|
225
|
+
}
|
|
226
|
+
// Now go backwards until we find an element that is not a placeholder.
|
|
227
|
+
while(target === null || target === void 0 ? void 0 : target.getAttribute('aria-placeholder')){
|
|
228
|
+
let prev = walker.previousNode();
|
|
229
|
+
if (prev && prev.getAttribute('aria-placeholder')) target = prev;
|
|
230
|
+
else break;
|
|
231
|
+
}
|
|
232
|
+
if (target) target.focus();
|
|
216
233
|
};
|
|
217
234
|
let { pressProps: pressProps } = $cIPI0$usePress({
|
|
218
235
|
onPressStart (e) {
|
|
@@ -262,7 +279,22 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
262
279
|
focusManager.focusFirst();
|
|
263
280
|
}
|
|
264
281
|
},
|
|
265
|
-
fieldProps:
|
|
282
|
+
fieldProps: {
|
|
283
|
+
...fieldProps,
|
|
284
|
+
value: state.value,
|
|
285
|
+
onChange: state.setValue,
|
|
286
|
+
minValue: props.minValue,
|
|
287
|
+
maxValue: props.maxValue,
|
|
288
|
+
placeholderValue: props.placeholderValue,
|
|
289
|
+
hideTimeZone: props.hideTimeZone,
|
|
290
|
+
hourCycle: props.hourCycle,
|
|
291
|
+
granularity: props.granularity,
|
|
292
|
+
isDisabled: props.isDisabled,
|
|
293
|
+
isReadOnly: props.isReadOnly,
|
|
294
|
+
isRequired: props.isRequired,
|
|
295
|
+
validationState: state.validationState,
|
|
296
|
+
autoFocus: props.autoFocus
|
|
297
|
+
},
|
|
266
298
|
descriptionProps: descriptionProps,
|
|
267
299
|
errorMessageProps: errorMessageProps,
|
|
268
300
|
buttonProps: {
|
|
@@ -272,31 +304,155 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
272
304
|
'aria-haspopup': 'dialog',
|
|
273
305
|
'aria-label': formatMessage('calendar'),
|
|
274
306
|
'aria-labelledby': `${labelledBy} ${buttonId}`,
|
|
275
|
-
'aria-describedby': ariaDescribedBy
|
|
307
|
+
'aria-describedby': ariaDescribedBy,
|
|
308
|
+
onPress: ()=>state.setOpen(true)
|
|
276
309
|
},
|
|
277
310
|
dialogProps: {
|
|
278
311
|
id: dialogId,
|
|
279
312
|
'aria-labelledby': `${labelledBy} ${buttonId}`
|
|
313
|
+
},
|
|
314
|
+
calendarProps: {
|
|
315
|
+
autoFocus: true,
|
|
316
|
+
value: state.dateValue,
|
|
317
|
+
onChange: state.setDateValue,
|
|
318
|
+
minValue: props.minValue,
|
|
319
|
+
maxValue: props.maxValue,
|
|
320
|
+
isDisabled: props.isDisabled,
|
|
321
|
+
isReadOnly: props.isReadOnly,
|
|
322
|
+
isDateDisabled: props.isDateDisabled,
|
|
323
|
+
defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue
|
|
280
324
|
}
|
|
281
325
|
};
|
|
282
326
|
}
|
|
283
327
|
|
|
284
328
|
|
|
285
|
-
var $32489daedd52963e$exports = {};
|
|
286
329
|
|
|
287
|
-
$parcel$export($32489daedd52963e$exports, "useDateSegment", () => $32489daedd52963e$export$1315d136e6f7581);
|
|
288
330
|
|
|
289
|
-
var $16f0b7bb276bc17e$exports = {};
|
|
290
331
|
|
|
291
|
-
$parcel$export($16f0b7bb276bc17e$exports, "labelIds", () => $16f0b7bb276bc17e$export$beb2340c1222c6d);
|
|
292
|
-
$parcel$export($16f0b7bb276bc17e$exports, "useDateField", () => $16f0b7bb276bc17e$export$5591b0b878c1a989);
|
|
293
332
|
|
|
294
333
|
|
|
295
334
|
|
|
296
335
|
|
|
297
336
|
|
|
298
337
|
|
|
299
|
-
|
|
338
|
+
|
|
339
|
+
const $887cac91b7cc8801$export$7b3062cd49e80452 = '__focusManager_' + Date.now();
|
|
340
|
+
function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
341
|
+
var ref1, ref2;
|
|
342
|
+
let formatMessage = $cIPI0$useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($204383cf4f6b0d06$exports)));
|
|
343
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $cIPI0$useField({
|
|
344
|
+
...props,
|
|
345
|
+
labelElementType: 'span'
|
|
346
|
+
});
|
|
347
|
+
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
348
|
+
let { locale: locale } = $cIPI0$useLocale();
|
|
349
|
+
let description = state.formatValue(locale, {
|
|
350
|
+
month: 'long'
|
|
351
|
+
});
|
|
352
|
+
let descProps = $cIPI0$useDescription(description);
|
|
353
|
+
let startFieldProps = $cIPI0$useLabels({
|
|
354
|
+
'aria-label': formatMessage('startDate'),
|
|
355
|
+
'aria-labelledby': labelledBy
|
|
356
|
+
});
|
|
357
|
+
let endFieldProps = $cIPI0$useLabels({
|
|
358
|
+
'aria-label': formatMessage('endDate'),
|
|
359
|
+
'aria-labelledby': labelledBy
|
|
360
|
+
});
|
|
361
|
+
let buttonId = $cIPI0$useId();
|
|
362
|
+
let dialogId = $cIPI0$useId();
|
|
363
|
+
let groupProps = $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref);
|
|
364
|
+
let { focusWithinProps: focusWithinProps } = $cIPI0$useFocusWithin({
|
|
365
|
+
onBlurWithin () {
|
|
366
|
+
state.confirmPlaceholder();
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
let ariaDescribedBy = [
|
|
370
|
+
descProps['aria-describedby'],
|
|
371
|
+
fieldProps['aria-describedby']
|
|
372
|
+
].filter(Boolean).join(' ') || undefined;
|
|
373
|
+
let focusManager = $cIPI0$useMemo(()=>$cIPI0$createFocusManager(ref)
|
|
374
|
+
, [
|
|
375
|
+
ref
|
|
376
|
+
]);
|
|
377
|
+
let commonFieldProps = {
|
|
378
|
+
[$887cac91b7cc8801$export$7b3062cd49e80452]: focusManager,
|
|
379
|
+
minValue: props.minValue,
|
|
380
|
+
maxValue: props.maxValue,
|
|
381
|
+
placeholderValue: props.placeholderValue,
|
|
382
|
+
hideTimeZone: props.hideTimeZone,
|
|
383
|
+
hourCycle: props.hourCycle,
|
|
384
|
+
granularity: props.granularity,
|
|
385
|
+
isDisabled: props.isDisabled,
|
|
386
|
+
isReadOnly: props.isReadOnly,
|
|
387
|
+
isRequired: props.isRequired,
|
|
388
|
+
validationState: state.validationState
|
|
389
|
+
};
|
|
390
|
+
return {
|
|
391
|
+
groupProps: $cIPI0$mergeProps(groupProps, fieldProps, descProps, focusWithinProps, {
|
|
392
|
+
role: 'group',
|
|
393
|
+
'aria-disabled': props.isDisabled || null,
|
|
394
|
+
'aria-describedby': ariaDescribedBy
|
|
395
|
+
}),
|
|
396
|
+
labelProps: {
|
|
397
|
+
...labelProps,
|
|
398
|
+
onClick: ()=>{
|
|
399
|
+
focusManager.focusFirst();
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
buttonProps: {
|
|
403
|
+
...descProps,
|
|
404
|
+
id: buttonId,
|
|
405
|
+
excludeFromTabOrder: true,
|
|
406
|
+
'aria-haspopup': 'dialog',
|
|
407
|
+
'aria-label': formatMessage('calendar'),
|
|
408
|
+
'aria-labelledby': `${labelledBy} ${buttonId}`,
|
|
409
|
+
'aria-describedby': ariaDescribedBy,
|
|
410
|
+
onPress: ()=>state.setOpen(true)
|
|
411
|
+
},
|
|
412
|
+
dialogProps: {
|
|
413
|
+
id: dialogId,
|
|
414
|
+
'aria-labelledby': `${labelledBy} ${buttonId}`
|
|
415
|
+
},
|
|
416
|
+
startFieldProps: {
|
|
417
|
+
...startFieldProps,
|
|
418
|
+
...commonFieldProps,
|
|
419
|
+
'aria-describedby': fieldProps['aria-describedby'],
|
|
420
|
+
value: (ref1 = state.value) === null || ref1 === void 0 ? void 0 : ref1.start,
|
|
421
|
+
onChange: (start)=>state.setDateTime('start', start)
|
|
422
|
+
,
|
|
423
|
+
autoFocus: props.autoFocus
|
|
424
|
+
},
|
|
425
|
+
endFieldProps: {
|
|
426
|
+
...endFieldProps,
|
|
427
|
+
...commonFieldProps,
|
|
428
|
+
'aria-describedby': fieldProps['aria-describedby'],
|
|
429
|
+
value: (ref2 = state.value) === null || ref2 === void 0 ? void 0 : ref2.end,
|
|
430
|
+
onChange: (end)=>state.setDateTime('end', end)
|
|
431
|
+
},
|
|
432
|
+
descriptionProps: descriptionProps,
|
|
433
|
+
errorMessageProps: errorMessageProps,
|
|
434
|
+
calendarProps: {
|
|
435
|
+
autoFocus: true,
|
|
436
|
+
value: state.dateRange,
|
|
437
|
+
onChange: state.setDateRange,
|
|
438
|
+
minValue: props.minValue,
|
|
439
|
+
maxValue: props.maxValue,
|
|
440
|
+
isDisabled: props.isDisabled,
|
|
441
|
+
isReadOnly: props.isReadOnly,
|
|
442
|
+
isDateDisabled: props.isDateDisabled,
|
|
443
|
+
defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
const $16f0b7bb276bc17e$export$653eddfc964b0f8a = new WeakMap();
|
|
300
456
|
function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
301
457
|
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $cIPI0$useField({
|
|
302
458
|
...props,
|
|
@@ -317,15 +473,28 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
317
473
|
descProps['aria-describedby'],
|
|
318
474
|
fieldProps['aria-describedby']
|
|
319
475
|
].filter(Boolean).join(' ') || undefined;
|
|
320
|
-
$
|
|
476
|
+
let propsFocusManager = props[$887cac91b7cc8801$export$7b3062cd49e80452];
|
|
477
|
+
let focusManager = $cIPI0$useMemo(()=>propsFocusManager || $cIPI0$createFocusManager(ref)
|
|
478
|
+
, [
|
|
479
|
+
propsFocusManager,
|
|
480
|
+
ref
|
|
481
|
+
]);
|
|
482
|
+
$16f0b7bb276bc17e$export$653eddfc964b0f8a.set(state, {
|
|
321
483
|
ariaLabelledBy: segmentLabelledBy,
|
|
322
|
-
ariaDescribedBy: describedBy
|
|
484
|
+
ariaDescribedBy: describedBy,
|
|
485
|
+
focusManager: focusManager
|
|
323
486
|
});
|
|
487
|
+
let autoFocusRef = $cIPI0$useRef(props.autoFocus);
|
|
488
|
+
$cIPI0$useEffect(()=>{
|
|
489
|
+
if (autoFocusRef.current) focusManager.focusFirst();
|
|
490
|
+
autoFocusRef.current = false;
|
|
491
|
+
}, [
|
|
492
|
+
focusManager
|
|
493
|
+
]);
|
|
324
494
|
return {
|
|
325
495
|
labelProps: {
|
|
326
496
|
...labelProps,
|
|
327
497
|
onClick: ()=>{
|
|
328
|
-
let focusManager = $cIPI0$createFocusManager(ref);
|
|
329
498
|
focusManager.focusFirst();
|
|
330
499
|
}
|
|
331
500
|
},
|
|
@@ -338,6 +507,9 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
338
507
|
errorMessageProps: errorMessageProps
|
|
339
508
|
};
|
|
340
509
|
}
|
|
510
|
+
function $16f0b7bb276bc17e$export$4c842f6a241dc825(props, state, ref) {
|
|
511
|
+
return $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref);
|
|
512
|
+
}
|
|
341
513
|
|
|
342
514
|
|
|
343
515
|
|
|
@@ -380,12 +552,11 @@ class $3aeceb3a64eb8358$var$DisplayNamesPolyfill {
|
|
|
380
552
|
|
|
381
553
|
|
|
382
554
|
|
|
383
|
-
|
|
384
|
-
function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
555
|
+
function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
|
|
385
556
|
let enteredKeys = $cIPI0$useRef('');
|
|
386
557
|
let { locale: locale , direction: direction } = $cIPI0$useLocale();
|
|
387
558
|
let displayNames = $3aeceb3a64eb8358$export$d42c60378c8168f8();
|
|
388
|
-
let focusManager = $
|
|
559
|
+
let { ariaLabelledBy: ariaLabelledBy , ariaDescribedBy: ariaDescribedBy , focusManager: focusManager } = $16f0b7bb276bc17e$export$653eddfc964b0f8a.get(state);
|
|
389
560
|
let textValue = segment.text;
|
|
390
561
|
let options = $cIPI0$useMemo(()=>state.dateFormatter.resolvedOptions()
|
|
391
562
|
, [
|
|
@@ -409,9 +580,9 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
409
580
|
textValue: textValue,
|
|
410
581
|
minValue: segment.minValue,
|
|
411
582
|
maxValue: segment.maxValue,
|
|
412
|
-
isDisabled:
|
|
413
|
-
isReadOnly:
|
|
414
|
-
isRequired:
|
|
583
|
+
isDisabled: state.isDisabled,
|
|
584
|
+
isReadOnly: state.isReadOnly || !segment.isEditable,
|
|
585
|
+
isRequired: state.isRequired,
|
|
415
586
|
onIncrement: ()=>{
|
|
416
587
|
enteredKeys.current = '';
|
|
417
588
|
state.increment(segment.type);
|
|
@@ -444,7 +615,7 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
444
615
|
locale
|
|
445
616
|
]);
|
|
446
617
|
let backspace = ()=>{
|
|
447
|
-
if (parser.isValidPartialNumber(segment.text) && !
|
|
618
|
+
if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly && !segment.isPlaceholder) {
|
|
448
619
|
let newValue = segment.text.slice(0, -1);
|
|
449
620
|
let parsed = parser.parse(newValue);
|
|
450
621
|
if (newValue.length === 0 || parsed === 0) state.clearSegment(segment.type);
|
|
@@ -461,20 +632,30 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
461
632
|
case 'ArrowLeft':
|
|
462
633
|
e.preventDefault();
|
|
463
634
|
e.stopPropagation();
|
|
464
|
-
if (direction === 'rtl') focusManager.focusNext(
|
|
465
|
-
|
|
635
|
+
if (direction === 'rtl') focusManager.focusNext({
|
|
636
|
+
tabbable: true
|
|
637
|
+
});
|
|
638
|
+
else focusManager.focusPrevious({
|
|
639
|
+
tabbable: true
|
|
640
|
+
});
|
|
466
641
|
break;
|
|
467
642
|
case 'ArrowRight':
|
|
468
643
|
e.preventDefault();
|
|
469
644
|
e.stopPropagation();
|
|
470
|
-
if (direction === 'rtl') focusManager.focusPrevious(
|
|
471
|
-
|
|
645
|
+
if (direction === 'rtl') focusManager.focusPrevious({
|
|
646
|
+
tabbable: true
|
|
647
|
+
});
|
|
648
|
+
else focusManager.focusNext({
|
|
649
|
+
tabbable: true
|
|
650
|
+
});
|
|
472
651
|
break;
|
|
473
652
|
case 'Enter':
|
|
474
653
|
e.preventDefault();
|
|
475
654
|
e.stopPropagation();
|
|
476
|
-
if (segment.isPlaceholder && !
|
|
477
|
-
focusManager.focusNext(
|
|
655
|
+
if (segment.isPlaceholder && !state.isReadOnly) state.confirmPlaceholder(segment.type);
|
|
656
|
+
focusManager.focusNext({
|
|
657
|
+
tabbable: true
|
|
658
|
+
});
|
|
478
659
|
break;
|
|
479
660
|
case 'Tab':
|
|
480
661
|
break;
|
|
@@ -512,14 +693,16 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
512
693
|
amPmFormatter
|
|
513
694
|
]);
|
|
514
695
|
let onInput = (key)=>{
|
|
515
|
-
if (
|
|
696
|
+
if (state.isDisabled || state.isReadOnly) return;
|
|
516
697
|
let newValue = enteredKeys.current + key;
|
|
517
698
|
switch(segment.type){
|
|
518
699
|
case 'dayPeriod':
|
|
519
700
|
if (startsWith(am, key)) state.setSegment('dayPeriod', 0);
|
|
520
701
|
else if (startsWith(pm, key)) state.setSegment('dayPeriod', 12);
|
|
521
702
|
else break;
|
|
522
|
-
focusManager.focusNext(
|
|
703
|
+
focusManager.focusNext({
|
|
704
|
+
tabbable: true
|
|
705
|
+
});
|
|
523
706
|
break;
|
|
524
707
|
case 'day':
|
|
525
708
|
case 'hour':
|
|
@@ -549,7 +732,9 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
549
732
|
if (shouldSetValue) state.setSegment(segment.type, segmentValue);
|
|
550
733
|
if (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length) {
|
|
551
734
|
enteredKeys.current = '';
|
|
552
|
-
if (shouldSetValue) focusManager.focusNext(
|
|
735
|
+
if (shouldSetValue) focusManager.focusNext({
|
|
736
|
+
tabbable: true
|
|
737
|
+
});
|
|
553
738
|
} else enteredKeys.current = newValue;
|
|
554
739
|
break;
|
|
555
740
|
}
|
|
@@ -572,7 +757,7 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
572
757
|
switch(e.inputType){
|
|
573
758
|
case 'deleteContentBackward':
|
|
574
759
|
case 'deleteContentForward':
|
|
575
|
-
if (parser.isValidPartialNumber(segment.text) && !
|
|
760
|
+
if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly) backspace();
|
|
576
761
|
break;
|
|
577
762
|
case 'insertCompositionText':
|
|
578
763
|
// insertCompositionText cannot be canceled.
|
|
@@ -623,7 +808,6 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
623
808
|
'aria-valuenow': null
|
|
624
809
|
} : {
|
|
625
810
|
};
|
|
626
|
-
let { ariaLabelledBy: ariaLabelledBy , ariaDescribedBy: ariaDescribedBy } = $16f0b7bb276bc17e$export$beb2340c1222c6d.get(state);
|
|
627
811
|
// Only apply aria-describedby to the first segment, unless the field is invalid. This avoids it being
|
|
628
812
|
// read every time the user navigates to a new segment.
|
|
629
813
|
let firstSegment = $cIPI0$useMemo(()=>state.segments.find((s)=>s.isEditable
|
|
@@ -632,20 +816,25 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
632
816
|
state.segments
|
|
633
817
|
]);
|
|
634
818
|
if (segment !== firstSegment && state.validationState !== 'invalid') ariaDescribedBy = undefined;
|
|
635
|
-
let id = $cIPI0$useId(
|
|
636
|
-
let isEditable = !
|
|
819
|
+
let id = $cIPI0$useId();
|
|
820
|
+
let isEditable = !state.isDisabled && !state.isReadOnly && segment.isEditable;
|
|
821
|
+
// Literal segments should not be visible to screen readers. We don't really need any of the above,
|
|
822
|
+
// but the rules of hooks mean hooks cannot be conditional so we have to put this condition here.
|
|
823
|
+
if (segment.type === 'literal') return {
|
|
824
|
+
segmentProps: {
|
|
825
|
+
'aria-hidden': true
|
|
826
|
+
}
|
|
827
|
+
};
|
|
637
828
|
return {
|
|
638
829
|
segmentProps: $cIPI0$mergeProps(spinButtonProps, pressProps, {
|
|
639
830
|
id: id,
|
|
640
831
|
...touchPropOverrides,
|
|
641
|
-
'aria-controls': props['aria-controls'],
|
|
642
|
-
// 'aria-haspopup': props['aria-haspopup'], // deprecated in ARIA 1.2
|
|
643
832
|
'aria-invalid': state.validationState === 'invalid' ? 'true' : undefined,
|
|
644
|
-
'aria-label':
|
|
833
|
+
'aria-label': displayNames.of(segment.type),
|
|
645
834
|
'aria-labelledby': `${ariaLabelledBy} ${id}`,
|
|
646
835
|
'aria-describedby': ariaDescribedBy,
|
|
647
836
|
'aria-placeholder': segment.isPlaceholder ? segment.text : undefined,
|
|
648
|
-
'aria-readonly':
|
|
837
|
+
'aria-readonly': state.isReadOnly || !segment.isEditable ? 'true' : undefined,
|
|
649
838
|
contentEditable: isEditable,
|
|
650
839
|
suppressContentEditableWarning: isEditable,
|
|
651
840
|
spellCheck: isEditable ? 'false' : undefined,
|
|
@@ -653,100 +842,22 @@ function $32489daedd52963e$export$1315d136e6f7581(props, segment, state, ref) {
|
|
|
653
842
|
autoCorrect: isEditable ? 'off' : undefined,
|
|
654
843
|
// Capitalization was changed in React 17...
|
|
655
844
|
[parseInt($cIPI0$react.version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,
|
|
656
|
-
inputMode:
|
|
657
|
-
tabIndex:
|
|
845
|
+
inputMode: state.isDisabled || segment.type === 'dayPeriod' || !isEditable ? undefined : 'numeric',
|
|
846
|
+
tabIndex: state.isDisabled ? undefined : 0,
|
|
658
847
|
onKeyDown: onKeyDown,
|
|
659
|
-
onFocus: onFocus
|
|
848
|
+
onFocus: onFocus,
|
|
849
|
+
style: {
|
|
850
|
+
caretColor: 'transparent'
|
|
851
|
+
}
|
|
660
852
|
})
|
|
661
853
|
};
|
|
662
854
|
}
|
|
663
855
|
|
|
664
856
|
|
|
665
857
|
|
|
666
|
-
var $887cac91b7cc8801$exports = {};
|
|
667
|
-
|
|
668
|
-
$parcel$export($887cac91b7cc8801$exports, "useDateRangePicker", () => $887cac91b7cc8801$export$12fd5f0e9f4bb192);
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
677
|
-
let formatMessage = $cIPI0$useMessageFormatter((/*@__PURE__*/$parcel$interopDefault($204383cf4f6b0d06$exports)));
|
|
678
|
-
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $cIPI0$useField({
|
|
679
|
-
...props,
|
|
680
|
-
labelElementType: 'span'
|
|
681
|
-
});
|
|
682
|
-
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
683
|
-
let { locale: locale } = $cIPI0$useLocale();
|
|
684
|
-
let description = state.formatValue(locale, {
|
|
685
|
-
month: 'long'
|
|
686
|
-
});
|
|
687
|
-
let descProps = $cIPI0$useDescription(description);
|
|
688
|
-
let startFieldProps = $cIPI0$useLabels({
|
|
689
|
-
'aria-label': formatMessage('startDate'),
|
|
690
|
-
'aria-labelledby': labelledBy
|
|
691
|
-
});
|
|
692
|
-
let endFieldProps = $cIPI0$useLabels({
|
|
693
|
-
'aria-label': formatMessage('endDate'),
|
|
694
|
-
'aria-labelledby': labelledBy
|
|
695
|
-
});
|
|
696
|
-
let buttonId = $cIPI0$useId();
|
|
697
|
-
let dialogId = $cIPI0$useId();
|
|
698
|
-
let groupProps = $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref);
|
|
699
|
-
let { focusWithinProps: focusWithinProps } = $cIPI0$useFocusWithin({
|
|
700
|
-
onBlurWithin () {
|
|
701
|
-
state.confirmPlaceholder();
|
|
702
|
-
}
|
|
703
|
-
});
|
|
704
|
-
let ariaDescribedBy = [
|
|
705
|
-
descProps['aria-describedby'],
|
|
706
|
-
fieldProps['aria-describedby']
|
|
707
|
-
].filter(Boolean).join(' ') || undefined;
|
|
708
|
-
return {
|
|
709
|
-
groupProps: $cIPI0$mergeProps(groupProps, fieldProps, descProps, focusWithinProps, {
|
|
710
|
-
role: 'group',
|
|
711
|
-
'aria-disabled': props.isDisabled || null,
|
|
712
|
-
'aria-describedby': ariaDescribedBy
|
|
713
|
-
}),
|
|
714
|
-
labelProps: {
|
|
715
|
-
...labelProps,
|
|
716
|
-
onClick: ()=>{
|
|
717
|
-
let focusManager = $cIPI0$createFocusManager(ref);
|
|
718
|
-
focusManager.focusFirst();
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
|
-
buttonProps: {
|
|
722
|
-
...descProps,
|
|
723
|
-
id: buttonId,
|
|
724
|
-
excludeFromTabOrder: true,
|
|
725
|
-
'aria-haspopup': 'dialog',
|
|
726
|
-
'aria-label': formatMessage('calendar'),
|
|
727
|
-
'aria-labelledby': `${labelledBy} ${buttonId}`,
|
|
728
|
-
'aria-describedby': ariaDescribedBy
|
|
729
|
-
},
|
|
730
|
-
dialogProps: {
|
|
731
|
-
id: dialogId,
|
|
732
|
-
'aria-labelledby': `${labelledBy} ${buttonId}`
|
|
733
|
-
},
|
|
734
|
-
startFieldProps: {
|
|
735
|
-
...startFieldProps,
|
|
736
|
-
'aria-describedby': fieldProps['aria-describedby']
|
|
737
|
-
},
|
|
738
|
-
endFieldProps: {
|
|
739
|
-
...endFieldProps,
|
|
740
|
-
'aria-describedby': fieldProps['aria-describedby']
|
|
741
|
-
},
|
|
742
|
-
descriptionProps: descriptionProps,
|
|
743
|
-
errorMessageProps: errorMessageProps
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
|
|
747
858
|
|
|
748
859
|
|
|
749
860
|
|
|
750
861
|
|
|
751
|
-
export {$6057a3d2a53a12fd$export$42df105a73306d51 as useDatePicker, $32489daedd52963e$export$1315d136e6f7581 as useDateSegment, $16f0b7bb276bc17e$export$
|
|
862
|
+
export {$6057a3d2a53a12fd$export$42df105a73306d51 as useDatePicker, $32489daedd52963e$export$1315d136e6f7581 as useDateSegment, $16f0b7bb276bc17e$export$5591b0b878c1a989 as useDateField, $16f0b7bb276bc17e$export$4c842f6a241dc825 as useTimeField, $887cac91b7cc8801$export$12fd5f0e9f4bb192 as useDateRangePicker, $3aeceb3a64eb8358$export$d42c60378c8168f8 as useDisplayNames};
|
|
752
863
|
//# sourceMappingURL=module.js.map
|