@snap-rail/ui 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/charts.js +12 -5
- package/lib/components/index.js +2195 -0
- package/lib/contract.js +138 -62
- package/lib/fallback.js +21 -4
- package/lib/index.js +4287 -261
- package/lib/runtime.js +206 -77
- package/lib/settings-pages/index.js +1326 -0
- package/lib/settings.js +122 -72
- package/lib/types/charts.d.ts +1 -1
- package/lib/types/charts.js +5 -5
- package/lib/types/components/alert.d.ts +57 -0
- package/lib/types/components/alert.js +46 -0
- package/lib/types/components/button.js +2 -2
- package/lib/types/components/combobox.d.ts +45 -0
- package/lib/types/components/combobox.js +108 -0
- package/lib/types/components/controls.d.ts +74 -11
- package/lib/types/components/controls.js +67 -24
- package/lib/types/components/dialog.js +1 -1
- package/lib/types/components/form-rhf.d.ts +56 -0
- package/lib/types/components/form-rhf.js +74 -0
- package/lib/types/components/form.d.ts +33 -5
- package/lib/types/components/form.js +22 -6
- package/lib/types/components/index.d.ts +8 -0
- package/lib/types/components/index.js +8 -0
- package/lib/types/components/input.d.ts +11 -5
- package/lib/types/components/input.js +34 -7
- package/lib/types/components/layout.d.ts +28 -6
- package/lib/types/components/layout.js +86 -13
- package/lib/types/components/overlay.d.ts +110 -0
- package/lib/types/components/overlay.js +185 -0
- package/lib/types/components/schema-form.d.ts +3 -1
- package/lib/types/components/schema-form.js +46 -40
- package/lib/types/components/slider.d.ts +18 -0
- package/lib/types/components/slider.js +15 -0
- package/lib/types/components/surface.js +12 -12
- package/lib/types/contract.d.ts +55 -30
- package/lib/types/contract.js +55 -30
- package/lib/types/runtime.js +3 -2
- package/lib/types/settings-pages/appearance.js +2 -2
- package/lib/types/settings-pages/plugins.js +2 -2
- package/lib/types/utils.d.ts +7 -1
- package/lib/types/utils.js +7 -1
- package/package.json +14 -7
- package/src/styles/base.css +315 -5
- package/src/styles/default.css +194 -6
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
|
-
"
|
|
151
|
+
"defaultValue",
|
|
152
|
+
"side",
|
|
153
|
+
"align"
|
|
150
154
|
]
|
|
151
155
|
},
|
|
152
156
|
"touch-select": {
|
|
@@ -154,41 +158,75 @@ const UI_COMPONENTS = {
|
|
|
154
158
|
"touch-select.root",
|
|
155
159
|
"touch-select.trigger",
|
|
156
160
|
"touch-select.sheet",
|
|
157
|
-
"touch-select.
|
|
161
|
+
"touch-select.options"
|
|
158
162
|
],
|
|
159
163
|
props: ["invalid", "disabled"]
|
|
160
164
|
},
|
|
165
|
+
combobox: {
|
|
166
|
+
parts: [
|
|
167
|
+
"combobox.root",
|
|
168
|
+
"combobox.anchor",
|
|
169
|
+
"combobox.list",
|
|
170
|
+
"combobox.option",
|
|
171
|
+
"combobox.empty"
|
|
172
|
+
],
|
|
173
|
+
slots: ["empty"],
|
|
174
|
+
props: [
|
|
175
|
+
"value",
|
|
176
|
+
"options",
|
|
177
|
+
"size",
|
|
178
|
+
"invalid",
|
|
179
|
+
"disabled",
|
|
180
|
+
"loading",
|
|
181
|
+
"onInputValueChange"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
161
184
|
checkbox: {
|
|
162
185
|
parts: [
|
|
163
186
|
"checkbox.root",
|
|
164
|
-
"checkbox.box",
|
|
165
187
|
"checkbox.indicator",
|
|
166
|
-
"checkbox.label"
|
|
188
|
+
"checkbox.label",
|
|
189
|
+
"checkbox.field",
|
|
190
|
+
"checkbox.description"
|
|
167
191
|
],
|
|
168
|
-
slots: ["label"],
|
|
192
|
+
slots: ["label", "description"],
|
|
169
193
|
props: [
|
|
170
194
|
"checked",
|
|
171
195
|
"invalid",
|
|
172
|
-
"disabled"
|
|
196
|
+
"disabled",
|
|
197
|
+
"labelPosition"
|
|
173
198
|
]
|
|
174
199
|
},
|
|
175
200
|
switch: {
|
|
176
201
|
parts: [
|
|
177
202
|
"switch.root",
|
|
178
203
|
"switch.thumb",
|
|
179
|
-
"switch.label"
|
|
204
|
+
"switch.label",
|
|
205
|
+
"switch.field",
|
|
206
|
+
"switch.description"
|
|
180
207
|
],
|
|
181
|
-
slots: ["label"],
|
|
182
|
-
props: [
|
|
208
|
+
slots: ["label", "description"],
|
|
209
|
+
props: [
|
|
210
|
+
"checked",
|
|
211
|
+
"disabled",
|
|
212
|
+
"labelPosition"
|
|
213
|
+
]
|
|
183
214
|
},
|
|
184
215
|
"radio-group": {
|
|
185
216
|
parts: [
|
|
186
217
|
"radio-group.root",
|
|
187
218
|
"radio-group.item",
|
|
188
219
|
"radio-group.indicator",
|
|
189
|
-
"radio-group.label"
|
|
220
|
+
"radio-group.label",
|
|
221
|
+
"radio-group.block",
|
|
222
|
+
"radio-group.description"
|
|
190
223
|
],
|
|
191
|
-
props: [
|
|
224
|
+
props: [
|
|
225
|
+
"value",
|
|
226
|
+
"disabled",
|
|
227
|
+
"label",
|
|
228
|
+
"description"
|
|
229
|
+
]
|
|
192
230
|
},
|
|
193
231
|
tabs: {
|
|
194
232
|
parts: [
|
|
@@ -198,7 +236,7 @@ const UI_COMPONENTS = {
|
|
|
198
236
|
"tabs.content"
|
|
199
237
|
],
|
|
200
238
|
slots: ["list", "content"],
|
|
201
|
-
props: ["value"
|
|
239
|
+
props: ["value"]
|
|
202
240
|
},
|
|
203
241
|
table: {
|
|
204
242
|
parts: [
|
|
@@ -246,7 +284,6 @@ const UI_COMPONENTS = {
|
|
|
246
284
|
},
|
|
247
285
|
dialog: {
|
|
248
286
|
parts: [
|
|
249
|
-
"dialog.root",
|
|
250
287
|
"dialog.overlay",
|
|
251
288
|
"dialog.panel",
|
|
252
289
|
"dialog.header",
|
|
@@ -271,12 +308,13 @@ const UI_COMPONENTS = {
|
|
|
271
308
|
},
|
|
272
309
|
sheet: {
|
|
273
310
|
parts: [
|
|
274
|
-
"
|
|
275
|
-
"
|
|
276
|
-
"
|
|
277
|
-
"
|
|
278
|
-
"
|
|
279
|
-
"
|
|
311
|
+
"dialog.overlay",
|
|
312
|
+
"dialog.panel",
|
|
313
|
+
"dialog.header",
|
|
314
|
+
"dialog.title",
|
|
315
|
+
"dialog.description",
|
|
316
|
+
"dialog.body",
|
|
317
|
+
"dialog.footer"
|
|
280
318
|
],
|
|
281
319
|
slots: [
|
|
282
320
|
"header",
|
|
@@ -286,27 +324,20 @@ const UI_COMPONENTS = {
|
|
|
286
324
|
props: ["open", "presentation"]
|
|
287
325
|
},
|
|
288
326
|
popover: {
|
|
289
|
-
parts: [
|
|
290
|
-
"popover.root",
|
|
291
|
-
"popover.trigger",
|
|
292
|
-
"popover.content"
|
|
293
|
-
],
|
|
327
|
+
parts: ["popover.trigger", "popover.content"],
|
|
294
328
|
slots: ["trigger", "content"]
|
|
295
329
|
},
|
|
296
330
|
tooltip: {
|
|
297
|
-
parts: [
|
|
298
|
-
"tooltip.root",
|
|
299
|
-
"tooltip.trigger",
|
|
300
|
-
"tooltip.content"
|
|
301
|
-
],
|
|
331
|
+
parts: ["tooltip.trigger", "tooltip.content"],
|
|
302
332
|
slots: ["trigger", "content"]
|
|
303
333
|
},
|
|
304
334
|
menu: {
|
|
305
335
|
parts: [
|
|
306
|
-
"menu.root",
|
|
307
336
|
"menu.trigger",
|
|
308
337
|
"menu.content",
|
|
309
338
|
"menu.item",
|
|
339
|
+
"menu.checkbox-item",
|
|
340
|
+
"menu.item-indicator",
|
|
310
341
|
"menu.separator"
|
|
311
342
|
],
|
|
312
343
|
slots: ["trigger", "content"]
|
|
@@ -317,7 +348,8 @@ const UI_COMPONENTS = {
|
|
|
317
348
|
"toast.title",
|
|
318
349
|
"toast.description",
|
|
319
350
|
"toast.action",
|
|
320
|
-
"toast.close"
|
|
351
|
+
"toast.close",
|
|
352
|
+
"toast.viewport"
|
|
321
353
|
],
|
|
322
354
|
slots: ["action"]
|
|
323
355
|
},
|
|
@@ -331,6 +363,52 @@ const UI_COMPONENTS = {
|
|
|
331
363
|
parts: ["led.root", "led.halo"],
|
|
332
364
|
props: ["tone"]
|
|
333
365
|
},
|
|
366
|
+
alert: {
|
|
367
|
+
parts: [
|
|
368
|
+
"alert.root",
|
|
369
|
+
"alert.title",
|
|
370
|
+
"alert.description"
|
|
371
|
+
],
|
|
372
|
+
slots: ["title", "description"],
|
|
373
|
+
props: ["intent"]
|
|
374
|
+
},
|
|
375
|
+
separator: {
|
|
376
|
+
parts: ["separator.root"],
|
|
377
|
+
props: ["orientation"]
|
|
378
|
+
},
|
|
379
|
+
skeleton: {
|
|
380
|
+
parts: ["skeleton.root"],
|
|
381
|
+
props: ["variant"]
|
|
382
|
+
},
|
|
383
|
+
list: {
|
|
384
|
+
parts: [
|
|
385
|
+
"list.root",
|
|
386
|
+
"list.item",
|
|
387
|
+
"list.leading",
|
|
388
|
+
"list.content",
|
|
389
|
+
"list.trailing"
|
|
390
|
+
],
|
|
391
|
+
slots: ["leading", "trailing"],
|
|
392
|
+
props: [
|
|
393
|
+
"divided",
|
|
394
|
+
"selected",
|
|
395
|
+
"disabled"
|
|
396
|
+
]
|
|
397
|
+
},
|
|
398
|
+
slider: {
|
|
399
|
+
parts: [
|
|
400
|
+
"slider.root",
|
|
401
|
+
"slider.track",
|
|
402
|
+
"slider.range",
|
|
403
|
+
"slider.thumb"
|
|
404
|
+
],
|
|
405
|
+
props: [
|
|
406
|
+
"value",
|
|
407
|
+
"min",
|
|
408
|
+
"max",
|
|
409
|
+
"step"
|
|
410
|
+
]
|
|
411
|
+
},
|
|
334
412
|
spinner: { parts: ["spinner.root"] },
|
|
335
413
|
"empty-state": {
|
|
336
414
|
parts: [
|
|
@@ -353,7 +431,13 @@ const UI_COMPONENTS = {
|
|
|
353
431
|
"form.fields",
|
|
354
432
|
"form.actions"
|
|
355
433
|
],
|
|
356
|
-
slots: ["fields", "actions"]
|
|
434
|
+
slots: ["fields", "actions"],
|
|
435
|
+
props: [
|
|
436
|
+
"orientation",
|
|
437
|
+
"gap",
|
|
438
|
+
"columns",
|
|
439
|
+
"form"
|
|
440
|
+
]
|
|
357
441
|
},
|
|
358
442
|
field: {
|
|
359
443
|
parts: [
|
|
@@ -372,12 +456,15 @@ const UI_COMPONENTS = {
|
|
|
372
456
|
props: [
|
|
373
457
|
"invalid",
|
|
374
458
|
"required",
|
|
375
|
-
"
|
|
459
|
+
"orientation",
|
|
460
|
+
"labelWidth",
|
|
461
|
+
"labelAlign"
|
|
376
462
|
]
|
|
377
463
|
},
|
|
378
464
|
"schema-form": {
|
|
379
465
|
parts: ["schema-form.root", "schema-form.field"],
|
|
380
|
-
slots: ["fields"]
|
|
466
|
+
slots: ["fields"],
|
|
467
|
+
props: ["columns"]
|
|
381
468
|
},
|
|
382
469
|
"app-shell": {
|
|
383
470
|
parts: [
|
|
@@ -430,6 +517,7 @@ const UI_COMPONENTS = {
|
|
|
430
517
|
parts: [
|
|
431
518
|
"toolbar.root",
|
|
432
519
|
"toolbar.start",
|
|
520
|
+
"toolbar.center",
|
|
433
521
|
"toolbar.end"
|
|
434
522
|
],
|
|
435
523
|
slots: ["start", "end"]
|
|
@@ -470,23 +558,26 @@ const UI_COMPONENTS = {
|
|
|
470
558
|
"scroll-area": { parts: [
|
|
471
559
|
"scroll-area.root",
|
|
472
560
|
"scroll-area.viewport",
|
|
473
|
-
"scroll-area.scrollbar"
|
|
561
|
+
"scroll-area.scrollbar",
|
|
562
|
+
"scroll-area.thumb"
|
|
474
563
|
] },
|
|
475
564
|
"drag-scroll": { parts: ["drag-scroll.root", "drag-scroll.viewport"] },
|
|
476
|
-
|
|
565
|
+
"chart-frame": {
|
|
477
566
|
parts: [
|
|
478
|
-
"
|
|
479
|
-
"
|
|
480
|
-
"
|
|
481
|
-
"
|
|
482
|
-
"
|
|
483
|
-
"
|
|
484
|
-
"
|
|
485
|
-
"
|
|
567
|
+
"chart-frame.root",
|
|
568
|
+
"chart-frame.header",
|
|
569
|
+
"chart-frame.title",
|
|
570
|
+
"chart-frame.description",
|
|
571
|
+
"chart-frame.actions",
|
|
572
|
+
"chart-frame.body",
|
|
573
|
+
"chart-frame.loading",
|
|
574
|
+
"chart-frame.empty",
|
|
575
|
+
"chart-frame.error"
|
|
486
576
|
],
|
|
487
577
|
slots: [
|
|
488
578
|
"header",
|
|
489
579
|
"title",
|
|
580
|
+
"description",
|
|
490
581
|
"actions",
|
|
491
582
|
"body",
|
|
492
583
|
"empty",
|
|
@@ -495,21 +586,6 @@ const UI_COMPONENTS = {
|
|
|
495
586
|
],
|
|
496
587
|
props: ["state"]
|
|
497
588
|
},
|
|
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
589
|
settings: { parts: [
|
|
514
590
|
"settings.root",
|
|
515
591
|
"settings.header",
|
package/lib/fallback.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
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";
|
|
4
|
+
import { Component, createContext, useContext, useSyncExternalStore } from "react";
|
|
5
|
+
import "@radix-ui/react-dropdown-menu";
|
|
6
|
+
import "@radix-ui/react-popover";
|
|
7
|
+
import "@radix-ui/react-toast";
|
|
8
|
+
import "@radix-ui/react-tooltip";
|
|
3
9
|
import "@radix-ui/react-checkbox";
|
|
4
10
|
import "@radix-ui/react-label";
|
|
5
11
|
import "@radix-ui/react-radio-group";
|
|
6
12
|
import "@radix-ui/react-select";
|
|
7
13
|
import "@radix-ui/react-switch";
|
|
8
14
|
import "@radix-ui/react-tabs";
|
|
9
|
-
import { Component, createContext, useContext, useSyncExternalStore } from "react";
|
|
10
15
|
import "@radix-ui/react-dialog";
|
|
16
|
+
import "react-hook-form";
|
|
17
|
+
import "@hookform/resolvers/zod";
|
|
18
|
+
import "@radix-ui/react-scroll-area";
|
|
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
|
|
@@ -19,7 +28,13 @@ import "@radix-ui/react-dialog";
|
|
|
19
28
|
function cn(...values) {
|
|
20
29
|
return values.filter((value) => typeof value === "string" && value.length > 0).join(" ");
|
|
21
30
|
}
|
|
22
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The anatomy attributes every semantic component renders. The identity is
|
|
33
|
+
* component-owned: components spread these AFTER caller props so a composite
|
|
34
|
+
* can never mask a host part (a masked `button.root` loses every skin rule
|
|
35
|
+
* and falls back to the UA default look). Composites tag their own wrappers
|
|
36
|
+
* instead of pushing `part()` into a child component's props.
|
|
37
|
+
*/
|
|
23
38
|
function part(component, name) {
|
|
24
39
|
return {
|
|
25
40
|
"data-snap-component": component,
|
|
@@ -78,7 +93,6 @@ function Button({ intent = "neutral", emphasis = "solid", size = "md", loading =
|
|
|
78
93
|
loading && jsx(Spinner, {})
|
|
79
94
|
] });
|
|
80
95
|
return jsx(Component, {
|
|
81
|
-
...part("button", "root"),
|
|
82
96
|
...type !== void 0 ? { type } : !asChild ? { type: "button" } : {},
|
|
83
97
|
className: cn("snap-button", className),
|
|
84
98
|
"data-intent": intent,
|
|
@@ -89,13 +103,13 @@ function Button({ intent = "neutral", emphasis = "solid", size = "md", loading =
|
|
|
89
103
|
"aria-busy": loading || void 0,
|
|
90
104
|
disabled: !asChild ? disabled === true || loading : void 0,
|
|
91
105
|
...props,
|
|
106
|
+
...part("button", "root"),
|
|
92
107
|
children: content
|
|
93
108
|
});
|
|
94
109
|
}
|
|
95
110
|
/** A square glyph button with a mandatory accessible label. */
|
|
96
111
|
function IconButton({ icon, label, active = false, intent = "neutral", emphasis = "ghost", size = "md", className, ...props }) {
|
|
97
112
|
return jsx("button", {
|
|
98
|
-
...part("icon-button", "root"),
|
|
99
113
|
type: "button",
|
|
100
114
|
className: cn("snap-icon-button", className),
|
|
101
115
|
"data-intent": intent,
|
|
@@ -105,6 +119,7 @@ function IconButton({ icon, label, active = false, intent = "neutral", emphasis
|
|
|
105
119
|
"aria-label": label,
|
|
106
120
|
"aria-pressed": active || void 0,
|
|
107
121
|
...props,
|
|
122
|
+
...part("icon-button", "root"),
|
|
108
123
|
children: jsx("span", {
|
|
109
124
|
...part("icon-button", "icon"),
|
|
110
125
|
"aria-hidden": "true",
|
|
@@ -139,6 +154,8 @@ function EmptyState({ title, description, icon, action, className }) {
|
|
|
139
154
|
]
|
|
140
155
|
});
|
|
141
156
|
}
|
|
157
|
+
createContext(null);
|
|
158
|
+
createContext(null);
|
|
142
159
|
//#endregion
|
|
143
160
|
//#region lib/types/components/layout.js
|
|
144
161
|
/** The operator-window shell frame. */
|