@mortenbrudvik/waveui 0.11.0 → 0.12.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.
Files changed (116) hide show
  1. package/README.md +97 -2
  2. package/dist/components/button/Link.cjs +1 -1
  3. package/dist/components/button/Link.cjs.map +1 -1
  4. package/dist/components/button/Link.mjs +4 -4
  5. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  6. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  7. package/dist/components/data-display/AvatarGroup.mjs +10 -10
  8. package/dist/components/data-display/InfoButton.cjs +1 -1
  9. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  10. package/dist/components/data-display/InfoButton.mjs +12 -12
  11. package/dist/components/feedback/Toaster.cjs +1 -1
  12. package/dist/components/feedback/Toaster.cjs.map +1 -1
  13. package/dist/components/feedback/Toaster.mjs +235 -235
  14. package/dist/components/feedback/Toaster.mjs.map +1 -1
  15. package/dist/components/input/Combobox.cjs +1 -1
  16. package/dist/components/input/Combobox.cjs.map +1 -1
  17. package/dist/components/input/Combobox.mjs +176 -175
  18. package/dist/components/input/Combobox.mjs.map +1 -1
  19. package/dist/components/input/DatePicker.cjs +1 -1
  20. package/dist/components/input/DatePicker.cjs.map +1 -1
  21. package/dist/components/input/DatePicker.mjs +188 -187
  22. package/dist/components/input/DatePicker.mjs.map +1 -1
  23. package/dist/components/input/Dropdown.cjs +1 -1
  24. package/dist/components/input/Dropdown.cjs.map +1 -1
  25. package/dist/components/input/Dropdown.mjs +41 -40
  26. package/dist/components/input/Dropdown.mjs.map +1 -1
  27. package/dist/components/input/Option.cjs +1 -1
  28. package/dist/components/input/Option.cjs.map +1 -1
  29. package/dist/components/input/Option.mjs +89 -87
  30. package/dist/components/input/Option.mjs.map +1 -1
  31. package/dist/components/input/TagPicker.root.cjs +1 -1
  32. package/dist/components/input/TagPicker.root.cjs.map +1 -1
  33. package/dist/components/input/TagPicker.root.mjs +136 -135
  34. package/dist/components/input/TagPicker.root.mjs.map +1 -1
  35. package/dist/components/input/TimePicker.cjs +1 -1
  36. package/dist/components/input/TimePicker.cjs.map +1 -1
  37. package/dist/components/input/TimePicker.mjs +156 -154
  38. package/dist/components/input/TimePicker.mjs.map +1 -1
  39. package/dist/components/navigation/Menu.popover.cjs +1 -1
  40. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  41. package/dist/components/navigation/Menu.popover.mjs +137 -127
  42. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  43. package/dist/components/navigation/Menu.root.cjs +1 -1
  44. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  45. package/dist/components/navigation/Menu.root.mjs +4 -4
  46. package/dist/components/overlays/Dialog.cjs +1 -1
  47. package/dist/components/overlays/Dialog.cjs.map +1 -1
  48. package/dist/components/overlays/Dialog.mjs +123 -123
  49. package/dist/components/overlays/Dialog.mjs.map +1 -1
  50. package/dist/components/overlays/Drawer.panel.cjs +1 -1
  51. package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
  52. package/dist/components/overlays/Drawer.panel.mjs +12 -12
  53. package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
  54. package/dist/components/overlays/Popover.cjs +1 -1
  55. package/dist/components/overlays/Popover.cjs.map +1 -1
  56. package/dist/components/overlays/Popover.mjs +173 -162
  57. package/dist/components/overlays/Popover.mjs.map +1 -1
  58. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  59. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  60. package/dist/components/overlays/TeachingPopover.mjs +96 -91
  61. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  62. package/dist/components/overlays/Tooltip.cjs +1 -1
  63. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  64. package/dist/components/overlays/Tooltip.mjs +47 -47
  65. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  66. package/dist/components/portal/Portal.cjs +1 -1
  67. package/dist/components/portal/Portal.cjs.map +1 -1
  68. package/dist/components/portal/Portal.mjs +5 -5
  69. package/dist/components/table/DataGrid.cjs +1 -1
  70. package/dist/components/table/DataGrid.cjs.map +1 -1
  71. package/dist/components/table/DataGrid.mjs +1 -1
  72. package/dist/hooks/useDismiss.cjs.map +1 -1
  73. package/dist/hooks/useDismiss.mjs.map +1 -1
  74. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  75. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  76. package/dist/hooks/useFocusVisible.cjs +2 -0
  77. package/dist/hooks/useFocusVisible.cjs.map +1 -0
  78. package/dist/hooks/useFocusVisible.mjs +49 -0
  79. package/dist/hooks/useFocusVisible.mjs.map +1 -0
  80. package/dist/hooks/useFocusableGroup.cjs +2 -0
  81. package/dist/hooks/useFocusableGroup.cjs.map +1 -0
  82. package/dist/hooks/useFocusableGroup.mjs +70 -0
  83. package/dist/hooks/useFocusableGroup.mjs.map +1 -0
  84. package/dist/hooks/useModalLayer.cjs +1 -1
  85. package/dist/hooks/useModalLayer.cjs.map +1 -1
  86. package/dist/hooks/useModalLayer.mjs +4 -4
  87. package/dist/hooks/useModalOpen.cjs +2 -0
  88. package/dist/hooks/useModalOpen.cjs.map +1 -0
  89. package/dist/hooks/useModalOpen.mjs +14 -0
  90. package/dist/hooks/useModalOpen.mjs.map +1 -0
  91. package/dist/hooks/usePopupPosition.cjs +1 -1
  92. package/dist/hooks/usePopupPosition.cjs.map +1 -1
  93. package/dist/hooks/usePopupPosition.mjs +82 -53
  94. package/dist/hooks/usePopupPosition.mjs.map +1 -1
  95. package/dist/hooks/useResolvedTarget.cjs +2 -0
  96. package/dist/hooks/useResolvedTarget.cjs.map +1 -0
  97. package/dist/hooks/useResolvedTarget.mjs +37 -0
  98. package/dist/hooks/useResolvedTarget.mjs.map +1 -0
  99. package/dist/hooks/useRovingGrid.cjs +1 -1
  100. package/dist/hooks/useRovingGrid.cjs.map +1 -1
  101. package/dist/hooks/useRovingGrid.mjs +8 -57
  102. package/dist/hooks/useRovingGrid.mjs.map +1 -1
  103. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  104. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  105. package/dist/hooks/useRovingTabIndex.mjs +142 -107
  106. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  107. package/dist/index.cjs +1 -1
  108. package/dist/index.d.cts +814 -18
  109. package/dist/index.d.ts +814 -18
  110. package/dist/index.mjs +120 -108
  111. package/dist/lib/layers.cjs +1 -1
  112. package/dist/lib/layers.cjs.map +1 -1
  113. package/dist/lib/layers.mjs +112 -109
  114. package/dist/lib/layers.mjs.map +1 -1
  115. package/dist/styles.css +1 -1
  116. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Option.mjs","names":["useId","_Fragment","useId$1","React","OptionCheckContext","OPTION_CLASSES","cn","OptionGroupMembers","listener","value","count","store","OptionGroupContext","OptionGroupHiddenContext","useOptionGroupMembership","groups","removes","group","remove","DISABLED_BOX_FORCED_COLORS","DISABLED_GLYPH_FORCED_COLORS","renderCheck","multiselect","classes","optionClassNames","selected","glyph","CheckIcon","renderSlot","boxClasses","disabled","forcedColors","glyphClasses","OptionImpl","rest","props","showCheck","groupHidden","useListboxOption","hidden","ref","optionRef","selectOption","pressOption","highlightOption","optionAttributes","optionProps","checkIconRenders","checkIcon","slotRendersContent","checkIconEmpty","warnOnce","composeEventHandlers","onClick","onMouseDown","onPointerMove","className","children","MemoOption","Option","ELEMENT_NODE","TEXT_NODE","nameText","node","element","ownLabel","text","child","groupHasName","labelledBy","labelId","ariaLabel","label","heading","UNNAMED_GROUP_WARNING","OptionGroupImpl","ariaLabelledBy","ListboxContext","parentGroups","hiddenByConsumer","members","subscribe","unsubscribeMembers","unsubscribeStore","empty","hasLabel","headingRef","isDev","optionGroupClassNames","materialiseSlotContent","OptionGroup","ListboxProvider","useListboxPopup","options","surfaceElementRef","usePopupPosition","surfaceOpen","useDismiss","onDismiss","reason","rootRef","useMergedRefs","setFloating","preventMouseDown","ListboxSurface","listRefProp","listMouseDown","listRest","listProps","listboxProps","listbox","listRef","list","expanded","listboxSurfaceClassNames","listClassName","emptyContent","Fragment","Portal","surfaceRef","floatingProps","surfaceClassName"],"sources":["../../../src/components/input/Option.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n listboxSurfaceClassNames,\n optionClassNames,\n optionGroupClassNames,\n} from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { hasWarned, isDev, warnOnce } from '../../lib/dev';\nimport { CheckIcon } from '../../lib/icons';\nimport { materialiseSlotContent, renderSlot, slotRendersContent, type Slot } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport type { DismissReason } from '../../hooks/useDismiss';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport {\n ListboxContext,\n markListboxElement,\n useListboxOption,\n type ListboxContextValue,\n type ListboxStore,\n type UseListboxResult,\n} from '../../hooks/useListbox';\nimport { Portal } from '../portal/Portal';\n\n/* ------------------------------------------------------------------ */\n/* Option */\n/* ------------------------------------------------------------------ */\n\n/**\n * Props of {@link Option}, an option of a listbox (Listbox, Combobox, Dropdown or a custom\n * picker's list).\n */\nexport interface OptionProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'value'> {\n /** Value associated with this option. Unique within its listbox. */\n value: string;\n /**\n * Text shown in the combobox (Combobox input, Dropdown trigger) when this option is selected.\n * Defaults to `textValue`, then the option's text content, then `value`. Pass it when the\n * children are not plain text (icons, custom components).\n */\n label?: string;\n /** Text matched by typeahead and filtering instead of the label. */\n textValue?: string;\n /**\n * Whether the option is disabled: it stays in the list but can never be selected (a click, Enter\n * and Space do nothing). Keyboard navigation and typeahead skip it, unless the listbox keeps\n * disabled options focusable (`disabledOptionsFocusable`), where they reach it. It is drawn in\n * the muted text colour, its check included: in a multi-select list the checkbox square takes\n * that colour instead of the brand colour, checked or not.\n * @default false\n */\n disabled?: boolean;\n /**\n * Replaces the check glyph that marks the option while it is selected (decorative,\n * `aria-hidden`); in a multi-select list the glyph is drawn inside the option's 16px checkbox\n * square. The check is a required indicator, the sign of the selection that does not rely on\n * colour: `null` and `undefined` keep the default glyph, and so does a value that renders\n * nothing (`false`, `''`, an empty array), which also logs a development warning. Unlike\n * `Combobox.expandIcon`, a value that renders nothing does not hide the indicator (Fluent's\n * `checkIcon={null}` removes it).\n * @default a check mark\n */\n checkIcon?: Slot<'span'>;\n /**\n * Hides the option, like a native `<option hidden>`: it is not shown, keyboard navigation and\n * typeahead skip it, and it never becomes the active option. Its label stays known, so a\n * selected hidden option (a placeholder) still shows in the combobox. The options of a hidden\n * `OptionGroup` are hidden the same way.\n * @default false\n */\n hidden?: boolean;\n /** Ref to the option `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/** Whether options draw the selected check mark (P05-internal; TagPicker lists no selected options). */\nconst OptionCheckContext = React.createContext(true);\nOptionCheckContext.displayName = 'OptionCheckContext';\n\n/*\n * State is exposed as data attributes (C-CLASS): `data-active` (keyboard/pointer highlight),\n * `data-selected`, `data-disabled`. State classes come before the consumer's `className` in `cn()`.\n *\n * Backgrounds (input-pickers#20): one unconditional `bg-(--option-bg)` paints the option, and the\n * hover/selected/active variants only set `--option-bg`. A variant that set `background-color`\n * itself (class + attribute or pseudo-class) would out-specify a consumer's plain `bg-*` class in\n * the cascade even though `cn()` keeps it; instead tailwind-merge replaces `bg-(--option-bg)` with\n * the consumer's class, which is then the only background declaration on the option. A consumer\n * `data-[active]:bg-…` / `data-[selected]:bg-…` restyles a single state (it out-specifies the\n * unconditional reader). The active outline is the focus indicator and stays a state variant.\n *\n * A filtered-out option carries the `hidden` attribute; base.css's scoped `[hidden]` rule hides\n * it over `flex` and over a consumer's display class.\n */\nconst OPTION_CLASSES = cn(\n 'flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground',\n 'bg-(--option-bg) [--option-bg:transparent]',\n 'not-disabled:not-aria-disabled:hover:[--option-bg:var(--wave-subtle-hover)]',\n 'data-[selected]:[--option-bg:var(--wave-subtle-selected)]',\n 'data-[active]:[--option-bg:var(--wave-subtle-hover)]',\n 'data-[active]:outline-2 data-[active]:-outline-offset-2 data-[active]:outline-ring',\n 'aria-disabled:cursor-not-allowed aria-disabled:text-muted-foreground',\n);\n\n/**\n * The values of the options rendered inside an `OptionGroup`, whatever wraps them (custom\n * components, Fragments, nested groups): each option adds its value from a layout effect.\n */\nclass OptionGroupMembers {\n private readonly counts = new Map<string, number>();\n private readonly listeners = new Set<() => void>();\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n add(value: string): () => void {\n this.counts.set(value, (this.counts.get(value) ?? 0) + 1);\n this.notify();\n return () => {\n const count = (this.counts.get(value) ?? 1) - 1;\n if (count > 0) this.counts.set(value, count);\n else this.counts.delete(value);\n this.notify();\n };\n }\n\n /** At least one option, and every one of them is hidden (filtered out, or by the consumer). */\n allHidden(store: ListboxStore | undefined): boolean {\n if (store === undefined || this.counts.size === 0) return false;\n for (const value of this.counts.keys()) if (!store.isHidden(value)) return false;\n return true;\n }\n\n private notify(): void {\n for (const listener of [...this.listeners]) listener();\n }\n}\n\n/** The groups around an option, outermost first (P05-internal). */\nconst OptionGroupContext = React.createContext<readonly OptionGroupMembers[]>([]);\nOptionGroupContext.displayName = 'OptionGroupContext';\n\n/** A group around the option has the consumer's `hidden` attribute (P05-internal). */\nconst OptionGroupHiddenContext = React.createContext(false);\nOptionGroupHiddenContext.displayName = 'OptionGroupHiddenContext';\n\n/** Adds an option's value to every group around it while the option is mounted. */\nfunction useOptionGroupMembership(value: string): void {\n const groups = React.useContext(OptionGroupContext);\n React.useLayoutEffect(() => {\n if (groups.length === 0) return;\n const removes = groups.map((group) => group.add(value));\n return () => {\n for (const remove of removes) remove();\n };\n }, [groups, value]);\n}\n\n/*\n * Forced colours of a disabled option's box, as Checkbox draws a disabled box: GrayText on Canvas\n * for the square and its glyph, without the Highlight background of `forcedColors.selectedLeaf`.\n */\nconst DISABLED_BOX_FORCED_COLORS = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\nconst DISABLED_GLYPH_FORCED_COLORS =\n 'forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** What the check column of an option draws (see {@link renderCheck}). */\ninterface CheckState {\n selected: boolean;\n multiselect: boolean;\n disabled: boolean;\n}\n\n/**\n * The check column of an option. Single-select: the check glyph, kept in its place but not drawn\n * while the option is not selected, so the option texts line up. Multi-select: a 16px checkbox\n * square in Checkbox's colours, with the glyph inside only while selected; as a leaf indicator it\n * takes `forcedColors.selectedLeaf` while checked. A disabled option's square follows the row, as\n * the single-select glyph does: its muted text colour draws the square and the glyph, in place of\n * the brand colour. `glyph` is the consumer's `checkIcon` when it renders content, else\n * `undefined` for the default glyph.\n */\nfunction renderCheck(\n glyph: Slot<'span'> | undefined,\n { selected, multiselect, disabled }: CheckState,\n): React.ReactNode {\n if (!multiselect) {\n const classes = cn(optionClassNames.checkIcon, 'shrink-0', !selected && 'invisible');\n return glyph === undefined ? (\n <CheckIcon className={classes} />\n ) : (\n renderSlot(glyph, 'span', cn('inline-flex', classes), { 'aria-hidden': true })\n );\n }\n // One class set per state, so a disabled box never carries the brand classes it replaces.\n let boxClasses: string;\n if (disabled) {\n boxClasses = cn('border-current bg-transparent', DISABLED_BOX_FORCED_COLORS);\n } else if (selected) {\n boxClasses = cn('border-primary bg-primary text-primary-foreground', forcedColors.selectedLeaf);\n } else {\n boxClasses = cn('border-stroke-accessible bg-transparent', forcedColors.control);\n }\n const glyphClasses = disabled ? DISABLED_GLYPH_FORCED_COLORS : undefined;\n return (\n <span\n aria-hidden=\"true\"\n data-wave-option-box=\"\"\n className={cn(\n optionClassNames.indicator,\n 'flex h-4 w-4 shrink-0 items-center justify-center rounded-xs border',\n boxClasses,\n )}\n >\n {selected &&\n (glyph === undefined ? (\n <CheckIcon size={12} className={cn(optionClassNames.checkIcon, glyphClasses)} />\n ) : (\n renderSlot(\n glyph,\n 'span',\n cn(optionClassNames.checkIcon, 'inline-flex shrink-0', glyphClasses),\n {\n 'aria-hidden': true,\n },\n )\n ))}\n </span>\n );\n}\n\nfunction OptionImpl(props: OptionProps) {\n const {\n value,\n label,\n textValue,\n disabled = false,\n hidden = false,\n checkIcon,\n className,\n children,\n onClick,\n onMouseDown,\n onPointerMove,\n ref,\n ...rest\n } = props;\n const showCheck = React.useContext(OptionCheckContext);\n const groupHidden = React.useContext(OptionGroupHiddenContext);\n // A consumer-hidden option is not navigable; optionProps renders `hidden`.\n const { selected, multiselect, optionProps } = useListboxOption<HTMLLIElement>(\n { value, label, textValue, disabled, hidden: hidden || groupHidden },\n ref,\n );\n useOptionGroupMembership(value);\n const {\n ref: optionRef,\n onClick: selectOption,\n // Standalone mode only: the pointer press that focuses the list.\n onMouseDown: pressOption,\n onPointerMove: highlightOption,\n ...optionAttributes\n } = optionProps;\n\n // The check is a required indicator (C-SLOTS): a `checkIcon` that renders nothing keeps the\n // default glyph and warns once.\n const checkIconRenders = checkIcon != null && slotRendersContent(checkIcon);\n const checkIconEmpty = checkIcon != null && !checkIconRenders;\n React.useEffect(() => {\n if (checkIconEmpty) {\n warnOnce(\n 'Option:checkIcon-empty',\n 'Option: `checkIcon` renders nothing, so the default check shows: a selected option must show its state. Pass a glyph, or leave it unset.',\n );\n }\n }, [checkIconEmpty]);\n\n return (\n <li\n data-value={value}\n {...rest}\n {...optionAttributes}\n ref={optionRef}\n onClick={composeEventHandlers(onClick, selectOption)}\n onMouseDown={composeEventHandlers(onMouseDown, pressOption)}\n onPointerMove={composeEventHandlers(onPointerMove, highlightOption)}\n className={cn(\n optionClassNames.root,\n OPTION_CLASSES,\n // While a multi-select option draws its box, the box carries the state, and\n // `forcedColors.selectedContainer` would draw every selected option like the active one.\n selected && !(multiselect && showCheck) && forcedColors.selectedContainer,\n className,\n )}\n >\n {showCheck &&\n renderCheck(checkIconRenders ? checkIcon : undefined, { selected, multiselect, disabled })}\n <span className={cn(optionClassNames.content, 'min-w-0 flex-1')}>{children ?? value}</span>\n </li>\n );\n}\nOptionImpl.displayName = 'Option';\n\nconst MemoOption = /* @__PURE__ */ React.memo(OptionImpl);\nMemoOption.displayName = 'Option';\n\n/**\n * An option of a listbox: a `Listbox`, `Combobox` or `Dropdown` (and `TagPicker`'s generated\n * list), or a custom picker's list, rendered through `ListboxSurface` or under a\n * `ListboxProvider`. Renders `<li role=\"option\">` with a stable id (`aria-activedescendant`\n * target), `aria-selected`, a check mark while selected (`checkIcon` replaces it; in a\n * multi-select list it sits in a checkbox square) and `data-active`/`data-selected`/\n * `data-disabled` attributes for styling.\n *\n * Options register with the surrounding listbox (in DOM order, groups included), so they can be\n * wrapped, grouped or rendered conditionally. The option is memoized: moving the highlight\n * re-renders only the previously and the newly active option.\n *\n * Styling: `className` comes last. A plain background class (`className=\"bg-primary\"`) replaces\n * the built-in hover, selected and active backgrounds in every state. To restyle one state only,\n * use its data variant (`data-[active]:bg-…`, `data-[selected]:bg-…`). The active option keeps\n * its focus outline.\n *\n * Use it inside a listbox only; it throws in development elsewhere.\n */\nexport const Option: React.NamedExoticComponent<OptionProps> = /* @__PURE__ */ markListboxElement(\n MemoOption,\n 'option',\n);\n\n/* ------------------------------------------------------------------ */\n/* OptionGroup */\n/* ------------------------------------------------------------------ */\n\n/**\n * Props of {@link OptionGroup}. `aria-label` and `aria-labelledby` go to the group's\n * `role=\"group\"` list; the other props go to its `<li role=\"presentation\">` item.\n */\nexport interface OptionGroupProps extends React.LiHTMLAttributes<HTMLLIElement> {\n /**\n * The group's heading, which names the group. Keep it text (an icon next to the text is fine): a\n * label cannot be interactive, since nothing in it is reachable inside a listbox. Without a\n * label no heading renders; name the group with `aria-label` or `aria-labelledby` then. A group\n * without a name logs a development warning.\n */\n label?: React.ReactNode;\n /**\n * Names the group's list in place of the label (the heading still shows). A prop that holds\n * `undefined`, as from a wrapper that forwards it, leaves the label in charge.\n */\n 'aria-label'?: string;\n /**\n * Ids of the elements that name the group's list, in place of the label (the heading still\n * shows). A prop that holds `undefined` leaves the label in charge.\n */\n 'aria-labelledby'?: string;\n /**\n * Hides the group and every option in it (see `Option`'s `hidden`): keyboard navigation and\n * typeahead skip its options.\n * @default false\n */\n hidden?: boolean;\n /** Ref to the group's `<li role=\"presentation\">` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\nconst ELEMENT_NODE = 1;\nconst TEXT_NODE = 3;\n\n/**\n * The text a heading gives the name of its group, for the development check of `OptionGroup`: its\n * text without `aria-hidden` or `hidden` parts, where an element's `aria-label` or an image's `alt`\n * stands for its content.\n */\nfunction nameText(node: Node | null): string {\n if (node === null) return '';\n if (node.nodeType === TEXT_NODE) return node.textContent ?? '';\n if (node.nodeType !== ELEMENT_NODE) return '';\n const element = node as Element;\n if (element.getAttribute('aria-hidden') === 'true' || element.hasAttribute('hidden')) return '';\n const ownLabel = element.getAttribute('aria-label')?.trim();\n if (ownLabel) return ownLabel;\n if (element.localName === 'img') return element.getAttribute('alt') ?? '';\n let text = '';\n for (const child of Array.from(element.childNodes)) text += nameText(child);\n return text;\n}\n\n/**\n * Whether a group's list has a name, for the development check of `OptionGroup`, in the order the\n * name is computed: a consumer `aria-labelledby` that is not blank (its presence counts; the\n * elements it names are not read), else a non-blank `aria-label`, else the heading that labels the\n * list. A string or number label is its own text; only an element label is read from the rendered\n * heading ({@link nameText}).\n */\nfunction groupHasName(\n label: React.ReactNode,\n ariaLabel: string | undefined,\n labelledBy: string | undefined,\n labelId: string,\n heading: HTMLElement | null,\n): boolean {\n if (labelledBy !== undefined && labelledBy !== labelId && labelledBy.trim() !== '') return true;\n if (ariaLabel !== undefined && ariaLabel.trim() !== '') return true;\n if (labelledBy !== labelId) return false;\n if (typeof label === 'string' || typeof label === 'number') return String(label).trim() !== '';\n return nameText(heading).trim() !== '';\n}\n\nconst UNNAMED_GROUP_WARNING = 'OptionGroup:unnamed';\n\nfunction OptionGroupImpl({\n label,\n className,\n children,\n hidden,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ref,\n ...rest\n}: OptionGroupProps) {\n const labelId = useId('option-group');\n const store = React.useContext(ListboxContext)?.store;\n const parentGroups = React.useContext(OptionGroupContext);\n const hiddenByConsumer = React.useContext(OptionGroupHiddenContext) || !!hidden;\n const [members] = React.useState(() => new OptionGroupMembers());\n const groups = React.useMemo(() => [...parentGroups, members], [parentGroups, members]);\n const subscribe = React.useCallback(\n (listener: () => void) => {\n const unsubscribeMembers = members.subscribe(listener);\n const unsubscribeStore = store?.subscribe(listener);\n return () => {\n unsubscribeMembers();\n unsubscribeStore?.();\n };\n },\n [members, store],\n );\n // Hidden while every option inside it is filtered out or hidden, also options wrapped in a\n // component (the options register with the group; re-read when they do and when the listbox\n // state changes).\n // The server render and the first client render show the group: no option has registered yet.\n const empty = React.useSyncExternalStore(\n subscribe,\n () => members.allHidden(store),\n () => false,\n );\n\n // The heading renders only for a label that renders content, so the list never points at an\n // empty heading. A consumer name wins over the heading; a prop that holds `undefined` (a wrapper\n // forwarding it) is no name of the consumer's.\n const hasLabel = slotRendersContent(label);\n const labelledBy = ariaLabelledBy ?? (ariaLabel === undefined && hasLabel ? labelId : undefined);\n\n // C-DEV: warn once when nothing names the group, checked again whenever the label, the\n // consumer `aria-label` or the resolved `aria-labelledby` changes.\n const headingRef = React.useRef<HTMLDivElement | null>(null);\n React.useEffect(() => {\n if (!isDev || hasWarned(UNNAMED_GROUP_WARNING)) return;\n if (groupHasName(label, ariaLabel, labelledBy, labelId, headingRef.current)) return;\n warnOnce(\n UNNAMED_GROUP_WARNING,\n 'OptionGroup: the group has no name. Give it a text `label`, `aria-label` or `aria-labelledby`.',\n );\n }, [label, ariaLabel, labelledBy, labelId]);\n\n return (\n <li\n {...rest}\n ref={ref}\n role=\"presentation\"\n hidden={hidden || empty || undefined}\n className={cn(optionGroupClassNames.root, className)}\n >\n {hasLabel && (\n <div\n ref={headingRef}\n id={labelId}\n role=\"presentation\"\n className={cn(\n optionGroupClassNames.label,\n 'px-3 py-1 text-caption-1 font-semibold text-muted-foreground',\n )}\n >\n {materialiseSlotContent(label)}\n </div>\n )}\n <ul\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n className={optionGroupClassNames.list}\n >\n <OptionGroupHiddenContext.Provider value={hiddenByConsumer}>\n <OptionGroupContext.Provider value={groups}>{children}</OptionGroupContext.Provider>\n </OptionGroupHiddenContext.Provider>\n </ul>\n </li>\n );\n}\nOptionGroupImpl.displayName = 'OptionGroup';\n\n/**\n * Groups options under an optional heading: `<li role=\"presentation\">` with the heading and a\n * `<ul role=\"group\">` of the options, named by the heading (`label`) or by your `aria-label` or\n * `aria-labelledby`, which win over it. Hidden while a filter (or their own `hidden`) hides all\n * its options, also options wrapped in a component or in nested groups. Use it inside a listbox,\n * as `Option`.\n */\nexport const OptionGroup: React.FC<OptionGroupProps> = /* @__PURE__ */ markListboxElement(\n OptionGroupImpl,\n 'group',\n);\n\n/* ------------------------------------------------------------------ */\n/* ListboxProvider */\n/* ------------------------------------------------------------------ */\n\n/** Props of {@link ListboxProvider}. */\nexport interface ListboxProviderProps {\n /** The context of a listbox: `useListbox(...).context`. */\n value: ListboxContextValue;\n /** The options (`Option`, `OptionGroup` or options of your own on `useListboxOption`). */\n children?: React.ReactNode;\n}\n\n/**\n * Provides a listbox's context to its options, for a custom picker that renders its list without\n * `ListboxSurface`: `<ListboxProvider value={listbox.context}><ul {...listbox.getListboxProps()}>…</ul></ListboxProvider>`.\n */\nexport function ListboxProvider({ value, children }: ListboxProviderProps) {\n return <ListboxContext.Provider value={value}>{children}</ListboxContext.Provider>;\n}\nListboxProvider.displayName = 'ListboxProvider';\n\n/* ------------------------------------------------------------------ */\n/* Listbox popup: useListboxPopup and ListboxSurface */\n/* ------------------------------------------------------------------ */\n\n/** Options of {@link useListboxPopup}. */\nexport interface UseListboxPopupOptions {\n /**\n * The listbox is open (your open state). While it is, a press outside your picker and its\n * surface, and focus leaving them, dismiss it.\n */\n open: boolean;\n /**\n * The surface is shown (the list, or the empty content of {@link ListboxSurface}): it is\n * positioned, and Escape dismisses it. While the listbox is open with nothing shown (no options\n * to show), Escape is left to an enclosing layer, such as a Dialog around the picker.\n */\n surfaceOpen: boolean;\n /**\n * Called when the popup should close: set your open state to `false`. `reason` is `'escape'`,\n * `'outside-press'` or `'focus-outside'`.\n */\n onDismiss: (reason: DismissReason) => void;\n /** Your picker's root element: presses and focus inside it are not outside the popup. */\n rootRef: React.RefObject<HTMLElement | null>;\n /**\n * The combobox element, which anchors the popup's dismiss layer. Pass the element to\n * `setReference` too (merged into its ref), which places the surface against it.\n */\n anchorRef: React.RefObject<HTMLElement | null>;\n}\n\n/**\n * Result of {@link useListboxPopup}. Destructure it: `eslint-plugin-react-hooks` treats an object\n * with a member passed to a `ref` prop as a ref, and rejects reading its other members during\n * render (`react-hooks/refs`).\n */\nexport interface UseListboxPopupResult {\n /** The popup's dismiss layer: pass it to {@link ListboxSurface}. */\n layerId: string;\n /**\n * Ref callback for the element the surface is placed against: merge it into your combobox's ref.\n */\n setReference: (el: HTMLElement | null) => void;\n /** Ref callback for the surface: pass it to {@link ListboxSurface}. */\n surfaceRef: React.RefCallback<HTMLElement>;\n /** The surface's `data-side`, `data-align` and position style: pass them to {@link ListboxSurface}. */\n floatingProps: { 'data-side': string; 'data-align': string; style: React.CSSProperties };\n}\n\n/**\n * Dismissal and positioning of a custom picker's listbox popup, for {@link ListboxSurface}. The\n * popup is dismissed by Escape, by a press outside your picker and its surface, and by focus\n * leaving them (`onDismiss` says which). The surface opens below the anchor and as wide as it,\n * flips above it when there is no room below, and is limited to the space available; its\n * `data-side` and `data-align` attributes give the final placement.\n *\n * While the listbox is open with nothing to show (`surfaceOpen` is `false`), Escape is left to an\n * enclosing layer, such as a Dialog around the picker. Let your combobox's key handler leave it\n * too: on such an Escape, set your open state to `false` without calling `listbox.onKeyDown`,\n * which handles Escape (and prevents its default) whenever the listbox is open. Do so only when\n * `!event.nativeEvent.isComposing`, as Dropdown, Combobox and TagPicker do: an Escape that only\n * cancels an IME composition must not close the listbox, and `listbox.onKeyDown` ignores such\n * keys too.\n *\n * @example\n * const expanded = open && listbox.items.length > 0;\n * const { layerId, setReference, surfaceRef, floatingProps } = useListboxPopup({\n * open,\n * surfaceOpen: expanded,\n * onDismiss: () => setOpen(false),\n * rootRef,\n * anchorRef: buttonRef,\n * });\n * const buttonMergedRef = useMergedRefs(buttonRef, setReference);\n */\nexport function useListboxPopup(options: UseListboxPopupOptions): UseListboxPopupResult {\n const { open, surfaceOpen, onDismiss, rootRef, anchorRef } = options;\n const surfaceElementRef = React.useRef<HTMLElement | null>(null);\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open: surfaceOpen,\n side: 'bottom',\n align: 'start',\n matchReferenceWidth: true,\n fitViewport: true,\n });\n const { layerId } = useDismiss({\n open,\n onDismiss: (reason) => onDismiss(reason),\n refs: [rootRef, surfaceElementRef],\n anchorRef,\n kind: 'listbox',\n escape: surfaceOpen,\n focusOutside: true,\n });\n const surfaceRef = useMergedRefs<HTMLElement>(surfaceElementRef, setFloating);\n return { layerId, setReference, surfaceRef, floatingProps };\n}\n\n/**\n * Attributes of the list element that ListboxSurface renders (see `listProps`). Its content is the\n * surface's `children`.\n */\nexport type ListboxSurfaceListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n | 'role'\n | 'id'\n | 'hidden'\n | 'tabIndex'\n | 'className'\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-multiselectable'\n | 'aria-activedescendant'\n | 'children'\n | 'dangerouslySetInnerHTML'\n> & {\n /** Ref to the `role=\"listbox\"` element (it moves between the picker and the popup). */\n ref?: React.Ref<HTMLUListElement>;\n};\n\n/**\n * Props of {@link ListboxSurface}. The options of one listbox live in one list at a time, and this\n * surface renders that list: render every option of the listbox inside it, never in a second list\n * of your own, not even for an exit animation.\n */\nexport interface ListboxSurfaceProps {\n /** The listbox: the result of `useListbox` in select-only or editable mode. */\n listbox: UseListboxResult;\n /** `layerId` from {@link useListboxPopup}: the surface joins the popup's dismiss layer. */\n layerId: string;\n /** `surfaceRef` from {@link useListboxPopup}. */\n surfaceRef: React.RefCallback<HTMLElement>;\n /** `floatingProps` from {@link useListboxPopup}: the surface's placement. */\n floatingProps: UseListboxPopupResult['floatingProps'];\n /** The listbox is open (your open state). `emptyContent` shows only while it is. */\n open: boolean;\n /**\n * The list is shown: the listbox is open and has options to show (`open &&\n * listbox.items.length > 0`). The list then renders in the surface, and otherwise `hidden`, in\n * place inside your picker. Set your combobox's `aria-expanded` to this value after spreading\n * `getComboboxProps()`, which reports `open`, so the combobox is not announced as expanded while\n * nothing is shown.\n */\n expanded: boolean;\n /**\n * Shown in the surface while the listbox is open but not expanded, such as a \"No matches\"\n * message. `undefined` and `null` show no surface; any other value shows one, so `false` and\n * `''` show an empty surface.\n */\n emptyContent?: React.ReactNode;\n /** Names the list. Name it with this or `aria-labelledby`, usually your picker's label. */\n 'aria-label'?: string;\n /** Ids of the elements that name the list, usually your picker's label. */\n 'aria-labelledby'?: string;\n /**\n * Options draw a check while selected (in a multi-select list, a checkbox square). Turn it off\n * for a list that never shows selected options, such as the suggestions of a tag picker.\n * @default true\n */\n showCheck?: boolean;\n /**\n * Classes merged last onto the list: they replace the list's own classes they conflict with,\n * its maximum height included.\n */\n listClassName?: string;\n /**\n * Classes merged last onto the surface, the popup around the list: they replace its own\n * classes they conflict with.\n */\n surfaceClassName?: string;\n /**\n * Attributes spread onto the list element before the listbox's own (`role`, `id`, `tabIndex`,\n * `aria-multiselectable`, `aria-activedescendant` and `hidden` win, also where the listbox\n * renders none of the last two): `data-*` and other `aria-*` attributes, `style`, and handlers,\n * composed before the listbox's own `onMouseDown`. `ref` is merged with the list's. Name the list\n * with `aria-label`/`aria-labelledby` (the props above), not here.\n */\n listProps?: ListboxSurfaceListProps;\n /** The options (`Option`, `OptionGroup` or options of your own on `useListboxOption`). */\n children?: React.ReactNode;\n}\n\nfunction preventMouseDown(event: React.MouseEvent) {\n event.preventDefault();\n}\n\n/**\n * The option list of a custom picker and the popup it opens in: a `<ul role=\"listbox\">` with the\n * options (spread from `listbox.getListboxProps()`), rendered `hidden` in place inside your\n * picker while the list is not shown, so the options register and their ids exist from the first\n * render, and in a portaled surface placed by {@link useListboxPopup} while it is, never in both.\n * While the listbox is open with nothing to show, the surface shows `emptyContent` instead, if\n * any. A press on the surface keeps focus on your combobox. It provides the listbox's context to\n * the options, so it needs no {@link ListboxProvider}.\n *\n * @example\n * <ListboxSurface\n * listbox={listbox}\n * layerId={layerId}\n * surfaceRef={surfaceRef}\n * floatingProps={floatingProps}\n * open={open}\n * expanded={expanded}\n * aria-labelledby={labelId}\n * >\n * <Option value=\"georgia\">Georgia</Option>\n * </ListboxSurface>\n */\nexport function ListboxSurface(props: ListboxSurfaceProps) {\n const {\n listbox,\n layerId,\n surfaceRef,\n floatingProps,\n open,\n expanded,\n emptyContent,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n showCheck = true,\n listClassName,\n surfaceClassName,\n listProps,\n children,\n } = props;\n\n // The consumer's list attributes go first, so the listbox's own win; its `onMouseDown` runs\n // before the list's (which keeps focus on the combobox) and its `ref` is merged with the list's.\n const { ref: listRefProp, onMouseDown: listMouseDown, ...listRest } = listProps ?? {};\n const listboxProps = listbox.getListboxProps();\n const listRef = useMergedRefs<HTMLUListElement>(listRefProp, listboxProps.ref);\n\n const list = (\n <OptionCheckContext.Provider value={showCheck}>\n <ListboxProvider value={listbox.context}>\n <ul\n {...listRest}\n {...listboxProps}\n // Absent from `listboxProps` when not set: a caller's value never survives the spread.\n aria-multiselectable={listboxProps['aria-multiselectable']}\n aria-activedescendant={listboxProps['aria-activedescendant']}\n onMouseDown={composeEventHandlers(listMouseDown, listboxProps.onMouseDown)}\n ref={listRef}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n hidden={!expanded || undefined}\n className={cn(\n listboxSurfaceClassNames.list,\n 'min-h-0 max-h-60 overflow-auto',\n listClassName,\n )}\n >\n {children}\n </ul>\n </ListboxProvider>\n </OptionCheckContext.Provider>\n );\n\n // A closed listbox never leaves a surface behind: the text typed before closing survives it.\n const showEmpty = open && !expanded && emptyContent !== undefined && emptyContent !== null;\n if (!expanded && !showEmpty) return list;\n\n return (\n <>\n {!expanded && list}\n <Portal layerId={layerId}>\n <div\n ref={surfaceRef}\n {...floatingProps}\n data-wave-listbox-surface=\"\"\n onMouseDown={preventMouseDown}\n className={cn(\n listboxSurfaceClassNames.root,\n 'flex flex-col overflow-hidden rounded border border-border bg-background py-1 text-foreground shadow-4',\n surfaceClassName,\n )}\n >\n {expanded ? list : emptyContent}\n </div>\n </Portal>\n </>\n );\n}\nListboxSurface.displayName = 'ListboxSurface';\n"],"mappings":";;;;;;;;;;;;;;;;;AA+EA,IAAMI,IAAqBD,EAAM,cAAc,EAAI;AACnD,EAAmB,cAAc;AAiBjC,IAAME,IAAiBC,EACrB,8FACA,8CACA,+EACA,6DACA,wDACA,sFACA,sEACF,GAMMC,IAAN,MAAyB;CACvB,yBAA0B,IAAI,IAAoB;CAClD,4BAA6B,IAAI,IAAgB;CAEjD,aAAa,OACX,KAAK,UAAU,IAAIC,CAAQ,SACd;EACX,KAAK,UAAU,OAAOA,CAAQ;CAChC;CAGF,IAAI,GAA2B;EAG7B,OAFA,KAAK,OAAO,IAAIC,IAAQ,KAAK,OAAO,IAAIA,CAAK,KAAK,KAAK,CAAC,GACxD,KAAK,OAAO,SACC;GACX,IAAMC,KAAS,KAAK,OAAO,IAAID,CAAK,KAAK,KAAK;GAG9C,AAFIC,IAAQ,IAAG,KAAK,OAAO,IAAID,GAAOC,CAAK,IACtC,KAAK,OAAO,OAAOD,CAAK,GAC7B,KAAK,OAAO;EACd;CACF;CAGA,UAAU,GAA0C;EAClD,IAAIE,MAAU,KAAA,KAAa,KAAK,OAAO,SAAS,GAAG,OAAO;EAC1D,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GAAIE;IAEJ,wBAAsBA,EAAa;IACnC,yBAAuBA,EAAa;IACpC,aAAazD,EAAqBsD,GAAeG,EAAa,WAAW;IACzE,KAAKE;IACL,cAAYxC;IACZ,mBAAiBK;IACjB,QAAQ,CAACqC,KAAY,KAAA;IACrB,WAAW3G,EACT4G,EAAyB,MACzB,kCACAC,CACF;IAEC;GACC,CAAA;EACW,CAAA;CACU,CAAA;CAO/B,OAFI,CAACF,MADa,MAASA,KAAYG,KAA+C,QAClDJ,IAGlC,kBAAA/G,GAAA,EAAA,UAAA,CACG,CAACgH,KAAYD,GACd,kBAACM,GAAD;EAAiB;EACf,UAAA,kBAAC,OAAD;GACE,KAAKC;GACL,GAAIC;GACJ,6BAA0B;GAC1B,aAAajB;GACb,WAAWjG,EACT4G,EAAyB,MACzB,0GACAO,CACF;GAEC,UAAAR,IAAWD,IAAOI;EAChB,CAAA;CACC,CAAA,CACR,EAAA,CAAA;AAEN;AACA,EAAe,cAAc"}
1
+ {"version":3,"file":"Option.mjs","names":["useId","_Fragment","useId$1","React","OptionCheckContext","OPTION_CLASSES","cn","OptionGroupMembers","listener","value","count","store","OptionGroupContext","OptionGroupHiddenContext","useOptionGroupMembership","groups","removes","group","remove","DISABLED_BOX_FORCED_COLORS","DISABLED_GLYPH_FORCED_COLORS","renderCheck","multiselect","classes","optionClassNames","selected","glyph","CheckIcon","renderSlot","boxClasses","disabled","forcedColors","glyphClasses","OptionImpl","rest","props","showCheck","groupHidden","useListboxOption","hidden","ref","optionRef","selectOption","pressOption","highlightOption","optionAttributes","optionProps","checkIconRenders","checkIcon","slotRendersContent","checkIconEmpty","warnOnce","composeEventHandlers","onClick","onMouseDown","onPointerMove","className","children","MemoOption","Option","ELEMENT_NODE","TEXT_NODE","nameText","node","element","ownLabel","text","child","groupHasName","labelledBy","labelId","ariaLabel","label","heading","UNNAMED_GROUP_WARNING","OptionGroupImpl","ariaLabelledBy","ListboxContext","parentGroups","hiddenByConsumer","members","subscribe","unsubscribeMembers","unsubscribeStore","empty","hasLabel","headingRef","isDev","optionGroupClassNames","materialiseSlotContent","OptionGroup","ListboxProvider","useListboxPopup","options","surfaceElementRef","usePopupPosition","surfaceOpen","resolvePositioning","positioning","useDismiss","onDismiss","reason","rootRef","useMergedRefs","setFloating","preventMouseDown","ListboxSurface","listRefProp","listMouseDown","listRest","listProps","listboxProps","listbox","listRef","list","expanded","listboxSurfaceClassNames","listClassName","emptyContent","Fragment","Portal","surfaceRef","floatingProps","surfaceClassName"],"sources":["../../../src/components/input/Option.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n listboxSurfaceClassNames,\n optionClassNames,\n optionGroupClassNames,\n} from '../../lib/classNames';\nimport { cn } from '../../lib/cn';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { hasWarned, isDev, warnOnce } from '../../lib/dev';\nimport { CheckIcon } from '../../lib/icons';\nimport { materialiseSlotContent, renderSlot, slotRendersContent, type Slot } from '../../lib/slot';\nimport { forcedColors } from '../../lib/styles';\nimport type { PopupPositioningOptions } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport type { DismissReason } from '../../hooks/useDismiss';\nimport { resolvePositioning, usePopupPosition } from '../../hooks/usePopupPosition';\nimport {\n ListboxContext,\n markListboxElement,\n useListboxOption,\n type ListboxContextValue,\n type ListboxStore,\n type UseListboxResult,\n} from '../../hooks/useListbox';\nimport { Portal } from '../portal/Portal';\n\n/* ------------------------------------------------------------------ */\n/* Option */\n/* ------------------------------------------------------------------ */\n\n/**\n * Props of {@link Option}, an option of a listbox (Listbox, Combobox, Dropdown or a custom\n * picker's list).\n */\nexport interface OptionProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'value'> {\n /** Value associated with this option. Unique within its listbox. */\n value: string;\n /**\n * Text shown in the combobox (Combobox input, Dropdown trigger) when this option is selected.\n * Defaults to `textValue`, then the option's text content, then `value`. Pass it when the\n * children are not plain text (icons, custom components).\n */\n label?: string;\n /** Text matched by typeahead and filtering instead of the label. */\n textValue?: string;\n /**\n * Whether the option is disabled: it stays in the list but can never be selected (a click, Enter\n * and Space do nothing). Keyboard navigation and typeahead skip it, unless the listbox keeps\n * disabled options focusable (`disabledOptionsFocusable`), where they reach it. It is drawn in\n * the muted text colour, its check included: in a multi-select list the checkbox square takes\n * that colour instead of the brand colour, checked or not.\n * @default false\n */\n disabled?: boolean;\n /**\n * Replaces the check glyph that marks the option while it is selected (decorative,\n * `aria-hidden`); in a multi-select list the glyph is drawn inside the option's 16px checkbox\n * square. The check is a required indicator, the sign of the selection that does not rely on\n * colour: `null` and `undefined` keep the default glyph, and so does a value that renders\n * nothing (`false`, `''`, an empty array), which also logs a development warning. Unlike\n * `Combobox.expandIcon`, a value that renders nothing does not hide the indicator (Fluent's\n * `checkIcon={null}` removes it).\n * @default a check mark\n */\n checkIcon?: Slot<'span'>;\n /**\n * Hides the option, like a native `<option hidden>`: it is not shown, keyboard navigation and\n * typeahead skip it, and it never becomes the active option. Its label stays known, so a\n * selected hidden option (a placeholder) still shows in the combobox. The options of a hidden\n * `OptionGroup` are hidden the same way.\n * @default false\n */\n hidden?: boolean;\n /** Ref to the option `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/** Whether options draw the selected check mark (P05-internal; TagPicker lists no selected options). */\nconst OptionCheckContext = React.createContext(true);\nOptionCheckContext.displayName = 'OptionCheckContext';\n\n/*\n * State is exposed as data attributes (C-CLASS): `data-active` (keyboard/pointer highlight),\n * `data-selected`, `data-disabled`. State classes come before the consumer's `className` in `cn()`.\n *\n * Backgrounds (input-pickers#20): one unconditional `bg-(--option-bg)` paints the option, and the\n * hover/selected/active variants only set `--option-bg`. A variant that set `background-color`\n * itself (class + attribute or pseudo-class) would out-specify a consumer's plain `bg-*` class in\n * the cascade even though `cn()` keeps it; instead tailwind-merge replaces `bg-(--option-bg)` with\n * the consumer's class, which is then the only background declaration on the option. A consumer\n * `data-[active]:bg-…` / `data-[selected]:bg-…` restyles a single state (it out-specifies the\n * unconditional reader). The active outline is the focus indicator and stays a state variant.\n *\n * A filtered-out option carries the `hidden` attribute; base.css's scoped `[hidden]` rule hides\n * it over `flex` and over a consumer's display class.\n */\nconst OPTION_CLASSES = cn(\n 'flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground',\n 'bg-(--option-bg) [--option-bg:transparent]',\n 'not-disabled:not-aria-disabled:hover:[--option-bg:var(--wave-subtle-hover)]',\n 'data-[selected]:[--option-bg:var(--wave-subtle-selected)]',\n 'data-[active]:[--option-bg:var(--wave-subtle-hover)]',\n 'data-[active]:outline-2 data-[active]:-outline-offset-2 data-[active]:outline-ring',\n 'aria-disabled:cursor-not-allowed aria-disabled:text-muted-foreground',\n);\n\n/**\n * The values of the options rendered inside an `OptionGroup`, whatever wraps them (custom\n * components, Fragments, nested groups): each option adds its value from a layout effect.\n */\nclass OptionGroupMembers {\n private readonly counts = new Map<string, number>();\n private readonly listeners = new Set<() => void>();\n\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n add(value: string): () => void {\n this.counts.set(value, (this.counts.get(value) ?? 0) + 1);\n this.notify();\n return () => {\n const count = (this.counts.get(value) ?? 1) - 1;\n if (count > 0) this.counts.set(value, count);\n else this.counts.delete(value);\n this.notify();\n };\n }\n\n /** At least one option, and every one of them is hidden (filtered out, or by the consumer). */\n allHidden(store: ListboxStore | undefined): boolean {\n if (store === undefined || this.counts.size === 0) return false;\n for (const value of this.counts.keys()) if (!store.isHidden(value)) return false;\n return true;\n }\n\n private notify(): void {\n for (const listener of [...this.listeners]) listener();\n }\n}\n\n/** The groups around an option, outermost first (P05-internal). */\nconst OptionGroupContext = React.createContext<readonly OptionGroupMembers[]>([]);\nOptionGroupContext.displayName = 'OptionGroupContext';\n\n/** A group around the option has the consumer's `hidden` attribute (P05-internal). */\nconst OptionGroupHiddenContext = React.createContext(false);\nOptionGroupHiddenContext.displayName = 'OptionGroupHiddenContext';\n\n/** Adds an option's value to every group around it while the option is mounted. */\nfunction useOptionGroupMembership(value: string): void {\n const groups = React.useContext(OptionGroupContext);\n React.useLayoutEffect(() => {\n if (groups.length === 0) return;\n const removes = groups.map((group) => group.add(value));\n return () => {\n for (const remove of removes) remove();\n };\n }, [groups, value]);\n}\n\n/*\n * Forced colours of a disabled option's box, as Checkbox draws a disabled box: GrayText on Canvas\n * for the square and its glyph, without the Highlight background of `forcedColors.selectedLeaf`.\n */\nconst DISABLED_BOX_FORCED_COLORS = 'forced-colors:border-[GrayText] forced-colors:bg-[Canvas]';\nconst DISABLED_GLYPH_FORCED_COLORS =\n 'forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none';\n\n/** What the check column of an option draws (see {@link renderCheck}). */\ninterface CheckState {\n selected: boolean;\n multiselect: boolean;\n disabled: boolean;\n}\n\n/**\n * The check column of an option. Single-select: the check glyph, kept in its place but not drawn\n * while the option is not selected, so the option texts line up. Multi-select: a 16px checkbox\n * square in Checkbox's colours, with the glyph inside only while selected; as a leaf indicator it\n * takes `forcedColors.selectedLeaf` while checked. A disabled option's square follows the row, as\n * the single-select glyph does: its muted text colour draws the square and the glyph, in place of\n * the brand colour. `glyph` is the consumer's `checkIcon` when it renders content, else\n * `undefined` for the default glyph.\n */\nfunction renderCheck(\n glyph: Slot<'span'> | undefined,\n { selected, multiselect, disabled }: CheckState,\n): React.ReactNode {\n if (!multiselect) {\n const classes = cn(optionClassNames.checkIcon, 'shrink-0', !selected && 'invisible');\n return glyph === undefined ? (\n <CheckIcon className={classes} />\n ) : (\n renderSlot(glyph, 'span', cn('inline-flex', classes), { 'aria-hidden': true })\n );\n }\n // One class set per state, so a disabled box never carries the brand classes it replaces.\n let boxClasses: string;\n if (disabled) {\n boxClasses = cn('border-current bg-transparent', DISABLED_BOX_FORCED_COLORS);\n } else if (selected) {\n boxClasses = cn('border-primary bg-primary text-primary-foreground', forcedColors.selectedLeaf);\n } else {\n boxClasses = cn('border-stroke-accessible bg-transparent', forcedColors.control);\n }\n const glyphClasses = disabled ? DISABLED_GLYPH_FORCED_COLORS : undefined;\n return (\n <span\n aria-hidden=\"true\"\n data-wave-option-box=\"\"\n className={cn(\n optionClassNames.indicator,\n 'flex h-4 w-4 shrink-0 items-center justify-center rounded-xs border',\n boxClasses,\n )}\n >\n {selected &&\n (glyph === undefined ? (\n <CheckIcon size={12} className={cn(optionClassNames.checkIcon, glyphClasses)} />\n ) : (\n renderSlot(\n glyph,\n 'span',\n cn(optionClassNames.checkIcon, 'inline-flex shrink-0', glyphClasses),\n {\n 'aria-hidden': true,\n },\n )\n ))}\n </span>\n );\n}\n\nfunction OptionImpl(props: OptionProps) {\n const {\n value,\n label,\n textValue,\n disabled = false,\n hidden = false,\n checkIcon,\n className,\n children,\n onClick,\n onMouseDown,\n onPointerMove,\n ref,\n ...rest\n } = props;\n const showCheck = React.useContext(OptionCheckContext);\n const groupHidden = React.useContext(OptionGroupHiddenContext);\n // A consumer-hidden option is not navigable; optionProps renders `hidden`.\n const { selected, multiselect, optionProps } = useListboxOption<HTMLLIElement>(\n { value, label, textValue, disabled, hidden: hidden || groupHidden },\n ref,\n );\n useOptionGroupMembership(value);\n const {\n ref: optionRef,\n onClick: selectOption,\n // Standalone mode only: the pointer press that focuses the list.\n onMouseDown: pressOption,\n onPointerMove: highlightOption,\n ...optionAttributes\n } = optionProps;\n\n // The check is a required indicator (C-SLOTS): a `checkIcon` that renders nothing keeps the\n // default glyph and warns once.\n const checkIconRenders = checkIcon != null && slotRendersContent(checkIcon);\n const checkIconEmpty = checkIcon != null && !checkIconRenders;\n React.useEffect(() => {\n if (checkIconEmpty) {\n warnOnce(\n 'Option:checkIcon-empty',\n 'Option: `checkIcon` renders nothing, so the default check shows: a selected option must show its state. Pass a glyph, or leave it unset.',\n );\n }\n }, [checkIconEmpty]);\n\n return (\n <li\n data-value={value}\n {...rest}\n {...optionAttributes}\n ref={optionRef}\n onClick={composeEventHandlers(onClick, selectOption)}\n onMouseDown={composeEventHandlers(onMouseDown, pressOption)}\n onPointerMove={composeEventHandlers(onPointerMove, highlightOption)}\n className={cn(\n optionClassNames.root,\n OPTION_CLASSES,\n // While a multi-select option draws its box, the box carries the state, and\n // `forcedColors.selectedContainer` would draw every selected option like the active one.\n selected && !(multiselect && showCheck) && forcedColors.selectedContainer,\n className,\n )}\n >\n {showCheck &&\n renderCheck(checkIconRenders ? checkIcon : undefined, { selected, multiselect, disabled })}\n <span className={cn(optionClassNames.content, 'min-w-0 flex-1')}>{children ?? value}</span>\n </li>\n );\n}\nOptionImpl.displayName = 'Option';\n\nconst MemoOption = /* @__PURE__ */ React.memo(OptionImpl);\nMemoOption.displayName = 'Option';\n\n/**\n * An option of a listbox: a `Listbox`, `Combobox` or `Dropdown` (and `TagPicker`'s generated\n * list), or a custom picker's list, rendered through `ListboxSurface` or under a\n * `ListboxProvider`. Renders `<li role=\"option\">` with a stable id (`aria-activedescendant`\n * target), `aria-selected`, a check mark while selected (`checkIcon` replaces it; in a\n * multi-select list it sits in a checkbox square) and `data-active`/`data-selected`/\n * `data-disabled` attributes for styling.\n *\n * Options register with the surrounding listbox (in DOM order, groups included), so they can be\n * wrapped, grouped or rendered conditionally. The option is memoized: moving the highlight\n * re-renders only the previously and the newly active option.\n *\n * Styling: `className` comes last. A plain background class (`className=\"bg-primary\"`) replaces\n * the built-in hover, selected and active backgrounds in every state. To restyle one state only,\n * use its data variant (`data-[active]:bg-…`, `data-[selected]:bg-…`). The active option keeps\n * its focus outline.\n *\n * Use it inside a listbox only; it throws in development elsewhere.\n */\nexport const Option: React.NamedExoticComponent<OptionProps> = /* @__PURE__ */ markListboxElement(\n MemoOption,\n 'option',\n);\n\n/* ------------------------------------------------------------------ */\n/* OptionGroup */\n/* ------------------------------------------------------------------ */\n\n/**\n * Props of {@link OptionGroup}. `aria-label` and `aria-labelledby` go to the group's\n * `role=\"group\"` list; the other props go to its `<li role=\"presentation\">` item.\n */\nexport interface OptionGroupProps extends React.LiHTMLAttributes<HTMLLIElement> {\n /**\n * The group's heading, which names the group. Keep it text (an icon next to the text is fine): a\n * label cannot be interactive, since nothing in it is reachable inside a listbox. Without a\n * label no heading renders; name the group with `aria-label` or `aria-labelledby` then. A group\n * without a name logs a development warning.\n */\n label?: React.ReactNode;\n /**\n * Names the group's list in place of the label (the heading still shows). A prop that holds\n * `undefined`, as from a wrapper that forwards it, leaves the label in charge.\n */\n 'aria-label'?: string;\n /**\n * Ids of the elements that name the group's list, in place of the label (the heading still\n * shows). A prop that holds `undefined` leaves the label in charge.\n */\n 'aria-labelledby'?: string;\n /**\n * Hides the group and every option in it (see `Option`'s `hidden`): keyboard navigation and\n * typeahead skip its options.\n * @default false\n */\n hidden?: boolean;\n /** Ref to the group's `<li role=\"presentation\">` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\nconst ELEMENT_NODE = 1;\nconst TEXT_NODE = 3;\n\n/**\n * The text a heading gives the name of its group, for the development check of `OptionGroup`: its\n * text without `aria-hidden` or `hidden` parts, where an element's `aria-label` or an image's `alt`\n * stands for its content.\n */\nfunction nameText(node: Node | null): string {\n if (node === null) return '';\n if (node.nodeType === TEXT_NODE) return node.textContent ?? '';\n if (node.nodeType !== ELEMENT_NODE) return '';\n const element = node as Element;\n if (element.getAttribute('aria-hidden') === 'true' || element.hasAttribute('hidden')) return '';\n const ownLabel = element.getAttribute('aria-label')?.trim();\n if (ownLabel) return ownLabel;\n if (element.localName === 'img') return element.getAttribute('alt') ?? '';\n let text = '';\n for (const child of Array.from(element.childNodes)) text += nameText(child);\n return text;\n}\n\n/**\n * Whether a group's list has a name, for the development check of `OptionGroup`, in the order the\n * name is computed: a consumer `aria-labelledby` that is not blank (its presence counts; the\n * elements it names are not read), else a non-blank `aria-label`, else the heading that labels the\n * list. A string or number label is its own text; only an element label is read from the rendered\n * heading ({@link nameText}).\n */\nfunction groupHasName(\n label: React.ReactNode,\n ariaLabel: string | undefined,\n labelledBy: string | undefined,\n labelId: string,\n heading: HTMLElement | null,\n): boolean {\n if (labelledBy !== undefined && labelledBy !== labelId && labelledBy.trim() !== '') return true;\n if (ariaLabel !== undefined && ariaLabel.trim() !== '') return true;\n if (labelledBy !== labelId) return false;\n if (typeof label === 'string' || typeof label === 'number') return String(label).trim() !== '';\n return nameText(heading).trim() !== '';\n}\n\nconst UNNAMED_GROUP_WARNING = 'OptionGroup:unnamed';\n\nfunction OptionGroupImpl({\n label,\n className,\n children,\n hidden,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n ref,\n ...rest\n}: OptionGroupProps) {\n const labelId = useId('option-group');\n const store = React.useContext(ListboxContext)?.store;\n const parentGroups = React.useContext(OptionGroupContext);\n const hiddenByConsumer = React.useContext(OptionGroupHiddenContext) || !!hidden;\n const [members] = React.useState(() => new OptionGroupMembers());\n const groups = React.useMemo(() => [...parentGroups, members], [parentGroups, members]);\n const subscribe = React.useCallback(\n (listener: () => void) => {\n const unsubscribeMembers = members.subscribe(listener);\n const unsubscribeStore = store?.subscribe(listener);\n return () => {\n unsubscribeMembers();\n unsubscribeStore?.();\n };\n },\n [members, store],\n );\n // Hidden while every option inside it is filtered out or hidden, also options wrapped in a\n // component (the options register with the group; re-read when they do and when the listbox\n // state changes).\n // The server render and the first client render show the group: no option has registered yet.\n const empty = React.useSyncExternalStore(\n subscribe,\n () => members.allHidden(store),\n () => false,\n );\n\n // The heading renders only for a label that renders content, so the list never points at an\n // empty heading. A consumer name wins over the heading; a prop that holds `undefined` (a wrapper\n // forwarding it) is no name of the consumer's.\n const hasLabel = slotRendersContent(label);\n const labelledBy = ariaLabelledBy ?? (ariaLabel === undefined && hasLabel ? labelId : undefined);\n\n // C-DEV: warn once when nothing names the group, checked again whenever the label, the\n // consumer `aria-label` or the resolved `aria-labelledby` changes.\n const headingRef = React.useRef<HTMLDivElement | null>(null);\n React.useEffect(() => {\n if (!isDev || hasWarned(UNNAMED_GROUP_WARNING)) return;\n if (groupHasName(label, ariaLabel, labelledBy, labelId, headingRef.current)) return;\n warnOnce(\n UNNAMED_GROUP_WARNING,\n 'OptionGroup: the group has no name. Give it a text `label`, `aria-label` or `aria-labelledby`.',\n );\n }, [label, ariaLabel, labelledBy, labelId]);\n\n return (\n <li\n {...rest}\n ref={ref}\n role=\"presentation\"\n hidden={hidden || empty || undefined}\n className={cn(optionGroupClassNames.root, className)}\n >\n {hasLabel && (\n <div\n ref={headingRef}\n id={labelId}\n role=\"presentation\"\n className={cn(\n optionGroupClassNames.label,\n 'px-3 py-1 text-caption-1 font-semibold text-muted-foreground',\n )}\n >\n {materialiseSlotContent(label)}\n </div>\n )}\n <ul\n role=\"group\"\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n className={optionGroupClassNames.list}\n >\n <OptionGroupHiddenContext.Provider value={hiddenByConsumer}>\n <OptionGroupContext.Provider value={groups}>{children}</OptionGroupContext.Provider>\n </OptionGroupHiddenContext.Provider>\n </ul>\n </li>\n );\n}\nOptionGroupImpl.displayName = 'OptionGroup';\n\n/**\n * Groups options under an optional heading: `<li role=\"presentation\">` with the heading and a\n * `<ul role=\"group\">` of the options, named by the heading (`label`) or by your `aria-label` or\n * `aria-labelledby`, which win over it. Hidden while a filter (or their own `hidden`) hides all\n * its options, also options wrapped in a component or in nested groups. Use it inside a listbox,\n * as `Option`.\n */\nexport const OptionGroup: React.FC<OptionGroupProps> = /* @__PURE__ */ markListboxElement(\n OptionGroupImpl,\n 'group',\n);\n\n/* ------------------------------------------------------------------ */\n/* ListboxProvider */\n/* ------------------------------------------------------------------ */\n\n/** Props of {@link ListboxProvider}. */\nexport interface ListboxProviderProps {\n /** The context of a listbox: `useListbox(...).context`. */\n value: ListboxContextValue;\n /** The options (`Option`, `OptionGroup` or options of your own on `useListboxOption`). */\n children?: React.ReactNode;\n}\n\n/**\n * Provides a listbox's context to its options, for a custom picker that renders its list without\n * `ListboxSurface`: `<ListboxProvider value={listbox.context}><ul {...listbox.getListboxProps()}>…</ul></ListboxProvider>`.\n */\nexport function ListboxProvider({ value, children }: ListboxProviderProps) {\n return <ListboxContext.Provider value={value}>{children}</ListboxContext.Provider>;\n}\nListboxProvider.displayName = 'ListboxProvider';\n\n/* ------------------------------------------------------------------ */\n/* Listbox popup: useListboxPopup and ListboxSurface */\n/* ------------------------------------------------------------------ */\n\n/** Options of {@link useListboxPopup}. */\nexport interface UseListboxPopupOptions {\n /**\n * The listbox is open (your open state). While it is, a press outside your picker and its\n * surface, and focus leaving them, dismiss it.\n */\n open: boolean;\n /**\n * The surface is shown (the list, or the empty content of {@link ListboxSurface}): it is\n * positioned, and Escape dismisses it. While the listbox is open with nothing shown (no options\n * to show), Escape is left to an enclosing layer, such as a Dialog around the picker.\n */\n surfaceOpen: boolean;\n /**\n * Called when the popup should close: set your open state to `false`. `reason` is `'escape'`,\n * `'outside-press'` or `'focus-outside'`.\n */\n onDismiss: (reason: DismissReason) => void;\n /** Your picker's root element: presses and focus inside it are not outside the popup. */\n rootRef: React.RefObject<HTMLElement | null>;\n /**\n * The combobox element, which anchors the popup's dismiss layer. Pass the element to\n * `setReference` too (merged into its ref), which places the surface against it.\n */\n anchorRef: React.RefObject<HTMLElement | null>;\n /**\n * Advanced positioning: `offset`, `fitViewport`, `matchReferenceWidth` and `fallbackPlacements`.\n * @default `{ matchReferenceWidth: true, fitViewport: true }`\n */\n positioning?: PopupPositioningOptions;\n}\n\n/**\n * Result of {@link useListboxPopup}. Destructure it: `eslint-plugin-react-hooks` treats an object\n * with a member passed to a `ref` prop as a ref, and rejects reading its other members during\n * render (`react-hooks/refs`).\n */\nexport interface UseListboxPopupResult {\n /** The popup's dismiss layer: pass it to {@link ListboxSurface}. */\n layerId: string;\n /**\n * Ref callback for the element the surface is placed against: merge it into your combobox's ref.\n */\n setReference: (el: HTMLElement | null) => void;\n /** Ref callback for the surface: pass it to {@link ListboxSurface}. */\n surfaceRef: React.RefCallback<HTMLElement>;\n /** The surface's `data-side`, `data-align` and position style: pass them to {@link ListboxSurface}. */\n floatingProps: { 'data-side': string; 'data-align': string; style: React.CSSProperties };\n}\n\n/**\n * Dismissal and positioning of a custom picker's listbox popup, for {@link ListboxSurface}. The\n * popup is dismissed by Escape, by a press outside your picker and its surface, and by focus\n * leaving them (`onDismiss` says which). The surface opens below the anchor and as wide as it,\n * flips above it when there is no room below, and is limited to the space available; its\n * `data-side` and `data-align` attributes give the final placement.\n *\n * While the listbox is open with nothing to show (`surfaceOpen` is `false`), Escape is left to an\n * enclosing layer, such as a Dialog around the picker. Let your combobox's key handler leave it\n * too: on such an Escape, set your open state to `false` without calling `listbox.onKeyDown`,\n * which handles Escape (and prevents its default) whenever the listbox is open. Do so only when\n * `!event.nativeEvent.isComposing`, as Dropdown, Combobox and TagPicker do: an Escape that only\n * cancels an IME composition must not close the listbox, and `listbox.onKeyDown` ignores such\n * keys too.\n *\n * @example\n * const expanded = open && listbox.items.length > 0;\n * const { layerId, setReference, surfaceRef, floatingProps } = useListboxPopup({\n * open,\n * surfaceOpen: expanded,\n * onDismiss: () => setOpen(false),\n * rootRef,\n * anchorRef: buttonRef,\n * });\n * const buttonMergedRef = useMergedRefs(buttonRef, setReference);\n */\nexport function useListboxPopup(options: UseListboxPopupOptions): UseListboxPopupResult {\n const { open, surfaceOpen, onDismiss, rootRef, anchorRef, positioning } = options;\n const surfaceElementRef = React.useRef<HTMLElement | null>(null);\n const { setReference, setFloating, floatingProps } = usePopupPosition({\n open: surfaceOpen,\n side: 'bottom',\n align: 'start',\n ...resolvePositioning(positioning, { matchReferenceWidth: true, fitViewport: true }),\n });\n const { layerId } = useDismiss({\n open,\n onDismiss: (reason) => onDismiss(reason),\n refs: [rootRef, surfaceElementRef],\n anchorRef,\n kind: 'listbox',\n escape: surfaceOpen,\n focusOutside: true,\n });\n const surfaceRef = useMergedRefs<HTMLElement>(surfaceElementRef, setFloating);\n return { layerId, setReference, surfaceRef, floatingProps };\n}\n\n/**\n * Attributes of the list element that ListboxSurface renders (see `listProps`). Its content is the\n * surface's `children`.\n */\nexport type ListboxSurfaceListProps = Omit<\n React.HTMLAttributes<HTMLUListElement>,\n | 'role'\n | 'id'\n | 'hidden'\n | 'tabIndex'\n | 'className'\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-multiselectable'\n | 'aria-activedescendant'\n | 'children'\n | 'dangerouslySetInnerHTML'\n> & {\n /** Ref to the `role=\"listbox\"` element (it moves between the picker and the popup). */\n ref?: React.Ref<HTMLUListElement>;\n};\n\n/**\n * Props of {@link ListboxSurface}. The options of one listbox live in one list at a time, and this\n * surface renders that list: render every option of the listbox inside it, never in a second list\n * of your own, not even for an exit animation.\n */\nexport interface ListboxSurfaceProps {\n /** The listbox: the result of `useListbox` in select-only or editable mode. */\n listbox: UseListboxResult;\n /** `layerId` from {@link useListboxPopup}: the surface joins the popup's dismiss layer. */\n layerId: string;\n /** `surfaceRef` from {@link useListboxPopup}. */\n surfaceRef: React.RefCallback<HTMLElement>;\n /** `floatingProps` from {@link useListboxPopup}: the surface's placement. */\n floatingProps: UseListboxPopupResult['floatingProps'];\n /** The listbox is open (your open state). `emptyContent` shows only while it is. */\n open: boolean;\n /**\n * The list is shown: the listbox is open and has options to show (`open &&\n * listbox.items.length > 0`). The list then renders in the surface, and otherwise `hidden`, in\n * place inside your picker. Set your combobox's `aria-expanded` to this value after spreading\n * `getComboboxProps()`, which reports `open`, so the combobox is not announced as expanded while\n * nothing is shown.\n */\n expanded: boolean;\n /**\n * Shown in the surface while the listbox is open but not expanded, such as a \"No matches\"\n * message. `undefined` and `null` show no surface; any other value shows one, so `false` and\n * `''` show an empty surface.\n */\n emptyContent?: React.ReactNode;\n /** Names the list. Name it with this or `aria-labelledby`, usually your picker's label. */\n 'aria-label'?: string;\n /** Ids of the elements that name the list, usually your picker's label. */\n 'aria-labelledby'?: string;\n /**\n * Options draw a check while selected (in a multi-select list, a checkbox square). Turn it off\n * for a list that never shows selected options, such as the suggestions of a tag picker.\n * @default true\n */\n showCheck?: boolean;\n /**\n * Classes merged last onto the list: they replace the list's own classes they conflict with,\n * its maximum height included.\n */\n listClassName?: string;\n /**\n * Classes merged last onto the surface, the popup around the list: they replace its own\n * classes they conflict with.\n */\n surfaceClassName?: string;\n /**\n * Attributes spread onto the list element before the listbox's own (`role`, `id`, `tabIndex`,\n * `aria-multiselectable`, `aria-activedescendant` and `hidden` win, also where the listbox\n * renders none of the last two): `data-*` and other `aria-*` attributes, `style`, and handlers,\n * composed before the listbox's own `onMouseDown`. `ref` is merged with the list's. Name the list\n * with `aria-label`/`aria-labelledby` (the props above), not here.\n */\n listProps?: ListboxSurfaceListProps;\n /** The options (`Option`, `OptionGroup` or options of your own on `useListboxOption`). */\n children?: React.ReactNode;\n}\n\nfunction preventMouseDown(event: React.MouseEvent) {\n event.preventDefault();\n}\n\n/**\n * The option list of a custom picker and the popup it opens in: a `<ul role=\"listbox\">` with the\n * options (spread from `listbox.getListboxProps()`), rendered `hidden` in place inside your\n * picker while the list is not shown, so the options register and their ids exist from the first\n * render, and in a portaled surface placed by {@link useListboxPopup} while it is, never in both.\n * While the listbox is open with nothing to show, the surface shows `emptyContent` instead, if\n * any. A press on the surface keeps focus on your combobox. It provides the listbox's context to\n * the options, so it needs no {@link ListboxProvider}.\n *\n * @example\n * <ListboxSurface\n * listbox={listbox}\n * layerId={layerId}\n * surfaceRef={surfaceRef}\n * floatingProps={floatingProps}\n * open={open}\n * expanded={expanded}\n * aria-labelledby={labelId}\n * >\n * <Option value=\"georgia\">Georgia</Option>\n * </ListboxSurface>\n */\nexport function ListboxSurface(props: ListboxSurfaceProps) {\n const {\n listbox,\n layerId,\n surfaceRef,\n floatingProps,\n open,\n expanded,\n emptyContent,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n showCheck = true,\n listClassName,\n surfaceClassName,\n listProps,\n children,\n } = props;\n\n // The consumer's list attributes go first, so the listbox's own win; its `onMouseDown` runs\n // before the list's (which keeps focus on the combobox) and its `ref` is merged with the list's.\n const { ref: listRefProp, onMouseDown: listMouseDown, ...listRest } = listProps ?? {};\n const listboxProps = listbox.getListboxProps();\n const listRef = useMergedRefs<HTMLUListElement>(listRefProp, listboxProps.ref);\n\n const list = (\n <OptionCheckContext.Provider value={showCheck}>\n <ListboxProvider value={listbox.context}>\n <ul\n {...listRest}\n {...listboxProps}\n // Absent from `listboxProps` when not set: a caller's value never survives the spread.\n aria-multiselectable={listboxProps['aria-multiselectable']}\n aria-activedescendant={listboxProps['aria-activedescendant']}\n onMouseDown={composeEventHandlers(listMouseDown, listboxProps.onMouseDown)}\n ref={listRef}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n hidden={!expanded || undefined}\n className={cn(\n listboxSurfaceClassNames.list,\n 'min-h-0 max-h-60 overflow-auto',\n listClassName,\n )}\n >\n {children}\n </ul>\n </ListboxProvider>\n </OptionCheckContext.Provider>\n );\n\n // A closed listbox never leaves a surface behind: the text typed before closing survives it.\n const showEmpty = open && !expanded && emptyContent !== undefined && emptyContent !== null;\n if (!expanded && !showEmpty) return list;\n\n return (\n <>\n {!expanded && list}\n <Portal layerId={layerId}>\n <div\n ref={surfaceRef}\n {...floatingProps}\n data-wave-listbox-surface=\"\"\n onMouseDown={preventMouseDown}\n className={cn(\n listboxSurfaceClassNames.root,\n 'flex flex-col overflow-hidden rounded border border-border bg-background py-1 text-foreground shadow-4',\n surfaceClassName,\n )}\n >\n {expanded ? list : emptyContent}\n </div>\n </Portal>\n </>\n );\n}\nListboxSurface.displayName = 'ListboxSurface';\n"],"mappings":";;;;;;;;;;;;;;;;;AAgFA,IAAMI,IAAqBD,EAAM,cAAc,EAAI;AACnD,EAAmB,cAAc;AAiBjC,IAAME,IAAiBC,EACrB,8FACA,8CACA,+EACA,6DACA,wDACA,sFACA,sEACF,GAMMC,IAAN,MAAyB;CACvB,yBAA0B,IAAI,IAAoB;CAClD,4BAA6B,IAAI,IAAgB;CAEjD,aAAa,OACX,KAAK,UAAU,IAAIC,CAAQ,SACd;EACX,KAAK,UAAU,OAAOA,CAAQ;CAChC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AwBA,SAAgBC,EAAe,GAA4B;CACzD,IAAM,EACJ,YACA,YACA,eACA,kBACA,SACA,aACA,iBACA,cAAcnC,GACd,mBAAmBK,GACnB,eAAY,IACZ,kBACA,qBACA,cACA,gBACEzC,GAIE,EAAE,KAAKwE,GAAa,aAAaC,GAAe,GAAGC,MAAaC,KAAa,CAAC,GAC9EC,IAAeC,EAAQ,gBAAgB,GACvCC,IAAUV,EAAgCI,GAAaI,EAAa,GAAG,GAEvEG,IACJ,kBAAC9G,EAAmB,UAApB;EAA6B,OAAOgC;EAClC,UAAA,kBAACuD,GAAD;GAAiB,OAAOqB,EAAQ;GAC9B,UAAA,kBAAC,MAAD;IACE,GAAIH;IACJ,GAAIE;IAEJ,wBAAsBA,EAAa;IACnC,yBAAuBA,EAAa;IACpC,aAAa3D,EAAqBwD,GAAeG,EAAa,WAAW;IACzE,KAAKE;IACL,cAAY1C;IACZ,mBAAiBK;IACjB,QAAQ,CAACuC,KAAY,KAAA;IACrB,WAAW7G,EACT8G,EAAyB,MACzB,kCACAC,CACF;IAEC;GACC,CAAA;EACW,CAAA;CACU,CAAA;CAO/B,OAFI,CAACF,MADa,MAASA,KAAYG,KAA+C,QAClDJ,IAGlC,kBAAAjH,GAAA,EAAA,UAAA,CACG,CAACkH,KAAYD,GACd,kBAACM,GAAD;EAAiB;EACf,UAAA,kBAAC,OAAD;GACE,KAAKC;GACL,GAAIC;GACJ,6BAA0B;GAC1B,aAAajB;GACb,WAAWnG,EACT8G,EAAyB,MACzB,0GACAO,CACF;GAEC,UAAAR,IAAWD,IAAOI;EAChB,CAAA;CACC,CAAA,CACR,EAAA,CAAA;AAEN;AACA,EAAe,cAAc"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),ee=require("../../lib/classNames.cjs"),i=require("../../hooks/useEventCallback.cjs"),a=require("../../hooks/useControllable.cjs"),te=require("../../hooks/useId.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),re=require("../../hooks/useIsClient.cjs"),ie=require("../../hooks/useFieldControl.cjs"),ae=require("../../hooks/useAnnounce.cjs"),oe=require("../../hooks/useListbox.cjs"),se=require("./inputLook.cjs"),ce=require("./Input.cjs"),le=require("../../hooks/useFormReset.cjs"),ue=require("../internal/HiddenInput.cjs"),de=require("./Option.cjs"),o=require("./pickerLabels.cjs"),s=require("./pickerValues.cjs"),fe=require("./TagPicker.context.cjs"),c=require("./TagPicker.create.cjs"),pe=require("./TagPicker.overflow.cjs"),l=require("./TagPicker.parts.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var me=[`medium`,`large`,`extra-large`],he=[],ge=new Map,_e={medium:`extra-small`,large:`small`,"extra-large":`medium`},ve=e=>`Remove ${e}`,ye=e=>`Selected: ${e.join(`, `)}`,be=e=>`Create "${e}"`,xe=e=>`+${e}`;function Se(e,t){return(e.textValue??e.label).toLowerCase().includes(t.toLowerCase())}function Ce(e){return`TagPicker: render exactly one trigger, \`TagPicker.Input\` or \`TagPicker.Button\`, inside \`TagPicker.Control\` (found ${e}).`}var we="TagPicker: `allowCreate` needs `TagPicker.Input`: `TagPicker.Button` has no text to create a tag from, so no create option is offered.",Te=`TagPicker.List: render one TagPicker.List, directly inside TagPicker (a Fragment is fine). A second list, or one inside a component of your own, splits the options over two lists.`;function Ee(e){if(e!=null){for(let{node:t}of n.flattenChildren(e))if(n.isElementOfType(t,l.TagPickerList))return t}}var f=e=>{let{options:n=he,children:f,value:De,defaultValue:Oe,onValueChange:ke,onChange:Ae,open:je,defaultOpen:Me,onOpenChange:Ne,placeholder:Pe=`Select...`,filter:Fe,query:Ie,defaultQuery:Le,onQueryChange:Re,disabled:p=!1,size:ze,appearance:Be,name:Ve,form:He,required:Ue,autoComplete:We=`off`,autoCapitalize:Ge,autoCorrect:Ke,maxLength:qe,readOnly:m=!1,allowCreate:h=!1,onOptionCreate:Je,clearable:Ye=!1,expandIcon:Xe,overflow:Ze=`wrap`,labels:g,inputMode:Qe,spellCheck:$e,enterKeyHint:et,autoFocus:tt,tabIndex:nt,id:rt,"aria-label":it,"aria-labelledby":at,"aria-describedby":ot,"aria-invalid":st,"aria-required":ct,"aria-errormessage":lt,"aria-details":ut,onFocus:dt,onBlur:ft,onKeyDown:pt,onKeyUp:mt,controlRef:ht,className:gt,ref:_t,...vt}=e;Ae!==void 0&&r.warnDeprecated(`TagPicker`,`onChange`,`onValueChange`);let _=Ze===`count`?`count`:`wrap`,yt=ie.useFieldContext(),bt=(Ue??yt?.required??!1)&&!m,{id:xt,"aria-label":v,"aria-labelledby":y,"aria-describedby":St,"aria-invalid":b,"aria-required":Ct}=ie.useFieldControl({id:rt,"aria-label":it,"aria-labelledby":at,"aria-describedby":ot,"aria-invalid":st,"aria-required":ct??Ue}),wt=ce.isInvalidLook(!1,b),{size:x,appearance:S}=se.useInputLook(ze,Be,{sizes:me,defaultSize:`medium`}),Tt=x===`medium`?`medium`:`large`,Et=_e[x],Dt=S===`filled-darker`?`outline`:`filled`,[C,w]=a.useControllable(De,Oe??s.EMPTY_VALUES,e=>{let t=[...e];ke?.(t),Ae?.(t)}),T=u.useMemo(()=>new Set(C),[C]),E=!p&&!m,[Ot,D]=a.useControllable(je,(Me??!1)&&E,Ne),kt=re.useIsClient(),O=Ot&&E&&kt,At=u.useRef(new Map),[k,jt]=u.useState(`input`),Mt=u.useCallback(e=>{let t={},n=At.current,r=()=>n.values().next().value??`input`;return n.set(t,e),jt(r()),()=>{n.delete(t),jt(r())}},[]),A=u.useRef(0),Nt=u.useCallback(()=>(A.current+=1,()=>{--A.current}),[]);u.useEffect(()=>{let e=At.current.size;e!==1&&r.warnOnce(`TagPicker:trigger`,Ce(e)),A.current>1&&r.warnOnce(`TagPicker.List:placement`,Te)});let j=k===`button`,[Pt,M]=a.useControllable(Ie,E?Le??``:``,Re),N=E&&!j?Pt:``,[P,Ft]=u.useState(E?`unlocked`:`mounted-locked`);E&&P!==`unlocked`?Ft(`unlocked`):!E&&P===`unlocked`&&Ft(`locked`),u.useEffect(()=>{P===`locked`&&M(``)},[P,M]);let It=!E&&Ot;u.useEffect(()=>{It&&D(!1)},[It,D]),ae.useAnnounce();let F=u.useRef(null),I=u.useRef(null),Lt=u.useRef(null),L=u.useRef(null),Rt=u.useRef(null),R=te.useId(`tagpicker-summary`),z=te.useId(`tagpicker-create`);u.useEffect(()=>{h&&j&&r.warnOnce(`TagPicker:allowCreate-button`,we)},[h,j]);let zt=Ee(f),B=zt?.props.children,V=B!=null,H=u.useMemo(()=>V?oe.collectOptionLabels(B):ge,[V,B]),U=u.useMemo(()=>{let e=new Map;for(let t of n)e.has(t.value)||e.set(t.value,t);return e},[n]),W=u.useMemo(()=>({remove:g?.remove??ve,selected:g?.selected??`Selected`,create:g?.create??be,clear:g?.clear??`Clear selection`,expand:g?.expand??`Show options`,overflowCount:g?.overflowCount??xe,noMatches:g?.noMatches??`No matches`}),[g]),Bt=h&&E&&!j&&O&&N.trim()!==``,G=Bt&&!V?c.createOptionText(N,{labels:n.map(e=>e.label),values:n.map(e=>e.value),selected:C}):null,Vt=u.useMemo(()=>{if(V)return;let e=n.filter(e=>!T.has(e.value)).map(e=>({value:e.value,label:e.label}));return G!==null&&e.push({value:z,label:W.create(G)}),e},[V,n,T,G,z,W]),Ht=u.useMemo(()=>{if(!V&&!N)return;let e=Fe??Se;return t=>t.value===z||!T.has(t.value)&&(N===``||e(t,N))},[V,N,Fe,T,z]),Ut=(e,t)=>{if(!E||C.includes(e))return;let n=[...C,e];w(n),M(``),o.announceToggle(g,t,!0,n.length)},Wt=()=>{let e=N.trim();if(!E||e===``)return;Je?.(e);let t=[...C,e];w(t),M(``),o.announceToggle(g,e,!0,t.length)},K=oe.useListbox({open:O,onOpenChange:e=>D(e),mode:j?`select-only`:`editable`,multiselect:!0,selectedValues:C,onSelect:(e,t)=>{e===z?Wt():Ut(e,t?.item.label??e)},items:Vt,filter:Ht,autoHighlight:j?`selected`:N?`first`:!1,idPrefix:`tagpicker-listbox`,onClearDraft:N&&!j?()=>M(``):void 0}),Gt=K.getItem,q=u.useCallback(e=>(V?Gt(e)?.label:void 0)??H.get(e)??U.get(e)?.label??e,[V,Gt,H,U]),J=G;if(Bt&&V){let e=K.items.filter(e=>e.value!==z);J=c.createOptionText(N,{labels:[...n.map(e=>e.label),...H.values(),...e.map(e=>e.label),...C.map(q)],values:[...n.map(e=>e.value),...H.keys(),...e.map(e=>e.value)],selected:C})}let Y=J!==null,X=O&&(K.items.length>0||Y),Kt=W.noMatches,Z=O&&(X||N!==``),qt=Z&&!X&&!Y,{layerId:Jt,setReference:Yt,surfaceRef:Xt,floatingProps:Zt}=de.useListboxPopup({open:O,surfaceOpen:Z,onDismiss:()=>D(!1),rootRef:F,anchorRef:I}),Qt=ne.useMergedRefs(F,_t);le.useFormReset(F,()=>{let e=Oe??s.EMPTY_VALUES;w(t=>s.sameValues(t,e)?t:[...e]),M(``)},He);let{focusWithin:$t,onFocus:en,onBlur:tn}=pe.useFocusWithin(_===`count`),Q=_===`count`&&!$t&&!O,nn=u.useMemo(()=>C.map(q),[C,q]),rn=pe.useTagOverflow({active:Q,values:C,labels:nn,control:Lt,group:L,chip:Rt,trigger:I}),$=i.useEventCallback(()=>{I.current?.focus()}),an=i.useEventCallback(()=>{E&&D(!O)}),on=i.useEventCallback(e=>{if(!E||!C.includes(e))return;let t=C.filter(t=>t!==e);w(t),o.announceToggle(g,q(e),!1,t.length)}),sn=i.useEventCallback(()=>{$(),E&&(C.length>0&&w([]),M(``),D(!1))}),cn=i.useEventCallback(e=>{if(!E)return;M(e),O||D(!0);let t=V?Array.from(H,([e,t])=>({value:e,label:t})):n;K.setActiveValue(c.findExactMatch(e,t,T))}),ln=i.useEventCallback(()=>{let e=L.current,t=e?l.tagListControls(e).at(-1):void 0;return t?.focus(),t!==void 0}),un=i.useEventCallback(e=>D(e)),dn=u.useCallback(e=>U.get(e),[U]),fn=u.useMemo(()=>({id:xt,"aria-label":v,"aria-labelledby":y,"aria-describedby":St,"aria-invalid":b,"aria-required":Ct,"aria-errormessage":lt,"aria-details":ut,tabIndex:nt,autoFocus:tt}),[xt,v,y,St,b,Ct,lt,ut,nt,tt]),pn=u.useMemo(()=>({autoComplete:We,autoCapitalize:Ge,autoCorrect:Ke,maxLength:qe,inputMode:Qe,spellCheck:$e,enterKeyHint:et,onFocus:dt,onBlur:ft,onKeyDown:pt,onKeyUp:mt,controlRef:ht}),[We,Ge,Ke,qe,Qe,$e,et,dt,ft,pt,mt,ht]),mn=v===void 0?y??yt?.labelId:y,hn=u.useMemo(()=>({"aria-label":v,"aria-labelledby":mn}),[v,mn]),gn=C.length>0,_n=u.useMemo(()=>({size:x,appearance:S,coreSize:Tt,tagSize:Et,tagAppearance:Dt,disabled:p,readOnly:m,interactive:E,invalidLook:wt,selected:C,labelOf:q,entryOf:dn,labels:W,placeholder:Pe,options:n,warnsUnknownValues:!V&&!h,dataMode:!V,listbox:K,open:O,expanded:X,query:N,surfaceOpen:Z,showCreate:Y,createText:J??``,createValue:z,emptyContent:N!==``&&!Y,layerId:Jt,surfaceRef:Xt,floatingProps:Zt,listLabel:hn,triggerProps:fn,inputProps:pn,summaryId:gn?R:void 0,triggerRef:I,setReference:Yt,controlRef:Lt,groupRef:L,chipRef:Rt,registerTrigger:Mt,registerList:Nt,triggerKind:k,setOpen:un,toggleOpen:an,focusTrigger:$,removeTag:on,clear:sn,editText:cn,focusLastTagControl:ln,expandIcon:Xe,clearable:Ye,overflow:_,collapsed:Q,hiddenValues:rn}),[x,S,Tt,Et,Dt,p,m,E,wt,C,q,dn,W,Pe,n,V,h,K,O,X,N,Z,Y,J,z,Jt,Xt,Zt,hn,fn,pn,gn,R,Yt,Mt,Nt,k,un,an,$,on,sn,cn,ln,Xe,Ye,_,Q,rn]),vn=f==null?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.TagPickerControl,{}),(0,d.jsx)(l.TagPickerList,{})]}):(0,d.jsxs)(d.Fragment,{children:[f,zt===void 0&&(0,d.jsx)(l.TagPickerList,{})]});return(0,d.jsxs)(`div`,{"data-size":x,"data-appearance":S,"data-overflow":_,"data-collapsed":Q?``:void 0,...vt,ref:Qt,className:t.cn(ee.tagPickerClassNames.root,`relative`,gt),onFocus:en,onBlur:tn,children:[(0,d.jsx)(fe.TagPickerContext.Provider,{value:_n,children:vn}),gn&&(0,d.jsx)(`span`,{id:R,hidden:!0,children:(g?.summary??ye)(C.map(q))}),(0,d.jsx)(`span`,{role:`status`,className:`sr-only`,children:qt&&Kt}),(0,d.jsx)(ue.HiddenInput,{name:Ve,form:He,disabled:p,value:C,type:`text`,required:bt,onInvalid:$})]})};f.displayName=`TagPicker`,exports.TagPickerRoot=f;
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),ee=require("../../lib/classNames.cjs"),i=require("../../hooks/useEventCallback.cjs"),a=require("../../hooks/useControllable.cjs"),te=require("../../hooks/useId.cjs"),ne=require("../../hooks/useMergedRefs.cjs"),re=require("../../hooks/useIsClient.cjs"),ie=require("../../hooks/useFieldControl.cjs"),ae=require("../../hooks/useAnnounce.cjs"),oe=require("../../hooks/useListbox.cjs"),se=require("./inputLook.cjs"),ce=require("./Input.cjs"),le=require("../../hooks/useFormReset.cjs"),ue=require("../internal/HiddenInput.cjs"),de=require("./Option.cjs"),o=require("./pickerLabels.cjs"),s=require("./pickerValues.cjs"),fe=require("./TagPicker.context.cjs"),c=require("./TagPicker.create.cjs"),pe=require("./TagPicker.overflow.cjs"),l=require("./TagPicker.parts.cjs");let u=require("react");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var me=[`medium`,`large`,`extra-large`],he=[],ge=new Map,_e={medium:`extra-small`,large:`small`,"extra-large":`medium`},ve=e=>`Remove ${e}`,ye=e=>`Selected: ${e.join(`, `)}`,be=e=>`Create "${e}"`,xe=e=>`+${e}`;function Se(e,t){return(e.textValue??e.label).toLowerCase().includes(t.toLowerCase())}function Ce(e){return`TagPicker: render exactly one trigger, \`TagPicker.Input\` or \`TagPicker.Button\`, inside \`TagPicker.Control\` (found ${e}).`}var we="TagPicker: `allowCreate` needs `TagPicker.Input`: `TagPicker.Button` has no text to create a tag from, so no create option is offered.",Te=`TagPicker.List: render one TagPicker.List, directly inside TagPicker (a Fragment is fine). A second list, or one inside a component of your own, splits the options over two lists.`;function Ee(e){if(e!=null){for(let{node:t}of n.flattenChildren(e))if(n.isElementOfType(t,l.TagPickerList))return t}}var f=e=>{let{options:n=he,children:f,value:De,defaultValue:Oe,onValueChange:ke,onChange:Ae,open:je,defaultOpen:Me,onOpenChange:Ne,placeholder:Pe=`Select...`,filter:Fe,query:Ie,defaultQuery:Le,onQueryChange:Re,disabled:p=!1,size:ze,positioning:Be,appearance:Ve,name:He,form:Ue,required:We,autoComplete:Ge=`off`,autoCapitalize:Ke,autoCorrect:qe,maxLength:Je,readOnly:m=!1,allowCreate:h=!1,onOptionCreate:Ye,clearable:Xe=!1,expandIcon:Ze,overflow:Qe=`wrap`,labels:g,inputMode:$e,spellCheck:et,enterKeyHint:tt,autoFocus:nt,tabIndex:rt,id:it,"aria-label":at,"aria-labelledby":ot,"aria-describedby":st,"aria-invalid":ct,"aria-required":lt,"aria-errormessage":ut,"aria-details":dt,onFocus:ft,onBlur:pt,onKeyDown:mt,onKeyUp:ht,controlRef:gt,className:_t,ref:vt,...yt}=e;Ae!==void 0&&r.warnDeprecated(`TagPicker`,`onChange`,`onValueChange`);let _=Qe===`count`?`count`:`wrap`,bt=ie.useFieldContext(),xt=(We??bt?.required??!1)&&!m,{id:St,"aria-label":v,"aria-labelledby":y,"aria-describedby":Ct,"aria-invalid":b,"aria-required":wt}=ie.useFieldControl({id:it,"aria-label":at,"aria-labelledby":ot,"aria-describedby":st,"aria-invalid":ct,"aria-required":lt??We}),Tt=ce.isInvalidLook(!1,b),{size:x,appearance:S}=se.useInputLook(ze,Ve,{sizes:me,defaultSize:`medium`}),Et=x===`medium`?`medium`:`large`,Dt=_e[x],Ot=S===`filled-darker`?`outline`:`filled`,[C,w]=a.useControllable(De,Oe??s.EMPTY_VALUES,e=>{let t=[...e];ke?.(t),Ae?.(t)}),T=u.useMemo(()=>new Set(C),[C]),E=!p&&!m,[kt,D]=a.useControllable(je,(Me??!1)&&E,Ne),At=re.useIsClient(),O=kt&&E&&At,jt=u.useRef(new Map),[k,Mt]=u.useState(`input`),Nt=u.useCallback(e=>{let t={},n=jt.current,r=()=>n.values().next().value??`input`;return n.set(t,e),Mt(r()),()=>{n.delete(t),Mt(r())}},[]),A=u.useRef(0),Pt=u.useCallback(()=>(A.current+=1,()=>{--A.current}),[]);u.useEffect(()=>{let e=jt.current.size;e!==1&&r.warnOnce(`TagPicker:trigger`,Ce(e)),A.current>1&&r.warnOnce(`TagPicker.List:placement`,Te)});let j=k===`button`,[Ft,M]=a.useControllable(Ie,E?Le??``:``,Re),N=E&&!j?Ft:``,[P,It]=u.useState(E?`unlocked`:`mounted-locked`);E&&P!==`unlocked`?It(`unlocked`):!E&&P===`unlocked`&&It(`locked`),u.useEffect(()=>{P===`locked`&&M(``)},[P,M]);let Lt=!E&&kt;u.useEffect(()=>{Lt&&D(!1)},[Lt,D]),ae.useAnnounce();let F=u.useRef(null),I=u.useRef(null),Rt=u.useRef(null),L=u.useRef(null),zt=u.useRef(null),R=te.useId(`tagpicker-summary`),z=te.useId(`tagpicker-create`);u.useEffect(()=>{h&&j&&r.warnOnce(`TagPicker:allowCreate-button`,we)},[h,j]);let Bt=Ee(f),Vt=Bt?.props.children,B=Vt!=null,V=u.useMemo(()=>B?oe.collectOptionLabels(Vt):ge,[B,Vt]),H=u.useMemo(()=>{let e=new Map;for(let t of n)e.has(t.value)||e.set(t.value,t);return e},[n]),U=u.useMemo(()=>({remove:g?.remove??ve,selected:g?.selected??`Selected`,create:g?.create??be,clear:g?.clear??`Clear selection`,expand:g?.expand??`Show options`,overflowCount:g?.overflowCount??xe,noMatches:g?.noMatches??`No matches`}),[g]),Ht=h&&E&&!j&&O&&N.trim()!==``,W=Ht&&!B?c.createOptionText(N,{labels:n.map(e=>e.label),values:n.map(e=>e.value),selected:C}):null,Ut=u.useMemo(()=>{if(B)return;let e=n.filter(e=>!T.has(e.value)).map(e=>({value:e.value,label:e.label}));return W!==null&&e.push({value:z,label:U.create(W)}),e},[B,n,T,W,z,U]),Wt=u.useMemo(()=>{if(!B&&!N)return;let e=Fe??Se;return t=>t.value===z||!T.has(t.value)&&(N===``||e(t,N))},[B,N,Fe,T,z]),Gt=(e,t)=>{if(!E||C.includes(e))return;let n=[...C,e];w(n),M(``),o.announceToggle(g,t,!0,n.length)},Kt=()=>{let e=N.trim();if(!E||e===``)return;Ye?.(e);let t=[...C,e];w(t),M(``),o.announceToggle(g,e,!0,t.length)},G=oe.useListbox({open:O,onOpenChange:e=>D(e),mode:j?`select-only`:`editable`,multiselect:!0,selectedValues:C,onSelect:(e,t)=>{e===z?Kt():Gt(e,t?.item.label??e)},items:Ut,filter:Wt,autoHighlight:j?`selected`:N?`first`:!1,idPrefix:`tagpicker-listbox`,onClearDraft:N&&!j?()=>M(``):void 0}),qt=G.getItem,K=u.useCallback(e=>(B?qt(e)?.label:void 0)??V.get(e)??H.get(e)?.label??e,[B,qt,V,H]),q=W;if(Ht&&B){let e=G.items.filter(e=>e.value!==z);q=c.createOptionText(N,{labels:[...n.map(e=>e.label),...V.values(),...e.map(e=>e.label),...C.map(K)],values:[...n.map(e=>e.value),...V.keys(),...e.map(e=>e.value)],selected:C})}let J=q!==null,Y=O&&(G.items.length>0||J),Jt=U.noMatches,X=O&&(Y||N!==``),Yt=X&&!Y&&!J,{layerId:Xt,setReference:Zt,surfaceRef:Qt,floatingProps:$t}=de.useListboxPopup({positioning:Be,open:O,surfaceOpen:X,onDismiss:()=>D(!1),rootRef:F,anchorRef:I}),en=ne.useMergedRefs(F,vt);le.useFormReset(F,()=>{let e=Oe??s.EMPTY_VALUES;w(t=>s.sameValues(t,e)?t:[...e]),M(``)},Ue);let{focusWithin:tn,onFocus:nn,onBlur:rn}=pe.useFocusWithin(_===`count`),Z=_===`count`&&!tn&&!O,an=u.useMemo(()=>C.map(K),[C,K]),on=pe.useTagOverflow({active:Z,values:C,labels:an,control:Rt,group:L,chip:zt,trigger:I}),Q=i.useEventCallback(()=>{I.current?.focus()}),sn=i.useEventCallback(()=>{E&&D(!O)}),cn=i.useEventCallback(e=>{if(!E||!C.includes(e))return;let t=C.filter(t=>t!==e);w(t),o.announceToggle(g,K(e),!1,t.length)}),ln=i.useEventCallback(()=>{Q(),E&&(C.length>0&&w([]),M(``),D(!1))}),un=i.useEventCallback(e=>{if(!E)return;M(e),O||D(!0);let t=B?Array.from(V,([e,t])=>({value:e,label:t})):n;G.setActiveValue(c.findExactMatch(e,t,T))}),dn=i.useEventCallback(()=>{let e=L.current,t=e?l.tagListControls(e).at(-1):void 0;return t?.focus(),t!==void 0}),fn=i.useEventCallback(e=>D(e)),pn=u.useCallback(e=>H.get(e),[H]),mn=u.useMemo(()=>({id:St,"aria-label":v,"aria-labelledby":y,"aria-describedby":Ct,"aria-invalid":b,"aria-required":wt,"aria-errormessage":ut,"aria-details":dt,tabIndex:rt,autoFocus:nt}),[St,v,y,Ct,b,wt,ut,dt,rt,nt]),hn=u.useMemo(()=>({autoComplete:Ge,autoCapitalize:Ke,autoCorrect:qe,maxLength:Je,inputMode:$e,spellCheck:et,enterKeyHint:tt,onFocus:ft,onBlur:pt,onKeyDown:mt,onKeyUp:ht,controlRef:gt}),[Ge,Ke,qe,Je,$e,et,tt,ft,pt,mt,ht,gt]),gn=v===void 0?y??bt?.labelId:y,_n=u.useMemo(()=>({"aria-label":v,"aria-labelledby":gn}),[v,gn]),$=C.length>0,vn=u.useMemo(()=>({size:x,appearance:S,coreSize:Et,tagSize:Dt,tagAppearance:Ot,disabled:p,readOnly:m,interactive:E,invalidLook:Tt,selected:C,labelOf:K,entryOf:pn,labels:U,placeholder:Pe,options:n,warnsUnknownValues:!B&&!h,dataMode:!B,listbox:G,open:O,expanded:Y,query:N,surfaceOpen:X,showCreate:J,createText:q??``,createValue:z,emptyContent:N!==``&&!J,layerId:Xt,surfaceRef:Qt,floatingProps:$t,listLabel:_n,triggerProps:mn,inputProps:hn,summaryId:$?R:void 0,triggerRef:I,setReference:Zt,controlRef:Rt,groupRef:L,chipRef:zt,registerTrigger:Nt,registerList:Pt,triggerKind:k,setOpen:fn,toggleOpen:sn,focusTrigger:Q,removeTag:cn,clear:ln,editText:un,focusLastTagControl:dn,expandIcon:Ze,clearable:Xe,overflow:_,collapsed:Z,hiddenValues:on}),[x,S,Et,Dt,Ot,p,m,E,Tt,C,K,pn,U,Pe,n,B,h,G,O,Y,N,X,J,q,z,Xt,Qt,$t,_n,mn,hn,$,R,Zt,Nt,Pt,k,fn,sn,Q,cn,ln,un,dn,Ze,Xe,_,Z,on]),yn=f==null?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l.TagPickerControl,{}),(0,d.jsx)(l.TagPickerList,{})]}):(0,d.jsxs)(d.Fragment,{children:[f,Bt===void 0&&(0,d.jsx)(l.TagPickerList,{})]});return(0,d.jsxs)(`div`,{"data-size":x,"data-appearance":S,"data-overflow":_,"data-collapsed":Z?``:void 0,...yt,ref:en,className:t.cn(ee.tagPickerClassNames.root,`relative`,_t),onFocus:nn,onBlur:rn,children:[(0,d.jsx)(fe.TagPickerContext.Provider,{value:vn,children:yn}),$&&(0,d.jsx)(`span`,{id:R,hidden:!0,children:(g?.summary??ye)(C.map(K))}),(0,d.jsx)(`span`,{role:`status`,className:`sr-only`,children:Yt&&Jt}),(0,d.jsx)(ue.HiddenInput,{name:He,form:Ue,disabled:p,value:C,type:`text`,required:xt,onInvalid:Q})]})};f.displayName=`TagPicker`,exports.TagPickerRoot=f;
2
2
  //# sourceMappingURL=TagPicker.root.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"TagPicker.root.cjs","names":["flattenChildren","isElementOfType","TagPickerList","useFieldContext","useFieldControl","isInvalidLook","useInputLook","useControllable","EMPTY_VALUES","React","useIsClient","useId","collectOptionLabels","createOptionText","useListbox","useListboxPopup","useMergedRefs","sameValues","useFocusWithin","useTagOverflow","useEventCallback","findExactMatch","tagListControls","_Fragment","TagPickerControl","cn","tagPickerClassNames","TagPickerContext","HiddenInput","require_runtime","require_cn","require_children","require_dev","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_useMergedRefs","require_useIsClient","require_useFieldControl","require_useAnnounce","require_useListbox","require_inputLook","require_Input","require_useFormReset","require_HiddenInput","require_Option","require_pickerLabels","require_pickerValues","require_TagPicker_context","require_TagPicker_create","require_TagPicker_overflow","require_TagPicker_parts","react","react_jsx_runtime","TAG_PICKER_SIZES","EMPTY_OPTIONS","EMPTY_LABELS","TAG_SIZE","defaultRemoveLabel","label","defaultSummaryLabel","labels","defaultCreateLabel","text","defaultOverflowCountLabel","count","matchesText","item","triggerMessage","ALLOW_CREATE_BUTTON_MESSAGE","LIST_PLACEMENT_MESSAGE","findList","children","node","TagPickerRoot","valueProp","openProp","queryProp","sizeProp","appearanceProp","overflowProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","props","onChange","overflow","field","validates","required","readOnly","triggerId","triggerLabel","triggerLabelledBy","triggerDescribedBy","triggerInvalid","triggerRequired","invalidLook","coreSize","size","tagSize","tagAppearance","appearance","selected","setSelected","defaultValue","list","next","onValueChange","selectedSet","interactive","disabled","openState","setOpen","defaultOpen","onOpenChange","isClient","open","triggersRef","triggerKind","setTriggerKind","registerTrigger","token","triggers","firstKind","kind","listCountRef","registerList","isButtonTrigger","queryState","setQuery","defaultQuery","onQueryChange","query","lock","setLock","lockedOpen","rootRef","triggerRef","controlElementRef","groupRef","chipRef","summaryId","createValue","allowCreate","listElement","listChildren","registration","collected","optionByValue","map","option","options","resolvedLabels","offersCreate","dataCreateText","items","available","listFilter","matches","filter","addTag","value","commitCreate","onOptionCreate","listbox","details","getItem","labelOf","createText","listed","showCreate","expanded","noMatchesText","surfaceOpen","noMatches","rootMergedRef","ref","initial","current","form","trackFocus","trackBlur","collapsed","focusWithin","tagLabels","hiddenValues","focusTrigger","toggleOpen","removeTag","v","clear","editText","candidates","focusLastTagControl","group","last","setOpenStable","entryOf","triggerProps","tabIndex","autoFocus","inputProps","autoComplete","autoCapitalize","autoCorrect","maxLength","inputMode","spellCheck","enterKeyHint","onFocus","onBlur","onKeyDown","onKeyUp","controlRef","listLabelledBy","listLabel","hasSummary","context","placeholder","layerId","surfaceRef","floatingProps","setReference","expandIcon","clearable","parts","className"],"sources":["../../../src/components/input/TagPicker.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { tagPickerClassNames } from '../../lib/classNames';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport type { Slot } from '../../lib/slot';\nimport type { CoreSize, InputAppearance, Size, TagAppearance, TagSize } from '../../lib/types';\nimport { useAnnounce } from '../../hooks/useAnnounce';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { collectOptionLabels, useListbox, type ListboxItem } from '../../hooks/useListbox';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { useInputLook } from './inputLook';\nimport { isInvalidLook } from './Input';\nimport { useListboxPopup } from './Option';\nimport { announceToggle } from './pickerLabels';\nimport { EMPTY_VALUES, sameValues } from './pickerValues';\nimport type { RoutedHandlers } from './routedHandlers';\nimport { TagPickerContext } from './TagPicker.context';\nimport type {\n ResolvedTagPickerLabels,\n TagPickerContextValue,\n TagPickerInputOnlyProps,\n TagPickerTriggerKind,\n TagPickerTriggerProps,\n} from './TagPicker.context';\nimport { createOptionText, findExactMatch } from './TagPicker.create';\nimport type { ExactMatchCandidate } from './TagPicker.create';\nimport type { TagPickerOption } from './TagPicker.option';\nimport { useFocusWithin, useTagOverflow } from './TagPicker.overflow';\nimport { TagPickerControl, TagPickerList, tagListControls } from './TagPicker.parts';\n\n/**\n * The TagPicker's built-in names, descriptions and announcements, for localization. Each member is\n * optional and falls back to its English default.\n */\nexport interface TagPickerLabels {\n /** Name of a tag's remove button.\n * @default (label) => `Remove ${label}`\n */\n remove?: (label: string) => string;\n /** Name of the list of selected tags.\n * @default 'Selected'\n */\n selected?: string;\n /** Description of the input that sums up the selected tags (their labels, in order).\n * @default (labels) => `Selected: ${labels.join(', ')}`\n */\n summary?: (labels: string[]) => string;\n /** Announcement when a tag is added; `count` is the number of tags after the change.\n * @default (label, count) => `${label} added, ${count} selected`\n */\n added?: (label: string, count: number) => string;\n /** Announcement when a tag is removed; `count` is the number of tags after the change.\n * @default (label, count) => `${label} removed, ${count} selected`\n */\n removed?: (label: string, count: number) => string;\n /** Status text (announced, and shown in the popup) when the typed text matches no option.\n * @default 'No matches'\n */\n noMatches?: string;\n /**\n * Text and name of the create option (`allowCreate`), from the trimmed typed text.\n * @default (text) => `Create \"${text}\"`\n */\n create?: (text: string) => string;\n /** Name of the clear button (`clearable`). @default 'Clear selection' */\n clear?: string;\n /** Name of the expand button at the end of the field. @default 'Show options' */\n expand?: string;\n /**\n * The \"+N\" text of the single-line layout (`overflow=\"count\"`); hidden from assistive\n * technology, which hears the input's summary of every tag.\n * @default (count) => `+${count}`\n */\n overflowCount?: (count: number) => string;\n}\n\n/** Sizes of TagPicker (Fluent's): medium (the 0.7 look), large and extra-large. */\nexport type TagPickerSize = Extract<Size, 'medium' | 'large' | 'extra-large'>;\n\n/** Properties for the TagPicker component. */\nexport interface TagPickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | RoutedHandlers\n> {\n /**\n * The options, the array form (`{ value, label, media?, secondaryContent? }`). With parts whose\n * `TagPicker.List` has children it only names values (tags, announcements). Changed in 0.11:\n * optional.\n */\n options?: readonly TagPickerOption[];\n /**\n * The parts: `TagPicker.Control` and `TagPicker.List`, directly inside TagPicker (a Fragment is\n * fine). Without children TagPicker renders both with their defaults; without a\n * `TagPicker.List` it renders the default list after the children.\n */\n children?: React.ReactNode;\n /**\n * Controlled array of selected option values (`[]` for none). Fluent's `selectedOptions`.\n */\n value?: readonly string[];\n /**\n * Initial selected values for uncontrolled usage; a form reset restores them.\n * @default []\n */\n defaultValue?: readonly string[];\n /**\n * Called with the new selection when it changes: a tag is added (an option, or a created tag)\n * or removed, or a form reset restores different tags. Fluent's `onOptionSelect`.\n */\n onValueChange?: (value: string[]) => void;\n /**\n * Called with the new selection when it changes: a tag is added or removed, or a form reset\n * restores different tags.\n * @deprecated Use `onValueChange`.\n */\n onChange?: (value: string[]) => void;\n /**\n * Controlled open state of the option list. The list renders only in the browser: an open\n * picker is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage. A picker that starts disabled or read-only starts\n * closed. The list renders only in the browser: it is closed in the server HTML and opens once\n * the picker has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /** Called when the option list opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Shown by TagPicker.Input or TagPicker.Button while no tag is selected; the part's own\n * `placeholder` wins.\n * @default 'Select...'\n */\n placeholder?: string;\n /**\n * Whether an option matches the typed text (the query). Called with every listed option, also\n * the options of `TagPicker.List`'s children (its `value`, `label` and `textValue`), and the\n * text whenever the text is not empty, never with a selected option or the create option; an\n * option it returns `false` for is filtered out. It may keep options that do not contain the\n * text: `filter={() => true}` with `query` and `onQueryChange` leaves the matching to you (a\n * server-side search that replaces `options`); for a create entry, use `allowCreate`. With a\n * server-side search, keep the selected options in `options` (they are never listed): a\n * selected value without an option shows its raw value as the tag label, with a development\n * warning (the \"Async search\" story does this).\n * @default a case-insensitive substring match on the option's `textValue ?? label`\n */\n filter?: (option: ListboxItem, query: string) => boolean;\n /**\n * Controlled query: the text typed since the last tag was added, which filters the options and\n * shows in the input (hidden while `disabled` or `readOnly`). Not used with TagPicker.Button.\n */\n query?: string;\n /**\n * Initial query for uncontrolled usage. A TagPicker that starts disabled or read-only starts\n * without it (as it starts closed). Not used with TagPicker.Button.\n * @default ''\n */\n defaultQuery?: string;\n /**\n * Called with the new query when it changes: as the user types, and with `''` when it resets (a\n * tag added or created, Escape on the closed list, the clear button, a form reset, or `disabled`\n * or `readOnly` turned on while text is typed). A blur or a close keeps the text. A TagPicker\n * that mounts disabled or read-only reports nothing: it keeps a controlled query, which shows\n * once it unlocks. Not used with TagPicker.Button.\n */\n onQueryChange?: (query: string) => void;\n /**\n * Whether the tag picker is disabled: nothing can be added or removed, the remove buttons leave\n * the tab order, and the expand and clear buttons are disabled. The field dims once.\n * @default false\n */\n disabled?: boolean;\n /**\n * Size of the tags and the field: `medium` (the 0.7 look), `large` or `extra-large` (Fluent's\n * union; TagPicker has no `small`). Default: the surrounding Field's `size`, else `WaveProvider\n * inputDefaults.size`, else `'medium'`; a Field or provider `small` gives `'medium'` too. Its\n * tags are one Tag size smaller: medium → extra-small, large → small, extra-large → medium. The\n * option list keeps its size.\n */\n size?: TagPickerSize;\n /**\n * Look of the field: `outline` (a full border), `underline` (a bottom stroke only),\n * `filled-darker` or `filled-lighter` (a fill without a visible stroke: give the field a visible\n * label). Default: `WaveProvider inputDefaults.appearance`, else `'outline'`. The tags are\n * filled, outlined on `filled-darker`.\n */\n appearance?: InputAppearance;\n /** Name of the values in form submissions (one hidden input per value). */\n name?: string;\n /** Id of the form the values belong to, when the TagPicker is outside it. */\n form?: string;\n /**\n * At least one tag is required to submit the form (native constraint validation). Like a native\n * readonly input, a `readOnly` TagPicker does not block submission.\n */\n required?: boolean;\n /**\n * The `autocomplete` attribute of TagPicker.Input's `<input role=\"combobox\">`. Browser autofill\n * is off unless you set it (for example `'on'`). With TagPicker.Button, not used.\n * @default 'off'\n */\n autoComplete?: string;\n /**\n * The maximum length of the typed text (`maxlength` of TagPicker.Input's `<input>`). With\n * TagPicker.Button, not used.\n */\n maxLength?: number;\n /**\n * The selection cannot be changed: the trigger is read-only, the tags have no remove buttons,\n * the expand button is disabled and the clear button hidden, and the option list neither opens\n * (click, keyboard, a controlled `open`) nor adds tags; Escape is left to the page. Turning it\n * (or `disabled`) on while the list is open closes it (`onOpenChange(false)`); a focused remove\n * button hands focus to the trigger.\n */\n readOnly?: boolean;\n /**\n * Lets the user add a tag of their own text: while the trimmed text matches no option label\n * and no selected value (ignoring case) and no option value, the list ends with a create option\n * (`labels.create`); Enter on it or a click adds the text as a tag, calls `onOptionCreate`, and\n * clears the text. Needs `TagPicker.Input` (not `TagPicker.Button`). WaveUI-only: Fluent's\n * TagPicker has no free tagging.\n * @default false\n */\n allowCreate?: boolean;\n /**\n * Called with the trimmed text when the user creates a tag, before `onValueChange` reports the\n * new value. Add an option for it if you keep options: until then the tag shows the raw text.\n * WaveUI-only (see `allowCreate`).\n */\n onOptionCreate?: (text: string) => void;\n /**\n * Shows a clear button at the end of the field while a tag is selected (not while `readOnly`;\n * disabled while `disabled`): it removes every tag (`onValueChange([])`), clears the typed\n * text, closes the list and focuses the trigger (the input, or `TagPicker.Button`). A Tab stop\n * after the trigger. The name of Fluent's Combobox and Dropdown prop.\n * @default false\n */\n clearable?: boolean;\n /**\n * The glyph of the expand button at the end of the field (default: a chevron). The button\n * opens and closes the list, keeps focus on the trigger and is not a Tab stop. `null` or\n * `undefined` keep the chevron; `false`, or a value that renders nothing, hides the button.\n * Decorative: a `<button>` passed here is unwrapped. `TagPicker.Control`'s `expandIcon` wins.\n */\n expandIcon?: Slot<'span'>;\n /**\n * `'wrap'`: the tags wrap onto more lines. `'count'`: while focus is outside the picker and its\n * list is closed, the tags stay on one line and the ones that do not fit give way to \"+N\"\n * (`labels.overflowCount`); focusing the picker shows them all. The tags are measured by\n * position: your own Tags in `TagPicker.Group` render in `value` order. WaveUI-only: Fluent's\n * single-line layout is a story, not a prop.\n * @default 'wrap'\n */\n overflow?: 'wrap' | 'count';\n /**\n * Names of the remove buttons and the tag list, the summary that describes the trigger, the\n * announcements, the \"No matches\" text, the create option, the clear and expand buttons and the\n * \"+N\" count, for localization. Unset members keep their English defaults.\n */\n labels?: TagPickerLabels;\n /**\n * Called when TagPicker.Input's `<input role=\"combobox\">` receives focus (the root keeps other\n * handlers). With TagPicker.Button, pass it (and `ref`) on the Button.\n */\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n /** Called when TagPicker.Input's `<input>` loses focus. With TagPicker.Button, pass it on the Button. */\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n /**\n * Called on a key press in TagPicker.Input's `<input>`, after the Input's own `onKeyDown` and\n * before the built-in listbox and tag keys; `event.preventDefault()` skips them. With\n * TagPicker.Button, pass it on the Button.\n */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Called when a key is released in TagPicker.Input's `<input>`. With TagPicker.Button, pass it on the Button. */\n onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;\n /**\n * Ref to TagPicker.Input's `<input role=\"combobox\">` (the focusable element). With\n * TagPicker.Button, pass `ref` on the Button.\n */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * How the picker came to be locked (`disabled` or `readOnly`): not at all, by a change while\n * mounted, or since it mounted.\n */\ntype LockState = 'unlocked' | 'locked' | 'mounted-locked';\n\nconst TAG_PICKER_SIZES: readonly TagPickerSize[] = ['medium', 'large', 'extra-large'];\nconst EMPTY_OPTIONS: readonly TagPickerOption[] = [];\nconst EMPTY_LABELS: ReadonlyMap<string, string> = new Map();\n\n/** The tag size of each picker size (Fluent's mapping, D54). */\nconst TAG_SIZE: Readonly<Record<TagPickerSize, TagSize>> = {\n medium: 'extra-small',\n large: 'small',\n 'extra-large': 'medium',\n};\n\nconst defaultRemoveLabel = (label: string) => `Remove ${label}`;\nconst defaultSummaryLabel = (labels: string[]) => `Selected: ${labels.join(', ')}`;\nconst defaultCreateLabel = (text: string) => `Create \"${text}\"`;\nconst defaultOverflowCountLabel = (count: number) => `+${count}`;\n\n/** The default `filter` (Phase 5 D13): a case-insensitive substring of `textValue ?? label`. */\nfunction matchesText(item: ListboxItem, text: string): boolean {\n return (item.textValue ?? item.label).toLowerCase().includes(text.toLowerCase());\n}\n\nfunction triggerMessage(count: number): string {\n return `TagPicker: render exactly one trigger, \\`TagPicker.Input\\` or \\`TagPicker.Button\\`, inside \\`TagPicker.Control\\` (found ${count}).`;\n}\n\nconst ALLOW_CREATE_BUTTON_MESSAGE =\n 'TagPicker: `allowCreate` needs `TagPicker.Input`: `TagPicker.Button` has no text to create a tag from, so no create option is offered.';\n\nconst LIST_PLACEMENT_MESSAGE =\n 'TagPicker.List: render one TagPicker.List, directly inside TagPicker (a Fragment is fine). A second list, or one inside a component of your own, splits the options over two lists.';\n\n/** The `TagPicker.List` among the direct children and Fragments, if any (D50). */\nfunction findList(\n children: React.ReactNode,\n): React.ReactElement<{ children?: React.ReactNode }> | undefined {\n if (children === null || children === undefined) return undefined;\n for (const { node } of flattenChildren(children)) {\n if (isElementOfType<{ children?: React.ReactNode }>(node, TagPickerList)) return node;\n }\n return undefined;\n}\n\nexport const TagPickerRoot = (props: TagPickerProps) => {\n const {\n options = EMPTY_OPTIONS,\n children,\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n open: openProp,\n defaultOpen,\n onOpenChange,\n placeholder = 'Select...',\n filter,\n query: queryProp,\n defaultQuery,\n onQueryChange,\n disabled = false,\n size: sizeProp,\n appearance: appearanceProp,\n name,\n form,\n required,\n autoComplete = 'off',\n autoCapitalize,\n autoCorrect,\n maxLength,\n readOnly = false,\n allowCreate = false,\n onOptionCreate,\n clearable = false,\n expandIcon,\n overflow: overflowProp = 'wrap',\n labels,\n inputMode,\n spellCheck,\n enterKeyHint,\n autoFocus,\n tabIndex,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n ref,\n ...rest\n } = props;\n\n if (onChange !== undefined) warnDeprecated('TagPicker', 'onChange', 'onValueChange');\n const overflow = overflowProp === 'count' ? 'count' : 'wrap';\n\n const field = useFieldContext();\n const isRequired = required ?? field?.required ?? false;\n // Like a native readonly input, a read-only TagPicker is barred from constraint validation (the\n // user could not fix it); its values are still submitted.\n const validates = isRequired && !readOnly;\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required matches\n // `isRequired`.\n 'aria-required': ariaRequired ?? required,\n });\n const {\n id: triggerId,\n 'aria-label': triggerLabel,\n 'aria-labelledby': triggerLabelledBy,\n 'aria-describedby': triggerDescribedBy,\n 'aria-invalid': triggerInvalid,\n 'aria-required': triggerRequired,\n } = fieldProps;\n // The error look follows the resolved state: the consumer's `aria-invalid` or the Field's.\n const invalidLook = isInvalidLook(false, triggerInvalid);\n const { size, appearance } = useInputLook(sizeProp, appearanceProp, {\n sizes: TAG_PICKER_SIZES,\n defaultSize: 'medium',\n });\n const coreSize: CoreSize = size === 'medium' ? 'medium' : 'large';\n const tagSize = TAG_SIZE[size];\n // A muted tag would barely show on the darker fill: outlined there (D54).\n const tagAppearance: TagAppearance = appearance === 'filled-darker' ? 'outline' : 'filled';\n\n const [selected, setSelected] = useControllable<readonly string[]>(\n valueProp,\n defaultValue ?? EMPTY_VALUES,\n (next) => {\n // The props are read only; the callbacks receive an array of their own.\n const list = [...next];\n onValueChange?.(list);\n onChange?.(list);\n },\n );\n const selectedSet = React.useMemo(() => new Set(selected), [selected]);\n const interactive = !disabled && !readOnly;\n // A picker that starts disabled or read-only never shows its list, so it starts closed (no close\n // to report later).\n const [openState, setOpen] = useControllable(\n openProp,\n (defaultOpen ?? false) && interactive,\n onOpenChange,\n );\n // The open list lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the picker shows the closed inline list and reports it closed, so\n // aria-controls and aria-activedescendant never name a missing element.\n const isClient = useIsClient();\n const open = openState && interactive && isClient;\n // The trigger parts (D63): their kind decides the listbox mode; the server HTML and the first\n // render use the editable mode of `TagPicker.Input`.\n const triggersRef = React.useRef(new Map<object, TagPickerTriggerKind>());\n const [triggerKind, setTriggerKind] = React.useState<TagPickerTriggerKind>('input');\n const registerTrigger = React.useCallback((kind: TagPickerTriggerKind) => {\n const token = {};\n const triggers = triggersRef.current;\n const firstKind = () => triggers.values().next().value ?? 'input';\n triggers.set(token, kind);\n setTriggerKind(firstKind());\n return () => {\n triggers.delete(token);\n setTriggerKind(firstKind());\n };\n }, []);\n const listCountRef = React.useRef(0);\n const registerList = React.useCallback(() => {\n listCountRef.current += 1;\n return () => {\n listCountRef.current -= 1;\n };\n }, []);\n // After every commit (every part's layout effect has run): exactly one trigger and one List.\n React.useEffect(() => {\n const triggers = triggersRef.current.size;\n if (triggers !== 1) warnOnce('TagPicker:trigger', triggerMessage(triggers));\n if (listCountRef.current > 1) warnOnce('TagPicker.List:placement', LIST_PLACEMENT_MESSAGE);\n });\n const isButtonTrigger = triggerKind === 'button';\n\n // The query (D12): the text typed since the last tag was added, which filters the options. A\n // picker that starts locked starts without a query, as it starts closed.\n const [queryState, setQuery] = useControllable(\n queryProp,\n interactive ? (defaultQuery ?? '') : '',\n onQueryChange,\n );\n // Locking the control (readOnly/disabled) while typing drops the typed text: hidden during\n // render here, and the reset reported from an effect, since `onQueryChange` never runs during\n // render (D12). `lock` is how the picker came to be locked (previous-value pattern, C-HOOKS):\n // `'locked'` by a change while mounted, whose reset is reported once, or `'mounted-locked'`\n // since it mounted, which reports nothing and keeps a controlled query, hidden until the picker\n // unlocks (R20).\n // `TagPicker.Button` has no text entry, so no query filters its list (D63).\n const query = interactive && !isButtonTrigger ? queryState : '';\n const [lock, setLock] = React.useState<LockState>(interactive ? 'unlocked' : 'mounted-locked');\n if (interactive && lock !== 'unlocked') setLock('unlocked');\n else if (!interactive && lock === 'unlocked') setLock('locked');\n React.useEffect(() => {\n if (lock === 'locked') setQuery('');\n }, [lock, setQuery]);\n // Locking also closes the list itself, not only the derived `open`, so unlocking does not reopen\n // it without a user action. The close is reported through onOpenChange (a consumer callback from\n // an effect, C-HOOKS); a controlled `open` that stays true is still not shown while locked.\n const lockedOpen = !interactive && openState;\n React.useEffect(() => {\n if (lockedOpen) setOpen(false);\n }, [lockedOpen, setOpen]);\n // Keeps the shared live regions alive while mounted: every addition and removal is announced\n // (`announceToggle`).\n useAnnounce();\n\n const rootRef = React.useRef<HTMLDivElement | null>(null);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const controlElementRef = React.useRef<HTMLDivElement | null>(null);\n const groupRef = React.useRef<HTMLDivElement | null>(null);\n const chipRef = React.useRef<HTMLSpanElement | null>(null);\n const summaryId = useId('tagpicker-summary');\n const createValue = useId('tagpicker-create');\n\n React.useEffect(() => {\n if (allowCreate && isButtonTrigger) {\n warnOnce('TagPicker:allowCreate-button', ALLOW_CREATE_BUTTON_MESSAGE);\n }\n }, [allowCreate, isButtonTrigger]);\n\n // The parts form (D50): a List among the direct children with children of its own switches the\n // listbox to registration mode; `options` then only names values.\n const listElement = findList(children);\n const listChildren = listElement?.props.children;\n const registration = listChildren !== undefined && listChildren !== null;\n const collected = React.useMemo(\n () => (registration ? collectOptionLabels(listChildren) : EMPTY_LABELS),\n [registration, listChildren],\n );\n\n const optionByValue = React.useMemo(() => {\n const map = new Map<string, TagPickerOption>();\n for (const option of options) if (!map.has(option.value)) map.set(option.value, option);\n return map;\n }, [options]);\n\n const resolvedLabels = React.useMemo<ResolvedTagPickerLabels>(\n () => ({\n remove: labels?.remove ?? defaultRemoveLabel,\n selected: labels?.selected ?? 'Selected',\n create: labels?.create ?? defaultCreateLabel,\n clear: labels?.clear ?? 'Clear selection',\n expand: labels?.expand ?? 'Show options',\n overflowCount: labels?.overflowCount ?? defaultOverflowCountLabel,\n noMatches: labels?.noMatches ?? 'No matches',\n }),\n [labels],\n );\n\n // The create option (D59) needs the text input, an interactive picker and an open list.\n const offersCreate =\n allowCreate && interactive && !isButtonTrigger && open && query.trim() !== '';\n // Data mode: the duplicate check reads every `options` entry, before the listbox, since the\n // create item is one of its items.\n const dataCreateText =\n offersCreate && !registration\n ? createOptionText(query, {\n labels: options.map((option) => option.label),\n values: options.map((option) => option.value),\n selected,\n })\n : null;\n\n const items = React.useMemo<ListboxItem[] | undefined>(() => {\n if (registration) return undefined;\n const available: ListboxItem[] = options\n .filter((option) => !selectedSet.has(option.value))\n .map((option) => ({ value: option.value, label: option.label }));\n if (dataCreateText !== null) {\n available.push({ value: createValue, label: resolvedLabels.create(dataCreateText) });\n }\n return available;\n }, [registration, options, selectedSet, dataCreateText, createValue, resolvedLabels]);\n\n // useListbox's navigability predicate (D58): the create option always, never a selected option,\n // and `filter` (else the default) bound to the typed text while there is any.\n const listFilter = React.useMemo(() => {\n if (!registration && !query) return undefined;\n const matches = filter ?? matchesText;\n return (item: ListboxItem) =>\n item.value === createValue ||\n (!selectedSet.has(item.value) && (query === '' || matches(item, query)));\n }, [registration, query, filter, selectedSet, createValue]);\n\n // Adds a listed option (`label`: the committed item's).\n const addTag = (value: string, label: string) => {\n if (!interactive || selected.includes(value)) return;\n const next = [...selected, value];\n setSelected(next);\n setQuery('');\n announceToggle(labels, label, true, next.length);\n };\n\n // Creates a tag of the trimmed text (D59): the create option was offered for it.\n const commitCreate = () => {\n const text = query.trim();\n if (!interactive || text === '') return;\n onOptionCreate?.(text);\n const next = [...selected, text];\n setSelected(next);\n setQuery('');\n announceToggle(labels, text, true, next.length);\n };\n\n const listbox = useListbox({\n open,\n onOpenChange: (next) => setOpen(next),\n mode: isButtonTrigger ? 'select-only' : 'editable',\n multiselect: true,\n selectedValues: selected,\n onSelect: (value, details) => {\n if (value === createValue) commitCreate();\n else addTag(value, details?.item.label ?? value);\n },\n items,\n filter: listFilter,\n // Typing a filter makes its first match active (as in Combobox), so Enter adds what the list\n // shows instead of submitting the form. Nothing is active on open or with the text cleared.\n // The Button trigger starts on the first listed option, as Dropdown does.\n autoHighlight: isButtonTrigger ? 'selected' : query ? 'first' : false,\n idPrefix: 'tagpicker-listbox',\n onClearDraft: query && !isButtonTrigger ? () => setQuery('') : undefined,\n });\n\n // A value's label (D58): its registered option's, else the List children's (the server and the\n // first render), else the `options` entry's, else the raw value.\n const getItem = listbox.getItem;\n const labelOf = React.useCallback(\n (value: string): string =>\n (registration ? getItem(value)?.label : undefined) ??\n collected.get(value) ??\n optionByValue.get(value)?.label ??\n value,\n [registration, getItem, collected, optionByValue],\n );\n\n // Registration mode: the create option is a rendered Option, so the duplicate check runs after\n // the listbox, over the labels it lists in this render and those of the selected values.\n let createText: string | null = dataCreateText;\n if (offersCreate && registration) {\n const listed = listbox.items.filter((item) => item.value !== createValue);\n createText = createOptionText(query, {\n labels: [\n ...options.map((option) => option.label),\n ...collected.values(),\n ...listed.map((item) => item.label),\n ...selected.map(labelOf),\n ],\n values: [\n ...options.map((option) => option.value),\n ...collected.keys(),\n ...listed.map((item) => item.value),\n ],\n selected,\n });\n }\n const showCreate = createText !== null;\n\n // aria-expanded only while a listbox with options (or the create option) is shown\n // (input-pickers#21).\n const expanded = open && (listbox.items.length > 0 || showCreate);\n const noMatchesText = resolvedLabels.noMatches;\n // The popup shows the options, or \"No matches\" for a query.\n const surfaceOpen = open && (expanded || query !== '');\n const noMatches = surfaceOpen && !expanded && !showCreate;\n const { layerId, setReference, surfaceRef, floatingProps } = useListboxPopup({\n open,\n surfaceOpen,\n onDismiss: () => setOpen(false),\n rootRef,\n anchorRef: triggerRef,\n });\n\n const rootMergedRef = useMergedRefs<HTMLDivElement>(rootRef, ref);\n\n useFormReset(\n rootRef,\n () => {\n // Compared by content (C-FORMS): an inline default is a new array on every render, and a\n // reset that keeps the same tags reports nothing.\n const initial = defaultValue ?? EMPTY_VALUES;\n setSelected((current) => (sameValues(current, initial) ? current : [...initial]));\n setQuery('');\n },\n form,\n );\n\n // The single-line layout (D62): collapsed while focus is outside the root and the list closed.\n const {\n focusWithin,\n onFocus: trackFocus,\n onBlur: trackBlur,\n } = useFocusWithin(overflow === 'count');\n const collapsed = overflow === 'count' && !focusWithin && !open;\n const tagLabels = React.useMemo(() => selected.map(labelOf), [selected, labelOf]);\n const hiddenValues = useTagOverflow({\n active: collapsed,\n values: selected,\n labels: tagLabels,\n control: controlElementRef,\n group: groupRef,\n chip: chipRef,\n trigger: triggerRef,\n });\n\n const focusTrigger = useEventCallback(() => {\n triggerRef.current?.focus();\n });\n const toggleOpen = useEventCallback(() => {\n if (interactive) setOpen(!open);\n });\n const removeTag = useEventCallback((value: string) => {\n if (!interactive || !selected.includes(value)) return;\n const next = selected.filter((v) => v !== value);\n setSelected(next);\n announceToggle(labels, labelOf(value), false, next.length);\n });\n const clear = useEventCallback(() => {\n focusTrigger();\n if (!interactive) return;\n if (selected.length > 0) setSelected([]);\n setQuery('');\n setOpen(false);\n });\n const editText = useEventCallback((text: string) => {\n if (!interactive) return;\n setQuery(text);\n if (!open) setOpen(true);\n // The option whose label equals the typed text becomes active (D60); a user edit only.\n const candidates: Iterable<ExactMatchCandidate> = registration\n ? Array.from(collected, ([value, label]) => ({ value, label }))\n : options;\n listbox.setActiveValue(findExactMatch(text, candidates, selectedSet));\n });\n const focusLastTagControl = useEventCallback(() => {\n const group = groupRef.current;\n const last = group ? tagListControls(group).at(-1) : undefined;\n last?.focus();\n return last !== undefined;\n });\n const setOpenStable = useEventCallback((next: boolean) => setOpen(next));\n const entryOf = React.useCallback((value: string) => optionByValue.get(value), [optionByValue]);\n\n const triggerProps = React.useMemo<TagPickerTriggerProps>(\n () => ({\n id: triggerId,\n 'aria-label': triggerLabel,\n 'aria-labelledby': triggerLabelledBy,\n 'aria-describedby': triggerDescribedBy,\n 'aria-invalid': triggerInvalid,\n 'aria-required': triggerRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n tabIndex,\n autoFocus,\n }),\n [\n triggerId,\n triggerLabel,\n triggerLabelledBy,\n triggerDescribedBy,\n triggerInvalid,\n triggerRequired,\n ariaErrorMessage,\n ariaDetails,\n tabIndex,\n autoFocus,\n ],\n );\n const inputProps = React.useMemo<TagPickerInputOnlyProps>(\n () => ({\n autoComplete,\n autoCapitalize,\n autoCorrect,\n maxLength,\n inputMode,\n spellCheck,\n enterKeyHint,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n }),\n [\n autoComplete,\n autoCapitalize,\n autoCorrect,\n maxLength,\n inputMode,\n spellCheck,\n enterKeyHint,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n ],\n );\n const listLabelledBy =\n triggerLabel === undefined ? (triggerLabelledBy ?? field?.labelId) : triggerLabelledBy;\n const listLabel = React.useMemo(\n () => ({ 'aria-label': triggerLabel, 'aria-labelledby': listLabelledBy }),\n [triggerLabel, listLabelledBy],\n );\n\n const hasSummary = selected.length > 0;\n const context = React.useMemo<TagPickerContextValue>(\n () => ({\n size,\n appearance,\n coreSize,\n tagSize,\n tagAppearance,\n disabled,\n readOnly,\n interactive,\n invalidLook,\n selected,\n labelOf,\n entryOf,\n labels: resolvedLabels,\n placeholder,\n options,\n warnsUnknownValues: !registration && !allowCreate,\n dataMode: !registration,\n listbox,\n open,\n expanded,\n query,\n surfaceOpen,\n showCreate,\n createText: createText ?? '',\n createValue,\n emptyContent: query !== '' && !showCreate,\n layerId,\n surfaceRef,\n floatingProps,\n listLabel,\n triggerProps,\n inputProps,\n summaryId: hasSummary ? summaryId : undefined,\n triggerRef,\n setReference,\n controlRef: controlElementRef,\n groupRef,\n chipRef,\n registerTrigger,\n registerList,\n triggerKind,\n setOpen: setOpenStable,\n toggleOpen,\n focusTrigger,\n removeTag,\n clear,\n editText,\n focusLastTagControl,\n expandIcon,\n clearable,\n overflow,\n collapsed,\n hiddenValues,\n }),\n [\n size,\n appearance,\n coreSize,\n tagSize,\n tagAppearance,\n disabled,\n readOnly,\n interactive,\n invalidLook,\n selected,\n labelOf,\n entryOf,\n resolvedLabels,\n placeholder,\n options,\n registration,\n allowCreate,\n listbox,\n open,\n expanded,\n query,\n surfaceOpen,\n showCreate,\n createText,\n createValue,\n layerId,\n surfaceRef,\n floatingProps,\n listLabel,\n triggerProps,\n inputProps,\n hasSummary,\n summaryId,\n setReference,\n registerTrigger,\n registerList,\n triggerKind,\n setOpenStable,\n toggleOpen,\n focusTrigger,\n removeTag,\n clear,\n editText,\n focusLastTagControl,\n expandIcon,\n clearable,\n overflow,\n collapsed,\n hiddenValues,\n ],\n );\n\n const parts =\n children === undefined || children === null ? (\n <>\n <TagPickerControl />\n <TagPickerList />\n </>\n ) : (\n <>\n {children}\n {/* A parts form without a List still has its listbox, so aria-controls never dangles. */}\n {listElement === undefined && <TagPickerList />}\n </>\n );\n\n return (\n <div\n data-size={size}\n data-appearance={appearance}\n data-overflow={overflow}\n data-collapsed={collapsed ? '' : undefined}\n {...rest}\n ref={rootMergedRef}\n className={cn(tagPickerClassNames.root, 'relative', className)}\n // Focus inside the root (DOM containment) expands the single-line layout.\n onFocus={trackFocus}\n onBlur={trackBlur}\n >\n <TagPickerContext.Provider value={context}>{parts}</TagPickerContext.Provider>\n {hasSummary && (\n // Describes the trigger. The list itself would read every \"Remove …\" button name too.\n <span id={summaryId} hidden>\n {(labels?.summary ?? defaultSummaryLabel)(selected.map(labelOf))}\n </span>\n )}\n {/* Mounted before its text: a live region added together with its text is not announced by\n every screen reader. The row in the popup is the visible copy. */}\n <span role=\"status\" className=\"sr-only\">\n {noMatches && noMatchesText}\n </span>\n <HiddenInput\n name={name}\n form={form}\n disabled={disabled}\n value={selected}\n type=\"text\"\n required={validates}\n onInvalid={focusTrigger}\n />\n </div>\n );\n};\nTagPickerRoot.displayName = 'TagPicker';\n"],"mappings":"0+BA2SA,IAAMuD,GAA6C,CAAC,SAAU,QAAS,aAAa,EAC9EC,GAA4C,CAAC,EAC7CC,GAA4C,IAAI,IAGhDC,GAAqD,CACzD,OAAQ,cACR,MAAO,QACP,cAAe,QACjB,EAEMC,GAAsB,GAAkB,UAAUC,IAClDC,GAAuB,GAAqB,aAAaC,EAAO,KAAK,IAAI,IACzEC,GAAsB,GAAiB,WAAWC,EAAK,GACvDC,GAA6B,GAAkB,IAAIC,IAGzD,SAASC,GAAY,EAAmB,EAAuB,CAC7D,OAAQC,EAAK,WAAaA,EAAK,MAAA,CAAO,YAAY,CAAC,CAAC,SAASJ,EAAK,YAAY,CAAC,CACjF,CAEA,SAASK,GAAe,EAAuB,CAC7C,MAAO,2HAA2HH,EAAM,GAC1I,CAEA,IAAMI,GACJ,yIAEIC,GACJ,sLAGF,SAASC,GACP,EACgE,CAChE,GAAIC,GAAa,KACjB,KAAK,GAAM,CAAE,UAAUzE,EAAAA,gBAAgByE,CAAQ,EAC7C,GAAIxE,EAAAA,gBAAgDyE,EAAMxE,EAAAA,aAAa,EAAG,OAAOwE,CAAA,CAGrF,CAEA,IAAaC,EAAiB,GAA0B,CACtD,GAAM,CACJ,UAAUnB,GACV,WACA,MAAOoB,GACP,gBACA,iBACA,YACA,KAAMC,GACN,eACA,gBACA,eAAc,YACd,UACA,MAAOC,GACP,gBACA,iBACA,WAAW,GACX,KAAMC,GACN,WAAYC,GACZ,QACA,QACA,YACA,gBAAe,MACf,kBACA,eACA,aACA,WAAW,GACX,cAAc,GACd,kBACA,aAAY,GACZ,cACA,SAAUC,GAAe,OACzB,SACA,aACA,cACA,gBACA,aACA,YACA,MACA,aAAcC,GACd,kBAAmBC,GACnB,mBAAoBC,GACpB,eAAgBC,GAChB,gBAAiBC,GACjB,oBAAqBC,GACrB,eAAgBC,GA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WACA,iBACA,WACA,WACA,cACA,eACA,WACA,UACA,WACA,OAAQsJ,EACR,eACA,UACA,mBAAoB,CAACN,GAAgB,CAACH,EACtC,SAAU,CAACG,EACX,UACA,OACA,WACA,QACA,cACA,aACA,WAAYsB,GAAc,GAC1B,cACA,aAAcpC,IAAU,IAAM,CAACsC,EAC/B,WACA,cACA,iBACA,aACA,gBACA,cACA,UAAW8C,GAAa3E,EAAY,IAAA,GACpC,aACA,gBACA,WAAYH,GACZ,WACA,WACA,mBACA,gBACA,cACA,QAAS0D,GACT,cACA,eACA,aACA,SACA,YACA,uBACA,cACA,aACA,WACA,YACA,eACF,GACA,CACElG,EACAG,EACAJ,GACAE,GACAC,GACAU,EACArB,EACAoB,EACAb,GACAM,EACAiE,EACA8B,GACA7C,EACAkE,GACAnE,EACAL,EACAH,EACAqB,EACAhD,EACAuD,EACAvC,EACAyC,EACAH,EACAF,EACA1B,EACA6E,GACAC,GACAC,GACAN,GACAjB,GACAG,GACAe,GACA3E,EACAiF,GACAtG,GACAM,GACAR,EACA8E,GACAT,GACAD,EACAE,GACAE,GACAC,GACAE,GACA8B,GACAC,GACA3I,EACAiG,EACAG,EACF,CACF,EAEMwC,GACJ/J,GAAuC,MACrC,EAAAnB,EAAA,KAAA,CAAA/B,EAAAA,SAAA,CAAA,SAAA,EACE,EAAA+B,EAAA,IAAA,CAAC9B,EAAAA,iBAAD,CAAmB,CAAA,GACnB,EAAA8B,EAAA,IAAA,CAACpD,EAAAA,cAAD,CAAgB,CAAA,CAChB,CAAA,CAAA,GAEF,EAAAoD,EAAA,KAAA,CAAA/B,EAAAA,SAAA,CAAA,SAAA,CACGkD,EAEA8E,KAAgB,IAAA,KAAa,EAAAjG,EAAA,IAAA,CAACpD,EAAAA,cAAD,CAAgB,CAAA,CAC9C,CAAA,CAAA,EAGN,OACE,EAAAoD,EAAA,KAAA,CAAC,MAAD,CACE,YAAWmD,EACX,kBAAiBG,EACjB,gBAAehB,EACf,iBAAgBiG,EAAY,GAAK,IAAA,GACjC,GAAIpG,GACJ,IAAK6F,GACL,UAAW7J,EAAAA,GAAGC,GAAAA,oBAAoB,KAAM,WAAY+M,EAAS,EAE7D,QAAS9C,GACT,OAAQC,GAVV,SAAA,EAYE,EAAAtI,EAAA,IAAA,CAAC3B,GAAAA,iBAAiB,SAAlB,CAA2B,MAAOqM,GAAU,SAAAQ,EAAiC,CAAA,EAC5ET,KAEC,EAAAzK,EAAA,IAAA,CAAC,OAAD,CAAM,GAAI8F,EAAW,OAAA,GACjB,UAAAtF,GAAQ,SAAWD,GAAA,CAAqBgD,EAAS,IAAIiE,CAAO,CAAC,CAC3D,CAAA,GAIR,EAAAxH,EAAA,IAAA,CAAC,OAAD,CAAM,KAAK,SAAS,UAAU,UAC3B,SAAA+H,IAAaF,EACV,CAAA,GACN,EAAA7H,EAAA,IAAA,CAAC1B,GAAAA,YAAD,CACQ,QACA,QACI,WACV,MAAOiF,EACP,KAAK,OACL,SAAUf,GACV,UAAWmG,CACZ,CAAA,CACE,GAET,EACA,EAAc,YAAc"}
1
+ {"version":3,"file":"TagPicker.root.cjs","names":["flattenChildren","isElementOfType","TagPickerList","useFieldContext","useFieldControl","isInvalidLook","useInputLook","useControllable","EMPTY_VALUES","React","useIsClient","useId","collectOptionLabels","createOptionText","useListbox","useListboxPopup","useMergedRefs","sameValues","useFocusWithin","useTagOverflow","useEventCallback","findExactMatch","tagListControls","_Fragment","TagPickerControl","cn","tagPickerClassNames","TagPickerContext","HiddenInput","require_runtime","require_cn","require_children","require_dev","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_useMergedRefs","require_useIsClient","require_useFieldControl","require_useAnnounce","require_useListbox","require_inputLook","require_Input","require_useFormReset","require_HiddenInput","require_Option","require_pickerLabels","require_pickerValues","require_TagPicker_context","require_TagPicker_create","require_TagPicker_overflow","require_TagPicker_parts","react","react_jsx_runtime","TAG_PICKER_SIZES","EMPTY_OPTIONS","EMPTY_LABELS","TAG_SIZE","defaultRemoveLabel","label","defaultSummaryLabel","labels","defaultCreateLabel","text","defaultOverflowCountLabel","count","matchesText","item","triggerMessage","ALLOW_CREATE_BUTTON_MESSAGE","LIST_PLACEMENT_MESSAGE","findList","children","node","TagPickerRoot","valueProp","openProp","queryProp","sizeProp","appearanceProp","overflowProp","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaInvalid","ariaRequired","ariaErrorMessage","ariaDetails","rest","props","onChange","overflow","field","validates","required","readOnly","triggerId","triggerLabel","triggerLabelledBy","triggerDescribedBy","triggerInvalid","triggerRequired","invalidLook","coreSize","size","tagSize","tagAppearance","appearance","selected","setSelected","defaultValue","list","next","onValueChange","selectedSet","interactive","disabled","openState","setOpen","defaultOpen","onOpenChange","isClient","open","triggersRef","triggerKind","setTriggerKind","registerTrigger","token","triggers","firstKind","kind","listCountRef","registerList","isButtonTrigger","queryState","setQuery","defaultQuery","onQueryChange","query","lock","setLock","lockedOpen","rootRef","triggerRef","controlElementRef","groupRef","chipRef","summaryId","createValue","allowCreate","listElement","listChildren","registration","collected","optionByValue","map","option","options","resolvedLabels","offersCreate","dataCreateText","items","available","listFilter","matches","filter","addTag","value","commitCreate","onOptionCreate","listbox","details","getItem","labelOf","createText","listed","showCreate","expanded","noMatchesText","surfaceOpen","noMatches","rootMergedRef","ref","initial","current","form","trackFocus","trackBlur","collapsed","focusWithin","tagLabels","hiddenValues","focusTrigger","toggleOpen","removeTag","v","clear","editText","candidates","focusLastTagControl","group","last","setOpenStable","entryOf","triggerProps","tabIndex","autoFocus","inputProps","autoComplete","autoCapitalize","autoCorrect","maxLength","inputMode","spellCheck","enterKeyHint","onFocus","onBlur","onKeyDown","onKeyUp","controlRef","listLabelledBy","listLabel","hasSummary","context","placeholder","layerId","surfaceRef","floatingProps","setReference","expandIcon","clearable","parts","className"],"sources":["../../../src/components/input/TagPicker.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { cn } from '../../lib/cn';\nimport { tagPickerClassNames } from '../../lib/classNames';\nimport { warnDeprecated, warnOnce } from '../../lib/dev';\nimport type { Slot } from '../../lib/slot';\nimport type {\n CoreSize,\n InputAppearance,\n PopupPositioningOptions,\n Size,\n TagAppearance,\n TagSize,\n} from '../../lib/types';\nimport { useAnnounce } from '../../hooks/useAnnounce';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useFieldContext, useFieldControl } from '../../hooks/useFieldControl';\nimport { useFormReset } from '../../hooks/useFormReset';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { collectOptionLabels, useListbox, type ListboxItem } from '../../hooks/useListbox';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { HiddenInput } from '../internal/HiddenInput';\nimport { useInputLook } from './inputLook';\nimport { isInvalidLook } from './Input';\nimport { useListboxPopup } from './Option';\nimport { announceToggle } from './pickerLabels';\nimport { EMPTY_VALUES, sameValues } from './pickerValues';\nimport type { RoutedHandlers } from './routedHandlers';\nimport { TagPickerContext } from './TagPicker.context';\nimport type {\n ResolvedTagPickerLabels,\n TagPickerContextValue,\n TagPickerInputOnlyProps,\n TagPickerTriggerKind,\n TagPickerTriggerProps,\n} from './TagPicker.context';\nimport { createOptionText, findExactMatch } from './TagPicker.create';\nimport type { ExactMatchCandidate } from './TagPicker.create';\nimport type { TagPickerOption } from './TagPicker.option';\nimport { useFocusWithin, useTagOverflow } from './TagPicker.overflow';\nimport { TagPickerControl, TagPickerList, tagListControls } from './TagPicker.parts';\n\n/**\n * The TagPicker's built-in names, descriptions and announcements, for localization. Each member is\n * optional and falls back to its English default.\n */\nexport interface TagPickerLabels {\n /** Name of a tag's remove button.\n * @default (label) => `Remove ${label}`\n */\n remove?: (label: string) => string;\n /** Name of the list of selected tags.\n * @default 'Selected'\n */\n selected?: string;\n /** Description of the input that sums up the selected tags (their labels, in order).\n * @default (labels) => `Selected: ${labels.join(', ')}`\n */\n summary?: (labels: string[]) => string;\n /** Announcement when a tag is added; `count` is the number of tags after the change.\n * @default (label, count) => `${label} added, ${count} selected`\n */\n added?: (label: string, count: number) => string;\n /** Announcement when a tag is removed; `count` is the number of tags after the change.\n * @default (label, count) => `${label} removed, ${count} selected`\n */\n removed?: (label: string, count: number) => string;\n /** Status text (announced, and shown in the popup) when the typed text matches no option.\n * @default 'No matches'\n */\n noMatches?: string;\n /**\n * Text and name of the create option (`allowCreate`), from the trimmed typed text.\n * @default (text) => `Create \"${text}\"`\n */\n create?: (text: string) => string;\n /** Name of the clear button (`clearable`). @default 'Clear selection' */\n clear?: string;\n /** Name of the expand button at the end of the field. @default 'Show options' */\n expand?: string;\n /**\n * The \"+N\" text of the single-line layout (`overflow=\"count\"`); hidden from assistive\n * technology, which hears the input's summary of every tag.\n * @default (count) => `+${count}`\n */\n overflowCount?: (count: number) => string;\n}\n\n/** Sizes of TagPicker (Fluent's): medium (the 0.7 look), large and extra-large. */\nexport type TagPickerSize = Extract<Size, 'medium' | 'large' | 'extra-large'>;\n\n/** Properties for the TagPicker component. */\nexport interface TagPickerProps extends Omit<\n React.HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue' | RoutedHandlers\n> {\n /**\n * The options, the array form (`{ value, label, media?, secondaryContent? }`). With parts whose\n * `TagPicker.List` has children it only names values (tags, announcements). Changed in 0.11:\n * optional.\n */\n options?: readonly TagPickerOption[];\n /**\n * The parts: `TagPicker.Control` and `TagPicker.List`, directly inside TagPicker (a Fragment is\n * fine). Without children TagPicker renders both with their defaults; without a\n * `TagPicker.List` it renders the default list after the children.\n */\n children?: React.ReactNode;\n /**\n * Controlled array of selected option values (`[]` for none). Fluent's `selectedOptions`.\n */\n value?: readonly string[];\n /**\n * Initial selected values for uncontrolled usage; a form reset restores them.\n * @default []\n */\n defaultValue?: readonly string[];\n /**\n * Called with the new selection when it changes: a tag is added (an option, or a created tag)\n * or removed, or a form reset restores different tags. Fluent's `onOptionSelect`.\n */\n onValueChange?: (value: string[]) => void;\n /**\n * Called with the new selection when it changes: a tag is added or removed, or a form reset\n * restores different tags.\n * @deprecated Use `onValueChange`.\n */\n onChange?: (value: string[]) => void;\n /**\n * Controlled open state of the option list. The list renders only in the browser: an open\n * picker is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state for uncontrolled usage. A picker that starts disabled or read-only starts\n * closed. The list renders only in the browser: it is closed in the server HTML and opens once\n * the picker has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /** Called when the option list opens or closes. */\n onOpenChange?: (open: boolean) => void;\n /**\n * Shown by TagPicker.Input or TagPicker.Button while no tag is selected; the part's own\n * `placeholder` wins.\n * @default 'Select...'\n */\n placeholder?: string;\n /**\n * Whether an option matches the typed text (the query). Called with every listed option, also\n * the options of `TagPicker.List`'s children (its `value`, `label` and `textValue`), and the\n * text whenever the text is not empty, never with a selected option or the create option; an\n * option it returns `false` for is filtered out. It may keep options that do not contain the\n * text: `filter={() => true}` with `query` and `onQueryChange` leaves the matching to you (a\n * server-side search that replaces `options`); for a create entry, use `allowCreate`. With a\n * server-side search, keep the selected options in `options` (they are never listed): a\n * selected value without an option shows its raw value as the tag label, with a development\n * warning (the \"Async search\" story does this).\n * @default a case-insensitive substring match on the option's `textValue ?? label`\n */\n filter?: (option: ListboxItem, query: string) => boolean;\n /**\n * Controlled query: the text typed since the last tag was added, which filters the options and\n * shows in the input (hidden while `disabled` or `readOnly`). Not used with TagPicker.Button.\n */\n query?: string;\n /**\n * Initial query for uncontrolled usage. A TagPicker that starts disabled or read-only starts\n * without it (as it starts closed). Not used with TagPicker.Button.\n * @default ''\n */\n defaultQuery?: string;\n /**\n * Called with the new query when it changes: as the user types, and with `''` when it resets (a\n * tag added or created, Escape on the closed list, the clear button, a form reset, or `disabled`\n * or `readOnly` turned on while text is typed). A blur or a close keeps the text. A TagPicker\n * that mounts disabled or read-only reports nothing: it keeps a controlled query, which shows\n * once it unlocks. Not used with TagPicker.Button.\n */\n onQueryChange?: (query: string) => void;\n /**\n * Whether the tag picker is disabled: nothing can be added or removed, the remove buttons leave\n * the tab order, and the expand and clear buttons are disabled. The field dims once.\n * @default false\n */\n disabled?: boolean;\n /**\n * Size of the tags and the field: `medium` (the 0.7 look), `large` or `extra-large` (Fluent's\n * union; TagPicker has no `small`). Default: the surrounding Field's `size`, else `WaveProvider\n * inputDefaults.size`, else `'medium'`; a Field or provider `small` gives `'medium'` too. Its\n * tags are one Tag size smaller: medium → extra-small, large → small, extra-large → medium. The\n * option list keeps its size.\n */\n size?: TagPickerSize;\n /**\n * Advanced positioning of the popup (Fluent's `positioning`): `offset`, `fitViewport`,\n * `matchReferenceWidth` and `fallbackPlacements` (tried in order when the requested side has no\n * room). The popup opens below the field.\n * @default `{ matchReferenceWidth: true, fitViewport: true }`\n */\n positioning?: PopupPositioningOptions;\n /**\n * Look of the field: `outline` (a full border), `underline` (a bottom stroke only),\n * `filled-darker` or `filled-lighter` (a fill without a visible stroke: give the field a visible\n * label). Default: `WaveProvider inputDefaults.appearance`, else `'outline'`. The tags are\n * filled, outlined on `filled-darker`.\n */\n appearance?: InputAppearance;\n /** Name of the values in form submissions (one hidden input per value). */\n name?: string;\n /** Id of the form the values belong to, when the TagPicker is outside it. */\n form?: string;\n /**\n * At least one tag is required to submit the form (native constraint validation). Like a native\n * readonly input, a `readOnly` TagPicker does not block submission.\n */\n required?: boolean;\n /**\n * The `autocomplete` attribute of TagPicker.Input's `<input role=\"combobox\">`. Browser autofill\n * is off unless you set it (for example `'on'`). With TagPicker.Button, not used.\n * @default 'off'\n */\n autoComplete?: string;\n /**\n * The maximum length of the typed text (`maxlength` of TagPicker.Input's `<input>`). With\n * TagPicker.Button, not used.\n */\n maxLength?: number;\n /**\n * The selection cannot be changed: the trigger is read-only, the tags have no remove buttons,\n * the expand button is disabled and the clear button hidden, and the option list neither opens\n * (click, keyboard, a controlled `open`) nor adds tags; Escape is left to the page. Turning it\n * (or `disabled`) on while the list is open closes it (`onOpenChange(false)`); a focused remove\n * button hands focus to the trigger.\n */\n readOnly?: boolean;\n /**\n * Lets the user add a tag of their own text: while the trimmed text matches no option label\n * and no selected value (ignoring case) and no option value, the list ends with a create option\n * (`labels.create`); Enter on it or a click adds the text as a tag, calls `onOptionCreate`, and\n * clears the text. Needs `TagPicker.Input` (not `TagPicker.Button`). WaveUI-only: Fluent's\n * TagPicker has no free tagging.\n * @default false\n */\n allowCreate?: boolean;\n /**\n * Called with the trimmed text when the user creates a tag, before `onValueChange` reports the\n * new value. Add an option for it if you keep options: until then the tag shows the raw text.\n * WaveUI-only (see `allowCreate`).\n */\n onOptionCreate?: (text: string) => void;\n /**\n * Shows a clear button at the end of the field while a tag is selected (not while `readOnly`;\n * disabled while `disabled`): it removes every tag (`onValueChange([])`), clears the typed\n * text, closes the list and focuses the trigger (the input, or `TagPicker.Button`). A Tab stop\n * after the trigger. The name of Fluent's Combobox and Dropdown prop.\n * @default false\n */\n clearable?: boolean;\n /**\n * The glyph of the expand button at the end of the field (default: a chevron). The button\n * opens and closes the list, keeps focus on the trigger and is not a Tab stop. `null` or\n * `undefined` keep the chevron; `false`, or a value that renders nothing, hides the button.\n * Decorative: a `<button>` passed here is unwrapped. `TagPicker.Control`'s `expandIcon` wins.\n */\n expandIcon?: Slot<'span'>;\n /**\n * `'wrap'`: the tags wrap onto more lines. `'count'`: while focus is outside the picker and its\n * list is closed, the tags stay on one line and the ones that do not fit give way to \"+N\"\n * (`labels.overflowCount`); focusing the picker shows them all. The tags are measured by\n * position: your own Tags in `TagPicker.Group` render in `value` order. WaveUI-only: Fluent's\n * single-line layout is a story, not a prop.\n * @default 'wrap'\n */\n overflow?: 'wrap' | 'count';\n /**\n * Names of the remove buttons and the tag list, the summary that describes the trigger, the\n * announcements, the \"No matches\" text, the create option, the clear and expand buttons and the\n * \"+N\" count, for localization. Unset members keep their English defaults.\n */\n labels?: TagPickerLabels;\n /**\n * Called when TagPicker.Input's `<input role=\"combobox\">` receives focus (the root keeps other\n * handlers). With TagPicker.Button, pass it (and `ref`) on the Button.\n */\n onFocus?: React.FocusEventHandler<HTMLInputElement>;\n /** Called when TagPicker.Input's `<input>` loses focus. With TagPicker.Button, pass it on the Button. */\n onBlur?: React.FocusEventHandler<HTMLInputElement>;\n /**\n * Called on a key press in TagPicker.Input's `<input>`, after the Input's own `onKeyDown` and\n * before the built-in listbox and tag keys; `event.preventDefault()` skips them. With\n * TagPicker.Button, pass it on the Button.\n */\n onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;\n /** Called when a key is released in TagPicker.Input's `<input>`. With TagPicker.Button, pass it on the Button. */\n onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;\n /**\n * Ref to TagPicker.Input's `<input role=\"combobox\">` (the focusable element). With\n * TagPicker.Button, pass `ref` on the Button.\n */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the root `<div>`. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * How the picker came to be locked (`disabled` or `readOnly`): not at all, by a change while\n * mounted, or since it mounted.\n */\ntype LockState = 'unlocked' | 'locked' | 'mounted-locked';\n\nconst TAG_PICKER_SIZES: readonly TagPickerSize[] = ['medium', 'large', 'extra-large'];\nconst EMPTY_OPTIONS: readonly TagPickerOption[] = [];\nconst EMPTY_LABELS: ReadonlyMap<string, string> = new Map();\n\n/** The tag size of each picker size (Fluent's mapping, D54). */\nconst TAG_SIZE: Readonly<Record<TagPickerSize, TagSize>> = {\n medium: 'extra-small',\n large: 'small',\n 'extra-large': 'medium',\n};\n\nconst defaultRemoveLabel = (label: string) => `Remove ${label}`;\nconst defaultSummaryLabel = (labels: string[]) => `Selected: ${labels.join(', ')}`;\nconst defaultCreateLabel = (text: string) => `Create \"${text}\"`;\nconst defaultOverflowCountLabel = (count: number) => `+${count}`;\n\n/** The default `filter` (Phase 5 D13): a case-insensitive substring of `textValue ?? label`. */\nfunction matchesText(item: ListboxItem, text: string): boolean {\n return (item.textValue ?? item.label).toLowerCase().includes(text.toLowerCase());\n}\n\nfunction triggerMessage(count: number): string {\n return `TagPicker: render exactly one trigger, \\`TagPicker.Input\\` or \\`TagPicker.Button\\`, inside \\`TagPicker.Control\\` (found ${count}).`;\n}\n\nconst ALLOW_CREATE_BUTTON_MESSAGE =\n 'TagPicker: `allowCreate` needs `TagPicker.Input`: `TagPicker.Button` has no text to create a tag from, so no create option is offered.';\n\nconst LIST_PLACEMENT_MESSAGE =\n 'TagPicker.List: render one TagPicker.List, directly inside TagPicker (a Fragment is fine). A second list, or one inside a component of your own, splits the options over two lists.';\n\n/** The `TagPicker.List` among the direct children and Fragments, if any (D50). */\nfunction findList(\n children: React.ReactNode,\n): React.ReactElement<{ children?: React.ReactNode }> | undefined {\n if (children === null || children === undefined) return undefined;\n for (const { node } of flattenChildren(children)) {\n if (isElementOfType<{ children?: React.ReactNode }>(node, TagPickerList)) return node;\n }\n return undefined;\n}\n\nexport const TagPickerRoot = (props: TagPickerProps) => {\n const {\n options = EMPTY_OPTIONS,\n children,\n value: valueProp,\n defaultValue,\n onValueChange,\n onChange,\n open: openProp,\n defaultOpen,\n onOpenChange,\n placeholder = 'Select...',\n filter,\n query: queryProp,\n defaultQuery,\n onQueryChange,\n disabled = false,\n size: sizeProp,\n positioning,\n appearance: appearanceProp,\n name,\n form,\n required,\n autoComplete = 'off',\n autoCapitalize,\n autoCorrect,\n maxLength,\n readOnly = false,\n allowCreate = false,\n onOptionCreate,\n clearable = false,\n expandIcon,\n overflow: overflowProp = 'wrap',\n labels,\n inputMode,\n spellCheck,\n enterKeyHint,\n autoFocus,\n tabIndex,\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n 'aria-required': ariaRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n className,\n ref,\n ...rest\n } = props;\n\n if (onChange !== undefined) warnDeprecated('TagPicker', 'onChange', 'onValueChange');\n const overflow = overflowProp === 'count' ? 'count' : 'wrap';\n\n const field = useFieldContext();\n const isRequired = required ?? field?.required ?? false;\n // Like a native readonly input, a read-only TagPicker is barred from constraint validation (the\n // user could not fix it); its values are still submitted.\n const validates = isRequired && !readOnly;\n const fieldProps = useFieldControl({\n id,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n 'aria-invalid': ariaInvalid,\n // An explicit `required={false}` wins over a required Field, so aria-required matches\n // `isRequired`.\n 'aria-required': ariaRequired ?? required,\n });\n const {\n id: triggerId,\n 'aria-label': triggerLabel,\n 'aria-labelledby': triggerLabelledBy,\n 'aria-describedby': triggerDescribedBy,\n 'aria-invalid': triggerInvalid,\n 'aria-required': triggerRequired,\n } = fieldProps;\n // The error look follows the resolved state: the consumer's `aria-invalid` or the Field's.\n const invalidLook = isInvalidLook(false, triggerInvalid);\n const { size, appearance } = useInputLook(sizeProp, appearanceProp, {\n sizes: TAG_PICKER_SIZES,\n defaultSize: 'medium',\n });\n const coreSize: CoreSize = size === 'medium' ? 'medium' : 'large';\n const tagSize = TAG_SIZE[size];\n // A muted tag would barely show on the darker fill: outlined there (D54).\n const tagAppearance: TagAppearance = appearance === 'filled-darker' ? 'outline' : 'filled';\n\n const [selected, setSelected] = useControllable<readonly string[]>(\n valueProp,\n defaultValue ?? EMPTY_VALUES,\n (next) => {\n // The props are read only; the callbacks receive an array of their own.\n const list = [...next];\n onValueChange?.(list);\n onChange?.(list);\n },\n );\n const selectedSet = React.useMemo(() => new Set(selected), [selected]);\n const interactive = !disabled && !readOnly;\n // A picker that starts disabled or read-only never shows its list, so it starts closed (no close\n // to report later).\n const [openState, setOpen] = useControllable(\n openProp,\n (defaultOpen ?? false) && interactive,\n onOpenChange,\n );\n // The open list lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the picker shows the closed inline list and reports it closed, so\n // aria-controls and aria-activedescendant never name a missing element.\n const isClient = useIsClient();\n const open = openState && interactive && isClient;\n // The trigger parts (D63): their kind decides the listbox mode; the server HTML and the first\n // render use the editable mode of `TagPicker.Input`.\n const triggersRef = React.useRef(new Map<object, TagPickerTriggerKind>());\n const [triggerKind, setTriggerKind] = React.useState<TagPickerTriggerKind>('input');\n const registerTrigger = React.useCallback((kind: TagPickerTriggerKind) => {\n const token = {};\n const triggers = triggersRef.current;\n const firstKind = () => triggers.values().next().value ?? 'input';\n triggers.set(token, kind);\n setTriggerKind(firstKind());\n return () => {\n triggers.delete(token);\n setTriggerKind(firstKind());\n };\n }, []);\n const listCountRef = React.useRef(0);\n const registerList = React.useCallback(() => {\n listCountRef.current += 1;\n return () => {\n listCountRef.current -= 1;\n };\n }, []);\n // After every commit (every part's layout effect has run): exactly one trigger and one List.\n React.useEffect(() => {\n const triggers = triggersRef.current.size;\n if (triggers !== 1) warnOnce('TagPicker:trigger', triggerMessage(triggers));\n if (listCountRef.current > 1) warnOnce('TagPicker.List:placement', LIST_PLACEMENT_MESSAGE);\n });\n const isButtonTrigger = triggerKind === 'button';\n\n // The query (D12): the text typed since the last tag was added, which filters the options. A\n // picker that starts locked starts without a query, as it starts closed.\n const [queryState, setQuery] = useControllable(\n queryProp,\n interactive ? (defaultQuery ?? '') : '',\n onQueryChange,\n );\n // Locking the control (readOnly/disabled) while typing drops the typed text: hidden during\n // render here, and the reset reported from an effect, since `onQueryChange` never runs during\n // render (D12). `lock` is how the picker came to be locked (previous-value pattern, C-HOOKS):\n // `'locked'` by a change while mounted, whose reset is reported once, or `'mounted-locked'`\n // since it mounted, which reports nothing and keeps a controlled query, hidden until the picker\n // unlocks (R20).\n // `TagPicker.Button` has no text entry, so no query filters its list (D63).\n const query = interactive && !isButtonTrigger ? queryState : '';\n const [lock, setLock] = React.useState<LockState>(interactive ? 'unlocked' : 'mounted-locked');\n if (interactive && lock !== 'unlocked') setLock('unlocked');\n else if (!interactive && lock === 'unlocked') setLock('locked');\n React.useEffect(() => {\n if (lock === 'locked') setQuery('');\n }, [lock, setQuery]);\n // Locking also closes the list itself, not only the derived `open`, so unlocking does not reopen\n // it without a user action. The close is reported through onOpenChange (a consumer callback from\n // an effect, C-HOOKS); a controlled `open` that stays true is still not shown while locked.\n const lockedOpen = !interactive && openState;\n React.useEffect(() => {\n if (lockedOpen) setOpen(false);\n }, [lockedOpen, setOpen]);\n // Keeps the shared live regions alive while mounted: every addition and removal is announced\n // (`announceToggle`).\n useAnnounce();\n\n const rootRef = React.useRef<HTMLDivElement | null>(null);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const controlElementRef = React.useRef<HTMLDivElement | null>(null);\n const groupRef = React.useRef<HTMLDivElement | null>(null);\n const chipRef = React.useRef<HTMLSpanElement | null>(null);\n const summaryId = useId('tagpicker-summary');\n const createValue = useId('tagpicker-create');\n\n React.useEffect(() => {\n if (allowCreate && isButtonTrigger) {\n warnOnce('TagPicker:allowCreate-button', ALLOW_CREATE_BUTTON_MESSAGE);\n }\n }, [allowCreate, isButtonTrigger]);\n\n // The parts form (D50): a List among the direct children with children of its own switches the\n // listbox to registration mode; `options` then only names values.\n const listElement = findList(children);\n const listChildren = listElement?.props.children;\n const registration = listChildren !== undefined && listChildren !== null;\n const collected = React.useMemo(\n () => (registration ? collectOptionLabels(listChildren) : EMPTY_LABELS),\n [registration, listChildren],\n );\n\n const optionByValue = React.useMemo(() => {\n const map = new Map<string, TagPickerOption>();\n for (const option of options) if (!map.has(option.value)) map.set(option.value, option);\n return map;\n }, [options]);\n\n const resolvedLabels = React.useMemo<ResolvedTagPickerLabels>(\n () => ({\n remove: labels?.remove ?? defaultRemoveLabel,\n selected: labels?.selected ?? 'Selected',\n create: labels?.create ?? defaultCreateLabel,\n clear: labels?.clear ?? 'Clear selection',\n expand: labels?.expand ?? 'Show options',\n overflowCount: labels?.overflowCount ?? defaultOverflowCountLabel,\n noMatches: labels?.noMatches ?? 'No matches',\n }),\n [labels],\n );\n\n // The create option (D59) needs the text input, an interactive picker and an open list.\n const offersCreate =\n allowCreate && interactive && !isButtonTrigger && open && query.trim() !== '';\n // Data mode: the duplicate check reads every `options` entry, before the listbox, since the\n // create item is one of its items.\n const dataCreateText =\n offersCreate && !registration\n ? createOptionText(query, {\n labels: options.map((option) => option.label),\n values: options.map((option) => option.value),\n selected,\n })\n : null;\n\n const items = React.useMemo<ListboxItem[] | undefined>(() => {\n if (registration) return undefined;\n const available: ListboxItem[] = options\n .filter((option) => !selectedSet.has(option.value))\n .map((option) => ({ value: option.value, label: option.label }));\n if (dataCreateText !== null) {\n available.push({ value: createValue, label: resolvedLabels.create(dataCreateText) });\n }\n return available;\n }, [registration, options, selectedSet, dataCreateText, createValue, resolvedLabels]);\n\n // useListbox's navigability predicate (D58): the create option always, never a selected option,\n // and `filter` (else the default) bound to the typed text while there is any.\n const listFilter = React.useMemo(() => {\n if (!registration && !query) return undefined;\n const matches = filter ?? matchesText;\n return (item: ListboxItem) =>\n item.value === createValue ||\n (!selectedSet.has(item.value) && (query === '' || matches(item, query)));\n }, [registration, query, filter, selectedSet, createValue]);\n\n // Adds a listed option (`label`: the committed item's).\n const addTag = (value: string, label: string) => {\n if (!interactive || selected.includes(value)) return;\n const next = [...selected, value];\n setSelected(next);\n setQuery('');\n announceToggle(labels, label, true, next.length);\n };\n\n // Creates a tag of the trimmed text (D59): the create option was offered for it.\n const commitCreate = () => {\n const text = query.trim();\n if (!interactive || text === '') return;\n onOptionCreate?.(text);\n const next = [...selected, text];\n setSelected(next);\n setQuery('');\n announceToggle(labels, text, true, next.length);\n };\n\n const listbox = useListbox({\n open,\n onOpenChange: (next) => setOpen(next),\n mode: isButtonTrigger ? 'select-only' : 'editable',\n multiselect: true,\n selectedValues: selected,\n onSelect: (value, details) => {\n if (value === createValue) commitCreate();\n else addTag(value, details?.item.label ?? value);\n },\n items,\n filter: listFilter,\n // Typing a filter makes its first match active (as in Combobox), so Enter adds what the list\n // shows instead of submitting the form. Nothing is active on open or with the text cleared.\n // The Button trigger starts on the first listed option, as Dropdown does.\n autoHighlight: isButtonTrigger ? 'selected' : query ? 'first' : false,\n idPrefix: 'tagpicker-listbox',\n onClearDraft: query && !isButtonTrigger ? () => setQuery('') : undefined,\n });\n\n // A value's label (D58): its registered option's, else the List children's (the server and the\n // first render), else the `options` entry's, else the raw value.\n const getItem = listbox.getItem;\n const labelOf = React.useCallback(\n (value: string): string =>\n (registration ? getItem(value)?.label : undefined) ??\n collected.get(value) ??\n optionByValue.get(value)?.label ??\n value,\n [registration, getItem, collected, optionByValue],\n );\n\n // Registration mode: the create option is a rendered Option, so the duplicate check runs after\n // the listbox, over the labels it lists in this render and those of the selected values.\n let createText: string | null = dataCreateText;\n if (offersCreate && registration) {\n const listed = listbox.items.filter((item) => item.value !== createValue);\n createText = createOptionText(query, {\n labels: [\n ...options.map((option) => option.label),\n ...collected.values(),\n ...listed.map((item) => item.label),\n ...selected.map(labelOf),\n ],\n values: [\n ...options.map((option) => option.value),\n ...collected.keys(),\n ...listed.map((item) => item.value),\n ],\n selected,\n });\n }\n const showCreate = createText !== null;\n\n // aria-expanded only while a listbox with options (or the create option) is shown\n // (input-pickers#21).\n const expanded = open && (listbox.items.length > 0 || showCreate);\n const noMatchesText = resolvedLabels.noMatches;\n // The popup shows the options, or \"No matches\" for a query.\n const surfaceOpen = open && (expanded || query !== '');\n const noMatches = surfaceOpen && !expanded && !showCreate;\n const { layerId, setReference, surfaceRef, floatingProps } = useListboxPopup({\n positioning,\n open,\n surfaceOpen,\n onDismiss: () => setOpen(false),\n rootRef,\n anchorRef: triggerRef,\n });\n\n const rootMergedRef = useMergedRefs<HTMLDivElement>(rootRef, ref);\n\n useFormReset(\n rootRef,\n () => {\n // Compared by content (C-FORMS): an inline default is a new array on every render, and a\n // reset that keeps the same tags reports nothing.\n const initial = defaultValue ?? EMPTY_VALUES;\n setSelected((current) => (sameValues(current, initial) ? current : [...initial]));\n setQuery('');\n },\n form,\n );\n\n // The single-line layout (D62): collapsed while focus is outside the root and the list closed.\n const {\n focusWithin,\n onFocus: trackFocus,\n onBlur: trackBlur,\n } = useFocusWithin(overflow === 'count');\n const collapsed = overflow === 'count' && !focusWithin && !open;\n const tagLabels = React.useMemo(() => selected.map(labelOf), [selected, labelOf]);\n const hiddenValues = useTagOverflow({\n active: collapsed,\n values: selected,\n labels: tagLabels,\n control: controlElementRef,\n group: groupRef,\n chip: chipRef,\n trigger: triggerRef,\n });\n\n const focusTrigger = useEventCallback(() => {\n triggerRef.current?.focus();\n });\n const toggleOpen = useEventCallback(() => {\n if (interactive) setOpen(!open);\n });\n const removeTag = useEventCallback((value: string) => {\n if (!interactive || !selected.includes(value)) return;\n const next = selected.filter((v) => v !== value);\n setSelected(next);\n announceToggle(labels, labelOf(value), false, next.length);\n });\n const clear = useEventCallback(() => {\n focusTrigger();\n if (!interactive) return;\n if (selected.length > 0) setSelected([]);\n setQuery('');\n setOpen(false);\n });\n const editText = useEventCallback((text: string) => {\n if (!interactive) return;\n setQuery(text);\n if (!open) setOpen(true);\n // The option whose label equals the typed text becomes active (D60); a user edit only.\n const candidates: Iterable<ExactMatchCandidate> = registration\n ? Array.from(collected, ([value, label]) => ({ value, label }))\n : options;\n listbox.setActiveValue(findExactMatch(text, candidates, selectedSet));\n });\n const focusLastTagControl = useEventCallback(() => {\n const group = groupRef.current;\n const last = group ? tagListControls(group).at(-1) : undefined;\n last?.focus();\n return last !== undefined;\n });\n const setOpenStable = useEventCallback((next: boolean) => setOpen(next));\n const entryOf = React.useCallback((value: string) => optionByValue.get(value), [optionByValue]);\n\n const triggerProps = React.useMemo<TagPickerTriggerProps>(\n () => ({\n id: triggerId,\n 'aria-label': triggerLabel,\n 'aria-labelledby': triggerLabelledBy,\n 'aria-describedby': triggerDescribedBy,\n 'aria-invalid': triggerInvalid,\n 'aria-required': triggerRequired,\n 'aria-errormessage': ariaErrorMessage,\n 'aria-details': ariaDetails,\n tabIndex,\n autoFocus,\n }),\n [\n triggerId,\n triggerLabel,\n triggerLabelledBy,\n triggerDescribedBy,\n triggerInvalid,\n triggerRequired,\n ariaErrorMessage,\n ariaDetails,\n tabIndex,\n autoFocus,\n ],\n );\n const inputProps = React.useMemo<TagPickerInputOnlyProps>(\n () => ({\n autoComplete,\n autoCapitalize,\n autoCorrect,\n maxLength,\n inputMode,\n spellCheck,\n enterKeyHint,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n }),\n [\n autoComplete,\n autoCapitalize,\n autoCorrect,\n maxLength,\n inputMode,\n spellCheck,\n enterKeyHint,\n onFocus,\n onBlur,\n onKeyDown,\n onKeyUp,\n controlRef,\n ],\n );\n const listLabelledBy =\n triggerLabel === undefined ? (triggerLabelledBy ?? field?.labelId) : triggerLabelledBy;\n const listLabel = React.useMemo(\n () => ({ 'aria-label': triggerLabel, 'aria-labelledby': listLabelledBy }),\n [triggerLabel, listLabelledBy],\n );\n\n const hasSummary = selected.length > 0;\n const context = React.useMemo<TagPickerContextValue>(\n () => ({\n size,\n appearance,\n coreSize,\n tagSize,\n tagAppearance,\n disabled,\n readOnly,\n interactive,\n invalidLook,\n selected,\n labelOf,\n entryOf,\n labels: resolvedLabels,\n placeholder,\n options,\n warnsUnknownValues: !registration && !allowCreate,\n dataMode: !registration,\n listbox,\n open,\n expanded,\n query,\n surfaceOpen,\n showCreate,\n createText: createText ?? '',\n createValue,\n emptyContent: query !== '' && !showCreate,\n layerId,\n surfaceRef,\n floatingProps,\n listLabel,\n triggerProps,\n inputProps,\n summaryId: hasSummary ? summaryId : undefined,\n triggerRef,\n setReference,\n controlRef: controlElementRef,\n groupRef,\n chipRef,\n registerTrigger,\n registerList,\n triggerKind,\n setOpen: setOpenStable,\n toggleOpen,\n focusTrigger,\n removeTag,\n clear,\n editText,\n focusLastTagControl,\n expandIcon,\n clearable,\n overflow,\n collapsed,\n hiddenValues,\n }),\n [\n size,\n appearance,\n coreSize,\n tagSize,\n tagAppearance,\n disabled,\n readOnly,\n interactive,\n invalidLook,\n selected,\n labelOf,\n entryOf,\n resolvedLabels,\n placeholder,\n options,\n registration,\n allowCreate,\n listbox,\n open,\n expanded,\n query,\n surfaceOpen,\n showCreate,\n createText,\n createValue,\n layerId,\n surfaceRef,\n floatingProps,\n listLabel,\n triggerProps,\n inputProps,\n hasSummary,\n summaryId,\n setReference,\n registerTrigger,\n registerList,\n triggerKind,\n setOpenStable,\n toggleOpen,\n focusTrigger,\n removeTag,\n clear,\n editText,\n focusLastTagControl,\n expandIcon,\n clearable,\n overflow,\n collapsed,\n hiddenValues,\n ],\n );\n\n const parts =\n children === undefined || children === null ? (\n <>\n <TagPickerControl />\n <TagPickerList />\n </>\n ) : (\n <>\n {children}\n {/* A parts form without a List still has its listbox, so aria-controls never dangles. */}\n {listElement === undefined && <TagPickerList />}\n </>\n );\n\n return (\n <div\n data-size={size}\n data-appearance={appearance}\n data-overflow={overflow}\n data-collapsed={collapsed ? '' : undefined}\n {...rest}\n ref={rootMergedRef}\n className={cn(tagPickerClassNames.root, 'relative', className)}\n // Focus inside the root (DOM containment) expands the single-line layout.\n onFocus={trackFocus}\n onBlur={trackBlur}\n >\n <TagPickerContext.Provider value={context}>{parts}</TagPickerContext.Provider>\n {hasSummary && (\n // Describes the trigger. The list itself would read every \"Remove …\" button name too.\n <span id={summaryId} hidden>\n {(labels?.summary ?? defaultSummaryLabel)(selected.map(labelOf))}\n </span>\n )}\n {/* Mounted before its text: a live region added together with its text is not announced by\n every screen reader. The row in the popup is the visible copy. */}\n <span role=\"status\" className=\"sr-only\">\n {noMatches && noMatchesText}\n </span>\n <HiddenInput\n name={name}\n form={form}\n disabled={disabled}\n value={selected}\n type=\"text\"\n required={validates}\n onInvalid={focusTrigger}\n />\n </div>\n );\n};\nTagPickerRoot.displayName = 'TagPicker';\n"],"mappings":"0+BAyTA,IAAMuD,GAA6C,CAAC,SAAU,QAAS,aAAa,EAC9EC,GAA4C,CAAC,EAC7CC,GAA4C,IAAI,IAGhDC,GAAqD,CACzD,OAAQ,cACR,MAAO,QACP,cAAe,QACjB,EAEMC,GAAsB,GAAkB,UAAUC,IAClDC,GAAuB,GAAqB,a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QvD,EAAS,QACjBwD,EAAOD,EAAQnL,EAAAA,gBAAgBmL,CAAK,CAAC,CAAC,GAAG,EAAE,EAAI,IAAA,GAErD,OADAC,GAAM,MAAM,EACLA,IAAS,IAAA,EAClB,CAAC,EACKC,GAAgBvL,EAAAA,iBAAkB,GAAkBmG,EAAQN,CAAI,CAAC,EACjE2F,GAAUnM,EAAM,YAAa,GAAkBkJ,EAAc,IAAIa,CAAK,EAAG,CAACb,CAAa,CAAC,EAExFkD,GAAepM,EAAM,aAClB,CACL,GAAIwF,GACJ,aAAcC,EACd,kBAAmBC,EACnB,mBAAoBC,GACpB,eAAgBC,EAChB,gBAAiBC,GACjB,oBAAqBf,GACrB,eAAgBC,GAChB,YACA,YACF,GACA,CACES,GACAC,EACAC,EACAC,GACAC,EACAC,GACAf,GACAC,GACAsH,GACAC,EACF,CACF,EACMC,GAAavM,EAAM,aAChB,CACL,gBACA,kBACA,eACA,aACA,aACA,cACA,gBACA,WACA,UACA,aACA,WACA,aACF,GACA,CACEwM,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,GACAC,EACF,CACF,EACMC,GACJ3H,IAAiB,IAAA,GAAaC,GAAqBN,IAAO,QAAWM,EACjE2H,GAAYrN,EAAM,aACf,CAAE,aAAcyF,EAAc,kBAAmB2H,EAAe,GACvE,CAAC3H,EAAc2H,EAAc,CAC/B,EAEME,EAAalH,EAAS,OAAS,EAC/BmH,GAAUvN,EAAM,aACb,CACL,OACA,aACA,YACA,WACA,iBACA,WACA,WACA,cACA,eACA,WACA,UACA,WACA,OAAQsJ,EACR,eACA,UACA,mBAAoB,CAACN,GAAgB,CAACH,EACtC,SAAU,CAACG,EACX,UACA,OACA,WACA,QACA,cACA,aACA,WAAYsB,GAAc,GAC1B,cACA,aAAcpC,IAAU,IAAM,CAACsC,EAC/B,WACA,cACA,iBACA,aACA,gBACA,cACA,UAAW8C,EAAa3E,EAAY,IAAA,GACpC,aACA,gBACA,WAAYH,G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