@nswds/ui 5.7.1 → 6.0.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.
@@ -6,7 +6,7 @@ import { Link } from './link.js';
6
6
 
7
7
  declare const badgeVariants: (props?: ({
8
8
  variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
9
- color?: "primary/grey" | "light" | "primary/white" | "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | null | undefined;
9
+ color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "primary/grey" | "light" | "primary/white" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | null | undefined;
11
11
  } & class_variance_authority_types.ClassProp) | undefined) => string;
12
12
  type BadgeProps = VariantProps<typeof badgeVariants> & React__default.ComponentPropsWithoutRef<'span'> & {
@@ -5,8 +5,8 @@ import React__default from 'react';
5
5
  import { Link } from './link.js';
6
6
 
7
7
  declare const buttonVariants: (props?: ({
8
- variant?: "solid" | "soft" | "surface" | "outline" | "link" | "ghost" | null | undefined;
9
- color?: "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | "danger" | "success" | "warning" | null | undefined;
8
+ variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
9
+ color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "danger" | "success" | "warning" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | "icon" | null | undefined;
11
11
  iconOnly?: boolean | null | undefined;
12
12
  } & class_variance_authority_types.ClassProp) | undefined) => string;
@@ -30,7 +30,7 @@ declare const headerColors: {
30
30
  };
31
31
  type HeaderColor = keyof typeof headerColors;
32
32
  declare const headerVariants: (props?: ({
33
- color?: "light" | "white" | "grey" | "dark" | null | undefined;
33
+ color?: "white" | "grey" | "light" | "dark" | null | undefined;
34
34
  } & class_variance_authority_types.ClassProp) | undefined) => string;
35
35
  declare const headerContainerVariants: (props?: ({
36
36
  container?: "fluid" | "contained" | null | undefined;
@@ -38,19 +38,16 @@ declare const headerContainerVariants: (props?: ({
38
38
  type HeaderBrandProps = React__default.ComponentPropsWithoutRef<'div'> & {
39
39
  /** Home-page target for the brand link. Defaults to `/`. */
40
40
  href?: React__default.ComponentPropsWithoutRef<typeof Link>['href'];
41
- /** Service or site name shown beside the logo. */
42
- sitename?: React__default.ReactNode;
43
41
  /**
44
- * Heading level for `sitename`. Omit (the default) to render a `<span>`,
45
- * which is usually right: the page's own `<h1>` belongs to its main content,
46
- * and a site name repeated in the header on every page is not the heading
47
- * that describes this page. Supply a level only when a service deliberately
48
- * places the site name in the document outline.
49
- *
50
- * `1` is excluded for the reason above; `6` is the deepest heading HTML
51
- * defines.
42
+ * Service or site name shown beside the logo. Renders as a `<span>`, never a
43
+ * heading: the brand sits in the `banner` landmark ahead of `<main>`, so any
44
+ * heading here would land in the outline *before* the page's own `<h1>` —
45
+ * the first heading a screen-reader user meets would be the site name
46
+ * repeated on every page, and the outline would open at a lower level and
47
+ * then jump up to 1. The heading that describes the page belongs to its main
48
+ * content.
52
49
  */
53
- headingLevel?: 2 | 3 | 4 | 5 | 6;
50
+ sitename?: React__default.ReactNode;
54
51
  /**
55
52
  * Version string shown in a Badge beside the brand. Sits outside the link,
56
53
  * so it never becomes part of the home link's accessible name.
@@ -108,7 +105,7 @@ type HeaderBrandProps = React__default.ComponentPropsWithoutRef<'div'> & {
108
105
  * The link renders through `Link`, so it picks up the framework link component
109
106
  * from `LinkProvider` (next/link et al) rather than hardcoding one.
110
107
  */
111
- declare function HeaderBrand({ className, href, sitename, headingLevel, version, versionLabel, badgeProps, logo, label, children, ref, ...props }: HeaderBrandProps): React__default.JSX.Element;
108
+ declare function HeaderBrand({ className, href, sitename, version, versionLabel, badgeProps, logo, label, children, ref, ...props }: HeaderBrandProps): React__default.JSX.Element;
112
109
  type HeaderActionsProps = React__default.ComponentPropsWithoutRef<'div'> & {
113
110
  ref?: React__default.Ref<HTMLDivElement>;
114
111
  };
@@ -81,7 +81,6 @@ function HeaderBrand({
81
81
  className,
82
82
  href = "/",
83
83
  sitename,
84
- headingLevel,
85
84
  version,
86
85
  versionLabel = "Version",
87
86
  badgeProps,
@@ -93,7 +92,6 @@ function HeaderBrand({
93
92
  }) {
94
93
  const color = React.useContext(HeaderColorContext);
95
94
  const onDarkSurface = DARK_SURFACE_COLORS.has(color);
96
- const Sitename = headingLevel ? `h${headingLevel}` : "span";
97
95
  warnIfBrandUnlabelled({ logo, sitename, label });
98
96
  const logoNode = logo === true ? (
99
97
  // Two lockups, one shown per breakpoint. Below sm the phone has no room
@@ -158,7 +156,7 @@ function HeaderBrand({
158
156
  // ink; dark mode does the same, matching the `dark:text-white` the
159
157
  // light/white variants already set on the surface.
160
158
  /* @__PURE__ */ jsx(
161
- Sitename,
159
+ "span",
162
160
  {
163
161
  className: cn(
164
162
  "font-bold text-balance max-sm:text-lg sm:max-lg:text-xl lg:text-2xl",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/header.tsx"],"names":[],"mappings":";;;;;;;;AA4BA,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,IAAA,EAAM,iFAAA;AAAA,EACN,KAAA,EACE,kIAAA;AAAA,EACF,KAAA,EACE,+HAAA;AAAA,EACF,IAAA,EAAM;AACR;AAMA,MAAM,oBAAA,GAAoC,OAAA;AAE1C,MAAM,cAAA,GAAiB,GAAA;AAAA,EACrB;AAAA,IACE,QAAA;AAAA;AAAA;AAAA;AAAA,IAIA,yEAAA;AAAA,IACA;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;AAEA,MAAM,uBAAA,GAA0B,GAAA;AAAA,EAC9B;AAAA,IACE,+GAAA;AAAA;AAAA;AAAA;AAAA,IAIA,yBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA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type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nimport { Badge, type BadgeProps } from '../components/badge.js'\nimport { Link } from '../components/link.js'\nimport { Logo } from '../components/logo.js'\n\n/**\n * Surface colours the header can be themed with, sharing the Masthead's and\n * SkipLink's four-name vocabulary (`dark`, `light`, `white`, `grey`) — the three\n * components stack at the top of the page and a service picks one word for the\n * whole chrome.\n *\n * Every pair is WCAG 2.2 AAA (1.4.6, 7:1), computed from the masterbrand oklch\n * tokens. Light mode: grey-800 on white 15.1:1, grey-800 on grey-100 13.8:1,\n * white on primary-800 14.4:1, white on grey-800 15.1:1. Dark mode deepens each\n * surface onto the same family's dark step and clears AAA more comfortably\n * still (17.2:1–20.2:1).\n *\n * Unlike the Masthead — a brand strip whose light/white/grey surfaces are frozen\n * across themes — the header is the page's own surface, so all four follow the\n * theme. Pair `Header color=\"dark\"` with `Masthead color=\"dark\"` when a service\n * wants the two to match in both modes.\n */\nconst headerColors = {\n // Ink values use the RAW masterbrand tokens (--grey-800) rather than\n // Tailwind's --color-* bridge aliases: Tailwind v4 tree-shakes an\n // unreferenced @theme key, and referencing one from inside an arbitrary\n // property is not a usage signal. Same reasoning as footer.tsx.\n // (--color-white is safe: `text-white` below is a real utility.)\n dark: 'bg-primary-800 text-white [--header-ink:var(--color-white)] dark:bg-primary-950',\n light:\n 'bg-grey-100 text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--header-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--header-ink:var(--color-white)]',\n grey: 'bg-grey-800 text-white [--header-ink:var(--color-white)] dark:bg-grey-950',\n}\n\ntype HeaderColor = keyof typeof headerColors\n\n// Shared by cva's defaultVariants, the data-color attribute and the logo\n// context, so the four can't drift apart.\nconst DEFAULT_HEADER_COLOR: HeaderColor = 'white'\n\nconst headerVariants = cva(\n [\n 'w-full',\n // The hairline rule derives from the surface's own ink, so it follows every\n // colour variant and both themes from one value. Mirrors the color-mix\n // derivation in footer.tsx (--footer-border) and link.tsx (--link-halo).\n '[--header-border:color-mix(in_oklch,var(--header-ink)_15%,transparent)]',\n 'duration-300 motion-safe:transition-shadow',\n ],\n {\n variants: {\n color: headerColors,\n },\n defaultVariants: {\n color: DEFAULT_HEADER_COLOR,\n },\n },\n)\n\nconst headerContainerVariants = cva(\n [\n 'mx-auto flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-3 max-sm:py-3 sm:max-lg:py-4 lg:py-5',\n // Lateral padding funnels through --header-padding-x so an app can retune it\n // once (via the `style` prop or a utility class) without a new variant. Same\n // mechanism, and the same 16px → 24px → 48px rhythm, as Masthead and Footer.\n 'px-(--header-padding-x)',\n '[--header-padding-x:--spacing(4)] sm:[--header-padding-x:--spacing(6)] lg:[--header-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app parity). --header-max-width is still read so a\n // shell app can constrain the inner wrapper without switching variants.\n fluid: 'max-w-[var(--header-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--header-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\n/**\n * Lets `HeaderBrand` adapt its artwork to the surface it is drawn on — the\n * default `Logo` paints its wordmark `nsw-blue-800` and the version `Badge`\n * paints itself `primary-800`, both of which disappear on the `dark`\n * (primary-800) surface. A `logo` node supplied by the consumer overrides the\n * lockup entirely; at that point the choice is theirs.\n */\nconst HeaderColorContext = React.createContext<HeaderColor>(DEFAULT_HEADER_COLOR)\n\n/** Surfaces dark enough to need light-on-dark artwork. */\nconst DARK_SURFACE_COLORS = new Set<HeaderColor>(['dark', 'grey'])\n\ntype HeaderBrandProps = React.ComponentPropsWithoutRef<'div'> & {\n /** Home-page target for the brand link. Defaults to `/`. */\n href?: React.ComponentPropsWithoutRef<typeof Link>['href']\n /** Service or site name shown beside the logo. */\n sitename?: React.ReactNode\n /**\n * Heading level for `sitename`. Omit (the default) to render a `<span>`,\n * which is usually right: the page's own `<h1>` belongs to its main content,\n * and a site name repeated in the header on every page is not the heading\n * that describes this page. Supply a level only when a service deliberately\n * places the site name in the document outline.\n *\n * `1` is excluded for the reason above; `6` is the deepest heading HTML\n * defines.\n */\n headingLevel?: 2 | 3 | 4 | 5 | 6\n /**\n * Version string shown in a Badge beside the brand. Sits outside the link,\n * so it never becomes part of the home link's accessible name.\n */\n version?: React.ReactNode\n /**\n * Visually-hidden prefix announced before `version`, giving the bare number\n * context for screen readers (\"2.1.0\" → \"Version 2.1.0\"). Pass an empty\n * string to suppress.\n */\n versionLabel?: string\n /**\n * Props forwarded to the version `Badge` — `size`, `color`, `variant`,\n * `className` and the rest of its API. Use it when the badge has to meet a\n * house rule the default does not, most often a minimum type size:\n *\n * ```tsx\n * <HeaderBrand version=\"2.1.0\" badgeProps={{ size: 'lg' }} />\n * ```\n *\n * An explicit value always wins — including `color`, whose surface-aware\n * default exists to stop the badge painting itself the same colour as a dark\n * header. Overriding it is the same trade as supplying your own `logo` node:\n * the contrast is then yours to check.\n *\n * `undefined` and `null` do *not* win: they fall back to the defaults, so a\n * conditional like `{ color: cond ? 'accent' : undefined }` keeps the\n * surface-aware colour on the falsy branch rather than dropping the badge to\n * cva's own `primary` default.\n *\n * `children` is excluded — the badge's content is `version` and\n * `versionLabel`.\n */\n badgeProps?: Omit<BadgeProps, 'children'>\n /**\n * `true` (default) renders the NSW Government waratah, `false` omits it, and\n * a node replaces it — pass an agency lockup here.\n */\n logo?: boolean | React.ReactNode\n /**\n * Accessible name for the brand link. Left unset by default: the link's name\n * is then its visible content — \"NSW Government\" (from `Logo`'s\n * visually-hidden text) plus `sitename` — which keeps the visible label\n * inside the accessible name (WCAG 2.2, 2.5.3 Label in Name). Overriding it\n * with something like \"Home page\" would break that, so set it only when the\n * brand renders no text at all.\n */\n label?: string\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: the\n * default `Logo` carries a visually-hidden \"NSW Government\", so a brand with\n * neither it nor a `sitename` renders a link with no text at all, and reaches\n * assistive tech unnamed (WCAG 2.2, 4.1.2 Name, Role, Value). A consumer's own\n * logo node is assumed to carry its own text. No-op in production.\n */\nfunction warnIfBrandUnlabelled({\n logo,\n sitename,\n label,\n}: Pick<HeaderBrandProps, 'logo' | 'sitename' | 'label'>) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!logo && !sitename && !label) {\n console.warn(\n '[nswds/ui] HeaderBrand has no logo and no sitename, so its home link has no accessible name — pass `label`.',\n )\n }\n}\n\n/**\n * Logo, site name and optional version badge, linked to the home page. Sits at\n * the start of the `Header` row.\n *\n * The link renders through `Link`, so it picks up the framework link component\n * from `LinkProvider` (next/link et al) rather than hardcoding one.\n */\nfunction HeaderBrand({\n className,\n href = '/',\n sitename,\n headingLevel,\n version,\n versionLabel = 'Version',\n badgeProps,\n logo = true,\n label,\n children,\n ref,\n ...props\n}: HeaderBrandProps) {\n const color = React.useContext(HeaderColorContext)\n const onDarkSurface = DARK_SURFACE_COLORS.has(color)\n const Sitename = headingLevel ? (`h${headingLevel}` as const) : 'span'\n\n warnIfBrandUnlabelled({ logo, sitename, label })\n\n const logoNode =\n logo === true ? (\n // Two lockups, one shown per breakpoint. Below sm the phone has no room\n // for the full three-row mark, so it takes the compact `wordmark='nsw'`\n // lockup (waratah + \"NSW\", no \"Government\"); sm and up take the full mark.\n //\n // Each is wrapped in a span carrying the show/hide, not the Logo itself,\n // because Logo emits a visually-hidden \"NSW Government\" span beside its\n // (aria-hidden) svg. Hiding only the svg would leave that label in the\n // tree twice, so the home link's accessible name would read \"NSW\n // Government NSW Government …\". Toggling the wrapper drops the hidden\n // variant's label with it, leaving exactly one.\n //\n // The wrappers hide with a single conditional utility each (`sm:hidden` /\n // `max-sm:hidden`) rather than a `hidden`/`sm:block` pair: a bare `hidden`\n // a consumer also uses is re-emitted after ours by their own Tailwind\n // build and a media query carries no extra specificity, so the pair is\n // not cascade-safe (see AGENTS.md §4) — one conditional is.\n <>\n <span className='sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n wordmark='nsw'\n className='block h-14 w-auto'\n />\n </span>\n <span className='max-sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n // 64px from lg, 56px below it — 56px is the floor, so the lockup\n // stays legible. Written as mutually exclusive breakpoint ranges\n // rather than `h-14 lg:h-16`: a bare `h-14` a consumer also uses is\n // re-emitted after ours by their own Tailwind build, and a media\n // query adds no specificity, so it would outrank the lg step and\n // freeze the logo at 56px.\n className='block w-auto max-lg:h-14 lg:h-16'\n />\n </span>\n </>\n ) : (\n // `false` / `null` fall through as the falsy nodes they are; anything\n // else is the consumer's own lockup.\n logo\n )\n\n return (\n <div\n data-slot='header-brand'\n {...props}\n className={cn('flex grow basis-0 items-center max-sm:gap-3 sm:gap-4', className)}\n ref={ref}\n >\n {/* variant='unstyled' — a brand lockup takes no underline or link\n colour. outline-current resolves to the surface's ink on every\n variant, so the focus indicator contrasts with the header\n (WCAG 2.2, 2.4.13 Focus Appearance). The negative margin keeps the\n indicator from nudging the row. */}\n <Link\n variant='unstyled'\n href={href}\n aria-label={label}\n className='-m-1 flex items-center gap-4 rounded-sm p-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current'\n >\n {logoNode}\n {sitename ? (\n // Brand-blue ink on the light surfaces (14.4:1 on white, 13.2:1 on\n // grey-100 — both WCAG 2.2 AAA). The `dark` surface *is* primary-800\n // and `grey` is nearly as deep, so those keep the header's own white\n // ink; dark mode does the same, matching the `dark:text-white` the\n // light/white variants already set on the surface.\n <Sitename\n className={cn(\n 'font-bold text-balance max-sm:text-lg sm:max-lg:text-xl lg:text-2xl',\n !onDarkSurface && 'text-primary-800 dark:text-white',\n )}\n >\n {sitename}\n </Sitename>\n ) : null}\n </Link>\n {version ? (\n // Badge's `primary` ink is primary-800 — the `dark` header's own\n // surface — so dark surfaces take the white badge instead.\n <Badge\n data-slot='header-version'\n {...badgeProps}\n // Derived after the spread rather than before it. Spreading last would\n // let a key that is merely *present* win, so\n // `badgeProps={{ color: cond ? 'accent' : undefined }}` would pass\n // `undefined` through to cva, which falls back to its own\n // `defaultVariants.color` of `primary` — and primary-800 is the dark\n // header's own background, so the badge would vanish into it. `??`\n // keeps explicit values winning while undefined (and null, which\n // cva's VariantProps permits and which would otherwise render an\n // unstyled badge) falls back to the surface-aware default.\n variant={badgeProps?.variant ?? 'soft'}\n color={badgeProps?.color ?? (onDarkSurface ? 'white' : 'primary')}\n >\n {versionLabel ? <span className='sr-only'>{versionLabel} </span> : null}\n {version}\n </Badge>\n ) : null}\n {children}\n </div>\n )\n}\n\ntype HeaderActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Trailing cluster of header controls — search, theme switcher, sign-in, and\n * the like. Deliberately unopinionated about what goes in it: site search and\n * theme switching are app concerns (they need routing and a theme provider),\n * so the design system supplies the slot and its spacing rather than the\n * widgets.\n *\n * Not a `nav` landmark: a row of controls is not a set of navigation links, and\n * an extra landmark on every page buries the ones that matter. Wrap genuine\n * navigation in your own `<nav>` inside `Header`.\n */\nfunction HeaderActions({ className, ref, ...props }: HeaderActionsProps) {\n return (\n <div\n data-slot='header-actions'\n {...props}\n className={cn(\n 'flex basis-0 items-center justify-end max-sm:gap-2 sm:gap-4 md:grow',\n className,\n )}\n ref={ref}\n />\n )\n}\n\ntype HeaderProps = React.ComponentPropsWithoutRef<'header'> &\n VariantProps<typeof headerVariants> &\n VariantProps<typeof headerContainerVariants> & {\n /** Stick to the top of the viewport as the page scrolls. Defaults to `true`. */\n sticky?: boolean\n /** Hairline rule along the bottom edge. Defaults to `true`. */\n border?: boolean\n /** Raise the header with a shadow once the page is scrolled. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Top-of-page `banner` landmark: brand, site name and header controls. Render\n * it once in a shared layout, below `SkipLinks` and `Masthead`.\n *\n * - `color` themes the surface; all four pairs are WCAG 2.2 AAA and follow the\n * theme in dark mode (see `headerColors`). The bottom rule derives from the\n * surface's ink, so it follows automatically.\n * - `container` selects the inner wrapper layout: `fluid` (full-bleed,\n * nswds-app parity) or `contained` (centred 1200px column, legacy\n * `nsw-container` parity). Fine-tune either with the `--header-max-width`\n * and `--header-padding-x` custom properties.\n * - Scroll position is tracked and exposed as `data-scrolled`, which is what\n * the `shadow` treatment keys off. Style your own scrolled state with it.\n *\n * Compose the row from `HeaderBrand` and `HeaderActions`:\n *\n * ```tsx\n * <Header>\n * <HeaderBrand sitename=\"Design System\" version=\"2.1.0\" />\n * <HeaderActions>\n * <ThemeSwitcher />\n * </HeaderActions>\n * </Header>\n * ```\n *\n * The `banner` landmark comes from the native `<header>` element, which only\n * carries it outside `article`, `aside`, `main`, `nav` and `section` — wrapping\n * `div`s are fine. Keep it out of `<main>`.\n *\n * The default `id=\"nsw-header\"` is kept for compatibility with existing shells\n * that target it (override via the `id` prop).\n */\nfunction Header({\n className,\n color,\n container,\n containerClassName,\n sticky = true,\n border = true,\n shadow = true,\n children,\n ref,\n ...props\n}: HeaderProps) {\n const [isScrolled, setIsScrolled] = React.useState(false)\n\n React.useEffect(() => {\n function onScroll() {\n setIsScrolled(window.scrollY > 0)\n }\n // Read once on mount too: a page restored mid-scroll (back/forward, or a\n // deep link to a fragment) never fires a scroll event.\n onScroll()\n window.addEventListener('scroll', onScroll, { passive: true })\n return () => window.removeEventListener('scroll', onScroll)\n }, [])\n\n return (\n <header\n id='nsw-header'\n data-slot='header'\n data-color={color ?? DEFAULT_HEADER_COLOR}\n // Present-or-absent rather than \"true\"/\"false\", so it reads like Base\n // UI's data-disabled and Tailwind's bare `data-scrolled:` variant works.\n data-scrolled={isScrolled || undefined}\n {...props}\n className={cn(\n headerVariants({ color }),\n // z-40 sits below the z-50 SkipLinks: a sticky header at the same\n // level comes later in the DOM and would paint over a focused skip\n // link, hiding the page's bypass mechanism (WCAG 2.2, 2.4.1).\n sticky && 'sticky top-0 z-40',\n // Always drawn, so the scrolled state changes no box heights.\n border && 'border-b border-(--header-border)',\n // Shadows read as elevation on light surfaces only; in dark mode the\n // rule above carries the separation.\n shadow &&\n 'data-scrolled:shadow-md data-scrolled:shadow-black/5 dark:data-scrolled:shadow-none',\n className,\n )}\n ref={ref}\n >\n <HeaderColorContext.Provider value={color ?? DEFAULT_HEADER_COLOR}>\n <div\n data-slot='header-container'\n className={cn(headerContainerVariants({ container }), containerClassName)}\n >\n {children}\n </div>\n </HeaderColorContext.Provider>\n </header>\n )\n}\n\nexport { Header, HeaderActions, HeaderBrand, headerColors, headerContainerVariants, headerVariants }\nexport type { HeaderActionsProps, HeaderBrandProps, HeaderColor, HeaderProps }\n"]}
1
+ {"version":3,"sources":["../../src/components/header.tsx"],"names":[],"mappings":";;;;;;;;AA4BA,MAAM,YAAA,GAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,IAAA,EAAM,iFAAA;AAAA,EACN,KAAA,EACE,kIAAA;AAAA,EACF,KAAA,EACE,+HAAA;AAAA,EACF,IAAA,EAAM;AACR;AAMA,MAAM,oBAAA,GAAoC,OAAA;AAE1C,MAAM,cAAA,GAAiB,GAAA;AAAA,EACrB;AAAA,IACE,QAAA;AAAA;AAAA;AAAA;AAAA,IAIA,yEAAA;AAAA,IACA;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;AAEA,MAAM,uBAAA,GAA0B,GAAA;AAAA,EAC9B;AAAA,IACE,+GAAA;AAAA;AAAA;AAAA;AAAA,IAIA,yBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,E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M;AACpB,IAAA,SAAS,QAAA,GAAW;AAClB,MAAA,aAAA,CAAc,MAAA,CAAO,UAAU,CAAC,CAAA;AAAA,IAClC;AAGA,IAAA,QAAA,EAAS;AACT,IAAA,MAAA,CAAO,iBAAiB,QAAA,EAAU,QAAA,EAAU,EAAE,OAAA,EAAS,MAAM,CAAA;AAC7D,IAAA,OAAO,MAAM,MAAA,CAAO,mBAAA,CAAoB,QAAA,EAAU,QAAQ,CAAA;AAAA,EAC5D,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAG,YAAA;AAAA,MACH,WAAA,EAAU,QAAA;AAAA,MACV,cAAY,KAAA,IAAS,oBAAA;AAAA,MAGrB,iBAAe,UAAA,IAAc,MAAA;AAAA,MAC5B,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,EAAA;AAAA,QACT,cAAA,CAAe,EAAE,KAAA,EAAO,CAAA;AAAA;AAAA;AAAA;AAAA,QAIxB,MAAA,IAAU,mBAAA;AAAA;AAAA,QAEV,MAAA,IAAU,mCAAA;AAAA;AAAA;AAAA,QAGV,MAAA,IACE,qFAAA;AAAA,QACF;AAAA,OACF;AAAA,MACA,GAAA;AAAA,MAEA,8BAAC,kBAAA,CAAmB,QAAA,EAAnB,EAA4B,KAAA,EAAO,SAAS,oBAAA,EAC3C,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,WAAA,EAAU,kBAAA;AAAA,UACV,WAAW,EAAA,CAAG,uBAAA,CAAwB,EAAE,SAAA,EAAW,GAAG,kBAAkB,CAAA;AAAA,UAEvE;AAAA;AAAA,OACH,EACF;AAAA;AAAA,GACF;AAEJ","file":"header.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 { Badge, type BadgeProps } from '../components/badge.js'\nimport { Link } from '../components/link.js'\nimport { Logo } from '../components/logo.js'\n\n/**\n * Surface colours the header can be themed with, sharing the Masthead's and\n * SkipLink's four-name vocabulary (`dark`, `light`, `white`, `grey`) — the three\n * components stack at the top of the page and a service picks one word for the\n * whole chrome.\n *\n * Every pair is WCAG 2.2 AAA (1.4.6, 7:1), computed from the masterbrand oklch\n * tokens. Light mode: grey-800 on white 15.1:1, grey-800 on grey-100 13.8:1,\n * white on primary-800 14.4:1, white on grey-800 15.1:1. Dark mode deepens each\n * surface onto the same family's dark step and clears AAA more comfortably\n * still (17.2:1–20.2:1).\n *\n * Unlike the Masthead — a brand strip whose light/white/grey surfaces are frozen\n * across themes — the header is the page's own surface, so all four follow the\n * theme. Pair `Header color=\"dark\"` with `Masthead color=\"dark\"` when a service\n * wants the two to match in both modes.\n */\nconst headerColors = {\n // Ink values use the RAW masterbrand tokens (--grey-800) rather than\n // Tailwind's --color-* bridge aliases: Tailwind v4 tree-shakes an\n // unreferenced @theme key, and referencing one from inside an arbitrary\n // property is not a usage signal. Same reasoning as footer.tsx.\n // (--color-white is safe: `text-white` below is a real utility.)\n dark: 'bg-primary-800 text-white [--header-ink:var(--color-white)] dark:bg-primary-950',\n light:\n 'bg-grey-100 text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--header-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--header-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--header-ink:var(--color-white)]',\n grey: 'bg-grey-800 text-white [--header-ink:var(--color-white)] dark:bg-grey-950',\n}\n\ntype HeaderColor = keyof typeof headerColors\n\n// Shared by cva's defaultVariants, the data-color attribute and the logo\n// context, so the four can't drift apart.\nconst DEFAULT_HEADER_COLOR: HeaderColor = 'white'\n\nconst headerVariants = cva(\n [\n 'w-full',\n // The hairline rule derives from the surface's own ink, so it follows every\n // colour variant and both themes from one value. Mirrors the color-mix\n // derivation in footer.tsx (--footer-border) and link.tsx (--link-halo).\n '[--header-border:color-mix(in_oklch,var(--header-ink)_15%,transparent)]',\n 'duration-300 motion-safe:transition-shadow',\n ],\n {\n variants: {\n color: headerColors,\n },\n defaultVariants: {\n color: DEFAULT_HEADER_COLOR,\n },\n },\n)\n\nconst headerContainerVariants = cva(\n [\n 'mx-auto flex w-full flex-wrap items-center justify-between gap-x-4 gap-y-3 max-sm:py-3 sm:max-lg:py-4 lg:py-5',\n // Lateral padding funnels through --header-padding-x so an app can retune it\n // once (via the `style` prop or a utility class) without a new variant. Same\n // mechanism, and the same 16px → 24px → 48px rhythm, as Masthead and Footer.\n 'px-(--header-padding-x)',\n '[--header-padding-x:--spacing(4)] sm:[--header-padding-x:--spacing(6)] lg:[--header-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app parity). --header-max-width is still read so a\n // shell app can constrain the inner wrapper without switching variants.\n fluid: 'max-w-[var(--header-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--header-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\n/**\n * Lets `HeaderBrand` adapt its artwork to the surface it is drawn on — the\n * default `Logo` paints its wordmark `nsw-blue-800` and the version `Badge`\n * paints itself `primary-800`, both of which disappear on the `dark`\n * (primary-800) surface. A `logo` node supplied by the consumer overrides the\n * lockup entirely; at that point the choice is theirs.\n */\nconst HeaderColorContext = React.createContext<HeaderColor>(DEFAULT_HEADER_COLOR)\n\n/** Surfaces dark enough to need light-on-dark artwork. */\nconst DARK_SURFACE_COLORS = new Set<HeaderColor>(['dark', 'grey'])\n\ntype HeaderBrandProps = React.ComponentPropsWithoutRef<'div'> & {\n /** Home-page target for the brand link. Defaults to `/`. */\n href?: React.ComponentPropsWithoutRef<typeof Link>['href']\n /**\n * Service or site name shown beside the logo. Renders as a `<span>`, never a\n * heading: the brand sits in the `banner` landmark ahead of `<main>`, so any\n * heading here would land in the outline *before* the page's own `<h1>` —\n * the first heading a screen-reader user meets would be the site name\n * repeated on every page, and the outline would open at a lower level and\n * then jump up to 1. The heading that describes the page belongs to its main\n * content.\n */\n sitename?: React.ReactNode\n /**\n * Version string shown in a Badge beside the brand. Sits outside the link,\n * so it never becomes part of the home link's accessible name.\n */\n version?: React.ReactNode\n /**\n * Visually-hidden prefix announced before `version`, giving the bare number\n * context for screen readers (\"2.1.0\" → \"Version 2.1.0\"). Pass an empty\n * string to suppress.\n */\n versionLabel?: string\n /**\n * Props forwarded to the version `Badge` — `size`, `color`, `variant`,\n * `className` and the rest of its API. Use it when the badge has to meet a\n * house rule the default does not, most often a minimum type size:\n *\n * ```tsx\n * <HeaderBrand version=\"2.1.0\" badgeProps={{ size: 'lg' }} />\n * ```\n *\n * An explicit value always wins — including `color`, whose surface-aware\n * default exists to stop the badge painting itself the same colour as a dark\n * header. Overriding it is the same trade as supplying your own `logo` node:\n * the contrast is then yours to check.\n *\n * `undefined` and `null` do *not* win: they fall back to the defaults, so a\n * conditional like `{ color: cond ? 'accent' : undefined }` keeps the\n * surface-aware colour on the falsy branch rather than dropping the badge to\n * cva's own `primary` default.\n *\n * `children` is excluded — the badge's content is `version` and\n * `versionLabel`.\n */\n badgeProps?: Omit<BadgeProps, 'children'>\n /**\n * `true` (default) renders the NSW Government waratah, `false` omits it, and\n * a node replaces it — pass an agency lockup here.\n */\n logo?: boolean | React.ReactNode\n /**\n * Accessible name for the brand link. Left unset by default: the link's name\n * is then its visible content — \"NSW Government\" (from `Logo`'s\n * visually-hidden text) plus `sitename` — which keeps the visible label\n * inside the accessible name (WCAG 2.2, 2.5.3 Label in Name). Overriding it\n * with something like \"Home page\" would break that, so set it only when the\n * brand renders no text at all.\n */\n label?: string\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: the\n * default `Logo` carries a visually-hidden \"NSW Government\", so a brand with\n * neither it nor a `sitename` renders a link with no text at all, and reaches\n * assistive tech unnamed (WCAG 2.2, 4.1.2 Name, Role, Value). A consumer's own\n * logo node is assumed to carry its own text. No-op in production.\n */\nfunction warnIfBrandUnlabelled({\n logo,\n sitename,\n label,\n}: Pick<HeaderBrandProps, 'logo' | 'sitename' | 'label'>) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!logo && !sitename && !label) {\n console.warn(\n '[nswds/ui] HeaderBrand has no logo and no sitename, so its home link has no accessible name — pass `label`.',\n )\n }\n}\n\n/**\n * Logo, site name and optional version badge, linked to the home page. Sits at\n * the start of the `Header` row.\n *\n * The link renders through `Link`, so it picks up the framework link component\n * from `LinkProvider` (next/link et al) rather than hardcoding one.\n */\nfunction HeaderBrand({\n className,\n href = '/',\n sitename,\n version,\n versionLabel = 'Version',\n badgeProps,\n logo = true,\n label,\n children,\n ref,\n ...props\n}: HeaderBrandProps) {\n const color = React.useContext(HeaderColorContext)\n const onDarkSurface = DARK_SURFACE_COLORS.has(color)\n\n warnIfBrandUnlabelled({ logo, sitename, label })\n\n const logoNode =\n logo === true ? (\n // Two lockups, one shown per breakpoint. Below sm the phone has no room\n // for the full three-row mark, so it takes the compact `wordmark='nsw'`\n // lockup (waratah + \"NSW\", no \"Government\"); sm and up take the full mark.\n //\n // Each is wrapped in a span carrying the show/hide, not the Logo itself,\n // because Logo emits a visually-hidden \"NSW Government\" span beside its\n // (aria-hidden) svg. Hiding only the svg would leave that label in the\n // tree twice, so the home link's accessible name would read \"NSW\n // Government NSW Government …\". Toggling the wrapper drops the hidden\n // variant's label with it, leaving exactly one.\n //\n // The wrappers hide with a single conditional utility each (`sm:hidden` /\n // `max-sm:hidden`) rather than a `hidden`/`sm:block` pair: a bare `hidden`\n // a consumer also uses is re-emitted after ours by their own Tailwind\n // build and a media query carries no extra specificity, so the pair is\n // not cascade-safe (see AGENTS.md §4) — one conditional is.\n <>\n <span className='sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n wordmark='nsw'\n className='block h-14 w-auto'\n />\n </span>\n <span className='max-sm:hidden'>\n <Logo\n logoType={onDarkSurface ? 'reversed' : 'default'}\n // 64px from lg, 56px below it — 56px is the floor, so the lockup\n // stays legible. Written as mutually exclusive breakpoint ranges\n // rather than `h-14 lg:h-16`: a bare `h-14` a consumer also uses is\n // re-emitted after ours by their own Tailwind build, and a media\n // query adds no specificity, so it would outrank the lg step and\n // freeze the logo at 56px.\n className='block w-auto max-lg:h-14 lg:h-16'\n />\n </span>\n </>\n ) : (\n // `false` / `null` fall through as the falsy nodes they are; anything\n // else is the consumer's own lockup.\n logo\n )\n\n return (\n <div\n data-slot='header-brand'\n {...props}\n className={cn('flex grow basis-0 items-center max-sm:gap-3 sm:gap-4', className)}\n ref={ref}\n >\n {/* variant='unstyled' — a brand lockup takes no underline or link\n colour. outline-current resolves to the surface's ink on every\n variant, so the focus indicator contrasts with the header\n (WCAG 2.2, 2.4.13 Focus Appearance). The negative margin keeps the\n indicator from nudging the row. */}\n <Link\n variant='unstyled'\n href={href}\n aria-label={label}\n className='-m-1 flex items-center gap-4 rounded-sm p-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current'\n >\n {logoNode}\n {sitename ? (\n // Brand-blue ink on the light surfaces (14.4:1 on white, 13.2:1 on\n // grey-100 — both WCAG 2.2 AAA). The `dark` surface *is* primary-800\n // and `grey` is nearly as deep, so those keep the header's own white\n // ink; dark mode does the same, matching the `dark:text-white` the\n // light/white variants already set on the surface.\n <span\n className={cn(\n 'font-bold text-balance max-sm:text-lg sm:max-lg:text-xl lg:text-2xl',\n !onDarkSurface && 'text-primary-800 dark:text-white',\n )}\n >\n {sitename}\n </span>\n ) : null}\n </Link>\n {version ? (\n // Badge's `primary` ink is primary-800 — the `dark` header's own\n // surface — so dark surfaces take the white badge instead.\n <Badge\n data-slot='header-version'\n {...badgeProps}\n // Derived after the spread rather than before it. Spreading last would\n // let a key that is merely *present* win, so\n // `badgeProps={{ color: cond ? 'accent' : undefined }}` would pass\n // `undefined` through to cva, which falls back to its own\n // `defaultVariants.color` of `primary` — and primary-800 is the dark\n // header's own background, so the badge would vanish into it. `??`\n // keeps explicit values winning while undefined (and null, which\n // cva's VariantProps permits and which would otherwise render an\n // unstyled badge) falls back to the surface-aware default.\n variant={badgeProps?.variant ?? 'soft'}\n color={badgeProps?.color ?? (onDarkSurface ? 'white' : 'primary')}\n >\n {versionLabel ? <span className='sr-only'>{versionLabel} </span> : null}\n {version}\n </Badge>\n ) : null}\n {children}\n </div>\n )\n}\n\ntype HeaderActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * Trailing cluster of header controls — search, theme switcher, sign-in, and\n * the like. Deliberately unopinionated about what goes in it: site search and\n * theme switching are app concerns (they need routing and a theme provider),\n * so the design system supplies the slot and its spacing rather than the\n * widgets.\n *\n * Not a `nav` landmark: a row of controls is not a set of navigation links, and\n * an extra landmark on every page buries the ones that matter. Wrap genuine\n * navigation in your own `<nav>` inside `Header`.\n */\nfunction HeaderActions({ className, ref, ...props }: HeaderActionsProps) {\n return (\n <div\n data-slot='header-actions'\n {...props}\n className={cn(\n 'flex basis-0 items-center justify-end max-sm:gap-2 sm:gap-4 md:grow',\n className,\n )}\n ref={ref}\n />\n )\n}\n\ntype HeaderProps = React.ComponentPropsWithoutRef<'header'> &\n VariantProps<typeof headerVariants> &\n VariantProps<typeof headerContainerVariants> & {\n /** Stick to the top of the viewport as the page scrolls. Defaults to `true`. */\n sticky?: boolean\n /** Hairline rule along the bottom edge. Defaults to `true`. */\n border?: boolean\n /** Raise the header with a shadow once the page is scrolled. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Top-of-page `banner` landmark: brand, site name and header controls. Render\n * it once in a shared layout, below `SkipLinks` and `Masthead`.\n *\n * - `color` themes the surface; all four pairs are WCAG 2.2 AAA and follow the\n * theme in dark mode (see `headerColors`). The bottom rule derives from the\n * surface's ink, so it follows automatically.\n * - `container` selects the inner wrapper layout: `fluid` (full-bleed,\n * nswds-app parity) or `contained` (centred 1200px column, legacy\n * `nsw-container` parity). Fine-tune either with the `--header-max-width`\n * and `--header-padding-x` custom properties.\n * - Scroll position is tracked and exposed as `data-scrolled`, which is what\n * the `shadow` treatment keys off. Style your own scrolled state with it.\n *\n * Compose the row from `HeaderBrand` and `HeaderActions`:\n *\n * ```tsx\n * <Header>\n * <HeaderBrand sitename=\"Design System\" version=\"2.1.0\" />\n * <HeaderActions>\n * <ThemeSwitcher />\n * </HeaderActions>\n * </Header>\n * ```\n *\n * The `banner` landmark comes from the native `<header>` element, which only\n * carries it outside `article`, `aside`, `main`, `nav` and `section` — wrapping\n * `div`s are fine. Keep it out of `<main>`.\n *\n * The default `id=\"nsw-header\"` is kept for compatibility with existing shells\n * that target it (override via the `id` prop).\n */\nfunction Header({\n className,\n color,\n container,\n containerClassName,\n sticky = true,\n border = true,\n shadow = true,\n children,\n ref,\n ...props\n}: HeaderProps) {\n const [isScrolled, setIsScrolled] = React.useState(false)\n\n React.useEffect(() => {\n function onScroll() {\n setIsScrolled(window.scrollY > 0)\n }\n // Read once on mount too: a page restored mid-scroll (back/forward, or a\n // deep link to a fragment) never fires a scroll event.\n onScroll()\n window.addEventListener('scroll', onScroll, { passive: true })\n return () => window.removeEventListener('scroll', onScroll)\n }, [])\n\n return (\n <header\n id='nsw-header'\n data-slot='header'\n data-color={color ?? DEFAULT_HEADER_COLOR}\n // Present-or-absent rather than \"true\"/\"false\", so it reads like Base\n // UI's data-disabled and Tailwind's bare `data-scrolled:` variant works.\n data-scrolled={isScrolled || undefined}\n {...props}\n className={cn(\n headerVariants({ color }),\n // z-40 sits below the z-50 SkipLinks: a sticky header at the same\n // level comes later in the DOM and would paint over a focused skip\n // link, hiding the page's bypass mechanism (WCAG 2.2, 2.4.1).\n sticky && 'sticky top-0 z-40',\n // Always drawn, so the scrolled state changes no box heights.\n border && 'border-b border-(--header-border)',\n // Shadows read as elevation on light surfaces only; in dark mode the\n // rule above carries the separation.\n shadow &&\n 'data-scrolled:shadow-md data-scrolled:shadow-black/5 dark:data-scrolled:shadow-none',\n className,\n )}\n ref={ref}\n >\n <HeaderColorContext.Provider value={color ?? DEFAULT_HEADER_COLOR}>\n <div\n data-slot='header-container'\n className={cn(headerContainerVariants({ container }), containerClassName)}\n >\n {children}\n </div>\n </HeaderColorContext.Provider>\n </header>\n )\n}\n\nexport { Header, HeaderActions, HeaderBrand, headerColors, headerContainerVariants, headerVariants }\nexport type { HeaderActionsProps, HeaderBrandProps, HeaderColor, HeaderProps }\n"]}
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const linkVariants: (props?: ({
6
- variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
6
+ variant?: "primary" | "secondary" | "white" | "unstyled" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type LinkComponent = React__default.ElementType;
9
9
  /**
@@ -10,7 +10,7 @@ declare const mastheadColors: {
10
10
  };
11
11
  type MastheadColor = keyof typeof mastheadColors;
12
12
  declare const mastheadVariants: (props?: ({
13
- color?: "light" | "white" | "grey" | "dark" | null | undefined;
13
+ color?: "white" | "grey" | "light" | "dark" | null | undefined;
14
14
  } & class_variance_authority_types.ClassProp) | undefined) => string;
15
15
  declare const mastheadContainerVariants: (props?: ({
16
16
  container?: "fluid" | "contained" | null | undefined;
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const skipLinkVariants: (props?: ({
6
- color?: "light" | "white" | "grey" | "dark" | null | undefined;
6
+ color?: "white" | "grey" | "light" | "dark" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type SkipLinkProps = React__default.ComponentPropsWithoutRef<'a'> & VariantProps<typeof skipLinkVariants> & {
9
9
  /** Same-page fragment target, e.g. `"#content"`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nswds/ui",
3
- "version": "5.7.1",
3
+ "version": "6.0.0",
4
4
  "description": "UI components for NSW Government digital products, providing reusable design elements and patterns for consistent user interfaces.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/digitalnsw/nswds-ui#readme",