Skip to content

Commit 72c9309

Browse files
mainframevCopilot
andcommitted
feat(react-tag-picker): export useTagPickerContextValues and TagPickerControlInternalSlots
Expose the existing context-values hook and the control's internal slots type so the headless TagPicker (and other consumers) can reuse them instead of duplicating the logic/type. No rename — exported as-is. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6bc2c66 commit 72c9309

7 files changed

Lines changed: 48 additions & 11 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "feat: export useTagPickerContextValues and TagPickerControlInternalSlots for headless composition",
4+
"packageName": "@fluentui/react-tag-picker",
5+
"email": "vgenaev@gmail.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-tag-picker/library/etc/react-tag-picker.api.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ export const renderTagPickerOptionGroup: (state: TagPickerOptionGroupState) => J
6161
export const TagPicker: React_2.FC<TagPickerProps>;
6262

6363
// @public
64-
export type TagPickerBaseProps = DistributiveOmit<TagPickerProps, 'positioning'>;
64+
export type TagPickerBaseProps = DistributiveOmit<TagPickerProps, 'positioning' | 'size' | 'appearance' | 'inline'>;
65+
66+
// @public
67+
export type TagPickerBaseState = Omit<TagPickerState, 'size' | 'appearance' | 'inline'>;
6568

6669
// @public
6770
export const TagPickerButton: ForwardRefComponent<TagPickerButtonProps>;
@@ -129,6 +132,11 @@ export type TagPickerControlBaseState = DistributiveOmit<TagPickerControlState,
129132
// @public (undocumented)
130133
export const tagPickerControlClassNames: SlotClassNames<TagPickerControlSlots & TagPickerControlInternalSlots>;
131134

135+
// @public (undocumented)
136+
export type TagPickerControlInternalSlots = {
137+
aside?: NonNullable<Slot<'span'>>;
138+
};
139+
132140
// @public
133141
export type TagPickerControlProps = ComponentProps<Partial<TagPickerControlSlots>>;
134142

@@ -285,7 +293,7 @@ export type TagPickerState = ComponentState<TagPickerSlots> & Pick<ComboboxState
285293
export const useTagPicker_unstable: (props: TagPickerProps) => TagPickerState;
286294

287295
// @public
288-
export const useTagPickerBase_unstable: (props: TagPickerBaseProps) => TagPickerState;
296+
export const useTagPickerBase_unstable: (props: TagPickerBaseProps) => TagPickerBaseState;
289297

290298
// @public
291299
export const useTagPickerButton_unstable: (props: TagPickerButtonProps, ref: React_2.Ref<HTMLButtonElement>) => TagPickerButtonState;
@@ -299,6 +307,9 @@ export const useTagPickerButtonStyles_unstable: (state: TagPickerButtonState) =>
299307
// @public (undocumented)
300308
export const useTagPickerContext_unstable: <T>(selector: ContextSelector<TagPickerContextValue, T>) => T;
301309

310+
// @public (undocumented)
311+
export function useTagPickerContextValues(state: TagPickerState): TagPickerContextValues;
312+
302313
// @public
303314
export const useTagPickerControl_unstable: (props: TagPickerControlProps, ref: React_2.Ref<HTMLDivElement>) => TagPickerControlState;
304315

packages/react-components/react-tag-picker/library/src/TagPicker.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type {
22
TagPickerBaseProps,
3+
TagPickerBaseState,
34
TagPickerContextValues,
45
TagPickerOnOpenChangeData,
56
TagPickerOnOptionSelectData,
@@ -13,4 +14,5 @@ export {
1314
renderTagPicker_unstable,
1415
useTagPicker_unstable,
1516
useTagPickerBase_unstable,
17+
useTagPickerContextValues,
1618
} from './components/TagPicker/index';

packages/react-components/react-tag-picker/library/src/components/TagPicker/TagPicker.types.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,11 @@ export type TagPickerContextValues = {
118118
* TagPicker Base Props - omits the floating-ui `positioning` prop; the styled wrapper
119119
* {@link TagPickerProps} re-introduces it via `usePositioning`.
120120
*/
121-
export type TagPickerBaseProps = DistributiveOmit<TagPickerProps, 'positioning'>;
121+
export type TagPickerBaseProps = DistributiveOmit<TagPickerProps, 'positioning' | 'size' | 'appearance' | 'inline'>;
122+
123+
/**
124+
* TagPicker Base State - the state produced by the base hook, which does not interact with the
125+
* `size`, `appearance` and `inline` props. These are layered on by the styled
126+
* {@link useTagPicker_unstable} hook.
127+
*/
128+
export type TagPickerBaseState = Omit<TagPickerState, 'size' | 'appearance' | 'inline'>;

packages/react-components/react-tag-picker/library/src/components/TagPicker/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export { TagPicker } from './TagPicker';
22
export type {
33
TagPickerBaseProps,
4+
TagPickerBaseState,
45
TagPickerContextValues,
56
TagPickerOnOpenChangeData,
67
TagPickerOnOptionSelectData,
@@ -11,3 +12,4 @@ export type {
1112
} from './TagPicker.types';
1213
export { renderTagPicker_unstable } from './renderTagPicker';
1314
export { useTagPicker_unstable, useTagPickerBase_unstable } from './useTagPicker';
15+
export { useTagPickerContextValues } from './useTagPickerContextValues';

packages/react-components/react-tag-picker/library/src/components/TagPicker/useTagPicker.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as React from 'react';
44
import { elementContains, useEventCallback, useId, useMergedRefs } from '@fluentui/react-utilities';
55
import type {
66
TagPickerBaseProps,
7+
TagPickerBaseState,
78
TagPickerOnOpenChangeData,
89
TagPickerOnOptionSelectData,
910
TagPickerProps,
@@ -22,13 +23,13 @@ const fallbackPositions: PositioningShorthandValue[] = ['above', 'after', 'after
2223
* Create the base state required to render TagPicker, without floating-ui positioning.
2324
* @param props - props from this instance of TagPicker (without `positioning`)
2425
*/
25-
export const useTagPickerBase_unstable = (props: TagPickerBaseProps): TagPickerState => {
26+
export const useTagPickerBase_unstable = (props: TagPickerBaseProps): TagPickerBaseState => {
2627
const popoverId = useId('picker-listbox');
2728
const triggerInnerRef = React.useRef<HTMLInputElement | HTMLButtonElement>(null);
2829
const secondaryActionRef = React.useRef<HTMLSpanElement>(null);
2930
const tagPickerGroupRef = React.useRef<HTMLDivElement>(null);
3031
const passiveTargetRef = React.useRef<HTMLDivElement>(null);
31-
const { size = 'medium', inline = false, noPopover = false, disableAutoFocus } = props;
32+
const { noPopover = false, disableAutoFocus } = props;
3233

3334
const {
3435
controller: activeDescendantController,
@@ -59,7 +60,6 @@ export const useTagPickerBase_unstable = (props: TagPickerBaseProps): TagPickerS
5960
disableAutoFocus,
6061
editable: true,
6162
multiselect: true,
62-
size: 'medium',
6363
});
6464

6565
const { trigger, popover } = childrenToTriggerAndPopover(props.children, noPopover);
@@ -76,15 +76,12 @@ export const useTagPickerBase_unstable = (props: TagPickerBaseProps): TagPickerS
7676
secondaryActionRef,
7777
tagPickerGroupRef,
7878
targetRef: passiveTargetRef,
79-
size,
80-
inline,
8179
open: comboboxState.open,
8280
mountNode: comboboxState.mountNode,
8381
onOptionClick: useEventCallback(event => {
8482
comboboxState.onOptionClick(event);
8583
comboboxState.setOpen(event, false);
8684
}),
87-
appearance: comboboxState.appearance,
8885
clearSelection: comboboxState.clearSelection,
8986
getOptionById: comboboxState.getOptionById,
9087
getOptionsMatchingValue: comboboxState.getOptionsMatchingValue,
@@ -123,7 +120,7 @@ export const useTagPickerBase_unstable = (props: TagPickerBaseProps): TagPickerS
123120
* @param props - props from this instance of Picker
124121
*/
125122
export const useTagPicker_unstable = (props: TagPickerProps): TagPickerState => {
126-
const { positioning } = props;
123+
const { positioning, size = 'medium', appearance = 'outline', inline = false } = props;
127124

128125
const { targetRef, containerRef } = usePositioning({
129126
position: 'below' as const,
@@ -138,6 +135,9 @@ export const useTagPicker_unstable = (props: TagPickerProps): TagPickerState =>
138135

139136
return {
140137
...baseState,
138+
size,
139+
appearance,
140+
inline,
141141
targetRef,
142142
popoverRef: useMergedRefs(baseState.popoverRef, containerRef),
143143
};

packages/react-components/react-tag-picker/library/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
export { TagPicker, renderTagPicker_unstable, useTagPicker_unstable, useTagPickerBase_unstable } from './TagPicker';
1+
export {
2+
TagPicker,
3+
renderTagPicker_unstable,
4+
useTagPicker_unstable,
5+
useTagPickerBase_unstable,
6+
useTagPickerContextValues,
7+
} from './TagPicker';
28
export type {
39
TagPickerBaseProps,
10+
TagPickerBaseState,
411
TagPickerContextValues,
512
TagPickerProps,
613
TagPickerSlots,
@@ -57,6 +64,7 @@ export {
5764
} from './TagPickerControl';
5865
export type {
5966
TagPickerControlBaseState,
67+
TagPickerControlInternalSlots,
6068
TagPickerControlProps,
6169
TagPickerControlSlots,
6270
TagPickerControlState,

0 commit comments

Comments
 (0)