@react-aria/datepicker 3.10.0 → 3.10.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/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/uk-UA.mjs +1 -1
- package/dist/useDateField.main.js +26 -26
- package/dist/useDateField.mjs +27 -27
- package/dist/useDateField.module.js +26 -26
- package/dist/useDatePicker.main.js +22 -22
- package/dist/useDatePicker.mjs +23 -23
- package/dist/useDatePicker.module.js +22 -22
- package/dist/useDatePickerGroup.main.js +9 -9
- package/dist/useDatePickerGroup.mjs +10 -10
- package/dist/useDatePickerGroup.module.js +9 -9
- package/dist/useDateRangePicker.main.js +27 -27
- package/dist/useDateRangePicker.mjs +28 -28
- package/dist/useDateRangePicker.module.js +27 -27
- package/dist/useDateSegment.main.js +72 -72
- package/dist/useDateSegment.mjs +73 -73
- package/dist/useDateSegment.module.js +72 -72
- 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 +19 -19
|
@@ -35,39 +35,39 @@ function $parcel$interopDefault(a) {
|
|
|
35
35
|
|
|
36
36
|
function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
37
37
|
var _state_value, _state_value1;
|
|
38
|
-
let stringFormatter = (0, $eIQ1H$useLocalizedStringFormatter)((0, ($parcel$interopDefault($eIQ1H$intlStringsmodulejs))),
|
|
38
|
+
let stringFormatter = (0, $eIQ1H$useLocalizedStringFormatter)((0, ($parcel$interopDefault($eIQ1H$intlStringsmodulejs))), '@react-aria/datepicker');
|
|
39
39
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
40
40
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $eIQ1H$useField)({
|
|
41
41
|
...props,
|
|
42
|
-
labelElementType:
|
|
42
|
+
labelElementType: 'span',
|
|
43
43
|
isInvalid: isInvalid,
|
|
44
44
|
errorMessage: props.errorMessage || validationErrors
|
|
45
45
|
});
|
|
46
|
-
let labelledBy = fieldProps[
|
|
46
|
+
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
47
47
|
let { locale: locale } = (0, $eIQ1H$useLocale)();
|
|
48
48
|
let range = state.formatValue(locale, {
|
|
49
|
-
month:
|
|
49
|
+
month: 'long'
|
|
50
50
|
});
|
|
51
|
-
let description = range ? stringFormatter.format(
|
|
51
|
+
let description = range ? stringFormatter.format('selectedRangeDescription', {
|
|
52
52
|
startDate: range.start,
|
|
53
53
|
endDate: range.end
|
|
54
|
-
}) :
|
|
54
|
+
}) : '';
|
|
55
55
|
let descProps = (0, $eIQ1H$useDescription)(description);
|
|
56
56
|
let startFieldProps = {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
'aria-label': stringFormatter.format('startDate'),
|
|
58
|
+
'aria-labelledby': labelledBy
|
|
59
59
|
};
|
|
60
60
|
let endFieldProps = {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
'aria-label': stringFormatter.format('endDate'),
|
|
62
|
+
'aria-labelledby': labelledBy
|
|
63
63
|
};
|
|
64
64
|
let buttonId = (0, $eIQ1H$useId)();
|
|
65
65
|
let dialogId = (0, $eIQ1H$useId)();
|
|
66
66
|
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
|
|
67
67
|
let ariaDescribedBy = [
|
|
68
|
-
descProps[
|
|
69
|
-
fieldProps[
|
|
70
|
-
].filter(Boolean).join(
|
|
68
|
+
descProps['aria-describedby'],
|
|
69
|
+
fieldProps['aria-describedby']
|
|
70
|
+
].filter(Boolean).join(' ') || undefined;
|
|
71
71
|
let focusManager = (0, $eIQ1H$useMemo)(()=>(0, $eIQ1H$createFocusManager)(ref, {
|
|
72
72
|
// Exclude the button from the focus manager.
|
|
73
73
|
accept: (element)=>element.id !== buttonId
|
|
@@ -77,8 +77,8 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
77
77
|
]);
|
|
78
78
|
let commonFieldProps = {
|
|
79
79
|
[(0, $16f0b7bb276bc17e$export$7b3062cd49e80452)]: focusManager,
|
|
80
|
-
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]:
|
|
81
|
-
|
|
80
|
+
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: 'presentation',
|
|
81
|
+
'aria-describedby': ariaDescribedBy,
|
|
82
82
|
placeholderValue: props.placeholderValue,
|
|
83
83
|
hideTimeZone: props.hideTimeZone,
|
|
84
84
|
hourCycle: props.hourCycle,
|
|
@@ -101,9 +101,9 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
101
101
|
let endFieldValidation = (0, $eIQ1H$useRef)((0, $eIQ1H$DEFAULT_VALIDATION_RESULT));
|
|
102
102
|
return {
|
|
103
103
|
groupProps: (0, $eIQ1H$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
104
|
-
role:
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
role: 'group',
|
|
105
|
+
'aria-disabled': props.isDisabled || null,
|
|
106
|
+
'aria-describedby': ariaDescribedBy,
|
|
107
107
|
onKeyDown (e) {
|
|
108
108
|
if (state.isOpen) return;
|
|
109
109
|
if (props.onKeyDown) props.onKeyDown(e);
|
|
@@ -122,23 +122,23 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
122
122
|
buttonProps: {
|
|
123
123
|
...descProps,
|
|
124
124
|
id: buttonId,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
'aria-haspopup': 'dialog',
|
|
126
|
+
'aria-label': stringFormatter.format('calendar'),
|
|
127
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
128
|
+
'aria-describedby': ariaDescribedBy,
|
|
129
|
+
'aria-expanded': state.isOpen,
|
|
130
130
|
isDisabled: props.isDisabled || props.isReadOnly,
|
|
131
131
|
onPress: ()=>state.setOpen(true)
|
|
132
132
|
},
|
|
133
133
|
dialogProps: {
|
|
134
134
|
id: dialogId,
|
|
135
|
-
|
|
135
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
136
136
|
},
|
|
137
137
|
startFieldProps: {
|
|
138
138
|
...startFieldProps,
|
|
139
139
|
...commonFieldProps,
|
|
140
140
|
value: (_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.start,
|
|
141
|
-
onChange: (start)=>state.setDateTime(
|
|
141
|
+
onChange: (start)=>state.setDateTime('start', start),
|
|
142
142
|
autoFocus: props.autoFocus,
|
|
143
143
|
name: props.startName,
|
|
144
144
|
[(0, $eIQ1H$privateValidationStateProp)]: {
|
|
@@ -156,7 +156,7 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
156
156
|
...endFieldProps,
|
|
157
157
|
...commonFieldProps,
|
|
158
158
|
value: (_state_value1 = state.value) === null || _state_value1 === void 0 ? void 0 : _state_value1.end,
|
|
159
|
-
onChange: (end)=>state.setDateTime(
|
|
159
|
+
onChange: (end)=>state.setDateTime('end', end),
|
|
160
160
|
name: props.endName,
|
|
161
161
|
[(0, $eIQ1H$privateValidationStateProp)]: {
|
|
162
162
|
realtimeValidation: state.realtimeValidation,
|
|
@@ -183,7 +183,7 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
183
183
|
allowsNonContiguousRanges: props.allowsNonContiguousRanges,
|
|
184
184
|
defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
|
|
185
185
|
isInvalid: state.isInvalid,
|
|
186
|
-
errorMessage: typeof props.errorMessage ===
|
|
186
|
+
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
|
|
187
187
|
},
|
|
188
188
|
isInvalid: isInvalid,
|
|
189
189
|
validationErrors: validationErrors,
|
|
@@ -193,4 +193,4 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
193
193
|
|
|
194
194
|
|
|
195
195
|
export {$887cac91b7cc8801$export$12fd5f0e9f4bb192 as useDateRangePicker};
|
|
196
|
-
//# sourceMappingURL=useDateRangePicker.
|
|
196
|
+
//# sourceMappingURL=useDateRangePicker.module.js.map
|
|
@@ -35,39 +35,39 @@ function $parcel$interopDefault(a) {
|
|
|
35
35
|
|
|
36
36
|
function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
37
37
|
var _state_value, _state_value1;
|
|
38
|
-
let stringFormatter = (0, $eIQ1H$useLocalizedStringFormatter)((0, ($parcel$interopDefault($eIQ1H$intlStringsmodulejs))),
|
|
38
|
+
let stringFormatter = (0, $eIQ1H$useLocalizedStringFormatter)((0, ($parcel$interopDefault($eIQ1H$intlStringsmodulejs))), '@react-aria/datepicker');
|
|
39
39
|
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
40
40
|
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $eIQ1H$useField)({
|
|
41
41
|
...props,
|
|
42
|
-
labelElementType:
|
|
42
|
+
labelElementType: 'span',
|
|
43
43
|
isInvalid: isInvalid,
|
|
44
44
|
errorMessage: props.errorMessage || validationErrors
|
|
45
45
|
});
|
|
46
|
-
let labelledBy = fieldProps[
|
|
46
|
+
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
47
47
|
let { locale: locale } = (0, $eIQ1H$useLocale)();
|
|
48
48
|
let range = state.formatValue(locale, {
|
|
49
|
-
month:
|
|
49
|
+
month: 'long'
|
|
50
50
|
});
|
|
51
|
-
let description = range ? stringFormatter.format(
|
|
51
|
+
let description = range ? stringFormatter.format('selectedRangeDescription', {
|
|
52
52
|
startDate: range.start,
|
|
53
53
|
endDate: range.end
|
|
54
|
-
}) :
|
|
54
|
+
}) : '';
|
|
55
55
|
let descProps = (0, $eIQ1H$useDescription)(description);
|
|
56
56
|
let startFieldProps = {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
'aria-label': stringFormatter.format('startDate'),
|
|
58
|
+
'aria-labelledby': labelledBy
|
|
59
59
|
};
|
|
60
60
|
let endFieldProps = {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
'aria-label': stringFormatter.format('endDate'),
|
|
62
|
+
'aria-labelledby': labelledBy
|
|
63
63
|
};
|
|
64
64
|
let buttonId = (0, $eIQ1H$useId)();
|
|
65
65
|
let dialogId = (0, $eIQ1H$useId)();
|
|
66
66
|
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
|
|
67
67
|
let ariaDescribedBy = [
|
|
68
|
-
descProps[
|
|
69
|
-
fieldProps[
|
|
70
|
-
].filter(Boolean).join(
|
|
68
|
+
descProps['aria-describedby'],
|
|
69
|
+
fieldProps['aria-describedby']
|
|
70
|
+
].filter(Boolean).join(' ') || undefined;
|
|
71
71
|
let focusManager = (0, $eIQ1H$useMemo)(()=>(0, $eIQ1H$createFocusManager)(ref, {
|
|
72
72
|
// Exclude the button from the focus manager.
|
|
73
73
|
accept: (element)=>element.id !== buttonId
|
|
@@ -77,8 +77,8 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
77
77
|
]);
|
|
78
78
|
let commonFieldProps = {
|
|
79
79
|
[(0, $16f0b7bb276bc17e$export$7b3062cd49e80452)]: focusManager,
|
|
80
|
-
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]:
|
|
81
|
-
|
|
80
|
+
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: 'presentation',
|
|
81
|
+
'aria-describedby': ariaDescribedBy,
|
|
82
82
|
placeholderValue: props.placeholderValue,
|
|
83
83
|
hideTimeZone: props.hideTimeZone,
|
|
84
84
|
hourCycle: props.hourCycle,
|
|
@@ -101,9 +101,9 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
101
101
|
let endFieldValidation = (0, $eIQ1H$useRef)((0, $eIQ1H$DEFAULT_VALIDATION_RESULT));
|
|
102
102
|
return {
|
|
103
103
|
groupProps: (0, $eIQ1H$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
104
|
-
role:
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
role: 'group',
|
|
105
|
+
'aria-disabled': props.isDisabled || null,
|
|
106
|
+
'aria-describedby': ariaDescribedBy,
|
|
107
107
|
onKeyDown (e) {
|
|
108
108
|
if (state.isOpen) return;
|
|
109
109
|
if (props.onKeyDown) props.onKeyDown(e);
|
|
@@ -122,23 +122,23 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
122
122
|
buttonProps: {
|
|
123
123
|
...descProps,
|
|
124
124
|
id: buttonId,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
'aria-haspopup': 'dialog',
|
|
126
|
+
'aria-label': stringFormatter.format('calendar'),
|
|
127
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
128
|
+
'aria-describedby': ariaDescribedBy,
|
|
129
|
+
'aria-expanded': state.isOpen,
|
|
130
130
|
isDisabled: props.isDisabled || props.isReadOnly,
|
|
131
131
|
onPress: ()=>state.setOpen(true)
|
|
132
132
|
},
|
|
133
133
|
dialogProps: {
|
|
134
134
|
id: dialogId,
|
|
135
|
-
|
|
135
|
+
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
136
136
|
},
|
|
137
137
|
startFieldProps: {
|
|
138
138
|
...startFieldProps,
|
|
139
139
|
...commonFieldProps,
|
|
140
140
|
value: (_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.start,
|
|
141
|
-
onChange: (start)=>state.setDateTime(
|
|
141
|
+
onChange: (start)=>state.setDateTime('start', start),
|
|
142
142
|
autoFocus: props.autoFocus,
|
|
143
143
|
name: props.startName,
|
|
144
144
|
[(0, $eIQ1H$privateValidationStateProp)]: {
|
|
@@ -156,7 +156,7 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
156
156
|
...endFieldProps,
|
|
157
157
|
...commonFieldProps,
|
|
158
158
|
value: (_state_value1 = state.value) === null || _state_value1 === void 0 ? void 0 : _state_value1.end,
|
|
159
|
-
onChange: (end)=>state.setDateTime(
|
|
159
|
+
onChange: (end)=>state.setDateTime('end', end),
|
|
160
160
|
name: props.endName,
|
|
161
161
|
[(0, $eIQ1H$privateValidationStateProp)]: {
|
|
162
162
|
realtimeValidation: state.realtimeValidation,
|
|
@@ -183,7 +183,7 @@ function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
|
183
183
|
allowsNonContiguousRanges: props.allowsNonContiguousRanges,
|
|
184
184
|
defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
|
|
185
185
|
isInvalid: state.isInvalid,
|
|
186
|
-
errorMessage: typeof props.errorMessage ===
|
|
186
|
+
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' ')
|
|
187
187
|
},
|
|
188
188
|
isInvalid: isInvalid,
|
|
189
189
|
validationErrors: validationErrors,
|
|
@@ -36,27 +36,27 @@ $parcel$export(module.exports, "useDateSegment", () => $5c015c6316d1904d$export$
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
39
|
-
let enteredKeys = (0, $5Tgzj$react.useRef)(
|
|
39
|
+
let enteredKeys = (0, $5Tgzj$react.useRef)('');
|
|
40
40
|
let { locale: locale } = (0, $5Tgzj$reactariai18n.useLocale)();
|
|
41
41
|
let displayNames = (0, $934ac650a0aceb4b$exports.useDisplayNames)();
|
|
42
42
|
let { ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy, ariaDescribedBy: ariaDescribedBy, focusManager: focusManager } = (0, $4acc2f407c169e55$exports.hookData).get(state);
|
|
43
|
-
let textValue = segment.isPlaceholder ?
|
|
43
|
+
let textValue = segment.isPlaceholder ? '' : segment.text;
|
|
44
44
|
let options = (0, $5Tgzj$react.useMemo)(()=>state.dateFormatter.resolvedOptions(), [
|
|
45
45
|
state.dateFormatter
|
|
46
46
|
]);
|
|
47
47
|
let monthDateFormatter = (0, $5Tgzj$reactariai18n.useDateFormatter)({
|
|
48
|
-
month:
|
|
48
|
+
month: 'long',
|
|
49
49
|
timeZone: options.timeZone
|
|
50
50
|
});
|
|
51
51
|
let hourDateFormatter = (0, $5Tgzj$reactariai18n.useDateFormatter)({
|
|
52
|
-
hour:
|
|
52
|
+
hour: 'numeric',
|
|
53
53
|
hour12: options.hour12,
|
|
54
54
|
timeZone: options.timeZone
|
|
55
55
|
});
|
|
56
|
-
if (segment.type ===
|
|
56
|
+
if (segment.type === 'month' && !segment.isPlaceholder) {
|
|
57
57
|
let monthTextValue = monthDateFormatter.format(state.dateValue);
|
|
58
58
|
textValue = monthTextValue !== textValue ? `${textValue} \u{2013} ${monthTextValue}` : monthTextValue;
|
|
59
|
-
} else if (segment.type ===
|
|
59
|
+
} else if (segment.type === 'hour' && !segment.isPlaceholder) textValue = hourDateFormatter.format(state.dateValue);
|
|
60
60
|
let { spinButtonProps: spinButtonProps } = (0, $5Tgzj$reactariaspinbutton.useSpinButton)({
|
|
61
61
|
// The ARIA spec says aria-valuenow is optional if there's no value, but aXe seems to require it.
|
|
62
62
|
// This doesn't seem to have any negative effects with real AT since we also use aria-valuetext.
|
|
@@ -69,27 +69,27 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
69
69
|
isReadOnly: state.isReadOnly || !segment.isEditable,
|
|
70
70
|
isRequired: state.isRequired,
|
|
71
71
|
onIncrement: ()=>{
|
|
72
|
-
enteredKeys.current =
|
|
72
|
+
enteredKeys.current = '';
|
|
73
73
|
state.increment(segment.type);
|
|
74
74
|
},
|
|
75
75
|
onDecrement: ()=>{
|
|
76
|
-
enteredKeys.current =
|
|
76
|
+
enteredKeys.current = '';
|
|
77
77
|
state.decrement(segment.type);
|
|
78
78
|
},
|
|
79
79
|
onIncrementPage: ()=>{
|
|
80
|
-
enteredKeys.current =
|
|
80
|
+
enteredKeys.current = '';
|
|
81
81
|
state.incrementPage(segment.type);
|
|
82
82
|
},
|
|
83
83
|
onDecrementPage: ()=>{
|
|
84
|
-
enteredKeys.current =
|
|
84
|
+
enteredKeys.current = '';
|
|
85
85
|
state.decrementPage(segment.type);
|
|
86
86
|
},
|
|
87
87
|
onIncrementToMax: ()=>{
|
|
88
|
-
enteredKeys.current =
|
|
88
|
+
enteredKeys.current = '';
|
|
89
89
|
state.setSegment(segment.type, segment.maxValue);
|
|
90
90
|
},
|
|
91
91
|
onDecrementToMin: ()=>{
|
|
92
|
-
enteredKeys.current =
|
|
92
|
+
enteredKeys.current = '';
|
|
93
93
|
state.setSegment(segment.type, segment.minValue);
|
|
94
94
|
}
|
|
95
95
|
});
|
|
@@ -103,20 +103,20 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
103
103
|
if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly && !segment.isPlaceholder) {
|
|
104
104
|
let newValue = segment.text.slice(0, -1);
|
|
105
105
|
let parsed = parser.parse(newValue);
|
|
106
|
-
newValue = parsed === 0 ?
|
|
106
|
+
newValue = parsed === 0 ? '' : newValue;
|
|
107
107
|
if (newValue.length === 0 || parsed === 0) state.clearSegment(segment.type);
|
|
108
108
|
else state.setSegment(segment.type, parsed);
|
|
109
109
|
enteredKeys.current = newValue;
|
|
110
|
-
} else if (segment.type ===
|
|
110
|
+
} else if (segment.type === 'dayPeriod') state.clearSegment(segment.type);
|
|
111
111
|
};
|
|
112
112
|
let onKeyDown = (e)=>{
|
|
113
113
|
// Firefox does not fire selectstart for Ctrl/Cmd + A
|
|
114
114
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=1742153
|
|
115
|
-
if (e.key ===
|
|
115
|
+
if (e.key === 'a' && ((0, $5Tgzj$reactariautils.isMac)() ? e.metaKey : e.ctrlKey)) e.preventDefault();
|
|
116
116
|
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return;
|
|
117
117
|
switch(e.key){
|
|
118
|
-
case
|
|
119
|
-
case
|
|
118
|
+
case 'Backspace':
|
|
119
|
+
case 'Delete':
|
|
120
120
|
// Safari on iOS does not fire beforeinput for the backspace key because the cursor is at the start.
|
|
121
121
|
e.preventDefault();
|
|
122
122
|
e.stopPropagation();
|
|
@@ -126,34 +126,34 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
126
126
|
};
|
|
127
127
|
// Safari dayPeriod option doesn't work...
|
|
128
128
|
let { startsWith: startsWith } = (0, $5Tgzj$reactariai18n.useFilter)({
|
|
129
|
-
sensitivity:
|
|
129
|
+
sensitivity: 'base'
|
|
130
130
|
});
|
|
131
131
|
let amPmFormatter = (0, $5Tgzj$reactariai18n.useDateFormatter)({
|
|
132
|
-
hour:
|
|
132
|
+
hour: 'numeric',
|
|
133
133
|
hour12: true
|
|
134
134
|
});
|
|
135
135
|
let am = (0, $5Tgzj$react.useMemo)(()=>{
|
|
136
136
|
let date = new Date();
|
|
137
137
|
date.setHours(0);
|
|
138
|
-
return amPmFormatter.formatToParts(date).find((part)=>part.type ===
|
|
138
|
+
return amPmFormatter.formatToParts(date).find((part)=>part.type === 'dayPeriod').value;
|
|
139
139
|
}, [
|
|
140
140
|
amPmFormatter
|
|
141
141
|
]);
|
|
142
142
|
let pm = (0, $5Tgzj$react.useMemo)(()=>{
|
|
143
143
|
let date = new Date();
|
|
144
144
|
date.setHours(12);
|
|
145
|
-
return amPmFormatter.formatToParts(date).find((part)=>part.type ===
|
|
145
|
+
return amPmFormatter.formatToParts(date).find((part)=>part.type === 'dayPeriod').value;
|
|
146
146
|
}, [
|
|
147
147
|
amPmFormatter
|
|
148
148
|
]);
|
|
149
149
|
// Get a list of formatted era names so users can type the first character to choose one.
|
|
150
150
|
let eraFormatter = (0, $5Tgzj$reactariai18n.useDateFormatter)({
|
|
151
|
-
year:
|
|
152
|
-
era:
|
|
153
|
-
timeZone:
|
|
151
|
+
year: 'numeric',
|
|
152
|
+
era: 'narrow',
|
|
153
|
+
timeZone: 'UTC'
|
|
154
154
|
});
|
|
155
155
|
let eras = (0, $5Tgzj$react.useMemo)(()=>{
|
|
156
|
-
if (segment.type !==
|
|
156
|
+
if (segment.type !== 'era') return [];
|
|
157
157
|
let date = (0, $5Tgzj$internationalizeddate.toCalendar)(new (0, $5Tgzj$internationalizeddate.CalendarDate)(1, 1, 1), state.calendar);
|
|
158
158
|
let eras = state.calendar.getEras().map((era)=>{
|
|
159
159
|
let eraDate = date.set({
|
|
@@ -161,9 +161,9 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
161
161
|
month: 1,
|
|
162
162
|
day: 1,
|
|
163
163
|
era: era
|
|
164
|
-
}).toDate(
|
|
164
|
+
}).toDate('UTC');
|
|
165
165
|
let parts = eraFormatter.formatToParts(eraDate);
|
|
166
|
-
let formatted = parts.find((p)=>p.type ===
|
|
166
|
+
let formatted = parts.find((p)=>p.type === 'era').value;
|
|
167
167
|
return {
|
|
168
168
|
era: era,
|
|
169
169
|
formatted: formatted
|
|
@@ -184,38 +184,38 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
184
184
|
if (state.isDisabled || state.isReadOnly) return;
|
|
185
185
|
let newValue = enteredKeys.current + key;
|
|
186
186
|
switch(segment.type){
|
|
187
|
-
case
|
|
188
|
-
if (startsWith(am, key)) state.setSegment(
|
|
189
|
-
else if (startsWith(pm, key)) state.setSegment(
|
|
187
|
+
case 'dayPeriod':
|
|
188
|
+
if (startsWith(am, key)) state.setSegment('dayPeriod', 0);
|
|
189
|
+
else if (startsWith(pm, key)) state.setSegment('dayPeriod', 12);
|
|
190
190
|
else break;
|
|
191
191
|
focusManager.focusNext();
|
|
192
192
|
break;
|
|
193
|
-
case
|
|
193
|
+
case 'era':
|
|
194
194
|
{
|
|
195
195
|
let matched = eras.find((e)=>startsWith(e.formatted, key));
|
|
196
196
|
if (matched) {
|
|
197
|
-
state.setSegment(
|
|
197
|
+
state.setSegment('era', matched.era);
|
|
198
198
|
focusManager.focusNext();
|
|
199
199
|
}
|
|
200
200
|
break;
|
|
201
201
|
}
|
|
202
|
-
case
|
|
203
|
-
case
|
|
204
|
-
case
|
|
205
|
-
case
|
|
206
|
-
case
|
|
207
|
-
case
|
|
202
|
+
case 'day':
|
|
203
|
+
case 'hour':
|
|
204
|
+
case 'minute':
|
|
205
|
+
case 'second':
|
|
206
|
+
case 'month':
|
|
207
|
+
case 'year':
|
|
208
208
|
{
|
|
209
209
|
if (!parser.isValidPartialNumber(newValue)) return;
|
|
210
210
|
let numberValue = parser.parse(newValue);
|
|
211
211
|
let segmentValue = numberValue;
|
|
212
212
|
let allowsZero = segment.minValue === 0;
|
|
213
|
-
if (segment.type ===
|
|
213
|
+
if (segment.type === 'hour' && state.dateFormatter.resolvedOptions().hour12) {
|
|
214
214
|
switch(state.dateFormatter.resolvedOptions().hourCycle){
|
|
215
|
-
case
|
|
215
|
+
case 'h11':
|
|
216
216
|
if (numberValue > 11) segmentValue = parser.parse(key);
|
|
217
217
|
break;
|
|
218
|
-
case
|
|
218
|
+
case 'h12':
|
|
219
219
|
allowsZero = false;
|
|
220
220
|
if (numberValue > 12) segmentValue = parser.parse(key);
|
|
221
221
|
break;
|
|
@@ -225,8 +225,8 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
225
225
|
if (isNaN(numberValue)) return;
|
|
226
226
|
let shouldSetValue = segmentValue !== 0 || allowsZero;
|
|
227
227
|
if (shouldSetValue) state.setSegment(segment.type, segmentValue);
|
|
228
|
-
if (Number(numberValue +
|
|
229
|
-
enteredKeys.current =
|
|
228
|
+
if (Number(numberValue + '0') > segment.maxValue || newValue.length >= String(segment.maxValue).length) {
|
|
229
|
+
enteredKeys.current = '';
|
|
230
230
|
if (shouldSetValue) focusManager.focusNext();
|
|
231
231
|
} else enteredKeys.current = newValue;
|
|
232
232
|
break;
|
|
@@ -234,7 +234,7 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
236
|
let onFocus = ()=>{
|
|
237
|
-
enteredKeys.current =
|
|
237
|
+
enteredKeys.current = '';
|
|
238
238
|
(0, $5Tgzj$reactariautils.scrollIntoViewport)(ref.current, {
|
|
239
239
|
containingElement: (0, $5Tgzj$reactariautils.getScrollParent)(ref.current)
|
|
240
240
|
});
|
|
@@ -242,16 +242,16 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
242
242
|
let selection = window.getSelection();
|
|
243
243
|
selection.collapse(ref.current);
|
|
244
244
|
};
|
|
245
|
-
let compositionRef = (0, $5Tgzj$react.useRef)(
|
|
245
|
+
let compositionRef = (0, $5Tgzj$react.useRef)('');
|
|
246
246
|
// @ts-ignore - TODO: possibly old TS version? doesn't fail in my editor...
|
|
247
|
-
(0, $5Tgzj$reactariautils.useEvent)(ref,
|
|
247
|
+
(0, $5Tgzj$reactariautils.useEvent)(ref, 'beforeinput', (e)=>{
|
|
248
248
|
e.preventDefault();
|
|
249
249
|
switch(e.inputType){
|
|
250
|
-
case
|
|
251
|
-
case
|
|
250
|
+
case 'deleteContentBackward':
|
|
251
|
+
case 'deleteContentForward':
|
|
252
252
|
if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly) backspace();
|
|
253
253
|
break;
|
|
254
|
-
case
|
|
254
|
+
case 'insertCompositionText':
|
|
255
255
|
// insertCompositionText cannot be canceled.
|
|
256
256
|
// Record the current state of the element so we can restore it in the `input` event below.
|
|
257
257
|
compositionRef.current = ref.current.textContent;
|
|
@@ -264,10 +264,10 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
264
264
|
break;
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
|
-
(0, $5Tgzj$reactariautils.useEvent)(ref,
|
|
267
|
+
(0, $5Tgzj$reactariautils.useEvent)(ref, 'input', (e)=>{
|
|
268
268
|
let { inputType: inputType, data: data } = e;
|
|
269
269
|
switch(inputType){
|
|
270
|
-
case
|
|
270
|
+
case 'insertCompositionText':
|
|
271
271
|
// Reset the DOM to how it was in the beforeinput event.
|
|
272
272
|
ref.current.textContent = compositionRef.current;
|
|
273
273
|
// Android sometimes fires key presses of letters as composition events. Need to handle am/pm keys here too.
|
|
@@ -290,12 +290,12 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
290
290
|
focusManager
|
|
291
291
|
]);
|
|
292
292
|
// spinbuttons cannot be focused with VoiceOver on iOS.
|
|
293
|
-
let touchPropOverrides = (0, $5Tgzj$reactariautils.isIOS)() || segment.type ===
|
|
294
|
-
role:
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
293
|
+
let touchPropOverrides = (0, $5Tgzj$reactariautils.isIOS)() || segment.type === 'timeZoneName' ? {
|
|
294
|
+
role: 'textbox',
|
|
295
|
+
'aria-valuemax': null,
|
|
296
|
+
'aria-valuemin': null,
|
|
297
|
+
'aria-valuetext': null,
|
|
298
|
+
'aria-valuenow': null
|
|
299
299
|
} : {};
|
|
300
300
|
// Only apply aria-describedby to the first segment, unless the field is invalid. This avoids it being
|
|
301
301
|
// read every time the user navigates to a new segment.
|
|
@@ -307,39 +307,39 @@ function $5c015c6316d1904d$export$1315d136e6f7581(segment, state, ref) {
|
|
|
307
307
|
let isEditable = !state.isDisabled && !state.isReadOnly && segment.isEditable;
|
|
308
308
|
// Prepend the label passed from the field to each segment name.
|
|
309
309
|
// This is needed because VoiceOver on iOS does not announce groups.
|
|
310
|
-
let name = segment.type ===
|
|
310
|
+
let name = segment.type === 'literal' ? '' : displayNames.of(segment.type);
|
|
311
311
|
let labelProps = (0, $5Tgzj$reactariautils.useLabels)({
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
'aria-label': `${name}${ariaLabel ? `, ${ariaLabel}` : ''}${ariaLabelledBy ? ', ' : ''}`,
|
|
313
|
+
'aria-labelledby': ariaLabelledBy
|
|
314
314
|
});
|
|
315
315
|
// Literal segments should not be visible to screen readers. We don't really need any of the above,
|
|
316
316
|
// but the rules of hooks mean hooks cannot be conditional so we have to put this condition here.
|
|
317
|
-
if (segment.type ===
|
|
317
|
+
if (segment.type === 'literal') return {
|
|
318
318
|
segmentProps: {
|
|
319
|
-
|
|
319
|
+
'aria-hidden': true
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
return {
|
|
323
323
|
segmentProps: (0, $5Tgzj$reactariautils.mergeProps)(spinButtonProps, labelProps, {
|
|
324
324
|
id: id,
|
|
325
325
|
...touchPropOverrides,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
326
|
+
'aria-invalid': state.isInvalid ? 'true' : undefined,
|
|
327
|
+
'aria-describedby': ariaDescribedBy,
|
|
328
|
+
'aria-readonly': state.isReadOnly || !segment.isEditable ? 'true' : undefined,
|
|
329
|
+
'data-placeholder': segment.isPlaceholder || undefined,
|
|
330
330
|
contentEditable: isEditable,
|
|
331
331
|
suppressContentEditableWarning: isEditable,
|
|
332
|
-
spellCheck: isEditable ?
|
|
333
|
-
autoCapitalize: isEditable ?
|
|
334
|
-
autoCorrect: isEditable ?
|
|
332
|
+
spellCheck: isEditable ? 'false' : undefined,
|
|
333
|
+
autoCapitalize: isEditable ? 'off' : undefined,
|
|
334
|
+
autoCorrect: isEditable ? 'off' : undefined,
|
|
335
335
|
// Capitalization was changed in React 17...
|
|
336
|
-
[parseInt((0, ($parcel$interopDefault($5Tgzj$react))).version, 10) >= 17 ?
|
|
337
|
-
inputMode: state.isDisabled || segment.type ===
|
|
336
|
+
[parseInt((0, ($parcel$interopDefault($5Tgzj$react))).version, 10) >= 17 ? 'enterKeyHint' : 'enterkeyhint']: isEditable ? 'next' : undefined,
|
|
337
|
+
inputMode: state.isDisabled || segment.type === 'dayPeriod' || segment.type === 'era' || !isEditable ? undefined : 'numeric',
|
|
338
338
|
tabIndex: state.isDisabled ? undefined : 0,
|
|
339
339
|
onKeyDown: onKeyDown,
|
|
340
340
|
onFocus: onFocus,
|
|
341
341
|
style: {
|
|
342
|
-
caretColor:
|
|
342
|
+
caretColor: 'transparent'
|
|
343
343
|
},
|
|
344
344
|
// Prevent pointer events from reaching useDatePickerGroup, and allow native browser behavior to focus the segment.
|
|
345
345
|
onPointerDown (e) {
|