@react-aria/datepicker 3.9.3 → 3.10.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.
Files changed (77) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/import.mjs +5 -1047
  16. package/dist/intlStrings.main.js +108 -0
  17. package/dist/intlStrings.main.js.map +1 -0
  18. package/dist/intlStrings.mjs +110 -0
  19. package/dist/intlStrings.module.js +110 -0
  20. package/dist/intlStrings.module.js.map +1 -0
  21. package/dist/it-IT.mjs +1 -1
  22. package/dist/ja-JP.mjs +1 -1
  23. package/dist/ko-KR.mjs +1 -1
  24. package/dist/lt-LT.mjs +1 -1
  25. package/dist/lv-LV.mjs +1 -1
  26. package/dist/main.js +11 -1053
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +5 -1047
  29. package/dist/module.js.map +1 -1
  30. package/dist/nb-NO.mjs +1 -1
  31. package/dist/nl-NL.mjs +1 -1
  32. package/dist/pl-PL.mjs +1 -1
  33. package/dist/pt-BR.mjs +1 -1
  34. package/dist/pt-PT.mjs +1 -1
  35. package/dist/ro-RO.mjs +1 -1
  36. package/dist/ru-RU.mjs +1 -1
  37. package/dist/sk-SK.mjs +1 -1
  38. package/dist/sl-SI.mjs +1 -1
  39. package/dist/sr-SP.mjs +1 -1
  40. package/dist/sv-SE.mjs +1 -1
  41. package/dist/tr-TR.mjs +1 -1
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/uk-UA.mjs +1 -1
  44. package/dist/useDateField.main.js +176 -0
  45. package/dist/useDateField.main.js.map +1 -0
  46. package/dist/useDateField.mjs +167 -0
  47. package/dist/useDateField.module.js +167 -0
  48. package/dist/useDateField.module.js.map +1 -0
  49. package/dist/useDatePicker.main.js +158 -0
  50. package/dist/useDatePicker.main.js.map +1 -0
  51. package/dist/useDatePicker.mjs +153 -0
  52. package/dist/useDatePicker.module.js +153 -0
  53. package/dist/useDatePicker.module.js.map +1 -0
  54. package/dist/useDatePickerGroup.main.js +91 -0
  55. package/dist/useDatePickerGroup.main.js.map +1 -0
  56. package/dist/useDatePickerGroup.mjs +86 -0
  57. package/dist/useDatePickerGroup.module.js +86 -0
  58. package/dist/useDatePickerGroup.module.js.map +1 -0
  59. package/dist/useDateRangePicker.main.js +201 -0
  60. package/dist/useDateRangePicker.main.js.map +1 -0
  61. package/dist/useDateRangePicker.mjs +196 -0
  62. package/dist/useDateRangePicker.module.js +196 -0
  63. package/dist/useDateRangePicker.module.js.map +1 -0
  64. package/dist/useDateSegment.main.js +366 -0
  65. package/dist/useDateSegment.main.js.map +1 -0
  66. package/dist/useDateSegment.mjs +357 -0
  67. package/dist/useDateSegment.module.js +357 -0
  68. package/dist/useDateSegment.module.js.map +1 -0
  69. package/dist/useDisplayNames.main.js +59 -0
  70. package/dist/useDisplayNames.main.js.map +1 -0
  71. package/dist/useDisplayNames.mjs +54 -0
  72. package/dist/useDisplayNames.module.js +54 -0
  73. package/dist/useDisplayNames.module.js.map +1 -0
  74. package/dist/zh-CN.mjs +1 -1
  75. package/dist/zh-TW.mjs +1 -1
  76. package/package.json +19 -19
  77. package/src/useDateSegment.ts +4 -0
package/dist/module.js CHANGED
@@ -1,885 +1,8 @@
1
- import $f23889fffbde9058$exports from "./ar-AE.module.js";
2
- import $09d9badaa8903929$exports from "./bg-BG.module.js";
3
- import $151b77e0fd711730$exports from "./cs-CZ.module.js";
4
- import $61915aa8630b90a2$exports from "./da-DK.module.js";
5
- import $35cea00159787840$exports from "./de-DE.module.js";
6
- import $518b4e82b9eacafd$exports from "./el-GR.module.js";
7
- import $1c2b297f7e2cf474$exports from "./en-US.module.js";
8
- import $07f628a707cf9b18$exports from "./es-ES.module.js";
9
- import $db553ffe17c7f4db$exports from "./et-EE.module.js";
10
- import $4afcfe00cd703f83$exports from "./fi-FI.module.js";
11
- import $1d2645d18d4c5be0$exports from "./fr-FR.module.js";
12
- import $64cb6a9be1f6fa48$exports from "./he-IL.module.js";
13
- import $2a1ef2e8050be27a$exports from "./hr-HR.module.js";
14
- import $ad429dca102acd0e$exports from "./hu-HU.module.js";
15
- import $6e68cb5d1cb97bd2$exports from "./it-IT.module.js";
16
- import $a82ee9af063ee069$exports from "./ja-JP.module.js";
17
- import $67e9091dbf37d4eb$exports from "./ko-KR.module.js";
18
- import $75834f9729f653d1$exports from "./lt-LT.module.js";
19
- import $a2df2c2520b4a7f0$exports from "./lv-LV.module.js";
20
- import $aedcd71db4933ed5$exports from "./nb-NO.module.js";
21
- import $3b2df9e54353046c$exports from "./nl-NL.module.js";
22
- import $c03fe977fcfafe93$exports from "./pl-PL.module.js";
23
- import $569f006fc292345f$exports from "./pt-BR.module.js";
24
- import $7c2494e14452f2dd$exports from "./pt-PT.module.js";
25
- import $eb82ef981b5592bf$exports from "./ro-RO.module.js";
26
- import $6efa0e119f396950$exports from "./ru-RU.module.js";
27
- import $7f5e57085d7f5049$exports from "./sk-SK.module.js";
28
- import $578ee7c11dcdde7a$exports from "./sl-SI.module.js";
29
- import $bbc3fd6cd0bc9d50$exports from "./sr-SP.module.js";
30
- import $0b04512118591d2a$exports from "./sv-SE.module.js";
31
- import $3a49d121fe4c9e1d$exports from "./tr-TR.module.js";
32
- import $5ba21dbb8914919d$exports from "./uk-UA.module.js";
33
- import $51078838e1b16cd7$exports from "./zh-CN.module.js";
34
- import $33fab8219207655a$exports from "./zh-TW.module.js";
35
- import {createFocusManager as $cIPI0$createFocusManager, getFocusableTreeWalker as $cIPI0$getFocusableTreeWalker} from "@react-aria/focus";
36
- import {useId as $cIPI0$useId, useDescription as $cIPI0$useDescription, filterDOMProps as $cIPI0$filterDOMProps, mergeProps as $cIPI0$mergeProps, useFormReset as $cIPI0$useFormReset, isMac as $cIPI0$isMac, scrollIntoViewport as $cIPI0$scrollIntoViewport, getScrollParent as $cIPI0$getScrollParent, useEvent as $cIPI0$useEvent, useLayoutEffect as $cIPI0$useLayoutEffect, isIOS as $cIPI0$isIOS, useLabels as $cIPI0$useLabels} from "@react-aria/utils";
37
- import {privateValidationStateProp as $cIPI0$privateValidationStateProp, DEFAULT_VALIDATION_RESULT as $cIPI0$DEFAULT_VALIDATION_RESULT, mergeValidation as $cIPI0$mergeValidation} from "@react-stately/form";
38
- import $cIPI0$react, {useMemo as $cIPI0$useMemo, useRef as $cIPI0$useRef, useEffect as $cIPI0$useEffect} from "react";
39
- import {useField as $cIPI0$useField} from "@react-aria/label";
40
- import {useFocusWithin as $cIPI0$useFocusWithin, usePress as $cIPI0$usePress} from "@react-aria/interactions";
41
- import {useLocalizedStringFormatter as $cIPI0$useLocalizedStringFormatter, useLocale as $cIPI0$useLocale, useDateFormatter as $cIPI0$useDateFormatter, useFilter as $cIPI0$useFilter, useLocalizedStringDictionary as $cIPI0$useLocalizedStringDictionary} from "@react-aria/i18n";
42
- import {useFormValidation as $cIPI0$useFormValidation} from "@react-aria/form";
43
- import {toCalendar as $cIPI0$toCalendar, CalendarDate as $cIPI0$CalendarDate} from "@internationalized/date";
44
- import {NumberParser as $cIPI0$NumberParser} from "@internationalized/number";
45
- import {useSpinButton as $cIPI0$useSpinButton} from "@react-aria/spinbutton";
46
-
47
-
48
- function $parcel$interopDefault(a) {
49
- return a && a.__esModule ? a.default : a;
50
- }
51
- /*
52
- * Copyright 2020 Adobe. All rights reserved.
53
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
54
- * you may not use this file except in compliance with the License. You may obtain a copy
55
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
56
- *
57
- * Unless required by applicable law or agreed to in writing, software distributed under
58
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
59
- * OF ANY KIND, either express or implied. See the License for the specific language
60
- * governing permissions and limitations under the License.
61
- */ /*
62
- * Copyright 2020 Adobe. All rights reserved.
63
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
64
- * you may not use this file except in compliance with the License. You may obtain a copy
65
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
66
- *
67
- * Unless required by applicable law or agreed to in writing, software distributed under
68
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
69
- * OF ANY KIND, either express or implied. See the License for the specific language
70
- * governing permissions and limitations under the License.
71
- */
72
-
73
- var $dfb4eba373ed9493$exports = {};
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
- $dfb4eba373ed9493$exports = {
109
- "ar-AE": $f23889fffbde9058$exports,
110
- "bg-BG": $09d9badaa8903929$exports,
111
- "cs-CZ": $151b77e0fd711730$exports,
112
- "da-DK": $61915aa8630b90a2$exports,
113
- "de-DE": $35cea00159787840$exports,
114
- "el-GR": $518b4e82b9eacafd$exports,
115
- "en-US": $1c2b297f7e2cf474$exports,
116
- "es-ES": $07f628a707cf9b18$exports,
117
- "et-EE": $db553ffe17c7f4db$exports,
118
- "fi-FI": $4afcfe00cd703f83$exports,
119
- "fr-FR": $1d2645d18d4c5be0$exports,
120
- "he-IL": $64cb6a9be1f6fa48$exports,
121
- "hr-HR": $2a1ef2e8050be27a$exports,
122
- "hu-HU": $ad429dca102acd0e$exports,
123
- "it-IT": $6e68cb5d1cb97bd2$exports,
124
- "ja-JP": $a82ee9af063ee069$exports,
125
- "ko-KR": $67e9091dbf37d4eb$exports,
126
- "lt-LT": $75834f9729f653d1$exports,
127
- "lv-LV": $a2df2c2520b4a7f0$exports,
128
- "nb-NO": $aedcd71db4933ed5$exports,
129
- "nl-NL": $3b2df9e54353046c$exports,
130
- "pl-PL": $c03fe977fcfafe93$exports,
131
- "pt-BR": $569f006fc292345f$exports,
132
- "pt-PT": $7c2494e14452f2dd$exports,
133
- "ro-RO": $eb82ef981b5592bf$exports,
134
- "ru-RU": $6efa0e119f396950$exports,
135
- "sk-SK": $7f5e57085d7f5049$exports,
136
- "sl-SI": $578ee7c11dcdde7a$exports,
137
- "sr-SP": $bbc3fd6cd0bc9d50$exports,
138
- "sv-SE": $0b04512118591d2a$exports,
139
- "tr-TR": $3a49d121fe4c9e1d$exports,
140
- "uk-UA": $5ba21dbb8914919d$exports,
141
- "zh-CN": $51078838e1b16cd7$exports,
142
- "zh-TW": $33fab8219207655a$exports
143
- };
144
-
145
-
146
-
147
-
148
- /*
149
- * Copyright 2020 Adobe. All rights reserved.
150
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
151
- * you may not use this file except in compliance with the License. You may obtain a copy
152
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
153
- *
154
- * Unless required by applicable law or agreed to in writing, software distributed under
155
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
156
- * OF ANY KIND, either express or implied. See the License for the specific language
157
- * governing permissions and limitations under the License.
158
- */
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
- function $3dfb0f96be0d6a08$export$4a931266a3838b86(state, ref, disableArrowNavigation) {
168
- let { direction: direction } = (0, $cIPI0$useLocale)();
169
- let focusManager = (0, $cIPI0$useMemo)(()=>(0, $cIPI0$createFocusManager)(ref), [
170
- ref
171
- ]);
172
- // Open the popover on alt + arrow down
173
- let onKeyDown = (e)=>{
174
- if (!e.currentTarget.contains(e.target)) return;
175
- if (e.altKey && (e.key === "ArrowDown" || e.key === "ArrowUp") && "setOpen" in state) {
176
- e.preventDefault();
177
- e.stopPropagation();
178
- state.setOpen(true);
179
- }
180
- if (disableArrowNavigation) return;
181
- switch(e.key){
182
- case "ArrowLeft":
183
- e.preventDefault();
184
- e.stopPropagation();
185
- if (direction === "rtl") focusManager.focusNext();
186
- else focusManager.focusPrevious();
187
- break;
188
- case "ArrowRight":
189
- e.preventDefault();
190
- e.stopPropagation();
191
- if (direction === "rtl") focusManager.focusPrevious();
192
- else focusManager.focusNext();
193
- break;
194
- }
195
- };
196
- // Focus the first placeholder segment from the end on mouse down/touch up in the field.
197
- let focusLast = ()=>{
198
- var _window_event;
199
- // Try to find the segment prior to the element that was clicked on.
200
- let target = (_window_event = window.event) === null || _window_event === void 0 ? void 0 : _window_event.target;
201
- let walker = (0, $cIPI0$getFocusableTreeWalker)(ref.current, {
202
- tabbable: true
203
- });
204
- if (target) {
205
- walker.currentNode = target;
206
- target = walker.previousNode();
207
- }
208
- // If no target found, find the last element from the end.
209
- if (!target) {
210
- let last;
211
- do {
212
- last = walker.lastChild();
213
- if (last) target = last;
214
- }while (last);
215
- }
216
- // Now go backwards until we find an element that is not a placeholder.
217
- while(target === null || target === void 0 ? void 0 : target.hasAttribute("data-placeholder")){
218
- let prev = walker.previousNode();
219
- if (prev && prev.hasAttribute("data-placeholder")) target = prev;
220
- else break;
221
- }
222
- if (target) target.focus();
223
- };
224
- let { pressProps: pressProps } = (0, $cIPI0$usePress)({
225
- preventFocusOnPress: true,
226
- allowTextSelectionOnPress: true,
227
- onPressStart (e) {
228
- if (e.pointerType === "mouse") focusLast();
229
- },
230
- onPress (e) {
231
- if (e.pointerType !== "mouse") focusLast();
232
- }
233
- });
234
- return (0, $cIPI0$mergeProps)(pressProps, {
235
- onKeyDown: onKeyDown
236
- });
237
- }
238
-
239
-
240
-
241
-
242
-
243
-
244
- const $16f0b7bb276bc17e$export$653eddfc964b0f8a = new WeakMap();
245
- const $16f0b7bb276bc17e$export$300019f83c56d282 = "__role_" + Date.now();
246
- const $16f0b7bb276bc17e$export$7b3062cd49e80452 = "__focusManager_" + Date.now();
247
- function $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref) {
248
- var _state_value;
249
- let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
250
- let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $cIPI0$useField)({
251
- ...props,
252
- labelElementType: "span",
253
- isInvalid: isInvalid,
254
- errorMessage: props.errorMessage || validationErrors
255
- });
256
- let valueOnFocus = (0, $cIPI0$useRef)(null);
257
- let { focusWithinProps: focusWithinProps } = (0, $cIPI0$useFocusWithin)({
258
- ...props,
259
- onFocusWithin (e) {
260
- var _props_onFocus;
261
- valueOnFocus.current = state.value;
262
- (_props_onFocus = props.onFocus) === null || _props_onFocus === void 0 ? void 0 : _props_onFocus.call(props, e);
263
- },
264
- onBlurWithin: (e)=>{
265
- var _props_onBlur;
266
- state.confirmPlaceholder();
267
- if (state.value !== valueOnFocus.current) state.commitValidation();
268
- (_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
269
- },
270
- onFocusWithinChange: props.onFocusChange
271
- });
272
- let stringFormatter = (0, $cIPI0$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($dfb4eba373ed9493$exports))), "@react-aria/datepicker");
273
- let message = state.maxGranularity === "hour" ? "selectedTimeDescription" : "selectedDateDescription";
274
- let field = state.maxGranularity === "hour" ? "time" : "date";
275
- let description = state.value ? stringFormatter.format(message, {
276
- [field]: state.formatValue({
277
- month: "long"
278
- })
279
- }) : "";
280
- let descProps = (0, $cIPI0$useDescription)(description);
281
- // If within a date picker or date range picker, the date field will have role="presentation" and an aria-describedby
282
- // will be passed in that references the value (e.g. entire range). Otherwise, add the field's value description.
283
- let describedBy = props[$16f0b7bb276bc17e$export$300019f83c56d282] === "presentation" ? fieldProps["aria-describedby"] : [
284
- descProps["aria-describedby"],
285
- fieldProps["aria-describedby"]
286
- ].filter(Boolean).join(" ") || undefined;
287
- let propsFocusManager = props[$16f0b7bb276bc17e$export$7b3062cd49e80452];
288
- let focusManager = (0, $cIPI0$useMemo)(()=>propsFocusManager || (0, $cIPI0$createFocusManager)(ref), [
289
- propsFocusManager,
290
- ref
291
- ]);
292
- let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref, props[$16f0b7bb276bc17e$export$300019f83c56d282] === "presentation");
293
- // Pass labels and other information to segments.
294
- $16f0b7bb276bc17e$export$653eddfc964b0f8a.set(state, {
295
- ariaLabel: props["aria-label"],
296
- ariaLabelledBy: [
297
- labelProps.id,
298
- props["aria-labelledby"]
299
- ].filter(Boolean).join(" ") || undefined,
300
- ariaDescribedBy: describedBy,
301
- focusManager: focusManager
302
- });
303
- let autoFocusRef = (0, $cIPI0$useRef)(props.autoFocus);
304
- // When used within a date picker or date range picker, the field gets role="presentation"
305
- // rather than role="group". Since the date picker/date range picker already has a role="group"
306
- // with a label and description, and the segments are already labeled by this as well, this
307
- // avoids very verbose duplicate announcements.
308
- let fieldDOMProps;
309
- if (props[$16f0b7bb276bc17e$export$300019f83c56d282] === "presentation") fieldDOMProps = {
310
- role: "presentation"
311
- };
312
- else fieldDOMProps = (0, $cIPI0$mergeProps)(fieldProps, {
313
- role: "group",
314
- "aria-disabled": props.isDisabled || undefined,
315
- "aria-describedby": describedBy
316
- });
317
- (0, $cIPI0$useEffect)(()=>{
318
- if (autoFocusRef.current) focusManager.focusFirst();
319
- autoFocusRef.current = false;
320
- }, [
321
- focusManager
322
- ]);
323
- (0, $cIPI0$useFormReset)(props.inputRef, state.value, state.setValue);
324
- (0, $cIPI0$useFormValidation)({
325
- ...props,
326
- focus () {
327
- focusManager.focusFirst();
328
- }
329
- }, state, props.inputRef);
330
- let inputProps = {
331
- type: "hidden",
332
- name: props.name,
333
- value: ((_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.toString()) || ""
334
- };
335
- if (props.validationBehavior === "native") {
336
- // Use a hidden <input type="text"> rather than <input type="hidden">
337
- // so that an empty value blocks HTML form submission when the field is required.
338
- inputProps.type = "text";
339
- inputProps.hidden = true;
340
- inputProps.required = props.isRequired;
341
- // Ignore react warning.
342
- inputProps.onChange = ()=>{};
343
- }
344
- let domProps = (0, $cIPI0$filterDOMProps)(props);
345
- return {
346
- labelProps: {
347
- ...labelProps,
348
- onClick: ()=>{
349
- focusManager.focusFirst();
350
- }
351
- },
352
- fieldProps: (0, $cIPI0$mergeProps)(domProps, fieldDOMProps, groupProps, focusWithinProps, {
353
- onKeyDown (e) {
354
- if (props.onKeyDown) props.onKeyDown(e);
355
- },
356
- onKeyUp (e) {
357
- if (props.onKeyUp) props.onKeyUp(e);
358
- }
359
- }),
360
- inputProps: inputProps,
361
- descriptionProps: descriptionProps,
362
- errorMessageProps: errorMessageProps,
363
- isInvalid: isInvalid,
364
- validationErrors: validationErrors,
365
- validationDetails: validationDetails
366
- };
367
- }
368
- function $16f0b7bb276bc17e$export$4c842f6a241dc825(props, state, ref) {
369
- var _state_timeValue;
370
- let res = $16f0b7bb276bc17e$export$5591b0b878c1a989(props, state, ref);
371
- res.inputProps.value = ((_state_timeValue = state.timeValue) === null || _state_timeValue === void 0 ? void 0 : _state_timeValue.toString()) || "";
372
- return res;
373
- }
374
-
375
-
376
-
377
-
378
-
379
-
380
- function $6057a3d2a53a12fd$export$42df105a73306d51(props, state, ref) {
381
- let buttonId = (0, $cIPI0$useId)();
382
- let dialogId = (0, $cIPI0$useId)();
383
- let fieldId = (0, $cIPI0$useId)();
384
- let stringFormatter = (0, $cIPI0$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($dfb4eba373ed9493$exports))), "@react-aria/datepicker");
385
- let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
386
- let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $cIPI0$useField)({
387
- ...props,
388
- labelElementType: "span",
389
- isInvalid: isInvalid,
390
- errorMessage: props.errorMessage || validationErrors
391
- });
392
- let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
393
- let labelledBy = fieldProps["aria-labelledby"] || fieldProps.id;
394
- let { locale: locale } = (0, $cIPI0$useLocale)();
395
- let date = state.formatValue(locale, {
396
- month: "long"
397
- });
398
- let description = date ? stringFormatter.format("selectedDateDescription", {
399
- date: date
400
- }) : "";
401
- let descProps = (0, $cIPI0$useDescription)(description);
402
- let ariaDescribedBy = [
403
- descProps["aria-describedby"],
404
- fieldProps["aria-describedby"]
405
- ].filter(Boolean).join(" ") || undefined;
406
- let domProps = (0, $cIPI0$filterDOMProps)(props);
407
- let focusManager = (0, $cIPI0$useMemo)(()=>(0, $cIPI0$createFocusManager)(ref), [
408
- ref
409
- ]);
410
- let { focusWithinProps: focusWithinProps } = (0, $cIPI0$useFocusWithin)({
411
- ...props,
412
- isDisabled: state.isOpen,
413
- onBlurWithin: props.onBlur,
414
- onFocusWithin: props.onFocus,
415
- onFocusWithinChange: props.onFocusChange
416
- });
417
- return {
418
- groupProps: (0, $cIPI0$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
419
- role: "group",
420
- "aria-disabled": props.isDisabled || null,
421
- "aria-labelledby": labelledBy,
422
- "aria-describedby": ariaDescribedBy,
423
- onKeyDown (e) {
424
- if (state.isOpen) return;
425
- if (props.onKeyDown) props.onKeyDown(e);
426
- },
427
- onKeyUp (e) {
428
- if (state.isOpen) return;
429
- if (props.onKeyUp) props.onKeyUp(e);
430
- }
431
- }),
432
- labelProps: {
433
- ...labelProps,
434
- onClick: ()=>{
435
- focusManager.focusFirst();
436
- }
437
- },
438
- fieldProps: {
439
- ...fieldProps,
440
- id: fieldId,
441
- [(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: "presentation",
442
- "aria-describedby": ariaDescribedBy,
443
- value: state.value,
444
- onChange: state.setValue,
445
- placeholderValue: props.placeholderValue,
446
- hideTimeZone: props.hideTimeZone,
447
- hourCycle: props.hourCycle,
448
- shouldForceLeadingZeros: props.shouldForceLeadingZeros,
449
- granularity: props.granularity,
450
- isDisabled: props.isDisabled,
451
- isReadOnly: props.isReadOnly,
452
- isRequired: props.isRequired,
453
- validationBehavior: props.validationBehavior,
454
- // DatePicker owns the validation state for the date field.
455
- [(0, $cIPI0$privateValidationStateProp)]: state,
456
- autoFocus: props.autoFocus,
457
- name: props.name
458
- },
459
- descriptionProps: descriptionProps,
460
- errorMessageProps: errorMessageProps,
461
- buttonProps: {
462
- ...descProps,
463
- id: buttonId,
464
- "aria-haspopup": "dialog",
465
- "aria-label": stringFormatter.format("calendar"),
466
- "aria-labelledby": `${buttonId} ${labelledBy}`,
467
- "aria-describedby": ariaDescribedBy,
468
- "aria-expanded": state.isOpen,
469
- isDisabled: props.isDisabled || props.isReadOnly,
470
- onPress: ()=>state.setOpen(true)
471
- },
472
- dialogProps: {
473
- id: dialogId,
474
- "aria-labelledby": `${buttonId} ${labelledBy}`
475
- },
476
- calendarProps: {
477
- autoFocus: true,
478
- value: state.dateValue,
479
- onChange: state.setDateValue,
480
- minValue: props.minValue,
481
- maxValue: props.maxValue,
482
- isDisabled: props.isDisabled,
483
- isReadOnly: props.isReadOnly,
484
- isDateUnavailable: props.isDateUnavailable,
485
- defaultFocusedValue: state.dateValue ? undefined : props.placeholderValue,
486
- isInvalid: state.isInvalid,
487
- errorMessage: typeof props.errorMessage === "function" ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(" ")
488
- },
489
- isInvalid: isInvalid,
490
- validationErrors: validationErrors,
491
- validationDetails: validationDetails
492
- };
493
- }
494
-
495
-
496
- /*
497
- * Copyright 2020 Adobe. All rights reserved.
498
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
499
- * you may not use this file except in compliance with the License. You may obtain a copy
500
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
501
- *
502
- * Unless required by applicable law or agreed to in writing, software distributed under
503
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
504
- * OF ANY KIND, either express or implied. See the License for the specific language
505
- * governing permissions and limitations under the License.
506
- */
507
-
508
-
509
-
510
-
511
-
512
- /*
513
- * Copyright 2020 Adobe. All rights reserved.
514
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
515
- * you may not use this file except in compliance with the License. You may obtain a copy
516
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
517
- *
518
- * Unless required by applicable law or agreed to in writing, software distributed under
519
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
520
- * OF ANY KIND, either express or implied. See the License for the specific language
521
- * governing permissions and limitations under the License.
522
- */ // @ts-ignore
523
-
524
-
525
-
526
- function $3aeceb3a64eb8358$export$d42c60378c8168f8() {
527
- let { locale: locale } = (0, $cIPI0$useLocale)();
528
- let dictionary = (0, $cIPI0$useLocalizedStringDictionary)((0, (/*@__PURE__*/$parcel$interopDefault($dfb4eba373ed9493$exports))), "@react-aria/datepicker");
529
- return (0, $cIPI0$useMemo)(()=>{
530
- // Try to use Intl.DisplayNames if possible. It may be supported in browsers, but not support the dateTimeField
531
- // type as that was only added in v2. https://github.com/tc39/intl-displaynames-v2
532
- try {
533
- // @ts-ignore
534
- return new Intl.DisplayNames(locale, {
535
- type: "dateTimeField"
536
- });
537
- } catch (err) {
538
- return new $3aeceb3a64eb8358$var$DisplayNamesPolyfill(locale, dictionary);
539
- }
540
- }, [
541
- locale,
542
- dictionary
543
- ]);
544
- }
545
- class $3aeceb3a64eb8358$var$DisplayNamesPolyfill {
546
- of(field) {
547
- return this.dictionary.getStringForLocale(field, this.locale);
548
- }
549
- constructor(locale, dictionary){
550
- this.locale = locale;
551
- this.dictionary = dictionary;
552
- }
553
- }
554
-
555
-
556
-
557
- function $32489daedd52963e$export$1315d136e6f7581(segment, state, ref) {
558
- let enteredKeys = (0, $cIPI0$useRef)("");
559
- let { locale: locale } = (0, $cIPI0$useLocale)();
560
- let displayNames = (0, $3aeceb3a64eb8358$export$d42c60378c8168f8)();
561
- let { ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy, ariaDescribedBy: ariaDescribedBy, focusManager: focusManager } = (0, $16f0b7bb276bc17e$export$653eddfc964b0f8a).get(state);
562
- let textValue = segment.isPlaceholder ? "" : segment.text;
563
- let options = (0, $cIPI0$useMemo)(()=>state.dateFormatter.resolvedOptions(), [
564
- state.dateFormatter
565
- ]);
566
- let monthDateFormatter = (0, $cIPI0$useDateFormatter)({
567
- month: "long",
568
- timeZone: options.timeZone
569
- });
570
- let hourDateFormatter = (0, $cIPI0$useDateFormatter)({
571
- hour: "numeric",
572
- hour12: options.hour12,
573
- timeZone: options.timeZone
574
- });
575
- if (segment.type === "month" && !segment.isPlaceholder) {
576
- let monthTextValue = monthDateFormatter.format(state.dateValue);
577
- textValue = monthTextValue !== textValue ? `${textValue} \u{2013} ${monthTextValue}` : monthTextValue;
578
- } else if (segment.type === "hour" && !segment.isPlaceholder) textValue = hourDateFormatter.format(state.dateValue);
579
- let { spinButtonProps: spinButtonProps } = (0, $cIPI0$useSpinButton)({
580
- // The ARIA spec says aria-valuenow is optional if there's no value, but aXe seems to require it.
581
- // This doesn't seem to have any negative effects with real AT since we also use aria-valuetext.
582
- // https://github.com/dequelabs/axe-core/issues/3505
583
- value: segment.value,
584
- textValue: textValue,
585
- minValue: segment.minValue,
586
- maxValue: segment.maxValue,
587
- isDisabled: state.isDisabled,
588
- isReadOnly: state.isReadOnly || !segment.isEditable,
589
- isRequired: state.isRequired,
590
- onIncrement: ()=>{
591
- enteredKeys.current = "";
592
- state.increment(segment.type);
593
- },
594
- onDecrement: ()=>{
595
- enteredKeys.current = "";
596
- state.decrement(segment.type);
597
- },
598
- onIncrementPage: ()=>{
599
- enteredKeys.current = "";
600
- state.incrementPage(segment.type);
601
- },
602
- onDecrementPage: ()=>{
603
- enteredKeys.current = "";
604
- state.decrementPage(segment.type);
605
- },
606
- onIncrementToMax: ()=>{
607
- enteredKeys.current = "";
608
- state.setSegment(segment.type, segment.maxValue);
609
- },
610
- onDecrementToMin: ()=>{
611
- enteredKeys.current = "";
612
- state.setSegment(segment.type, segment.minValue);
613
- }
614
- });
615
- let parser = (0, $cIPI0$useMemo)(()=>new (0, $cIPI0$NumberParser)(locale, {
616
- maximumFractionDigits: 0
617
- }), [
618
- locale
619
- ]);
620
- let backspace = ()=>{
621
- if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly && !segment.isPlaceholder) {
622
- let newValue = segment.text.slice(0, -1);
623
- let parsed = parser.parse(newValue);
624
- if (newValue.length === 0 || parsed === 0) state.clearSegment(segment.type);
625
- else state.setSegment(segment.type, parsed);
626
- enteredKeys.current = newValue;
627
- } else if (segment.type === "dayPeriod") state.clearSegment(segment.type);
628
- };
629
- let onKeyDown = (e)=>{
630
- // Firefox does not fire selectstart for Ctrl/Cmd + A
631
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1742153
632
- if (e.key === "a" && ((0, $cIPI0$isMac)() ? e.metaKey : e.ctrlKey)) e.preventDefault();
633
- if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return;
634
- switch(e.key){
635
- case "Backspace":
636
- case "Delete":
637
- // Safari on iOS does not fire beforeinput for the backspace key because the cursor is at the start.
638
- e.preventDefault();
639
- e.stopPropagation();
640
- backspace();
641
- break;
642
- }
643
- };
644
- // Safari dayPeriod option doesn't work...
645
- let { startsWith: startsWith } = (0, $cIPI0$useFilter)({
646
- sensitivity: "base"
647
- });
648
- let amPmFormatter = (0, $cIPI0$useDateFormatter)({
649
- hour: "numeric",
650
- hour12: true
651
- });
652
- let am = (0, $cIPI0$useMemo)(()=>{
653
- let date = new Date();
654
- date.setHours(0);
655
- return amPmFormatter.formatToParts(date).find((part)=>part.type === "dayPeriod").value;
656
- }, [
657
- amPmFormatter
658
- ]);
659
- let pm = (0, $cIPI0$useMemo)(()=>{
660
- let date = new Date();
661
- date.setHours(12);
662
- return amPmFormatter.formatToParts(date).find((part)=>part.type === "dayPeriod").value;
663
- }, [
664
- amPmFormatter
665
- ]);
666
- // Get a list of formatted era names so users can type the first character to choose one.
667
- let eraFormatter = (0, $cIPI0$useDateFormatter)({
668
- year: "numeric",
669
- era: "narrow",
670
- timeZone: "UTC"
671
- });
672
- let eras = (0, $cIPI0$useMemo)(()=>{
673
- if (segment.type !== "era") return [];
674
- let date = (0, $cIPI0$toCalendar)(new (0, $cIPI0$CalendarDate)(1, 1, 1), state.calendar);
675
- let eras = state.calendar.getEras().map((era)=>{
676
- let eraDate = date.set({
677
- year: 1,
678
- month: 1,
679
- day: 1,
680
- era: era
681
- }).toDate("UTC");
682
- let parts = eraFormatter.formatToParts(eraDate);
683
- let formatted = parts.find((p)=>p.type === "era").value;
684
- return {
685
- era: era,
686
- formatted: formatted
687
- };
688
- });
689
- // Remove the common prefix from formatted values. This is so that in calendars with eras like
690
- // ERA0 and ERA1 (e.g. Ethiopic), users can press "0" and "1" to select an era. In other cases,
691
- // the first letter is used.
692
- let prefixLength = $32489daedd52963e$var$commonPrefixLength(eras.map((era)=>era.formatted));
693
- if (prefixLength) for (let era of eras)era.formatted = era.formatted.slice(prefixLength);
694
- return eras;
695
- }, [
696
- eraFormatter,
697
- state.calendar,
698
- segment.type
699
- ]);
700
- let onInput = (key)=>{
701
- if (state.isDisabled || state.isReadOnly) return;
702
- let newValue = enteredKeys.current + key;
703
- switch(segment.type){
704
- case "dayPeriod":
705
- if (startsWith(am, key)) state.setSegment("dayPeriod", 0);
706
- else if (startsWith(pm, key)) state.setSegment("dayPeriod", 12);
707
- else break;
708
- focusManager.focusNext();
709
- break;
710
- case "era":
711
- {
712
- let matched = eras.find((e)=>startsWith(e.formatted, key));
713
- if (matched) {
714
- state.setSegment("era", matched.era);
715
- focusManager.focusNext();
716
- }
717
- break;
718
- }
719
- case "day":
720
- case "hour":
721
- case "minute":
722
- case "second":
723
- case "month":
724
- case "year":
725
- {
726
- if (!parser.isValidPartialNumber(newValue)) return;
727
- let numberValue = parser.parse(newValue);
728
- let segmentValue = numberValue;
729
- let allowsZero = segment.minValue === 0;
730
- if (segment.type === "hour" && state.dateFormatter.resolvedOptions().hour12) {
731
- switch(state.dateFormatter.resolvedOptions().hourCycle){
732
- case "h11":
733
- if (numberValue > 11) segmentValue = parser.parse(key);
734
- break;
735
- case "h12":
736
- allowsZero = false;
737
- if (numberValue > 12) segmentValue = parser.parse(key);
738
- break;
739
- }
740
- if (segment.value >= 12 && numberValue > 1) numberValue += 12;
741
- } else if (numberValue > segment.maxValue) segmentValue = parser.parse(key);
742
- if (isNaN(numberValue)) return;
743
- let shouldSetValue = segmentValue !== 0 || allowsZero;
744
- if (shouldSetValue) state.setSegment(segment.type, segmentValue);
745
- if (Number(numberValue + "0") > segment.maxValue || newValue.length >= String(segment.maxValue).length) {
746
- enteredKeys.current = "";
747
- if (shouldSetValue) focusManager.focusNext();
748
- } else enteredKeys.current = newValue;
749
- break;
750
- }
751
- }
752
- };
753
- let onFocus = ()=>{
754
- enteredKeys.current = "";
755
- (0, $cIPI0$scrollIntoViewport)(ref.current, {
756
- containingElement: (0, $cIPI0$getScrollParent)(ref.current)
757
- });
758
- // Collapse selection to start or Chrome won't fire input events.
759
- let selection = window.getSelection();
760
- selection.collapse(ref.current);
761
- };
762
- let compositionRef = (0, $cIPI0$useRef)("");
763
- // @ts-ignore - TODO: possibly old TS version? doesn't fail in my editor...
764
- (0, $cIPI0$useEvent)(ref, "beforeinput", (e)=>{
765
- e.preventDefault();
766
- switch(e.inputType){
767
- case "deleteContentBackward":
768
- case "deleteContentForward":
769
- if (parser.isValidPartialNumber(segment.text) && !state.isReadOnly) backspace();
770
- break;
771
- case "insertCompositionText":
772
- // insertCompositionText cannot be canceled.
773
- // Record the current state of the element so we can restore it in the `input` event below.
774
- compositionRef.current = ref.current.textContent;
775
- // Safari gets stuck in a composition state unless we also assign to the value here.
776
- // eslint-disable-next-line no-self-assign
777
- ref.current.textContent = ref.current.textContent;
778
- break;
779
- default:
780
- if (e.data != null) onInput(e.data);
781
- break;
782
- }
783
- });
784
- (0, $cIPI0$useEvent)(ref, "input", (e)=>{
785
- let { inputType: inputType, data: data } = e;
786
- switch(inputType){
787
- case "insertCompositionText":
788
- // Reset the DOM to how it was in the beforeinput event.
789
- ref.current.textContent = compositionRef.current;
790
- // Android sometimes fires key presses of letters as composition events. Need to handle am/pm keys here too.
791
- // Can also happen e.g. with Pinyin keyboard on iOS.
792
- if (startsWith(am, data) || startsWith(pm, data)) onInput(data);
793
- break;
794
- }
795
- });
796
- (0, $cIPI0$useLayoutEffect)(()=>{
797
- let element = ref.current;
798
- return ()=>{
799
- // If the focused segment is removed, focus the previous one, or the next one if there was no previous one.
800
- if (document.activeElement === element) {
801
- let prev = focusManager.focusPrevious();
802
- if (!prev) focusManager.focusNext();
803
- }
804
- };
805
- }, [
806
- ref,
807
- focusManager
808
- ]);
809
- // spinbuttons cannot be focused with VoiceOver on iOS.
810
- let touchPropOverrides = (0, $cIPI0$isIOS)() || segment.type === "timeZoneName" ? {
811
- role: "textbox",
812
- "aria-valuemax": null,
813
- "aria-valuemin": null,
814
- "aria-valuetext": null,
815
- "aria-valuenow": null
816
- } : {};
817
- // Only apply aria-describedby to the first segment, unless the field is invalid. This avoids it being
818
- // read every time the user navigates to a new segment.
819
- let firstSegment = (0, $cIPI0$useMemo)(()=>state.segments.find((s)=>s.isEditable), [
820
- state.segments
821
- ]);
822
- if (segment !== firstSegment && !state.isInvalid) ariaDescribedBy = undefined;
823
- let id = (0, $cIPI0$useId)();
824
- let isEditable = !state.isDisabled && !state.isReadOnly && segment.isEditable;
825
- // Prepend the label passed from the field to each segment name.
826
- // This is needed because VoiceOver on iOS does not announce groups.
827
- let name = segment.type === "literal" ? "" : displayNames.of(segment.type);
828
- let labelProps = (0, $cIPI0$useLabels)({
829
- "aria-label": `${name}${ariaLabel ? `, ${ariaLabel}` : ""}${ariaLabelledBy ? ", " : ""}`,
830
- "aria-labelledby": ariaLabelledBy
831
- });
832
- // Literal segments should not be visible to screen readers. We don't really need any of the above,
833
- // but the rules of hooks mean hooks cannot be conditional so we have to put this condition here.
834
- if (segment.type === "literal") return {
835
- segmentProps: {
836
- "aria-hidden": true
837
- }
838
- };
839
- return {
840
- segmentProps: (0, $cIPI0$mergeProps)(spinButtonProps, labelProps, {
841
- id: id,
842
- ...touchPropOverrides,
843
- "aria-invalid": state.isInvalid ? "true" : undefined,
844
- "aria-describedby": ariaDescribedBy,
845
- "aria-readonly": state.isReadOnly || !segment.isEditable ? "true" : undefined,
846
- "data-placeholder": segment.isPlaceholder || undefined,
847
- contentEditable: isEditable,
848
- suppressContentEditableWarning: isEditable,
849
- spellCheck: isEditable ? "false" : undefined,
850
- autoCapitalize: isEditable ? "off" : undefined,
851
- autoCorrect: isEditable ? "off" : undefined,
852
- // Capitalization was changed in React 17...
853
- [parseInt((0, $cIPI0$react).version, 10) >= 17 ? "enterKeyHint" : "enterkeyhint"]: isEditable ? "next" : undefined,
854
- inputMode: state.isDisabled || segment.type === "dayPeriod" || segment.type === "era" || !isEditable ? undefined : "numeric",
855
- tabIndex: state.isDisabled ? undefined : 0,
856
- onKeyDown: onKeyDown,
857
- onFocus: onFocus,
858
- style: {
859
- caretColor: "transparent"
860
- },
861
- // Prevent pointer events from reaching useDatePickerGroup, and allow native browser behavior to focus the segment.
862
- onPointerDown (e) {
863
- e.stopPropagation();
864
- },
865
- onMouseDown (e) {
866
- e.stopPropagation();
867
- }
868
- })
869
- };
870
- }
871
- function $32489daedd52963e$var$commonPrefixLength(strings) {
872
- // Sort the strings, and compare the characters in the first and last to find the common prefix.
873
- strings.sort();
874
- let first = strings[0];
875
- let last = strings[strings.length - 1];
876
- for(let i = 0; i < first.length; i++){
877
- if (first[i] !== last[i]) return i;
878
- }
879
- return 0;
880
- }
881
-
882
-
1
+ import {useDatePicker as $6057a3d2a53a12fd$export$42df105a73306d51} from "./useDatePicker.module.js";
2
+ import {useDateSegment as $32489daedd52963e$export$1315d136e6f7581} from "./useDateSegment.module.js";
3
+ import {useDateField as $16f0b7bb276bc17e$export$5591b0b878c1a989, useTimeField as $16f0b7bb276bc17e$export$4c842f6a241dc825} from "./useDateField.module.js";
4
+ import {useDateRangePicker as $887cac91b7cc8801$export$12fd5f0e9f4bb192} from "./useDateRangePicker.module.js";
5
+ import {useDisplayNames as $3aeceb3a64eb8358$export$d42c60378c8168f8} from "./useDisplayNames.module.js";
883
6
 
884
7
  /*
885
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -898,170 +21,5 @@ function $32489daedd52963e$var$commonPrefixLength(strings) {
898
21
 
899
22
 
900
23
 
901
-
902
-
903
-
904
- function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
905
- var _state_value, _state_value1;
906
- let stringFormatter = (0, $cIPI0$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($dfb4eba373ed9493$exports))), "@react-aria/datepicker");
907
- let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
908
- let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $cIPI0$useField)({
909
- ...props,
910
- labelElementType: "span",
911
- isInvalid: isInvalid,
912
- errorMessage: props.errorMessage || validationErrors
913
- });
914
- let labelledBy = fieldProps["aria-labelledby"] || fieldProps.id;
915
- let { locale: locale } = (0, $cIPI0$useLocale)();
916
- let range = state.formatValue(locale, {
917
- month: "long"
918
- });
919
- let description = range ? stringFormatter.format("selectedRangeDescription", {
920
- startDate: range.start,
921
- endDate: range.end
922
- }) : "";
923
- let descProps = (0, $cIPI0$useDescription)(description);
924
- let startFieldProps = {
925
- "aria-label": stringFormatter.format("startDate"),
926
- "aria-labelledby": labelledBy
927
- };
928
- let endFieldProps = {
929
- "aria-label": stringFormatter.format("endDate"),
930
- "aria-labelledby": labelledBy
931
- };
932
- let buttonId = (0, $cIPI0$useId)();
933
- let dialogId = (0, $cIPI0$useId)();
934
- let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
935
- let ariaDescribedBy = [
936
- descProps["aria-describedby"],
937
- fieldProps["aria-describedby"]
938
- ].filter(Boolean).join(" ") || undefined;
939
- let focusManager = (0, $cIPI0$useMemo)(()=>(0, $cIPI0$createFocusManager)(ref, {
940
- // Exclude the button from the focus manager.
941
- accept: (element)=>element.id !== buttonId
942
- }), [
943
- ref,
944
- buttonId
945
- ]);
946
- let commonFieldProps = {
947
- [(0, $16f0b7bb276bc17e$export$7b3062cd49e80452)]: focusManager,
948
- [(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: "presentation",
949
- "aria-describedby": ariaDescribedBy,
950
- placeholderValue: props.placeholderValue,
951
- hideTimeZone: props.hideTimeZone,
952
- hourCycle: props.hourCycle,
953
- granularity: props.granularity,
954
- shouldForceLeadingZeros: props.shouldForceLeadingZeros,
955
- isDisabled: props.isDisabled,
956
- isReadOnly: props.isReadOnly,
957
- isRequired: props.isRequired,
958
- validationBehavior: props.validationBehavior
959
- };
960
- let domProps = (0, $cIPI0$filterDOMProps)(props);
961
- let { focusWithinProps: focusWithinProps } = (0, $cIPI0$useFocusWithin)({
962
- ...props,
963
- isDisabled: state.isOpen,
964
- onBlurWithin: props.onBlur,
965
- onFocusWithin: props.onFocus,
966
- onFocusWithinChange: props.onFocusChange
967
- });
968
- let startFieldValidation = (0, $cIPI0$useRef)((0, $cIPI0$DEFAULT_VALIDATION_RESULT));
969
- let endFieldValidation = (0, $cIPI0$useRef)((0, $cIPI0$DEFAULT_VALIDATION_RESULT));
970
- return {
971
- groupProps: (0, $cIPI0$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
972
- role: "group",
973
- "aria-disabled": props.isDisabled || null,
974
- "aria-describedby": ariaDescribedBy,
975
- onKeyDown (e) {
976
- if (state.isOpen) return;
977
- if (props.onKeyDown) props.onKeyDown(e);
978
- },
979
- onKeyUp (e) {
980
- if (state.isOpen) return;
981
- if (props.onKeyUp) props.onKeyUp(e);
982
- }
983
- }),
984
- labelProps: {
985
- ...labelProps,
986
- onClick: ()=>{
987
- focusManager.focusFirst();
988
- }
989
- },
990
- buttonProps: {
991
- ...descProps,
992
- id: buttonId,
993
- "aria-haspopup": "dialog",
994
- "aria-label": stringFormatter.format("calendar"),
995
- "aria-labelledby": `${buttonId} ${labelledBy}`,
996
- "aria-describedby": ariaDescribedBy,
997
- "aria-expanded": state.isOpen,
998
- isDisabled: props.isDisabled || props.isReadOnly,
999
- onPress: ()=>state.setOpen(true)
1000
- },
1001
- dialogProps: {
1002
- id: dialogId,
1003
- "aria-labelledby": `${buttonId} ${labelledBy}`
1004
- },
1005
- startFieldProps: {
1006
- ...startFieldProps,
1007
- ...commonFieldProps,
1008
- value: (_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.start,
1009
- onChange: (start)=>state.setDateTime("start", start),
1010
- autoFocus: props.autoFocus,
1011
- name: props.startName,
1012
- [(0, $cIPI0$privateValidationStateProp)]: {
1013
- realtimeValidation: state.realtimeValidation,
1014
- displayValidation: state.displayValidation,
1015
- updateValidation (e) {
1016
- startFieldValidation.current = e;
1017
- state.updateValidation((0, $cIPI0$mergeValidation)(e, endFieldValidation.current));
1018
- },
1019
- resetValidation: state.resetValidation,
1020
- commitValidation: state.commitValidation
1021
- }
1022
- },
1023
- endFieldProps: {
1024
- ...endFieldProps,
1025
- ...commonFieldProps,
1026
- value: (_state_value1 = state.value) === null || _state_value1 === void 0 ? void 0 : _state_value1.end,
1027
- onChange: (end)=>state.setDateTime("end", end),
1028
- name: props.endName,
1029
- [(0, $cIPI0$privateValidationStateProp)]: {
1030
- realtimeValidation: state.realtimeValidation,
1031
- displayValidation: state.displayValidation,
1032
- updateValidation (e) {
1033
- endFieldValidation.current = e;
1034
- state.updateValidation((0, $cIPI0$mergeValidation)(startFieldValidation.current, e));
1035
- },
1036
- resetValidation: state.resetValidation,
1037
- commitValidation: state.commitValidation
1038
- }
1039
- },
1040
- descriptionProps: descriptionProps,
1041
- errorMessageProps: errorMessageProps,
1042
- calendarProps: {
1043
- autoFocus: true,
1044
- value: state.dateRange,
1045
- onChange: state.setDateRange,
1046
- minValue: props.minValue,
1047
- maxValue: props.maxValue,
1048
- isDisabled: props.isDisabled,
1049
- isReadOnly: props.isReadOnly,
1050
- isDateUnavailable: props.isDateUnavailable,
1051
- allowsNonContiguousRanges: props.allowsNonContiguousRanges,
1052
- defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
1053
- isInvalid: state.isInvalid,
1054
- errorMessage: typeof props.errorMessage === "function" ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(" ")
1055
- },
1056
- isInvalid: isInvalid,
1057
- validationErrors: validationErrors,
1058
- validationDetails: validationDetails
1059
- };
1060
- }
1061
-
1062
-
1063
-
1064
-
1065
-
1066
24
  export {$6057a3d2a53a12fd$export$42df105a73306d51 as useDatePicker, $32489daedd52963e$export$1315d136e6f7581 as useDateSegment, $16f0b7bb276bc17e$export$5591b0b878c1a989 as useDateField, $16f0b7bb276bc17e$export$4c842f6a241dc825 as useTimeField, $887cac91b7cc8801$export$12fd5f0e9f4bb192 as useDateRangePicker, $3aeceb3a64eb8358$export$d42c60378c8168f8 as useDisplayNames};
1067
25
  //# sourceMappingURL=module.js.map