@snap-rail/ui 0.3.0 → 0.4.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.
@@ -1,11 +1,11 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as SeparatorPrimitive from "@radix-ui/react-separator";
3
3
  import { Slot } from "@radix-ui/react-slot";
4
- import { createContext, useContext, useEffect, useId, useRef, useState, useSyncExternalStore } from "react";
4
+ import { createContext, useContext, useEffect, useId, useRef, useState } from "react";
5
5
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
6
6
  import * as PopoverPrimitive from "@radix-ui/react-popover";
7
- import * as ToastPrimitive from "@radix-ui/react-toast";
8
7
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
8
+ import { Toaster as Toaster$1, toast as toast$1 } from "sonner";
9
9
  import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
10
10
  import * as LabelPrimitive from "@radix-ui/react-label";
11
11
  import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
@@ -374,9 +374,10 @@ function NumberInput({ min, max, step = 1, size = "md", invalid = false, fieldCl
374
374
  //#endregion
375
375
  //#region lib/types/components/overlay.js
376
376
  /**
377
- * Overlay semantics over Radix: tooltips, popovers, dropdown menus, and
378
- * toasts. Behaviour/keyboard/focus handling stays here; skins target the
379
- * stable parts (`tooltip.*`, `popover.*`, `menu.*`, `toast.*`) and state
377
+ * Overlay semantics over Radix: tooltips, popovers, and dropdown menus; the
378
+ * toast queue runs on Sonner (the Radix toast primitive is deprecated
379
+ * upstream). Behaviour/keyboard/focus handling stays here; skins target the
380
+ * stable parts (`tooltip.*`, `popover.*`, `menu.*`) and Sonner's toast data
380
381
  * attributes. The imperative toast() helper pairs with the <Toaster/> the
381
382
  * runtime mounts in every surface root.
382
383
  *
@@ -543,102 +544,88 @@ function MenuSeparator({ className, ...props }) {
543
544
  ...part("menu", "separator")
544
545
  });
545
546
  }
546
- let toastNextId = 1;
547
- let toastRecords = [];
548
- const toastListeners = /* @__PURE__ */ new Set();
549
- function toastEmit() {
550
- for (const listener of toastListeners) listener();
551
- }
552
- function toastDismiss(id) {
553
- toastRecords = toastRecords.filter((record) => record.id !== id);
554
- toastEmit();
547
+ /** Stroke glyphs per intent (lucide-style 24-box, `currentColor`); the skin
548
+ * colours them through the toast's `[data-icon]`. */
549
+ const TOAST_INTENT_PATHS = {
550
+ neutral: jsxs(Fragment, { children: [
551
+ jsx("circle", {
552
+ cx: "12",
553
+ cy: "12",
554
+ r: "10"
555
+ }),
556
+ jsx("path", { d: "M12 16v-4" }),
557
+ jsx("path", { d: "M12 8h.01" })
558
+ ] }),
559
+ primary: jsxs(Fragment, { children: [
560
+ jsx("circle", {
561
+ cx: "12",
562
+ cy: "12",
563
+ r: "10"
564
+ }),
565
+ jsx("path", { d: "M12 16v-4" }),
566
+ jsx("path", { d: "M12 8h.01" })
567
+ ] }),
568
+ success: jsxs(Fragment, { children: [jsx("circle", {
569
+ cx: "12",
570
+ cy: "12",
571
+ r: "10"
572
+ }), jsx("path", { d: "m9 12 2 2 4-4" })] }),
573
+ warning: jsxs(Fragment, { children: [
574
+ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
575
+ jsx("path", { d: "M12 9v4" }),
576
+ jsx("path", { d: "M12 17h.01" })
577
+ ] }),
578
+ danger: jsxs(Fragment, { children: [
579
+ jsx("circle", {
580
+ cx: "12",
581
+ cy: "12",
582
+ r: "10"
583
+ }),
584
+ jsx("path", { d: "m15 9-6 6" }),
585
+ jsx("path", { d: "m9 9 6 6" })
586
+ ] })
587
+ };
588
+ function toastIcon(intent) {
589
+ return jsx("svg", {
590
+ viewBox: "0 0 24 24",
591
+ fill: "none",
592
+ stroke: "currentColor",
593
+ strokeWidth: 2,
594
+ strokeLinecap: "round",
595
+ strokeLinejoin: "round",
596
+ "aria-hidden": "true",
597
+ children: TOAST_INTENT_PATHS[intent]
598
+ });
555
599
  }
556
- /** Enqueue a toast on the runtime-mounted {@link Toaster}s. */
600
+ /** Enqueue a toast on the runtime-mounted {@link Toaster}s. Backed by Sonner
601
+ * (the Radix toast primitive is deprecated upstream): `success`/`warning`/
602
+ * `danger` map to the typed emitters, `neutral`/`primary` ride the plain one,
603
+ * and every toast carries an `snap-intent-*` class the skins target. */
557
604
  function toast(entry) {
558
- const id = toastNextId++;
559
- toastRecords = [...toastRecords, {
560
- ...entry,
561
- id
562
- }];
563
- toastEmit();
564
- return id;
605
+ const intent = entry.intent ?? "neutral";
606
+ const options = {
607
+ description: entry.description,
608
+ icon: toastIcon(intent),
609
+ duration: entry.duration === 0 ? Number.POSITIVE_INFINITY : entry.duration ?? 5e3,
610
+ className: `snap-intent-${intent}`
611
+ };
612
+ switch (intent) {
613
+ case "success": return toast$1.success(entry.title, options);
614
+ case "warning": return toast$1.warning(entry.title, options);
615
+ case "danger": return toast$1.error(entry.title, options);
616
+ default: return toast$1(entry.title, options);
617
+ }
565
618
  }
566
619
  /** Dismiss a queued toast by id. */
567
620
  function dismissToast(id) {
568
- toastDismiss(id);
621
+ toast$1.dismiss(id);
569
622
  }
570
623
  /** The runtime-mounted viewport: renders the shared toast queue. Pages never
571
624
  * mount this themselves — the runtime provides one per surface root. */
572
- function Toaster(props) {
573
- const records = useSyncExternalStore((onStoreChange) => {
574
- toastListeners.add(onStoreChange);
575
- return () => toastListeners.delete(onStoreChange);
576
- }, () => toastRecords, () => toastRecords);
577
- return jsxs(ToastPrimitive.Provider, {
578
- ...props,
579
- children: [records.map((record) => jsxs(ToastPrimitive.Root, {
580
- ...part("toast", "root"),
581
- className: "snap-toast",
582
- "data-intent": record.intent ?? "neutral",
583
- duration: record.duration ?? 5e3,
584
- onOpenChange: (open) => {
585
- if (!open) toastDismiss(record.id);
586
- },
587
- children: [
588
- jsx(ToastTitle, { children: record.title }),
589
- record.description !== void 0 && jsx(ToastDescription, { children: record.description }),
590
- jsx(ToastClose, { "aria-label": "关闭" })
591
- ]
592
- }, record.id)), jsx(ToastViewport, {})]
593
- });
594
- }
595
- /** The raw toast root for pages that manage their own open state. */
596
- const Toast = ToastPrimitive.Root;
597
- /** A toast title with its part tag. */
598
- function ToastTitle({ className, children, ...props }) {
599
- return jsx(ToastPrimitive.Title, {
600
- className: cn("snap-toast-title", className),
601
- ...props,
602
- ...part("toast", "title"),
603
- children
604
- });
605
- }
606
- /** A toast description with its part tag. */
607
- function ToastDescription({ className, children, ...props }) {
608
- return jsx(ToastPrimitive.Description, {
609
- className: cn("snap-toast-description", className),
610
- ...props,
611
- ...part("toast", "description"),
612
- children
613
- });
614
- }
615
- /** An interactive toast action (confirm/retry affordances). */
616
- function ToastAction({ className, children, ...props }) {
617
- return jsx(ToastPrimitive.Action, {
618
- className: cn("snap-toast-action", className),
619
- ...props,
620
- ...part("toast", "action"),
621
- children
622
- });
623
- }
624
- /** A toast dismissal button. */
625
- function ToastClose({ className, children, ...props }) {
626
- return jsx(ToastPrimitive.Close, {
627
- className: cn("snap-toast-close", className),
628
- ...props,
629
- ...part("toast", "close"),
630
- children: children ?? jsx("span", {
631
- "aria-hidden": "true",
632
- children: "×"
633
- })
634
- });
635
- }
636
- /** The toast viewport; only the runtime's {@link Toaster} mounts one. */
637
- function ToastViewport({ className, ...props }) {
638
- return jsx(ToastPrimitive.Viewport, {
639
- className: cn("snap-toast-viewport", className),
640
- ...props,
641
- ...part("toast", "viewport")
625
+ function Toaster() {
626
+ return jsx(Toaster$1, {
627
+ position: "bottom-right",
628
+ closeButton: true
642
629
  });
643
630
  }
644
631
  //#endregion
@@ -2192,4 +2179,4 @@ function TableEmpty({ colSpan, children }) {
2192
2179
  }) });
2193
2180
  }
2194
2181
  //#endregion
2195
- export { Alert, AlertDescription, AlertTitle, AppShell, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Combobox, Controller, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DragScroll, EmptyState, Field, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormProvider, Grid, IconButton, Input, Label, Led, List, ListItem, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger, NumberInput, Page, Panel, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Row, SchemaForm, ScrollArea, Section, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, Separator, Sheet, Skeleton, Slider, Spinner, Split, Stack, Switch, Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastTitle, ToastViewport, Toaster, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TouchSelect, attachDragPan, cn, controlHeight, dismissToast, literalValuesOf, part, schemaNodeOf, space, toast, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch, zodResolver };
2182
+ export { Alert, AlertDescription, AlertTitle, AppShell, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Combobox, Controller, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DragScroll, EmptyState, Field, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormProvider, Grid, IconButton, Input, Label, Led, List, ListItem, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger, NumberInput, Page, Panel, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Row, SchemaForm, ScrollArea, Section, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, Separator, Sheet, Skeleton, Slider, Spinner, Split, Stack, Switch, Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TouchSelect, attachDragPan, cn, controlHeight, dismissToast, literalValuesOf, part, schemaNodeOf, space, toast, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch, zodResolver };
package/lib/contract.js CHANGED
@@ -342,17 +342,6 @@ const UI_COMPONENTS = {
342
342
  ],
343
343
  slots: ["trigger", "content"]
344
344
  },
345
- toast: {
346
- parts: [
347
- "toast.root",
348
- "toast.title",
349
- "toast.description",
350
- "toast.action",
351
- "toast.close",
352
- "toast.viewport"
353
- ],
354
- slots: ["action"]
355
- },
356
345
  progress: { parts: [
357
346
  "progress.root",
358
347
  "progress.track",
package/lib/fallback.js CHANGED
@@ -4,8 +4,8 @@ import { Slot } from "@radix-ui/react-slot";
4
4
  import { Component, createContext, useContext, useSyncExternalStore } from "react";
5
5
  import "@radix-ui/react-dropdown-menu";
6
6
  import "@radix-ui/react-popover";
7
- import "@radix-ui/react-toast";
8
7
  import "@radix-ui/react-tooltip";
8
+ import "sonner";
9
9
  import "@radix-ui/react-checkbox";
10
10
  import "@radix-ui/react-label";
11
11
  import "@radix-ui/react-radio-group";
@@ -127,6 +127,39 @@ function IconButton({ icon, label, active = false, intent = "neutral", emphasis
127
127
  })
128
128
  });
129
129
  }
130
+ jsxs(Fragment, { children: [
131
+ jsx("circle", {
132
+ cx: "12",
133
+ cy: "12",
134
+ r: "10"
135
+ }),
136
+ jsx("path", { d: "M12 16v-4" }),
137
+ jsx("path", { d: "M12 8h.01" })
138
+ ] }), jsxs(Fragment, { children: [
139
+ jsx("circle", {
140
+ cx: "12",
141
+ cy: "12",
142
+ r: "10"
143
+ }),
144
+ jsx("path", { d: "M12 16v-4" }),
145
+ jsx("path", { d: "M12 8h.01" })
146
+ ] }), jsxs(Fragment, { children: [jsx("circle", {
147
+ cx: "12",
148
+ cy: "12",
149
+ r: "10"
150
+ }), jsx("path", { d: "m9 12 2 2 4-4" })] }), jsxs(Fragment, { children: [
151
+ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
152
+ jsx("path", { d: "M12 9v4" }),
153
+ jsx("path", { d: "M12 17h.01" })
154
+ ] }), jsxs(Fragment, { children: [
155
+ jsx("circle", {
156
+ cx: "12",
157
+ cy: "12",
158
+ r: "10"
159
+ }),
160
+ jsx("path", { d: "m15 9-6 6" }),
161
+ jsx("path", { d: "m9 9 6 6" })
162
+ ] });
130
163
  //#endregion
131
164
  //#region lib/types/components/feedback.js
132
165
  /** A centered empty/zero-state block. */
package/lib/index.js CHANGED
@@ -4,8 +4,8 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator";
4
4
  import { Slot as Slot$1 } from "@radix-ui/react-slot";
5
5
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
6
6
  import * as PopoverPrimitive from "@radix-ui/react-popover";
7
- import * as ToastPrimitive from "@radix-ui/react-toast";
8
7
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
8
+ import { Toaster as Toaster$1, toast as toast$1 } from "sonner";
9
9
  import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
10
10
  import * as LabelPrimitive from "@radix-ui/react-label";
11
11
  import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
@@ -369,17 +369,6 @@ const UI_COMPONENTS = {
369
369
  ],
370
370
  slots: ["trigger", "content"]
371
371
  },
372
- toast: {
373
- parts: [
374
- "toast.root",
375
- "toast.title",
376
- "toast.description",
377
- "toast.action",
378
- "toast.close",
379
- "toast.viewport"
380
- ],
381
- slots: ["action"]
382
- },
383
372
  progress: { parts: [
384
373
  "progress.root",
385
374
  "progress.track",
@@ -1320,9 +1309,10 @@ function NumberInput({ min, max, step = 1, size = "md", invalid = false, fieldCl
1320
1309
  //#endregion
1321
1310
  //#region lib/types/components/overlay.js
1322
1311
  /**
1323
- * Overlay semantics over Radix: tooltips, popovers, dropdown menus, and
1324
- * toasts. Behaviour/keyboard/focus handling stays here; skins target the
1325
- * stable parts (`tooltip.*`, `popover.*`, `menu.*`, `toast.*`) and state
1312
+ * Overlay semantics over Radix: tooltips, popovers, and dropdown menus; the
1313
+ * toast queue runs on Sonner (the Radix toast primitive is deprecated
1314
+ * upstream). Behaviour/keyboard/focus handling stays here; skins target the
1315
+ * stable parts (`tooltip.*`, `popover.*`, `menu.*`) and Sonner's toast data
1326
1316
  * attributes. The imperative toast() helper pairs with the <Toaster/> the
1327
1317
  * runtime mounts in every surface root.
1328
1318
  *
@@ -1489,102 +1479,88 @@ function MenuSeparator({ className, ...props }) {
1489
1479
  ...part("menu", "separator")
1490
1480
  });
1491
1481
  }
1492
- let toastNextId = 1;
1493
- let toastRecords = [];
1494
- const toastListeners = /* @__PURE__ */ new Set();
1495
- function toastEmit() {
1496
- for (const listener of toastListeners) listener();
1497
- }
1498
- function toastDismiss(id) {
1499
- toastRecords = toastRecords.filter((record) => record.id !== id);
1500
- toastEmit();
1482
+ /** Stroke glyphs per intent (lucide-style 24-box, `currentColor`); the skin
1483
+ * colours them through the toast's `[data-icon]`. */
1484
+ const TOAST_INTENT_PATHS = {
1485
+ neutral: jsxs(Fragment, { children: [
1486
+ jsx("circle", {
1487
+ cx: "12",
1488
+ cy: "12",
1489
+ r: "10"
1490
+ }),
1491
+ jsx("path", { d: "M12 16v-4" }),
1492
+ jsx("path", { d: "M12 8h.01" })
1493
+ ] }),
1494
+ primary: jsxs(Fragment, { children: [
1495
+ jsx("circle", {
1496
+ cx: "12",
1497
+ cy: "12",
1498
+ r: "10"
1499
+ }),
1500
+ jsx("path", { d: "M12 16v-4" }),
1501
+ jsx("path", { d: "M12 8h.01" })
1502
+ ] }),
1503
+ success: jsxs(Fragment, { children: [jsx("circle", {
1504
+ cx: "12",
1505
+ cy: "12",
1506
+ r: "10"
1507
+ }), jsx("path", { d: "m9 12 2 2 4-4" })] }),
1508
+ warning: jsxs(Fragment, { children: [
1509
+ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
1510
+ jsx("path", { d: "M12 9v4" }),
1511
+ jsx("path", { d: "M12 17h.01" })
1512
+ ] }),
1513
+ danger: jsxs(Fragment, { children: [
1514
+ jsx("circle", {
1515
+ cx: "12",
1516
+ cy: "12",
1517
+ r: "10"
1518
+ }),
1519
+ jsx("path", { d: "m15 9-6 6" }),
1520
+ jsx("path", { d: "m9 9 6 6" })
1521
+ ] })
1522
+ };
1523
+ function toastIcon(intent) {
1524
+ return jsx("svg", {
1525
+ viewBox: "0 0 24 24",
1526
+ fill: "none",
1527
+ stroke: "currentColor",
1528
+ strokeWidth: 2,
1529
+ strokeLinecap: "round",
1530
+ strokeLinejoin: "round",
1531
+ "aria-hidden": "true",
1532
+ children: TOAST_INTENT_PATHS[intent]
1533
+ });
1501
1534
  }
1502
- /** Enqueue a toast on the runtime-mounted {@link Toaster}s. */
1535
+ /** Enqueue a toast on the runtime-mounted {@link Toaster}s. Backed by Sonner
1536
+ * (the Radix toast primitive is deprecated upstream): `success`/`warning`/
1537
+ * `danger` map to the typed emitters, `neutral`/`primary` ride the plain one,
1538
+ * and every toast carries an `snap-intent-*` class the skins target. */
1503
1539
  function toast(entry) {
1504
- const id = toastNextId++;
1505
- toastRecords = [...toastRecords, {
1506
- ...entry,
1507
- id
1508
- }];
1509
- toastEmit();
1510
- return id;
1540
+ const intent = entry.intent ?? "neutral";
1541
+ const options = {
1542
+ description: entry.description,
1543
+ icon: toastIcon(intent),
1544
+ duration: entry.duration === 0 ? Number.POSITIVE_INFINITY : entry.duration ?? 5e3,
1545
+ className: `snap-intent-${intent}`
1546
+ };
1547
+ switch (intent) {
1548
+ case "success": return toast$1.success(entry.title, options);
1549
+ case "warning": return toast$1.warning(entry.title, options);
1550
+ case "danger": return toast$1.error(entry.title, options);
1551
+ default: return toast$1(entry.title, options);
1552
+ }
1511
1553
  }
1512
1554
  /** Dismiss a queued toast by id. */
1513
1555
  function dismissToast(id) {
1514
- toastDismiss(id);
1556
+ toast$1.dismiss(id);
1515
1557
  }
1516
1558
  /** The runtime-mounted viewport: renders the shared toast queue. Pages never
1517
1559
  * mount this themselves — the runtime provides one per surface root. */
1518
- function Toaster(props) {
1519
- const records = useSyncExternalStore((onStoreChange) => {
1520
- toastListeners.add(onStoreChange);
1521
- return () => toastListeners.delete(onStoreChange);
1522
- }, () => toastRecords, () => toastRecords);
1523
- return jsxs(ToastPrimitive.Provider, {
1524
- ...props,
1525
- children: [records.map((record) => jsxs(ToastPrimitive.Root, {
1526
- ...part("toast", "root"),
1527
- className: "snap-toast",
1528
- "data-intent": record.intent ?? "neutral",
1529
- duration: record.duration ?? 5e3,
1530
- onOpenChange: (open) => {
1531
- if (!open) toastDismiss(record.id);
1532
- },
1533
- children: [
1534
- jsx(ToastTitle, { children: record.title }),
1535
- record.description !== void 0 && jsx(ToastDescription, { children: record.description }),
1536
- jsx(ToastClose, { "aria-label": "关闭" })
1537
- ]
1538
- }, record.id)), jsx(ToastViewport, {})]
1539
- });
1540
- }
1541
- /** The raw toast root for pages that manage their own open state. */
1542
- const Toast = ToastPrimitive.Root;
1543
- /** A toast title with its part tag. */
1544
- function ToastTitle({ className, children, ...props }) {
1545
- return jsx(ToastPrimitive.Title, {
1546
- className: cn("snap-toast-title", className),
1547
- ...props,
1548
- ...part("toast", "title"),
1549
- children
1550
- });
1551
- }
1552
- /** A toast description with its part tag. */
1553
- function ToastDescription({ className, children, ...props }) {
1554
- return jsx(ToastPrimitive.Description, {
1555
- className: cn("snap-toast-description", className),
1556
- ...props,
1557
- ...part("toast", "description"),
1558
- children
1559
- });
1560
- }
1561
- /** An interactive toast action (confirm/retry affordances). */
1562
- function ToastAction({ className, children, ...props }) {
1563
- return jsx(ToastPrimitive.Action, {
1564
- className: cn("snap-toast-action", className),
1565
- ...props,
1566
- ...part("toast", "action"),
1567
- children
1568
- });
1569
- }
1570
- /** A toast dismissal button. */
1571
- function ToastClose({ className, children, ...props }) {
1572
- return jsx(ToastPrimitive.Close, {
1573
- className: cn("snap-toast-close", className),
1574
- ...props,
1575
- ...part("toast", "close"),
1576
- children: children ?? jsx("span", {
1577
- "aria-hidden": "true",
1578
- children: "×"
1579
- })
1580
- });
1581
- }
1582
- /** The toast viewport; only the runtime's {@link Toaster} mounts one. */
1583
- function ToastViewport({ className, ...props }) {
1584
- return jsx(ToastPrimitive.Viewport, {
1585
- className: cn("snap-toast-viewport", className),
1586
- ...props,
1587
- ...part("toast", "viewport")
1560
+ function Toaster() {
1561
+ return jsx(Toaster$1, {
1562
+ position: "bottom-right",
1563
+ closeButton: true
1588
1564
  });
1589
1565
  }
1590
1566
  //#endregion
@@ -5305,4 +5281,4 @@ async function createClientRuntime(handle, options) {
5305
5281
  };
5306
5282
  }
5307
5283
  //#endregion
5308
- export { Alert, AlertDescription, AlertTitle, AppShell, Badge, Button, CUSTOM_SLOT_PATTERN, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartFrame, Checkbox, ClientProvider, Combobox, Controller, DEFAULT_DARK, DEFAULT_DARK_ID, DEFAULT_LIGHT, DEFAULT_LIGHT_ID, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DragScroll, EmptyState, Field, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormProvider, Grid, IconButton, Input, Label, Led, List, ListItem, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger, NumberInput, Page, Panel, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Row, SchemaForm, ScrollArea, Section, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, Separator, SettingsEntry, SettingsSurface, Sheet, Skeleton, SkinsProvider, Slider, Slot, Spinner, Split, Stack, Switch, Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastTitle, ToastViewport, Toaster, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TouchSelect, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, UiProvider, Visualization, attachBallDrag, attachDragPan, chartThemeOf, cn, controlHeight, createClientRuntime, dismissToast, fallbackPlugin, isValidSlotId, literalValuesOf, pagesPlugin, part, schemaNodeOf, settingsPageInfo, settingsPlugin, skinTokenVar, skinsPlugin, slotsPlugin, space, toast, useActiveLayout, useChartTheme, useClient, useController, useFieldArray, useForm, useFormContext, useFormState, usePagesVersion, useSkinId, useSkinTokens, useSkins, useUi, useUiVersion, useWatch, zodResolver };
5284
+ export { Alert, AlertDescription, AlertTitle, AppShell, Badge, Button, CUSTOM_SLOT_PATTERN, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartFrame, Checkbox, ClientProvider, Combobox, Controller, DEFAULT_DARK, DEFAULT_DARK_ID, DEFAULT_LIGHT, DEFAULT_LIGHT_ID, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DragScroll, EmptyState, Field, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormProvider, Grid, IconButton, Input, Label, Led, List, ListItem, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger, NumberInput, Page, Panel, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Row, SchemaForm, ScrollArea, Section, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, Separator, SettingsEntry, SettingsSurface, Sheet, Skeleton, SkinsProvider, Slider, Slot, Spinner, Split, Stack, Switch, Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TouchSelect, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, UiProvider, Visualization, attachBallDrag, attachDragPan, chartThemeOf, cn, controlHeight, createClientRuntime, dismissToast, fallbackPlugin, isValidSlotId, literalValuesOf, pagesPlugin, part, schemaNodeOf, settingsPageInfo, settingsPlugin, skinTokenVar, skinsPlugin, slotsPlugin, space, toast, useActiveLayout, useChartTheme, useClient, useController, useFieldArray, useForm, useFormContext, useFormState, usePagesVersion, useSkinId, useSkinTokens, useSkins, useUi, useUiVersion, useWatch, zodResolver };
package/lib/runtime.js CHANGED
@@ -11,8 +11,8 @@ import "@radix-ui/react-separator";
11
11
  import { Slot as Slot$1 } from "@radix-ui/react-slot";
12
12
  import "@radix-ui/react-dropdown-menu";
13
13
  import "@radix-ui/react-popover";
14
- import * as ToastPrimitive from "@radix-ui/react-toast";
15
14
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
15
+ import { Toaster } from "sonner";
16
16
  import "@radix-ui/react-checkbox";
17
17
  import "@radix-ui/react-label";
18
18
  import "@radix-ui/react-radio-group";
@@ -198,76 +198,45 @@ function Input({ size = "md", invalid = false, prefix, suffix, onClear, fieldCla
198
198
  function TooltipProvider(props) {
199
199
  return jsx(TooltipPrimitive.Provider, { ...props });
200
200
  }
201
- let toastRecords = [];
202
- const toastListeners = /* @__PURE__ */ new Set();
203
- function toastEmit() {
204
- for (const listener of toastListeners) listener();
205
- }
206
- function toastDismiss(id) {
207
- toastRecords = toastRecords.filter((record) => record.id !== id);
208
- toastEmit();
209
- }
201
+ jsxs(Fragment, { children: [
202
+ jsx("circle", {
203
+ cx: "12",
204
+ cy: "12",
205
+ r: "10"
206
+ }),
207
+ jsx("path", { d: "M12 16v-4" }),
208
+ jsx("path", { d: "M12 8h.01" })
209
+ ] }), jsxs(Fragment, { children: [
210
+ jsx("circle", {
211
+ cx: "12",
212
+ cy: "12",
213
+ r: "10"
214
+ }),
215
+ jsx("path", { d: "M12 16v-4" }),
216
+ jsx("path", { d: "M12 8h.01" })
217
+ ] }), jsxs(Fragment, { children: [jsx("circle", {
218
+ cx: "12",
219
+ cy: "12",
220
+ r: "10"
221
+ }), jsx("path", { d: "m9 12 2 2 4-4" })] }), jsxs(Fragment, { children: [
222
+ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
223
+ jsx("path", { d: "M12 9v4" }),
224
+ jsx("path", { d: "M12 17h.01" })
225
+ ] }), jsxs(Fragment, { children: [
226
+ jsx("circle", {
227
+ cx: "12",
228
+ cy: "12",
229
+ r: "10"
230
+ }),
231
+ jsx("path", { d: "m15 9-6 6" }),
232
+ jsx("path", { d: "m9 9 6 6" })
233
+ ] });
210
234
  /** The runtime-mounted viewport: renders the shared toast queue. Pages never
211
235
  * mount this themselves — the runtime provides one per surface root. */
212
- function Toaster(props) {
213
- const records = useSyncExternalStore((onStoreChange) => {
214
- toastListeners.add(onStoreChange);
215
- return () => toastListeners.delete(onStoreChange);
216
- }, () => toastRecords, () => toastRecords);
217
- return jsxs(ToastPrimitive.Provider, {
218
- ...props,
219
- children: [records.map((record) => jsxs(ToastPrimitive.Root, {
220
- ...part("toast", "root"),
221
- className: "snap-toast",
222
- "data-intent": record.intent ?? "neutral",
223
- duration: record.duration ?? 5e3,
224
- onOpenChange: (open) => {
225
- if (!open) toastDismiss(record.id);
226
- },
227
- children: [
228
- jsx(ToastTitle, { children: record.title }),
229
- record.description !== void 0 && jsx(ToastDescription, { children: record.description }),
230
- jsx(ToastClose, { "aria-label": "关闭" })
231
- ]
232
- }, record.id)), jsx(ToastViewport, {})]
233
- });
234
- }
235
- /** A toast title with its part tag. */
236
- function ToastTitle({ className, children, ...props }) {
237
- return jsx(ToastPrimitive.Title, {
238
- className: cn("snap-toast-title", className),
239
- ...props,
240
- ...part("toast", "title"),
241
- children
242
- });
243
- }
244
- /** A toast description with its part tag. */
245
- function ToastDescription({ className, children, ...props }) {
246
- return jsx(ToastPrimitive.Description, {
247
- className: cn("snap-toast-description", className),
248
- ...props,
249
- ...part("toast", "description"),
250
- children
251
- });
252
- }
253
- /** A toast dismissal button. */
254
- function ToastClose({ className, children, ...props }) {
255
- return jsx(ToastPrimitive.Close, {
256
- className: cn("snap-toast-close", className),
257
- ...props,
258
- ...part("toast", "close"),
259
- children: children ?? jsx("span", {
260
- "aria-hidden": "true",
261
- children: "×"
262
- })
263
- });
264
- }
265
- /** The toast viewport; only the runtime's {@link Toaster} mounts one. */
266
- function ToastViewport({ className, ...props }) {
267
- return jsx(ToastPrimitive.Viewport, {
268
- className: cn("snap-toast-viewport", className),
269
- ...props,
270
- ...part("toast", "viewport")
236
+ function Toaster$1() {
237
+ return jsx(Toaster, {
238
+ position: "bottom-right",
239
+ closeButton: true
271
240
  });
272
241
  }
273
242
  //#endregion
@@ -2983,7 +2952,7 @@ function MainRoot(props) {
2983
2952
  }) : layout.render(),
2984
2953
  jsx(OverlayHost, { ctx: props.ctx }),
2985
2954
  jsx(SettingsFallbackHost, { ctx: props.ctx }),
2986
- jsx(Toaster, {})
2955
+ jsx(Toaster$1, {})
2987
2956
  ] }) });
2988
2957
  }
2989
2958
  /**
@@ -3016,7 +2985,7 @@ function BallRoot(props) {
3016
2985
  height: "100%"
3017
2986
  },
3018
2987
  children: occupant.render({ surface: "ball" })
3019
- }), jsx(Toaster, {})] });
2988
+ }), jsx(Toaster$1, {})] });
3020
2989
  return jsx("div", {
3021
2990
  ref: rootRef,
3022
2991
  "data-snap-part": "ball.root",
@@ -5,8 +5,8 @@ import "@radix-ui/react-separator";
5
5
  import { Slot } from "@radix-ui/react-slot";
6
6
  import "@radix-ui/react-dropdown-menu";
7
7
  import "@radix-ui/react-popover";
8
- import "@radix-ui/react-toast";
9
8
  import "@radix-ui/react-tooltip";
9
+ import "sonner";
10
10
  import "@radix-ui/react-checkbox";
11
11
  import "@radix-ui/react-label";
12
12
  import "@radix-ui/react-radio-group";
@@ -185,6 +185,39 @@ function Input({ size = "md", invalid = false, prefix, suffix, onClear, fieldCla
185
185
  ]
186
186
  });
187
187
  }
188
+ jsxs(Fragment, { children: [
189
+ jsx("circle", {
190
+ cx: "12",
191
+ cy: "12",
192
+ r: "10"
193
+ }),
194
+ jsx("path", { d: "M12 16v-4" }),
195
+ jsx("path", { d: "M12 8h.01" })
196
+ ] }), jsxs(Fragment, { children: [
197
+ jsx("circle", {
198
+ cx: "12",
199
+ cy: "12",
200
+ r: "10"
201
+ }),
202
+ jsx("path", { d: "M12 16v-4" }),
203
+ jsx("path", { d: "M12 8h.01" })
204
+ ] }), jsxs(Fragment, { children: [jsx("circle", {
205
+ cx: "12",
206
+ cy: "12",
207
+ r: "10"
208
+ }), jsx("path", { d: "m9 12 2 2 4-4" })] }), jsxs(Fragment, { children: [
209
+ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
210
+ jsx("path", { d: "M12 9v4" }),
211
+ jsx("path", { d: "M12 17h.01" })
212
+ ] }), jsxs(Fragment, { children: [
213
+ jsx("circle", {
214
+ cx: "12",
215
+ cy: "12",
216
+ r: "10"
217
+ }),
218
+ jsx("path", { d: "m15 9-6 6" }),
219
+ jsx("path", { d: "m9 9 6 6" })
220
+ ] });
188
221
  //#endregion
189
222
  //#region lib/types/components/dialog.js
190
223
  /**
package/lib/settings.js CHANGED
@@ -4,8 +4,8 @@ import "@radix-ui/react-separator";
4
4
  import { Slot } from "@radix-ui/react-slot";
5
5
  import "@radix-ui/react-dropdown-menu";
6
6
  import "@radix-ui/react-popover";
7
- import "@radix-ui/react-toast";
8
7
  import "@radix-ui/react-tooltip";
8
+ import "sonner";
9
9
  import "@radix-ui/react-checkbox";
10
10
  import "@radix-ui/react-label";
11
11
  import "@radix-ui/react-radio-group";
@@ -192,6 +192,39 @@ function Input({ size = "md", invalid = false, prefix, suffix, onClear, fieldCla
192
192
  ]
193
193
  });
194
194
  }
195
+ jsxs(Fragment, { children: [
196
+ jsx("circle", {
197
+ cx: "12",
198
+ cy: "12",
199
+ r: "10"
200
+ }),
201
+ jsx("path", { d: "M12 16v-4" }),
202
+ jsx("path", { d: "M12 8h.01" })
203
+ ] }), jsxs(Fragment, { children: [
204
+ jsx("circle", {
205
+ cx: "12",
206
+ cy: "12",
207
+ r: "10"
208
+ }),
209
+ jsx("path", { d: "M12 16v-4" }),
210
+ jsx("path", { d: "M12 8h.01" })
211
+ ] }), jsxs(Fragment, { children: [jsx("circle", {
212
+ cx: "12",
213
+ cy: "12",
214
+ r: "10"
215
+ }), jsx("path", { d: "m9 12 2 2 4-4" })] }), jsxs(Fragment, { children: [
216
+ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }),
217
+ jsx("path", { d: "M12 9v4" }),
218
+ jsx("path", { d: "M12 17h.01" })
219
+ ] }), jsxs(Fragment, { children: [
220
+ jsx("circle", {
221
+ cx: "12",
222
+ cy: "12",
223
+ r: "10"
224
+ }),
225
+ jsx("path", { d: "m15 9-6 6" }),
226
+ jsx("path", { d: "m9 9 6 6" })
227
+ ] });
195
228
  //#endregion
196
229
  //#region lib/types/components/dialog.js
197
230
  /**
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Overlay semantics over Radix: tooltips, popovers, dropdown menus, and
3
- * toasts. Behaviour/keyboard/focus handling stays here; skins target the
4
- * stable parts (`tooltip.*`, `popover.*`, `menu.*`, `toast.*`) and state
2
+ * Overlay semantics over Radix: tooltips, popovers, and dropdown menus; the
3
+ * toast queue runs on Sonner (the Radix toast primitive is deprecated
4
+ * upstream). Behaviour/keyboard/focus handling stays here; skins target the
5
+ * stable parts (`tooltip.*`, `popover.*`, `menu.*`) and Sonner's toast data
5
6
  * attributes. The imperative toast() helper pairs with the <Toaster/> the
6
7
  * runtime mounts in every surface root.
7
8
  *
@@ -9,7 +10,6 @@
9
10
  */
10
11
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
11
12
  import * as PopoverPrimitive from '@radix-ui/react-popover';
12
- import * as ToastPrimitive from '@radix-ui/react-toast';
13
13
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
14
14
  import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
15
15
  /** The tooltip root; wraps `TooltipTrigger`/`TooltipContent` and owns delay. */
@@ -88,23 +88,14 @@ export interface ToastEntry {
88
88
  * (default 5000). */
89
89
  duration?: number;
90
90
  }
91
- /** Enqueue a toast on the runtime-mounted {@link Toaster}s. */
91
+ /** Enqueue a toast on the runtime-mounted {@link Toaster}s. Backed by Sonner
92
+ * (the Radix toast primitive is deprecated upstream): `success`/`warning`/
93
+ * `danger` map to the typed emitters, `neutral`/`primary` ride the plain one,
94
+ * and every toast carries an `snap-intent-*` class the skins target. */
92
95
  export declare function toast(entry: ToastEntry): number;
93
96
  /** Dismiss a queued toast by id. */
94
97
  export declare function dismissToast(id: number): void;
95
98
  /** The runtime-mounted viewport: renders the shared toast queue. Pages never
96
99
  * mount this themselves — the runtime provides one per surface root. */
97
- export declare function Toaster(props: Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Provider>, 'duration'>): ReactNode;
98
- /** The raw toast root for pages that manage their own open state. */
99
- export declare const Toast: import("react").ForwardRefExoticComponent<ToastPrimitive.ToastProps & import("react").RefAttributes<HTMLLIElement>>;
100
- /** A toast title with its part tag. */
101
- export declare function ToastTitle({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Title>): ReactNode;
102
- /** A toast description with its part tag. */
103
- export declare function ToastDescription({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Description>): ReactNode;
104
- /** An interactive toast action (confirm/retry affordances). */
105
- export declare function ToastAction({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Action>): ReactNode;
106
- /** A toast dismissal button. */
107
- export declare function ToastClose({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Close>): ReactNode;
108
- /** The toast viewport; only the runtime's {@link Toaster} mounts one. */
109
- export declare function ToastViewport({ className, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Viewport>): ReactNode;
100
+ export declare function Toaster(): ReactNode;
110
101
  //# sourceMappingURL=overlay.d.ts.map
@@ -1,8 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /**
3
- * Overlay semantics over Radix: tooltips, popovers, dropdown menus, and
4
- * toasts. Behaviour/keyboard/focus handling stays here; skins target the
5
- * stable parts (`tooltip.*`, `popover.*`, `menu.*`, `toast.*`) and state
3
+ * Overlay semantics over Radix: tooltips, popovers, and dropdown menus; the
4
+ * toast queue runs on Sonner (the Radix toast primitive is deprecated
5
+ * upstream). Behaviour/keyboard/focus handling stays here; skins target the
6
+ * stable parts (`tooltip.*`, `popover.*`, `menu.*`) and Sonner's toast data
6
7
  * attributes. The imperative toast() helper pairs with the <Toaster/> the
7
8
  * runtime mounts in every surface root.
8
9
  *
@@ -10,9 +11,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
11
  */
11
12
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
12
13
  import * as PopoverPrimitive from '@radix-ui/react-popover';
13
- import * as ToastPrimitive from '@radix-ui/react-toast';
14
14
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
15
- import { useRef, useSyncExternalStore, } from 'react';
15
+ import { Toaster as SonnerToaster, toast as sonnerToast } from 'sonner';
16
+ import { useRef, } from 'react';
16
17
  import { cn, part } from "../utils.js";
17
18
  /* ------------------------------------------------------------------ Tooltip */
18
19
  /** The tooltip root; wraps `TooltipTrigger`/`TooltipContent` and owns delay. */
@@ -126,60 +127,44 @@ export function MenuGroup(props) {
126
127
  export function MenuSeparator({ className, ...props }) {
127
128
  return _jsx(DropdownMenuPrimitive.Separator, { className: cn('snap-menu-separator', className), ...props, ...part('menu', 'separator') });
128
129
  }
129
- let toastNextId = 1;
130
- let toastRecords = [];
131
- const toastListeners = new Set();
132
- function toastEmit() {
133
- for (const listener of toastListeners)
134
- listener();
135
- }
136
- function toastDismiss(id) {
137
- toastRecords = toastRecords.filter(record => record.id !== id);
138
- toastEmit();
139
- }
140
- /** Enqueue a toast on the runtime-mounted {@link Toaster}s. */
130
+ /** Stroke glyphs per intent (lucide-style 24-box, `currentColor`); the skin
131
+ * colours them through the toast's `[data-icon]`. */
132
+ const TOAST_INTENT_PATHS = {
133
+ neutral: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("path", { d: "M12 16v-4" }), _jsx("path", { d: "M12 8h.01" })] })),
134
+ primary: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("path", { d: "M12 16v-4" }), _jsx("path", { d: "M12 8h.01" })] })),
135
+ success: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("path", { d: "m9 12 2 2 4-4" })] })),
136
+ warning: (_jsxs(_Fragment, { children: [_jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z" }), _jsx("path", { d: "M12 9v4" }), _jsx("path", { d: "M12 17h.01" })] })),
137
+ danger: (_jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("path", { d: "m15 9-6 6" }), _jsx("path", { d: "m9 9 6 6" })] })),
138
+ };
139
+ function toastIcon(intent) {
140
+ return (_jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: TOAST_INTENT_PATHS[intent] }));
141
+ }
142
+ /** Enqueue a toast on the runtime-mounted {@link Toaster}s. Backed by Sonner
143
+ * (the Radix toast primitive is deprecated upstream): `success`/`warning`/
144
+ * `danger` map to the typed emitters, `neutral`/`primary` ride the plain one,
145
+ * and every toast carries an `snap-intent-*` class the skins target. */
141
146
  export function toast(entry) {
142
- const id = toastNextId++;
143
- toastRecords = [...toastRecords, { ...entry, id }];
144
- toastEmit();
145
- return id;
147
+ const intent = entry.intent ?? 'neutral';
148
+ const options = {
149
+ description: entry.description,
150
+ icon: toastIcon(intent),
151
+ duration: entry.duration === 0 ? Number.POSITIVE_INFINITY : (entry.duration ?? 5000),
152
+ className: `snap-intent-${intent}`,
153
+ };
154
+ switch (intent) {
155
+ case 'success': return sonnerToast.success(entry.title, options);
156
+ case 'warning': return sonnerToast.warning(entry.title, options);
157
+ case 'danger': return sonnerToast.error(entry.title, options);
158
+ default: return sonnerToast(entry.title, options);
159
+ }
146
160
  }
147
161
  /** Dismiss a queued toast by id. */
148
162
  export function dismissToast(id) {
149
- toastDismiss(id);
163
+ sonnerToast.dismiss(id);
150
164
  }
151
165
  /** The runtime-mounted viewport: renders the shared toast queue. Pages never
152
166
  * mount this themselves — the runtime provides one per surface root. */
153
- export function Toaster(props) {
154
- const records = useSyncExternalStore((onStoreChange) => {
155
- toastListeners.add(onStoreChange);
156
- return () => toastListeners.delete(onStoreChange);
157
- }, () => toastRecords, () => toastRecords);
158
- return (_jsxs(ToastPrimitive.Provider, { ...props, children: [records.map(record => (_jsxs(ToastPrimitive.Root, { ...part('toast', 'root'), className: "snap-toast", "data-intent": record.intent ?? 'neutral', duration: record.duration ?? 5000, onOpenChange: (open) => {
159
- if (!open)
160
- toastDismiss(record.id);
161
- }, children: [_jsx(ToastTitle, { children: record.title }), record.description !== undefined && _jsx(ToastDescription, { children: record.description }), _jsx(ToastClose, { "aria-label": "\u5173\u95ED" })] }, record.id))), _jsx(ToastViewport, {})] }));
162
- }
163
- /** The raw toast root for pages that manage their own open state. */
164
- export const Toast = ToastPrimitive.Root;
165
- /** A toast title with its part tag. */
166
- export function ToastTitle({ className, children, ...props }) {
167
- return _jsx(ToastPrimitive.Title, { className: cn('snap-toast-title', className), ...props, ...part('toast', 'title'), children: children });
168
- }
169
- /** A toast description with its part tag. */
170
- export function ToastDescription({ className, children, ...props }) {
171
- return _jsx(ToastPrimitive.Description, { className: cn('snap-toast-description', className), ...props, ...part('toast', 'description'), children: children });
172
- }
173
- /** An interactive toast action (confirm/retry affordances). */
174
- export function ToastAction({ className, children, ...props }) {
175
- return _jsx(ToastPrimitive.Action, { className: cn('snap-toast-action', className), ...props, ...part('toast', 'action'), children: children });
176
- }
177
- /** A toast dismissal button. */
178
- export function ToastClose({ className, children, ...props }) {
179
- return _jsx(ToastPrimitive.Close, { className: cn('snap-toast-close', className), ...props, ...part('toast', 'close'), children: children ?? _jsx("span", { "aria-hidden": "true", children: "\u00D7" }) });
180
- }
181
- /** The toast viewport; only the runtime's {@link Toaster} mounts one. */
182
- export function ToastViewport({ className, ...props }) {
183
- return _jsx(ToastPrimitive.Viewport, { className: cn('snap-toast-viewport', className), ...props, ...part('toast', 'viewport') });
167
+ export function Toaster() {
168
+ return _jsx(SonnerToaster, { position: "bottom-right", closeButton: true });
184
169
  }
185
170
  //# sourceMappingURL=overlay.js.map
@@ -265,10 +265,6 @@ export declare const UI_COMPONENTS: {
265
265
  readonly parts: readonly ["menu.trigger", "menu.content", "menu.item", "menu.checkbox-item", "menu.item-indicator", "menu.separator"];
266
266
  readonly slots: readonly ["trigger", "content"];
267
267
  };
268
- readonly toast: {
269
- readonly parts: readonly ["toast.root", "toast.title", "toast.description", "toast.action", "toast.close", "toast.viewport"];
270
- readonly slots: readonly ["action"];
271
- };
272
268
  readonly progress: {
273
269
  readonly parts: readonly ["progress.root", "progress.track", "progress.indicator"];
274
270
  };
@@ -153,10 +153,6 @@ export const UI_COMPONENTS = {
153
153
  parts: ['menu.trigger', 'menu.content', 'menu.item', 'menu.checkbox-item', 'menu.item-indicator', 'menu.separator'],
154
154
  slots: ['trigger', 'content'],
155
155
  },
156
- toast: {
157
- parts: ['toast.root', 'toast.title', 'toast.description', 'toast.action', 'toast.close', 'toast.viewport'],
158
- slots: ['action'],
159
- },
160
156
  progress: {
161
157
  parts: ['progress.root', 'progress.track', 'progress.indicator'],
162
158
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snap-rail/ui",
3
3
  "description": "The built-in UI substrate: semantic components, typed region slots, skins, settings and renderer runtime",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -76,18 +76,18 @@
76
76
  "@radix-ui/react-slot": "^1.3.3",
77
77
  "@radix-ui/react-switch": "^1.3.7",
78
78
  "@radix-ui/react-tabs": "^1.1.13",
79
- "@radix-ui/react-toast": "^1.3.1",
80
79
  "@radix-ui/react-tooltip": "^1.2.16",
81
- "react-hook-form": "^7.91.0"
80
+ "react-hook-form": "^7.91.0",
81
+ "sonner": "^2.0.8"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "react": ">=19",
85
85
  "react-dom": ">=19",
86
86
  "zod": "^4.4.3",
87
- "@snap-rail/connection": "^0.1.0",
88
87
  "@snap-rail/cordis": "^4.0.3",
88
+ "@snap-rail/protocol": "^0.1.3",
89
89
  "@snap-rail/shell": "^0.2.4",
90
- "@snap-rail/protocol": "^0.1.3"
90
+ "@snap-rail/connection": "^0.1.0"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@types/react": "^19.2.14",
@@ -99,11 +99,11 @@
99
99
  "typescript": "^6.0.3",
100
100
  "vitest": "^4.1.8",
101
101
  "zod": "^4.4.3",
102
+ "@snap-rail/app-boot": "^0.1.3",
102
103
  "@snap-rail/client-kernel": "^0.1.2",
103
104
  "@snap-rail/connection": "^0.1.0",
104
105
  "@snap-rail/cordis": "^4.0.3",
105
106
  "@snap-rail/cordis-plugin-timer": "^1.1.3",
106
- "@snap-rail/app-boot": "^0.1.3",
107
107
  "@snap-rail/protocol": "^0.1.3",
108
108
  "@snap-rail/shell": "^0.2.4",
109
109
  "@snap-rail/station-rpc": "^0.1.0"
@@ -485,23 +485,41 @@
485
485
  background: var(--snap-color-border);
486
486
  }
487
487
 
488
- [data-snap-part='toast.viewport'] {
489
- position: fixed;
490
- right: 0;
491
- bottom: 0;
492
- z-index: var(--snap-z-modal);
493
- display: flex;
494
- flex-direction: column;
495
- gap: var(--snap-space-sm);
496
- margin: 0;
488
+ /* Toast (Sonner hosts the queue; these fit it to the semantic scale).
489
+ * The stylesheet ships with the app boot, so the structural rules here are
490
+ * written to out-last its defaults by loading order and specificity. */
491
+ [data-sonner-toast] {
497
492
  padding: var(--snap-space-md);
498
- list-style: none;
493
+ gap: var(--snap-space-sm);
494
+ font-size: var(--snap-text-sm);
499
495
  }
500
496
 
501
- [data-snap-part='toast.root'] {
502
- display: flex;
503
- flex-direction: column;
504
- gap: var(--snap-space-xs);
497
+ [data-sonner-toast] [data-icon] {
498
+ width: 1.15em;
499
+ height: 1.15em;
500
+ }
501
+
502
+ [data-sonner-toast] [data-icon] svg {
503
+ display: block;
504
+ width: 100%;
505
+ height: 100%;
506
+ }
507
+
508
+ [data-sonner-toast] [data-content] {
509
+ /* keep clear of the absolutely-positioned close button */
510
+ padding-right: var(--snap-space-lg);
511
+ }
512
+
513
+ [data-sonner-toast] [data-close-button] {
514
+ /* always reachable on touch: pinned top-right, visible without hover */
515
+ top: 0;
516
+ right: 0;
517
+ left: auto;
518
+ opacity: 1;
519
+ width: 28px;
520
+ height: 28px;
521
+ border: 0;
522
+ background: transparent;
505
523
  }
506
524
 
507
525
  [data-snap-part='alert.root'] {
@@ -538,45 +538,75 @@
538
538
  font-size: var(--snap-text-xs);
539
539
  }
540
540
 
541
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='toast.root'] {
541
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toaster] {
542
+ z-index: var(--snap-z-toast);
543
+ --border-radius: var(--snap-radius-md);
544
+ }
545
+
546
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast] {
542
547
  min-width: 280px;
543
- max-width: 360px;
548
+ max-width: 380px;
544
549
  border: var(--snap-border-width) solid var(--snap-color-border);
545
550
  border-radius: var(--snap-radius-md);
546
551
  background: var(--snap-color-surface-raised);
547
- padding: var(--snap-space-md);
552
+ color: var(--snap-color-text);
548
553
  box-shadow: var(--snap-shadow-lg);
549
554
  }
550
555
 
551
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='toast.root'][data-intent='danger'] {
552
- border-color: var(--snap-color-danger);
556
+ /* intent reads through a translucent tint and the icon colour; the frame
557
+ * stays neutral */
558
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast][data-type='success'] {
559
+ background: color-mix(in srgb, var(--snap-color-success) 10%, var(--snap-color-surface-raised));
553
560
  }
554
561
 
555
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='toast.root'][data-intent='success'] {
556
- border-color: var(--snap-color-success);
562
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast][data-type='warning'] {
563
+ background: color-mix(in srgb, var(--snap-color-warning) 10%, var(--snap-color-surface-raised));
557
564
  }
558
565
 
559
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='toast.root'][data-intent='warning'] {
560
- border-color: var(--snap-color-warning);
566
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast][data-type='error'] {
567
+ background: color-mix(in srgb, var(--snap-color-danger) 10%, var(--snap-color-surface-raised));
568
+ }
569
+
570
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast].snap-intent-primary {
571
+ background: color-mix(in srgb, var(--snap-color-primary) 8%, var(--snap-color-surface-raised));
572
+ }
573
+
574
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast] [data-icon] {
575
+ color: var(--snap-color-muted);
576
+ }
577
+
578
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast][data-type='success'] [data-icon] {
579
+ color: var(--snap-color-success);
580
+ }
581
+
582
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast][data-type='warning'] [data-icon] {
583
+ color: var(--snap-color-warning);
584
+ }
585
+
586
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast][data-type='error'] [data-icon] {
587
+ color: var(--snap-color-danger);
588
+ }
589
+
590
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast].snap-intent-primary [data-icon] {
591
+ color: var(--snap-color-primary);
561
592
  }
562
593
 
563
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='toast.title'] {
594
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast] [data-title] {
564
595
  font-weight: var(--snap-weight-medium);
565
596
  }
566
597
 
567
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='toast.description'] {
598
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast] [data-description] {
568
599
  color: var(--snap-color-muted);
569
- font-size: var(--snap-text-sm);
600
+ opacity: 1;
570
601
  }
571
602
 
572
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='toast.close'] {
573
- position: absolute;
574
- top: var(--snap-space-sm);
575
- right: var(--snap-space-sm);
576
- border: 0;
577
- background: transparent;
603
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast] [data-close-button] {
578
604
  color: var(--snap-color-muted);
579
- cursor: pointer;
605
+ border-radius: var(--snap-radius-full);
606
+ }
607
+
608
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-sonner-toast] [data-close-button]:hover {
609
+ background: color-mix(in srgb, var(--snap-color-muted) 18%, transparent);
580
610
  }
581
611
 
582
612
  /* Alerts / separator / skeleton / list / slider ---------------------- */