@fluentui/react-combobox 9.5.16 → 9.5.18
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 +145 -1
- package/CHANGELOG.md +39 -2
- package/lib/components/Combobox/useCombobox.js +9 -13
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +1 -2
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/components/Listbox/useListbox.js +1 -2
- package/lib/components/Listbox/useListbox.js.map +1 -1
- package/lib/components/Option/useOption.js +3 -4
- package/lib/components/Option/useOption.js.map +1 -1
- package/lib/utils/useComboboxBaseState.js +1 -2
- package/lib/utils/useComboboxBaseState.js.map +1 -1
- package/lib/utils/useComboboxPopup.js +2 -3
- package/lib/utils/useComboboxPopup.js.map +1 -1
- package/lib/utils/useOptionCollection.js +1 -2
- package/lib/utils/useOptionCollection.js.map +1 -1
- package/lib/utils/useSelection.js +2 -4
- package/lib/utils/useSelection.js.map +1 -1
- package/lib/utils/useTriggerListboxSlots.js +7 -9
- package/lib/utils/useTriggerListboxSlots.js.map +1 -1
- package/lib-commonjs/components/Combobox/useCombobox.js +9 -12
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdown.js +1 -2
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListbox.js +1 -2
- package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
- package/lib-commonjs/components/Option/useOption.js +3 -4
- package/lib-commonjs/components/Option/useOption.js.map +1 -1
- package/lib-commonjs/utils/useComboboxBaseState.js +1 -2
- package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
- package/lib-commonjs/utils/useComboboxPopup.js +2 -3
- package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
- package/lib-commonjs/utils/useOptionCollection.js +1 -2
- package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
- package/lib-commonjs/utils/useSelection.js +2 -4
- package/lib-commonjs/utils/useSelection.js.map +1 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js +7 -9
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useListbox.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, mergeCallbacks, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useContextSelector, useHasParentContext } from '@fluentui/react-context-selector';\nimport { getDropdownActionFromKey, getIndexFromAction } from '../../utils/dropdownKeyActions';\nimport { useOptionCollection } from '../../utils/useOptionCollection';\nimport { useScrollOptionsIntoView } from '../../utils/useScrollOptionsIntoView';\nimport { useSelection } from '../../utils/useSelection';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\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 */ export const useListbox_unstable = (props, ref)=>{\n
|
|
1
|
+
{"version":3,"sources":["useListbox.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, mergeCallbacks, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useContextSelector, useHasParentContext } from '@fluentui/react-context-selector';\nimport { getDropdownActionFromKey, getIndexFromAction } from '../../utils/dropdownKeyActions';\nimport { useOptionCollection } from '../../utils/useOptionCollection';\nimport { useScrollOptionsIntoView } from '../../utils/useScrollOptionsIntoView';\nimport { useSelection } from '../../utils/useSelection';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\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 */ export const useListbox_unstable = (props, ref)=>{\n const { multiselect } = props;\n const optionCollection = useOptionCollection();\n const { getCount, getOptionAtIndex, getIndexOfId } = optionCollection;\n const { clearSelection, selectedOptions, selectOption } = useSelection(props);\n const [activeOption, setActiveOption] = React.useState();\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 const onKeyDown = (event)=>{\n const action = getDropdownActionFromKey(event, {\n open: true\n });\n const maxIndex = getCount() - 1;\n const activeIndex = activeOption ? getIndexOfId(activeOption.id) : -1;\n let newIndex = activeIndex;\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 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 const onMouseOver = (event)=>{\n setFocusVisible(false);\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 // without a parent combobox context, provide values directly from Listbox\n const optionContextValues = hasComboboxContext ? {\n activeOption: comboboxActiveOption,\n focusVisible: comboboxFocusVisible,\n selectedOptions: comboboxSelectedOptions,\n selectOption: comboboxSelectOption,\n setActiveOption: comboboxSetActiveOption\n } : {\n activeOption,\n focusVisible,\n selectedOptions,\n selectOption,\n setActiveOption\n };\n const state = {\n components: {\n root: 'div'\n },\n root: slot.always(getNativeElementProps('div', {\n ref,\n role: multiselect ? 'menu' : 'listbox',\n 'aria-activedescendant': hasComboboxContext ? undefined : activeOption === null || activeOption === void 0 ? void 0 : activeOption.id,\n 'aria-multiselectable': multiselect,\n tabIndex: 0,\n ...props\n }), {\n elementType: 'div'\n }),\n multiselect,\n clearSelection,\n ...optionCollection,\n ...optionContextValues\n };\n const scrollContainerRef = useScrollOptionsIntoView(state);\n state.root.ref = useMergedRefs(state.root.ref, scrollContainerRef);\n state.root.onKeyDown = useEventCallback(mergeCallbacks(state.root.onKeyDown, onKeyDown));\n state.root.onMouseOver = useEventCallback(mergeCallbacks(state.root.onMouseOver, onMouseOver));\n return state;\n};\n"],"names":["useListbox_unstable","props","ref","multiselect","optionCollection","useOptionCollection","getCount","getOptionAtIndex","getIndexOfId","clearSelection","selectedOptions","selectOption","useSelection","activeOption","setActiveOption","React","useState","focusVisible","setFocusVisible","onKeyDown","event","action","getDropdownActionFromKey","open","maxIndex","activeIndex","id","newIndex","getIndexFromAction","preventDefault","onMouseOver","hasComboboxContext","useHasParentContext","ComboboxContext","comboboxActiveOption","useContextSelector","ctx","comboboxFocusVisible","comboboxSelectedOptions","comboboxSelectOption","comboboxSetActiveOption","optionContextValues","state","components","root","slot","always","getNativeElementProps","role","undefined","tabIndex","elementType","scrollContainerRef","useScrollOptionsIntoView","useMergedRefs","useEventCallback","mergeCallbacks"],"mappings":";;;;+BAgBiBA;;;eAAAA;;;;iEAhBM;gCACsE;sCACrC;oCACK;qCACzB;0CACK;8BACZ;iCACG;AASrB,MAAMA,sBAAsB,CAACC,OAAOC;IAC3C,MAAM,EAAEC,WAAW,EAAE,GAAGF;IACxB,MAAMG,mBAAmBC,IAAAA,wCAAmB;IAC5C,MAAM,EAAEC,QAAQ,EAAEC,gBAAgB,EAAEC,YAAY,EAAE,GAAGJ;IACrD,MAAM,EAAEK,cAAc,EAAEC,eAAe,EAAEC,YAAY,EAAE,GAAGC,IAAAA,0BAAY,EAACX;IACvE,MAAM,CAACY,cAAcC,gBAAgB,GAAGC,O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AiB0B;IACrB,IAAI;QACA3B;QACAI;QACAP;QACAC;QACAG;IACJ;IACA,MAAM4B,QAAQ;QACVC,YAAY;YACRC,MAAM;QACV;QACAA,MAAMC,oBAAI,CAACC,MAAM,CAACC,IAAAA,qCAAqB,EAAC,OAAO;YAC3C7C;YACA8C,MAAM7C,cAAc,SAAS;YAC7B,yBAAyB4B,qBAAqBkB,YAAYpC,iBAAiB,QAAQA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAaa,EAAE;YACrI,wBAAwBvB;YACxB+C,UAAU;YACV,GAAGjD,KAAK;QACZ,IAAI;YACAkD,aAAa;QACjB;QACAhD;QACAM;QACA,GAAGL,gBAAgB;QACnB,GAAGqC,mBAAmB;IAC1B;IACA,MAAMW,qBAAqBC,IAAAA,kDAAwB,EAACX;IACpDA,MAAME,IAAI,CAAC1C,GAAG,GAAGoD,IAAAA,6BAAa,EAACZ,MAAME,IAAI,CAAC1C,GAAG,EAAEkD;IAC/CV,MAAME,IAAI,CAACzB,SAAS,GAAGoC,IAAAA,gCAAgB,EAACC,IAAAA,8BAAc,EAACd,MAAME,IAAI,CAACzB,SAAS,EAAEA;IAC7EuB,MAAME,IAAI,CAACd,WAAW,GAAGyB,IAAAA,gCAAgB,EAACC,IAAAA,8BAAc,EAACd,MAAME,IAAI,CAACd,WAAW,EAAEA;IACjF,OAAOY;AACX"}
|
|
@@ -76,7 +76,7 @@ const useOption_unstable = (props, ref)=>{
|
|
|
76
76
|
CheckIcon = selected ? /*#__PURE__*/ _react.createElement(_reacticons.Checkmark12Filled, null) : '';
|
|
77
77
|
}
|
|
78
78
|
const onClick = (event)=>{
|
|
79
|
-
var _props_onClick
|
|
79
|
+
var _props_onClick;
|
|
80
80
|
if (disabled) {
|
|
81
81
|
event.preventDefault();
|
|
82
82
|
return;
|
|
@@ -85,12 +85,11 @@ const useOption_unstable = (props, ref)=>{
|
|
|
85
85
|
setActiveOption(optionData);
|
|
86
86
|
// close on option click for single-select options in a combobox
|
|
87
87
|
if (!multiselect) {
|
|
88
|
-
|
|
89
|
-
(_setOpen = setOpen) === null || _setOpen === void 0 ? void 0 : _setOpen(event, false);
|
|
88
|
+
setOpen === null || setOpen === void 0 ? void 0 : setOpen(event, false);
|
|
90
89
|
}
|
|
91
90
|
// handle selection change
|
|
92
91
|
selectOption(event, optionData);
|
|
93
|
-
(_props_onClick =
|
|
92
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, event);
|
|
94
93
|
};
|
|
95
94
|
// register option data with context
|
|
96
95
|
_react.useEffect(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOption.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useId, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useContextSelector } from '@fluentui/react-context-selector';\nimport { CheckmarkFilled, Checkmark12Filled } from '@fluentui/react-icons';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport { ListboxContext } from '../../contexts/ListboxContext';\nfunction getTextString(text, children) {\n if (text !== undefined) {\n return text;\n }\n let textString = '';\n let hasNonStringChild = false;\n React.Children.forEach(children, (child)=>{\n if (typeof child === 'string') {\n textString += child;\n } else {\n hasNonStringChild = true;\n }\n });\n // warn if an Option has non-string children and no text prop\n if (hasNonStringChild) {\n // eslint-disable-next-line no-console\n console.warn('Provide a `text` prop to Option components when they contain non-string children.');\n }\n return textString;\n}\n/**\n * Create the state required to render Option.\n *\n * The returned state can be modified with hooks such as useOptionStyles_unstable,\n * before being passed to renderOption_unstable.\n *\n * @param props - props from this instance of Option\n * @param ref - reference to root HTMLElement of Option\n */ export const useOption_unstable = (props, ref)=>{\n const { children, disabled, text, value } = props;\n const optionRef = React.useRef(null);\n const optionText = getTextString(text, children);\n const optionValue = value !== null && value !== void 0 ? value : optionText;\n // use the id if provided, otherwise use a generated id\n const id = useId('fluent-option', props.id);\n // data used for context registration & events\n const optionData = React.useMemo(()=>({\n id,\n disabled,\n text: optionText,\n value: optionValue\n }), [\n id,\n disabled,\n optionText,\n optionValue\n ]);\n // context values\n const focusVisible = useContextSelector(ListboxContext, (ctx)=>ctx.focusVisible);\n const multiselect = useContextSelector(ListboxContext, (ctx)=>ctx.multiselect);\n const registerOption = useContextSelector(ListboxContext, (ctx)=>ctx.registerOption);\n const selected = useContextSelector(ListboxContext, (ctx)=>{\n const selectedOptions = ctx.selectedOptions;\n return !!optionValue && !!selectedOptions.find((o)=>o === optionValue);\n });\n const selectOption = useContextSelector(ListboxContext, (ctx)=>ctx.selectOption);\n const setActiveOption = useContextSelector(ListboxContext, (ctx)=>ctx.setActiveOption);\n const setOpen = useContextSelector(ComboboxContext, (ctx)=>ctx.setOpen);\n // current active option?\n const active = useContextSelector(ListboxContext, (ctx)=>{\n var _ctx_activeOption, _ctx_activeOption1;\n return ((_ctx_activeOption = ctx.activeOption) === null || _ctx_activeOption === void 0 ? void 0 : _ctx_activeOption.id) !== undefined && ((_ctx_activeOption1 = ctx.activeOption) === null || _ctx_activeOption1 === void 0 ? void 0 : _ctx_activeOption1.id) === id;\n });\n // check icon\n let CheckIcon = /*#__PURE__*/ React.createElement(CheckmarkFilled, null);\n if (multiselect) {\n CheckIcon = selected ? /*#__PURE__*/ React.createElement(Checkmark12Filled, null) : '';\n }\n const onClick = (event)=>{\n var _props_onClick
|
|
1
|
+
{"version":3,"sources":["useOption.js"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useId, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useContextSelector } from '@fluentui/react-context-selector';\nimport { CheckmarkFilled, Checkmark12Filled } from '@fluentui/react-icons';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport { ListboxContext } from '../../contexts/ListboxContext';\nfunction getTextString(text, children) {\n if (text !== undefined) {\n return text;\n }\n let textString = '';\n let hasNonStringChild = false;\n React.Children.forEach(children, (child)=>{\n if (typeof child === 'string') {\n textString += child;\n } else {\n hasNonStringChild = true;\n }\n });\n // warn if an Option has non-string children and no text prop\n if (hasNonStringChild) {\n // eslint-disable-next-line no-console\n console.warn('Provide a `text` prop to Option components when they contain non-string children.');\n }\n return textString;\n}\n/**\n * Create the state required to render Option.\n *\n * The returned state can be modified with hooks such as useOptionStyles_unstable,\n * before being passed to renderOption_unstable.\n *\n * @param props - props from this instance of Option\n * @param ref - reference to root HTMLElement of Option\n */ export const useOption_unstable = (props, ref)=>{\n const { children, disabled, text, value } = props;\n const optionRef = React.useRef(null);\n const optionText = getTextString(text, children);\n const optionValue = value !== null && value !== void 0 ? value : optionText;\n // use the id if provided, otherwise use a generated id\n const id = useId('fluent-option', props.id);\n // data used for context registration & events\n const optionData = React.useMemo(()=>({\n id,\n disabled,\n text: optionText,\n value: optionValue\n }), [\n id,\n disabled,\n optionText,\n optionValue\n ]);\n // context values\n const focusVisible = useContextSelector(ListboxContext, (ctx)=>ctx.focusVisible);\n const multiselect = useContextSelector(ListboxContext, (ctx)=>ctx.multiselect);\n const registerOption = useContextSelector(ListboxContext, (ctx)=>ctx.registerOption);\n const selected = useContextSelector(ListboxContext, (ctx)=>{\n const selectedOptions = ctx.selectedOptions;\n return !!optionValue && !!selectedOptions.find((o)=>o === optionValue);\n });\n const selectOption = useContextSelector(ListboxContext, (ctx)=>ctx.selectOption);\n const setActiveOption = useContextSelector(ListboxContext, (ctx)=>ctx.setActiveOption);\n const setOpen = useContextSelector(ComboboxContext, (ctx)=>ctx.setOpen);\n // current active option?\n const active = useContextSelector(ListboxContext, (ctx)=>{\n var _ctx_activeOption, _ctx_activeOption1;\n return ((_ctx_activeOption = ctx.activeOption) === null || _ctx_activeOption === void 0 ? void 0 : _ctx_activeOption.id) !== undefined && ((_ctx_activeOption1 = ctx.activeOption) === null || _ctx_activeOption1 === void 0 ? void 0 : _ctx_activeOption1.id) === id;\n });\n // check icon\n let CheckIcon = /*#__PURE__*/ React.createElement(CheckmarkFilled, null);\n if (multiselect) {\n CheckIcon = selected ? /*#__PURE__*/ React.createElement(Checkmark12Filled, null) : '';\n }\n const onClick = (event)=>{\n var _props_onClick;\n if (disabled) {\n event.preventDefault();\n return;\n }\n // clicked option should always become active option\n setActiveOption(optionData);\n // close on option click for single-select options in a combobox\n if (!multiselect) {\n setOpen === null || setOpen === void 0 ? void 0 : setOpen(event, false);\n }\n // handle selection change\n selectOption(event, optionData);\n (_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, event);\n };\n // register option data with context\n React.useEffect(()=>{\n if (id && optionRef.current) {\n return registerOption(optionData, optionRef.current);\n }\n }, [\n id,\n optionData,\n registerOption\n ]);\n const semanticProps = multiselect ? {\n role: 'menuitemcheckbox',\n 'aria-checked': selected\n } : {\n role: 'option',\n 'aria-selected': selected\n };\n return {\n components: {\n root: 'div',\n checkIcon: 'span'\n },\n root: slot.always(getNativeElementProps('div', {\n ref: useMergedRefs(ref, optionRef),\n 'aria-disabled': disabled ? 'true' : undefined,\n id,\n ...semanticProps,\n ...props,\n onClick\n }), {\n elementType: 'div'\n }),\n checkIcon: slot.optional(props.checkIcon, {\n renderByDefault: true,\n defaultProps: {\n 'aria-hidden': 'true',\n children: CheckIcon\n },\n elementType: 'span'\n }),\n active,\n disabled,\n focusVisible,\n multiselect,\n selected\n };\n};\n"],"names":["useOption_unstable","getTextString","text","children","undefined","textString","hasNonStringChild","React","Children","forEach","child","console","warn","props","ref","disabled","value","optionRef","useRef","optionText","optionValue","id","useId","optionData","useMemo","focusVisible","useContextSelector","ListboxContext","ctx","multiselect","registerOption","selected","selectedOptions","find","o","selectOption","setActiveOption","setOpen","ComboboxContext","active","_ctx_activeOption","_ctx_activeOption1","activeOption","CheckIcon","createElement","CheckmarkFilled","Checkmark12Filled","onClick","event","_props_onClick","preventDefault","call","useEffect","current","semanticProps","role","components","root","checkIcon","slot","always","getNativeElementProps","useMergedRefs","elementType","optional","renderByDefault","defaultProps"],"mappings":";;;;+BAkCiBA;;;eAAAA;;;;iEAlCM;gCAC2C;sCAC/B;4BACgB;iCACnB;gC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AAK,IAAI,KAAK,IAAIA,eAAeE,IAAI,CAACtC,OAAOmC;IACjH;IACA,oCAAoC;IACpCzC,OAAM6C,SAAS,CAAC;QACZ,IAAI/B,MAAMJ,UAAUoC,OAAO,EAAE;YACzB,OAAOvB,eAAeP,YAAYN,UAAUoC,OAAO;QACvD;IACJ,GAAG;QACChC;QACAE;QACAO;KACH;IACD,MAAMwB,gBAAgBzB,cAAc;QAChC0B,MAAM;QACN,gBAAgBxB;IACpB,IAAI;QACAwB,MAAM;QACN,iBAAiBxB;IACrB;IACA,OAAO;QACHyB,YAAY;YACRC,MAAM;YACNC,WAAW;QACf;QACAD,MAAME,oBAAI,CAACC,MAAM,CAACC,IAAAA,qCAAqB,EAAC,OAAO;YAC3C/C,KAAKgD,IAAAA,6BAAa,EAAChD,KAAKG;YACxB,iBAAiBF,WAAW,SAASX;YACrCiB;YACA,GAAGiC,aAAa;YAChB,GAAGzC,KAAK;YACRkC;QACJ,IAAI;YACAgB,aAAa;QACjB;QACAL,WAAWC,oBAAI,CAACK,QAAQ,CAACnD,MAAM6C,SAAS,EAAE;YACtCO,iBAAiB;YACjBC,cAAc;gBACV,eAAe;gBACf/D,UAAUwC;YACd;YACAoB,aAAa;QACjB;QACAxB;QACAxB;QACAU;QACAI;QACAE;IACJ;AACJ"}
|
|
@@ -68,8 +68,7 @@ const useComboboxBaseState = (props)=>{
|
|
|
68
68
|
initialState: false
|
|
69
69
|
});
|
|
70
70
|
const setOpen = _react.useCallback((event, newState)=>{
|
|
71
|
-
|
|
72
|
-
(_onOpenChange = onOpenChange) === null || _onOpenChange === void 0 ? void 0 : _onOpenChange(event, {
|
|
71
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {
|
|
73
72
|
open: newState
|
|
74
73
|
});
|
|
75
74
|
setOpenState(newState);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useComboboxBaseState.js"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState, useFirstMount } from '@fluentui/react-utilities';\nimport { useOptionCollection } from '../utils/useOptionCollection';\nimport { useSelection } from '../utils/useSelection';\n/**\n * State shared between Combobox and Dropdown components\n */ export const useComboboxBaseState = (props)=>{\n const { appearance = 'outline', children, editable = false, inlinePopup = false, mountNode = undefined, multiselect, onOpenChange, size = 'medium' } = props;\n const optionCollection = useOptionCollection();\n const { getOptionAtIndex, getOptionsMatchingValue } = optionCollection;\n const [activeOption, setActiveOption] = React.useState();\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 // track focused state to conditionally render collapsed listbox\n const [hasFocus, setHasFocus] = React.useState(false);\n const ignoreNextBlur = React.useRef(false);\n const selectionState = useSelection(props);\n const { selectedOptions } = selectionState;\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 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 // handle defaultValue here, so it is overridden by selection\n if (isFirstMount && props.defaultValue !== undefined) {\n return props.defaultValue;\n }\n const selectedOptionsText = getOptionsMatchingValue((optionValue)=>{\n return selectedOptions.includes(optionValue);\n }).map((option)=>option.text);\n if (multiselect) {\n // editable inputs should not display multiple selected options in the input as text\n return editable ? '' : selectedOptionsText.join(', ');\n }\n return selectedOptionsText[0];\n // do not change value after isFirstMount changes,\n // we do not want to accidentally override defaultValue on a second render\n // unless another value is intentionally set\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n controllableValue,\n editable,\n getOptionsMatchingValue,\n multiselect,\n props.defaultValue,\n 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 const setOpen = React.useCallback((event, newState)=>{\n
|
|
1
|
+
{"version":3,"sources":["useComboboxBaseState.js"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState, useFirstMount } from '@fluentui/react-utilities';\nimport { useOptionCollection } from '../utils/useOptionCollection';\nimport { useSelection } from '../utils/useSelection';\n/**\n * State shared between Combobox and Dropdown components\n */ export const useComboboxBaseState = (props)=>{\n const { appearance = 'outline', children, editable = false, inlinePopup = false, mountNode = undefined, multiselect, onOpenChange, size = 'medium' } = props;\n const optionCollection = useOptionCollection();\n const { getOptionAtIndex, getOptionsMatchingValue } = optionCollection;\n const [activeOption, setActiveOption] = React.useState();\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 // track focused state to conditionally render collapsed listbox\n const [hasFocus, setHasFocus] = React.useState(false);\n const ignoreNextBlur = React.useRef(false);\n const selectionState = useSelection(props);\n const { selectedOptions } = selectionState;\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 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 // handle defaultValue here, so it is overridden by selection\n if (isFirstMount && props.defaultValue !== undefined) {\n return props.defaultValue;\n }\n const selectedOptionsText = getOptionsMatchingValue((optionValue)=>{\n return selectedOptions.includes(optionValue);\n }).map((option)=>option.text);\n if (multiselect) {\n // editable inputs should not display multiple selected options in the input as text\n return editable ? '' : selectedOptionsText.join(', ');\n }\n return selectedOptionsText[0];\n // do not change value after isFirstMount changes,\n // we do not want to accidentally override defaultValue on a second render\n // unless another value is intentionally set\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n controllableValue,\n editable,\n getOptionsMatchingValue,\n multiselect,\n props.defaultValue,\n 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 const setOpen = React.useCallback((event, newState)=>{\n onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {\n open: newState\n });\n setOpenState(newState);\n }, [\n onOpenChange,\n setOpenState\n ]);\n // update active option based on change in open state or children\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 = getOptionsMatchingValue((v)=>v === selectedOptions[0]).pop();\n selectedOption && setActiveOption(selectedOption);\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 or children\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n open,\n children\n ]);\n return {\n ...optionCollection,\n ...selectionState,\n activeOption,\n appearance,\n focusVisible,\n hasFocus,\n ignoreNextBlur,\n inlinePopup,\n mountNode,\n open,\n setActiveOption,\n setFocusVisible,\n setHasFocus,\n setOpen,\n setValue,\n size,\n value\n };\n};\n"],"names":["useComboboxBaseState","props","appearance","children","editable","inlinePopup","mountNode","undefined","multiselect","onOpenChange","size","optionCollection","useOptionCollection","getOptionAtIndex","getOptionsMatchingValue","activeOption","setActiveOption","React","useState","focusVisible","setFocusVisible","hasFocus","setHasFocus","ignoreNextBlur","useRef","selectionState","useSelection","selectedOptions","isFirstMount","useFirstMount","controllableValue","setValue","useControllableState","state","value","initialState","useMemo","defaultValue","selectedOptionsText","optionValue","includes","map","option","text","join","open","setOpenState","defaultState","defaultOpen","setOpen","useCallback","event","newState","useEffect","length","selectedOption","v","pop"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;gCAC6B;qCAChB;8BACP;AAGlB,MAAMA,uBAAuB,CAACC;IACrC,MAAM,EAAEC,aAAa,SAAS,EAAEC,QAAQ,EAAEC,WAAW,KAAK,EAAEC,cAAc,KAAK,EAAEC,YAAYC,SAAS,EAAEC,WAAW,EAAEC,YAAY,EAAEC,OAAO,QAAQ,EAAE,GAAGT;IACvJ,MAAMU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Gd,IAAAA,oCAAoB,EAAC;QAC9CC,OAAOhC,MAAM4C,IAAI;QACjBE,cAAc9C,MAAM+C,WAAW;QAC/Bb,cAAc;IAClB;IACA,MAAMc,UAAUhC,OAAMiC,WAAW,CAAC,CAACC,OAAOC;QACtC3C,iBAAiB,QAAQA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAa0C,OAAO;YAC5EN,MAAMO;QACV;QACAN,aAAaM;IACjB,GAAG;QACC3C;QACAqC;KACH;IACD,iEAAiE;IACjE7B,OAAMoC,SAAS,CAAC;QACZ,IAAIR,QAAQ,CAAC9B,cAAc;YACvB,sFAAsF;YACtF,IAAI,CAACP,eAAemB,gBAAgB2B,MAAM,GAAG,GAAG;gBAC5C,MAAMC,iBAAiBzC,wBAAwB,CAAC0C,IAAIA,MAAM7B,eAAe,CAAC,EAAE,EAAE8B,GAAG;gBACjFF,kBAAkBvC,gBAAgBuC;YACtC,OAAO;gBACHvC,gBAAgBH,iBAAiB;YACrC;QACJ,OAAO,IAAI,CAACgC,MAAM;YACd,uCAAuC;YACvC7B,gBAAgBT;QACpB;IACJ,+EAA+E;IAC/E,uDAAuD;IACvD,GAAG;QACCsC;QACA1C;KACH;IACD,OAAO;QACH,GAAGQ,gBAAgB;QACnB,GAAGc,cAAc;QACjBV;QACAb;QACAiB;QACAE;QACAE;QACAlB;QACAC;QACAuC;QACA7B;QACAI;QACAE;QACA2B;QACAlB;QACArB;QACAwB;IACJ;AACJ"}
|
|
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "useComboboxPopup", {
|
|
|
11
11
|
const _reactpositioning = require("@fluentui/react-positioning");
|
|
12
12
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
13
13
|
function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
|
|
14
|
-
var _listboxShorthand, _triggerShorthand;
|
|
15
14
|
const { positioning } = props;
|
|
16
15
|
// Set a default set of fallback positions to try if the dropdown does not fit on screen
|
|
17
16
|
const fallbackPositions = [
|
|
@@ -33,7 +32,7 @@ function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
|
|
|
33
32
|
...(0, _reactpositioning.resolvePositioningShorthand)(positioning)
|
|
34
33
|
};
|
|
35
34
|
const { targetRef, containerRef } = (0, _reactpositioning.usePositioning)(popperOptions);
|
|
36
|
-
const listboxRef = (0, _reactutilities.useMergedRefs)(
|
|
35
|
+
const listboxRef = (0, _reactutilities.useMergedRefs)(listboxShorthand === null || listboxShorthand === void 0 ? void 0 : listboxShorthand.ref, containerRef);
|
|
37
36
|
const listbox = listboxShorthand && {
|
|
38
37
|
...listboxShorthand,
|
|
39
38
|
ref: listboxRef
|
|
@@ -41,7 +40,7 @@ function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
|
|
|
41
40
|
return [
|
|
42
41
|
{
|
|
43
42
|
...triggerShorthand,
|
|
44
|
-
ref: (0, _reactutilities.useMergedRefs)(
|
|
43
|
+
ref: (0, _reactutilities.useMergedRefs)(triggerShorthand === null || triggerShorthand === void 0 ? void 0 : triggerShorthand.ref, targetRef)
|
|
45
44
|
},
|
|
46
45
|
listbox
|
|
47
46
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useComboboxPopup.js"],"sourcesContent":["import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useMergedRefs } from '@fluentui/react-utilities';\nexport function useComboboxPopup(props, triggerShorthand, listboxShorthand) {\n
|
|
1
|
+
{"version":3,"sources":["useComboboxPopup.js"],"sourcesContent":["import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useMergedRefs } from '@fluentui/react-utilities';\nexport function useComboboxPopup(props, triggerShorthand, listboxShorthand) {\n const { positioning } = props;\n // Set a default set of fallback positions to try if the dropdown does not fit on screen\n const fallbackPositions = [\n 'above',\n 'after',\n 'after-top',\n 'before',\n 'before-top'\n ];\n // popper options\n const popperOptions = {\n position: 'below',\n align: 'start',\n offset: {\n crossAxis: 0,\n mainAxis: 2\n },\n fallbackPositions,\n ...resolvePositioningShorthand(positioning)\n };\n const { targetRef, containerRef } = usePositioning(popperOptions);\n const listboxRef = useMergedRefs(listboxShorthand === null || listboxShorthand === void 0 ? void 0 : listboxShorthand.ref, containerRef);\n const listbox = listboxShorthand && {\n ...listboxShorthand,\n ref: listboxRef\n };\n return [\n {\n ...triggerShorthand,\n ref: useMergedRefs(triggerShorthand === null || triggerShorthand === void 0 ? void 0 : triggerShorthand.ref, targetRef)\n },\n listbox\n ];\n}\n"],"names":["useComboboxPopup","props","triggerShorthand","listboxShorthand","positioning","fallbackPositions","popperOptions","position","align","offset","crossAxis","mainAxis","resolvePositioningShorthand","targetRef","containerRef","usePositioning","listboxRef","useMergedRefs","ref","listbox"],"mappings":";;;;+BAEgBA;;;eAAAA;;;kCAF4C;gCAC9B;AACvB,SAASA,iBAAiBC,KAAK,EAAEC,gBAAgB,EAAEC,gBAAgB;IACtE,MAAM,EAAEC,WAAW,EAAE,GAAGH;IACxB,wFAAwF;IACxF,MAAMI,oBAAoB;QACtB;QACA;QACA;QACA;QACA;KACH;IACD,iBAAiB;IACjB,MAAMC,gBAAgB;QAClBC,UAAU;QACVC,OAAO;QACPC,QAAQ;YACJC,WAAW;YACXC,UAAU;QACd;QACAN;QACA,GAAGO,IAAAA,6CAA2B,EAACR,YAAY;IAC/C;IACA,MAAM,EAAES,SAAS,EAAEC,YAAY,EAAE,GAAGC,IAAAA,gCAAc,EAACT;IACnD,MAAMU,aAAaC,IAAAA,6BAAa,EAACd,qBAAqB,QAAQA,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBe,GAAG,EAAEJ;IAC3H,MAAMK,UAAUhB,oBAAoB;QAChC,GAAGA,gBAAgB;QACnBe,KAAKF;IACT;IACA,OAAO;QACH;YACI,GAAGd,gBAAgB;YACnBgB,KAAKD,IAAAA,6BAAa,EAACf,qBAAqB,QAAQA,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBgB,GAAG,EAAEL;QACjH;QACAM;KACH;AACL"}
|
|
@@ -20,9 +20,8 @@ const useOptionCollection = ()=>{
|
|
|
20
20
|
};
|
|
21
21
|
const getIndexOfId = (id)=>nodes.current.findIndex((node)=>node.option.id === id);
|
|
22
22
|
const getOptionById = (id)=>{
|
|
23
|
-
var _item;
|
|
24
23
|
const item = nodes.current.find((node)=>node.option.id === id);
|
|
25
|
-
return
|
|
24
|
+
return item === null || item === void 0 ? void 0 : item.option;
|
|
26
25
|
};
|
|
27
26
|
const getOptionsMatchingText = (matcher)=>{
|
|
28
27
|
return nodes.current.filter((node)=>matcher(node.option.text)).map((node)=>node.option);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useOptionCollection.js"],"sourcesContent":["import * as React from 'react';\n/**\n * A hook for managing a collection of child Options\n */ export const useOptionCollection = ()=>{\n const nodes = React.useRef([]);\n const collectionAPI = React.useMemo(()=>{\n const getCount = ()=>nodes.current.length;\n const getOptionAtIndex = (index)=>{\n var _nodes_current_index;\n return (_nodes_current_index = nodes.current[index]) === null || _nodes_current_index === void 0 ? void 0 : _nodes_current_index.option;\n };\n const getIndexOfId = (id)=>nodes.current.findIndex((node)=>node.option.id === id);\n const getOptionById = (id)=>{\n
|
|
1
|
+
{"version":3,"sources":["useOptionCollection.js"],"sourcesContent":["import * as React from 'react';\n/**\n * A hook for managing a collection of child Options\n */ export const useOptionCollection = ()=>{\n const nodes = React.useRef([]);\n const collectionAPI = React.useMemo(()=>{\n const getCount = ()=>nodes.current.length;\n const getOptionAtIndex = (index)=>{\n var _nodes_current_index;\n return (_nodes_current_index = nodes.current[index]) === null || _nodes_current_index === void 0 ? void 0 : _nodes_current_index.option;\n };\n const getIndexOfId = (id)=>nodes.current.findIndex((node)=>node.option.id === id);\n const getOptionById = (id)=>{\n const item = nodes.current.find((node)=>node.option.id === id);\n return item === null || item === void 0 ? void 0 : item.option;\n };\n const getOptionsMatchingText = (matcher)=>{\n return nodes.current.filter((node)=>matcher(node.option.text)).map((node)=>node.option);\n };\n const getOptionsMatchingValue = (matcher)=>{\n return nodes.current.filter((node)=>matcher(node.option.value)).map((node)=>node.option);\n };\n return {\n getCount,\n getOptionAtIndex,\n getIndexOfId,\n getOptionById,\n getOptionsMatchingText,\n getOptionsMatchingValue\n };\n }, []);\n const registerOption = React.useCallback((option, element)=>{\n var _nodes_current_index;\n const index = nodes.current.findIndex((node)=>{\n if (!node.element || !element) {\n return false;\n }\n if (node.option.id === option.id) {\n return true;\n }\n // use the DOM method compareDocumentPosition to order the current node against registered nodes\n // eslint-disable-next-line no-bitwise\n return node.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING;\n });\n // do not register the option if it already exists\n if (((_nodes_current_index = nodes.current[index]) === null || _nodes_current_index === void 0 ? void 0 : _nodes_current_index.option.id) !== option.id) {\n const newItem = {\n element,\n option\n };\n // If an index is not found we will push the element to the end.\n if (index === -1) {\n nodes.current = [\n ...nodes.current,\n newItem\n ];\n } else {\n nodes.current.splice(index, 0, newItem);\n }\n }\n // return the unregister function\n return ()=>{\n nodes.current = nodes.current.filter((node)=>node.option.id !== option.id);\n };\n }, []);\n return {\n ...collectionAPI,\n options: nodes.current.map((node)=>node.option),\n registerOption\n };\n};\n"],"names":["useOptionCollection","nodes","React","useRef","collectionAPI","useMemo","getCount","current","length","getOptionAtIndex","index","_nodes_current_index","option","getIndexOfId","id","findIndex","node","getOptionById","item","find","getOptionsMatchingText","matcher","filter","text","map","getOptionsMatchingValue","value","registerOption","useCallback","element","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","newItem","splice","options"],"mappings":";;;;+BAGiBA;;;eAAAA;;;;iEAHM;AAGZ,MAAMA,sBAAsB;IACnC,MAAMC,QAAQC,OAAMC,MAAM,CAAC,EAAE;IAC7B,MAAMC,gBAAgBF,OAAMG,OAAO,CAAC;QAChC,MAAMC,WAAW,IAAIL,MAAMM,OAAO,CAACC,MAAM;QACzC,MAAMC,mBAAmB,CAACC;YACtB,IAAIC;YACJ,OAAO,AAACA,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2BAA2B;QAC3F;QACA,kDAAkD;QAClD,IAAI,AAAC,CAAA,AAACrB,CAAAA,uBAAuBV,MAAMM,OAAO,CAACG,MAAM,AAAD,MAAO,QAAQC,yBAAyB,KAAK,IAAI,KAAK,IAAIA,qBAAqBC,MAAM,CAACE,EAAE,AAAD,MAAOF,OAAOE,EAAE,EAAE;YACrJ,MAAMmB,UAAU;gBACZJ;gBACAjB;YACJ;YACA,gEAAgE;YAChE,IAAIF,UAAU,CAAC,GAAG;gBACdT,MAAMM,OAAO,GAAG;uBACTN,MAAMM,OAAO;oBAChB0B;iBACH;YACL,OAAO;gBACHhC,MAAMM,OAAO,CAAC2B,MAAM,CAACxB,OAAO,GAAGuB;YACnC;QACJ;QACA,iCAAiC;QACjC,OAAO;YACHhC,MAAMM,OAAO,GAAGN,MAAMM,OAAO,CAACe,MAAM,CAAC,CAACN,OAAOA,KAAKJ,MAAM,CAACE,EAAE,KAAKF,OAAOE,EAAE;QAC7E;IACJ,GAAG,EAAE;IACL,OAAO;QACH,GAAGV,aAAa;QAChB+B,SAASlC,MAAMM,OAAO,CAACiB,GAAG,CAAC,CAACR,OAAOA,KAAKJ,MAAM;QAC9Ce;IACJ;AACJ"}
|
|
@@ -18,7 +18,6 @@ const useSelection = (props)=>{
|
|
|
18
18
|
initialState: []
|
|
19
19
|
});
|
|
20
20
|
const selectOption = (0, _react.useCallback)((event, option)=>{
|
|
21
|
-
var _onOptionSelect;
|
|
22
21
|
// if the option is disabled, do nothing
|
|
23
22
|
if (option.disabled) {
|
|
24
23
|
return;
|
|
@@ -45,7 +44,7 @@ const useSelection = (props)=>{
|
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
setSelectedOptions(newSelection);
|
|
48
|
-
|
|
47
|
+
onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {
|
|
49
48
|
optionValue: option.value,
|
|
50
49
|
optionText: option.text,
|
|
51
50
|
selectedOptions: newSelection
|
|
@@ -57,9 +56,8 @@ const useSelection = (props)=>{
|
|
|
57
56
|
setSelectedOptions
|
|
58
57
|
]);
|
|
59
58
|
const clearSelection = (event)=>{
|
|
60
|
-
var _onOptionSelect;
|
|
61
59
|
setSelectedOptions([]);
|
|
62
|
-
|
|
60
|
+
onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {
|
|
63
61
|
optionValue: undefined,
|
|
64
62
|
optionText: undefined,
|
|
65
63
|
selectedOptions: []
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useSelection.js"],"sourcesContent":["import { useCallback } from 'react';\nimport { useControllableState } from '@fluentui/react-utilities';\nexport const useSelection = (props)=>{\n const { defaultSelectedOptions, multiselect, onOptionSelect } = props;\n const [selectedOptions, setSelectedOptions] = useControllableState({\n state: props.selectedOptions,\n defaultState: defaultSelectedOptions,\n initialState: []\n });\n const selectOption = useCallback((event, option)=>{\n
|
|
1
|
+
{"version":3,"sources":["useSelection.js"],"sourcesContent":["import { useCallback } from 'react';\nimport { useControllableState } from '@fluentui/react-utilities';\nexport const useSelection = (props)=>{\n const { defaultSelectedOptions, multiselect, onOptionSelect } = props;\n const [selectedOptions, setSelectedOptions] = useControllableState({\n state: props.selectedOptions,\n defaultState: defaultSelectedOptions,\n initialState: []\n });\n const selectOption = useCallback((event, option)=>{\n // if the option is disabled, do nothing\n if (option.disabled) {\n return;\n }\n // for single-select, always return the selected option\n let newSelection = [\n option.value\n ];\n // toggle selected state of the option for multiselect\n if (multiselect) {\n const selectedIndex = selectedOptions.findIndex((o)=>o === option.value);\n if (selectedIndex > -1) {\n // deselect option\n newSelection = [\n ...selectedOptions.slice(0, selectedIndex),\n ...selectedOptions.slice(selectedIndex + 1)\n ];\n } else {\n // select option\n newSelection = [\n ...selectedOptions,\n option.value\n ];\n }\n }\n setSelectedOptions(newSelection);\n onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {\n optionValue: option.value,\n optionText: option.text,\n selectedOptions: newSelection\n });\n }, [\n onOptionSelect,\n multiselect,\n selectedOptions,\n setSelectedOptions\n ]);\n const clearSelection = (event)=>{\n setSelectedOptions([]);\n onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {\n optionValue: undefined,\n optionText: undefined,\n selectedOptions: []\n });\n };\n return {\n clearSelection,\n selectOption,\n selectedOptions\n };\n};\n"],"names":["useSelection","props","defaultSelectedOptions","multiselect","onOptionSelect","selectedOptions","setSelectedOptions","useControllableState","state","defaultState","initialState","selectOption","useCallback","event","option","disabled","newSelection","value","selectedIndex","findIndex","o","slice","optionValue","optionText","text","clearSelection","undefined"],"mappings":";;;;+BAEaA;;;eAAAA;;;uBAFe;gCACS;AAC9B,MAAMA,eAAe,CAACC;IACzB,MAAM,EAAEC,sBAAsB,EAAEC,WAAW,EAAEC,cAAc,EAAE,GAAGH;IAChE,MAAM,CAACI,iBAAiBC,mBAAmB,GAAGC,IAAAA,oCAAoB,EAAC;QAC/DC,OAAOP,MAAMI,eAAe;QAC5BI,cAAcP;QACdQ,cAAc,EAAE;IACpB;IACA,MAAMC,eAAeC,IAAAA,kBAAW,EAAC,CAACC,OAAOC;QACrC,wCAAwC;QACxC,IAAIA,OAAOC,QAAQ,EAAE;YACjB;QACJ;QACA,uDAAuD;QACvD,IAAIC,eAAe;YACfF,OAAOG,KAAK;SACf;QACD,sDAAsD;QACtD,IAAId,aAAa;YACb,MAAMe,gBAAgBb,gBAAgBc,SAAS,CAAC,CAACC,IAAIA,MAAMN,OAAOG,KAAK;YACvE,IAAIC,gBAAgB,CAAC,GAAG;gBACpB,kBAAkB;gBAClBF,eAAe;uBACRX,gBAAgBgB,KAAK,CAAC,GAAGH;uBACzBb,gBAAgBgB,KAAK,CAACH,gBAAgB;iBAC5C;YACL,OAAO;gBACH,gBAAgB;gBAChBF,eAAe;uBACRX;oBACHS,OAAOG,KAAK;iBACf;YACL;QACJ;QACAX,mBAAmBU;QACnBZ,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeS,OAAO;YAClFS,aAAaR,OAAOG,KAAK;YACzBM,YAAYT,OAAOU,IAAI;YACvBnB,iBAAiBW;QACrB;IACJ,GAAG;QACCZ;QACAD;QACAE;QACAC;KACH;IACD,MAAMmB,iBAAiB,CAACZ;QACpBP,mBAAmB,EAAE;QACrBF,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeS,OAAO;YAClFS,aAAaI;YACbH,YAAYG;YACZrB,iBAAiB,EAAE;QACvB;IACJ;IACA,OAAO;QACHoB;QACAd;QACAN;IACJ;AACJ"}
|
|
@@ -13,13 +13,12 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
13
13
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
14
14
|
const _dropdownKeyActions = require("../utils/dropdownKeyActions");
|
|
15
15
|
function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
|
|
16
|
-
var _listboxSlot, _activeOption, _triggerSlot, _listbox, _listbox1, _listbox2;
|
|
17
16
|
const { multiselect } = props;
|
|
18
17
|
const { activeOption, getCount, getIndexOfId, getOptionAtIndex, ignoreNextBlur, open, selectOption, setActiveOption, setFocusVisible, setHasFocus, setOpen } = state;
|
|
19
18
|
// handle trigger focus/blur
|
|
20
19
|
const triggerRef = _react.useRef(null);
|
|
21
20
|
// resolve listbox shorthand props
|
|
22
|
-
const listboxId = (0, _reactutilities.useId)('fluent-listbox',
|
|
21
|
+
const listboxId = (0, _reactutilities.useId)('fluent-listbox', listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id);
|
|
23
22
|
const listbox = listboxSlot && {
|
|
24
23
|
id: listboxId,
|
|
25
24
|
multiselect,
|
|
@@ -29,13 +28,13 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
|
|
|
29
28
|
// resolve trigger shorthand props
|
|
30
29
|
const trigger = {
|
|
31
30
|
'aria-expanded': open,
|
|
32
|
-
'aria-activedescendant': open ?
|
|
31
|
+
'aria-activedescendant': open ? activeOption === null || activeOption === void 0 ? void 0 : activeOption.id : undefined,
|
|
33
32
|
role: 'combobox',
|
|
34
33
|
...triggerSlot,
|
|
35
34
|
// explicitly type the ref as an intersection here to prevent type errors
|
|
36
35
|
// since the `children` prop has mutually incompatible types between input/button
|
|
37
36
|
// functionally both ref and triggerRef will always be the same element type
|
|
38
|
-
ref: (0, _reactutilities.useMergedRefs)(ref,
|
|
37
|
+
ref: (0, _reactutilities.useMergedRefs)(ref, triggerSlot === null || triggerSlot === void 0 ? void 0 : triggerSlot.ref, triggerRef)
|
|
39
38
|
};
|
|
40
39
|
/*
|
|
41
40
|
* Handle focus when clicking the listbox popup:
|
|
@@ -44,13 +43,13 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
|
|
|
44
43
|
*/ const listboxOnClick = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
|
|
45
44
|
var _triggerRef_current;
|
|
46
45
|
(_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
|
|
47
|
-
},
|
|
46
|
+
}, listbox === null || listbox === void 0 ? void 0 : listbox.onClick));
|
|
48
47
|
const listboxOnMouseOver = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
|
|
49
48
|
setFocusVisible(false);
|
|
50
|
-
},
|
|
49
|
+
}, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseOver));
|
|
51
50
|
const listboxOnMouseDown = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
|
|
52
51
|
ignoreNextBlur.current = true;
|
|
53
|
-
},
|
|
52
|
+
}, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseDown));
|
|
54
53
|
// listbox is nullable, only add event handlers if it exists
|
|
55
54
|
if (listbox) {
|
|
56
55
|
listbox.onClick = listboxOnClick;
|
|
@@ -93,8 +92,7 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
|
|
|
93
92
|
setOpen(event, false);
|
|
94
93
|
break;
|
|
95
94
|
case 'CloseSelect':
|
|
96
|
-
|
|
97
|
-
!multiselect && !((_activeOption = activeOption) === null || _activeOption === void 0 ? void 0 : _activeOption.disabled) && setOpen(event, false);
|
|
95
|
+
!multiselect && !(activeOption === null || activeOption === void 0 ? void 0 : activeOption.disabled) && setOpen(event, false);
|
|
98
96
|
// fallthrough
|
|
99
97
|
case 'Select':
|
|
100
98
|
activeOption && selectOption(event, activeOption);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTriggerListboxSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, useId, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey, getIndexFromAction } from '../utils/dropdownKeyActions';\n/*\n * useTriggerListboxSlots returns a tuple of trigger/listbox shorthand,\n * with the semantics and event handlers needed for the Combobox and Dropdown components.\n * The element type of the ref should always match the element type used in the trigger shorthand.\n */ export function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {\n
|
|
1
|
+
{"version":3,"sources":["useTriggerListboxSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, useId, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey, getIndexFromAction } from '../utils/dropdownKeyActions';\n/*\n * useTriggerListboxSlots returns a tuple of trigger/listbox shorthand,\n * with the semantics and event handlers needed for the Combobox and Dropdown components.\n * The element type of the ref should always match the element type used in the trigger shorthand.\n */ export function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {\n const { multiselect } = props;\n const { activeOption, getCount, getIndexOfId, getOptionAtIndex, ignoreNextBlur, open, selectOption, setActiveOption, setFocusVisible, setHasFocus, setOpen } = state;\n // handle trigger focus/blur\n const triggerRef = React.useRef(null);\n // resolve listbox shorthand props\n const listboxId = useId('fluent-listbox', listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id);\n const listbox = listboxSlot && {\n id: listboxId,\n multiselect,\n tabIndex: undefined,\n ...listboxSlot\n };\n // resolve trigger shorthand props\n const trigger = {\n 'aria-expanded': open,\n 'aria-activedescendant': open ? activeOption === null || activeOption === void 0 ? void 0 : activeOption.id : undefined,\n role: 'combobox',\n ...triggerSlot,\n // explicitly type the ref as an intersection here to prevent type errors\n // since the `children` prop has mutually incompatible types between input/button\n // functionally both ref and triggerRef will always be the same element type\n ref: useMergedRefs(ref, triggerSlot === null || triggerSlot === void 0 ? void 0 : triggerSlot.ref, triggerRef)\n };\n /*\n * Handle focus when clicking the listbox popup:\n * 1. Move focus back to the button/input when the listbox is clicked (otherwise it goes to body)\n * 2. Do not close the listbox on button/input blur when clicking into the listbox\n */ const listboxOnClick = useEventCallback(mergeCallbacks((event)=>{\n var _triggerRef_current;\n (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();\n }, listbox === null || listbox === void 0 ? void 0 : listbox.onClick));\n const listboxOnMouseOver = useEventCallback(mergeCallbacks((event)=>{\n setFocusVisible(false);\n }, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseOver));\n const listboxOnMouseDown = useEventCallback(mergeCallbacks((event)=>{\n ignoreNextBlur.current = true;\n }, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseDown));\n // listbox is nullable, only add event handlers if it exists\n if (listbox) {\n listbox.onClick = listboxOnClick;\n listbox.onMouseOver = listboxOnMouseOver;\n listbox.onMouseDown = listboxOnMouseDown;\n }\n // the trigger should open/close the popup on click or blur\n trigger.onBlur = mergeCallbacks((event)=>{\n if (!ignoreNextBlur.current) {\n setOpen(event, false);\n }\n ignoreNextBlur.current = false;\n setHasFocus(false);\n }, trigger.onBlur);\n trigger.onClick = mergeCallbacks((event)=>{\n setOpen(event, !open);\n }, trigger.onClick);\n trigger.onFocus = mergeCallbacks((event)=>{\n setHasFocus(true);\n }, trigger.onFocus);\n // handle combobox keyboard interaction\n trigger.onKeyDown = mergeCallbacks((event)=>{\n const action = getDropdownActionFromKey(event, {\n open,\n multiselect\n });\n const maxIndex = getCount() - 1;\n const activeIndex = activeOption ? getIndexOfId(activeOption.id) : -1;\n let newIndex = activeIndex;\n switch(action){\n case 'Open':\n event.preventDefault();\n setFocusVisible(true);\n setOpen(event, true);\n break;\n case 'Close':\n // stop propagation for escape key to avoid dismissing any parent popups\n event.stopPropagation();\n event.preventDefault();\n setOpen(event, false);\n break;\n case 'CloseSelect':\n !multiselect && !(activeOption === null || activeOption === void 0 ? void 0 : activeOption.disabled) && setOpen(event, false);\n // fallthrough\n case 'Select':\n activeOption && selectOption(event, activeOption);\n event.preventDefault();\n break;\n case 'Tab':\n !multiselect && activeOption && selectOption(event, activeOption);\n break;\n default:\n newIndex = getIndexFromAction(action, activeIndex, maxIndex);\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 }, trigger.onKeyDown);\n trigger.onMouseOver = mergeCallbacks((event)=>{\n setFocusVisible(false);\n }, trigger.onMouseOver);\n return [\n trigger,\n listbox\n ];\n}\n"],"names":["useTriggerListboxSlots","props","state","ref","triggerSlot","listboxSlot","multiselect","activeOption","getCount","getIndexOfId","getOptionAtIndex","ignoreNextBlur","open","selectOption","setActiveOption","setFocusVisible","setHasFocus","setOpen","triggerRef","React","useRef","listboxId","useId","id","listbox","tabIndex","undefined","trigger","role","useMergedRefs","listboxOnClick","useEventCallback","mergeCallbacks","event","_triggerRef_current","current","focus","onClick","listboxOnMouseOver","onMouseOver","listboxOnMouseDown","onMouseDown","onBlur","onFocus","onKeyDown","action","getDropdownActionFromKey","maxIndex","activeIndex","newIndex","preventDefault","stopPropagation","disabled","getIndexFromAction"],"mappings":";;;;+BAOoBA;;;eAAAA;;;;iEAPG;gCACgD;oCACV;AAKlD,SAASA,uBAAuBC,KAAK,EAAEC,KAAK,EAAEC,GA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,KAAK;gBACD,CAAC3B,eAAe,CAAEC,CAAAA,iBAAiB,QAAQA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAa6C,QAAQ,AAAD,KAAMnC,QAAQgB,OAAO;YAC3H,cAAc;YACd,KAAK;gBACD1B,gBAAgBM,aAAaoB,OAAO1B;gBACpC0B,MAAMiB,cAAc;gBACpB;YACJ,KAAK;gBACD,CAAC5C,eAAeC,gBAAgBM,aAAaoB,OAAO1B;gBACpD;YACJ;gBACI0C,WAAWI,IAAAA,sCAAkB,EAACR,QAAQG,aAAaD;QAC3D;QACA,IAAIE,aAAaD,aAAa;YAC1B,mEAAmE;YACnEf,MAAMiB,cAAc;YACpBpC,gBAAgBJ,iBAAiBuC;YACjClC,gBAAgB;QACpB;IACJ,GAAGY,QAAQiB,SAAS;IACpBjB,QAAQY,WAAW,GAAGP,IAAAA,8BAAc,EAAC,CAACC;QAClClB,gBAAgB;IACpB,GAAGY,QAAQY,WAAW;IACtB,OAAO;QACHZ;QACAH;KACH;AACL"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-combobox",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.18",
|
|
4
4
|
"description": "Fluent UI React Combobox component",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"@fluentui/scripts-tasks": "*"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@fluentui/keyboard-keys": "^9.0.
|
|
37
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
38
|
-
"@fluentui/react-field": "^9.1.
|
|
39
|
-
"@fluentui/react-icons": "^2.0.
|
|
40
|
-
"@fluentui/react-jsx-runtime": "^9.0.
|
|
41
|
-
"@fluentui/react-portal": "^9.3.
|
|
42
|
-
"@fluentui/react-positioning": "^9.9.
|
|
43
|
-
"@fluentui/react-shared-contexts": "^9.
|
|
44
|
-
"@fluentui/react-theme": "^9.1.
|
|
45
|
-
"@fluentui/react-utilities": "^9.13.
|
|
36
|
+
"@fluentui/keyboard-keys": "^9.0.6",
|
|
37
|
+
"@fluentui/react-context-selector": "^9.1.36",
|
|
38
|
+
"@fluentui/react-field": "^9.1.31",
|
|
39
|
+
"@fluentui/react-icons": "^2.0.217",
|
|
40
|
+
"@fluentui/react-jsx-runtime": "^9.0.12",
|
|
41
|
+
"@fluentui/react-portal": "^9.3.18",
|
|
42
|
+
"@fluentui/react-positioning": "^9.9.15",
|
|
43
|
+
"@fluentui/react-shared-contexts": "^9.9.1",
|
|
44
|
+
"@fluentui/react-theme": "^9.1.14",
|
|
45
|
+
"@fluentui/react-utilities": "^9.13.5",
|
|
46
46
|
"@griffel/react": "^1.5.14",
|
|
47
47
|
"@swc/helpers": "^0.5.1"
|
|
48
48
|
},
|