@nswds/ui 4.7.0 → 4.7.1
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 +23 -4
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/expandable-search.js +2 -2
- package/dist/components/expandable-search.js.map +1 -1
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/footer.js +11 -8
- package/dist/components/footer.js.map +1 -1
- package/dist/components/header.js +9 -6
- package/dist/components/header.js.map +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/link.js +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/main-nav.js +4 -4
- package/dist/components/main-nav.js.map +1 -1
- package/dist/components/navigation-menu.js +7 -7
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/push-menu.d.ts +5 -5
- package/dist/components/push-menu.js +2 -2
- package/dist/components/push-menu.js.map +1 -1
- package/dist/components/side-nav.js +5 -5
- package/dist/components/side-nav.js.map +1 -1
- package/dist/components/site-search.js +2 -2
- package/dist/components/site-search.js.map +1 -1
- package/dist/components/skip-link.js +1 -1
- package/dist/components/skip-link.js.map +1 -1
- package/dist/components/spinner.js +1 -1
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/step-indicator.js +5 -5
- package/dist/components/step-indicator.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/push-menu.tsx"],"names":[],"mappings":";;;;;;;;;AA0BA,MAAM,qBAAA,GAAwB;AA2B9B,SAAS,aAAa,IAAA,EAAwB;AAC5C,EAAA,OAAO,CAAA,MAAA,EAAS,KAAK,MAAA,GAAS,CAAA,GAAI,KAAK,IAAA,CAAK,IAAI,IAAI,MAAM,CAAA,CAAA;AAC5D;AASA,SAA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A;AAAA,aAAA;AAAA,YA7HK,KAAA,CAAM;AAAA,WA8Hb;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"push-menu.js","sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Button } from '../components/button.js'\nimport { Link } from '../components/link.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { IconClose } from '../icons/close.js'\nimport { IconWest } from '../icons/west.js'\n\n/**\n * Default slide duration for level transitions, in milliseconds — the default\n * of the `durationMs` prop.\n *\n * COUPLING: `durationMs` drives BOTH the `--push-menu-duration` custom\n * property (set inline on the root, read by the CSS transition) and the state\n * machine's `setTimeout`s (which settle the animation state, pop levels, and\n * schedule focus restoration). Do not override the custom property directly —\n * that changes only the visual duration while the state machine still settles\n * on `durationMs`, desyncing the two; pass `durationMs` instead. Under\n * `prefers-reduced-motion` the slide is skipped (`motion-reduce:\n * transition-none`) but the state machine still waits the full duration; the\n * menu is simply \"settled early\" for those users, never broken.\n */\nconst PUSH_MENU_DURATION_MS = 300\n\n/** A node in the menu tree. Items with `links` drill in; items with `href` navigate. */\ntype PushMenuItem = {\n /** Unique across the whole tree — level ids and focus restoration track items by id. */\n id: string\n /** Visible label. */\n title: string\n /** Navigation target for leaf items. Ignored for drilling when `links` is non-empty. */\n href?: string\n /** Child items. A non-empty array makes this item a drill-in button, not a link. */\n links?: PushMenuItem[]\n}\n\n/** One entry in the level stack — the root level plus one per drill-in. */\ntype PushMenuLevel = {\n id: string\n title: string\n /** 1 for the root level, incrementing per drill-in. */\n depth: number\n items: PushMenuItem[]\n /** The item whose activation opened this level. Absent on the root level. */\n parentItem?: PushMenuItem\n}\n\ntype PushMenuAnimationState = 'idle' | 'sliding-forward' | 'sliding-backward'\n\nfunction buildLevelId(path: string[]): string {\n return `level-${path.length > 0 ? path.join('--') : 'root'}`\n}\n\n/**\n * Collapses a trail of level titles into a single \"A › B › C\" string, keeping\n * the ends and eliding the middle once it outgrows `maxLength`. Exported so an\n * app can render the same trail outside the menu (e.g. in a sheet header).\n * Prefixed with \"PushMenu\" to avoid colliding with a future breadcrumb\n * component in the package barrel.\n */\nfunction generatePushMenuBreadcrumb(levels: { title: string }[], maxLength = 50): string {\n const first = levels[0]\n if (levels.length <= 1) {\n return first?.title ?? 'Menu'\n }\n\n const full = levels.map((level) => level.title).join(' › ')\n if (full.length <= maxLength) {\n return full\n }\n\n const last = levels.at(-1)\n const secondLast = levels.at(-2)\n if (levels.length > 3 && first && last && secondLast) {\n return `${first.title} › … › ${secondLast.title} › ${last.title}`\n }\n\n return `${full.slice(0, maxLength - 1)}…`\n}\n\n/**\n * Dev-only guard, mirroring `warnIfIconButtonUnlabelled` in button.tsx. It\n * replaces the nswds-app source's rendered \"Navigation Error\" fallback panel:\n * malformed navigation data is a programming error, not a runtime state a user\n * should ever see, so the design system surfaces it to the developer console\n * and renders what it can instead of shipping error chrome. No-op in\n * production.\n */\nfunction warnIfNavigationMalformed(navigation: PushMenuItem[]) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!Array.isArray(navigation) || navigation.length === 0) {\n console.warn('[nswds/ui] PushMenu received no navigation items — the menu renders empty.')\n return\n }\n const seen = new Set<string>()\n const visit = (items: PushMenuItem[]) => {\n for (const item of items) {\n if (!item?.id || !item.title) {\n console.warn('[nswds/ui] PushMenu navigation item is missing an `id` or `title`:', item)\n continue\n }\n if (seen.has(item.id)) {\n console.warn(\n `[nswds/ui] PushMenu navigation contains duplicate id \"${item.id}\" — level ids and focus restoration track items by id, so ids must be unique across the whole tree.`,\n )\n }\n seen.add(item.id)\n if (!item.href && !item.links?.length) {\n console.warn(\n `[nswds/ui] PushMenu item \"${item.id}\" has neither an href nor children — it renders as a button that only fires onItemClick.`,\n )\n }\n if (item.links?.length) {\n visit(item.links)\n }\n }\n }\n visit(navigation)\n}\n\n// One treatment for every row — drill-in buttons and leaf links alike — so the\n// two read as a single list. Tokenized from the nswds-app source's\n// border-l + primary-800 active pattern, with dark-mode equivalents the app\n// lacked (its grey-800-on-white text disappeared in dark mode).\nconst itemBaseClassName = [\n // min-h-11 guarantees the 44px minimum target size (WCAG 2.2, 2.5.8 Target\n // Size) even for single-line rows with compact padding overrides.\n 'relative flex min-h-11 w-full cursor-pointer items-center justify-between gap-x-6 border-l p-4 text-left text-base',\n 'transition-colors motion-reduce:transition-none',\n 'hover:border-primary-800 hover:bg-primary-800/10 dark:hover:border-primary-200 dark:hover:bg-primary-200/10',\n // Inset outline (negative offset): the levels scroll inside an\n // overflow-hidden root, so an outward offset would be clipped on the first\n // and last rows (WCAG 2.2, 2.4.13 Focus Appearance).\n 'focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-800 dark:focus-visible:outline-primary-200',\n].join(' ')\n\nconst itemActiveClassName =\n 'border-primary-800 bg-primary-800/10 font-semibold text-primary-800 dark:border-primary-200 dark:bg-primary-200/10 dark:text-primary-200'\n\nconst itemInactiveClassName = 'border-transparent text-popover-foreground'\n\ntype PushMenuProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children' | 'title'> & {\n /** The menu tree. Item ids must be unique across the whole tree. */\n navigation: PushMenuItem[]\n /**\n * The app's current pathname. Leaf links whose `href` matches get\n * `aria-current=\"page\"` and the active treatment. Replaces the nswds-app\n * source's `usePathname()` — the design system is framework-free, so the\n * router value is passed in rather than read from next/navigation.\n */\n currentHref?: string\n /** Root level title, shown in the header row. Also the default `aria-label`. */\n title?: string\n /** Fired when a leaf item (link or child-less button) is activated. */\n onItemClick?: (item: PushMenuItem) => void\n /** Fired after a forward/back slide settles on a level. */\n onNavigate?: (level: PushMenuLevel, history: PushMenuLevel[]) => void\n /**\n * Renders a close button in the header row when provided. Unlike the\n * nswds-app source — which only offered close on sub-levels, leaving the\n * root level uncloseable — the button renders on every level.\n */\n onClose?: () => void\n /** Show the \"A › B › C\" trail under the header on sub-levels. Defaults to `true`. */\n showBreadcrumbs?: boolean\n /**\n * Slide duration in milliseconds, defaulting to `PUSH_MENU_DURATION_MS`\n * (300). Drives both the `--push-menu-duration` custom property and the\n * state machine's timeouts — tune the slide here, never by overriding the\n * custom property (see the coupling note on the constant).\n */\n durationMs?: number\n /** Label for the Back button on sub-levels. Defaults to `'Back'`. */\n backLabel?: string\n /** Accessible label for the close button. Defaults to `'Close menu'`. */\n closeLabel?: string\n /**\n * Heading level for the per-level title, following `FooterNavColumn`'s\n * precedent (the nswds-app source used a `Heading` component this package\n * does not ship). Defaults to `2`; `1` is excluded because a menu panel\n * title is never the page's own title.\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Multi-level slide-in-place drill-down menu (\"push menu\") for mobile\n * navigation, ported from nswds-app's `MultiLevelPushMenu`. Items with\n * children render as buttons that slide a new level in from the right; leaf\n * items render as links through `Link`, so apps can inject their framework\n * link component via `LinkProvider`. Fill height from its container — compose\n * it inside `SheetContent side=\"left\"` for the classic mobile drawer.\n *\n * Accessibility contract (all improvements over the nswds-app source, which\n * got several of these wrong):\n *\n * - The root is a `nav` landmark named by `title` (override with `aria-label`).\n * - Non-current levels carry the `inert` attribute, so a hidden level's links\n * are neither tabbable nor exposed to assistive tech. The app left every\n * mounted level in the tab order, letting keyboard users tab into invisible\n * history levels (WCAG 2.2, 2.4.3 Focus Order).\n * - Focus moves with the level change (2.4.3): drilling forward focuses the\n * new level's Back button; going back focuses the item that opened the\n * level just left, tracked by item id and restored after the slide settles.\n * Without this, `inert` on the old level would silently drop focus to\n * `<body>`. The Back button is the only route back (the breadcrumb is\n * decorative), so it always renders on sub-levels — hiding it would make\n * drill-down one-way.\n * - A single visually-hidden `aria-live=\"polite\"` region at the root announces\n * the current level's title, suffixed with the level number below the root.\n * A live attribute on the per-level headings would not work: each level's\n * heading is freshly mounted, and newly-mounted live regions are not\n * reliably announced.\n * - Level lists are `<ul role=\"list\">` — `list-style: none` strips list\n * semantics in some screen reader/browser pairings (notably VoiceOver), and\n * the explicit role restores them.\n * - Every row is at least 44px tall (2.5.8 Target Size); Back/close buttons\n * inherit `Button`'s 44px touch target.\n * - During the slide, rows get `pointer-events-none` and the state machine\n * ignores re-entrant navigation, but nothing is ever `disabled` — disabling\n * the focused Back button mid-animation would eject keyboard focus.\n * - Slides are CSS transforms with `motion-reduce:transition-none`, replacing\n * the app's inline transition strings (which ignored reduced motion).\n *\n * Departures from the nswds-app source, beyond the above:\n *\n * - The footer/stats block (Level N, item counts, progress dots, lucide\n * icons) is cut, along with its `showStats`/`showFooter` props: it was demo\n * chrome for the sandbox, not part of a navigation component's job. The\n * breadcrumb trail it hosted moves under the header row.\n * - The rendered \"Navigation Error\" fallback for malformed data is replaced\n * by a dev-only console warning (`warnIfNavigationMalformed`), mirroring\n * button.tsx's `warnIfIconButtonUnlabelled`.\n * - The breadcrumb trail is `aria-hidden`: it repeats what the heading and\n * live region already announce, and \"›\" separators read poorly in AT.\n *\n * The level stack is seeded from `navigation`/`title` on mount; pass a `key`\n * to remount (and reset to the root level) if either changes at runtime.\n */\nfunction PushMenu({\n navigation,\n currentHref,\n title = 'Menu',\n onItemClick,\n onNavigate,\n onClose,\n showBreadcrumbs = true,\n durationMs = PUSH_MENU_DURATION_MS,\n backLabel = 'Back',\n closeLabel = 'Close menu',\n headingLevel = 2,\n className,\n style,\n 'aria-label': ariaLabel,\n ref,\n ...props\n}: PushMenuProps) {\n const [navigationHistory, setNavigationHistory] = React.useState<PushMenuLevel[]>(() => [\n { items: navigation, title, depth: 1, id: buildLevelId([]) },\n ])\n const [animationState, setAnimationState] = React.useState<PushMenuAnimationState>('idle')\n const [isAnimationStarted, setIsAnimationStarted] = React.useState(false)\n\n const containerRef = React.useRef<HTMLElement | null>(null)\n const timeoutRef = React.useRef<number | null>(null)\n // Focus target applied by the effect below, after React commits the level\n // change — the target element must exist and must no longer be inert.\n const pendingFocusRef = React.useRef<{ levelId: string; itemId?: string } | null>(null)\n\n warnIfNavigationMalformed(navigation)\n\n React.useEffect(() => {\n return () => {\n if (timeoutRef.current !== null) {\n window.clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n // Layout effect, not a passive one: the same commit that queues a focus\n // move can also flip the previously-focused element inert (drilling turns\n // the old level inert; going back turns the departing level inert), and the\n // browser blurs an element the moment it becomes inert. Applying the new\n // focus before paint means AT never observes the intermediate\n // focus-on-body state, and a containing dialog's focus guards (Base UI\n // Sheet) see focus already inside the popup when their async handlers run.\n React.useLayoutEffect(() => {\n const pending = pendingFocusRef.current\n if (!pending) {\n return\n }\n pendingFocusRef.current = null\n const level = containerRef.current?.querySelector<HTMLElement>(\n `[data-level-id=\"${CSS.escape(pending.levelId)}\"]`,\n )\n if (!level) {\n return\n }\n const target = pending.itemId\n ? level.querySelector<HTMLElement>(`[data-item-id=\"${CSS.escape(pending.itemId)}\"]`)\n : (level.querySelector<HTMLElement>('[data-slot=\"push-menu-back-button\"]') ??\n level.querySelector<HTMLElement>(\n '[data-slot=\"push-menu-item\"], [data-slot=\"push-menu-link\"]',\n ))\n // preventScroll: a level mid-slide sits at translateX(100%) inside an\n // overflow-hidden root; letting focus scroll it into view would desync the\n // container's scroll position from the transform.\n target?.focus({ preventScroll: true })\n // animationState is a dependency because back-navigation queues its focus\n // move on the slide START (an animationState commit), not on the level\n // pop — see navigateBack.\n }, [navigationHistory, animationState])\n\n const breadcrumb = React.useMemo(\n // During a back slide the trail already excludes the departing level —\n // the breadcrumb tracks the level the user is arriving at (see\n // activeIndex below), same as the live region.\n () =>\n generatePushMenuBreadcrumb(\n animationState === 'sliding-backward' ? navigationHistory.slice(0, -1) : navigationHistory,\n ),\n [navigationHistory, animationState],\n )\n\n function navigateToSubmenu(item: PushMenuItem) {\n if (!item.links?.length || animationState !== 'idle') {\n return\n }\n const levelPath = [\n ...navigationHistory.flatMap((level) => (level.parentItem ? [level.parentItem.id] : [])),\n item.id,\n ]\n const currentDepth = navigationHistory.at(-1)?.depth ?? 1\n const newLevel: PushMenuLevel = {\n items: item.links,\n title: item.title,\n parentItem: item,\n depth: currentDepth + 1,\n id: buildLevelId(levelPath),\n }\n const newHistory = [...navigationHistory, newLevel]\n\n // Focus moves as soon as the new level commits (see the effect above):\n // waiting for the slide to finish would leave focus on the old level,\n // which turns inert in the same commit and would eject focus to <body>.\n pendingFocusRef.current = { levelId: newLevel.id }\n setNavigationHistory(newHistory)\n setAnimationState('sliding-forward')\n setIsAnimationStarted(false)\n\n // Two-step start: the new level mounts at translateX(100%) with no\n // transition, then flips to 0 with the transition on. The layout read in\n // between is LOAD-BEARING: without it, nothing forces the browser to\n // compute styles for the mounted-at-100% frame, and when both states land\n // in one style recalc there is no transition — the panel snaps into\n // place instead of sliding (an intermittent, timing-dependent jump).\n // Reading layout inside the rAF forces that recalc deterministically.\n requestAnimationFrame(() => {\n containerRef.current?.getBoundingClientRect()\n setIsAnimationStarted(true)\n })\n\n timeoutRef.current = window.setTimeout(() => {\n setAnimationState('idle')\n setIsAnimationStarted(false)\n onNavigate?.(newLevel, newHistory)\n }, durationMs)\n }\n\n function navigateBack() {\n if (navigationHistory.length <= 1 || animationState !== 'idle') {\n return\n }\n const popped = navigationHistory.at(-1)\n const revealed = navigationHistory.at(-2)\n if (!revealed) {\n return\n }\n\n // Focus moves at slide START, symmetric with drilling forward: the\n // 'sliding-backward' commit un-inerts the revealed level (see the\n // activeIndex logic below) and the effect above focuses the item that\n // opened the departing level. Restoring focus at the POP instead — while\n // focus still sat on the departing level's Back button — meant the\n // focused node was removed from a live dialog, and Base UI's focus\n // containment would re-grab focus to the dialog popup a frame after our\n // restoration, silently overriding it (observed inside Sheet).\n pendingFocusRef.current = { levelId: revealed.id, itemId: popped?.parentItem?.id }\n setAnimationState('sliding-backward')\n\n timeoutRef.current = window.setTimeout(() => {\n const newHistory = navigationHistory.slice(0, -1)\n setNavigationHistory(newHistory)\n setAnimationState('idle')\n onNavigate?.(revealed, newHistory)\n }, durationMs)\n }\n\n const currentLevel = navigationHistory.at(-1)\n if (!currentLevel) {\n return null\n }\n\n const isAnimating = animationState !== 'idle'\n // The level the user is arriving AT — the stack top, except during a back\n // slide, where the user's intent has already committed to the level being\n // revealed underneath. data-current, inert, the live region and the\n // breadcrumb all follow this index so focus can land on the revealed level\n // at slide start and AT hears the destination, not the departing level.\n const activeIndex =\n animationState === 'sliding-backward'\n ? navigationHistory.length - 2\n : navigationHistory.length - 1\n const activeLevel = navigationHistory[activeIndex] ?? currentLevel\n const HeadingTag = `h${headingLevel}` as const\n\n return (\n <nav\n data-slot='push-menu'\n aria-label={ariaLabel ?? title}\n // Present while a slide is running (matches header's present-or-absent\n // data-scrolled convention). Consumers can style the transition off it;\n // tests use it to wait for the state machine to go idle — clicks during\n // a slide are dropped by design, and pointer-events-none does not stop\n // a programmatic .click().\n data-animating={isAnimating || undefined}\n {...props}\n className={cn(\n 'relative isolate h-full overflow-hidden bg-popover text-popover-foreground',\n className,\n )}\n // The slide duration custom property is set from durationMs so the CSS\n // transition and the setTimeout state machine can never disagree — see\n // the coupling note on PUSH_MENU_DURATION_MS.\n style={{ ...style, '--push-menu-duration': `${durationMs}ms` } as React.CSSProperties}\n ref={(node) => {\n containerRef.current = node\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ;(ref as React.RefObject<HTMLElement | null>).current = node\n }\n }}\n >\n {/* Persistent live region: announces level changes to AT without\n stealing focus from the managed focus moves. The level number is\n appended below the root because live regions only re-announce when\n their content actually changes — navigating between identically-\n titled levels would otherwise announce nothing. Consecutive levels\n always differ in depth, so consecutive announcements always differ. */}\n <div data-slot='push-menu-live-region' aria-live='polite' className='sr-only'>\n {activeLevel.depth > 1\n ? `${activeLevel.title}, level ${activeLevel.depth}`\n : activeLevel.title}\n </div>\n\n {navigationHistory.map((level, index) => {\n // The stack top is the level that MOVES (slides in forward, slides\n // out backward); the active level is the one the user is arriving at\n // — they differ only during a back slide.\n const isTopLevel = index === navigationHistory.length - 1\n const isActiveLevel = index === activeIndex\n // Always shown below the root: the Back button is the ONLY route back\n // (the breadcrumb is aria-hidden and there is no keyboard binding or\n // imperative API), so making it optional would strand users.\n const shouldShowBackButton = level.depth > 1\n\n let translateX = 0\n if (animationState === 'sliding-forward') {\n translateX = isTopLevel ? (isAnimationStarted ? 0 : 100) : 0\n } else if (animationState === 'sliding-backward') {\n translateX = isTopLevel ? 100 : 0\n }\n\n // Only the moving (top) level transitions; forward slides wait for\n // the second frame so the mount position is applied untransitioned.\n const isSliding =\n isTopLevel &&\n (animationState === 'sliding-backward' ||\n (animationState === 'sliding-forward' && isAnimationStarted))\n\n return (\n <div\n key={level.id}\n data-slot='push-menu-level'\n data-level-id={level.id}\n data-current={isActiveLevel || undefined}\n // Non-active levels must be invisible to keyboard and AT, not\n // just to the eye. Keying this on the ACTIVE level (not the stack\n // top) un-inerts the revealed level at back-slide start, so focus\n // can move there immediately — and the focused Back button is\n // never removed from a live dialog while still focused.\n inert={!isActiveLevel}\n className={cn(\n 'absolute inset-0 flex h-full w-full flex-col bg-popover will-change-transform',\n isSliding\n ? 'transition-transform duration-(--push-menu-duration) ease-out motion-reduce:transition-none'\n : 'transition-none',\n )}\n style={{ transform: `translateX(${translateX}%)`, zIndex: index + 1 }}\n >\n <div\n data-slot='push-menu-header'\n className='flex min-h-11 items-center gap-1 border-b border-border px-2 py-2'\n >\n {shouldShowBackButton && (\n <Button\n data-slot='push-menu-back-button'\n variant='ghost'\n color='primary'\n size='sm'\n leadingVisual={IconWest}\n onClick={navigateBack}\n className={cn(isAnimating && 'pointer-events-none')}\n >\n {backLabel}\n </Button>\n )}\n <HeadingTag\n data-slot='push-menu-title'\n className='min-w-0 flex-1 truncate px-2 text-base font-semibold'\n >\n {level.title}\n </HeadingTag>\n {onClose && (\n <Button\n data-slot='push-menu-close-button'\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n leadingVisual={IconClose}\n onClick={onClose}\n />\n )}\n </div>\n\n {showBreadcrumbs && isActiveLevel && level.depth > 1 && (\n // aria-hidden: the trail repeats what the heading and live\n // region already announce, and \"›\" separators read poorly in AT.\n <p\n data-slot='push-menu-breadcrumb'\n aria-hidden='true'\n className='truncate border-b border-border px-4 py-2 text-xs text-muted-foreground'\n >\n {breadcrumb}\n </p>\n )}\n\n <div data-slot='push-menu-items' className='flex-1 overflow-y-auto'>\n {/* role='list' restores list semantics stripped by list-none. */}\n <ul role='list' className='m-0 list-none divide-y divide-border p-0'>\n {level.items.map((item) => {\n const hasChildren = Boolean(item.links?.length)\n const isActive = item.href != null && item.href === currentHref\n\n return (\n <li key={item.id}>\n {hasChildren ? (\n <button\n type='button'\n data-slot='push-menu-item'\n data-item-id={item.id}\n onClick={() => navigateToSubmenu(item)}\n className={cn(\n itemBaseClassName,\n isActive ? itemActiveClassName : itemInactiveClassName,\n isAnimating && 'pointer-events-none',\n )}\n >\n <span className='min-w-0 flex-1 truncate'>{item.title}</span>\n <IconChevronRight aria-hidden='true' className='size-5 shrink-0' />\n </button>\n ) : item.href ? (\n <Link\n variant='unstyled'\n data-slot='push-menu-link'\n data-item-id={item.id}\n href={item.href}\n aria-current={isActive ? 'page' : undefined}\n onClick={() => onItemClick?.(item)}\n className={cn(\n itemBaseClassName,\n isActive ? itemActiveClassName : itemInactiveClassName,\n isAnimating && 'pointer-events-none',\n )}\n >\n <span className='min-w-0 flex-1 truncate'>{item.title}</span>\n </Link>\n ) : (\n <button\n type='button'\n data-slot='push-menu-item'\n data-item-id={item.id}\n onClick={() => onItemClick?.(item)}\n className={cn(\n itemBaseClassName,\n itemInactiveClassName,\n isAnimating && 'pointer-events-none',\n )}\n >\n <span className='min-w-0 flex-1 truncate'>{item.title}</span>\n </button>\n )}\n </li>\n )\n })}\n </ul>\n </div>\n </div>\n )\n })}\n </nav>\n )\n}\n\nexport { generatePushMenuBreadcrumb, PUSH_MENU_DURATION_MS, PushMenu }\nexport type { PushMenuItem, PushMenuLevel, PushMenuProps }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/push-menu.tsx"],"names":[],"mappings":";;;;;;;;;AA0BA,MAAM,qBAAA,GAAw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GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,yBAAA,EAA2B,eAAK,KAAA,EAAM;AAAA;AAAA,mBACxD,EAAA,EA7CK,KAAK,EA+Cd,CAAA;AAAA,gBAEJ,CAAC,GACH,CAAA,EACF;AAAA;AAAA,aAAA;AAAA,YA7HK,KAAA,CAAM;AAAA,WA8Hb;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,GACH;AAEJ","file":"push-menu.js","sourcesContent":["'use client'\n\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Button } from '../components/button.js'\nimport { Link } from '../components/link.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\nimport { IconClose } from '../icons/close.js'\nimport { IconWest } from '../icons/west.js'\n\n/**\n * Default slide duration for level transitions, in milliseconds — the default\n * of the `durationMs` prop.\n *\n * COUPLING: `durationMs` drives BOTH the `--push-menu-duration` custom\n * property (set inline on the root, read by the CSS transition) and the state\n * machine's `setTimeout`s (which settle the animation state, pop levels, and\n * schedule focus restoration). Do not override the custom property directly —\n * that changes only the visual duration while the state machine still settles\n * on `durationMs`, desyncing the two; pass `durationMs` instead. Under\n * `prefers-reduced-motion` the slide is skipped (the transition is applied\n * under `motion-safe:` only) but the state machine still waits the full\n * duration; the menu is simply \"settled early\" for those users, never broken.\n */\nconst PUSH_MENU_DURATION_MS = 300\n\n/** A node in the menu tree. Items with `links` drill in; items with `href` navigate. */\ntype PushMenuItem = {\n /** Unique across the whole tree — level ids and focus restoration track items by id. */\n id: string\n /** Visible label. */\n title: string\n /** Navigation target for leaf items. Ignored for drilling when `links` is non-empty. */\n href?: string\n /** Child items. A non-empty array makes this item a drill-in button, not a link. */\n links?: PushMenuItem[]\n}\n\n/** One entry in the level stack — the root level plus one per drill-in. */\ntype PushMenuLevel = {\n id: string\n title: string\n /** 1 for the root level, incrementing per drill-in. */\n depth: number\n items: PushMenuItem[]\n /** The item whose activation opened this level. Absent on the root level. */\n parentItem?: PushMenuItem\n}\n\ntype PushMenuAnimationState = 'idle' | 'sliding-forward' | 'sliding-backward'\n\nfunction buildLevelId(path: string[]): string {\n return `level-${path.length > 0 ? path.join('--') : 'root'}`\n}\n\n/**\n * Collapses a trail of level titles into a single \"A › B › C\" string, keeping\n * the ends and eliding the middle once it outgrows `maxLength`. Exported so an\n * app can render the same trail outside the menu (e.g. in a sheet header).\n * Prefixed with \"PushMenu\" to avoid colliding with a future breadcrumb\n * component in the package barrel.\n */\nfunction generatePushMenuBreadcrumb(levels: { title: string }[], maxLength = 50): string {\n const first = levels[0]\n if (levels.length <= 1) {\n return first?.title ?? 'Menu'\n }\n\n const full = levels.map((level) => level.title).join(' › ')\n if (full.length <= maxLength) {\n return full\n }\n\n const last = levels.at(-1)\n const secondLast = levels.at(-2)\n if (levels.length > 3 && first && last && secondLast) {\n return `${first.title} › … › ${secondLast.title} › ${last.title}`\n }\n\n return `${full.slice(0, maxLength - 1)}…`\n}\n\n/**\n * Dev-only guard, mirroring `warnIfIconButtonUnlabelled` in button.tsx. It\n * replaces the nswds-app source's rendered \"Navigation Error\" fallback panel:\n * malformed navigation data is a programming error, not a runtime state a user\n * should ever see, so the design system surfaces it to the developer console\n * and renders what it can instead of shipping error chrome. No-op in\n * production.\n */\nfunction warnIfNavigationMalformed(navigation: PushMenuItem[]) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!Array.isArray(navigation) || navigation.length === 0) {\n console.warn('[nswds/ui] PushMenu received no navigation items — the menu renders empty.')\n return\n }\n const seen = new Set<string>()\n const visit = (items: PushMenuItem[]) => {\n for (const item of items) {\n if (!item?.id || !item.title) {\n console.warn('[nswds/ui] PushMenu navigation item is missing an `id` or `title`:', item)\n continue\n }\n if (seen.has(item.id)) {\n console.warn(\n `[nswds/ui] PushMenu navigation contains duplicate id \"${item.id}\" — level ids and focus restoration track items by id, so ids must be unique across the whole tree.`,\n )\n }\n seen.add(item.id)\n if (!item.href && !item.links?.length) {\n console.warn(\n `[nswds/ui] PushMenu item \"${item.id}\" has neither an href nor children — it renders as a button that only fires onItemClick.`,\n )\n }\n if (item.links?.length) {\n visit(item.links)\n }\n }\n }\n visit(navigation)\n}\n\n// One treatment for every row — drill-in buttons and leaf links alike — so the\n// two read as a single list. Tokenized from the nswds-app source's\n// border-l + primary-800 active pattern, with dark-mode equivalents the app\n// lacked (its grey-800-on-white text disappeared in dark mode).\nconst itemBaseClassName = [\n // min-h-11 guarantees the 44px minimum target size (WCAG 2.2, 2.5.8 Target\n // Size) even for single-line rows with compact padding overrides.\n 'relative flex min-h-11 w-full cursor-pointer items-center justify-between gap-x-6 border-l p-4 text-left text-base',\n 'motion-safe:transition-colors',\n 'hover:border-primary-800 hover:bg-primary-800/10 dark:hover:border-primary-200 dark:hover:bg-primary-200/10',\n // Inset outline (negative offset): the levels scroll inside an\n // overflow-hidden root, so an outward offset would be clipped on the first\n // and last rows (WCAG 2.2, 2.4.13 Focus Appearance).\n 'focus-visible:outline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary-800 dark:focus-visible:outline-primary-200',\n].join(' ')\n\nconst itemActiveClassName =\n 'border-primary-800 bg-primary-800/10 font-semibold text-primary-800 dark:border-primary-200 dark:bg-primary-200/10 dark:text-primary-200'\n\nconst itemInactiveClassName = 'border-transparent text-popover-foreground'\n\ntype PushMenuProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children' | 'title'> & {\n /** The menu tree. Item ids must be unique across the whole tree. */\n navigation: PushMenuItem[]\n /**\n * The app's current pathname. Leaf links whose `href` matches get\n * `aria-current=\"page\"` and the active treatment. Replaces the nswds-app\n * source's `usePathname()` — the design system is framework-free, so the\n * router value is passed in rather than read from next/navigation.\n */\n currentHref?: string\n /** Root level title, shown in the header row. Also the default `aria-label`. */\n title?: string\n /** Fired when a leaf item (link or child-less button) is activated. */\n onItemClick?: (item: PushMenuItem) => void\n /** Fired after a forward/back slide settles on a level. */\n onNavigate?: (level: PushMenuLevel, history: PushMenuLevel[]) => void\n /**\n * Renders a close button in the header row when provided. Unlike the\n * nswds-app source — which only offered close on sub-levels, leaving the\n * root level uncloseable — the button renders on every level.\n */\n onClose?: () => void\n /** Show the \"A › B › C\" trail under the header on sub-levels. Defaults to `true`. */\n showBreadcrumbs?: boolean\n /**\n * Slide duration in milliseconds, defaulting to `PUSH_MENU_DURATION_MS`\n * (300). Drives both the `--push-menu-duration` custom property and the\n * state machine's timeouts — tune the slide here, never by overriding the\n * custom property (see the coupling note on the constant).\n */\n durationMs?: number\n /** Label for the Back button on sub-levels. Defaults to `'Back'`. */\n backLabel?: string\n /** Accessible label for the close button. Defaults to `'Close menu'`. */\n closeLabel?: string\n /**\n * Heading level for the per-level title, following `FooterNavColumn`'s\n * precedent (the nswds-app source used a `Heading` component this package\n * does not ship). Defaults to `2`; `1` is excluded because a menu panel\n * title is never the page's own title.\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Multi-level slide-in-place drill-down menu (\"push menu\") for mobile\n * navigation, ported from nswds-app's `MultiLevelPushMenu`. Items with\n * children render as buttons that slide a new level in from the right; leaf\n * items render as links through `Link`, so apps can inject their framework\n * link component via `LinkProvider`. Fill height from its container — compose\n * it inside `SheetContent side=\"left\"` for the classic mobile drawer.\n *\n * Accessibility contract (all improvements over the nswds-app source, which\n * got several of these wrong):\n *\n * - The root is a `nav` landmark named by `title` (override with `aria-label`).\n * - Non-current levels carry the `inert` attribute, so a hidden level's links\n * are neither tabbable nor exposed to assistive tech. The app left every\n * mounted level in the tab order, letting keyboard users tab into invisible\n * history levels (WCAG 2.2, 2.4.3 Focus Order).\n * - Focus moves with the level change (2.4.3): drilling forward focuses the\n * new level's Back button; going back focuses the item that opened the\n * level just left, tracked by item id and restored after the slide settles.\n * Without this, `inert` on the old level would silently drop focus to\n * `<body>`. The Back button is the only route back (the breadcrumb is\n * decorative), so it always renders on sub-levels — hiding it would make\n * drill-down one-way.\n * - A single visually-hidden `aria-live=\"polite\"` region at the root announces\n * the current level's title, suffixed with the level number below the root.\n * A live attribute on the per-level headings would not work: each level's\n * heading is freshly mounted, and newly-mounted live regions are not\n * reliably announced.\n * - Level lists are `<ul role=\"list\">` — `list-style: none` strips list\n * semantics in some screen reader/browser pairings (notably VoiceOver), and\n * the explicit role restores them.\n * - Every row is at least 44px tall (2.5.8 Target Size); Back/close buttons\n * inherit `Button`'s 44px touch target.\n * - During the slide, rows get `pointer-events-none` and the state machine\n * ignores re-entrant navigation, but nothing is ever `disabled` — disabling\n * the focused Back button mid-animation would eject keyboard focus.\n * - Slides are CSS transforms applied under `motion-safe:`, replacing the app's\n * inline transition strings (which ignored reduced motion).\n *\n * Departures from the nswds-app source, beyond the above:\n *\n * - The footer/stats block (Level N, item counts, progress dots, lucide\n * icons) is cut, along with its `showStats`/`showFooter` props: it was demo\n * chrome for the sandbox, not part of a navigation component's job. The\n * breadcrumb trail it hosted moves under the header row.\n * - The rendered \"Navigation Error\" fallback for malformed data is replaced\n * by a dev-only console warning (`warnIfNavigationMalformed`), mirroring\n * button.tsx's `warnIfIconButtonUnlabelled`.\n * - The breadcrumb trail is `aria-hidden`: it repeats what the heading and\n * live region already announce, and \"›\" separators read poorly in AT.\n *\n * The level stack is seeded from `navigation`/`title` on mount; pass a `key`\n * to remount (and reset to the root level) if either changes at runtime.\n */\nfunction PushMenu({\n navigation,\n currentHref,\n title = 'Menu',\n onItemClick,\n onNavigate,\n onClose,\n showBreadcrumbs = true,\n durationMs = PUSH_MENU_DURATION_MS,\n backLabel = 'Back',\n closeLabel = 'Close menu',\n headingLevel = 2,\n className,\n style,\n 'aria-label': ariaLabel,\n ref,\n ...props\n}: PushMenuProps) {\n const [navigationHistory, setNavigationHistory] = React.useState<PushMenuLevel[]>(() => [\n { items: navigation, title, depth: 1, id: buildLevelId([]) },\n ])\n const [animationState, setAnimationState] = React.useState<PushMenuAnimationState>('idle')\n const [isAnimationStarted, setIsAnimationStarted] = React.useState(false)\n\n const containerRef = React.useRef<HTMLElement | null>(null)\n const timeoutRef = React.useRef<number | null>(null)\n // Focus target applied by the effect below, after React commits the level\n // change — the target element must exist and must no longer be inert.\n const pendingFocusRef = React.useRef<{ levelId: string; itemId?: string } | null>(null)\n\n warnIfNavigationMalformed(navigation)\n\n React.useEffect(() => {\n return () => {\n if (timeoutRef.current !== null) {\n window.clearTimeout(timeoutRef.current)\n }\n }\n }, [])\n\n // Layout effect, not a passive one: the same commit that queues a focus\n // move can also flip the previously-focused element inert (drilling turns\n // the old level inert; going back turns the departing level inert), and the\n // browser blurs an element the moment it becomes inert. Applying the new\n // focus before paint means AT never observes the intermediate\n // focus-on-body state, and a containing dialog's focus guards (Base UI\n // Sheet) see focus already inside the popup when their async handlers run.\n React.useLayoutEffect(() => {\n const pending = pendingFocusRef.current\n if (!pending) {\n return\n }\n pendingFocusRef.current = null\n const level = containerRef.current?.querySelector<HTMLElement>(\n `[data-level-id=\"${CSS.escape(pending.levelId)}\"]`,\n )\n if (!level) {\n return\n }\n const target = pending.itemId\n ? level.querySelector<HTMLElement>(`[data-item-id=\"${CSS.escape(pending.itemId)}\"]`)\n : (level.querySelector<HTMLElement>('[data-slot=\"push-menu-back-button\"]') ??\n level.querySelector<HTMLElement>(\n '[data-slot=\"push-menu-item\"], [data-slot=\"push-menu-link\"]',\n ))\n // preventScroll: a level mid-slide sits at translateX(100%) inside an\n // overflow-hidden root; letting focus scroll it into view would desync the\n // container's scroll position from the transform.\n target?.focus({ preventScroll: true })\n // animationState is a dependency because back-navigation queues its focus\n // move on the slide START (an animationState commit), not on the level\n // pop — see navigateBack.\n }, [navigationHistory, animationState])\n\n const breadcrumb = React.useMemo(\n // During a back slide the trail already excludes the departing level —\n // the breadcrumb tracks the level the user is arriving at (see\n // activeIndex below), same as the live region.\n () =>\n generatePushMenuBreadcrumb(\n animationState === 'sliding-backward' ? navigationHistory.slice(0, -1) : navigationHistory,\n ),\n [navigationHistory, animationState],\n )\n\n function navigateToSubmenu(item: PushMenuItem) {\n if (!item.links?.length || animationState !== 'idle') {\n return\n }\n const levelPath = [\n ...navigationHistory.flatMap((level) => (level.parentItem ? [level.parentItem.id] : [])),\n item.id,\n ]\n const currentDepth = navigationHistory.at(-1)?.depth ?? 1\n const newLevel: PushMenuLevel = {\n items: item.links,\n title: item.title,\n parentItem: item,\n depth: currentDepth + 1,\n id: buildLevelId(levelPath),\n }\n const newHistory = [...navigationHistory, newLevel]\n\n // Focus moves as soon as the new level commits (see the effect above):\n // waiting for the slide to finish would leave focus on the old level,\n // which turns inert in the same commit and would eject focus to <body>.\n pendingFocusRef.current = { levelId: newLevel.id }\n setNavigationHistory(newHistory)\n setAnimationState('sliding-forward')\n setIsAnimationStarted(false)\n\n // Two-step start: the new level mounts at translateX(100%) with no\n // transition, then flips to 0 with the transition on. The layout read in\n // between is LOAD-BEARING: without it, nothing forces the browser to\n // compute styles for the mounted-at-100% frame, and when both states land\n // in one style recalc there is no transition — the panel snaps into\n // place instead of sliding (an intermittent, timing-dependent jump).\n // Reading layout inside the rAF forces that recalc deterministically.\n requestAnimationFrame(() => {\n containerRef.current?.getBoundingClientRect()\n setIsAnimationStarted(true)\n })\n\n timeoutRef.current = window.setTimeout(() => {\n setAnimationState('idle')\n setIsAnimationStarted(false)\n onNavigate?.(newLevel, newHistory)\n }, durationMs)\n }\n\n function navigateBack() {\n if (navigationHistory.length <= 1 || animationState !== 'idle') {\n return\n }\n const popped = navigationHistory.at(-1)\n const revealed = navigationHistory.at(-2)\n if (!revealed) {\n return\n }\n\n // Focus moves at slide START, symmetric with drilling forward: the\n // 'sliding-backward' commit un-inerts the revealed level (see the\n // activeIndex logic below) and the effect above focuses the item that\n // opened the departing level. Restoring focus at the POP instead — while\n // focus still sat on the departing level's Back button — meant the\n // focused node was removed from a live dialog, and Base UI's focus\n // containment would re-grab focus to the dialog popup a frame after our\n // restoration, silently overriding it (observed inside Sheet).\n pendingFocusRef.current = { levelId: revealed.id, itemId: popped?.parentItem?.id }\n setAnimationState('sliding-backward')\n\n timeoutRef.current = window.setTimeout(() => {\n const newHistory = navigationHistory.slice(0, -1)\n setNavigationHistory(newHistory)\n setAnimationState('idle')\n onNavigate?.(revealed, newHistory)\n }, durationMs)\n }\n\n const currentLevel = navigationHistory.at(-1)\n if (!currentLevel) {\n return null\n }\n\n const isAnimating = animationState !== 'idle'\n // The level the user is arriving AT — the stack top, except during a back\n // slide, where the user's intent has already committed to the level being\n // revealed underneath. data-current, inert, the live region and the\n // breadcrumb all follow this index so focus can land on the revealed level\n // at slide start and AT hears the destination, not the departing level.\n const activeIndex =\n animationState === 'sliding-backward'\n ? navigationHistory.length - 2\n : navigationHistory.length - 1\n const activeLevel = navigationHistory[activeIndex] ?? currentLevel\n const HeadingTag = `h${headingLevel}` as const\n\n return (\n <nav\n data-slot='push-menu'\n aria-label={ariaLabel ?? title}\n // Present while a slide is running (matches header's present-or-absent\n // data-scrolled convention). Consumers can style the transition off it;\n // tests use it to wait for the state machine to go idle — clicks during\n // a slide are dropped by design, and pointer-events-none does not stop\n // a programmatic .click().\n data-animating={isAnimating || undefined}\n {...props}\n className={cn(\n 'relative isolate h-full overflow-hidden bg-popover text-popover-foreground',\n className,\n )}\n // The slide duration custom property is set from durationMs so the CSS\n // transition and the setTimeout state machine can never disagree — see\n // the coupling note on PUSH_MENU_DURATION_MS.\n style={{ ...style, '--push-menu-duration': `${durationMs}ms` } as React.CSSProperties}\n ref={(node) => {\n containerRef.current = node\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ;(ref as React.RefObject<HTMLElement | null>).current = node\n }\n }}\n >\n {/* Persistent live region: announces level changes to AT without\n stealing focus from the managed focus moves. The level number is\n appended below the root because live regions only re-announce when\n their content actually changes — navigating between identically-\n titled levels would otherwise announce nothing. Consecutive levels\n always differ in depth, so consecutive announcements always differ. */}\n <div data-slot='push-menu-live-region' aria-live='polite' className='sr-only'>\n {activeLevel.depth > 1\n ? `${activeLevel.title}, level ${activeLevel.depth}`\n : activeLevel.title}\n </div>\n\n {navigationHistory.map((level, index) => {\n // The stack top is the level that MOVES (slides in forward, slides\n // out backward); the active level is the one the user is arriving at\n // — they differ only during a back slide.\n const isTopLevel = index === navigationHistory.length - 1\n const isActiveLevel = index === activeIndex\n // Always shown below the root: the Back button is the ONLY route back\n // (the breadcrumb is aria-hidden and there is no keyboard binding or\n // imperative API), so making it optional would strand users.\n const shouldShowBackButton = level.depth > 1\n\n let translateX = 0\n if (animationState === 'sliding-forward') {\n translateX = isTopLevel ? (isAnimationStarted ? 0 : 100) : 0\n } else if (animationState === 'sliding-backward') {\n translateX = isTopLevel ? 100 : 0\n }\n\n // Only the moving (top) level transitions; forward slides wait for\n // the second frame so the mount position is applied untransitioned.\n const isSliding =\n isTopLevel &&\n (animationState === 'sliding-backward' ||\n (animationState === 'sliding-forward' && isAnimationStarted))\n\n return (\n <div\n key={level.id}\n data-slot='push-menu-level'\n data-level-id={level.id}\n data-current={isActiveLevel || undefined}\n // Non-active levels must be invisible to keyboard and AT, not\n // just to the eye. Keying this on the ACTIVE level (not the stack\n // top) un-inerts the revealed level at back-slide start, so focus\n // can move there immediately — and the focused Back button is\n // never removed from a live dialog while still focused.\n inert={!isActiveLevel}\n className={cn(\n 'absolute inset-0 flex h-full w-full flex-col bg-popover will-change-transform',\n isSliding\n ? 'duration-(--push-menu-duration) ease-out motion-safe:transition-transform'\n : 'transition-none',\n )}\n style={{ transform: `translateX(${translateX}%)`, zIndex: index + 1 }}\n >\n <div\n data-slot='push-menu-header'\n className='flex min-h-11 items-center gap-1 border-b border-border px-2 py-2'\n >\n {shouldShowBackButton && (\n <Button\n data-slot='push-menu-back-button'\n variant='ghost'\n color='primary'\n size='sm'\n leadingVisual={IconWest}\n onClick={navigateBack}\n className={cn(isAnimating && 'pointer-events-none')}\n >\n {backLabel}\n </Button>\n )}\n <HeadingTag\n data-slot='push-menu-title'\n className='min-w-0 flex-1 truncate px-2 text-base font-semibold'\n >\n {level.title}\n </HeadingTag>\n {onClose && (\n <Button\n data-slot='push-menu-close-button'\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={closeLabel}\n leadingVisual={IconClose}\n onClick={onClose}\n />\n )}\n </div>\n\n {showBreadcrumbs && isActiveLevel && level.depth > 1 && (\n // aria-hidden: the trail repeats what the heading and live\n // region already announce, and \"›\" separators read poorly in AT.\n <p\n data-slot='push-menu-breadcrumb'\n aria-hidden='true'\n className='truncate border-b border-border px-4 py-2 text-xs text-muted-foreground'\n >\n {breadcrumb}\n </p>\n )}\n\n <div data-slot='push-menu-items' className='flex-1 overflow-y-auto'>\n {/* role='list' restores list semantics stripped by list-none. */}\n <ul role='list' className='m-0 list-none divide-y divide-border p-0'>\n {level.items.map((item) => {\n const hasChildren = Boolean(item.links?.length)\n const isActive = item.href != null && item.href === currentHref\n\n return (\n <li key={item.id}>\n {hasChildren ? (\n <button\n type='button'\n data-slot='push-menu-item'\n data-item-id={item.id}\n onClick={() => navigateToSubmenu(item)}\n className={cn(\n itemBaseClassName,\n isActive ? itemActiveClassName : itemInactiveClassName,\n isAnimating && 'pointer-events-none',\n )}\n >\n <span className='min-w-0 flex-1 truncate'>{item.title}</span>\n <IconChevronRight aria-hidden='true' className='size-5 shrink-0' />\n </button>\n ) : item.href ? (\n <Link\n variant='unstyled'\n data-slot='push-menu-link'\n data-item-id={item.id}\n href={item.href}\n aria-current={isActive ? 'page' : undefined}\n onClick={() => onItemClick?.(item)}\n className={cn(\n itemBaseClassName,\n isActive ? itemActiveClassName : itemInactiveClassName,\n isAnimating && 'pointer-events-none',\n )}\n >\n <span className='min-w-0 flex-1 truncate'>{item.title}</span>\n </Link>\n ) : (\n <button\n type='button'\n data-slot='push-menu-item'\n data-item-id={item.id}\n onClick={() => onItemClick?.(item)}\n className={cn(\n itemBaseClassName,\n itemInactiveClassName,\n isAnimating && 'pointer-events-none',\n )}\n >\n <span className='min-w-0 flex-1 truncate'>{item.title}</span>\n </button>\n )}\n </li>\n )\n })}\n </ul>\n </div>\n </div>\n )\n })}\n </nav>\n )\n}\n\nexport { generatePushMenuBreadcrumb, PUSH_MENU_DURATION_MS, PushMenu }\nexport type { PushMenuItem, PushMenuLevel, PushMenuProps }\n"]}
|
|
@@ -8,8 +8,8 @@ import { IconChevronRight } from '../icons/chevron-right.js';
|
|
|
8
8
|
|
|
9
9
|
const sideNavRowVariants = cva(
|
|
10
10
|
[
|
|
11
|
-
"w-full cursor-pointer rounded-r-sm border-l border-transparent py-1 pr-2 pl-4 text-left text-base/8 sm:text-sm/6",
|
|
12
|
-
"
|
|
11
|
+
"w-full cursor-pointer rounded-r-sm border-l border-transparent py-1 pr-2 pl-4 text-left max-sm:text-base/8 sm:text-sm/6",
|
|
12
|
+
"motion-safe:transition-colors",
|
|
13
13
|
"hover:border-grey-950 hover:bg-primary-800/10 hover:font-semibold hover:text-grey-950",
|
|
14
14
|
"dark:text-grey-400 dark:hover:border-grey-400 dark:hover:text-white",
|
|
15
15
|
"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"
|
|
@@ -59,7 +59,7 @@ function SideNavList({ items, currentHref, onNavigate, nested = false }) {
|
|
|
59
59
|
"data-slot": "side-nav-list",
|
|
60
60
|
className: cn(
|
|
61
61
|
"flex flex-col border-l border-grey-400 dark:border-grey-200/15",
|
|
62
|
-
nested ? "mt-2 ml-5 gap-1" : "
|
|
62
|
+
nested ? "mt-2 ml-5 gap-1" : "gap-2 max-lg:mt-2 lg:mt-4"
|
|
63
63
|
),
|
|
64
64
|
children: items.map((item) => /* @__PURE__ */ jsx(
|
|
65
65
|
SideNavRow,
|
|
@@ -90,7 +90,7 @@ function SideNavRow({ item, currentHref, onNavigate }) {
|
|
|
90
90
|
IconChevronRight,
|
|
91
91
|
{
|
|
92
92
|
"aria-hidden": "true",
|
|
93
|
-
className: "ml-2 size-5 shrink-0
|
|
93
|
+
className: "ml-2 size-5 shrink-0 duration-200 group-data-panel-open:rotate-90 motion-safe:transition-transform"
|
|
94
94
|
}
|
|
95
95
|
)
|
|
96
96
|
]
|
|
@@ -147,7 +147,7 @@ function SideNav({
|
|
|
147
147
|
"data-slot": "side-nav",
|
|
148
148
|
...props,
|
|
149
149
|
"aria-label": ariaLabel,
|
|
150
|
-
className: cn("text-
|
|
150
|
+
className: cn("text-grey-800 max-lg:text-base lg:text-sm dark:text-grey-400", className),
|
|
151
151
|
ref,
|
|
152
152
|
children: /* @__PURE__ */ jsx("ul", { role: "list", "data-slot": "side-nav-sections", className: "flex flex-col gap-9", children: sections.map((section) => /* @__PURE__ */ jsx("li", { "data-slot": "side-nav-section", children: section.links ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
153
153
|
/* @__PURE__ */ jsx(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/side-nav.tsx"],"names":[],"mappings":";;;;;;;AAoDA,MAAM,kBAAA,GAAqB,GAAA;AAAA,EACzB;AAAA,IACE,kHAAA;AAAA,IACA,iDAAA;AAAA,IACA,uFAAA;AAAA,IACA,qEAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,IAAA,EAAM,oHAAA;AAAA,QACN,KAAA,EAAO;AAAA;AACT,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS;AAAA;AACX;AAEJ;AAOA,SAAS,yBAAA,CAA0B,MAAmB,WAAA,EAA0C;AAC9F,EAAA,IAAI,gBAAgB,MAAA,EAAW;AAC7B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,IAAA,CAAK,SAAS,WAAA,EAAa;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA,CAAK,OAAO,IAAA,CAAK,CAAC,UAAU,yBAAA,CAA0B,KAAA,EAAO,WAAW,CAAC,CAAA,IAAK,KAAA;AACvF;AASA,SAAS,oBAAoB,IAAA,EAAmB;AAC9C,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AACzC,IAAA;AAAA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IAAA,EAAA,EAAuC,aAAU,kBAAA,EAC/C,QAAA,EAAA,OAAA,CAAQ,wBACP,IAAA,CAAA,QAAA,EAAA,EAIE,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,OAAA;AAAA,UAAA;AAAA,YACC,WAAA,EAAU,kBAAA;AAAA,YACV,SAAA,EAAU,wDAAA;AAAA,YAET,QAAA,EAAA,OAAA,CAAQ;AAAA;AAAA,SACX;AAAA,wBACA,GAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,OAAO,OAAA,CAAQ,KAAA;AAAA,YACf,WAAA;AAAA,YACA;AAAA;AAAA;AACF,OAAA,EACF,CAAA;AAAA;AAAA;AAAA,4BAIC,WAAA,EAAA,EAAY,KAAA,EAAO,CAAC,OAAO,CAAA,EAAG,aAA0B,UAAA,EAAwB;AAAA,OAAA,EAAA,EArB5E,OAAA,CAAQ,IAAA,IAAQ,OAAA,CAAQ,KAuBjC,CACD,CAAA,EACH;AAAA;AAAA,GACF;AAEJ","file":"side-nav.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../components/collapsible.js'\nimport { Link } from '../components/link.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\n\n/**\n * One entry in a `SideNav` tree.\n *\n * - `href` and no `links` — a leaf link.\n * - `links` — a branch. At the top level it renders as a section heading over an\n * always-visible list; at any deeper level it renders as a collapsible\n * trigger. A branch's own `href` is IGNORED (the row is a disclosure button,\n * not a link) — a dev-only warning flags it, mirroring the nswds-app\n * `SidebarNavigation` behaviour where branch rows only toggled.\n * - Neither — a dead entry; rendered as inert text and flagged with a dev-only\n * warning rather than a decoy `<a>` with no destination.\n */\ntype SideNavItem = {\n /** Visible text for the link, section heading, or branch trigger. */\n title: string\n href?: string\n links?: SideNavItem[]\n}\n\n/**\n * Row treatment shared by leaf links and branch triggers — the nswds-app\n * left-rail language: each row carries its own left border sitting exactly on\n * the list's rail (the `-ml-px` on the `<li>`), so hover and the current-page\n * state recolour the rail segment beside the row.\n *\n * Departures from the source, both deliberate:\n * - The idle border is `border-transparent` rather than the bare `border-l`\n * default: idle rows show the rail through their transparent border, so the\n * idle rail colour is defined once (on the list) instead of twice.\n * - The current row adds `dark:text-white`. The source left dark active text\n * to fall through to the idle `dark:text-grey-400`, which on the\n * `dark:bg-white/20` highlight is both low-contrast and cascade-order\n * dependent; bold white ink clears WCAG 2.2 AA (1.4.3) on that overlay.\n *\n * The hover font-weight change (`hover:font-semibold`) is source parity; it\n * reflows the row's own text only, never the rail.\n *\n * Focus uses the house visible-focus pattern (outline-current, offset 2), so\n * the indicator always contrasts with whatever text colour the row currently\n * has (WCAG 2.2, 2.4.13 Focus Appearance).\n */\nconst sideNavRowVariants = cva(\n [\n 'w-full cursor-pointer rounded-r-sm border-l border-transparent py-1 pr-2 pl-4 text-left text-base/8 sm:text-sm/6',\n 'transition-colors motion-reduce:transition-none',\n 'hover:border-grey-950 hover:bg-primary-800/10 hover:font-semibold hover:text-grey-950',\n 'dark:text-grey-400 dark:hover:border-grey-400 dark:hover:text-white',\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current',\n ],\n {\n variants: {\n current: {\n true: 'border-primary-800 bg-primary-800/10 font-bold text-primary-800 dark:border-white dark:bg-white/20 dark:text-white',\n false: '',\n },\n },\n defaultVariants: {\n current: false,\n },\n },\n)\n\n/**\n * Port of nswds-app's `isLinkOrDescendantActive`: true when the item itself,\n * or any item anywhere beneath it, is the current page. Drives `defaultOpen`\n * on branch collapsibles so the rail opens onto the reader's location.\n */\nfunction isItemOrDescendantCurrent(item: SideNavItem, currentHref: string | undefined): boolean {\n if (currentHref === undefined) {\n return false\n }\n if (item.href === currentHref) {\n return true\n }\n return item.links?.some((child) => isItemOrDescendantCurrent(child, currentHref)) ?? false\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: an item\n * with neither destination nor children renders as inert text (a decoy link\n * would violate WCAG 2.2, 4.1.2 Name, Role, Value expectations), and a branch's\n * `href` is silently unreachable because the row renders as a disclosure\n * button. Both are almost certainly data mistakes. No-op in production.\n */\nfunction warnIfItemMisshapen(item: SideNavItem) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n const hasChildren = (item.links?.length ?? 0) > 0\n if (!hasChildren && item.href === undefined) {\n console.warn(\n `[nswds/ui] SideNav item \"${item.title}\" has neither href nor links — it renders as inert text. Give it a destination or children.`,\n )\n }\n if (hasChildren && item.href !== undefined) {\n console.warn(\n `[nswds/ui] SideNav item \"${item.title}\" has both href and links — branch rows render as collapsible triggers, so its href is unreachable. Add a separate leaf item for the destination.`,\n )\n }\n}\n\ntype SideNavListProps = {\n items: SideNavItem[]\n currentHref?: string\n onNavigate?: React.MouseEventHandler<HTMLAnchorElement>\n /** Deeper than the section rail — tighter gap, indented, per the source. */\n nested?: boolean\n}\n\n/**\n * A rail of rows: the bordered `<ul>` every level of the tree renders into.\n * `role='list'` is kept from the source — Safari/VoiceOver strips list\n * semantics from lists whose `list-style` is removed, and the explicit role\n * restores them (this is the one sanctioned hand-written role in the file).\n */\nfunction SideNavList({ items, currentHref, onNavigate, nested = false }: SideNavListProps) {\n return (\n <ul\n role='list'\n data-slot='side-nav-list'\n className={cn(\n 'flex flex-col border-l border-grey-400 dark:border-grey-200/15',\n nested ? 'mt-2 ml-5 gap-1' : 'mt-2 gap-2 lg:mt-4',\n )}\n >\n {items.map((item) => (\n <SideNavRow\n key={item.href ?? item.title}\n item={item}\n currentHref={currentHref}\n onNavigate={onNavigate}\n />\n ))}\n </ul>\n )\n}\n\ntype SideNavRowProps = {\n item: SideNavItem\n currentHref?: string\n onNavigate?: React.MouseEventHandler<HTMLAnchorElement>\n}\n\n/**\n * One row of the rail — a leaf link, a collapsible branch, or (data mistake)\n * inert text. Recurses through `SideNavList` for branch children.\n */\nfunction SideNavRow({ item, currentHref, onNavigate }: SideNavRowProps) {\n const hasChildren = (item.links?.length ?? 0) > 0\n const isCurrent = currentHref !== undefined && item.href === currentHref\n\n warnIfItemMisshapen(item)\n\n if (hasChildren) {\n return (\n <li data-slot='side-nav-item' className='-ml-px flex w-full flex-col items-start gap-1'>\n {/* defaultOpen (not controlled `open`) so the branch holding the\n current page starts expanded but the reader can still fold it —\n the source's auto-expansion behaviour exactly. */}\n <Collapsible className='w-full' defaultOpen={isItemOrDescendantCurrent(item, currentHref)}>\n {/* Base UI's Trigger owns the disclosure semantics (aria-expanded,\n aria-controls, keyboard activation) — nothing hand-rolled here.\n `group` scopes the chevron's rotation to THIS trigger: nested\n triggers are never ancestors of each other's icons, and the\n Collapsible root carries data-open (not data-panel-open), so an\n open outer branch cannot rotate descendant chevrons. */}\n <CollapsibleTrigger\n data-slot='side-nav-trigger'\n className={cn(sideNavRowVariants(), 'group flex items-center justify-between gap-1')}\n >\n <span>{item.title}</span>\n <IconChevronRight\n aria-hidden='true'\n className='ml-2 size-5 shrink-0 transition-transform duration-200 group-data-panel-open:rotate-90 motion-reduce:transition-none'\n />\n </CollapsibleTrigger>\n <CollapsibleContent data-slot='side-nav-panel'>\n <SideNavList\n items={item.links ?? []}\n currentHref={currentHref}\n onNavigate={onNavigate}\n nested\n />\n </CollapsibleContent>\n </Collapsible>\n </li>\n )\n }\n\n if (item.href === undefined) {\n // No destination, no children: inert text, not a decoy anchor. The\n // dev-only warning above names the item.\n return (\n <li data-slot='side-nav-item' className='-ml-px flex w-full flex-col items-start gap-1'>\n <span\n data-slot='side-nav-text'\n className={cn(sideNavRowVariants(), 'inline-block cursor-default')}\n >\n {item.title}\n </span>\n </li>\n )\n }\n\n return (\n <li data-slot='side-nav-item' className='-ml-px flex w-full flex-col items-start gap-1'>\n {/* variant='unstyled' — the rail supplies the complete row treatment;\n Link's underline/colour variants would fight it. Rendering through\n Link still picks up the framework link component from LinkProvider\n (next/link et al). */}\n <Link\n variant='unstyled'\n data-slot='side-nav-link'\n href={item.href}\n onClick={onNavigate}\n aria-current={isCurrent ? 'page' : undefined}\n className={cn(sideNavRowVariants({ current: isCurrent }), 'inline-block')}\n >\n {item.title}\n </Link>\n </li>\n )\n}\n\ntype SideNavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> & {\n /**\n * The navigation tree. A top-level item with `links` renders as a section\n * heading over an always-visible rail; one without renders as a plain rail\n * link — mirroring nswds-app `Navigation`'s section shape. Deeper items with\n * `links` render as collapsible branches (nswds-app `SidebarNavigation`).\n */\n sections: SideNavItem[]\n /**\n * The current page's href. The matching leaf gets `aria-current='page'` and\n * the active rail treatment, and every branch on the path to it starts\n * expanded — at MOUNT only. Branches are `defaultOpen`, not controlled: a\n * later `currentHref` change (SPA navigation) re-highlights the leaf but\n * never re-expands a branch the reader has folded, so the highlight can\n * land inside a collapsed branch. Branch expansion is seeded from\n * `currentHref` on mount; pass a `key` (e.g. `key={currentHref}`) to\n * remount and re-open the path on navigation — the same contract as\n * PushMenu's level stack. Frameworkless replacement for the source's\n * `usePathname()` — pass your router's pathname in.\n */\n currentHref?: string\n /**\n * Fired from every leaf link (never from branch triggers). The mobile-drawer\n * close hook, as in the source's `onLinkClick`.\n */\n onNavigate?: React.MouseEventHandler<HTMLAnchorElement>\n /**\n * Heading level for section titles. Defaults to `2` — correct when the nav\n * sits at the top level of the document outline. Step it down when the page\n * nests the nav under another heading (WCAG 1.3.1). `1` is excluded: a\n * section-nav heading is never the page's own title. Same contract as\n * `FooterNavColumn`.\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Left-rail section navigation — the consolidation of nswds-app's flat\n * `Navigation` and recursive `SidebarNavigation` into one tree-shaped\n * component. Renders a `<nav>` landmark of headed sections whose links may\n * nest to any depth; nested branches collapse.\n *\n * Accessibility contract:\n * - The landmark is named (`aria-label`, default \"Section navigation\") so it is\n * distinguishable from the page's other navigation landmarks (WCAG 1.3.1).\n * - Disclosure semantics — `aria-expanded`, `aria-controls`, Enter/Space\n * activation — come entirely from Base UI's Collapsible; nothing hand-rolled.\n * - The current page is marked with `aria-current='page'`, and every branch on\n * the path to it starts expanded ON MOUNT, so the highlighted location is\n * visible on arrival (ported `isLinkOrDescendantActive`). Expansion is\n * `defaultOpen`, so it does not re-run when `currentHref` changes — see the\n * `currentHref` prop for the `key={currentHref}` remount workaround.\n * - Focus is always visible via the house `outline-current` pattern (2.4.13).\n *\n * Departures from the nswds-app source (see also `sideNavRowVariants` and\n * `SideNavItem`):\n * - `usePathname()` → the `currentHref` prop; links render through `Link`, so\n * frameworks inject their own anchor via `LinkProvider`.\n * - The Radix-based Collapsible → the Base UI primitive (this repo's\n * `collapsible.tsx`), whose open state is `data-panel-open` on the trigger\n * rather than Radix's `data-state='open'`.\n * - The source rendered a stray empty `<ul>` after link-less sections and sent\n * `href='#'` placeholders through the tree; both are dropped.\n */\nfunction SideNav({\n className,\n sections,\n currentHref,\n onNavigate,\n headingLevel = 2,\n 'aria-label': ariaLabel = 'Section navigation',\n ref,\n ...props\n}: SideNavProps) {\n const Heading = `h${headingLevel}` as const\n\n return (\n <nav\n data-slot='side-nav'\n {...props}\n aria-label={ariaLabel}\n // Base ink declared once here (the source inherited the page body's\n // colour in light mode; a design-system component states it).\n className={cn('text-base text-grey-800 lg:text-sm dark:text-grey-400', className)}\n ref={ref}\n >\n <ul role='list' data-slot='side-nav-sections' className='flex flex-col gap-9'>\n {sections.map((section) => (\n <li key={section.href ?? section.title} data-slot='side-nav-section'>\n {section.links ? (\n <>\n {/* font-display resolves through @nswds/tokens' Tailwind\n preset (--font-display, Public Sans stack) — the same\n utility the source used. */}\n <Heading\n data-slot='side-nav-heading'\n className='font-display font-medium text-grey-800 dark:text-white'\n >\n {section.title}\n </Heading>\n <SideNavList\n items={section.links}\n currentHref={currentHref}\n onNavigate={onNavigate}\n />\n </>\n ) : (\n // A link-less section is a single rail link (Navigation.tsx\n // parity) — reuse the rail so the border/offset stay identical.\n <SideNavList items={[section]} currentHref={currentHref} onNavigate={onNavigate} />\n )}\n </li>\n ))}\n </ul>\n </nav>\n )\n}\n\nexport { SideNav, sideNavRowVariants }\nexport type { SideNavItem, SideNavProps }\nexport type SideNavRowVariantProps = VariantProps<typeof sideNavRowVariants>\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/side-nav.tsx"],"names":[],"mappings":";;;;;;;AAoDA,MAAM,kBAAA,GAAqB,GAAA;AAAA,EACzB;AAAA,IACE,yHAAA;AAAA,IACA,+BAAA;AAAA,IACA,uFAAA;AAAA,IACA,qEAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,IAAA,EAAM,oHAAA;AAAA,QACN,KAAA,EAAO;AAAA;AACT,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS;AAAA;AACX;AAEJ;AAOA,SAAS,yBAAA,CAA0B,MAAmB,WAAA,EAA0C;AAC9F,EAAA,IAAI,gBAAgB,MAAA,EAAW;AAC7B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,IAAA,CAAK,SAAS,WAAA,EAAa;AAC7B,IAAA,OAAO,IAAA;AAAA,EACT;AACA,EAAA,OAAO,IAAA,CAAK,OAAO,IAAA,CAAK,CAAC,UAAU,yBAAA,CAA0B,KAAA,EAAO,WAAW,CAAC,CAAA,IAAK,KAAA;AACvF;AASA,SAAS,oBAAoB,IAAA,EAAmB;AAC9C,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AACzC,IAAA;AAAA,EACF;AACA,EAAA,MAAM,WAAA,GAAA,CAAe,IAAA,CAAK,KAAA,EAAO,MAAA,IAAU,CAAA,IAAK,CAAA;AAChD,EAAA,IAAI,CAAC,WAAA,IAAe,IAAA,CAAK,IAAA,KAAS,MAAA,EAAW;AAC3C,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN,CAAA,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DAAA;AAAA,YAET,QAAA,EAAA,OAAA,CAAQ;AAAA;AAAA,SACX;AAAA,wBACA,GAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,OAAO,OAAA,CAAQ,KAAA;AAAA,YACf,WAAA;AAAA,YACA;AAAA;AAAA;AACF,OAAA,EACF,CAAA;AAAA;AAAA;AAAA,4BAIC,WAAA,EAAA,EAAY,KAAA,EAAO,CAAC,OAAO,CAAA,EAAG,aAA0B,UAAA,EAAwB;AAAA,OAAA,EAAA,EArB5E,OAAA,CAAQ,IAAA,IAAQ,OAAA,CAAQ,KAuBjC,CACD,CAAA,EACH;AAAA;AAAA,GACF;AAEJ","file":"side-nav.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../components/collapsible.js'\nimport { Link } from '../components/link.js'\nimport { IconChevronRight } from '../icons/chevron-right.js'\n\n/**\n * One entry in a `SideNav` tree.\n *\n * - `href` and no `links` — a leaf link.\n * - `links` — a branch. At the top level it renders as a section heading over an\n * always-visible list; at any deeper level it renders as a collapsible\n * trigger. A branch's own `href` is IGNORED (the row is a disclosure button,\n * not a link) — a dev-only warning flags it, mirroring the nswds-app\n * `SidebarNavigation` behaviour where branch rows only toggled.\n * - Neither — a dead entry; rendered as inert text and flagged with a dev-only\n * warning rather than a decoy `<a>` with no destination.\n */\ntype SideNavItem = {\n /** Visible text for the link, section heading, or branch trigger. */\n title: string\n href?: string\n links?: SideNavItem[]\n}\n\n/**\n * Row treatment shared by leaf links and branch triggers — the nswds-app\n * left-rail language: each row carries its own left border sitting exactly on\n * the list's rail (the `-ml-px` on the `<li>`), so hover and the current-page\n * state recolour the rail segment beside the row.\n *\n * Departures from the source, both deliberate:\n * - The idle border is `border-transparent` rather than the bare `border-l`\n * default: idle rows show the rail through their transparent border, so the\n * idle rail colour is defined once (on the list) instead of twice.\n * - The current row adds `dark:text-white`. The source left dark active text\n * to fall through to the idle `dark:text-grey-400`, which on the\n * `dark:bg-white/20` highlight is both low-contrast and cascade-order\n * dependent; bold white ink clears WCAG 2.2 AA (1.4.3) on that overlay.\n *\n * The hover font-weight change (`hover:font-semibold`) is source parity; it\n * reflows the row's own text only, never the rail.\n *\n * Focus uses the house visible-focus pattern (outline-current, offset 2), so\n * the indicator always contrasts with whatever text colour the row currently\n * has (WCAG 2.2, 2.4.13 Focus Appearance).\n */\nconst sideNavRowVariants = cva(\n [\n 'w-full cursor-pointer rounded-r-sm border-l border-transparent py-1 pr-2 pl-4 text-left max-sm:text-base/8 sm:text-sm/6',\n 'motion-safe:transition-colors',\n 'hover:border-grey-950 hover:bg-primary-800/10 hover:font-semibold hover:text-grey-950',\n 'dark:text-grey-400 dark:hover:border-grey-400 dark:hover:text-white',\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current',\n ],\n {\n variants: {\n current: {\n true: 'border-primary-800 bg-primary-800/10 font-bold text-primary-800 dark:border-white dark:bg-white/20 dark:text-white',\n false: '',\n },\n },\n defaultVariants: {\n current: false,\n },\n },\n)\n\n/**\n * Port of nswds-app's `isLinkOrDescendantActive`: true when the item itself,\n * or any item anywhere beneath it, is the current page. Drives `defaultOpen`\n * on branch collapsibles so the rail opens onto the reader's location.\n */\nfunction isItemOrDescendantCurrent(item: SideNavItem, currentHref: string | undefined): boolean {\n if (currentHref === undefined) {\n return false\n }\n if (item.href === currentHref) {\n return true\n }\n return item.links?.some((child) => isItemOrDescendantCurrent(child, currentHref)) ?? false\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: an item\n * with neither destination nor children renders as inert text (a decoy link\n * would violate WCAG 2.2, 4.1.2 Name, Role, Value expectations), and a branch's\n * `href` is silently unreachable because the row renders as a disclosure\n * button. Both are almost certainly data mistakes. No-op in production.\n */\nfunction warnIfItemMisshapen(item: SideNavItem) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n const hasChildren = (item.links?.length ?? 0) > 0\n if (!hasChildren && item.href === undefined) {\n console.warn(\n `[nswds/ui] SideNav item \"${item.title}\" has neither href nor links — it renders as inert text. Give it a destination or children.`,\n )\n }\n if (hasChildren && item.href !== undefined) {\n console.warn(\n `[nswds/ui] SideNav item \"${item.title}\" has both href and links — branch rows render as collapsible triggers, so its href is unreachable. Add a separate leaf item for the destination.`,\n )\n }\n}\n\ntype SideNavListProps = {\n items: SideNavItem[]\n currentHref?: string\n onNavigate?: React.MouseEventHandler<HTMLAnchorElement>\n /** Deeper than the section rail — tighter gap, indented, per the source. */\n nested?: boolean\n}\n\n/**\n * A rail of rows: the bordered `<ul>` every level of the tree renders into.\n * `role='list'` is kept from the source — Safari/VoiceOver strips list\n * semantics from lists whose `list-style` is removed, and the explicit role\n * restores them (this is the one sanctioned hand-written role in the file).\n */\nfunction SideNavList({ items, currentHref, onNavigate, nested = false }: SideNavListProps) {\n return (\n <ul\n role='list'\n data-slot='side-nav-list'\n className={cn(\n 'flex flex-col border-l border-grey-400 dark:border-grey-200/15',\n nested ? 'mt-2 ml-5 gap-1' : 'gap-2 max-lg:mt-2 lg:mt-4',\n )}\n >\n {items.map((item) => (\n <SideNavRow\n key={item.href ?? item.title}\n item={item}\n currentHref={currentHref}\n onNavigate={onNavigate}\n />\n ))}\n </ul>\n )\n}\n\ntype SideNavRowProps = {\n item: SideNavItem\n currentHref?: string\n onNavigate?: React.MouseEventHandler<HTMLAnchorElement>\n}\n\n/**\n * One row of the rail — a leaf link, a collapsible branch, or (data mistake)\n * inert text. Recurses through `SideNavList` for branch children.\n */\nfunction SideNavRow({ item, currentHref, onNavigate }: SideNavRowProps) {\n const hasChildren = (item.links?.length ?? 0) > 0\n const isCurrent = currentHref !== undefined && item.href === currentHref\n\n warnIfItemMisshapen(item)\n\n if (hasChildren) {\n return (\n <li data-slot='side-nav-item' className='-ml-px flex w-full flex-col items-start gap-1'>\n {/* defaultOpen (not controlled `open`) so the branch holding the\n current page starts expanded but the reader can still fold it —\n the source's auto-expansion behaviour exactly. */}\n <Collapsible className='w-full' defaultOpen={isItemOrDescendantCurrent(item, currentHref)}>\n {/* Base UI's Trigger owns the disclosure semantics (aria-expanded,\n aria-controls, keyboard activation) — nothing hand-rolled here.\n `group` scopes the chevron's rotation to THIS trigger: nested\n triggers are never ancestors of each other's icons, and the\n Collapsible root carries data-open (not data-panel-open), so an\n open outer branch cannot rotate descendant chevrons. */}\n <CollapsibleTrigger\n data-slot='side-nav-trigger'\n className={cn(sideNavRowVariants(), 'group flex items-center justify-between gap-1')}\n >\n <span>{item.title}</span>\n <IconChevronRight\n aria-hidden='true'\n className='ml-2 size-5 shrink-0 duration-200 group-data-panel-open:rotate-90 motion-safe:transition-transform'\n />\n </CollapsibleTrigger>\n <CollapsibleContent data-slot='side-nav-panel'>\n <SideNavList\n items={item.links ?? []}\n currentHref={currentHref}\n onNavigate={onNavigate}\n nested\n />\n </CollapsibleContent>\n </Collapsible>\n </li>\n )\n }\n\n if (item.href === undefined) {\n // No destination, no children: inert text, not a decoy anchor. The\n // dev-only warning above names the item.\n return (\n <li data-slot='side-nav-item' className='-ml-px flex w-full flex-col items-start gap-1'>\n <span\n data-slot='side-nav-text'\n className={cn(sideNavRowVariants(), 'inline-block cursor-default')}\n >\n {item.title}\n </span>\n </li>\n )\n }\n\n return (\n <li data-slot='side-nav-item' className='-ml-px flex w-full flex-col items-start gap-1'>\n {/* variant='unstyled' — the rail supplies the complete row treatment;\n Link's underline/colour variants would fight it. Rendering through\n Link still picks up the framework link component from LinkProvider\n (next/link et al). */}\n <Link\n variant='unstyled'\n data-slot='side-nav-link'\n href={item.href}\n onClick={onNavigate}\n aria-current={isCurrent ? 'page' : undefined}\n className={cn(sideNavRowVariants({ current: isCurrent }), 'inline-block')}\n >\n {item.title}\n </Link>\n </li>\n )\n}\n\ntype SideNavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> & {\n /**\n * The navigation tree. A top-level item with `links` renders as a section\n * heading over an always-visible rail; one without renders as a plain rail\n * link — mirroring nswds-app `Navigation`'s section shape. Deeper items with\n * `links` render as collapsible branches (nswds-app `SidebarNavigation`).\n */\n sections: SideNavItem[]\n /**\n * The current page's href. The matching leaf gets `aria-current='page'` and\n * the active rail treatment, and every branch on the path to it starts\n * expanded — at MOUNT only. Branches are `defaultOpen`, not controlled: a\n * later `currentHref` change (SPA navigation) re-highlights the leaf but\n * never re-expands a branch the reader has folded, so the highlight can\n * land inside a collapsed branch. Branch expansion is seeded from\n * `currentHref` on mount; pass a `key` (e.g. `key={currentHref}`) to\n * remount and re-open the path on navigation — the same contract as\n * PushMenu's level stack. Frameworkless replacement for the source's\n * `usePathname()` — pass your router's pathname in.\n */\n currentHref?: string\n /**\n * Fired from every leaf link (never from branch triggers). The mobile-drawer\n * close hook, as in the source's `onLinkClick`.\n */\n onNavigate?: React.MouseEventHandler<HTMLAnchorElement>\n /**\n * Heading level for section titles. Defaults to `2` — correct when the nav\n * sits at the top level of the document outline. Step it down when the page\n * nests the nav under another heading (WCAG 1.3.1). `1` is excluded: a\n * section-nav heading is never the page's own title. Same contract as\n * `FooterNavColumn`.\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6\n ref?: React.Ref<HTMLElement>\n}\n\n/**\n * Left-rail section navigation — the consolidation of nswds-app's flat\n * `Navigation` and recursive `SidebarNavigation` into one tree-shaped\n * component. Renders a `<nav>` landmark of headed sections whose links may\n * nest to any depth; nested branches collapse.\n *\n * Accessibility contract:\n * - The landmark is named (`aria-label`, default \"Section navigation\") so it is\n * distinguishable from the page's other navigation landmarks (WCAG 1.3.1).\n * - Disclosure semantics — `aria-expanded`, `aria-controls`, Enter/Space\n * activation — come entirely from Base UI's Collapsible; nothing hand-rolled.\n * - The current page is marked with `aria-current='page'`, and every branch on\n * the path to it starts expanded ON MOUNT, so the highlighted location is\n * visible on arrival (ported `isLinkOrDescendantActive`). Expansion is\n * `defaultOpen`, so it does not re-run when `currentHref` changes — see the\n * `currentHref` prop for the `key={currentHref}` remount workaround.\n * - Focus is always visible via the house `outline-current` pattern (2.4.13).\n *\n * Departures from the nswds-app source (see also `sideNavRowVariants` and\n * `SideNavItem`):\n * - `usePathname()` → the `currentHref` prop; links render through `Link`, so\n * frameworks inject their own anchor via `LinkProvider`.\n * - The Radix-based Collapsible → the Base UI primitive (this repo's\n * `collapsible.tsx`), whose open state is `data-panel-open` on the trigger\n * rather than Radix's `data-state='open'`.\n * - The source rendered a stray empty `<ul>` after link-less sections and sent\n * `href='#'` placeholders through the tree; both are dropped.\n */\nfunction SideNav({\n className,\n sections,\n currentHref,\n onNavigate,\n headingLevel = 2,\n 'aria-label': ariaLabel = 'Section navigation',\n ref,\n ...props\n}: SideNavProps) {\n const Heading = `h${headingLevel}` as const\n\n return (\n <nav\n data-slot='side-nav'\n {...props}\n aria-label={ariaLabel}\n // Base ink declared once here (the source inherited the page body's\n // colour in light mode; a design-system component states it).\n className={cn('text-grey-800 max-lg:text-base lg:text-sm dark:text-grey-400', className)}\n ref={ref}\n >\n <ul role='list' data-slot='side-nav-sections' className='flex flex-col gap-9'>\n {sections.map((section) => (\n <li key={section.href ?? section.title} data-slot='side-nav-section'>\n {section.links ? (\n <>\n {/* font-display resolves through @nswds/tokens' Tailwind\n preset (--font-display, Public Sans stack) — the same\n utility the source used. */}\n <Heading\n data-slot='side-nav-heading'\n className='font-display font-medium text-grey-800 dark:text-white'\n >\n {section.title}\n </Heading>\n <SideNavList\n items={section.links}\n currentHref={currentHref}\n onNavigate={onNavigate}\n />\n </>\n ) : (\n // A link-less section is a single rail link (Navigation.tsx\n // parity) — reuse the rail so the border/offset stay identical.\n <SideNavList items={[section]} currentHref={currentHref} onNavigate={onNavigate} />\n )}\n </li>\n ))}\n </ul>\n </nav>\n )\n}\n\nexport { SideNav, sideNavRowVariants }\nexport type { SideNavItem, SideNavProps }\nexport type SideNavRowVariantProps = VariantProps<typeof sideNavRowVariants>\n"]}
|
|
@@ -91,7 +91,7 @@ function SiteSearch({
|
|
|
91
91
|
Dialog.Backdrop,
|
|
92
92
|
{
|
|
93
93
|
"data-slot": "site-search-overlay",
|
|
94
|
-
className: "fixed inset-0 z-50 bg-black/80
|
|
94
|
+
className: "fixed inset-0 z-50 bg-black/80 duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs motion-safe:transition-opacity"
|
|
95
95
|
}
|
|
96
96
|
),
|
|
97
97
|
/* @__PURE__ */ jsxs(
|
|
@@ -104,7 +104,7 @@ function SiteSearch({
|
|
|
104
104
|
// Centred panel on the house popup surface (popover.tsx / sheet.tsx).
|
|
105
105
|
"fixed top-[max(--spacing(4),15vh)] left-1/2 z-50 w-[calc(100vw-2rem)] max-w-2xl -translate-x-1/2",
|
|
106
106
|
"rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden",
|
|
107
|
-
"
|
|
107
|
+
"duration-150 ease-out motion-safe:transition",
|
|
108
108
|
"data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0",
|
|
109
109
|
className
|
|
110
110
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/site-search.tsx"],"names":[],"mappings":";;;;;;;;AA4HA,SAAS,UAAA,CAAW;AAAA,EAClB,MAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA,EAAM,QAAA;AAAA,EACN,YAAA;AAAA,EACA,WAAA,GAAc,KAAA;AAAA,EACd,QAAA,GAAW,IAAA;AAAA,EACX,KAAA,GAAQ,aAAA;AAAA,EACR,WAAA,GAAc,mCAAA;AAAA,EACd,YAAA,GAAe,mBAAA;AAAA,EACf,OAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAAoB;AAClB,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,KAAA,CAAM,SAAS,WAAW,CAAA;AAC1E,EAAA,MAAM,eAAe,QAAA,KAAa,MAAA;AAClC,E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,8BAAC,YAAA,CAAa,IAAA;AAAA,8BAAb;AAAA,gCAEC,KAAA,EAAO,IAAA;AAAA,gCACP,WAAA,EAAU,kBAAA;AAAA,gCACV,OAAA,EAAS,MAAM,YAAA,CAAa,IAAI,CAAA;AAAA,gCAGhC,SAAA,EAAU,4OAAA;AAAA,gCAET,QAAA,EAAA,IAAA,CAAK;AAAA,+BAAA;AAAA,8BARD,IAAA,CAAK;AAAA,6BASZ,EAEJ;AAAA;AAAA,yBAAA;AAAA,wBAxBK,KAAA,CAAM;AAAA;AAyBb;AAAA;AAEJ;AAAA;AAAA,aACF;AAAA,YAEC,YAAY,IAAA,mBACX,GAAA;AAAA,cAAC,KAAA;AAAA,cAAA;AAAA,gBACC,WAAA,EAAU,oBAAA;AAAA,gBACV,SAAA,EAAU,uEAAA;AAAA,gBAET;AAAA;AAAA,aACH,GACE;AAAA;AAAA;AAAA;AACN,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"site-search.js","sourcesContent":["'use client'\n\nimport { Autocomplete } from '@base-ui/react/autocomplete'\nimport { Dialog } from '@base-ui/react/dialog'\nimport React from 'react'\n\nimport { IconSearch } from '../icons/search.js'\nimport { cn } from '../lib/utils.js'\n\nimport { Button } from '../components/button.js'\n\n/** A single searchable destination. `keywords` extend matching beyond the title. */\ntype SiteSearchItem = {\n title: string\n href: string\n keywords?: string[]\n}\n\n/** A titled section of results, rendered with a muted group heading. */\ntype SiteSearchGroup = {\n title: string\n items: SiteSearchItem[]\n}\n\ntype SiteSearchProps = {\n /** The searchable site map, as titled groups of items. */\n groups: SiteSearchGroup[]\n /**\n * Called with the chosen item on click or Enter, after the palette closes.\n * Navigation is the APP's job — call your router here (e.g. next/navigation's\n * `router.push(item.href)`). The design system ships no framework code, so it\n * never navigates itself; this mirrors the DS-wide framework-free rule\n * (see `Link` / `LinkProvider`).\n */\n onSelect: (item: SiteSearchItem) => void\n /** Whether the palette is open. Use when controlled. */\n open?: boolean\n /** Called whenever the palette asks to open or close. */\n onOpenChange?: (open: boolean) => void\n /** Whether the palette is initially open (uncontrolled). */\n defaultOpen?: boolean\n /**\n * Wire the global Cmd/Ctrl-K toggle on `document`, with cleanup on unmount.\n * Defaults to true. Only one shortcut-enabled SiteSearch should be mounted\n * per page, or each press toggles all of them.\n */\n shortcut?: boolean\n /**\n * Accessible name for the palette, applied as `aria-label` to the dialog\n * panel, the search input and the default trigger. Defaults to\n * `'Search site'`. Mirrors ExpandableSearch's `label` prop — localise it\n * rather than hardcoding English into consumers' pages.\n */\n label?: string\n /** Placeholder for the search input. */\n placeholder?: string\n /** Message shown when no items match the query. */\n emptyMessage?: string\n /**\n * The element that opens the palette. Defaults to a ghost icon `Button`\n * named by `label`. Pass an element to replace it — it is composed via Base\n * UI's `render` prop, so it inherits the trigger behaviour and ARIA — or\n * `null` to render no trigger at all (open via `open` or the shortcut).\n * A custom trigger owns its own accessible name — `label` is applied as\n * `aria-label` to the default icon button only, since overriding a visible\n * label that way fails WCAG 2.2, 2.5.3 Label in Name.\n *\n * Conditional triggers must resolve to `null`, not `false`: write\n * `cond ? <Button/> : null`, since `cond && <Button/>` yields `false`, which\n * Base UI's `render` prop rejects with an invalid-element error. TypeScript\n * catches it (`false` is not assignable here); plain-JS consumers see the\n * error at render.\n */\n trigger?: React.ReactElement | null\n /**\n * Extra content rendered at the foot of the panel, below the results —\n * e.g. shortcut hints or a \"browse all\" link.\n */\n children?: React.ReactNode\n /** Extra classes for the centred panel. */\n className?: string\n}\n\n/**\n * Cmd/Ctrl-K command-palette site search: a centred modal panel with a\n * filter-as-you-type input over a grouped list of destinations.\n *\n * Ported from nswds-app's `MobileSearch`, rebuilt framework-free: the app\n * version composed cmdk's `Command*` widgets with next/navigation's router;\n * this version composes Base UI's Autocomplete (the combobox/listbox pattern)\n * inside Base UI's Dialog, and hands the chosen item to `onSelect` instead of\n * navigating. The Autocomplete renders in `inline` mode — its input and list\n * sit statically inside the dialog panel with no popup of their own — which is\n * Base UI's documented composition for palettes (it avoids any portal /\n * focus-trap interplay between the two primitives; the always-`open` inline\n * root unmounts with the dialog, so the query and highlight reset on close).\n *\n * Accessibility contract (inherited, not hand-rolled):\n * - Dialog provides the modal behaviour: focus trap, scroll lock, Escape and\n * backdrop-press dismissal, and focus restoration to the trigger on close.\n * The panel is named via `aria-label` (WCAG 2.2, 4.1.2).\n * - Autocomplete provides the combobox pattern: the input is announced as a\n * combobox controlling a listbox, arrow keys move `aria-activedescendant`\n * highlight while DOM focus stays in the input, Enter activates the\n * highlighted item, and the empty state is announced politely.\n * - The trigger (default or custom) renders through `Dialog.Trigger`, so it\n * carries `aria-haspopup=\"dialog\"` / `aria-expanded` automatically.\n * - Result rows are at least 44px tall (2.5.8 Target Size, AAA-sized).\n * - Panel and backdrop transitions honour `prefers-reduced-motion` (2.3.3).\n *\n * Departures from the nswds-app source, beyond the rebuild above:\n * - `groups`/`onSelect` replace the app's `NavigationItem[]` + router: the\n * data shape is explicit (`title`/`href`/`keywords`) instead of the app's\n * nav config, and untitled/unlinked entries can't exist by construction\n * (the source filtered them at render time).\n * - Filtering matches `title` AND `keywords`, case-insensitively, via the\n * Autocomplete `filter` prop. Base UI's `useFilter` helper only matches one\n * string per item, so a custom predicate is the documented escape hatch for\n * multi-field matching; groups with no matching items are dropped by the\n * primitive, headings included.\n * - The Cmd/Ctrl-K listener can be disabled (`shortcut={false}`) — required\n * for pages that mount more than one instance. It still toggles, per the\n * source.\n */\nfunction SiteSearch({\n groups,\n onSelect,\n open: openProp,\n onOpenChange,\n defaultOpen = false,\n shortcut = true,\n label = 'Search site',\n placeholder = 'Type to search across the site...',\n emptyMessage = 'No results found.',\n trigger,\n children,\n className,\n}: SiteSearchProps) {\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const isControlled = openProp !== undefined\n const open = isControlled ? openProp : uncontrolledOpen\n\n const inputRef = React.useRef<HTMLInputElement>(null)\n\n // Latest-value refs so the document-level shortcut listener (bound once per\n // `shortcut` value) never acts on a stale open state or stale callbacks.\n // They are written in a passive effect (not during render, per\n // react-hooks/refs) — safe because they are only read from event listeners,\n // which always fire after the commit that synced them.\n const openRef = React.useRef(open)\n const requestOpenChangeRef = React.useRef<(next: boolean) => void>(() => {})\n\n const requestOpenChange = (next: boolean) => {\n if (isControlled) {\n // Dedupe against the render-authoritative prop only — never write\n // openRef optimistically here. An optimistic write would let a parent\n // that vetoes a request (ignores it, so no re-render runs the resync\n // effect) permanently swallow every later identical request. Accepted\n // trade-off: a same-tick duplicate close (Escape reaching both the\n // Autocomplete and the Dialog) may reach `onOpenChange` twice with the\n // same value — idempotent for a setState parent, and correctness in\n // the veto case beats dedupe cosmetics.\n if (open === next) {\n return\n }\n onOpenChange?.(next)\n return\n }\n // Uncontrolled, the component owns the state, so the optimistic write is\n // safe (the commit below confirms it) and dedupes the double-report case\n // (both primitives announcing the same close) down to one callback.\n if (openRef.current === next) {\n return\n }\n openRef.current = next\n setUncontrolledOpen(next)\n onOpenChange?.(next)\n }\n\n React.useEffect(() => {\n // `open` (not `next` from an event) is authoritative here: in controlled\n // mode this effect is the ref's ONLY writer, so the shortcut listener\n // always toggles from the last value the parent actually rendered.\n openRef.current = open\n requestOpenChangeRef.current = requestOpenChange\n })\n\n React.useEffect(() => {\n if (!shortcut) {\n return undefined\n }\n const handleKeyDown = (event: KeyboardEvent) => {\n if (\n event.key.toLowerCase() === 'k' &&\n (event.metaKey || event.ctrlKey) &&\n !event.altKey &&\n !event.defaultPrevented\n ) {\n event.preventDefault()\n // Toggle, per the nswds-app source: the same chord opens and closes.\n requestOpenChangeRef.current(!openRef.current)\n }\n }\n document.addEventListener('keydown', handleKeyDown)\n return () => document.removeEventListener('keydown', handleKeyDown)\n }, [shortcut])\n\n const handleSelect = (item: SiteSearchItem) => {\n // Close first, then hand over — mirrors the source's `runCommand`, so the\n // app's navigation starts from a closed palette.\n requestOpenChange(false)\n onSelect(item)\n }\n\n const filter = React.useCallback((item: SiteSearchItem, query: string) => {\n const q = query.trim().toLowerCase()\n if (q === '') {\n return true\n }\n if (item.title.toLowerCase().includes(q)) {\n return true\n }\n return (item.keywords ?? []).some((keyword) => keyword.toLowerCase().includes(q))\n }, [])\n\n const defaultTrigger = (\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={label}\n leadingVisual={IconSearch}\n />\n )\n\n return (\n <Dialog.Root open={open} onOpenChange={(next) => requestOpenChange(next)}>\n {trigger === null ? null : (\n <Dialog.Trigger data-slot='site-search-trigger' render={trigger ?? defaultTrigger} />\n )}\n\n <Dialog.Portal>\n <Dialog.Backdrop\n data-slot='site-search-overlay'\n className='fixed inset-0 z-50 bg-black/80 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs motion-reduce:transition-none'\n />\n <Dialog.Popup\n data-slot='site-search-panel'\n aria-label={label}\n // The default focus target on touch is the panel itself (to keep the\n // virtual keyboard closed) — wrong for a search palette, whose whole\n // purpose is typing. Always focus the input.\n initialFocus={inputRef}\n className={cn(\n // Centred panel on the house popup surface (popover.tsx / sheet.tsx).\n 'fixed top-[max(--spacing(4),15vh)] left-1/2 z-50 w-[calc(100vw-2rem)] max-w-2xl -translate-x-1/2',\n 'rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden',\n 'transition duration-150 ease-out motion-reduce:transition-none',\n 'data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0',\n className,\n )}\n >\n <Autocomplete.Root\n items={groups}\n filter={filter}\n itemToStringValue={(item: SiteSearchItem) => item.title}\n autoHighlight\n // Inline mode: the list renders statically inside the dialog panel\n // (no Autocomplete portal/positioner), with `open` pinned per the\n // Base UI docs. Opening/closing belongs to the Dialog; the whole\n // Autocomplete unmounts with it, resetting query and highlight.\n inline\n open\n onOpenChange={(nextOpen, eventDetails) => {\n // The pinned-open inline Autocomplete still *requests* closes;\n // forward the ones that should dismiss the palette. Other\n // reasons (input-clear, focus-out) must not close the dialog —\n // clearing the query or tabbing within the trap isn't dismissal.\n if (\n !nextOpen &&\n (eventDetails.reason === 'escape-key' || eventDetails.reason === 'item-press')\n ) {\n requestOpenChange(false)\n }\n }}\n >\n <div\n data-slot='site-search-input-row'\n className='flex items-center gap-3 border-b border-foreground/10 px-4'\n >\n <IconSearch aria-hidden='true' className='size-5 shrink-0 text-muted-foreground' />\n <Autocomplete.Input\n data-slot='site-search-input'\n aria-label={label}\n placeholder={placeholder}\n className='h-12 w-full bg-transparent text-base text-foreground outline-hidden placeholder:text-muted-foreground'\n ref={inputRef}\n />\n </div>\n\n {/* Base UI renders Empty's children only while the list is empty;\n the padding lives on the inner div so the (always-mounted, for\n polite announcements) outer element paints nothing otherwise. */}\n <Autocomplete.Empty data-slot='site-search-empty'>\n <div className='px-4 py-6 text-center text-sm text-muted-foreground'>\n {emptyMessage}\n </div>\n </Autocomplete.Empty>\n\n <Autocomplete.List\n data-slot='site-search-list'\n className='max-h-[min(--spacing(96),60vh)] overflow-y-auto overscroll-contain p-2 empty:hidden'\n >\n {(group: SiteSearchGroup) => (\n <Autocomplete.Group\n key={group.title}\n items={group.items}\n data-slot='site-search-group'\n >\n <Autocomplete.GroupLabel\n data-slot='site-search-group-label'\n className='px-3 pt-3 pb-1 text-xs font-semibold text-muted-foreground'\n >\n {group.title}\n </Autocomplete.GroupLabel>\n <Autocomplete.Collection>\n {(item: SiteSearchItem) => (\n <Autocomplete.Item\n key={item.href}\n value={item}\n data-slot='site-search-item'\n onClick={() => handleSelect(item)}\n // Highlight treatment mirrors menubar.tsx: keyboard and\n // hover unify as data-highlighted, painted as 10% ink.\n className='flex min-h-11 cursor-default items-center gap-2 rounded-sm px-3 py-2 text-sm text-foreground outline-hidden select-none data-highlighted:bg-primary-800/10 data-highlighted:text-accent-foreground dark:data-highlighted:bg-primary-200/10'\n >\n {item.title}\n </Autocomplete.Item>\n )}\n </Autocomplete.Collection>\n </Autocomplete.Group>\n )}\n </Autocomplete.List>\n </Autocomplete.Root>\n\n {children != null ? (\n <div\n data-slot='site-search-footer'\n className='border-t border-foreground/10 px-4 py-2 text-xs text-muted-foreground'\n >\n {children}\n </div>\n ) : null}\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n )\n}\n\nexport { SiteSearch }\nexport type { SiteSearchGroup, SiteSearchItem, SiteSearchProps }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/site-search.tsx"],"names":[],"mappings":";;;;;;;;AA4HA,SAAS,UAAA,CAAW;AAAA,EAClB,MAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA,EAAM,QAAA;AAAA,EACN,YAAA;AAAA,EACA,WAAA,GAAc,KAAA;AAAA,EACd,QAAA,GAAW,IAAA;AAAA,EACX,KAAA,GAAQ,aAAA;AAAA,EACR,WAAA,GAAc,mCAAA;AAAA,EACd,YAAA,GAAe,mBAAA;AAAA,EACf,OAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAA,EAAoB;AAClB,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,KAAA,CAAM,SAAS,WAAW,CAAA;AAC1E,EAAA,MAAM,eAAe,QAAA,KAAa,MAAA;AAClC,EAAA,MAAM,IAAA,GAAO,eAAe,QAAA,GAAW,gBAAA;AAEvC,EAAA,MAAM,QAAA,GAAW,KAAA,CAAM,MAAA,CAAyB,IAAI,CAAA;AAOpD,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,MAAA,CAAO,IAAI,CAAA;AACjC,EAAA,MAAM,oBAAA,GAAuB,KAAA,CAAM,MAAA,CAAgC,MAAM;AAAA,EAAC,CAAC,CAAA;AAE3E,EAAA,MAAM,iBAAA,GAAoB,CAAC,IAAA,KAAkB;AAC3C,IAAA,IAAI,YAAA,EAAc;AAShB,MAAA,IAAI,SAAS,IAAA,EAAM;AACjB,QAAA;AAAA,MACF;AACA,MAAA,YAAA,GAAe,IAAI,CAAA;AACnB,MAAA;AAAA,IACF;AAIA,IAAA,IAAI,OAAA,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AAA;AAAA,gBAET;AAAA;AAAA,aACH,GACE;AAAA;AAAA;AAAA;AACN,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"site-search.js","sourcesContent":["'use client'\n\nimport { Autocomplete } from '@base-ui/react/autocomplete'\nimport { Dialog } from '@base-ui/react/dialog'\nimport React from 'react'\n\nimport { IconSearch } from '../icons/search.js'\nimport { cn } from '../lib/utils.js'\n\nimport { Button } from '../components/button.js'\n\n/** A single searchable destination. `keywords` extend matching beyond the title. */\ntype SiteSearchItem = {\n title: string\n href: string\n keywords?: string[]\n}\n\n/** A titled section of results, rendered with a muted group heading. */\ntype SiteSearchGroup = {\n title: string\n items: SiteSearchItem[]\n}\n\ntype SiteSearchProps = {\n /** The searchable site map, as titled groups of items. */\n groups: SiteSearchGroup[]\n /**\n * Called with the chosen item on click or Enter, after the palette closes.\n * Navigation is the APP's job — call your router here (e.g. next/navigation's\n * `router.push(item.href)`). The design system ships no framework code, so it\n * never navigates itself; this mirrors the DS-wide framework-free rule\n * (see `Link` / `LinkProvider`).\n */\n onSelect: (item: SiteSearchItem) => void\n /** Whether the palette is open. Use when controlled. */\n open?: boolean\n /** Called whenever the palette asks to open or close. */\n onOpenChange?: (open: boolean) => void\n /** Whether the palette is initially open (uncontrolled). */\n defaultOpen?: boolean\n /**\n * Wire the global Cmd/Ctrl-K toggle on `document`, with cleanup on unmount.\n * Defaults to true. Only one shortcut-enabled SiteSearch should be mounted\n * per page, or each press toggles all of them.\n */\n shortcut?: boolean\n /**\n * Accessible name for the palette, applied as `aria-label` to the dialog\n * panel, the search input and the default trigger. Defaults to\n * `'Search site'`. Mirrors ExpandableSearch's `label` prop — localise it\n * rather than hardcoding English into consumers' pages.\n */\n label?: string\n /** Placeholder for the search input. */\n placeholder?: string\n /** Message shown when no items match the query. */\n emptyMessage?: string\n /**\n * The element that opens the palette. Defaults to a ghost icon `Button`\n * named by `label`. Pass an element to replace it — it is composed via Base\n * UI's `render` prop, so it inherits the trigger behaviour and ARIA — or\n * `null` to render no trigger at all (open via `open` or the shortcut).\n * A custom trigger owns its own accessible name — `label` is applied as\n * `aria-label` to the default icon button only, since overriding a visible\n * label that way fails WCAG 2.2, 2.5.3 Label in Name.\n *\n * Conditional triggers must resolve to `null`, not `false`: write\n * `cond ? <Button/> : null`, since `cond && <Button/>` yields `false`, which\n * Base UI's `render` prop rejects with an invalid-element error. TypeScript\n * catches it (`false` is not assignable here); plain-JS consumers see the\n * error at render.\n */\n trigger?: React.ReactElement | null\n /**\n * Extra content rendered at the foot of the panel, below the results —\n * e.g. shortcut hints or a \"browse all\" link.\n */\n children?: React.ReactNode\n /** Extra classes for the centred panel. */\n className?: string\n}\n\n/**\n * Cmd/Ctrl-K command-palette site search: a centred modal panel with a\n * filter-as-you-type input over a grouped list of destinations.\n *\n * Ported from nswds-app's `MobileSearch`, rebuilt framework-free: the app\n * version composed cmdk's `Command*` widgets with next/navigation's router;\n * this version composes Base UI's Autocomplete (the combobox/listbox pattern)\n * inside Base UI's Dialog, and hands the chosen item to `onSelect` instead of\n * navigating. The Autocomplete renders in `inline` mode — its input and list\n * sit statically inside the dialog panel with no popup of their own — which is\n * Base UI's documented composition for palettes (it avoids any portal /\n * focus-trap interplay between the two primitives; the always-`open` inline\n * root unmounts with the dialog, so the query and highlight reset on close).\n *\n * Accessibility contract (inherited, not hand-rolled):\n * - Dialog provides the modal behaviour: focus trap, scroll lock, Escape and\n * backdrop-press dismissal, and focus restoration to the trigger on close.\n * The panel is named via `aria-label` (WCAG 2.2, 4.1.2).\n * - Autocomplete provides the combobox pattern: the input is announced as a\n * combobox controlling a listbox, arrow keys move `aria-activedescendant`\n * highlight while DOM focus stays in the input, Enter activates the\n * highlighted item, and the empty state is announced politely.\n * - The trigger (default or custom) renders through `Dialog.Trigger`, so it\n * carries `aria-haspopup=\"dialog\"` / `aria-expanded` automatically.\n * - Result rows are at least 44px tall (2.5.8 Target Size, AAA-sized).\n * - Panel and backdrop transitions honour `prefers-reduced-motion` (2.3.3).\n *\n * Departures from the nswds-app source, beyond the rebuild above:\n * - `groups`/`onSelect` replace the app's `NavigationItem[]` + router: the\n * data shape is explicit (`title`/`href`/`keywords`) instead of the app's\n * nav config, and untitled/unlinked entries can't exist by construction\n * (the source filtered them at render time).\n * - Filtering matches `title` AND `keywords`, case-insensitively, via the\n * Autocomplete `filter` prop. Base UI's `useFilter` helper only matches one\n * string per item, so a custom predicate is the documented escape hatch for\n * multi-field matching; groups with no matching items are dropped by the\n * primitive, headings included.\n * - The Cmd/Ctrl-K listener can be disabled (`shortcut={false}`) — required\n * for pages that mount more than one instance. It still toggles, per the\n * source.\n */\nfunction SiteSearch({\n groups,\n onSelect,\n open: openProp,\n onOpenChange,\n defaultOpen = false,\n shortcut = true,\n label = 'Search site',\n placeholder = 'Type to search across the site...',\n emptyMessage = 'No results found.',\n trigger,\n children,\n className,\n}: SiteSearchProps) {\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen)\n const isControlled = openProp !== undefined\n const open = isControlled ? openProp : uncontrolledOpen\n\n const inputRef = React.useRef<HTMLInputElement>(null)\n\n // Latest-value refs so the document-level shortcut listener (bound once per\n // `shortcut` value) never acts on a stale open state or stale callbacks.\n // They are written in a passive effect (not during render, per\n // react-hooks/refs) — safe because they are only read from event listeners,\n // which always fire after the commit that synced them.\n const openRef = React.useRef(open)\n const requestOpenChangeRef = React.useRef<(next: boolean) => void>(() => {})\n\n const requestOpenChange = (next: boolean) => {\n if (isControlled) {\n // Dedupe against the render-authoritative prop only — never write\n // openRef optimistically here. An optimistic write would let a parent\n // that vetoes a request (ignores it, so no re-render runs the resync\n // effect) permanently swallow every later identical request. Accepted\n // trade-off: a same-tick duplicate close (Escape reaching both the\n // Autocomplete and the Dialog) may reach `onOpenChange` twice with the\n // same value — idempotent for a setState parent, and correctness in\n // the veto case beats dedupe cosmetics.\n if (open === next) {\n return\n }\n onOpenChange?.(next)\n return\n }\n // Uncontrolled, the component owns the state, so the optimistic write is\n // safe (the commit below confirms it) and dedupes the double-report case\n // (both primitives announcing the same close) down to one callback.\n if (openRef.current === next) {\n return\n }\n openRef.current = next\n setUncontrolledOpen(next)\n onOpenChange?.(next)\n }\n\n React.useEffect(() => {\n // `open` (not `next` from an event) is authoritative here: in controlled\n // mode this effect is the ref's ONLY writer, so the shortcut listener\n // always toggles from the last value the parent actually rendered.\n openRef.current = open\n requestOpenChangeRef.current = requestOpenChange\n })\n\n React.useEffect(() => {\n if (!shortcut) {\n return undefined\n }\n const handleKeyDown = (event: KeyboardEvent) => {\n if (\n event.key.toLowerCase() === 'k' &&\n (event.metaKey || event.ctrlKey) &&\n !event.altKey &&\n !event.defaultPrevented\n ) {\n event.preventDefault()\n // Toggle, per the nswds-app source: the same chord opens and closes.\n requestOpenChangeRef.current(!openRef.current)\n }\n }\n document.addEventListener('keydown', handleKeyDown)\n return () => document.removeEventListener('keydown', handleKeyDown)\n }, [shortcut])\n\n const handleSelect = (item: SiteSearchItem) => {\n // Close first, then hand over — mirrors the source's `runCommand`, so the\n // app's navigation starts from a closed palette.\n requestOpenChange(false)\n onSelect(item)\n }\n\n const filter = React.useCallback((item: SiteSearchItem, query: string) => {\n const q = query.trim().toLowerCase()\n if (q === '') {\n return true\n }\n if (item.title.toLowerCase().includes(q)) {\n return true\n }\n return (item.keywords ?? []).some((keyword) => keyword.toLowerCase().includes(q))\n }, [])\n\n const defaultTrigger = (\n <Button\n variant='ghost'\n color='grey'\n size='icon'\n aria-label={label}\n leadingVisual={IconSearch}\n />\n )\n\n return (\n <Dialog.Root open={open} onOpenChange={(next) => requestOpenChange(next)}>\n {trigger === null ? null : (\n <Dialog.Trigger data-slot='site-search-trigger' render={trigger ?? defaultTrigger} />\n )}\n\n <Dialog.Portal>\n <Dialog.Backdrop\n data-slot='site-search-overlay'\n className='fixed inset-0 z-50 bg-black/80 duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs motion-safe:transition-opacity'\n />\n <Dialog.Popup\n data-slot='site-search-panel'\n aria-label={label}\n // The default focus target on touch is the panel itself (to keep the\n // virtual keyboard closed) — wrong for a search palette, whose whole\n // purpose is typing. Always focus the input.\n initialFocus={inputRef}\n className={cn(\n // Centred panel on the house popup surface (popover.tsx / sheet.tsx).\n 'fixed top-[max(--spacing(4),15vh)] left-1/2 z-50 w-[calc(100vw-2rem)] max-w-2xl -translate-x-1/2',\n 'rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden',\n 'duration-150 ease-out motion-safe:transition',\n 'data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0',\n className,\n )}\n >\n <Autocomplete.Root\n items={groups}\n filter={filter}\n itemToStringValue={(item: SiteSearchItem) => item.title}\n autoHighlight\n // Inline mode: the list renders statically inside the dialog panel\n // (no Autocomplete portal/positioner), with `open` pinned per the\n // Base UI docs. Opening/closing belongs to the Dialog; the whole\n // Autocomplete unmounts with it, resetting query and highlight.\n inline\n open\n onOpenChange={(nextOpen, eventDetails) => {\n // The pinned-open inline Autocomplete still *requests* closes;\n // forward the ones that should dismiss the palette. Other\n // reasons (input-clear, focus-out) must not close the dialog —\n // clearing the query or tabbing within the trap isn't dismissal.\n if (\n !nextOpen &&\n (eventDetails.reason === 'escape-key' || eventDetails.reason === 'item-press')\n ) {\n requestOpenChange(false)\n }\n }}\n >\n <div\n data-slot='site-search-input-row'\n className='flex items-center gap-3 border-b border-foreground/10 px-4'\n >\n <IconSearch aria-hidden='true' className='size-5 shrink-0 text-muted-foreground' />\n <Autocomplete.Input\n data-slot='site-search-input'\n aria-label={label}\n placeholder={placeholder}\n className='h-12 w-full bg-transparent text-base text-foreground outline-hidden placeholder:text-muted-foreground'\n ref={inputRef}\n />\n </div>\n\n {/* Base UI renders Empty's children only while the list is empty;\n the padding lives on the inner div so the (always-mounted, for\n polite announcements) outer element paints nothing otherwise. */}\n <Autocomplete.Empty data-slot='site-search-empty'>\n <div className='px-4 py-6 text-center text-sm text-muted-foreground'>\n {emptyMessage}\n </div>\n </Autocomplete.Empty>\n\n <Autocomplete.List\n data-slot='site-search-list'\n className='max-h-[min(--spacing(96),60vh)] overflow-y-auto overscroll-contain p-2 empty:hidden'\n >\n {(group: SiteSearchGroup) => (\n <Autocomplete.Group\n key={group.title}\n items={group.items}\n data-slot='site-search-group'\n >\n <Autocomplete.GroupLabel\n data-slot='site-search-group-label'\n className='px-3 pt-3 pb-1 text-xs font-semibold text-muted-foreground'\n >\n {group.title}\n </Autocomplete.GroupLabel>\n <Autocomplete.Collection>\n {(item: SiteSearchItem) => (\n <Autocomplete.Item\n key={item.href}\n value={item}\n data-slot='site-search-item'\n onClick={() => handleSelect(item)}\n // Highlight treatment mirrors menubar.tsx: keyboard and\n // hover unify as data-highlighted, painted as 10% ink.\n className='flex min-h-11 cursor-default items-center gap-2 rounded-sm px-3 py-2 text-sm text-foreground outline-hidden select-none data-highlighted:bg-primary-800/10 data-highlighted:text-accent-foreground dark:data-highlighted:bg-primary-200/10'\n >\n {item.title}\n </Autocomplete.Item>\n )}\n </Autocomplete.Collection>\n </Autocomplete.Group>\n )}\n </Autocomplete.List>\n </Autocomplete.Root>\n\n {children != null ? (\n <div\n data-slot='site-search-footer'\n className='border-t border-foreground/10 px-4 py-2 text-xs text-muted-foreground'\n >\n {children}\n </div>\n ) : null}\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n )\n}\n\nexport { SiteSearch }\nexport type { SiteSearchGroup, SiteSearchItem, SiteSearchProps }\n"]}
|
|
@@ -15,7 +15,7 @@ const skipLinkVariants = cva(
|
|
|
15
15
|
// pattern) — still in the tab order, so it is the first thing keyboard
|
|
16
16
|
// and screen-reader users reach.
|
|
17
17
|
"absolute inset-x-0 top-0 w-full -translate-y-[101%]",
|
|
18
|
-
"
|
|
18
|
+
"motion-safe:transition-transform",
|
|
19
19
|
"focus:translate-y-0",
|
|
20
20
|
// min-h-11 keeps the revealed bar at ≥44px — 2.5.5 Target Size (AAA).
|
|
21
21
|
"group flex min-h-11 items-center px-4 py-2 text-xs font-medium no-underline",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/skip-link.tsx"],"names":[],"mappings":";;;;AAYA,MAAM,cAAA,GAAiB;AAAA,EACrB,IAAA,EAAM,+CAAA;AAAA,EACN,KAAA,EAAO,2BAAA;AAAA,EACP,KAAA,EAAO,wBAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAEA,MAAM,gBAAA,GAAmB,GAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,IAIE,qDAAA;AAAA,IACA,
|
|
1
|
+
{"version":3,"sources":["../../src/components/skip-link.tsx"],"names":[],"mappings":";;;;AAYA,MAAM,cAAA,GAAiB;AAAA,EACrB,IAAA,EAAM,+CAAA;AAAA,EACN,KAAA,EAAO,2BAAA;AAAA,EACP,KAAA,EAAO,wBAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAEA,MAAM,gBAAA,GAAmB,GAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,IAIE,qDAAA;AAAA,IACA,kCAAA;AAAA,IACA,qBAAA;AAAA;AAAA,IAEA,6EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,KAAA,EAAO;AAAA,KACT;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,KAAA,EAAO;AAAA;AACT;AAEJ;AAQA,SAAS,gBAAgB,KAAA,EAA4C;AACnE,EAAA,MAAM,IAAA,GAAO,MAAM,aAAA,CAAc,IAAA;AACjC,EAAA,IAAI,CAAC,IAAA,IAAQ,IAAA,KAAS,GAAA,EAAK;AACzB,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,EAAA,GAAK,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AACrB,EAAA,IAAI;AACF,IAAA,EAAA,GAAK,mBAAmB,EAAE,CAAA;AAAA,EAC5B,CAAA,CA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AAA;AAAA;AAAA,EAIA,2BACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAc,IAAA,EAAK,MAAA,EAAO,QAAA,EAAA,oBAAA,EAEpC,CAAA;AAAA,oBACA,GAAA,CAAC,QAAA,EAAA,EAAS,KAAA,EAAc,IAAA,EAAK,YAAW,QAAA,EAAA,iBAAA,EAExC;AAAA,GAAA,EACF,CAAA;AAAA,EAEF,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAmB;AACjB,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,YAAA,EAAW,YAAA;AAAA,MACX,WAAA,EAAU,YAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,mCAAA,EAAqC,SAAS,CAAA;AAAA,MAC5D,GAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"skip-link.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n// Same curated WCAG 2.2 AAA (7:1) pairs as the Masthead — the two components\n// are designed to be themed together, mirroring how the legacy\n// `masthead-theme` option drove both `.nsw-masthead--light` and\n// `.nsw-skip--light`. Kept as a local map (not imported from masthead.tsx) so\n// each file stays standalone for registry distribution.\nconst skipLinkColors = {\n dark: 'bg-primary-800 text-white dark:bg-primary-950',\n light: 'bg-grey-100 text-grey-900',\n white: 'bg-white text-grey-900',\n grey: 'bg-grey-800 text-white',\n}\n\nconst skipLinkVariants = cva(\n [\n // Parked above the viewport until focused (legacy translateY(-101%)\n // pattern) — still in the tab order, so it is the first thing keyboard\n // and screen-reader users reach.\n 'absolute inset-x-0 top-0 w-full -translate-y-[101%]',\n 'motion-safe:transition-transform',\n 'focus:translate-y-0',\n // min-h-11 keeps the revealed bar at ≥44px — 2.5.5 Target Size (AAA).\n 'group flex min-h-11 items-center px-4 py-2 text-xs font-medium no-underline',\n // The visible focus indicator is the ring around the label span\n // (2.4.13 Focus Appearance): outline-current guarantees it contrasts with\n // the bar on every colour variant. outline-hidden (not outline-none) on\n // the anchor keeps a forced-colors fallback outline.\n 'focus:outline-hidden',\n ],\n {\n variants: {\n color: skipLinkColors,\n },\n defaultVariants: {\n color: 'dark',\n },\n },\n)\n\n/**\n * Move focus to the skip target. Fragment navigation alone only moves the\n * sequential-focus starting point; explicitly focusing the target makes\n * screen readers announce it. Non-focusable targets get a temporary\n * `tabindex=\"-1\"` (removed on blur), matching the legacy skip-to behaviour.\n */\nfunction focusSkipTarget(event: React.MouseEvent<HTMLAnchorElement>) {\n const hash = event.currentTarget.hash\n if (!hash || hash === '#') {\n return\n }\n\n let id = hash.slice(1)\n try {\n id = decodeURIComponent(id)\n } catch {\n // Malformed escape sequence — fall back to the raw fragment.\n }\n\n const target = document.getElementById(id)\n if (!target) {\n return\n }\n\n if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) {\n target.setAttribute('tabindex', '-1')\n target.addEventListener(\n 'blur',\n () => {\n target.removeAttribute('tabindex')\n },\n { once: true },\n )\n }\n\n target.focus()\n}\n\ntype SkipLinkProps = React.ComponentPropsWithoutRef<'a'> &\n VariantProps<typeof skipLinkVariants> & {\n /** Same-page fragment target, e.g. `\"#content\"`. */\n href: string\n ref?: React.Ref<HTMLAnchorElement>\n }\n\n/**\n * A single focus-revealed bypass link (2.4.1 Bypass Blocks). Hidden above the\n * viewport until it receives keyboard focus, then slides in as a full-width\n * bar. Designed to sit inside `SkipLinks`, which provides the positioned\n * `<nav>` landmark; standalone use needs a positioned ancestor.\n *\n * Renders a plain `<a>` (not the themeable `Link`) because skip links are\n * same-page fragment jumps — routing framework link components are\n * unnecessary and can interfere with fragment navigation.\n */\nfunction SkipLink({ className, color, href, onClick, children, ref, ...props }: SkipLinkProps) {\n return (\n <a\n data-slot='skip-link'\n {...props}\n href={href}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n focusSkipTarget(event)\n }\n }}\n className={cn(skipLinkVariants({ color }), className)}\n ref={ref}\n >\n <span className='group-focus:outline group-focus:outline-2 group-focus:outline-offset-2 group-focus:outline-current'>\n {children}\n </span>\n </a>\n )\n}\n\ntype SkipLinksProps = React.ComponentPropsWithoutRef<'nav'> &\n VariantProps<typeof skipLinkVariants> & {\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Fixed landmark that holds the page's skip links, rendered as the first\n * element in the body (before the `Masthead`). Successor to the legacy\n * `.nsw-skip` nav.\n *\n * When the `children` prop is omitted it renders the legacy default pair —\n * \"Skip to navigation\" (`#nav`) and \"Skip to content\" (`#content`) — themed\n * by `color`. Any provided children (including an explicitly empty list from\n * a `.map()` or a false conditional) render exactly as given, per normal\n * React semantics — the defaults are never injected alongside or instead of\n * explicit content, since their `#nav`/`#content` targets may not exist on a\n * page that opted into custom links. Compose your own `SkipLink` children\n * for different targets or extra links:\n *\n * ```tsx\n * <SkipLinks>\n * <SkipLink href=\"#main-navigation\">Skip to navigation</SkipLink>\n * <SkipLink href=\"#main-content\">Skip to content</SkipLink>\n * <SkipLink href=\"#search\">Skip to search</SkipLink>\n * </SkipLinks>\n * ```\n */\nfunction SkipLinks({\n className,\n color,\n // Destructuring default: applies only when the prop is `undefined`\n // (omitted), never for explicit null/false/[] children. `color` is\n // initialised earlier in the pattern, so it is in scope here.\n children = (\n <>\n <SkipLink color={color} href='#nav'>\n Skip to navigation\n </SkipLink>\n <SkipLink color={color} href='#content'>\n Skip to content\n </SkipLink>\n </>\n ),\n ref,\n ...props\n}: SkipLinksProps) {\n return (\n <nav\n aria-label='Skip links'\n data-slot='skip-links'\n {...props}\n className={cn('fixed inset-x-0 top-0 z-50 w-full', className)}\n ref={ref}\n >\n {children}\n </nav>\n )\n}\n\nexport { SkipLink, SkipLinks, skipLinkVariants }\nexport type { SkipLinkProps, SkipLinksProps }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/spinner.tsx"],"names":[],"mappings":";;;AAKA,MAAM,KAAA,GAAQ;AAAA,EACZ,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI;AAAA,GACN;AAAA,EACA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,gCAAA;AAAA,IACT,MAAA,EAAQ,+BAAA;AAAA,IACR,KAAA,EAAO,0BAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKP,OAAA,EAAS;AAAA;AAEb,CAAA;AAmBA,SAAS,OAAA,CAAQ;AAAA,EACf,SAAA;AAAA,EACA,YAAA;AAAA,EACA,IAAA,GAAO,IAAA;AAAA,EACP,KAAA,GAAQ,SAAA;AAAA,EACR,KAAA,GAAQ,SAAA;AAAA,EACR,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiB;AAKf,EAAA,MAAM,WAAW,KAAA,KAAU,EAAA;AAC3B,EAAA,uBACE,IAAA,CAAC,UAAK,GAAA,EAAU,IAAA,EAAM,WAAW,QAAA,GAAW,MAAA,EAAW,SAAA,EAAuB,GAAG,KAAA,EAC/E,QAAA,EAAA;AAAA,oBAAA,IAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,IAAA,EAAK,MAAA;AAAA,QACL,OAAA,EAAQ,aAAA;AAAA,QACR,aAAA,EAAY,MAAA;AAAA,QACZ,SAAA,EAAW,EAAA;AAAA,UACT,
|
|
1
|
+
{"version":3,"sources":["../../src/components/spinner.tsx"],"names":[],"mappings":";;;AAKA,MAAM,KAAA,GAAQ;AAAA,EACZ,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ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,CAAA,GAAU;AAAA,GAAA,EACzD,CAAA;AAEJ","file":"spinner.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../lib/utils.js'\n\nconst theme = {\n size: {\n xs: 'h-3 w-3',\n sm: 'h-4 w-4',\n md: 'h-6 w-6',\n lg: 'h-8 w-8',\n xl: 'h-10 w-10',\n },\n color: {\n primary: 'fill-primary-800 text-grey-400',\n accent: 'fill-accent-600 text-grey-400',\n white: 'fill-white text-white/30',\n // Inherit the surrounding text colour (e.g. inside a Button, where the\n // text colour varies per variant/colour). The arc uses currentColor at\n // full strength; the track is the same colour dimmed via opacity on the\n // first <path>, so the two-tone effect works from a single hue.\n current: 'fill-current text-current [&>path:first-child]:opacity-25',\n },\n}\n\ntype SpinnerProps = {\n /** Applied to the outer status element, like every other spread prop. */\n className?: string\n /** Applied to the inner svg (sizing/colour live there). */\n svgClassName?: string\n size?: keyof typeof theme.size\n color?: keyof typeof theme.color\n /**\n * Accessible name announced for the `role=\"status\"` element. Defaults to\n * \"Loading\"; pass an empty string to suppress when surrounding content\n * already conveys the busy state (e.g. inside a Button with a label).\n */\n label?: string\n} & React.HTMLAttributes<HTMLSpanElement> & {\n ref?: React.Ref<HTMLSpanElement>\n }\n\nfunction Spinner({\n className,\n svgClassName,\n size = 'md',\n color = 'primary',\n label = 'Loading',\n ref,\n ...props\n}: SpinnerProps) {\n // An empty label suppresses the live region entirely: a `role=\"status\"`\n // element with no text content is an empty, redundant live region (e.g. when\n // the Spinner sits inside a Button whose own `aria-busy` conveys the state).\n // A consumer-supplied `role` in `...props` still wins, as before.\n const labelled = label !== ''\n return (\n <span ref={ref} role={labelled ? 'status' : undefined} className={className} {...props}>\n <svg\n fill='none'\n viewBox='0 0 100 101'\n aria-hidden='true'\n className={cn(\n 'inline motion-safe:animate-spin',\n theme.color[color],\n theme.size[size],\n svgClassName,\n )}\n >\n <path\n d='M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z'\n fill='currentColor'\n />\n <path\n d='M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z'\n fill='currentFill'\n />\n </svg>\n {labelled ? <span className='sr-only'>{label}</span> : null}\n </span>\n )\n}\n\nexport { Spinner }\nexport type { SpinnerProps }\n"]}
|
|
@@ -60,7 +60,7 @@ const stepStatusStyles = {
|
|
|
60
60
|
};
|
|
61
61
|
const markerBase = [
|
|
62
62
|
"relative z-10 flex size-6 items-center justify-center rounded-full",
|
|
63
|
-
"
|
|
63
|
+
"motion-safe:transition-colors",
|
|
64
64
|
"[--step-ink-hover:color-mix(in_oklch,var(--step-ink)_85%,var(--black))]"
|
|
65
65
|
];
|
|
66
66
|
const markerStyles = {
|
|
@@ -78,7 +78,7 @@ const markerStyles = {
|
|
|
78
78
|
// filled for the current step).
|
|
79
79
|
dot: cn(markerBase, "border-2 border-(--step-ink) bg-background")
|
|
80
80
|
};
|
|
81
|
-
const stepTextClassName = "text-sm text-grey-700 transition-colors group-hover:text-grey-800
|
|
81
|
+
const stepTextClassName = "text-sm text-grey-700 motion-safe:transition-colors group-hover:text-grey-800 dark:text-grey-300 dark:group-hover:text-grey-100";
|
|
82
82
|
const currentTextClassName = "text-sm font-semibold text-primary-800 dark:text-primary-200";
|
|
83
83
|
const DEFAULT_STATUS_LABELS = Object.fromEntries(
|
|
84
84
|
Object.entries(stepStatusStyles).flatMap(
|
|
@@ -170,7 +170,7 @@ function StepIndicator({
|
|
|
170
170
|
"span",
|
|
171
171
|
{
|
|
172
172
|
className: cn(
|
|
173
|
-
"size-2 rounded-full
|
|
173
|
+
"size-2 rounded-full motion-safe:transition-colors",
|
|
174
174
|
currentVariant === "dot" ? "bg-(--step-ink)" : "bg-transparent group-hover:bg-(--step-ink)"
|
|
175
175
|
)
|
|
176
176
|
}
|
|
@@ -236,14 +236,14 @@ function StepNav({
|
|
|
236
236
|
ref,
|
|
237
237
|
"data-slot": "step-nav",
|
|
238
238
|
"aria-label": ariaLabel,
|
|
239
|
-
className: cn("text-base lg:text-sm", className),
|
|
239
|
+
className: cn("max-lg:text-base lg:text-sm", className),
|
|
240
240
|
...props,
|
|
241
241
|
children: /* @__PURE__ */ jsx("ol", { role: "list", className: "space-y-9", children: sections.map((section) => /* @__PURE__ */ jsxs("li", { "data-slot": "step-nav-section", children: [
|
|
242
242
|
/* @__PURE__ */ jsx(Heading, { "data-slot": "step-nav-heading", className: "font-medium text-foreground", children: section.title }),
|
|
243
243
|
/* @__PURE__ */ jsx(
|
|
244
244
|
StepIndicator,
|
|
245
245
|
{
|
|
246
|
-
className: "mt-2 lg:mt-4",
|
|
246
|
+
className: "max-lg:mt-2 lg:mt-4",
|
|
247
247
|
steps: section.steps,
|
|
248
248
|
currentHref,
|
|
249
249
|
onNavigate,
|