@mortenbrudvik/waveui 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +454 -74
- package/dist/components/button/Link.cjs +1 -1
- package/dist/components/button/Link.cjs.map +1 -1
- package/dist/components/button/Link.mjs +4 -4
- package/dist/components/button/Toolbar.cjs +1 -1
- package/dist/components/button/Toolbar.cjs.map +1 -1
- package/dist/components/button/Toolbar.mjs +25 -30
- package/dist/components/button/Toolbar.mjs.map +1 -1
- package/dist/components/button/Toolbar.navigation.cjs +2 -0
- package/dist/components/button/Toolbar.navigation.cjs.map +1 -0
- package/dist/components/button/Toolbar.navigation.mjs +17 -0
- package/dist/components/button/Toolbar.navigation.mjs.map +1 -0
- package/dist/components/data-display/Avatar.cjs +1 -1
- package/dist/components/data-display/Avatar.cjs.map +1 -1
- package/dist/components/data-display/Avatar.context.cjs +2 -0
- package/dist/components/data-display/Avatar.context.cjs.map +1 -0
- package/dist/components/data-display/Avatar.context.mjs +9 -0
- package/dist/components/data-display/Avatar.context.mjs.map +1 -0
- package/dist/components/data-display/Avatar.mjs +66 -61
- package/dist/components/data-display/Avatar.mjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.cjs +1 -1
- package/dist/components/data-display/AvatarGroup.cjs.map +1 -1
- package/dist/components/data-display/AvatarGroup.mjs +10 -10
- package/dist/components/data-display/InfoButton.cjs +1 -1
- package/dist/components/data-display/InfoButton.cjs.map +1 -1
- package/dist/components/data-display/InfoButton.mjs +12 -12
- package/dist/components/data-display/InteractionTag.cjs +2 -0
- package/dist/components/data-display/InteractionTag.cjs.map +1 -0
- package/dist/components/data-display/InteractionTag.mjs +234 -0
- package/dist/components/data-display/InteractionTag.mjs.map +1 -0
- package/dist/components/data-display/Tag.cjs +1 -1
- package/dist/components/data-display/Tag.cjs.map +1 -1
- package/dist/components/data-display/Tag.mjs +222 -90
- package/dist/components/data-display/Tag.mjs.map +1 -1
- package/dist/components/data-display/TagGroup.cjs +2 -0
- package/dist/components/data-display/TagGroup.cjs.map +1 -0
- package/dist/components/data-display/TagGroup.context.cjs +2 -0
- package/dist/components/data-display/TagGroup.context.cjs.map +1 -0
- package/dist/components/data-display/TagGroup.context.mjs +113 -0
- package/dist/components/data-display/TagGroup.context.mjs.map +1 -0
- package/dist/components/data-display/TagGroup.mjs +149 -0
- package/dist/components/data-display/TagGroup.mjs.map +1 -0
- package/dist/components/data-display/tagStyles.cjs +2 -0
- package/dist/components/data-display/tagStyles.cjs.map +1 -0
- package/dist/components/data-display/tagStyles.mjs +108 -0
- package/dist/components/data-display/tagStyles.mjs.map +1 -0
- package/dist/components/feedback/Toaster.cjs +1 -1
- package/dist/components/feedback/Toaster.cjs.map +1 -1
- package/dist/components/feedback/Toaster.mjs +287 -255
- package/dist/components/feedback/Toaster.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 +7 -7
- package/dist/components/input/Combobox.expand.mjs.map +1 -1
- package/dist/components/input/Combobox.mjs +176 -175
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/DatePicker.cjs +1 -1
- package/dist/components/input/DatePicker.cjs.map +1 -1
- package/dist/components/input/DatePicker.mjs +188 -187
- 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 +41 -40
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +101 -94
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.context.cjs.map +1 -1
- package/dist/components/input/SwatchPicker.context.mjs.map +1 -1
- package/dist/components/input/SwatchPicker.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.context.cjs +2 -0
- package/dist/components/input/TagPicker.context.cjs.map +1 -0
- package/dist/components/input/TagPicker.context.mjs +20 -0
- package/dist/components/input/TagPicker.context.mjs.map +1 -0
- package/dist/components/input/TagPicker.create.cjs +2 -0
- package/dist/components/input/TagPicker.create.cjs.map +1 -0
- package/dist/components/input/TagPicker.create.mjs +24 -0
- package/dist/components/input/TagPicker.create.mjs.map +1 -0
- package/dist/components/input/TagPicker.mjs +13 -279
- package/dist/components/input/TagPicker.mjs.map +1 -1
- package/dist/components/input/TagPicker.option.cjs +2 -0
- package/dist/components/input/TagPicker.option.cjs.map +1 -0
- package/dist/components/input/TagPicker.option.mjs +45 -0
- package/dist/components/input/TagPicker.option.mjs.map +1 -0
- package/dist/components/input/TagPicker.overflow.cjs +2 -0
- package/dist/components/input/TagPicker.overflow.cjs.map +1 -0
- package/dist/components/input/TagPicker.overflow.mjs +153 -0
- package/dist/components/input/TagPicker.overflow.mjs.map +1 -0
- package/dist/components/input/TagPicker.parts.cjs +2 -0
- package/dist/components/input/TagPicker.parts.cjs.map +1 -0
- package/dist/components/input/TagPicker.parts.mjs +425 -0
- package/dist/components/input/TagPicker.parts.mjs.map +1 -0
- package/dist/components/input/TagPicker.root.cjs +2 -0
- package/dist/components/input/TagPicker.root.cjs.map +1 -0
- package/dist/components/input/TagPicker.root.mjs +417 -0
- package/dist/components/input/TagPicker.root.mjs.map +1 -0
- package/dist/components/input/TimePicker.cjs +1 -1
- package/dist/components/input/TimePicker.cjs.map +1 -1
- package/dist/components/input/TimePicker.mjs +156 -154
- package/dist/components/input/TimePicker.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/navigation/Hamburger.cjs +2 -0
- package/dist/components/navigation/Hamburger.cjs.map +1 -0
- package/dist/components/navigation/Hamburger.mjs +54 -0
- package/dist/components/navigation/Hamburger.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 +137 -127
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- 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 +4 -4
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.context.cjs +2 -0
- package/dist/components/navigation/Nav.context.cjs.map +1 -0
- package/dist/components/navigation/Nav.context.mjs +137 -0
- package/dist/components/navigation/Nav.context.mjs.map +1 -0
- package/dist/components/navigation/Nav.mjs +151 -258
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/Nav.parts.cjs +2 -0
- package/dist/components/navigation/Nav.parts.cjs.map +1 -0
- package/dist/components/navigation/Nav.parts.mjs +77 -0
- package/dist/components/navigation/Nav.parts.mjs.map +1 -0
- package/dist/components/navigation/Nav.root.cjs +2 -0
- package/dist/components/navigation/Nav.root.cjs.map +1 -0
- package/dist/components/navigation/Nav.root.mjs +78 -0
- package/dist/components/navigation/Nav.root.mjs.map +1 -0
- package/dist/components/navigation/NavDrawer.cjs +2 -0
- package/dist/components/navigation/NavDrawer.cjs.map +1 -0
- package/dist/components/navigation/NavDrawer.context.cjs +2 -0
- package/dist/components/navigation/NavDrawer.context.cjs.map +1 -0
- package/dist/components/navigation/NavDrawer.context.mjs +11 -0
- package/dist/components/navigation/NavDrawer.context.mjs.map +1 -0
- package/dist/components/navigation/NavDrawer.mjs +179 -0
- package/dist/components/navigation/NavDrawer.mjs.map +1 -0
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +188 -123
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Dialog.shared.cjs +1 -1
- package/dist/components/overlays/Dialog.shared.cjs.map +1 -1
- package/dist/components/overlays/Dialog.shared.mjs +157 -81
- package/dist/components/overlays/Dialog.shared.mjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.cjs +2 -0
- package/dist/components/overlays/Dialog.slots.cjs.map +1 -0
- package/dist/components/overlays/Dialog.slots.mjs +129 -0
- package/dist/components/overlays/Dialog.slots.mjs.map +1 -0
- package/dist/components/overlays/Drawer.cjs +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.context.cjs +2 -0
- package/dist/components/overlays/Drawer.context.cjs.map +1 -0
- package/dist/components/overlays/Drawer.context.mjs +29 -0
- package/dist/components/overlays/Drawer.context.mjs.map +1 -0
- package/dist/components/overlays/Drawer.mjs +12 -187
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.cjs +2 -0
- package/dist/components/overlays/Drawer.panel.cjs.map +1 -0
- package/dist/components/overlays/Drawer.panel.mjs +159 -0
- package/dist/components/overlays/Drawer.panel.mjs.map +1 -0
- package/dist/components/overlays/Drawer.parts.cjs +2 -0
- package/dist/components/overlays/Drawer.parts.cjs.map +1 -0
- package/dist/components/overlays/Drawer.parts.mjs +152 -0
- package/dist/components/overlays/Drawer.parts.mjs.map +1 -0
- package/dist/components/overlays/Drawer.root.cjs +2 -0
- package/dist/components/overlays/Drawer.root.cjs.map +1 -0
- package/dist/components/overlays/Drawer.root.mjs +207 -0
- package/dist/components/overlays/Drawer.root.mjs.map +1 -0
- package/dist/components/overlays/Drawer.scroll.cjs +2 -0
- package/dist/components/overlays/Drawer.scroll.cjs.map +1 -0
- package/dist/components/overlays/Drawer.scroll.mjs +42 -0
- package/dist/components/overlays/Drawer.scroll.mjs.map +1 -0
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +173 -162
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs +96 -91
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +47 -47
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/portal/Portal.cjs +1 -1
- package/dist/components/portal/Portal.cjs.map +1 -1
- package/dist/components/portal/Portal.mjs +5 -5
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +1 -1
- package/dist/hooks/useDismiss.cjs.map +1 -1
- package/dist/hooks/useDismiss.mjs.map +1 -1
- package/dist/hooks/useFocusTrap.cjs +1 -1
- package/dist/hooks/useFocusTrap.cjs.map +1 -1
- package/dist/hooks/useFocusTrap.mjs +115 -98
- package/dist/hooks/useFocusTrap.mjs.map +1 -1
- package/dist/hooks/useFocusVisible.cjs +2 -0
- package/dist/hooks/useFocusVisible.cjs.map +1 -0
- package/dist/hooks/useFocusVisible.mjs +49 -0
- package/dist/hooks/useFocusVisible.mjs.map +1 -0
- package/dist/hooks/useFocusableGroup.cjs +2 -0
- package/dist/hooks/useFocusableGroup.cjs.map +1 -0
- package/dist/hooks/useFocusableGroup.mjs +70 -0
- package/dist/hooks/useFocusableGroup.mjs.map +1 -0
- package/dist/hooks/useModalLayer.cjs +1 -1
- package/dist/hooks/useModalLayer.cjs.map +1 -1
- package/dist/hooks/useModalLayer.mjs +34 -21
- package/dist/hooks/useModalLayer.mjs.map +1 -1
- package/dist/hooks/useModalOpen.cjs +2 -0
- package/dist/hooks/useModalOpen.cjs.map +1 -0
- package/dist/hooks/useModalOpen.mjs +14 -0
- package/dist/hooks/useModalOpen.mjs.map +1 -0
- package/dist/hooks/usePopupPosition.cjs +1 -1
- package/dist/hooks/usePopupPosition.cjs.map +1 -1
- package/dist/hooks/usePopupPosition.mjs +82 -53
- package/dist/hooks/usePopupPosition.mjs.map +1 -1
- package/dist/hooks/useResolvedTarget.cjs +2 -0
- package/dist/hooks/useResolvedTarget.cjs.map +1 -0
- package/dist/hooks/useResolvedTarget.mjs +37 -0
- package/dist/hooks/useResolvedTarget.mjs.map +1 -0
- package/dist/hooks/useRestoreFocus.cjs +1 -1
- package/dist/hooks/useRestoreFocus.cjs.map +1 -1
- package/dist/hooks/useRestoreFocus.mjs +91 -78
- package/dist/hooks/useRestoreFocus.mjs.map +1 -1
- package/dist/hooks/useRovingGrid.cjs +1 -1
- package/dist/hooks/useRovingGrid.cjs.map +1 -1
- package/dist/hooks/useRovingGrid.mjs +8 -57
- package/dist/hooks/useRovingGrid.mjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +180 -121
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3070 -269
- package/dist/index.d.ts +3070 -269
- package/dist/index.mjs +127 -107
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +137 -77
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/icons.cjs +1 -1
- package/dist/lib/icons.cjs.map +1 -1
- package/dist/lib/icons.mjs +13 -6
- package/dist/lib/icons.mjs.map +1 -1
- package/dist/lib/layers.cjs +1 -1
- package/dist/lib/layers.cjs.map +1 -1
- package/dist/lib/layers.mjs +120 -111
- package/dist/lib/layers.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +25 -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_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,EAC1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AEKoC,EAAe5K,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"}
|
|
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_styles","require_Portal","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,EAAM,WAAWC,GAAAA,kBAAkB,EACjDoE,EAAaF,IAAS,MAAQA,EAAK,cAAgBC,EAAcD,EAAO,KACxEG,EAASD,GAAY,MAAQ,KAC7BE,EAAYD,IAAW,KAEvB,CAACE,EAAWC,EAASC,IAAkBxE,GAAAA,gBAC3C0D,EACAe,GAAe,GACfC,CACF,EAMMC,GAAW1E,GAAAA,YAAY,EACvB2E,EAAaR,IAAW,MAAQ,CAACA,EAAO,OAASA,EAAO,KACxDS,EAAOP,GAAaK,IAAYC,EAItC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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"}
|
|
@@ -12,8 +12,8 @@ import { useRovingTabIndex as ie } from "../../hooks/useRovingTabIndex.mjs";
|
|
|
12
12
|
import { useMergedRefs as ae } from "../../hooks/useMergedRefs.mjs";
|
|
13
13
|
import { useIsClient as oe } from "../../hooks/useIsClient.mjs";
|
|
14
14
|
import { getLayerTreeElements as se } from "../../lib/layers.mjs";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { focusRing as ce } from "../../lib/styles.mjs";
|
|
16
|
+
import { PortalDepthContext as le } from "../portal/Portal.mjs";
|
|
17
17
|
import { useCheckedValues as ue, withCheckedValuesListener as de } from "../../hooks/useCheckedValues.mjs";
|
|
18
18
|
import { useHoverIntent as fe } from "../../hooks/useHoverIntent.mjs";
|
|
19
19
|
import { MenuContext as o, MenuListContext as pe, useCheckableRegistry as me, useMenuListContext as he } from "./Menu.context.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 = he(), g = l.useContext(
|
|
36
|
+
let h = he(), g = l.useContext(le), _ = 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
|
}, [
|
|
@@ -296,7 +296,7 @@ var d = ({ children: t, open: n, defaultOpen: s, onOpenChange: c, checkedValues:
|
|
|
296
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, _e,
|
|
299
|
+
className: e(ee.root, _e, ce, 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/
|
|
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/classNames.cjs"),a=require("../../hooks/useId.cjs"),o=require("../../lib/styles.cjs"),s=require("../../lib/icons.cjs"),c=require("./Nav.context.cjs"),l=require("./Nav.parts.cjs"),u=require("./Nav.root.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("react/jsx-runtime");var p=`flex h-5 w-5 shrink-0 items-center justify-center`;function m(e,n){return e&&r.slotRendersContent(e)?r.renderSlot(e,`span`,t.cn(n,p),{"aria-hidden":!0}):null}var h={base:t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,o.focusRingInset,o.disabledStyles),selected:`bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary`,idle:`text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,selectedInRow:`text-primary font-semibold`,rowSelected:`bg-subtle-selected border-s-2 border-s-primary`},g={base:t.cn(`flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none`,o.focusRingInset,o.disabledStyles),selected:`text-primary font-semibold`,idle:`text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover`,selectedInRow:`text-primary font-semibold`,rowSelected:void 0},_=`group/nav-row flex items-center transition-colors motion-reduce:transition-none`,v=`hover:bg-subtle-hover`,y=t.cn(`flex shrink-0 items-center gap-1 pe-2`,`*:opacity-0 group-hover/nav-row:*:opacity-100 group-focus-within/nav-row:*:opacity-100`,`forced-colors:*:opacity-100 [@media(hover:none)]:*:opacity-100`,`*:has-[[aria-pressed=true]]:opacity-100 *:has-[[aria-expanded=true]]:opacity-100`,`[&>[aria-pressed=true]]:opacity-100 [&>[aria-expanded=true]]:opacity-100`),b=t.cn(`flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none`,`data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary`,o.focusRingInset);function x(e){if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!0;let t=e.currentTarget,n=t.getAttribute(`target`);return!!n&&n.toLowerCase()!==`_self`||t.hasAttribute(`download`)}function S(e,n,i,a,o,s,c){let{value:l,icon:u,disabled:d=!1,href:p,className:h,children:g,onClick:b,actions:S,ref:C,...w}=e,T=n.value===l,E=p!==void 0,D=i?{"data-roving-value":l}:void 0,O=r.slotRendersContent(S),k=w.id??c,A=O?{id:k}:void 0,j=e=>{if(d){e.preventDefault();return}b?.(e),!(E?!e.defaultPrevented&&x(e):e.defaultPrevented)&&n.select(l)},M=(0,f.jsxs)(f.Fragment,{children:[s&&m(u,o.icon),s?(0,f.jsx)(`span`,{className:t.cn(o.content,`flex-1 text-start`),children:g}):g]}),N=t.cn(o.root,a.base,T?O?a.selectedInRow:a.selected:a.idle,O&&`min-w-0 flex-1`,h),P=O?t.cn(o.listItem,_,T&&a.rowSelected?a.rowSelected:!d&&v):o.listItem,F=O?(0,f.jsx)(`span`,{role:`group`,"aria-labelledby":k,"data-wave-nav-actions":``,className:t.cn(o.actions,y),children:r.materialiseSlotContent(S)}):null;if(E)return(0,f.jsxs)(`li`,{className:P,children:[(0,f.jsx)(`a`,{...w,...A,...D,ref:C,href:d?void 0:p,role:d?`link`:w.role,"aria-disabled":d?!0:w[`aria-disabled`],"aria-current":T?`page`:void 0,onClick:j,className:N,children:M}),F]});let{rel:I,...L}=w;return(0,f.jsxs)(`li`,{className:P,children:[(0,f.jsx)(`button`,{type:`button`,...L,...A,...D,ref:C,disabled:d,"aria-current":T?`page`:void 0,onClick:j,className:N,children:M}),F]})}var C=({value:e,label:r,icon:o,className:l,children:u,ref:p,...h})=>{let g=c.useNavContext(`Nav.Category`),_=d.useContext(c.NavRovingContext),{value:v,openCategories:y,toggleCategory:x,currentCategory:S,categoryStore:C}=g;c.useNavValue(g,`category`,e);let w=a.useId(`wave-nav-category`),T=y.includes(e),E=!T&&v!==``&&c.containsValue(u,v),D=d.useSyncExternalStore(C.subscribe,()=>v!==``&&C.get(v)===e,()=>!1);d.useLayoutEffect(()=>{if(E)return C.record(v,e),()=>C.forget(v,e)},[C,E,v,e]);let O=!T&&(S===e||D||E);d.useLayoutEffect(()=>{if(_)return _.reportCurrentCategory(e,O),()=>_.reportCurrentCategory(e,!1)},[_,e,O]);let k=d.useRef(null);c.useNavListChildCheck(k,`Nav.Category`,`sub-items`);let A=r,j=u;if(r===void 0){n.warnDeprecated(`Nav.Category`,`text children as the label`,`label`,"Pass the category label in `label` and only the sub-items as children.");let e=d.Children.toArray(u),t=e=>typeof e==`string`||typeof e==`number`;A=e.filter(t).join(``),j=e.filter(e=>!t(e))}return(0,f.jsxs)(`li`,{ref:p,...h,className:t.cn(i.navCategoryClassNames.root,l),children:[(0,f.jsxs)(`button`,{type:`button`,"aria-expanded":T,"aria-controls":T?w:void 0,"aria-current":O?!0:void 0,"data-contains-current":O?``:void 0,"data-roving-value":_?`wave-nav-category:${e}`:void 0,onClick:()=>x(e),className:t.cn(i.navCategoryClassNames.button,b),children:[m(o,i.navCategoryClassNames.icon),(0,f.jsx)(`span`,{className:t.cn(i.navCategoryClassNames.label,`flex-1 text-start`),children:A}),(0,f.jsx)(s.ChevronDownIcon,{className:t.cn(i.navCategoryClassNames.expandIcon,`shrink-0 transition-transform motion-reduce:transition-none`,T&&`rotate-180`)})]}),T&&(0,f.jsx)(c.NavCategoryValueContext.Provider,{value:e,children:(0,f.jsx)(`ul`,{ref:k,id:w,className:t.cn(i.navCategoryClassNames.list,`m-0 list-none p-0`),children:j})})]})};C.displayName=`NavCategory`,c.markNavPart(C,`category`);function w(e){let t=c.useNavContext(`Nav.Item`);c.useNavValue(t,`item`,e.value),c.useRecordCategory(t,e.value);let n=d.useContext(c.NavRovingContext),r=a.useId(`wave-nav-item`);return S(e,t,n,h,{root:i.navItemClassNames.root,listItem:i.navItemClassNames.listItem,actions:i.navItemClassNames.actions,icon:i.navItemClassNames.icon,content:i.navItemClassNames.content},!0,r)}w.displayName=`NavItem`,c.markNavPart(w,`entry`);function T(e){let t=c.useNavContext(`Nav.SubItem`);c.useNavValue(t,`item`,e.value),c.useRecordCategory(t,e.value);let n=d.useContext(c.NavRovingContext),r=a.useId(`wave-nav-item`);return S(e,t,n,g,{root:i.navSubItemClassNames.root,listItem:i.navSubItemClassNames.listItem,actions:i.navSubItemClassNames.actions},!1,r)}T.displayName=`NavSubItem`,c.markNavPart(T,`entry`);var E=Object.assign(u.NavRoot,{Category:C,Item:w,SubItem:T,SectionHeader:l.NavSectionHeader,Divider:l.NavDivider,AppItem:l.NavAppItem,AppItemStatic:l.NavAppItemStatic});exports.Nav=E,exports.NavAppItem=l.NavAppItem,exports.NavAppItemStatic=l.NavAppItemStatic,exports.NavCategory=C,exports.NavDivider=l.NavDivider,exports.NavItem=w,exports.NavSectionHeader=l.NavSectionHeader,exports.NavSubItem=T;
|
|
2
2
|
//# sourceMappingURL=Nav.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Nav.cjs","names":["React","slotRendersContent","renderSlot","cn","focusRingInset","disabledStyles","getElementType","_Fragment","useId","navCategoryClassNames","ChevronDownIcon","navItemClassNames","navSubItemClassNames","resolveDeprecatedProp","useControllable","useEventCallback","navClassNames","require_runtime","require_cn","require_children","require_dev","require_slot","require_classNames","require_useEventCallback","require_useControllable","require_useId","require_styles","require_icons","react","react_jsx_runtime","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","componentName","warnDuplicateValue","kind","useNavValue","context","registerValue","useRecordCategory","categoryStore","iconClasses","renderIcon","icon","className","itemClasses","subItemClasses","categoryButtonClasses","childrenOf","element","children","isThenable","forEachElement","nodes","node","visit","child","error","isPart","types","containsValue","found","NavItem","NavSubItem","selected","findCategoriesContaining","result","current","inner","NavCategory","opensElsewhere","event","link","target","renderNavEntry","rest","props","isSelected","isLink","href","handleClick","disabled","onClick","content","withIcon","stable","entryClassName","classes","buttonRest","currentValue","listId","isOpen","openCategories","holdsCurrentChild","holdsShownCurrent","containsCurrent","currentCategory","buttonLabel","label","items","parts","isText","part","toggleCategory","NavRoot","valueProp","defaultValueProp","openCategoriesProp","controlledValue","selectedValue","defaultValue","defaultSelectedValue","onNavItemSelect","setValue","onValueChange","notifyNavItemSelect","select","next","initialOpenCategories","defaultOpenCategories","setOpenCategories","onOpenCategoriesChange","previous","entry","valueCountsRef","counts","key","count","remaining","contextValue","Nav"],"sources":["../../../src/components/navigation/Nav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n navCategoryClassNames,\n navClassNames,\n navItemClassNames,\n navSubItemClassNames,\n} from '../../lib/classNames';\nimport type { Slot } from '../../lib/types';\nimport { renderSlot, slotRendersContent } from '../../lib/slot';\nimport {\n reportMissingContext,\n resolveDeprecatedProp,\n warnDeprecated,\n warnOnce,\n} from '../../lib/dev';\nimport { getElementType } from '../../lib/children';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useEventCallback } from '../../hooks/useEventCallback';\nimport { useId } from '../../hooks/useId';\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n/** The two value namespaces of a Nav: items (Nav.Item and Nav.SubItem) and categories. */\ntype NavValueKind = 'item' | 'category';\n\n/**\n * The category each sub-item was last shown in, by sub-item value: written from layout effects by\n * the mounted sub-items and by a closed category whose children hold the current value, read by\n * the categories with `useSyncExternalStore`. An entry outlives its sub-item, so a category closed\n * after its current sub-item was shown still knows it contains the current page.\n */\ninterface NavCategoryStore {\n /**\n * Records the category a mounted item renders in, or a closed category whose children hold the\n * value; `null` (an item outside any category) forgets an earlier entry, so a value moved out of\n * a category no longer marks it.\n */\n record: (value: string, category: string | null) => void;\n /** Forgets the entry of `value` while it is still `category`. */\n forget: (value: string, category: string) => void;\n /** The category last recorded for a sub-item value. */\n get: (value: string) => string | undefined;\n subscribe: (listener: () => void) => () => void;\n}\n\nfunction createCategoryStore(): NavCategoryStore {\n const categories = new Map<string, string>();\n const listeners = new Set<() => void>();\n const notify = () => listeners.forEach((listener) => listener());\n return {\n record(value, category) {\n if ((categories.get(value) ?? null) === category) return;\n if (category === null) categories.delete(value);\n else categories.set(value, category);\n notify();\n },\n forget(value, category) {\n if (categories.get(value) !== category) return;\n categories.delete(value);\n notify();\n },\n get: (value) => categories.get(value),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\ninterface NavContextValue {\n /** The selected item value (`''` when nothing is selected). */\n value: string;\n /** Selects an item (activation handler: also fires the deprecated `onNavItemSelect`). */\n select: (value: string) => void;\n openCategories: readonly string[];\n toggleCategory: (value: string) => void;\n /** Registers a mounted item or category value (duplicate warning); returns the cleanup. */\n registerValue: (kind: NavValueKind, value: string) => () => void;\n /** The `currentCategory` hint of the Nav. */\n currentCategory: string | undefined;\n categoryStore: NavCategoryStore;\n}\n\nconst NavContext = React.createContext<NavContextValue | null>(null);\nNavContext.displayName = 'NavContext';\n\nconst noop = () => {};\nconst INERT_NAV_CONTEXT: NavContextValue = {\n value: '',\n select: noop,\n openCategories: [],\n toggleCategory: noop,\n registerValue: () => noop,\n currentCategory: undefined,\n categoryStore: { record: noop, forget: noop, get: () => undefined, subscribe: () => noop },\n};\n\n/**\n * The value of the Nav.Category a sub-item renders in (`null` outside a category). It renders no\n * element; a sub-item outside a category is valid, so there is no missing-context error.\n */\nconst NavCategoryValueContext = React.createContext<string | null>(null);\nNavCategoryValueContext.displayName = 'NavCategoryValueContext';\n\n/** C-CONTEXT: throws in development, logs once and returns an inert value in production. */\nfunction useNavContext(componentName: string): NavContextValue {\n const context = React.useContext(NavContext);\n if (context) return context;\n reportMissingContext(componentName, 'Nav');\n return INERT_NAV_CONTEXT;\n}\n\nfunction warnDuplicateValue(kind: NavValueKind, value: string): void {\n warnOnce(\n `Nav:duplicate-${kind}:${value}`,\n kind === 'item'\n ? `Nav: several items share the value \"${value}\". Nav.Item and Nav.SubItem values must be unique within a Nav; every item with the current value is marked as the current page.`\n : `Nav: several categories share the value \"${value}\". Nav.Category values must be unique within a Nav; they open and close together.`,\n );\n}\n\n/** Registers the value of a mounted item or category, so Nav can warn about duplicates. */\nfunction useNavValue(context: NavContextValue, kind: NavValueKind, value: string): void {\n const { registerValue } = context;\n React.useEffect(() => registerValue(kind, value), [registerValue, kind, value]);\n}\n\n/**\n * Records the category a mounted item renders in, which the category reads once closed (`null`\n * outside a category, which forgets a stale entry for the value).\n */\nfunction useRecordCategory(context: NavContextValue, value: string): void {\n const category = React.useContext(NavCategoryValueContext);\n const { categoryStore } = context;\n React.useLayoutEffect(() => {\n categoryStore.record(value, category);\n }, [categoryStore, value, category]);\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Properties for the Nav component. */\nexport interface NavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'defaultValue'> {\n /** Controlled value of the selected nav item. */\n value?: string;\n /**\n * Selected nav item value for uncontrolled usage.\n * @default ''\n */\n defaultValue?: string;\n /** Called with the new value when the selection changes (not when the current item is re-selected). */\n onValueChange?: (value: string) => void;\n /** @deprecated Use `value`. */\n selectedValue?: string;\n /** @deprecated Use `defaultValue`. */\n defaultSelectedValue?: string;\n /**\n * @deprecated Use `onValueChange`. Unlike `onValueChange`, it fires on every activation,\n * re-selecting the current item included (0.4 behaviour).\n */\n onNavItemSelect?: (value: string) => void;\n /** Controlled list of open category values. */\n openCategories?: readonly string[];\n /**\n * Categories open initially (uncontrolled). Without it, the categories that contain the\n * selected item (`value`, else `defaultValue`) start open, so the current page is visible on the\n * first render; an empty list keeps every category closed.\n */\n defaultOpenCategories?: readonly string[];\n /** Called with the new list of open category values (a new array) when a category is toggled. */\n onOpenCategoriesChange?: (openCategories: string[]) => void;\n /**\n * The `value` of the category that contains the current item, for sub-items Nav cannot find by\n * itself (rendered by your own component inside a closed category). Usually not needed: Nav\n * finds sub-items among a category's children (through Fragments and wrapper elements) and\n * remembers the category of the current sub-item once it has been shown. A hint, not state:\n * unlike Fluent's `selectedCategoryValue` it has no default or change callback.\n */\n currentCategory?: string;\n /** Ref to the `<nav>` element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n/** Properties for the NavCategory sub-component. */\nexport interface NavCategoryProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * Value identifying this category (used by `openCategories`), unique among the categories of\n * the Nav (a duplicate warns in development).\n */\n value: string;\n /**\n * Label of the category's toggle button (any content). Without it, the text children are used\n * as the label — deprecated: pass the label here and only the sub-items as children.\n */\n label?: React.ReactNode;\n /**\n * Icon displayed before the category label. Rendered with `aria-hidden=\"true\"`. A falsy icon\n * (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /** The category's sub-items (`Nav.SubItem`), rendered in its list while it is open. */\n children?: React.ReactNode;\n /** Ref to the category's `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * The props of Nav.Item that every branch shares ({@link NavItemAnchorProps},\n * {@link NavItemButtonProps}, {@link NavItemDynamicProps}).\n */\nexport interface NavItemOwnProps {\n /**\n * Value identifying this nav item, unique among the items and sub-items of the Nav (a duplicate\n * warns in development).\n */\n value: string;\n /**\n * Icon displayed before the item label. Rendered with `aria-hidden=\"true\"`. A falsy icon (`''`,\n * `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Whether the item is disabled: a native `disabled` button, or an `aria-disabled` link without\n * `href`. Activating a disabled item never selects it; a disabled item whose value is the\n * current `value` still shows as current (`aria-current=\"page\"` and the selected look), because\n * the current value belongs to the app.\n */\n disabled?: boolean;\n /** Label content. */\n children?: React.ReactNode;\n}\n\n/**\n * The attributes only a link has (`target`, `download`, `hrefLang`, `ping`, …). Button items\n * declare them as `undefined`, so they are a type error without `href` instead of landing on the\n * `<button>`. `rel` cannot be listed (React types it on every element, RDFa); a button item drops\n * it at run time instead.\n */\ntype NoAnchorOnlyAttributes = {\n [\n K in Exclude<\n keyof React.AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof React.ButtonHTMLAttributes<HTMLButtonElement>\n >\n ]?: undefined;\n};\n\n/**\n * Nav.Item rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement`. 0.4 typed every item's handlers on `HTMLButtonElement`, so with a string\n * `href` an unannotated 0.4 handler that reads a button-only member (such as\n * `e.currentTarget.form`) no longer compiles; a handler already typed as\n * `React.MouseEventHandler<HTMLButtonElement>` still does (React handler types are bivariant).\n */\nexport interface NavItemAnchorProps\n extends\n NavItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.Item rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavItemButtonProps\n extends\n NavItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavItemOwnProps> {\n /** Button items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavItem sub-component: link props with `href`, button props without.\n *\n * A union type (0.4 had an interface): an interface cannot extend it, so extend one branch\n * (`interface X extends NavItemButtonProps`) or intersect (`type X = NavItemProps & { … }`).\n * `React.ComponentProps<typeof Nav.Item>` resolves to the last overload,\n * {@link NavItemDynamicProps}.\n */\nexport type NavItemProps = NavItemAnchorProps | NavItemButtonProps;\n\n/**\n * Nav.Item with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Resolved after the button and link signatures.\n *\n * Only the attributes both elements share are accepted (no `target`, `download`, `type`, `form`,\n * …), and handlers receive events of either element (`HTMLAnchorElement | HTMLButtonElement`).\n * 0.4 typed them as button events (`HTMLAttributes<HTMLButtonElement>`), so an unannotated 0.4\n * handler that reads a button-only member (such as `e.currentTarget.form`) no longer compiles here;\n * narrow `e.currentTarget` first. (A string `href` types handlers on `HTMLAnchorElement`, see\n * {@link NavItemAnchorProps}; no `href` keeps `HTMLButtonElement`.)\n */\nexport interface NavItemDynamicProps\n extends\n NavItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/**\n * The props of Nav.SubItem that every branch shares: those of {@link NavItemOwnProps} without\n * `icon`.\n */\nexport type NavSubItemOwnProps = Omit<NavItemOwnProps, 'icon'>;\n\n/**\n * Nav.SubItem rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement` (0.4: `HTMLButtonElement`); see {@link NavItemAnchorProps}.\n */\nexport interface NavSubItemAnchorProps\n extends\n NavSubItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavSubItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.SubItem rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavSubItemButtonProps\n extends\n NavSubItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** Button sub-items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavSubItem sub-component: link props with `href`, button props without.\n * A union type like {@link NavItemProps} (extend a branch or intersect; `React.ComponentProps`\n * resolves to {@link NavSubItemDynamicProps}).\n */\nexport type NavSubItemProps = NavSubItemAnchorProps | NavSubItemButtonProps;\n\n/**\n * Nav.SubItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Only the attributes both elements share are accepted, and handlers\n * receive events of either element (0.4 typed them as button events); see\n * {@link NavItemDynamicProps}.\n */\nexport interface NavSubItemDynamicProps\n extends\n NavSubItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** The props both entry kinds share at runtime (the union narrowed by `href`). */\ntype NavEntryProps = NavItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst iconClasses = 'flex h-5 w-5 shrink-0 items-center justify-center';\n\n/**\n * The `icon` slot of Nav.Item and Nav.Category, or `null` when it renders nothing. A falsy icon\n * (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4 and as in\n * Avatar, and so is a collection whose items render nothing, so no empty 20px box is rendered\n * before the label. The check does not consume a generator: renderSlot still renders its items.\n */\nfunction renderIcon(\n icon: Slot<'span'> | undefined,\n className: string | undefined,\n): React.ReactElement | null {\n return icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(className, iconClasses), { 'aria-hidden': true })\n : null;\n}\n\nconst itemClasses = {\n base: cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary',\n idle: 'text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst subItemClasses = {\n base: cn(\n 'flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'text-primary font-semibold',\n idle: 'text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n};\n\nconst categoryButtonClasses = cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n // A closed category that contains the current page shows the selected look of an item.\n 'data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary',\n focusRingInset,\n);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ntype ElementWithChildren = React.ReactElement<{ value?: unknown; children?: React.ReactNode }>;\n\nfunction childrenOf(element: ElementWithChildren): React.ReactNode {\n const { children } = element.props;\n return typeof children === 'function' ? undefined : children;\n}\n\n/** Whether a thrown value suspends rendering (a loading lazy chunk, a pending promise). */\nfunction isThenable(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\n/*\n * The walks below run during Nav's render and reach consumer content at any depth. Content that\n * is still loading inside the consumer's own <Suspense> (a promise child, a lazy node, a\n * `React.lazy` component) suspends that boundary when React renders it; walking it must never\n * suspend Nav itself, which would hide the whole Nav behind an outer boundary. So a child that\n * cannot be read yet is skipped, and a lazy type that is still loading is not a part (its\n * children are still walked). Parts written in a Server Component arrive as loaded client\n * references and are recognized.\n */\n\n/** Calls `visit` with each element of `nodes` (as `React.Children.forEach`), skipping pending ones. */\nfunction forEachElement(nodes: React.ReactNode, visit: (child: ElementWithChildren) => void): void {\n if (Array.isArray(nodes)) {\n for (const node of nodes as React.ReactNode[]) forEachElement(node, visit);\n return;\n }\n try {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<ElementWithChildren['props']>(child)) visit(child);\n });\n } catch (error) {\n if (!isThenable(error)) throw error;\n }\n}\n\n/** Whether `element` is one of `types`; a lazy type still loading is none (it never suspends). */\nfunction isPart(element: ElementWithChildren, ...types: unknown[]): boolean {\n return types.includes(getElementType(element, { suspend: false }));\n}\n\n/**\n * Whether `nodes` contain a Nav.Item/Nav.SubItem element with `value === selected` (parts written\n * in a Server Component, lazy client references, included). Called during render only.\n */\nfunction containsValue(nodes: React.ReactNode, selected: string): boolean {\n let found = false;\n forEachElement(nodes, (child) => {\n if (found) return;\n if (isPart(child, NavItem, NavSubItem) && child.props.value === selected) {\n found = true;\n } else {\n found = containsValue(childrenOf(child), selected);\n }\n });\n return found;\n}\n\n/** The values of the Nav.Category elements (at any depth of JSX) that contain `selected`. */\nfunction findCategoriesContaining(nodes: React.ReactNode, selected: string): string[] {\n const result: string[] = [];\n if (!selected) return result;\n const visit = (current: React.ReactNode) => {\n forEachElement(current, (child) => {\n const inner = childrenOf(child);\n if (\n isPart(child, NavCategory) &&\n typeof child.props.value === 'string' &&\n containsValue(inner, selected)\n ) {\n result.push(child.props.value);\n }\n visit(inner);\n });\n };\n visit(nodes);\n return result;\n}\n\n/**\n * Whether a click on a link opens it somewhere other than the current page, checked as routers\n * do: a modifier key (a new tab or window, a download), a mouse button other than the main one, a\n * `target` other than `_self`, or a `download` link. Only when the default is not prevented does\n * the browser actually open it there.\n */\nfunction opensElsewhere(event: React.MouseEvent<HTMLElement>): boolean {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return true;\n }\n const link = event.currentTarget;\n const target = link.getAttribute('target');\n return (!!target && target.toLowerCase() !== '_self') || link.hasAttribute('download');\n}\n\n/** The stable classes of an entry, written literally by Nav.Item and Nav.SubItem. */\ninterface NavEntryClassNames {\n root: string;\n listItem: string;\n icon?: string;\n content?: string;\n}\n\n/** Shared rendering of Nav.Item and Nav.SubItem (link or button). */\nfunction renderNavEntry(\n props: NavEntryProps,\n context: NavContextValue,\n classes: { base: string; selected: string; idle: string },\n stable: NavEntryClassNames,\n withIcon: boolean,\n): React.ReactElement {\n const { value, icon, disabled = false, href, className, children, onClick, ref, ...rest } = props;\n const isSelected = context.value === value;\n const isLink = href !== undefined;\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n // A link is still selected when the consumer prevents its default (client-side routing:\n // `preventDefault()` + `router.push(href)`, whatever the modifier keys: the browser then opens\n // nothing elsewhere), but not when the browser opens it elsewhere (the current page does not\n // change); a button honours `preventDefault()` (C-COMPOSE).\n if (isLink ? !event.defaultPrevented && opensElsewhere(event) : event.defaultPrevented) return;\n context.select(value);\n };\n\n const content = (\n <>\n {withIcon && renderIcon(icon, stable.icon)}\n {withIcon ? (\n <span className={cn(stable.content, 'flex-1 text-start')}>{children}</span>\n ) : (\n children\n )}\n </>\n );\n\n const entryClassName = cn(\n stable.root,\n classes.base,\n isSelected ? classes.selected : classes.idle,\n className,\n );\n\n if (isLink) {\n return (\n <li className={stable.listItem}>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={disabled ? undefined : href}\n role={disabled ? 'link' : rest.role}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </a>\n </li>\n );\n }\n\n // `rel` only belongs on a link: a button item drops it (React types it on every element).\n const { rel, ...buttonRest } = rest;\n return (\n <li className={stable.listItem}>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n ref={ref as React.Ref<HTMLButtonElement>}\n disabled={disabled}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </button>\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Nav.Category\n// ---------------------------------------------------------------------------\n\n/**\n * A collapsible group of sub-items. Its toggle button shows `label` and reports `aria-expanded`\n * (and `aria-controls` while open); the sub-items render in a nested list while it is open.\n * Open state lives on `Nav` (`openCategories`/`defaultOpenCategories`).\n *\n * A closed category that contains the current item marks its toggle button with\n * `aria-current=\"true\"` (the button is not the page's link, so not `\"page\"`),\n * `data-contains-current` and the selected look of `Nav.Item`. It contains the current item when\n * a `Nav.SubItem` with the current value is among its children (through Fragments and wrapper\n * elements, also in the server HTML), when the current sub-item was last shown in it (and has not\n * moved among another category's children since), or when it is the Nav's `currentCategory`. An\n * open category is not marked: its sub-item shows the current page.\n *\n * Also exported as `NavCategory` (import the flat name from React Server Components).\n */\nconst NavCategory = ({\n value,\n label,\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavCategoryProps) => {\n const context = useNavContext('Nav.Category');\n const {\n value: currentValue,\n openCategories,\n toggleCategory,\n currentCategory,\n categoryStore,\n } = context;\n useNavValue(context, 'category', value);\n const listId = useId('wave-nav-category');\n const isOpen = openCategories.includes(value);\n\n // The current sub-item is among the children of this closed category (also on the server).\n const holdsCurrentChild = !isOpen && currentValue !== '' && containsValue(children, currentValue);\n // The current sub-item was last shown in this category (none on the server).\n const holdsShownCurrent = React.useSyncExternalStore(\n categoryStore.subscribe,\n () => currentValue !== '' && categoryStore.get(currentValue) === value,\n () => false,\n );\n // Children that hold the current sub-item make this the category the Nav remembers for it, so a\n // category it was shown in before it moved here is no longer marked. The entry is forgotten when\n // they stop holding it (an open category records through its mounted sub-item instead).\n React.useLayoutEffect(() => {\n if (!holdsCurrentChild) return;\n categoryStore.record(currentValue, value);\n return () => categoryStore.forget(currentValue, value);\n }, [categoryStore, holdsCurrentChild, currentValue, value]);\n const containsCurrent =\n !isOpen && (currentCategory === value || holdsShownCurrent || holdsCurrentChild);\n\n let buttonLabel: React.ReactNode = label;\n let items: React.ReactNode = children;\n if (label === undefined) {\n // Deprecated 0.4 path: the text children are the label, the other children the sub-items.\n warnDeprecated(\n 'Nav.Category',\n 'text children as the label',\n 'label',\n 'Pass the category label in `label` and only the sub-items as children.',\n );\n const parts = React.Children.toArray(children);\n const isText = (part: unknown) => typeof part === 'string' || typeof part === 'number';\n buttonLabel = parts.filter(isText).join('');\n items = parts.filter((part) => !isText(part));\n }\n\n return (\n <li ref={ref} {...rest} className={cn(navCategoryClassNames.root, className)}>\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-current={containsCurrent ? true : undefined}\n data-contains-current={containsCurrent ? '' : undefined}\n onClick={() => toggleCategory(value)}\n className={cn(navCategoryClassNames.button, categoryButtonClasses)}\n >\n {renderIcon(icon, navCategoryClassNames.icon)}\n <span className={cn(navCategoryClassNames.label, 'flex-1 text-start')}>{buttonLabel}</span>\n <ChevronDownIcon\n className={cn(\n navCategoryClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isOpen && 'rotate-180',\n )}\n />\n </button>\n {isOpen && (\n <NavCategoryValueContext.Provider value={value}>\n <ul id={listId} className={cn(navCategoryClassNames.list, 'm-0 list-none p-0')}>\n {items}\n </ul>\n </NavCategoryValueContext.Provider>\n )}\n </li>\n );\n};\nNavCategory.displayName = 'NavCategory';\n\n// ---------------------------------------------------------------------------\n// Nav.Item / Nav.SubItem\n// ---------------------------------------------------------------------------\n\n/**\n * A top-level navigation entry: a link when `href` is given (anchor props), a button otherwise\n * (button props). Clicking selects it (`aria-current=\"page\"`); activating a disabled entry never\n * selects it (a disabled entry whose value is the current value still shows as current).\n *\n * A click that opens a link somewhere other than the current page selects nothing (the consumer's\n * `onClick` still runs, and the browser opens the link): Ctrl/Cmd/Shift/Alt-click, a mouse button\n * other than the main one, a `target` other than `_self`, or a `download` link. When the consumer's\n * `onClick` calls `preventDefault()` (client-side routing), the browser opens nothing, so the item\n * is selected whatever the keys, button or `target`.\n *\n * Typed by overloads, resolved in order: without `href` (button props, button events), with a\n * string `href` (anchor props, anchor events), then an `href` that may be `undefined` at run time\n * ({@link NavItemDynamicProps}: events of either element).\n *\n * Also exported as `NavItem` (import the flat name from React Server Components).\n */\nfunction NavItem(props: NavItemButtonProps): React.ReactElement;\nfunction NavItem(props: NavItemAnchorProps): React.ReactElement;\nfunction NavItem(props: NavItemDynamicProps): React.ReactElement;\nfunction NavItem(props: NavItemProps | NavItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.Item');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(\n props as NavEntryProps,\n context,\n itemClasses,\n {\n root: navItemClassNames.root,\n listItem: navItemClassNames.listItem,\n icon: navItemClassNames.icon,\n content: navItemClassNames.content,\n },\n true,\n );\n}\nNavItem.displayName = 'NavItem';\n\n/**\n * An indented entry inside a `Nav.Category`: a link when `href` is given, a button otherwise.\n * Selected like `Nav.Item` (a click that the browser opens somewhere else selects nothing; one\n * whose default your `onClick` prevents is selected), and typed by overloads like `Nav.Item`\n * (button, link, then {@link NavSubItemDynamicProps}).\n *\n * Also exported as `NavSubItem` (import the flat name from React Server Components).\n */\nfunction NavSubItem(props: NavSubItemButtonProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemAnchorProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemDynamicProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemProps | NavSubItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.SubItem');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n return renderNavEntry(\n props as NavEntryProps,\n context,\n subItemClasses,\n { root: navSubItemClassNames.root, listItem: navSubItemClassNames.listItem },\n false,\n );\n}\nNavSubItem.displayName = 'NavSubItem';\n\n// ---------------------------------------------------------------------------\n// Nav (root)\n// ---------------------------------------------------------------------------\n\nconst NavRoot = ({\n value: valueProp,\n defaultValue: defaultValueProp,\n onValueChange,\n selectedValue,\n defaultSelectedValue,\n onNavItemSelect,\n openCategories: openCategoriesProp,\n defaultOpenCategories,\n onOpenCategoriesChange,\n currentCategory,\n className,\n children,\n ref,\n ...rest\n}: NavProps) => {\n const controlledValue = resolveDeprecatedProp(\n 'Nav',\n valueProp,\n selectedValue,\n 'selectedValue',\n 'value',\n );\n const defaultValue =\n resolveDeprecatedProp(\n 'Nav',\n defaultValueProp,\n defaultSelectedValue,\n 'defaultSelectedValue',\n 'defaultValue',\n ) ?? '';\n if (onNavItemSelect !== undefined) warnDeprecated('Nav', 'onNavItemSelect', 'onValueChange');\n\n const [value, setValue] = useControllable(controlledValue, defaultValue, onValueChange);\n const notifyNavItemSelect = useEventCallback(onNavItemSelect);\n const select = React.useCallback(\n (next: string) => {\n setValue(next);\n // Deprecated event-named alias: every activation, re-selection included (C-NAMING).\n notifyNavItemSelect(next);\n },\n [setValue, notifyNavItemSelect],\n );\n\n const [initialOpenCategories] = React.useState<readonly string[]>(\n () =>\n defaultOpenCategories ?? findCategoriesContaining(children, controlledValue ?? defaultValue),\n );\n const [openCategories, setOpenCategories] = useControllable<readonly string[]>(\n openCategoriesProp,\n initialOpenCategories,\n (next) => onOpenCategoriesChange?.([...next]),\n );\n const toggleCategory = React.useCallback(\n (category: string) => {\n setOpenCategories((previous) =>\n previous.includes(category)\n ? previous.filter((entry) => entry !== category)\n : [...previous, category],\n );\n },\n [setOpenCategories],\n );\n\n // Duplicate values (C-DEV): the mounted items and categories per value (written from their\n // effects only); a second one with a value already in use warns once per value.\n const valueCountsRef = React.useRef<Map<string, number> | null>(null);\n const registerValue = React.useCallback((kind: NavValueKind, entry: string) => {\n const counts = (valueCountsRef.current ??= new Map<string, number>());\n const key = `${kind}:${entry}`;\n const count = (counts.get(key) ?? 0) + 1;\n counts.set(key, count);\n if (count > 1) warnDuplicateValue(kind, entry);\n return () => {\n const remaining = (counts.get(key) ?? 1) - 1;\n if (remaining > 0) counts.set(key, remaining);\n else counts.delete(key);\n };\n }, []);\n\n const [categoryStore] = React.useState(createCategoryStore);\n\n const contextValue = React.useMemo<NavContextValue>(\n () => ({\n value,\n select,\n openCategories,\n toggleCategory,\n registerValue,\n currentCategory,\n categoryStore,\n }),\n [value, select, openCategories, toggleCategory, registerValue, currentCategory, categoryStore],\n );\n\n return (\n <NavContext.Provider value={contextValue}>\n <nav\n aria-label=\"Navigation\"\n {...rest}\n ref={ref}\n className={cn(\n navClassNames.root,\n 'w-60 border-e border-border bg-background py-2',\n className,\n )}\n >\n <ul className={cn(navClassNames.list, 'm-0 list-none p-0')}>{children}</ul>\n </nav>\n </NavContext.Provider>\n );\n};\nNavRoot.displayName = 'Nav';\n\n/**\n * A vertical side navigation (`<nav>` landmark, default name \"Navigation\") with items, links and\n * collapsible categories.\n *\n * - **Selection**: `value`/`defaultValue`/`onValueChange` (`onValueChange` fires only when the\n * value changes). The deprecated `selectedValue`/`defaultSelectedValue`/`onNavItemSelect` still\n * work; `onNavItemSelect` keeps firing on every activation, re-selection included. A click that\n * opens a link in another tab or window (or downloads it) selects nothing, unless the item's\n * `onClick` prevents the default (client-side routing: then nothing opens elsewhere).\n * - **Categories**: `openCategories`/`defaultOpenCategories`/`onOpenCategoriesChange`. Without\n * `defaultOpenCategories`, the categories containing the selected item (`value` or\n * `defaultValue`) start open. A closed category that contains the selected item marks its toggle\n * (`aria-current=\"true\"`, `data-contains-current`, the selected look); pass `currentCategory`\n * for sub-items your own component renders inside a closed category.\n * - **Values** are unique: among the items and sub-items, and among the categories (a duplicate\n * warns in development).\n *\n * Sub-components are also exported under flat names (`NavCategory`, `NavItem`, `NavSubItem`):\n * React Server Components import those, because dotted access (`Nav.Item`) needs a client file.\n */\nexport const Nav = /* @__PURE__ */ Object.assign(NavRoot, {\n Category: NavCategory,\n Item: NavItem,\n SubItem: NavSubItem,\n});\n\nexport { NavCategory, NavItem, NavSubItem };\n"],"mappings":"wfAkDA,SAAS8B,GAAwC,CAC/C,IAAMC,EAAa,IAAI,IACjBC,EAAY,IAAI,IAChBC,MAAeD,EAAU,QAAS,GAAaE,EAAS,CAAC,EAC/D,MAAO,CACL,OAAO,EAAO,EAAU,EACjBH,EAAW,IAAII,CAAK,GAAK,QAAUC,IACpCA,IAAa,KAAML,EAAW,OAAOI,CAAK,EACzCJ,EAAW,IAAII,EAAOC,CAAQ,EACnCH,EAAO,EACT,EACA,OAAO,EAAO,EAA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iBACA,gBACA,kBACA,eACF,GACA,CAACmC,EAAO0F,EAAQxB,EAAgBW,EAAgBjE,EAAe0D,EAAiBxD,CAAa,CAC/F,EAEA,OACE,EAAApB,EAAA,IAAA,CAACQ,EAAW,SAAZ,CAAqB,MAAOqG,EAC1B,UAAA,EAAA7G,EAAA,IAAA,CAAC,MAAD,CACE,aAAW,aACX,GAAIuD,EACC,MACL,UAAWjF,EAAAA,GACTa,EAAAA,cAAc,KACd,iDACAqC,CACF,EAEA,UAAA,EAAAxB,EAAA,IAAA,CAAC,KAAD,CAAI,UAAW1B,EAAAA,GAAGa,EAAAA,cAAc,KAAM,mBAAmB,EAAI,UAAa,CAAA,CACvE,CAAA,CACc,CAAA,CAEzB,EACA,EAAQ,YAAc,MAsBtB,IAAa2H,EAAsB,OAAO,OAAO1B,EAAS,CACxD,SAAUnC,EACV,KAAMP,EACN,QAASC,CACX,CAAC"}
|
|
1
|
+
{"version":3,"file":"Nav.cjs","names":["slotRendersContent","renderSlot","cn","focusRingInset","disabledStyles","_Fragment","materialiseSlotContent","useNavContext","React","NavRovingContext","useId","containsValue","navCategoryClassNames","ChevronDownIcon","NavCategoryValueContext","markNavPart","navItemClassNames","navSubItemClassNames","NavRoot","NavSectionHeader","NavDivider","NavAppItem","NavAppItemStatic","require_runtime","require_cn","require_dev","require_slot","require_classNames","require_useId","require_styles","require_icons","require_Nav_context","require_Nav_parts","require_Nav_root","react","react_jsx_runtime","iconClasses","renderIcon","icon","className","itemClasses","subItemClasses","rowClasses","rowHoverClasses","actionsClasses","categoryButtonClasses","opensElsewhere","event","link","target","renderNavEntry","rest","props","isSelected","context","value","isLink","href","rovingProps","roving","hasActions","actions","itemId","generatedId","idProps","handleClick","disabled","onClick","content","withIcon","stable","children","entryClassName","classes","listItemClassName","actionsGroup","buttonRest","NavCategory","currentValue","listId","isOpen","openCategories","holdsCurrentChild","holdsShownCurrent","categoryStore","containsCurrent","currentCategory","listRef","buttonLabel","label","items","parts","isText","part","toggleCategory","NavItem","NavSubItem","Nav"],"sources":["../../../src/components/navigation/Nav.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n navCategoryClassNames,\n navItemClassNames,\n navSubItemClassNames,\n} from '../../lib/classNames';\nimport type { Slot } from '../../lib/types';\nimport { materialiseSlotContent, renderSlot, slotRendersContent } from '../../lib/slot';\nimport { warnDeprecated } from '../../lib/dev';\nimport { ChevronDownIcon } from '../../lib/icons';\nimport { disabledStyles, focusRingInset } from '../../lib/styles';\nimport { useId } from '../../hooks/useId';\nimport {\n NavCategoryValueContext,\n NavRovingContext,\n containsValue,\n markNavPart,\n useNavContext,\n useNavListChildCheck,\n useNavValue,\n useRecordCategory,\n type NavContextValue,\n type NavRovingContextValue,\n type NoAnchorOnlyAttributes,\n} from './Nav.context';\nimport { NavAppItem, NavAppItemStatic, NavDivider, NavSectionHeader } from './Nav.parts';\nimport { NavRoot } from './Nav.root';\n\n/*\n * The Nav compound: the item types, styles and rendering of Nav.Item and Nav.SubItem, Nav.Category,\n * the `Object.assign` with its JSDoc, the flat names and the type re-exports. Nothing imports this\n * module but the barrel: the root (`Nav.root.tsx`) and the contexts (`Nav.context.ts`) recognise\n * the parts by the markers set next to each `displayName` below; the structural parts live in\n * `Nav.parts.tsx`.\n */\n\nexport type { NavProps } from './Nav.root';\nexport type {\n NavSectionHeaderProps,\n NavDividerProps,\n NavAppItemOwnProps,\n NavAppItemAnchorProps,\n NavAppItemButtonProps,\n NavAppItemProps,\n NavAppItemDynamicProps,\n NavAppItemStaticProps,\n} from './Nav.parts';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Properties for the NavCategory sub-component. */\nexport interface NavCategoryProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * Value identifying this category (used by `openCategories`), unique among the categories of\n * the Nav (a duplicate warns in development).\n */\n value: string;\n /**\n * Label of the category's toggle button (any content). Without it, the text children are used\n * as the label — deprecated: pass the label here and only the sub-items as children.\n */\n label?: React.ReactNode;\n /**\n * Icon displayed before the category label. Rendered with `aria-hidden=\"true\"`. A falsy icon\n * (`''`, `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * The category's sub-items (`Nav.SubItem`), and `Nav.SectionHeader` and `Nav.Divider`, rendered\n * in its list while it is open.\n */\n children?: React.ReactNode;\n /** Ref to the category's `<li>` element. */\n ref?: React.Ref<HTMLLIElement>;\n}\n\n/**\n * The props of Nav.Item that every branch shares ({@link NavItemAnchorProps},\n * {@link NavItemButtonProps}, {@link NavItemDynamicProps}).\n */\nexport interface NavItemOwnProps {\n /**\n * Value identifying this nav item, unique among the items and sub-items of the Nav (a duplicate\n * warns in development).\n */\n value: string;\n /**\n * Icon displayed before the item label. Rendered with `aria-hidden=\"true\"`. A falsy icon (`''`,\n * `0`) or a list of nothing renders no icon box.\n */\n icon?: Slot<'span'>;\n /**\n * Whether the item is disabled: a native `disabled` button, or an `aria-disabled` link without\n * `href`. Activating a disabled item never selects it; a disabled item whose value is the\n * current `value` still shows as current (`aria-current=\"page\"` and the selected look), because\n * the current value belongs to the app.\n */\n disabled?: boolean;\n /** Label content. */\n children?: React.ReactNode;\n /**\n * Controls beside the item in its row (Fluent's SplitNavItem): a ToggleButton that pins the\n * page, a MenuButton with more commands, each with its own name (a Tooltip with\n * `relationship=\"label\"` names an icon-only one). They render after the item's link or button,\n * never inside it, in a group named by the item; each is a Tab stop after the item, and a click\n * or key on one never selects the item. They are drawn while the row is hovered or has focus,\n * while one of them is pressed or has its popup open, and always in forced colours and on touch\n * screens; otherwise they are transparent and still focusable. They stay enabled when the item\n * is `disabled`. With actions, the selected background and indicator are drawn on the row (the\n * item's list item, `.wave-nav-item__list-item`), so a `className` on the item no longer covers\n * them. Content that renders nothing renders no group. Fluent's `actionButton`, `toggleButton`\n * and `menuButton` slots and their tooltips are your own controls here.\n */\n actions?: React.ReactNode;\n}\n\n/**\n * Nav.Item rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement`. 0.4 typed every item's handlers on `HTMLButtonElement`, so with a string\n * `href` an unannotated 0.4 handler that reads a button-only member (such as\n * `e.currentTarget.form`) no longer compiles; a handler already typed as\n * `React.MouseEventHandler<HTMLButtonElement>` still does (React handler types are bivariant).\n */\nexport interface NavItemAnchorProps\n extends\n NavItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.Item rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavItemButtonProps\n extends\n NavItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavItemOwnProps> {\n /** Button items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavItem sub-component: link props with `href`, button props without.\n *\n * A union type (0.4 had an interface): an interface cannot extend it, so extend one branch\n * (`interface X extends NavItemButtonProps`) or intersect (`type X = NavItemProps & { … }`).\n * `React.ComponentProps<typeof Nav.Item>` resolves to the last overload,\n * {@link NavItemDynamicProps}.\n */\nexport type NavItemProps = NavItemAnchorProps | NavItemButtonProps;\n\n/**\n * Nav.Item with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Resolved after the button and link signatures.\n *\n * Only the attributes both elements share are accepted (no `target`, `download`, `type`, `form`,\n * …), and handlers receive events of either element (`HTMLAnchorElement | HTMLButtonElement`).\n * 0.4 typed them as button events (`HTMLAttributes<HTMLButtonElement>`), so an unannotated 0.4\n * handler that reads a button-only member (such as `e.currentTarget.form`) no longer compiles here;\n * narrow `e.currentTarget` first. (A string `href` types handlers on `HTMLAnchorElement`, see\n * {@link NavItemAnchorProps}; no `href` keeps `HTMLButtonElement`.)\n */\nexport interface NavItemDynamicProps\n extends\n NavItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/**\n * The props of Nav.SubItem that every branch shares: those of {@link NavItemOwnProps} without\n * `icon`.\n */\nexport type NavSubItemOwnProps = Omit<NavItemOwnProps, 'icon'>;\n\n/**\n * Nav.SubItem rendered as a link (`href` given): anchor attributes, and handlers typed on\n * `HTMLAnchorElement` (0.4: `HTMLButtonElement`); see {@link NavItemAnchorProps}.\n */\nexport interface NavSubItemAnchorProps\n extends\n NavSubItemOwnProps,\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof NavSubItemOwnProps> {\n /**\n * URL to navigate to; renders an `<a>`. Required in this branch, so `href` discriminates the\n * union and handlers without `href` are typed as button handlers.\n */\n href: string;\n /** Ref to the `<a>` element. */\n ref?: React.Ref<HTMLAnchorElement>;\n}\n\n/** Nav.SubItem rendered as a button (no `href`): button attributes (a `rel` is not rendered). */\nexport interface NavSubItemButtonProps\n extends\n NavSubItemOwnProps,\n NoAnchorOnlyAttributes,\n Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** Button sub-items have no `href`. */\n href?: undefined;\n /** Ref to the `<button>` element. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/**\n * Properties for the NavSubItem sub-component: link props with `href`, button props without.\n * A union type like {@link NavItemProps} (extend a branch or intersect; `React.ComponentProps`\n * resolves to {@link NavSubItemDynamicProps}).\n */\nexport type NavSubItemProps = NavSubItemAnchorProps | NavSubItemButtonProps;\n\n/**\n * Nav.SubItem with an `href` known only at run time (`string | undefined`): a link when it is a\n * string, a button otherwise. Only the attributes both elements share are accepted, and handlers\n * receive events of either element (0.4 typed them as button events); see\n * {@link NavItemDynamicProps}.\n */\nexport interface NavSubItemDynamicProps\n extends\n NavSubItemOwnProps,\n Omit<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, keyof NavSubItemOwnProps> {\n /** URL to navigate to; renders an `<a>` when defined, a `<button>` otherwise. */\n href?: string;\n /** Ref to the rendered `<a>` or `<button>` element. */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement>;\n}\n\n/** The props both entry kinds share at runtime (the union narrowed by `href`). */\ntype NavEntryProps = NavItemOwnProps &\n Omit<React.AllHTMLAttributes<HTMLElement>, keyof NavItemOwnProps | 'ref'> & {\n ref?: React.Ref<HTMLElement>;\n };\n\n// ---------------------------------------------------------------------------\n// Styles\n// ---------------------------------------------------------------------------\n\nconst iconClasses = 'flex h-5 w-5 shrink-0 items-center justify-center';\n\n/**\n * The `icon` slot of Nav.Item and Nav.Category, or `null` when it renders nothing. A falsy icon\n * (`icon={name && <Icon />}` with `name` '' or a count of 0) is no icon, as in 0.4 and as in\n * Avatar, and so is a collection whose items render nothing, so no empty 20px box is rendered\n * before the label. The check does not consume a generator: renderSlot still renders its items.\n */\nfunction renderIcon(\n icon: Slot<'span'> | undefined,\n className: string | undefined,\n): React.ReactElement | null {\n return icon && slotRendersContent(icon)\n ? renderSlot(icon, 'span', cn(className, iconClasses), { 'aria-hidden': true })\n : null;\n}\n\nconst itemClasses = {\n base: cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'bg-subtle-selected text-primary font-semibold border-s-2 border-s-primary',\n idle: 'text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n // With actions, the selected background and indicator move to the row (D121).\n selectedInRow: 'text-primary font-semibold',\n rowSelected: 'bg-subtle-selected border-s-2 border-s-primary',\n};\n\nconst subItemClasses = {\n base: cn(\n 'flex w-full items-center ps-11 pe-4 py-1.5 text-body-1 text-start no-underline transition-colors motion-reduce:transition-none',\n focusRingInset,\n disabledStyles,\n ),\n selected: 'text-primary font-semibold',\n idle: 'text-muted-foreground not-disabled:not-aria-disabled:hover:text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover',\n // Sub-items have no selected background: a sub-item row gets only the hover.\n selectedInRow: 'text-primary font-semibold',\n rowSelected: undefined,\n};\n\n/** The classes an entry's link or button and its row share. */\ninterface NavEntryClasses {\n base: string;\n selected: string;\n idle: string;\n selectedInRow: string;\n rowSelected: string | undefined;\n}\n\n/**\n * The row of an entry with actions (D121): the list item lays out the link or button and the\n * actions side by side and carries the selected look, or the hover of an enabled entry. A list\n * item cannot be disabled, so its hover needs no gate.\n */\nconst rowClasses =\n 'group/nav-row flex items-center transition-colors motion-reduce:transition-none';\nconst rowHoverClasses = 'hover:bg-subtle-hover';\n\n/**\n * The actions element (D120). Each direct child is transparent until the row is hovered or has\n * focus inside it, and is always drawn in forced colours and on devices without hover; a child\n * that is or holds a pressed toggle or an expanded trigger stays drawn (the first pair covers an\n * action wrapped in a Tooltip's span, the second a bare one). Opacity keeps every action\n * focusable, so Shift+Tab and a focus return reach it. No motion.\n */\nconst actionsClasses = cn(\n 'flex shrink-0 items-center gap-1 pe-2',\n '*:opacity-0 group-hover/nav-row:*:opacity-100 group-focus-within/nav-row:*:opacity-100',\n 'forced-colors:*:opacity-100 [@media(hover:none)]:*:opacity-100',\n '*:has-[[aria-pressed=true]]:opacity-100 *:has-[[aria-expanded=true]]:opacity-100',\n '[&>[aria-pressed=true]]:opacity-100 [&>[aria-expanded=true]]:opacity-100',\n);\n\nconst categoryButtonClasses = cn(\n 'flex w-full items-center gap-2 px-4 py-2 text-body-1 font-semibold text-foreground not-disabled:not-aria-disabled:hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n // A closed category that contains the current page shows the selected look of an item.\n 'data-[contains-current]:bg-subtle-selected data-[contains-current]:text-primary data-[contains-current]:border-s-2 data-[contains-current]:border-s-primary',\n focusRingInset,\n);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Whether a click on a link opens it somewhere other than the current page, checked as routers\n * do: a modifier key (a new tab or window, a download), a mouse button other than the main one, a\n * `target` other than `_self`, or a `download` link. Only when the default is not prevented does\n * the browser actually open it there.\n */\nfunction opensElsewhere(event: React.MouseEvent<HTMLElement>): boolean {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return true;\n }\n const link = event.currentTarget;\n const target = link.getAttribute('target');\n return (!!target && target.toLowerCase() !== '_self') || link.hasAttribute('download');\n}\n\n/** The stable classes of an entry, written literally by Nav.Item and Nav.SubItem. */\ninterface NavEntryClassNames {\n root: string;\n listItem: string;\n actions: string;\n icon?: string;\n content?: string;\n}\n\n/**\n * Shared rendering of Nav.Item and Nav.SubItem (link or button). Inside an arrow-key body\n * (`roving` provided) the link or button also carries `data-roving-value={value}`, after the\n * consumer's attributes; in a plain Nav nothing is added. With `actions` that render content, the\n * list item becomes the row (D121) and holds the link or button, then the actions in a group named\n * by it through `generatedId` (unless the consumer gave an `id`), siblings, never nested (D119).\n */\nfunction renderNavEntry(\n props: NavEntryProps,\n context: NavContextValue,\n roving: NavRovingContextValue | null,\n classes: NavEntryClasses,\n stable: NavEntryClassNames,\n withIcon: boolean,\n generatedId: string,\n): React.ReactElement {\n const {\n value,\n icon,\n disabled = false,\n href,\n className,\n children,\n onClick,\n actions,\n ref,\n ...rest\n } = props;\n const isSelected = context.value === value;\n const isLink = href !== undefined;\n const rovingProps = roving ? { 'data-roving-value': value } : undefined;\n // No empty group (`actions={cond && <Button />}` with `cond` false); the id is rendered only\n // while the group points at it, so an item without actions keeps its 0.10 HTML.\n const hasActions = slotRendersContent(actions);\n const itemId = rest.id ?? generatedId;\n const idProps = hasActions ? { id: itemId } : undefined;\n\n const handleClick = (event: React.MouseEvent<HTMLElement>) => {\n if (disabled) {\n event.preventDefault();\n return;\n }\n onClick?.(event);\n // A link is still selected when the consumer prevents its default (client-side routing:\n // `preventDefault()` + `router.push(href)`, whatever the modifier keys: the browser then opens\n // nothing elsewhere), but not when the browser opens it elsewhere (the current page does not\n // change); a button honours `preventDefault()` (C-COMPOSE).\n if (isLink ? !event.defaultPrevented && opensElsewhere(event) : event.defaultPrevented) return;\n context.select(value);\n };\n\n const content = (\n <>\n {withIcon && renderIcon(icon, stable.icon)}\n {withIcon ? (\n <span className={cn(stable.content, 'flex-1 text-start')}>{children}</span>\n ) : (\n children\n )}\n </>\n );\n\n const entryClassName = cn(\n stable.root,\n classes.base,\n isSelected ? (hasActions ? classes.selectedInRow : classes.selected) : classes.idle,\n hasActions && 'min-w-0 flex-1',\n className,\n );\n\n const listItemClassName = hasActions\n ? cn(\n stable.listItem,\n rowClasses,\n isSelected && classes.rowSelected ? classes.rowSelected : !disabled && rowHoverClasses,\n )\n : stable.listItem;\n\n const actionsGroup = hasActions ? (\n <span\n role=\"group\"\n aria-labelledby={itemId}\n data-wave-nav-actions=\"\"\n className={cn(stable.actions, actionsClasses)}\n >\n {materialiseSlotContent(actions)}\n </span>\n ) : null;\n\n if (isLink) {\n return (\n <li className={listItemClassName}>\n <a\n {...(rest as React.AnchorHTMLAttributes<HTMLAnchorElement>)}\n {...idProps}\n {...rovingProps}\n ref={ref as React.Ref<HTMLAnchorElement>}\n href={disabled ? undefined : href}\n role={disabled ? 'link' : rest.role}\n aria-disabled={disabled ? true : rest['aria-disabled']}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </a>\n {actionsGroup}\n </li>\n );\n }\n\n // `rel` only belongs on a link: a button item drops it (React types it on every element).\n const { rel, ...buttonRest } = rest;\n return (\n <li className={listItemClassName}>\n <button\n type=\"button\"\n {...(buttonRest as React.ButtonHTMLAttributes<HTMLButtonElement>)}\n {...idProps}\n {...rovingProps}\n ref={ref as React.Ref<HTMLButtonElement>}\n disabled={disabled}\n aria-current={isSelected ? 'page' : undefined}\n onClick={handleClick}\n className={entryClassName}\n >\n {content}\n </button>\n {actionsGroup}\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Nav.Category\n// ---------------------------------------------------------------------------\n\n/**\n * A collapsible group of sub-items. Its toggle button shows `label` and reports `aria-expanded`\n * (and `aria-controls` while open); the sub-items render in a nested list while it is open.\n * Open state lives on `Nav` (`openCategories`/`defaultOpenCategories`).\n *\n * A closed category that contains the current item marks its toggle button with\n * `aria-current=\"true\"` (the button is not the page's link, so not `\"page\"`),\n * `data-contains-current` and the selected look of `Nav.Item`. It contains the current item when\n * a `Nav.SubItem` with the current value is among its children (through Fragments and wrapper\n * elements, also in the server HTML), when the current sub-item was last shown in it (and has not\n * moved among another category's children since), or when it is the Nav's `currentCategory`. An\n * open category is not marked: its sub-item shows the current page.\n *\n * Also exported as `NavCategory` (import the flat name from React Server Components).\n */\nconst NavCategory = ({\n value,\n label,\n icon,\n className,\n children,\n ref,\n ...rest\n}: NavCategoryProps) => {\n const context = useNavContext('Nav.Category');\n const roving = React.useContext(NavRovingContext);\n const {\n value: currentValue,\n openCategories,\n toggleCategory,\n currentCategory,\n categoryStore,\n } = context;\n useNavValue(context, 'category', value);\n const listId = useId('wave-nav-category');\n const isOpen = openCategories.includes(value);\n\n // The current sub-item is among the children of this closed category (also on the server).\n const holdsCurrentChild = !isOpen && currentValue !== '' && containsValue(children, currentValue);\n // The current sub-item was last shown in this category (none on the server).\n const holdsShownCurrent = React.useSyncExternalStore(\n categoryStore.subscribe,\n () => currentValue !== '' && categoryStore.get(currentValue) === value,\n () => false,\n );\n // Children that hold the current sub-item make this the category the Nav remembers for it, so a\n // category it was shown in before it moved here is no longer marked. The entry is forgotten when\n // they stop holding it (an open category records through its mounted sub-item instead).\n React.useLayoutEffect(() => {\n if (!holdsCurrentChild) return;\n categoryStore.record(currentValue, value);\n return () => categoryStore.forget(currentValue, value);\n }, [categoryStore, holdsCurrentChild, currentValue, value]);\n const containsCurrent =\n !isOpen && (currentCategory === value || holdsShownCurrent || holdsCurrentChild);\n // Inside an arrow-key body: whether this is a closed category that holds the current page (the\n // body's first Tab stop), before paint; nothing is reported in a plain Nav.\n React.useLayoutEffect(() => {\n if (!roving) return;\n roving.reportCurrentCategory(value, containsCurrent);\n return () => roving.reportCurrentCategory(value, false);\n }, [roving, value, containsCurrent]);\n // Development only: every child of the open list is an <li> (`Nav.Category:list-child`).\n const listRef = React.useRef<HTMLUListElement>(null);\n useNavListChildCheck(listRef, 'Nav.Category', 'sub-items');\n\n let buttonLabel: React.ReactNode = label;\n let items: React.ReactNode = children;\n if (label === undefined) {\n // Deprecated 0.4 path: the text children are the label, the other children the sub-items.\n warnDeprecated(\n 'Nav.Category',\n 'text children as the label',\n 'label',\n 'Pass the category label in `label` and only the sub-items as children.',\n );\n const parts = React.Children.toArray(children);\n const isText = (part: unknown) => typeof part === 'string' || typeof part === 'number';\n buttonLabel = parts.filter(isText).join('');\n items = parts.filter((part) => !isText(part));\n }\n\n return (\n <li ref={ref} {...rest} className={cn(navCategoryClassNames.root, className)}>\n <button\n type=\"button\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? listId : undefined}\n aria-current={containsCurrent ? true : undefined}\n data-contains-current={containsCurrent ? '' : undefined}\n data-roving-value={roving ? `wave-nav-category:${value}` : undefined}\n onClick={() => toggleCategory(value)}\n className={cn(navCategoryClassNames.button, categoryButtonClasses)}\n >\n {renderIcon(icon, navCategoryClassNames.icon)}\n <span className={cn(navCategoryClassNames.label, 'flex-1 text-start')}>{buttonLabel}</span>\n <ChevronDownIcon\n className={cn(\n navCategoryClassNames.expandIcon,\n 'shrink-0 transition-transform motion-reduce:transition-none',\n isOpen && 'rotate-180',\n )}\n />\n </button>\n {isOpen && (\n <NavCategoryValueContext.Provider value={value}>\n <ul\n ref={listRef}\n id={listId}\n className={cn(navCategoryClassNames.list, 'm-0 list-none p-0')}\n >\n {items}\n </ul>\n </NavCategoryValueContext.Provider>\n )}\n </li>\n );\n};\nNavCategory.displayName = 'NavCategory';\nmarkNavPart(NavCategory, 'category');\n\n// ---------------------------------------------------------------------------\n// Nav.Item / Nav.SubItem\n// ---------------------------------------------------------------------------\n\n/**\n * A top-level navigation entry: a link when `href` is given (anchor props), a button otherwise\n * (button props). Clicking selects it (`aria-current=\"page\"`); activating a disabled entry never\n * selects it (a disabled entry whose value is the current value still shows as current).\n *\n * A click that opens a link somewhere other than the current page selects nothing (the consumer's\n * `onClick` still runs, and the browser opens the link): Ctrl/Cmd/Shift/Alt-click, a mouse button\n * other than the main one, a `target` other than `_self`, or a `download` link. When the consumer's\n * `onClick` calls `preventDefault()` (client-side routing), the browser opens nothing, so the item\n * is selected whatever the keys, button or `target`.\n *\n * `actions` puts your own controls (a pin toggle, a menu button) beside the item in its row, in a\n * group named by the item; they never select it.\n *\n * Typed by overloads, resolved in order: without `href` (button props, button events), with a\n * string `href` (anchor props, anchor events), then an `href` that may be `undefined` at run time\n * ({@link NavItemDynamicProps}: events of either element).\n *\n * Also exported as `NavItem` (import the flat name from React Server Components).\n */\nfunction NavItem(props: NavItemButtonProps): React.ReactElement;\nfunction NavItem(props: NavItemAnchorProps): React.ReactElement;\nfunction NavItem(props: NavItemDynamicProps): React.ReactElement;\nfunction NavItem(props: NavItemProps | NavItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.Item');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n const roving = React.useContext(NavRovingContext);\n // Called always, rendered only while the item's actions render (D119).\n const generatedId = useId('wave-nav-item');\n return renderNavEntry(\n props as NavEntryProps,\n context,\n roving,\n itemClasses,\n {\n root: navItemClassNames.root,\n listItem: navItemClassNames.listItem,\n actions: navItemClassNames.actions,\n icon: navItemClassNames.icon,\n content: navItemClassNames.content,\n },\n true,\n generatedId,\n );\n}\nNavItem.displayName = 'NavItem';\nmarkNavPart(NavItem, 'entry');\n\n/**\n * An indented entry inside a `Nav.Category`: a link when `href` is given, a button otherwise.\n * Selected like `Nav.Item` (a click that the browser opens somewhere else selects nothing; one\n * whose default your `onClick` prevents is selected), and typed by overloads like `Nav.Item`\n * (button, link, then {@link NavSubItemDynamicProps}). Takes `actions` like `Nav.Item`.\n *\n * Also exported as `NavSubItem` (import the flat name from React Server Components).\n */\nfunction NavSubItem(props: NavSubItemButtonProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemAnchorProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemDynamicProps): React.ReactElement;\nfunction NavSubItem(props: NavSubItemProps | NavSubItemDynamicProps): React.ReactElement {\n const context = useNavContext('Nav.SubItem');\n useNavValue(context, 'item', props.value);\n useRecordCategory(context, props.value);\n const roving = React.useContext(NavRovingContext);\n // Called always, rendered only while the sub-item's actions render (D119).\n const generatedId = useId('wave-nav-item');\n return renderNavEntry(\n props as NavEntryProps,\n context,\n roving,\n subItemClasses,\n {\n root: navSubItemClassNames.root,\n listItem: navSubItemClassNames.listItem,\n actions: navSubItemClassNames.actions,\n },\n false,\n generatedId,\n );\n}\nNavSubItem.displayName = 'NavSubItem';\nmarkNavPart(NavSubItem, 'entry');\n\n/**\n * A vertical side navigation (`<nav>` landmark, default name \"Navigation\") with items, links and\n * collapsible categories.\n *\n * - **Selection**: `value`/`defaultValue`/`onValueChange` (`onValueChange` fires only when the\n * value changes). The deprecated `selectedValue`/`defaultSelectedValue`/`onNavItemSelect` still\n * work; `onNavItemSelect` keeps firing on every activation, re-selection included. A click that\n * opens a link in another tab or window (or downloads it) selects nothing, unless the item's\n * `onClick` prevents the default (client-side routing: then nothing opens elsewhere).\n * - **Categories**: `openCategories`/`defaultOpenCategories`/`onOpenCategoriesChange`. Without\n * `defaultOpenCategories`, the categories containing the selected item (`value` or\n * `defaultValue`) start open. A closed category that contains the selected item marks its toggle\n * (`aria-current=\"true\"`, `data-contains-current`, the selected look); pass `currentCategory`\n * for sub-items your own component renders inside a closed category.\n * - **Values** are unique: among the items and sub-items, and among the categories (a duplicate\n * warns in development).\n * - **Structure**: every child of the Nav, and of a category, is a part or your own `<li>`; a\n * development warning names anything else (a `<div>`, text, the wrapper of a Tooltip around an\n * item). `Nav.SectionHeader` is a heading between groups of items (`<h3>` unless\n * `headingLevel`, which stands for the `as` of Fluent's NavSectionHeader), and `Nav.Divider` a\n * line between groups, hidden from assistive technology (Fluent's NavDivider is a separator).\n * - **App identity**: `Nav.AppItem` shows the app's name and logo at the top, as a link with\n * `href` or a button; it is never selected. `Nav.AppItemStatic` shows them as plain text.\n * - **Item actions**: `actions` on `Nav.Item` and `Nav.SubItem` (Fluent's SplitNavItem) puts your\n * own controls beside the item, in a group named by it; each is a Tab stop after the item, and\n * none selects it. They are drawn while the row is hovered or has focus, while one is pressed or\n * has its menu open, and always on touch screens and in forced colours. With actions, a selected\n * item's background and indicator are drawn on its row (`.wave-nav-item__list-item`).\n *\n * Sub-components are also exported under flat names (`NavCategory`, `NavItem`, `NavSubItem`,\n * `NavSectionHeader`, `NavDivider`, `NavAppItem`, `NavAppItemStatic`): React Server Components\n * import those, because dotted access (`Nav.Item`) needs a client file.\n */\nexport const Nav = /* @__PURE__ */ Object.assign(NavRoot, {\n Category: NavCategory,\n Item: NavItem,\n SubItem: NavSubItem,\n SectionHeader: NavSectionHeader,\n Divider: NavDivider,\n AppItem: NavAppItem,\n AppItemStatic: NavAppItemStatic,\n});\n\nexport {\n NavCategory,\n NavItem,\n NavSubItem,\n NavSectionHeader,\n NavDivider,\n NavAppItem,\n NavAppItemStatic,\n};\n"],"mappings":"idA0PA,IAAMoC,EAAc,oDAQpB,SAASC,EACP,EACA,EAC2B,CAC3B,OAAOC,GAAQtC,EAAAA,mBAAmBsC,CAAI,EAClCrC,EAAAA,WAAWqC,EAAM,OAAQpC,EAAAA,GAAGqC,EAAWH,CAAW,EAAG,CAAE,cAAe,EAAK,CAAC,EAC5E,IACN,CAEA,IAAMI,EAAc,CAClB,KAAMtC,EAAAA,GACJ,+HACAC,EAAAA,eACAC,EAAAA,cACF,EACA,SAAU,4EACV,KAAM,uEAEN,cAAe,6BACf,YAAa,gDACf,EAEMqC,EAA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EAAA,YAAYuB,EAAS,OAAQF,EAAM,KAAK,EACxCrB,EAAA,kBAAkBuB,EAASF,EAAM,KAAK,EACtC,IAAMO,EAASnD,EAAM,WAAWC,EAAAA,gBAAgB,EAE1CsD,EAAcrD,EAAAA,MAAM,eAAe,EACzC,OAAOwC,EACLE,EACAE,EACAK,EACAnB,EACA,CACE,KAAMxB,EAAAA,kBAAkB,KACxB,SAAUA,EAAAA,kBAAkB,SAC5B,QAASA,EAAAA,kBAAkB,QAC3B,KAAMA,EAAAA,kBAAkB,KACxB,QAASA,EAAAA,kBAAkB,OAC7B,EACA,GACA+C,CACF,CACF,CACA,EAAQ,YAAc,UACtBhD,EAAAA,YAAYgF,EAAS,OAAO,EAa5B,SAASC,EAAW,EAAqE,CACvF,IAAM1C,EAAU/C,EAAAA,cAAc,aAAa,EAC3CwB,EAAA,YAAYuB,EAAS,OAAQF,EAAM,KAAK,EACxCrB,EAAA,kBAAkBuB,EAASF,EAAM,KAAK,EACtC,IAAMO,EAASnD,EAAM,WAAWC,EAAAA,gBAAgB,EAE1CsD,EAAcrD,EAAAA,MAAM,eAAe,EACzC,OAAOwC,EACLE,EACAE,EACAK,EACAlB,EACA,CACE,KAAMxB,EAAAA,qBAAqB,KAC3B,SAAUA,EAAAA,qBAAqB,SAC/B,QAASA,EAAAA,qBAAqB,OAChC,EACA,GACA8C,CACF,CACF,CACA,EAAW,YAAc,aACzBhD,EAAAA,YAAYiF,EAAY,OAAO,EAmC/B,IAAaC,EAAsB,OAAO,OAAO/E,EAAAA,QAAS,CACxD,SAAU2D,EACV,KAAMkB,EACN,QAASC,EACT,cAAe7E,EAAAA,iBACf,QAASC,EAAAA,WACT,QAASC,EAAAA,WACT,cAAeC,EAAAA,gBACjB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/children.cjs"),n=require("../../lib/dev.cjs");let r=require("react");r=e.__toESM(r,1);function i(){let e=new Map,t=new Set,n=()=>t.forEach(e=>e());return{record(t,r){(e.get(t)??null)!==r&&(r===null?e.delete(t):e.set(t,r),n())},forget(t,r){e.get(t)===r&&(e.delete(t),n())},get:t=>e.get(t),subscribe(e){return t.add(e),()=>{t.delete(e)}}}}var a=r.createContext(null);a.displayName=`NavContext`;var o=()=>{},s={value:``,select:o,openCategories:[],toggleCategory:o,registerValue:()=>o,currentCategory:void 0,categoryStore:{record:o,forget:o,get:()=>void 0,subscribe:()=>o}},c=r.createContext(null);c.displayName=`NavCategoryValueContext`;function l(e){return r.useContext(a)||(n.reportMissingContext(e,`Nav`),s)}function u(e,t,n){let{registerValue:i}=e;r.useEffect(()=>i(t,n),[i,t,n])}function d(e,t){let n=r.useContext(c),{categoryStore:i}=e;r.useLayoutEffect(()=>{i.record(t,n)},[i,t,n])}var f=r.createContext(null);f.displayName=`NavRovingContext`;var p=Symbol.for(`wave.navPart`);function m(e,t){return e[p]=t,e}function h(e){let n=t.getElementType(e,{suspend:!1});if(typeof n!=`function`&&typeof n!=`object`||n===null)return null;let r=n[p];return r===`entry`||r===`category`?r:null}function g(e){let{children:t}=e.props;return typeof t==`function`?void 0:t}function _(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&typeof e.then==`function`}function v(e,t){if(Array.isArray(e)){for(let n of e)v(n,t);return}try{r.Children.forEach(e,e=>{r.isValidElement(e)&&t(e)})}catch(e){if(!_(e))throw e}}function y(e,t){let n=!1;return v(e,e=>{n||=h(e)===`entry`&&e.props.value===t||y(g(e),t)}),n}function b(e,t){let n=[];if(!t)return n;let r=e=>{v(e,e=>{let i=g(e);h(e)===`category`&&typeof e.props.value==`string`&&y(i,t)&&n.push(e.props.value),r(i)})};return r(e),n}var x={items:`Use the Nav parts (Nav.Item, Nav.Category, Nav.SectionHeader, Nav.Divider, Nav.AppItem, Nav.AppItemStatic) as its children, or wrap your own content in an <li>.`,"sub-items":`Use Nav.SubItem, Nav.SectionHeader and Nav.Divider as its children, or wrap your own content in an <li>.`},S=new Set([`li`,`script`,`template`]);function C(e){for(let t of Array.from(e.childNodes))if(t.nodeType===Node.ELEMENT_NODE){let e=t.localName.toLowerCase();if(!S.has(e))return`a <${e}> element`}else if(t.nodeType===Node.TEXT_NODE&&(t.textContent??``).trim()!==``)return`text`;return null}function w(e,t,i){r.useEffect(()=>{if(!n.isDev)return;let r=`${t}:list-child`,a=e.current;if(!a||n.hasWarned(r))return;let o=C(a);o!==null&&n.warnOnce(r,`${t}: its list holds ${o}, but a list can hold only <li> elements. ${x[i]}`)})}exports.NavCategoryValueContext=c,exports.NavContext=a,exports.NavRovingContext=f,exports.containsValue=y,exports.createCategoryStore=i,exports.findCategoriesContaining=b,exports.getNavPartKind=h,exports.markNavPart=m,exports.useNavContext=l,exports.useNavListChildCheck=w,exports.useNavValue=u,exports.useRecordCategory=d;
|
|
2
|
+
//# sourceMappingURL=Nav.context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Nav.context.cjs","names":["React","getElementType","isDev","hasWarned","require_runtime","require_children","require_dev","react","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","componentName","useNavValue","context","registerValue","kind","useRecordCategory","categoryStore","NavRovingContext","NAV_PART","markNavPart","component","getNavPartKind","type","node","childrenOf","element","children","isThenable","forEachElement","nodes","visit","child","error","containsValue","found","selected","findCategoriesContaining","result","current","inner","LIST_CHILD_ADVICE","ALLOWED_LIST_CHILDREN","describeInvalidListChild","list","tag","useNavListChildCheck","key","owner","invalid","contents"],"sources":["../../../src/components/navigation/Nav.context.ts"],"sourcesContent":["import * as React from 'react';\nimport { getElementType } from '../../lib/children';\nimport { hasWarned, isDev, reportMissingContext, warnOnce } from '../../lib/dev';\n\n/*\n * The contexts of a Nav root (Nav, NavDrawer) and its parts: the root's state (`NavContext`), the\n * category a sub-item renders in and the roving bookkeeping of an arrow-key body; the category\n * store; the part markers and the children walks that find the current page; the development check\n * of a Nav list's children; and the link-only attributes mask of the button items. Internal; it\n * imports no component, so a root reaches the parts through their markers, never through an import.\n */\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\n/** The two value namespaces of a Nav: items (Nav.Item and Nav.SubItem) and categories. */\nexport type NavValueKind = 'item' | 'category';\n\n/**\n * The category each sub-item was last shown in, by sub-item value: written from layout effects by\n * the mounted sub-items and by a closed category whose children hold the current value, read by\n * the categories with `useSyncExternalStore`. An entry outlives its sub-item, so a category closed\n * after its current sub-item was shown still knows it contains the current page.\n */\nexport interface NavCategoryStore {\n /**\n * Records the category a mounted item renders in, or a closed category whose children hold the\n * value; `null` (an item outside any category) forgets an earlier entry, so a value moved out of\n * a category no longer marks it.\n */\n record(value: string, category: string | null): void;\n /** Forgets the entry of `value` while it is still `category`. */\n forget(value: string, category: string): void;\n /** The category last recorded for a sub-item value. */\n get(value: string): string | undefined;\n /** Subscribes to every change of an entry; returns the unsubscribe function. */\n subscribe(listener: () => void): () => void;\n}\n\n/** A new, empty category store (one per Nav root, created once). */\nexport function createCategoryStore(): NavCategoryStore {\n const categories = new Map<string, string>();\n const listeners = new Set<() => void>();\n const notify = () => listeners.forEach((listener) => listener());\n return {\n record(value, category) {\n if ((categories.get(value) ?? null) === category) return;\n if (category === null) categories.delete(value);\n else categories.set(value, category);\n notify();\n },\n forget(value, category) {\n if (categories.get(value) !== category) return;\n categories.delete(value);\n notify();\n },\n get: (value) => categories.get(value),\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\n/** The context a Nav root (Nav, NavDrawer) provides to its parts (0.10's fields, unchanged). */\nexport interface NavContextValue {\n /** The selected item value (`''` when nothing is selected). */\n value: string;\n /**\n * Activation of an item: sets the value, then calls the root's `onActivate` (every activation,\n * re-selection included; Nav's deprecated `onNavItemSelect`).\n */\n select: (value: string) => void;\n /** The values of the open categories. */\n openCategories: readonly string[];\n /** Opens a closed category, closes an open one. */\n toggleCategory: (value: string) => void;\n /** Registers a mounted item or category value (duplicate warning); returns the cleanup. */\n registerValue: (kind: NavValueKind, value: string) => () => void;\n /** The `currentCategory` hint of the root. */\n currentCategory: string | undefined;\n /** The categories the sub-items were last shown in. */\n categoryStore: NavCategoryStore;\n}\n\n/** The state of the Nav root around a part (`null` outside one). */\nexport const NavContext = React.createContext<NavContextValue | null>(null);\nNavContext.displayName = 'NavContext';\n\nconst noop = () => {};\nconst INERT_NAV_CONTEXT: NavContextValue = {\n value: '',\n select: noop,\n openCategories: [],\n toggleCategory: noop,\n registerValue: () => noop,\n currentCategory: undefined,\n categoryStore: { record: noop, forget: noop, get: () => undefined, subscribe: () => noop },\n};\n\n/**\n * The value of the Nav.Category a sub-item renders in (`null` outside a category). It renders no\n * element; a sub-item outside a category is valid, so there is no missing-context error.\n */\nexport const NavCategoryValueContext = React.createContext<string | null>(null);\nNavCategoryValueContext.displayName = 'NavCategoryValueContext';\n\n/**\n * The Nav root's context for the part `componentName` (C-CONTEXT): outside a Nav it throws\n * `[WaveUI] <componentName> must be used within Nav` in development, and in production logs once\n * and returns an inert value.\n */\nexport function useNavContext(componentName: string): NavContextValue {\n const context = React.useContext(NavContext);\n if (context) return context;\n reportMissingContext(componentName, 'Nav');\n return INERT_NAV_CONTEXT;\n}\n\n/** Registers the value of a mounted item or category, so the root can warn about duplicates. */\nexport function useNavValue(context: NavContextValue, kind: NavValueKind, value: string): void {\n const { registerValue } = context;\n React.useEffect(() => registerValue(kind, value), [registerValue, kind, value]);\n}\n\n/**\n * Records the category a mounted item renders in, which the category reads once closed (`null`\n * outside a category, which forgets a stale entry for the value).\n */\nexport function useRecordCategory(context: NavContextValue, value: string): void {\n const category = React.useContext(NavCategoryValueContext);\n const { categoryStore } = context;\n React.useLayoutEffect(() => {\n categoryStore.record(value, category);\n }, [categoryStore, value, category]);\n}\n\n// ---------------------------------------------------------------------------\n// Roving bookkeeping (an arrow-key body)\n// ---------------------------------------------------------------------------\n\n/** What an arrow-key body (NavDrawer.Body `focusMode=\"arrow\"`) gives the Nav parts inside it. */\nexport interface NavRovingContextValue {\n /**\n * Called by every Nav.Category from a layout effect keyed on `[context, value, containsCurrent]`:\n * `(value, true)` while it is a closed category that holds the current page, `(value, false)`\n * when it stops being one and in the effect's cleanup (an unmount, StrictMode's double mount).\n * Must be stable (memoised by the provider).\n */\n reportCurrentCategory: (category: string, holdsCurrent: boolean) => void;\n}\n\n/**\n * Provided (non-null) inside an arrow-key body: every Nav.Item and Nav.SubItem renders\n * `data-roving-value={value}` on its link or button (after the consumer's attributes: the\n * bookkeeping wins), and every category toggle `data-roving-value={'wave-nav-category:' + value}`\n * (stable, also while open), and reports as {@link NavRovingContextValue} says. `null` (the\n * default, every plain Nav): nothing is rendered or reported, so a Nav's server HTML is 0.10's.\n */\nexport const NavRovingContext = React.createContext<NavRovingContextValue | null>(null);\nNavRovingContext.displayName = 'NavRovingContext';\n\n// ---------------------------------------------------------------------------\n// Part markers and the children walks\n// ---------------------------------------------------------------------------\n\n/** What a marked Nav part is to the walks: an entry (Nav.Item, Nav.SubItem) or a category. */\nexport type NavPartKind = 'entry' | 'category';\n\n/**\n * The marker property of a Nav part, read only by {@link getNavPartKind}. A registry symbol\n * (`Symbol.for`), as Field's label marker (`fieldLabel.ts`): the ESM and CJS copies of the package\n * share it, so a part marked by one copy is recognised by the other.\n */\nconst NAV_PART: symbol = Symbol.for('wave.navPart');\n\n/**\n * Marks `component` as a Nav part of `kind`, so the walks of a Nav root recognise its elements\n * without importing it; call it next to `displayName`. Returns `component`.\n */\nexport function markNavPart<T extends object>(component: T, kind: NavPartKind): T {\n (component as Record<symbol, unknown>)[NAV_PART] = kind;\n return component;\n}\n\n/**\n * The kind of Nav part `node` is an element of, or `null` for anything else. The type is resolved\n * with `getElementType(node, { suspend: false })`: a lazy client reference (a part written in a\n * Server Component) is recognised, and a lazy type still loading is no part (it never suspends).\n */\nexport function getNavPartKind(node: React.ReactNode): NavPartKind | null {\n const type = getElementType(node, { suspend: false });\n if ((typeof type !== 'function' && typeof type !== 'object') || type === null) return null;\n const kind = (type as Record<symbol, unknown>)[NAV_PART];\n return kind === 'entry' || kind === 'category' ? kind : null;\n}\n\ntype ElementWithChildren = React.ReactElement<{ value?: unknown; children?: React.ReactNode }>;\n\nfunction childrenOf(element: ElementWithChildren): React.ReactNode {\n const { children } = element.props;\n return typeof children === 'function' ? undefined : children;\n}\n\n/** Whether a thrown value suspends rendering (a loading lazy chunk, a pending promise). */\nfunction isThenable(value: unknown): boolean {\n return (\n (typeof value === 'object' || typeof value === 'function') &&\n value !== null &&\n typeof (value as { then?: unknown }).then === 'function'\n );\n}\n\n/*\n * The walks below run during the render of a Nav root and of a category, and reach consumer\n * content at any depth. Content that is still loading inside the consumer's own <Suspense> (a\n * promise child, a lazy node, a `React.lazy` component) suspends that boundary when React renders\n * it; walking it must never suspend the Nav itself, which would hide the whole Nav behind an outer\n * boundary. So a child that cannot be read yet is skipped, and a lazy type that is still loading is\n * not a part (its children are still walked). Parts written in a Server Component arrive as loaded\n * client references and are recognized.\n */\n\n/** Calls `visit` with each element of `nodes` (as `React.Children.forEach`), skipping pending ones. */\nfunction forEachElement(nodes: React.ReactNode, visit: (child: ElementWithChildren) => void): void {\n if (Array.isArray(nodes)) {\n for (const node of nodes as React.ReactNode[]) forEachElement(node, visit);\n return;\n }\n try {\n React.Children.forEach(nodes, (child) => {\n if (React.isValidElement<ElementWithChildren['props']>(child)) visit(child);\n });\n } catch (error) {\n if (!isThenable(error)) throw error;\n }\n}\n\n/**\n * Whether `nodes` contain a Nav.Item/Nav.SubItem element with `value === selected` (parts written\n * in a Server Component, lazy client references, included). Called during render only; never\n * suspends.\n */\nexport function containsValue(nodes: React.ReactNode, selected: string): boolean {\n let found = false;\n forEachElement(nodes, (child) => {\n if (found) return;\n if (getNavPartKind(child) === 'entry' && child.props.value === selected) {\n found = true;\n } else {\n found = containsValue(childrenOf(child), selected);\n }\n });\n return found;\n}\n\n/** The values of the Nav.Category elements (at any depth of JSX) that contain `selected`. */\nexport function findCategoriesContaining(nodes: React.ReactNode, selected: string): string[] {\n const result: string[] = [];\n if (!selected) return result;\n const visit = (current: React.ReactNode) => {\n forEachElement(current, (child) => {\n const inner = childrenOf(child);\n if (\n getNavPartKind(child) === 'category' &&\n typeof child.props.value === 'string' &&\n containsValue(inner, selected)\n ) {\n result.push(child.props.value);\n }\n visit(inner);\n });\n };\n visit(nodes);\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// The list-child check\n// ---------------------------------------------------------------------------\n\n/** The advice of the list-child warning, by what the list holds. */\nconst LIST_CHILD_ADVICE = {\n items:\n 'Use the Nav parts (Nav.Item, Nav.Category, Nav.SectionHeader, Nav.Divider, Nav.AppItem, Nav.AppItemStatic) as its children, or wrap your own content in an <li>.',\n 'sub-items':\n 'Use Nav.SubItem, Nav.SectionHeader and Nav.Divider as its children, or wrap your own content in an <li>.',\n} as const;\n\n/** Element children a list may hold besides `<li>`: script-supporting elements (React's streaming placeholders). */\nconst ALLOWED_LIST_CHILDREN = new Set(['li', 'script', 'template']);\n\n/**\n * What the first child node of `list` that a list cannot hold is (`a <div> element`, `text`), or\n * `null` when every child is an `<li>`, a script-supporting element, whitespace text or a comment.\n */\nfunction describeInvalidListChild(list: HTMLElement): string | null {\n for (const node of Array.from(list.childNodes)) {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const tag = (node as Element).localName.toLowerCase();\n if (!ALLOWED_LIST_CHILDREN.has(tag)) return `a <${tag}> element`;\n } else if (node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim() !== '') {\n return 'text';\n }\n }\n return null;\n}\n\n/**\n * Development only: after every commit of the calling component, warns once per `owner`\n * (`${owner}:list-child`) at the first child node of `list` that is neither an `<li>`, `<script>`\n * nor `<template>` element nor whitespace text (comments, and the nothing that `null`, Fragments\n * and Suspense boundaries render, never warn). `contents` picks the advice: `'items'` the Nav\n * parts, `'sub-items'` Nav.SubItem, Nav.SectionHeader and Nav.Divider.\n */\nexport function useNavListChildCheck(\n list: React.RefObject<HTMLUListElement | null>,\n owner: string,\n contents: 'items' | 'sub-items',\n): void {\n React.useEffect(() => {\n if (!isDev) return;\n const key = `${owner}:list-child`;\n const element = list.current;\n if (!element || hasWarned(key)) return;\n const invalid = describeInvalidListChild(element);\n if (invalid === null) return;\n warnOnce(\n key,\n `${owner}: its list holds ${invalid}, but a list can hold only <li> elements. ${LIST_CHILD_ADVICE[contents]}`,\n );\n });\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * The attributes only a link has (`target`, `download`, `hrefLang`, `ping`, …). Button items\n * declare them as `undefined`, so they are a type error without `href` instead of landing on the\n * `<button>`. `rel` cannot be listed (React types it on every element, RDFa); a button item drops\n * it at run time instead.\n */\nexport type NoAnchorOnlyAttributes = {\n [\n K in Exclude<\n keyof React.AnchorHTMLAttributes<HTMLAnchorElement>,\n keyof React.ButtonHTMLAttributes<HTMLButtonElement>\n >\n ]?: undefined;\n};\n"],"mappings":"gLAyCA,SAAgBQ,GAAwC,CACtD,IAAMC,EAAa,IAAI,IACjBC,EAAY,IAAI,IAChBC,MAAeD,EAAU,QAAS,GAAaE,EAAS,CAAC,EAC/D,MAAO,CACL,OAAO,EAAO,EAAU,EACjBH,EAAW,IAAII,CAAK,GAAK,QAAUC,IACpCA,IAAa,KAAML,EAAW,OAAOI,CAAK,EACzCJ,EAAW,IAAII,EAAOC,CAAQ,EACnCH,EAAO,EACT,EACA,OAAO,EAAO,EAAU,CAClBF,EAAW,IAAII,CAAK,IAAMC,IAC9BL,EAAW,OAAOI,CAAK,EACvBF,EAAO,EACT,EACA,IAAM,GAAUF,EAAW,IAAII,CAAK,EACpC,UAAU,EAAU,CAElB,OADAH,EAAU,IAAIE,CAAQ,MACT,CACXF,EAAU,OAAOE,CAAQ,CAC3B,CACF,CACF,CACF,CAwBA,IAAaG,EAAaf,EAAM,cAAsC,IAAI,EAC1E,EAAW,YAAc,aAEzB,IAAMgB,MAAa,CAAC,EACdC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