@snap-rail/ui 0.3.0 → 0.4.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.
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
@@ -2681,6 +2650,39 @@ function SettingsEntry(props) {
2681
2650
  onClick: props.open
2682
2651
  });
2683
2652
  }
2653
+ /** The settings footer: the running app's version plus the copyright line,
2654
+ * pinned below the page area of every settings page. The version rides the
2655
+ * existing `update.state` snapshot (`app.getVersion()`, populated in dev
2656
+ * too); hosts without the update bridge — or bare contexts without client
2657
+ * services — simply get no footer instead of an error. */
2658
+ function SettingsFooter({ ctx }) {
2659
+ const [version, setVersion] = useState(void 0);
2660
+ useEffect(() => {
2661
+ let link;
2662
+ try {
2663
+ link = ctx.client.link;
2664
+ } catch {
2665
+ return;
2666
+ }
2667
+ let cancelled = false;
2668
+ link.call("update.state", {}).then((result) => {
2669
+ if (!cancelled && result.ok) setVersion(result.value.status.currentVersion);
2670
+ }).catch(() => void 0);
2671
+ return () => {
2672
+ cancelled = true;
2673
+ };
2674
+ }, [ctx]);
2675
+ if (version === void 0) return null;
2676
+ return jsxs("footer", {
2677
+ ...part("settings", "footer"),
2678
+ className: "snap-settings-footer",
2679
+ children: [jsxs("span", { children: ["snap-rail v", version] }), jsxs("span", { children: [
2680
+ "© ",
2681
+ (/* @__PURE__ */ new Date()).getFullYear(),
2682
+ " snap-rail · Apache-2.0"
2683
+ ] })]
2684
+ });
2685
+ }
2684
2686
  /** The default settings surface. */
2685
2687
  function SettingsSurface(props) {
2686
2688
  const { service, ctx } = props;
@@ -2754,14 +2756,18 @@ function SettingsSurface(props) {
2754
2756
  }), jsx("span", { children: page.title })]
2755
2757
  }, page.id))]
2756
2758
  }, group))
2757
- }), jsx("main", {
2759
+ }), jsxs("main", {
2758
2760
  ...part("settings", "content"),
2759
2761
  className: "snap-settings-content",
2760
2762
  "data-active-page": activeId,
2761
- children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
2762
- page: active.id,
2763
- children: active.render()
2764
- })
2763
+ children: [jsx("div", {
2764
+ ...part("settings", "page"),
2765
+ className: "snap-settings-page",
2766
+ children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
2767
+ page: active.id,
2768
+ children: active.render()
2769
+ })
2770
+ }), jsx(SettingsFooter, { ctx })]
2765
2771
  })]
2766
2772
  })]
2767
2773
  })
@@ -2983,7 +2989,7 @@ function MainRoot(props) {
2983
2989
  }) : layout.render(),
2984
2990
  jsx(OverlayHost, { ctx: props.ctx }),
2985
2991
  jsx(SettingsFallbackHost, { ctx: props.ctx }),
2986
- jsx(Toaster, {})
2992
+ jsx(Toaster$1, {})
2987
2993
  ] }) });
2988
2994
  }
2989
2995
  /**
@@ -3016,7 +3022,7 @@ function BallRoot(props) {
3016
3022
  height: "100%"
3017
3023
  },
3018
3024
  children: occupant.render({ surface: "ball" })
3019
- }), jsx(Toaster, {})] });
3025
+ }), jsx(Toaster$1, {})] });
3020
3026
  return jsx("div", {
3021
3027
  ref: rootRef,
3022
3028
  "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
  /**
@@ -1906,6 +1939,39 @@ function SettingsEntry(props) {
1906
1939
  onClick: props.open
1907
1940
  });
1908
1941
  }
1942
+ /** The settings footer: the running app's version plus the copyright line,
1943
+ * pinned below the page area of every settings page. The version rides the
1944
+ * existing `update.state` snapshot (`app.getVersion()`, populated in dev
1945
+ * too); hosts without the update bridge — or bare contexts without client
1946
+ * services — simply get no footer instead of an error. */
1947
+ function SettingsFooter({ ctx }) {
1948
+ const [version, setVersion] = useState(void 0);
1949
+ useEffect(() => {
1950
+ let link;
1951
+ try {
1952
+ link = ctx.client.link;
1953
+ } catch {
1954
+ return;
1955
+ }
1956
+ let cancelled = false;
1957
+ link.call("update.state", {}).then((result) => {
1958
+ if (!cancelled && result.ok) setVersion(result.value.status.currentVersion);
1959
+ }).catch(() => void 0);
1960
+ return () => {
1961
+ cancelled = true;
1962
+ };
1963
+ }, [ctx]);
1964
+ if (version === void 0) return null;
1965
+ return jsxs("footer", {
1966
+ ...part("settings", "footer"),
1967
+ className: "snap-settings-footer",
1968
+ children: [jsxs("span", { children: ["snap-rail v", version] }), jsxs("span", { children: [
1969
+ "© ",
1970
+ (/* @__PURE__ */ new Date()).getFullYear(),
1971
+ " snap-rail · Apache-2.0"
1972
+ ] })]
1973
+ });
1974
+ }
1909
1975
  /** The default settings surface. */
1910
1976
  function SettingsSurface(props) {
1911
1977
  const { service, ctx } = props;
@@ -1979,14 +2045,18 @@ function SettingsSurface(props) {
1979
2045
  }), jsx("span", { children: page.title })]
1980
2046
  }, page.id))]
1981
2047
  }, group))
1982
- }), jsx("main", {
2048
+ }), jsxs("main", {
1983
2049
  ...part("settings", "content"),
1984
2050
  className: "snap-settings-content",
1985
2051
  "data-active-page": activeId,
1986
- children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
1987
- page: active.id,
1988
- children: active.render()
1989
- })
2052
+ children: [jsx("div", {
2053
+ ...part("settings", "page"),
2054
+ className: "snap-settings-page",
2055
+ children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
2056
+ page: active.id,
2057
+ children: active.render()
2058
+ })
2059
+ }), jsx(SettingsFooter, { ctx })]
1990
2060
  })]
1991
2061
  })]
1992
2062
  })
@@ -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
  };
@@ -367,7 +363,7 @@ export declare const UI_COMPONENTS: {
367
363
  readonly props: readonly ["state"];
368
364
  };
369
365
  readonly settings: {
370
- readonly parts: readonly ["settings.root", "settings.header", "settings.title", "settings.body", "settings.nav", "settings.nav-item", "settings.nav-icon", "settings.group", "settings.group-title", "settings.content"];
366
+ readonly parts: readonly ["settings.root", "settings.header", "settings.title", "settings.body", "settings.nav", "settings.nav-item", "settings.nav-icon", "settings.group", "settings.group-title", "settings.content", "settings.page", "settings.footer"];
371
367
  };
372
368
  };
373
369
  /** One semantic component name. */
@@ -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
  },
@@ -250,6 +246,8 @@ export const UI_COMPONENTS = {
250
246
  'settings.group',
251
247
  'settings.group-title',
252
248
  'settings.content',
249
+ 'settings.page',
250
+ 'settings.footer',
253
251
  ],
254
252
  },
255
253
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Component, useState, useSyncExternalStore } from 'react';
2
+ import { Component, useEffect, useState, useSyncExternalStore } from 'react';
3
3
  import { Button, Dialog, DialogContent, DialogTitle, EmptyState, IconButton, } from "./components/index.js";
4
4
  import { UI_SLOT_IDS } from "./contract.js";
5
5
  import { AppearancePage } from "./settings-pages/appearance.js";
@@ -42,6 +42,32 @@ export function SettingsEntry(props) {
42
42
  }
43
43
  return _jsx(IconButton, { icon: _jsx(GearIcon, {}), label: "\u8BBE\u7F6E", active: props.isOpen, onClick: props.open });
44
44
  }
45
+ /** The settings footer: the running app's version plus the copyright line,
46
+ * pinned below the page area of every settings page. The version rides the
47
+ * existing `update.state` snapshot (`app.getVersion()`, populated in dev
48
+ * too); hosts without the update bridge — or bare contexts without client
49
+ * services — simply get no footer instead of an error. */
50
+ function SettingsFooter({ ctx }) {
51
+ const [version, setVersion] = useState(undefined);
52
+ useEffect(() => {
53
+ let link;
54
+ try {
55
+ link = ctx.client.link;
56
+ }
57
+ catch {
58
+ return;
59
+ }
60
+ let cancelled = false;
61
+ void link.call('update.state', {}).then(result => {
62
+ if (!cancelled && result.ok)
63
+ setVersion(result.value.status.currentVersion);
64
+ }).catch(() => undefined);
65
+ return () => { cancelled = true; };
66
+ }, [ctx]);
67
+ if (version === undefined)
68
+ return null;
69
+ return (_jsxs("footer", { ...part('settings', 'footer'), className: "snap-settings-footer", children: [_jsxs("span", { children: ["snap-rail v", version] }), _jsxs("span", { children: ["\u00A9 ", new Date().getFullYear(), " snap-rail \u00B7 Apache-2.0"] })] }));
70
+ }
45
71
  /** The default settings surface. */
46
72
  export function SettingsSurface(props) {
47
73
  const { service, ctx } = props;
@@ -61,9 +87,9 @@ export function SettingsSurface(props) {
61
87
  bucket.push(page);
62
88
  }
63
89
  return (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: open, onOpenChange: next => { if (!next)
64
- service.close(); }, children: _jsx(DialogContent, { presentation: "fullscreen", showClose: false, children: _jsxs("div", { ...part('settings', 'root'), className: "snap-settings", children: [_jsxs("header", { ...part('settings', 'header'), className: "snap-settings-header", children: [_jsx(DialogTitle, { children: "\u8BBE\u7F6E" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [_jsx(IconButton, { icon: _jsx(GearIcon, {}), label: "\u914D\u7F6E\u63D2\u4EF6\u6E90", onClick: () => setFeedOpen(true) }), _jsx(IconButton, { icon: _jsx(CloseIcon, {}), label: "\u5173\u95ED", onClick: () => service.close() })] })] }), _jsxs("div", { ...part('settings', 'body'), className: "snap-settings-body", children: [_jsx("nav", { ...part('settings', 'nav'), className: "snap-settings-nav", "aria-label": "\u8BBE\u7F6E\u9875", children: [...groups.entries()].map(([group, entries]) => (_jsxs("div", { ...part('settings', 'group'), className: "snap-settings-group", children: [_jsx("div", { ...part('settings', 'group-title'), className: "snap-settings-group-title", children: group }), entries.map(page => (_jsxs("button", { type: "button", ...part('settings', 'nav-item'), className: cn('snap-settings-nav-item', page.id === activeId && 'is-active'), "data-active": page.id === activeId || undefined, "aria-current": page.id === activeId ? 'page' : undefined, onClick: () => service.open(page.id), children: [page.icon !== undefined && _jsx("span", { ...part('settings', 'nav-icon'), children: page.icon }), _jsx("span", { children: page.title })] }, page.id)))] }, group))) }), _jsx("main", { ...part('settings', 'content'), className: "snap-settings-content", "data-active-page": activeId, children: active === undefined
65
- ? _jsx(EmptyState, { title: "\u6682\u65E0\u8BBE\u7F6E\u9875" })
66
- : _jsx(SettingsPageBoundary, { page: active.id, children: active.render() }) })] })] }) }) }), _jsx(PluginFeedDialog, { ctx: ctx, open: feedOpen, onOpenChange: setFeedOpen })] }));
90
+ service.close(); }, children: _jsx(DialogContent, { presentation: "fullscreen", showClose: false, children: _jsxs("div", { ...part('settings', 'root'), className: "snap-settings", children: [_jsxs("header", { ...part('settings', 'header'), className: "snap-settings-header", children: [_jsx(DialogTitle, { children: "\u8BBE\u7F6E" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [_jsx(IconButton, { icon: _jsx(GearIcon, {}), label: "\u914D\u7F6E\u63D2\u4EF6\u6E90", onClick: () => setFeedOpen(true) }), _jsx(IconButton, { icon: _jsx(CloseIcon, {}), label: "\u5173\u95ED", onClick: () => service.close() })] })] }), _jsxs("div", { ...part('settings', 'body'), className: "snap-settings-body", children: [_jsx("nav", { ...part('settings', 'nav'), className: "snap-settings-nav", "aria-label": "\u8BBE\u7F6E\u9875", children: [...groups.entries()].map(([group, entries]) => (_jsxs("div", { ...part('settings', 'group'), className: "snap-settings-group", children: [_jsx("div", { ...part('settings', 'group-title'), className: "snap-settings-group-title", children: group }), entries.map(page => (_jsxs("button", { type: "button", ...part('settings', 'nav-item'), className: cn('snap-settings-nav-item', page.id === activeId && 'is-active'), "data-active": page.id === activeId || undefined, "aria-current": page.id === activeId ? 'page' : undefined, onClick: () => service.open(page.id), children: [page.icon !== undefined && _jsx("span", { ...part('settings', 'nav-icon'), children: page.icon }), _jsx("span", { children: page.title })] }, page.id)))] }, group))) }), _jsxs("main", { ...part('settings', 'content'), className: "snap-settings-content", "data-active-page": activeId, children: [_jsx("div", { ...part('settings', 'page'), className: "snap-settings-page", children: active === undefined
91
+ ? _jsx(EmptyState, { title: "\u6682\u65E0\u8BBE\u7F6E\u9875" })
92
+ : _jsx(SettingsPageBoundary, { page: active.id, children: active.render() }) }), _jsx(SettingsFooter, { ctx: ctx })] })] })] }) }) }), _jsx(PluginFeedDialog, { ctx: ctx, open: feedOpen, onOpenChange: setFeedOpen })] }));
67
93
  }
68
94
  /** Mount the settings registry and its default slot contributions. */
69
95
  const settingsPlugin = {