@snap-rail/ui 0.1.0 → 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 (49) hide show
  1. package/lib/charts.js +6 -29
  2. package/lib/contract.js +119 -78
  3. package/lib/fallback.js +11 -1
  4. package/lib/index.js +2466 -735
  5. package/lib/runtime.js +1552 -490
  6. package/lib/settings.js +1162 -244
  7. package/lib/skins.js +163 -189
  8. package/lib/types/charts.d.ts +1 -1
  9. package/lib/types/charts.js +5 -5
  10. package/lib/types/components/alert.d.ts +57 -0
  11. package/lib/types/components/alert.js +46 -0
  12. package/lib/types/components/controls.d.ts +74 -11
  13. package/lib/types/components/controls.js +60 -17
  14. package/lib/types/components/dialog.d.ts +5 -5
  15. package/lib/types/components/dialog.js +2 -2
  16. package/lib/types/components/form-rhf.d.ts +56 -0
  17. package/lib/types/components/form-rhf.js +74 -0
  18. package/lib/types/components/form.d.ts +33 -5
  19. package/lib/types/components/form.js +22 -6
  20. package/lib/types/components/index.d.ts +7 -0
  21. package/lib/types/components/index.js +7 -0
  22. package/lib/types/components/input.d.ts +16 -7
  23. package/lib/types/components/input.js +39 -9
  24. package/lib/types/components/layout.d.ts +32 -7
  25. package/lib/types/components/layout.js +88 -15
  26. package/lib/types/components/overlay.d.ts +95 -0
  27. package/lib/types/components/overlay.js +138 -0
  28. package/lib/types/components/schema-form.d.ts +16 -4
  29. package/lib/types/components/schema-form.js +69 -40
  30. package/lib/types/components/slider.d.ts +18 -0
  31. package/lib/types/components/slider.js +15 -0
  32. package/lib/types/contract.d.ts +49 -37
  33. package/lib/types/contract.js +49 -33
  34. package/lib/types/fallback.js +1 -1
  35. package/lib/types/runtime.d.ts +23 -1
  36. package/lib/types/runtime.js +77 -20
  37. package/lib/types/settings-pages/appearance.d.ts +6 -4
  38. package/lib/types/settings-pages/appearance.js +33 -36
  39. package/lib/types/settings-pages/plugin-feed.d.ts +17 -0
  40. package/lib/types/settings-pages/plugin-feed.js +66 -0
  41. package/lib/types/settings-pages/plugins.d.ts +10 -5
  42. package/lib/types/settings-pages/plugins.js +284 -21
  43. package/lib/types/settings.d.ts +1 -0
  44. package/lib/types/settings.js +14 -8
  45. package/lib/types/skins.d.ts +38 -44
  46. package/lib/types/skins.js +172 -169
  47. package/package.json +16 -9
  48. package/src/styles/base.css +251 -5
  49. package/src/styles/default.css +315 -136
package/lib/charts.js CHANGED
@@ -19,30 +19,6 @@ function part(component, name) {
19
19
  };
20
20
  }
21
21
  //#endregion
22
- //#region lib/types/contract.js
23
- /** The stable region slots every layout may provide. */
24
- const UI_SLOT_IDS = {
25
- /** The one active layout of the operator window. */
26
- layout: "shell.layout",
27
- /** The operator titlebar. */
28
- titlebar: "shell.titlebar",
29
- /** Contributed titlebar actions. */
30
- titlebarActions: "shell.titlebar.actions",
31
- /** Sidebar extension area. */
32
- sidebar: "shell.sidebar",
33
- /** Statusbar extension area. */
34
- statusbar: "shell.statusbar",
35
- /** The global overlay stack (dialogs, confirms). */
36
- overlay: "shell.overlay",
37
- /** The floating ball surface face. */
38
- ball: "shell.ball",
39
- /** The settings trigger. */
40
- settingsEntry: "settings.entry",
41
- /** The settings surface itself. */
42
- settingsSurface: "settings.surface"
43
- };
44
- UI_SLOT_IDS.layout, UI_SLOT_IDS.titlebar, UI_SLOT_IDS.titlebarActions, UI_SLOT_IDS.sidebar, UI_SLOT_IDS.statusbar, UI_SLOT_IDS.overlay, UI_SLOT_IDS.ball, UI_SLOT_IDS.settingsEntry, UI_SLOT_IDS.settingsSurface;
45
- //#endregion
46
22
  //#region lib/types/skins.js
47
23
  /** The React context carrying the skin service. */
48
24
  const SkinsContext = createContext(null);
@@ -52,7 +28,7 @@ function useSkins() {
52
28
  if (service === null) throw new Error("useSkins: no SkinsProvider in the tree");
53
29
  return service;
54
30
  }
55
- /** Re-render on skin/mode changes and return the active token set. */
31
+ /** Re-render on theme changes and return the active token set. */
56
32
  function useSkinTokens() {
57
33
  const service = useSkins();
58
34
  useSyncExternalStore(service.subscribe, service.version, service.version);
@@ -74,6 +50,7 @@ function ChartFrame({ title, description, actions, state = "ready", empty, error
74
50
  ...part("chart-frame", "title"),
75
51
  children: title
76
52
  }), description !== void 0 && jsx("div", {
53
+ ...part("chart-frame", "description"),
77
54
  className: "snap-chart-frame-description",
78
55
  children: description
79
56
  })] }), actions !== void 0 && jsx("div", {
@@ -85,20 +62,20 @@ function ChartFrame({ title, description, actions, state = "ready", empty, error
85
62
  className: "snap-chart-frame-body",
86
63
  "data-state": state,
87
64
  children: state === "loading" ? loading ?? jsx("div", {
88
- ...part("visualization", "loading"),
65
+ ...part("chart-frame", "loading"),
89
66
  children: "加载中…"
90
67
  }) : state === "empty" ? empty ?? jsx("div", {
91
- ...part("visualization", "empty"),
68
+ ...part("chart-frame", "empty"),
92
69
  children: "暂无数据"
93
70
  }) : state === "error" ? error ?? jsx("div", {
94
- ...part("visualization", "error"),
71
+ ...part("chart-frame", "error"),
95
72
  role: "alert",
96
73
  children: "图表加载失败"
97
74
  }) : children
98
75
  })]
99
76
  });
100
77
  }
101
- /** A chart frame that exposes the `visualization.*` anatomy as well. */
78
+ /** An alias of {@link ChartFrame} for pages that prefer the generic name. */
102
79
  function Visualization(props) {
103
80
  return jsx(ChartFrame, { ...props });
104
81
  }
package/lib/contract.js CHANGED
@@ -106,7 +106,8 @@ const UI_COMPONENTS = {
106
106
  props: [
107
107
  "size",
108
108
  "invalid",
109
- "disabled"
109
+ "disabled",
110
+ "fieldClassName"
110
111
  ]
111
112
  },
112
113
  textarea: {
@@ -114,7 +115,8 @@ const UI_COMPONENTS = {
114
115
  props: [
115
116
  "size",
116
117
  "invalid",
117
- "disabled"
118
+ "disabled",
119
+ "fieldClassName"
118
120
  ]
119
121
  },
120
122
  "number-input": {
@@ -141,12 +143,14 @@ const UI_COMPONENTS = {
141
143
  "select.item-indicator",
142
144
  "select.empty"
143
145
  ],
144
- slots: ["empty"],
146
+ slots: ["empty", "children"],
145
147
  props: [
146
148
  "size",
147
149
  "invalid",
148
150
  "disabled",
149
- "presentation"
151
+ "defaultValue",
152
+ "side",
153
+ "align"
150
154
  ]
151
155
  },
152
156
  "touch-select": {
@@ -161,34 +165,49 @@ const UI_COMPONENTS = {
161
165
  checkbox: {
162
166
  parts: [
163
167
  "checkbox.root",
164
- "checkbox.box",
165
168
  "checkbox.indicator",
166
- "checkbox.label"
169
+ "checkbox.label",
170
+ "checkbox.field",
171
+ "checkbox.description"
167
172
  ],
168
- slots: ["label"],
173
+ slots: ["label", "description"],
169
174
  props: [
170
175
  "checked",
171
176
  "invalid",
172
- "disabled"
177
+ "disabled",
178
+ "labelPosition"
173
179
  ]
174
180
  },
175
181
  switch: {
176
182
  parts: [
177
183
  "switch.root",
178
184
  "switch.thumb",
179
- "switch.label"
185
+ "switch.label",
186
+ "switch.field",
187
+ "switch.description"
180
188
  ],
181
- slots: ["label"],
182
- props: ["checked", "disabled"]
189
+ slots: ["label", "description"],
190
+ props: [
191
+ "checked",
192
+ "disabled",
193
+ "labelPosition"
194
+ ]
183
195
  },
184
196
  "radio-group": {
185
197
  parts: [
186
198
  "radio-group.root",
187
199
  "radio-group.item",
188
200
  "radio-group.indicator",
189
- "radio-group.label"
201
+ "radio-group.label",
202
+ "radio-group.block",
203
+ "radio-group.description"
190
204
  ],
191
- props: ["value", "disabled"]
205
+ props: [
206
+ "value",
207
+ "disabled",
208
+ "label",
209
+ "description"
210
+ ]
192
211
  },
193
212
  tabs: {
194
213
  parts: [
@@ -198,7 +217,7 @@ const UI_COMPONENTS = {
198
217
  "tabs.content"
199
218
  ],
200
219
  slots: ["list", "content"],
201
- props: ["value", "presentation"]
220
+ props: ["value"]
202
221
  },
203
222
  table: {
204
223
  parts: [
@@ -246,7 +265,6 @@ const UI_COMPONENTS = {
246
265
  },
247
266
  dialog: {
248
267
  parts: [
249
- "dialog.root",
250
268
  "dialog.overlay",
251
269
  "dialog.panel",
252
270
  "dialog.header",
@@ -271,12 +289,13 @@ const UI_COMPONENTS = {
271
289
  },
272
290
  sheet: {
273
291
  parts: [
274
- "sheet.root",
275
- "sheet.overlay",
276
- "sheet.panel",
277
- "sheet.header",
278
- "sheet.body",
279
- "sheet.footer"
292
+ "dialog.overlay",
293
+ "dialog.panel",
294
+ "dialog.header",
295
+ "dialog.title",
296
+ "dialog.description",
297
+ "dialog.body",
298
+ "dialog.footer"
280
299
  ],
281
300
  slots: [
282
301
  "header",
@@ -286,27 +305,20 @@ const UI_COMPONENTS = {
286
305
  props: ["open", "presentation"]
287
306
  },
288
307
  popover: {
289
- parts: [
290
- "popover.root",
291
- "popover.trigger",
292
- "popover.content"
293
- ],
308
+ parts: ["popover.trigger", "popover.content"],
294
309
  slots: ["trigger", "content"]
295
310
  },
296
311
  tooltip: {
297
- parts: [
298
- "tooltip.root",
299
- "tooltip.trigger",
300
- "tooltip.content"
301
- ],
312
+ parts: ["tooltip.trigger", "tooltip.content"],
302
313
  slots: ["trigger", "content"]
303
314
  },
304
315
  menu: {
305
316
  parts: [
306
- "menu.root",
307
317
  "menu.trigger",
308
318
  "menu.content",
309
319
  "menu.item",
320
+ "menu.checkbox-item",
321
+ "menu.item-indicator",
310
322
  "menu.separator"
311
323
  ],
312
324
  slots: ["trigger", "content"]
@@ -317,7 +329,8 @@ const UI_COMPONENTS = {
317
329
  "toast.title",
318
330
  "toast.description",
319
331
  "toast.action",
320
- "toast.close"
332
+ "toast.close",
333
+ "toast.viewport"
321
334
  ],
322
335
  slots: ["action"]
323
336
  },
@@ -331,6 +344,52 @@ const UI_COMPONENTS = {
331
344
  parts: ["led.root", "led.halo"],
332
345
  props: ["tone"]
333
346
  },
347
+ alert: {
348
+ parts: [
349
+ "alert.root",
350
+ "alert.title",
351
+ "alert.description"
352
+ ],
353
+ slots: ["title", "description"],
354
+ props: ["intent"]
355
+ },
356
+ separator: {
357
+ parts: ["separator.root"],
358
+ props: ["orientation"]
359
+ },
360
+ skeleton: {
361
+ parts: ["skeleton.root"],
362
+ props: ["variant"]
363
+ },
364
+ list: {
365
+ parts: [
366
+ "list.root",
367
+ "list.item",
368
+ "list.leading",
369
+ "list.content",
370
+ "list.trailing"
371
+ ],
372
+ slots: ["leading", "trailing"],
373
+ props: [
374
+ "divided",
375
+ "selected",
376
+ "disabled"
377
+ ]
378
+ },
379
+ slider: {
380
+ parts: [
381
+ "slider.root",
382
+ "slider.track",
383
+ "slider.range",
384
+ "slider.thumb"
385
+ ],
386
+ props: [
387
+ "value",
388
+ "min",
389
+ "max",
390
+ "step"
391
+ ]
392
+ },
334
393
  spinner: { parts: ["spinner.root"] },
335
394
  "empty-state": {
336
395
  parts: [
@@ -353,7 +412,13 @@ const UI_COMPONENTS = {
353
412
  "form.fields",
354
413
  "form.actions"
355
414
  ],
356
- slots: ["fields", "actions"]
415
+ slots: ["fields", "actions"],
416
+ props: [
417
+ "orientation",
418
+ "gap",
419
+ "columns",
420
+ "form"
421
+ ]
357
422
  },
358
423
  field: {
359
424
  parts: [
@@ -372,12 +437,15 @@ const UI_COMPONENTS = {
372
437
  props: [
373
438
  "invalid",
374
439
  "required",
375
- "disabled"
440
+ "orientation",
441
+ "labelWidth",
442
+ "labelAlign"
376
443
  ]
377
444
  },
378
445
  "schema-form": {
379
446
  parts: ["schema-form.root", "schema-form.field"],
380
- slots: ["fields"]
447
+ slots: ["fields"],
448
+ props: ["columns"]
381
449
  },
382
450
  "app-shell": {
383
451
  parts: [
@@ -430,6 +498,7 @@ const UI_COMPONENTS = {
430
498
  parts: [
431
499
  "toolbar.root",
432
500
  "toolbar.start",
501
+ "toolbar.center",
433
502
  "toolbar.end"
434
503
  ],
435
504
  slots: ["start", "end"]
@@ -470,23 +539,26 @@ const UI_COMPONENTS = {
470
539
  "scroll-area": { parts: [
471
540
  "scroll-area.root",
472
541
  "scroll-area.viewport",
473
- "scroll-area.scrollbar"
542
+ "scroll-area.scrollbar",
543
+ "scroll-area.thumb"
474
544
  ] },
475
545
  "drag-scroll": { parts: ["drag-scroll.root", "drag-scroll.viewport"] },
476
- visualization: {
546
+ "chart-frame": {
477
547
  parts: [
478
- "visualization.root",
479
- "visualization.header",
480
- "visualization.title",
481
- "visualization.actions",
482
- "visualization.body",
483
- "visualization.empty",
484
- "visualization.error",
485
- "visualization.loading"
548
+ "chart-frame.root",
549
+ "chart-frame.header",
550
+ "chart-frame.title",
551
+ "chart-frame.description",
552
+ "chart-frame.actions",
553
+ "chart-frame.body",
554
+ "chart-frame.loading",
555
+ "chart-frame.empty",
556
+ "chart-frame.error"
486
557
  ],
487
558
  slots: [
488
559
  "header",
489
560
  "title",
561
+ "description",
490
562
  "actions",
491
563
  "body",
492
564
  "empty",
@@ -495,21 +567,6 @@ const UI_COMPONENTS = {
495
567
  ],
496
568
  props: ["state"]
497
569
  },
498
- "chart-frame": {
499
- parts: [
500
- "chart-frame.root",
501
- "chart-frame.header",
502
- "chart-frame.title",
503
- "chart-frame.actions",
504
- "chart-frame.body"
505
- ],
506
- slots: [
507
- "header",
508
- "title",
509
- "actions",
510
- "body"
511
- ]
512
- },
513
570
  settings: { parts: [
514
571
  "settings.root",
515
572
  "settings.header",
@@ -523,21 +580,5 @@ const UI_COMPONENTS = {
523
580
  "settings.content"
524
581
  ] }
525
582
  };
526
- /** The presentation targets a skin may tune. */
527
- const PRESENTATION_TARGETS = [
528
- "dialog",
529
- "select",
530
- "tabs",
531
- "toast"
532
- ];
533
- /** The presentation variants the core implements. */
534
- const PRESENTATION_VARIANTS = [
535
- "modal",
536
- "sheet",
537
- "fullscreen",
538
- "popover",
539
- "segmented",
540
- "inline"
541
- ];
542
583
  //#endregion
543
- export { CUSTOM_SLOT_PATTERN, PRESENTATION_TARGETS, PRESENTATION_VARIANTS, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, isValidSlotId };
584
+ export { CUSTOM_SLOT_PATTERN, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, isValidSlotId };
package/lib/fallback.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import "@radix-ui/react-separator";
2
3
  import { Slot } from "@radix-ui/react-slot";
3
4
  import "@radix-ui/react-checkbox";
4
5
  import "@radix-ui/react-label";
@@ -8,6 +9,14 @@ import "@radix-ui/react-switch";
8
9
  import "@radix-ui/react-tabs";
9
10
  import { Component, createContext, useContext, useSyncExternalStore } from "react";
10
11
  import "@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
  //#region lib/types/utils.js
12
21
  /**
13
22
  * Small helpers shared by the headless semantic components: class merging and
@@ -139,6 +148,8 @@ function EmptyState({ title, description, icon, action, className }) {
139
148
  ]
140
149
  });
141
150
  }
151
+ createContext(null);
152
+ createContext(null);
142
153
  //#endregion
143
154
  //#region lib/types/components/layout.js
144
155
  /** The operator-window shell frame. */
@@ -354,7 +365,6 @@ function FallbackShell(props) {
354
365
  },
355
366
  children: jsx(EmptyState, {
356
367
  title: "尚未激活业务套件",
357
- description: "打开设置的「插件管理」页,安装并启用一个业务套件;驱动也在同一处安装。",
358
368
  action: jsx(Button, {
359
369
  intent: "primary",
360
370
  onClick: () => props.ctx.settings.open("plugins"),