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;;;;AAgDM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,cAAC,UAAU,cAAE,UAAU,YAAE,QAAQ,WAAE,OAAO,QAAE,OAAO,UAAS,GAAG;IAEnE,IAAI,YAAY,CAAA;QACd,MAAM,MAAM,EAAE,GAAG;QAEjB,IAAI,QAAQ,WAAY,CAAA,cAAc,UAAS,GAC7C,EAAE,cAAc;QAGlB,IAAI,cAAc,YAChB;QAGF,8BAA8B;QAC9B,2FAA2F;QAC3F,IAAI,QAAQ,WAAW,UAAU;YAC/B,EAAE,cAAc;YAChB,SAAS,MAAM,KAAK;QACtB;QAEA,IAAI,QAAQ;YACV,4HAA4H;YAC5H,WAAW;YACX,IAAI,MAAM,KAAK,KAAK,MAAO,CAAA,CAAC,SAAS,OAAO,IAAI,SAAS,OAAO,CAAC,KAAK,KAAK,EAAC,GAC1E,EAAE,mBAAmB;iBAChB;gBACL,EAAE,cAAc;gBAChB,MAAM,QAAQ,CAAC;gBACf,IAAI,SACF;YAEJ;;IAEJ;IAEA,IAAI,qBAAqB;QACvB,MAAM,QAAQ,CAAC;QAEf,IAAI,SACF;IAEJ;IAEA,IAAI,eAAe;QACjB,+FAA+F;QAC/F,mCAAmC;QACnC,SAAS,OAAO,EAAE;IACpB;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,sCAAW,EAC5F;QACE,GAAG,KAAK;QACR,OAAO,MAAM,KAAK;QAClB,UAAU,MAAM,QAAQ;QACxB,WAAW,CAAC,aAAa,CAAA,GAAA,+BAAI,EAAE,WAAW,MAAM,SAAS,IAAI,MAAM,SAAS;cAC5E;IACF,GACA;IAGF,OAAO;oBACL;QACA,YAAY;YACV,GAAG,UAAU;YACb,yCAAyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,qBAAqB;YACrB,YAAY,cAAc;YAC1B,SAAS;0BACT;QACF;0BACA;2BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/react-aria/src/searchfield/useSearchField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaTextFieldProps, useTextField} from '../textfield/useTextField';\nimport {chain} from '../utils/chain';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../../intl/searchfield/*.json';\nimport {SearchFieldProps, SearchFieldState} from 'react-stately/useSearchFieldState';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaSearchFieldProps extends SearchFieldProps, Omit<AriaTextFieldProps, 'type'> {\n /**\n * An enumerated attribute that defines what action label or icon to preset for the enter key on\n * virtual keyboards. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).\n */\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n /**\n * The type of input to render. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).\n *\n * @default 'search'\n */\n type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {});\n}\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps;\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n *\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {isDisabled, isReadOnly, onSubmit, onClear, type = 'search'} = props;\n\n let onKeyDown = e => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField(\n {\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n },\n inputRef\n );\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+CM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,qDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,cAAC,UAAU,cAAE,UAAU,YAAE,QAAQ,WAAE,OAAO,QAAE,OAAO,UAAS,GAAG;IAEnE,IAAI,YAAY,CAAA;QACd,MAAM,MAAM,EAAE,GAAG;QAEjB,IAAI,QAAQ,WAAY,CAAA,cAAc,UAAS,GAC7C,EAAE,cAAc;QAGlB,IAAI,cAAc,YAChB;QAGF,8BAA8B;QAC9B,2FAA2F;QAC3F,IAAI,QAAQ,WAAW,UAAU;YAC/B,EAAE,cAAc;YAChB,SAAS,MAAM,KAAK;QACtB;QAEA,IAAI,QAAQ;YACV,4HAA4H;YAC5H,WAAW;YACX,IAAI,MAAM,KAAK,KAAK,MAAO,CAAA,CAAC,SAAS,OAAO,IAAI,SAAS,OAAO,CAAC,KAAK,KAAK,EAAC,GAC1E,EAAE,mBAAmB;iBAChB;gBACL,EAAE,cAAc;gBAChB,MAAM,QAAQ,CAAC;gBACf,IAAI,SACF;YAEJ;;IAEJ;IAEA,IAAI,qBAAqB;QACvB,MAAM,QAAQ,CAAC;QAEf,IAAI,SACF;IAEJ;IAEA,IAAI,eAAe;QACjB,+FAA+F;QAC/F,mCAAmC;QACnC,SAAS,OAAO,EAAE;IACpB;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,sCAAW,EAC5F;QACE,GAAG,KAAK;QACR,OAAO,MAAM,KAAK;QAClB,UAAU,MAAM,QAAQ;QACxB,WAAW,CAAC,aAAa,CAAA,GAAA,+BAAI,EAAE,WAAW,MAAM,SAAS,IAAI,MAAM,SAAS;cAC5E;IACF,GACA;IAGF,OAAO;oBACL;QACA,YAAY;YACV,GAAG,UAAU;YACb,yCAAyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,qBAAqB;YACrB,YAAY,cAAc;YAC1B,SAAS;0BACT;QACF;0BACA;2BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/react-aria/src/searchfield/useSearchField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaTextFieldProps, useTextField} from '../textfield/useTextField';\nimport {chain} from '../utils/chain';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport intlMessages from '../../intl/searchfield/*.json';\nimport {SearchFieldProps, SearchFieldState} from 'react-stately/useSearchFieldState';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaSearchFieldProps extends SearchFieldProps, Omit<AriaTextFieldProps, 'type'> {\n /**\n * An enumerated attribute that defines what action label or icon to preset for the enter key on\n * virtual keyboards. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).\n */\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n /**\n * The type of input to render. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).\n *\n * @default 'search'\n */\n type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {});\n}\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps;\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n *\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {isDisabled, isReadOnly, onSubmit, onClear, type = 'search'} = props;\n\n let onKeyDown = e => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField(\n {\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n },\n inputRef\n );\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;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L;QACA,YAAY;YACV,GAAG,UAAU;YACb,yCAAyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,qBAAqB;YACrB,YAAY,cAAc;YAC1B,SAAS;0BACT;QACF;0BACA;2BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/react-aria/src/searchfield/useSearchField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaTextFieldProps, useTextField} from '../textfield/useTextField';\nimport {chain} from '../utils/chain';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../../intl/searchfield/*.json';\nimport {SearchFieldProps, SearchFieldState} from 'react-stately/useSearchFieldState';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaSearchFieldProps extends SearchFieldProps, Omit<AriaTextFieldProps, 'type'> {\n /**\n * An enumerated attribute that defines what action label or icon to preset for the enter key on\n * virtual keyboards. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).\n */\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n /**\n * The type of input to render. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).\n *\n * @default 'search'\n */\n type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {});\n}\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps;\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n *\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {isDisabled, isReadOnly, onSubmit, onClear, type = 'search'} = props;\n\n let onKeyDown = e => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField(\n {\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n },\n inputRef\n );\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+CM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,8CAAW,GAAG;IAChE,IAAI,cAAC,UAAU,cAAE,UAAU,YAAE,QAAQ,WAAE,OAAO,QAAE,OAAO,UAAS,GAAG;IAEnE,IAAI,YAAY,CAAA;QACd,MAAM,MAAM,EAAE,GAAG;QAEjB,IAAI,QAAQ,WAAY,CAAA,cAAc,UAAS,GAC7C,EAAE,cAAc;QAGlB,IAAI,cAAc,YAChB;QAGF,8BAA8B;QAC9B,2FAA2F;QAC3F,IAAI,QAAQ,WAAW,UAAU;YAC/B,EAAE,cAAc;YAChB,SAAS,MAAM,KAAK;QACtB;QAEA,IAAI,QAAQ;YACV,4HAA4H;YAC5H,WAAW;YACX,IAAI,MAAM,KAAK,KAAK,MAAO,CAAA,CAAC,SAAS,OAAO,IAAI,SAAS,OAAO,CAAC,KAAK,KAAK,EAAC,GAC1E,EAAE,mBAAmB;iBAChB;gBACL,EAAE,cAAc;gBAChB,MAAM,QAAQ,CAAC;gBACf,IAAI,SACF;YAEJ;;IAEJ;IAEA,IAAI,qBAAqB;QACvB,MAAM,QAAQ,CAAC;QAEf,IAAI,SACF;IAEJ;IAEA,IAAI,eAAe;YACjB,+FAA+F;QAC/F,mCAAmC;QACnC;SAAA,oBAAA,SAAS,OAAO,cAAhB,wCAAA,kBAAkB,KAAK;IACzB;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,wCAAW,EAC5F;QACE,GAAG,KAAK;QACR,OAAO,MAAM,KAAK;QAClB,UAAU,MAAM,QAAQ;QACxB,WAAW,CAAC,aAAa,CAAA,GAAA,yCAAI,EAAE,WAAW,MAAM,SAAS,IAAI,MAAM,SAAS;cAC5E;IACF,GACA;IAGF,OAAO;oBACL;QACA,YAAY;YACV,GAAG,UAAU;YACb,yCAAyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,qBAAqB;YACrB,YAAY,cAAc;YAC1B,SAAS;0BACT;QACF;0BACA;2BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/react-aria/src/searchfield/useSearchField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaTextFieldProps, useTextField} from '../textfield/useTextField';\nimport {chain} from '../utils/chain';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport intlMessages from '../../intl/searchfield/*.json';\nimport {SearchFieldProps, SearchFieldState} from 'react-stately/useSearchFieldState';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaSearchFieldProps extends SearchFieldProps, Omit<AriaTextFieldProps, 'type'> {\n /**\n * An enumerated attribute that defines what action label or icon to preset for the enter key on\n * virtual keyboards. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).\n */\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n /**\n * The type of input to render. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).\n *\n * @default 'search'\n */\n type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {});\n}\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps;\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n *\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {isDisabled, isReadOnly, onSubmit, onClear, type = 'search'} = props;\n\n let onKeyDown = e => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField(\n {\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n },\n inputRef\n );\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAgDM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,cAAC,UAAU,cAAE,UAAU,YAAE,QAAQ,WAAE,OAAO,QAAE,OAAO,UAAS,GAAG;IAEnE,IAAI,YAAY,CAAA;QACd,MAAM,MAAM,EAAE,GAAG;QAEjB,IAAI,QAAQ,WAAY,CAAA,cAAc,UAAS,GAC7C,EAAE,cAAc;QAGlB,IAAI,cAAc,YAChB;QAGF,8BAA8B;QAC9B,2FAA2F;QAC3F,IAAI,QAAQ,WAAW,UAAU;YAC/B,EAAE,cAAc;YAChB,SAAS,MAAM,KAAK;QACtB;QAEA,IAAI,QAAQ;YACV,4HAA4H;YAC5H,WAAW;YACX,IAAI,MAAM,KAAK,KAAK,MAAO,CAAA,CAAC,SAAS,OAAO,IAAI,SAAS,OAAO,CAAC,KAAK,KAAK,EAAC,GAC1E,EAAE,mBAAmB;iBAChB;gBACL,EAAE,cAAc;gBAChB,MAAM,QAAQ,CAAC;gBACf,IAAI,SACF;YAEJ;;IAEJ;IAEA,IAAI,qBAAqB;QACvB,MAAM,QAAQ,CAAC;QAEf,IAAI,SACF;IAEJ;IAEA,IAAI,eAAe;QACjB,+FAA+F;QAC/F,mCAAmC;QACnC,SAAS,OAAO,EAAE;IACpB;IAEA,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAE,GAAG,YAAW,GAAG,CAAA,GAAA,wCAAW,EAC5F;QACE,GAAG,KAAK;QACR,OAAO,MAAM,KAAK;QAClB,UAAU,MAAM,QAAQ;QACxB,WAAW,CAAC,aAAa,CAAA,GAAA,yCAAI,EAAE,WAAW,MAAM,SAAS,IAAI,MAAM,SAAS;cAC5E;IACF,GACA;IAGF,OAAO;oBACL;QACA,YAAY;YACV,GAAG,UAAU;YACb,yCAAyC;YACzC,cAAc;QAChB;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,qBAAqB;YACrB,qBAAqB;YACrB,YAAY,cAAc;YAC1B,SAAS;0BACT;QACF;0BACA;2BACA;QACA,GAAG,UAAU;IACf;AACF","sources":["packages/react-aria/src/searchfield/useSearchField.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaTextFieldProps, useTextField} from '../textfield/useTextField';\nimport {chain} from '../utils/chain';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\n// @ts-ignore\nimport intlMessages from '../../intl/searchfield/*.json';\nimport {SearchFieldProps, SearchFieldState} from 'react-stately/useSearchFieldState';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaSearchFieldProps extends SearchFieldProps, Omit<AriaTextFieldProps, 'type'> {\n /**\n * An enumerated attribute that defines what action label or icon to preset for the enter key on\n * virtual keyboards. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).\n */\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n /**\n * The type of input to render. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).\n *\n * @default 'search'\n */\n type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {});\n}\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps;\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n *\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {isDisabled, isReadOnly, onSubmit, onClear, type = 'search'} = props;\n\n let onKeyDown = e => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField(\n {\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n },\n inputRef\n );\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.mjs.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+CM,SAAS,0CACd,KAA2B,EAC3B,KAAuB,EACvB,QAA4C;IAE5C,IAAI,kBAAkB,CAAA,GAAA,yCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAChE,IAAI,cAAC,UAAU,cAAE,UAAU,YAAE,QAAQ,WAAE,OAAO,QAAE,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Content":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\nimport {AriaTextFieldProps, useTextField} from '../textfield/useTextField';\nimport {chain} from '../utils/chain';\nimport {DOMAttributes, RefObject, ValidationResult} from '@react-types/shared';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport intlMessages from '../../intl/searchfield/*.json';\nimport {SearchFieldProps, SearchFieldState} from 'react-stately/useSearchFieldState';\nimport {useLocalizedStringFormatter} from '../i18n/useLocalizedStringFormatter';\n\nexport interface AriaSearchFieldProps extends SearchFieldProps, Omit<AriaTextFieldProps, 'type'> {\n /**\n * An enumerated attribute that defines what action label or icon to preset for the enter key on\n * virtual keyboards. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint).\n */\n enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';\n /**\n * The type of input to render. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdeftype).\n *\n * @default 'search'\n */\n type?: 'text' | 'search' | 'url' | 'tel' | 'email' | 'password' | (string & {});\n}\n\nexport interface SearchFieldAria extends ValidationResult {\n /** Props for the text field's visible label element (if any). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>;\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>;\n /** Props for the clear button. */\n clearButtonProps: AriaButtonProps;\n /** Props for the searchfield's description element, if any. */\n descriptionProps: DOMAttributes;\n /** Props for the searchfield's error message element, if any. */\n errorMessageProps: DOMAttributes;\n}\n\n/**\n * Provides the behavior and accessibility implementation for a search field.\n *\n * @param props - Props for the search field.\n * @param state - State for the search field, as returned by `useSearchFieldState`.\n * @param inputRef - A ref to the input element.\n */\nexport function useSearchField(\n props: AriaSearchFieldProps,\n state: SearchFieldState,\n inputRef: RefObject<HTMLInputElement | null>\n): SearchFieldAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/searchfield');\n let {isDisabled, isReadOnly, onSubmit, onClear, type = 'search'} = props;\n\n let onKeyDown = e => {\n const key = e.key;\n\n if (key === 'Enter' && (isDisabled || isReadOnly)) {\n e.preventDefault();\n }\n\n if (isDisabled || isReadOnly) {\n return;\n }\n\n // for backward compatibility;\n // otherwise, \"Enter\" on an input would trigger a form submit, the default browser behavior\n if (key === 'Enter' && onSubmit) {\n e.preventDefault();\n onSubmit(state.value);\n }\n\n if (key === 'Escape') {\n // Also check the inputRef value for the case where the value was set directly on the input element instead of going through\n // the hook\n if (state.value === '' && (!inputRef.current || inputRef.current.value === '')) {\n e.continuePropagation();\n } else {\n e.preventDefault();\n state.setValue('');\n if (onClear) {\n onClear();\n }\n }\n }\n };\n\n let onClearButtonClick = () => {\n state.setValue('');\n\n if (onClear) {\n onClear();\n }\n };\n\n let onPressStart = () => {\n // this is in PressStart for mobile so that touching the clear button doesn't remove focus from\n // the input and close the keyboard\n inputRef.current?.focus();\n };\n\n let {labelProps, inputProps, descriptionProps, errorMessageProps, ...validation} = useTextField(\n {\n ...props,\n value: state.value,\n onChange: state.setValue,\n onKeyDown: !isReadOnly ? chain(onKeyDown, props.onKeyDown) : props.onKeyDown,\n type\n },\n inputRef\n );\n\n return {\n labelProps,\n inputProps: {\n ...inputProps,\n // already handled by useSearchFieldState\n defaultValue: undefined\n },\n clearButtonProps: {\n 'aria-label': stringFormatter.format('Clear search'),\n excludeFromTabOrder: true,\n preventFocusOnPress: true,\n isDisabled: isDisabled || isReadOnly,\n onPress: onClearButtonClick,\n onPressStart\n },\n descriptionProps,\n errorMessageProps,\n ...validation\n };\n}\n"],"names":[],"version":3,"file":"useSearchField.mjs.map"}
@@ -95,8 +95,6 @@ function $60b1d3323c1be9a0$export$e64b2f635402ca43(props, state, ref) {
95
95
  isInvalid: isInvalid,
96
96
  errorMessage: props.errorMessage || validationErrors
97
97
  });
98
- typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
99
- delete typeSelectProps.onKeyDownCapture;
100
98
  if (state.selectionManager.selectionMode === 'multiple') typeSelectProps = {};
101
99
  let domProps = (0, $b97366b6eabbb2cc$exports.filterDOMProps)(props, {
102
100
  labelable: true
@@ -149,6 +147,7 @@ function $60b1d3323c1be9a0$export$e64b2f635402ca43(props, state, ref) {
149
147
  },
150
148
  menuProps: {
151
149
  ...menuProps,
150
+ onAction: undefined,
152
151
  autoFocus: state.focusStrategy || true,
153
152
  shouldSelectOnPressUp: true,
154
153
  shouldFocusOnHover: true,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA0FM,MAAM,4CAAyD,IAAI;AAYnE,SAAS,0CACd,KAA8B,EAC9B,KAAwB,EACxB,GAAkC;IAElC,IAAI,oBAAC,gBAAgB,cAAE,UAAU,cAAE,UAAU,QAAE,IAAI,QAAE,IAAI,sBAAE,qBAAqB,QAAO,GAAG;IAE1F,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,qCAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,WAAW,CAAA,GAAA,oBAAM,EACnB,IACE,oBACA,IAAI,CAAA,GAAA,8CAAmB,EAAE,MAAM,UAAU,EAAE,MAAM,YAAY,EAAE,KAAK,WACtE;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;QAAU;KAAI;IAGzE,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,wCAAa,EAC/C;oBACE;QACA,MAAM;IACR,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,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,mBAAmB;gBACjB,UAAU,CAAC,kBAAkB;gBAC7B,YAAY,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aAClF,CACE,MAAM,CAAC,SACP,IAAI,CAAC;QACV;0BACA;2BACA;mBACA;0BACA;2BACA;QACA,mBAAmB;wBACjB;kBACA;YACA,OAAO,MAAM,KAAK;mBAClB;YACA,YAAY;kBACZ;QACF;IACF;AACF","sources":["packages/react-aria/src/select/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\n\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n FocusableDOMProps,\n KeyboardDelegate,\n RefObject,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEvent, useMemo} from 'react';\nimport {HiddenSelectProps} from './HiddenSelect';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {SelectionMode, SelectProps, SelectState} from 'react-stately/useSelectState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useCollator} from '../i18n/useCollator';\nimport {useField} from '../label/useField';\nimport {useId} from '../utils/useId';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useTypeSelect} from '../selection/useTypeSelect';\n\nexport interface AriaSelectProps<T, M extends SelectionMode = 'single'>\n extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {\n /**\n * Describes the type of autocomplete functionality the input should provide if any. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n */\n autoComplete?: string;\n /**\n * The name of the input, used when submitting an HTML form.\n */\n name?: string;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface AriaSelectOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaSelectProps<T, M>,\n 'children'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface SelectAria<T, M extends SelectionMode = 'single'> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps;\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>;\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes;\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes;\n\n /** Props for the hidden select element. */\n hiddenSelectProps: HiddenSelectProps<T, M>;\n}\n\ninterface SelectData {\n isDisabled?: boolean;\n isRequired?: boolean;\n name?: string;\n form?: string;\n validationBehavior?: 'aria' | 'native';\n}\n\nexport const selectData: WeakMap<SelectState<any, any>, SelectData> = new WeakMap<\n SelectState<any>,\n SelectData\n>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n *\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T, M extends SelectionMode = 'single'>(\n props: AriaSelectOptions<T, M>,\n state: SelectState<T, M>,\n ref: RefObject<HTMLElement | null>\n): SelectAria<T, M> {\n let {keyboardDelegate, isDisabled, isRequired, name, form, validationBehavior = 'aria'} = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate(state.collection, state.disabledKeys, ref, collator),\n [keyboardDelegate, state.collection, state.disabledKeys, collator, ref]\n );\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (state.selectionManager.selectionMode === 'multiple') {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyAbove?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyBelow?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;\n delete typeSelectProps.onKeyDownCapture;\n if (state.selectionManager.selectionMode === 'multiple') {\n typeSelectProps = {};\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n form,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current?.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: e => {\n if (nodeContains(e.currentTarget, e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails,\n hiddenSelectProps: {\n isDisabled,\n name,\n label: props.label,\n state,\n triggerRef: ref,\n form\n }\n };\n}\n"],"names":[],"version":3,"file":"useSelect.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA0FM,MAAM,4CAAyD,IAAI;AAYnE,SAAS,0CACd,KAA8B,EAC9B,KAAwB,EACxB,GAAkC;IAElC,IAAI,oBAAC,gBAAgB,cAAE,UAAU,cAAE,UAAU,QAAE,IAAI,QAAE,IAAI,sBAAE,qBAAqB,QAAO,GAAG;IAE1F,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,qCAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,WAAW,CAAA,GAAA,oBAAM,EACnB,IACE,oBACA,IAAI,CAAA,GAAA,8CAAmB,EAAE,MAAM,UAAU,EAAE,MAAM,YAAY,EAAE,KAAK,WACtE;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;QAAU;KAAI;IAGzE,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,wCAAa,EAC/C;oBACE;QACA,MAAM;IACR,GACA,OACA;IAGF,IAAI,YAAY,CAAC;QACf,IAAI,MAAM,gBAAgB,CAAC,aAAa,KAAK,YAC3C;QAGF,OAAQ,EAAE,GAAG;YACX,KAAK;gBAAa;oBAChB,+BAA+B;oBAC/B,EAAE,cAAc;oBAEhB,IAAI,MACF,MAAM,WAAW,IAAI,OACjB,SAAS,WAAW,GAAG,MAAM,WAAW,IACxC,SAAS,WAAW;oBAC1B,IAAI,OAAO,MACT,MAAM,cAAc,CAAC;oBAEvB;gBACF;YACA,KAAK;gBAAc;oBACjB,+BAA+B;oBAC/B,EAAE,cAAc;oBAEhB,IAAI,MACF,MAAM,WAAW,IAAI,OACjB,SAAS,WAAW,GAAG,MAAM,WAAW,IAC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Y,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aACpF,CACE,MAAM,CAAC,SACP,IAAI,CAAC;YACR,SAAQ,CAAa;gBACnB,IAAI,MAAM,SAAS,EACjB;gBAGF,IAAI,MAAM,OAAO,EACf,MAAM,OAAO,CAAC;gBAGhB,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,QAAO,CAAa;gBAClB,IAAI,MAAM,MAAM,EACd;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;QACF;QACA,YAAY;YACV,IAAI;QACN;QACA,WAAW;YACT,GAAG,SAAS;YACZ,UAAU;YACV,WAAW,MAAM,aAAa,IAAI;YAClC,uBAAuB;YACvB,oBAAoB;YACpB,wBAAwB;YACxB,cAAc;YACd,QAAQ,CAAA;gBACN,IAAI,CAAA,GAAA,sCAAW,EAAE,EAAE,aAAa,EAAE,EAAE,aAAa,GAC/C;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,mBAAmB;gBACjB,UAAU,CAAC,kBAAkB;gBAC7B,YAAY,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aAClF,CACE,MAAM,CAAC,SACP,IAAI,CAAC;QACV;0BACA;2BACA;mBACA;0BACA;2BACA;QACA,mBAAmB;wBACjB;kBACA;YACA,OAAO,MAAM,KAAK;mBAClB;YACA,YAAY;kBACZ;QACF;IACF;AACF","sources":["packages/react-aria/src/select/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\n\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n FocusableDOMProps,\n KeyboardDelegate,\n RefObject,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEvent, useMemo} from 'react';\nimport {HiddenSelectProps} from './HiddenSelect';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {SelectionMode, SelectProps, SelectState} from 'react-stately/useSelectState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useCollator} from '../i18n/useCollator';\nimport {useField} from '../label/useField';\nimport {useId} from '../utils/useId';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useTypeSelect} from '../selection/useTypeSelect';\n\nexport interface AriaSelectProps<T, M extends SelectionMode = 'single'>\n extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {\n /**\n * Describes the type of autocomplete functionality the input should provide if any. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n */\n autoComplete?: string;\n /**\n * The name of the input, used when submitting an HTML form.\n */\n name?: string;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface AriaSelectOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaSelectProps<T, M>,\n 'children'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface SelectAria<T, M extends SelectionMode = 'single'> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps;\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>;\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes;\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes;\n\n /** Props for the hidden select element. */\n hiddenSelectProps: HiddenSelectProps<T, M>;\n}\n\ninterface SelectData {\n isDisabled?: boolean;\n isRequired?: boolean;\n name?: string;\n form?: string;\n validationBehavior?: 'aria' | 'native';\n}\n\nexport const selectData: WeakMap<SelectState<any, any>, SelectData> = new WeakMap<\n SelectState<any>,\n SelectData\n>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n *\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T, M extends SelectionMode = 'single'>(\n props: AriaSelectOptions<T, M>,\n state: SelectState<T, M>,\n ref: RefObject<HTMLElement | null>\n): SelectAria<T, M> {\n let {keyboardDelegate, isDisabled, isRequired, name, form, validationBehavior = 'aria'} = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate(state.collection, state.disabledKeys, ref, collator),\n [keyboardDelegate, state.collection, state.disabledKeys, collator, ref]\n );\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (state.selectionManager.selectionMode === 'multiple') {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyAbove?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyBelow?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n if (state.selectionManager.selectionMode === 'multiple') {\n typeSelectProps = {};\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n form,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current?.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: e => {\n if (nodeContains(e.currentTarget, e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails,\n hiddenSelectProps: {\n isDisabled,\n name,\n label: props.label,\n state,\n triggerRef: ref,\n form\n }\n };\n}\n"],"names":[],"version":3,"file":"useSelect.cjs.map"}
@@ -90,8 +90,6 @@ function $960d44b6aa09c372$export$e64b2f635402ca43(props, state, ref) {
90
90
  isInvalid: isInvalid,
91
91
  errorMessage: props.errorMessage || validationErrors
92
92
  });
93
- typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
94
- delete typeSelectProps.onKeyDownCapture;
95
93
  if (state.selectionManager.selectionMode === 'multiple') typeSelectProps = {};
96
94
  let domProps = (0, $6a28a4717b9a4e1c$export$457c3d6518dd4c6f)(props, {
97
95
  labelable: true
@@ -145,6 +143,7 @@ function $960d44b6aa09c372$export$e64b2f635402ca43(props, state, ref) {
145
143
  },
146
144
  menuProps: {
147
145
  ...menuProps,
146
+ onAction: undefined,
148
147
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AK;mBAClB;YACA,YAAY;kBACZ;QACF;IACF;AACF","sources":["packages/react-aria/src/select/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\n\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n FocusableDOMProps,\n KeyboardDelegate,\n RefObject,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEvent, useMemo} from 'react';\nimport {HiddenSelectProps} from './HiddenSelect';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {SelectionMode, SelectProps, SelectState} from 'react-stately/useSelectState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useCollator} from '../i18n/useCollator';\nimport {useField} from '../label/useField';\nimport {useId} from '../utils/useId';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useTypeSelect} from '../selection/useTypeSelect';\n\nexport interface AriaSelectProps<T, M extends SelectionMode = 'single'>\n extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {\n /**\n * Describes the type of autocomplete functionality the input should provide if any. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n */\n autoComplete?: string;\n /**\n * The name of the input, used when submitting an HTML form.\n */\n name?: string;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface AriaSelectOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaSelectProps<T, M>,\n 'children'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface SelectAria<T, M extends SelectionMode = 'single'> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps;\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>;\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes;\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes;\n\n /** Props for the hidden select element. */\n hiddenSelectProps: HiddenSelectProps<T, M>;\n}\n\ninterface SelectData {\n isDisabled?: boolean;\n isRequired?: boolean;\n name?: string;\n form?: string;\n validationBehavior?: 'aria' | 'native';\n}\n\nexport const selectData: WeakMap<SelectState<any, any>, SelectData> = new WeakMap<\n SelectState<any>,\n SelectData\n>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n *\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T, M extends SelectionMode = 'single'>(\n props: AriaSelectOptions<T, M>,\n state: SelectState<T, M>,\n ref: RefObject<HTMLElement | null>\n): SelectAria<T, M> {\n let {keyboardDelegate, isDisabled, isRequired, name, form, validationBehavior = 'aria'} = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate(state.collection, state.disabledKeys, ref, collator),\n [keyboardDelegate, state.collection, state.disabledKeys, collator, ref]\n );\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (state.selectionManager.selectionMode === 'multiple') {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyAbove?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyBelow?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;\n delete typeSelectProps.onKeyDownCapture;\n if (state.selectionManager.selectionMode === 'multiple') {\n typeSelectProps = {};\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n form,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current?.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: e => {\n if (nodeContains(e.currentTarget, e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails,\n hiddenSelectProps: {\n isDisabled,\n name,\n label: props.label,\n state,\n triggerRef: ref,\n form\n }\n };\n}\n"],"names":[],"version":3,"file":"useSelect.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA0FM,MAAM,4CAAyD,IAAI;AAYnE,SAAS,0CACd,KAA8B,EAC9B,KAAwB,EACxB,GAAkC;IAElC,IAAI,oBAAC,gBAAgB,cAAE,UAAU,cAAE,UAAU,QAAE,IA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AGhB,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,QAAO,CAAa;gBAClB,IAAI,MAAM,MAAM,EACd;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;QACF;QACA,YAAY;YACV,IAAI;QACN;QACA,WAAW;YACT,GAAG,SAAS;YACZ,UAAU;YACV,WAAW,MAAM,aAAa,IAAI;YAClC,uBAAuB;YACvB,oBAAoB;YACpB,wBAAwB;YACxB,cAAc;YACd,QAAQ,CAAA;gBACN,IAAI,CAAA,GAAA,yCAAW,EAAE,EAAE,aAAa,EAAE,EAAE,aAAa,GAC/C;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,mBAAmB;gBACjB,UAAU,CAAC,kBAAkB;gBAC7B,YAAY,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aAClF,CACE,MAAM,CAAC,SACP,IAAI,CAAC;QACV;0BACA;2BACA;mBACA;0BACA;2BACA;QACA,mBAAmB;wBACjB;kBACA;YACA,OAAO,MAAM,KAAK;mBAClB;YACA,YAAY;kBACZ;QACF;IACF;AACF","sources":["packages/react-aria/src/select/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\n\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n FocusableDOMProps,\n KeyboardDelegate,\n RefObject,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEvent, useMemo} from 'react';\nimport {HiddenSelectProps} from './HiddenSelect';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {SelectionMode, SelectProps, SelectState} from 'react-stately/useSelectState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useCollator} from '../i18n/useCollator';\nimport {useField} from '../label/useField';\nimport {useId} from '../utils/useId';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useTypeSelect} from '../selection/useTypeSelect';\n\nexport interface AriaSelectProps<T, M extends SelectionMode = 'single'>\n extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {\n /**\n * Describes the type of autocomplete functionality the input should provide if any. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n */\n autoComplete?: string;\n /**\n * The name of the input, used when submitting an HTML form.\n */\n name?: string;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface AriaSelectOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaSelectProps<T, M>,\n 'children'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface SelectAria<T, M extends SelectionMode = 'single'> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps;\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>;\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes;\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes;\n\n /** Props for the hidden select element. */\n hiddenSelectProps: HiddenSelectProps<T, M>;\n}\n\ninterface SelectData {\n isDisabled?: boolean;\n isRequired?: boolean;\n name?: string;\n form?: string;\n validationBehavior?: 'aria' | 'native';\n}\n\nexport const selectData: WeakMap<SelectState<any, any>, SelectData> = new WeakMap<\n SelectState<any>,\n SelectData\n>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n *\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T, M extends SelectionMode = 'single'>(\n props: AriaSelectOptions<T, M>,\n state: SelectState<T, M>,\n ref: RefObject<HTMLElement | null>\n): SelectAria<T, M> {\n let {keyboardDelegate, isDisabled, isRequired, name, form, validationBehavior = 'aria'} = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate(state.collection, state.disabledKeys, ref, collator),\n [keyboardDelegate, state.collection, state.disabledKeys, collator, ref]\n );\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (state.selectionManager.selectionMode === 'multiple') {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyAbove?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyBelow?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n if (state.selectionManager.selectionMode === 'multiple') {\n typeSelectProps = {};\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n form,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current?.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: e => {\n if (nodeContains(e.currentTarget, e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails,\n hiddenSelectProps: {\n isDisabled,\n name,\n label: props.label,\n state,\n triggerRef: ref,\n form\n }\n };\n}\n"],"names":[],"version":3,"file":"useSelect.js.map"}
@@ -88,8 +88,6 @@ function $c0a45cd074520508$export$e64b2f635402ca43(props, state, ref) {
88
88
  isInvalid: isInvalid,
89
89
  errorMessage: props.errorMessage || validationErrors
90
90
  });
91
- typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
92
- delete typeSelectProps.onKeyDownCapture;
93
91
  if (state.selectionManager.selectionMode === 'multiple') typeSelectProps = {};
94
92
  let domProps = (0, $8e9d2fae0ecb9001$export$457c3d6518dd4c6f)(props, {
95
93
  labelable: true
@@ -142,6 +140,7 @@ function $c0a45cd074520508$export$e64b2f635402ca43(props, state, ref) {
142
140
  },
143
141
  menuProps: {
144
142
  ...menuProps,
143
+ onAction: undefined,
145
144
  autoFocus: state.focusStrategy || true,
146
145
  shouldSelectOnPressUp: true,
147
146
  shouldFocusOnHover: true,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA0FM,MAAM,4CAAyD,IAAI;AAYnE,SA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AAO,CAAC;gBAGhB,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,QAAO,CAAa;gBAClB,IAAI,MAAM,MAAM,EACd;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;QACF;QACA,YAAY;YACV,IAAI;QACN;QACA,WAAW;YACT,GAAG,SAAS;YACZ,WAAW,MAAM,aAAa,IAAI;YAClC,uBAAuB;YACvB,oBAAoB;YACpB,wBAAwB;YACxB,cAAc;YACd,QAAQ,CAAA;gBACN,IAAI,CAAA,GAAA,yCAAW,EAAE,EAAE,aAAa,EAAE,EAAE,aAAa,GAC/C;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,mBAAmB;gBACjB,UAAU,CAAC,kBAAkB;gBAC7B,YAAY,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aAClF,CACE,MAAM,CAAC,SACP,IAAI,CAAC;QACV;0BACA;2BACA;mBACA;0BACA;2BACA;QACA,mBAAmB;wBACjB;kBACA;YACA,OAAO,MAAM,KAAK;mBAClB;YACA,YAAY;kBACZ;QACF;IACF;AACF","sources":["packages/react-aria/src/select/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\n\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n FocusableDOMProps,\n KeyboardDelegate,\n RefObject,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEvent, useMemo} from 'react';\nimport {HiddenSelectProps} from './HiddenSelect';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {SelectionMode, SelectProps, SelectState} from 'react-stately/useSelectState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useCollator} from '../i18n/useCollator';\nimport {useField} from '../label/useField';\nimport {useId} from '../utils/useId';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useTypeSelect} from '../selection/useTypeSelect';\n\nexport interface AriaSelectProps<T, M extends SelectionMode = 'single'>\n extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {\n /**\n * Describes the type of autocomplete functionality the input should provide if any. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n */\n autoComplete?: string;\n /**\n * The name of the input, used when submitting an HTML form.\n */\n name?: string;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface AriaSelectOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaSelectProps<T, M>,\n 'children'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface SelectAria<T, M extends SelectionMode = 'single'> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps;\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>;\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes;\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes;\n\n /** Props for the hidden select element. */\n hiddenSelectProps: HiddenSelectProps<T, M>;\n}\n\ninterface SelectData {\n isDisabled?: boolean;\n isRequired?: boolean;\n name?: string;\n form?: string;\n validationBehavior?: 'aria' | 'native';\n}\n\nexport const selectData: WeakMap<SelectState<any, any>, SelectData> = new WeakMap<\n SelectState<any>,\n SelectData\n>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n *\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T, M extends SelectionMode = 'single'>(\n props: AriaSelectOptions<T, M>,\n state: SelectState<T, M>,\n ref: RefObject<HTMLElement | null>\n): SelectAria<T, M> {\n let {keyboardDelegate, isDisabled, isRequired, name, form, validationBehavior = 'aria'} = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate(state.collection, state.disabledKeys, ref, collator),\n [keyboardDelegate, state.collection, state.disabledKeys, collator, ref]\n );\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (state.selectionManager.selectionMode === 'multiple') {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyAbove?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyBelow?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;\n delete typeSelectProps.onKeyDownCapture;\n if (state.selectionManager.selectionMode === 'multiple') {\n typeSelectProps = {};\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n form,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current?.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: e => {\n if (nodeContains(e.currentTarget, e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails,\n hiddenSelectProps: {\n isDisabled,\n name,\n label: props.label,\n state,\n triggerRef: ref,\n form\n }\n };\n}\n"],"names":[],"version":3,"file":"useSelect.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;AA0FM,MAAM,4CAAyD,IAAI;AAYnE,SAAS,0CACd,KAA8B,EAC9B,KAAwB,EACxB,GAAkC;IAElC,IAAI,oBAAC,gBAAgB,cAAE,UAAU,cAAE,UAAU,QAAE,IAAI,QAAE,IAAI,sBAAE,qBAAqB,QAAO,GAAG;IAE1F,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,yCAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,WAAW,CAAA,GAAA,cAAM,EACnB,IACE,oBACA,IAAI,CAAA,GAAA,yCAAmB,EAAE,MAAM,UAAU,EAAE,MAAM,YAAY,EAAE,KAAK,WACtE;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;QAAU;KAAI;IAGz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IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,mBAAmB;gBACjB,UAAU,CAAC,kBAAkB;gBAC7B,YAAY,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aAClF,CACE,MAAM,CAAC,SACP,IAAI,CAAC;QACV;0BACA;2BACA;mBACA;0BACA;2BACA;QACA,mBAAmB;wBACjB;kBACA;YACA,OAAO,MAAM,KAAK;mBAClB;YACA,YAAY;kBACZ;QACF;IACF;AACF","sources":["packages/react-aria/src/select/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '../button/useButton';\n\nimport {\n AriaLabelingProps,\n DOMAttributes,\n DOMProps,\n FocusableDOMProps,\n KeyboardDelegate,\n RefObject,\n ValidationResult\n} from '@react-types/shared';\nimport {AriaListBoxOptions} from '../listbox/useListBox';\nimport {chain} from '../utils/chain';\nimport {filterDOMProps} from '../utils/filterDOMProps';\nimport {FocusEvent, useMemo} from 'react';\nimport {HiddenSelectProps} from './HiddenSelect';\nimport {ListKeyboardDelegate} from '../selection/ListKeyboardDelegate';\nimport {mergeProps} from '../utils/mergeProps';\nimport {nodeContains} from '../utils/shadowdom/DOMFunctions';\nimport {SelectionMode, SelectProps, SelectState} from 'react-stately/useSelectState';\nimport {setInteractionModality} from '../interactions/useFocusVisible';\nimport {useCollator} from '../i18n/useCollator';\nimport {useField} from '../label/useField';\nimport {useId} from '../utils/useId';\nimport {useMenuTrigger} from '../menu/useMenuTrigger';\nimport {useTypeSelect} from '../selection/useTypeSelect';\n\nexport interface AriaSelectProps<T, M extends SelectionMode = 'single'>\n extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {\n /**\n * Describes the type of autocomplete functionality the input should provide if any. See\n * [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n */\n autoComplete?: string;\n /**\n * The name of the input, used when submitting an HTML form.\n */\n name?: string;\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string;\n}\n\nexport interface AriaSelectOptions<T, M extends SelectionMode = 'single'> extends Omit<\n AriaSelectProps<T, M>,\n 'children'\n> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate;\n}\n\nexport interface SelectAria<T, M extends SelectionMode = 'single'> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes;\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps;\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes;\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>;\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes;\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes;\n\n /** Props for the hidden select element. */\n hiddenSelectProps: HiddenSelectProps<T, M>;\n}\n\ninterface SelectData {\n isDisabled?: boolean;\n isRequired?: boolean;\n name?: string;\n form?: string;\n validationBehavior?: 'aria' | 'native';\n}\n\nexport const selectData: WeakMap<SelectState<any, any>, SelectData> = new WeakMap<\n SelectState<any>,\n SelectData\n>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n *\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T, M extends SelectionMode = 'single'>(\n props: AriaSelectOptions<T, M>,\n state: SelectState<T, M>,\n ref: RefObject<HTMLElement | null>\n): SelectAria<T, M> {\n let {keyboardDelegate, isDisabled, isRequired, name, form, validationBehavior = 'aria'} = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(\n () =>\n keyboardDelegate ||\n new ListKeyboardDelegate(state.collection, state.disabledKeys, ref, collator),\n [keyboardDelegate, state.collection, state.disabledKeys, collator, ref]\n );\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n if (state.selectionManager.selectionMode === 'multiple') {\n return;\n }\n\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyAbove?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key =\n state.selectedKey != null\n ? delegate.getKeyBelow?.(state.selectedKey)\n : delegate.getFirstKey?.();\n if (key != null) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n if (state.selectionManager.selectionMode === 'multiple') {\n typeSelectProps = {};\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n form,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current?.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n onAction: undefined,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: e => {\n if (nodeContains(e.currentTarget, e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ]\n .filter(Boolean)\n .join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails,\n hiddenSelectProps: {\n isDisabled,\n name,\n label: props.label,\n state,\n triggerRef: ref,\n form\n }\n };\n}\n"],"names":[],"version":3,"file":"useSelect.mjs.map"}
@@ -1,4 +1,5 @@
1
1
  var $0e21c65e8f2fcfc9$exports = require("./DOMLayoutDelegate.cjs");
2
+ var $b07dd3d1fedd87d6$exports = require("./utils.cjs");
2
3
  var $c3942aba3ca10757$exports = require("../utils/isScrollable.cjs");
3
4
 
4
5
 
@@ -19,6 +20,7 @@ $parcel$export(module.exports, "ListKeyboardDelegate", function () { return $22e
19
20
  * governing permissions and limitations under the License.
20
21
  */
21
22
 
23
+
22
24
  class $22ef0686d6af4fda$export$a05409b8bb224a5a {
23
25
  constructor(...args){
24
26
  if (args.length === 1) {
@@ -90,12 +92,34 @@ class $22ef0686d6af4fda$export$a05409b8bb224a5a {
90
92
  isSameColumn(prevRect, itemRect) {
91
93
  return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;
92
94
  }
95
+ // checks to see if the next/prev key is spatially above/below the current key. If not, that means we are in
96
+ // a reversed column layout and need to adjust appropriately
97
+ // TODO: still need to see how this works with virtualizer once there is handling for the reverse layout
98
+ // this felt like a simpler approach then changing getKeyAbove/Below to be purely spatial calculations
99
+ isReversed(key) {
100
+ let nextKey = this.getNextKey(key);
101
+ let currentEl = (0, $b07dd3d1fedd87d6$exports.getItemElement)(this.ref, key);
102
+ if (nextKey != null) {
103
+ let nextEl = (0, $b07dd3d1fedd87d6$exports.getItemElement)(this.ref, nextKey);
104
+ if (!currentEl || !nextEl) return false;
105
+ return currentEl.getBoundingClientRect().top > nextEl.getBoundingClientRect().top;
106
+ }
107
+ let prevKey = this.getPreviousKey(key);
108
+ if (prevKey != null) {
109
+ let prevEl = (0, $b07dd3d1fedd87d6$exports.getItemElement)(this.ref, prevKey);
110
+ if (!currentEl || !prevEl) return false;
111
+ return prevEl.getBoundingClientRect().top > currentEl.getBoundingClientRect().top;
112
+ }
113
+ return false;
114
+ }
93
115
  getKeyBelow(key, options) {
94
116
  if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getNextKey(key, options), this.isSameRow);
117
+ else if (this.orientation === 'vertical') return this.isReversed(key) ? this.getPreviousKey(key, options) : this.getNextKey(key, options);
95
118
  else return this.getNextKey(key, options);
96
119
  }
97
120
  getKeyAbove(key, options) {
98
121
  if (this.layout === 'grid' && this.orientation === 'vertical') return this.findKey(key, (key)=>this.getPreviousKey(key, options), this.isSameRow);
122
+ else if (this.orientation === 'vertical') return this.isReversed(key) ? this.getNextKey(key, options) : this.getPreviousKey(key, options);
99
123
  else return this.getPreviousKey(key, options);
100
124
  }
101
125
  getNextColumn(key, right, options) {
@@ -139,6 +163,7 @@ class $22ef0686d6af4fda$export$a05409b8bb224a5a {
139
163
  let menu = this.ref.current;
140
164
  let itemRect = this.layoutDelegate.getItemRect(key);
141
165
  if (!itemRect) return null;
166
+ let reversed = this.isReversed(key);
142
167
  if (menu && !(0, $c3942aba3ca10757$exports.isScrollable)(menu)) return this.getFirstKey();
143
168
  let nextKey = key;
144
169
  if (this.orientation === 'horizontal') {
@@ -148,18 +173,21 @@ class $22ef0686d6af4fda$export$a05409b8bb224a5a {
148
173
  itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
149
174
  }
150
175
  } else {
151
- let pageY = Math.max(0, itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height);
176
+ let visibleRect = this.layoutDelegate.getVisibleRect();
177
+ // column reverse makes y negative for items so we need to instead do current pos - height instead
178
+ let pageY = reversed ? itemRect.y - visibleRect.height : Math.max(0, itemRect.y + itemRect.height - visibleRect.height);
152
179
  while(itemRect && itemRect.y > pageY && nextKey != null){
153
180
  nextKey = this.getKeyAbove(nextKey);
154
181
  itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
155
182
  }
156
183
  }
157
- return nextKey ?? this.getFirstKey();
184
+ return nextKey ?? (reversed ? this.getLastKey() : this.getFirstKey());
158
185
  }
159
186
  getKeyPageBelow(key) {
160
187
  let menu = this.ref.current;
161
188
  let itemRect = this.layoutDelegate.getItemRect(key);
162
189
  if (!itemRect) return null;
190
+ let reversed = this.isReversed(key);
163
191
  if (menu && !(0, $c3942aba3ca10757$exports.isScrollable)(menu)) return this.getLastKey();
164
192
  let nextKey = key;
165
193
  if (this.orientation === 'horizontal') {
@@ -175,7 +203,7 @@ class $22ef0686d6af4fda$export$a05409b8bb224a5a {
175
203
  itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);
176
204
  }
177
205
  }
178
- return nextKey ?? this.getLastKey();
206
+ return nextKey ?? (reversed ? this.getFirstKey() : this.getLastKey());
179
207
  }
180
208
  getKeyForSearch(search, fromKey) {
181
209
  if (!this.collator) return null;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA6BM,MAAM;IAmBX,YAAY,GAAG,IAAW,CAAE;QAC1B,IAAI,KAAK,MAAM,KAAK,GAAG;YACrB,IAAI,OAAO,IAAI,CAAC,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,KAAK,UAAU;YACjC,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG;YACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,QAAQ;YAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,YAAY,IAAI,IAAI;YAC7C,IAAI,CAAC,gBAAgB,GAAG,KAAK,gBAAgB,IAAI;YACjD,IAAI,CAAC,WAAW,GAAG,KAAK,WAAW,IAAI;YACvC,IAAI,CAAC,SAAS,GAAG,KAAK,SAAS;YAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,MAAM,IAAI;YAC7B,IAAI,CAAC,cAAc,GAAG,KAAK,cAAc,IAAI,IAAI,CAAA,GAAA,2CAAgB,EAAE,KAAK,GAAG;QAC7E,OAAO;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE;YACzB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE;YAC3B,IAAI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,SAAS,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,GAAG,MAAM;YAG5E,MAAO,YAAY,SAAS,CAAC,GAAG,SAAS,WAAW,KAAM;gBACxD,UAAU,IAAI,CAAC,WAAW,CAAC;gBAC3B,WAAW,WAAW,OAAO,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;YACtE;QACF;QAEA,OAAO,WAAW,IAAI,CAAC,UAAU;IACnC;IAEA,gBAAgB,MAAc,EAAE,OAAa,EAAc;QACzD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAChB,OAAO;QAGT,IAAI,aAAa,IAAI,CAAC,UAAU;QAChC,IAAI,MAAM,WAAW,IAAI,CAAC,WAAW;QACrC,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,WAAW,OAAO,CAAC;YAC9B,IAAI,CAAC,MACH,OAAO;YAET,IAAI,YAAY,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,MAAM;YACrD,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,YAAY,GACjE,OAAO;YAGT,MAAM,IAAI,CAAC,UAAU,CAAC;QACxB;QAEA,OAAO;IACT;AACF","sources":["packages/react-aria/src/selection/ListKeyboardDelegate.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n Collection,\n Direction,\n DisabledBehavior,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n Node,\n Orientation,\n Rect,\n RefObject\n} from '@react-types/shared';\nimport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nimport {isScrollable} from '../utils/isScrollable';\n\ninterface ListKeyboardDelegateOptions<T> {\n collection: Collection<Node<T>>;\n ref: RefObject<HTMLElement | null>;\n collator?: Intl.Collator;\n layout?: 'stack' | 'grid';\n orientation?: Orientation;\n direction?: Direction;\n disabledKeys?: Set<Key>;\n disabledBehavior?: DisabledBehavior;\n layoutDelegate?: LayoutDelegate;\n}\n\nexport class ListKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<Node<T>>;\n private disabledKeys: Set<Key>;\n private disabledBehavior: DisabledBehavior;\n private ref: RefObject<HTMLElement | null>;\n private collator: Intl.Collator | undefined;\n private layout: 'stack' | 'grid';\n private orientation?: Orientation;\n private direction?: Direction;\n private layoutDelegate: LayoutDelegate;\n\n constructor(\n collection: Collection<Node<T>>,\n disabledKeys: Set<Key>,\n ref: RefObject<HTMLElement | null>,\n collator?: Intl.Collator,\n expandedKeys?: Set<Key>\n );\n constructor(options: ListKeyboardDelegateOptions<T>);\n constructor(...args: any[]) {\n if (args.length === 1) {\n let opts = args[0] as ListKeyboardDelegateOptions<T>;\n this.collection = opts.collection;\n this.ref = opts.ref;\n this.collator = opts.collator;\n this.disabledKeys = opts.disabledKeys || new Set();\n this.disabledBehavior = opts.disabledBehavior || 'all';\n this.orientation = opts.orientation || 'vertical';\n this.direction = opts.direction;\n this.layout = opts.layout || 'stack';\n this.layoutDelegate = opts.layoutDelegate || new DOMLayoutDelegate(opts.ref);\n } else {\n this.collection = args[0];\n this.disabledKeys = args[1];\n this.ref = args[2];\n this.collator = args[3];\n this.layout = 'stack';\n this.orientation = 'vertical';\n this.disabledBehavior = 'all';\n this.layoutDelegate = new DOMLayoutDelegate(this.ref);\n }\n\n // If this is a vertical stack, remove the left/right methods completely\n // so they aren't called by useDroppableCollection.\n if (this.layout === 'stack' && this.orientation === 'vertical') {\n this.getKeyLeftOf = undefined;\n this.getKeyRightOf = undefined;\n }\n }\n\n private isDisabled(item: Node<unknown>) {\n return (\n this.disabledBehavior === 'all' &&\n (item.props?.isDisabled || this.disabledKeys.has(item.key)) &&\n item.props?.disabledBehavior !== 'selection'\n );\n }\n\n private findNextNonDisabled(\n key: Key | null,\n getNext: (key: Key) => Key | null,\n includeDisabled = false\n ): Key | null {\n let nextKey = key;\n while (nextKey != null) {\n let item = this.collection.getItem(nextKey);\n if (item?.type === 'item' && (includeDisabled || !this.isDisabled(item))) {\n return nextKey;\n }\n\n nextKey = getNext(nextKey);\n }\n\n return null;\n }\n\n getNextKey(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n let nextKey: Key | null = key;\n nextKey = this.collection.getKeyAfter(nextKey);\n return this.findNextNonDisabled(\n nextKey,\n key => this.collection.getKeyAfter(key),\n options?.includeDisabled\n );\n }\n\n getPreviousKey(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n let nextKey: Key | null = key;\n nextKey = this.collection.getKeyBefore(nextKey);\n return this.findNextNonDisabled(\n nextKey,\n key => this.collection.getKeyBefore(key),\n options?.includeDisabled\n );\n }\n\n private findKey(\n key: Key,\n nextKey: (key: Key) => Key | null,\n shouldSkip: (prevRect: Rect, itemRect: Rect) => boolean\n ) {\n let tempKey: Key | null = key;\n let itemRect = this.layoutDelegate.getItemRect(tempKey);\n if (!itemRect || tempKey == null) {\n return null;\n }\n\n // Find the item above or below in the same column.\n let prevRect = itemRect;\n do {\n tempKey = nextKey(tempKey);\n if (tempKey == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(tempKey);\n } while (itemRect && shouldSkip(prevRect, itemRect) && tempKey != null);\n\n return tempKey;\n }\n\n private isSameRow(prevRect: Rect, itemRect: Rect) {\n return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;\n }\n\n private isSameColumn(prevRect: Rect, itemRect: Rect) {\n return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;\n }\n\n getKeyBelow(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, key => this.getNextKey(key, options), this.isSameRow);\n } else {\n return this.getNextKey(key, options);\n }\n }\n\n getKeyAbove(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, key => this.getPreviousKey(key, options), this.isSameRow);\n } else {\n return this.getPreviousKey(key, options);\n }\n }\n\n private getNextColumn(key: Key, right: boolean, options?: {includeDisabled?: boolean}) {\n return right ? this.getPreviousKey(key, options) : this.getNextKey(key, options);\n }\n\n getKeyRightOf?(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n // This is a temporary solution for CardView until we refactor useSelectableCollection.\n // https://github.com/orgs/adobe/projects/19/views/32?pane=issue&itemId=77825042\n let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyRightOf' : 'getKeyLeftOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(\n key,\n key => this.layoutDelegate[layoutDelegateMethod](key),\n options?.includeDisabled\n );\n }\n\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'rtl', options);\n } else {\n return this.findKey(\n key,\n key => this.getNextColumn(key, this.direction === 'rtl', options),\n this.isSameColumn\n );\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'rtl', options);\n }\n\n return null;\n }\n\n getKeyLeftOf?(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyLeftOf' : 'getKeyRightOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(\n key,\n key => this.layoutDelegate[layoutDelegateMethod](key),\n options?.includeDisabled\n );\n }\n\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'ltr', options);\n } else {\n return this.findKey(\n key,\n key => this.getNextColumn(key, this.direction === 'ltr', options),\n this.isSameColumn\n );\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'ltr', options);\n }\n\n return null;\n }\n\n getFirstKey(): Key | null {\n let key = this.collection.getFirstKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyAfter(key));\n }\n\n getLastKey(): Key | null {\n let key = this.collection.getLastKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyBefore(key));\n }\n\n getKeyPageAbove(key: Key): Key | null {\n let menu = this.ref.current;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n if (menu && !isScrollable(menu)) {\n return this.getFirstKey();\n }\n\n let nextKey: Key | null = key;\n if (this.orientation === 'horizontal') {\n let pageX = Math.max(\n 0,\n itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width\n );\n\n while (itemRect && itemRect.x > pageX && nextKey != null) {\n nextKey = this.getKeyAbove(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n } else {\n let pageY = Math.max(\n 0,\n itemRect.y + itemRect.height - this.layoutDelegate.getVisibleRect().height\n );\n\n while (itemRect && itemRect.y > pageY && nextKey != null) {\n nextKey = this.getKeyAbove(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n }\n\n return nextKey ?? this.getFirstKey();\n }\n\n getKeyPageBelow(key: Key): Key | null {\n let menu = this.ref.current;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n if (menu && !isScrollable(menu)) {\n return this.getLastKey();\n }\n\n let nextKey: Key | null = key;\n if (this.orientation === 'horizontal') {\n let pageX = Math.min(\n this.layoutDelegate.getContentSize().width,\n itemRect.x - itemRect.width + this.layoutDelegate.getVisibleRect().width\n );\n\n while (itemRect && itemRect.x < pageX && nextKey != null) {\n nextKey = this.getKeyBelow(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n } else {\n let pageY = Math.min(\n this.layoutDelegate.getContentSize().height,\n itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height\n );\n\n while (itemRect && itemRect.y < pageY && nextKey != null) {\n nextKey = this.getKeyBelow(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n }\n\n return nextKey ?? this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key): Key | null {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (!item) {\n return null;\n }\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getNextKey(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"ListKeyboardDelegate.cjs.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA8BM,MAAM;IAmBX,YAAY,GAAG,IAAW,CAAE;QAC1B,IAAI,KAAK,MAAM,KAAK,GAAG;YACrB,IAAI,OAAO,IAAI,CAAC,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,KAAK,UAAU;YACjC,IAAI,CAAC,GAAG,GAAG,KAAK,GAAG;YACnB,IAAI,CAAC,QAAQ,GAAG,KAAK,QAAQ;YAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,YAAY,IAAI,IAAI;YAC7C,IAAI,CAAC,gBAAgB,GAAG,KAAK,gBAAgB,IAAI;YACjD,IAAI,CAAC,WAAW,GAAG,KAAK,WAAW,IAAI;YACvC,IAAI,CAAC,SAAS,GAAG,KAAK,SAAS;YAC/B,IAAI,CAAC,MAAM,GAAG,KAAK,MAAM,IAAI;YAC7B,IAAI,CAAC,cAAc,GAAG,KAAK,cAAc,IAAI,IAAI,CAAA,GAAA,2CAAgB,EAAE,KAAK,GAAG;QAC7E,OAAO;YACL,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,EAAE;YACzB,IAAI,CAAC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IAAI,CAAC,cAAc,CAAC,cAAc,GAAG,MAAM;YAG5E,MAAO,YAAY,SAAS,CAAC,GAAG,SAAS,WAAW,KAAM;gBACxD,UAAU,IAAI,CAAC,WAAW,CAAC;gBAC3B,WAAW,WAAW,OAAO,OAAO,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;YACtE;QACF;QAEA,OAAO,WAAY,CAAA,WAAW,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,UAAU,EAAC;IACrE;IAEA,gBAAgB,MAAc,EAAE,OAAa,EAAc;QACzD,IAAI,CAAC,IAAI,CAAC,QAAQ,EAChB,OAAO;QAGT,IAAI,aAAa,IAAI,CAAC,UAAU;QAChC,IAAI,MAAM,WAAW,IAAI,CAAC,WAAW;QACrC,MAAO,OAAO,KAAM;YAClB,IAAI,OAAO,WAAW,OAAO,CAAC;YAC9B,IAAI,CAAC,MACH,OAAO;YAET,IAAI,YAAY,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,MAAM;YACrD,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,YAAY,GACjE,OAAO;YAGT,MAAM,IAAI,CAAC,UAAU,CAAC;QACxB;QAEA,OAAO;IACT;AACF","sources":["packages/react-aria/src/selection/ListKeyboardDelegate.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n Collection,\n Direction,\n DisabledBehavior,\n Key,\n KeyboardDelegate,\n LayoutDelegate,\n Node,\n Orientation,\n Rect,\n RefObject\n} from '@react-types/shared';\nimport {DOMLayoutDelegate} from './DOMLayoutDelegate';\nimport {getItemElement} from './utils';\nimport {isScrollable} from '../utils/isScrollable';\n\ninterface ListKeyboardDelegateOptions<T> {\n collection: Collection<Node<T>>;\n ref: RefObject<HTMLElement | null>;\n collator?: Intl.Collator;\n layout?: 'stack' | 'grid';\n orientation?: Orientation;\n direction?: Direction;\n disabledKeys?: Set<Key>;\n disabledBehavior?: DisabledBehavior;\n layoutDelegate?: LayoutDelegate;\n}\n\nexport class ListKeyboardDelegate<T> implements KeyboardDelegate {\n private collection: Collection<Node<T>>;\n private disabledKeys: Set<Key>;\n private disabledBehavior: DisabledBehavior;\n private ref: RefObject<HTMLElement | null>;\n private collator: Intl.Collator | undefined;\n private layout: 'stack' | 'grid';\n private orientation?: Orientation;\n private direction?: Direction;\n private layoutDelegate: LayoutDelegate;\n\n constructor(\n collection: Collection<Node<T>>,\n disabledKeys: Set<Key>,\n ref: RefObject<HTMLElement | null>,\n collator?: Intl.Collator,\n expandedKeys?: Set<Key>\n );\n constructor(options: ListKeyboardDelegateOptions<T>);\n constructor(...args: any[]) {\n if (args.length === 1) {\n let opts = args[0] as ListKeyboardDelegateOptions<T>;\n this.collection = opts.collection;\n this.ref = opts.ref;\n this.collator = opts.collator;\n this.disabledKeys = opts.disabledKeys || new Set();\n this.disabledBehavior = opts.disabledBehavior || 'all';\n this.orientation = opts.orientation || 'vertical';\n this.direction = opts.direction;\n this.layout = opts.layout || 'stack';\n this.layoutDelegate = opts.layoutDelegate || new DOMLayoutDelegate(opts.ref);\n } else {\n this.collection = args[0];\n this.disabledKeys = args[1];\n this.ref = args[2];\n this.collator = args[3];\n this.layout = 'stack';\n this.orientation = 'vertical';\n this.disabledBehavior = 'all';\n this.layoutDelegate = new DOMLayoutDelegate(this.ref);\n }\n\n // If this is a vertical stack, remove the left/right methods completely\n // so they aren't called by useDroppableCollection.\n if (this.layout === 'stack' && this.orientation === 'vertical') {\n this.getKeyLeftOf = undefined;\n this.getKeyRightOf = undefined;\n }\n }\n\n private isDisabled(item: Node<unknown>) {\n return (\n this.disabledBehavior === 'all' &&\n (item.props?.isDisabled || this.disabledKeys.has(item.key)) &&\n item.props?.disabledBehavior !== 'selection'\n );\n }\n\n private findNextNonDisabled(\n key: Key | null,\n getNext: (key: Key) => Key | null,\n includeDisabled = false\n ): Key | null {\n let nextKey = key;\n while (nextKey != null) {\n let item = this.collection.getItem(nextKey);\n if (item?.type === 'item' && (includeDisabled || !this.isDisabled(item))) {\n return nextKey;\n }\n\n nextKey = getNext(nextKey);\n }\n\n return null;\n }\n\n getNextKey(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n let nextKey: Key | null = key;\n nextKey = this.collection.getKeyAfter(nextKey);\n return this.findNextNonDisabled(\n nextKey,\n key => this.collection.getKeyAfter(key),\n options?.includeDisabled\n );\n }\n\n getPreviousKey(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n let nextKey: Key | null = key;\n nextKey = this.collection.getKeyBefore(nextKey);\n return this.findNextNonDisabled(\n nextKey,\n key => this.collection.getKeyBefore(key),\n options?.includeDisabled\n );\n }\n\n private findKey(\n key: Key,\n nextKey: (key: Key) => Key | null,\n shouldSkip: (prevRect: Rect, itemRect: Rect) => boolean\n ) {\n let tempKey: Key | null = key;\n let itemRect = this.layoutDelegate.getItemRect(tempKey);\n if (!itemRect || tempKey == null) {\n return null;\n }\n\n // Find the item above or below in the same column.\n let prevRect = itemRect;\n do {\n tempKey = nextKey(tempKey);\n if (tempKey == null) {\n break;\n }\n itemRect = this.layoutDelegate.getItemRect(tempKey);\n } while (itemRect && shouldSkip(prevRect, itemRect) && tempKey != null);\n\n return tempKey;\n }\n\n private isSameRow(prevRect: Rect, itemRect: Rect) {\n return prevRect.y === itemRect.y || prevRect.x !== itemRect.x;\n }\n\n private isSameColumn(prevRect: Rect, itemRect: Rect) {\n return prevRect.x === itemRect.x || prevRect.y !== itemRect.y;\n }\n\n // checks to see if the next/prev key is spatially above/below the current key. If not, that means we are in\n // a reversed column layout and need to adjust appropriately\n // TODO: still need to see how this works with virtualizer once there is handling for the reverse layout\n // this felt like a simpler approach then changing getKeyAbove/Below to be purely spatial calculations\n private isReversed(key: Key): boolean {\n let nextKey = this.getNextKey(key);\n let currentEl = getItemElement(this.ref, key);\n if (nextKey != null) {\n let nextEl = getItemElement(this.ref, nextKey);\n if (!currentEl || !nextEl) {\n return false;\n }\n return currentEl.getBoundingClientRect().top > nextEl.getBoundingClientRect().top;\n }\n let prevKey = this.getPreviousKey(key);\n if (prevKey != null) {\n let prevEl = getItemElement(this.ref, prevKey);\n if (!currentEl || !prevEl) {\n return false;\n }\n return prevEl.getBoundingClientRect().top > currentEl.getBoundingClientRect().top;\n }\n return false;\n }\n\n getKeyBelow(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, key => this.getNextKey(key, options), this.isSameRow);\n } else if (this.orientation === 'vertical') {\n return this.isReversed(key)\n ? this.getPreviousKey(key, options)\n : this.getNextKey(key, options);\n } else {\n return this.getNextKey(key, options);\n }\n }\n\n getKeyAbove(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n if (this.layout === 'grid' && this.orientation === 'vertical') {\n return this.findKey(key, key => this.getPreviousKey(key, options), this.isSameRow);\n } else if (this.orientation === 'vertical') {\n return this.isReversed(key)\n ? this.getNextKey(key, options)\n : this.getPreviousKey(key, options);\n } else {\n return this.getPreviousKey(key, options);\n }\n }\n\n private getNextColumn(key: Key, right: boolean, options?: {includeDisabled?: boolean}) {\n return right ? this.getPreviousKey(key, options) : this.getNextKey(key, options);\n }\n\n getKeyRightOf?(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n // This is a temporary solution for CardView until we refactor useSelectableCollection.\n // https://github.com/orgs/adobe/projects/19/views/32?pane=issue&itemId=77825042\n let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyRightOf' : 'getKeyLeftOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(\n key,\n key => this.layoutDelegate[layoutDelegateMethod](key),\n options?.includeDisabled\n );\n }\n\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'rtl', options);\n } else {\n return this.findKey(\n key,\n key => this.getNextColumn(key, this.direction === 'rtl', options),\n this.isSameColumn\n );\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'rtl', options);\n }\n\n return null;\n }\n\n getKeyLeftOf?(key: Key, options?: {includeDisabled?: boolean}): Key | null {\n let layoutDelegateMethod = this.direction === 'ltr' ? 'getKeyLeftOf' : 'getKeyRightOf';\n if (this.layoutDelegate[layoutDelegateMethod]) {\n key = this.layoutDelegate[layoutDelegateMethod](key);\n return this.findNextNonDisabled(\n key,\n key => this.layoutDelegate[layoutDelegateMethod](key),\n options?.includeDisabled\n );\n }\n\n if (this.layout === 'grid') {\n if (this.orientation === 'vertical') {\n return this.getNextColumn(key, this.direction === 'ltr', options);\n } else {\n return this.findKey(\n key,\n key => this.getNextColumn(key, this.direction === 'ltr', options),\n this.isSameColumn\n );\n }\n } else if (this.orientation === 'horizontal') {\n return this.getNextColumn(key, this.direction === 'ltr', options);\n }\n\n return null;\n }\n\n getFirstKey(): Key | null {\n let key = this.collection.getFirstKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyAfter(key));\n }\n\n getLastKey(): Key | null {\n let key = this.collection.getLastKey();\n return this.findNextNonDisabled(key, key => this.collection.getKeyBefore(key));\n }\n\n getKeyPageAbove(key: Key): Key | null {\n let menu = this.ref.current;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n let reversed = this.isReversed(key);\n if (menu && !isScrollable(menu)) {\n return this.getFirstKey();\n }\n\n let nextKey: Key | null = key;\n if (this.orientation === 'horizontal') {\n let pageX = Math.max(\n 0,\n itemRect.x + itemRect.width - this.layoutDelegate.getVisibleRect().width\n );\n\n while (itemRect && itemRect.x > pageX && nextKey != null) {\n nextKey = this.getKeyAbove(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n } else {\n let visibleRect = this.layoutDelegate.getVisibleRect();\n // column reverse makes y negative for items so we need to instead do current pos - height instead\n let pageY = reversed\n ? itemRect.y - visibleRect.height\n : Math.max(0, itemRect.y + itemRect.height - visibleRect.height);\n\n while (itemRect && itemRect.y > pageY && nextKey != null) {\n nextKey = this.getKeyAbove(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n }\n\n return nextKey ?? (reversed ? this.getLastKey() : this.getFirstKey());\n }\n\n getKeyPageBelow(key: Key): Key | null {\n let menu = this.ref.current;\n let itemRect = this.layoutDelegate.getItemRect(key);\n if (!itemRect) {\n return null;\n }\n\n let reversed = this.isReversed(key);\n if (menu && !isScrollable(menu)) {\n return this.getLastKey();\n }\n\n let nextKey: Key | null = key;\n if (this.orientation === 'horizontal') {\n let pageX = Math.min(\n this.layoutDelegate.getContentSize().width,\n itemRect.x - itemRect.width + this.layoutDelegate.getVisibleRect().width\n );\n\n while (itemRect && itemRect.x < pageX && nextKey != null) {\n nextKey = this.getKeyBelow(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n } else {\n let pageY = Math.min(\n this.layoutDelegate.getContentSize().height,\n itemRect.y - itemRect.height + this.layoutDelegate.getVisibleRect().height\n );\n\n while (itemRect && itemRect.y < pageY && nextKey != null) {\n nextKey = this.getKeyBelow(nextKey);\n itemRect = nextKey == null ? null : this.layoutDelegate.getItemRect(nextKey);\n }\n }\n\n return nextKey ?? (reversed ? this.getFirstKey() : this.getLastKey());\n }\n\n getKeyForSearch(search: string, fromKey?: Key): Key | null {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (!item) {\n return null;\n }\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getNextKey(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"ListKeyboardDelegate.cjs.map"}