@fluentui/react-tag-picker 9.8.8 → 9.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -2
- package/dist/index.d.ts +85 -8
- package/lib/TagPicker.js +1 -1
- package/lib/TagPicker.js.map +1 -1
- package/lib/TagPickerButton.js +1 -1
- package/lib/TagPickerButton.js.map +1 -1
- package/lib/TagPickerControl.js +1 -1
- package/lib/TagPickerControl.js.map +1 -1
- package/lib/TagPickerInput.js +1 -1
- package/lib/TagPickerInput.js.map +1 -1
- package/lib/components/TagPicker/TagPicker.types.js +5 -1
- package/lib/components/TagPicker/TagPicker.types.js.map +1 -1
- package/lib/components/TagPicker/index.js +2 -1
- package/lib/components/TagPicker/index.js.map +1 -1
- package/lib/components/TagPicker/useTagPicker.js +38 -26
- package/lib/components/TagPicker/useTagPicker.js.map +1 -1
- package/lib/components/TagPickerButton/TagPickerButton.types.js +1 -1
- package/lib/components/TagPickerButton/TagPickerButton.types.js.map +1 -1
- package/lib/components/TagPickerButton/index.js +1 -1
- package/lib/components/TagPickerButton/index.js.map +1 -1
- package/lib/components/TagPickerButton/useTagPickerButton.js +22 -12
- package/lib/components/TagPickerButton/useTagPickerButton.js.map +1 -1
- package/lib/components/TagPickerButton/useTagPickerButtonStyles.styles.js +0 -2
- package/lib/components/TagPickerButton/useTagPickerButtonStyles.styles.js.map +1 -1
- package/lib/components/TagPickerButton/useTagPickerButtonStyles.styles.raw.js +0 -1
- package/lib/components/TagPickerButton/useTagPickerButtonStyles.styles.raw.js.map +1 -1
- package/lib/components/TagPickerControl/TagPickerControl.types.js +1 -1
- package/lib/components/TagPickerControl/TagPickerControl.types.js.map +1 -1
- package/lib/components/TagPickerControl/index.js +1 -1
- package/lib/components/TagPickerControl/index.js.map +1 -1
- package/lib/components/TagPickerControl/useTagPickerControl.js +22 -11
- package/lib/components/TagPickerControl/useTagPickerControl.js.map +1 -1
- package/lib/components/TagPickerControl/useTagPickerControlStyles.styles.js +0 -2
- package/lib/components/TagPickerControl/useTagPickerControlStyles.styles.js.map +1 -1
- package/lib/components/TagPickerControl/useTagPickerControlStyles.styles.raw.js +0 -1
- package/lib/components/TagPickerControl/useTagPickerControlStyles.styles.raw.js.map +1 -1
- package/lib/components/TagPickerGroup/useTagPickerGroupStyles.styles.js +0 -2
- package/lib/components/TagPickerGroup/useTagPickerGroupStyles.styles.js.map +1 -1
- package/lib/components/TagPickerGroup/useTagPickerGroupStyles.styles.raw.js +0 -1
- package/lib/components/TagPickerGroup/useTagPickerGroupStyles.styles.raw.js.map +1 -1
- package/lib/components/TagPickerInput/TagPickerInput.types.js +1 -1
- package/lib/components/TagPickerInput/TagPickerInput.types.js.map +1 -1
- package/lib/components/TagPickerInput/index.js +1 -1
- package/lib/components/TagPickerInput/index.js.map +1 -1
- package/lib/components/TagPickerInput/useTagPickerInput.js +43 -23
- package/lib/components/TagPickerInput/useTagPickerInput.js.map +1 -1
- package/lib/components/TagPickerInput/useTagPickerInputStyles.styles.js +0 -2
- package/lib/components/TagPickerInput/useTagPickerInputStyles.styles.js.map +1 -1
- package/lib/components/TagPickerInput/useTagPickerInputStyles.styles.raw.js +0 -1
- package/lib/components/TagPickerInput/useTagPickerInputStyles.styles.raw.js.map +1 -1
- package/lib/components/TagPickerList/useTagPickerListStyles.styles.js +0 -2
- package/lib/components/TagPickerList/useTagPickerListStyles.styles.js.map +1 -1
- package/lib/components/TagPickerList/useTagPickerListStyles.styles.raw.js +0 -1
- package/lib/components/TagPickerList/useTagPickerListStyles.styles.raw.js.map +1 -1
- package/lib/components/TagPickerOption/useTagPickerOptionStyles.styles.js +0 -2
- package/lib/components/TagPickerOption/useTagPickerOptionStyles.styles.js.map +1 -1
- package/lib/components/TagPickerOption/useTagPickerOptionStyles.styles.raw.js +0 -1
- package/lib/components/TagPickerOption/useTagPickerOptionStyles.styles.raw.js.map +1 -1
- package/lib/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.js +0 -2
- package/lib/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.js.map +1 -1
- package/lib/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.raw.js +0 -1
- package/lib/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.raw.js.map +1 -1
- package/lib/index.js +5 -5
- package/lib/index.js.map +1 -1
- package/lib-commonjs/TagPicker.js +6 -0
- package/lib-commonjs/TagPicker.js.map +1 -1
- package/lib-commonjs/TagPickerButton.js +3 -0
- package/lib-commonjs/TagPickerButton.js.map +1 -1
- package/lib-commonjs/TagPickerControl.js +3 -0
- package/lib-commonjs/TagPickerControl.js.map +1 -1
- package/lib-commonjs/TagPickerInput.js +3 -0
- package/lib-commonjs/TagPickerInput.js.map +1 -1
- package/lib-commonjs/components/TagPicker/TagPicker.types.js +5 -1
- package/lib-commonjs/components/TagPicker/TagPicker.types.js.map +1 -1
- package/lib-commonjs/components/TagPicker/index.js +7 -0
- package/lib-commonjs/components/TagPicker/index.js.map +1 -1
- package/lib-commonjs/components/TagPicker/useTagPicker.js +40 -23
- package/lib-commonjs/components/TagPicker/useTagPicker.js.map +1 -1
- package/lib-commonjs/components/TagPickerButton/TagPickerButton.types.js +1 -1
- package/lib-commonjs/components/TagPickerButton/TagPickerButton.types.js.map +1 -1
- package/lib-commonjs/components/TagPickerButton/index.js +3 -0
- package/lib-commonjs/components/TagPickerButton/index.js.map +1 -1
- package/lib-commonjs/components/TagPickerButton/useTagPickerButton.js +22 -9
- package/lib-commonjs/components/TagPickerButton/useTagPickerButton.js.map +1 -1
- package/lib-commonjs/components/TagPickerButton/useTagPickerButtonStyles.styles.js +0 -1
- package/lib-commonjs/components/TagPickerButton/useTagPickerButtonStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TagPickerButton/useTagPickerButtonStyles.styles.raw.js +0 -1
- package/lib-commonjs/components/TagPickerButton/useTagPickerButtonStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/TagPickerControl/TagPickerControl.types.js +1 -1
- package/lib-commonjs/components/TagPickerControl/TagPickerControl.types.js.map +1 -1
- package/lib-commonjs/components/TagPickerControl/index.js +3 -0
- package/lib-commonjs/components/TagPickerControl/index.js.map +1 -1
- package/lib-commonjs/components/TagPickerControl/useTagPickerControl.js +22 -8
- package/lib-commonjs/components/TagPickerControl/useTagPickerControl.js.map +1 -1
- package/lib-commonjs/components/TagPickerControl/useTagPickerControlStyles.styles.js +0 -1
- package/lib-commonjs/components/TagPickerControl/useTagPickerControlStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TagPickerControl/useTagPickerControlStyles.styles.raw.js +0 -1
- package/lib-commonjs/components/TagPickerControl/useTagPickerControlStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/TagPickerGroup/useTagPickerGroupStyles.styles.js +0 -1
- package/lib-commonjs/components/TagPickerGroup/useTagPickerGroupStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TagPickerGroup/useTagPickerGroupStyles.styles.raw.js +0 -1
- package/lib-commonjs/components/TagPickerGroup/useTagPickerGroupStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/TagPickerInput/TagPickerInput.types.js +1 -1
- package/lib-commonjs/components/TagPickerInput/TagPickerInput.types.js.map +1 -1
- package/lib-commonjs/components/TagPickerInput/index.js +3 -0
- package/lib-commonjs/components/TagPickerInput/index.js.map +1 -1
- package/lib-commonjs/components/TagPickerInput/useTagPickerInput.js +41 -20
- package/lib-commonjs/components/TagPickerInput/useTagPickerInput.js.map +1 -1
- package/lib-commonjs/components/TagPickerInput/useTagPickerInputStyles.styles.js +0 -1
- package/lib-commonjs/components/TagPickerInput/useTagPickerInputStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TagPickerInput/useTagPickerInputStyles.styles.raw.js +0 -1
- package/lib-commonjs/components/TagPickerInput/useTagPickerInputStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/TagPickerList/useTagPickerListStyles.styles.js +0 -1
- package/lib-commonjs/components/TagPickerList/useTagPickerListStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TagPickerList/useTagPickerListStyles.styles.raw.js +0 -1
- package/lib-commonjs/components/TagPickerList/useTagPickerListStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/TagPickerOption/useTagPickerOptionStyles.styles.js +0 -1
- package/lib-commonjs/components/TagPickerOption/useTagPickerOptionStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TagPickerOption/useTagPickerOptionStyles.styles.raw.js +0 -1
- package/lib-commonjs/components/TagPickerOption/useTagPickerOptionStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.js +0 -1
- package/lib-commonjs/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.js.map +1 -1
- package/lib-commonjs/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.raw.js +0 -1
- package/lib-commonjs/components/TagPickerOptionGroup/useTagPickerOptionGroupStyles.styles.raw.js.map +1 -1
- package/lib-commonjs/index.js +18 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-tag-picker
|
|
2
2
|
|
|
3
|
-
This log was last generated on Wed,
|
|
3
|
+
This log was last generated on Wed, 15 Jul 2026 14:10:09 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.10.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tag-picker_v9.10.0)
|
|
8
|
+
|
|
9
|
+
Wed, 15 Jul 2026 14:10:09 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tag-picker_v9.9.0..@fluentui/react-tag-picker_v9.10.0)
|
|
11
|
+
|
|
12
|
+
### Minor changes
|
|
13
|
+
|
|
14
|
+
- feat: export useTagPickerContextValues and TagPickerControlInternalSlots for headless composition ([PR #36353](https://github.com/microsoft/fluentui/pull/36353) by vgenaev@gmail.com)
|
|
15
|
+
|
|
16
|
+
## [9.9.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tag-picker_v9.9.0)
|
|
17
|
+
|
|
18
|
+
Wed, 24 Jun 2026 11:10:00 GMT
|
|
19
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tag-picker_v9.8.8..@fluentui/react-tag-picker_v9.9.0)
|
|
20
|
+
|
|
21
|
+
### Minor changes
|
|
22
|
+
|
|
23
|
+
- feat: add base hooks/types for headless composition ([PR #36260](https://github.com/microsoft/fluentui/pull/36260) by viktorgenaev@microsoft.com)
|
|
24
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.4 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
25
|
+
- Bump @fluentui/react-utilities to v9.26.5 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
26
|
+
- Bump @fluentui/react-portal to v9.8.14 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
27
|
+
- Bump @fluentui/react-tabster to v9.26.16 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
28
|
+
- Bump @fluentui/react-aria to v9.17.13 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
29
|
+
- Bump @fluentui/react-combobox to v9.17.3 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
30
|
+
- Bump @fluentui/react-tags to v9.9.2 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
31
|
+
- Bump @fluentui/react-context-selector to v9.2.18 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
32
|
+
- Bump @fluentui/react-positioning to v9.22.3 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
33
|
+
- Bump @fluentui/react-field to v9.5.3 ([commit](https://github.com/microsoft/fluentui/commit/a4b871ca80c1f16f35ab4229def4fe02be7f30ea) by beachball)
|
|
34
|
+
|
|
35
|
+
### Patches
|
|
36
|
+
|
|
37
|
+
- fix: remove redundant use no memo directives, and add justification to valid ones ([PR #36224](https://github.com/microsoft/fluentui/pull/36224) by martinhochel@microsoft.com)
|
|
38
|
+
|
|
7
39
|
## [9.8.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-tag-picker_v9.8.8)
|
|
8
40
|
|
|
9
|
-
Wed, 27 May 2026 11:18:
|
|
41
|
+
Wed, 27 May 2026 11:18:57 GMT
|
|
10
42
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tag-picker_v9.8.7..@fluentui/react-tag-picker_v9.8.8)
|
|
11
43
|
|
|
12
44
|
### Patches
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { ComboboxState } from '@fluentui/react-combobox';
|
|
|
6
6
|
import type { ComponentProps } from '@fluentui/react-utilities';
|
|
7
7
|
import type { ComponentState } from '@fluentui/react-utilities';
|
|
8
8
|
import type { ContextSelector } from '@fluentui/react-context-selector';
|
|
9
|
+
import type { DistributiveOmit } from '@fluentui/react-utilities';
|
|
9
10
|
import type { DropdownProps } from '@fluentui/react-combobox';
|
|
10
11
|
import type { EventData } from '@fluentui/react-utilities';
|
|
11
12
|
import type { EventHandler } from '@fluentui/react-utilities';
|
|
@@ -69,12 +70,37 @@ export declare const renderTagPickerOptionGroup: (state: TagPickerOptionGroupSta
|
|
|
69
70
|
*/
|
|
70
71
|
export declare const TagPicker: React_2.FC<TagPickerProps>;
|
|
71
72
|
|
|
73
|
+
/**
|
|
74
|
+
* TagPicker Base Props - omits the presentation-related props that the base hook does not handle:
|
|
75
|
+
* the floating-ui `positioning` prop (the styled {@link TagPickerProps} re-introduces it via
|
|
76
|
+
* `usePositioning`) as well as `size`, `appearance` and `inline` (layered on by the styled
|
|
77
|
+
* {@link useTagPicker_unstable} hook).
|
|
78
|
+
*/
|
|
79
|
+
export declare type TagPickerBaseProps = DistributiveOmit<TagPickerProps, 'positioning' | 'size' | 'appearance' | 'inline'>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* TagPicker Base State - the state produced by the base hook, which does not interact with the
|
|
83
|
+
* `size`, `appearance` and `inline` props. These are layered on by the styled
|
|
84
|
+
* {@link useTagPicker_unstable} hook.
|
|
85
|
+
*/
|
|
86
|
+
export declare type TagPickerBaseState = Omit<TagPickerState, 'size' | 'appearance' | 'inline'>;
|
|
87
|
+
|
|
72
88
|
/**
|
|
73
89
|
* TagPickerButton component -
|
|
74
90
|
* A TagPickerButton is an alternative to TagPickerInput that does not include an input field.
|
|
75
91
|
*/
|
|
76
92
|
export declare const TagPickerButton: ForwardRefComponent<TagPickerButtonProps>;
|
|
77
93
|
|
|
94
|
+
/**
|
|
95
|
+
* TagPickerButton Base Props - omits design-only props
|
|
96
|
+
*/
|
|
97
|
+
export declare type TagPickerButtonBaseProps = DistributiveOmit<TagPickerButtonProps, 'size' | 'appearance'>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* TagPickerButton Base State - omits design-only state
|
|
101
|
+
*/
|
|
102
|
+
export declare type TagPickerButtonBaseState = DistributiveOmit<TagPickerButtonState, 'size'>;
|
|
103
|
+
|
|
78
104
|
export declare const tagPickerButtonClassNames: SlotClassNames<TagPickerButtonSlots>;
|
|
79
105
|
|
|
80
106
|
/**
|
|
@@ -95,6 +121,8 @@ export declare type TagPickerButtonState = ComponentState<TagPickerButtonSlots>
|
|
|
95
121
|
hasSelectedOption: boolean;
|
|
96
122
|
};
|
|
97
123
|
|
|
124
|
+
export declare const TagPickerContextProvider: React_2.Provider<TagPickerContextValue | undefined> & React_2.FC<React_2.ProviderProps<TagPickerContextValue | undefined>>;
|
|
125
|
+
|
|
98
126
|
export declare interface TagPickerContextValue extends Pick<ComboboxBaseState, 'open' | 'clearSelection' | 'getOptionById' | 'selectedOptions' | 'selectOption' | 'setHasFocus' | 'setOpen' | 'setValue' | 'value' | 'appearance' | 'disabled'> {
|
|
99
127
|
triggerRef: React_2.RefObject<HTMLInputElement | HTMLButtonElement | null>;
|
|
100
128
|
popoverRef: React_2.RefObject<HTMLDivElement | null>;
|
|
@@ -118,13 +146,18 @@ export declare type TagPickerContextValues = {
|
|
|
118
146
|
*/
|
|
119
147
|
export declare const TagPickerControl: ForwardRefComponent<TagPickerControlProps>;
|
|
120
148
|
|
|
149
|
+
/**
|
|
150
|
+
* TagPickerControl Base State - omits design-only state derived from picker context.
|
|
151
|
+
*/
|
|
152
|
+
export declare type TagPickerControlBaseState = DistributiveOmit<TagPickerControlState, 'size' | 'appearance'>;
|
|
153
|
+
|
|
121
154
|
export declare const tagPickerControlClassNames: SlotClassNames<TagPickerControlSlots & TagPickerControlInternalSlots>;
|
|
122
155
|
|
|
123
156
|
declare type TagPickerControlCSSProperties = React_2.CSSProperties & {
|
|
124
157
|
'--fui-TagPickerControl-aside-width'?: string | number;
|
|
125
158
|
};
|
|
126
159
|
|
|
127
|
-
declare type TagPickerControlInternalSlots = {
|
|
160
|
+
export declare type TagPickerControlInternalSlots = {
|
|
128
161
|
aside?: NonNullable<Slot<'span'>>;
|
|
129
162
|
};
|
|
130
163
|
|
|
@@ -179,6 +212,16 @@ export declare type TagPickerGroupState = TagGroupState & {
|
|
|
179
212
|
*/
|
|
180
213
|
export declare const TagPickerInput: ForwardRefComponent<TagPickerInputProps>;
|
|
181
214
|
|
|
215
|
+
/**
|
|
216
|
+
* TagPickerInput Base Props - omits design-only props
|
|
217
|
+
*/
|
|
218
|
+
export declare type TagPickerInputBaseProps = DistributiveOmit<TagPickerInputProps, 'appearance'>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* TagPickerInput Base State - omits design-only state
|
|
222
|
+
*/
|
|
223
|
+
export declare type TagPickerInputBaseState = DistributiveOmit<TagPickerInputState, 'size'>;
|
|
224
|
+
|
|
182
225
|
export declare const tagPickerInputClassNames: SlotClassNames<TagPickerInputSlots>;
|
|
183
226
|
|
|
184
227
|
/**
|
|
@@ -353,16 +396,30 @@ export declare type TagPickerState = ComponentState<TagPickerSlots> & Pick<Combo
|
|
|
353
396
|
export declare const useTagPicker_unstable: (props: TagPickerProps) => TagPickerState;
|
|
354
397
|
|
|
355
398
|
/**
|
|
356
|
-
* Create the state required to render
|
|
399
|
+
* Create the base state required to render TagPicker, without floating-ui positioning.
|
|
400
|
+
* @param props - props from this instance of TagPicker (without `positioning`)
|
|
401
|
+
*/
|
|
402
|
+
export declare const useTagPickerBase_unstable: (props: TagPickerBaseProps) => TagPickerBaseState;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Create the state required to render TagPickerButton.
|
|
357
406
|
*
|
|
358
|
-
* The returned state can be modified with hooks such as
|
|
359
|
-
* before being passed to
|
|
407
|
+
* The returned state can be modified with hooks such as useTagPickerButtonStyles_unstable,
|
|
408
|
+
* before being passed to renderTagPickerButton_unstable.
|
|
360
409
|
*
|
|
361
|
-
* @param props - props from this instance of
|
|
362
|
-
* @param ref - reference to root
|
|
410
|
+
* @param props - props from this instance of TagPickerButton
|
|
411
|
+
* @param ref - reference to root HTMLButtonElement of TagPickerButton
|
|
363
412
|
*/
|
|
364
413
|
export declare const useTagPickerButton_unstable: (props: TagPickerButtonProps, ref: React_2.Ref<HTMLButtonElement>) => TagPickerButtonState;
|
|
365
414
|
|
|
415
|
+
/**
|
|
416
|
+
* Create the base state required to render TagPickerButton, without design-only props.
|
|
417
|
+
*
|
|
418
|
+
* @param props - props from this instance of TagPickerButton (without size, appearance)
|
|
419
|
+
* @param ref - reference to root HTMLButtonElement of TagPickerButton
|
|
420
|
+
*/
|
|
421
|
+
export declare const useTagPickerButtonBase_unstable: (props: TagPickerButtonBaseProps, ref: React_2.Ref<HTMLButtonElement>) => TagPickerButtonBaseState;
|
|
422
|
+
|
|
366
423
|
/**
|
|
367
424
|
* Apply styling to the PickerButton slots based on the state
|
|
368
425
|
*/
|
|
@@ -370,6 +427,8 @@ export declare const useTagPickerButtonStyles_unstable: (state: TagPickerButtonS
|
|
|
370
427
|
|
|
371
428
|
export declare const useTagPickerContext_unstable: <T>(selector: ContextSelector<TagPickerContextValue, T>) => T;
|
|
372
429
|
|
|
430
|
+
export declare function useTagPickerContextValues(state: TagPickerState): TagPickerContextValues;
|
|
431
|
+
|
|
373
432
|
/**
|
|
374
433
|
* Create the state required to render PickerControl.
|
|
375
434
|
*
|
|
@@ -381,6 +440,14 @@ export declare const useTagPickerContext_unstable: <T>(selector: ContextSelector
|
|
|
381
440
|
*/
|
|
382
441
|
export declare const useTagPickerControl_unstable: (props: TagPickerControlProps, ref: React_2.Ref<HTMLDivElement>) => TagPickerControlState;
|
|
383
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Create the base state required to render TagPickerControl, without design-only state.
|
|
445
|
+
*
|
|
446
|
+
* @param props - props from this instance of TagPickerControl
|
|
447
|
+
* @param ref - reference to root HTMLDivElement of TagPickerControl
|
|
448
|
+
*/
|
|
449
|
+
export declare const useTagPickerControlBase_unstable: (props: TagPickerControlProps, ref: React_2.Ref<HTMLDivElement>) => TagPickerControlBaseState;
|
|
450
|
+
|
|
384
451
|
/**
|
|
385
452
|
* Apply styling to the PickerControl slots based on the state
|
|
386
453
|
*/
|
|
@@ -425,9 +492,19 @@ export declare const useTagPickerGroupStyles_unstable: (state: TagPickerGroupSta
|
|
|
425
492
|
* before being passed to renderTagPickerInput_unstable.
|
|
426
493
|
*
|
|
427
494
|
* @param props - props from this instance of TagPickerInput
|
|
428
|
-
* @param ref - reference to root
|
|
495
|
+
* @param ref - reference to root HTMLInputElement of TagPickerInput
|
|
496
|
+
*/
|
|
497
|
+
export declare const useTagPickerInput_unstable: (props: TagPickerInputProps, ref: React_2.Ref<HTMLInputElement>) => TagPickerInputState;
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Create the base state required to render TagPickerInput, without design-only props.
|
|
501
|
+
* The Base hook omits Tabster-driven focus management; consumers can re-add it via the
|
|
502
|
+
* styled wrapper {@link useTagPickerInput_unstable} or by composing their own keydown handler.
|
|
503
|
+
*
|
|
504
|
+
* @param props - props from this instance of TagPickerInput (without appearance)
|
|
505
|
+
* @param ref - reference to root HTMLInputElement of TagPickerInput
|
|
429
506
|
*/
|
|
430
|
-
export declare const
|
|
507
|
+
export declare const useTagPickerInputBase_unstable: (props: TagPickerInputBaseProps, ref: React_2.Ref<HTMLInputElement>) => TagPickerInputBaseState;
|
|
431
508
|
|
|
432
509
|
/**
|
|
433
510
|
* Apply styling to the TagPickerInput slots based on the state
|
package/lib/TagPicker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TagPicker, renderTagPicker_unstable, useTagPicker_unstable } from './components/TagPicker/index';
|
|
1
|
+
export { TagPicker, renderTagPicker_unstable, useTagPicker_unstable, useTagPickerBase_unstable, useTagPickerContextValues } from './components/TagPicker/index';
|
package/lib/TagPicker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TagPicker.ts"],"sourcesContent":["export type {\n TagPickerContextValues,\n TagPickerOnOpenChangeData,\n TagPickerOnOptionSelectData,\n TagPickerProps,\n TagPickerSize,\n TagPickerSlots,\n TagPickerState,\n} from './components/TagPicker/index';\nexport {
|
|
1
|
+
{"version":3,"sources":["../src/TagPicker.ts"],"sourcesContent":["export type {\n TagPickerBaseProps,\n TagPickerBaseState,\n TagPickerContextValues,\n TagPickerOnOpenChangeData,\n TagPickerOnOptionSelectData,\n TagPickerProps,\n TagPickerSize,\n TagPickerSlots,\n TagPickerState,\n} from './components/TagPicker/index';\nexport {\n TagPicker,\n renderTagPicker_unstable,\n useTagPicker_unstable,\n useTagPickerBase_unstable,\n useTagPickerContextValues,\n} from './components/TagPicker/index';\n"],"names":["TagPicker","renderTagPicker_unstable","useTagPicker_unstable","useTagPickerBase_unstable","useTagPickerContextValues"],"mappings":"AAWA,SACEA,SAAS,EACTC,wBAAwB,EACxBC,qBAAqB,EACrBC,yBAAyB,EACzBC,yBAAyB,QACpB,+BAA+B"}
|
package/lib/TagPickerButton.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TagPickerButton, renderTagPickerButton_unstable, tagPickerButtonClassNames, useTagPickerButtonStyles_unstable, useTagPickerButton_unstable } from './components/TagPickerButton/index';
|
|
1
|
+
export { TagPickerButton, renderTagPickerButton_unstable, tagPickerButtonClassNames, useTagPickerButtonStyles_unstable, useTagPickerButton_unstable, useTagPickerButtonBase_unstable } from './components/TagPickerButton/index';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TagPickerButton.ts"],"sourcesContent":["export type {\n TagPickerButtonProps,\n TagPickerButtonSlots,\n TagPickerButtonState,\n} from './components/TagPickerButton/index';\nexport {\n TagPickerButton,\n renderTagPickerButton_unstable,\n tagPickerButtonClassNames,\n useTagPickerButtonStyles_unstable,\n useTagPickerButton_unstable,\n} from './components/TagPickerButton/index';\n"],"names":["TagPickerButton","renderTagPickerButton_unstable","tagPickerButtonClassNames","useTagPickerButtonStyles_unstable","useTagPickerButton_unstable"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/TagPickerButton.ts"],"sourcesContent":["export type {\n TagPickerButtonBaseProps,\n TagPickerButtonBaseState,\n TagPickerButtonProps,\n TagPickerButtonSlots,\n TagPickerButtonState,\n} from './components/TagPickerButton/index';\nexport {\n TagPickerButton,\n renderTagPickerButton_unstable,\n tagPickerButtonClassNames,\n useTagPickerButtonStyles_unstable,\n useTagPickerButton_unstable,\n useTagPickerButtonBase_unstable,\n} from './components/TagPickerButton/index';\n"],"names":["TagPickerButton","renderTagPickerButton_unstable","tagPickerButtonClassNames","useTagPickerButtonStyles_unstable","useTagPickerButton_unstable","useTagPickerButtonBase_unstable"],"mappings":"AAOA,SACEA,eAAe,EACfC,8BAA8B,EAC9BC,yBAAyB,EACzBC,iCAAiC,EACjCC,2BAA2B,EAC3BC,+BAA+B,QAC1B,qCAAqC"}
|
package/lib/TagPickerControl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TagPickerControl, iconSizes, renderTagPickerControl_unstable, tagPickerControlAsideWidthToken, tagPickerControlClassNames, useTagPickerControlStyles_unstable, useTagPickerControl_unstable } from './components/TagPickerControl/index';
|
|
1
|
+
export { TagPickerControl, iconSizes, renderTagPickerControl_unstable, tagPickerControlAsideWidthToken, tagPickerControlClassNames, useTagPickerControlStyles_unstable, useTagPickerControl_unstable, useTagPickerControlBase_unstable } from './components/TagPickerControl/index';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TagPickerControl.ts"],"sourcesContent":["export type {\n TagPickerControlCSSProperties,\n TagPickerControlInternalSlots,\n TagPickerControlProps,\n TagPickerControlSlots,\n TagPickerControlState,\n} from './components/TagPickerControl/index';\nexport {\n TagPickerControl,\n iconSizes,\n renderTagPickerControl_unstable,\n tagPickerControlAsideWidthToken,\n tagPickerControlClassNames,\n useTagPickerControlStyles_unstable,\n useTagPickerControl_unstable,\n} from './components/TagPickerControl/index';\n"],"names":["TagPickerControl","iconSizes","renderTagPickerControl_unstable","tagPickerControlAsideWidthToken","tagPickerControlClassNames","useTagPickerControlStyles_unstable","useTagPickerControl_unstable"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/TagPickerControl.ts"],"sourcesContent":["export type {\n TagPickerControlBaseState,\n TagPickerControlCSSProperties,\n TagPickerControlInternalSlots,\n TagPickerControlProps,\n TagPickerControlSlots,\n TagPickerControlState,\n} from './components/TagPickerControl/index';\nexport {\n TagPickerControl,\n iconSizes,\n renderTagPickerControl_unstable,\n tagPickerControlAsideWidthToken,\n tagPickerControlClassNames,\n useTagPickerControlStyles_unstable,\n useTagPickerControl_unstable,\n useTagPickerControlBase_unstable,\n} from './components/TagPickerControl/index';\n"],"names":["TagPickerControl","iconSizes","renderTagPickerControl_unstable","tagPickerControlAsideWidthToken","tagPickerControlClassNames","useTagPickerControlStyles_unstable","useTagPickerControl_unstable","useTagPickerControlBase_unstable"],"mappings":"AAQA,SACEA,gBAAgB,EAChBC,SAAS,EACTC,+BAA+B,EAC/BC,+BAA+B,EAC/BC,0BAA0B,EAC1BC,kCAAkC,EAClCC,4BAA4B,EAC5BC,gCAAgC,QAC3B,sCAAsC"}
|
package/lib/TagPickerInput.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TagPickerInput, renderTagPickerInput_unstable, tagPickerInputClassNames, useTagPickerInputStyles_unstable, useTagPickerInput_unstable } from './components/TagPickerInput/index';
|
|
1
|
+
export { TagPickerInput, renderTagPickerInput_unstable, tagPickerInputClassNames, useTagPickerInputStyles_unstable, useTagPickerInput_unstable, useTagPickerInputBase_unstable } from './components/TagPickerInput/index';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TagPickerInput.ts"],"sourcesContent":["export type {
|
|
1
|
+
{"version":3,"sources":["../src/TagPickerInput.ts"],"sourcesContent":["export type {\n TagPickerInputBaseProps,\n TagPickerInputBaseState,\n TagPickerInputProps,\n TagPickerInputSlots,\n TagPickerInputState,\n} from './components/TagPickerInput/index';\nexport {\n TagPickerInput,\n renderTagPickerInput_unstable,\n tagPickerInputClassNames,\n useTagPickerInputStyles_unstable,\n useTagPickerInput_unstable,\n useTagPickerInputBase_unstable,\n} from './components/TagPickerInput/index';\n"],"names":["TagPickerInput","renderTagPickerInput_unstable","tagPickerInputClassNames","useTagPickerInputStyles_unstable","useTagPickerInput_unstable","useTagPickerInputBase_unstable"],"mappings":"AAOA,SACEA,cAAc,EACdC,6BAA6B,EAC7BC,wBAAwB,EACxBC,gCAAgC,EAChCC,0BAA0B,EAC1BC,8BAA8B,QACzB,oCAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPicker/TagPicker.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPicker/TagPicker.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type {\n ComponentProps,\n ComponentState,\n DistributiveOmit,\n EventData,\n EventHandler,\n JSXElement,\n} from '@fluentui/react-utilities';\nimport type { ComboboxProps, ComboboxState, ListboxContextValue } from '@fluentui/react-combobox';\nimport type { TagPickerContextValue } from '../../contexts/TagPickerContext';\nimport type { ActiveDescendantContextValue } from '@fluentui/react-aria';\n\nexport type TagPickerSlots = {};\n\nexport type TagPickerSize = 'medium' | 'large' | 'extra-large';\n\n/**\n * Event data for the `onOptionSelect` event.\n *\n * * value - The value of the selected option that triggered the event\n * * selectedOptions - The list of selected options\n */\nexport type TagPickerOnOptionSelectData = {\n value: string;\n selectedOptions: string[];\n} & (EventData<'click', React.MouseEvent<HTMLDivElement>> | EventData<'keydown', React.KeyboardEvent<HTMLDivElement>>);\n\nexport type TagPickerOnOpenChangeData = { open: boolean } & (\n | EventData<'click', React.MouseEvent<HTMLDivElement>>\n | EventData<'keydown', React.KeyboardEvent<HTMLDivElement>>\n);\n\n/**\n * Picker Props\n */\nexport type TagPickerProps = ComponentProps<TagPickerSlots> &\n Pick<\n ComboboxProps,\n | 'positioning'\n | 'disabled'\n | 'defaultOpen'\n | 'selectedOptions'\n | 'defaultSelectedOptions'\n | 'open'\n | 'disableAutoFocus'\n > &\n Pick<Partial<TagPickerContextValue>, 'size' | 'appearance'> & {\n /**\n * By default, when a single children is provided, the TagPicker will assume that the children\n * is a popover. By setting this prop to true, the children will be treated as a trigger instead.\n *\n * @default false\n */\n noPopover?: boolean;\n onOpenChange?: EventHandler<TagPickerOnOpenChangeData>;\n onOptionSelect?: EventHandler<TagPickerOnOptionSelectData>;\n\n /**\n * Can contain two children including a trigger and a popover\n */\n children: [JSXElement, JSXElement | undefined | false] | JSXElement;\n /**\n * TagPickers are rendered out of DOM order on `document.body` by default,\n * use this to render the popover in DOM order\n *\n * @default false\n */\n inline?: boolean;\n };\n\n/**\n * State used in rendering Picker\n */\nexport type TagPickerState = ComponentState<TagPickerSlots> &\n Pick<\n ComboboxState,\n | 'open'\n | 'activeDescendantController'\n | 'mountNode'\n | 'onOptionClick'\n | 'registerOption'\n | 'selectedOptions'\n | 'selectOption'\n | 'value'\n | 'setValue'\n | 'setOpen'\n | 'setHasFocus'\n | 'appearance'\n | 'clearSelection'\n | 'getOptionById'\n | 'getOptionsMatchingValue'\n | 'disabled'\n > &\n Pick<\n TagPickerContextValue,\n | 'triggerRef'\n | 'secondaryActionRef'\n | 'popoverId'\n | 'popoverRef'\n | 'targetRef'\n | 'tagPickerGroupRef'\n | 'size'\n | 'noPopover'\n > & {\n trigger: React.ReactNode;\n popover?: React.ReactNode;\n inline: boolean;\n };\n\nexport type TagPickerContextValues = {\n picker: TagPickerContextValue;\n activeDescendant: ActiveDescendantContextValue;\n listbox: ListboxContextValue;\n};\n\n/**\n * TagPicker Base Props - omits the presentation-related props that the base hook does not handle:\n * the floating-ui `positioning` prop (the styled {@link TagPickerProps} re-introduces it via\n * `usePositioning`) as well as `size`, `appearance` and `inline` (layered on by the styled\n * {@link useTagPicker_unstable} hook).\n */\nexport type TagPickerBaseProps = DistributiveOmit<TagPickerProps, 'positioning' | 'size' | 'appearance' | 'inline'>;\n\n/**\n * TagPicker Base State - the state produced by the base hook, which does not interact with the\n * `size`, `appearance` and `inline` props. These are layered on by the styled\n * {@link useTagPicker_unstable} hook.\n */\nexport type TagPickerBaseState = Omit<TagPickerState, 'size' | 'appearance' | 'inline'>;\n"],"names":[],"mappings":"AA4HA;;;;CAIC,GACD,WAAwF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { TagPicker } from './TagPicker';
|
|
2
2
|
export { renderTagPicker_unstable } from './renderTagPicker';
|
|
3
|
-
export { useTagPicker_unstable } from './useTagPicker';
|
|
3
|
+
export { useTagPicker_unstable, useTagPickerBase_unstable } from './useTagPicker';
|
|
4
|
+
export { useTagPickerContextValues } from './useTagPickerContextValues';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPicker/index.ts"],"sourcesContent":["export { TagPicker } from './TagPicker';\nexport type {\n TagPickerContextValues,\n TagPickerOnOpenChangeData,\n TagPickerOnOptionSelectData,\n TagPickerProps,\n TagPickerSize,\n TagPickerSlots,\n TagPickerState,\n} from './TagPicker.types';\nexport { renderTagPicker_unstable } from './renderTagPicker';\nexport { useTagPicker_unstable } from './useTagPicker';\n"],"names":["TagPicker","renderTagPicker_unstable","useTagPicker_unstable"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPicker/index.ts"],"sourcesContent":["export { TagPicker } from './TagPicker';\nexport type {\n TagPickerBaseProps,\n TagPickerBaseState,\n TagPickerContextValues,\n TagPickerOnOpenChangeData,\n TagPickerOnOptionSelectData,\n TagPickerProps,\n TagPickerSize,\n TagPickerSlots,\n TagPickerState,\n} from './TagPicker.types';\nexport { renderTagPicker_unstable } from './renderTagPicker';\nexport { useTagPicker_unstable, useTagPickerBase_unstable } from './useTagPicker';\nexport { useTagPickerContextValues } from './useTagPickerContextValues';\n"],"names":["TagPicker","renderTagPicker_unstable","useTagPicker_unstable","useTagPickerBase_unstable","useTagPickerContextValues"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AAYxC,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,qBAAqB,EAAEC,yBAAyB,QAAQ,iBAAiB;AAClF,SAASC,yBAAyB,QAAQ,8BAA8B"}
|
|
@@ -14,29 +14,15 @@ const fallbackPositions = [
|
|
|
14
14
|
'before-top'
|
|
15
15
|
];
|
|
16
16
|
/**
|
|
17
|
-
* Create the state required to render
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
* before being passed to renderPicker_unstable.
|
|
21
|
-
*
|
|
22
|
-
* @param props - props from this instance of Picker
|
|
23
|
-
*/ export const useTagPicker_unstable = (props)=>{
|
|
17
|
+
* Create the base state required to render TagPicker, without floating-ui positioning.
|
|
18
|
+
* @param props - props from this instance of TagPicker (without `positioning`)
|
|
19
|
+
*/ export const useTagPickerBase_unstable = (props)=>{
|
|
24
20
|
const popoverId = useId('picker-listbox');
|
|
25
21
|
const triggerInnerRef = React.useRef(null);
|
|
26
22
|
const secondaryActionRef = React.useRef(null);
|
|
27
23
|
const tagPickerGroupRef = React.useRef(null);
|
|
28
|
-
const
|
|
29
|
-
const {
|
|
30
|
-
position: 'below',
|
|
31
|
-
align: 'start',
|
|
32
|
-
offset: {
|
|
33
|
-
crossAxis: 0,
|
|
34
|
-
mainAxis: 2
|
|
35
|
-
},
|
|
36
|
-
fallbackPositions,
|
|
37
|
-
matchTargetSize: 'width',
|
|
38
|
-
...resolvePositioningShorthand(positioning)
|
|
39
|
-
});
|
|
24
|
+
const passiveTargetRef = React.useRef(null);
|
|
25
|
+
const { noPopover = false, disableAutoFocus } = props;
|
|
40
26
|
const { controller: activeDescendantController, activeParentRef, listboxRef } = useActiveDescendant({
|
|
41
27
|
matchOption: (el)=>el.classList.contains(optionClassNames.root)
|
|
42
28
|
});
|
|
@@ -62,8 +48,7 @@ const fallbackPositions = [
|
|
|
62
48
|
activeDescendantController,
|
|
63
49
|
disableAutoFocus,
|
|
64
50
|
editable: true,
|
|
65
|
-
multiselect: true
|
|
66
|
-
size: 'medium'
|
|
51
|
+
multiselect: true
|
|
67
52
|
});
|
|
68
53
|
const { trigger, popover } = childrenToTriggerAndPopover(props.children, noPopover);
|
|
69
54
|
return {
|
|
@@ -75,19 +60,16 @@ const fallbackPositions = [
|
|
|
75
60
|
noPopover,
|
|
76
61
|
disabled: comboboxState.disabled,
|
|
77
62
|
triggerRef: useMergedRefs(triggerInnerRef, activeParentRef),
|
|
78
|
-
popoverRef: useMergedRefs(listboxRef
|
|
63
|
+
popoverRef: useMergedRefs(listboxRef),
|
|
79
64
|
secondaryActionRef,
|
|
80
65
|
tagPickerGroupRef,
|
|
81
|
-
targetRef,
|
|
82
|
-
size,
|
|
83
|
-
inline,
|
|
66
|
+
targetRef: passiveTargetRef,
|
|
84
67
|
open: comboboxState.open,
|
|
85
68
|
mountNode: comboboxState.mountNode,
|
|
86
69
|
onOptionClick: useEventCallback((event)=>{
|
|
87
70
|
comboboxState.onOptionClick(event);
|
|
88
71
|
comboboxState.setOpen(event, false);
|
|
89
72
|
}),
|
|
90
|
-
appearance: comboboxState.appearance,
|
|
91
73
|
clearSelection: comboboxState.clearSelection,
|
|
92
74
|
getOptionById: comboboxState.getOptionById,
|
|
93
75
|
getOptionsMatchingValue: comboboxState.getOptionsMatchingValue,
|
|
@@ -114,6 +96,36 @@ const fallbackPositions = [
|
|
|
114
96
|
value: comboboxState.value
|
|
115
97
|
};
|
|
116
98
|
};
|
|
99
|
+
/**
|
|
100
|
+
* Create the state required to render Picker.
|
|
101
|
+
*
|
|
102
|
+
* The returned state can be modified with hooks such as usePickerStyles_unstable,
|
|
103
|
+
* before being passed to renderPicker_unstable.
|
|
104
|
+
*
|
|
105
|
+
* @param props - props from this instance of Picker
|
|
106
|
+
*/ export const useTagPicker_unstable = (props)=>{
|
|
107
|
+
const { positioning, size = 'medium', appearance = 'outline', inline = false } = props;
|
|
108
|
+
const { targetRef, containerRef } = usePositioning({
|
|
109
|
+
position: 'below',
|
|
110
|
+
align: 'start',
|
|
111
|
+
offset: {
|
|
112
|
+
crossAxis: 0,
|
|
113
|
+
mainAxis: 2
|
|
114
|
+
},
|
|
115
|
+
fallbackPositions,
|
|
116
|
+
matchTargetSize: 'width',
|
|
117
|
+
...resolvePositioningShorthand(positioning)
|
|
118
|
+
});
|
|
119
|
+
const baseState = useTagPickerBase_unstable(props);
|
|
120
|
+
return {
|
|
121
|
+
...baseState,
|
|
122
|
+
size,
|
|
123
|
+
appearance,
|
|
124
|
+
inline,
|
|
125
|
+
targetRef,
|
|
126
|
+
popoverRef: useMergedRefs(baseState.popoverRef, containerRef)
|
|
127
|
+
};
|
|
128
|
+
};
|
|
117
129
|
const childrenToTriggerAndPopover = (children, noPopover)=>{
|
|
118
130
|
const childrenArray = React.Children.toArray(children);
|
|
119
131
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPicker/useTagPicker.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { elementContains, useEventCallback, useId, useMergedRefs } from '@fluentui/react-utilities';\nimport type {\n TagPickerOnOpenChangeData,\n TagPickerOnOptionSelectData,\n TagPickerProps,\n TagPickerState,\n} from './TagPicker.types';\nimport { optionClassNames } from '@fluentui/react-combobox';\nimport type { PositioningShorthandValue } from '@fluentui/react-positioning';\nimport { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { useComboboxBaseState } from '@fluentui/react-combobox';\n\n// Set a default set of fallback positions to try if the dropdown does not fit on screen\nconst fallbackPositions: PositioningShorthandValue[] = ['above', 'after', 'after-top', 'before', 'before-top'];\n\n/**\n * Create the state required to render Picker.\n *\n * The returned state can be modified with hooks such as usePickerStyles_unstable,\n * before being passed to renderPicker_unstable.\n *\n * @param props - props from this instance of Picker\n */\nexport const useTagPicker_unstable = (props: TagPickerProps): TagPickerState => {\n const popoverId = useId('picker-listbox');\n const triggerInnerRef = React.useRef<HTMLInputElement | HTMLButtonElement>(null);\n const secondaryActionRef = React.useRef<HTMLSpanElement>(null);\n const tagPickerGroupRef = React.useRef<HTMLDivElement>(null);\n const { positioning, size = 'medium', inline = false, noPopover = false, disableAutoFocus } = props;\n\n const { targetRef, containerRef } = usePositioning({\n position: 'below' as const,\n align: 'start' as const,\n offset: { crossAxis: 0, mainAxis: 2 },\n fallbackPositions,\n matchTargetSize: 'width' as const,\n ...resolvePositioningShorthand(positioning),\n });\n\n const {\n controller: activeDescendantController,\n activeParentRef,\n listboxRef,\n } = useActiveDescendant<HTMLInputElement, HTMLDivElement>({\n matchOption: el => el.classList.contains(optionClassNames.root),\n });\n\n const comboboxState = useComboboxBaseState({\n ...props,\n onOptionSelect: useEventCallback((event, data) =>\n props.onOptionSelect?.(event, {\n selectedOptions: data.selectedOptions,\n value: data.optionValue,\n type: event.type,\n event,\n } as TagPickerOnOptionSelectData),\n ),\n onOpenChange: useEventCallback((event, data) =>\n props.onOpenChange?.(event, {\n ...data,\n type: event.type,\n event,\n } as TagPickerOnOpenChangeData),\n ),\n activeDescendantController,\n disableAutoFocus,\n editable: true,\n multiselect: true,\n size: 'medium',\n });\n\n const { trigger, popover } = childrenToTriggerAndPopover(props.children, noPopover);\n return {\n activeDescendantController,\n components: {},\n trigger,\n popover: comboboxState.open || comboboxState.hasFocus ? popover : undefined,\n popoverId,\n noPopover,\n disabled: comboboxState.disabled,\n triggerRef: useMergedRefs(triggerInnerRef, activeParentRef),\n popoverRef: useMergedRefs(listboxRef, containerRef),\n secondaryActionRef,\n tagPickerGroupRef,\n targetRef,\n size,\n inline,\n open: comboboxState.open,\n mountNode: comboboxState.mountNode,\n onOptionClick: useEventCallback(event => {\n comboboxState.onOptionClick(event);\n comboboxState.setOpen(event, false);\n }),\n appearance: comboboxState.appearance,\n clearSelection: comboboxState.clearSelection,\n getOptionById: comboboxState.getOptionById,\n getOptionsMatchingValue: comboboxState.getOptionsMatchingValue,\n registerOption: comboboxState.registerOption,\n selectedOptions: comboboxState.selectedOptions,\n selectOption: useEventCallback((event, data) => {\n // if the option is already selected, invoke onOptionSelect callback with current selected values\n // the combobox state would unselect the option, which is not the behavior expected\n if (\n comboboxState.selectedOptions.includes(data.value) &&\n !elementContains(tagPickerGroupRef.current, event.target as Node)\n ) {\n props.onOptionSelect?.(event, {\n selectedOptions: comboboxState.selectedOptions,\n value: data.value,\n type: event.type,\n event,\n } as TagPickerOnOptionSelectData);\n return;\n }\n comboboxState.selectOption(event, data);\n }),\n setHasFocus: comboboxState.setHasFocus,\n setOpen: comboboxState.setOpen,\n setValue: comboboxState.setValue,\n value: comboboxState.value,\n };\n};\n\nconst childrenToTriggerAndPopover = (children: React.ReactNode, noPopover: boolean) => {\n const childrenArray = React.Children.toArray(children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (childrenArray.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('TagPicker must contain at least one child');\n }\n\n if (childrenArray.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('TagPicker must contain at most two children');\n }\n }\n\n if (noPopover) {\n return { trigger: childrenArray[0] };\n }\n\n let trigger: React.ReactElement | undefined = undefined;\n let popover: React.ReactElement | undefined = undefined;\n\n if (childrenArray.length === 2) {\n trigger = childrenArray[0];\n popover = childrenArray[1];\n } else if (childrenArray.length === 1) {\n popover = childrenArray[0];\n }\n\n return { trigger, popover };\n};\n"],"names":["React","elementContains","useEventCallback","useId","useMergedRefs","optionClassNames","resolvePositioningShorthand","usePositioning","useActiveDescendant","useComboboxBaseState","fallbackPositions","useTagPicker_unstable","props","popoverId","triggerInnerRef","useRef","secondaryActionRef","tagPickerGroupRef","positioning","size","inline","noPopover","disableAutoFocus","targetRef","containerRef","position","align","offset","crossAxis","mainAxis","matchTargetSize","controller","activeDescendantController","activeParentRef","listboxRef","matchOption","el","classList","contains","root","comboboxState","onOptionSelect","event","data","selectedOptions","value","optionValue","type","onOpenChange","editable","multiselect","trigger","popover","childrenToTriggerAndPopover","children","components","open","hasFocus","undefined","disabled","triggerRef","popoverRef","mountNode","onOptionClick","setOpen","appearance","clearSelection","getOptionById","getOptionsMatchingValue","registerOption","selectOption","includes","current","target","setHasFocus","setValue","childrenArray","Children","toArray","process","env","NODE_ENV","length","console","warn"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,eAAe,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,aAAa,QAAQ,4BAA4B;AAOpG,SAASC,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AAOF,KAAKE,KAAK;oBACjBE,MAAML,MAAMK,IAAI;oBAChBL;gBACF;gBACA;YACF;YACAF,cAAc8B,YAAY,CAAC5B,OAAOC;QACpC;QACA+B,aAAalC,cAAckC,WAAW;QACtCV,SAASxB,cAAcwB,OAAO;QAC9BW,UAAUnC,cAAcmC,QAAQ;QAChC9B,OAAOL,cAAcK,KAAK;IAC5B;AACF,EAAE;AAEF,MAAMQ,8BAA8B,CAACC,UAA2BjC;IAC9D,MAAMuD,gBAAgB5E,MAAM6E,QAAQ,CAACC,OAAO,CAACxB;IAE7C,IAAIyB,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIL,cAAcM,MAAM,KAAK,GAAG;YAC9B,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf;QAEA,IAAIR,cAAcM,MAAM,GAAG,GAAG;YAC5B,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf;IACF;IAEA,IAAI/D,WAAW;QACb,OAAO;YAAE8B,SAASyB,aAAa,CAAC,EAAE;QAAC;IACrC;IAEA,IAAIzB,UAA0CO;IAC9C,IAAIN,UAA0CM;IAE9C,IAAIkB,cAAcM,MAAM,KAAK,GAAG;QAC9B/B,UAAUyB,aAAa,CAAC,EAAE;QAC1BxB,UAAUwB,aAAa,CAAC,EAAE;IAC5B,OAAO,IAAIA,cAAcM,MAAM,KAAK,GAAG;QACrC9B,UAAUwB,aAAa,CAAC,EAAE;IAC5B;IAEA,OAAO;QAAEzB;QAASC;IAAQ;AAC5B"}
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPicker/useTagPicker.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { elementContains, useEventCallback, useId, useMergedRefs } from '@fluentui/react-utilities';\nimport type {\n TagPickerBaseProps,\n TagPickerBaseState,\n TagPickerOnOpenChangeData,\n TagPickerOnOptionSelectData,\n TagPickerProps,\n TagPickerState,\n} from './TagPicker.types';\nimport { optionClassNames } from '@fluentui/react-combobox';\nimport type { PositioningShorthandValue } from '@fluentui/react-positioning';\nimport { resolvePositioningShorthand, usePositioning } from '@fluentui/react-positioning';\nimport { useActiveDescendant } from '@fluentui/react-aria';\nimport { useComboboxBaseState } from '@fluentui/react-combobox';\n\n// Set a default set of fallback positions to try if the dropdown does not fit on screen\nconst fallbackPositions: PositioningShorthandValue[] = ['above', 'after', 'after-top', 'before', 'before-top'];\n\n/**\n * Create the base state required to render TagPicker, without floating-ui positioning.\n * @param props - props from this instance of TagPicker (without `positioning`)\n */\nexport const useTagPickerBase_unstable = (props: TagPickerBaseProps): TagPickerBaseState => {\n const popoverId = useId('picker-listbox');\n const triggerInnerRef = React.useRef<HTMLInputElement | HTMLButtonElement>(null);\n const secondaryActionRef = React.useRef<HTMLSpanElement>(null);\n const tagPickerGroupRef = React.useRef<HTMLDivElement>(null);\n const passiveTargetRef = React.useRef<HTMLDivElement>(null);\n const { noPopover = false, disableAutoFocus } = props;\n\n const {\n controller: activeDescendantController,\n activeParentRef,\n listboxRef,\n } = useActiveDescendant<HTMLInputElement, HTMLDivElement>({\n matchOption: el => el.classList.contains(optionClassNames.root),\n });\n\n const comboboxState = useComboboxBaseState({\n ...props,\n onOptionSelect: useEventCallback((event, data) =>\n props.onOptionSelect?.(event, {\n selectedOptions: data.selectedOptions,\n value: data.optionValue,\n type: event.type,\n event,\n } as TagPickerOnOptionSelectData),\n ),\n onOpenChange: useEventCallback((event, data) =>\n props.onOpenChange?.(event, {\n ...data,\n type: event.type,\n event,\n } as TagPickerOnOpenChangeData),\n ),\n activeDescendantController,\n disableAutoFocus,\n editable: true,\n multiselect: true,\n });\n\n const { trigger, popover } = childrenToTriggerAndPopover(props.children, noPopover);\n return {\n activeDescendantController,\n components: {},\n trigger,\n popover: comboboxState.open || comboboxState.hasFocus ? popover : undefined,\n popoverId,\n noPopover,\n disabled: comboboxState.disabled,\n triggerRef: useMergedRefs(triggerInnerRef, activeParentRef),\n popoverRef: useMergedRefs(listboxRef),\n secondaryActionRef,\n tagPickerGroupRef,\n targetRef: passiveTargetRef,\n open: comboboxState.open,\n mountNode: comboboxState.mountNode,\n onOptionClick: useEventCallback(event => {\n comboboxState.onOptionClick(event);\n comboboxState.setOpen(event, false);\n }),\n clearSelection: comboboxState.clearSelection,\n getOptionById: comboboxState.getOptionById,\n getOptionsMatchingValue: comboboxState.getOptionsMatchingValue,\n registerOption: comboboxState.registerOption,\n selectedOptions: comboboxState.selectedOptions,\n selectOption: useEventCallback((event, data) => {\n // if the option is already selected, invoke onOptionSelect callback with current selected values\n // the combobox state would unselect the option, which is not the behavior expected\n if (\n comboboxState.selectedOptions.includes(data.value) &&\n !elementContains(tagPickerGroupRef.current, event.target as Node)\n ) {\n props.onOptionSelect?.(event, {\n selectedOptions: comboboxState.selectedOptions,\n value: data.value,\n type: event.type,\n event,\n } as TagPickerOnOptionSelectData);\n return;\n }\n comboboxState.selectOption(event, data);\n }),\n setHasFocus: comboboxState.setHasFocus,\n setOpen: comboboxState.setOpen,\n setValue: comboboxState.setValue,\n value: comboboxState.value,\n };\n};\n\n/**\n * Create the state required to render Picker.\n *\n * The returned state can be modified with hooks such as usePickerStyles_unstable,\n * before being passed to renderPicker_unstable.\n *\n * @param props - props from this instance of Picker\n */\nexport const useTagPicker_unstable = (props: TagPickerProps): TagPickerState => {\n const { positioning, size = 'medium', appearance = 'outline', inline = false } = props;\n\n const { targetRef, containerRef } = usePositioning({\n position: 'below' as const,\n align: 'start' as const,\n offset: { crossAxis: 0, mainAxis: 2 },\n fallbackPositions,\n matchTargetSize: 'width' as const,\n ...resolvePositioningShorthand(positioning),\n });\n\n const baseState = useTagPickerBase_unstable(props);\n\n return {\n ...baseState,\n size,\n appearance,\n inline,\n targetRef,\n popoverRef: useMergedRefs(baseState.popoverRef, containerRef),\n };\n};\n\nconst childrenToTriggerAndPopover = (children: React.ReactNode, noPopover: boolean) => {\n const childrenArray = React.Children.toArray(children) as React.ReactElement[];\n\n if (process.env.NODE_ENV !== 'production') {\n if (childrenArray.length === 0) {\n // eslint-disable-next-line no-console\n console.warn('TagPicker must contain at least one child');\n }\n\n if (childrenArray.length > 2) {\n // eslint-disable-next-line no-console\n console.warn('TagPicker must contain at most two children');\n }\n }\n\n if (noPopover) {\n return { trigger: childrenArray[0] };\n }\n\n let trigger: React.ReactElement | undefined = undefined;\n let popover: React.ReactElement | undefined = undefined;\n\n if (childrenArray.length === 2) {\n trigger = childrenArray[0];\n popover = childrenArray[1];\n } else if (childrenArray.length === 1) {\n popover = childrenArray[0];\n }\n\n return { trigger, popover };\n};\n"],"names":["React","elementContains","useEventCallback","useId","useMergedRefs","optionClassNames","resolvePositioningShorthand","usePositioning","useActiveDescendant","useComboboxBaseState","fallbackPositions","useTagPickerBase_unstable","props","popoverId","triggerInnerRef","useRef","secondaryActionRef","tagPickerGroupRef","passiveTargetRef","noPopover","disableAutoFocus","controller","activeDescendantController","activeParentRef","listboxRef","matchOption","el","classList","contains","root","comboboxState","onOptionSelect","event","data","selectedOptions","value","optionValue","type","onOpenChange","editable","multiselect","trigger","popover","childrenToTriggerAndPopover","children","components","open","hasFocus","undefined","disabled","triggerRef","popoverRef","targetRef","mountNode","onOptionClick","setOpen","clearSelection","getOptionById","getOptionsMatchingValue","registerOption","selectOption","includes","current","target","setHasFocus","setValue","useTagPicker_unstable","positioning","size","appearance","inline","containerRef","position","align","offset","crossAxis","mainAxis","matchTargetSize","baseState","childrenArray","Children","toArray","process","env","NODE_ENV","length","console","warn"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,eAAe,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,aAAa,QAAQ,4BAA4B;AASpG,SAASC,gBAAgB,QAAQ,2BAA2B;AAE5D,SAASC,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AAC1F,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,wFAAwF;AACxF,MAAMC,oBAAiD;IAAC;IAAS;IAAS;IAAa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DiE,UAAU;QACVC,OAAO;QACPC,QAAQ;YAAEC,WAAW;YAAGC,UAAU;QAAE;QACpClE;QACAmE,iBAAiB;QACjB,GAAGvE,4BAA4B6D,YAAY;IAC7C;IAEA,MAAMW,YAAYnE,0BAA0BC;IAE5C,OAAO;QACL,GAAGkE,SAAS;QACZV;QACAC;QACAC;QACAlB;QACAD,YAAY/C,cAAc0E,UAAU3B,UAAU,EAAEoB;IAClD;AACF,EAAE;AAEF,MAAM5B,8BAA8B,CAACC,UAA2BzB;IAC9D,MAAM4D,gBAAgB/E,MAAMgF,QAAQ,CAACC,OAAO,CAACrC;IAE7C,IAAIsC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAIL,cAAcM,MAAM,KAAK,GAAG;YAC9B,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf;QAEA,IAAIR,cAAcM,MAAM,GAAG,GAAG;YAC5B,sCAAsC;YACtCC,QAAQC,IAAI,CAAC;QACf;IACF;IAEA,IAAIpE,WAAW;QACb,OAAO;YAAEsB,SAASsC,aAAa,CAAC,EAAE;QAAC;IACrC;IAEA,IAAItC,UAA0CO;IAC9C,IAAIN,UAA0CM;IAE9C,IAAI+B,cAAcM,MAAM,KAAK,GAAG;QAC9B5C,UAAUsC,aAAa,CAAC,EAAE;QAC1BrC,UAAUqC,aAAa,CAAC,EAAE;IAC5B,OAAO,IAAIA,cAAcM,MAAM,KAAK,GAAG;QACrC3C,UAAUqC,aAAa,CAAC,EAAE;IAC5B;IAEA,OAAO;QAAEtC;QAASC;IAAQ;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPickerButton/TagPickerButton.types.ts"],"sourcesContent":["import type { DropdownProps } from '@fluentui/react-combobox';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { TagPickerContextValue } from '../../contexts/TagPickerContext';\n\nexport type TagPickerButtonSlots = {\n root: Slot<'button'>;\n};\n\n/**\n * PickerButton Props\n */\nexport type TagPickerButtonProps = ComponentProps<TagPickerButtonSlots> &\n Pick<DropdownProps, 'size' | 'appearance'> & {\n disabled?: boolean;\n };\n\n/**\n * State used in rendering PickerButton\n */\nexport type TagPickerButtonState = ComponentState<TagPickerButtonSlots> &\n Pick<TagPickerContextValue, 'size'> & {\n hasSelectedOption: boolean;\n };\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPickerButton/TagPickerButton.types.ts"],"sourcesContent":["import type { DropdownProps } from '@fluentui/react-combobox';\nimport type { ComponentProps, ComponentState, DistributiveOmit, Slot } from '@fluentui/react-utilities';\nimport type { TagPickerContextValue } from '../../contexts/TagPickerContext';\n\nexport type TagPickerButtonSlots = {\n root: Slot<'button'>;\n};\n\n/**\n * PickerButton Props\n */\nexport type TagPickerButtonProps = ComponentProps<TagPickerButtonSlots> &\n Pick<DropdownProps, 'size' | 'appearance'> & {\n disabled?: boolean;\n };\n\n/**\n * State used in rendering PickerButton\n */\nexport type TagPickerButtonState = ComponentState<TagPickerButtonSlots> &\n Pick<TagPickerContextValue, 'size'> & {\n hasSelectedOption: boolean;\n };\n\n/**\n * TagPickerButton Base Props - omits design-only props\n */\nexport type TagPickerButtonBaseProps = DistributiveOmit<TagPickerButtonProps, 'size' | 'appearance'>;\n\n/**\n * TagPickerButton Base State - omits design-only state\n */\nexport type TagPickerButtonBaseState = DistributiveOmit<TagPickerButtonState, 'size'>;\n"],"names":[],"mappings":"AA6BA;;CAEC,GACD,WAAsF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { TagPickerButton } from './TagPickerButton';
|
|
2
2
|
export { renderTagPickerButton_unstable } from './renderTagPickerButton';
|
|
3
|
-
export { useTagPickerButton_unstable } from './useTagPickerButton';
|
|
3
|
+
export { useTagPickerButton_unstable, useTagPickerButtonBase_unstable } from './useTagPickerButton';
|
|
4
4
|
export { tagPickerButtonClassNames, useTagPickerButtonStyles_unstable } from './useTagPickerButtonStyles.styles';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPickerButton/index.ts"],"sourcesContent":["export { TagPickerButton } from './TagPickerButton';\nexport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPickerButton/index.ts"],"sourcesContent":["export { TagPickerButton } from './TagPickerButton';\nexport type {\n TagPickerButtonBaseProps,\n TagPickerButtonBaseState,\n TagPickerButtonProps,\n TagPickerButtonSlots,\n TagPickerButtonState,\n} from './TagPickerButton.types';\nexport { renderTagPickerButton_unstable } from './renderTagPickerButton';\nexport { useTagPickerButton_unstable, useTagPickerButtonBase_unstable } from './useTagPickerButton';\nexport { tagPickerButtonClassNames, useTagPickerButtonStyles_unstable } from './useTagPickerButtonStyles.styles';\n"],"names":["TagPickerButton","renderTagPickerButton_unstable","useTagPickerButton_unstable","useTagPickerButtonBase_unstable","tagPickerButtonClassNames","useTagPickerButtonStyles_unstable"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AAQpD,SAASC,8BAA8B,QAAQ,0BAA0B;AACzE,SAASC,2BAA2B,EAAEC,+BAA+B,QAAQ,uBAAuB;AACpG,SAASC,yBAAyB,EAAEC,iCAAiC,QAAQ,oCAAoC"}
|
|
@@ -3,14 +3,11 @@ import { useActiveDescendantContext } from '@fluentui/react-aria';
|
|
|
3
3
|
import { useTagPickerContext_unstable } from '../../contexts/TagPickerContext';
|
|
4
4
|
import { useButtonTriggerSlot } from '@fluentui/react-combobox';
|
|
5
5
|
/**
|
|
6
|
-
* Create the state required to render
|
|
6
|
+
* Create the base state required to render TagPickerButton, without design-only props.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
* @param props - props from this instance of PickerButton
|
|
12
|
-
* @param ref - reference to root HTMLDivElement of PickerButton
|
|
13
|
-
*/ export const useTagPickerButton_unstable = (props, ref)=>{
|
|
8
|
+
* @param props - props from this instance of TagPickerButton (without size, appearance)
|
|
9
|
+
* @param ref - reference to root HTMLButtonElement of TagPickerButton
|
|
10
|
+
*/ export const useTagPickerButtonBase_unstable = (props, ref)=>{
|
|
14
11
|
const { controller: activeDescendantController } = useActiveDescendantContext();
|
|
15
12
|
const triggerRef = useTagPickerContext_unstable((ctx)=>ctx.triggerRef);
|
|
16
13
|
const open = useTagPickerContext_unstable((ctx)=>ctx.open);
|
|
@@ -28,7 +25,7 @@ import { useButtonTriggerSlot } from '@fluentui/react-combobox';
|
|
|
28
25
|
defaultProps: {
|
|
29
26
|
type: 'button',
|
|
30
27
|
tabIndex: 0,
|
|
31
|
-
children: value || // @ts-expect-error - FIXME: TS2339: Property 'placeholder' does not exist on type '
|
|
28
|
+
children: value || // @ts-expect-error - FIXME: TS2339: Property 'placeholder' does not exist on type 'TagPickerButtonBaseProps'
|
|
32
29
|
props.placeholder,
|
|
33
30
|
'aria-controls': open ? popoverId : undefined,
|
|
34
31
|
ref
|
|
@@ -42,14 +39,27 @@ import { useButtonTriggerSlot } from '@fluentui/react-combobox';
|
|
|
42
39
|
multiselect: true
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
|
-
|
|
46
|
-
const state = {
|
|
42
|
+
return {
|
|
47
43
|
components: {
|
|
48
44
|
root: 'button'
|
|
49
45
|
},
|
|
50
46
|
root,
|
|
51
|
-
size,
|
|
52
47
|
hasSelectedOption
|
|
53
48
|
};
|
|
54
|
-
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Create the state required to render TagPickerButton.
|
|
52
|
+
*
|
|
53
|
+
* The returned state can be modified with hooks such as useTagPickerButtonStyles_unstable,
|
|
54
|
+
* before being passed to renderTagPickerButton_unstable.
|
|
55
|
+
*
|
|
56
|
+
* @param props - props from this instance of TagPickerButton
|
|
57
|
+
* @param ref - reference to root HTMLButtonElement of TagPickerButton
|
|
58
|
+
*/ export const useTagPickerButton_unstable = (props, ref)=>{
|
|
59
|
+
const baseState = useTagPickerButtonBase_unstable(props, ref);
|
|
60
|
+
const size = useTagPickerContext_unstable((ctx)=>ctx.size);
|
|
61
|
+
return {
|
|
62
|
+
...baseState,
|
|
63
|
+
size
|
|
64
|
+
};
|
|
55
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPickerButton/useTagPickerButton.tsx"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useActiveDescendantContext } from '@fluentui/react-aria';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPickerButton/useTagPickerButton.tsx"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport { useActiveDescendantContext } from '@fluentui/react-aria';\nimport type {\n TagPickerButtonBaseProps,\n TagPickerButtonBaseState,\n TagPickerButtonProps,\n TagPickerButtonState,\n} from './TagPickerButton.types';\nimport { useTagPickerContext_unstable } from '../../contexts/TagPickerContext';\nimport { useButtonTriggerSlot } from '@fluentui/react-combobox';\n\n/**\n * Create the base state required to render TagPickerButton, without design-only props.\n *\n * @param props - props from this instance of TagPickerButton (without size, appearance)\n * @param ref - reference to root HTMLButtonElement of TagPickerButton\n */\nexport const useTagPickerButtonBase_unstable = (\n props: TagPickerButtonBaseProps,\n ref: React.Ref<HTMLButtonElement>,\n): TagPickerButtonBaseState => {\n const { controller: activeDescendantController } = useActiveDescendantContext();\n const triggerRef = useTagPickerContext_unstable(ctx => ctx.triggerRef);\n const open = useTagPickerContext_unstable(ctx => ctx.open);\n const value = useTagPickerContext_unstable(ctx => ctx.value);\n const hasSelectedOption = useTagPickerContext_unstable(ctx => ctx.selectedOptions.length > 0);\n const popoverId = useTagPickerContext_unstable(ctx => ctx.popoverId);\n const getOptionById = useTagPickerContext_unstable(ctx => ctx.getOptionById);\n const selectOption = useTagPickerContext_unstable(ctx => ctx.selectOption);\n const setHasFocus = useTagPickerContext_unstable(ctx => ctx.setHasFocus);\n const setOpen = useTagPickerContext_unstable(ctx => ctx.setOpen);\n\n // casting is required here as triggerRef can either be button or input,\n // but in this case we can assure it's a button\n const root = useButtonTriggerSlot(props, triggerRef as React.RefObject<HTMLButtonElement>, {\n activeDescendantController,\n defaultProps: {\n type: 'button',\n tabIndex: 0,\n children:\n value ||\n // @ts-expect-error - FIXME: TS2339: Property 'placeholder' does not exist on type 'TagPickerButtonBaseProps'\n props.placeholder,\n 'aria-controls': open ? popoverId : undefined,\n ref,\n },\n state: {\n getOptionById,\n open,\n selectOption,\n setHasFocus,\n setOpen,\n multiselect: true,\n },\n });\n\n return {\n components: {\n root: 'button',\n },\n root,\n hasSelectedOption,\n };\n};\n\n/**\n * Create the state required to render TagPickerButton.\n *\n * The returned state can be modified with hooks such as useTagPickerButtonStyles_unstable,\n * before being passed to renderTagPickerButton_unstable.\n *\n * @param props - props from this instance of TagPickerButton\n * @param ref - reference to root HTMLButtonElement of TagPickerButton\n */\nexport const useTagPickerButton_unstable = (\n props: TagPickerButtonProps,\n ref: React.Ref<HTMLButtonElement>,\n): TagPickerButtonState => {\n const baseState = useTagPickerButtonBase_unstable(props, ref);\n const size = useTagPickerContext_unstable(ctx => ctx.size);\n\n return {\n ...baseState,\n size,\n };\n};\n"],"names":["useActiveDescendantContext","useTagPickerContext_unstable","useButtonTriggerSlot","useTagPickerButtonBase_unstable","props","ref","controller","activeDescendantController","triggerRef","ctx","open","value","hasSelectedOption","selectedOptions","length","popoverId","getOptionById","selectOption","setHasFocus","setOpen","root","defaultProps","type","tabIndex","children","placeholder","undefined","state","multiselect","components","useTagPickerButton_unstable","baseState","size"],"mappings":"AAAA;AAGA,SAASA,0BAA0B,QAAQ,uBAAuB;AAOlE,SAASC,4BAA4B,QAAQ,kCAAkC;AAC/E,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE;;;;;CAKC,GACD,OAAO,MAAMC,kCAAkC,CAC7CC,OACAC;IAEA,MAAM,EAAEC,YAAYC,0BAA0B,EAAE,GAAGP;IACnD,MAAMQ,aAAaP,6BAA6BQ,CAAAA,MAAOA,IAAID,UAAU;IACrE,MAAME,OAAOT,6BAA6BQ,CAAAA,MAAOA,IAAIC,IAAI;IACzD,MAAMC,QAAQV,6BAA6BQ,CAAAA,MAAOA,IAAIE,KAAK;IAC3D,MAAMC,oBAAoBX,6BAA6BQ,CAAAA,MAAOA,IAAII,eAAe,CAACC,MAAM,GAAG;IAC3F,MAAMC,YAAYd,6BAA6BQ,CAAAA,MAAOA,IAAIM,SAAS;IACnE,MAAMC,gBAAgBf,6BAA6BQ,CAAAA,MAAOA,IAAIO,aAAa;IAC3E,MAAMC,eAAehB,6BAA6BQ,CAAAA,MAAOA,IAAIQ,YAAY;IACzE,MAAMC,cAAcjB,6BAA6BQ,CAAAA,MAAOA,IAAIS,WAAW;IACvE,MAAMC,UAAUlB,6BAA6BQ,CAAAA,MAAOA,IAAIU,OAAO;IAE/D,wEAAwE;IACxE,+CAA+C;IAC/C,MAAMC,OAAOlB,qBAAqBE,OAAOI,YAAkD;QACzFD;QACAc,cAAc;YACZC,MAAM;YACNC,UAAU;YACVC,UACEb,SACA,6GAA6G;YAC7GP,MAAMqB,WAAW;YACnB,iBAAiBf,OAAOK,YAAYW;YACpCrB;QACF;QACAsB,OAAO;YACLX;YACAN;YACAO;YACAC;YACAC;YACAS,aAAa;QACf;IACF;IAEA,OAAO;QACLC,YAAY;YACVT,MAAM;QACR;QACAA;QACAR;IACF;AACF,EAAE;AAEF;;;;;;;;CAQC,GACD,OAAO,MAAMkB,8BAA8B,CACzC1B,OACAC;IAEA,MAAM0B,YAAY5B,gCAAgCC,OAAOC;IACzD,MAAM2B,OAAO/B,6BAA6BQ,CAAAA,MAAOA,IAAIuB,IAAI;IAEzD,OAAO;QACL,GAAGD,SAAS;QACZC;IACF;AACF,EAAE"}
|
|
@@ -252,8 +252,6 @@ const useStyles = /*#__PURE__*/__styles({
|
|
|
252
252
|
* Apply styling to the PickerButton slots based on the state
|
|
253
253
|
*/
|
|
254
254
|
export const useTagPickerButtonStyles_unstable = state => {
|
|
255
|
-
'use no memo';
|
|
256
|
-
|
|
257
255
|
const styles = useStyles();
|
|
258
256
|
// eslint-disable-next-line react-hooks/immutability
|
|
259
257
|
state.root.className = mergeClasses(tagPickerButtonClassNames.root, styles.button, styles[state.size], state.hasSelectedOption && styles.visuallyHidden, state.root.className);
|