@nswds/ui 9.2.0 → 9.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/components/breadcrumb.d.ts +1 -1
  2. package/dist/components/breadcrumb.js +5 -4
  3. package/dist/components/breadcrumb.js.map +1 -1
  4. package/dist/components/button-group.js +3 -2
  5. package/dist/components/button-group.js.map +1 -1
  6. package/dist/components/button.d.ts +2 -2
  7. package/dist/components/callout.d.ts +2 -2
  8. package/dist/components/callout.js +4 -3
  9. package/dist/components/callout.js.map +1 -1
  10. package/dist/components/description-list.js +7 -4
  11. package/dist/components/description-list.js.map +1 -1
  12. package/dist/components/expandable-search.js +5 -4
  13. package/dist/components/expandable-search.js.map +1 -1
  14. package/dist/components/footer.d.ts +1 -1
  15. package/dist/components/footer.js +9 -5
  16. package/dist/components/footer.js.map +1 -1
  17. package/dist/components/header.d.ts +1 -1
  18. package/dist/components/header.js +9 -5
  19. package/dist/components/header.js.map +1 -1
  20. package/dist/components/hero.d.ts +2 -2
  21. package/dist/components/hero.js +22 -11
  22. package/dist/components/hero.js.map +1 -1
  23. package/dist/components/input-group.d.ts +1 -1
  24. package/dist/components/link.d.ts +1 -1
  25. package/dist/components/main-nav.d.ts +1 -1
  26. package/dist/components/main-nav.js +9 -5
  27. package/dist/components/main-nav.js.map +1 -1
  28. package/dist/components/masthead.d.ts +1 -1
  29. package/dist/components/masthead.js +8 -4
  30. package/dist/components/masthead.js.map +1 -1
  31. package/dist/components/native-select.js +9 -6
  32. package/dist/components/native-select.js.map +1 -1
  33. package/dist/components/page-header.d.ts +138 -0
  34. package/dist/components/page-header.js +181 -0
  35. package/dist/components/page-header.js.map +1 -0
  36. package/dist/components/select.js +6 -3
  37. package/dist/components/select.js.map +1 -1
  38. package/dist/components/skeleton.js +4 -3
  39. package/dist/components/skeleton.js.map +1 -1
  40. package/dist/components/tabs.js +7 -5
  41. package/dist/components/tabs.js.map +1 -1
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.js +1 -0
  44. package/dist/lib/resolve-variant.d.ts +23 -0
  45. package/dist/lib/resolve-variant.js +7 -0
  46. package/dist/lib/resolve-variant.js.map +1 -0
  47. package/dist/styles.css +1 -1
  48. package/package.json +5 -4
@@ -1,5 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { cva } from 'class-variance-authority';
3
+ import { resolveVariant } from '../lib/resolve-variant.js';
3
4
  import { cn } from '../lib/utils.js';
4
5
 
5
6
  const heroColors = {
@@ -29,6 +30,9 @@ const heroColors = {
29
30
  ].join(" ")
30
31
  };
31
32
  const DEFAULT_HERO_COLOR = "white";
33
+ const DEFAULT_HERO_LAYOUT = "split";
34
+ const DEFAULT_HERO_CONTAINER = "fluid";
35
+ const DEFAULT_HERO_FIT = "framed";
32
36
  const heroVariants = cva("group/hero w-full text-(--hero-ink)", {
33
37
  variants: {
34
38
  color: heroColors
@@ -62,8 +66,8 @@ const heroInnerVariants = cva(
62
66
  }
63
67
  },
64
68
  defaultVariants: {
65
- layout: "split",
66
- container: "fluid"
69
+ layout: DEFAULT_HERO_LAYOUT,
70
+ container: DEFAULT_HERO_CONTAINER
67
71
  }
68
72
  }
69
73
  );
@@ -79,22 +83,28 @@ function Hero({
79
83
  children,
80
84
  ...props
81
85
  }) {
86
+ const colorway = resolveVariant(color, DEFAULT_HERO_COLOR);
87
+ const layoutway = resolveVariant(layout, DEFAULT_HERO_LAYOUT);
88
+ const containerway = resolveVariant(container, DEFAULT_HERO_CONTAINER);
82
89
  return /* @__PURE__ */ jsx(
83
90
  "section",
84
91
  {
85
92
  ref,
86
93
  "data-slot": "hero",
87
- "data-color": color ?? DEFAULT_HERO_COLOR,
88
- "data-layout": layout ?? "split",
89
- "data-align": align,
90
94
  "aria-labelledby": labelledBy,
91
- className: cn(heroVariants({ color, className })),
92
95
  ...props,
96
+ "data-color": colorway,
97
+ "data-layout": layoutway,
98
+ "data-align": align,
99
+ className: cn(heroVariants({ color: colorway, className })),
93
100
  children: /* @__PURE__ */ jsx(
94
101
  "div",
95
102
  {
96
103
  "data-slot": "hero-inner",
97
- className: cn(heroInnerVariants({ layout, container }), innerClassName),
104
+ className: cn(
105
+ heroInnerVariants({ layout: layoutway, container: containerway }),
106
+ innerClassName
107
+ ),
98
108
  children
99
109
  }
100
110
  )
@@ -205,19 +215,20 @@ const heroMediaVariants = cva(
205
215
  }
206
216
  },
207
217
  defaultVariants: {
208
- fit: "framed"
218
+ fit: DEFAULT_HERO_FIT
209
219
  }
210
220
  }
211
221
  );
212
222
  function HeroMedia({ className, fit, ref, ...props }) {
223
+ const fitway = resolveVariant(fit, DEFAULT_HERO_FIT);
213
224
  return /* @__PURE__ */ jsx(
214
225
  "div",
215
226
  {
216
227
  ref,
217
228
  "data-slot": "hero-media",
218
- "data-fit": fit ?? "framed",
219
- className: cn(heroMediaVariants({ fit, className })),
220
- ...props
229
+ ...props,
230
+ "data-fit": fitway,
231
+ className: cn(heroMediaVariants({ fit: fitway, className }))
221
232
  }
222
233
  );
223
234
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/hero.tsx"],"names":[],"mappings":";;;;AAqBA,MAAM,UAAA,GAAa;AAAA;AAAA;AAAA,EAGjB,IAAA,EAAM;AAAA,IACJ,+CAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,4DAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,yDAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA;AAAA;AAAA;AAAA,EAIV,IAAA,EAAM;AAAA,IACJ,kEAAA;AAAA,IACA,iGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG;AACZ;AAIA,MAAM,kBAAA,GAAgC,OAAA;AAEtC,MAAM,Y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,EAAW,CAAC,CAAA;AAAA,MAClD,GAAG;AAAA;AAAA,GACN;AAEJ","file":"hero.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils.js'\n\n/**\n * Surface colours a hero can be drawn on, in the Header's and Masthead's\n * four-name vocabulary plus `tint`, the pale brand panel a landing page uses\n * to mark its opening off from a white body.\n *\n * Each surface sets three inks the slots read: `--hero-heading` (the title),\n * `--hero-ink` (body text and anything a consumer adds) and `--hero-muted`\n * (the description). On the light surfaces the heading is the brand navy and\n * the description the muted role token, both of which flip for dark mode on\n * their own; on `dark` everything is white, because white on `primary-800` is\n * the one pairing that clears WCAG 2.2 AAA (14.4:1) and a muted white would\n * not. Dark mode deepens each surface onto its family's dark step, on the\n * same ramp Header uses (`-800 → -950`, white → `grey-900`, `-100 → -850`), so\n * a hero under a themed header never draws a seam.\n */\nconst heroColors = {\n // The brand band, as Header's `dark`: primary-800 with white text,\n // deepening to primary-950 in dark mode (AGENTS.md §3, recorded exception).\n dark: [\n 'bg-primary-800 text-white dark:bg-primary-950',\n '[--hero-ink:var(--color-white)] [--hero-heading:var(--color-white)] [--hero-muted:var(--color-white)]',\n ].join(' '),\n light: [\n 'bg-grey-100 text-grey-800 dark:bg-grey-850 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n white: [\n 'bg-white text-grey-800 dark:bg-grey-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n // The pale brand panel. primary-200 is the masterbrand's light blue; in dark\n // mode it deepens to primary-900, one step short of the `dark` surface's\n // dark step so the two stay distinguishable when stacked.\n tint: [\n 'bg-primary-200 text-grey-800 dark:bg-primary-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--grey-800)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n}\n\ntype HeroColor = keyof typeof heroColors\n\nconst DEFAULT_HERO_COLOR: HeroColor = 'white'\n\nconst heroVariants = cva('group/hero w-full text-(--hero-ink)', {\n variants: {\n color: heroColors,\n },\n defaultVariants: {\n color: DEFAULT_HERO_COLOR,\n },\n})\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container` and the\n * chrome components (16px → 24px → 48px, funnelled through\n * `--hero-padding-x`), so a hero's text lines up with the header above it.\n * The media slots read the same custom property to bleed back out to the\n * edge, which is why it is a property and not a bare padding utility.\n *\n * Vertical rhythm lives on `HeroContent`, not here: a `bleed` image fills the\n * full height of the band, so the band itself cannot carry padding.\n */\nconst heroInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--hero-padding-x)',\n '[--hero-padding-x:--spacing(4)] sm:[--hero-padding-x:--spacing(6)] lg:[--hero-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n layout: {\n // Content beside media from `lg:`, stacked (content first) below it.\n split: 'grid max-lg:grid-cols-1 lg:grid-cols-2 lg:items-stretch lg:gap-x-16',\n // Content over media, each full width. Also the layout for a hero\n // with no media at all.\n stack: 'flex flex-col',\n },\n container: {\n // Full-bleed, matching the chrome's default. `--hero-max-width` is\n // still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--hero-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--hero-max-width,75rem)]',\n },\n },\n defaultVariants: {\n layout: 'split',\n container: 'fluid',\n },\n },\n)\n\ntype HeroProps = React.ComponentPropsWithoutRef<'section'> &\n VariantProps<typeof heroVariants> &\n VariantProps<typeof heroInnerVariants> & {\n /**\n * Where the text sits. `centre` centres the content column and its\n * title, description and actions — the opener of a landing page.\n * `start` is the default, for a hero that reads on from the header.\n */\n align?: 'start' | 'centre'\n /**\n * `id` of the `HeroTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section`, no fallback name is invented.\n */\n labelledBy?: string\n /** Classes applied to the inner column. */\n innerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * The opening band of a page: a title, a short description, up to two\n * actions, and optionally one illustration.\n *\n * Compose it from its slots — `HeroContent` holding `HeroTitle`,\n * `HeroDescription` and `HeroActions`, with an optional `HeroRule` above the\n * title and an optional `HeroMedia` beside or beneath the content:\n *\n * ```tsx\n * <Hero color='dark' layout='split' labelledBy='hero-title'>\n * <HeroContent>\n * <HeroTitle id='hero-title'>Made to send.</HeroTitle>\n * <HeroDescription>Reusable components for NSW Government email.</HeroDescription>\n * <HeroActions>\n * <ButtonLink href='/start' color='white'>Get started</ButtonLink>\n * </HeroActions>\n * </HeroContent>\n * <HeroMedia fit='bleed'>\n * <img src='/illustration.png' alt='' />\n * </HeroMedia>\n * </Hero>\n * ```\n *\n * The five registry blocks (`hero-split`, `hero-framed`, `hero-panel`,\n * `hero-centred`, `hero-statement`) are worked examples of the combinations\n * the NSW Design System recommends; copy one and adapt it.\n */\nfunction Hero({\n className,\n innerClassName,\n color,\n layout,\n container,\n align = 'start',\n labelledBy,\n ref,\n children,\n ...props\n}: HeroProps) {\n return (\n <section\n ref={ref}\n data-slot='hero'\n data-color={color ?? DEFAULT_HERO_COLOR}\n data-layout={layout ?? 'split'}\n data-align={align}\n aria-labelledby={labelledBy}\n className={cn(heroVariants({ color, className }))}\n {...props}\n >\n <div\n data-slot='hero-inner'\n className={cn(heroInnerVariants({ layout, container }), innerClassName)}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype HeroContentProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The text column: title, description and actions, vertically centred\n * against the media beside it and carrying the hero's vertical rhythm.\n */\nfunction HeroContent({ className, ref, ...props }: HeroContentProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-content'\n className={cn(\n 'flex flex-col justify-center gap-6',\n // The band's vertical rhythm, one step tighter than Section's so a\n // hero does not push the page's first content below the fold.\n 'max-sm:py-14 sm:max-lg:py-16 lg:py-24',\n // Centred alignment, driven by the hero's data-align so a consumer\n // sets it once.\n 'group-data-[align=centre]/hero:mx-auto group-data-[align=centre]/hero:max-w-4xl group-data-[align=centre]/hero:items-center group-data-[align=centre]/hero:text-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a hero opens the page and\n * its title is the page's title; `2` for a hero that opens a section of a\n * page whose `h1` sits elsewhere, so the outline stays in order (WCAG\n * 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The headline. Semibold rather than bold, at 60px from `lg:`, with the\n * tracking the masterbrand's display setting asks for. Sentence case — the\n * brand sets nothing in uppercase.\n */\nfunction HeroTitle({ className, headingLevel = 1, ref, ...props }: HeroTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <Heading\n ref={ref}\n data-slot='hero-title'\n className={cn(\n 'max-w-[20ch] font-semibold tracking-tight text-balance text-(--hero-heading)',\n 'max-sm:text-4xl sm:max-lg:text-5xl lg:text-6xl',\n 'max-sm:leading-tight sm:leading-none',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/** One or two sentences under the title, at the reading measure. */\nfunction HeroDescription({ className, ref, ...props }: HeroDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='hero-description'\n className={cn('max-w-prose text-lg leading-8 text-pretty text-(--hero-muted)', className)}\n {...props}\n />\n )\n}\n\ntype HeroActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The row of actions. One or two `ButtonLink`s: the first solid, the second\n * outline. On the `dark` surface give them `color='white'`; elsewhere\n * `primary` (see the note on Button's `color`).\n */\nfunction HeroActions({ className, ref, ...props }: HeroActionsProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-actions'\n className={cn(\n 'flex flex-wrap gap-3 pt-3',\n 'group-data-[align=centre]/hero:justify-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short accent rule above the title, for a hero that carries no\n * illustration and wants one mark of the brand colour. Decorative, so it is\n * hidden from assistive technology.\n */\nfunction HeroRule({ className, ref, ...props }: HeroRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='hero-rule'\n className={cn('h-1.5 w-16 rounded-sm bg-primary', className)}\n {...props}\n />\n )\n}\n\n/**\n * How the illustration sits against the content. Every fit sizes the image\n * it wraps to fill the slot and crop (`object-cover`), so a consumer passes a\n * plain `<img>` or their framework's image component.\n */\nconst heroMediaVariants = cva(\n 'relative overflow-hidden *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover',\n {\n variants: {\n fit: {\n /**\n * Flush to the band's edge, filling its full height — the opener of\n * email.digital.nsw.gov.au. Reads `--hero-padding-x` back out to the\n * edge on the media side (and both sides when stacked on a phone).\n * With `container='contained'` it reaches the column's edge, not the\n * viewport's.\n */\n bleed:\n 'max-lg:-mx-(--hero-padding-x) max-lg:aspect-3/2 lg:-mr-(--hero-padding-x) lg:h-full',\n /** A rounded picture beside the content, vertically centred. */\n framed: 'aspect-3/2 self-center rounded-md max-sm:mb-14 sm:max-lg:mb-16 lg:mb-0',\n /**\n * Rising from the bottom edge of the band with its top corners\n * rounded, as though the page's first card had been pulled up into\n * the hero. Pair with `color='tint'`.\n */\n rise: 'aspect-4/3 self-end rounded-t-md',\n /**\n * A shallow full-width strip beneath the content, for `layout='stack'`.\n * Reads `--hero-padding-x` back out to the edge on both sides.\n */\n band: '-mx-(--hero-padding-x) max-sm:h-48 sm:max-lg:h-64 lg:h-80',\n },\n },\n defaultVariants: {\n fit: 'framed',\n },\n },\n)\n\ntype HeroMediaProps = React.ComponentPropsWithoutRef<'div'> &\n VariantProps<typeof heroMediaVariants> & {\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The illustration slot. Wraps one image; the `fit` decides how it sits.\n * The image's `alt` is the consumer's: empty when the picture decorates the\n * title, descriptive when it carries meaning the text does not.\n */\nfunction HeroMedia({ className, fit, ref, ...props }: HeroMediaProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-media'\n data-fit={fit ?? 'framed'}\n className={cn(heroMediaVariants({ fit, className }))}\n {...props}\n />\n )\n}\n\nexport {\n Hero,\n HeroActions,\n heroColors,\n HeroContent,\n HeroDescription,\n heroInnerVariants,\n HeroMedia,\n heroMediaVariants,\n HeroRule,\n HeroTitle,\n heroVariants,\n}\nexport type {\n HeroActionsProps,\n HeroColor,\n HeroContentProps,\n HeroDescriptionProps,\n HeroMediaProps,\n HeroProps,\n HeroRuleProps,\n HeroTitleProps,\n}\n"]}
1
+ {"version":3,"sources":["../../src/components/hero.tsx"],"names":[],"mappings":";;;;;AAsBA,MAAM,UAAA,GAAa;AAAA;AAAA;AAAA,EAGjB,IAAA,EAAM;AAAA,IACJ,+CAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,4DAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA,EACV,KAAA,EAAO;AAAA,IACL,yDAAA;AAAA,IACA,mGAAA;AAAA,IACA;AAAA,GACF,CAAE,KAAK,GAAG,CAAA;AAAA;AAAA;AAAA;AAAA,EAIV,IAAA,EAAM;AAAA,IACJ,kEAAA;AAAA,IACA,i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AAA;AAAA,QAMR,IAAA,EAAM,kCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAKN,IAAA,EAAM;AAAA;AACR,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,GAAA,EAAK;AAAA;AACP;AAEJ;AAYA,SAAS,UAAU,EAAE,SAAA,EAAW,KAAK,GAAA,EAAK,GAAG,OAAM,EAAmB;AAEpE,EAAA,MAAM,MAAA,GAAS,cAAA,CAAe,GAAA,EAAK,gBAAgB,CAAA;AACnD,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,YAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,UAAA,EAAU,MAAA;AAAA,MACV,SAAA,EAAW,GAAG,iBAAA,CAAkB,EAAE,KAAK,MAAA,EAAQ,SAAA,EAAW,CAAC;AAAA;AAAA,GAC7D;AAEJ","file":"hero.js","sourcesContent":["import type * as React from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * Surface colours a hero can be drawn on, in the Header's and Masthead's\n * four-name vocabulary plus `tint`, the pale brand panel a landing page uses\n * to mark its opening off from a white body.\n *\n * Each surface sets three inks the slots read: `--hero-heading` (the title),\n * `--hero-ink` (body text and anything a consumer adds) and `--hero-muted`\n * (the description). On the light surfaces the heading is the brand navy and\n * the description the muted role token, both of which flip for dark mode on\n * their own; on `dark` everything is white, because white on `primary-800` is\n * the one pairing that clears WCAG 2.2 AAA (14.4:1) and a muted white would\n * not. Dark mode deepens each surface onto its family's dark step, on the\n * same ramp Header uses (`-800 → -950`, white → `grey-900`, `-100 → -850`), so\n * a hero under a themed header never draws a seam.\n */\nconst heroColors = {\n // The brand band, as Header's `dark`: primary-800 with white text,\n // deepening to primary-950 in dark mode (AGENTS.md §3, recorded exception).\n dark: [\n 'bg-primary-800 text-white dark:bg-primary-950',\n '[--hero-ink:var(--color-white)] [--hero-heading:var(--color-white)] [--hero-muted:var(--color-white)]',\n ].join(' '),\n light: [\n 'bg-grey-100 text-grey-800 dark:bg-grey-850 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n white: [\n 'bg-white text-grey-800 dark:bg-grey-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--text-muted)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n // The pale brand panel. primary-200 is the masterbrand's light blue; in dark\n // mode it deepens to primary-900, one step short of the `dark` surface's\n // dark step so the two stay distinguishable when stacked.\n tint: [\n 'bg-primary-200 text-grey-800 dark:bg-primary-900 dark:text-white',\n '[--hero-ink:var(--grey-800)] [--hero-heading:var(--primary-800)] [--hero-muted:var(--grey-800)]',\n 'dark:[--hero-ink:var(--color-white)] dark:[--hero-heading:var(--color-white)] dark:[--hero-muted:var(--color-white)]',\n ].join(' '),\n}\n\ntype HeroColor = keyof typeof heroColors\n\nconst DEFAULT_HERO_COLOR: HeroColor = 'white'\n// Shared by cva's defaultVariants and the `resolveVariant` calls (and, for\n// layout and fit, the data-* attributes), so they can't drift apart — the\n// arrangement Header and Masthead use for their colour.\nconst DEFAULT_HERO_LAYOUT = 'split'\nconst DEFAULT_HERO_CONTAINER = 'fluid'\nconst DEFAULT_HERO_FIT = 'framed'\n\nconst heroVariants = cva('group/hero w-full text-(--hero-ink)', {\n variants: {\n color: heroColors,\n },\n defaultVariants: {\n color: DEFAULT_HERO_COLOR,\n },\n})\n\n/**\n * The inner column, carrying the same lateral rhythm as `Container` and the\n * chrome components (16px → 24px → 48px, funnelled through\n * `--hero-padding-x`), so a hero's text lines up with the header above it.\n * The media slots read the same custom property to bleed back out to the\n * edge, which is why it is a property and not a bare padding utility.\n *\n * Vertical rhythm lives on `HeroContent`, not here: a `bleed` image fills the\n * full height of the band, so the band itself cannot carry padding.\n */\nconst heroInnerVariants = cva(\n [\n 'mx-auto w-full',\n 'px-(--hero-padding-x)',\n '[--hero-padding-x:--spacing(4)] sm:[--hero-padding-x:--spacing(6)] lg:[--hero-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n layout: {\n // Content beside media from `lg:`, stacked (content first) below it.\n split: 'grid max-lg:grid-cols-1 lg:grid-cols-2 lg:items-stretch lg:gap-x-16',\n // Content over media, each full width. Also the layout for a hero\n // with no media at all.\n stack: 'flex flex-col',\n },\n container: {\n // Full-bleed, matching the chrome's default. `--hero-max-width` is\n // still read so a shell app can constrain the column without\n // switching variants.\n fluid: 'max-w-[var(--hero-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--hero-max-width,75rem)]',\n },\n },\n defaultVariants: {\n layout: DEFAULT_HERO_LAYOUT,\n container: DEFAULT_HERO_CONTAINER,\n },\n },\n)\n\n// The native `color` attribute is omitted so the prop type admits the `null`\n// cva's `VariantProps` allows and the component resolves.\ntype HeroProps = Omit<React.ComponentPropsWithoutRef<'section'>, 'color'> &\n VariantProps<typeof heroVariants> &\n VariantProps<typeof heroInnerVariants> & {\n /**\n * Where the text sits. `centre` centres the content column and its\n * title, description and actions — the opener of a landing page.\n * `start` is the default, for a hero that reads on from the header.\n */\n align?: 'start' | 'centre'\n /**\n * `id` of the `HeroTitle`. Names the section so it is exposed as a\n * `region` landmark; as with `Section`, no fallback name is invented.\n */\n labelledBy?: string\n /** Classes applied to the inner column. */\n innerClassName?: string\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * The opening band of a page: a title, a short description, up to two\n * actions, and optionally one illustration.\n *\n * Compose it from its slots — `HeroContent` holding `HeroTitle`,\n * `HeroDescription` and `HeroActions`, with an optional `HeroRule` above the\n * title and an optional `HeroMedia` beside or beneath the content:\n *\n * ```tsx\n * <Hero color='dark' layout='split' labelledBy='hero-title'>\n * <HeroContent>\n * <HeroTitle id='hero-title'>Made to send.</HeroTitle>\n * <HeroDescription>Reusable components for NSW Government email.</HeroDescription>\n * <HeroActions>\n * <ButtonLink href='/start' color='white'>Get started</ButtonLink>\n * </HeroActions>\n * </HeroContent>\n * <HeroMedia fit='bleed'>\n * <img src='/illustration.png' alt='' />\n * </HeroMedia>\n * </Hero>\n * ```\n *\n * The five registry blocks (`hero-split`, `hero-framed`, `hero-panel`,\n * `hero-centred`, `hero-statement`) are worked examples of the combinations\n * the NSW Design System recommends; copy one and adapt it.\n */\nfunction Hero({\n className,\n innerClassName,\n color,\n layout,\n container,\n align = 'start',\n labelledBy,\n ref,\n children,\n ...props\n}: HeroProps) {\n // Resolved once (see `resolveVariant`), so cva, the data attributes and\n // anything else reading these agree for `null` and `''` as well as the\n // default spelling.\n const colorway = resolveVariant(color, DEFAULT_HERO_COLOR)\n const layoutway = resolveVariant(layout, DEFAULT_HERO_LAYOUT)\n const containerway = resolveVariant(container, DEFAULT_HERO_CONTAINER)\n return (\n <section\n ref={ref}\n data-slot='hero'\n aria-labelledby={labelledBy}\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-color={colorway}\n data-layout={layoutway}\n data-align={align}\n className={cn(heroVariants({ color: colorway, className }))}\n >\n <div\n data-slot='hero-inner'\n className={cn(\n heroInnerVariants({ layout: layoutway, container: containerway }),\n innerClassName,\n )}\n >\n {children}\n </div>\n </section>\n )\n}\n\ntype HeroContentProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The text column: title, description and actions, vertically centred\n * against the media beside it and carrying the hero's vertical rhythm.\n */\nfunction HeroContent({ className, ref, ...props }: HeroContentProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-content'\n className={cn(\n 'flex flex-col justify-center gap-6',\n // The band's vertical rhythm, one step tighter than Section's so a\n // hero does not push the page's first content below the fold.\n 'max-sm:py-14 sm:max-lg:py-16 lg:py-24',\n // Centred alignment, driven by the hero's data-align so a consumer\n // sets it once.\n 'group-data-[align=centre]/hero:mx-auto group-data-[align=centre]/hero:max-w-4xl group-data-[align=centre]/hero:items-center group-data-[align=centre]/hero:text-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroTitleProps = React.ComponentPropsWithoutRef<'h1'> & {\n /**\n * The heading element. `1` by default, because a hero opens the page and\n * its title is the page's title; `2` for a hero that opens a section of a\n * page whose `h1` sits elsewhere, so the outline stays in order (WCAG\n * 1.3.1).\n */\n headingLevel?: 1 | 2\n ref?: React.Ref<HTMLHeadingElement>\n}\n\n/**\n * The headline. Semibold rather than bold, at 60px from `lg:`, with the\n * tracking the masterbrand's display setting asks for. Sentence case — the\n * brand sets nothing in uppercase.\n */\nfunction HeroTitle({ className, headingLevel = 1, ref, ...props }: HeroTitleProps) {\n const Heading = `h${headingLevel}` as const\n return (\n <Heading\n ref={ref}\n data-slot='hero-title'\n className={cn(\n 'max-w-[20ch] font-semibold tracking-tight text-balance text-(--hero-heading)',\n 'max-sm:text-4xl sm:max-lg:text-5xl lg:text-6xl',\n 'max-sm:leading-tight sm:leading-none',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroDescriptionProps = React.ComponentPropsWithoutRef<'p'> & {\n ref?: React.Ref<HTMLParagraphElement>\n}\n\n/** One or two sentences under the title, at the reading measure. */\nfunction HeroDescription({ className, ref, ...props }: HeroDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot='hero-description'\n className={cn('max-w-prose text-lg leading-8 text-pretty text-(--hero-muted)', className)}\n {...props}\n />\n )\n}\n\ntype HeroActionsProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * The row of actions. One or two `ButtonLink`s: the first solid, the second\n * outline. On the `dark` surface give them `color='white'`; elsewhere\n * `primary` (see the note on Button's `color`).\n */\nfunction HeroActions({ className, ref, ...props }: HeroActionsProps) {\n return (\n <div\n ref={ref}\n data-slot='hero-actions'\n className={cn(\n 'flex flex-wrap gap-3 pt-3',\n 'group-data-[align=centre]/hero:justify-center',\n className,\n )}\n {...props}\n />\n )\n}\n\ntype HeroRuleProps = React.ComponentPropsWithoutRef<'div'> & {\n ref?: React.Ref<HTMLDivElement>\n}\n\n/**\n * A short accent rule above the title, for a hero that carries no\n * illustration and wants one mark of the brand colour. Decorative, so it is\n * hidden from assistive technology.\n */\nfunction HeroRule({ className, ref, ...props }: HeroRuleProps) {\n return (\n <div\n ref={ref}\n aria-hidden='true'\n data-slot='hero-rule'\n className={cn('h-1.5 w-16 rounded-sm bg-primary', className)}\n {...props}\n />\n )\n}\n\n/**\n * How the illustration sits against the content. Every fit sizes the image\n * it wraps to fill the slot and crop (`object-cover`), so a consumer passes a\n * plain `<img>` or their framework's image component.\n */\nconst heroMediaVariants = cva(\n 'relative overflow-hidden *:size-full *:object-cover [&_img]:size-full [&_img]:object-cover',\n {\n variants: {\n fit: {\n /**\n * Flush to the band's edge, filling its full height — the opener of\n * email.digital.nsw.gov.au. Reads `--hero-padding-x` back out to the\n * edge on the media side (and both sides when stacked on a phone).\n * With `container='contained'` it reaches the column's edge, not the\n * viewport's.\n */\n bleed:\n 'max-lg:-mx-(--hero-padding-x) max-lg:aspect-3/2 lg:-mr-(--hero-padding-x) lg:h-full',\n /** A rounded picture beside the content, vertically centred. */\n framed: 'aspect-3/2 self-center rounded-md max-sm:mb-14 sm:max-lg:mb-16 lg:mb-0',\n /**\n * Rising from the bottom edge of the band with its top corners\n * rounded, as though the page's first card had been pulled up into\n * the hero. Pair with `color='tint'`.\n */\n rise: 'aspect-4/3 self-end rounded-t-md',\n /**\n * A shallow full-width strip beneath the content, for `layout='stack'`.\n * Reads `--hero-padding-x` back out to the edge on both sides.\n */\n band: '-mx-(--hero-padding-x) max-sm:h-48 sm:max-lg:h-64 lg:h-80',\n },\n },\n defaultVariants: {\n fit: DEFAULT_HERO_FIT,\n },\n },\n)\n\ntype HeroMediaProps = React.ComponentPropsWithoutRef<'div'> &\n VariantProps<typeof heroMediaVariants> & {\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The illustration slot. Wraps one image; the `fit` decides how it sits.\n * The image's `alt` is the consumer's: empty when the picture decorates the\n * title, descriptive when it carries meaning the text does not.\n */\nfunction HeroMedia({ className, fit, ref, ...props }: HeroMediaProps) {\n // Resolved once, as `Hero` does for `color` and `layout`.\n const fitway = resolveVariant(fit, DEFAULT_HERO_FIT)\n return (\n <div\n ref={ref}\n data-slot='hero-media'\n {...props}\n data-fit={fitway}\n className={cn(heroMediaVariants({ fit: fitway, className }))}\n />\n )\n}\n\nexport {\n Hero,\n HeroActions,\n heroColors,\n HeroContent,\n HeroDescription,\n heroInnerVariants,\n HeroMedia,\n heroMediaVariants,\n HeroRule,\n HeroTitle,\n heroVariants,\n}\nexport type {\n HeroActionsProps,\n HeroColor,\n HeroContentProps,\n HeroDescriptionProps,\n HeroMediaProps,\n HeroProps,\n HeroRuleProps,\n HeroTitleProps,\n}\n"]}
@@ -35,7 +35,7 @@ declare function InputGroupButton({ className, type, variant, size, ...props }:
35
35
  type?: 'button' | 'submit' | 'reset';
36
36
  }): React.JSX.Element;
37
37
  declare const inputGroupActionVariants: (props?: ({
38
- variant?: "solid" | "open" | "subtle" | null | undefined;
38
+ variant?: "open" | "solid" | "subtle" | null | undefined;
39
39
  } & class_variance_authority_types.ClassProp) | undefined) => string;
40
40
  declare function InputGroupAction({ className, type, variant, ...props }: Omit<React.ComponentProps<typeof Button>, 'size' | 'type' | 'variant'> & VariantProps<typeof inputGroupActionVariants> & {
41
41
  type?: 'button' | 'submit' | 'reset';
@@ -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?: "primary" | "secondary" | "white" | "unstyled" | null | undefined;
6
+ variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type LinkComponent = React__default.ElementType;
9
9
  /**
@@ -69,7 +69,7 @@ type MainNavItem = {
69
69
  href?: string;
70
70
  links?: MainNavLinkItem[];
71
71
  };
72
- type MainNavProps = Omit<React__default.ComponentPropsWithoutRef<'nav'>, 'children'> & VariantProps<typeof mainNavVariants> & VariantProps<typeof mainNavContainerVariants> & {
72
+ type MainNavProps = Omit<React__default.ComponentPropsWithoutRef<'nav'>, 'children' | 'color'> & VariantProps<typeof mainNavVariants> & VariantProps<typeof mainNavContainerVariants> & {
73
73
  /** Top-level items; items with `links` open mega panels. */
74
74
  navigation: MainNavItem[];
75
75
  /**
@@ -3,6 +3,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
3
  import { cva } from 'class-variance-authority';
4
4
  import React from 'react';
5
5
  import { IconEast } from '../icons/east.js';
6
+ import { resolveVariant } from '../lib/resolve-variant.js';
6
7
  import { cn } from '../lib/utils.js';
7
8
  import { NavigationMenu, NavigationMenuList, NavigationMenuItem, NavigationMenuLink, NavigationMenuTrigger, NavigationMenuContent } from '../components/navigation-menu.js';
8
9
 
@@ -22,6 +23,7 @@ const mainNavColors = [
22
23
  "white"
23
24
  ];
24
25
  const DEFAULT_MAIN_NAV_COLOR = "white";
26
+ const DEFAULT_MAIN_NAV_CONTAINER = "fluid";
25
27
  const mainNavVariants = cva(
26
28
  [
27
29
  "w-full",
@@ -106,7 +108,7 @@ const mainNavContainerVariants = cva(
106
108
  }
107
109
  },
108
110
  defaultVariants: {
109
- container: "fluid"
111
+ container: DEFAULT_MAIN_NAV_CONTAINER
110
112
  }
111
113
  }
112
114
  );
@@ -313,16 +315,18 @@ function MainNav({
313
315
  lastAlignOffsetRef.current = element.getBoundingClientRect().left - trigger.getBoundingClientRect().left;
314
316
  return lastAlignOffsetRef.current;
315
317
  }, []);
318
+ const colorway = resolveVariant(color, DEFAULT_MAIN_NAV_COLOR);
319
+ const containerway = resolveVariant(container, DEFAULT_MAIN_NAV_CONTAINER);
316
320
  return /* @__PURE__ */ jsx(
317
321
  "nav",
318
322
  {
319
323
  id: "nsw-main-navigation",
320
324
  "data-slot": "main-nav",
321
- "data-color": color ?? DEFAULT_MAIN_NAV_COLOR,
322
325
  "aria-label": ariaLabel,
323
326
  ...props,
327
+ "data-color": colorway,
324
328
  className: cn(
325
- mainNavVariants({ color, border }),
329
+ mainNavVariants({ color: colorway, border }),
326
330
  // z-40 matches Header (both sit below the z-50 SkipLinks). An app
327
331
  // stacking this under a sticky Header sets --main-nav-top to the
328
332
  // header's height.
@@ -337,7 +341,7 @@ function MainNav({
337
341
  {
338
342
  ref: containerRef,
339
343
  "data-slot": "main-nav-container",
340
- className: cn(mainNavContainerVariants({ container }), containerClassName),
344
+ className: cn(mainNavContainerVariants({ container: containerway }), containerClassName),
341
345
  children: navigation.length === 0 ? (
342
346
  // No items: render the message directly rather than an empty
343
347
  // NavigationMenu, which would still mount the portal, positioner and
@@ -368,7 +372,7 @@ function MainNav({
368
372
  MainNavMenuItem,
369
373
  {
370
374
  item,
371
- color: color ?? DEFAULT_MAIN_NAV_COLOR,
375
+ color: colorway,
372
376
  currentHref,
373
377
  panelWidth
374
378
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/main-nav.tsx"],"names":[],"mappings":";;;;;;;AAoCA,MAAM,aAAA,GAAgB;AAAA,EACpB,aAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,aAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF;AAMA,MAAM,sBAAA,GAAuC,OAAA;AAE7C,MAAM,eAAA,GAAkB,GAAA;AAAA,EACtB;AAAA,IACE,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AAS,sBAAA;AAAA,kBAChB,WAAA;AAAA,kBACA;AAAA,iBAAA;AAAA,gBAJK,GAAG,IAAA,CAAK,KAAK,CAAA,CAAA,EAAI,IAAA,CAAK,QAAQ,SAAS,CAAA;AAAA,eAM/C,CAAA,EACH;AAAA;AAAA,WACF,EACF;AAAA;AAAA;AAEJ;AAAA,GACF;AAEJ","file":"main-nav.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { IconEast } from '../icons/east.js'\nimport { cn } from '../lib/utils.js'\n\nimport {\n NavigationMenu,\n NavigationMenuContent,\n NavigationMenuItem,\n NavigationMenuLink,\n NavigationMenuList,\n NavigationMenuTrigger,\n} from '../components/navigation-menu.js'\n\n/**\n * Surface colours the main navigation can be themed with — exactly the\n * Footer's thirteen-name vocabulary, so a service that themes its footer\n * `primary-800` writes the same word here. Each name is the LIGHT-mode\n * surface; dark mode deepens it onto the same family's dark steps (see the\n * `color` variants below), so `color` expresses tonal weight rather than a\n * literal colour.\n *\n * The bar's text/background pairs are identical to the Footer's, so its\n * contrast conclusions carry over verbatim: every light pair clears WCAG 2.2\n * AA (1.4.3, 4.5:1) for the bar's text and 11 of the 13 also clear AAA\n * (1.4.6, 7:1). The two AA-only pairs are `primary-600` (4.57:1) and\n * `accent-600` (5.18:1), both with white ink; prefer the `-800` steps when a\n * service is held to AAA. In dark mode all thirteen clear AAA (worst 13.6:1).\n *\n * The mega panels always render on the house popup surface (`bg-popover`),\n * matching the nswds-app source where every dropdown was white regardless of\n * bar colour — only the panel's accent ink follows the colour family.\n */\nconst mainNavColors = [\n 'primary-800',\n 'primary-600',\n 'primary-400',\n 'primary-200',\n 'grey-800',\n 'grey-600',\n 'grey-400',\n 'grey-200',\n 'accent-800',\n 'accent-600',\n 'accent-400',\n 'accent-200',\n 'white',\n] as const\n\ntype MainNavColor = (typeof mainNavColors)[number]\n\n// Shared by cva's defaultVariants, the data-color attribute and the panel\n// variant lookup, so the three can't drift apart.\nconst DEFAULT_MAIN_NAV_COLOR: MainNavColor = 'white'\n\nconst mainNavVariants = cva(\n [\n 'w-full',\n // Every derived colour on the bar resolves from a single --main-nav-ink\n // token, so a colour variant only has to declare the surface utilities and\n // that one value — this replaces the nswds-app source's hand-written\n // 13-variant × 8-slot style table. The border derivation is written\n // literally here (once) rather than per-variant: Tailwind scans source\n // text for class names, so a template-built arbitrary property would\n // never be emitted. Hover/active halos are not derived here — the\n // triggers ride navigation-menu.tsx's --nav-menu-halo chain, re-pointed\n // at this ink (see mainNavItemInk), so there is exactly one halo recipe.\n '[--main-nav-border:color-mix(in_oklch,var(--main-nav-ink)_15%,transparent)]',\n ],\n {\n variants: {\n // Ink values use the RAW masterbrand tokens (--primary-800, --grey-800,\n // --accent-800) rather than Tailwind's --color-* bridge aliases. Tailwind\n // v4 tree-shakes an unreferenced @theme key, and referencing one from\n // inside an arbitrary property is not a usage signal — the raw tokens are\n // plain :root declarations from @nswds/tokens and always resolve.\n // (--color-white is safe: `text-white` / `bg-white` below are real\n // utilities, so that key is always emitted.)\n //\n // Dark mode deepens every surface onto the same family's dark steps —\n // -800→-950, -600→-900, -400→-850, -200→-800, white→grey-900 — the\n // Footer's exact mapping, so the luminance ORDER within a family is\n // preserved and a stacked Footer + MainNav sharing one colour word stay\n // in step in both themes. Ink goes white on all thirteen; every dark\n // pair is WCAG 2.2 AAA (worst 13.6:1).\n color: {\n 'primary-800':\n 'bg-primary-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n },\n // Rules along the bar's edges, drawn from the ink-derived border token so\n // they follow every colour variant and both themes. Replaces the app\n // source's deprecated showTopBorder/showBottomBorder booleans, which are\n // deliberately not ported.\n border: {\n none: '',\n top: 'border-t border-(--main-nav-border)',\n bottom: 'border-b border-(--main-nav-border)',\n both: 'border-y border-(--main-nav-border)',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n border: 'none',\n },\n },\n)\n\nconst mainNavContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center',\n // Lateral padding funnels through --main-nav-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Same mechanism, and the same 16px → 24px → 48px rhythm, as\n // Masthead, Header and Footer.\n 'px-(--main-nav-padding-x)',\n '[--main-nav-padding-x:--spacing(4)] sm:[--main-nav-padding-x:--spacing(6)] lg:[--main-nav-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app fullBleed parity). --main-nav-max-width is\n // still read so a shell app can constrain the inner wrapper without\n // switching variants.\n fluid: 'max-w-[var(--main-nav-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--main-nav-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\n/**\n * Mega-panel accent ink, keyed by the same thirteen colour names as the bar.\n * The panel itself is always the house popup surface (`bg-popover`, white in\n * light mode) — parity with the app source, whose dropdown was white for\n * every variant — so the family only tints the featured lead link, hover ink\n * and cell borders. Declared on the Content element (not inherited from the\n * bar) because Base UI portals the panel to `document.body`: a custom\n * property set on the `<nav>` can never reach it.\n *\n * Light inks are the family's -800 step on white — grey-800 on white is\n * 15.1:1 and white on primary-800 is 14.4:1 (both AAA; contrast is symmetric,\n * ratios from header.tsx); accent-800 on white clears AAA per the Footer's\n * verified pairs. Dark inks step to the family's -200 — the same dark-mode\n * interactive ink link.tsx and navigation-menu.tsx already use on this\n * popover surface. The featured lead is text-xl bold, so even the softest\n * pair is far above the large-text AA floor (1.4.3, 3:1).\n */\nconst mainNavPanelVariants = cva(\n [\n 'p-0 whitespace-normal',\n // The sibling Content (and the shared popup, via popupClassName below)\n // cap themselves at --available-width, which Base UI measures from the\n // active trigger — for a mid-bar trigger that is less than the nav's\n // width, which would shrink right-hand panels. The panel's width is\n // container-measured and can never exceed the viewport, so the cap is\n // safely lifted.\n 'max-w-none',\n '[--main-nav-panel-border:color-mix(in_oklch,var(--main-nav-panel-ink)_15%,transparent)]',\n ],\n {\n variants: {\n color: {\n 'primary-800':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-600':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-400':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-200':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'grey-800':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-600':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-400':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-200':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'accent-800':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-600':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-400':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-200':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n white: '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n },\n },\n)\n\n// Re-points the sibling navigation-menu's ink at the bar's surface ink. The\n// trigger/link halos and focus outlines in navigation-menu.tsx all derive\n// from --nav-menu-ink via color-mix ON THE SAME ELEMENT, so overriding the\n// one token retargets the whole chain: hover/active halos and the\n// focus-visible outline become surface-relative, guaranteeing the indicator\n// contrasts on all thirteen surfaces (WCAG 2.2, 2.4.13 Focus Appearance).\n// Both light and dark are overridden because the sibling pins its own\n// dark-mode ink (primary-200); --main-nav-ink is already theme-aware.\nconst mainNavItemInk =\n '[--nav-menu-ink:var(--main-nav-ink)] dark:[--nav-menu-ink:var(--main-nav-ink)]'\n\n// Same re-point for links INSIDE the portalled panel, where the bar's ink\n// cannot reach — these derive from the panel accent ink instead.\nconst mainNavPanelInk =\n '[--nav-menu-ink:var(--main-nav-panel-ink)] dark:[--nav-menu-ink:var(--main-nav-panel-ink)]'\n\n// Restyles the sibling trigger to the app source's bar metrics: 56px min\n// height, square corners, bold base text, wider gutters from lg up. The open\n// panel is marked with the app's 4px inset underline (data-popup-open comes\n// from Base UI); data-current draws the same underline persistently when\n// `currentHref` falls inside this section, so the underline means \"you are\n// here\" at rest and \"this panel is open\" during use.\nconst mainNavTriggerClassName = [\n mainNavItemInk,\n 'mb-0 h-auto min-h-14 w-auto justify-start rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold text-(--main-nav-ink)',\n 'lg:px-8',\n '[&_svg]:size-6',\n // Inset focus ring: the sibling list is a horizontal scroll container, and\n // a scroll container clips everything drawn outside a child's border box —\n // the house outward `outline-offset-2` would simply vanish on the first and\n // last triggers. Same reasoning (and same fix) as push-menu.tsx's rows.\n 'focus-visible:-outline-offset-2',\n 'data-popup-open:shadow-[inset_0_-4px_0_0_currentColor]',\n 'data-current:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// A panel-less item, restyled from the sibling link to sit visually beside\n// the triggers (cn's conflict merge lets these win over the link's stacked\n// defaults). `active` → data-active draws the current-page underline; Base UI\n// pairs it with aria-current='page' on the same element (WCAG 2.4.8).\nconst mainNavTopLinkClassName = [\n mainNavItemInk,\n 'inline-flex min-h-14 flex-row items-center justify-start gap-1 rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold whitespace-nowrap text-(--main-nav-ink)',\n 'lg:px-8',\n // Inset for the same reason as the trigger above — these sit in the\n // scrolling list, not in a portalled panel.\n 'focus-visible:-outline-offset-2',\n 'data-active:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// The featured lead link at the top of a mega panel: the section title,\n// oversized, with an east arrow that nudges forward on hover (the app\n// source's exact affordance, on the house easing curve; the nudge is a\n// transition, so motion-reduce users get an instant state change — WCAG\n// 2.3.3). `group` scopes the icon's group-hover to this anchor — the panel is\n// portalled, so no other `group` ancestor can capture it.\nconst mainNavFeaturedLinkClassName = [\n mainNavPanelInk,\n 'group relative flex-row items-center rounded-none px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)',\n].join(' ')\n\n// The lead when the section has no `href`: the same visual weight as the\n// featured link, but a plain heading row — no anchor (a dead link announced\n// as a link fails the reader who activates it), no hover halo, and no east\n// arrow (an arrow on a non-link promises navigation that never happens). No\n// mainNavPanelInk re-point either: that chain only feeds interactive halos.\nconst mainNavFeaturedHeadingClassName =\n 'flex flex-row items-center px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)'\n\n// One bordered grid cell per section link. The anchor itself is the cell —\n// the app source wrapped a div around a stretched-link span, but making the\n// whole cell the anchor gives the same hit area with one element and no\n// aria-hidden overlay. Cells draw a top hairline from the panel ink; the last\n// grid row closes with a bottom hairline via the app's :nth-last-child(-n+3)\n// selector (tuned to the widest, 3-column layout — at narrower widths the\n// final one or two cells simply carry the closing rule, matching the app).\nconst mainNavSectionLinkClassName = [\n mainNavPanelInk,\n 'relative mx-2 justify-center rounded-none border-t border-(--main-nav-panel-border) p-4 text-base font-semibold whitespace-normal text-popover-foreground',\n 'hover:text-(--main-nav-panel-ink)',\n '[&:nth-last-child(-n+3)]:border-b',\n].join(' ')\n\n/** One link inside a mega panel. */\ntype MainNavLinkItem = {\n /** Visible link text, e.g. \"Find support near you\". */\n title: string\n href: string\n}\n\n/**\n * One top-level navigation item. With `links` it renders as a trigger opening\n * a mega panel (with `href` becoming the panel's featured lead link; without\n * an `href` the lead is a plain heading row — dev builds warn); without\n * `links` it renders as a plain link styled like the triggers. Recursion is\n * deliberately one level deep — mega panels list flat links, per the app\n * source's NavigationSection shape.\n */\ntype MainNavItem = {\n title: string\n href?: string\n links?: MainNavLinkItem[]\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: an item\n * with neither `href` nor `links` renders a dead `\"#\"` link — almost always a\n * data mistake, and a trap for keyboard and screen-reader users who activate\n * it and go nowhere. A section (`links`, no `href`) is legal but demoted —\n * its panel lead renders as a plain heading instead of the featured link —\n * so it gets its own nudge. No-op in production.\n */\nfunction warnIfItemUnlinked(item: MainNavItem) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!item.href && !item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav item \"${item.title}\" has no href and no links — it will render as a dead \"#\" link.`,\n )\n }\n if (!item.href && item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav section \"${item.title}\" has links but no href — its panel lead renders as a plain heading; pass href to make it a link.`,\n )\n }\n}\n\ntype MainNavMenuItemProps = {\n item: MainNavItem\n color: MainNavColor\n currentHref?: string\n /** Measured container width, forwarded as the panel's inline width. */\n panelWidth: number | null\n}\n\n/**\n * One bar entry: a plain link for items without `links`, a trigger + mega\n * panel for items with them. Internal — the data-driven `MainNav` API is the\n * public surface; compose the navigation-menu primitives directly for layouts\n * this doesn't cover.\n */\nfunction MainNavMenuItem({ item, color, currentHref, panelWidth }: MainNavMenuItemProps) {\n warnIfItemUnlinked(item)\n\n const links = item.links\n const isExactCurrent = item.href !== undefined && item.href === currentHref\n const isSectionCurrent =\n isExactCurrent ||\n (currentHref !== undefined && (links?.some((link) => link.href === currentHref) ?? false))\n\n if (!links?.length) {\n return (\n <NavigationMenuItem className='shrink-0'>\n <NavigationMenuLink\n data-slot='main-nav-top-link'\n href={item.href ?? '#'}\n active={isExactCurrent}\n className={mainNavTopLinkClassName}\n >\n {item.title}\n </NavigationMenuLink>\n </NavigationMenuItem>\n )\n }\n\n return (\n <NavigationMenuItem className='shrink-0'>\n {/* The trigger is a button (it discloses, it doesn't navigate), so it\n can't carry aria-current — data-current draws the visual \"you are\n here\" underline while the aria-current announcement lives on the\n exact matching link inside the panel. */}\n <NavigationMenuTrigger\n data-current={isSectionCurrent || undefined}\n className={mainNavTriggerClassName}\n >\n {item.title}\n </NavigationMenuTrigger>\n {/* Inline width (not a CSS var): the panel is portalled to\n document.body, so a custom property set on the nav can't reach it.\n Before the first measurement resolves the panel falls back to the\n sibling's natural w-max sizing. */}\n <NavigationMenuContent\n data-slot='main-nav-panel'\n className={mainNavPanelVariants({ color })}\n style={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <div className='grid w-full'>\n {/* No section href → no featured LINK: an `href=\"#\"` fallback here\n would be a dead link announced as a link. The heading row keeps\n the lead's visual weight without the anchor, halo or arrow — see\n mainNavFeaturedHeadingClassName. */}\n {item.href === undefined ? (\n <div data-slot='main-nav-featured-heading' className={mainNavFeaturedHeadingClassName}>\n {item.title}\n </div>\n ) : (\n <NavigationMenuLink\n data-slot='main-nav-featured-link'\n href={item.href}\n active={isExactCurrent}\n className={mainNavFeaturedLinkClassName}\n >\n {item.title}\n <IconEast\n aria-hidden='true'\n className='ml-4 size-6 shrink-0 text-current duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-1 motion-safe:transition-transform'\n />\n </NavigationMenuLink>\n )}\n <div\n data-slot='main-nav-panel-links'\n className='grid overflow-hidden px-4 pb-12 max-sm:grid-cols-1 sm:max-lg:grid-cols-2 lg:grid-cols-3'\n >\n {links.map((link, index) => (\n <NavigationMenuLink\n key={`${link.title}-${link.href}-${index}`}\n data-slot='main-nav-section-link'\n href={link.href}\n active={link.href === currentHref}\n className={mainNavSectionLinkClassName}\n >\n {link.title}\n </NavigationMenuLink>\n ))}\n </div>\n </div>\n </NavigationMenuContent>\n </NavigationMenuItem>\n )\n}\n\ntype MainNavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children'> &\n VariantProps<typeof mainNavVariants> &\n VariantProps<typeof mainNavContainerVariants> & {\n /** Top-level items; items with `links` open mega panels. */\n navigation: MainNavItem[]\n /**\n * The current page's href. The exact matching link gets\n * `aria-current=\"page\"`, and the top-level item it belongs to (a plain\n * link, or the trigger whose panel contains it) gets the current-item\n * underline. The app source read this from next/navigation's\n * `usePathname` — a framework API this package must not import; compare\n * in the consumer and pass the result down.\n */\n currentHref?: string\n /**\n * Stick to the top of the viewport as the page scrolls. Defaults to\n * `false`. When the nav renders below a sticky `Header`, set\n * `--main-nav-top` to the header's height so the two stack instead of\n * overlapping — this custom property replaces the app source's\n * `useSelectorHeight` DOM-measuring hook (the app measured `#nsw-header`\n * on every resize; a consumer that needs a live value can still measure\n * its own header and write the property, see the Sticky story).\n */\n sticky?: boolean\n /** Drop shadow under the bar. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n /**\n * Shown in the bar when `navigation` is empty. Defaults to\n * \"No navigation items available.\"; pass `null` to render an empty bar.\n *\n * An empty `navigation` array is a legitimate runtime state, not a data\n * mistake — a CMS with nothing published, a menu filtered down to nothing\n * by the reader's permissions, or a failed nav fetch all produce it. The\n * bar keeps its themed surface either way, so with no message it reads as\n * an unexplained coloured strip.\n */\n emptyMessage?: React.ReactNode\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Full-width NSW site navigation bar with mega-menu panels — the data-driven\n * consolidation of the nswds-app `NavigationMenuMainNavigation` /\n * `MainNavigation` components, rebuilt on this package's `NavigationMenu`\n * (Base UI underneath).\n *\n * - `navigation` drives everything: items with `links` render a trigger whose\n * mega panel shows a featured lead link (the section `href`; with no `href`\n * the lead demotes to a plain heading row — dev builds warn) above a\n * responsive 1/2/3-column grid of bordered section links; items without\n * `links` render plain links styled like the triggers. All anchors render\n * through `Link`, so a framework link injected via `LinkProvider`\n * (e.g. next/link) is used automatically.\n * - `color` themes the bar with the Footer's thirteen-name vocabulary and its\n * exact dark-mode deepening; every derived colour (halos, borders, focus\n * outlines) resolves from a single `--main-nav-ink` per variant. Contrast\n * conclusions are the Footer's, verbatim (see `mainNavColors`).\n * - Panels span the nav container's full width: a ResizeObserver on the inner\n * container feeds each panel's inline width, and an `alignOffset` function\n * shifts Base UI's trigger-anchored positioner back to the container's left\n * edge (measured at position time from the open trigger, so it is exact for\n * every trigger — this replaces the app source's panelMetrics state).\n * The offset is physical and correct in BOTH directions: Base UI passes\n * `align` to floating-ui as a physical placement and only mirrors a logical\n * `side`, so nothing about this anchoring flips under RTL. See the comment\n * on `alignOffset`, and the RightToLeft story that pins it.\n * - `container`, `border`, `shadow`, `sticky` mirror the house chrome\n * components; the app's deprecated `showTopBorder`/`showBottomBorder` and\n * `responsive` props are not ported (use `border` and\n * `className=\"hidden lg:block\"`).\n *\n * Accessibility: the outer `<nav>` is the landmark (default label \"Main\n * navigation\"; Base UI's own root is demoted to a `<div>` via `render` so the\n * page doesn't gain a nested nav landmark). Everything interactive is\n * inherited from Base UI via the sibling: triggers are real buttons with\n * `aria-expanded`/`aria-controls`, ArrowDown/Enter opens, arrow keys rove,\n * Escape and focus-out close, and the current page announces\n * `aria-current=\"page\"` (WCAG 2.4.8). Focus indicators are 2px ink-derived\n * outlines that contrast on all thirteen surfaces and on the panel surface\n * (2.4.7, 2.4.13). The 220ms `closeDelay` reproduces the app's hover-out\n * grace timer through Base UI instead of a hand-rolled setTimeout.\n *\n * The default `id=\"nsw-main-navigation\"` is kept for compatibility with\n * existing shells that target it (override via the `id` prop).\n */\nfunction MainNav({\n className,\n containerClassName,\n color,\n container,\n border,\n navigation,\n currentHref,\n sticky = false,\n shadow = true,\n emptyMessage = 'No navigation items available.',\n 'aria-label': ariaLabel = 'Main navigation',\n ref,\n ...props\n}: MainNavProps) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const [panelWidth, setPanelWidth] = React.useState<number | null>(null)\n\n React.useEffect(() => {\n const element = containerRef.current\n if (!element) {\n return\n }\n const measure = () => {\n setPanelWidth(element.getBoundingClientRect().width)\n }\n // Read once on mount: panels can open before the first resize.\n measure()\n const observer = new ResizeObserver(measure)\n observer.observe(element)\n return () => observer.disconnect()\n }, [])\n\n // Shifts the popup from Base UI's anchor (the open trigger) to the\n // container's left edge. Called by the positioner at position time, when\n // the open trigger is findable via data-popup-open — so the offset is exact\n // per trigger with no per-trigger state.\n //\n // PHYSICAL, and correct in both directions — this is deliberate, and the\n // opposite of what the comment here used to claim (\"Assumes LTR; RTL would\n // need the mirrored calculation\"). Base UI's useAnchorPositioning consults\n // the direction ONLY to map a logical `side` (`inline-start`/`inline-end`);\n // `align` is passed through to floating-ui as a physical placement, so\n // `side='bottom' align='start'` anchors the popup's LEFT edge to the\n // trigger's left in RTL exactly as in LTR, and `alignOffset` is applied on\n // floating-ui's physical cross axis. Nothing mirrors, so neither should this.\n //\n // Verified, not assumed: adding the mirror (trigger.right - container.right)\n // and rendering the bar under `dir='rtl'` WITH a DirectionProvider put the\n // panel at left=914 against a container at left=0 — the mirror moved an\n // already-left-anchored panel. The RightToLeft story pins the correct\n // geometry so a future Base UI release that starts mirroring `align` fails\n // here instead of in a consumer's RTL site.\n //\n // The ref caches the last successful offset for the windows when NO trigger\n // carries data-popup-open — chiefly the ~300ms close fade, when a recompute\n // (scroll/resize mid-fade) returning 0 would snap the still-visible\n // full-width panel back to the trigger's edge. Repeating the last real\n // offset holds the fading panel where it was.\n const lastAlignOffsetRef = React.useRef(0)\n const alignOffset = React.useCallback(() => {\n const element = containerRef.current\n if (!element) {\n return lastAlignOffsetRef.current\n }\n const trigger = element.querySelector('[data-popup-open]')\n if (!trigger) {\n return lastAlignOffsetRef.current\n }\n lastAlignOffsetRef.current =\n element.getBoundingClientRect().left - trigger.getBoundingClientRect().left\n return lastAlignOffsetRef.current\n }, [])\n\n return (\n <nav\n id='nsw-main-navigation'\n data-slot='main-nav'\n data-color={color ?? DEFAULT_MAIN_NAV_COLOR}\n aria-label={ariaLabel}\n {...props}\n className={cn(\n mainNavVariants({ color, border }),\n // z-40 matches Header (both sit below the z-50 SkipLinks). An app\n // stacking this under a sticky Header sets --main-nav-top to the\n // header's height.\n sticky && 'sticky top-[var(--main-nav-top,0px)] z-40',\n // House scrolled-header shadow; in dark mode borders carry separation.\n shadow && 'shadow-md shadow-black/5 dark:shadow-none',\n className,\n )}\n ref={ref}\n >\n <div\n ref={containerRef}\n data-slot='main-nav-container'\n className={cn(mainNavContainerVariants({ container }), containerClassName)}\n >\n {navigation.length === 0 ? (\n // No items: render the message directly rather than an empty\n // NavigationMenu, which would still mount the portal, positioner and\n // popup surface for a menubar that can never open.\n emptyMessage != null && (\n <p\n data-slot='main-nav-empty'\n className='flex min-h-14 items-center py-2 text-base leading-6 text-(--main-nav-ink)'\n >\n {emptyMessage}\n </p>\n )\n ) : (\n <>\n {/* render={<div/>}: Base UI's root is itself a <nav>; demoting it\n keeps this component to ONE navigation landmark. sideOffset 0\n seats the panel flush under the bar; collision handling is off\n because alignOffset/width already pin the panel inside the\n viewport. closeDelay 220 = the app's PANEL_CLOSE_DELAY_MS. */}\n <NavigationMenu\n render={<div />}\n className='w-full max-w-none justify-start'\n side='bottom'\n sideOffset={0}\n align='start'\n alignOffset={alignOffset}\n collisionPadding={0}\n collisionAvoidance={{ side: 'none', align: 'none' }}\n closeDelay={220}\n // Square corners (the full-width panel meets the bar edge-to-edge)\n // and no --available-width cap — see mainNavPanelVariants.\n popupClassName='max-w-none rounded-none'\n // The popup itself must follow the measured width too: Base UI\n // sizes it from --popup-width, measured once when a section\n // activates, so a panel opened before the first measurement lands\n // (or resized while open) would keep a stale popup width and clip\n // the full-width panel to a sliver. An inline width stays reactive.\n popupStyle={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <NavigationMenuList className='w-full justify-start gap-0 border-b-0'>\n {navigation.map((item) => (\n <MainNavMenuItem\n key={`${item.title}-${item.href ?? 'section'}`}\n item={item}\n color={color ?? DEFAULT_MAIN_NAV_COLOR}\n currentHref={currentHref}\n panelWidth={panelWidth}\n />\n ))}\n </NavigationMenuList>\n </NavigationMenu>\n </>\n )}\n </div>\n </nav>\n )\n}\n\nexport { MainNav, mainNavColors, mainNavContainerVariants, mainNavPanelVariants, mainNavVariants }\nexport type { MainNavColor, MainNavItem, MainNavLinkItem, MainNavProps }\n"]}
1
+ {"version":3,"sources":["../../src/components/main-nav.tsx"],"names":[],"mappings":";;;;;;;;AAqCA,MA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A,cACV,IAAA,EAAK,QAAA;AAAA,cACL,UAAA,EAAY,CAAA;AAAA,cACZ,KAAA,EAAM,OAAA;AAAA,cACN,WAAA;AAAA,cACA,gBAAA,EAAkB,CAAA;AAAA,cAClB,kBAAA,EAAoB,EAAE,IAAA,EAAM,MAAA,EAAQ,OAAO,MAAA,EAAO;AAAA,cAClD,UAAA,EAAY,GAAA;AAAA,cAGZ,cAAA,EAAe,yBAAA;AAAA,cAMf,YAAY,UAAA,KAAe,IAAA,GAAO,MAAA,GAAY,EAAE,OAAO,UAAA,EAAW;AAAA,cAElE,8BAAC,kBAAA,EAAA,EAAmB,SAAA,EAAU,yCAC3B,QAAA,EAAA,UAAA,CAAW,GAAA,CAAI,CAAC,IAAA,qBACf,GAAA;AAAA,gBAAC,eAAA;AAAA,gBAAA;AAAA,kBAEC,IAAA;AAAA,kBACA,KAAA,EAAO,QAAA;AAAA,kBACP,WAAA;AAAA,kBACA;AAAA,iBAAA;AAAA,gBAJK,GAAG,IAAA,CAAK,KAAK,CAAA,CAAA,EAAI,IAAA,CAAK,QAAQ,SAAS,CAAA;AAAA,eAM/C,CAAA,EACH;AAAA;AAAA,WACF,EACF;AAAA;AAAA;AAEJ;AAAA,GACF;AAEJ","file":"main-nav.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { IconEast } from '../icons/east.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nimport {\n NavigationMenu,\n NavigationMenuContent,\n NavigationMenuItem,\n NavigationMenuLink,\n NavigationMenuList,\n NavigationMenuTrigger,\n} from '../components/navigation-menu.js'\n\n/**\n * Surface colours the main navigation can be themed with — exactly the\n * Footer's thirteen-name vocabulary, so a service that themes its footer\n * `primary-800` writes the same word here. Each name is the LIGHT-mode\n * surface; dark mode deepens it onto the same family's dark steps (see the\n * `color` variants below), so `color` expresses tonal weight rather than a\n * literal colour.\n *\n * The bar's text/background pairs are identical to the Footer's, so its\n * contrast conclusions carry over verbatim: every light pair clears WCAG 2.2\n * AA (1.4.3, 4.5:1) for the bar's text and 11 of the 13 also clear AAA\n * (1.4.6, 7:1). The two AA-only pairs are `primary-600` (4.57:1) and\n * `accent-600` (5.18:1), both with white ink; prefer the `-800` steps when a\n * service is held to AAA. In dark mode all thirteen clear AAA (worst 13.6:1).\n *\n * The mega panels always render on the house popup surface (`bg-popover`),\n * matching the nswds-app source where every dropdown was white regardless of\n * bar colour — only the panel's accent ink follows the colour family.\n */\nconst mainNavColors = [\n 'primary-800',\n 'primary-600',\n 'primary-400',\n 'primary-200',\n 'grey-800',\n 'grey-600',\n 'grey-400',\n 'grey-200',\n 'accent-800',\n 'accent-600',\n 'accent-400',\n 'accent-200',\n 'white',\n] as const\n\ntype MainNavColor = (typeof mainNavColors)[number]\n\n// Shared by the bar's and the panel's cva defaultVariants and the\n// `resolveVariant` call in `MainNav`, so they can't drift apart.\nconst DEFAULT_MAIN_NAV_COLOR: MainNavColor = 'white'\n// Shared by cva's defaultVariants and the `resolveVariant` call in `MainNav`.\nconst DEFAULT_MAIN_NAV_CONTAINER = 'fluid'\n\nconst mainNavVariants = cva(\n [\n 'w-full',\n // Every derived colour on the bar resolves from a single --main-nav-ink\n // token, so a colour variant only has to declare the surface utilities and\n // that one value — this replaces the nswds-app source's hand-written\n // 13-variant × 8-slot style table. The border derivation is written\n // literally here (once) rather than per-variant: Tailwind scans source\n // text for class names, so a template-built arbitrary property would\n // never be emitted. Hover/active halos are not derived here — the\n // triggers ride navigation-menu.tsx's --nav-menu-halo chain, re-pointed\n // at this ink (see mainNavItemInk), so there is exactly one halo recipe.\n '[--main-nav-border:color-mix(in_oklch,var(--main-nav-ink)_15%,transparent)]',\n ],\n {\n variants: {\n // Ink values use the RAW masterbrand tokens (--primary-800, --grey-800,\n // --accent-800) rather than Tailwind's --color-* bridge aliases. Tailwind\n // v4 tree-shakes an unreferenced @theme key, and referencing one from\n // inside an arbitrary property is not a usage signal — the raw tokens are\n // plain :root declarations from @nswds/tokens and always resolve.\n // (--color-white is safe: `text-white` / `bg-white` below are real\n // utilities, so that key is always emitted.)\n //\n // Dark mode deepens every surface onto the same family's dark steps —\n // -800→-950, -600→-900, -400→-850, -200→-800, white→grey-900 — the\n // Footer's exact mapping, so the luminance ORDER within a family is\n // preserved and a stacked Footer + MainNav sharing one colour word stay\n // in step in both themes. Ink goes white on all thirteen; every dark\n // pair is WCAG 2.2 AAA (worst 13.6:1).\n color: {\n 'primary-800':\n 'bg-primary-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-950',\n 'primary-600':\n 'bg-primary-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-primary-900',\n 'primary-400':\n 'bg-primary-400 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'primary-200':\n 'bg-primary-200 text-primary-800 [--main-nav-ink:var(--primary-800)] dark:bg-primary-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-800': 'bg-grey-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-950',\n 'grey-600': 'bg-grey-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-grey-900',\n 'grey-400':\n 'bg-grey-400 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'grey-200':\n 'bg-grey-200 text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-800':\n 'bg-accent-800 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-950',\n 'accent-600':\n 'bg-accent-600 text-white [--main-nav-ink:var(--color-white)] dark:bg-accent-900',\n 'accent-400':\n 'bg-accent-400 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-850 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n 'accent-200':\n 'bg-accent-200 text-accent-800 [--main-nav-ink:var(--accent-800)] dark:bg-accent-800 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n white:\n 'bg-white text-grey-800 [--main-nav-ink:var(--grey-800)] dark:bg-grey-900 dark:text-white dark:[--main-nav-ink:var(--color-white)]',\n },\n // Rules along the bar's edges, drawn from the ink-derived border token so\n // they follow every colour variant and both themes. Replaces the app\n // source's deprecated showTopBorder/showBottomBorder booleans, which are\n // deliberately not ported.\n border: {\n none: '',\n top: 'border-t border-(--main-nav-border)',\n bottom: 'border-b border-(--main-nav-border)',\n both: 'border-y border-(--main-nav-border)',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n border: 'none',\n },\n },\n)\n\nconst mainNavContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center',\n // Lateral padding funnels through --main-nav-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Same mechanism, and the same 16px → 24px → 48px rhythm, as\n // Masthead, Header and Footer.\n 'px-(--main-nav-padding-x)',\n '[--main-nav-padding-x:--spacing(4)] sm:[--main-nav-padding-x:--spacing(6)] lg:[--main-nav-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app fullBleed parity). --main-nav-max-width is\n // still read so a shell app can constrain the inner wrapper without\n // switching variants.\n fluid: 'max-w-[var(--main-nav-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--main-nav-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: DEFAULT_MAIN_NAV_CONTAINER,\n },\n },\n)\n\n/**\n * Mega-panel accent ink, keyed by the same thirteen colour names as the bar.\n * The panel itself is always the house popup surface (`bg-popover`, white in\n * light mode) — parity with the app source, whose dropdown was white for\n * every variant — so the family only tints the featured lead link, hover ink\n * and cell borders. Declared on the Content element (not inherited from the\n * bar) because Base UI portals the panel to `document.body`: a custom\n * property set on the `<nav>` can never reach it.\n *\n * Light inks are the family's -800 step on white — grey-800 on white is\n * 15.1:1 and white on primary-800 is 14.4:1 (both AAA; contrast is symmetric,\n * ratios from header.tsx); accent-800 on white clears AAA per the Footer's\n * verified pairs. Dark inks step to the family's -200 — the same dark-mode\n * interactive ink link.tsx and navigation-menu.tsx already use on this\n * popover surface. The featured lead is text-xl bold, so even the softest\n * pair is far above the large-text AA floor (1.4.3, 3:1).\n */\nconst mainNavPanelVariants = cva(\n [\n 'p-0 whitespace-normal',\n // The sibling Content (and the shared popup, via popupClassName below)\n // cap themselves at --available-width, which Base UI measures from the\n // active trigger — for a mid-bar trigger that is less than the nav's\n // width, which would shrink right-hand panels. The panel's width is\n // container-measured and can never exceed the viewport, so the cap is\n // safely lifted.\n 'max-w-none',\n '[--main-nav-panel-border:color-mix(in_oklch,var(--main-nav-panel-ink)_15%,transparent)]',\n ],\n {\n variants: {\n color: {\n 'primary-800':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-600':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-400':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'primary-200':\n '[--main-nav-panel-ink:var(--primary-800)] dark:[--main-nav-panel-ink:var(--primary-200)]',\n 'grey-800':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-600':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-400':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'grey-200':\n '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n 'accent-800':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-600':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-400':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n 'accent-200':\n '[--main-nav-panel-ink:var(--accent-800)] dark:[--main-nav-panel-ink:var(--accent-200)]',\n white: '[--main-nav-panel-ink:var(--grey-800)] dark:[--main-nav-panel-ink:var(--grey-200)]',\n },\n },\n defaultVariants: {\n color: DEFAULT_MAIN_NAV_COLOR,\n },\n },\n)\n\n// Re-points the sibling navigation-menu's ink at the bar's surface ink. The\n// trigger/link halos and focus outlines in navigation-menu.tsx all derive\n// from --nav-menu-ink via color-mix ON THE SAME ELEMENT, so overriding the\n// one token retargets the whole chain: hover/active halos and the\n// focus-visible outline become surface-relative, guaranteeing the indicator\n// contrasts on all thirteen surfaces (WCAG 2.2, 2.4.13 Focus Appearance).\n// Both light and dark are overridden because the sibling pins its own\n// dark-mode ink (primary-200); --main-nav-ink is already theme-aware.\nconst mainNavItemInk =\n '[--nav-menu-ink:var(--main-nav-ink)] dark:[--nav-menu-ink:var(--main-nav-ink)]'\n\n// Same re-point for links INSIDE the portalled panel, where the bar's ink\n// cannot reach — these derive from the panel accent ink instead.\nconst mainNavPanelInk =\n '[--nav-menu-ink:var(--main-nav-panel-ink)] dark:[--nav-menu-ink:var(--main-nav-panel-ink)]'\n\n// Restyles the sibling trigger to the app source's bar metrics: 56px min\n// height, square corners, bold base text, wider gutters from lg up. The open\n// panel is marked with the app's 4px inset underline (data-popup-open comes\n// from Base UI); data-current draws the same underline persistently when\n// `currentHref` falls inside this section, so the underline means \"you are\n// here\" at rest and \"this panel is open\" during use.\nconst mainNavTriggerClassName = [\n mainNavItemInk,\n 'mb-0 h-auto min-h-14 w-auto justify-start rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold text-(--main-nav-ink)',\n 'lg:px-8',\n '[&_svg]:size-6',\n // Inset focus ring: the sibling list is a horizontal scroll container, and\n // a scroll container clips everything drawn outside a child's border box —\n // the house outward `outline-offset-2` would simply vanish on the first and\n // last triggers. Same reasoning (and same fix) as push-menu.tsx's rows.\n 'focus-visible:-outline-offset-2',\n 'data-popup-open:shadow-[inset_0_-4px_0_0_currentColor]',\n 'data-current:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// A panel-less item, restyled from the sibling link to sit visually beside\n// the triggers (cn's conflict merge lets these win over the link's stacked\n// defaults). `active` → data-active draws the current-page underline; Base UI\n// pairs it with aria-current='page' on the same element (WCAG 2.4.8).\nconst mainNavTopLinkClassName = [\n mainNavItemInk,\n 'inline-flex min-h-14 flex-row items-center justify-start gap-1 rounded-none max-lg:px-4 py-2 text-base leading-6 font-bold whitespace-nowrap text-(--main-nav-ink)',\n 'lg:px-8',\n // Inset for the same reason as the trigger above — these sit in the\n // scrolling list, not in a portalled panel.\n 'focus-visible:-outline-offset-2',\n 'data-active:shadow-[inset_0_-4px_0_0_currentColor]',\n].join(' ')\n\n// The featured lead link at the top of a mega panel: the section title,\n// oversized, with an east arrow that nudges forward on hover (the app\n// source's exact affordance, on the house easing curve; the nudge is a\n// transition, so motion-reduce users get an instant state change — WCAG\n// 2.3.3). `group` scopes the icon's group-hover to this anchor — the panel is\n// portalled, so no other `group` ancestor can capture it.\nconst mainNavFeaturedLinkClassName = [\n mainNavPanelInk,\n 'group relative flex-row items-center rounded-none px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)',\n].join(' ')\n\n// The lead when the section has no `href`: the same visual weight as the\n// featured link, but a plain heading row — no anchor (a dead link announced\n// as a link fails the reader who activates it), no hover halo, and no east\n// arrow (an arrow on a non-link promises navigation that never happens). No\n// mainNavPanelInk re-point either: that chain only feeds interactive halos.\nconst mainNavFeaturedHeadingClassName =\n 'flex flex-row items-center px-8 py-8 text-xl font-bold whitespace-normal text-(--main-nav-panel-ink)'\n\n// One bordered grid cell per section link. The anchor itself is the cell —\n// the app source wrapped a div around a stretched-link span, but making the\n// whole cell the anchor gives the same hit area with one element and no\n// aria-hidden overlay. Cells draw a top hairline from the panel ink; the last\n// grid row closes with a bottom hairline via the app's :nth-last-child(-n+3)\n// selector (tuned to the widest, 3-column layout — at narrower widths the\n// final one or two cells simply carry the closing rule, matching the app).\nconst mainNavSectionLinkClassName = [\n mainNavPanelInk,\n 'relative mx-2 justify-center rounded-none border-t border-(--main-nav-panel-border) p-4 text-base font-semibold whitespace-normal text-popover-foreground',\n 'hover:text-(--main-nav-panel-ink)',\n '[&:nth-last-child(-n+3)]:border-b',\n].join(' ')\n\n/** One link inside a mega panel. */\ntype MainNavLinkItem = {\n /** Visible link text, e.g. \"Find support near you\". */\n title: string\n href: string\n}\n\n/**\n * One top-level navigation item. With `links` it renders as a trigger opening\n * a mega panel (with `href` becoming the panel's featured lead link; without\n * an `href` the lead is a plain heading row — dev builds warn); without\n * `links` it renders as a plain link styled like the triggers. Recursion is\n * deliberately one level deep — mega panels list flat links, per the app\n * source's NavigationSection shape.\n */\ntype MainNavItem = {\n title: string\n href?: string\n links?: MainNavLinkItem[]\n}\n\n/**\n * Dev-only guard, mirroring the icon-only Button check in button.tsx: an item\n * with neither `href` nor `links` renders a dead `\"#\"` link — almost always a\n * data mistake, and a trap for keyboard and screen-reader users who activate\n * it and go nowhere. A section (`links`, no `href`) is legal but demoted —\n * its panel lead renders as a plain heading instead of the featured link —\n * so it gets its own nudge. No-op in production.\n */\nfunction warnIfItemUnlinked(item: MainNavItem) {\n if (process.env.NODE_ENV === 'production') {\n return\n }\n if (!item.href && !item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav item \"${item.title}\" has no href and no links — it will render as a dead \"#\" link.`,\n )\n }\n if (!item.href && item.links?.length) {\n console.warn(\n `[nswds/ui] MainNav section \"${item.title}\" has links but no href — its panel lead renders as a plain heading; pass href to make it a link.`,\n )\n }\n}\n\ntype MainNavMenuItemProps = {\n item: MainNavItem\n color: MainNavColor\n currentHref?: string\n /** Measured container width, forwarded as the panel's inline width. */\n panelWidth: number | null\n}\n\n/**\n * One bar entry: a plain link for items without `links`, a trigger + mega\n * panel for items with them. Internal — the data-driven `MainNav` API is the\n * public surface; compose the navigation-menu primitives directly for layouts\n * this doesn't cover.\n */\nfunction MainNavMenuItem({ item, color, currentHref, panelWidth }: MainNavMenuItemProps) {\n warnIfItemUnlinked(item)\n\n const links = item.links\n const isExactCurrent = item.href !== undefined && item.href === currentHref\n const isSectionCurrent =\n isExactCurrent ||\n (currentHref !== undefined && (links?.some((link) => link.href === currentHref) ?? false))\n\n if (!links?.length) {\n return (\n <NavigationMenuItem className='shrink-0'>\n <NavigationMenuLink\n data-slot='main-nav-top-link'\n href={item.href ?? '#'}\n active={isExactCurrent}\n className={mainNavTopLinkClassName}\n >\n {item.title}\n </NavigationMenuLink>\n </NavigationMenuItem>\n )\n }\n\n return (\n <NavigationMenuItem className='shrink-0'>\n {/* The trigger is a button (it discloses, it doesn't navigate), so it\n can't carry aria-current — data-current draws the visual \"you are\n here\" underline while the aria-current announcement lives on the\n exact matching link inside the panel. */}\n <NavigationMenuTrigger\n data-current={isSectionCurrent || undefined}\n className={mainNavTriggerClassName}\n >\n {item.title}\n </NavigationMenuTrigger>\n {/* Inline width (not a CSS var): the panel is portalled to\n document.body, so a custom property set on the nav can't reach it.\n Before the first measurement resolves the panel falls back to the\n sibling's natural w-max sizing. */}\n <NavigationMenuContent\n data-slot='main-nav-panel'\n className={mainNavPanelVariants({ color })}\n style={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <div className='grid w-full'>\n {/* No section href → no featured LINK: an `href=\"#\"` fallback here\n would be a dead link announced as a link. The heading row keeps\n the lead's visual weight without the anchor, halo or arrow — see\n mainNavFeaturedHeadingClassName. */}\n {item.href === undefined ? (\n <div data-slot='main-nav-featured-heading' className={mainNavFeaturedHeadingClassName}>\n {item.title}\n </div>\n ) : (\n <NavigationMenuLink\n data-slot='main-nav-featured-link'\n href={item.href}\n active={isExactCurrent}\n className={mainNavFeaturedLinkClassName}\n >\n {item.title}\n <IconEast\n aria-hidden='true'\n className='ml-4 size-6 shrink-0 text-current duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover:translate-x-1 motion-safe:transition-transform'\n />\n </NavigationMenuLink>\n )}\n <div\n data-slot='main-nav-panel-links'\n className='grid overflow-hidden px-4 pb-12 max-sm:grid-cols-1 sm:max-lg:grid-cols-2 lg:grid-cols-3'\n >\n {links.map((link, index) => (\n <NavigationMenuLink\n key={`${link.title}-${link.href}-${index}`}\n data-slot='main-nav-section-link'\n href={link.href}\n active={link.href === currentHref}\n className={mainNavSectionLinkClassName}\n >\n {link.title}\n </NavigationMenuLink>\n ))}\n </div>\n </div>\n </NavigationMenuContent>\n </NavigationMenuItem>\n )\n}\n\n// The native `color` attribute is omitted so the prop type admits the `null`\n// cva's `VariantProps` allows and the component resolves.\ntype MainNavProps = Omit<React.ComponentPropsWithoutRef<'nav'>, 'children' | 'color'> &\n VariantProps<typeof mainNavVariants> &\n VariantProps<typeof mainNavContainerVariants> & {\n /** Top-level items; items with `links` open mega panels. */\n navigation: MainNavItem[]\n /**\n * The current page's href. The exact matching link gets\n * `aria-current=\"page\"`, and the top-level item it belongs to (a plain\n * link, or the trigger whose panel contains it) gets the current-item\n * underline. The app source read this from next/navigation's\n * `usePathname` — a framework API this package must not import; compare\n * in the consumer and pass the result down.\n */\n currentHref?: string\n /**\n * Stick to the top of the viewport as the page scrolls. Defaults to\n * `false`. When the nav renders below a sticky `Header`, set\n * `--main-nav-top` to the header's height so the two stack instead of\n * overlapping — this custom property replaces the app source's\n * `useSelectorHeight` DOM-measuring hook (the app measured `#nsw-header`\n * on every resize; a consumer that needs a live value can still measure\n * its own header and write the property, see the Sticky story).\n */\n sticky?: boolean\n /** Drop shadow under the bar. Defaults to `true`. */\n shadow?: boolean\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n /**\n * Shown in the bar when `navigation` is empty. Defaults to\n * \"No navigation items available.\"; pass `null` to render an empty bar.\n *\n * An empty `navigation` array is a legitimate runtime state, not a data\n * mistake — a CMS with nothing published, a menu filtered down to nothing\n * by the reader's permissions, or a failed nav fetch all produce it. The\n * bar keeps its themed surface either way, so with no message it reads as\n * an unexplained coloured strip.\n */\n emptyMessage?: React.ReactNode\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Full-width NSW site navigation bar with mega-menu panels — the data-driven\n * consolidation of the nswds-app `NavigationMenuMainNavigation` /\n * `MainNavigation` components, rebuilt on this package's `NavigationMenu`\n * (Base UI underneath).\n *\n * - `navigation` drives everything: items with `links` render a trigger whose\n * mega panel shows a featured lead link (the section `href`; with no `href`\n * the lead demotes to a plain heading row — dev builds warn) above a\n * responsive 1/2/3-column grid of bordered section links; items without\n * `links` render plain links styled like the triggers. All anchors render\n * through `Link`, so a framework link injected via `LinkProvider`\n * (e.g. next/link) is used automatically.\n * - `color` themes the bar with the Footer's thirteen-name vocabulary and its\n * exact dark-mode deepening; every derived colour (halos, borders, focus\n * outlines) resolves from a single `--main-nav-ink` per variant. Contrast\n * conclusions are the Footer's, verbatim (see `mainNavColors`).\n * - Panels span the nav container's full width: a ResizeObserver on the inner\n * container feeds each panel's inline width, and an `alignOffset` function\n * shifts Base UI's trigger-anchored positioner back to the container's left\n * edge (measured at position time from the open trigger, so it is exact for\n * every trigger — this replaces the app source's panelMetrics state).\n * The offset is physical and correct in BOTH directions: Base UI passes\n * `align` to floating-ui as a physical placement and only mirrors a logical\n * `side`, so nothing about this anchoring flips under RTL. See the comment\n * on `alignOffset`, and the RightToLeft story that pins it.\n * - `container`, `border`, `shadow`, `sticky` mirror the house chrome\n * components; the app's deprecated `showTopBorder`/`showBottomBorder` and\n * `responsive` props are not ported (use `border` and\n * `className=\"hidden lg:block\"`).\n *\n * Accessibility: the outer `<nav>` is the landmark (default label \"Main\n * navigation\"; Base UI's own root is demoted to a `<div>` via `render` so the\n * page doesn't gain a nested nav landmark). Everything interactive is\n * inherited from Base UI via the sibling: triggers are real buttons with\n * `aria-expanded`/`aria-controls`, ArrowDown/Enter opens, arrow keys rove,\n * Escape and focus-out close, and the current page announces\n * `aria-current=\"page\"` (WCAG 2.4.8). Focus indicators are 2px ink-derived\n * outlines that contrast on all thirteen surfaces and on the panel surface\n * (2.4.7, 2.4.13). The 220ms `closeDelay` reproduces the app's hover-out\n * grace timer through Base UI instead of a hand-rolled setTimeout.\n *\n * The default `id=\"nsw-main-navigation\"` is kept for compatibility with\n * existing shells that target it (override via the `id` prop).\n */\nfunction MainNav({\n className,\n containerClassName,\n color,\n container,\n border,\n navigation,\n currentHref,\n sticky = false,\n shadow = true,\n emptyMessage = 'No navigation items available.',\n 'aria-label': ariaLabel = 'Main navigation',\n ref,\n ...props\n}: MainNavProps) {\n const containerRef = React.useRef<HTMLDivElement>(null)\n const [panelWidth, setPanelWidth] = React.useState<number | null>(null)\n\n React.useEffect(() => {\n const element = containerRef.current\n if (!element) {\n return\n }\n const measure = () => {\n setPanelWidth(element.getBoundingClientRect().width)\n }\n // Read once on mount: panels can open before the first resize.\n measure()\n const observer = new ResizeObserver(measure)\n observer.observe(element)\n return () => observer.disconnect()\n }, [])\n\n // Shifts the popup from Base UI's anchor (the open trigger) to the\n // container's left edge. Called by the positioner at position time, when\n // the open trigger is findable via data-popup-open — so the offset is exact\n // per trigger with no per-trigger state.\n //\n // PHYSICAL, and correct in both directions — this is deliberate, and the\n // opposite of what the comment here used to claim (\"Assumes LTR; RTL would\n // need the mirrored calculation\"). Base UI's useAnchorPositioning consults\n // the direction ONLY to map a logical `side` (`inline-start`/`inline-end`);\n // `align` is passed through to floating-ui as a physical placement, so\n // `side='bottom' align='start'` anchors the popup's LEFT edge to the\n // trigger's left in RTL exactly as in LTR, and `alignOffset` is applied on\n // floating-ui's physical cross axis. Nothing mirrors, so neither should this.\n //\n // Verified, not assumed: adding the mirror (trigger.right - container.right)\n // and rendering the bar under `dir='rtl'` WITH a DirectionProvider put the\n // panel at left=914 against a container at left=0 — the mirror moved an\n // already-left-anchored panel. The RightToLeft story pins the correct\n // geometry so a future Base UI release that starts mirroring `align` fails\n // here instead of in a consumer's RTL site.\n //\n // The ref caches the last successful offset for the windows when NO trigger\n // carries data-popup-open — chiefly the ~300ms close fade, when a recompute\n // (scroll/resize mid-fade) returning 0 would snap the still-visible\n // full-width panel back to the trigger's edge. Repeating the last real\n // offset holds the fading panel where it was.\n const lastAlignOffsetRef = React.useRef(0)\n const alignOffset = React.useCallback(() => {\n const element = containerRef.current\n if (!element) {\n return lastAlignOffsetRef.current\n }\n const trigger = element.querySelector('[data-popup-open]')\n if (!trigger) {\n return lastAlignOffsetRef.current\n }\n lastAlignOffsetRef.current =\n element.getBoundingClientRect().left - trigger.getBoundingClientRect().left\n return lastAlignOffsetRef.current\n }, [])\n\n // Resolved once (see `resolveVariant`), so cva, `data-color` and the panel\n // colourway agree for `null` and `''` as well as the default spelling, and\n // `container={null}` keeps the inner wrapper's max-width class, which reads\n // `--main-nav-max-width`, instead of dropping it.\n const colorway = resolveVariant(color, DEFAULT_MAIN_NAV_COLOR)\n const containerway = resolveVariant(container, DEFAULT_MAIN_NAV_CONTAINER)\n\n return (\n <nav\n id='nsw-main-navigation'\n data-slot='main-nav'\n aria-label={ariaLabel}\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-color={colorway}\n className={cn(\n mainNavVariants({ color: colorway, border }),\n // z-40 matches Header (both sit below the z-50 SkipLinks). An app\n // stacking this under a sticky Header sets --main-nav-top to the\n // header's height.\n sticky && 'sticky top-[var(--main-nav-top,0px)] z-40',\n // House scrolled-header shadow; in dark mode borders carry separation.\n shadow && 'shadow-md shadow-black/5 dark:shadow-none',\n className,\n )}\n ref={ref}\n >\n <div\n ref={containerRef}\n data-slot='main-nav-container'\n className={cn(mainNavContainerVariants({ container: containerway }), containerClassName)}\n >\n {navigation.length === 0 ? (\n // No items: render the message directly rather than an empty\n // NavigationMenu, which would still mount the portal, positioner and\n // popup surface for a menubar that can never open.\n emptyMessage != null && (\n <p\n data-slot='main-nav-empty'\n className='flex min-h-14 items-center py-2 text-base leading-6 text-(--main-nav-ink)'\n >\n {emptyMessage}\n </p>\n )\n ) : (\n <>\n {/* render={<div/>}: Base UI's root is itself a <nav>; demoting it\n keeps this component to ONE navigation landmark. sideOffset 0\n seats the panel flush under the bar; collision handling is off\n because alignOffset/width already pin the panel inside the\n viewport. closeDelay 220 = the app's PANEL_CLOSE_DELAY_MS. */}\n <NavigationMenu\n render={<div />}\n className='w-full max-w-none justify-start'\n side='bottom'\n sideOffset={0}\n align='start'\n alignOffset={alignOffset}\n collisionPadding={0}\n collisionAvoidance={{ side: 'none', align: 'none' }}\n closeDelay={220}\n // Square corners (the full-width panel meets the bar edge-to-edge)\n // and no --available-width cap — see mainNavPanelVariants.\n popupClassName='max-w-none rounded-none'\n // The popup itself must follow the measured width too: Base UI\n // sizes it from --popup-width, measured once when a section\n // activates, so a panel opened before the first measurement lands\n // (or resized while open) would keep a stale popup width and clip\n // the full-width panel to a sliver. An inline width stays reactive.\n popupStyle={panelWidth === null ? undefined : { width: panelWidth }}\n >\n <NavigationMenuList className='w-full justify-start gap-0 border-b-0'>\n {navigation.map((item) => (\n <MainNavMenuItem\n key={`${item.title}-${item.href ?? 'section'}`}\n item={item}\n color={colorway}\n currentHref={currentHref}\n panelWidth={panelWidth}\n />\n ))}\n </NavigationMenuList>\n </NavigationMenu>\n </>\n )}\n </div>\n </nav>\n )\n}\n\nexport { MainNav, mainNavColors, mainNavContainerVariants, mainNavPanelVariants, mainNavVariants }\nexport type { MainNavColor, MainNavItem, MainNavLinkItem, MainNavProps }\n"]}
@@ -15,7 +15,7 @@ declare const mastheadVariants: (props?: ({
15
15
  declare const mastheadContainerVariants: (props?: ({
16
16
  container?: "fluid" | "contained" | null | undefined;
17
17
  } & class_variance_authority_types.ClassProp) | undefined) => string;
18
- type MastheadProps = React__default.ComponentPropsWithoutRef<'div'> & VariantProps<typeof mastheadVariants> & VariantProps<typeof mastheadContainerVariants> & {
18
+ type MastheadProps = Omit<React__default.ComponentPropsWithoutRef<'div'>, 'color'> & VariantProps<typeof mastheadVariants> & VariantProps<typeof mastheadContainerVariants> & {
19
19
  /** Classes applied to the inner width-constraining wrapper. */
20
20
  containerClassName?: string;
21
21
  ref?: React__default.Ref<HTMLDivElement>;
@@ -1,5 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { cva } from 'class-variance-authority';
3
+ import { resolveVariant } from '../lib/resolve-variant.js';
3
4
  import { cn } from '../lib/utils.js';
4
5
 
5
6
  const mastheadColors = {
@@ -12,6 +13,7 @@ const mastheadColors = {
12
13
  grey: "bg-grey-800 text-white dark:bg-grey-950"
13
14
  };
14
15
  const DEFAULT_MASTHEAD_COLOR = "dark";
16
+ const DEFAULT_MASTHEAD_CONTAINER = "fluid";
15
17
  const mastheadVariants = cva("w-full text-xs", {
16
18
  variants: {
17
19
  color: mastheadColors
@@ -41,7 +43,7 @@ const mastheadContainerVariants = cva(
41
43
  }
42
44
  },
43
45
  defaultVariants: {
44
- container: "fluid"
46
+ container: DEFAULT_MASTHEAD_CONTAINER
45
47
  }
46
48
  }
47
49
  );
@@ -54,20 +56,22 @@ function Masthead({
54
56
  ref,
55
57
  ...props
56
58
  }) {
59
+ const colorway = resolveVariant(color, DEFAULT_MASTHEAD_COLOR);
60
+ const containerway = resolveVariant(container, DEFAULT_MASTHEAD_CONTAINER);
57
61
  return /* @__PURE__ */ jsx(
58
62
  "div",
59
63
  {
60
64
  id: "nsw-masthead",
61
65
  "data-slot": "masthead",
62
- "data-color": color ?? DEFAULT_MASTHEAD_COLOR,
63
66
  ...props,
64
- className: cn(mastheadVariants({ color }), className),
67
+ "data-color": colorway,
68
+ className: cn(mastheadVariants({ color: colorway }), className),
65
69
  ref,
66
70
  children: /* @__PURE__ */ jsx(
67
71
  "div",
68
72
  {
69
73
  "data-slot": "masthead-container",
70
- className: cn(mastheadContainerVariants({ container }), containerClassName),
74
+ className: cn(mastheadContainerVariants({ container: containerway }), containerClassName),
71
75
  children: children ?? "A NSW Government website"
72
76
  }
73
77
  )
@@ -1 +1 @@
1
- {"version":3,"sources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A;AAAA,QAAA;AAAA,UACC,WAAA,EAAU,oBAAA;AAAA,UACV,WAAW,EAAA,CAAG,yBAAA,CAA0B,EAAE,SAAA,EAAW,GAAG,kBAAkB,CAAA;AAAA,UAEzE,QAAA,EAAA,QAAA,IAAY;AAAA;AAAA;AACf;AAAA,GACF;AAEJ","file":"masthead.js","sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n// Colour pairs are curated for WCAG 2.2 AAA (1.4.6 Contrast Enhanced): every\n// text/background combination below resolves to at least 7:1, in BOTH themes.\n// This is why the Masthead does not accept the full Button colour palette —\n// accent/danger/warning backgrounds with white text sit under 7:1 and would\n// silently break the AAA guarantee. Add new colours only with a verified pair.\n//\n// Light mode: 14.4 (dark), 17.4 (light), 19.0 (white), 15.1 (grey).\n// Dark mode: 20.0 (dark), 17.2 (light), 19.0 (white), 20.2 (grey).\n//\n// Every variant deepens in dark mode, on the same ramp steps `Header` uses —\n// -100→-850, white→-900, -800→-950 — because the two are designed to be themed\n// together and sit flush against each other. Only `dark` used to flip: a\n// `white` masthead stayed pure white above a `grey-900` header, an 18.9:1 band\n// across the top of a dark page, and `light` did the same at 15.8:1. The\n// asymmetry was the tell that this was an omission rather than a policy — a\n// deliberately theme-invariant set would not have flipped one of its four.\nconst mastheadColors = {\n // Legacy .nsw-masthead (brand dark).\n dark: 'bg-primary-800 text-white dark:bg-primary-950',\n // Legacy .nsw-masthead--light (off-white). grey-100 is the same value as\n // the legacy --nsw-off-white (#f2f2f2).\n light: 'bg-grey-100 text-grey-900 dark:bg-grey-850 dark:text-white',\n white: 'bg-white text-grey-900 dark:bg-grey-900 dark:text-white',\n grey: 'bg-grey-800 text-white dark:bg-grey-950',\n}\n\ntype MastheadColor = keyof typeof mastheadColors\n\n// Shared by cva's defaultVariants and the data-color attribute, so the two\n// can't drift apart — the same arrangement as Header, Footer and MainNav.\nconst DEFAULT_MASTHEAD_COLOR: MastheadColor = 'dark'\n\nconst mastheadVariants = cva('w-full text-xs', {\n variants: {\n color: mastheadColors,\n },\n defaultVariants: {\n color: DEFAULT_MASTHEAD_COLOR,\n },\n})\n\nconst mastheadContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center justify-between gap-x-4 py-2',\n // Lateral padding funnels through --masthead-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Defaults reproduce the nswds-app rhythm: 16px → 24px → 48px.\n 'px-(--masthead-padding-x)',\n '[--masthead-padding-x:--spacing(4)] sm:[--masthead-padding-x:--spacing(6)] lg:[--masthead-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app style). --masthead-max-width is still read so\n // a shell app can constrain the inner wrapper without switching\n // variants (the archive/practice `#nsw-masthead > div` override).\n fluid: 'max-w-[var(--masthead-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--masthead-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\ntype MastheadProps = React.ComponentPropsWithoutRef<'div'> &\n VariantProps<typeof mastheadVariants> &\n VariantProps<typeof mastheadContainerVariants> & {\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The \"A NSW Government website\" strip shown above the site header on every\n * NSW Government page. Successor to the legacy `.nsw-masthead`.\n *\n * - `color` selects a WCAG 2.2 AAA text/background pair (`dark` matches the\n * legacy default, `light` matches the legacy `--light` theme).\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 `--masthead-max-width`\n * and `--masthead-padding-x` custom properties.\n * - Children replace the default message; pass a `SkipLinks` sibling before\n * the Masthead for bypass-blocks support.\n *\n * The default `id=\"nsw-masthead\"` is kept for compatibility with existing\n * shells that target it (override via the `id` prop).\n */\nfunction Masthead({\n className,\n color,\n container,\n containerClassName,\n children,\n ref,\n ...props\n}: MastheadProps) {\n return (\n <div\n id='nsw-masthead'\n data-slot='masthead'\n // Named surface, exposed for styling hooks and test diagnostics — the\n // convention Header, Footer and MainNav already follow.\n data-color={color ?? DEFAULT_MASTHEAD_COLOR}\n {...props}\n className={cn(mastheadVariants({ color }), className)}\n ref={ref}\n >\n <div\n data-slot='masthead-container'\n className={cn(mastheadContainerVariants({ container }), containerClassName)}\n >\n {children ?? 'A NSW Government website'}\n </div>\n </div>\n )\n}\n\nexport { Masthead, mastheadContainerVariants, mastheadVariants }\nexport type { MastheadColor, MastheadProps }\n"]}
1
+ {"version":3,"sources":["../../src/components/masthead.tsx"],"names":[],"mappings":";;;;;AAsBA,MAAM,cAAA,GAAiB;AAAA;AAAA,EAErB,IAAA,EAAM,+CAAA;AAAA;AAAA;AAAA,EAGN,KAAA,EAAO,4DAAA;AAAA,EACP,KAAA,EAAO,yDAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAMA,MAAM,sBAAA,GAAwC,MAAA;AAE9C,MAAM,0BAAA,GAA6B,OAAA;AAEnC,MAAM,gBAAA,GAAmB,IAAI,gBAAA,EAAkB;AAAA,EAC7C,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA,GACT;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,KAAA,EAAO;AAAA;AAEX,CAAC;AAED,MAAM,yBAAA,GAA4B,GAAA;AAAA,EAChC;AAAA,IACE,+DAAA;AAAA;AAAA;AAAA;AAAA,IAIA,2BAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,SAAA,EAAW;AAAA;AAAA;AAAA;AAAA,QAIT,KAAA,EAAO,wCAAA;AAAA;AAAA,QAEP,SAAA,EAAW;AAAA;AACb,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,SAAA,EAAW;AAAA;AACb;AAEJ;AA4BA,SAAS,QAAA,CAAS;AAAA,EAChB,SAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAkB;AAKhB,EAAA,MAAM,QAAA,GAAW,cAAA,CAAe,KAAA,EAAO,sBAAsB,CAAA;AAC7D,EAAA,MAAM,YAAA,GAAe,cAAA,CAAe,SAAA,EAAW,0BAA0B,CAAA;AACzE,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAG,cAAA;AAAA,MACH,WAAA,EAAU,UAAA;AAAA,MACT,GAAG,KAAA;AAAA,MAKJ,YAAA,EAAY,QAAA;AAAA,MACZ,SAAA,EAAW,GAAG,gBAAA,CAAiB,EAAE,OAAO,QAAA,EAAU,GAAG,SAAS,CAAA;AAAA,MAC9D,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,WAAA,EAAU,oBAAA;AAAA,UACV,SAAA,EAAW,GAAG,yBAAA,CAA0B,EAAE,WAAW,YAAA,EAAc,GAAG,kBAAkB,CAAA;AAAA,UAEvF,QAAA,EAAA,QAAA,IAAY;AAAA;AAAA;AACf;AAAA,GACF;AAEJ","file":"masthead.js","sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\n// Colour pairs are curated for WCAG 2.2 AAA (1.4.6 Contrast Enhanced): every\n// text/background combination below resolves to at least 7:1, in BOTH themes.\n// This is why the Masthead does not accept the full Button colour palette —\n// accent/danger/warning backgrounds with white text sit under 7:1 and would\n// silently break the AAA guarantee. Add new colours only with a verified pair.\n//\n// Light mode: 14.4 (dark), 17.4 (light), 19.0 (white), 15.1 (grey).\n// Dark mode: 20.0 (dark), 17.2 (light), 19.0 (white), 20.2 (grey).\n//\n// Every variant deepens in dark mode, on the same ramp steps `Header` uses —\n// -100→-850, white→-900, -800→-950 — because the two are designed to be themed\n// together and sit flush against each other. Only `dark` used to flip: a\n// `white` masthead stayed pure white above a `grey-900` header, an 18.9:1 band\n// across the top of a dark page, and `light` did the same at 15.8:1. The\n// asymmetry was the tell that this was an omission rather than a policy — a\n// deliberately theme-invariant set would not have flipped one of its four.\nconst mastheadColors = {\n // Legacy .nsw-masthead (brand dark).\n dark: 'bg-primary-800 text-white dark:bg-primary-950',\n // Legacy .nsw-masthead--light (off-white). grey-100 is the same value as\n // the legacy --nsw-off-white (#f2f2f2).\n light: 'bg-grey-100 text-grey-900 dark:bg-grey-850 dark:text-white',\n white: 'bg-white text-grey-900 dark:bg-grey-900 dark:text-white',\n grey: 'bg-grey-800 text-white dark:bg-grey-950',\n}\n\ntype MastheadColor = keyof typeof mastheadColors\n\n// Shared by cva's defaultVariants and the data-color attribute, so the two\n// can't drift apart — the same arrangement as Header, Footer and MainNav.\nconst DEFAULT_MASTHEAD_COLOR: MastheadColor = 'dark'\n// Shared by cva's defaultVariants and the `resolveVariant` call in `Masthead`.\nconst DEFAULT_MASTHEAD_CONTAINER = 'fluid'\n\nconst mastheadVariants = cva('w-full text-xs', {\n variants: {\n color: mastheadColors,\n },\n defaultVariants: {\n color: DEFAULT_MASTHEAD_COLOR,\n },\n})\n\nconst mastheadContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center justify-between gap-x-4 py-2',\n // Lateral padding funnels through --masthead-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Defaults reproduce the nswds-app rhythm: 16px → 24px → 48px.\n 'px-(--masthead-padding-x)',\n '[--masthead-padding-x:--spacing(4)] sm:[--masthead-padding-x:--spacing(6)] lg:[--masthead-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app style). --masthead-max-width is still read so\n // a shell app can constrain the inner wrapper without switching\n // variants (the archive/practice `#nsw-masthead > div` override).\n fluid: 'max-w-[var(--masthead-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--masthead-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: DEFAULT_MASTHEAD_CONTAINER,\n },\n },\n)\n\n// The native `color` attribute is omitted so the prop type admits the `null`\n// cva's `VariantProps` allows and the component resolves.\ntype MastheadProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'color'> &\n VariantProps<typeof mastheadVariants> &\n VariantProps<typeof mastheadContainerVariants> & {\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The \"A NSW Government website\" strip shown above the site header on every\n * NSW Government page. Successor to the legacy `.nsw-masthead`.\n *\n * - `color` selects a WCAG 2.2 AAA text/background pair (`dark` matches the\n * legacy default, `light` matches the legacy `--light` theme).\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 `--masthead-max-width`\n * and `--masthead-padding-x` custom properties.\n * - Children replace the default message; pass a `SkipLinks` sibling before\n * the Masthead for bypass-blocks support.\n *\n * The default `id=\"nsw-masthead\"` is kept for compatibility with existing\n * shells that target it (override via the `id` prop).\n */\nfunction Masthead({\n className,\n color,\n container,\n containerClassName,\n children,\n ref,\n ...props\n}: MastheadProps) {\n // Resolved once (see `resolveVariant`), so cva and `data-color` agree for\n // `null` and `''` as well as the default spelling, and\n // `container={null}` keeps the inner wrapper's max-width class, which reads\n // `--masthead-max-width`, instead of dropping it.\n const colorway = resolveVariant(color, DEFAULT_MASTHEAD_COLOR)\n const containerway = resolveVariant(container, DEFAULT_MASTHEAD_CONTAINER)\n return (\n <div\n id='nsw-masthead'\n data-slot='masthead'\n {...props}\n // Named surface, exposed for styling hooks and test diagnostics — the\n // convention Header, Footer and MainNav already follow. After the\n // spread, so a consumer's own `data-color` cannot desync it from the\n // classes both derive from the resolved value.\n data-color={colorway}\n className={cn(mastheadVariants({ color: colorway }), className)}\n ref={ref}\n >\n <div\n data-slot='masthead-container'\n className={cn(mastheadContainerVariants({ container: containerway }), containerClassName)}\n >\n {children ?? 'A NSW Government website'}\n </div>\n </div>\n )\n}\n\nexport { Masthead, mastheadContainerVariants, mastheadVariants }\nexport type { MastheadColor, MastheadProps }\n"]}