@react-aria/calendar 3.5.6 → 3.5.8

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 (43) hide show
  1. package/dist/import.mjs +4 -778
  2. package/dist/intlStrings.main.js +108 -0
  3. package/dist/intlStrings.main.js.map +1 -0
  4. package/dist/intlStrings.mjs +110 -0
  5. package/dist/intlStrings.module.js +110 -0
  6. package/dist/intlStrings.module.js.map +1 -0
  7. package/dist/main.js +8 -782
  8. package/dist/main.js.map +1 -1
  9. package/dist/module.js +4 -778
  10. package/dist/module.js.map +1 -1
  11. package/dist/types.d.ts.map +1 -1
  12. package/dist/useCalendar.main.js +25 -0
  13. package/dist/useCalendar.main.js.map +1 -0
  14. package/dist/useCalendar.mjs +20 -0
  15. package/dist/useCalendar.module.js +20 -0
  16. package/dist/useCalendar.module.js.map +1 -0
  17. package/dist/useCalendarBase.main.js +112 -0
  18. package/dist/useCalendarBase.main.js.map +1 -0
  19. package/dist/useCalendarBase.mjs +107 -0
  20. package/dist/useCalendarBase.module.js +107 -0
  21. package/dist/useCalendarBase.module.js.map +1 -0
  22. package/dist/useCalendarCell.main.js +276 -0
  23. package/dist/useCalendarCell.main.js.map +1 -0
  24. package/dist/useCalendarCell.mjs +271 -0
  25. package/dist/useCalendarCell.module.js +271 -0
  26. package/dist/useCalendarCell.module.js.map +1 -0
  27. package/dist/useCalendarGrid.main.js +139 -0
  28. package/dist/useCalendarGrid.main.js.map +1 -0
  29. package/dist/useCalendarGrid.mjs +134 -0
  30. package/dist/useCalendarGrid.module.js +134 -0
  31. package/dist/useCalendarGrid.module.js.map +1 -0
  32. package/dist/useRangeCalendar.main.js +66 -0
  33. package/dist/useRangeCalendar.main.js.map +1 -0
  34. package/dist/useRangeCalendar.mjs +61 -0
  35. package/dist/useRangeCalendar.module.js +61 -0
  36. package/dist/useRangeCalendar.module.js.map +1 -0
  37. package/dist/utils.main.js +138 -0
  38. package/dist/utils.main.js.map +1 -0
  39. package/dist/utils.mjs +130 -0
  40. package/dist/utils.module.js +130 -0
  41. package/dist/utils.module.js.map +1 -0
  42. package/package.json +11 -11
  43. package/src/useRangeCalendar.ts +6 -5
@@ -0,0 +1,134 @@
1
+ import {hookData as $a074e1e2d0f0a665$export$653eddfc964b0f8a, useVisibleRangeDescription as $a074e1e2d0f0a665$export$31afe65d91ef6e8} from "./utils.module.js";
2
+ import {startOfWeek as $NQfxu$startOfWeek, today as $NQfxu$today} from "@internationalized/date";
3
+ import {useMemo as $NQfxu$useMemo} from "react";
4
+ import {useLabels as $NQfxu$useLabels, mergeProps as $NQfxu$mergeProps} from "@react-aria/utils";
5
+ import {useLocale as $NQfxu$useLocale, useDateFormatter as $NQfxu$useDateFormatter} from "@react-aria/i18n";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $e3031d1f8c9d64eb$export$cb95147730a423f5(props, state) {
23
+ let { startDate: startDate = state.visibleRange.start, endDate: endDate = state.visibleRange.end } = props;
24
+ let { direction: direction } = (0, $NQfxu$useLocale)();
25
+ let onKeyDown = (e)=>{
26
+ switch(e.key){
27
+ case 'Enter':
28
+ case ' ':
29
+ e.preventDefault();
30
+ state.selectFocusedDate();
31
+ break;
32
+ case 'PageUp':
33
+ e.preventDefault();
34
+ e.stopPropagation();
35
+ state.focusPreviousSection(e.shiftKey);
36
+ break;
37
+ case 'PageDown':
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ state.focusNextSection(e.shiftKey);
41
+ break;
42
+ case 'End':
43
+ e.preventDefault();
44
+ e.stopPropagation();
45
+ state.focusSectionEnd();
46
+ break;
47
+ case 'Home':
48
+ e.preventDefault();
49
+ e.stopPropagation();
50
+ state.focusSectionStart();
51
+ break;
52
+ case 'ArrowLeft':
53
+ e.preventDefault();
54
+ e.stopPropagation();
55
+ if (direction === 'rtl') state.focusNextDay();
56
+ else state.focusPreviousDay();
57
+ break;
58
+ case 'ArrowUp':
59
+ e.preventDefault();
60
+ e.stopPropagation();
61
+ state.focusPreviousRow();
62
+ break;
63
+ case 'ArrowRight':
64
+ e.preventDefault();
65
+ e.stopPropagation();
66
+ if (direction === 'rtl') state.focusPreviousDay();
67
+ else state.focusNextDay();
68
+ break;
69
+ case 'ArrowDown':
70
+ e.preventDefault();
71
+ e.stopPropagation();
72
+ state.focusNextRow();
73
+ break;
74
+ case 'Escape':
75
+ // Cancel the selection.
76
+ if ('setAnchorDate' in state) {
77
+ e.preventDefault();
78
+ state.setAnchorDate(null);
79
+ }
80
+ break;
81
+ }
82
+ };
83
+ let visibleRangeDescription = (0, $a074e1e2d0f0a665$export$31afe65d91ef6e8)(startDate, endDate, state.timeZone, true);
84
+ let { ariaLabel: ariaLabel, ariaLabelledBy: ariaLabelledBy } = (0, $a074e1e2d0f0a665$export$653eddfc964b0f8a).get(state);
85
+ let labelProps = (0, $NQfxu$useLabels)({
86
+ 'aria-label': [
87
+ ariaLabel,
88
+ visibleRangeDescription
89
+ ].filter(Boolean).join(', '),
90
+ 'aria-labelledby': ariaLabelledBy
91
+ });
92
+ let dayFormatter = (0, $NQfxu$useDateFormatter)({
93
+ weekday: props.weekdayStyle || 'narrow',
94
+ timeZone: state.timeZone
95
+ });
96
+ let { locale: locale } = (0, $NQfxu$useLocale)();
97
+ let weekDays = (0, $NQfxu$useMemo)(()=>{
98
+ let weekStart = (0, $NQfxu$startOfWeek)((0, $NQfxu$today)(state.timeZone), locale);
99
+ return [
100
+ ...new Array(7).keys()
101
+ ].map((index)=>{
102
+ let date = weekStart.add({
103
+ days: index
104
+ });
105
+ let dateDay = date.toDate(state.timeZone);
106
+ return dayFormatter.format(dateDay);
107
+ });
108
+ }, [
109
+ locale,
110
+ state.timeZone,
111
+ dayFormatter
112
+ ]);
113
+ return {
114
+ gridProps: (0, $NQfxu$mergeProps)(labelProps, {
115
+ role: 'grid',
116
+ 'aria-readonly': state.isReadOnly || null,
117
+ 'aria-disabled': state.isDisabled || null,
118
+ 'aria-multiselectable': 'highlightedRange' in state || undefined,
119
+ onKeyDown: onKeyDown,
120
+ onFocus: ()=>state.setFocused(true),
121
+ onBlur: ()=>state.setFocused(false)
122
+ }),
123
+ headerProps: {
124
+ // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.
125
+ // The day names are already included in the label of each cell, so there's no need to announce them twice.
126
+ 'aria-hidden': true
127
+ },
128
+ weekDays: weekDays
129
+ };
130
+ }
131
+
132
+
133
+ export {$e3031d1f8c9d64eb$export$cb95147730a423f5 as useCalendarGrid};
134
+ //# sourceMappingURL=useCalendarGrid.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6CM,SAAS,0CAAgB,KAA4B,EAAE,KAAyC;IACrG,IAAI,aACF,YAAY,MAAM,YAAY,CAAC,KAAK,WACpC,UAAU,MAAM,YAAY,CAAC,GAAG,EACjC,GAAG;IAEJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAE1B,IAAI,YAAY,CAAC;QACf,OAAQ,EAAE,GAAG;YACX,KAAK;YACL,KAAK;gBACH,EAAE,cAAc;gBAChB,MAAM,iBAAiB;gBACvB;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,oBAAoB,CAAC,EAAE,QAAQ;gBACrC;YACF,KAAK;gBACH,EAAE,cAAc;gBAChB,EAAE,eAAe;gBACjB,MAAM,gBAAgB,CAAC,EAAE,QAAQ;gBACjC;YACF,KAAK;gBACH,EAAE,c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O;eAAI,IAAI,MAAM,GAAG,IAAI;SAAG,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,OAAO,UAAU,GAAG,CAAC;gBAAC,MAAM;YAAK;YACrC,IAAI,UAAU,KAAK,MAAM,CAAC,MAAM,QAAQ;YACxC,OAAO,aAAa,MAAM,CAAC;QAC7B;IACF,GAAG;QAAC;QAAQ,MAAM,QAAQ;QAAE;KAAa;IAEzC,OAAO;QACL,WAAW,CAAA,GAAA,iBAAS,EAAE,YAAY;YAChC,MAAM;YACN,iBAAiB,MAAM,UAAU,IAAI;YACrC,iBAAiB,MAAM,UAAU,IAAI;YACrC,wBAAwB,AAAC,sBAAsB,SAAU;uBACzD;YACA,SAAS,IAAM,MAAM,UAAU,CAAC;YAChC,QAAQ,IAAM,MAAM,UAAU,CAAC;QACjC;QACA,aAAa;YACX,oGAAoG;YACpG,2GAA2G;YAC3G,eAAe;QACjB;kBACA;IACF;AACF","sources":["packages/@react-aria/calendar/src/useCalendarGrid.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 {CalendarDate, startOfWeek, today} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\nimport {DOMAttributes} from '@react-types/shared';\nimport {hookData, useVisibleRangeDescription} from './utils';\nimport {KeyboardEvent, useMemo} from 'react';\nimport {mergeProps, useLabels} from '@react-aria/utils';\nimport {useDateFormatter, useLocale} from '@react-aria/i18n';\n\nexport interface AriaCalendarGridProps {\n /**\n * The first date displayed in the calendar grid.\n * Defaults to the first visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n startDate?: CalendarDate,\n /**\n * The last date displayed in the calendar grid.\n * Defaults to the last visible date in the calendar.\n * Override this to display multiple date grids in a calendar.\n */\n endDate?: CalendarDate,\n /**\n * The style of weekday names to display in the calendar grid header,\n * e.g. single letter, abbreviation, or full day name.\n * @default \"narrow\"\n */\n weekdayStyle?: 'narrow' | 'short' | 'long'\n}\n\nexport interface CalendarGridAria {\n /** Props for the date grid element (e.g. `<table>`). */\n gridProps: DOMAttributes,\n /** Props for the grid header element (e.g. `<thead>`). */\n headerProps: DOMAttributes,\n /** A list of week day abbreviations formatted for the current locale, typically used in column headers. */\n weekDays: string[]\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar grid component.\n * A calendar grid displays a single grid of days within a calendar or range calendar which\n * can be keyboard navigated and selected by the user.\n */\nexport function useCalendarGrid(props: AriaCalendarGridProps, state: CalendarState | RangeCalendarState): CalendarGridAria {\n let {\n startDate = state.visibleRange.start,\n endDate = state.visibleRange.end\n } = props;\n\n let {direction} = useLocale();\n\n let onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'Enter':\n case ' ':\n e.preventDefault();\n state.selectFocusedDate();\n break;\n case 'PageUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousSection(e.shiftKey);\n break;\n case 'PageDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextSection(e.shiftKey);\n break;\n case 'End':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionEnd();\n break;\n case 'Home':\n e.preventDefault();\n e.stopPropagation();\n state.focusSectionStart();\n break;\n case 'ArrowLeft':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusNextDay();\n } else {\n state.focusPreviousDay();\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n e.stopPropagation();\n state.focusPreviousRow();\n break;\n case 'ArrowRight':\n e.preventDefault();\n e.stopPropagation();\n if (direction === 'rtl') {\n state.focusPreviousDay();\n } else {\n state.focusNextDay();\n }\n break;\n case 'ArrowDown':\n e.preventDefault();\n e.stopPropagation();\n state.focusNextRow();\n break;\n case 'Escape':\n // Cancel the selection.\n if ('setAnchorDate' in state) {\n e.preventDefault();\n state.setAnchorDate(null);\n }\n break;\n }\n };\n\n let visibleRangeDescription = useVisibleRangeDescription(startDate, endDate, state.timeZone, true);\n\n let {ariaLabel, ariaLabelledBy} = hookData.get(state);\n let labelProps = useLabels({\n 'aria-label': [ariaLabel, visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': ariaLabelledBy\n });\n\n let dayFormatter = useDateFormatter({weekday: props.weekdayStyle || 'narrow', timeZone: state.timeZone});\n let {locale} = useLocale();\n let weekDays = useMemo(() => {\n let weekStart = startOfWeek(today(state.timeZone), locale);\n return [...new Array(7).keys()].map((index) => {\n let date = weekStart.add({days: index});\n let dateDay = date.toDate(state.timeZone);\n return dayFormatter.format(dateDay);\n });\n }, [locale, state.timeZone, dayFormatter]);\n\n return {\n gridProps: mergeProps(labelProps, {\n role: 'grid',\n 'aria-readonly': state.isReadOnly || null,\n 'aria-disabled': state.isDisabled || null,\n 'aria-multiselectable': ('highlightedRange' in state) || undefined,\n onKeyDown,\n onFocus: () => state.setFocused(true),\n onBlur: () => state.setFocused(false)\n }),\n headerProps: {\n // Column headers are hidden to screen readers to make navigating with a touch screen reader easier.\n // The day names are already included in the label of each cell, so there's no need to announce them twice.\n 'aria-hidden': true\n },\n weekDays\n };\n}\n"],"names":[],"version":3,"file":"useCalendarGrid.module.js.map"}
@@ -0,0 +1,66 @@
1
+ var $02ef492a56b91cb2$exports = require("./useCalendarBase.main.js");
2
+ var $3kfPe$react = require("react");
3
+ var $3kfPe$reactariautils = require("@react-aria/utils");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useRangeCalendar", () => $c49ada48cbc48220$export$87e0539f600c24e5);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $c49ada48cbc48220$export$87e0539f600c24e5(props, state, ref) {
25
+ let res = (0, $02ef492a56b91cb2$exports.useCalendarBase)(props, state);
26
+ // We need to ignore virtual pointer events from VoiceOver due to these bugs.
27
+ // https://bugs.webkit.org/show_bug.cgi?id=222627
28
+ // https://bugs.webkit.org/show_bug.cgi?id=223202
29
+ // usePress also does this and waits for the following click event before firing.
30
+ // We need to match that here otherwise this will fire before the press event in
31
+ // useCalendarCell, causing range selection to not work properly.
32
+ let isVirtualClick = (0, $3kfPe$react.useRef)(false);
33
+ let windowRef = (0, $3kfPe$react.useRef)(typeof window !== 'undefined' ? window : null);
34
+ (0, $3kfPe$reactariautils.useEvent)(windowRef, 'pointerdown', (e)=>{
35
+ isVirtualClick.current = e.width === 0 && e.height === 0;
36
+ });
37
+ // Stop range selection when pressing or releasing a pointer outside the calendar body,
38
+ // except when pressing the next or previous buttons to switch months.
39
+ let endDragging = (e)=>{
40
+ if (isVirtualClick.current) {
41
+ isVirtualClick.current = false;
42
+ return;
43
+ }
44
+ state.setDragging(false);
45
+ if (!state.anchorDate) return;
46
+ let target = e.target;
47
+ if (ref.current && ref.current.contains(document.activeElement) && (!ref.current.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
48
+ };
49
+ (0, $3kfPe$reactariautils.useEvent)(windowRef, 'pointerup', endDragging);
50
+ // Also stop range selection on blur, e.g. tabbing away from the calendar.
51
+ res.calendarProps.onBlur = (e)=>{
52
+ if (!ref.current) return;
53
+ if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
54
+ };
55
+ // Prevent touch scrolling while dragging
56
+ (0, $3kfPe$reactariautils.useEvent)(ref, 'touchmove', (e)=>{
57
+ if (state.isDragging) e.preventDefault();
58
+ }, {
59
+ passive: false,
60
+ capture: true
61
+ });
62
+ return res;
63
+ }
64
+
65
+
66
+ //# sourceMappingURL=useRangeCalendar.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAaM,SAAS,0CAAsC,KAAgC,EAAE,KAAyB,EAAE,GAAgC;IACjJ,IAAI,MAAM,CAAA,GAAA,yCAAc,EAAE,OAAO;IAEjC,6EAA6E;IAC7E,iDAAiD;IACjD,iDAAiD;IACjD,iFAAiF;IACjF,gFAAgF;IAChF,iEAAiE;IACjE,IAAI,iBAAiB,CAAA,GAAA,mBAAK,EAAE;IAC5B,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE,OAAO,WAAW,cAAc,SAAS;IAChE,CAAA,GAAA,8BAAO,EAAE,WAAW,eAAe,CAAA;QACjC,eAAe,OAAO,GAAG,EAAE,KAAK,KAAK,KAAK,EAAE,MAAM,KAAK;IACzD;IAEA,uFAAuF;IACvF,sEAAsE;IACtE,IAAI,cAAc,CAAC;QACjB,IAAI,eAAe,OAAO,EAAE;YAC1B,eAAe,OAAO,GAAG;YACzB;QACF;QAEA,MAAM,WAAW,CAAC;QAClB,IAAI,CAAC,MAAM,UAAU,EACnB;QAGF,IAAI,SAAS,EAAE,MAAM;QACrB,IACE,IAAI,OAAO,IACX,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,KAC1C,CAAA,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,0BAAyB,GAE3E,MAAM,iBAAiB;IAE3B;IAEA,CAAA,GAAA,8BAAO,EAAE,WAAW,aAAa;IAEjC,0EAA0E;IAC1E,IAAI,aAAa,CAAC,MAAM,GAAG,CAAA;QACzB,IAAI,CAAC,IAAI,OAAO,EACd;QAEF,IAAI,AAAC,CAAA,CAAC,EAAE,aAAa,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAA,KAAM,MAAM,UAAU,EAClF,MAAM,iBAAiB;IAE3B;IAEA,yCAAyC;IACzC,CAAA,GAAA,8BAAO,EAAE,KAAK,aAAa,CAAA;QACzB,IAAI,MAAM,UAAU,EAClB,EAAE,cAAc;IAEpB,GAAG;QAAC,SAAS;QAAO,SAAS;IAAI;IAEjC,OAAO;AACT","sources":["packages/@react-aria/calendar/src/useRangeCalendar.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 {AriaRangeCalendarProps, DateValue} from '@react-types/calendar';\nimport {CalendarAria, useCalendarBase} from './useCalendarBase';\nimport {FocusableElement} from '@react-types/shared';\nimport {RangeCalendarState} from '@react-stately/calendar';\nimport {RefObject, useRef} from 'react';\nimport {useEvent} from '@react-aria/utils';\n\n/**\n * Provides the behavior and accessibility implementation for a range calendar component.\n * A range calendar displays one or more date grids and allows users to select a contiguous range of dates.\n */\nexport function useRangeCalendar<T extends DateValue>(props: AriaRangeCalendarProps<T>, state: RangeCalendarState, ref: RefObject<FocusableElement>): CalendarAria {\n let res = useCalendarBase(props, state);\n\n // We need to ignore virtual pointer events from VoiceOver due to these bugs.\n // https://bugs.webkit.org/show_bug.cgi?id=222627\n // https://bugs.webkit.org/show_bug.cgi?id=223202\n // usePress also does this and waits for the following click event before firing.\n // We need to match that here otherwise this will fire before the press event in\n // useCalendarCell, causing range selection to not work properly.\n let isVirtualClick = useRef(false);\n let windowRef = useRef(typeof window !== 'undefined' ? window : null);\n useEvent(windowRef, 'pointerdown', e => {\n isVirtualClick.current = e.width === 0 && e.height === 0;\n });\n\n // Stop range selection when pressing or releasing a pointer outside the calendar body,\n // except when pressing the next or previous buttons to switch months.\n let endDragging = (e: PointerEvent) => {\n if (isVirtualClick.current) {\n isVirtualClick.current = false;\n return;\n }\n\n state.setDragging(false);\n if (!state.anchorDate) {\n return;\n }\n\n let target = e.target as Element;\n if (\n ref.current &&\n ref.current.contains(document.activeElement) &&\n (!ref.current.contains(target) || !target.closest('button, [role=\"button\"]'))\n ) {\n state.selectFocusedDate();\n }\n };\n\n useEvent(windowRef, 'pointerup', endDragging);\n\n // Also stop range selection on blur, e.g. tabbing away from the calendar.\n res.calendarProps.onBlur = e => {\n if (!ref.current) {\n return;\n }\n if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) {\n state.selectFocusedDate();\n }\n };\n\n // Prevent touch scrolling while dragging\n useEvent(ref, 'touchmove', e => {\n if (state.isDragging) {\n e.preventDefault();\n }\n }, {passive: false, capture: true});\n\n return res;\n}\n"],"names":[],"version":3,"file":"useRangeCalendar.main.js.map"}
@@ -0,0 +1,61 @@
1
+ import {useCalendarBase as $c4acc1de3ab169cf$export$d652b3ea2d672d5b} from "./useCalendarBase.mjs";
2
+ import {useRef as $juhpn$useRef} from "react";
3
+ import {useEvent as $juhpn$useEvent} from "@react-aria/utils";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $46a4342aab3d8076$export$87e0539f600c24e5(props, state, ref) {
19
+ let res = (0, $c4acc1de3ab169cf$export$d652b3ea2d672d5b)(props, state);
20
+ // We need to ignore virtual pointer events from VoiceOver due to these bugs.
21
+ // https://bugs.webkit.org/show_bug.cgi?id=222627
22
+ // https://bugs.webkit.org/show_bug.cgi?id=223202
23
+ // usePress also does this and waits for the following click event before firing.
24
+ // We need to match that here otherwise this will fire before the press event in
25
+ // useCalendarCell, causing range selection to not work properly.
26
+ let isVirtualClick = (0, $juhpn$useRef)(false);
27
+ let windowRef = (0, $juhpn$useRef)(typeof window !== 'undefined' ? window : null);
28
+ (0, $juhpn$useEvent)(windowRef, 'pointerdown', (e)=>{
29
+ isVirtualClick.current = e.width === 0 && e.height === 0;
30
+ });
31
+ // Stop range selection when pressing or releasing a pointer outside the calendar body,
32
+ // except when pressing the next or previous buttons to switch months.
33
+ let endDragging = (e)=>{
34
+ if (isVirtualClick.current) {
35
+ isVirtualClick.current = false;
36
+ return;
37
+ }
38
+ state.setDragging(false);
39
+ if (!state.anchorDate) return;
40
+ let target = e.target;
41
+ if (ref.current && ref.current.contains(document.activeElement) && (!ref.current.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
42
+ };
43
+ (0, $juhpn$useEvent)(windowRef, 'pointerup', endDragging);
44
+ // Also stop range selection on blur, e.g. tabbing away from the calendar.
45
+ res.calendarProps.onBlur = (e)=>{
46
+ if (!ref.current) return;
47
+ if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
48
+ };
49
+ // Prevent touch scrolling while dragging
50
+ (0, $juhpn$useEvent)(ref, 'touchmove', (e)=>{
51
+ if (state.isDragging) e.preventDefault();
52
+ }, {
53
+ passive: false,
54
+ capture: true
55
+ });
56
+ return res;
57
+ }
58
+
59
+
60
+ export {$46a4342aab3d8076$export$87e0539f600c24e5 as useRangeCalendar};
61
+ //# sourceMappingURL=useRangeCalendar.module.js.map
@@ -0,0 +1,61 @@
1
+ import {useCalendarBase as $c4acc1de3ab169cf$export$d652b3ea2d672d5b} from "./useCalendarBase.module.js";
2
+ import {useRef as $juhpn$useRef} from "react";
3
+ import {useEvent as $juhpn$useEvent} from "@react-aria/utils";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $46a4342aab3d8076$export$87e0539f600c24e5(props, state, ref) {
19
+ let res = (0, $c4acc1de3ab169cf$export$d652b3ea2d672d5b)(props, state);
20
+ // We need to ignore virtual pointer events from VoiceOver due to these bugs.
21
+ // https://bugs.webkit.org/show_bug.cgi?id=222627
22
+ // https://bugs.webkit.org/show_bug.cgi?id=223202
23
+ // usePress also does this and waits for the following click event before firing.
24
+ // We need to match that here otherwise this will fire before the press event in
25
+ // useCalendarCell, causing range selection to not work properly.
26
+ let isVirtualClick = (0, $juhpn$useRef)(false);
27
+ let windowRef = (0, $juhpn$useRef)(typeof window !== 'undefined' ? window : null);
28
+ (0, $juhpn$useEvent)(windowRef, 'pointerdown', (e)=>{
29
+ isVirtualClick.current = e.width === 0 && e.height === 0;
30
+ });
31
+ // Stop range selection when pressing or releasing a pointer outside the calendar body,
32
+ // except when pressing the next or previous buttons to switch months.
33
+ let endDragging = (e)=>{
34
+ if (isVirtualClick.current) {
35
+ isVirtualClick.current = false;
36
+ return;
37
+ }
38
+ state.setDragging(false);
39
+ if (!state.anchorDate) return;
40
+ let target = e.target;
41
+ if (ref.current && ref.current.contains(document.activeElement) && (!ref.current.contains(target) || !target.closest('button, [role="button"]'))) state.selectFocusedDate();
42
+ };
43
+ (0, $juhpn$useEvent)(windowRef, 'pointerup', endDragging);
44
+ // Also stop range selection on blur, e.g. tabbing away from the calendar.
45
+ res.calendarProps.onBlur = (e)=>{
46
+ if (!ref.current) return;
47
+ if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) state.selectFocusedDate();
48
+ };
49
+ // Prevent touch scrolling while dragging
50
+ (0, $juhpn$useEvent)(ref, 'touchmove', (e)=>{
51
+ if (state.isDragging) e.preventDefault();
52
+ }, {
53
+ passive: false,
54
+ capture: true
55
+ });
56
+ return res;
57
+ }
58
+
59
+
60
+ export {$46a4342aab3d8076$export$87e0539f600c24e5 as useRangeCalendar};
61
+ //# sourceMappingURL=useRangeCalendar.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAaM,SAAS,0CAAsC,KAAgC,EAAE,KAAyB,EAAE,GAAgC;IACjJ,IAAI,MAAM,CAAA,GAAA,yCAAc,EAAE,OAAO;IAEjC,6EAA6E;IAC7E,iDAAiD;IACjD,iDAAiD;IACjD,iFAAiF;IACjF,gFAAgF;IAChF,iEAAiE;IACjE,IAAI,iBAAiB,CAAA,GAAA,aAAK,EAAE;IAC5B,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE,OAAO,WAAW,cAAc,SAAS;IAChE,CAAA,GAAA,eAAO,EAAE,WAAW,eAAe,CAAA;QACjC,eAAe,OAAO,GAAG,EAAE,KAAK,KAAK,KAAK,EAAE,MAAM,KAAK;IACzD;IAEA,uFAAuF;IACvF,sEAAsE;IACtE,IAAI,cAAc,CAAC;QACjB,IAAI,eAAe,OAAO,EAAE;YAC1B,eAAe,OAAO,GAAG;YACzB;QACF;QAEA,MAAM,WAAW,CAAC;QAClB,IAAI,CAAC,MAAM,UAAU,EACnB;QAGF,IAAI,SAAS,EAAE,MAAM;QACrB,IACE,IAAI,OAAO,IACX,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,aAAa,KAC1C,CAAA,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,0BAAyB,GAE3E,MAAM,iBAAiB;IAE3B;IAEA,CAAA,GAAA,eAAO,EAAE,WAAW,aAAa;IAEjC,0EAA0E;IAC1E,IAAI,aAAa,CAAC,MAAM,GAAG,CAAA;QACzB,IAAI,CAAC,IAAI,OAAO,EACd;QAEF,IAAI,AAAC,CAAA,CAAC,EAAE,aAAa,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAA,KAAM,MAAM,UAAU,EAClF,MAAM,iBAAiB;IAE3B;IAEA,yCAAyC;IACzC,CAAA,GAAA,eAAO,EAAE,KAAK,aAAa,CAAA;QACzB,IAAI,MAAM,UAAU,EAClB,EAAE,cAAc;IAEpB,GAAG;QAAC,SAAS;QAAO,SAAS;IAAI;IAEjC,OAAO;AACT","sources":["packages/@react-aria/calendar/src/useRangeCalendar.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 {AriaRangeCalendarProps, DateValue} from '@react-types/calendar';\nimport {CalendarAria, useCalendarBase} from './useCalendarBase';\nimport {FocusableElement} from '@react-types/shared';\nimport {RangeCalendarState} from '@react-stately/calendar';\nimport {RefObject, useRef} from 'react';\nimport {useEvent} from '@react-aria/utils';\n\n/**\n * Provides the behavior and accessibility implementation for a range calendar component.\n * A range calendar displays one or more date grids and allows users to select a contiguous range of dates.\n */\nexport function useRangeCalendar<T extends DateValue>(props: AriaRangeCalendarProps<T>, state: RangeCalendarState, ref: RefObject<FocusableElement>): CalendarAria {\n let res = useCalendarBase(props, state);\n\n // We need to ignore virtual pointer events from VoiceOver due to these bugs.\n // https://bugs.webkit.org/show_bug.cgi?id=222627\n // https://bugs.webkit.org/show_bug.cgi?id=223202\n // usePress also does this and waits for the following click event before firing.\n // We need to match that here otherwise this will fire before the press event in\n // useCalendarCell, causing range selection to not work properly.\n let isVirtualClick = useRef(false);\n let windowRef = useRef(typeof window !== 'undefined' ? window : null);\n useEvent(windowRef, 'pointerdown', e => {\n isVirtualClick.current = e.width === 0 && e.height === 0;\n });\n\n // Stop range selection when pressing or releasing a pointer outside the calendar body,\n // except when pressing the next or previous buttons to switch months.\n let endDragging = (e: PointerEvent) => {\n if (isVirtualClick.current) {\n isVirtualClick.current = false;\n return;\n }\n\n state.setDragging(false);\n if (!state.anchorDate) {\n return;\n }\n\n let target = e.target as Element;\n if (\n ref.current &&\n ref.current.contains(document.activeElement) &&\n (!ref.current.contains(target) || !target.closest('button, [role=\"button\"]'))\n ) {\n state.selectFocusedDate();\n }\n };\n\n useEvent(windowRef, 'pointerup', endDragging);\n\n // Also stop range selection on blur, e.g. tabbing away from the calendar.\n res.calendarProps.onBlur = e => {\n if (!ref.current) {\n return;\n }\n if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) {\n state.selectFocusedDate();\n }\n };\n\n // Prevent touch scrolling while dragging\n useEvent(ref, 'touchmove', e => {\n if (state.isDragging) {\n e.preventDefault();\n }\n }, {passive: false, capture: true});\n\n return res;\n}\n"],"names":[],"version":3,"file":"useRangeCalendar.module.js.map"}
@@ -0,0 +1,138 @@
1
+ var $bd6dc95a3c5ee5cd$exports = require("./intlStrings.main.js");
2
+ var $idq92$internationalizeddate = require("@internationalized/date");
3
+ var $idq92$reactariai18n = require("@react-aria/i18n");
4
+ var $idq92$react = require("react");
5
+
6
+
7
+ function $parcel$interopDefault(a) {
8
+ return a && a.__esModule ? a.default : a;
9
+ }
10
+
11
+ function $parcel$export(e, n, v, s) {
12
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
13
+ }
14
+
15
+ $parcel$export(module.exports, "hookData", () => $df1d8e967e73ec8e$export$653eddfc964b0f8a);
16
+ $parcel$export(module.exports, "getEraFormat", () => $df1d8e967e73ec8e$export$134cbb7fb09a9522);
17
+ $parcel$export(module.exports, "useSelectedDateDescription", () => $df1d8e967e73ec8e$export$b6df97c887c38e1a);
18
+ $parcel$export(module.exports, "useVisibleRangeDescription", () => $df1d8e967e73ec8e$export$31afe65d91ef6e8);
19
+ /*
20
+ * Copyright 2020 Adobe. All rights reserved.
21
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License. You may obtain a copy
23
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software distributed under
26
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
+ * OF ANY KIND, either express or implied. See the License for the specific language
28
+ * governing permissions and limitations under the License.
29
+ */
30
+
31
+
32
+
33
+ const $df1d8e967e73ec8e$export$653eddfc964b0f8a = new WeakMap();
34
+ function $df1d8e967e73ec8e$export$134cbb7fb09a9522(date) {
35
+ return (date === null || date === void 0 ? void 0 : date.calendar.identifier) === 'gregory' && date.era === 'BC' ? 'short' : undefined;
36
+ }
37
+ function $df1d8e967e73ec8e$export$b6df97c887c38e1a(state) {
38
+ let stringFormatter = (0, $idq92$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($bd6dc95a3c5ee5cd$exports))), '@react-aria/calendar');
39
+ let start, end;
40
+ if ('highlightedRange' in state) ({ start: start, end: end } = state.highlightedRange || {});
41
+ else start = end = state.value;
42
+ let dateFormatter = (0, $idq92$reactariai18n.useDateFormatter)({
43
+ weekday: 'long',
44
+ month: 'long',
45
+ year: 'numeric',
46
+ day: 'numeric',
47
+ era: $df1d8e967e73ec8e$export$134cbb7fb09a9522(start) || $df1d8e967e73ec8e$export$134cbb7fb09a9522(end),
48
+ timeZone: state.timeZone
49
+ });
50
+ let anchorDate = 'anchorDate' in state ? state.anchorDate : null;
51
+ return (0, $idq92$react.useMemo)(()=>{
52
+ // No message if currently selecting a range, or there is nothing highlighted.
53
+ if (!anchorDate && start && end) {
54
+ // Use a single date message if the start and end dates are the same day,
55
+ // otherwise include both dates.
56
+ if ((0, $idq92$internationalizeddate.isSameDay)(start, end)) {
57
+ let date = dateFormatter.format(start.toDate(state.timeZone));
58
+ return stringFormatter.format('selectedDateDescription', {
59
+ date: date
60
+ });
61
+ } else {
62
+ let dateRange = $df1d8e967e73ec8e$var$formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);
63
+ return stringFormatter.format('selectedRangeDescription', {
64
+ dateRange: dateRange
65
+ });
66
+ }
67
+ }
68
+ return '';
69
+ }, [
70
+ start,
71
+ end,
72
+ anchorDate,
73
+ state.timeZone,
74
+ stringFormatter,
75
+ dateFormatter
76
+ ]);
77
+ }
78
+ function $df1d8e967e73ec8e$export$31afe65d91ef6e8(startDate, endDate, timeZone, isAria) {
79
+ let stringFormatter = (0, $idq92$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($bd6dc95a3c5ee5cd$exports))), '@react-aria/calendar');
80
+ let era = $df1d8e967e73ec8e$export$134cbb7fb09a9522(startDate) || $df1d8e967e73ec8e$export$134cbb7fb09a9522(endDate);
81
+ let monthFormatter = (0, $idq92$reactariai18n.useDateFormatter)({
82
+ month: 'long',
83
+ year: 'numeric',
84
+ era: era,
85
+ calendar: startDate.calendar.identifier,
86
+ timeZone: timeZone
87
+ });
88
+ let dateFormatter = (0, $idq92$reactariai18n.useDateFormatter)({
89
+ month: 'long',
90
+ year: 'numeric',
91
+ day: 'numeric',
92
+ era: era,
93
+ calendar: startDate.calendar.identifier,
94
+ timeZone: timeZone
95
+ });
96
+ return (0, $idq92$react.useMemo)(()=>{
97
+ // Special case for month granularity. Format as a single month if only a
98
+ // single month is visible, otherwise format as a range of months.
99
+ if ((0, $idq92$internationalizeddate.isSameDay)(startDate, (0, $idq92$internationalizeddate.startOfMonth)(startDate))) {
100
+ if ((0, $idq92$internationalizeddate.isSameDay)(endDate, (0, $idq92$internationalizeddate.endOfMonth)(startDate))) return monthFormatter.format(startDate.toDate(timeZone));
101
+ else if ((0, $idq92$internationalizeddate.isSameDay)(endDate, (0, $idq92$internationalizeddate.endOfMonth)(endDate))) return isAria ? $df1d8e967e73ec8e$var$formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone) : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
102
+ }
103
+ return isAria ? $df1d8e967e73ec8e$var$formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone) : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));
104
+ }, [
105
+ startDate,
106
+ endDate,
107
+ monthFormatter,
108
+ dateFormatter,
109
+ stringFormatter,
110
+ timeZone,
111
+ isAria
112
+ ]);
113
+ }
114
+ function $df1d8e967e73ec8e$var$formatRange(dateFormatter, stringFormatter, start, end, timeZone) {
115
+ let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));
116
+ // Find the separator between the start and end date. This is determined
117
+ // by finding the last shared literal before the end range.
118
+ let separatorIndex = -1;
119
+ for(let i = 0; i < parts.length; i++){
120
+ let part = parts[i];
121
+ if (part.source === 'shared' && part.type === 'literal') separatorIndex = i;
122
+ else if (part.source === 'endRange') break;
123
+ }
124
+ // Now we can combine the parts into start and end strings.
125
+ let startValue = '';
126
+ let endValue = '';
127
+ for(let i = 0; i < parts.length; i++){
128
+ if (i < separatorIndex) startValue += parts[i].value;
129
+ else if (i > separatorIndex) endValue += parts[i].value;
130
+ }
131
+ return stringFormatter.format('dateRange', {
132
+ startDate: startValue,
133
+ endDate: endValue
134
+ });
135
+ }
136
+
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C,WAAW,IAAI,MAAM,CAAC;IAEhF,wEAAwE;IACxE,2DAA2D;IAC3D,IAAI,iBAAiB;IACrB,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,OAAO,KAAK,CAAC,EAAE;QACnB,IAAI,KAAK,MAAM,KAAK,YAAY,KAAK,IAAI,KAAK,WAC5C,iBAAiB;aACZ,IAAI,KAAK,MAAM,KAAK,YACzB;IAEJ;IAEA,2DAA2D;IAC3D,IAAI,aAAa;IACjB,IAAI,WAAW;IACf,IAAK,IAAI,IAAI,GAAG,IAAI,MAAM,MAAM,EAAE,IAAK;QACrC,IAAI,IAAI,gBACN,cAAc,KAAK,CAAC,EAAE,CAAC,KAAK;aACvB,IAAI,IAAI,gBACb,YAAY,KAAK,CAAC,EAAE,CAAC,KAAK;IAE9B;IAEA,OAAO,gBAAgB,MAAM,CAAC,aAAa;QAAC,WAAW;QAAY,SAAS;IAAQ;AACtF","sources":["packages/@react-aria/calendar/src/utils.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 {CalendarDate, DateFormatter, endOfMonth, isSameDay, startOfMonth} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from '@react-stately/calendar';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport type {LocalizedStringFormatter} from '@internationalized/string';\nimport {useDateFormatter, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo} from 'react';\n\ninterface HookData {\n ariaLabel: string,\n ariaLabelledBy: string,\n errorMessageId: string,\n selectedDateDescription: string\n}\n\nexport const hookData = new WeakMap<CalendarState | RangeCalendarState, HookData>();\n\nexport function getEraFormat(date: CalendarDate): 'short' | undefined {\n return date?.calendar.identifier === 'gregory' && date.era === 'BC' ? 'short' : undefined;\n}\n\nexport function useSelectedDateDescription(state: CalendarState | RangeCalendarState) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n\n let start: CalendarDate, end: CalendarDate;\n if ('highlightedRange' in state) {\n ({start, end} = state.highlightedRange || {});\n } else {\n start = end = state.value;\n }\n\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era: getEraFormat(start) || getEraFormat(end),\n timeZone: state.timeZone\n });\n\n let anchorDate = 'anchorDate' in state ? state.anchorDate : null;\n return useMemo(() => {\n // No message if currently selecting a range, or there is nothing highlighted.\n if (!anchorDate && start && end) {\n // Use a single date message if the start and end dates are the same day,\n // otherwise include both dates.\n if (isSameDay(start, end)) {\n let date = dateFormatter.format(start.toDate(state.timeZone));\n return stringFormatter.format('selectedDateDescription', {date});\n } else {\n let dateRange = formatRange(dateFormatter, stringFormatter, start, end, state.timeZone);\n\n return stringFormatter.format('selectedRangeDescription', {dateRange});\n }\n }\n return '';\n }, [start, end, anchorDate, state.timeZone, stringFormatter, dateFormatter]);\n}\n\nexport function useVisibleRangeDescription(startDate: CalendarDate, endDate: CalendarDate, timeZone: string, isAria: boolean) {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let era: any = getEraFormat(startDate) || getEraFormat(endDate);\n let monthFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n let dateFormatter = useDateFormatter({\n month: 'long',\n year: 'numeric',\n day: 'numeric',\n era,\n calendar: startDate.calendar.identifier,\n timeZone\n });\n\n return useMemo(() => {\n // Special case for month granularity. Format as a single month if only a\n // single month is visible, otherwise format as a range of months.\n if (isSameDay(startDate, startOfMonth(startDate))) {\n if (isSameDay(endDate, endOfMonth(startDate))) {\n return monthFormatter.format(startDate.toDate(timeZone));\n } else if (isSameDay(endDate, endOfMonth(endDate))) {\n return isAria\n ? formatRange(monthFormatter, stringFormatter, startDate, endDate, timeZone)\n : monthFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }\n }\n\n return isAria\n ? formatRange(dateFormatter, stringFormatter, startDate, endDate, timeZone)\n : dateFormatter.formatRange(startDate.toDate(timeZone), endDate.toDate(timeZone));\n }, [startDate, endDate, monthFormatter, dateFormatter, stringFormatter, timeZone, isAria]);\n}\n\nfunction formatRange(dateFormatter: DateFormatter, stringFormatter: LocalizedStringFormatter, start: CalendarDate, end: CalendarDate, timeZone: string) {\n let parts = dateFormatter.formatRangeToParts(start.toDate(timeZone), end.toDate(timeZone));\n\n // Find the separator between the start and end date. This is determined\n // by finding the last shared literal before the end range.\n let separatorIndex = -1;\n for (let i = 0; i < parts.length; i++) {\n let part = parts[i];\n if (part.source === 'shared' && part.type === 'literal') {\n separatorIndex = i;\n } else if (part.source === 'endRange') {\n break;\n }\n }\n\n // Now we can combine the parts into start and end strings.\n let startValue = '';\n let endValue = '';\n for (let i = 0; i < parts.length; i++) {\n if (i < separatorIndex) {\n startValue += parts[i].value;\n } else if (i > separatorIndex) {\n endValue += parts[i].value;\n }\n }\n\n return stringFormatter.format('dateRange', {startDate: startValue, endDate: endValue});\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}