@react-aria/datepicker 3.0.0-rc.0 → 3.0.0-rc.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/dist/main.js +43 -39
- package/dist/main.js.map +1 -1
- package/dist/module.js +43 -39
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/useDateField.ts +1 -2
- package/src/useDatePicker.ts +2 -3
- package/src/useDatePickerGroup.ts +32 -3
- package/src/useDateRangePicker.ts +5 -2
- package/src/useDateSegment.ts +7 -23
package/dist/main.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var $IwcIq$reactariafocus = require("@react-aria/focus");
|
|
2
2
|
var $IwcIq$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $IwcIq$react = require("react");
|
|
3
4
|
var $IwcIq$reactarialabel = require("@react-aria/label");
|
|
4
5
|
var $IwcIq$reactariai18n = require("@react-aria/i18n");
|
|
5
|
-
var $IwcIq$react = require("react");
|
|
6
6
|
var $IwcIq$reactariainteractions = require("@react-aria/interactions");
|
|
7
7
|
var $IwcIq$internationalizednumber = require("@internationalized/number");
|
|
8
8
|
var $IwcIq$reactariaspinbutton = require("@react-aria/spinbutton");
|
|
@@ -23,6 +23,7 @@ $parcel$export(module.exports, "useDateRangePicker", () => $20f695b1b69e6b9e$exp
|
|
|
23
23
|
$parcel$export(module.exports, "useDisplayNames", () => $934ac650a0aceb4b$export$d42c60378c8168f8);
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
|
|
26
27
|
var $c7d0e80b992ca68a$exports = {};
|
|
27
28
|
var $aa344be62785b256$exports = {};
|
|
28
29
|
$aa344be62785b256$exports = JSON.parse("{\"calendar\":\"التقويم\",\"day\":\"يوم\",\"dayPeriod\":\"ص/م\",\"endDate\":\"تاريخ الانتهاء\",\"era\":\"العصر\",\"hour\":\"الساعات\",\"minute\":\"الدقائق\",\"month\":\"الشهر\",\"second\":\"الثواني\",\"selectedDateDescription\":\"تاريخ محدد: {date}\",\"selectedRangeDescription\":\"المدى الزمني المحدد: {startDate} إلى {endDate}\",\"selectedTimeDescription\":\"الوقت المحدد: {time}\",\"startDate\":\"تاريخ البدء\",\"timeZoneName\":\"التوقيت\",\"weekday\":\"اليوم\",\"year\":\"السنة\"}");
|
|
@@ -205,7 +206,14 @@ $c7d0e80b992ca68a$exports = {
|
|
|
205
206
|
|
|
206
207
|
|
|
207
208
|
|
|
208
|
-
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
function $715562ad3b4cced4$export$4a931266a3838b86(state, ref1, disableArrowNavigation) {
|
|
212
|
+
let { direction: direction } = $IwcIq$reactariai18n.useLocale();
|
|
213
|
+
let focusManager = $IwcIq$react.useMemo(()=>$IwcIq$reactariafocus.createFocusManager(ref1)
|
|
214
|
+
, [
|
|
215
|
+
ref1
|
|
216
|
+
]);
|
|
209
217
|
// Open the popover on alt + arrow down
|
|
210
218
|
let onKeyDown = (e)=>{
|
|
211
219
|
if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {
|
|
@@ -213,6 +221,21 @@ function $715562ad3b4cced4$export$4a931266a3838b86(state, ref1) {
|
|
|
213
221
|
e.stopPropagation();
|
|
214
222
|
state.setOpen(true);
|
|
215
223
|
}
|
|
224
|
+
if (disableArrowNavigation) return;
|
|
225
|
+
switch(e.key){
|
|
226
|
+
case 'ArrowLeft':
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
e.stopPropagation();
|
|
229
|
+
if (direction === 'rtl') focusManager.focusNext();
|
|
230
|
+
else focusManager.focusPrevious();
|
|
231
|
+
break;
|
|
232
|
+
case 'ArrowRight':
|
|
233
|
+
e.preventDefault();
|
|
234
|
+
e.stopPropagation();
|
|
235
|
+
if (direction === 'rtl') focusManager.focusPrevious();
|
|
236
|
+
else focusManager.focusNext();
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
216
239
|
};
|
|
217
240
|
// Focus the first placeholder segment from the end on mouse down/touch up in the field.
|
|
218
241
|
let focusLast = ()=>{
|
|
@@ -267,7 +290,6 @@ function $4acc2f407c169e55$export$5591b0b878c1a989(props, state, ref) {
|
|
|
267
290
|
...props,
|
|
268
291
|
labelElementType: 'span'
|
|
269
292
|
});
|
|
270
|
-
let groupProps = $715562ad3b4cced4$export$4a931266a3838b86(state, ref);
|
|
271
293
|
let { focusWithinProps: focusWithinProps } = $IwcIq$reactariainteractions.useFocusWithin({
|
|
272
294
|
onBlurWithin () {
|
|
273
295
|
state.confirmPlaceholder();
|
|
@@ -294,6 +316,7 @@ function $4acc2f407c169e55$export$5591b0b878c1a989(props, state, ref) {
|
|
|
294
316
|
propsFocusManager,
|
|
295
317
|
ref
|
|
296
318
|
]);
|
|
319
|
+
let groupProps = $715562ad3b4cced4$export$4a931266a3838b86(state, ref, props[$4acc2f407c169e55$export$300019f83c56d282] === 'presentation');
|
|
297
320
|
// Pass labels and other information to segments.
|
|
298
321
|
$4acc2f407c169e55$export$653eddfc964b0f8a.set(state, {
|
|
299
322
|
ariaLabel: props['aria-label'],
|
|
@@ -368,6 +391,10 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
368
391
|
fieldProps['aria-describedby']
|
|
369
392
|
].filter(Boolean).join(' ') || undefined;
|
|
370
393
|
let domProps = $IwcIq$reactariautils.filterDOMProps(props);
|
|
394
|
+
let focusManager = $IwcIq$react.useMemo(()=>$IwcIq$reactariafocus.createFocusManager(ref)
|
|
395
|
+
, [
|
|
396
|
+
ref
|
|
397
|
+
]);
|
|
371
398
|
return {
|
|
372
399
|
groupProps: $IwcIq$reactariautils.mergeProps(domProps, groupProps, fieldProps, descProps, {
|
|
373
400
|
role: 'group',
|
|
@@ -378,7 +405,6 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
378
405
|
labelProps: {
|
|
379
406
|
...labelProps,
|
|
380
407
|
onClick: ()=>{
|
|
381
|
-
let focusManager = $IwcIq$reactariafocus.createFocusManager(ref);
|
|
382
408
|
focusManager.focusFirst();
|
|
383
409
|
}
|
|
384
410
|
},
|
|
@@ -405,7 +431,6 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
405
431
|
buttonProps: {
|
|
406
432
|
...descProps,
|
|
407
433
|
id: buttonId,
|
|
408
|
-
excludeFromTabOrder: true,
|
|
409
434
|
'aria-haspopup': 'dialog',
|
|
410
435
|
'aria-label': formatMessage('calendar'),
|
|
411
436
|
'aria-labelledby': `${labelledBy} ${buttonId}`,
|
|
@@ -473,7 +498,7 @@ class $934ac650a0aceb4b$var$DisplayNamesPolyfill {
|
|
|
473
498
|
|
|
474
499
|
function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
475
500
|
let enteredKeys = $IwcIq$react.useRef('');
|
|
476
|
-
let { locale: locale
|
|
501
|
+
let { locale: locale } = $IwcIq$reactariai18n.useLocale();
|
|
477
502
|
let displayNames = $934ac650a0aceb4b$export$d42c60378c8168f8();
|
|
478
503
|
let { ariaLabel: ariaLabel , ariaLabelledBy: ariaLabelledBy , ariaDescribedBy: ariaDescribedBy , focusManager: focusManager } = $4acc2f407c169e55$export$653eddfc964b0f8a.get(state);
|
|
479
504
|
let textValue = segment.text;
|
|
@@ -548,33 +573,11 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
548
573
|
if (e.key === 'a' && ($IwcIq$reactariautils.isMac() ? e.metaKey : e.ctrlKey)) e.preventDefault();
|
|
549
574
|
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return;
|
|
550
575
|
switch(e.key){
|
|
551
|
-
case 'ArrowLeft':
|
|
552
|
-
e.preventDefault();
|
|
553
|
-
e.stopPropagation();
|
|
554
|
-
if (direction === 'rtl') focusManager.focusNext({
|
|
555
|
-
tabbable: true
|
|
556
|
-
});
|
|
557
|
-
else focusManager.focusPrevious({
|
|
558
|
-
tabbable: true
|
|
559
|
-
});
|
|
560
|
-
break;
|
|
561
|
-
case 'ArrowRight':
|
|
562
|
-
e.preventDefault();
|
|
563
|
-
e.stopPropagation();
|
|
564
|
-
if (direction === 'rtl') focusManager.focusPrevious({
|
|
565
|
-
tabbable: true
|
|
566
|
-
});
|
|
567
|
-
else focusManager.focusNext({
|
|
568
|
-
tabbable: true
|
|
569
|
-
});
|
|
570
|
-
break;
|
|
571
576
|
case 'Enter':
|
|
572
577
|
e.preventDefault();
|
|
573
578
|
e.stopPropagation();
|
|
574
579
|
if (segment.isPlaceholder && !state.isReadOnly) state.confirmPlaceholder(segment.type);
|
|
575
|
-
focusManager.focusNext(
|
|
576
|
-
tabbable: true
|
|
577
|
-
});
|
|
580
|
+
focusManager.focusNext();
|
|
578
581
|
break;
|
|
579
582
|
case 'Tab':
|
|
580
583
|
break;
|
|
@@ -619,9 +622,7 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
619
622
|
if (startsWith(am, key)) state.setSegment('dayPeriod', 0);
|
|
620
623
|
else if (startsWith(pm, key)) state.setSegment('dayPeriod', 12);
|
|
621
624
|
else break;
|
|
622
|
-
focusManager.focusNext(
|
|
623
|
-
tabbable: true
|
|
624
|
-
});
|
|
625
|
+
focusManager.focusNext();
|
|
625
626
|
break;
|
|
626
627
|
case 'day':
|
|
627
628
|
case 'hour':
|
|
@@ -651,9 +652,7 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
651
652
|
if (shouldSetValue) state.setSegment(segment.type, segmentValue);
|
|
652
653
|
if (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length) {
|
|
653
654
|
enteredKeys.current = '';
|
|
654
|
-
if (shouldSetValue) focusManager.focusNext(
|
|
655
|
-
tabbable: true
|
|
656
|
-
});
|
|
655
|
+
if (shouldSetValue) focusManager.focusNext();
|
|
657
656
|
} else enteredKeys.current = newValue;
|
|
658
657
|
break;
|
|
659
658
|
}
|
|
@@ -665,9 +664,11 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
665
664
|
// Safari requires that a selection is set or it won't fire input events.
|
|
666
665
|
// Since usePress disables text selection, this won't happen by default.
|
|
667
666
|
ref.current.style.webkitUserSelect = 'text';
|
|
667
|
+
ref.current.style.userSelect = 'text';
|
|
668
668
|
let selection = window.getSelection();
|
|
669
669
|
selection.collapse(ref.current);
|
|
670
|
-
ref.current.style.webkitUserSelect = '';
|
|
670
|
+
ref.current.style.webkitUserSelect = 'none';
|
|
671
|
+
ref.current.style.userSelect = 'none';
|
|
671
672
|
};
|
|
672
673
|
let compositionRef = $IwcIq$react.useRef('');
|
|
673
674
|
// @ts-ignore - TODO: possibly old TS version? doesn't fail in my editor...
|
|
@@ -823,9 +824,13 @@ function $20f695b1b69e6b9e$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
823
824
|
descProps['aria-describedby'],
|
|
824
825
|
fieldProps['aria-describedby']
|
|
825
826
|
].filter(Boolean).join(' ') || undefined;
|
|
826
|
-
let focusManager = $IwcIq$react.useMemo(()=>$IwcIq$reactariafocus.createFocusManager(ref
|
|
827
|
+
let focusManager = $IwcIq$react.useMemo(()=>$IwcIq$reactariafocus.createFocusManager(ref, {
|
|
828
|
+
// Exclude the button from the focus manager.
|
|
829
|
+
accept: (element)=>element.id !== buttonId
|
|
830
|
+
})
|
|
827
831
|
, [
|
|
828
|
-
ref
|
|
832
|
+
ref,
|
|
833
|
+
buttonId
|
|
829
834
|
]);
|
|
830
835
|
let commonFieldProps = {
|
|
831
836
|
[$4acc2f407c169e55$export$7b3062cd49e80452]: focusManager,
|
|
@@ -858,7 +863,6 @@ function $20f695b1b69e6b9e$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
858
863
|
buttonProps: {
|
|
859
864
|
...descProps,
|
|
860
865
|
id: buttonId,
|
|
861
|
-
excludeFromTabOrder: true,
|
|
862
866
|
'aria-haspopup': 'dialog',
|
|
863
867
|
'aria-label': formatMessage('calendar'),
|
|
864
868
|
'aria-labelledby': `${labelledBy} ${buttonId}`,
|