@fluentui/react-combobox 9.7.4 → 9.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +41 -9
  2. package/dist/index.d.ts +54 -11
  3. package/lib/components/Combobox/Combobox.types.js.map +1 -1
  4. package/lib/components/Combobox/renderCombobox.js +15 -11
  5. package/lib/components/Combobox/renderCombobox.js.map +1 -1
  6. package/lib/components/Combobox/useCombobox.js +12 -4
  7. package/lib/components/Combobox/useCombobox.js.map +1 -1
  8. package/lib/components/Combobox/useInputTriggerSlot.js +14 -12
  9. package/lib/components/Combobox/useInputTriggerSlot.js.map +1 -1
  10. package/lib/components/Dropdown/Dropdown.types.js.map +1 -1
  11. package/lib/components/Dropdown/renderDropdown.js +19 -15
  12. package/lib/components/Dropdown/renderDropdown.js.map +1 -1
  13. package/lib/components/Dropdown/useButtonTriggerSlot.js +51 -31
  14. package/lib/components/Dropdown/useButtonTriggerSlot.js.map +1 -1
  15. package/lib/components/Dropdown/useDropdown.js +14 -4
  16. package/lib/components/Dropdown/useDropdown.js.map +1 -1
  17. package/lib/components/Listbox/Listbox.types.js.map +1 -1
  18. package/lib/components/Listbox/renderListbox.js +7 -3
  19. package/lib/components/Listbox/renderListbox.js.map +1 -1
  20. package/lib/components/Listbox/useListbox.js +43 -35
  21. package/lib/components/Listbox/useListbox.js.map +1 -1
  22. package/lib/components/Option/Option.types.js.map +1 -1
  23. package/lib/components/Option/useOption.js +7 -11
  24. package/lib/components/Option/useOption.js.map +1 -1
  25. package/lib/components/Option/useOptionStyles.styles.js +27 -28
  26. package/lib/components/Option/useOptionStyles.styles.js.map +1 -1
  27. package/lib/contexts/useComboboxContextValues.js +14 -5
  28. package/lib/contexts/useComboboxContextValues.js.map +1 -1
  29. package/lib/contexts/useListboxContextValues.js +12 -5
  30. package/lib/contexts/useListboxContextValues.js.map +1 -1
  31. package/lib/utils/ComboboxBase.types.js.map +1 -1
  32. package/lib/utils/OptionCollection.types.js.map +1 -1
  33. package/lib/utils/Selection.types.js.map +1 -1
  34. package/lib/utils/dropdownKeyActions.js +0 -21
  35. package/lib/utils/dropdownKeyActions.js.map +1 -1
  36. package/lib/utils/useComboboxBaseState.js +52 -14
  37. package/lib/utils/useComboboxBaseState.js.map +1 -1
  38. package/lib/utils/useOptionCollection.js +18 -45
  39. package/lib/utils/useOptionCollection.js.map +1 -1
  40. package/lib/utils/useTriggerSlot.js +86 -33
  41. package/lib/utils/useTriggerSlot.js.map +1 -1
  42. package/lib-commonjs/components/Combobox/renderCombobox.js +15 -11
  43. package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
  44. package/lib-commonjs/components/Combobox/useCombobox.js +12 -4
  45. package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
  46. package/lib-commonjs/components/Combobox/useInputTriggerSlot.js +14 -12
  47. package/lib-commonjs/components/Combobox/useInputTriggerSlot.js.map +1 -1
  48. package/lib-commonjs/components/Dropdown/renderDropdown.js +19 -15
  49. package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
  50. package/lib-commonjs/components/Dropdown/useButtonTriggerSlot.js +51 -31
  51. package/lib-commonjs/components/Dropdown/useButtonTriggerSlot.js.map +1 -1
  52. package/lib-commonjs/components/Dropdown/useDropdown.js +14 -4
  53. package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
  54. package/lib-commonjs/components/Listbox/renderListbox.js +7 -3
  55. package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
  56. package/lib-commonjs/components/Listbox/useListbox.js +42 -34
  57. package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
  58. package/lib-commonjs/components/Option/useOption.js +7 -11
  59. package/lib-commonjs/components/Option/useOption.js.map +1 -1
  60. package/lib-commonjs/components/Option/useOptionStyles.styles.js +85 -85
  61. package/lib-commonjs/components/Option/useOptionStyles.styles.js.map +1 -1
  62. package/lib-commonjs/contexts/useComboboxContextValues.js +13 -5
  63. package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
  64. package/lib-commonjs/contexts/useListboxContextValues.js +13 -5
  65. package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
  66. package/lib-commonjs/utils/dropdownKeyActions.js +3 -30
  67. package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
  68. package/lib-commonjs/utils/useComboboxBaseState.js +52 -14
  69. package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
  70. package/lib-commonjs/utils/useOptionCollection.js +18 -45
  71. package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
  72. package/lib-commonjs/utils/useTriggerSlot.js +84 -31
  73. package/lib-commonjs/utils/useTriggerSlot.js.map +1 -1
  74. package/package.json +9 -8
  75. package/lib/utils/useScrollOptionsIntoView.js +0 -29
  76. package/lib/utils/useScrollOptionsIntoView.js.map +0 -1
  77. package/lib-commonjs/utils/useScrollOptionsIntoView.js +0 -40
  78. package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["useInputTriggerSlot.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';\nimport { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';\nimport { useTriggerSlot } from '../../utils/useTriggerSlot';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\n/*\n * useInputTriggerSlot 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 useInputTriggerSlot(triggerFromProps, ref, options) {\n const { state: { open, value, activeOption, selectOption, setValue, setActiveOption, setFocusVisible, multiselect, selectedOptions, clearSelection, getOptionsMatchingText, getIndexOfId, setOpen }, freeform, defaultProps } = options;\n const onBlur = (ev)=>{\n // handle selection and updating value if freeform is false\n if (!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 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 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 // update value and active option based on input\n const onChange = (ev)=>{\n const inputValue = ev.target.value;\n // update uncontrolled value\n 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 const trigger = useTriggerSlot(triggerFromProps, ref, {\n state: options.state,\n defaultProps,\n elementType: 'input'\n });\n trigger.onChange = mergeCallbacks(trigger.onChange, onChange);\n trigger.onBlur = mergeCallbacks(trigger.onBlur, onBlur);\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 /**\n * Freeform combobox should not select\n */ const defaultOnKeyDown = trigger.onKeyDown;\n const onKeyDown = useEventCallback((ev)=>{\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n 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 ((isTyping.current || !open) && ev.key === ' ') {\n var _triggerFromProps_onKeyDown;\n triggerFromProps === null || triggerFromProps === void 0 ? void 0 : (_triggerFromProps_onKeyDown = triggerFromProps.onKeyDown) === null || _triggerFromProps_onKeyDown === void 0 ? void 0 : _triggerFromProps_onKeyDown.call(triggerFromProps, ev);\n return;\n }\n defaultOnKeyDown === null || defaultOnKeyDown === void 0 ? void 0 : defaultOnKeyDown(ev);\n });\n trigger.onKeyDown = onKeyDown;\n if (hideActiveDescendant) {\n trigger['aria-activedescendant'] = undefined;\n }\n return trigger;\n}\n"],"names":["useInputTriggerSlot","triggerFromProps","ref","options","state","open","value","activeOption","selectOption","setValue","setActiveOption","setFocusVisible","multiselect","selectedOptions","clearSelection","getOptionsMatchingText","getIndexOfId","setOpen","freeform","defaultProps","onBlur","ev","trim","toLowerCase","text","undefined","getOptionFromInput","inputValue","searchString","length","matcher","optionText","indexOf","matches","startIndex","id","nextMatch","find","option","_matches_","onChange","target","matchingOption","trigger","useTriggerSlot","elementType","mergeCallbacks","hideActiveDescendant","setHideActiveDescendant","React","useState","isTyping","useRef","defaultOnKeyDown","onKeyDown","useEventCallback","getDropdownActionFromKey","key","ArrowLeft","ArrowRight","action","current","_triggerFromProps_onKeyDown","call"],"mappings":";;;;+BASoBA;;;eAAAA;;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;QACA,oDAAoD;QACpD,MAAMY,SAASJ,IAAAA,4CAAwB,EAACnC,IAAI;YACxChB;YACAO;QACJ;QACA,IAAIgD,WAAW,QAAQ;YACnBT,SAASU,OAAO,GAAG;QACvB,OAAO,IAAID,WAAW,UAAUvC,GAAGoC,GAAG,KAAK,OAAOG,WAAW,UAAUA,WAAW,cAAcA,WAAW,WAAWA,WAAW,UAAUA,WAAW,YAAYA,WAAW,YAAY;YACrLT,SAASU,OAAO,GAAG;QACvB;QACA,wGAAwG;QACxG,IAAI,AAACV,CAAAA,SAASU,OAAO,IAAI,CAACxD,IAAG,KAAMgB,GAAGoC,GAAG,KAAK,KAAK;YAC/C,IAAIK;YACJ7D,qBAAqB,QAAQA,qBAAqB,KAAK,IAAI,KAAK,IAAI,AAAC6D,CAAAA,8BAA8B7D,iBAAiBqD,SAAS,AAAD,MAAO,QAAQQ,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BC,IAAI,CAAC9D,kBAAkBoB;YAChP;QACJ;QACAgC,qBAAqB,QAAQA,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBhC;IACzF;IACAsB,QAAQW,SAAS,GAAGA;IACpB,IAAIP,sBAAsB;QACtBJ,OAAO,CAAC,wBAAwB,GAAGlB;IACvC;IACA,OAAOkB;AACX"}
1
+ {"version":3,"sources":["useInputTriggerSlot.js"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';\nimport { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';\nimport { useTriggerSlot } from '../../utils/useTriggerSlot';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\n/*\n * useInputTriggerSlot 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 useInputTriggerSlot(triggerFromProps, ref, options) {\n const { state: { open, value, selectOption, setValue, multiselect, selectedOptions, clearSelection, getOptionById, setOpen }, freeform, defaultProps, activeDescendantController } = options;\n const onBlur = (ev)=>{\n // handle selection and updating value if freeform is false\n if (!open && !freeform) {\n const activeOptionId = activeDescendantController.active();\n const activeOption = activeOptionId ? getOptionById(activeOptionId) : null;\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 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 const getOptionFromInput = (inputValue)=>{\n const searchString = inputValue === null || inputValue === void 0 ? void 0 : inputValue.trim().toLowerCase();\n if (!searchString || searchString.length === 0) {\n activeDescendantController.blur();\n return;\n }\n const matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString) === 0;\n const match = activeDescendantController.find((id)=>{\n const option = getOptionById(id);\n return !!option && matcher(option.text);\n });\n if (!match) {\n activeDescendantController.blur();\n return undefined;\n }\n return getOptionById(match);\n };\n // update value and active option based on input\n const onChange = (ev)=>{\n const inputValue = ev.target.value;\n // update uncontrolled value\n setValue(inputValue);\n // handle updating active option based on input\n const matchingOption = getOptionFromInput(inputValue);\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 const trigger = useTriggerSlot(triggerFromProps, ref, {\n state: options.state,\n defaultProps,\n elementType: 'input',\n activeDescendantController\n });\n trigger.onChange = mergeCallbacks(trigger.onChange, onChange);\n trigger.onBlur = mergeCallbacks(trigger.onBlur, onBlur);\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 /**\n * Freeform combobox should not select\n */ const defaultOnKeyDown = trigger.onKeyDown;\n const onKeyDown = useEventCallback((ev)=>{\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n 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 ((isTyping.current || !open) && ev.key === ' ') {\n var _triggerFromProps_onKeyDown;\n triggerFromProps === null || triggerFromProps === void 0 ? void 0 : (_triggerFromProps_onKeyDown = triggerFromProps.onKeyDown) === null || _triggerFromProps_onKeyDown === void 0 ? void 0 : _triggerFromProps_onKeyDown.call(triggerFromProps, ev);\n return;\n }\n defaultOnKeyDown === null || defaultOnKeyDown === void 0 ? void 0 : defaultOnKeyDown(ev);\n });\n trigger.onKeyDown = onKeyDown;\n if (hideActiveDescendant) {\n trigger['aria-activedescendant'] = undefined;\n }\n return trigger;\n}\n"],"names":["useInputTriggerSlot","triggerFromProps","ref","options","state","open","value","selectOption","setValue","multiselect","selectedOptions","clearSelection","getOptionById","setOpen","freeform","defaultProps","activeDescendantController","onBlur","ev","activeOptionId","active","activeOption","trim","toLowerCase","text","undefined","getOptionFromInput","inputValue","searchString","length","blur","matcher","optionText","indexOf","match","find","id","option","onChange","target","matchingOption","trigger","useTriggerSlot","elementType","mergeCallbacks","hideActiveDescendant","setHideActiveDescendant","React","useState","isTyping","useRef","defaultOnKeyDown","onKeyDown","useEventCallback","getDropdownActionFromKey","key","ArrowLeft","ArrowRight","action","current","_triggerFromProps_onKeyDown","call"],"mapp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ASU,OAAO,GAAG;QACvB,OAAO,IAAID,WAAW,UAAUxC,GAAGqC,GAAG,KAAK,OAAOG,WAAW,UAAUA,WAAW,cAAcA,WAAW,WAAWA,WAAW,UAAUA,WAAW,YAAYA,WAAW,YAAY;YACrLT,SAASU,OAAO,GAAG;QACvB;QACA,wGAAwG;QACxG,IAAI,AAACV,CAAAA,SAASU,OAAO,IAAI,CAACtD,IAAG,KAAMa,GAAGqC,GAAG,KAAK,KAAK;YAC/C,IAAIK;YACJ3D,qBAAqB,QAAQA,qBAAqB,KAAK,IAAI,KAAK,IAAI,AAAC2D,CAAAA,8BAA8B3D,iBAAiBmD,SAAS,AAAD,MAAO,QAAQQ,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BC,IAAI,CAAC5D,kBAAkBiB;YAChP;QACJ;QACAiC,qBAAqB,QAAQA,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBjC;IACzF;IACAuB,QAAQW,SAAS,GAAGA;IACpB,IAAIP,sBAAsB;QACtBJ,OAAO,CAAC,wBAAwB,GAAGhB;IACvC;IACA,OAAOgB;AACX"}
@@ -11,25 +11,29 @@ Object.defineProperty(exports, "renderDropdown_unstable", {
11
11
  const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
12
  const _reactportal = require("@fluentui/react-portal");
13
13
  const _reactutilities = require("@fluentui/react-utilities");
14
+ const _reactaria = require("@fluentui/react-aria");
14
15
  const _ComboboxContext = require("../../contexts/ComboboxContext");
15
16
  const renderDropdown_unstable = (state, contextValues)=>{
16
17
  (0, _reactutilities.assertSlots)(state);
17
18
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {
18
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_ComboboxContext.ComboboxContext.Provider, {
19
- value: contextValues.combobox,
20
- children: [
21
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.button, {
22
- children: [
23
- state.button.children,
24
- state.expandIcon && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.expandIcon, {})
25
- ]
26
- }),
27
- state.clearButton && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.clearButton, {}),
28
- state.listbox && (state.inlinePopup ? /*#__PURE__*/ (0, _jsxruntime.jsx)(state.listbox, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactportal.Portal, {
29
- mountNode: state.mountNode,
30
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.listbox, {})
31
- }))
32
- ]
19
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactaria.ActiveDescendantContextProvider, {
20
+ value: contextValues.activeDescendant,
21
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_ComboboxContext.ComboboxContext.Provider, {
22
+ value: contextValues.combobox,
23
+ children: [
24
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(state.button, {
25
+ children: [
26
+ state.button.children,
27
+ state.expandIcon && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.expandIcon, {})
28
+ ]
29
+ }),
30
+ state.clearButton && /*#__PURE__*/ (0, _jsxruntime.jsx)(state.clearButton, {}),
31
+ state.listbox && (state.inlinePopup ? /*#__PURE__*/ (0, _jsxruntime.jsx)(state.listbox, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactportal.Portal, {
32
+ mountNode: state.mountNode,
33
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.listbox, {})
34
+ }))
35
+ ]
36
+ })
33
37
  })
34
38
  });
35
39
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["renderDropdown.js"],"sourcesContent":[" import { jsx as _jsx, jsxs as _jsxs } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { Portal } from '@fluentui/react-portal';\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\n/**\n * Render the final JSX of Dropdown\n */ export const renderDropdown_unstable = (state, contextValues)=>{\n assertSlots(state);\n return /*#__PURE__*/ _jsx(state.root, {\n children: /*#__PURE__*/ _jsxs(ComboboxContext.Provider, {\n value: contextValues.combobox,\n children: [\n /*#__PURE__*/ _jsxs(state.button, {\n children: [\n state.button.children,\n state.expandIcon && /*#__PURE__*/ _jsx(state.expandIcon, {})\n ]\n }),\n state.clearButton && /*#__PURE__*/ _jsx(state.clearButton, {}),\n state.listbox && (state.inlinePopup ? /*#__PURE__*/ _jsx(state.listbox, {}) : /*#__PURE__*/ _jsx(Portal, {\n mountNode: state.mountNode,\n children: /*#__PURE__*/ _jsx(state.listbox, {})\n }))\n ]\n })\n });\n};\n"],"names":["renderDropdown_unstable","state","contextValues","assertSlots","_jsx","root","children","_jsxs","ComboboxContext","Provider","value","combobox","button","expandIcon","clearButton","listbox","inlinePopup","Portal","mountNode"],"mappings":";;;;+BAMiBA;;;eAAAA;;;4BAN4B;6BACtB;gCACK;iCACI;AAGrB,MAAMA,0BAA0B,CAACC,OAAOC;IAC/CC,IAAAA,2BAAW,EAACF;IACZ,OAAO,WAAW,GAAGG,IAAAA,eAAI,EAACH,MAAMI,IAAI,EAAE;QAClCC,UAAU,WAAW,GAAGC,IAAAA,gBAAK,EAACC,gCAAe,CAACC,QAAQ,EAAE;YACpDC,OAAOR,cAAcS,QAAQ;YAC7BL,UAAU;gBACN,WAAW,GAAGC,IAAAA,gBAAK,EAACN,MAAMW,MAAM,EAAE;oBAC9BN,UAAU;wBACNL,MAAMW,MAAM,CAACN,QAAQ;wBACrBL,MAAMY,UAAU,IAAI,WAAW,GAAGT,IAAAA,eAAI,EAACH,MAAMY,UAAU,EAAE,CAAC;qBAC7D;gBACL;gBACAZ,MAAMa,WAAW,IAAI,WAAW,GAAGV,IAAAA,eAAI,EAACH,MAAMa,WAAW,EAAE,CAAC;gBAC5Db,MAAMc,OAAO,IAAKd,CAAAA,MAAMe,WAAW,GAAG,WAAW,GAAGZ,IAAAA,eAAI,EAACH,MAAMc,OAAO,EAAE,CAAC,KAAK,WAAW,GAAGX,IAAAA,eAAI,EAACa,mBAAM,EAAE;oBACrGC,WAAWjB,MAAMiB,SAAS;oBAC1BZ,UAAU,WAAW,GAAGF,IAAAA,eAAI,EAACH,MAAMc,OAAO,EAAE,CAAC;gBACjD,EAAC;aACJ;QACL;IACJ;AACJ"}
1
+ {"version":3,"sources":["renderDropdown.js"],"sourcesContent":[" import { jsx as _jsx, jsxs as _jsxs } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { Portal } from '@fluentui/react-portal';\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { ActiveDescendantContextProvider } from '@fluentui/react-aria';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\n/**\n * Render the final JSX of Dropdown\n */ export const renderDropdown_unstable = (state, contextValues)=>{\n assertSlots(state);\n return /*#__PURE__*/ _jsx(state.root, {\n children: /*#__PURE__*/ _jsx(ActiveDescendantContextProvider, {\n value: contextValues.activeDescendant,\n children: /*#__PURE__*/ _jsxs(ComboboxContext.Provider, {\n value: contextValues.combobox,\n children: [\n /*#__PURE__*/ _jsxs(state.button, {\n children: [\n state.button.children,\n state.expandIcon && /*#__PURE__*/ _jsx(state.expandIcon, {})\n ]\n }),\n state.clearButton && /*#__PURE__*/ _jsx(state.clearButton, {}),\n state.listbox && (state.inlinePopup ? /*#__PURE__*/ _jsx(state.listbox, {}) : /*#__PURE__*/ _jsx(Portal, {\n mountNode: state.mountNode,\n children: /*#__PURE__*/ _jsx(state.listbox, {})\n }))\n ]\n })\n })\n });\n};\n"],"names":["renderDropdown_unstable","state","contextValues","assertSlots","_jsx","root","children","ActiveDescendantContextProvider","value","activeDescendant","_jsxs","ComboboxContext","Provider","combobox","button","expandIcon","clearButton","listbox","inlinePopup","Portal","mountNode"],"mappings":";;;;+BAOiBA;;;eAAAA;;;4BAP4B;6BACtB;gCACK;2BACoB;iCAChB;AAGrB,MAAMA,0BAA0B,CAACC,OAAOC;IAC/CC,IAAAA,2BAAW,EAACF;IACZ,OAAO,WAAW,GAAGG,IAAAA,eAAI,EAACH,MAAMI,IAAI,EAAE;QAClCC,UAAU,WAAW,GAAGF,IAAAA,eAAI,EAACG,0CAA+B,EAAE;YAC1DC,OAAON,cAAcO,gBAAgB;YACrCH,UAAU,WAAW,GAAGI,IAAAA,gBAAK,EAACC,gCAAe,CAACC,QAAQ,EAAE;gBACpDJ,OAAON,cAAcW,QAAQ;gBAC7BP,UAAU;oBACN,WAAW,GAAGI,IAAAA,gBAAK,EAACT,MAAMa,MAAM,EAAE;wBAC9BR,UAAU;4BACNL,MAAMa,MAAM,CAACR,QAAQ;4BACrBL,MAAMc,UAAU,IAAI,WAAW,GAAGX,IAAAA,eAAI,EAACH,MAAMc,UAAU,EAAE,CAAC;yBAC7D;oBACL;oBACAd,MAAMe,WAAW,IAAI,WAAW,GAAGZ,IAAAA,eAAI,EAACH,MAAMe,WAAW,EAAE,CAAC;oBAC5Df,MAAMgB,OAAO,IAAKhB,CAAAA,MAAMiB,WAAW,GAAG,WAAW,GAAGd,IAAAA,eAAI,EAACH,MAAMgB,OAAO,EAAE,CAAC,KAAK,WAAW,GAAGb,IAAAA,eAAI,EAACe,mBAAM,EAAE;wBACrGC,WAAWnB,MAAMmB,SAAS;wBAC1Bd,UAAU,WAAW,GAAGF,IAAAA,eAAI,EAACH,MAAMgB,OAAO,EAAE,CAAC;oBACjD,EAAC;iBACJ;YACL;QACJ;IACJ;AACJ"}
@@ -14,40 +14,51 @@ const _reactutilities = require("@fluentui/react-utilities");
14
14
  const _useTriggerSlot = require("../../utils/useTriggerSlot");
15
15
  const _dropdownKeyActions = require("../../utils/dropdownKeyActions");
16
16
  function useButtonTriggerSlot(triggerFromProps, ref, options) {
17
- const { state: { open, activeOption, setOpen, getOptionsMatchingText, getIndexOfId, setActiveOption, setFocusVisible }, defaultProps } = options;
17
+ const { state: { open, setOpen, getOptionById }, defaultProps, activeDescendantController } = options;
18
18
  // jump to matching option based on typing
19
19
  const searchString = _react.useRef('');
20
20
  const [setKeyTimeout, clearKeyTimeout] = (0, _reactutilities.useTimeout)();
21
- const getNextMatchingOption = ()=>{
22
- // first check for matches for the full searchString
23
- let matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString.current) === 0;
24
- let matches = getOptionsMatchingText(matcher);
25
- let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
26
- // if the dropdown is already open and the searchstring is a single character,
27
- // then look after the current activeOption for letters
28
- // this is so slowly typing the same letter will cycle through matches
29
- if (open && searchString.current.length === 1) {
30
- startIndex++;
21
+ const moveToNextMatchingOption = (matcher, opt = {
22
+ startFromNext: false
23
+ })=>{
24
+ const { startFromNext } = opt;
25
+ const activeOptionId = activeDescendantController.active();
26
+ const nextInOrder = activeDescendantController.find((id)=>{
27
+ const option = getOptionById(id);
28
+ return !!option && matcher(option.text);
29
+ }, {
30
+ startFrom: startFromNext ? activeDescendantController.next({
31
+ passive: true
32
+ }) : activeOptionId
33
+ });
34
+ if (nextInOrder) {
35
+ return nextInOrder;
36
+ }
37
+ // Cycle back to first match
38
+ return activeDescendantController.find((id)=>{
39
+ const option = getOptionById(id);
40
+ return !!option && matcher(option.text);
41
+ });
42
+ };
43
+ const moveToNextMatchingOptionWithSameCharacterHandling = ()=>{
44
+ if (moveToNextMatchingOption((optionText)=>{
45
+ return optionText.toLocaleLowerCase().indexOf(searchString.current) === 0;
46
+ }, {
47
+ // Slowly pressing the same key will cycle through options
48
+ startFromNext: searchString.current.length === 1
49
+ })) {
50
+ return;
31
51
  }
32
52
  // if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
33
- if (!matches.length) {
34
- const letters = searchString.current.split('');
35
- const allSameLetter = letters.length && letters.every((letter)=>letter === letters[0]);
53
+ if (allCharactersSame(searchString.current) && moveToNextMatchingOption((optionText)=>{
54
+ return optionText.toLocaleLowerCase().indexOf(searchString.current[0]) === 0;
55
+ }, {
36
56
  // if the search is all the same letter, cycle through options starting with that letter
37
- if (allSameLetter) {
38
- startIndex++;
39
- matcher = (optionText)=>optionText.toLowerCase().indexOf(letters[0]) === 0;
40
- matches = getOptionsMatchingText(matcher);
41
- }
42
- }
43
- // if there is an active option and multiple matches,
44
- // return first matching option after the current active option, looping back to the top
45
- if (matches.length > 1 && activeOption) {
46
- const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);
47
- return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
57
+ startFromNext: true
58
+ })) {
59
+ return;
48
60
  }
49
- var _matches_;
50
- return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;
61
+ activeDescendantController.blur();
51
62
  };
52
63
  const onTriggerKeyDown = (ev)=>{
53
64
  // clear timeout, if it exists
@@ -61,16 +72,25 @@ function useButtonTriggerSlot(triggerFromProps, ref, options) {
61
72
  }, 500);
62
73
  // update state
63
74
  !open && setOpen(ev, true);
64
- const nextOption = getNextMatchingOption();
65
- setActiveOption(nextOption);
66
- setFocusVisible(true);
75
+ moveToNextMatchingOptionWithSameCharacterHandling();
67
76
  }
68
77
  };
69
78
  const trigger = (0, _useTriggerSlot.useTriggerSlot)(triggerFromProps, ref, {
70
79
  state: options.state,
71
80
  defaultProps,
72
- elementType: 'button'
81
+ elementType: 'button',
82
+ activeDescendantController
73
83
  });
74
84
  trigger.onKeyDown = (0, _reactutilities.mergeCallbacks)(onTriggerKeyDown, trigger.onKeyDown);
75
85
  return trigger;
76
86
  }
87
+ /**
88
+ * @returns - whether every character in the string is the same
89
+ */ function allCharactersSame(str) {
90
+ for(let i = 1; i < str.length; i++){
91
+ if (str[i] !== str[i - 1]) {
92
+ return false;
93
+ }
94
+ }
95
+ return true;
96
+ }
@@ -1 +1 @@
1
- {"version":3,"sources":["useButtonTriggerSlot.js"],"sourcesContent":["import * as React from 'react';\nimport { useTimeout, mergeCallbacks } from '@fluentui/react-utilities';\nimport { useTriggerSlot } from '../../utils/useTriggerSlot';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\n/*\n * useButtonTriggerSlot 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 useButtonTriggerSlot(triggerFromProps, ref, options) {\n const { state: { open, activeOption, setOpen, getOptionsMatchingText, getIndexOfId, setActiveOption, setFocusVisible }, defaultProps } = options;\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 const trigger = useTriggerSlot(triggerFromProps, ref, {\n state: options.state,\n defaultProps,\n elementType: 'button'\n });\n trigger.onKeyDown = mergeCallbacks(onTriggerKeyDown, trigger.onKeyDown);\n return trigger;\n}\n"],"names":["useButtonTriggerSlot","triggerFromProps","ref","options","state","open","activeOption","setOpen","getOptionsMatchingText","getIndexOfId","setActiveOption","setFocusVisible","defaultProps","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","trigger","useTriggerSlot","elementType","onKeyDown","mergeCallbacks"],"mappings":";;;;+BAQoBA;;;eAAAA;;;;iEARG;gCACoB;gCACZ;oCACU;AAK9B,SAASA,qBAAqBC,gBAAgB,EAAEC,GAAG,EAAEC,OAAO;IACnE,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,YAAY,EAAEC,OAAO,EAAEC,sBAAsB,EAAEC,YAAY,EAAEC,eAAe,EAAEC,eAAe,EAAE,EAAEC,YAAY,EAAE,GAAGT;IACzI,0CAA0C;IAC1C,MAAMU,eAAeC,OAAMC,MAAM,CAAC;IAClC,MAAM,CAACC,eAAeC,gBAAgB,GAAGC,IAAAA,0BAAU;IACnD,MAAMC,wBAAwB;QAC1B,oDAAoD;QACpD,IAAIC,UAAU,CAACC,aAAaA,WAAWC,WAAW,GAAGC,OAAO,CAACV,aAAaW,OAAO,MAAM;QACvF,IAAIC,UAAUjB,uBAAuBY;QACrC,IAAIM,aAAapB,eAAeG,aAAaH,aAAaqB,EAAE,IAAI;QAChE,8EAA8E;QAC9E,uDAAuD;QACvD,sEAAsE;QACtE,IAAItB,QAAQQ,aAAaW,OAAO,CAACI,MAAM,KAAK,GAAG;YAC3CF;QACJ;QACA,yFAAyF;QACzF,IAAI,CAACD,QAAQG,MAAM,EAAE;YACjB,MAAMC,UAAUhB,aAAaW,OAAO,CAACM,KAAK,CAAC;YA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\nimport { useTimeout, mergeCallbacks } from '@fluentui/react-utilities';\nimport { useTriggerSlot } from '../../utils/useTriggerSlot';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\n/*\n * useButtonTriggerSlot 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 useButtonTriggerSlot(triggerFromProps, ref, options) {\n const { state: { open, setOpen, getOptionById }, defaultProps, activeDescendantController } = options;\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n const moveToNextMatchingOption = (matcher, opt = {\n startFromNext: false\n })=>{\n const { startFromNext } = opt;\n const activeOptionId = activeDescendantController.active();\n const nextInOrder = activeDescendantController.find((id)=>{\n const option = getOptionById(id);\n return !!option && matcher(option.text);\n }, {\n startFrom: startFromNext ? activeDescendantController.next({\n passive: true\n }) : activeOptionId\n });\n if (nextInOrder) {\n return nextInOrder;\n }\n // Cycle back to first match\n return activeDescendantController.find((id)=>{\n const option = getOptionById(id);\n return !!option && matcher(option.text);\n });\n };\n const moveToNextMatchingOptionWithSameCharacterHandling = ()=>{\n if (moveToNextMatchingOption((optionText)=>{\n return optionText.toLocaleLowerCase().indexOf(searchString.current) === 0;\n }, {\n // Slowly pressing the same key will cycle through options\n startFromNext: searchString.current.length === 1\n })) {\n return;\n }\n // if there are no direct matches, check if the search is all the same letter, e.g. \"aaa\"\n if (allCharactersSame(searchString.current) && moveToNextMatchingOption((optionText)=>{\n return optionText.toLocaleLowerCase().indexOf(searchString.current[0]) === 0;\n }, {\n // if the search is all the same letter, cycle through options starting with that letter\n startFromNext: true\n })) {\n return;\n }\n activeDescendantController.blur();\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 moveToNextMatchingOptionWithSameCharacterHandling();\n }\n };\n const trigger = useTriggerSlot(triggerFromProps, ref, {\n state: options.state,\n defaultProps,\n elementType: 'button',\n activeDescendantController\n });\n trigger.onKeyDown = mergeCallbacks(onTriggerKeyDown, trigger.onKeyDown);\n return trigger;\n}\n/**\n * @returns - whether every character in the string is the same\n */ function allCharactersSame(str) {\n for(let i = 1; i < str.length; i++){\n if (str[i] !== str[i - 1]) {\n return false;\n }\n }\n return true;\n}\n"],"names":["useButtonTriggerSlot","triggerFromProps","ref","options","state","open","setOpen","getOptionById","defaultProps","activeDescendantController","searchString","React","useRef","setKeyTimeout","clearKeyTimeout","useTimeout","moveToNextMatchingOption","matcher","opt","startFromNext","activeOptionId","active","nextInOrder","find","id","option","text","startFrom","next","passive","moveToNextMatchingOptionWithSameCharacterHandling","optionText","toLocaleLowerCase","indexOf","current","length","allCharactersSame","blur","onTriggerKeyDown","ev","getDropdownActionFromKey","key","toLowerCase","trigger","useTriggerSlot","elementType","onKeyDown","mergeCallbacks","str","i"],"mappings":";;;;+BAQoBA;;;eAAAA;;;;iEARG;gCACoB;gCACZ;oCACU;AAK9B,SAASA,qBAAqBC,gBAAgB,EAAEC,GAAG,EAAEC,OAAO;IACnE,MAAM,EAAEC,OAAO,EAAEC,IAAI,EAAEC,OAAO,EAAEC,aAAa,EAAE,EAAEC,YAAY,EAAEC,0BAA0B,EAAE,GAAGN;IAC9F,0CAA0C;IAC1C,MAAMO,eAAeC,OAAMC,MAAM,CAAC;IAClC,MAAM,CAACC,eAAeC,gBAAgB,GAAGC,IAAAA,0BAAU;IACnD,MAAMC,2BAA2B,CAACC,SAASC,MAAM;QAC7CC,eAAe;IACnB,CAAC;QACG,MAAM,EAAEA,aAAa,EAAE,GAAGD;QAC1B,MAAME,iBAAiBX,2BAA2BY,MAAM;QACxD,MAAMC,cAAcb,2BAA2Bc,IAAI,CAAC,CAACC;YACjD,MAAM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kC,QAAQG,SAAS,GAAGC,IAAAA,8BAAc,EAACT,kBAAkBK,QAAQG,SAAS;IACtE,OAAOH;AACX;AACA;;CAEC,GAAG,SAASP,kBAAkBY,GAAG;IAC9B,IAAI,IAAIC,IAAI,GAAGA,IAAID,IAAIb,MAAM,EAAEc,IAAI;QAC/B,IAAID,GAAG,CAACC,EAAE,KAAKD,GAAG,CAACC,IAAI,EAAE,EAAE;YACvB,OAAO;QACX;IACJ;IACA,OAAO;AACX"}
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "useDropdown_unstable", {
11
11
  const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
12
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
13
  const _reactfield = require("@fluentui/react-field");
14
+ const _reactaria = require("@fluentui/react-aria");
14
15
  const _reacticons = require("@fluentui/react-icons");
15
16
  const _reactutilities = require("@fluentui/react-utilities");
16
17
  const _useComboboxBaseState = require("../../utils/useComboboxBaseState");
@@ -18,6 +19,7 @@ const _useComboboxPositioning = require("../../utils/useComboboxPositioning");
18
19
  const _Listbox = require("../Listbox/Listbox");
19
20
  const _useListboxSlot = require("../../utils/useListboxSlot");
20
21
  const _useButtonTriggerSlot = require("./useButtonTriggerSlot");
22
+ const _useOptionStylesstyles = require("../Option/useOptionStyles.styles");
21
23
  const useDropdown_unstable = (props, ref)=>{
22
24
  var _state_clearButton;
23
25
  // Merge props from surrounding <Field>, if any
@@ -25,7 +27,13 @@ const useDropdown_unstable = (props, ref)=>{
25
27
  supportsLabelFor: true,
26
28
  supportsSize: true
27
29
  });
28
- const baseState = (0, _useComboboxBaseState.useComboboxBaseState)(props);
30
+ const { listboxRef: activeDescendantListboxRef, activeParentRef, controller: activeDescendantController } = (0, _reactaria.useActiveDescendant)({
31
+ matchOption: (el)=>el.classList.contains(_useOptionStylesstyles.optionClassNames.root)
32
+ });
33
+ const baseState = (0, _useComboboxBaseState.useComboboxBaseState)({
34
+ ...props,
35
+ activeDescendantController
36
+ });
29
37
  const { clearable, clearSelection, hasFocus, multiselect, open, selectedOptions } = baseState;
30
38
  const { primary: triggerNativeProps, root: rootNativeProps } = (0, _reactutilities.getPartitionedNativeProps)({
31
39
  props,
@@ -36,7 +44,7 @@ const useDropdown_unstable = (props, ref)=>{
36
44
  });
37
45
  const [comboboxPopupRef, comboboxTargetRef] = (0, _useComboboxPositioning.useComboboxPositioning)(props);
38
46
  const triggerRef = _react.useRef(null);
39
- const listbox = (0, _useListboxSlot.useListboxSlot)(props.listbox, comboboxPopupRef, {
47
+ const listbox = (0, _useListboxSlot.useListboxSlot)(props.listbox, (0, _reactutilities.useMergedRefs)(comboboxPopupRef, activeDescendantListboxRef), {
40
48
  state: baseState,
41
49
  triggerRef,
42
50
  defaultProps: {
@@ -44,7 +52,7 @@ const useDropdown_unstable = (props, ref)=>{
44
52
  }
45
53
  });
46
54
  var _props_button;
47
- const trigger = (0, _useButtonTriggerSlot.useButtonTriggerSlot)((_props_button = props.button) !== null && _props_button !== void 0 ? _props_button : {}, (0, _reactutilities.useMergedRefs)(triggerRef, ref), {
55
+ const trigger = (0, _useButtonTriggerSlot.useButtonTriggerSlot)((_props_button = props.button) !== null && _props_button !== void 0 ? _props_button : {}, (0, _reactutilities.useMergedRefs)(triggerRef, activeParentRef, ref), {
48
56
  state: baseState,
49
57
  defaultProps: {
50
58
  type: 'button',
@@ -52,7 +60,8 @@ const useDropdown_unstable = (props, ref)=>{
52
60
  children: baseState.value || props.placeholder,
53
61
  'aria-controls': open ? listbox === null || listbox === void 0 ? void 0 : listbox.id : undefined,
54
62
  ...triggerNativeProps
55
- }
63
+ },
64
+ activeDescendantController
56
65
  });
57
66
  const rootSlot = _reactutilities.slot.always(props.root, {
58
67
  defaultProps: {
@@ -95,6 +104,7 @@ const useDropdown_unstable = (props, ref)=>{
95
104
  }),
96
105
  placeholderVisible: !baseState.value && !!props.placeholder,
97
106
  showClearButton,
107
+ activeDescendantController,
98
108
  ...baseState
99
109
  };
100
110
  const onClearButtonClick = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((_state_clearButton = state.clearButton) === null || _state_clearButton === void 0 ? void 0 : _state_clearButton.onClick, (ev)=>{
@@ -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, DismissRegular as DismissIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, useMergedRefs, slot, useEventCallback } from '@fluentui/react-utilities';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { Listbox } from '../Listbox/Listbox';\nimport { useListboxSlot } from '../../utils/useListboxSlot';\nimport { useButtonTriggerSlot } from './useButtonTriggerSlot';\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 var _state_clearButton;\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 { clearable, clearSelection, hasFocus, multiselect, open, selectedOptions } = 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 const triggerRef = React.useRef(null);\n const listbox = useListboxSlot(props.listbox, comboboxPopupRef, {\n state: baseState,\n triggerRef,\n defaultProps: {\n children: props.children\n }\n });\n var _props_button;\n const trigger = useButtonTriggerSlot((_props_button = props.button) !== null && _props_button !== void 0 ? _props_button : {}, useMergedRefs(triggerRef, ref), {\n state: baseState,\n defaultProps: {\n type: 'button',\n tabIndex: 0,\n children: baseState.value || props.placeholder,\n 'aria-controls': open ? listbox === null || listbox === void 0 ? void 0 : listbox.id : undefined,\n ...triggerNativeProps\n }\n });\n const rootSlot = slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !props.inlinePopup && open ? listbox === null || listbox === void 0 ? void 0 : listbox.id : undefined,\n children: props.children,\n ...rootNativeProps\n },\n elementType: 'div'\n });\n rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);\n const showClearButton = selectedOptions.length > 0 && clearable && !multiselect;\n const state = {\n components: {\n root: 'div',\n button: 'button',\n clearButton: 'button',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: rootSlot,\n button: trigger,\n listbox: open || hasFocus ? listbox : undefined,\n clearButton: slot.optional(props.clearButton, {\n defaultProps: {\n 'aria-label': 'Clear selection',\n children: /*#__PURE__*/ React.createElement(DismissIcon, null),\n // Safari doesn't allow to focus an element with this\n tabIndex: 0,\n type: 'button'\n },\n elementType: 'button',\n renderByDefault: true\n }),\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 showClearButton,\n ...baseState\n };\n const onClearButtonClick = useEventCallback(mergeCallbacks((_state_clearButton = state.clearButton) === null || _state_clearButton === void 0 ? void 0 : _state_clearButton.onClick, (ev)=>{\n var _triggerRef_current;\n clearSelection(ev);\n (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();\n }));\n if (state.clearButton) {\n state.clearButton.onClick = onClearButtonClick;\n }\n // Heads up! We don't support \"clearable\" in multiselect mode, so we should never display a slot\n if (multiselect) {\n state.clearButton = undefined;\n }\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- \"process.env\" does not change in runtime\n React.useEffect(()=>{\n if (clearable && multiselect) {\n // eslint-disable-next-line no-console\n console.error(`[@fluentui/react-combobox] \"clearable\" prop is not supported in multiselect mode.`);\n }\n }, [\n clearable,\n multiselect\n ]);\n }\n return state;\n};\n"],"names":["useDropdown_unstable","props","ref","_state_clearButton","useFieldControlProps_unstable","supportsLabelFor","supportsSize","baseState","useComboboxBaseState","clearable","clearSelection","hasFocus","multiselect","open","selectedOptions","primary","triggerNativeProps","root","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","comboboxPopupRef","comboboxTargetRef","useComboboxPositioning","triggerRef","React","useRef","listbox","useListboxSlot","state","defaultProps","children","_props_button","trigger","useButtonTriggerSlot","button","useMergedRefs","type","tabIndex","value","placeholder","id","undefined","rootSlot","slot","always","inlinePopup","elementType","showClearButton","length","components","clearButton","expandIcon","Listbox","optional","createElement","DismissIcon","renderByDefault","ChevronDownIcon","placeholderVisible","onClearButtonClick","useEventCallback","mergeCallbacks","onClick","ev","_triggerRef_current","current","focus","process","env","NODE_ENV","useEffect","console","error"],"mappings":";;;;+BAiBiBA;;;eAAAA;;;;iEAjBM;4BACuB;4BACuC;gCACY;sCAC5D;wCACE;yBACf;gCACO;sCACM;AAS1B,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,IAAIC;IACJ,+CAA+C;IAC/CF,QAAQG,IAAAA,yCAA6B,EAACH,OAAO;QACzCI,kBAAkB;QAClBC,cAAc;IAClB;IACA,MAAMC,YAAYC,IAAAA,0CAAoB,EAACP;IACvC,MAAM,EAAEQ,SAAS,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,IAAI,EAAEC,eAAe,EAAE,GAAGP;IACpF,MAAM,EAAEQ,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,MAAMwB,aAA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js"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { ChevronDownRegular as ChevronDownIcon, DismissRegular as DismissIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, useMergedRefs, slot, useEventCallback } from '@fluentui/react-utilities';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { Listbox } from '../Listbox/Listbox';\nimport { useListboxSlot } from '../../utils/useListboxSlot';\nimport { useButtonTriggerSlot } from './useButtonTriggerSlot';\nimport { optionClassNames } from '../Option/useOptionStyles.styles';\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 var _state_clearButton;\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, {\n supportsLabelFor: true,\n supportsSize: true\n });\n const { listboxRef: activeDescendantListboxRef, activeParentRef, controller: activeDescendantController } = useActiveDescendant({\n matchOption: (el)=>el.classList.contains(optionClassNames.root)\n });\n const baseState = useComboboxBaseState({\n ...props,\n activeDescendantController\n });\n const { clearable, clearSelection, hasFocus, multiselect, open, selectedOptions } = 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 const triggerRef = React.useRef(null);\n const listbox = useListboxSlot(props.listbox, useMergedRefs(comboboxPopupRef, activeDescendantListboxRef), {\n state: baseState,\n triggerRef,\n defaultProps: {\n children: props.children\n }\n });\n var _props_button;\n const trigger = useButtonTriggerSlot((_props_button = props.button) !== null && _props_button !== void 0 ? _props_button : {}, useMergedRefs(triggerRef, activeParentRef, ref), {\n state: baseState,\n defaultProps: {\n type: 'button',\n tabIndex: 0,\n children: baseState.value || props.placeholder,\n 'aria-controls': open ? listbox === null || listbox === void 0 ? void 0 : listbox.id : undefined,\n ...triggerNativeProps\n },\n activeDescendantController\n });\n const rootSlot = slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !props.inlinePopup && open ? listbox === null || listbox === void 0 ? void 0 : listbox.id : undefined,\n children: props.children,\n ...rootNativeProps\n },\n elementType: 'div'\n });\n rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);\n const showClearButton = selectedOptions.length > 0 && clearable && !multiselect;\n const state = {\n components: {\n root: 'div',\n button: 'button',\n clearButton: 'button',\n expandIcon: 'span',\n listbox: Listbox\n },\n root: rootSlot,\n button: trigger,\n listbox: open || hasFocus ? listbox : undefined,\n clearButton: slot.optional(props.clearButton, {\n defaultProps: {\n 'aria-label': 'Clear selection',\n children: /*#__PURE__*/ React.createElement(DismissIcon, null),\n // Safari doesn't allow to focus an element with this\n tabIndex: 0,\n type: 'button'\n },\n elementType: 'button',\n renderByDefault: true\n }),\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 showClearButton,\n activeDescendantController,\n ...baseState\n };\n const onClearButtonClick = useEventCallback(mergeCallbacks((_state_clearButton = state.clearButton) === null || _state_clearButton === void 0 ? void 0 : _state_clearButton.onClick, (ev)=>{\n var _triggerRef_current;\n clearSelection(ev);\n (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();\n }));\n if (state.clearButton) {\n state.clearButton.onClick = onClearButtonClick;\n }\n // Heads up! We don't support \"clearable\" in multiselect mode, so we should never display a slot\n if (multiselect) {\n state.clearButton = undefined;\n }\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- \"process.env\" does not change in runtime\n React.useEffect(()=>{\n if (clearable && multiselect) {\n // eslint-disable-next-line no-console\n console.error(`[@fluentui/react-combobox] \"clearable\" prop is not supported in multiselect mode.`);\n }\n }, [\n clearable,\n multiselect\n ]);\n }\n return state;\n};\n"],"names":["useDropdown_unstable","props","ref","_state_clearButton","useFieldControlProps_unstable","supportsLabelFor","supportsSize","listboxRef","activeDescendantListboxRef","activeParentRef","controller","activeDescendantController","useActiveDescendant","matchOption","el","classList","contains","optionClassNames","root","baseState","useComboboxBaseState","clearable","clearSelection","hasFocus","multiselect","open","selectedOptions","primary","triggerNativeProps","rootNativeProps","getPartitionedNativeProps","primarySlotTagName","excludedPropNames","comboboxPopupRef","comboboxTargetRef","useComboboxPositioning","triggerRef","React","useRef","listbox","useListboxSlot","useMergedRefs","state","defaultProps","children","_props_button","trigger","useButtonTriggerSlot","button","type","tabIndex","value","placeholder","id","undefined","rootSlot","slot","always","inlinePopup","elementType","showClearButton","length","components","clearButton","expandIcon","Listbox","optional","createElement","DismissIcon","renderByDefault","ChevronDownIcon","placeholderVisible","onClearButtonClick","useEventCallback","mergeCallbacks","onClick","ev","_triggerRef_current","current","focus","process","env","NODE_ENV","useEffect","console","error"],"mappings":";;;;+BAmBiBA;;;eAAAA;;;;iEAnBM;4BACuB;2BACV;4BACiD;gCACY;sCAC5D;wCACE;yBACf;gCACO;sCACM;uCACJ;AAStB,MAAMA,uBAAuB,CAACC,OAAOC;IAC5C,IAAIC;IACJ,+CAA+C;IAC/CF,QAAQG,IAAAA,yCAA6B,EAACH,OAAO;QACzCI,kBAAkB;QAClBC,cAAc;IAClB;IACA,MAAM,EAAEC,YAAYC,0BAA0B,EAAEC,eAAe,EAAEC,YAAYC,0BAA0B,EAAE,GAAGC,IAAAA,8BAAmB,EAAC;QAC5HC,aAAa,CAACC,KAAKA,GAAGC,SAAS,CAACC,QAAQ,CAACC,uCAAgB,CAACC,IAAI;IAClE;IACA,MAAMC,YA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E,KAAK;IAC9H;IACA,IAAIrC,MAAMqB,WAAW,EAAE;QACnBrB,MAAMqB,WAAW,CAACY,OAAO,GAAGH;IAChC;IACA,gGAAgG;IAChG,IAAIhD,aAAa;QACbkB,MAAMqB,WAAW,GAAGT;IACxB;IACA,IAAI0B,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,kGAAkG;QAClG7C,OAAM8C,SAAS,CAAC;YACZ,IAAI9D,aAAaG,aAAa;gBAC1B,sCAAsC;gBACtC4D,QAAQC,KAAK,CAAC,CAAC,iFAAiF,CAAC;YACrG;QACJ,GAAG;YACChE;YACAG;SACH;IACL;IACA,OAAOkB;AACX"}
@@ -10,11 +10,15 @@ Object.defineProperty(exports, "renderListbox_unstable", {
10
10
  });
11
11
  const _jsxruntime = require("@fluentui/react-jsx-runtime/jsx-runtime");
12
12
  const _reactutilities = require("@fluentui/react-utilities");
13
+ const _reactaria = require("@fluentui/react-aria");
13
14
  const _ListboxContext = require("../../contexts/ListboxContext");
14
15
  const renderListbox_unstable = (state, contextValues)=>{
15
16
  (0, _reactutilities.assertSlots)(state);
16
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_ListboxContext.ListboxContext.Provider, {
17
- value: contextValues.listbox,
18
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {})
17
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactaria.ActiveDescendantContextProvider, {
18
+ value: contextValues.activeDescendant,
19
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_ListboxContext.ListboxContext.Provider, {
20
+ value: contextValues.listbox,
21
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(state.root, {})
22
+ })
19
23
  });
20
24
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["renderListbox.js"],"sourcesContent":[" import { jsx as _jsx } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { ListboxContext } from '../../contexts/ListboxContext';\n/**\n * Render the final JSX of Listbox\n */ export const renderListbox_unstable = (state, contextValues)=>{\n assertSlots(state);\n return /*#__PURE__*/ _jsx(ListboxContext.Provider, {\n value: contextValues.listbox,\n children: /*#__PURE__*/ _jsx(state.root, {})\n });\n};\n"],"names":["renderListbox_unstable","state","contextValues","assertSlots","_jsx","ListboxContext","Provider","value","listbox","children","root"],"mappings":";;;;+BAKiBA;;;eAAAA;;;4BALa;gCACF;gCACG;AAGpB,MAAMA,yBAAyB,CAACC,OAAOC;IAC9CC,IAAAA,2BAAW,EAACF;IACZ,OAAO,WAAW,GAAGG,IAAAA,eAAI,EAACC,8BAAc,CAACC,QAAQ,EAAE;QAC/CC,OAAOL,cAAcM,OAAO;QAC5BC,UAAU,WAAW,GAAGL,IAAAA,eAAI,EAACH,MAAMS,IAAI,EAAE,CAAC;IAC9C;AACJ"}
1
+ {"version":3,"sources":["renderListbox.js"],"sourcesContent":[" import { jsx as _jsx } from \"@fluentui/react-jsx-runtime/jsx-runtime\";\nimport { assertSlots } from '@fluentui/react-utilities';\nimport { ActiveDescendantContextProvider } from '@fluentui/react-aria';\nimport { ListboxContext } from '../../contexts/ListboxContext';\n/**\n * Render the final JSX of Listbox\n */ export const renderListbox_unstable = (state, contextValues)=>{\n assertSlots(state);\n return /*#__PURE__*/ _jsx(ActiveDescendantContextProvider, {\n value: contextValues.activeDescendant,\n children: /*#__PURE__*/ _jsx(ListboxContext.Provider, {\n value: contextValues.listbox,\n children: /*#__PURE__*/ _jsx(state.root, {})\n })\n });\n};\n"],"names":["renderListbox_unstable","state","contextValues","assertSlots","_jsx","ActiveDescendantContextProvider","value","activeDescendant","children","ListboxContext","Provider","listbox","root"],"mappings":";;;;+BAMiBA;;;eAAAA;;;4BANa;gCACF;2BACoB;gCACjB;AAGpB,MAAMA,yBAAyB,CAACC,OAAOC;IAC9CC,IAAAA,2BAAW,EAACF;IACZ,OAAO,WAAW,GAAGG,IAAAA,eAAI,EAACC,0CAA+B,EAAE;QACvDC,OAAOJ,cAAcK,gBAAgB;QACrCC,UAAU,WAAW,GAAGJ,IAAAA,eAAI,EAACK,8BAAc,CAACC,QAAQ,EAAE;YAClDJ,OAAOJ,cAAcS,OAAO;YAC5BH,UAAU,WAAW,GAAGJ,IAAAA,eAAI,EAACH,MAAMW,IAAI,EAAE,CAAC;QAC9C;IACJ;AACJ"}
@@ -12,65 +12,76 @@ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildc
12
12
  const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
13
  const _reactutilities = require("@fluentui/react-utilities");
14
14
  const _reactcontextselector = require("@fluentui/react-context-selector");
15
+ const _reactaria = require("@fluentui/react-aria");
15
16
  const _dropdownKeyActions = require("../../utils/dropdownKeyActions");
16
17
  const _useOptionCollection = require("../../utils/useOptionCollection");
17
- const _useScrollOptionsIntoView = require("../../utils/useScrollOptionsIntoView");
18
18
  const _useSelection = require("../../utils/useSelection");
19
19
  const _ComboboxContext = require("../../contexts/ComboboxContext");
20
+ const _useOptionStylesstyles = require("../Option/useOptionStyles.styles");
21
+ // eslint-disable-next-line @typescript-eslint/naming-convention
22
+ const UNSAFE_noLongerUsed = {
23
+ activeOption: undefined,
24
+ focusVisible: false,
25
+ setActiveOption: ()=>null
26
+ };
20
27
  const useListbox_unstable = (props, ref)=>{
21
28
  const { multiselect } = props;
22
29
  const optionCollection = (0, _useOptionCollection.useOptionCollection)();
23
- const { getCount, getOptionAtIndex, getIndexOfId } = optionCollection;
30
+ const { getOptionById } = optionCollection;
31
+ const { listboxRef: activeDescendantListboxRef, activeParentRef, controller } = (0, _reactaria.useActiveDescendant)({
32
+ matchOption: (el)=>el.classList.contains(_useOptionStylesstyles.optionClassNames.root)
33
+ });
34
+ const activeDescendantContext = (0, _reactaria.useActiveDescendantContext)();
35
+ const activeDescendantController = (0, _reactaria.useHasParentActiveDescendantContext)() ? activeDescendantContext.controller : controller;
24
36
  const { clearSelection, selectedOptions, selectOption } = (0, _useSelection.useSelection)(props);
25
- const [activeOption, setActiveOption] = _react.useState();
26
- // track whether keyboard focus outline should be shown
27
- // tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move
28
- const [focusVisible, setFocusVisible] = _react.useState(false);
29
37
  const onKeyDown = (event)=>{
30
38
  const action = (0, _dropdownKeyActions.getDropdownActionFromKey)(event, {
31
39
  open: true
32
40
  });
33
- const maxIndex = getCount() - 1;
34
- const activeIndex = activeOption ? getIndexOfId(activeOption.id) : -1;
35
- let newIndex = activeIndex;
41
+ const activeOptionId = activeDescendantController.active();
42
+ const activeOption = activeOptionId ? getOptionById(activeOptionId) : null;
36
43
  switch(action){
44
+ case 'Next':
45
+ if (activeOption) {
46
+ activeDescendantController.next();
47
+ } else {
48
+ activeDescendantController.first();
49
+ }
50
+ break;
51
+ case 'Previous':
52
+ if (activeOption) {
53
+ activeDescendantController.prev();
54
+ } else {
55
+ activeDescendantController.first();
56
+ }
57
+ break;
58
+ case 'PageUp':
59
+ case 'First':
60
+ activeDescendantController.first();
61
+ break;
62
+ case 'PageDown':
63
+ case 'Last':
64
+ activeDescendantController.last();
65
+ break;
37
66
  case 'Select':
38
67
  case 'CloseSelect':
39
68
  activeOption && selectOption(event, activeOption);
40
69
  break;
41
- default:
42
- newIndex = (0, _dropdownKeyActions.getIndexFromAction)(action, activeIndex, maxIndex);
43
- }
44
- if (newIndex !== activeIndex) {
45
- // prevent default page scroll/keyboard action if the index changed
46
- event.preventDefault();
47
- setActiveOption(getOptionAtIndex(newIndex));
48
- setFocusVisible(true);
49
70
  }
50
71
  };
51
- const onMouseOver = (event)=>{
52
- setFocusVisible(false);
53
- };
54
72
  // get state from parent combobox, if it exists
55
73
  const hasComboboxContext = (0, _reactcontextselector.useHasParentContext)(_ComboboxContext.ComboboxContext);
56
- const comboboxActiveOption = (0, _reactcontextselector.useContextSelector)(_ComboboxContext.ComboboxContext, (ctx)=>ctx.activeOption);
57
- const comboboxFocusVisible = (0, _reactcontextselector.useContextSelector)(_ComboboxContext.ComboboxContext, (ctx)=>ctx.focusVisible);
58
74
  const comboboxSelectedOptions = (0, _reactcontextselector.useContextSelector)(_ComboboxContext.ComboboxContext, (ctx)=>ctx.selectedOptions);
59
75
  const comboboxSelectOption = (0, _reactcontextselector.useContextSelector)(_ComboboxContext.ComboboxContext, (ctx)=>ctx.selectOption);
60
- const comboboxSetActiveOption = (0, _reactcontextselector.useContextSelector)(_ComboboxContext.ComboboxContext, (ctx)=>ctx.setActiveOption);
61
76
  // without a parent combobox context, provide values directly from Listbox
62
77
  const optionContextValues = hasComboboxContext ? {
63
- activeOption: comboboxActiveOption,
64
- focusVisible: comboboxFocusVisible,
65
78
  selectedOptions: comboboxSelectedOptions,
66
79
  selectOption: comboboxSelectOption,
67
- setActiveOption: comboboxSetActiveOption
80
+ ...UNSAFE_noLongerUsed
68
81
  } : {
69
- activeOption,
70
- focusVisible,
71
82
  selectedOptions,
72
83
  selectOption,
73
- setActiveOption
84
+ ...UNSAFE_noLongerUsed
74
85
  };
75
86
  const state = {
76
87
  components: {
@@ -80,9 +91,8 @@ const useListbox_unstable = (props, ref)=>{
80
91
  // FIXME:
81
92
  // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`
82
93
  // but since it would be a breaking change to fix it, we are casting ref to it's proper type
83
- ref: ref,
94
+ ref: (0, _reactutilities.useMergedRefs)(ref, activeParentRef, activeDescendantListboxRef),
84
95
  role: multiselect ? 'menu' : 'listbox',
85
- 'aria-activedescendant': hasComboboxContext ? undefined : activeOption === null || activeOption === void 0 ? void 0 : activeOption.id,
86
96
  tabIndex: 0,
87
97
  ...props
88
98
  }), {
@@ -90,12 +100,10 @@ const useListbox_unstable = (props, ref)=>{
90
100
  }),
91
101
  multiselect,
92
102
  clearSelection,
103
+ activeDescendantController,
93
104
  ...optionCollection,
94
105
  ...optionContextValues
95
106
  };
96
- const scrollContainerRef = (0, _useScrollOptionsIntoView.useScrollOptionsIntoView)(state);
97
- state.root.ref = (0, _reactutilities.useMergedRefs)(state.root.ref, scrollContainerRef);
98
107
  state.root.onKeyDown = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(state.root.onKeyDown, onKeyDown));
99
- state.root.onMouseOver = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(state.root.onMouseOver, onMouseOver));
100
108
  return state;
101
109
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["useListbox.js"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, 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(getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: ref,\n role: multiselect ? 'menu' : 'listbox',\n 'aria-activedescendant': hasComboboxContext ? undefined : activeOption === null || activeOption === void 0 ? void 0 : activeOption.id,\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","getIntrinsicElementProps","role","undefined","tabIndex","elementType","scrollContainerRef","useScrollOptionsIntoView","useMergedRefs","useEventCallback","mergeCallbacks"],"mappings":";;;;+BAgBiBA;;;eAAAA;;;;iEAhBM;gCACyE;sCACxC;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,OAAMC,QAAQ;IACtD,uDAAuD;IACvD,yFAAyF;IACzF,MAAM,CAACC,cAAcC,gBAAgB,GAAGH,OAAMC,QAAQ,CAAC;IACvD,MAAMG,YAAY,CAACC;QACf,MAAMC,SAASC,IAAAA,4CAAwB,EAACF,OAAO;YAC3CG,MAAM;QACV;QACA,MAAMC,WAAWlB,aAAa;QAC9B,MAAMmB,cAAcZ,eAAeL,aAAaK,aAAaa,EAAE,IAAI,CAAC;QACpE,IAAIC,WAAWF;QACf,OAAOJ;YACH,KAAK;YACL,KAAK;gBACDR,gBAAgBF,aAAaS,OAAOP;gBACpC;YACJ;gBACIc,WAAWC,IAAAA,sCAAkB,EAACP,QAAQI,aAAa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ACAM;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"}
1
+ {"version":3,"sources":["useListbox.js"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeCallbacks, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useContextSelector, useHasParentContext } from '@fluentui/react-context-selector';\nimport { useActiveDescendant, useActiveDescendantContext, useHasParentActiveDescendantContext } from '@fluentui/react-aria';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useOptionCollection } from '../../utils/useOptionCollection';\nimport { useSelection } from '../../utils/useSelection';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport { optionClassNames } from '../Option/useOptionStyles.styles';\n// eslint-disable-next-line @typescript-eslint/naming-convention\nconst UNSAFE_noLongerUsed = {\n activeOption: undefined,\n focusVisible: false,\n setActiveOption: ()=>null\n};\n/**\n * Create the state required to render Listbox.\n *\n * The returned state can be modified with hooks such as useListboxStyles_unstable,\n * before being passed to renderListbox_unstable.\n *\n * @param props - props from this instance of Listbox\n * @param ref - reference to root HTMLElement of Listbox\n */ export const useListbox_unstable = (props, ref)=>{\n const { multiselect } = props;\n const optionCollection = useOptionCollection();\n const { getOptionById } = optionCollection;\n const { listboxRef: activeDescendantListboxRef, activeParentRef, controller } = useActiveDescendant({\n matchOption: (el)=>el.classList.contains(optionClassNames.root)\n });\n const activeDescendantContext = useActiveDescendantContext();\n const activeDescendantController = useHasParentActiveDescendantContext() ? activeDescendantContext.controller : controller;\n const { clearSelection, selectedOptions, selectOption } = useSelection(props);\n const onKeyDown = (event)=>{\n const action = getDropdownActionFromKey(event, {\n open: true\n });\n const activeOptionId = activeDescendantController.active();\n const activeOption = activeOptionId ? getOptionById(activeOptionId) : null;\n switch(action){\n case 'Next':\n if (activeOption) {\n activeDescendantController.next();\n } else {\n activeDescendantController.first();\n }\n break;\n case 'Previous':\n if (activeOption) {\n activeDescendantController.prev();\n } else {\n activeDescendantController.first();\n }\n break;\n case 'PageUp':\n case 'First':\n activeDescendantController.first();\n break;\n case 'PageDown':\n case 'Last':\n activeDescendantController.last();\n break;\n case 'Select':\n case 'CloseSelect':\n activeOption && selectOption(event, activeOption);\n break;\n }\n };\n // get state from parent combobox, if it exists\n const hasComboboxContext = useHasParentContext(ComboboxContext);\n const comboboxSelectedOptions = useContextSelector(ComboboxContext, (ctx)=>ctx.selectedOptions);\n const comboboxSelectOption = useContextSelector(ComboboxContext, (ctx)=>ctx.selectOption);\n // without a parent combobox context, provide values directly from Listbox\n const optionContextValues = hasComboboxContext ? {\n selectedOptions: comboboxSelectedOptions,\n selectOption: comboboxSelectOption,\n ...UNSAFE_noLongerUsed\n } : {\n selectedOptions,\n selectOption,\n ...UNSAFE_noLongerUsed\n };\n const state = {\n components: {\n root: 'div'\n },\n root: slot.always(getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, activeParentRef, activeDescendantListboxRef),\n role: multiselect ? 'menu' : 'listbox',\n tabIndex: 0,\n ...props\n }), {\n elementType: 'div'\n }),\n multiselect,\n clearSelection,\n activeDescendantController,\n ...optionCollection,\n ...optionContextValues\n };\n state.root.onKeyDown = useEventCallback(mergeCallbacks(state.root.onKeyDown, onKeyDown));\n return state;\n};\n"],"names":["useListbox_unstable","UNSAFE_noLongerUsed","activeOption","undefined","focusVisible","setActiveOption","props","ref","multiselect","optionCollection","useOptionCollection","getOptionById","listboxRef","activeDescendantListboxRef","activeParentRef","controller","useActiveDescendant","matchOption","el","classList","contains","optionClassNames","root","activeDescendantContext","useActiveDescendantContext","activeDescendantController","useHasParentActiveDescendantContext","clearSelection","selectedOptions","selectOption","useSelection","onKeyDown","event","action","getDropdownActionFromKey","open","activeOptionId","active","next","first","prev","last","hasComboboxContext","useHasParentContext","ComboboxContext","comboboxSelectedOptions","useContextSelector","ctx","comboboxSelectOption","optionContextValues","state","components","slot","always","getIntrinsicElementProps","useMergedRefs","role","tabIndex","elementType","useEventCallback","mergeCallbacks"],"mappings":";;;;+BAuBiBA;;;eAAAA;;;;iEAvBM;gCACyE;sCACxC;2BAC6C;oCAC5D;qCACL;8BACP;iCACG;uCACC;AACjC,gEAAgE;AAChE,MAAMC,sBAAsB;IACxBC,cAAcC;IACdC,cAAc;IACdC,iBAAiB,IAAI;AACzB;AASW,MAAML,sBAAsB,CAACM,OAAOC;IAC3C,MAAM,EAAEC,WAAW,EAAE,GAAGF;IACxB,MAAMG,mBAAmBC,IAAAA,wCAAmB;IAC5C,MAAM,EAAEC,aAAa,EAAE,GAAGF;IAC1B,MAAM,EAAEG,YAAYC,0BAA0B,EAAEC,eAAe,EAAEC,UAAU,EAAE,GAAGC,IAAAA,8BAAmB,EAAC;QAChGC,aAAa,CAACC,KAAKA,GAAGC,SAAS,CAACC,QAAQ,CAACC,uCAAgB,CAACC,IAAI;IAClE;IACA,MAAMC,0BAA0BC,IAAAA,qCAA0B;IAC1D,MAAMC,6BAA6BC,IAAAA,8CAAmC,MAAKH,wBAAwBR,UAAU,GAAGA;IAChH,MAAM,EAAEY,cAAc,EAAEC,eAAe,EAAEC,YAAY,EAAE,GAAGC,IAAAA,0BAAY,EAACxB;IACvE,MAAMyB,YAAY,CAACC;QACf,MAAMC,SAASC,IAA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