@fluentui/react-combobox 9.0.0-beta.9 → 9.0.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 (302) hide show
  1. package/CHANGELOG.json +848 -1
  2. package/CHANGELOG.md +248 -2
  3. package/README.md +1 -3
  4. package/dist/index.d.ts +62 -11
  5. package/lib/Combobox.js.map +1 -1
  6. package/lib/ComboboxField.js +2 -0
  7. package/lib/ComboboxField.js.map +1 -0
  8. package/lib/Dropdown.js.map +1 -1
  9. package/lib/Listbox.js.map +1 -1
  10. package/lib/Option.js.map +1 -1
  11. package/lib/OptionGroup.js.map +1 -1
  12. package/lib/components/Combobox/Combobox.js +0 -1
  13. package/lib/components/Combobox/Combobox.js.map +1 -1
  14. package/lib/components/Combobox/Combobox.types.js.map +1 -1
  15. package/lib/components/Combobox/index.js.map +1 -1
  16. package/lib/components/Combobox/renderCombobox.js +10 -6
  17. package/lib/components/Combobox/renderCombobox.js.map +1 -1
  18. package/lib/components/Combobox/useCombobox.js +107 -70
  19. package/lib/components/Combobox/useCombobox.js.map +1 -1
  20. package/lib/components/Combobox/useComboboxStyles.js +246 -185
  21. package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
  22. package/lib/components/ComboboxField/ComboboxField.js +8 -0
  23. package/lib/components/ComboboxField/ComboboxField.js.map +1 -0
  24. package/lib/components/ComboboxField/index.js +2 -0
  25. package/lib/components/ComboboxField/index.js.map +1 -0
  26. package/lib/components/Dropdown/Dropdown.js +0 -1
  27. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  28. package/lib/components/Dropdown/Dropdown.types.js.map +1 -1
  29. package/lib/components/Dropdown/index.js.map +1 -1
  30. package/lib/components/Dropdown/renderDropdown.js +10 -6
  31. package/lib/components/Dropdown/renderDropdown.js.map +1 -1
  32. package/lib/components/Dropdown/useDropdown.js +25 -36
  33. package/lib/components/Dropdown/useDropdown.js.map +1 -1
  34. package/lib/components/Dropdown/useDropdownStyles.js +236 -176
  35. package/lib/components/Dropdown/useDropdownStyles.js.map +1 -1
  36. package/lib/components/Listbox/Listbox.js +0 -1
  37. package/lib/components/Listbox/Listbox.js.map +1 -1
  38. package/lib/components/Listbox/Listbox.types.js.map +1 -1
  39. package/lib/components/Listbox/index.js.map +1 -1
  40. package/lib/components/Listbox/renderListbox.js +2 -2
  41. package/lib/components/Listbox/renderListbox.js.map +1 -1
  42. package/lib/components/Listbox/useListbox.js +15 -17
  43. package/lib/components/Listbox/useListbox.js.map +1 -1
  44. package/lib/components/Listbox/useListboxStyles.js +16 -20
  45. package/lib/components/Listbox/useListboxStyles.js.map +1 -1
  46. package/lib/components/Option/Option.js +0 -1
  47. package/lib/components/Option/Option.js.map +1 -1
  48. package/lib/components/Option/Option.types.js.map +1 -1
  49. package/lib/components/Option/index.js.map +1 -1
  50. package/lib/components/Option/renderOption.js +4 -3
  51. package/lib/components/Option/renderOption.js.map +1 -1
  52. package/lib/components/Option/useOption.js +46 -39
  53. package/lib/components/Option/useOption.js.map +1 -1
  54. package/lib/components/Option/useOptionStyles.js +101 -79
  55. package/lib/components/Option/useOptionStyles.js.map +1 -1
  56. package/lib/components/OptionGroup/OptionGroup.js +0 -1
  57. package/lib/components/OptionGroup/OptionGroup.js.map +1 -1
  58. package/lib/components/OptionGroup/OptionGroup.types.js.map +1 -1
  59. package/lib/components/OptionGroup/index.js.map +1 -1
  60. package/lib/components/OptionGroup/renderOptionGroup.js +4 -3
  61. package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
  62. package/lib/components/OptionGroup/useOptionGroup.js +0 -1
  63. package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
  64. package/lib/components/OptionGroup/useOptionGroupStyles.js +29 -34
  65. package/lib/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
  66. package/lib/contexts/ComboboxContext.js +9 -11
  67. package/lib/contexts/ComboboxContext.js.map +1 -1
  68. package/lib/contexts/ListboxContext.js +7 -9
  69. package/lib/contexts/ListboxContext.js.map +1 -1
  70. package/lib/contexts/useComboboxContextValues.js.map +1 -1
  71. package/lib/contexts/useListboxContextValues.js +2 -2
  72. package/lib/contexts/useListboxContextValues.js.map +1 -1
  73. package/lib/index.js +6 -0
  74. package/lib/index.js.map +1 -1
  75. package/lib/utils/ComboboxBase.types.js.map +1 -1
  76. package/lib/utils/OptionCollection.types.js.map +1 -1
  77. package/lib/utils/Selection.types.js.map +1 -1
  78. package/lib/utils/dropdownKeyActions.js +12 -33
  79. package/lib/utils/dropdownKeyActions.js.map +1 -1
  80. package/lib/utils/internalTokens.js.map +1 -1
  81. package/lib/utils/useComboboxBaseState.js +29 -30
  82. package/lib/utils/useComboboxBaseState.js.map +1 -1
  83. package/lib/utils/useComboboxPopup.js +6 -4
  84. package/lib/utils/useComboboxPopup.js.map +1 -1
  85. package/lib/utils/useOptionCollection.js +13 -23
  86. package/lib/utils/useOptionCollection.js.map +1 -1
  87. package/lib/utils/useScrollOptionsIntoView.js +36 -0
  88. package/lib/utils/useScrollOptionsIntoView.js.map +1 -0
  89. package/lib/utils/useSelection.js +9 -12
  90. package/lib/utils/useSelection.js.map +1 -1
  91. package/lib/utils/useTriggerListboxSlots.js +34 -40
  92. package/lib/utils/useTriggerListboxSlots.js.map +1 -1
  93. package/lib-amd/Combobox.js +6 -0
  94. package/lib-amd/Combobox.js.map +1 -0
  95. package/lib-amd/ComboboxField.js +6 -0
  96. package/lib-amd/ComboboxField.js.map +1 -0
  97. package/lib-amd/Dropdown.js +6 -0
  98. package/lib-amd/Dropdown.js.map +1 -0
  99. package/lib-amd/Listbox.js +6 -0
  100. package/lib-amd/Listbox.js.map +1 -0
  101. package/lib-amd/Option.js +6 -0
  102. package/lib-amd/Option.js.map +1 -0
  103. package/lib-amd/OptionGroup.js +6 -0
  104. package/lib-amd/OptionGroup.js.map +1 -0
  105. package/lib-amd/components/Combobox/Combobox.js +16 -0
  106. package/lib-amd/components/Combobox/Combobox.js.map +1 -0
  107. package/lib-amd/components/Combobox/Combobox.types.js +5 -0
  108. package/lib-amd/components/Combobox/Combobox.types.js.map +1 -0
  109. package/lib-amd/components/Combobox/index.js +10 -0
  110. package/lib-amd/components/Combobox/index.js.map +1 -0
  111. package/lib-amd/components/Combobox/renderCombobox.js +20 -0
  112. package/lib-amd/components/Combobox/renderCombobox.js.map +1 -0
  113. package/lib-amd/components/Combobox/useCombobox.js +206 -0
  114. package/lib-amd/components/Combobox/useCombobox.js.map +1 -0
  115. package/lib-amd/components/Combobox/useComboboxStyles.js +152 -0
  116. package/lib-amd/components/Combobox/useComboboxStyles.js.map +1 -0
  117. package/lib-amd/components/ComboboxField/ComboboxField.js +10 -0
  118. package/lib-amd/components/ComboboxField/ComboboxField.js.map +1 -0
  119. package/lib-amd/components/ComboboxField/index.js +6 -0
  120. package/lib-amd/components/ComboboxField/index.js.map +1 -0
  121. package/lib-amd/components/Dropdown/Dropdown.js +16 -0
  122. package/lib-amd/components/Dropdown/Dropdown.js.map +1 -0
  123. package/lib-amd/components/Dropdown/Dropdown.types.js +5 -0
  124. package/lib-amd/components/Dropdown/Dropdown.types.js.map +1 -0
  125. package/lib-amd/components/Dropdown/index.js +10 -0
  126. package/lib-amd/components/Dropdown/index.js.map +1 -0
  127. package/lib-amd/components/Dropdown/renderDropdown.js +21 -0
  128. package/lib-amd/components/Dropdown/renderDropdown.js.map +1 -0
  129. package/lib-amd/components/Dropdown/useDropdown.js +121 -0
  130. package/lib-amd/components/Dropdown/useDropdown.js.map +1 -0
  131. package/lib-amd/components/Dropdown/useDropdownStyles.js +127 -0
  132. package/lib-amd/components/Dropdown/useDropdownStyles.js.map +1 -0
  133. package/lib-amd/components/Listbox/Listbox.js +16 -0
  134. package/lib-amd/components/Listbox/Listbox.js.map +1 -0
  135. package/lib-amd/components/Listbox/Listbox.types.js +5 -0
  136. package/lib-amd/components/Listbox/Listbox.types.js.map +1 -0
  137. package/lib-amd/components/Listbox/index.js +10 -0
  138. package/lib-amd/components/Listbox/index.js.map +1 -0
  139. package/lib-amd/components/Listbox/renderListbox.js +15 -0
  140. package/lib-amd/components/Listbox/renderListbox.js.map +1 -0
  141. package/lib-amd/components/Listbox/useListbox.js +80 -0
  142. package/lib-amd/components/Listbox/useListbox.js.map +1 -0
  143. package/lib-amd/components/Listbox/useListboxStyles.js +24 -0
  144. package/lib-amd/components/Listbox/useListboxStyles.js.map +1 -0
  145. package/lib-amd/components/Option/Option.js +15 -0
  146. package/lib-amd/components/Option/Option.js.map +1 -0
  147. package/lib-amd/components/Option/Option.types.js +5 -0
  148. package/lib-amd/components/Option/Option.types.js.map +1 -0
  149. package/lib-amd/components/Option/index.js +10 -0
  150. package/lib-amd/components/Option/index.js.map +1 -0
  151. package/lib-amd/components/Option/renderOption.js +16 -0
  152. package/lib-amd/components/Option/renderOption.js.map +1 -0
  153. package/lib-amd/components/Option/useOption.js +117 -0
  154. package/lib-amd/components/Option/useOption.js.map +1 -0
  155. package/lib-amd/components/Option/useOptionStyles.js +73 -0
  156. package/lib-amd/components/Option/useOptionStyles.js.map +1 -0
  157. package/lib-amd/components/OptionGroup/OptionGroup.js +15 -0
  158. package/lib-amd/components/OptionGroup/OptionGroup.js.map +1 -0
  159. package/lib-amd/components/OptionGroup/OptionGroup.types.js +5 -0
  160. package/lib-amd/components/OptionGroup/OptionGroup.types.js.map +1 -0
  161. package/lib-amd/components/OptionGroup/index.js +10 -0
  162. package/lib-amd/components/OptionGroup/index.js.map +1 -0
  163. package/lib-amd/components/OptionGroup/renderOptionGroup.js +16 -0
  164. package/lib-amd/components/OptionGroup/renderOptionGroup.js.map +1 -0
  165. package/lib-amd/components/OptionGroup/useOptionGroup.js +33 -0
  166. package/lib-amd/components/OptionGroup/useOptionGroup.js.map +1 -0
  167. package/lib-amd/components/OptionGroup/useOptionGroupStyles.js +34 -0
  168. package/lib-amd/components/OptionGroup/useOptionGroupStyles.js.map +1 -0
  169. package/lib-amd/contexts/ComboboxContext.js +28 -0
  170. package/lib-amd/contexts/ComboboxContext.js.map +1 -0
  171. package/lib-amd/contexts/ListboxContext.js +23 -0
  172. package/lib-amd/contexts/ListboxContext.js.map +1 -0
  173. package/lib-amd/contexts/useComboboxContextValues.js +23 -0
  174. package/lib-amd/contexts/useComboboxContextValues.js.map +1 -0
  175. package/lib-amd/contexts/useListboxContextValues.js +24 -0
  176. package/lib-amd/contexts/useListboxContextValues.js.map +1 -0
  177. package/lib-amd/index.js +37 -0
  178. package/lib-amd/index.js.map +1 -0
  179. package/lib-amd/utils/ComboboxBase.types.js +5 -0
  180. package/lib-amd/utils/ComboboxBase.types.js.map +1 -0
  181. package/lib-amd/utils/OptionCollection.types.js +5 -0
  182. package/lib-amd/utils/OptionCollection.types.js.map +1 -0
  183. package/lib-amd/utils/Selection.types.js +5 -0
  184. package/lib-amd/utils/Selection.types.js.map +1 -0
  185. package/lib-amd/utils/dropdownKeyActions.js +85 -0
  186. package/lib-amd/utils/dropdownKeyActions.js.map +1 -0
  187. package/lib-amd/utils/internalTokens.js +11 -0
  188. package/lib-amd/utils/internalTokens.js.map +1 -0
  189. package/lib-amd/utils/useComboboxBaseState.js +76 -0
  190. package/lib-amd/utils/useComboboxBaseState.js.map +1 -0
  191. package/lib-amd/utils/useComboboxPopup.js +16 -0
  192. package/lib-amd/utils/useComboboxPopup.js.map +1 -0
  193. package/lib-amd/utils/useOptionCollection.js +65 -0
  194. package/lib-amd/utils/useOptionCollection.js.map +1 -0
  195. package/lib-amd/utils/useScrollOptionsIntoView.js +33 -0
  196. package/lib-amd/utils/useScrollOptionsIntoView.js.map +1 -0
  197. package/lib-amd/utils/useSelection.js +42 -0
  198. package/lib-amd/utils/useSelection.js.map +1 -0
  199. package/lib-amd/utils/useTriggerListboxSlots.js +104 -0
  200. package/lib-amd/utils/useTriggerListboxSlots.js.map +1 -0
  201. package/lib-commonjs/Combobox.js +0 -2
  202. package/lib-commonjs/Combobox.js.map +1 -1
  203. package/lib-commonjs/ComboboxField.js +8 -0
  204. package/lib-commonjs/ComboboxField.js.map +1 -0
  205. package/lib-commonjs/Dropdown.js +0 -2
  206. package/lib-commonjs/Dropdown.js.map +1 -1
  207. package/lib-commonjs/Listbox.js +0 -2
  208. package/lib-commonjs/Listbox.js.map +1 -1
  209. package/lib-commonjs/Option.js +0 -2
  210. package/lib-commonjs/Option.js.map +1 -1
  211. package/lib-commonjs/OptionGroup.js +0 -2
  212. package/lib-commonjs/OptionGroup.js.map +1 -1
  213. package/lib-commonjs/components/Combobox/Combobox.js +0 -7
  214. package/lib-commonjs/components/Combobox/Combobox.js.map +1 -1
  215. package/lib-commonjs/components/Combobox/Combobox.types.js.map +1 -1
  216. package/lib-commonjs/components/Combobox/index.js +0 -6
  217. package/lib-commonjs/components/Combobox/index.js.map +1 -1
  218. package/lib-commonjs/components/Combobox/renderCombobox.js +10 -12
  219. package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
  220. package/lib-commonjs/components/Combobox/useCombobox.js +106 -78
  221. package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
  222. package/lib-commonjs/components/Combobox/useComboboxStyles.js +245 -189
  223. package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
  224. package/lib-commonjs/components/ComboboxField/ComboboxField.js +14 -0
  225. package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -0
  226. package/lib-commonjs/components/ComboboxField/index.js +8 -0
  227. package/lib-commonjs/components/ComboboxField/index.js.map +1 -0
  228. package/lib-commonjs/components/Dropdown/Dropdown.js +0 -7
  229. package/lib-commonjs/components/Dropdown/Dropdown.js.map +1 -1
  230. package/lib-commonjs/components/Dropdown/Dropdown.types.js.map +1 -1
  231. package/lib-commonjs/components/Dropdown/index.js +0 -6
  232. package/lib-commonjs/components/Dropdown/index.js.map +1 -1
  233. package/lib-commonjs/components/Dropdown/renderDropdown.js +10 -12
  234. package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
  235. package/lib-commonjs/components/Dropdown/useDropdown.js +25 -47
  236. package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
  237. package/lib-commonjs/components/Dropdown/useDropdownStyles.js +235 -180
  238. package/lib-commonjs/components/Dropdown/useDropdownStyles.js.map +1 -1
  239. package/lib-commonjs/components/Listbox/Listbox.js +0 -7
  240. package/lib-commonjs/components/Listbox/Listbox.js.map +1 -1
  241. package/lib-commonjs/components/Listbox/Listbox.types.js.map +1 -1
  242. package/lib-commonjs/components/Listbox/index.js +0 -6
  243. package/lib-commonjs/components/Listbox/index.js.map +1 -1
  244. package/lib-commonjs/components/Listbox/renderListbox.js +2 -7
  245. package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
  246. package/lib-commonjs/components/Listbox/useListbox.js +14 -25
  247. package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
  248. package/lib-commonjs/components/Listbox/useListboxStyles.js +16 -24
  249. package/lib-commonjs/components/Listbox/useListboxStyles.js.map +1 -1
  250. package/lib-commonjs/components/Option/Option.js +0 -6
  251. package/lib-commonjs/components/Option/Option.js.map +1 -1
  252. package/lib-commonjs/components/Option/Option.types.js.map +1 -1
  253. package/lib-commonjs/components/Option/index.js +0 -6
  254. package/lib-commonjs/components/Option/index.js.map +1 -1
  255. package/lib-commonjs/components/Option/renderOption.js +4 -7
  256. package/lib-commonjs/components/Option/renderOption.js.map +1 -1
  257. package/lib-commonjs/components/Option/useOption.js +45 -45
  258. package/lib-commonjs/components/Option/useOption.js.map +1 -1
  259. package/lib-commonjs/components/Option/useOptionStyles.js +101 -83
  260. package/lib-commonjs/components/Option/useOptionStyles.js.map +1 -1
  261. package/lib-commonjs/components/OptionGroup/OptionGroup.js +0 -6
  262. package/lib-commonjs/components/OptionGroup/OptionGroup.js.map +1 -1
  263. package/lib-commonjs/components/OptionGroup/OptionGroup.types.js.map +1 -1
  264. package/lib-commonjs/components/OptionGroup/index.js +0 -6
  265. package/lib-commonjs/components/OptionGroup/index.js.map +1 -1
  266. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js +4 -7
  267. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js.map +1 -1
  268. package/lib-commonjs/components/OptionGroup/useOptionGroup.js +0 -4
  269. package/lib-commonjs/components/OptionGroup/useOptionGroup.js.map +1 -1
  270. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js +29 -38
  271. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
  272. package/lib-commonjs/contexts/ComboboxContext.js +10 -14
  273. package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
  274. package/lib-commonjs/contexts/ListboxContext.js +8 -12
  275. package/lib-commonjs/contexts/ListboxContext.js.map +1 -1
  276. package/lib-commonjs/contexts/useComboboxContextValues.js +0 -2
  277. package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
  278. package/lib-commonjs/contexts/useListboxContextValues.js +2 -6
  279. package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
  280. package/lib-commonjs/index.js +43 -11
  281. package/lib-commonjs/index.js.map +1 -1
  282. package/lib-commonjs/utils/ComboboxBase.types.js.map +1 -1
  283. package/lib-commonjs/utils/OptionCollection.types.js.map +1 -1
  284. package/lib-commonjs/utils/Selection.types.js.map +1 -1
  285. package/lib-commonjs/utils/dropdownKeyActions.js +12 -37
  286. package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
  287. package/lib-commonjs/utils/internalTokens.js.map +1 -1
  288. package/lib-commonjs/utils/useComboboxBaseState.js +29 -36
  289. package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
  290. package/lib-commonjs/utils/useComboboxPopup.js +6 -8
  291. package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
  292. package/lib-commonjs/utils/useOptionCollection.js +13 -26
  293. package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
  294. package/lib-commonjs/utils/useScrollOptionsIntoView.js +43 -0
  295. package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -0
  296. package/lib-commonjs/utils/useSelection.js +9 -15
  297. package/lib-commonjs/utils/useSelection.js.map +1 -1
  298. package/lib-commonjs/utils/useTriggerListboxSlots.js +33 -44
  299. package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
  300. package/package.json +23 -22
  301. package/Spec-migration.md +0 -13
  302. package/Spec.md +0 -520
@@ -1 +1 @@
1
- {"version":3,"sources":["Listbox.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Listbox/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/Listbox.ts"],"sourcesContent":["export * from './components/Listbox/index';\n"]}
@@ -3,8 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./components/Option/index"), exports);
10
8
  //# sourceMappingURL=Option.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["Option.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Option/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/Option.ts"],"sourcesContent":["export * from './components/Option/index';\n"]}
@@ -3,8 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./components/OptionGroup/index"), exports);
10
8
  //# sourceMappingURL=OptionGroup.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["OptionGroup.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gCAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/OptionGroup/index';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/OptionGroup.ts"],"sourcesContent":["export * from './components/OptionGroup/index';\n"]}
@@ -4,21 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Combobox = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const useCombobox_1 = /*#__PURE__*/require("./useCombobox");
11
-
12
9
  const renderCombobox_1 = /*#__PURE__*/require("./renderCombobox");
13
-
14
10
  const useComboboxStyles_1 = /*#__PURE__*/require("./useComboboxStyles");
15
-
16
11
  const useComboboxContextValues_1 = /*#__PURE__*/require("../../contexts/useComboboxContextValues");
17
12
  /**
18
13
  * Combobox component: a selection control that allows users to choose from a set of possible options
19
14
  */
20
-
21
-
22
15
  exports.Combobox = /*#__PURE__*/React.forwardRef((props, ref) => {
23
16
  const state = useCombobox_1.useCombobox_unstable(props, ref);
24
17
  const contextValues = useComboboxContextValues_1.useComboboxContextValues(state);
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Combobox/Combobox.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AAEA,MAAA,0BAAA,gBAAA,OAAA,CAAA,yCAAA,CAAA;AAGA;;AAEG;;;AACU,OAAA,CAAA,QAAA,gBAA+C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EAC1F,MAAM,KAAK,GAAG,aAAA,CAAA,oBAAA,CAAqB,KAArB,EAA4B,GAA5B,CAAd;EACA,MAAM,aAAa,GAAG,0BAAA,CAAA,wBAAA,CAAyB,KAAzB,CAAtB;EAEA,mBAAA,CAAA,0BAAA,CAA2B,KAA3B;EACA,OAAO,gBAAA,CAAA,uBAAA,CAAwB,KAAxB,EAA+B,aAA/B,CAAP;AACD,CAN2D,CAA/C;AAQb,OAAA,CAAA,QAAA,CAAS,WAAT,GAAuB,UAAvB","sourcesContent":["import * as React from 'react';\nimport { useCombobox_unstable } from './useCombobox';\nimport { renderCombobox_unstable } from './renderCombobox';\nimport { useComboboxStyles_unstable } from './useComboboxStyles';\nimport type { ComboboxProps } from './Combobox.types';\nimport { useComboboxContextValues } from '../../contexts/useComboboxContextValues';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Combobox component: a selection control that allows users to choose from a set of possible options\n */\nexport const Combobox: ForwardRefComponent<ComboboxProps> = React.forwardRef((props, ref) => {\n const state = useCombobox_unstable(props, ref);\n const contextValues = useComboboxContextValues(state);\n\n useComboboxStyles_unstable(state);\n return renderCombobox_unstable(state, contextValues);\n});\n\nCombobox.displayName = 'Combobox';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAEA;AAGA;;;AAGaA,gBAAQ,gBAAuCC,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAC1F,MAAMC,KAAK,GAAGC,kCAAoB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAC9C,MAAMG,aAAa,GAAGC,mDAAwB,CAACH,KAAK,CAAC;EAErDI,8CAA0B,CAACJ,KAAK,CAAC;EACjC,OAAOK,wCAAuB,CAACL,KAAK,EAAEE,aAAa,CAAC;AACtD,CAAC,CAAC;AAEFP,gBAAQ,CAACW,WAAW,GAAG,UAAU","names":["exports","React","forwardRef","props","ref","state","useCombobox_1","contextValues","useComboboxContextValues_1","useComboboxStyles_1","renderCombobox_1","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Combobox/Combobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useCombobox_unstable } from './useCombobox';\nimport { renderCombobox_unstable } from './renderCombobox';\nimport { useComboboxStyles_unstable } from './useComboboxStyles';\nimport type { ComboboxProps } from './Combobox.types';\nimport { useComboboxContextValues } from '../../contexts/useComboboxContextValues';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Combobox component: a selection control that allows users to choose from a set of possible options\n */\nexport const Combobox: ForwardRefComponent<ComboboxProps> = React.forwardRef((props, ref) => {\n const state = useCombobox_unstable(props, ref);\n const contextValues = useComboboxContextValues(state);\n\n useComboboxStyles_unstable(state);\n return renderCombobox_unstable(state, contextValues);\n});\n\nCombobox.displayName = 'Combobox';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
@@ -3,16 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./Combobox"), exports);
10
-
11
8
  tslib_1.__exportStar(require("./Combobox.types"), exports);
12
-
13
9
  tslib_1.__exportStar(require("./renderCombobox"), exports);
14
-
15
10
  tslib_1.__exportStar(require("./useCombobox"), exports);
16
-
17
11
  tslib_1.__exportStar(require("./useComboboxStyles"), exports);
18
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Combobox/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Combobox';\nexport * from './Combobox.types';\nexport * from './renderCombobox';\nexport * from './useCombobox';\nexport * from './useComboboxStyles';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Combobox/index.ts"],"sourcesContent":["export * from './Combobox';\nexport * from './Combobox.types';\nexport * from './renderCombobox';\nexport * from './useCombobox';\nexport * from './useComboboxStyles';\n"]}
@@ -4,33 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderCombobox_unstable = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
11
-
12
9
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
-
14
10
  const ComboboxContext_1 = /*#__PURE__*/require("../../contexts/ComboboxContext");
15
11
  /**
16
12
  * Render the final JSX of Combobox
17
13
  */
18
-
19
-
20
14
  const renderCombobox_unstable = (state, contextValues) => {
21
15
  const {
22
16
  slots,
23
17
  slotProps
24
18
  } = react_utilities_1.getSlots(state);
25
- return React.createElement(slots.root, { ...slotProps.root
19
+ return React.createElement(slots.root, {
20
+ ...slotProps.root
26
21
  }, React.createElement(ComboboxContext_1.ComboboxContext.Provider, {
27
22
  value: contextValues.combobox
28
- }, React.createElement(slots.input, { ...slotProps.input
29
- }), slots.expandIcon && React.createElement(slots.expandIcon, { ...slotProps.expandIcon
30
- }), slots.listbox && (state.inlinePopup ? React.createElement(slots.listbox, { ...slotProps.listbox
31
- }) : React.createElement(react_portal_1.Portal, null, React.createElement(slots.listbox, { ...slotProps.listbox
23
+ }, React.createElement(slots.input, {
24
+ ...slotProps.input
25
+ }), slots.expandIcon && React.createElement(slots.expandIcon, {
26
+ ...slotProps.expandIcon
27
+ }), slots.listbox && (state.inlinePopup ? React.createElement(slots.listbox, {
28
+ ...slotProps.listbox
29
+ }) : React.createElement(react_portal_1.Portal, null, React.createElement(slots.listbox, {
30
+ ...slotProps.listbox
32
31
  })))));
33
32
  };
34
-
35
33
  exports.renderCombobox_unstable = renderCombobox_unstable;
36
34
  //# sourceMappingURL=renderCombobox.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Combobox/renderCombobox.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,gCAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,uBAAuB,GAAG,CAAC,KAAD,EAAuB,aAAvB,KAA+D;EACpG,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAAwB,KAAxB,CAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACE,KAAA,CAAA,aAAA,CAAC,iBAAA,CAAA,eAAA,CAAgB,QAAjB,EAAyB;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAzB,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,KAAP,EAAY,EAAA,GAAK,SAAS,CAAC;EAAf,CAAZ,CADF,EAEG,KAAK,CAAC,UAAN,IAAoB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,UAAP,EAAiB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAjB,CAFvB,EAGG,KAAK,CAAC,OAAN,KACE,KAAK,CAAC,WAAN,GACC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;EAAf,CAAd,CADD,GAGC,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO,IAAP,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;EAAf,CAAd,CADF,CAJH,CAHH,CADF,CADF;AAgBD,CAnBM;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB","sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport type { ComboboxContextValues, ComboboxState, ComboboxSlots } from './Combobox.types';\n\n/**\n * Render the final JSX of Combobox\n */\nexport const renderCombobox_unstable = (state: ComboboxState, contextValues: ComboboxContextValues) => {\n const { slots, slotProps } = getSlots<ComboboxSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <ComboboxContext.Provider value={contextValues.combobox}>\n <slots.input {...slotProps.input} />\n {slots.expandIcon && <slots.expandIcon {...slotProps.expandIcon} />}\n {slots.listbox &&\n (state.inlinePopup ? (\n <slots.listbox {...slotProps.listbox} />\n ) : (\n <Portal>\n <slots.listbox {...slotProps.listbox} />\n </Portal>\n ))}\n </ComboboxContext.Provider>\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAGA;;;AAGO,MAAMA,uBAAuB,GAAG,CAACC,KAAoB,EAAEC,aAAoC,KAAI;EACpG,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAgBJ,KAAK,CAAC;EAE3D,OACEK,oBAACH,KAAK,CAACI,IAAI;IAAA,GAAKH,SAAS,CAACG;EAAI,GAC5BD,oBAACE,iCAAe,CAACC,QAAQ;IAACC,KAAK,EAAER,aAAa,CAACS;EAAQ,GACrDL,oBAACH,KAAK,CAACS,KAAK;IAAA,GAAKR,SAAS,CAACQ;EAAK,EAAI,EACnCT,KAAK,CAACU,UAAU,IAAIP,oBAACH,KAAK,CAACU,UAAU;IAAA,GAAKT,SAAS,CAACS;EAAU,EAAI,EAClEV,KAAK,CAACW,OAAO,KACXb,KAAK,CAACc,WAAW,GAChBT,oBAACH,KAAK,CAACW,OAAO;IAAA,GAAKV,SAAS,CAACU;EAAO,EAAI,GAExCR,oBAACU,qBAAM,QACLV,oBAACH,KAAK,CAACW,OAAO;IAAA,GAAKV,SAAS,CAACU;EAAO,EAAI,CAE3C,CAAC,CACqB,CAChB;AAEjB,CAAC;AAnBYG,+BAAuB","names":["renderCombobox_unstable","state","contextValues","slots","slotProps","react_utilities_1","React","root","ComboboxContext_1","Provider","value","combobox","input","expandIcon","listbox","inlinePopup","react_portal_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Combobox/renderCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport type { ComboboxContextValues, ComboboxState, ComboboxSlots } from './Combobox.types';\n\n/**\n * Render the final JSX of Combobox\n */\nexport const renderCombobox_unstable = (state: ComboboxState, contextValues: ComboboxContextValues) => {\n const { slots, slotProps } = getSlots<ComboboxSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <ComboboxContext.Provider value={contextValues.combobox}>\n <slots.input {...slotProps.input} />\n {slots.expandIcon && <slots.expandIcon {...slotProps.expandIcon} />}\n {slots.listbox &&\n (state.inlinePopup ? (\n <slots.listbox {...slotProps.listbox} />\n ) : (\n <Portal>\n <slots.listbox {...slotProps.listbox} />\n </Portal>\n ))}\n </ComboboxContext.Provider>\n </slots.root>\n );\n};\n"]}
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useCombobox_unstable = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
8
+ const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
10
9
  const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
11
-
12
10
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
-
11
+ const dropdownKeyActions_1 = /*#__PURE__*/require("../../utils/dropdownKeyActions");
14
12
  const useComboboxBaseState_1 = /*#__PURE__*/require("../../utils/useComboboxBaseState");
15
-
16
- const useTriggerListboxSlots_1 = /*#__PURE__*/require("../../utils/useTriggerListboxSlots");
17
-
18
13
  const useComboboxPopup_1 = /*#__PURE__*/require("../../utils/useComboboxPopup");
19
-
14
+ const useTriggerListboxSlots_1 = /*#__PURE__*/require("../../utils/useTriggerListboxSlots");
20
15
  const Listbox_1 = /*#__PURE__*/require("../Listbox/Listbox");
21
16
  /**
22
17
  * Create the state required to render Combobox.
@@ -27,17 +22,17 @@ const Listbox_1 = /*#__PURE__*/require("../Listbox/Listbox");
27
22
  * @param props - props from this instance of Combobox
28
23
  * @param ref - reference to root HTMLElement of Combobox
29
24
  */
30
-
31
-
32
25
  const useCombobox_unstable = (props, ref) => {
33
- var _a;
34
-
35
- const baseState = useComboboxBaseState_1.useComboboxBaseState(props);
26
+ var _a, _b;
27
+ const baseState = useComboboxBaseState_1.useComboboxBaseState({
28
+ ...props,
29
+ editable: true
30
+ });
36
31
  const {
37
32
  activeOption,
38
33
  clearSelection,
39
34
  getIndexOfId,
40
- getOptionsMatchingValue,
35
+ getOptionsMatchingText,
41
36
  hasFocus,
42
37
  open,
43
38
  selectOption,
@@ -49,9 +44,12 @@ const useCombobox_unstable = (props, ref) => {
49
44
  value
50
45
  } = baseState;
51
46
  const {
47
+ disabled,
52
48
  freeform,
49
+ inlinePopup,
53
50
  multiselect
54
51
  } = props;
52
+ const comboId = react_utilities_1.useId('combobox-');
55
53
  const {
56
54
  primary: triggerNativeProps,
57
55
  root: rootNativeProps
@@ -61,90 +59,95 @@ const useCombobox_unstable = (props, ref) => {
61
59
  excludedPropNames: ['children', 'size']
62
60
  });
63
61
  const rootRef = React.useRef(null);
64
- const triggerRef = React.useRef(null); // calculate listbox width style based on trigger width
65
-
66
- const [popupWidth, setPopupWidth] = React.useState();
62
+ const triggerRef = React.useRef(null);
63
+ // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set
64
+ // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows
65
+ // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888
66
+ const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);
67
+ // calculate listbox width style based on trigger width
68
+ const [popupDimensions, setPopupDimensions] = React.useState();
67
69
  React.useEffect(() => {
68
70
  var _a;
69
-
70
- const width = open ? `${(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px` : undefined;
71
- setPopupWidth(width);
72
- }, [open]); // handle input type-to-select
73
-
74
- const getSearchString = inputValue => {
75
- // if there are commas in the value string, take the text after the last comma
76
- const searchString = inputValue.split(',').pop();
77
- return (searchString === null || searchString === void 0 ? void 0 : searchString.trim().toLowerCase()) || '';
78
- }; // set active option and selection based on typing
79
-
80
-
71
+ // only recalculate width when opening
72
+ if (open) {
73
+ const width = `${(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px`;
74
+ if (width !== (popupDimensions === null || popupDimensions === void 0 ? void 0 : popupDimensions.width)) {
75
+ setPopupDimensions({
76
+ width
77
+ });
78
+ }
79
+ }
80
+ }, [open, popupDimensions]);
81
+ // set active option and selection based on typing
81
82
  const getOptionFromInput = inputValue => {
82
83
  var _a;
83
-
84
- const searchString = getSearchString(inputValue);
85
-
86
- if (searchString.length === 0) {
84
+ const searchString = inputValue === null || inputValue === void 0 ? void 0 : inputValue.trim().toLowerCase();
85
+ if (!searchString || searchString.length === 0) {
87
86
  return;
88
87
  }
89
-
90
- const matcher = optionValue => optionValue.toLowerCase().indexOf(searchString) === 0;
91
-
92
- const matches = getOptionsMatchingValue(matcher); // return first matching option after the current active option, looping back to the top
93
-
88
+ const matcher = optionText => optionText.toLowerCase().indexOf(searchString) === 0;
89
+ const matches = getOptionsMatchingText(matcher);
90
+ // return first matching option after the current active option, looping back to the top
94
91
  if (matches.length > 1 && activeOption) {
95
92
  const startIndex = getIndexOfId(activeOption.id);
96
93
  const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);
97
94
  return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
98
95
  }
99
-
100
96
  return (_a = matches[0]) !== null && _a !== void 0 ? _a : undefined;
101
97
  };
102
98
  /* Handle typed input */
103
99
  // reset any typed value when an option is selected
104
-
105
-
106
100
  baseState.selectOption = (ev, option) => {
107
101
  setValue(undefined);
108
102
  selectOption(ev, option);
109
103
  };
110
-
111
104
  const onTriggerBlur = ev => {
112
105
  // handle selection and updating value if freeform is false
113
106
  if (!baseState.open && !freeform) {
114
107
  // select matching option, if the value fully matches
115
- if (value && activeOption && getSearchString(value) === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.value.toLowerCase())) {
108
+ if (value && activeOption && value.trim().toLowerCase() === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.value.toLowerCase())) {
116
109
  baseState.selectOption(ev, activeOption);
117
- } // reset typed value when the input loses focus while collapsed, unless freeform is true
118
-
119
-
110
+ }
111
+ // reset typed value when the input loses focus while collapsed, unless freeform is true
120
112
  setValue(undefined);
121
113
  }
122
114
  };
123
-
124
115
  baseState.setOpen = (ev, newState) => {
116
+ if (disabled) {
117
+ return;
118
+ }
125
119
  if (!newState && !freeform) {
126
120
  setValue(undefined);
127
121
  }
128
-
129
122
  setOpen(ev, newState);
130
- }; // update value and active option based on input
131
-
132
-
123
+ };
124
+ // update value and active option based on input
133
125
  const onTriggerChange = ev => {
134
- const inputValue = ev.target.value; // update uncontrolled value
135
-
136
- baseState.setValue(inputValue); // handle updating active option based on input
137
-
126
+ const inputValue = ev.target.value;
127
+ // update uncontrolled value
128
+ baseState.setValue(inputValue);
129
+ // handle updating active option based on input
138
130
  const matchingOption = getOptionFromInput(inputValue);
139
131
  setActiveOption(matchingOption);
140
- setFocusVisible(true); // clear selection for single-select if the input value no longer matches the selection
141
-
132
+ setFocusVisible(true);
133
+ // clear selection for single-select if the input value no longer matches the selection
142
134
  if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || selectedOptions[0].indexOf(inputValue) !== 0)) {
143
135
  clearSelection(ev);
144
136
  }
145
- }; // resolve input and listbox slot props
146
-
147
-
137
+ };
138
+ // open Combobox when typing
139
+ const onTriggerKeyDown = ev => {
140
+ if (!open && dropdownKeyActions_1.getDropdownActionFromKey(ev) === 'Type') {
141
+ baseState.setOpen(ev, true);
142
+ }
143
+ // clear activedescendant when moving the text insertion cursor
144
+ if (ev.key === keyboard_keys_1.ArrowLeft || ev.key === keyboard_keys_1.ArrowRight) {
145
+ setHideActiveDescendant(true);
146
+ } else {
147
+ setHideActiveDescendant(false);
148
+ }
149
+ };
150
+ // resolve input and listbox slot props
148
151
  let triggerSlot;
149
152
  let listboxSlot;
150
153
  triggerSlot = react_utilities_1.resolveShorthand(props.input, {
@@ -157,19 +160,21 @@ const useCombobox_unstable = (props, ref) => {
157
160
  }
158
161
  });
159
162
  triggerSlot.onChange = react_utilities_1.mergeCallbacks(triggerSlot.onChange, onTriggerChange);
160
- triggerSlot.onBlur = react_utilities_1.mergeCallbacks(triggerSlot.onBlur, onTriggerBlur); // only resolve listbox slot if needed
161
-
163
+ triggerSlot.onBlur = react_utilities_1.mergeCallbacks(triggerSlot.onBlur, onTriggerBlur);
164
+ triggerSlot.onKeyDown = react_utilities_1.mergeCallbacks(triggerSlot.onKeyDown, onTriggerKeyDown);
165
+ // only resolve listbox slot if needed
162
166
  listboxSlot = open || hasFocus ? react_utilities_1.resolveShorthand(props.listbox, {
163
167
  required: true,
164
168
  defaultProps: {
165
169
  children: props.children,
166
- style: {
167
- width: popupWidth
168
- }
170
+ style: popupDimensions
169
171
  }
170
172
  }) : undefined;
171
173
  [triggerSlot, listboxSlot] = useComboboxPopup_1.useComboboxPopup(props, triggerSlot, listboxSlot);
172
174
  [triggerSlot, listboxSlot] = useTriggerListboxSlots_1.useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);
175
+ if (hideActiveDescendant) {
176
+ triggerSlot['aria-activedescendant'] = undefined;
177
+ }
173
178
  const state = {
174
179
  components: {
175
180
  root: 'div',
@@ -179,7 +184,9 @@ const useCombobox_unstable = (props, ref) => {
179
184
  },
180
185
  root: react_utilities_1.resolveShorthand(props.root, {
181
186
  required: true,
182
- defaultProps: { ...rootNativeProps
187
+ defaultProps: {
188
+ 'aria-owns': !inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,
189
+ ...rootNativeProps
183
190
  }
184
191
  }),
185
192
  input: triggerSlot,
@@ -187,38 +194,59 @@ const useCombobox_unstable = (props, ref) => {
187
194
  expandIcon: react_utilities_1.resolveShorthand(props.expandIcon, {
188
195
  required: true,
189
196
  defaultProps: {
190
- children: React.createElement(react_icons_1.ChevronDownRegular, null)
197
+ 'aria-expanded': open,
198
+ children: React.createElement(react_icons_1.ChevronDownRegular, null),
199
+ role: 'button'
191
200
  }
192
201
  }),
193
- ...baseState,
194
- setOpen
202
+ ...baseState
195
203
  };
196
204
  state.root.ref = react_utilities_1.useMergedRefs(state.root.ref, rootRef);
197
205
  /* handle open/close + focus change when clicking expandIcon */
198
-
199
206
  const {
200
207
  onMouseDown: onIconMouseDown,
201
208
  onClick: onIconClick
202
209
  } = state.expandIcon || {};
203
210
  const onExpandIconMouseDown = react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(onIconMouseDown, () => {
204
- // do not dismiss on blur when clicking the icon
205
- baseState.ignoreNextBlur.current = true;
211
+ // do not dismiss on blur when closing via clicking the icon
212
+ if (open) {
213
+ baseState.ignoreNextBlur.current = true;
214
+ }
206
215
  }));
207
216
  const onExpandIconClick = react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(onIconClick, event => {
208
- var _a; // open and set focus
209
-
210
-
217
+ var _a;
218
+ // open and set focus
211
219
  state.setOpen(event, !state.open);
212
220
  (_a = triggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
221
+ // set focus visible=false, since this can only be done with the mouse/pointer
222
+ setFocusVisible(false);
213
223
  }));
214
-
215
224
  if (state.expandIcon) {
216
225
  state.expandIcon.onMouseDown = onExpandIconMouseDown;
217
226
  state.expandIcon.onClick = onExpandIconClick;
227
+ // If there is no explicit aria-label, calculate default accName attribute for expandIcon button,
228
+ // using the following steps:
229
+ // 1. If there is an aria-label, it is "Open [aria-label]"
230
+ // 2. If there is an aria-labelledby, it is "Open [aria-labelledby target]" (using aria-labelledby + ids)
231
+ // 3. If there is no aria-label/ledby attr, it falls back to "Open"
232
+ // We can't fall back to a label/htmlFor name because of https://github.com/w3c/accname/issues/179
233
+ const hasExpandLabel = state.expandIcon['aria-label'] || state.expandIcon['aria-labelledby'];
234
+ const defaultOpenString = 'Open'; // this is english-only since it is the fallback
235
+ if (!hasExpandLabel) {
236
+ if (props['aria-labelledby']) {
237
+ const chevronId = (_b = state.expandIcon.id) !== null && _b !== void 0 ? _b : `${comboId}-chevron`;
238
+ const chevronLabelledBy = `${chevronId} ${state.input['aria-labelledby']}`;
239
+ state.expandIcon['aria-label'] = defaultOpenString;
240
+ state.expandIcon.id = chevronId;
241
+ state.expandIcon['aria-labelledby'] = chevronLabelledBy;
242
+ } else if (props['aria-label']) {
243
+ state.expandIcon['aria-label'] = `${defaultOpenString} ${props['aria-label']}`;
244
+ } else {
245
+ state.expandIcon['aria-label'] = defaultOpenString;
246
+ }
247
+ }
218
248
  }
219
-
220
249
  return state;
221
250
  };
222
-
223
251
  exports.useCombobox_unstable = useCombobox_unstable;
224
252
  //# sourceMappingURL=useCombobox.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["components/Combobox/useCombobox.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAA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CAAA,gBAAA,CACxB,iBAAA,CAAA,cAAA,CAAe,WAAf,EAA6B,KAAD,IAA6C;WAAA,CACvE;;;IACA,KAAK,CAAC,OAAN,CAAc,KAAd,EAAqB,CAAC,KAAK,CAAC,IAA5B;IACA,CAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,KAAF,EAAlB;EACD,CAJD,CADwB,CAA1B;;EAQA,IAAI,KAAK,CAAC,UAAV,EAAsB;IACpB,KAAK,CAAC,UAAN,CAAiB,WAAjB,GAA+B,qBAA/B;IACA,KAAK,CAAC,UAAN,CAAiB,OAAjB,GAA2B,iBAA3B;EACD;;EAED,OAAO,KAAP;AACD,CArMM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n resolveShorthand,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { SelectionEvents } from '../../utils/Selection.types';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { ComboboxProps, ComboboxState } from './Combobox.types';\n\n/**\n * Create the state required to render Combobox.\n *\n * The returned state can be modified with hooks such as useComboboxStyles_unstable,\n * before being passed to renderCombobox_unstable.\n *\n * @param props - props from this instance of Combobox\n * @param ref - reference to root HTMLElement of Combobox\n */\nexport const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLInputElement>): ComboboxState => {\n const baseState = useComboboxBaseState(props);\n const {\n activeOption,\n clearSelection,\n getIndexOfId,\n getOptionsMatchingValue,\n hasFocus,\n open,\n selectOption,\n selectedOptions,\n setActiveOption,\n setFocusVisible,\n setOpen,\n setValue,\n value,\n } = baseState;\n const { freeform, multiselect } = props;\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['children', 'size'],\n });\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLInputElement>(null);\n\n // calculate listbox width style based on trigger width\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 // handle input type-to-select\n const getSearchString = (inputValue: string): string => {\n // if there are commas in the value string, take the text after the last comma\n const searchString = inputValue.split(',').pop();\n\n return searchString?.trim().toLowerCase() || '';\n };\n\n // set active option and selection based on typing\n const getOptionFromInput = (inputValue: string): OptionValue | undefined => {\n const searchString = getSearchString(inputValue);\n\n if (searchString.length === 0) {\n return;\n }\n\n const matcher = (optionValue: string) => optionValue.toLowerCase().indexOf(searchString) === 0;\n const matches = getOptionsMatchingValue(matcher);\n\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const startIndex = getIndexOfId(activeOption.id);\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 /* Handle typed input */\n\n // reset any typed value when an option is selected\n baseState.selectOption = (ev: SelectionEvents, option: OptionValue) => {\n setValue(undefined);\n selectOption(ev, option);\n };\n\n const onTriggerBlur = (ev: React.FocusEvent<HTMLInputElement>) => {\n // handle selection and updating value if freeform is false\n if (!baseState.open && !freeform) {\n // select matching option, if the value fully matches\n if (value && activeOption && getSearchString(value) === activeOption?.value.toLowerCase()) {\n baseState.selectOption(ev, activeOption);\n }\n\n // reset typed value when the input loses focus while collapsed, unless freeform is true\n setValue(undefined);\n }\n };\n\n baseState.setOpen = (ev, newState: boolean) => {\n if (!newState && !freeform) {\n setValue(undefined);\n }\n\n setOpen(ev, newState);\n };\n\n // update value and active option based on input\n const onTriggerChange = (ev: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = ev.target.value;\n // update uncontrolled value\n baseState.setValue(inputValue);\n\n // handle updating active option based on input\n const matchingOption = getOptionFromInput(inputValue);\n setActiveOption(matchingOption);\n\n setFocusVisible(true);\n\n // clear selection for single-select if the input value no longer matches the selection\n if (\n !multiselect &&\n selectedOptions.length === 1 &&\n (inputValue.length < 1 || selectedOptions[0].indexOf(inputValue) !== 0)\n ) {\n clearSelection(ev);\n }\n };\n\n // resolve input and listbox slot props\n let triggerSlot: Slot<'input'>;\n let listboxSlot: Slot<typeof Listbox> | undefined;\n\n triggerSlot = resolveShorthand(props.input, {\n required: true,\n defaultProps: {\n ref: useMergedRefs(props.input?.ref, triggerRef),\n type: 'text',\n value: value ?? '',\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);\n triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur);\n\n // only resolve listbox slot if needed\n listboxSlot =\n open || 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: ComboboxState = {\n components: {\n root: 'div',\n input: 'input',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n ...rootNativeProps,\n },\n }),\n input: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: <ChevronDownIcon />,\n },\n }),\n ...baseState,\n setOpen,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n\n /* handle open/close + focus change when clicking expandIcon */\n const { onMouseDown: onIconMouseDown, onClick: onIconClick } = state.expandIcon || {};\n const onExpandIconMouseDown = useEventCallback(\n mergeCallbacks(onIconMouseDown, () => {\n // do not dismiss on blur when clicking the icon\n baseState.ignoreNextBlur.current = true;\n }),\n );\n\n const onExpandIconClick = useEventCallback(\n mergeCallbacks(onIconClick, (event: React.MouseEvent<HTMLSpanElement>) => {\n // open and set focus\n state.setOpen(event, !state.open);\n triggerRef.current?.focus();\n }),\n );\n\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AAMA;;;;;;;;;AASO,MAAMA,oBAAoB,GAAG,CAACC,KAAoB,EAAEC,GAAgC,KAAmB;;EAC5G,MAAMC,SAAS,GAAGC,2CAAoB,CAAC;IAAE,GAAGH,KAAK;IAAEI,QAAQ,EAAE;EAAI,CAAE,CAAC;EACpE,MAAM;IACJC,YAAY;IACZC,cAAc;IACdC,YAAY;IACZC,sBAAsB;IACtBC,QAAQ;IACRC,IAAI;IACJC,YAAY;IACZC,eAAe;IACfC,eAAe;IACfC,eAAe;IACfC,OAAO;IACPC,QAAQ;IACRC;EAAK,CACN,GAAGf,SAAS;EACb,MAAM;IAAEgB,QAAQ;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;EAAW,CAAE,GAAGrB,KAAK;EAC9D,MAAMsB,OAAO,GAAGC,uBAAK,CAAC,WAAW,CAAC;EAElC,MAAM;IAAEC,OAAO,EAAEC,kBAAkB;IAAEC,IAAI,EAAEC;EAAe,CAAE,GAAGJ,2CAAyB,CAAC;IACvFvB,KAAK;IACL4B,kBAAkB,EAAE,OAAO;IAC3BC,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM;GACv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,UAAU,CAAC/B,EAAE,mCAAI,GAAGhC,OAAO,UAAU;QAC7D,MAAM+E,iBAAiB,GAAG,GAAGD,SAAS,IAAIjB,KAAK,CAACZ,KAAK,CAAC,iBAAiB,CAAC,EAAE;QAE1EY,KAAK,CAACE,UAAU,CAAC,YAAY,CAAC,GAAGc,iBAAiB;QAClDhB,KAAK,CAACE,UAAU,CAAC/B,EAAE,GAAG8C,SAAS;QAC/BjB,KAAK,CAACE,UAAU,CAAC,iBAAiB,CAAC,GAAGgB,iBAAiB;OACxD,MAAM,IAAIrG,KAAK,CAAC,YAAY,CAAC,EAAE;QAC9BmF,KAAK,CAACE,UAAU,CAAC,YAAY,CAAC,GAAG,GAAGc,iBAAiB,IAAInG,KAAK,CAAC,YAAY,CAAC,EAAE;OAC/E,MAAM;QACLmF,KAAK,CAACE,UAAU,CAAC,YAAY,CAAC,GAAGc,iBAAiB;;;;EAKxD,OAAOhB,KAAK;AACd,CAAC;AA7PYmB,4BAAoB","names":["useCombobox_unstable","props","ref","baseState","useComboboxBaseState_1","editable","activeOption","clearSelection","getIndexOfId","getOptionsMatchingText","hasFocus","open","selectOption","selectedOptions","setActiveOption","setFocusVisible","setOpen","setValue","value","disabled","freeform","inlinePopup","multiselect","comboId","react_utilities_1","primary","triggerNativeProps","root","rootNativeProps","primarySlotTagName","excludedPropNames","rootRef","React","useRef","triggerRef","hideActiveDescendant","setHideActiveDescendant","useState","popupDimensions","setPopupDimensions","useEffect","width","current","clientWidth","getOptionFromInput","inputValue","searchString","trim","toLowerCase","length","matcher","optionText","indexOf","matches","startIndex","id","nextMatch","find","option","undefined","ev","onTriggerBlur","newState","onTriggerChange","target","matchingOption","onTriggerKeyDown","dropdownKeyActions_1","key","keyboard_keys_1","triggerSlot","listboxSlot","input","required","defaultProps","type","onChange","onBlur","onKeyDown","listbox","children","style","useComboboxPopup_1","useTriggerListboxSlots_1","state","components","expandIcon","Listbox_1","react_icons_1","role","onMouseDown","onIconMouseDown","onClick","onIconClick","onExpandIconMouseDown","ignoreNextBlur","onExpandIconClick","event","focus","hasExpandLabel","defaultOpenString","chevronId","chevronLabelledBy","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Combobox/useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n resolveShorthand,\n mergeCallbacks,\n useEventCallback,\n useId,\n useMergedRefs,\n} 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 { SelectionEvents } from '../../utils/Selection.types';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { ComboboxProps, ComboboxState } from './Combobox.types';\n\n/**\n * Create the state required to render Combobox.\n *\n * The returned state can be modified with hooks such as useComboboxStyles_unstable,\n * before being passed to renderCombobox_unstable.\n *\n * @param props - props from this instance of Combobox\n * @param ref - reference to root HTMLElement of Combobox\n */\nexport const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLInputElement>): ComboboxState => {\n const baseState = useComboboxBaseState({ ...props, editable: true });\n const {\n activeOption,\n clearSelection,\n getIndexOfId,\n getOptionsMatchingText,\n hasFocus,\n open,\n selectOption,\n selectedOptions,\n setActiveOption,\n setFocusVisible,\n setOpen,\n setValue,\n value,\n } = baseState;\n const { disabled, freeform, inlinePopup, multiselect } = props;\n const comboId = useId('combobox-');\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['children', 'size'],\n });\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLInputElement>(null);\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n\n // calculate listbox width style based on trigger width\n const [popupDimensions, setPopupDimensions] = React.useState<{ width: string }>();\n React.useEffect(() => {\n // only recalculate width when opening\n if (open) {\n const width = `${rootRef.current?.clientWidth}px`;\n if (width !== popupDimensions?.width) {\n setPopupDimensions({ width });\n }\n }\n }, [open, popupDimensions]);\n\n // set active option and selection based on typing\n const getOptionFromInput = (inputValue: string): OptionValue | undefined => {\n const searchString = inputValue?.trim().toLowerCase();\n\n if (!searchString || searchString.length === 0) {\n return;\n }\n\n const matcher = (optionText: string) => optionText.toLowerCase().indexOf(searchString) === 0;\n const matches = getOptionsMatchingText(matcher);\n\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const startIndex = getIndexOfId(activeOption.id);\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 /* Handle typed input */\n\n // reset any typed value when an option is selected\n baseState.selectOption = (ev: SelectionEvents, option: OptionValue) => {\n setValue(undefined);\n selectOption(ev, option);\n };\n\n const onTriggerBlur = (ev: React.FocusEvent<HTMLInputElement>) => {\n // handle selection and updating value if freeform is false\n if (!baseState.open && !freeform) {\n // select matching option, if the value fully matches\n if (value && activeOption && value.trim().toLowerCase() === activeOption?.value.toLowerCase()) {\n baseState.selectOption(ev, activeOption);\n }\n\n // reset typed value when the input loses focus while collapsed, unless freeform is true\n setValue(undefined);\n }\n };\n\n baseState.setOpen = (ev, newState: boolean) => {\n if (disabled) {\n return;\n }\n\n if (!newState && !freeform) {\n setValue(undefined);\n }\n\n setOpen(ev, newState);\n };\n\n // update value and active option based on input\n const onTriggerChange = (ev: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = ev.target.value;\n // update uncontrolled value\n baseState.setValue(inputValue);\n\n // handle updating active option based on input\n const matchingOption = getOptionFromInput(inputValue);\n setActiveOption(matchingOption);\n\n setFocusVisible(true);\n\n // clear selection for single-select if the input value no longer matches the selection\n if (\n !multiselect &&\n selectedOptions.length === 1 &&\n (inputValue.length < 1 || selectedOptions[0].indexOf(inputValue) !== 0)\n ) {\n clearSelection(ev);\n }\n };\n\n // open Combobox when typing\n const onTriggerKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n baseState.setOpen(ev, true);\n }\n\n // clear activedescendant when moving the text insertion cursor\n if (ev.key === ArrowLeft || ev.key === ArrowRight) {\n setHideActiveDescendant(true);\n } else {\n setHideActiveDescendant(false);\n }\n };\n\n // resolve input and listbox slot props\n let triggerSlot: Slot<'input'>;\n let listboxSlot: Slot<typeof Listbox> | undefined;\n\n triggerSlot = resolveShorthand(props.input, {\n required: true,\n defaultProps: {\n ref: useMergedRefs(props.input?.ref, triggerRef),\n type: 'text',\n value: value ?? '',\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);\n triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur);\n triggerSlot.onKeyDown = mergeCallbacks(triggerSlot.onKeyDown, onTriggerKeyDown);\n\n // only resolve listbox slot if needed\n listboxSlot =\n open || hasFocus\n ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: popupDimensions,\n },\n })\n : undefined;\n\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n\n if (hideActiveDescendant) {\n triggerSlot['aria-activedescendant'] = undefined;\n }\n\n const state: ComboboxState = {\n components: {\n root: 'div',\n input: 'input',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n 'aria-owns': !inlinePopup ? listboxSlot?.id : undefined,\n ...rootNativeProps,\n },\n }),\n input: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n 'aria-expanded': open,\n children: <ChevronDownIcon />,\n role: 'button',\n },\n }),\n ...baseState,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n\n /* handle open/close + focus change when clicking expandIcon */\n const { onMouseDown: onIconMouseDown, onClick: onIconClick } = state.expandIcon || {};\n const onExpandIconMouseDown = useEventCallback(\n mergeCallbacks(onIconMouseDown, () => {\n // do not dismiss on blur when closing via clicking the icon\n if (open) {\n baseState.ignoreNextBlur.current = true;\n }\n }),\n );\n\n const onExpandIconClick = useEventCallback(\n mergeCallbacks(onIconClick, (event: React.MouseEvent<HTMLSpanElement>) => {\n // open and set focus\n state.setOpen(event, !state.open);\n triggerRef.current?.focus();\n\n // set focus visible=false, since this can only be done with the mouse/pointer\n setFocusVisible(false);\n }),\n );\n\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\n\n // If there is no explicit aria-label, calculate default accName attribute for expandIcon button,\n // using the following steps:\n // 1. If there is an aria-label, it is \"Open [aria-label]\"\n // 2. If there is an aria-labelledby, it is \"Open [aria-labelledby target]\" (using aria-labelledby + ids)\n // 3. If there is no aria-label/ledby attr, it falls back to \"Open\"\n // We can't fall back to a label/htmlFor name because of https://github.com/w3c/accname/issues/179\n const hasExpandLabel = state.expandIcon['aria-label'] || state.expandIcon['aria-labelledby'];\n const defaultOpenString = 'Open'; // this is english-only since it is the fallback\n if (!hasExpandLabel) {\n if (props['aria-labelledby']) {\n const chevronId = state.expandIcon.id ?? `${comboId}-chevron`;\n const chevronLabelledBy = `${chevronId} ${state.input['aria-labelledby']}`;\n\n state.expandIcon['aria-label'] = defaultOpenString;\n state.expandIcon.id = chevronId;\n state.expandIcon['aria-labelledby'] = chevronLabelledBy;\n } else if (props['aria-label']) {\n state.expandIcon['aria-label'] = `${defaultOpenString} ${props['aria-label']}`;\n } else {\n state.expandIcon['aria-label'] = defaultOpenString;\n }\n }\n }\n\n return state;\n};\n"]}