@mortenbrudvik/waveui 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +634 -167
- package/dist/components/data-display/InfoButton.cjs +2 -0
- package/dist/components/data-display/InfoButton.cjs.map +1 -0
- package/dist/components/data-display/InfoButton.mjs +173 -0
- package/dist/components/data-display/InfoButton.mjs.map +1 -0
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +39 -96
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/input/Calendar.cjs +2 -0
- package/dist/components/input/Calendar.cjs.map +1 -0
- package/dist/components/input/Calendar.mjs +352 -0
- package/dist/components/input/Calendar.mjs.map +1 -0
- package/dist/components/input/Calendar.views.cjs +2 -0
- package/dist/components/input/Calendar.views.cjs.map +1 -0
- package/dist/components/input/Calendar.views.mjs +194 -0
- package/dist/components/input/Calendar.views.mjs.map +1 -0
- package/dist/components/input/Checkbox.cjs +1 -1
- package/dist/components/input/Checkbox.cjs.map +1 -1
- package/dist/components/input/Checkbox.mjs +91 -75
- package/dist/components/input/Checkbox.mjs.map +1 -1
- package/dist/components/input/ColorArea.cjs +1 -1
- package/dist/components/input/ColorArea.cjs.map +1 -1
- package/dist/components/input/ColorArea.mjs +18 -18
- package/dist/components/input/ColorArea.mjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.cjs +1 -1
- package/dist/components/input/ColorPicker.parts.cjs.map +1 -1
- package/dist/components/input/ColorPicker.parts.mjs +1 -1
- package/dist/components/input/ColorPicker.parts.mjs.map +1 -1
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.cjs +1 -1
- package/dist/components/input/Combobox.expand.cjs.map +1 -1
- package/dist/components/input/Combobox.expand.mjs +20 -20
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +219 -138
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/Combobox.text.cjs +2 -0
- package/dist/components/input/Combobox.text.cjs.map +1 -0
- package/dist/components/input/Combobox.text.mjs +24 -0
- package/dist/components/input/Combobox.text.mjs.map +1 -0
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +205 -286
- package/dist/components/input/DatePicker.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +137 -105
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Field.cjs +1 -1
- package/dist/components/input/Field.cjs.map +1 -1
- package/dist/components/input/Field.mjs +99 -66
- package/dist/components/input/Field.mjs.map +1 -1
- package/dist/components/input/Input.cjs +1 -1
- package/dist/components/input/Input.cjs.map +1 -1
- package/dist/components/input/Input.mjs +79 -55
- package/dist/components/input/Input.mjs.map +1 -1
- package/dist/components/input/Label.cjs +1 -1
- package/dist/components/input/Label.cjs.map +1 -1
- package/dist/components/input/Label.mjs +19 -13
- package/dist/components/input/Label.mjs.map +1 -1
- package/dist/components/input/Listbox.cjs +2 -0
- package/dist/components/input/Listbox.cjs.map +1 -0
- package/dist/components/input/Listbox.mjs +134 -0
- package/dist/components/input/Listbox.mjs.map +1 -0
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +158 -97
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/Rating.cjs +1 -1
- package/dist/components/input/Rating.cjs.map +1 -1
- package/dist/components/input/Rating.item.cjs +2 -0
- package/dist/components/input/Rating.item.cjs.map +1 -0
- package/dist/components/input/Rating.item.mjs +255 -0
- package/dist/components/input/Rating.item.mjs.map +1 -0
- package/dist/components/input/Rating.mjs +150 -151
- package/dist/components/input/Rating.mjs.map +1 -1
- package/dist/components/input/SearchBox.cjs +1 -1
- package/dist/components/input/SearchBox.cjs.map +1 -1
- package/dist/components/input/SearchBox.mjs +146 -115
- package/dist/components/input/SearchBox.mjs.map +1 -1
- package/dist/components/input/Select.cjs +1 -1
- package/dist/components/input/Select.cjs.map +1 -1
- package/dist/components/input/Select.mjs +34 -25
- package/dist/components/input/Select.mjs.map +1 -1
- package/dist/components/input/Slider.cjs +1 -1
- package/dist/components/input/Slider.cjs.map +1 -1
- package/dist/components/input/Slider.mjs +77 -54
- package/dist/components/input/Slider.mjs.map +1 -1
- package/dist/components/input/SpinButton.cjs +1 -1
- package/dist/components/input/SpinButton.cjs.map +1 -1
- package/dist/components/input/SpinButton.mjs +198 -96
- package/dist/components/input/SpinButton.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.context.cjs +2 -0
- package/dist/components/input/SwatchPicker.context.cjs.map +1 -0
- package/dist/components/input/SwatchPicker.context.mjs +35 -0
- package/dist/components/input/SwatchPicker.context.mjs.map +1 -0
- package/dist/components/input/SwatchPicker.mjs +131 -103
- package/dist/components/input/SwatchPicker.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.swatches.cjs +2 -0
- package/dist/components/input/SwatchPicker.swatches.cjs.map +1 -0
- package/dist/components/input/SwatchPicker.swatches.mjs +207 -0
- package/dist/components/input/SwatchPicker.swatches.mjs.map +1 -0
- package/dist/components/input/Switch.cjs +1 -1
- package/dist/components/input/Switch.cjs.map +1 -1
- package/dist/components/input/Switch.mjs +71 -55
- package/dist/components/input/Switch.mjs.map +1 -1
- package/dist/components/input/TagPicker.cjs +1 -1
- package/dist/components/input/TagPicker.cjs.map +1 -1
- package/dist/components/input/TagPicker.mjs +154 -123
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/Textarea.cjs +1 -1
- package/dist/components/input/Textarea.cjs.map +1 -1
- package/dist/components/input/Textarea.mjs +28 -21
- package/dist/components/input/Textarea.mjs.map +1 -1
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +204 -199
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/input/dateUtils.cjs +1 -1
- package/dist/components/input/dateUtils.cjs.map +1 -1
- package/dist/components/input/dateUtils.mjs +114 -96
- package/dist/components/input/dateUtils.mjs.map +1 -1
- package/dist/components/input/fieldLabel.cjs +2 -0
- package/dist/components/input/fieldLabel.cjs.map +1 -0
- package/dist/components/input/fieldLabel.mjs +17 -0
- package/dist/components/input/fieldLabel.mjs.map +1 -0
- package/dist/components/input/inputLook.cjs +2 -0
- package/dist/components/input/inputLook.cjs.map +1 -0
- package/dist/components/input/inputLook.mjs +28 -0
- package/dist/components/input/inputLook.mjs.map +1 -0
- package/dist/components/input/pickerLabels.cjs +2 -0
- package/dist/components/input/pickerLabels.cjs.map +1 -0
- package/dist/components/input/pickerLabels.mjs +16 -0
- package/dist/components/input/pickerLabels.mjs.map +1 -0
- package/dist/components/input/pickerStyles.cjs +1 -1
- package/dist/components/input/pickerStyles.cjs.map +1 -1
- package/dist/components/input/pickerStyles.mjs +42 -4
- package/dist/components/input/pickerStyles.mjs.map +1 -1
- package/dist/components/input/pickerValues.cjs +2 -0
- package/dist/components/input/pickerValues.cjs.map +1 -0
- package/dist/components/input/pickerValues.mjs +24 -0
- package/dist/components/input/pickerValues.mjs.map +1 -0
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +10 -10
- package/dist/components/navigation/Menu.root.cjs +1 -1
- package/dist/components/navigation/Menu.root.cjs.map +1 -1
- package/dist/components/navigation/Menu.root.mjs +10 -10
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +203 -208
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/Popover.shared.cjs +1 -1
- package/dist/components/overlays/Popover.shared.cjs.map +1 -1
- package/dist/components/overlays/Popover.shared.mjs +82 -77
- package/dist/components/overlays/Popover.shared.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +25 -19
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/useGridNavigation.cjs +1 -1
- package/dist/components/table/useGridNavigation.cjs.map +1 -1
- package/dist/components/table/useGridNavigation.mjs +67 -70
- package/dist/components/table/useGridNavigation.mjs.map +1 -1
- package/dist/hooks/useActiveDescendant.cjs +2 -0
- package/dist/hooks/useActiveDescendant.cjs.map +1 -0
- package/dist/hooks/useActiveDescendant.mjs +56 -0
- package/dist/hooks/useActiveDescendant.mjs.map +1 -0
- package/dist/hooks/useFieldControl.cjs.map +1 -1
- package/dist/hooks/useFieldControl.mjs.map +1 -1
- package/dist/hooks/useListbox.cjs +1 -1
- package/dist/hooks/useListbox.cjs.map +1 -1
- package/dist/hooks/useListbox.mjs +250 -210
- package/dist/hooks/useListbox.mjs.map +1 -1
- package/dist/hooks/useRovingGrid.cjs +2 -0
- package/dist/hooks/useRovingGrid.cjs.map +1 -0
- package/dist/hooks/useRovingGrid.mjs +69 -0
- package/dist/hooks/useRovingGrid.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2901 -203
- package/dist/index.d.ts +2901 -203
- package/dist/index.mjs +107 -99
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +111 -67
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/date.cjs +2 -0
- package/dist/lib/date.cjs.map +1 -0
- package/dist/lib/date.mjs +44 -0
- package/dist/lib/date.mjs.map +1 -0
- package/dist/lib/focus.cjs +1 -1
- package/dist/lib/focus.cjs.map +1 -1
- package/dist/lib/focus.mjs +5 -2
- package/dist/lib/focus.mjs.map +1 -1
- package/dist/lib/layers.cjs.map +1 -1
- package/dist/lib/layers.mjs.map +1 -1
- package/dist/lib/styles.cjs +1 -1
- package/dist/lib/styles.cjs.map +1 -1
- package/dist/lib/styles.mjs +21 -4
- package/dist/lib/styles.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +13 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Menu.root.cjs","names":["flattenChildren","isElementOfType","MenuTrigger","MenuPopover","useMenuListContext","React","PortalDepthContext","useControllable","useIsClient","useId","useCheckedValues","useEventCallback","withCheckedValuesListener","getLayerTreeElements","useHoverIntent","useContextMenuAnchor","useRovingTabIndex","MENU_ITEM_SELECTOR","useMergedRefs","getFirstTabbable","useCheckableRegistry","useMenuListPointer","MenuContext","MenuListContext","composeEventHandlers","withTypeaheadText","cn","menuClassNames","menuSurfaceClasses","focusRing","require_runtime","require_cn","require_children","require_dev","require_composeEventHandlers","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_focus","require_useRovingTabIndex","require_useMergedRefs","require_useIsClient","require_layers","require_Portal","require_styles","require_useCheckedValues","require_Menu_context","require_Menu_shared","require_useHoverIntent","require_Menu_popover","require_useContextMenuAnchor","require_Menu_trigger","react","react_jsx_runtime","noop","HOVER_DELAY_MS","hasPopupParts","children","node","listProps","quoted","names","name","MenuRoot","openProp","persistOnItemClickProp","openOnHoverProp","openDelayProp","closeDelayProp","openOnContextProp","rest","list","portalDepth","parentList","parent","isSubmenu","openState","setOpen","openControlled","defaultOpen","onOpenChange","isClient","parentOpen","open","popup","triggerId","menuId","labelledBy","setLabelledBy","triggerRef","triggerElement","setTriggerElementState","setTriggerElement","element","surfaceApiRef","surfaceElement","setSurfaceElement","surfaceLayerId","setSurfaceLayerId","registerSurface","api","ownChecked","checkedValues","defaultCheckedValues","onCheckedValuesChange","parentChecked","ownsCheckedState","listens","listener","sharedChecked","checked","persistOnItemClick","openDelay","closeDelay","contextMode","hoverMode","ignoredProps","className","onKeyDown","onKeyDownCapture","onFocus","onPointerMove","value","ref","ignoredMessage","staticPopupProps","hoverAndContext","verb","pronoun","staticMenuRef","openSubmenuRef","containsFocus","surfaceApi","active","el","listContainsFocus","hoverCloseRef","isHoverClose","closeMenu","byHover","requestClose","requestHoverClose","openReasonRef","hoverOpenPendingRef","initialFocusRef","isHoverOpen","hoverIntentTriggerHandlers","hoverSurfaceHandlers","cancelHover","startHoverClose","forgetHoverOpening","hoverTriggerHandlers","event","openWithFocus","target","takeInitialFocus","contextAnchor","contextOpener","contextTriggerHandlers","contextSurfaceHandlers","parentListHoverFocusing","parentHoverFocusing","isHoverFocusing","contextPressRef","doc","onPointerDown","onPointerEnd","dismiss","reason","registerOpenSubmenu","previous","submenu","submenuHandle","registerWithParent","parentCloseChain","closeChain","contextValue","fromContext","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","mergedRef","menuIsTabStop","setMenuIsTabStop","menu","noItemTabStop","focusFirst","getTabIndex","registerCheckable","isListHoverFocusing","listPointerMove","listContext","hoverGroup"],"sources":["../../../src/components/navigation/Menu.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getFirstTabbable } from '../../lib/focus';\nimport { getLayerTreeElements, type DismissReason } from '../../lib/layers';\nimport { focusRing } from '../../lib/styles';\nimport type { CheckedValues, CheckedValuesChangeHandler } from '../../lib/types';\nimport { useCheckedValues, withCheckedValuesListener } from '../../hooks/useCheckedValues';\nimport { useContextMenuAnchor } from '../../hooks/useContextMenuAnchor';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useHoverIntent, type HoverIntent } from '../../hooks/useHoverIntent';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { PortalDepthContext } from '../portal/Portal';\nimport {\n MenuContext,\n MenuListContext,\n useCheckableRegistry,\n useMenuListContext,\n} from './Menu.context';\nimport type {\n InitialFocus,\n MenuContextValue,\n MenuListContextValue,\n MenuSurfaceApi,\n OpenSubmenu,\n} from './Menu.context';\nimport { MENU_ITEM_SELECTOR, menuSurfaceClasses, withTypeaheadText } from './Menu.shared';\nimport { MenuPopover, useMenuListPointer } from './Menu.popover';\nimport { MenuTrigger } from './Menu.trigger';\n\n/** Properties for the Menu component. */\nexport interface MenuProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Menu items and dividers (static menu), or a `Menu.Trigger` and a `Menu.Popover` (popup menu).\n */\n children: React.ReactNode;\n /**\n * Controlled open state of a popup menu (`Menu.Trigger` + `Menu.Popover`). Passing it, even\n * `false` (like passing `defaultOpen` or `onOpenChange`), makes Menu a popup menu that renders no\n * element of its own: use it only with `Menu.Trigger`/`Menu.Popover`. Items outside\n * `Menu.Popover` then have no `role=\"menu\"` parent (development warning). Leave all three out\n * for a static menu. The popup renders only in the browser: an open menu is closed in the\n * server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state of an uncontrolled popup menu; a popup menu starts closed without it.\n * Passing it, even `false`, makes Menu a popup menu (see `open`), so for a Menu without\n * `Menu.Trigger`/`Menu.Popover` children, leaving it out is not the same as `false`. The popup\n * renders only in the browser: a menu open by default is closed in the server HTML and opens\n * once it has hydrated.\n */\n defaultOpen?: boolean;\n /**\n * Called with the next open state when the popup menu opens or closes (only on change). Passing\n * it makes Menu a popup menu (see `open`).\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Checked items of the menu's checkbox, radio and switch items, per group `name` (controlled).\n * A submenu without its own `checkedValues` or `defaultCheckedValues` shares its parent menu's\n * state. Works for static and popup menus; unlike `open`, it does not make Menu a popup menu.\n */\n checkedValues?: CheckedValues;\n /** Initial checked items for uncontrolled usage (gives a submenu its own state). @default {} */\n defaultCheckedValues?: CheckedValues;\n /**\n * Called when an item changes the checked items (only on change): the new checked values of every\n * group first, then `details` with the group's `name`, its `checkedItems` and the `event` (Fluent's\n * `onCheckedValueChange(event, { name, checkedItems })`). WaveUI always passes `details`; it is\n * typed optional until 1.0. On a submenu that shares its parent's state it only listens: it is\n * called after the parent's callback, for changes made in this submenu.\n */\n onCheckedValuesChange?: CheckedValuesChangeHandler;\n /**\n * Keep a popup menu open after any of its items is activated; an item's own `persistOnClick`\n * wins. A submenu inherits it unless it sets it.\n * @default false\n */\n persistOnItemClick?: boolean;\n /**\n * Open the popup menu when a mouse pointer rests on its trigger, and close it once the pointer\n * has been off the trigger and the menu for `closeDelay` while focus is not inside the menu. A\n * menu opened by hover does not take focus; a click (or Enter, Space, ArrowDown) on its trigger\n * keeps it open and moves focus into it, as opening it that way does. After Escape or an\n * outside press it does not reopen until the pointer has left the trigger. Touch and pen never\n * open it by hover, and an `aria-disabled` trigger never opens. A triangle between the trigger\n * and the menu keeps it open while the pointer moves diagonally into it. Ignored with\n * `openOnContext` (development warning) and on a static menu (development warning).\n * @default false (true for a submenu)\n */\n openOnHover?: boolean;\n /**\n * Milliseconds a hovering mouse pointer rests on the trigger before the menu opens (mouse hover\n * only). A submenu inherits its parent's, also from a static menu. @default 250\n */\n openDelay?: number;\n /**\n * Milliseconds before a hover-opened menu closes once the mouse pointer has left it and its\n * trigger (mouse hover only). A submenu inherits its parent's, also from a static menu.\n * @default 250\n */\n closeDelay?: number;\n /**\n * Make `Menu.Trigger` a context-menu region: a right click (a Ctrl+click on macOS, a long press\n * where the browser reports one) opens the menu at the pointer, and Shift+F10 or the\n * ContextMenu key opens it at the focused element inside the region, instead of a click; a\n * second gesture while it is open moves it there. Focus returns to the element that had it.\n * The browser's context menu is suppressed there and inside the menu, 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 region or the row of the gesture (the one under the pointer, or the focused one)\n * closes it. The trigger gets no `aria-haspopup`/`aria-expanded` (it is not a menu button; with\n * a render-prop child, do not spread them): name the menu with `aria-label` on `Menu.Popover`,\n * and consider `aria-keyshortcuts=\"Shift+F10\"` on the region. iOS Safari reports no long press.\n * Ignored on a submenu; `openOnHover` is ignored with it.\n * @default false\n */\n openOnContext?: boolean;\n /**\n * Ref to the static menu element (`role=\"menu\"`). A popup menu renders no root element, so it\n * ignores `ref`, `className` and other DOM props (development warning): pass them to\n * `Menu.Popover`.\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst noop = () => {};\n\n/** Default of `openDelay` and `closeDelay` (InfoLabel's hover delays). */\nconst HOVER_DELAY_MS = 250;\n\n/**\n * Whether the children contain a `Menu.Trigger` or `Menu.Popover`: direct children and the\n * children of Fragments only (other elements and components are not searched). Parts written in\n * a Server Component (lazy client references) are recognised too.\n */\nexport function hasPopupParts(children: React.ReactNode): boolean {\n return flattenChildren(children).some(({ node }) =>\n isElementOfType(node, MenuTrigger, MenuPopover),\n );\n}\n\n/** Joins prop names for a message: `a`, `` `a` and `b` ``. */\nfunction listProps(names: string[]): string {\n const quoted = names.map((name) => `\\`${name}\\``);\n return quoted.length > 1\n ? `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`\n : quoted.join('');\n}\n\n// The root of the `Menu` compound. Its component JSDoc is on the `Menu` export (Menu.tsx) only\n// (C-DOCS): a docblock here would replace it as the Storybook description.\nexport const MenuRoot = ({\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n checkedValues,\n defaultCheckedValues,\n onCheckedValuesChange,\n persistOnItemClick: persistOnItemClickProp,\n openOnHover: openOnHoverProp,\n openDelay: openDelayProp,\n closeDelay: closeDelayProp,\n openOnContext: openOnContextProp,\n className,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerMove,\n ref,\n ...rest\n}: MenuProps) => {\n // A Menu rendered in a menu list with no portal between them is a submenu of that list's menu.\n // A Menu inside a Popover or Dialog opened from an item sits one portal deeper: a root menu.\n const list = useMenuListContext();\n const portalDepth = React.useContext(PortalDepthContext);\n const parentList = list !== null && list.portalDepth === portalDepth ? list : null;\n const parent = parentList?.menu ?? null;\n const isSubmenu = parent !== null;\n\n const [openState, setOpen, openControlled] = useControllable(\n openProp,\n defaultOpen ?? false,\n onOpenChange,\n );\n // The popup menu lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the menu reports itself closed, so the trigger's aria-expanded and\n // aria-controls never describe a menu that is not there. A submenu of a popup menu is open only\n // while that menu is: a parent that closes (through its controlled prop, or while it runs an\n // exit motion) takes the submenu's surface, layer and focus restore along in the same commit.\n const isClient = useIsClient();\n const parentOpen = parent === null || !parent.popup || parent.open;\n const open = openState && isClient && parentOpen;\n // A parent that closed without closing this submenu (its controlled `open` prop): an\n // uncontrolled submenu closes too, so it does not reopen with the parent. A controlled\n // submenu's state is the app's.\n React.useLayoutEffect(() => {\n if (parentOpen || !openState || openControlled) return;\n setOpen(false);\n }, [parentOpen, openState, openControlled, setOpen]);\n\n const popup =\n openProp !== undefined ||\n defaultOpen !== undefined ||\n onOpenChange !== undefined ||\n hasPopupParts(children);\n\n const triggerId = useId('wave-menu-trigger');\n const menuId = useId('wave-menu');\n const [labelledBy, setLabelledBy] = React.useState(triggerId);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const [triggerElement, setTriggerElementState] = React.useState<HTMLElement | null>(null);\n const setTriggerElement = React.useCallback((element: HTMLElement | null) => {\n triggerRef.current = element;\n setTriggerElementState(element);\n }, []);\n\n // The open surface: its API in a ref (read in events), its element and layer in state (the\n // hover and context-menu hooks observe them).\n const surfaceApiRef = React.useRef<MenuSurfaceApi | null>(null);\n const [surfaceElement, setSurfaceElement] = React.useState<HTMLElement | null>(null);\n const [surfaceLayerId, setSurfaceLayerId] = React.useState('');\n const registerSurface = React.useCallback((api: MenuSurfaceApi | null) => {\n surfaceApiRef.current = api;\n setSurfaceElement(api?.surface ?? null);\n // Kept after the surface closes: a context gesture records its opener against the last layer.\n if (api) setSurfaceLayerId(api.layerId);\n }, []);\n\n // Checked values: one state per menu tree. A Menu owns its state when it sets `checkedValues` or\n // `defaultCheckedValues`, or has no parent; otherwise it uses its parent's, and its own\n // `onCheckedValuesChange` only listens to the changes its items make (called after the owner's).\n const ownChecked = useCheckedValues(checkedValues, defaultCheckedValues, onCheckedValuesChange);\n const parentChecked = parent?.checked ?? null;\n const ownsCheckedState =\n parentChecked === null || checkedValues !== undefined || defaultCheckedValues !== undefined;\n const listens = onCheckedValuesChange !== undefined;\n const listener = useEventCallback(onCheckedValuesChange);\n const sharedChecked = React.useMemo(\n () =>\n parentChecked && listens ? withCheckedValuesListener(parentChecked, listener) : parentChecked,\n [parentChecked, listens, listener],\n );\n const checked = ownsCheckedState || sharedChecked === null ? ownChecked : sharedChecked;\n const persistOnItemClick = persistOnItemClickProp ?? parent?.persistOnItemClick ?? false;\n const openDelay = openDelayProp ?? parent?.openDelay ?? HOVER_DELAY_MS;\n const closeDelay = closeDelayProp ?? parent?.closeDelay ?? HOVER_DELAY_MS;\n\n // Context mode applies to a root popup menu; hover to a popup menu outside context mode.\n const contextMode = popup && !isSubmenu && openOnContextProp === true;\n const hoverMode = popup && !contextMode && (openOnHoverProp ?? isSubmenu);\n\n // C-DEV: a popup menu renders no root element, so root DOM props and the ref go nowhere.\n const ignoredProps: string[] = [];\n if (popup) {\n if (className !== undefined) ignoredProps.push('className');\n if (onKeyDown !== undefined) ignoredProps.push('onKeyDown');\n if (onKeyDownCapture !== undefined) ignoredProps.push('onKeyDownCapture');\n if (onFocus !== undefined) ignoredProps.push('onFocus');\n if (onPointerMove !== undefined) ignoredProps.push('onPointerMove');\n for (const [name, value] of Object.entries(rest)) {\n if (value !== undefined) ignoredProps.push(name);\n }\n if (ref != null) ignoredProps.push('ref');\n }\n const ignoredMessage =\n ignoredProps.length === 0\n ? ''\n : `Menu: a popup menu (Menu.Trigger + Menu.Popover) renders no element of its own, so ${ignoredProps\n .map((name) => `\\`${name}\\``)\n .join(', ')} on Menu ${ignoredProps.length === 1 ? 'is' : 'are'} ignored. Pass ${\n ignoredProps.length === 1 ? 'it' : 'them'\n } to Menu.Popover (the menu surface) or to the trigger's child instead.`;\n React.useEffect(() => {\n if (ignoredMessage) warnOnce('Menu:popup-ignored-props', ignoredMessage);\n }, [ignoredMessage]);\n\n // C-DEV: the popup openings do nothing on a static menu; hover gives way to context gestures.\n const staticPopupProps = popup\n ? ''\n : listProps(\n [openOnHoverProp ? 'openOnHover' : null, openOnContextProp ? 'openOnContext' : null].filter(\n (name): name is string => name !== null,\n ),\n );\n const hoverAndContext = contextMode && openOnHoverProp === true;\n React.useEffect(() => {\n if (!staticPopupProps) return;\n const [verb, pronoun] = staticPopupProps.includes(' and ') ? ['are', 'they'] : ['is', 'it'];\n warnOnce(\n 'Menu:static-popup-props',\n `Menu: ${staticPopupProps} ${verb} ignored on a static menu: ${pronoun} apply to a popup menu (Menu.Trigger + Menu.Popover). A static menu passes openDelay and closeDelay on to its submenus.`,\n );\n }, [staticPopupProps]);\n React.useEffect(() => {\n if (!hoverAndContext) return;\n warnOnce(\n 'Menu:hover-and-context',\n 'Menu: openOnHover is ignored with openOnContext: a context menu opens only from a context gesture (a right click, Shift+F10 or the ContextMenu key).',\n );\n }, [hoverAndContext]);\n\n const staticMenuRef = React.useRef<HTMLDivElement | null>(null);\n\n // The open submenu of this menu's list (one at a time) and what focus inside means for the chain.\n const openSubmenuRef = React.useRef<OpenSubmenu | null>(null);\n const containsFocus = useEventCallback((): boolean => {\n const surfaceApi = surfaceApiRef.current;\n const element = surfaceApi?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (!element || !active) return false;\n if (element.contains(active)) return true;\n // A popup menu's layer tree holds its submenus and the portals opened from its items; its own\n // elements (the trigger) do not count.\n if (surfaceApi) {\n return getLayerTreeElements(surfaceApi.layerId, { includeOwnElements: false }).some((el) =>\n el.contains(active),\n );\n }\n return openSubmenuRef.current?.containsFocus() ?? false;\n });\n // Focus in a list of the chain: this menu's list, else (recursively) its open submenu's. A\n // portal opened from an item does not count, so hover never takes focus from it.\n const listContainsFocus = useEventCallback((): boolean => {\n const element = surfaceApiRef.current?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (element && active && element.contains(active)) return true;\n return openSubmenuRef.current?.listContainsFocus() ?? false;\n });\n\n // Every close of this menu closes its open submenu first, innermost first, through the\n // submenu's own state: each controlled submenu hears onOpenChange(false) once. A close asked for\n // by the hover intent is marked (before the request, in case the app applies it synchronously),\n // so the surface's focus restore moves no focus; every other close request, and the next\n // opening, clears the mark. A submenu closed along with it is taken along by the restore itself.\n const hoverCloseRef = React.useRef(false);\n const isHoverClose = React.useCallback(() => hoverCloseRef.current, []);\n const closeMenu = (byHover: boolean) => {\n hoverCloseRef.current = byHover;\n openSubmenuRef.current?.close();\n setOpen(false);\n };\n const requestClose = useEventCallback(() => closeMenu(false));\n const requestHoverClose = useEventCallback(() => closeMenu(true));\n\n // Why the open menu is open: a hover opening stays unpinned (the hover close applies) until the\n // trigger is activated; every other opening (click, keys, context, a controlled `open`) pins it.\n const openReasonRef = React.useRef<'hover' | 'other'>('other');\n const hoverOpenPendingRef = React.useRef(false);\n const initialFocusRef = React.useRef<InitialFocus>('first');\n React.useLayoutEffect(() => {\n if (open) {\n openReasonRef.current = hoverOpenPendingRef.current ? 'hover' : 'other';\n hoverCloseRef.current = false;\n }\n hoverOpenPendingRef.current = false;\n }, [open]);\n const isHoverOpen = React.useCallback(() => openReasonRef.current === 'hover', []);\n\n const {\n triggerHandlers: hoverIntentTriggerHandlers,\n surfaceHandlers: hoverSurfaceHandlers,\n cancel: cancelHover,\n startClose: startHoverClose,\n } = useHoverIntent({\n enabled: hoverMode,\n open,\n openDelay,\n closeDelay,\n trigger: triggerElement,\n surface: surfaceElement,\n group: parentList?.hoverGroup,\n onOpen: () => {\n hoverOpenPendingRef.current = true;\n initialFocusRef.current = 'none';\n setOpen(true);\n },\n onClose: requestHoverClose,\n // Pinned, or focus inside the menu (not on its trigger): the hover close waits.\n canClose: () => openReasonRef.current === 'hover' && !containsFocus(),\n });\n\n // A hover opening stays pending until the menu opens, in a later render too (an app that\n // applies it in a transition). One the app has not applied when the pointer leaves the trigger\n // (a controlled menu whose app kept `open` false) is forgotten then, so a later opening by the\n // app is an ordinary one: it focuses the first item and is pinned.\n const forgetHoverOpening = useEventCallback(() => {\n if (open) return;\n hoverOpenPendingRef.current = false;\n if (initialFocusRef.current === 'none') initialFocusRef.current = 'first';\n });\n const hoverTriggerHandlers = React.useMemo<HoverIntent['triggerHandlers']>(\n () => ({\n ...hoverIntentTriggerHandlers,\n onPointerLeave: (event) => {\n hoverIntentTriggerHandlers.onPointerLeave(event);\n forgetHoverOpening();\n },\n }),\n [hoverIntentTriggerHandlers, forgetHoverOpening],\n );\n\n const openWithFocus = React.useCallback(\n (target: InitialFocus) => {\n // Any opening but hover pins the menu; an open, hover-opened menu is pinned and focused.\n openReasonRef.current = 'other';\n hoverOpenPendingRef.current = false;\n cancelHover();\n const surfaceApi = surfaceApiRef.current;\n if (surfaceApi) {\n if (target === 'last') surfaceApi.focusLast();\n else if (target === 'first') surfaceApi.focusFirst();\n return;\n }\n initialFocusRef.current = target;\n setOpen(true);\n },\n [setOpen, cancelHover],\n );\n const takeInitialFocus = React.useCallback((): InitialFocus => {\n const target = initialFocusRef.current;\n initialFocusRef.current = 'first';\n return target;\n }, []);\n\n // Context gestures on the trigger region: a context gesture opens the menu (focus on its first\n // item) at the pointer or the focused row; a right click outside or an anchor-moving scroll\n // closes it.\n const {\n anchor: contextAnchor,\n fromContext,\n opener: contextOpener,\n triggerHandlers: contextTriggerHandlers,\n surfaceHandlers: contextSurfaceHandlers,\n } = useContextMenuAnchor({\n enabled: contextMode,\n open,\n trigger: triggerElement,\n layerId: surfaceLayerId,\n onOpen: () => openWithFocus('first'),\n onClose: requestClose,\n });\n\n // Focus follows the mouse: a submenu that loses focus to an item the pointer is focusing in an\n // enclosing list becomes a hover-opened submenu and closes through the hover close. A submenu\n // with `openOnHover={false}` has no hover close, so it closes at once, as for a keyboard move.\n const parentListHoverFocusing = parentList?.isHoverFocusing;\n const parentHoverFocusing = parent?.isHoverFocusing;\n const isHoverFocusing = useEventCallback(\n (): boolean => (parentListHoverFocusing?.() ?? false) || (parentHoverFocusing?.() ?? false),\n );\n // A press in progress that can be a context gesture: the right button, a Ctrl+press (the macOS\n // context click) or a touch or pen press (a long press). Recorded at its pointerdown and\n // forgotten at its pointerup, while a context menu is open.\n const contextPressRef = React.useRef(false);\n React.useEffect(() => {\n if (!contextMode || !open || !triggerElement) return undefined;\n const doc = triggerElement.ownerDocument;\n const onPointerDown = (event: PointerEvent) => {\n contextPressRef.current =\n event.button === 2 ||\n (event.button === 0 &&\n (event.ctrlKey || event.pointerType === 'touch' || event.pointerType === 'pen'));\n };\n const onPointerEnd = () => {\n contextPressRef.current = false;\n };\n doc.addEventListener('pointerdown', onPointerDown, true);\n doc.addEventListener('pointerup', onPointerEnd, true);\n doc.addEventListener('pointercancel', onPointerEnd, true);\n return () => {\n doc.removeEventListener('pointerdown', onPointerDown, true);\n doc.removeEventListener('pointerup', onPointerEnd, true);\n doc.removeEventListener('pointercancel', onPointerEnd, true);\n contextPressRef.current = false;\n };\n }, [contextMode, open, triggerElement]);\n\n const dismiss = useEventCallback((reason: DismissReason, event: Event) => {\n // Focus that such a press moves into a context menu's region does not close the menu: a\n // right-button (or macOS Ctrl+) press focuses the row under the pointer before the contextmenu\n // event that moves the menu there (Chromium, Firefox). Any other focus move into the region (a\n // primary press, the app) closes it, as does an outside press and Tab (the surface's handler).\n if (\n reason === 'focus-outside' &&\n contextMode &&\n contextPressRef.current &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n ) {\n return;\n }\n if (reason === 'focus-outside' && isSubmenu && hoverMode && isHoverFocusing()) {\n openReasonRef.current = 'hover';\n startHoverClose(event);\n return;\n }\n requestClose();\n });\n\n const registerOpenSubmenu = React.useCallback((submenu: OpenSubmenu) => {\n const previous = openSubmenuRef.current;\n openSubmenuRef.current = submenu;\n // One open submenu per list: the one open before closes.\n if (previous && previous !== submenu) previous.close();\n return () => {\n if (openSubmenuRef.current === submenu) openSubmenuRef.current = null;\n };\n }, []);\n\n // A submenu registers with its parent while it is open.\n const submenuHandle = React.useMemo<OpenSubmenu>(\n () => ({ close: requestClose, containsFocus, listContainsFocus }),\n [requestClose, containsFocus, listContainsFocus],\n );\n const registerWithParent = parent?.registerOpenSubmenu;\n React.useLayoutEffect(() => {\n if (!open || !registerWithParent) return undefined;\n return registerWithParent(submenuHandle);\n }, [open, registerWithParent, submenuHandle]);\n\n // Item activation and Tab close the whole chain: a submenu of a popup menu hands the close up,\n // and the top menu (the root, or a submenu of a static menu) puts focus on its return target\n // first (focus before close: a Dialog an item opens returns focus there), then closes.\n const parentCloseChain = parent?.popup ? parent.closeChain : null;\n const closeChain = useEventCallback(() => {\n if (parentCloseChain) {\n parentCloseChain();\n return;\n }\n if (!popup) return;\n const target = surfaceApiRef.current?.getReturnFocus() ?? null;\n if (target) {\n const doc = target.ownerDocument;\n const active = doc.activeElement;\n const lost = !active || active === doc.body || active === doc.documentElement;\n if (lost || containsFocus()) target.focus({ preventScroll: true });\n }\n requestClose();\n });\n\n const contextValue = React.useMemo<MenuContextValue>(\n () => ({\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n onTriggerId: setLabelledBy,\n menuId,\n triggerRef,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n openOnContext: contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n }),\n [\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n menuId,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n ],\n );\n\n // Static menu: roving tab stop over the items (the last focused one keeps it).\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n getTabIndex,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n tabStop: 'last-focused',\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rovingRef, staticMenuRef);\n\n // Disabled items never hold the tab stop, so with no enabled item the static menu itself does:\n // Tab still reaches it and a screen reader announces it. Checked whenever the roving hook's tab\n // stop changes (`getTabIndex` changes with it: an item enabled, disabled, added or removed), and\n // after it is stamped (this effect runs after the hook's).\n const [menuIsTabStop, setMenuIsTabStop] = React.useState(false);\n React.useLayoutEffect(() => {\n const menu = staticMenuRef.current;\n if (popup || !menu) return;\n const noItemTabStop = getFirstTabbable(menu) === null;\n if (noItemTabStop === menuIsTabStop) return;\n setMenuIsTabStop(noItemTabStop);\n // An item became enabled while the menu itself had focus: focus moves on to it, rather than\n // staying on an element that is no longer focusable.\n if (!noItemTabStop && menu.ownerDocument.activeElement === menu) focusFirst();\n }, [popup, menuIsTabStop, focusFirst, getTabIndex]);\n\n // The static menu is a menu list: its items close nothing when activated, and the item under\n // the mouse takes focus while focus is inside the menu tree.\n const registerCheckable = useCheckableRegistry();\n const {\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n onPointerMove: listPointerMove,\n } = useMenuListPointer(contextValue);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu: contextValue,\n isStatic: true,\n portalDepth,\n closeFromItem: noop,\n registerCheckable,\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n }),\n [contextValue, portalDepth, registerCheckable, hoverGroup, isListHoverFocusing],\n );\n\n if (popup) {\n return <MenuContext.Provider value={contextValue}>{children}</MenuContext.Provider>;\n }\n\n return (\n <MenuContext.Provider value={contextValue}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n ref={mergedRef}\n tabIndex={rest.tabIndex ?? (menuIsTabStop ? 0 : undefined)}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, rovingKeyDown)}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n className={cn(menuClassNames.root, menuSurfaceClasses, focusRing, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </MenuContext.Provider>\n );\n};\nMenuRoot.displayName = 'Menu';\n"],"mappings":"w+BAqIA,IAAMuD,OAAa,CAAC,EAGdC,GAAiB,IAOvB,SAAgBC,GAAc,EAAoC,CAChE,OAAOzD,EAAAA,gBAAgB0D,CAAQ,CAAC,CAAC,MAAM,CAAE,UACvCzD,EAAAA,gBAAgB0D,EAAMzD,EAAAA,YAAaC,GAAAA,WAAW,CAChD,CACF,CAGA,SAASyD,GAAU,EAAyB,CAC1C,IAAMC,EAASC,EAAM,IAAK,GAAS,KAAKC,EAAK,GAAG,EAChD,OAAOF,EAAO,OAAS,EACnB,GAAGA,EAAO,MA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"version":3,"file":"Menu.root.cjs","names":["flattenChildren","isElementOfType","MenuTrigger","MenuPopover","useMenuListContext","React","PortalDepthContext","useControllable","useIsClient","useId","useCheckedValues","useEventCallback","withCheckedValuesListener","getLayerTreeElements","useHoverIntent","useContextMenuAnchor","useRovingTabIndex","MENU_ITEM_SELECTOR","useMergedRefs","getFirstTabbable","useCheckableRegistry","useMenuListPointer","MenuContext","MenuListContext","composeEventHandlers","withTypeaheadText","cn","menuClassNames","menuSurfaceClasses","focusRing","require_runtime","require_cn","require_children","require_dev","require_composeEventHandlers","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_focus","require_useRovingTabIndex","require_useMergedRefs","require_useIsClient","require_layers","require_Portal","require_styles","require_useCheckedValues","require_useHoverIntent","require_Menu_context","require_Menu_shared","require_Menu_popover","require_useContextMenuAnchor","require_Menu_trigger","react","react_jsx_runtime","noop","HOVER_DELAY_MS","hasPopupParts","children","node","listProps","quoted","names","name","MenuRoot","openProp","persistOnItemClickProp","openOnHoverProp","openDelayProp","closeDelayProp","openOnContextProp","rest","list","portalDepth","parentList","parent","isSubmenu","openState","setOpen","openControlled","defaultOpen","onOpenChange","isClient","parentOpen","open","popup","triggerId","menuId","labelledBy","setLabelledBy","triggerRef","triggerElement","setTriggerElementState","setTriggerElement","element","surfaceApiRef","surfaceElement","setSurfaceElement","surfaceLayerId","setSurfaceLayerId","registerSurface","api","ownChecked","checkedValues","defaultCheckedValues","onCheckedValuesChange","parentChecked","ownsCheckedState","listens","listener","sharedChecked","checked","persistOnItemClick","openDelay","closeDelay","contextMode","hoverMode","ignoredProps","className","onKeyDown","onKeyDownCapture","onFocus","onPointerMove","value","ref","ignoredMessage","staticPopupProps","hoverAndContext","verb","pronoun","staticMenuRef","openSubmenuRef","containsFocus","surfaceApi","active","el","listContainsFocus","hoverCloseRef","isHoverClose","closeMenu","byHover","requestClose","requestHoverClose","openReasonRef","hoverOpenPendingRef","initialFocusRef","isHoverOpen","hoverIntentTriggerHandlers","hoverSurfaceHandlers","cancelHover","startHoverClose","forgetHoverOpening","hoverTriggerHandlers","event","openWithFocus","target","takeInitialFocus","contextAnchor","contextOpener","contextTriggerHandlers","contextSurfaceHandlers","parentListHoverFocusing","parentHoverFocusing","isHoverFocusing","contextPressRef","doc","onPointerDown","onPointerEnd","dismiss","reason","registerOpenSubmenu","previous","submenu","submenuHandle","registerWithParent","parentCloseChain","closeChain","contextValue","fromContext","rovingRef","rovingKeyDown","rovingKeyDownCapture","rovingFocus","mergedRef","menuIsTabStop","setMenuIsTabStop","menu","noItemTabStop","focusFirst","getTabIndex","registerCheckable","isListHoverFocusing","listPointerMove","listContext","hoverGroup"],"sources":["../../../src/components/navigation/Menu.root.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { menuClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { getFirstTabbable } from '../../lib/focus';\nimport { getLayerTreeElements, type DismissReason } from '../../lib/layers';\nimport { focusRing } from '../../lib/styles';\nimport type { CheckedValues, CheckedValuesChangeHandler } from '../../lib/types';\nimport { useCheckedValues, withCheckedValuesListener } from '../../hooks/useCheckedValues';\nimport { useContextMenuAnchor } from '../../hooks/useContextMenuAnchor';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useHoverIntent, type HoverIntent } from '../../hooks/useHoverIntent';\nimport { useId } from '../../hooks/useId';\nimport { useIsClient } from '../../hooks/useIsClient';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useRovingTabIndex } from '../../hooks/useRovingTabIndex';\nimport { PortalDepthContext } from '../portal/Portal';\nimport {\n MenuContext,\n MenuListContext,\n useCheckableRegistry,\n useMenuListContext,\n} from './Menu.context';\nimport type {\n InitialFocus,\n MenuContextValue,\n MenuListContextValue,\n MenuSurfaceApi,\n OpenSubmenu,\n} from './Menu.context';\nimport { MENU_ITEM_SELECTOR, menuSurfaceClasses, withTypeaheadText } from './Menu.shared';\nimport { MenuPopover, useMenuListPointer } from './Menu.popover';\nimport { MenuTrigger } from './Menu.trigger';\n\n/** Properties for the Menu component. */\nexport interface MenuProps extends React.HTMLAttributes<HTMLDivElement> {\n /**\n * Menu items and dividers (static menu), or a `Menu.Trigger` and a `Menu.Popover` (popup menu).\n */\n children: React.ReactNode;\n /**\n * Controlled open state of a popup menu (`Menu.Trigger` + `Menu.Popover`). Passing it, even\n * `false` (like passing `defaultOpen` or `onOpenChange`), makes Menu a popup menu that renders no\n * element of its own: use it only with `Menu.Trigger`/`Menu.Popover`. Items outside\n * `Menu.Popover` then have no `role=\"menu\"` parent (development warning). Leave all three out\n * for a static menu. The popup renders only in the browser: an open menu is closed in the\n * server HTML and opens once it has hydrated.\n */\n open?: boolean;\n /**\n * Initial open state of an uncontrolled popup menu; a popup menu starts closed without it.\n * Passing it, even `false`, makes Menu a popup menu (see `open`), so for a Menu without\n * `Menu.Trigger`/`Menu.Popover` children, leaving it out is not the same as `false`. The popup\n * renders only in the browser: a menu open by default is closed in the server HTML and opens\n * once it has hydrated.\n */\n defaultOpen?: boolean;\n /**\n * Called with the next open state when the popup menu opens or closes (only on change). Passing\n * it makes Menu a popup menu (see `open`).\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Checked items of the menu's checkbox, radio and switch items, per group `name` (controlled).\n * A submenu without its own `checkedValues` or `defaultCheckedValues` shares its parent menu's\n * state. Works for static and popup menus; unlike `open`, it does not make Menu a popup menu.\n */\n checkedValues?: CheckedValues;\n /** Initial checked items for uncontrolled usage (gives a submenu its own state). @default {} */\n defaultCheckedValues?: CheckedValues;\n /**\n * Called when an item changes the checked items (only on change): the new checked values of every\n * group first, then `details` with the group's `name`, its `checkedItems` and the `event` (Fluent's\n * `onCheckedValueChange(event, { name, checkedItems })`). WaveUI always passes `details`; it is\n * typed optional until 1.0. On a submenu that shares its parent's state it only listens: it is\n * called after the parent's callback, for changes made in this submenu.\n */\n onCheckedValuesChange?: CheckedValuesChangeHandler;\n /**\n * Keep a popup menu open after any of its items is activated; an item's own `persistOnClick`\n * wins. A submenu inherits it unless it sets it.\n * @default false\n */\n persistOnItemClick?: boolean;\n /**\n * Open the popup menu when a mouse pointer rests on its trigger, and close it once the pointer\n * has been off the trigger and the menu for `closeDelay` while focus is not inside the menu. A\n * menu opened by hover does not take focus; a click (or Enter, Space, ArrowDown) on its trigger\n * keeps it open and moves focus into it, as opening it that way does. After Escape or an\n * outside press it does not reopen until the pointer has left the trigger. Touch and pen never\n * open it by hover, and an `aria-disabled` trigger never opens. A triangle between the trigger\n * and the menu keeps it open while the pointer moves diagonally into it. Ignored with\n * `openOnContext` (development warning) and on a static menu (development warning).\n * @default false (true for a submenu)\n */\n openOnHover?: boolean;\n /**\n * Milliseconds a hovering mouse pointer rests on the trigger before the menu opens (mouse hover\n * only). A submenu inherits its parent's, also from a static menu. @default 250\n */\n openDelay?: number;\n /**\n * Milliseconds before a hover-opened menu closes once the mouse pointer has left it and its\n * trigger (mouse hover only). A submenu inherits its parent's, also from a static menu.\n * @default 250\n */\n closeDelay?: number;\n /**\n * Make `Menu.Trigger` a context-menu region: a right click (a Ctrl+click on macOS, a long press\n * where the browser reports one) opens the menu at the pointer, and Shift+F10 or the\n * ContextMenu key opens it at the focused element inside the region, instead of a click; a\n * second gesture while it is open moves it there. Focus returns to the element that had it.\n * The browser's context menu is suppressed there and inside the menu, 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 region or the row of the gesture (the one under the pointer, or the focused one)\n * closes it. The trigger gets no `aria-haspopup`/`aria-expanded` (it is not a menu button; with\n * a render-prop child, do not spread them): name the menu with `aria-label` on `Menu.Popover`,\n * and consider `aria-keyshortcuts=\"Shift+F10\"` on the region. iOS Safari reports no long press.\n * Ignored on a submenu; `openOnHover` is ignored with it.\n * @default false\n */\n openOnContext?: boolean;\n /**\n * Ref to the static menu element (`role=\"menu\"`). A popup menu renders no root element, so it\n * ignores `ref`, `className` and other DOM props (development warning): pass them to\n * `Menu.Popover`.\n */\n ref?: React.Ref<HTMLDivElement>;\n}\n\nconst noop = () => {};\n\n/** Default of `openDelay` and `closeDelay` (InfoLabel's hover delays). */\nconst HOVER_DELAY_MS = 250;\n\n/**\n * Whether the children contain a `Menu.Trigger` or `Menu.Popover`: direct children and the\n * children of Fragments only (other elements and components are not searched). Parts written in\n * a Server Component (lazy client references) are recognised too.\n */\nexport function hasPopupParts(children: React.ReactNode): boolean {\n return flattenChildren(children).some(({ node }) =>\n isElementOfType(node, MenuTrigger, MenuPopover),\n );\n}\n\n/** Joins prop names for a message: `a`, `` `a` and `b` ``. */\nfunction listProps(names: string[]): string {\n const quoted = names.map((name) => `\\`${name}\\``);\n return quoted.length > 1\n ? `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`\n : quoted.join('');\n}\n\n// The root of the `Menu` compound. Its component JSDoc is on the `Menu` export (Menu.tsx) only\n// (C-DOCS): a docblock here would replace it as the Storybook description.\nexport const MenuRoot = ({\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n checkedValues,\n defaultCheckedValues,\n onCheckedValuesChange,\n persistOnItemClick: persistOnItemClickProp,\n openOnHover: openOnHoverProp,\n openDelay: openDelayProp,\n closeDelay: closeDelayProp,\n openOnContext: openOnContextProp,\n className,\n onKeyDown,\n onKeyDownCapture,\n onFocus,\n onPointerMove,\n ref,\n ...rest\n}: MenuProps) => {\n // A Menu rendered in a menu list with no portal between them is a submenu of that list's menu.\n // A Menu inside a Popover or Dialog opened from an item sits one portal deeper: a root menu.\n const list = useMenuListContext();\n const portalDepth = React.useContext(PortalDepthContext);\n const parentList = list !== null && list.portalDepth === portalDepth ? list : null;\n const parent = parentList?.menu ?? null;\n const isSubmenu = parent !== null;\n\n const [openState, setOpen, openControlled] = useControllable(\n openProp,\n defaultOpen ?? false,\n onOpenChange,\n );\n // The popup menu lives in a portal, which renders only in the browser: until then (the server\n // HTML, hydration) the menu reports itself closed, so the trigger's aria-expanded and\n // aria-controls never describe a menu that is not there. A submenu of a popup menu is open only\n // while that menu is: a parent that closes (through its controlled prop, or while it runs an\n // exit motion) takes the submenu's surface, layer and focus restore along in the same commit.\n const isClient = useIsClient();\n const parentOpen = parent === null || !parent.popup || parent.open;\n const open = openState && isClient && parentOpen;\n // A parent that closed without closing this submenu (its controlled `open` prop): an\n // uncontrolled submenu closes too, so it does not reopen with the parent. A controlled\n // submenu's state is the app's.\n React.useLayoutEffect(() => {\n if (parentOpen || !openState || openControlled) return;\n setOpen(false);\n }, [parentOpen, openState, openControlled, setOpen]);\n\n const popup =\n openProp !== undefined ||\n defaultOpen !== undefined ||\n onOpenChange !== undefined ||\n hasPopupParts(children);\n\n const triggerId = useId('wave-menu-trigger');\n const menuId = useId('wave-menu');\n const [labelledBy, setLabelledBy] = React.useState(triggerId);\n const triggerRef = React.useRef<HTMLElement | null>(null);\n const [triggerElement, setTriggerElementState] = React.useState<HTMLElement | null>(null);\n const setTriggerElement = React.useCallback((element: HTMLElement | null) => {\n triggerRef.current = element;\n setTriggerElementState(element);\n }, []);\n\n // The open surface: its API in a ref (read in events), its element and layer in state (the\n // hover and context-menu hooks observe them).\n const surfaceApiRef = React.useRef<MenuSurfaceApi | null>(null);\n const [surfaceElement, setSurfaceElement] = React.useState<HTMLElement | null>(null);\n const [surfaceLayerId, setSurfaceLayerId] = React.useState('');\n const registerSurface = React.useCallback((api: MenuSurfaceApi | null) => {\n surfaceApiRef.current = api;\n setSurfaceElement(api?.surface ?? null);\n // Kept after the surface closes: a context gesture records its opener against the last layer.\n if (api) setSurfaceLayerId(api.layerId);\n }, []);\n\n // Checked values: one state per menu tree. A Menu owns its state when it sets `checkedValues` or\n // `defaultCheckedValues`, or has no parent; otherwise it uses its parent's, and its own\n // `onCheckedValuesChange` only listens to the changes its items make (called after the owner's).\n const ownChecked = useCheckedValues(checkedValues, defaultCheckedValues, onCheckedValuesChange);\n const parentChecked = parent?.checked ?? null;\n const ownsCheckedState =\n parentChecked === null || checkedValues !== undefined || defaultCheckedValues !== undefined;\n const listens = onCheckedValuesChange !== undefined;\n const listener = useEventCallback(onCheckedValuesChange);\n const sharedChecked = React.useMemo(\n () =>\n parentChecked && listens ? withCheckedValuesListener(parentChecked, listener) : parentChecked,\n [parentChecked, listens, listener],\n );\n const checked = ownsCheckedState || sharedChecked === null ? ownChecked : sharedChecked;\n const persistOnItemClick = persistOnItemClickProp ?? parent?.persistOnItemClick ?? false;\n const openDelay = openDelayProp ?? parent?.openDelay ?? HOVER_DELAY_MS;\n const closeDelay = closeDelayProp ?? parent?.closeDelay ?? HOVER_DELAY_MS;\n\n // Context mode applies to a root popup menu; hover to a popup menu outside context mode.\n const contextMode = popup && !isSubmenu && openOnContextProp === true;\n const hoverMode = popup && !contextMode && (openOnHoverProp ?? isSubmenu);\n\n // C-DEV: a popup menu renders no root element, so root DOM props and the ref go nowhere.\n const ignoredProps: string[] = [];\n if (popup) {\n if (className !== undefined) ignoredProps.push('className');\n if (onKeyDown !== undefined) ignoredProps.push('onKeyDown');\n if (onKeyDownCapture !== undefined) ignoredProps.push('onKeyDownCapture');\n if (onFocus !== undefined) ignoredProps.push('onFocus');\n if (onPointerMove !== undefined) ignoredProps.push('onPointerMove');\n for (const [name, value] of Object.entries(rest)) {\n if (value !== undefined) ignoredProps.push(name);\n }\n if (ref != null) ignoredProps.push('ref');\n }\n const ignoredMessage =\n ignoredProps.length === 0\n ? ''\n : `Menu: a popup menu (Menu.Trigger + Menu.Popover) renders no element of its own, so ${ignoredProps\n .map((name) => `\\`${name}\\``)\n .join(', ')} on Menu ${ignoredProps.length === 1 ? 'is' : 'are'} ignored. Pass ${\n ignoredProps.length === 1 ? 'it' : 'them'\n } to Menu.Popover (the menu surface) or to the trigger's child instead.`;\n React.useEffect(() => {\n if (ignoredMessage) warnOnce('Menu:popup-ignored-props', ignoredMessage);\n }, [ignoredMessage]);\n\n // C-DEV: the popup openings do nothing on a static menu; hover gives way to context gestures.\n const staticPopupProps = popup\n ? ''\n : listProps(\n [openOnHoverProp ? 'openOnHover' : null, openOnContextProp ? 'openOnContext' : null].filter(\n (name): name is string => name !== null,\n ),\n );\n const hoverAndContext = contextMode && openOnHoverProp === true;\n React.useEffect(() => {\n if (!staticPopupProps) return;\n const [verb, pronoun] = staticPopupProps.includes(' and ') ? ['are', 'they'] : ['is', 'it'];\n warnOnce(\n 'Menu:static-popup-props',\n `Menu: ${staticPopupProps} ${verb} ignored on a static menu: ${pronoun} apply to a popup menu (Menu.Trigger + Menu.Popover). A static menu passes openDelay and closeDelay on to its submenus.`,\n );\n }, [staticPopupProps]);\n React.useEffect(() => {\n if (!hoverAndContext) return;\n warnOnce(\n 'Menu:hover-and-context',\n 'Menu: openOnHover is ignored with openOnContext: a context menu opens only from a context gesture (a right click, Shift+F10 or the ContextMenu key).',\n );\n }, [hoverAndContext]);\n\n const staticMenuRef = React.useRef<HTMLDivElement | null>(null);\n\n // The open submenu of this menu's list (one at a time) and what focus inside means for the chain.\n const openSubmenuRef = React.useRef<OpenSubmenu | null>(null);\n const containsFocus = useEventCallback((): boolean => {\n const surfaceApi = surfaceApiRef.current;\n const element = surfaceApi?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (!element || !active) return false;\n if (element.contains(active)) return true;\n // A popup menu's layer tree holds its submenus and the portals opened from its items; its own\n // elements (the trigger) do not count.\n if (surfaceApi) {\n return getLayerTreeElements(surfaceApi.layerId, { includeOwnElements: false }).some((el) =>\n el.contains(active),\n );\n }\n return openSubmenuRef.current?.containsFocus() ?? false;\n });\n // Focus in a list of the chain: this menu's list, else (recursively) its open submenu's. A\n // portal opened from an item does not count, so hover never takes focus from it.\n const listContainsFocus = useEventCallback((): boolean => {\n const element = surfaceApiRef.current?.surface ?? staticMenuRef.current;\n const active = element?.ownerDocument.activeElement;\n if (element && active && element.contains(active)) return true;\n return openSubmenuRef.current?.listContainsFocus() ?? false;\n });\n\n // Every close of this menu closes its open submenu first, innermost first, through the\n // submenu's own state: each controlled submenu hears onOpenChange(false) once. A close asked for\n // by the hover intent is marked (before the request, in case the app applies it synchronously),\n // so the surface's focus restore moves no focus; every other close request, and the next\n // opening, clears the mark. A submenu closed along with it is taken along by the restore itself.\n const hoverCloseRef = React.useRef(false);\n const isHoverClose = React.useCallback(() => hoverCloseRef.current, []);\n const closeMenu = (byHover: boolean) => {\n hoverCloseRef.current = byHover;\n openSubmenuRef.current?.close();\n setOpen(false);\n };\n const requestClose = useEventCallback(() => closeMenu(false));\n const requestHoverClose = useEventCallback(() => closeMenu(true));\n\n // Why the open menu is open: a hover opening stays unpinned (the hover close applies) until the\n // trigger is activated; every other opening (click, keys, context, a controlled `open`) pins it.\n const openReasonRef = React.useRef<'hover' | 'other'>('other');\n const hoverOpenPendingRef = React.useRef(false);\n const initialFocusRef = React.useRef<InitialFocus>('first');\n React.useLayoutEffect(() => {\n if (open) {\n openReasonRef.current = hoverOpenPendingRef.current ? 'hover' : 'other';\n hoverCloseRef.current = false;\n }\n hoverOpenPendingRef.current = false;\n }, [open]);\n const isHoverOpen = React.useCallback(() => openReasonRef.current === 'hover', []);\n\n const {\n triggerHandlers: hoverIntentTriggerHandlers,\n surfaceHandlers: hoverSurfaceHandlers,\n cancel: cancelHover,\n startClose: startHoverClose,\n } = useHoverIntent({\n enabled: hoverMode,\n open,\n openDelay,\n closeDelay,\n trigger: triggerElement,\n surface: surfaceElement,\n group: parentList?.hoverGroup,\n onOpen: () => {\n hoverOpenPendingRef.current = true;\n initialFocusRef.current = 'none';\n setOpen(true);\n },\n onClose: requestHoverClose,\n // Pinned, or focus inside the menu (not on its trigger): the hover close waits.\n canClose: () => openReasonRef.current === 'hover' && !containsFocus(),\n });\n\n // A hover opening stays pending until the menu opens, in a later render too (an app that\n // applies it in a transition). One the app has not applied when the pointer leaves the trigger\n // (a controlled menu whose app kept `open` false) is forgotten then, so a later opening by the\n // app is an ordinary one: it focuses the first item and is pinned.\n const forgetHoverOpening = useEventCallback(() => {\n if (open) return;\n hoverOpenPendingRef.current = false;\n if (initialFocusRef.current === 'none') initialFocusRef.current = 'first';\n });\n const hoverTriggerHandlers = React.useMemo<HoverIntent['triggerHandlers']>(\n () => ({\n ...hoverIntentTriggerHandlers,\n onPointerLeave: (event) => {\n hoverIntentTriggerHandlers.onPointerLeave(event);\n forgetHoverOpening();\n },\n }),\n [hoverIntentTriggerHandlers, forgetHoverOpening],\n );\n\n const openWithFocus = React.useCallback(\n (target: InitialFocus) => {\n // Any opening but hover pins the menu; an open, hover-opened menu is pinned and focused.\n openReasonRef.current = 'other';\n hoverOpenPendingRef.current = false;\n cancelHover();\n const surfaceApi = surfaceApiRef.current;\n if (surfaceApi) {\n if (target === 'last') surfaceApi.focusLast();\n else if (target === 'first') surfaceApi.focusFirst();\n return;\n }\n initialFocusRef.current = target;\n setOpen(true);\n },\n [setOpen, cancelHover],\n );\n const takeInitialFocus = React.useCallback((): InitialFocus => {\n const target = initialFocusRef.current;\n initialFocusRef.current = 'first';\n return target;\n }, []);\n\n // Context gestures on the trigger region: a context gesture opens the menu (focus on its first\n // item) at the pointer or the focused row; a right click outside or an anchor-moving scroll\n // closes it.\n const {\n anchor: contextAnchor,\n fromContext,\n opener: contextOpener,\n triggerHandlers: contextTriggerHandlers,\n surfaceHandlers: contextSurfaceHandlers,\n } = useContextMenuAnchor({\n enabled: contextMode,\n open,\n trigger: triggerElement,\n layerId: surfaceLayerId,\n onOpen: () => openWithFocus('first'),\n onClose: requestClose,\n });\n\n // Focus follows the mouse: a submenu that loses focus to an item the pointer is focusing in an\n // enclosing list becomes a hover-opened submenu and closes through the hover close. A submenu\n // with `openOnHover={false}` has no hover close, so it closes at once, as for a keyboard move.\n const parentListHoverFocusing = parentList?.isHoverFocusing;\n const parentHoverFocusing = parent?.isHoverFocusing;\n const isHoverFocusing = useEventCallback(\n (): boolean => (parentListHoverFocusing?.() ?? false) || (parentHoverFocusing?.() ?? false),\n );\n // A press in progress that can be a context gesture: the right button, a Ctrl+press (the macOS\n // context click) or a touch or pen press (a long press). Recorded at its pointerdown and\n // forgotten at its pointerup, while a context menu is open.\n const contextPressRef = React.useRef(false);\n React.useEffect(() => {\n if (!contextMode || !open || !triggerElement) return undefined;\n const doc = triggerElement.ownerDocument;\n const onPointerDown = (event: PointerEvent) => {\n contextPressRef.current =\n event.button === 2 ||\n (event.button === 0 &&\n (event.ctrlKey || event.pointerType === 'touch' || event.pointerType === 'pen'));\n };\n const onPointerEnd = () => {\n contextPressRef.current = false;\n };\n doc.addEventListener('pointerdown', onPointerDown, true);\n doc.addEventListener('pointerup', onPointerEnd, true);\n doc.addEventListener('pointercancel', onPointerEnd, true);\n return () => {\n doc.removeEventListener('pointerdown', onPointerDown, true);\n doc.removeEventListener('pointerup', onPointerEnd, true);\n doc.removeEventListener('pointercancel', onPointerEnd, true);\n contextPressRef.current = false;\n };\n }, [contextMode, open, triggerElement]);\n\n const dismiss = useEventCallback((reason: DismissReason, event: Event) => {\n // Focus that such a press moves into a context menu's region does not close the menu: a\n // right-button (or macOS Ctrl+) press focuses the row under the pointer before the contextmenu\n // event that moves the menu there (Chromium, Firefox). Any other focus move into the region (a\n // primary press, the app) closes it, as does an outside press and Tab (the surface's handler).\n if (\n reason === 'focus-outside' &&\n contextMode &&\n contextPressRef.current &&\n event.target instanceof Node &&\n triggerRef.current?.contains(event.target)\n ) {\n return;\n }\n if (reason === 'focus-outside' && isSubmenu && hoverMode && isHoverFocusing()) {\n openReasonRef.current = 'hover';\n startHoverClose(event);\n return;\n }\n requestClose();\n });\n\n const registerOpenSubmenu = React.useCallback((submenu: OpenSubmenu) => {\n const previous = openSubmenuRef.current;\n openSubmenuRef.current = submenu;\n // One open submenu per list: the one open before closes.\n if (previous && previous !== submenu) previous.close();\n return () => {\n if (openSubmenuRef.current === submenu) openSubmenuRef.current = null;\n };\n }, []);\n\n // A submenu registers with its parent while it is open.\n const submenuHandle = React.useMemo<OpenSubmenu>(\n () => ({ close: requestClose, containsFocus, listContainsFocus }),\n [requestClose, containsFocus, listContainsFocus],\n );\n const registerWithParent = parent?.registerOpenSubmenu;\n React.useLayoutEffect(() => {\n if (!open || !registerWithParent) return undefined;\n return registerWithParent(submenuHandle);\n }, [open, registerWithParent, submenuHandle]);\n\n // Item activation and Tab close the whole chain: a submenu of a popup menu hands the close up,\n // and the top menu (the root, or a submenu of a static menu) puts focus on its return target\n // first (focus before close: a Dialog an item opens returns focus there), then closes.\n const parentCloseChain = parent?.popup ? parent.closeChain : null;\n const closeChain = useEventCallback(() => {\n if (parentCloseChain) {\n parentCloseChain();\n return;\n }\n if (!popup) return;\n const target = surfaceApiRef.current?.getReturnFocus() ?? null;\n if (target) {\n const doc = target.ownerDocument;\n const active = doc.activeElement;\n const lost = !active || active === doc.body || active === doc.documentElement;\n if (lost || containsFocus()) target.focus({ preventScroll: true });\n }\n requestClose();\n });\n\n const contextValue = React.useMemo<MenuContextValue>(\n () => ({\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n onTriggerId: setLabelledBy,\n menuId,\n triggerRef,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n openOnContext: contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n }),\n [\n popup,\n open,\n setOpen,\n openWithFocus,\n takeInitialFocus,\n registerSurface,\n triggerId,\n labelledBy,\n menuId,\n triggerElement,\n setTriggerElement,\n parent,\n checked,\n persistOnItemClick,\n isSubmenu,\n requestClose,\n closeChain,\n registerOpenSubmenu,\n listContainsFocus,\n openDelay,\n closeDelay,\n dismiss,\n isHoverFocusing,\n isHoverOpen,\n isHoverClose,\n hoverTriggerHandlers,\n hoverSurfaceHandlers,\n contextMode,\n contextTriggerHandlers,\n contextSurfaceHandlers,\n contextAnchor,\n fromContext,\n contextOpener,\n ],\n );\n\n // Static menu: roving tab stop over the items (the last focused one keeps it).\n const {\n containerProps: { ref: rovingRef },\n handleKeyDown: rovingKeyDown,\n handleKeyDownCapture: rovingKeyDownCapture,\n handleFocus: rovingFocus,\n focusFirst,\n getTabIndex,\n } = useRovingTabIndex({\n orientation: 'vertical',\n loop: true,\n typeahead: true,\n tabStop: 'last-focused',\n manageTabIndex: true,\n itemSelector: MENU_ITEM_SELECTOR,\n });\n const mergedRef = useMergedRefs<HTMLDivElement>(ref, rovingRef, staticMenuRef);\n\n // Disabled items never hold the tab stop, so with no enabled item the static menu itself does:\n // Tab still reaches it and a screen reader announces it. Checked whenever the roving hook's tab\n // stop changes (`getTabIndex` changes with it: an item enabled, disabled, added or removed), and\n // after it is stamped (this effect runs after the hook's).\n const [menuIsTabStop, setMenuIsTabStop] = React.useState(false);\n React.useLayoutEffect(() => {\n const menu = staticMenuRef.current;\n if (popup || !menu) return;\n const noItemTabStop = getFirstTabbable(menu) === null;\n if (noItemTabStop === menuIsTabStop) return;\n setMenuIsTabStop(noItemTabStop);\n // An item became enabled while the menu itself had focus: focus moves on to it, rather than\n // staying on an element that is no longer focusable.\n if (!noItemTabStop && menu.ownerDocument.activeElement === menu) focusFirst();\n }, [popup, menuIsTabStop, focusFirst, getTabIndex]);\n\n // The static menu is a menu list: its items close nothing when activated, and the item under\n // the mouse takes focus while focus is inside the menu tree.\n const registerCheckable = useCheckableRegistry();\n const {\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n onPointerMove: listPointerMove,\n } = useMenuListPointer(contextValue);\n const listContext = React.useMemo<MenuListContextValue>(\n () => ({\n menu: contextValue,\n isStatic: true,\n portalDepth,\n closeFromItem: noop,\n registerCheckable,\n hoverGroup,\n isHoverFocusing: isListHoverFocusing,\n }),\n [contextValue, portalDepth, registerCheckable, hoverGroup, isListHoverFocusing],\n );\n\n if (popup) {\n return <MenuContext.Provider value={contextValue}>{children}</MenuContext.Provider>;\n }\n\n return (\n <MenuContext.Provider value={contextValue}>\n <MenuListContext.Provider value={listContext}>\n <div\n role=\"menu\"\n {...rest}\n ref={mergedRef}\n tabIndex={rest.tabIndex ?? (menuIsTabStop ? 0 : undefined)}\n data-roving-container=\"\"\n onKeyDown={composeEventHandlers(onKeyDown, rovingKeyDown)}\n onKeyDownCapture={withTypeaheadText(\n composeEventHandlers(onKeyDownCapture, rovingKeyDownCapture),\n )}\n onFocus={composeEventHandlers(onFocus, rovingFocus, { checkDefaultPrevented: false })}\n onPointerMove={composeEventHandlers(onPointerMove, listPointerMove)}\n className={cn(menuClassNames.root, menuSurfaceClasses, focusRing, className)}\n >\n {children}\n </div>\n </MenuListContext.Provider>\n </MenuContext.Provider>\n );\n};\nMenuRoot.displayName = 'Menu';\n"],"mappings":"w+BAqIA,IAAMuD,OAAa,CAAC,EAGdC,GAAiB,IAOvB,SAAgBC,GAAc,EAAoC,CAChE,OAAOzD,EAAAA,gBAAgB0D,CAAQ,CAAC,CAAC,MAAM,CAAE,UACvCzD,EAAAA,gBAAgB0D,EAAMzD,EAAAA,YAAaC,GAAAA,WAAW,CAChD,CACF,CAGA,SAASyD,GAAU,EAAyB,CAC1C,IAAMC,EAASC,EAAM,IAAK,GAAS,KAAKC,EAAK,GAAG,EAChD,OAAOF,EAAO,OAAS,EACnB,GAAGA,EAAO,MAAM,EAAG,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,OAAOA,EAAOA,EAAO,OAAS,KAChEA,EAAO,KAAK,EAAE,CACpB,CAIA,IAAaG,GAAY,CACvB,WACA,KAAMC,EACN,cACA,eACA,iBACA,wBACA,wBACA,mBAAoBC,GACpB,YAAaC,EACb,UAAWC,GACX,WAAYC,GACZ,cAAeC,GACf,aACA,aACA,oBACA,WACA,iBACA,OACA,GAAGC,KACY,CAGf,IAAMC,EAAOpE,EAAAA,mBAAmB,EAC1BqE,EAAcpE,EA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EAAM,aAClB,CACL,QACA,OACA,UACA,gBACA,oBACA,mBACA,YACA,cACA,YAAaoF,GACb,SACA,aACA,iBACA,qBACA,SACA,WACA,sBACA,YACA,eACA,cACA,uBACA,oBACA,YACA,aACA,WACA,kBACA,eACA,gBACA,wBACA,wBACA,cAAe0B,EACf,0BACA,0BACA,iBACA,eACA,gBACF,GACA,CACE9B,EACAD,EACAN,EACA4E,EACAE,GACAxD,GACAd,EACAE,GACAD,EACAI,EACAE,GACAlB,EACAoC,GACAC,GACApC,EACAiE,EACAmC,GACAN,GACAlC,EACAvB,EACAC,EACAsD,GACAL,EACAjB,GACAR,GACAc,GACAJ,GACAjC,EACA4C,GACAC,GACAH,GACAqB,GACApB,EACF,CACF,EAGM,CACJ,eAAgB,CAAE,IAAKqB,IACvB,cAAeC,GACf,qBAAsBC,GACtB,YAAaC,GACb,cACA,gBACEtK,GAAAA,kBAAkB,CACpB,YAAa,WACb,KAAM,GACN,UAAW,GACX,QAAS,eACT,eAAgB,GAChB,aAAcC,EAAAA,kBAChB,CAAC,EACKsK,GAAYrK,GAAAA,cAA8B0G,GAAKuD,GAAWjD,CAAa,EAMvE,CAACsD,EAAeC,IAAoBpL,EAAM,SAAS,EAAK,EAC9DgD,EAAM,oBAAsB,CAC1B,IAAMqI,EAAOxD,EAAc,QAC3B,GAAI7C,GAAS,CAACqG,EAAM,OACpB,IAAMC,EAAgBxK,GAAAA,iBAAiBuK,CAAI,IAAM,KAC7CC,IAAkBH,IACtBC,GAAiBE,CAAa,EAG1B,CAACA,GAAiBD,EAAK,cAAc,gBAAkBA,GAAME,GAAW,EAC9E,EAAG,CAACvG,EAAOmG,EAAeI,GAAYC,EAAW,CAAC,EAIlD,IAAMC,GAAoB1K,EAAAA,qBAAqB,EACzC,CACJ,cACA,gBAAiB2K,GACjB,cAAeC,IACb3K,GAAAA,mBAAmB4J,CAAY,EAC7BgB,GAAc5L,EAAM,aACjB,CACL,KAAM4K,EACN,SAAU,GACV,cACA,cAAe1H,GACf,qBACA,cACA,gBAAiBwI,EACnB,GACA,CAACd,EAAcxG,EAAaqH,GAAmBI,GAAYH,EAAmB,CAChF,EAMA,OAJI1G,GACK,EAAA/B,EAAA,IAAA,CAAChC,EAAAA,YAAY,SAAb,CAAsB,MAAO2J,EAAe,UAA+B,CAAA,GAIlF,EAAA3H,EAAA,IAAA,CAAChC,EAAAA,YAAY,SAAb,CAAsB,MAAO2J,EAC3B,UAAA,EAAA3H,EAAA,IAAA,CAAC/B,EAAAA,gBAAgB,SAAjB,CAA0B,MAAO0K,GAC/B,UAAA,EAAA3I,EAAA,IAAA,CAAC,MAAD,CACE,KAAK,OACL,GAAIiB,EACJ,IAAKgH,GACL,SAAUhH,EAAK,WAAaiH,EAAgB,EAAI,IAAA,IAChD,wBAAsB,GACtB,UAAWhK,EAAAA,qBAAqB+F,GAAW6D,EAAa,EACxD,iBAAkB3J,EAAAA,kBAChBD,EAAAA,qBAAqBgG,GAAkB6D,EAAoB,CAC7D,EACA,QAAS7J,EAAAA,qBAAqBiG,GAAS6D,GAAa,CAAE,sBAAuB,EAAM,CAAC,EACpF,cAAe9J,EAAAA,qBAAqBkG,GAAesE,EAAe,EAClE,UAAWtK,EAAAA,GAAGC,GAAAA,eAAe,KAAMC,EAAAA,mBAAoBC,GAAAA,UAAWyF,EAAS,EAE1E,UACE,CAAA,CACmB,CAAA,CACN,CAAA,CAE1B,EACA,EAAS,YAAc"}
|
|
@@ -15,9 +15,9 @@ import { getLayerTreeElements as se } from "../../lib/layers.mjs";
|
|
|
15
15
|
import { PortalDepthContext as ce } from "../portal/Portal.mjs";
|
|
16
16
|
import { focusRing as le } from "../../lib/styles.mjs";
|
|
17
17
|
import { useCheckedValues as ue, withCheckedValuesListener as de } from "../../hooks/useCheckedValues.mjs";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
18
|
+
import { useHoverIntent as fe } from "../../hooks/useHoverIntent.mjs";
|
|
19
|
+
import { MenuContext as o, MenuListContext as pe, useCheckableRegistry as me, useMenuListContext as he } from "./Menu.context.mjs";
|
|
20
|
+
import { MENU_ITEM_SELECTOR as ge, menuSurfaceClasses as _e, withTypeaheadText as ve } from "./Menu.shared.mjs";
|
|
21
21
|
import { MenuPopover as s, useMenuListPointer as ye } from "./Menu.popover.mjs";
|
|
22
22
|
import { useContextMenuAnchor as be } from "../../hooks/useContextMenuAnchor.mjs";
|
|
23
23
|
import { MenuTrigger as c } from "./Menu.trigger.mjs";
|
|
@@ -33,7 +33,7 @@ function we(e) {
|
|
|
33
33
|
return t.length > 1 ? `${t.slice(0, -1).join(", ")} and ${t[t.length - 1]}` : t.join("");
|
|
34
34
|
}
|
|
35
35
|
var d = ({ children: t, open: n, defaultOpen: s, onOpenChange: c, checkedValues: d, defaultCheckedValues: Te, onCheckedValuesChange: f, persistOnItemClick: Ee, openOnHover: p, openDelay: De, closeDelay: Oe, openOnContext: ke, className: Ae, onKeyDown: je, onKeyDownCapture: Me, onFocus: Ne, onPointerMove: Pe, ref: Fe, ...m }) => {
|
|
36
|
-
let h =
|
|
36
|
+
let h = he(), g = l.useContext(ce), _ = h !== null && h.portalDepth === g ? h : null, v = _?.menu ?? null, y = v !== null, [b, x, S] = te(n, s ?? !1, c), Ie = oe(), C = v === null || !v.popup || v.open, w = b && Ie && C;
|
|
37
37
|
l.useLayoutEffect(() => {
|
|
38
38
|
C || !b || S || x(!1);
|
|
39
39
|
}, [
|
|
@@ -80,7 +80,7 @@ var d = ({ children: t, open: n, defaultOpen: s, onOpenChange: c, checkedValues:
|
|
|
80
80
|
l.useLayoutEffect(() => {
|
|
81
81
|
w && (W.current = G.current ? "hover" : "other", H.current = !1), G.current = !1;
|
|
82
82
|
}, [w]);
|
|
83
|
-
let it = l.useCallback(() => W.current === "hover", []), { triggerHandlers: q, surfaceHandlers: at, cancel: ot, startClose: st } =
|
|
83
|
+
let it = l.useCallback(() => W.current === "hover", []), { triggerHandlers: q, surfaceHandlers: at, cancel: ot, startClose: st } = fe({
|
|
84
84
|
enabled: $e,
|
|
85
85
|
open: w,
|
|
86
86
|
openDelay: M,
|
|
@@ -251,7 +251,7 @@ var d = ({ children: t, open: n, defaultOpen: s, onOpenChange: c, checkedValues:
|
|
|
251
251
|
typeahead: !0,
|
|
252
252
|
tabStop: "last-focused",
|
|
253
253
|
manageTabIndex: !0,
|
|
254
|
-
itemSelector:
|
|
254
|
+
itemSelector: ge
|
|
255
255
|
}), kt = ae(Fe, Ct, R), [$, At] = l.useState(!1);
|
|
256
256
|
l.useLayoutEffect(() => {
|
|
257
257
|
let e = R.current;
|
|
@@ -264,7 +264,7 @@ var d = ({ children: t, open: n, defaultOpen: s, onOpenChange: c, checkedValues:
|
|
|
264
264
|
Dt,
|
|
265
265
|
Ot
|
|
266
266
|
]);
|
|
267
|
-
let jt =
|
|
267
|
+
let jt = me(), { hoverGroup: Mt, isHoverFocusing: Nt, onPointerMove: Pt } = ye(Q), Ft = l.useMemo(() => ({
|
|
268
268
|
menu: Q,
|
|
269
269
|
isStatic: !0,
|
|
270
270
|
portalDepth: g,
|
|
@@ -284,7 +284,7 @@ var d = ({ children: t, open: n, defaultOpen: s, onOpenChange: c, checkedValues:
|
|
|
284
284
|
children: t
|
|
285
285
|
}) : /* @__PURE__ */ u(o.Provider, {
|
|
286
286
|
value: Q,
|
|
287
|
-
children: /* @__PURE__ */ u(
|
|
287
|
+
children: /* @__PURE__ */ u(pe.Provider, {
|
|
288
288
|
value: Ft,
|
|
289
289
|
children: /* @__PURE__ */ u("div", {
|
|
290
290
|
role: "menu",
|
|
@@ -293,10 +293,10 @@ var d = ({ children: t, open: n, defaultOpen: s, onOpenChange: c, checkedValues:
|
|
|
293
293
|
tabIndex: m.tabIndex ?? ($ ? 0 : void 0),
|
|
294
294
|
"data-roving-container": "",
|
|
295
295
|
onKeyDown: i(je, wt),
|
|
296
|
-
onKeyDownCapture:
|
|
296
|
+
onKeyDownCapture: ve(i(Me, Tt)),
|
|
297
297
|
onFocus: i(Ne, Et, { checkDefaultPrevented: !1 }),
|
|
298
298
|
onPointerMove: i(Pe, Pt),
|
|
299
|
-
className: e(ee.root,
|
|
299
|
+
className: e(ee.root, _e, le, Ae),
|
|
300
300
|
children: t
|
|
301
301
|
})
|
|
302
302
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../lib/classNames.cjs"),o=require("../../hooks/useEventCallback.cjs"),s=require("../../hooks/useControllable.cjs"),c=require("../../hooks/useId.cjs"),l=require("../../lib/focus.cjs"),u=require("../../hooks/useMergedRefs.cjs"),ee=require("../../hooks/useIsClient.cjs"),d=require("../../lib/layers.cjs"),f=require("../../hooks/useDismiss.cjs"),p=require("../portal/Portal.cjs"),te=require("../../hooks/usePopupPosition.cjs"),ne=require("../../hooks/useRestoreFocus.cjs"),m=require("../../hooks/useTriggerElement.cjs"),h=require("../../hooks/useHoverIntent.cjs"),g=require("../../hooks/useContextMenuAnchor.cjs"),_=require("./Popover.shared.cjs");let v=require("react");v=e.__toESM(v,1);let y=require("react/jsx-runtime");var b=v.createContext(null);b.displayName=`PopoverContext`;var x=null;function S(){return x??={open:!1,setOpen:()=>{},contentId:`wave-popover-inert-content`,setCustomContentId:()=>{},triggerId:`wave-popover-inert-trigger`,resolvedTriggerId:void 0,setResolvedTriggerId:()=>{},triggerRef:{current:null},triggerElement:null,triggerElementRef:()=>{},surfaceElementRef:()=>{},arrowRef:{current:null},onTriggerClick:()=>{},onTriggerKeyDown:()=>{},hoverTriggerHandlers:null,hoverSurfaceHandlers:null,contextMode:!1,contextTriggerHandlers:null,onContentContextMenu:()=>{},keyboardContext:!1,onContentKeyDown:()=>{},layerId:`wave-popover-inert-layer`,floatingProps:{"data-side":`bottom`,"data-align":`start`,style:{}},arrowStyles:{},placedSide:`bottom`},x}function C(e){return v.useContext(b)||(n.reportMissingContext(e,`Popover`),S())}function w(e,t){let n=(t??``).split(/\s+/).filter(t=>t&&e.getElementById(t));return n.length>0?n.join(` `):void 0}function T(e,t){if(!e)return t;let n=e.ownerDocument,r=(t?n.getElementById(t):null)??m.getTriggerFocusTarget(e)??e;return w(n,r.getAttribute(`aria-labelledby`))??(r.id||e.id||void 0)}function re(e,t){return t.split(/\s+/).some(t=>{let n=t?e.getElementById(t):null;return n?n.getAttribute(`aria-label`)?.trim()||n.textContent?.trim()?!0:!!n.querySelector(`[aria-label]:not([aria-label=""]), [alt]:not([alt=""]), [title]:not([title=""])`):!1})}var E=()=>()=>{};function D(e,t){let n=e?.ownerDocument.activeElement;return!e||!n?!1:e.contains(n)?!0:d.getLayerTreeElements(t,{includeOwnElements:!1}).some(e=>e.contains(n))}function ie(e){return!!e&&typeof e.nodeType==`number`}function O(e){return{get current(){return e()}}}function ae(e,t,n){return m.getTriggerFocusTarget(e)??_.getTabbableThrough(e,t,n)}var k=({open:e,defaultOpen:t,onOpenChange:r,side:i=`bottom`,align:a=`start`,ignoreOutsideRefs:d,openOnHover:p=!1,openDelay:x=250,closeDelay:S=500,openOnContext:C=!1,target:w,children:T})=>{let[re,E]=s.useControllable(e,t??!1,r),k=v.useRef(!1),A=o.useEventCallback(e=>{k.current=!1,E(e)}),j=v.useCallback(()=>k.current,[]),M=ee.useIsClient(),N=re&&M,[P,F]=v.useState(`other`),[I,L]=v.useState(!1),[oe,R]=v.useState(N),z=P;N!==oe&&(R(N),N&&(z=I?`hover`:`other`)),z!==P&&F(z),I&&L(!1);let B=c.useId(`popover-content`),[V,H]=v.useState(void 0),se=V??B,U=c.useId(`popover-trigger`),[ce,W]=v.useState(void 0),[G,le]=v.useState(null),[K,ue]=v.useState(null),q=v.useRef(null),J=v.useRef(null),de=v.useRef(null),fe=ie(w)?w:null,Y=v.useRef(null);v.useInsertionEffect(()=>{Y.current=fe},[fe]);let{setReference:pe,setFloating:me,floatingProps:he,arrowStyles:ge,side:_e}=te.usePopupPosition({open:N,side:i,align:a,offset:8,arrowRef:de}),ve=v.useRef(null),ye=o.useEventCallback(()=>{let e=C?ve.current?.current:null;if(e&&l.isConnectedAndFocusable(e))return e;let t=q.current,n=t?m.getTriggerFocusTarget(t):null;if(n)return n;let r=Y.current;return r&&l.isConnectedAndFocusable(r)?r:t}),be=v.useMemo(()=>O(ye),[ye]),xe=o.useEventCallback(e=>!(e.ctrlKey&&q.current?.contains(e.target))),{layerId:X}=f.useDismiss({open:N,onDismiss:()=>A(!1),refs:C?[J,Y,...d??[]]:[J,q,Y,...d??[]],anchorRef:be,kind:`popover`,outsidePress:!C||xe}),Z=v.useRef(!1),{anchor:Se,fromContext:Ce,origin:we,opener:Q,triggerHandlers:Te,surfaceHandlers:Ee}=g.useContextMenuAnchor({enabled:C,open:N,trigger:K,layerId:X,onOpen:e=>{Z.current=e===`keyboard`,A(!0)},onClose:()=>A(!1)});v.useInsertionEffect(()=>{ve.current=Q},[Q]);let De=m.useTriggerFocusRef(q);ne.useRestoreFocus({enabled:N,container:G,triggerRef:C?void 0:De,finalFocusRef:C?Q:void 0,fallback:ye,onlyIfFocusInside:!0,isHoverClose:j}),v.useLayoutEffect(()=>{N&&(k.current=!1)},[N]);let Oe=u.useMergedRefs(q,ue),ke=u.useMergedRefs(J,le,me);v.useLayoutEffect(()=>{pe(Ce?Se??(K&&(m.getTriggerFocusTarget(K)??K)):w??K)},[Se,Ce,w,K,pe]),v.useLayoutEffect(()=>{if(Z.current){if(!N){Z.current=!1;return}G&&(Z.current=!1,l.focusElement(l.getFirstTabbable(G)??G,{preventScroll:!0}))}}),v.useEffect(()=>{p&&C&&n.warnOnce(`Popover:hover-and-context`,"Popover: `openOnHover` is ignored with `openOnContext`: a context popover opens on a right click, Shift+F10 or the ContextMenu key, not on hover.")},[p,C]);let $=p&&!C,Ae=o.useEventCallback(()=>z===`hover`&&!D(J.current,X)),{triggerHandlers:je,surfaceHandlers:Me,cancel:Ne}=h.useHoverIntent({enabled:$,open:N,openDelay:x,closeDelay:S,trigger:K,surface:G,onOpen:()=>{L(!0),A(!0)},onClose:()=>{k.current=!0,E(!1)},canClose:Ae}),Pe=o.useEventCallback(()=>{Ne(),N&&z===`hover`?F(`other`):A(e=>!e)}),Fe=o.useEventCallback(()=>{let e=q.current,t=C?Q.current:null;return t&&e?.contains(t)?t:e??Y.current}),Ie=v.useMemo(()=>O(Fe),[Fe]),Le=o.useEventCallback(e=>{if(e.key!==`Tab`||e.shiftKey||!N)return;if(C){let t=Fe();if(!t||e.target!==(m.getTriggerFocusTarget(t)??t))return}let t=J.current,n=t?l.getFirstTabbable(t):null;n&&(e.preventDefault(),n.focus())}),Re=_.usePopoverTabOrder({enabled:N,surface:G,anchorRef:Ie,getPreviousStop:ae}),ze=Ce&&we===`keyboard`,Be=v.useMemo(()=>({open:N,setOpen:A,contentId:se,setCustomContentId:H,triggerId:U,resolvedTriggerId:ce,setResolvedTriggerId:W,triggerRef:q,triggerElement:K,triggerElementRef:Oe,surfaceElementRef:ke,arrowRef:de,onTriggerClick:Pe,onTriggerKeyDown:Le,hoverTriggerHandlers:$?je:null,hoverSurfaceHandlers:$?Me:null,contextMode:C,contextTriggerHandlers:C?Te:null,onContentContextMenu:Ee.onContextMenu,keyboardContext:ze,onContentKeyDown:Re,layerId:X,floatingProps:he,arrowStyles:ge,placedSide:_e}),[N,A,se,U,ce,K,Oe,ke,Pe,Le,$,je,Me,C,Te,Ee,ze,Re,X,he,ge,_e]);return(0,y.jsx)(b.Provider,{value:Be,children:T})};k.displayName=`Popover`;var A=({children:e,asChild:t,id:n,onClick:r,onKeyDown:a,onContextMenu:o,onPointerEnter:s,onPointerMove:c,onPointerLeave:l,ref:ee,...d})=>{let{open:f,contentId:p,triggerId:te,triggerElementRef:ne,setResolvedTriggerId:h,onTriggerClick:g,onTriggerKeyDown:_,hoverTriggerHandlers:v,contextMode:y,contextTriggerHandlers:b}=C(`Popover.Trigger`),x=u.useMergedRefs(ee,ne),S={...d,id:n??te,"aria-haspopup":`dialog`,"aria-expanded":!y&&f,"aria-controls":f&&!y?p:void 0,onClick:i.composeEventHandlers(r,y?void 0:g),onKeyDown:i.composeEventHandlers(a,b?i.composeEventHandlers(b.onKeyDown,_):_),onContextMenu:b?i.composeEventHandlers(o,b.onContextMenu):o,onPointerEnter:v?i.composeEventHandlers(s,v.onPointerEnter):s,onPointerMove:v?i.composeEventHandlers(c,v.onPointerMove):c,onPointerLeave:v?i.composeEventHandlers(l,v.onPointerLeave):l,ref:x};return m.useTriggerElement(e,S,{componentName:`Popover.Trigger`,asChild:t,onResolvedId:h,omitStateAria:y})};A.displayName=`PopoverTrigger`;var j=({children:e,title:o,id:s,className:l,style:ee,"aria-label":d,"aria-labelledby":f,onKeyDown:te,onContextMenu:ne,onPointerEnter:m,onPointerLeave:h,ref:g,...b})=>{let{open:x,contentId:S,setCustomContentId:w,resolvedTriggerId:D,triggerRef:ie,triggerElement:O,surfaceElementRef:ae,arrowRef:k,layerId:A,floatingProps:j,arrowStyles:M,placedSide:N,onContentKeyDown:P,hoverSurfaceHandlers:F,contextMode:I,onContentContextMenu:L,keyboardContext:oe}=C(`Popover.Content`),R=c.useId(`popover-title`),z=u.useMergedRefs(g,ae),B=r.slotRendersContent(o),V=f===void 0&&!d&&!B,H=x&&V&&!I,se=v.useCallback(e=>{if(!H||!O||typeof MutationObserver>`u`)return E();let t=new MutationObserver(e);return t.observe(O,{attributes:!0,attributeFilter:[`id`,`aria-labelledby`],childList:!0,subtree:!0}),()=>t.disconnect()},[H,O]),U=v.useSyncExternalStore(se,()=>H?T(O,D):void 0,()=>H?D:void 0),ce=f??(d?void 0:B?R:U),W=s||void 0;return v.useEffect(()=>(w(W),()=>w(void 0)),[W,w]),v.useEffect(()=>{x&&V&&I&&n.isDev&&n.warnOnce(`Popover.Content:name`,"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`.")},[x,V,I]),v.useEffect(()=>{if(!H||!n.isDev)return;let e=ie.current;if(!e){n.warnOnce(`Popover.Content:name`,"Popover.Content: the popover has no accessible name. Pass `title`, `aria-label` or `aria-labelledby`, or open it from a Popover.Trigger.");return}let t=T(e,D);t?re(e.ownerDocument,t)||n.warnOnce(`Popover.Content:trigger-name`,"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.warnOnce(`Popover.Content:trigger-id`,"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`.")},[H,D,ie,U]),x?(0,y.jsx)(p.Portal,{layerId:A,children:(0,y.jsxs)(`div`,{role:`dialog`,"aria-label":d,"aria-labelledby":ce,tabIndex:oe?-1:void 0,...b,ref:z,id:W??S,"data-side":j[`data-side`],"data-align":j[`data-align`],style:{...ee,...j.style},onKeyDown:i.composeEventHandlers(te,P),onContextMenu:i.composeEventHandlers(ne,L),onPointerEnter:F?i.composeEventHandlers(m,F.onPointerEnter):m,onPointerLeave:F?i.composeEventHandlers(h,F.onPointerLeave):h,className:t.cn(a.popoverContentClassNames.root,`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`,l),children:[(0,y.jsx)(_.PopoverBeak,{ref:k,side:N,style:M,"data-wave-popover-arrow":``,className:a.popoverContentClassNames.beak}),B&&(0,y.jsx)(`h2`,{id:R,className:t.cn(a.popoverContentClassNames.title,`mb-2 text-subtitle-2 font-semibold`),children:o}),e]})}):null};j.displayName=`PopoverContent`;var M=Object.assign(k,{Trigger:A,Content:j});exports.Popover=M,exports.PopoverContent=j,exports.PopoverTrigger=A;
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/dev.cjs"),r=require("../../lib/slot.cjs"),i=require("../../lib/composeEventHandlers.cjs"),a=require("../../lib/classNames.cjs"),o=require("../../hooks/useEventCallback.cjs"),s=require("../../hooks/useControllable.cjs"),c=require("../../hooks/useId.cjs"),l=require("../../lib/focus.cjs"),u=require("../../hooks/useMergedRefs.cjs"),d=require("../../hooks/useIsClient.cjs"),f=require("../../hooks/useDismiss.cjs"),p=require("../portal/Portal.cjs"),m=require("../../hooks/usePopupPosition.cjs"),ee=require("../../hooks/useRestoreFocus.cjs"),te=require("../../hooks/useHoverIntent.cjs"),h=require("./Popover.shared.cjs"),g=require("../../hooks/useTriggerElement.cjs"),_=require("../../hooks/useContextMenuAnchor.cjs");let v=require("react");v=e.__toESM(v,1);let y=require("react/jsx-runtime");var b=v.createContext(null);b.displayName=`PopoverContext`;var x=null;function S(){return x??={open:!1,setOpen:()=>{},contentId:`wave-popover-inert-content`,setCustomContentId:()=>{},triggerId:`wave-popover-inert-trigger`,resolvedTriggerId:void 0,setResolvedTriggerId:()=>{},triggerRef:{current:null},triggerElement:null,triggerElementRef:()=>{},surfaceElementRef:()=>{},arrowRef:{current:null},onTriggerClick:()=>{},onTriggerKeyDown:()=>{},hoverTriggerHandlers:null,hoverSurfaceHandlers:null,contextMode:!1,contextTriggerHandlers:null,onContentContextMenu:()=>{},keyboardContext:!1,onContentKeyDown:()=>{},layerId:`wave-popover-inert-layer`,floatingProps:{"data-side":`bottom`,"data-align":`start`,style:{}},arrowStyles:{},placedSide:`bottom`},x}function C(e){return v.useContext(b)||(n.reportMissingContext(e,`Popover`),S())}function w(e,t){let n=(t??``).split(/\s+/).filter(t=>t&&e.getElementById(t));return n.length>0?n.join(` `):void 0}function T(e,t){if(!e)return t;let n=e.ownerDocument,r=(t?n.getElementById(t):null)??g.getTriggerFocusTarget(e)??e;return w(n,r.getAttribute(`aria-labelledby`))??(r.id||e.id||void 0)}function ne(e,t){return t.split(/\s+/).some(t=>{let n=t?e.getElementById(t):null;return n?n.getAttribute(`aria-label`)?.trim()||n.textContent?.trim()?!0:!!n.querySelector(`[aria-label]:not([aria-label=""]), [alt]:not([alt=""]), [title]:not([title=""])`):!1})}var re=()=>()=>{};function E(e){return!!e&&typeof e.nodeType==`number`}function D(e){return{get current(){return e()}}}function O(e,t,n){return g.getTriggerFocusTarget(e)??h.getTabbableThrough(e,t,n)}var k=({open:e,defaultOpen:t,onOpenChange:r,side:i=`bottom`,align:a=`start`,ignoreOutsideRefs:p,openOnHover:x=!1,openDelay:S=250,closeDelay:C=500,openOnContext:w=!1,target:T,children:ne})=>{let[re,k]=s.useControllable(e,t??!1,r),A=v.useRef(!1),j=o.useEventCallback(e=>{A.current=!1,k(e)}),M=v.useCallback(()=>A.current,[]),N=d.useIsClient(),P=re&&N,[F,I]=v.useState(`other`),[L,R]=v.useState(!1),[ie,ae]=v.useState(P),z=F;P!==ie&&(ae(P),P&&(z=L?`hover`:`other`)),z!==F&&I(z),L&&R(!1);let oe=c.useId(`popover-content`),[B,V]=v.useState(void 0),H=B??oe,U=c.useId(`popover-trigger`),[W,se]=v.useState(void 0),[G,ce]=v.useState(null),[K,le]=v.useState(null),q=v.useRef(null),J=v.useRef(null),ue=v.useRef(null),de=E(T)?T:null,Y=v.useRef(null);v.useInsertionEffect(()=>{Y.current=de},[de]);let{setReference:fe,setFloating:pe,floatingProps:me,arrowStyles:he,side:ge}=m.usePopupPosition({open:P,side:i,align:a,offset:8,arrowRef:ue}),_e=v.useRef(null),ve=o.useEventCallback(()=>{let e=w?_e.current?.current:null;if(e&&l.isConnectedAndFocusable(e))return e;let t=q.current,n=t?g.getTriggerFocusTarget(t):null;if(n)return n;let r=Y.current;return r&&l.isConnectedAndFocusable(r)?r:t}),ye=v.useMemo(()=>D(ve),[ve]),be=o.useEventCallback(e=>!(e.ctrlKey&&q.current?.contains(e.target))),{layerId:X}=f.useDismiss({open:P,onDismiss:()=>j(!1),refs:w?[J,Y,...p??[]]:[J,q,Y,...p??[]],anchorRef:ye,kind:`popover`,outsidePress:!w||be}),Z=v.useRef(!1),{anchor:xe,fromContext:Se,origin:Ce,opener:Q,triggerHandlers:we,surfaceHandlers:Te}=_.useContextMenuAnchor({enabled:w,open:P,trigger:K,layerId:X,onOpen:e=>{Z.current=e===`keyboard`,j(!0)},onClose:()=>j(!1)});v.useInsertionEffect(()=>{_e.current=Q},[Q]);let Ee=g.useTriggerFocusRef(q);ee.useRestoreFocus({enabled:P,container:G,triggerRef:w?void 0:Ee,finalFocusRef:w?Q:void 0,fallback:ve,onlyIfFocusInside:!0,isHoverClose:M}),v.useLayoutEffect(()=>{P&&(A.current=!1)},[P]);let De=u.useMergedRefs(q,le),Oe=u.useMergedRefs(J,ce,pe);v.useLayoutEffect(()=>{fe(Se?xe??(K&&(g.getTriggerFocusTarget(K)??K)):T??K)},[xe,Se,T,K,fe]),v.useLayoutEffect(()=>{if(Z.current){if(!P){Z.current=!1;return}G&&(Z.current=!1,l.focusElement(l.getFirstTabbable(G)??G,{preventScroll:!0}))}}),v.useEffect(()=>{x&&w&&n.warnOnce(`Popover:hover-and-context`,"Popover: `openOnHover` is ignored with `openOnContext`: a context popover opens on a right click, Shift+F10 or the ContextMenu key, not on hover.")},[x,w]);let $=x&&!w,ke=o.useEventCallback(()=>z===`hover`&&!h.isFocusInSurfaceTree(J.current,X)),{triggerHandlers:Ae,surfaceHandlers:je,cancel:Me}=te.useHoverIntent({enabled:$,open:P,openDelay:S,closeDelay:C,trigger:K,surface:G,onOpen:()=>{R(!0),j(!0)},onClose:()=>{A.current=!0,k(!1)},canClose:ke}),Ne=o.useEventCallback(()=>{Me(),P&&z===`hover`?I(`other`):j(e=>!e)}),Pe=o.useEventCallback(()=>{let e=q.current,t=w?Q.current:null;return t&&e?.contains(t)?t:e??Y.current}),Fe=v.useMemo(()=>D(Pe),[Pe]),Ie=o.useEventCallback(e=>{if(e.key!==`Tab`||e.shiftKey||!P)return;if(w){let t=Pe();if(!t||e.target!==(g.getTriggerFocusTarget(t)??t))return}let t=J.current,n=t?l.getFirstTabbable(t):null;n&&(e.preventDefault(),n.focus())}),Le=h.usePopoverTabOrder({enabled:P,surface:G,anchorRef:Fe,getPreviousStop:O}),Re=Se&&Ce===`keyboard`,ze=v.useMemo(()=>({open:P,setOpen:j,contentId:H,setCustomContentId:V,triggerId:U,resolvedTriggerId:W,setResolvedTriggerId:se,triggerRef:q,triggerElement:K,triggerElementRef:De,surfaceElementRef:Oe,arrowRef:ue,onTriggerClick:Ne,onTriggerKeyDown:Ie,hoverTriggerHandlers:$?Ae:null,hoverSurfaceHandlers:$?je:null,contextMode:w,contextTriggerHandlers:w?we:null,onContentContextMenu:Te.onContextMenu,keyboardContext:Re,onContentKeyDown:Le,layerId:X,floatingProps:me,arrowStyles:he,placedSide:ge}),[P,j,H,U,W,K,De,Oe,Ne,Ie,$,Ae,je,w,we,Te,Re,Le,X,me,he,ge]);return(0,y.jsx)(b.Provider,{value:ze,children:ne})};k.displayName=`Popover`;var A=({children:e,asChild:t,id:n,onClick:r,onKeyDown:a,onContextMenu:o,onPointerEnter:s,onPointerMove:c,onPointerLeave:l,ref:d,...f})=>{let{open:p,contentId:m,triggerId:ee,triggerElementRef:te,setResolvedTriggerId:h,onTriggerClick:_,onTriggerKeyDown:v,hoverTriggerHandlers:y,contextMode:b,contextTriggerHandlers:x}=C(`Popover.Trigger`),S=u.useMergedRefs(d,te),w={...f,id:n??ee,"aria-haspopup":`dialog`,"aria-expanded":!b&&p,"aria-controls":p&&!b?m:void 0,onClick:i.composeEventHandlers(r,b?void 0:_),onKeyDown:i.composeEventHandlers(a,x?i.composeEventHandlers(x.onKeyDown,v):v),onContextMenu:x?i.composeEventHandlers(o,x.onContextMenu):o,onPointerEnter:y?i.composeEventHandlers(s,y.onPointerEnter):s,onPointerMove:y?i.composeEventHandlers(c,y.onPointerMove):c,onPointerLeave:y?i.composeEventHandlers(l,y.onPointerLeave):l,ref:S};return g.useTriggerElement(e,w,{componentName:`Popover.Trigger`,asChild:t,onResolvedId:h,omitStateAria:b})};A.displayName=`PopoverTrigger`;var j=({children:e,title:o,id:s,className:l,style:d,"aria-label":f,"aria-labelledby":m,onKeyDown:ee,onContextMenu:te,onPointerEnter:g,onPointerLeave:_,ref:b,...x})=>{let{open:S,contentId:w,setCustomContentId:E,resolvedTriggerId:D,triggerRef:O,triggerElement:k,surfaceElementRef:A,arrowRef:j,layerId:M,floatingProps:N,arrowStyles:P,placedSide:F,onContentKeyDown:I,hoverSurfaceHandlers:L,contextMode:R,onContentContextMenu:ie,keyboardContext:ae}=C(`Popover.Content`),z=c.useId(`popover-title`),oe=u.useMergedRefs(b,A),B=r.slotRendersContent(o),V=m===void 0&&!f&&!B,H=S&&V&&!R,U=v.useCallback(e=>{if(!H||!k||typeof MutationObserver>`u`)return re();let t=new MutationObserver(e);return t.observe(k,{attributes:!0,attributeFilter:[`id`,`aria-labelledby`],childList:!0,subtree:!0}),()=>t.disconnect()},[H,k]),W=v.useSyncExternalStore(U,()=>H?T(k,D):void 0,()=>H?D:void 0),se=m??(f?void 0:B?z:W),G=s||void 0;return v.useEffect(()=>(E(G),()=>E(void 0)),[G,E]),v.useEffect(()=>{S&&V&&R&&n.isDev&&n.warnOnce(`Popover.Content:name`,"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`.")},[S,V,R]),v.useEffect(()=>{if(!H||!n.isDev)return;let e=O.current;if(!e){n.warnOnce(`Popover.Content:name`,"Popover.Content: the popover has no accessible name. Pass `title`, `aria-label` or `aria-labelledby`, or open it from a Popover.Trigger.");return}let t=T(e,D);t?ne(e.ownerDocument,t)||n.warnOnce(`Popover.Content:trigger-name`,"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.warnOnce(`Popover.Content:trigger-id`,"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`.")},[H,D,O,W]),S?(0,y.jsx)(p.Portal,{layerId:M,children:(0,y.jsxs)(`div`,{role:`dialog`,"aria-label":f,"aria-labelledby":se,tabIndex:ae?-1:void 0,...x,ref:oe,id:G??w,"data-side":N[`data-side`],"data-align":N[`data-align`],style:{...d,...N.style},onKeyDown:i.composeEventHandlers(ee,I),onContextMenu:i.composeEventHandlers(te,ie),onPointerEnter:L?i.composeEventHandlers(g,L.onPointerEnter):g,onPointerLeave:L?i.composeEventHandlers(_,L.onPointerLeave):_,className:t.cn(a.popoverContentClassNames.root,`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`,l),children:[(0,y.jsx)(h.PopoverBeak,{ref:j,side:F,style:P,"data-wave-popover-arrow":``,className:a.popoverContentClassNames.beak}),B&&(0,y.jsx)(`h2`,{id:z,className:t.cn(a.popoverContentClassNames.title,`mb-2 text-subtitle-2 font-semibold`),children:o}),e]})}):null};j.displayName=`PopoverContent`;var M=Object.assign(k,{Trigger:A,Content:j});exports.Popover=M,exports.PopoverContent=j,exports.PopoverTrigger=A;
|
|
2
2
|
//# sourceMappingURL=Popover.cjs.map
|