@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.
- package/CHANGELOG.json +848 -1
- package/CHANGELOG.md +248 -2
- package/README.md +1 -3
- package/dist/index.d.ts +62 -11
- package/lib/Combobox.js.map +1 -1
- package/lib/ComboboxField.js +2 -0
- package/lib/ComboboxField.js.map +1 -0
- 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 +0 -1
- package/lib/components/Combobox/Combobox.js.map +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 +10 -6
- package/lib/components/Combobox/renderCombobox.js.map +1 -1
- package/lib/components/Combobox/useCombobox.js +107 -70
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Combobox/useComboboxStyles.js +246 -185
- package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib/components/ComboboxField/ComboboxField.js +8 -0
- package/lib/components/ComboboxField/ComboboxField.js.map +1 -0
- package/lib/components/ComboboxField/index.js +2 -0
- package/lib/components/ComboboxField/index.js.map +1 -0
- package/lib/components/Dropdown/Dropdown.js +0 -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 +10 -6
- package/lib/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +25 -36
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdownStyles.js +236 -176
- 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/Listbox.types.js.map +1 -1
- package/lib/components/Listbox/index.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 +15 -17
- package/lib/components/Listbox/useListbox.js.map +1 -1
- package/lib/components/Listbox/useListboxStyles.js +16 -20
- 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/Option.types.js.map +1 -1
- package/lib/components/Option/index.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 +46 -39
- package/lib/components/Option/useOption.js.map +1 -1
- package/lib/components/Option/useOptionStyles.js +101 -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/OptionGroup.types.js.map +1 -1
- package/lib/components/OptionGroup/index.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 +9 -11
- package/lib/contexts/ComboboxContext.js.map +1 -1
- package/lib/contexts/ListboxContext.js +7 -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 +6 -0
- package/lib/index.js.map +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.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 +29 -30
- 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 +13 -23
- package/lib/utils/useOptionCollection.js.map +1 -1
- package/lib/utils/useScrollOptionsIntoView.js +36 -0
- package/lib/utils/useScrollOptionsIntoView.js.map +1 -0
- package/lib/utils/useSelection.js +9 -12
- package/lib/utils/useSelection.js.map +1 -1
- package/lib/utils/useTriggerListboxSlots.js +34 -40
- package/lib/utils/useTriggerListboxSlots.js.map +1 -1
- package/lib-amd/Combobox.js +6 -0
- package/lib-amd/Combobox.js.map +1 -0
- package/lib-amd/ComboboxField.js +6 -0
- package/lib-amd/ComboboxField.js.map +1 -0
- package/lib-amd/Dropdown.js +6 -0
- package/lib-amd/Dropdown.js.map +1 -0
- package/lib-amd/Listbox.js +6 -0
- package/lib-amd/Listbox.js.map +1 -0
- package/lib-amd/Option.js +6 -0
- package/lib-amd/Option.js.map +1 -0
- package/lib-amd/OptionGroup.js +6 -0
- package/lib-amd/OptionGroup.js.map +1 -0
- package/lib-amd/components/Combobox/Combobox.js +16 -0
- package/lib-amd/components/Combobox/Combobox.js.map +1 -0
- package/lib-amd/components/Combobox/Combobox.types.js +5 -0
- package/lib-amd/components/Combobox/Combobox.types.js.map +1 -0
- package/lib-amd/components/Combobox/index.js +10 -0
- package/lib-amd/components/Combobox/index.js.map +1 -0
- package/lib-amd/components/Combobox/renderCombobox.js +20 -0
- package/lib-amd/components/Combobox/renderCombobox.js.map +1 -0
- package/lib-amd/components/Combobox/useCombobox.js +206 -0
- package/lib-amd/components/Combobox/useCombobox.js.map +1 -0
- package/lib-amd/components/Combobox/useComboboxStyles.js +152 -0
- package/lib-amd/components/Combobox/useComboboxStyles.js.map +1 -0
- package/lib-amd/components/ComboboxField/ComboboxField.js +10 -0
- package/lib-amd/components/ComboboxField/ComboboxField.js.map +1 -0
- package/lib-amd/components/ComboboxField/index.js +6 -0
- package/lib-amd/components/ComboboxField/index.js.map +1 -0
- package/lib-amd/components/Dropdown/Dropdown.js +16 -0
- package/lib-amd/components/Dropdown/Dropdown.js.map +1 -0
- package/lib-amd/components/Dropdown/Dropdown.types.js +5 -0
- package/lib-amd/components/Dropdown/Dropdown.types.js.map +1 -0
- package/lib-amd/components/Dropdown/index.js +10 -0
- package/lib-amd/components/Dropdown/index.js.map +1 -0
- package/lib-amd/components/Dropdown/renderDropdown.js +21 -0
- package/lib-amd/components/Dropdown/renderDropdown.js.map +1 -0
- package/lib-amd/components/Dropdown/useDropdown.js +121 -0
- package/lib-amd/components/Dropdown/useDropdown.js.map +1 -0
- package/lib-amd/components/Dropdown/useDropdownStyles.js +127 -0
- package/lib-amd/components/Dropdown/useDropdownStyles.js.map +1 -0
- package/lib-amd/components/Listbox/Listbox.js +16 -0
- package/lib-amd/components/Listbox/Listbox.js.map +1 -0
- package/lib-amd/components/Listbox/Listbox.types.js +5 -0
- package/lib-amd/components/Listbox/Listbox.types.js.map +1 -0
- package/lib-amd/components/Listbox/index.js +10 -0
- package/lib-amd/components/Listbox/index.js.map +1 -0
- package/lib-amd/components/Listbox/renderListbox.js +15 -0
- package/lib-amd/components/Listbox/renderListbox.js.map +1 -0
- package/lib-amd/components/Listbox/useListbox.js +80 -0
- package/lib-amd/components/Listbox/useListbox.js.map +1 -0
- package/lib-amd/components/Listbox/useListboxStyles.js +24 -0
- package/lib-amd/components/Listbox/useListboxStyles.js.map +1 -0
- package/lib-amd/components/Option/Option.js +15 -0
- package/lib-amd/components/Option/Option.js.map +1 -0
- package/lib-amd/components/Option/Option.types.js +5 -0
- package/lib-amd/components/Option/Option.types.js.map +1 -0
- package/lib-amd/components/Option/index.js +10 -0
- package/lib-amd/components/Option/index.js.map +1 -0
- package/lib-amd/components/Option/renderOption.js +16 -0
- package/lib-amd/components/Option/renderOption.js.map +1 -0
- package/lib-amd/components/Option/useOption.js +117 -0
- package/lib-amd/components/Option/useOption.js.map +1 -0
- package/lib-amd/components/Option/useOptionStyles.js +73 -0
- package/lib-amd/components/Option/useOptionStyles.js.map +1 -0
- package/lib-amd/components/OptionGroup/OptionGroup.js +15 -0
- package/lib-amd/components/OptionGroup/OptionGroup.js.map +1 -0
- package/lib-amd/components/OptionGroup/OptionGroup.types.js +5 -0
- package/lib-amd/components/OptionGroup/OptionGroup.types.js.map +1 -0
- package/lib-amd/components/OptionGroup/index.js +10 -0
- package/lib-amd/components/OptionGroup/index.js.map +1 -0
- package/lib-amd/components/OptionGroup/renderOptionGroup.js +16 -0
- package/lib-amd/components/OptionGroup/renderOptionGroup.js.map +1 -0
- package/lib-amd/components/OptionGroup/useOptionGroup.js +33 -0
- package/lib-amd/components/OptionGroup/useOptionGroup.js.map +1 -0
- package/lib-amd/components/OptionGroup/useOptionGroupStyles.js +34 -0
- package/lib-amd/components/OptionGroup/useOptionGroupStyles.js.map +1 -0
- package/lib-amd/contexts/ComboboxContext.js +28 -0
- package/lib-amd/contexts/ComboboxContext.js.map +1 -0
- package/lib-amd/contexts/ListboxContext.js +23 -0
- package/lib-amd/contexts/ListboxContext.js.map +1 -0
- package/lib-amd/contexts/useComboboxContextValues.js +23 -0
- package/lib-amd/contexts/useComboboxContextValues.js.map +1 -0
- package/lib-amd/contexts/useListboxContextValues.js +24 -0
- package/lib-amd/contexts/useListboxContextValues.js.map +1 -0
- package/lib-amd/index.js +37 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/utils/ComboboxBase.types.js +5 -0
- package/lib-amd/utils/ComboboxBase.types.js.map +1 -0
- package/lib-amd/utils/OptionCollection.types.js +5 -0
- package/lib-amd/utils/OptionCollection.types.js.map +1 -0
- package/lib-amd/utils/Selection.types.js +5 -0
- package/lib-amd/utils/Selection.types.js.map +1 -0
- package/lib-amd/utils/dropdownKeyActions.js +85 -0
- package/lib-amd/utils/dropdownKeyActions.js.map +1 -0
- package/lib-amd/utils/internalTokens.js +11 -0
- package/lib-amd/utils/internalTokens.js.map +1 -0
- package/lib-amd/utils/useComboboxBaseState.js +76 -0
- package/lib-amd/utils/useComboboxBaseState.js.map +1 -0
- package/lib-amd/utils/useComboboxPopup.js +16 -0
- package/lib-amd/utils/useComboboxPopup.js.map +1 -0
- package/lib-amd/utils/useOptionCollection.js +65 -0
- package/lib-amd/utils/useOptionCollection.js.map +1 -0
- package/lib-amd/utils/useScrollOptionsIntoView.js +33 -0
- package/lib-amd/utils/useScrollOptionsIntoView.js.map +1 -0
- package/lib-amd/utils/useSelection.js +42 -0
- package/lib-amd/utils/useSelection.js.map +1 -0
- package/lib-amd/utils/useTriggerListboxSlots.js +104 -0
- package/lib-amd/utils/useTriggerListboxSlots.js.map +1 -0
- package/lib-commonjs/Combobox.js +0 -2
- package/lib-commonjs/Combobox.js.map +1 -1
- package/lib-commonjs/ComboboxField.js +8 -0
- package/lib-commonjs/ComboboxField.js.map +1 -0
- 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 +106 -78
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useComboboxStyles.js +245 -189
- package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib-commonjs/components/ComboboxField/ComboboxField.js +14 -0
- package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -0
- package/lib-commonjs/components/ComboboxField/index.js +8 -0
- package/lib-commonjs/components/ComboboxField/index.js.map +1 -0
- 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 +25 -47
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js +235 -180
- 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 +14 -25
- package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListboxStyles.js +16 -24
- 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 +45 -45
- package/lib-commonjs/components/Option/useOption.js.map +1 -1
- package/lib-commonjs/components/Option/useOptionStyles.js +101 -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 +10 -14
- package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
- package/lib-commonjs/contexts/ListboxContext.js +8 -12
- 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 +43 -11
- 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 +29 -36
- 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 +13 -26
- package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
- package/lib-commonjs/utils/useScrollOptionsIntoView.js +43 -0
- package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -0
- package/lib-commonjs/utils/useSelection.js +9 -15
- package/lib-commonjs/utils/useSelection.js.map +1 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js +33 -44
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
- package/package.json +23 -22
- package/Spec-migration.md +0 -13
- package/Spec.md +0 -520
|
@@ -4,17 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderListbox_unstable = 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 ListboxContext_1 = /*#__PURE__*/require("../../contexts/ListboxContext");
|
|
13
10
|
/**
|
|
14
11
|
* Render the final JSX of Listbox
|
|
15
12
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
13
|
const renderListbox_unstable = (state, contextValues) => {
|
|
19
14
|
const {
|
|
20
15
|
slots,
|
|
@@ -22,9 +17,9 @@ const renderListbox_unstable = (state, contextValues) => {
|
|
|
22
17
|
} = react_utilities_1.getSlots(state);
|
|
23
18
|
return React.createElement(ListboxContext_1.ListboxContext.Provider, {
|
|
24
19
|
value: contextValues.listbox
|
|
25
|
-
}, React.createElement(slots.root, {
|
|
20
|
+
}, React.createElement(slots.root, {
|
|
21
|
+
...slotProps.root
|
|
26
22
|
}));
|
|
27
23
|
};
|
|
28
|
-
|
|
29
24
|
exports.renderListbox_unstable = renderListbox_unstable;
|
|
30
25
|
//# sourceMappingURL=renderListbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAEA;AAEA;;;AAGO,MAAMA,sBAAsB,GAAG,CAACC,KAAmB,EAAEC,aAAmC,KAAI;EACjG,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAeJ,KAAK,CAAC;EAE1D,OACEK,oBAACC,+BAAc,CAACC,QAAQ;IAACC,KAAK,EAAEP,aAAa,CAACQ;EAAO,GACnDJ,oBAACH,KAAK,CAACQ,IAAI;IAAA,GAAKP,SAAS,CAACO;EAAI,EAAI,CACV;AAE9B,CAAC;AARYC,8BAAsB","names":["renderListbox_unstable","state","contextValues","slots","slotProps","react_utilities_1","React","ListboxContext_1","Provider","value","listbox","root","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Listbox/renderListbox.tsx"],"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"]}
|
|
@@ -4,20 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useListbox_unstable = 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 react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
|
13
|
-
|
|
14
|
-
const useSelection_1 = /*#__PURE__*/require("../../utils/useSelection");
|
|
15
|
-
|
|
16
10
|
const dropdownKeyActions_1 = /*#__PURE__*/require("../../utils/dropdownKeyActions");
|
|
17
|
-
|
|
18
|
-
const ComboboxContext_1 = /*#__PURE__*/require("../../contexts/ComboboxContext");
|
|
19
|
-
|
|
20
11
|
const useOptionCollection_1 = /*#__PURE__*/require("../../utils/useOptionCollection");
|
|
12
|
+
const useScrollOptionsIntoView_1 = /*#__PURE__*/require("../../utils/useScrollOptionsIntoView");
|
|
13
|
+
const useSelection_1 = /*#__PURE__*/require("../../utils/useSelection");
|
|
14
|
+
const ComboboxContext_1 = /*#__PURE__*/require("../../contexts/ComboboxContext");
|
|
21
15
|
/**
|
|
22
16
|
* Create the state required to render Listbox.
|
|
23
17
|
*
|
|
@@ -27,8 +21,6 @@ const useOptionCollection_1 = /*#__PURE__*/require("../../utils/useOptionCollect
|
|
|
27
21
|
* @param props - props from this instance of Listbox
|
|
28
22
|
* @param ref - reference to root HTMLElement of Listbox
|
|
29
23
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
24
|
const useListbox_unstable = (props, ref) => {
|
|
33
25
|
const {
|
|
34
26
|
multiselect
|
|
@@ -40,14 +32,14 @@ const useListbox_unstable = (props, ref) => {
|
|
|
40
32
|
getIndexOfId
|
|
41
33
|
} = optionCollection;
|
|
42
34
|
const {
|
|
35
|
+
clearSelection,
|
|
43
36
|
selectedOptions,
|
|
44
37
|
selectOption
|
|
45
38
|
} = useSelection_1.useSelection(props);
|
|
46
|
-
const [activeOption, setActiveOption] = React.useState();
|
|
39
|
+
const [activeOption, setActiveOption] = React.useState();
|
|
40
|
+
// track whether keyboard focus outline should be shown
|
|
47
41
|
// tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move
|
|
48
|
-
|
|
49
42
|
const [focusVisible, setFocusVisible] = React.useState(false);
|
|
50
|
-
|
|
51
43
|
const onKeyDown = event => {
|
|
52
44
|
const action = dropdownKeyActions_1.getDropdownActionFromKey(event, {
|
|
53
45
|
open: true
|
|
@@ -55,17 +47,14 @@ const useListbox_unstable = (props, ref) => {
|
|
|
55
47
|
const maxIndex = getCount() - 1;
|
|
56
48
|
const activeIndex = activeOption ? getIndexOfId(activeOption.id) : -1;
|
|
57
49
|
let newIndex = activeIndex;
|
|
58
|
-
|
|
59
50
|
switch (action) {
|
|
60
51
|
case 'Select':
|
|
61
52
|
case 'CloseSelect':
|
|
62
53
|
activeOption && selectOption(event, activeOption);
|
|
63
54
|
break;
|
|
64
|
-
|
|
65
55
|
default:
|
|
66
56
|
newIndex = dropdownKeyActions_1.getIndexFromAction(action, activeIndex, maxIndex);
|
|
67
57
|
}
|
|
68
|
-
|
|
69
58
|
if (newIndex !== activeIndex) {
|
|
70
59
|
// prevent default page scroll/keyboard action if the index changed
|
|
71
60
|
event.preventDefault();
|
|
@@ -73,19 +62,17 @@ const useListbox_unstable = (props, ref) => {
|
|
|
73
62
|
setFocusVisible(true);
|
|
74
63
|
}
|
|
75
64
|
};
|
|
76
|
-
|
|
77
65
|
const onMouseOver = event => {
|
|
78
66
|
setFocusVisible(false);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
|
|
67
|
+
};
|
|
68
|
+
// get state from parent combobox, if it exists
|
|
82
69
|
const hasComboboxContext = react_context_selector_1.useHasParentContext(ComboboxContext_1.ComboboxContext);
|
|
83
70
|
const comboboxActiveOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.activeOption);
|
|
84
71
|
const comboboxFocusVisible = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.focusVisible);
|
|
85
72
|
const comboboxSelectedOptions = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.selectedOptions);
|
|
86
73
|
const comboboxSelectOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.selectOption);
|
|
87
|
-
const comboboxSetActiveOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.setActiveOption);
|
|
88
|
-
|
|
74
|
+
const comboboxSetActiveOption = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.setActiveOption);
|
|
75
|
+
// without a parent combobox context, provide values directly from Listbox
|
|
89
76
|
const optionContextValues = hasComboboxContext ? {
|
|
90
77
|
activeOption: comboboxActiveOption,
|
|
91
78
|
focusVisible: comboboxFocusVisible,
|
|
@@ -105,20 +92,22 @@ const useListbox_unstable = (props, ref) => {
|
|
|
105
92
|
},
|
|
106
93
|
root: react_utilities_1.getNativeElementProps('div', {
|
|
107
94
|
ref,
|
|
108
|
-
role: 'listbox',
|
|
95
|
+
role: multiselect ? 'menu' : 'listbox',
|
|
109
96
|
'aria-activedescendant': hasComboboxContext ? undefined : activeOption === null || activeOption === void 0 ? void 0 : activeOption.id,
|
|
110
97
|
'aria-multiselectable': multiselect,
|
|
111
98
|
tabIndex: 0,
|
|
112
99
|
...props
|
|
113
100
|
}),
|
|
114
101
|
multiselect,
|
|
102
|
+
clearSelection,
|
|
115
103
|
...optionCollection,
|
|
116
104
|
...optionContextValues
|
|
117
105
|
};
|
|
106
|
+
const scrollContainerRef = useScrollOptionsIntoView_1.useScrollOptionsIntoView(state);
|
|
107
|
+
state.root.ref = react_utilities_1.useMergedRefs(state.root.ref, scrollContainerRef);
|
|
118
108
|
state.root.onKeyDown = react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(state.root.onKeyDown, onKeyDown));
|
|
119
109
|
state.root.onMouseOver = react_utilities_1.useEventCallback(react_utilities_1.mergeCallbacks(state.root.onMouseOver, onMouseOver));
|
|
120
110
|
return state;
|
|
121
111
|
};
|
|
122
|
-
|
|
123
112
|
exports.useListbox_unstable = useListbox_unstable;
|
|
124
113
|
//# sourceMappingURL=useListbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"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","names":["useListbox_unstable","props","ref","multiselect","optionCollection","useOptionCollection_1","getCount","getOptionAtIndex","getIndexOfId","clearSelection","selectedOptions","selectOption","useSelection_1","activeOption","setActiveOption","React","useState","focusVisible","setFocusVisible","onKeyDown","event","action","dropdownKeyActions_1","open","maxIndex","activeIndex","id","newIndex","preventDefault","onMouseOver","hasComboboxContext","react_context_selector_1","ComboboxContext_1","comboboxActiveOption","ctx","comboboxFocusVisible","comboboxSelectedOptions","comboboxSelectOption","comboboxSetActiveOption","optionContextValues","state","components","root","react_utilities_1","role","undefined","tabIndex","scrollContainerRef","useScrollOptionsIntoView_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Listbox/useListbox.ts"],"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"]}
|
|
@@ -4,49 +4,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useListboxStyles_unstable = exports.listboxClassNames = void 0;
|
|
7
|
-
|
|
8
7
|
const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
|
|
9
|
-
|
|
10
8
|
const react_1 = /*#__PURE__*/require("@griffel/react");
|
|
11
|
-
|
|
12
9
|
exports.listboxClassNames = {
|
|
13
10
|
root: 'fui-Listbox'
|
|
14
11
|
};
|
|
15
12
|
/**
|
|
16
13
|
* Styles for the root slot
|
|
17
14
|
*/
|
|
18
|
-
|
|
19
15
|
const useStyles = /*#__PURE__*/react_1.__styles({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
"Belr9w4": "fiut8dr"
|
|
16
|
+
root: {
|
|
17
|
+
De3pzq: "fxugw4r",
|
|
18
|
+
B7ck84d: "f1ewtqcl",
|
|
19
|
+
mc9l5x: "f22iagw",
|
|
20
|
+
Beiy3e4: "f1vx9l62",
|
|
21
|
+
Bf4jedk: "f3hsy1e",
|
|
22
|
+
Bmxbyg5: "f5zp4f",
|
|
23
|
+
Bpd4iqm: "fpvhumw",
|
|
24
|
+
oeaueh: "f1yog68k",
|
|
25
|
+
Bw0xxkn: "f13sgyd8",
|
|
26
|
+
z8tnut: "f1x4af0m",
|
|
27
|
+
z189sj: ["f7x41pl", "fruq291"],
|
|
28
|
+
Byoj8tv: "fd55psn",
|
|
29
|
+
uwmqm3: ["fruq291", "f7x41pl"],
|
|
30
|
+
Belr9w4: "fiut8dr"
|
|
36
31
|
}
|
|
37
32
|
}, {
|
|
38
|
-
|
|
33
|
+
d: [".fxugw4r{background-color:var(--colorNeutralBackground1);}", ".f1ewtqcl{box-sizing:border-box;}", ".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".f3hsy1e{min-width:160px;}", ".f5zp4f{overflow-y:auto;}", ".fpvhumw{outline-width:1px;}", ".f1yog68k{outline-style:solid;}", ".f13sgyd8{outline-color:var(--colorTransparentStroke);}", ".f1x4af0m{padding-top:var(--spacingHorizontalXS);}", ".f7x41pl{padding-right:var(--spacingHorizontalXS);}", ".fruq291{padding-left:var(--spacingHorizontalXS);}", ".fd55psn{padding-bottom:var(--spacingHorizontalXS);}", ".fiut8dr{row-gap:var(--spacingHorizontalXXS);}"]
|
|
39
34
|
});
|
|
40
35
|
/**
|
|
41
36
|
* Apply styling to the Listbox slots based on the state
|
|
42
37
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
38
|
const useListboxStyles_unstable = state => {
|
|
46
39
|
const styles = useStyles();
|
|
47
40
|
state.root.className = react_1.mergeClasses(exports.listboxClassNames.root, styles.root, state.root.className);
|
|
48
41
|
return state;
|
|
49
42
|
};
|
|
50
|
-
|
|
51
43
|
exports.useListboxStyles_unstable = useListboxStyles_unstable;
|
|
52
44
|
//# sourceMappingURL=useListboxStyles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AAEA;AAGaA,yBAAiB,GAAiC;EAC7DC,IAAI,EAAE;CACP;AAED;;;AAGA,MAAMC,SAAS,gBAAGC,gBAAU;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;AAAA;EAAA;AAAA,EAY1B;AAEF;;;AAGO,MAAMC,yBAAyB,GAAIC,KAAmB,IAAkB;EAC7E,MAAMC,MAAM,GAAGJ,SAAS,EAAE;EAC1BG,KAAK,CAACJ,IAAI,CAACM,SAAS,GAAGJ,oBAAY,CAACH,yBAAiB,CAACC,IAAI,EAAEK,MAAM,CAACL,IAAI,EAAEI,KAAK,CAACJ,IAAI,CAACM,SAAS,CAAC;EAE9F,OAAOF,KAAK;AACd,CAAC;AALYL,iCAAyB","names":["exports","root","useStyles","react_1","useListboxStyles_unstable","state","styles","className"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Listbox/useListboxStyles.ts"],"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"]}
|
|
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Option = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const useOption_1 = /*#__PURE__*/require("./useOption");
|
|
11
|
-
|
|
12
9
|
const renderOption_1 = /*#__PURE__*/require("./renderOption");
|
|
13
|
-
|
|
14
10
|
const useOptionStyles_1 = /*#__PURE__*/require("./useOptionStyles");
|
|
15
11
|
/**
|
|
16
12
|
* Option component: a styled child option of a Combobox
|
|
17
13
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
14
|
exports.Option = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
21
15
|
const state = useOption_1.useOption_unstable(props, ref);
|
|
22
16
|
useOptionStyles_1.useOptionStyles_unstable(state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAIA;;;AAGaA,cAAM,gBAAqCC,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACtF,MAAMC,KAAK,GAAGC,8BAAkB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAE5CG,0CAAwB,CAACF,KAAK,CAAC;EAC/B,OAAOG,oCAAqB,CAACH,KAAK,CAAC;AACrC,CAAC,CAAC;AAEFL,cAAM,CAACS,WAAW,GAAG,QAAQ","names":["exports","React","forwardRef","props","ref","state","useOption_1","useOptionStyles_1","renderOption_1","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Option/Option.tsx"],"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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
|
|
@@ -3,16 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
|
-
|
|
9
7
|
tslib_1.__exportStar(require("./Option"), exports);
|
|
10
|
-
|
|
11
8
|
tslib_1.__exportStar(require("./Option.types"), exports);
|
|
12
|
-
|
|
13
9
|
tslib_1.__exportStar(require("./renderOption"), exports);
|
|
14
|
-
|
|
15
10
|
tslib_1.__exportStar(require("./useOption"), exports);
|
|
16
|
-
|
|
17
11
|
tslib_1.__exportStar(require("./useOptionStyles"), exports);
|
|
18
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Option/index.ts"],"sourcesContent":["export * from './Option';\nexport * from './Option.types';\nexport * from './renderOption';\nexport * from './useOption';\nexport * from './useOptionStyles';\n"]}
|
|
@@ -4,24 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderOption_unstable = void 0;
|
|
7
|
-
|
|
8
7
|
const React = /*#__PURE__*/require("react");
|
|
9
|
-
|
|
10
8
|
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
9
|
/**
|
|
12
10
|
* Render the final JSX of Option
|
|
13
11
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
12
|
const renderOption_unstable = state => {
|
|
17
13
|
const {
|
|
18
14
|
slots,
|
|
19
15
|
slotProps
|
|
20
16
|
} = react_utilities_1.getSlots(state);
|
|
21
|
-
return React.createElement(slots.root, {
|
|
22
|
-
|
|
17
|
+
return React.createElement(slots.root, {
|
|
18
|
+
...slotProps.root
|
|
19
|
+
}, React.createElement(slots.checkIcon, {
|
|
20
|
+
...slotProps.checkIcon
|
|
23
21
|
}), slotProps.root.children);
|
|
24
22
|
};
|
|
25
|
-
|
|
26
23
|
exports.renderOption_unstable = renderOption_unstable;
|
|
27
24
|
//# sourceMappingURL=renderOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":";;;;;;AAAA;AACA;AAGA;;;AAGO,MAAMA,qBAAqB,GAAIC,KAAkB,IAAI;EAC1D,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAcH,KAAK,CAAC;EAEzD,OACEI,oBAACH,KAAK,CAACI,IAAI;IAAA,GAAKH,SAAS,CAACG;EAAI,GAC5BD,oBAACH,KAAK,CAACK,SAAS;IAAA,GAAKJ,SAAS,CAACI;EAAS,EAAI,EAC3CJ,SAAS,CAACG,IAAI,CAACE,QAAQ,CACb;AAEjB,CAAC;AATYC,6BAAqB","names":["renderOption_unstable","state","slots","slotProps","react_utilities_1","React","root","checkIcon","children","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Option/renderOption.tsx"],"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"]}
|
|
@@ -4,31 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useOption_unstable = 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 react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
|
13
|
-
|
|
14
10
|
const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
|
|
15
|
-
|
|
16
11
|
const ComboboxContext_1 = /*#__PURE__*/require("../../contexts/ComboboxContext");
|
|
17
|
-
|
|
18
12
|
const ListboxContext_1 = /*#__PURE__*/require("../../contexts/ListboxContext");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return value;
|
|
13
|
+
function getTextString(text, children) {
|
|
14
|
+
if (text !== undefined) {
|
|
15
|
+
return text;
|
|
23
16
|
}
|
|
24
|
-
|
|
25
|
-
let
|
|
17
|
+
let textString = '';
|
|
18
|
+
let hasNonStringChild = false;
|
|
26
19
|
React.Children.forEach(children, child => {
|
|
27
20
|
if (typeof child === 'string') {
|
|
28
|
-
|
|
21
|
+
textString += child;
|
|
22
|
+
} else {
|
|
23
|
+
hasNonStringChild = true;
|
|
29
24
|
}
|
|
30
25
|
});
|
|
31
|
-
|
|
26
|
+
// warn if an Option has non-string children and no text prop
|
|
27
|
+
if (hasNonStringChild) {
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.warn('Provide a `text` prop to Option components when they contain non-string children.');
|
|
30
|
+
}
|
|
31
|
+
return textString;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Create the state required to render Option.
|
|
@@ -39,24 +39,26 @@ function getValueString(value, children) {
|
|
|
39
39
|
* @param props - props from this instance of Option
|
|
40
40
|
* @param ref - reference to root HTMLElement of Option
|
|
41
41
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
42
|
const useOption_unstable = (props, ref) => {
|
|
45
43
|
const {
|
|
44
|
+
children,
|
|
46
45
|
disabled,
|
|
46
|
+
text,
|
|
47
47
|
value
|
|
48
48
|
} = props;
|
|
49
49
|
const optionRef = React.useRef(null);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const optionText = getTextString(text, children);
|
|
51
|
+
const optionValue = value !== null && value !== void 0 ? value : optionText;
|
|
52
|
+
// use the id if provided, otherwise use a generated id
|
|
53
|
+
const id = react_utilities_1.useId('fluent-option', props.id);
|
|
54
|
+
// data used for context registration & events
|
|
54
55
|
const optionData = React.useMemo(() => ({
|
|
55
56
|
id,
|
|
56
57
|
disabled,
|
|
58
|
+
text: optionText,
|
|
57
59
|
value: optionValue
|
|
58
|
-
}), [id, disabled, optionValue]);
|
|
59
|
-
|
|
60
|
+
}), [id, disabled, optionText, optionValue]);
|
|
61
|
+
// context values
|
|
60
62
|
const focusVisible = react_context_selector_1.useContextSelector(ListboxContext_1.ListboxContext, ctx => ctx.focusVisible);
|
|
61
63
|
const multiselect = react_context_selector_1.useContextSelector(ListboxContext_1.ListboxContext, ctx => ctx.multiselect);
|
|
62
64
|
const registerOption = react_context_selector_1.useContextSelector(ListboxContext_1.ListboxContext, ctx => ctx.registerOption);
|
|
@@ -66,46 +68,46 @@ const useOption_unstable = (props, ref) => {
|
|
|
66
68
|
});
|
|
67
69
|
const selectOption = react_context_selector_1.useContextSelector(ListboxContext_1.ListboxContext, ctx => ctx.selectOption);
|
|
68
70
|
const setActiveOption = react_context_selector_1.useContextSelector(ListboxContext_1.ListboxContext, ctx => ctx.setActiveOption);
|
|
69
|
-
const setOpen = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.setOpen);
|
|
70
|
-
|
|
71
|
+
const setOpen = react_context_selector_1.useContextSelector(ComboboxContext_1.ComboboxContext, ctx => ctx.setOpen);
|
|
72
|
+
// current active option?
|
|
71
73
|
const active = react_context_selector_1.useContextSelector(ListboxContext_1.ListboxContext, ctx => {
|
|
72
74
|
var _a, _b;
|
|
73
|
-
|
|
74
75
|
return ((_a = ctx.activeOption) === null || _a === void 0 ? void 0 : _a.id) !== undefined && ((_b = ctx.activeOption) === null || _b === void 0 ? void 0 : _b.id) === id;
|
|
75
|
-
});
|
|
76
|
-
|
|
76
|
+
});
|
|
77
|
+
// check icon
|
|
77
78
|
let CheckIcon = React.createElement(react_icons_1.CheckmarkFilled, null);
|
|
78
|
-
|
|
79
79
|
if (multiselect) {
|
|
80
|
-
CheckIcon = selected ? React.createElement(react_icons_1.
|
|
80
|
+
CheckIcon = selected ? React.createElement(react_icons_1.Checkmark12Filled, null) : '';
|
|
81
81
|
}
|
|
82
|
-
|
|
83
82
|
const onClick = event => {
|
|
84
83
|
var _a;
|
|
85
|
-
|
|
86
84
|
if (disabled) {
|
|
87
85
|
event.preventDefault();
|
|
88
86
|
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
}
|
|
88
|
+
// clicked option should always become active option
|
|
89
|
+
setActiveOption(optionData);
|
|
90
|
+
// close on option click for single-select options in a combobox
|
|
94
91
|
if (!multiselect) {
|
|
95
92
|
setOpen === null || setOpen === void 0 ? void 0 : setOpen(event, false);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
}
|
|
94
|
+
// handle selection change
|
|
99
95
|
selectOption(event, optionData);
|
|
100
96
|
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
};
|
|
98
|
+
// register option data with context
|
|
104
99
|
React.useEffect(() => {
|
|
105
100
|
if (id && optionRef.current) {
|
|
106
101
|
return registerOption(optionData, optionRef.current);
|
|
107
102
|
}
|
|
108
103
|
}, [id, optionData, registerOption]);
|
|
104
|
+
const semanticProps = multiselect ? {
|
|
105
|
+
role: 'menuitemcheckbox',
|
|
106
|
+
'aria-checked': selected
|
|
107
|
+
} : {
|
|
108
|
+
role: 'option',
|
|
109
|
+
'aria-selected': selected
|
|
110
|
+
};
|
|
109
111
|
return {
|
|
110
112
|
components: {
|
|
111
113
|
root: 'div',
|
|
@@ -113,10 +115,9 @@ const useOption_unstable = (props, ref) => {
|
|
|
113
115
|
},
|
|
114
116
|
root: react_utilities_1.getNativeElementProps('div', {
|
|
115
117
|
ref: react_utilities_1.useMergedRefs(ref, optionRef),
|
|
116
|
-
role: 'option',
|
|
117
118
|
'aria-disabled': disabled ? 'true' : undefined,
|
|
118
|
-
'aria-selected': `${selected}`,
|
|
119
119
|
id,
|
|
120
|
+
...semanticProps,
|
|
120
121
|
...props,
|
|
121
122
|
onClick
|
|
122
123
|
}),
|
|
@@ -134,6 +135,5 @@ const useOption_unstable = (props, ref) => {
|
|
|
134
135
|
selected
|
|
135
136
|
};
|
|
136
137
|
};
|
|
137
|
-
|
|
138
138
|
exports.useOption_unstable = useOption_unstable;
|
|
139
139
|
//# sourceMappingURL=useOption.js.map
|