@nswds/ui 5.0.6 → 5.0.7

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
  /**
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const mastheadVariants: (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
  declare const mastheadContainerVariants: (props?: ({
9
9
  container?: "fluid" | "contained" | null | undefined;
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import React__default from 'react';
4
4
 
5
5
  declare const skipLinkVariants: (props?: ({
6
- color?: "light" | "white" | "grey" | "dark" | null | undefined;
6
+ color?: "white" | "grey" | "light" | "dark" | null | undefined;
7
7
  } & class_variance_authority_types.ClassProp) | undefined) => string;
8
8
  type SkipLinkProps = React__default.ComponentPropsWithoutRef<'a'> & VariantProps<typeof skipLinkVariants> & {
9
9
  /** Same-page fragment target, e.g. `"#content"`. */
@@ -1,6 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { ToasterProps } from 'sonner';
3
3
 
4
- declare const Toaster: ({ ...props }: ToasterProps) => React.JSX.Element;
4
+ /**
5
+ * Toast host. Mount once, near the root.
6
+ *
7
+ * Every prop this component sets a default for is MERGED with the consumer's
8
+ * value rather than replaced. Spreading `{...props}` last — the shadcn default
9
+ * this was scaffolded from — meant a consumer passing `style` for something
10
+ * unrelated (a z-index, an offset) silently discarded the whole token bridge
11
+ * above, and passing one `icons` entry discarded the other four. Object spread
12
+ * replaces keys wholesale; it does not deep-merge.
13
+ */
14
+ declare const Toaster: ({ className, style, icons, toastOptions, ...props }: ToasterProps) => React.JSX.Element;
5
15
 
6
16
  export { Toaster };
@@ -7,30 +7,35 @@ import { IconCheckCircle } from '../icons/check-circle.js';
7
7
  import { IconError } from '../icons/error.js';
8
8
  import { IconInfo } from '../icons/info.js';
9
9
  import { IconWarning } from '../icons/warning.js';
10
+ import { cn } from '../lib/utils.js';
10
11
 
11
- const Toaster = ({ ...props }) => {
12
+ const tokenBridge = {
13
+ "--normal-bg": "var(--popover)",
14
+ "--normal-text": "var(--popover-foreground)",
15
+ "--normal-border": "var(--border)",
16
+ "--border-radius": "var(--radius)"
17
+ };
18
+ const Toaster = ({ className, style, icons, toastOptions, ...props }) => {
12
19
  const { theme = "system" } = useTheme();
13
20
  return /* @__PURE__ */ jsx(
14
21
  Toaster$1,
15
22
  {
16
23
  theme,
17
- className: "toaster group",
24
+ className: cn("toaster group", className),
18
25
  icons: {
19
26
  success: /* @__PURE__ */ jsx(IconCheckCircle, { className: "size-4" }),
20
27
  info: /* @__PURE__ */ jsx(IconInfo, { className: "size-4" }),
21
28
  warning: /* @__PURE__ */ jsx(IconWarning, { className: "size-4" }),
22
29
  error: /* @__PURE__ */ jsx(IconError, { className: "size-4" }),
23
- loading: /* @__PURE__ */ jsx(Spinner, { size: "sm", color: "current", label: "" })
24
- },
25
- style: {
26
- "--normal-bg": "var(--popover)",
27
- "--normal-text": "var(--popover-foreground)",
28
- "--normal-border": "var(--border)",
29
- "--border-radius": "var(--radius)"
30
+ loading: /* @__PURE__ */ jsx(Spinner, { size: "sm", color: "current", label: "" }),
31
+ ...icons
30
32
  },
33
+ style: { ...tokenBridge, ...style },
31
34
  toastOptions: {
35
+ ...toastOptions,
32
36
  classNames: {
33
- toast: "cn-toast"
37
+ toast: "cn-toast",
38
+ ...toastOptions?.classNames
34
39
  }
35
40
  },
36
41
  ...props
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/sonner.tsx"],"names":["Sonner"],"mappings":";;;;;;;;;AAYA,MAAM,OAAA,GAAU,CAAC,EAAE,GAAG,OAAM,KAAoB;AAC9C,EAAA,MAAM,EAAE,KAAA,GAAQ,QAAA,EAAS,GAAI,QAAA,EAAS;AAEtC,EAAA,uBACE,GAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,SAAA,EAAU,eAAA;AAAA,MACV,KAAA,EAAO;AAAA,QACL,OAAA,kBAAS,GAAA,CAAC,eAAA,EAAA,EAAgB,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QAC7C,IAAA,kBAAM,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACnC,OAAA,kBAAS,GAAA,CAAC,WAAA,EAAA,EAAY,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACzC,KAAA,kBAAO,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACrC,OAAA,sBAAU,OAAA,EAAA,EAAQ,IAAA,EAAK,MAAK,KAAA,EAAM,SAAA,EAAU,OAAM,EAAA,EAAG;AAAA,OACvD;AAAA,MACA,KAAA,EACE;AAAA,QACE,aAAA,EAAe,gBAAA;AAAA,QACf,eAAA,EAAiB,2BAAA;AAAA,QACjB,iBAAA,EAAmB,eAAA;AAAA,QACnB,iBAAA,EAAmB;AAAA,OACrB;AAAA,MAEF,YAAA,EAAc;AAAA,QACZ,UAAA,EAAY;AAAA,UACV,KAAA,EAAO;AAAA;AACT,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"sonner.js","sourcesContent":["'use client'\n\nimport { useTheme } from 'next-themes'\nimport * as React from 'react'\nimport { Toaster as Sonner, type ToasterProps } from 'sonner'\n\nimport { Spinner } from '../components/spinner.js'\nimport { IconCheckCircle } from '../icons/check-circle.js'\nimport { IconError } from '../icons/error.js'\nimport { IconInfo } from '../icons/info.js'\nimport { IconWarning } from '../icons/warning.js'\n\nconst Toaster = ({ ...props }: ToasterProps) => {\n const { theme = 'system' } = useTheme()\n\n return (\n <Sonner\n theme={theme as ToasterProps['theme']}\n className='toaster group'\n icons={{\n success: <IconCheckCircle className='size-4' />,\n info: <IconInfo className='size-4' />,\n warning: <IconWarning className='size-4' />,\n error: <IconError className='size-4' />,\n loading: <Spinner size='sm' color='current' label='' />,\n }}\n style={\n {\n '--normal-bg': 'var(--popover)',\n '--normal-text': 'var(--popover-foreground)',\n '--normal-border': 'var(--border)',\n '--border-radius': 'var(--radius)',\n } as React.CSSProperties\n }\n toastOptions={{\n classNames: {\n toast: 'cn-toast',\n },\n }}\n {...props}\n />\n )\n}\n\nexport { Toaster }\n"]}
1
+ {"version":3,"sources":["../../src/components/sonner.tsx"],"names":["Sonner"],"mappings":";;;;;;;;;;AA0BA,MAAM,WAAA,GAAc;AAAA,EAClB,aAAA,EAAe,gBAAA;AAAA,EACf,eAAA,EAAiB,2BAAA;AAAA,EACjB,iBAAA,EAAmB,eAAA;AAAA,EACnB,iBAAA,EAAmB;AACrB,CAAA;AAYA,MAAM,OAAA,GAAU,CAAC,EAAE,SAAA,EAAW,OAAO,KAAA,EAAO,YAAA,EAAc,GAAG,KAAA,EAAM,KAAoB;AACrF,EAAA,MAAM,EAAE,KAAA,GAAQ,QAAA,EAAS,GAAI,QAAA,EAAS;AAEtC,EAAA,uBACE,GAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MAIA,SAAA,EAAW,EAAA,CAAG,eAAA,EAAiB,SAAS,CAAA;AAAA,MACxC,KAAA,EAAO;AAAA,QACL,OAAA,kBAAS,GAAA,CAAC,eAAA,EAAA,EAAgB,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QAC7C,IAAA,kBAAM,GAAA,CAAC,QAAA,EAAA,EAAS,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACnC,OAAA,kBAAS,GAAA,CAAC,WAAA,EAAA,EAAY,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACzC,KAAA,kBAAO,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,QACrC,OAAA,sBAAU,OAAA,EAAA,EAAQ,IAAA,EAAK,MAAK,KAAA,EAAM,SAAA,EAAU,OAAM,EAAA,EAAG,CAAA;AAAA,QACrD,GAAG;AAAA,OACL;AAAA,MACA,KAAA,EAAO,EAAE,GAAG,WAAA,EAAa,GAAG,KAAA,EAAM;AAAA,MAGlC,YAAA,EAAc;AAAA,QACZ,GAAG,YAAA;AAAA,QACH,UAAA,EAAY;AAAA,UACV,KAAA,EAAO,UAAA;AAAA,UACP,GAAG,YAAA,EAAc;AAAA;AACnB,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"sonner.js","sourcesContent":["'use client'\n\nimport { useTheme } from 'next-themes'\nimport * as React from 'react'\nimport { Toaster as Sonner, type ToasterProps } from 'sonner'\n\nimport { Spinner } from '../components/spinner.js'\nimport { IconCheckCircle } from '../icons/check-circle.js'\nimport { IconError } from '../icons/error.js'\nimport { IconInfo } from '../icons/info.js'\nimport { IconWarning } from '../icons/warning.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * Binds sonner's own theming variables to the NSW semantic tokens.\n *\n * All four names below are sonner's public CSS API — three `--normal-*` colour\n * variables plus `--border-radius`, which is a separate name rather than part\n * of that family. Sonner's own stylesheet reads each of them.\n *\n * They are set ONLY here: none of the four is defined in the compiled\n * `dist/styles.css`, so this object is the single point at which the design\n * system's tokens reach a toast. Losing it silently drops every toast back to\n * sonner's built-in palette, which is why `style` is merged below rather than\n * overwritten.\n */\nconst tokenBridge = {\n '--normal-bg': 'var(--popover)',\n '--normal-text': 'var(--popover-foreground)',\n '--normal-border': 'var(--border)',\n '--border-radius': 'var(--radius)',\n} as React.CSSProperties\n\n/**\n * Toast host. Mount once, near the root.\n *\n * Every prop this component sets a default for is MERGED with the consumer's\n * value rather than replaced. Spreading `{...props}` last — the shadcn default\n * this was scaffolded from — meant a consumer passing `style` for something\n * unrelated (a z-index, an offset) silently discarded the whole token bridge\n * above, and passing one `icons` entry discarded the other four. Object spread\n * replaces keys wholesale; it does not deep-merge.\n */\nconst Toaster = ({ className, style, icons, toastOptions, ...props }: ToasterProps) => {\n const { theme = 'system' } = useTheme()\n\n return (\n <Sonner\n theme={theme as ToasterProps['theme']}\n // `toaster` and `group` are shadcn-compatible styling hooks. Nothing in\n // this package targets them, but consumers migrating from shadcn may, so\n // they are kept and merged rather than dropped.\n className={cn('toaster group', className)}\n icons={{\n success: <IconCheckCircle className='size-4' />,\n info: <IconInfo className='size-4' />,\n warning: <IconWarning className='size-4' />,\n error: <IconError className='size-4' />,\n loading: <Spinner size='sm' color='current' label='' />,\n ...icons,\n }}\n style={{ ...tokenBridge, ...style }}\n // Two levels of merge, not one: a consumer's `toastOptions` must not drop\n // our `classNames`, and their `classNames` must not drop `toast`.\n toastOptions={{\n ...toastOptions,\n classNames: {\n toast: 'cn-toast',\n ...toastOptions?.classNames,\n },\n }}\n {...props}\n />\n )\n}\n\nexport { Toaster }\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nswds/ui",
3
- "version": "5.0.6",
3
+ "version": "5.0.7",
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",