@fluentui/react-combobox 9.17.7 → 9.17.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -2
- package/dist/index.d.cts +30 -0
- package/dist/index.d.ts +30 -0
- 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 +2 -2
- package/lib/components/Combobox/renderCombobox.js.map +1 -1
- package/lib/components/Combobox/useCombobox.js +62 -42
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Combobox/useComboboxExpandIconSlot.js +40 -0
- package/lib/components/Combobox/useComboboxExpandIconSlot.js.map +1 -0
- package/lib/components/Combobox/useComboboxStyles.styles.js +2 -2
- package/lib/components/Combobox/useComboboxStyles.styles.js.map +1 -1
- package/lib/components/Combobox/useComboboxStyles.styles.raw.js +2 -3
- package/lib/components/Combobox/useComboboxStyles.styles.raw.js.map +1 -1
- package/lib/components/Combobox/useInputTriggerSlot.js +3 -2
- package/lib/components/Combobox/useInputTriggerSlot.js.map +1 -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 +2 -2
- package/lib/components/Dropdown/renderDropdown.js.map +1 -1
- package/lib/components/Dropdown/useButtonTriggerSlot.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +5 -7
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdownStyles.styles.js +2 -2
- package/lib/components/Dropdown/useDropdownStyles.styles.js.map +1 -1
- package/lib/components/Dropdown/useDropdownStyles.styles.raw.js +2 -3
- package/lib/components/Dropdown/useDropdownStyles.styles.raw.js.map +1 -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.map +1 -1
- package/lib/components/Listbox/useListboxStyles.styles.raw.js.map +1 -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 +2 -2
- package/lib/components/Option/renderOption.js.map +1 -1
- package/lib/components/Option/useOption.js +1 -2
- package/lib/components/Option/useOption.js.map +1 -1
- package/lib/components/Option/useOptionStyles.styles.js +2 -2
- package/lib/components/Option/useOptionStyles.styles.js.map +1 -1
- package/lib/components/Option/useOptionStyles.styles.raw.js +1 -1
- package/lib/components/Option/useOptionStyles.styles.raw.js.map +1 -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 +2 -2
- package/lib/components/OptionGroup/renderOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroup.js.map +1 -1
- package/lib/components/OptionGroup/useOptionGroupStyles.styles.raw.js.map +1 -1
- package/lib/contexts/ComboboxContext.js.map +1 -1
- package/lib/contexts/ListboxContext.js.map +1 -1
- package/lib/contexts/useComboboxContextValues.js.map +1 -1
- package/lib/contexts/useListboxContextValues.js.map +1 -1
- package/lib/hooks/useComboboxFilter.js.map +1 -1
- package/lib/hooks/useTabsterEscapeIgnore.js.map +1 -1
- package/lib/index.js +1 -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.map +1 -1
- package/lib/utils/internalTokens.js.map +1 -1
- package/lib/utils/isComboboxOptionElement.js.map +1 -1
- package/lib/utils/useComboboxBaseState.js +5 -4
- package/lib/utils/useComboboxBaseState.js.map +1 -1
- package/lib/utils/useComboboxPositioning.js.map +1 -1
- package/lib/utils/useListboxSlot.js.map +1 -1
- package/lib/utils/useOptionCollection.js.map +1 -1
- package/lib/utils/useSelection.js.map +1 -1
- package/lib/utils/useTriggerSlot.js +6 -3
- package/lib/utils/useTriggerSlot.js.map +1 -1
- package/lib-commonjs/Combobox.cjs +7 -7
- package/lib-commonjs/Dropdown.cjs +7 -7
- package/lib-commonjs/Listbox.cjs +6 -6
- package/lib-commonjs/Option.cjs +7 -7
- package/lib-commonjs/OptionGroup.cjs +6 -6
- package/lib-commonjs/components/Combobox/Combobox.cjs.map +1 -1
- package/lib-commonjs/components/Combobox/Combobox.types.cjs.map +1 -1
- package/lib-commonjs/components/Combobox/index.cjs +7 -7
- package/lib-commonjs/components/Combobox/index.cjs.map +1 -1
- package/lib-commonjs/components/Combobox/renderCombobox.cjs.map +1 -1
- package/lib-commonjs/components/Combobox/useCombobox.cjs +62 -44
- package/lib-commonjs/components/Combobox/useCombobox.cjs.map +1 -1
- package/lib-commonjs/components/Combobox/useComboboxExpandIconSlot.cjs +46 -0
- package/lib-commonjs/components/Combobox/useComboboxExpandIconSlot.cjs.map +1 -0
- package/lib-commonjs/components/Combobox/useComboboxStyles.styles.cjs +5 -5
- package/lib-commonjs/components/Combobox/useComboboxStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/Combobox/useComboboxStyles.styles.raw.cjs +5 -6
- package/lib-commonjs/components/Combobox/useComboboxStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/Combobox/useInputTriggerSlot.cjs +3 -2
- package/lib-commonjs/components/Combobox/useInputTriggerSlot.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/Dropdown.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/Dropdown.types.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/index.cjs +7 -7
- package/lib-commonjs/components/Dropdown/index.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/renderDropdown.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/useButtonTriggerSlot.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdown.cjs +8 -10
- package/lib-commonjs/components/Dropdown/useDropdown.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.styles.cjs +5 -5
- package/lib-commonjs/components/Dropdown/useDropdownStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.styles.raw.cjs +5 -6
- package/lib-commonjs/components/Dropdown/useDropdownStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.cjs.map +1 -1
- package/lib-commonjs/components/Listbox/Listbox.types.cjs.map +1 -1
- package/lib-commonjs/components/Listbox/index.cjs +6 -6
- package/lib-commonjs/components/Listbox/index.cjs.map +1 -1
- package/lib-commonjs/components/Listbox/renderListbox.cjs.map +1 -1
- package/lib-commonjs/components/Listbox/useListbox.cjs.map +1 -1
- package/lib-commonjs/components/Listbox/useListboxStyles.styles.cjs +3 -3
- package/lib-commonjs/components/Listbox/useListboxStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/Listbox/useListboxStyles.styles.raw.cjs +3 -3
- package/lib-commonjs/components/Listbox/useListboxStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/Option/Option.cjs.map +1 -1
- package/lib-commonjs/components/Option/Option.types.cjs.map +1 -1
- package/lib-commonjs/components/Option/index.cjs +7 -7
- package/lib-commonjs/components/Option/index.cjs.map +1 -1
- package/lib-commonjs/components/Option/renderOption.cjs.map +1 -1
- package/lib-commonjs/components/Option/useOption.cjs +4 -5
- package/lib-commonjs/components/Option/useOption.cjs.map +1 -1
- package/lib-commonjs/components/Option/useOptionStyles.styles.cjs +5 -5
- package/lib-commonjs/components/Option/useOptionStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/Option/useOptionStyles.styles.raw.cjs +4 -4
- package/lib-commonjs/components/Option/useOptionStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.cjs.map +1 -1
- package/lib-commonjs/components/OptionGroup/OptionGroup.types.cjs.map +1 -1
- package/lib-commonjs/components/OptionGroup/index.cjs +6 -6
- package/lib-commonjs/components/OptionGroup/index.cjs.map +1 -1
- package/lib-commonjs/components/OptionGroup/renderOptionGroup.cjs.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroup.cjs.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.styles.cjs +3 -3
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.styles.cjs.map +1 -1
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.styles.raw.cjs +3 -3
- package/lib-commonjs/components/OptionGroup/useOptionGroupStyles.styles.raw.cjs.map +1 -1
- package/lib-commonjs/contexts/ComboboxContext.cjs +3 -3
- package/lib-commonjs/contexts/ComboboxContext.cjs.map +1 -1
- package/lib-commonjs/contexts/ListboxContext.cjs +4 -4
- package/lib-commonjs/contexts/ListboxContext.cjs.map +1 -1
- package/lib-commonjs/contexts/useComboboxContextValues.cjs.map +1 -1
- package/lib-commonjs/contexts/useListboxContextValues.cjs.map +1 -1
- package/lib-commonjs/hooks/useComboboxFilter.cjs.map +1 -1
- package/lib-commonjs/hooks/useTabsterEscapeIgnore.cjs.map +1 -1
- package/lib-commonjs/index.cjs +44 -40
- package/lib-commonjs/index.cjs.map +1 -1
- package/lib-commonjs/utils/ComboboxBase.types.cjs.map +1 -1
- package/lib-commonjs/utils/OptionCollection.types.cjs.map +1 -1
- package/lib-commonjs/utils/Selection.types.cjs.map +1 -1
- package/lib-commonjs/utils/dropdownKeyActions.cjs.map +1 -1
- package/lib-commonjs/utils/internalTokens.cjs.map +1 -1
- package/lib-commonjs/utils/isComboboxOptionElement.cjs.map +1 -1
- package/lib-commonjs/utils/useComboboxBaseState.cjs +5 -4
- package/lib-commonjs/utils/useComboboxBaseState.cjs.map +1 -1
- package/lib-commonjs/utils/useComboboxPositioning.cjs.map +1 -1
- package/lib-commonjs/utils/useListboxSlot.cjs.map +1 -1
- package/lib-commonjs/utils/useOptionCollection.cjs.map +1 -1
- package/lib-commonjs/utils/useSelection.cjs.map +1 -1
- package/lib-commonjs/utils/useTriggerSlot.cjs +6 -3
- package/lib-commonjs/utils/useTriggerSlot.cjs.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-combobox
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Tue, 10 Nov 2026 16:49:10 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.17.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.17.9)
|
|
8
|
+
|
|
9
|
+
Tue, 10 Nov 2026 16:49:10 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- fix: apply icon sizing and layout styles to font glyphs as well as SVG icons ([PR #36958](https://github.com/microsoft/fluentui/pull/36958) by martinhochel@microsoft.com)
|
|
14
|
+
|
|
15
|
+
## [9.17.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.17.8)
|
|
16
|
+
|
|
17
|
+
Mon, 19 Oct 2026 16:49:01 GMT
|
|
18
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.17.7..@fluentui/react-combobox_v9.17.8)
|
|
19
|
+
|
|
20
|
+
### Patches
|
|
21
|
+
|
|
22
|
+
- fix: make the Combobox expand icon keyboard- and click-operable without duplicate pointer toggles or hidden, missing-icon, or duplicate blur interactions ([PR #36574](https://github.com/microsoft/fluentui/pull/36574) by dmytrokirpa@microsoft.com)
|
|
23
|
+
- Bump @fluentui/react-aria to v9.17.16 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
24
|
+
- Bump @fluentui/react-context-selector to v9.2.21 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
25
|
+
- Bump @fluentui/react-field to v9.5.6 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
26
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.7 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
27
|
+
- Bump @fluentui/react-portal to v9.8.17 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
28
|
+
- Bump @fluentui/react-positioning to v9.23.4 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
29
|
+
- Bump @fluentui/react-tabster to v9.26.19 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
30
|
+
- Bump @fluentui/react-utilities to v9.27.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
|
|
31
|
+
|
|
7
32
|
## [9.17.7](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.17.7)
|
|
8
33
|
|
|
9
|
-
Wed, 23 Sep 2026 09:
|
|
34
|
+
Wed, 23 Sep 2026 09:04:33 GMT
|
|
10
35
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.17.6..@fluentui/react-combobox_v9.17.7)
|
|
11
36
|
|
|
12
37
|
### Patches
|
package/dist/index.d.cts
CHANGED
|
@@ -597,6 +597,28 @@ export declare const useComboboxBaseState: (props: ComboboxBaseProps & {
|
|
|
597
597
|
|
|
598
598
|
export declare function useComboboxContextValues(state: Omit<ComboboxBaseState, 'freeform'> & Pick<ComboboxState, 'activeDescendantController'>): ComboboxBaseContextValues;
|
|
599
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Creates the `expandIcon` slot of a combobox: button semantics plus the default accessible name.
|
|
602
|
+
*
|
|
603
|
+
* @internal
|
|
604
|
+
*/
|
|
605
|
+
export declare function useComboboxExpandIconSlot(expandIconFromProps: Slot<'span'> | undefined | null, options: UseComboboxExpandIconSlotOptions): SlotComponentType<ExtractSlotProps<Slot<'span'>>> | undefined;
|
|
606
|
+
|
|
607
|
+
declare type UseComboboxExpandIconSlotOptions = {
|
|
608
|
+
/** Whether the combobox trigger is disabled. */
|
|
609
|
+
disabled?: boolean;
|
|
610
|
+
/** Whether the expand icon is visually hidden by the clear icon. */
|
|
611
|
+
hideFromTabOrder?: boolean;
|
|
612
|
+
/** Whether the listbox is currently open. */
|
|
613
|
+
open: boolean;
|
|
614
|
+
/** `aria-label` passed to the combobox. */
|
|
615
|
+
'aria-label'?: string;
|
|
616
|
+
/** `aria-labelledby` passed to the combobox. */
|
|
617
|
+
'aria-labelledby'?: string;
|
|
618
|
+
/** `aria-labelledby` of the resolved input trigger, used to build the labelling chain. */
|
|
619
|
+
triggerLabelledBy?: string;
|
|
620
|
+
};
|
|
621
|
+
|
|
600
622
|
/**
|
|
601
623
|
* @internal
|
|
602
624
|
*/
|
|
@@ -666,6 +688,7 @@ declare type UseInputTriggerSlotOptions = {
|
|
|
666
688
|
freeform: boolean | undefined;
|
|
667
689
|
defaultProps?: Partial<ComboboxProps>;
|
|
668
690
|
activeDescendantController: ActiveDescendantImperativeRef;
|
|
691
|
+
shouldCloseOnBlur?: UseTriggerSlotOptions['shouldCloseOnBlur'];
|
|
669
692
|
};
|
|
670
693
|
|
|
671
694
|
/**
|
|
@@ -742,6 +765,13 @@ export declare const useOptionGroupStyles_unstable: (state: OptionGroupState) =>
|
|
|
742
765
|
*/
|
|
743
766
|
export declare const useOptionStyles_unstable: (state: OptionState) => OptionState;
|
|
744
767
|
|
|
768
|
+
declare type UseTriggerSlotOptions = {
|
|
769
|
+
state: UseTriggerSlotState;
|
|
770
|
+
defaultProps: unknown;
|
|
771
|
+
activeDescendantController: ActiveDescendantImperativeRef;
|
|
772
|
+
shouldCloseOnBlur?: (event: React_2.FocusEvent<HTMLButtonElement> & React_2.FocusEvent<HTMLInputElement>) => boolean;
|
|
773
|
+
};
|
|
774
|
+
|
|
745
775
|
declare type UseTriggerSlotState = Pick<ComboboxBaseState, 'open' | 'getOptionById' | 'selectOption' | 'setOpen' | 'multiselect' | 'setHasFocus'>;
|
|
746
776
|
|
|
747
777
|
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -597,6 +597,28 @@ export declare const useComboboxBaseState: (props: ComboboxBaseProps & {
|
|
|
597
597
|
|
|
598
598
|
export declare function useComboboxContextValues(state: Omit<ComboboxBaseState, 'freeform'> & Pick<ComboboxState, 'activeDescendantController'>): ComboboxBaseContextValues;
|
|
599
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Creates the `expandIcon` slot of a combobox: button semantics plus the default accessible name.
|
|
602
|
+
*
|
|
603
|
+
* @internal
|
|
604
|
+
*/
|
|
605
|
+
export declare function useComboboxExpandIconSlot(expandIconFromProps: Slot<'span'> | undefined | null, options: UseComboboxExpandIconSlotOptions): SlotComponentType<ExtractSlotProps<Slot<'span'>>> | undefined;
|
|
606
|
+
|
|
607
|
+
declare type UseComboboxExpandIconSlotOptions = {
|
|
608
|
+
/** Whether the combobox trigger is disabled. */
|
|
609
|
+
disabled?: boolean;
|
|
610
|
+
/** Whether the expand icon is visually hidden by the clear icon. */
|
|
611
|
+
hideFromTabOrder?: boolean;
|
|
612
|
+
/** Whether the listbox is currently open. */
|
|
613
|
+
open: boolean;
|
|
614
|
+
/** `aria-label` passed to the combobox. */
|
|
615
|
+
'aria-label'?: string;
|
|
616
|
+
/** `aria-labelledby` passed to the combobox. */
|
|
617
|
+
'aria-labelledby'?: string;
|
|
618
|
+
/** `aria-labelledby` of the resolved input trigger, used to build the labelling chain. */
|
|
619
|
+
triggerLabelledBy?: string;
|
|
620
|
+
};
|
|
621
|
+
|
|
600
622
|
/**
|
|
601
623
|
* @internal
|
|
602
624
|
*/
|
|
@@ -666,6 +688,7 @@ declare type UseInputTriggerSlotOptions = {
|
|
|
666
688
|
freeform: boolean | undefined;
|
|
667
689
|
defaultProps?: Partial<ComboboxProps>;
|
|
668
690
|
activeDescendantController: ActiveDescendantImperativeRef;
|
|
691
|
+
shouldCloseOnBlur?: UseTriggerSlotOptions['shouldCloseOnBlur'];
|
|
669
692
|
};
|
|
670
693
|
|
|
671
694
|
/**
|
|
@@ -742,6 +765,13 @@ export declare const useOptionGroupStyles_unstable: (state: OptionGroupState) =>
|
|
|
742
765
|
*/
|
|
743
766
|
export declare const useOptionStyles_unstable: (state: OptionState) => OptionState;
|
|
744
767
|
|
|
768
|
+
declare type UseTriggerSlotOptions = {
|
|
769
|
+
state: UseTriggerSlotState;
|
|
770
|
+
defaultProps: unknown;
|
|
771
|
+
activeDescendantController: ActiveDescendantImperativeRef;
|
|
772
|
+
shouldCloseOnBlur?: (event: React_2.FocusEvent<HTMLButtonElement> & React_2.FocusEvent<HTMLInputElement>) => boolean;
|
|
773
|
+
};
|
|
774
|
+
|
|
745
775
|
declare type UseTriggerSlotState = Pick<ComboboxBaseState, 'open' | 'getOptionById' | 'selectOption' | 'setOpen' | 'multiselect' | 'setHasFocus'>;
|
|
746
776
|
|
|
747
777
|
export { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Combobox/Combobox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useCombobox_unstable } from './useCombobox';\nimport { renderCombobox_unstable } from './renderCombobox';\nimport { useComboboxStyles_unstable } from './useComboboxStyles.styles';\nimport type { ComboboxProps } from './Combobox.types';\nimport { useComboboxContextValues } from '../../contexts/useComboboxContextValues';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Combobox component: a selection control that allows users to choose from a set of possible options\n */\nexport const Combobox: ForwardRefComponent<ComboboxProps> = React.forwardRef((props, ref) => {\n const state = useCombobox_unstable(props, ref);\n const contextValues = useComboboxContextValues(state);\n\n useComboboxStyles_unstable(state);\n\n useCustomStyleHook_unstable('useComboboxStyles_unstable')(state);\n\n return renderCombobox_unstable(state, contextValues);\n});\n\nCombobox.displayName = 'Combobox';\n"],"names":["React","useCombobox_unstable","renderCombobox_unstable","useComboboxStyles_unstable","useComboboxContextValues","useCustomStyleHook_unstable","Combobox","forwardRef","props","ref","state","contextValues","displayName"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ,mBAAgB;AACrD,SAASC,uBAAuB,QAAQ,sBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,gCAA6B;AAExE,SAASC,wBAAwB,QAAQ,6CAA0C;AAEnF,SAASC,2BAA2B,QAAQ,kCAAkC;AAE9E;;CAEC,GACD,OAAO,MAAMC,yBAA+CN,MAAMO,UAAU,CAAC,CAACC,OAAOC;IACnF,MAAMC,QAAQT,qBAAqBO,OAAOC;IAC1C,MAAME,gBAAgBP,yBAAyBM;IAE/CP,2BAA2BO;IAE3BL,4BAA4B,8BAA8BK;IAE1D,OAAOR,wBAAwBQ,OAAOC;AACxC,GAAG;AAEHL,SAASM,WAAW,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Combobox/Combobox.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, DistributiveOmit, Slot } from '@fluentui/react-utilities';\nimport type { ActiveDescendantImperativeRef } from '@fluentui/react-aria';\nimport type {\n ActiveOptionChangeData as ComboboxBaseActiveOptionChangeData,\n ComboboxBaseContextValues,\n ComboboxBaseOpenChangeData,\n ComboboxBaseOpenEvents,\n ComboboxBaseProps,\n ComboboxBaseState,\n} from '../../utils/ComboboxBase.types';\nimport type { Listbox } from '../Listbox/Listbox';\n\nexport type ComboboxSlots = {\n /** The root combobox slot */\n root: NonNullable<Slot<'div'>>;\n\n /** The dropdown arrow icon */\n expandIcon?: Slot<'span'>;\n\n /** The dropdown clear icon */\n clearIcon?: Slot<'span'>;\n\n /** The primary slot, an input with role=\"combobox\" */\n input: NonNullable<Slot<'input'>>;\n\n /** The dropdown listbox slot */\n listbox?: Slot<typeof Listbox>;\n};\n\n/**\n * Combobox Props\n */\nexport type ComboboxProps = Omit<ComponentProps<Partial<ComboboxSlots>, 'input'>, 'children' | 'size'> &\n ComboboxBaseProps & {\n freeform?: boolean;\n /**\n * The primary slot, `<input>`, does not support children so we need to explicitly include it here.\n */\n children?: React.ReactNode;\n };\n\n/**\n * Combobox Props without design-only props.\n */\nexport type BaseComboboxProps = DistributiveOmit<ComboboxProps, 'appearance' | 'size'>;\n\n/**\n * State used in rendering Combobox\n */\nexport type ComboboxState = ComponentState<ComboboxSlots> &\n ComboboxBaseState & {\n showClearIcon?: boolean;\n activeDescendantController: ActiveDescendantImperativeRef;\n };\n\n/**\n * State used in rendering Combobox, without design-only state.\n */\nexport type BaseComboboxState = DistributiveOmit<ComboboxState, 'appearance' | 'size'>;\n\n/* Export types defined in ComboboxBase */\nexport type ComboboxContextValues = ComboboxBaseContextValues;\nexport type ComboboxOpenChangeData = ComboboxBaseOpenChangeData;\nexport type ComboboxOpenEvents = ComboboxBaseOpenEvents;\nexport type ActiveOptionChangeData = ComboboxBaseActiveOptionChangeData;\n"],"names":[],"mappings":"AAiEA,WAAwE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Combobox/index.ts"],"sourcesContent":["export { Combobox } from './Combobox';\nexport type {\n ActiveOptionChangeData,\n BaseComboboxProps,\n BaseComboboxState,\n ComboboxContextValues,\n ComboboxOpenChangeData,\n ComboboxOpenEvents,\n ComboboxProps,\n ComboboxSlots,\n ComboboxState,\n} from './Combobox.types';\nexport { renderCombobox_unstable } from './renderCombobox';\nexport { useComboboxBase_unstable, useCombobox_unstable } from './useCombobox';\nexport { comboboxClassNames, useComboboxStyles_unstable } from './useComboboxStyles.styles';\n"],"names":["Combobox","renderCombobox_unstable","useComboboxBase_unstable","useCombobox_unstable","comboboxClassNames","useComboboxStyles_unstable"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAa;AAYtC,SAASC,uBAAuB,QAAQ,sBAAmB;AAC3D,SAASC,wBAAwB,EAAEC,oBAAoB,QAAQ,mBAAgB;AAC/E,SAASC,kBAAkB,EAAEC,0BAA0B,QAAQ,gCAA6B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { Portal } from "@fluentui/react-portal";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { Portal } from "@fluentui/react-portal";
|
|
3
3
|
import { ActiveDescendantContextProvider } from "@fluentui/react-aria";
|
|
4
4
|
import { assertSlots } from "@fluentui/react-utilities";
|
|
5
5
|
import { ComboboxContext } from "../../contexts/ComboboxContext.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Combobox/renderCombobox.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\nimport { Portal } from '@fluentui/react-portal';\nimport { ActiveDescendantContextProvider } from '@fluentui/react-aria';\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { JSXElement } from '@fluentui/react-utilities';\nimport { ComboboxContext } from '../../contexts/ComboboxContext';\nimport type { ComboboxContextValues, BaseComboboxState, ComboboxSlots } from './Combobox.types';\nimport { ListboxProvider } from '../../contexts/ListboxContext';\n\n/**\n * Render the final JSX of Combobox\n */\nexport const renderCombobox_unstable = (state: BaseComboboxState, contextValues: ComboboxContextValues): JSXElement => {\n assertSlots<ComboboxSlots>(state);\n\n return (\n <state.root>\n <ActiveDescendantContextProvider value={contextValues.activeDescendant}>\n <ListboxProvider value={contextValues.listbox}>\n {/*eslint-disable-next-line @typescript-eslint/no-deprecated*/}\n <ComboboxContext.Provider value={contextValues.combobox}>\n <state.input />\n {state.clearIcon && <state.clearIcon />}\n {state.expandIcon && <state.expandIcon />}\n {state.listbox &&\n (state.inlinePopup ? (\n <state.listbox />\n ) : (\n <Portal mountNode={state.mountNode}>\n <state.listbox />\n </Portal>\n ))}\n {/*eslint-disable-next-line @typescript-eslint/no-deprecated*/}\n </ComboboxContext.Provider>\n </ListboxProvider>\n </ActiveDescendantContextProvider>\n </state.root>\n );\n};\n"],"names":["Portal","ActiveDescendantContextProvider","assertSlots","ComboboxContext","ListboxProvider","renderCombobox_unstable","state","contextValues","root","value","activeDescendant","listbox","Provider","combobox","input","clearIcon","expandIcon","inlinePopup","mountNode"],"mappings":";AAAA,0BAA0B,GAC1B,iDAAiD,GACjD,SAASA,MAAM,QAAQ,yBAAyB;AAChD,SAASC,+BAA+B,QAAQ,uBAAuB;AAEvE,SAASC,WAAW,QAAQ,4BAA4B;AAExD,SAASC,eAAe,QAAQ,oCAAiC;AAEjE,SAASC,eAAe,QAAQ,mCAAgC;AAEhE;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CAACC,OAA0BC;IAChEL,YAA2BI;IAE3B,qBACE,KAACA,MAAME,IAAI;kBACT,cAAA,KAACP;YAAgCQ,OAAOF,cAAcG,gBAAgB;sBACpE,cAAA,KAACN;gBAAgBK,OAAOF,cAAcI,OAAO;0BAE3C,cAAA,MAACR,gBAAgBS,QAAQ;oBAACH,OAAOF,cAAcM,QAAQ;;sCACrD,KAACP,MAAMQ,KAAK;wBACXR,MAAMS,SAAS,kBAAI,KAACT,MAAMS,SAAS;wBACnCT,MAAMU,UAAU,kBAAI,KAACV,MAAMU,UAAU;wBACrCV,MAAMK,OAAO,IACXL,CAAAA,MAAMW,WAAW,iBAChB,KAACX,MAAMK,OAAO,sBAEd,KAACX;4BAAOkB,WAAWZ,MAAMY,SAAS;sCAChC,cAAA,KAACZ,MAAMK,OAAO;0BAElB;;;;;;AAOd,EAAE"}
|
|
@@ -3,7 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { useActiveDescendant } from "@fluentui/react-aria";
|
|
4
4
|
import { useFieldContext_unstable, useFieldControlProps_unstable } from "@fluentui/react-field";
|
|
5
5
|
import { ChevronDownRegular as ChevronDownIcon, DismissRegular as DismissIcon } from "@fluentui/react-icons";
|
|
6
|
-
import { getPartitionedNativeProps, mergeCallbacks, useEventCallback,
|
|
6
|
+
import { getPartitionedNativeProps, mergeCallbacks, useEventCallback, useMergedRefs, slot, useOnClickOutside } from "@fluentui/react-utilities";
|
|
7
7
|
import { useFluent_unstable as useFluent } from "@fluentui/react-shared-contexts";
|
|
8
8
|
import { useComboboxBaseState } from "../../utils/useComboboxBaseState.js";
|
|
9
9
|
import { useComboboxPositioning } from "../../utils/useComboboxPositioning.js";
|
|
@@ -12,13 +12,15 @@ import { useListboxSlot } from "../../utils/useListboxSlot.js";
|
|
|
12
12
|
import { useInputTriggerSlot } from "./useInputTriggerSlot.js";
|
|
13
13
|
import { isComboboxOptionElement } from "../../utils/isComboboxOptionElement.js";
|
|
14
14
|
import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
15
|
+
import { useComboboxExpandIconSlot } from "./useComboboxExpandIconSlot.js";
|
|
15
16
|
/**
|
|
16
17
|
* Create the base state required to render Combobox, without design-only props.
|
|
17
18
|
*
|
|
18
19
|
* @param props - props from this instance of Combobox (without appearance and size)
|
|
19
20
|
* @param ref - reference to root HTMLInputElement of Combobox
|
|
20
21
|
*/ export const useComboboxBase_unstable = (props, ref)=>{
|
|
21
|
-
var
|
|
22
|
+
var _props_input;
|
|
23
|
+
var _state_expandIcon, _state_expandIcon1, _state_expandIcon2, _state_clearIcon, _state_clearIcon1;
|
|
22
24
|
// Merge props from surrounding <Field>, if any
|
|
23
25
|
props = useFieldControlProps_unstable(props, {
|
|
24
26
|
supportsLabelFor: true,
|
|
@@ -36,7 +38,7 @@ import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
|
36
38
|
const { clearable, clearSelection, disabled, multiselect, open, selectedOptions, setOpen, value, hasFocus } = baseState;
|
|
37
39
|
const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);
|
|
38
40
|
const { disableAutoFocus = false, freeform, inlinePopup } = props;
|
|
39
|
-
const
|
|
41
|
+
const expandIconRef = React.useRef(null);
|
|
40
42
|
const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({
|
|
41
43
|
props,
|
|
42
44
|
primarySlotTagName: 'input',
|
|
@@ -53,7 +55,6 @@ import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
|
53
55
|
disableAutoFocus
|
|
54
56
|
}
|
|
55
57
|
});
|
|
56
|
-
var _props_input;
|
|
57
58
|
const triggerSlot = useInputTriggerSlot((_props_input = props.input) !== null && _props_input !== void 0 ? _props_input : {}, useMergedRefs(triggerRef, activeParentRef, ref), {
|
|
58
59
|
state: comboboxInternalState,
|
|
59
60
|
freeform,
|
|
@@ -63,7 +64,8 @@ import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
|
63
64
|
'aria-controls': open ? listbox === null || listbox === void 0 ? void 0 : listbox.id : undefined,
|
|
64
65
|
...triggerNativeProps
|
|
65
66
|
},
|
|
66
|
-
activeDescendantController
|
|
67
|
+
activeDescendantController,
|
|
68
|
+
shouldCloseOnBlur: (event)=>!expandIconRef.current || event.relatedTarget !== expandIconRef.current
|
|
67
69
|
});
|
|
68
70
|
const rootSlot = slot.always(props.root, {
|
|
69
71
|
defaultProps: {
|
|
@@ -73,6 +75,14 @@ import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
|
73
75
|
elementType: 'div'
|
|
74
76
|
});
|
|
75
77
|
rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);
|
|
78
|
+
rootSlot.onBlur = mergeCallbacks(rootSlot.onBlur, (event)=>{
|
|
79
|
+
if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
|
|
80
|
+
if (event.target !== event.currentTarget.querySelector('input')) {
|
|
81
|
+
comboboxInternalState.setOpen(event, false);
|
|
82
|
+
}
|
|
83
|
+
comboboxInternalState.setHasFocus(false);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
76
86
|
const showClearIcon = selectedOptions.length > 0 && !disabled && clearable && !multiselect;
|
|
77
87
|
const state = {
|
|
78
88
|
components: {
|
|
@@ -92,14 +102,13 @@ import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
|
92
102
|
elementType: 'span',
|
|
93
103
|
renderByDefault: true
|
|
94
104
|
}),
|
|
95
|
-
expandIcon:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
elementType: 'span'
|
|
105
|
+
expandIcon: useComboboxExpandIconSlot(props.expandIcon, {
|
|
106
|
+
disabled,
|
|
107
|
+
hideFromTabOrder: showClearIcon,
|
|
108
|
+
open,
|
|
109
|
+
'aria-label': props['aria-label'],
|
|
110
|
+
'aria-labelledby': props['aria-labelledby'],
|
|
111
|
+
triggerLabelledBy: triggerSlot['aria-labelledby']
|
|
103
112
|
}),
|
|
104
113
|
showClearIcon,
|
|
105
114
|
activeDescendantController,
|
|
@@ -121,33 +130,46 @@ import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
|
121
130
|
mergeCallbacks(onIconMouseDown, (event)=>{
|
|
122
131
|
var _triggerRef_current;
|
|
123
132
|
event.preventDefault();
|
|
124
|
-
|
|
133
|
+
if (!state.disabled) {
|
|
134
|
+
state.setOpen(event, !state.open);
|
|
135
|
+
}
|
|
125
136
|
(_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
|
|
126
137
|
}));
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const hasExpandLabel = state.expandIcon['aria-label'] || state.expandIcon['aria-labelledby'];
|
|
136
|
-
const defaultOpenString = 'Open'; // this is english-only since it is the fallback
|
|
137
|
-
if (!hasExpandLabel) {
|
|
138
|
-
if (props['aria-labelledby']) {
|
|
139
|
-
var _state_expandIcon_id;
|
|
140
|
-
const chevronId = (_state_expandIcon_id = state.expandIcon.id) !== null && _state_expandIcon_id !== void 0 ? _state_expandIcon_id : `${comboId}-chevron`;
|
|
141
|
-
const chevronLabelledBy = `${chevronId} ${state.input['aria-labelledby']}`;
|
|
142
|
-
state.expandIcon['aria-label'] = defaultOpenString;
|
|
143
|
-
state.expandIcon.id = chevronId;
|
|
144
|
-
state.expandIcon['aria-labelledby'] = chevronLabelledBy;
|
|
145
|
-
} else if (props['aria-label']) {
|
|
146
|
-
state.expandIcon['aria-label'] = `${defaultOpenString} ${props['aria-label']}`;
|
|
147
|
-
} else {
|
|
148
|
-
state.expandIcon['aria-label'] = defaultOpenString;
|
|
138
|
+
const onExpandIconClick = useEventCallback(// eslint-disable-next-line react-hooks/refs
|
|
139
|
+
mergeCallbacks((_state_expandIcon = state.expandIcon) === null || _state_expandIcon === void 0 ? void 0 : _state_expandIcon.onClick, (event)=>{
|
|
140
|
+
// Pointer clicks already toggle on mousedown; click-only activation has detail 0.
|
|
141
|
+
if (event.detail === 0) {
|
|
142
|
+
var _triggerRef_current;
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
if (!state.disabled) {
|
|
145
|
+
state.setOpen(event, !state.open);
|
|
149
146
|
}
|
|
147
|
+
(_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
|
|
148
|
+
}
|
|
149
|
+
}));
|
|
150
|
+
const onExpandIconKeyDown = useEventCallback(// eslint-disable-next-line react-hooks/refs
|
|
151
|
+
mergeCallbacks((_state_expandIcon1 = state.expandIcon) === null || _state_expandIcon1 === void 0 ? void 0 : _state_expandIcon1.onKeyDown, (event)=>{
|
|
152
|
+
if (state.open && event.key === 'Escape') {
|
|
153
|
+
var _triggerRef_current;
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
event.stopPropagation();
|
|
156
|
+
state.setOpen(event, false);
|
|
157
|
+
(_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
|
|
158
|
+
return;
|
|
150
159
|
}
|
|
160
|
+
if (!state.disabled && (event.key === 'Enter' || event.key === ' ')) {
|
|
161
|
+
var _triggerRef_current1;
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
state.setOpen(event, !state.open);
|
|
164
|
+
(_triggerRef_current1 = triggerRef.current) === null || _triggerRef_current1 === void 0 ? void 0 : _triggerRef_current1.focus();
|
|
165
|
+
}
|
|
166
|
+
}));
|
|
167
|
+
const expandIconSlotRef = useMergedRefs((_state_expandIcon2 = state.expandIcon) === null || _state_expandIcon2 === void 0 ? void 0 : _state_expandIcon2.ref, expandIconRef);
|
|
168
|
+
if (state.expandIcon) {
|
|
169
|
+
state.expandIcon.ref = expandIconSlotRef;
|
|
170
|
+
state.expandIcon.onMouseDown = onExpandIconMouseDown;
|
|
171
|
+
state.expandIcon.onClick = onExpandIconClick;
|
|
172
|
+
state.expandIcon.onKeyDown = onExpandIconKeyDown;
|
|
151
173
|
}
|
|
152
174
|
const onClearIconMouseDown = useEventCallback(mergeCallbacks((_state_clearIcon = state.clearIcon) === null || _state_clearIcon === void 0 ? void 0 : _state_clearIcon.onMouseDown, (ev)=>{
|
|
153
175
|
ev.preventDefault();
|
|
@@ -186,18 +208,16 @@ import { useTabsterEscapeIgnore } from "../../hooks/useTabsterEscapeIgnore.js";
|
|
|
186
208
|
* @param props - props from this instance of Combobox
|
|
187
209
|
* @param ref - reference to root HTMLElement of Combobox
|
|
188
210
|
*/ export const useCombobox_unstable = (props, ref)=>{
|
|
211
|
+
var _ref;
|
|
189
212
|
const fieldContext = useFieldContext_unstable();
|
|
190
|
-
|
|
191
|
-
const { appearance = 'outline', size = (_fieldContext_size = fieldContext === null || fieldContext === void 0 ? void 0 : fieldContext.size) !== null && _fieldContext_size !== void 0 ? _fieldContext_size : 'medium', ...baseProps } = props;
|
|
213
|
+
const { appearance = 'outline', size = (_ref = fieldContext === null || fieldContext === void 0 ? void 0 : fieldContext.size) !== null && _ref !== void 0 ? _ref : 'medium', ...baseProps } = props;
|
|
192
214
|
const baseState = useComboboxBase_unstable(baseProps, ref);
|
|
193
215
|
if (baseState.clearIcon) {
|
|
194
|
-
var _baseState_clearIcon;
|
|
195
|
-
var _children;
|
|
216
|
+
var _baseState_clearIcon, _children;
|
|
196
217
|
(_children = (_baseState_clearIcon = baseState.clearIcon).children) !== null && _children !== void 0 ? _children : _baseState_clearIcon.children = /*#__PURE__*/ React.createElement(DismissIcon, null);
|
|
197
218
|
}
|
|
198
219
|
if (baseState.expandIcon) {
|
|
199
|
-
var _baseState_expandIcon;
|
|
200
|
-
var _children1;
|
|
220
|
+
var _baseState_expandIcon, _children1;
|
|
201
221
|
(_children1 = (_baseState_expandIcon = baseState.expandIcon).children) !== null && _children1 !== void 0 ? _children1 : _baseState_expandIcon.children = /*#__PURE__*/ React.createElement(ChevronDownIcon, null);
|
|
202
222
|
}
|
|
203
223
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { useFieldContext_unstable, useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ChevronDownRegular as ChevronDownIcon, DismissRegular as DismissIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n useEventCallback,\n useId,\n useMergedRefs,\n slot,\n useOnClickOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { Listbox } from '../Listbox/Listbox';\nimport type {\n BaseComboboxProps,\n BaseComboboxState,\n ComboboxOpenEvents,\n ComboboxProps,\n ComboboxState,\n} from './Combobox.types';\nimport { useListboxSlot } from '../../utils/useListboxSlot';\nimport { useInputTriggerSlot } from './useInputTriggerSlot';\nimport { isComboboxOptionElement } from '../../utils/isComboboxOptionElement';\nimport { useTabsterEscapeIgnore } from '../../hooks/useTabsterEscapeIgnore';\n\n/**\n * Create the base state required to render Combobox, without design-only props.\n *\n * @param props - props from this instance of Combobox (without appearance and size)\n * @param ref - reference to root HTMLInputElement of Combobox\n */\nexport const useComboboxBase_unstable = (\n props: BaseComboboxProps,\n ref: React.Ref<HTMLInputElement>,\n): BaseComboboxState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n const {\n listboxRef: activeDescendantListboxRef,\n activeParentRef,\n controller: activeDescendantController,\n } = useActiveDescendant<HTMLInputElement, HTMLDivElement>({\n matchOption: isComboboxOptionElement,\n });\n const comboboxInternalState = useComboboxBaseState({ ...props, editable: true, activeDescendantController });\n const { appearance: _appearance, size: _size, ...baseState } = comboboxInternalState;\n\n const { clearable, clearSelection, disabled, multiselect, open, selectedOptions, setOpen, value, hasFocus } =\n baseState;\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);\n const { disableAutoFocus = false, freeform, inlinePopup } = props;\n const comboId = useId('combobox-');\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['children'],\n });\n\n const triggerRef = React.useRef<HTMLInputElement>(null);\n\n const listbox = useListboxSlot(props.listbox, useMergedRefs(comboboxPopupRef, activeDescendantListboxRef), {\n state: comboboxInternalState,\n triggerRef,\n defaultProps: {\n children: props.children,\n disableAutoFocus,\n },\n });\n\n const triggerSlot = useInputTriggerSlot(props.input ?? {}, useMergedRefs(triggerRef, activeParentRef, ref), {\n state: comboboxInternalState,\n freeform,\n defaultProps: {\n type: 'text',\n value: value ?? '',\n 'aria-controls': open ? listbox?.id : undefined,\n ...triggerNativeProps,\n },\n activeDescendantController,\n });\n\n const rootSlot = slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !inlinePopup && open ? listbox?.id : undefined,\n ...rootNativeProps,\n },\n elementType: 'div',\n });\n rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);\n\n const showClearIcon = selectedOptions.length > 0 && !disabled && clearable && !multiselect;\n const state: BaseComboboxState = {\n components: { root: 'div', input: 'input', expandIcon: 'span', listbox: Listbox, clearIcon: 'span' },\n root: rootSlot,\n input: triggerSlot,\n listbox: open || hasFocus ? listbox : undefined,\n clearIcon: slot.optional(props.clearIcon, {\n defaultProps: {\n 'aria-hidden': 'true',\n },\n elementType: 'span',\n renderByDefault: true,\n }),\n expandIcon: slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n 'aria-disabled': disabled ? 'true' : undefined,\n 'aria-expanded': open,\n role: 'button',\n },\n elementType: 'span',\n }),\n showClearIcon,\n activeDescendantController,\n ...baseState,\n };\n\n const { targetDocument } = useFluent();\n\n useOnClickOutside({\n element: targetDocument,\n callback: event => setOpen(event as unknown as ComboboxOpenEvents, false),\n refs: [triggerRef, comboboxPopupRef, comboboxTargetRef],\n disabled: !open,\n });\n\n /* handle open/close + focus change when clicking expandIcon */\n const { onMouseDown: onIconMouseDown } = state.expandIcon || {};\n\n const onExpandIconMouseDown = useEventCallback(\n // eslint-disable-next-line react-hooks/refs\n mergeCallbacks(onIconMouseDown, (event: React.MouseEvent<HTMLSpanElement>) => {\n event.preventDefault();\n state.setOpen(event, !state.open);\n triggerRef.current?.focus();\n }),\n );\n\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n\n // If there is no explicit aria-label, calculate default accName attribute for expandIcon button,\n // using the following steps:\n // 1. If there is an aria-label, it is \"Open [aria-label]\"\n // 2. If there is an aria-labelledby, it is \"Open [aria-labelledby target]\" (using aria-labelledby + ids)\n // 3. If there is no aria-label/ledby attr, it falls back to \"Open\"\n // We can't fall back to a label/htmlFor name because of https://github.com/w3c/accname/issues/179\n const hasExpandLabel = state.expandIcon['aria-label'] || state.expandIcon['aria-labelledby'];\n const defaultOpenString = 'Open'; // this is english-only since it is the fallback\n if (!hasExpandLabel) {\n if (props['aria-labelledby']) {\n const chevronId = state.expandIcon.id ?? `${comboId}-chevron`;\n const chevronLabelledBy = `${chevronId} ${state.input['aria-labelledby']}`;\n\n state.expandIcon['aria-label'] = defaultOpenString;\n state.expandIcon.id = chevronId;\n state.expandIcon['aria-labelledby'] = chevronLabelledBy;\n } else if (props['aria-label']) {\n state.expandIcon['aria-label'] = `${defaultOpenString} ${props['aria-label']}`;\n } else {\n state.expandIcon['aria-label'] = defaultOpenString;\n }\n }\n }\n\n const onClearIconMouseDown = useEventCallback(\n mergeCallbacks(state.clearIcon?.onMouseDown, (ev: React.MouseEvent<HTMLSpanElement>) => {\n ev.preventDefault();\n }),\n );\n const onClearIconClick = useEventCallback(\n mergeCallbacks(state.clearIcon?.onClick, (ev: React.MouseEvent<HTMLSpanElement>) => {\n clearSelection(ev);\n }),\n );\n\n if (state.clearIcon) {\n state.clearIcon.onMouseDown = onClearIconMouseDown;\n state.clearIcon.onClick = onClearIconClick;\n }\n\n // Heads up! We don't support \"clearable\" in multiselect mode, so we should never display a slot\n if (multiselect) {\n state.clearIcon = undefined;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- \"process.env\" does not change in runtime\n React.useEffect(() => {\n if (clearable && multiselect) {\n // eslint-disable-next-line no-console\n console.error(`[@fluentui/react-combobox] \"clearable\" prop is not supported in multiselect mode.`);\n }\n }, [clearable, multiselect]);\n }\n\n return state;\n};\n\n/**\n * Create the state required to render Combobox.\n *\n * The returned state can be modified with hooks such as useComboboxStyles_unstable,\n * before being passed to renderCombobox_unstable.\n *\n * @param props - props from this instance of Combobox\n * @param ref - reference to root HTMLElement of Combobox\n */\nexport const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLInputElement>): ComboboxState => {\n const fieldContext = useFieldContext_unstable();\n const { appearance = 'outline', size = fieldContext?.size ?? 'medium', ...baseProps } = props;\n const baseState = useComboboxBase_unstable(baseProps, ref);\n\n if (baseState.clearIcon) {\n baseState.clearIcon.children ??= <DismissIcon />;\n }\n\n if (baseState.expandIcon) {\n baseState.expandIcon.children ??= <ChevronDownIcon />;\n }\n\n return {\n ...baseState,\n appearance,\n size,\n input: {\n ...useTabsterEscapeIgnore(baseState.input, baseState.open),\n ...baseState.input,\n },\n };\n};\n"],"names":["React","useActiveDescendant","useFieldContext_unstable","useFieldControlProps_unstable","ChevronDownRegular","ChevronDownIcon","DismissRegular","DismissIcon","getPartitionedNativeProps","mergeCallbacks","useEventCallback","useId","useMergedRefs","slot","useOnClickOutside","useFluent_unstable","useFluent","useComboboxBaseState","useComboboxPositioning","Listbox","useListboxSlot","useInputTriggerSlot","isComboboxOptionElement","useTabsterEscapeIgnore","useComboboxBase_unstable","props","ref","state","supportsLabelFor","supportsRequired","listboxRef","activeDescendantListboxRef","activeParentRef","controller","activeDescendantController","matchOption","comboboxInternalState","editable","appearance","_appearance","size","_size","baseState","clearable","clearSelection","disabled","multiselect","open","selectedOptions","setOpen","value","hasFocus","comboboxPopupRef","comboboxTargetRef","disableAutoFocus","freeform","inlinePopup","comboId","primary","triggerNativeProps","root","rootNativeProps","primarySlotTagName","excludedPropNames","triggerRef","useRef","listbox","defaultProps","children","triggerSlot","input","type","id","undefined","rootSlot","always","elementType","showClearIcon","length","components","expandIcon","clearIcon","optional","renderByDefault","role","targetDocument","element","callback","event","refs","onMouseDown","onIconMouseDown","onExpandIconMouseDown","preventDefault","current","focus","hasExpandLabel","defaultOpenString","chevronId","chevronLabelledBy","onClearIconMouseDown","ev","onClearIconClick","onClick","process","env","NODE_ENV","useEffect","console","error","useCombobox_unstable","fieldContext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QAAQC,KAAK,CAAC,CAAC,iFAAiF,CAAC;YACnG;QACF,GAAG;YAAClE;YAAWG;SAAY;IAC7B;IAEA,OAAOnB;AACT,EAAE;AAEF;;;;;;;;CAQC,GACD,OAAO,MAAMmF,uBAAuB,CAACrF,OAAsBC;IACzD,MAAMqF,eAAe7G;QACkB6G;IAAvC,MAAM,EAAEzE,aAAa,SAAS,EAAEE,OAAOuE,CAAAA,qBAAAA,yBAAAA,mCAAAA,aAAcvE,IAAI,cAAlBuE,gCAAAA,qBAAsB,QAAQ,EAAE,GAAGC,WAAW,GAAGvF;IACxF,MAAMiB,YAAYlB,yBAAyBwF,WAAWtF;IAEtD,IAAIgB,UAAUuC,SAAS,EAAE;YACvBvC;;QAAAA,cAAAA,uBAAAA,UAAUuC,SAAS,EAACb,yDAApB1B,qBAAoB0B,yBAAa,oBAAC7D;IACpC;IAEA,IAAImC,UAAUsC,UAAU,EAAE;YACxBtC;;QAAAA,eAAAA,wBAAAA,UAAUsC,UAAU,EAACZ,2DAArB1B,sBAAqB0B,yBAAa,oBAAC/D;IACrC;IAEA,OAAO;QACL,GAAGqC,SAAS;QACZJ;QACAE;QACA8B,OAAO;YACL,GAAG/C,uBAAuBmB,UAAU4B,KAAK,EAAE5B,UAAUK,IAAI,CAAC;YAC1D,GAAGL,UAAU4B,KAAK;QACpB;IACF;AACF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Combobox/useCombobox.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { useFieldContext_unstable, useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ChevronDownRegular as ChevronDownIcon, DismissRegular as DismissIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n slot,\n useOnClickOutside,\n} from '@fluentui/react-utilities';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { Listbox } from '../Listbox/Listbox';\nimport type {\n BaseComboboxProps,\n BaseComboboxState,\n ComboboxOpenEvents,\n ComboboxProps,\n ComboboxState,\n} from './Combobox.types';\nimport { useListboxSlot } from '../../utils/useListboxSlot';\nimport { useInputTriggerSlot } from './useInputTriggerSlot';\nimport { isComboboxOptionElement } from '../../utils/isComboboxOptionElement';\nimport { useTabsterEscapeIgnore } from '../../hooks/useTabsterEscapeIgnore';\nimport { useComboboxExpandIconSlot } from './useComboboxExpandIconSlot';\n\n/**\n * Create the base state required to render Combobox, without design-only props.\n *\n * @param props - props from this instance of Combobox (without appearance and size)\n * @param ref - reference to root HTMLInputElement of Combobox\n */\nexport const useComboboxBase_unstable = (\n props: BaseComboboxProps,\n ref: React.Ref<HTMLInputElement>,\n): BaseComboboxState => {\n // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true });\n const {\n listboxRef: activeDescendantListboxRef,\n activeParentRef,\n controller: activeDescendantController,\n } = useActiveDescendant<HTMLInputElement, HTMLDivElement>({\n matchOption: isComboboxOptionElement,\n });\n const comboboxInternalState = useComboboxBaseState({ ...props, editable: true, activeDescendantController });\n const { appearance: _appearance, size: _size, ...baseState } = comboboxInternalState;\n\n const { clearable, clearSelection, disabled, multiselect, open, selectedOptions, setOpen, value, hasFocus } =\n baseState;\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);\n const { disableAutoFocus = false, freeform, inlinePopup } = props;\n const expandIconRef = React.useRef<HTMLSpanElement>(null);\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['children'],\n });\n\n const triggerRef = React.useRef<HTMLInputElement>(null);\n\n const listbox = useListboxSlot(props.listbox, useMergedRefs(comboboxPopupRef, activeDescendantListboxRef), {\n state: comboboxInternalState,\n triggerRef,\n defaultProps: {\n children: props.children,\n disableAutoFocus,\n },\n });\n\n const triggerSlot = useInputTriggerSlot(props.input ?? {}, useMergedRefs(triggerRef, activeParentRef, ref), {\n state: comboboxInternalState,\n freeform,\n defaultProps: {\n type: 'text',\n value: value ?? '',\n 'aria-controls': open ? listbox?.id : undefined,\n ...triggerNativeProps,\n },\n activeDescendantController,\n shouldCloseOnBlur: event => !expandIconRef.current || event.relatedTarget !== expandIconRef.current,\n });\n\n const rootSlot = slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !inlinePopup && open ? listbox?.id : undefined,\n ...rootNativeProps,\n },\n elementType: 'div',\n });\n rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);\n rootSlot.onBlur = mergeCallbacks(rootSlot.onBlur, event => {\n if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {\n if (event.target !== event.currentTarget.querySelector('input')) {\n comboboxInternalState.setOpen(event as unknown as ComboboxOpenEvents, false);\n }\n comboboxInternalState.setHasFocus(false);\n }\n });\n\n const showClearIcon = selectedOptions.length > 0 && !disabled && clearable && !multiselect;\n const state: BaseComboboxState = {\n components: { root: 'div', input: 'input', expandIcon: 'span', listbox: Listbox, clearIcon: 'span' },\n root: rootSlot,\n input: triggerSlot,\n listbox: open || hasFocus ? listbox : undefined,\n clearIcon: slot.optional(props.clearIcon, {\n defaultProps: {\n 'aria-hidden': 'true',\n },\n elementType: 'span',\n renderByDefault: true,\n }),\n expandIcon: useComboboxExpandIconSlot(props.expandIcon, {\n disabled,\n hideFromTabOrder: showClearIcon,\n open,\n 'aria-label': props['aria-label'],\n 'aria-labelledby': props['aria-labelledby'],\n triggerLabelledBy: triggerSlot['aria-labelledby'],\n }),\n showClearIcon,\n activeDescendantController,\n ...baseState,\n };\n\n const { targetDocument } = useFluent();\n\n useOnClickOutside({\n element: targetDocument,\n callback: event => setOpen(event as unknown as ComboboxOpenEvents, false),\n refs: [triggerRef, comboboxPopupRef, comboboxTargetRef],\n disabled: !open,\n });\n\n /* handle open/close + focus change when clicking expandIcon */\n const { onMouseDown: onIconMouseDown } = state.expandIcon || {};\n\n const onExpandIconMouseDown = useEventCallback(\n // eslint-disable-next-line react-hooks/refs\n mergeCallbacks(onIconMouseDown, (event: React.MouseEvent<HTMLSpanElement>) => {\n event.preventDefault();\n if (!state.disabled) {\n state.setOpen(event, !state.open);\n }\n triggerRef.current?.focus();\n }),\n );\n\n const onExpandIconClick = useEventCallback(\n // eslint-disable-next-line react-hooks/refs\n mergeCallbacks(state.expandIcon?.onClick, (event: React.MouseEvent<HTMLSpanElement>) => {\n // Pointer clicks already toggle on mousedown; click-only activation has detail 0.\n if (event.detail === 0) {\n event.preventDefault();\n if (!state.disabled) {\n state.setOpen(event, !state.open);\n }\n triggerRef.current?.focus();\n }\n }),\n );\n\n const onExpandIconKeyDown = useEventCallback(\n // eslint-disable-next-line react-hooks/refs\n mergeCallbacks(state.expandIcon?.onKeyDown, event => {\n if (state.open && event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n state.setOpen(event, false);\n triggerRef.current?.focus();\n return;\n }\n\n if (!state.disabled && (event.key === 'Enter' || event.key === ' ')) {\n event.preventDefault();\n state.setOpen(event, !state.open);\n triggerRef.current?.focus();\n }\n }),\n );\n const expandIconSlotRef = useMergedRefs(state.expandIcon?.ref, expandIconRef);\n\n if (state.expandIcon) {\n state.expandIcon.ref = expandIconSlotRef;\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\n state.expandIcon.onKeyDown = onExpandIconKeyDown;\n }\n\n const onClearIconMouseDown = useEventCallback(\n mergeCallbacks(state.clearIcon?.onMouseDown, (ev: React.MouseEvent<HTMLSpanElement>) => {\n ev.preventDefault();\n }),\n );\n const onClearIconClick = useEventCallback(\n mergeCallbacks(state.clearIcon?.onClick, (ev: React.MouseEvent<HTMLSpanElement>) => {\n clearSelection(ev);\n }),\n );\n\n if (state.clearIcon) {\n state.clearIcon.onMouseDown = onClearIconMouseDown;\n state.clearIcon.onClick = onClearIconClick;\n }\n\n // Heads up! We don't support \"clearable\" in multiselect mode, so we should never display a slot\n if (multiselect) {\n state.clearIcon = undefined;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks -- \"process.env\" does not change in runtime\n React.useEffect(() => {\n if (clearable && multiselect) {\n // eslint-disable-next-line no-console\n console.error(`[@fluentui/react-combobox] \"clearable\" prop is not supported in multiselect mode.`);\n }\n }, [clearable, multiselect]);\n }\n\n return state;\n};\n\n/**\n * Create the state required to render Combobox.\n *\n * The returned state can be modified with hooks such as useComboboxStyles_unstable,\n * before being passed to renderCombobox_unstable.\n *\n * @param props - props from this instance of Combobox\n * @param ref - reference to root HTMLElement of Combobox\n */\nexport const useCombobox_unstable = (props: ComboboxProps, ref: React.Ref<HTMLInputElement>): ComboboxState => {\n const fieldContext = useFieldContext_unstable();\n const { appearance = 'outline', size = fieldContext?.size ?? 'medium', ...baseProps } = props;\n const baseState = useComboboxBase_unstable(baseProps, ref);\n\n if (baseState.clearIcon) {\n baseState.clearIcon.children ??= <DismissIcon />;\n }\n\n if (baseState.expandIcon) {\n baseState.expandIcon.children ??= <ChevronDownIcon />;\n }\n\n return {\n ...baseState,\n appearance,\n size,\n input: {\n ...useTabsterEscapeIgnore(baseState.input, baseState.open),\n ...baseState.input,\n },\n };\n};\n"],"names":["React","useActiveDescendant","useFieldContext_unstable","useFieldControlProps_unstable","ChevronDownRegular","ChevronDownIcon","DismissRegular","DismissIcon","getPartitionedNativeProps","mergeCallbacks","useEventCallback","useMergedRefs","slot","useOnClickOutside","useFluent_unstable","useFluent","useComboboxBaseState","useComboboxPositioning","Listbox","useListboxSlot","useInputTriggerSlot","isComboboxOptionElement","useTabsterEscapeIgnore","useComboboxExpandIconSlot","useComboboxBase_unstable","props","ref","state","supportsLabelFor","supportsRequired","listboxRef","activeDescendantListboxRef","activeParentRef","controller","activeDescendantController","matchOption","comboboxInternalState","editable","appearance","_appearance","size","_size","baseState","clearable","clearSelection","disabled","multiselect","open","selectedOptions","setOpen","value","hasFocus","comboboxPopupRef","comboboxTargetRef","disableAutoFocus","freeform","inlinePopup","expandIconRef","useRef","primary","triggerNativeProps","root","rootNativeProps","primarySlotTagName","excludedPropNames","triggerRef","listbox","defaultProps","children","triggerSlot","input","type","id","undefined","shouldCloseOnBlur","event","current","relatedTarget","rootSlot","always","elementType","onBlur","currentTarget","contains","target","querySelector","setHasFocus","showClearIcon","length","components","expandIcon","clearIcon","optional","renderByDefault","hideFromTabOrder","triggerLabelledBy","targetDocument","element","callback","refs","onMouseDown","onIconMouseDown","onExpandIconMouseDown","preventDefault","focus","onExpandIconClick","onClick","detail","onExpandIconKeyDown","onKeyDown","key","stopPropagation","expandIconSlotRef","onClearIconMouseDown","ev","onClearIconClick","process","env","NODE_ENV","useEffect","console","error","useCombobox_unstable","fieldContext","baseProps"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,wBAAwB,EAAEC,6BAA6B,QAAQ,wBAAwB;AAChG,SAASC,sBAAsBC,eAAe,EAAEC,kBAAkBC,WAAW,QAAQ,wBAAwB;AAC7G,SACEC,yBAAyB,EACzBC,cAAc,EACdC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,EACJC,iBAAiB,QACZ,4BAA4B;AACnC,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAClF,SAASC,oBAAoB,QAAQ,sCAAmC;AACxE,SAASC,sBAAsB,QAAQ,wCAAqC;AAC5E,SAASC,OAAO,QAAQ,wBAAqB;AAQ7C,SAASC,cAAc,QAAQ,gCAA6B;AAC5D,SAASC,mBAAmB,QAAQ,2BAAwB;AAC5D,SAASC,uBAAuB,QAAQ,yCAAsC;AAC9E,SAASC,sBAAsB,QAAQ,wCAAqC;AAC5E,SAASC,yBAAyB,QAAQ,iCAA8B;AAExE;;;;;CAKC,GACD,OAAO,MAAM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, useId } from "@fluentui/react-utilities";
|
|
2
|
+
/**
|
|
3
|
+
* Creates the `expandIcon` slot of a combobox: button semantics plus the default accessible name.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/ export function useComboboxExpandIconSlot(expandIconFromProps, options) {
|
|
7
|
+
const defaultExpandIconId = useId('combobox-chevron-');
|
|
8
|
+
const { disabled, hideFromTabOrder, open, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, triggerLabelledBy } = options;
|
|
9
|
+
const expandIcon = slot.optional(expandIconFromProps, {
|
|
10
|
+
renderByDefault: true,
|
|
11
|
+
defaultProps: {
|
|
12
|
+
'aria-disabled': disabled ? 'true' : undefined,
|
|
13
|
+
'aria-expanded': open,
|
|
14
|
+
role: 'button',
|
|
15
|
+
tabIndex: disabled ? -1 : 0
|
|
16
|
+
},
|
|
17
|
+
elementType: 'span'
|
|
18
|
+
});
|
|
19
|
+
if (!expandIcon) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
if (disabled || hideFromTabOrder) {
|
|
23
|
+
expandIcon.tabIndex = -1;
|
|
24
|
+
}
|
|
25
|
+
const hasExpandLabel = expandIcon['aria-label'] || expandIcon['aria-labelledby'];
|
|
26
|
+
if (!hasExpandLabel) {
|
|
27
|
+
if (triggerLabelledBy || ariaLabelledBy) {
|
|
28
|
+
var _expandIcon_id;
|
|
29
|
+
const expandIconId = (_expandIcon_id = expandIcon.id) !== null && _expandIcon_id !== void 0 ? _expandIcon_id : defaultExpandIconId;
|
|
30
|
+
expandIcon.id = expandIconId;
|
|
31
|
+
expandIcon['aria-labelledby'] = `${expandIcon.id} ${triggerLabelledBy !== null && triggerLabelledBy !== void 0 ? triggerLabelledBy : ariaLabelledBy}`.trim();
|
|
32
|
+
expandIcon['aria-label'] = 'Open';
|
|
33
|
+
} else if (ariaLabel) {
|
|
34
|
+
expandIcon['aria-label'] = `Open ${ariaLabel}`;
|
|
35
|
+
} else {
|
|
36
|
+
expandIcon['aria-label'] = 'Open';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return expandIcon;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Combobox/useComboboxExpandIconSlot.ts"],"sourcesContent":["import { slot, useId } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, Slot, SlotComponentType } from '@fluentui/react-utilities';\n\ntype UseComboboxExpandIconSlotOptions = {\n /** Whether the combobox trigger is disabled. */\n disabled?: boolean;\n /** Whether the expand icon is visually hidden by the clear icon. */\n hideFromTabOrder?: boolean;\n /** Whether the listbox is currently open. */\n open: boolean;\n /** `aria-label` passed to the combobox. */\n 'aria-label'?: string;\n /** `aria-labelledby` passed to the combobox. */\n 'aria-labelledby'?: string;\n /** `aria-labelledby` of the resolved input trigger, used to build the labelling chain. */\n triggerLabelledBy?: string;\n};\n\n/**\n * Creates the `expandIcon` slot of a combobox: button semantics plus the default accessible name.\n *\n * @internal\n */\nexport function useComboboxExpandIconSlot(\n expandIconFromProps: Slot<'span'> | undefined | null,\n options: UseComboboxExpandIconSlotOptions,\n): SlotComponentType<ExtractSlotProps<Slot<'span'>>> | undefined {\n const defaultExpandIconId = useId('combobox-chevron-');\n const {\n disabled,\n hideFromTabOrder,\n open,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n triggerLabelledBy,\n } = options;\n const expandIcon = slot.optional(expandIconFromProps, {\n renderByDefault: true,\n defaultProps: {\n 'aria-disabled': disabled ? 'true' : undefined,\n 'aria-expanded': open,\n role: 'button',\n tabIndex: disabled ? -1 : 0,\n },\n elementType: 'span',\n });\n\n if (!expandIcon) {\n return undefined;\n }\n\n if (disabled || hideFromTabOrder) {\n expandIcon.tabIndex = -1;\n }\n\n const hasExpandLabel = expandIcon['aria-label'] || expandIcon['aria-labelledby'];\n\n if (!hasExpandLabel) {\n if (triggerLabelledBy || ariaLabelledBy) {\n const expandIconId = expandIcon.id ?? defaultExpandIconId;\n expandIcon.id = expandIconId;\n expandIcon['aria-labelledby'] = `${expandIcon.id} ${triggerLabelledBy ?? ariaLabelledBy}`.trim();\n expandIcon['aria-label'] = 'Open';\n } else if (ariaLabel) {\n expandIcon['aria-label'] = `Open ${ariaLabel}`;\n } else {\n expandIcon['aria-label'] = 'Open';\n }\n }\n\n return expandIcon;\n}\n"],"names":["slot","useId","useComboboxExpandIconSlot","expandIconFromProps","options","defaultExpandIconId","disabled","hideFromTabOrder","open","ariaLabel","ariaLabelledBy","triggerLabelledBy","expandIcon","optional","renderByDefault","defaultProps","undefined","role","tabIndex","elementType","hasExpandLabel","expandIconId","id","trim"],"mappings":"AAAA,SAASA,IAAI,EAAEC,KAAK,QAAQ,4BAA4B;AAkBxD;;;;CAIC,GACD,OAAO,SAASC,0BACdC,mBAAoD,EACpDC,OAAyC;IAEzC,MAAMC,sBAAsBJ,MAAM;IAClC,MAAM,EACJK,QAAQ,EACRC,gBAAgB,EAChBC,IAAI,EACJ,cAAcC,SAAS,EACvB,mBAAmBC,cAAc,EACjCC,iBAAiB,EAClB,GAAGP;IACJ,MAAMQ,aAAaZ,KAAKa,QAAQ,CAACV,qBAAqB;QACpDW,iBAAiB;QACjBC,cAAc;YACZ,iBAAiBT,WAAW,SAASU;YACrC,iBAAiBR;YACjBS,MAAM;YACNC,UAAUZ,WAAW,CAAC,IAAI;QAC5B;QACAa,aAAa;IACf;IAEA,IAAI,CAACP,YAAY;QACf,OAAOI;IACT;IAEA,IAAIV,YAAYC,kBAAkB;QAChCK,WAAWM,QAAQ,GAAG,CAAC;IACzB;IAEA,MAAME,iBAAiBR,UAAU,CAAC,aAAa,IAAIA,UAAU,CAAC,kBAAkB;IAEhF,IAAI,CAACQ,gBAAgB;QACnB,IAAIT,qBAAqBD,gBAAgB;gBAClBE;YAArB,MAAMS,gBAAeT,iBAAAA,WAAWU,EAAE,cAAbV,4BAAAA,iBAAiBP;YACtCO,WAAWU,EAAE,GAAGD;YAChBT,UAAU,CAAC,kBAAkB,GAAG,GAAGA,WAAWU,EAAE,CAAC,CAAC,EAAEX,8BAAAA,+BAAAA,oBAAqBD,gBAAgB,CAACa,IAAI;YAC9FX,UAAU,CAAC,aAAa,GAAG;QAC7B,OAAO,IAAIH,WAAW;YACpBG,UAAU,CAAC,aAAa,GAAG,CAAC,KAAK,EAAEH,WAAW;QAChD,OAAO;YACLG,UAAU,CAAC,aAAa,GAAG;QAC7B;IACF;IAEA,OAAOA;AACT"}
|
|
@@ -331,7 +331,7 @@ const useIconStyles = /*#__PURE__*/__styles({
|
|
|
331
331
|
mc9l5x: "ftgm304",
|
|
332
332
|
Be2twd7: "f1pp30po",
|
|
333
333
|
qhf8xq: "f10pi13n",
|
|
334
|
-
|
|
334
|
+
fz51y7: "f1amoxe3",
|
|
335
335
|
Bsft5z2: "f13zj6fq",
|
|
336
336
|
E3zdtr: "f1mdlcz9",
|
|
337
337
|
bn5sak: "frwkxtg",
|
|
@@ -381,7 +381,7 @@ const useIconStyles = /*#__PURE__*/__styles({
|
|
|
381
381
|
Bceei9c: "fdrzuqr"
|
|
382
382
|
}
|
|
383
383
|
}, {
|
|
384
|
-
d: [".f1ewtqcl{box-sizing:border-box;}", ".fxkbij4{color:var(--colorNeutralStrokeAccessible);}", ".f1k6fduh{cursor:pointer;}", ".ftgm304{display:block;}", ".f1pp30po{font-size:var(--fontSizeBase500);}", ".f10pi13n{position:relative;}", ".
|
|
384
|
+
d: [".f1ewtqcl{box-sizing:border-box;}", ".fxkbij4{color:var(--colorNeutralStrokeAccessible);}", ".f1k6fduh{cursor:pointer;}", ".ftgm304{display:block;}", ".f1pp30po{font-size:var(--fontSizeBase500);}", ".f10pi13n{position:relative;}", ".f1amoxe3 svg,.f1amoxe3 .fui-Icon-font{display:block;}", ".f13zj6fq::after{content:\"\";}", ".f1mdlcz9::after{position:absolute;}", ".frwkxtg::after{top:0;}", ".fo72kxq::after{bottom:0;}", ".f1n6gb5g::after{left:0;}", ".f15yvnhg::after{right:0;}", ".fjseox{display:none;}", ".f1ekcaio{clip:rect(0px, 0px, 0px, 0px);}", ".f1mpe4l3{height:1px;}", [".f1jlpb2r{margin:-1px;}", {
|
|
385
385
|
p: -1
|
|
386
386
|
}], [".f1a3p1vp{overflow:hidden;}", {
|
|
387
387
|
p: -1
|