@depup/react-aria-components 1.19.0-depup.27 → 1.20.0-depup.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 (257) hide show
  1. package/PreviewTrigger/package.json +5 -0
  2. package/README.md +2 -2
  3. package/TokenField/package.json +5 -0
  4. package/changes.json +1 -1
  5. package/dist/exports/GridList.cjs.map +1 -1
  6. package/dist/exports/GridList.js.map +1 -1
  7. package/dist/exports/GridList.mjs.map +1 -1
  8. package/dist/exports/PreviewTrigger.cjs +26 -0
  9. package/dist/exports/PreviewTrigger.cjs.map +1 -0
  10. package/dist/exports/PreviewTrigger.js +21 -0
  11. package/dist/exports/PreviewTrigger.js.map +1 -0
  12. package/dist/exports/PreviewTrigger.mjs +21 -0
  13. package/dist/exports/PreviewTrigger.mjs.map +1 -0
  14. package/dist/exports/TokenField.cjs +31 -0
  15. package/dist/exports/TokenField.cjs.map +1 -0
  16. package/dist/exports/TokenField.js +21 -0
  17. package/dist/exports/TokenField.js.map +1 -0
  18. package/dist/exports/TokenField.mjs +21 -0
  19. package/dist/exports/TokenField.mjs.map +1 -0
  20. package/dist/exports/Tree.cjs.map +1 -1
  21. package/dist/exports/Tree.js.map +1 -1
  22. package/dist/exports/Tree.mjs.map +1 -1
  23. package/dist/exports/index.cjs +12 -0
  24. package/dist/exports/index.cjs.map +1 -1
  25. package/dist/exports/index.js +7 -1
  26. package/dist/exports/index.js.map +1 -1
  27. package/dist/exports/index.mjs +7 -1
  28. package/dist/exports/index.mjs.map +1 -1
  29. package/dist/private/Checkbox.cjs.map +1 -1
  30. package/dist/private/Checkbox.js.map +1 -1
  31. package/dist/private/Checkbox.mjs.map +1 -1
  32. package/dist/private/ComboBox.cjs +21 -2
  33. package/dist/private/ComboBox.cjs.map +1 -1
  34. package/dist/private/ComboBox.js +21 -2
  35. package/dist/private/ComboBox.js.map +1 -1
  36. package/dist/private/ComboBox.mjs +21 -2
  37. package/dist/private/ComboBox.mjs.map +1 -1
  38. package/dist/private/Dialog.cjs +15 -1
  39. package/dist/private/Dialog.cjs.map +1 -1
  40. package/dist/private/Dialog.js +15 -1
  41. package/dist/private/Dialog.js.map +1 -1
  42. package/dist/private/Dialog.mjs +15 -1
  43. package/dist/private/Dialog.mjs.map +1 -1
  44. package/dist/private/DragAndDrop.cjs +1 -0
  45. package/dist/private/DragAndDrop.cjs.map +1 -1
  46. package/dist/private/DragAndDrop.js +1 -0
  47. package/dist/private/DragAndDrop.js.map +1 -1
  48. package/dist/private/DragAndDrop.mjs +1 -0
  49. package/dist/private/DragAndDrop.mjs.map +1 -1
  50. package/dist/private/DropZone.cjs +5 -2
  51. package/dist/private/DropZone.cjs.map +1 -1
  52. package/dist/private/DropZone.js +5 -3
  53. package/dist/private/DropZone.js.map +1 -1
  54. package/dist/private/DropZone.mjs +5 -2
  55. package/dist/private/DropZone.mjs.map +1 -1
  56. package/dist/private/FileTrigger.cjs +1 -0
  57. package/dist/private/FileTrigger.cjs.map +1 -1
  58. package/dist/private/FileTrigger.js +1 -0
  59. package/dist/private/FileTrigger.js.map +1 -1
  60. package/dist/private/FileTrigger.mjs +1 -0
  61. package/dist/private/FileTrigger.mjs.map +1 -1
  62. package/dist/private/GridLayout.cjs +3 -1
  63. package/dist/private/GridLayout.cjs.map +1 -1
  64. package/dist/private/GridLayout.js +3 -1
  65. package/dist/private/GridLayout.js.map +1 -1
  66. package/dist/private/GridLayout.mjs +3 -1
  67. package/dist/private/GridLayout.mjs.map +1 -1
  68. package/dist/private/GridList.cjs +12 -1
  69. package/dist/private/GridList.cjs.map +1 -1
  70. package/dist/private/GridList.js +12 -1
  71. package/dist/private/GridList.js.map +1 -1
  72. package/dist/private/GridList.mjs +12 -1
  73. package/dist/private/GridList.mjs.map +1 -1
  74. package/dist/private/ListBox.cjs +9 -1
  75. package/dist/private/ListBox.cjs.map +1 -1
  76. package/dist/private/ListBox.js +9 -1
  77. package/dist/private/ListBox.js.map +1 -1
  78. package/dist/private/ListBox.mjs +9 -1
  79. package/dist/private/ListBox.mjs.map +1 -1
  80. package/dist/private/Menu.cjs +4 -2
  81. package/dist/private/Menu.cjs.map +1 -1
  82. package/dist/private/Menu.js +4 -2
  83. package/dist/private/Menu.js.map +1 -1
  84. package/dist/private/Menu.mjs +4 -2
  85. package/dist/private/Menu.mjs.map +1 -1
  86. package/dist/private/Meter.cjs +2 -1
  87. package/dist/private/Meter.cjs.map +1 -1
  88. package/dist/private/Meter.js +2 -1
  89. package/dist/private/Meter.js.map +1 -1
  90. package/dist/private/Meter.mjs +2 -1
  91. package/dist/private/Meter.mjs.map +1 -1
  92. package/dist/private/Modal.cjs +2 -0
  93. package/dist/private/Modal.cjs.map +1 -1
  94. package/dist/private/Modal.js +2 -0
  95. package/dist/private/Modal.js.map +1 -1
  96. package/dist/private/Modal.mjs +2 -0
  97. package/dist/private/Modal.mjs.map +1 -1
  98. package/dist/private/Popover.cjs +34 -9
  99. package/dist/private/Popover.cjs.map +1 -1
  100. package/dist/private/Popover.js +34 -9
  101. package/dist/private/Popover.js.map +1 -1
  102. package/dist/private/Popover.mjs +34 -9
  103. package/dist/private/Popover.mjs.map +1 -1
  104. package/dist/private/PreviewTrigger.cjs +88 -0
  105. package/dist/private/PreviewTrigger.cjs.map +1 -0
  106. package/dist/private/PreviewTrigger.js +80 -0
  107. package/dist/private/PreviewTrigger.js.map +1 -0
  108. package/dist/private/PreviewTrigger.mjs +79 -0
  109. package/dist/private/PreviewTrigger.mjs.map +1 -0
  110. package/dist/private/ProgressBar.cjs +6 -1
  111. package/dist/private/ProgressBar.cjs.map +1 -1
  112. package/dist/private/ProgressBar.js +6 -1
  113. package/dist/private/ProgressBar.js.map +1 -1
  114. package/dist/private/ProgressBar.mjs +6 -1
  115. package/dist/private/ProgressBar.mjs.map +1 -1
  116. package/dist/private/Select.cjs.map +1 -1
  117. package/dist/private/Select.js.map +1 -1
  118. package/dist/private/Select.mjs.map +1 -1
  119. package/dist/private/Table.cjs +26 -14
  120. package/dist/private/Table.cjs.map +1 -1
  121. package/dist/private/Table.js +26 -14
  122. package/dist/private/Table.js.map +1 -1
  123. package/dist/private/Table.mjs +26 -14
  124. package/dist/private/Table.mjs.map +1 -1
  125. package/dist/private/TableLayout.cjs +3 -1
  126. package/dist/private/TableLayout.cjs.map +1 -1
  127. package/dist/private/TableLayout.js +3 -1
  128. package/dist/private/TableLayout.js.map +1 -1
  129. package/dist/private/TableLayout.mjs +3 -1
  130. package/dist/private/TableLayout.mjs.map +1 -1
  131. package/dist/private/TagGroup.cjs +1 -0
  132. package/dist/private/TagGroup.cjs.map +1 -1
  133. package/dist/private/TagGroup.js +1 -0
  134. package/dist/private/TagGroup.js.map +1 -1
  135. package/dist/private/TagGroup.mjs +1 -0
  136. package/dist/private/TagGroup.mjs.map +1 -1
  137. package/dist/private/ToggleButton.cjs.map +1 -1
  138. package/dist/private/ToggleButton.js.map +1 -1
  139. package/dist/private/ToggleButton.mjs.map +1 -1
  140. package/dist/private/TokenField.cjs +207 -0
  141. package/dist/private/TokenField.cjs.map +1 -0
  142. package/dist/private/TokenField.js +197 -0
  143. package/dist/private/TokenField.js.map +1 -0
  144. package/dist/private/TokenField.mjs +195 -0
  145. package/dist/private/TokenField.mjs.map +1 -0
  146. package/dist/private/Tooltip.cjs +10 -2
  147. package/dist/private/Tooltip.cjs.map +1 -1
  148. package/dist/private/Tooltip.js +10 -2
  149. package/dist/private/Tooltip.js.map +1 -1
  150. package/dist/private/Tooltip.mjs +10 -2
  151. package/dist/private/Tooltip.mjs.map +1 -1
  152. package/dist/private/Tree.cjs +11 -1
  153. package/dist/private/Tree.cjs.map +1 -1
  154. package/dist/private/Tree.js +11 -1
  155. package/dist/private/Tree.js.map +1 -1
  156. package/dist/private/Tree.mjs +11 -1
  157. package/dist/private/Tree.mjs.map +1 -1
  158. package/dist/private/Virtualizer.cjs +18 -16
  159. package/dist/private/Virtualizer.cjs.map +1 -1
  160. package/dist/private/Virtualizer.js +18 -16
  161. package/dist/private/Virtualizer.js.map +1 -1
  162. package/dist/private/Virtualizer.mjs +18 -16
  163. package/dist/private/Virtualizer.mjs.map +1 -1
  164. package/dist/private/useDragAndDrop.cjs +7 -0
  165. package/dist/private/useDragAndDrop.cjs.map +1 -1
  166. package/dist/private/useDragAndDrop.js +7 -0
  167. package/dist/private/useDragAndDrop.js.map +1 -1
  168. package/dist/private/useDragAndDrop.mjs +7 -0
  169. package/dist/private/useDragAndDrop.mjs.map +1 -1
  170. package/dist/private/utils.cjs.map +1 -1
  171. package/dist/private/utils.js.map +1 -1
  172. package/dist/private/utils.mjs.map +1 -1
  173. package/dist/types/exports/GridList.d.ts +1 -1
  174. package/dist/types/exports/PreviewTrigger.d.ts +3 -0
  175. package/dist/types/exports/TokenField.d.ts +5 -0
  176. package/dist/types/exports/Tree.d.ts +1 -1
  177. package/dist/types/exports/index.d.ts +7 -2
  178. package/dist/types/src/ComboBox.d.ts +4 -1
  179. package/dist/types/src/GridList.d.ts +12 -1
  180. package/dist/types/src/ListBox.d.ts +1 -1
  181. package/dist/types/src/Popover.d.ts +7 -0
  182. package/dist/types/src/PreviewTrigger.d.ts +23 -0
  183. package/dist/types/src/Select.d.ts +1 -1
  184. package/dist/types/src/Table.d.ts +24 -0
  185. package/dist/types/src/TokenField.d.ts +111 -0
  186. package/dist/types/src/Tree.d.ts +7 -5
  187. package/dist/types/src/Virtualizer.d.ts +4 -0
  188. package/dist/types/src/utils.d.ts +19 -5
  189. package/i18n/ar-AE.js +1 -1
  190. package/i18n/ar-AE.mjs +1 -1
  191. package/i18n/bg-BG.js +1 -1
  192. package/i18n/bg-BG.mjs +1 -1
  193. package/i18n/cs-CZ.js +1 -1
  194. package/i18n/cs-CZ.mjs +1 -1
  195. package/i18n/da-DK.js +1 -1
  196. package/i18n/da-DK.mjs +1 -1
  197. package/i18n/de-DE.js +1 -1
  198. package/i18n/de-DE.mjs +1 -1
  199. package/i18n/el-GR.js +1 -1
  200. package/i18n/el-GR.mjs +1 -1
  201. package/i18n/en-US.js +1 -1
  202. package/i18n/en-US.mjs +1 -1
  203. package/i18n/es-ES.js +1 -1
  204. package/i18n/es-ES.mjs +1 -1
  205. package/i18n/et-EE.js +1 -1
  206. package/i18n/et-EE.mjs +1 -1
  207. package/i18n/fi-FI.js +1 -1
  208. package/i18n/fi-FI.mjs +1 -1
  209. package/i18n/fr-FR.js +1 -1
  210. package/i18n/fr-FR.mjs +1 -1
  211. package/i18n/he-IL.js +1 -1
  212. package/i18n/he-IL.mjs +1 -1
  213. package/i18n/hr-HR.js +1 -1
  214. package/i18n/hr-HR.mjs +1 -1
  215. package/i18n/hu-HU.js +1 -1
  216. package/i18n/hu-HU.mjs +1 -1
  217. package/i18n/it-IT.js +1 -1
  218. package/i18n/it-IT.mjs +1 -1
  219. package/i18n/ja-JP.js +1 -1
  220. package/i18n/ja-JP.mjs +1 -1
  221. package/i18n/ko-KR.js +1 -1
  222. package/i18n/ko-KR.mjs +1 -1
  223. package/i18n/lt-LT.js +1 -1
  224. package/i18n/lt-LT.mjs +1 -1
  225. package/i18n/lv-LV.js +1 -1
  226. package/i18n/lv-LV.mjs +1 -1
  227. package/i18n/nb-NO.js +1 -1
  228. package/i18n/nb-NO.mjs +1 -1
  229. package/i18n/nl-NL.js +1 -1
  230. package/i18n/nl-NL.mjs +1 -1
  231. package/i18n/pl-PL.js +1 -1
  232. package/i18n/pl-PL.mjs +1 -1
  233. package/i18n/pt-BR.js +1 -1
  234. package/i18n/pt-BR.mjs +1 -1
  235. package/i18n/pt-PT.js +1 -1
  236. package/i18n/pt-PT.mjs +1 -1
  237. package/i18n/ro-RO.js +1 -1
  238. package/i18n/ro-RO.mjs +1 -1
  239. package/i18n/ru-RU.js +1 -1
  240. package/i18n/ru-RU.mjs +1 -1
  241. package/i18n/sk-SK.js +1 -1
  242. package/i18n/sk-SK.mjs +1 -1
  243. package/i18n/sl-SI.js +1 -1
  244. package/i18n/sl-SI.mjs +1 -1
  245. package/i18n/sr-SP.js +1 -1
  246. package/i18n/sr-SP.mjs +1 -1
  247. package/i18n/sv-SE.js +1 -1
  248. package/i18n/sv-SE.mjs +1 -1
  249. package/i18n/tr-TR.js +1 -1
  250. package/i18n/tr-TR.mjs +1 -1
  251. package/i18n/uk-UA.js +1 -1
  252. package/i18n/uk-UA.mjs +1 -1
  253. package/i18n/zh-CN.js +1 -1
  254. package/i18n/zh-CN.mjs +1 -1
  255. package/i18n/zh-TW.js +1 -1
  256. package/i18n/zh-TW.mjs +1 -1
  257. package/package.json +32 -31
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAuDM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAkD;AAMzD,MAAM,0DAAc,CAAA,GAAA,uBAAS,EAAE,SAAS,YAC7C,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,SAAC,QAAQ,aAAG,WAAW,aAAG,WAAW,sBAAK,kBAAkB,OAAM,GAAG;IACzE,QAAQ,CAAA,GAAA,2CAAI,EAAE,OAAO,UAAU;IAE/B,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,iCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACjF,IAAI,oBAAC,gBAAgB,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,6CAAa,EAAE;QAAC,GAAG,KAAK;eAAE;IAAK;IAEpE,0DAA0D;IAC1D,IAAI,aAAa,kBAAkB,YAAY,AAAE,CAAA,QAAQ,QAAO,IAAM,CAAA,WAAW,QAAO,IAAM;IAE9F,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;wBACN;YACA,WAAW,gBAAgB,CAAC,iBAAiB;6BAC7C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,qCAAS,EAAE,UAAU,aAAa,iBAAiB;QACvD,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;qBACpB,0DAAC,CAAA,GAAA,sCAAW,EAAE,QAAQ;QAAC,OAAO;YAAC,GAAG,UAAU;YAAE,KAAK;YAAU,aAAa;QAAM;OAC7E,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/ProgressBar.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps, useProgressBar} from 'react-aria/useProgressBar';\n\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface ProgressBarProps\n extends\n Omit<AriaProgressBarProps, 'label'>,\n RenderProps<ProgressBarRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ProgressBar'\n */\n className?: ClassNameOrFunction<ProgressBarRenderProps>;\n}\n\nexport interface ProgressBarRenderProps {\n /**\n * The value as a percentage between the minimum and maximum.\n */\n percentage: number | undefined;\n /**\n * A formatted version of the value.\n *\n * @selector [aria-valuetext]\n */\n valueText: string | undefined;\n /**\n * Whether the progress bar is indeterminate.\n *\n * @selector :not([aria-valuenow])\n */\n isIndeterminate: boolean;\n}\n\nexport const ProgressBarContext =\n createContext<ContextValue<ProgressBarProps, HTMLDivElement>>(null);\n\n/**\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport const ProgressBar = forwardRef(function ProgressBar(\n props: ProgressBarProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ProgressBarContext);\n let {value = 0, minValue = 0, maxValue = 100, isIndeterminate = false} = props;\n value = clamp(value, minValue, maxValue);\n\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {progressBarProps, labelProps} = useProgressBar({...props, label});\n\n // Calculate the width of the progress bar as a percentage\n let percentage = isIndeterminate ? undefined : ((value - minValue) / (maxValue - minValue)) * 100;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ProgressBar',\n values: {\n percentage,\n valueText: progressBarProps['aria-valuetext'],\n isIndeterminate\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, progressBarProps)}\n ref={ref}\n slot={props.slot || undefined}>\n <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n {renderProps.children}\n </LabelContext.Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"ProgressBar.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAsDM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAkD;AAMzD,MAAM,0DAAc,CAAA,GAAA,uBAAS,EAAE,SAAS,YAC7C,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,SAAC,QAAQ,aAAG,WAAW,aAAG,WAAW,sBAAK,kBAAkB,OAAM,GAAG;IACzE,QAAQ,CAAA,GAAA,2CAAI,EAAE,OAAO,UAAU;IAE/B,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,iCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACjF,IAAI,oBAAC,gBAAgB,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,6CAAa,EAAE;QAAC,GAAG,KAAK;eAAE;IAAK;IAEpE,IAAI,QAAQ,WAAW;IACvB,0DAA0D;IAC1D,IAAI,aAAiC;IACrC,IAAI,CAAC;QACH,IAAI,UAAU,GACZ,aAAa;aAEb,aAAa,AAAE,CAAA,QAAQ,QAAO,IAAK,QAAS;;IAIhD,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;wBACN;YACA,WAAW,gBAAgB,CAAC,iBAAiB;6BAC7C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,qCAAS,EAAE,UAAU,aAAa,iBAAiB;QACvD,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;qBACpB,0DAAC,CAAA,GAAA,sCAAW,EAAE,QAAQ;QAAC,OAAO;YAAC,GAAG,UAAU;YAAE,KAAK;YAAU,aAAa;QAAM;OAC7E,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/ProgressBar.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps, useProgressBar} from 'react-aria/useProgressBar';\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface ProgressBarProps\n extends\n Omit<AriaProgressBarProps, 'label'>,\n RenderProps<ProgressBarRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ProgressBar'\n */\n className?: ClassNameOrFunction<ProgressBarRenderProps>;\n}\n\nexport interface ProgressBarRenderProps {\n /**\n * The value as a percentage between the minimum and maximum.\n */\n percentage: number | undefined;\n /**\n * A formatted version of the value.\n *\n * @selector [aria-valuetext]\n */\n valueText: string | undefined;\n /**\n * Whether the progress bar is indeterminate.\n *\n * @selector :not([aria-valuenow])\n */\n isIndeterminate: boolean;\n}\n\nexport const ProgressBarContext =\n createContext<ContextValue<ProgressBarProps, HTMLDivElement>>(null);\n\n/**\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport const ProgressBar = forwardRef(function ProgressBar(\n props: ProgressBarProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ProgressBarContext);\n let {value = 0, minValue = 0, maxValue = 100, isIndeterminate = false} = props;\n value = clamp(value, minValue, maxValue);\n\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {progressBarProps, labelProps} = useProgressBar({...props, label});\n\n let range = maxValue - minValue;\n // Calculate the width of the progress bar as a percentage\n let percentage: number | undefined = undefined;\n if (!isIndeterminate) {\n if (range === 0) {\n percentage = 0;\n } else {\n percentage = ((value - minValue) / range) * 100;\n }\n }\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ProgressBar',\n values: {\n percentage,\n valueText: progressBarProps['aria-valuetext'],\n isIndeterminate\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, progressBarProps)}\n ref={ref}\n slot={props.slot || undefined}>\n <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n {renderProps.children}\n </LabelContext.Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"ProgressBar.cjs.map"}
@@ -33,8 +33,13 @@ const $71551be8b98e6856$export$c17561cb55d4db30 = /*#__PURE__*/ (0, $lG3gV$forwa
33
33
  ...props,
34
34
  label: label
35
35
  });
36
+ let range = maxValue - minValue;
36
37
  // Calculate the width of the progress bar as a percentage
37
- let percentage = isIndeterminate ? undefined : (value - minValue) / (maxValue - minValue) * 100;
38
+ let percentage = undefined;
39
+ if (!isIndeterminate) {
40
+ if (range === 0) percentage = 0;
41
+ else percentage = (value - minValue) / range * 100;
42
+ }
38
43
  let renderProps = (0, $b7b7a92703138c9b$export$4d86445c2cf5e3)({
39
44
  ...props,
40
45
  defaultClassName: 'react-aria-ProgressBar',
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAuDM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AAMzD,MAAM,0DAAc,CAAA,GAAA,iBAAS,EAAE,SAAS,YAC7C,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,SAAC,QAAQ,aAAG,WAAW,aAAG,WAAW,sBAAK,kBAAkB,OAAM,GAAG;IACzE,QAAQ,CAAA,GAAA,YAAI,EAAE,OAAO,UAAU;IAE/B,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACjF,IAAI,oBAAC,gBAAgB,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QAAC,GAAG,KAAK;eAAE;IAAK;IAEpE,0DAA0D;IAC1D,IAAI,aAAa,kBAAkB,YAAY,AAAE,CAAA,QAAQ,QAAO,IAAM,CAAA,WAAW,QAAO,IAAM;IAE9F,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;wBACN;YACA,WAAW,gBAAgB,CAAC,iBAAiB;6BAC7C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,iBAAiB;QACvD,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;qBACpB,gCAAC,CAAA,GAAA,yCAAW,EAAE,QAAQ;QAAC,OAAO;YAAC,GAAG,UAAU;YAAE,KAAK;YAAU,aAAa;QAAM;OAC7E,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/ProgressBar.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps, useProgressBar} from 'react-aria/useProgressBar';\n\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface ProgressBarProps\n extends\n Omit<AriaProgressBarProps, 'label'>,\n RenderProps<ProgressBarRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ProgressBar'\n */\n className?: ClassNameOrFunction<ProgressBarRenderProps>;\n}\n\nexport interface ProgressBarRenderProps {\n /**\n * The value as a percentage between the minimum and maximum.\n */\n percentage: number | undefined;\n /**\n * A formatted version of the value.\n *\n * @selector [aria-valuetext]\n */\n valueText: string | undefined;\n /**\n * Whether the progress bar is indeterminate.\n *\n * @selector :not([aria-valuenow])\n */\n isIndeterminate: boolean;\n}\n\nexport const ProgressBarContext =\n createContext<ContextValue<ProgressBarProps, HTMLDivElement>>(null);\n\n/**\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport const ProgressBar = forwardRef(function ProgressBar(\n props: ProgressBarProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ProgressBarContext);\n let {value = 0, minValue = 0, maxValue = 100, isIndeterminate = false} = props;\n value = clamp(value, minValue, maxValue);\n\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {progressBarProps, labelProps} = useProgressBar({...props, label});\n\n // Calculate the width of the progress bar as a percentage\n let percentage = isIndeterminate ? undefined : ((value - minValue) / (maxValue - minValue)) * 100;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ProgressBar',\n values: {\n percentage,\n valueText: progressBarProps['aria-valuetext'],\n isIndeterminate\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, progressBarProps)}\n ref={ref}\n slot={props.slot || undefined}>\n <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n {renderProps.children}\n </LabelContext.Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"ProgressBar.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAsDM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AAMzD,MAAM,0DAAc,CAAA,GAAA,iBAAS,EAAE,SAAS,YAC7C,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,SAAC,QAAQ,aAAG,WAAW,aAAG,WAAW,sBAAK,kBAAkB,OAAM,GAAG;IACzE,QAAQ,CAAA,GAAA,YAAI,EAAE,OAAO,UAAU;IAE/B,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACjF,IAAI,oBAAC,gBAAgB,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QAAC,GAAG,KAAK;eAAE;IAAK;IAEpE,IAAI,QAAQ,WAAW;IACvB,0DAA0D;IAC1D,IAAI,aAAiC;IACrC,IAAI,CAAC;QACH,IAAI,UAAU,GACZ,aAAa;aAEb,aAAa,AAAE,CAAA,QAAQ,QAAO,IAAK,QAAS;;IAIhD,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;wBACN;YACA,WAAW,gBAAgB,CAAC,iBAAiB;6BAC7C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,iBAAiB;QACvD,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;qBACpB,gCAAC,CAAA,GAAA,yCAAW,EAAE,QAAQ;QAAC,OAAO;YAAC,GAAG,UAAU;YAAE,KAAK;YAAU,aAAa;QAAM;OAC7E,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/ProgressBar.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps, useProgressBar} from 'react-aria/useProgressBar';\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface ProgressBarProps\n extends\n Omit<AriaProgressBarProps, 'label'>,\n RenderProps<ProgressBarRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ProgressBar'\n */\n className?: ClassNameOrFunction<ProgressBarRenderProps>;\n}\n\nexport interface ProgressBarRenderProps {\n /**\n * The value as a percentage between the minimum and maximum.\n */\n percentage: number | undefined;\n /**\n * A formatted version of the value.\n *\n * @selector [aria-valuetext]\n */\n valueText: string | undefined;\n /**\n * Whether the progress bar is indeterminate.\n *\n * @selector :not([aria-valuenow])\n */\n isIndeterminate: boolean;\n}\n\nexport const ProgressBarContext =\n createContext<ContextValue<ProgressBarProps, HTMLDivElement>>(null);\n\n/**\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport const ProgressBar = forwardRef(function ProgressBar(\n props: ProgressBarProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ProgressBarContext);\n let {value = 0, minValue = 0, maxValue = 100, isIndeterminate = false} = props;\n value = clamp(value, minValue, maxValue);\n\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {progressBarProps, labelProps} = useProgressBar({...props, label});\n\n let range = maxValue - minValue;\n // Calculate the width of the progress bar as a percentage\n let percentage: number | undefined = undefined;\n if (!isIndeterminate) {\n if (range === 0) {\n percentage = 0;\n } else {\n percentage = ((value - minValue) / range) * 100;\n }\n }\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ProgressBar',\n values: {\n percentage,\n valueText: progressBarProps['aria-valuetext'],\n isIndeterminate\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, progressBarProps)}\n ref={ref}\n slot={props.slot || undefined}>\n <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n {renderProps.children}\n </LabelContext.Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"ProgressBar.js.map"}
@@ -33,8 +33,13 @@ const $6c0095e7e99364f2$export$c17561cb55d4db30 = /*#__PURE__*/ (0, $8MuvO$forwa
33
33
  ...props,
34
34
  label: label
35
35
  });
36
+ let range = maxValue - minValue;
36
37
  // Calculate the width of the progress bar as a percentage
37
- let percentage = isIndeterminate ? undefined : (value - minValue) / (maxValue - minValue) * 100;
38
+ let percentage = undefined;
39
+ if (!isIndeterminate) {
40
+ if (range === 0) percentage = 0;
41
+ else percentage = (value - minValue) / range * 100;
42
+ }
38
43
  let renderProps = (0, $7230ffa83bc0c2cf$export$4d86445c2cf5e3)({
39
44
  ...props,
40
45
  defaultClassName: 'react-aria-ProgressBar',
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAuDM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AAMzD,MAAM,0DAAc,CAAA,GAAA,iBAAS,EAAE,SAAS,YAC7C,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,SAAC,QAAQ,aAAG,WAAW,aAAG,WAAW,sBAAK,kBAAkB,OAAM,GAAG;IACzE,QAAQ,CAAA,GAAA,YAAI,EAAE,OAAO,UAAU;IAE/B,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACjF,IAAI,oBAAC,gBAAgB,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QAAC,GAAG,KAAK;eAAE;IAAK;IAEpE,0DAA0D;IAC1D,IAAI,aAAa,kBAAkB,YAAY,AAAE,CAAA,QAAQ,QAAO,IAAM,CAAA,WAAW,QAAO,IAAM;IAE9F,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;wBACN;YACA,WAAW,gBAAgB,CAAC,iBAAiB;6BAC7C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,iBAAiB;QACvD,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;qBACpB,gCAAC,CAAA,GAAA,yCAAW,EAAE,QAAQ;QAAC,OAAO;YAAC,GAAG,UAAU;YAAE,KAAK;YAAU,aAAa;QAAM;OAC7E,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/ProgressBar.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps, useProgressBar} from 'react-aria/useProgressBar';\n\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface ProgressBarProps\n extends\n Omit<AriaProgressBarProps, 'label'>,\n RenderProps<ProgressBarRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ProgressBar'\n */\n className?: ClassNameOrFunction<ProgressBarRenderProps>;\n}\n\nexport interface ProgressBarRenderProps {\n /**\n * The value as a percentage between the minimum and maximum.\n */\n percentage: number | undefined;\n /**\n * A formatted version of the value.\n *\n * @selector [aria-valuetext]\n */\n valueText: string | undefined;\n /**\n * Whether the progress bar is indeterminate.\n *\n * @selector :not([aria-valuenow])\n */\n isIndeterminate: boolean;\n}\n\nexport const ProgressBarContext =\n createContext<ContextValue<ProgressBarProps, HTMLDivElement>>(null);\n\n/**\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport const ProgressBar = forwardRef(function ProgressBar(\n props: ProgressBarProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ProgressBarContext);\n let {value = 0, minValue = 0, maxValue = 100, isIndeterminate = false} = props;\n value = clamp(value, minValue, maxValue);\n\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {progressBarProps, labelProps} = useProgressBar({...props, label});\n\n // Calculate the width of the progress bar as a percentage\n let percentage = isIndeterminate ? undefined : ((value - minValue) / (maxValue - minValue)) * 100;\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ProgressBar',\n values: {\n percentage,\n valueText: progressBarProps['aria-valuetext'],\n isIndeterminate\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, progressBarProps)}\n ref={ref}\n slot={props.slot || undefined}>\n <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n {renderProps.children}\n </LabelContext.Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"ProgressBar.mjs.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAsDM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAkD;AAMzD,MAAM,0DAAc,CAAA,GAAA,iBAAS,EAAE,SAAS,YAC7C,KAAuB,EACvB,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,SAAC,QAAQ,aAAG,WAAW,aAAG,WAAW,sBAAK,kBAAkB,OAAM,GAAG;IACzE,QAAQ,CAAA,GAAA,YAAI,EAAE,OAAO,UAAU;IAE/B,IAAI,CAAC,UAAU,MAAM,GAAG,CAAA,GAAA,yCAAM,EAAE,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB;IACjF,IAAI,oBAAC,gBAAgB,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QAAC,GAAG,KAAK;eAAE;IAAK;IAEpE,IAAI,QAAQ,WAAW;IACvB,0DAA0D;IAC1D,IAAI,aAAiC;IACrC,IAAI,CAAC;QACH,IAAI,UAAU,GACZ,aAAa;aAEb,aAAa,AAAE,CAAA,QAAQ,QAAO,IAAK,QAAS;;IAIhD,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;wBACN;YACA,WAAW,gBAAgB,CAAC,iBAAiB;6BAC7C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACL,GAAG,CAAA,GAAA,iBAAS,EAAE,UAAU,aAAa,iBAAiB;QACvD,KAAK;QACL,MAAM,MAAM,IAAI,IAAI;qBACpB,gCAAC,CAAA,GAAA,yCAAW,EAAE,QAAQ;QAAC,OAAO;YAAC,GAAG,UAAU;YAAE,KAAK;YAAU,aAAa;QAAM;OAC7E,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/ProgressBar.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaProgressBarProps, useProgressBar} from 'react-aria/useProgressBar';\nimport {clamp} from 'react-stately/private/utils/number';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot\n} from './utils';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport {LabelContext} from './Label';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport React, {createContext, ForwardedRef, forwardRef} from 'react';\n\nexport interface ProgressBarProps\n extends\n Omit<AriaProgressBarProps, 'label'>,\n RenderProps<ProgressBarRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-ProgressBar'\n */\n className?: ClassNameOrFunction<ProgressBarRenderProps>;\n}\n\nexport interface ProgressBarRenderProps {\n /**\n * The value as a percentage between the minimum and maximum.\n */\n percentage: number | undefined;\n /**\n * A formatted version of the value.\n *\n * @selector [aria-valuetext]\n */\n valueText: string | undefined;\n /**\n * Whether the progress bar is indeterminate.\n *\n * @selector :not([aria-valuenow])\n */\n isIndeterminate: boolean;\n}\n\nexport const ProgressBarContext =\n createContext<ContextValue<ProgressBarProps, HTMLDivElement>>(null);\n\n/**\n * Progress bars show either determinate or indeterminate progress of an operation\n * over time.\n */\nexport const ProgressBar = forwardRef(function ProgressBar(\n props: ProgressBarProps,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ProgressBarContext);\n let {value = 0, minValue = 0, maxValue = 100, isIndeterminate = false} = props;\n value = clamp(value, minValue, maxValue);\n\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {progressBarProps, labelProps} = useProgressBar({...props, label});\n\n let range = maxValue - minValue;\n // Calculate the width of the progress bar as a percentage\n let percentage: number | undefined = undefined;\n if (!isIndeterminate) {\n if (range === 0) {\n percentage = 0;\n } else {\n percentage = ((value - minValue) / range) * 100;\n }\n }\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-ProgressBar',\n values: {\n percentage,\n valueText: progressBarProps['aria-valuetext'],\n isIndeterminate\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.div\n {...mergeProps(DOMProps, renderProps, progressBarProps)}\n ref={ref}\n slot={props.slot || undefined}>\n <LabelContext.Provider value={{...labelProps, ref: labelRef, elementType: 'span'}}>\n {renderProps.children}\n </LabelContext.Provider>\n </dom.div>\n );\n});\n"],"names":[],"version":3,"file":"ProgressBar.mjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,0BAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,oBAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACA,UACN;QAAC;QAAU;QAAY;QAAW;KAAW;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AM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,0DAAC,CAAA,GAAA,qCAAU,EAAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,0BAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,oBAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACA,UACN;QAAC;QAAU;QAAY;QAAW;KAAW;IAG/C,qBACE,0DAAC,CAAA,GAAA,mDAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,0DAAC;YAAY,OAAO;YAAO,YAAY;YAAY,WAAW;;AAGnF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IAAC,CAAA,GAAA,sCAAW;I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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 {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T = {}, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.cjs.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACA,UACN;QAAC;QAAU;QAAY;QAAW;KAAW;IAG/C,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,gCAAC;YAAY,OAAO;YAAO,YAAY;YAAY,WAAW;;AAGnF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IAAC,CAAA,GAAA,yCAAW;IAAG,CAAA,GAAA,yCAAY;IAAG,CAAA,GAAA,yCAAU;CAAE;AAQjE,SAAS,kCAAe,SAAC,KAAK,EAAE,WAAW,GAAG,cAAE,UAAU,EAAsB;IAC9E,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,GA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AAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACA,UACN;QAAC;QAAU;QAAY;QAAW;KAAW;IAG/C,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,gCAAC;YAAY,OAAO;YAAO,YAAY;YAAY,WAAW;;AAGnF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IAAC,CAAA,GAAA,yCAAW;IAAG,CAAA,GAAA,yCAAY;IAAG,CAAA,GAAA,yCAAU;CAAE;AAQjE,SAAS,kCAAe,SAAC,KAA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AAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T = {}, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACA,UACN;QAAC;QAAU;QAAY;QAAW;KAAW;IAG/C,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,gCAAC;YAAY,OAAO;YAAO,YAAY;YAAY,WAAW;;AAGnF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB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copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAyHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAiE;AACxE,MAAM,0DAAqB,CAAA,GAAA,oBAAY,EAA8C;AAKrF,MAAM,4CAAS,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,OAGnE,KAAwB,EAAE,GAAiC;IAC3D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YAAC,QAAQ,cAAE,aAAa,kBAAO,YAAY,mBAAO,aAAa,OAAM,GAAG;IAC5E,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,IACE,OAAO,aAAa,aAChB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,WAAW;YACX,gBAAgB;YAChB,iBAAiB;QACnB,KACA,UACN;QAAC;QAAU;QAAY;QAAW;KAAW;IAG/C,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,gCAAC;YAAY,OAAO;YAAO,YAAY;YAAY,WAAW;;AAGnF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IAAC,CAAA,GAAA,yCAAW;IAAG,CAAA,GAAA,yCAAY;IAAG,CAAA,GAAA,yCAAU;CAAE;AAQjE,SAAS,kCAAe,SAAC,KAAK,EAAE,WAAW,GAAG,cAAE,UAAU,EAAsB;IAC9E,IAAI,EAAC,oBAAoB,sBAAsB,EAAC,GAAG,CAAA,G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GAAG,CAAC,CAAA;YACf,IAAI,KAAK,IAAI,KAAK,WAChB,qBAAO,gCAAC,CAAA,GAAA,eAAO;gBAAE,KAAK;eAAQ,QAAQ,CAAC,QAAQ;iBAE/C,OAAO,KAAK,KAAK;QAErB;IACF,GAAG;QAAC;QAAe;QAAW;QAAW;KAAS;IAElD,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,+CAAW,GAAG;IAEhE,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,mBAAmB,eAAe,gBAAgB,MAAM,CAAC;QAC1E,kBAAkB;QAClB,QAAQ;YACN,cAAc,AAAC,MAAM,aAAa,CAAC,EAAE,EAAE,SAAe;YACtD,eAAe,CAAA,GAAA,cAAM,EACnB,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,AAAC,KAAK,KAAK,IAAU,OAC3D;gBAAC,MAAM,aAAa;aAAC;0BAEvB;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,IAAI;QACP,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;qBAEtD,gCAAC,CAAA,GAAA,yCAAU,EAAE,QAAQ;QAAC,OAAO;OAAY,YAAY,QAAQ;AAGnE","sources":["packages/react-aria-components/src/Select.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaSelectProps, HiddenSelect, useSelect} from 'react-aria/useSelect';\n\nimport {ButtonContext} from './Button';\nimport {\n ClassNameOrFunction,\n ContextValue,\n dom,\n Provider,\n RACValidation,\n removeDataAttributes,\n RenderProps,\n SlotProps,\n useContextProps,\n useRenderProps,\n useSlot,\n useSlottedContext\n} from './utils';\nimport {Collection, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes} from '@react-types/shared';\nimport intlMessages from '../intl/*.json';\nimport {ItemRenderProps} from './Collection';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {mergeProps} from 'react-aria/mergeProps';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n Fragment,\n HTMLAttributes,\n ReactNode,\n useContext,\n useMemo,\n useRef\n} from 'react';\nimport {SelectState, useSelectState} from 'react-stately/useSelectState';\nimport {TextContext} from './Text';\nimport {useFocusRing} from 'react-aria/useFocusRing';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useLocalizedStringFormatter} from 'react-aria/useLocalizedStringFormatter';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface SelectRenderProps {\n /**\n * Whether the select is focused, either via a mouse or keyboard.\n *\n * @selector [data-focused]\n */\n isFocused: boolean;\n /**\n * Whether the select is keyboard focused.\n *\n * @selector [data-focus-visible]\n */\n isFocusVisible: boolean;\n /**\n * Whether the select is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the select is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the select is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the select is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n}\n\nexport interface SelectProps<T = {}, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaSelectProps<T, M>,\n | 'children'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n | 'items'\n >,\n RACValidation,\n RenderProps<SelectRenderProps>,\n SlotProps,\n GlobalDOMAttributes<HTMLDivElement> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-Select'\n */\n className?: ClassNameOrFunction<SelectRenderProps>;\n /**\n * Temporary text that occupies the select when it is empty.\n *\n * @default 'Select an item' (localized)\n */\n placeholder?: string;\n}\n\nexport const SelectContext =\n createContext<ContextValue<SelectProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const SelectStateContext = createContext<SelectState<unknown, SelectionMode> | null>(null);\n\n/**\n * A select displays a collapsible list of options and allows a user to select one of them.\n */\nexport const Select = /*#__PURE__*/ createHideableComponent(function Select<\n T,\n M extends SelectionMode = 'single'\n>(props: SelectProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, SelectContext);\n let {children, isDisabled = false, isInvalid = false, isRequired = false} = props;\n let content = useMemo(\n () =>\n typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n isFocused: false,\n isFocusVisible: false,\n defaultChildren: null\n })\n : children,\n [children, isDisabled, isInvalid, isRequired]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <SelectInner props={props} collection={collection} selectRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, TextContext];\n\ninterface SelectInnerProps<T> {\n props: SelectProps<T, SelectionMode>;\n selectRef: ForwardedRef<HTMLDivElement>;\n collection: Collection<Node<T>>;\n}\n\nfunction SelectInner<T>({props, selectRef: ref, collection}: SelectInnerProps<T>) {\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let state = useSelectState({\n ...props,\n collection,\n children: undefined,\n validationBehavior\n });\n\n let {isFocusVisible, focusProps} = useFocusRing({within: true});\n\n // Get props for child elements from useSelect\n let buttonRef = useRef<HTMLButtonElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n labelProps,\n triggerProps,\n valueProps,\n menuProps,\n descriptionProps,\n errorMessageProps,\n hiddenSelectProps,\n ...validation\n } = useSelect(\n {\n ...removeDataAttributes(props),\n label,\n validationBehavior\n },\n state,\n buttonRef\n );\n\n // Only expose a subset of state to renderProps function to avoid infinite render loop\n let renderPropsState = useMemo(\n () => ({\n isOpen: state.isOpen,\n isFocused: state.isFocused,\n isFocusVisible,\n isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false\n }),\n [\n state.isOpen,\n state.isFocused,\n isFocusVisible,\n props.isDisabled,\n validation.isInvalid,\n props.isRequired\n ]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-Select'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [SelectContext, props],\n [SelectStateContext, state],\n [SelectValueContext, valueProps],\n [LabelContext, {...labelProps, ref: labelRef, elementType: 'span'}],\n [\n ButtonContext,\n {...triggerProps, ref: buttonRef, isPressed: state.isOpen, autoFocus: props.autoFocus}\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n trigger: 'Select',\n triggerRef: buttonRef,\n scrollRef,\n placement: 'bottom start',\n 'aria-labelledby': menuProps['aria-labelledby'],\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...menuProps, ref: scrollRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [FieldErrorContext, validation]\n ]}>\n <dom.div\n {...mergeProps(DOMProps, renderProps, focusProps)}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n <HiddenSelect {...hiddenSelectProps} autoComplete={props.autoComplete} />\n </dom.div>\n </Provider>\n );\n}\n\nexport interface SelectValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\n /**\n * The object value of the first selected item.\n *\n * @deprecated\n */\n selectedItem: T | null;\n /** The object values of the currently selected items. */\n selectedItems: (T | null)[];\n /** The textValue of the currently selected items. */\n selectedText: string;\n /** The state of the select. */\n state: SelectState<T, 'single' | 'multiple'>;\n}\n\nexport interface SelectValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<SelectValueRenderProps<T>, 'span'> {\n /**\n * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the\n * element. A function may be provided to compute the class based on component state.\n *\n * @default 'react-aria-SelectValue'\n */\n className?: ClassNameOrFunction<SelectValueRenderProps<T>>;\n}\n\nexport const SelectValueContext =\n createContext<ContextValue<SelectValueProps<any>, HTMLSpanElement>>(null);\n\n/**\n * SelectValue renders the current value of a Select, or a placeholder if no value is selected.\n * It is usually placed within the button element.\n */\nexport const SelectValue = /*#__PURE__*/ createHideableComponent(function SelectValue<T>(\n props: SelectValueProps<T>,\n ref: ForwardedRef<HTMLSpanElement>\n) {\n [props, ref] = useContextProps(props, ref, SelectValueContext);\n let state = useContext(SelectStateContext)! as SelectState<T, 'single' | 'multiple'>;\n let {placeholder} = useSlottedContext(SelectContext)!;\n let rendered = state.selectedItems.map(item => {\n let rendered = item.props?.children;\n // If the selected item has a function as a child, we need to call it to render to React.JSX.\n if (typeof rendered === 'function') {\n let fn = rendered as (s: ItemRenderProps) => ReactNode;\n rendered = fn({\n isHovered: false,\n isPressed: false,\n isSelected: false,\n isFocused: false,\n isFocusVisible: false,\n isDisabled: false,\n selectionMode: 'single',\n selectionBehavior: 'toggle'\n });\n }\n\n return rendered;\n });\n\n let formatter = useListFormatter();\n let textValue = useMemo(\n () => state.selectedItems.map(item => item?.textValue),\n [state.selectedItems]\n );\n let selectionMode = state.selectionManager.selectionMode;\n let selectedText = useMemo(\n () => (selectionMode === 'single' ? (textValue[0] ?? '') : formatter.format(textValue)),\n [selectionMode, formatter, textValue]\n );\n\n let defaultChildren = useMemo(() => {\n if (selectionMode === 'single') {\n return rendered[0];\n }\n\n let parts = formatter.formatToParts(textValue);\n if (parts.length === 0) {\n return null;\n }\n\n let index = 0;\n return parts.map(part => {\n if (part.type === 'element') {\n return <Fragment key={index}>{rendered[index++]}</Fragment>;\n } else {\n return part.value;\n }\n });\n }, [selectionMode, formatter, textValue, rendered]);\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, 'react-aria-components');\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: defaultChildren ?? placeholder ?? stringFormatter.format('selectPlaceholder'),\n defaultClassName: 'react-aria-SelectValue',\n values: {\n selectedItem: (state.selectedItems[0]?.value as T) ?? null,\n selectedItems: useMemo(\n () => state.selectedItems.map(item => (item.value as T) ?? null),\n [state.selectedItems]\n ),\n selectedText,\n isPlaceholder: state.selectedItems.length === 0,\n state\n }\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n\n return (\n <dom.span\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}>\n {/* clear description and error message slots */}\n <TextContext.Provider value={undefined}>{renderProps.children}</TextContext.Provider>\n </dom.span>\n );\n});\n"],"names":[],"version":3,"file":"Select.mjs.map"}
@@ -308,7 +308,8 @@ const $af9b3e5459f1bf61$export$7063e69b8a954175 = /*#__PURE__*/ (0, $ke19Y$react
308
308
  tableRef: tableRef,
309
309
  scrollRef: scrollRef,
310
310
  tableWidth: width,
311
- useTableColumnResizeState: $ke19Y$reactstatelyuseTableState.useTableColumnResizeState,
311
+ useTableColumnResizeState: // oxlint-disable-next-line react/react-compiler
312
+ $ke19Y$reactstatelyuseTableState.useTableColumnResizeState,
312
313
  onResizeStart: props.onResizeStart,
313
314
  onResize: props.onResize,
314
315
  onResizeEnd: props.onResizeEnd
@@ -336,6 +337,7 @@ const $af9b3e5459f1bf61$export$93e4b0b2cc49b648 = /*#__PURE__*/ (0, $ke19Y$react
336
337
  const $af9b3e5459f1bf61$export$38de1cb0526c21fb = /*#__PURE__*/ (0, $ke19Y$react.createContext)(null);
337
338
  const $af9b3e5459f1bf61$export$a2680a798823803c = /*#__PURE__*/ (0, $ke19Y$react.createContext)(null);
338
339
  const $af9b3e5459f1bf61$export$54ec01a60f47d33d = /*#__PURE__*/ (0, $ke19Y$react.forwardRef)(function Table(props, ref) {
340
+ // oxlint-disable-next-line react/react-compiler
339
341
  [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $af9b3e5459f1bf61$export$93e4b0b2cc49b648);
340
342
  // Separate selection state so we have access to it from collection components via useTableOptions.
341
343
  let selectionState = (0, $ke19Y$reactstatelyuseMultipleSelectionState.useMultipleSelectionState)(props);
@@ -387,6 +389,7 @@ const $af9b3e5459f1bf61$var$EXPANSION_KEYS = {
387
389
  }
388
390
  };
389
391
  function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, selectionState: selectionState, collection: collection }) {
392
+ // oxlint-disable-next-line react/react-compiler
390
393
  [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, (0, $433949643203e332$exports.SelectableCollectionContext));
391
394
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
392
395
  let { shouldUseVirtualFocus: shouldUseVirtualFocus, disallowTypeAhead: disallowTypeAhead, filter: filter, ...DOMCollectionProps } = props;
@@ -396,6 +399,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
396
399
  tableContainerContext?.tableRef
397
400
  ]));
398
401
  let [expandedKeys, setExpandedKeys] = (0, $ke19Y$reactstatelyuseControlledState.useControlledState)(props.expandedKeys ? new Set(props.expandedKeys) : undefined, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), props.onExpandedChange);
402
+ // oxlint-disable-next-line react/react-compiler
399
403
  collection = (0, $ke19Y$react.useMemo)(()=>collection.withExpandedKeys(expandedKeys), [
400
404
  collection,
401
405
  expandedKeys
@@ -408,6 +412,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
408
412
  expandedKeys: expandedKeys,
409
413
  onExpandedChange: setExpandedKeys
410
414
  });
415
+ // oxlint-disable-next-line react/react-compiler
411
416
  let filteredState = (0, $ke19Y$reactstatelyuseTableState.UNSTABLE_useFilteredTableState)(tableState, filter);
412
417
  let { isVirtualized: isVirtualized, layoutDelegate: layoutDelegate, dropTargetDelegate: ctxDropTargetDelegate, CollectionRoot: CollectionRoot } = (0, $ke19Y$react.useContext)((0, $f7b82bedbb70abac$exports.CollectionRendererContext));
413
418
  let { dragAndDropHooks: dragAndDropHooks } = props;
@@ -438,11 +443,13 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
438
443
  let { direction: direction } = (0, $ke19Y$reactariaI18nProvider.useLocale)();
439
444
  let [treeDropTargetDelegate] = (0, $ke19Y$react.useState)(()=>new (0, $56f56e0916461149$exports.TreeDropTargetDelegate)());
440
445
  if (hasDragHooks && dragAndDropHooks) {
446
+ // oxlint-disable-next-line react/react-compiler
441
447
  dragState = dragAndDropHooks.useDraggableCollectionState({
442
448
  collection: filteredState.collection,
443
449
  selectionManager: selectionManager,
444
450
  preview: dragAndDropHooks.renderDragPreview ? preview : undefined
445
451
  });
452
+ // oxlint-disable-next-line react/react-compiler
446
453
  dragAndDropHooks.useDraggableCollection({}, dragState, ref);
447
454
  let DragPreview = dragAndDropHooks.DragPreview;
448
455
  dragPreview = dragAndDropHooks.renderDragPreview ? /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement(DragPreview, {
@@ -450,6 +457,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
450
457
  }, dragAndDropHooks.renderDragPreview) : null;
451
458
  }
452
459
  if (hasDropHooks && dragAndDropHooks) {
460
+ // oxlint-disable-next-line react/react-compiler
453
461
  dropState = dragAndDropHooks.useDroppableCollectionState({
454
462
  collection: filteredState.collection,
455
463
  selectionManager: selectionManager
@@ -463,6 +471,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
463
471
  });
464
472
  let dropTargetDelegate = dragAndDropHooks.dropTargetDelegate || ctxDropTargetDelegate || new dragAndDropHooks.ListDropTargetDelegate(collection.rows, ref);
465
473
  treeDropTargetDelegate.setup(dropTargetDelegate, tableState, direction);
474
+ // oxlint-disable-next-line react/react-compiler
466
475
  droppableCollection = dragAndDropHooks.useDroppableCollection({
467
476
  keyboardDelegate: keyboardDelegate,
468
477
  dropTargetDelegate: treeDropTargetDelegate,
@@ -504,6 +513,7 @@ function $af9b3e5459f1bf61$var$TableInner({ props: props, forwardedRef: ref, sel
504
513
  let style = renderProps.style;
505
514
  let layoutState = null;
506
515
  if (tableContainerContext) {
516
+ // oxlint-disable-next-line react/react-compiler
507
517
  layoutState = tableContainerContext.useTableColumnResizeState({
508
518
  tableWidth: tableContainerContext.tableWidth
509
519
  }, filteredState);
@@ -697,7 +707,9 @@ const $af9b3e5459f1bf61$export$816b5d811295e6bc = /*#__PURE__*/ (0, $ke19Y$react
697
707
  let { isVirtualized: isVirtualized } = (0, $ke19Y$react.useContext)((0, $f7b82bedbb70abac$exports.CollectionRendererContext));
698
708
  let { columnHeaderProps: columnHeaderProps, isPressed: isPressed } = (0, $ke19Y$reactariauseTable.useTableColumnHeader)({
699
709
  node: column,
700
- isVirtualized: isVirtualized
710
+ isVirtualized: isVirtualized,
711
+ focusMode: props.focusMode,
712
+ allowsArrowNavigation: props.allowsArrowNavigation
701
713
  }, state, ref);
702
714
  let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $ke19Y$reactariauseFocusRing.useFocusRing)();
703
715
  let layoutState = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$export$a2680a798823803c);
@@ -783,7 +795,7 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
783
795
  let { onResizeStart: onResizeStart, onResize: onResize, onResizeEnd: onResizeEnd } = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$var$ResizableTableContainerContext);
784
796
  let { column: column, triggerRef: triggerRef } = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$var$ColumnResizerContext);
785
797
  let inputRef = (0, $ke19Y$react.useRef)(null);
786
- let { resizerProps: resizerProps, inputProps: inputProps, isResizing: isResizing } = (0, $ke19Y$reactariauseTable.useTableColumnResize)({
798
+ let { resizerProps: resizerProps, inputProps: inputProps, isResizing: isResizing, isMouseResizing: isMouseResizing } = (0, $ke19Y$reactariauseTable.useTableColumnResize)({
787
799
  column: column,
788
800
  'aria-label': props['aria-label'] || stringFormatter.format('tableResizer'),
789
801
  onResizeStart: onResizeStart,
@@ -821,20 +833,15 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
821
833
  resizableDirection: resizableDirection
822
834
  }
823
835
  });
824
- let [isMouseDown, setMouseDown] = (0, $ke19Y$react.useState)(false);
825
- let onPointerDown = (e)=>{
826
- if (e.pointerType === 'mouse') setMouseDown(true);
827
- };
828
- if (!isResizing && isMouseDown) setMouseDown(false);
829
836
  let DOMProps = (0, $ke19Y$reactariafilterDOMProps.filterDOMProps)(props, {
830
837
  global: true
831
838
  });
839
+ // Cursor overlay is used to style the cursor against the entire screen.
840
+ // Do not turn off pointer events or the cursor will no longer be styled.
832
841
  return /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
833
842
  ref: objectRef,
834
843
  role: "presentation",
835
- ...(0, $ke19Y$reactariamergeProps.mergeProps)(DOMProps, renderProps, resizerProps, {
836
- onPointerDown: onPointerDown
837
- }, hoverProps),
844
+ ...(0, $ke19Y$reactariamergeProps.mergeProps)(DOMProps, renderProps, resizerProps, hoverProps),
838
845
  "data-hovered": isHovered || undefined,
839
846
  "data-focused": isFocused || undefined,
840
847
  "data-focus-visible": isFocusVisible || undefined,
@@ -843,7 +850,7 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
843
850
  }, renderProps.children, /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement("input", {
844
851
  ref: inputRef,
845
852
  ...(0, $ke19Y$reactariamergeProps.mergeProps)(inputProps, focusProps)
846
- }), isResizing && isMouseDown && /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$reactdom))).createPortal(/*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement("div", {
853
+ }), isResizing && isMouseResizing && /*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$reactdom))).createPortal(/*#__PURE__*/ (0, ($parcel$interopDefault($ke19Y$react))).createElement("div", {
847
854
  style: {
848
855
  position: 'fixed',
849
856
  top: 0,
@@ -851,7 +858,8 @@ const $af9b3e5459f1bf61$export$ee689e97a7664bfd = /*#__PURE__*/ (0, $ke19Y$react
851
858
  bottom: 0,
852
859
  right: 0,
853
860
  cursor: cursor
854
- }
861
+ },
862
+ "data-testid": "cursor-overlay"
855
863
  }), document.body));
856
864
  });
857
865
  class $af9b3e5459f1bf61$var$TableBodyNode extends (0, $ke19Y$reactariaprivatecollectionsBaseCollection.FilterableNode) {
@@ -1200,7 +1208,9 @@ const $af9b3e5459f1bf61$export$f6f0c3fe4ec306ea = /*#__PURE__*/ (0, $ke19Y$react
1200
1208
  let { gridCellProps: gridCellProps, isPressed: isPressed } = (0, $ke19Y$reactariauseTable.useTableCell)({
1201
1209
  node: cell,
1202
1210
  shouldSelectOnPressUp: !!dragState,
1203
- isVirtualized: isVirtualized
1211
+ isVirtualized: isVirtualized,
1212
+ focusMode: props.focusMode,
1213
+ allowsArrowNavigation: props.allowsArrowNavigation
1204
1214
  }, state, ref);
1205
1215
  let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $ke19Y$reactariauseFocusRing.useFocusRing)();
1206
1216
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $ke19Y$reactariauseHover.useHover)({});
@@ -1258,6 +1268,7 @@ function $af9b3e5459f1bf61$var$TableDropIndicatorWrapper(props, ref) {
1258
1268
  ref = (0, $ke19Y$reactariauseObjectRef.useObjectRef)(ref);
1259
1269
  let { dragAndDropHooks: dragAndDropHooks, dropState: dropState } = (0, $ke19Y$react.useContext)((0, $d3d8871226fc64f2$exports.DragAndDropContext));
1260
1270
  let buttonRef = (0, $ke19Y$react.useRef)(null);
1271
+ // oxlint-disable-next-line react/react-compiler
1261
1272
  let { dropIndicatorProps: dropIndicatorProps, isHidden: isHidden, isDropTarget: isDropTarget } = dragAndDropHooks.useDropIndicator(props, dropState, buttonRef);
1262
1273
  if (isHidden) return null;
1263
1274
  let level = dropState && props.target.type === 'item' ? (dropState.collection.getItem(props.target.key)?.level || 0) + 1 : 1;
@@ -1334,6 +1345,7 @@ function $af9b3e5459f1bf61$var$RootDropIndicator() {
1334
1345
  let state = (0, $ke19Y$react.useContext)($af9b3e5459f1bf61$export$38de1cb0526c21fb);
1335
1346
  let { dragAndDropHooks: dragAndDropHooks, dropState: dropState } = (0, $ke19Y$react.useContext)((0, $d3d8871226fc64f2$exports.DragAndDropContext));
1336
1347
  let ref = (0, $ke19Y$react.useRef)(null);
1348
+ // oxlint-disable-next-line react/react-compiler
1337
1349
  let { dropIndicatorProps: dropIndicatorProps } = dragAndDropHooks.useDropIndicator({
1338
1350
  target: {
1339
1351
  type: 'root'