@mortenbrudvik/waveui 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +97 -2
  2. package/dist/components/button/Link.cjs +1 -1
  3. package/dist/components/button/Link.cjs.map +1 -1
  4. package/dist/components/button/Link.mjs +4 -4
  5. package/dist/components/data-display/AvatarGroup.cjs +1 -1
  6. package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
  7. package/dist/components/data-display/AvatarGroup.mjs +10 -10
  8. package/dist/components/data-display/InfoButton.cjs +1 -1
  9. package/dist/components/data-display/InfoButton.cjs.map +1 -1
  10. package/dist/components/data-display/InfoButton.mjs +12 -12
  11. package/dist/components/feedback/Toaster.cjs +1 -1
  12. package/dist/components/feedback/Toaster.cjs.map +1 -1
  13. package/dist/components/feedback/Toaster.mjs +235 -235
  14. package/dist/components/feedback/Toaster.mjs.map +1 -1
  15. package/dist/components/input/Combobox.cjs +1 -1
  16. package/dist/components/input/Combobox.cjs.map +1 -1
  17. package/dist/components/input/Combobox.mjs +176 -175
  18. package/dist/components/input/Combobox.mjs.map +1 -1
  19. package/dist/components/input/DatePicker.cjs +1 -1
  20. package/dist/components/input/DatePicker.cjs.map +1 -1
  21. package/dist/components/input/DatePicker.mjs +188 -187
  22. package/dist/components/input/DatePicker.mjs.map +1 -1
  23. package/dist/components/input/Dropdown.cjs +1 -1
  24. package/dist/components/input/Dropdown.cjs.map +1 -1
  25. package/dist/components/input/Dropdown.mjs +41 -40
  26. package/dist/components/input/Dropdown.mjs.map +1 -1
  27. package/dist/components/input/Option.cjs +1 -1
  28. package/dist/components/input/Option.cjs.map +1 -1
  29. package/dist/components/input/Option.mjs +89 -87
  30. package/dist/components/input/Option.mjs.map +1 -1
  31. package/dist/components/input/TagPicker.root.cjs +1 -1
  32. package/dist/components/input/TagPicker.root.cjs.map +1 -1
  33. package/dist/components/input/TagPicker.root.mjs +136 -135
  34. package/dist/components/input/TagPicker.root.mjs.map +1 -1
  35. package/dist/components/input/TimePicker.cjs +1 -1
  36. package/dist/components/input/TimePicker.cjs.map +1 -1
  37. package/dist/components/input/TimePicker.mjs +156 -154
  38. package/dist/components/input/TimePicker.mjs.map +1 -1
  39. package/dist/components/navigation/Menu.popover.cjs +1 -1
  40. package/dist/components/navigation/Menu.popover.cjs.map +1 -1
  41. package/dist/components/navigation/Menu.popover.mjs +137 -127
  42. package/dist/components/navigation/Menu.popover.mjs.map +1 -1
  43. package/dist/components/navigation/Menu.root.cjs +1 -1
  44. package/dist/components/navigation/Menu.root.cjs.map +1 -1
  45. package/dist/components/navigation/Menu.root.mjs +4 -4
  46. package/dist/components/overlays/Dialog.cjs +1 -1
  47. package/dist/components/overlays/Dialog.cjs.map +1 -1
  48. package/dist/components/overlays/Dialog.mjs +123 -123
  49. package/dist/components/overlays/Dialog.mjs.map +1 -1
  50. package/dist/components/overlays/Drawer.panel.cjs +1 -1
  51. package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
  52. package/dist/components/overlays/Drawer.panel.mjs +12 -12
  53. package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
  54. package/dist/components/overlays/Popover.cjs +1 -1
  55. package/dist/components/overlays/Popover.cjs.map +1 -1
  56. package/dist/components/overlays/Popover.mjs +173 -162
  57. package/dist/components/overlays/Popover.mjs.map +1 -1
  58. package/dist/components/overlays/TeachingPopover.cjs +1 -1
  59. package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
  60. package/dist/components/overlays/TeachingPopover.mjs +96 -91
  61. package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
  62. package/dist/components/overlays/Tooltip.cjs +1 -1
  63. package/dist/components/overlays/Tooltip.cjs.map +1 -1
  64. package/dist/components/overlays/Tooltip.mjs +47 -47
  65. package/dist/components/overlays/Tooltip.mjs.map +1 -1
  66. package/dist/components/portal/Portal.cjs +1 -1
  67. package/dist/components/portal/Portal.cjs.map +1 -1
  68. package/dist/components/portal/Portal.mjs +5 -5
  69. package/dist/components/table/DataGrid.cjs +1 -1
  70. package/dist/components/table/DataGrid.cjs.map +1 -1
  71. package/dist/components/table/DataGrid.mjs +1 -1
  72. package/dist/hooks/useDismiss.cjs.map +1 -1
  73. package/dist/hooks/useDismiss.mjs.map +1 -1
  74. package/dist/hooks/useFocusTrap.cjs.map +1 -1
  75. package/dist/hooks/useFocusTrap.mjs.map +1 -1
  76. package/dist/hooks/useFocusVisible.cjs +2 -0
  77. package/dist/hooks/useFocusVisible.cjs.map +1 -0
  78. package/dist/hooks/useFocusVisible.mjs +49 -0
  79. package/dist/hooks/useFocusVisible.mjs.map +1 -0
  80. package/dist/hooks/useFocusableGroup.cjs +2 -0
  81. package/dist/hooks/useFocusableGroup.cjs.map +1 -0
  82. package/dist/hooks/useFocusableGroup.mjs +70 -0
  83. package/dist/hooks/useFocusableGroup.mjs.map +1 -0
  84. package/dist/hooks/useModalLayer.cjs +1 -1
  85. package/dist/hooks/useModalLayer.cjs.map +1 -1
  86. package/dist/hooks/useModalLayer.mjs +4 -4
  87. package/dist/hooks/useModalOpen.cjs +2 -0
  88. package/dist/hooks/useModalOpen.cjs.map +1 -0
  89. package/dist/hooks/useModalOpen.mjs +14 -0
  90. package/dist/hooks/useModalOpen.mjs.map +1 -0
  91. package/dist/hooks/usePopupPosition.cjs +1 -1
  92. package/dist/hooks/usePopupPosition.cjs.map +1 -1
  93. package/dist/hooks/usePopupPosition.mjs +82 -53
  94. package/dist/hooks/usePopupPosition.mjs.map +1 -1
  95. package/dist/hooks/useResolvedTarget.cjs +2 -0
  96. package/dist/hooks/useResolvedTarget.cjs.map +1 -0
  97. package/dist/hooks/useResolvedTarget.mjs +37 -0
  98. package/dist/hooks/useResolvedTarget.mjs.map +1 -0
  99. package/dist/hooks/useRovingGrid.cjs +1 -1
  100. package/dist/hooks/useRovingGrid.cjs.map +1 -1
  101. package/dist/hooks/useRovingGrid.mjs +8 -57
  102. package/dist/hooks/useRovingGrid.mjs.map +1 -1
  103. package/dist/hooks/useRovingTabIndex.cjs +1 -1
  104. package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
  105. package/dist/hooks/useRovingTabIndex.mjs +142 -107
  106. package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
  107. package/dist/index.cjs +1 -1
  108. package/dist/index.d.cts +814 -18
  109. package/dist/index.d.ts +814 -18
  110. package/dist/index.mjs +120 -108
  111. package/dist/lib/layers.cjs +1 -1
  112. package/dist/lib/layers.cjs.map +1 -1
  113. package/dist/lib/layers.mjs +112 -109
  114. package/dist/lib/layers.mjs.map +1 -1
  115. package/dist/styles.css +1 -1
  116. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Popover.cjs","names":["React","getTriggerFocusTarget","getTabbableThrough","useControllable","useEventCallback","useIsClient","useId","usePopupPosition","isConnectedAndFocusable","useDismiss","useContextMenuAnchor","useTriggerFocusRef","useMergedRefs","getFirstTabbable","isFocusInSurfaceTree","useHoverIntent","usePopoverTabOrder","composeEventHandlers","useTriggerElement","slotRendersContent","isDev","Portal","cn","popoverContentClassNames","PopoverBeak","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_focus","require_useMergedRefs","require_useIsClient","require_useDismiss","require_Portal","require_usePopupPosition","require_useRestoreFocus","require_useHoverIntent","require_Popover_shared","require_useTriggerElement","require_useContextMenuAnchor","react","react_jsx_runtime","PopoverContext","inertContext","getInertContext","usePopoverContext","componentName","presentIds","present","ids","id","doc","findTriggerLabelId","trigger","resolvedId","named","referencesText","el","subscribeNothing","isElementTarget","target","createResolvedRef","resolve","getPopoverPreviousStop","anchor","surface","order","PopoverRoot","openProp","openState","setOpen","defaultOpen","onOpenChange","hoverCloseRef","requestOpen","next","isHoverClose","isClient","open","openReason","setOpenReason","hoverRequested","setHoverRequested","previousOpen","setPreviousOpen","reason","generatedContentId","customContentId","setCustomContentId","contentId","triggerId","resolvedTriggerId","setResolvedTriggerId","setSurface","triggerElement","setTriggerElement","triggerRef","surfaceRef","arrowRef","targetElement","targetRef","placedSide","contextOpenerRef","resolveFocusTarget","gestureOpener","openOnContext","triggerTarget","targetEl","focusTargetRef","isOutsidePress","event","ignoreOutsideRefs","focusContentRef","contextAnchor","contextOrigin","contextOpener","contextTriggerHandlers","contextSurfaceHandlers","origin","triggerFocusRef","triggerElementRef","surfaceElementRef","setFloating","setReference","fromContext","openOnHover","hoverEnabled","canHoverClose","layerId","hoverTriggerHandlers","hoverSurfaceHandlers","cancelHover","onTriggerClick","current","resolveTabAnchor","tabAnchorRef","onTriggerKeyDown","surfaceElement","first","onContentKeyDown","keyboardContext","context","floatingProps","arrowStyles","PopoverTrigger","idProp","rest","hover","gesture","elementRef","ref","triggerProps","contextMode","onClick","onKeyDown","onContextMenu","onPointerEnter","onPointerMove","onPointerLeave","children","PopoverContent","ariaLabel","ariaLabelledBy","titleId","hasTitle","title","unnamed","checkTrigger","subscribeTrigger","observer","onChange","triggerLabelId","labelledBy","customId","labelIds","style","onContentContextMenu","className","Popover"],"sources":["../../../src/components/overlays/Popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { popoverContentClassNames } from '../../lib/classNames';\nimport { isDev, reportMissingContext, warnOnce } from '../../lib/dev';\nimport { slotRendersContent } from '../../lib/slot';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { focusElement, getFirstTabbable, isConnectedAndFocusable } from '../../lib/focus';\nimport type { PopupAlign, PopupSide, PopupTarget } from '../../lib/types';\nimport { useId } from '../../hooks/useId';\nimport { useControllable, type SetValue } from '../../hooks/useControllable';\nimport { useContextMenuAnchor, type ContextMenuAnchor } from '../../hooks/useContextMenuAnchor';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useHoverIntent, type HoverIntent } from '../../hooks/useHoverIntent';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport {\n getTriggerFocusTarget,\n useTriggerElement,\n useTriggerFocusRef,\n} from '../../hooks/useTriggerElement';\nimport { Portal } from '../portal/Portal';\nimport {\n getTabbableThrough,\n isFocusInSurfaceTree,\n PopoverBeak,\n usePopoverTabOrder,\n type PopoverPhysicalSide,\n} from './Popover.shared';\n\n/** Properties for the Popover component. */\nexport interface PopoverProps {\n /**\n * Controlled open state of the popover. The content renders only in the browser: an open\n * popover is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Default open state for uncontrolled usage. The content renders only in the browser: a\n * popover open by default is closed in the server HTML and opens once it has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Called with the requested open state when it differs from the current one: a trigger click,\n * Escape and an outside press; the hover opening and closing of `openOnHover`; and, with\n * `openOnContext`, a context gesture (a right click, a macOS Ctrl+click, Shift+F10 or the\n * ContextMenu key), a right click outside, and a scroll that moves the row it opened at.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Side of the trigger the content opens on. `start`/`end` follow the writing direction. The\n * content flips to the opposite side when there is not enough room.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment of the content along the trigger's edge.\n * @default 'start'\n */\n align?: PopupAlign;\n /**\n * Elements outside the popover whose presses must not dismiss it, e.g. an external toggle\n * button that opens and closes the popover itself.\n */\n ignoreOutsideRefs?: ReadonlyArray<React.RefObject<HTMLElement | null>>;\n /**\n * Open the popover when a mouse pointer rests on its trigger (a hover card), and close it once\n * the pointer has been off the trigger and the content for `closeDelay` while focus is not\n * inside the content. A popover opened by hover does not take focus, and its hover close leaves\n * focus where it is; a click on its trigger keeps it open and keeps focus where it is (a second\n * click closes it, as without hover). After Escape or an outside press it does not reopen until\n * the pointer has left the trigger. Touch and pen never open it by hover, and an `aria-disabled`\n * trigger never opens. A triangle between the trigger and the content keeps it open while the\n * pointer moves diagonally into it. Ignored with `openOnContext` (development warning).\n * @default false\n */\n openOnHover?: boolean;\n /**\n * Milliseconds a hovering mouse pointer rests on the trigger before the popover opens (mouse\n * hover only).\n * @default 250\n */\n openDelay?: number;\n /**\n * Milliseconds before a hover-opened popover closes once the mouse pointer has left it and its\n * trigger (Fluent's `mouseLeaveDelay`; mouse hover only).\n * @default 500\n */\n closeDelay?: number;\n /**\n * Make `Popover.Trigger` a context-menu region (a list, a row, a canvas): a right click (a\n * Ctrl+click on macOS, a long press where the browser reports one) opens the popover at the\n * pointer and leaves focus where it is (Tab from that element enters the content), and\n * Shift+F10 or the ContextMenu key opens it at the focused element inside the region and moves\n * focus into the content, instead of a click. Focus returns to the element that had it. The\n * browser's context menu is suppressed there and inside the content, except in text fields\n * inside the region, which keep it. A press elsewhere, a right click outside or a scroll that\n * moves the row it opened at (the one under the pointer, or the focused one), as a scroll of\n * the region's own content does, closes it. The trigger gets no `aria-haspopup`/`aria-expanded`\n * (it is not a popover button; with a render-prop child, do not spread them): name the content\n * with `title`, `aria-label` or `aria-labelledby`, and consider `aria-keyshortcuts=\"Shift+F10\"`\n * on the region. iOS Safari reports no long press. `openOnHover` is ignored with it.\n * @default false\n */\n openOnContext?: boolean;\n /**\n * Where to place the content instead of next to `Popover.Trigger`: an element or a\n * `VirtualElement` (a rectangle, such as a point; an inline object is fine). With a controlled\n * `open`, a popover with a `target` needs no trigger; name it with `title`, `aria-label` or\n * `aria-labelledby`, and give a toggle button you use as the target `aria-haspopup=\"dialog\"`,\n * `aria-expanded` and `aria-controls` yourself. A press on a target element does not close the\n * popover, and Tab from it enters the content when there is no trigger. Hold the element in\n * state (a ref cannot be observed; TeachingPopover's `target` also takes a ref). A popover\n * opened by `openOnContext` is placed at the gesture instead.\n */\n target?: PopupTarget;\n /** `Popover.Trigger` and `Popover.Content`. */\n children: React.ReactNode;\n}\n\n/**\n * Props the trigger puts on its element; a render-prop child of `Popover.Trigger` receives them\n * (spread them onto the element that opens the popover). With `openOnContext` the element is a\n * context-menu region, not a popover button: do not spread `aria-haspopup`, `aria-expanded` and\n * `aria-controls` onto it (`aria-expanded` is then always `false`, `aria-controls` is absent and\n * `onClick` does nothing); spread ones are removed after each commit, with a development warning.\n */\nexport type PopoverTriggerChildProps = Omit<React.HTMLAttributes<HTMLElement>, 'children'> & {\n id: string;\n 'aria-haspopup': 'dialog';\n 'aria-expanded': boolean;\n /** The content's id, only while the popover is open (never with `openOnContext`). */\n 'aria-controls': string | undefined;\n onClick: React.MouseEventHandler<HTMLElement>;\n /**\n * Moves Tab from the open trigger into the portaled content (which lives at the end of the\n * document), so the keyboard order follows the trigger.\n */\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n ref: React.RefCallback<HTMLElement>;\n};\n\n/** Properties for the PopoverTrigger sub-component. */\nexport interface PopoverTriggerProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that toggles the popover (its props are merged onto it), or a render function\n * that receives the trigger props.\n */\n children: React.ReactNode | ((props: PopoverTriggerChildProps) => React.ReactNode);\n /**\n * `false` renders the 0.4 wrapper `<span>` carrying the trigger props around the children\n * instead of merging them onto the child. `aria-haspopup`, `aria-expanded` and `aria-controls`,\n * which a generic element cannot carry, go to the first element in the tab order inside the\n * span. A render-prop child ignores `asChild` and receives every prop.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Properties for the PopoverContent sub-component. */\nexport interface PopoverContentProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Content to render inside the popover. */\n children: React.ReactNode;\n /**\n * Visible heading rendered at the top of the popover; it names the dialog. Without `title`,\n * `aria-label` or `aria-labelledby`, the popover is labelled by its trigger, except with\n * `openOnContext` (a region's text is no name), where it needs one of them.\n */\n title?: React.ReactNode;\n /** Id of the surface; the trigger's `aria-controls` follows it. Defaults to a generated id. */\n id?: string;\n /** Ref to the popover surface. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: SetValue<boolean>;\n /** The content's id: the consumer's `Popover.Content` id when given, else a generated one. */\n contentId: string;\n /** `Popover.Content` reports the consumer's `id` so the trigger's `aria-controls` follows it. */\n setCustomContentId: (id: string | undefined) => void;\n triggerId: string;\n /** The id the trigger element ended up with (the child's own id wins). */\n resolvedTriggerId: string | undefined;\n setResolvedTriggerId: (id: string) => void;\n triggerRef: React.RefObject<HTMLElement | null>;\n /** The trigger element as state (read during render, e.g. to check the labelling id). */\n triggerElement: HTMLElement | null;\n /** Ref callback for the trigger element: focus-restore target and positioning anchor. */\n triggerElementRef: React.RefCallback<HTMLElement>;\n /** Ref callback for the surface: dismissal, focus restore and positioning. */\n surfaceElementRef: React.RefCallback<HTMLElement>;\n arrowRef: React.RefObject<HTMLDivElement | null>;\n /** The trigger's click: toggles the popover, or pins one that hover opened (keeps it open). */\n onTriggerClick: () => void;\n /** Tab from the open trigger enters the portaled content. */\n onTriggerKeyDown: React.KeyboardEventHandler<HTMLElement>;\n /** Hover opening (`openOnHover`): composed onto the trigger; `null` without it. */\n hoverTriggerHandlers: HoverIntent['triggerHandlers'] | null;\n /** Hover opening (`openOnHover`): composed onto the content; `null` without it. */\n hoverSurfaceHandlers: HoverIntent['surfaceHandlers'] | null;\n /** `openOnContext`: the trigger is a context-menu region, not a popover button. */\n contextMode: boolean;\n /** Context gestures (`openOnContext`): composed onto the trigger; `null` without it. */\n contextTriggerHandlers: ContextMenuAnchor['triggerHandlers'] | null;\n /** Composed onto the content: suppresses the browser's context menu there in context mode. */\n onContentContextMenu: React.MouseEventHandler<HTMLElement>;\n /** Opened by a keyboard context gesture: the content takes focus (itself when nothing can). */\n keyboardContext: boolean;\n /** Tab past the content's edges continues around the trigger in the page order. */\n onContentKeyDown: React.KeyboardEventHandler<HTMLElement>;\n layerId: string;\n floatingProps: { 'data-side': string; 'data-align': string; style: React.CSSProperties };\n arrowStyles: React.CSSProperties;\n placedSide: PopoverPhysicalSide;\n}\n\nconst PopoverContext = React.createContext<PopoverContextValue | null>(null);\nPopoverContext.displayName = 'PopoverContext';\n\nlet inertContext: PopoverContextValue | null = null;\n\n/** Production fallback for a misplaced sub-component: a closed popover that does nothing. */\nfunction getInertContext(): PopoverContextValue {\n inertContext ??= {\n open: false,\n setOpen: () => {},\n contentId: 'wave-popover-inert-content',\n setCustomContentId: () => {},\n triggerId: 'wave-popover-inert-trigger',\n resolvedTriggerId: undefined,\n setResolvedTriggerId: () => {},\n triggerRef: { current: null },\n triggerElement: null,\n triggerElementRef: () => {},\n surfaceElementRef: () => {},\n arrowRef: { current: null },\n onTriggerClick: () => {},\n onTriggerKeyDown: () => {},\n hoverTriggerHandlers: null,\n hoverSurfaceHandlers: null,\n contextMode: false,\n contextTriggerHandlers: null,\n onContentContextMenu: () => {},\n keyboardContext: false,\n onContentKeyDown: () => {},\n layerId: 'wave-popover-inert-layer',\n floatingProps: { 'data-side': 'bottom', 'data-align': 'start', style: {} },\n arrowStyles: {},\n placedSide: 'bottom',\n };\n return inertContext;\n}\n\nfunction usePopoverContext(componentName: string): PopoverContextValue {\n const context = React.useContext(PopoverContext);\n if (context) return context;\n reportMissingContext(componentName, 'Popover');\n return getInertContext();\n}\n\n/** The ids of an id list that exist in `doc`, joined; `undefined` when none does. */\nfunction presentIds(doc: Document, ids: string | null): string | undefined {\n const present = (ids ?? '').split(/\\s+/).filter((id) => id && doc.getElementById(id));\n return present.length > 0 ? present.join(' ') : undefined;\n}\n\n/**\n * The ids `Popover.Content`'s default `aria-labelledby` points at, so the popover gets its\n * trigger's name. The named element is the one with the resolved id when the document has it,\n * otherwise the trigger's focus target (for example the Button inside a Tooltip that sits between\n * `Popover.Trigger` and the Button, whose own id wins), else the trigger element. When that\n * element is itself named through `aria-labelledby` (an icon-only Button inside\n * `Tooltip relationship=\"label\"`, or a button labelled by a visible label), its label ids are\n * returned: a name computation does not follow a second `aria-labelledby` hop, so pointing at the\n * button would leave the popover unnamed. Otherwise the element's id, else the trigger's own.\n * `undefined` when none of them has an id (a render-prop child that does not spread `id`), so the\n * reference never dangles; only ids present in the document are returned. Before the trigger\n * element is known, the resolved id.\n */\nfunction findTriggerLabelId(\n trigger: HTMLElement | null,\n resolvedId: string | undefined,\n): string | undefined {\n if (!trigger) return resolvedId;\n const doc = trigger.ownerDocument;\n const named =\n (resolvedId ? doc.getElementById(resolvedId) : null) ??\n getTriggerFocusTarget(trigger) ??\n trigger;\n return (\n presentIds(doc, named.getAttribute('aria-labelledby')) ?? (named.id || trigger.id || undefined)\n );\n}\n\n/**\n * Whether one of the elements an id list references has text for a name: its own `aria-label`\n * or text, or a descendant's `aria-label`, `alt` or `title`. Deliberately lenient (it only drives\n * a development warning): content that assistive technology ignores still counts as text.\n */\nfunction referencesText(doc: Document, ids: string): boolean {\n return ids.split(/\\s+/).some((id) => {\n const el = id ? doc.getElementById(id) : null;\n if (!el) return false;\n if (el.getAttribute('aria-label')?.trim() || el.textContent?.trim()) return true;\n return !!el.querySelector(\n '[aria-label]:not([aria-label=\"\"]), [alt]:not([alt=\"\"]), [title]:not([title=\"\"])',\n );\n });\n}\n\nconst subscribeNothing = (): (() => void) => () => {};\n\n/** Why an open popover opened: hover (it closes by hover), or anything else (it is pinned). */\ntype OpenReason = 'hover' | 'other';\n\n/** Whether a `target` is an element rather than a VirtualElement (duck typed, any realm). */\nfunction isElementTarget(target: PopupTarget | undefined): target is HTMLElement {\n return !!target && typeof (target as Partial<Node>).nodeType === 'number';\n}\n\n/** A read-only ref whose `current` is `resolve()` at the time it is read (event time). */\nfunction createResolvedRef(resolve: () => HTMLElement | null): React.RefObject<HTMLElement | null> {\n return {\n get current() {\n return resolve();\n },\n };\n}\n\n/**\n * The content's previous stop: the focus target of the element it follows (the trigger, the row of\n * a context gesture, a `target` element), else the tab stop before that element.\n */\nfunction getPopoverPreviousStop(\n anchor: HTMLElement,\n surface: HTMLElement,\n order?: readonly HTMLElement[],\n): HTMLElement | null {\n return getTriggerFocusTarget(anchor) ?? getTabbableThrough(anchor, surface, order);\n}\n\n// A const arrow (like DialogRoot and DrawerRoot): its type can be named in consumers' declaration\n// files, e.g. a story's `satisfies Meta<typeof Popover>` (a function declaration's `typeof` cannot,\n// TS4023).\nconst PopoverRoot = ({\n open: openProp,\n defaultOpen,\n onOpenChange,\n side = 'bottom',\n align = 'start',\n ignoreOutsideRefs,\n openOnHover = false,\n openDelay = 250,\n closeDelay = 500,\n openOnContext = false,\n target,\n children,\n}: PopoverProps) => {\n const [openState, setOpen] = useControllable(openProp, defaultOpen ?? false, onOpenChange);\n // A hover close in flight (written in handlers, read when the popover closes): set when the hover\n // intent asks to close, so that close moves no focus even when a controlled parent applies it in\n // a later render (a transition). Every other request to open or close forgets it, and so does\n // the next opening.\n const hoverCloseRef = React.useRef(false);\n const requestOpen = useEventCallback<SetValue<boolean>>((next) => {\n hoverCloseRef.current = false;\n setOpen(next);\n });\n const isHoverClose = React.useCallback(() => hoverCloseRef.current, []);\n // The content lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the popover reports itself closed, so the trigger's aria-expanded and\n // aria-controls never describe content that is not there.\n const isClient = useIsClient();\n const open = openState && isClient;\n\n // Why the popover opened, decided when it opens (C-HOOKS: a previous-value state): `hover` when\n // hover asked for that open (a request consumed by the next render, so an open that a\n // controlled parent refused does not linger), else `other` (click, keys, a context gesture, a\n // controlled open).\n const [openReason, setOpenReason] = React.useState<OpenReason>('other');\n const [hoverRequested, setHoverRequested] = React.useState(false);\n const [previousOpen, setPreviousOpen] = React.useState(open);\n let reason = openReason;\n if (open !== previousOpen) {\n setPreviousOpen(open);\n if (open) reason = hoverRequested ? 'hover' : 'other';\n }\n if (reason !== openReason) setOpenReason(reason);\n if (hoverRequested) setHoverRequested(false);\n\n const generatedContentId = useId('popover-content');\n const [customContentId, setCustomContentId] = React.useState<string | undefined>(undefined);\n const contentId = customContentId ?? generatedContentId;\n const triggerId = useId('popover-trigger');\n const [resolvedTriggerId, setResolvedTriggerId] = React.useState<string | undefined>(undefined);\n const [surface, setSurface] = React.useState<HTMLElement | null>(null);\n const [triggerElement, setTriggerElement] = React.useState<HTMLElement | null>(null);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const surfaceRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLDivElement | null>(null);\n // A `target` element (not a VirtualElement) belongs to the dismiss layer, anchors the keyboard\n // order without a trigger and can take focus back.\n const targetElement = isElementTarget(target) ? target : null;\n const targetRef = React.useRef<HTMLElement | null>(null);\n React.useInsertionEffect(() => {\n targetRef.current = targetElement;\n }, [targetElement]);\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const {\n setReference,\n setFloating,\n floatingProps,\n arrowStyles,\n side: placedSide,\n } = usePopupPosition({ open, side, align, offset: 8, arrowRef });\n\n // The one focus resolver: the focus-return fallback and the layer's anchor (where a surface\n // opened from the content restores focus once its opener is gone). In context mode the element\n // focused at the gesture (the row) first; then the trigger's focus target (for a wrapper span,\n // the element inside it that carries the state ARIA), a focusable `target` element, and the\n // trigger itself. The context hook's opener ref is stable; it is filled in once the hook runs.\n const contextOpenerRef = React.useRef<React.RefObject<HTMLElement | null> | null>(null);\n const resolveFocusTarget = useEventCallback((): HTMLElement | null => {\n const gestureOpener = openOnContext ? contextOpenerRef.current?.current : null;\n if (gestureOpener && isConnectedAndFocusable(gestureOpener)) return gestureOpener;\n const trigger = triggerRef.current;\n const triggerTarget = trigger ? getTriggerFocusTarget(trigger) : null;\n if (triggerTarget) return triggerTarget;\n const targetEl = targetRef.current;\n if (targetEl && isConnectedAndFocusable(targetEl)) return targetEl;\n return trigger;\n });\n const focusTargetRef = React.useMemo(\n () => createResolvedRef(resolveFocusTarget),\n [resolveFocusTarget],\n );\n\n // In context mode the region is no part of the layer: a primary press elsewhere in it closes the\n // popover like any outside press. A Ctrl+press inside it is a macOS context click, whose\n // `contextmenu` moves the popover instead.\n const isOutsidePress = useEventCallback(\n (event: PointerEvent | MouseEvent) =>\n !(event.ctrlKey && triggerRef.current?.contains(event.target as Node)),\n );\n const { layerId } = useDismiss({\n open,\n onDismiss: () => requestOpen(false),\n refs: openOnContext\n ? [surfaceRef, targetRef, ...(ignoreOutsideRefs ?? [])]\n : [surfaceRef, triggerRef, targetRef, ...(ignoreOutsideRefs ?? [])],\n anchorRef: focusTargetRef,\n kind: 'popover',\n outsidePress: openOnContext ? isOutsidePress : true,\n });\n\n // A keyboard context gesture moves focus into the content, once it is there (see below).\n const focusContentRef = React.useRef(false);\n const {\n anchor: contextAnchor,\n fromContext,\n origin: contextOrigin,\n opener: contextOpener,\n triggerHandlers: contextTriggerHandlers,\n surfaceHandlers: contextSurfaceHandlers,\n } = useContextMenuAnchor({\n enabled: openOnContext,\n open,\n trigger: triggerElement,\n layerId,\n onOpen: (origin) => {\n focusContentRef.current = origin === 'keyboard';\n requestOpen(true);\n },\n onClose: () => requestOpen(false),\n });\n React.useInsertionEffect(() => {\n contextOpenerRef.current = contextOpener;\n }, [contextOpener]);\n\n // Focus returns to the element that takes focus for the trigger, as Shift+Tab from the content\n // does, when the popover closes while focus is inside it or on `<body>`; a hover close restores\n // only focus inside, so it never moves focus. In context mode it returns to the element focused\n // at the gesture (the row): the region is no restore target of its own (as `triggerRef` it\n // would be taken for the opener).\n const triggerFocusRef = useTriggerFocusRef(triggerRef);\n useRestoreFocus({\n enabled: open,\n container: surface,\n triggerRef: openOnContext ? undefined : triggerFocusRef,\n finalFocusRef: openOnContext ? contextOpener : undefined,\n fallback: resolveFocusTarget,\n onlyIfFocusInside: true,\n isHoverClose,\n });\n React.useLayoutEffect(() => {\n if (open) hoverCloseRef.current = false;\n }, [open]);\n\n const triggerElementRef = useMergedRefs<HTMLElement>(triggerRef, setTriggerElement);\n const surfaceElementRef = useMergedRefs<HTMLElement>(surfaceRef, setSurface, setFloating);\n\n // The positioning anchor: the context gesture (the pointer, or the focused row, else the\n // trigger's focus target, else the trigger) while the popover was opened by one, else `target`,\n // else the trigger. A new VirtualElement on every render repositions without a render loop.\n React.useLayoutEffect(() => {\n if (fromContext) {\n setReference(\n contextAnchor ??\n (triggerElement && (getTriggerFocusTarget(triggerElement) ?? triggerElement)),\n );\n } else {\n setReference(target ?? triggerElement);\n }\n }, [contextAnchor, fromContext, target, triggerElement, setReference]);\n\n // After the commit that has the surface (and after a gesture while open): focus its first\n // tabbable element, else the surface itself (it then has `tabIndex={-1}`). A gesture whose open\n // was refused leaves nothing pending. No deps: every commit, since a gesture always renders.\n React.useLayoutEffect(() => {\n if (!focusContentRef.current) return;\n if (!open) {\n focusContentRef.current = false;\n return;\n }\n if (!surface) return;\n focusContentRef.current = false;\n focusElement(getFirstTabbable(surface) ?? surface, { preventScroll: true });\n });\n\n React.useEffect(() => {\n if (!openOnHover || !openOnContext) return;\n warnOnce(\n 'Popover:hover-and-context',\n 'Popover: `openOnHover` is ignored with `openOnContext`: a context popover opens on a right click, Shift+F10 or the ContextMenu key, not on hover.',\n );\n }, [openOnHover, openOnContext]);\n\n // Hover opening: a popover that hover opened closes by hover until a click on the trigger pins\n // it; focus inside the content (or a layer opened from it) keeps it open, focus on the trigger\n // does not.\n const hoverEnabled = openOnHover && !openOnContext;\n const canHoverClose = useEventCallback(\n () => reason === 'hover' && !isFocusInSurfaceTree(surfaceRef.current, layerId),\n );\n const {\n triggerHandlers: hoverTriggerHandlers,\n surfaceHandlers: hoverSurfaceHandlers,\n cancel: cancelHover,\n } = useHoverIntent({\n enabled: hoverEnabled,\n open,\n openDelay,\n closeDelay,\n trigger: triggerElement,\n surface,\n onOpen: () => {\n setHoverRequested(true);\n requestOpen(true);\n },\n onClose: () => {\n // Before the request: a parent may apply it synchronously (flushSync).\n hoverCloseRef.current = true;\n setOpen(false);\n },\n canClose: canHoverClose,\n });\n\n const onTriggerClick = useEventCallback(() => {\n cancelHover();\n if (open && reason === 'hover') setOpenReason('other');\n else requestOpen((current) => !current);\n });\n\n // The element the content follows in the keyboard order: in context mode the element focused\n // at the gesture when it lies inside the region, else the trigger, else a `target` element.\n // With neither (a VirtualElement target and no trigger) the content keeps the portal's place.\n const resolveTabAnchor = useEventCallback((): HTMLElement | null => {\n const trigger = triggerRef.current;\n const gestureOpener = openOnContext ? contextOpener.current : null;\n if (gestureOpener && trigger?.contains(gestureOpener)) return gestureOpener;\n return trigger ?? targetRef.current;\n });\n const tabAnchorRef = React.useMemo(() => createResolvedRef(resolveTabAnchor), [resolveTabAnchor]);\n\n // Keyboard order of the portaled content (it lives at the end of the document), as if it\n // followed the trigger like 0.4's inline content: Tab from the open trigger enters it (here, in\n // the trigger's own `onKeyDown`, which runs before a dialog's focus trap), Tab past its last\n // element continues after the trigger, Shift+Tab from its first element returns to the trigger\n // (the element inside a wrapper span), and Shift+Tab from the element after the trigger enters\n // it at its last element. The end of the page does not visit it a second time where its portal\n // is, and no Tab cycle forms (see usePopoverTabOrder). In a context region only Tab from the\n // element the content follows enters it; Tab on the region's other rows moves on as usual.\n const onTriggerKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key !== 'Tab' || event.shiftKey || !open) return;\n if (openOnContext) {\n const anchor = resolveTabAnchor();\n if (!anchor || event.target !== (getTriggerFocusTarget(anchor) ?? anchor)) return;\n }\n const surfaceElement = surfaceRef.current;\n const first = surfaceElement ? getFirstTabbable(surfaceElement) : null;\n if (!first) return;\n event.preventDefault();\n first.focus();\n });\n\n const onContentKeyDown = usePopoverTabOrder({\n enabled: open,\n surface,\n anchorRef: tabAnchorRef,\n // Shift+Tab from the content's first element returns to the trigger (the element in a span),\n // or, when nothing in the trigger can take focus, to the tab stop before it.\n getPreviousStop: getPopoverPreviousStop,\n });\n\n const keyboardContext = fromContext && contextOrigin === 'keyboard';\n const context = React.useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen: requestOpen,\n contentId,\n setCustomContentId,\n triggerId,\n resolvedTriggerId,\n setResolvedTriggerId,\n triggerRef,\n triggerElement,\n triggerElementRef,\n surfaceElementRef,\n arrowRef,\n onTriggerClick,\n onTriggerKeyDown,\n hoverTriggerHandlers: hoverEnabled ? hoverTriggerHandlers : null,\n hoverSurfaceHandlers: hoverEnabled ? hoverSurfaceHandlers : null,\n contextMode: openOnContext,\n contextTriggerHandlers: openOnContext ? contextTriggerHandlers : null,\n onContentContextMenu: contextSurfaceHandlers.onContextMenu,\n keyboardContext,\n onContentKeyDown,\n layerId,\n floatingProps,\n arrowStyles,\n placedSide,\n }),\n [\n open,\n requestOpen,\n contentId,\n triggerId,\n resolvedTriggerId,\n triggerElement,\n triggerElementRef,\n surfaceElementRef,\n onTriggerClick,\n onTriggerKeyDown,\n hoverEnabled,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n openOnContext,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n keyboardContext,\n onContentKeyDown,\n layerId,\n floatingProps,\n arrowStyles,\n placedSide,\n ],\n );\n\n return <PopoverContext.Provider value={context}>{children}</PopoverContext.Provider>;\n};\n\nPopoverRoot.displayName = 'Popover';\n\n/**\n * The element that toggles the popover. Its props are merged onto the single child (no wrapper\n * element): `aria-haspopup=\"dialog\"`, `aria-expanded`, `aria-controls` (while open), an `id` that\n * labels the content, a composed `onClick` and the ref used as positioning anchor and focus-return\n * target. The child's own `id`, handlers and classes are kept; the live state ARIA always wins.\n * A render function receives the props instead (spread all of them, `id` included: the content is\n * named by it); `asChild={false}` renders the 0.4 wrapper span, and a custom child that neither\n * forwards `ref` nor spreads its props falls back to that span automatically (with a development\n * warning). On the span, the state ARIA goes to the first element in the tab order inside it, and\n * focus returns to that element (to the span when you made it the trigger with a `role` such as\n * `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n *\n * With `openOnHover` a mouse pointer resting on it opens the popover, and a click pins a\n * hover-opened popover instead of closing it. With `openOnContext` it is a context-menu region (a\n * list, a row, a canvas) instead of a button: it receives its `id` and the context-menu and key\n * handlers, but no state ARIA and no click toggle (a render function still receives every prop:\n * do not spread the state ARIA then).\n *\n * A Tooltip goes between the trigger and the button: it passes the trigger's `id` and ARIA on to\n * the button, which the Tooltip also describes.\n *\n * @example\n * <Popover.Trigger>\n * <Tooltip content=\"Narrow the list\">\n * <Button>Filters</Button>\n * </Tooltip>\n * </Popover.Trigger>\n *\n * Also exported as `PopoverTrigger` for React Server Components, which cannot use the dotted\n * `Popover.Trigger` (that needs a client file).\n */\nexport const PopoverTrigger = ({\n children,\n asChild,\n id: idProp,\n onClick,\n onKeyDown,\n onContextMenu,\n onPointerEnter,\n onPointerMove,\n onPointerLeave,\n ref,\n ...rest\n}: PopoverTriggerProps) => {\n const {\n open,\n contentId,\n triggerId,\n triggerElementRef,\n setResolvedTriggerId,\n onTriggerClick,\n onTriggerKeyDown,\n hoverTriggerHandlers: hover,\n contextMode,\n contextTriggerHandlers: gesture,\n } = usePopoverContext('Popover.Trigger');\n const elementRef = useMergedRefs<HTMLElement>(ref, triggerElementRef);\n\n // On a wrapper span (`asChild={false}`, the automatic fallback) useTriggerElement moves the\n // state ARIA onto the first element in the tab order inside it. The hover handlers are there\n // only with `openOnHover`, the context handlers only with `openOnContext`. A context region is\n // no popover button: it gets no state ARIA and no click toggle (useTriggerElement\n // `omitStateAria`), and a render-prop child reads a constant closed state.\n const triggerProps = {\n ...rest,\n id: idProp ?? triggerId,\n 'aria-haspopup': 'dialog' as const,\n 'aria-expanded': contextMode ? false : open,\n 'aria-controls': open && !contextMode ? contentId : undefined,\n onClick: composeEventHandlers(onClick, contextMode ? undefined : onTriggerClick),\n onKeyDown: composeEventHandlers(\n onKeyDown,\n gesture ? composeEventHandlers(gesture.onKeyDown, onTriggerKeyDown) : onTriggerKeyDown,\n ),\n onContextMenu: gesture\n ? composeEventHandlers(onContextMenu, gesture.onContextMenu)\n : onContextMenu,\n onPointerEnter: hover\n ? composeEventHandlers(onPointerEnter, hover.onPointerEnter)\n : onPointerEnter,\n onPointerMove: hover ? composeEventHandlers(onPointerMove, hover.onPointerMove) : onPointerMove,\n onPointerLeave: hover\n ? composeEventHandlers(onPointerLeave, hover.onPointerLeave)\n : onPointerLeave,\n ref: elementRef,\n } as PopoverTriggerChildProps;\n\n return useTriggerElement(children, triggerProps, {\n componentName: 'Popover.Trigger',\n asChild,\n onResolvedId: setResolvedTriggerId,\n omitStateAria: contextMode,\n });\n};\nPopoverTrigger.displayName = 'PopoverTrigger';\n\n/**\n * The popover surface: a non-modal `role=\"dialog\"` rendered in a portal (so overflow containers\n * never clip it) and positioned next to the trigger with a beak, flipping and shifting to stay in\n * the viewport. It closes on Escape and on a press outside (presses inside nested overlays opened\n * from it count as inside), and focus returns to the trigger when it closes while focus was inside.\n * In the keyboard order it follows the trigger, like inline content: Tab from the open trigger\n * enters it, Tab past its last element continues after the trigger, and Shift+Tab from the element\n * after the trigger enters it at its last element. Tab from the last element of the page moves\n * past it, and Shift+Tab from outside the page reaches the page's last element first, so a lap\n * visits it once. For a trigger outside the tab order (nothing in it can take focus, or\n * `tabIndex={-1}`), Tab from the tab stop before the trigger enters it, and Shift+Tab from its\n * first element returns to the trigger, or to that tab stop when nothing in the trigger can take\n * focus. With no tab stop before the trigger, the content is reached at the end of the page.\n * Named by `title`, `aria-label`/`aria-labelledby`, or else by its trigger: `aria-labelledby`\n * points at the id the trigger element carries in the document, or at the trigger's own label\n * elements when the trigger is named through `aria-labelledby` (an icon-only Button inside\n * `Tooltip relationship=\"label\"`); never at a missing id. A development warning names the problem\n * when the trigger has no id or no text. With `openOnContext` it is never named by the trigger (a\n * region's text is no name): pass `title`, `aria-label` or `aria-labelledby` (a development\n * warning otherwise). A consumer `id` is kept, and the trigger's `aria-controls` follows it. The\n * beak inherits the surface's background and border colors, so a `className` that changes them\n * restyles the beak too.\n *\n * With `openOnContext` it opens at the pointer of a right click, or at the focused row for\n * Shift+F10 and the ContextMenu key, and it follows that row in the keyboard order; with a\n * `target` it is placed at the target and, without a trigger, follows a target element in the\n * keyboard order.\n *\n * Also exported as `PopoverContent` for React Server Components, which cannot use the dotted\n * `Popover.Content` (that needs a client file).\n */\nexport const PopoverContent = ({\n children,\n title,\n id: idProp,\n className,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n onKeyDown,\n onContextMenu,\n onPointerEnter,\n onPointerLeave,\n ref,\n ...rest\n}: PopoverContentProps) => {\n const {\n open,\n contentId,\n setCustomContentId,\n resolvedTriggerId,\n triggerRef,\n triggerElement,\n surfaceElementRef,\n arrowRef,\n layerId,\n floatingProps,\n arrowStyles,\n placedSide,\n onContentKeyDown,\n hoverSurfaceHandlers: hover,\n contextMode,\n onContentContextMenu,\n keyboardContext,\n } = usePopoverContext('Popover.Content');\n const titleId = useId('popover-title');\n const elementRef = useMergedRefs<HTMLDivElement>(ref, surfaceElementRef);\n const hasTitle = slotRendersContent(title);\n const unnamed = ariaLabelledBy === undefined && !ariaLabel && !hasTitle;\n // A context region is no popover button, and its whole text is no name: in context mode the\n // content is never labelled by the trigger.\n const checkTrigger = open && unnamed && !contextMode;\n\n // The trigger's label ids in the document, re-read when the trigger's ids or labels change: a\n // Tooltip between Popover.Trigger and the Button leaves the Button's own id in place (and with\n // `relationship=\"label\"` names it through `aria-labelledby`), and a render-prop child may not\n // spread `id` at all — never point aria-labelledby at an id that is not there.\n const subscribeTrigger = React.useCallback(\n (onChange: () => void) => {\n if (!checkTrigger || !triggerElement || typeof MutationObserver === 'undefined') {\n return subscribeNothing();\n }\n const observer = new MutationObserver(onChange);\n observer.observe(triggerElement, {\n attributes: true,\n attributeFilter: ['id', 'aria-labelledby'],\n childList: true,\n subtree: true,\n });\n return () => observer.disconnect();\n },\n [checkTrigger, triggerElement],\n );\n const triggerLabelId = React.useSyncExternalStore(\n subscribeTrigger,\n () => (checkTrigger ? findTriggerLabelId(triggerElement, resolvedTriggerId) : undefined),\n () => (checkTrigger ? resolvedTriggerId : undefined),\n );\n\n const labelledBy =\n ariaLabelledBy ?? (ariaLabel ? undefined : hasTitle ? titleId : triggerLabelId);\n const customId = idProp || undefined;\n\n // Report the consumer's id to the root so the trigger's `aria-controls` points at it.\n React.useEffect(() => {\n setCustomContentId(customId);\n return () => setCustomContentId(undefined);\n }, [customId, setCustomContentId]);\n\n React.useEffect(() => {\n if (!open || !unnamed || !contextMode || !isDev) return;\n warnOnce(\n 'Popover.Content:name',\n 'Popover.Content: the popover has no accessible name. A context popover (openOnContext) is not named by its region: pass `title`, `aria-label` or `aria-labelledby`.',\n );\n }, [open, unnamed, contextMode]);\n\n React.useEffect(() => {\n if (!checkTrigger || !isDev) return;\n // Read after commit: a trigger's ref is attached by now even before it reported its id.\n const trigger = triggerRef.current;\n if (!trigger) {\n warnOnce(\n 'Popover.Content:name',\n 'Popover.Content: the popover has no accessible name. Pass `title`, `aria-label` or `aria-labelledby`, or open it from a Popover.Trigger.',\n );\n return;\n }\n const labelIds = findTriggerLabelId(trigger, resolvedTriggerId);\n if (!labelIds) {\n warnOnce(\n 'Popover.Content:trigger-id',\n 'Popover.Content: the popover is named by its trigger, but the trigger element has no `id` (a render-prop child of Popover.Trigger must spread the `id` it receives), so the popover has no accessible name. Spread every trigger prop onto the element, or pass `title`, `aria-label` or `aria-labelledby`.',\n );\n } else if (!referencesText(trigger.ownerDocument, labelIds)) {\n warnOnce(\n 'Popover.Content:trigger-name',\n 'Popover.Content: the popover is named by its trigger, but the trigger has no text to name it (an icon-only trigger needs `aria-label`, or `aria-labelledby` pointing at text), so the popover has no accessible name. Name the trigger, or pass `title`, `aria-label` or `aria-labelledby`.',\n );\n }\n }, [checkTrigger, resolvedTriggerId, triggerRef, triggerLabelId]);\n\n if (!open) return null;\n\n return (\n <Portal layerId={layerId}>\n <div\n role=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n tabIndex={keyboardContext ? -1 : undefined}\n {...rest}\n ref={elementRef}\n id={customId ?? contentId}\n data-side={floatingProps['data-side']}\n data-align={floatingProps['data-align']}\n style={{ ...style, ...floatingProps.style }}\n onKeyDown={composeEventHandlers(onKeyDown, onContentKeyDown)}\n onContextMenu={composeEventHandlers(onContextMenu, onContentContextMenu)}\n onPointerEnter={\n hover ? composeEventHandlers(onPointerEnter, hover.onPointerEnter) : onPointerEnter\n }\n onPointerLeave={\n hover ? composeEventHandlers(onPointerLeave, hover.onPointerLeave) : onPointerLeave\n }\n className={cn(\n popoverContentClassNames.root,\n 'w-64 rounded-md border border-border bg-background p-4 text-body-1 font-normal text-foreground normal-case tracking-normal text-start shadow-4',\n className,\n )}\n >\n <PopoverBeak\n ref={arrowRef}\n side={placedSide}\n style={arrowStyles}\n data-wave-popover-arrow=\"\"\n className={popoverContentClassNames.beak}\n />\n {hasTitle && (\n <h2\n id={titleId}\n className={cn(popoverContentClassNames.title, 'mb-2 text-subtitle-2 font-semibold')}\n >\n {title}\n </h2>\n )}\n {children}\n </div>\n </Portal>\n );\n};\nPopoverContent.displayName = 'PopoverContent';\n\n/**\n * A non-modal popup anchored to a trigger: `Popover.Trigger` (merges its props onto the child\n * button) and `Popover.Content` (portaled, positioned `role=\"dialog\"` surface). Use it for custom\n * popups such as filters or details; for a menu button use `Menu.Trigger` and `Menu.Popover`,\n * which add menu semantics and keyboard support.\n *\n * Controlled (`open`/`onOpenChange`) or uncontrolled (`defaultOpen`); `side`/`align` place the\n * content, and `ignoreOutsideRefs` lists external elements (such as a toggle button) whose presses\n * do not dismiss it.\n *\n * - **Hover cards:** `openOnHover` opens it when a mouse pointer rests on the trigger\n * (`openDelay`) and closes it once the pointer has left the trigger and the content\n * (`closeDelay`), unless focus is inside; a click on the trigger pins it.\n * - **Context popovers:** `openOnContext` makes the trigger a context-menu region: a right click\n * opens it at the pointer, Shift+F10 or the ContextMenu key at the focused row (with focus\n * moving into the content). Name the content with `title` or `aria-label`.\n * - **Custom anchors:** `target` places it at another element or at a `VirtualElement` (a point, a\n * text selection); with a controlled `open` it needs no trigger.\n *\n * @example\n * <Popover>\n * <Popover.Trigger><Button>Details</Button></Popover.Trigger>\n * <Popover.Content title=\"Details\">…</Popover.Content>\n * </Popover>\n */\nexport const Popover = /* @__PURE__ */ Object.assign(PopoverRoot, {\n Trigger: PopoverTrigger,\n Content: Pop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EAAmBK,EAAY2E,CAAc,CAAC,EAE3D7F,GAGH,EAAArC,EAAA,IAAA,CAACzB,EAAAA,OAAD,CAAiB,UACf,UAAA,EAAAyB,EAAA,KAAA,CAAC,MAAD,CACE,KAAK,SACL,aAAYwH,EACZ,kBAAiBW,GACjB,SAAUhC,GAAkB,GAAK,IAAA,GACjC,GAAIM,EACJ,IAAKG,GACL,GAAIwB,GAAYpF,EAChB,YAAWqD,EAAc,aACzB,aAAYA,EAAc,cAC1B,MAAO,CAAE,GAAGiC,EAAO,GAAGjC,EAAc,KAAM,EAC1C,UAAWlI,EAAAA,qBAAqB8I,GAAWf,CAAgB,EAC3D,cAAe/H,EAAAA,qBAAqB+I,GAAeqB,EAAoB,EACvE,eACE7B,EAAQvI,EAAAA,qBAAqBgJ,EAAgBT,EAAM,cAAc,EAAIS,EAEvE,eACET,EAAQvI,EAAAA,qBAAqBkJ,EAAgBX,EAAM,cAAc,EAAIW,EAEvE,UAAW7I,EAAAA,GACTC,EAAAA,yBAAyB,KACzB,iJACA+J,CACF,EAvBF,SAAA,EAyBE,EAAAxI,EAAA,IAAA,CAACtB,EAAAA,YAAD,CACE,IAAK+E,EACL,KAAMG,EACN,MAAO0C,EACP,0BAAwB,GACxB,UAAW7H,EAAAA,yBAAyB,IACrC,CAAA,EACAkJ,IACC,EAAA3H,EAAA,IAAA,CAAC,KAAD,CACE,GAAI0H,EACJ,UAAWlJ,EAAAA,GAAGC,EAAAA,yBAAyB,MAAO,oCAAoC,EAEjF,SAAAmJ,CACC,CAAA,EAELN,CACE,GACC,CAAA,EA9CQ,IAgDpB,EACA,EAAe,YAAc,iBA2B7B,IAAamB,EAA0B,OAAO,OAAO/G,EAAa,CAChE,QAAS6E,EACT,QAASgB,CACX,CAAC"}
1
+ {"version":3,"file":"Popover.cjs","names":["React","getTriggerFocusTarget","getTabbableThrough","usePopupTarget","useControllable","useEventCallback","useIsClient","useId","usePopupPosition","resolvePositioning","isConnectedAndFocusable","useDismiss","useContextMenuAnchor","useTriggerFocusRef","useMergedRefs","getFirstTabbable","isFocusInSurfaceTree","useHoverIntent","usePopoverTabOrder","composeEventHandlers","useTriggerElement","slotRendersContent","isDev","_Fragment","cn","popoverContentClassNames","Portal","PopoverBeak","require_runtime","require_cn","require_dev","require_slot","require_composeEventHandlers","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_focus","require_useMergedRefs","require_useIsClient","require_usePopupPosition","require_useDismiss","require_useRestoreFocus","require_Portal","require_useHoverIntent","require_Popover_shared","require_useTriggerElement","require_useResolvedTarget","require_useContextMenuAnchor","react","react_jsx_runtime","PopoverContext","inertContext","getInertContext","usePopoverContext","componentName","presentIds","present","ids","id","doc","findTriggerLabelId","trigger","resolvedId","named","referencesText","el","subscribeNothing","isElementTarget","target","createResolvedRef","resolve","getPopoverPreviousStop","anchor","surface","order","PopoverRoot","openProp","targetProp","targetPending","positioning","openState","setOpen","defaultOpen","onOpenChange","hoverCloseRef","requestOpen","next","isHoverClose","isClient","open","openReason","setOpenReason","hoverRequested","setHoverRequested","previousOpen","setPreviousOpen","reason","generatedContentId","customContentId","setCustomContentId","contentId","triggerId","resolvedTriggerId","setResolvedTriggerId","setSurface","triggerElement","setTriggerElement","triggerRef","surfaceRef","arrowRef","targetElement","targetRef","positionedProps","placedSide","floatingProps","contextOpenerRef","resolveFocusTarget","gestureOpener","openOnContext","triggerTarget","targetEl","focusTargetRef","isOutsidePress","event","ignoreOutsideRefs","focusContentRef","contextAnchor","contextOrigin","contextOpener","contextTriggerHandlers","contextSurfaceHandlers","origin","triggerFocusRef","triggerElementRef","surfaceElementRef","setFloating","setReference","fromContext","openOnHover","hoverEnabled","canHoverClose","layerId","hoverTriggerHandlers","hoverSurfaceHandlers","cancelHover","onTriggerClick","current","resolveTabAnchor","tabAnchorRef","onTriggerKeyDown","surfaceElement","first","onContentKeyDown","keyboardContext","context","arrowStyles","PopoverTrigger","idProp","rest","hover","gesture","elementRef","ref","triggerProps","contextMode","onClick","onKeyDown","onContextMenu","onPointerEnter","onPointerMove","onPointerLeave","children","PopoverContent","ariaLabel","ariaLabelledBy","titleId","hasTitle","title","unnamed","checkTrigger","subscribeTrigger","observer","onChange","triggerLabelId","labelledBy","customId","labelIds","titleAndChildren","style","onContentContextMenu","className","fitViewport","Popover"],"sources":["../../../src/components/overlays/Popover.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { popoverContentClassNames } from '../../lib/classNames';\nimport { isDev, reportMissingContext, warnOnce } from '../../lib/dev';\nimport { slotRendersContent } from '../../lib/slot';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { focusElement, getFirstTabbable, isConnectedAndFocusable } from '../../lib/focus';\nimport type {\n PopupAlign,\n PopupPositioning,\n PopupSide,\n PopupTarget,\n PopupTargetInput,\n} from '../../lib/types';\nimport { usePopupTarget } from '../../hooks/useResolvedTarget';\nimport { useId } from '../../hooks/useId';\nimport { useControllable, type SetValue } from '../../hooks/useControllable';\nimport { useContextMenuAnchor, type ContextMenuAnchor } from '../../hooks/useContextMenuAnchor';\nimport { useDismiss } from '../../hooks/useDismiss';\nimport { useHoverIntent, type HoverIntent } from '../../hooks/useHoverIntent';\nimport { useRestoreFocus } from '../../hooks/useRestoreFocus';\nimport { resolvePositioning, usePopupPosition } from '../../hooks/usePopupPosition';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport {\n getTriggerFocusTarget,\n useTriggerElement,\n useTriggerFocusRef,\n} from '../../hooks/useTriggerElement';\nimport { Portal } from '../portal/Portal';\nimport {\n getTabbableThrough,\n isFocusInSurfaceTree,\n PopoverBeak,\n usePopoverTabOrder,\n type PopoverPhysicalSide,\n} from './Popover.shared';\n\n/** Properties for the Popover component. */\nexport interface PopoverProps {\n /**\n * Controlled open state of the popover. The content renders only in the browser: an open\n * popover is closed in the server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Default open state for uncontrolled usage. The content renders only in the browser: a\n * popover open by default is closed in the server HTML and opens once it has hydrated.\n * @default false\n */\n defaultOpen?: boolean;\n /**\n * Called with the requested open state when it differs from the current one: a trigger click,\n * Escape and an outside press; the hover opening and closing of `openOnHover`; and, with\n * `openOnContext`, a context gesture (a right click, a macOS Ctrl+click, Shift+F10 or the\n * ContextMenu key), a right click outside, and a scroll that moves the row it opened at.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Side of the trigger the content opens on. `start`/`end` follow the writing direction. The\n * content flips to the opposite side when there is not enough room.\n * @default 'bottom'\n */\n side?: PopupSide;\n /** Alignment of the content along the trigger's edge.\n * @default 'start'\n */\n align?: PopupAlign;\n /**\n * Elements outside the popover whose presses must not dismiss it, e.g. an external toggle\n * button that opens and closes the popover itself.\n */\n ignoreOutsideRefs?: ReadonlyArray<React.RefObject<HTMLElement | null>>;\n /**\n * Open the popover when a mouse pointer rests on its trigger (a hover card), and close it once\n * the pointer has been off the trigger and the content for `closeDelay` while focus is not\n * inside the content. A popover opened by hover does not take focus, and its hover close leaves\n * focus where it is; a click on its trigger keeps it open and keeps focus where it is (a second\n * click closes it, as without hover). After Escape or an outside press it does not reopen until\n * the pointer has left the trigger. Touch and pen never open it by hover, and an `aria-disabled`\n * trigger never opens. A triangle between the trigger and the content keeps it open while the\n * pointer moves diagonally into it. Ignored with `openOnContext` (development warning).\n * @default false\n */\n openOnHover?: boolean;\n /**\n * Milliseconds a hovering mouse pointer rests on the trigger before the popover opens (mouse\n * hover only).\n * @default 250\n */\n openDelay?: number;\n /**\n * Milliseconds before a hover-opened popover closes once the mouse pointer has left it and its\n * trigger (Fluent's `mouseLeaveDelay`; mouse hover only).\n * @default 500\n */\n closeDelay?: number;\n /**\n * Make `Popover.Trigger` a context-menu region (a list, a row, a canvas): a right click (a\n * Ctrl+click on macOS, a long press where the browser reports one) opens the popover at the\n * pointer and leaves focus where it is (Tab from that element enters the content), and\n * Shift+F10 or the ContextMenu key opens it at the focused element inside the region and moves\n * focus into the content, instead of a click. Focus returns to the element that had it. The\n * browser's context menu is suppressed there and inside the content, except in text fields\n * inside the region, which keep it. A press elsewhere, a right click outside or a scroll that\n * moves the row it opened at (the one under the pointer, or the focused one), as a scroll of\n * the region's own content does, closes it. The trigger gets no `aria-haspopup`/`aria-expanded`\n * (it is not a popover button; with a render-prop child, do not spread them): name the content\n * with `title`, `aria-label` or `aria-labelledby`, and consider `aria-keyshortcuts=\"Shift+F10\"`\n * on the region. iOS Safari reports no long press. `openOnHover` is ignored with it.\n * @default false\n */\n openOnContext?: boolean;\n /**\n * Where to place the content instead of next to `Popover.Trigger`: an element or a\n * `VirtualElement` (a rectangle, such as a point; an inline object is fine). With a controlled\n * `open`, a popover with a `target` needs no trigger; name it with `title`, `aria-label` or\n * `aria-labelledby`, and give a toggle button you use as the target `aria-haspopup=\"dialog\"`,\n * `aria-expanded` and `aria-controls` yourself. A press on a target element does not close the\n * popover, and Tab from it enters the content when there is no trigger. Hold the element in\n * state, or pass a ref object (read after each render of the popover, so an element that attaches without it rendering is noticed on its next render). A popover\n * opened by `openOnContext` is placed at the gesture instead.\n */\n target?: PopupTargetInput;\n /**\n * Advanced positioning (Fluent's `positioning`): `offset` (px from the anchor), `fitViewport`\n * (limit the content to the space the viewport leaves; Fluent's `autoSize`), `matchReferenceWidth`,\n * `fallbackPlacements` (tried in order when the requested side has no room) and `target` (used\n * when the `target` prop is not set). `side` and `align` stay separate props.\n * @default `{ offset: 8 }`\n */\n positioning?: PopupPositioning;\n /** `Popover.Trigger` and `Popover.Content`. */\n children: React.ReactNode;\n}\n\n/**\n * Props the trigger puts on its element; a render-prop child of `Popover.Trigger` receives them\n * (spread them onto the element that opens the popover). With `openOnContext` the element is a\n * context-menu region, not a popover button: do not spread `aria-haspopup`, `aria-expanded` and\n * `aria-controls` onto it (`aria-expanded` is then always `false`, `aria-controls` is absent and\n * `onClick` does nothing); spread ones are removed after each commit, with a development warning.\n */\nexport type PopoverTriggerChildProps = Omit<React.HTMLAttributes<HTMLElement>, 'children'> & {\n id: string;\n 'aria-haspopup': 'dialog';\n 'aria-expanded': boolean;\n /** The content's id, only while the popover is open (never with `openOnContext`). */\n 'aria-controls': string | undefined;\n onClick: React.MouseEventHandler<HTMLElement>;\n /**\n * Moves Tab from the open trigger into the portaled content (which lives at the end of the\n * document), so the keyboard order follows the trigger.\n */\n onKeyDown: React.KeyboardEventHandler<HTMLElement>;\n ref: React.RefCallback<HTMLElement>;\n};\n\n/** Properties for the PopoverTrigger sub-component. */\nexport interface PopoverTriggerProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {\n /**\n * The element that toggles the popover (its props are merged onto it), or a render function\n * that receives the trigger props.\n */\n children: React.ReactNode | ((props: PopoverTriggerChildProps) => React.ReactNode);\n /**\n * `false` renders the 0.4 wrapper `<span>` carrying the trigger props around the children\n * instead of merging them onto the child. `aria-haspopup`, `aria-expanded` and `aria-controls`,\n * which a generic element cannot carry, go to the first element in the tab order inside the\n * span. A render-prop child ignores `asChild` and receives every prop.\n * @default true\n */\n asChild?: boolean;\n /** Ref to the trigger element (the child, or the wrapper span). */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Properties for the PopoverContent sub-component. */\nexport interface PopoverContentProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {\n /** Content to render inside the popover. */\n children: React.ReactNode;\n /**\n * Visible heading rendered at the top of the popover; it names the dialog. Without `title`,\n * `aria-label` or `aria-labelledby`, the popover is labelled by its trigger, except with\n * `openOnContext` (a region's text is no name), where it needs one of them.\n */\n title?: React.ReactNode;\n /** Id of the surface; the trigger's `aria-controls` follows it. Defaults to a generated id. */\n id?: string;\n /** Ref to the popover surface. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: SetValue<boolean>;\n /** The content's id: the consumer's `Popover.Content` id when given, else a generated one. */\n contentId: string;\n /** `Popover.Content` reports the consumer's `id` so the trigger's `aria-controls` follows it. */\n setCustomContentId: (id: string | undefined) => void;\n triggerId: string;\n /** The id the trigger element ended up with (the child's own id wins). */\n resolvedTriggerId: string | undefined;\n setResolvedTriggerId: (id: string) => void;\n triggerRef: React.RefObject<HTMLElement | null>;\n /** The trigger element as state (read during render, e.g. to check the labelling id). */\n triggerElement: HTMLElement | null;\n /** Ref callback for the trigger element: focus-restore target and positioning anchor. */\n triggerElementRef: React.RefCallback<HTMLElement>;\n /** Ref callback for the surface: dismissal, focus restore and positioning. */\n surfaceElementRef: React.RefCallback<HTMLElement>;\n arrowRef: React.RefObject<HTMLDivElement | null>;\n /** The trigger's click: toggles the popover, or pins one that hover opened (keeps it open). */\n onTriggerClick: () => void;\n /** Tab from the open trigger enters the portaled content. */\n onTriggerKeyDown: React.KeyboardEventHandler<HTMLElement>;\n /** Hover opening (`openOnHover`): composed onto the trigger; `null` without it. */\n hoverTriggerHandlers: HoverIntent['triggerHandlers'] | null;\n /** Hover opening (`openOnHover`): composed onto the content; `null` without it. */\n hoverSurfaceHandlers: HoverIntent['surfaceHandlers'] | null;\n /** `openOnContext`: the trigger is a context-menu region, not a popover button. */\n contextMode: boolean;\n /** Context gestures (`openOnContext`): composed onto the trigger; `null` without it. */\n contextTriggerHandlers: ContextMenuAnchor['triggerHandlers'] | null;\n /** Composed onto the content: suppresses the browser's context menu there in context mode. */\n onContentContextMenu: React.MouseEventHandler<HTMLElement>;\n /** Opened by a keyboard context gesture: the content takes focus (itself when nothing can). */\n keyboardContext: boolean;\n /** Tab past the content's edges continues around the trigger in the page order. */\n onContentKeyDown: React.KeyboardEventHandler<HTMLElement>;\n layerId: string;\n floatingProps: { 'data-side': string; 'data-align': string; style: React.CSSProperties };\n arrowStyles: React.CSSProperties;\n placedSide: PopoverPhysicalSide;\n /** `positioning.fitViewport`: the content scrolls inside the border when it is limited. */\n fitViewport: boolean;\n}\n\nconst PopoverContext = React.createContext<PopoverContextValue | null>(null);\nPopoverContext.displayName = 'PopoverContext';\n\nlet inertContext: PopoverContextValue | null = null;\n\n/** Production fallback for a misplaced sub-component: a closed popover that does nothing. */\nfunction getInertContext(): PopoverContextValue {\n inertContext ??= {\n open: false,\n setOpen: () => {},\n contentId: 'wave-popover-inert-content',\n setCustomContentId: () => {},\n triggerId: 'wave-popover-inert-trigger',\n resolvedTriggerId: undefined,\n setResolvedTriggerId: () => {},\n triggerRef: { current: null },\n triggerElement: null,\n triggerElementRef: () => {},\n surfaceElementRef: () => {},\n arrowRef: { current: null },\n onTriggerClick: () => {},\n onTriggerKeyDown: () => {},\n hoverTriggerHandlers: null,\n hoverSurfaceHandlers: null,\n contextMode: false,\n contextTriggerHandlers: null,\n onContentContextMenu: () => {},\n keyboardContext: false,\n onContentKeyDown: () => {},\n layerId: 'wave-popover-inert-layer',\n floatingProps: { 'data-side': 'bottom', 'data-align': 'start', style: {} },\n arrowStyles: {},\n placedSide: 'bottom',\n fitViewport: false,\n };\n return inertContext;\n}\n\nfunction usePopoverContext(componentName: string): PopoverContextValue {\n const context = React.useContext(PopoverContext);\n if (context) return context;\n reportMissingContext(componentName, 'Popover');\n return getInertContext();\n}\n\n/** The ids of an id list that exist in `doc`, joined; `undefined` when none does. */\nfunction presentIds(doc: Document, ids: string | null): string | undefined {\n const present = (ids ?? '').split(/\\s+/).filter((id) => id && doc.getElementById(id));\n return present.length > 0 ? present.join(' ') : undefined;\n}\n\n/**\n * The ids `Popover.Content`'s default `aria-labelledby` points at, so the popover gets its\n * trigger's name. The named element is the one with the resolved id when the document has it,\n * otherwise the trigger's focus target (for example the Button inside a Tooltip that sits between\n * `Popover.Trigger` and the Button, whose own id wins), else the trigger element. When that\n * element is itself named through `aria-labelledby` (an icon-only Button inside\n * `Tooltip relationship=\"label\"`, or a button labelled by a visible label), its label ids are\n * returned: a name computation does not follow a second `aria-labelledby` hop, so pointing at the\n * button would leave the popover unnamed. Otherwise the element's id, else the trigger's own.\n * `undefined` when none of them has an id (a render-prop child that does not spread `id`), so the\n * reference never dangles; only ids present in the document are returned. Before the trigger\n * element is known, the resolved id.\n */\nfunction findTriggerLabelId(\n trigger: HTMLElement | null,\n resolvedId: string | undefined,\n): string | undefined {\n if (!trigger) return resolvedId;\n const doc = trigger.ownerDocument;\n const named =\n (resolvedId ? doc.getElementById(resolvedId) : null) ??\n getTriggerFocusTarget(trigger) ??\n trigger;\n return (\n presentIds(doc, named.getAttribute('aria-labelledby')) ?? (named.id || trigger.id || undefined)\n );\n}\n\n/**\n * Whether one of the elements an id list references has text for a name: its own `aria-label`\n * or text, or a descendant's `aria-label`, `alt` or `title`. Deliberately lenient (it only drives\n * a development warning): content that assistive technology ignores still counts as text.\n */\nfunction referencesText(doc: Document, ids: string): boolean {\n return ids.split(/\\s+/).some((id) => {\n const el = id ? doc.getElementById(id) : null;\n if (!el) return false;\n if (el.getAttribute('aria-label')?.trim() || el.textContent?.trim()) return true;\n return !!el.querySelector(\n '[aria-label]:not([aria-label=\"\"]), [alt]:not([alt=\"\"]), [title]:not([title=\"\"])',\n );\n });\n}\n\nconst subscribeNothing = (): (() => void) => () => {};\n\n/** Why an open popover opened: hover (it closes by hover), or anything else (it is pinned). */\ntype OpenReason = 'hover' | 'other';\n\n/** Whether a `target` is an element rather than a VirtualElement (duck typed, any realm). */\nfunction isElementTarget(target: PopupTarget | undefined): target is HTMLElement {\n return !!target && typeof (target as Partial<Node>).nodeType === 'number';\n}\n\n/** A read-only ref whose `current` is `resolve()` at the time it is read (event time). */\nfunction createResolvedRef(resolve: () => HTMLElement | null): React.RefObject<HTMLElement | null> {\n return {\n get current() {\n return resolve();\n },\n };\n}\n\n/**\n * The content's previous stop: the focus target of the element it follows (the trigger, the row of\n * a context gesture, a `target` element), else the tab stop before that element.\n */\nfunction getPopoverPreviousStop(\n anchor: HTMLElement,\n surface: HTMLElement,\n order?: readonly HTMLElement[],\n): HTMLElement | null {\n return getTriggerFocusTarget(anchor) ?? getTabbableThrough(anchor, surface, order);\n}\n\n// A const arrow (like DialogRoot and DrawerRoot): its type can be named in consumers' declaration\n// files, e.g. a story's `satisfies Meta<typeof Popover>` (a function declaration's `typeof` cannot,\n// TS4023).\nconst PopoverRoot = ({\n open: openProp,\n defaultOpen,\n onOpenChange,\n side = 'bottom',\n align = 'start',\n ignoreOutsideRefs,\n openOnHover = false,\n openDelay = 250,\n closeDelay = 500,\n openOnContext = false,\n target: targetProp,\n positioning,\n children,\n}: PopoverProps) => {\n const { target, pending: targetPending } = usePopupTarget('Popover', targetProp, positioning);\n const [openState, setOpen] = useControllable(openProp, defaultOpen ?? false, onOpenChange);\n // A hover close in flight (written in handlers, read when the popover closes): set when the hover\n // intent asks to close, so that close moves no focus even when a controlled parent applies it in\n // a later render (a transition). Every other request to open or close forgets it, and so does\n // the next opening.\n const hoverCloseRef = React.useRef(false);\n const requestOpen = useEventCallback<SetValue<boolean>>((next) => {\n hoverCloseRef.current = false;\n setOpen(next);\n });\n const isHoverClose = React.useCallback(() => hoverCloseRef.current, []);\n // The content lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the popover reports itself closed, so the trigger's aria-expanded and\n // aria-controls never describe content that is not there.\n const isClient = useIsClient();\n const open = openState && isClient;\n\n // Why the popover opened, decided when it opens (C-HOOKS: a previous-value state): `hover` when\n // hover asked for that open (a request consumed by the next render, so an open that a\n // controlled parent refused does not linger), else `other` (click, keys, a context gesture, a\n // controlled open).\n const [openReason, setOpenReason] = React.useState<OpenReason>('other');\n const [hoverRequested, setHoverRequested] = React.useState(false);\n const [previousOpen, setPreviousOpen] = React.useState(open);\n let reason = openReason;\n if (open !== previousOpen) {\n setPreviousOpen(open);\n if (open) reason = hoverRequested ? 'hover' : 'other';\n }\n if (reason !== openReason) setOpenReason(reason);\n if (hoverRequested) setHoverRequested(false);\n\n const generatedContentId = useId('popover-content');\n const [customContentId, setCustomContentId] = React.useState<string | undefined>(undefined);\n const contentId = customContentId ?? generatedContentId;\n const triggerId = useId('popover-trigger');\n const [resolvedTriggerId, setResolvedTriggerId] = React.useState<string | undefined>(undefined);\n const [surface, setSurface] = React.useState<HTMLElement | null>(null);\n const [triggerElement, setTriggerElement] = React.useState<HTMLElement | null>(null);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const surfaceRef = React.useRef<HTMLElement | null>(null);\n const arrowRef = React.useRef<HTMLDivElement | null>(null);\n // A `target` element (not a VirtualElement) belongs to the dismiss layer, anchors the keyboard\n // order without a trigger and can take focus back.\n const targetElement = isElementTarget(target) ? target : null;\n const targetRef = React.useRef<HTMLElement | null>(null);\n React.useInsertionEffect(() => {\n targetRef.current = targetElement;\n }, [targetElement]);\n\n // Destructured: react-hooks/refs treats an object whose member is passed to `ref` as a ref.\n const {\n setReference,\n setFloating,\n floatingProps: positionedProps,\n arrowStyles,\n side: placedSide,\n } = usePopupPosition({\n open,\n side,\n align,\n arrowRef,\n ...resolvePositioning(positioning, { offset: 8 }),\n });\n // A ref target that holds no element yet keeps the popup hidden (as TeachingPopover's is).\n const floatingProps = React.useMemo(\n () =>\n targetPending\n ? { ...positionedProps, style: { ...positionedProps.style, visibility: 'hidden' as const } }\n : positionedProps,\n [targetPending, positionedProps],\n );\n\n // The one focus resolver: the focus-return fallback and the layer's anchor (where a surface\n // opened from the content restores focus once its opener is gone). In context mode the element\n // focused at the gesture (the row) first; then the trigger's focus target (for a wrapper span,\n // the element inside it that carries the state ARIA), a focusable `target` element, and the\n // trigger itself. The context hook's opener ref is stable; it is filled in once the hook runs.\n const contextOpenerRef = React.useRef<React.RefObject<HTMLElement | null> | null>(null);\n const resolveFocusTarget = useEventCallback((): HTMLElement | null => {\n const gestureOpener = openOnContext ? contextOpenerRef.current?.current : null;\n if (gestureOpener && isConnectedAndFocusable(gestureOpener)) return gestureOpener;\n const trigger = triggerRef.current;\n const triggerTarget = trigger ? getTriggerFocusTarget(trigger) : null;\n if (triggerTarget) return triggerTarget;\n const targetEl = targetRef.current;\n if (targetEl && isConnectedAndFocusable(targetEl)) return targetEl;\n return trigger;\n });\n const focusTargetRef = React.useMemo(\n () => createResolvedRef(resolveFocusTarget),\n [resolveFocusTarget],\n );\n\n // In context mode the region is no part of the layer: a primary press elsewhere in it closes the\n // popover like any outside press. A Ctrl+press inside it is a macOS context click, whose\n // `contextmenu` moves the popover instead.\n const isOutsidePress = useEventCallback(\n (event: PointerEvent | MouseEvent) =>\n !(event.ctrlKey && triggerRef.current?.contains(event.target as Node)),\n );\n const { layerId } = useDismiss({\n open,\n onDismiss: () => requestOpen(false),\n refs: openOnContext\n ? [surfaceRef, targetRef, ...(ignoreOutsideRefs ?? [])]\n : [surfaceRef, triggerRef, targetRef, ...(ignoreOutsideRefs ?? [])],\n anchorRef: focusTargetRef,\n kind: 'popover',\n outsidePress: openOnContext ? isOutsidePress : true,\n });\n\n // A keyboard context gesture moves focus into the content, once it is there (see below).\n const focusContentRef = React.useRef(false);\n const {\n anchor: contextAnchor,\n fromContext,\n origin: contextOrigin,\n opener: contextOpener,\n triggerHandlers: contextTriggerHandlers,\n surfaceHandlers: contextSurfaceHandlers,\n } = useContextMenuAnchor({\n enabled: openOnContext,\n open,\n trigger: triggerElement,\n layerId,\n onOpen: (origin) => {\n focusContentRef.current = origin === 'keyboard';\n requestOpen(true);\n },\n onClose: () => requestOpen(false),\n });\n React.useInsertionEffect(() => {\n contextOpenerRef.current = contextOpener;\n }, [contextOpener]);\n\n // Focus returns to the element that takes focus for the trigger, as Shift+Tab from the content\n // does, when the popover closes while focus is inside it or on `<body>`; a hover close restores\n // only focus inside, so it never moves focus. In context mode it returns to the element focused\n // at the gesture (the row): the region is no restore target of its own (as `triggerRef` it\n // would be taken for the opener).\n const triggerFocusRef = useTriggerFocusRef(triggerRef);\n useRestoreFocus({\n enabled: open,\n container: surface,\n triggerRef: openOnContext ? undefined : triggerFocusRef,\n finalFocusRef: openOnContext ? contextOpener : undefined,\n fallback: resolveFocusTarget,\n onlyIfFocusInside: true,\n isHoverClose,\n });\n React.useLayoutEffect(() => {\n if (open) hoverCloseRef.current = false;\n }, [open]);\n\n const triggerElementRef = useMergedRefs<HTMLElement>(triggerRef, setTriggerElement);\n const surfaceElementRef = useMergedRefs<HTMLElement>(surfaceRef, setSurface, setFloating);\n\n // The positioning anchor: the context gesture (the pointer, or the focused row, else the\n // trigger's focus target, else the trigger) while the popover was opened by one, else `target`,\n // else the trigger. A new VirtualElement on every render repositions without a render loop.\n React.useLayoutEffect(() => {\n if (fromContext) {\n setReference(\n contextAnchor ??\n (triggerElement && (getTriggerFocusTarget(triggerElement) ?? triggerElement)),\n );\n } else {\n setReference(target ?? triggerElement);\n }\n }, [contextAnchor, fromContext, target, triggerElement, setReference]);\n\n // After the commit that has the surface (and after a gesture while open): focus its first\n // tabbable element, else the surface itself (it then has `tabIndex={-1}`). A gesture whose open\n // was refused leaves nothing pending. No deps: every commit, since a gesture always renders.\n React.useLayoutEffect(() => {\n if (!focusContentRef.current) return;\n if (!open) {\n focusContentRef.current = false;\n return;\n }\n if (!surface) return;\n focusContentRef.current = false;\n focusElement(getFirstTabbable(surface) ?? surface, { preventScroll: true });\n });\n\n React.useEffect(() => {\n if (!openOnHover || !openOnContext) return;\n warnOnce(\n 'Popover:hover-and-context',\n 'Popover: `openOnHover` is ignored with `openOnContext`: a context popover opens on a right click, Shift+F10 or the ContextMenu key, not on hover.',\n );\n }, [openOnHover, openOnContext]);\n\n // Hover opening: a popover that hover opened closes by hover until a click on the trigger pins\n // it; focus inside the content (or a layer opened from it) keeps it open, focus on the trigger\n // does not.\n const hoverEnabled = openOnHover && !openOnContext;\n const canHoverClose = useEventCallback(\n () => reason === 'hover' && !isFocusInSurfaceTree(surfaceRef.current, layerId),\n );\n const {\n triggerHandlers: hoverTriggerHandlers,\n surfaceHandlers: hoverSurfaceHandlers,\n cancel: cancelHover,\n } = useHoverIntent({\n enabled: hoverEnabled,\n open,\n openDelay,\n closeDelay,\n trigger: triggerElement,\n surface,\n onOpen: () => {\n setHoverRequested(true);\n requestOpen(true);\n },\n onClose: () => {\n // Before the request: a parent may apply it synchronously (flushSync).\n hoverCloseRef.current = true;\n setOpen(false);\n },\n canClose: canHoverClose,\n });\n\n const onTriggerClick = useEventCallback(() => {\n cancelHover();\n if (open && reason === 'hover') setOpenReason('other');\n else requestOpen((current) => !current);\n });\n\n // The element the content follows in the keyboard order: in context mode the element focused\n // at the gesture when it lies inside the region, else the trigger, else a `target` element.\n // With neither (a VirtualElement target and no trigger) the content keeps the portal's place.\n const resolveTabAnchor = useEventCallback((): HTMLElement | null => {\n const trigger = triggerRef.current;\n const gestureOpener = openOnContext ? contextOpener.current : null;\n if (gestureOpener && trigger?.contains(gestureOpener)) return gestureOpener;\n return trigger ?? targetRef.current;\n });\n const tabAnchorRef = React.useMemo(() => createResolvedRef(resolveTabAnchor), [resolveTabAnchor]);\n\n // Keyboard order of the portaled content (it lives at the end of the document), as if it\n // followed the trigger like 0.4's inline content: Tab from the open trigger enters it (here, in\n // the trigger's own `onKeyDown`, which runs before a dialog's focus trap), Tab past its last\n // element continues after the trigger, Shift+Tab from its first element returns to the trigger\n // (the element inside a wrapper span), and Shift+Tab from the element after the trigger enters\n // it at its last element. The end of the page does not visit it a second time where its portal\n // is, and no Tab cycle forms (see usePopoverTabOrder). In a context region only Tab from the\n // element the content follows enters it; Tab on the region's other rows moves on as usual.\n const onTriggerKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLElement>) => {\n if (event.key !== 'Tab' || event.shiftKey || !open) return;\n if (openOnContext) {\n const anchor = resolveTabAnchor();\n if (!anchor || event.target !== (getTriggerFocusTarget(anchor) ?? anchor)) return;\n }\n const surfaceElement = surfaceRef.current;\n const first = surfaceElement ? getFirstTabbable(surfaceElement) : null;\n if (!first) return;\n event.preventDefault();\n first.focus();\n });\n\n const onContentKeyDown = usePopoverTabOrder({\n enabled: open,\n surface,\n anchorRef: tabAnchorRef,\n // Shift+Tab from the content's first element returns to the trigger (the element in a span),\n // or, when nothing in the trigger can take focus, to the tab stop before it.\n getPreviousStop: getPopoverPreviousStop,\n });\n\n const keyboardContext = fromContext && contextOrigin === 'keyboard';\n const context = React.useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen: requestOpen,\n contentId,\n setCustomContentId,\n triggerId,\n resolvedTriggerId,\n setResolvedTriggerId,\n triggerRef,\n triggerElement,\n triggerElementRef,\n surfaceElementRef,\n arrowRef,\n onTriggerClick,\n onTriggerKeyDown,\n hoverTriggerHandlers: hoverEnabled ? hoverTriggerHandlers : null,\n hoverSurfaceHandlers: hoverEnabled ? hoverSurfaceHandlers : null,\n contextMode: openOnContext,\n contextTriggerHandlers: openOnContext ? contextTriggerHandlers : null,\n onContentContextMenu: contextSurfaceHandlers.onContextMenu,\n keyboardContext,\n onContentKeyDown,\n layerId,\n floatingProps,\n arrowStyles,\n placedSide,\n fitViewport: positioning?.fitViewport === true,\n }),\n [\n open,\n requestOpen,\n contentId,\n triggerId,\n resolvedTriggerId,\n triggerElement,\n triggerElementRef,\n surfaceElementRef,\n onTriggerClick,\n onTriggerKeyDown,\n hoverEnabled,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n openOnContext,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n keyboardContext,\n onContentKeyDown,\n layerId,\n floatingProps,\n arrowStyles,\n placedSide,\n positioning?.fitViewport,\n ],\n );\n\n return <PopoverContext.Provider value={context}>{children}</PopoverContext.Provider>;\n};\n\nPopoverRoot.displayName = 'Popover';\n\n/**\n * The element that toggles the popover. Its props are merged onto the single child (no wrapper\n * element): `aria-haspopup=\"dialog\"`, `aria-expanded`, `aria-controls` (while open), an `id` that\n * labels the content, a composed `onClick` and the ref used as positioning anchor and focus-return\n * target. The child's own `id`, handlers and classes are kept; the live state ARIA always wins.\n * A render function receives the props instead (spread all of them, `id` included: the content is\n * named by it); `asChild={false}` renders the 0.4 wrapper span, and a custom child that neither\n * forwards `ref` nor spreads its props falls back to that span automatically (with a development\n * warning). On the span, the state ARIA goes to the first element in the tab order inside it, and\n * focus returns to that element (to the span when you made it the trigger with a `role` such as\n * `button` and `tabIndex={0}`, or when nothing inside it can take focus).\n *\n * With `openOnHover` a mouse pointer resting on it opens the popover, and a click pins a\n * hover-opened popover instead of closing it. With `openOnContext` it is a context-menu region (a\n * list, a row, a canvas) instead of a button: it receives its `id` and the context-menu and key\n * handlers, but no state ARIA and no click toggle (a render function still receives every prop:\n * do not spread the state ARIA then).\n *\n * A Tooltip goes between the trigger and the button: it passes the trigger's `id` and ARIA on to\n * the button, which the Tooltip also describes.\n *\n * @example\n * <Popover.Trigger>\n * <Tooltip content=\"Narrow the list\">\n * <Button>Filters</Button>\n * </Tooltip>\n * </Popover.Trigger>\n *\n * Also exported as `PopoverTrigger` for React Server Components, which cannot use the dotted\n * `Popover.Trigger` (that needs a client file).\n */\nexport const PopoverTrigger = ({\n children,\n asChild,\n id: idProp,\n onClick,\n onKeyDown,\n onContextMenu,\n onPointerEnter,\n onPointerMove,\n onPointerLeave,\n ref,\n ...rest\n}: PopoverTriggerProps) => {\n const {\n open,\n contentId,\n triggerId,\n triggerElementRef,\n setResolvedTriggerId,\n onTriggerClick,\n onTriggerKeyDown,\n hoverTriggerHandlers: hover,\n contextMode,\n contextTriggerHandlers: gesture,\n } = usePopoverContext('Popover.Trigger');\n const elementRef = useMergedRefs<HTMLElement>(ref, triggerElementRef);\n\n // On a wrapper span (`asChild={false}`, the automatic fallback) useTriggerElement moves the\n // state ARIA onto the first element in the tab order inside it. The hover handlers are there\n // only with `openOnHover`, the context handlers only with `openOnContext`. A context region is\n // no popover button: it gets no state ARIA and no click toggle (useTriggerElement\n // `omitStateAria`), and a render-prop child reads a constant closed state.\n const triggerProps = {\n ...rest,\n id: idProp ?? triggerId,\n 'aria-haspopup': 'dialog' as const,\n 'aria-expanded': contextMode ? false : open,\n 'aria-controls': open && !contextMode ? contentId : undefined,\n onClick: composeEventHandlers(onClick, contextMode ? undefined : onTriggerClick),\n onKeyDown: composeEventHandlers(\n onKeyDown,\n gesture ? composeEventHandlers(gesture.onKeyDown, onTriggerKeyDown) : onTriggerKeyDown,\n ),\n onContextMenu: gesture\n ? composeEventHandlers(onContextMenu, gesture.onContextMenu)\n : onContextMenu,\n onPointerEnter: hover\n ? composeEventHandlers(onPointerEnter, hover.onPointerEnter)\n : onPointerEnter,\n onPointerMove: hover ? composeEventHandlers(onPointerMove, hover.onPointerMove) : onPointerMove,\n onPointerLeave: hover\n ? composeEventHandlers(onPointerLeave, hover.onPointerLeave)\n : onPointerLeave,\n ref: elementRef,\n } as PopoverTriggerChildProps;\n\n return useTriggerElement(children, triggerProps, {\n componentName: 'Popover.Trigger',\n asChild,\n onResolvedId: setResolvedTriggerId,\n omitStateAria: contextMode,\n });\n};\nPopoverTrigger.displayName = 'PopoverTrigger';\n\n/**\n * The popover surface: a non-modal `role=\"dialog\"` rendered in a portal (so overflow containers\n * never clip it) and positioned next to the trigger with a beak, flipping and shifting to stay in\n * the viewport. It closes on Escape and on a press outside (presses inside nested overlays opened\n * from it count as inside), and focus returns to the trigger when it closes while focus was inside.\n * In the keyboard order it follows the trigger, like inline content: Tab from the open trigger\n * enters it, Tab past its last element continues after the trigger, and Shift+Tab from the element\n * after the trigger enters it at its last element. Tab from the last element of the page moves\n * past it, and Shift+Tab from outside the page reaches the page's last element first, so a lap\n * visits it once. For a trigger outside the tab order (nothing in it can take focus, or\n * `tabIndex={-1}`), Tab from the tab stop before the trigger enters it, and Shift+Tab from its\n * first element returns to the trigger, or to that tab stop when nothing in the trigger can take\n * focus. With no tab stop before the trigger, the content is reached at the end of the page.\n * Named by `title`, `aria-label`/`aria-labelledby`, or else by its trigger: `aria-labelledby`\n * points at the id the trigger element carries in the document, or at the trigger's own label\n * elements when the trigger is named through `aria-labelledby` (an icon-only Button inside\n * `Tooltip relationship=\"label\"`); never at a missing id. A development warning names the problem\n * when the trigger has no id or no text. With `openOnContext` it is never named by the trigger (a\n * region's text is no name): pass `title`, `aria-label` or `aria-labelledby` (a development\n * warning otherwise). A consumer `id` is kept, and the trigger's `aria-controls` follows it. The\n * beak inherits the surface's background and border colors, so a `className` that changes them\n * restyles the beak too.\n *\n * With `openOnContext` it opens at the pointer of a right click, or at the focused row for\n * Shift+F10 and the ContextMenu key, and it follows that row in the keyboard order; with a\n * `target` it is placed at the target and, without a trigger, follows a target element in the\n * keyboard order.\n *\n * Also exported as `PopoverContent` for React Server Components, which cannot use the dotted\n * `Popover.Content` (that needs a client file).\n */\nexport const PopoverContent = ({\n children,\n title,\n id: idProp,\n className,\n style,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n onKeyDown,\n onContextMenu,\n onPointerEnter,\n onPointerLeave,\n ref,\n ...rest\n}: PopoverContentProps) => {\n const {\n open,\n contentId,\n setCustomContentId,\n resolvedTriggerId,\n triggerRef,\n triggerElement,\n surfaceElementRef,\n arrowRef,\n layerId,\n floatingProps,\n arrowStyles,\n placedSide,\n fitViewport,\n onContentKeyDown,\n hoverSurfaceHandlers: hover,\n contextMode,\n onContentContextMenu,\n keyboardContext,\n } = usePopoverContext('Popover.Content');\n const titleId = useId('popover-title');\n const elementRef = useMergedRefs<HTMLDivElement>(ref, surfaceElementRef);\n const hasTitle = slotRendersContent(title);\n const unnamed = ariaLabelledBy === undefined && !ariaLabel && !hasTitle;\n // A context region is no popover button, and its whole text is no name: in context mode the\n // content is never labelled by the trigger.\n const checkTrigger = open && unnamed && !contextMode;\n\n // The trigger's label ids in the document, re-read when the trigger's ids or labels change: a\n // Tooltip between Popover.Trigger and the Button leaves the Button's own id in place (and with\n // `relationship=\"label\"` names it through `aria-labelledby`), and a render-prop child may not\n // spread `id` at all — never point aria-labelledby at an id that is not there.\n const subscribeTrigger = React.useCallback(\n (onChange: () => void) => {\n if (!checkTrigger || !triggerElement || typeof MutationObserver === 'undefined') {\n return subscribeNothing();\n }\n const observer = new MutationObserver(onChange);\n observer.observe(triggerElement, {\n attributes: true,\n attributeFilter: ['id', 'aria-labelledby'],\n childList: true,\n subtree: true,\n });\n return () => observer.disconnect();\n },\n [checkTrigger, triggerElement],\n );\n const triggerLabelId = React.useSyncExternalStore(\n subscribeTrigger,\n () => (checkTrigger ? findTriggerLabelId(triggerElement, resolvedTriggerId) : undefined),\n () => (checkTrigger ? resolvedTriggerId : undefined),\n );\n\n const labelledBy =\n ariaLabelledBy ?? (ariaLabel ? undefined : hasTitle ? titleId : triggerLabelId);\n const customId = idProp || undefined;\n\n // Report the consumer's id to the root so the trigger's `aria-controls` points at it.\n React.useEffect(() => {\n setCustomContentId(customId);\n return () => setCustomContentId(undefined);\n }, [customId, setCustomContentId]);\n\n React.useEffect(() => {\n if (!open || !unnamed || !contextMode || !isDev) return;\n warnOnce(\n 'Popover.Content:name',\n 'Popover.Content: the popover has no accessible name. A context popover (openOnContext) is not named by its region: pass `title`, `aria-label` or `aria-labelledby`.',\n );\n }, [open, unnamed, contextMode]);\n\n React.useEffect(() => {\n if (!checkTrigger || !isDev) return;\n // Read after commit: a trigger's ref is attached by now even before it reported its id.\n const trigger = triggerRef.current;\n if (!trigger) {\n warnOnce(\n 'Popover.Content:name',\n 'Popover.Content: the popover has no accessible name. Pass `title`, `aria-label` or `aria-labelledby`, or open it from a Popover.Trigger.',\n );\n return;\n }\n const labelIds = findTriggerLabelId(trigger, resolvedTriggerId);\n if (!labelIds) {\n warnOnce(\n 'Popover.Content:trigger-id',\n 'Popover.Content: the popover is named by its trigger, but the trigger element has no `id` (a render-prop child of Popover.Trigger must spread the `id` it receives), so the popover has no accessible name. Spread every trigger prop onto the element, or pass `title`, `aria-label` or `aria-labelledby`.',\n );\n } else if (!referencesText(trigger.ownerDocument, labelIds)) {\n warnOnce(\n 'Popover.Content:trigger-name',\n 'Popover.Content: the popover is named by its trigger, but the trigger has no text to name it (an icon-only trigger needs `aria-label`, or `aria-labelledby` pointing at text), so the popover has no accessible name. Name the trigger, or pass `title`, `aria-label` or `aria-labelledby`.',\n );\n }\n }, [checkTrigger, resolvedTriggerId, triggerRef, triggerLabelId]);\n\n if (!open) return null;\n\n const titleAndChildren = (\n <>\n {hasTitle && (\n <h2\n id={titleId}\n className={cn(popoverContentClassNames.title, 'mb-2 text-subtitle-2 font-semibold')}\n >\n {title}\n </h2>\n )}\n {children}\n </>\n );\n\n return (\n <Portal layerId={layerId}>\n <div\n role=\"dialog\"\n aria-label={ariaLabel}\n aria-labelledby={labelledBy}\n tabIndex={keyboardContext ? -1 : undefined}\n {...rest}\n ref={elementRef}\n id={customId ?? contentId}\n data-side={floatingProps['data-side']}\n data-align={floatingProps['data-align']}\n style={{ ...style, ...floatingProps.style }}\n onKeyDown={composeEventHandlers(onKeyDown, onContentKeyDown)}\n onContextMenu={composeEventHandlers(onContextMenu, onContentContextMenu)}\n onPointerEnter={\n hover ? composeEventHandlers(onPointerEnter, hover.onPointerEnter) : onPointerEnter\n }\n onPointerLeave={\n hover ? composeEventHandlers(onPointerLeave, hover.onPointerLeave) : onPointerLeave\n }\n className={cn(\n popoverContentClassNames.root,\n 'w-64 rounded-md border border-border bg-background p-4 text-body-1 font-normal text-foreground normal-case tracking-normal text-start shadow-4',\n className,\n )}\n >\n <PopoverBeak\n ref={arrowRef}\n side={placedSide}\n style={arrowStyles}\n data-wave-popover-arrow=\"\"\n className={popoverContentClassNames.beak}\n />\n {fitViewport ? (\n // The beak sits half outside the border, so the scroller is inside it: the viewport\n // limit minus the content's padding (2 x 1rem) and border (2 x 1px).\n <div className=\"overflow-y-auto max-h-[calc(var(--wave-popup-available-height)-2rem-2px)]\">\n {titleAndChildren}\n </div>\n ) : (\n titleAndChildren\n )}\n </div>\n </Portal>\n );\n};\nPopoverContent.displayName = 'PopoverContent';\n\n/**\n * A non-modal popup anchored to a trigger: `Popover.Trigger` (merges its props onto the child\n * button) and `Popover.Content` (portaled, positioned `role=\"dialog\"` surface). Use it for custom\n * popups such as filters or details; for a menu button use `Menu.Trigger` and `Menu.Popover`,\n * which add menu semantics and keyboard support.\n *\n * Controlled (`open`/`onOpenChange`) or uncontrolled (`defaultOpen`); `side`/`align` place the\n * content, and `ignoreOutsideRefs` lists external elements (such as a toggle button) whose presses\n * do not dismiss it.\n *\n * - **Hover cards:** `openOnHover` opens it when a mouse pointer rests on the trigger\n * (`openDelay`) and closes it once the pointer has left the trigger and the content\n * (`closeDelay`), unless focus is inside; a click on the trigger pins it.\n * - **Context popovers:** `openOnContext` makes the trigger a context-menu region: a right click\n * opens it at the pointer, Shift+F10 or the ContextMenu key at the focused row (with focus\n * moving into the content). Name the content with `title` or `aria-label`.\n * - **Custom anchors:** `target` places it at another element or at a `VirtualElement` (a point, a\n * text selection); with a controlled `open` it needs no trigger.\n *\n * @example\n * <Popover>\n * <Popover.Trigger><Button>Details</Button></Popover.Trigger>\n * <Popover.Content title=\"Details\">…</Popover.Content>\n * </Popover>\n */\nexport const Popover = /* @__PURE__ */ Object.assign(PopoverRoot, {\n Trigger: PopoverTrigger,\n Content: PopoverContent,\n});\n"],"mappings":"47BA+OA,IAAMmD,EAAiBnD,EAAM,cAA0C,IAAI,EAC3E,EAAe,YAAc,iBAE7B,IAAIoD,EAA2C,KAG/C,SAASC,GAAuC,CA6B9C,MA5BA,KAAiB,CACf,KAAM,GACN,YAAe,CAAC,EAChB,UAAW,6BACX,uBAA0B,CAAC,EAC3B,UAAW,6BACX,kBAAmB,IAAA,GACnB,yBAA4B,CAAC,EAC7B,WAAY,CAAE,QAAS,IAAK,EAC5B,eAAgB,KAChB,sBAAyB,CAAC,EAC1B,sBAAyB,CAAC,EAC1B,SAAU,CAAE,QAAS,IAAK,EAC1B,mBAAsB,CAAC,EACvB,qBAAwB,CAAC,EACzB,qBAAsB,KACtB,qBAAsB,KACtB,YAAa,GACb,uBAAwB,KACxB,yBAA4B,CAAC,EAC7B,gBAAiB,GACjB,qBAAwB,CAAC,EACzB,QAAS,2BACT,cAAe,CAAE,YAAa,SAAU,aAAc,QAAS,MAAO,CAAC,CAAE,EACzE,YAAa,CAAC,EACd,WAAY,SACZ,YAAa,EACf,EACOD,CACT,CAEA,SAASE,EAAkB,EAA4C,CAIrE,OAHgBtD,EAAM,WAAWmD,CAC7B,IACJrB,EAAA,qBAAqByB,EAAe,SAAS,EACtCF,EAAgB,EACzB,CAGA,SAASG,EAAW,E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