@fluentui/react-combobox 9.5.33 → 9.5.35
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 +34 -9
- package/dist/index.d.ts +11 -0
- package/lib/components/Combobox/useCombobox.js +22 -126
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Combobox/useInputTriggerSlot.js +103 -0
- package/lib/components/Combobox/useInputTriggerSlot.js.map +1 -0
- package/lib/components/Dropdown/useButtonTriggerSlot.js +69 -0
- package/lib/components/Dropdown/useButtonTriggerSlot.js.map +1 -0
- package/lib/components/Dropdown/useDropdown.js +18 -76
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/utils/ComboboxBase.types.js.map +1 -1
- package/lib/utils/useComboboxBaseState.js +2 -1
- package/lib/utils/useComboboxBaseState.js.map +1 -1
- package/lib/utils/useListboxSlot.js +37 -0
- package/lib/utils/useListboxSlot.js.map +1 -0
- package/lib/utils/useTriggerSlot.js +75 -0
- package/lib/utils/useTriggerSlot.js.map +1 -0
- package/lib-commonjs/components/Combobox/useCombobox.js +22 -126
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useInputTriggerSlot.js +110 -0
- package/lib-commonjs/components/Combobox/useInputTriggerSlot.js.map +1 -0
- package/lib-commonjs/components/Dropdown/useButtonTriggerSlot.js +76 -0
- package/lib-commonjs/components/Dropdown/useButtonTriggerSlot.js.map +1 -0
- package/lib-commonjs/components/Dropdown/useDropdown.js +17 -75
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/utils/useComboboxBaseState.js +2 -1
- package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
- package/lib-commonjs/utils/useListboxSlot.js +46 -0
- package/lib-commonjs/utils/useListboxSlot.js.map +1 -0
- package/lib-commonjs/utils/useTriggerSlot.js +83 -0
- package/lib-commonjs/utils/useTriggerSlot.js.map +1 -0
- package/package.json +8 -8
- package/lib/utils/useTriggerListboxSlots.js +0 -133
- package/lib/utils/useTriggerListboxSlots.js.map +0 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js +0 -140
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,49 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-combobox
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 18 Dec 2023 17:47:03 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.5.35](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.5.35)
|
|
8
|
+
|
|
9
|
+
Mon, 18 Dec 2023 17:47:03 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.5.34..@fluentui/react-combobox_v9.5.35)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- refactor: Encapsulates listbox and trigger slot construction ([PR #30010](https://github.com/microsoft/fluentui/pull/30010) by lingfan.gao@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-positioning to v9.10.5 ([PR #30010](https://github.com/microsoft/fluentui/pull/30010) by beachball)
|
|
16
|
+
|
|
17
|
+
## [9.5.34](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.5.34)
|
|
18
|
+
|
|
19
|
+
Mon, 18 Dec 2023 14:40:46 GMT
|
|
20
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.5.33..@fluentui/react-combobox_v9.5.34)
|
|
21
|
+
|
|
22
|
+
### Patches
|
|
23
|
+
|
|
24
|
+
- Bump @fluentui/react-context-selector to v9.1.44 ([PR #30103](https://github.com/microsoft/fluentui/pull/30103) by beachball)
|
|
25
|
+
- Bump @fluentui/react-field to v9.1.45 ([PR #30103](https://github.com/microsoft/fluentui/pull/30103) by beachball)
|
|
26
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.22 ([PR #30103](https://github.com/microsoft/fluentui/pull/30103) by beachball)
|
|
27
|
+
- Bump @fluentui/react-portal to v9.4.5 ([PR #30103](https://github.com/microsoft/fluentui/pull/30103) by beachball)
|
|
28
|
+
- Bump @fluentui/react-positioning to v9.10.4 ([PR #30103](https://github.com/microsoft/fluentui/pull/30103) by beachball)
|
|
29
|
+
- Bump @fluentui/react-shared-contexts to v9.13.2 ([PR #30103](https://github.com/microsoft/fluentui/pull/30103) by beachball)
|
|
30
|
+
- Bump @fluentui/react-utilities to v9.15.4 ([PR #30103](https://github.com/microsoft/fluentui/pull/30103) by beachball)
|
|
31
|
+
|
|
7
32
|
## [9.5.33](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.5.33)
|
|
8
33
|
|
|
9
|
-
Thu, 14 Dec 2023 09:
|
|
34
|
+
Thu, 14 Dec 2023 09:58:43 GMT
|
|
10
35
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.5.32..@fluentui/react-combobox_v9.5.33)
|
|
11
36
|
|
|
12
37
|
### Patches
|
|
13
38
|
|
|
14
39
|
- fix: Applies border-box sizing to listbox slot ([PR #30028](https://github.com/microsoft/fluentui/pull/30028) by lingfan.gao@microsoft.com)
|
|
15
|
-
- Bump @fluentui/react-context-selector to v9.1.43 ([
|
|
16
|
-
- Bump @fluentui/react-field to v9.1.44 ([
|
|
17
|
-
- Bump @fluentui/react-jsx-runtime to v9.0.21 ([
|
|
18
|
-
- Bump @fluentui/react-portal to v9.4.4 ([
|
|
19
|
-
- Bump @fluentui/react-positioning to v9.10.3 ([
|
|
20
|
-
- Bump @fluentui/react-shared-contexts to v9.13.1 ([
|
|
21
|
-
- Bump @fluentui/react-utilities to v9.15.3 ([
|
|
40
|
+
- Bump @fluentui/react-context-selector to v9.1.43 ([PR #30056](https://github.com/microsoft/fluentui/pull/30056) by beachball)
|
|
41
|
+
- Bump @fluentui/react-field to v9.1.44 ([PR #30056](https://github.com/microsoft/fluentui/pull/30056) by beachball)
|
|
42
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.21 ([PR #30056](https://github.com/microsoft/fluentui/pull/30056) by beachball)
|
|
43
|
+
- Bump @fluentui/react-portal to v9.4.4 ([PR #30056](https://github.com/microsoft/fluentui/pull/30056) by beachball)
|
|
44
|
+
- Bump @fluentui/react-positioning to v9.10.3 ([PR #30056](https://github.com/microsoft/fluentui/pull/30056) by beachball)
|
|
45
|
+
- Bump @fluentui/react-shared-contexts to v9.13.1 ([PR #30056](https://github.com/microsoft/fluentui/pull/30056) by beachball)
|
|
46
|
+
- Bump @fluentui/react-utilities to v9.15.3 ([PR #30056](https://github.com/microsoft/fluentui/pull/30056) by beachball)
|
|
22
47
|
|
|
23
48
|
## [9.5.32](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.5.32)
|
|
24
49
|
|
package/dist/index.d.ts
CHANGED
|
@@ -90,10 +90,21 @@ declare type ComboboxBaseProps = SelectionProps & Pick<PortalProps, 'mountNode'>
|
|
|
90
90
|
declare type ComboboxBaseState = Required<Pick<ComboboxBaseProps, 'appearance' | 'open' | 'inlinePopup' | 'size'>> & Pick<ComboboxBaseProps, 'mountNode' | 'placeholder' | 'value' | 'multiselect'> & OptionCollectionState & SelectionState & {
|
|
91
91
|
activeOption?: OptionValue;
|
|
92
92
|
focusVisible: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated - no longer used internally
|
|
95
|
+
* whether the combobox/dropdown currently has focus
|
|
96
|
+
*/
|
|
93
97
|
hasFocus: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated - no longer used internally
|
|
100
|
+
* Whether the next blur event should be ignored, and the combobox/dropdown will not close.
|
|
101
|
+
*/
|
|
94
102
|
ignoreNextBlur: React_2.MutableRefObject<boolean>;
|
|
95
103
|
setActiveOption: React_2.Dispatch<React_2.SetStateAction<OptionValue | undefined>>;
|
|
96
104
|
setFocusVisible(focusVisible: boolean): void;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated - no longer used internally
|
|
107
|
+
*/
|
|
97
108
|
setHasFocus(hasFocus: boolean): void;
|
|
98
109
|
setOpen(event: ComboboxBaseOpenEvents, newState: boolean): void;
|
|
99
110
|
setValue(newValue: string | undefined): void;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useFieldControlProps_unstable } from '@fluentui/react-field';
|
|
3
|
-
import { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';
|
|
4
3
|
import { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';
|
|
5
4
|
import { getPartitionedNativeProps, mergeCallbacks, useEventCallback, useId, useMergedRefs, slot } from '@fluentui/react-utilities';
|
|
6
|
-
import { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';
|
|
7
5
|
import { useComboboxBaseState } from '../../utils/useComboboxBaseState';
|
|
8
6
|
import { useComboboxPositioning } from '../../utils/useComboboxPositioning';
|
|
9
|
-
import { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';
|
|
10
7
|
import { Listbox } from '../Listbox/Listbox';
|
|
8
|
+
import { useListboxSlot } from '../../utils/useListboxSlot';
|
|
9
|
+
import { useInputTriggerSlot } from './useInputTriggerSlot';
|
|
11
10
|
/**
|
|
12
11
|
* Create the state required to render Combobox.
|
|
13
12
|
*
|
|
@@ -17,7 +16,6 @@ import { Listbox } from '../Listbox/Listbox';
|
|
|
17
16
|
* @param props - props from this instance of Combobox
|
|
18
17
|
* @param ref - reference to root HTMLElement of Combobox
|
|
19
18
|
*/ export const useCombobox_unstable = (props, ref)=>{
|
|
20
|
-
var _props_input;
|
|
21
19
|
// Merge props from surrounding <Field>, if any
|
|
22
20
|
props = useFieldControlProps_unstable(props, {
|
|
23
21
|
supportsLabelFor: true,
|
|
@@ -28,9 +26,9 @@ import { Listbox } from '../Listbox/Listbox';
|
|
|
28
26
|
...props,
|
|
29
27
|
editable: true
|
|
30
28
|
});
|
|
31
|
-
const {
|
|
29
|
+
const { open, selectOption, setOpen, setValue, value } = baseState;
|
|
32
30
|
const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);
|
|
33
|
-
const { disabled, freeform, inlinePopup
|
|
31
|
+
const { disabled, freeform, inlinePopup } = props;
|
|
34
32
|
const comboId = useId('combobox-');
|
|
35
33
|
const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({
|
|
36
34
|
props,
|
|
@@ -40,48 +38,11 @@ import { Listbox } from '../Listbox/Listbox';
|
|
|
40
38
|
'size'
|
|
41
39
|
]
|
|
42
40
|
});
|
|
43
|
-
|
|
44
|
-
const triggerRef = React.useRef(null);
|
|
45
|
-
// NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set
|
|
46
|
-
// To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows
|
|
47
|
-
// ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888
|
|
48
|
-
const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);
|
|
49
|
-
// save the typing vs. navigating options state, as the space key should behave differently in each case
|
|
50
|
-
// we do not want to update the combobox when this changes, just save the value between renders
|
|
51
|
-
const isTyping = React.useRef(false);
|
|
52
|
-
// set active option and selection based on typing
|
|
53
|
-
const getOptionFromInput = (inputValue)=>{
|
|
54
|
-
const searchString = inputValue === null || inputValue === void 0 ? void 0 : inputValue.trim().toLowerCase();
|
|
55
|
-
if (!searchString || searchString.length === 0) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString) === 0;
|
|
59
|
-
const matches = getOptionsMatchingText(matcher);
|
|
60
|
-
// return first matching option after the current active option, looping back to the top
|
|
61
|
-
if (matches.length > 1 && activeOption) {
|
|
62
|
-
const startIndex = getIndexOfId(activeOption.id);
|
|
63
|
-
const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);
|
|
64
|
-
return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
|
|
65
|
-
}
|
|
66
|
-
var _matches_;
|
|
67
|
-
return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;
|
|
68
|
-
};
|
|
69
|
-
/* Handle typed input */ // reset any typed value when an option is selected
|
|
41
|
+
// reset any typed value when an option is selected
|
|
70
42
|
baseState.selectOption = (ev, option)=>{
|
|
71
43
|
setValue(undefined);
|
|
72
44
|
selectOption(ev, option);
|
|
73
45
|
};
|
|
74
|
-
const onTriggerBlur = (ev)=>{
|
|
75
|
-
// handle selection and updating value if freeform is false
|
|
76
|
-
if (!baseState.open && !freeform) {
|
|
77
|
-
// select matching option, if the value fully matches
|
|
78
|
-
if (value && activeOption && value.trim().toLowerCase() === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.text.toLowerCase())) {
|
|
79
|
-
baseState.selectOption(ev, activeOption);
|
|
80
|
-
}
|
|
81
|
-
// reset typed value when the input loses focus while collapsed, unless freeform is true
|
|
82
|
-
setValue(undefined);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
46
|
baseState.setOpen = (ev, newState)=>{
|
|
86
47
|
if (disabled) {
|
|
87
48
|
return;
|
|
@@ -91,53 +52,27 @@ import { Listbox } from '../Listbox/Listbox';
|
|
|
91
52
|
}
|
|
92
53
|
setOpen(ev, newState);
|
|
93
54
|
};
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const matchingOption = getOptionFromInput(inputValue);
|
|
101
|
-
setActiveOption(matchingOption);
|
|
102
|
-
setFocusVisible(true);
|
|
103
|
-
// clear selection for single-select if the input value no longer matches the selection
|
|
104
|
-
if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || !matchingOption)) {
|
|
105
|
-
clearSelection(ev);
|
|
55
|
+
const triggerRef = React.useRef(null);
|
|
56
|
+
const listbox = useListboxSlot(props.listbox, comboboxPopupRef, {
|
|
57
|
+
state: baseState,
|
|
58
|
+
triggerRef,
|
|
59
|
+
defaultProps: {
|
|
60
|
+
children: props.children
|
|
106
61
|
}
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
62
|
+
});
|
|
63
|
+
var _props_input;
|
|
64
|
+
const triggerSlot = useInputTriggerSlot((_props_input = props.input) !== null && _props_input !== void 0 ? _props_input : {}, useMergedRefs(triggerRef, ref), {
|
|
65
|
+
state: baseState,
|
|
66
|
+
freeform,
|
|
112
67
|
defaultProps: {
|
|
113
|
-
ref: useMergedRefs((_props_input = props.input) === null || _props_input === void 0 ? void 0 : _props_input.ref, triggerRef),
|
|
114
68
|
type: 'text',
|
|
115
69
|
value: value !== null && value !== void 0 ? value : '',
|
|
116
70
|
...triggerNativeProps
|
|
117
|
-
}
|
|
118
|
-
elementType: 'input'
|
|
71
|
+
}
|
|
119
72
|
});
|
|
120
|
-
const resolvedPropsOnKeyDown = triggerSlot.onKeyDown;
|
|
121
|
-
triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);
|
|
122
|
-
triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur); // only resolve listbox slot if needed
|
|
123
|
-
listboxSlot = open || hasFocus ? slot.optional(props.listbox, {
|
|
124
|
-
renderByDefault: true,
|
|
125
|
-
defaultProps: {
|
|
126
|
-
children: props.children
|
|
127
|
-
},
|
|
128
|
-
elementType: Listbox
|
|
129
|
-
}) : undefined;
|
|
130
|
-
[triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);
|
|
131
|
-
const listboxRef = useMergedRefs(listboxSlot === null || listboxSlot === void 0 ? void 0 : listboxSlot.ref, comboboxPopupRef);
|
|
132
|
-
if (hideActiveDescendant) {
|
|
133
|
-
triggerSlot['aria-activedescendant'] = undefined;
|
|
134
|
-
}
|
|
135
|
-
if (listboxSlot) {
|
|
136
|
-
listboxSlot.ref = listboxRef;
|
|
137
|
-
}
|
|
138
73
|
const rootSlot = slot.always(props.root, {
|
|
139
74
|
defaultProps: {
|
|
140
|
-
'aria-owns': !inlinePopup ?
|
|
75
|
+
'aria-owns': !inlinePopup && open ? listbox === null || listbox === void 0 ? void 0 : listbox.id : undefined,
|
|
141
76
|
...rootNativeProps
|
|
142
77
|
},
|
|
143
78
|
elementType: 'div'
|
|
@@ -152,7 +87,7 @@ import { Listbox } from '../Listbox/Listbox';
|
|
|
152
87
|
},
|
|
153
88
|
root: rootSlot,
|
|
154
89
|
input: triggerSlot,
|
|
155
|
-
listbox:
|
|
90
|
+
listbox: open ? listbox : undefined,
|
|
156
91
|
expandIcon: slot.optional(props.expandIcon, {
|
|
157
92
|
renderByDefault: true,
|
|
158
93
|
defaultProps: {
|
|
@@ -164,54 +99,15 @@ import { Listbox } from '../Listbox/Listbox';
|
|
|
164
99
|
}),
|
|
165
100
|
...baseState
|
|
166
101
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
state.input.onKeyDown = useEventCallback((ev)=>{
|
|
170
|
-
if (!open && getDropdownActionFromKey(ev) === 'Type') {
|
|
171
|
-
baseState.setOpen(ev, true);
|
|
172
|
-
}
|
|
173
|
-
// clear activedescendant when moving the text insertion cursor
|
|
174
|
-
if (ev.key === ArrowLeft || ev.key === ArrowRight) {
|
|
175
|
-
setHideActiveDescendant(true);
|
|
176
|
-
} else {
|
|
177
|
-
setHideActiveDescendant(false);
|
|
178
|
-
}
|
|
179
|
-
// update typing state to true if the user is typing
|
|
180
|
-
const action = getDropdownActionFromKey(ev, {
|
|
181
|
-
open,
|
|
182
|
-
multiselect
|
|
183
|
-
});
|
|
184
|
-
if (action === 'Type') {
|
|
185
|
-
isTyping.current = true;
|
|
186
|
-
} else if (action === 'Open' && ev.key !== ' ' || action === 'Next' || action === 'Previous' || action === 'First' || action === 'Last' || action === 'PageUp' || action === 'PageDown') {
|
|
187
|
-
isTyping.current = false;
|
|
188
|
-
}
|
|
189
|
-
// allow space to insert a character if freeform & the last action was typing, or if the popup is closed
|
|
190
|
-
if (freeform && (isTyping.current || !open) && ev.key === ' ') {
|
|
191
|
-
resolvedPropsOnKeyDown === null || resolvedPropsOnKeyDown === void 0 ? void 0 : resolvedPropsOnKeyDown(ev);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
// if we're not allowing space to type, continue with default behavior
|
|
195
|
-
defaultOnTriggerKeyDown === null || defaultOnTriggerKeyDown === void 0 ? void 0 : defaultOnTriggerKeyDown(ev);
|
|
196
|
-
});
|
|
197
|
-
/* handle open/close + focus change when clicking expandIcon */ const { onMouseDown: onIconMouseDown, onClick: onIconClick } = state.expandIcon || {};
|
|
198
|
-
const onExpandIconMouseDown = useEventCallback(mergeCallbacks(onIconMouseDown, ()=>{
|
|
199
|
-
// do not dismiss on blur when closing via clicking the icon
|
|
200
|
-
if (open) {
|
|
201
|
-
baseState.ignoreNextBlur.current = true;
|
|
202
|
-
}
|
|
203
|
-
}));
|
|
204
|
-
const onExpandIconClick = useEventCallback(mergeCallbacks(onIconClick, (event)=>{
|
|
102
|
+
/* handle open/close + focus change when clicking expandIcon */ const { onMouseDown: onIconMouseDown } = state.expandIcon || {};
|
|
103
|
+
const onExpandIconMouseDown = useEventCallback(mergeCallbacks(onIconMouseDown, (event)=>{
|
|
205
104
|
var _triggerRef_current;
|
|
206
|
-
|
|
105
|
+
event.preventDefault();
|
|
207
106
|
state.setOpen(event, !state.open);
|
|
208
107
|
(_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
|
|
209
|
-
// set focus visible=false, since this can only be done with the mouse/pointer
|
|
210
|
-
setFocusVisible(false);
|
|
211
108
|
}));
|
|
212
109
|
if (state.expandIcon) {
|
|
213
110
|
state.expandIcon.onMouseDown = onExpandIconMouseDown;
|
|
214
|
-
state.expandIcon.onClick = onExpandIconClick;
|
|
215
111
|
// If there is no explicit aria-label, calculate default accName attribute for expandIcon button,
|
|
216
112
|
// using the following steps:
|
|
217
113
|
// 1. If there is an aria-label, it is "Open [aria-label]"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n useEventCallback,\n useId,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { SelectionEvents } from '../../utils/Selection.types';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { ComboboxProps, ComboboxState } from './Combobox.types';\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 // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true, supportsSize: true });\n\n const baseState = useComboboxBaseState({ ...props, editable: true });\n const {\n activeOption,\n clearSelection,\n getIndexOfId,\n getOptionsMatchingText,\n hasFocus,\n open,\n selectOption,\n selectedOptions,\n setActiveOption,\n setFocusVisible,\n setOpen,\n setValue,\n value,\n } = baseState;\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);\n const { disabled, freeform, inlinePopup, multiselect } = props;\n const comboId = useId('combobox-');\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['children', 'size'],\n });\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLInputElement>(null);\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n\n // save the typing vs. navigating options state, as the space key should behave differently in each case\n // we do not want to update the combobox when this changes, just save the value between renders\n const isTyping = React.useRef(false);\n\n // set active option and selection based on typing\n const getOptionFromInput = (inputValue: string): OptionValue | undefined => {\n const searchString = inputValue?.trim().toLowerCase();\n\n if (!searchString || searchString.length === 0) {\n return;\n }\n\n const matcher = (optionText: string) => optionText.toLowerCase().indexOf(searchString) === 0;\n const matches = getOptionsMatchingText(matcher);\n\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const startIndex = getIndexOfId(activeOption.id);\n const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);\n return nextMatch ?? matches[0];\n }\n\n return matches[0] ?? undefined;\n };\n\n /* Handle typed input */\n\n // reset any typed value when an option is selected\n baseState.selectOption = (ev: SelectionEvents, option: OptionValue) => {\n setValue(undefined);\n selectOption(ev, option);\n };\n\n const onTriggerBlur = (ev: React.FocusEvent<HTMLInputElement>) => {\n // handle selection and updating value if freeform is false\n if (!baseState.open && !freeform) {\n // select matching option, if the value fully matches\n if (value && activeOption && value.trim().toLowerCase() === activeOption?.text.toLowerCase()) {\n baseState.selectOption(ev, activeOption);\n }\n\n // reset typed value when the input loses focus while collapsed, unless freeform is true\n setValue(undefined);\n }\n };\n\n baseState.setOpen = (ev, newState: boolean) => {\n if (disabled) {\n return;\n }\n\n if (!newState && !freeform) {\n setValue(undefined);\n }\n\n setOpen(ev, newState);\n };\n\n // update value and active option based on input\n const onTriggerChange = (ev: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = ev.target.value;\n // update uncontrolled value\n baseState.setValue(inputValue);\n\n // handle updating active option based on input\n const matchingOption = getOptionFromInput(inputValue);\n setActiveOption(matchingOption);\n\n setFocusVisible(true);\n\n // clear selection for single-select if the input value no longer matches the selection\n if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || !matchingOption)) {\n clearSelection(ev);\n }\n };\n\n // resolve input and listbox slot props\n let triggerSlot: Slot<'input'>;\n let listboxSlot: Slot<typeof Listbox> | undefined;\n\n triggerSlot = slot.always(props.input, {\n defaultProps: {\n ref: useMergedRefs(props.input?.ref, triggerRef),\n type: 'text',\n value: value ?? '',\n ...triggerNativeProps,\n },\n elementType: 'input',\n });\n const resolvedPropsOnKeyDown = triggerSlot.onKeyDown;\n triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);\n triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur); // only resolve listbox slot if needed\n listboxSlot =\n open || hasFocus\n ? slot.optional(props.listbox, {\n renderByDefault: true,\n defaultProps: { children: props.children },\n elementType: Listbox,\n })\n : undefined;\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n const listboxRef = useMergedRefs(listboxSlot?.ref, comboboxPopupRef);\n\n if (hideActiveDescendant) {\n triggerSlot['aria-activedescendant'] = undefined;\n }\n\n if (listboxSlot) {\n listboxSlot.ref = listboxRef;\n }\n\n const rootSlot = slot.always(props.root, {\n defaultProps: {\n 'aria-owns': !inlinePopup ? listboxSlot?.id : undefined,\n ...rootNativeProps,\n },\n elementType: 'div',\n });\n rootSlot.ref = useMergedRefs(rootSlot.ref, comboboxTargetRef);\n\n const state: ComboboxState = {\n components: { root: 'div', input: 'input', expandIcon: 'span', listbox: Listbox },\n root: rootSlot,\n input: triggerSlot,\n listbox: listboxSlot,\n expandIcon: slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n 'aria-expanded': open,\n children: <ChevronDownIcon />,\n role: 'button',\n },\n elementType: 'span',\n }),\n ...baseState,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\n\n /* Set input.onKeyDown here, so we can override the default behavior for spacebar */\n const defaultOnTriggerKeyDown = state.input.onKeyDown;\n state.input.onKeyDown = useEventCallback((ev: React.KeyboardEvent<HTMLInputElement>) => {\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n baseState.setOpen(ev, true);\n }\n\n // clear activedescendant when moving the text insertion cursor\n if (ev.key === ArrowLeft || ev.key === ArrowRight) {\n setHideActiveDescendant(true);\n } else {\n setHideActiveDescendant(false);\n }\n\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(ev, { open, multiselect });\n if (action === 'Type') {\n isTyping.current = true;\n }\n // otherwise, update the typing state to false if opening or navigating dropdown options\n // other actions, like closing the dropdown, should not impact typing state.\n else if (\n (action === 'Open' && ev.key !== ' ') ||\n action === 'Next' ||\n action === 'Previous' ||\n action === 'First' ||\n action === 'Last' ||\n action === 'PageUp' ||\n action === 'PageDown'\n ) {\n isTyping.current = false;\n }\n\n // allow space to insert a character if freeform & the last action was typing, or if the popup is closed\n if (freeform && (isTyping.current || !open) && ev.key === ' ') {\n resolvedPropsOnKeyDown?.(ev);\n return;\n }\n\n // if we're not allowing space to type, continue with default behavior\n defaultOnTriggerKeyDown?.(ev);\n });\n\n /* handle open/close + focus change when clicking expandIcon */\n const { onMouseDown: onIconMouseDown, onClick: onIconClick } = state.expandIcon || {};\n const onExpandIconMouseDown = useEventCallback(\n mergeCallbacks(onIconMouseDown, () => {\n // do not dismiss on blur when closing via clicking the icon\n if (open) {\n baseState.ignoreNextBlur.current = true;\n }\n }),\n );\n\n const onExpandIconClick = useEventCallback(\n mergeCallbacks(onIconClick, (event: React.MouseEvent<HTMLSpanElement>) => {\n // open and set focus\n state.setOpen(event, !state.open);\n triggerRef.current?.focus();\n\n // set focus visible=false, since this can only be done with the mouse/pointer\n setFocusVisible(false);\n }),\n );\n\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\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 return state;\n};\n"],"names":["React","useFieldControlProps_unstable","ArrowLeft","ArrowRight","ChevronDownRegular","ChevronDownIcon","getPartitionedNativeProps","mergeCallbacks","useEventCallback","useId","useMergedRefs","slot","getDropdownActionFromKey","useComboboxBaseState","useComboboxPositioning","useTriggerListboxSlots","Listbox","useCombobox_unstable","props","ref","supportsLabelFor","supportsRequired","supportsSize","baseState","editable","activeOption","clearSelection","getIndexOfId","getOptionsMatchingText","hasFocus","open","selectOption","selectedOptions","setActiveOption","setFocusVisible","setOpen","setValue","value","comboboxPopupRef","comboboxTargetRef","disabled","freeform","inlinePopup","multiselect","comboId","primary","triggerNativeProps","root","rootNativeProps","primarySlotTagName","excludedPropNames","rootRef","useRef","triggerRef","hideActiveDescendant","setHideActiveDescendant","useState","isTyping","getOptionFromInput","inputValue","searchString","trim","toLowerCase","length","matcher","optionText","indexOf","matches","startIndex","id","nextMatch","find","option","undefined","ev","onTriggerBlur","text","newState","onTriggerChange","target","matchingOption","triggerSlot","listboxSlot","always","input","defaultProps","type","elementType","resolvedPropsOnKeyDown","onKeyDown","onChange","onBlur","optional","listbox","renderByDefault","children","listboxRef","rootSlot","state","components","expandIcon","role","defaultOnTriggerKeyDown","key","action","current","onMouseDown","onIconMouseDown","onClick","onIconClick","onExpandIconMouseDown","ignoreNextBlur","onExpandIconClick","event","focus","hasExpandLabel","defaultOpenString","chevronId","chevronLabelledBy"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SAASC,SAAS,EAAEC,UAAU,QAAQ,0BAA0B;AAChE,SAASC,sBAAsBC,eAAe,QAAQ,wBAAwB;AAC9E,SACEC,yBAAyB,EACzBC,cAAc,EACdC,gBAAgB,EAChBC,KAAK,EACLC,aAAa,EACbC,IAAI,QACC,4BAA4B;AACnC,SAASC,wBAAwB,QAAQ,iCAAiC;AAC1E,SAASC,oBAAoB,QAAQ,mCAAmC;AACxE,SAASC,sBAAsB,QAAQ,qCAAqC;AAC5E,SAASC,sBAAsB,QAAQ,qCAAqC;AAC5E,SAASC,OAAO,QAAQ,qBAAqB;AAM7C;;;;;;;;CAQC,GACD,OAAO,MAAMC,uBAAuB,CAACC,OAAsBC;QAwHlCD;IAvHvB,+CAA+C;IAC/CA,QAAQjB,8BAA8BiB,OAAO;QAAEE,kBAAkB;QAAMC,kBAAkB;QAAMC,cAAc;IAAK;IAElH,MAAMC,YAAYV,qBAAqB;QAAE,GAAGK,KAAK;QAAEM,UAAU;IAAK;IAClE,MAAM,EACJC,YAAY,EACZC,cAAc,EACdC,YAAY,EACZC,sBAAsB,EACtBC,QAAQ,EACRC,IAAI,EACJC,YAAY,EACZC,eAAe,EACfC,eAAe,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AE"}
|
|
1
|
+
{"version":3,"sources":["useCombobox.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useFieldControlProps_unstable } from '@fluentui/react-field';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n mergeCallbacks,\n useEventCallback,\n useId,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPositioning } from '../../utils/useComboboxPositioning';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { SelectionEvents } from '../../utils/Selection.types';\nimport type { OptionValue } from '../../utils/OptionCollection.types';\nimport type { ComboboxProps, ComboboxState } from './Combobox.types';\nimport { useListboxSlot } from '../../utils/useListboxSlot';\nimport { useInputTriggerSlot } from './useInputTriggerSlot';\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 // Merge props from surrounding <Field>, if any\n props = useFieldControlProps_unstable(props, { supportsLabelFor: true, supportsRequired: true, supportsSize: true });\n\n const baseState = useComboboxBaseState({ ...props, editable: true });\n const { open, selectOption, setOpen, setValue, value } = baseState;\n const [comboboxPopupRef, comboboxTargetRef] = useComboboxPositioning(props);\n const { disabled, freeform, inlinePopup } = props;\n const comboId = useId('combobox-');\n\n const { primary: triggerNativeProps, root: rootNativeProps } = getPartitionedNativeProps({\n props,\n primarySlotTagName: 'input',\n excludedPropNames: ['children', 'size'],\n });\n\n // reset any typed value when an option is selected\n baseState.selectOption = (ev: SelectionEvents, option: OptionValue) => {\n setValue(undefined);\n selectOption(ev, option);\n };\n\n baseState.setOpen = (ev, newState: boolean) => {\n if (disabled) {\n return;\n }\n\n if (!newState && !freeform) {\n setValue(undefined);\n }\n\n setOpen(ev, newState);\n };\n\n const triggerRef = React.useRef<HTMLInputElement>(null);\n\n const listbox = useListboxSlot(props.listbox, comboboxPopupRef, {\n state: baseState,\n triggerRef,\n defaultProps: {\n children: props.children,\n },\n });\n\n const triggerSlot = useInputTriggerSlot(props.input ?? {}, useMergedRefs(triggerRef, ref), {\n state: baseState,\n freeform,\n defaultProps: {\n type: 'text',\n value: value ?? '',\n ...triggerNativeProps,\n },\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 state: ComboboxState = {\n components: { root: 'div', input: 'input', expandIcon: 'span', listbox: Listbox },\n root: rootSlot,\n input: triggerSlot,\n listbox: open ? listbox : undefined,\n expandIcon: slot.optional(props.expandIcon, {\n renderByDefault: true,\n defaultProps: {\n 'aria-expanded': open,\n children: <ChevronDownIcon />,\n role: 'button',\n },\n elementType: 'span',\n }),\n ...baseState,\n };\n\n /* handle open/close + focus change when clicking expandIcon */\n const { onMouseDown: onIconMouseDown } = state.expandIcon || {};\n\n const onExpandIconMouseDown = useEventCallback(\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 return state;\n};\n"],"names":["React","useFieldControlProps_unstable","ChevronDownRegular","ChevronDownIcon","getPartitionedNativeProps","mergeCallbacks","useEventCallback","useId","useMergedRefs","slot","useComboboxBaseState","useComboboxPositioning","Listbox","useListboxSlot","useInputTriggerSlot","useCombobox_unstable","props","ref","supportsLabelFor","supportsRequired","supportsSize","baseState","editable","open","selectOption","setOpen","setValue","value","comboboxPopupRef","comboboxTargetRef","disabled","freeform","inlinePopup","comboId","primary","triggerNativeProps","root","rootNativeProps","primarySlotTagName","excludedPropNames","ev","option","undefined","newState","triggerRef","useRef","listbox","state","defaultProps","children","triggerSlot","input","type","rootSlot","always","id","elementType","components","expandIcon","optional","renderByDefault","role","onMouseDown","onIconMouseDown","onExpandIconMouseDown","event","preventDefault","current","focus","hasExpandLabel","defaultOpenString","chevronId","chevronLabelledBy"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,6BAA6B,QAAQ,wBAAwB;AACtE,SAASC,sBAAsBC,eAAe,QAAQ,wBAAwB;AAC9E,SACEC,yBAAyB,EACzBC,cAAc,EACdC,gBAAgB,EAChBC,KAAK,EACLC,aAAa,EACbC,IAAI,QACC,4BAA4B;AACnC,SAASC,oBAAoB,QAAQ,mCAAmC;AACxE,SAASC,sBAAsB,QAAQ,qCAAqC;AAC5E,SAASC,OAAO,QAAQ,qBAAqB;AAI7C,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,mBA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W,UAAU,CAAC,kBAAkB;QAC5F,MAAMY,oBAAoB,QAAQ,gDAAgD;QAClF,IAAI,CAACD,gBAAgB;YACnB,IAAIrD,KAAK,CAAC,kBAAkB,EAAE;oBACV+B;gBAAlB,MAAMwB,YAAYxB,CAAAA,uBAAAA,MAAMW,UAAU,CAACH,EAAE,cAAnBR,kCAAAA,uBAAuB,CAAC,EAAEd,QAAQ,QAAQ,CAAC;gBAC7D,MAAMuC,oBAAoB,CAAC,EAAED,UAAU,CAAC,EAAExB,MAAMI,KAAK,CAAC,kBAAkB,CAAC,CAAC;gBAE1EJ,MAAMW,UAAU,CAAC,aAAa,GAAGY;gBACjCvB,MAAMW,UAAU,CAACH,EAAE,GAAGgB;gBACtBxB,MAAMW,UAAU,CAAC,kBAAkB,GAAGc;YACxC,OAAO,IAAIxD,KAAK,CAAC,aAAa,EAAE;gBAC9B+B,MAAMW,UAAU,CAAC,aAAa,GAAG,CAAC,EAAEY,kBAAkB,CAAC,EAAEtD,KAAK,CAAC,aAAa,CAAC,CAAC;YAChF,OAAO;gBACL+B,MAAMW,UAAU,CAAC,aAAa,GAAGY;YACnC;QACF;IACF;IAEA,OAAOvB;AACT,EAAE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';
|
|
3
|
+
import { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';
|
|
4
|
+
import { useTriggerSlot } from '../../utils/useTriggerSlot';
|
|
5
|
+
import { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';
|
|
6
|
+
/*
|
|
7
|
+
* useInputTriggerSlot returns a tuple of trigger/listbox shorthand,
|
|
8
|
+
* with the semantics and event handlers needed for the Combobox and Dropdown components.
|
|
9
|
+
* The element type of the ref should always match the element type used in the trigger shorthand.
|
|
10
|
+
*/ export function useInputTriggerSlot(triggerFromProps, ref, options) {
|
|
11
|
+
const { state: { open, value, activeOption, selectOption, setValue, setActiveOption, setFocusVisible, multiselect, selectedOptions, clearSelection, getOptionsMatchingText, getIndexOfId, setOpen }, freeform, defaultProps } = options;
|
|
12
|
+
const onBlur = (ev)=>{
|
|
13
|
+
// handle selection and updating value if freeform is false
|
|
14
|
+
if (!open && !freeform) {
|
|
15
|
+
// select matching option, if the value fully matches
|
|
16
|
+
if (value && activeOption && value.trim().toLowerCase() === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.text.toLowerCase())) {
|
|
17
|
+
selectOption(ev, activeOption);
|
|
18
|
+
}
|
|
19
|
+
// reset typed value when the input loses focus while collapsed, unless freeform is true
|
|
20
|
+
setValue(undefined);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const getOptionFromInput = (inputValue)=>{
|
|
24
|
+
const searchString = inputValue === null || inputValue === void 0 ? void 0 : inputValue.trim().toLowerCase();
|
|
25
|
+
if (!searchString || searchString.length === 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString) === 0;
|
|
29
|
+
const matches = getOptionsMatchingText(matcher);
|
|
30
|
+
// return first matching option after the current active option, looping back to the top
|
|
31
|
+
if (matches.length > 1 && activeOption) {
|
|
32
|
+
const startIndex = getIndexOfId(activeOption.id);
|
|
33
|
+
const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);
|
|
34
|
+
return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
|
|
35
|
+
}
|
|
36
|
+
var _matches_;
|
|
37
|
+
return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;
|
|
38
|
+
};
|
|
39
|
+
// update value and active option based on input
|
|
40
|
+
const onChange = (ev)=>{
|
|
41
|
+
const inputValue = ev.target.value;
|
|
42
|
+
// update uncontrolled value
|
|
43
|
+
setValue(inputValue);
|
|
44
|
+
// handle updating active option based on input
|
|
45
|
+
const matchingOption = getOptionFromInput(inputValue);
|
|
46
|
+
setActiveOption(matchingOption);
|
|
47
|
+
setFocusVisible(true);
|
|
48
|
+
// clear selection for single-select if the input value no longer matches the selection
|
|
49
|
+
if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || !matchingOption)) {
|
|
50
|
+
clearSelection(ev);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const trigger = useTriggerSlot(triggerFromProps, ref, {
|
|
54
|
+
state: options.state,
|
|
55
|
+
defaultProps,
|
|
56
|
+
elementType: 'input'
|
|
57
|
+
});
|
|
58
|
+
trigger.onChange = mergeCallbacks(trigger.onChange, onChange);
|
|
59
|
+
trigger.onBlur = mergeCallbacks(trigger.onBlur, onBlur);
|
|
60
|
+
// NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set
|
|
61
|
+
// To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows
|
|
62
|
+
// ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888
|
|
63
|
+
const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);
|
|
64
|
+
// save the typing vs. navigating options state, as the space key should behave differently in each case
|
|
65
|
+
// we do not want to update the combobox when this changes, just save the value between renders
|
|
66
|
+
const isTyping = React.useRef(false);
|
|
67
|
+
/**
|
|
68
|
+
* Freeform combobox should not select
|
|
69
|
+
*/ const defaultOnKeyDown = trigger.onKeyDown;
|
|
70
|
+
const onKeyDown = useEventCallback((ev)=>{
|
|
71
|
+
if (!open && getDropdownActionFromKey(ev) === 'Type') {
|
|
72
|
+
setOpen(ev, true);
|
|
73
|
+
}
|
|
74
|
+
// clear activedescendant when moving the text insertion cursor
|
|
75
|
+
if (ev.key === ArrowLeft || ev.key === ArrowRight) {
|
|
76
|
+
setHideActiveDescendant(true);
|
|
77
|
+
} else {
|
|
78
|
+
setHideActiveDescendant(false);
|
|
79
|
+
}
|
|
80
|
+
// update typing state to true if the user is typing
|
|
81
|
+
const action = getDropdownActionFromKey(ev, {
|
|
82
|
+
open,
|
|
83
|
+
multiselect
|
|
84
|
+
});
|
|
85
|
+
if (action === 'Type') {
|
|
86
|
+
isTyping.current = true;
|
|
87
|
+
} else if (action === 'Open' && ev.key !== ' ' || action === 'Next' || action === 'Previous' || action === 'First' || action === 'Last' || action === 'PageUp' || action === 'PageDown') {
|
|
88
|
+
isTyping.current = false;
|
|
89
|
+
}
|
|
90
|
+
// allow space to insert a character if freeform & the last action was typing, or if the popup is closed
|
|
91
|
+
if (freeform && (isTyping.current || !open) && ev.key === ' ') {
|
|
92
|
+
var _triggerFromProps_onKeyDown;
|
|
93
|
+
triggerFromProps === null || triggerFromProps === void 0 ? void 0 : (_triggerFromProps_onKeyDown = triggerFromProps.onKeyDown) === null || _triggerFromProps_onKeyDown === void 0 ? void 0 : _triggerFromProps_onKeyDown.call(triggerFromProps, ev);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
defaultOnKeyDown === null || defaultOnKeyDown === void 0 ? void 0 : defaultOnKeyDown(ev);
|
|
97
|
+
});
|
|
98
|
+
trigger.onKeyDown = onKeyDown;
|
|
99
|
+
if (hideActiveDescendant) {
|
|
100
|
+
trigger['aria-activedescendant'] = undefined;
|
|
101
|
+
}
|
|
102
|
+
return trigger;
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useInputTriggerSlot.ts"],"sourcesContent":["import * as React from 'react';\nimport { mergeCallbacks, useEventCallback } from '@fluentui/react-utilities';\nimport type { ExtractSlotProps, Slot, SlotComponentType } from '@fluentui/react-utilities';\nimport { ArrowLeft, ArrowRight } from '@fluentui/keyboard-keys';\nimport { useTriggerSlot, UseTriggerSlotState } from '../../utils/useTriggerSlot';\nimport { ComboboxProps, ComboboxState } from './Combobox.types';\nimport { OptionValue } from '../../utils/OptionCollection.types';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\n\ntype UsedComboboxState = UseTriggerSlotState &\n Pick<ComboboxState, 'value' | 'setValue' | 'selectedOptions' | 'clearSelection' | 'getOptionsMatchingText'>;\n\ntype UseInputTriggerSlotOptions = {\n state: UsedComboboxState;\n freeform: boolean | undefined;\n defaultProps: Partial<ComboboxProps>;\n};\n\n/*\n * useInputTriggerSlot returns a tuple of trigger/listbox shorthand,\n * with the semantics and event handlers needed for the Combobox and Dropdown components.\n * The element type of the ref should always match the element type used in the trigger shorthand.\n */\nexport function useInputTriggerSlot(\n triggerFromProps: NonNullable<Slot<'input'>>,\n ref: React.Ref<HTMLInputElement>,\n options: UseInputTriggerSlotOptions,\n): SlotComponentType<ExtractSlotProps<Slot<'input'>>> {\n const {\n state: {\n open,\n value,\n activeOption,\n selectOption,\n setValue,\n setActiveOption,\n setFocusVisible,\n multiselect,\n selectedOptions,\n clearSelection,\n getOptionsMatchingText,\n getIndexOfId,\n setOpen,\n },\n freeform,\n defaultProps,\n } = options;\n\n const onBlur = (ev: React.FocusEvent<HTMLInputElement>) => {\n // handle selection and updating value if freeform is false\n if (!open && !freeform) {\n // select matching option, if the value fully matches\n if (value && activeOption && value.trim().toLowerCase() === activeOption?.text.toLowerCase()) {\n selectOption(ev, activeOption);\n }\n\n // reset typed value when the input loses focus while collapsed, unless freeform is true\n setValue(undefined);\n }\n };\n\n const getOptionFromInput = (inputValue: string): OptionValue | undefined => {\n const searchString = inputValue?.trim().toLowerCase();\n\n if (!searchString || searchString.length === 0) {\n return;\n }\n\n const matcher = (optionText: string) => optionText.toLowerCase().indexOf(searchString) === 0;\n const matches = getOptionsMatchingText(matcher);\n\n // return first matching option after the current active option, looping back to the top\n if (matches.length > 1 && activeOption) {\n const startIndex = getIndexOfId(activeOption.id);\n const nextMatch = matches.find(option => getIndexOfId(option.id) >= startIndex);\n return nextMatch ?? matches[0];\n }\n\n return matches[0] ?? undefined;\n };\n\n // update value and active option based on input\n const onChange = (ev: React.ChangeEvent<HTMLInputElement>) => {\n const inputValue = ev.target.value;\n // update uncontrolled value\n setValue(inputValue);\n\n // handle updating active option based on input\n const matchingOption = getOptionFromInput(inputValue);\n setActiveOption(matchingOption);\n\n setFocusVisible(true);\n\n // clear selection for single-select if the input value no longer matches the selection\n if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || !matchingOption)) {\n clearSelection(ev);\n }\n };\n\n const trigger = useTriggerSlot(triggerFromProps, ref, {\n state: options.state,\n defaultProps,\n elementType: 'input',\n });\n\n trigger.onChange = mergeCallbacks(trigger.onChange, onChange);\n trigger.onBlur = mergeCallbacks(trigger.onBlur, onBlur);\n\n // NVDA and JAWS have bugs that suppress reading the input value text when aria-activedescendant is set\n // To prevent this, we clear the HTML attribute (but save the state) when a user presses left/right arrows\n // ref: https://github.com/microsoft/fluentui/issues/26359#issuecomment-1397759888\n const [hideActiveDescendant, setHideActiveDescendant] = React.useState(false);\n // save the typing vs. navigating options state, as the space key should behave differently in each case\n // we do not want to update the combobox when this changes, just save the value between renders\n const isTyping = React.useRef(false);\n\n /**\n * Freeform combobox should not select\n */\n const defaultOnKeyDown = trigger.onKeyDown;\n const onKeyDown = useEventCallback((ev: React.KeyboardEvent<HTMLInputElement>) => {\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n setOpen(ev, true);\n }\n\n // clear activedescendant when moving the text insertion cursor\n if (ev.key === ArrowLeft || ev.key === ArrowRight) {\n setHideActiveDescendant(true);\n } else {\n setHideActiveDescendant(false);\n }\n\n // update typing state to true if the user is typing\n const action = getDropdownActionFromKey(ev, { open, multiselect });\n if (action === 'Type') {\n isTyping.current = true;\n }\n // otherwise, update the typing state to false if opening or navigating dropdown options\n // other actions, like closing the dropdown, should not impact typing state.\n else if (\n (action === 'Open' && ev.key !== ' ') ||\n action === 'Next' ||\n action === 'Previous' ||\n action === 'First' ||\n action === 'Last' ||\n action === 'PageUp' ||\n action === 'PageDown'\n ) {\n isTyping.current = false;\n }\n\n // allow space to insert a character if freeform & the last action was typing, or if the popup is closed\n if (freeform && (isTyping.current || !open) && ev.key === ' ') {\n triggerFromProps?.onKeyDown?.(ev);\n return;\n }\n\n defaultOnKeyDown?.(ev);\n });\n\n trigger.onKeyDown = onKeyDown;\n\n if (hideActiveDescendant) {\n trigger['aria-activedescendant'] = undefined;\n }\n\n return trigger;\n}\n"],"names":["React","mergeCallbacks","useEventCallback","ArrowLeft","ArrowRight","useTriggerSlot","getDropdownActionFromKey","useInputTriggerSlot","triggerFromProps","ref","options","state","open","value","activeOption","selectOption","setValue","setActiveOption","setFocusVisible","multiselect","selectedOptions","clearSelection","getOptionsMatchingText","getIndexOfId","setOpen","freeform","defaultProps","onBlur","ev","trim","toLowerCase","text","undefined","getOptionFromInput","inputValue","searchString","length","matcher","optionText","indexOf","matches","startIndex","id","nextMatch","find","option","onChange","target","matchingOption","trigger","elementType","hideActiveDescendant","setHideActiveDescendant","useState","isTyping","useRef","defaultOnKeyDown","onKeyDown","key","action","current"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,cAAc,EAAEC,gBAAgB,QAAQ,4BAA4B;AAE7E,SAASC,SAAS,EAAEC,UAAU,QAAQ,0BAA0B;AAChE,SAASC,cAAc,QAA6B,6BAA6B;AAGjF,SAASC,wBAAwB,QAAQ,iCAAiC;AAW1E;;;;CAIC,GACD,OAAO,SAASC,oBACdC,gBAA4C,EAC5CC,GAAgC,EAChCC,OAAmC;IAEnC,MAAM,EACJC,OAAO,EACLC,IAAI,EACJC,KAAK,EACLC,YAAY,EACZC,YAAY,EACZC,QAAQ,EACRC,eAAe,EACfC,eAAe,EACfC,WAAW,EACXC,eAAe,EACfC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,EACZC,OAAO,EACR,EACDC,QAAQ,EACRC,YAAY,EACb,GAAGhB;IAEJ,MAAMiB,SAAS,CAACC;QACd,2DAA2D;QAC3D,IAAI,CAAChB,QAAQ,CAACa,UAAU;YACtB,qDAAqD;YACrD,IAAIZ,SAASC,gBAAgBD,MAAMgB,IAAI,GAAGC,WAAW,QAAOhB,yBAAAA,mCAAAA,aAAciB,IAAI,CAACD,WAAW,KAAI;gBAC5Ff,aAAaa,IAAId;YACnB;YAEA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utilities';
|
|
3
|
+
import { useTriggerSlot } from '../../utils/useTriggerSlot';
|
|
4
|
+
import { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';
|
|
5
|
+
/*
|
|
6
|
+
* useButtonTriggerSlot returns a tuple of trigger/listbox shorthand,
|
|
7
|
+
* with the semantics and event handlers needed for the Combobox and Dropdown components.
|
|
8
|
+
* The element type of the ref should always match the element type used in the trigger shorthand.
|
|
9
|
+
*/ export function useButtonTriggerSlot(triggerFromProps, ref, options) {
|
|
10
|
+
const { state: { open, activeOption, setOpen, getOptionsMatchingText, getIndexOfId, setActiveOption, setFocusVisible }, defaultProps } = options;
|
|
11
|
+
// jump to matching option based on typing
|
|
12
|
+
const searchString = React.useRef('');
|
|
13
|
+
const [setKeyTimeout, clearKeyTimeout] = useTimeout();
|
|
14
|
+
const getNextMatchingOption = ()=>{
|
|
15
|
+
// first check for matches for the full searchString
|
|
16
|
+
let matcher = (optionText)=>optionText.toLowerCase().indexOf(searchString.current) === 0;
|
|
17
|
+
let matches = getOptionsMatchingText(matcher);
|
|
18
|
+
let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0;
|
|
19
|
+
// if the dropdown is already open and the searchstring is a single character,
|
|
20
|
+
// then look after the current activeOption for letters
|
|
21
|
+
// this is so slowly typing the same letter will cycle through matches
|
|
22
|
+
if (open && searchString.current.length === 1) {
|
|
23
|
+
startIndex++;
|
|
24
|
+
}
|
|
25
|
+
// if there are no direct matches, check if the search is all the same letter, e.g. "aaa"
|
|
26
|
+
if (!matches.length) {
|
|
27
|
+
const letters = searchString.current.split('');
|
|
28
|
+
const allSameLetter = letters.length && letters.every((letter)=>letter === letters[0]);
|
|
29
|
+
// if the search is all the same letter, cycle through options starting with that letter
|
|
30
|
+
if (allSameLetter) {
|
|
31
|
+
startIndex++;
|
|
32
|
+
matcher = (optionText)=>optionText.toLowerCase().indexOf(letters[0]) === 0;
|
|
33
|
+
matches = getOptionsMatchingText(matcher);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// if there is an active option and multiple matches,
|
|
37
|
+
// return first matching option after the current active option, looping back to the top
|
|
38
|
+
if (matches.length > 1 && activeOption) {
|
|
39
|
+
const nextMatch = matches.find((option)=>getIndexOfId(option.id) >= startIndex);
|
|
40
|
+
return nextMatch !== null && nextMatch !== void 0 ? nextMatch : matches[0];
|
|
41
|
+
}
|
|
42
|
+
var _matches_;
|
|
43
|
+
return (_matches_ = matches[0]) !== null && _matches_ !== void 0 ? _matches_ : undefined;
|
|
44
|
+
};
|
|
45
|
+
const onTriggerKeyDown = (ev)=>{
|
|
46
|
+
// clear timeout, if it exists
|
|
47
|
+
clearKeyTimeout();
|
|
48
|
+
// if the key was a char key, update search string
|
|
49
|
+
if (getDropdownActionFromKey(ev) === 'Type') {
|
|
50
|
+
// update search string
|
|
51
|
+
searchString.current += ev.key.toLowerCase();
|
|
52
|
+
setKeyTimeout(()=>{
|
|
53
|
+
searchString.current = '';
|
|
54
|
+
}, 500);
|
|
55
|
+
// update state
|
|
56
|
+
!open && setOpen(ev, true);
|
|
57
|
+
const nextOption = getNextMatchingOption();
|
|
58
|
+
setActiveOption(nextOption);
|
|
59
|
+
setFocusVisible(true);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const trigger = useTriggerSlot(triggerFromProps, ref, {
|
|
63
|
+
state: options.state,
|
|
64
|
+
defaultProps,
|
|
65
|
+
elementType: 'button'
|
|
66
|
+
});
|
|
67
|
+
trigger.onKeyDown = mergeCallbacks(onTriggerKeyDown, trigger.onKeyDown);
|
|
68
|
+
return trigger;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useButtonTriggerSlot.ts"],"sourcesContent":["import * as React from 'react';\nimport { useTimeout, mergeCallbacks } from '@fluentui/react-utilities';\nimport type { Slot, ExtractSlotProps, SlotComponentType } from '@fluentui/react-utilities';\nimport { useTriggerSlot, UseTriggerSlotState } from '../../utils/useTriggerSlot';\nimport { OptionValue } from '../../utils/OptionCollection.types';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { DropdownState } from './Dropdown.types';\n\ntype UsedDropdownState = UseTriggerSlotState & Pick<DropdownState, 'getOptionsMatchingText'>;\ntype UseButtonTriggerSlotOptions = {\n state: UsedDropdownState;\n defaultProps: unknown;\n};\n\n/*\n * useButtonTriggerSlot returns a tuple of trigger/listbox shorthand,\n * with the semantics and event handlers needed for the Combobox and Dropdown components.\n * The element type of the ref should always match the element type used in the trigger shorthand.\n */\nexport function useButtonTriggerSlot(\n triggerFromProps: NonNullable<Slot<'button'>>,\n ref: React.Ref<HTMLButtonElement>,\n options: UseButtonTriggerSlotOptions,\n): SlotComponentType<ExtractSlotProps<Slot<'button'>>> {\n const {\n state: { open, activeOption, setOpen, getOptionsMatchingText, getIndexOfId, setActiveOption, setFocusVisible },\n defaultProps,\n } = options;\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 = (optionText: string) => optionText.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 = (optionText: string) => optionText.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 const trigger = useTriggerSlot(triggerFromProps, ref, { state: options.state, defaultProps, elementType: 'button' });\n trigger.onKeyDown = mergeCallbacks(onTriggerKeyDown, trigger.onKeyDown);\n\n return trigger;\n}\n"],"names":["React","useTimeout","mergeCallbacks","useTriggerSlot","getDropdownActionFromKey","useButtonTriggerSlot","triggerFromProps","ref","options","state","open","activeOption","setOpen","getOptionsMatchingText","getIndexOfId","setActiveOption","setFocusVisible","defaultProps","searchString","useRef","setKeyTimeout","clearKeyTimeout","getNextMatchingOption","matcher","optionText","toLowerCase","indexOf","current","matches","startIndex","id","length","letters","split","allSameLetter","every","letter","nextMatch","find","option","undefined","onTriggerKeyDown","ev","key","nextOption","trigger","elementType","onKeyDown"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,UAAU,EAAEC,cAAc,QAAQ,4BAA4B;AAEvE,SAASC,cAAc,QAA6B,6BAA6B;AAEjF,SAASC,wBAAwB,QAAQ,iCAAiC;AAS1E;;;;CAIC,GACD,OAAO,SAASC,qBACdC,gBAA6C,EAC7CC,GAAiC,EACjCC,OAAoC;IAEpC,MAAM,EACJC,OAAO,EAAEC,IAAI,EAAEC,YAAY,EAAEC,OAAO,EAAEC,sBAAsB,EAAEC,YAAY,EAAEC,eAAe,EAAEC,eAAe,EAAE,EAC9GC,YAAY,EACb,GAAGT;IAEJ,0CAA0C;IAC1C,MAAMU,eAAelB,MAAMmB,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