@react-aria/calendar 3.5.6 → 3.5.7

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 +4 -778
  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 +8 -782
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +4 -778
  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/useCalendar.main.js +25 -0
  45. package/dist/useCalendar.main.js.map +1 -0
  46. package/dist/useCalendar.mjs +20 -0
  47. package/dist/useCalendar.module.js +20 -0
  48. package/dist/useCalendar.module.js.map +1 -0
  49. package/dist/useCalendarBase.main.js +112 -0
  50. package/dist/useCalendarBase.main.js.map +1 -0
  51. package/dist/useCalendarBase.mjs +107 -0
  52. package/dist/useCalendarBase.module.js +107 -0
  53. package/dist/useCalendarBase.module.js.map +1 -0
  54. package/dist/useCalendarCell.main.js +276 -0
  55. package/dist/useCalendarCell.main.js.map +1 -0
  56. package/dist/useCalendarCell.mjs +271 -0
  57. package/dist/useCalendarCell.module.js +271 -0
  58. package/dist/useCalendarCell.module.js.map +1 -0
  59. package/dist/useCalendarGrid.main.js +139 -0
  60. package/dist/useCalendarGrid.main.js.map +1 -0
  61. package/dist/useCalendarGrid.mjs +134 -0
  62. package/dist/useCalendarGrid.module.js +134 -0
  63. package/dist/useCalendarGrid.module.js.map +1 -0
  64. package/dist/useRangeCalendar.main.js +66 -0
  65. package/dist/useRangeCalendar.main.js.map +1 -0
  66. package/dist/useRangeCalendar.mjs +61 -0
  67. package/dist/useRangeCalendar.module.js +61 -0
  68. package/dist/useRangeCalendar.module.js.map +1 -0
  69. package/dist/utils.main.js +138 -0
  70. package/dist/utils.main.js.map +1 -0
  71. package/dist/utils.mjs +130 -0
  72. package/dist/utils.module.js +130 -0
  73. package/dist/utils.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 +11 -11
  77. package/src/useRangeCalendar.ts +6 -5
package/dist/module.js CHANGED
@@ -1,356 +1,7 @@
1
- import $39324ace0d945f59$exports from "./ar-AE.module.js";
2
- import $1830a539e98c7baf$exports from "./bg-BG.module.js";
3
- import $f4b92528965aab97$exports from "./cs-CZ.module.js";
4
- import $1cd578ef0547c8f1$exports from "./da-DK.module.js";
5
- import $db55a8973925d619$exports from "./de-DE.module.js";
6
- import $ec6937d58566d443$exports from "./el-GR.module.js";
7
- import $1f5cea0742dc284a$exports from "./en-US.module.js";
8
- import $2ca7ea366384817b$exports from "./es-ES.module.js";
9
- import $97874a7fe9cd091f$exports from "./et-EE.module.js";
10
- import $5d376b7fce1a45b2$exports from "./fi-FI.module.js";
11
- import $3bf722b362aaf54d$exports from "./fr-FR.module.js";
12
- import $38c43f8322316031$exports from "./he-IL.module.js";
13
- import $c90e0f32b44630bf$exports from "./hr-HR.module.js";
14
- import $715875e6e7a338f4$exports from "./hu-HU.module.js";
15
- import $37d77c66e34daccf$exports from "./it-IT.module.js";
16
- import $542f39aee29303c3$exports from "./ja-JP.module.js";
17
- import $22a5f0623ea73e4f$exports from "./ko-KR.module.js";
18
- import $522380d13d62cba0$exports from "./lt-LT.module.js";
19
- import $8a7bc830b2fe6485$exports from "./lv-LV.module.js";
20
- import $9fac9c044470683b$exports from "./nb-NO.module.js";
21
- import $b127d3569efb1449$exports from "./nl-NL.module.js";
22
- import $51404a4090633490$exports from "./pl-PL.module.js";
23
- import $e5e6a3fe3b4527df$exports from "./pt-BR.module.js";
24
- import $c519dcadcbb1ee47$exports from "./pt-PT.module.js";
25
- import $e5aa0186ca7889c6$exports from "./ro-RO.module.js";
26
- import $5b907f5fa3eee652$exports from "./ru-RU.module.js";
27
- import $1b4c51359c99cf79$exports from "./sk-SK.module.js";
28
- import $02e4e6a4608cc6f3$exports from "./sl-SI.module.js";
29
- import $6dd2fbaad93b6878$exports from "./sr-SP.module.js";
30
- import $33ea59bfe6e804e0$exports from "./sv-SE.module.js";
31
- import $4603b0d0246969b2$exports from "./tr-TR.module.js";
32
- import $82649816f530bb1b$exports from "./uk-UA.module.js";
33
- import $628e140a43dfb330$exports from "./zh-CN.module.js";
34
- import $745937250cd4679c$exports from "./zh-TW.module.js";
35
- import {announce as $amWdn$announce} from "@react-aria/live-announcer";
36
- import {filterDOMProps as $amWdn$filterDOMProps, useUpdateEffect as $amWdn$useUpdateEffect, useSlotId as $amWdn$useSlotId, useLabels as $amWdn$useLabels, mergeProps as $amWdn$mergeProps, useEvent as $amWdn$useEvent, useDeepMemo as $amWdn$useDeepMemo, useDescription as $amWdn$useDescription, focusWithoutScrolling as $amWdn$focusWithoutScrolling, scrollIntoViewport as $amWdn$scrollIntoViewport, getScrollParent as $amWdn$getScrollParent} from "@react-aria/utils";
37
- import {useLocalizedStringFormatter as $amWdn$useLocalizedStringFormatter, useDateFormatter as $amWdn$useDateFormatter, useLocale as $amWdn$useLocale} from "@react-aria/i18n";
38
- import {useState as $amWdn$useState, useMemo as $amWdn$useMemo, useRef as $amWdn$useRef, useEffect as $amWdn$useEffect} from "react";
39
- import {isSameDay as $amWdn$isSameDay, startOfMonth as $amWdn$startOfMonth, endOfMonth as $amWdn$endOfMonth, startOfWeek as $amWdn$startOfWeek, today as $amWdn$today, isEqualDay as $amWdn$isEqualDay, isToday as $amWdn$isToday} from "@internationalized/date";
40
- import {usePress as $amWdn$usePress, getInteractionModality as $amWdn$getInteractionModality} from "@react-aria/interactions";
41
-
42
-
43
- function $parcel$interopDefault(a) {
44
- return a && a.__esModule ? a.default : a;
45
- }
46
- /*
47
- * Copyright 2020 Adobe. All rights reserved.
48
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
49
- * you may not use this file except in compliance with the License. You may obtain a copy
50
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
51
- *
52
- * Unless required by applicable law or agreed to in writing, software distributed under
53
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
54
- * OF ANY KIND, either express or implied. See the License for the specific language
55
- * governing permissions and limitations under the License.
56
- */ /*
57
- * Copyright 2020 Adobe. All rights reserved.
58
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
59
- * you may not use this file except in compliance with the License. You may obtain a copy
60
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
61
- *
62
- * Unless required by applicable law or agreed to in writing, software distributed under
63
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
64
- * OF ANY KIND, either express or implied. See the License for the specific language
65
- * governing permissions and limitations under the License.
66
- */ /*
67
- * Copyright 2020 Adobe. All rights reserved.
68
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
69
- * you may not use this file except in compliance with the License. You may obtain a copy
70
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
71
- *
72
- * Unless required by applicable law or agreed to in writing, software distributed under
73
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
74
- * OF ANY KIND, either express or implied. See the License for the specific language
75
- * governing permissions and limitations under the License.
76
- */
77
-
78
- /*
79
- * Copyright 2020 Adobe. All rights reserved.
80
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
81
- * you may not use this file except in compliance with the License. You may obtain a copy
82
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
83
- *
84
- * Unless required by applicable law or agreed to in writing, software distributed under
85
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
86
- * OF ANY KIND, either express or implied. See the License for the specific language
87
- * governing permissions and limitations under the License.
88
- */
89
- var $3904726b442bd9b2$exports = {};
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
- $3904726b442bd9b2$exports = {
125
- "ar-AE": $39324ace0d945f59$exports,
126
- "bg-BG": $1830a539e98c7baf$exports,
127
- "cs-CZ": $f4b92528965aab97$exports,
128
- "da-DK": $1cd578ef0547c8f1$exports,
129
- "de-DE": $db55a8973925d619$exports,
130
- "el-GR": $ec6937d58566d443$exports,
131
- "en-US": $1f5cea0742dc284a$exports,
132
- "es-ES": $2ca7ea366384817b$exports,
133
- "et-EE": $97874a7fe9cd091f$exports,
134
- "fi-FI": $5d376b7fce1a45b2$exports,
135
- "fr-FR": $3bf722b362aaf54d$exports,
136
- "he-IL": $38c43f8322316031$exports,
137
- "hr-HR": $c90e0f32b44630bf$exports,
138
- "hu-HU": $715875e6e7a338f4$exports,
139
- "it-IT": $37d77c66e34daccf$exports,
140
- "ja-JP": $542f39aee29303c3$exports,
141
- "ko-KR": $22a5f0623ea73e4f$exports,
142
- "lt-LT": $522380d13d62cba0$exports,
143
- "lv-LV": $8a7bc830b2fe6485$exports,
144
- "nb-NO": $9fac9c044470683b$exports,
145
- "nl-NL": $b127d3569efb1449$exports,
146
- "pl-PL": $51404a4090633490$exports,
147
- "pt-BR": $e5e6a3fe3b4527df$exports,
148
- "pt-PT": $c519dcadcbb1ee47$exports,
149
- "ro-RO": $e5aa0186ca7889c6$exports,
150
- "ru-RU": $5b907f5fa3eee652$exports,
151
- "sk-SK": $1b4c51359c99cf79$exports,
152
- "sl-SI": $02e4e6a4608cc6f3$exports,
153
- "sr-SP": $6dd2fbaad93b6878$exports,
154
- "sv-SE": $33ea59bfe6e804e0$exports,
155
- "tr-TR": $4603b0d0246969b2$exports,
156
- "uk-UA": $82649816f530bb1b$exports,
157
- "zh-CN": $628e140a43dfb330$exports,
158
- "zh-TW": $745937250cd4679c$exports
159
- };
160
-
161
-
162
-
163
-
164
- const $a074e1e2d0f0a665$export$653eddfc964b0f8a = new WeakMap();
165
- function $a074e1e2d0f0a665$export$134cbb7fb09a9522(date) {
166
- return (date === null || date === void 0 ? void 0 : date.calendar.identifier) === "gregory" && date.era === "BC" ? "short" : undefined;
167
- }
168
- function $a074e1e2d0f0a665$export$b6df97c887c38e1a(state) {
169
- let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
170
- let start, end;
171
- if ("highlightedRange" in state) ({ start: start, end: end } = state.highlightedRange || {});
172
- else start = end = state.value;
173
- let dateFormatter = (0, $amWdn$useDateFormatter)({
174
- weekday: "long",
175
- month: "long",
176
- year: "numeric",
177
- day: "numeric",
178
- era: $a074e1e2d0f0a665$export$134cbb7fb09a9522(start) || $a074e1e2d0f0a665$export$134cbb7fb09a9522(end),
179
- timeZone: state.timeZone
180
- });
181
- let anchorDate = "anchorDate" in state ? state.anchorDate : null;
182
- return (0, $amWdn$useMemo)(()=>{
183
- // No message if currently selecting a range, or there is nothing highlighted.
184
- if (!anchorDate && start && end) {
185
- // Use a single date message if the start and end dates are the same day,
186
- // otherwise include both dates.
187
- if ((0, $amWdn$isSameDay)(start, end)) {
188
- let date = dateFormatter.format(start.toDate(state.timeZone));
189
- return stringFormatter.format("selectedDateDescription", {
190
- date: date
191
- });
192
- } else {
193
- let dateRange = $a074e1e2d0f0a665$var$formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);
194
- return stringFormatter.format("selectedRangeDescription", {
195
- dateRange: dateRange
196
- });
197
- }
198
- }
199
- return "";
200
- }, [
201
- start,
202
- end,
203
- anchorDate,
204
- state.timeZone,
205
- stringFormatter,
206
- dateFormatter
207
- ]);
208
- }
209
- function $a074e1e2d0f0a665$export$31afe65d91ef6e8(startDate, endDate, timeZone, isAria) {
210
- let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
211
- let era = $a074e1e2d0f0a665$export$134cbb7fb09a9522(startDate) || $a074e1e2d0f0a665$export$134cbb7fb09a9522(endDate);
212
- let monthFormatter = (0, $amWdn$useDateFormatter)({
213
- month: "long",
214
- year: "numeric",
215
- era: era,
216
- calendar: startDate.calendar.identifier,
217
- timeZone: timeZone
218
- });
219
- let dateFormatter = (0, $amWdn$useDateFormatter)({
220
- month: "long",
221
- year: "numeric",
222
- day: "numeric",
223
- era: era,
224
- calendar: startDate.calendar.identifier,
225
- timeZone: timeZone
226
- });
227
- return (0, $amWdn$useMemo)(()=>{
228
- // Special case for month granularity. Format as a single month if only a
229
- // single month is visible, otherwise format as a range of months.
230
- if ((0, $amWdn$isSameDay)(startDate, (0, $amWdn$startOfMonth)(startDate))) {
231
- if ((0, $amWdn$isSameDay)(endDate, (0, $amWdn$endOfMonth)(startDate))) return monthFormatter.format(startDate.toDate(timeZone));
232
- else if ((0, $amWdn$isSameDay)(endDate, (0, $amWdn$endOfMonth)(endDate))) return isAria ? $a074e1e2d0f0a665$var$formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone) : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
233
- }
234
- return isAria ? $a074e1e2d0f0a665$var$formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone) : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
235
- }, [
236
- startDate,
237
- endDate,
238
- monthFormatter,
239
- dateFormatter,
240
- stringFormatter,
241
- timeZone,
242
- isAria
243
- ]);
244
- }
245
- function $a074e1e2d0f0a665$var$formatRange(dateFormatter, stringFormatter, start, end, timeZone) {
246
- let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));
247
- // Find the separator between the start and end date. This is determined
248
- // by finding the last shared literal before the end range.
249
- let separatorIndex = -1;
250
- for(let i = 0; i < parts.length; i++){
251
- let part = parts[i];
252
- if (part.source === "shared" && part.type === "literal") separatorIndex = i;
253
- else if (part.source === "endRange") break;
254
- }
255
- // Now we can combine the parts into start and end strings.
256
- let startValue = "";
257
- let endValue = "";
258
- for(let i = 0; i < parts.length; i++){
259
- if (i < separatorIndex) startValue += parts[i].value;
260
- else if (i > separatorIndex) endValue += parts[i].value;
261
- }
262
- return stringFormatter.format("dateRange", {
263
- startDate: startValue,
264
- endDate: endValue
265
- });
266
- }
267
-
268
-
269
-
270
-
271
-
272
- function $c4acc1de3ab169cf$export$d652b3ea2d672d5b(props, state) {
273
- let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
274
- let domProps = (0, $amWdn$filterDOMProps)(props);
275
- let title = (0, $a074e1e2d0f0a665$export$31afe65d91ef6e8)(state.visibleRange.start, state.visibleRange.end, state.timeZone, false);
276
- let visibleRangeDescription = (0, $a074e1e2d0f0a665$export$31afe65d91ef6e8)(state.visibleRange.start, state.visibleRange.end, state.timeZone, true);
277
- // Announce when the visible date range changes
278
- (0, $amWdn$useUpdateEffect)(()=>{
279
- // only when pressing the Previous or Next button
280
- if (!state.isFocused) (0, $amWdn$announce)(visibleRangeDescription);
281
- }, [
282
- visibleRangeDescription
283
- ]);
284
- // Announce when the selected value changes
285
- let selectedDateDescription = (0, $a074e1e2d0f0a665$export$b6df97c887c38e1a)(state);
286
- (0, $amWdn$useUpdateEffect)(()=>{
287
- if (selectedDateDescription) (0, $amWdn$announce)(selectedDateDescription, "polite", 4000);
288
- // handle an update to the caption that describes the currently selected range, to announce the new value
289
- }, [
290
- selectedDateDescription
291
- ]);
292
- let errorMessageId = (0, $amWdn$useSlotId)([
293
- Boolean(props.errorMessage),
294
- props.isInvalid,
295
- props.validationState
296
- ]);
297
- // Pass the label to the child grid elements.
298
- (0, $a074e1e2d0f0a665$export$653eddfc964b0f8a).set(state, {
299
- ariaLabel: props["aria-label"],
300
- ariaLabelledBy: props["aria-labelledby"],
301
- errorMessageId: errorMessageId,
302
- selectedDateDescription: selectedDateDescription
303
- });
304
- // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.
305
- let [nextFocused, setNextFocused] = (0, $amWdn$useState)(false);
306
- let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();
307
- if (nextDisabled && nextFocused) {
308
- setNextFocused(false);
309
- state.setFocused(true);
310
- }
311
- let [previousFocused, setPreviousFocused] = (0, $amWdn$useState)(false);
312
- let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();
313
- if (previousDisabled && previousFocused) {
314
- setPreviousFocused(false);
315
- state.setFocused(true);
316
- }
317
- let labelProps = (0, $amWdn$useLabels)({
318
- id: props["id"],
319
- "aria-label": [
320
- props["aria-label"],
321
- visibleRangeDescription
322
- ].filter(Boolean).join(", "),
323
- "aria-labelledby": props["aria-labelledby"]
324
- });
325
- return {
326
- calendarProps: (0, $amWdn$mergeProps)(domProps, labelProps, {
327
- role: "application",
328
- "aria-describedby": props["aria-describedby"] || undefined
329
- }),
330
- nextButtonProps: {
331
- onPress: ()=>state.focusNextPage(),
332
- "aria-label": stringFormatter.format("next"),
333
- isDisabled: nextDisabled,
334
- onFocusChange: setNextFocused
335
- },
336
- prevButtonProps: {
337
- onPress: ()=>state.focusPreviousPage(),
338
- "aria-label": stringFormatter.format("previous"),
339
- isDisabled: previousDisabled,
340
- onFocusChange: setPreviousFocused
341
- },
342
- errorMessageProps: {
343
- id: errorMessageId
344
- },
345
- title: title
346
- };
347
- }
348
-
349
-
350
- function $9942cad8a072a530$export$3ee915f8151bd4f1(props, state) {
351
- return (0, $c4acc1de3ab169cf$export$d652b3ea2d672d5b)(props, state);
352
- }
353
-
1
+ import {useCalendar as $9942cad8a072a530$export$3ee915f8151bd4f1} from "./useCalendar.module.js";
2
+ import {useRangeCalendar as $46a4342aab3d8076$export$87e0539f600c24e5} from "./useRangeCalendar.module.js";
3
+ import {useCalendarGrid as $e3031d1f8c9d64eb$export$cb95147730a423f5} from "./useCalendarGrid.module.js";
4
+ import {useCalendarCell as $36a0ac60f04457c5$export$136073280381448e} from "./useCalendarCell.module.js";
354
5
 
355
6
  /*
356
7
  * Copyright 2020 Adobe. All rights reserved.
@@ -365,431 +16,6 @@ function $9942cad8a072a530$export$3ee915f8151bd4f1(props, state) {
365
16
  */
366
17
 
367
18
 
368
- function $46a4342aab3d8076$export$87e0539f600c24e5(props, state, ref) {
369
- let res = (0, $c4acc1de3ab169cf$export$d652b3ea2d672d5b)(props, state);
370
- // We need to ignore virtual pointer events from VoiceOver due to these bugs.
371
- // https://bugs.webkit.org/show_bug.cgi?id=222627
372
- // https://bugs.webkit.org/show_bug.cgi?id=223202
373
- // usePress also does this and waits for the following click event before firing.
374
- // We need to match that here otherwise this will fire before the press event in
375
- // useCalendarCell, causing range selection to not work properly.
376
- let isVirtualClick = (0, $amWdn$useRef)(false);
377
- let windowRef = (0, $amWdn$useRef)(typeof window !== "undefined" ? window : null);
378
- (0, $amWdn$useEvent)(windowRef, "pointerdown", (e)=>{
379
- isVirtualClick.current = e.width === 0 && e.height === 0;
380
- });
381
- // Stop range selection when pressing or releasing a pointer outside the calendar body,
382
- // except when pressing the next or previous buttons to switch months.
383
- let endDragging = (e)=>{
384
- if (isVirtualClick.current) {
385
- isVirtualClick.current = false;
386
- return;
387
- }
388
- state.setDragging(false);
389
- if (!state.anchorDate) return;
390
- let target = e.target;
391
- let body = document.getElementById(res.calendarProps.id);
392
- if (body && body.contains(document.activeElement) && (!body.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
393
- };
394
- (0, $amWdn$useEvent)(windowRef, "pointerup", endDragging);
395
- (0, $amWdn$useEvent)(windowRef, "pointercancel", endDragging);
396
- // Also stop range selection on blur, e.g. tabbing away from the calendar.
397
- res.calendarProps.onBlur = (e)=>{
398
- if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
399
- };
400
- // Prevent touch scrolling while dragging
401
- (0, $amWdn$useEvent)(ref, "touchmove", (e)=>{
402
- if (state.isDragging) e.preventDefault();
403
- }, {
404
- passive: false,
405
- capture: true
406
- });
407
- return res;
408
- }
409
-
410
-
411
- /*
412
- * Copyright 2020 Adobe. All rights reserved.
413
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
414
- * you may not use this file except in compliance with the License. You may obtain a copy
415
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
416
- *
417
- * Unless required by applicable law or agreed to in writing, software distributed under
418
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
419
- * OF ANY KIND, either express or implied. See the License for the specific language
420
- * governing permissions and limitations under the License.
421
- */
422
-
423
-
424
-
425
-
426
- function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
427
- let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end } = props;
428
- let { direction: direction } = (0, $amWdn$useLocale)();
429
- let onKeyDown = (e)=>{
430
- switch(e.key){
431
- case "Enter":
432
- case " ":
433
- e.preventDefault();
434
- state.selectFocusedDate();
435
- break;
436
- case "PageUp":
437
- e.preventDefault();
438
- e.stopPropagation();
439
- state.focusPreviousSection(e.shiftKey);
440
- break;
441
- case "PageDown":
442
- e.preventDefault();
443
- e.stopPropagation();
444
- state.focusNextSection(e.shiftKey);
445
- break;
446
- case "End":
447
- e.preventDefault();
448
- e.stopPropagation();
449
- state.focusSectionEnd();
450
- break;
451
- case "Home":
452
- e.preventDefault();
453
- e.stopPropagation();
454
- state.focusSectionStart();
455
- break;
456
- case "ArrowLeft":
457
- e.preventDefault();
458
- e.stopPropagation();
459
- if (direction === "rtl") state.focusNextDay();
460
- else state.focusPreviousDay();
461
- break;
462
- case "ArrowUp":
463
- e.preventDefault();
464
- e.stopPropagation();
465
- state.focusPreviousRow();
466
- break;
467
- case "ArrowRight":
468
- e.preventDefault();
469
- e.stopPropagation();
470
- if (direction === "rtl") state.focusPreviousDay();
471
- else state.focusNextDay();
472
- break;
473
- case "ArrowDown":
474
- e.preventDefault();
475
- e.stopPropagation();
476
- state.focusNextRow();
477
- break;
478
- case "Escape":
479
- // Cancel the selection.
480
- if ("setAnchorDate" in state) {
481
- e.preventDefault();
482
- state.setAnchorDate(null);
483
- }
484
- break;
485
- }
486
- };
487
- let visibleRangeDescription = (0, $a074e1e2d0f0a665$export$31afe65d91ef6e8)(startDate, endDate, state.timeZone, true);
488
- let { ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy } = (0, $a074e1e2d0f0a665$export$653eddfc964b0f8a).get(state);
489
- let labelProps = (0, $amWdn$useLabels)({
490
- "aria-label": [
491
- ariaLabel,
492
- visibleRangeDescription
493
- ].filter(Boolean).join(", "),
494
- "aria-labelledby": ariaLabelledBy
495
- });
496
- let dayFormatter = (0, $amWdn$useDateFormatter)({
497
- weekday: props.weekdayStyle || "narrow",
498
- timeZone: state.timeZone
499
- });
500
- let { locale: locale } = (0, $amWdn$useLocale)();
501
- let weekDays = (0, $amWdn$useMemo)(()=>{
502
- let weekStart = (0, $amWdn$startOfWeek)((0, $amWdn$today)(state.timeZone), locale);
503
- return [
504
- ...new Array(7).keys()
505
- ].map((index)=>{
506
- let date = weekStart.add({
507
- days: index
508
- });
509
- let dateDay = date.toDate(state.timeZone);
510
- return dayFormatter.format(dateDay);
511
- });
512
- }, [
513
- locale,
514
- state.timeZone,
515
- dayFormatter
516
- ]);
517
- return {
518
- gridProps: (0, $amWdn$mergeProps)(labelProps, {
519
- role: "grid",
520
- "aria-readonly": state.isReadOnly || null,
521
- "aria-disabled": state.isDisabled || null,
522
- "aria-multiselectable": "highlightedRange" in state || undefined,
523
- onKeyDown: onKeyDown,
524
- onFocus: ()=>state.setFocused(true),
525
- onBlur: ()=>state.setFocused(false)
526
- }),
527
- headerProps: {
528
- // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.
529
- // The day names are already included in the label of each cell, so there's no need to announce them twice.
530
- "aria-hidden": true
531
- },
532
- weekDays: weekDays
533
- };
534
- }
535
-
536
-
537
- /*
538
- * Copyright 2020 Adobe. All rights reserved.
539
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
540
- * you may not use this file except in compliance with the License. You may obtain a copy
541
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
542
- *
543
- * Unless required by applicable law or agreed to in writing, software distributed under
544
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
545
- * OF ANY KIND, either express or implied. See the License for the specific language
546
- * governing permissions and limitations under the License.
547
- */
548
-
549
-
550
-
551
-
552
-
553
-
554
- function $36a0ac60f04457c5$export$136073280381448e(props, state, ref) {
555
- let { date: date, isDisabled: isDisabled } = props;
556
- let { errorMessageId: errorMessageId, selectedDateDescription: selectedDateDescription } = (0, $a074e1e2d0f0a665$export$653eddfc964b0f8a).get(state);
557
- let stringFormatter = (0, $amWdn$useLocalizedStringFormatter)((0, (/*@__PURE__*/$parcel$interopDefault($3904726b442bd9b2$exports))), "@react-aria/calendar");
558
- let dateFormatter = (0, $amWdn$useDateFormatter)({
559
- weekday: "long",
560
- day: "numeric",
561
- month: "long",
562
- year: "numeric",
563
- era: (0, $a074e1e2d0f0a665$export$134cbb7fb09a9522)(date),
564
- timeZone: state.timeZone
565
- });
566
- let isSelected = state.isSelected(date);
567
- let isFocused = state.isCellFocused(date);
568
- isDisabled = isDisabled || state.isCellDisabled(date);
569
- let isUnavailable = state.isCellUnavailable(date);
570
- let isSelectable = !isDisabled && !isUnavailable;
571
- let isInvalid = state.isValueInvalid && ("highlightedRange" in state ? !state.anchorDate && state.highlightedRange && date.compare(state.highlightedRange.start) >= 0 && date.compare(state.highlightedRange.end) <= 0 : state.value && (0, $amWdn$isSameDay)(state.value, date));
572
- if (isInvalid) isSelected = true;
573
- // For performance, reuse the same date object as before if the new date prop is the same.
574
- // This allows subsequent useMemo results to be reused.
575
- date = (0, $amWdn$useDeepMemo)(date, (0, $amWdn$isEqualDay));
576
- let nativeDate = (0, $amWdn$useMemo)(()=>date.toDate(state.timeZone), [
577
- date,
578
- state.timeZone
579
- ]);
580
- // aria-label should be localize Day of week, Month, Day and Year without Time.
581
- let isDateToday = (0, $amWdn$isToday)(date, state.timeZone);
582
- let label = (0, $amWdn$useMemo)(()=>{
583
- let label = "";
584
- // If this is a range calendar, add a description of the full selected range
585
- // to the first and last selected date.
586
- if ("highlightedRange" in state && state.value && !state.anchorDate && ((0, $amWdn$isSameDay)(date, state.value.start) || (0, $amWdn$isSameDay)(date, state.value.end))) label = selectedDateDescription + ", ";
587
- label += dateFormatter.format(nativeDate);
588
- if (isDateToday) // If date is today, set appropriate string depending on selected state:
589
- label = stringFormatter.format(isSelected ? "todayDateSelected" : "todayDate", {
590
- date: label
591
- });
592
- else if (isSelected) // If date is selected but not today:
593
- label = stringFormatter.format("dateSelected", {
594
- date: label
595
- });
596
- if (state.minValue && (0, $amWdn$isSameDay)(date, state.minValue)) label += ", " + stringFormatter.format("minimumDate");
597
- else if (state.maxValue && (0, $amWdn$isSameDay)(date, state.maxValue)) label += ", " + stringFormatter.format("maximumDate");
598
- return label;
599
- }, [
600
- dateFormatter,
601
- nativeDate,
602
- stringFormatter,
603
- isSelected,
604
- isDateToday,
605
- date,
606
- state,
607
- selectedDateDescription
608
- ]);
609
- // When a cell is focused and this is a range calendar, add a prompt to help
610
- // screenreader users know that they are in a range selection mode.
611
- let rangeSelectionPrompt = "";
612
- if ("anchorDate" in state && isFocused && !state.isReadOnly && isSelectable) {
613
- // If selection has started add "click to finish selecting range"
614
- if (state.anchorDate) rangeSelectionPrompt = stringFormatter.format("finishRangeSelectionPrompt");
615
- else rangeSelectionPrompt = stringFormatter.format("startRangeSelectionPrompt");
616
- }
617
- let descriptionProps = (0, $amWdn$useDescription)(rangeSelectionPrompt);
618
- let isAnchorPressed = (0, $amWdn$useRef)(false);
619
- let isRangeBoundaryPressed = (0, $amWdn$useRef)(false);
620
- let touchDragTimerRef = (0, $amWdn$useRef)(null);
621
- let { pressProps: pressProps, isPressed: isPressed } = (0, $amWdn$usePress)({
622
- // When dragging to select a range, we don't want dragging over the original anchor
623
- // again to trigger onPressStart. Cancel presses immediately when the pointer exits.
624
- shouldCancelOnPointerExit: "anchorDate" in state && !!state.anchorDate,
625
- preventFocusOnPress: true,
626
- isDisabled: !isSelectable || state.isReadOnly,
627
- onPressStart (e) {
628
- if (state.isReadOnly) {
629
- state.setFocusedDate(date);
630
- return;
631
- }
632
- if ("highlightedRange" in state && !state.anchorDate && (e.pointerType === "mouse" || e.pointerType === "touch")) {
633
- // Allow dragging the start or end date of a range to modify it
634
- // rather than starting a new selection.
635
- // Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges
636
- // are constrained to available dates. The user will need to select a new range in this case.
637
- if (state.highlightedRange && !isInvalid) {
638
- if ((0, $amWdn$isSameDay)(date, state.highlightedRange.start)) {
639
- state.setAnchorDate(state.highlightedRange.end);
640
- state.setFocusedDate(date);
641
- state.setDragging(true);
642
- isRangeBoundaryPressed.current = true;
643
- return;
644
- } else if ((0, $amWdn$isSameDay)(date, state.highlightedRange.end)) {
645
- state.setAnchorDate(state.highlightedRange.start);
646
- state.setFocusedDate(date);
647
- state.setDragging(true);
648
- isRangeBoundaryPressed.current = true;
649
- return;
650
- }
651
- }
652
- let startDragging = ()=>{
653
- state.setDragging(true);
654
- touchDragTimerRef.current = null;
655
- state.selectDate(date);
656
- state.setFocusedDate(date);
657
- isAnchorPressed.current = true;
658
- };
659
- // Start selection on mouse/touch down so users can drag to select a range.
660
- // On touch, delay dragging to determine if the user really meant to scroll.
661
- if (e.pointerType === "touch") touchDragTimerRef.current = setTimeout(startDragging, 200);
662
- else startDragging();
663
- }
664
- },
665
- onPressEnd () {
666
- isRangeBoundaryPressed.current = false;
667
- isAnchorPressed.current = false;
668
- clearTimeout(touchDragTimerRef.current);
669
- touchDragTimerRef.current = null;
670
- },
671
- onPress () {
672
- // For non-range selection, always select on press up.
673
- if (!("anchorDate" in state) && !state.isReadOnly) {
674
- state.selectDate(date);
675
- state.setFocusedDate(date);
676
- }
677
- },
678
- onPressUp (e) {
679
- if (state.isReadOnly) return;
680
- // If the user tapped quickly, the date won't be selected yet and the
681
- // timer will still be in progress. In this case, select the date on touch up.
682
- // Timer is cleared in onPressEnd.
683
- if ("anchorDate" in state && touchDragTimerRef.current) {
684
- state.selectDate(date);
685
- state.setFocusedDate(date);
686
- }
687
- if ("anchorDate" in state) {
688
- if (isRangeBoundaryPressed.current) // When clicking on the start or end date of an already selected range,
689
- // start a new selection on press up to also allow dragging the date to
690
- // change the existing range.
691
- state.setAnchorDate(date);
692
- else if (state.anchorDate && !isAnchorPressed.current) {
693
- // When releasing a drag or pressing the end date of a range, select it.
694
- state.selectDate(date);
695
- state.setFocusedDate(date);
696
- } else if (e.pointerType === "keyboard" && !state.anchorDate) {
697
- // For range selection, auto-advance the focused date by one if using keyboard.
698
- // This gives an indication that you're selecting a range rather than a single date.
699
- // For mouse, this is unnecessary because users will see the indication on hover. For screen readers,
700
- // there will be an announcement to "click to finish selecting range" (above).
701
- state.selectDate(date);
702
- let nextDay = date.add({
703
- days: 1
704
- });
705
- if (state.isInvalid(nextDay)) nextDay = date.subtract({
706
- days: 1
707
- });
708
- if (!state.isInvalid(nextDay)) state.setFocusedDate(nextDay);
709
- } else if (e.pointerType === "virtual") {
710
- // For screen readers, just select the date on click.
711
- state.selectDate(date);
712
- state.setFocusedDate(date);
713
- }
714
- }
715
- }
716
- });
717
- let tabIndex = null;
718
- if (!isDisabled) tabIndex = (0, $amWdn$isSameDay)(date, state.focusedDate) ? 0 : -1;
719
- // Focus the button in the DOM when the state updates.
720
- (0, $amWdn$useEffect)(()=>{
721
- if (isFocused && ref.current) {
722
- (0, $amWdn$focusWithoutScrolling)(ref.current);
723
- // Scroll into view if navigating with a keyboard, otherwise
724
- // try not to shift the view under the user's mouse/finger.
725
- // If in a overlay, scrollIntoViewport will only cause scrolling
726
- // up to the overlay scroll body to prevent overlay shifting.
727
- // Also only scroll into view if the cell actually got focused.
728
- // There are some cases where the cell might be disabled or inside,
729
- // an inert container and we don't want to scroll then.
730
- if ((0, $amWdn$getInteractionModality)() !== "pointer" && document.activeElement === ref.current) (0, $amWdn$scrollIntoViewport)(ref.current, {
731
- containingElement: (0, $amWdn$getScrollParent)(ref.current)
732
- });
733
- }
734
- }, [
735
- isFocused,
736
- ref
737
- ]);
738
- let cellDateFormatter = (0, $amWdn$useDateFormatter)({
739
- day: "numeric",
740
- timeZone: state.timeZone,
741
- calendar: date.calendar.identifier
742
- });
743
- let formattedDate = (0, $amWdn$useMemo)(()=>cellDateFormatter.formatToParts(nativeDate).find((part)=>part.type === "day").value, [
744
- cellDateFormatter,
745
- nativeDate
746
- ]);
747
- return {
748
- cellProps: {
749
- role: "gridcell",
750
- "aria-disabled": !isSelectable || null,
751
- "aria-selected": isSelected || null,
752
- "aria-invalid": isInvalid || null
753
- },
754
- buttonProps: (0, $amWdn$mergeProps)(pressProps, {
755
- onFocus () {
756
- if (!isDisabled) state.setFocusedDate(date);
757
- },
758
- tabIndex: tabIndex,
759
- role: "button",
760
- "aria-disabled": !isSelectable || null,
761
- "aria-label": label,
762
- "aria-invalid": isInvalid || null,
763
- "aria-describedby": [
764
- isInvalid ? errorMessageId : null,
765
- descriptionProps["aria-describedby"]
766
- ].filter(Boolean).join(" ") || undefined,
767
- onPointerEnter (e) {
768
- // Highlight the date on hover or drag over a date when selecting a range.
769
- if ("highlightDate" in state && (e.pointerType !== "touch" || state.isDragging) && isSelectable) state.highlightDate(date);
770
- },
771
- onPointerDown (e) {
772
- // This is necessary on touch devices to allow dragging
773
- // outside the original pressed element.
774
- // (JSDOM does not support this)
775
- if ("releasePointerCapture" in e.target) e.target.releasePointerCapture(e.pointerId);
776
- },
777
- onContextMenu (e) {
778
- // Prevent context menu on long press.
779
- e.preventDefault();
780
- }
781
- }),
782
- isPressed: isPressed,
783
- isFocused: isFocused,
784
- isSelected: isSelected,
785
- isDisabled: isDisabled,
786
- isUnavailable: isUnavailable,
787
- isOutsideVisibleRange: date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,
788
- isInvalid: isInvalid,
789
- formattedDate: formattedDate
790
- };
791
- }
792
-
793
19
 
794
20
 
795
21