@mortenbrudvik/waveui 0.10.0 → 0.11.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 +357 -72
- 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/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 +213 -181
- package/dist/components/feedback/Toaster.mjs.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/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.mjs +16 -11
- 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 +416 -0
- package/dist/components/input/TagPicker.root.mjs.map +1 -0
- 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/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 +190 -125
- 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/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/useModalLayer.cjs +1 -1
- package/dist/hooks/useModalLayer.cjs.map +1 -1
- package/dist/hooks/useModalLayer.mjs +35 -22
- package/dist/hooks/useModalLayer.mjs.map +1 -1
- 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/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +102 -78
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2226 -221
- package/dist/index.d.ts +2226 -221
- package/dist/index.mjs +115 -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 +53 -47
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hamburger.mjs","names":["React","GLYPH_SIZES","Hamburger","rest","drawer","NavDrawerContext","iconButton","unwrapButtonGlyph","icon","glyphRenders","slotRendersContent","glyph","iconEmpty","warnOnce","label","materialiseSlotContent","children","named","toggle","event","stateProps","Button","withPartClass","NavigationIcon","size","hamburgerClassNames","composeEventHandlers","onClick","cn","className"],"sources":["../../../src/components/navigation/Hamburger.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport { hamburgerClassNames } from '../../lib/classNames';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport { warnOnce } from '../../lib/dev';\nimport { NavigationIcon } from '../../lib/icons';\nimport { materialiseSlotContent, slotRendersContent, type Slot } from '../../lib/slot';\nimport type { Appearance, Size } from '../../lib/types';\nimport { Button } from '../button/Button';\nimport { unwrapButtonGlyph, withPartClass } from '../button/Button.slots';\nimport { NavDrawerContext } from './NavDrawer.context';\n\n/*\n * Hamburger: a Button with the navigation glyph that toggles the NavDrawer it sits in. Reads only\n * the NavDrawer's context module (never `NavDrawer.tsx`), so it holds no drawer machinery.\n */\n\n/** Properties for the Hamburger component. */\nexport interface HamburgerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * Visual style. Fluent's `transparent` look is WaveUI's `subtle` (WaveUI's `transparent` is\n * link-coloured).\n * @default 'subtle'\n */\n appearance?: Appearance;\n /**\n * Size: the button's height and the glyph (12, 16, 20, 24 or 28px).\n * @default 'medium'\n */\n size?: Size;\n /**\n * Replaces the navigation glyph (three bars). Decorative (`aria-hidden`). Unlike Button's `icon`,\n * a Hamburger always shows a glyph: `null`, `undefined` and a value that renders nothing keep\n * the default (the last warns in development). A `<button>` or `Button` passed here is not\n * nested: its children become the glyph and its props are dropped, with a warning.\n */\n icon?: Slot<'span'>;\n /**\n * The button's name. Without `aria-label`, `aria-labelledby`, `title` or a visible label\n * (children), the Hamburger is named \"Navigation\"; localize it here. The name stays the same\n * while the drawer opens and closes (the state is `aria-expanded`).\n * @default 'Navigation'\n */\n 'aria-label'?: string;\n /**\n * Unavailable but focusable (see `Button.disabledFocusable`): no toggle, no `onClick`.\n * @default false\n */\n disabledFocusable?: boolean;\n /** Ref to the `<button>`. */\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n/** The default glyph's size per button size. */\nconst GLYPH_SIZES: Readonly<Record<Size, number>> = {\n 'extra-small': 12,\n small: 16,\n medium: 20,\n large: 24,\n 'extra-large': 28,\n};\n\n/**\n * A button that opens and closes a navigation drawer: a `Button` (`subtle`, icon-only) with the\n * navigation glyph, named \"Navigation\" by default. Inside a `NavDrawer` (in its header) it toggles\n * that drawer and reports it with `aria-expanded` and `aria-controls`. Elsewhere (your page\n * header) it is a plain button: pass `aria-expanded={open}`, `aria-controls` (while the drawer's\n * panel is rendered) and, for an overlay drawer, `aria-haspopup=\"dialog\"`, and toggle your state\n * in `onClick`. Fluent's `Hamburger`.\n *\n * @example\n * <Hamburger\n * aria-expanded={open}\n * aria-controls={open ? 'main-nav' : undefined}\n * aria-haspopup=\"dialog\"\n * onClick={() => setOpen(!open)}\n * />\n */\nexport const Hamburger = ({\n appearance = 'subtle',\n size = 'medium',\n icon,\n onClick,\n className,\n children,\n ref,\n ...rest\n}: HamburgerProps) => {\n const drawer = React.useContext(NavDrawerContext);\n\n // A required indicator (C-SLOTS): a button passed as `icon` is unwrapped, never nested, and a\n // value that renders nothing keeps the default glyph.\n const { glyph, button: iconButton } = unwrapButtonGlyph(icon);\n const glyphRenders = slotRendersContent(glyph);\n // An unwrapped button reports its own warning only.\n const iconEmpty = iconButton === null && icon != null && !glyphRenders;\n React.useEffect(() => {\n if (iconEmpty) {\n warnOnce(\n 'Hamburger:icon-empty',\n 'Hamburger: `icon` renders nothing, so the default navigation glyph shows. Unlike `Button`, a Hamburger always shows a glyph: pass an icon, or leave `icon` unset.',\n );\n }\n }, [iconEmpty]);\n React.useEffect(() => {\n if (iconButton) {\n warnOnce(\n 'Hamburger:icon-button',\n `Hamburger: \\`icon\\` received ${iconButton}; its children render as the glyph and its props were dropped (buttons cannot be nested). Pass icon content instead, e.g. \\`icon={<MyIcon />}\\`.`,\n );\n }\n }, [iconButton]);\n\n // The default name, while nothing else names the button. A generator label is read once; its\n // items are what renders.\n const label = materialiseSlotContent(children);\n const named =\n Boolean(rest['aria-label']) ||\n Boolean(rest['aria-labelledby']) ||\n Boolean(rest.title) ||\n slotRendersContent(label);\n\n // Inside a NavDrawer: the toggle, after the consumer's onClick (`preventDefault()` skips it). A\n // click that bubbles through the React tree from a portal opened inside it is not its own\n // (C-COMPOSE).\n const toggle = drawer\n ? (event: React.MouseEvent<HTMLButtonElement>) => {\n if (!(event.target instanceof Node) || !event.currentTarget.contains(event.target)) return;\n drawer.requestOpen(!drawer.open, { reason: 'trigger', event: event.nativeEvent });\n }\n : undefined;\n // The drawer's state wins over a consumer's (the modal triggers' rule); no `aria-haspopup`, as\n // the Hamburger is inside the surface it toggles.\n const stateProps = drawer\n ? {\n 'aria-expanded': drawer.open,\n 'aria-controls': drawer.panelId,\n 'aria-haspopup': undefined,\n }\n : undefined;\n\n return (\n <Button\n {...rest}\n aria-label={named ? rest['aria-label'] : 'Navigation'}\n {...stateProps}\n ref={ref}\n appearance={appearance}\n size={size}\n icon={withPartClass(\n glyphRenders ? glyph : <NavigationIcon size={GLYPH_SIZES[size]} />,\n hamburgerClassNames.icon,\n )}\n onClick={composeEventHandlers(onClick, toggle)}\n className={cn(hamburgerClassNames.root, className)}\n >\n {label}\n </Button>\n );\n};\nHamburger.displayName = 'Hamburger';\n"],"mappings":";;;;;;;;;;;;;AAsDA,IAAMC,IAA8C;CAClD,eAAe;CACf,OAAO;CACP,QAAQ;CACR,OAAO;CACP,eAAe;AACjB,GAkBaC,KAAa,EACxB,gBAAa,UACb,UAAO,UACP,SACA,YACA,cACA,aACA,QACA,GAAGC,QACiB;CACpB,IAAMC,IAASJ,EAAM,WAAWK,CAAgB,GAI1C,EAAE,UAAO,QAAQC,MAAeC,EAAkBC,CAAI,GACtDC,IAAeC,EAAmBC,CAAK,GAEvCC,IAAYN,MAAe,QAAQE,KAAQ,QAAQ,CAACC;CAS1D,AARAT,EAAM,gBAAgB;EACpB,AAAIY,KACFC,EACE,wBACA,mKACF;CAEJ,GAAG,CAACD,CAAS,CAAC,GACdZ,EAAM,gBAAgB;EACpB,AAAIM,KACFO,EACE,yBACA,gCAAgCP,EAAW,iJAC7C;CAEJ,GAAG,CAACA,CAAU,CAAC;CAIf,IAAMQ,IAAQC,EAAuBC,CAAQ,GACvCC,IACJ,EAAQd,EAAK,iBACb,EAAQA,EAAK,sBACb,EAAQA,EAAK,SACbO,EAAmBI,CAAK,GAKpBI,IAASd,KACV,MAA+C;EAC9C,AAAMe,EAAM,kBAAkB,QAAUA,EAAM,cAAc,SAASA,EAAM,MAAM,KACjFf,EAAO,YAAY,CAACA,EAAO,MAAM;GAAE,QAAQ;GAAW,OAAOe,EAAM;EAAY,CAAC;CAClF,IACA,KAAA,GAGEC,IAAahB,IACf;EACE,iBAAiBA,EAAO;EACxB,iBAAiBA,EAAO;EACxB,iBAAiB,KAAA;CACnB,IACA,KAAA;CAEJ,OACE,kBAACiB,GAAD;EACE,GAAIlB;EACJ,cAAYc,IAAQd,EAAK,gBAAgB;EACzC,GAAIiB;EACC;EACO;EACN;EACN,MAAME,EACJb,IAAeE,IAAQ,kBAACY,GAAD,EAAgB,MAAMtB,EAAYuB,GAAQ,CAAA,GACjEC,EAAoB,IACtB;EACA,SAASC,EAAqBC,GAAST,CAAM;EAC7C,WAAWU,EAAGH,EAAoB,MAAMI,CAAS;EAEhD,UAAAf;CACK,CAAA;AAEZ;AACA,EAAU,cAAc"}
|
|
@@ -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, NavS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AAIC,EAAKC,CAAK,EACjBA,EAAQ,GAAG7F,EAAmBC,EAAMwF,CAAK,MAChC,CACX,IAAMK,GAAaH,EAAO,IAAIC,CAAG,GAAK,GAAK,EACvCE,EAAY,EAAGH,EAAO,IAAIC,EAAKE,CAAS,EACvCH,EAAO,OAAOC,CAAG,CACxB,CACF,EAAG,CAAC,CAAC,EAEC,CAACtF,GAAiBjD,EAAM,SAAS8B,CAAmB,EAEpD4G,EAAe1I,EAAM,aAClB,CACL,QACA,SACA,iBACA,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,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AaC,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,EAA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AM,YAC1B,OAAOA,EAAM,MAAM,OAAU,UAC7BE,EAAcM,EAAOJ,CAAQ,GAE7BE,EAAO,KAAKN,EAAM,MAAM,KAAK,EAE/BD,EAAMS,CAAK,CACb,CAAC,CACH,EAEA,OADAT,EAAMD,CAAK,EACJQ,CACT,CAOA,IAAMG,EAAoB,CACxB,MACE,mKACF,YACE,0GACJ,EAGMC,EAAwB,IAAI,IAAI,CAAC,KAAM,SAAU,UAAU,CAAC,EAMlE,SAASC,EAAyB,EAAkC,CAClE,IAAK,IAAMnB,KAAQ,MAAM,KAAKoB,EAAK,UAAU,EAC3C,GAAIpB,EAAK,WAAa,KAAK,aAAc,CACvC,IAAMqB,EAAOrB,EAAiB,UAAU,YAAY,EACpD,GAAI,CAACkB,EAAsB,IAAIG,CAAG,EAAG,MAAO,MAAMA,EAAI,UACxD,MAAO,GAAIrB,EAAK,WAAa,KAAK,YAAcA,EAAK,aAAe,GAAA,CAAI,KAAK,IAAM,GACjF,MAAO,OAGX,OAAO,IACT,CASA,SAAgBsB,EACd,EACA,EACA,EACM,CACNhD,EAAM,cAAgB,CACpB,GAAI,CAACL,EAAAA,MAAO,OACZ,IAAMsD,EAAM,GAAGC,EAAM,aACftB,EAAUkB,EAAK,QACrB,GAAI,CAAClB,GAAWhC,EAAAA,UAAUqD,CAAG,EAAG,OAChC,IAAME,EAAUN,EAAyBjB,CAAO,EAC5CuB,IAAY,MAChBpD,EAAA,SACEkD,EACA,GAAGC,EAAM,mBAAmBC,EAAQ,4CAA4CR,EAAkBS,IACpG,CACF,CAAC,CACH"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getElementType as e } from "../../lib/children.mjs";
|
|
3
|
+
import { hasWarned as t, isDev as n, reportMissingContext as r, warnOnce as i } from "../../lib/dev.mjs";
|
|
4
|
+
import * as a from "react";
|
|
5
|
+
//#region src/components/navigation/Nav.context.ts
|
|
6
|
+
function o() {
|
|
7
|
+
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = () => t.forEach((e) => e());
|
|
8
|
+
return {
|
|
9
|
+
record(t, r) {
|
|
10
|
+
(e.get(t) ?? null) !== r && (r === null ? e.delete(t) : e.set(t, r), n());
|
|
11
|
+
},
|
|
12
|
+
forget(t, r) {
|
|
13
|
+
e.get(t) === r && (e.delete(t), n());
|
|
14
|
+
},
|
|
15
|
+
get: (t) => e.get(t),
|
|
16
|
+
subscribe(e) {
|
|
17
|
+
return t.add(e), () => {
|
|
18
|
+
t.delete(e);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var s = a.createContext(null);
|
|
24
|
+
s.displayName = "NavContext";
|
|
25
|
+
var c = () => {}, l = {
|
|
26
|
+
value: "",
|
|
27
|
+
select: c,
|
|
28
|
+
openCategories: [],
|
|
29
|
+
toggleCategory: c,
|
|
30
|
+
registerValue: () => c,
|
|
31
|
+
currentCategory: void 0,
|
|
32
|
+
categoryStore: {
|
|
33
|
+
record: c,
|
|
34
|
+
forget: c,
|
|
35
|
+
get: () => void 0,
|
|
36
|
+
subscribe: () => c
|
|
37
|
+
}
|
|
38
|
+
}, u = a.createContext(null);
|
|
39
|
+
u.displayName = "NavCategoryValueContext";
|
|
40
|
+
function d(e) {
|
|
41
|
+
return a.useContext(s) || (r(e, "Nav"), l);
|
|
42
|
+
}
|
|
43
|
+
function f(e, t, n) {
|
|
44
|
+
let { registerValue: r } = e;
|
|
45
|
+
a.useEffect(() => r(t, n), [
|
|
46
|
+
r,
|
|
47
|
+
t,
|
|
48
|
+
n
|
|
49
|
+
]);
|
|
50
|
+
}
|
|
51
|
+
function p(e, t) {
|
|
52
|
+
let n = a.useContext(u), { categoryStore: r } = e;
|
|
53
|
+
a.useLayoutEffect(() => {
|
|
54
|
+
r.record(t, n);
|
|
55
|
+
}, [
|
|
56
|
+
r,
|
|
57
|
+
t,
|
|
58
|
+
n
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
var m = a.createContext(null);
|
|
62
|
+
m.displayName = "NavRovingContext";
|
|
63
|
+
var h = Symbol.for("wave.navPart");
|
|
64
|
+
function g(e, t) {
|
|
65
|
+
return e[h] = t, e;
|
|
66
|
+
}
|
|
67
|
+
function _(t) {
|
|
68
|
+
let n = e(t, { suspend: !1 });
|
|
69
|
+
if (typeof n != "function" && typeof n != "object" || n === null) return null;
|
|
70
|
+
let r = n[h];
|
|
71
|
+
return r === "entry" || r === "category" ? r : null;
|
|
72
|
+
}
|
|
73
|
+
function v(e) {
|
|
74
|
+
let { children: t } = e.props;
|
|
75
|
+
return typeof t == "function" ? void 0 : t;
|
|
76
|
+
}
|
|
77
|
+
function y(e) {
|
|
78
|
+
return (typeof e == "object" || typeof e == "function") && e !== null && typeof e.then == "function";
|
|
79
|
+
}
|
|
80
|
+
function b(e, t) {
|
|
81
|
+
if (Array.isArray(e)) {
|
|
82
|
+
for (let n of e) b(n, t);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
a.Children.forEach(e, (e) => {
|
|
87
|
+
a.isValidElement(e) && t(e);
|
|
88
|
+
});
|
|
89
|
+
} catch (e) {
|
|
90
|
+
if (!y(e)) throw e;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function x(e, t) {
|
|
94
|
+
let n = !1;
|
|
95
|
+
return b(e, (e) => {
|
|
96
|
+
n ||= _(e) === "entry" && e.props.value === t || x(v(e), t);
|
|
97
|
+
}), n;
|
|
98
|
+
}
|
|
99
|
+
function S(e, t) {
|
|
100
|
+
let n = [];
|
|
101
|
+
if (!t) return n;
|
|
102
|
+
let r = (e) => {
|
|
103
|
+
b(e, (e) => {
|
|
104
|
+
let i = v(e);
|
|
105
|
+
_(e) === "category" && typeof e.props.value == "string" && x(i, t) && n.push(e.props.value), r(i);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return r(e), n;
|
|
109
|
+
}
|
|
110
|
+
var C = {
|
|
111
|
+
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>.",
|
|
112
|
+
"sub-items": "Use Nav.SubItem, Nav.SectionHeader and Nav.Divider as its children, or wrap your own content in an <li>."
|
|
113
|
+
}, w = /* @__PURE__ */ new Set([
|
|
114
|
+
"li",
|
|
115
|
+
"script",
|
|
116
|
+
"template"
|
|
117
|
+
]);
|
|
118
|
+
function T(e) {
|
|
119
|
+
for (let t of Array.from(e.childNodes)) if (t.nodeType === Node.ELEMENT_NODE) {
|
|
120
|
+
let e = t.localName.toLowerCase();
|
|
121
|
+
if (!w.has(e)) return `a <${e}> element`;
|
|
122
|
+
} else if (t.nodeType === Node.TEXT_NODE && (t.textContent ?? "").trim() !== "") return "text";
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function E(e, r, o) {
|
|
126
|
+
a.useEffect(() => {
|
|
127
|
+
if (!n) return;
|
|
128
|
+
let a = `${r}:list-child`, s = e.current;
|
|
129
|
+
if (!s || t(a)) return;
|
|
130
|
+
let c = T(s);
|
|
131
|
+
c !== null && i(a, `${r}: its list holds ${c}, but a list can hold only <li> elements. ${C[o]}`);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { u as NavCategoryValueContext, s as NavContext, m as NavRovingContext, x as containsValue, o as createCategoryStore, S as findCategoriesContaining, _ as getNavPartKind, g as markNavPart, d as useNavContext, E as useNavListChildCheck, f as useNavValue, p as useRecordCategory };
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=Nav.context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Nav.context.mjs","names":["React","createCategoryStore","categories","listeners","notify","listener","value","category","NavContext","noop","INERT_NAV_CONTEXT","NavCategoryValueContext","useNavContext","reportMissingContext","componentName","useNavValue","context","registerValue","kind","useRecordCategory","categoryStore","NavRovingContext","NAV_PART","markNavPart","component","getNavPartKind","type","getElementType","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","isDev","key","owner","hasWarned","invalid","warnOnce","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":";;;;;AAyCA,SAAgBC,IAAwC;CACtD,IAAMC,oBAAa,IAAI,IAAoB,GACrCC,oBAAY,IAAI,IAAgB,GAChCC,UAAeD,EAAU,SAAS,MAAaE,EAAS,CAAC;CAC/D,OAAO;EACL,OAAO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