@fluentui/react-combobox 9.0.0-beta.19 → 9.0.0-beta.21

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 (166) hide show
  1. package/CHANGELOG.json +117 -1
  2. package/CHANGELOG.md +32 -2
  3. package/lib/components/Combobox/Combobox.js +0 -1
  4. package/lib/components/Combobox/Combobox.js.map +1 -1
  5. package/lib/components/Combobox/renderCombobox.js +10 -6
  6. package/lib/components/Combobox/renderCombobox.js.map +1 -1
  7. package/lib/components/Combobox/useCombobox.js +41 -53
  8. package/lib/components/Combobox/useCombobox.js.map +1 -1
  9. package/lib/components/Combobox/useComboboxStyles.js +209 -217
  10. package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
  11. package/lib/components/ComboboxField/ComboboxField.js.map +1 -1
  12. package/lib/components/Dropdown/Dropdown.js +0 -1
  13. package/lib/components/Dropdown/Dropdown.js.map +1 -1
  14. package/lib/components/Dropdown/renderDropdown.js +10 -6
  15. package/lib/components/Dropdown/renderDropdown.js.map +1 -1
  16. package/lib/components/Dropdown/useDropdown.js +20 -32
  17. package/lib/components/Dropdown/useDropdown.js.map +1 -1
  18. package/lib/components/Dropdown/useDropdownStyles.js +199 -206
  19. package/lib/components/Dropdown/useDropdownStyles.js.map +1 -1
  20. package/lib/components/Listbox/Listbox.js +0 -1
  21. package/lib/components/Listbox/Listbox.js.map +1 -1
  22. package/lib/components/Listbox/renderListbox.js +2 -2
  23. package/lib/components/Listbox/renderListbox.js.map +1 -1
  24. package/lib/components/Listbox/useListbox.js +6 -13
  25. package/lib/components/Listbox/useListbox.js.map +1 -1
  26. package/lib/components/Listbox/useListboxStyles.js +18 -21
  27. package/lib/components/Listbox/useListboxStyles.js.map +1 -1
  28. package/lib/components/Option/Option.js +0 -1
  29. package/lib/components/Option/Option.js.map +1 -1
  30. package/lib/components/Option/renderOption.js +4 -3
  31. package/lib/components/Option/renderOption.js.map +1 -1
  32. package/lib/components/Option/useOption.js +20 -32
  33. package/lib/components/Option/useOption.js.map +1 -1
  34. package/lib/components/Option/useOptionStyles.js +74 -79
  35. package/lib/components/Option/useOptionStyles.js.map +1 -1
  36. package/lib/components/OptionGroup/OptionGroup.js +0 -1
  37. package/lib/components/OptionGroup/OptionGroup.js.map +1 -1
  38. package/lib/components/OptionGroup/renderOptionGroup.js +4 -3
  39. package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
  40. package/lib/components/OptionGroup/useOptionGroup.js +0 -1
  41. package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
  42. package/lib/components/OptionGroup/useOptionGroupStyles.js +29 -34
  43. package/lib/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
  44. package/lib/contexts/ComboboxContext.js +8 -11
  45. package/lib/contexts/ComboboxContext.js.map +1 -1
  46. package/lib/contexts/ListboxContext.js +6 -9
  47. package/lib/contexts/ListboxContext.js.map +1 -1
  48. package/lib/contexts/useComboboxContextValues.js.map +1 -1
  49. package/lib/contexts/useListboxContextValues.js +2 -2
  50. package/lib/contexts/useListboxContextValues.js.map +1 -1
  51. package/lib/index.js.map +1 -1
  52. package/lib/utils/dropdownKeyActions.js +12 -33
  53. package/lib/utils/dropdownKeyActions.js.map +1 -1
  54. package/lib/utils/internalTokens.js.map +1 -1
  55. package/lib/utils/useComboboxBaseState.js +23 -27
  56. package/lib/utils/useComboboxBaseState.js.map +1 -1
  57. package/lib/utils/useComboboxPopup.js +6 -4
  58. package/lib/utils/useComboboxPopup.js.map +1 -1
  59. package/lib/utils/useOptionCollection.js +10 -20
  60. package/lib/utils/useOptionCollection.js.map +1 -1
  61. package/lib/utils/useScrollOptionsIntoView.js +2 -5
  62. package/lib/utils/useScrollOptionsIntoView.js.map +1 -1
  63. package/lib/utils/useSelection.js +7 -12
  64. package/lib/utils/useSelection.js.map +1 -1
  65. package/lib/utils/useTriggerListboxSlots.js +31 -39
  66. package/lib/utils/useTriggerListboxSlots.js.map +1 -1
  67. package/lib-commonjs/Combobox.js +0 -2
  68. package/lib-commonjs/Combobox.js.map +1 -1
  69. package/lib-commonjs/ComboboxField.js +0 -2
  70. package/lib-commonjs/ComboboxField.js.map +1 -1
  71. package/lib-commonjs/Dropdown.js +0 -2
  72. package/lib-commonjs/Dropdown.js.map +1 -1
  73. package/lib-commonjs/Listbox.js +0 -2
  74. package/lib-commonjs/Listbox.js.map +1 -1
  75. package/lib-commonjs/Option.js +0 -2
  76. package/lib-commonjs/Option.js.map +1 -1
  77. package/lib-commonjs/OptionGroup.js +0 -2
  78. package/lib-commonjs/OptionGroup.js.map +1 -1
  79. package/lib-commonjs/components/Combobox/Combobox.js +0 -7
  80. package/lib-commonjs/components/Combobox/Combobox.js.map +1 -1
  81. package/lib-commonjs/components/Combobox/Combobox.types.js.map +1 -1
  82. package/lib-commonjs/components/Combobox/index.js +0 -6
  83. package/lib-commonjs/components/Combobox/index.js.map +1 -1
  84. package/lib-commonjs/components/Combobox/renderCombobox.js +10 -12
  85. package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
  86. package/lib-commonjs/components/Combobox/useCombobox.js +41 -63
  87. package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
  88. package/lib-commonjs/components/Combobox/useComboboxStyles.js +209 -222
  89. package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
  90. package/lib-commonjs/components/ComboboxField/ComboboxField.js +0 -4
  91. package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -1
  92. package/lib-commonjs/components/ComboboxField/index.js +0 -2
  93. package/lib-commonjs/components/ComboboxField/index.js.map +1 -1
  94. package/lib-commonjs/components/Dropdown/Dropdown.js +0 -7
  95. package/lib-commonjs/components/Dropdown/Dropdown.js.map +1 -1
  96. package/lib-commonjs/components/Dropdown/Dropdown.types.js.map +1 -1
  97. package/lib-commonjs/components/Dropdown/index.js +0 -6
  98. package/lib-commonjs/components/Dropdown/index.js.map +1 -1
  99. package/lib-commonjs/components/Dropdown/renderDropdown.js +10 -12
  100. package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
  101. package/lib-commonjs/components/Dropdown/useDropdown.js +20 -43
  102. package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
  103. package/lib-commonjs/components/Dropdown/useDropdownStyles.js +199 -211
  104. package/lib-commonjs/components/Dropdown/useDropdownStyles.js.map +1 -1
  105. package/lib-commonjs/components/Listbox/Listbox.js +0 -7
  106. package/lib-commonjs/components/Listbox/Listbox.js.map +1 -1
  107. package/lib-commonjs/components/Listbox/Listbox.types.js.map +1 -1
  108. package/lib-commonjs/components/Listbox/index.js +0 -6
  109. package/lib-commonjs/components/Listbox/index.js.map +1 -1
  110. package/lib-commonjs/components/Listbox/renderListbox.js +2 -7
  111. package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
  112. package/lib-commonjs/components/Listbox/useListbox.js +6 -23
  113. package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
  114. package/lib-commonjs/components/Listbox/useListboxStyles.js +18 -25
  115. package/lib-commonjs/components/Listbox/useListboxStyles.js.map +1 -1
  116. package/lib-commonjs/components/Option/Option.js +0 -6
  117. package/lib-commonjs/components/Option/Option.js.map +1 -1
  118. package/lib-commonjs/components/Option/Option.types.js.map +1 -1
  119. package/lib-commonjs/components/Option/index.js +0 -6
  120. package/lib-commonjs/components/Option/index.js.map +1 -1
  121. package/lib-commonjs/components/Option/renderOption.js +4 -7
  122. package/lib-commonjs/components/Option/renderOption.js.map +1 -1
  123. package/lib-commonjs/components/Option/useOption.js +20 -39
  124. package/lib-commonjs/components/Option/useOption.js.map +1 -1
  125. package/lib-commonjs/components/Option/useOptionStyles.js +74 -83
  126. package/lib-commonjs/components/Option/useOptionStyles.js.map +1 -1
  127. package/lib-commonjs/components/OptionGroup/OptionGroup.js +0 -6
  128. package/lib-commonjs/components/OptionGroup/OptionGroup.js.map +1 -1
  129. package/lib-commonjs/components/OptionGroup/OptionGroup.types.js.map +1 -1
  130. package/lib-commonjs/components/OptionGroup/index.js +0 -6
  131. package/lib-commonjs/components/OptionGroup/index.js.map +1 -1
  132. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js +4 -7
  133. package/lib-commonjs/components/OptionGroup/renderOptionGroup.js.map +1 -1
  134. package/lib-commonjs/components/OptionGroup/useOptionGroup.js +0 -4
  135. package/lib-commonjs/components/OptionGroup/useOptionGroup.js.map +1 -1
  136. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js +29 -38
  137. package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
  138. package/lib-commonjs/contexts/ComboboxContext.js +8 -13
  139. package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
  140. package/lib-commonjs/contexts/ListboxContext.js +6 -11
  141. package/lib-commonjs/contexts/ListboxContext.js.map +1 -1
  142. package/lib-commonjs/contexts/useComboboxContextValues.js +0 -2
  143. package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
  144. package/lib-commonjs/contexts/useListboxContextValues.js +2 -6
  145. package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
  146. package/lib-commonjs/index.js +0 -20
  147. package/lib-commonjs/index.js.map +1 -1
  148. package/lib-commonjs/utils/ComboboxBase.types.js.map +1 -1
  149. package/lib-commonjs/utils/OptionCollection.types.js.map +1 -1
  150. package/lib-commonjs/utils/Selection.types.js.map +1 -1
  151. package/lib-commonjs/utils/dropdownKeyActions.js +12 -37
  152. package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
  153. package/lib-commonjs/utils/internalTokens.js.map +1 -1
  154. package/lib-commonjs/utils/useComboboxBaseState.js +23 -33
  155. package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
  156. package/lib-commonjs/utils/useComboboxPopup.js +6 -8
  157. package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
  158. package/lib-commonjs/utils/useOptionCollection.js +10 -23
  159. package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
  160. package/lib-commonjs/utils/useScrollOptionsIntoView.js +2 -9
  161. package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -1
  162. package/lib-commonjs/utils/useSelection.js +7 -15
  163. package/lib-commonjs/utils/useSelection.js.map +1 -1
  164. package/lib-commonjs/utils/useTriggerListboxSlots.js +30 -43
  165. package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
  166. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-combobox/src/components/Combobox/useComboboxStyles.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAEA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,4BAAA,CAAA;;AAGa,OAAA,CAAA,kBAAA,GAAoD;EAC/D,IAAI,EAAE,cADyD;EAE/D,KAAK,EAAE,qBAFwD;EAG/D,UAAU,EAAE,0BAHmD;EAI/D,OAAO,EAAE;AAJsD,CAApD,C,CAOb;AACA;;AACA,MAAM,YAAY,GAAG;EACnB,KAAK,EAAE,MADY;EAEnB,MAAM,EAAE,MAFW;EAGnB,KAAK,EAAE;AAHY,CAArB;AAMA;;AAEG;;AACH,MAAM,SAAS,gBAAG,OAAA,SAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAA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I,KAAK,CAAC,UAAV,EAAsB;IACpB,KAAK,CAAC,UAAN,CAAiB,SAAjB,GAA6B,OAAA,CAAA,YAAA,CAC3B,OAAA,CAAA,kBAAA,CAAmB,UADQ,EAE3B,UAAU,CAAC,IAFgB,EAG3B,UAAU,CAAC,IAAD,CAHiB,EAI3B,QAAQ,IAAI,UAAU,CAAC,QAJI,EAK3B,KAAK,CAAC,UAAN,CAAiB,SALU,CAA7B;EAOD;;EAED,OAAO,KAAP;AACD,CAhDM;;AAAM,OAAA,CAAA,0BAAA,GAA0B,0BAA1B","sourcesContent":["import { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { iconSizes } from '../../utils/internalTokens';\nimport type { ComboboxSlots, ComboboxState } from './Combobox.types';\n\nexport const comboboxClassNames: SlotClassNames<ComboboxSlots> = {\n root: 'fui-Combobox',\n input: 'fui-Combobox__input',\n expandIcon: 'fui-Combobox__expandIcon',\n listbox: 'fui-Combobox__listbox',\n};\n\n// Matches internal heights for Select and Input, but there are no theme variables for these\n// field heights are 2px less than other controls, since the border is on the parent element.\nconst fieldHeights = {\n small: '22px',\n medium: '30px',\n large: '38px',\n};\n\n/**\n * Styles for Combobox\n */\nconst useStyles = makeStyles({\n root: {\n alignItems: 'center',\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n boxSizing: 'border-box',\n columnGap: tokens.spacingHorizontalXXS,\n display: 'inline-grid',\n gridTemplateColumns: '1fr auto',\n justifyContent: 'space-between',\n minWidth: '250px',\n position: 'relative',\n\n // windows high contrast mode focus indicator\n ':focus-within': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: 'transparent',\n },\n\n // bottom focus border, shared with Input, Select, and SpinButton\n '::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n left: '-1px',\n bottom: '-1px',\n right: '-1px',\n height: `max(2px, ${tokens.borderRadiusMedium})`,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderBottomRightRadius: tokens.borderRadiusMedium,\n ...shorthands.borderBottom(tokens.strokeWidthThick, 'solid', tokens.colorCompoundBrandStroke),\n clipPath: 'inset(calc(100% - 2px) 0 0 0)',\n transform: 'scaleX(0)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationUltraFast,\n transitionDelay: tokens.curveAccelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within::after': {\n transform: 'scaleX(1)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationNormal,\n transitionDelay: tokens.curveDecelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within:active::after': {\n borderBottomColor: tokens.colorCompoundBrandStrokePressed,\n },\n },\n\n listbox: {},\n\n listboxCollapsed: {\n display: 'none',\n },\n\n // size variants\n small: {\n paddingRight: tokens.spacingHorizontalSNudge,\n },\n medium: {\n paddingRight: tokens.spacingHorizontalMNudge,\n },\n large: {\n columnGap: tokens.spacingHorizontalSNudge,\n paddingRight: tokens.spacingHorizontalM,\n },\n\n // appearance variants\n outline: {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke1),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n outlineInteractive: {\n '&:hover': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Hover),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n '&:active': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n },\n underline: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStrokeAccessible),\n ...shorthands.borderRadius(0),\n },\n 'filled-lighter': {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n 'filled-darker': {\n backgroundColor: tokens.colorNeutralBackground3,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n invalid: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n ...shorthands.borderColor(tokens.colorPaletteRedBorder2),\n },\n },\n invalidUnderline: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n borderBottomColor: tokens.colorPaletteRedBorder2,\n },\n },\n\n disabled: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n '@media (forced-colors: active)': {\n ...shorthands.borderColor('GrayText'),\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n input: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.border('0'),\n color: tokens.colorNeutralForeground1,\n fontFamily: tokens.fontFamilyBase,\n\n '&:focus': {\n outlineStyle: 'none',\n },\n\n '&::placeholder': {\n color: tokens.colorNeutralForeground4,\n opacity: 1,\n },\n },\n\n // size variants\n small: {\n height: fieldHeights.small,\n ...typographyStyles.caption1,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalSNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n medium: {\n height: fieldHeights.medium,\n ...typographyStyles.body1,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalMNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n large: {\n height: fieldHeights.large,\n ...typographyStyles.body2,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalM} + ${tokens.spacingHorizontalSNudge})`),\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n backgroundColor: tokens.colorTransparentBackground,\n cursor: 'not-allowed',\n '::placeholder': {\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n});\n\nconst useIconStyles = makeStyles({\n icon: {\n boxSizing: 'border-box',\n color: tokens.colorNeutralStrokeAccessible,\n display: 'block',\n fontSize: tokens.fontSizeBase500,\n\n // the SVG must have display: block for accurate positioning\n // otherwise an extra inline space is inserted after the svg element\n '& svg': {\n display: 'block',\n },\n },\n\n // icon size variants\n small: {\n fontSize: iconSizes.small,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n medium: {\n fontSize: iconSizes.medium,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n large: {\n fontSize: iconSizes.large,\n marginLeft: tokens.spacingHorizontalSNudge,\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n\n/**\n * Apply styling to the Combobox slots based on the state\n */\nexport const useComboboxStyles_unstable = (state: ComboboxState): ComboboxState => {\n const { appearance, open, size } = state;\n const invalid = `${state.input['aria-invalid']}` === 'true';\n const disabled = state.input.disabled;\n const styles = useStyles();\n const iconStyles = useIconStyles();\n const inputStyles = useInputStyles();\n\n state.root.className = mergeClasses(\n comboboxClassNames.root,\n styles.root,\n styles[appearance],\n styles[size],\n !disabled && appearance === 'outline' && styles.outlineInteractive,\n invalid && appearance !== 'underline' && styles.invalid,\n invalid && appearance === 'underline' && styles.invalidUnderline,\n disabled && styles.disabled,\n state.root.className,\n );\n\n state.input.className = mergeClasses(\n comboboxClassNames.input,\n inputStyles.input,\n inputStyles[size],\n disabled && inputStyles.disabled,\n state.input.className,\n );\n\n if (state.listbox) {\n state.listbox.className = mergeClasses(\n comboboxClassNames.listbox,\n styles.listbox,\n !open && styles.listboxCollapsed,\n state.listbox.className,\n );\n }\n\n if (state.expandIcon) {\n state.expandIcon.className = mergeClasses(\n comboboxClassNames.expandIcon,\n iconStyles.icon,\n iconStyles[size],\n disabled && iconStyles.disabled,\n state.expandIcon.className,\n );\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAEA;AACA;AAGaA,0BAAkB,GAAkC;EAC/DC,IAAI,EAAE,cA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UAAU,KAAK,WAAW,IAAIK,MAAM,CAACF,OAAO,EACvDA,OAAO,IAAIH,UAAU,KAAK,WAAW,IAAIK,MAAM,CAACK,gBAAgB,EAChEN,QAAQ,IAAIC,MAAM,CAACD,QAAQ,EAC3BL,KAAK,CAACb,IAAI,CAACsB,SAAS,CACrB;EAEDT,KAAK,CAACZ,KAAK,CAACqB,SAAS,GAAGb,oBAAY,CAClCV,0BAAkB,CAACE,KAAK,EACxBoB,WAAW,CAACpB,KAAK,EACjBoB,WAAW,CAACL,IAAI,CAAC,EACjBE,QAAQ,IAAIG,WAAW,CAACH,QAAQ,EAChCL,KAAK,CAACZ,KAAK,CAACqB,SAAS,CACtB;EAED,IAAIT,KAAK,CAACV,OAAO,EAAE;IACjBU,KAAK,CAACV,OAAO,CAACmB,SAAS,GAAGb,oBAAY,CACpCV,0BAAkB,CAACI,OAAO,EAC1BgB,MAAM,CAAChB,OAAO,EACd,CAACY,IAAI,IAAII,MAAM,CAACM,gBAAgB,EAChCZ,KAAK,CAACV,OAAO,CAACmB,SAAS,CACxB;;EAGH,IAAIT,KAAK,CAACX,UAAU,EAAE;IACpBW,KAAK,CAACX,UAAU,CAACoB,SAAS,GAAGb,oBAAY,CACvCV,0BAAkB,CAACG,UAAU,EAC7BkB,UAAU,CAACM,IAAI,EACfN,UAAU,CAACJ,IAAI,CAAC,EAChBE,QAAQ,IAAIE,UAAU,CAACF,QAAQ,EAC/BL,KAAK,CAACX,UAAU,CAACoB,SAAS,CAC3B;;EAGH,OAAOT,KAAK;AACd,CAAC;AAhDYd,kCAA0B","names":["exports","root","input","expandIcon","listbox","fieldHeights","small","medium","large","useStyles","react_1","useInputStyles","useIconStyles","useComboboxStyles_unstable","state","appearance","open","size","invalid","disabled","styles","iconStyles","inputStyles","className","outlineInteractive","invalidUnderline","listboxCollapsed","icon"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Combobox/useComboboxStyles.ts"],"sourcesContent":["import { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { iconSizes } from '../../utils/internalTokens';\nimport type { ComboboxSlots, ComboboxState } from './Combobox.types';\n\nexport const comboboxClassNames: SlotClassNames<ComboboxSlots> = {\n root: 'fui-Combobox',\n input: 'fui-Combobox__input',\n expandIcon: 'fui-Combobox__expandIcon',\n listbox: 'fui-Combobox__listbox',\n};\n\n// Matches internal heights for Select and Input, but there are no theme variables for these\n// field heights are 2px less than other controls, since the border is on the parent element.\nconst fieldHeights = {\n small: '22px',\n medium: '30px',\n large: '38px',\n};\n\n/**\n * Styles for Combobox\n */\nconst useStyles = makeStyles({\n root: {\n alignItems: 'center',\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n boxSizing: 'border-box',\n columnGap: tokens.spacingHorizontalXXS,\n display: 'inline-grid',\n gridTemplateColumns: '1fr auto',\n justifyContent: 'space-between',\n minWidth: '250px',\n position: 'relative',\n\n // windows high contrast mode focus indicator\n ':focus-within': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: 'transparent',\n },\n\n // bottom focus border, shared with Input, Select, and SpinButton\n '::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n left: '-1px',\n bottom: '-1px',\n right: '-1px',\n height: `max(2px, ${tokens.borderRadiusMedium})`,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderBottomRightRadius: tokens.borderRadiusMedium,\n ...shorthands.borderBottom(tokens.strokeWidthThick, 'solid', tokens.colorCompoundBrandStroke),\n clipPath: 'inset(calc(100% - 2px) 0 0 0)',\n transform: 'scaleX(0)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationUltraFast,\n transitionDelay: tokens.curveAccelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within::after': {\n transform: 'scaleX(1)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationNormal,\n transitionDelay: tokens.curveDecelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within:active::after': {\n borderBottomColor: tokens.colorCompoundBrandStrokePressed,\n },\n },\n\n listbox: {},\n\n listboxCollapsed: {\n display: 'none',\n },\n\n // size variants\n small: {\n paddingRight: tokens.spacingHorizontalSNudge,\n },\n medium: {\n paddingRight: tokens.spacingHorizontalMNudge,\n },\n large: {\n columnGap: tokens.spacingHorizontalSNudge,\n paddingRight: tokens.spacingHorizontalM,\n },\n\n // appearance variants\n outline: {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke1),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n outlineInteractive: {\n '&:hover': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Hover),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n '&:active': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n },\n underline: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStrokeAccessible),\n ...shorthands.borderRadius(0),\n },\n 'filled-lighter': {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n 'filled-darker': {\n backgroundColor: tokens.colorNeutralBackground3,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n invalid: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n ...shorthands.borderColor(tokens.colorPaletteRedBorder2),\n },\n },\n invalidUnderline: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n borderBottomColor: tokens.colorPaletteRedBorder2,\n },\n },\n\n disabled: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n '@media (forced-colors: active)': {\n ...shorthands.borderColor('GrayText'),\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n input: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.border('0'),\n color: tokens.colorNeutralForeground1,\n fontFamily: tokens.fontFamilyBase,\n\n '&:focus': {\n outlineStyle: 'none',\n },\n\n '&::placeholder': {\n color: tokens.colorNeutralForeground4,\n opacity: 1,\n },\n },\n\n // size variants\n small: {\n height: fieldHeights.small,\n ...typographyStyles.caption1,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalSNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n medium: {\n height: fieldHeights.medium,\n ...typographyStyles.body1,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalMNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n large: {\n height: fieldHeights.large,\n ...typographyStyles.body2,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalM} + ${tokens.spacingHorizontalSNudge})`),\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n backgroundColor: tokens.colorTransparentBackground,\n cursor: 'not-allowed',\n '::placeholder': {\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n});\n\nconst useIconStyles = makeStyles({\n icon: {\n boxSizing: 'border-box',\n color: tokens.colorNeutralStrokeAccessible,\n display: 'block',\n fontSize: tokens.fontSizeBase500,\n\n // the SVG must have display: block for accurate positioning\n // otherwise an extra inline space is inserted after the svg element\n '& svg': {\n display: 'block',\n },\n },\n\n // icon size variants\n small: {\n fontSize: iconSizes.small,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n medium: {\n fontSize: iconSizes.medium,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n large: {\n fontSize: iconSizes.large,\n marginLeft: tokens.spacingHorizontalSNudge,\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n\n/**\n * Apply styling to the Combobox slots based on the state\n */\nexport const useComboboxStyles_unstable = (state: ComboboxState): ComboboxState => {\n const { appearance, open, size } = state;\n const invalid = `${state.input['aria-invalid']}` === 'true';\n const disabled = state.input.disabled;\n const styles = useStyles();\n const iconStyles = useIconStyles();\n const inputStyles = useInputStyles();\n\n state.root.className = mergeClasses(\n comboboxClassNames.root,\n styles.root,\n styles[appearance],\n styles[size],\n !disabled && appearance === 'outline' && styles.outlineInteractive,\n invalid && appearance !== 'underline' && styles.invalid,\n invalid && appearance === 'underline' && styles.invalidUnderline,\n disabled && styles.disabled,\n state.root.className,\n );\n\n state.input.className = mergeClasses(\n comboboxClassNames.input,\n inputStyles.input,\n inputStyles[size],\n disabled && inputStyles.disabled,\n state.input.className,\n );\n\n if (state.listbox) {\n state.listbox.className = mergeClasses(\n comboboxClassNames.listbox,\n styles.listbox,\n !open && styles.listboxCollapsed,\n state.listbox.className,\n );\n }\n\n if (state.expandIcon) {\n state.expandIcon.className = mergeClasses(\n comboboxClassNames.expandIcon,\n iconStyles.icon,\n iconStyles[size],\n disabled && iconStyles.disabled,\n state.expandIcon.className,\n );\n }\n\n return state;\n};\n"]}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ComboboxField = exports.comboboxFieldClassNames = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const react_field_1 = /*#__PURE__*/require("@fluentui/react-field");
11
-
12
9
  const Combobox_1 = /*#__PURE__*/require("../../Combobox");
13
-
14
10
  exports.comboboxFieldClassNames = /*#__PURE__*/react_field_1.getFieldClassNames('ComboboxField');
15
11
  exports.ComboboxField = /*#__PURE__*/React.forwardRef((props, ref) => {
16
12
  const state = react_field_1.useField_unstable(props, ref, {
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-combobox/src/components/ComboboxField/ComboboxField.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAEA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AAOA,MAAA,UAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AAIa,OAAA,CAAA,uBAAA,gBAA0B,aAAA,CAAA,kBAAA,CAAmB,eAAnB,CAA1B;AAEA,OAAA,CAAA,aAAA,gBAAyD,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EACpG,MAAM,KAAK,GAAG,aAAA,CAAA,iBAAA,CAAkB,KAAlB,EAAyB,GAAzB,EAA8B;IAAE,SAAS,EAAE,UAAA,CAAA,QAAb;IAAuB,UAAU,EAAE,OAAA,CAAA;EAAnC,CAA9B,CAAd;EACA,aAAA,CAAA,uBAAA,CAAwB,KAAxB;EACA,OAAO,aAAA,CAAA,oBAAA,CAAqB,KAArB,CAAP;AACD,CAJqE,CAAzD;AAMb,OAAA,CAAA,aAAA,CAAc,WAAd,GAA4B,eAA5B","sourcesContent":["import * as React from 'react';\nimport type { FieldProps } from '@fluentui/react-field';\nimport {\n getFieldClassNames,\n renderField_unstable,\n useFieldStyles_unstable,\n useField_unstable,\n} from '@fluentui/react-field';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { Combobox } from '../../Combobox';\n\nexport type ComboboxFieldProps = FieldProps<typeof Combobox>;\n\nexport const comboboxFieldClassNames = getFieldClassNames('ComboboxField');\n\nexport const ComboboxField: ForwardRefComponent<ComboboxFieldProps> = React.forwardRef((props, ref) => {\n const state = useField_unstable(props, ref, { component: Combobox, classNames: comboboxFieldClassNames });\n useFieldStyles_unstable(state);\n return renderField_unstable(state);\n});\n\nComboboxField.displayName = 'ComboboxField';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AAEA;AAOA;AAIaA,+BAAuB,gBAAGC,gCAAkB,CAAC,eAAe,CAAC;AAE7DD,qBAAa,gBAA4CE,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EACpG,MAAMC,KAAK,GAAGL,+BAAiB,CAACG,KAAK,EAAEC,GAAG,EAAE;IAAEE,SAAS,EAAEC,mBAAQ;IAAEC,UAAU,EAAET;EAAuB,CAAE,CAAC;EACzGC,qCAAuB,CAACK,KAAK,CAAC;EAC9B,OAAOL,kCAAoB,CAACK,KAAK,CAAC;AACpC,CAAC,CAAC;AAEFN,qBAAa,CAACU,WAAW,GAAG,eAAe","names":["exports","react_field_1","React","forwardRef","props","ref","state","component","Combobox_1","classNames","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/ComboboxField/ComboboxField.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { FieldProps } from '@fluentui/react-field';\nimport {\n getFieldClassNames,\n renderField_unstable,\n useFieldStyles_unstable,\n useField_unstable,\n} from '@fluentui/react-field';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { Combobox } from '../../Combobox';\n\nexport type ComboboxFieldProps = FieldProps<typeof Combobox>;\n\nexport const comboboxFieldClassNames = getFieldClassNames('ComboboxField');\n\nexport const ComboboxField: ForwardRefComponent<ComboboxFieldProps> = React.forwardRef((props, ref) => {\n const state = useField_unstable(props, ref, { component: Combobox, classNames: comboboxFieldClassNames });\n useFieldStyles_unstable(state);\n return renderField_unstable(state);\n});\n\nComboboxField.displayName = 'ComboboxField';\n"]}
@@ -3,8 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./ComboboxField"), exports);
10
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-combobox/src/components/ComboboxField/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './ComboboxField';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/ComboboxField/index.ts"],"sourcesContent":["export * from './ComboboxField';\n"]}
@@ -4,21 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Dropdown = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const useDropdown_1 = /*#__PURE__*/require("./useDropdown");
11
-
12
9
  const renderDropdown_1 = /*#__PURE__*/require("./renderDropdown");
13
-
14
10
  const useDropdownStyles_1 = /*#__PURE__*/require("./useDropdownStyles");
15
-
16
11
  const useComboboxContextValues_1 = /*#__PURE__*/require("../../contexts/useComboboxContextValues");
17
12
  /**
18
13
  * Dropdown component: a selection control that allows users to choose from a set of possible options
19
14
  */
20
-
21
-
22
15
  exports.Dropdown = /*#__PURE__*/React.forwardRef((props, ref) => {
23
16
  const state = useDropdown_1.useDropdown_unstable(props, ref);
24
17
  const contextValues = useComboboxContextValues_1.useComboboxContextValues(state);
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-combobox/src/components/Dropdown/Dropdown.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,eAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,kBAAA,CAAA;;AACA,MAAA,mBAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AAEA,MAAA,0BAAA,gBAAA,OAAA,CAAA,yCAAA,CAAA;AAGA;;AAEG;;;AACU,OAAA,CAAA,QAAA,gBAA+C,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;EAC1F,MAAM,KAAK,GAAG,aAAA,CAAA,oBAAA,CAAqB,KAArB,EAA4B,GAA5B,CAAd;EACA,MAAM,aAAa,GAAG,0BAAA,CAAA,wBAAA,CAAyB,KAAzB,CAAtB;EAEA,mBAAA,CAAA,0BAAA,CAA2B,KAA3B;EACA,OAAO,gBAAA,CAAA,uBAAA,CAAwB,KAAxB,EAA+B,aAA/B,CAAP;AACD,CAN2D,CAA/C;AAQb,OAAA,CAAA,QAAA,CAAS,WAAT,GAAuB,UAAvB","sourcesContent":["import * as React from 'react';\nimport { useDropdown_unstable } from './useDropdown';\nimport { renderDropdown_unstable } from './renderDropdown';\nimport { useDropdownStyles_unstable } from './useDropdownStyles';\nimport type { DropdownProps } from './Dropdown.types';\nimport { useComboboxContextValues } from '../../contexts/useComboboxContextValues';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Dropdown component: a selection control that allows users to choose from a set of possible options\n */\nexport const Dropdown: ForwardRefComponent<DropdownProps> = React.forwardRef((props, ref) => {\n const state = useDropdown_unstable(props, ref);\n const contextValues = useComboboxContextValues(state);\n\n useDropdownStyles_unstable(state);\n return renderDropdown_unstable(state, contextValues);\n});\n\nDropdown.displayName = 'Dropdown';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAEA;AAGA;;;AAGaA,gBAAQ,gBAAuCC,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAC1F,MAAMC,KAAK,GAAGC,kCAAoB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAC9C,MAAMG,aAAa,GAAGC,mDAAwB,CAACH,KAAK,CAAC;EAErDI,8CAA0B,CAACJ,KAAK,CAAC;EACjC,OAAOK,wCAAuB,CAACL,KAAK,EAAEE,aAAa,CAAC;AACtD,CAAC,CAAC;AAEFP,gBAAQ,CAACW,WAAW,GAAG,UAAU","names":["exports","React","forwardRef","props","ref","state","useDropdown_1","contextValues","useComboboxContextValues_1","useDropdownStyles_1","renderDropdown_1","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useDropdown_unstable } from './useDropdown';\nimport { renderDropdown_unstable } from './renderDropdown';\nimport { useDropdownStyles_unstable } from './useDropdownStyles';\nimport type { DropdownProps } from './Dropdown.types';\nimport { useComboboxContextValues } from '../../contexts/useComboboxContextValues';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Dropdown component: a selection control that allows users to choose from a set of possible options\n */\nexport const Dropdown: ForwardRefComponent<DropdownProps> = React.forwardRef((props, ref) => {\n const state = useDropdown_unstable(props, ref);\n const contextValues = useComboboxContextValues(state);\n\n useDropdownStyles_unstable(state);\n return renderDropdown_unstable(state, contextValues);\n});\n\nDropdown.displayName = 'Dropdown';\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
1
+ {"version":3,"mappings":"","names":[],"sourceRoot":"../src/","sources":[],"sourcesContent":[]}
@@ -3,16 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  const tslib_1 = /*#__PURE__*/require("tslib");
8
-
9
7
  tslib_1.__exportStar(require("./Dropdown"), exports);
10
-
11
8
  tslib_1.__exportStar(require("./Dropdown.types"), exports);
12
-
13
9
  tslib_1.__exportStar(require("./renderDropdown"), exports);
14
-
15
10
  tslib_1.__exportStar(require("./useDropdown"), exports);
16
-
17
11
  tslib_1.__exportStar(require("./useDropdownStyles"), exports);
18
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-combobox/src/components/Dropdown/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,YAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,kBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,eAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,qBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Dropdown';\nexport * from './Dropdown.types';\nexport * from './renderDropdown';\nexport * from './useDropdown';\nexport * from './useDropdownStyles';\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAAA;AACAA;AACAA;AACAA;AACAA","names":["tslib_1"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Dropdown/index.ts"],"sourcesContent":["export * from './Dropdown';\nexport * from './Dropdown.types';\nexport * from './renderDropdown';\nexport * from './useDropdown';\nexport * from './useDropdownStyles';\n"]}
@@ -4,33 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderDropdown_unstable = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
11
-
12
9
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
-
14
10
  const ComboboxContext_1 = /*#__PURE__*/require("../../contexts/ComboboxContext");
15
11
  /**
16
12
  * Render the final JSX of Dropdown
17
13
  */
18
-
19
-
20
14
  const renderDropdown_unstable = (state, contextValues) => {
21
15
  const {
22
16
  slots,
23
17
  slotProps
24
18
  } = react_utilities_1.getSlots(state);
25
- return React.createElement(slots.root, { ...slotProps.root
19
+ return React.createElement(slots.root, {
20
+ ...slotProps.root
26
21
  }, React.createElement(ComboboxContext_1.ComboboxContext.Provider, {
27
22
  value: contextValues.combobox
28
- }, React.createElement(slots.button, { ...slotProps.button
29
- }, slotProps.button.children, slots.expandIcon && React.createElement(slots.expandIcon, { ...slotProps.expandIcon
30
- })), slots.listbox && (state.inlinePopup ? React.createElement(slots.listbox, { ...slotProps.listbox
31
- }) : React.createElement(react_portal_1.Portal, null, React.createElement(slots.listbox, { ...slotProps.listbox
23
+ }, React.createElement(slots.button, {
24
+ ...slotProps.button
25
+ }, slotProps.button.children, slots.expandIcon && React.createElement(slots.expandIcon, {
26
+ ...slotProps.expandIcon
27
+ })), slots.listbox && (state.inlinePopup ? React.createElement(slots.listbox, {
28
+ ...slotProps.listbox
29
+ }) : React.createElement(react_portal_1.Portal, null, React.createElement(slots.listbox, {
30
+ ...slotProps.listbox
32
31
  })))));
33
32
  };
34
-
35
33
  exports.renderDropdown_unstable = renderDropdown_unstable;
36
34
  //# sourceMappingURL=renderDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-combobox/src/components/Dropdown/renderDropdown.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,wBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,gCAAA,CAAA;AAGA;;AAEG;;;AACI,MAAM,uBAAuB,GAAG,CAAC,KAAD,EAAuB,aAAvB,KAA+D;EACpG,MAAM;IAAE,KAAF;IAAS;EAAT,IAAuB,iBAAA,CAAA,QAAA,CAAwB,KAAxB,CAA7B;EAEA,OACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;EAAf,CAAX,EACE,KAAA,CAAA,aAAA,CAAC,iBAAA,CAAA,eAAA,CAAgB,QAAjB,EAAyB;IAAC,KAAK,EAAE,aAAa,CAAC;EAAtB,CAAzB,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,MAAP,EAAa,EAAA,GAAK,SAAS,CAAC;EAAf,CAAb,EACG,SAAS,CAAC,MAAV,CAAiB,QADpB,EAEG,KAAK,CAAC,UAAN,IAAoB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,UAAP,EAAiB,EAAA,GAAK,SAAS,CAAC;EAAf,CAAjB,CAFvB,CADF,EAKG,KAAK,CAAC,OAAN,KACE,KAAK,CAAC,WAAN,GACC,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;EAAf,CAAd,CADD,GAGC,KAAA,CAAA,aAAA,CAAC,cAAA,CAAA,MAAD,EAAO,IAAP,EACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;EAAf,CAAd,CADF,CAJH,CALH,CADF,CADF;AAkBD,CArBM;;AAAM,OAAA,CAAA,uBAAA,GAAuB,uBAAvB","sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport type { DropdownContextValues, DropdownState, DropdownSlots } from './Dropdown.types';\n\n/**\n * Render the final JSX of Dropdown\n */\nexport const renderDropdown_unstable = (state: DropdownState, contextValues: DropdownContextValues) => {\n const { slots, slotProps } = getSlots<DropdownSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <ComboboxContext.Provider value={contextValues.combobox}>\n <slots.button {...slotProps.button}>\n {slotProps.button.children}\n {slots.expandIcon && <slots.expandIcon {...slotProps.expandIcon} />}\n </slots.button>\n {slots.listbox &&\n (state.inlinePopup ? (\n <slots.listbox {...slotProps.listbox} />\n ) : (\n <Portal>\n <slots.listbox {...slotProps.listbox} />\n </Portal>\n ))}\n </ComboboxContext.Provider>\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AAGA;;;AAGO,MAAMA,uBAAuB,GAAG,CAACC,KAAoB,EAAEC,aAAoC,KAAI;EACpG,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGC,0BAAQ,CAAgBJ,KAAK,CAAC;EAE3D,OACEK,oBAACH,KAAK,CAACI,IAAI;IAAA,GAAKH,SAAS,CAACG;EAAI,GAC5BD,oBAACE,iCAAe,CAACC,QAAQ;IAACC,KAAK,EAAER,aAAa,CAACS;EAAQ,GACrDL,oBAACH,KAAK,CAACS,MAAM;IAAA,GAAKR,SAAS,CAACQ;EAAM,GAC/BR,SAAS,CAACQ,MAAM,CAACC,QAAQ,EACzBV,KAAK,CAACW,UAAU,IAAIR,oBAACH,KAAK,CAACW,UAAU;IAAA,GAAKV,SAAS,CAACU;EAAU,EAAI,CACtD,EACdX,KAAK,CAACY,OAAO,KACXd,KAAK,CAACe,WAAW,GAChBV,oBAACH,KAAK,CAACY,OAAO;IAAA,GAAKX,SAAS,CAACW;EAAO,EAAI,GAExCT,oBAACW,qBAAM,QACLX,oBAACH,KAAK,CAACY,OAAO;IAAA,GAAKX,SAAS,CAACW;EAAO,EAAI,CAE3C,CAAC,CACqB,CAChB;AAEjB,CAAC;AArBYG,+BAAuB","names":["renderDropdown_unstable","state","contextValues","slots","slotProps","react_utilities_1","React","root","ComboboxContext_1","Provider","value","combobox","button","children","expandIcon","listbox","inlinePopup","react_portal_1","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Dropdown/renderDropdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { Portal } from '@fluentui/react-portal';\nimport { getSlots } from '@fluentui/react-utilities';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport type { DropdownContextValues, DropdownState, DropdownSlots } from './Dropdown.types';\n\n/**\n * Render the final JSX of Dropdown\n */\nexport const renderDropdown_unstable = (state: DropdownState, contextValues: DropdownContextValues) => {\n const { slots, slotProps } = getSlots<DropdownSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n <ComboboxContext.Provider value={contextValues.combobox}>\n <slots.button {...slotProps.button}>\n {slotProps.button.children}\n {slots.expandIcon && <slots.expandIcon {...slotProps.expandIcon} />}\n </slots.button>\n {slots.listbox &&\n (state.inlinePopup ? (\n <slots.listbox {...slotProps.listbox} />\n ) : (\n <Portal>\n <slots.listbox {...slotProps.listbox} />\n </Portal>\n ))}\n </ComboboxContext.Provider>\n </slots.root>\n );\n};\n"]}
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useDropdown_unstable = void 0;
7
-
8
7
  const React = /*#__PURE__*/require("react");
9
-
10
8
  const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
11
-
12
9
  const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
13
-
14
10
  const dropdownKeyActions_1 = /*#__PURE__*/require("../../utils/dropdownKeyActions");
15
-
16
11
  const useComboboxBaseState_1 = /*#__PURE__*/require("../../utils/useComboboxBaseState");
17
-
18
12
  const useComboboxPopup_1 = /*#__PURE__*/require("../../utils/useComboboxPopup");
19
-
20
13
  const useTriggerListboxSlots_1 = /*#__PURE__*/require("../../utils/useTriggerListboxSlots");
21
-
22
14
  const Listbox_1 = /*#__PURE__*/require("../Listbox/Listbox");
23
-
24
15
  const react_utilities_2 = /*#__PURE__*/require("@fluentui/react-utilities");
25
16
  /**
26
17
  * Create the state required to render Dropdown.
@@ -31,8 +22,6 @@ const react_utilities_2 = /*#__PURE__*/require("@fluentui/react-utilities");
31
22
  * @param props - props from this instance of Dropdown
32
23
  * @param ref - reference to root HTMLElement of Dropdown
33
24
  */
34
-
35
-
36
25
  const useDropdown_unstable = (props, ref) => {
37
26
  const baseState = useComboboxBaseState_1.useComboboxBaseState(props);
38
27
  const {
@@ -51,78 +40,67 @@ const useDropdown_unstable = (props, ref) => {
51
40
  props,
52
41
  primarySlotTagName: 'button',
53
42
  excludedPropNames: ['children']
54
- }); // set listbox popup width based off the root/trigger width
55
-
43
+ });
44
+ // set listbox popup width based off the root/trigger width
56
45
  const rootRef = React.useRef(null);
57
46
  const [popupWidth, setPopupWidth] = React.useState();
58
47
  React.useEffect(() => {
59
48
  var _a;
60
-
61
49
  const width = open ? `${(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px` : undefined;
62
50
  setPopupWidth(width);
63
- }, [open]); // jump to matching option based on typing
64
-
51
+ }, [open]);
52
+ // jump to matching option based on typing
65
53
  const searchString = React.useRef('');
66
54
  const [setKeyTimeout, clearKeyTimeout] = react_utilities_1.useTimeout();
67
-
68
55
  const getNextMatchingOption = () => {
69
- var _a; // first check for matches for the full searchString
70
-
71
-
56
+ var _a;
57
+ // first check for matches for the full searchString
72
58
  let matcher = optionValue => optionValue.toLowerCase().indexOf(searchString.current) === 0;
73
-
74
59
  let matches = getOptionsMatchingText(matcher);
75
- let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0; // if the dropdown is already open and the searchstring is a single character,
60
+ let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
61
+ // if the dropdown is already open and the searchstring is a single character,
76
62
  // then look after the current activeOption for letters
77
63
  // this is so slowly typing the same letter will cycle through matches
78
-
79
64
  if (open && searchString.current.length === 1) {
80
65
  startIndex++;
81
- } // if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
82
-
83
-
66
+ }
67
+ // if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
84
68
  if (!matches.length) {
85
69
  const letters = searchString.current.split('');
86
- const allSameLetter = letters.length && letters.every(letter => letter === letters[0]); // if the search is all the same letter, cycle through options starting with that letter
87
-
70
+ const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);
71
+ // if the search is all the same letter, cycle through options starting with that letter
88
72
  if (allSameLetter) {
89
73
  startIndex++;
90
-
91
74
  matcher = optionValue => optionValue.toLowerCase().indexOf(letters[0]) === 0;
92
-
93
75
  matches = getOptionsMatchingText(matcher);
94
76
  }
95
- } // if there is an active option and multiple matches,
77
+ }
78
+ // if there is an active option and multiple matches,
96
79
  // return first matching option after the current active option, looping back to the top
97
-
98
-
99
80
  if (matches.length > 1 && activeOption) {
100
81
  const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);
101
82
  return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
102
83
  }
103
-
104
84
  return (_a = matches[0]) !== null && _a !== void 0 ? _a : undefined;
105
85
  };
106
-
107
86
  const onTriggerKeyDown = ev => {
108
87
  // clear timeout, if it exists
109
- clearKeyTimeout(); // if the key was a char key, update search string
110
-
88
+ clearKeyTimeout();
89
+ // if the key was a char key, update search string
111
90
  if (dropdownKeyActions_1.getDropdownActionFromKey(ev) === 'Type') {
112
91
  // update search string
113
92
  searchString.current += ev.key.toLowerCase();
114
93
  setKeyTimeout(() => {
115
94
  searchString.current = '';
116
- }, 500); // update state
117
-
95
+ }, 500);
96
+ // update state
118
97
  !open && setOpen(ev, true);
119
98
  const nextOption = getNextMatchingOption();
120
99
  setActiveOption(nextOption);
121
100
  setFocusVisible(true);
122
101
  }
123
- }; // resolve button and listbox slot props
124
-
125
-
102
+ };
103
+ // resolve button and listbox slot props
126
104
  let triggerSlot;
127
105
  let listboxSlot;
128
106
  triggerSlot = react_utilities_1.resolveShorthand(props.button, {
@@ -173,6 +151,5 @@ const useDropdown_unstable = (props, ref) => {
173
151
  state.root.ref = react_utilities_2.useMergedRefs(state.root.ref, rootRef);
174
152
  return state;
175
153
  };
176
-
177
154
  exports.useDropdown_unstable = useDropdown_unstable;
178
155
  //# sourceMappingURL=useDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["packages/react-components/react-combobox/src/components/Dropdown/useDropdown.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,aAAA,gBAAA,OAAA,CAAA,uBAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,oBAAA,gBAAA,OAAA,CAAA,gCAAA,CAAA;;AACA,MAAA,sBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AACA,MAAA,kBAAA,gBAAA,OAAA,CAAA,8BAAA,CAAA;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,oCAAA,CAAA;;AACA,MAAA,SAA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BAAA,CAAiB,KAAjB,EAAwB,WAAxB,EAAqC,WAArC,CAA7B;EACA,CAAC,WAAD,EAAc,WAAd,IAA6B,wBAAA,CAAA,sBAAA,CAAuB,KAAvB,EAA8B,SAA9B,EAAyC,GAAzC,EAA8C,WAA9C,EAA2D,WAA3D,CAA7B;EAEA,MAAM,KAAK,GAAkB;IAC3B,UAAU,EAAE;MACV,IAAI,EAAE,KADI;MAEV,MAAM,EAAE,QAFE;MAGV,UAAU,EAAE,MAHF;MAIV,OAAO,EAAE,SAAA,CAAA;IAJC,CADe;IAO3B,IAAI,EAAE,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,IAAvB,EAA6B;MACjC,QAAQ,EAAE,IADuB;MAEjC,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK,CAAC,QADJ;QAEZ,GAAG;MAFS;IAFmB,CAA7B,CAPqB;IAc3B,MAAM,EAAE,WAdmB;IAe3B,OAAO,EAAE,WAfkB;IAgB3B,UAAU,EAAE,iBAAA,CAAA,gBAAA,CAAiB,KAAK,CAAC,UAAvB,EAAmC;MAC7C,QAAQ,EAAE,IADmC;MAE7C,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAA,CAAA,aAAA,CAAC,aAAA,CAAA,kBAAD,EAAgB,IAAhB;MADE;IAF+B,CAAnC,CAhBe;IAsB3B,kBAAkB,EAAE,CAAC,SAAS,CAAC,KAAX,IAAoB,CAAC,CAAC,KAAK,CAAC,WAtBrB;IAuB3B,GAAG;EAvBwB,CAA7B;EA0BA,KAAK,CAAC,IAAN,CAAW,GAAX,GAAiB,iBAAA,CAAA,aAAA,CAAc,KAAK,CAAC,IAAN,CAAW,GAAzB,EAA8B,OAA9B,CAAjB;EAEA,OAAO,KAAP;AACD,CAjJM;;AAAM,OAAA,CAAA,oBAAA,GAAoB,oBAApB","sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useTimeout } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { DropdownProps, DropdownState } from './Dropdown.types';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n\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 */\nexport const useDropdown_unstable = (props: DropdownProps, ref: React.Ref<HTMLButtonElement>): DropdownState => {\n const baseState = useComboboxBaseState(props);\n const {\n activeOption,\n getIndexOfId,\n getOptionsMatchingText,\n open,\n setActiveOption,\n setFocusVisible,\n setOpen,\n } = baseState;\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: ['children'],\n });\n\n // set listbox popup width based off the root/trigger width\n const rootRef = React.useRef<HTMLDivElement>(null);\n const [popupWidth, setPopupWidth] = React.useState<string>();\n React.useEffect(() => {\n const width = open ? `${rootRef.current?.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n\n const getNextMatchingOption = (): OptionValue | undefined => {\n // first check for matches for the full searchString\n let matcher = (optionValue: string) => optionValue.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n\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\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\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = (optionValue: string) => optionValue.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\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 ?? matches[0];\n }\n\n return matches[0] ?? undefined;\n };\n\n const onTriggerKeyDown = (ev: React.KeyboardEvent<HTMLButtonElement>) => {\n // clear timeout, if it exists\n clearKeyTimeout();\n\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\n // update state\n !open && setOpen(ev, true);\n\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n\n // resolve button and listbox slot props\n let triggerSlot: Slot<'button'>;\n let listboxSlot: Slot<typeof Listbox> | undefined;\n\n triggerSlot = resolveShorthand(props.button, {\n required: true,\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n\n listboxSlot =\n baseState.open || baseState.hasFocus\n ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: { width: popupWidth },\n },\n })\n : undefined;\n\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n\n const state: DropdownState = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n children: props.children,\n ...rootNativeProps,\n },\n }),\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: <ChevronDownIcon />,\n },\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n\n return state;\n};\n"],"sourceRoot":"../src/"}
1
+ {"version":3,"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;;;;;;;;;AASO,MAAMA,oBAAoB,GAAG,CAACC,KAAoB,EAAEC,GAAiC,KAAmB;EAC7G,MAAMC,SAAS,GAAGC,2CAAoB,CAACH,KAAK,CAAC;EAC7C,MAAM;IACJI,YAAY;IACZC,YAAY;IACZC,sBAAsB;IACtBC,IAAI;IACJC,eAAe;IACfC,eAAe;IACfC;EAAO,CACR,GAAGR,SAAS;EAEb,MAAM;IAAES,OAAO,EAAEC,kBAAkB;IAAEC,IAAI,EAAEC;EAAe,CAAE,GAAGC,2CAAyB,CAAC;IACvFf,KAAK;IACLgB,kBAAkB,EAAE,QAAQ;IAC5BC,iBAAiB,EAAE,CAAC,UAAU;GAC/B,CAAC;EAEF;EACA,MAAMC,OAAO,GAAGC,KAAK,CAACC,MAAM,CAAiB,IAAI,CAAC;EAClD,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGH,KAAK,CAACI,QAAQ,EAAU;EAC5DJ,KAAK,CAACK,SAAS,CAAC,MAAK;;IACnB,MAAMC,KAAK,GAAGlB,IAAI,GAAG,GAAG,aAAO,CAACmB,OAAO,0CAAEC,WAAW,IAAI,GAAGC,SAAS;IACpEN,aAAa,CAACG,KAAK,CAAC;EACtB,CAAC,EAAE,CAAClB,IAAI,CAAC,CAAC;EAEV;EACA,MAAMsB,YAAY,G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EJ;MAAU;;GAE7B,CAAC,GACFO,SAAS;EAEf,CAAC0B,WAAW,EAAEC,WAAW,CAAC,GAAGY,mCAAgB,CAACnE,KAAK,EAAEsD,WAAW,EAAEC,WAAW,CAAC;EAC9E,CAACD,WAAW,EAAEC,WAAW,CAAC,GAAGa,+CAAsB,CAACpE,KAAK,EAAEE,SAAS,EAAED,GAAG,EAAEqD,WAAW,EAAEC,WAAW,CAAC;EAEpG,MAAMc,KAAK,GAAkB;IAC3BC,UAAU,EAAE;MACVzD,IAAI,EAAE,KAAK;MACX2C,MAAM,EAAE,QAAQ;MAChBe,UAAU,EAAE,MAAM;MAClBN,OAAO,EAAEO;KACV;IACD3D,IAAI,EAAEE,kCAAgB,CAACf,KAAK,CAACa,IAAI,EAAE;MACjC4C,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZE,QAAQ,EAAE5D,KAAK,CAAC4D,QAAQ;QACxB,GAAG9C;;KAEN,CAAC;IACF0C,MAAM,EAAEF,WAAW;IACnBW,OAAO,EAAEV,WAAW;IACpBgB,UAAU,EAAExD,kCAAgB,CAACf,KAAK,CAACuE,UAAU,EAAE;MAC7Cd,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZE,QAAQ,EAAEzC,oBAACsD,gCAAe;;KAE7B,CAAC;IACFC,kBAAkB,EAAE,CAACxE,SAAS,CAAC2D,KAAK,IAAI,CAAC,CAAC7D,KAAK,CAAC8D,WAAW;IAC3D,GAAG5D;GACJ;EAEDmE,KAAK,CAACxD,IAAI,CAACZ,GAAG,GAAG0E,+BAAa,CAACN,KAAK,CAACxD,IAAI,CAACZ,GAAG,EAAEiB,OAAO,CAAC;EAEvD,OAAOmD,KAAK;AACd,CAAC;AAjJYO,4BAAoB","names":["useDropdown_unstable","props","ref","baseState","useComboboxBaseState_1","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","react_utilities_1","primarySlotTagName","excludedPropNames","rootRef","React","useRef","popupWidth","setPopupWidth","useState","useEffect","width","current","clientWidth","undefined","searchString","setKeyTimeout","clearKeyTimeout","getNextMatchingOption","matcher","optionValue","toLowerCase","indexOf","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","onTriggerKeyDown","ev","dropdownKeyActions_1","key","nextOption","triggerSlot","listboxSlot","button","required","defaultProps","type","children","value","placeholder","onKeyDown","hasFocus","listbox","style","useComboboxPopup_1","useTriggerListboxSlots_1","state","components","expandIcon","Listbox_1","react_icons_1","placeholderVisible","react_utilities_2","exports"],"sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Dropdown/useDropdown.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useTimeout } from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { DropdownProps, DropdownState } from './Dropdown.types';\nimport { useMergedRefs } from '@fluentui/react-utilities';\n\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 */\nexport const useDropdown_unstable = (props: DropdownProps, ref: React.Ref<HTMLButtonElement>): DropdownState => {\n const baseState = useComboboxBaseState(props);\n const {\n activeOption,\n getIndexOfId,\n getOptionsMatchingText,\n open,\n setActiveOption,\n setFocusVisible,\n setOpen,\n } = baseState;\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'button',\n excludedPropNames: ['children'],\n });\n\n // set listbox popup width based off the root/trigger width\n const rootRef = React.useRef<HTMLDivElement>(null);\n const [popupWidth, setPopupWidth] = React.useState<string>();\n React.useEffect(() => {\n const width = open ? `${rootRef.current?.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n\n // jump to matching option based on typing\n const searchString = React.useRef('');\n const [setKeyTimeout, clearKeyTimeout] = useTimeout();\n\n const getNextMatchingOption = (): OptionValue | undefined => {\n // first check for matches for the full searchString\n let matcher = (optionValue: string) => optionValue.toLowerCase().indexOf(searchString.current) === 0;\n let matches = getOptionsMatchingText(matcher);\n let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;\n\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\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\n // if the search is all the same letter, cycle through options starting with that letter\n if (allSameLetter) {\n startIndex++;\n matcher = (optionValue: string) => optionValue.toLowerCase().indexOf(letters[0]) === 0;\n matches = getOptionsMatchingText(matcher);\n }\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 ?? matches[0];\n }\n\n return matches[0] ?? undefined;\n };\n\n const onTriggerKeyDown = (ev: React.KeyboardEvent<HTMLButtonElement>) => {\n // clear timeout, if it exists\n clearKeyTimeout();\n\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\n // update state\n !open && setOpen(ev, true);\n\n const nextOption = getNextMatchingOption();\n setActiveOption(nextOption);\n setFocusVisible(true);\n }\n };\n\n // resolve button and listbox slot props\n let triggerSlot: Slot<'button'>;\n let listboxSlot: Slot<typeof Listbox> | undefined;\n\n triggerSlot = resolveShorthand(props.button, {\n required: true,\n defaultProps: {\n type: 'button',\n children: baseState.value || props.placeholder,\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onKeyDown = mergeCallbacks(onTriggerKeyDown, triggerSlot.onKeyDown);\n\n listboxSlot =\n baseState.open || baseState.hasFocus\n ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: { width: popupWidth },\n },\n })\n : undefined;\n\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n\n const state: DropdownState = {\n components: {\n root: 'div',\n button: 'button',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n children: props.children,\n ...rootNativeProps,\n },\n }),\n button: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: <ChevronDownIcon />,\n },\n }),\n placeholderVisible: !baseState.value && !!props.placeholder,\n ...baseState,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n\n return state;\n};\n"]}