@fluentui/react-combobox 9.2.4 → 9.2.5

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 (292) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +82 -1
  3. package/CHANGELOG.md +22 -2
  4. package/lib/Combobox.js.map +1 -1
  5. package/lib/ComboboxField.js.map +1 -1
  6. package/lib/Dropdown.js.map +1 -1
  7. package/lib/Listbox.js.map +1 -1
  8. package/lib/Option.js.map +1 -1
  9. package/lib/OptionGroup.js.map +1 -1
  10. package/lib/components/Combobox/Combobox.js.map +1 -1
  11. package/lib/components/Combobox/Combobox.types.js +1 -1
  12. package/lib/components/Combobox/Combobox.types.js.map +1 -1
  13. package/lib/components/Combobox/index.js.map +1 -1
  14. package/lib/components/Combobox/renderCombobox.js +2 -12
  15. package/lib/components/Combobox/renderCombobox.js.map +1 -1
  16. package/lib/components/Combobox/useCombobox.js +11 -11
  17. package/lib/components/Combobox/useCombobox.js.map +1 -1
  18. package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
  19. package/lib/components/ComboboxField/ComboboxField.js +1 -2
  20. package/lib/components/ComboboxField/ComboboxField.js.map +1 -1
  21. package/lib/components/ComboboxField/index.js.map +1 -1
  22. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  23. package/lib/components/Dropdown/Dropdown.types.js.map +1 -1
  24. package/lib/components/Dropdown/index.js.map +1 -1
  25. package/lib/components/Dropdown/renderDropdown.js +2 -12
  26. package/lib/components/Dropdown/renderDropdown.js.map +1 -1
  27. package/lib/components/Dropdown/useDropdown.js +4 -4
  28. package/lib/components/Dropdown/useDropdown.js.map +1 -1
  29. package/lib/components/Dropdown/useDropdownStyles.js.map +1 -1
  30. package/lib/components/Listbox/Listbox.js.map +1 -1
  31. package/lib/components/Listbox/Listbox.types.js.map +1 -1
  32. package/lib/components/Listbox/index.js.map +1 -1
  33. package/lib/components/Listbox/renderListbox.js +1 -3
  34. package/lib/components/Listbox/renderListbox.js.map +1 -1
  35. package/lib/components/Listbox/useListbox.js.map +1 -1
  36. package/lib/components/Listbox/useListboxStyles.js.map +1 -1
  37. package/lib/components/Option/Option.js.map +1 -1
  38. package/lib/components/Option/Option.types.js +1 -1
  39. package/lib/components/Option/Option.types.js.map +1 -1
  40. package/lib/components/Option/index.js.map +1 -1
  41. package/lib/components/Option/renderOption.js +1 -5
  42. package/lib/components/Option/renderOption.js.map +1 -1
  43. package/lib/components/Option/useOption.js +4 -4
  44. package/lib/components/Option/useOption.js.map +1 -1
  45. package/lib/components/Option/useOptionStyles.js.map +1 -1
  46. package/lib/components/OptionGroup/OptionGroup.js.map +1 -1
  47. package/lib/components/OptionGroup/OptionGroup.types.js.map +1 -1
  48. package/lib/components/OptionGroup/index.js.map +1 -1
  49. package/lib/components/OptionGroup/renderOptionGroup.js +1 -5
  50. package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
  51. package/lib/components/OptionGroup/useOptionGroup.js +1 -0
  52. package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
  53. package/lib/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
  54. package/lib/contexts/ComboboxContext.js.map +1 -1
  55. package/lib/contexts/ListboxContext.js.map +1 -1
  56. package/lib/contexts/useComboboxContextValues.js.map +1 -1
  57. package/lib/contexts/useListboxContextValues.js.map +1 -1
  58. package/lib/index.js.map +1 -1
  59. package/lib/utils/ComboboxBase.types.js +1 -1
  60. package/lib/utils/ComboboxBase.types.js.map +1 -1
  61. package/lib/utils/OptionCollection.types.js.map +1 -1
  62. package/lib/utils/Selection.types.js +1 -1
  63. package/lib/utils/Selection.types.js.map +1 -1
  64. package/lib/utils/dropdownKeyActions.js +1 -0
  65. package/lib/utils/dropdownKeyActions.js.map +1 -1
  66. package/lib/utils/internalTokens.js.map +1 -1
  67. package/lib/utils/useComboboxBaseState.js +1 -3
  68. package/lib/utils/useComboboxBaseState.js.map +1 -1
  69. package/lib/utils/useComboboxPopup.js.map +1 -1
  70. package/lib/utils/useOptionCollection.js +4 -4
  71. package/lib/utils/useOptionCollection.js.map +1 -1
  72. package/lib/utils/useScrollOptionsIntoView.js.map +1 -1
  73. package/lib/utils/useSelection.js.map +1 -1
  74. package/lib/utils/useTriggerListboxSlots.js +6 -6
  75. package/lib/utils/useTriggerListboxSlots.js.map +1 -1
  76. package/lib-commonjs/Combobox.js +5 -4
  77. package/lib-commonjs/Combobox.js.map +1 -1
  78. package/lib-commonjs/ComboboxField.js +5 -4
  79. package/lib-commonjs/ComboboxField.js.map +1 -1
  80. package/lib-commonjs/Dropdown.js +5 -4
  81. package/lib-commonjs/Dropdown.js.map +1 -1
  82. package/lib-commonjs/Listbox.js +5 -4
  83. package/lib-commonjs/Listbox.js.map +1 -1
  84. package/lib-commonjs/Option.js +5 -4
  85. package/lib-commonjs/Option.js.map +1 -1
  86. package/lib-commonjs/OptionGroup.js +5 -4
  87. package/lib-commonjs/OptionGroup.js.map +1 -1
  88. package/lib-commonjs/components/Combobox/Combobox.js +21 -22
  89. package/lib-commonjs/components/Combobox/Combobox.js.map +1 -1
  90. package/lib-commonjs/components/Combobox/Combobox.types.js +5 -2
  91. package/lib-commonjs/components/Combobox/Combobox.types.js.map +1 -1
  92. package/lib-commonjs/components/Combobox/index.js +9 -8
  93. package/lib-commonjs/components/Combobox/index.js.map +1 -1
  94. package/lib-commonjs/components/Combobox/renderCombobox.js +17 -30
  95. package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
  96. package/lib-commonjs/components/Combobox/useCombobox.js +220 -246
  97. package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
  98. package/lib-commonjs/components/Combobox/useComboboxStyles.js +642 -292
  99. package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
  100. package/lib-commonjs/components/ComboboxField/ComboboxField.js +17 -11
  101. package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -1
  102. package/lib-commonjs/components/ComboboxField/index.js +5 -4
  103. package/lib-commonjs/components/ComboboxField/index.js.map +1 -1
  104. package/lib-commonjs/components/Dropdown/Dropdown.js +21 -22
  105. package/lib-commonjs/components/Dropdown/Dropdown.js.map +1 -1
  106. package/lib-commonjs/components/Dropdown/Dropdown.types.js +3 -2
  107. package/lib-commonjs/components/Dropdown/Dropdown.types.js.map +1 -1
  108. package/lib-commonjs/components/Dropdown/index.js +9 -8
  109. package/lib-commonjs/components/Dropdown/index.js.map +1 -1
  110. package/lib-commonjs/components/Dropdown/renderDropdown.js +17 -30
  111. package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
  112. package/lib-commonjs/components/Dropdown/useDropdown.js +138 -152
  113. package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
  114. package/lib-commonjs/components/Dropdown/useDropdownStyles.js +618 -279
  115. package/lib-commonjs/components/Dropdown/useDropdownStyles.js.map +1 -1
  116. package/lib-commonjs/components/Listbox/Listbox.js +21 -22
  117. package/lib-commonjs/components/Listbox/Listbox.js.map +1 -1
  118. package/lib-commonjs/components/Listbox/Listbox.types.js +3 -2
  119. package/lib-commonjs/components/Listbox/Listbox.types.js.map +1 -1
  120. package/lib-commonjs/components/Listbox/index.js +9 -8
  121. package/lib-commonjs/components/Listbox/index.js.map +1 -1
  122. package/lib-commonjs/components/Listbox/renderListbox.js +16 -21
  123. package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
  124. package/lib-commonjs/components/Listbox/useListbox.js +93 -109
  125. package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
  126. package/lib-commonjs/components/Listbox/useListboxStyles.js +59 -35
  127. package/lib-commonjs/components/Listbox/useListboxStyles.js.map +1 -1
  128. package/lib-commonjs/components/Option/Option.js +19 -20
  129. package/lib-commonjs/components/Option/Option.js.map +1 -1
  130. package/lib-commonjs/components/Option/Option.types.js +5 -2
  131. package/lib-commonjs/components/Option/Option.types.js.map +1 -1
  132. package/lib-commonjs/components/Option/index.js +9 -8
  133. package/lib-commonjs/components/Option/index.js.map +1 -1
  134. package/lib-commonjs/components/Option/renderOption.js +13 -20
  135. package/lib-commonjs/components/Option/renderOption.js.map +1 -1
  136. package/lib-commonjs/components/Option/useOption.js +129 -131
  137. package/lib-commonjs/components/Option/useOption.js.map +1 -1
  138. package/lib-commonjs/components/Option/useOptionStyles.js +327 -140
  139. package/lib-commonjs/components/Option/useOptionStyles.js.map +1 -1
  140. package/lib-commonjs/components/OptionGroup/OptionGroup.js +19 -20
  141. package/lib-commonjs/components/OptionGroup/OptionGroup.js.map +1 -1
  142. package/lib-commonjs/components/OptionGroup/OptionGroup.types.js +3 -2
  143. package/lib-commonjs/components/OptionGroup/OptionGroup.types.js.map +1 -1
  144. package/lib-commonjs/components/OptionGroup/index.js +9 -8
  145. package/lib-commonjs/components/OptionGroup/index.js.map +1 -1
  146. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js +13 -20
  147. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js.map +1 -1
  148. package/lib-commonjs/components/OptionGroup/useOptionGroup.js +31 -38
  149. package/lib-commonjs/components/OptionGroup/useOptionGroup.js.map +1 -1
  150. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js +107 -53
  151. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
  152. package/lib-commonjs/contexts/ComboboxContext.js +30 -22
  153. package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
  154. package/lib-commonjs/contexts/ListboxContext.js +26 -18
  155. package/lib-commonjs/contexts/ListboxContext.js.map +1 -1
  156. package/lib-commonjs/contexts/useComboboxContextValues.js +23 -32
  157. package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
  158. package/lib-commonjs/contexts/useListboxContextValues.js +26 -32
  159. package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
  160. package/lib-commonjs/index.js +53 -201
  161. package/lib-commonjs/index.js.map +1 -1
  162. package/lib-commonjs/utils/ComboboxBase.types.js +5 -2
  163. package/lib-commonjs/utils/ComboboxBase.types.js.map +1 -1
  164. package/lib-commonjs/utils/OptionCollection.types.js +3 -2
  165. package/lib-commonjs/utils/OptionCollection.types.js.map +1 -1
  166. package/lib-commonjs/utils/Selection.types.js +5 -2
  167. package/lib-commonjs/utils/Selection.types.js.map +1 -1
  168. package/lib-commonjs/utils/dropdownKeyActions.js +80 -85
  169. package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
  170. package/lib-commonjs/utils/internalTokens.js +11 -8
  171. package/lib-commonjs/utils/internalTokens.js.map +1 -1
  172. package/lib-commonjs/utils/useComboboxBaseState.js +106 -108
  173. package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
  174. package/lib-commonjs/utils/useComboboxPopup.js +33 -33
  175. package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
  176. package/lib-commonjs/utils/useOptionCollection.js +74 -71
  177. package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
  178. package/lib-commonjs/utils/useScrollOptionsIntoView.js +35 -38
  179. package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -1
  180. package/lib-commonjs/utils/useSelection.js +66 -55
  181. package/lib-commonjs/utils/useSelection.js.map +1 -1
  182. package/lib-commonjs/utils/useTriggerListboxSlots.js +115 -129
  183. package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
  184. package/package.json +14 -13
  185. package/lib-amd/Combobox.js +0 -6
  186. package/lib-amd/Combobox.js.map +0 -1
  187. package/lib-amd/ComboboxField.js +0 -6
  188. package/lib-amd/ComboboxField.js.map +0 -1
  189. package/lib-amd/Dropdown.js +0 -6
  190. package/lib-amd/Dropdown.js.map +0 -1
  191. package/lib-amd/Listbox.js +0 -6
  192. package/lib-amd/Listbox.js.map +0 -1
  193. package/lib-amd/Option.js +0 -6
  194. package/lib-amd/Option.js.map +0 -1
  195. package/lib-amd/OptionGroup.js +0 -6
  196. package/lib-amd/OptionGroup.js.map +0 -1
  197. package/lib-amd/components/Combobox/Combobox.js +0 -18
  198. package/lib-amd/components/Combobox/Combobox.js.map +0 -1
  199. package/lib-amd/components/Combobox/Combobox.types.js +0 -5
  200. package/lib-amd/components/Combobox/Combobox.types.js.map +0 -1
  201. package/lib-amd/components/Combobox/index.js +0 -10
  202. package/lib-amd/components/Combobox/index.js.map +0 -1
  203. package/lib-amd/components/Combobox/renderCombobox.js +0 -20
  204. package/lib-amd/components/Combobox/renderCombobox.js.map +0 -1
  205. package/lib-amd/components/Combobox/useCombobox.js +0 -204
  206. package/lib-amd/components/Combobox/useCombobox.js.map +0 -1
  207. package/lib-amd/components/Combobox/useComboboxStyles.js +0 -152
  208. package/lib-amd/components/Combobox/useComboboxStyles.js.map +0 -1
  209. package/lib-amd/components/ComboboxField/ComboboxField.js +0 -10
  210. package/lib-amd/components/ComboboxField/ComboboxField.js.map +0 -1
  211. package/lib-amd/components/ComboboxField/index.js +0 -6
  212. package/lib-amd/components/ComboboxField/index.js.map +0 -1
  213. package/lib-amd/components/Dropdown/Dropdown.js +0 -18
  214. package/lib-amd/components/Dropdown/Dropdown.js.map +0 -1
  215. package/lib-amd/components/Dropdown/Dropdown.types.js +0 -5
  216. package/lib-amd/components/Dropdown/Dropdown.types.js.map +0 -1
  217. package/lib-amd/components/Dropdown/index.js +0 -10
  218. package/lib-amd/components/Dropdown/index.js.map +0 -1
  219. package/lib-amd/components/Dropdown/renderDropdown.js +0 -21
  220. package/lib-amd/components/Dropdown/renderDropdown.js.map +0 -1
  221. package/lib-amd/components/Dropdown/useDropdown.js +0 -121
  222. package/lib-amd/components/Dropdown/useDropdown.js.map +0 -1
  223. package/lib-amd/components/Dropdown/useDropdownStyles.js +0 -127
  224. package/lib-amd/components/Dropdown/useDropdownStyles.js.map +0 -1
  225. package/lib-amd/components/Listbox/Listbox.js +0 -18
  226. package/lib-amd/components/Listbox/Listbox.js.map +0 -1
  227. package/lib-amd/components/Listbox/Listbox.types.js +0 -5
  228. package/lib-amd/components/Listbox/Listbox.types.js.map +0 -1
  229. package/lib-amd/components/Listbox/index.js +0 -10
  230. package/lib-amd/components/Listbox/index.js.map +0 -1
  231. package/lib-amd/components/Listbox/renderListbox.js +0 -15
  232. package/lib-amd/components/Listbox/renderListbox.js.map +0 -1
  233. package/lib-amd/components/Listbox/useListbox.js +0 -80
  234. package/lib-amd/components/Listbox/useListbox.js.map +0 -1
  235. package/lib-amd/components/Listbox/useListboxStyles.js +0 -24
  236. package/lib-amd/components/Listbox/useListboxStyles.js.map +0 -1
  237. package/lib-amd/components/Option/Option.js +0 -17
  238. package/lib-amd/components/Option/Option.js.map +0 -1
  239. package/lib-amd/components/Option/Option.types.js +0 -5
  240. package/lib-amd/components/Option/Option.types.js.map +0 -1
  241. package/lib-amd/components/Option/index.js +0 -10
  242. package/lib-amd/components/Option/index.js.map +0 -1
  243. package/lib-amd/components/Option/renderOption.js +0 -16
  244. package/lib-amd/components/Option/renderOption.js.map +0 -1
  245. package/lib-amd/components/Option/useOption.js +0 -112
  246. package/lib-amd/components/Option/useOption.js.map +0 -1
  247. package/lib-amd/components/Option/useOptionStyles.js +0 -73
  248. package/lib-amd/components/Option/useOptionStyles.js.map +0 -1
  249. package/lib-amd/components/OptionGroup/OptionGroup.js +0 -17
  250. package/lib-amd/components/OptionGroup/OptionGroup.js.map +0 -1
  251. package/lib-amd/components/OptionGroup/OptionGroup.types.js +0 -5
  252. package/lib-amd/components/OptionGroup/OptionGroup.types.js.map +0 -1
  253. package/lib-amd/components/OptionGroup/index.js +0 -10
  254. package/lib-amd/components/OptionGroup/index.js.map +0 -1
  255. package/lib-amd/components/OptionGroup/renderOptionGroup.js +0 -16
  256. package/lib-amd/components/OptionGroup/renderOptionGroup.js.map +0 -1
  257. package/lib-amd/components/OptionGroup/useOptionGroup.js +0 -33
  258. package/lib-amd/components/OptionGroup/useOptionGroup.js.map +0 -1
  259. package/lib-amd/components/OptionGroup/useOptionGroupStyles.js +0 -34
  260. package/lib-amd/components/OptionGroup/useOptionGroupStyles.js.map +0 -1
  261. package/lib-amd/contexts/ComboboxContext.js +0 -28
  262. package/lib-amd/contexts/ComboboxContext.js.map +0 -1
  263. package/lib-amd/contexts/ListboxContext.js +0 -23
  264. package/lib-amd/contexts/ListboxContext.js.map +0 -1
  265. package/lib-amd/contexts/useComboboxContextValues.js +0 -23
  266. package/lib-amd/contexts/useComboboxContextValues.js.map +0 -1
  267. package/lib-amd/contexts/useListboxContextValues.js +0 -24
  268. package/lib-amd/contexts/useListboxContextValues.js.map +0 -1
  269. package/lib-amd/index.js +0 -37
  270. package/lib-amd/index.js.map +0 -1
  271. package/lib-amd/utils/ComboboxBase.types.js +0 -5
  272. package/lib-amd/utils/ComboboxBase.types.js.map +0 -1
  273. package/lib-amd/utils/OptionCollection.types.js +0 -5
  274. package/lib-amd/utils/OptionCollection.types.js.map +0 -1
  275. package/lib-amd/utils/Selection.types.js +0 -5
  276. package/lib-amd/utils/Selection.types.js.map +0 -1
  277. package/lib-amd/utils/dropdownKeyActions.js +0 -85
  278. package/lib-amd/utils/dropdownKeyActions.js.map +0 -1
  279. package/lib-amd/utils/internalTokens.js +0 -11
  280. package/lib-amd/utils/internalTokens.js.map +0 -1
  281. package/lib-amd/utils/useComboboxBaseState.js +0 -83
  282. package/lib-amd/utils/useComboboxBaseState.js.map +0 -1
  283. package/lib-amd/utils/useComboboxPopup.js +0 -16
  284. package/lib-amd/utils/useComboboxPopup.js.map +0 -1
  285. package/lib-amd/utils/useOptionCollection.js +0 -69
  286. package/lib-amd/utils/useOptionCollection.js.map +0 -1
  287. package/lib-amd/utils/useScrollOptionsIntoView.js +0 -33
  288. package/lib-amd/utils/useScrollOptionsIntoView.js.map +0 -1
  289. package/lib-amd/utils/useSelection.js +0 -42
  290. package/lib-amd/utils/useSelection.js.map +0 -1
  291. package/lib-amd/utils/useTriggerListboxSlots.js +0 -104
  292. package/lib-amd/utils/useTriggerListboxSlots.js.map +0 -1
@@ -1,156 +1,142 @@
1
1
  "use strict";
2
-
3
2
  Object.defineProperty(exports, "__esModule", {
4
- value: true
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "useDropdown_unstable", {
6
+ enumerable: true,
7
+ get: ()=>useDropdown_unstable
5
8
  });
6
- exports.useDropdown_unstable = void 0;
7
- const React = /*#__PURE__*/require("react");
8
- const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
9
- const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
10
- const dropdownKeyActions_1 = /*#__PURE__*/require("../../utils/dropdownKeyActions");
11
- const useComboboxBaseState_1 = /*#__PURE__*/require("../../utils/useComboboxBaseState");
12
- const useComboboxPopup_1 = /*#__PURE__*/require("../../utils/useComboboxPopup");
13
- const useTriggerListboxSlots_1 = /*#__PURE__*/require("../../utils/useTriggerListboxSlots");
14
- const Listbox_1 = /*#__PURE__*/require("../Listbox/Listbox");
15
- const react_utilities_2 = /*#__PURE__*/require("@fluentui/react-utilities");
16
- /**
17
- * Create the state required to render Dropdown.
18
- *
19
- * The returned state can be modified with hooks such as useDropdownStyles_unstable,
20
- * before being passed to renderDropdown_unstable.
21
- *
22
- * @param props - props from this instance of Dropdown
23
- * @param ref - reference to root HTMLElement of Dropdown
24
- */
25
- const useDropdown_unstable = (props, ref) => {
26
- const baseState = useComboboxBaseState_1.useComboboxBaseState(props);
27
- const {
28
- activeOption,
29
- getIndexOfId,
30
- getOptionsMatchingText,
31
- open,
32
- setActiveOption,
33
- setFocusVisible,
34
- setOpen
35
- } = baseState;
36
- const {
37
- primary: triggerNativeProps,
38
- root: rootNativeProps
39
- } = react_utilities_1.getPartitionedNativeProps({
40
- props,
41
- primarySlotTagName: 'button',
42
- excludedPropNames: ['children']
43
- });
44
- // set listbox popup width based off the root/trigger width
45
- const rootRef = React.useRef(null);
46
- const [popupWidth, setPopupWidth] = React.useState();
47
- React.useEffect(() => {
48
- var _a;
49
- const width = open ? `${(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px` : undefined;
50
- setPopupWidth(width);
51
- }, [open]);
52
- // jump to matching option based on typing
53
- const searchString = React.useRef('');
54
- const [setKeyTimeout, clearKeyTimeout] = react_utilities_1.useTimeout();
55
- const getNextMatchingOption = () => {
56
- var _a;
57
- // first check for matches for the full searchString
58
- let matcher = optionText => optionText.toLowerCase().indexOf(searchString.current) === 0;
59
- let matches = getOptionsMatchingText(matcher);
60
- let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
61
- // if the dropdown is already open and the searchstring is a single character,
62
- // then look after the current activeOption for letters
63
- // this is so slowly typing the same letter will cycle through matches
64
- if (open && searchString.current.length === 1) {
65
- startIndex++;
66
- }
67
- // if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
68
- if (!matches.length) {
69
- const letters = searchString.current.split('');
70
- const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);
71
- // if the search is all the same letter, cycle through options starting with that letter
72
- if (allSameLetter) {
73
- startIndex++;
74
- matcher = optionText => optionText.toLowerCase().indexOf(letters[0]) === 0;
75
- matches = getOptionsMatchingText(matcher);
76
- }
77
- }
78
- // if there is an active option and multiple matches,
79
- // return first matching option after the current active option, looping back to the top
80
- if (matches.length > 1 && activeOption) {
81
- const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);
82
- return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
83
- }
84
- return (_a = matches[0]) !== null && _a !== void 0 ? _a : undefined;
85
- };
86
- const onTriggerKeyDown = ev => {
87
- // clear timeout, if it exists
88
- clearKeyTimeout();
89
- // if the key was a char key, update search string
90
- if (dropdownKeyActions_1.getDropdownActionFromKey(ev) === 'Type') {
91
- // update search string
92
- searchString.current += ev.key.toLowerCase();
93
- setKeyTimeout(() => {
94
- searchString.current = '';
95
- }, 500);
96
- // update state
97
- !open && setOpen(ev, true);
98
- const nextOption = getNextMatchingOption();
99
- setActiveOption(nextOption);
100
- setFocusVisible(true);
101
- }
102
- };
103
- // resolve button and listbox slot props
104
- let triggerSlot;
105
- let listboxSlot;
106
- triggerSlot = react_utilities_1.resolveShorthand(props.button, {
107
- required: true,
108
- defaultProps: {
109
- type: 'button',
110
- children: baseState.value || props.placeholder,
111
- ...triggerNativeProps
112
- }
113
- });
114
- triggerSlot.onKeyDown = react_utilities_1.mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);
115
- listboxSlot = baseState.open || baseState.hasFocus ? react_utilities_1.resolveShorthand(props.listbox, {
116
- required: true,
117
- defaultProps: {
118
- children: props.children,
119
- style: {
120
- width: popupWidth
121
- }
122
- }
123
- }) : undefined;
124
- [triggerSlot, listboxSlot] = useComboboxPopup_1.useComboboxPopup(props, triggerSlot, listboxSlot);
125
- [triggerSlot, listboxSlot] = useTriggerListboxSlots_1.useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);
126
- const state = {
127
- components: {
128
- root: 'div',
129
- button: 'button',
130
- expandIcon: 'span',
131
- listbox: Listbox_1.Listbox
132
- },
133
- root: react_utilities_1.resolveShorthand(props.root, {
134
- required: true,
135
- defaultProps: {
136
- 'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,
137
- children: props.children,
138
- ...rootNativeProps
139
- }
140
- }),
141
- button: triggerSlot,
142
- listbox: listboxSlot,
143
- expandIcon: react_utilities_1.resolveShorthand(props.expandIcon, {
144
- required: true,
145
- defaultProps: {
146
- children: React.createElement(react_icons_1.ChevronDownRegular, null)
147
- }
148
- }),
149
- placeholderVisible: !baseState.value && !!props.placeholder,
150
- ...baseState
151
- };
152
- state.root.ref = react_utilities_2.useMergedRefs(state.root.ref, rootRef);
153
- return state;
154
- };
155
- exports.useDropdown_unstable = useDropdown_unstable;
9
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _reactIcons = require("@fluentui/react-icons");
12
+ const _reactUtilities = require("@fluentui/react-utilities");
13
+ const _dropdownKeyActions = require("../../utils/dropdownKeyActions");
14
+ const _useComboboxBaseState = require("../../utils/useComboboxBaseState");
15
+ const _useComboboxPopup = require("../../utils/useComboboxPopup");
16
+ const _useTriggerListboxSlots = require("../../utils/useTriggerListboxSlots");
17
+ const _listbox = require("../Listbox/Listbox");
18
+ const useDropdown_unstable = (props, ref)=>{
19
+ const baseState = (0, _useComboboxBaseState.useComboboxBaseState)(props);
20
+ const { activeOption , getIndexOfId , getOptionsMatchingText , open , setActiveOption , setFocusVisible , setOpen } = baseState;
21
+ const { primary: triggerNativeProps , root: rootNativeProps } = (0, _reactUtilities.getPartitionedNativeProps)({
22
+ props,
23
+ primarySlotTagName: 'button',
24
+ excludedPropNames: [
25
+ 'children'
26
+ ]
27
+ });
28
+ // set listbox popup width based off the root/trigger width
29
+ const rootRef = _react.useRef(null);
30
+ const [popupWidth, setPopupWidth] = _react.useState();
31
+ _react.useEffect(()=>{
32
+ var _rootRef_current;
33
+ const width = open ? `${(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.clientWidth}px` : undefined;
34
+ setPopupWidth(width);
35
+ }, [
36
+ open
37
+ ]);
38
+ // jump to matching option based on typing
39
+ const searchString = _react.useRef('');
40
+ const [setKeyTimeout, clearKeyTimeout] = (0, _reactUtilities.useTimeout)();
41
+ const getNextMatchingOption = ()=>{
42
+ // first check for matches for the full searchString
43
+ let matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString.current) === 0;
44
+ let matches = getOptionsMatchingText(matcher);
45
+ let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
46
+ // if the dropdown is already open and the searchstring is a single character,
47
+ // then look after the current activeOption for letters
48
+ // this is so slowly typing the same letter will cycle through matches
49
+ if (open && searchString.current.length === 1) {
50
+ startIndex++;
51
+ }
52
+ // if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
53
+ if (!matches.length) {
54
+ const letters = searchString.current.split('');
55
+ const allSameLetter = letters.length && letters.every((letter)=>letter === letters[0]);
56
+ // if the search is all the same letter, cycle through options starting with that letter
57
+ if (allSameLetter) {
58
+ startIndex++;
59
+ matcher = (optionText)=>optionText.toLowerCase().indexOf(letters[0]) === 0;
60
+ matches = getOptionsMatchingText(matcher);
61
+ }
62
+ }
63
+ // if there is an active option and multiple matches,
64
+ // return first matching option after the current active option, looping back to the top
65
+ if (matches.length > 1 && activeOption) {
66
+ const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);
67
+ return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
68
+ }
69
+ var _matches_;
70
+ return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;
71
+ };
72
+ const onTriggerKeyDown = (ev)=>{
73
+ // clear timeout, if it exists
74
+ clearKeyTimeout();
75
+ // if the key was a char key, update search string
76
+ if ((0, _dropdownKeyActions.getDropdownActionFromKey)(ev) === 'Type') {
77
+ // update search string
78
+ searchString.current += ev.key.toLowerCase();
79
+ setKeyTimeout(()=>{
80
+ searchString.current = '';
81
+ }, 500);
82
+ // update state
83
+ !open && setOpen(ev, true);
84
+ const nextOption = getNextMatchingOption();
85
+ setActiveOption(nextOption);
86
+ setFocusVisible(true);
87
+ }
88
+ };
89
+ // resolve button and listbox slot props
90
+ let triggerSlot;
91
+ let listboxSlot;
92
+ triggerSlot = (0, _reactUtilities.resolveShorthand)(props.button, {
93
+ required: true,
94
+ defaultProps: {
95
+ type: 'button',
96
+ children: baseState.value || props.placeholder,
97
+ ...triggerNativeProps
98
+ }
99
+ });
100
+ triggerSlot.onKeyDown = (0, _reactUtilities.mergeCallbacks)(onTriggerKeyDown, triggerSlot.onKeyDown);
101
+ listboxSlot = baseState.open || baseState.hasFocus ? (0, _reactUtilities.resolveShorthand)(props.listbox, {
102
+ required: true,
103
+ defaultProps: {
104
+ children: props.children,
105
+ style: {
106
+ width: popupWidth
107
+ }
108
+ }
109
+ }) : undefined;
110
+ [triggerSlot, listboxSlot] = (0, _useComboboxPopup.useComboboxPopup)(props, triggerSlot, listboxSlot);
111
+ [triggerSlot, listboxSlot] = (0, _useTriggerListboxSlots.useTriggerListboxSlots)(props, baseState, ref, triggerSlot, listboxSlot);
112
+ const state = {
113
+ components: {
114
+ root: 'div',
115
+ button: 'button',
116
+ expandIcon: 'span',
117
+ listbox: _listbox.Listbox
118
+ },
119
+ root: (0, _reactUtilities.resolveShorthand)(props.root, {
120
+ required: true,
121
+ defaultProps: {
122
+ 'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,
123
+ children: props.children,
124
+ ...rootNativeProps
125
+ }
126
+ }),
127
+ button: triggerSlot,
128
+ listbox: listboxSlot,
129
+ expandIcon: (0, _reactUtilities.resolveShorthand)(props.expandIcon, {
130
+ required: true,
131
+ defaultProps: {
132
+ children: /*#__PURE__*/ _react.createElement(_reactIcons.ChevronDownRegular, null)
133
+ }
134
+ }),
135
+ placeholderVisible: !baseState.value && !!props.placeholder,
136
+ ...baseState
137
+ };
138
+ state.root.ref = (0, _reactUtilities.useMergedRefs)(state.root.ref, rootRef);
139
+ return state;
140
+ }; //# sourceMappingURL=useDropdown.js.map
141
+
156
142
  //# sourceMappingURL=useDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","require","react_icons_1","react_utilities_1","dropdownKeyActions_1","useComboboxBaseState_1","useComboboxPopup_1","useTriggerListboxSlots_1","Listbox_1","react_utilities_2","useDropdown_unstable","props","ref","baseState","useComboboxBaseState","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","rootRef","useRef","popupWidth","setPopupWidth","useState","useEffect","width","_a","current","clientWidth","undefined","searchString","setKeyTimeout","clearKeyTimeout","useTimeout","getNextMatchingOption","matcher","optionText","toLowerCase","indexOf","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","onTriggerKeyDown","ev","getDropdownActionFromKey","key","nextOption","triggerSlot","listboxSlot","resolveShorthand","button","required","defaultProps","type","children","value","placeholder","onKeyDown","mergeCallbacks","hasFocus","listbox","style","useComboboxPopup","useTriggerListboxSlots","state","components","expandIcon","Listbox","inlinePopup","createElement","ChevronDownRegular","placeholderVisible","useMergedRefs","exports"],"sources":["../src/packages/react-components/react-combobox/src/components/Dropdown/useDropdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useTimeout } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { DropdownProps, DropdownState } from './Dropdown.types';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n\n/**\n * Create the state required to render Dropdown.\n *\n * The returned state can be modified with hooks such as useDropdownStyles_unstable,\n * before being passed to renderDropdown_unstable.\n *\n * @param props - props from this instance of Dropdown\n * @param ref - reference to root HTMLElement of Dropdown\n */\nexport const useDropdown_unstable = (props: DropdownProps, ref: React.Ref<HTMLButtonElement>): DropdownState => {\n const baseState = useComboboxBaseState(props);\n const { activeOption, getIndexOfId, getOptionsMatchingText, open, setActiveOption, setFocusVisible, setOpen } =\n baseState;\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: ['children'],\n });\n\n // set listbox popup width based off the root/trigger width\n const rootRef = React.useRef<HTMLDivElement>(null);\n const [popupWidth, setPopupWidth] = React.useState<string>();\n React.useEffect(() => {\n const width = open ? `${rootRef.current?.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n\n const getNextMatchingOption = (): OptionValue | undefined => {\n // first check for matches for the full searchString\n let matcher = (optionText: string) => optionText.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n\n // if the dropdown is already open and the searchstring is a single character,\n // then look after the current activeOption for letters\n // this is so slowly typing the same letter will cycle through matches\n if (open && searchString.current.length === 1) {\n startIndex++;\n }\n\n // if there are no direct matches, check if the search is all the same letter, e.g. \"aaa\"\n if (!matches.length) {\n const letters = searchString.current.split('');\n const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);\n\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = (optionText: string) => optionText.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\n }\n\n // if there is an active option and multiple matches,\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);\n return nextMatch ?? matches[0];\n }\n\n return matches[0] ?? undefined;\n };\n\n const onTriggerKeyDown = (ev: React.KeyboardEvent<HTMLButtonElement>) => {\n // clear timeout, if it exists\n clearKeyTimeout();\n\n // if the key was a char key, update search string\n if (getDropdownActionFromKey(ev) === 'Type') {\n // update search string\n searchString.current += ev.key.toLowerCase();\n setKeyTimeout(() => {\n searchString.current = '';\n }, 500);\n\n // update state\n !open && setOpen(ev, true);\n\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n\n // resolve button and listbox slot props\n let triggerSlot: Slot<'button'>;\n let listboxSlot: Slot<typeof Listbox> | undefined;\n\n triggerSlot = resolveShorthand(props.button, {\n required: true,\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n\n listboxSlot =\n baseState.open || baseState.hasFocus\n ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: { width: popupWidth },\n },\n })\n : undefined;\n\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n\n const state: DropdownState = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n 'aria-owns': !props.inlinePopup ? listboxSlot?.id : undefined,\n children: props.children,\n ...rootNativeProps,\n },\n }),\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: <ChevronDownIcon />,\n },\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n\n return state;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,aAAA,gBAAAD,OAAA;AACA,MAAAE,iBAAA,gBAAAF,OAAA;AACA,MAAAG,oBAAA,gBAAAH,OAAA;AACA,MAAAI,sBAAA,gBAAAJ,OAAA;AACA,MAAAK,kBAAA,gBAAAL,OAAA;AACA,MAAAM,wBAAA,gBAAAN,OAAA;AACA,MAAAO,SAAA,gBAAAP,OAAA;AAIA,MAAAQ,iBAAA,gBAAAR,OAAA;AAEA;;;;;;;;;AASO,MAAMS,oBAAoB,GAAGA,CAACC,KAAoB,EAAEC,GAAiC,KAAmB;EAC7G,MAAMC,SAAS,GAAGR,sBAAA,CAAAS,oBAAoB,CAACH,KAAK,CAAC;EAC7C,MAAM;IAAEI,YAAY;IAAEC,YAAY;IAAEC,sBAAsB;IAAEC,IAAI;IAAEC,eAAe;IAAEC,eAAe;IAAEC;EAAO,CAAE,GAC3GR,SAAS;EAEX,MAAM;IAAES,OAAO,EAAEC,kBAAkB;IA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E,gBAAgB,CAACzD,KAAK,CAACa,IAAI,EAAE;MACjC8C,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZ,WAAW,EAAE,CAAC5D,KAAK,CAAC4E,WAAW,GAAGpB,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEhB,EAAE,GAAGZ,SAAS;QAC7DkC,QAAQ,EAAE9D,KAAK,CAAC8D,QAAQ;QACxB,GAAGhD;;KAEN,CAAC;IACF4C,MAAM,EAAEH,WAAW;IACnBa,OAAO,EAAEZ,WAAW;IACpBkB,UAAU,EAAElF,iBAAA,CAAAiE,gBAAgB,CAACzD,KAAK,CAAC0E,UAAU,EAAE;MAC7Cf,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZE,QAAQ,EAAEzE,KAAA,CAAAwF,aAAA,CAACtF,aAAA,CAAAuF,kBAAe;;KAE7B,CAAC;IACFC,kBAAkB,EAAE,CAAC7E,SAAS,CAAC6D,KAAK,IAAI,CAAC,CAAC/D,KAAK,CAACgE,WAAW;IAC3D,GAAG9D;GACJ;EAEDsE,KAAK,CAAC3D,IAAI,CAACZ,GAAG,GAAGH,iBAAA,CAAAkF,aAAa,CAACR,KAAK,CAAC3D,IAAI,CAACZ,GAAG,EAAEiB,OAAO,CAAC;EAEvD,OAAOsD,KAAK;AACd,CAAC;AA3IYS,OAAA,CAAAlF,oBAAoB,GAAAA,oBAAA"}
1
+ {"version":3,"sources":["../../../lib/components/Dropdown/useDropdown.js"],"sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useTimeout } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n/**\n * Create the state required to render Dropdown.\n *\n * The returned state can be modified with hooks such as useDropdownStyles_unstable,\n * before being passed to renderDropdown_unstable.\n *\n * @param props - props from this instance of Dropdown\n * @param ref - reference to root HTMLElement of Dropdown\n */\nexport const useDropdown_unstable = (props, ref) => {\n const baseState = useComboboxBaseState(props);\n const {\n activeOption,\n getIndexOfId,\n getOptionsMatchingText,\n open,\n setActiveOption,\n setFocusVisible,\n setOpen\n } = baseState;\n const {\n primary: triggerNativeProps,\n root: rootNativeProps\n } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: ['children']\n });\n // set listbox popup width based off the root/trigger width\n const rootRef = React.useRef(null);\n const [popupWidth, setPopupWidth] = React.useState();\n React.useEffect(() => {\n var _rootRef_current;\n const width = open ? `${(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n const getNextMatchingOption = () => {\n // first check for matches for the full searchString\n let matcher = optionText => optionText.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n // if the dropdown is already open and the searchstring is a single character,\n // then look after the current activeOption for letters\n // this is so slowly typing the same letter will cycle through matches\n if (open && searchString.current.length === 1) {\n startIndex++;\n }\n // if there are no direct matches, check if the search is all the same letter, e.g. \"aaa\"\n if (!matches.length) {\n const letters = searchString.current.split('');\n const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = optionText => optionText.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\n }\n // if there is an active option and multiple matches,\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);\n return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];\n }\n var _matches_;\n return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;\n };\n const onTriggerKeyDown = ev => {\n // clear timeout, if it exists\n clearKeyTimeout();\n // if the key was a char key, update search string\n if (getDropdownActionFromKey(ev) === 'Type') {\n // update search string\n searchString.current += ev.key.toLowerCase();\n setKeyTimeout(() => {\n searchString.current = '';\n }, 500);\n // update state\n !open && setOpen(ev, true);\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n // resolve button and listbox slot props\n let triggerSlot;\n let listboxSlot;\n triggerSlot = resolveShorthand(props.button, {\n required: true,\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps\n }\n });\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n listboxSlot = baseState.open || baseState.hasFocus ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: {\n width: popupWidth\n }\n }\n }) : undefined;\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n const state = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n 'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,\n children: props.children,\n ...rootNativeProps\n }\n }),\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: /*#__PURE__*/React.createElement(ChevronDownIcon, null)\n }\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState\n };\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n return state;\n};\n//# sourceMappingURL=useDropdown.js.map"],"names":["useDropdown_unstable","props","ref","baseState","useComboboxBaseState","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","rootRef","React","useRef","popupWidth","setPopupWidth","useState","useEffect","_rootRef_current","width","current","clientWidth","undefined","searchString","setKeyTimeout","clearKeyTimeout","useTimeout","getNextMatchingOption","matcher","optionText","toLowerCase","indexOf","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","_matches_","onTriggerKeyDown","ev","getDropdownActionFromKey","key","nextOption","triggerSlot","listboxSlot","resolveShorthand","button","required","defaultProps","type","children","value","placeholder","onKeyDown","mergeCallbacks","hasFocus","listbox","style","useComboboxPopup","useTriggerListboxSlots","state","components","expandIcon","Listbox","inlinePopup","createElement","ChevronDownIcon","placeholderVisible","useMergedRefs"],"mappings":";;;;+BAkBaA;;aAAAA;;;6DAlBU;4BAC+B;gCACkC;oCAC/C;sCACJ;kCACJ;wCACM;yBACf;AAWjB,MAAMA,uBAAuB,CAACC,OAAOC,MAAQ;IAClD,MAAMC,YAAYC,IAAAA,0CAAoB,EAACH;IACvC,MAAM,EACJI,aAAY,EACZC,aAAY,EACZC,uBAAsB,EACtBC,KAAI,EACJC,gBAAe,EACfC,gBAAe,EACfC,QAAO,EACR,GAAGR;IACJ,MAAM,EACJS,SAASC,mBAAkB,EAC3BC,MAAMC,gBAAe,EACtB,GAAGC,IAAAA,yCAAyB,EAAC;QAC5Bf;QACAgB,oBAAoB;QACpBC,mBAAmB;YAAC;SAAW;IACjC;IACA,2DAA2D;IAC3D,MAAMC,UAAUC,OAAMC,MAAM,CAAC,IAAI;IACjC,MAAM,CAACC,YAAYC,cAAc,GAAGH,OAAMI,QAAQ;IAClDJ,OAAMK,SAAS,CAAC,IAAM;QACpB,IAAIC;QACJ,MAAMC,QA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