@snap-rail/ui 0.1.1 → 0.2.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.
Files changed (36) hide show
  1. package/lib/charts.js +5 -4
  2. package/lib/contract.js +118 -61
  3. package/lib/fallback.js +11 -0
  4. package/lib/index.js +3948 -154
  5. package/lib/runtime.js +151 -28
  6. package/lib/settings.js +67 -23
  7. package/lib/types/charts.d.ts +1 -1
  8. package/lib/types/charts.js +5 -5
  9. package/lib/types/components/alert.d.ts +57 -0
  10. package/lib/types/components/alert.js +46 -0
  11. package/lib/types/components/controls.d.ts +74 -11
  12. package/lib/types/components/controls.js +60 -17
  13. package/lib/types/components/form-rhf.d.ts +56 -0
  14. package/lib/types/components/form-rhf.js +74 -0
  15. package/lib/types/components/form.d.ts +33 -5
  16. package/lib/types/components/form.js +22 -6
  17. package/lib/types/components/index.d.ts +7 -0
  18. package/lib/types/components/index.js +7 -0
  19. package/lib/types/components/input.d.ts +11 -5
  20. package/lib/types/components/input.js +34 -7
  21. package/lib/types/components/layout.d.ts +28 -6
  22. package/lib/types/components/layout.js +86 -13
  23. package/lib/types/components/overlay.d.ts +95 -0
  24. package/lib/types/components/overlay.js +138 -0
  25. package/lib/types/components/schema-form.d.ts +3 -1
  26. package/lib/types/components/schema-form.js +46 -40
  27. package/lib/types/components/slider.d.ts +18 -0
  28. package/lib/types/components/slider.js +15 -0
  29. package/lib/types/contract.d.ts +49 -29
  30. package/lib/types/contract.js +49 -29
  31. package/lib/types/runtime.js +3 -2
  32. package/lib/types/settings-pages/appearance.js +2 -2
  33. package/lib/types/settings-pages/plugins.js +2 -2
  34. package/package.json +13 -6
  35. package/src/styles/base.css +243 -5
  36. package/src/styles/default.css +184 -6
package/lib/runtime.js CHANGED
@@ -7,6 +7,7 @@ import { TimerService } from "@snap-rail/cordis-plugin-timer";
7
7
  import { shellContract } from "@snap-rail/shell/contract";
8
8
  import { Component, createContext, useContext, useEffect, useRef, useState, useSyncExternalStore } from "react";
9
9
  import { createRoot } from "react-dom/client";
10
+ import "@radix-ui/react-separator";
10
11
  import { Slot as Slot$1 } from "@radix-ui/react-slot";
11
12
  import "@radix-ui/react-checkbox";
12
13
  import "@radix-ui/react-label";
@@ -15,6 +16,14 @@ import "@radix-ui/react-select";
15
16
  import * as SwitchPrimitive from "@radix-ui/react-switch";
16
17
  import * as TabsPrimitive from "@radix-ui/react-tabs";
17
18
  import * as DialogPrimitive from "@radix-ui/react-dialog";
19
+ import "react-hook-form";
20
+ import "@hookform/resolvers/zod";
21
+ import "@radix-ui/react-scroll-area";
22
+ import "@radix-ui/react-dropdown-menu";
23
+ import "@radix-ui/react-popover";
24
+ import * as ToastPrimitive from "@radix-ui/react-toast";
25
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
26
+ import "@radix-ui/react-slider";
18
27
  import { PLUGINS_FEED_URLS_KEY } from "@snap-rail/app-boot/contract";
19
28
  //#region lib/types/utils.js
20
29
  /**
@@ -39,6 +48,19 @@ function space(token) {
39
48
  return `var(--snap-space-${token})`;
40
49
  }
41
50
  //#endregion
51
+ //#region lib/types/components/alert.js
52
+ /** An inline status banner for results and failures. */
53
+ function Alert({ intent = "neutral", className, children, ...props }) {
54
+ return jsx("div", {
55
+ ...part("alert", "root"),
56
+ role: "alert",
57
+ className: cn("snap-alert", className),
58
+ "data-intent": intent,
59
+ ...props,
60
+ children
61
+ });
62
+ }
63
+ //#endregion
42
64
  //#region lib/types/components/button.js
43
65
  /**
44
66
  * Semantic buttons: one behaviour, skin-owned visuals. The DOM exposes
@@ -198,7 +220,14 @@ function DialogFooter({ children, className }) {
198
220
  //#endregion
199
221
  //#region lib/types/components/controls.js
200
222
  /** The tabs root. */
201
- const Tabs = TabsPrimitive.Root;
223
+ function Tabs({ className, children, ...props }) {
224
+ return jsx(TabsPrimitive.Root, {
225
+ ...part("tabs", "root"),
226
+ className: cn("snap-tabs", className),
227
+ ...props,
228
+ children
229
+ });
230
+ }
202
231
  /** The tabs list. */
203
232
  function TabsList({ className, children, ...props }) {
204
233
  return jsx(TabsPrimitive.List, {
@@ -217,21 +246,36 @@ function TabsTrigger({ className, children, ...props }) {
217
246
  children
218
247
  });
219
248
  }
220
- /** A boolean switch. */
221
- function Switch({ className, label, ...props }) {
222
- return jsxs("label", {
249
+ /** A boolean switch with an optional label on either side. */
250
+ function Switch({ className, label, labelPosition = "end", description, containerClassName, ...props }) {
251
+ const labelNode = label !== void 0 && jsx("span", {
252
+ ...part("switch", "label"),
253
+ children: label
254
+ });
255
+ const row = jsxs("label", {
223
256
  className: "snap-switch-label",
224
- children: [jsx(SwitchPrimitive.Root, {
225
- ...part("switch", "root"),
226
- className: cn("snap-switch", className),
227
- ...props,
228
- children: jsx(SwitchPrimitive.Thumb, {
229
- ...part("switch", "thumb"),
230
- className: "snap-switch-thumb"
231
- })
232
- }), label !== void 0 && jsx("span", {
233
- ...part("switch", "label"),
234
- children: label
257
+ children: [
258
+ labelPosition === "start" && labelNode,
259
+ jsx(SwitchPrimitive.Root, {
260
+ ...part("switch", "root"),
261
+ className: cn("snap-switch", className),
262
+ ...props,
263
+ children: jsx(SwitchPrimitive.Thumb, {
264
+ ...part("switch", "thumb"),
265
+ className: "snap-switch-thumb"
266
+ })
267
+ }),
268
+ labelPosition === "end" && labelNode
269
+ ]
270
+ });
271
+ if (description === void 0) return row;
272
+ return jsxs("span", {
273
+ ...part("switch", "field"),
274
+ className: cn("snap-switch-field", containerClassName),
275
+ children: [row, jsx("span", {
276
+ ...part("switch", "description"),
277
+ className: "snap-field-help",
278
+ children: description
235
279
  })]
236
280
  });
237
281
  }
@@ -271,12 +315,14 @@ function EmptyState({ title, description, icon, action, className }) {
271
315
  ]
272
316
  });
273
317
  }
318
+ createContext(null);
319
+ createContext(null);
274
320
  //#endregion
275
321
  //#region lib/types/components/input.js
276
322
  /** A single-line text field with semantic prefix/suffix slots. Layout
277
323
  * `style`/`className` dress the wrapper — the visible control; the native
278
324
  * field already stretches inside it. */
279
- function Input({ size = "md", invalid = false, prefix, suffix, onClear, componentName = "input", className, style, disabled, ...props }) {
325
+ function Input({ size = "md", invalid = false, prefix, suffix, onClear, fieldClassName, componentName = "input", className, style, disabled, ...props }) {
280
326
  return jsxs("div", {
281
327
  ...part(componentName, "root"),
282
328
  className: cn("snap-input", className),
@@ -291,7 +337,7 @@ function Input({ size = "md", invalid = false, prefix, suffix, onClear, componen
291
337
  }),
292
338
  jsx("input", {
293
339
  ...part(componentName, "field"),
294
- className: "snap-input-field",
340
+ className: cn("snap-input-field", fieldClassName),
295
341
  disabled,
296
342
  "aria-invalid": invalid || void 0,
297
343
  ...props
@@ -493,6 +539,84 @@ function Section({ title, description, actions, className, style, children }) {
493
539
  });
494
540
  }
495
541
  //#endregion
542
+ //#region lib/types/components/overlay.js
543
+ /** The tooltip provider; the runtime mounts one, pages only need it standalone. */
544
+ function TooltipProvider(props) {
545
+ return jsx(TooltipPrimitive.Provider, { ...props });
546
+ }
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();
555
+ }
556
+ /** The runtime-mounted viewport: renders the shared toast queue. Pages never
557
+ * mount this themselves — the runtime provides one per surface root. */
558
+ function Toaster(props) {
559
+ const records = useSyncExternalStore((onStoreChange) => {
560
+ toastListeners.add(onStoreChange);
561
+ return () => toastListeners.delete(onStoreChange);
562
+ }, () => toastRecords, () => toastRecords);
563
+ return jsxs(ToastPrimitive.Provider, {
564
+ ...props,
565
+ children: [records.map((record) => jsxs(ToastPrimitive.Root, {
566
+ ...part("toast", "root"),
567
+ className: "snap-toast",
568
+ "data-intent": record.intent ?? "neutral",
569
+ duration: record.duration ?? 5e3,
570
+ onOpenChange: (open) => {
571
+ if (!open) toastDismiss(record.id);
572
+ },
573
+ children: [
574
+ jsx(ToastTitle, { children: record.title }),
575
+ record.description !== void 0 && jsx(ToastDescription, { children: record.description }),
576
+ jsx(ToastClose, { "aria-label": "关闭" })
577
+ ]
578
+ }, record.id)), jsx(ToastViewport, {})]
579
+ });
580
+ }
581
+ /** A toast title with its part tag. */
582
+ function ToastTitle({ className, children, ...props }) {
583
+ return jsx(ToastPrimitive.Title, {
584
+ ...part("toast", "title"),
585
+ className: cn("snap-toast-title", className),
586
+ ...props,
587
+ children
588
+ });
589
+ }
590
+ /** A toast description with its part tag. */
591
+ function ToastDescription({ className, children, ...props }) {
592
+ return jsx(ToastPrimitive.Description, {
593
+ ...part("toast", "description"),
594
+ className: cn("snap-toast-description", className),
595
+ ...props,
596
+ children
597
+ });
598
+ }
599
+ /** A toast dismissal button. */
600
+ function ToastClose({ className, children, ...props }) {
601
+ return jsx(ToastPrimitive.Close, {
602
+ ...part("toast", "close"),
603
+ className: cn("snap-toast-close", className),
604
+ ...props,
605
+ children: children ?? jsx("span", {
606
+ "aria-hidden": "true",
607
+ children: "×"
608
+ })
609
+ });
610
+ }
611
+ /** The toast viewport; only the runtime's {@link Toaster} mounts one. */
612
+ function ToastViewport({ className, ...props }) {
613
+ return jsx(ToastPrimitive.Viewport, {
614
+ ...part("toast", "viewport"),
615
+ className: cn("snap-toast-viewport", className),
616
+ ...props
617
+ });
618
+ }
619
+ //#endregion
496
620
  //#region lib/types/components/surface.js
497
621
  /** A semantic table. */
498
622
  function Table({ className, children, ...props }) {
@@ -1402,9 +1526,8 @@ function AppearancePage() {
1402
1526
  children: jsxs(Stack, {
1403
1527
  gap: "lg",
1404
1528
  children: [
1405
- error !== void 0 && jsx("div", {
1406
- role: "alert",
1407
- style: { color: "var(--snap-color-danger)" },
1529
+ error !== void 0 && jsx(Alert, {
1530
+ intent: "danger",
1408
1531
  children: error
1409
1532
  }),
1410
1533
  jsx(Section, {
@@ -1988,9 +2111,8 @@ function PluginsPage({ ctx }) {
1988
2111
  children: [
1989
2112
  jsxs(Stack, {
1990
2113
  gap: "lg",
1991
- children: [error !== void 0 && jsx("div", {
1992
- role: "alert",
1993
- style: { color: "var(--snap-color-danger)" },
2114
+ children: [error !== void 0 && jsx(Alert, {
2115
+ intent: "danger",
1994
2116
  children: error
1995
2117
  }), rows.length === 0 ? jsx(EmptyState, {
1996
2118
  title: "还没有安装插件",
@@ -2844,7 +2966,7 @@ function SettingsFallbackHost(props) {
2844
2966
  /** The operator-window root. */
2845
2967
  function MainRoot(props) {
2846
2968
  const layout = useActiveLayout();
2847
- return jsxs(Fragment, { children: [
2969
+ return jsx(Fragment, { children: jsxs(TooltipProvider, { children: [
2848
2970
  jsx(StageProfiles, {
2849
2971
  ctx: props.ctx,
2850
2972
  layout
@@ -2854,8 +2976,9 @@ function MainRoot(props) {
2854
2976
  children: "没有已加载的布局插件。"
2855
2977
  }) : layout.render(),
2856
2978
  jsx(OverlayHost, { ctx: props.ctx }),
2857
- jsx(SettingsFallbackHost, { ctx: props.ctx })
2858
- ] });
2979
+ jsx(SettingsFallbackHost, { ctx: props.ctx }),
2980
+ jsx(Toaster, {})
2981
+ ] }) });
2859
2982
  }
2860
2983
  /**
2861
2984
  * The fallback ball face used when no plugin occupies `shell.ball`: a themed
@@ -2881,13 +3004,13 @@ function BallRoot(props) {
2881
3004
  }
2882
3005
  });
2883
3006
  }, [hasOccupant, link]);
2884
- if (occupant !== void 0) return jsx("div", {
3007
+ if (occupant !== void 0) return jsxs(TooltipProvider, { children: [jsx("div", {
2885
3008
  style: {
2886
3009
  width: "100%",
2887
3010
  height: "100%"
2888
3011
  },
2889
3012
  children: occupant.render({ surface: "ball" })
2890
- });
3013
+ }), jsx(Toaster, {})] });
2891
3014
  return jsx("div", {
2892
3015
  ref: rootRef,
2893
3016
  "data-snap-part": "ball.root",
package/lib/settings.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Component, createContext, useContext, useEffect, useState, useSyncExternalStore } from "react";
3
+ import "@radix-ui/react-separator";
3
4
  import { Slot } from "@radix-ui/react-slot";
4
5
  import "@radix-ui/react-checkbox";
5
6
  import "@radix-ui/react-label";
@@ -8,6 +9,14 @@ import "@radix-ui/react-select";
8
9
  import * as SwitchPrimitive from "@radix-ui/react-switch";
9
10
  import * as TabsPrimitive from "@radix-ui/react-tabs";
10
11
  import * as DialogPrimitive from "@radix-ui/react-dialog";
12
+ import "react-hook-form";
13
+ import "@hookform/resolvers/zod";
14
+ import "@radix-ui/react-scroll-area";
15
+ import "@radix-ui/react-dropdown-menu";
16
+ import "@radix-ui/react-popover";
17
+ import "@radix-ui/react-toast";
18
+ import "@radix-ui/react-tooltip";
19
+ import "@radix-ui/react-slider";
11
20
  import { rpcErrorText } from "@snap-rail/connection";
12
21
  import "@snap-rail/client-kernel";
13
22
  import "@snap-rail/station-rpc/contract";
@@ -39,6 +48,19 @@ function space(token) {
39
48
  return `var(--snap-space-${token})`;
40
49
  }
41
50
  //#endregion
51
+ //#region lib/types/components/alert.js
52
+ /** An inline status banner for results and failures. */
53
+ function Alert({ intent = "neutral", className, children, ...props }) {
54
+ return jsx("div", {
55
+ ...part("alert", "root"),
56
+ role: "alert",
57
+ className: cn("snap-alert", className),
58
+ "data-intent": intent,
59
+ ...props,
60
+ children
61
+ });
62
+ }
63
+ //#endregion
42
64
  //#region lib/types/components/button.js
43
65
  /**
44
66
  * Semantic buttons: one behaviour, skin-owned visuals. The DOM exposes
@@ -198,7 +220,14 @@ function DialogFooter({ children, className }) {
198
220
  //#endregion
199
221
  //#region lib/types/components/controls.js
200
222
  /** The tabs root. */
201
- const Tabs = TabsPrimitive.Root;
223
+ function Tabs({ className, children, ...props }) {
224
+ return jsx(TabsPrimitive.Root, {
225
+ ...part("tabs", "root"),
226
+ className: cn("snap-tabs", className),
227
+ ...props,
228
+ children
229
+ });
230
+ }
202
231
  /** The tabs list. */
203
232
  function TabsList({ className, children, ...props }) {
204
233
  return jsx(TabsPrimitive.List, {
@@ -217,21 +246,36 @@ function TabsTrigger({ className, children, ...props }) {
217
246
  children
218
247
  });
219
248
  }
220
- /** A boolean switch. */
221
- function Switch({ className, label, ...props }) {
222
- return jsxs("label", {
249
+ /** A boolean switch with an optional label on either side. */
250
+ function Switch({ className, label, labelPosition = "end", description, containerClassName, ...props }) {
251
+ const labelNode = label !== void 0 && jsx("span", {
252
+ ...part("switch", "label"),
253
+ children: label
254
+ });
255
+ const row = jsxs("label", {
223
256
  className: "snap-switch-label",
224
- children: [jsx(SwitchPrimitive.Root, {
225
- ...part("switch", "root"),
226
- className: cn("snap-switch", className),
227
- ...props,
228
- children: jsx(SwitchPrimitive.Thumb, {
229
- ...part("switch", "thumb"),
230
- className: "snap-switch-thumb"
231
- })
232
- }), label !== void 0 && jsx("span", {
233
- ...part("switch", "label"),
234
- children: label
257
+ children: [
258
+ labelPosition === "start" && labelNode,
259
+ jsx(SwitchPrimitive.Root, {
260
+ ...part("switch", "root"),
261
+ className: cn("snap-switch", className),
262
+ ...props,
263
+ children: jsx(SwitchPrimitive.Thumb, {
264
+ ...part("switch", "thumb"),
265
+ className: "snap-switch-thumb"
266
+ })
267
+ }),
268
+ labelPosition === "end" && labelNode
269
+ ]
270
+ });
271
+ if (description === void 0) return row;
272
+ return jsxs("span", {
273
+ ...part("switch", "field"),
274
+ className: cn("snap-switch-field", containerClassName),
275
+ children: [row, jsx("span", {
276
+ ...part("switch", "description"),
277
+ className: "snap-field-help",
278
+ children: description
235
279
  })]
236
280
  });
237
281
  }
@@ -271,12 +315,14 @@ function EmptyState({ title, description, icon, action, className }) {
271
315
  ]
272
316
  });
273
317
  }
318
+ createContext(null);
319
+ createContext(null);
274
320
  //#endregion
275
321
  //#region lib/types/components/input.js
276
322
  /** A single-line text field with semantic prefix/suffix slots. Layout
277
323
  * `style`/`className` dress the wrapper — the visible control; the native
278
324
  * field already stretches inside it. */
279
- function Input({ size = "md", invalid = false, prefix, suffix, onClear, componentName = "input", className, style, disabled, ...props }) {
325
+ function Input({ size = "md", invalid = false, prefix, suffix, onClear, fieldClassName, componentName = "input", className, style, disabled, ...props }) {
280
326
  return jsxs("div", {
281
327
  ...part(componentName, "root"),
282
328
  className: cn("snap-input", className),
@@ -291,7 +337,7 @@ function Input({ size = "md", invalid = false, prefix, suffix, onClear, componen
291
337
  }),
292
338
  jsx("input", {
293
339
  ...part(componentName, "field"),
294
- className: "snap-input-field",
340
+ className: cn("snap-input-field", fieldClassName),
295
341
  disabled,
296
342
  "aria-invalid": invalid || void 0,
297
343
  ...props
@@ -705,9 +751,8 @@ function AppearancePage() {
705
751
  children: jsxs(Stack, {
706
752
  gap: "lg",
707
753
  children: [
708
- error !== void 0 && jsx("div", {
709
- role: "alert",
710
- style: { color: "var(--snap-color-danger)" },
754
+ error !== void 0 && jsx(Alert, {
755
+ intent: "danger",
711
756
  children: error
712
757
  }),
713
758
  jsx(Section, {
@@ -1291,9 +1336,8 @@ function PluginsPage({ ctx }) {
1291
1336
  children: [
1292
1337
  jsxs(Stack, {
1293
1338
  gap: "lg",
1294
- children: [error !== void 0 && jsx("div", {
1295
- role: "alert",
1296
- style: { color: "var(--snap-color-danger)" },
1339
+ children: [error !== void 0 && jsx(Alert, {
1340
+ intent: "danger",
1297
1341
  children: error
1298
1342
  }), rows.length === 0 ? jsx(EmptyState, {
1299
1343
  title: "还没有安装插件",
@@ -24,7 +24,7 @@ export interface ChartFrameProps {
24
24
  }
25
25
  /** A semantic frame for a chart, gauge, map, or custom visualization. */
26
26
  export declare function ChartFrame({ title, description, actions, state, empty, error, loading, children, className, style, }: ChartFrameProps): ReactNode;
27
- /** A chart frame that exposes the `visualization.*` anatomy as well. */
27
+ /** An alias of {@link ChartFrame} for pages that prefer the generic name. */
28
28
  export declare function Visualization(props: ChartFrameProps): ReactNode;
29
29
  /** The theme object ECharts/D3 adapters can consume. */
30
30
  export interface ChartTheme {
@@ -3,15 +3,15 @@ import { cn, part } from "./utils.js";
3
3
  import { useSkinTokens } from "./skins.js";
4
4
  /** A semantic frame for a chart, gauge, map, or custom visualization. */
5
5
  export function ChartFrame({ title, description, actions, state = 'ready', empty, error, loading, children, className, style, }) {
6
- return (_jsxs("section", { ...part('chart-frame', 'root'), className: cn('snap-chart-frame', className), "data-state": state, style: style, children: [(title !== undefined || description !== undefined || actions !== undefined) && (_jsxs("header", { ...part('chart-frame', 'header'), className: "snap-chart-frame-header", children: [_jsxs("div", { children: [title !== undefined && _jsx("div", { ...part('chart-frame', 'title'), children: title }), description !== undefined && _jsx("div", { className: "snap-chart-frame-description", children: description })] }), actions !== undefined && _jsx("div", { ...part('chart-frame', 'actions'), children: actions })] })), _jsx("div", { ...part('chart-frame', 'body'), className: "snap-chart-frame-body", "data-state": state, children: state === 'loading'
7
- ? loading ?? _jsx("div", { ...part('visualization', 'loading'), children: "\u52A0\u8F7D\u4E2D\u2026" })
6
+ return (_jsxs("section", { ...part('chart-frame', 'root'), className: cn('snap-chart-frame', className), "data-state": state, style: style, children: [(title !== undefined || description !== undefined || actions !== undefined) && (_jsxs("header", { ...part('chart-frame', 'header'), className: "snap-chart-frame-header", children: [_jsxs("div", { children: [title !== undefined && _jsx("div", { ...part('chart-frame', 'title'), children: title }), description !== undefined && _jsx("div", { ...part('chart-frame', 'description'), className: "snap-chart-frame-description", children: description })] }), actions !== undefined && _jsx("div", { ...part('chart-frame', 'actions'), children: actions })] })), _jsx("div", { ...part('chart-frame', 'body'), className: "snap-chart-frame-body", "data-state": state, children: state === 'loading'
7
+ ? loading ?? _jsx("div", { ...part('chart-frame', 'loading'), children: "\u52A0\u8F7D\u4E2D\u2026" })
8
8
  : state === 'empty'
9
- ? empty ?? _jsx("div", { ...part('visualization', 'empty'), children: "\u6682\u65E0\u6570\u636E" })
9
+ ? empty ?? _jsx("div", { ...part('chart-frame', 'empty'), children: "\u6682\u65E0\u6570\u636E" })
10
10
  : state === 'error'
11
- ? error ?? _jsx("div", { ...part('visualization', 'error'), role: "alert", children: "\u56FE\u8868\u52A0\u8F7D\u5931\u8D25" })
11
+ ? error ?? _jsx("div", { ...part('chart-frame', 'error'), role: "alert", children: "\u56FE\u8868\u52A0\u8F7D\u5931\u8D25" })
12
12
  : children })] }));
13
13
  }
14
- /** A chart frame that exposes the `visualization.*` anatomy as well. */
14
+ /** An alias of {@link ChartFrame} for pages that prefer the generic name. */
15
15
  export function Visualization(props) {
16
16
  return _jsx(ChartFrame, { ...props });
17
17
  }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Attention surfaces: alerts (inline banners), separators, skeletons, and
3
+ * lists. Read-only primitives; the skin owns their visuals through the
4
+ * `alert.*`, `separator.*`, `skeleton.*`, and `list.*` parts.
5
+ *
6
+ * @module @snap-rail/ui/components/alert
7
+ */
8
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
9
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
10
+ import type { ButtonIntent } from './button.tsx';
11
+ /** Props of {@link Alert}. */
12
+ export interface AlertProps extends ComponentPropsWithoutRef<'div'> {
13
+ /** The semantic tone; the skin maps it to colour like a button intent. */
14
+ intent?: ButtonIntent;
15
+ }
16
+ /** An inline status banner for results and failures. */
17
+ export declare function Alert({ intent, className, children, ...props }: AlertProps): ReactNode;
18
+ /** The alert heading line. */
19
+ export declare function AlertTitle({ className, children, ...props }: ComponentPropsWithoutRef<'h5'>): ReactNode;
20
+ /** The alert body text. */
21
+ export declare function AlertDescription({ className, children, ...props }: ComponentPropsWithoutRef<'div'>): ReactNode;
22
+ /** Props of {@link Separator}. */
23
+ export interface SeparatorProps extends ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> {
24
+ orientation?: 'horizontal' | 'vertical';
25
+ }
26
+ /** A themed rule between sections. */
27
+ export declare function Separator({ orientation, className, ...props }: SeparatorProps): ReactNode;
28
+ /** Props of {@link Skeleton}. */
29
+ export interface SkeletonProps extends ComponentPropsWithoutRef<'div'> {
30
+ /** The shape variant; `text` matches the line height of body text. */
31
+ variant?: 'block' | 'text' | 'circle';
32
+ }
33
+ /** A neutral loading placeholder shaped by the skin. */
34
+ export declare function Skeleton({ variant, className, ...props }: SkeletonProps): ReactNode;
35
+ /** Props of {@link List}. */
36
+ export interface ListProps extends ComponentPropsWithoutRef<'ul'> {
37
+ /** Draw hairlines between items (default false). */
38
+ divided?: boolean;
39
+ }
40
+ /** A vertical collection of {@link ListItem} rows. */
41
+ export declare function List({ divided, className, children, ...props }: ListProps): ReactNode;
42
+ /** Props of {@link ListItem}. */
43
+ export interface ListItemProps extends Omit<ComponentPropsWithoutRef<'li'>, 'onClick' | 'disabled'> {
44
+ /** Leading glyph/figure slot (status LED, icon, thumbnail). */
45
+ leading?: ReactNode;
46
+ /** Trailing slot (badge, timestamp, action). */
47
+ trailing?: ReactNode;
48
+ /** Marks the row as the current selection. */
49
+ selected?: boolean;
50
+ /** Dim the row and ignore activation. */
51
+ disabled?: boolean;
52
+ /** Makes the row interactive (role=button, keyboard activation). */
53
+ onClick?: () => void;
54
+ }
55
+ /** One list row with leading/trailing slots. */
56
+ export declare function ListItem({ leading, trailing, selected, disabled, onClick, className, children, ...props }: ListItemProps): ReactNode;
57
+ //# sourceMappingURL=alert.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Attention surfaces: alerts (inline banners), separators, skeletons, and
4
+ * lists. Read-only primitives; the skin owns their visuals through the
5
+ * `alert.*`, `separator.*`, `skeleton.*`, and `list.*` parts.
6
+ *
7
+ * @module @snap-rail/ui/components/alert
8
+ */
9
+ import * as SeparatorPrimitive from '@radix-ui/react-separator';
10
+ import { cn, part } from "../utils.js";
11
+ /** An inline status banner for results and failures. */
12
+ export function Alert({ intent = 'neutral', className, children, ...props }) {
13
+ return (_jsx("div", { ...part('alert', 'root'), role: "alert", className: cn('snap-alert', className), "data-intent": intent, ...props, children: children }));
14
+ }
15
+ /** The alert heading line. */
16
+ export function AlertTitle({ className, children, ...props }) {
17
+ return _jsx("h5", { ...part('alert', 'title'), className: cn('snap-alert-title', className), ...props, children: children });
18
+ }
19
+ /** The alert body text. */
20
+ export function AlertDescription({ className, children, ...props }) {
21
+ return _jsx("div", { ...part('alert', 'description'), className: cn('snap-alert-description', className), ...props, children: children });
22
+ }
23
+ /** A themed rule between sections. */
24
+ export function Separator({ orientation = 'horizontal', className, ...props }) {
25
+ return (_jsx(SeparatorPrimitive.Root, { ...part('separator', 'root'), orientation: orientation, className: cn('snap-separator', className), ...props }));
26
+ }
27
+ /** A neutral loading placeholder shaped by the skin. */
28
+ export function Skeleton({ variant = 'block', className, ...props }) {
29
+ return _jsx("div", { ...part('skeleton', 'root'), className: cn('snap-skeleton', className), "data-variant": variant, "aria-hidden": "true", ...props });
30
+ }
31
+ /** A vertical collection of {@link ListItem} rows. */
32
+ export function List({ divided = false, className, children, ...props }) {
33
+ return (_jsx("ul", { ...part('list', 'root'), className: cn('snap-list', className), "data-divided": divided || undefined, ...props, children: children }));
34
+ }
35
+ /** One list row with leading/trailing slots. */
36
+ export function ListItem({ leading, trailing, selected = false, disabled = false, onClick, className, children, ...props }) {
37
+ const interactive = onClick !== undefined && !disabled;
38
+ const activate = (event) => {
39
+ if (event.key === 'Enter' || event.key === ' ') {
40
+ event.preventDefault();
41
+ onClick?.();
42
+ }
43
+ };
44
+ return (_jsxs("li", { ...part('list', 'item'), className: cn('snap-list-item', className), "data-selected": selected || undefined, "data-interactive": interactive || undefined, "data-disabled": disabled || undefined, "aria-disabled": disabled || undefined, ...interactive ? { role: 'button', tabIndex: 0, onClick, onKeyDown: activate } : {}, ...props, children: [leading !== undefined && _jsx("span", { ...part('list', 'leading'), children: leading }), _jsx("span", { ...part('list', 'content'), style: { flex: 1, minWidth: 0 }, children: children }), trailing !== undefined && _jsx("span", { ...part('list', 'trailing'), children: trailing })] }));
45
+ }
46
+ //# sourceMappingURL=alert.js.map