@nswds/ui 5.0.6 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/main-nav.d.ts +12 -1
- package/dist/components/main-nav.js +24 -3
- package/dist/components/main-nav.js.map +1 -1
- package/dist/components/navigation-menu.d.ts +22 -0
- package/dist/components/navigation-menu.js +1 -1
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/push-menu.d.ts +54 -5
- package/dist/components/push-menu.js +98 -53
- package/dist/components/push-menu.js.map +1 -1
- package/dist/components/side-nav.d.ts +27 -3
- package/dist/components/side-nav.js +7 -12
- package/dist/components/side-nav.js.map +1 -1
- package/dist/components/skip-link.js +7 -1
- package/dist/components/skip-link.js.map +1 -1
- package/dist/components/sonner.d.ts +11 -1
- package/dist/components/sonner.js +15 -10
- package/dist/components/sonner.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
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,C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AA,CAAG,8DAAA,EAAgE,SAAS,CAAA;AAAA,MACvF,GAAA;AAAA,MAEA,8BAAC,IAAA,EAAA,EAAG,IAAA,EAAK,QAAO,WAAA,EAAU,mBAAA,EAAoB,WAAU,qBAAA,EACrD,QAAA,EAAA,QAAA,CAAS,GAAA,CAAI,CAAC,4BACb,GAAA,CAAC,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 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"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/side-nav.tsx"],"names":[],"mappings":";;;;;;;AAkEA,MAAM,kBAAA,GAAqB,GAAA;AAAA,EACzB;AAAA,IACE,2IAAA;AAAA,IACA,mCAAA;AAAA,IACA,+BAAA;AAAA,IACA,mEAAA;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,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A,YAAA,EACH,oBAGF,GAAA,CAAC,IAAA,EAAA,EAAG,IAAA,EAAK,MAAA,EAAO,WAAA,EAAU,mBAAA,EAAoB,SAAA,EAAU,qBAAA,EACrD,mBAAS,GAAA,CAAI,CAAC,OAAA,qBACb,GAAA,CAAC,IAAA,EAAA,EAAuC,WAAA,EAAU,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,GAEJ;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 source's hover font-weight change (`hover:font-semibold`) is NOT ported.\n * DESIGN.md's Derived State Rule has hover, active and focus deriving from one\n * ink via `color-mix`, and a weight jump is not a derivation: it changes glyph\n * advance widths, so a label sitting near its wrap point can reflow — and grow\n * the row — under the pointer. The remaining hover treatment (rail colour,\n * 10% ink tint, ink shift) already distinguishes the state without moving\n * anything. The persistent `current` row keeps `font-bold`: that is a resting\n * state, so it never reflows on interaction.\n *\n * Rows are floored at 44px on coarse pointers. DESIGN.md commits the system to\n * \"44px+ touch floors\", and the sibling PushMenu enforces it with `min-h-11` —\n * but the rail's own metrics (`py-1` over a 24px line box from `sm:` up) come\n * to 32px, so a tablet reader was tapping targets a third under the stated\n * floor. This clears WCAG 2.2 AA 2.5.8 either way (24px); the floor is the\n * design system's own promise, held here the same way `Button` holds it, on\n * pointer type rather than breakpoint so a desktop rail stays dense.\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 'flex w-full cursor-pointer items-center 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 '[@media(pointer:coarse)]:min-h-11',\n 'motion-safe:transition-colors',\n 'hover:border-grey-950 hover:bg-primary-800/10 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 data-slot='side-nav-text' className={cn(sideNavRowVariants(), 'cursor-default')}>\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 }))}\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 /**\n * Shown when `sections` is empty. Defaults to \"No navigation items\n * available.\"; pass `null` to render nothing.\n *\n * An empty tree is a legitimate runtime state (unpublished content,\n * permission-filtered menus, a failed fetch), not a data mistake — without a\n * message the rail renders an empty `<ul>` and the reader is left with a\n * blank column and no explanation.\n */\n emptyMessage?: React.ReactNode\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 emptyMessage = 'No navigation items available.',\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 {sections.length === 0 ? (\n emptyMessage != null && (\n <p data-slot='side-nav-empty' className='text-muted-foreground'>\n {emptyMessage}\n </p>\n )\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 )}\n </nav>\n )\n}\n\nexport { SideNav, sideNavRowVariants }\nexport type { SideNavItem, SideNavProps }\nexport type SideNavRowVariantProps = VariantProps<typeof sideNavRowVariants>\n"]}
|
|
@@ -18,7 +18,13 @@ const skipLinkVariants = cva(
|
|
|
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
|
+
//
|
|
22
|
+
// text-base, not the legacy text-xs: this is the first thing a keyboard or
|
|
23
|
+
// screen-magnifier user meets on the page, and 12px is below the smallest
|
|
24
|
+
// step DESIGN.md names for running copy. font-medium keeps it in the
|
|
25
|
+
// system's label voice. The bar is min-h-11, and 16px text on py-2 comes
|
|
26
|
+
// to 40px, so the floor still governs the height — nothing moves.
|
|
27
|
+
"group flex min-h-11 items-center px-4 py-2 text-base font-medium no-underline",
|
|
22
28
|
// The visible focus indicator is the ring around the label span
|
|
23
29
|
// (2.4.13 Focus Appearance): outline-current guarantees it contrasts with
|
|
24
30
|
// the bar on every colour variant. outline-hidden (not outline-none) on
|
|
@@ -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,kCAAA;AAAA,IACA,qBAAA;AAAA;AAAA,
|
|
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;AAA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AA,IAAA;AAAA,MACC,WAAA,EAAU,WAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,IAAA;AAAA,MACA,OAAA,EAAS,CAAC,KAAA,KAAU;AAClB,QAAA,OAAA,GAAU,KAAK,CAAA;AACf,QAAA,IAAI,CAAC,MAAM,gBAAA,EAAkB;AAC3B,UAAA,eAAA,CAAgB,KAAK,CAAA;AAAA,QACvB;AAAA,MACF,CAAA;AAAA,MACA,WAAW,EAAA,CAAG,gBAAA,CAAiB,EAAE,KAAA,EAAO,GAAG,SAAS,CAAA;AAAA,MACpD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,oGAAA,EACb,QAAA,EACH;AAAA;AAAA,GACF;AAEJ;AA6BA,SAAS,SAAA,CAAU;AAAA,EACjB,SAAA;AAAA,EACA,KAAA;AAAA;AAAA;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 //\n // text-base, not the legacy text-xs: this is the first thing a keyboard or\n // screen-magnifier user meets on the page, and 12px is below the smallest\n // step DESIGN.md names for running copy. font-medium keeps it in the\n // system's label voice. The bar is min-h-11, and 16px text on py-2 comes\n // to 40px, so the floor still governs the height — nothing moves.\n 'group flex min-h-11 items-center px-4 py-2 text-base 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,6 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ToasterProps } from 'sonner';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Toast host. Mount once, near the root.
|
|
6
|
+
*
|
|
7
|
+
* Every prop this component sets a default for is MERGED with the consumer's
|
|
8
|
+
* value rather than replaced. Spreading `{...props}` last — the shadcn default
|
|
9
|
+
* this was scaffolded from — meant a consumer passing `style` for something
|
|
10
|
+
* unrelated (a z-index, an offset) silently discarded the whole token bridge
|
|
11
|
+
* above, and passing one `icons` entry discarded the other four. Object spread
|
|
12
|
+
* replaces keys wholesale; it does not deep-merge.
|
|
13
|
+
*/
|
|
14
|
+
declare const Toaster: ({ className, style, icons, toastOptions, ...props }: ToasterProps) => React.JSX.Element;
|
|
5
15
|
|
|
6
16
|
export { Toaster };
|
|
@@ -7,30 +7,35 @@ import { IconCheckCircle } from '../icons/check-circle.js';
|
|
|
7
7
|
import { IconError } from '../icons/error.js';
|
|
8
8
|
import { IconInfo } from '../icons/info.js';
|
|
9
9
|
import { IconWarning } from '../icons/warning.js';
|
|
10
|
+
import { cn } from '../lib/utils.js';
|
|
10
11
|
|
|
11
|
-
const
|
|
12
|
+
const tokenBridge = {
|
|
13
|
+
"--normal-bg": "var(--popover)",
|
|
14
|
+
"--normal-text": "var(--popover-foreground)",
|
|
15
|
+
"--normal-border": "var(--border)",
|
|
16
|
+
"--border-radius": "var(--radius)"
|
|
17
|
+
};
|
|
18
|
+
const Toaster = ({ className, style, icons, toastOptions, ...props }) => {
|
|
12
19
|
const { theme = "system" } = useTheme();
|
|
13
20
|
return /* @__PURE__ */ jsx(
|
|
14
21
|
Toaster$1,
|
|
15
22
|
{
|
|
16
23
|
theme,
|
|
17
|
-
className: "toaster group",
|
|
24
|
+
className: cn("toaster group", className),
|
|
18
25
|
icons: {
|
|
19
26
|
success: /* @__PURE__ */ jsx(IconCheckCircle, { className: "size-4" }),
|
|
20
27
|
info: /* @__PURE__ */ jsx(IconInfo, { className: "size-4" }),
|
|
21
28
|
warning: /* @__PURE__ */ jsx(IconWarning, { className: "size-4" }),
|
|
22
29
|
error: /* @__PURE__ */ jsx(IconError, { className: "size-4" }),
|
|
23
|
-
loading: /* @__PURE__ */ jsx(Spinner, { size: "sm", color: "current", label: "" })
|
|
24
|
-
|
|
25
|
-
style: {
|
|
26
|
-
"--normal-bg": "var(--popover)",
|
|
27
|
-
"--normal-text": "var(--popover-foreground)",
|
|
28
|
-
"--normal-border": "var(--border)",
|
|
29
|
-
"--border-radius": "var(--radius)"
|
|
30
|
+
loading: /* @__PURE__ */ jsx(Spinner, { size: "sm", color: "current", label: "" }),
|
|
31
|
+
...icons
|
|
30
32
|
},
|
|
33
|
+
style: { ...tokenBridge, ...style },
|
|
31
34
|
toastOptions: {
|
|
35
|
+
...toastOptions,
|
|
32
36
|
classNames: {
|
|
33
|
-
toast: "cn-toast"
|
|
37
|
+
toast: "cn-toast",
|
|
38
|
+
...toastOptions?.classNames
|
|
34
39
|
}
|
|
35
40
|
},
|
|
36
41
|
...props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/sonner.tsx"],"names":["Sonner"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/sonner.tsx"],"names":["Sonner"],"mappings":";;;;;;;;;;AA0BA,MAAM,WAAA,GAAc;AAAA,EAClB,aAAA,EAAe,gBAAA;AAAA,EACf,eAAA,EAAiB,2BAAA;AAAA,EACjB,iBAAA,EAAmB,eAAA;AAAA,EACnB,iBAAA,EAAmB;AACrB,CAAA;AAYA,MAAM,OAAA,GAAU,CAAC,EAAE,SAAA,EAAW,OAAO,KAAA,EAAO,YAAA,EAAc,GAAG,KAAA,EAAM,KAAoB;AACrF,EAAA,MAAM,EAAE,KAAA,GAAQ,QAAA,EAAS,GAAI,QAAA,EAAS;AAEtC,EAAA,uBACE,GAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MAIA,SAAA,EAAW,EAAA,CAAG,eAAA,EAAiB,SAAS,CAAA;AAAA,MACxC,KAAA,EAAO;AAAA,QACL,OAAA,kBAAS,GAAA,CAAC,eAAA,EAAA,EAAgB,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QAC7C,IAAA,kBAAM,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACnC,OAAA,kBAAS,GAAA,CAAC,WAAA,EAAA,EAAY,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACzC,KAAA,kBAAO,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACrC,OAAA,sBAAU,OAAA,EAAA,EAAQ,IAAA,EAAK,MAAK,KAAA,EAAM,SAAA,EAAU,OAAM,EAAA,EAAG,CAAA;AAAA,QACrD,GAAG;AAAA,OACL;AAAA,MACA,KAAA,EAAO,EAAE,GAAG,WAAA,EAAa,GAAG,KAAA,EAAM;AAAA,MAGlC,YAAA,EAAc;AAAA,QACZ,GAAG,YAAA;AAAA,QACH,UAAA,EAAY;AAAA,UACV,KAAA,EAAO,UAAA;AAAA,UACP,GAAG,YAAA,EAAc;AAAA;AACnB,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"sonner.js","sourcesContent":["'use client'\n\nimport { useTheme } from 'next-themes'\nimport * as React from 'react'\nimport { Toaster as Sonner, type ToasterProps } from 'sonner'\n\nimport { Spinner } from '../components/spinner.js'\nimport { IconCheckCircle } from '../icons/check-circle.js'\nimport { IconError } from '../icons/error.js'\nimport { IconInfo } from '../icons/info.js'\nimport { IconWarning } from '../icons/warning.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * Binds sonner's own theming variables to the NSW semantic tokens.\n *\n * All four names below are sonner's public CSS API — three `--normal-*` colour\n * variables plus `--border-radius`, which is a separate name rather than part\n * of that family. Sonner's own stylesheet reads each of them.\n *\n * They are set ONLY here: none of the four is defined in the compiled\n * `dist/styles.css`, so this object is the single point at which the design\n * system's tokens reach a toast. Losing it silently drops every toast back to\n * sonner's built-in palette, which is why `style` is merged below rather than\n * overwritten.\n */\nconst tokenBridge = {\n '--normal-bg': 'var(--popover)',\n '--normal-text': 'var(--popover-foreground)',\n '--normal-border': 'var(--border)',\n '--border-radius': 'var(--radius)',\n} as React.CSSProperties\n\n/**\n * Toast host. Mount once, near the root.\n *\n * Every prop this component sets a default for is MERGED with the consumer's\n * value rather than replaced. Spreading `{...props}` last — the shadcn default\n * this was scaffolded from — meant a consumer passing `style` for something\n * unrelated (a z-index, an offset) silently discarded the whole token bridge\n * above, and passing one `icons` entry discarded the other four. Object spread\n * replaces keys wholesale; it does not deep-merge.\n */\nconst Toaster = ({ className, style, icons, toastOptions, ...props }: ToasterProps) => {\n const { theme = 'system' } = useTheme()\n\n return (\n <Sonner\n theme={theme as ToasterProps['theme']}\n // `toaster` and `group` are shadcn-compatible styling hooks. Nothing in\n // this package targets them, but consumers migrating from shadcn may, so\n // they are kept and merged rather than dropped.\n className={cn('toaster group', className)}\n icons={{\n success: <IconCheckCircle className='size-4' />,\n info: <IconInfo className='size-4' />,\n warning: <IconWarning className='size-4' />,\n error: <IconError className='size-4' />,\n loading: <Spinner size='sm' color='current' label='' />,\n ...icons,\n }}\n style={{ ...tokenBridge, ...style }}\n // Two levels of merge, not one: a consumer's `toastOptions` must not drop\n // our `classNames`, and their `classNames` must not drop `toast`.\n toastOptions={{\n ...toastOptions,\n classNames: {\n toast: 'cn-toast',\n ...toastOptions?.classNames,\n },\n }}\n {...props}\n />\n )\n}\n\nexport { Toaster }\n"]}
|