@fluentui/react-tag-picker 9.7.16 → 9.8.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 +26 -2
- package/dist/index.d.ts +8 -2
- package/lib/components/TagPicker/TagPicker.types.js.map +1 -1
- package/lib/components/TagPicker/useTagPicker.js +2 -1
- package/lib/components/TagPicker/useTagPicker.js.map +1 -1
- package/lib/components/TagPickerList/TagPickerList.types.js.map +1 -1
- package/lib/components/TagPickerOptionGroup/useTagPickerOptionGroup.js +1 -0
- package/lib/components/TagPickerOptionGroup/useTagPickerOptionGroup.js.map +1 -1
- package/lib-commonjs/components/TagPicker/TagPicker.types.js.map +1 -1
- package/lib-commonjs/components/TagPicker/useTagPicker.js +2 -1
- package/lib-commonjs/components/TagPicker/useTagPicker.js.map +1 -1
- package/lib-commonjs/components/TagPickerList/TagPickerList.types.js.map +1 -1
- package/lib-commonjs/components/TagPickerOptionGroup/useTagPickerOptionGroup.js +1 -0
- package/lib-commonjs/components/TagPickerOptionGroup/useTagPickerOptionGroup.js.map +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-tag-picker
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Wed, 25 Feb 2026 13:28:21 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.8.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tag-picker_v9.8.0)
|
|
8
|
+
|
|
9
|
+
Wed, 25 Feb 2026 13:28:21 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tag-picker_v9.7.16..@fluentui/react-tag-picker_v9.8.0)
|
|
11
|
+
|
|
12
|
+
### Minor changes
|
|
13
|
+
|
|
14
|
+
- feat: add disableAutoFocus prop to TagPicker and deprecate on TagPickerList ([PR #35768](https://github.com/microsoft/fluentui/pull/35768) by bsunderhus@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-jsx-runtime to v9.4.1 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
16
|
+
- Bump @fluentui/react-shared-contexts to v9.26.2 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
17
|
+
- Bump @fluentui/react-utilities to v9.26.2 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
18
|
+
- Bump @fluentui/react-portal to v9.8.11 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
19
|
+
- Bump @fluentui/react-tabster to v9.26.13 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
20
|
+
- Bump @fluentui/react-aria to v9.17.10 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
21
|
+
- Bump @fluentui/react-combobox to v9.16.16 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
22
|
+
- Bump @fluentui/react-tags to v9.7.16 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
23
|
+
- Bump @fluentui/react-context-selector to v9.2.15 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
24
|
+
- Bump @fluentui/react-positioning to v9.21.0 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
25
|
+
- Bump @fluentui/react-field to v9.4.15 ([PR #35782](https://github.com/microsoft/fluentui/pull/35782) by beachball)
|
|
26
|
+
|
|
27
|
+
### Patches
|
|
28
|
+
|
|
29
|
+
- fix: add missing "use client" directive to client components and styles ([PR #35719](https://github.com/microsoft/fluentui/pull/35719) by dmytrokirpa@microsoft.com)
|
|
30
|
+
|
|
7
31
|
## [9.7.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-tag-picker_v9.7.16)
|
|
8
32
|
|
|
9
|
-
Thu, 12 Feb 2026 10:
|
|
33
|
+
Thu, 12 Feb 2026 10:46:15 GMT
|
|
10
34
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tag-picker_v9.7.15..@fluentui/react-tag-picker_v9.7.16)
|
|
11
35
|
|
|
12
36
|
### Patches
|
package/dist/index.d.ts
CHANGED
|
@@ -209,7 +209,13 @@ export declare const tagPickerListClassNames: SlotClassNames<TagPickerListSlots>
|
|
|
209
209
|
/**
|
|
210
210
|
* TagPickerList Props
|
|
211
211
|
*/
|
|
212
|
-
export declare type TagPickerListProps = ComponentProps<TagPickerListSlots
|
|
212
|
+
export declare type TagPickerListProps = ComponentProps<TagPickerListSlots> & {
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated TagPickerList is always rendered within a TagPicker which manages active descendant focus.
|
|
215
|
+
* This prop has no effect.
|
|
216
|
+
*/
|
|
217
|
+
disableAutoFocus?: boolean;
|
|
218
|
+
};
|
|
213
219
|
|
|
214
220
|
export declare type TagPickerListSlots = {
|
|
215
221
|
root: Slot<typeof Listbox>;
|
|
@@ -300,7 +306,7 @@ export declare type TagPickerOptionState = ComponentState<TagPickerOptionSlots>
|
|
|
300
306
|
/**
|
|
301
307
|
* Picker Props
|
|
302
308
|
*/
|
|
303
|
-
export declare type TagPickerProps = ComponentProps<TagPickerSlots> & Pick<ComboboxProps, 'positioning' | 'disabled' | 'defaultOpen' | 'selectedOptions' | 'defaultSelectedOptions' | 'open'> & Pick<Partial<TagPickerContextValue>, 'size' | 'appearance'> & {
|
|
309
|
+
export declare type TagPickerProps = ComponentProps<TagPickerSlots> & Pick<ComboboxProps, 'positioning' | 'disabled' | 'defaultOpen' | 'selectedOptions' | 'defaultSelectedOptions' | 'open' | 'disableAutoFocus'> & Pick<Partial<TagPickerContextValue>, 'size' | 'appearance'> & {
|
|
304
310
|
/**
|
|
305
311
|
* By default, when a single children is provided, the TagPicker will assume that the children
|
|
306
312
|
* is a popover. By setting this prop to true, the children will be treated as a trigger instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPicker/TagPicker.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, EventData, EventHandler, JSXElement } 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'
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPicker/TagPicker.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, EventData, EventHandler, JSXElement } 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"],"names":[],"mappings":"AAuGA,WAIE"}
|
|
@@ -25,7 +25,7 @@ const fallbackPositions = [
|
|
|
25
25
|
const triggerInnerRef = React.useRef(null);
|
|
26
26
|
const secondaryActionRef = React.useRef(null);
|
|
27
27
|
const tagPickerGroupRef = React.useRef(null);
|
|
28
|
-
const { positioning, size = 'medium', inline = false, noPopover = false } = props;
|
|
28
|
+
const { positioning, size = 'medium', inline = false, noPopover = false, disableAutoFocus } = props;
|
|
29
29
|
const { targetRef, containerRef } = usePositioning({
|
|
30
30
|
position: 'below',
|
|
31
31
|
align: 'start',
|
|
@@ -60,6 +60,7 @@ const fallbackPositions = [
|
|
|
60
60
|
});
|
|
61
61
|
}),
|
|
62
62
|
activeDescendantController,
|
|
63
|
+
disableAutoFocus,
|
|
63
64
|
editable: true,
|
|
64
65
|
multiselect: true,
|
|
65
66
|
size: 'medium'
|
|
@@ -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 { PositioningShorthandValue, 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 } = 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 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","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,gBAAgB,QAAQ,2BAA2B;AAC5D,SAAoCC,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AACrH,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,wFAAwF;AACxF,MAAMC,oBAAiD;IAAC;IAAS;IAAS;IAAa;IAAU;CAAa;AAE9G;;;;;;;CAOC,GACD,OAAO,MAAMC,wBAAwB,CAACC;IACpC,MAAMC,YAAYV,MAAM;IACxB,MAAMW,kBAAkBd,MAAMe,MAAM,CAAuC;IAC3E,MAAMC,qBAAqBhB,MAAMe,MAAM,CAAkB;IACzD,MAAME,oBAAoBjB,MAAMe,MAAM,CAAiB;IACvD,MAAM,EAAEG,WAAW,EAAEC,OAAO,QAAQ,EAAEC,SAAS,KAAK,EAAEC,YAAY,KAAK,EAAE,
|
|
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 { PositioningShorthandValue, 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,gBAAgB,QAAQ,2BAA2B;AAC5D,SAAoCC,2BAA2B,EAAEC,cAAc,QAAQ,8BAA8B;AACrH,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE,wFAAwF;AACxF,MAAMC,oBAAiD;IAAC;IAAS;IAAS;IAAa;IAAU;CAAa;AAE9G;;;;;;;CAOC,GACD,OAAO,MAAMC,wBAAwB,CAACC;IACpC,MAAMC,YAAYV,MAAM;IACxB,MAAMW,kBAAkBd,MAAMe,MAAM,CAAuC;IAC3E,MAAMC,qBAAqBhB,MAAMe,MAAM,CAAkB;IACzD,MAAME,oBAAoBjB,MAAMe,MAAM,CAAiB;IACvD,MAAM,EAAEG,WAAW,EAAEC,OAAO,QAAQ,EAAEC,SAAS,KAAK,EAAEC,YAAY,KAAK,EAAEC,gBAAgB,EAAE,GAAGV;IAE9F,MAAM,EAAEW,SAAS,EAAEC,YAAY,EAAE,GAAGjB,eAAe;QACjDkB,UAAU;QACVC,OAAO;QACPC,QAAQ;YAAEC,WAAW;YAAGC,UAAU;QAAE;QACpC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C,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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPickerList/TagPickerList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { Listbox } from '@fluentui/react-combobox';\nimport { TagPickerContextValue } from '../../contexts/TagPickerContext';\n\nexport type TagPickerListSlots = {\n root: Slot<typeof Listbox>;\n};\n\n/**\n * TagPickerList Props\n */\nexport type TagPickerListProps = ComponentProps<TagPickerListSlots
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPickerList/TagPickerList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { Listbox } from '@fluentui/react-combobox';\nimport { TagPickerContextValue } from '../../contexts/TagPickerContext';\n\nexport type TagPickerListSlots = {\n root: Slot<typeof Listbox>;\n};\n\n/**\n * TagPickerList Props\n */\nexport type TagPickerListProps = ComponentProps<TagPickerListSlots> & {\n /**\n * @deprecated TagPickerList is always rendered within a TagPicker which manages active descendant focus.\n * This prop has no effect.\n */\n disableAutoFocus?: boolean;\n};\n\n/**\n * State used in rendering TagPickerList\n */\nexport type TagPickerListState = ComponentState<TagPickerListSlots> & Pick<TagPickerContextValue, 'open'>;\n"],"names":[],"mappings":"AAmBA;;CAEC,GACD,WAA0G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPickerOptionGroup/useTagPickerOptionGroup.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPickerOptionGroup/useTagPickerOptionGroup.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { TagPickerOptionGroupProps, TagPickerOptionGroupState } from './TagPickerOptionGroup.types';\nimport { useOptionGroup_unstable } from '@fluentui/react-combobox';\n\n/**\n * Create the state required to render TagPickerOptionGroup.\n *\n * The returned state can be modified with hooks such as useTagPickerOptionGroupStyles_unstable,\n * before being passed to renderTagPickerOptionGroup_unstable.\n *\n * @param props - props from this instance of TagPickerOptionGroup\n * @param ref - reference to root HTMLDivElement of TagPickerOptionGroup\n */\nexport const useTagPickerOptionGroup: (\n props: TagPickerOptionGroupProps,\n ref: React.Ref<HTMLDivElement>,\n) => TagPickerOptionGroupState = useOptionGroup_unstable;\n"],"names":["React","useOptionGroup_unstable","useTagPickerOptionGroup"],"mappings":"AAAA;AAEA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,uBAAuB,QAAQ,2BAA2B;AAEnE;;;;;;;;CAQC,GACD,OAAO,MAAMC,0BAGoBD,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPicker/TagPicker.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, EventData, EventHandler, JSXElement } 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'
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPicker/TagPicker.types.ts"],"sourcesContent":["import type * as React from 'react';\nimport type { ComponentProps, ComponentState, EventData, EventHandler, JSXElement } 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"],"names":[],"mappings":""}
|
|
@@ -28,7 +28,7 @@ const useTagPicker_unstable = (props)=>{
|
|
|
28
28
|
const triggerInnerRef = _react.useRef(null);
|
|
29
29
|
const secondaryActionRef = _react.useRef(null);
|
|
30
30
|
const tagPickerGroupRef = _react.useRef(null);
|
|
31
|
-
const { positioning, size = 'medium', inline = false, noPopover = false } = props;
|
|
31
|
+
const { positioning, size = 'medium', inline = false, noPopover = false, disableAutoFocus } = props;
|
|
32
32
|
const { targetRef, containerRef } = (0, _reactpositioning.usePositioning)({
|
|
33
33
|
position: 'below',
|
|
34
34
|
align: 'start',
|
|
@@ -63,6 +63,7 @@ const useTagPicker_unstable = (props)=>{
|
|
|
63
63
|
});
|
|
64
64
|
}),
|
|
65
65
|
activeDescendantController,
|
|
66
|
+
disableAutoFocus,
|
|
66
67
|
editable: true,
|
|
67
68
|
multiselect: true,
|
|
68
69
|
size: 'medium'
|
|
@@ -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 { PositioningShorthandValue, 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 } = 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 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","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;;;;;+BA0BaW;;;;;;;iEAxBU,QAAQ;gCACyC,4BAA4B;+BAOnE,2BAA2B;kCAC2B,8BAA8B;2BACjF,uBAAuB;AAG3D,wFAAwF;AACxF,MAAMD,oBAAiD;IAAC;IAAS;IAAS;IAAa;IAAU;CAAa;AAUvG,8BAA8B,CAACE;IACpC,MAAMC,gBAAYV,qBAAAA,EAAM;IACxB,MAAMW,kBAAkBd,OAAMe,MAAM,CAAuC;IAC3E,MAAMC,qBAAqBhB,OAAMe,MAAM,CAAkB;IACzD,MAAME,oBAAoBjB,OAAMe,MAAM,CAAiB;IACvD,MAAM,EAAEG,WAAW,EAAEC,OAAO,QAAQ,EAAEC,SAAS,KAAK,EAAEC,YAAY,KAAK,EAAE,
|
|
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 { PositioningShorthandValue, 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;;;;;+BA0BaW;;;;;;;iEAxBU,QAAQ;gCACyC,4BAA4B;+BAOnE,2BAA2B;kCAC2B,8BAA8B;2BACjF,uBAAuB;AAG3D,wFAAwF;AACxF,MAAMD,oBAAiD;IAAC;IAAS;IAAS;IAAa;IAAU;CAAa;AAUvG,8BAA8B,CAACE;IACpC,MAAMC,gBAAYV,qBAAAA,EAAM;IACxB,MAAMW,kBAAkBd,OAAMe,MAAM,CAAuC;IAC3E,MAAMC,qBAAqBhB,OAAMe,MAAM,CAAkB;IACzD,MAAME,oBAAoBjB,O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SAASxB,cAAcwB,OAAO;QAC9BW,UAAUnC,cAAcmC,QAAQ;QAChC9B,OAAOL,cAAcK,KAAK;IAC5B;AACF,EAAE;AAEF,MAAMQ,8BAA8B,CAACC,UAA2BjC;IAC9D,MAAMuD,gBAAgB5E,OAAM6E,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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPickerList/TagPickerList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { Listbox } from '@fluentui/react-combobox';\nimport { TagPickerContextValue } from '../../contexts/TagPickerContext';\n\nexport type TagPickerListSlots = {\n root: Slot<typeof Listbox>;\n};\n\n/**\n * TagPickerList Props\n */\nexport type TagPickerListProps = ComponentProps<TagPickerListSlots
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPickerList/TagPickerList.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport type { Listbox } from '@fluentui/react-combobox';\nimport { TagPickerContextValue } from '../../contexts/TagPickerContext';\n\nexport type TagPickerListSlots = {\n root: Slot<typeof Listbox>;\n};\n\n/**\n * TagPickerList Props\n */\nexport type TagPickerListProps = ComponentProps<TagPickerListSlots> & {\n /**\n * @deprecated TagPickerList is always rendered within a TagPicker which manages active descendant focus.\n * This prop has no effect.\n */\n disableAutoFocus?: boolean;\n};\n\n/**\n * State used in rendering TagPickerList\n */\nexport type TagPickerListState = ComponentState<TagPickerListSlots> & Pick<TagPickerContextValue, 'open'>;\n"],"names":[],"mappings":"AAmBA;;CAEC,GACD,WAA0G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/TagPickerOptionGroup/useTagPickerOptionGroup.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/components/TagPickerOptionGroup/useTagPickerOptionGroup.ts"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { TagPickerOptionGroupProps, TagPickerOptionGroupState } from './TagPickerOptionGroup.types';\nimport { useOptionGroup_unstable } from '@fluentui/react-combobox';\n\n/**\n * Create the state required to render TagPickerOptionGroup.\n *\n * The returned state can be modified with hooks such as useTagPickerOptionGroupStyles_unstable,\n * before being passed to renderTagPickerOptionGroup_unstable.\n *\n * @param props - props from this instance of TagPickerOptionGroup\n * @param ref - reference to root HTMLDivElement of TagPickerOptionGroup\n */\nexport const useTagPickerOptionGroup: (\n props: TagPickerOptionGroupProps,\n ref: React.Ref<HTMLDivElement>,\n) => TagPickerOptionGroupState = useOptionGroup_unstable;\n"],"names":["React","useOptionGroup_unstable","useTagPickerOptionGroup"],"mappings":"AAAA;;;;;;;;;;;;iEAEuB,QAAQ;+BAES,2BAA2B;AAW5D,MAAME,0BAGoBD,sCAAAA,CAAwB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-tag-picker",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"description": "FluentUI TagPicker component",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@fluentui/react-jsx-runtime": "^9.4.
|
|
22
|
-
"@fluentui/react-shared-contexts": "^9.26.
|
|
21
|
+
"@fluentui/react-jsx-runtime": "^9.4.1",
|
|
22
|
+
"@fluentui/react-shared-contexts": "^9.26.2",
|
|
23
23
|
"@fluentui/react-theme": "^9.2.1",
|
|
24
|
-
"@fluentui/react-utilities": "^9.26.
|
|
25
|
-
"@fluentui/react-portal": "^9.8.
|
|
26
|
-
"@fluentui/react-tabster": "^9.26.
|
|
27
|
-
"@fluentui/react-aria": "^9.17.
|
|
24
|
+
"@fluentui/react-utilities": "^9.26.2",
|
|
25
|
+
"@fluentui/react-portal": "^9.8.11",
|
|
26
|
+
"@fluentui/react-tabster": "^9.26.13",
|
|
27
|
+
"@fluentui/react-aria": "^9.17.10",
|
|
28
28
|
"@fluentui/react-icons": "^2.0.245",
|
|
29
|
-
"@fluentui/react-combobox": "^9.16.
|
|
30
|
-
"@fluentui/react-tags": "^9.7.
|
|
31
|
-
"@fluentui/react-context-selector": "^9.2.
|
|
32
|
-
"@fluentui/react-positioning": "^9.
|
|
29
|
+
"@fluentui/react-combobox": "^9.16.16",
|
|
30
|
+
"@fluentui/react-tags": "^9.7.16",
|
|
31
|
+
"@fluentui/react-context-selector": "^9.2.15",
|
|
32
|
+
"@fluentui/react-positioning": "^9.21.0",
|
|
33
33
|
"@fluentui/keyboard-keys": "^9.0.8",
|
|
34
|
-
"@fluentui/react-field": "^9.4.
|
|
34
|
+
"@fluentui/react-field": "^9.4.15",
|
|
35
35
|
"@griffel/react": "^1.5.32",
|
|
36
36
|
"@swc/helpers": "^0.5.1"
|
|
37
37
|
},
|