@fluentui/react-combobox 9.5.27 → 9.5.29
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.md +35 -2
- package/lib/components/Combobox/useCombobox.js +16 -28
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +17 -25
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/utils/{useComboboxPopup.js → useComboboxPositioning.js} +5 -12
- package/lib/utils/useComboboxPositioning.js.map +1 -0
- package/lib/utils/useTriggerListboxSlots.js +14 -1
- package/lib/utils/useTriggerListboxSlots.js.map +1 -1
- package/lib-commonjs/components/Combobox/useCombobox.js +16 -28
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdown.js +17 -25
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/utils/{useComboboxPopup.js → useComboboxPositioning.js} +8 -14
- package/lib-commonjs/utils/useComboboxPositioning.js.map +1 -0
- package/lib-commonjs/utils/useTriggerListboxSlots.js +14 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
- package/package.json +17 -11
- package/CHANGELOG.json +0 -4193
- package/lib/utils/useComboboxPopup.js.map +0 -1
- package/lib-commonjs/utils/useComboboxPopup.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCombobox.js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, useEventCallback, useId, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\n/**\n * Create the state required to render Combobox.\n *\n * The returned state can be modified with hooks such as useComboboxStyles_unstable,\n * before being passed to renderCombobox_unstable.\n *\n * @param props - props from this instance of Combobox\n * @param ref - reference to root HTMLElement of Combobox\n */ export const useCombobox_unstable = (props, ref)=>{\n var _props_input;\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsRequired: true,\n supportsSize: true\n });\n const baseState = useComboboxBaseState({\n ...props,\n editable: true\n });\n const { activeOption, clearSelection, getIndexOfId, getOptionsMatchingText, hasFocus, open, selectOption, selectedOptions, setActiveOption, setFocusVisible, setOpen, setValue, value } = baseState;\n const { disabled, freeform, inlinePopup, multiselect } = props;\n const comboId = useId('combobox-');\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: [\n 'children',\n 'size'\n ]\n });\n const rootRef = React.useRef(null);\n const triggerRef = React.useRef(null);\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n // save the typing vs. navigating options state, as the space key should behave differently in each case\n // we do not want to update the combobox when this changes, just save the value between renders\n const isTyping = React.useRef(false);\n // calculate listbox width style based on trigger width\n const [popupDimensions, setPopupDimensions] = React.useState();\n React.useEffect(()=>{\n // only recalculate width when opening\n if (open) {\n var _rootRef_current;\n const width = `${(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.clientWidth}px`;\n if (width !== (popupDimensions === null || popupDimensions === void 0 ? void 0 : popupDimensions.width)) {\n setPopupDimensions({\n width\n });\n }\n }\n }, [\n open,\n popupDimensions\n ]);\n // set active option and selection based on typing\n const getOptionFromInput = (inputValue)=>{\n const searchString = inputValue === null || inputValue === void 0 ? void 0 : inputValue.trim().toLowerCase();\n if (!searchString || searchString.length === 0) {\n return;\n }\n const matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString) === 0;\n const matches = getOptionsMatchingText(matcher);\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const startIndex = getIndexOfId(activeOption.id);\n const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);\n return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];\n }\n var _matches_;\n return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;\n };\n /* Handle typed input */ // reset any typed value when an option is selected\n baseState.selectOption = (ev, option)=>{\n setValue(undefined);\n selectOption(ev, option);\n };\n const onTriggerBlur = (ev)=>{\n // handle selection and updating value if freeform is false\n if (!baseState.open && !freeform) {\n // select matching option, if the value fully matches\n if (value && activeOption && value.trim().toLowerCase() === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.text.toLowerCase())) {\n baseState.selectOption(ev, activeOption);\n }\n // reset typed value when the input loses focus while collapsed, unless freeform is true\n setValue(undefined);\n }\n };\n baseState.setOpen = (ev, newState)=>{\n if (disabled) {\n return;\n }\n if (!newState && !freeform) {\n setValue(undefined);\n }\n setOpen(ev, newState);\n };\n // update value and active option based on input\n const onTriggerChange = (ev)=>{\n const inputValue = ev.target.value;\n // update uncontrolled value\n baseState.setValue(inputValue);\n // handle updating active option based on input\n const matchingOption = getOptionFromInput(inputValue);\n setActiveOption(matchingOption);\n setFocusVisible(true);\n // clear selection for single-select if the input value no longer matches the selection\n if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || !matchingOption)) {\n clearSelection(ev);\n }\n };\n // resolve input and listbox slot props\n let triggerSlot;\n let listboxSlot;\n triggerSlot = slot.always(props.input, {\n defaultProps: {\n ref: useMergedRefs((_props_input = props.input) === null || _props_input === void 0 ? void 0 : _props_input.ref, triggerRef),\n type: 'text',\n value: value !== null && value !== void 0 ? value : '',\n ...triggerNativeProps\n },\n elementType: 'input'\n });\n const resolvedPropsOnKeyDown = triggerSlot.onKeyDown;\n triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);\n triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur); // only resolve listbox slot if needed\n listboxSlot = open || hasFocus ? slot.optional(props.listbox, {\n renderByDefault: true,\n defaultProps: {\n children: props.children,\n style: popupDimensions\n },\n elementType: Listbox\n }) : undefined;\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n if (hideActiveDescendant) {\n triggerSlot['aria-activedescendant'] = undefined;\n }\n const state = {\n components: {\n root: 'div',\n input: 'input',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,\n ...rootNativeProps\n },\n elementType: 'div'\n }),\n input: triggerSlot,\n listbox: listboxSlot,\n expandIcon: slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n 'aria-expanded': open,\n children: /*#__PURE__*/ React.createElement(ChevronDownIcon, null),\n role: 'button'\n },\n elementType: 'span'\n }),\n ...baseState\n };\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n /* Set input.onKeyDown here, so we can override the default behavior for spacebar */ const defaultOnTriggerKeyDown = state.input.onKeyDown;\n state.input.onKeyDown = useEventCallback((ev)=>{\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n baseState.setOpen(ev, true);\n }\n // clear activedescendant when moving the text insertion cursor\n if (ev.key === ArrowLeft || ev.key === ArrowRight) {\n setHideActiveDescendant(true);\n } else {\n setHideActiveDescendant(false);\n }\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(ev, {\n open,\n multiselect\n });\n if (action === 'Type') {\n isTyping.current = true;\n } else if (action === 'Open' && ev.key !== ' ' || action === 'Next' || action === 'Previous' || action === 'First' || action === 'Last' || action === 'PageUp' || action === 'PageDown') {\n isTyping.current = false;\n }\n // allow space to insert a character if freeform & the last action was typing, or if the popup is closed\n if (freeform && (isTyping.current || !open) && ev.key === ' ') {\n resolvedPropsOnKeyDown === null || resolvedPropsOnKeyDown === void 0 ? void 0 : resolvedPropsOnKeyDown(ev);\n return;\n }\n // if we're not allowing space to type, continue with default behavior\n defaultOnTriggerKeyDown === null || defaultOnTriggerKeyDown === void 0 ? void 0 : defaultOnTriggerKeyDown(ev);\n });\n /* handle open/close + focus change when clicking expandIcon */ const { onMouseDown: onIconMouseDown, onClick: onIconClick } = state.expandIcon || {};\n const onExpandIconMouseDown = useEventCallback(mergeCallbacks(onIconMouseDown, ()=>{\n // do not dismiss on blur when closing via clicking the icon\n if (open) {\n baseState.ignoreNextBlur.current = true;\n }\n }));\n const onExpandIconClick = useEventCallback(mergeCallbacks(onIconClick, (event)=>{\n var _triggerRef_current;\n // open and set focus\n state.setOpen(event, !state.open);\n (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();\n // set focus visible=false, since this can only be done with the mouse/pointer\n setFocusVisible(false);\n }));\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\n // If there is no explicit aria-label, calculate default accName attribute for expandIcon button,\n // using the following steps:\n // 1. If there is an aria-label, it is \"Open [aria-label]\"\n // 2. If there is an aria-labelledby, it is \"Open [aria-labelledby target]\" (using aria-labelledby + ids)\n // 3. If there is no aria-label/ledby attr, it falls back to \"Open\"\n // We can't fall back to a label/htmlFor name because of https://github.com/w3c/accname/issues/179\n const hasExpandLabel = state.expandIcon['aria-label'] || state.expandIcon['aria-labelledby'];\n const defaultOpenString = 'Open'; // this is english-only since it is the fallback\n if (!hasExpandLabel) {\n if (props['aria-labelledby']) {\n var _state_expandIcon_id;\n const chevronId = (_state_expandIcon_id = state.expandIcon.id) !== null && _state_expandIcon_id !== void 0 ? _state_expandIcon_id : `${comboId}-chevron`;\n const chevronLabelledBy = `${chevronId} ${state.input['aria-labelledby']}`;\n state.expandIcon['aria-label'] = defaultOpenString;\n state.expandIcon.id = chevronId;\n state.expandIcon['aria-labelledby'] = chevronLabelledBy;\n } else if (props['aria-label']) {\n state.expandIcon['aria-label'] = `${defaultOpenString} ${props['aria-label']}`;\n } else {\n state.expandIcon['aria-label'] = defaultOpenString;\n }\n }\n }\n return state;\n};\n"],"names":["useCombobox_unstable","props","ref","_props_input","useFieldControlProps_unstable","supportsLabelFor","supportsRequired","supportsSize","baseState","useComboboxBaseState","editable","activeOption","clearSelection","getIndexOfId","getOptionsMatchingText","hasFocus","open","selectOption","selectedOptions","setActiveOption","setFocusVisible","setOpen","setValue","value","disabled","freeform","inlinePopup","multiselect","comboId","useId","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","rootRef","React","useRef","triggerRef","hideActiveDescendant","setHideActiveDescendant","useState","isTyping","popupDimensions","setPopupDimensions","useEffect","_rootRef_current","width","current","clientWidth","getOptionFromInput","inputValue","searchString","trim","toLowerCase","length","matcher","optionText","indexOf","matches","startIndex","id","nextMatch","find","option","_matches_","undefined","ev","onTriggerBlur","text","newState","onTriggerChange","target","matchingOption","triggerSlot","listboxSlot","slot","always","input","defaultProps","useMergedRefs","type","elementType","resolvedPropsOnKeyDown","onKeyDown","onChange","mergeCallbacks","onBlur","optional","listbox","renderByDefault","children","style","Listbox","useComboboxPopup","useTriggerListboxSlots","state","components","expandIcon","createElement","ChevronDownIcon","role","defaultOnTriggerKeyDown","useEventCallback","getDropdownActionFromKey","key","ArrowLeft","ArrowRight","action","onMouseDown","onIconMouseDown","onClick","onIconClick","onExpandIconMouseDown","ignoreNextBlur","onExpandIconClick","event","_triggerRef_current","focus","hasEx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AK,CAAC,aAAa,EAAE;gBAC5BiG,MAAME,UAAU,CAAC,aAAa,GAAG,CAAC,EAAEsB,kBAAkB,CAAC,EAAEzH,KAAK,CAAC,aAAa,CAAC,CAAC;YAClF,OAAO;gBACHiG,MAAME,UAAU,CAAC,aAAa,GAAGsB;YACrC;QACJ;IACJ;IACA,OAAOxB;AACX"}
|
|
1
|
+
{"version":3,"sources":["useCombobox.js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, useEventCallback, useId, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\n/**\n * Create the state required to render Combobox.\n *\n * The returned state can be modified with hooks such as useComboboxStyles_unstable,\n * before being passed to renderCombobox_unstable.\n *\n * @param props - props from this instance of Combobox\n * @param ref - reference to root HTMLElement of Combobox\n */ export const useCombobox_unstable = (props, ref)=>{\n var _props_input;\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsRequired: true,\n supportsSize: true\n });\n const baseState = useComboboxBaseState({\n ...props,\n editable: true\n });\n const { activeOption, clearSelection, getIndexOfId, getOptionsMatchingText, hasFocus, open, selectOption, selectedOptions, setActiveOption, setFocusVisible, setOpen, setValue, value } = baseState;\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);\n const { disabled, freeform, inlinePopup, multiselect } = props;\n const comboId = useId('combobox-');\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: [\n 'children',\n 'size'\n ]\n });\n const rootRef = React.useRef(null);\n const triggerRef = React.useRef(null);\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n // save the typing vs. navigating options state, as the space key should behave differently in each case\n // we do not want to update the combobox when this changes, just save the value between renders\n const isTyping = React.useRef(false);\n // set active option and selection based on typing\n const getOptionFromInput = (inputValue)=>{\n const searchString = inputValue === null || inputValue === void 0 ? void 0 : inputValue.trim().toLowerCase();\n if (!searchString || searchString.length === 0) {\n return;\n }\n const matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString) === 0;\n const matches = getOptionsMatchingText(matcher);\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const startIndex = getIndexOfId(activeOption.id);\n const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);\n return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];\n }\n var _matches_;\n return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;\n };\n /* Handle typed input */ // reset any typed value when an option is selected\n baseState.selectOption = (ev, option)=>{\n setValue(undefined);\n selectOption(ev, option);\n };\n const onTriggerBlur = (ev)=>{\n // handle selection and updating value if freeform is false\n if (!baseState.open && !freeform) {\n // select matching option, if the value fully matches\n if (value && activeOption && value.trim().toLowerCase() === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.text.toLowerCase())) {\n baseState.selectOption(ev, activeOption);\n }\n // reset typed value when the input loses focus while collapsed, unless freeform is true\n setValue(undefined);\n }\n };\n baseState.setOpen = (ev, newState)=>{\n if (disabled) {\n return;\n }\n if (!newState && !freeform) {\n setValue(undefined);\n }\n setOpen(ev, newState);\n };\n // update value and active option based on input\n const onTriggerChange = (ev)=>{\n const inputValue = ev.target.value;\n // update uncontrolled value\n baseState.setValue(inputValue);\n // handle updating active option based on input\n const matchingOption = getOptionFromInput(inputValue);\n setActiveOption(matchingOption);\n setFocusVisible(true);\n // clear selection for single-select if the input value no longer matches the selection\n if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || !matchingOption)) {\n clearSelection(ev);\n }\n };\n // resolve input and listbox slot props\n let triggerSlot;\n let listboxSlot;\n triggerSlot = slot.always(props.input, {\n defaultProps: {\n ref: useMergedRefs((_props_input = props.input) === null || _props_input === void 0 ? void 0 : _props_input.ref, triggerRef),\n type: 'text',\n value: value !== null && value !== void 0 ? value : '',\n ...triggerNativeProps\n },\n elementType: 'input'\n });\n const resolvedPropsOnKeyDown = triggerSlot.onKeyDown;\n triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);\n triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur); // only resolve listbox slot if needed\n listboxSlot = open || hasFocus ? slot.optional(props.listbox, {\n renderByDefault: true,\n defaultProps: {\n children: props.children\n },\n elementType: Listbox\n }) : undefined;\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n const listboxRef = useMergedRefs(listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.ref, comboboxPopupRef);\n if (hideActiveDescendant) {\n triggerSlot['aria-activedescendant'] = undefined;\n }\n if (listboxSlot) {\n listboxSlot.ref = listboxRef;\n }\n const rootSlot = slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,\n ...rootNativeProps\n },\n elementType: 'div'\n });\n rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);\n const state = {\n components: {\n root: 'div',\n input: 'input',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: rootSlot,\n input: triggerSlot,\n listbox: listboxSlot,\n expandIcon: slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n 'aria-expanded': open,\n children: /*#__PURE__*/ React.createElement(ChevronDownIcon, null),\n role: 'button'\n },\n elementType: 'span'\n }),\n ...baseState\n };\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n /* Set input.onKeyDown here, so we can override the default behavior for spacebar */ const defaultOnTriggerKeyDown = state.input.onKeyDown;\n state.input.onKeyDown = useEventCallback((ev)=>{\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n baseState.setOpen(ev, true);\n }\n // clear activedescendant when moving the text insertion cursor\n if (ev.key === ArrowLeft || ev.key === ArrowRight) {\n setHideActiveDescendant(true);\n } else {\n setHideActiveDescendant(false);\n }\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(ev, {\n open,\n multiselect\n });\n if (action === 'Type') {\n isTyping.current = true;\n } else if (action === 'Open' && ev.key !== ' ' || action === 'Next' || action === 'Previous' || action === 'First' || action === 'Last' || action === 'PageUp' || action === 'PageDown') {\n isTyping.current = false;\n }\n // allow space to insert a character if freeform & the last action was typing, or if the popup is closed\n if (freeform && (isTyping.current || !open) && ev.key === ' ') {\n resolvedPropsOnKeyDown === null || resolvedPropsOnKeyDown === void 0 ? void 0 : resolvedPropsOnKeyDown(ev);\n return;\n }\n // if we're not allowing space to type, continue with default behavior\n defaultOnTriggerKeyDown === null || defaultOnTriggerKeyDown === void 0 ? void 0 : defaultOnTriggerKeyDown(ev);\n });\n /* handle open/close + focus change when clicking expandIcon */ const { onMouseDown: onIconMouseDown, onClick: onIconClick } = state.expandIcon || {};\n const onExpandIconMouseDown = useEventCallback(mergeCallbacks(onIconMouseDown, ()=>{\n // do not dismiss on blur when closing via clicking the icon\n if (open) {\n baseState.ignoreNextBlur.current = true;\n }\n }));\n const onExpandIconClick = useEventCallback(mergeCallbacks(onIconClick, (event)=>{\n var _triggerRef_current;\n // open and set focus\n state.setOpen(event, !state.open);\n (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();\n // set focus visible=false, since this can only be done with the mouse/pointer\n setFocusVisible(false);\n }));\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\n // If there is no explicit aria-label, calculate default accName attribute for expandIcon button,\n // using the following steps:\n // 1. If there is an aria-label, it is \"Open [aria-label]\"\n // 2. If there is an aria-labelledby, it is \"Open [aria-labelledby target]\" (using aria-labelledby + ids)\n // 3. If there is no aria-label/ledby attr, it falls back to \"Open\"\n // We can't fall back to a label/htmlFor name because of https://github.com/w3c/accname/issues/179\n const hasExpandLabel = state.expandIcon['aria-label'] || state.expandIcon['aria-labelledby'];\n const defaultOpenString = 'Open'; // this is english-only since it is the fallback\n if (!hasExpandLabel) {\n if (props['aria-labelledby']) {\n var _state_expandIcon_id;\n const chevronId = (_state_expandIcon_id = state.expandIcon.id) !== null && _state_expandIcon_id !== void 0 ? _state_expandIcon_id : `${comboId}-chevron`;\n const chevronLabelledBy = `${chevronId} ${state.input['aria-labelledby']}`;\n state.expandIcon['aria-label'] = defaultOpenString;\n state.expandIcon.id = chevronId;\n state.expandIcon['aria-labelledby'] = chevronLabelledBy;\n } else if (props['aria-label']) {\n state.expandIcon['aria-label'] = `${defaultOpenString} ${props['aria-label']}`;\n } else {\n state.expandIcon['aria-label'] = defaultOpenString;\n }\n }\n }\n return state;\n};\n"],"names":["useCombobox_unstable","props","ref","_props_input","useFieldControlProps_unstable","supportsLabelFor","supportsRequired","supportsSize","baseState","useComboboxBaseState","editable","activeOption","clearSelection","getIndexOfId","getOptionsMatchingText","hasFocus","open","selectOption","selectedOptions","setActiveOption","setFocusVisible","setOpen","setValue","value","comboboxPopupRef","comboboxTargetRef","useComboboxPositioning","disabled","freeform","inlinePopup","multiselect","comboId","useId","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","rootRef","React","useRef","triggerRef","hideActiveDescendant","setHideActiveDescendant","useState","isTyping","getOptionFromInput","inputValue","searchString","trim","toLowerCase","length","matcher","optionText","indexOf","matches","startIndex","id","nextMatch","find","option","_matches_","undefined","ev","onTriggerBlur","text","newState","onTriggerChange","target","matchingOption","triggerSlot","listboxSlot","slot","always","input","defaultProps","useMergedRefs","type","elementType","resolvedPropsOnKeyDown","onKeyDown","onChange","mergeCallbacks","onBlur","optional","listbox","renderByDefault","children","Listbox","useTriggerListboxSlots","listboxRef","rootSlot","state","components","expandIcon","createElement","ChevronDownIcon","role","defaultOnTriggerKeyDown","useEventCallback","getDropdownActionFromKey","key","ArrowLeft","ArrowRight","action","current","onMouseDown","onIconMouseDown","onClick","onIconClick","onExpandIconMouseDown","ignoreNextBlur","onExpandIconClick","event","_triggerRef_current","focus","hasExpandLabel","defaultOpenString","_state_expandIcon_id","chevronId","chevronLabelledBy"],"mappings":";;;;+BAkBiBA;;;eAAAA;;;;iEAlBM;4BACuB;8BACR;4BACgB;gCACkD;oCAC/D;sCACJ;wCACE;wCACA;yBACf;AASb,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,IAAIC;IACJ,+CAA+C;IAC/CF,QAAQG,IAAAA,yCAA6B,EAACH,OAAO;QACzCI,kBAAkB;QAClBC,kBAAkB;QAClBC,cAAc;IAClB;IACA,MAAMC,YAAYC,IAAAA,0CAAoB,EAAC;QACnC,GAAGR,KAAK;QACRS,UAAU;IACd;IACA,MAAM,EAAEC,YAAY,EAAEC,cAAc,EAAEC,YAAY,EAAEC,sBAAsB,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,YAAY,EAAEC,eAAe,EAAEC,eAAe,EAAEC,eAAe,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGf;IAC1L,MAAM,CAACgB,kBAAkBC,kBAAkB,GAAGC,IAAAA,8CAAsB,EAACzB;IACrE,MAAM,EAAE0B,QAAQ,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,WAAW,EAAE,GAAG7B;IACzD,MAAM8B,UAAUC,IAAAA,qBAAK,EAAC;IACtB,M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MAAMlB,KAAK,CAAC,kBAAkB,CAAC,CAAC;gBAC1EkB,MAAME,UAAU,CAAC,aAAa,GAAGuB;gBACjCzB,MAAME,UAAU,CAACrC,EAAE,GAAG8D;gBACtB3B,MAAME,UAAU,CAAC,kBAAkB,GAAG0B;YAC1C,OAAO,IAAIzH,KAAK,CAAC,aAAa,EAAE;gBAC5B6F,MAAME,UAAU,CAAC,aAAa,GAAG,CAAC,EAAEuB,kBAAkB,CAAC,EAAEtH,KAAK,CAAC,aAAa,CAAC,CAAC;YAClF,OAAO;gBACH6F,MAAME,UAAU,CAAC,aAAa,GAAGuB;YACrC;QACJ;IACJ;IACA,OAAOzB;AACX"}
|
|
@@ -15,7 +15,7 @@ const _reacticons = require("@fluentui/react-icons");
|
|
|
15
15
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
16
16
|
const _dropdownKeyActions = require("../../utils/dropdownKeyActions");
|
|
17
17
|
const _useComboboxBaseState = require("../../utils/useComboboxBaseState");
|
|
18
|
-
const
|
|
18
|
+
const _useComboboxPositioning = require("../../utils/useComboboxPositioning");
|
|
19
19
|
const _useTriggerListboxSlots = require("../../utils/useTriggerListboxSlots");
|
|
20
20
|
const _Listbox = require("../Listbox/Listbox");
|
|
21
21
|
const useDropdown_unstable = (props, ref)=>{
|
|
@@ -33,16 +33,7 @@ const useDropdown_unstable = (props, ref)=>{
|
|
|
33
33
|
'children'
|
|
34
34
|
]
|
|
35
35
|
});
|
|
36
|
-
|
|
37
|
-
const rootRef = _react.useRef(null);
|
|
38
|
-
const [popupWidth, setPopupWidth] = _react.useState();
|
|
39
|
-
_react.useEffect(()=>{
|
|
40
|
-
var _rootRef_current;
|
|
41
|
-
const width = open ? `${(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.clientWidth}px` : undefined;
|
|
42
|
-
setPopupWidth(width);
|
|
43
|
-
}, [
|
|
44
|
-
open
|
|
45
|
-
]);
|
|
36
|
+
const [comboboxPopupRef, comboboxTargetRef] = (0, _useComboboxPositioning.useComboboxPositioning)(props);
|
|
46
37
|
// jump to matching option based on typing
|
|
47
38
|
const searchString = _react.useRef('');
|
|
48
39
|
const [setKeyTimeout, clearKeyTimeout] = (0, _reactutilities.useTimeout)();
|
|
@@ -109,15 +100,24 @@ const useDropdown_unstable = (props, ref)=>{
|
|
|
109
100
|
listboxSlot = baseState.open || baseState.hasFocus ? _reactutilities.slot.optional(props.listbox, {
|
|
110
101
|
renderByDefault: true,
|
|
111
102
|
defaultProps: {
|
|
112
|
-
children: props.children
|
|
113
|
-
style: {
|
|
114
|
-
width: popupWidth
|
|
115
|
-
}
|
|
103
|
+
children: props.children
|
|
116
104
|
},
|
|
117
105
|
elementType: _Listbox.Listbox
|
|
118
106
|
}) : undefined;
|
|
119
|
-
[triggerSlot, listboxSlot] = (0, _useComboboxPopup.useComboboxPopup)(props, triggerSlot, listboxSlot);
|
|
120
107
|
[triggerSlot, listboxSlot] = (0, _useTriggerListboxSlots.useTriggerListboxSlots)(props, baseState, ref, triggerSlot, listboxSlot);
|
|
108
|
+
const listboxRef = (0, _reactutilities.useMergedRefs)(listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.ref, comboboxPopupRef);
|
|
109
|
+
if (listboxSlot) {
|
|
110
|
+
listboxSlot.ref = listboxRef;
|
|
111
|
+
}
|
|
112
|
+
const rootSlot = _reactutilities.slot.always(props.root, {
|
|
113
|
+
defaultProps: {
|
|
114
|
+
'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,
|
|
115
|
+
children: props.children,
|
|
116
|
+
...rootNativeProps
|
|
117
|
+
},
|
|
118
|
+
elementType: 'div'
|
|
119
|
+
});
|
|
120
|
+
rootSlot.ref = (0, _reactutilities.useMergedRefs)(rootSlot.ref, comboboxTargetRef);
|
|
121
121
|
const state = {
|
|
122
122
|
components: {
|
|
123
123
|
root: 'div',
|
|
@@ -125,14 +125,7 @@ const useDropdown_unstable = (props, ref)=>{
|
|
|
125
125
|
expandIcon: 'span',
|
|
126
126
|
listbox: _Listbox.Listbox
|
|
127
127
|
},
|
|
128
|
-
root:
|
|
129
|
-
defaultProps: {
|
|
130
|
-
'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,
|
|
131
|
-
children: props.children,
|
|
132
|
-
...rootNativeProps
|
|
133
|
-
},
|
|
134
|
-
elementType: 'div'
|
|
135
|
-
}),
|
|
128
|
+
root: rootSlot,
|
|
136
129
|
button: triggerSlot,
|
|
137
130
|
listbox: listboxSlot,
|
|
138
131
|
expandIcon: _reactutilities.slot.optional(props.expandIcon, {
|
|
@@ -145,6 +138,5 @@ const useDropdown_unstable = (props, ref)=>{
|
|
|
145
138
|
placeholderVisible: !baseState.value && !!props.placeholder,
|
|
146
139
|
...baseState
|
|
147
140
|
};
|
|
148
|
-
state.root.ref = (0, _reactutilities.useMergedRefs)(state.root.ref, rootRef);
|
|
149
141
|
return state;
|
|
150
142
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useDropdown.js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, useMergedRefs, useTimeout, slot } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\n/**\n * Create the state required to render Dropdown.\n *\n * The returned state can be modified with hooks such as useDropdownStyles_unstable,\n * before being passed to renderDropdown_unstable.\n *\n * @param props - props from this instance of Dropdown\n * @param ref - reference to root HTMLElement of Dropdown\n */ export const useDropdown_unstable = (props, ref)=>{\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsSize: true\n });\n const baseState = useComboboxBaseState(props);\n const { activeOption, getIndexOfId, getOptionsMatchingText, open, setActiveOption, setFocusVisible, setOpen } = baseState;\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: [\n 'children'\n ]\n });\n // set listbox popup width based off the root/trigger width\n const rootRef = React.useRef(null);\n const [popupWidth, setPopupWidth] = React.useState();\n React.useEffect(()=>{\n var _rootRef_current;\n const width = open ? `${(_rootRef_current = rootRef.current) === null || _rootRef_current === void 0 ? void 0 : _rootRef_current.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [\n open\n ]);\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n const getNextMatchingOption = ()=>{\n // first check for matches for the full searchString\n let matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n // if the dropdown is already open and the searchstring is a single character,\n // then look after the current activeOption for letters\n // this is so slowly typing the same letter will cycle through matches\n if (open && searchString.current.length === 1) {\n startIndex++;\n }\n // if there are no direct matches, check if the search is all the same letter, e.g. \"aaa\"\n if (!matches.length) {\n const letters = searchString.current.split('');\n const allSameLetter = letters.length && letters.every((letter)=>letter === letters[0]);\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = (optionText)=>optionText.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\n }\n // if there is an active option and multiple matches,\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);\n return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];\n }\n var _matches_;\n return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;\n };\n const onTriggerKeyDown = (ev)=>{\n // clear timeout, if it exists\n clearKeyTimeout();\n // if the key was a char key, update search string\n if (getDropdownActionFromKey(ev) === 'Type') {\n // update search string\n searchString.current += ev.key.toLowerCase();\n setKeyTimeout(()=>{\n searchString.current = '';\n }, 500);\n // update state\n !open && setOpen(ev, true);\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n // resolve button and listbox slot props\n let triggerSlot;\n let listboxSlot;\n triggerSlot = slot.always(props.button, {\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps\n },\n elementType: 'button'\n });\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n listboxSlot = baseState.open || baseState.hasFocus ? slot.optional(props.listbox, {\n renderByDefault: true,\n defaultProps: {\n children: props.children,\n style: {\n width: popupWidth\n }\n },\n elementType: Listbox\n }) : undefined;\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n const state = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,\n children: props.children,\n ...rootNativeProps\n },\n elementType: 'div'\n }),\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(ChevronDownIcon, null)\n },\n elementType: 'span'\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState\n };\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n return state;\n};\n"],"names":["useDropdown_unstable","props","ref","useFieldControlProps_unstable","supportsLabelFor","supportsSize","baseState","useComboboxBaseState","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","rootRef","React","useRef","popupWidth","setPopupWidth","useState","useEffect","_rootRef_current","width","current","clientWidth","undefined","searchString","setKeyTimeout","clearKeyTimeout","useTimeout","getNextMatchingOption","matcher","optionText","toLowerCase","indexOf","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","_matches_","onTriggerKeyDown","ev","getDropdownActionFromKey","key","nextOption","triggerSlot","listboxSlot","slot","always","button","defaultProps","type","children","value","placeholder","elementType","onKeyDown","mergeCallbacks","hasFocus","optional","listbox","renderByDefault","style","Listbox","useComboboxPopup","useTriggerListboxSlots","state","components","expandIcon","inlinePopup","createElement","ChevronDownIcon","placeholderVisible","useMergedRefs"],"mappings":";;;;+BAiBiBA;;;eAAAA;;;;iEAjBM;4BACuB;4BACQ;gCACqC;oCAClD;sCACJ;kCACJ;wCACM;yBACf;AASb,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,+CAA+C;IAC/CD,QAAQE,IAAAA,yCAA6B,EAACF,OAAO;QACzCG,kBAAkB;QAClBC,cAAc;IAClB;IACA,MAAMC,YAAYC,IAAAA,0CAAoB,EAACN;IACvC,MAAM,EAAEO,YAAY,EAAEC,YAAY,EAAEC,sBAAsB,EAAEC,IAAI,EAAEC,eAAe,EAAEC,eAAe,EAAEC,OAAO,EAAE,GAAGR;IAChH,MAAM,EAAES,SAASC,kBAAkB,EAAEC,MAAMC,eAAe,EAAE,GAAGC,IAAAA,yCAAyB,EAAC;QACrFlB;QACAmB,oBAAoB;QACpBC,mBAAmB;YACf;SACH;IACL;IACA,2DAA2D;IAC3D,MAAMC,UAAUC,OAAMC,MAAM,CAAC;IAC7B,MAAM,CAACC,YAAYC,cAAc,GAAGH,OAAMI,QAAQ;IAClDJ,OAAMK,SAAS,CAAC;QACZ,IAAIC;QACJ,MAAMC,QA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AM;YACNgD,QAAQ;YACRmB,YAAY;YACZR,SAASG,gBAAO;QACpB;QACA9D,MAAM8C,oBAAI,CAACC,MAAM,CAAC/D,MAAMgB,IAAI,EAAE;YAC1BiD,cAAc;gBACV,aAAa,CAACjE,MAAMoF,WAAW,GAAGvB,gBAAgB,QAAQA,gBAAgB,KAAK,IAAI,KAAK,IAAIA,YAAYjB,EAAE,GAAGZ;gBAC7GmC,UAAUnE,MAAMmE,QAAQ;gBACxB,GAAGlD,eAAe;YACtB;YACAqD,aAAa;QACjB;QACAN,QAAQJ;QACRe,SAASd;QACTsB,YAAYrB,oBAAI,CAACY,QAAQ,CAAC1E,MAAMmF,UAAU,EAAE;YACxCP,iBAAiB;YACjBX,cAAc;gBACVE,UAAU,WAAW,GAAG7C,OAAM+D,aAAa,CAACC,8BAAe,EAAE;YACjE;YACAhB,aAAa;QACjB;QACAiB,oBAAoB,CAAClF,UAAU+D,KAAK,IAAI,CAAC,CAACpE,MAAMqE,WAAW;QAC3D,GAAGhE,SAAS;IAChB;IACA4E,MAAMjE,IAAI,CAACf,GAAG,GAAGuF,IAAAA,6BAAa,EAACP,MAAMjE,IAAI,CAACf,GAAG,EAAEoB;IAC/C,OAAO4D;AACX"}
|
|
1
|
+
{"version":3,"sources":["useDropdown.js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, useMergedRefs, useTimeout, slot } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\n/**\n * Create the state required to render Dropdown.\n *\n * The returned state can be modified with hooks such as useDropdownStyles_unstable,\n * before being passed to renderDropdown_unstable.\n *\n * @param props - props from this instance of Dropdown\n * @param ref - reference to root HTMLElement of Dropdown\n */ export const useDropdown_unstable = (props, ref)=>{\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsSize: true\n });\n const baseState = useComboboxBaseState(props);\n const { activeOption, getIndexOfId, getOptionsMatchingText, open, setActiveOption, setFocusVisible, setOpen } = baseState;\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: [\n 'children'\n ]\n });\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n const getNextMatchingOption = ()=>{\n // first check for matches for the full searchString\n let matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n // if the dropdown is already open and the searchstring is a single character,\n // then look after the current activeOption for letters\n // this is so slowly typing the same letter will cycle through matches\n if (open && searchString.current.length === 1) {\n startIndex++;\n }\n // if there are no direct matches, check if the search is all the same letter, e.g. \"aaa\"\n if (!matches.length) {\n const letters = searchString.current.split('');\n const allSameLetter = letters.length && letters.every((letter)=>letter === letters[0]);\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = (optionText)=>optionText.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\n }\n // if there is an active option and multiple matches,\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);\n return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];\n }\n var _matches_;\n return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;\n };\n const onTriggerKeyDown = (ev)=>{\n // clear timeout, if it exists\n clearKeyTimeout();\n // if the key was a char key, update search string\n if (getDropdownActionFromKey(ev) === 'Type') {\n // update search string\n searchString.current += ev.key.toLowerCase();\n setKeyTimeout(()=>{\n searchString.current = '';\n }, 500);\n // update state\n !open && setOpen(ev, true);\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n // resolve button and listbox slot props\n let triggerSlot;\n let listboxSlot;\n triggerSlot = slot.always(props.button, {\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps\n },\n elementType: 'button'\n });\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n listboxSlot = baseState.open || baseState.hasFocus ? slot.optional(props.listbox, {\n renderByDefault: true,\n defaultProps: {\n children: props.children\n },\n elementType: Listbox\n }) : undefined;\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n const listboxRef = useMergedRefs(listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.ref, comboboxPopupRef);\n if (listboxSlot) {\n listboxSlot.ref = listboxRef;\n }\n const rootSlot = slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,\n children: props.children,\n ...rootNativeProps\n },\n elementType: 'div'\n });\n rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);\n const state = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: rootSlot,\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n children: /*#__PURE__*/ React.createElement(ChevronDownIcon, null)\n },\n elementType: 'span'\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState\n };\n return state;\n};\n"],"names":["useDropdown_unstable","props","ref","useFieldControlProps_unstable","supportsLabelFor","supportsSize","baseState","useComboboxBaseState","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","comboboxPopupRef","comboboxTargetRef","useComboboxPositioning","searchString","React","useRef","setKeyTimeout","clearKeyTimeout","useTimeout","getNextMatchingOption","matcher","optionText","toLowerCase","indexOf","current","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","_matches_","undefined","onTriggerKeyDown","ev","getDropdownActionFromKey","key","nextOption","triggerSlot","listboxSlot","slot","always","button","defaultProps","type","children","value","placeholder","elementType","onKeyDown","mergeCallbacks","hasFocus","optional","listbox","renderByDefault","Listbox","useTriggerListboxSlots","listboxRef","useMergedRefs","rootSlot","inlinePopup","state","components","expandIcon","createElement","ChevronDownIcon","placeholderVisible"],"mappings":";;;;+BAiBiBA;;;eAAAA;;;;iEAjBM;4BACuB;4BACQ;gCACqC;oCAClD;sCACJ;wCACE;wCACA;yBACf;AASb,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,+CAA+C;IAC/CD,QAAQE,IAAAA,yCAA6B,EAACF,OAAO;QACzCG,kBAAkB;QAClBC,cAAc;IAClB;IACA,MAAMC,YAAYC,IAAAA,0CAAoB,EAACN;IACvC,MAAM,EAAEO,YAAY,EAAEC,YAAY,EAAEC,sBAAsB,EAAEC,IAAI,EAAEC,eAAe,EAAEC,eAAe,EAAEC,OAAO,EAAE,GAAGR;IAChH,MAAM,EAAES,SAASC,kBAAkB,EAAEC,MAAMC,eAAe,EAAE,GAAGC,IAAAA,yCAAyB,EAAC;QACrFlB;QACAmB,oBAAoB;QACpBC,mBAAmB;YACf;SACH;IACL;IACA,MAAM,CAACC,kBAAkBC,kBAAkB,GAAGC,IAAAA,8CAAsB,EAACvB;IACrE,0CAA0C;IAC1C,MAAMwB,eAAeC,OAAMC,MAAM,CAAC;IAClC,MAAM,CAACC,eAAeC,gBAAgB,GAAGC,IAAAA,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3E,GAAG,GAAG0E,IAAAA,6BAAa,EAACC,SAAS3E,GAAG,EAAEqB;IAC3C,MAAMwD,QAAQ;QACVC,YAAY;YACR/D,MAAM;YACN2C,QAAQ;YACRqB,YAAY;YACZV,SAASE,gBAAO;QACpB;QACAxD,MAAM4D;QACNjB,QAAQJ;QACRe,SAASd;QACTwB,YAAYvB,oBAAI,CAACY,QAAQ,CAACrE,MAAMgF,UAAU,EAAE;YACxCT,iBAAiB;YACjBX,cAAc;gBACVE,UAAU,WAAW,GAAGrC,OAAMwD,aAAa,CAACC,8BAAe,EAAE;YACjE;YACAjB,aAAa;QACjB;QACAkB,oBAAoB,CAAC9E,UAAU0D,KAAK,IAAI,CAAC,CAAC/D,MAAMgE,WAAW;QAC3D,GAAG3D,SAAS;IAChB;IACA,OAAOyE;AACX"}
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "useComboboxPositioning", {
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: function() {
|
|
8
|
-
return
|
|
8
|
+
return useComboboxPositioning;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
11
12
|
const _reactpositioning = require("@fluentui/react-positioning");
|
|
12
|
-
const
|
|
13
|
-
function
|
|
13
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
14
|
+
function useComboboxPositioning(props) {
|
|
14
15
|
const { positioning } = props;
|
|
15
16
|
// Set a default set of fallback positions to try if the dropdown does not fit on screen
|
|
16
17
|
const fallbackPositions = [
|
|
@@ -29,19 +30,12 @@ function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
|
|
|
29
30
|
mainAxis: 2
|
|
30
31
|
},
|
|
31
32
|
fallbackPositions,
|
|
33
|
+
matchTargetSize: 'width',
|
|
32
34
|
...(0, _reactpositioning.resolvePositioningShorthand)(positioning)
|
|
33
35
|
};
|
|
34
36
|
const { targetRef, containerRef } = (0, _reactpositioning.usePositioning)(popperOptions);
|
|
35
|
-
const listboxRef = (0, _reactutilities.useMergedRefs)(listboxShorthand === null || listboxShorthand === void 0 ? void 0 : listboxShorthand.ref, containerRef);
|
|
36
|
-
const listbox = listboxShorthand && {
|
|
37
|
-
...listboxShorthand,
|
|
38
|
-
ref: listboxRef
|
|
39
|
-
};
|
|
40
37
|
return [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
ref: (0, _reactutilities.useMergedRefs)(triggerShorthand === null || triggerShorthand === void 0 ? void 0 : triggerShorthand.ref, targetRef)
|
|
44
|
-
},
|
|
45
|
-
listbox
|
|
38
|
+
containerRef,
|
|
39
|
+
targetRef
|
|
46
40
|
];
|
|
47
41
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useComboboxPositioning.js"],"sourcesContent":["import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport * as React from 'react';\nexport function useComboboxPositioning(props) {\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 matchTargetSize: 'width',\n ...resolvePositioningShorthand(positioning)\n };\n const { targetRef, containerRef } = usePositioning(popperOptions);\n return [\n containerRef,\n targetRef\n ];\n}\n"],"names":["useComboboxPositioning","props","positioning","fallbackPositions","popperOptions","position","align","offset","crossAxis","mainAxis","matchTargetSize","resolvePositioningShorthand","targetRef","containerRef","usePositioning"],"mappings":";;;;+BAEgBA;;;eAAAA;;;;kCAF4C;iEACrC;AAChB,SAASA,uBAAuBC,KAAK;IACxC,MAAM,EAAEC,WAAW,EAAE,GAAGD;IACxB,wFAAwF;IACxF,MAAME,oBAAoB;QACtB;QACA;QACA;QACA;QACA;KACH;IACD,iBAAiB;IACjB,MAAMC,gBAAgB;QAClBC,UAAU;QACVC,OAAO;QACPC,QAAQ;YACJC,WAAW;YACXC,UAAU;QACd;QACAN;QACAO,iBAAiB;QACjB,GAAGC,IAAAA,6CAA2B,EAACT,YAAY;IAC/C;IACA,MAAM,EAAEU,SAAS,EAAEC,YAAY,EAAE,GAAGC,IAAAA,gCAAc,EAACV;IACnD,OAAO;QACHS;QACAD;KACH;AACL"}
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "useTriggerListboxSlots", {
|
|
|
10
10
|
});
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
13
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
|
13
14
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
14
15
|
const _dropdownKeyActions = require("../utils/dropdownKeyActions");
|
|
15
16
|
function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
|
|
@@ -17,13 +18,16 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
|
|
|
17
18
|
const { activeOption, getCount, getIndexOfId, getOptionAtIndex, ignoreNextBlur, open, selectOption, setActiveOption, setFocusVisible, setHasFocus, setOpen } = state;
|
|
18
19
|
// handle trigger focus/blur
|
|
19
20
|
const triggerRef = _react.useRef(null);
|
|
21
|
+
const listboxRef = _react.useRef(null);
|
|
20
22
|
// resolve listbox shorthand props
|
|
21
23
|
const listboxId = (0, _reactutilities.useId)('fluent-listbox', listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id);
|
|
24
|
+
const mergedListboxRef = (0, _reactutilities.useMergedRefs)(listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.ref, listboxRef);
|
|
22
25
|
const listbox = listboxSlot && {
|
|
23
26
|
id: listboxId,
|
|
24
27
|
multiselect,
|
|
25
28
|
tabIndex: undefined,
|
|
26
|
-
...listboxSlot
|
|
29
|
+
...listboxSlot,
|
|
30
|
+
ref: mergedListboxRef
|
|
27
31
|
};
|
|
28
32
|
// resolve trigger shorthand props
|
|
29
33
|
const trigger = {
|
|
@@ -47,8 +51,17 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
|
|
|
47
51
|
const listboxOnMouseOver = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
|
|
48
52
|
setFocusVisible(false);
|
|
49
53
|
}, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseOver));
|
|
54
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
|
55
|
+
const documentOnMouseUp = (0, _reactutilities.useEventCallback)((ev)=>{
|
|
56
|
+
var _listboxRef_current;
|
|
57
|
+
if (!((_listboxRef_current = listboxRef.current) === null || _listboxRef_current === void 0 ? void 0 : _listboxRef_current.contains(ev.target))) {
|
|
58
|
+
setOpen(ev, false);
|
|
59
|
+
}
|
|
60
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mouseup', documentOnMouseUp);
|
|
61
|
+
});
|
|
50
62
|
const listboxOnMouseDown = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
|
|
51
63
|
ignoreNextBlur.current = true;
|
|
64
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mouseup', documentOnMouseUp);
|
|
52
65
|
}, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseDown));
|
|
53
66
|
// listbox is nullable, only add event handlers if it exists
|
|
54
67
|
if (listbox) {
|
|
@@ -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 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,GAAG,EAAEC,WAAW,EAAEC,WAAW;IAClF,MAAM,EAAEC,WAAW,EAAE,GAAGL;IACxB,MAAM,EAAEM,YAAY,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,IAAI,EAAEC,YAAY,EAAEC,eAAe,EAAEC,eAAe,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAAGf;IAC/J,4BAA4B;IAC5B,MAAMgB,aAAaC,OAAMC,MAAM,CAAC;IAChC,kCAAkC;IAClC,MAAMC,YAAYC,IAAAA,qBAAK,EAAC,kBAAkBjB,gBAAgB,QAAQA,gBAAgB,KAAK,IAAI,KAAK,IAAIA,YAAYkB,EAAE;IAClH,MAAMC,UAAUnB,eAAe;QAC3BkB,IAAIF;QACJf;QACAmB,UAAUC;QACV,GAAGrB,WAAW;IAClB;IACA,kCAAkC;IAClC,MAAMsB,UAAU;QACZ,iBAAiBf;QACjB,yBAAyBA,OAAOL,iBAAiB,QAAQA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAagB,EAAE,GAAGG;QAC9GE,MAAM;QACN,GAAGxB,WAAW;QACd,yEAAyE;QACzE,iFAAiF;QACjF,4EAA4E;QAC5ED,KAAK0B,IAAAA,6BAAa,EAAC1B,KAAKC,gBAAgB,QAAQA,gBAAgB,KAAK,IAAI,KAAK,IAAIA,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Ac,EAAC,CAACC;QAChC,MAAMY,SAASC,IAAAA,4CAAwB,EAACb,OAAO;YAC3CrB;YACAN;QACJ;QACA,MAAMyC,WAAWvC,aAAa;QAC9B,MAAMwC,cAAczC,eAAeE,aAAaF,aAAagB,EAAE,IAAI,CAAC;QACpE,IAAI0B,WAAWD;QACf,OAAOH;YACH,KAAK;gBACDZ,MAAMiB,cAAc;gBACpBnC,gBAAgB;gBAChBE,QAAQgB,OAAO;gBACf;YACJ,KAAK;gBACD,wEAAwE;gBACxEA,MAAMkB,eAAe;gBACrBlB,MAAMiB,cAAc;gBACpBjC,QAAQgB,OAAO;gBACf;YACJ,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"}
|
|
1
|
+
{"version":3,"sources":["useTriggerListboxSlots.js"],"sourcesContent":["import * as React from 'react';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\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 const listboxRef = 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 mergedListboxRef = useMergedRefs(listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.ref, listboxRef);\n const listbox = listboxSlot && {\n id: listboxId,\n multiselect,\n tabIndex: undefined,\n ...listboxSlot,\n ref: mergedListboxRef\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 { targetDocument } = useFluent_unstable();\n const documentOnMouseUp = useEventCallback((ev)=>{\n var _listboxRef_current;\n if (!((_listboxRef_current = listboxRef.current) === null || _listboxRef_current === void 0 ? void 0 : _listboxRef_current.contains(ev.target))) {\n setOpen(ev, false);\n }\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('mouseup', documentOnMouseUp);\n });\n const listboxOnMouseDown = useEventCallback(mergeCallbacks((event)=>{\n ignoreNextBlur.current = true;\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('mouseup', documentOnMouseUp);\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","listboxRef","listboxId","useId","id","mergedListboxRef","useMergedRefs","listbox","tabIndex","undefined","trigger","role","listboxOnClick","useEventCallback","mergeCallbacks","event","_triggerRef_current","current","focus","onClick","listboxOnMouseOver","onMouseOver","targetDocument","useFluent_unstable","documentOnMouseUp","ev","_listboxRef_current","contains","target","removeEventListener","listboxOnMouseDown","addEventListener","onMouseDown","onBlur","onFocus","onKeyDown","action","getDropdownActionFromKey","maxIndex","activeIndex","newIndex","preventDefault","stopPropagation","disabled","getIndexFromAction"],"mappings":";;;;+BAQoBA;;;eAAAA;;;;iEARG;qCACY;gCACoC;oCACV;AAKlD,SAASA,uBAAuBC,KAAK,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,EAAEC,WAAW;IAClF,MAAM,EAAEC,WAAW,EAAE,GAAGL;IACxB,MAAM,EAAEM,YAAY,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,IAAI,EAAEC,YAAY,EAAEC,eAAe,EAAEC,eAAe,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAAGf;IAC/J,4BAA4B;IAC5B,MAAMgB,aAAaC,OAAMC,MAAM,CAAC;IAChC,MAAMC,aAAaF,OAAMC,MAAM,CAAC;IAChC,kC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YACAN;QACJ;QACA,MAAMoD,WAAWlD,aAAa;QAC9B,MAAMmD,cAAcpD,eAAeE,aAAaF,aAAaiB,EAAE,IAAI,CAAC;QACpE,IAAIoC,WAAWD;QACf,OAAOH;YACH,KAAK;gBACDrB,MAAM0B,cAAc;gBACpB9C,gBAAgB;gBAChBE,QAAQkB,OAAO;gBACf;YACJ,KAAK;gBACD,wEAAwE;gBACxEA,MAAM2B,eAAe;gBACrB3B,MAAM0B,cAAc;gBACpB5C,QAAQkB,OAAO;gBACf;YACJ,KAAK;gBACD,CAAC7B,eAAe,CAAEC,CAAAA,iBAAiB,QAAQA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAawD,QAAQ,AAAD,KAAM9C,QAAQkB,OAAO;YAC3H,cAAc;YACd,KAAK;gBACD5B,gBAAgBM,aAAasB,OAAO5B;gBACpC4B,MAAM0B,cAAc;gBACpB;YACJ,KAAK;gBACD,CAACvD,eAAeC,gBAAgBM,aAAasB,OAAO5B;gBACpD;YACJ;gBACIqD,WAAWI,IAAAA,sCAAkB,EAACR,QAAQG,aAAaD;QAC3D;QACA,IAAIE,aAAaD,aAAa;YAC1B,mEAAmE;YACnExB,MAAM0B,cAAc;YACpB/C,gBAAgBJ,iBAAiBkD;YACjC7C,gBAAgB;QACpB;IACJ,GAAGe,QAAQyB,SAAS;IACpBzB,QAAQW,WAAW,GAAGP,IAAAA,8BAAc,EAAC,CAACC;QAClCpB,gBAAgB;IACpB,GAAGe,QAAQW,WAAW;IACtB,OAAO;QACHX;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.29",
|
|
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.
|
|
36
|
+
"@fluentui/keyboard-keys": "^9.0.7",
|
|
37
|
+
"@fluentui/react-context-selector": "^9.1.42",
|
|
38
|
+
"@fluentui/react-field": "^9.1.41",
|
|
39
39
|
"@fluentui/react-icons": "^2.0.217",
|
|
40
|
-
"@fluentui/react-jsx-runtime": "^9.0.
|
|
41
|
-
"@fluentui/react-portal": "^9.
|
|
42
|
-
"@fluentui/react-positioning": "^9.
|
|
43
|
-
"@fluentui/react-shared-contexts": "^9.
|
|
44
|
-
"@fluentui/react-theme": "^9.1.
|
|
45
|
-
"@fluentui/react-utilities": "^9.15.
|
|
40
|
+
"@fluentui/react-jsx-runtime": "^9.0.19",
|
|
41
|
+
"@fluentui/react-portal": "^9.4.0",
|
|
42
|
+
"@fluentui/react-positioning": "^9.10.0",
|
|
43
|
+
"@fluentui/react-shared-contexts": "^9.12.0",
|
|
44
|
+
"@fluentui/react-theme": "^9.1.16",
|
|
45
|
+
"@fluentui/react-utilities": "^9.15.2",
|
|
46
46
|
"@griffel/react": "^1.5.14",
|
|
47
47
|
"@swc/helpers": "^0.5.1"
|
|
48
48
|
},
|
|
@@ -67,5 +67,11 @@
|
|
|
67
67
|
"require": "./lib-commonjs/index.js"
|
|
68
68
|
},
|
|
69
69
|
"./package.json": "./package.json"
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"*.md",
|
|
73
|
+
"dist/*.d.ts",
|
|
74
|
+
"lib",
|
|
75
|
+
"lib-commonjs"
|
|
76
|
+
]
|
|
71
77
|
}
|