@fluentui/react-combobox 9.0.0-beta.19 → 9.0.0-beta.21
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/CHANGELOG.json +117 -1
- package/CHANGELOG.md +32 -2
- package/lib/components/Combobox/Combobox.js +0 -1
- package/lib/components/Combobox/Combobox.js.map +1 -1
- package/lib/components/Combobox/renderCombobox.js +10 -6
- package/lib/components/Combobox/renderCombobox.js.map +1 -1
- package/lib/components/Combobox/useCombobox.js +41 -53
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Combobox/useComboboxStyles.js +209 -217
- package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib/components/ComboboxField/ComboboxField.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.js +0 -1
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/renderDropdown.js +10 -6
- package/lib/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +20 -32
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdownStyles.js +199 -206
- package/lib/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib/components/Listbox/Listbox.js +0 -1
- package/lib/components/Listbox/Listbox.js.map +1 -1
- package/lib/components/Listbox/renderListbox.js +2 -2
- package/lib/components/Listbox/renderListbox.js.map +1 -1
- package/lib/components/Listbox/useListbox.js +6 -13
- package/lib/components/Listbox/useListbox.js.map +1 -1
- package/lib/components/Listbox/useListboxStyles.js +18 -21
- package/lib/components/Listbox/useListboxStyles.js.map +1 -1
- package/lib/components/Option/Option.js +0 -1
- package/lib/components/Option/Option.js.map +1 -1
- package/lib/components/Option/renderOption.js +4 -3
- package/lib/components/Option/renderOption.js.map +1 -1
- package/lib/components/Option/useOption.js +20 -32
- package/lib/components/Option/useOption.js.map +1 -1
- package/lib/components/Option/useOptionStyles.js +74 -79
- package/lib/components/Option/useOptionStyles.js.map +1 -1
- package/lib/components/OptionGroup/OptionGroup.js +0 -1
- package/lib/components/OptionGroup/OptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/renderOptionGroup.js +4 -3
- package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroup.js +0 -1
- package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroupStyles.js +29 -34
- package/lib/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
- package/lib/contexts/ComboboxContext.js +8 -11
- package/lib/contexts/ComboboxContext.js.map +1 -1
- package/lib/contexts/ListboxContext.js +6 -9
- package/lib/contexts/ListboxContext.js.map +1 -1
- package/lib/contexts/useComboboxContextValues.js.map +1 -1
- package/lib/contexts/useListboxContextValues.js +2 -2
- package/lib/contexts/useListboxContextValues.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/dropdownKeyActions.js +12 -33
- package/lib/utils/dropdownKeyActions.js.map +1 -1
- package/lib/utils/internalTokens.js.map +1 -1
- package/lib/utils/useComboboxBaseState.js +23 -27
- package/lib/utils/useComboboxBaseState.js.map +1 -1
- package/lib/utils/useComboboxPopup.js +6 -4
- package/lib/utils/useComboboxPopup.js.map +1 -1
- package/lib/utils/useOptionCollection.js +10 -20
- package/lib/utils/useOptionCollection.js.map +1 -1
- package/lib/utils/useScrollOptionsIntoView.js +2 -5
- package/lib/utils/useScrollOptionsIntoView.js.map +1 -1
- package/lib/utils/useSelection.js +7 -12
- package/lib/utils/useSelection.js.map +1 -1
- package/lib/utils/useTriggerListboxSlots.js +31 -39
- package/lib/utils/useTriggerListboxSlots.js.map +1 -1
- package/lib-commonjs/Combobox.js +0 -2
- package/lib-commonjs/Combobox.js.map +1 -1
- package/lib-commonjs/ComboboxField.js +0 -2
- package/lib-commonjs/ComboboxField.js.map +1 -1
- package/lib-commonjs/Dropdown.js +0 -2
- package/lib-commonjs/Dropdown.js.map +1 -1
- package/lib-commonjs/Listbox.js +0 -2
- package/lib-commonjs/Listbox.js.map +1 -1
- package/lib-commonjs/Option.js +0 -2
- package/lib-commonjs/Option.js.map +1 -1
- package/lib-commonjs/OptionGroup.js +0 -2
- package/lib-commonjs/OptionGroup.js.map +1 -1
- package/lib-commonjs/components/Combobox/Combobox.js +0 -7
- package/lib-commonjs/components/Combobox/Combobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/Combobox.types.js.map +1 -1
- package/lib-commonjs/components/Combobox/index.js +0 -6
- package/lib-commonjs/components/Combobox/index.js.map +1 -1
- package/lib-commonjs/components/Combobox/renderCombobox.js +10 -12
- package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useCombobox.js +41 -63
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useComboboxStyles.js +209 -222
- package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib-commonjs/components/ComboboxField/ComboboxField.js +0 -4
- package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -1
- package/lib-commonjs/components/ComboboxField/index.js +0 -2
- package/lib-commonjs/components/ComboboxField/index.js.map +1 -1
- package/lib-commonjs/components/Dropdown/Dropdown.js +0 -7
- package/lib-commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/Dropdown.types.js.map +1 -1
- package/lib-commonjs/components/Dropdown/index.js +0 -6
- package/lib-commonjs/components/Dropdown/index.js.map +1 -1
- package/lib-commonjs/components/Dropdown/renderDropdown.js +10 -12
- package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdown.js +20 -43
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js +199 -211
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.js +0 -7
- package/lib-commonjs/components/Listbox/Listbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.types.js.map +1 -1
- package/lib-commonjs/components/Listbox/index.js +0 -6
- package/lib-commonjs/components/Listbox/index.js.map +1 -1
- package/lib-commonjs/components/Listbox/renderListbox.js +2 -7
- package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListbox.js +6 -23
- package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListboxStyles.js +18 -25
- package/lib-commonjs/components/Listbox/useListboxStyles.js.map +1 -1
- package/lib-commonjs/components/Option/Option.js +0 -6
- package/lib-commonjs/components/Option/Option.js.map +1 -1
- package/lib-commonjs/components/Option/Option.types.js.map +1 -1
- package/lib-commonjs/components/Option/index.js +0 -6
- package/lib-commonjs/components/Option/index.js.map +1 -1
- package/lib-commonjs/components/Option/renderOption.js +4 -7
- package/lib-commonjs/components/Option/renderOption.js.map +1 -1
- package/lib-commonjs/components/Option/useOption.js +20 -39
- package/lib-commonjs/components/Option/useOption.js.map +1 -1
- package/lib-commonjs/components/Option/useOptionStyles.js +74 -83
- package/lib-commonjs/components/Option/useOptionStyles.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.js +0 -6
- package/lib-commonjs/components/OptionGroup/OptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.types.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/index.js +0 -6
- package/lib-commonjs/components/OptionGroup/index.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/renderOptionGroup.js +4 -7
- package/lib-commonjs/components/OptionGroup/renderOptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroup.js +0 -4
- package/lib-commonjs/components/OptionGroup/useOptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js +29 -38
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
- package/lib-commonjs/contexts/ComboboxContext.js +8 -13
- package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
- package/lib-commonjs/contexts/ListboxContext.js +6 -11
- package/lib-commonjs/contexts/ListboxContext.js.map +1 -1
- package/lib-commonjs/contexts/useComboboxContextValues.js +0 -2
- package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
- package/lib-commonjs/contexts/useListboxContextValues.js +2 -6
- package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
- package/lib-commonjs/index.js +0 -20
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/ComboboxBase.types.js.map +1 -1
- package/lib-commonjs/utils/OptionCollection.types.js.map +1 -1
- package/lib-commonjs/utils/Selection.types.js.map +1 -1
- package/lib-commonjs/utils/dropdownKeyActions.js +12 -37
- package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
- package/lib-commonjs/utils/internalTokens.js.map +1 -1
- package/lib-commonjs/utils/useComboboxBaseState.js +23 -33
- package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
- package/lib-commonjs/utils/useComboboxPopup.js +6 -8
- package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
- package/lib-commonjs/utils/useOptionCollection.js +10 -23
- package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
- package/lib-commonjs/utils/useScrollOptionsIntoView.js +2 -9
- package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -1
- package/lib-commonjs/utils/useSelection.js +7 -15
- package/lib-commonjs/utils/useSelection.js.map +1 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js +30 -43
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
- package/package.json +9 -9
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useComboboxContextValues = void 0;
|
|
7
|
-
|
|
8
7
|
function useComboboxContextValues(state) {
|
|
9
8
|
const {
|
|
10
9
|
activeOption,
|
|
@@ -34,6 +33,5 @@ function useComboboxContextValues(state) {
|
|
|
34
33
|
combobox
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
exports.useComboboxContextValues = useComboboxContextValues;
|
|
39
37
|
//# sourceMappingURL=useComboboxContextValues.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAEA,SAAgBA,wBAAwB,CAACC,KAAwB;EAC/D,MAAM;IACJC,YAAY;IACZC,UAAU;IACVC,YAAY;IACZC,IAAI;IACJC,cAAc;IACdC,eAAe;IACfC,YAAY;IACZC,eAAe;IACfC,OAAO;IACPC;EAAI,CACL,GAAGV,KAAK;EAET,MAAMW,QAAQ,GAAG;IACfV,YAAY;IACZC,UAAU;IACVC,YAAY;IACZC,IAAI;IACJC,cAAc;IACdC,eAAe;IACfC,YAAY;IACZC,eAAe;IACfC,OAAO;IACPC;GACD;EAED,OAAO;IAAEC;EAAQ,CAAE;AACrB;AA5BAC","names":["useComboboxContextValues","state","activeOption","appearance","focusVisible","open","registerOption","selectedOptions","selectOption","setActiveOption","setOpen","size","combobox","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/contexts/useComboboxContextValues.ts"],"sourcesContent":["import { ComboboxBaseContextValues, ComboboxBaseState } from '../utils/ComboboxBase.types';\n\nexport function useComboboxContextValues(state: ComboboxBaseState): ComboboxBaseContextValues {\n const {\n activeOption,\n appearance,\n focusVisible,\n open,\n registerOption,\n selectedOptions,\n selectOption,\n setActiveOption,\n setOpen,\n size,\n } = state;\n\n const combobox = {\n activeOption,\n appearance,\n focusVisible,\n open,\n registerOption,\n selectedOptions,\n selectOption,\n setActiveOption,\n setOpen,\n size,\n };\n\n return { combobox };\n}\n"]}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useListboxContextValues = void 0;
|
|
7
|
-
|
|
8
7
|
const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
|
9
|
-
|
|
10
8
|
const ComboboxContext_1 = /*#__PURE__*/require("./ComboboxContext");
|
|
11
|
-
|
|
12
9
|
function useListboxContextValues(state) {
|
|
13
10
|
const hasComboboxContext = react_context_selector_1.useHasParentContext(ComboboxContext_1.ComboboxContext);
|
|
14
11
|
const {
|
|
@@ -19,8 +16,8 @@ function useListboxContextValues(state) {
|
|
|
19
16
|
selectedOptions,
|
|
20
17
|
selectOption,
|
|
21
18
|
setActiveOption
|
|
22
|
-
} = state;
|
|
23
|
-
|
|
19
|
+
} = state;
|
|
20
|
+
// get register/unregister functions from parent combobox context
|
|
24
21
|
const comboboxRegisterOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.registerOption);
|
|
25
22
|
const registerOptionValue = hasComboboxContext ? comboboxRegisterOption : registerOption;
|
|
26
23
|
const listbox = {
|
|
@@ -36,6 +33,5 @@ function useListboxContextValues(state) {
|
|
|
36
33
|
listbox
|
|
37
34
|
};
|
|
38
35
|
}
|
|
39
|
-
|
|
40
36
|
exports.useListboxContextValues = useListboxContextValues;
|
|
41
37
|
//# sourceMappingURL=useListboxContextValues.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;AAEA,SAAgBA,uBAAuB,CAACC,KAAmB;EACzD,MAAMC,kBAAkB,GAAGC,4CAAmB,CAACC,iCAAe,CAAC;EAC/D,MAAM;IACJC,YAAY;IACZC,YAAY;IACZC,WAAW;IACXC,cAAc;IACdC,eAAe;IACfC,YAAY;IACZC;EAAe,CAChB,GAAGV,KAAK;EAET;EACA,MAAMW,sBAAsB,GAAGT,2CAAkB,CAACC,iCAAe,EAAES,GAAG,IAAIA,GAAG,CAACL,cAAc,CAAC;EAE7F,MAAMM,mBAAmB,GAAGZ,kBAAkB,GAAGU,sBAAsB,GAAGJ,cAAc;EAExF,MAAMO,OAAO,GAAG;IACdV,YAAY;IACZC,YAAY;IACZC,WAAW;IACXC,cAAc,EAAEM,mBAAmB;IACnCL,eAAe;IACfC,YAAY;IACZC;GACD;EAED,OAAO;IAAEI;EAAO,CAAE;AACpB;AA5BAC","names":["useListboxContextValues","state","hasComboboxContext","react_context_selector_1","ComboboxContext_1","activeOption","focusVisible","multiselect","registerOption","selectedOptions","selectOption","setActiveOption","comboboxRegisterOption","ctx","registerOptionValue","listbox","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/contexts/useListboxContextValues.ts"],"sourcesContent":["import { useContextSelector, useHasParentContext } from '@fluentui/react-context-selector';\nimport { ListboxContextValues, ListboxState } from '../components/Listbox/Listbox.types';\nimport { ComboboxContext } from './ComboboxContext';\n\nexport function useListboxContextValues(state: ListboxState): ListboxContextValues {\n const hasComboboxContext = useHasParentContext(ComboboxContext);\n const {\n activeOption,\n focusVisible,\n multiselect,\n registerOption,\n selectedOptions,\n selectOption,\n setActiveOption,\n } = state;\n\n // get register/unregister functions from parent combobox context\n const comboboxRegisterOption = useContextSelector(ComboboxContext, ctx => ctx.registerOption);\n\n const registerOptionValue = hasComboboxContext ? comboboxRegisterOption : registerOption;\n\n const listbox = {\n activeOption,\n focusVisible,\n multiselect,\n registerOption: registerOptionValue,\n selectedOptions,\n selectOption,\n setActiveOption,\n };\n\n return { listbox };\n}\n"]}
|
package/lib-commonjs/index.js
CHANGED
|
@@ -4,45 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.comboboxFieldClassNames = exports.ComboboxField_unstable = exports.useOptionGroup_unstable = exports.useOptionGroupStyles_unstable = exports.renderOptionGroup_unstable = exports.optionGroupClassNames = exports.OptionGroup = exports.useDropdown_unstable = exports.useDropdownStyles_unstable = exports.renderDropdown_unstable = exports.dropdownClassNames = exports.Dropdown = exports.useCombobox_unstable = exports.useComboboxStyles_unstable = exports.renderCombobox_unstable = exports.comboboxClassNames = exports.Combobox = exports.useOption_unstable = exports.useOptionStyles_unstable = exports.renderOption_unstable = exports.optionClassNames = exports.Option = exports.useListbox_unstable = exports.useListboxStyles_unstable = exports.renderListbox_unstable = exports.listboxClassNames = exports.Listbox = exports.useListboxContextValues = exports.useComboboxContextValues = exports.ListboxProvider = exports.ComboboxProvider = void 0;
|
|
7
|
-
|
|
8
7
|
var ComboboxContext_1 = /*#__PURE__*/require("./contexts/ComboboxContext");
|
|
9
|
-
|
|
10
8
|
Object.defineProperty(exports, "ComboboxProvider", {
|
|
11
9
|
enumerable: true,
|
|
12
10
|
get: function () {
|
|
13
11
|
return ComboboxContext_1.ComboboxProvider;
|
|
14
12
|
}
|
|
15
13
|
});
|
|
16
|
-
|
|
17
14
|
var ListboxContext_1 = /*#__PURE__*/require("./contexts/ListboxContext");
|
|
18
|
-
|
|
19
15
|
Object.defineProperty(exports, "ListboxProvider", {
|
|
20
16
|
enumerable: true,
|
|
21
17
|
get: function () {
|
|
22
18
|
return ListboxContext_1.ListboxProvider;
|
|
23
19
|
}
|
|
24
20
|
});
|
|
25
|
-
|
|
26
21
|
var useComboboxContextValues_1 = /*#__PURE__*/require("./contexts/useComboboxContextValues");
|
|
27
|
-
|
|
28
22
|
Object.defineProperty(exports, "useComboboxContextValues", {
|
|
29
23
|
enumerable: true,
|
|
30
24
|
get: function () {
|
|
31
25
|
return useComboboxContextValues_1.useComboboxContextValues;
|
|
32
26
|
}
|
|
33
27
|
});
|
|
34
|
-
|
|
35
28
|
var useListboxContextValues_1 = /*#__PURE__*/require("./contexts/useListboxContextValues");
|
|
36
|
-
|
|
37
29
|
Object.defineProperty(exports, "useListboxContextValues", {
|
|
38
30
|
enumerable: true,
|
|
39
31
|
get: function () {
|
|
40
32
|
return useListboxContextValues_1.useListboxContextValues;
|
|
41
33
|
}
|
|
42
34
|
});
|
|
43
|
-
|
|
44
35
|
var Listbox_1 = /*#__PURE__*/require("./Listbox");
|
|
45
|
-
|
|
46
36
|
Object.defineProperty(exports, "Listbox", {
|
|
47
37
|
enumerable: true,
|
|
48
38
|
get: function () {
|
|
@@ -73,9 +63,7 @@ Object.defineProperty(exports, "useListbox_unstable", {
|
|
|
73
63
|
return Listbox_1.useListbox_unstable;
|
|
74
64
|
}
|
|
75
65
|
});
|
|
76
|
-
|
|
77
66
|
var Option_1 = /*#__PURE__*/require("./Option");
|
|
78
|
-
|
|
79
67
|
Object.defineProperty(exports, "Option", {
|
|
80
68
|
enumerable: true,
|
|
81
69
|
get: function () {
|
|
@@ -106,9 +94,7 @@ Object.defineProperty(exports, "useOption_unstable", {
|
|
|
106
94
|
return Option_1.useOption_unstable;
|
|
107
95
|
}
|
|
108
96
|
});
|
|
109
|
-
|
|
110
97
|
var Combobox_1 = /*#__PURE__*/require("./Combobox");
|
|
111
|
-
|
|
112
98
|
Object.defineProperty(exports, "Combobox", {
|
|
113
99
|
enumerable: true,
|
|
114
100
|
get: function () {
|
|
@@ -139,9 +125,7 @@ Object.defineProperty(exports, "useCombobox_unstable", {
|
|
|
139
125
|
return Combobox_1.useCombobox_unstable;
|
|
140
126
|
}
|
|
141
127
|
});
|
|
142
|
-
|
|
143
128
|
var Dropdown_1 = /*#__PURE__*/require("./Dropdown");
|
|
144
|
-
|
|
145
129
|
Object.defineProperty(exports, "Dropdown", {
|
|
146
130
|
enumerable: true,
|
|
147
131
|
get: function () {
|
|
@@ -172,9 +156,7 @@ Object.defineProperty(exports, "useDropdown_unstable", {
|
|
|
172
156
|
return Dropdown_1.useDropdown_unstable;
|
|
173
157
|
}
|
|
174
158
|
});
|
|
175
|
-
|
|
176
159
|
var OptionGroup_1 = /*#__PURE__*/require("./OptionGroup");
|
|
177
|
-
|
|
178
160
|
Object.defineProperty(exports, "OptionGroup", {
|
|
179
161
|
enumerable: true,
|
|
180
162
|
get: function () {
|
|
@@ -205,9 +187,7 @@ Object.defineProperty(exports, "useOptionGroup_unstable", {
|
|
|
205
187
|
return OptionGroup_1.useOptionGroup_unstable;
|
|
206
188
|
}
|
|
207
189
|
});
|
|
208
|
-
|
|
209
190
|
var ComboboxField_1 = /*#__PURE__*/require("./ComboboxField");
|
|
210
|
-
|
|
211
191
|
Object.defineProperty(exports, "ComboboxField_unstable", {
|
|
212
192
|
enumerable: true,
|
|
213
193
|
get: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAASA;EAAAC;EAAAC;IAAA,yCAAgB;EAAA;AAAA;AAEzB;AAASF;EAAAC;EAAAC;IAAA,uCAAe;EAAA;AAAA;AAExB;AAASF;EAAAC;EAAAC;IAAA,0DAAwB;EAAA;AAAA;AACjC;AAASF;EAAAC;EAAAC;IAAA,wDAAuB;EAAA;AAAA;AAChC;AACEF;EAAAC;EAAAC;IAAA,wBAAO;EAAA;AAAA;AACPF;EAAAC;EAAAC;IAAA,kCAAiB;EAAA;AAAA;AACjBF;EAAAC;EAAAC;IAAA,uCAAsB;EAAA;AAAA;AACtBF;EAAAC;EAAAC;IAAA,0CAAyB;EAAA;AAAA;AACzBF;EAAAC;EAAAC;IAAA,oCAAmB;EAAA;AAAA;AAGrB;AACEF;EAAAC;EAAAC;IAAA,sBAAM;EAAA;AAAA;AACNF;EAAAC;EAAAC;IAAA,gCAAgB;EAAA;AAAA;AAChBF;EAAAC;EAAAC;IAAA,qCAAqB;EAAA;AAAA;AACrBF;EAAAC;EAAAC;IAAA,wCAAwB;EAAA;AAAA;AACxBF;EAAAC;EAAAC;IAAA,kCAAkB;EAAA;AAAA;AAGpB;AACEF;EAAAC;EAAAC;IAAA,0BAAQ;EAAA;AAAA;AACRF;EAAAC;EAAAC;IAAA,oCAAkB;EAAA;AAAA;AAClBF;EAAAC;EAAAC;IAAA,yCAAuB;EAAA;AAAA;AACvBF;EAAAC;EAAAC;IAAA,4CAA0B;EAAA;AAAA;AAC1BF;EAAAC;EAAAC;IAAA,sCAAoB;EAAA;AAAA;AAUtB;AACEF;EAAAC;EAAAC;IAAA,0BAAQ;EAAA;AAAA;AACRF;EAAAC;EAAAC;IAAA,oCAAkB;EAAA;AAAA;AAClBF;EAAAC;EAAAC;IAAA,yCAAuB;EAAA;AAAA;AACvBF;EAAAC;EAAAC;IAAA,4CAA0B;EAAA;AAAA;AAC1BF;EAAAC;EAAAC;IAAA,sCAAoB;EAAA;AAAA;AAUtB;AACEF;EAAAC;EAAAC;IAAA,gCAAW;EAAA;AAAA;AACXF;EAAAC;EAAAC;IAAA,0CAAqB;EAAA;AAAA;AACrBF;EAAAC;EAAAC;IAAA,+CAA0B;EAAA;AAAA;AAC1BF;EAAAC;EAAAC;IAAA,kDAA6B;EAAA;AAAA;AAC7BF;EAAAC;EAAAC;IAAA,4CAAuB;EAAA;AAAA;AAIzB;AAASF;EAAAC;EAAAC;IAAA,oCAAa;EAAA;AAAA;AAA4BF;EAAAC;EAAAC;IAAA,8CAAuB;EAAA;AAAA","names":["Object","enumerable","get"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/index.ts"],"sourcesContent":["export { ComboboxProvider } from './contexts/ComboboxContext';\nexport type { ComboboxContextValue } from './contexts/ComboboxContext';\nexport { ListboxProvider } from './contexts/ListboxContext';\nexport type { ListboxContextValue } from './contexts/ListboxContext';\nexport { useComboboxContextValues } from './contexts/useComboboxContextValues';\nexport { useListboxContextValues } from './contexts/useListboxContextValues';\nexport {\n Listbox,\n listboxClassNames,\n renderListbox_unstable,\n useListboxStyles_unstable,\n useListbox_unstable,\n} from './Listbox';\nexport type { ListboxContextValues, ListboxProps, ListboxSlots, ListboxState } from './Listbox';\nexport {\n Option,\n optionClassNames,\n renderOption_unstable,\n useOptionStyles_unstable,\n useOption_unstable,\n} from './Option';\nexport type { OptionProps, OptionSlots, OptionState } from './Option';\nexport {\n Combobox,\n comboboxClassNames,\n renderCombobox_unstable,\n useComboboxStyles_unstable,\n useCombobox_unstable,\n} from './Combobox';\nexport type {\n ComboboxContextValues,\n ComboboxOpenChangeData,\n ComboboxOpenEvents,\n ComboboxProps,\n ComboboxSlots,\n ComboboxState,\n} from './Combobox';\nexport {\n Dropdown,\n dropdownClassNames,\n renderDropdown_unstable,\n useDropdownStyles_unstable,\n useDropdown_unstable,\n} from './Dropdown';\nexport type {\n DropdownContextValues,\n DropdownOpenChangeData,\n DropdownOpenEvents,\n DropdownProps,\n DropdownSlots,\n DropdownState,\n} from './Dropdown';\nexport {\n OptionGroup,\n optionGroupClassNames,\n renderOptionGroup_unstable,\n useOptionGroupStyles_unstable,\n useOptionGroup_unstable,\n} from './OptionGroup';\nexport type { OptionGroupProps, OptionGroupSlots, OptionGroupState } from './OptionGroup';\n\nexport { ComboboxField as ComboboxField_unstable, comboboxFieldClassNames } from './ComboboxField';\nexport type { ComboboxFieldProps as ComboboxFieldProps_unstable } from './ComboboxField';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getIndexFromAction = exports.getDropdownActionFromKey = void 0;
|
|
7
|
-
|
|
8
7
|
const keys = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
|
9
8
|
/**
|
|
10
9
|
* Converts a keyboard interaction into a defined action
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
11
|
function getDropdownActionFromKey(e, options = {}) {
|
|
15
12
|
const {
|
|
16
13
|
open = true,
|
|
@@ -22,98 +19,76 @@ function getDropdownActionFromKey(e, options = {}) {
|
|
|
22
19
|
ctrlKey,
|
|
23
20
|
key,
|
|
24
21
|
metaKey
|
|
25
|
-
} = e;
|
|
26
|
-
|
|
22
|
+
} = e;
|
|
23
|
+
// typing action occurs whether open or closed
|
|
27
24
|
if (key.length === 1 && code !== keys.Space && !altKey && !ctrlKey && !metaKey) {
|
|
28
25
|
return 'Type';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
}
|
|
27
|
+
// handle opening the dropdown if closed
|
|
32
28
|
if (!open) {
|
|
33
29
|
if (code === keys.ArrowDown || code === keys.ArrowUp || code === keys.Enter || code === keys.Space) {
|
|
34
30
|
return 'Open';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
}
|
|
32
|
+
// if the dropdown is closed and an action did not match the above, do nothing
|
|
38
33
|
return 'None';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
}
|
|
35
|
+
// select or close actions
|
|
42
36
|
if (code === keys.ArrowUp && altKey || code === keys.Enter || !multiselect && code === keys.Space) {
|
|
43
37
|
return 'CloseSelect';
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
if (multiselect && code === keys.Space) {
|
|
47
40
|
return 'Select';
|
|
48
41
|
}
|
|
49
|
-
|
|
50
42
|
if (code === keys.Escape) {
|
|
51
43
|
return 'Close';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
}
|
|
45
|
+
// navigation interactions
|
|
55
46
|
if (code === keys.ArrowDown) {
|
|
56
47
|
return 'Next';
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
if (code === keys.ArrowUp) {
|
|
60
50
|
return 'Previous';
|
|
61
51
|
}
|
|
62
|
-
|
|
63
52
|
if (code === keys.Home) {
|
|
64
53
|
return 'First';
|
|
65
54
|
}
|
|
66
|
-
|
|
67
55
|
if (code === keys.End) {
|
|
68
56
|
return 'Last';
|
|
69
57
|
}
|
|
70
|
-
|
|
71
58
|
if (code === keys.PageUp) {
|
|
72
59
|
return 'PageUp';
|
|
73
60
|
}
|
|
74
|
-
|
|
75
61
|
if (code === keys.PageDown) {
|
|
76
62
|
return 'PageDown';
|
|
77
63
|
}
|
|
78
|
-
|
|
79
64
|
if (code === keys.Tab) {
|
|
80
65
|
return 'Tab';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
}
|
|
67
|
+
// if nothing matched, return none
|
|
84
68
|
return 'None';
|
|
85
69
|
}
|
|
86
|
-
|
|
87
70
|
exports.getDropdownActionFromKey = getDropdownActionFromKey;
|
|
88
71
|
/**
|
|
89
72
|
* Returns the requested option index from an action
|
|
90
73
|
*/
|
|
91
|
-
|
|
92
74
|
function getIndexFromAction(action, currentIndex, maxIndex) {
|
|
93
75
|
switch (action) {
|
|
94
76
|
case 'Next':
|
|
95
77
|
return Math.min(maxIndex, currentIndex + 1);
|
|
96
78
|
break;
|
|
97
|
-
|
|
98
79
|
case 'Previous':
|
|
99
80
|
return Math.max(0, currentIndex - 1);
|
|
100
|
-
|
|
101
81
|
case 'First':
|
|
102
82
|
return 0;
|
|
103
|
-
|
|
104
83
|
case 'Last':
|
|
105
84
|
return maxIndex;
|
|
106
|
-
|
|
107
85
|
case 'PageDown':
|
|
108
86
|
return Math.min(maxIndex, currentIndex + 10);
|
|
109
|
-
|
|
110
87
|
case 'PageUp':
|
|
111
88
|
return Math.max(0, currentIndex - 10);
|
|
112
|
-
|
|
113
89
|
default:
|
|
114
90
|
return currentIndex;
|
|
115
91
|
}
|
|
116
92
|
}
|
|
117
|
-
|
|
118
93
|
exports.getIndexFromAction = getIndexFromAction;
|
|
119
94
|
//# sourceMappingURL=dropdownKeyActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AA2BA;;;AAGA,SAAgBA,wBAAwB,CACtCC,CAAsC,EACtCC,UAAiC,EAAE;EAEnC,MAAM;IAAEC,IAA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Ef,IAAIb,IAAI,KAAKM,IAAI,CAACQ,MAAM,EAAE;IACxB,OAAO,QAAQ;;EAEjB,IAAId,IAAI,KAAKM,IAAI,CAACS,QAAQ,EAAE;IAC1B,OAAO,UAAU;;EAEnB,IAAIf,IAAI,KAAKM,IAAI,CAACU,GAAG,EAAE;IACrB,OAAO,KAAK;;EAGd;EACA,OAAO,MAAM;AACf;AA3DAC;AA6DA;;;AAGA,SAAgBC,kBAAkB,CAACC,MAAuB,EAAEC,YAAoB,EAAEC,QAAgB;EAChG,QAAQF,MAAM;IACZ,KAAK,MAAM;MACT,OAAOG,IAAI,CAACC,GAAG,CAACF,QAAQ,EAAED,YAAY,GAAG,CAAC,CAAC;MAC3C;IACF,KAAK,UAAU;MACb,OAAOE,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEJ,YAAY,GAAG,CAAC,CAAC;IACtC,KAAK,OAAO;MACV,OAAO,CAAC;IACV,KAAK,MAAM;MACT,OAAOC,QAAQ;IACjB,KAAK,UAAU;MACb,OAAOC,IAAI,CAACC,GAAG,CAACF,QAAQ,EAAED,YAAY,GAAG,EAAE,CAAC;IAC9C,KAAK,QAAQ;MACX,OAAOE,IAAI,CAACE,GAAG,CAAC,CAAC,EAAEJ,YAAY,GAAG,EAAE,CAAC;IACvC;MACE,OAAOA,YAAY;EAAC;AAE1B;AAlBAH","names":["getDropdownActionFromKey","e","options","open","multiselect","code","key","altKey","ctrlKey","metaKey","length","keys","Space","ArrowDown","ArrowUp","Enter","Escape","Home","End","PageUp","PageDown","Tab","exports","getIndexFromAction","action","currentIndex","maxIndex","Math","min","max"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/utils/dropdownKeyActions.ts"],"sourcesContent":["import * as keys from '@fluentui/keyboard-keys';\nimport * as React from 'react';\n\n/**\n * enum of actions available in any type of managed dropdown control\n * e.g. combobox, select, datepicker, menu\n */\nexport type DropdownActions =\n | 'Close'\n | 'CloseSelect'\n | 'First'\n | 'Last'\n | 'Next'\n | 'None'\n | 'Open'\n | 'PageDown'\n | 'PageUp'\n | 'Previous'\n | 'Select'\n | 'Tab'\n | 'Type';\n\nexport interface DropdownActionOptions {\n open?: boolean;\n multiselect?: boolean;\n}\n\n/**\n * Converts a keyboard interaction into a defined action\n */\nexport function getDropdownActionFromKey(\n e: KeyboardEvent | React.KeyboardEvent,\n options: DropdownActionOptions = {},\n): DropdownActions {\n const { open = true, multiselect = false } = options;\n const code = e.key;\n const { altKey, ctrlKey, key, metaKey } = e;\n\n // typing action occurs whether open or closed\n if (key.length === 1 && code !== keys.Space && !altKey && !ctrlKey && !metaKey) {\n return 'Type';\n }\n\n // handle opening the dropdown if closed\n if (!open) {\n if (code === keys.ArrowDown || code === keys.ArrowUp || code === keys.Enter || code === keys.Space) {\n return 'Open';\n }\n\n // if the dropdown is closed and an action did not match the above, do nothing\n return 'None';\n }\n\n // select or close actions\n if ((code === keys.ArrowUp && altKey) || code === keys.Enter || (!multiselect && code === keys.Space)) {\n return 'CloseSelect';\n }\n if (multiselect && code === keys.Space) {\n return 'Select';\n }\n if (code === keys.Escape) {\n return 'Close';\n }\n\n // navigation interactions\n if (code === keys.ArrowDown) {\n return 'Next';\n }\n if (code === keys.ArrowUp) {\n return 'Previous';\n }\n if (code === keys.Home) {\n return 'First';\n }\n if (code === keys.End) {\n return 'Last';\n }\n if (code === keys.PageUp) {\n return 'PageUp';\n }\n if (code === keys.PageDown) {\n return 'PageDown';\n }\n if (code === keys.Tab) {\n return 'Tab';\n }\n\n // if nothing matched, return none\n return 'None';\n}\n\n/**\n * Returns the requested option index from an action\n */\nexport function getIndexFromAction(action: DropdownActions, currentIndex: number, maxIndex: number): number {\n switch (action) {\n case 'Next':\n return Math.min(maxIndex, currentIndex + 1);\n break;\n case 'Previous':\n return Math.max(0, currentIndex - 1);\n case 'First':\n return 0;\n case 'Last':\n return maxIndex;\n case 'PageDown':\n return Math.min(maxIndex, currentIndex + 10);\n case 'PageUp':\n return Math.max(0, currentIndex - 10);\n default:\n return currentIndex;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAaA,iBAAS,GAAG;EACvBC,KAAK,EAAE,MAAM;EACbC,MAAM,EAAE,MAAM;EACdC,KAAK,EAAE;CACR","names":["exports","small","medium","large"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/utils/internalTokens.ts"],"sourcesContent":["export const iconSizes = {\n small: '16px',\n medium: '20px',\n large: '24px',\n};\n"]}
|
|
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useComboboxBaseState = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
|
-
|
|
12
9
|
const useOptionCollection_1 = /*#__PURE__*/require("../utils/useOptionCollection");
|
|
13
|
-
|
|
14
10
|
const useSelection_1 = /*#__PURE__*/require("../utils/useSelection");
|
|
15
11
|
/**
|
|
16
12
|
* State shared between Combobox and Dropdown components
|
|
17
13
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
14
|
const useComboboxBaseState = props => {
|
|
21
15
|
const {
|
|
22
16
|
appearance = 'outline',
|
|
@@ -31,18 +25,18 @@ const useComboboxBaseState = props => {
|
|
|
31
25
|
getOptionAtIndex,
|
|
32
26
|
getOptionsMatchingText
|
|
33
27
|
} = optionCollection;
|
|
34
|
-
const [activeOption, setActiveOption] = React.useState();
|
|
28
|
+
const [activeOption, setActiveOption] = React.useState();
|
|
29
|
+
// track whether keyboard focus outline should be shown
|
|
35
30
|
// tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
const [focusVisible, setFocusVisible] = React.useState(false);
|
|
32
|
+
// track focused state to conditionally render collapsed listbox
|
|
39
33
|
const [hasFocus, setHasFocus] = React.useState(false);
|
|
40
34
|
const ignoreNextBlur = React.useRef(false);
|
|
41
35
|
const selectionState = useSelection_1.useSelection(props);
|
|
42
36
|
const {
|
|
43
37
|
selectedOptions
|
|
44
|
-
} = selectionState;
|
|
45
|
-
|
|
38
|
+
} = selectionState;
|
|
39
|
+
// calculate value based on props, internal value changes, and selected options
|
|
46
40
|
const isFirstMount = react_utilities_1.useFirstMount();
|
|
47
41
|
const [controllableValue, setValue] = react_utilities_1.useControllableState({
|
|
48
42
|
state: props.value,
|
|
@@ -52,53 +46,50 @@ const useComboboxBaseState = props => {
|
|
|
52
46
|
// don't compute the value if it is defined through props or setValue,
|
|
53
47
|
if (controllableValue !== undefined) {
|
|
54
48
|
return controllableValue;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
}
|
|
50
|
+
// handle defaultValue here, so it is overridden by selection
|
|
58
51
|
if (isFirstMount && props.defaultValue !== undefined) {
|
|
59
52
|
return props.defaultValue;
|
|
60
53
|
}
|
|
61
|
-
|
|
62
54
|
if (multiselect) {
|
|
63
55
|
// editable inputs should not display multiple selected options in the input as text
|
|
64
56
|
return editable ? '' : selectedOptions.join(', ');
|
|
65
57
|
}
|
|
66
|
-
|
|
67
58
|
return selectedOptions[0];
|
|
68
|
-
}, [controllableValue, editable, isFirstMount, multiselect, props.defaultValue, selectedOptions]);
|
|
69
|
-
|
|
59
|
+
}, [controllableValue, editable, isFirstMount, multiselect, props.defaultValue, selectedOptions]);
|
|
60
|
+
// Handle open state, which is shared with options in context
|
|
70
61
|
const [open, setOpenState] = react_utilities_1.useControllableState({
|
|
71
62
|
state: props.open,
|
|
72
63
|
defaultState: props.defaultOpen,
|
|
73
64
|
initialState: false
|
|
74
65
|
});
|
|
75
|
-
|
|
76
|
-
const setOpen = (event, newState) => {
|
|
66
|
+
const setOpen = React.useCallback((event, newState) => {
|
|
77
67
|
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {
|
|
78
68
|
open: newState
|
|
79
69
|
});
|
|
80
70
|
setOpenState(newState);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
}, [onOpenChange, setOpenState]);
|
|
72
|
+
// update active option based on change in open state
|
|
84
73
|
React.useEffect(() => {
|
|
85
74
|
if (open && !activeOption) {
|
|
86
|
-
// if there is a
|
|
87
|
-
if (selectedOptions.length > 0) {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
}
|
|
75
|
+
// if it is single-select and there is a selected option, start at the selected option
|
|
76
|
+
if (!multiselect && selectedOptions.length > 0) {
|
|
77
|
+
const selectedOption = getOptionsMatchingText(v => v === selectedOptions[0]).pop();
|
|
78
|
+
selectedOption && setActiveOption(selectedOption);
|
|
79
|
+
}
|
|
80
|
+
// default to starting at the first option
|
|
91
81
|
else {
|
|
92
82
|
setActiveOption(getOptionAtIndex(0));
|
|
93
83
|
}
|
|
94
84
|
} else if (!open) {
|
|
95
85
|
// reset the active option when closing
|
|
96
86
|
setActiveOption(undefined);
|
|
97
|
-
}
|
|
87
|
+
}
|
|
88
|
+
// this should only be run in response to changes in the open state
|
|
98
89
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
-
|
|
100
90
|
}, [open]);
|
|
101
|
-
return {
|
|
91
|
+
return {
|
|
92
|
+
...optionCollection,
|
|
102
93
|
...selectionState,
|
|
103
94
|
activeOption,
|
|
104
95
|
appearance,
|
|
@@ -116,6 +107,5 @@ const useComboboxBaseState = props => {
|
|
|
116
107
|
value
|
|
117
108
|
};
|
|
118
109
|
};
|
|
119
|
-
|
|
120
110
|
exports.useComboboxBaseState = useComboboxBaseState;
|
|
121
111
|
//# sourceMappingURL=useComboboxBaseState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AAGA;;;AAGO,MAAMA,oBAAoB,GAAIC,KAAiD,IAAuB;EAC3G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ZV,UAAU;IACVc,YAAY;IACZE,QAAQ;IACRE,cAAc;IACdhB,WAAW;IACXgC,IAAI;IACJvB,eAAe;IACfI,eAAe;IACfE,WAAW;IACXqB,OAAO;IACPZ,QAAQ;IACRrB,IAAI;IACJuB;GACD;AACH,CAAC;AA1GYmB,4BAAoB","names":["useComboboxBaseState","props","appearance","editable","inlinePopup","multiselect","onOpenChange","size","optionCollection","useOptionCollection_1","getOptionAtIndex","getOptionsMatchingText","activeOption","setActiveOption","React","useState","focusVisible","setFocusVisible","hasFocus","setHasFocus","ignoreNextBlur","useRef","selectionState","useSelection_1","selectedOptions","isFirstMount","react_utilities_1","controllableValue","setValue","state","value","initialState","undefined","useMemo","defaultValue","join","open","setOpenState","defaultState","defaultOpen","setOpen","useCallback","event","newState","useEffect","length","selectedOption","v","pop","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/utils/useComboboxBaseState.ts"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState, useFirstMount } from '@fluentui/react-utilities';\nimport { useOptionCollection } from '../utils/useOptionCollection';\nimport { OptionValue } from '../utils/OptionCollection.types';\nimport { useSelection } from '../utils/useSelection';\nimport type { ComboboxBaseProps, ComboboxBaseOpenEvents, ComboboxBaseState } from './ComboboxBase.types';\n\n/**\n * State shared between Combobox and Dropdown components\n */\nexport const useComboboxBaseState = (props: ComboboxBaseProps & { editable?: boolean }): ComboboxBaseState => {\n const {\n appearance = 'outline',\n editable = false,\n inlinePopup = false,\n multiselect,\n onOpenChange,\n size = 'medium',\n } = props;\n\n const optionCollection = useOptionCollection();\n const { getOptionAtIndex, getOptionsMatchingText } = optionCollection;\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 // track focused state to conditionally render collapsed listbox\n const [hasFocus, setHasFocus] = React.useState(false);\n\n const ignoreNextBlur = React.useRef(false);\n\n const selectionState = useSelection(props);\n const { selectedOptions } = selectionState;\n\n // calculate value based on props, internal value changes, and selected options\n const isFirstMount = useFirstMount();\n const [controllableValue, setValue] = useControllableState({\n state: props.value,\n initialState: undefined,\n });\n\n const value = React.useMemo(() => {\n // don't compute the value if it is defined through props or setValue,\n if (controllableValue !== undefined) {\n return controllableValue;\n }\n\n // handle defaultValue here, so it is overridden by selection\n if (isFirstMount && props.defaultValue !== undefined) {\n return props.defaultValue;\n }\n\n if (multiselect) {\n // editable inputs should not display multiple selected options in the input as text\n return editable ? '' : selectedOptions.join(', ');\n }\n\n return selectedOptions[0];\n }, [controllableValue, editable, isFirstMount, multiselect, props.defaultValue, selectedOptions]);\n\n // Handle open state, which is shared with options in context\n const [open, setOpenState] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false,\n });\n\n const setOpen = React.useCallback(\n (event: ComboboxBaseOpenEvents, newState: boolean) => {\n onOpenChange?.(event, { open: newState });\n setOpenState(newState);\n },\n [onOpenChange, setOpenState],\n );\n\n // update active option based on change in open state\n React.useEffect(() => {\n if (open && !activeOption) {\n // if it is single-select and there is a selected option, start at the selected option\n if (!multiselect && selectedOptions.length > 0) {\n const selectedOption = getOptionsMatchingText(v => v === selectedOptions[0]).pop();\n selectedOption && setActiveOption(selectedOption);\n }\n // default to starting at the first option\n else {\n setActiveOption(getOptionAtIndex(0));\n }\n } else if (!open) {\n // reset the active option when closing\n setActiveOption(undefined);\n }\n // this should only be run in response to changes in the open state\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return {\n ...optionCollection,\n ...selectionState,\n activeOption,\n appearance,\n focusVisible,\n hasFocus,\n ignoreNextBlur,\n inlinePopup,\n open,\n setActiveOption,\n setFocusVisible,\n setHasFocus,\n setOpen,\n setValue,\n size,\n value,\n };\n};\n"]}
|
|
@@ -4,16 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useComboboxPopup = void 0;
|
|
7
|
-
|
|
8
7
|
const react_positioning_1 = /*#__PURE__*/require("@fluentui/react-positioning");
|
|
9
|
-
|
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
|
-
|
|
12
9
|
function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
|
|
13
10
|
const {
|
|
14
11
|
positioning
|
|
15
|
-
} = props;
|
|
16
|
-
|
|
12
|
+
} = props;
|
|
13
|
+
// popper options
|
|
17
14
|
const popperOptions = {
|
|
18
15
|
position: 'below',
|
|
19
16
|
align: 'start',
|
|
@@ -28,13 +25,14 @@ function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
|
|
|
28
25
|
containerRef
|
|
29
26
|
} = react_positioning_1.usePositioning(popperOptions);
|
|
30
27
|
const listboxRef = react_utilities_1.useMergedRefs(listboxShorthand === null || listboxShorthand === void 0 ? void 0 : listboxShorthand.ref, containerRef);
|
|
31
|
-
const listbox = listboxShorthand && {
|
|
28
|
+
const listbox = listboxShorthand && {
|
|
29
|
+
...listboxShorthand,
|
|
32
30
|
ref: listboxRef
|
|
33
31
|
};
|
|
34
|
-
return [{
|
|
32
|
+
return [{
|
|
33
|
+
...triggerShorthand,
|
|
35
34
|
ref: react_utilities_1.useMergedRefs(triggerShorthand === null || triggerShorthand === void 0 ? void 0 : triggerShorthand.ref, targetRef)
|
|
36
35
|
}, listbox];
|
|
37
36
|
}
|
|
38
|
-
|
|
39
37
|
exports.useComboboxPopup = useComboboxPopup;
|
|
40
38
|
//# sourceMappingURL=useComboboxPopup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAeA,SAAgBA,gBAAgB,CAC9BC,KAAwB,EACxBC,gBAAqF,EACrFC,gBAAyD;EAKzD,MAAM;IAAEC;EAAW,CAAE,GAAGH,KAAK;EAE7B;EACA,MAAMI,aAAa,GAAG;IACpBC,QAAQ,EAAE,OAAgB;IAC1BC,KAAK,EAAE,OAAgB;IACvBC,MAAM,EAAE;MAAEC,SAAS,EAAE,CAAC;MAAEC,QAAQ,EAAE;IAAC,CAAE;IACrC,GAAGC,+CAA2B,CAACP,WAAW;GAC3C;EAED,MAAM;IAAEQ,SAAS;IAAEC;EAAY,CAAE,GAAGF,kCAAc,CAACN,aAAa,CAAC;EAEjE,MAAMS,UAAU,GAAGC,+BAAa,CAACZ,gBAAgB,aAAhBA,gBAAgB,uBAAhBA,gBAAgB,CAAEa,GAAG,EAAEH,YAAY,CAAC;EACrE,MAAMI,OAAO,GAAGd,gBAAgB,IAAI;IAAE,GAAGA,gBAAgB;IAAEa,GAAG,EAAEF;EAAU,CAAE;EAE5E,OAAO,CAAC;IAAE,GAAGZ,gBAAgB;IAAEc,GAAG,EAAED,+BAAa,CAACb,gBAAgB,aAAhBA,gBAAgB,uBAAhBA,gBAAgB,CAAEc,GAAG,EAAEJ,SAAS;EAAC,CAAE,EAAEK,OAAO,CAAC;AACjG;AAxBAC","names":["useComboboxPopup","props","triggerShorthand","listboxShorthand","positioning","popperOptions","position","align","offset","crossAxis","mainAxis","react_positioning_1","targetRef","containerRef","listboxRef","react_utilities_1","ref","listbox","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/utils/useComboboxPopup.ts"],"sourcesContent":["import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { ExtractSlotProps, Slot, useMergedRefs } from '@fluentui/react-utilities';\nimport type { ComboboxBaseProps } from './ComboboxBase.types';\nimport { Listbox } from '../components/Listbox/Listbox';\n\nexport function useComboboxPopup(\n props: ComboboxBaseProps,\n triggerShorthand?: ExtractSlotProps<Slot<'button'>>,\n listboxShorthand?: ExtractSlotProps<Slot<typeof Listbox>>,\n): [trigger: ExtractSlotProps<Slot<'button'>>, listbox?: ExtractSlotProps<Slot<typeof Listbox>>];\nexport function useComboboxPopup(\n props: ComboboxBaseProps,\n triggerShorthand?: ExtractSlotProps<Slot<'input'>>,\n listboxShorthand?: ExtractSlotProps<Slot<typeof Listbox>>,\n): [trigger: ExtractSlotProps<Slot<'input'>>, listbox?: ExtractSlotProps<Slot<typeof Listbox>>];\n\nexport function useComboboxPopup(\n props: ComboboxBaseProps,\n triggerShorthand?: ExtractSlotProps<Slot<'input'>> | ExtractSlotProps<Slot<'button'>>,\n listboxShorthand?: ExtractSlotProps<Slot<typeof Listbox>>,\n): [\n trigger: ExtractSlotProps<Slot<'input'>> | ExtractSlotProps<Slot<'button'>>,\n listbox?: ExtractSlotProps<Slot<typeof Listbox>>,\n] {\n const { positioning } = props;\n\n // popper options\n const popperOptions = {\n position: 'below' as const,\n align: 'start' as const,\n offset: { crossAxis: 0, mainAxis: 2 },\n ...resolvePositioningShorthand(positioning),\n };\n\n const { targetRef, containerRef } = usePositioning(popperOptions);\n\n const listboxRef = useMergedRefs(listboxShorthand?.ref, containerRef);\n const listbox = listboxShorthand && { ...listboxShorthand, ref: listboxRef };\n\n return [{ ...triggerShorthand, ref: useMergedRefs(triggerShorthand?.ref, targetRef) }, listbox];\n}\n"]}
|