@fluentui/react-combobox 9.0.0-beta.16 → 9.0.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +123 -1
- package/CHANGELOG.md +34 -2
- package/dist/index.d.ts +32 -9
- package/lib/components/Combobox/useCombobox.js +24 -18
- package/lib/components/Combobox/useCombobox.js.map +1 -1
- package/lib/components/Combobox/useComboboxStyles.js +11 -5
- package/lib/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib/components/Dropdown/useDropdown.js +3 -3
- package/lib/components/Dropdown/useDropdown.js.map +1 -1
- package/lib/components/Dropdown/useDropdownStyles.js +8 -2
- package/lib/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib/components/Listbox/Listbox.types.js.map +1 -1
- package/lib/components/Listbox/useListbox.js +3 -1
- package/lib/components/Listbox/useListbox.js.map +1 -1
- package/lib/components/Option/Option.types.js.map +1 -1
- package/lib/components/Option/useOption.js +30 -11
- package/lib/components/Option/useOption.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/useComboboxBaseState.js +6 -4
- package/lib/utils/useComboboxBaseState.js.map +1 -1
- package/lib/utils/useOptionCollection.js +3 -3
- package/lib/utils/useOptionCollection.js.map +1 -1
- package/lib/utils/useSelection.js +2 -0
- package/lib/utils/useSelection.js.map +1 -1
- package/lib/utils/useTriggerListboxSlots.js +1 -1
- package/lib/utils/useTriggerListboxSlots.js.map +1 -1
- package/lib-commonjs/components/Combobox/useCombobox.js +25 -18
- package/lib-commonjs/components/Combobox/useCombobox.js.map +1 -1
- package/lib-commonjs/components/Combobox/useComboboxStyles.js +10 -4
- package/lib-commonjs/components/Combobox/useComboboxStyles.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdown.js +3 -3
- package/lib-commonjs/components/Dropdown/useDropdown.js.map +1 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js +7 -1
- package/lib-commonjs/components/Dropdown/useDropdownStyles.js.map +1 -1
- package/lib-commonjs/components/Listbox/useListbox.js +3 -1
- package/lib-commonjs/components/Listbox/useListbox.js.map +1 -1
- package/lib-commonjs/components/Option/useOption.js +30 -11
- package/lib-commonjs/components/Option/useOption.js.map +1 -1
- package/lib-commonjs/utils/useComboboxBaseState.js +6 -4
- package/lib-commonjs/utils/useComboboxBaseState.js.map +1 -1
- package/lib-commonjs/utils/useOptionCollection.js +3 -3
- package/lib-commonjs/utils/useOptionCollection.js.map +1 -1
- package/lib-commonjs/utils/useSelection.js +2 -0
- package/lib-commonjs/utils/useSelection.js.map +1 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js +1 -1
- package/lib-commonjs/utils/useTriggerListboxSlots.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,129 @@
|
|
|
2
2
|
"name": "@fluentui/react-combobox",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Tue, 20 Dec 2022 14:55:47 GMT",
|
|
6
|
+
"tag": "@fluentui/react-combobox_v9.0.0-beta.18",
|
|
7
|
+
"version": "9.0.0-beta.18",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "sarah.higley@microsoft.com",
|
|
12
|
+
"package": "@fluentui/react-combobox",
|
|
13
|
+
"commit": "e7ee1eff2c65a070786a31ee1170072937c0e143",
|
|
14
|
+
"comment": "feat: update Listbox and Option to use menu and menuitemcheckbox semantics for multiselect"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "sarah.higley@microsoft.com",
|
|
18
|
+
"package": "@fluentui/react-combobox",
|
|
19
|
+
"commit": "72504f20386a53a551b2580a52c760704f526b21",
|
|
20
|
+
"comment": "feat: multiselect Combobox does not display selected options in the text field"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"author": "beachball",
|
|
24
|
+
"package": "@fluentui/react-combobox",
|
|
25
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.3",
|
|
26
|
+
"commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"author": "beachball",
|
|
30
|
+
"package": "@fluentui/react-combobox",
|
|
31
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-alpha.11",
|
|
32
|
+
"commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"author": "beachball",
|
|
36
|
+
"package": "@fluentui/react-combobox",
|
|
37
|
+
"comment": "Bump @fluentui/react-portal to v9.0.13",
|
|
38
|
+
"commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"author": "beachball",
|
|
42
|
+
"package": "@fluentui/react-combobox",
|
|
43
|
+
"comment": "Bump @fluentui/react-positioning to v9.3.4",
|
|
44
|
+
"commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"author": "beachball",
|
|
48
|
+
"package": "@fluentui/react-combobox",
|
|
49
|
+
"comment": "Bump @fluentui/react-theme to v9.1.4",
|
|
50
|
+
"commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"author": "beachball",
|
|
54
|
+
"package": "@fluentui/react-combobox",
|
|
55
|
+
"comment": "Bump @fluentui/react-utilities to v9.3.0",
|
|
56
|
+
"commit": "e7530bc179fd0e303448083c76a4af41a0e15322"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"date": "Mon, 05 Dec 2022 18:29:21 GMT",
|
|
63
|
+
"tag": "@fluentui/react-combobox_v9.0.0-beta.17",
|
|
64
|
+
"version": "9.0.0-beta.17",
|
|
65
|
+
"comments": {
|
|
66
|
+
"prerelease": [
|
|
67
|
+
{
|
|
68
|
+
"author": "sarah.higley@microsoft.com",
|
|
69
|
+
"package": "@fluentui/react-combobox",
|
|
70
|
+
"commit": "84a26d8111dc4bb9d3cd1edbb99691e68899d261",
|
|
71
|
+
"comment": " feat: update Option value to be a non-display value, and add an Option text prop that is required if the child is not a string"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"author": "sarah.higley@microsoft.com",
|
|
75
|
+
"package": "@fluentui/react-combobox",
|
|
76
|
+
"commit": "d1c530bef46d1ddd962ee29ff8fd510475ec5c96",
|
|
77
|
+
"comment": "fix: open Combobox popup when typing"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"author": "behowell@microsoft.com",
|
|
81
|
+
"package": "@fluentui/react-combobox",
|
|
82
|
+
"commit": "6679b1430f61182d34c0b90de33806d9624d811a",
|
|
83
|
+
"comment": "chore: Replace use of fontSize tokens with typographyStyles"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"author": "sarah.higley@microsoft.com",
|
|
87
|
+
"package": "@fluentui/react-combobox",
|
|
88
|
+
"commit": "e19f11c2cc4e52c06d93bcd2eed8ae84572b18d1",
|
|
89
|
+
"comment": "fix: Combobox should close on blur after clicking expand icon"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"author": "beachball",
|
|
93
|
+
"package": "@fluentui/react-combobox",
|
|
94
|
+
"comment": "Bump @fluentui/react-field to v9.0.0-alpha.10",
|
|
95
|
+
"commit": "4c29542a51bf068e171690cc8e59c14489883912"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"author": "beachball",
|
|
99
|
+
"package": "@fluentui/react-combobox",
|
|
100
|
+
"comment": "Bump @fluentui/react-portal to v9.0.12",
|
|
101
|
+
"commit": "4c29542a51bf068e171690cc8e59c14489883912"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"author": "beachball",
|
|
105
|
+
"package": "@fluentui/react-combobox",
|
|
106
|
+
"comment": "Bump @fluentui/react-positioning to v9.3.3",
|
|
107
|
+
"commit": "4c29542a51bf068e171690cc8e59c14489883912"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"author": "beachball",
|
|
111
|
+
"package": "@fluentui/react-combobox",
|
|
112
|
+
"comment": "Bump @fluentui/react-theme to v9.1.3",
|
|
113
|
+
"commit": "4c29542a51bf068e171690cc8e59c14489883912"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"none": [
|
|
117
|
+
{
|
|
118
|
+
"author": "sarah.higley@microsoft.com",
|
|
119
|
+
"package": "@fluentui/react-combobox",
|
|
120
|
+
"commit": "3c7120c60f749da6b0c1427bbdc69320daa4e1e7",
|
|
121
|
+
"comment": "feat: add Dropdown stories"
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"date": "Thu, 17 Nov 2022 23:05:35 GMT",
|
|
6
128
|
"tag": "@fluentui/react-combobox_v9.0.0-beta.16",
|
|
7
129
|
"version": "9.0.0-beta.16",
|
|
8
130
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-combobox
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 20 Dec 2022 14:55:47 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.0.0-beta.18](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.0.0-beta.18)
|
|
8
|
+
|
|
9
|
+
Tue, 20 Dec 2022 14:55:47 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.0.0-beta.17..@fluentui/react-combobox_v9.0.0-beta.18)
|
|
11
|
+
|
|
12
|
+
### Changes
|
|
13
|
+
|
|
14
|
+
- feat: update Listbox and Option to use menu and menuitemcheckbox semantics for multiselect ([PR #25905](https://github.com/microsoft/fluentui/pull/25905) by sarah.higley@microsoft.com)
|
|
15
|
+
- feat: multiselect Combobox does not display selected options in the text field ([PR #25898](https://github.com/microsoft/fluentui/pull/25898) by sarah.higley@microsoft.com)
|
|
16
|
+
- Bump @fluentui/react-context-selector to v9.1.3 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
|
|
17
|
+
- Bump @fluentui/react-field to v9.0.0-alpha.11 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
|
|
18
|
+
- Bump @fluentui/react-portal to v9.0.13 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
|
|
19
|
+
- Bump @fluentui/react-positioning to v9.3.4 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
|
|
20
|
+
- Bump @fluentui/react-theme to v9.1.4 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
|
|
21
|
+
- Bump @fluentui/react-utilities to v9.3.0 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
|
|
22
|
+
|
|
23
|
+
## [9.0.0-beta.17](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.0.0-beta.17)
|
|
24
|
+
|
|
25
|
+
Mon, 05 Dec 2022 18:29:21 GMT
|
|
26
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.0.0-beta.16..@fluentui/react-combobox_v9.0.0-beta.17)
|
|
27
|
+
|
|
28
|
+
### Changes
|
|
29
|
+
|
|
30
|
+
- feat: update Option value to be a non-display value, and add an Option text prop that is required if the child is not a string ([PR #25379](https://github.com/microsoft/fluentui/pull/25379) by sarah.higley@microsoft.com)
|
|
31
|
+
- fix: open Combobox popup when typing ([PR #25769](https://github.com/microsoft/fluentui/pull/25769) by sarah.higley@microsoft.com)
|
|
32
|
+
- chore: Replace use of fontSize tokens with typographyStyles ([PR #25727](https://github.com/microsoft/fluentui/pull/25727) by behowell@microsoft.com)
|
|
33
|
+
- fix: Combobox should close on blur after clicking expand icon ([PR #25771](https://github.com/microsoft/fluentui/pull/25771) by sarah.higley@microsoft.com)
|
|
34
|
+
- Bump @fluentui/react-field to v9.0.0-alpha.10 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
|
|
35
|
+
- Bump @fluentui/react-portal to v9.0.12 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
|
|
36
|
+
- Bump @fluentui/react-positioning to v9.3.3 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
|
|
37
|
+
- Bump @fluentui/react-theme to v9.1.3 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
|
|
38
|
+
|
|
7
39
|
## [9.0.0-beta.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-combobox_v9.0.0-beta.16)
|
|
8
40
|
|
|
9
|
-
Thu, 17 Nov 2022 23:
|
|
41
|
+
Thu, 17 Nov 2022 23:05:35 GMT
|
|
10
42
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-combobox_v9.0.0-beta.15..@fluentui/react-combobox_v9.0.0-beta.16)
|
|
11
43
|
|
|
12
44
|
### Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ declare type ComboboxBaseProps = SelectionProps & {
|
|
|
47
47
|
*/
|
|
48
48
|
defaultOpen?: boolean;
|
|
49
49
|
/**
|
|
50
|
-
* The default value when the combobox's value is uncontrolled
|
|
50
|
+
* The default value displayed in the trigger input or button when the combobox's value is uncontrolled
|
|
51
51
|
*/
|
|
52
52
|
defaultValue?: string;
|
|
53
53
|
/**
|
|
@@ -89,17 +89,16 @@ declare type ComboboxBaseProps = SelectionProps & {
|
|
|
89
89
|
/**
|
|
90
90
|
* State used in rendering Combobox
|
|
91
91
|
*/
|
|
92
|
-
declare type ComboboxBaseState = Required<Pick<ComboboxBaseProps, 'appearance' | 'open' | 'inlinePopup' | 'size'>> & Pick<ComboboxBaseProps, 'placeholder' | 'value'> & OptionCollectionState & SelectionState & {
|
|
92
|
+
declare type ComboboxBaseState = Required<Pick<ComboboxBaseProps, 'appearance' | 'open' | 'inlinePopup' | 'size'>> & Pick<ComboboxBaseProps, 'placeholder' | 'value' | 'multiselect'> & OptionCollectionState & SelectionState & {
|
|
93
93
|
activeOption?: OptionValue;
|
|
94
94
|
focusVisible: boolean;
|
|
95
95
|
hasFocus: boolean;
|
|
96
96
|
ignoreNextBlur: React_2.MutableRefObject<boolean>;
|
|
97
|
-
selectOption(event: SelectionEvents, option: OptionValue): void;
|
|
98
97
|
setActiveOption(option?: OptionValue): void;
|
|
99
98
|
setFocusVisible(focusVisible: boolean): void;
|
|
100
99
|
setHasFocus(hasFocus: boolean): void;
|
|
101
100
|
setOpen(event: ComboboxBaseOpenEvents, newState: boolean): void;
|
|
102
|
-
setValue(newValue: string): void;
|
|
101
|
+
setValue(newValue: string | undefined): void;
|
|
103
102
|
};
|
|
104
103
|
|
|
105
104
|
export declare const comboboxClassNames: SlotClassNames<ComboboxSlots>;
|
|
@@ -205,7 +204,7 @@ export declare type ListboxSlots = {
|
|
|
205
204
|
/**
|
|
206
205
|
* State used in rendering Listbox
|
|
207
206
|
*/
|
|
208
|
-
export declare type ListboxState = ComponentState<ListboxSlots> & OptionCollectionState & SelectionState & {
|
|
207
|
+
export declare type ListboxState = ComponentState<ListboxSlots> & OptionCollectionState & Pick<SelectionProps, 'multiselect'> & SelectionState & {
|
|
209
208
|
activeOption?: OptionValue;
|
|
210
209
|
focusVisible: boolean;
|
|
211
210
|
selectOption(event: SelectionEvents, option: OptionValue): void;
|
|
@@ -229,8 +228,8 @@ declare type OptionCollectionState = {
|
|
|
229
228
|
getOptionAtIndex(index: number): OptionValue | undefined;
|
|
230
229
|
/** Returns the option data by key. */
|
|
231
230
|
getOptionById(id: string): OptionValue | undefined;
|
|
232
|
-
/** Returns an array of options filtered by a value matching function. */
|
|
233
|
-
|
|
231
|
+
/** Returns an array of options filtered by a value matching function against the option's text string. */
|
|
232
|
+
getOptionsMatchingText(matcher: (value: string) => boolean): OptionValue[];
|
|
234
233
|
/** The unordered option data. */
|
|
235
234
|
options: OptionValue[];
|
|
236
235
|
registerOption: (option: OptionValue, element: HTMLElement) => () => void;
|
|
@@ -260,6 +259,7 @@ export declare type OptionGroupState = ComponentState<OptionGroupSlots>;
|
|
|
260
259
|
|
|
261
260
|
declare type OptionOnSelectData = {
|
|
262
261
|
optionValue: string | undefined;
|
|
262
|
+
optionText: string | undefined;
|
|
263
263
|
selectedOptions: string[];
|
|
264
264
|
};
|
|
265
265
|
|
|
@@ -273,7 +273,24 @@ export declare type OptionProps = ComponentProps<Partial<OptionSlots>> & {
|
|
|
273
273
|
*/
|
|
274
274
|
disabled?: boolean;
|
|
275
275
|
value?: string;
|
|
276
|
-
}
|
|
276
|
+
} & ({
|
|
277
|
+
/**
|
|
278
|
+
* An optional override the string value of the Option's display text,
|
|
279
|
+
* defaulting to the Option's child content.
|
|
280
|
+
* This is used as the Dropdown button's or Combobox input's value when the option is selected,
|
|
281
|
+
* and as the comparison for type-to-find keyboard functionality.
|
|
282
|
+
*/
|
|
283
|
+
text?: string;
|
|
284
|
+
children: string;
|
|
285
|
+
} | {
|
|
286
|
+
/**
|
|
287
|
+
* The string value of the Option's display text when the Option's children are not a string.
|
|
288
|
+
* This is used as the Dropdown button's or Combobox input's value when the option is selected,
|
|
289
|
+
* and as the comparison for type-to-find keyboard functionality.
|
|
290
|
+
*/
|
|
291
|
+
text: string;
|
|
292
|
+
children?: React_2.ReactNode;
|
|
293
|
+
});
|
|
277
294
|
|
|
278
295
|
export declare type OptionSlots = {
|
|
279
296
|
root: NonNullable<Slot<'div'>>;
|
|
@@ -295,6 +312,8 @@ declare type OptionValue = {
|
|
|
295
312
|
disabled?: boolean;
|
|
296
313
|
/** The `id` attribute of the option. */
|
|
297
314
|
id: string;
|
|
315
|
+
/** The `text` string for the option. */
|
|
316
|
+
text: string;
|
|
298
317
|
/** The value string of the option. */
|
|
299
318
|
value: string;
|
|
300
319
|
};
|
|
@@ -343,7 +362,11 @@ declare type SelectionProps = {
|
|
|
343
362
|
selectedOptions?: string[];
|
|
344
363
|
};
|
|
345
364
|
|
|
346
|
-
declare type SelectionState =
|
|
365
|
+
declare type SelectionState = {
|
|
366
|
+
clearSelection: (event: SelectionEvents) => void;
|
|
367
|
+
selectedOptions: string[];
|
|
368
|
+
selectOption: (event: SelectionEvents, option: OptionValue) => void;
|
|
369
|
+
};
|
|
347
370
|
|
|
348
371
|
/**
|
|
349
372
|
* Create the state required to render Combobox.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';
|
|
3
3
|
import { getPartitionedNativeProps, resolveShorthand, mergeCallbacks, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';
|
|
4
|
+
import { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';
|
|
4
5
|
import { useComboboxBaseState } from '../../utils/useComboboxBaseState';
|
|
5
6
|
import { useComboboxPopup } from '../../utils/useComboboxPopup';
|
|
6
7
|
import { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';
|
|
@@ -18,12 +19,14 @@ import { Listbox } from '../Listbox/Listbox';
|
|
|
18
19
|
export const useCombobox_unstable = (props, ref) => {
|
|
19
20
|
var _a;
|
|
20
21
|
|
|
21
|
-
const baseState = useComboboxBaseState(props
|
|
22
|
+
const baseState = useComboboxBaseState({ ...props,
|
|
23
|
+
editable: true
|
|
24
|
+
});
|
|
22
25
|
const {
|
|
23
26
|
activeOption,
|
|
24
27
|
clearSelection,
|
|
25
28
|
getIndexOfId,
|
|
26
|
-
|
|
29
|
+
getOptionsMatchingText,
|
|
27
30
|
hasFocus,
|
|
28
31
|
open,
|
|
29
32
|
selectOption,
|
|
@@ -55,27 +58,20 @@ export const useCombobox_unstable = (props, ref) => {
|
|
|
55
58
|
|
|
56
59
|
const width = open ? `${(_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth}px` : undefined;
|
|
57
60
|
setPopupWidth(width);
|
|
58
|
-
}, [open]); //
|
|
59
|
-
|
|
60
|
-
const getSearchString = inputValue => {
|
|
61
|
-
// if there are commas in the value string, take the text after the last comma
|
|
62
|
-
const searchString = inputValue.split(',').pop();
|
|
63
|
-
return (searchString === null || searchString === void 0 ? void 0 : searchString.trim().toLowerCase()) || '';
|
|
64
|
-
}; // set active option and selection based on typing
|
|
65
|
-
|
|
61
|
+
}, [open]); // set active option and selection based on typing
|
|
66
62
|
|
|
67
63
|
const getOptionFromInput = inputValue => {
|
|
68
64
|
var _a;
|
|
69
65
|
|
|
70
|
-
const searchString =
|
|
66
|
+
const searchString = inputValue === null || inputValue === void 0 ? void 0 : inputValue.trim().toLowerCase();
|
|
71
67
|
|
|
72
|
-
if (searchString.length === 0) {
|
|
68
|
+
if (!searchString || searchString.length === 0) {
|
|
73
69
|
return;
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
const matcher =
|
|
72
|
+
const matcher = optionText => optionText.toLowerCase().indexOf(searchString) === 0;
|
|
77
73
|
|
|
78
|
-
const matches =
|
|
74
|
+
const matches = getOptionsMatchingText(matcher); // return first matching option after the current active option, looping back to the top
|
|
79
75
|
|
|
80
76
|
if (matches.length > 1 && activeOption) {
|
|
81
77
|
const startIndex = getIndexOfId(activeOption.id);
|
|
@@ -98,7 +94,7 @@ export const useCombobox_unstable = (props, ref) => {
|
|
|
98
94
|
// handle selection and updating value if freeform is false
|
|
99
95
|
if (!baseState.open && !freeform) {
|
|
100
96
|
// select matching option, if the value fully matches
|
|
101
|
-
if (value && activeOption &&
|
|
97
|
+
if (value && activeOption && value.trim().toLowerCase() === (activeOption === null || activeOption === void 0 ? void 0 : activeOption.value.toLowerCase())) {
|
|
102
98
|
baseState.selectOption(ev, activeOption);
|
|
103
99
|
} // reset typed value when the input loses focus while collapsed, unless freeform is true
|
|
104
100
|
|
|
@@ -128,6 +124,13 @@ export const useCombobox_unstable = (props, ref) => {
|
|
|
128
124
|
if (!multiselect && selectedOptions.length === 1 && (inputValue.length < 1 || selectedOptions[0].indexOf(inputValue) !== 0)) {
|
|
129
125
|
clearSelection(ev);
|
|
130
126
|
}
|
|
127
|
+
}; // open Combobox when typing
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
const onTriggerKeyDown = ev => {
|
|
131
|
+
if (!open && getDropdownActionFromKey(ev) === 'Type') {
|
|
132
|
+
setOpen(ev, true);
|
|
133
|
+
}
|
|
131
134
|
}; // resolve input and listbox slot props
|
|
132
135
|
|
|
133
136
|
|
|
@@ -143,7 +146,8 @@ export const useCombobox_unstable = (props, ref) => {
|
|
|
143
146
|
}
|
|
144
147
|
});
|
|
145
148
|
triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);
|
|
146
|
-
triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur);
|
|
149
|
+
triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur);
|
|
150
|
+
triggerSlot.onKeyDown = mergeCallbacks(triggerSlot.onKeyDown, onTriggerKeyDown); // only resolve listbox slot if needed
|
|
147
151
|
|
|
148
152
|
listboxSlot = open || hasFocus ? resolveShorthand(props.listbox, {
|
|
149
153
|
required: true,
|
|
@@ -187,8 +191,10 @@ export const useCombobox_unstable = (props, ref) => {
|
|
|
187
191
|
onClick: onIconClick
|
|
188
192
|
} = state.expandIcon || {};
|
|
189
193
|
const onExpandIconMouseDown = useEventCallback(mergeCallbacks(onIconMouseDown, () => {
|
|
190
|
-
// do not dismiss on blur when clicking the icon
|
|
191
|
-
|
|
194
|
+
// do not dismiss on blur when closing via clicking the icon
|
|
195
|
+
if (open) {
|
|
196
|
+
baseState.ignoreNextBlur.current = true;
|
|
197
|
+
}
|
|
192
198
|
}));
|
|
193
199
|
const onExpandIconClick = useEventCallback(mergeCallbacks(onIconClick, event => {
|
|
194
200
|
var _a; // open and set focus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-combobox/src/components/Combobox/useCombobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,kBAAkB,IAAI,eAA/B,QAAsD,uBAAtD;AACA,SACE,yBADF,EAEE,gBAFF,EAGE,cAHF,EAIE,gBAJF,EAKE,aALF,QAMO,2BANP;AAOA,SAAS,oBAAT,QAAqC,kCAArC;AACA,SAAS,gBAAT,QAAiC,8BAAjC;AACA,SAAS,sBAAT,QAAuC,oCAAvC;AACA,SAAS,OAAT,QAAwB,oBAAxB;AAMA;;;;;;;;AAQG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAAC,KAAD,EAAuB,GAAvB,KAA0E;;;EAC5G,MAAM,SAAS,GAAG,oBAAoB,CAAC,KAAD,CAAtC;EACA,MAAM;IACJ,YADI;IAEJ,cAFI;IAGJ,YAHI;IAIJ,uBAJI;IAKJ,QALI;IAMJ,IANI;IAOJ,YAPI;IAQJ,eARI;IASJ,eATI;IAUJ,eAVI;IAWJ,OAXI;IAYJ,QAZI;IAaJ;EAbI,IAcF,SAdJ;EAeA,MAAM;IAAE,QAAF;IAAY;EAAZ,IAA4B,KAAlC;EAEA,MAAM;IAAE,OAAO,EAAE,kBAAX;IAA+B,IAAI,EAAE;EAArC,IAAyD,yBAAyB,CAAC;IACvF,KADuF;IAEvF,kBAAkB,EAAE,OAFmE;IAGvF,iBAAiB,EAAE,CAAC,UAAD,EAAa,MAAb;EAHoE,CAAD,CAAxF;EAMA,MAAM,OAAO,GAAG,KAAK,CAAC,MAAN,CAA6B,IAA7B,CAAhB;EACA,MAAM,UAAU,GAAG,KAAK,CAAC,MAAN,CAA+B,IAA/B,CAAnB,CA1B4G,CA4B5G;;EACA,MAAM,CAAC,UAAD,EAAa,aAAb,IAA8B,KAAK,CAAC,QAAN,EAApC;EAC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AC,KAAK,CAAC,IAA5B;IACA,CAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,KAAF,EAAlB;EACD,CAJa,CAD0B,CAA1C;;EAQA,IAAI,KAAK,CAAC,UAAV,EAAsB;IACpB,KAAK,CAAC,UAAN,CAAiB,WAAjB,GAA+B,qBAA/B;IACA,KAAK,CAAC,UAAN,CAAiB,OAAjB,GAA2B,iBAA3B;EACD;;EAED,OAAO,KAAP;AACD,CArMM","sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n resolveShorthand,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { 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 const baseState = useComboboxBaseState(props);\n const {\n activeOption,\n clearSelection,\n getIndexOfId,\n getOptionsMatchingValue,\n hasFocus,\n open,\n selectOption,\n selectedOptions,\n setActiveOption,\n setFocusVisible,\n setOpen,\n setValue,\n value,\n } = baseState;\n const { freeform, multiselect } = props;\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 // calculate listbox width style based on trigger width\n const [popupWidth, setPopupWidth] = React.useState<string>();\n React.useEffect(() => {\n const width = open ? `${rootRef.current?.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n\n // handle input type-to-select\n const getSearchString = (inputValue: string): string => {\n // if there are commas in the value string, take the text after the last comma\n const searchString = inputValue.split(',').pop();\n\n return searchString?.trim().toLowerCase() || '';\n };\n\n // set active option and selection based on typing\n const getOptionFromInput = (inputValue: string): OptionValue | undefined => {\n const searchString = getSearchString(inputValue);\n\n if (searchString.length === 0) {\n return;\n }\n\n const matcher = (optionValue: string) => optionValue.toLowerCase().indexOf(searchString) === 0;\n const matches = getOptionsMatchingValue(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 && getSearchString(value) === activeOption?.value.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 (!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 (\n !multiselect &&\n selectedOptions.length === 1 &&\n (inputValue.length < 1 || selectedOptions[0].indexOf(inputValue) !== 0)\n ) {\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 = resolveShorthand(props.input, {\n required: true,\n defaultProps: {\n ref: useMergedRefs(props.input?.ref, triggerRef),\n type: 'text',\n value: value ?? '',\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);\n triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur);\n\n // only resolve listbox slot if needed\n listboxSlot =\n open || hasFocus\n ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: { width: popupWidth },\n },\n })\n : undefined;\n\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n\n const state: ComboboxState = {\n components: {\n root: 'div',\n input: 'input',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n ...rootNativeProps,\n },\n }),\n input: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: <ChevronDownIcon />,\n },\n }),\n ...baseState,\n setOpen,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\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 clicking the icon\n baseState.ignoreNextBlur.current = true;\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 );\n\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-combobox/src/components/Combobox/useCombobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,kBAAkB,IAAI,eAA/B,QAAsD,uBAAtD;AACA,SACE,yBADF,EAEE,gBAFF,EAGE,cAHF,EAIE,gBAJF,EAKE,aALF,QAMO,2BANP;AAOA,SAAS,wBAAT,QAAyC,gCAAzC;AACA,SAAS,oBAAT,QAAqC,kCAArC;AACA,SAAS,gBAAT,QAAiC,8BAAjC;AACA,SAAS,sBAAT,QAAuC,oCAAvC;AACA,SAAS,OAAT,QAAwB,oBAAxB;AAMA;;;;;;;;AAQG;;AACH,OAAO,MAAM,oBAAoB,GAAG,CAAC,KAAD,EAAuB,GAAvB,KAA0E;;;EAC5G,MAAM,SAAS,GAAG,oBAAoB,CAAC,EAAE,GAAG,KAAL;IAAY,QAAQ,EAAE;EAAtB,CAAD,CAAtC;EACA,MAAM;IACJ,YADI;IAEJ,cAFI;IAGJ,YAHI;IAIJ,sBAJI;IAKJ,QALI;IAMJ,IANI;IAOJ,YAPI;IAQJ,eARI;IASJ,eATI;IAUJ,eAVI;IAWJ,OAXI;IAYJ,QAZI;IAaJ;EAbI,IAcF,SAdJ;EAeA,MAAM;IAAE,QAAF;IAAY;EAAZ,IAA4B,KAAlC;EAEA,MAAM;IAAE,OAAO,EAAE,kBAAX;IAA+B,IAAI,EAAE;EAArC,IAAyD,yBAAyB,CAAC;IACvF,KADuF;IAEvF,k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;EAEA;;EACA,MAAM;IAAE,WAAW,EAAE,eAAf;IAAgC,OAAO,EAAE;EAAzC,IAAyD,KAAK,CAAC,UAAN,IAAoB,EAAnF;EACA,MAAM,qBAAqB,GAAG,gBAAgB,CAC5C,cAAc,CAAC,eAAD,EAAkB,MAAK;IACnC;IACA,IAAI,IAAJ,EAAU;MACR,SAAS,CAAC,cAAV,CAAyB,OAAzB,GAAmC,IAAnC;IACD;EACF,CALa,CAD8B,CAA9C;EASA,MAAM,iBAAiB,GAAG,gBAAgB,CACxC,cAAc,CAAC,WAAD,EAAe,KAAD,IAA6C;WAAA,CACvE;;;IACA,KAAK,CAAC,OAAN,CAAc,KAAd,EAAqB,CAAC,KAAK,CAAC,IAA5B;IACA,CAAA,EAAA,GAAA,UAAU,CAAC,OAAX,MAAkB,IAAlB,IAAkB,EAAA,KAAA,KAAA,CAAlB,GAAkB,KAAA,CAAlB,GAAkB,EAAA,CAAE,KAAF,EAAlB;EACD,CAJa,CAD0B,CAA1C;;EAQA,IAAI,KAAK,CAAC,UAAV,EAAsB;IACpB,KAAK,CAAC,UAAN,CAAiB,WAAjB,GAA+B,qBAA/B;IACA,KAAK,CAAC,UAAN,CAAiB,OAAjB,GAA2B,iBAA3B;EACD;;EAED,OAAO,KAAP;AACD,CAvMM","sourcesContent":["import * as React from 'react';\nimport { ChevronDownRegular as ChevronDownIcon } from '@fluentui/react-icons';\nimport {\n getPartitionedNativeProps,\n resolveShorthand,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport { getDropdownActionFromKey } from '../../utils/dropdownKeyActions';\nimport { useComboboxBaseState } from '../../utils/useComboboxBaseState';\nimport { useComboboxPopup } from '../../utils/useComboboxPopup';\nimport { useTriggerListboxSlots } from '../../utils/useTriggerListboxSlots';\nimport { Listbox } from '../Listbox/Listbox';\nimport type { Slot } from '@fluentui/react-utilities';\nimport type { 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 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 { freeform, multiselect } = props;\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 // calculate listbox width style based on trigger width\n const [popupWidth, setPopupWidth] = React.useState<string>();\n React.useEffect(() => {\n const width = open ? `${rootRef.current?.clientWidth}px` : undefined;\n setPopupWidth(width);\n }, [open]);\n\n // 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?.value.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 (!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 (\n !multiselect &&\n selectedOptions.length === 1 &&\n (inputValue.length < 1 || selectedOptions[0].indexOf(inputValue) !== 0)\n ) {\n clearSelection(ev);\n }\n };\n\n // open Combobox when typing\n const onTriggerKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {\n if (!open && getDropdownActionFromKey(ev) === 'Type') {\n setOpen(ev, true);\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 = resolveShorthand(props.input, {\n required: true,\n defaultProps: {\n ref: useMergedRefs(props.input?.ref, triggerRef),\n type: 'text',\n value: value ?? '',\n ...triggerNativeProps,\n },\n });\n\n triggerSlot.onChange = mergeCallbacks(triggerSlot.onChange, onTriggerChange);\n triggerSlot.onBlur = mergeCallbacks(triggerSlot.onBlur, onTriggerBlur);\n triggerSlot.onKeyDown = mergeCallbacks(triggerSlot.onKeyDown, onTriggerKeyDown);\n\n // only resolve listbox slot if needed\n listboxSlot =\n open || hasFocus\n ? resolveShorthand(props.listbox, {\n required: true,\n defaultProps: {\n children: props.children,\n style: { width: popupWidth },\n },\n })\n : undefined;\n\n [triggerSlot, listboxSlot] = useComboboxPopup(props, triggerSlot, listboxSlot);\n [triggerSlot, listboxSlot] = useTriggerListboxSlots(props, baseState, ref, triggerSlot, listboxSlot);\n\n const state: ComboboxState = {\n components: {\n root: 'div',\n input: 'input',\n expandIcon: 'span',\n listbox: Listbox,\n },\n root: resolveShorthand(props.root, {\n required: true,\n defaultProps: {\n ...rootNativeProps,\n },\n }),\n input: triggerSlot,\n listbox: listboxSlot,\n expandIcon: resolveShorthand(props.expandIcon, {\n required: true,\n defaultProps: {\n children: <ChevronDownIcon />,\n },\n }),\n ...baseState,\n setOpen,\n };\n\n state.root.ref = useMergedRefs(state.root.ref, rootRef);\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 );\n\n if (state.expandIcon) {\n state.expandIcon.onMouseDown = onExpandIconMouseDown;\n state.expandIcon.onClick = onExpandIconClick;\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tokens } from '@fluentui/react-theme';
|
|
1
|
+
import { tokens, typographyStyles } from '@fluentui/react-theme';
|
|
2
2
|
import { __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
3
3
|
import { iconSizes } from '../../utils/internalTokens';
|
|
4
4
|
export const comboboxClassNames = {
|
|
@@ -200,8 +200,10 @@ const useInputStyles = /*#__PURE__*/__styles({
|
|
|
200
200
|
"B3o7kgh": "f13ta7ih"
|
|
201
201
|
},
|
|
202
202
|
"small": {
|
|
203
|
-
"Be2twd7": "fy9rknc",
|
|
204
203
|
"Bqenvij": "f50nw0v",
|
|
204
|
+
"Bahqtrf": "fk6fouc",
|
|
205
|
+
"Be2twd7": "fy9rknc",
|
|
206
|
+
"Bhrd7zp": "figsok6",
|
|
205
207
|
"Bg96gwp": "fwrc4pm",
|
|
206
208
|
"z8tnut": "f1g0x7ka",
|
|
207
209
|
"z189sj": ["fhxju0i", "f1cnd47f"],
|
|
@@ -209,8 +211,10 @@ const useInputStyles = /*#__PURE__*/__styles({
|
|
|
209
211
|
"uwmqm3": ["f1xile11", "fqznh8f"]
|
|
210
212
|
},
|
|
211
213
|
"medium": {
|
|
212
|
-
"Be2twd7": "fkhj508",
|
|
213
214
|
"Bqenvij": "f1tvdnth",
|
|
215
|
+
"Bahqtrf": "fk6fouc",
|
|
216
|
+
"Be2twd7": "fkhj508",
|
|
217
|
+
"Bhrd7zp": "figsok6",
|
|
214
218
|
"Bg96gwp": "f1i3iumi",
|
|
215
219
|
"z8tnut": "f1g0x7ka",
|
|
216
220
|
"z189sj": ["fhxju0i", "f1cnd47f"],
|
|
@@ -218,8 +222,10 @@ const useInputStyles = /*#__PURE__*/__styles({
|
|
|
218
222
|
"uwmqm3": ["f1e60jzv", "f135dnwl"]
|
|
219
223
|
},
|
|
220
224
|
"large": {
|
|
221
|
-
"Be2twd7": "fod5ikn",
|
|
222
225
|
"Bqenvij": "f1ihhdec",
|
|
226
|
+
"Bahqtrf": "fk6fouc",
|
|
227
|
+
"Be2twd7": "fod5ikn",
|
|
228
|
+
"Bhrd7zp": "figsok6",
|
|
223
229
|
"Bg96gwp": "faaz57k",
|
|
224
230
|
"z8tnut": "f1g0x7ka",
|
|
225
231
|
"z189sj": ["fhxju0i", "f1cnd47f"],
|
|
@@ -233,7 +239,7 @@ const useInputStyles = /*#__PURE__*/__styles({
|
|
|
233
239
|
"yvdlaj": "fahhnxm"
|
|
234
240
|
}
|
|
235
241
|
}, {
|
|
236
|
-
"d": [".f1c21dwh{background-color:var(--colorTransparentBackground);}", ".fre7gi1{border-top-width:0;}", ".f1358rze{border-right-width:0;}", ".f1rvrf73{border-left-width:0;}", ".fqdk4by{border-bottom-width:0;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fwyc1cq::-webkit-input-placeholder{color:var(--colorNeutralForeground4);}", ".fwyc1cq::-moz-placeholder{color:var(--colorNeutralForeground4);}", ".f13ta7ih::-webkit-input-placeholder{opacity:1;}", ".f13ta7ih::-moz-placeholder{opacity:1;}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".
|
|
242
|
+
"d": [".f1c21dwh{background-color:var(--colorTransparentBackground);}", ".fre7gi1{border-top-width:0;}", ".f1358rze{border-right-width:0;}", ".f1rvrf73{border-left-width:0;}", ".fqdk4by{border-bottom-width:0;}", ".f19n0e5{color:var(--colorNeutralForeground1);}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fwyc1cq::-webkit-input-placeholder{color:var(--colorNeutralForeground4);}", ".fwyc1cq::-moz-placeholder{color:var(--colorNeutralForeground4);}", ".f13ta7ih::-webkit-input-placeholder{opacity:1;}", ".f13ta7ih::-moz-placeholder{opacity:1;}", ".f50nw0v{height:22px;}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".fwrc4pm{line-height:var(--lineHeightBase200);}", ".f1g0x7ka{padding-top:0;}", ".fhxju0i{padding-right:0;}", ".f1cnd47f{padding-left:0;}", ".f1qch9an{padding-bottom:0;}", ".f1xile11{padding-left:calc(var(--spacingHorizontalSNudge) + var(--spacingHorizontalXXS));}", ".fqznh8f{padding-right:calc(var(--spacingHorizontalSNudge) + var(--spacingHorizontalXXS));}", ".f1tvdnth{height:30px;}", ".fkhj508{font-size:var(--fontSizeBase300);}", ".f1i3iumi{line-height:var(--lineHeightBase300);}", ".f1e60jzv{padding-left:calc(var(--spacingHorizontalMNudge) + var(--spacingHorizontalXXS));}", ".f135dnwl{padding-right:calc(var(--spacingHorizontalMNudge) + var(--spacingHorizontalXXS));}", ".f1ihhdec{height:38px;}", ".fod5ikn{font-size:var(--fontSizeBase400);}", ".faaz57k{line-height:var(--lineHeightBase400);}", ".fnphzt9{padding-left:calc(var(--spacingHorizontalM) + var(--spacingHorizontalSNudge));}", ".flt1dlf{padding-right:calc(var(--spacingHorizontalM) + var(--spacingHorizontalSNudge));}", ".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}", ".fdrzuqr{cursor:not-allowed;}", ".fahhnxm::-webkit-input-placeholder{color:var(--colorNeutralForegroundDisabled);}", ".fahhnxm::-moz-placeholder{color:var(--colorNeutralForegroundDisabled);}"],
|
|
237
243
|
"f": [".ftqa4ok:focus{outline-style:none;}"]
|
|
238
244
|
});
|
|
239
245
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["packages/react-components/react-combobox/src/components/Combobox/useComboboxStyles.ts"],"names":[],"mappings":"AAAA,SAAS,MAAT,QAAuB,uBAAvB;AAEA,mBAAqB,YAArB,EAAmC,UAAnC,QAAqD,gBAArD;AACA,SAAS,SAAT,QAA0B,4BAA1B;AAGA,OAAO,MAAM,kBAAkB,GAAkC;EAC/D,IAAI,EAAE,cADyD;EAE/D,KAAK,EAAE,qBAFwD;EAG/D,UAAU,EAAE,0BAHmD;EAI/D,OAAO,EAAE;AAJsD,CAA1D,C,CAOP;AACA;;AACA,MAAM,YAAY,GAAG;EACnB,KAAK,EAAE,MADY;EAEnB,MAAM,EAAE,MAFW;EAGnB,KAAK,EAAE;AAHY,CAArB;AAMA;;AAEG;;AACH,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;I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CAAC,IAAD,IAAS,MAAM,CAAC,gBAHoB,EAIpC,KAAK,CAAC,OAAN,CAAc,SAJsB,CAAtC;EAMD;;EAED,IAAI,KAAK,CAAC,UAAV,EAAsB;IACpB,KAAK,CAAC,UAAN,CAAiB,SAAjB,GAA6B,YAAY,CACvC,kBAAkB,CAAC,UADoB,EAEvC,UAAU,CAAC,IAF4B,EAGvC,UAAU,CAAC,IAAD,CAH6B,EAIvC,QAAQ,IAAI,UAAU,CAAC,QAJgB,EAKvC,KAAK,CAAC,UAAN,CAAiB,SALsB,CAAzC;EAOD;;EAED,OAAO,KAAP;AACD,CAhDM","sourcesContent":["import { tokens } from '@fluentui/react-theme';\nimport { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { iconSizes } from '../../utils/internalTokens';\nimport type { ComboboxSlots, ComboboxState } from './Combobox.types';\n\nexport const comboboxClassNames: SlotClassNames<ComboboxSlots> = {\n root: 'fui-Combobox',\n input: 'fui-Combobox__input',\n expandIcon: 'fui-Combobox__expandIcon',\n listbox: 'fui-Combobox__listbox',\n};\n\n// Matches internal heights for Select and Input, but there are no theme variables for these\n// field heights are 2px less than other controls, since the border is on the parent element.\nconst fieldHeights = {\n small: '22px',\n medium: '30px',\n large: '38px',\n};\n\n/**\n * Styles for Combobox\n */\nconst useStyles = makeStyles({\n root: {\n alignItems: 'center',\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n boxSizing: 'border-box',\n columnGap: tokens.spacingHorizontalXXS,\n display: 'inline-grid',\n gridTemplateColumns: '1fr auto',\n justifyContent: 'space-between',\n minWidth: '250px',\n position: 'relative',\n\n // windows high contrast mode focus indicator\n ':focus-within': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: 'transparent',\n },\n\n // bottom focus border, shared with Input, Select, and SpinButton\n '::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n left: '-1px',\n bottom: '-1px',\n right: '-1px',\n height: `max(2px, ${tokens.borderRadiusMedium})`,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderBottomRightRadius: tokens.borderRadiusMedium,\n ...shorthands.borderBottom(tokens.strokeWidthThick, 'solid', tokens.colorCompoundBrandStroke),\n clipPath: 'inset(calc(100% - 2px) 0 0 0)',\n transform: 'scaleX(0)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationUltraFast,\n transitionDelay: tokens.curveAccelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within::after': {\n transform: 'scaleX(1)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationNormal,\n transitionDelay: tokens.curveDecelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within:active::after': {\n borderBottomColor: tokens.colorCompoundBrandStrokePressed,\n },\n },\n\n listbox: {},\n\n listboxCollapsed: {\n display: 'none',\n },\n\n // size variants\n small: {\n paddingRight: tokens.spacingHorizontalSNudge,\n },\n medium: {\n paddingRight: tokens.spacingHorizontalMNudge,\n },\n large: {\n columnGap: tokens.spacingHorizontalSNudge,\n paddingRight: tokens.spacingHorizontalM,\n },\n\n // appearance variants\n outline: {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke1),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n outlineInteractive: {\n '&:hover': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Hover),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n '&:active': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n },\n underline: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStrokeAccessible),\n ...shorthands.borderRadius(0),\n },\n 'filled-lighter': {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n 'filled-darker': {\n backgroundColor: tokens.colorNeutralBackground3,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n invalid: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n ...shorthands.borderColor(tokens.colorPaletteRedBorder2),\n },\n },\n invalidUnderline: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n borderBottomColor: tokens.colorPaletteRedBorder2,\n },\n },\n\n disabled: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n '@media (forced-colors: active)': {\n ...shorthands.borderColor('GrayText'),\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n input: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.border('0'),\n color: tokens.colorNeutralForeground1,\n fontFamily: tokens.fontFamilyBase,\n\n '&:focus': {\n outlineStyle: 'none',\n },\n\n '&::placeholder': {\n color: tokens.colorNeutralForeground4,\n opacity: 1,\n },\n },\n\n // size variants\n small: {\n fontSize: tokens.fontSizeBase200,\n height: fieldHeights.small,\n lineHeight: tokens.lineHeightBase200,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalSNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n medium: {\n fontSize: tokens.fontSizeBase300,\n height: fieldHeights.medium,\n lineHeight: tokens.lineHeightBase300,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalMNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n large: {\n fontSize: tokens.fontSizeBase400,\n height: fieldHeights.large,\n lineHeight: tokens.lineHeightBase400,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalM} + ${tokens.spacingHorizontalSNudge})`),\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n backgroundColor: tokens.colorTransparentBackground,\n cursor: 'not-allowed',\n '::placeholder': {\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n});\n\nconst useIconStyles = makeStyles({\n icon: {\n boxSizing: 'border-box',\n color: tokens.colorNeutralStrokeAccessible,\n display: 'block',\n fontSize: tokens.fontSizeBase500,\n\n // the SVG must have display: block for accurate positioning\n // otherwise an extra inline space is inserted after the svg element\n '& svg': {\n display: 'block',\n },\n },\n\n // icon size variants\n small: {\n fontSize: iconSizes.small,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n medium: {\n fontSize: iconSizes.medium,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n large: {\n fontSize: iconSizes.large,\n marginLeft: tokens.spacingHorizontalSNudge,\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n\n/**\n * Apply styling to the Combobox slots based on the state\n */\nexport const useComboboxStyles_unstable = (state: ComboboxState): ComboboxState => {\n const { appearance, open, size } = state;\n const invalid = `${state.input['aria-invalid']}` === 'true';\n const disabled = state.input.disabled;\n const styles = useStyles();\n const iconStyles = useIconStyles();\n const inputStyles = useInputStyles();\n\n state.root.className = mergeClasses(\n comboboxClassNames.root,\n styles.root,\n styles[appearance],\n styles[size],\n !disabled && appearance === 'outline' && styles.outlineInteractive,\n invalid && appearance !== 'underline' && styles.invalid,\n invalid && appearance === 'underline' && styles.invalidUnderline,\n disabled && styles.disabled,\n state.root.className,\n );\n\n state.input.className = mergeClasses(\n comboboxClassNames.input,\n inputStyles.input,\n inputStyles[size],\n disabled && inputStyles.disabled,\n state.input.className,\n );\n\n if (state.listbox) {\n state.listbox.className = mergeClasses(\n comboboxClassNames.listbox,\n styles.listbox,\n !open && styles.listboxCollapsed,\n state.listbox.className,\n );\n }\n\n if (state.expandIcon) {\n state.expandIcon.className = mergeClasses(\n comboboxClassNames.expandIcon,\n iconStyles.icon,\n iconStyles[size],\n disabled && iconStyles.disabled,\n state.expandIcon.className,\n );\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
1
|
+
{"version":3,"sources":["packages/react-components/react-combobox/src/components/Combobox/useComboboxStyles.ts"],"names":[],"mappings":"AAAA,SAAS,MAAT,EAAiB,gBAAjB,QAAyC,uBAAzC;AAEA,mBAAqB,YAArB,EAAmC,UAAnC,QAAqD,gBAArD;AACA,SAAS,SAAT,QAA0B,4BAA1B;AAGA,OAAO,MAAM,kBAAkB,GAAkC;EAC/D,IAAI,EAAE,cADyD;EAE/D,KAAK,EAAE,qBAFwD;EAG/D,UAAU,EAAE,0BAHmD;EAI/D,OAAO,EAAE;AAJsD,CAA1D,C,CAOP;AACA;;AACA,MAAM,YAAY,GAAG;EACnB,KAAK,EAAE,MADY;EAEnB,MAAM,EAAE,MAFW;EAGnB,KAAK,EAAE;AAHY,CAArB;AAMA;;AAEG;;AACH,MAAM,SAAS,gBAAG;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IA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ographyStyles } from '@fluentui/react-theme';\nimport { SlotClassNames } from '@fluentui/react-utilities';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { iconSizes } from '../../utils/internalTokens';\nimport type { ComboboxSlots, ComboboxState } from './Combobox.types';\n\nexport const comboboxClassNames: SlotClassNames<ComboboxSlots> = {\n root: 'fui-Combobox',\n input: 'fui-Combobox__input',\n expandIcon: 'fui-Combobox__expandIcon',\n listbox: 'fui-Combobox__listbox',\n};\n\n// Matches internal heights for Select and Input, but there are no theme variables for these\n// field heights are 2px less than other controls, since the border is on the parent element.\nconst fieldHeights = {\n small: '22px',\n medium: '30px',\n large: '38px',\n};\n\n/**\n * Styles for Combobox\n */\nconst useStyles = makeStyles({\n root: {\n alignItems: 'center',\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n boxSizing: 'border-box',\n columnGap: tokens.spacingHorizontalXXS,\n display: 'inline-grid',\n gridTemplateColumns: '1fr auto',\n justifyContent: 'space-between',\n minWidth: '250px',\n position: 'relative',\n\n // windows high contrast mode focus indicator\n ':focus-within': {\n outlineWidth: '2px',\n outlineStyle: 'solid',\n outlineColor: 'transparent',\n },\n\n // bottom focus border, shared with Input, Select, and SpinButton\n '::after': {\n boxSizing: 'border-box',\n content: '\"\"',\n position: 'absolute',\n left: '-1px',\n bottom: '-1px',\n right: '-1px',\n height: `max(2px, ${tokens.borderRadiusMedium})`,\n borderBottomLeftRadius: tokens.borderRadiusMedium,\n borderBottomRightRadius: tokens.borderRadiusMedium,\n ...shorthands.borderBottom(tokens.strokeWidthThick, 'solid', tokens.colorCompoundBrandStroke),\n clipPath: 'inset(calc(100% - 2px) 0 0 0)',\n transform: 'scaleX(0)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationUltraFast,\n transitionDelay: tokens.curveAccelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within::after': {\n transform: 'scaleX(1)',\n transitionProperty: 'transform',\n transitionDuration: tokens.durationNormal,\n transitionDelay: tokens.curveDecelerateMid,\n\n '@media screen and (prefers-reduced-motion: reduce)': {\n transitionDuration: '0.01ms',\n transitionDelay: '0.01ms',\n },\n },\n ':focus-within:active::after': {\n borderBottomColor: tokens.colorCompoundBrandStrokePressed,\n },\n },\n\n listbox: {},\n\n listboxCollapsed: {\n display: 'none',\n },\n\n // size variants\n small: {\n paddingRight: tokens.spacingHorizontalSNudge,\n },\n medium: {\n paddingRight: tokens.spacingHorizontalMNudge,\n },\n large: {\n columnGap: tokens.spacingHorizontalSNudge,\n paddingRight: tokens.spacingHorizontalM,\n },\n\n // appearance variants\n outline: {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStroke1),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n outlineInteractive: {\n '&:hover': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Hover),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n\n '&:active': {\n ...shorthands.borderColor(tokens.colorNeutralStroke1Pressed),\n borderBottomColor: tokens.colorNeutralStrokeAccessible,\n },\n },\n underline: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderBottom(tokens.strokeWidthThin, 'solid', tokens.colorNeutralStrokeAccessible),\n ...shorthands.borderRadius(0),\n },\n 'filled-lighter': {\n backgroundColor: tokens.colorNeutralBackground1,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n 'filled-darker': {\n backgroundColor: tokens.colorNeutralBackground3,\n ...shorthands.border(tokens.strokeWidthThin, 'solid', tokens.colorTransparentStroke),\n },\n invalid: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n ...shorthands.borderColor(tokens.colorPaletteRedBorder2),\n },\n },\n invalidUnderline: {\n ':not(:focus-within),:hover:not(:focus-within)': {\n borderBottomColor: tokens.colorPaletteRedBorder2,\n },\n },\n\n disabled: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled),\n '@media (forced-colors: active)': {\n ...shorthands.borderColor('GrayText'),\n },\n },\n});\n\nconst useInputStyles = makeStyles({\n input: {\n backgroundColor: tokens.colorTransparentBackground,\n ...shorthands.border('0'),\n color: tokens.colorNeutralForeground1,\n fontFamily: tokens.fontFamilyBase,\n\n '&:focus': {\n outlineStyle: 'none',\n },\n\n '&::placeholder': {\n color: tokens.colorNeutralForeground4,\n opacity: 1,\n },\n },\n\n // size variants\n small: {\n height: fieldHeights.small,\n ...typographyStyles.caption1,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalSNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n medium: {\n height: fieldHeights.medium,\n ...typographyStyles.body1,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalMNudge} + ${tokens.spacingHorizontalXXS})`),\n },\n large: {\n height: fieldHeights.large,\n ...typographyStyles.body2,\n ...shorthands.padding(0, 0, 0, `calc(${tokens.spacingHorizontalM} + ${tokens.spacingHorizontalSNudge})`),\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n backgroundColor: tokens.colorTransparentBackground,\n cursor: 'not-allowed',\n '::placeholder': {\n color: tokens.colorNeutralForegroundDisabled,\n },\n },\n});\n\nconst useIconStyles = makeStyles({\n icon: {\n boxSizing: 'border-box',\n color: tokens.colorNeutralStrokeAccessible,\n display: 'block',\n fontSize: tokens.fontSizeBase500,\n\n // the SVG must have display: block for accurate positioning\n // otherwise an extra inline space is inserted after the svg element\n '& svg': {\n display: 'block',\n },\n },\n\n // icon size variants\n small: {\n fontSize: iconSizes.small,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n medium: {\n fontSize: iconSizes.medium,\n marginLeft: tokens.spacingHorizontalXXS,\n },\n large: {\n fontSize: iconSizes.large,\n marginLeft: tokens.spacingHorizontalSNudge,\n },\n disabled: {\n color: tokens.colorNeutralForegroundDisabled,\n },\n});\n\n/**\n * Apply styling to the Combobox slots based on the state\n */\nexport const useComboboxStyles_unstable = (state: ComboboxState): ComboboxState => {\n const { appearance, open, size } = state;\n const invalid = `${state.input['aria-invalid']}` === 'true';\n const disabled = state.input.disabled;\n const styles = useStyles();\n const iconStyles = useIconStyles();\n const inputStyles = useInputStyles();\n\n state.root.className = mergeClasses(\n comboboxClassNames.root,\n styles.root,\n styles[appearance],\n styles[size],\n !disabled && appearance === 'outline' && styles.outlineInteractive,\n invalid && appearance !== 'underline' && styles.invalid,\n invalid && appearance === 'underline' && styles.invalidUnderline,\n disabled && styles.disabled,\n state.root.className,\n );\n\n state.input.className = mergeClasses(\n comboboxClassNames.input,\n inputStyles.input,\n inputStyles[size],\n disabled && inputStyles.disabled,\n state.input.className,\n );\n\n if (state.listbox) {\n state.listbox.className = mergeClasses(\n comboboxClassNames.listbox,\n styles.listbox,\n !open && styles.listboxCollapsed,\n state.listbox.className,\n );\n }\n\n if (state.expandIcon) {\n state.expandIcon.className = mergeClasses(\n comboboxClassNames.expandIcon,\n iconStyles.icon,\n iconStyles[size],\n disabled && iconStyles.disabled,\n state.expandIcon.className,\n );\n }\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -22,7 +22,7 @@ export const useDropdown_unstable = (props, ref) => {
|
|
|
22
22
|
const {
|
|
23
23
|
activeOption,
|
|
24
24
|
getIndexOfId,
|
|
25
|
-
|
|
25
|
+
getOptionsMatchingText,
|
|
26
26
|
open,
|
|
27
27
|
setActiveOption,
|
|
28
28
|
setFocusVisible,
|
|
@@ -55,7 +55,7 @@ export const useDropdown_unstable = (props, ref) => {
|
|
|
55
55
|
|
|
56
56
|
let matcher = optionValue => optionValue.toLowerCase().indexOf(searchString.current) === 0;
|
|
57
57
|
|
|
58
|
-
let matches =
|
|
58
|
+
let matches = getOptionsMatchingText(matcher);
|
|
59
59
|
let startIndex = activeOption ? getIndexOfId(activeOption.id) : 0; // if the dropdown is already open and the searchstring is a single character,
|
|
60
60
|
// then look after the current activeOption for letters
|
|
61
61
|
// this is so slowly typing the same letter will cycle through matches
|
|
@@ -74,7 +74,7 @@ export const useDropdown_unstable = (props, ref) => {
|
|
|
74
74
|
|
|
75
75
|
matcher = optionValue => optionValue.toLowerCase().indexOf(letters[0]) === 0;
|
|
76
76
|
|
|
77
|
-
matches =
|
|
77
|
+
matches = getOptionsMatchingText(matcher);
|
|
78
78
|
}
|
|
79
79
|
} // if there is an active option and multiple matches,
|
|
80
80
|
// return first matching option after the current active option, looping back to the top
|