@fluentui/react-combobox 9.2.3 → 9.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.swcrc +30 -0
- package/CHANGELOG.json +121 -1
- package/CHANGELOG.md +35 -2
- package/lib/Combobox.js.map +1 -1
- package/lib/ComboboxField.js.map +1 -1
- package/lib/Dropdown.js.map +1 -1
- package/lib/Listbox.js.map +1 -1
- package/lib/Option.js.map +1 -1
- package/lib/OptionGroup.js.map +1 -1
- package/lib/components/Combobox/Combobox.js.map +1 -1
- package/lib/components/Combobox/Combobox.types.js +1 -1
- package/lib/components/Combobox/Combobox.types.js.map +1 -1
- package/lib/components/Combobox/index.js.map +1 -1
- package/lib/components/Combobox/renderCombobox.js +2 -12
- package/lib/components/Combobox/renderCombobox.js.map +1 -1
- package/lib/components/Combobox/useCombobox.js +11 -11
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib/components/ComboboxField/ComboboxField.js +1 -2
- package/lib/components/ComboboxField/ComboboxField.js.map +1 -1
- package/lib/components/ComboboxField/index.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.types.js.map +1 -1
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/Dropdown/renderDropdown.js +2 -12
- package/lib/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +4 -4
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib/components/Listbox/Listbox.js.map +1 -1
- package/lib/components/Listbox/Listbox.types.js.map +1 -1
- package/lib/components/Listbox/index.js.map +1 -1
- package/lib/components/Listbox/renderListbox.js +1 -3
- package/lib/components/Listbox/renderListbox.js.map +1 -1
- package/lib/components/Listbox/useListbox.js.map +1 -1
- package/lib/components/Listbox/useListboxStyles.js.map +1 -1
- package/lib/components/Option/Option.js.map +1 -1
- package/lib/components/Option/Option.types.js +1 -1
- package/lib/components/Option/Option.types.js.map +1 -1
- package/lib/components/Option/index.js.map +1 -1
- package/lib/components/Option/renderOption.js +1 -5
- package/lib/components/Option/renderOption.js.map +1 -1
- package/lib/components/Option/useOption.js +4 -4
- package/lib/components/Option/useOption.js.map +1 -1
- package/lib/components/Option/useOptionStyles.js.map +1 -1
- package/lib/components/OptionGroup/OptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/OptionGroup.types.js.map +1 -1
- package/lib/components/OptionGroup/index.js.map +1 -1
- package/lib/components/OptionGroup/renderOptionGroup.js +1 -5
- package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroup.js +1 -0
- package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
- package/lib/contexts/ComboboxContext.js.map +1 -1
- package/lib/contexts/ListboxContext.js.map +1 -1
- package/lib/contexts/useComboboxContextValues.js.map +1 -1
- package/lib/contexts/useListboxContextValues.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/ComboboxBase.types.js +1 -1
- package/lib/utils/ComboboxBase.types.js.map +1 -1
- package/lib/utils/OptionCollection.types.js.map +1 -1
- package/lib/utils/Selection.types.js +1 -1
- package/lib/utils/Selection.types.js.map +1 -1
- package/lib/utils/dropdownKeyActions.js +1 -0
- package/lib/utils/dropdownKeyActions.js.map +1 -1
- package/lib/utils/internalTokens.js.map +1 -1
- package/lib/utils/useComboboxBaseState.js +1 -3
- package/lib/utils/useComboboxBaseState.js.map +1 -1
- package/lib/utils/useComboboxPopup.js.map +1 -1
- package/lib/utils/useOptionCollection.js +4 -4
- package/lib/utils/useOptionCollection.js.map +1 -1
- package/lib/utils/useScrollOptionsIntoView.js.map +1 -1
- package/lib/utils/useSelection.js.map +1 -1
- package/lib/utils/useTriggerListboxSlots.js +6 -6
- package/lib/utils/useTriggerListboxSlots.js.map +1 -1
- package/lib-commonjs/Combobox.js +5 -4
- package/lib-commonjs/Combobox.js.map +1 -1
- package/lib-commonjs/ComboboxField.js +5 -4
- package/lib-commonjs/ComboboxField.js.map +1 -1
- package/lib-commonjs/Dropdown.js +5 -4
- package/lib-commonjs/Dropdown.js.map +1 -1
- package/lib-commonjs/Listbox.js +5 -4
- package/lib-commonjs/Listbox.js.map +1 -1
- package/lib-commonjs/Option.js +5 -4
- package/lib-commonjs/Option.js.map +1 -1
- package/lib-commonjs/OptionGroup.js +5 -4
- package/lib-commonjs/OptionGroup.js.map +1 -1
- package/lib-commonjs/components/Combobox/Combobox.js +21 -22
- package/lib-commonjs/components/Combobox/Combobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/Combobox.types.js +5 -2
- package/lib-commonjs/components/Combobox/Combobox.types.js.map +1 -1
- package/lib-commonjs/components/Combobox/index.js +9 -8
- package/lib-commonjs/components/Combobox/index.js.map +1 -1
- package/lib-commonjs/components/Combobox/renderCombobox.js +17 -30
- package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useCombobox.js +220 -246
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useComboboxStyles.js +642 -292
- package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib-commonjs/components/ComboboxField/ComboboxField.js +17 -11
- package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -1
- package/lib-commonjs/components/ComboboxField/index.js +5 -4
- package/lib-commonjs/components/ComboboxField/index.js.map +1 -1
- package/lib-commonjs/components/Dropdown/Dropdown.js +21 -22
- package/lib-commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/Dropdown.types.js +3 -2
- package/lib-commonjs/components/Dropdown/Dropdown.types.js.map +1 -1
- package/lib-commonjs/components/Dropdown/index.js +9 -8
- package/lib-commonjs/components/Dropdown/index.js.map +1 -1
- package/lib-commonjs/components/Dropdown/renderDropdown.js +17 -30
- package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdown.js +138 -152
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js +618 -279
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.js +21 -22
- package/lib-commonjs/components/Listbox/Listbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.types.js +3 -2
- package/lib-commonjs/components/Listbox/Listbox.types.js.map +1 -1
- package/lib-commonjs/components/Listbox/index.js +9 -8
- package/lib-commonjs/components/Listbox/index.js.map +1 -1
- package/lib-commonjs/components/Listbox/renderListbox.js +16 -21
- package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListbox.js +93 -109
- package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListboxStyles.js +59 -35
- package/lib-commonjs/components/Listbox/useListboxStyles.js.map +1 -1
- package/lib-commonjs/components/Option/Option.js +19 -20
- package/lib-commonjs/components/Option/Option.js.map +1 -1
- package/lib-commonjs/components/Option/Option.types.js +5 -2
- package/lib-commonjs/components/Option/Option.types.js.map +1 -1
- package/lib-commonjs/components/Option/index.js +9 -8
- package/lib-commonjs/components/Option/index.js.map +1 -1
- package/lib-commonjs/components/Option/renderOption.js +13 -20
- package/lib-commonjs/components/Option/renderOption.js.map +1 -1
- package/lib-commonjs/components/Option/useOption.js +129 -131
- package/lib-commonjs/components/Option/useOption.js.map +1 -1
- package/lib-commonjs/components/Option/useOptionStyles.js +327 -140
- package/lib-commonjs/components/Option/useOptionStyles.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.js +19 -20
- package/lib-commonjs/components/OptionGroup/OptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.types.js +3 -2
- package/lib-commonjs/components/OptionGroup/OptionGroup.types.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/index.js +9 -8
- package/lib-commonjs/components/OptionGroup/index.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/renderOptionGroup.js +13 -20
- package/lib-commonjs/components/OptionGroup/renderOptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroup.js +31 -38
- package/lib-commonjs/components/OptionGroup/useOptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js +107 -53
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
- package/lib-commonjs/contexts/ComboboxContext.js +30 -22
- package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
- package/lib-commonjs/contexts/ListboxContext.js +26 -18
- package/lib-commonjs/contexts/ListboxContext.js.map +1 -1
- package/lib-commonjs/contexts/useComboboxContextValues.js +23 -32
- package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
- package/lib-commonjs/contexts/useListboxContextValues.js +26 -32
- package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
- package/lib-commonjs/index.js +53 -201
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/ComboboxBase.types.js +5 -2
- package/lib-commonjs/utils/ComboboxBase.types.js.map +1 -1
- package/lib-commonjs/utils/OptionCollection.types.js +3 -2
- package/lib-commonjs/utils/OptionCollection.types.js.map +1 -1
- package/lib-commonjs/utils/Selection.types.js +5 -2
- package/lib-commonjs/utils/Selection.types.js.map +1 -1
- package/lib-commonjs/utils/dropdownKeyActions.js +80 -85
- package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
- package/lib-commonjs/utils/internalTokens.js +11 -8
- package/lib-commonjs/utils/internalTokens.js.map +1 -1
- package/lib-commonjs/utils/useComboboxBaseState.js +106 -108
- package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
- package/lib-commonjs/utils/useComboboxPopup.js +33 -33
- package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
- package/lib-commonjs/utils/useOptionCollection.js +74 -71
- package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
- package/lib-commonjs/utils/useScrollOptionsIntoView.js +35 -38
- package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -1
- package/lib-commonjs/utils/useSelection.js +66 -55
- package/lib-commonjs/utils/useSelection.js.map +1 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js +115 -129
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
- package/package.json +14 -13
- package/lib-amd/Combobox.js +0 -6
- package/lib-amd/Combobox.js.map +0 -1
- package/lib-amd/ComboboxField.js +0 -6
- package/lib-amd/ComboboxField.js.map +0 -1
- package/lib-amd/Dropdown.js +0 -6
- package/lib-amd/Dropdown.js.map +0 -1
- package/lib-amd/Listbox.js +0 -6
- package/lib-amd/Listbox.js.map +0 -1
- package/lib-amd/Option.js +0 -6
- package/lib-amd/Option.js.map +0 -1
- package/lib-amd/OptionGroup.js +0 -6
- package/lib-amd/OptionGroup.js.map +0 -1
- package/lib-amd/components/Combobox/Combobox.js +0 -18
- package/lib-amd/components/Combobox/Combobox.js.map +0 -1
- package/lib-amd/components/Combobox/Combobox.types.js +0 -5
- package/lib-amd/components/Combobox/Combobox.types.js.map +0 -1
- package/lib-amd/components/Combobox/index.js +0 -10
- package/lib-amd/components/Combobox/index.js.map +0 -1
- package/lib-amd/components/Combobox/renderCombobox.js +0 -20
- package/lib-amd/components/Combobox/renderCombobox.js.map +0 -1
- package/lib-amd/components/Combobox/useCombobox.js +0 -204
- package/lib-amd/components/Combobox/useCombobox.js.map +0 -1
- package/lib-amd/components/Combobox/useComboboxStyles.js +0 -152
- package/lib-amd/components/Combobox/useComboboxStyles.js.map +0 -1
- package/lib-amd/components/ComboboxField/ComboboxField.js +0 -10
- package/lib-amd/components/ComboboxField/ComboboxField.js.map +0 -1
- package/lib-amd/components/ComboboxField/index.js +0 -6
- package/lib-amd/components/ComboboxField/index.js.map +0 -1
- package/lib-amd/components/Dropdown/Dropdown.js +0 -18
- package/lib-amd/components/Dropdown/Dropdown.js.map +0 -1
- package/lib-amd/components/Dropdown/Dropdown.types.js +0 -5
- package/lib-amd/components/Dropdown/Dropdown.types.js.map +0 -1
- package/lib-amd/components/Dropdown/index.js +0 -10
- package/lib-amd/components/Dropdown/index.js.map +0 -1
- package/lib-amd/components/Dropdown/renderDropdown.js +0 -21
- package/lib-amd/components/Dropdown/renderDropdown.js.map +0 -1
- package/lib-amd/components/Dropdown/useDropdown.js +0 -121
- package/lib-amd/components/Dropdown/useDropdown.js.map +0 -1
- package/lib-amd/components/Dropdown/useDropdownStyles.js +0 -127
- package/lib-amd/components/Dropdown/useDropdownStyles.js.map +0 -1
- package/lib-amd/components/Listbox/Listbox.js +0 -18
- package/lib-amd/components/Listbox/Listbox.js.map +0 -1
- package/lib-amd/components/Listbox/Listbox.types.js +0 -5
- package/lib-amd/components/Listbox/Listbox.types.js.map +0 -1
- package/lib-amd/components/Listbox/index.js +0 -10
- package/lib-amd/components/Listbox/index.js.map +0 -1
- package/lib-amd/components/Listbox/renderListbox.js +0 -15
- package/lib-amd/components/Listbox/renderListbox.js.map +0 -1
- package/lib-amd/components/Listbox/useListbox.js +0 -80
- package/lib-amd/components/Listbox/useListbox.js.map +0 -1
- package/lib-amd/components/Listbox/useListboxStyles.js +0 -24
- package/lib-amd/components/Listbox/useListboxStyles.js.map +0 -1
- package/lib-amd/components/Option/Option.js +0 -17
- package/lib-amd/components/Option/Option.js.map +0 -1
- package/lib-amd/components/Option/Option.types.js +0 -5
- package/lib-amd/components/Option/Option.types.js.map +0 -1
- package/lib-amd/components/Option/index.js +0 -10
- package/lib-amd/components/Option/index.js.map +0 -1
- package/lib-amd/components/Option/renderOption.js +0 -16
- package/lib-amd/components/Option/renderOption.js.map +0 -1
- package/lib-amd/components/Option/useOption.js +0 -112
- package/lib-amd/components/Option/useOption.js.map +0 -1
- package/lib-amd/components/Option/useOptionStyles.js +0 -73
- package/lib-amd/components/Option/useOptionStyles.js.map +0 -1
- package/lib-amd/components/OptionGroup/OptionGroup.js +0 -17
- package/lib-amd/components/OptionGroup/OptionGroup.js.map +0 -1
- package/lib-amd/components/OptionGroup/OptionGroup.types.js +0 -5
- package/lib-amd/components/OptionGroup/OptionGroup.types.js.map +0 -1
- package/lib-amd/components/OptionGroup/index.js +0 -10
- package/lib-amd/components/OptionGroup/index.js.map +0 -1
- package/lib-amd/components/OptionGroup/renderOptionGroup.js +0 -16
- package/lib-amd/components/OptionGroup/renderOptionGroup.js.map +0 -1
- package/lib-amd/components/OptionGroup/useOptionGroup.js +0 -33
- package/lib-amd/components/OptionGroup/useOptionGroup.js.map +0 -1
- package/lib-amd/components/OptionGroup/useOptionGroupStyles.js +0 -34
- package/lib-amd/components/OptionGroup/useOptionGroupStyles.js.map +0 -1
- package/lib-amd/contexts/ComboboxContext.js +0 -28
- package/lib-amd/contexts/ComboboxContext.js.map +0 -1
- package/lib-amd/contexts/ListboxContext.js +0 -23
- package/lib-amd/contexts/ListboxContext.js.map +0 -1
- package/lib-amd/contexts/useComboboxContextValues.js +0 -23
- package/lib-amd/contexts/useComboboxContextValues.js.map +0 -1
- package/lib-amd/contexts/useListboxContextValues.js +0 -24
- package/lib-amd/contexts/useListboxContextValues.js.map +0 -1
- package/lib-amd/index.js +0 -37
- package/lib-amd/index.js.map +0 -1
- package/lib-amd/utils/ComboboxBase.types.js +0 -5
- package/lib-amd/utils/ComboboxBase.types.js.map +0 -1
- package/lib-amd/utils/OptionCollection.types.js +0 -5
- package/lib-amd/utils/OptionCollection.types.js.map +0 -1
- package/lib-amd/utils/Selection.types.js +0 -5
- package/lib-amd/utils/Selection.types.js.map +0 -1
- package/lib-amd/utils/dropdownKeyActions.js +0 -85
- package/lib-amd/utils/dropdownKeyActions.js.map +0 -1
- package/lib-amd/utils/internalTokens.js +0 -11
- package/lib-amd/utils/internalTokens.js.map +0 -1
- package/lib-amd/utils/useComboboxBaseState.js +0 -83
- package/lib-amd/utils/useComboboxBaseState.js.map +0 -1
- package/lib-amd/utils/useComboboxPopup.js +0 -16
- package/lib-amd/utils/useComboboxPopup.js.map +0 -1
- package/lib-amd/utils/useOptionCollection.js +0 -69
- package/lib-amd/utils/useOptionCollection.js.map +0 -1
- package/lib-amd/utils/useScrollOptionsIntoView.js +0 -33
- package/lib-amd/utils/useScrollOptionsIntoView.js.map +0 -1
- package/lib-amd/utils/useSelection.js +0 -42
- package/lib-amd/utils/useSelection.js.map +0 -1
- package/lib-amd/utils/useTriggerListboxSlots.js +0 -104
- package/lib-amd/utils/useTriggerListboxSlots.js.map +0 -1
|
@@ -1,156 +1,142 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
2
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "useDropdown_unstable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>useDropdown_unstable
|
|
5
8
|
});
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
}),
|
|
141
|
-
button: triggerSlot,
|
|
142
|
-
listbox: listboxSlot,
|
|
143
|
-
expandIcon: react_utilities_1.resolveShorthand(props.expandIcon, {
|
|
144
|
-
required: true,
|
|
145
|
-
defaultProps: {
|
|
146
|
-
children: React.createElement(react_icons_1.ChevronDownRegular, null)
|
|
147
|
-
}
|
|
148
|
-
}),
|
|
149
|
-
placeholderVisible: !baseState.value && !!props.placeholder,
|
|
150
|
-
...baseState
|
|
151
|
-
};
|
|
152
|
-
state.root.ref = react_utilities_2.useMergedRefs(state.root.ref, rootRef);
|
|
153
|
-
return state;
|
|
154
|
-
};
|
|
155
|
-
exports.useDropdown_unstable = useDropdown_unstable;
|
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
11
|
+
const _reactIcons = require("@fluentui/react-icons");
|
|
12
|
+
const _reactUtilities = require("@fluentui/react-utilities");
|
|
13
|
+
const _dropdownKeyActions = require("../../utils/dropdownKeyActions");
|
|
14
|
+
const _useComboboxBaseState = require("../../utils/useComboboxBaseState");
|
|
15
|
+
const _useComboboxPopup = require("../../utils/useComboboxPopup");
|
|
16
|
+
const _useTriggerListboxSlots = require("../../utils/useTriggerListboxSlots");
|
|
17
|
+
const _listbox = require("../Listbox/Listbox");
|
|
18
|
+
const useDropdown_unstable = (props, ref)=>{
|
|
19
|
+
const baseState = (0, _useComboboxBaseState.useComboboxBaseState)(props);
|
|
20
|
+
const { activeOption , getIndexOfId , getOptionsMatchingText , open , setActiveOption , setFocusVisible , setOpen } = baseState;
|
|
21
|
+
const { primary: triggerNativeProps , root: rootNativeProps } = (0, _reactUtilities.getPartitionedNativeProps)({
|
|
22
|
+
props,
|
|
23
|
+
primarySlotTagName: 'button',
|
|
24
|
+
excludedPropNames: [
|
|
25
|
+
'children'
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
// set listbox popup width based off the root/trigger width
|
|
29
|
+
const rootRef = _react.useRef(null);
|
|
30
|
+
const [popupWidth, setPopupWidth] = _react.useState();
|
|
31
|
+
_react.useEffect(()=>{
|
|
32
|
+
var _rootRef_current;
|
|
33
|
+
const width = open ? `${(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.clientWidth}px` : undefined;
|
|
34
|
+
setPopupWidth(width);
|
|
35
|
+
}, [
|
|
36
|
+
open
|
|
37
|
+
]);
|
|
38
|
+
// jump to matching option based on typing
|
|
39
|
+
const searchString = _react.useRef('');
|
|
40
|
+
const [setKeyTimeout, clearKeyTimeout] = (0, _reactUtilities.useTimeout)();
|
|
41
|
+
const getNextMatchingOption = ()=>{
|
|
42
|
+
// first check for matches for the full searchString
|
|
43
|
+
let matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString.current) === 0;
|
|
44
|
+
let matches = getOptionsMatchingText(matcher);
|
|
45
|
+
let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
|
|
46
|
+
// if the dropdown is already open and the searchstring is a single character,
|
|
47
|
+
// then look after the current activeOption for letters
|
|
48
|
+
// this is so slowly typing the same letter will cycle through matches
|
|
49
|
+
if (open && searchString.current.length === 1) {
|
|
50
|
+
startIndex++;
|
|
51
|
+
}
|
|
52
|
+
// if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
|
|
53
|
+
if (!matches.length) {
|
|
54
|
+
const letters = searchString.current.split('');
|
|
55
|
+
const allSameLetter = letters.length && letters.every((letter)=>letter === letters[0]);
|
|
56
|
+
// if the search is all the same letter, cycle through options starting with that letter
|
|
57
|
+
if (allSameLetter) {
|
|
58
|
+
startIndex++;
|
|
59
|
+
matcher = (optionText)=>optionText.toLowerCase().indexOf(letters[0]) === 0;
|
|
60
|
+
matches = getOptionsMatchingText(matcher);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// if there is an active option and multiple matches,
|
|
64
|
+
// return first matching option after the current active option, looping back to the top
|
|
65
|
+
if (matches.length > 1 && activeOption) {
|
|
66
|
+
const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);
|
|
67
|
+
return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
|
|
68
|
+
}
|
|
69
|
+
var _matches_;
|
|
70
|
+
return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;
|
|
71
|
+
};
|
|
72
|
+
const onTriggerKeyDown = (ev)=>{
|
|
73
|
+
// clear timeout, if it exists
|
|
74
|
+
clearKeyTimeout();
|
|
75
|
+
// if the key was a char key, update search string
|
|
76
|
+
if ((0, _dropdownKeyActions.getDropdownActionFromKey)(ev) === 'Type') {
|
|
77
|
+
// update search string
|
|
78
|
+
searchString.current += ev.key.toLowerCase();
|
|
79
|
+
setKeyTimeout(()=>{
|
|
80
|
+
searchString.current = '';
|
|
81
|
+
}, 500);
|
|
82
|
+
// update state
|
|
83
|
+
!open && setOpen(ev, true);
|
|
84
|
+
const nextOption = getNextMatchingOption();
|
|
85
|
+
setActiveOption(nextOption);
|
|
86
|
+
setFocusVisible(true);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// resolve button and listbox slot props
|
|
90
|
+
let triggerSlot;
|
|
91
|
+
let listboxSlot;
|
|
92
|
+
triggerSlot = (0, _reactUtilities.resolveShorthand)(props.button, {
|
|
93
|
+
required: true,
|
|
94
|
+
defaultProps: {
|
|
95
|
+
type: 'button',
|
|
96
|
+
children: baseState.value || props.placeholder,
|
|
97
|
+
...triggerNativeProps
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
triggerSlot.onKeyDown = (0, _reactUtilities.mergeCallbacks)(onTriggerKeyDown, triggerSlot.onKeyDown);
|
|
101
|
+
listboxSlot = baseState.open || baseState.hasFocus ? (0, _reactUtilities.resolveShorthand)(props.listbox, {
|
|
102
|
+
required: true,
|
|
103
|
+
defaultProps: {
|
|
104
|
+
children: props.children,
|
|
105
|
+
style: {
|
|
106
|
+
width: popupWidth
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}) : undefined;
|
|
110
|
+
[triggerSlot, listboxSlot] = (0, _useComboboxPopup.useComboboxPopup)(props, triggerSlot, listboxSlot);
|
|
111
|
+
[triggerSlot, listboxSlot] = (0, _useTriggerListboxSlots.useTriggerListboxSlots)(props, baseState, ref, triggerSlot, listboxSlot);
|
|
112
|
+
const state = {
|
|
113
|
+
components: {
|
|
114
|
+
root: 'div',
|
|
115
|
+
button: 'button',
|
|
116
|
+
expandIcon: 'span',
|
|
117
|
+
listbox: _listbox.Listbox
|
|
118
|
+
},
|
|
119
|
+
root: (0, _reactUtilities.resolveShorthand)(props.root, {
|
|
120
|
+
required: true,
|
|
121
|
+
defaultProps: {
|
|
122
|
+
'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,
|
|
123
|
+
children: props.children,
|
|
124
|
+
...rootNativeProps
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
button: triggerSlot,
|
|
128
|
+
listbox: listboxSlot,
|
|
129
|
+
expandIcon: (0, _reactUtilities.resolveShorthand)(props.expandIcon, {
|
|
130
|
+
required: true,
|
|
131
|
+
defaultProps: {
|
|
132
|
+
children: /*#__PURE__*/ _react.createElement(_reactIcons.ChevronDownRegular, null)
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
placeholderVisible: !baseState.value && !!props.placeholder,
|
|
136
|
+
...baseState
|
|
137
|
+
};
|
|
138
|
+
state.root.ref = (0, _reactUtilities.useMergedRefs)(state.root.ref, rootRef);
|
|
139
|
+
return state;
|
|
140
|
+
}; //# sourceMappingURL=useDropdown.js.map
|
|
141
|
+
|
|
156
142
|
//# sourceMappingURL=useDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","require","react_icons_1","react_utilities_1","dropdownKeyActions_1","useComboboxBaseState_1","useComboboxPopup_1","useTriggerListboxSlots_1","Listbox_1","react_utilities_2","useDropdown_unstable","props","ref","baseState","useComboboxBaseState","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","rootRef","useRef","popupWidth","setPopupWidth","useState","useEffect","width","_a","current","clientWidth","undefined","searchString","setKeyTimeout","clearKeyTimeout","useTimeout","getNextMatchingOption","matcher","optionText","toLowerCase","indexOf","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","onTriggerKeyDown","ev","getDropdownActionFromKey","key","nextOption","triggerSlot","listboxSlot","resolveShorthand","button","required","defaultProps","type","children","value","placeholder","onKeyDown","mergeCallbacks","hasFocus","listbox","style","useComboboxPopup","useTriggerListboxSlots","state","components","expandIcon","Listbox","inlinePopup","createElement","ChevronDownRegular","placeholderVisible","useMergedRefs","exports"],"sources":["../src/packages/react-components/react-combobox/src/components/Dropdown/useDropdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useTimeout } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { DropdownProps, DropdownState } from './Dropdown.types';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n\n/**\n * Create the state required to render Dropdown.\n *\n * The returned state can be modified with hooks such as useDropdownStyles_unstable,\n * before being passed to renderDropdown_unstable.\n *\n * @param props - props from this instance of Dropdown\n * @param ref - reference to root HTMLElement of Dropdown\n */\nexport const useDropdown_unstable = (props: DropdownProps, ref: React.Ref<HTMLButtonElement>): DropdownState => {\n const baseState = useComboboxBaseState(props);\n const { activeOption, getIndexOfId, getOptionsMatchingText, open, setActiveOption, setFocusVisible, setOpen } =\n baseState;\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: ['children'],\n });\n\n // set listbox popup width based off the root/trigger width\n const rootRef = React.useRef<HTMLDivElement>(null);\n const [popupWidth, setPopupWidth] = React.useState<string>();\n React.useEffect(() => {\n const width = open ? `${rootRef.current?.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n\n const getNextMatchingOption = (): OptionValue | undefined => {\n // first check for matches for the full searchString\n let matcher = (optionText: string) => optionText.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n\n // if the dropdown is already open and the searchstring is a single character,\n // then look after the current activeOption for letters\n // this is so slowly typing the same letter will cycle through matches\n if (open && searchString.current.length === 1) {\n startIndex++;\n }\n\n // if there are no direct matches, check if the search is all the same letter, e.g. \"aaa\"\n if (!matches.length) {\n const letters = searchString.current.split('');\n const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);\n\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = (optionText: string) => optionText.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\n }\n\n // if there is an active option and multiple matches,\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);\n return nextMatch ?? matches[0];\n }\n\n return matches[0] ?? undefined;\n };\n\n const onTriggerKeyDown = (ev: React.KeyboardEvent<HTMLButtonElement>) => {\n // clear timeout, if it exists\n clearKeyTimeout();\n\n // if the key was a char key, update search string\n if (getDropdownActionFromKey(ev) === 'Type') {\n // update search string\n searchString.current += ev.key.toLowerCase();\n setKeyTimeout(() => {\n searchString.current = '';\n }, 500);\n\n // update state\n !open && setOpen(ev, true);\n\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n\n // resolve button and listbox slot props\n let triggerSlot: Slot<'button'>;\n let listboxSlot: Slot<typeof Listbox> | undefined;\n\n triggerSlot = resolveShorthand(props.button, {\n required: true,\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n\n listboxSlot =\n baseState.open || baseState.hasFocus\n ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: { width: popupWidth },\n },\n })\n : undefined;\n\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n\n const state: DropdownState = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n 'aria-owns': !props.inlinePopup ? listboxSlot?.id : undefined,\n children: props.children,\n ...rootNativeProps,\n },\n }),\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: <ChevronDownIcon />,\n },\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n\n return state;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,aAAA,gBAAAD,OAAA;AACA,MAAAE,iBAAA,gBAAAF,OAAA;AACA,MAAAG,oBAAA,gBAAAH,OAAA;AACA,MAAAI,sBAAA,gBAAAJ,OAAA;AACA,MAAAK,kBAAA,gBAAAL,OAAA;AACA,MAAAM,wBAAA,gBAAAN,OAAA;AACA,MAAAO,SAAA,gBAAAP,OAAA;AAIA,MAAAQ,iBAAA,gBAAAR,OAAA;AAEA;;;;;;;;;AASO,MAAMS,oBAAoB,GAAGA,CAACC,KAAoB,EA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AEE,SAAS,EAAED,GAAG,EAAEsD,WAAW,EAAEC,WAAW,CAAC;EAEpG,MAAMgB,KAAK,GAAkB;IAC3BC,UAAU,EAAE;MACV5D,IAAI,EAAE,KAAK;MACX6C,MAAM,EAAE,QAAQ;MAChBgB,UAAU,EAAE,MAAM;MAClBN,OAAO,EAAEvE,SAAA,CAAA8E;KACV;IACD9D,IAAI,EAAErB,iBAAA,CAAAiE,gBAAgB,CAACzD,KAAK,CAACa,IAAI,EAAE;MACjC8C,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZ,WAAW,EAAE,CAAC5D,KAAK,CAAC4E,WAAW,GAAGpB,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEhB,EAAE,GAAGZ,SAAS;QAC7DkC,QAAQ,EAAE9D,KAAK,CAAC8D,QAAQ;QACxB,GAAGhD;;KAEN,CAAC;IACF4C,MAAM,EAAEH,WAAW;IACnBa,OAAO,EAAEZ,WAAW;IACpBkB,UAAU,EAAElF,iBAAA,CAAAiE,gBAAgB,CAACzD,KAAK,CAAC0E,UAAU,EAAE;MAC7Cf,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZE,QAAQ,EAAEzE,KAAA,CAAAwF,aAAA,CAACtF,aAAA,CAAAuF,kBAAe;;KAE7B,CAAC;IACFC,kBAAkB,EAAE,CAAC7E,SAAS,CAAC6D,KAAK,IAAI,CAAC,CAAC/D,KAAK,CAACgE,WAAW;IAC3D,GAAG9D;GACJ;EAEDsE,KAAK,CAAC3D,IAAI,CAACZ,GAAG,GAAGH,iBAAA,CAAAkF,aAAa,CAACR,KAAK,CAAC3D,IAAI,CAACZ,GAAG,EAAEiB,OAAO,CAAC;EAEvD,OAAOsD,KAAK;AACd,CAAC;AA3IYS,OAAA,CAAAlF,oBAAoB,GAAAA,oBAAA"}
|
|
1
|
+
{"version":3,"sources":["../../../lib/components/Dropdown/useDropdown.js"],"sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useTimeout } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n/**\n * Create the state required to render Dropdown.\n *\n * The returned state can be modified with hooks such as useDropdownStyles_unstable,\n * before being passed to renderDropdown_unstable.\n *\n * @param props - props from this instance of Dropdown\n * @param ref - reference to root HTMLElement of Dropdown\n */\nexport const useDropdown_unstable = (props, ref) => {\n const baseState = useComboboxBaseState(props);\n const {\n activeOption,\n getIndexOfId,\n getOptionsMatchingText,\n open,\n setActiveOption,\n setFocusVisible,\n setOpen\n } = baseState;\n const {\n primary: triggerNativeProps,\n root: rootNativeProps\n } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: ['children']\n });\n // set listbox popup width based off the root/trigger width\n const rootRef = React.useRef(null);\n const [popupWidth, setPopupWidth] = React.useState();\n React.useEffect(() => {\n var _rootRef_current;\n const width = open ? `${(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n const getNextMatchingOption = () => {\n // first check for matches for the full searchString\n let matcher = optionText => optionText.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n // if the dropdown is already open and the searchstring is a single character,\n // then look after the current activeOption for letters\n // this is so slowly typing the same letter will cycle through matches\n if (open && searchString.current.length === 1) {\n startIndex++;\n }\n // if there are no direct matches, check if the search is all the same letter, e.g. \"aaa\"\n if (!matches.length) {\n const letters = searchString.current.split('');\n const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = optionText => optionText.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\n }\n // if there is an active option and multiple matches,\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);\n return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];\n }\n var _matches_;\n return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;\n };\n const onTriggerKeyDown = ev => {\n // clear timeout, if it exists\n clearKeyTimeout();\n // if the key was a char key, update search string\n if (getDropdownActionFromKey(ev) === 'Type') {\n // update search string\n searchString.current += ev.key.toLowerCase();\n setKeyTimeout(() => {\n searchString.current = '';\n }, 500);\n // update state\n !open && setOpen(ev, true);\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n // resolve button and listbox slot props\n let triggerSlot;\n let listboxSlot;\n triggerSlot = resolveShorthand(props.button, {\n required: true,\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps\n }\n });\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n listboxSlot = baseState.open || baseState.hasFocus ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: {\n width: popupWidth\n }\n }\n }) : undefined;\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n const state = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n 'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,\n children: props.children,\n ...rootNativeProps\n }\n }),\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: /*#__PURE__*/React.createElement(ChevronDownIcon, null)\n }\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState\n };\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n return state;\n};\n//# sourceMappingURL=useDropdown.js.map"],"names":["useDropdown_unstable","props","ref","baseState","useComboboxBaseState","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","rootRef","React","useRef","popupWidth","setPopupWidth","useState","useEffect","_rootRef_current","width","current","clientWidth","undefined","searchString","setKeyTimeout","clearKeyTimeout","useTimeout","getNextMatchingOption","matcher","optionText","toLowerCase","indexOf","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","_matches_","onTriggerKeyDown","ev","getDropdownActionFromKey","key","nextOption","triggerSlot","listboxSlot","resolveShorthand","button","required","defaultProps","type","children","value","placeholder","onKeyDown","mergeCallbacks","hasFocus","listbox","style","useComboboxPopup","useTriggerListboxSlots","state","components","expandIcon","Listbox","inlinePopup","createElement","ChevronDownIcon","placeholderVisible","useMergedRefs"],"mappings":";;;;+BAkBaA;;aAAAA;;;6DAlBU;4BAC+B;gCACkC;oCAC/C;sCACJ;kCACJ;wCACM;yBACf;AAWjB,MAAMA,uBAAuB,CAACC,OAAOC,MAAQ;IAClD,MAAMC,YAAYC,IAAAA,0CAAoB,EAACH;IACvC,MAAM,EACJI,aAAY,EACZC,aAAY,EACZC,uBAAsB,EACtBC,KAAI,EACJC,gBAAe,EACfC,gBAAe,EACfC,QAAO,EACR,GAAGR;IACJ,MAAM,EACJS,SAASC,mBAAkB,EAC3BC,MAAMC,gBAAe,EACt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