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;;;;;AAiBM,SAAS,0CACd,KAA6B,EAC7B,KAA0B,EAC1B,GAAqD;IAErD,IAAI,sBAAC,kBAAkB,SAAE,KAAK,EAAC,GAAG;IAElC,iIAAiI;IACjI,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,uBAAuB,YAAY,KAAK,WAAW,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE;YAC5E,IAAI,eAAe,MAAM,kBAAkB,CAAC,SAAS,GACjD,MAAM,kBAAkB,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,mBACvD;YACJ,IAAI,OAAO,CAAC,iBAAiB,CAAC;YAE9B,kDAAkD;YAClD,sDAAsD;YACtD,IAAI,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,UAC5B,IAAI,OAAO,CAAC,KAAK,GAAG;YAGtB,IAAI,CAAC,MAAM,kBAAkB,CAAC,SAAS,EACrC,MAAM,gBAAgB,CAAC,wCAAkB,IAAI,OAAO;QAExD;IACF;IAEA,IAAI,iBAAiB,C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F,aAAa;YACb,KAAK,KAAK,GAAG;QAEjB;IACF,GAAG;QAAC;QAAK;KAAmB;AAC9B;AAEA,SAAS,kCAAY,KAAyB;IAC5C,6GAA6G;IAC7G,+HAA+H;IAC/H,IAAI,WAAW,MAAM,QAAQ;IAC7B,OAAO;QACL,UAAU,SAAS,QAAQ;QAC3B,aAAa,SAAS,WAAW;QACjC,iBAAiB,SAAS,eAAe;QACzC,eAAe,SAAS,aAAa;QACrC,gBAAgB,SAAS,cAAc;QACvC,cAAc,SAAS,YAAY;QACnC,SAAS,SAAS,OAAO;QACzB,UAAU,SAAS,QAAQ;QAC3B,cAAc,SAAS,YAAY;QACnC,cAAc,SAAS,YAAY;QACnC,OAAO,SAAS,KAAK;IACvB;AACF;AAEA,SAAS,wCAAkB,KAAyB;IAClD,OAAO;QACL,WAAW,CAAC,MAAM,QAAQ,CAAC,KAAK;QAChC,mBAAmB,kCAAY;QAC/B,kBAAkB,MAAM,iBAAiB,GAAG;YAAC,MAAM,iBAAiB;SAAC,GAAG,EAAE;IAC5E;AACF;AAEA,SAAS,2CAAqB,IAAqB;IACjD,IAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,CAAC,MAAM,EAAE,IAAK;QAC7C,IAAI,UAAU,KAAK,QAAQ,CAAC,EAAE;QAC9B,IAAI,QAAQ,QAAQ,EAAE,UAAU,OAC9B,OAAO;IAEX;IAEA,OAAO;AACT","sources":["packages/react-aria/src/form/useFormValidation.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {FormValidationState} from 'react-stately/private/form/useFormValidationState';\n\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {RefObject, Validation, ValidationResult} from '@react-types/shared';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEffect, useRef} from 'react';\nimport {useEffectEvent} from '../utils/useEffectEvent';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\n\ntype ValidatableElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;\n\ninterface FormValidationProps<T> extends Validation<T> {\n focus?: () => void;\n}\n\nexport function useFormValidation<T>(\n props: FormValidationProps<T>,\n state: FormValidationState,\n ref: RefObject<ValidatableElement | null> | undefined\n): void {\n let {validationBehavior, focus} = props;\n\n // This is a useLayoutEffect so that it runs before the useEffect in useFormValidationState, which commits the validation change.\n useLayoutEffect(() => {\n if (validationBehavior === 'native' && ref?.current && !ref.current.disabled) {\n let errorMessage = state.realtimeValidation.isInvalid\n ? state.realtimeValidation.validationErrors.join(' ') || 'Invalid value.'\n : '';\n ref.current.setCustomValidity(errorMessage);\n\n // Prevent default tooltip for validation message.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=605277\n if (!ref.current.hasAttribute('title')) {\n ref.current.title = '';\n }\n\n if (!state.realtimeValidation.isInvalid) {\n state.updateValidation(getNativeValidity(ref.current));\n }\n }\n });\n\n let isIgnoredReset = useRef(false);\n let onReset = useEffectEvent(() => {\n if (!isIgnoredReset.current) {\n state.resetValidation();\n }\n });\n\n let onInvalid = useEffectEvent((e: Event) => {\n // Only commit validation if we are not already displaying one.\n // This avoids clearing server errors that the user didn't actually fix.\n if (!state.displayValidation.isInvalid) {\n state.commitValidation();\n }\n\n // Auto focus the first invalid input in a form, unless the error already had its default prevented.\n let form = ref?.current?.form;\n if (!e.defaultPrevented && ref && form && getFirstInvalidInput(form) === ref.current) {\n if (focus) {\n focus();\n } else {\n ref.current?.focus();\n }\n\n // Always show focus ring.\n setInteractionModality('keyboard');\n }\n\n // Prevent default browser error UI from appearing.\n e.preventDefault();\n });\n\n let onChange = useEffectEvent(() => {\n state.commitValidation();\n });\n\n useEffect(() => {\n let input = ref?.current;\n if (!input) {\n return;\n }\n\n let form = input.form;\n\n let reset = form?.reset;\n if (form) {\n // Try to detect React's automatic form reset behavior so we don't clear\n // validation errors that are returned by server actions.\n // To do this, we ignore programmatic form resets that occur outside a user event.\n // This is best-effort. There may be false positives, e.g. setTimeout.\n form.reset = () => {\n // React uses MessageChannel for scheduling, so ignore 'message' events.\n isIgnoredReset.current =\n !window.event ||\n (window.event.type === 'message' && getEventTarget(window.event) instanceof MessagePort);\n reset?.call(form);\n isIgnoredReset.current = false;\n };\n }\n\n input.addEventListener('invalid', onInvalid);\n input.addEventListener('change', onChange);\n form?.addEventListener('reset', onReset);\n return () => {\n input!.removeEventListener('invalid', onInvalid);\n input!.removeEventListener('change', onChange);\n form?.removeEventListener('reset', onReset);\n if (form) {\n // @ts-ignore\n form.reset = reset;\n }\n };\n }, [ref, validationBehavior]);\n}\n\nfunction getValidity(input: ValidatableElement) {\n // The native ValidityState object is live, meaning each property is a getter that returns the current state.\n // We need to create a snapshot of the validity state at the time this function is called to avoid unpredictable React renders.\n let validity = input.validity;\n return {\n badInput: validity.badInput,\n customError: validity.customError,\n patternMismatch: validity.patternMismatch,\n rangeOverflow: validity.rangeOverflow,\n rangeUnderflow: validity.rangeUnderflow,\n stepMismatch: validity.stepMismatch,\n tooLong: validity.tooLong,\n tooShort: validity.tooShort,\n typeMismatch: validity.typeMismatch,\n valueMissing: validity.valueMissing,\n valid: validity.valid\n };\n}\n\nfunction getNativeValidity(input: ValidatableElement): ValidationResult {\n return {\n isInvalid: !input.validity.valid,\n validationDetails: getValidity(input),\n validationErrors: input.validationMessage ? [input.validationMessage] : []\n };\n}\n\nfunction getFirstInvalidInput(form: HTMLFormElement): ValidatableElement | null {\n for (let i = 0; i < form.elements.length; i++) {\n let element = form.elements[i] as ValidatableElement;\n if (element.validity?.valid === false) {\n return element;\n }\n }\n\n return null;\n}\n"],"names":[],"version":3,"file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M,QAAQ,CAAC,KAAK;QAChC,mBAAmB,kCAAY;QAC/B,kBAAkB,MAAM,iBAAiB,GAAG;YAAC,MAAM,iBAAiB;SAAC,GAAG,EAAE;IAC5E;AACF;AAEA,SAAS,2CAAqB,IAAqB;IACjD,IAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,CAAC,MAAM,EAAE,IAAK;QAC7C,IAAI,UAAU,KAAK,QAAQ,CAAC,EAAE;QAC9B,IAAI,QAAQ,QAAQ,EAAE,UAAU,OAC9B,OAAO;IAEX;IAEA,OAAO;AACT","sources":["packages/react-aria/src/form/useFormValidation.ts"],"sourcesContent":["/*\n * Copyright 2023 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 {FormValidationState} from 'react-stately/private/form/useFormValidationState';\n\nimport {getEventTarget} from '../utils/shadowdom/DOMFunctions';\nimport {RefObject, Validation, ValidationResult} from '@react-types/shared';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useEffect, useRef} from 'react';\nimport {useEffectEvent} from '../utils/useEffectEvent';\nimport {useLayoutEffect} from '../utils/useLayoutEffect';\n\ntype ValidatableElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;\n\ninterface FormValidationProps<T> extends Validation<T> {\n focus?: () => void;\n}\n\nexport function useFormValidation<T>(\n props: FormValidationProps<T>,\n state: FormValidationState,\n ref: RefObject<ValidatableElement | null> | undefined\n): void {\n let {validationBehavior, focus} = props;\n\n // This is a useLayoutEffect so that it runs before the useEffect in useFormValidationState, which commits the validation change.\n useLayoutEffect(() => {\n if (\n validationBehavior === 'native' &&\n ref?.current &&\n 'setCustomValidity' in ref.current &&\n !ref.current.disabled\n ) {\n let errorMessage = state.realtimeValidation.isInvalid\n ? state.realtimeValidation.validationErrors.join(' ') || 'Invalid value.'\n : '';\n ref.current.setCustomValidity(errorMessage);\n\n // Prevent default tooltip for validation message.\n // https://bugzilla.mozilla.org/show_bug.cgi?id=605277\n if (!ref.current.hasAttribute('title')) {\n ref.current.title = '';\n }\n\n if (!state.realtimeValidation.isInvalid) {\n state.updateValidation(getNativeValidity(ref.current));\n }\n }\n });\n\n let isIgnoredReset = useRef(false);\n let onReset = useEffectEvent(() => {\n if (!isIgnoredReset.current) {\n state.resetValidation();\n }\n });\n\n let onInvalid = useEffectEvent((e: Event) => {\n // Only commit validation if we are not already displaying one.\n // This avoids clearing server errors that the user didn't actually fix.\n if (!state.displayValidation.isInvalid) {\n state.commitValidation();\n }\n\n // Auto focus the first invalid input in a form, unless the error already had its default prevented.\n let form = ref?.current?.form;\n if (!e.defaultPrevented && ref && form && getFirstInvalidInput(form) === ref.current) {\n if (focus) {\n focus();\n } else {\n ref.current?.focus();\n }\n\n // Always show focus ring.\n setInteractionModality('keyboard');\n }\n\n // Prevent default browser error UI from appearing.\n e.preventDefault();\n });\n\n let onChange = useEffectEvent(() => {\n state.commitValidation();\n });\n\n useEffect(() => {\n let input = ref?.current;\n if (!input) {\n return;\n }\n\n let form = input.form;\n\n let reset = form?.reset;\n if (form) {\n // Try to detect React's automatic form reset behavior so we don't clear\n // validation errors that are returned by server actions.\n // To do this, we ignore programmatic form resets that occur outside a user event.\n // This is best-effort. There may be false positives, e.g. setTimeout.\n form.reset = () => {\n // React uses MessageChannel for scheduling, so ignore 'message' events.\n isIgnoredReset.current =\n !window.event ||\n (window.event.type === 'message' && getEventTarget(window.event) instanceof MessagePort);\n reset?.call(form);\n isIgnoredReset.current = false;\n };\n }\n\n input.addEventListener('invalid', onInvalid);\n input.addEventListener('change', onChange);\n form?.addEventListener('reset', onReset);\n return () => {\n input!.removeEventListener('invalid', onInvalid);\n input!.removeEventListener('change', onChange);\n form?.removeEventListener('reset', onReset);\n if (form) {\n // @ts-ignore\n form.reset = reset;\n }\n };\n }, [ref, validationBehavior]);\n}\n\nfunction getValidity(input: ValidatableElement) {\n // The native ValidityState object is live, meaning each property is a getter that returns the current state.\n // We need to create a snapshot of the validity state at the time this function is called to avoid unpredictable React renders.\n let validity = input.validity;\n return {\n badInput: validity.badInput,\n customError: validity.customError,\n patternMismatch: validity.patternMismatch,\n rangeOverflow: validity.rangeOverflow,\n rangeUnderflow: validity.rangeUnderflow,\n stepMismatch: validity.stepMismatch,\n tooLong: validity.tooLong,\n tooShort: validity.tooShort,\n typeMismatch: validity.typeMismatch,\n valueMissing: validity.valueMissing,\n valid: validity.valid\n };\n}\n\nfunction getNativeValidity(input: ValidatableElement): ValidationResult {\n return {\n isInvalid: !input.validity.valid,\n validationDetails: getValidity(input),\n validationErrors: input.validationMessage ? [input.validationMessage] : []\n };\n}\n\nfunction getFirstInvalidInput(form: HTMLFormElement): ValidatableElement | null {\n for (let i = 0; i < form.elements.length; i++) {\n let element = form.elements[i] as ValidatableElement;\n if (element.validity?.valid === false) {\n return element;\n }\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"useFormValidation.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA8BM,SAAS,0CACd,KAAqC,EACrC,KAA4B;IAE5B,IAAI,cACF,aAAa,CAAA,MACX,MAAM,UAAU,CAAC,YAAY,GAAG,QAAQ,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,WAC1E,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAEhE,oFAAoF;IACpF,wCAAwC;IACxC,IAAI,YAAY,MAAM,gBAAgB,CAAC,YAAY;IACnD,IAAI,gBAAgB,CAAA,GAAA,mBAAK,EAAE;IAC3B,IAAI,0BAA0B,CAAA,GAAA,wBAAU,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I,MAAM,gBAAgB,CAAC,aAAa,KAAK,YAC3C;YAAA,IACE,SAAS,MAAM,KAAK,KACpB,cAAc,SACd,UAAU,IAAI,GAAG,KACjB,cAAc,OAAO,KAAK,SAC1B,cAAc,OAAO,EAAE,OAAO,GAE9B,SAAS,IAAI,CACX,cAAc,QACV,gBAAgB,MAAM,CAAC,iBACvB,gBAAgB,MAAM,CAAC,iBAAiB;gBAAC,OAAO,UAAU,IAAI;YAAA;QAEtE;QAGF,IAAI,SAAS,MAAM,GAAG,GACpB,CAAA,GAAA,kCAAO,EAAE,SAAS,IAAI,CAAC;QAGzB,cAAc,OAAO,GAAG;IAC1B,GAAG;QACD;QACA,MAAM,gBAAgB,CAAC,YAAY;QACnC,MAAM,gBAAgB,CAAC,SAAS;QAChC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,UAAU;QAChB;QACA;KACD;IAED,8FAA8F;IAC9F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,MAAM,gBAAgB,CAAC,SAAS,EAClC;aACK;YACL,uFAAuF;YACvF,IAAI,MAAM,sBAAsB;YAChC,OAAO,IAAM,qBAAqB;QACpC;IACF,GAAG;QAAC;QAAW,MAAM,gBAAgB,CAAC,SAAS;KAAC;AAClD;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/react-aria/src/grid/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {Collection, Key, Node, Selection} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {SelectionManager} from 'react-stately/private/selection/SelectionManager';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface GridSelectionAnnouncementProps {\n /**\n * A function that returns the text that should be announced by assistive technology when a row is\n * added or removed from selection.\n *\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string;\n}\n\ninterface GridSelectionState<T> {\n /** A collection of items in the grid. */\n collection: Collection<Node<T>>;\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>;\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager;\n}\n\nexport function useGridSelectionAnnouncement<T>(\n props: GridSelectionAnnouncementProps,\n state: GridSelectionState<T>\n): void {\n let {\n getRowText = key =>\n state.collection.getTextValue?.(key) ?? state.collection.getItem(key)?.textValue\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n // Many screen readers do not announce when items in a grid are selected/deselected.\n // We do this using an ARIA live region.\n let selection = state.selectionManager.rawSelection;\n let lastSelection = useRef(selection);\n let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\n lastSelection.current = selection;\n\n return;\n }\n\n let addedKeys = diffSelection(selection, lastSelection.current);\n let removedKeys = diffSelection(lastSelection.current, selection);\n\n // If adding or removing a single row from the selection, announce the name of that item.\n let isReplace = state.selectionManager.selectionBehavior === 'replace';\n let messages: string[] = [];\n\n if (state.selectionManager.selectedKeys.size === 1 && isReplace) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\n if (removedText) {\n messages.push(stringFormatter.format('deselectedItem', {item: removedText}));\n }\n }\n }\n\n // Announce how many items are selected, except when selecting the first item.\n if (state.selectionManager.selectionMode === 'multiple') {\n if (\n messages.length === 0 ||\n selection === 'all' ||\n selection.size > 1 ||\n lastSelection.current === 'all' ||\n lastSelection.current?.size > 1\n ) {\n messages.push(\n selection === 'all'\n ? stringFormatter.format('selectedAll')\n : stringFormatter.format('selectedCount', {count: selection.size})\n );\n }\n }\n\n if (messages.length > 0) {\n announce(messages.join(' '));\n }\n\n lastSelection.current = selection;\n }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\n}\n\nfunction diffSelection(a: Selection, b: Selection): Set<Key> {\n let res = new Set<Key>();\n if (a === 'all' || b === 'all') {\n return res;\n }\n\n for (let key of a.keys()) {\n if (!b.has(key)) {\n res.add(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sB;YAChC,OAAO,IAAM,qBAAqB;QACpC;IACF,GAAG;QAAC;QAAW,MAAM,gBAAgB,CAAC,SAAS;KAAC;AAClD;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/react-aria/src/grid/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {Collection, Key, Node, Selection} from '@react-types/shared';\nimport intlMessages from '../../intl/grid/*.json';\nimport {SelectionManager} from 'react-stately/private/selection/SelectionManager';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface GridSelectionAnnouncementProps {\n /**\n * A function that returns the text that should be announced by assistive technology when a row is\n * added or removed from selection.\n *\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string;\n}\n\ninterface GridSelectionState<T> {\n /** A collection of items in the grid. */\n collection: Collection<Node<T>>;\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>;\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager;\n}\n\nexport function useGridSelectionAnnouncement<T>(\n props: GridSelectionAnnouncementProps,\n state: GridSelectionState<T>\n): void {\n let {\n getRowText = key =>\n state.collection.getTextValue?.(key) ?? state.collection.getItem(key)?.textValue\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n // Many screen readers do not announce when items in a grid are selected/deselected.\n // We do this using an ARIA live region.\n let selection = state.selectionManager.rawSelection;\n let lastSelection = useRef(selection);\n let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\n lastSelection.current = selection;\n\n return;\n }\n\n let addedKeys = diffSelection(selection, lastSelection.current);\n let removedKeys = diffSelection(lastSelection.current, selection);\n\n // If adding or removing a single row from the selection, announce the name of that item.\n let isReplace = state.selectionManager.selectionBehavior === 'replace';\n let messages: string[] = [];\n\n if (state.selectionManager.selectedKeys.size === 1 && isReplace) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\n if (removedText) {\n messages.push(stringFormatter.format('deselectedItem', {item: removedText}));\n }\n }\n }\n\n // Announce how many items are selected, except when selecting the first item.\n if (state.selectionManager.selectionMode === 'multiple') {\n if (\n messages.length === 0 ||\n selection === 'all' ||\n selection.size > 1 ||\n lastSelection.current === 'all' ||\n lastSelection.current?.size > 1\n ) {\n messages.push(\n selection === 'all'\n ? stringFormatter.format('selectedAll')\n : stringFormatter.format('selectedCount', {count: selection.size})\n );\n }\n }\n\n if (messages.length > 0) {\n announce(messages.join(' '));\n }\n\n lastSelection.current = selection;\n }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\n}\n\nfunction diffSelection(a: Selection, b: Selection): Set<Key> {\n let res = new Set<Key>();\n if (a === 'all' || b === 'all') {\n return res;\n }\n\n for (let key of a.keys()) {\n if (!b.has(key)) {\n res.add(key);\n }\n }\n\n return res;\n}\n"],"names":[],"version":3,"file":"useGridSelectionAnnouncement.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA8BM,SAAS,0CACd,KAAqC,EACrC,KAA4B;IAE5B,IAAI,cACF,aAAa,CAAA;YACX,gCAAA,mBAAwC;YAAxC;eAAA,CAAA,mCAAA,iCAAA,CAAA,oBAAA,MAAM,UAAU,EAAC,YAAY,cAA7B,qDAAA,oCAAA,mBAAgC,kBAAhC,6CAAA,mCAAwC,4BAAA,MAAM,UAAU,CAAC,OAAO,CAAC,kBAAzB,gDAAA,0BAA+B,SAAS;OACnF,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAEhE,oFAAoF;IACpF,wCAAwC;IACxC,IAAI,YAAY,MAAM,gBAAgB,CAAC,YAAY;IACnD,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAE;IAC3B,IAAI,0BAA0B,CAAA,GAAA,kBAAU,EAAE;YA+CpC;QA9CJ,IAAI,CAAC,MAAM,gBAAgB,CAAC,SAA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IACE,SAAS,MAAM,KAAK,KACpB,cAAc,SACd,UAAU,IAAI,GAAG,KACjB,cAAc,OAAO,KAAK,SAC1B,EAAA,yBAAA,cAAc,OAAO,cAArB,6CAAA,uBAAuB,IAAI,IAAG,GAE9B,SAAS,IAAI,CACX,cAAc,QACV,gBAAgB,MAAM,CAAC,iBACvB,gBAAgB,MAAM,CAAC,iBAAiB;gBAAC,OAAO,UAAU,IAAI;YAAA;QAEtE;QAGF,IAAI,SAAS,MAAM,GAAG,GACpB,CAAA,GAAA,yCAAO,EAAE,SAAS,IAAI,CAAC;QAGzB,cAAc,OAAO,GAAG;IAC1B,GAAG;QACD;QACA,MAAM,gBAAgB,CAAC,YAAY;QACnC,MAAM,gBAAgB,CAAC,SAAS;QAChC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,UAAU;QAChB;QACA;KACD;IAED,8FAA8F;IAC9F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,MAAM,gBAAgB,CAAC,SAAS,EAClC;aACK;YACL,uFAAuF;YACvF,IAAI,MAAM,sBAAsB;YAChC,OAAO,IAAM,qBAAqB;QACpC;IACF,GAAG;QAAC;QAAW,MAAM,gBAAgB,CAAC,SAAS;KAAC;AAClD;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/react-aria/src/grid/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {Collection, Key, Node, Selection} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {SelectionManager} from 'react-stately/private/selection/SelectionManager';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface GridSelectionAnnouncementProps {\n /**\n * A function that returns the text that should be announced by assistive technology when a row is\n * added or removed from selection.\n *\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string;\n}\n\ninterface GridSelectionState<T> {\n /** A collection of items in the grid. */\n collection: Collection<Node<T>>;\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>;\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager;\n}\n\nexport function useGridSelectionAnnouncement<T>(\n props: GridSelectionAnnouncementProps,\n state: GridSelectionState<T>\n): void {\n let {\n getRowText = key =>\n state.collection.getTextValue?.(key) ?? state.collection.getItem(key)?.textValue\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n // Many screen readers do not announce when items in a grid are selected/deselected.\n // We do this using an ARIA live region.\n let selection = state.selectionManager.rawSelection;\n let lastSelection = useRef(selection);\n let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\n lastSelection.current = selection;\n\n return;\n }\n\n let addedKeys = diffSelection(selection, lastSelection.current);\n let removedKeys = diffSelection(lastSelection.current, selection);\n\n // If adding or removing a single row from the selection, announce the name of that item.\n let isReplace = state.selectionManager.selectionBehavior === 'replace';\n let messages: string[] = [];\n\n if (state.selectionManager.selectedKeys.size === 1 && isReplace) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\n if (removedText) {\n messages.push(stringFormatter.format('deselectedItem', {item: removedText}));\n }\n }\n }\n\n // Announce how many items are selected, except when selecting the first item.\n if (state.selectionManager.selectionMode === 'multiple') {\n if (\n messages.length === 0 ||\n selection === 'all' ||\n selection.size > 1 ||\n lastSelection.current === 'all' ||\n lastSelection.current?.size > 1\n ) {\n messages.push(\n selection === 'all'\n ? stringFormatter.format('selectedAll')\n : stringFormatter.format('selectedCount', {count: selection.size})\n );\n }\n }\n\n if (messages.length > 0) {\n announce(messages.join(' '));\n }\n\n lastSelection.current = selection;\n }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\n}\n\nfunction diffSelection(a: Selection, b: Selection): Set<Key> {\n let res = new Set<Key>();\n if (a === 'all' || b === 'all') {\n return res;\n }\n\n for (let key of a.keys()) {\n if (!b.has(key)) {\n res.add(key);\n }\n }\n\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AM,UAAU;QAChB;QACA;KACD;IAED,8FAA8F;IAC9F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,MAAM,gBAAgB,CAAC,SAAS,EAClC;aACK;YACL,uFAAuF;YACvF,IAAI,MAAM,sBAAsB;YAChC,OAAO,IAAM,qBAAqB;QACpC;IACF,GAAG;QAAC;QAAW,MAAM,gBAAgB,CAAC,SAAS;KAAC;AAClD;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/react-aria/src/grid/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {Collection, Key, Node, Selection} from '@react-types/shared';\nimport intlMessages from '../../intl/grid/*.json';\nimport {SelectionManager} from 'react-stately/private/selection/SelectionManager';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface GridSelectionAnnouncementProps {\n /**\n * A function that returns the text that should be announced by assistive technology when a row is\n * added or removed from selection.\n *\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string;\n}\n\ninterface GridSelectionState<T> {\n /** A collection of items in the grid. */\n collection: Collection<Node<T>>;\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>;\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager;\n}\n\nexport function useGridSelectionAnnouncement<T>(\n props: GridSelectionAnnouncementProps,\n state: GridSelectionState<T>\n): void {\n let {\n getRowText = key =>\n state.collection.getTextValue?.(key) ?? state.collection.getItem(key)?.textValue\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n // Many screen readers do not announce when items in a grid are selected/deselected.\n // We do this using an ARIA live region.\n let selection = state.selectionManager.rawSelection;\n let lastSelection = useRef(selection);\n let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\n lastSelection.current = selection;\n\n return;\n }\n\n let addedKeys = diffSelection(selection, lastSelection.current);\n let removedKeys = diffSelection(lastSelection.current, selection);\n\n // If adding or removing a single row from the selection, announce the name of that item.\n let isReplace = state.selectionManager.selectionBehavior === 'replace';\n let messages: string[] = [];\n\n if (state.selectionManager.selectedKeys.size === 1 && isReplace) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\n if (removedText) {\n messages.push(stringFormatter.format('deselectedItem', {item: removedText}));\n }\n }\n }\n\n // Announce how many items are selected, except when selecting the first item.\n if (state.selectionManager.selectionMode === 'multiple') {\n if (\n messages.length === 0 ||\n selection === 'all' ||\n selection.size > 1 ||\n lastSelection.current === 'all' ||\n lastSelection.current?.size > 1\n ) {\n messages.push(\n selection === 'all'\n ? stringFormatter.format('selectedAll')\n : stringFormatter.format('selectedCount', {count: selection.size})\n );\n }\n }\n\n if (messages.length > 0) {\n announce(messages.join(' '));\n }\n\n lastSelection.current = selection;\n }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\n}\n\nfunction diffSelection(a: Selection, b: Selection): Set<Key> {\n let res = new Set<Key>();\n if (a === 'all' || b === 'all') {\n return res;\n }\n\n for (let key of a.keys()) {\n if (!b.has(key)) {\n res.add(key);\n }\n }\n\n return res;\n}\n"],"names":[],"version":3,"file":"useGridSelectionAnnouncement.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA8BM,SAAS,0CACd,KAAqC,EACrC,KAA4B;IAE5B,IAAI,cACF,aAAa,CAAA,MACX,MAAM,UAAU,CAAC,YAAY,GAAG,QAAQ,MAAM,UAAU,CAAC,OAAO,CAAC,MAAM,WAC1E,GAAG;IACJ,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAEhE,oFAAoF;IACpF,wCAAwC;IACxC,IAAI,YAAY,MAAM,gBAAgB,CAAC,YAAY;IACnD,IAAI,gBAAgB,CAAA,GAAA,aAAK,EAAE;IAC3B,IAAI,0BAA0B,CAAA,GAAA,kBAAU,EAAE;QACxC,IAAI,CAAC,MAAM,gBAAgB,C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C;YAAA,IACE,SAAS,MAAM,KAAK,KACpB,cAAc,SACd,UAAU,IAAI,GAAG,KACjB,cAAc,OAAO,KAAK,SAC1B,cAAc,OAAO,EAAE,OAAO,GAE9B,SAAS,IAAI,CACX,cAAc,QACV,gBAAgB,MAAM,CAAC,iBACvB,gBAAgB,MAAM,CAAC,iBAAiB;gBAAC,OAAO,UAAU,IAAI;YAAA;QAEtE;QAGF,IAAI,SAAS,MAAM,GAAG,GACpB,CAAA,GAAA,yCAAO,EAAE,SAAS,IAAI,CAAC;QAGzB,cAAc,OAAO,GAAG;IAC1B,GAAG;QACD;QACA,MAAM,gBAAgB,CAAC,YAAY;QACnC,MAAM,gBAAgB,CAAC,SAAS;QAChC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,UAAU;QAChB;QACA;KACD;IAED,8FAA8F;IAC9F,CAAA,GAAA,yCAAc,EAAE;QACd,IAAI,MAAM,gBAAgB,CAAC,SAAS,EAClC;aACK;YACL,uFAAuF;YACvF,IAAI,MAAM,sBAAsB;YAChC,OAAO,IAAM,qBAAqB;QACpC;IACF,GAAG;QAAC;QAAW,MAAM,gBAAgB,CAAC,SAAS;KAAC;AAClD;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/react-aria/src/grid/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {Collection, Key, Node, Selection} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {SelectionManager} from 'react-stately/private/selection/SelectionManager';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface GridSelectionAnnouncementProps {\n /**\n * A function that returns the text that should be announced by assistive technology when a row is\n * added or removed from selection.\n *\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string;\n}\n\ninterface GridSelectionState<T> {\n /** A collection of items in the grid. */\n collection: Collection<Node<T>>;\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>;\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager;\n}\n\nexport function useGridSelectionAnnouncement<T>(\n props: GridSelectionAnnouncementProps,\n state: GridSelectionState<T>\n): void {\n let {\n getRowText = key =>\n state.collection.getTextValue?.(key) ?? state.collection.getItem(key)?.textValue\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n // Many screen readers do not announce when items in a grid are selected/deselected.\n // We do this using an ARIA live region.\n let selection = state.selectionManager.rawSelection;\n let lastSelection = useRef(selection);\n let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\n lastSelection.current = selection;\n\n return;\n }\n\n let addedKeys = diffSelection(selection, lastSelection.current);\n let removedKeys = diffSelection(lastSelection.current, selection);\n\n // If adding or removing a single row from the selection, announce the name of that item.\n let isReplace = state.selectionManager.selectionBehavior === 'replace';\n let messages: string[] = [];\n\n if (state.selectionManager.selectedKeys.size === 1 && isReplace) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\n if (removedText) {\n messages.push(stringFormatter.format('deselectedItem', {item: removedText}));\n }\n }\n }\n\n // Announce how many items are selected, except when selecting the first item.\n if (state.selectionManager.selectionMode === 'multiple') {\n if (\n messages.length === 0 ||\n selection === 'all' ||\n selection.size > 1 ||\n lastSelection.current === 'all' ||\n lastSelection.current?.size > 1\n ) {\n messages.push(\n selection === 'all'\n ? stringFormatter.format('selectedAll')\n : stringFormatter.format('selectedCount', {count: selection.size})\n );\n }\n }\n\n if (messages.length > 0) {\n announce(messages.join(' '));\n }\n\n lastSelection.current = selection;\n }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\n}\n\nfunction diffSelection(a: Selection, b: Selection): Set<Key> {\n let res = new Set<Key>();\n if (a === 'all' || b === 'all') {\n return res;\n }\n\n for (let key of a.keys()) {\n if (!b.has(key)) {\n res.add(key);\n }\n }\n\n return res;\n}\n"],"names":[],"version":3,"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AAC;QAAW,MAAM,gBAAgB,CAAC,SAAS;KAAC;AAClD;AAEA,SAAS,oCAAc,CAAY,EAAE,CAAY;IAC/C,IAAI,MAAM,IAAI;IACd,IAAI,MAAM,SAAS,MAAM,OACvB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAE,IAAI,GACpB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,IAAI,GAAG,CAAC;IAIZ,OAAO;AACT","sources":["packages/react-aria/src/grid/useGridSelectionAnnouncement.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {Collection, Key, Node, Selection} from '@react-types/shared';\nimport intlMessages from '../../intl/grid/*.json';\nimport {SelectionManager} from 'react-stately/private/selection/SelectionManager';\nimport {useCallback, useRef} from 'react';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useUpdateEffect} from '../utils/useUpdateEffect';\n\nexport interface GridSelectionAnnouncementProps {\n /**\n * A function that returns the text that should be announced by assistive technology when a row is\n * added or removed from selection.\n *\n * @default (key) => state.collection.getItem(key)?.textValue\n */\n getRowText?: (key: Key) => string;\n}\n\ninterface GridSelectionState<T> {\n /** A collection of items in the grid. */\n collection: Collection<Node<T>>;\n /** A set of items that are disabled. */\n disabledKeys: Set<Key>;\n /** A selection manager to read and update multiple selection state. */\n selectionManager: SelectionManager;\n}\n\nexport function useGridSelectionAnnouncement<T>(\n props: GridSelectionAnnouncementProps,\n state: GridSelectionState<T>\n): void {\n let {\n getRowText = key =>\n state.collection.getTextValue?.(key) ?? state.collection.getItem(key)?.textValue\n } = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n // Many screen readers do not announce when items in a grid are selected/deselected.\n // We do this using an ARIA live region.\n let selection = state.selectionManager.rawSelection;\n let lastSelection = useRef(selection);\n let announceSelectionChange = useCallback(() => {\n if (!state.selectionManager.isFocused || selection === lastSelection.current) {\n lastSelection.current = selection;\n\n return;\n }\n\n let addedKeys = diffSelection(selection, lastSelection.current);\n let removedKeys = diffSelection(lastSelection.current, selection);\n\n // If adding or removing a single row from the selection, announce the name of that item.\n let isReplace = state.selectionManager.selectionBehavior === 'replace';\n let messages: string[] = [];\n\n if (state.selectionManager.selectedKeys.size === 1 && isReplace) {\n let firstKey = state.selectionManager.selectedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let currentSelectionText = getRowText(firstKey);\n if (currentSelectionText) {\n messages.push(stringFormatter.format('selectedItem', {item: currentSelectionText}));\n }\n }\n } else if (addedKeys.size === 1 && removedKeys.size === 0) {\n let firstKey = addedKeys.keys().next().value;\n if (firstKey != null) {\n let addedText = getRowText(firstKey);\n if (addedText) {\n messages.push(stringFormatter.format('selectedItem', {item: addedText}));\n }\n }\n } else if (removedKeys.size === 1 && addedKeys.size === 0) {\n let firstKey = removedKeys.keys().next().value;\n if (firstKey != null && state.collection.getItem(firstKey)) {\n let removedText = getRowText(firstKey);\n if (removedText) {\n messages.push(stringFormatter.format('deselectedItem', {item: removedText}));\n }\n }\n }\n\n // Announce how many items are selected, except when selecting the first item.\n if (state.selectionManager.selectionMode === 'multiple') {\n if (\n messages.length === 0 ||\n selection === 'all' ||\n selection.size > 1 ||\n lastSelection.current === 'all' ||\n lastSelection.current?.size > 1\n ) {\n messages.push(\n selection === 'all'\n ? stringFormatter.format('selectedAll')\n : stringFormatter.format('selectedCount', {count: selection.size})\n );\n }\n }\n\n if (messages.length > 0) {\n announce(messages.join(' '));\n }\n\n lastSelection.current = selection;\n }, [\n selection,\n state.selectionManager.selectedKeys,\n state.selectionManager.isFocused,\n state.selectionManager.selectionBehavior,\n state.selectionManager.selectionMode,\n state.collection,\n getRowText,\n stringFormatter\n ]);\n\n // useUpdateEffect will handle using useEffectEvent, no need to stabilize anything on this end\n useUpdateEffect(() => {\n if (state.selectionManager.isFocused) {\n announceSelectionChange();\n } else {\n // Wait a frame in case the collection is about to become focused (e.g. on mouse down).\n let raf = requestAnimationFrame(announceSelectionChange);\n return () => cancelAnimationFrame(raf);\n }\n }, [selection, state.selectionManager.isFocused]);\n}\n\nfunction diffSelection(a: Selection, b: Selection): Set<Key> {\n let res = new Set<Key>();\n if (a === 'all' || b === 'all') {\n return res;\n }\n\n for (let key of a.keys()) {\n if (!b.has(key)) {\n res.add(key);\n }\n }\n\n return res;\n}\n"],"names":[],"version":3,"file":"useGridSelectionAnnouncement.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;AAyBO,SAAS,0CACd,KAAqC,EACrC,KAAsB;IAEtB,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,+BAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/react-aria/src/grid/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '../checkbox/useCheckbox';\nimport {IGridCollection as GridCollection} from 'react-stately/private/grid/GridCollection';\nimport {GridState} from 'react-stately/private/grid/useGridState';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key;\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n *\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(\n props: AriaGridSelectionCheckboxProps,\n state: GridState<T, C>\n): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;AAwBO,SAAS,0CACd,KAAqC,EACrC,KAAsB;IAEtB,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,+BAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/react-aria/src/grid/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '../checkbox/useCheckbox';\nimport {IGridCollection as GridCollection} from 'react-stately/private/grid/GridCollection';\nimport {GridState} from 'react-stately/private/grid/useGridState';\nimport intlMessages from '../../intl/grid/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key;\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n *\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(\n props: AriaGridSelectionCheckboxProps,\n state: GridState<T, C>\n): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAyBO,SAAS,0CACd,KAAqC,EACrC,KAAsB;IAEtB,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,yCAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/react-aria/src/grid/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '../checkbox/useCheckbox';\nimport {IGridCollection as GridCollection} from 'react-stately/private/grid/GridCollection';\nimport {GridState} from 'react-stately/private/grid/useGridState';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key;\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n *\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(\n props: AriaGridSelectionCheckboxProps,\n state: GridState<T, C>\n): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAwBO,SAAS,0CACd,KAAqC,EACrC,KAAsB;IAEtB,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,yCAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/react-aria/src/grid/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '../checkbox/useCheckbox';\nimport {IGridCollection as GridCollection} from 'react-stately/private/grid/GridCollection';\nimport {GridState} from 'react-stately/private/grid/useGridState';\nimport intlMessages from '../../intl/grid/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key;\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n *\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(\n props: AriaGridSelectionCheckboxProps,\n state: GridState<T, C>\n): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAyBO,SAAS,0CACd,KAAqC,EACrC,KAAsB;IAEtB,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,yCAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/react-aria/src/grid/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '../checkbox/useCheckbox';\nimport {IGridCollection as GridCollection} from 'react-stately/private/grid/GridCollection';\nimport {GridState} from 'react-stately/private/grid/useGridState';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key;\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n *\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(\n props: AriaGridSelectionCheckboxProps,\n state: GridState<T, C>\n): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;AAwBO,SAAS,0CACd,KAAqC,EACrC,KAAsB;IAEtB,IAAI,OAAC,GAAG,EAAC,GAAG;IAEZ,IAAI,UAAU,MAAM,gBAAgB;IACpC,IAAI,aAAa,CAAA,GAAA,yCAAI;IACrB,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,aAAa,CAAC;IACvD,IAAI,aAAa,MAAM,gBAAgB,CAAC,UAAU,CAAC;IAEnD,4EAA4E;IAC5E,IAAI,WAAW,IAAM,QAAQ,eAAe,CAAC;IAE7C,MAAM,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAElE,OAAO;QACL,eAAe;YACb,IAAI;YACJ,cAAc,gBAAgB,MAAM,CAAC;wBACrC;wBACA;sBACA;QACF;IACF;AACF","sources":["packages/react-aria/src/grid/useGridSelectionCheckbox.ts"],"sourcesContent":["import {AriaCheckboxProps} from '../checkbox/useCheckbox';\nimport {IGridCollection as GridCollection} from 'react-stately/private/grid/GridCollection';\nimport {GridState} from 'react-stately/private/grid/useGridState';\nimport intlMessages from '../../intl/grid/*.json';\nimport {Key} from '@react-types/shared';\nimport {useId} from '../utils/useId';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaGridSelectionCheckboxProps {\n /** A unique key for the checkbox. */\n key: Key;\n}\n\nexport interface GridSelectionCheckboxAria {\n /** Props for the row selection checkbox element. */\n checkboxProps: AriaCheckboxProps;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a selection checkbox in a grid.\n *\n * @param props - Props for the selection checkbox.\n * @param state - State of the grid, as returned by `useGridState`.\n */\nexport function useGridSelectionCheckbox<T, C extends GridCollection<T>>(\n props: AriaGridSelectionCheckboxProps,\n state: GridState<T, C>\n): GridSelectionCheckboxAria {\n let {key} = props;\n\n let manager = state.selectionManager;\n let checkboxId = useId();\n let isDisabled = !state.selectionManager.canSelectItem(key);\n let isSelected = state.selectionManager.isSelected(key);\n\n // Checkbox should always toggle selection, regardless of selectionBehavior.\n let onChange = () => manager.toggleSelection(key);\n\n const stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n\n return {\n checkboxProps: {\n id: checkboxId,\n 'aria-label': stringFormatter.format('select'),\n isSelected,\n isDisabled,\n onChange\n }\n };\n}\n"],"names":[],"version":3,"file":"useGridSelectionCheckbox.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAqBM,SAAS,0CACd,KAAyC;IAEzC,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,gDAAqB;IACpC,sGAAsG;IACtG,IAAI,kBACF,AAAC,CAAA,aAAa,aAAa,aAAa,aAAa,YAAY,IAAG,KACpE,OAAO,WAAW,eAClB,kBAAkB;IAEpB,IAAI,yBAAyB,CAAA,GAAA,oBAAM,EAAE;QACnC,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;QACxD,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,iBAAiB;QAEhE,IAAI;QACJ,IAAI,iBACF,UAAU,gBAAgB,MAAM,CAAC;QAGnC,OAAO,sBAAsB,aAAa,kBAAkB,UAAU,MAAM,cAAc,GACtF,UACA;IACN,GAAG;QACD,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,cAAc;QACpB;QACA;KACD;IAED,IAAI,mBAAmB,CAAA,GAAA,wCAAa,EAAE;IACtC,OAAO;AACT","sources":["packages/react-aria/src/grid/useHighlightSelectionDescription.ts"],"sourcesContent":["/*\n * Copyright 2021 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} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {MultipleSelectionManager} from 'react-stately/useMultipleSelectionState';\nimport {useDescription} from '../utils/useDescription';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo} from 'react';\n\nexport interface HighlightSelectionDescriptionProps {\n selectionManager: MultipleSelectionManager;\n hasItemActions?: boolean;\n}\n\n/**\n * Computes the description for a grid selectable collection.\n *\n * @param props\n */\nexport function useHighlightSelectionDescription(\n props: HighlightSelectionDescriptionProps\n): AriaLabelingProps {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n let modality = useInteractionModality();\n // null is the default if the user hasn't interacted with the table at all yet or the rest of the page\n let shouldLongPress =\n (modality === 'pointer' || modality === 'virtual' || modality == null) &&\n typeof window !== 'undefined' &&\n 'ontouchstart' in window;\n\n let interactionDescription = useMemo(() => {\n let selectionMode = props.selectionManager.selectionMode;\n let selectionBehavior = props.selectionManager.selectionBehavior;\n\n let message: string | undefined;\n if (shouldLongPress) {\n message = stringFormatter.format('longPressToSelect');\n }\n\n return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions\n ? message\n : undefined;\n }, [\n props.selectionManager.selectionMode,\n props.selectionManager.selectionBehavior,\n props.hasItemActions,\n stringFormatter,\n shouldLongPress\n ]);\n\n let descriptionProps = useDescription(interactionDescription);\n return descriptionProps;\n}\n"],"names":[],"version":3,"file":"useHighlightSelectionDescription.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAoBM,SAAS,0CACd,KAAyC;IAEzC,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,gDAAqB;IACpC,sGAAsG;IACtG,IAAI,kBACF,AAAC,CAAA,aAAa,aAAa,aAAa,aAAa,YAAY,IAAG,KACpE,OAAO,WAAW,eAClB,kBAAkB;IAEpB,IAAI,yBAAyB,CAAA,GAAA,oBAAM,EAAE;QACnC,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;QACxD,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,iBAAiB;QAEhE,IAAI;QACJ,IAAI,iBACF,UAAU,gBAAgB,MAAM,CAAC;QAGnC,OAAO,sBAAsB,aAAa,kBAAkB,UAAU,MAAM,cAAc,GACtF,UACA;IACN,GAAG;QACD,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,cAAc;QACpB;QACA;KACD;IAED,IAAI,mBAAmB,CAAA,GAAA,wCAAa,EAAE;IACtC,OAAO;AACT","sources":["packages/react-aria/src/grid/useHighlightSelectionDescription.ts"],"sourcesContent":["/*\n * Copyright 2021 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} from '@react-types/shared';\nimport intlMessages from '../../intl/grid/*.json';\nimport {MultipleSelectionManager} from 'react-stately/useMultipleSelectionState';\nimport {useDescription} from '../utils/useDescription';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo} from 'react';\n\nexport interface HighlightSelectionDescriptionProps {\n selectionManager: MultipleSelectionManager;\n hasItemActions?: boolean;\n}\n\n/**\n * Computes the description for a grid selectable collection.\n *\n * @param props\n */\nexport function useHighlightSelectionDescription(\n props: HighlightSelectionDescriptionProps\n): AriaLabelingProps {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n let modality = useInteractionModality();\n // null is the default if the user hasn't interacted with the table at all yet or the rest of the page\n let shouldLongPress =\n (modality === 'pointer' || modality === 'virtual' || modality == null) &&\n typeof window !== 'undefined' &&\n 'ontouchstart' in window;\n\n let interactionDescription = useMemo(() => {\n let selectionMode = props.selectionManager.selectionMode;\n let selectionBehavior = props.selectionManager.selectionBehavior;\n\n let message: string | undefined;\n if (shouldLongPress) {\n message = stringFormatter.format('longPressToSelect');\n }\n\n return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions\n ? message\n : undefined;\n }, [\n props.selectionManager.selectionMode,\n props.selectionManager.selectionBehavior,\n props.hasItemActions,\n stringFormatter,\n shouldLongPress\n ]);\n\n let descriptionProps = useDescription(interactionDescription);\n return descriptionProps;\n}\n"],"names":[],"version":3,"file":"useHighlightSelectionDescription.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAqBM,SAAS,0CACd,KAAyC;IAEzC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAqB;IACpC,sGAAsG;IACtG,IAAI,kBACF,AAAC,CAAA,aAAa,aAAa,aAAa,aAAa,YAAY,IAAG,KACpE,OAAO,WAAW,eAClB,kBAAkB;IAEpB,IAAI,yBAAyB,CAAA,GAAA,cAAM,EAAE;QACnC,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;QACxD,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,iBAAiB;QAEhE,IAAI;QACJ,IAAI,iBACF,UAAU,gBAAgB,MAAM,CAAC;QAGnC,OAAO,sBAAsB,aAAa,kBAAkB,UAAU,MAAM,cAAc,GACtF,UACA;IACN,GAAG;QACD,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,cAAc;QACpB;QACA;KACD;IAED,IAAI,mBAAmB,CAAA,GAAA,yCAAa,EAAE;IACtC,OAAO;AACT","sources":["packages/react-aria/src/grid/useHighlightSelectionDescription.ts"],"sourcesContent":["/*\n * Copyright 2021 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} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {MultipleSelectionManager} from 'react-stately/useMultipleSelectionState';\nimport {useDescription} from '../utils/useDescription';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo} from 'react';\n\nexport interface HighlightSelectionDescriptionProps {\n selectionManager: MultipleSelectionManager;\n hasItemActions?: boolean;\n}\n\n/**\n * Computes the description for a grid selectable collection.\n *\n * @param props\n */\nexport function useHighlightSelectionDescription(\n props: HighlightSelectionDescriptionProps\n): AriaLabelingProps {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n let modality = useInteractionModality();\n // null is the default if the user hasn't interacted with the table at all yet or the rest of the page\n let shouldLongPress =\n (modality === 'pointer' || modality === 'virtual' || modality == null) &&\n typeof window !== 'undefined' &&\n 'ontouchstart' in window;\n\n let interactionDescription = useMemo(() => {\n let selectionMode = props.selectionManager.selectionMode;\n let selectionBehavior = props.selectionManager.selectionBehavior;\n\n let message: string | undefined;\n if (shouldLongPress) {\n message = stringFormatter.format('longPressToSelect');\n }\n\n return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions\n ? message\n : undefined;\n }, [\n props.selectionManager.selectionMode,\n props.selectionManager.selectionBehavior,\n props.hasItemActions,\n stringFormatter,\n shouldLongPress\n ]);\n\n let descriptionProps = useDescription(interactionDescription);\n return descriptionProps;\n}\n"],"names":[],"version":3,"file":"useHighlightSelectionDescription.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAoBM,SAAS,0CACd,KAAyC;IAEzC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAqB;IACpC,sGAAsG;IACtG,IAAI,kBACF,AAAC,CAAA,aAAa,aAAa,aAAa,aAAa,YAAY,IAAG,KACpE,OAAO,WAAW,eAClB,kBAAkB;IAEpB,IAAI,yBAAyB,CAAA,GAAA,cAAM,EAAE;QACnC,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;QACxD,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,iBAAiB;QAEhE,IAAI;QACJ,IAAI,iBACF,UAAU,gBAAgB,MAAM,CAAC;QAGnC,OAAO,sBAAsB,aAAa,kBAAkB,UAAU,MAAM,cAAc,GACtF,UACA;IACN,GAAG;QACD,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,cAAc;QACpB;QACA;KACD;IAED,IAAI,mBAAmB,CAAA,GAAA,yCAAa,EAAE;IACtC,OAAO;AACT","sources":["packages/react-aria/src/grid/useHighlightSelectionDescription.ts"],"sourcesContent":["/*\n * Copyright 2021 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} from '@react-types/shared';\nimport intlMessages from '../../intl/grid/*.json';\nimport {MultipleSelectionManager} from 'react-stately/useMultipleSelectionState';\nimport {useDescription} from '../utils/useDescription';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo} from 'react';\n\nexport interface HighlightSelectionDescriptionProps {\n selectionManager: MultipleSelectionManager;\n hasItemActions?: boolean;\n}\n\n/**\n * Computes the description for a grid selectable collection.\n *\n * @param props\n */\nexport function useHighlightSelectionDescription(\n props: HighlightSelectionDescriptionProps\n): AriaLabelingProps {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n let modality = useInteractionModality();\n // null is the default if the user hasn't interacted with the table at all yet or the rest of the page\n let shouldLongPress =\n (modality === 'pointer' || modality === 'virtual' || modality == null) &&\n typeof window !== 'undefined' &&\n 'ontouchstart' in window;\n\n let interactionDescription = useMemo(() => {\n let selectionMode = props.selectionManager.selectionMode;\n let selectionBehavior = props.selectionManager.selectionBehavior;\n\n let message: string | undefined;\n if (shouldLongPress) {\n message = stringFormatter.format('longPressToSelect');\n }\n\n return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions\n ? message\n : undefined;\n }, [\n props.selectionManager.selectionMode,\n props.selectionManager.selectionBehavior,\n props.hasItemActions,\n stringFormatter,\n shouldLongPress\n ]);\n\n let descriptionProps = useDescription(interactionDescription);\n return descriptionProps;\n}\n"],"names":[],"version":3,"file":"useHighlightSelectionDescription.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAqBM,SAAS,0CACd,KAAyC;IAEzC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAqB;IACpC,sGAAsG;IACtG,IAAI,kBACF,AAAC,CAAA,aAAa,aAAa,aAAa,aAAa,YAAY,IAAG,KACpE,OAAO,WAAW,eAClB,kBAAkB;IAEpB,IAAI,yBAAyB,CAAA,GAAA,cAAM,EAAE;QACnC,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;QACxD,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,iBAAiB;QAEhE,IAAI;QACJ,IAAI,iBACF,UAAU,gBAAgB,MAAM,CAAC;QAGnC,OAAO,sBAAsB,aAAa,kBAAkB,UAAU,MAAM,cAAc,GACtF,UACA;IACN,GAAG;QACD,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,cAAc;QACpB;QACA;KACD;IAED,IAAI,mBAAmB,CAAA,GAAA,yCAAa,EAAE;IACtC,OAAO;AACT","sources":["packages/react-aria/src/grid/useHighlightSelectionDescription.ts"],"sourcesContent":["/*\n * Copyright 2021 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} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../../intl/grid/*.json';\nimport {MultipleSelectionManager} from 'react-stately/useMultipleSelectionState';\nimport {useDescription} from '../utils/useDescription';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo} from 'react';\n\nexport interface HighlightSelectionDescriptionProps {\n selectionManager: MultipleSelectionManager;\n hasItemActions?: boolean;\n}\n\n/**\n * Computes the description for a grid selectable collection.\n *\n * @param props\n */\nexport function useHighlightSelectionDescription(\n props: HighlightSelectionDescriptionProps\n): AriaLabelingProps {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n let modality = useInteractionModality();\n // null is the default if the user hasn't interacted with the table at all yet or the rest of the page\n let shouldLongPress =\n (modality === 'pointer' || modality === 'virtual' || modality == null) &&\n typeof window !== 'undefined' &&\n 'ontouchstart' in window;\n\n let interactionDescription = useMemo(() => {\n let selectionMode = props.selectionManager.selectionMode;\n let selectionBehavior = props.selectionManager.selectionBehavior;\n\n let message: string | undefined;\n if (shouldLongPress) {\n message = stringFormatter.format('longPressToSelect');\n }\n\n return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions\n ? message\n : undefined;\n }, [\n props.selectionManager.selectionMode,\n props.selectionManager.selectionBehavior,\n props.hasItemActions,\n stringFormatter,\n shouldLongPress\n ]);\n\n let descriptionProps = useDescription(interactionDescription);\n return descriptionProps;\n}\n"],"names":[],"version":3,"file":"useHighlightSelectionDescription.mjs.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAoBM,SAAS,0CACd,KAAyC;IAEzC,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,WAAW,CAAA,GAAA,yCAAqB;IACpC,sGAAsG;IACtG,IAAI,kBACF,AAAC,CAAA,aAAa,aAAa,aAAa,aAAa,YAAY,IAAG,KACpE,OAAO,WAAW,eAClB,kBAAkB;IAEpB,IAAI,yBAAyB,CAAA,GAAA,cAAM,EAAE;QACnC,IAAI,gBAAgB,MAAM,gBAAgB,CAAC,aAAa;QACxD,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,iBAAiB;QAEhE,IAAI;QACJ,IAAI,iBACF,UAAU,gBAAgB,MAAM,CAAC;QAGnC,OAAO,sBAAsB,aAAa,kBAAkB,UAAU,MAAM,cAAc,GACtF,UACA;IACN,GAAG;QACD,MAAM,gBAAgB,CAAC,aAAa;QACpC,MAAM,gBAAgB,CAAC,iBAAiB;QACxC,MAAM,cAAc;QACpB;QACA;KACD;IAED,IAAI,mBAAmB,CAAA,GAAA,yCAAa,EAAE;IACtC,OAAO;AACT","sources":["packages/react-aria/src/grid/useHighlightSelectionDescription.ts"],"sourcesContent":["/*\n * Copyright 2021 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} from '@react-types/shared';\nimport intlMessages from '../../intl/grid/*.json';\nimport {MultipleSelectionManager} from 'react-stately/useMultipleSelectionState';\nimport {useDescription} from '../utils/useDescription';\nimport {useInteractionModality} from '../interactions/useFocusVisible';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\nimport {useMemo} from 'react';\n\nexport interface HighlightSelectionDescriptionProps {\n selectionManager: MultipleSelectionManager;\n hasItemActions?: boolean;\n}\n\n/**\n * Computes the description for a grid selectable collection.\n *\n * @param props\n */\nexport function useHighlightSelectionDescription(\n props: HighlightSelectionDescriptionProps\n): AriaLabelingProps {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/grid');\n let modality = useInteractionModality();\n // null is the default if the user hasn't interacted with the table at all yet or the rest of the page\n let shouldLongPress =\n (modality === 'pointer' || modality === 'virtual' || modality == null) &&\n typeof window !== 'undefined' &&\n 'ontouchstart' in window;\n\n let interactionDescription = useMemo(() => {\n let selectionMode = props.selectionManager.selectionMode;\n let selectionBehavior = props.selectionManager.selectionBehavior;\n\n let message: string | undefined;\n if (shouldLongPress) {\n message = stringFormatter.format('longPressToSelect');\n }\n\n return selectionBehavior === 'replace' && selectionMode !== 'none' && props.hasItemActions\n ? message\n : undefined;\n }, [\n props.selectionManager.selectionMode,\n props.selectionManager.selectionBehavior,\n props.hasItemActions,\n stringFormatter,\n shouldLongPress\n ]);\n\n let descriptionProps = useDescription(interactionDescription);\n return descriptionProps;\n}\n"],"names":[],"version":3,"file":"useHighlightSelectionDescription.mjs.map"}
@@ -47,7 +47,8 @@ function $9a37293f310f6644$export$664f9155035607eb(props, state, ref) {
47
47
  linkBehavior: linkBehavior,
48
48
  disallowTypeAhead: disallowTypeAhead,
49
49
  autoFocus: props.autoFocus,
50
- escapeKeyBehavior: escapeKeyBehavior
50
+ escapeKeyBehavior: escapeKeyBehavior,
51
+ UNSTABLE_focusOnEntry: props.UNSTABLE_focusOnEntry
51
52
  });
52
53
  let id = (0, $7ac82d1fee77eb8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AAa,KAAK,aAAa,SAAS;IACnE,GACA,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,sDAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/gridlist/useGridList.ts"],"sourcesContent":["/*\n * Copyright 2022 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 CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n FocusStrategy,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {listMap} from './utils';\nimport {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {useGridSelectionAnnouncement} from '../grid/useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '../focus/useHasTabbableChild';\nimport {useHighlightSelectionDescription} from '../grid/useHighlightSelectionDescription';\nimport {useId} from '../utils/useId';\nimport {useSelectableList} from '../selection/useSelectableList';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /** Whether to auto focus the gridlist or an option. */\n autoFocus?: boolean | FocusStrategy;\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends\n * on the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void;\n /**\n * Whether `disabledKeys` applies to all interactions, or only selection.\n *\n * @default 'all'\n */\n disabledBehavior?: DisabledBehavior;\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean;\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n *\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab';\n /**\n * Whether pressing the escape key should clear selection in the grid list or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n *\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n}\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean;\n /**\n * Whether typeahead navigation is disabled.\n *\n * @default false\n */\n disallowTypeAhead?: boolean;\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n /**\n * Whether focus should wrap around when the end/start is reached.\n *\n * @default false\n */\n shouldFocusWrap?: boolean;\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n *\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override';\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive\n * children. A grid list displays data in a single column and enables a user to navigate its\n * contents via directional navigation keys.\n *\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(\n props: AriaGridListOptions<T>,\n state: ListState<T>,\n ref: RefObject<HTMLElement | null>\n): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n disallowTypeAhead,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow',\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior,\n disallowTypeAhead,\n autoFocus: props.autoFocus,\n escapeKeyBehavior\n });\n\n let id = useId(props.id);\n listMap.set(state, {\n id,\n onAction,\n linkBehavior,\n keyboardNavigationBehavior,\n shouldSelectOnPressUp\n });\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable':\n state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGridList.cjs.map"}
1
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IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,sDAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/gridlist/useGridList.ts"],"sourcesContent":["/*\n * Copyright 2022 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 CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n FocusStrategy,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {listMap} from './utils';\nimport {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {useGridSelectionAnnouncement} from '../grid/useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '../focus/useHasTabbableChild';\nimport {useHighlightSelectionDescription} from '../grid/useHighlightSelectionDescription';\nimport {useId} from '../utils/useId';\nimport {useSelectableList} from '../selection/useSelectableList';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /** Whether to auto focus the gridlist or an option. */\n autoFocus?: boolean | FocusStrategy;\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends\n * on the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void;\n /**\n * Whether `disabledKeys` applies to all interactions, or only selection.\n *\n * @default 'all'\n */\n disabledBehavior?: DisabledBehavior;\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean;\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n *\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab';\n /**\n * Whether pressing the escape key should clear selection in the grid list or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n *\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n}\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean;\n /**\n * Whether typeahead navigation is disabled.\n *\n * @default false\n */\n disallowTypeAhead?: boolean;\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n /**\n * Whether focus should wrap around when the end/start is reached.\n *\n * @default false\n */\n shouldFocusWrap?: boolean;\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n *\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override';\n /**\n * Which item in the collection to focus when tabbing into the collection. Overrides default\n * roving tab index like behavior.\n *\n * @private\n */\n UNSTABLE_focusOnEntry?: 'first' | 'last';\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive\n * children. A grid list displays data in a single column and enables a user to navigate its\n * contents via directional navigation keys.\n *\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(\n props: AriaGridListOptions<T>,\n state: ListState<T>,\n ref: RefObject<HTMLElement | null>\n): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n disallowTypeAhead,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow',\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior,\n disallowTypeAhead,\n autoFocus: props.autoFocus,\n escapeKeyBehavior,\n UNSTABLE_focusOnEntry: props.UNSTABLE_focusOnEntry\n });\n\n let id = useId(props.id);\n listMap.set(state, {\n id,\n onAction,\n linkBehavior,\n keyboardNavigationBehavior,\n shouldSelectOnPressUp\n });\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable':\n state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGridList.cjs.map"}
@@ -41,7 +41,8 @@ function $386a4c16c0702f9d$export$664f9155035607eb(props, state, ref) {
41
41
  linkBehavior: linkBehavior,
42
42
  disallowTypeAhead: disallowTypeAhead,
43
43
  autoFocus: props.autoFocus,
44
- escapeKeyBehavior: escapeKeyBehavior
44
+ escapeKeyBehavior: escapeKeyBehavior,
45
+ UNSTABLE_focusOnEntry: props.UNSTABLE_focusOnEntry
45
46
  });
46
47
  let id = (0, $0292efe68908de6b$export$f680877a34711e37)(props.id);
47
48
  (0, $781ed2e01df48c52$export$5b9bb410392e3991).set(state, {
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAkHM,SAAS,0CACd,KAA6B,EAC7B,KAAmB,EACnB,GAAkC;IAElC,IAAI,iBACF,aAAa,oBACb,gBAAgB,kBAChB,cAAc,YACd,QAAQ,qBACR,iBAAiB,gBACjB,eAAe,sCACf,6BAA6B,4BAC7B,oBAAoB,yCACpB,qBAAqB,EACtB,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE;QAClC,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;aAChC;0BACA;wBACA;uBACA;QACA,eAAe,MAAM,gBAAgB,CAAC,iBAAiB,KAAK;QAC5D,iBAAiB,MAAM,eAAe;sBACtC;2BACA;QACA,WAAW,MAAM,SAAS;2BAC1B;IACF;IAEA,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC,OAAO;YACjB;kBACA;sBACA;oCACA;+BACA;IACF;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAA+B,EAAE;QACtD,kBAAkB,MAAM,gBAAgB;QACxC,gBAAgB,CAAC,CAAC;IACpB;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,YAA2B,CAAA,GAAA,yCAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBACE,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa,SAAS;IACnE,GACA,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,yCAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/gridlist/useGridList.ts"],"sourcesContent":["/*\n * Copyright 2022 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 CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n FocusStrategy,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {listMap} from './utils';\nimport {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {useGridSelectionAnnouncement} from '../grid/useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '../focus/useHasTabbableChild';\nimport {useHighlightSelectionDescription} from '../grid/useHighlightSelectionDescription';\nimport {useId} from '../utils/useId';\nimport {useSelectableList} from '../selection/useSelectableList';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /** Whether to auto focus the gridlist or an option. */\n autoFocus?: boolean | FocusStrategy;\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends\n * on the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void;\n /**\n * Whether `disabledKeys` applies to all interactions, or only selection.\n *\n * @default 'all'\n */\n disabledBehavior?: DisabledBehavior;\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean;\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n *\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab';\n /**\n * Whether pressing the escape key should clear selection in the grid list or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n *\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n}\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean;\n /**\n * Whether typeahead navigation is disabled.\n *\n * @default false\n */\n disallowTypeAhead?: boolean;\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n /**\n * Whether focus should wrap around when the end/start is reached.\n *\n * @default false\n */\n shouldFocusWrap?: boolean;\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n *\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override';\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive\n * children. A grid list displays data in a single column and enables a user to navigate its\n * contents via directional navigation keys.\n *\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(\n props: AriaGridListOptions<T>,\n state: ListState<T>,\n ref: RefObject<HTMLElement | null>\n): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n disallowTypeAhead,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow',\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior,\n disallowTypeAhead,\n autoFocus: props.autoFocus,\n escapeKeyBehavior\n });\n\n let id = useId(props.id);\n listMap.set(state, {\n id,\n onAction,\n linkBehavior,\n keyboardNavigationBehavior,\n shouldSelectOnPressUp\n });\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable':\n state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGridList.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAyHM,SAAS,0CACd,KAA6B,EAC7B,KAAmB,EACnB,GAAkC;IAElC,IAAI,iBACF,aAAa,oBACb,gBAAgB,kBAChB,cAAc,YACd,QAAQ,qBACR,iBAAiB,gBACjB,eAAe,sCACf,6BAA6B,4BAC7B,oBAAoB,yCACpB,qBAAqB,EACtB,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE;QAClC,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;aAChC;0BACA;wBACA;uBACA;QACA,eAAe,MAAM,gBAAgB,CAAC,iBAAiB,KAAK;QAC5D,iBAAiB,MAAM,eAAe;sBACtC;2BACA;QACA,WAAW,MAAM,SAAS;2BAC1B;QACA,uBAAuB,MAAM,qBAAqB;IACpD;IAEA,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC,OAAO;YACjB;kBACA;sBACA;oCACA;+BACA;IACF;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAA+B,EAAE;QACtD,kBAAkB,MAAM,gBAAgB;QACxC,gBAAgB,CAAC,CAAC;IACpB;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,YAA2B,CAAA,GAAA,yCAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBACE,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa,SAAS;IACnE,GACA,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,yCAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/gridlist/useGridList.ts"],"sourcesContent":["/*\n * Copyright 2022 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 CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n FocusStrategy,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {listMap} from './utils';\nimport {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {useGridSelectionAnnouncement} from '../grid/useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '../focus/useHasTabbableChild';\nimport {useHighlightSelectionDescription} from '../grid/useHighlightSelectionDescription';\nimport {useId} from '../utils/useId';\nimport {useSelectableList} from '../selection/useSelectableList';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /** Whether to auto focus the gridlist or an option. */\n autoFocus?: boolean | FocusStrategy;\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends\n * on the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void;\n /**\n * Whether `disabledKeys` applies to all interactions, or only selection.\n *\n * @default 'all'\n */\n disabledBehavior?: DisabledBehavior;\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean;\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n *\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab';\n /**\n * Whether pressing the escape key should clear selection in the grid list or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n *\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n}\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean;\n /**\n * Whether typeahead navigation is disabled.\n *\n * @default false\n */\n disallowTypeAhead?: boolean;\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n /**\n * Whether focus should wrap around when the end/start is reached.\n *\n * @default false\n */\n shouldFocusWrap?: boolean;\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n *\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override';\n /**\n * Which item in the collection to focus when tabbing into the collection. Overrides default\n * roving tab index like behavior.\n *\n * @private\n */\n UNSTABLE_focusOnEntry?: 'first' | 'last';\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive\n * children. A grid list displays data in a single column and enables a user to navigate its\n * contents via directional navigation keys.\n *\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(\n props: AriaGridListOptions<T>,\n state: ListState<T>,\n ref: RefObject<HTMLElement | null>\n): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n disallowTypeAhead,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow',\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior,\n disallowTypeAhead,\n autoFocus: props.autoFocus,\n escapeKeyBehavior,\n UNSTABLE_focusOnEntry: props.UNSTABLE_focusOnEntry\n });\n\n let id = useId(props.id);\n listMap.set(state, {\n id,\n onAction,\n linkBehavior,\n keyboardNavigationBehavior,\n shouldSelectOnPressUp\n });\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable':\n state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGridList.js.map"}
@@ -41,7 +41,8 @@ function $34d813d3524a584a$export$664f9155035607eb(props, state, ref) {
41
41
  linkBehavior: linkBehavior,
42
42
  disallowTypeAhead: disallowTypeAhead,
43
43
  autoFocus: props.autoFocus,
44
- escapeKeyBehavior: escapeKeyBehavior
44
+ escapeKeyBehavior: escapeKeyBehavior,
45
+ UNSTABLE_focusOnEntry: props.UNSTABLE_focusOnEntry
45
46
  });
46
47
  let id = (0, $390e54f620492c70$export$f680877a34711e37)(props.id);
47
48
  (0, $c1c90317e8bffe4d$export$5b9bb410392e3991).set(state, {
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAkHM,SAAS,0CACd,KAA6B,EAC7B,KAAmB,EACnB,GAAkC;IAElC,IAAI,iBACF,aAAa,oBACb,gBAAgB,kBAChB,cAAc,YACd,QAAQ,qBACR,iBAAiB,gBACjB,eAAe,sCACf,6BAA6B,4BAC7B,oBAAoB,yCACpB,qBAAqB,EACtB,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE;QAClC,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;aAChC;0BACA;wBACA;uBACA;QACA,eAAe,MAAM,gBAAgB,CAAC,iBAAiB,KAAK;QAC5D,iBAAiB,MAAM,eAAe;sBACtC;2BACA;QACA,WAAW,MAAM,SAAS;2BAC1B;IACF;IAEA,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC,OAAO;YACjB;kBACA;sBACA;oCACA;+BACA;IACF;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAA+B,EAAE;QACtD,kBAAkB,MAAM,gBAAgB;QACxC,gBAAgB,CAAC,CAAC;IACpB;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,YAA2B,CAAA,GAAA,yCAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBACE,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa,SAAS;IACnE,GACA,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,yCAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/gridlist/useGridList.ts"],"sourcesContent":["/*\n * Copyright 2022 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 CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n FocusStrategy,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {listMap} from './utils';\nimport {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {useGridSelectionAnnouncement} from '../grid/useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '../focus/useHasTabbableChild';\nimport {useHighlightSelectionDescription} from '../grid/useHighlightSelectionDescription';\nimport {useId} from '../utils/useId';\nimport {useSelectableList} from '../selection/useSelectableList';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /** Whether to auto focus the gridlist or an option. */\n autoFocus?: boolean | FocusStrategy;\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends\n * on the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void;\n /**\n * Whether `disabledKeys` applies to all interactions, or only selection.\n *\n * @default 'all'\n */\n disabledBehavior?: DisabledBehavior;\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean;\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n *\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab';\n /**\n * Whether pressing the escape key should clear selection in the grid list or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n *\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n}\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean;\n /**\n * Whether typeahead navigation is disabled.\n *\n * @default false\n */\n disallowTypeAhead?: boolean;\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n /**\n * Whether focus should wrap around when the end/start is reached.\n *\n * @default false\n */\n shouldFocusWrap?: boolean;\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n *\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override';\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive\n * children. A grid list displays data in a single column and enables a user to navigate its\n * contents via directional navigation keys.\n *\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(\n props: AriaGridListOptions<T>,\n state: ListState<T>,\n ref: RefObject<HTMLElement | null>\n): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n disallowTypeAhead,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow',\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior,\n disallowTypeAhead,\n autoFocus: props.autoFocus,\n escapeKeyBehavior\n });\n\n let id = useId(props.id);\n listMap.set(state, {\n id,\n onAction,\n linkBehavior,\n keyboardNavigationBehavior,\n shouldSelectOnPressUp\n });\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable':\n state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGridList.mjs.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AAyHM,SAAS,0CACd,KAA6B,EAC7B,KAAmB,EACnB,GAAkC;IAElC,IAAI,iBACF,aAAa,oBACb,gBAAgB,kBAChB,cAAc,YACd,QAAQ,qBACR,iBAAiB,gBACjB,eAAe,sCACf,6BAA6B,4BAC7B,oBAAoB,yCACpB,qBAAqB,EACtB,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE;QAClC,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;aAChC;0BACA;wBACA;uBACA;QACA,eAAe,MAAM,gBAAgB,CAAC,iBAAiB,KAAK;QAC5D,iBAAiB,MAAM,eAAe;sBACtC;2BACA;QACA,WAAW,MAAM,SAAS;2BAC1B;QACA,uBAAuB,MAAM,qBAAqB;IACpD;IAEA,IAAI,KAAK,CAAA,GAAA,yCAAI,EAAE,MAAM,EAAE;IACvB,CAAA,GAAA,yCAAM,EAAE,GAAG,CAAC,OAAO;YACjB;kBACA;sBACA;oCACA;+BACA;IACF;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAA+B,EAAE;QACtD,kBAAkB,MAAM,gBAAgB;QACxC,gBAAgB,CAAC,CAAC;IACpB;IAEA,IAAI,mBAAmB,CAAA,GAAA,yCAAkB,EAAE,KAAK;QAC9C,YAAY,MAAM,UAAU,CAAC,IAAI,KAAK;IACxC;IAEA,IAAI,WAAW,CAAA,GAAA,yCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,YAA2B,CAAA,GAAA,yCAAS,EACtC,UACA;QACE,MAAM;YACN;QACA,wBACE,MAAM,gBAAgB,CAAC,aAAa,KAAK,aAAa,SAAS;IACnE,GACA,mGAAmG;IACnG,MAAM,UAAU,CAAC,IAAI,KAAK,IAAI;QAAC,UAAU,mBAAmB,KAAK;IAAC,IAAI,WACtE;IAGF,IAAI,eAAe;QACjB,SAAS,CAAC,gBAAgB,GAAG,MAAM,UAAU,CAAC,IAAI;QAClD,SAAS,CAAC,gBAAgB,GAAG;IAC/B;IAEA,CAAA,GAAA,yCAA2B,EAAE,CAAC,GAAG;IAEjC,OAAO;mBACL;IACF;AACF","sources":["packages/react-aria/src/gridlist/useGridList.ts"],"sourcesContent":["/*\n * Copyright 2022 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 CollectionBase,\n DisabledBehavior,\n DOMAttributes,\n DOMProps,\n FocusStrategy,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n MultipleSelection,\n RefObject\n} from '@react-types/shared';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {listMap} from './utils';\nimport {ListState} from 'react-stately/useListState';\nimport {mergeProps} from '../utils/mergeProps';\nimport {useGridSelectionAnnouncement} from '../grid/useGridSelectionAnnouncement';\nimport {useHasTabbableChild} from '../focus/useHasTabbableChild';\nimport {useHighlightSelectionDescription} from '../grid/useHighlightSelectionDescription';\nimport {useId} from '../utils/useId';\nimport {useSelectableList} from '../selection/useSelectableList';\n\nexport interface GridListProps<T> extends CollectionBase<T>, MultipleSelection {\n /** Whether to auto focus the gridlist or an option. */\n autoFocus?: boolean | FocusStrategy;\n /**\n * Handler that is called when a user performs an action on an item. The exact user event depends\n * on the collection's `selectionBehavior` prop and the interaction modality.\n */\n onAction?: (key: Key) => void;\n /**\n * Whether `disabledKeys` applies to all interactions, or only selection.\n *\n * @default 'all'\n */\n disabledBehavior?: DisabledBehavior;\n /** Whether selection should occur on press up instead of press down. */\n shouldSelectOnPressUp?: boolean;\n}\n\nexport interface AriaGridListProps<T> extends GridListProps<T>, DOMProps, AriaLabelingProps {\n /**\n * Whether keyboard navigation to focusable elements within grid list items is\n * via the left/right arrow keys or the tab key.\n *\n * @default 'arrow'\n */\n keyboardNavigationBehavior?: 'arrow' | 'tab';\n /**\n * Whether pressing the escape key should clear selection in the grid list or not.\n *\n * Most experiences should not modify this option as it eliminates a keyboard user's ability to\n * easily clear selection. Only use if the escape key is being handled externally or should not\n * trigger selection clearing contextually.\n *\n * @default 'clearSelection'\n */\n escapeKeyBehavior?: 'clearSelection' | 'none';\n}\n\nexport interface AriaGridListOptions<T> extends Omit<AriaGridListProps<T>, 'children'> {\n /** Whether the list uses virtual scrolling. */\n isVirtualized?: boolean;\n /**\n * Whether typeahead navigation is disabled.\n *\n * @default false\n */\n disallowTypeAhead?: boolean;\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n /**\n * A delegate object that provides layout information for items in the collection.\n * By default this uses the DOM, but this can be overridden to implement things like\n * virtualized scrolling.\n */\n layoutDelegate?: LayoutDelegate;\n /**\n * Whether focus should wrap around when the end/start is reached.\n *\n * @default false\n */\n shouldFocusWrap?: boolean;\n /**\n * The behavior of links in the collection.\n * - 'action': link behaves like onAction.\n * - 'selection': link follows selection interactions (e.g. if URL drives selection).\n * - 'override': links override all other interactions (link items are not selectable).\n *\n * @default 'action'\n */\n linkBehavior?: 'action' | 'selection' | 'override';\n /**\n * Which item in the collection to focus when tabbing into the collection. Overrides default\n * roving tab index like behavior.\n *\n * @private\n */\n UNSTABLE_focusOnEntry?: 'first' | 'last';\n}\n\nexport interface GridListAria {\n /** Props for the grid element. */\n gridProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a list component with interactive\n * children. A grid list displays data in a single column and enables a user to navigate its\n * contents via directional navigation keys.\n *\n * @param props - Props for the list.\n * @param state - State for the list, as returned by `useListState`.\n * @param ref - The ref attached to the list element.\n */\nexport function useGridList<T>(\n props: AriaGridListOptions<T>,\n state: ListState<T>,\n ref: RefObject<HTMLElement | null>\n): GridListAria {\n let {\n isVirtualized,\n keyboardDelegate,\n layoutDelegate,\n onAction,\n disallowTypeAhead,\n linkBehavior = 'action',\n keyboardNavigationBehavior = 'arrow',\n escapeKeyBehavior = 'clearSelection',\n shouldSelectOnPressUp\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let {listProps} = useSelectableList({\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n ref,\n keyboardDelegate,\n layoutDelegate,\n isVirtualized,\n selectOnFocus: state.selectionManager.selectionBehavior === 'replace',\n shouldFocusWrap: props.shouldFocusWrap,\n linkBehavior,\n disallowTypeAhead,\n autoFocus: props.autoFocus,\n escapeKeyBehavior,\n UNSTABLE_focusOnEntry: props.UNSTABLE_focusOnEntry\n });\n\n let id = useId(props.id);\n listMap.set(state, {\n id,\n onAction,\n linkBehavior,\n keyboardNavigationBehavior,\n shouldSelectOnPressUp\n });\n\n let descriptionProps = useHighlightSelectionDescription({\n selectionManager: state.selectionManager,\n hasItemActions: !!onAction\n });\n\n let hasTabbableChild = useHasTabbableChild(ref, {\n isDisabled: state.collection.size !== 0\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n let gridProps: DOMAttributes = mergeProps(\n domProps,\n {\n role: 'grid',\n id,\n 'aria-multiselectable':\n state.selectionManager.selectionMode === 'multiple' ? 'true' : undefined\n },\n // If collection is empty, make sure the grid is tabbable unless there is a child tabbable element.\n state.collection.size === 0 ? {tabIndex: hasTabbableChild ? -1 : 0} : listProps,\n descriptionProps\n );\n\n if (isVirtualized) {\n gridProps['aria-rowcount'] = state.collection.size;\n gridProps['aria-colcount'] = 1;\n }\n\n useGridSelectionAnnouncement({}, state);\n\n return {\n gridProps\n };\n}\n"],"names":[],"version":3,"file":"useGridList.mjs.map"}
@@ -5,6 +5,7 @@ var $9fb4ac1cc58342cc$exports = require("../focus/FocusScope.cjs");
5
5
  var $daad9bac4699131f$exports = require("./utils.cjs");
6
6
  var $d865e4ff74ef4a73$exports = require("../utils/getScrollParent.cjs");
7
7
  var $d0df89f3abe2c2ca$exports = require("../interactions/useFocusVisible.cjs");
8
+ var $48f566b6becd50da$exports = require("../utils/isFocusable.cjs");
8
9
  var $89b39774f3b79dbb$exports = require("../utils/mergeProps.cjs");
9
10
  var $9a1324d6ffd8bbb0$exports = require("../utils/scrollIntoView.cjs");
10
11
  var $f38c7e3583533f40$exports = require("../selection/useSelectableItem.cjs");
@@ -43,6 +44,7 @@ $parcel$export(module.exports, "useGridListItem", function () { return $d07dc266
43
44
 
44
45
 
45
46
 
47
+
46
48
  const $d07dc266c3dc14c0$var$EXPANSION_KEYS = {
47
49
  expand: {
48
50
  ltr: 'ArrowRight',
@@ -117,25 +119,7 @@ function $d07dc266c3dc14c0$export$9610e69494fadfd2(props, state, ref) {
117
119
  if (!(0, $da02ee888921bc9e$exports.nodeContains)(e.currentTarget, (0, $da02ee888921bc9e$exports.getEventTarget)(e)) || !ref.current || !activeElement) return;
118
120
  let walker = (0, $9fb4ac1cc58342cc$exports.getFocusableTreeWalker)(ref.current);
119
121
  walker.currentNode = activeElement;
120
- if ('expandedKeys' in state && activeElement === ref.current) {
121
- if (e.key === $d07dc266c3dc14c0$var$EXPANSION_KEYS['expand'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
122
- state.toggleKey(node.key);
123
- e.stopPropagation();
124
- return;
125
- } else if (e.key === $d07dc266c3dc14c0$var$EXPANSION_KEYS['collapse'][direction] && state.selectionManager.focusedKey === node.key) {
126
- // If item is collapsible, collapse it; else move to parent
127
- if (hasChildRows && state.expandedKeys.has(node.key)) {
128
- state.toggleKey(node.key);
129
- e.stopPropagation();
130
- return;
131
- } else if (!state.expandedKeys.has(node.key) && node.parentKey && state.collection.getItem(node.parentKey)?.type === 'item') {
132
- // Item is a leaf or already collapsed, move focus to parent
133
- state.selectionManager.setFocusedKey(node.parentKey);
134
- e.stopPropagation();
135
- return;
136
- }
137
- }
138
- }
122
+ if ($d07dc266c3dc14c0$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)) return;
139
123
  switch(e.key){
140
124
  case 'ArrowLeft':
141
125
  if (keyboardNavigationBehavior === 'arrow') {
@@ -232,6 +216,16 @@ function $d07dc266c3dc14c0$export$9610e69494fadfd2(props, state, ref) {
232
216
  let onKeyDown = (e)=>{
233
217
  let activeElement = (0, $da02ee888921bc9e$exports.getActiveElement)();
234
218
  if (!(0, $da02ee888921bc9e$exports.nodeContains)(e.currentTarget, (0, $da02ee888921bc9e$exports.getEventTarget)(e)) || !ref.current || !activeElement) return;
219
+ if (keyboardNavigationBehavior === 'tab') {
220
+ // Stop propagation for all events that originate from the children of the gridlist item since we don't want to trigger
221
+ // grid level interactions (row navigation/typeselect/etc)
222
+ // exception made for Tab since that needs to propagate to useSelectableCollection to tab out of the gridlist, might be others?
223
+ if ((0, $da02ee888921bc9e$exports.getEventTarget)(e) !== ref.current && e.key !== 'Tab') {
224
+ e.stopPropagation();
225
+ return;
226
+ }
227
+ if ($d07dc266c3dc14c0$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, ref.current)) return;
228
+ }
235
229
  switch(e.key){
236
230
  case 'Tab':
237
231
  if (keyboardNavigationBehavior === 'tab') {
@@ -259,8 +253,7 @@ function $d07dc266c3dc14c0$export$9610e69494fadfd2(props, state, ref) {
259
253
  // }
260
254
  let rowProps = (0, $89b39774f3b79dbb$exports.mergeProps)(itemProps, linkProps, {
261
255
  role: 'row',
262
- onKeyDownCapture: onKeyDownCapture,
263
- onKeyDown: onKeyDown,
256
+ onKeyDownCapture: keyboardNavigationBehavior === 'arrow' ? onKeyDownCapture : undefined,
264
257
  onFocus: onFocus,
265
258
  // 'aria-label': [(node.textValue || undefined), rowAnnouncement].filter(Boolean).join(', '),
266
259
  'aria-label': node['aria-label'] || node.textValue || undefined,
@@ -269,6 +262,33 @@ function $d07dc266c3dc14c0$export$9610e69494fadfd2(props, state, ref) {
269
262
  'aria-labelledby': descriptionId && (node['aria-label'] || node.textValue) ? `${(0, $daad9bac4699131f$exports.getRowId)(state, node.key)} ${descriptionId}` : undefined,
270
263
  id: (0, $daad9bac4699131f$exports.getRowId)(state, node.key)
271
264
  });
265
+ // we need to guard against space/enter triggering selection/row link via usePress (from itemProps) so check if propagation
266
+ // is stopped. this also fixes space not working in a textfield in a tree parent row
267
+ let baseOnKeyDown = rowProps.onKeyDown;
268
+ rowProps.onKeyDown = (e)=>{
269
+ onKeyDown(e);
270
+ if (!e.isPropagationStopped()) baseOnKeyDown?.(e);
271
+ };
272
+ // guard against presses triggering row selecition when they happen on elements within the row
273
+ // am currently assuming if it is tabbable it is interactive, but maybe can use a different kind of check
274
+ let baseOnPointerDown = rowProps.onPointerDown;
275
+ rowProps.onPointerDown = (e)=>{
276
+ let target = (0, $da02ee888921bc9e$exports.getEventTarget)(e);
277
+ if (target && target !== ref.current && (0, $48f566b6becd50da$exports.isTabbable)(target)) {
278
+ e.stopPropagation();
279
+ return;
280
+ }
281
+ baseOnPointerDown?.(e);
282
+ };
283
+ let baseOnMouseDown = rowProps.onMouseDown;
284
+ rowProps.onMouseDown = (e)=>{
285
+ let target = (0, $da02ee888921bc9e$exports.getEventTarget)(e);
286
+ if (target && target !== ref.current && (0, $48f566b6becd50da$exports.isTabbable)(target)) {
287
+ e.stopPropagation();
288
+ return;
289
+ }
290
+ baseOnMouseDown?.(e);
291
+ };
272
292
  if (isVirtualized) {
273
293
  let { collection: collection } = state;
274
294
  let nodes = [
@@ -295,6 +315,27 @@ function $d07dc266c3dc14c0$export$9610e69494fadfd2(props, state, ref) {
295
315
  ...itemStates
296
316
  };
297
317
  }
318
+ function $d07dc266c3dc14c0$var$handleTreeExpansionKeys(e, state, node, hasChildRows, direction, activeElement, rowRef) {
319
+ if (!('expandedKeys' in state) || activeElement !== rowRef) return false;
320
+ if (e.key === $d07dc266c3dc14c0$var$EXPANSION_KEYS['expand'][direction] && state.selectionManager.focusedKey === node.key && hasChildRows && !state.expandedKeys.has(node.key)) {
321
+ state.toggleKey(node.key);
322
+ e.stopPropagation();
323
+ return true;
324
+ } else if (e.key === $d07dc266c3dc14c0$var$EXPANSION_KEYS['collapse'][direction] && state.selectionManager.focusedKey === node.key) {
325
+ // If item is collapsible, collapse it; else move to parent
326
+ if (hasChildRows && state.expandedKeys.has(node.key)) {
327
+ state.toggleKey(node.key);
328
+ e.stopPropagation();
329
+ return true;
330
+ } else if (!state.expandedKeys.has(node.key) && node.parentKey && state.collection.getItem(node.parentKey)?.type === 'item') {
331
+ // Item is a leaf or already collapsed, move focus to parent
332
+ state.selectionManager.setFocusedKey(node.parentKey);
333
+ e.stopPropagation();
334
+ return true;
335
+ }
336
+ }
337
+ return false;
338
+ }
298
339
  function $d07dc266c3dc14c0$var$last(walker) {
299
340
  let next = null;
300
341
  let last = null;