@mortenbrudvik/waveui 0.11.0 → 0.13.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 (210) hide show
  1. package/README.md +157 -13
  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/Avatar.cjs +1 -1
  6. package/dist/components/data-display/Avatar.cjs.map +1 -1
  7. package/dist/components/data-display/Avatar.colors.cjs +2 -0
  8. package/dist/components/data-display/Avatar.colors.cjs.map +1 -0
  9. package/dist/components/data-display/Avatar.colors.mjs +45 -0
  10. package/dist/components/data-display/Avatar.colors.mjs.map +1 -0
  11. package/dist/components/data-display/Avatar.context.cjs +1 -1
  12. package/dist/components/data-display/Avatar.context.cjs.map +1 -1
  13. package/dist/components/data-display/Avatar.context.mjs +4 -2
  14. package/dist/components/data-display/Avatar.context.mjs.map +1 -1
  15. package/dist/components/data-display/Avatar.mjs +103 -96
  16. package/dist/components/data-display/Avatar.mjs.map +1 -1
  17. package/dist/components/data-display/Avatar.sizes.cjs +2 -0
  18. package/dist/components/data-display/Avatar.sizes.cjs.map +1 -0
  19. package/dist/components/data-display/Avatar.sizes.mjs +41 -0
  20. package/dist/components/data-display/Avatar.sizes.mjs.map +1 -0
  21. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  22. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  23. package/dist/components/data-display/AvatarGroup.context.cjs +2 -0
  24. package/dist/components/data-display/AvatarGroup.context.cjs.map +1 -0
  25. package/dist/components/data-display/AvatarGroup.context.mjs +9 -0
  26. package/dist/components/data-display/AvatarGroup.context.mjs.map +1 -0
  27. package/dist/components/data-display/AvatarGroup.mjs +65 -122
  28. package/dist/components/data-display/AvatarGroup.mjs.map +1 -1
  29. package/dist/components/data-display/AvatarGroup.partition.cjs +2 -0
  30. package/dist/components/data-display/AvatarGroup.partition.cjs.map +1 -0
  31. package/dist/components/data-display/AvatarGroup.partition.mjs +14 -0
  32. package/dist/components/data-display/AvatarGroup.partition.mjs.map +1 -0
  33. package/dist/components/data-display/AvatarGroup.parts.cjs +2 -0
  34. package/dist/components/data-display/AvatarGroup.parts.cjs.map +1 -0
  35. package/dist/components/data-display/AvatarGroup.parts.mjs +178 -0
  36. package/dist/components/data-display/AvatarGroup.parts.mjs.map +1 -0
  37. package/dist/components/data-display/InfoButton.cjs +1 -1
  38. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  39. package/dist/components/data-display/InfoButton.mjs +12 -12
  40. package/dist/components/data-display/InteractionTag.cjs +1 -1
  41. package/dist/components/data-display/InteractionTag.cjs.map +1 -1
  42. package/dist/components/data-display/InteractionTag.mjs +36 -33
  43. package/dist/components/data-display/InteractionTag.mjs.map +1 -1
  44. package/dist/components/data-display/Persona.cjs +1 -1
  45. package/dist/components/data-display/Persona.cjs.map +1 -1
  46. package/dist/components/data-display/Persona.mjs +96 -37
  47. package/dist/components/data-display/Persona.mjs.map +1 -1
  48. package/dist/components/data-display/PresenceBadge.cjs +1 -1
  49. package/dist/components/data-display/PresenceBadge.cjs.map +1 -1
  50. package/dist/components/data-display/PresenceBadge.mjs +42 -28
  51. package/dist/components/data-display/PresenceBadge.mjs.map +1 -1
  52. package/dist/components/data-display/Tag.cjs +1 -1
  53. package/dist/components/data-display/Tag.cjs.map +1 -1
  54. package/dist/components/data-display/Tag.mjs +111 -108
  55. package/dist/components/data-display/Tag.mjs.map +1 -1
  56. package/dist/components/feedback/Toaster.cjs +1 -1
  57. package/dist/components/feedback/Toaster.cjs.map +1 -1
  58. package/dist/components/feedback/Toaster.mjs +235 -235
  59. package/dist/components/feedback/Toaster.mjs.map +1 -1
  60. package/dist/components/input/Combobox.cjs +1 -1
  61. package/dist/components/input/Combobox.cjs.map +1 -1
  62. package/dist/components/input/Combobox.mjs +176 -175
  63. package/dist/components/input/Combobox.mjs.map +1 -1
  64. package/dist/components/input/DatePicker.cjs +1 -1
  65. package/dist/components/input/DatePicker.cjs.map +1 -1
  66. package/dist/components/input/DatePicker.mjs +188 -187
  67. package/dist/components/input/DatePicker.mjs.map +1 -1
  68. package/dist/components/input/Dropdown.cjs +1 -1
  69. package/dist/components/input/Dropdown.cjs.map +1 -1
  70. package/dist/components/input/Dropdown.mjs +41 -40
  71. package/dist/components/input/Dropdown.mjs.map +1 -1
  72. package/dist/components/input/Option.cjs +1 -1
  73. package/dist/components/input/Option.cjs.map +1 -1
  74. package/dist/components/input/Option.mjs +89 -87
  75. package/dist/components/input/Option.mjs.map +1 -1
  76. package/dist/components/input/TagPicker.root.cjs +1 -1
  77. package/dist/components/input/TagPicker.root.cjs.map +1 -1
  78. package/dist/components/input/TagPicker.root.mjs +136 -135
  79. package/dist/components/input/TagPicker.root.mjs.map +1 -1
  80. package/dist/components/input/TimePicker.cjs +1 -1
  81. package/dist/components/input/TimePicker.cjs.map +1 -1
  82. package/dist/components/input/TimePicker.mjs +156 -154
  83. package/dist/components/input/TimePicker.mjs.map +1 -1
  84. package/dist/components/layout/Card.cjs +1 -1
  85. package/dist/components/layout/Card.cjs.map +1 -1
  86. package/dist/components/layout/Card.context.cjs +2 -0
  87. package/dist/components/layout/Card.context.cjs.map +1 -0
  88. package/dist/components/layout/Card.context.mjs +14 -0
  89. package/dist/components/layout/Card.context.mjs.map +1 -0
  90. package/dist/components/layout/Card.mjs +138 -92
  91. package/dist/components/layout/Card.mjs.map +1 -1
  92. package/dist/components/layout/Card.preview.cjs +2 -0
  93. package/dist/components/layout/Card.preview.cjs.map +1 -0
  94. package/dist/components/layout/Card.preview.mjs +22 -0
  95. package/dist/components/layout/Card.preview.mjs.map +1 -0
  96. package/dist/components/layout/Carousel.button.cjs +2 -0
  97. package/dist/components/layout/Carousel.button.cjs.map +1 -0
  98. package/dist/components/layout/Carousel.button.mjs +34 -0
  99. package/dist/components/layout/Carousel.button.mjs.map +1 -0
  100. package/dist/components/layout/Carousel.cjs +1 -1
  101. package/dist/components/layout/Carousel.cjs.map +1 -1
  102. package/dist/components/layout/Carousel.context.cjs +2 -0
  103. package/dist/components/layout/Carousel.context.cjs.map +1 -0
  104. package/dist/components/layout/Carousel.context.mjs +24 -0
  105. package/dist/components/layout/Carousel.context.mjs.map +1 -0
  106. package/dist/components/layout/Carousel.drag.cjs +2 -0
  107. package/dist/components/layout/Carousel.drag.cjs.map +1 -0
  108. package/dist/components/layout/Carousel.drag.mjs +79 -0
  109. package/dist/components/layout/Carousel.drag.mjs.map +1 -0
  110. package/dist/components/layout/Carousel.groups.cjs +2 -0
  111. package/dist/components/layout/Carousel.groups.cjs.map +1 -0
  112. package/dist/components/layout/Carousel.groups.mjs +23 -0
  113. package/dist/components/layout/Carousel.groups.mjs.map +1 -0
  114. package/dist/components/layout/Carousel.mjs +288 -150
  115. package/dist/components/layout/Carousel.mjs.map +1 -1
  116. package/dist/components/layout/Carousel.styles.cjs +2 -0
  117. package/dist/components/layout/Carousel.styles.cjs.map +1 -0
  118. package/dist/components/layout/Carousel.styles.mjs +30 -0
  119. package/dist/components/layout/Carousel.styles.mjs.map +1 -0
  120. package/dist/components/layout/TabList.cjs +1 -1
  121. package/dist/components/layout/TabList.cjs.map +1 -1
  122. package/dist/components/layout/TabList.mjs +163 -124
  123. package/dist/components/layout/TabList.mjs.map +1 -1
  124. package/dist/components/navigation/Menu.popover.cjs +1 -1
  125. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  126. package/dist/components/navigation/Menu.popover.mjs +137 -127
  127. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  128. package/dist/components/navigation/Menu.root.cjs +1 -1
  129. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  130. package/dist/components/navigation/Menu.root.mjs +4 -4
  131. package/dist/components/overlays/Dialog.cjs +1 -1
  132. package/dist/components/overlays/Dialog.cjs.map +1 -1
  133. package/dist/components/overlays/Dialog.mjs +123 -123
  134. package/dist/components/overlays/Dialog.mjs.map +1 -1
  135. package/dist/components/overlays/Drawer.panel.cjs +1 -1
  136. package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
  137. package/dist/components/overlays/Drawer.panel.mjs +12 -12
  138. package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
  139. package/dist/components/overlays/Popover.cjs +1 -1
  140. package/dist/components/overlays/Popover.cjs.map +1 -1
  141. package/dist/components/overlays/Popover.mjs +173 -162
  142. package/dist/components/overlays/Popover.mjs.map +1 -1
  143. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  144. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  145. package/dist/components/overlays/TeachingPopover.mjs +96 -91
  146. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  147. package/dist/components/overlays/Tooltip.cjs +1 -1
  148. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  149. package/dist/components/overlays/Tooltip.mjs +47 -47
  150. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  151. package/dist/components/portal/Portal.cjs +1 -1
  152. package/dist/components/portal/Portal.cjs.map +1 -1
  153. package/dist/components/portal/Portal.mjs +5 -5
  154. package/dist/components/table/DataGrid.cjs +1 -1
  155. package/dist/components/table/DataGrid.cjs.map +1 -1
  156. package/dist/components/table/DataGrid.mjs +1 -1
  157. package/dist/hooks/useDismiss.cjs.map +1 -1
  158. package/dist/hooks/useDismiss.mjs.map +1 -1
  159. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  160. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  161. package/dist/hooks/useFocusVisible.cjs +2 -0
  162. package/dist/hooks/useFocusVisible.cjs.map +1 -0
  163. package/dist/hooks/useFocusVisible.mjs +49 -0
  164. package/dist/hooks/useFocusVisible.mjs.map +1 -0
  165. package/dist/hooks/useFocusableGroup.cjs +2 -0
  166. package/dist/hooks/useFocusableGroup.cjs.map +1 -0
  167. package/dist/hooks/useFocusableGroup.mjs +70 -0
  168. package/dist/hooks/useFocusableGroup.mjs.map +1 -0
  169. package/dist/hooks/useModalLayer.cjs +1 -1
  170. package/dist/hooks/useModalLayer.cjs.map +1 -1
  171. package/dist/hooks/useModalLayer.mjs +4 -4
  172. package/dist/hooks/useModalOpen.cjs +2 -0
  173. package/dist/hooks/useModalOpen.cjs.map +1 -0
  174. package/dist/hooks/useModalOpen.mjs +14 -0
  175. package/dist/hooks/useModalOpen.mjs.map +1 -0
  176. package/dist/hooks/usePopupPosition.cjs +1 -1
  177. package/dist/hooks/usePopupPosition.cjs.map +1 -1
  178. package/dist/hooks/usePopupPosition.mjs +82 -53
  179. package/dist/hooks/usePopupPosition.mjs.map +1 -1
  180. package/dist/hooks/useResolvedTarget.cjs +2 -0
  181. package/dist/hooks/useResolvedTarget.cjs.map +1 -0
  182. package/dist/hooks/useResolvedTarget.mjs +37 -0
  183. package/dist/hooks/useResolvedTarget.mjs.map +1 -0
  184. package/dist/hooks/useRovingGrid.cjs +1 -1
  185. package/dist/hooks/useRovingGrid.cjs.map +1 -1
  186. package/dist/hooks/useRovingGrid.mjs +8 -57
  187. package/dist/hooks/useRovingGrid.mjs.map +1 -1
  188. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  189. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  190. package/dist/hooks/useRovingTabIndex.mjs +142 -107
  191. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  192. package/dist/index.cjs +1 -1
  193. package/dist/index.d.cts +1364 -66
  194. package/dist/index.d.ts +1364 -66
  195. package/dist/index.mjs +132 -115
  196. package/dist/lib/classNames.cjs +1 -1
  197. package/dist/lib/classNames.cjs.map +1 -1
  198. package/dist/lib/classNames.mjs +112 -92
  199. package/dist/lib/classNames.mjs.map +1 -1
  200. package/dist/lib/initials.cjs +2 -0
  201. package/dist/lib/initials.cjs.map +1 -0
  202. package/dist/lib/initials.mjs +21 -0
  203. package/dist/lib/initials.mjs.map +1 -0
  204. package/dist/lib/layers.cjs +1 -1
  205. package/dist/lib/layers.cjs.map +1 -1
  206. package/dist/lib/layers.mjs +112 -109
  207. package/dist/lib/layers.mjs.map +1 -1
  208. package/dist/styles.css +1 -1
  209. package/package.json +1 -1
  210. package/src/styles/tokens.css +102 -0
@@ -1 +1 @@
1
- {"version":3,"file":"Option.cjs","names":["React","cn","optionClassNames","CheckIcon","renderSlot","forcedColors","useListboxOption","slotRendersContent","composeEventHandlers","useId","ListboxContext","isDev","hasWarned","optionGroupClassNames","materialiseSlotContent","usePopupPosition","useDismiss","useMergedRefs","listboxSurfaceClassNames","_Fragment","Portal","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useId","require_useMergedRefs","require_useListbox","require_useDismiss","require_Portal","require_styles","require_icons","require_usePopupPosition","react","react_jsx_runtime","OptionCheckContext","OPTION_CLASSES","OptionGroupMembers","listener","value","count","store","OptionGroupContext","OptionGroupHiddenContext","useOptionGroupMembership","groups","removes","group","remove","DISABLED_BOX_FORCED_COLORS","DISABLED_GLYPH_FORCED_COLORS","renderCheck","multiselect","classes","selected","glyph","boxClasses","disabled","glyphClasses","OptionImpl","rest","props","showCheck","groupHidden","hidden","ref","optionRef","selectOption","pressOption","highlightOption","optionAttributes","optionProps","checkIconRenders","checkIcon","checkIconEmpty","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","parentGroups","hiddenByConsumer","members","subscribe","unsubscribeMembers","unsubscribeStore","empty","hasLabel","headingRef","OptionGroup","ListboxProvider","useListboxPopup","options","surfaceElementRef","surfaceOpen","onDismiss","reason","rootRef","setFloating","preventMouseDown","event","ListboxSurface","listRefProp","listMouseDown","listRest","listProps","listboxProps","listbox","listRef","list","expanded","listClassName","emptyContent","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":"onBA+EA,IAAMqC,EAAqBrC,EAAM,cAAc,EAAI,EACnD,EAAmB,YAAc,qBAiBjC,IAAMsC,EAAiBrC,EAAAA,GACrB,6FACA,6CACA,8EACA,4DACA,uDACA,qFACA,sEACF,EAMMsC,EAAN,KAAyB,CACvB,OAA0B,IAAI,IAC9B,UAA6B,IAAI,IAEjC,UAAa,IACX,KAAK,UAAU,IAAIC,CAAQ,MACd,CACX,KAAK,UAAU,OAAOA,CAAQ,CAChC,GAGF,IAAI,EAA2B,CAG7B,OAFA,KAAK,OAAO,IAAIC,GAAQ,KAAK,OAAO,IAAIA,CAAK,GAAK,GAAK,CAAC,EACxD,KAAK,OAAO,MACC,CACX,IAAMC,GAAS,KAAK,OAAO,IAAID,CAAK,GAAK,GAAK,EAC1CC,EAAQ,EAAG,KAAK,OAAO,IAAID,EAAOC,CAAK,EACtC,KAAK,OAAO,OAAOD,CAAK,EAC7B,KAAK,OAAO,CACd,CACF,CAGA,UAAU,EAA0C,CAClD,GAAIE,IAAU,IAAA,IAAa,KAAK,OAAO,OAAS,EAAG,MAAO,GAC1D,IAAK,IAAMF,KAAS,KAAK,OAAO,KAAK,EAAG,GAAI,CAACE,EAAM,SAASF,CAAK,EAAG,MAAO,GAC3E,MAAO,EACT,CAEA,QAAuB,CACrB,IAAK,IAAMD,IAAY,CAAC,GAAG,KAAK,SAAS,EAAGA,EAAS,CACvD,CACF,EAGMI,EAAqB5C,EAAM,cAA6C,CAA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A,eACA,aAAc3B,EACd,kBAAmBK,EACnB,YAAY,GACZ,gBACA,mBACA,YACA,YACErC,EAIE,CAAE,IAAK4D,EAAa,YAAaC,EAAe,GAAGC,GAAaC,GAAa,CAAC,EAC9EC,EAAeC,EAAQ,gBAAgB,EACvCC,EAAUhH,EAAAA,cAAgC0G,EAAaI,EAAa,GAAG,EAEvEG,GACJ,EAAA9F,EAAA,IAAA,CAACC,EAAmB,SAApB,CAA6B,MAAO2B,EAClC,UAAA,EAAA5B,EAAA,IAAA,CAAC2E,EAAD,CAAiB,MAAOiB,EAAQ,QAC9B,UAAA,EAAA5F,EAAA,IAAA,CAAC,KAAD,CACE,GAAIyF,EACJ,GAAIE,EAEJ,uBAAsBA,EAAa,wBACnC,wBAAuBA,EAAa,yBACpC,YAAavH,EAAAA,qBAAqBoH,EAAeG,EAAa,WAAW,EACzE,IAAKE,EACL,aAAYlC,EACZ,kBAAiBK,EACjB,OAAQ,CAAC+B,GAAY,IAAA,GACrB,UAAWlI,EAAAA,GACTiB,EAAAA,yBAAyB,KACzB,iCACAkH,CACF,EAEC,UACC,CAAA,CACW,CAAA,CACU,CAAA,EAO/B,MAFI,CAACD,IADa,IAASA,GAAYE,GAA+C,MAClDH,GAGlC,EAAA9F,EAAA,KAAA,CAAAjB,EAAAA,SAAA,CAAA,SAAA,CACG,CAACgH,GAAYD,GACd,EAAA9F,EAAA,IAAA,CAAChB,EAAAA,OAAD,CAAiB,UACf,UAAA,EAAAgB,EAAA,IAAA,CAAC,MAAD,CACE,IAAKkG,EACL,GAAIC,EACJ,4BAA0B,GAC1B,YAAaf,EACb,UAAWvH,EAAAA,GACTiB,EAAAA,yBAAyB,KACzB,yGACAsH,CACF,EAEC,SAAAL,EAAWD,EAAOG,CAChB,CAAA,CACC,CAAA,CACR,CAAA,CAAA,CAEN,CACA,EAAe,YAAc"}
1
+ {"version":3,"file":"Option.cjs","names":["React","cn","optionClassNames","CheckIcon","renderSlot","forcedColors","useListboxOption","slotRendersContent","composeEventHandlers","useId","ListboxContext","isDev","hasWarned","optionGroupClassNames","materialiseSlotContent","usePopupPosition","resolvePositioning","useDismiss","useMergedRefs","listboxSurfaceClassNames","_Fragment","Portal","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useId","require_useMergedRefs","require_useListbox","require_usePopupPosition","require_useDismiss","require_styles","require_Portal","require_icons","react","react_jsx_runtime","OptionCheckContext","OPTION_CLASSES","OptionGroupMembers","listener","value","count","store","OptionGroupContext","OptionGroupHiddenContext","useOptionGroupMembership","groups","removes","group","remove","DISABLED_BOX_FORCED_COLORS","DISABLED_GLYPH_FORCED_COLORS","renderCheck","multiselect","classes","selected","glyph","boxClasses","disabled","glyphClasses","OptionImpl","rest","props","showCheck","groupHidden","hidden","ref","optionRef","selectOption","pressOption","highlightOption","optionAttributes","optionProps","checkIconRenders","checkIcon","checkIconEmpty","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","parentGroups","hiddenByConsumer","members","subscribe","unsubscribeMembers","unsubscribeStore","empty","hasLabel","headingRef","OptionGroup","ListboxProvider","useListboxPopup","options","surfaceElementRef","surfaceOpen","positioning","onDismiss","reason","rootRef","setFloating","preventMouseDown","event","ListboxSurface","listRefProp","listMouseDown","listRest","listProps","listboxProps","listbox","listRef","list","expanded","listClassName","emptyContent","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":"onBAgFA,IAAMsC,EAAqBtC,EAAM,cAAc,EAAI,EACnD,EAAmB,YAAc,qBAiBjC,IAAMuC,EAAiBtC,EAAAA,GACrB,6FACA,6CACA,8EACA,4DACA,uDACA,qFACA,sEACF,EAMMuC,EAAN,KAAyB,CACvB,OAA0B,IAAI,IAC9B,UAA6B,IAAI,IAEjC,UAAa,IACX,KAAK,UAAU,IAAIC,CAAQ,MACd,CACX,KAAK,UAAU,OAAOA,CAAQ,CAChC,GAGF,IAAI,EAA2B,CAG7B,OAFA,KAAK,OAAO,IAAIC,GAAQ,KAAK,OAAO,IAAIA,CAAK,GAAK,GAAK,CAAC,EACxD,KAAK,OAAO,MACC,CACX,IAAMC,GAAS,KAAK,OAAO,IAAID,CAAK,GAAK,GAAK,EAC1CC,EAAQ,EAAG,KAAK,OAAO,IAAID,EAAOC,CAAK,EACtC,KAAK,OAAO,OAAOD,CAAK,EAC7B,KAAK,OAAO,CACd,CACF,CAGA,UAAU,EAA0C,CAClD,GAAIE,IAAU,IAAA,IAAa,KAAK,OAAO,OAAS,EAAG,MAAO,GAC1D,IAAK,IAAMF,KAAS,KAAK,OAAO,KAAK,EAAG,GAAI,CAACE,EAAM,SAASF,CAAK,EAAG,MAAO,GAC3E,MAAO,EACT,CAEA,QAAuB,CACrB,IAAK,IAAMD,IAAY,CAAC,GAAG,KAAK,SAAS,EAAGA,EAAS,CACvD,CACF,EAGMI,EAAqB7C,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@@ import { listboxSurfaceClassNames as c, optionClassNames as l, optionGroupClassN
7
7
  import { useId as d } from "../../hooks/useId.mjs";
8
8
  import { useMergedRefs as f } from "../../hooks/useMergedRefs.mjs";
9
9
  import { ListboxContext as p, markListboxElement as m, useListboxOption as h } from "../../hooks/useListbox.mjs";
10
- import { useDismiss as g } from "../../hooks/useDismiss.mjs";
11
- import { Portal as _ } from "../portal/Portal.mjs";
12
- import { forcedColors as v } from "../../lib/styles.mjs";
13
- import { CheckIcon as y } from "../../lib/icons.mjs";
14
- import { usePopupPosition as b } from "../../hooks/usePopupPosition.mjs";
15
- import * as x from "react";
16
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
10
+ import { resolvePositioning as g, usePopupPosition as _ } from "../../hooks/usePopupPosition.mjs";
11
+ import { useDismiss as v } from "../../hooks/useDismiss.mjs";
12
+ import { forcedColors as y } from "../../lib/styles.mjs";
13
+ import { Portal as b } from "../portal/Portal.mjs";
14
+ import { CheckIcon as x } from "../../lib/icons.mjs";
15
+ import * as S from "react";
16
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
17
17
  //#region src/components/input/Option.tsx
18
- var T = x.createContext(!0);
19
- T.displayName = "OptionCheckContext";
20
- var E = e("flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground", "bg-(--option-bg) [--option-bg:transparent]", "not-disabled:not-aria-disabled:hover:[--option-bg:var(--wave-subtle-hover)]", "data-[selected]:[--option-bg:var(--wave-subtle-selected)]", "data-[active]:[--option-bg:var(--wave-subtle-hover)]", "data-[active]:outline-2 data-[active]:-outline-offset-2 data-[active]:outline-ring", "aria-disabled:cursor-not-allowed aria-disabled:text-muted-foreground"), D = class {
18
+ var E = S.createContext(!0);
19
+ E.displayName = "OptionCheckContext";
20
+ var D = e("flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-body-1 text-foreground", "bg-(--option-bg) [--option-bg:transparent]", "not-disabled:not-aria-disabled:hover:[--option-bg:var(--wave-subtle-hover)]", "data-[selected]:[--option-bg:var(--wave-subtle-selected)]", "data-[active]:[--option-bg:var(--wave-subtle-hover)]", "data-[active]:outline-2 data-[active]:-outline-offset-2 data-[active]:outline-ring", "aria-disabled:cursor-not-allowed aria-disabled:text-muted-foreground"), O = class {
21
21
  counts = /* @__PURE__ */ new Map();
22
22
  listeners = /* @__PURE__ */ new Set();
23
23
  subscribe = (e) => (this.listeners.add(e), () => {
@@ -37,13 +37,13 @@ var E = e("flex cursor-pointer select-none items-center gap-2 px-3 py-1.5 text-b
37
37
  notify() {
38
38
  for (let e of [...this.listeners]) e();
39
39
  }
40
- }, O = x.createContext([]);
41
- O.displayName = "OptionGroupContext";
42
- var k = x.createContext(!1);
43
- k.displayName = "OptionGroupHiddenContext";
44
- function A(e) {
45
- let t = x.useContext(O);
46
- x.useLayoutEffect(() => {
40
+ }, k = S.createContext([]);
41
+ k.displayName = "OptionGroupContext";
42
+ var A = S.createContext(!1);
43
+ A.displayName = "OptionGroupHiddenContext";
44
+ function j(e) {
45
+ let t = S.useContext(k);
46
+ S.useLayoutEffect(() => {
47
47
  if (t.length === 0) return;
48
48
  let n = t.map((t) => t.add(e));
49
49
  return () => {
@@ -51,160 +51,162 @@ function A(e) {
51
51
  };
52
52
  }, [t, e]);
53
53
  }
54
- var j = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]", M = "forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none";
55
- function N(t, { selected: n, multiselect: r, disabled: i }) {
54
+ var M = "forced-colors:border-[GrayText] forced-colors:bg-[Canvas]", N = "forced-colors:text-[GrayText] forced-colors:forced-color-adjust-none";
55
+ function P(t, { selected: n, multiselect: r, disabled: i }) {
56
56
  if (!r) {
57
57
  let r = e(l.checkIcon, "shrink-0", !n && "invisible");
58
- return t === void 0 ? /* @__PURE__ */ C(y, { className: r }) : a(t, "span", e("inline-flex", r), { "aria-hidden": !0 });
58
+ return t === void 0 ? /* @__PURE__ */ w(x, { className: r }) : a(t, "span", e("inline-flex", r), { "aria-hidden": !0 });
59
59
  }
60
60
  let o;
61
- o = i ? e("border-current bg-transparent", j) : n ? e("border-primary bg-primary text-primary-foreground", v.selectedLeaf) : e("border-stroke-accessible bg-transparent", v.control);
62
- let s = i ? M : void 0;
63
- return /* @__PURE__ */ C("span", {
61
+ o = i ? e("border-current bg-transparent", M) : n ? e("border-primary bg-primary text-primary-foreground", y.selectedLeaf) : e("border-stroke-accessible bg-transparent", y.control);
62
+ let s = i ? N : void 0;
63
+ return /* @__PURE__ */ w("span", {
64
64
  "aria-hidden": "true",
65
65
  "data-wave-option-box": "",
66
66
  className: e(l.indicator, "flex h-4 w-4 shrink-0 items-center justify-center rounded-xs border", o),
67
- children: n && (t === void 0 ? /* @__PURE__ */ C(y, {
67
+ children: n && (t === void 0 ? /* @__PURE__ */ w(x, {
68
68
  size: 12,
69
69
  className: e(l.checkIcon, s)
70
70
  }) : a(t, "span", e(l.checkIcon, "inline-flex shrink-0", s), { "aria-hidden": !0 }))
71
71
  });
72
72
  }
73
- function P(t) {
74
- let { value: n, label: i, textValue: a, disabled: c = !1, hidden: u = !1, checkIcon: d, className: f, children: p, onClick: m, onMouseDown: g, onPointerMove: _, ref: y, ...b } = t, S = x.useContext(T), D = x.useContext(k), { selected: O, multiselect: j, optionProps: M } = h({
73
+ function F(t) {
74
+ let { value: n, label: i, textValue: a, disabled: c = !1, hidden: u = !1, checkIcon: d, className: f, children: p, onClick: m, onMouseDown: g, onPointerMove: _, ref: v, ...b } = t, x = S.useContext(E), C = S.useContext(A), { selected: O, multiselect: k, optionProps: M } = h({
75
75
  value: n,
76
76
  label: i,
77
77
  textValue: a,
78
78
  disabled: c,
79
- hidden: u || D
80
- }, y);
81
- A(n);
82
- let { ref: P, onClick: F, onMouseDown: I, onPointerMove: L, ...R } = M, z = d != null && o(d), B = d != null && !z;
83
- return x.useEffect(() => {
79
+ hidden: u || C
80
+ }, v);
81
+ j(n);
82
+ let { ref: N, onClick: F, onMouseDown: I, onPointerMove: L, ...R } = M, z = d != null && o(d), B = d != null && !z;
83
+ return S.useEffect(() => {
84
84
  B && r("Option:checkIcon-empty", "Option: `checkIcon` renders nothing, so the default check shows: a selected option must show its state. Pass a glyph, or leave it unset.");
85
- }, [B]), /* @__PURE__ */ w("li", {
85
+ }, [B]), /* @__PURE__ */ T("li", {
86
86
  "data-value": n,
87
87
  ...b,
88
88
  ...R,
89
- ref: P,
89
+ ref: N,
90
90
  onClick: s(m, F),
91
91
  onMouseDown: s(g, I),
92
92
  onPointerMove: s(_, L),
93
- className: e(l.root, E, O && !(j && S) && v.selectedContainer, f),
94
- children: [S && N(z ? d : void 0, {
93
+ className: e(l.root, D, O && !(k && x) && y.selectedContainer, f),
94
+ children: [x && P(z ? d : void 0, {
95
95
  selected: O,
96
- multiselect: j,
96
+ multiselect: k,
97
97
  disabled: c
98
- }), /* @__PURE__ */ C("span", {
98
+ }), /* @__PURE__ */ w("span", {
99
99
  className: e(l.content, "min-w-0 flex-1"),
100
100
  children: p ?? n
101
101
  })]
102
102
  });
103
103
  }
104
- P.displayName = "Option";
105
- var F = /* @__PURE__ */ x.memo(P);
106
104
  F.displayName = "Option";
107
- var I = /* @__PURE__ */ m(F, "option"), L = 1, R = 3;
108
- function z(e) {
105
+ var I = /* @__PURE__ */ S.memo(F);
106
+ I.displayName = "Option";
107
+ var L = /* @__PURE__ */ m(I, "option"), R = 1, z = 3;
108
+ function B(e) {
109
109
  if (e === null) return "";
110
- if (e.nodeType === R) return e.textContent ?? "";
111
- if (e.nodeType !== L) return "";
110
+ if (e.nodeType === z) return e.textContent ?? "";
111
+ if (e.nodeType !== R) return "";
112
112
  let t = e;
113
113
  if (t.getAttribute("aria-hidden") === "true" || t.hasAttribute("hidden")) return "";
114
114
  let n = t.getAttribute("aria-label")?.trim();
115
115
  if (n) return n;
116
116
  if (t.localName === "img") return t.getAttribute("alt") ?? "";
117
117
  let r = "";
118
- for (let e of Array.from(t.childNodes)) r += z(e);
118
+ for (let e of Array.from(t.childNodes)) r += B(e);
119
119
  return r;
120
120
  }
121
- function B(e, t, n, r, i) {
122
- return n !== void 0 && n !== r && n.trim() !== "" || t !== void 0 && t.trim() !== "" ? !0 : n === r ? typeof e == "string" || typeof e == "number" ? String(e).trim() !== "" : z(i).trim() !== "" : !1;
121
+ function V(e, t, n, r, i) {
122
+ return n !== void 0 && n !== r && n.trim() !== "" || t !== void 0 && t.trim() !== "" ? !0 : n === r ? typeof e == "string" || typeof e == "number" ? String(e).trim() !== "" : B(i).trim() !== "" : !1;
123
123
  }
124
- var V = "OptionGroup:unnamed";
125
- function H({ label: a, className: s, children: c, hidden: l, "aria-label": f, "aria-labelledby": m, ref: h, ...g }) {
126
- let _ = d("option-group"), v = x.useContext(p)?.store, y = x.useContext(O), b = x.useContext(k) || !!l, [S] = x.useState(() => new D()), T = x.useMemo(() => [...y, S], [y, S]), E = x.useCallback((e) => {
127
- let t = S.subscribe(e), n = v?.subscribe(e);
124
+ var H = "OptionGroup:unnamed";
125
+ function U({ label: a, className: s, children: c, hidden: l, "aria-label": f, "aria-labelledby": m, ref: h, ...g }) {
126
+ let _ = d("option-group"), v = S.useContext(p)?.store, y = S.useContext(k), b = S.useContext(A) || !!l, [x] = S.useState(() => new O()), C = S.useMemo(() => [...y, x], [y, x]), E = S.useCallback((e) => {
127
+ let t = x.subscribe(e), n = v?.subscribe(e);
128
128
  return () => {
129
129
  t(), n?.();
130
130
  };
131
- }, [S, v]), A = x.useSyncExternalStore(E, () => S.allHidden(v), () => !1), j = o(a), M = m ?? (f === void 0 && j ? _ : void 0), N = x.useRef(null);
132
- return x.useEffect(() => {
133
- n && !t(V) && (B(a, f, M, _, N.current) || r(V, "OptionGroup: the group has no name. Give it a text `label`, `aria-label` or `aria-labelledby`."));
131
+ }, [x, v]), D = S.useSyncExternalStore(E, () => x.allHidden(v), () => !1), j = o(a), M = m ?? (f === void 0 && j ? _ : void 0), N = S.useRef(null);
132
+ return S.useEffect(() => {
133
+ n && !t(H) && (V(a, f, M, _, N.current) || r(H, "OptionGroup: the group has no name. Give it a text `label`, `aria-label` or `aria-labelledby`."));
134
134
  }, [
135
135
  a,
136
136
  f,
137
137
  M,
138
138
  _
139
- ]), /* @__PURE__ */ w("li", {
139
+ ]), /* @__PURE__ */ T("li", {
140
140
  ...g,
141
141
  ref: h,
142
142
  role: "presentation",
143
- hidden: l || A || void 0,
143
+ hidden: l || D || void 0,
144
144
  className: e(u.root, s),
145
- children: [j && /* @__PURE__ */ C("div", {
145
+ children: [j && /* @__PURE__ */ w("div", {
146
146
  ref: N,
147
147
  id: _,
148
148
  role: "presentation",
149
149
  className: e(u.label, "px-3 py-1 text-caption-1 font-semibold text-muted-foreground"),
150
150
  children: i(a)
151
- }), /* @__PURE__ */ C("ul", {
151
+ }), /* @__PURE__ */ w("ul", {
152
152
  role: "group",
153
153
  "aria-label": f,
154
154
  "aria-labelledby": M,
155
155
  className: u.list,
156
- children: /* @__PURE__ */ C(k.Provider, {
156
+ children: /* @__PURE__ */ w(A.Provider, {
157
157
  value: b,
158
- children: /* @__PURE__ */ C(O.Provider, {
159
- value: T,
158
+ children: /* @__PURE__ */ w(k.Provider, {
159
+ value: C,
160
160
  children: c
161
161
  })
162
162
  })
163
163
  })]
164
164
  });
165
165
  }
166
- H.displayName = "OptionGroup";
167
- var U = /* @__PURE__ */ m(H, "group");
168
- function W({ value: e, children: t }) {
169
- return /* @__PURE__ */ C(p.Provider, {
166
+ U.displayName = "OptionGroup";
167
+ var W = /* @__PURE__ */ m(U, "group");
168
+ function G({ value: e, children: t }) {
169
+ return /* @__PURE__ */ w(p.Provider, {
170
170
  value: e,
171
171
  children: t
172
172
  });
173
173
  }
174
- W.displayName = "ListboxProvider";
175
- function G(e) {
176
- let { open: t, surfaceOpen: n, onDismiss: r, rootRef: i, anchorRef: a } = e, o = x.useRef(null), { setReference: s, setFloating: c, floatingProps: l } = b({
174
+ G.displayName = "ListboxProvider";
175
+ function K(e) {
176
+ let { open: t, surfaceOpen: n, onDismiss: r, rootRef: i, anchorRef: a, positioning: o } = e, s = S.useRef(null), { setReference: c, setFloating: l, floatingProps: u } = _({
177
177
  open: n,
178
178
  side: "bottom",
179
179
  align: "start",
180
- matchReferenceWidth: !0,
181
- fitViewport: !0
182
- }), { layerId: u } = g({
180
+ ...g(o, {
181
+ matchReferenceWidth: !0,
182
+ fitViewport: !0
183
+ })
184
+ }), { layerId: d } = v({
183
185
  open: t,
184
186
  onDismiss: (e) => r(e),
185
- refs: [i, o],
187
+ refs: [i, s],
186
188
  anchorRef: a,
187
189
  kind: "listbox",
188
190
  escape: n,
189
191
  focusOutside: !0
190
192
  });
191
193
  return {
192
- layerId: u,
193
- setReference: s,
194
- surfaceRef: f(o, c),
195
- floatingProps: l
194
+ layerId: d,
195
+ setReference: c,
196
+ surfaceRef: f(s, l),
197
+ floatingProps: u
196
198
  };
197
199
  }
198
- function K(e) {
200
+ function q(e) {
199
201
  e.preventDefault();
200
202
  }
201
- function q(t) {
202
- let { listbox: n, layerId: r, surfaceRef: i, floatingProps: a, open: o, expanded: l, emptyContent: u, "aria-label": d, "aria-labelledby": p, showCheck: m = !0, listClassName: h, surfaceClassName: g, listProps: v, children: y } = t, { ref: b, onMouseDown: x, ...E } = v ?? {}, D = n.getListboxProps(), O = f(b, D.ref), k = /* @__PURE__ */ C(T.Provider, {
203
+ function J(t) {
204
+ let { listbox: n, layerId: r, surfaceRef: i, floatingProps: a, open: o, expanded: l, emptyContent: u, "aria-label": d, "aria-labelledby": p, showCheck: m = !0, listClassName: h, surfaceClassName: g, listProps: _, children: v } = t, { ref: y, onMouseDown: x, ...S } = _ ?? {}, D = n.getListboxProps(), O = f(y, D.ref), k = /* @__PURE__ */ w(E.Provider, {
203
205
  value: m,
204
- children: /* @__PURE__ */ C(W, {
206
+ children: /* @__PURE__ */ w(G, {
205
207
  value: n.context,
206
- children: /* @__PURE__ */ C("ul", {
207
- ...E,
208
+ children: /* @__PURE__ */ w("ul", {
209
+ ...S,
208
210
  ...D,
209
211
  "aria-multiselectable": D["aria-multiselectable"],
210
212
  "aria-activedescendant": D["aria-activedescendant"],
@@ -214,24 +216,24 @@ function q(t) {
214
216
  "aria-labelledby": p,
215
217
  hidden: !l || void 0,
216
218
  className: e(c.list, "min-h-0 max-h-60 overflow-auto", h),
217
- children: y
219
+ children: v
218
220
  })
219
221
  })
220
222
  });
221
- return !l && (!o || l || u == null) ? k : /* @__PURE__ */ w(S, { children: [!l && k, /* @__PURE__ */ C(_, {
223
+ return !l && (!o || l || u == null) ? k : /* @__PURE__ */ T(C, { children: [!l && k, /* @__PURE__ */ w(b, {
222
224
  layerId: r,
223
- children: /* @__PURE__ */ C("div", {
225
+ children: /* @__PURE__ */ w("div", {
224
226
  ref: i,
225
227
  ...a,
226
228
  "data-wave-listbox-surface": "",
227
- onMouseDown: K,
229
+ onMouseDown: q,
228
230
  className: e(c.root, "flex flex-col overflow-hidden rounded border border-border bg-background py-1 text-foreground shadow-4", g),
229
231
  children: l ? k : u
230
232
  })
231
233
  })] });
232
234
  }
233
- q.displayName = "ListboxSurface";
235
+ J.displayName = "ListboxSurface";
234
236
  //#endregion
235
- export { W as ListboxProvider, q as ListboxSurface, I as Option, U as OptionGroup, G as useListboxPopup };
237
+ export { G as ListboxProvider, J as ListboxSurface, L as Option, W as OptionGroup, K as useListboxPopup };
236
238
 
237
239
  //# sourceMappingURL=Option.mjs.map