@react-aria/datepicker 3.10.0 → 3.11.0
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/ar-AE.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/intlStrings.mjs +1 -1
- package/dist/it-IT.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/types.d.ts +10 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.mjs +1 -1
- package/dist/useDateField.main.js +27 -26
- package/dist/useDateField.main.js.map +1 -1
- package/dist/useDateField.mjs +28 -27
- package/dist/useDateField.module.js +27 -26
- package/dist/useDateField.module.js.map +1 -1
- package/dist/useDatePicker.main.js +23 -23
- package/dist/useDatePicker.main.js.map +1 -1
- package/dist/useDatePicker.mjs +24 -24
- package/dist/useDatePicker.module.js +23 -23
- package/dist/useDatePicker.module.js.map +1 -1
- package/dist/useDatePickerGroup.main.js +10 -10
- package/dist/useDatePickerGroup.main.js.map +1 -1
- package/dist/useDatePickerGroup.mjs +11 -11
- package/dist/useDatePickerGroup.module.js +10 -10
- package/dist/useDatePickerGroup.module.js.map +1 -1
- package/dist/useDateRangePicker.main.js +28 -28
- package/dist/useDateRangePicker.main.js.map +1 -1
- package/dist/useDateRangePicker.mjs +29 -29
- package/dist/useDateRangePicker.module.js +28 -28
- package/dist/useDateRangePicker.module.js.map +1 -1
- package/dist/useDateSegment.main.js +79 -72
- package/dist/useDateSegment.main.js.map +1 -1
- package/dist/useDateSegment.mjs +80 -73
- package/dist/useDateSegment.module.js +79 -72
- package/dist/useDateSegment.module.js.map +1 -1
- package/dist/useDisplayNames.main.js +2 -2
- package/dist/useDisplayNames.mjs +3 -3
- package/dist/useDisplayNames.module.js +2 -2
- package/dist/zh-CN.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +21 -21
- package/src/useDateField.ts +8 -7
- package/src/useDatePicker.ts +3 -3
- package/src/useDatePickerGroup.ts +4 -4
- package/src/useDateRangePicker.ts +3 -3
- package/src/useDateSegment.ts +15 -5
package/dist/useDateField.mjs
CHANGED
|
@@ -32,14 +32,14 @@ function $parcel$interopDefault(a) {
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
const $16f0b7bb276bc17e$export$653eddfc964b0f8a = new WeakMap();
|
|
35
|
-
const $16f0b7bb276bc17e$export$300019f83c56d282 =
|
|
36
|
-
const $16f0b7bb276bc17e$export$7b3062cd49e80452 =
|
|
35
|
+
const $16f0b7bb276bc17e$export$300019f83c56d282 = '__role_' + Date.now();
|
|
36
|
+
const $16f0b7bb276bc17e$export$7b3062cd49e80452 = '__focusManager_' + Date.now();
|
|
37
37
|
function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
38
38
|
var _state_value;
|
|
39
39
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
40
40
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $7Gzdi$useField)({
|
|
41
41
|
...props,
|
|
42
|
-
labelElementType:
|
|
42
|
+
labelElementType: 'span',
|
|
43
43
|
isInvalid: isInvalid,
|
|
44
44
|
errorMessage: props.errorMessage || validationErrors
|
|
45
45
|
});
|
|
@@ -59,34 +59,34 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
59
59
|
},
|
|
60
60
|
onFocusWithinChange: props.onFocusChange
|
|
61
61
|
});
|
|
62
|
-
let stringFormatter = (0, $7Gzdi$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7Gzdi$intlStringsmodulejs))),
|
|
63
|
-
let message = state.maxGranularity ===
|
|
64
|
-
let field = state.maxGranularity ===
|
|
62
|
+
let stringFormatter = (0, $7Gzdi$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7Gzdi$intlStringsmodulejs))), '@react-aria/datepicker');
|
|
63
|
+
let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';
|
|
64
|
+
let field = state.maxGranularity === 'hour' ? 'time' : 'date';
|
|
65
65
|
let description = state.value ? stringFormatter.format(message, {
|
|
66
66
|
[field]: state.formatValue({
|
|
67
|
-
month:
|
|
67
|
+
month: 'long'
|
|
68
68
|
})
|
|
69
|
-
}) :
|
|
69
|
+
}) : '';
|
|
70
70
|
let descProps = (0, $7Gzdi$useDescription)(description);
|
|
71
71
|
// If within a date picker or date range picker, the date field will have role="presentation" and an aria-describedby
|
|
72
72
|
// will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.
|
|
73
|
-
let describedBy = props[$16f0b7bb276bc17e$export$300019f83c56d282] ===
|
|
74
|
-
descProps[
|
|
75
|
-
fieldProps[
|
|
76
|
-
].filter(Boolean).join(
|
|
73
|
+
let describedBy = props[$16f0b7bb276bc17e$export$300019f83c56d282] === 'presentation' ? fieldProps['aria-describedby'] : [
|
|
74
|
+
descProps['aria-describedby'],
|
|
75
|
+
fieldProps['aria-describedby']
|
|
76
|
+
].filter(Boolean).join(' ') || undefined;
|
|
77
77
|
let propsFocusManager = props[$16f0b7bb276bc17e$export$7b3062cd49e80452];
|
|
78
78
|
let focusManager = (0, $7Gzdi$useMemo)(()=>propsFocusManager || (0, $7Gzdi$createFocusManager)(ref), [
|
|
79
79
|
propsFocusManager,
|
|
80
80
|
ref
|
|
81
81
|
]);
|
|
82
|
-
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref, props[$16f0b7bb276bc17e$export$300019f83c56d282] ===
|
|
82
|
+
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref, props[$16f0b7bb276bc17e$export$300019f83c56d282] === 'presentation');
|
|
83
83
|
// Pass labels and other information to segments.
|
|
84
84
|
$16f0b7bb276bc17e$export$653eddfc964b0f8a.set(state, {
|
|
85
|
-
ariaLabel: props[
|
|
85
|
+
ariaLabel: props['aria-label'],
|
|
86
86
|
ariaLabelledBy: [
|
|
87
87
|
labelProps.id,
|
|
88
|
-
props[
|
|
89
|
-
].filter(Boolean).join(
|
|
88
|
+
props['aria-labelledby']
|
|
89
|
+
].filter(Boolean).join(' ') || undefined,
|
|
90
90
|
ariaDescribedBy: describedBy,
|
|
91
91
|
focusManager: focusManager
|
|
92
92
|
});
|
|
@@ -96,13 +96,13 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
96
96
|
// with a label and description, and the segments are already labeled by this as well, this
|
|
97
97
|
// avoids very verbose duplicate announcements.
|
|
98
98
|
let fieldDOMProps;
|
|
99
|
-
if (props[$16f0b7bb276bc17e$export$300019f83c56d282] ===
|
|
100
|
-
role:
|
|
99
|
+
if (props[$16f0b7bb276bc17e$export$300019f83c56d282] === 'presentation') fieldDOMProps = {
|
|
100
|
+
role: 'presentation'
|
|
101
101
|
};
|
|
102
102
|
else fieldDOMProps = (0, $7Gzdi$mergeProps)(fieldProps, {
|
|
103
|
-
role:
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
role: 'group',
|
|
104
|
+
'aria-disabled': props.isDisabled || undefined,
|
|
105
|
+
'aria-describedby': describedBy
|
|
106
106
|
});
|
|
107
107
|
(0, $7Gzdi$useEffect)(()=>{
|
|
108
108
|
if (autoFocusRef.current) focusManager.focusFirst();
|
|
@@ -118,14 +118,15 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
118
118
|
}
|
|
119
119
|
}, state, props.inputRef);
|
|
120
120
|
let inputProps = {
|
|
121
|
-
type:
|
|
121
|
+
type: 'hidden',
|
|
122
122
|
name: props.name,
|
|
123
|
-
value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) ||
|
|
123
|
+
value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) || '',
|
|
124
|
+
disabled: props.isDisabled
|
|
124
125
|
};
|
|
125
|
-
if (props.validationBehavior ===
|
|
126
|
+
if (props.validationBehavior === 'native') {
|
|
126
127
|
// Use a hidden <input type="text"> rather than <input type="hidden">
|
|
127
128
|
// so that an empty value blocks HTML form submission when the field is required.
|
|
128
|
-
inputProps.type =
|
|
129
|
+
inputProps.type = 'text';
|
|
129
130
|
inputProps.hidden = true;
|
|
130
131
|
inputProps.required = props.isRequired;
|
|
131
132
|
// Ignore react warning.
|
|
@@ -158,10 +159,10 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
158
159
|
function $16f0b7bb276bc17e$export$4c842f6a241dc825(props, state, ref) {
|
|
159
160
|
var _state_timeValue;
|
|
160
161
|
let res = $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref);
|
|
161
|
-
res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) ||
|
|
162
|
+
res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) || '';
|
|
162
163
|
return res;
|
|
163
164
|
}
|
|
164
165
|
|
|
165
166
|
|
|
166
167
|
export {$16f0b7bb276bc17e$export$653eddfc964b0f8a as hookData, $16f0b7bb276bc17e$export$300019f83c56d282 as roleSymbol, $16f0b7bb276bc17e$export$7b3062cd49e80452 as focusManagerSymbol, $16f0b7bb276bc17e$export$5591b0b878c1a989 as useDateField, $16f0b7bb276bc17e$export$4c842f6a241dc825 as useTimeField};
|
|
167
|
-
//# sourceMappingURL=useDateField.
|
|
168
|
+
//# sourceMappingURL=useDateField.module.js.map
|
|
@@ -32,14 +32,14 @@ function $parcel$interopDefault(a) {
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
const $16f0b7bb276bc17e$export$653eddfc964b0f8a = new WeakMap();
|
|
35
|
-
const $16f0b7bb276bc17e$export$300019f83c56d282 =
|
|
36
|
-
const $16f0b7bb276bc17e$export$7b3062cd49e80452 =
|
|
35
|
+
const $16f0b7bb276bc17e$export$300019f83c56d282 = '__role_' + Date.now();
|
|
36
|
+
const $16f0b7bb276bc17e$export$7b3062cd49e80452 = '__focusManager_' + Date.now();
|
|
37
37
|
function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
38
38
|
var _state_value;
|
|
39
39
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
40
40
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $7Gzdi$useField)({
|
|
41
41
|
...props,
|
|
42
|
-
labelElementType:
|
|
42
|
+
labelElementType: 'span',
|
|
43
43
|
isInvalid: isInvalid,
|
|
44
44
|
errorMessage: props.errorMessage || validationErrors
|
|
45
45
|
});
|
|
@@ -59,34 +59,34 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
59
59
|
},
|
|
60
60
|
onFocusWithinChange: props.onFocusChange
|
|
61
61
|
});
|
|
62
|
-
let stringFormatter = (0, $7Gzdi$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7Gzdi$intlStringsmodulejs))),
|
|
63
|
-
let message = state.maxGranularity ===
|
|
64
|
-
let field = state.maxGranularity ===
|
|
62
|
+
let stringFormatter = (0, $7Gzdi$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7Gzdi$intlStringsmodulejs))), '@react-aria/datepicker');
|
|
63
|
+
let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';
|
|
64
|
+
let field = state.maxGranularity === 'hour' ? 'time' : 'date';
|
|
65
65
|
let description = state.value ? stringFormatter.format(message, {
|
|
66
66
|
[field]: state.formatValue({
|
|
67
|
-
month:
|
|
67
|
+
month: 'long'
|
|
68
68
|
})
|
|
69
|
-
}) :
|
|
69
|
+
}) : '';
|
|
70
70
|
let descProps = (0, $7Gzdi$useDescription)(description);
|
|
71
71
|
// If within a date picker or date range picker, the date field will have role="presentation" and an aria-describedby
|
|
72
72
|
// will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.
|
|
73
|
-
let describedBy = props[$16f0b7bb276bc17e$export$300019f83c56d282] ===
|
|
74
|
-
descProps[
|
|
75
|
-
fieldProps[
|
|
76
|
-
].filter(Boolean).join(
|
|
73
|
+
let describedBy = props[$16f0b7bb276bc17e$export$300019f83c56d282] === 'presentation' ? fieldProps['aria-describedby'] : [
|
|
74
|
+
descProps['aria-describedby'],
|
|
75
|
+
fieldProps['aria-describedby']
|
|
76
|
+
].filter(Boolean).join(' ') || undefined;
|
|
77
77
|
let propsFocusManager = props[$16f0b7bb276bc17e$export$7b3062cd49e80452];
|
|
78
78
|
let focusManager = (0, $7Gzdi$useMemo)(()=>propsFocusManager || (0, $7Gzdi$createFocusManager)(ref), [
|
|
79
79
|
propsFocusManager,
|
|
80
80
|
ref
|
|
81
81
|
]);
|
|
82
|
-
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref, props[$16f0b7bb276bc17e$export$300019f83c56d282] ===
|
|
82
|
+
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref, props[$16f0b7bb276bc17e$export$300019f83c56d282] === 'presentation');
|
|
83
83
|
// Pass labels and other information to segments.
|
|
84
84
|
$16f0b7bb276bc17e$export$653eddfc964b0f8a.set(state, {
|
|
85
|
-
ariaLabel: props[
|
|
85
|
+
ariaLabel: props['aria-label'],
|
|
86
86
|
ariaLabelledBy: [
|
|
87
87
|
labelProps.id,
|
|
88
|
-
props[
|
|
89
|
-
].filter(Boolean).join(
|
|
88
|
+
props['aria-labelledby']
|
|
89
|
+
].filter(Boolean).join(' ') || undefined,
|
|
90
90
|
ariaDescribedBy: describedBy,
|
|
91
91
|
focusManager: focusManager
|
|
92
92
|
});
|
|
@@ -96,13 +96,13 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
96
96
|
// with a label and description, and the segments are already labeled by this as well, this
|
|
97
97
|
// avoids very verbose duplicate announcements.
|
|
98
98
|
let fieldDOMProps;
|
|
99
|
-
if (props[$16f0b7bb276bc17e$export$300019f83c56d282] ===
|
|
100
|
-
role:
|
|
99
|
+
if (props[$16f0b7bb276bc17e$export$300019f83c56d282] === 'presentation') fieldDOMProps = {
|
|
100
|
+
role: 'presentation'
|
|
101
101
|
};
|
|
102
102
|
else fieldDOMProps = (0, $7Gzdi$mergeProps)(fieldProps, {
|
|
103
|
-
role:
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
role: 'group',
|
|
104
|
+
'aria-disabled': props.isDisabled || undefined,
|
|
105
|
+
'aria-describedby': describedBy
|
|
106
106
|
});
|
|
107
107
|
(0, $7Gzdi$useEffect)(()=>{
|
|
108
108
|
if (autoFocusRef.current) focusManager.focusFirst();
|
|
@@ -118,14 +118,15 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
118
118
|
}
|
|
119
119
|
}, state, props.inputRef);
|
|
120
120
|
let inputProps = {
|
|
121
|
-
type:
|
|
121
|
+
type: 'hidden',
|
|
122
122
|
name: props.name,
|
|
123
|
-
value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) ||
|
|
123
|
+
value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) || '',
|
|
124
|
+
disabled: props.isDisabled
|
|
124
125
|
};
|
|
125
|
-
if (props.validationBehavior ===
|
|
126
|
+
if (props.validationBehavior === 'native') {
|
|
126
127
|
// Use a hidden <input type="text"> rather than <input type="hidden">
|
|
127
128
|
// so that an empty value blocks HTML form submission when the field is required.
|
|
128
|
-
inputProps.type =
|
|
129
|
+
inputProps.type = 'text';
|
|
129
130
|
inputProps.hidden = true;
|
|
130
131
|
inputProps.required = props.isRequired;
|
|
131
132
|
// Ignore react warning.
|
|
@@ -158,7 +159,7 @@ function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
|
|
|
158
159
|
function $16f0b7bb276bc17e$export$4c842f6a241dc825(props, state, ref) {
|
|
159
160
|
var _state_timeValue;
|
|
160
161
|
let res = $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref);
|
|
161
|
-
res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) ||
|
|
162
|
+
res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) || '';
|
|
162
163
|
return res;
|
|
163
164
|
}
|
|
164
165
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA2CM,MAAM,4CAAW,IAAI;AAIrB,MAAM,4CAAa,YAAY,KAAK,GAAG;AACvC,MAAM,4CAAqB,oBAAoB,KAAK,GAAG;AAOvD,SAAS,0CAAkC,KAA8B,EAAE,KAAqB,EAAE,GAAuB;QAsFrH;IArFT,IAAI,aAAC,S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AkB,KAAK,UAAU;QACzC,qEAAqE;QACrE,iFAAiF;QACjF,WAAW,IAAI,GAAG;QAClB,WAAW,MAAM,GAAG;QACpB,WAAW,QAAQ,GAAG,MAAM,UAAU;QACtC,wBAAwB;QACxB,WAAW,QAAQ,GAAG,KAAO;IAC/B;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE;IAC9B,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,SAAS;gBACP,aAAa,UAAU;YACzB;QACF;QACA,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU,eAAe,YAAY,kBAAkB;YAC5E,WAAU,CAAgB;gBACxB,IAAI,MAAM,SAAS,EACjB,MAAM,SAAS,CAAC;YAEpB;YACA,SAAQ,CAAgB;gBACtB,IAAI,MAAM,OAAO,EACf,MAAM,OAAO,CAAC;YAElB;QACF;oBACA;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF;AAYO,SAAS,0CAAkC,KAA8B,EAAE,KAAqB,EAAE,GAAuB;QAEvG;IADvB,IAAI,MAAM,0CAAa,OAAO,OAAO;IACrC,IAAI,UAAU,CAAC,KAAK,GAAG,EAAA,mBAAA,MAAM,SAAS,cAAf,uCAAA,iBAAiB,QAAQ,OAAM;IACtD,OAAO;AACT","sources":["packages/@react-aria/datepicker/src/useDateField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDateFieldProps as AriaDateFieldPropsBase, AriaTimeFieldProps, DateValue, TimeValue} from '@react-types/datepicker';\nimport {createFocusManager, FocusManager} from '@react-aria/focus';\nimport {DateFieldState, TimeFieldState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject, useEffect, useMemo, useRef} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n// Allows this hook to also be used with TimeField\nexport interface AriaDateFieldOptions<T extends DateValue> extends Omit<AriaDateFieldPropsBase<T>, 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'placeholderValue' | 'validate'> {\n /** A ref for the hidden input element for HTML form submission. */\n inputRef?: RefObject<HTMLInputElement>\n}\n\nexport interface DateFieldAria extends ValidationResult {\n /** Props for the field's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the field grouping element. */\n fieldProps: GroupDOMAttributes,\n /** Props for the hidden input element for HTML form submission. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n// Data that is passed between useDateField and useDateSegment.\ninterface HookData {\n ariaLabel: string,\n ariaLabelledBy: string,\n ariaDescribedBy: string,\n focusManager: FocusManager\n}\n\nexport const hookData = new WeakMap<DateFieldState, HookData>();\n\n// Private props that we pass from useDatePicker/useDateRangePicker.\n// Ideally we'd use a Symbol for this, but React doesn't support them: https://github.com/facebook/react/issues/7552\nexport const roleSymbol = '__role_' + Date.now();\nexport const focusManagerSymbol = '__focusManager_' + Date.now();\n\n/**\n * Provides the behavior and accessibility implementation for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateField<T extends DateValue>(props: AriaDateFieldOptions<T>, state: DateFieldState, ref: RefObject<Element>): DateFieldAria {\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let valueOnFocus = useRef<DateValue | null>(null);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n onFocusWithin(e) {\n valueOnFocus.current = state.value;\n props.onFocus?.(e);\n },\n onBlurWithin: (e) => {\n state.confirmPlaceholder();\n if (state.value !== valueOnFocus.current) {\n state.commitValidation();\n }\n props.onBlur?.(e);\n },\n onFocusWithinChange: props.onFocusChange\n });\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';\n let field = state.maxGranularity === 'hour' ? 'time' : 'date';\n let description = state.value ? stringFormatter.format(message, {[field]: state.formatValue({month: 'long'})}) : '';\n let descProps = useDescription(description);\n\n // If within a date picker or date range picker, the date field will have role=\"presentation\" and an aria-describedby\n // will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.\n let describedBy = props[roleSymbol] === 'presentation'\n ? fieldProps['aria-describedby']\n : [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let propsFocusManager = props[focusManagerSymbol];\n let focusManager = useMemo(() => propsFocusManager || createFocusManager(ref), [propsFocusManager, ref]);\n let groupProps = useDatePickerGroup(state, ref, props[roleSymbol] === 'presentation');\n\n // Pass labels and other information to segments.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: [labelProps.id, props['aria-labelledby']].filter(Boolean).join(' ') || undefined,\n ariaDescribedBy: describedBy,\n focusManager\n });\n\n let autoFocusRef = useRef(props.autoFocus);\n\n // When used within a date picker or date range picker, the field gets role=\"presentation\"\n // rather than role=\"group\". Since the date picker/date range picker already has a role=\"group\"\n // with a label and description, and the segments are already labeled by this as well, this\n // avoids very verbose duplicate announcements.\n let fieldDOMProps: GroupDOMAttributes;\n if (props[roleSymbol] === 'presentation') {\n fieldDOMProps = {\n role: 'presentation'\n };\n } else {\n fieldDOMProps = mergeProps(fieldProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || undefined,\n 'aria-describedby': describedBy\n });\n }\n\n useEffect(() => {\n if (autoFocusRef.current) {\n focusManager.focusFirst();\n }\n autoFocusRef.current = false;\n }, [focusManager]);\n\n useFormReset(props.inputRef, state.value, state.setValue);\n useFormValidation({\n ...props,\n focus() {\n focusManager.focusFirst();\n }\n }, state, props.inputRef);\n\n let inputProps: InputHTMLAttributes<HTMLInputElement> = {\n type: 'hidden',\n name: props.name,\n value: state.value?.toString() || ''\n };\n\n if (props.validationBehavior === 'native') {\n // Use a hidden <input type=\"text\"> rather than <input type=\"hidden\">\n // so that an empty value blocks HTML form submission when the field is required.\n inputProps.type = 'text';\n inputProps.hidden = true;\n inputProps.required = props.isRequired;\n // Ignore react warning.\n inputProps.onChange = () => {};\n }\n\n let domProps = filterDOMProps(props);\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: mergeProps(domProps, fieldDOMProps, groupProps, focusWithinProps, {\n onKeyDown(e: KeyboardEvent) {\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n inputProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\nexport interface AriaTimeFieldOptions<T extends TimeValue> extends AriaTimeFieldProps<T> {\n /** A ref for the hidden input element for HTML form submission. */\n inputRef?: RefObject<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a time field component.\n * A time field allows users to enter and edit time values using a keyboard.\n * Each part of a time value is displayed in an individually editable segment.\n */\nexport function useTimeField<T extends TimeValue>(props: AriaTimeFieldOptions<T>, state: TimeFieldState, ref: RefObject<Element>): DateFieldAria {\n let res = useDateField(props, state, ref);\n res.inputProps.value = state.timeValue?.toString() || '';\n return res;\n}\n"],"names":[],"version":3,"file":"useDateField.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA2CM,MAAM,4CAAW,IAAI;AAIrB,MAAM,4CAAa,YAAY,KAAK,GAAG;AACvC,MAAM,4CAAqB,oBAAoB,KAAK,GAAG;AAOvD,SAAS,0CAAkC,KAA8B,EAAE,KAAqB,EAAE,GAA8B;QAsF5H;IArFT,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAC9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC3E,GAAG,KAAK;QACR,kBAAkB;mBAClB;QACA,cAAc,MAAM,YAAY,IAAI;IACtC;IAEA,IAAI,eAAe,CAAA,GAAA,aAAK,EAAoB;IAC5C,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,GAAG,KAAK;QACR,eAAc,CAAC;gBAEb;YADA,aAAa,OAAO,GAAG,MAAM,KAAK;aAClC,iBAAA,MAAM,OAAO,cAAb,qCAAA,oBAAA,OAAgB;QAClB;QACA,cAAc,CAAC;gBAKb;YAJA,MAAM,kBAAkB;YACxB,IAAI,MAAM,KAAK,KAAK,aAAa,OAAO,EACtC,MAAM,gBAAgB;aAExB,gBAAA,MAAM,MAAM,cAAZ,oCAAA,mBAAA,OAAe;QACjB;QACA,qBAAqB,MAAM,aAAa;IAC1C;IAEA,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,UAAU,MAAM,cAAc,KAAK,SAAS,4BAA4B;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sources":["packages/@react-aria/datepicker/src/useDateField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaDateFieldProps as AriaDateFieldPropsBase, AriaTimeFieldProps, DateValue, TimeValue} from '@react-types/datepicker';\nimport {createFocusManager, FocusManager} from '@react-aria/focus';\nimport {DateFieldState, TimeFieldState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, useEffect, useMemo, useRef} from 'react';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\n// Allows this hook to also be used with TimeField\nexport interface AriaDateFieldOptions<T extends DateValue> extends Omit<AriaDateFieldPropsBase<T>, 'value' | 'defaultValue' | 'onChange' | 'minValue' | 'maxValue' | 'placeholderValue' | 'validate'> {\n /** A ref for the hidden input element for HTML form submission. */\n inputRef?: RefObject<HTMLInputElement | null>\n}\n\nexport interface DateFieldAria extends ValidationResult {\n /** Props for the field's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the field grouping element. */\n fieldProps: GroupDOMAttributes,\n /** Props for the hidden input element for HTML form submission. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n// Data that is passed between useDateField and useDateSegment.\ninterface HookData {\n ariaLabel: string,\n ariaLabelledBy: string,\n ariaDescribedBy: string,\n focusManager: FocusManager\n}\n\nexport const hookData = new WeakMap<DateFieldState, HookData>();\n\n// Private props that we pass from useDatePicker/useDateRangePicker.\n// Ideally we'd use a Symbol for this, but React doesn't support them: https://github.com/facebook/react/issues/7552\nexport const roleSymbol = '__role_' + Date.now();\nexport const focusManagerSymbol = '__focusManager_' + Date.now();\n\n/**\n * Provides the behavior and accessibility implementation for a date field component.\n * A date field allows users to enter and edit date and time values using a keyboard.\n * Each part of a date value is displayed in an individually editable segment.\n */\nexport function useDateField<T extends DateValue>(props: AriaDateFieldOptions<T>, state: DateFieldState, ref: RefObject<Element | null>): DateFieldAria {\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let valueOnFocus = useRef<DateValue | null>(null);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n onFocusWithin(e) {\n valueOnFocus.current = state.value;\n props.onFocus?.(e);\n },\n onBlurWithin: (e) => {\n state.confirmPlaceholder();\n if (state.value !== valueOnFocus.current) {\n state.commitValidation();\n }\n props.onBlur?.(e);\n },\n onFocusWithinChange: props.onFocusChange\n });\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let message = state.maxGranularity === 'hour' ? 'selectedTimeDescription' : 'selectedDateDescription';\n let field = state.maxGranularity === 'hour' ? 'time' : 'date';\n let description = state.value ? stringFormatter.format(message, {[field]: state.formatValue({month: 'long'})}) : '';\n let descProps = useDescription(description);\n\n // If within a date picker or date range picker, the date field will have role=\"presentation\" and an aria-describedby\n // will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.\n let describedBy = props[roleSymbol] === 'presentation'\n ? fieldProps['aria-describedby']\n : [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let propsFocusManager = props[focusManagerSymbol];\n let focusManager = useMemo(() => propsFocusManager || createFocusManager(ref), [propsFocusManager, ref]);\n let groupProps = useDatePickerGroup(state, ref, props[roleSymbol] === 'presentation');\n\n // Pass labels and other information to segments.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: [labelProps.id, props['aria-labelledby']].filter(Boolean).join(' ') || undefined,\n ariaDescribedBy: describedBy,\n focusManager\n });\n\n let autoFocusRef = useRef(props.autoFocus);\n\n // When used within a date picker or date range picker, the field gets role=\"presentation\"\n // rather than role=\"group\". Since the date picker/date range picker already has a role=\"group\"\n // with a label and description, and the segments are already labeled by this as well, this\n // avoids very verbose duplicate announcements.\n let fieldDOMProps: GroupDOMAttributes;\n if (props[roleSymbol] === 'presentation') {\n fieldDOMProps = {\n role: 'presentation'\n };\n } else {\n fieldDOMProps = mergeProps(fieldProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || undefined,\n 'aria-describedby': describedBy\n });\n }\n\n useEffect(() => {\n if (autoFocusRef.current) {\n focusManager.focusFirst();\n }\n autoFocusRef.current = false;\n }, [focusManager]);\n\n useFormReset(props.inputRef, state.value, state.setValue);\n useFormValidation({\n ...props,\n focus() {\n focusManager.focusFirst();\n }\n }, state, props.inputRef);\n\n let inputProps: InputHTMLAttributes<HTMLInputElement> = {\n type: 'hidden',\n name: props.name,\n value: state.value?.toString() || '',\n disabled: props.isDisabled\n };\n\n if (props.validationBehavior === 'native') {\n // Use a hidden <input type=\"text\"> rather than <input type=\"hidden\">\n // so that an empty value blocks HTML form submission when the field is required.\n inputProps.type = 'text';\n inputProps.hidden = true;\n inputProps.required = props.isRequired;\n // Ignore react warning.\n inputProps.onChange = () => {};\n }\n\n let domProps = filterDOMProps(props);\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: mergeProps(domProps, fieldDOMProps, groupProps, focusWithinProps, {\n onKeyDown(e: KeyboardEvent) {\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n inputProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n\nexport interface AriaTimeFieldOptions<T extends TimeValue> extends AriaTimeFieldProps<T> {\n /** A ref for the hidden input element for HTML form submission. */\n inputRef?: RefObject<HTMLInputElement | null>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a time field component.\n * A time field allows users to enter and edit time values using a keyboard.\n * Each part of a time value is displayed in an individually editable segment.\n */\nexport function useTimeField<T extends TimeValue>(props: AriaTimeFieldOptions<T>, state: TimeFieldState, ref: RefObject<Element | null>): DateFieldAria {\n let res = useDateField(props, state, ref);\n res.inputProps.value = state.timeValue?.toString() || '';\n return res;\n}\n"],"names":[],"version":3,"file":"useDateField.module.js.map"}
|
|
@@ -4,10 +4,10 @@ var $715562ad3b4cced4$exports = require("./useDatePickerGroup.main.js");
|
|
|
4
4
|
var $bxHoL$reactariafocus = require("@react-aria/focus");
|
|
5
5
|
var $bxHoL$reactariautils = require("@react-aria/utils");
|
|
6
6
|
var $bxHoL$reactstatelyform = require("@react-stately/form");
|
|
7
|
-
var $bxHoL$react = require("react");
|
|
8
7
|
var $bxHoL$reactarialabel = require("@react-aria/label");
|
|
9
8
|
var $bxHoL$reactariainteractions = require("@react-aria/interactions");
|
|
10
9
|
var $bxHoL$reactariai18n = require("@react-aria/i18n");
|
|
10
|
+
var $bxHoL$react = require("react");
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
function $parcel$interopDefault(a) {
|
|
@@ -43,28 +43,28 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
43
43
|
let buttonId = (0, $bxHoL$reactariautils.useId)();
|
|
44
44
|
let dialogId = (0, $bxHoL$reactariautils.useId)();
|
|
45
45
|
let fieldId = (0, $bxHoL$reactariautils.useId)();
|
|
46
|
-
let stringFormatter = (0, $bxHoL$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($c1905b78f6d2f5bf$exports))),
|
|
46
|
+
let stringFormatter = (0, $bxHoL$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($c1905b78f6d2f5bf$exports))), '@react-aria/datepicker');
|
|
47
47
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
48
48
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $bxHoL$reactarialabel.useField)({
|
|
49
49
|
...props,
|
|
50
|
-
labelElementType:
|
|
50
|
+
labelElementType: 'span',
|
|
51
51
|
isInvalid: isInvalid,
|
|
52
52
|
errorMessage: props.errorMessage || validationErrors
|
|
53
53
|
});
|
|
54
54
|
let groupProps = (0, $715562ad3b4cced4$exports.useDatePickerGroup)(state, ref);
|
|
55
|
-
let labelledBy = fieldProps[
|
|
55
|
+
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
56
56
|
let { locale: locale } = (0, $bxHoL$reactariai18n.useLocale)();
|
|
57
57
|
let date = state.formatValue(locale, {
|
|
58
|
-
month:
|
|
58
|
+
month: 'long'
|
|
59
59
|
});
|
|
60
|
-
let description = date ? stringFormatter.format(
|
|
60
|
+
let description = date ? stringFormatter.format('selectedDateDescription', {
|
|
61
61
|
date: date
|
|
62
|
-
}) :
|
|
62
|
+
}) : '';
|
|
63
63
|
let descProps = (0, $bxHoL$reactariautils.useDescription)(description);
|
|
64
64
|
let ariaDescribedBy = [
|
|
65
|
-
descProps[
|
|
66
|
-
fieldProps[
|
|
67
|
-
].filter(Boolean).join(
|
|
65
|
+
descProps['aria-describedby'],
|
|
66
|
+
fieldProps['aria-describedby']
|
|
67
|
+
].filter(Boolean).join(' ') || undefined;
|
|
68
68
|
let domProps = (0, $bxHoL$reactariautils.filterDOMProps)(props);
|
|
69
69
|
let focusManager = (0, $bxHoL$react.useMemo)(()=>(0, $bxHoL$reactariafocus.createFocusManager)(ref), [
|
|
70
70
|
ref
|
|
@@ -78,10 +78,10 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
78
78
|
});
|
|
79
79
|
return {
|
|
80
80
|
groupProps: (0, $bxHoL$reactariautils.mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
81
|
-
role:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
role: 'group',
|
|
82
|
+
'aria-disabled': props.isDisabled || null,
|
|
83
|
+
'aria-labelledby': labelledBy,
|
|
84
|
+
'aria-describedby': ariaDescribedBy,
|
|
85
85
|
onKeyDown (e) {
|
|
86
86
|
if (state.isOpen) return;
|
|
87
87
|
if (props.onKeyDown) props.onKeyDown(e);
|
|
@@ -100,8 +100,8 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
100
100
|
fieldProps: {
|
|
101
101
|
...fieldProps,
|
|
102
102
|
id: fieldId,
|
|
103
|
-
[(0, $4acc2f407c169e55$exports.roleSymbol)]:
|
|
104
|
-
|
|
103
|
+
[(0, $4acc2f407c169e55$exports.roleSymbol)]: 'presentation',
|
|
104
|
+
'aria-describedby': ariaDescribedBy,
|
|
105
105
|
value: state.value,
|
|
106
106
|
onChange: state.setValue,
|
|
107
107
|
placeholderValue: props.placeholderValue,
|
|
@@ -123,17 +123,17 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
123
123
|
buttonProps: {
|
|
124
124
|
...descProps,
|
|
125
125
|
id: buttonId,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
'aria-haspopup': 'dialog',
|
|
127
|
+
'aria-label': stringFormatter.format('calendar'),
|
|
128
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
129
|
+
'aria-describedby': ariaDescribedBy,
|
|
130
|
+
'aria-expanded': state.isOpen,
|
|
131
131
|
isDisabled: props.isDisabled || props.isReadOnly,
|
|
132
132
|
onPress: ()=>state.setOpen(true)
|
|
133
133
|
},
|
|
134
134
|
dialogProps: {
|
|
135
135
|
id: dialogId,
|
|
136
|
-
|
|
136
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
137
137
|
},
|
|
138
138
|
calendarProps: {
|
|
139
139
|
autoFocus: true,
|
|
@@ -146,7 +146,7 @@ function $e90ae7c26a69c6b1$export$42df105a73306d51(props, state, ref) {
|
|
|
146
146
|
isDateUnavailable: props.isDateUnavailable,
|
|
147
147
|
defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
|
|
148
148
|
isInvalid: state.isInvalid,
|
|
149
|
-
errorMessage: typeof props.errorMessage ===
|
|
149
|
+
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
|
|
150
150
|
},
|
|
151
151
|
isInvalid: isInvalid,
|
|
152
152
|
validationErrors: validationErrors,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA2CM,SAAS,0CAAmC,KAA6B,EAAE,KAAsB,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA2CM,SAAS,0CAAmC,KAA6B,EAAE,KAAsB,EAAE,GAA8B;IACtI,IAAI,WAAW,CAAA,GAAA,2BAAI;IACnB,IAAI,WAAW,CAAA,GAAA,2BAAI;IACnB,IAAI,UAAU,CAAA,GAAA,2BAAI;IAClB,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE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,YAAY,MAAM,UAAU;YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;QAC9K;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDatePicker.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {CalendarProps} from '@react-types/calendar';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DatePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useDescription, useId} from '@react-aria/utils';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {privateValidationStateProp} from '@react-stately/form';\nimport {roleSymbol} from './useDateField';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo} from 'react';\n\nexport interface DatePickerAria extends ValidationResult {\n /** Props for the date picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date field and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the date field. */\n fieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the calendar within the popover dialog. */\n calendarProps: CalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date picker combines a DateField and a Calendar popover to allow users to enter or select a date and time value.\n */\nexport function useDatePicker<T extends DateValue>(props: AriaDatePickerProps<T>, state: DatePickerState, ref: RefObject<Element | null>): DatePickerAria {\n let buttonId = useId();\n let dialogId = useId();\n let fieldId = useId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let date = state.formatValue(locale, {month: 'long'});\n let description = date ? stringFormatter.format('selectedDateDescription', {date}) : '';\n let descProps = useDescription(description);\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let domProps = filterDOMProps(props);\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: props.onBlur,\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\n });\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n fieldProps: {\n ...fieldProps,\n id: fieldId,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n value: state.value,\n onChange: state.setValue,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n granularity: props.granularity,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior,\n // DatePicker owns the validation state for the date field.\n [privateValidationStateProp]: state,\n autoFocus: props.autoFocus,\n name: props.name\n },\n descriptionProps,\n errorMessageProps,\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n calendarProps: {\n autoFocus: true,\n value: state.dateValue,\n onChange: state.setDateValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' '))\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDatePicker.main.js.map"}
|
package/dist/useDatePicker.mjs
CHANGED
|
@@ -4,10 +4,10 @@ import {useDatePickerGroup as $3dfb0f96be0d6a08$export$4a931266a3838b86} from ".
|
|
|
4
4
|
import {createFocusManager as $4lVjK$createFocusManager} from "@react-aria/focus";
|
|
5
5
|
import {useId as $4lVjK$useId, useDescription as $4lVjK$useDescription, filterDOMProps as $4lVjK$filterDOMProps, mergeProps as $4lVjK$mergeProps} from "@react-aria/utils";
|
|
6
6
|
import {privateValidationStateProp as $4lVjK$privateValidationStateProp} from "@react-stately/form";
|
|
7
|
-
import {useMemo as $4lVjK$useMemo} from "react";
|
|
8
7
|
import {useField as $4lVjK$useField} from "@react-aria/label";
|
|
9
8
|
import {useFocusWithin as $4lVjK$useFocusWithin} from "@react-aria/interactions";
|
|
10
9
|
import {useLocalizedStringFormatter as $4lVjK$useLocalizedStringFormatter, useLocale as $4lVjK$useLocale} from "@react-aria/i18n";
|
|
10
|
+
import {useMemo as $4lVjK$useMemo} from "react";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
function $parcel$interopDefault(a) {
|
|
@@ -37,28 +37,28 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
37
37
|
let buttonId = (0, $4lVjK$useId)();
|
|
38
38
|
let dialogId = (0, $4lVjK$useId)();
|
|
39
39
|
let fieldId = (0, $4lVjK$useId)();
|
|
40
|
-
let stringFormatter = (0, $4lVjK$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4lVjK$intlStringsmodulejs))),
|
|
40
|
+
let stringFormatter = (0, $4lVjK$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4lVjK$intlStringsmodulejs))), '@react-aria/datepicker');
|
|
41
41
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
42
42
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $4lVjK$useField)({
|
|
43
43
|
...props,
|
|
44
|
-
labelElementType:
|
|
44
|
+
labelElementType: 'span',
|
|
45
45
|
isInvalid: isInvalid,
|
|
46
46
|
errorMessage: props.errorMessage || validationErrors
|
|
47
47
|
});
|
|
48
48
|
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
|
|
49
|
-
let labelledBy = fieldProps[
|
|
49
|
+
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
50
50
|
let { locale: locale } = (0, $4lVjK$useLocale)();
|
|
51
51
|
let date = state.formatValue(locale, {
|
|
52
|
-
month:
|
|
52
|
+
month: 'long'
|
|
53
53
|
});
|
|
54
|
-
let description = date ? stringFormatter.format(
|
|
54
|
+
let description = date ? stringFormatter.format('selectedDateDescription', {
|
|
55
55
|
date: date
|
|
56
|
-
}) :
|
|
56
|
+
}) : '';
|
|
57
57
|
let descProps = (0, $4lVjK$useDescription)(description);
|
|
58
58
|
let ariaDescribedBy = [
|
|
59
|
-
descProps[
|
|
60
|
-
fieldProps[
|
|
61
|
-
].filter(Boolean).join(
|
|
59
|
+
descProps['aria-describedby'],
|
|
60
|
+
fieldProps['aria-describedby']
|
|
61
|
+
].filter(Boolean).join(' ') || undefined;
|
|
62
62
|
let domProps = (0, $4lVjK$filterDOMProps)(props);
|
|
63
63
|
let focusManager = (0, $4lVjK$useMemo)(()=>(0, $4lVjK$createFocusManager)(ref), [
|
|
64
64
|
ref
|
|
@@ -72,10 +72,10 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
72
72
|
});
|
|
73
73
|
return {
|
|
74
74
|
groupProps: (0, $4lVjK$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
75
|
-
role:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
role: 'group',
|
|
76
|
+
'aria-disabled': props.isDisabled || null,
|
|
77
|
+
'aria-labelledby': labelledBy,
|
|
78
|
+
'aria-describedby': ariaDescribedBy,
|
|
79
79
|
onKeyDown (e) {
|
|
80
80
|
if (state.isOpen) return;
|
|
81
81
|
if (props.onKeyDown) props.onKeyDown(e);
|
|
@@ -94,8 +94,8 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
94
94
|
fieldProps: {
|
|
95
95
|
...fieldProps,
|
|
96
96
|
id: fieldId,
|
|
97
|
-
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]:
|
|
98
|
-
|
|
97
|
+
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: 'presentation',
|
|
98
|
+
'aria-describedby': ariaDescribedBy,
|
|
99
99
|
value: state.value,
|
|
100
100
|
onChange: state.setValue,
|
|
101
101
|
placeholderValue: props.placeholderValue,
|
|
@@ -117,17 +117,17 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
117
117
|
buttonProps: {
|
|
118
118
|
...descProps,
|
|
119
119
|
id: buttonId,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
120
|
+
'aria-haspopup': 'dialog',
|
|
121
|
+
'aria-label': stringFormatter.format('calendar'),
|
|
122
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
123
|
+
'aria-describedby': ariaDescribedBy,
|
|
124
|
+
'aria-expanded': state.isOpen,
|
|
125
125
|
isDisabled: props.isDisabled || props.isReadOnly,
|
|
126
126
|
onPress: ()=>state.setOpen(true)
|
|
127
127
|
},
|
|
128
128
|
dialogProps: {
|
|
129
129
|
id: dialogId,
|
|
130
|
-
|
|
130
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
131
131
|
},
|
|
132
132
|
calendarProps: {
|
|
133
133
|
autoFocus: true,
|
|
@@ -140,7 +140,7 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
140
140
|
isDateUnavailable: props.isDateUnavailable,
|
|
141
141
|
defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
|
|
142
142
|
isInvalid: state.isInvalid,
|
|
143
|
-
errorMessage: typeof props.errorMessage ===
|
|
143
|
+
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
|
|
144
144
|
},
|
|
145
145
|
isInvalid: isInvalid,
|
|
146
146
|
validationErrors: validationErrors,
|
|
@@ -150,4 +150,4 @@ function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
|
150
150
|
|
|
151
151
|
|
|
152
152
|
export {$6057a3d2a53a12fd$export$42df105a73306d51 as useDatePicker};
|
|
153
|
-
//# sourceMappingURL=useDatePicker.
|
|
153
|
+
//# sourceMappingURL=useDatePicker.module.js.map
|