@react-aria/datepicker 3.16.0 → 3.17.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/import.mjs +6 -6
- package/dist/main.js +11 -11
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -6
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +12 -0
- package/package.json +16 -28
- package/src/index.ts +13 -11
- package/dist/ar-AE.main.js +0 -21
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -23
- package/dist/ar-AE.module.js +0 -23
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -21
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -23
- package/dist/bg-BG.module.js +0 -23
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -21
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -23
- package/dist/cs-CZ.module.js +0 -23
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -21
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -23
- package/dist/da-DK.module.js +0 -23
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -21
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -23
- package/dist/de-DE.module.js +0 -23
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -21
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -23
- package/dist/el-GR.module.js +0 -23
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -21
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -23
- package/dist/en-US.module.js +0 -23
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -21
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -23
- package/dist/es-ES.module.js +0 -23
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -21
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -23
- package/dist/et-EE.module.js +0 -23
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -21
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -23
- package/dist/fi-FI.module.js +0 -23
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -21
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -23
- package/dist/fr-FR.module.js +0 -23
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -21
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -23
- package/dist/he-IL.module.js +0 -23
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -21
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -23
- package/dist/hr-HR.module.js +0 -23
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -21
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -23
- package/dist/hu-HU.module.js +0 -23
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -21
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -23
- package/dist/it-IT.module.js +0 -23
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -21
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -23
- package/dist/ja-JP.module.js +0 -23
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -21
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -23
- package/dist/ko-KR.module.js +0 -23
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -21
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -23
- package/dist/lt-LT.module.js +0 -23
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -21
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -23
- package/dist/lv-LV.module.js +0 -23
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -21
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -23
- package/dist/nb-NO.module.js +0 -23
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -21
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -23
- package/dist/nl-NL.module.js +0 -23
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -21
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -23
- package/dist/pl-PL.module.js +0 -23
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -21
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -23
- package/dist/pt-BR.module.js +0 -23
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -21
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -23
- package/dist/pt-PT.module.js +0 -23
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -21
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -23
- package/dist/ro-RO.module.js +0 -23
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -21
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -23
- package/dist/ru-RU.module.js +0 -23
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -21
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -23
- package/dist/sk-SK.module.js +0 -23
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -21
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -23
- package/dist/sl-SI.module.js +0 -23
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -21
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -23
- package/dist/sr-SP.module.js +0 -23
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -21
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -23
- package/dist/sv-SE.module.js +0 -23
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -21
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -23
- package/dist/tr-TR.module.js +0 -23
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -108
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -21
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -23
- package/dist/uk-UA.module.js +0 -23
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useDateField.main.js +0 -181
- package/dist/useDateField.main.js.map +0 -1
- package/dist/useDateField.mjs +0 -172
- package/dist/useDateField.module.js +0 -172
- package/dist/useDateField.module.js.map +0 -1
- package/dist/useDatePicker.main.js +0 -178
- package/dist/useDatePicker.main.js.map +0 -1
- package/dist/useDatePicker.mjs +0 -173
- package/dist/useDatePicker.module.js +0 -173
- package/dist/useDatePicker.module.js.map +0 -1
- package/dist/useDatePickerGroup.main.js +0 -121
- package/dist/useDatePickerGroup.main.js.map +0 -1
- package/dist/useDatePickerGroup.mjs +0 -116
- package/dist/useDatePickerGroup.module.js +0 -116
- package/dist/useDatePickerGroup.module.js.map +0 -1
- package/dist/useDateRangePicker.main.js +0 -224
- package/dist/useDateRangePicker.main.js.map +0 -1
- package/dist/useDateRangePicker.mjs +0 -219
- package/dist/useDateRangePicker.module.js +0 -219
- package/dist/useDateRangePicker.module.js.map +0 -1
- package/dist/useDateSegment.main.js +0 -370
- package/dist/useDateSegment.main.js.map +0 -1
- package/dist/useDateSegment.mjs +0 -361
- package/dist/useDateSegment.module.js +0 -361
- package/dist/useDateSegment.module.js.map +0 -1
- package/dist/useDisplayNames.main.js +0 -58
- package/dist/useDisplayNames.main.js.map +0 -1
- package/dist/useDisplayNames.mjs +0 -53
- package/dist/useDisplayNames.module.js +0 -53
- package/dist/useDisplayNames.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -21
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -23
- package/dist/zh-CN.module.js +0 -23
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -21
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -23
- package/dist/zh-TW.module.js +0 -23
- package/dist/zh-TW.module.js.map +0 -1
- package/src/useDateField.ts +0 -213
- package/src/useDatePicker.ts +0 -192
- package/src/useDatePickerGroup.ts +0 -138
- package/src/useDateRangePicker.ts +0 -243
- package/src/useDateSegment.ts +0 -413
- package/src/useDisplayNames.ts +0 -51
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import $4lVjK$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
-
import {roleSymbol as $16f0b7bb276bc17e$export$300019f83c56d282} from "./useDateField.module.js";
|
|
3
|
-
import {useDatePickerGroup as $3dfb0f96be0d6a08$export$4a931266a3838b86} from "./useDatePickerGroup.module.js";
|
|
4
|
-
import {createFocusManager as $4lVjK$createFocusManager} from "@react-aria/focus";
|
|
5
|
-
import {useId as $4lVjK$useId, useDescription as $4lVjK$useDescription, filterDOMProps as $4lVjK$filterDOMProps, nodeContains as $4lVjK$nodeContains, mergeProps as $4lVjK$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {privateValidationStateProp as $4lVjK$privateValidationStateProp} from "@react-stately/form";
|
|
7
|
-
import {useField as $4lVjK$useField} from "@react-aria/label";
|
|
8
|
-
import {useFocusWithin as $4lVjK$useFocusWithin} from "@react-aria/interactions";
|
|
9
|
-
import {useLocalizedStringFormatter as $4lVjK$useLocalizedStringFormatter, useLocale as $4lVjK$useLocale} from "@react-aria/i18n";
|
|
10
|
-
import {useMemo as $4lVjK$useMemo, useRef as $4lVjK$useRef} from "react";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function $parcel$interopDefault(a) {
|
|
14
|
-
return a && a.__esModule ? a.default : a;
|
|
15
|
-
}
|
|
16
|
-
/*
|
|
17
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
18
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
19
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
20
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
-
*
|
|
22
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
23
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
24
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
25
|
-
* governing permissions and limitations under the License.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
|
|
37
|
-
let buttonId = (0, $4lVjK$useId)();
|
|
38
|
-
let dialogId = (0, $4lVjK$useId)();
|
|
39
|
-
let fieldId = (0, $4lVjK$useId)();
|
|
40
|
-
let stringFormatter = (0, $4lVjK$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4lVjK$intlStringsmodulejs))), '@react-aria/datepicker');
|
|
41
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
42
|
-
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $4lVjK$useField)({
|
|
43
|
-
...props,
|
|
44
|
-
labelElementType: 'span',
|
|
45
|
-
isInvalid: isInvalid,
|
|
46
|
-
errorMessage: props.errorMessage || validationErrors
|
|
47
|
-
});
|
|
48
|
-
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
|
|
49
|
-
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
50
|
-
let { locale: locale } = (0, $4lVjK$useLocale)();
|
|
51
|
-
let date = state.formatValue(locale, {
|
|
52
|
-
month: 'long'
|
|
53
|
-
});
|
|
54
|
-
let description = date ? stringFormatter.format('selectedDateDescription', {
|
|
55
|
-
date: date
|
|
56
|
-
}) : '';
|
|
57
|
-
let descProps = (0, $4lVjK$useDescription)(description);
|
|
58
|
-
let ariaDescribedBy = [
|
|
59
|
-
descProps['aria-describedby'],
|
|
60
|
-
fieldProps['aria-describedby']
|
|
61
|
-
].filter(Boolean).join(' ') || undefined;
|
|
62
|
-
let domProps = (0, $4lVjK$filterDOMProps)(props);
|
|
63
|
-
let focusManager = (0, $4lVjK$useMemo)(()=>(0, $4lVjK$createFocusManager)(ref), [
|
|
64
|
-
ref
|
|
65
|
-
]);
|
|
66
|
-
let isFocused = (0, $4lVjK$useRef)(false);
|
|
67
|
-
let { focusWithinProps: focusWithinProps } = (0, $4lVjK$useFocusWithin)({
|
|
68
|
-
...props,
|
|
69
|
-
isDisabled: state.isOpen,
|
|
70
|
-
onBlurWithin: (e)=>{
|
|
71
|
-
// Ignore when focus moves into the popover.
|
|
72
|
-
let dialog = document.getElementById(dialogId);
|
|
73
|
-
if (!(0, $4lVjK$nodeContains)(dialog, e.relatedTarget)) {
|
|
74
|
-
var _props_onBlur, _props_onFocusChange;
|
|
75
|
-
isFocused.current = false;
|
|
76
|
-
(_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
|
|
77
|
-
(_props_onFocusChange = props.onFocusChange) === null || _props_onFocusChange === void 0 ? void 0 : _props_onFocusChange.call(props, false);
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
onFocusWithin: (e)=>{
|
|
81
|
-
if (!isFocused.current) {
|
|
82
|
-
var _props_onFocus, _props_onFocusChange;
|
|
83
|
-
isFocused.current = true;
|
|
84
|
-
(_props_onFocus = props.onFocus) === null || _props_onFocus === void 0 ? void 0 : _props_onFocus.call(props, e);
|
|
85
|
-
(_props_onFocusChange = props.onFocusChange) === null || _props_onFocusChange === void 0 ? void 0 : _props_onFocusChange.call(props, true);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
return {
|
|
90
|
-
groupProps: (0, $4lVjK$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
91
|
-
role: 'group',
|
|
92
|
-
'aria-disabled': props.isDisabled || null,
|
|
93
|
-
'aria-labelledby': labelledBy,
|
|
94
|
-
'aria-describedby': ariaDescribedBy,
|
|
95
|
-
onKeyDown (e) {
|
|
96
|
-
if (state.isOpen) return;
|
|
97
|
-
if (props.onKeyDown) props.onKeyDown(e);
|
|
98
|
-
},
|
|
99
|
-
onKeyUp (e) {
|
|
100
|
-
if (state.isOpen) return;
|
|
101
|
-
if (props.onKeyUp) props.onKeyUp(e);
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
labelProps: {
|
|
105
|
-
...labelProps,
|
|
106
|
-
onClick: ()=>{
|
|
107
|
-
focusManager.focusFirst();
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
fieldProps: {
|
|
111
|
-
...fieldProps,
|
|
112
|
-
id: fieldId,
|
|
113
|
-
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: 'presentation',
|
|
114
|
-
'aria-describedby': ariaDescribedBy,
|
|
115
|
-
value: state.value,
|
|
116
|
-
defaultValue: state.defaultValue,
|
|
117
|
-
onChange: state.setValue,
|
|
118
|
-
placeholderValue: props.placeholderValue,
|
|
119
|
-
hideTimeZone: props.hideTimeZone,
|
|
120
|
-
hourCycle: props.hourCycle,
|
|
121
|
-
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
|
|
122
|
-
granularity: props.granularity,
|
|
123
|
-
isDisabled: props.isDisabled,
|
|
124
|
-
isReadOnly: props.isReadOnly,
|
|
125
|
-
isRequired: props.isRequired,
|
|
126
|
-
validationBehavior: props.validationBehavior,
|
|
127
|
-
// DatePicker owns the validation state for the date field.
|
|
128
|
-
[(0, $4lVjK$privateValidationStateProp)]: state,
|
|
129
|
-
autoFocus: props.autoFocus,
|
|
130
|
-
name: props.name,
|
|
131
|
-
form: props.form
|
|
132
|
-
},
|
|
133
|
-
descriptionProps: descriptionProps,
|
|
134
|
-
errorMessageProps: errorMessageProps,
|
|
135
|
-
buttonProps: {
|
|
136
|
-
...descProps,
|
|
137
|
-
id: buttonId,
|
|
138
|
-
'aria-haspopup': 'dialog',
|
|
139
|
-
'aria-label': stringFormatter.format('calendar'),
|
|
140
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
141
|
-
'aria-describedby': ariaDescribedBy,
|
|
142
|
-
'aria-expanded': state.isOpen,
|
|
143
|
-
isDisabled: props.isDisabled || props.isReadOnly,
|
|
144
|
-
onPress: ()=>state.setOpen(true)
|
|
145
|
-
},
|
|
146
|
-
dialogProps: {
|
|
147
|
-
id: dialogId,
|
|
148
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
149
|
-
},
|
|
150
|
-
calendarProps: {
|
|
151
|
-
autoFocus: true,
|
|
152
|
-
value: state.dateValue,
|
|
153
|
-
onChange: state.setDateValue,
|
|
154
|
-
minValue: props.minValue,
|
|
155
|
-
maxValue: props.maxValue,
|
|
156
|
-
isDisabled: props.isDisabled,
|
|
157
|
-
isReadOnly: props.isReadOnly,
|
|
158
|
-
isDateUnavailable: props.isDateUnavailable,
|
|
159
|
-
defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
|
|
160
|
-
isInvalid: state.isInvalid,
|
|
161
|
-
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
|
|
162
|
-
firstDayOfWeek: props.firstDayOfWeek,
|
|
163
|
-
pageBehavior: props.pageBehavior
|
|
164
|
-
},
|
|
165
|
-
isInvalid: isInvalid,
|
|
166
|
-
validationErrors: validationErrors,
|
|
167
|
-
validationDetails: validationDetails
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
export {$6057a3d2a53a12fd$export$42df105a73306d51 as useDatePicker};
|
|
173
|
-
//# sourceMappingURL=useDatePicker.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AA2CM,SAAS,0CAAmC,KAA6B,EAAE,KAAsB,EAAE,GAA8B;IACtI,IAAI,WAAW,CAAA,GAAA,YAAI;IACnB,IAAI,WAAW,CAAA,GAAA,YAAI;IACnB,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,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,aAAa,CAA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,IAAM,MAAM,OAAO,CAAC;QAC/B;QACA,aAAa;YACX,IAAI;YACJ,mBAAmB,GAAG,SAAS,CAAC,EAAE,YAAY;QAChD;QACA,eAAe;YACb,WAAW;YACX,OAAO,MAAM,SAAS;YACtB,UAAU,MAAM,YAAY;YAC5B,UAAU,MAAM,QAAQ;YACxB,UAAU,MAAM,QAAQ;YACxB,YAAY,MAAM,UAAU;YAC5B,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;YAC5K,gBAAgB,MAAM,cAAc;YACpC,cAAc,MAAM,YAAY;QAClC;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, nodeContains, 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, useRef} 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 isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!nodeContains(dialog, e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\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 defaultValue: state.defaultValue,\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 form: props.form\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 firstDayOfWeek: props.firstDayOfWeek,\n pageBehavior: props.pageBehavior\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDatePicker.module.js.map"}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
var $19S5E$reactariafocus = require("@react-aria/focus");
|
|
2
|
-
var $19S5E$reactariautils = require("@react-aria/utils");
|
|
3
|
-
var $19S5E$reactariai18n = require("@react-aria/i18n");
|
|
4
|
-
var $19S5E$react = require("react");
|
|
5
|
-
var $19S5E$reactariainteractions = require("@react-aria/interactions");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function $parcel$export(e, n, v, s) {
|
|
9
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
$parcel$export(module.exports, "useDatePickerGroup", () => $715562ad3b4cced4$export$4a931266a3838b86);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function $715562ad3b4cced4$export$4a931266a3838b86(state, ref, disableArrowNavigation) {
|
|
19
|
-
let { direction: direction } = (0, $19S5E$reactariai18n.useLocale)();
|
|
20
|
-
let focusManager = (0, $19S5E$react.useMemo)(()=>(0, $19S5E$reactariafocus.createFocusManager)(ref), [
|
|
21
|
-
ref
|
|
22
|
-
]);
|
|
23
|
-
// Open the popover on alt + arrow down
|
|
24
|
-
let onKeyDown = (e)=>{
|
|
25
|
-
if (!(0, $19S5E$reactariautils.nodeContains)(e.currentTarget, e.target)) return;
|
|
26
|
-
if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {
|
|
27
|
-
e.preventDefault();
|
|
28
|
-
e.stopPropagation();
|
|
29
|
-
state.setOpen(true);
|
|
30
|
-
}
|
|
31
|
-
if (disableArrowNavigation) return;
|
|
32
|
-
switch(e.key){
|
|
33
|
-
case 'ArrowLeft':
|
|
34
|
-
e.preventDefault();
|
|
35
|
-
e.stopPropagation();
|
|
36
|
-
if (direction === 'rtl') {
|
|
37
|
-
if (ref.current) {
|
|
38
|
-
let target = e.target;
|
|
39
|
-
let prev = $715562ad3b4cced4$var$findNextSegment(ref.current, target.getBoundingClientRect().left, -1);
|
|
40
|
-
if (prev) prev.focus();
|
|
41
|
-
}
|
|
42
|
-
} else focusManager.focusPrevious();
|
|
43
|
-
break;
|
|
44
|
-
case 'ArrowRight':
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
e.stopPropagation();
|
|
47
|
-
if (direction === 'rtl') {
|
|
48
|
-
if (ref.current) {
|
|
49
|
-
let target = e.target;
|
|
50
|
-
let next = $715562ad3b4cced4$var$findNextSegment(ref.current, target.getBoundingClientRect().left, 1);
|
|
51
|
-
if (next) next.focus();
|
|
52
|
-
}
|
|
53
|
-
} else focusManager.focusNext();
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
// Focus the first placeholder segment from the end on mouse down/touch up in the field.
|
|
58
|
-
let focusLast = ()=>{
|
|
59
|
-
var _window_event;
|
|
60
|
-
if (!ref.current) return;
|
|
61
|
-
// Try to find the segment prior to the element that was clicked on.
|
|
62
|
-
let target = (_window_event = window.event) === null || _window_event === void 0 ? void 0 : _window_event.target;
|
|
63
|
-
let walker = (0, $19S5E$reactariafocus.getFocusableTreeWalker)(ref.current, {
|
|
64
|
-
tabbable: true
|
|
65
|
-
});
|
|
66
|
-
if (target) {
|
|
67
|
-
walker.currentNode = target;
|
|
68
|
-
target = walker.previousNode();
|
|
69
|
-
}
|
|
70
|
-
// If no target found, find the last element from the end.
|
|
71
|
-
if (!target) {
|
|
72
|
-
let last;
|
|
73
|
-
do {
|
|
74
|
-
last = walker.lastChild();
|
|
75
|
-
if (last) target = last;
|
|
76
|
-
}while (last);
|
|
77
|
-
}
|
|
78
|
-
// Now go backwards until we find an element that is not a placeholder.
|
|
79
|
-
while(target === null || target === void 0 ? void 0 : target.hasAttribute('data-placeholder')){
|
|
80
|
-
let prev = walker.previousNode();
|
|
81
|
-
if (prev && prev.hasAttribute('data-placeholder')) target = prev;
|
|
82
|
-
else break;
|
|
83
|
-
}
|
|
84
|
-
if (target) target.focus();
|
|
85
|
-
};
|
|
86
|
-
let { pressProps: pressProps } = (0, $19S5E$reactariainteractions.usePress)({
|
|
87
|
-
preventFocusOnPress: true,
|
|
88
|
-
allowTextSelectionOnPress: true,
|
|
89
|
-
onPressStart (e) {
|
|
90
|
-
if (e.pointerType === 'mouse') focusLast();
|
|
91
|
-
},
|
|
92
|
-
onPress (e) {
|
|
93
|
-
if (e.pointerType === 'touch' || e.pointerType === 'pen') focusLast();
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
return (0, $19S5E$reactariautils.mergeProps)(pressProps, {
|
|
97
|
-
onKeyDown: onKeyDown
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function $715562ad3b4cced4$var$findNextSegment(group, fromX, direction) {
|
|
101
|
-
let walker = (0, $19S5E$reactariafocus.getFocusableTreeWalker)(group, {
|
|
102
|
-
tabbable: true
|
|
103
|
-
});
|
|
104
|
-
let node = walker.nextNode();
|
|
105
|
-
let closest = null;
|
|
106
|
-
let closestDistance = Infinity;
|
|
107
|
-
while(node){
|
|
108
|
-
let x = node.getBoundingClientRect().left;
|
|
109
|
-
let distance = x - fromX;
|
|
110
|
-
let absoluteDistance = Math.abs(distance);
|
|
111
|
-
if (Math.sign(distance) === direction && absoluteDistance < closestDistance) {
|
|
112
|
-
closest = node;
|
|
113
|
-
closestDistance = absoluteDistance;
|
|
114
|
-
}
|
|
115
|
-
node = walker.nextNode();
|
|
116
|
-
}
|
|
117
|
-
return closest;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
//# sourceMappingURL=useDatePickerGroup.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAQO,SAAS,0CAAmB,KAA8D,EAAE,GAA8B,EAAE,sBAAgC;IACjK,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,eAAe,CAAA,GAAA,oBAAM,EAAE,IAAM,CAAA,GAAA,wCAAiB,EAAE,MAAM;QAAC;KAAI;IAE/D,uCAAuC;IACvC,IAAI,YAAY,CAAC;QACf,IAAI,CAAC,CAAA,GAAA,kCAAW,EAAE,EAAE,aAAa,EAAE,EAAE,MAAM,GACzC;QAGF,IAAI,EAAE,MAAM,IAAK,CAAA,EAAE,GAAG,KAAK,eAAe,EAAE,GAAG,KAAK,SAAQ,KAAM,aAAa,OAAO;YACpF,EAAE,cAAc;YAChB,EAAE,eAAe;YACjB,MAAM,OAAO,CAAC;QAChB;QAEA,IAAI,wBACF;QAGF,OAAQ,EAAE,GAAG;YACX,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,IAAI,cAAc,OAChB;oBAAA,IAAI,IAAI,OAAO,EAAE;wBACf,IAAI,SAAS,EAAE,MAAM;wBACrB,IAAI,OAAO,sCAAgB,IAAI,OAAO,EAAE,OAAO,qBAAqB,G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W,EAAE,WAAW,KAAK,OACjD;QAEJ;IACF;IAEA,OAAO,CAAA,GAAA,gCAAS,EAAE,YAAY;mBAAC;IAAS;AAC1C;AAEA,SAAS,sCAAgB,KAAc,EAAE,KAAa,EAAE,SAAiB;IACvE,IAAI,SAAS,CAAA,GAAA,4CAAqB,EAAE,OAAO;QAAC,UAAU;IAAI;IAC1D,IAAI,OAAO,OAAO,QAAQ;IAC1B,IAAI,UAAmC;IACvC,IAAI,kBAAkB;IACtB,MAAO,KAAM;QACX,IAAI,IAAI,AAAC,KAAiB,qBAAqB,GAAG,IAAI;QACtD,IAAI,WAAW,IAAI;QACnB,IAAI,mBAAmB,KAAK,GAAG,CAAC;QAChC,IAAI,KAAK,IAAI,CAAC,cAAc,aAAa,mBAAmB,iBAAiB;YAC3E,UAAU;YACV,kBAAkB;QACpB;QACA,OAAO,OAAO,QAAQ;IACxB;IACA,OAAO;AACT","sources":["packages/@react-aria/datepicker/src/useDatePickerGroup.ts"],"sourcesContent":["import {createFocusManager, getFocusableTreeWalker} from '@react-aria/focus';\nimport {DateFieldState, DatePickerState, DateRangePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, FocusableElement, KeyboardEvent, RefObject} from '@react-types/shared';\nimport {mergeProps, nodeContains} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useMemo} from 'react';\nimport {usePress} from '@react-aria/interactions';\n\nexport function useDatePickerGroup(state: DatePickerState | DateRangePickerState | DateFieldState, ref: RefObject<Element | null>, disableArrowNavigation?: boolean): DOMAttributes<FocusableElement> {\n let {direction} = useLocale();\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n // Open the popover on alt + arrow down\n let onKeyDown = (e: KeyboardEvent) => {\n if (!nodeContains(e.currentTarget, e.target as Element)) {\n return;\n }\n\n if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {\n e.preventDefault();\n e.stopPropagation();\n state.setOpen(true);\n }\n\n if (disableArrowNavigation) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n if (ref.current) {\n let target = e.target as FocusableElement;\n let prev = findNextSegment(ref.current, target.getBoundingClientRect().left, -1);\n\n if (prev) {\n prev.focus();\n }\n }\n } else {\n focusManager.focusPrevious();\n }\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n if (ref.current) {\n let target = e.target as FocusableElement;\n let next = findNextSegment(ref.current, target.getBoundingClientRect().left, 1);\n\n if (next) {\n next.focus();\n }\n }\n } else {\n focusManager.focusNext();\n }\n break;\n }\n };\n\n // Focus the first placeholder segment from the end on mouse down/touch up in the field.\n let focusLast = () => {\n if (!ref.current) {\n return;\n }\n // Try to find the segment prior to the element that was clicked on.\n let target = window.event?.target as FocusableElement;\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n if (target) {\n walker.currentNode = target;\n target = walker.previousNode() as FocusableElement;\n }\n\n // If no target found, find the last element from the end.\n if (!target) {\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n target = last;\n }\n } while (last);\n }\n\n // Now go backwards until we find an element that is not a placeholder.\n while (target?.hasAttribute('data-placeholder')) {\n let prev = walker.previousNode() as FocusableElement;\n if (prev && prev.hasAttribute('data-placeholder')) {\n target = prev;\n } else {\n break;\n }\n }\n\n if (target) {\n target.focus();\n }\n };\n\n let {pressProps} = usePress({\n preventFocusOnPress: true,\n allowTextSelectionOnPress: true,\n onPressStart(e) {\n if (e.pointerType === 'mouse') {\n focusLast();\n }\n },\n onPress(e) {\n if (e.pointerType === 'touch' || e.pointerType === 'pen') {\n focusLast();\n }\n }\n });\n\n return mergeProps(pressProps, {onKeyDown});\n}\n\nfunction findNextSegment(group: Element, fromX: number, direction: number) {\n let walker = getFocusableTreeWalker(group, {tabbable: true});\n let node = walker.nextNode();\n let closest: FocusableElement | null = null;\n let closestDistance = Infinity;\n while (node) {\n let x = (node as Element).getBoundingClientRect().left;\n let distance = x - fromX;\n let absoluteDistance = Math.abs(distance);\n if (Math.sign(distance) === direction && absoluteDistance < closestDistance) {\n closest = node as FocusableElement;\n closestDistance = absoluteDistance;\n }\n node = walker.nextNode();\n }\n return closest;\n}\n"],"names":[],"version":3,"file":"useDatePickerGroup.main.js.map"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {createFocusManager as $7CEvq$createFocusManager, getFocusableTreeWalker as $7CEvq$getFocusableTreeWalker} from "@react-aria/focus";
|
|
2
|
-
import {nodeContains as $7CEvq$nodeContains, mergeProps as $7CEvq$mergeProps} from "@react-aria/utils";
|
|
3
|
-
import {useLocale as $7CEvq$useLocale} from "@react-aria/i18n";
|
|
4
|
-
import {useMemo as $7CEvq$useMemo} from "react";
|
|
5
|
-
import {usePress as $7CEvq$usePress} from "@react-aria/interactions";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref, disableArrowNavigation) {
|
|
13
|
-
let { direction: direction } = (0, $7CEvq$useLocale)();
|
|
14
|
-
let focusManager = (0, $7CEvq$useMemo)(()=>(0, $7CEvq$createFocusManager)(ref), [
|
|
15
|
-
ref
|
|
16
|
-
]);
|
|
17
|
-
// Open the popover on alt + arrow down
|
|
18
|
-
let onKeyDown = (e)=>{
|
|
19
|
-
if (!(0, $7CEvq$nodeContains)(e.currentTarget, e.target)) return;
|
|
20
|
-
if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
e.stopPropagation();
|
|
23
|
-
state.setOpen(true);
|
|
24
|
-
}
|
|
25
|
-
if (disableArrowNavigation) return;
|
|
26
|
-
switch(e.key){
|
|
27
|
-
case 'ArrowLeft':
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
e.stopPropagation();
|
|
30
|
-
if (direction === 'rtl') {
|
|
31
|
-
if (ref.current) {
|
|
32
|
-
let target = e.target;
|
|
33
|
-
let prev = $3dfb0f96be0d6a08$var$findNextSegment(ref.current, target.getBoundingClientRect().left, -1);
|
|
34
|
-
if (prev) prev.focus();
|
|
35
|
-
}
|
|
36
|
-
} else focusManager.focusPrevious();
|
|
37
|
-
break;
|
|
38
|
-
case 'ArrowRight':
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
e.stopPropagation();
|
|
41
|
-
if (direction === 'rtl') {
|
|
42
|
-
if (ref.current) {
|
|
43
|
-
let target = e.target;
|
|
44
|
-
let next = $3dfb0f96be0d6a08$var$findNextSegment(ref.current, target.getBoundingClientRect().left, 1);
|
|
45
|
-
if (next) next.focus();
|
|
46
|
-
}
|
|
47
|
-
} else focusManager.focusNext();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
// Focus the first placeholder segment from the end on mouse down/touch up in the field.
|
|
52
|
-
let focusLast = ()=>{
|
|
53
|
-
var _window_event;
|
|
54
|
-
if (!ref.current) return;
|
|
55
|
-
// Try to find the segment prior to the element that was clicked on.
|
|
56
|
-
let target = (_window_event = window.event) === null || _window_event === void 0 ? void 0 : _window_event.target;
|
|
57
|
-
let walker = (0, $7CEvq$getFocusableTreeWalker)(ref.current, {
|
|
58
|
-
tabbable: true
|
|
59
|
-
});
|
|
60
|
-
if (target) {
|
|
61
|
-
walker.currentNode = target;
|
|
62
|
-
target = walker.previousNode();
|
|
63
|
-
}
|
|
64
|
-
// If no target found, find the last element from the end.
|
|
65
|
-
if (!target) {
|
|
66
|
-
let last;
|
|
67
|
-
do {
|
|
68
|
-
last = walker.lastChild();
|
|
69
|
-
if (last) target = last;
|
|
70
|
-
}while (last);
|
|
71
|
-
}
|
|
72
|
-
// Now go backwards until we find an element that is not a placeholder.
|
|
73
|
-
while(target === null || target === void 0 ? void 0 : target.hasAttribute('data-placeholder')){
|
|
74
|
-
let prev = walker.previousNode();
|
|
75
|
-
if (prev && prev.hasAttribute('data-placeholder')) target = prev;
|
|
76
|
-
else break;
|
|
77
|
-
}
|
|
78
|
-
if (target) target.focus();
|
|
79
|
-
};
|
|
80
|
-
let { pressProps: pressProps } = (0, $7CEvq$usePress)({
|
|
81
|
-
preventFocusOnPress: true,
|
|
82
|
-
allowTextSelectionOnPress: true,
|
|
83
|
-
onPressStart (e) {
|
|
84
|
-
if (e.pointerType === 'mouse') focusLast();
|
|
85
|
-
},
|
|
86
|
-
onPress (e) {
|
|
87
|
-
if (e.pointerType === 'touch' || e.pointerType === 'pen') focusLast();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return (0, $7CEvq$mergeProps)(pressProps, {
|
|
91
|
-
onKeyDown: onKeyDown
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function $3dfb0f96be0d6a08$var$findNextSegment(group, fromX, direction) {
|
|
95
|
-
let walker = (0, $7CEvq$getFocusableTreeWalker)(group, {
|
|
96
|
-
tabbable: true
|
|
97
|
-
});
|
|
98
|
-
let node = walker.nextNode();
|
|
99
|
-
let closest = null;
|
|
100
|
-
let closestDistance = Infinity;
|
|
101
|
-
while(node){
|
|
102
|
-
let x = node.getBoundingClientRect().left;
|
|
103
|
-
let distance = x - fromX;
|
|
104
|
-
let absoluteDistance = Math.abs(distance);
|
|
105
|
-
if (Math.sign(distance) === direction && absoluteDistance < closestDistance) {
|
|
106
|
-
closest = node;
|
|
107
|
-
closestDistance = absoluteDistance;
|
|
108
|
-
}
|
|
109
|
-
node = walker.nextNode();
|
|
110
|
-
}
|
|
111
|
-
return closest;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
export {$3dfb0f96be0d6a08$export$4a931266a3838b86 as useDatePickerGroup};
|
|
116
|
-
//# sourceMappingURL=useDatePickerGroup.module.js.map
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import {createFocusManager as $7CEvq$createFocusManager, getFocusableTreeWalker as $7CEvq$getFocusableTreeWalker} from "@react-aria/focus";
|
|
2
|
-
import {nodeContains as $7CEvq$nodeContains, mergeProps as $7CEvq$mergeProps} from "@react-aria/utils";
|
|
3
|
-
import {useLocale as $7CEvq$useLocale} from "@react-aria/i18n";
|
|
4
|
-
import {useMemo as $7CEvq$useMemo} from "react";
|
|
5
|
-
import {usePress as $7CEvq$usePress} from "@react-aria/interactions";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
function $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref, disableArrowNavigation) {
|
|
13
|
-
let { direction: direction } = (0, $7CEvq$useLocale)();
|
|
14
|
-
let focusManager = (0, $7CEvq$useMemo)(()=>(0, $7CEvq$createFocusManager)(ref), [
|
|
15
|
-
ref
|
|
16
|
-
]);
|
|
17
|
-
// Open the popover on alt + arrow down
|
|
18
|
-
let onKeyDown = (e)=>{
|
|
19
|
-
if (!(0, $7CEvq$nodeContains)(e.currentTarget, e.target)) return;
|
|
20
|
-
if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {
|
|
21
|
-
e.preventDefault();
|
|
22
|
-
e.stopPropagation();
|
|
23
|
-
state.setOpen(true);
|
|
24
|
-
}
|
|
25
|
-
if (disableArrowNavigation) return;
|
|
26
|
-
switch(e.key){
|
|
27
|
-
case 'ArrowLeft':
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
e.stopPropagation();
|
|
30
|
-
if (direction === 'rtl') {
|
|
31
|
-
if (ref.current) {
|
|
32
|
-
let target = e.target;
|
|
33
|
-
let prev = $3dfb0f96be0d6a08$var$findNextSegment(ref.current, target.getBoundingClientRect().left, -1);
|
|
34
|
-
if (prev) prev.focus();
|
|
35
|
-
}
|
|
36
|
-
} else focusManager.focusPrevious();
|
|
37
|
-
break;
|
|
38
|
-
case 'ArrowRight':
|
|
39
|
-
e.preventDefault();
|
|
40
|
-
e.stopPropagation();
|
|
41
|
-
if (direction === 'rtl') {
|
|
42
|
-
if (ref.current) {
|
|
43
|
-
let target = e.target;
|
|
44
|
-
let next = $3dfb0f96be0d6a08$var$findNextSegment(ref.current, target.getBoundingClientRect().left, 1);
|
|
45
|
-
if (next) next.focus();
|
|
46
|
-
}
|
|
47
|
-
} else focusManager.focusNext();
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
// Focus the first placeholder segment from the end on mouse down/touch up in the field.
|
|
52
|
-
let focusLast = ()=>{
|
|
53
|
-
var _window_event;
|
|
54
|
-
if (!ref.current) return;
|
|
55
|
-
// Try to find the segment prior to the element that was clicked on.
|
|
56
|
-
let target = (_window_event = window.event) === null || _window_event === void 0 ? void 0 : _window_event.target;
|
|
57
|
-
let walker = (0, $7CEvq$getFocusableTreeWalker)(ref.current, {
|
|
58
|
-
tabbable: true
|
|
59
|
-
});
|
|
60
|
-
if (target) {
|
|
61
|
-
walker.currentNode = target;
|
|
62
|
-
target = walker.previousNode();
|
|
63
|
-
}
|
|
64
|
-
// If no target found, find the last element from the end.
|
|
65
|
-
if (!target) {
|
|
66
|
-
let last;
|
|
67
|
-
do {
|
|
68
|
-
last = walker.lastChild();
|
|
69
|
-
if (last) target = last;
|
|
70
|
-
}while (last);
|
|
71
|
-
}
|
|
72
|
-
// Now go backwards until we find an element that is not a placeholder.
|
|
73
|
-
while(target === null || target === void 0 ? void 0 : target.hasAttribute('data-placeholder')){
|
|
74
|
-
let prev = walker.previousNode();
|
|
75
|
-
if (prev && prev.hasAttribute('data-placeholder')) target = prev;
|
|
76
|
-
else break;
|
|
77
|
-
}
|
|
78
|
-
if (target) target.focus();
|
|
79
|
-
};
|
|
80
|
-
let { pressProps: pressProps } = (0, $7CEvq$usePress)({
|
|
81
|
-
preventFocusOnPress: true,
|
|
82
|
-
allowTextSelectionOnPress: true,
|
|
83
|
-
onPressStart (e) {
|
|
84
|
-
if (e.pointerType === 'mouse') focusLast();
|
|
85
|
-
},
|
|
86
|
-
onPress (e) {
|
|
87
|
-
if (e.pointerType === 'touch' || e.pointerType === 'pen') focusLast();
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return (0, $7CEvq$mergeProps)(pressProps, {
|
|
91
|
-
onKeyDown: onKeyDown
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function $3dfb0f96be0d6a08$var$findNextSegment(group, fromX, direction) {
|
|
95
|
-
let walker = (0, $7CEvq$getFocusableTreeWalker)(group, {
|
|
96
|
-
tabbable: true
|
|
97
|
-
});
|
|
98
|
-
let node = walker.nextNode();
|
|
99
|
-
let closest = null;
|
|
100
|
-
let closestDistance = Infinity;
|
|
101
|
-
while(node){
|
|
102
|
-
let x = node.getBoundingClientRect().left;
|
|
103
|
-
let distance = x - fromX;
|
|
104
|
-
let absoluteDistance = Math.abs(distance);
|
|
105
|
-
if (Math.sign(distance) === direction && absoluteDistance < closestDistance) {
|
|
106
|
-
closest = node;
|
|
107
|
-
closestDistance = absoluteDistance;
|
|
108
|
-
}
|
|
109
|
-
node = walker.nextNode();
|
|
110
|
-
}
|
|
111
|
-
return closest;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
export {$3dfb0f96be0d6a08$export$4a931266a3838b86 as useDatePickerGroup};
|
|
116
|
-
//# sourceMappingURL=useDatePickerGroup.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAQO,SAAS,0CAAmB,KAA8D,EAAE,GAA8B,EAAE,sBAAgC;IACjK,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,eAAe,CAAA,GAAA,cAAM,EAAE,IAAM,CAAA,GAAA,yBAAiB,EAAE,MAAM;QAAC;KAAI;IAE/D,uCAAuC;IACvC,IAAI,YAAY,CAAC;QACf,IAAI,CAAC,CAAA,GAAA,mBAAW,EAAE,EAAE,aAAa,EAAE,EAAE,MAAM,GACzC;QAGF,IAAI,EAAE,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ACvE,MAAO,mBAAA,6BAAA,OAAQ,YAAY,CAAC,oBAAqB;YAC/C,IAAI,OAAO,OAAO,YAAY;YAC9B,IAAI,QAAQ,KAAK,YAAY,CAAC,qBAC5B,SAAS;iBAET;QAEJ;QAEA,IAAI,QACF,OAAO,KAAK;IAEhB;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,qBAAqB;QACrB,2BAA2B;QAC3B,cAAa,CAAC;YACZ,IAAI,EAAE,WAAW,KAAK,SACpB;QAEJ;QACA,SAAQ,CAAC;YACP,IAAI,EAAE,WAAW,KAAK,WAAW,EAAE,WAAW,KAAK,OACjD;QAEJ;IACF;IAEA,OAAO,CAAA,GAAA,iBAAS,EAAE,YAAY;mBAAC;IAAS;AAC1C;AAEA,SAAS,sCAAgB,KAAc,EAAE,KAAa,EAAE,SAAiB;IACvE,IAAI,SAAS,CAAA,GAAA,6BAAqB,EAAE,OAAO;QAAC,UAAU;IAAI;IAC1D,IAAI,OAAO,OAAO,QAAQ;IAC1B,IAAI,UAAmC;IACvC,IAAI,kBAAkB;IACtB,MAAO,KAAM;QACX,IAAI,IAAI,AAAC,KAAiB,qBAAqB,GAAG,IAAI;QACtD,IAAI,WAAW,IAAI;QACnB,IAAI,mBAAmB,KAAK,GAAG,CAAC;QAChC,IAAI,KAAK,IAAI,CAAC,cAAc,aAAa,mBAAmB,iBAAiB;YAC3E,UAAU;YACV,kBAAkB;QACpB;QACA,OAAO,OAAO,QAAQ;IACxB;IACA,OAAO;AACT","sources":["packages/@react-aria/datepicker/src/useDatePickerGroup.ts"],"sourcesContent":["import {createFocusManager, getFocusableTreeWalker} from '@react-aria/focus';\nimport {DateFieldState, DatePickerState, DateRangePickerState} from '@react-stately/datepicker';\nimport {DOMAttributes, FocusableElement, KeyboardEvent, RefObject} from '@react-types/shared';\nimport {mergeProps, nodeContains} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useMemo} from 'react';\nimport {usePress} from '@react-aria/interactions';\n\nexport function useDatePickerGroup(state: DatePickerState | DateRangePickerState | DateFieldState, ref: RefObject<Element | null>, disableArrowNavigation?: boolean): DOMAttributes<FocusableElement> {\n let {direction} = useLocale();\n let focusManager = useMemo(() => createFocusManager(ref), [ref]);\n\n // Open the popover on alt + arrow down\n let onKeyDown = (e: KeyboardEvent) => {\n if (!nodeContains(e.currentTarget, e.target as Element)) {\n return;\n }\n\n if (e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp') && 'setOpen' in state) {\n e.preventDefault();\n e.stopPropagation();\n state.setOpen(true);\n }\n\n if (disableArrowNavigation) {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n if (ref.current) {\n let target = e.target as FocusableElement;\n let prev = findNextSegment(ref.current, target.getBoundingClientRect().left, -1);\n\n if (prev) {\n prev.focus();\n }\n }\n } else {\n focusManager.focusPrevious();\n }\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n if (ref.current) {\n let target = e.target as FocusableElement;\n let next = findNextSegment(ref.current, target.getBoundingClientRect().left, 1);\n\n if (next) {\n next.focus();\n }\n }\n } else {\n focusManager.focusNext();\n }\n break;\n }\n };\n\n // Focus the first placeholder segment from the end on mouse down/touch up in the field.\n let focusLast = () => {\n if (!ref.current) {\n return;\n }\n // Try to find the segment prior to the element that was clicked on.\n let target = window.event?.target as FocusableElement;\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n if (target) {\n walker.currentNode = target;\n target = walker.previousNode() as FocusableElement;\n }\n\n // If no target found, find the last element from the end.\n if (!target) {\n let last: FocusableElement;\n do {\n last = walker.lastChild() as FocusableElement;\n if (last) {\n target = last;\n }\n } while (last);\n }\n\n // Now go backwards until we find an element that is not a placeholder.\n while (target?.hasAttribute('data-placeholder')) {\n let prev = walker.previousNode() as FocusableElement;\n if (prev && prev.hasAttribute('data-placeholder')) {\n target = prev;\n } else {\n break;\n }\n }\n\n if (target) {\n target.focus();\n }\n };\n\n let {pressProps} = usePress({\n preventFocusOnPress: true,\n allowTextSelectionOnPress: true,\n onPressStart(e) {\n if (e.pointerType === 'mouse') {\n focusLast();\n }\n },\n onPress(e) {\n if (e.pointerType === 'touch' || e.pointerType === 'pen') {\n focusLast();\n }\n }\n });\n\n return mergeProps(pressProps, {onKeyDown});\n}\n\nfunction findNextSegment(group: Element, fromX: number, direction: number) {\n let walker = getFocusableTreeWalker(group, {tabbable: true});\n let node = walker.nextNode();\n let closest: FocusableElement | null = null;\n let closestDistance = Infinity;\n while (node) {\n let x = (node as Element).getBoundingClientRect().left;\n let distance = x - fromX;\n let absoluteDistance = Math.abs(distance);\n if (Math.sign(distance) === direction && absoluteDistance < closestDistance) {\n closest = node as FocusableElement;\n closestDistance = absoluteDistance;\n }\n node = walker.nextNode();\n }\n return closest;\n}\n"],"names":[],"version":3,"file":"useDatePickerGroup.module.js.map"}
|