@depup/react-aria-components 1.19.0-depup.27 → 1.21.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 (333) hide show
  1. package/NavigationTree/package.json +5 -0
  2. package/PreviewTrigger/package.json +5 -0
  3. package/README.md +2 -2
  4. package/TokenField/package.json +5 -0
  5. package/changes.json +1 -1
  6. package/dist/exports/GridList.cjs.map +1 -1
  7. package/dist/exports/GridList.js.map +1 -1
  8. package/dist/exports/GridList.mjs.map +1 -1
  9. package/dist/exports/Menu.cjs +1 -0
  10. package/dist/exports/Menu.cjs.map +1 -1
  11. package/dist/exports/Menu.js +2 -2
  12. package/dist/exports/Menu.js.map +1 -1
  13. package/dist/exports/Menu.mjs +2 -2
  14. package/dist/exports/Menu.mjs.map +1 -1
  15. package/dist/exports/NavigationTree.cjs +37 -0
  16. package/dist/exports/NavigationTree.cjs.map +1 -0
  17. package/dist/exports/NavigationTree.js +25 -0
  18. package/dist/exports/NavigationTree.js.map +1 -0
  19. package/dist/exports/NavigationTree.mjs +25 -0
  20. package/dist/exports/NavigationTree.mjs.map +1 -0
  21. package/dist/exports/PreviewTrigger.cjs +26 -0
  22. package/dist/exports/PreviewTrigger.cjs.map +1 -0
  23. package/dist/exports/PreviewTrigger.js +21 -0
  24. package/dist/exports/PreviewTrigger.js.map +1 -0
  25. package/dist/exports/PreviewTrigger.mjs +21 -0
  26. package/dist/exports/PreviewTrigger.mjs.map +1 -0
  27. package/dist/exports/TokenField.cjs +31 -0
  28. package/dist/exports/TokenField.cjs.map +1 -0
  29. package/dist/exports/TokenField.js +21 -0
  30. package/dist/exports/TokenField.js.map +1 -0
  31. package/dist/exports/TokenField.mjs +21 -0
  32. package/dist/exports/TokenField.mjs.map +1 -0
  33. package/dist/exports/Tree.cjs.map +1 -1
  34. package/dist/exports/Tree.js.map +1 -1
  35. package/dist/exports/Tree.mjs.map +1 -1
  36. package/dist/exports/index.cjs +25 -0
  37. package/dist/exports/index.cjs.map +1 -1
  38. package/dist/exports/index.js +12 -2
  39. package/dist/exports/index.js.map +1 -1
  40. package/dist/exports/index.mjs +12 -2
  41. package/dist/exports/index.mjs.map +1 -1
  42. package/dist/private/Checkbox.cjs.map +1 -1
  43. package/dist/private/Checkbox.js.map +1 -1
  44. package/dist/private/Checkbox.mjs.map +1 -1
  45. package/dist/private/ComboBox.cjs +21 -2
  46. package/dist/private/ComboBox.cjs.map +1 -1
  47. package/dist/private/ComboBox.js +21 -2
  48. package/dist/private/ComboBox.js.map +1 -1
  49. package/dist/private/ComboBox.mjs +21 -2
  50. package/dist/private/ComboBox.mjs.map +1 -1
  51. package/dist/private/Dialog.cjs +21 -1
  52. package/dist/private/Dialog.cjs.map +1 -1
  53. package/dist/private/Dialog.js +21 -1
  54. package/dist/private/Dialog.js.map +1 -1
  55. package/dist/private/Dialog.mjs +21 -1
  56. package/dist/private/Dialog.mjs.map +1 -1
  57. package/dist/private/DragAndDrop.cjs +1 -0
  58. package/dist/private/DragAndDrop.cjs.map +1 -1
  59. package/dist/private/DragAndDrop.js +1 -0
  60. package/dist/private/DragAndDrop.js.map +1 -1
  61. package/dist/private/DragAndDrop.mjs +1 -0
  62. package/dist/private/DragAndDrop.mjs.map +1 -1
  63. package/dist/private/DropZone.cjs +5 -2
  64. package/dist/private/DropZone.cjs.map +1 -1
  65. package/dist/private/DropZone.js +5 -3
  66. package/dist/private/DropZone.js.map +1 -1
  67. package/dist/private/DropZone.mjs +5 -2
  68. package/dist/private/DropZone.mjs.map +1 -1
  69. package/dist/private/FileTrigger.cjs +1 -0
  70. package/dist/private/FileTrigger.cjs.map +1 -1
  71. package/dist/private/FileTrigger.js +1 -0
  72. package/dist/private/FileTrigger.js.map +1 -1
  73. package/dist/private/FileTrigger.mjs +1 -0
  74. package/dist/private/FileTrigger.mjs.map +1 -1
  75. package/dist/private/GridLayout.cjs +3 -1
  76. package/dist/private/GridLayout.cjs.map +1 -1
  77. package/dist/private/GridLayout.js +3 -1
  78. package/dist/private/GridLayout.js.map +1 -1
  79. package/dist/private/GridLayout.mjs +3 -1
  80. package/dist/private/GridLayout.mjs.map +1 -1
  81. package/dist/private/GridList.cjs +12 -1
  82. package/dist/private/GridList.cjs.map +1 -1
  83. package/dist/private/GridList.js +12 -1
  84. package/dist/private/GridList.js.map +1 -1
  85. package/dist/private/GridList.mjs +12 -1
  86. package/dist/private/GridList.mjs.map +1 -1
  87. package/dist/private/ListBox.cjs +9 -1
  88. package/dist/private/ListBox.cjs.map +1 -1
  89. package/dist/private/ListBox.js +9 -1
  90. package/dist/private/ListBox.js.map +1 -1
  91. package/dist/private/ListBox.mjs +9 -1
  92. package/dist/private/ListBox.mjs.map +1 -1
  93. package/dist/private/Menu.cjs +59 -2
  94. package/dist/private/Menu.cjs.map +1 -1
  95. package/dist/private/Menu.js +60 -4
  96. package/dist/private/Menu.js.map +1 -1
  97. package/dist/private/Menu.mjs +60 -4
  98. package/dist/private/Menu.mjs.map +1 -1
  99. package/dist/private/Meter.cjs +2 -1
  100. package/dist/private/Meter.cjs.map +1 -1
  101. package/dist/private/Meter.js +2 -1
  102. package/dist/private/Meter.js.map +1 -1
  103. package/dist/private/Meter.mjs +2 -1
  104. package/dist/private/Meter.mjs.map +1 -1
  105. package/dist/private/Modal.cjs +2 -0
  106. package/dist/private/Modal.cjs.map +1 -1
  107. package/dist/private/Modal.js +2 -0
  108. package/dist/private/Modal.js.map +1 -1
  109. package/dist/private/Modal.mjs +2 -0
  110. package/dist/private/Modal.mjs.map +1 -1
  111. package/dist/private/NavigationTree.cjs +272 -0
  112. package/dist/private/NavigationTree.cjs.map +1 -0
  113. package/dist/private/NavigationTree.js +258 -0
  114. package/dist/private/NavigationTree.js.map +1 -0
  115. package/dist/private/NavigationTree.mjs +257 -0
  116. package/dist/private/NavigationTree.mjs.map +1 -0
  117. package/dist/private/Popover.cjs +34 -9
  118. package/dist/private/Popover.cjs.map +1 -1
  119. package/dist/private/Popover.js +34 -9
  120. package/dist/private/Popover.js.map +1 -1
  121. package/dist/private/Popover.mjs +34 -9
  122. package/dist/private/Popover.mjs.map +1 -1
  123. package/dist/private/PreviewTrigger.cjs +88 -0
  124. package/dist/private/PreviewTrigger.cjs.map +1 -0
  125. package/dist/private/PreviewTrigger.js +80 -0
  126. package/dist/private/PreviewTrigger.js.map +1 -0
  127. package/dist/private/PreviewTrigger.mjs +79 -0
  128. package/dist/private/PreviewTrigger.mjs.map +1 -0
  129. package/dist/private/ProgressBar.cjs +6 -1
  130. package/dist/private/ProgressBar.cjs.map +1 -1
  131. package/dist/private/ProgressBar.js +6 -1
  132. package/dist/private/ProgressBar.js.map +1 -1
  133. package/dist/private/ProgressBar.mjs +6 -1
  134. package/dist/private/ProgressBar.mjs.map +1 -1
  135. package/dist/private/RadioGroup.cjs.map +1 -1
  136. package/dist/private/RadioGroup.js.map +1 -1
  137. package/dist/private/RadioGroup.mjs.map +1 -1
  138. package/dist/private/Select.cjs.map +1 -1
  139. package/dist/private/Select.js.map +1 -1
  140. package/dist/private/Select.mjs.map +1 -1
  141. package/dist/private/Switch.cjs +8 -2
  142. package/dist/private/Switch.cjs.map +1 -1
  143. package/dist/private/Switch.js +9 -3
  144. package/dist/private/Switch.js.map +1 -1
  145. package/dist/private/Switch.mjs +9 -3
  146. package/dist/private/Switch.mjs.map +1 -1
  147. package/dist/private/Table.cjs +26 -14
  148. package/dist/private/Table.cjs.map +1 -1
  149. package/dist/private/Table.js +26 -14
  150. package/dist/private/Table.js.map +1 -1
  151. package/dist/private/Table.mjs +26 -14
  152. package/dist/private/Table.mjs.map +1 -1
  153. package/dist/private/TableLayout.cjs +3 -1
  154. package/dist/private/TableLayout.cjs.map +1 -1
  155. package/dist/private/TableLayout.js +3 -1
  156. package/dist/private/TableLayout.js.map +1 -1
  157. package/dist/private/TableLayout.mjs +3 -1
  158. package/dist/private/TableLayout.mjs.map +1 -1
  159. package/dist/private/TagGroup.cjs +1 -0
  160. package/dist/private/TagGroup.cjs.map +1 -1
  161. package/dist/private/TagGroup.js +1 -0
  162. package/dist/private/TagGroup.js.map +1 -1
  163. package/dist/private/TagGroup.mjs +1 -0
  164. package/dist/private/TagGroup.mjs.map +1 -1
  165. package/dist/private/Text.cjs +3 -1
  166. package/dist/private/Text.cjs.map +1 -1
  167. package/dist/private/Text.js +4 -2
  168. package/dist/private/Text.js.map +1 -1
  169. package/dist/private/Text.mjs +4 -2
  170. package/dist/private/Text.mjs.map +1 -1
  171. package/dist/private/ToggleButton.cjs.map +1 -1
  172. package/dist/private/ToggleButton.js.map +1 -1
  173. package/dist/private/ToggleButton.mjs.map +1 -1
  174. package/dist/private/TokenField.cjs +235 -0
  175. package/dist/private/TokenField.cjs.map +1 -0
  176. package/dist/private/TokenField.js +225 -0
  177. package/dist/private/TokenField.js.map +1 -0
  178. package/dist/private/TokenField.mjs +223 -0
  179. package/dist/private/TokenField.mjs.map +1 -0
  180. package/dist/private/Tooltip.cjs +10 -2
  181. package/dist/private/Tooltip.cjs.map +1 -1
  182. package/dist/private/Tooltip.js +10 -2
  183. package/dist/private/Tooltip.js.map +1 -1
  184. package/dist/private/Tooltip.mjs +10 -2
  185. package/dist/private/Tooltip.mjs.map +1 -1
  186. package/dist/private/Tree.cjs +11 -1
  187. package/dist/private/Tree.cjs.map +1 -1
  188. package/dist/private/Tree.js +11 -1
  189. package/dist/private/Tree.js.map +1 -1
  190. package/dist/private/Tree.mjs +11 -1
  191. package/dist/private/Tree.mjs.map +1 -1
  192. package/dist/private/TreeDropTargetDelegate.cjs +11 -6
  193. package/dist/private/TreeDropTargetDelegate.cjs.map +1 -1
  194. package/dist/private/TreeDropTargetDelegate.js +11 -6
  195. package/dist/private/TreeDropTargetDelegate.js.map +1 -1
  196. package/dist/private/TreeDropTargetDelegate.mjs +11 -6
  197. package/dist/private/TreeDropTargetDelegate.mjs.map +1 -1
  198. package/dist/private/Virtualizer.cjs +18 -16
  199. package/dist/private/Virtualizer.cjs.map +1 -1
  200. package/dist/private/Virtualizer.js +18 -16
  201. package/dist/private/Virtualizer.js.map +1 -1
  202. package/dist/private/Virtualizer.mjs +18 -16
  203. package/dist/private/Virtualizer.mjs.map +1 -1
  204. package/dist/private/useDragAndDrop.cjs +7 -0
  205. package/dist/private/useDragAndDrop.cjs.map +1 -1
  206. package/dist/private/useDragAndDrop.js +7 -0
  207. package/dist/private/useDragAndDrop.js.map +1 -1
  208. package/dist/private/useDragAndDrop.mjs +7 -0
  209. package/dist/private/useDragAndDrop.mjs.map +1 -1
  210. package/dist/private/utils.cjs.map +1 -1
  211. package/dist/private/utils.js.map +1 -1
  212. package/dist/private/utils.mjs.map +1 -1
  213. package/dist/types/exports/GridList.d.ts +1 -1
  214. package/dist/types/exports/Menu.d.ts +2 -2
  215. package/dist/types/exports/NavigationTree.d.ts +8 -0
  216. package/dist/types/exports/PreviewTrigger.d.ts +3 -0
  217. package/dist/types/exports/TokenField.d.ts +5 -0
  218. package/dist/types/exports/Tree.d.ts +1 -1
  219. package/dist/types/exports/index.d.ts +14 -5
  220. package/dist/types/src/Breadcrumbs.d.ts +2 -2
  221. package/dist/types/src/Button.d.ts +1 -1
  222. package/dist/types/src/Calendar.d.ts +6 -6
  223. package/dist/types/src/Checkbox.d.ts +8 -8
  224. package/dist/types/src/Collection.d.ts +1 -1
  225. package/dist/types/src/ComboBox.d.ts +6 -3
  226. package/dist/types/src/DateField.d.ts +4 -4
  227. package/dist/types/src/DatePicker.d.ts +2 -2
  228. package/dist/types/src/Dialog.d.ts +2 -2
  229. package/dist/types/src/Disclosure.d.ts +2 -2
  230. package/dist/types/src/GridList.d.ts +18 -7
  231. package/dist/types/src/Group.d.ts +1 -1
  232. package/dist/types/src/Header.d.ts +1 -1
  233. package/dist/types/src/Input.d.ts +1 -1
  234. package/dist/types/src/Label.d.ts +1 -1
  235. package/dist/types/src/Link.d.ts +1 -1
  236. package/dist/types/src/ListBox.d.ts +6 -6
  237. package/dist/types/src/Menu.d.ts +25 -6
  238. package/dist/types/src/Meter.d.ts +1 -1
  239. package/dist/types/src/Modal.d.ts +2 -2
  240. package/dist/types/src/NavigationTree.d.ts +80 -0
  241. package/dist/types/src/NumberField.d.ts +1 -1
  242. package/dist/types/src/OverlayArrow.d.ts +1 -1
  243. package/dist/types/src/Popover.d.ts +8 -1
  244. package/dist/types/src/PreviewTrigger.d.ts +23 -0
  245. package/dist/types/src/RadioGroup.d.ts +8 -8
  246. package/dist/types/src/SearchField.d.ts +1 -1
  247. package/dist/types/src/Select.d.ts +3 -3
  248. package/dist/types/src/Separator.d.ts +1 -1
  249. package/dist/types/src/Slider.d.ts +5 -5
  250. package/dist/types/src/Switch.d.ts +7 -7
  251. package/dist/types/src/Table.d.ts +32 -8
  252. package/dist/types/src/Tabs.d.ts +5 -5
  253. package/dist/types/src/TagGroup.d.ts +3 -3
  254. package/dist/types/src/Text.d.ts +1 -1
  255. package/dist/types/src/TextField.d.ts +1 -1
  256. package/dist/types/src/Toast.d.ts +3 -3
  257. package/dist/types/src/ToggleButton.d.ts +1 -1
  258. package/dist/types/src/ToggleButtonGroup.d.ts +1 -1
  259. package/dist/types/src/TokenField.d.ts +111 -0
  260. package/dist/types/src/Toolbar.d.ts +1 -1
  261. package/dist/types/src/Tooltip.d.ts +1 -1
  262. package/dist/types/src/Tree.d.ts +12 -10
  263. package/dist/types/src/Virtualizer.d.ts +4 -0
  264. package/dist/types/src/utils.d.ts +19 -5
  265. package/i18n/ar-AE.js +1 -1
  266. package/i18n/ar-AE.mjs +1 -1
  267. package/i18n/bg-BG.js +1 -1
  268. package/i18n/bg-BG.mjs +1 -1
  269. package/i18n/cs-CZ.js +1 -1
  270. package/i18n/cs-CZ.mjs +1 -1
  271. package/i18n/da-DK.js +1 -1
  272. package/i18n/da-DK.mjs +1 -1
  273. package/i18n/de-DE.js +1 -1
  274. package/i18n/de-DE.mjs +1 -1
  275. package/i18n/el-GR.js +1 -1
  276. package/i18n/el-GR.mjs +1 -1
  277. package/i18n/en-US.js +1 -1
  278. package/i18n/en-US.mjs +1 -1
  279. package/i18n/es-ES.js +1 -1
  280. package/i18n/es-ES.mjs +1 -1
  281. package/i18n/et-EE.js +1 -1
  282. package/i18n/et-EE.mjs +1 -1
  283. package/i18n/fi-FI.js +1 -1
  284. package/i18n/fi-FI.mjs +1 -1
  285. package/i18n/fr-FR.js +1 -1
  286. package/i18n/fr-FR.mjs +1 -1
  287. package/i18n/he-IL.js +1 -1
  288. package/i18n/he-IL.mjs +1 -1
  289. package/i18n/hr-HR.js +1 -1
  290. package/i18n/hr-HR.mjs +1 -1
  291. package/i18n/hu-HU.js +1 -1
  292. package/i18n/hu-HU.mjs +1 -1
  293. package/i18n/it-IT.js +1 -1
  294. package/i18n/it-IT.mjs +1 -1
  295. package/i18n/ja-JP.js +1 -1
  296. package/i18n/ja-JP.mjs +1 -1
  297. package/i18n/ko-KR.js +1 -1
  298. package/i18n/ko-KR.mjs +1 -1
  299. package/i18n/lt-LT.js +1 -1
  300. package/i18n/lt-LT.mjs +1 -1
  301. package/i18n/lv-LV.js +1 -1
  302. package/i18n/lv-LV.mjs +1 -1
  303. package/i18n/nb-NO.js +1 -1
  304. package/i18n/nb-NO.mjs +1 -1
  305. package/i18n/nl-NL.js +1 -1
  306. package/i18n/nl-NL.mjs +1 -1
  307. package/i18n/pl-PL.js +1 -1
  308. package/i18n/pl-PL.mjs +1 -1
  309. package/i18n/pt-BR.js +1 -1
  310. package/i18n/pt-BR.mjs +1 -1
  311. package/i18n/pt-PT.js +1 -1
  312. package/i18n/pt-PT.mjs +1 -1
  313. package/i18n/ro-RO.js +1 -1
  314. package/i18n/ro-RO.mjs +1 -1
  315. package/i18n/ru-RU.js +1 -1
  316. package/i18n/ru-RU.mjs +1 -1
  317. package/i18n/sk-SK.js +1 -1
  318. package/i18n/sk-SK.mjs +1 -1
  319. package/i18n/sl-SI.js +1 -1
  320. package/i18n/sl-SI.mjs +1 -1
  321. package/i18n/sr-SP.js +1 -1
  322. package/i18n/sr-SP.mjs +1 -1
  323. package/i18n/sv-SE.js +1 -1
  324. package/i18n/sv-SE.mjs +1 -1
  325. package/i18n/tr-TR.js +1 -1
  326. package/i18n/tr-TR.mjs +1 -1
  327. package/i18n/uk-UA.js +1 -1
  328. package/i18n/uk-UA.mjs +1 -1
  329. package/i18n/zh-CN.js +1 -1
  330. package/i18n/zh-CN.mjs +1 -1
  331. package/i18n/zh-TW.js +1 -1
  332. package/i18n/zh-TW.mjs +1 -1
  333. package/package.json +33 -31
@@ -1,6 +1,7 @@
1
1
  var $16c7f9b22cce3838$exports = require("./Button.cjs");
2
2
  var $048d76b84370f141$exports = require("./utils.cjs");
3
3
  var $862aa7df04d8fa76$exports = require("./FieldError.cjs");
4
+ var $433949643203e332$exports = require("./Autocomplete.cjs");
4
5
  var $5adc12e2ce73be8f$exports = require("./Form.cjs");
5
6
  var $f3068c15cd7dcac2$exports = require("./Group.cjs");
6
7
  var $81dc1c05bf045ce0$exports = require("./Input.cjs");
@@ -63,6 +64,7 @@ $parcel$export(module.exports, "ComboBoxValue", function () { return $251f6141ad
63
64
 
64
65
 
65
66
 
67
+
66
68
  const $251f6141ad6e692a$export$d414ccceff7063c3 = /*#__PURE__*/ (0, $3UK7x$react.createContext)(null);
67
69
  const $251f6141ad6e692a$export$c02625b26074192c = /*#__PURE__*/ (0, $3UK7x$react.createContext)(null);
68
70
  const $251f6141ad6e692a$export$72b9695b8216309a = /*#__PURE__*/ (0, $3UK7x$reactariaprivatecollectionsHidden.createHideableComponent)(function ComboBox(props, ref) {
@@ -101,6 +103,7 @@ const $251f6141ad6e692a$var$CLEAR_CONTEXTS = [
101
103
  (0, $d5d46822336ca1e1$exports.LabelContext),
102
104
  (0, $16c7f9b22cce3838$exports.ButtonContext),
103
105
  (0, $81dc1c05bf045ce0$exports.InputContext),
106
+ (0, $433949643203e332$exports.FieldInputContext),
104
107
  (0, $f3068c15cd7dcac2$exports.GroupContext),
105
108
  (0, $cab7d9a238d19c33$exports.TextContext)
106
109
  ];
@@ -127,6 +130,7 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
127
130
  let listBoxRef = (0, $3UK7x$react.useRef)(null);
128
131
  let popoverRef = (0, $3UK7x$react.useRef)(null);
129
132
  let [labelRef, label] = (0, $048d76b84370f141$exports.useSlot)(!props['aria-label'] && !props['aria-labelledby']);
133
+ let [labelElementType, setLabelElementType] = (0, $3UK7x$react.useState)('label');
130
134
  let { buttonProps: buttonProps, inputProps: inputProps, listBoxProps: listBoxProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, valueProps: valueProps, ...validation } = (0, $3UK7x$reactariauseComboBox.useComboBox)({
131
135
  ...(0, $048d76b84370f141$exports.removeDataAttributes)(props),
132
136
  label: label,
@@ -135,7 +139,8 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
135
139
  listBoxRef: listBoxRef,
136
140
  popoverRef: popoverRef,
137
141
  name: formValue === 'text' ? name : undefined,
138
- validationBehavior: validationBehavior
142
+ validationBehavior: validationBehavior,
143
+ labelElementType: labelElementType
139
144
  }, state);
140
145
  // Make menu width match input + button
141
146
  // Left for backward compatibility in case a <Group> is not rendered.
@@ -162,7 +167,8 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
162
167
  get current () {
163
168
  return groupRef.current || inputRef.current;
164
169
  }
165
- }), [
170
+ }), // oxlint-disable-next-line react/react-compiler
171
+ [
166
172
  groupRef,
167
173
  inputRef
168
174
  ]);
@@ -215,6 +221,7 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
215
221
  (0, $d5d46822336ca1e1$exports.LabelContext),
216
222
  {
217
223
  ...labelProps,
224
+ elementType: labelElementType,
218
225
  ref: labelRef
219
226
  }
220
227
  ],
@@ -233,6 +240,18 @@ function $251f6141ad6e692a$var$ComboBoxInner({ props: props, collection: collect
233
240
  ref: inputRef
234
241
  }
235
242
  ],
243
+ [
244
+ (0, $433949643203e332$exports.FieldInputContext),
245
+ {
246
+ ...inputProps,
247
+ ref: (0, $3UK7x$react.useCallback)((el)=>{
248
+ inputRef.current = el; // TODO: figure out how to fix non-input element types in useComboBox/useTextField
249
+ if (el) setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');
250
+ }, []),
251
+ value: state.inputValue,
252
+ onChange: (v)=>state.setInputValue(v)
253
+ }
254
+ ],
236
255
  [
237
256
  (0, $88595bf043e542ec$exports.OverlayTriggerStateContext),
238
257
  state
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAwHM,MAAM,0DACX,CAAA,GAAA,0BAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,0BAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,gEAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,oBAAM,EAClB,kBACE,0DAAC,CAAA,GAAA,wCAAa,EAAE,QAAQ;YAAC,OAAO;gBAAC,OAAO,MAAM,KAAK,IAAI,MAAM,YAAY;YAAA;WACtE,OAAO,aAAa,aACjB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,iBAAiB;wBACjB;QACF,KACA,WAGR;QAAC;QAAU;QAAY;QAAW;QAAY;QAAY,MAAM,KAAK;QAAE,MAAM,YAAY;KAAC;IAG5F,qBACE,0DAAC,CAAA,GAAA,mDAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,0DAAC;YAAc,OAAO;YAAO,YAAY;YAAY,aAAa;;AAGvF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IAAC,CAAA,GAAA,sCAAW;IAAG,CAAA,GAAA,uCAAY;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KAAK,IAAU,OAC3D;gBAAC,MAAM,aAAa;aAAC;0BAEvB;YACA,eAAe,MAAM,aAAa,CAAC,MAAM,KAAK;mBAC9C;QACF;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.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 */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\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 {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\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-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /** The filter function used to determine if a option should be included in the combo box list. */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, InputContext, GroupContext, TextContext];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n [groupRef, inputRef]\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 isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\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 ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\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-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\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.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;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AClB,QAAQ;YACN,eAAe,CAAA,GAAA,oBAAM,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,6CAAa,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,0DAAC,CAAA,GAAA,6BAAE,EAAE,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.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 */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\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, FocusableElement, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\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-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /**\n * The filter function used to determine if an option should be included in the combo box list.\n * By default, a language-sensitive \"contains\" filter from `useFilter` is used.\n */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [\n LabelContext,\n ButtonContext,\n InputContext,\n FieldInputContext,\n GroupContext,\n TextContext\n];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let [labelElementType, setLabelElementType] = useState<'span' | 'label'>('label');\n\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior,\n labelElementType\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n // oxlint-disable-next-line react/react-compiler\n [groupRef, inputRef]\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 isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, elementType: labelElementType, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [\n FieldInputContext,\n {\n ...inputProps,\n ref: useCallback((el: FocusableElement) => {\n inputRef.current = el as HTMLInputElement; // TODO: figure out how to fix non-input element types in useComboBox/useTextField\n if (el) {\n setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');\n }\n }, []),\n value: state.inputValue,\n onChange: v => state.setInputValue(v as string)\n } as any\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\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 ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\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-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\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.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.cjs.map"}
@@ -1,6 +1,7 @@
1
1
  import {ButtonContext as $fc203795b9b363cd$export$24d547caef80ccd1} from "./Button.js";
2
2
  import {dom as $b7b7a92703138c9b$export$df3a06d6289f983e, Provider as $b7b7a92703138c9b$export$2881499e37b75b9a, removeDataAttributes as $b7b7a92703138c9b$export$ef03459518577ad4, useContextProps as $b7b7a92703138c9b$export$29f1550f4b0d4415, useRenderProps as $b7b7a92703138c9b$export$4d86445c2cf5e3, useSlot as $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8, useSlottedContext as $b7b7a92703138c9b$export$fabf2dc03a41866e} from "./utils.js";
3
3
  import {FieldErrorContext as $6567560e1d9cc847$export$ff05c3ac10437e03} from "./FieldError.js";
4
+ import {FieldInputContext as $8f09b710ef85b337$export$698f465ec27e93df} from "./Autocomplete.js";
4
5
  import {FormContext as $c7332d4a2d191cd2$export$c24727297075ec6a} from "./Form.js";
5
6
  import {GroupContext as $2e357e4f16c05be6$export$f9c6924e160136d1} from "./Group.js";
6
7
  import {InputContext as $d8e7992b5f7739ce$export$37fb8590cf2c088c} from "./Input.js";
@@ -49,6 +50,7 @@ import {useResizeObserver as $feVgu$useResizeObserver} from "react-aria/private/
49
50
 
50
51
 
51
52
 
53
+
52
54
  const $ddc2347ad81bd857$export$d414ccceff7063c3 = /*#__PURE__*/ (0, $feVgu$createContext)(null);
53
55
  const $ddc2347ad81bd857$export$c02625b26074192c = /*#__PURE__*/ (0, $feVgu$createContext)(null);
54
56
  const $ddc2347ad81bd857$export$72b9695b8216309a = /*#__PURE__*/ (0, $feVgu$createHideableComponent)(function ComboBox(props, ref) {
@@ -90,6 +92,7 @@ const $ddc2347ad81bd857$var$CLEAR_CONTEXTS = [
90
92
  (0, $3e4839e5b30e7b17$export$75b6ee27786ba447),
91
93
  (0, $fc203795b9b363cd$export$24d547caef80ccd1),
92
94
  (0, $d8e7992b5f7739ce$export$37fb8590cf2c088c),
95
+ (0, $8f09b710ef85b337$export$698f465ec27e93df),
93
96
  (0, $2e357e4f16c05be6$export$f9c6924e160136d1),
94
97
  (0, $20d769b1e2b13352$export$9afb8bc826b033ea)
95
98
  ];
@@ -117,6 +120,7 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
117
120
  let listBoxRef = (0, $feVgu$useRef)(null);
118
121
  let popoverRef = (0, $feVgu$useRef)(null);
119
122
  let [labelRef, label] = (0, $b7b7a92703138c9b$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
123
+ let [labelElementType, setLabelElementType] = (0, $feVgu$useState)('label');
120
124
  let { buttonProps: buttonProps, inputProps: inputProps, listBoxProps: listBoxProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, valueProps: valueProps, ...validation } = (0, $feVgu$useComboBox)({
121
125
  ...(0, $b7b7a92703138c9b$export$ef03459518577ad4)(props),
122
126
  label: label,
@@ -125,7 +129,8 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
125
129
  listBoxRef: listBoxRef,
126
130
  popoverRef: popoverRef,
127
131
  name: formValue === 'text' ? name : undefined,
128
- validationBehavior: validationBehavior
132
+ validationBehavior: validationBehavior,
133
+ labelElementType: labelElementType
129
134
  }, state);
130
135
  // Make menu width match input + button
131
136
  // Left for backward compatibility in case a <Group> is not rendered.
@@ -153,7 +158,8 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
153
158
  get current () {
154
159
  return groupRef.current || inputRef.current;
155
160
  }
156
- }), [
161
+ }), // oxlint-disable-next-line react/react-compiler
162
+ [
157
163
  groupRef,
158
164
  inputRef
159
165
  ]);
@@ -206,6 +212,7 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
206
212
  (0, $3e4839e5b30e7b17$export$75b6ee27786ba447),
207
213
  {
208
214
  ...labelProps,
215
+ elementType: labelElementType,
209
216
  ref: labelRef
210
217
  }
211
218
  ],
@@ -224,6 +231,18 @@ function $ddc2347ad81bd857$var$ComboBoxInner({ props: props, collection: collect
224
231
  ref: inputRef
225
232
  }
226
233
  ],
234
+ [
235
+ (0, $8f09b710ef85b337$export$698f465ec27e93df),
236
+ {
237
+ ...inputProps,
238
+ ref: (0, $feVgu$useCallback)((el)=>{
239
+ inputRef.current = el; // TODO: figure out how to fix non-input element types in useComboBox/useTextField
240
+ if (el) setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');
241
+ }, []),
242
+ value: state.inputValue,
243
+ onChange: (v)=>state.setInputValue(v)
244
+ }
245
+ ],
227
246
  [
228
247
  (0, $acf8e70c2f419f18$export$d2f961adcb0afbe),
229
248
  state
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAwHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,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ClC,YAAY,QAAQ,EACpB;AAIT;AAgCO,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAyD;AAOhE,MAAM,2CAAgB,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,cAC1E,KAA4B,EAC5B,GAAiC;IAEjC,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,QAAQ,CAAA,GAAA,iBAAS,EAAE;IACvB,IAAI,YAAY,CAAA,GAAA,uBAAe;IAC/B,IAAI,eAAe,CAAA,GAAA,cAAM,EACvB,IACE,UAAU,MAAM,CACd,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,CAAA,iBAAA,2BAAA,KAAM,SAAS,KAAI,IAAI,MAAM,CAAC,CAAA,IAAK,MAAM,MAE7E;QAAC;QAAW,MAAM,aAAa;KAAC;IAGlC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,gBAAgB,MAAM,WAAW;QAClD,kBAAkB;QAClB,QAAQ;YACN,eAAe,CAAA,GAAA,cAAM,EACnB,IAAM,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA;wBAAS;2BAAD,CAAC,cAAA,KAAK,KAAK,cAAV,yBAAA,cAAoB;oBAC3D;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,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.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 */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\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 {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\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-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /** The filter function used to determine if a option should be included in the combo box list. */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, InputContext, GroupContext, TextContext];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n [groupRef, inputRef]\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 isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\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 ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\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-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\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.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;AA4HM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB;YAC0C;6BAAxC,gCAAC,CAAA,GAAA,yC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a,EAAE,OAAO;QAAC,QAAQ;IAAI;IAElD,qBACE,gCAAC,CAAA,GAAA,yCAAE,EAAE,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.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 */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\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, FocusableElement, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\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-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /**\n * The filter function used to determine if an option should be included in the combo box list.\n * By default, a language-sensitive \"contains\" filter from `useFilter` is used.\n */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [\n LabelContext,\n ButtonContext,\n InputContext,\n FieldInputContext,\n GroupContext,\n TextContext\n];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let [labelElementType, setLabelElementType] = useState<'span' | 'label'>('label');\n\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior,\n labelElementType\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n // oxlint-disable-next-line react/react-compiler\n [groupRef, inputRef]\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 isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, elementType: labelElementType, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [\n FieldInputContext,\n {\n ...inputProps,\n ref: useCallback((el: FocusableElement) => {\n inputRef.current = el as HTMLInputElement; // TODO: figure out how to fix non-input element types in useComboBox/useTextField\n if (el) {\n setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');\n }\n }, []),\n value: state.inputValue,\n onChange: v => state.setInputValue(v as string)\n } as any\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\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 ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\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-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\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.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.js.map"}
@@ -1,6 +1,7 @@
1
1
  import {ButtonContext as $7705c033048f6da7$export$24d547caef80ccd1} from "./Button.mjs";
2
2
  import {dom as $7230ffa83bc0c2cf$export$df3a06d6289f983e, Provider as $7230ffa83bc0c2cf$export$2881499e37b75b9a, removeDataAttributes as $7230ffa83bc0c2cf$export$ef03459518577ad4, useContextProps as $7230ffa83bc0c2cf$export$29f1550f4b0d4415, useRenderProps as $7230ffa83bc0c2cf$export$4d86445c2cf5e3, useSlot as $7230ffa83bc0c2cf$export$9d4c57ee4c6ffdd8, useSlottedContext as $7230ffa83bc0c2cf$export$fabf2dc03a41866e} from "./utils.mjs";
3
3
  import {FieldErrorContext as $1f3c3b1a70cec653$export$ff05c3ac10437e03} from "./FieldError.mjs";
4
+ import {FieldInputContext as $4b38b5b75ecc6208$export$698f465ec27e93df} from "./Autocomplete.mjs";
4
5
  import {FormContext as $cdaed739b1139372$export$c24727297075ec6a} from "./Form.mjs";
5
6
  import {GroupContext as $3a442827418ebe87$export$f9c6924e160136d1} from "./Group.mjs";
6
7
  import {InputContext as $41fb335299a4a39e$export$37fb8590cf2c088c} from "./Input.mjs";
@@ -49,6 +50,7 @@ import {useResizeObserver as $er33p$useResizeObserver} from "react-aria/private/
49
50
 
50
51
 
51
52
 
53
+
52
54
  const $dbdc5e6e7ce01b4b$export$d414ccceff7063c3 = /*#__PURE__*/ (0, $er33p$createContext)(null);
53
55
  const $dbdc5e6e7ce01b4b$export$c02625b26074192c = /*#__PURE__*/ (0, $er33p$createContext)(null);
54
56
  const $dbdc5e6e7ce01b4b$export$72b9695b8216309a = /*#__PURE__*/ (0, $er33p$createHideableComponent)(function ComboBox(props, ref) {
@@ -87,6 +89,7 @@ const $dbdc5e6e7ce01b4b$var$CLEAR_CONTEXTS = [
87
89
  (0, $43a3b93638fe5db9$export$75b6ee27786ba447),
88
90
  (0, $7705c033048f6da7$export$24d547caef80ccd1),
89
91
  (0, $41fb335299a4a39e$export$37fb8590cf2c088c),
92
+ (0, $4b38b5b75ecc6208$export$698f465ec27e93df),
90
93
  (0, $3a442827418ebe87$export$f9c6924e160136d1),
91
94
  (0, $efe09c6d1c304b50$export$9afb8bc826b033ea)
92
95
  ];
@@ -113,6 +116,7 @@ function $dbdc5e6e7ce01b4b$var$ComboBoxInner({ props: props, collection: collect
113
116
  let listBoxRef = (0, $er33p$useRef)(null);
114
117
  let popoverRef = (0, $er33p$useRef)(null);
115
118
  let [labelRef, label] = (0, $7230ffa83bc0c2cf$export$9d4c57ee4c6ffdd8)(!props['aria-label'] && !props['aria-labelledby']);
119
+ let [labelElementType, setLabelElementType] = (0, $er33p$useState)('label');
116
120
  let { buttonProps: buttonProps, inputProps: inputProps, listBoxProps: listBoxProps, labelProps: labelProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps, valueProps: valueProps, ...validation } = (0, $er33p$useComboBox)({
117
121
  ...(0, $7230ffa83bc0c2cf$export$ef03459518577ad4)(props),
118
122
  label: label,
@@ -121,7 +125,8 @@ function $dbdc5e6e7ce01b4b$var$ComboBoxInner({ props: props, collection: collect
121
125
  listBoxRef: listBoxRef,
122
126
  popoverRef: popoverRef,
123
127
  name: formValue === 'text' ? name : undefined,
124
- validationBehavior: validationBehavior
128
+ validationBehavior: validationBehavior,
129
+ labelElementType: labelElementType
125
130
  }, state);
126
131
  // Make menu width match input + button
127
132
  // Left for backward compatibility in case a <Group> is not rendered.
@@ -148,7 +153,8 @@ function $dbdc5e6e7ce01b4b$var$ComboBoxInner({ props: props, collection: collect
148
153
  get current () {
149
154
  return groupRef.current || inputRef.current;
150
155
  }
151
- }), [
156
+ }), // oxlint-disable-next-line react/react-compiler
157
+ [
152
158
  groupRef,
153
159
  inputRef
154
160
  ]);
@@ -201,6 +207,7 @@ function $dbdc5e6e7ce01b4b$var$ComboBoxInner({ props: props, collection: collect
201
207
  (0, $43a3b93638fe5db9$export$75b6ee27786ba447),
202
208
  {
203
209
  ...labelProps,
210
+ elementType: labelElementType,
204
211
  ref: labelRef
205
212
  }
206
213
  ],
@@ -219,6 +226,18 @@ function $dbdc5e6e7ce01b4b$var$ComboBoxInner({ props: props, collection: collect
219
226
  ref: inputRef
220
227
  }
221
228
  ],
229
+ [
230
+ (0, $4b38b5b75ecc6208$export$698f465ec27e93df),
231
+ {
232
+ ...inputProps,
233
+ ref: (0, $er33p$useCallback)((el)=>{
234
+ inputRef.current = el; // TODO: figure out how to fix non-input element types in useComboBox/useTextField
235
+ if (el) setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');
236
+ }, []),
237
+ value: state.inputValue,
238
+ onChange: (v)=>state.setInputValue(v)
239
+ }
240
+ ],
222
241
  [
223
242
  (0, $f2ff30fde7b014be$export$d2f961adcb0afbe),
224
243
  state
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;AAwHM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,kBACE,gCAAC,CAAA,GAAA,yCAAa,EAAE,QAAQ;YAAC,OAAO;gBAAC,OAAO,MAAM,KAAK,IAAI,MAAM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,EACvB,IACE,UAAU,MAAM,CACd,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,MAAM,aAAa,IAAI,MAAM,CAAC,CAAA,IAAK,MAAM,MAE7E;QAAC;QAAW,MAAM,aAAa;KAAC;IAGlC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,gBAAgB,MAAM,WAAW;QAClD,kBAAkB;QAClB,QAAQ;YACN,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,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.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 */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\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 {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\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-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /** The filter function used to determine if a option should be included in the combo box list. */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [LabelContext, ButtonContext, InputContext, GroupContext, TextContext];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n [groupRef, inputRef]\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 isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\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 ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\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-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\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.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.mjs.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;;;;;AA4HM,MAAM,0DACX,CAAA,GAAA,oBAAY,EAAmE;AAC1E,MAAM,0DAAuB,CAAA,GAAA,oBAAY,EAA4C;AAMrF,MAAM,4CAAW,WAAW,GAAG,CAAA,GAAA,8BAAsB,EAAE,SAAS,SAGrE,KAA0B,EAAE,GAAiC;IAC7D,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,YACF,QAAQ,cACR,aAAa,kBACb,YAAY,mBACZ,aAAa,mBACb,aAAa,OACd,GAAG;IACJ,IAAI,UAAU,CAAA,GAAA,cAAM,EAClB,kBACE,gCAAC,CAAA,GAAA,yCAAa,EAAE,QAAQ;YAAC,OAAO;gBAAC,OAAO,MAAM,KAAK,IAAI,MAAM,YAAY;YAAA;WACtE,OAAO,aAAa,aACjB,SAAS;YACP,QAAQ;wBACR;uBACA;wBACA;YACA,iBAAiB;wBACjB;QACF,KACA,WAGR;QAAC;QAAU;QAAY;QAAW;QAAY;QAAY,MAAM,KAAK;QAAE,MAAM,YAAY;KAAC;IAG5F,qBACE,gCAAC,CAAA,GAAA,wBAAgB;QAAE,SAAS;OACzB,CAAA,2BAAc,gCAAC;YAAc,OAAO;YAAO,YAAY;YAAY,aAAa;;AAGvF;AAEA,wCAAwC;AACxC,MAAM,uCAAiB;IACrB,CAAA,G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AAE;IACvB,IAAI,YAAY,CAAA,GAAA,uBAAe;IAC/B,IAAI,eAAe,CAAA,GAAA,cAAM,EACvB,IACE,UAAU,MAAM,CACd,MAAM,aAAa,CAAC,GAAG,CAAC,CAAA,OAAQ,MAAM,aAAa,IAAI,MAAM,CAAC,CAAA,IAAK,MAAM,MAE7E;QAAC;QAAW,MAAM,aAAa;KAAC;IAGlC,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,iBAAiB,gBAAgB,MAAM,WAAW;QAClD,kBAAkB;QAClB,QAAQ;YACN,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,GAAG;QACN,KAAK;QACJ,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,oBAAkB,MAAM,aAAa,CAAC,MAAM,KAAK,KAAK;;AAG5D","sources":["packages/react-aria-components/src/ComboBox.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 */\nimport {AriaComboBoxProps, useComboBox} from 'react-aria/useComboBox';\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, FocusableElement, Node} from '@react-types/shared';\nimport {CollectionBuilder} from 'react-aria/CollectionBuilder';\nimport {ComboBoxState, useComboBoxState} from 'react-stately/useComboBoxState';\nimport {createHideableComponent} from 'react-aria/private/collections/Hidden';\nimport {FieldErrorContext} from './FieldError';\nimport {FieldInputContext} from './Autocomplete';\nimport {filterDOMProps} from 'react-aria/filterDOMProps';\nimport {FormContext} from './Form';\nimport {GlobalDOMAttributes, Key, RefObject} from '@react-types/shared';\nimport {GroupContext} from './Group';\nimport {InputContext} from './Input';\nimport {LabelContext} from './Label';\nimport {ListBoxContext, ListStateContext} from './ListBox';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport React, {\n createContext,\n ForwardedRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\nimport {TextContext} from './Text';\nimport {useFilter} from 'react-aria/useFilter';\nimport {useListFormatter} from 'react-aria/useListFormatter';\nimport {useResizeObserver} from 'react-aria/private/utils/useResizeObserver';\n\ntype SelectionMode = 'single' | 'multiple';\n\nexport interface ComboBoxRenderProps {\n /**\n * Whether the combobox is currently open.\n *\n * @selector [data-open]\n */\n isOpen: boolean;\n /**\n * Whether the combobox is disabled.\n *\n * @selector [data-disabled]\n */\n isDisabled: boolean;\n /**\n * Whether the combobox is invalid.\n *\n * @selector [data-invalid]\n */\n isInvalid: boolean;\n /**\n * Whether the combobox is required.\n *\n * @selector [data-required]\n */\n isRequired: boolean;\n /**\n * Whether the combobox is read only.\n *\n * @selector [data-readonly]\n */\n isReadOnly: boolean;\n}\n\nexport interface ComboBoxProps<T, M extends SelectionMode = 'single'>\n extends\n Omit<\n AriaComboBoxProps<T, M>,\n | 'children'\n | 'placeholder'\n | 'label'\n | 'description'\n | 'errorMessage'\n | 'validationState'\n | 'validationBehavior'\n >,\n RACValidation,\n RenderProps<ComboBoxRenderProps>,\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-ComboBox'\n */\n className?: ClassNameOrFunction<ComboBoxRenderProps>;\n /**\n * The filter function used to determine if an option should be included in the combo box list.\n * By default, a language-sensitive \"contains\" filter from `useFilter` is used.\n */\n defaultFilter?: (textValue: string, inputValue: string) => boolean;\n /**\n * Whether the text or key of the selected item is submitted as part of an HTML form. When\n * `allowsCustomValue` is `true`, this option does not apply and the text is always submitted.\n *\n * @default 'key'\n */\n formValue?: 'text' | 'key';\n /** Whether the combo box allows the menu to be open when the collection is empty. */\n allowsEmptyCollection?: boolean;\n}\n\nexport const ComboBoxContext =\n createContext<ContextValue<ComboBoxProps<any, SelectionMode>, HTMLDivElement>>(null);\nexport const ComboBoxStateContext = createContext<ComboBoxState<any, SelectionMode> | null>(null);\n\n/**\n * A combo box combines a text input with a listbox, allowing users to filter a list of options to\n * items matching a query.\n */\nexport const ComboBox = /*#__PURE__*/ createHideableComponent(function ComboBox<\n T,\n M extends SelectionMode = 'single'\n>(props: ComboBoxProps<T, M>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, ComboBoxContext);\n let {\n children,\n isDisabled = false,\n isInvalid = false,\n isRequired = false,\n isReadOnly = false\n } = props;\n let content = useMemo(\n () => (\n <ListBoxContext.Provider value={{items: props.items ?? props.defaultItems}}>\n {typeof children === 'function'\n ? children({\n isOpen: false,\n isDisabled,\n isInvalid,\n isRequired,\n defaultChildren: null,\n isReadOnly\n })\n : children}\n </ListBoxContext.Provider>\n ),\n [children, isDisabled, isInvalid, isRequired, isReadOnly, props.items, props.defaultItems]\n );\n\n return (\n <CollectionBuilder content={content}>\n {collection => <ComboBoxInner props={props} collection={collection} comboBoxRef={ref} />}\n </CollectionBuilder>\n );\n});\n\n// Contexts to clear inside the popover.\nconst CLEAR_CONTEXTS = [\n LabelContext,\n ButtonContext,\n InputContext,\n FieldInputContext,\n GroupContext,\n TextContext\n];\n\ninterface ComboBoxInnerProps<T> {\n props: ComboBoxProps<T, SelectionMode>;\n collection: Collection<Node<T>>;\n comboBoxRef: RefObject<HTMLDivElement | null>;\n}\n\nfunction ComboBoxInner<T>({props, collection, comboBoxRef: ref}: ComboBoxInnerProps<T>) {\n let {name, formValue = 'key', allowsCustomValue} = props;\n if (allowsCustomValue) {\n formValue = 'text';\n }\n\n let {validationBehavior: formValidationBehavior} = useSlottedContext(FormContext) || {};\n let validationBehavior = props.validationBehavior ?? formValidationBehavior ?? 'native';\n let {contains} = useFilter({sensitivity: 'base'});\n let state = useComboBoxState({\n ...props,\n defaultFilter: props.defaultFilter || contains,\n // If props.items isn't provided, rely on collection filtering (aka listbox.items is provided or defaultItems provided to Combobox)\n items: props.items,\n children: undefined,\n collection,\n validationBehavior\n });\n\n let buttonRef = useRef<HTMLButtonElement>(null);\n let inputRef = useRef<HTMLInputElement>(null);\n let groupRef = useRef<HTMLDivElement>(null);\n let listBoxRef = useRef<HTMLDivElement>(null);\n let popoverRef = useRef<HTMLDivElement>(null);\n let [labelRef, label] = useSlot(!props['aria-label'] && !props['aria-labelledby']);\n let [labelElementType, setLabelElementType] = useState<'span' | 'label'>('label');\n\n let {\n buttonProps,\n inputProps,\n listBoxProps,\n labelProps,\n descriptionProps,\n errorMessageProps,\n valueProps,\n ...validation\n } = useComboBox(\n {\n ...removeDataAttributes(props),\n label,\n inputRef,\n buttonRef,\n listBoxRef,\n popoverRef,\n name: formValue === 'text' ? name : undefined,\n validationBehavior,\n labelElementType\n },\n state\n );\n\n // Make menu width match input + button\n // Left for backward compatibility in case a <Group> is not rendered.\n let [menuWidth, setMenuWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (inputRef.current && !groupRef.current) {\n let buttonRect = buttonRef.current?.getBoundingClientRect();\n let inputRect = inputRef.current.getBoundingClientRect();\n let minX = buttonRect ? Math.min(buttonRect.left, inputRect.left) : inputRect.left;\n let maxX = buttonRect ? Math.max(buttonRect.right, inputRect.right) : inputRect.right;\n setMenuWidth(maxX - minX + 'px');\n }\n }, [buttonRef, inputRef, setMenuWidth]);\n\n useResizeObserver({\n ref: inputRef,\n onResize: onResize\n });\n\n // Position popover relative to group if available, otherwise input.\n let triggerRef = useMemo(\n () => ({\n get current() {\n return groupRef.current || inputRef.current;\n }\n }),\n // oxlint-disable-next-line react/react-compiler\n [groupRef, inputRef]\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 isDisabled: props.isDisabled || false,\n isInvalid: validation.isInvalid || false,\n isRequired: props.isRequired || false,\n isReadOnly: props.isReadOnly || false\n }),\n [state.isOpen, props.isDisabled, validation.isInvalid, props.isRequired, props.isReadOnly]\n );\n\n let renderProps = useRenderProps({\n ...props,\n values: renderPropsState,\n defaultClassName: 'react-aria-ComboBox'\n });\n\n let DOMProps = filterDOMProps(props, {global: true});\n delete DOMProps.id;\n\n let inputs: ReactElement[] = [];\n if (name && formValue === 'key') {\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n if (values.length === 0) {\n values = [null];\n }\n\n inputs = values.map((value, i) => (\n <input key={i} type=\"hidden\" name={name} form={props.form} value={value ?? ''} />\n ));\n }\n\n return (\n <Provider\n values={[\n [ComboBoxStateContext, state],\n [LabelContext, {...labelProps, elementType: labelElementType, ref: labelRef}],\n [ButtonContext, {...buttonProps, ref: buttonRef, isPressed: state.isOpen}],\n [InputContext, {...inputProps, ref: inputRef}],\n [\n FieldInputContext,\n {\n ...inputProps,\n ref: useCallback((el: FocusableElement) => {\n inputRef.current = el as HTMLInputElement; // TODO: figure out how to fix non-input element types in useComboBox/useTextField\n if (el) {\n setLabelElementType(el.tagName.toLowerCase() === 'input' ? 'label' : 'span');\n }\n }, []),\n value: state.inputValue,\n onChange: v => state.setInputValue(v as string)\n } as any\n ],\n [OverlayTriggerStateContext, state],\n [\n PopoverContext,\n {\n ref: popoverRef,\n triggerRef,\n scrollRef: listBoxRef,\n placement: 'bottom start',\n isNonModal: true,\n trigger: 'ComboBox',\n style: {'--trigger-width': menuWidth} as React.CSSProperties,\n clearContexts: CLEAR_CONTEXTS\n }\n ],\n [ListBoxContext, {...listBoxProps, ref: listBoxRef}],\n [ListStateContext, state],\n [\n TextContext,\n {\n slots: {\n description: descriptionProps,\n errorMessage: errorMessageProps\n }\n }\n ],\n [\n GroupContext,\n {ref: groupRef, isInvalid: validation.isInvalid, isDisabled: props.isDisabled || false}\n ],\n [FieldErrorContext, validation],\n [ComboBoxValueContext, valueProps]\n ]}>\n <dom.div\n {...DOMProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n data-focused={state.isFocused || undefined}\n data-open={state.isOpen || undefined}\n data-disabled={props.isDisabled || undefined}\n data-readonly={props.isReadOnly || undefined}\n data-invalid={validation.isInvalid || undefined}\n data-required={props.isRequired || undefined}>\n {renderProps.children}\n {inputs}\n </dom.div>\n </Provider>\n );\n}\n\nexport interface ComboBoxValueRenderProps<T> {\n /**\n * Whether the value is a placeholder.\n *\n * @selector [data-placeholder]\n */\n isPlaceholder: boolean;\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 ComboBox. */\n state: ComboBoxState<T, 'single' | 'multiple'>;\n}\n\nexport interface ComboBoxValueProps<T>\n extends\n Omit<HTMLAttributes<HTMLElement>, keyof RenderProps<unknown>>,\n RenderProps<ComboBoxValueRenderProps<T>, 'div'> {\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-ComboBoxValue'\n */\n className?: ClassNameOrFunction<ComboBoxValueRenderProps<T>>;\n /** A value to display when no items are selected. */\n placeholder?: ReactNode;\n}\n\nexport const ComboBoxValueContext =\n createContext<ContextValue<ComboBoxValueProps<any>, HTMLDivElement>>(null);\n\n/**\n * ComboBoxValue renders the selected values of a ComboBox, or a placeholder if no value is\n * selected. By default, the items are rendered as a comma separated list. Use the render function\n * to customize this.\n */\nexport const ComboBoxValue = /*#__PURE__*/ createHideableComponent(function ComboBoxValue<T>(\n props: ComboBoxValueProps<T>,\n ref: ForwardedRef<HTMLDivElement>\n) {\n [props, ref] = useContextProps(props, ref, ComboBoxValueContext);\n let state = useContext(ComboBoxStateContext)!;\n let formatter = useListFormatter();\n let selectedText = useMemo(\n () =>\n formatter.format(\n state.selectedItems.map(item => item?.textValue || '').filter(v => v !== '')\n ),\n [formatter, state.selectedItems]\n );\n\n let renderProps = useRenderProps({\n ...props,\n defaultChildren: selectedText || props.placeholder,\n defaultClassName: 'react-aria-ComboBoxValue',\n values: {\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.div\n ref={ref}\n {...DOMProps}\n {...renderProps}\n data-placeholder={state.selectedItems.length === 0 || undefined}\n />\n );\n});\n"],"names":[],"version":3,"file":"ComboBox.mjs.map"}
@@ -3,12 +3,14 @@ var $048d76b84370f141$exports = require("./utils.cjs");
3
3
  var $03e8b4fd5e44cde9$exports = require("./Heading.cjs");
4
4
  var $74e35a768d38d46b$exports = require("./Popover.cjs");
5
5
  var $76f9e98b4261ab43$exports = require("./Menu.cjs");
6
+ var $cab7d9a238d19c33$exports = require("./Text.cjs");
6
7
  var $kcsOx$reactariauseDialog = require("react-aria/useDialog");
7
8
  var $kcsOx$reactariafilterDOMProps = require("react-aria/filterDOMProps");
8
9
  var $kcsOx$reactariamergeProps = require("react-aria/mergeProps");
9
10
  var $kcsOx$reactariaprivateinteractionsPressResponder = require("react-aria/private/interactions/PressResponder");
10
11
  var $kcsOx$react = require("react");
11
12
  var $kcsOx$reactariauseId = require("react-aria/useId");
13
+ var $kcsOx$reactariaprivatecollectionsHidden = require("react-aria/private/collections/Hidden");
12
14
  var $kcsOx$reactstatelyuseMenuTriggerState = require("react-stately/useMenuTriggerState");
13
15
  var $kcsOx$reactariauseOverlayTrigger = require("react-aria/useOverlayTrigger");
14
16
 
@@ -48,6 +50,8 @@ $parcel$export(module.exports, "Dialog", function () { return $88595bf043e542ec$
48
50
 
49
51
 
50
52
 
53
+
54
+
51
55
  const $88595bf043e542ec$export$8b93a07348a7730c = /*#__PURE__*/ (0, $kcsOx$react.createContext)(null);
52
56
  const $88595bf043e542ec$export$d2f961adcb0afbe = /*#__PURE__*/ (0, $kcsOx$react.createContext)(null);
53
57
  function $88595bf043e542ec$export$2e1e1122cf0cba88(props) {
@@ -62,8 +66,14 @@ function $88595bf043e542ec$export$2e1e1122cf0cba88(props) {
62
66
  // This is done in RAC instead of hooks because otherwise we cannot distinguish
63
67
  // between context and props. Normally aria-labelledby overrides the title
64
68
  // but when sent by context we want the title to win.
69
+ // oxlint-disable-next-line react/react-compiler
65
70
  triggerProps.id = (0, $kcsOx$reactariauseId.useId)();
71
+ // oxlint-disable-next-line react/react-compiler
66
72
  overlayProps['aria-labelledby'] = triggerProps.id;
73
+ // If within a collection (e.g. Tabs), render nothing.
74
+ // Not using createHideableComponent for this because that also creates a forwardRef.
75
+ let isHidden = (0, $kcsOx$reactariaprivatecollectionsHidden.useIsHidden)();
76
+ if (isHidden) return null;
67
77
  return /*#__PURE__*/ (0, ($parcel$interopDefault($kcsOx$react))).createElement((0, $048d76b84370f141$exports.Provider), {
68
78
  values: [
69
79
  [
@@ -83,6 +93,7 @@ function $88595bf043e542ec$export$2e1e1122cf0cba88(props) {
83
93
  {
84
94
  trigger: 'DialogTrigger',
85
95
  triggerRef: buttonRef,
96
+ id: overlayProps.id,
86
97
  'aria-labelledby': overlayProps['aria-labelledby']
87
98
  }
88
99
  ]
@@ -96,7 +107,7 @@ function $88595bf043e542ec$export$2e1e1122cf0cba88(props) {
96
107
  const $88595bf043e542ec$export$3ddf2d174ce01153 = /*#__PURE__*/ (0, $kcsOx$react.forwardRef)(function Dialog(props, ref) {
97
108
  let originalAriaLabelledby = props['aria-labelledby'];
98
109
  [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $88595bf043e542ec$export$8b93a07348a7730c);
99
- let { dialogProps: dialogProps, titleProps: titleProps } = (0, $kcsOx$reactariauseDialog.useDialog)({
110
+ let { dialogProps: dialogProps, titleProps: titleProps, contentProps: contentProps } = (0, $kcsOx$reactariauseDialog.useDialog)({
100
111
  ...props,
101
112
  // Only pass aria-labelledby from props, not context.
102
113
  // Context is used as a fallback below.
@@ -140,6 +151,15 @@ const $88595bf043e542ec$export$3ddf2d174ce01153 = /*#__PURE__*/ (0, $kcsOx$react
140
151
  }
141
152
  }
142
153
  ],
154
+ [
155
+ (0, $cab7d9a238d19c33$exports.TextContext),
156
+ {
157
+ slots: {
158
+ [(0, $048d76b84370f141$exports.DEFAULT_SLOT)]: {},
159
+ description: contentProps
160
+ }
161
+ }
162
+ ],
143
163
  [
144
164
  (0, $16c7f9b22cce3838$exports.ButtonContext),
145
165
  {