atlas-react-kit 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/COMPONENTS.md CHANGED
@@ -38,7 +38,7 @@ no root component barrel.
38
38
  | `separator`, `skeleton` | `Separator`, `Skeleton` |
39
39
  | `slider` | `Slider`; `value` number, `onValueChange`, optional `onValueCommit`, `min`, `max`, `step`, `disabled`, `id`, `aria-labelledby`, `className`. Radix Slider; 44px thumb hit; square track; primary fill. Name it with `aria-labelledby`. |
40
40
  | `sortable-table-head` | `SortableTableHead`; `sorted`, `direction` (`asc` \ |
41
- | `sonner` | `Toaster`; Sonner props, with `next-themes` theme defaults |
41
+ | `sonner` | `Toaster`, `toast`; kit-styled toasts (status icons, kit buttons, close button); import `toast` from here, not `sonner` |
42
42
  | `spinner` | `Spinner`; `role="status"` with `aria-label` (default `Loading`) |
43
43
  | `stat-tile` | `StatTile`, `statTileGrid`, `sectionLabel`; `label`, `value`, optional `sub`, `children`, `className`. |
44
44
  | `switch` | `Switch`; settings that apply immediately; square track and thumb |
package/README.md CHANGED
@@ -7,7 +7,7 @@ keeping locally (`InfoTip`, `ColorLegend`, `SearchPicker`, `Markdown`,
7
7
  React 19 and Tailwind 4 are required.
8
8
 
9
9
  ```sh
10
- npm install --save-exact atlas-react-kit@0.6.1
10
+ npm install --save-exact atlas-react-kit@0.7.0
11
11
  ```
12
12
 
13
13
  Import components by subpath:
@@ -116,7 +116,7 @@ artifact with the package owner's npm login:
116
116
  ```sh
117
117
  mkdir -p release-artifacts
118
118
  npm pack --pack-destination release-artifacts
119
- npm publish ./release-artifacts/atlas-react-kit-0.6.1.tgz --access public
119
+ npm publish ./release-artifacts/atlas-react-kit-0.7.0.tgz --access public
120
120
  ```
121
121
 
122
122
  See [CONTRIBUTING.md](./CONTRIBUTING.md) for adding components, the browser
package/dist/sonner.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- import * as React from "react";
2
- import { type ToasterProps } from "sonner";
3
- declare const Toaster: ({ ...props }: ToasterProps) => React.JSX.Element;
4
- export { Toaster };
1
+ import { toast, type ToasterProps } from "sonner";
2
+ /**
3
+ * Mount one near the app root and call `toast()` from this module (not from
4
+ * `sonner` directly), so the app and the toaster always share one Sonner.
5
+ */
6
+ declare const Toaster: ({ toastOptions, ...props }: ToasterProps) => import("react").JSX.Element;
7
+ export { Toaster, toast };
8
+ export type { ToasterProps };
package/dist/sonner.js CHANGED
@@ -1,15 +1,61 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import * as React from "react";
3
+ import { CircleAlertIcon, CircleCheckIcon, InfoIcon, LoaderCircleIcon, XIcon, } from "lucide-react";
4
4
  import { useTheme } from "next-themes";
5
- import { Toaster as Sonner } from "sonner";
6
- const Toaster = ({ ...props }) => {
5
+ import { Toaster as Sonner, toast } from "sonner";
6
+ import { buttonVariants } from "./button.js";
7
+ import { cn } from "./utils.js";
8
+ /**
9
+ * Toasts drawn entirely with kit classes. Sonner's own styles are unlayered
10
+ * CSS that Tailwind utilities cannot override, so the toaster runs Sonner
11
+ * `unstyled` and styles every part here: the popover surface, Alert-style
12
+ * status icons (the tone colors the icon, title, and border, not the body
13
+ * text), kit buttons for actions, and a labelled close button with the
14
+ * shared focus ring.
15
+ */
16
+ const classNames = {
17
+ toast: "flex w-(--width) flex-wrap items-start justify-end gap-3 rounded-none border border-border bg-popover p-4 pr-10 text-sm text-popover-foreground shadow-lg",
18
+ // Fills the row beside the icon, so action buttons wrap to their own row
19
+ // (aligned right by the toast's justify-end).
20
+ content: "flex min-w-0 flex-1 basis-[calc(100%-1.75rem)] flex-col gap-0.5",
21
+ title: "font-medium leading-5",
22
+ description: "leading-5 text-muted-foreground",
23
+ icon: "mt-0.5 flex size-4 shrink-0 items-center justify-center [&_svg]:size-4",
24
+ actionButton: cn(buttonVariants({ size: "xs" }), "shrink-0"),
25
+ cancelButton: cn(buttonVariants({ variant: "outline", size: "xs" }), "shrink-0"),
26
+ closeButton: cn(buttonVariants({ variant: "ghost", size: "icon-xs" }), "absolute top-2 right-2 text-muted-foreground"),
27
+ success: "border-success/40 [&_[data-title]]:text-success",
28
+ warning: "border-warning/40 [&_[data-title]]:text-warning",
29
+ error: "border-destructive/40 [&_[data-title]]:text-destructive",
30
+ };
31
+ const icons = {
32
+ success: _jsx(CircleCheckIcon, { "aria-hidden": true, className: "text-success" }),
33
+ info: _jsx(InfoIcon, { "aria-hidden": true, className: "text-foreground" }),
34
+ warning: _jsx(CircleAlertIcon, { "aria-hidden": true, className: "text-warning" }),
35
+ error: _jsx(CircleAlertIcon, { "aria-hidden": true, className: "text-destructive" }),
36
+ loading: (_jsx(LoaderCircleIcon, { "aria-hidden": true, className: "animate-spin text-muted-foreground" })),
37
+ close: _jsx(XIcon, { "aria-hidden": true }),
38
+ };
39
+ /** Merge app class names onto the kit's, part by part. */
40
+ function mergeClassNames(extra) {
41
+ if (!extra)
42
+ return classNames;
43
+ const merged = { ...classNames };
44
+ for (const [part, value] of Object.entries(extra)) {
45
+ merged[part] = cn(classNames[part], value);
46
+ }
47
+ return merged;
48
+ }
49
+ /**
50
+ * Mount one near the app root and call `toast()` from this module (not from
51
+ * `sonner` directly), so the app and the toaster always share one Sonner.
52
+ */
53
+ const Toaster = ({ toastOptions, ...props }) => {
7
54
  const { theme = "system" } = useTheme();
8
- return (_jsx(Sonner, { theme: theme, className: "toaster group", style: {
9
- "--normal-bg": "var(--popover)",
10
- "--normal-text": "var(--popover-foreground)",
11
- "--normal-border": "var(--border)",
12
- "--border-radius": "0px",
13
- }, ...props }));
55
+ return (_jsx(Sonner, { theme: theme, className: "toaster group", closeButton: true, icons: icons, ...props, toastOptions: {
56
+ ...toastOptions,
57
+ unstyled: true,
58
+ classNames: mergeClassNames(toastOptions?.classNames),
59
+ } }));
14
60
  };
15
- export { Toaster };
61
+ export { Toaster, toast };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atlas-react-kit",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Shared React components and Tailwind theme for Atlas",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,8 +39,8 @@ and tells Tailwind to scan the kit's compiled files:
39
39
 
40
40
  Dark mode needs `ThemeProvider` from `atlas-react-kit/theme-provider` near the
41
41
  root (or a `dark` class on an ancestor). Toasts need one `<Toaster />` from
42
- `atlas-react-kit/sonner`; call `toast()` from the `sonner` package, which the
43
- app should list as its own dependency. Fix missing setup rather than working
42
+ `atlas-react-kit/sonner`; import `toast` from `atlas-react-kit/sonner` too,
43
+ never from `sonner` (a second copy of Sonner never reaches the kit's toaster). Fix missing setup rather than working
44
44
  around unstyled components.
45
45
 
46
46
  ## 3. Pick the kit component for the job