@nswds/ui 9.6.3 → 9.6.4

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.
@@ -15,6 +15,7 @@ const tokenBridge = {
15
15
  "--normal-border": "var(--border)",
16
16
  "--border-radius": "var(--radius)"
17
17
  };
18
+ const descriptionBridge = "text-muted-foreground! in-data-[rich-colors=true]:text-inherit!";
18
19
  const Toaster = ({ className, style, icons, toastOptions, ...props }) => {
19
20
  const { theme = "system" } = useTheme();
20
21
  return /* @__PURE__ */ jsx(
@@ -35,7 +36,8 @@ const Toaster = ({ className, style, icons, toastOptions, ...props }) => {
35
36
  ...toastOptions,
36
37
  classNames: {
37
38
  toast: "cn-toast",
38
- ...toastOptions?.classNames
39
+ ...toastOptions?.classNames,
40
+ description: cn(descriptionBridge, toastOptions?.classNames?.description)
39
41
  }
40
42
  },
41
43
  ...props
@@ -1 +1 @@
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"]}
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;AAaA,MAAM,iBAAA,GAAoB,iEAAA;AAY1B,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,MAIlC,YAAA,EAAc;AAAA,QACZ,GAAG,YAAA;AAAA,QACH,UAAA,EAAY;AAAA,UACV,KAAA,EAAO,UAAA;AAAA,UACP,GAAG,YAAA,EAAc,UAAA;AAAA,UACjB,WAAA,EAAa,EAAA,CAAG,iBAAA,EAAmB,YAAA,EAAc,YAAY,WAAW;AAAA;AAC1E,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 * The description's colour, bridged to the muted-foreground token. Sonner has\n * no variable for it: it paints its own grey and switches to a light one only\n * when ITS theme is dark, which Toaster reads from next-themes. On a page made\n * dark any other way the description stayed dark grey on the dark popover\n * surface, 1.43:1 (#252). The token flips with the page, whatever drives it.\n *\n * Important, because sonner's rule (`[data-sonner-toast][data-styled='true']\n * [data-description]`) outranks a single class. A rich-colours toast keeps\n * sonner's own behaviour: the description inherits the toast's tinted ink.\n */\nconst descriptionBridge = 'text-muted-foreground! in-data-[rich-colors=true]:text-inherit!'\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` — or\n // the description bridge, which is merged with theirs.\n toastOptions={{\n ...toastOptions,\n classNames: {\n toast: 'cn-toast',\n ...toastOptions?.classNames,\n description: cn(descriptionBridge, toastOptions?.classNames?.description),\n },\n }}\n {...props}\n />\n )\n}\n\nexport { Toaster }\n"]}