@nswds/ui 5.1.0 → 5.1.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.
@@ -6,7 +6,7 @@ import { Link } from './link.js';
6
6
 
7
7
  declare const badgeVariants: (props?: ({
8
8
  variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
9
- color?: "primary/grey" | "light" | "primary/white" | "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | null | undefined;
9
+ color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "primary/grey" | "light" | "primary/white" | null | undefined;
10
10
  size?: "default" | "sm" | "lg" | null | undefined;
11
11
  } & class_variance_authority_types.ClassProp) | undefined) => string;
12
12
  type BadgeProps = VariantProps<typeof badgeVariants> & React__default.ComponentPropsWithoutRef<'span'> & {
@@ -5,9 +5,9 @@ import React__default from 'react';
5
5
  import { Link } from './link.js';
6
6
 
7
7
  declare const buttonVariants: (props?: ({
8
- variant?: "solid" | "soft" | "surface" | "outline" | "link" | "ghost" | null | undefined;
9
- color?: "white" | "grey" | "primary" | "secondary" | "tertiary" | "accent" | "danger" | "success" | "warning" | null | undefined;
10
- size?: "default" | "sm" | "lg" | "icon" | null | undefined;
8
+ variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
9
+ color?: "primary" | "secondary" | "white" | "accent" | "grey" | "tertiary" | "danger" | "success" | "warning" | null | undefined;
10
+ size?: "default" | "sm" | "icon" | "lg" | null | undefined;
11
11
  iconOnly?: boolean | null | undefined;
12
12
  } & class_variance_authority_types.ClassProp) | undefined) => string;
13
13
  /**
@@ -30,7 +30,7 @@ declare const headerColors: {
30
30
  };
31
31
  type HeaderColor = keyof typeof headerColors;
32
32
  declare const headerVariants: (props?: ({
33
- color?: "light" | "white" | "grey" | "dark" | null | undefined;
33
+ color?: "white" | "grey" | "light" | "dark" | null | undefined;
34
34
  } & class_variance_authority_types.ClassProp) | undefined) => string;
35
35
  declare const headerContainerVariants: (props?: ({
36
36
  container?: "fluid" | "contained" | null | undefined;
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const linkVariants: (props?: ({
6
- variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
6
+ variant?: "primary" | "secondary" | "white" | "unstyled" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type LinkComponent = React__default.ElementType;
9
9
  /**
@@ -2,8 +2,15 @@ import * as class_variance_authority_types from 'class-variance-authority/types'
2
2
  import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
+ declare const mastheadColors: {
6
+ dark: string;
7
+ light: string;
8
+ white: string;
9
+ grey: string;
10
+ };
11
+ type MastheadColor = keyof typeof mastheadColors;
5
12
  declare const mastheadVariants: (props?: ({
6
- color?: "light" | "white" | "grey" | "dark" | null | undefined;
13
+ color?: "white" | "grey" | "light" | "dark" | null | undefined;
7
14
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
15
  declare const mastheadContainerVariants: (props?: ({
9
16
  container?: "fluid" | "contained" | null | undefined;
@@ -31,4 +38,4 @@ type MastheadProps = React__default.ComponentPropsWithoutRef<'div'> & VariantPro
31
38
  */
32
39
  declare function Masthead({ className, color, container, containerClassName, children, ref, ...props }: MastheadProps): React__default.JSX.Element;
33
40
 
34
- export { Masthead, type MastheadProps, mastheadContainerVariants, mastheadVariants };
41
+ export { Masthead, type MastheadColor, type MastheadProps, mastheadContainerVariants, mastheadVariants };
@@ -3,21 +3,21 @@ import { cva } from 'class-variance-authority';
3
3
  import { cn } from '../lib/utils.js';
4
4
 
5
5
  const mastheadColors = {
6
- // Legacy .nsw-masthead (brand dark). Deepens in dark mode, matching the
7
- // original nswds-app implementation.
6
+ // Legacy .nsw-masthead (brand dark).
8
7
  dark: "bg-primary-800 text-white dark:bg-primary-950",
9
8
  // Legacy .nsw-masthead--light (off-white). grey-100 is the same value as
10
9
  // the legacy --nsw-off-white (#f2f2f2).
11
- light: "bg-grey-100 text-grey-900",
12
- white: "bg-white text-grey-900",
13
- grey: "bg-grey-800 text-white"
10
+ light: "bg-grey-100 text-grey-900 dark:bg-grey-850 dark:text-white",
11
+ white: "bg-white text-grey-900 dark:bg-grey-900 dark:text-white",
12
+ grey: "bg-grey-800 text-white dark:bg-grey-950"
14
13
  };
14
+ const DEFAULT_MASTHEAD_COLOR = "dark";
15
15
  const mastheadVariants = cva("w-full text-xs", {
16
16
  variants: {
17
17
  color: mastheadColors
18
18
  },
19
19
  defaultVariants: {
20
- color: "dark"
20
+ color: DEFAULT_MASTHEAD_COLOR
21
21
  }
22
22
  });
23
23
  const mastheadContainerVariants = cva(
@@ -59,6 +59,7 @@ function Masthead({
59
59
  {
60
60
  id: "nsw-masthead",
61
61
  "data-slot": "masthead",
62
+ "data-color": color ?? DEFAULT_MASTHEAD_COLOR,
62
63
  ...props,
63
64
  className: cn(mastheadVariants({ color }), className),
64
65
  ref,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/masthead.tsx"],"names":[],"mappings":";;;;AAUA,MAAM,cAAA,GAAiB;AAAA;AAAA;AAAA,EAGrB,IAAA,EAAM,+CAAA;AAAA;AAAA;AAAA,EAGN,KAAA,EAAO,2BAAA;AAAA,EACP,KAAA,EAAO,wBAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAEA,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;AA0BA,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;AAChB,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAG,cAAA;AAAA,MACH,WAAA,EAAU,UAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,WAAW,EAAA,CAAG,gBAAA,CAAiB,EAAE,KAAA,EAAO,GAAG,SAAS,CAAA;AAAA,MACpD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;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. This is why the\n// Masthead does not accept the full Button colour palette — accent/danger/\n// warning backgrounds with white text sit under 7:1 and would silently break\n// the AAA guarantee. Add new colours only with a verified pair.\nconst mastheadColors = {\n // Legacy .nsw-masthead (brand dark). Deepens in dark mode, matching the\n // original nswds-app implementation.\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',\n white: 'bg-white text-grey-900',\n grey: 'bg-grey-800 text-white',\n}\n\nconst mastheadVariants = cva('w-full text-xs', {\n variants: {\n color: mastheadColors,\n },\n defaultVariants: {\n color: 'dark',\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 {...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 { MastheadProps }\n"]}
1
+ {"version":3,"sources":["../../src/components/masthead.tsx"],"names":[],"mappings":";;;;AAqBA,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,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;AA0BA,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;AAChB,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAG,cAAA;AAAA,MACH,WAAA,EAAU,UAAA;AAAA,MAGV,cAAY,KAAA,IAAS,sBAAA;AAAA,MACpB,GAAG,KAAA;AAAA,MACJ,WAAW,EAAA,CAAG,gBAAA,CAAiB,EAAE,KAAA,EAAO,GAAG,SAAS,CAAA;AAAA,MACpD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;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"]}
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const skipLinkVariants: (props?: ({
6
- color?: "light" | "white" | "grey" | "dark" | null | undefined;
6
+ color?: "white" | "grey" | "light" | "dark" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type SkipLinkProps = React__default.ComponentPropsWithoutRef<'a'> & VariantProps<typeof skipLinkVariants> & {
9
9
  /** Same-page fragment target, e.g. `"#content"`. */
@@ -5,9 +5,9 @@ import { cn } from '../lib/utils.js';
5
5
 
6
6
  const skipLinkColors = {
7
7
  dark: "bg-primary-800 text-white dark:bg-primary-950",
8
- light: "bg-grey-100 text-grey-900",
9
- white: "bg-white text-grey-900",
10
- grey: "bg-grey-800 text-white"
8
+ light: "bg-grey-100 text-grey-900 dark:bg-grey-850 dark:text-white",
9
+ white: "bg-white text-grey-900 dark:bg-grey-900 dark:text-white",
10
+ grey: "bg-grey-800 text-white dark:bg-grey-950"
11
11
  };
12
12
  const skipLinkVariants = cva(
13
13
  [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/skip-link.tsx"],"names":[],"mappings":";;;;AAYA,MAAM,cAAA,GAAiB;AAAA,EACrB,IAAA,EAAM,+CAAA;AAAA,EACN,KAAA,EAAO,2BAAA;AAAA,EACP,KAAA,EAAO,wBAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAEA,MAAM,gBAAA,GAAmB,GAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,IAIE,qDAAA;AAAA,IACA,kCAAA;AAAA,IACA,qBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQA,+EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,KAAA,EAAO;AAAA,KACT;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,KAAA,EAAO;AAAA;AACT;AAEJ;AAQA,SAAS,gBAAgB,KAAA,EAA4C;AACnE,EAAA,MAAM,IAAA,GAAO,MAAM,aAAA,CAAc,IAAA;AACjC,EAAA,IAAI,CAAC,IAAA,IAAQ,IAAA,KAAS,GAAA,EAAK;AACzB,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,EAAA,GAAK,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AACrB,EAAA,IAAI;AACF,IAAA,EAAA,GAAK,mBAAmB,EAAE,CAAA;AAAA,EAC5B,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,cAAA,CAAe,EAAE,CAAA;AACzC,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,OAAO,QAAA,GAAW,CAAA,IAAK,CAAC,MA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C,QAAA,EAAA,EAAS,KAAA,EAAc,IAAA,EAAK,YAAW,QAAA,EAAA,iBAAA,EAExC;AAAA,GAAA,EACF,CAAA;AAAA,EAEF,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAmB;AACjB,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,YAAA,EAAW,YAAA;AAAA,MACX,WAAA,EAAU,YAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,mCAAA,EAAqC,SAAS,CAAA;AAAA,MAC5D,GAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"skip-link.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n// Same curated WCAG 2.2 AAA (7:1) pairs as the Masthead — the two components\n// are designed to be themed together, mirroring how the legacy\n// `masthead-theme` option drove both `.nsw-masthead--light` and\n// `.nsw-skip--light`. Kept as a local map (not imported from masthead.tsx) so\n// each file stays standalone for registry distribution.\nconst skipLinkColors = {\n dark: 'bg-primary-800 text-white dark:bg-primary-950',\n light: 'bg-grey-100 text-grey-900',\n white: 'bg-white text-grey-900',\n grey: 'bg-grey-800 text-white',\n}\n\nconst skipLinkVariants = cva(\n [\n // Parked above the viewport until focused (legacy translateY(-101%)\n // pattern) — still in the tab order, so it is the first thing keyboard\n // and screen-reader users reach.\n 'absolute inset-x-0 top-0 w-full -translate-y-[101%]',\n 'motion-safe:transition-transform',\n 'focus:translate-y-0',\n // min-h-11 keeps the revealed bar at ≥44px — 2.5.5 Target Size (AAA).\n //\n // text-base, not the legacy text-xs: this is the first thing a keyboard or\n // screen-magnifier user meets on the page, and 12px is below the smallest\n // step DESIGN.md names for running copy. font-medium keeps it in the\n // system's label voice. The bar is min-h-11, and 16px text on py-2 comes\n // to 40px, so the floor still governs the height — nothing moves.\n 'group flex min-h-11 items-center px-4 py-2 text-base font-medium no-underline',\n // The visible focus indicator is the ring around the label span\n // (2.4.13 Focus Appearance): outline-current guarantees it contrasts with\n // the bar on every colour variant. outline-hidden (not outline-none) on\n // the anchor keeps a forced-colors fallback outline.\n 'focus:outline-hidden',\n ],\n {\n variants: {\n color: skipLinkColors,\n },\n defaultVariants: {\n color: 'dark',\n },\n },\n)\n\n/**\n * Move focus to the skip target. Fragment navigation alone only moves the\n * sequential-focus starting point; explicitly focusing the target makes\n * screen readers announce it. Non-focusable targets get a temporary\n * `tabindex=\"-1\"` (removed on blur), matching the legacy skip-to behaviour.\n */\nfunction focusSkipTarget(event: React.MouseEvent<HTMLAnchorElement>) {\n const hash = event.currentTarget.hash\n if (!hash || hash === '#') {\n return\n }\n\n let id = hash.slice(1)\n try {\n id = decodeURIComponent(id)\n } catch {\n // Malformed escape sequence — fall back to the raw fragment.\n }\n\n const target = document.getElementById(id)\n if (!target) {\n return\n }\n\n if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) {\n target.setAttribute('tabindex', '-1')\n target.addEventListener(\n 'blur',\n () => {\n target.removeAttribute('tabindex')\n },\n { once: true },\n )\n }\n\n target.focus()\n}\n\ntype SkipLinkProps = React.ComponentPropsWithoutRef<'a'> &\n VariantProps<typeof skipLinkVariants> & {\n /** Same-page fragment target, e.g. `\"#content\"`. */\n href: string\n ref?: React.Ref<HTMLAnchorElement>\n }\n\n/**\n * A single focus-revealed bypass link (2.4.1 Bypass Blocks). Hidden above the\n * viewport until it receives keyboard focus, then slides in as a full-width\n * bar. Designed to sit inside `SkipLinks`, which provides the positioned\n * `<nav>` landmark; standalone use needs a positioned ancestor.\n *\n * Renders a plain `<a>` (not the themeable `Link`) because skip links are\n * same-page fragment jumps — routing framework link components are\n * unnecessary and can interfere with fragment navigation.\n */\nfunction SkipLink({ className, color, href, onClick, children, ref, ...props }: SkipLinkProps) {\n return (\n <a\n data-slot='skip-link'\n {...props}\n href={href}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n focusSkipTarget(event)\n }\n }}\n className={cn(skipLinkVariants({ color }), className)}\n ref={ref}\n >\n <span className='group-focus:outline group-focus:outline-2 group-focus:outline-offset-2 group-focus:outline-current'>\n {children}\n </span>\n </a>\n )\n}\n\ntype SkipLinksProps = React.ComponentPropsWithoutRef<'nav'> &\n VariantProps<typeof skipLinkVariants> & {\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Fixed landmark that holds the page's skip links, rendered as the first\n * element in the body (before the `Masthead`). Successor to the legacy\n * `.nsw-skip` nav.\n *\n * When the `children` prop is omitted it renders the legacy default pair —\n * \"Skip to navigation\" (`#nav`) and \"Skip to content\" (`#content`) — themed\n * by `color`. Any provided children (including an explicitly empty list from\n * a `.map()` or a false conditional) render exactly as given, per normal\n * React semantics — the defaults are never injected alongside or instead of\n * explicit content, since their `#nav`/`#content` targets may not exist on a\n * page that opted into custom links. Compose your own `SkipLink` children\n * for different targets or extra links:\n *\n * ```tsx\n * <SkipLinks>\n * <SkipLink href=\"#main-navigation\">Skip to navigation</SkipLink>\n * <SkipLink href=\"#main-content\">Skip to content</SkipLink>\n * <SkipLink href=\"#search\">Skip to search</SkipLink>\n * </SkipLinks>\n * ```\n */\nfunction SkipLinks({\n className,\n color,\n // Destructuring default: applies only when the prop is `undefined`\n // (omitted), never for explicit null/false/[] children. `color` is\n // initialised earlier in the pattern, so it is in scope here.\n children = (\n <>\n <SkipLink color={color} href='#nav'>\n Skip to navigation\n </SkipLink>\n <SkipLink color={color} href='#content'>\n Skip to content\n </SkipLink>\n </>\n ),\n ref,\n ...props\n}: SkipLinksProps) {\n return (\n <nav\n aria-label='Skip links'\n data-slot='skip-links'\n {...props}\n className={cn('fixed inset-x-0 top-0 z-50 w-full', className)}\n ref={ref}\n >\n {children}\n </nav>\n )\n}\n\nexport { SkipLink, SkipLinks, skipLinkVariants }\nexport type { SkipLinkProps, SkipLinksProps }\n"]}
1
+ {"version":3,"sources":["../../src/components/skip-link.tsx"],"names":[],"mappings":";;;;AAmBA,MAA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AA,MACC,YAAA,EAAW,YAAA;AAAA,MACX,WAAA,EAAU,YAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,SAAA,EAAW,EAAA,CAAG,mCAAA,EAAqC,SAAS,CAAA;AAAA,MAC5D,GAAA;AAAA,MAEC;AAAA;AAAA,GACH;AAEJ","file":"skip-link.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n// Same curated WCAG 2.2 AAA (7:1) pairs as the Masthead, in both themes — the\n// two components are designed to be themed together, mirroring how the legacy\n// `masthead-theme` option drove both `.nsw-masthead--light` and\n// `.nsw-skip--light`. Kept as a local map (not imported from masthead.tsx) so\n// each file stays standalone for registry distribution; the duplication is the\n// cost of that, so a change here belongs in masthead.tsx too.\n//\n// The dark-mode steps match Masthead's exactly (-100→-850, white→-900,\n// -800→-950). Previously only `dark` flipped, so a revealed `white` skip link\n// was a pure-white bar on a dark page — worse here than on the Masthead,\n// because this bar appears without warning at the moment a keyboard user takes\n// focus, rather than sitting statically at the top of the page.\nconst skipLinkColors = {\n dark: 'bg-primary-800 text-white dark:bg-primary-950',\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\nconst skipLinkVariants = cva(\n [\n // Parked above the viewport until focused (legacy translateY(-101%)\n // pattern) — still in the tab order, so it is the first thing keyboard\n // and screen-reader users reach.\n 'absolute inset-x-0 top-0 w-full -translate-y-[101%]',\n 'motion-safe:transition-transform',\n 'focus:translate-y-0',\n // min-h-11 keeps the revealed bar at ≥44px — 2.5.5 Target Size (AAA).\n //\n // text-base, not the legacy text-xs: this is the first thing a keyboard or\n // screen-magnifier user meets on the page, and 12px is below the smallest\n // step DESIGN.md names for running copy. font-medium keeps it in the\n // system's label voice. The bar is min-h-11, and 16px text on py-2 comes\n // to 40px, so the floor still governs the height — nothing moves.\n 'group flex min-h-11 items-center px-4 py-2 text-base font-medium no-underline',\n // The visible focus indicator is the ring around the label span\n // (2.4.13 Focus Appearance): outline-current guarantees it contrasts with\n // the bar on every colour variant. outline-hidden (not outline-none) on\n // the anchor keeps a forced-colors fallback outline.\n 'focus:outline-hidden',\n ],\n {\n variants: {\n color: skipLinkColors,\n },\n defaultVariants: {\n color: 'dark',\n },\n },\n)\n\n/**\n * Move focus to the skip target. Fragment navigation alone only moves the\n * sequential-focus starting point; explicitly focusing the target makes\n * screen readers announce it. Non-focusable targets get a temporary\n * `tabindex=\"-1\"` (removed on blur), matching the legacy skip-to behaviour.\n */\nfunction focusSkipTarget(event: React.MouseEvent<HTMLAnchorElement>) {\n const hash = event.currentTarget.hash\n if (!hash || hash === '#') {\n return\n }\n\n let id = hash.slice(1)\n try {\n id = decodeURIComponent(id)\n } catch {\n // Malformed escape sequence — fall back to the raw fragment.\n }\n\n const target = document.getElementById(id)\n if (!target) {\n return\n }\n\n if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) {\n target.setAttribute('tabindex', '-1')\n target.addEventListener(\n 'blur',\n () => {\n target.removeAttribute('tabindex')\n },\n { once: true },\n )\n }\n\n target.focus()\n}\n\ntype SkipLinkProps = React.ComponentPropsWithoutRef<'a'> &\n VariantProps<typeof skipLinkVariants> & {\n /** Same-page fragment target, e.g. `\"#content\"`. */\n href: string\n ref?: React.Ref<HTMLAnchorElement>\n }\n\n/**\n * A single focus-revealed bypass link (2.4.1 Bypass Blocks). Hidden above the\n * viewport until it receives keyboard focus, then slides in as a full-width\n * bar. Designed to sit inside `SkipLinks`, which provides the positioned\n * `<nav>` landmark; standalone use needs a positioned ancestor.\n *\n * Renders a plain `<a>` (not the themeable `Link`) because skip links are\n * same-page fragment jumps — routing framework link components are\n * unnecessary and can interfere with fragment navigation.\n */\nfunction SkipLink({ className, color, href, onClick, children, ref, ...props }: SkipLinkProps) {\n return (\n <a\n data-slot='skip-link'\n {...props}\n href={href}\n onClick={(event) => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n focusSkipTarget(event)\n }\n }}\n className={cn(skipLinkVariants({ color }), className)}\n ref={ref}\n >\n <span className='group-focus:outline group-focus:outline-2 group-focus:outline-offset-2 group-focus:outline-current'>\n {children}\n </span>\n </a>\n )\n}\n\ntype SkipLinksProps = React.ComponentPropsWithoutRef<'nav'> &\n VariantProps<typeof skipLinkVariants> & {\n ref?: React.Ref<HTMLElement>\n }\n\n/**\n * Fixed landmark that holds the page's skip links, rendered as the first\n * element in the body (before the `Masthead`). Successor to the legacy\n * `.nsw-skip` nav.\n *\n * When the `children` prop is omitted it renders the legacy default pair —\n * \"Skip to navigation\" (`#nav`) and \"Skip to content\" (`#content`) — themed\n * by `color`. Any provided children (including an explicitly empty list from\n * a `.map()` or a false conditional) render exactly as given, per normal\n * React semantics — the defaults are never injected alongside or instead of\n * explicit content, since their `#nav`/`#content` targets may not exist on a\n * page that opted into custom links. Compose your own `SkipLink` children\n * for different targets or extra links:\n *\n * ```tsx\n * <SkipLinks>\n * <SkipLink href=\"#main-navigation\">Skip to navigation</SkipLink>\n * <SkipLink href=\"#main-content\">Skip to content</SkipLink>\n * <SkipLink href=\"#search\">Skip to search</SkipLink>\n * </SkipLinks>\n * ```\n */\nfunction SkipLinks({\n className,\n color,\n // Destructuring default: applies only when the prop is `undefined`\n // (omitted), never for explicit null/false/[] children. `color` is\n // initialised earlier in the pattern, so it is in scope here.\n children = (\n <>\n <SkipLink color={color} href='#nav'>\n Skip to navigation\n </SkipLink>\n <SkipLink color={color} href='#content'>\n Skip to content\n </SkipLink>\n </>\n ),\n ref,\n ...props\n}: SkipLinksProps) {\n return (\n <nav\n aria-label='Skip links'\n data-slot='skip-links'\n {...props}\n className={cn('fixed inset-x-0 top-0 z-50 w-full', className)}\n ref={ref}\n >\n {children}\n </nav>\n )\n}\n\nexport { SkipLink, SkipLinks, skipLinkVariants }\nexport type { SkipLinkProps, SkipLinksProps }\n"]}
package/dist/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export { LabeledSeparator, LabeledSeparatorProps } from './components/labeled-se
15
15
  export { ExternalLink, ExternalLinkProps, Link, LinkComponent, LinkProps, LinkProvider, LinkUrlObject, linkVariants } from './components/link.js';
16
16
  export { Logo, LogoProps } from './components/logo.js';
17
17
  export { MainNav, MainNavColor, MainNavItem, MainNavLinkItem, MainNavProps, mainNavColors, mainNavContainerVariants, mainNavPanelVariants, mainNavVariants } from './components/main-nav.js';
18
- export { Masthead, MastheadProps, mastheadContainerVariants, mastheadVariants } from './components/masthead.js';
18
+ export { Masthead, MastheadColor, MastheadProps, mastheadContainerVariants, mastheadVariants } from './components/masthead.js';
19
19
  export { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger } from './components/popover.js';
20
20
  export { PUSH_MENU_DURATION_MS, PushMenu, PushMenuItem, PushMenuLevel, PushMenuProps, generatePushMenuBreadcrumb } from './components/push-menu.js';
21
21
  export { ResizableHandle, ResizablePanel, ResizablePanelGroup } from './components/resizable.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nswds/ui",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "UI components for NSW Government digital products, providing reusable design elements and patterns for consistent user interfaces.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/digitalnsw/nswds-ui#readme",