@fluentui/react-combobox 9.5.8 → 9.5.10

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 (147) hide show
  1. package/CHANGELOG.json +121 -1
  2. package/CHANGELOG.md +35 -2
  3. package/lib/components/Combobox/Combobox.js.map +1 -1
  4. package/lib/components/Combobox/renderCombobox.js +15 -7
  5. package/lib/components/Combobox/renderCombobox.js.map +1 -1
  6. package/lib/components/Combobox/useCombobox.js +17 -13
  7. package/lib/components/Combobox/useCombobox.js.map +1 -1
  8. package/lib/components/Combobox/useComboboxStyles.styles.js.map +1 -1
  9. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  10. package/lib/components/Dropdown/renderDropdown.js +19 -7
  11. package/lib/components/Dropdown/renderDropdown.js.map +1 -1
  12. package/lib/components/Dropdown/useDropdown.js +4 -3
  13. package/lib/components/Dropdown/useDropdown.js.map +1 -1
  14. package/lib/components/Dropdown/useDropdownStyles.styles.js.map +1 -1
  15. package/lib/components/Listbox/Listbox.js.map +1 -1
  16. package/lib/components/Listbox/renderListbox.js +5 -4
  17. package/lib/components/Listbox/renderListbox.js.map +1 -1
  18. package/lib/components/Listbox/useListbox.js +5 -4
  19. package/lib/components/Listbox/useListbox.js.map +1 -1
  20. package/lib/components/Option/Option.js.map +1 -1
  21. package/lib/components/Option/renderOption.js +7 -2
  22. package/lib/components/Option/renderOption.js.map +1 -1
  23. package/lib/components/Option/useOption.js +5 -4
  24. package/lib/components/Option/useOption.js.map +1 -1
  25. package/lib/components/Option/useOptionStyles.styles.js.map +1 -1
  26. package/lib/components/OptionGroup/OptionGroup.js.map +1 -1
  27. package/lib/components/OptionGroup/renderOptionGroup.js +9 -2
  28. package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
  29. package/lib/components/OptionGroup/useOptionGroup.js +1 -1
  30. package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
  31. package/lib/contexts/ComboboxContext.js.map +1 -1
  32. package/lib/contexts/ListboxContext.js.map +1 -1
  33. package/lib/contexts/useComboboxContextValues.js +1 -1
  34. package/lib/contexts/useComboboxContextValues.js.map +1 -1
  35. package/lib/contexts/useListboxContextValues.js +1 -1
  36. package/lib/contexts/useListboxContextValues.js.map +1 -1
  37. package/lib/utils/dropdownKeyActions.js +2 -2
  38. package/lib/utils/dropdownKeyActions.js.map +1 -1
  39. package/lib/utils/useComboboxBaseState.js +5 -4
  40. package/lib/utils/useComboboxBaseState.js.map +1 -1
  41. package/lib/utils/useComboboxPopup.js +5 -4
  42. package/lib/utils/useComboboxPopup.js.map +1 -1
  43. package/lib/utils/useOptionCollection.js +2 -1
  44. package/lib/utils/useOptionCollection.js.map +1 -1
  45. package/lib/utils/useScrollOptionsIntoView.js +3 -3
  46. package/lib/utils/useScrollOptionsIntoView.js.map +1 -1
  47. package/lib/utils/useSelection.js +5 -3
  48. package/lib/utils/useSelection.js.map +1 -1
  49. package/lib/utils/useTriggerListboxSlots.js +11 -9
  50. package/lib/utils/useTriggerListboxSlots.js.map +1 -1
  51. package/lib-commonjs/Combobox.js +2 -2
  52. package/lib-commonjs/Combobox.js.map +1 -1
  53. package/lib-commonjs/Dropdown.js +2 -2
  54. package/lib-commonjs/Dropdown.js.map +1 -1
  55. package/lib-commonjs/Listbox.js +2 -2
  56. package/lib-commonjs/Listbox.js.map +1 -1
  57. package/lib-commonjs/Option.js +2 -2
  58. package/lib-commonjs/Option.js.map +1 -1
  59. package/lib-commonjs/OptionGroup.js +2 -2
  60. package/lib-commonjs/OptionGroup.js.map +1 -1
  61. package/lib-commonjs/Selection.js +2 -2
  62. package/lib-commonjs/Selection.js.map +1 -1
  63. package/lib-commonjs/components/Combobox/Combobox.js +9 -7
  64. package/lib-commonjs/components/Combobox/Combobox.js.map +1 -1
  65. package/lib-commonjs/components/Combobox/Combobox.types.js +2 -2
  66. package/lib-commonjs/components/Combobox/Combobox.types.js.map +1 -1
  67. package/lib-commonjs/components/Combobox/index.js +6 -6
  68. package/lib-commonjs/components/Combobox/index.js.map +1 -1
  69. package/lib-commonjs/components/Combobox/renderCombobox.js +22 -12
  70. package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
  71. package/lib-commonjs/components/Combobox/useCombobox.js +43 -38
  72. package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
  73. package/lib-commonjs/components/Combobox/useComboboxStyles.styles.js +10 -6
  74. package/lib-commonjs/components/Combobox/useComboboxStyles.styles.js.map +1 -1
  75. package/lib-commonjs/components/Dropdown/Dropdown.js +9 -7
  76. package/lib-commonjs/components/Dropdown/Dropdown.js.map +1 -1
  77. package/lib-commonjs/components/Dropdown/index.js +6 -6
  78. package/lib-commonjs/components/Dropdown/index.js.map +1 -1
  79. package/lib-commonjs/components/Dropdown/renderDropdown.js +26 -12
  80. package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
  81. package/lib-commonjs/components/Dropdown/useDropdown.js +24 -21
  82. package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
  83. package/lib-commonjs/components/Dropdown/useDropdownStyles.styles.js +9 -5
  84. package/lib-commonjs/components/Dropdown/useDropdownStyles.styles.js.map +1 -1
  85. package/lib-commonjs/components/Listbox/Listbox.js +9 -7
  86. package/lib-commonjs/components/Listbox/Listbox.js.map +1 -1
  87. package/lib-commonjs/components/Listbox/index.js +6 -6
  88. package/lib-commonjs/components/Listbox/index.js.map +1 -1
  89. package/lib-commonjs/components/Listbox/renderListbox.js +12 -9
  90. package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
  91. package/lib-commonjs/components/Listbox/useListbox.js +23 -20
  92. package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
  93. package/lib-commonjs/components/Listbox/useListboxStyles.styles.js +7 -3
  94. package/lib-commonjs/components/Listbox/useListboxStyles.styles.js.map +1 -1
  95. package/lib-commonjs/components/Option/Option.js +9 -7
  96. package/lib-commonjs/components/Option/Option.js.map +1 -1
  97. package/lib-commonjs/components/Option/Option.types.js +2 -2
  98. package/lib-commonjs/components/Option/Option.types.js.map +1 -1
  99. package/lib-commonjs/components/Option/index.js +6 -6
  100. package/lib-commonjs/components/Option/index.js.map +1 -1
  101. package/lib-commonjs/components/Option/renderOption.js +13 -6
  102. package/lib-commonjs/components/Option/renderOption.js.map +1 -1
  103. package/lib-commonjs/components/Option/useOption.js +29 -26
  104. package/lib-commonjs/components/Option/useOption.js.map +1 -1
  105. package/lib-commonjs/components/Option/useOptionStyles.styles.js +8 -4
  106. package/lib-commonjs/components/Option/useOptionStyles.styles.js.map +1 -1
  107. package/lib-commonjs/components/OptionGroup/OptionGroup.js +9 -7
  108. package/lib-commonjs/components/OptionGroup/OptionGroup.js.map +1 -1
  109. package/lib-commonjs/components/OptionGroup/index.js +6 -6
  110. package/lib-commonjs/components/OptionGroup/index.js.map +1 -1
  111. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js +15 -6
  112. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js.map +1 -1
  113. package/lib-commonjs/components/OptionGroup/useOptionGroup.js +10 -8
  114. package/lib-commonjs/components/OptionGroup/useOptionGroup.js.map +1 -1
  115. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.styles.js +7 -3
  116. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.styles.js.map +1 -1
  117. package/lib-commonjs/contexts/ComboboxContext.js +8 -4
  118. package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
  119. package/lib-commonjs/contexts/ListboxContext.js +8 -4
  120. package/lib-commonjs/contexts/ListboxContext.js.map +1 -1
  121. package/lib-commonjs/contexts/useComboboxContextValues.js +4 -2
  122. package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
  123. package/lib-commonjs/contexts/useListboxContextValues.js +8 -6
  124. package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
  125. package/lib-commonjs/index.js +94 -36
  126. package/lib-commonjs/index.js.map +1 -1
  127. package/lib-commonjs/utils/ComboboxBase.types.js +2 -2
  128. package/lib-commonjs/utils/ComboboxBase.types.js.map +1 -1
  129. package/lib-commonjs/utils/Selection.types.js +2 -2
  130. package/lib-commonjs/utils/Selection.types.js.map +1 -1
  131. package/lib-commonjs/utils/dropdownKeyActions.js +23 -19
  132. package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
  133. package/lib-commonjs/utils/internalTokens.js +3 -1
  134. package/lib-commonjs/utils/internalTokens.js.map +1 -1
  135. package/lib-commonjs/utils/useComboboxBaseState.js +14 -11
  136. package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
  137. package/lib-commonjs/utils/useComboboxPopup.js +11 -8
  138. package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
  139. package/lib-commonjs/utils/useOptionCollection.js +7 -4
  140. package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
  141. package/lib-commonjs/utils/useScrollOptionsIntoView.js +10 -8
  142. package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -1
  143. package/lib-commonjs/utils/useSelection.js +10 -6
  144. package/lib-commonjs/utils/useSelection.js.map +1 -1
  145. package/lib-commonjs/utils/useTriggerListboxSlots.js +25 -21
  146. package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
  147. package/package.json +15 -15
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "iconSizes", {
6
6
  enumerable: true,
7
- get: ()=>iconSizes
7
+ get: function() {
8
+ return iconSizes;
9
+ }
8
10
  });
9
11
  const iconSizes = {
10
12
  small: '16px',
@@ -1 +1 @@
1
- {"version":3,"sources":["internalTokens.js"],"sourcesContent":["export const iconSizes = {\n small: '16px',\n medium: '20px',\n large: '24px'\n};\n"],"names":["iconSizes","small","medium","large"],"mappings":";;;;+BAAaA;;aAAAA;;AAAN,MAAMA,YAAY;IACrBC,OAAO;IACPC,QAAQ;IACRC,OAAO;AACX"}
1
+ {"version":3,"sources":["internalTokens.js"],"sourcesContent":["export const iconSizes = {\n small: '16px',\n medium: '20px',\n large: '24px'\n};\n"],"names":["iconSizes","small","medium","large"],"mappings":";;;;+BAAaA;;;eAAAA;;;AAAN,MAAMA,YAAY;IACrBC,OAAO;IACPC,QAAQ;IACRC,OAAO;AACX"}
@@ -4,17 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useComboboxBaseState", {
6
6
  enumerable: true,
7
- get: ()=>useComboboxBaseState
7
+ get: function() {
8
+ return useComboboxBaseState;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- const _reactUtilities = require("@fluentui/react-utilities");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _reactutilities = require("@fluentui/react-utilities");
12
14
  const _useOptionCollection = require("../utils/useOptionCollection");
13
15
  const _useSelection = require("../utils/useSelection");
14
16
  const useComboboxBaseState = (props)=>{
15
- const { appearance ='outline' , children , editable =false , inlinePopup =false , mountNode =undefined , multiselect , onOpenChange , size ='medium' } = props;
17
+ const { appearance = 'outline', children, editable = false, inlinePopup = false, mountNode = undefined, multiselect, onOpenChange, size = 'medium' } = props;
16
18
  const optionCollection = (0, _useOptionCollection.useOptionCollection)();
17
- const { getOptionAtIndex , getOptionsMatchingValue } = optionCollection;
19
+ const { getOptionAtIndex, getOptionsMatchingValue } = optionCollection;
18
20
  const [activeOption, setActiveOption] = _react.useState();
19
21
  // track whether keyboard focus outline should be shown
20
22
  // tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move
@@ -23,10 +25,10 @@ const useComboboxBaseState = (props)=>{
23
25
  const [hasFocus, setHasFocus] = _react.useState(false);
24
26
  const ignoreNextBlur = _react.useRef(false);
25
27
  const selectionState = (0, _useSelection.useSelection)(props);
26
- const { selectedOptions } = selectionState;
28
+ const { selectedOptions } = selectionState;
27
29
  // calculate value based on props, internal value changes, and selected options
28
- const isFirstMount = (0, _reactUtilities.useFirstMount)();
29
- const [controllableValue, setValue] = (0, _reactUtilities.useControllableState)({
30
+ const isFirstMount = (0, _reactutilities.useFirstMount)();
31
+ const [controllableValue, setValue] = (0, _reactutilities.useControllableState)({
30
32
  state: props.value,
31
33
  initialState: undefined
32
34
  });
@@ -60,13 +62,14 @@ const useComboboxBaseState = (props)=>{
60
62
  selectedOptions
61
63
  ]);
62
64
  // Handle open state, which is shared with options in context
63
- const [open, setOpenState] = (0, _reactUtilities.useControllableState)({
65
+ const [open, setOpenState] = (0, _reactutilities.useControllableState)({
64
66
  state: props.open,
65
67
  defaultState: props.defaultOpen,
66
68
  initialState: false
67
69
  });
68
70
  const setOpen = _react.useCallback((event, newState)=>{
69
- onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {
71
+ var _onOpenChange;
72
+ (_onOpenChange = onOpenChange) === null || _onOpenChange === void 0 ? void 0 : _onOpenChange(event, {
70
73
  open: newState
71
74
  });
72
75
  setOpenState(newState);
@@ -1 +1 @@
1
- {"version":3,"sources":["useComboboxBaseState.js"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState, useFirstMount } from '@fluentui/react-utilities';\nimport { useOptionCollection } from '../utils/useOptionCollection';\nimport { useSelection } from '../utils/useSelection';\n/**\n * State shared between Combobox and Dropdown components\n */ export const useComboboxBaseState = (props)=>{\n const { appearance ='outline' , children , editable =false , inlinePopup =false , mountNode =undefined , multiselect , onOpenChange , size ='medium' } = props;\n const optionCollection = useOptionCollection();\n const { getOptionAtIndex , getOptionsMatchingValue } = optionCollection;\n const [activeOption, setActiveOption] = React.useState();\n // track whether keyboard focus outline should be shown\n // tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move\n const [focusVisible, setFocusVisible] = React.useState(false);\n // track focused state to conditionally render collapsed listbox\n const [hasFocus, setHasFocus] = React.useState(false);\n const ignoreNextBlur = React.useRef(false);\n const selectionState = useSelection(props);\n const { selectedOptions } = selectionState;\n // calculate value based on props, internal value changes, and selected options\n const isFirstMount = useFirstMount();\n const [controllableValue, setValue] = useControllableState({\n state: props.value,\n initialState: undefined\n });\n const value = React.useMemo(()=>{\n // don't compute the value if it is defined through props or setValue,\n if (controllableValue !== undefined) {\n return controllableValue;\n }\n // handle defaultValue here, so it is overridden by selection\n if (isFirstMount && props.defaultValue !== undefined) {\n return props.defaultValue;\n }\n const selectedOptionsText = getOptionsMatchingValue((optionValue)=>{\n return selectedOptions.includes(optionValue);\n }).map((option)=>option.text);\n if (multiselect) {\n // editable inputs should not display multiple selected options in the input as text\n return editable ? '' : selectedOptionsText.join(', ');\n }\n return selectedOptionsText[0];\n // do not change value after isFirstMount changes,\n // we do not want to accidentally override defaultValue on a second render\n // unless another value is intentionally set\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n controllableValue,\n editable,\n getOptionsMatchingValue,\n multiselect,\n props.defaultValue,\n selectedOptions\n ]);\n // Handle open state, which is shared with options in context\n const [open, setOpenState] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false\n });\n const setOpen = React.useCallback((event, newState)=>{\n onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(event, {\n open: newState\n });\n setOpenState(newState);\n }, [\n onOpenChange,\n setOpenState\n ]);\n // update active option based on change in open state or children\n React.useEffect(()=>{\n if (open && !activeOption) {\n // if it is single-select and there is a selected option, start at the selected option\n if (!multiselect && selectedOptions.length > 0) {\n const selectedOption = getOptionsMatchingValue((v)=>v === selectedOptions[0]).pop();\n selectedOption && setActiveOption(selectedOption);\n } else {\n setActiveOption(getOptionAtIndex(0));\n }\n } else if (!open) {\n // reset the active option when closing\n setActiveOption(undefined);\n }\n // this should only be run in response to changes in the open state or children\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n open,\n children\n ]);\n return {\n ...optionCollection,\n ...selectionState,\n activeOption,\n appearance,\n focusVisible,\n hasFocus,\n ignoreNextBlur,\n inlinePopup,\n mountNode,\n open,\n setActiveOption,\n setFocusVisible,\n setHasFocus,\n setOpen,\n setValue,\n size,\n value\n };\n};\n"],"names":["useComboboxBaseState","props","appearance","children","editable","inlinePopup","mountNode","undefined","multiselect","onOpenChange","size","optionCollection","useOptionCollection","getOptionAtIndex","getOptionsMatchingValue","activeOption","setActiveOption","React","useState","focusVisible","setFocusVisible","hasFocus","setHasFocus","ignoreNextBlur","useRef","selectionState","useSelection","selectedOptions","isFirstMount","useFirstMount","controllableValue","setValue","useControllableState","state","value","initialState","useMemo","defaultValue","selectedOptionsText","optionValue","includes","map","option","text","join","open","setOpenState","defaultState","defaultOpen","setOpen","useCallback","event","newState","useEffect","length","selectedOption","v","pop"],"mappings":";;;;+BAMiBA;;aAAAA;;;6DANM;gCAC6B;qCAChB;8BACP;AAGlB,MAAMA,uBAAuB,CAACC,QAAQ;IAC7C,MAAM,EAAEC,YAAY,UAAS,EAAGC,SAAQ,EAAGC,UAAU,KAAK,CAAA,EAAGC,aAAa,KAAK,CAAA,EAAGC,WAAWC,UAAS,EAAGC,YAAW,EAAGC,aAAY,EAAGC,MAAM,SAAQ,EAAG,GAAGT;IAC1J,MAAMU,mBAAmBC,IAAAA,wCAAmB;IAC5C,MAAM,EAAEC,iBAAgB,EAAGC,wBAAuB,EAAG,GAAGH;IACxD,MAAM,CAACI,cAAcC,gBAAgB,GAAGC,OAAMC,QAAQ;IACtD,uDAAuD;IACvD,yFAAyF;IACzF,MAAM,CAACC,cAAcC,gBAAgB,GAAGH,OAAMC,QAAQ,CAAC,KAAK;IAC5D,gEAAgE;IAChE,MAAM,CAACG,UAAUC,YAAY,GAAGL,OAAMC,QAAQ,CAAC,KAAK;IACpD,MAAMK,iBAAiBN,OAAMO,MAAM,CAAC,KAAK;IACzC,MAAMC,iBAAiBC,IAAAA,0BAAY,EAACzB;IACpC,MAAM,EAAE0B,gBAAe,EAAG,GAAGF;IAC7B,+EAA+E;IAC/E,MAAMG,eAAeC,IAAAA,6BAAa;IAClC,MAAM,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,MAAM,GAAG,GAAG;gBAC5C,MAAMC,iBAAiBzC,wBAAwB,CAAC0C,IAAIA,MAAM7B,eAAe,CAAC,EAAE,EAAE8B,GAAG;gBACjFF,kBAAkBvC,gBAAgBuC;YACtC,OAAO;gBACHvC,gBAAgBH,iBAAiB;YACrC,CAAC;QACL,OAAO,IAAI,CAACgC,MAAM;YACd,uCAAuC;YACvC7B,gBAAgBT;QACpB,CAAC;IACL,+EAA+E;IAC/E,uDAAuD;IACvD,GAAG;QACCsC;QACA1C;KACH;IACD,OAAO;QACH,GAAGQ,gBAAgB;QACnB,GAAGc,cAAc;QACjBV;QACAb;QACAiB;QACAE;QACAE;QACAlB;QACAC;QACAuC;QACA7B;QACAI;QACAE;QACA2B;QACAlB;QACArB;QACAwB;IACJ;AACJ"}
1
+ {"version":3,"sources":["useComboboxBaseState.js"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState, useFirstMount } from '@fluentui/react-utilities';\nimport { useOptionCollection } from '../utils/useOptionCollection';\nimport { useSelection } from '../utils/useSelection';\n/**\n * State shared between Combobox and Dropdown components\n */ export const useComboboxBaseState = (props)=>{\n const { appearance = 'outline', children, editable = false, inlinePopup = false, mountNode = undefined, multiselect, onOpenChange, size = 'medium' } = props;\n const optionCollection = useOptionCollection();\n const { getOptionAtIndex, getOptionsMatchingValue } = optionCollection;\n const [activeOption, setActiveOption] = React.useState();\n // track whether keyboard focus outline should be shown\n // tabster/keyborg doesn't work here, since the actual keyboard focus target doesn't move\n const [focusVisible, setFocusVisible] = React.useState(false);\n // track focused state to conditionally render collapsed listbox\n const [hasFocus, setHasFocus] = React.useState(false);\n const ignoreNextBlur = React.useRef(false);\n const selectionState = useSelection(props);\n const { selectedOptions } = selectionState;\n // calculate value based on props, internal value changes, and selected options\n const isFirstMount = useFirstMount();\n const [controllableValue, setValue] = useControllableState({\n state: props.value,\n initialState: undefined\n });\n const value = React.useMemo(()=>{\n // don't compute the value if it is defined through props or setValue,\n if (controllableValue !== undefined) {\n return controllableValue;\n }\n // handle defaultValue here, so it is overridden by selection\n if (isFirstMount && props.defaultValue !== undefined) {\n return props.defaultValue;\n }\n const selectedOptionsText = getOptionsMatchingValue((optionValue)=>{\n return selectedOptions.includes(optionValue);\n }).map((option)=>option.text);\n if (multiselect) {\n // editable inputs should not display multiple selected options in the input as text\n return editable ? '' : selectedOptionsText.join(', ');\n }\n return selectedOptionsText[0];\n // do not change value after isFirstMount changes,\n // we do not want to accidentally override defaultValue on a second render\n // unless another value is intentionally set\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n controllableValue,\n editable,\n getOptionsMatchingValue,\n multiselect,\n props.defaultValue,\n selectedOptions\n ]);\n // Handle open state, which is shared with options in context\n const [open, setOpenState] = useControllableState({\n state: props.open,\n defaultState: props.defaultOpen,\n initialState: false\n });\n const setOpen = React.useCallback((event, newState)=>{\n var _onOpenChange;\n (_onOpenChange = onOpenChange) === null || _onOpenChange === void 0 ? void 0 : _onOpenChange(event, {\n open: newState\n });\n setOpenState(newState);\n }, [\n onOpenChange,\n setOpenState\n ]);\n // update active option based on change in open state or children\n React.useEffect(()=>{\n if (open && !activeOption) {\n // if it is single-select and there is a selected option, start at the selected option\n if (!multiselect && selectedOptions.length > 0) {\n const selectedOption = getOptionsMatchingValue((v)=>v === selectedOptions[0]).pop();\n selectedOption && setActiveOption(selectedOption);\n } else {\n setActiveOption(getOptionAtIndex(0));\n }\n } else if (!open) {\n // reset the active option when closing\n setActiveOption(undefined);\n }\n // this should only be run in response to changes in the open state or children\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n open,\n children\n ]);\n return {\n ...optionCollection,\n ...selectionState,\n activeOption,\n appearance,\n focusVisible,\n hasFocus,\n ignoreNextBlur,\n inlinePopup,\n mountNode,\n open,\n setActiveOption,\n setFocusVisible,\n setHasFocus,\n setOpen,\n setValue,\n size,\n value\n };\n};\n"],"names":["useComboboxBaseState","props","appearance","children","editable","inlinePopup","mountNode","undefined","multiselect","onOpenChange","size","optionCollection","useOptionCollection","getOptionAtIndex","getOptionsMatchingValue","activeOption","setActiveOption","React","useState","focusVisible","setFocusVisible","hasFocus","setHasFocus","ignoreNextBlur","useRef","selectionState","useSelection","selectedOptions","isFirstMount","useFirstMount","controllableValue","setValue","useControllableState","state","value","initialState","useMemo","defaultValue","selectedOptionsText","optionValue","includes","map","option","text","join","open","setOpenState","defaultState","defaultOpen","setOpen","useCallback","event","newState","_onOpenChange","useEffect","length","selectedOption","v","pop"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;gCAC6B;qCAChB;8BACP;AAGlB,MAAMA,uBAAuB,CAACC;IACrC,MAAM,EAAEC,aAAa,SAAS,EAAEC,QAAQ,EAAEC,WAAW,KAAK,EAAEC,cAAc,KAAK,EAAEC,YAAYC,SAAS,EAAEC,WAAW,EAAEC,YAAY,EAAEC,OAAO,QAAQ,EAAE,GAAGT;IACvJ,MAAMU,mBAAmBC,IAAAA,wCAAmB;IAC5C,MAAM,EAAEC,gBAAgB,EAAEC,uBAAuB,EAAE,GAAGH;IACtD,MAAM,CAACI,cAAcC,gBAAgB,GAAGC,OAAMC,QAAQ;IACtD,uDAAuD;IACvD,yFAAyF;IACzF,MAAM,CAACC,cAAcC,gBAAgB,GAAGH,OAAMC,QAAQ,CAAC;IACvD,gEAAgE;IAChE,MAAM,CAACG,UAAUC,YAAY,GAAGL,OAAMC,QAAQ,CAAC;IAC/C,MAAMK,iBAAiBN,OAAMO,MAAM,CAAC;IACpC,MAAMC,iBAAiBC,IAAAA,0BAAY,EAACzB;IACpC,MAAM,EAAE0B,eAAe,EAAE,GAAGF;IAC5B,+EAA+E;IAC/E,MAAMG,eAAeC,IAAAA,6BAAa;IAClC,MAAM,CAACC,mBAAmBC,SAAS,GAAGC,IAAAA,oCAAoB,EAAC;QACvDC,OAAOhC,MAAMiC,KAAK;QAClBC,cAAc5B;IAClB;IACA,MAAM2B,QAAQjB,OAAMmB,OAAO,CAAC;QACxB,sEAAsE;QACtE,IAAIN,sBAAs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M;YACd,uCAAuC;YACvC7B,gBAAgBT;QACpB;IACJ,+EAA+E;IAC/E,uDAAuD;IACvD,GAAG;QACCsC;QACA1C;KACH;IACD,OAAO;QACH,GAAGQ,gBAAgB;QACnB,GAAGc,cAAc;QACjBV;QACAb;QACAiB;QACAE;QACAE;QACAlB;QACAC;QACAuC;QACA7B;QACAI;QACAE;QACA2B;QACAlB;QACArB;QACAwB;IACJ;AACJ"}
@@ -4,12 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useComboboxPopup", {
6
6
  enumerable: true,
7
- get: ()=>useComboboxPopup
7
+ get: function() {
8
+ return useComboboxPopup;
9
+ }
8
10
  });
9
- const _reactPositioning = require("@fluentui/react-positioning");
10
- const _reactUtilities = require("@fluentui/react-utilities");
11
+ const _reactpositioning = require("@fluentui/react-positioning");
12
+ const _reactutilities = require("@fluentui/react-utilities");
11
13
  function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
12
- const { positioning } = props;
14
+ var _listboxShorthand, _triggerShorthand;
15
+ const { positioning } = props;
13
16
  // Set a default set of fallback positions to try if the dropdown does not fit on screen
14
17
  const fallbackPositions = [
15
18
  'above',
@@ -27,10 +30,10 @@ function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
27
30
  mainAxis: 2
28
31
  },
29
32
  fallbackPositions,
30
- ...(0, _reactPositioning.resolvePositioningShorthand)(positioning)
33
+ ...(0, _reactpositioning.resolvePositioningShorthand)(positioning)
31
34
  };
32
- const { targetRef , containerRef } = (0, _reactPositioning.usePositioning)(popperOptions);
33
- const listboxRef = (0, _reactUtilities.useMergedRefs)(listboxShorthand === null || listboxShorthand === void 0 ? void 0 : listboxShorthand.ref, containerRef);
35
+ const { targetRef, containerRef } = (0, _reactpositioning.usePositioning)(popperOptions);
36
+ const listboxRef = (0, _reactutilities.useMergedRefs)((_listboxShorthand = listboxShorthand) === null || _listboxShorthand === void 0 ? void 0 : _listboxShorthand.ref, containerRef);
34
37
  const listbox = listboxShorthand && {
35
38
  ...listboxShorthand,
36
39
  ref: listboxRef
@@ -38,7 +41,7 @@ function useComboboxPopup(props, triggerShorthand, listboxShorthand) {
38
41
  return [
39
42
  {
40
43
  ...triggerShorthand,
41
- ref: (0, _reactUtilities.useMergedRefs)(triggerShorthand === null || triggerShorthand === void 0 ? void 0 : triggerShorthand.ref, targetRef)
44
+ ref: (0, _reactutilities.useMergedRefs)((_triggerShorthand = triggerShorthand) === null || _triggerShorthand === void 0 ? void 0 : _triggerShorthand.ref, targetRef)
42
45
  },
43
46
  listbox
44
47
  ];
@@ -1 +1 @@
1
- {"version":3,"sources":["useComboboxPopup.js"],"sourcesContent":["import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useMergedRefs } from '@fluentui/react-utilities';\nexport function useComboboxPopup(props, triggerShorthand, listboxShorthand) {\n const { positioning } = props;\n // Set a default set of fallback positions to try if the dropdown does not fit on screen\n const fallbackPositions = [\n 'above',\n 'after',\n 'after-top',\n 'before',\n 'before-top'\n ];\n // popper options\n const popperOptions = {\n position: 'below',\n align: 'start',\n offset: {\n crossAxis: 0,\n mainAxis: 2\n },\n fallbackPositions,\n ...resolvePositioningShorthand(positioning)\n };\n const { targetRef , containerRef } = usePositioning(popperOptions);\n const listboxRef = useMergedRefs(listboxShorthand === null || listboxShorthand === void 0 ? void 0 : listboxShorthand.ref, containerRef);\n const listbox = listboxShorthand && {\n ...listboxShorthand,\n ref: listboxRef\n };\n return [\n {\n ...triggerShorthand,\n ref: useMergedRefs(triggerShorthand === null || triggerShorthand === void 0 ? void 0 : triggerShorthand.ref, targetRef)\n },\n listbox\n ];\n}\n"],"names":["useComboboxPopup","props","triggerShorthand","listboxShorthand","positioning","fallbackPositions","popperOptions","position","align","offset","crossAxis","mainAxis","resolvePositioningShorthand","targetRef","containerRef","usePositioning","listboxRef","useMergedRefs","ref","listbox"],"mappings":";;;;+BAEgBA;;aAAAA;;kCAF4C;gCAC9B;AACvB,SAASA,iBAAiBC,KAAK,EAAEC,gBAAgB,EAAEC,gBAAgB,EAAE;IACxE,MAAM,EAAEC,YAAW,EAAG,GAAGH;IACzB,wFAAwF;IACxF,MAAMI,oBAAoB;QACtB;QACA;QACA;QACA;QACA;KACH;IACD,iBAAiB;IACjB,MAAMC,gBAAgB;QAClBC,UAAU;QACVC,OAAO;QACPC,QAAQ;YACJC,WAAW;YACXC,UAAU;QACd;QACAN;QACA,GAAGO,IAAAA,6CAA2B,EAACR,YAAY;IAC/C;IACA,MAAM,EAAES,UAAS,EAAGC,aAAY,EAAG,GAAGC,IAAAA,gCAAc,EAACT;IACrD,MAAMU,aAAaC,IAAAA,6BAAa,EAACd,qBAAqB,IAAI,IAAIA,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBe,GAAG,EAAEJ;IAC3H,MAAMK,UAAUhB,oBAAoB;QAChC,GAAGA,gBAAgB;QACnBe,KAAKF;IACT;IACA,OAAO;QACH;YACI,GAAGd,gBAAgB;YACnBgB,KAAKD,IAAAA,6BAAa,EAACf,qBAAqB,IAAI,IAAIA,qBAAqB,KAAK,IAAI,KAAK,IAAIA,iBAAiBgB,GAAG,EAAEL;QACjH;QACAM;KACH;AACL"}
1
+ {"version":3,"sources":["useComboboxPopup.js"],"sourcesContent":["import { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useMergedRefs } from '@fluentui/react-utilities';\nexport function useComboboxPopup(props, triggerShorthand, listboxShorthand) {\n var _listboxShorthand, _triggerShorthand;\n const { positioning } = props;\n // Set a default set of fallback positions to try if the dropdown does not fit on screen\n const fallbackPositions = [\n 'above',\n 'after',\n 'after-top',\n 'before',\n 'before-top'\n ];\n // popper options\n const popperOptions = {\n position: 'below',\n align: 'start',\n offset: {\n crossAxis: 0,\n mainAxis: 2\n },\n fallbackPositions,\n ...resolvePositioningShorthand(positioning)\n };\n const { targetRef, containerRef } = usePositioning(popperOptions);\n const listboxRef = useMergedRefs((_listboxShorthand = listboxShorthand) === null || _listboxShorthand === void 0 ? void 0 : _listboxShorthand.ref, containerRef);\n const listbox = listboxShorthand && {\n ...listboxShorthand,\n ref: listboxRef\n };\n return [\n {\n ...triggerShorthand,\n ref: useMergedRefs((_triggerShorthand = triggerShorthand) === null || _triggerShorthand === void 0 ? void 0 : _triggerShorthand.ref, targetRef)\n },\n listbox\n ];\n}\n"],"names":["useComboboxPopup","props","triggerShorthand","listboxShorthand","_listboxShorthand","_triggerShorthand","positioning","fallbackPositions","popperOptions","position","align","offset","crossAxis","mainAxis","resolvePositioningShorthand","targetRef","containerRef","usePositioning","listboxRef","useMergedRefs","ref","listbox"],"mappings":";;;;+BAEgBA;;;eAAAA;;;kCAF4C;gCAC9B;AACvB,SAASA,iBAAiBC,KAAK,EAAEC,gBAAgB,EAAEC,gBAAgB;IACtE,IAAIC,mBAAmBC;IACvB,MAAM,EAAEC,WAAW,EAAE,GAAGL;IACxB,wFAAwF;IACxF,MAAMM,oBAAoB;QACtB;QACA;QACA;QACA;QACA;KACH;IACD,iBAAiB;IACjB,MAAMC,gBAAgB;QAClBC,UAAU;QACVC,OAAO;QACPC,QAAQ;YACJC,WAAW;YACXC,UAAU;QACd;QACAN;QACA,GAAGO,IAAAA,6CAA2B,EAACR,YAAY;IAC/C;IACA,MAAM,EAAES,SAAS,EAAEC,YAAY,EAAE,GAAGC,IAAAA,gCAAc,EAACT;IACnD,MAAMU,aAAaC,IAAAA,6BAAa,EAAC,AAACf,CAAAA,oBAAoBD,gBAAe,MAAO,QAAQC,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBgB,GAAG,EAAEJ;IACnJ,MAAMK,UAAUlB,oBAAoB;QAChC,GAAGA,gBAAgB;QACnBiB,KAAKF;IACT;IACA,OAAO;QACH;YACI,GAAGhB,gBAAgB;YACnBkB,KAAKD,IAAAA,6BAAa,EAAC,AAACd,CAAAA,oBAAoBH,gBAAe,MAAO,QAAQG,sBAAsB,KAAK,IAAI,KAAK,IAAIA,kBAAkBe,GAAG,EAAEL;QACzI;QACAM;KACH;AACL"}
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useOptionCollection", {
6
6
  enumerable: true,
7
- get: ()=>useOptionCollection
7
+ get: function() {
8
+ return useOptionCollection;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
11
13
  const useOptionCollection = ()=>{
12
14
  const nodes = _react.useRef([]);
13
15
  const collectionAPI = _react.useMemo(()=>{
@@ -18,8 +20,9 @@ const useOptionCollection = ()=>{
18
20
  };
19
21
  const getIndexOfId = (id)=>nodes.current.findIndex((node)=>node.option.id === id);
20
22
  const getOptionById = (id)=>{
23
+ var _item;
21
24
  const item = nodes.current.find((node)=>node.option.id === id);
22
- return item === null || item === void 0 ? void 0 : item.option;
25
+ return (_item = item) === null || _item === void 0 ? void 0 : _item.option;
23
26
  };
24
27
  const getOptionsMatchingText = (matcher)=>{
25
28
  return nodes.current.filter((node)=>matcher(node.option.text)).map((node)=>node.option);
@@ -1 +1 @@
1
- {"version":3,"sources":["useOptionCollection.js"],"sourcesContent":["import * as React from 'react';\n/**\n * A hook for managing a collection of child Options\n */ export const useOptionCollection = ()=>{\n const nodes = React.useRef([]);\n const collectionAPI = React.useMemo(()=>{\n const getCount = ()=>nodes.current.length;\n const getOptionAtIndex = (index)=>{\n var _nodes_current_index;\n return (_nodes_current_index = nodes.current[index]) === null || _nodes_current_index === void 0 ? void 0 : _nodes_current_index.option;\n };\n const getIndexOfId = (id)=>nodes.current.findIndex((node)=>node.option.id === id);\n const getOptionById = (id)=>{\n const item = nodes.current.find((node)=>node.option.id === id);\n return item === null || item === void 0 ? void 0 : item.option;\n };\n const getOptionsMatchingText = (matcher)=>{\n return nodes.current.filter((node)=>matcher(node.option.text)).map((node)=>node.option);\n };\n const getOptionsMatchingValue = (matcher)=>{\n return nodes.current.filter((node)=>matcher(node.option.value)).map((node)=>node.option);\n };\n return {\n getCount,\n getOptionAtIndex,\n getIndexOfId,\n getOptionById,\n getOptionsMatchingText,\n getOptionsMatchingValue\n };\n }, []);\n const registerOption = React.useCallback((option, element)=>{\n var _nodes_current_index;\n const index = nodes.current.findIndex((node)=>{\n if (!node.element || !element) {\n return false;\n }\n if (node.option.id === option.id) {\n return true;\n }\n // use the DOM method compareDocumentPosition to order the current node against registered nodes\n // eslint-disable-next-line no-bitwise\n return node.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING;\n });\n // do not register the option if it already exists\n if (((_nodes_current_index = nodes.current[index]) === null || _nodes_current_index === void 0 ? void 0 : _nodes_current_index.option.id) !== option.id) {\n const newItem = {\n element,\n option\n };\n // If an index is not found we will push the element to the end.\n if (index === -1) {\n nodes.current = [\n ...nodes.current,\n newItem\n ];\n } else {\n nodes.current.splice(index, 0, newItem);\n }\n }\n // return the unregister function\n return ()=>{\n nodes.current = nodes.current.filter((node)=>node.option.id !== option.id);\n };\n }, []);\n return {\n ...collectionAPI,\n options: nodes.current.map((node)=>node.option),\n registerOption\n };\n};\n"],"names":["useOptionCollection","nodes","React","useRef","collectionAPI","useMemo","getCount","current","length","getOptionAtIndex","index","_nodes_current_index","option","getIndexOfId","id","findIndex","node","getOptionById","item","find","getOptionsMatchingText","matcher","filter","text","map","getOptionsMatchingValue","value","registerOption","useCallback","element","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","newItem","splice","options"],"mappings":";;;;+BAGiBA;;aAAAA;;;6DAHM;AAGZ,MAAMA,sBAAsB,IAAI;IACvC,MAAMC,QAAQC,OAAMC,MAAM,CAAC,EAAE;IAC7B,MAAMC,gBAAgBF,OAAMG,OAAO,CAAC,IAAI;QACpC,MAAMC,WAAW,IAAIL,MAAMM,OAAO,CAACC,MAAM;Q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AAE,EAAE;gBAC9B,OAAO,IAAI;YACf,CAAC;YACD,gGAAgG;YAChG,sCAAsC;YACtC,OAAOE,KAAKa,OAAO,CAACC,uBAAuB,CAACD,WAAWE,KAAKC,2BAA2B;QAC3F;QACA,kDAAkD;QAClD,IAAI,AAAC,CAAA,AAACrB,CAAAA,uBAAuBV,MAAMM,OAAO,CAACG,MAAM,AAAD,MAAO,IAAI,IAAIC,yBAAyB,KAAK,IAAI,KAAK,IAAIA,qBAAqBC,MAAM,CAACE,EAAE,AAAD,MAAOF,OAAOE,EAAE,EAAE;YACrJ,MAAMmB,UAAU;gBACZJ;gBACAjB;YACJ;YACA,gEAAgE;YAChE,IAAIF,UAAU,CAAC,GAAG;gBACdT,MAAMM,OAAO,GAAG;uBACTN,MAAMM,OAAO;oBAChB0B;iBACH;YACL,OAAO;gBACHhC,MAAMM,OAAO,CAAC2B,MAAM,CAACxB,OAAO,GAAGuB;YACnC,CAAC;QACL,CAAC;QACD,iCAAiC;QACjC,OAAO,IAAI;YACPhC,MAAMM,OAAO,GAAGN,MAAMM,OAAO,CAACe,MAAM,CAAC,CAACN,OAAOA,KAAKJ,MAAM,CAACE,EAAE,KAAKF,OAAOE,EAAE;QAC7E;IACJ,GAAG,EAAE;IACL,OAAO;QACH,GAAGV,aAAa;QAChB+B,SAASlC,MAAMM,OAAO,CAACiB,GAAG,CAAC,CAACR,OAAOA,KAAKJ,MAAM;QAC9Ce;IACJ;AACJ"}
1
+ {"version":3,"sources":["useOptionCollection.js"],"sourcesContent":["import * as React from 'react';\n/**\n * A hook for managing a collection of child Options\n */ export const useOptionCollection = ()=>{\n const nodes = React.useRef([]);\n const collectionAPI = React.useMemo(()=>{\n const getCount = ()=>nodes.current.length;\n const getOptionAtIndex = (index)=>{\n var _nodes_current_index;\n return (_nodes_current_index = nodes.current[index]) === null || _nodes_current_index === void 0 ? void 0 : _nodes_current_index.option;\n };\n const getIndexOfId = (id)=>nodes.current.findIndex((node)=>node.option.id === id);\n const getOptionById = (id)=>{\n var _item;\n const item = nodes.current.find((node)=>node.option.id === id);\n return (_item = item) === null || _item === void 0 ? void 0 : _item.option;\n };\n const getOptionsMatchingText = (matcher)=>{\n return nodes.current.filter((node)=>matcher(node.option.text)).map((node)=>node.option);\n };\n const getOptionsMatchingValue = (matcher)=>{\n return nodes.current.filter((node)=>matcher(node.option.value)).map((node)=>node.option);\n };\n return {\n getCount,\n getOptionAtIndex,\n getIndexOfId,\n getOptionById,\n getOptionsMatchingText,\n getOptionsMatchingValue\n };\n }, []);\n const registerOption = React.useCallback((option, element)=>{\n var _nodes_current_index;\n const index = nodes.current.findIndex((node)=>{\n if (!node.element || !element) {\n return false;\n }\n if (node.option.id === option.id) {\n return true;\n }\n // use the DOM method compareDocumentPosition to order the current node against registered nodes\n // eslint-disable-next-line no-bitwise\n return node.element.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING;\n });\n // do not register the option if it already exists\n if (((_nodes_current_index = nodes.current[index]) === null || _nodes_current_index === void 0 ? void 0 : _nodes_current_index.option.id) !== option.id) {\n const newItem = {\n element,\n option\n };\n // If an index is not found we will push the element to the end.\n if (index === -1) {\n nodes.current = [\n ...nodes.current,\n newItem\n ];\n } else {\n nodes.current.splice(index, 0, newItem);\n }\n }\n // return the unregister function\n return ()=>{\n nodes.current = nodes.current.filter((node)=>node.option.id !== option.id);\n };\n }, []);\n return {\n ...collectionAPI,\n options: nodes.current.map((node)=>node.option),\n registerOption\n };\n};\n"],"names":["useOptionCollection","nodes","React","useRef","collectionAPI","useMemo","getCount","current","length","getOptionAtIndex","index","_nodes_current_index","option","getIndexOfId","id","findIndex","node","getOptionById","_item","item","find","getOptionsMatchingText","matcher","filter","text","map","getOptionsMatchingValue","value","registerOption","useCallback","element","compareDocumentPosition","Node","DOCUMENT_POSITION_PRECEDING","newItem","splice","options"],"mappings":";;;;+BAGiBA;;;eAAAA;;;;iEAHM;AAGZ,MAAMA,sBAAsB;IACnC,MAAMC,QAAQC,OAAMC,MAAM,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,CAACA,SAAS;gBAC3B,OAAO;YACX;YACA,IAAId,KAAKJ,MAAM,CAACE,EAAE,KAAKF,OAAOE,EAAE,EAAE;gBAC9B,OAAO;YACX;YACA,gGAAgG;YAChG,sCAAsC;YACtC,OAAOE,KAAKc,OAAO,CAACC,uBAAuB,CAACD,WAAWE,KAAKC,2BAA2B;QAC3F;QACA,kDAAkD;QAClD,IAAI,AAAC,CAAA,AAACtB,CAAAA,uBAAuBV,MAAMM,OAAO,CAACG,MAAM,AAAD,MAAO,QAAQC,yBAAyB,KAAK,IAAI,KAAK,IAAIA,qBAAqBC,MAAM,CAACE,EAAE,AAAD,MAAOF,OAAOE,EAAE,EAAE;YACrJ,MAAMoB,UAAU;gBACZJ;gBACAlB;YACJ;YACA,gEAAgE;YAChE,IAAIF,UAAU,CAAC,GAAG;gBACdT,MAAMM,OAAO,GAAG;uBACTN,MAAMM,OAAO;oBAChB2B;iBACH;YACL,OAAO;gBACHjC,MAAMM,OAAO,CAAC4B,MAAM,CAACzB,OAAO,GAAGwB;YACnC;QACJ;QACA,iCAAiC;QACjC,OAAO;YACHjC,MAAMM,OAAO,GAAGN,MAAMM,OAAO,CAACgB,MAAM,CAAC,CAACP,OAAOA,KAAKJ,MAAM,CAACE,EAAE,KAAKF,OAAOE,EAAE;QAC7E;IACJ,GAAG,EAAE;IACL,OAAO;QACH,GAAGV,aAAa;QAChBgC,SAASnC,MAAMM,OAAO,CAACkB,GAAG,CAAC,CAACT,OAAOA,KAAKJ,MAAM;QAC9CgB;IACJ;AACJ"}
@@ -4,22 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useScrollOptionsIntoView", {
6
6
  enumerable: true,
7
- get: ()=>useScrollOptionsIntoView
7
+ get: function() {
8
+ return useScrollOptionsIntoView;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- const _reactUtilities = require("@fluentui/react-utilities");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _reactutilities = require("@fluentui/react-utilities");
12
14
  function useScrollOptionsIntoView(state) {
13
- const { activeOption } = state;
15
+ const { activeOption } = state;
14
16
  const scrollContainerRef = _react.useRef(null);
15
17
  _react.useEffect(()=>{
16
- if (scrollContainerRef.current && activeOption && (0, _reactUtilities.canUseDOM)()) {
18
+ if (scrollContainerRef.current && activeOption && (0, _reactutilities.canUseDOM)()) {
17
19
  const activeOptionElement = scrollContainerRef.current.querySelector(`#${activeOption.id}`);
18
20
  if (!activeOptionElement) {
19
21
  return;
20
22
  }
21
- const { offsetHeight , offsetTop } = activeOptionElement;
22
- const { offsetHeight: parentOffsetHeight , scrollTop } = scrollContainerRef.current;
23
+ const { offsetHeight, offsetTop } = activeOptionElement;
24
+ const { offsetHeight: parentOffsetHeight, scrollTop } = scrollContainerRef.current;
23
25
  const isAbove = offsetTop < scrollTop;
24
26
  const isBelow = offsetTop + offsetHeight > scrollTop + parentOffsetHeight;
25
27
  // add a small buffer for general visual nicety
@@ -1 +1 @@
1
- {"version":3,"sources":["useScrollOptionsIntoView.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nexport function useScrollOptionsIntoView(state) {\n const { activeOption } = state;\n const scrollContainerRef = React.useRef(null);\n React.useEffect(()=>{\n if (scrollContainerRef.current && activeOption && canUseDOM()) {\n const activeOptionElement = scrollContainerRef.current.querySelector(`#${activeOption.id}`);\n if (!activeOptionElement) {\n return;\n }\n const { offsetHeight , offsetTop } = activeOptionElement;\n const { offsetHeight: parentOffsetHeight , scrollTop } = scrollContainerRef.current;\n const isAbove = offsetTop < scrollTop;\n const isBelow = offsetTop + offsetHeight > scrollTop + parentOffsetHeight;\n // add a small buffer for general visual nicety\n // it looks slightly better if the option has some space from the top/bottom while arrowing\n const buffer = 2;\n if (isAbove) {\n scrollContainerRef.current.scrollTo(0, offsetTop - buffer);\n } else if (isBelow) {\n scrollContainerRef.current.scrollTo(0, offsetTop - parentOffsetHeight + offsetHeight + buffer);\n }\n }\n }, [\n activeOption\n ]);\n return scrollContainerRef;\n}\n"],"names":["useScrollOptionsIntoView","state","activeOption","scrollContainerRef","React","useRef","useEffect","current","canUseDOM","activeOptionElement","querySelector","id","offsetHeight","offsetTop","parentOffsetHeight","scrollTop","isAbove","isBelow","buffer","scrollTo"],"mappings":";;;;+BAEgBA;;aAAAA;;;6DAFO;gCACG;AACnB,SAASA,yBAAyBC,KAAK,EAAE;IAC5C,MAAM,EAAEC,aAAY,EAAG,GAAGD;IAC1B,MAAME,qBAAqBC,OAAMC,MAAM,CAAC,IAAI;IAC5CD,OAAME,SAAS,CAAC,IAAI;QAChB,IAAIH,mBAAmBI,OAAO,IAAIL,gBAAgBM,IAAAA,yBAAS,KAAI;YAC3D,MAAMC,sBAAsBN,mBAAmBI,OAAO,CAACG,aAAa,CAAC,CAAC,CAAC,EAAER,aAAaS,EAAE,CAAC,CAAC;YAC1F,IAAI,CAACF,qBAAqB;gBACtB;YACJ,CAAC;YACD,MAAM,EAAEG,aAAY,EAAGC,UAAS,EAAG,GAAGJ;YACtC,MAAM,EAAEG,cAAcE,mBAAkB,EAAGC,UAAS,EAAG,GAAGZ,mBAAmBI,OAAO;YACpF,MAAMS,UAAUH,YAAYE;YAC5B,MAAME,UAAUJ,YAAYD,eAAeG,YAAYD;YACvD,+CAA+C;YAC/C,2FAA2F;YAC3F,MAAMI,SAAS;YACf,IAAIF,SAAS;gBACTb,mBAAmBI,OAAO,CAACY,QAAQ,CAAC,GAAGN,YAAYK;YACvD,OAAO,IAAID,SAAS;gBAChBd,mBAAmBI,OAAO,CAACY,QAAQ,CAAC,GAAGN,YAAYC,qBAAqBF,eAAeM;YAC3F,CAAC;QACL,CAAC;IACL,GAAG;QACChB;KACH;IACD,OAAOC;AACX"}
1
+ {"version":3,"sources":["useScrollOptionsIntoView.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '@fluentui/react-utilities';\nexport function useScrollOptionsIntoView(state) {\n const { activeOption } = state;\n const scrollContainerRef = React.useRef(null);\n React.useEffect(()=>{\n if (scrollContainerRef.current && activeOption && canUseDOM()) {\n const activeOptionElement = scrollContainerRef.current.querySelector(`#${activeOption.id}`);\n if (!activeOptionElement) {\n return;\n }\n const { offsetHeight, offsetTop } = activeOptionElement;\n const { offsetHeight: parentOffsetHeight, scrollTop } = scrollContainerRef.current;\n const isAbove = offsetTop < scrollTop;\n const isBelow = offsetTop + offsetHeight > scrollTop + parentOffsetHeight;\n // add a small buffer for general visual nicety\n // it looks slightly better if the option has some space from the top/bottom while arrowing\n const buffer = 2;\n if (isAbove) {\n scrollContainerRef.current.scrollTo(0, offsetTop - buffer);\n } else if (isBelow) {\n scrollContainerRef.current.scrollTo(0, offsetTop - parentOffsetHeight + offsetHeight + buffer);\n }\n }\n }, [\n activeOption\n ]);\n return scrollContainerRef;\n}\n"],"names":["useScrollOptionsIntoView","state","activeOption","scrollContainerRef","React","useRef","useEffect","current","canUseDOM","activeOptionElement","querySelector","id","offsetHeight","offsetTop","parentOffsetHeight","scrollTop","isAbove","isBelow","buffer","scrollTo"],"mappings":";;;;+BAEgBA;;;eAAAA;;;;iEAFO;gCACG;AACnB,SAASA,yBAAyBC,KAAK;IAC1C,MAAM,EAAEC,YAAY,EAAE,GAAGD;IACzB,MAAME,qBAAqBC,OAAMC,MAAM,CAAC;IACxCD,OAAME,SAAS,CAAC;QACZ,IAAIH,mBAAmBI,OAAO,IAAIL,gBAAgBM,IAAAA,yBAAS,KAAI;YAC3D,MAAMC,sBAAsBN,mBAAmBI,OAAO,CAACG,aAAa,CAAC,CAAC,CAAC,EAAER,aAAaS,EAAE,CAAC,CAAC;YAC1F,IAAI,CAACF,qBAAqB;gBACtB;YACJ;YACA,MAAM,EAAEG,YAAY,EAAEC,SAAS,EAAE,GAAGJ;YACpC,MAAM,EAAEG,cAAcE,kBAAkB,EAAEC,SAAS,EAAE,GAAGZ,mBAAmBI,OAAO;YAClF,MAAMS,UAAUH,YAAYE;YAC5B,MAAME,UAAUJ,YAAYD,eAAeG,YAAYD;YACvD,+CAA+C;YAC/C,2FAA2F;YAC3F,MAAMI,SAAS;YACf,IAAIF,SAAS;gBACTb,mBAAmBI,OAAO,CAACY,QAAQ,CAAC,GAAGN,YAAYK;YACvD,OAAO,IAAID,SAAS;gBAChBd,mBAAmBI,OAAO,CAACY,QAAQ,CAAC,GAAGN,YAAYC,qBAAqBF,eAAeM;YAC3F;QACJ;IACJ,GAAG;QACChB;KACH;IACD,OAAOC;AACX"}
@@ -4,18 +4,21 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useSelection", {
6
6
  enumerable: true,
7
- get: ()=>useSelection
7
+ get: function() {
8
+ return useSelection;
9
+ }
8
10
  });
9
11
  const _react = require("react");
10
- const _reactUtilities = require("@fluentui/react-utilities");
12
+ const _reactutilities = require("@fluentui/react-utilities");
11
13
  const useSelection = (props)=>{
12
- const { defaultSelectedOptions , multiselect , onOptionSelect } = props;
13
- const [selectedOptions, setSelectedOptions] = (0, _reactUtilities.useControllableState)({
14
+ const { defaultSelectedOptions, multiselect, onOptionSelect } = props;
15
+ const [selectedOptions, setSelectedOptions] = (0, _reactutilities.useControllableState)({
14
16
  state: props.selectedOptions,
15
17
  defaultState: defaultSelectedOptions,
16
18
  initialState: []
17
19
  });
18
20
  const selectOption = (0, _react.useCallback)((event, option)=>{
21
+ var _onOptionSelect;
19
22
  // if the option is disabled, do nothing
20
23
  if (option.disabled) {
21
24
  return;
@@ -42,7 +45,7 @@ const useSelection = (props)=>{
42
45
  }
43
46
  }
44
47
  setSelectedOptions(newSelection);
45
- onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {
48
+ (_onOptionSelect = onOptionSelect) === null || _onOptionSelect === void 0 ? void 0 : _onOptionSelect(event, {
46
49
  optionValue: option.value,
47
50
  optionText: option.text,
48
51
  selectedOptions: newSelection
@@ -54,8 +57,9 @@ const useSelection = (props)=>{
54
57
  setSelectedOptions
55
58
  ]);
56
59
  const clearSelection = (event)=>{
60
+ var _onOptionSelect;
57
61
  setSelectedOptions([]);
58
- onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {
62
+ (_onOptionSelect = onOptionSelect) === null || _onOptionSelect === void 0 ? void 0 : _onOptionSelect(event, {
59
63
  optionValue: undefined,
60
64
  optionText: undefined,
61
65
  selectedOptions: []
@@ -1 +1 @@
1
- {"version":3,"sources":["useSelection.js"],"sourcesContent":["import { useCallback } from 'react';\nimport { useControllableState } from '@fluentui/react-utilities';\nexport const useSelection = (props)=>{\n const { defaultSelectedOptions , multiselect , onOptionSelect } = props;\n const [selectedOptions, setSelectedOptions] = useControllableState({\n state: props.selectedOptions,\n defaultState: defaultSelectedOptions,\n initialState: []\n });\n const selectOption = useCallback((event, option)=>{\n // if the option is disabled, do nothing\n if (option.disabled) {\n return;\n }\n // for single-select, always return the selected option\n let newSelection = [\n option.value\n ];\n // toggle selected state of the option for multiselect\n if (multiselect) {\n const selectedIndex = selectedOptions.findIndex((o)=>o === option.value);\n if (selectedIndex > -1) {\n // deselect option\n newSelection = [\n ...selectedOptions.slice(0, selectedIndex),\n ...selectedOptions.slice(selectedIndex + 1)\n ];\n } else {\n // select option\n newSelection = [\n ...selectedOptions,\n option.value\n ];\n }\n }\n setSelectedOptions(newSelection);\n onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {\n optionValue: option.value,\n optionText: option.text,\n selectedOptions: newSelection\n });\n }, [\n onOptionSelect,\n multiselect,\n selectedOptions,\n setSelectedOptions\n ]);\n const clearSelection = (event)=>{\n setSelectedOptions([]);\n onOptionSelect === null || onOptionSelect === void 0 ? void 0 : onOptionSelect(event, {\n optionValue: undefined,\n optionText: undefined,\n selectedOptions: []\n });\n };\n return {\n clearSelection,\n selectOption,\n selectedOptions\n };\n};\n"],"names":["useSelection","props","defaultSelectedOptions","multiselect","onOptionSelect","selectedOptions","setSelectedOptions","useControllableState","state","defaultState","initialState","selectOption","useCallback","event","option","disabled","newSelection","value","selectedIndex","findIndex","o","slice","optionValue","optionText","text","clearSelection","undefined"],"mappings":";;;;+BAEaA;;aAAAA;;uBAFe;gCACS;AAC9B,MAAMA,eAAe,CAACC,QAAQ;IACjC,MAAM,EAAEC,uBAAsB,EAAGC,YAAW,EAAGC,eAAc,EAAG,GAAGH;IACnE,MAAM,CAACI,iBAAiBC,mBAAmB,GAAGC,IAAAA,oCAAoB,EAAC;QAC/DC,OAAOP,MAAMI,eAAe;QAC5BI,cAAcP;QACdQ,cAAc,EAAE;IACpB;IACA,MAAMC,eAAeC,IAAAA,kBAAW,EAAC,CAACC,OAAOC,SAAS;QAC9C,wCAAwC;QACxC,IAAIA,OAAOC,QAAQ,EAAE;YACjB;QACJ,CAAC;QACD,uDAAuD;QACvD,IAAIC,eAAe;YACfF,OAAOG,KAAK;SACf;QACD,sDAAsD;QACtD,IAAId,aAAa;YACb,MAAMe,gBAAgBb,gBAAgBc,SAAS,CAAC,CAACC,IAAIA,MAAMN,OAAOG,KAAK;YACvE,IAAIC,gBAAgB,CAAC,GAAG;gBACpB,kBAAkB;gBAClBF,eAAe;uBACRX,gBAAgBgB,KAAK,CAAC,GAAGH;uBACzBb,gBAAgBgB,KAAK,CAACH,gBAAgB;iBAC5C;YACL,OAAO;gBACH,gBAAgB;gBAChBF,eAAe;uBACRX;oBACHS,OAAOG,KAAK;iBACf;YACL,CAAC;QACL,CAAC;QACDX,mBAAmBU;QACnBZ,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeS,OAAO;YAClFS,aAAaR,OAAOG,KAAK;YACzBM,YAAYT,OAAOU,IAAI;YACvBnB,iBAAiBW;QACrB,EAAE;IACN,GAAG;QACCZ;QACAD;QACAE;QACAC;KACH;IACD,MAAMmB,iBAAiB,CAACZ,QAAQ;QAC5BP,mBAAmB,EAAE;QACrBF,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeS,OAAO;YAClFS,aAAaI;YACbH,YAAYG;YACZrB,iBAAiB,EAAE;QACvB,EAAE;IACN;IACA,OAAO;QACHoB;QACAd;QACAN;IACJ;AACJ"}
1
+ {"version":3,"sources":["useSelection.js"],"sourcesContent":["import { useCallback } from 'react';\nimport { useControllableState } from '@fluentui/react-utilities';\nexport const useSelection = (props)=>{\n const { defaultSelectedOptions, multiselect, onOptionSelect } = props;\n const [selectedOptions, setSelectedOptions] = useControllableState({\n state: props.selectedOptions,\n defaultState: defaultSelectedOptions,\n initialState: []\n });\n const selectOption = useCallback((event, option)=>{\n var _onOptionSelect;\n // if the option is disabled, do nothing\n if (option.disabled) {\n return;\n }\n // for single-select, always return the selected option\n let newSelection = [\n option.value\n ];\n // toggle selected state of the option for multiselect\n if (multiselect) {\n const selectedIndex = selectedOptions.findIndex((o)=>o === option.value);\n if (selectedIndex > -1) {\n // deselect option\n newSelection = [\n ...selectedOptions.slice(0, selectedIndex),\n ...selectedOptions.slice(selectedIndex + 1)\n ];\n } else {\n // select option\n newSelection = [\n ...selectedOptions,\n option.value\n ];\n }\n }\n setSelectedOptions(newSelection);\n (_onOptionSelect = onOptionSelect) === null || _onOptionSelect === void 0 ? void 0 : _onOptionSelect(event, {\n optionValue: option.value,\n optionText: option.text,\n selectedOptions: newSelection\n });\n }, [\n onOptionSelect,\n multiselect,\n selectedOptions,\n setSelectedOptions\n ]);\n const clearSelection = (event)=>{\n var _onOptionSelect;\n setSelectedOptions([]);\n (_onOptionSelect = onOptionSelect) === null || _onOptionSelect === void 0 ? void 0 : _onOptionSelect(event, {\n optionValue: undefined,\n optionText: undefined,\n selectedOptions: []\n });\n };\n return {\n clearSelection,\n selectOption,\n selectedOptions\n };\n};\n"],"names":["useSelection","props","defaultSelectedOptions","multiselect","onOptionSelect","selectedOptions","setSelectedOptions","useControllableState","state","defaultState","initialState","selectOption","useCallback","event","option","_onOptionSelect","disabled","newSelection","value","selectedIndex","findIndex","o","slice","optionValue","optionText","text","clearSelection","undefined"],"mappings":";;;;+BAEaA;;;eAAAA;;;uBAFe;gCACS;AAC9B,MAAMA,eAAe,CAACC;IACzB,MAAM,EAAEC,sBAAsB,EAAEC,WAAW,EAAEC,cAAc,EAAE,GAAGH;IAChE,MAAM,CAACI,iBAAiBC,mBAAmB,GAAGC,IAAAA,oCAAoB,EAAC;QAC/DC,OAAOP,MAAMI,eAAe;QAC5BI,cAAcP;QACdQ,cAAc,EAAE;IACpB;IACA,MAAMC,eAAeC,IAAAA,kBAAW,EAAC,CAACC,OAAOC;QACrC,IAAIC;QACJ,wCAAwC;QACxC,IAAID,OAAOE,QAAQ,EAAE;YACjB;QACJ;QACA,uDAAuD;QACvD,IAAIC,eAAe;YACfH,OAAOI,KAAK;SACf;QACD,sDAAsD;QACtD,IAAIf,aAAa;YACb,MAAMgB,gBAAgBd,gBAAgBe,SAAS,CAAC,CAACC,IAAIA,MAAMP,OAAOI,KAAK;YACvE,IAAIC,gBAAgB,CAAC,GAAG;gBACpB,kBAAkB;gBAClBF,eAAe;uBACRZ,gBAAgBiB,KAAK,CAAC,GAAGH;uBACzBd,gBAAgBiB,KAAK,CAACH,gBAAgB;iBAC5C;YACL,OAAO;gBACH,gBAAgB;gBAChBF,eAAe;uBACRZ;oBACHS,OAAOI,KAAK;iBACf;YACL;QACJ;QACAZ,mBAAmBW;QAClBF,CAAAA,kBAAkBX,cAAa,MAAO,QAAQW,oBAAoB,KAAK,IAAI,KAAK,IAAIA,gBAAgBF,OAAO;YACxGU,aAAaT,OAAOI,KAAK;YACzBM,YAAYV,OAAOW,IAAI;YACvBpB,iBAAiBY;QACrB;IACJ,GAAG;QACCb;QACAD;QACAE;QACAC;KACH;IACD,MAAMoB,iBAAiB,CAACb;QACpB,IAAIE;QACJT,mBAAmB,EAAE;QACpBS,CAAAA,kBAAkBX,cAAa,MAAO,QAAQW,oBAAoB,KAAK,IAAI,KAAK,IAAIA,gBAAgBF,OAAO;YACxGU,aAAaI;YACbH,YAAYG;YACZtB,iBAAiB,EAAE;QACvB;IACJ;IACA,OAAO;QACHqB;QACAf;QACAN;IACJ;AACJ"}
@@ -4,19 +4,22 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useTriggerListboxSlots", {
6
6
  enumerable: true,
7
- get: ()=>useTriggerListboxSlots
7
+ get: function() {
8
+ return useTriggerListboxSlots;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
- const _reactUtilities = require("@fluentui/react-utilities");
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
13
+ const _reactutilities = require("@fluentui/react-utilities");
12
14
  const _dropdownKeyActions = require("../utils/dropdownKeyActions");
13
15
  function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
14
- const { multiselect } = props;
15
- const { activeOption , getCount , getIndexOfId , getOptionAtIndex , ignoreNextBlur , open , selectOption , setActiveOption , setFocusVisible , setHasFocus , setOpen } = state;
16
+ var _listboxSlot, _activeOption, _triggerSlot, _listbox, _listbox1, _listbox2;
17
+ const { multiselect } = props;
18
+ const { activeOption, getCount, getIndexOfId, getOptionAtIndex, ignoreNextBlur, open, selectOption, setActiveOption, setFocusVisible, setHasFocus, setOpen } = state;
16
19
  // handle trigger focus/blur
17
20
  const triggerRef = _react.useRef(null);
18
21
  // resolve listbox shorthand props
19
- const listboxId = (0, _reactUtilities.useId)('fluent-listbox', listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id);
22
+ const listboxId = (0, _reactutilities.useId)('fluent-listbox', (_listboxSlot = listboxSlot) === null || _listboxSlot === void 0 ? void 0 : _listboxSlot.id);
20
23
  const listbox = listboxSlot && {
21
24
  id: listboxId,
22
25
  multiselect,
@@ -26,28 +29,28 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
26
29
  // resolve trigger shorthand props
27
30
  const trigger = {
28
31
  'aria-expanded': open,
29
- 'aria-activedescendant': open ? activeOption === null || activeOption === void 0 ? void 0 : activeOption.id : undefined,
32
+ 'aria-activedescendant': open ? (_activeOption = activeOption) === null || _activeOption === void 0 ? void 0 : _activeOption.id : undefined,
30
33
  role: 'combobox',
31
34
  ...triggerSlot,
32
35
  // explicitly type the ref as an intersection here to prevent type errors
33
36
  // since the `children` prop has mutually incompatible types between input/button
34
37
  // functionally both ref and triggerRef will always be the same element type
35
- ref: (0, _reactUtilities.useMergedRefs)(ref, triggerSlot === null || triggerSlot === void 0 ? void 0 : triggerSlot.ref, triggerRef)
38
+ ref: (0, _reactutilities.useMergedRefs)(ref, (_triggerSlot = triggerSlot) === null || _triggerSlot === void 0 ? void 0 : _triggerSlot.ref, triggerRef)
36
39
  };
37
40
  /*
38
41
  * Handle focus when clicking the listbox popup:
39
42
  * 1. Move focus back to the button/input when the listbox is clicked (otherwise it goes to body)
40
43
  * 2. Do not close the listbox on button/input blur when clicking into the listbox
41
- */ const listboxOnClick = (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)((event)=>{
44
+ */ const listboxOnClick = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
42
45
  var _triggerRef_current;
43
46
  (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
44
- }, listbox === null || listbox === void 0 ? void 0 : listbox.onClick));
45
- const listboxOnMouseOver = (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)((event)=>{
47
+ }, (_listbox = listbox) === null || _listbox === void 0 ? void 0 : _listbox.onClick));
48
+ const listboxOnMouseOver = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
46
49
  setFocusVisible(false);
47
- }, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseOver));
48
- const listboxOnMouseDown = (0, _reactUtilities.useEventCallback)((0, _reactUtilities.mergeCallbacks)((event)=>{
50
+ }, (_listbox1 = listbox) === null || _listbox1 === void 0 ? void 0 : _listbox1.onMouseOver));
51
+ const listboxOnMouseDown = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)((event)=>{
49
52
  ignoreNextBlur.current = true;
50
- }, listbox === null || listbox === void 0 ? void 0 : listbox.onMouseDown));
53
+ }, (_listbox2 = listbox) === null || _listbox2 === void 0 ? void 0 : _listbox2.onMouseDown));
51
54
  // listbox is nullable, only add event handlers if it exists
52
55
  if (listbox) {
53
56
  listbox.onClick = listboxOnClick;
@@ -55,21 +58,21 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
55
58
  listbox.onMouseDown = listboxOnMouseDown;
56
59
  }
57
60
  // the trigger should open/close the popup on click or blur
58
- trigger.onBlur = (0, _reactUtilities.mergeCallbacks)((event)=>{
61
+ trigger.onBlur = (0, _reactutilities.mergeCallbacks)((event)=>{
59
62
  if (!ignoreNextBlur.current) {
60
63
  setOpen(event, false);
61
64
  }
62
65
  ignoreNextBlur.current = false;
63
66
  setHasFocus(false);
64
67
  }, trigger.onBlur);
65
- trigger.onClick = (0, _reactUtilities.mergeCallbacks)((event)=>{
68
+ trigger.onClick = (0, _reactutilities.mergeCallbacks)((event)=>{
66
69
  setOpen(event, !open);
67
70
  }, trigger.onClick);
68
- trigger.onFocus = (0, _reactUtilities.mergeCallbacks)((event)=>{
71
+ trigger.onFocus = (0, _reactutilities.mergeCallbacks)((event)=>{
69
72
  setHasFocus(true);
70
73
  }, trigger.onFocus);
71
74
  // handle combobox keyboard interaction
72
- trigger.onKeyDown = (0, _reactUtilities.mergeCallbacks)((event)=>{
75
+ trigger.onKeyDown = (0, _reactutilities.mergeCallbacks)((event)=>{
73
76
  const action = (0, _dropdownKeyActions.getDropdownActionFromKey)(event, {
74
77
  open,
75
78
  multiselect
@@ -90,7 +93,8 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
90
93
  setOpen(event, false);
91
94
  break;
92
95
  case 'CloseSelect':
93
- !multiselect && !(activeOption === null || activeOption === void 0 ? void 0 : activeOption.disabled) && setOpen(event, false);
96
+ var _activeOption;
97
+ !multiselect && !((_activeOption = activeOption) === null || _activeOption === void 0 ? void 0 : _activeOption.disabled) && setOpen(event, false);
94
98
  // fallthrough
95
99
  case 'Select':
96
100
  activeOption && selectOption(event, activeOption);
@@ -109,7 +113,7 @@ function useTriggerListboxSlots(props, state, ref, triggerSlot, listboxSlot) {
109
113
  setFocusVisible(true);
110
114
  }
111
115
  }, trigger.onKeyDown);
112
- trigger.onMouseOver = (0, _reactUtilities.mergeCallbacks)((event)=>{
116
+ trigger.onMouseOver = (0, _reactutilities.mergeCallbacks)((event)=>{
113
117
  setFocusVisible(false);
114
118
  }, trigger.onMouseOver);
115
119
  return [
@@ -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;;aAAAA;;;6DAPG;gCACgD;oCACV;AAKlD,SAASA,uBAAuBC,KAAK,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,EAAEC,WAAW,EAAE;IACpF,MAAM,EAAEC,Y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IAAI;gBACnB,KAAM;YACV,KAAK;gBACD,wEAAwE;gBACxEA,MAAMkB,eAAe;gBACrBlB,MAAMiB,cAAc;gBACpBjC,QAAQgB,OAAO,KAAK;gBACpB,KAAM;YACV,KAAK;gBACD,CAAC3B,eAAe,CAAEC,CAAAA,iBAAiB,IAAI,IAAIA,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAa6C,QAAQ,AAAD,KAAMnC,QAAQgB,OAAO,KAAK;YAChI,cAAc;YACd,KAAK;gBACD1B,gBAAgBM,aAAaoB,OAAO1B;gBACpC0B,MAAMiB,cAAc;gBACpB,KAAM;YACV,KAAK;gBACD,CAAC5C,eAAeC,gBAAgBM,aAAaoB,OAAO1B;gBACpD,KAAM;YACV;gBACI0C,WAAWI,IAAAA,sCAAkB,EAACR,QAAQG,aAAaD;QAC3D;QACA,IAAIE,aAAaD,aAAa;YAC1B,mEAAmE;YACnEf,MAAMiB,cAAc;YACpBpC,gBAAgBJ,iBAAiBuC;YACjClC,gBAAgB,IAAI;QACxB,CAAC;IACL,GAAGY,QAAQiB,SAAS;IACpBjB,QAAQY,WAAW,GAAGP,IAAAA,8BAAc,EAAC,CAACC,QAAQ;QAC1ClB,gBAAgB,KAAK;IACzB,GAAGY,QAAQY,WAAW;IACtB,OAAO;QACHZ;QACAH;KACH;AACL"}
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 var _listboxSlot, _activeOption, _triggerSlot, _listbox, _listbox1, _listbox2;\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 = 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 = 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 = 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 = listbox) === null || _listbox === void 0 ? void 0 : _listbox.onClick));\n const listboxOnMouseOver = useEventCallback(mergeCallbacks((event)=>{\n setFocusVisible(false);\n }, (_listbox1 = listbox) === null || _listbox1 === void 0 ? void 0 : _listbox1.onMouseOver));\n const listboxOnMouseDown = useEventCallback(mergeCallbacks((event)=>{\n ignoreNextBlur.current = true;\n }, (_listbox2 = listbox) === null || _listbox2 === void 0 ? void 0 : _listbox2.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 var _activeOption;\n !multiselect && !((_activeOption = 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","_listboxSlot","_activeOption","_triggerSlot","_listbox","_listbox1","_listbox2","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,IAAIC,cAAcC,eAAeC,cAAcC,UAAUC,WAAWC;IACpE,MAAM,EAAEC,WAAW,EAAE,GAAGX;IACxB,MAAM,EAAEY,YAAY,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,gBAAgB,EAAEC,cAAc,EAAEC,IAAI,EAAEC,YAAY,EAAEC,eAAe,EAAEC,eAAe,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAAGrB;IAC/J,4BAA4B;IAC5B,MAAMsB,aAAaC,OAAMC,MAAM,CAAC;IAChC,kCAAkC;IAClC,MAAMC,YAAYC,IAAAA,qBAAK,EAAC,kBAAkB,AAACtB,CAAAA,eAAeD,WAAU,MAAO,QAAQC,iBAAiB,KAAK,IAAI,KAAK,IAAIA,aAAauB,EAAE;IACrI,MAAMC,UAAUzB,eAAe;QAC3BwB,IAAIF;QACJf;QACAmB,UAAUC;QACV,GAAG3B,WAAW;IAClB;IACA,kCAAkC;IAClC,MAAM4B,UAAU;QACZ,iBAAiBf;QACjB,yBAAyBA,OAAO,AAACX,CAAAA,gBAAgBM,YAAW,MAAO,QAAQN,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcsB,EAAE,GAAGG;QAClIE,MAAM;QACN,GAAG9B,WAAW;QACd,yEAAyE;QACzE,iFAAiF;QACjF,4EAA4E;QAC5ED,KAAKgC,IAAAA,6BAAa,EAAChC,KAAK,AAACK,CAAAA,eAAeJ,W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,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-combobox",
3
- "version": "9.5.8",
3
+ "version": "9.5.10",
4
4
  "description": "Fluent UI React Combobox component",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -33,24 +33,24 @@
33
33
  "@fluentui/scripts-tasks": "*"
34
34
  },
35
35
  "dependencies": {
36
- "@fluentui/keyboard-keys": "^9.0.3",
37
- "@fluentui/react-context-selector": "^9.1.30",
38
- "@fluentui/react-field": "^9.1.21",
36
+ "@fluentui/keyboard-keys": "^9.0.4",
37
+ "@fluentui/react-context-selector": "^9.1.32",
38
+ "@fluentui/react-field": "^9.1.23",
39
39
  "@fluentui/react-icons": "^2.0.207",
40
- "@fluentui/react-jsx-runtime": "^9.0.2",
41
- "@fluentui/react-portal": "^9.3.9",
42
- "@fluentui/react-positioning": "^9.9.7",
43
- "@fluentui/react-shared-contexts": "^9.7.2",
44
- "@fluentui/react-theme": "^9.1.11",
45
- "@fluentui/react-utilities": "^9.12.0",
40
+ "@fluentui/react-jsx-runtime": "^9.0.4",
41
+ "@fluentui/react-portal": "^9.3.11",
42
+ "@fluentui/react-positioning": "^9.9.9",
43
+ "@fluentui/react-shared-contexts": "^9.7.3",
44
+ "@fluentui/react-theme": "^9.1.12",
45
+ "@fluentui/react-utilities": "^9.13.1",
46
46
  "@griffel/react": "^1.5.14",
47
- "@swc/helpers": "^0.4.14"
47
+ "@swc/helpers": "^0.5.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "@types/react": ">=16.8.0 <19.0.0",
51
- "@types/react-dom": ">=16.8.0 <19.0.0",
52
- "react": ">=16.8.0 <19.0.0",
53
- "react-dom": ">=16.8.0 <19.0.0",
50
+ "@types/react": ">=16.14.0 <19.0.0",
51
+ "@types/react-dom": ">=16.14.0 <19.0.0",
52
+ "react": ">=16.14.0 <19.0.0",
53
+ "react-dom": ">=16.14.0 <19.0.0",
54
54
  "scheduler": "^0.19.0 || ^0.20.0"
55
55
  },
56
56
  "beachball": {