@fluentui/react-combobox 9.0.0-beta.9 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +848 -1
- package/CHANGELOG.md +248 -2
- package/README.md +1 -3
- package/dist/index.d.ts +62 -11
- package/lib/Combobox.js.map +1 -1
- package/lib/ComboboxField.js +2 -0
- package/lib/ComboboxField.js.map +1 -0
- package/lib/Dropdown.js.map +1 -1
- package/lib/Listbox.js.map +1 -1
- package/lib/Option.js.map +1 -1
- package/lib/OptionGroup.js.map +1 -1
- package/lib/components/Combobox/Combobox.js +0 -1
- package/lib/components/Combobox/Combobox.js.map +1 -1
- package/lib/components/Combobox/Combobox.types.js.map +1 -1
- package/lib/components/Combobox/index.js.map +1 -1
- package/lib/components/Combobox/renderCombobox.js +10 -6
- package/lib/components/Combobox/renderCombobox.js.map +1 -1
- package/lib/components/Combobox/useCombobox.js +107 -70
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Combobox/useComboboxStyles.js +246 -185
- package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib/components/ComboboxField/ComboboxField.js +8 -0
- package/lib/components/ComboboxField/ComboboxField.js.map +1 -0
- package/lib/components/ComboboxField/index.js +2 -0
- package/lib/components/ComboboxField/index.js.map +1 -0
- package/lib/components/Dropdown/Dropdown.js +0 -1
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.types.js.map +1 -1
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/Dropdown/renderDropdown.js +10 -6
- package/lib/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +25 -36
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdownStyles.js +236 -176
- package/lib/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib/components/Listbox/Listbox.js +0 -1
- package/lib/components/Listbox/Listbox.js.map +1 -1
- package/lib/components/Listbox/Listbox.types.js.map +1 -1
- package/lib/components/Listbox/index.js.map +1 -1
- package/lib/components/Listbox/renderListbox.js +2 -2
- package/lib/components/Listbox/renderListbox.js.map +1 -1
- package/lib/components/Listbox/useListbox.js +15 -17
- package/lib/components/Listbox/useListbox.js.map +1 -1
- package/lib/components/Listbox/useListboxStyles.js +16 -20
- package/lib/components/Listbox/useListboxStyles.js.map +1 -1
- package/lib/components/Option/Option.js +0 -1
- package/lib/components/Option/Option.js.map +1 -1
- package/lib/components/Option/Option.types.js.map +1 -1
- package/lib/components/Option/index.js.map +1 -1
- package/lib/components/Option/renderOption.js +4 -3
- package/lib/components/Option/renderOption.js.map +1 -1
- package/lib/components/Option/useOption.js +46 -39
- package/lib/components/Option/useOption.js.map +1 -1
- package/lib/components/Option/useOptionStyles.js +101 -79
- package/lib/components/Option/useOptionStyles.js.map +1 -1
- package/lib/components/OptionGroup/OptionGroup.js +0 -1
- package/lib/components/OptionGroup/OptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/OptionGroup.types.js.map +1 -1
- package/lib/components/OptionGroup/index.js.map +1 -1
- package/lib/components/OptionGroup/renderOptionGroup.js +4 -3
- package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroup.js +0 -1
- package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroupStyles.js +29 -34
- package/lib/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
- package/lib/contexts/ComboboxContext.js +9 -11
- package/lib/contexts/ComboboxContext.js.map +1 -1
- package/lib/contexts/ListboxContext.js +7 -9
- package/lib/contexts/ListboxContext.js.map +1 -1
- package/lib/contexts/useComboboxContextValues.js.map +1 -1
- package/lib/contexts/useListboxContextValues.js +2 -2
- package/lib/contexts/useListboxContextValues.js.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib/utils/ComboboxBase.types.js.map +1 -1
- package/lib/utils/OptionCollection.types.js.map +1 -1
- package/lib/utils/Selection.types.js.map +1 -1
- package/lib/utils/dropdownKeyActions.js +12 -33
- package/lib/utils/dropdownKeyActions.js.map +1 -1
- package/lib/utils/internalTokens.js.map +1 -1
- package/lib/utils/useComboboxBaseState.js +29 -30
- package/lib/utils/useComboboxBaseState.js.map +1 -1
- package/lib/utils/useComboboxPopup.js +6 -4
- package/lib/utils/useComboboxPopup.js.map +1 -1
- package/lib/utils/useOptionCollection.js +13 -23
- package/lib/utils/useOptionCollection.js.map +1 -1
- package/lib/utils/useScrollOptionsIntoView.js +36 -0
- package/lib/utils/useScrollOptionsIntoView.js.map +1 -0
- package/lib/utils/useSelection.js +9 -12
- package/lib/utils/useSelection.js.map +1 -1
- package/lib/utils/useTriggerListboxSlots.js +34 -40
- package/lib/utils/useTriggerListboxSlots.js.map +1 -1
- package/lib-amd/Combobox.js +6 -0
- package/lib-amd/Combobox.js.map +1 -0
- package/lib-amd/ComboboxField.js +6 -0
- package/lib-amd/ComboboxField.js.map +1 -0
- package/lib-amd/Dropdown.js +6 -0
- package/lib-amd/Dropdown.js.map +1 -0
- package/lib-amd/Listbox.js +6 -0
- package/lib-amd/Listbox.js.map +1 -0
- package/lib-amd/Option.js +6 -0
- package/lib-amd/Option.js.map +1 -0
- package/lib-amd/OptionGroup.js +6 -0
- package/lib-amd/OptionGroup.js.map +1 -0
- package/lib-amd/components/Combobox/Combobox.js +16 -0
- package/lib-amd/components/Combobox/Combobox.js.map +1 -0
- package/lib-amd/components/Combobox/Combobox.types.js +5 -0
- package/lib-amd/components/Combobox/Combobox.types.js.map +1 -0
- package/lib-amd/components/Combobox/index.js +10 -0
- package/lib-amd/components/Combobox/index.js.map +1 -0
- package/lib-amd/components/Combobox/renderCombobox.js +20 -0
- package/lib-amd/components/Combobox/renderCombobox.js.map +1 -0
- package/lib-amd/components/Combobox/useCombobox.js +206 -0
- package/lib-amd/components/Combobox/useCombobox.js.map +1 -0
- package/lib-amd/components/Combobox/useComboboxStyles.js +152 -0
- package/lib-amd/components/Combobox/useComboboxStyles.js.map +1 -0
- package/lib-amd/components/ComboboxField/ComboboxField.js +10 -0
- package/lib-amd/components/ComboboxField/ComboboxField.js.map +1 -0
- package/lib-amd/components/ComboboxField/index.js +6 -0
- package/lib-amd/components/ComboboxField/index.js.map +1 -0
- package/lib-amd/components/Dropdown/Dropdown.js +16 -0
- package/lib-amd/components/Dropdown/Dropdown.js.map +1 -0
- package/lib-amd/components/Dropdown/Dropdown.types.js +5 -0
- package/lib-amd/components/Dropdown/Dropdown.types.js.map +1 -0
- package/lib-amd/components/Dropdown/index.js +10 -0
- package/lib-amd/components/Dropdown/index.js.map +1 -0
- package/lib-amd/components/Dropdown/renderDropdown.js +21 -0
- package/lib-amd/components/Dropdown/renderDropdown.js.map +1 -0
- package/lib-amd/components/Dropdown/useDropdown.js +121 -0
- package/lib-amd/components/Dropdown/useDropdown.js.map +1 -0
- package/lib-amd/components/Dropdown/useDropdownStyles.js +127 -0
- package/lib-amd/components/Dropdown/useDropdownStyles.js.map +1 -0
- package/lib-amd/components/Listbox/Listbox.js +16 -0
- package/lib-amd/components/Listbox/Listbox.js.map +1 -0
- package/lib-amd/components/Listbox/Listbox.types.js +5 -0
- package/lib-amd/components/Listbox/Listbox.types.js.map +1 -0
- package/lib-amd/components/Listbox/index.js +10 -0
- package/lib-amd/components/Listbox/index.js.map +1 -0
- package/lib-amd/components/Listbox/renderListbox.js +15 -0
- package/lib-amd/components/Listbox/renderListbox.js.map +1 -0
- package/lib-amd/components/Listbox/useListbox.js +80 -0
- package/lib-amd/components/Listbox/useListbox.js.map +1 -0
- package/lib-amd/components/Listbox/useListboxStyles.js +24 -0
- package/lib-amd/components/Listbox/useListboxStyles.js.map +1 -0
- package/lib-amd/components/Option/Option.js +15 -0
- package/lib-amd/components/Option/Option.js.map +1 -0
- package/lib-amd/components/Option/Option.types.js +5 -0
- package/lib-amd/components/Option/Option.types.js.map +1 -0
- package/lib-amd/components/Option/index.js +10 -0
- package/lib-amd/components/Option/index.js.map +1 -0
- package/lib-amd/components/Option/renderOption.js +16 -0
- package/lib-amd/components/Option/renderOption.js.map +1 -0
- package/lib-amd/components/Option/useOption.js +117 -0
- package/lib-amd/components/Option/useOption.js.map +1 -0
- package/lib-amd/components/Option/useOptionStyles.js +73 -0
- package/lib-amd/components/Option/useOptionStyles.js.map +1 -0
- package/lib-amd/components/OptionGroup/OptionGroup.js +15 -0
- package/lib-amd/components/OptionGroup/OptionGroup.js.map +1 -0
- package/lib-amd/components/OptionGroup/OptionGroup.types.js +5 -0
- package/lib-amd/components/OptionGroup/OptionGroup.types.js.map +1 -0
- package/lib-amd/components/OptionGroup/index.js +10 -0
- package/lib-amd/components/OptionGroup/index.js.map +1 -0
- package/lib-amd/components/OptionGroup/renderOptionGroup.js +16 -0
- package/lib-amd/components/OptionGroup/renderOptionGroup.js.map +1 -0
- package/lib-amd/components/OptionGroup/useOptionGroup.js +33 -0
- package/lib-amd/components/OptionGroup/useOptionGroup.js.map +1 -0
- package/lib-amd/components/OptionGroup/useOptionGroupStyles.js +34 -0
- package/lib-amd/components/OptionGroup/useOptionGroupStyles.js.map +1 -0
- package/lib-amd/contexts/ComboboxContext.js +28 -0
- package/lib-amd/contexts/ComboboxContext.js.map +1 -0
- package/lib-amd/contexts/ListboxContext.js +23 -0
- package/lib-amd/contexts/ListboxContext.js.map +1 -0
- package/lib-amd/contexts/useComboboxContextValues.js +23 -0
- package/lib-amd/contexts/useComboboxContextValues.js.map +1 -0
- package/lib-amd/contexts/useListboxContextValues.js +24 -0
- package/lib-amd/contexts/useListboxContextValues.js.map +1 -0
- package/lib-amd/index.js +37 -0
- package/lib-amd/index.js.map +1 -0
- package/lib-amd/utils/ComboboxBase.types.js +5 -0
- package/lib-amd/utils/ComboboxBase.types.js.map +1 -0
- package/lib-amd/utils/OptionCollection.types.js +5 -0
- package/lib-amd/utils/OptionCollection.types.js.map +1 -0
- package/lib-amd/utils/Selection.types.js +5 -0
- package/lib-amd/utils/Selection.types.js.map +1 -0
- package/lib-amd/utils/dropdownKeyActions.js +85 -0
- package/lib-amd/utils/dropdownKeyActions.js.map +1 -0
- package/lib-amd/utils/internalTokens.js +11 -0
- package/lib-amd/utils/internalTokens.js.map +1 -0
- package/lib-amd/utils/useComboboxBaseState.js +76 -0
- package/lib-amd/utils/useComboboxBaseState.js.map +1 -0
- package/lib-amd/utils/useComboboxPopup.js +16 -0
- package/lib-amd/utils/useComboboxPopup.js.map +1 -0
- package/lib-amd/utils/useOptionCollection.js +65 -0
- package/lib-amd/utils/useOptionCollection.js.map +1 -0
- package/lib-amd/utils/useScrollOptionsIntoView.js +33 -0
- package/lib-amd/utils/useScrollOptionsIntoView.js.map +1 -0
- package/lib-amd/utils/useSelection.js +42 -0
- package/lib-amd/utils/useSelection.js.map +1 -0
- package/lib-amd/utils/useTriggerListboxSlots.js +104 -0
- package/lib-amd/utils/useTriggerListboxSlots.js.map +1 -0
- package/lib-commonjs/Combobox.js +0 -2
- package/lib-commonjs/Combobox.js.map +1 -1
- package/lib-commonjs/ComboboxField.js +8 -0
- package/lib-commonjs/ComboboxField.js.map +1 -0
- package/lib-commonjs/Dropdown.js +0 -2
- package/lib-commonjs/Dropdown.js.map +1 -1
- package/lib-commonjs/Listbox.js +0 -2
- package/lib-commonjs/Listbox.js.map +1 -1
- package/lib-commonjs/Option.js +0 -2
- package/lib-commonjs/Option.js.map +1 -1
- package/lib-commonjs/OptionGroup.js +0 -2
- package/lib-commonjs/OptionGroup.js.map +1 -1
- package/lib-commonjs/components/Combobox/Combobox.js +0 -7
- package/lib-commonjs/components/Combobox/Combobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/Combobox.types.js.map +1 -1
- package/lib-commonjs/components/Combobox/index.js +0 -6
- package/lib-commonjs/components/Combobox/index.js.map +1 -1
- package/lib-commonjs/components/Combobox/renderCombobox.js +10 -12
- package/lib-commonjs/components/Combobox/renderCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useCombobox.js +106 -78
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useComboboxStyles.js +245 -189
- package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib-commonjs/components/ComboboxField/ComboboxField.js +14 -0
- package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -0
- package/lib-commonjs/components/ComboboxField/index.js +8 -0
- package/lib-commonjs/components/ComboboxField/index.js.map +1 -0
- package/lib-commonjs/components/Dropdown/Dropdown.js +0 -7
- package/lib-commonjs/components/Dropdown/Dropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/Dropdown.types.js.map +1 -1
- package/lib-commonjs/components/Dropdown/index.js +0 -6
- package/lib-commonjs/components/Dropdown/index.js.map +1 -1
- package/lib-commonjs/components/Dropdown/renderDropdown.js +10 -12
- package/lib-commonjs/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdown.js +25 -47
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js +235 -180
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.js +0 -7
- package/lib-commonjs/components/Listbox/Listbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.types.js.map +1 -1
- package/lib-commonjs/components/Listbox/index.js +0 -6
- package/lib-commonjs/components/Listbox/index.js.map +1 -1
- package/lib-commonjs/components/Listbox/renderListbox.js +2 -7
- package/lib-commonjs/components/Listbox/renderListbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListbox.js +14 -25
- package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListboxStyles.js +16 -24
- package/lib-commonjs/components/Listbox/useListboxStyles.js.map +1 -1
- package/lib-commonjs/components/Option/Option.js +0 -6
- package/lib-commonjs/components/Option/Option.js.map +1 -1
- package/lib-commonjs/components/Option/Option.types.js.map +1 -1
- package/lib-commonjs/components/Option/index.js +0 -6
- package/lib-commonjs/components/Option/index.js.map +1 -1
- package/lib-commonjs/components/Option/renderOption.js +4 -7
- package/lib-commonjs/components/Option/renderOption.js.map +1 -1
- package/lib-commonjs/components/Option/useOption.js +45 -45
- package/lib-commonjs/components/Option/useOption.js.map +1 -1
- package/lib-commonjs/components/Option/useOptionStyles.js +101 -83
- package/lib-commonjs/components/Option/useOptionStyles.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.js +0 -6
- package/lib-commonjs/components/OptionGroup/OptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.types.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/index.js +0 -6
- package/lib-commonjs/components/OptionGroup/index.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/renderOptionGroup.js +4 -7
- package/lib-commonjs/components/OptionGroup/renderOptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroup.js +0 -4
- package/lib-commonjs/components/OptionGroup/useOptionGroup.js.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js +29 -38
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.js.map +1 -1
- package/lib-commonjs/contexts/ComboboxContext.js +10 -14
- package/lib-commonjs/contexts/ComboboxContext.js.map +1 -1
- package/lib-commonjs/contexts/ListboxContext.js +8 -12
- package/lib-commonjs/contexts/ListboxContext.js.map +1 -1
- package/lib-commonjs/contexts/useComboboxContextValues.js +0 -2
- package/lib-commonjs/contexts/useComboboxContextValues.js.map +1 -1
- package/lib-commonjs/contexts/useListboxContextValues.js +2 -6
- package/lib-commonjs/contexts/useListboxContextValues.js.map +1 -1
- package/lib-commonjs/index.js +43 -11
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/ComboboxBase.types.js.map +1 -1
- package/lib-commonjs/utils/OptionCollection.types.js.map +1 -1
- package/lib-commonjs/utils/Selection.types.js.map +1 -1
- package/lib-commonjs/utils/dropdownKeyActions.js +12 -37
- package/lib-commonjs/utils/dropdownKeyActions.js.map +1 -1
- package/lib-commonjs/utils/internalTokens.js.map +1 -1
- package/lib-commonjs/utils/useComboboxBaseState.js +29 -36
- package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
- package/lib-commonjs/utils/useComboboxPopup.js +6 -8
- package/lib-commonjs/utils/useComboboxPopup.js.map +1 -1
- package/lib-commonjs/utils/useOptionCollection.js +13 -26
- package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
- package/lib-commonjs/utils/useScrollOptionsIntoView.js +43 -0
- package/lib-commonjs/utils/useScrollOptionsIntoView.js.map +1 -0
- package/lib-commonjs/utils/useSelection.js +9 -15
- package/lib-commonjs/utils/useSelection.js.map +1 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js +33 -44
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
- package/package.json +23 -22
- package/Spec-migration.md +0 -13
- package/Spec.md +0 -520
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,SAASC,0BAA0B,QAAQ,qBAAqB;AAEhE,SAASC,wBAAwB,QAAQ,yCAAyC;AAGlF;;;AAGA,OAAO,MAAMC,QAAQ,gBAAuCL,KAAK,CAACM,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAC1F,MAAMC,KAAK,GAAGR,oBAAoB,CAACM,KAAK,EAAEC,GAAG,CAAC;EAC9C,MAAME,aAAa,GAAGN,wBAAwB,CAACK,KAAK,CAAC;EAErDN,0BAA0B,CAACM,KAAK,CAAC;EACjC,OAAOP,uBAAuB,CAACO,KAAK,EAAEC,aAAa,CAAC;AACtD,CAAC,CAAC;AAEFL,QAAQ,CAACM,WAAW,GAAG,UAAU","names":["React","useDropdown_unstable","renderDropdown_unstable","useDropdownStyles_unstable","useComboboxContextValues","Dropdown","forwardRef","props","ref","state","contextValues","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,"file":"Dropdown.types.js","sourceRoot":"../src/","sources":["components/Dropdown/Dropdown.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type {\n ComboboxBaseContextValues,\n ComboboxBaseOpenChangeData,\n ComboboxBaseOpenEvents,\n ComboboxBaseProps,\n ComboboxBaseState,\n} from '../../utils/ComboboxBase.types';\nimport { Listbox } from '../Listbox/Listbox';\n\nexport type DropdownSlots = {\n /* The root dropdown slot */\n root: NonNullable<Slot<'div'>>;\n\n /* The dropdown arrow icon */\n expandIcon: Slot<'span'>;\n\n /* The primary slot, the element with role=\"combobox\" */\n button: NonNullable<Slot<'button'>>;\n\n /* The dropdown listbox slot */\n listbox?: Slot<typeof Listbox>;\n};\n\n/**\n * Dropdown Props\n */\nexport type DropdownProps = ComponentProps<Partial<DropdownSlots>, 'button'> & ComboboxBaseProps;\n\n/**\n * State used in rendering Dropdown\n */\nexport type DropdownState = ComponentState<DropdownSlots> &\n ComboboxBaseState & {\n /* Whether the placeholder is currently displayed */\n placeholderVisible: boolean;\n };\n\n/* Export types defined in ComboboxBase */\nexport type DropdownContextValues = ComboboxBaseContextValues;\nexport type DropdownOpenEvents = ComboboxBaseOpenEvents;\nexport type DropdownOpenChangeData = ComboboxBaseOpenChangeData;\n"]}
|
|
1
|
+
{"version":3,"file":"Dropdown.types.js","sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Dropdown/Dropdown.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type {\n ComboboxBaseContextValues,\n ComboboxBaseOpenChangeData,\n ComboboxBaseOpenEvents,\n ComboboxBaseProps,\n ComboboxBaseState,\n} from '../../utils/ComboboxBase.types';\nimport { Listbox } from '../Listbox/Listbox';\n\nexport type DropdownSlots = {\n /* The root dropdown slot */\n root: NonNullable<Slot<'div'>>;\n\n /* The dropdown arrow icon */\n expandIcon: Slot<'span'>;\n\n /* The primary slot, the element with role=\"combobox\" */\n button: NonNullable<Slot<'button'>>;\n\n /* The dropdown listbox slot */\n listbox?: Slot<typeof Listbox>;\n};\n\n/**\n * Dropdown Props\n */\nexport type DropdownProps = ComponentProps<Partial<DropdownSlots>, 'button'> & ComboboxBaseProps;\n\n/**\n * State used in rendering Dropdown\n */\nexport type DropdownState = ComponentState<DropdownSlots> &\n ComboboxBaseState & {\n /* Whether the placeholder is currently displayed */\n placeholderVisible: boolean;\n };\n\n/* Export types defined in ComboboxBase */\nexport type DropdownContextValues = ComboboxBaseContextValues;\nexport type DropdownOpenEvents = ComboboxBaseOpenEvents;\nexport type DropdownOpenChangeData = ComboboxBaseOpenChangeData;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Dropdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './Dropdown';\nexport * from './Dropdown.types';\nexport * from './renderDropdown';\nexport * from './useDropdown';\nexport * from './useDropdownStyles';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["packages/react-components/react-combobox/src/components/Dropdown/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC","sourcesContent":["export * from './Dropdown';\nexport * from './Dropdown.types';\nexport * from './renderDropdown';\nexport * from './useDropdown';\nexport * from './useDropdownStyles';\n"]}
|
|
@@ -5,19 +5,23 @@ import { ComboboxContext } from '../../contexts/ComboboxContext';
|
|
|
5
5
|
/**
|
|
6
6
|
* Render the final JSX of Dropdown
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
8
|
export const renderDropdown_unstable = (state, contextValues) => {
|
|
10
9
|
const {
|
|
11
10
|
slots,
|
|
12
11
|
slotProps
|
|
13
12
|
} = getSlots(state);
|
|
14
|
-
return /*#__PURE__*/React.createElement(slots.root, {
|
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, {
|
|
14
|
+
...slotProps.root
|
|
15
15
|
}, /*#__PURE__*/React.createElement(ComboboxContext.Provider, {
|
|
16
16
|
value: contextValues.combobox
|
|
17
|
-
}, /*#__PURE__*/React.createElement(slots.button, {
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
17
|
+
}, /*#__PURE__*/React.createElement(slots.button, {
|
|
18
|
+
...slotProps.button
|
|
19
|
+
}, slotProps.button.children, slots.expandIcon && /*#__PURE__*/React.createElement(slots.expandIcon, {
|
|
20
|
+
...slotProps.expandIcon
|
|
21
|
+
})), slots.listbox && (state.inlinePopup ? /*#__PURE__*/React.createElement(slots.listbox, {
|
|
22
|
+
...slotProps.listbox
|
|
23
|
+
}) : /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(slots.listbox, {
|
|
24
|
+
...slotProps.listbox
|
|
21
25
|
})))));
|
|
22
26
|
};
|
|
23
27
|
//# sourceMappingURL=renderDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,QAAQ,QAAQ,2BAA2B;AACpD,SAASC,eAAe,QAAQ,gCAAgC;AAGhE;;;AAGA,OAAO,MAAMC,uBAAuB,GAAG,CAACC,KAAoB,EAAEC,aAAoC,KAAI;EACpG,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGN,QAAQ,CAAgBG,KAAK,CAAC;EAE3D,oBACEL,oBAACO,KAAK,CAACE,IAAI;IAAA,GAAKD,SAAS,CAACC;EAAI,gBAC5BT,oBAACG,eAAe,CAACO,QAAQ;IAACC,KAAK,EAAEL,aAAa,CAACM;EAAQ,gBACrDZ,oBAACO,KAAK,CAACM,MAAM;IAAA,GAAKL,SAAS,CAACK;EAAM,GAC/BL,SAAS,CAACK,MAAM,CAACC,QAAQ,EACzBP,KAAK,CAACQ,UAAU,iBAAIf,oBAACO,KAAK,CAACQ,UAAU;IAAA,GAAKP,SAAS,CAACO;EAAU,EAAI,CACtD,EACdR,KAAK,CAACS,OAAO,KACXX,KAAK,CAACY,WAAW,gBAChBjB,oBAACO,KAAK,CAACS,OAAO;IAAA,GAAKR,SAAS,CAACQ;EAAO,EAAI,gBAExChB,oBAACC,MAAM,qBACLD,oBAACO,KAAK,CAACS,OAAO;IAAA,GAAKR,SAAS,CAACQ;EAAO,EAAI,CAE3C,CAAC,CACqB,CAChB;AAEjB,CAAC","names":["React","Portal","getSlots","ComboboxContext","renderDropdown_unstable","state","contextValues","slots","slotProps","root","Provider","value","combobox","button","children","expandIcon","listbox","inlinePopup"],"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"]}
|
|
@@ -3,8 +3,8 @@ import { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';
|
|
|
3
3
|
import { getPartitionedNativeProps, mergeCallbacks, resolveShorthand, useTimeout } from '@fluentui/react-utilities';
|
|
4
4
|
import { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';
|
|
5
5
|
import { useComboboxBaseState } from '../../utils/useComboboxBaseState';
|
|
6
|
-
import { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';
|
|
7
6
|
import { useComboboxPopup } from '../../utils/useComboboxPopup';
|
|
7
|
+
import { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';
|
|
8
8
|
import { Listbox } from '../Listbox/Listbox';
|
|
9
9
|
import { useMergedRefs } from '@fluentui/react-utilities';
|
|
10
10
|
/**
|
|
@@ -16,13 +16,12 @@ import { useMergedRefs } from '@fluentui/react-utilities';
|
|
|
16
16
|
* @param props - props from this instance of Dropdown
|
|
17
17
|
* @param ref - reference to root HTMLElement of Dropdown
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
19
|
export const useDropdown_unstable = (props, ref) => {
|
|
21
20
|
const baseState = useComboboxBaseState(props);
|
|
22
21
|
const {
|
|
23
22
|
activeOption,
|
|
24
23
|
getIndexOfId,
|
|
25
|
-
|
|
24
|
+
getOptionsMatchingText,
|
|
26
25
|
open,
|
|
27
26
|
setActiveOption,
|
|
28
27
|
setFocusVisible,
|
|
@@ -35,78 +34,67 @@ export const useDropdown_unstable = (props, ref) => {
|
|
|
35
34
|
props,
|
|
36
35
|
primarySlotTagName: 'button',
|
|
37
36
|
excludedPropNames: ['children']
|
|
38
|
-
});
|
|
39
|
-
|
|
37
|
+
});
|
|
38
|
+
// set listbox popup width based off the root/trigger width
|
|
40
39
|
const rootRef = React.useRef(null);
|
|
41
40
|
const [popupWidth, setPopupWidth] = React.useState();
|
|
42
41
|
React.useEffect(() => {
|
|
43
42
|
var _a;
|
|
44
|
-
|
|
45
43
|
const width = open ? `${(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px` : undefined;
|
|
46
44
|
setPopupWidth(width);
|
|
47
|
-
}, [open]);
|
|
48
|
-
|
|
45
|
+
}, [open]);
|
|
46
|
+
// jump to matching option based on typing
|
|
49
47
|
const searchString = React.useRef('');
|
|
50
48
|
const [setKeyTimeout, clearKeyTimeout] = useTimeout();
|
|
51
|
-
|
|
52
49
|
const getNextMatchingOption = () => {
|
|
53
|
-
var _a;
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
var _a;
|
|
51
|
+
// first check for matches for the full searchString
|
|
56
52
|
let matcher = optionValue => optionValue.toLowerCase().indexOf(searchString.current) === 0;
|
|
57
|
-
|
|
58
|
-
let
|
|
59
|
-
|
|
53
|
+
let matches = getOptionsMatchingText(matcher);
|
|
54
|
+
let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
|
|
55
|
+
// if the dropdown is already open and the searchstring is a single character,
|
|
60
56
|
// then look after the current activeOption for letters
|
|
61
57
|
// this is so slowly typing the same letter will cycle through matches
|
|
62
|
-
|
|
63
58
|
if (open && searchString.current.length === 1) {
|
|
64
59
|
startIndex++;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
}
|
|
61
|
+
// if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
|
|
68
62
|
if (!matches.length) {
|
|
69
63
|
const letters = searchString.current.split('');
|
|
70
|
-
const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);
|
|
71
|
-
|
|
64
|
+
const allSameLetter = letters.length && letters.every(letter => letter === letters[0]);
|
|
65
|
+
// if the search is all the same letter, cycle through options starting with that letter
|
|
72
66
|
if (allSameLetter) {
|
|
73
67
|
startIndex++;
|
|
74
|
-
|
|
75
68
|
matcher = optionValue => optionValue.toLowerCase().indexOf(letters[0]) === 0;
|
|
76
|
-
|
|
77
|
-
matches = getOptionsMatchingValue(matcher);
|
|
69
|
+
matches = getOptionsMatchingText(matcher);
|
|
78
70
|
}
|
|
79
|
-
}
|
|
71
|
+
}
|
|
72
|
+
// if there is an active option and multiple matches,
|
|
80
73
|
// return first matching option after the current active option, looping back to the top
|
|
81
|
-
|
|
82
|
-
|
|
83
74
|
if (matches.length > 1 && activeOption) {
|
|
84
75
|
const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);
|
|
85
76
|
return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
|
|
86
77
|
}
|
|
87
|
-
|
|
88
78
|
return (_a = matches[0]) !== null && _a !== void 0 ? _a : undefined;
|
|
89
79
|
};
|
|
90
|
-
|
|
91
80
|
const onTriggerKeyDown = ev => {
|
|
92
81
|
// clear timeout, if it exists
|
|
93
|
-
clearKeyTimeout();
|
|
94
|
-
|
|
82
|
+
clearKeyTimeout();
|
|
83
|
+
// if the key was a char key, update search string
|
|
95
84
|
if (getDropdownActionFromKey(ev) === 'Type') {
|
|
96
85
|
// update search string
|
|
97
86
|
searchString.current += ev.key.toLowerCase();
|
|
98
87
|
setKeyTimeout(() => {
|
|
99
88
|
searchString.current = '';
|
|
100
|
-
}, 500);
|
|
101
|
-
|
|
89
|
+
}, 500);
|
|
90
|
+
// update state
|
|
102
91
|
!open && setOpen(ev, true);
|
|
103
92
|
const nextOption = getNextMatchingOption();
|
|
104
93
|
setActiveOption(nextOption);
|
|
105
94
|
setFocusVisible(true);
|
|
106
95
|
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
|
|
96
|
+
};
|
|
97
|
+
// resolve button and listbox slot props
|
|
110
98
|
let triggerSlot;
|
|
111
99
|
let listboxSlot;
|
|
112
100
|
triggerSlot = resolveShorthand(props.button, {
|
|
@@ -139,6 +127,7 @@ export const useDropdown_unstable = (props, ref) => {
|
|
|
139
127
|
root: resolveShorthand(props.root, {
|
|
140
128
|
required: true,
|
|
141
129
|
defaultProps: {
|
|
130
|
+
'aria-owns': !props.inlinePopup ? listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.id : undefined,
|
|
142
131
|
children: props.children,
|
|
143
132
|
...rootNativeProps
|
|
144
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["components/Dropdown/useDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,kBAAkB,IAAI,eAA/B,QAAsD,uBAAtD;AACA,SAAS,yBAAT,EAAoC,cAApC,EAAoD,gBAApD,EAAsE,UAAtE,QAAwF,2BAAxF;AACA,SAAS,wBAAT,QAAyC,gCAAzC;AACA,SAAS,oBAAT,QAAqC,kCAArC;AACA,SAAS,sBAAT,QAAuC,oCAAvC;AACA,SAAS,gBAAT,QAAiC,8BAAjC;AACA,SAAS,OAAT,QAAwB,oBAAxB;AAIA,SAAS,aAAT,QAA8B,2BAA9B;AAEA;;;;;;;;AAQG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAAC,KAAD,EAAuB,GA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MAGV,UAAU,EAAE,MAHF;MAIV,OAAO,EAAE;IAJC,CADe;IAO3B,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,IAAP,EAAa;MACjC,QAAQ,EAAE,IADuB;MAEjC,YAAY,EAAE;QACZ,QAAQ,EAAE,KAAK,CAAC,QADJ;QAEZ,GAAG;MAFS;IAFmB,CAAb,CAPK;IAc3B,MAAM,EAAE,WAdmB;IAe3B,OAAO,EAAE,WAfkB;IAgB3B,UAAU,EAAE,gBAAgB,CAAC,KAAK,CAAC,UAAP,EAAmB;MAC7C,QAAQ,EAAE,IADmC;MAE7C,YAAY,EAAE;QACZ,QAAQ,eAAE,KAAA,CAAA,aAAA,CAAC,eAAD,EAAgB,IAAhB;MADE;IAF+B,CAAnB,CAhBD;IAsB3B,kBAAkB,EAAE,CAAC,SAAS,CAAC,KAAX,IAAoB,CAAC,CAAC,KAAK,CAAC,WAtBrB;IAuB3B,GAAG;EAvBwB,CAA7B;EA0BA,KAAK,CAAC,IAAN,CAAW,GAAX,GAAiB,aAAa,CAAC,KAAK,CAAC,IAAN,CAAW,GAAZ,EAAiB,OAAjB,CAA9B;EAEA,OAAO,KAAP;AACD,CAjJM","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 { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\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 getOptionsMatchingValue,\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 = getOptionsMatchingValue(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 = getOptionsMatchingValue(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,OAAO,KAAKA,KA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f,CAACyB,WAAW,EAAEC,WAAW,CAAC,GAAGxD,gBAAgB,CAACK,KAAK,EAAEkD,WAAW,EAAEC,WAAW,CAAC;EAC9E,CAACD,WAAW,EAAEC,WAAW,CAAC,GAAGvD,sBAAsB,CAACI,KAAK,EAAEE,SAAS,EAAED,GAAG,EAAEiD,WAAW,EAAEC,WAAW,CAAC;EAEpG,MAAMY,KAAK,GAAkB;IAC3BC,UAAU,EAAE;MACVpD,IAAI,EAAE,KAAK;MACXwC,MAAM,EAAE,QAAQ;MAChBa,UAAU,EAAE,MAAM;MAClBJ,OAAO,EAAEhE;KACV;IACDe,IAAI,EAAErB,gBAAgB,CAACS,KAAK,CAACY,IAAI,EAAE;MACjCyC,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZ,WAAW,EAAE,CAACtD,KAAK,CAACkE,WAAW,GAAGf,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEf,EAAE,GAAGX,SAAS;QAC7D+B,QAAQ,EAAExD,KAAK,CAACwD,QAAQ;QACxB,GAAG3C;;KAEN,CAAC;IACFuC,MAAM,EAAEF,WAAW;IACnBW,OAAO,EAAEV,WAAW;IACpBc,UAAU,EAAE1E,gBAAgB,CAACS,KAAK,CAACiE,UAAU,EAAE;MAC7CZ,QAAQ,EAAE,IAAI;MACdC,YAAY,EAAE;QACZE,QAAQ,eAAEtE,oBAACE,eAAe;;KAE7B,CAAC;IACF+E,kBAAkB,EAAE,CAACjE,SAAS,CAACuD,KAAK,IAAI,CAAC,CAACzD,KAAK,CAAC0D,WAAW;IAC3D,GAAGxD;GACJ;EAED6D,KAAK,CAACnD,IAAI,CAACX,GAAG,GAAGH,aAAa,CAACiE,KAAK,CAACnD,IAAI,CAACX,GAAG,EAAEe,OAAO,CAAC;EAEvD,OAAO+C,KAAK;AACd,CAAC","names":["React","ChevronDownRegular","ChevronDownIcon","getPartitionedNativeProps","mergeCallbacks","resolveShorthand","useTimeout","getDropdownActionFromKey","useComboboxBaseState","useComboboxPopup","useTriggerListboxSlots","Listbox","useMergedRefs","useDropdown_unstable","props","ref","baseState","activeOption","getIndexOfId","getOptionsMatchingText","open","setActiveOption","setFocusVisible","setOpen","primary","triggerNativeProps","root","rootNativeProps","primarySlotTagName","excludedPropNames","rootRef","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","key","nextOption","triggerSlot","listboxSlot","button","required","defaultProps","type","children","value","placeholder","onKeyDown","hasFocus","listbox","style","state","components","expandIcon","inlinePopup","placeholderVisible"],"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 'aria-owns': !props.inlinePopup ? listboxSlot?.id : undefined,\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"]}
|