@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
@@ -0,0 +1,121 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-icons", "@fluentui/react-utilities", "../../utils/dropdownKeyActions", "../../utils/useComboboxBaseState", "../../utils/useComboboxPopup", "../../utils/useTriggerListboxSlots", "../Listbox/Listbox", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_icons_1, react_utilities_1, dropdownKeyActions_1, useComboboxBaseState_1, useComboboxPopup_1, useTriggerListboxSlots_1, Listbox_1, react_utilities_2) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useDropdown_unstable = void 0;
5
+ /**
6
+ * Create the state required to render Dropdown.
7
+ *
8
+ * The returned state can be modified with hooks such as useDropdownStyles_unstable,
9
+ * before being passed to renderDropdown_unstable.
10
+ *
11
+ * @param props - props from this instance of Dropdown
12
+ * @param ref - reference to root HTMLElement of Dropdown
13
+ */
14
+ var useDropdown_unstable = function (props, ref) {
15
+ var _a, _b;
16
+ var baseState = useComboboxBaseState_1.useComboboxBaseState(props);
17
+ var activeOption = baseState.activeOption, getIndexOfId = baseState.getIndexOfId, getOptionsMatchingText = baseState.getOptionsMatchingText, open = baseState.open, setActiveOption = baseState.setActiveOption, setFocusVisible = baseState.setFocusVisible, setOpen = baseState.setOpen;
18
+ var _c = react_utilities_1.getPartitionedNativeProps({
19
+ props: props,
20
+ primarySlotTagName: 'button',
21
+ excludedPropNames: ['children'],
22
+ }), triggerNativeProps = _c.primary, rootNativeProps = _c.root;
23
+ // set listbox popup width based off the root/trigger width
24
+ var rootRef = React.useRef(null);
25
+ var _d = React.useState(), popupWidth = _d[0], setPopupWidth = _d[1];
26
+ React.useEffect(function () {
27
+ var _a;
28
+ var width = open ? ((_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) + "px" : undefined;
29
+ setPopupWidth(width);
30
+ }, [open]);
31
+ // jump to matching option based on typing
32
+ var searchString = React.useRef('');
33
+ var _e = react_utilities_1.useTimeout(), setKeyTimeout = _e[0], clearKeyTimeout = _e[1];
34
+ var getNextMatchingOption = function () {
35
+ var _a;
36
+ // first check for matches for the full searchString
37
+ var matcher = function (optionValue) { return optionValue.toLowerCase().indexOf(searchString.current) === 0; };
38
+ var matches = getOptionsMatchingText(matcher);
39
+ var startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
40
+ // if the dropdown is already open and the searchstring is a single character,
41
+ // then look after the current activeOption for letters
42
+ // this is so slowly typing the same letter will cycle through matches
43
+ if (open && searchString.current.length === 1) {
44
+ startIndex++;
45
+ }
46
+ // if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
47
+ if (!matches.length) {
48
+ var letters_1 = searchString.current.split('');
49
+ var allSameLetter = letters_1.length && letters_1.every(function (letter) { return letter === letters_1[0]; });
50
+ // if the search is all the same letter, cycle through options starting with that letter
51
+ if (allSameLetter) {
52
+ startIndex++;
53
+ matcher = function (optionValue) { return optionValue.toLowerCase().indexOf(letters_1[0]) === 0; };
54
+ matches = getOptionsMatchingText(matcher);
55
+ }
56
+ }
57
+ // if there is an active option and multiple matches,
58
+ // return first matching option after the current active option, looping back to the top
59
+ if (matches.length > 1 && activeOption) {
60
+ var nextMatch = matches.find(function (option) { return getIndexOfId(option.id) >= startIndex; });
61
+ return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
62
+ }
63
+ return (_a = matches[0]) !== null && _a !== void 0 ? _a : undefined;
64
+ };
65
+ var onTriggerKeyDown = function (ev) {
66
+ // clear timeout, if it exists
67
+ clearKeyTimeout();
68
+ // if the key was a char key, update search string
69
+ if (dropdownKeyActions_1.getDropdownActionFromKey(ev) === 'Type') {
70
+ // update search string
71
+ searchString.current += ev.key.toLowerCase();
72
+ setKeyTimeout(function () {
73
+ searchString.current = '';
74
+ }, 500);
75
+ // update state
76
+ !open && setOpen(ev, true);
77
+ var nextOption = getNextMatchingOption();
78
+ setActiveOption(nextOption);
79
+ setFocusVisible(true);
80
+ }
81
+ };
82
+ // resolve button and listbox slot props
83
+ var triggerSlot;
84
+ var listboxSlot;
85
+ triggerSlot = react_utilities_1.resolveShorthand(props.button, {
86
+ required: true,
87
+ defaultProps: tslib_1.__assign({ type: 'button', children: baseState.value || props.placeholder }, triggerNativeProps),
88
+ });
89
+ triggerSlot.onKeyDown = react_utilities_1.mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);
90
+ listboxSlot =
91
+ baseState.open || baseState.hasFocus
92
+ ? react_utilities_1.resolveShorthand(props.listbox, {
93
+ required: true,
94
+ defaultProps: {
95
+ children: props.children,
96
+ style: { width: popupWidth },
97
+ },
98
+ })
99
+ : undefined;
100
+ _a = useComboboxPopup_1.useComboboxPopup(props, triggerSlot, listboxSlot), triggerSlot = _a[0], listboxSlot = _a[1];
101
+ _b = useTriggerListboxSlots_1.useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot), triggerSlot = _b[0], listboxSlot = _b[1];
102
+ var state = tslib_1.__assign({ components: {
103
+ root: 'div',
104
+ button: 'button',
105
+ expandIcon: 'span',
106
+ listbox: Listbox_1.Listbox,
107
+ }, root: react_utilities_1.resolveShorthand(props.root, {
108
+ required: true,
109
+ defaultProps: tslib_1.__assign({ 'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined, children: props.children }, rootNativeProps),
110
+ }), button: triggerSlot, listbox: listboxSlot, expandIcon: react_utilities_1.resolveShorthand(props.expandIcon, {
111
+ required: true,
112
+ defaultProps: {
113
+ children: React.createElement(react_icons_1.ChevronDownRegular, null),
114
+ },
115
+ }), placeholderVisible: !baseState.value && !!props.placeholder }, baseState);
116
+ state.root.ref = react_utilities_2.useMergedRefs(state.root.ref, rootRef);
117
+ return state;
118
+ };
119
+ exports.useDropdown_unstable = useDropdown_unstable;
120
+ });
121
+ //# sourceMappingURL=useDropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDropdown.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Dropdown/useDropdown.tsx"],"names":[],"mappings":";;;;IAaA;;;;;;;;OAQG;IACI,IAAM,oBAAoB,GAAG,UAAC,KAAoB,EAAE,GAAiC;;QAC1F,IAAM,SAAS,GAAG,2CAAoB,CAAC,KAAK,CAAC,CAAC;QAE5C,IAAA,YAAY,GAOV,SAAS,aAPC,EACZ,YAAY,GAMV,SAAS,aANC,EACZ,sBAAsB,GAKpB,SAAS,uBALW,EACtB,IAAI,GAIF,SAAS,KAJP,EACJ,eAAe,GAGb,SAAS,gBAHI,EACf,eAAe,GAEb,SAAS,gBAFI,EACf,OAAO,GACL,SAAS,QADJ,CACK;QAER,IAAA,KAAyD,2CAAyB,CAAC;YACvF,KAAK,OAAA;YACL,kBAAkB,EAAE,QAAQ;YAC5B,iBAAiB,EAAE,CAAC,UAAU,CAAC;SAChC,CAAC,EAJe,kBAAkB,aAAA,EAAQ,eAAe,UAIxD,CAAC;QAEH,2DAA2D;QAC3D,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC7C,IAAA,KAA8B,KAAK,CAAC,QAAQ,EAAU,EAArD,UAAU,QAAA,EAAE,aAAa,QAA4B,CAAC;QAC7D,KAAK,CAAC,SAAS,CAAC;;YACd,IAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAG,MAAA,OAAO,CAAC,OAAO,0CAAE,WAAW,QAAI,CAAC,CAAC,CAAC,SAAS,CAAC;YACrE,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QAEX,0CAA0C;QAC1C,IAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChC,IAAA,KAAmC,4BAAU,EAAE,EAA9C,aAAa,QAAA,EAAE,e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AAK,CAAC,WAAW,IACxD,SAAS,CACb,CAAC;QAEF,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,+BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAExD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAlJW,QAAA,oBAAoB,wBAkJ/B","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 {\n activeOption,\n getIndexOfId,\n getOptionsMatchingText,\n open,\n setActiveOption,\n setFocusVisible,\n 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 = (optionValue: string) => optionValue.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 = (optionValue: string) => optionValue.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"]}
@@ -0,0 +1,127 @@
1
+ define(["require", "exports", "tslib", "@fluentui/react-theme", "@griffel/react", "../../utils/internalTokens"], function (require, exports, tslib_1, react_theme_1, react_1, internalTokens_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useDropdownStyles_unstable = exports.dropdownClassNames = void 0;
5
+ exports.dropdownClassNames = {
6
+ root: 'fui-Dropdown',
7
+ button: 'fui-Dropdown__button',
8
+ expandIcon: 'fui-Dropdown__expandIcon',
9
+ listbox: 'fui-Dropdown__listbox',
10
+ };
11
+ /**
12
+ * Styles for Dropdown
13
+ */
14
+ var useStyles = react_1.makeStyles({
15
+ root: tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusMedium)), { boxSizing: 'border-box', display: 'inline-block', minWidth: '250px', position: 'relative',
16
+ // windows high contrast mode focus indicator
17
+ ':focus-within': {
18
+ outlineWidth: '2px',
19
+ outlineStyle: 'solid',
20
+ outlineColor: 'transparent',
21
+ },
22
+ // bottom focus border, shared with Input, Select, and SpinButton
23
+ '::after': tslib_1.__assign(tslib_1.__assign({ boxSizing: 'border-box', content: '""', position: 'absolute', left: '-1px', bottom: '-1px', right: '-1px', height: "max(" + react_theme_1.tokens.strokeWidthThick + ", " + react_theme_1.tokens.borderRadiusMedium + ")", borderBottomLeftRadius: react_theme_1.tokens.borderRadiusMedium, borderBottomRightRadius: react_theme_1.tokens.borderRadiusMedium }, react_1.shorthands.borderBottom(react_theme_1.tokens.strokeWidthThick, 'solid', react_theme_1.tokens.colorCompoundBrandStroke)), { clipPath: 'inset(calc(100% - 2px) 0 0 0)', transform: 'scaleX(0)', transitionProperty: 'transform', transitionDuration: react_theme_1.tokens.durationUltraFast, transitionDelay: react_theme_1.tokens.curveAccelerateMid, '@media screen and (prefers-reduced-motion: reduce)': {
24
+ transitionDuration: '0.01ms',
25
+ transitionDelay: '0.01ms',
26
+ } }), ':focus-within::after': {
27
+ transform: 'scaleX(1)',
28
+ transitionProperty: 'transform',
29
+ transitionDuration: react_theme_1.tokens.durationNormal,
30
+ transitionDelay: react_theme_1.tokens.curveDecelerateMid,
31
+ '@media screen and (prefers-reduced-motion: reduce)': {
32
+ transitionDuration: '0.01ms',
33
+ transitionDelay: '0.01ms',
34
+ },
35
+ }, ':focus-within:active::after': {
36
+ borderBottomColor: react_theme_1.tokens.colorCompoundBrandStrokePressed,
37
+ } }),
38
+ listbox: tslib_1.__assign(tslib_1.__assign({ boxShadow: "" + react_theme_1.tokens.shadow16 }, react_1.shorthands.borderRadius(react_theme_1.tokens.borderRadiusMedium)), { maxHeight: '80vh' }),
39
+ listboxCollapsed: {
40
+ display: 'none',
41
+ },
42
+ button: tslib_1.__assign(tslib_1.__assign({ alignItems: 'center', backgroundColor: react_theme_1.tokens.colorTransparentBackground }, react_1.shorthands.border('0')), { boxSizing: 'border-box', color: react_theme_1.tokens.colorNeutralForeground1, columnGap: react_theme_1.tokens.spacingHorizontalXXS, cursor: 'pointer', display: 'grid', fontFamily: react_theme_1.tokens.fontFamilyBase, gridTemplateColumns: '[content] 1fr [icon] auto [end]', justifyContent: 'space-between', textAlign: 'left', width: '100%', '&:focus': {
43
+ outlineStyle: 'none',
44
+ } }),
45
+ placeholder: {
46
+ color: react_theme_1.tokens.colorNeutralForeground4,
47
+ },
48
+ // size variants
49
+ small: tslib_1.__assign(tslib_1.__assign({}, react_theme_1.typographyStyles.caption1), react_1.shorthands.padding('3px', react_theme_1.tokens.spacingHorizontalSNudge, '3px', "calc(" + react_theme_1.tokens.spacingHorizontalSNudge + " + " + react_theme_1.tokens.spacingHorizontalXXS + ")")),
50
+ medium: tslib_1.__assign(tslib_1.__assign({}, react_theme_1.typographyStyles.body1), react_1.shorthands.padding('5px', react_theme_1.tokens.spacingHorizontalMNudge, '5px', "calc(" + react_theme_1.tokens.spacingHorizontalMNudge + " + " + react_theme_1.tokens.spacingHorizontalXXS + ")")),
51
+ large: tslib_1.__assign(tslib_1.__assign({ columnGap: react_theme_1.tokens.spacingHorizontalSNudge }, react_theme_1.typographyStyles.body2), react_1.shorthands.padding('7px', react_theme_1.tokens.spacingHorizontalM, '7px', "calc(" + react_theme_1.tokens.spacingHorizontalM + " + " + react_theme_1.tokens.spacingHorizontalSNudge + ")")),
52
+ // appearance variants
53
+ outline: tslib_1.__assign(tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorNeutralBackground1 }, react_1.shorthands.border(react_theme_1.tokens.strokeWidthThin, 'solid', react_theme_1.tokens.colorNeutralStroke1)), { borderBottomColor: react_theme_1.tokens.colorNeutralStrokeAccessible }),
54
+ outlineInteractive: {
55
+ '&:hover': tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorNeutralStroke1Hover)), { borderBottomColor: react_theme_1.tokens.colorNeutralStrokeAccessible }),
56
+ '&:active': tslib_1.__assign(tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorNeutralStroke1Pressed)), { borderBottomColor: react_theme_1.tokens.colorNeutralStrokeAccessible }),
57
+ },
58
+ underline: tslib_1.__assign(tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorTransparentBackground }, react_1.shorthands.borderBottom(react_theme_1.tokens.strokeWidthThin, 'solid', react_theme_1.tokens.colorNeutralStrokeAccessible)), react_1.shorthands.borderRadius(0)),
59
+ 'filled-lighter': tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorNeutralBackground1 }, react_1.shorthands.border(react_theme_1.tokens.strokeWidthThin, 'solid', 'transparent')),
60
+ 'filled-darker': tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorNeutralBackground3 }, react_1.shorthands.border(react_theme_1.tokens.strokeWidthThin, 'solid', 'transparent')),
61
+ invalid: {
62
+ ':not(:focus-within),:hover:not(:focus-within)': tslib_1.__assign({}, react_1.shorthands.borderColor(react_theme_1.tokens.colorPaletteRedBorder2)),
63
+ },
64
+ invalidUnderline: {
65
+ ':not(:focus-within),:hover:not(:focus-within)': {
66
+ borderBottomColor: react_theme_1.tokens.colorPaletteRedBorder2,
67
+ },
68
+ },
69
+ disabled: tslib_1.__assign(tslib_1.__assign({ cursor: 'not-allowed', backgroundColor: react_theme_1.tokens.colorTransparentBackground }, react_1.shorthands.borderColor(react_theme_1.tokens.colorNeutralStrokeDisabled)), { '@media (forced-colors: active)': tslib_1.__assign({}, react_1.shorthands.borderColor('GrayText')) }),
70
+ disabledText: {
71
+ color: react_theme_1.tokens.colorNeutralForegroundDisabled,
72
+ cursor: 'not-allowed',
73
+ },
74
+ });
75
+ var useIconStyles = react_1.makeStyles({
76
+ icon: {
77
+ boxSizing: 'border-box',
78
+ color: react_theme_1.tokens.colorNeutralStrokeAccessible,
79
+ display: 'block',
80
+ fontSize: react_theme_1.tokens.fontSizeBase500,
81
+ gridColumnStart: 'icon',
82
+ gridColumnEnd: 'end',
83
+ // the SVG must have display: block for accurate positioning
84
+ // otherwise an extra inline space is inserted after the svg element
85
+ '& svg': {
86
+ display: 'block',
87
+ },
88
+ },
89
+ // icon size variants
90
+ small: {
91
+ fontSize: internalTokens_1.iconSizes.small,
92
+ marginLeft: react_theme_1.tokens.spacingHorizontalXXS,
93
+ },
94
+ medium: {
95
+ fontSize: internalTokens_1.iconSizes.medium,
96
+ marginLeft: react_theme_1.tokens.spacingHorizontalXXS,
97
+ },
98
+ large: {
99
+ fontSize: internalTokens_1.iconSizes.large,
100
+ marginLeft: react_theme_1.tokens.spacingHorizontalSNudge,
101
+ },
102
+ disabled: {
103
+ color: react_theme_1.tokens.colorNeutralForegroundDisabled,
104
+ },
105
+ });
106
+ /**
107
+ * Apply styling to the Dropdown slots based on the state
108
+ */
109
+ var useDropdownStyles_unstable = function (state) {
110
+ var appearance = state.appearance, open = state.open, placeholderVisible = state.placeholderVisible, size = state.size;
111
+ var invalid = "" + state.button['aria-invalid'] === 'true';
112
+ var disabled = state.button.disabled;
113
+ var styles = useStyles();
114
+ var iconStyles = useIconStyles();
115
+ state.root.className = react_1.mergeClasses(exports.dropdownClassNames.root, styles.root, styles[appearance], !disabled && appearance === 'outline' && styles.outlineInteractive, invalid && appearance !== 'underline' && styles.invalid, invalid && appearance === 'underline' && styles.invalidUnderline, disabled && styles.disabled, state.root.className);
116
+ state.button.className = react_1.mergeClasses(exports.dropdownClassNames.button, styles.button, styles[size], placeholderVisible && styles.placeholder, disabled && styles.disabledText, state.button.className);
117
+ if (state.listbox) {
118
+ state.listbox.className = react_1.mergeClasses(exports.dropdownClassNames.listbox, styles.listbox, !open && styles.listboxCollapsed, state.listbox.className);
119
+ }
120
+ if (state.expandIcon) {
121
+ state.expandIcon.className = react_1.mergeClasses(exports.dropdownClassNames.expandIcon, iconStyles.icon, iconStyles[size], disabled && iconStyles.disabled, state.expandIcon.className);
122
+ }
123
+ return state;
124
+ };
125
+ exports.useDropdownStyles_unstable = useDropdownStyles_unstable;
126
+ });
127
+ //# sourceMappingURL=useDropdownStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDropdownStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Dropdown/useDropdownStyles.ts"],"names":[],"mappings":";;;;IAMa,QAAA,kBAAkB,GAAkC;QAC/D,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,sBAAsB;QAC9B,UAAU,EAAE,0BAA0B;QACtC,OAAO,EAAE,uBAAuB;KACjC,CAAC;IAEF;;OAEG;IACH,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,wCACC,kBAAU,CAAC,YAAY,CAAC,oBAAM,CAAC,kBAAkB,CAAC,KACrD,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,UAAU;YAEpB,6CAA6C;YAC7C,eAAe,EAAE;gBACf,YAAY,EAAE,KAAK;gBACnB,YAAY,EAAE,OAAO;gBACrB,YAAY,EAAE,aAAa;aAC5B;YAED,iEAAiE;YACjE,SAAS,sCACP,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,IAAI,EACb,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAO,oBAAM,CAAC,gBAAgB,UAAK,oBAAM,CAAC,kBAAkB,MAAG,EACvE,sBAAsB,EAAE,oBAAM,CAAC,kBAAkB,EACjD,uBAAuB,EAAE,oBAAM,CAAC,kBAAkB,IAC/C,kBAAU,CAAC,YAAY,CAAC,oBAAM,CAAC,gBAAgB,EAAE,OAAO,EAAE,oBAAM,CAAC,wBAAwB,CAAC,KAC7F,QAAQ,EAAE,+BAA+B,EACzC,SAAS,EAAE,WAAW,EACtB,kBAAkB,EAAE,WAAW,EAC/B,kBAAkB,EAAE,oBAAM,CAAC,iBAAiB,EAC5C,eAAe,EAAE,oBAAM,C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kB,IAAI,MAAM,CAAC,WAAW,EACxC,QAAQ,IAAI,MAAM,CAAC,YAAY,EAC/B,KAAK,CAAC,MAAM,CAAC,SAAS,CACvB,CAAC;QAEF,IAAI,KAAK,CAAC,OAAO,EAAE;YACjB,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,oBAAY,CACpC,0BAAkB,CAAC,OAAO,EAC1B,MAAM,CAAC,OAAO,EACd,CAAC,IAAI,IAAI,MAAM,CAAC,gBAAgB,EAChC,KAAK,CAAC,OAAO,CAAC,SAAS,CACxB,CAAC;SACH;QAED,IAAI,KAAK,CAAC,UAAU,EAAE;YACpB,KAAK,CAAC,UAAU,CAAC,SAAS,GAAG,oBAAY,CACvC,0BAAkB,CAAC,UAAU,EAC7B,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,IAAI,CAAC,EAChB,QAAQ,IAAI,UAAU,CAAC,QAAQ,EAC/B,KAAK,CAAC,UAAU,CAAC,SAAS,CAC3B,CAAC;SACH;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IA/CW,QAAA,0BAA0B,8BA+CrC","sourcesContent":["import { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { iconSizes } from '../../utils/internalTokens';\nimport type { DropdownSlots, DropdownState } from './Dropdown.types';\n\nexport const dropdownClassNames: SlotClassNames<DropdownSlots> = {\n root: 'fui-Dropdown',\n button: 'fui-Dropdown__button',\n expandIcon: 'fui-Dropdown__expandIcon',\n listbox: 'fui-Dropdown__listbox',\n};\n\n/**\n * Styles for Dropdown\n */\nconst useStyles = makeStyles({\n root: {\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n boxSizing: 'border-box',\n display: 'inline-block',\n minWidth: '250px',\n position: 'relative',\n\n // windows high contrast mode focus indicator\n ':focus-within': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: 'transparent',\n },\n\n // bottom focus border, shared with Input, Select, and SpinButton\n '::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n left: '-1px',\n bottom: '-1px',\n right: '-1px',\n height: `max(${tokens.strokeWidthThick}, ${tokens.borderRadiusMedium})`,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderBottomRightRadius: tokens.borderRadiusMedium,\n ...shorthands.borderBottom(tokens.strokeWidthThick, 'solid', tokens.colorCompoundBrandStroke),\n clipPath: 'inset(calc(100% - 2px) 0 0 0)',\n transform: 'scaleX(0)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationUltraFast,\n transitionDelay: tokens.curveAccelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within::after': {\n transform: 'scaleX(1)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationNormal,\n transitionDelay: tokens.curveDecelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within:active::after': {\n borderBottomColor: tokens.colorCompoundBrandStrokePressed,\n },\n },\n\n listbox: {\n boxShadow: `${tokens.shadow16}`,\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n maxHeight: '80vh',\n },\n\n listboxCollapsed: {\n display: 'none',\n },\n\n button: {\n alignItems: 'center',\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.border('0'),\n boxSizing: 'border-box',\n color: tokens.colorNeutralForeground1,\n columnGap: tokens.spacingHorizontalXXS,\n cursor: 'pointer',\n display: 'grid',\n fontFamily: tokens.fontFamilyBase,\n gridTemplateColumns: '[content] 1fr [icon] auto [end]',\n justifyContent: 'space-between',\n textAlign: 'left',\n width: '100%',\n\n '&:focus': {\n outlineStyle: 'none',\n },\n },\n\n placeholder: {\n color: tokens.colorNeutralForeground4,\n },\n\n // size variants\n small: {\n ...typographyStyles.caption1,\n ...shorthands.padding(\n '3px',\n tokens.spacingHorizontalSNudge,\n '3px',\n `calc(${tokens.spacingHorizontalSNudge} + ${tokens.spacingHorizontalXXS})`,\n ),\n },\n medium: {\n ...typographyStyles.body1,\n ...shorthands.padding(\n '5px',\n tokens.spacingHorizontalMNudge,\n '5px',\n `calc(${tokens.spacingHorizontalMNudge} + ${tokens.spacingHorizontalXXS})`,\n ),\n },\n large: {\n columnGap: tokens.spacingHorizontalSNudge,\n ...typographyStyles.body2,\n ...shorthands.padding(\n '7px',\n tokens.spacingHorizontalM,\n '7px',\n `calc(${tokens.spacingHorizontalM} + ${tokens.spacingHorizontalSNudge})`,\n ),\n },\n\n // appearance variants\n outline: {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke1),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n outlineInteractive: {\n '&:hover': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Hover),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n '&:active': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n },\n underline: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStrokeAccessible),\n ...shorthands.borderRadius(0),\n },\n 'filled-lighter': {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', 'transparent'),\n },\n 'filled-darker': {\n backgroundColor: tokens.colorNeutralBackground3,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', 'transparent'),\n },\n invalid: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n ...shorthands.borderColor(tokens.colorPaletteRedBorder2),\n },\n },\n invalidUnderline: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n borderBottomColor: tokens.colorPaletteRedBorder2,\n },\n },\n disabled: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n '@media (forced-colors: active)': {\n ...shorthands.borderColor('GrayText'),\n },\n },\n\n disabledText: {\n color: tokens.colorNeutralForegroundDisabled,\n cursor: 'not-allowed',\n },\n});\n\nconst useIconStyles = makeStyles({\n icon: {\n boxSizing: 'border-box',\n color: tokens.colorNeutralStrokeAccessible,\n display: 'block',\n fontSize: tokens.fontSizeBase500,\n gridColumnStart: 'icon',\n gridColumnEnd: 'end',\n\n // the SVG must have display: block for accurate positioning\n // otherwise an extra inline space is inserted after the svg element\n '& svg': {\n display: 'block',\n },\n },\n\n // icon size variants\n small: {\n fontSize: iconSizes.small,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n medium: {\n fontSize: iconSizes.medium,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n large: {\n fontSize: iconSizes.large,\n marginLeft: tokens.spacingHorizontalSNudge,\n },\n\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n\n/**\n * Apply styling to the Dropdown slots based on the state\n */\nexport const useDropdownStyles_unstable = (state: DropdownState): DropdownState => {\n const { appearance, open, placeholderVisible, size } = state;\n const invalid = `${state.button['aria-invalid']}` === 'true';\n const disabled = state.button.disabled;\n const styles = useStyles();\n const iconStyles = useIconStyles();\n\n state.root.className = mergeClasses(\n dropdownClassNames.root,\n styles.root,\n styles[appearance],\n !disabled && appearance === 'outline' && styles.outlineInteractive,\n invalid && appearance !== 'underline' && styles.invalid,\n invalid && appearance === 'underline' && styles.invalidUnderline,\n disabled && styles.disabled,\n state.root.className,\n );\n\n state.button.className = mergeClasses(\n dropdownClassNames.button,\n styles.button,\n styles[size],\n placeholderVisible && styles.placeholder,\n disabled && styles.disabledText,\n state.button.className,\n );\n\n if (state.listbox) {\n state.listbox.className = mergeClasses(\n dropdownClassNames.listbox,\n styles.listbox,\n !open && styles.listboxCollapsed,\n state.listbox.className,\n );\n }\n\n if (state.expandIcon) {\n state.expandIcon.className = mergeClasses(\n dropdownClassNames.expandIcon,\n iconStyles.icon,\n iconStyles[size],\n disabled && iconStyles.disabled,\n state.expandIcon.className,\n );\n }\n\n return state;\n};\n"]}
@@ -0,0 +1,16 @@
1
+ define(["require", "exports", "react", "./useListbox", "./renderListbox", "./useListboxStyles", "../../contexts/useListboxContextValues"], function (require, exports, React, useListbox_1, renderListbox_1, useListboxStyles_1, useListboxContextValues_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Listbox = void 0;
5
+ /**
6
+ * Listbox component: a standalone selection control, or the popup in a Combobox
7
+ */
8
+ exports.Listbox = React.forwardRef(function (props, ref) {
9
+ var state = useListbox_1.useListbox_unstable(props, ref);
10
+ var contextValues = useListboxContextValues_1.useListboxContextValues(state);
11
+ useListboxStyles_1.useListboxStyles_unstable(state);
12
+ return renderListbox_1.renderListbox_unstable(state, contextValues);
13
+ });
14
+ exports.Listbox.displayName = 'Listbox';
15
+ });
16
+ //# sourceMappingURL=Listbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Listbox.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Listbox/Listbox.tsx"],"names":[],"mappings":";;;;IAQA;;OAEG;IACU,QAAA,OAAO,GAAsC,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QACpF,IAAM,KAAK,GAAG,gCAAmB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9C,IAAM,aAAa,GAAG,iDAAuB,CAAC,KAAK,CAAC,CAAC;QAErD,4CAAyB,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,sCAAsB,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,eAAO,CAAC,WAAW,GAAG,SAAS,CAAC","sourcesContent":["import * as React from 'react';\nimport { useListbox_unstable } from './useListbox';\nimport { renderListbox_unstable } from './renderListbox';\nimport { useListboxStyles_unstable } from './useListboxStyles';\nimport type { ListboxProps } from './Listbox.types';\nimport { useListboxContextValues } from '../../contexts/useListboxContextValues';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Listbox component: a standalone selection control, or the popup in a Combobox\n */\nexport const Listbox: ForwardRefComponent<ListboxProps> = React.forwardRef((props, ref) => {\n const state = useListbox_unstable(props, ref);\n const contextValues = useListboxContextValues(state);\n\n useListboxStyles_unstable(state);\n return renderListbox_unstable(state, contextValues);\n});\n\nListbox.displayName = 'Listbox';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=Listbox.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Listbox.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Listbox/Listbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { OptionValue, OptionCollectionState } from '../../utils/OptionCollection.types';\nimport { SelectionEvents, SelectionProps, SelectionState } from '../../utils/Selection.types';\nimport type { ListboxContextValue } from '../../contexts/ListboxContext';\n\nexport type ListboxSlots = {\n /* The root slot, a `<div>` with `role=\"listbox\"` */\n root: Slot<'div'>;\n};\n\n/**\n * Listbox Props\n */\nexport type ListboxProps = ComponentProps<ListboxSlots> & SelectionProps;\n\n/**\n * State used in rendering Listbox\n */\nexport type ListboxState = ComponentState<ListboxSlots> &\n OptionCollectionState &\n Pick<SelectionProps, 'multiselect'> &\n SelectionState & {\n /* Option data for the currently highlighted option (not the selected option) */\n activeOption?: OptionValue;\n\n // Whether the keyboard focus outline style should be visible\n focusVisible: boolean;\n\n selectOption(event: SelectionEvents, option: OptionValue): void;\n\n setActiveOption(option?: OptionValue): void;\n };\n\nexport type ListboxContextValues = {\n listbox: ListboxContextValue;\n};\n"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "tslib", "./Listbox", "./Listbox.types", "./renderListbox", "./useListbox", "./useListboxStyles"], function (require, exports, tslib_1, Listbox_1, Listbox_types_1, renderListbox_1, useListbox_1, useListboxStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(Listbox_1, exports);
5
+ tslib_1.__exportStar(Listbox_types_1, exports);
6
+ tslib_1.__exportStar(renderListbox_1, exports);
7
+ tslib_1.__exportStar(useListbox_1, exports);
8
+ tslib_1.__exportStar(useListboxStyles_1, exports);
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Listbox/index.ts"],"names":[],"mappings":";;;IAAA,yCAA0B;IAC1B,+CAAgC;IAChC,+CAAgC;IAChC,4CAA6B;IAC7B,kDAAmC","sourcesContent":["export * from './Listbox';\nexport * from './Listbox.types';\nexport * from './renderListbox';\nexport * from './useListbox';\nexport * from './useListboxStyles';\n"]}
@@ -0,0 +1,15 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "../../contexts/ListboxContext"], function (require, exports, tslib_1, React, react_utilities_1, ListboxContext_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderListbox_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of Listbox
7
+ */
8
+ var renderListbox_unstable = function (state, contextValues) {
9
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
+ return (React.createElement(ListboxContext_1.ListboxContext.Provider, { value: contextValues.listbox },
11
+ React.createElement(slots.root, tslib_1.__assign({}, slotProps.root))));
12
+ };
13
+ exports.renderListbox_unstable = renderListbox_unstable;
14
+ });
15
+ //# sourceMappingURL=renderListbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderListbox.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Listbox/renderListbox.tsx"],"names":[],"mappings":";;;;IAKA;;OAEG;IACI,IAAM,sBAAsB,GAAG,UAAC,KAAmB,EAAE,aAAmC;QACvF,IAAA,KAAuB,0BAAQ,CAAe,KAAK,CAAC,EAAlD,KAAK,WAAA,EAAE,SAAS,eAAkC,CAAC;QAE3D,OAAO,CACL,oBAAC,+BAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,CAAC,OAAO;YACnD,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI,EAAI,CACV,CAC3B,CAAC;IACJ,CAAC,CAAC;IARW,QAAA,sBAAsB,0BAQjC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { ListboxContextValues, ListboxState, ListboxSlots } from './Listbox.types';\nimport { ListboxContext } from '../../contexts/ListboxContext';\n\n/**\n * Render the final JSX of Listbox\n */\nexport const renderListbox_unstable = (state: ListboxState, contextValues: ListboxContextValues) => {\n const { slots, slotProps } = getSlots<ListboxSlots>(state);\n\n return (\n <ListboxContext.Provider value={contextValues.listbox}>\n <slots.root {...slotProps.root} />\n </ListboxContext.Provider>\n );\n};\n"]}
@@ -0,0 +1,80 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities", "@fluentui/react-context-selector", "../../utils/dropdownKeyActions", "../../utils/useOptionCollection", "../../utils/useScrollOptionsIntoView", "../../utils/useSelection", "../../contexts/ComboboxContext"], function (require, exports, tslib_1, React, react_utilities_1, react_context_selector_1, dropdownKeyActions_1, useOptionCollection_1, useScrollOptionsIntoView_1, useSelection_1, ComboboxContext_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useListbox_unstable = void 0;
5
+ /**
6
+ * Create the state required to render Listbox.
7
+ *
8
+ * The returned state can be modified with hooks such as useListboxStyles_unstable,
9
+ * before being passed to renderListbox_unstable.
10
+ *
11
+ * @param props - props from this instance of Listbox
12
+ * @param ref - reference to root HTMLElement of Listbox
13
+ */
14
+ var useListbox_unstable = function (props, ref) {
15
+ var multiselect = props.multiselect;
16
+ var optionCollection = useOptionCollection_1.useOptionCollection();
17
+ var getCount = optionCollection.getCount, getOptionAtIndex = optionCollection.getOptionAtIndex, getIndexOfId = optionCollection.getIndexOfId;
18
+ var _a = useSelection_1.useSelection(props), clearSelection = _a.clearSelection, selectedOptions = _a.selectedOptions, selectOption = _a.selectOption;
19
+ var _b = React.useState(), activeOption = _b[0], setActiveOption = _b[1];
20
+ // track whether keyboard focus outline should be shown
21
+ // tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move
22
+ var _c = React.useState(false), focusVisible = _c[0], setFocusVisible = _c[1];
23
+ var onKeyDown = function (event) {
24
+ var action = dropdownKeyActions_1.getDropdownActionFromKey(event, { open: true });
25
+ var maxIndex = getCount() - 1;
26
+ var activeIndex = activeOption ? getIndexOfId(activeOption.id) : -1;
27
+ var newIndex = activeIndex;
28
+ switch (action) {
29
+ case 'Select':
30
+ case 'CloseSelect':
31
+ activeOption && selectOption(event, activeOption);
32
+ break;
33
+ default:
34
+ newIndex = dropdownKeyActions_1.getIndexFromAction(action, activeIndex, maxIndex);
35
+ }
36
+ if (newIndex !== activeIndex) {
37
+ // prevent default page scroll/keyboard action if the index changed
38
+ event.preventDefault();
39
+ setActiveOption(getOptionAtIndex(newIndex));
40
+ setFocusVisible(true);
41
+ }
42
+ };
43
+ var onMouseOver = function (event) {
44
+ setFocusVisible(false);
45
+ };
46
+ // get state from parent combobox, if it exists
47
+ var hasComboboxContext = react_context_selector_1.useHasParentContext(ComboboxContext_1.ComboboxContext);
48
+ var comboboxActiveOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, function (ctx) { return ctx.activeOption; });
49
+ var comboboxFocusVisible = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, function (ctx) { return ctx.focusVisible; });
50
+ var comboboxSelectedOptions = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, function (ctx) { return ctx.selectedOptions; });
51
+ var comboboxSelectOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, function (ctx) { return ctx.selectOption; });
52
+ var comboboxSetActiveOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, function (ctx) { return ctx.setActiveOption; });
53
+ // without a parent combobox context, provide values directly from Listbox
54
+ var optionContextValues = hasComboboxContext
55
+ ? {
56
+ activeOption: comboboxActiveOption,
57
+ focusVisible: comboboxFocusVisible,
58
+ selectedOptions: comboboxSelectedOptions,
59
+ selectOption: comboboxSelectOption,
60
+ setActiveOption: comboboxSetActiveOption,
61
+ }
62
+ : {
63
+ activeOption: activeOption,
64
+ focusVisible: focusVisible,
65
+ selectedOptions: selectedOptions,
66
+ selectOption: selectOption,
67
+ setActiveOption: setActiveOption,
68
+ };
69
+ var state = tslib_1.__assign(tslib_1.__assign({ components: {
70
+ root: 'div',
71
+ }, root: react_utilities_1.getNativeElementProps('div', tslib_1.__assign({ ref: ref, role: multiselect ? 'menu' : 'listbox', 'aria-activedescendant': hasComboboxContext ? undefined : activeOption === null || activeOption === void 0 ? void 0 : activeOption.id, 'aria-multiselectable': multiselect, tabIndex: 0 }, props)), multiselect: multiselect, clearSelection: clearSelection }, optionCollection), optionContextValues);
72
+ var scrollContainerRef = useScrollOptionsIntoView_1.useScrollOptionsIntoView(state);
73
+ state.root.ref = react_utilities_1.useMergedRefs(state.root.ref, scrollContainerRef);
74
+ state.root.onKeyDown = react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(state.root.onKeyDown, onKeyDown));
75
+ state.root.onMouseOver = react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(state.root.onMouseOver, onMouseOver));
76
+ return state;
77
+ };
78
+ exports.useListbox_unstable = useListbox_unstable;
79
+ });
80
+ //# sourceMappingURL=useListbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useListbox.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Listbox/use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gBACZ,YAAY,cAAA;gBACZ,eAAe,iBAAA;gBACf,YAAY,cAAA;gBACZ,eAAe,iBAAA;aAChB,CAAC;QAEN,IAAM,KAAK,uCACT,UAAU,EAAE;gBACV,IAAI,EAAE,KAAK;aACZ,EACD,IAAI,EAAE,uCAAqB,CAAC,KAAK,qBAC/B,GAAG,KAAA,EACH,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EACtC,uBAAuB,EAAE,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,EAAE,EAC1E,sBAAsB,EAAE,WAAW,EACnC,QAAQ,EAAE,CAAC,IACR,KAAK,EACR,EACF,WAAW,aAAA,EACX,cAAc,gBAAA,IACX,gBAAgB,GAChB,mBAAmB,CACvB,CAAC;QAEF,IAAM,kBAAkB,GAAG,mDAAwB,CAAC,KAAK,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,+BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;QAEnE,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,kCAAgB,CAAC,gCAAc,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;QACzF,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,kCAAgB,CAAC,gCAAc,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;QAE/F,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IA1FW,QAAA,mBAAmB,uBA0F9B","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, mergeCallbacks, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { useContextSelector, useHasParentContext } from '@fluentui/react-context-selector';\nimport { getDropdownActionFromKey, getIndexFromAction } from '../../utils/dropdownKeyActions';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport { useOptionCollection } from '../../utils/useOptionCollection';\nimport { useScrollOptionsIntoView } from '../../utils/useScrollOptionsIntoView';\nimport { useSelection } from '../../utils/useSelection';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport type { ListboxProps, ListboxState } from './Listbox.types';\n\n/**\n * Create the state required to render Listbox.\n *\n * The returned state can be modified with hooks such as useListboxStyles_unstable,\n * before being passed to renderListbox_unstable.\n *\n * @param props - props from this instance of Listbox\n * @param ref - reference to root HTMLElement of Listbox\n */\nexport const useListbox_unstable = (props: ListboxProps, ref: React.Ref<HTMLElement>): ListboxState => {\n const { multiselect } = props;\n const optionCollection = useOptionCollection();\n const { getCount, getOptionAtIndex, getIndexOfId } = optionCollection;\n\n const { clearSelection, selectedOptions, selectOption } = useSelection(props);\n\n const [activeOption, setActiveOption] = React.useState<OptionValue | undefined>();\n\n // track whether keyboard focus outline should be shown\n // tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move\n const [focusVisible, setFocusVisible] = React.useState(false);\n\n const onKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n const action = getDropdownActionFromKey(event, { open: true });\n const maxIndex = getCount() - 1;\n const activeIndex = activeOption ? getIndexOfId(activeOption.id) : -1;\n let newIndex = activeIndex;\n\n switch (action) {\n case 'Select':\n case 'CloseSelect':\n activeOption && selectOption(event, activeOption);\n break;\n default:\n newIndex = getIndexFromAction(action, activeIndex, maxIndex);\n }\n\n if (newIndex !== activeIndex) {\n // prevent default page scroll/keyboard action if the index changed\n event.preventDefault();\n setActiveOption(getOptionAtIndex(newIndex));\n setFocusVisible(true);\n }\n };\n\n const onMouseOver = (event: React.MouseEvent<HTMLElement>) => {\n setFocusVisible(false);\n };\n\n // get state from parent combobox, if it exists\n const hasComboboxContext = useHasParentContext(ComboboxContext);\n const comboboxActiveOption = useContextSelector(ComboboxContext, ctx => ctx.activeOption);\n const comboboxFocusVisible = useContextSelector(ComboboxContext, ctx => ctx.focusVisible);\n const comboboxSelectedOptions = useContextSelector(ComboboxContext, ctx => ctx.selectedOptions);\n const comboboxSelectOption = useContextSelector(ComboboxContext, ctx => ctx.selectOption);\n const comboboxSetActiveOption = useContextSelector(ComboboxContext, ctx => ctx.setActiveOption);\n\n // without a parent combobox context, provide values directly from Listbox\n const optionContextValues = hasComboboxContext\n ? {\n activeOption: comboboxActiveOption,\n focusVisible: comboboxFocusVisible,\n selectedOptions: comboboxSelectedOptions,\n selectOption: comboboxSelectOption,\n setActiveOption: comboboxSetActiveOption,\n }\n : {\n activeOption,\n focusVisible,\n selectedOptions,\n selectOption,\n setActiveOption,\n };\n\n const state: ListboxState = {\n components: {\n root: 'div',\n },\n root: getNativeElementProps('div', {\n ref,\n role: multiselect ? 'menu' : 'listbox',\n 'aria-activedescendant': hasComboboxContext ? undefined : activeOption?.id,\n 'aria-multiselectable': multiselect,\n tabIndex: 0,\n ...props,\n }),\n multiselect,\n clearSelection,\n ...optionCollection,\n ...optionContextValues,\n };\n\n const scrollContainerRef = useScrollOptionsIntoView(state);\n state.root.ref = useMergedRefs(state.root.ref, scrollContainerRef);\n\n state.root.onKeyDown = useEventCallback(mergeCallbacks(state.root.onKeyDown, onKeyDown));\n state.root.onMouseOver = useEventCallback(mergeCallbacks(state.root.onMouseOver, onMouseOver));\n\n return state;\n};\n"]}
@@ -0,0 +1,24 @@
1
+ define(["require", "exports", "tslib", "@fluentui/react-theme", "@griffel/react"], function (require, exports, tslib_1, react_theme_1, react_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useListboxStyles_unstable = exports.listboxClassNames = void 0;
5
+ exports.listboxClassNames = {
6
+ root: 'fui-Listbox',
7
+ };
8
+ /**
9
+ * Styles for the root slot
10
+ */
11
+ var useStyles = react_1.makeStyles({
12
+ root: tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({ backgroundColor: react_theme_1.tokens.colorNeutralBackground1, boxSizing: 'border-box', display: 'flex', flexDirection: 'column', minWidth: '160px', overflowY: 'auto' }, react_1.shorthands.outline('1px', 'solid', react_theme_1.tokens.colorTransparentStroke)), react_1.shorthands.padding(react_theme_1.tokens.spacingHorizontalXS)), { rowGap: react_theme_1.tokens.spacingHorizontalXXS }),
13
+ });
14
+ /**
15
+ * Apply styling to the Listbox slots based on the state
16
+ */
17
+ var useListboxStyles_unstable = function (state) {
18
+ var styles = useStyles();
19
+ state.root.className = react_1.mergeClasses(exports.listboxClassNames.root, styles.root, state.root.className);
20
+ return state;
21
+ };
22
+ exports.useListboxStyles_unstable = useListboxStyles_unstable;
23
+ });
24
+ //# sourceMappingURL=useListboxStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useListboxStyles.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Listbox/useListboxStyles.ts"],"names":[],"mappings":";;;;IAKa,QAAA,iBAAiB,GAAiC;QAC7D,IAAI,EAAE,aAAa;KACpB,CAAC;IAEF;;OAEG;IACH,IAAM,SAAS,GAAG,kBAAU,CAAC;QAC3B,IAAI,uDACF,eAAe,EAAE,oBAAM,CAAC,uBAAuB,EAC/C,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,QAAQ,EACvB,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,MAAM,IACd,kBAAU,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,oBAAM,CAAC,sBAAsB,CAAC,GACjE,kBAAU,CAAC,OAAO,CAAC,oBAAM,CAAC,mBAAmB,CAAC,KACjD,MAAM,EAAE,oBAAM,CAAC,oBAAoB,GACpC;KACF,CAAC,CAAC;IAEH;;OAEG;IACI,IAAM,yBAAyB,GAAG,UAAC,KAAmB;QAC3D,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,oBAAY,CAAC,yBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE/F,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IALW,QAAA,yBAAyB,6BAKpC","sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { ListboxSlots, ListboxState } from './Listbox.types';\n\nexport const listboxClassNames: SlotClassNames<ListboxSlots> = {\n root: 'fui-Listbox',\n};\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n backgroundColor: tokens.colorNeutralBackground1,\n boxSizing: 'border-box',\n display: 'flex',\n flexDirection: 'column',\n minWidth: '160px',\n overflowY: 'auto',\n ...shorthands.outline('1px', 'solid', tokens.colorTransparentStroke),\n ...shorthands.padding(tokens.spacingHorizontalXS),\n rowGap: tokens.spacingHorizontalXXS,\n },\n});\n\n/**\n * Apply styling to the Listbox slots based on the state\n */\nexport const useListboxStyles_unstable = (state: ListboxState): ListboxState => {\n const styles = useStyles();\n state.root.className = mergeClasses(listboxClassNames.root, styles.root, state.root.className);\n\n return state;\n};\n"]}
@@ -0,0 +1,15 @@
1
+ define(["require", "exports", "react", "./useOption", "./renderOption", "./useOptionStyles"], function (require, exports, React, useOption_1, renderOption_1, useOptionStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Option = void 0;
5
+ /**
6
+ * Option component: a styled child option of a Combobox
7
+ */
8
+ exports.Option = React.forwardRef(function (props, ref) {
9
+ var state = useOption_1.useOption_unstable(props, ref);
10
+ useOptionStyles_1.useOptionStyles_unstable(state);
11
+ return renderOption_1.renderOption_unstable(state);
12
+ });
13
+ exports.Option.displayName = 'Option';
14
+ });
15
+ //# sourceMappingURL=Option.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Option/Option.tsx"],"names":[],"mappings":";;;;IAOA;;OAEG;IACU,QAAA,MAAM,GAAqC,KAAK,CAAC,UAAU,CAAC,UAAC,KAAK,EAAE,GAAG;QAClF,IAAM,KAAK,GAAG,8BAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE7C,0CAAwB,CAAC,KAAK,CAAC,CAAC;QAChC,OAAO,oCAAqB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,cAAM,CAAC,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["import * as React from 'react';\nimport { useOption_unstable } from './useOption';\nimport { renderOption_unstable } from './renderOption';\nimport { useOptionStyles_unstable } from './useOptionStyles';\nimport type { OptionProps } from './Option.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Option component: a styled child option of a Combobox\n */\nexport const Option: ForwardRefComponent<OptionProps> = React.forwardRef((props, ref) => {\n const state = useOption_unstable(props, ref);\n\n useOptionStyles_unstable(state);\n return renderOption_unstable(state);\n});\n\nOption.displayName = 'Option';\n"]}
@@ -0,0 +1,5 @@
1
+ define(["require", "exports"], function (require, exports) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ });
5
+ //# sourceMappingURL=Option.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Option.types.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Option/Option.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type OptionSlots = {\n /* The root option slot, with role=\"option\" */\n root: NonNullable<Slot<'div'>>;\n\n /* The check icon that is visible for selected options */\n checkIcon: Slot<'span'>;\n};\n\n/**\n * Option Props\n */\nexport type OptionProps = ComponentProps<Partial<OptionSlots>> & {\n /**\n * Sets an option to the `disabled` state.\n * Disabled options cannot be selected, but are still keyboard navigable\n */\n disabled?: boolean;\n\n /*\n * Defines a unique identifier for the option.\n * Use this to control selectedOptions, or to get the option value in the onOptionSelect callback.\n * Defaults to `text` if not provided.\n */\n value?: string;\n} & (\n | {\n /**\n * An optional override the string value of the Option's display text,\n * defaulting to the Option's child content.\n * This is used as the Dropdown button's or Combobox input's value when the option is selected,\n * and as the comparison for type-to-find keyboard functionality.\n */\n text?: string;\n children: string;\n }\n | {\n /**\n * The string value of the Option's display text when the Option's children are not a string.\n * This is used as the Dropdown button's or Combobox input's value when the option is selected,\n * and as the comparison for type-to-find keyboard functionality.\n */\n text: string;\n children?: React.ReactNode;\n }\n );\n\n/**\n * State used in rendering Option\n */\nexport type OptionState = ComponentState<OptionSlots> &\n Pick<OptionProps, 'disabled'> & {\n /* If true, this is the currently highlighted option */\n active: boolean;\n\n // Whether the keyboard focus outline style should be visible\n focusVisible: boolean;\n\n /* If true, the option is part of a multiselect combobox or listbox */\n multiselect?: boolean;\n\n /* If true, the option is selected */\n selected: boolean;\n };\n"]}
@@ -0,0 +1,10 @@
1
+ define(["require", "exports", "tslib", "./Option", "./Option.types", "./renderOption", "./useOption", "./useOptionStyles"], function (require, exports, tslib_1, Option_1, Option_types_1, renderOption_1, useOption_1, useOptionStyles_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ tslib_1.__exportStar(Option_1, exports);
5
+ tslib_1.__exportStar(Option_types_1, exports);
6
+ tslib_1.__exportStar(renderOption_1, exports);
7
+ tslib_1.__exportStar(useOption_1, exports);
8
+ tslib_1.__exportStar(useOptionStyles_1, exports);
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Option/index.ts"],"names":[],"mappings":";;;IAAA,wCAAyB;IACzB,8CAA+B;IAC/B,8CAA+B;IAC/B,2CAA4B;IAC5B,iDAAkC","sourcesContent":["export * from './Option';\nexport * from './Option.types';\nexport * from './renderOption';\nexport * from './useOption';\nexport * from './useOptionStyles';\n"]}
@@ -0,0 +1,16 @@
1
+ define(["require", "exports", "tslib", "react", "@fluentui/react-utilities"], function (require, exports, tslib_1, React, react_utilities_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.renderOption_unstable = void 0;
5
+ /**
6
+ * Render the final JSX of Option
7
+ */
8
+ var renderOption_unstable = function (state) {
9
+ var _a = react_utilities_1.getSlots(state), slots = _a.slots, slotProps = _a.slotProps;
10
+ return (React.createElement(slots.root, tslib_1.__assign({}, slotProps.root),
11
+ React.createElement(slots.checkIcon, tslib_1.__assign({}, slotProps.checkIcon)),
12
+ slotProps.root.children));
13
+ };
14
+ exports.renderOption_unstable = renderOption_unstable;
15
+ });
16
+ //# sourceMappingURL=renderOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderOption.js","sourceRoot":"","sources":["../../../../../../../../../packages/react-components/react-combobox/src/components/Option/renderOption.tsx"],"names":[],"mappings":";;;;IAIA;;OAEG;IACI,IAAM,qBAAqB,GAAG,UAAC,KAAkB;QAChD,IAAA,KAAuB,0BAAQ,CAAc,KAAK,CAAC,EAAjD,KAAK,WAAA,EAAE,SAAS,eAAiC,CAAC;QAE1D,OAAO,CACL,oBAAC,KAAK,CAAC,IAAI,uBAAK,SAAS,CAAC,IAAI;YAC5B,oBAAC,KAAK,CAAC,SAAS,uBAAK,SAAS,CAAC,SAAS,EAAI;YAC3C,SAAS,CAAC,IAAI,CAAC,QAAQ,CACb,CACd,CAAC;IACJ,CAAC,CAAC;IATW,QAAA,qBAAqB,yBAShC","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { OptionState, OptionSlots } from './Option.types';\n\n/**\n * Render the final JSX of Option\n */\nexport const renderOption_unstable = (state: OptionState) => {\n const { slots, slotProps } = getSlots<OptionSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <slots.checkIcon {...slotProps.checkIcon} />\n {slotProps.root.children}\n </slots.root>\n );\n};\n"]}