react-aria 3.49.0 → 3.50.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 (244) hide show
  1. package/dist/private/autocomplete/useAutocomplete.cjs +16 -7
  2. package/dist/private/autocomplete/useAutocomplete.cjs.map +1 -1
  3. package/dist/private/autocomplete/useAutocomplete.js +16 -7
  4. package/dist/private/autocomplete/useAutocomplete.js.map +1 -1
  5. package/dist/private/autocomplete/useAutocomplete.mjs +16 -7
  6. package/dist/private/autocomplete/useAutocomplete.mjs.map +1 -1
  7. package/dist/private/breadcrumbs/useBreadcrumbs.cjs.map +1 -1
  8. package/dist/private/breadcrumbs/useBreadcrumbs.js.map +1 -1
  9. package/dist/private/breadcrumbs/useBreadcrumbs.mjs.map +1 -1
  10. package/dist/private/calendar/useCalendarBase.cjs.map +1 -1
  11. package/dist/private/calendar/useCalendarBase.js.map +1 -1
  12. package/dist/private/calendar/useCalendarBase.mjs.map +1 -1
  13. package/dist/private/calendar/useCalendarCell.cjs.map +1 -1
  14. package/dist/private/calendar/useCalendarCell.js.map +1 -1
  15. package/dist/private/calendar/useCalendarCell.mjs.map +1 -1
  16. package/dist/private/calendar/useCalendarYearPicker.cjs +4 -4
  17. package/dist/private/calendar/useCalendarYearPicker.cjs.map +1 -1
  18. package/dist/private/calendar/useCalendarYearPicker.js +4 -4
  19. package/dist/private/calendar/useCalendarYearPicker.js.map +1 -1
  20. package/dist/private/calendar/useCalendarYearPicker.mjs +4 -4
  21. package/dist/private/calendar/useCalendarYearPicker.mjs.map +1 -1
  22. package/dist/private/calendar/utils.cjs.map +1 -1
  23. package/dist/private/calendar/utils.js.map +1 -1
  24. package/dist/private/calendar/utils.mjs.map +1 -1
  25. package/dist/private/color/useColorArea.cjs.map +1 -1
  26. package/dist/private/color/useColorArea.js.map +1 -1
  27. package/dist/private/color/useColorArea.mjs.map +1 -1
  28. package/dist/private/color/useColorSwatch.cjs.map +1 -1
  29. package/dist/private/color/useColorSwatch.js.map +1 -1
  30. package/dist/private/color/useColorSwatch.mjs.map +1 -1
  31. package/dist/private/combobox/useComboBox.cjs +2 -0
  32. package/dist/private/combobox/useComboBox.cjs.map +1 -1
  33. package/dist/private/combobox/useComboBox.js +2 -0
  34. package/dist/private/combobox/useComboBox.js.map +1 -1
  35. package/dist/private/combobox/useComboBox.mjs +2 -0
  36. package/dist/private/combobox/useComboBox.mjs.map +1 -1
  37. package/dist/private/datepicker/useDateField.cjs.map +1 -1
  38. package/dist/private/datepicker/useDateField.js.map +1 -1
  39. package/dist/private/datepicker/useDateField.mjs.map +1 -1
  40. package/dist/private/datepicker/useDatePicker.cjs.map +1 -1
  41. package/dist/private/datepicker/useDatePicker.js.map +1 -1
  42. package/dist/private/datepicker/useDatePicker.mjs.map +1 -1
  43. package/dist/private/datepicker/useDateRangePicker.cjs.map +1 -1
  44. package/dist/private/datepicker/useDateRangePicker.js.map +1 -1
  45. package/dist/private/datepicker/useDateRangePicker.mjs.map +1 -1
  46. package/dist/private/datepicker/useDisplayNames.cjs +1 -2
  47. package/dist/private/datepicker/useDisplayNames.cjs.map +1 -1
  48. package/dist/private/datepicker/useDisplayNames.js +1 -2
  49. package/dist/private/datepicker/useDisplayNames.js.map +1 -1
  50. package/dist/private/datepicker/useDisplayNames.mjs +1 -2
  51. package/dist/private/datepicker/useDisplayNames.mjs.map +1 -1
  52. package/dist/private/dnd/DragManager.cjs +4 -1
  53. package/dist/private/dnd/DragManager.cjs.map +1 -1
  54. package/dist/private/dnd/DragManager.js +4 -1
  55. package/dist/private/dnd/DragManager.js.map +1 -1
  56. package/dist/private/dnd/DragManager.mjs +4 -1
  57. package/dist/private/dnd/DragManager.mjs.map +1 -1
  58. package/dist/private/dnd/useDrag.cjs.map +1 -1
  59. package/dist/private/dnd/useDrag.js.map +1 -1
  60. package/dist/private/dnd/useDrag.mjs.map +1 -1
  61. package/dist/private/dnd/useDraggableItem.cjs.map +1 -1
  62. package/dist/private/dnd/useDraggableItem.js.map +1 -1
  63. package/dist/private/dnd/useDraggableItem.mjs.map +1 -1
  64. package/dist/private/dnd/useDropIndicator.cjs.map +1 -1
  65. package/dist/private/dnd/useDropIndicator.js.map +1 -1
  66. package/dist/private/dnd/useDropIndicator.mjs.map +1 -1
  67. package/dist/private/dnd/useVirtualDrop.cjs.map +1 -1
  68. package/dist/private/dnd/useVirtualDrop.js.map +1 -1
  69. package/dist/private/dnd/useVirtualDrop.mjs.map +1 -1
  70. package/dist/private/dnd/utils.cjs +13 -3
  71. package/dist/private/dnd/utils.cjs.map +1 -1
  72. package/dist/private/dnd/utils.js +13 -3
  73. package/dist/private/dnd/utils.js.map +1 -1
  74. package/dist/private/dnd/utils.mjs +13 -3
  75. package/dist/private/dnd/utils.mjs.map +1 -1
  76. package/dist/private/form/useFormValidation.cjs +1 -1
  77. package/dist/private/form/useFormValidation.cjs.map +1 -1
  78. package/dist/private/form/useFormValidation.js +1 -1
  79. package/dist/private/form/useFormValidation.js.map +1 -1
  80. package/dist/private/form/useFormValidation.mjs +1 -1
  81. package/dist/private/form/useFormValidation.mjs.map +1 -1
  82. package/dist/private/grid/useGridSelectionAnnouncement.cjs.map +1 -1
  83. package/dist/private/grid/useGridSelectionAnnouncement.js.map +1 -1
  84. package/dist/private/grid/useGridSelectionAnnouncement.mjs.map +1 -1
  85. package/dist/private/grid/useGridSelectionCheckbox.cjs.map +1 -1
  86. package/dist/private/grid/useGridSelectionCheckbox.js.map +1 -1
  87. package/dist/private/grid/useGridSelectionCheckbox.mjs.map +1 -1
  88. package/dist/private/grid/useHighlightSelectionDescription.cjs.map +1 -1
  89. package/dist/private/grid/useHighlightSelectionDescription.js.map +1 -1
  90. package/dist/private/grid/useHighlightSelectionDescription.mjs.map +1 -1
  91. package/dist/private/gridlist/useGridList.cjs +2 -1
  92. package/dist/private/gridlist/useGridList.cjs.map +1 -1
  93. package/dist/private/gridlist/useGridList.js +2 -1
  94. package/dist/private/gridlist/useGridList.js.map +1 -1
  95. package/dist/private/gridlist/useGridList.mjs +2 -1
  96. package/dist/private/gridlist/useGridList.mjs.map +1 -1
  97. package/dist/private/gridlist/useGridListItem.cjs +62 -21
  98. package/dist/private/gridlist/useGridListItem.cjs.map +1 -1
  99. package/dist/private/gridlist/useGridListItem.js +63 -22
  100. package/dist/private/gridlist/useGridListItem.js.map +1 -1
  101. package/dist/private/gridlist/useGridListItem.mjs +62 -21
  102. package/dist/private/gridlist/useGridListItem.mjs.map +1 -1
  103. package/dist/private/interactions/createEventHandler.cjs +3 -0
  104. package/dist/private/interactions/createEventHandler.cjs.map +1 -1
  105. package/dist/private/interactions/createEventHandler.js +3 -0
  106. package/dist/private/interactions/createEventHandler.js.map +1 -1
  107. package/dist/private/interactions/createEventHandler.mjs +3 -0
  108. package/dist/private/interactions/createEventHandler.mjs.map +1 -1
  109. package/dist/private/interactions/useFocusVisible.cjs +16 -5
  110. package/dist/private/interactions/useFocusVisible.cjs.map +1 -1
  111. package/dist/private/interactions/useFocusVisible.js +16 -5
  112. package/dist/private/interactions/useFocusVisible.js.map +1 -1
  113. package/dist/private/interactions/useFocusVisible.mjs +16 -5
  114. package/dist/private/interactions/useFocusVisible.mjs.map +1 -1
  115. package/dist/private/menu/useMenu.cjs.map +1 -1
  116. package/dist/private/menu/useMenu.js.map +1 -1
  117. package/dist/private/menu/useMenu.mjs.map +1 -1
  118. package/dist/private/menu/useMenuItem.cjs +1 -1
  119. package/dist/private/menu/useMenuItem.cjs.map +1 -1
  120. package/dist/private/menu/useMenuItem.js +1 -1
  121. package/dist/private/menu/useMenuItem.js.map +1 -1
  122. package/dist/private/menu/useMenuItem.mjs +1 -1
  123. package/dist/private/menu/useMenuItem.mjs.map +1 -1
  124. package/dist/private/menu/useMenuTrigger.cjs.map +1 -1
  125. package/dist/private/menu/useMenuTrigger.js.map +1 -1
  126. package/dist/private/menu/useMenuTrigger.mjs.map +1 -1
  127. package/dist/private/menu/utils.cjs.map +1 -1
  128. package/dist/private/menu/utils.js.map +1 -1
  129. package/dist/private/menu/utils.mjs.map +1 -1
  130. package/dist/private/numberfield/useNumberField.cjs.map +1 -1
  131. package/dist/private/numberfield/useNumberField.js.map +1 -1
  132. package/dist/private/numberfield/useNumberField.mjs.map +1 -1
  133. package/dist/private/overlays/DismissButton.cjs.map +1 -1
  134. package/dist/private/overlays/DismissButton.js.map +1 -1
  135. package/dist/private/overlays/DismissButton.mjs.map +1 -1
  136. package/dist/private/overlays/calculatePosition.cjs +7 -7
  137. package/dist/private/overlays/calculatePosition.cjs.map +1 -1
  138. package/dist/private/overlays/calculatePosition.js +7 -7
  139. package/dist/private/overlays/calculatePosition.js.map +1 -1
  140. package/dist/private/overlays/calculatePosition.mjs +7 -7
  141. package/dist/private/overlays/calculatePosition.mjs.map +1 -1
  142. package/dist/private/overlays/useOverlayPosition.cjs +3 -2
  143. package/dist/private/overlays/useOverlayPosition.cjs.map +1 -1
  144. package/dist/private/overlays/useOverlayPosition.js +3 -2
  145. package/dist/private/overlays/useOverlayPosition.js.map +1 -1
  146. package/dist/private/overlays/useOverlayPosition.mjs +3 -2
  147. package/dist/private/overlays/useOverlayPosition.mjs.map +1 -1
  148. package/dist/private/searchfield/useSearchField.cjs.map +1 -1
  149. package/dist/private/searchfield/useSearchField.js.map +1 -1
  150. package/dist/private/searchfield/useSearchField.mjs.map +1 -1
  151. package/dist/private/select/useSelect.cjs +1 -2
  152. package/dist/private/select/useSelect.cjs.map +1 -1
  153. package/dist/private/select/useSelect.js +1 -2
  154. package/dist/private/select/useSelect.js.map +1 -1
  155. package/dist/private/select/useSelect.mjs +1 -2
  156. package/dist/private/select/useSelect.mjs.map +1 -1
  157. package/dist/private/selection/ListKeyboardDelegate.cjs +31 -3
  158. package/dist/private/selection/ListKeyboardDelegate.cjs.map +1 -1
  159. package/dist/private/selection/ListKeyboardDelegate.js +31 -3
  160. package/dist/private/selection/ListKeyboardDelegate.js.map +1 -1
  161. package/dist/private/selection/ListKeyboardDelegate.mjs +31 -3
  162. package/dist/private/selection/ListKeyboardDelegate.mjs.map +1 -1
  163. package/dist/private/selection/useSelectableCollection.cjs +20 -14
  164. package/dist/private/selection/useSelectableCollection.cjs.map +1 -1
  165. package/dist/private/selection/useSelectableCollection.js +26 -19
  166. package/dist/private/selection/useSelectableCollection.js.map +1 -1
  167. package/dist/private/selection/useSelectableCollection.mjs +20 -14
  168. package/dist/private/selection/useSelectableCollection.mjs.map +1 -1
  169. package/dist/private/selection/useTypeSelect.cjs +50 -18
  170. package/dist/private/selection/useTypeSelect.cjs.map +1 -1
  171. package/dist/private/selection/useTypeSelect.js +51 -19
  172. package/dist/private/selection/useTypeSelect.js.map +1 -1
  173. package/dist/private/selection/useTypeSelect.mjs +51 -19
  174. package/dist/private/selection/useTypeSelect.mjs.map +1 -1
  175. package/dist/private/spinbutton/useSpinButton.cjs.map +1 -1
  176. package/dist/private/spinbutton/useSpinButton.js.map +1 -1
  177. package/dist/private/spinbutton/useSpinButton.mjs.map +1 -1
  178. package/dist/private/steplist/useStepList.cjs.map +1 -1
  179. package/dist/private/steplist/useStepList.js.map +1 -1
  180. package/dist/private/steplist/useStepList.mjs.map +1 -1
  181. package/dist/private/table/useTable.cjs.map +1 -1
  182. package/dist/private/table/useTable.js.map +1 -1
  183. package/dist/private/table/useTable.mjs.map +1 -1
  184. package/dist/private/table/useTableColumnHeader.cjs.map +1 -1
  185. package/dist/private/table/useTableColumnHeader.js.map +1 -1
  186. package/dist/private/table/useTableColumnHeader.mjs.map +1 -1
  187. package/dist/private/table/useTableColumnResize.cjs.map +1 -1
  188. package/dist/private/table/useTableColumnResize.js.map +1 -1
  189. package/dist/private/table/useTableColumnResize.mjs.map +1 -1
  190. package/dist/private/table/useTableRow.cjs.map +1 -1
  191. package/dist/private/table/useTableRow.js.map +1 -1
  192. package/dist/private/table/useTableRow.mjs.map +1 -1
  193. package/dist/private/table/useTableSelectionCheckbox.cjs.map +1 -1
  194. package/dist/private/table/useTableSelectionCheckbox.js.map +1 -1
  195. package/dist/private/table/useTableSelectionCheckbox.mjs.map +1 -1
  196. package/dist/private/tabs/TabsKeyboardDelegate.cjs +2 -2
  197. package/dist/private/tabs/TabsKeyboardDelegate.cjs.map +1 -1
  198. package/dist/private/tabs/TabsKeyboardDelegate.js +2 -2
  199. package/dist/private/tabs/TabsKeyboardDelegate.js.map +1 -1
  200. package/dist/private/tabs/TabsKeyboardDelegate.mjs +2 -2
  201. package/dist/private/tabs/TabsKeyboardDelegate.mjs.map +1 -1
  202. package/dist/private/tag/useTag.cjs.map +1 -1
  203. package/dist/private/tag/useTag.js.map +1 -1
  204. package/dist/private/tag/useTag.mjs.map +1 -1
  205. package/dist/private/toast/useToast.cjs.map +1 -1
  206. package/dist/private/toast/useToast.js.map +1 -1
  207. package/dist/private/toast/useToast.mjs.map +1 -1
  208. package/dist/private/toast/useToastRegion.cjs.map +1 -1
  209. package/dist/private/toast/useToastRegion.js.map +1 -1
  210. package/dist/private/toast/useToastRegion.mjs.map +1 -1
  211. package/dist/private/toolbar/useToolbar.cjs +0 -1
  212. package/dist/private/toolbar/useToolbar.cjs.map +1 -1
  213. package/dist/private/toolbar/useToolbar.js +0 -1
  214. package/dist/private/toolbar/useToolbar.js.map +1 -1
  215. package/dist/private/toolbar/useToolbar.mjs +0 -1
  216. package/dist/private/toolbar/useToolbar.mjs.map +1 -1
  217. package/dist/private/tree/useTree.cjs.map +1 -1
  218. package/dist/private/tree/useTree.js.map +1 -1
  219. package/dist/private/tree/useTree.mjs.map +1 -1
  220. package/dist/private/tree/useTreeItem.cjs.map +1 -1
  221. package/dist/private/tree/useTreeItem.js.map +1 -1
  222. package/dist/private/tree/useTreeItem.mjs.map +1 -1
  223. package/dist/private/utils/isElementVisible.cjs +1 -1
  224. package/dist/private/utils/isElementVisible.cjs.map +1 -1
  225. package/dist/private/utils/isElementVisible.js +1 -1
  226. package/dist/private/utils/isElementVisible.js.map +1 -1
  227. package/dist/private/utils/isElementVisible.mjs +1 -1
  228. package/dist/private/utils/isElementVisible.mjs.map +1 -1
  229. package/dist/private/utils/isFocusable.cjs +3 -1
  230. package/dist/private/utils/isFocusable.cjs.map +1 -1
  231. package/dist/private/utils/isFocusable.js +3 -1
  232. package/dist/private/utils/isFocusable.js.map +1 -1
  233. package/dist/private/utils/isFocusable.mjs +3 -1
  234. package/dist/private/utils/isFocusable.mjs.map +1 -1
  235. package/dist/types/src/dnd/utils.d.ts +2 -2
  236. package/dist/types/src/gridlist/useGridList.d.ts +7 -0
  237. package/dist/types/src/menu/useMenu.d.ts +1 -1
  238. package/dist/types/src/menu/utils.d.ts +1 -1
  239. package/dist/types/src/overlays/calculatePosition.d.ts +1 -0
  240. package/dist/types/src/overlays/useOverlayPosition.d.ts +8 -0
  241. package/dist/types/src/selection/ListKeyboardDelegate.d.ts +1 -0
  242. package/dist/types/src/selection/useSelectableCollection.d.ts +7 -0
  243. package/dist/types/src/tree/useTree.d.ts +1 -1
  244. package/package.json +4 -4
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;AAuIM,SAAS,0CACd,KAAiC,EACjC,KAAwB;IAExB,IAAI,YACF,QAAQ,iBACR,aAAa,UACb,MAAM,yBACN,wBAAwB,4BACxB,sBAAsB,OACvB,GAAG;IAEJ,IAAI,eAAe,CAAA,GAAA,yCAAI;IACvB,IAAI,UAAU,CAAA,GAAA,aAAK,EAA6C;IAChE,IAAI,4BAA4B,CAAA,GAAA,aAAK,EAAE;IACvC,IAAI,yBAAyB,CAAA,GAAA,aAAK,EAAiB;IAEnD,2HAA2H;IAC3H,uCAAuC;IACvC,IAAI,uBAAuB,CAAA,GAAA,yCAAqB,QAAQ,aAAc,CAAA,CAAA,GAAA,yCAAI,OAAO,CAAA,GAAA,yCAAQ,GAAE;IAC3F,IAAI,CAAC,uBAAuB,yBAAyB,GAAG,CAAA,GAAA,eAAO,EAC7D,CAAC,wBAAwB,CAAC;IAE5B,6IAA6I;IAC7I,iEAAiE;IACjE,IAAI,CAAC,eA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AE,iBAAiB,EAAE,aAAa;IAExD;IAEA,IAAI,UAAU,CAAC;QACb,IAAI,CAAC,EAAE,SAAS,EACd;QAGF,IAAI,iBAAiB,uBAAuB,OAAO,GAC/C,SAAS,cAAc,CAAC,uBAAuB,OAAO,IACtD;QACJ,IAAI,gBAAgB;YAClB,IAAI,SAAS,CAAA,GAAA,yCAAa,EAAE;YAC5B,eAAe;gBACb,kKAAkK;gBAClK,CAAA,GAAA,yCAAkB,EAAE,QAAQ,cAAc,OAAO;gBACjD,CAAA,GAAA,yCAAmB,EAAE,cAAc,OAAO,EAAG;YAC/C;QACF;IACF;IAEA,2FAA2F;IAC3F,oFAAoF;IACpF,+EAA+E;IAC/E,wFAAwF;IACxF,IAAI,gBAAgB,CAAC;QACnB,IACE,EAAE,MAAM,KAAK,KACb,EAAE,WAAW,KAAK,WAClB,uBAAuB,OAAO,IAAI,QAClC,SAAS,OAAO,IAAI,MAEpB;QAGF,IAAI,CAAA,GAAA,yCAAa,EAAE,OAAO,SAAS,OAAO,EACxC;IAEJ;IAEA,uGAAuG;IACvG,uDAAuD;IACvD,IAAI,aAAa;QACf,OAAO,MAAM,UAAU;kBACvB;IACF;IAEA,IAAI,oBAAoB;mBACtB;QACA,yBAAyB,MAAM,aAAa,IAAI;gBAChD;iBACA;uBACA;IACF;IAEA,IAAI,eACF,aAAa;QACX,GAAG,UAAU;QACb,GAAI,yBAAyB,iBAAiB;QAC9C,cAAc;QACd,iBAAiB;QACjB,mFAAmF;QACnF,qBAAqB;QACrB,qGAAqG;QACrG,aAAa;QACb,gEAAgE;QAChE,YAAY;QACZ,cAAc;IAChB;IAGF,OAAO;oBACL;QACA,iBAAiB,CAAA,GAAA,yCAAS,EAAE,iBAAiB;mCAC3C;YACA,mBAAmB;QACrB;QACA,eAAe;QACf,QAAQ,UAAU,OAAO,WAAW;IACtC;AACF","sources":["packages/react-aria/src/autocomplete/useAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {\n AriaLabelingProps,\n BaseEvent,\n DOMProps,\n FocusableElement,\n FocusEvents,\n KeyboardEvents,\n Node,\n RefObject,\n ValueBase\n} from '@react-types/shared';\nimport {AriaTextFieldProps} from '../textfield/useTextField';\nimport {\n AutocompleteProps,\n AutocompleteState\n} from 'react-stately/private/autocomplete/useAutocompleteState';\nimport {CLEAR_FOCUS_EVENT, FOCUS_EVENT} from '../utils/constants';\nimport {\n dispatchVirtualBlur,\n dispatchVirtualFocus,\n getVirtuallyFocusedElement,\n moveVirtualFocus\n} from '../focus/virtualFocus';\nimport {getActiveElement, getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality, getPointerType} from '../interactions/useFocusVisible';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/autocomplete/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {isCtrlKeyPressed} from '../utils/keyboard';\nimport {mergeProps} from '../utils/mergeProps';\nimport {mergeRefs} from '../utils/mergeRefs';\nimport {\n FocusEvent as ReactFocusEvent,\n KeyboardEvent as ReactKeyboardEvent,\n PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {useEffectEvent} from '../utils/useEffectEvent';\nimport {useEvent} from '../utils/useEvent';\n\nimport {useId} from '../utils/useId';\n\nimport {useLabels} from '../utils/useLabels';\n// @ts-ignore\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useObjectRef} from '../utils/useObjectRef';\n\nexport interface CollectionOptions extends DOMProps, AriaLabelingProps {\n /** Whether the collection items should use virtual focus instead of being focused directly. */\n shouldUseVirtualFocus: boolean;\n /** Whether typeahead is disabled. */\n disallowTypeAhead: boolean;\n}\n\nexport interface InputProps<T = FocusableElement>\n extends\n DOMProps,\n FocusEvents<T>,\n KeyboardEvents,\n Pick<ValueBase<string>, 'onChange' | 'value'>,\n Pick<\n AriaTextFieldProps,\n | 'enterKeyHint'\n | 'aria-controls'\n | 'aria-autocomplete'\n | 'aria-activedescendant'\n | 'spellCheck'\n | 'autoCorrect'\n | 'autoComplete'\n > {}\n\nexport interface AriaAutocompleteProps<T> extends AutocompleteProps {\n /**\n * An optional filter function used to determine if a option should be included in the\n * autocomplete list. Include this if the items you are providing to your wrapped collection\n * aren't filtered by default.\n */\n filter?: (textValue: string, inputValue: string, node: Node<T>) => boolean;\n\n /**\n * Whether or not to focus the first item in the collection after a filter is performed. Note this\n * is only applicable if virtual focus behavior is not turned off via `disableVirtualFocus`.\n *\n * @default false\n */\n disableAutoFocusFirst?: boolean;\n\n /**\n * Whether the autocomplete should disable virtual focus, instead making the wrapped collection\n * directly tabbable.\n *\n * @default false\n */\n disableVirtualFocus?: boolean;\n}\n\nexport interface AriaAutocompleteOptions<T> extends Omit<AriaAutocompleteProps<T>, 'children'> {\n /** The ref for the wrapped collection element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the wrapped collection element. */\n collectionRef: RefObject<HTMLElement | null>;\n}\n\nexport interface AutocompleteAria<T> {\n /**\n * Props for the autocomplete input element. These should be passed to the input's aria hooks\n * (e.g. useTextField/useSearchField/etc) respectively.\n */\n inputProps: InputProps;\n /** Props for the collection, to be passed to collection's respective aria hook (e.g. useMenu). */\n collectionProps: CollectionOptions;\n /** Ref to attach to the wrapped collection. */\n collectionRef: RefObject<HTMLElement | null>;\n /**\n * A filter function that returns if the provided collection node should be filtered out of the\n * collection.\n */\n filter?: (nodeTextValue: string, node: Node<T>) => boolean;\n}\n\n/**\n * Provides the behavior and accessibility implementation for an autocomplete component. An\n * autocomplete combines a text input with a collection, allowing users to filter the collection's\n * contents match a query.\n *\n * @param props - Props for the autocomplete.\n * @param state - State for the autocomplete, as returned by `useAutocompleteState`.\n */\nexport function useAutocomplete<T>(\n props: AriaAutocompleteOptions<T>,\n state: AutocompleteState\n): AutocompleteAria<T> {\n let {\n inputRef,\n collectionRef,\n filter,\n disableAutoFocusFirst = false,\n disableVirtualFocus = false\n } = props;\n\n let collectionId = useId();\n let timeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let delayNextActiveDescendant = useRef(false);\n let queuedActiveDescendant = useRef<string | null>(null);\n\n // For mobile screen readers, we don't want virtual focus, instead opting to disable FocusScope's restoreFocus and manually\n // moving focus back to the subtriggers\n let isMobileScreenReader = getInteractionModality() === 'virtual' && (isIOS() || isAndroid());\n let [shouldUseVirtualFocus, setShouldUseVirtualFocus] = useState(\n !isMobileScreenReader && !disableVirtualFocus\n );\n // Tracks if a collection has been connected to the autocomplete. If false, we don't want to add various attributes to the autocomplete input\n // since it isn't attached to a filterable collection (e.g. Tabs)\n let [hasCollection, setHasCollection] = useState(false);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n let updateActiveDescendantEvent = useEffectEvent((e: Event) => {\n // Ensure input is focused if the user clicks on the collection directly.\n // don't trigger on touch so that mobile keyboard doesnt appear when tapping on options\n if (\n !e.isTrusted &&\n shouldUseVirtualFocus &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) !== inputRef.current &&\n getPointerType() !== 'touch'\n ) {\n inputRef.current.focus();\n }\n\n let target = getEventTarget(e) as Element | null;\n if (e.isTrusted || !target || queuedActiveDescendant.current === target.id) {\n return;\n }\n\n clearTimeout(timeout.current);\n if (target !== collectionRef.current) {\n if (delayNextActiveDescendant.current) {\n queuedActiveDescendant.current = target.id;\n timeout.current = setTimeout(() => {\n state.setFocusedNodeId(target.id);\n }, 500);\n } else {\n queuedActiveDescendant.current = target.id;\n state.setFocusedNodeId(target.id);\n }\n } else if (\n queuedActiveDescendant.current &&\n !document.getElementById(queuedActiveDescendant.current)\n ) {\n // If we recieve a focus event refocusing the collection, either we have newly refocused the input and are waiting for the\n // wrapped collection to refocus the previously focused node if any OR\n // we are in a state where we've filtered to such a point that there aren't any matching items in the collection to focus.\n // In this case we want to clear tracked item if any and clear active descendant\n queuedActiveDescendant.current = null;\n state.setFocusedNodeId(null);\n }\n\n delayNextActiveDescendant.current = false;\n });\n\n let [collectionNode, setCollectionNode] = useState<HTMLElement | null>(null);\n let callbackRef = useCallback(node => {\n setCollectionNode(node);\n if (node != null) {\n // If useSelectableCollection isn't passed shouldUseVirtualFocus even when useAutocomplete provides it\n // that means the collection doesn't support it (e.g. Table). If that is the case, we need to disable it here regardless\n // of what the user's provided so that the input doesn't recieve the onKeyDown and autocomplete props.\n if (node.getAttribute('tabindex') != null) {\n setShouldUseVirtualFocus(false);\n }\n setHasCollection(true);\n } else {\n setHasCollection(false);\n }\n }, []);\n useLayoutEffect(() => {\n if (collectionNode != null) {\n // When typing forward, we want to delay the setting of active descendant to not interrupt the native screen reader announcement\n // of the letter you just typed. If we recieve another focus event then we clear the queued update\n collectionNode.addEventListener('focusin', updateActiveDescendantEvent);\n }\n return () => {\n collectionNode?.removeEventListener('focusin', updateActiveDescendantEvent);\n };\n }, [collectionNode]);\n\n // Make sure to memo so that React doesn't keep registering a new event listeners on every rerender of the wrapped collection\n let mergedCollectionRef = useObjectRef(\n useMemo(() => mergeRefs(collectionRef, callbackRef), [collectionRef, callbackRef])\n );\n\n let focusFirstItem = useCallback(() => {\n delayNextActiveDescendant.current = true;\n collectionRef.current?.dispatchEvent(\n new CustomEvent(FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: {\n focusStrategy: 'first'\n }\n })\n );\n }, [collectionRef]);\n\n let clearVirtualFocus = useCallback(\n (clearFocusKey?: boolean) => {\n moveVirtualFocus(getActiveElement());\n queuedActiveDescendant.current = null;\n state.setFocusedNodeId(null);\n let clearFocusEvent = new CustomEvent(CLEAR_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: {\n clearFocusKey\n }\n });\n clearTimeout(timeout.current);\n delayNextActiveDescendant.current = false;\n collectionRef.current?.dispatchEvent(clearFocusEvent);\n },\n [collectionRef, state]\n );\n\n let lastInputType = useRef('');\n useEvent(inputRef, 'input', e => {\n let {inputType} = e as InputEvent;\n lastInputType.current = inputType;\n });\n\n let onChange = (value: string) => {\n // Tell wrapped collection to focus the first element in the list when typing forward and to clear focused key when modifying the text via\n // copy paste/backspacing/undo/redo for screen reader announcements\n if (lastInputType.current === 'insertText' && !disableAutoFocusFirst) {\n focusFirstItem();\n } else if (\n lastInputType.current &&\n (lastInputType.current.includes('insert') ||\n lastInputType.current.includes('delete') ||\n lastInputType.current.includes('history'))\n ) {\n clearVirtualFocus(true);\n\n // If onChange was triggered before the timeout actually updated the activedescendant, we need to fire\n // our own dispatchVirtualFocus so focusVisible gets reapplied on the input\n if (getVirtuallyFocusedElement(document) === inputRef.current) {\n dispatchVirtualFocus(inputRef.current!, null);\n }\n }\n\n state.setInputValue(value);\n };\n\n let keyDownTarget = useRef<Element | null>(null);\n // For textfield specific keydown operations\n let onKeyDown = (e: BaseEvent<ReactKeyboardEvent<any>>) => {\n keyDownTarget.current = getEventTarget(e) as Element;\n if (e.nativeEvent.isComposing) {\n return;\n }\n\n let focusedNodeId = queuedActiveDescendant.current;\n if (\n focusedNodeId !== null &&\n getOwnerDocument(inputRef.current).getElementById(focusedNodeId) == null\n ) {\n // if the focused id doesn't exist in document, then we need to clear the tracked focused node, otherwise\n // we will be attempting to fire key events on a non-existing node instead of trying to focus the newly swapped wrapped collection.\n // This can happen if you are swapping out the Autocomplete wrapped collection component like in the docs search.\n queuedActiveDescendant.current = null;\n focusedNodeId = null;\n }\n\n switch (e.key) {\n case 'a':\n if (isCtrlKeyPressed(e)) {\n return;\n }\n break;\n case 'Escape':\n // Early return for Escape here so it doesn't leak the Escape event from the simulated collection event below and\n // close the dialog prematurely. Ideally that should be up to the discretion of the input element hence the check\n // for isPropagationStopped\n if (e.isDefaultPrevented()) {\n return;\n }\n break;\n case ' ':\n // Space shouldn't trigger onAction so early return.\n return;\n case 'Tab':\n // Don't propogate Tab down to the collection, otherwise we will try to focus the collection via useSelectableCollection's Tab handler (aka shift tab logic)\n // We want FocusScope to handle Tab if one exists (aka sub dialog), so special casepropogate\n if ('continuePropagation' in e) {\n e.continuePropagation();\n }\n return;\n case 'Home':\n case 'End':\n case 'PageDown':\n case 'PageUp':\n case 'ArrowUp':\n case 'ArrowDown':\n case 'ArrowRight':\n case 'ArrowLeft': {\n if ((e.key === 'Home' || e.key === 'End') && focusedNodeId == null && e.shiftKey) {\n return;\n }\n\n // If there is text within the input field, we'll want continue propagating events down\n // to the wrapped collection if there is a focused node so that a user can continue moving the\n // virtual focus. However, if the user doesn't have a focus in the collection, just move the text\n // cursor instead. They can move focus down into the collection via down/up arrow if need be\n if ((e.key === 'ArrowRight' || e.key === 'ArrowLeft') && state.inputValue.length > 0) {\n if (focusedNodeId == null) {\n if (!e.isPropagationStopped()) {\n e.stopPropagation();\n }\n return;\n }\n\n break;\n }\n\n // Prevent these keys from moving the text cursor in the input\n e.preventDefault();\n // Move virtual focus into the wrapped collection\n let focusCollection = new CustomEvent(FOCUS_EVENT, {\n cancelable: true,\n bubbles: true\n });\n\n collectionRef.current?.dispatchEvent(focusCollection);\n break;\n }\n }\n\n // Emulate the keyboard events that happen in the input field in the wrapped collection. This is for triggering things like onAction via Enter\n // or moving focus from one item to another. Stop propagation on the input event if it isn't already stopped so it doesn't leak out. For events\n // like ESC, the dispatched event below will bubble out of the collection and be stopped if handled by useSelectableCollection, otherwise will bubble\n // as expected\n if (!e.isPropagationStopped()) {\n e.stopPropagation();\n }\n\n let shouldPerformDefaultAction = true;\n if (collectionRef.current !== null) {\n if (focusedNodeId == null) {\n shouldPerformDefaultAction =\n collectionRef.current?.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n ) || false;\n } else {\n let item = document.getElementById(focusedNodeId);\n if (item) {\n shouldPerformDefaultAction =\n item?.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)) || false;\n }\n }\n }\n\n if (shouldPerformDefaultAction) {\n switch (e.key) {\n case 'ArrowLeft':\n case 'ArrowRight': {\n // Clear the activedescendant so NVDA announcements aren't interrupted but retain the focused key in the collection so the\n // user's keyboard navigation restarts from where they left off\n clearVirtualFocus();\n break;\n }\n case 'Enter':\n // Trigger click action on item when Enter key was pressed.\n if (focusedNodeId != null) {\n let item = document.getElementById(focusedNodeId);\n item?.dispatchEvent(new PointerEvent('click', e.nativeEvent));\n }\n break;\n }\n } else {\n // TODO: check if we can do this, want to stop textArea from using its default Enter behavior so items are properly triggered\n e.preventDefault();\n }\n };\n\n let onKeyUpCapture = useEffectEvent(e => {\n // Dispatch simulated key up events for things like triggering links in listbox\n // Make sure to stop the propagation of the input keyup event so that the simulated keyup/down pair\n // is detected by usePress instead of the original keyup originating from the input\n if (getEventTarget(e) === keyDownTarget.current) {\n e.stopImmediatePropagation();\n let focusedNodeId = queuedActiveDescendant.current;\n if (focusedNodeId == null) {\n collectionRef.current?.dispatchEvent(new KeyboardEvent(e.type, e));\n } else {\n let item = document.getElementById(focusedNodeId);\n item?.dispatchEvent(new KeyboardEvent(e.type, e));\n }\n }\n });\n\n useEffect(() => {\n document.addEventListener('keyup', onKeyUpCapture, true);\n return () => {\n document.removeEventListener('keyup', onKeyUpCapture, true);\n };\n }, []);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/autocomplete');\n let collectionProps = useLabels({\n id: collectionId,\n 'aria-label': stringFormatter.format('collectionLabel')\n });\n\n let filterFn = useCallback(\n (nodeTextValue: string, node: Node<T>) => {\n if (filter) {\n return filter(nodeTextValue, state.inputValue, node);\n }\n\n return true;\n },\n [state.inputValue, filter]\n );\n\n // Be sure to clear/restore the virtual + collection focus when blurring/refocusing the field so we only show the\n // focus ring on the virtually focused collection when are actually interacting with the Autocomplete\n let onBlur = (e: ReactFocusEvent) => {\n if (!e.isTrusted) {\n return;\n }\n\n let lastFocusedNode = queuedActiveDescendant.current\n ? document.getElementById(queuedActiveDescendant.current)\n : null;\n if (lastFocusedNode) {\n dispatchVirtualBlur(lastFocusedNode, e.relatedTarget);\n }\n };\n\n let onFocus = (e: ReactFocusEvent) => {\n if (!e.isTrusted) {\n return;\n }\n\n let curFocusedNode = queuedActiveDescendant.current\n ? document.getElementById(queuedActiveDescendant.current)\n : null;\n if (curFocusedNode) {\n let target = getEventTarget(e);\n queueMicrotask(() => {\n // instead of focusing the last focused node, just focus the collection instead and have the collection handle what item to focus via useSelectableCollection/Item\n dispatchVirtualBlur(target, collectionRef.current);\n dispatchVirtualFocus(collectionRef.current!, target);\n });\n }\n };\n\n // Clicking back into the input can happen after focus moved elsewhere in the dialog, while\n // virtual focus is still on an option. Clear virtual focus on pointer down so mouse\n // interactions restore the input state before the click's focus handling runs.\n // Touch is excluded because touch interactions should not move focus back to the input.\n let onPointerDown = (e: ReactPointerEvent) => {\n if (\n e.button !== 0 ||\n e.pointerType === 'touch' ||\n queuedActiveDescendant.current == null ||\n inputRef.current == null\n ) {\n return;\n }\n\n if (getEventTarget(e) === inputRef.current) {\n clearVirtualFocus();\n }\n };\n\n // Only apply the autocomplete specific behaviors if the collection component wrapped by it is actually\n // being filtered/allows filtering by the Autocomplete.\n let inputProps = {\n value: state.inputValue,\n onChange\n } as AriaTextFieldProps<FocusableElement>;\n\n let virtualFocusProps = {\n onKeyDown,\n 'aria-activedescendant': state.focusedNodeId ?? undefined,\n onBlur,\n onFocus,\n onPointerDown\n };\n\n if (hasCollection) {\n inputProps = {\n ...inputProps,\n ...(shouldUseVirtualFocus && virtualFocusProps),\n enterKeyHint: 'go',\n 'aria-controls': collectionId,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n // This disable's iOS's autocorrect suggestions, since the autocomplete provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false',\n autoComplete: 'off'\n };\n }\n\n return {\n inputProps,\n collectionProps: mergeProps(collectionProps, {\n shouldUseVirtualFocus,\n disallowTypeAhead: shouldUseVirtualFocus\n }),\n collectionRef: mergedCollectionRef,\n filter: filter != null ? filterFn : undefined\n };\n}\n"],"names":[],"version":3,"file":"useAutocomplete.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;AAoIM,SAAS,0CACd,KAAiC,EACjC,KAAwB;IAExB,IAAI,YACF,QAAQ,iBACR,aAAa,UACb,MAAM,yBACN,wBAAwB,4BACxB,sBAAsB,OACvB,GAAG;IAEJ,IAAI,eAAe,CAAA,GAAA,yCAAI;IACvB,IAAI,UAAU,CAAA,GAAA,aAAK,EAA6C;IAChE,IAAI,4BAA4B,CAAA,GAAA,aAAK,EAAE;IACvC,IAAI,yBAAyB,CAAA,GAAA,aAAK,EAAiB;IAEnD,2HAA2H;IAC3H,uCAAuC;IACvC,IAAI,uBAAuB,CAAA,GAAA,yCAAqB,QAAQ,aAAc,CAAA,CAAA,GAAA,yCAAI,OAAO,CAAA,GAAA,yCAAQ,GAAE;IAC3F,IAAI,CAAC,uBAAuB,yBAAyB,GAAG,CAAA,GAAA,eAAO,EAC7D,CAAC,wBAAwB,CAAC;IAE5B,6IAA6I;IAC7I,iEAAiE;IACjE,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAE;IACjD,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvD,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO,IAAM,aAAa,QAAQ,OAAO;IAC3C,GAAG,EAAE;IAEL,IAAI,8BAA8B,CAAA,GAAA,yCAAa,EAAE,CAAC;QAChD,yEAAyE;QACzE,uFA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QAGF,IAAI,iBAAiB,uBAAuB,OAAO,GAC/C,SAAS,cAAc,CAAC,uBAAuB,OAAO,IACtD;QACJ,IAAI,gBAAgB;YAClB,IAAI,SAAS,CAAA,GAAA,yCAAa,EAAE;YAC5B,eAAe;gBACb,kKAAkK;gBAClK,CAAA,GAAA,yCAAkB,EAAE,QAAQ,cAAc,OAAO;gBACjD,CAAA,GAAA,yCAAmB,EAAE,cAAc,OAAO,EAAG;YAC/C;QACF;IACF;IAEA,2FAA2F;IAC3F,oFAAoF;IACpF,+EAA+E;IAC/E,wFAAwF;IACxF,IAAI,gBAAgB,CAAC;QACnB,IACE,EAAE,MAAM,KAAK,KACb,EAAE,WAAW,KAAK,WAClB,uBAAuB,OAAO,IAAI,QAClC,SAAS,OAAO,IAAI,MAEpB;QAGF,IAAI,CAAA,GAAA,yCAAa,EAAE,OAAO,SAAS,OAAO,EACxC;IAEJ;IAEA,uGAAuG;IACvG,uDAAuD;IACvD,IAAI,aAAa;QACf,OAAO,MAAM,UAAU;kBACvB;IACF;IAEA,IAAI,oBAAoB;mBACtB;QACA,yBAAyB,MAAM,aAAa,IAAI;gBAChD;iBACA;uBACA;IACF;IAEA,aAAa;QACX,GAAG,UAAU;QACb,GAAI,yBAAyB,iBAAiB,iBAAiB;QAC/D,cAAc;QACd,iBAAiB,gBAAgB,eAAe;QAChD,mFAAmF;QACnF,qBAAqB;QACrB,qGAAqG;QACrG,aAAa;QACb,gEAAgE;QAChE,YAAY;QACZ,cAAc;IAChB;IAEA,OAAO;oBACL;QACA,iBAAiB,CAAA,GAAA,yCAAS,EAAE,iBAAiB;mCAC3C;YACA,mBAAmB;YACnB,WAAW,mBAAmB,UAAU;QAC1C;QACA,eAAe;QACf,QAAQ,UAAU,OAAO,WAAW;IACtC;AACF","sources":["packages/react-aria/src/autocomplete/useAutocomplete.ts"],"sourcesContent":["/*\n * Copyright 2024 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 {\n AriaLabelingProps,\n BaseEvent,\n DOMProps,\n FocusableElement,\n FocusEvents,\n KeyboardEvents,\n Node,\n RefObject,\n ValueBase\n} from '@react-types/shared';\nimport {AriaTextFieldProps} from '../textfield/useTextField';\nimport {\n AutocompleteProps,\n AutocompleteState\n} from 'react-stately/private/autocomplete/useAutocompleteState';\nimport {CLEAR_FOCUS_EVENT, FOCUS_EVENT} from '../utils/constants';\nimport {\n dispatchVirtualBlur,\n dispatchVirtualFocus,\n getVirtuallyFocusedElement,\n moveVirtualFocus\n} from '../focus/virtualFocus';\nimport {getActiveElement, getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getInteractionModality, getPointerType} from '../interactions/useFocusVisible';\nimport {getOwnerDocument} from '../utils/domHelpers';\nimport intlMessages from '../../intl/autocomplete/*.json';\nimport {isAndroid, isIOS} from '../utils/platform';\nimport {isCtrlKeyPressed} from '../utils/keyboard';\nimport {mergeProps} from '../utils/mergeProps';\nimport {mergeRefs} from '../utils/mergeRefs';\nimport {\n FocusEvent as ReactFocusEvent,\n KeyboardEvent as ReactKeyboardEvent,\n PointerEvent as ReactPointerEvent,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {useEffectEvent} from '../utils/useEffectEvent';\nimport {useEvent} from '../utils/useEvent';\nimport {useId} from '../utils/useId';\nimport {useLabels} from '../utils/useLabels';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useObjectRef} from '../utils/useObjectRef';\n\nexport interface CollectionOptions extends DOMProps, AriaLabelingProps {\n /** Whether the collection items should use virtual focus instead of being focused directly. */\n shouldUseVirtualFocus: boolean;\n /** Whether typeahead is disabled. */\n disallowTypeAhead: boolean;\n}\n\nexport interface InputProps<T = FocusableElement>\n extends\n DOMProps,\n FocusEvents<T>,\n KeyboardEvents,\n Pick<ValueBase<string>, 'onChange' | 'value'>,\n Pick<\n AriaTextFieldProps,\n | 'enterKeyHint'\n | 'aria-controls'\n | 'aria-autocomplete'\n | 'aria-activedescendant'\n | 'spellCheck'\n | 'autoCorrect'\n | 'autoComplete'\n > {}\n\nexport interface AriaAutocompleteProps<T> extends AutocompleteProps {\n /**\n * An optional filter function used to determine if a option should be included in the\n * autocomplete list. Include this if the items you are providing to your wrapped collection\n * aren't filtered by default.\n */\n filter?: (textValue: string, inputValue: string, node: Node<T>) => boolean;\n\n /**\n * Whether or not to focus the first item in the collection after a filter is performed. Note this\n * is only applicable if virtual focus behavior is not turned off via `disableVirtualFocus`.\n *\n * @default false\n */\n disableAutoFocusFirst?: boolean;\n\n /**\n * Whether the autocomplete should disable virtual focus, instead making the wrapped collection\n * directly tabbable.\n *\n * @default false\n */\n disableVirtualFocus?: boolean;\n}\n\nexport interface AriaAutocompleteOptions<T> extends Omit<AriaAutocompleteProps<T>, 'children'> {\n /** The ref for the wrapped collection element. */\n inputRef: RefObject<HTMLInputElement | null>;\n /** The ref for the wrapped collection element. */\n collectionRef: RefObject<HTMLElement | null>;\n}\n\nexport interface AutocompleteAria<T> {\n /**\n * Props for the autocomplete input element. These should be passed to the input's aria hooks\n * (e.g. useTextField/useSearchField/etc) respectively.\n */\n inputProps: InputProps;\n /** Props for the collection, to be passed to collection's respective aria hook (e.g. useMenu). */\n collectionProps: CollectionOptions;\n /** Ref to attach to the wrapped collection. */\n collectionRef: RefObject<HTMLElement | null>;\n /**\n * A filter function that returns if the provided collection node should be filtered out of the\n * collection.\n */\n filter?: (nodeTextValue: string, node: Node<T>) => boolean;\n}\n\n/**\n * Provides the behavior and accessibility implementation for an autocomplete component. An\n * autocomplete combines a text input with a collection, allowing users to filter the collection's\n * contents match a query.\n *\n * @param props - Props for the autocomplete.\n * @param state - State for the autocomplete, as returned by `useAutocompleteState`.\n */\nexport function useAutocomplete<T>(\n props: AriaAutocompleteOptions<T>,\n state: AutocompleteState\n): AutocompleteAria<T> {\n let {\n inputRef,\n collectionRef,\n filter,\n disableAutoFocusFirst = false,\n disableVirtualFocus = false\n } = props;\n\n let collectionId = useId();\n let timeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let delayNextActiveDescendant = useRef(false);\n let queuedActiveDescendant = useRef<string | null>(null);\n\n // For mobile screen readers, we don't want virtual focus, instead opting to disable FocusScope's restoreFocus and manually\n // moving focus back to the subtriggers\n let isMobileScreenReader = getInteractionModality() === 'virtual' && (isIOS() || isAndroid());\n let [shouldUseVirtualFocus, setShouldUseVirtualFocus] = useState(\n !isMobileScreenReader && !disableVirtualFocus\n );\n // Tracks if a collection has been connected to the autocomplete. If false, we don't want to add various attributes to the autocomplete input\n // since it isn't attached to a filterable collection (e.g. Tabs)\n let [hasCollection, setHasCollection] = useState(false);\n let [autoFocusOnMount, setAutoFocusOnMount] = useState(false);\n\n useEffect(() => {\n return () => clearTimeout(timeout.current);\n }, []);\n\n let updateActiveDescendantEvent = useEffectEvent((e: Event) => {\n // Ensure input is focused if the user clicks on the collection directly.\n // don't trigger on touch so that mobile keyboard doesnt appear when tapping on options\n if (\n !e.isTrusted &&\n shouldUseVirtualFocus &&\n inputRef.current &&\n getActiveElement(getOwnerDocument(inputRef.current)) !== inputRef.current &&\n getPointerType() !== 'touch'\n ) {\n inputRef.current.focus();\n }\n\n let target = getEventTarget(e) as Element | null;\n if (e.isTrusted || !target || queuedActiveDescendant.current === target.id) {\n return;\n }\n\n clearTimeout(timeout.current);\n if (target !== collectionRef.current) {\n if (delayNextActiveDescendant.current) {\n queuedActiveDescendant.current = target.id;\n timeout.current = setTimeout(() => {\n state.setFocusedNodeId(target.id);\n }, 500);\n } else {\n queuedActiveDescendant.current = target.id;\n state.setFocusedNodeId(target.id);\n }\n } else if (\n queuedActiveDescendant.current &&\n !document.getElementById(queuedActiveDescendant.current)\n ) {\n // If we recieve a focus event refocusing the collection, either we have newly refocused the input and are waiting for the\n // wrapped collection to refocus the previously focused node if any OR\n // we are in a state where we've filtered to such a point that there aren't any matching items in the collection to focus.\n // In this case we want to clear tracked item if any and clear active descendant\n queuedActiveDescendant.current = null;\n state.setFocusedNodeId(null);\n }\n\n delayNextActiveDescendant.current = false;\n });\n\n let [collectionNode, setCollectionNode] = useState<HTMLElement | null>(null);\n let callbackRef = useCallback(node => {\n setCollectionNode(node);\n if (node != null) {\n // If useSelectableCollection isn't passed shouldUseVirtualFocus even when useAutocomplete provides it\n // that means the collection doesn't support it (e.g. Table). If that is the case, we need to disable it here regardless\n // of what the user's provided so that the input doesn't recieve the onKeyDown and autocomplete props.\n if (node.getAttribute('tabindex') != null) {\n setShouldUseVirtualFocus(false);\n }\n setHasCollection(true);\n } else {\n setHasCollection(false);\n }\n }, []);\n useLayoutEffect(() => {\n if (collectionNode != null) {\n // When typing forward, we want to delay the setting of active descendant to not interrupt the native screen reader announcement\n // of the letter you just typed. If we recieve another focus event then we clear the queued update\n collectionNode.addEventListener('focusin', updateActiveDescendantEvent);\n }\n return () => {\n collectionNode?.removeEventListener('focusin', updateActiveDescendantEvent);\n };\n }, [collectionNode]);\n\n // Make sure to memo so that React doesn't keep registering a new event listeners on every rerender of the wrapped collection\n let mergedCollectionRef = useObjectRef(\n useMemo(() => mergeRefs(collectionRef, callbackRef), [collectionRef, callbackRef])\n );\n\n let focusFirstItem = useCallback(() => {\n if (!collectionRef.current) {\n setAutoFocusOnMount(true);\n return;\n }\n\n delayNextActiveDescendant.current = true;\n collectionRef.current?.dispatchEvent(\n new CustomEvent(FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: {\n focusStrategy: 'first'\n }\n })\n );\n }, [collectionRef]);\n\n let clearVirtualFocus = useCallback(\n (clearFocusKey?: boolean) => {\n setAutoFocusOnMount(false);\n moveVirtualFocus(getActiveElement());\n queuedActiveDescendant.current = null;\n state.setFocusedNodeId(null);\n let clearFocusEvent = new CustomEvent(CLEAR_FOCUS_EVENT, {\n cancelable: true,\n bubbles: true,\n detail: {\n clearFocusKey\n }\n });\n clearTimeout(timeout.current);\n delayNextActiveDescendant.current = false;\n collectionRef.current?.dispatchEvent(clearFocusEvent);\n },\n [collectionRef, state]\n );\n\n let lastInputType = useRef('');\n useEvent(inputRef, 'beforeinput', e => {\n let {inputType} = e as InputEvent;\n lastInputType.current = inputType;\n });\n\n let onChange = (value: string) => {\n // Tell wrapped collection to focus the first element in the list when typing forward and to clear focused key when modifying the text via\n // copy paste/backspacing/undo/redo for screen reader announcements\n if (\n (lastInputType.current === 'insertText' ||\n // IME composition (e.g. CJK input) reports 'insertCompositionText'/'insertFromComposition'\n // instead of 'insertText'. Treat these as forward typing so the first item gets virtual focus.\n lastInputType.current === 'insertCompositionText' ||\n lastInputType.current === 'insertFromComposition') &&\n !disableAutoFocusFirst\n ) {\n focusFirstItem();\n } else if (\n lastInputType.current &&\n (lastInputType.current.includes('insert') ||\n lastInputType.current.includes('delete') ||\n lastInputType.current.includes('history'))\n ) {\n clearVirtualFocus(true);\n\n // If onChange was triggered before the timeout actually updated the activedescendant, we need to fire\n // our own dispatchVirtualFocus so focusVisible gets reapplied on the input\n if (getVirtuallyFocusedElement(document) === inputRef.current) {\n dispatchVirtualFocus(inputRef.current!, null);\n }\n }\n\n state.setInputValue(value);\n };\n\n let keyDownTarget = useRef<Element | null>(null);\n // For textfield specific keydown operations\n let onKeyDown = (e: BaseEvent<ReactKeyboardEvent<any>>) => {\n keyDownTarget.current = getEventTarget(e) as Element;\n if (e.nativeEvent.isComposing) {\n return;\n }\n\n let focusedNodeId = queuedActiveDescendant.current;\n if (\n focusedNodeId !== null &&\n getOwnerDocument(inputRef.current).getElementById(focusedNodeId) == null\n ) {\n // if the focused id doesn't exist in document, then we need to clear the tracked focused node, otherwise\n // we will be attempting to fire key events on a non-existing node instead of trying to focus the newly swapped wrapped collection.\n // This can happen if you are swapping out the Autocomplete wrapped collection component like in the docs search.\n queuedActiveDescendant.current = null;\n focusedNodeId = null;\n }\n\n switch (e.key) {\n case 'a':\n if (isCtrlKeyPressed(e)) {\n return;\n }\n break;\n case 'Escape':\n // Early return for Escape here so it doesn't leak the Escape event from the simulated collection event below and\n // close the dialog prematurely. Ideally that should be up to the discretion of the input element hence the check\n // for isPropagationStopped\n if (e.isDefaultPrevented()) {\n return;\n }\n break;\n case ' ':\n // Space shouldn't trigger onAction so early return.\n return;\n case 'Tab':\n // Don't propogate Tab down to the collection, otherwise we will try to focus the collection via useSelectableCollection's Tab handler (aka shift tab logic)\n // We want FocusScope to handle Tab if one exists (aka sub dialog), so special casepropogate\n if ('continuePropagation' in e) {\n e.continuePropagation();\n }\n return;\n case 'Home':\n case 'End':\n case 'PageDown':\n case 'PageUp':\n case 'ArrowUp':\n case 'ArrowDown':\n case 'ArrowRight':\n case 'ArrowLeft': {\n if ((e.key === 'Home' || e.key === 'End') && focusedNodeId == null && e.shiftKey) {\n return;\n }\n\n // If there is text within the input field, we'll want continue propagating events down\n // to the wrapped collection if there is a focused node so that a user can continue moving the\n // virtual focus. However, if the user doesn't have a focus in the collection, just move the text\n // cursor instead. They can move focus down into the collection via down/up arrow if need be\n if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {\n if (focusedNodeId == null) {\n if (!e.isPropagationStopped()) {\n e.stopPropagation();\n }\n return;\n }\n\n break;\n }\n\n // Prevent these keys from moving the text cursor in the input\n e.preventDefault();\n // Move virtual focus into the wrapped collection\n let focusCollection = new CustomEvent(FOCUS_EVENT, {\n cancelable: true,\n bubbles: true\n });\n\n collectionRef.current?.dispatchEvent(focusCollection);\n break;\n }\n }\n\n // Emulate the keyboard events that happen in the input field in the wrapped collection. This is for triggering things like onAction via Enter\n // or moving focus from one item to another. Stop propagation on the input event if it isn't already stopped so it doesn't leak out. For events\n // like ESC, the dispatched event below will bubble out of the collection and be stopped if handled by useSelectableCollection, otherwise will bubble\n // as expected\n if (!e.isPropagationStopped()) {\n e.stopPropagation();\n }\n\n let shouldPerformDefaultAction = true;\n if (collectionRef.current !== null) {\n if (focusedNodeId == null) {\n shouldPerformDefaultAction =\n collectionRef.current?.dispatchEvent(\n new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)\n ) || false;\n } else {\n let item = document.getElementById(focusedNodeId);\n if (item) {\n shouldPerformDefaultAction =\n item?.dispatchEvent(new KeyboardEvent(e.nativeEvent.type, e.nativeEvent)) || false;\n }\n }\n }\n\n if (shouldPerformDefaultAction) {\n switch (e.key) {\n case 'ArrowLeft':\n case 'ArrowRight': {\n // Clear the activedescendant so NVDA announcements aren't interrupted but retain the focused key in the collection so the\n // user's keyboard navigation restarts from where they left off\n clearVirtualFocus();\n break;\n }\n case 'Enter':\n // Trigger click action on item when Enter key was pressed.\n if (focusedNodeId != null) {\n let item = document.getElementById(focusedNodeId);\n item?.dispatchEvent(new PointerEvent('click', e.nativeEvent));\n }\n break;\n }\n } else {\n // TODO: check if we can do this, want to stop textArea from using its default Enter behavior so items are properly triggered\n e.preventDefault();\n }\n };\n\n let onKeyUpCapture = useEffectEvent(e => {\n // Dispatch simulated key up events for things like triggering links in listbox\n // Make sure to stop the propagation of the input keyup event so that the simulated keyup/down pair\n // is detected by usePress instead of the original keyup originating from the input\n if (getEventTarget(e) === keyDownTarget.current) {\n e.stopImmediatePropagation();\n let focusedNodeId = queuedActiveDescendant.current;\n if (focusedNodeId == null) {\n collectionRef.current?.dispatchEvent(new KeyboardEvent(e.type, e));\n } else {\n let item = document.getElementById(focusedNodeId);\n item?.dispatchEvent(new KeyboardEvent(e.type, e));\n }\n }\n });\n\n useEffect(() => {\n document.addEventListener('keyup', onKeyUpCapture, true);\n return () => {\n document.removeEventListener('keyup', onKeyUpCapture, true);\n };\n }, []);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/autocomplete');\n let collectionProps = useLabels({\n id: collectionId,\n 'aria-label': stringFormatter.format('collectionLabel')\n });\n\n let filterFn = useCallback(\n (nodeTextValue: string, node: Node<T>) => {\n if (filter) {\n return filter(nodeTextValue, state.inputValue, node);\n }\n\n return true;\n },\n [state.inputValue, filter]\n );\n\n // Be sure to clear/restore the virtual + collection focus when blurring/refocusing the field so we only show the\n // focus ring on the virtually focused collection when are actually interacting with the Autocomplete\n let onBlur = (e: ReactFocusEvent) => {\n if (!e.isTrusted) {\n return;\n }\n\n let lastFocusedNode = queuedActiveDescendant.current\n ? document.getElementById(queuedActiveDescendant.current)\n : null;\n if (lastFocusedNode) {\n dispatchVirtualBlur(lastFocusedNode, e.relatedTarget);\n }\n };\n\n let onFocus = (e: ReactFocusEvent) => {\n if (!e.isTrusted) {\n return;\n }\n\n let curFocusedNode = queuedActiveDescendant.current\n ? document.getElementById(queuedActiveDescendant.current)\n : null;\n if (curFocusedNode) {\n let target = getEventTarget(e);\n queueMicrotask(() => {\n // instead of focusing the last focused node, just focus the collection instead and have the collection handle what item to focus via useSelectableCollection/Item\n dispatchVirtualBlur(target, collectionRef.current);\n dispatchVirtualFocus(collectionRef.current!, target);\n });\n }\n };\n\n // Clicking back into the input can happen after focus moved elsewhere in the dialog, while\n // virtual focus is still on an option. Clear virtual focus on pointer down so mouse\n // interactions restore the input state before the click's focus handling runs.\n // Touch is excluded because touch interactions should not move focus back to the input.\n let onPointerDown = (e: ReactPointerEvent) => {\n if (\n e.button !== 0 ||\n e.pointerType === 'touch' ||\n queuedActiveDescendant.current == null ||\n inputRef.current == null\n ) {\n return;\n }\n\n if (getEventTarget(e) === inputRef.current) {\n clearVirtualFocus();\n }\n };\n\n // Only apply the autocomplete specific behaviors if the collection component wrapped by it is actually\n // being filtered/allows filtering by the Autocomplete.\n let inputProps = {\n value: state.inputValue,\n onChange\n } as AriaTextFieldProps<FocusableElement>;\n\n let virtualFocusProps = {\n onKeyDown,\n 'aria-activedescendant': state.focusedNodeId ?? undefined,\n onBlur,\n onFocus,\n onPointerDown\n };\n\n inputProps = {\n ...inputProps,\n ...(shouldUseVirtualFocus && hasCollection && virtualFocusProps),\n enterKeyHint: 'go',\n 'aria-controls': hasCollection ? collectionId : undefined,\n // TODO: readd proper logic for completionMode = complete (aria-autocomplete: both)\n 'aria-autocomplete': 'list',\n // This disable's iOS's autocorrect suggestions, since the autocomplete provides its own suggestions.\n autoCorrect: 'off',\n // This disable's the macOS Safari spell check auto corrections.\n spellCheck: 'false',\n autoComplete: 'off'\n };\n\n return {\n inputProps,\n collectionProps: mergeProps(collectionProps, {\n shouldUseVirtualFocus,\n disallowTypeAhead: shouldUseVirtualFocus,\n autoFocus: autoFocusOnMount ? 'first' : false\n }),\n collectionRef: mergedCollectionRef,\n filter: filter != null ? filterFn : undefined\n };\n}\n"],"names":[],"version":3,"file":"useAutocomplete.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAmBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,cAAc,SAAS,EAAE,GAAG,YAAW,GAAG;IAE/C,IAAI,UAAU,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IACxD,OAAO;QACL,UAAU;YACR,GAAG,CAAA,GAAA,wCAAa,EAAE,YAAY;gBAAC,WAAW;YAAI,EAAE;YAChD,cAAc,aAAa,QAAQ,MAAM,CAAC;QAC5C;IACF;AACF","sources":["packages/react-aria/src/breadcrumbs/useBreadcrumbs.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 {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\n// @ts-ignore\nimport intlMessages from '../../intl/breadcrumbs/*.json';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaBreadcrumbsProps extends DOMProps, AriaLabelingProps {}\n\nexport interface BreadcrumbsAria {\n /** Props for the breadcrumbs navigation element. */\n navProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a breadcrumbs component.\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nexport function useBreadcrumbs(props: AriaBreadcrumbsProps): BreadcrumbsAria {\n let {'aria-label': ariaLabel, ...otherProps} = props;\n\n let strings = useLocalizedStringFormatter(intlMessages, '@react-aria/breadcrumbs');\n return {\n navProps: {\n ...filterDOMProps(otherProps, {labelable: true}),\n 'aria-label': ariaLabel || strings.format('breadcrumbs')\n }\n };\n}\n"],"names":[],"version":3,"file":"useBreadcrumbs.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,cAAc,SAAS,EAAE,GAAG,YAAW,GAAG;IAE/C,IAAI,UAAU,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IACxD,OAAO;QACL,UAAU;YACR,GAAG,CAAA,GAAA,wCAAa,EAAE,YAAY;gBAAC,WAAW;YAAI,EAAE;YAChD,cAAc,aAAa,QAAQ,MAAM,CAAC;QAC5C;IACF;AACF","sources":["packages/react-aria/src/breadcrumbs/useBreadcrumbs.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 {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport intlMessages from '../../intl/breadcrumbs/*.json';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaBreadcrumbsProps extends DOMProps, AriaLabelingProps {}\n\nexport interface BreadcrumbsAria {\n /** Props for the breadcrumbs navigation element. */\n navProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a breadcrumbs component.\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nexport function useBreadcrumbs(props: AriaBreadcrumbsProps): BreadcrumbsAria {\n let {'aria-label': ariaLabel, ...otherProps} = props;\n\n let strings = useLocalizedStringFormatter(intlMessages, '@react-aria/breadcrumbs');\n return {\n navProps: {\n ...filterDOMProps(otherProps, {labelable: true}),\n 'aria-label': ariaLabel || strings.format('breadcrumbs')\n }\n };\n}\n"],"names":[],"version":3,"file":"useBreadcrumbs.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAmBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,cAAc,SAAS,EAAE,GAAG,YAAW,GAAG;IAE/C,IAAI,UAAU,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IACxD,OAAO;QACL,UAAU;YACR,GAAG,CAAA,GAAA,yCAAa,EAAE,YAAY;gBAAC,WAAW;YAAI,EAAE;YAChD,cAAc,aAAa,QAAQ,MAAM,CAAC;QAC5C;IACF;AACF","sources":["packages/react-aria/src/breadcrumbs/useBreadcrumbs.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 {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\n// @ts-ignore\nimport intlMessages from '../../intl/breadcrumbs/*.json';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaBreadcrumbsProps extends DOMProps, AriaLabelingProps {}\n\nexport interface BreadcrumbsAria {\n /** Props for the breadcrumbs navigation element. */\n navProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a breadcrumbs component.\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nexport function useBreadcrumbs(props: AriaBreadcrumbsProps): BreadcrumbsAria {\n let {'aria-label': ariaLabel, ...otherProps} = props;\n\n let strings = useLocalizedStringFormatter(intlMessages, '@react-aria/breadcrumbs');\n return {\n navProps: {\n ...filterDOMProps(otherProps, {labelable: true}),\n 'aria-label': ariaLabel || strings.format('breadcrumbs')\n }\n };\n}\n"],"names":[],"version":3,"file":"useBreadcrumbs.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,cAAc,SAAS,EAAE,GAAG,YAAW,GAAG;IAE/C,IAAI,UAAU,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IACxD,OAAO;QACL,UAAU;YACR,GAAG,CAAA,GAAA,yCAAa,EAAE,YAAY;gBAAC,WAAW;YAAI,EAAE;YAChD,cAAc,aAAa,QAAQ,MAAM,CAAC;QAC5C;IACF;AACF","sources":["packages/react-aria/src/breadcrumbs/useBreadcrumbs.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 {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport intlMessages from '../../intl/breadcrumbs/*.json';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaBreadcrumbsProps extends DOMProps, AriaLabelingProps {}\n\nexport interface BreadcrumbsAria {\n /** Props for the breadcrumbs navigation element. */\n navProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a breadcrumbs component.\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nexport function useBreadcrumbs(props: AriaBreadcrumbsProps): BreadcrumbsAria {\n let {'aria-label': ariaLabel, ...otherProps} = props;\n\n let strings = useLocalizedStringFormatter(intlMessages, '@react-aria/breadcrumbs');\n return {\n navProps: {\n ...filterDOMProps(otherProps, {labelable: true}),\n 'aria-label': ariaLabel || strings.format('breadcrumbs')\n }\n };\n}\n"],"names":[],"version":3,"file":"useBreadcrumbs.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAmBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,cAAc,SAAS,EAAE,GAAG,YAAW,GAAG;IAE/C,IAAI,UAAU,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IACxD,OAAO;QACL,UAAU;YACR,GAAG,CAAA,GAAA,yCAAa,EAAE,YAAY;gBAAC,WAAW;YAAI,EAAE;YAChD,cAAc,aAAa,QAAQ,MAAM,CAAC;QAC5C;IACF;AACF","sources":["packages/react-aria/src/breadcrumbs/useBreadcrumbs.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 {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\n// @ts-ignore\nimport intlMessages from '../../intl/breadcrumbs/*.json';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaBreadcrumbsProps extends DOMProps, AriaLabelingProps {}\n\nexport interface BreadcrumbsAria {\n /** Props for the breadcrumbs navigation element. */\n navProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a breadcrumbs component.\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nexport function useBreadcrumbs(props: AriaBreadcrumbsProps): BreadcrumbsAria {\n let {'aria-label': ariaLabel, ...otherProps} = props;\n\n let strings = useLocalizedStringFormatter(intlMessages, '@react-aria/breadcrumbs');\n return {\n navProps: {\n ...filterDOMProps(otherProps, {labelable: true}),\n 'aria-label': ariaLabel || strings.format('breadcrumbs')\n }\n };\n}\n"],"names":[],"version":3,"file":"useBreadcrumbs.mjs.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkBM,SAAS,0CAAe,KAA2B;IACxD,IAAI,EAAC,cAAc,SAAS,EAAE,GAAG,YAAW,GAAG;IAE/C,IAAI,UAAU,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IACxD,OAAO;QACL,UAAU;YACR,GAAG,CAAA,GAAA,yCAAa,EAAE,YAAY;gBAAC,WAAW;YAAI,EAAE;YAChD,cAAc,aAAa,QAAQ,MAAM,CAAC;QAC5C;IACF;AACF","sources":["packages/react-aria/src/breadcrumbs/useBreadcrumbs.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 {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport intlMessages from '../../intl/breadcrumbs/*.json';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaBreadcrumbsProps extends DOMProps, AriaLabelingProps {}\n\nexport interface BreadcrumbsAria {\n /** Props for the breadcrumbs navigation element. */\n navProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a breadcrumbs component.\n * Breadcrumbs display a hierarchy of links to the current page or resource in an application.\n */\nexport function useBreadcrumbs(props: AriaBreadcrumbsProps): BreadcrumbsAria {\n let {'aria-label': ariaLabel, ...otherProps} = props;\n\n let strings = useLocalizedStringFormatter(intlMessages, '@react-aria/breadcrumbs');\n return {\n navProps: {\n ...filterDOMProps(otherProps, {labelable: true}),\n 'aria-label': ariaLabel || strings.format('breadcrumbs')\n }\n };\n}\n"],"names":[],"version":3,"file":"useBreadcrumbs.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAmCM,SAAS,0CACd,KAAuD,EACvD,KAAgE;IAEhE,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,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9E,IAAI,oBAAoB,iBAAiB;QACvC,mBAAmB;QACnB,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,aAAa,CAAA,GAAA,mCAAQ,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK;QACf,cAAc;YAAC,KAAK,CAAC,aAAa;YAAE;SAAwB,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QAClF,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,oCAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,gBAAgB,KAAK,CAAC,eAAe,IAAI;YACzC,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarBase.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 {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {\n CalendarPropsBase,\n CalendarSelectionMode,\n CalendarState\n} from 'react-stately/useCalendarState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\n// @ts-ignore\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSlotId} from '../utils/useId';\nimport {useState} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes;\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps;\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps;\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes;\n /** A description of the visible date range, for use in the calendar title. */\n title: string;\n}\n\nexport function useCalendarBase(\n props: CalendarPropsBase & DOMProps & AriaLabelingProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState\n): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n false\n );\n let visibleRangeDescription = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n true\n );\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([\n Boolean(props.errorMessage),\n props.isInvalid,\n props.validationState\n ]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAkCM,SAAS,0CACd,KAAuD,EACvD,KAAgE;IAEhE,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,wCAAa,EAAE;IAE9B,IAAI,QAAQ,CAAA,GAAA,oDAAyB,EACnC,MAAM,YAAY,CAAC,KAAK,EACxB,MAAM,YAAY,CAAC,GAAG,EACtB,MAAM,QAAQ,EACd;IAEF,IAAI,0BAA0B,CAAA,GAAA,oDAAyB,EACrD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C;QAClF,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,oCAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,gBAAgB,KAAK,CAAC,eAAe,IAAI;YACzC,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarBase.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 {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {\n CalendarPropsBase,\n CalendarSelectionMode,\n CalendarState\n} from 'react-stately/useCalendarState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSlotId} from '../utils/useId';\nimport {useState} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes;\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps;\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps;\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes;\n /** A description of the visible date range, for use in the calendar title. */\n title: string;\n}\n\nexport function useCalendarBase(\n props: CalendarPropsBase & DOMProps & AriaLabelingProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState\n): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n false\n );\n let visibleRangeDescription = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n true\n );\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([\n Boolean(props.errorMessage),\n props.isInvalid,\n props.validationState\n ]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAmCM,SAAS,0CACd,KAAuD,EACvD,KAAgE;IAEhE,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE;IAE9B,IAAI,QAAQ,CAAA,GAAA,wCAAyB,EACnC,MAAM,YAAY,CAAC,KAAK,EACxB,MAAM,YAAY,CAAC,GAAG,EACtB,MAAM,QAAQ,EACd;IAEF,IAAI,0BAA0B,CAAA,GAAA,wCAAyB,EACrD,MAAM,YAAY,CAAC,KAAK,EACxB,MAAM,YAAY,CAAC,GAAG,EACtB,MAAM,QAAQ,EACd;IAGF,+CAA+C;IAC/C,CAAA,GAAA,yCAAc,EAAE;QACd,iDAAiD;QACjD,IAAI,CAAC,MAAM,SAAS,EAClB,CAAA,GAAA,yCAAO,EAAE;IAEb,GAAG;QAAC;KAAwB;IAE5B,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M,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarBase.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 {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {\n CalendarPropsBase,\n CalendarSelectionMode,\n CalendarState\n} from 'react-stately/useCalendarState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\n// @ts-ignore\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSlotId} from '../utils/useId';\nimport {useState} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes;\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps;\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps;\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes;\n /** A description of the visible date range, for use in the calendar title. */\n title: string;\n}\n\nexport function useCalendarBase(\n props: CalendarPropsBase & DOMProps & AriaLabelingProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState\n): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n false\n );\n let visibleRangeDescription = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n true\n );\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([\n Boolean(props.errorMessage),\n props.isInvalid,\n props.validationState\n ]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAkCM,SAAS,0CACd,KAAuD,EACvD,KAAgE;IAEhE,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE;IAE9B,IAAI,QAAQ,CAAA,GAAA,wCAAyB,EACnC,MAAM,YAAY,CAAC,KAAK,EACxB,MAAM,YAAY,CAAC,GAAG,EACtB,MAAM,QAAQ,EACd;IAEF,IAAI,0BAA0B,CAAA,GAAA,wCAAyB,EACrD,MAAM,YAAY,CAAC,KAAK,EACxB,MAAM,YAAY,CAAC,GAAG,EACtB,MAAM,QAAQ,EACd;IAGF,+CAA+C;IAC/C,CAAA,GAAA,yCAAc,EAAE;QACd,iDAAiD;QACjD,IAAI,CAAC,MAAM,SAAS,EAClB,CAAA,GAAA,yCAAO,EAAE;IAEb,GAAG;QAAC;KAAwB;IAE5B,2CAA2C;IAC3C,IAAI,0BAA0B,CAAA,GAAA,yCAAyB,EAAE;IACzD,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,yBACF,CAAA,GAAA,yCAAO,EAAE,yBAAyB,UAAU;IAE9C,yGAAyG;IAC3G,GAAG;QAAC;KAAwB;IAE5B,IAAI,iBAAiB,CAAA,GAAA,yCAAQ,EAAE;QAC7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calendar/useCalendarBase.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 {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {\n CalendarPropsBase,\n CalendarSelectionMode,\n CalendarState\n} from 'react-stately/useCalendarState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSlotId} from '../utils/useId';\nimport {useState} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes;\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps;\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps;\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes;\n /** A description of the visible date range, for use in the calendar title. */\n title: string;\n}\n\nexport function useCalendarBase(\n props: CalendarPropsBase & DOMProps & AriaLabelingProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState\n): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n false\n );\n let visibleRangeDescription = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n true\n );\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([\n Boolean(props.errorMessage),\n props.isInvalid,\n props.validationState\n ]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAmCM,SAAS,0CACd,KAAuD,EACvD,KAAgE;IAEhE,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE;IAE9B,IAAI,QAAQ,CAAA,GAAA,wCAAyB,EACnC,MAAM,YAAY,CAAC,KAAK,EACxB,MAAM,YAAY,CAAC,GAAG,EACtB,MAAM,QAAQ,EACd;IAEF,IAAI,0BAA0B,CAAA,GAAA,wCAAyB,EACrD,MAAM,YAAY,CAAC,KAAK,EACxB,MAAM,YAAY,CAAC,GAAG,EACtB,MAAM,QAAQ,EACd;IAGF,+CAA+C;IAC/C,CAAA,GAAA,yCAAc,EAAE;QACd,iDAAiD;QACjD,IAAI,CAAC,MAAM,SAAS,EAClB,CAAA,GAAA,yCAAO,EAAE;IAEb,GAAG;QAAC;KAAwB;IAE5B,2CAA2C;IAC3C,IAAI,0BAA0B,CAAA,GAAA,yCAAyB,EAAE;IACzD,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,yBACF,CAAA,GAAA,yCAAO,EAAE,yBAAyB,UAAU;IAE9C,yGAAyG;IAC3G,GAAG;QAAC;KAAwB;IAE5B,IAAI,iBAAiB,CAAA,GAAA,yCAAQ,EAAE;QAC7B,QAAQ,MAAM,YAAY;QAC1B,MAAM,SAAS;QACf,MAAM,eAAe;KACtB;IAED,6CAA6C;IAC7C,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC,OAAO;QAClB,WAAW,KAAK,CAAC,aAAa;QAC9B,gBAAgB,KAAK,CAAC,kBAAkB;wBACxC;iCACA;IACF;IAEA,2GAA2G;IAC3G,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE;IAC7C,IAAI,eAAe,MAAM,UAAU,IAAI,MAAM,yBAAyB;IACtE,IAAI,gBAAgB,aAAa;QAC/B,eAAe;QACf,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,CAAC,iBAAiB,mBAAmB,GAAG,CAAA,GAAA,eAAO,EAAE;IACrD,IAAI,mBAAmB,MAAM,UAAU,IAAI,MAAM,6BAA6B;IAC9E,IAAI,oBAAoB,iBAAiB;QACvC,mBAAmB;QACnB,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,aAAa,CAAA,GAAA,yCAAQ,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK;QACf,cAAc;YAAC,KAAK,CAAC,aAAa;YAAE;SAAwB,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QAClF,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,yCAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,gBAAgB,KAAK,CAAC,eAAe,IAAI;YACzC,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarBase.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 {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {\n CalendarPropsBase,\n CalendarSelectionMode,\n CalendarState\n} from 'react-stately/useCalendarState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\n// @ts-ignore\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSlotId} from '../utils/useId';\nimport {useState} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes;\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps;\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps;\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes;\n /** A description of the visible date range, for use in the calendar title. */\n title: string;\n}\n\nexport function useCalendarBase(\n props: CalendarPropsBase & DOMProps & AriaLabelingProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState\n): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n false\n );\n let visibleRangeDescription = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n true\n );\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([\n Boolean(props.errorMessage),\n props.isInvalid,\n props.validationState\n ]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;AAkCM,SAAS,0CACd,KAAuD,EACvD,KAAgE;IAE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rD,IAAI,mBAAmB,MAAM,UAAU,IAAI,MAAM,6BAA6B;IAC9E,IAAI,oBAAoB,iBAAiB;QACvC,mBAAmB;QACnB,MAAM,UAAU,CAAC;IACnB;IAEA,IAAI,aAAa,CAAA,GAAA,yCAAQ,EAAE;QACzB,IAAI,KAAK,CAAC,KAAK;QACf,cAAc;YAAC,KAAK,CAAC,aAAa;YAAE;SAAwB,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QAClF,mBAAmB,KAAK,CAAC,kBAAkB;IAC7C;IAEA,OAAO;QACL,eAAe,CAAA,GAAA,yCAAS,EAAE,UAAU,YAAY;YAC9C,MAAM;YACN,gBAAgB,KAAK,CAAC,eAAe,IAAI;YACzC,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;QACnD;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,aAAa;YAClC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,iBAAiB;YACf,SAAS,IAAM,MAAM,iBAAiB;YACtC,cAAc,gBAAgB,MAAM,CAAC;YACrC,YAAY;YACZ,eAAe;QACjB;QACA,mBAAmB;YACjB,IAAI;QACN;eACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarBase.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 {announce} from '../live-announcer/LiveAnnouncer';\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaLabelingProps, DOMAttributes, DOMProps} from '@react-types/shared';\nimport {\n CalendarPropsBase,\n CalendarSelectionMode,\n CalendarState\n} from 'react-stately/useCalendarState';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {hookData, useSelectedDateDescription, useVisibleRangeDescription} from './utils';\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {useLabels} from '../utils/useLabels';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useSlotId} from '../utils/useId';\nimport {useState} from 'react';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface CalendarAria {\n /** Props for the calendar grouping element. */\n calendarProps: DOMAttributes;\n /** Props for the next button. */\n nextButtonProps: AriaButtonProps;\n /** Props for the previous button. */\n prevButtonProps: AriaButtonProps;\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes;\n /** A description of the visible date range, for use in the calendar title. */\n title: string;\n}\n\nexport function useCalendarBase(\n props: CalendarPropsBase & DOMProps & AriaLabelingProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState\n): CalendarAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let domProps = filterDOMProps(props);\n\n let title = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n false\n );\n let visibleRangeDescription = useVisibleRangeDescription(\n state.visibleRange.start,\n state.visibleRange.end,\n state.timeZone,\n true\n );\n\n // Announce when the visible date range changes\n useUpdateEffect(() => {\n // only when pressing the Previous or Next button\n if (!state.isFocused) {\n announce(visibleRangeDescription);\n }\n }, [visibleRangeDescription]);\n\n // Announce when the selected value changes\n let selectedDateDescription = useSelectedDateDescription(state);\n useUpdateEffect(() => {\n if (selectedDateDescription) {\n announce(selectedDateDescription, 'polite', 4000);\n }\n // handle an update to the caption that describes the currently selected range, to announce the new value\n }, [selectedDateDescription]);\n\n let errorMessageId = useSlotId([\n Boolean(props.errorMessage),\n props.isInvalid,\n props.validationState\n ]);\n\n // Pass the label to the child grid elements.\n hookData.set(state, {\n ariaLabel: props['aria-label'],\n ariaLabelledBy: props['aria-labelledby'],\n errorMessageId,\n selectedDateDescription\n });\n\n // If the next or previous buttons become disabled while they are focused, move focus to the calendar body.\n let [nextFocused, setNextFocused] = useState(false);\n let nextDisabled = props.isDisabled || state.isNextVisibleRangeInvalid();\n if (nextDisabled && nextFocused) {\n setNextFocused(false);\n state.setFocused(true);\n }\n\n let [previousFocused, setPreviousFocused] = useState(false);\n let previousDisabled = props.isDisabled || state.isPreviousVisibleRangeInvalid();\n if (previousDisabled && previousFocused) {\n setPreviousFocused(false);\n state.setFocused(true);\n }\n\n let labelProps = useLabels({\n id: props['id'],\n 'aria-label': [props['aria-label'], visibleRangeDescription].filter(Boolean).join(', '),\n 'aria-labelledby': props['aria-labelledby']\n });\n\n return {\n calendarProps: mergeProps(domProps, labelProps, {\n role: 'application',\n 'aria-details': props['aria-details'] || undefined,\n 'aria-describedby': props['aria-describedby'] || undefined\n }),\n nextButtonProps: {\n onPress: () => state.focusNextPage(),\n 'aria-label': stringFormatter.format('next'),\n isDisabled: nextDisabled,\n onFocusChange: setNextFocused\n },\n prevButtonProps: {\n onPress: () => state.focusPreviousPage(),\n 'aria-label': stringFormatter.format('previous'),\n isDisabled: previousDisabled,\n onFocusChange: setPreviousFocused\n },\n errorMessageProps: {\n id: errorMessageId\n },\n title\n };\n}\n"],"names":[],"version":3,"file":"useCalendarBase.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA+EM,SAAS,0CACd,KAA4B,EAC5B,KAAgE,EAChE,GAAkC;IAElC,IAAI,QAAC,IAAI,cAAE,UAAU,EAAC,GAAG;IACzB,IAAI,kBAAC,cAAc,2BAAE,uBAAuB,EAAC,GAAG,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC;IAC7D,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,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,CAC3E,MAAM,CAAC,SACP,IAAI,CAAC,QAAQ;YAClB,gBAAe,CAAC;gBACd,0EAA0E;gBAC1E,IACE,mBAAmB,SAClB,CAAA,EAAE,WAAW,KAAK,WAAW,MAAM,UAAU,AAAD,KAC7C,cAEA,MAAM,aAAa,CAAC;YAExB;YACA,eAAc,CAAe;gBAC3B,uDAAuD;gBACvD,wCAAwC;gBACxC,gCAAgC;gBAChC,IAAI,SAAS,CAAA,GAAA,wCAAa,EAAE;gBAC5B,IAAI,kBAAkB,eAAe,2BAA2B,QAAQ;oBACtE,IAAI,uBAAuB,QACzB;wBAAA,IAAI,OAAO,iBAAiB,CAAC,EAAE,SAAS,GACtC,OAAO,qBAAqB,CAAC,EAAE,SAAS;oBAC1C,OAEA,AAAC,OAAuB,qBAAqB,CAAC,EAAE,SAAS;gBAE7D;YACF;YACA,eAAc,CAAC;gBACb,sCAAsC;gBACtC,EAAE,cAAc;YAClB;QACF;mBACA;mBACA;oBACA;oBACA;uBACA;QACA,uBACE,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,GAAG,IAAI;mBACvF;uBACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarCell.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, isEqualDay, isSameDay, isToday} from '@internationalized/date';\nimport {CalendarSelectionMode, CalendarState} from 'react-stately/useCalendarState';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getActiveElement, getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getEraFormat, hookData} from './utils';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport {getScrollParent} from '../utils/getScrollParent';\n// @ts-ignore\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {useDateFormatter} from '../i18n/useDateFormatter';\nimport {useDeepMemo} from '../utils/useDeepMemo';\nimport {useDescription} from '../utils/useDescription';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {usePress} from '../interactions/usePress';\n\nexport interface AriaCalendarCellProps {\n /** The date that this cell represents. */\n date: CalendarDate;\n /**\n * Whether the cell is disabled. By default, this is determined by the\n * Calendar's `minValue`, `maxValue`, and `isDisabled` props.\n */\n isDisabled?: boolean;\n\n /**\n * Whether the cell is outside of the current month.\n */\n isOutsideMonth?: boolean;\n}\n\nexport interface CalendarCellAria {\n /** Props for the grid cell element (e.g. `<td>`). */\n cellProps: DOMAttributes;\n /** Props for the button element within the cell. */\n buttonProps: DOMAttributes;\n /** Whether the cell is currently being pressed. */\n isPressed: boolean;\n /** Whether the cell is selected. */\n isSelected: boolean;\n /** Whether the cell is focused. */\n isFocused: boolean;\n /**\n * Whether the cell is disabled, according to the calendar's `minValue`, `maxValue`, and\n * `isDisabled` props. Disabled dates are not focusable, and cannot be selected by the user. They\n * are typically displayed with a dimmed appearance.\n */\n isDisabled: boolean;\n /**\n * Whether the cell is unavailable, according to the calendar's `isDateUnavailable` prop.\n * Unavailable dates remain focusable, but cannot be selected by the user. They should be\n * displayed with a visual affordance to indicate they are unavailable, such as a different color\n * or a strikethrough.\n *\n * Note that because they are focusable, unavailable dates must meet a 4.5:1 color contrast ratio,\n * [as defined by WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).\n */\n isUnavailable: boolean;\n /**\n * Whether the cell is outside the visible range of the calendar.\n * For example, dates before the first day of a month in the same week.\n */\n isOutsideVisibleRange: boolean;\n /** Whether the cell is part of an invalid selection. */\n isInvalid: boolean;\n /** The day number formatted according to the current locale. */\n formattedDate: string;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar cell component.\n * A calendar cell displays a date cell within a calendar grid which can be selected by the user.\n */\nexport function useCalendarCell(\n props: AriaCalendarCellProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState,\n ref: RefObject<HTMLElement | null>\n): CalendarCellAria {\n let {date, isDisabled} = props;\n let {errorMessageId, selectedDateDescription} = hookData.get(state)!;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n era: getEraFormat(date),\n timeZone: state.timeZone\n });\n let isFocused = state.isCellFocused(date) && !props.isOutsideMonth;\n isDisabled = isDisabled || state.isCellDisabled(date) || !!props.isOutsideMonth;\n let isUnavailable = state.isCellUnavailable(date);\n let isSelectable = !isDisabled && !isUnavailable;\n let isSelected = state.isSelected(date) && isSelectable;\n let isInvalid = false;\n if (state.isValueInvalid) {\n if ('highlightedRange' in state) {\n isInvalid =\n !state.anchorDate &&\n state.highlightedRange != null &&\n date.compare(state.highlightedRange.start) >= 0 &&\n date.compare(state.highlightedRange.end) <= 0;\n } else if (Array.isArray(state.value)) {\n isInvalid = state.value.some(value => isSameDay(value, date));\n } else if (state.value) {\n isInvalid = isSameDay(state.value as CalendarDate, date);\n }\n }\n\n if (isInvalid && !isDisabled) {\n isSelected = true;\n }\n\n // For performance, reuse the same date object as before if the new date prop is the same.\n // This allows subsequent useMemo results to be reused.\n date = useDeepMemo<CalendarDate>(date, isEqualDay);\n let nativeDate = useMemo(() => date.toDate(state.timeZone), [date, state.timeZone]);\n\n // aria-label should be localize Day of week, Month, Day and Year without Time.\n let isDateToday = isToday(date, state.timeZone);\n let label = useMemo(() => {\n let label = '';\n\n // If this is a range calendar, add a description of the full selected range\n // to the first and last selected date.\n if (\n 'highlightedRange' in state &&\n state.value &&\n !state.anchorDate &&\n (isSameDay(date, state.value.start) || isSameDay(date, state.value.end))\n ) {\n label = selectedDateDescription + ', ';\n }\n\n label += dateFormatter.format(nativeDate);\n if (isDateToday) {\n // If date is today, set appropriate string depending on selected state:\n label = stringFormatter.format(isSelected ? 'todayDateSelected' : 'todayDate', {\n date: label\n });\n } else if (isSelected) {\n // If date is selected but not today:\n label = stringFormatter.format('dateSelected', {\n date: label\n });\n }\n\n if (state.minValue && isSameDay(date, state.minValue)) {\n label += ', ' + stringFormatter.format('minimumDate');\n } else if (state.maxValue && isSameDay(date, state.maxValue)) {\n label += ', ' + stringFormatter.format('maximumDate');\n }\n\n return label;\n }, [\n dateFormatter,\n nativeDate,\n stringFormatter,\n isSelected,\n isDateToday,\n date,\n state,\n selectedDateDescription\n ]);\n\n // When a cell is focused and this is a range calendar, add a prompt to help\n // screenreader users know that they are in a range selection mode.\n let rangeSelectionPrompt = '';\n if ('anchorDate' in state && isFocused && !state.isReadOnly && isSelectable) {\n // If selection has started add \"click to finish selecting range\"\n if (state.anchorDate) {\n rangeSelectionPrompt = stringFormatter.format('finishRangeSelectionPrompt');\n // Otherwise, add \"click to start selecting range\" prompt\n } else {\n rangeSelectionPrompt = stringFormatter.format('startRangeSelectionPrompt');\n }\n }\n\n let descriptionProps = useDescription(rangeSelectionPrompt);\n\n let isAnchorPressed = useRef(false);\n let isRangeBoundaryPressed = useRef(false);\n let touchDragTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let {pressProps, isPressed} = usePress({\n // When dragging to select a range, we don't want dragging over the original anchor\n // again to trigger onPressStart. Cancel presses immediately when the pointer exits.\n shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,\n preventFocusOnPress: true,\n isDisabled: !isSelectable || state.isReadOnly,\n onPressStart(e) {\n if (state.isReadOnly) {\n state.setFocusedDate(date);\n state.setFocused(true);\n return;\n }\n\n if (\n 'highlightedRange' in state &&\n !state.anchorDate &&\n (e.pointerType === 'mouse' || e.pointerType === 'touch')\n ) {\n // Allow dragging the start or end date of a range to modify it\n // rather than starting a new selection.\n // Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges\n // are constrained to available dates. The user will need to select a new range in this case.\n if (state.highlightedRange && !isInvalid) {\n if (isSameDay(date, state.highlightedRange.start)) {\n state.setAnchorDate(state.highlightedRange.end);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n } else if (isSameDay(date, state.highlightedRange.end)) {\n state.setAnchorDate(state.highlightedRange.start);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n }\n }\n\n let startDragging = () => {\n state.setDragging(true);\n touchDragTimerRef.current = undefined;\n\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n isAnchorPressed.current = true;\n };\n\n // Start selection on mouse/touch down so users can drag to select a range.\n // On touch, delay dragging to determine if the user really meant to scroll.\n if (e.pointerType === 'touch') {\n touchDragTimerRef.current = setTimeout(startDragging, 200);\n } else {\n startDragging();\n }\n }\n },\n onPressEnd() {\n isRangeBoundaryPressed.current = false;\n isAnchorPressed.current = false;\n clearTimeout(touchDragTimerRef.current);\n touchDragTimerRef.current = undefined;\n },\n onPress() {\n // For non-range selection, always select on press up.\n if (!('anchorDate' in state) && !state.isReadOnly) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n onPressUp(e) {\n if (state.isReadOnly) {\n return;\n }\n\n // If the user tapped quickly, the date won't be selected yet and the\n // timer will still be in progress. In this case, select the date on touch up.\n // Timer is cleared in onPressEnd.\n if ('anchorDate' in state && touchDragTimerRef.current) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n\n if ('anchorDate' in state) {\n if (isRangeBoundaryPressed.current) {\n // When clicking on the start or end date of an already selected range,\n // start a new selection on press up to also allow dragging the date to\n // change the existing range.\n state.setAnchorDate(date);\n } else if (state.anchorDate && !isAnchorPressed.current) {\n // When releasing a drag or pressing the end date of a range, select it.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n } else if (e.pointerType === 'keyboard' && !state.anchorDate) {\n // For range selection, auto-advance the focused date by one if using keyboard.\n // This gives an indication that you're selecting a range rather than a single date.\n // For mouse, this is unnecessary because users will see the indication on hover. For screen readers,\n // there will be an announcement to \"click to finish selecting range\" (above).\n state.selectDate(date);\n state.focusNearestAvailableDate(date);\n } else if (e.pointerType === 'virtual') {\n // For screen readers, just select the date on click.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n }\n }\n });\n\n let tabIndex: number | undefined = undefined;\n if (!isDisabled) {\n tabIndex = isSameDay(date, state.focusedDate) ? 0 : -1;\n }\n\n // Focus the button in the DOM when the state updates.\n useEffect(() => {\n if (isFocused && ref.current) {\n focusWithoutScrolling(ref.current);\n\n // Scroll into view if navigating with a keyboard, otherwise\n // try not to shift the view under the user's mouse/finger.\n // If in a overlay, scrollIntoViewport will only cause scrolling\n // up to the overlay scroll body to prevent overlay shifting.\n // Also only scroll into view if the cell actually got focused.\n // There are some cases where the cell might be disabled or inside,\n // an inert container and we don't want to scroll then.\n if (getInteractionModality() !== 'pointer' && getActiveElement() === ref.current) {\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n }\n }\n }, [isFocused, ref]);\n\n let cellDateFormatter = useDateFormatter({\n day: 'numeric',\n timeZone: state.timeZone,\n calendar: date.calendar.identifier\n });\n\n let formattedDate = useMemo(\n () => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day')!.value,\n [cellDateFormatter, nativeDate]\n );\n\n return {\n cellProps: {\n role: 'gridcell',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-selected': isSelected || undefined,\n 'aria-invalid': isInvalid || undefined\n },\n buttonProps: mergeProps(pressProps, {\n onFocus() {\n if (!isDisabled) {\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n tabIndex,\n role: 'button',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-label': label,\n 'aria-invalid': isInvalid || undefined,\n 'aria-describedby':\n [isInvalid ? errorMessageId : undefined, descriptionProps['aria-describedby']]\n .filter(Boolean)\n .join(' ') || undefined,\n onPointerEnter(e) {\n // Highlight the date on hover or drag over a date when selecting a range.\n if (\n 'highlightDate' in state &&\n (e.pointerType !== 'touch' || state.isDragging) &&\n isSelectable\n ) {\n state.highlightDate(date);\n }\n },\n onPointerDown(e: PointerEvent) {\n // This is necessary on touch devices to allow dragging\n // outside the original pressed element.\n // (JSDOM does not support this)\n let target = getEventTarget(e);\n if (target instanceof HTMLElement && 'releasePointerCapture' in target) {\n if ('hasPointerCapture' in target) {\n if (target.hasPointerCapture(e.pointerId)) {\n target.releasePointerCapture(e.pointerId);\n }\n } else {\n (target as HTMLElement).releasePointerCapture(e.pointerId);\n }\n }\n },\n onContextMenu(e) {\n // Prevent context menu on long press.\n e.preventDefault();\n }\n }),\n isPressed,\n isFocused,\n isSelected,\n isDisabled,\n isUnavailable,\n isOutsideVisibleRange:\n date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,\n isInvalid,\n formattedDate\n };\n}\n"],"names":[],"version":3,"file":"useCalendarCell.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA8EM,SAAS,0CACd,KAA4B,EAC5B,KAAgE,EAChE,GAAkC;IAElC,IAAI,QAAC,IAAI,cAAE,UAAU,EAAC,GAAG;IACzB,IAAI,kBAAC,cAAc,2BAAE,uBAAuB,EAAC,GAAG,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC;IAC7D,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE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,CAAC,mBAAmB;aAAC,CAC3E,MAAM,CAAC,SACP,IAAI,CAAC,QAAQ;YAClB,gBAAe,CAAC;gBACd,0EAA0E;gBAC1E,IACE,mBAAmB,SAClB,CAAA,EAAE,WAAW,KAAK,WAAW,MAAM,UAAU,AAAD,KAC7C,cAEA,MAAM,aAAa,CAAC;YAExB;YACA,eAAc,CAAe;gBAC3B,uDAAuD;gBACvD,wCAAwC;gBACxC,gCAAgC;gBAChC,IAAI,SAAS,CAAA,GAAA,wCAAa,EAAE;gBAC5B,IAAI,kBAAkB,eAAe,2BAA2B,QAAQ;oBACtE,IAAI,uBAAuB,QACzB;wBAAA,IAAI,OAAO,iBAAiB,CAAC,EAAE,SAAS,GACtC,OAAO,qBAAqB,CAAC,EAAE,SAAS;oBAC1C,OAEA,AAAC,OAAuB,qBAAqB,CAAC,EAAE,SAAS;gBAE7D;YACF;YACA,eAAc,CAAC;gBACb,sCAAsC;gBACtC,EAAE,cAAc;YAClB;QACF;mBACA;mBACA;oBACA;oBACA;uBACA;QACA,uBACE,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,GAAG,IAAI;mBACvF;uBACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarCell.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, isEqualDay, isSameDay, isToday} from '@internationalized/date';\nimport {CalendarSelectionMode, CalendarState} from 'react-stately/useCalendarState';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getActiveElement, getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getEraFormat, hookData} from './utils';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport {getScrollParent} from '../utils/getScrollParent';\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {useDateFormatter} from '../i18n/useDateFormatter';\nimport {useDeepMemo} from '../utils/useDeepMemo';\nimport {useDescription} from '../utils/useDescription';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {usePress} from '../interactions/usePress';\n\nexport interface AriaCalendarCellProps {\n /** The date that this cell represents. */\n date: CalendarDate;\n /**\n * Whether the cell is disabled. By default, this is determined by the\n * Calendar's `minValue`, `maxValue`, and `isDisabled` props.\n */\n isDisabled?: boolean;\n\n /**\n * Whether the cell is outside of the current month.\n */\n isOutsideMonth?: boolean;\n}\n\nexport interface CalendarCellAria {\n /** Props for the grid cell element (e.g. `<td>`). */\n cellProps: DOMAttributes;\n /** Props for the button element within the cell. */\n buttonProps: DOMAttributes;\n /** Whether the cell is currently being pressed. */\n isPressed: boolean;\n /** Whether the cell is selected. */\n isSelected: boolean;\n /** Whether the cell is focused. */\n isFocused: boolean;\n /**\n * Whether the cell is disabled, according to the calendar's `minValue`, `maxValue`, and\n * `isDisabled` props. Disabled dates are not focusable, and cannot be selected by the user. They\n * are typically displayed with a dimmed appearance.\n */\n isDisabled: boolean;\n /**\n * Whether the cell is unavailable, according to the calendar's `isDateUnavailable` prop.\n * Unavailable dates remain focusable, but cannot be selected by the user. They should be\n * displayed with a visual affordance to indicate they are unavailable, such as a different color\n * or a strikethrough.\n *\n * Note that because they are focusable, unavailable dates must meet a 4.5:1 color contrast ratio,\n * [as defined by WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).\n */\n isUnavailable: boolean;\n /**\n * Whether the cell is outside the visible range of the calendar.\n * For example, dates before the first day of a month in the same week.\n */\n isOutsideVisibleRange: boolean;\n /** Whether the cell is part of an invalid selection. */\n isInvalid: boolean;\n /** The day number formatted according to the current locale. */\n formattedDate: string;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar cell component.\n * A calendar cell displays a date cell within a calendar grid which can be selected by the user.\n */\nexport function useCalendarCell(\n props: AriaCalendarCellProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState,\n ref: RefObject<HTMLElement | null>\n): CalendarCellAria {\n let {date, isDisabled} = props;\n let {errorMessageId, selectedDateDescription} = hookData.get(state)!;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n era: getEraFormat(date),\n timeZone: state.timeZone\n });\n let isFocused = state.isCellFocused(date) && !props.isOutsideMonth;\n isDisabled = isDisabled || state.isCellDisabled(date) || !!props.isOutsideMonth;\n let isUnavailable = state.isCellUnavailable(date);\n let isSelectable = !isDisabled && !isUnavailable;\n let isSelected = state.isSelected(date) && isSelectable;\n let isInvalid = false;\n if (state.isValueInvalid) {\n if ('highlightedRange' in state) {\n isInvalid =\n !state.anchorDate &&\n state.highlightedRange != null &&\n date.compare(state.highlightedRange.start) >= 0 &&\n date.compare(state.highlightedRange.end) <= 0;\n } else if (Array.isArray(state.value)) {\n isInvalid = state.value.some(value => isSameDay(value, date));\n } else if (state.value) {\n isInvalid = isSameDay(state.value as CalendarDate, date);\n }\n }\n\n if (isInvalid && !isDisabled) {\n isSelected = true;\n }\n\n // For performance, reuse the same date object as before if the new date prop is the same.\n // This allows subsequent useMemo results to be reused.\n date = useDeepMemo<CalendarDate>(date, isEqualDay);\n let nativeDate = useMemo(() => date.toDate(state.timeZone), [date, state.timeZone]);\n\n // aria-label should be localize Day of week, Month, Day and Year without Time.\n let isDateToday = isToday(date, state.timeZone);\n let label = useMemo(() => {\n let label = '';\n\n // If this is a range calendar, add a description of the full selected range\n // to the first and last selected date.\n if (\n 'highlightedRange' in state &&\n state.value &&\n !state.anchorDate &&\n (isSameDay(date, state.value.start) || isSameDay(date, state.value.end))\n ) {\n label = selectedDateDescription + ', ';\n }\n\n label += dateFormatter.format(nativeDate);\n if (isDateToday) {\n // If date is today, set appropriate string depending on selected state:\n label = stringFormatter.format(isSelected ? 'todayDateSelected' : 'todayDate', {\n date: label\n });\n } else if (isSelected) {\n // If date is selected but not today:\n label = stringFormatter.format('dateSelected', {\n date: label\n });\n }\n\n if (state.minValue && isSameDay(date, state.minValue)) {\n label += ', ' + stringFormatter.format('minimumDate');\n } else if (state.maxValue && isSameDay(date, state.maxValue)) {\n label += ', ' + stringFormatter.format('maximumDate');\n }\n\n return label;\n }, [\n dateFormatter,\n nativeDate,\n stringFormatter,\n isSelected,\n isDateToday,\n date,\n state,\n selectedDateDescription\n ]);\n\n // When a cell is focused and this is a range calendar, add a prompt to help\n // screenreader users know that they are in a range selection mode.\n let rangeSelectionPrompt = '';\n if ('anchorDate' in state && isFocused && !state.isReadOnly && isSelectable) {\n // If selection has started add \"click to finish selecting range\"\n if (state.anchorDate) {\n rangeSelectionPrompt = stringFormatter.format('finishRangeSelectionPrompt');\n // Otherwise, add \"click to start selecting range\" prompt\n } else {\n rangeSelectionPrompt = stringFormatter.format('startRangeSelectionPrompt');\n }\n }\n\n let descriptionProps = useDescription(rangeSelectionPrompt);\n\n let isAnchorPressed = useRef(false);\n let isRangeBoundaryPressed = useRef(false);\n let touchDragTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let {pressProps, isPressed} = usePress({\n // When dragging to select a range, we don't want dragging over the original anchor\n // again to trigger onPressStart. Cancel presses immediately when the pointer exits.\n shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,\n preventFocusOnPress: true,\n isDisabled: !isSelectable || state.isReadOnly,\n onPressStart(e) {\n if (state.isReadOnly) {\n state.setFocusedDate(date);\n state.setFocused(true);\n return;\n }\n\n if (\n 'highlightedRange' in state &&\n !state.anchorDate &&\n (e.pointerType === 'mouse' || e.pointerType === 'touch')\n ) {\n // Allow dragging the start or end date of a range to modify it\n // rather than starting a new selection.\n // Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges\n // are constrained to available dates. The user will need to select a new range in this case.\n if (state.highlightedRange && !isInvalid) {\n if (isSameDay(date, state.highlightedRange.start)) {\n state.setAnchorDate(state.highlightedRange.end);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n } else if (isSameDay(date, state.highlightedRange.end)) {\n state.setAnchorDate(state.highlightedRange.start);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n }\n }\n\n let startDragging = () => {\n state.setDragging(true);\n touchDragTimerRef.current = undefined;\n\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n isAnchorPressed.current = true;\n };\n\n // Start selection on mouse/touch down so users can drag to select a range.\n // On touch, delay dragging to determine if the user really meant to scroll.\n if (e.pointerType === 'touch') {\n touchDragTimerRef.current = setTimeout(startDragging, 200);\n } else {\n startDragging();\n }\n }\n },\n onPressEnd() {\n isRangeBoundaryPressed.current = false;\n isAnchorPressed.current = false;\n clearTimeout(touchDragTimerRef.current);\n touchDragTimerRef.current = undefined;\n },\n onPress() {\n // For non-range selection, always select on press up.\n if (!('anchorDate' in state) && !state.isReadOnly) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n onPressUp(e) {\n if (state.isReadOnly) {\n return;\n }\n\n // If the user tapped quickly, the date won't be selected yet and the\n // timer will still be in progress. In this case, select the date on touch up.\n // Timer is cleared in onPressEnd.\n if ('anchorDate' in state && touchDragTimerRef.current) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n\n if ('anchorDate' in state) {\n if (isRangeBoundaryPressed.current) {\n // When clicking on the start or end date of an already selected range,\n // start a new selection on press up to also allow dragging the date to\n // change the existing range.\n state.setAnchorDate(date);\n } else if (state.anchorDate && !isAnchorPressed.current) {\n // When releasing a drag or pressing the end date of a range, select it.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n } else if (e.pointerType === 'keyboard' && !state.anchorDate) {\n // For range selection, auto-advance the focused date by one if using keyboard.\n // This gives an indication that you're selecting a range rather than a single date.\n // For mouse, this is unnecessary because users will see the indication on hover. For screen readers,\n // there will be an announcement to \"click to finish selecting range\" (above).\n state.selectDate(date);\n state.focusNearestAvailableDate(date);\n } else if (e.pointerType === 'virtual') {\n // For screen readers, just select the date on click.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n }\n }\n });\n\n let tabIndex: number | undefined = undefined;\n if (!isDisabled) {\n tabIndex = isSameDay(date, state.focusedDate) ? 0 : -1;\n }\n\n // Focus the button in the DOM when the state updates.\n useEffect(() => {\n if (isFocused && ref.current) {\n focusWithoutScrolling(ref.current);\n\n // Scroll into view if navigating with a keyboard, otherwise\n // try not to shift the view under the user's mouse/finger.\n // If in a overlay, scrollIntoViewport will only cause scrolling\n // up to the overlay scroll body to prevent overlay shifting.\n // Also only scroll into view if the cell actually got focused.\n // There are some cases where the cell might be disabled or inside,\n // an inert container and we don't want to scroll then.\n if (getInteractionModality() !== 'pointer' && getActiveElement() === ref.current) {\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n }\n }\n }, [isFocused, ref]);\n\n let cellDateFormatter = useDateFormatter({\n day: 'numeric',\n timeZone: state.timeZone,\n calendar: date.calendar.identifier\n });\n\n let formattedDate = useMemo(\n () => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day')!.value,\n [cellDateFormatter, nativeDate]\n );\n\n return {\n cellProps: {\n role: 'gridcell',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-selected': isSelected || undefined,\n 'aria-invalid': isInvalid || undefined\n },\n buttonProps: mergeProps(pressProps, {\n onFocus() {\n if (!isDisabled) {\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n tabIndex,\n role: 'button',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-label': label,\n 'aria-invalid': isInvalid || undefined,\n 'aria-describedby':\n [isInvalid ? errorMessageId : undefined, descriptionProps['aria-describedby']]\n .filter(Boolean)\n .join(' ') || undefined,\n onPointerEnter(e) {\n // Highlight the date on hover or drag over a date when selecting a range.\n if (\n 'highlightDate' in state &&\n (e.pointerType !== 'touch' || state.isDragging) &&\n isSelectable\n ) {\n state.highlightDate(date);\n }\n },\n onPointerDown(e: PointerEvent) {\n // This is necessary on touch devices to allow dragging\n // outside the original pressed element.\n // (JSDOM does not support this)\n let target = getEventTarget(e);\n if (target instanceof HTMLElement && 'releasePointerCapture' in target) {\n if ('hasPointerCapture' in target) {\n if (target.hasPointerCapture(e.pointerId)) {\n target.releasePointerCapture(e.pointerId);\n }\n } else {\n (target as HTMLElement).releasePointerCapture(e.pointerId);\n }\n }\n },\n onContextMenu(e) {\n // Prevent context menu on long press.\n e.preventDefault();\n }\n }),\n isPressed,\n isFocused,\n isSelected,\n isDisabled,\n isUnavailable,\n isOutsideVisibleRange:\n date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,\n isInvalid,\n formattedDate\n };\n}\n"],"names":[],"version":3,"file":"useCalendarCell.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA+EM,SAAS,0CACd,KAA4B,EAC5B,KAAgE,EAChE,GAAkC;IAElC,IAAI,QAAC,IAAI,cAAE,UAAU,EAAC,GAAG;IACzB,IAAI,kBAAC,cAAc,2BAAE,uBAAuB,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;IAC7D,IAAI,kBAAkB,CAAA,GAAA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BAAgB,CAAC,mBAAmB;aAAC,CAC3E,MAAM,CAAC,SACP,IAAI,CAAC,QAAQ;YAClB,gBAAe,CAAC;gBACd,0EAA0E;gBAC1E,IACE,mBAAmB,SAClB,CAAA,EAAE,WAAW,KAAK,WAAW,MAAM,UAAU,AAAD,KAC7C,cAEA,MAAM,aAAa,CAAC;YAExB;YACA,eAAc,CAAe;gBAC3B,uDAAuD;gBACvD,wCAAwC;gBACxC,gCAAgC;gBAChC,IAAI,SAAS,CAAA,GAAA,yCAAa,EAAE;gBAC5B,IAAI,kBAAkB,eAAe,2BAA2B,QAAQ;oBACtE,IAAI,uBAAuB,QACzB;wBAAA,IAAI,OAAO,iBAAiB,CAAC,EAAE,SAAS,GACtC,OAAO,qBAAqB,CAAC,EAAE,SAAS;oBAC1C,OAEA,AAAC,OAAuB,qBAAqB,CAAC,EAAE,SAAS;gBAE7D;YACF;YACA,eAAc,CAAC;gBACb,sCAAsC;gBACtC,EAAE,cAAc;YAClB;QACF;mBACA;mBACA;oBACA;oBACA;uBACA;QACA,uBACE,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,GAAG,IAAI;mBACvF;uBACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarCell.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, isEqualDay, isSameDay, isToday} from '@internationalized/date';\nimport {CalendarSelectionMode, CalendarState} from 'react-stately/useCalendarState';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getActiveElement, getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getEraFormat, hookData} from './utils';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport {getScrollParent} from '../utils/getScrollParent';\n// @ts-ignore\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {useDateFormatter} from '../i18n/useDateFormatter';\nimport {useDeepMemo} from '../utils/useDeepMemo';\nimport {useDescription} from '../utils/useDescription';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {usePress} from '../interactions/usePress';\n\nexport interface AriaCalendarCellProps {\n /** The date that this cell represents. */\n date: CalendarDate;\n /**\n * Whether the cell is disabled. By default, this is determined by the\n * Calendar's `minValue`, `maxValue`, and `isDisabled` props.\n */\n isDisabled?: boolean;\n\n /**\n * Whether the cell is outside of the current month.\n */\n isOutsideMonth?: boolean;\n}\n\nexport interface CalendarCellAria {\n /** Props for the grid cell element (e.g. `<td>`). */\n cellProps: DOMAttributes;\n /** Props for the button element within the cell. */\n buttonProps: DOMAttributes;\n /** Whether the cell is currently being pressed. */\n isPressed: boolean;\n /** Whether the cell is selected. */\n isSelected: boolean;\n /** Whether the cell is focused. */\n isFocused: boolean;\n /**\n * Whether the cell is disabled, according to the calendar's `minValue`, `maxValue`, and\n * `isDisabled` props. Disabled dates are not focusable, and cannot be selected by the user. They\n * are typically displayed with a dimmed appearance.\n */\n isDisabled: boolean;\n /**\n * Whether the cell is unavailable, according to the calendar's `isDateUnavailable` prop.\n * Unavailable dates remain focusable, but cannot be selected by the user. They should be\n * displayed with a visual affordance to indicate they are unavailable, such as a different color\n * or a strikethrough.\n *\n * Note that because they are focusable, unavailable dates must meet a 4.5:1 color contrast ratio,\n * [as defined by WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).\n */\n isUnavailable: boolean;\n /**\n * Whether the cell is outside the visible range of the calendar.\n * For example, dates before the first day of a month in the same week.\n */\n isOutsideVisibleRange: boolean;\n /** Whether the cell is part of an invalid selection. */\n isInvalid: boolean;\n /** The day number formatted according to the current locale. */\n formattedDate: string;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar cell component.\n * A calendar cell displays a date cell within a calendar grid which can be selected by the user.\n */\nexport function useCalendarCell(\n props: AriaCalendarCellProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState,\n ref: RefObject<HTMLElement | null>\n): CalendarCellAria {\n let {date, isDisabled} = props;\n let {errorMessageId, selectedDateDescription} = hookData.get(state)!;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n era: getEraFormat(date),\n timeZone: state.timeZone\n });\n let isFocused = state.isCellFocused(date) && !props.isOutsideMonth;\n isDisabled = isDisabled || state.isCellDisabled(date) || !!props.isOutsideMonth;\n let isUnavailable = state.isCellUnavailable(date);\n let isSelectable = !isDisabled && !isUnavailable;\n let isSelected = state.isSelected(date) && isSelectable;\n let isInvalid = false;\n if (state.isValueInvalid) {\n if ('highlightedRange' in state) {\n isInvalid =\n !state.anchorDate &&\n state.highlightedRange != null &&\n date.compare(state.highlightedRange.start) >= 0 &&\n date.compare(state.highlightedRange.end) <= 0;\n } else if (Array.isArray(state.value)) {\n isInvalid = state.value.some(value => isSameDay(value, date));\n } else if (state.value) {\n isInvalid = isSameDay(state.value as CalendarDate, date);\n }\n }\n\n if (isInvalid && !isDisabled) {\n isSelected = true;\n }\n\n // For performance, reuse the same date object as before if the new date prop is the same.\n // This allows subsequent useMemo results to be reused.\n date = useDeepMemo<CalendarDate>(date, isEqualDay);\n let nativeDate = useMemo(() => date.toDate(state.timeZone), [date, state.timeZone]);\n\n // aria-label should be localize Day of week, Month, Day and Year without Time.\n let isDateToday = isToday(date, state.timeZone);\n let label = useMemo(() => {\n let label = '';\n\n // If this is a range calendar, add a description of the full selected range\n // to the first and last selected date.\n if (\n 'highlightedRange' in state &&\n state.value &&\n !state.anchorDate &&\n (isSameDay(date, state.value.start) || isSameDay(date, state.value.end))\n ) {\n label = selectedDateDescription + ', ';\n }\n\n label += dateFormatter.format(nativeDate);\n if (isDateToday) {\n // If date is today, set appropriate string depending on selected state:\n label = stringFormatter.format(isSelected ? 'todayDateSelected' : 'todayDate', {\n date: label\n });\n } else if (isSelected) {\n // If date is selected but not today:\n label = stringFormatter.format('dateSelected', {\n date: label\n });\n }\n\n if (state.minValue && isSameDay(date, state.minValue)) {\n label += ', ' + stringFormatter.format('minimumDate');\n } else if (state.maxValue && isSameDay(date, state.maxValue)) {\n label += ', ' + stringFormatter.format('maximumDate');\n }\n\n return label;\n }, [\n dateFormatter,\n nativeDate,\n stringFormatter,\n isSelected,\n isDateToday,\n date,\n state,\n selectedDateDescription\n ]);\n\n // When a cell is focused and this is a range calendar, add a prompt to help\n // screenreader users know that they are in a range selection mode.\n let rangeSelectionPrompt = '';\n if ('anchorDate' in state && isFocused && !state.isReadOnly && isSelectable) {\n // If selection has started add \"click to finish selecting range\"\n if (state.anchorDate) {\n rangeSelectionPrompt = stringFormatter.format('finishRangeSelectionPrompt');\n // Otherwise, add \"click to start selecting range\" prompt\n } else {\n rangeSelectionPrompt = stringFormatter.format('startRangeSelectionPrompt');\n }\n }\n\n let descriptionProps = useDescription(rangeSelectionPrompt);\n\n let isAnchorPressed = useRef(false);\n let isRangeBoundaryPressed = useRef(false);\n let touchDragTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let {pressProps, isPressed} = usePress({\n // When dragging to select a range, we don't want dragging over the original anchor\n // again to trigger onPressStart. Cancel presses immediately when the pointer exits.\n shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,\n preventFocusOnPress: true,\n isDisabled: !isSelectable || state.isReadOnly,\n onPressStart(e) {\n if (state.isReadOnly) {\n state.setFocusedDate(date);\n state.setFocused(true);\n return;\n }\n\n if (\n 'highlightedRange' in state &&\n !state.anchorDate &&\n (e.pointerType === 'mouse' || e.pointerType === 'touch')\n ) {\n // Allow dragging the start or end date of a range to modify it\n // rather than starting a new selection.\n // Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges\n // are constrained to available dates. The user will need to select a new range in this case.\n if (state.highlightedRange && !isInvalid) {\n if (isSameDay(date, state.highlightedRange.start)) {\n state.setAnchorDate(state.highlightedRange.end);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n } else if (isSameDay(date, state.highlightedRange.end)) {\n state.setAnchorDate(state.highlightedRange.start);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n }\n }\n\n let startDragging = () => {\n state.setDragging(true);\n touchDragTimerRef.current = undefined;\n\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n isAnchorPressed.current = true;\n };\n\n // Start selection on mouse/touch down so users can drag to select a range.\n // On touch, delay dragging to determine if the user really meant to scroll.\n if (e.pointerType === 'touch') {\n touchDragTimerRef.current = setTimeout(startDragging, 200);\n } else {\n startDragging();\n }\n }\n },\n onPressEnd() {\n isRangeBoundaryPressed.current = false;\n isAnchorPressed.current = false;\n clearTimeout(touchDragTimerRef.current);\n touchDragTimerRef.current = undefined;\n },\n onPress() {\n // For non-range selection, always select on press up.\n if (!('anchorDate' in state) && !state.isReadOnly) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n onPressUp(e) {\n if (state.isReadOnly) {\n return;\n }\n\n // If the user tapped quickly, the date won't be selected yet and the\n // timer will still be in progress. In this case, select the date on touch up.\n // Timer is cleared in onPressEnd.\n if ('anchorDate' in state && touchDragTimerRef.current) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n\n if ('anchorDate' in state) {\n if (isRangeBoundaryPressed.current) {\n // When clicking on the start or end date of an already selected range,\n // start a new selection on press up to also allow dragging the date to\n // change the existing range.\n state.setAnchorDate(date);\n } else if (state.anchorDate && !isAnchorPressed.current) {\n // When releasing a drag or pressing the end date of a range, select it.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n } else if (e.pointerType === 'keyboard' && !state.anchorDate) {\n // For range selection, auto-advance the focused date by one if using keyboard.\n // This gives an indication that you're selecting a range rather than a single date.\n // For mouse, this is unnecessary because users will see the indication on hover. For screen readers,\n // there will be an announcement to \"click to finish selecting range\" (above).\n state.selectDate(date);\n state.focusNearestAvailableDate(date);\n } else if (e.pointerType === 'virtual') {\n // For screen readers, just select the date on click.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n }\n }\n });\n\n let tabIndex: number | undefined = undefined;\n if (!isDisabled) {\n tabIndex = isSameDay(date, state.focusedDate) ? 0 : -1;\n }\n\n // Focus the button in the DOM when the state updates.\n useEffect(() => {\n if (isFocused && ref.current) {\n focusWithoutScrolling(ref.current);\n\n // Scroll into view if navigating with a keyboard, otherwise\n // try not to shift the view under the user's mouse/finger.\n // If in a overlay, scrollIntoViewport will only cause scrolling\n // up to the overlay scroll body to prevent overlay shifting.\n // Also only scroll into view if the cell actually got focused.\n // There are some cases where the cell might be disabled or inside,\n // an inert container and we don't want to scroll then.\n if (getInteractionModality() !== 'pointer' && getActiveElement() === ref.current) {\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n }\n }\n }, [isFocused, ref]);\n\n let cellDateFormatter = useDateFormatter({\n day: 'numeric',\n timeZone: state.timeZone,\n calendar: date.calendar.identifier\n });\n\n let formattedDate = useMemo(\n () => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day')!.value,\n [cellDateFormatter, nativeDate]\n );\n\n return {\n cellProps: {\n role: 'gridcell',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-selected': isSelected || undefined,\n 'aria-invalid': isInvalid || undefined\n },\n buttonProps: mergeProps(pressProps, {\n onFocus() {\n if (!isDisabled) {\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n tabIndex,\n role: 'button',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-label': label,\n 'aria-invalid': isInvalid || undefined,\n 'aria-describedby':\n [isInvalid ? errorMessageId : undefined, descriptionProps['aria-describedby']]\n .filter(Boolean)\n .join(' ') || undefined,\n onPointerEnter(e) {\n // Highlight the date on hover or drag over a date when selecting a range.\n if (\n 'highlightDate' in state &&\n (e.pointerType !== 'touch' || state.isDragging) &&\n isSelectable\n ) {\n state.highlightDate(date);\n }\n },\n onPointerDown(e: PointerEvent) {\n // This is necessary on touch devices to allow dragging\n // outside the original pressed element.\n // (JSDOM does not support this)\n let target = getEventTarget(e);\n if (target instanceof HTMLElement && 'releasePointerCapture' in target) {\n if ('hasPointerCapture' in target) {\n if (target.hasPointerCapture(e.pointerId)) {\n target.releasePointerCapture(e.pointerId);\n }\n } else {\n (target as HTMLElement).releasePointerCapture(e.pointerId);\n }\n }\n },\n onContextMenu(e) {\n // Prevent context menu on long press.\n e.preventDefault();\n }\n }),\n isPressed,\n isFocused,\n isSelected,\n isDisabled,\n isUnavailable,\n isOutsideVisibleRange:\n date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,\n isInvalid,\n formattedDate\n };\n}\n"],"names":[],"version":3,"file":"useCalendarCell.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;AA8EM,SAAS,0CACd,KAA4B,EAC5B,KAAgE,EAChE,GAAkC;IAElC,IAAI,QAAC,IAAI,cAAE,UAAU,EAAC,GAAG;IACzB,IAAI,kBAAC,cAAc,2BAAE,uBAAuB,EAAC,GAAG,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC;IAC7D,IAAI,kBAAkB,CAAA,GA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,gBAAgB,CAAC,mBAAmB;aAAC,CAC3E,MAAM,CAAC,SACP,IAAI,CAAC,QAAQ;YAClB,gBAAe,CAAC;gBACd,0EAA0E;gBAC1E,IACE,mBAAmB,SAClB,CAAA,EAAE,WAAW,KAAK,WAAW,MAAM,UAAU,AAAD,KAC7C,cAEA,MAAM,aAAa,CAAC;YAExB;YACA,eAAc,CAAe;gBAC3B,uDAAuD;gBACvD,wCAAwC;gBACxC,gCAAgC;gBAChC,IAAI,SAAS,CAAA,GAAA,yCAAa,EAAE;gBAC5B,IAAI,kBAAkB,eAAe,2BAA2B,QAAQ;oBACtE,IAAI,uBAAuB,QACzB;wBAAA,IAAI,OAAO,iBAAiB,CAAC,EAAE,SAAS,GACtC,OAAO,qBAAqB,CAAC,EAAE,SAAS;oBAC1C,OAEA,AAAC,OAAuB,qBAAqB,CAAC,EAAE,SAAS;gBAE7D;YACF;YACA,eAAc,CAAC;gBACb,sCAAsC;gBACtC,EAAE,cAAc;YAClB;QACF;mBACA;mBACA;oBACA;oBACA;uBACA;QACA,uBACE,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,KAAK,IAAI,KAAK,KAAK,OAAO,CAAC,MAAM,YAAY,CAAC,GAAG,IAAI;mBACvF;uBACA;IACF;AACF","sources":["packages/react-aria/src/calendar/useCalendarCell.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, isEqualDay, isSameDay, isToday} from '@internationalized/date';\nimport {CalendarSelectionMode, CalendarState} from 'react-stately/useCalendarState';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {focusWithoutScrolling} from '../utils/focusWithoutScrolling';\nimport {getActiveElement, getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {getEraFormat, hookData} from './utils';\nimport {getInteractionModality} from '../interactions/useFocusVisible';\nimport {getScrollParent} from '../utils/getScrollParent';\nimport intlMessages from '../../intl/calendar/*.json';\nimport {mergeProps} from '../utils/mergeProps';\nimport {RangeCalendarState} from 'react-stately/useRangeCalendarState';\nimport {scrollIntoViewport} from '../utils/scrollIntoView';\nimport {useDateFormatter} from '../i18n/useDateFormatter';\nimport {useDeepMemo} from '../utils/useDeepMemo';\nimport {useDescription} from '../utils/useDescription';\nimport {useEffect, useMemo, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {usePress} from '../interactions/usePress';\n\nexport interface AriaCalendarCellProps {\n /** The date that this cell represents. */\n date: CalendarDate;\n /**\n * Whether the cell is disabled. By default, this is determined by the\n * Calendar's `minValue`, `maxValue`, and `isDisabled` props.\n */\n isDisabled?: boolean;\n\n /**\n * Whether the cell is outside of the current month.\n */\n isOutsideMonth?: boolean;\n}\n\nexport interface CalendarCellAria {\n /** Props for the grid cell element (e.g. `<td>`). */\n cellProps: DOMAttributes;\n /** Props for the button element within the cell. */\n buttonProps: DOMAttributes;\n /** Whether the cell is currently being pressed. */\n isPressed: boolean;\n /** Whether the cell is selected. */\n isSelected: boolean;\n /** Whether the cell is focused. */\n isFocused: boolean;\n /**\n * Whether the cell is disabled, according to the calendar's `minValue`, `maxValue`, and\n * `isDisabled` props. Disabled dates are not focusable, and cannot be selected by the user. They\n * are typically displayed with a dimmed appearance.\n */\n isDisabled: boolean;\n /**\n * Whether the cell is unavailable, according to the calendar's `isDateUnavailable` prop.\n * Unavailable dates remain focusable, but cannot be selected by the user. They should be\n * displayed with a visual affordance to indicate they are unavailable, such as a different color\n * or a strikethrough.\n *\n * Note that because they are focusable, unavailable dates must meet a 4.5:1 color contrast ratio,\n * [as defined by WCAG](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html).\n */\n isUnavailable: boolean;\n /**\n * Whether the cell is outside the visible range of the calendar.\n * For example, dates before the first day of a month in the same week.\n */\n isOutsideVisibleRange: boolean;\n /** Whether the cell is part of an invalid selection. */\n isInvalid: boolean;\n /** The day number formatted according to the current locale. */\n formattedDate: string;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a calendar cell component.\n * A calendar cell displays a date cell within a calendar grid which can be selected by the user.\n */\nexport function useCalendarCell(\n props: AriaCalendarCellProps,\n state: CalendarState<CalendarSelectionMode> | RangeCalendarState,\n ref: RefObject<HTMLElement | null>\n): CalendarCellAria {\n let {date, isDisabled} = props;\n let {errorMessageId, selectedDateDescription} = hookData.get(state)!;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/calendar');\n let dateFormatter = useDateFormatter({\n weekday: 'long',\n day: 'numeric',\n month: 'long',\n year: 'numeric',\n era: getEraFormat(date),\n timeZone: state.timeZone\n });\n let isFocused = state.isCellFocused(date) && !props.isOutsideMonth;\n isDisabled = isDisabled || state.isCellDisabled(date) || !!props.isOutsideMonth;\n let isUnavailable = state.isCellUnavailable(date);\n let isSelectable = !isDisabled && !isUnavailable;\n let isSelected = state.isSelected(date) && isSelectable;\n let isInvalid = false;\n if (state.isValueInvalid) {\n if ('highlightedRange' in state) {\n isInvalid =\n !state.anchorDate &&\n state.highlightedRange != null &&\n date.compare(state.highlightedRange.start) >= 0 &&\n date.compare(state.highlightedRange.end) <= 0;\n } else if (Array.isArray(state.value)) {\n isInvalid = state.value.some(value => isSameDay(value, date));\n } else if (state.value) {\n isInvalid = isSameDay(state.value as CalendarDate, date);\n }\n }\n\n if (isInvalid && !isDisabled) {\n isSelected = true;\n }\n\n // For performance, reuse the same date object as before if the new date prop is the same.\n // This allows subsequent useMemo results to be reused.\n date = useDeepMemo<CalendarDate>(date, isEqualDay);\n let nativeDate = useMemo(() => date.toDate(state.timeZone), [date, state.timeZone]);\n\n // aria-label should be localize Day of week, Month, Day and Year without Time.\n let isDateToday = isToday(date, state.timeZone);\n let label = useMemo(() => {\n let label = '';\n\n // If this is a range calendar, add a description of the full selected range\n // to the first and last selected date.\n if (\n 'highlightedRange' in state &&\n state.value &&\n !state.anchorDate &&\n (isSameDay(date, state.value.start) || isSameDay(date, state.value.end))\n ) {\n label = selectedDateDescription + ', ';\n }\n\n label += dateFormatter.format(nativeDate);\n if (isDateToday) {\n // If date is today, set appropriate string depending on selected state:\n label = stringFormatter.format(isSelected ? 'todayDateSelected' : 'todayDate', {\n date: label\n });\n } else if (isSelected) {\n // If date is selected but not today:\n label = stringFormatter.format('dateSelected', {\n date: label\n });\n }\n\n if (state.minValue && isSameDay(date, state.minValue)) {\n label += ', ' + stringFormatter.format('minimumDate');\n } else if (state.maxValue && isSameDay(date, state.maxValue)) {\n label += ', ' + stringFormatter.format('maximumDate');\n }\n\n return label;\n }, [\n dateFormatter,\n nativeDate,\n stringFormatter,\n isSelected,\n isDateToday,\n date,\n state,\n selectedDateDescription\n ]);\n\n // When a cell is focused and this is a range calendar, add a prompt to help\n // screenreader users know that they are in a range selection mode.\n let rangeSelectionPrompt = '';\n if ('anchorDate' in state && isFocused && !state.isReadOnly && isSelectable) {\n // If selection has started add \"click to finish selecting range\"\n if (state.anchorDate) {\n rangeSelectionPrompt = stringFormatter.format('finishRangeSelectionPrompt');\n // Otherwise, add \"click to start selecting range\" prompt\n } else {\n rangeSelectionPrompt = stringFormatter.format('startRangeSelectionPrompt');\n }\n }\n\n let descriptionProps = useDescription(rangeSelectionPrompt);\n\n let isAnchorPressed = useRef(false);\n let isRangeBoundaryPressed = useRef(false);\n let touchDragTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n let {pressProps, isPressed} = usePress({\n // When dragging to select a range, we don't want dragging over the original anchor\n // again to trigger onPressStart. Cancel presses immediately when the pointer exits.\n shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,\n preventFocusOnPress: true,\n isDisabled: !isSelectable || state.isReadOnly,\n onPressStart(e) {\n if (state.isReadOnly) {\n state.setFocusedDate(date);\n state.setFocused(true);\n return;\n }\n\n if (\n 'highlightedRange' in state &&\n !state.anchorDate &&\n (e.pointerType === 'mouse' || e.pointerType === 'touch')\n ) {\n // Allow dragging the start or end date of a range to modify it\n // rather than starting a new selection.\n // Don't allow dragging when invalid, or weird jumping behavior may occur as date ranges\n // are constrained to available dates. The user will need to select a new range in this case.\n if (state.highlightedRange && !isInvalid) {\n if (isSameDay(date, state.highlightedRange.start)) {\n state.setAnchorDate(state.highlightedRange.end);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n } else if (isSameDay(date, state.highlightedRange.end)) {\n state.setAnchorDate(state.highlightedRange.start);\n state.setFocusedDate(date);\n state.setFocused(true);\n state.setDragging(true);\n isRangeBoundaryPressed.current = true;\n return;\n }\n }\n\n let startDragging = () => {\n state.setDragging(true);\n touchDragTimerRef.current = undefined;\n\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n isAnchorPressed.current = true;\n };\n\n // Start selection on mouse/touch down so users can drag to select a range.\n // On touch, delay dragging to determine if the user really meant to scroll.\n if (e.pointerType === 'touch') {\n touchDragTimerRef.current = setTimeout(startDragging, 200);\n } else {\n startDragging();\n }\n }\n },\n onPressEnd() {\n isRangeBoundaryPressed.current = false;\n isAnchorPressed.current = false;\n clearTimeout(touchDragTimerRef.current);\n touchDragTimerRef.current = undefined;\n },\n onPress() {\n // For non-range selection, always select on press up.\n if (!('anchorDate' in state) && !state.isReadOnly) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n onPressUp(e) {\n if (state.isReadOnly) {\n return;\n }\n\n // If the user tapped quickly, the date won't be selected yet and the\n // timer will still be in progress. In this case, select the date on touch up.\n // Timer is cleared in onPressEnd.\n if ('anchorDate' in state && touchDragTimerRef.current) {\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n\n if ('anchorDate' in state) {\n if (isRangeBoundaryPressed.current) {\n // When clicking on the start or end date of an already selected range,\n // start a new selection on press up to also allow dragging the date to\n // change the existing range.\n state.setAnchorDate(date);\n } else if (state.anchorDate && !isAnchorPressed.current) {\n // When releasing a drag or pressing the end date of a range, select it.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n } else if (e.pointerType === 'keyboard' && !state.anchorDate) {\n // For range selection, auto-advance the focused date by one if using keyboard.\n // This gives an indication that you're selecting a range rather than a single date.\n // For mouse, this is unnecessary because users will see the indication on hover. For screen readers,\n // there will be an announcement to \"click to finish selecting range\" (above).\n state.selectDate(date);\n state.focusNearestAvailableDate(date);\n } else if (e.pointerType === 'virtual') {\n // For screen readers, just select the date on click.\n state.selectDate(date);\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n }\n }\n });\n\n let tabIndex: number | undefined = undefined;\n if (!isDisabled) {\n tabIndex = isSameDay(date, state.focusedDate) ? 0 : -1;\n }\n\n // Focus the button in the DOM when the state updates.\n useEffect(() => {\n if (isFocused && ref.current) {\n focusWithoutScrolling(ref.current);\n\n // Scroll into view if navigating with a keyboard, otherwise\n // try not to shift the view under the user's mouse/finger.\n // If in a overlay, scrollIntoViewport will only cause scrolling\n // up to the overlay scroll body to prevent overlay shifting.\n // Also only scroll into view if the cell actually got focused.\n // There are some cases where the cell might be disabled or inside,\n // an inert container and we don't want to scroll then.\n if (getInteractionModality() !== 'pointer' && getActiveElement() === ref.current) {\n scrollIntoViewport(ref.current, {containingElement: getScrollParent(ref.current)});\n }\n }\n }, [isFocused, ref]);\n\n let cellDateFormatter = useDateFormatter({\n day: 'numeric',\n timeZone: state.timeZone,\n calendar: date.calendar.identifier\n });\n\n let formattedDate = useMemo(\n () => cellDateFormatter.formatToParts(nativeDate).find(part => part.type === 'day')!.value,\n [cellDateFormatter, nativeDate]\n );\n\n return {\n cellProps: {\n role: 'gridcell',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-selected': isSelected || undefined,\n 'aria-invalid': isInvalid || undefined\n },\n buttonProps: mergeProps(pressProps, {\n onFocus() {\n if (!isDisabled) {\n state.setFocusedDate(date);\n state.setFocused(true);\n }\n },\n tabIndex,\n role: 'button',\n 'aria-disabled': !isSelectable || undefined,\n 'aria-label': label,\n 'aria-invalid': isInvalid || undefined,\n 'aria-describedby':\n [isInvalid ? errorMessageId : undefined, descriptionProps['aria-describedby']]\n .filter(Boolean)\n .join(' ') || undefined,\n onPointerEnter(e) {\n // Highlight the date on hover or drag over a date when selecting a range.\n if (\n 'highlightDate' in state &&\n (e.pointerType !== 'touch' || state.isDragging) &&\n isSelectable\n ) {\n state.highlightDate(date);\n }\n },\n onPointerDown(e: PointerEvent) {\n // This is necessary on touch devices to allow dragging\n // outside the original pressed element.\n // (JSDOM does not support this)\n let target = getEventTarget(e);\n if (target instanceof HTMLElement && 'releasePointerCapture' in target) {\n if ('hasPointerCapture' in target) {\n if (target.hasPointerCapture(e.pointerId)) {\n target.releasePointerCapture(e.pointerId);\n }\n } else {\n (target as HTMLElement).releasePointerCapture(e.pointerId);\n }\n }\n },\n onContextMenu(e) {\n // Prevent context menu on long press.\n e.preventDefault();\n }\n }),\n isPressed,\n isFocused,\n isSelected,\n isDisabled,\n isUnavailable,\n isOutsideVisibleRange:\n date.compare(state.visibleRange.start) < 0 || date.compare(state.visibleRange.end) > 0,\n isInvalid,\n formattedDate\n };\n}\n"],"names":[],"version":3,"file":"useCalendarCell.js.map"}