@safe-ugc-ui/types 0.5.1 → 1.0.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/dist/index.d.ts +119191 -46657
- package/dist/index.js +334 -173
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,21 @@ import { z } from "zod";
|
|
|
3
3
|
var refSchema = z.object({
|
|
4
4
|
$ref: z.string()
|
|
5
5
|
});
|
|
6
|
+
var templatePartSchema = z.union([
|
|
7
|
+
z.string(),
|
|
8
|
+
z.number(),
|
|
9
|
+
z.boolean(),
|
|
10
|
+
z.null(),
|
|
11
|
+
refSchema
|
|
12
|
+
]);
|
|
13
|
+
var templateValueSchema = z.object({
|
|
14
|
+
$template: z.array(templatePartSchema).min(1)
|
|
15
|
+
}).strict();
|
|
16
|
+
var templatedStringSchema = z.union([
|
|
17
|
+
z.string(),
|
|
18
|
+
refSchema,
|
|
19
|
+
templateValueSchema
|
|
20
|
+
]);
|
|
6
21
|
var assetPathSchema = z.string().startsWith("@assets/");
|
|
7
22
|
var colorSchema = z.string();
|
|
8
23
|
var lengthSchema = z.union([z.number(), z.string()]);
|
|
@@ -20,12 +35,58 @@ function isRef(value) {
|
|
|
20
35
|
function isDynamic(value) {
|
|
21
36
|
return isRef(value);
|
|
22
37
|
}
|
|
38
|
+
function isTemplateValue(value) {
|
|
39
|
+
return typeof value === "object" && value !== null && "$template" in value && Array.isArray(value.$template);
|
|
40
|
+
}
|
|
23
41
|
function isAssetPath(value) {
|
|
24
42
|
return typeof value === "string" && value.startsWith("@assets/");
|
|
25
43
|
}
|
|
26
44
|
|
|
27
|
-
// src/
|
|
45
|
+
// src/conditions.ts
|
|
28
46
|
import { z as z2 } from "zod";
|
|
47
|
+
var conditionOperandLiteralSchema = z2.union([
|
|
48
|
+
z2.string(),
|
|
49
|
+
z2.number(),
|
|
50
|
+
z2.boolean(),
|
|
51
|
+
z2.null()
|
|
52
|
+
]);
|
|
53
|
+
var conditionOperandSchema = z2.union([
|
|
54
|
+
conditionOperandLiteralSchema,
|
|
55
|
+
refSchema
|
|
56
|
+
]);
|
|
57
|
+
var comparisonConditionOpSchema = z2.enum([
|
|
58
|
+
"eq",
|
|
59
|
+
"ne",
|
|
60
|
+
"gt",
|
|
61
|
+
"gte",
|
|
62
|
+
"lt",
|
|
63
|
+
"lte"
|
|
64
|
+
]);
|
|
65
|
+
var comparisonConditionSchema = z2.object({
|
|
66
|
+
op: comparisonConditionOpSchema,
|
|
67
|
+
left: conditionOperandSchema,
|
|
68
|
+
right: conditionOperandSchema
|
|
69
|
+
});
|
|
70
|
+
var conditionSchema = z2.lazy(() => z2.union([
|
|
71
|
+
z2.boolean(),
|
|
72
|
+
refSchema,
|
|
73
|
+
z2.object({
|
|
74
|
+
op: z2.literal("not"),
|
|
75
|
+
value: conditionSchema
|
|
76
|
+
}),
|
|
77
|
+
z2.object({
|
|
78
|
+
op: z2.literal("and"),
|
|
79
|
+
values: z2.array(conditionSchema).min(1)
|
|
80
|
+
}),
|
|
81
|
+
z2.object({
|
|
82
|
+
op: z2.literal("or"),
|
|
83
|
+
values: z2.array(conditionSchema).min(1)
|
|
84
|
+
}),
|
|
85
|
+
comparisonConditionSchema
|
|
86
|
+
]));
|
|
87
|
+
|
|
88
|
+
// src/styles.ts
|
|
89
|
+
import { z as z3 } from "zod";
|
|
29
90
|
|
|
30
91
|
// src/constants.ts
|
|
31
92
|
var CARD_JSON_MAX_BYTES = 1e6;
|
|
@@ -34,10 +95,13 @@ var STYLE_OBJECTS_TOTAL_MAX_BYTES = 1e5;
|
|
|
34
95
|
var ASSET_INDIVIDUAL_MAX_BYTES = 5e6;
|
|
35
96
|
var ASSET_TOTAL_MAX_BYTES = 5e7;
|
|
36
97
|
var MAX_NODE_COUNT = 1e4;
|
|
98
|
+
var MAX_INTERACTIVE_ITEMS = 16;
|
|
37
99
|
var MAX_LOOP_ITERATIONS = 1e3;
|
|
38
100
|
var MAX_NESTED_LOOPS = 2;
|
|
101
|
+
var MAX_CONDITION_DEPTH = 5;
|
|
39
102
|
var MAX_OVERFLOW_AUTO_COUNT = 2;
|
|
40
103
|
var MAX_STACK_NESTING = 3;
|
|
104
|
+
var COMPACT_BREAKPOINT_MAX_WIDTH = 480;
|
|
41
105
|
var ZINDEX_MIN = 0;
|
|
42
106
|
var ZINDEX_MAX = 100;
|
|
43
107
|
var TRANSFORM_SCALE_MIN = 0.1;
|
|
@@ -54,6 +118,7 @@ var ALLOWED_FONT_FAMILIES = [
|
|
|
54
118
|
"display",
|
|
55
119
|
"handwriting"
|
|
56
120
|
];
|
|
121
|
+
var ASPECT_RATIO_PATTERN = /^\s*[0-9]+(\.[0-9]+)?\s*\/\s*[0-9]+(\.[0-9]+)?\s*$/;
|
|
57
122
|
var TEXT_SHADOW_MAX_COUNT = 5;
|
|
58
123
|
var TEXT_SHADOW_BLUR_MAX = 100;
|
|
59
124
|
var BOX_SHADOW_MAX_COUNT = 5;
|
|
@@ -149,7 +214,9 @@ var ALL_COMPONENT_TYPES = [
|
|
|
149
214
|
"Chip",
|
|
150
215
|
// 2.4 Interaction (optional)
|
|
151
216
|
"Button",
|
|
152
|
-
"Toggle"
|
|
217
|
+
"Toggle",
|
|
218
|
+
"Accordion",
|
|
219
|
+
"Tabs"
|
|
153
220
|
];
|
|
154
221
|
var FORBIDDEN_STYLE_PROPERTIES = [
|
|
155
222
|
"backgroundImage",
|
|
@@ -330,71 +397,71 @@ var CSS_NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
|
330
397
|
]);
|
|
331
398
|
|
|
332
399
|
// src/styles.ts
|
|
333
|
-
var gradientStopSchema =
|
|
334
|
-
color: dynamicSchema(
|
|
335
|
-
position: dynamicSchema(
|
|
400
|
+
var gradientStopSchema = z3.object({
|
|
401
|
+
color: dynamicSchema(z3.string()),
|
|
402
|
+
position: dynamicSchema(z3.string())
|
|
336
403
|
// e.g. "0%", "100%"
|
|
337
404
|
});
|
|
338
|
-
var linearGradientSchema =
|
|
339
|
-
type:
|
|
340
|
-
direction: dynamicSchema(
|
|
405
|
+
var linearGradientSchema = z3.object({
|
|
406
|
+
type: z3.literal("linear"),
|
|
407
|
+
direction: dynamicSchema(z3.string()),
|
|
341
408
|
// e.g. "135deg", "to right"
|
|
342
|
-
stops:
|
|
409
|
+
stops: z3.array(gradientStopSchema)
|
|
343
410
|
});
|
|
344
|
-
var radialGradientSchema =
|
|
345
|
-
type:
|
|
346
|
-
stops:
|
|
411
|
+
var radialGradientSchema = z3.object({
|
|
412
|
+
type: z3.literal("radial"),
|
|
413
|
+
stops: z3.array(gradientStopSchema)
|
|
347
414
|
});
|
|
348
|
-
var repeatingLinearGradientSchema =
|
|
349
|
-
type:
|
|
350
|
-
direction: dynamicSchema(
|
|
415
|
+
var repeatingLinearGradientSchema = z3.object({
|
|
416
|
+
type: z3.literal("repeating-linear"),
|
|
417
|
+
direction: dynamicSchema(z3.string()),
|
|
351
418
|
// e.g. "180deg"
|
|
352
|
-
stops:
|
|
419
|
+
stops: z3.array(gradientStopSchema)
|
|
353
420
|
});
|
|
354
|
-
var gradientObjectSchema =
|
|
421
|
+
var gradientObjectSchema = z3.union([
|
|
355
422
|
linearGradientSchema,
|
|
356
423
|
radialGradientSchema,
|
|
357
424
|
repeatingLinearGradientSchema
|
|
358
425
|
]);
|
|
359
|
-
var shadowObjectSchema =
|
|
360
|
-
offsetX: dynamicSchema(
|
|
361
|
-
offsetY: dynamicSchema(
|
|
362
|
-
blur: dynamicSchema(
|
|
363
|
-
spread: dynamicSchema(
|
|
364
|
-
color: dynamicSchema(
|
|
365
|
-
});
|
|
366
|
-
var textShadowObjectSchema =
|
|
367
|
-
offsetX: dynamicSchema(
|
|
368
|
-
offsetY: dynamicSchema(
|
|
369
|
-
blur: dynamicSchema(
|
|
370
|
-
color: dynamicSchema(
|
|
371
|
-
});
|
|
372
|
-
var borderStyleValueSchema =
|
|
373
|
-
var borderObjectSchema =
|
|
374
|
-
width: dynamicSchema(
|
|
426
|
+
var shadowObjectSchema = z3.object({
|
|
427
|
+
offsetX: dynamicSchema(z3.number()),
|
|
428
|
+
offsetY: dynamicSchema(z3.number()),
|
|
429
|
+
blur: dynamicSchema(z3.number()).optional(),
|
|
430
|
+
spread: dynamicSchema(z3.number()).optional(),
|
|
431
|
+
color: dynamicSchema(z3.string())
|
|
432
|
+
});
|
|
433
|
+
var textShadowObjectSchema = z3.object({
|
|
434
|
+
offsetX: dynamicSchema(z3.number()),
|
|
435
|
+
offsetY: dynamicSchema(z3.number()),
|
|
436
|
+
blur: dynamicSchema(z3.number()).optional(),
|
|
437
|
+
color: dynamicSchema(z3.string())
|
|
438
|
+
});
|
|
439
|
+
var borderStyleValueSchema = z3.enum(["solid", "dashed", "dotted", "none"]);
|
|
440
|
+
var borderObjectSchema = z3.object({
|
|
441
|
+
width: dynamicSchema(z3.number()),
|
|
375
442
|
style: dynamicSchema(borderStyleValueSchema),
|
|
376
|
-
color: dynamicSchema(
|
|
443
|
+
color: dynamicSchema(z3.string())
|
|
377
444
|
});
|
|
378
|
-
var transformObjectSchema =
|
|
379
|
-
rotate: dynamicSchema(
|
|
445
|
+
var transformObjectSchema = z3.object({
|
|
446
|
+
rotate: dynamicSchema(z3.string()).optional(),
|
|
380
447
|
// e.g. "45deg"
|
|
381
|
-
scale: dynamicSchema(
|
|
448
|
+
scale: dynamicSchema(z3.number()).optional(),
|
|
382
449
|
// 0.1 ~ 1.5
|
|
383
|
-
translateX: dynamicSchema(
|
|
450
|
+
translateX: dynamicSchema(z3.number()).optional(),
|
|
384
451
|
// -500 ~ 500
|
|
385
|
-
translateY: dynamicSchema(
|
|
452
|
+
translateY: dynamicSchema(z3.number()).optional()
|
|
386
453
|
// -500 ~ 500
|
|
387
454
|
});
|
|
388
|
-
var positionValueSchema =
|
|
389
|
-
var overflowValueSchema =
|
|
390
|
-
var displayValueSchema =
|
|
391
|
-
var flexDirectionValueSchema =
|
|
455
|
+
var positionValueSchema = z3.enum(["static", "relative", "absolute"]);
|
|
456
|
+
var overflowValueSchema = z3.enum(["visible", "hidden", "auto"]);
|
|
457
|
+
var displayValueSchema = z3.enum(["flex", "block", "none"]);
|
|
458
|
+
var flexDirectionValueSchema = z3.enum([
|
|
392
459
|
"row",
|
|
393
460
|
"column",
|
|
394
461
|
"row-reverse",
|
|
395
462
|
"column-reverse"
|
|
396
463
|
]);
|
|
397
|
-
var justifyContentValueSchema =
|
|
464
|
+
var justifyContentValueSchema = z3.enum([
|
|
398
465
|
"start",
|
|
399
466
|
"flex-start",
|
|
400
467
|
"center",
|
|
@@ -404,7 +471,7 @@ var justifyContentValueSchema = z2.enum([
|
|
|
404
471
|
"space-around",
|
|
405
472
|
"space-evenly"
|
|
406
473
|
]);
|
|
407
|
-
var alignItemsValueSchema =
|
|
474
|
+
var alignItemsValueSchema = z3.enum([
|
|
408
475
|
"start",
|
|
409
476
|
"flex-start",
|
|
410
477
|
"center",
|
|
@@ -413,7 +480,7 @@ var alignItemsValueSchema = z2.enum([
|
|
|
413
480
|
"stretch",
|
|
414
481
|
"baseline"
|
|
415
482
|
]);
|
|
416
|
-
var alignSelfValueSchema =
|
|
483
|
+
var alignSelfValueSchema = z3.enum([
|
|
417
484
|
"auto",
|
|
418
485
|
"start",
|
|
419
486
|
"flex-start",
|
|
@@ -422,57 +489,68 @@ var alignSelfValueSchema = z2.enum([
|
|
|
422
489
|
"flex-end",
|
|
423
490
|
"stretch"
|
|
424
491
|
]);
|
|
425
|
-
var flexWrapValueSchema =
|
|
426
|
-
var textAlignValueSchema =
|
|
492
|
+
var flexWrapValueSchema = z3.enum(["nowrap", "wrap", "wrap-reverse"]);
|
|
493
|
+
var textAlignValueSchema = z3.enum([
|
|
427
494
|
"left",
|
|
428
495
|
"center",
|
|
429
496
|
"right",
|
|
430
497
|
"justify"
|
|
431
498
|
]);
|
|
432
|
-
var textDecorationValueSchema =
|
|
499
|
+
var textDecorationValueSchema = z3.enum([
|
|
433
500
|
"none",
|
|
434
501
|
"underline",
|
|
435
502
|
"line-through"
|
|
436
503
|
]);
|
|
437
|
-
var fontStyleValueSchema =
|
|
438
|
-
var fontFamilyValueSchema =
|
|
439
|
-
var fontWeightValueSchema =
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
504
|
+
var fontStyleValueSchema = z3.enum(["normal", "italic"]);
|
|
505
|
+
var fontFamilyValueSchema = z3.enum(ALLOWED_FONT_FAMILIES);
|
|
506
|
+
var fontWeightValueSchema = z3.union([
|
|
507
|
+
z3.enum(["normal", "bold"]),
|
|
508
|
+
z3.literal("100"),
|
|
509
|
+
z3.literal("200"),
|
|
510
|
+
z3.literal("300"),
|
|
511
|
+
z3.literal("400"),
|
|
512
|
+
z3.literal("500"),
|
|
513
|
+
z3.literal("600"),
|
|
514
|
+
z3.literal("700"),
|
|
515
|
+
z3.literal("800"),
|
|
516
|
+
z3.literal("900"),
|
|
517
|
+
z3.literal(100),
|
|
518
|
+
z3.literal(200),
|
|
519
|
+
z3.literal(300),
|
|
520
|
+
z3.literal(400),
|
|
521
|
+
z3.literal(500),
|
|
522
|
+
z3.literal(600),
|
|
523
|
+
z3.literal(700),
|
|
524
|
+
z3.literal(800),
|
|
525
|
+
z3.literal(900)
|
|
459
526
|
]);
|
|
460
|
-
var easingValueSchema =
|
|
527
|
+
var easingValueSchema = z3.enum([
|
|
461
528
|
"ease",
|
|
462
529
|
"linear",
|
|
463
530
|
"ease-in",
|
|
464
531
|
"ease-out",
|
|
465
532
|
"ease-in-out"
|
|
466
533
|
]);
|
|
467
|
-
var transitionDefSchema =
|
|
468
|
-
property:
|
|
469
|
-
duration:
|
|
534
|
+
var transitionDefSchema = z3.object({
|
|
535
|
+
property: z3.string(),
|
|
536
|
+
duration: z3.number(),
|
|
470
537
|
easing: easingValueSchema.optional(),
|
|
471
|
-
delay:
|
|
538
|
+
delay: z3.number().optional()
|
|
472
539
|
});
|
|
473
|
-
var transitionFieldSchema =
|
|
474
|
-
var
|
|
475
|
-
|
|
540
|
+
var transitionFieldSchema = z3.union([transitionDefSchema, z3.array(transitionDefSchema)]).optional();
|
|
541
|
+
var textSpanStyleSchema = z3.object({
|
|
542
|
+
backgroundColor: dynamicSchema(colorSchema).optional(),
|
|
543
|
+
color: dynamicSchema(colorSchema).optional(),
|
|
544
|
+
fontFamily: dynamicSchema(fontFamilyValueSchema).optional(),
|
|
545
|
+
fontSize: dynamicSchema(lengthSchema).optional(),
|
|
546
|
+
fontWeight: dynamicSchema(fontWeightValueSchema).optional(),
|
|
547
|
+
fontStyle: dynamicSchema(fontStyleValueSchema).optional(),
|
|
548
|
+
textDecoration: dynamicSchema(textDecorationValueSchema).optional(),
|
|
549
|
+
letterSpacing: dynamicSchema(lengthSchema).optional(),
|
|
550
|
+
textShadow: z3.union([textShadowObjectSchema, z3.array(textShadowObjectSchema)]).optional()
|
|
551
|
+
}).strict();
|
|
552
|
+
var sizeValueSchema = z3.union([lengthSchema, percentageSchema, z3.literal("auto")]);
|
|
553
|
+
var lineHeightValueSchema = z3.union([z3.number(), lengthSchema]);
|
|
476
554
|
var coreStyleShape = {
|
|
477
555
|
// -----------------------------------------------------------------------
|
|
478
556
|
// Layout — Dynamic
|
|
@@ -483,17 +561,21 @@ var coreStyleShape = {
|
|
|
483
561
|
alignItems: dynamicSchema(alignItemsValueSchema).optional(),
|
|
484
562
|
alignSelf: dynamicSchema(alignSelfValueSchema).optional(),
|
|
485
563
|
flexWrap: dynamicSchema(flexWrapValueSchema).optional(),
|
|
486
|
-
flex: dynamicSchema(
|
|
564
|
+
flex: dynamicSchema(z3.number()).optional(),
|
|
487
565
|
gap: dynamicSchema(lengthSchema).optional(),
|
|
488
566
|
// -----------------------------------------------------------------------
|
|
489
567
|
// Sizing — Dynamic
|
|
490
568
|
// -----------------------------------------------------------------------
|
|
491
569
|
width: dynamicSchema(sizeValueSchema).optional(),
|
|
492
570
|
height: dynamicSchema(sizeValueSchema).optional(),
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
571
|
+
aspectRatio: dynamicSchema(z3.union([
|
|
572
|
+
z3.number().positive(),
|
|
573
|
+
z3.string().regex(ASPECT_RATIO_PATTERN)
|
|
574
|
+
])).optional(),
|
|
575
|
+
minWidth: dynamicSchema(z3.union([lengthSchema, percentageSchema])).optional(),
|
|
576
|
+
maxWidth: dynamicSchema(z3.union([lengthSchema, percentageSchema])).optional(),
|
|
577
|
+
minHeight: dynamicSchema(z3.union([lengthSchema, percentageSchema])).optional(),
|
|
578
|
+
maxHeight: dynamicSchema(z3.union([lengthSchema, percentageSchema])).optional(),
|
|
497
579
|
// -----------------------------------------------------------------------
|
|
498
580
|
// Spacing — Dynamic
|
|
499
581
|
// -----------------------------------------------------------------------
|
|
@@ -534,7 +616,7 @@ var coreStyleShape = {
|
|
|
534
616
|
// -----------------------------------------------------------------------
|
|
535
617
|
// Opacity — Dynamic
|
|
536
618
|
// -----------------------------------------------------------------------
|
|
537
|
-
opacity: dynamicSchema(
|
|
619
|
+
opacity: dynamicSchema(z3.number()).optional(),
|
|
538
620
|
// -----------------------------------------------------------------------
|
|
539
621
|
// Gradient — Static only
|
|
540
622
|
// -----------------------------------------------------------------------
|
|
@@ -542,11 +624,11 @@ var coreStyleShape = {
|
|
|
542
624
|
// -----------------------------------------------------------------------
|
|
543
625
|
// Shadow — Static only (single or array of shadows)
|
|
544
626
|
// -----------------------------------------------------------------------
|
|
545
|
-
boxShadow:
|
|
627
|
+
boxShadow: z3.union([shadowObjectSchema, z3.array(shadowObjectSchema)]).optional(),
|
|
546
628
|
// -----------------------------------------------------------------------
|
|
547
629
|
// Text shadow — Static only (single or array of shadows)
|
|
548
630
|
// -----------------------------------------------------------------------
|
|
549
|
-
textShadow:
|
|
631
|
+
textShadow: z3.union([textShadowObjectSchema, z3.array(textShadowObjectSchema)]).optional(),
|
|
550
632
|
// -----------------------------------------------------------------------
|
|
551
633
|
// Borders — Static only
|
|
552
634
|
// -----------------------------------------------------------------------
|
|
@@ -574,177 +656,224 @@ var coreStyleShape = {
|
|
|
574
656
|
// -----------------------------------------------------------------------
|
|
575
657
|
// Object-fit — Dynamic (for Image nodes)
|
|
576
658
|
// -----------------------------------------------------------------------
|
|
577
|
-
objectFit: dynamicSchema(
|
|
578
|
-
objectPosition: dynamicSchema(
|
|
659
|
+
objectFit: dynamicSchema(z3.enum(["cover", "contain", "fill", "none", "scale-down"])).optional(),
|
|
660
|
+
objectPosition: dynamicSchema(z3.string()).optional(),
|
|
579
661
|
// -----------------------------------------------------------------------
|
|
580
662
|
// Grid — Dynamic
|
|
581
663
|
// -----------------------------------------------------------------------
|
|
582
|
-
gridTemplateColumns: dynamicSchema(
|
|
583
|
-
gridTemplateRows: dynamicSchema(
|
|
584
|
-
gridColumn: dynamicSchema(
|
|
585
|
-
gridRow: dynamicSchema(
|
|
664
|
+
gridTemplateColumns: dynamicSchema(z3.string()).optional(),
|
|
665
|
+
gridTemplateRows: dynamicSchema(z3.string()).optional(),
|
|
666
|
+
gridColumn: dynamicSchema(z3.string()).optional(),
|
|
667
|
+
gridRow: dynamicSchema(z3.string()).optional(),
|
|
586
668
|
// -----------------------------------------------------------------------
|
|
587
669
|
// z-index — Static only (0-100 enforced at validation layer)
|
|
588
670
|
// -----------------------------------------------------------------------
|
|
589
|
-
zIndex:
|
|
671
|
+
zIndex: z3.number().optional(),
|
|
590
672
|
// -----------------------------------------------------------------------
|
|
591
673
|
// $style — reference to a named style in card.styles
|
|
592
674
|
// -----------------------------------------------------------------------
|
|
593
|
-
$style:
|
|
675
|
+
$style: z3.string().optional()
|
|
594
676
|
};
|
|
595
|
-
var hoverStylePropsSchema =
|
|
677
|
+
var hoverStylePropsSchema = z3.object({
|
|
596
678
|
...coreStyleShape,
|
|
597
679
|
transition: transitionFieldSchema
|
|
598
680
|
});
|
|
599
|
-
var
|
|
681
|
+
var responsiveStylePropsSchema = z3.object({
|
|
682
|
+
...coreStyleShape
|
|
683
|
+
});
|
|
684
|
+
var responsivePropsSchema = z3.object({
|
|
685
|
+
compact: responsiveStylePropsSchema.optional()
|
|
686
|
+
}).strict();
|
|
687
|
+
var stylePropsSchema = z3.object({
|
|
600
688
|
...coreStyleShape,
|
|
601
689
|
hoverStyle: hoverStylePropsSchema.optional(),
|
|
602
690
|
transition: transitionFieldSchema
|
|
603
691
|
});
|
|
604
692
|
|
|
605
693
|
// src/props.ts
|
|
606
|
-
import { z as
|
|
607
|
-
var
|
|
608
|
-
|
|
694
|
+
import { z as z4 } from "zod";
|
|
695
|
+
var textSpanSchema = z4.object({
|
|
696
|
+
text: templatedStringSchema,
|
|
697
|
+
style: textSpanStyleSchema.optional()
|
|
698
|
+
}).strict();
|
|
699
|
+
var textPropsSchema = z4.object({
|
|
700
|
+
content: templatedStringSchema.optional(),
|
|
701
|
+
spans: z4.array(textSpanSchema).min(1).max(32).optional(),
|
|
702
|
+
maxLines: z4.number().int().min(1).max(10).optional(),
|
|
703
|
+
truncate: z4.enum(["ellipsis", "clip"]).optional()
|
|
609
704
|
});
|
|
610
|
-
var imagePropsSchema =
|
|
705
|
+
var imagePropsSchema = z4.object({
|
|
611
706
|
src: refOnlySchema(assetPathSchema),
|
|
612
|
-
alt: dynamicSchema(
|
|
707
|
+
alt: dynamicSchema(z4.string()).optional()
|
|
613
708
|
});
|
|
614
|
-
var progressBarPropsSchema =
|
|
615
|
-
value: dynamicSchema(
|
|
616
|
-
max: dynamicSchema(
|
|
709
|
+
var progressBarPropsSchema = z4.object({
|
|
710
|
+
value: dynamicSchema(z4.number()),
|
|
711
|
+
max: dynamicSchema(z4.number()),
|
|
617
712
|
color: dynamicSchema(colorSchema).optional()
|
|
618
713
|
});
|
|
619
|
-
var avatarPropsSchema =
|
|
714
|
+
var avatarPropsSchema = z4.object({
|
|
620
715
|
src: refOnlySchema(assetPathSchema),
|
|
621
716
|
size: dynamicSchema(lengthSchema).optional()
|
|
622
717
|
});
|
|
623
|
-
var iconPropsSchema =
|
|
718
|
+
var iconPropsSchema = z4.object({
|
|
624
719
|
name: dynamicSchema(iconNameSchema),
|
|
625
720
|
size: dynamicSchema(lengthSchema).optional(),
|
|
626
721
|
color: dynamicSchema(colorSchema).optional()
|
|
627
722
|
});
|
|
628
|
-
var badgePropsSchema =
|
|
629
|
-
label:
|
|
723
|
+
var badgePropsSchema = z4.object({
|
|
724
|
+
label: templatedStringSchema,
|
|
630
725
|
color: dynamicSchema(colorSchema).optional()
|
|
631
726
|
});
|
|
632
|
-
var chipPropsSchema =
|
|
633
|
-
label:
|
|
727
|
+
var chipPropsSchema = z4.object({
|
|
728
|
+
label: templatedStringSchema,
|
|
634
729
|
color: dynamicSchema(colorSchema).optional()
|
|
635
730
|
});
|
|
636
|
-
var dividerPropsSchema =
|
|
731
|
+
var dividerPropsSchema = z4.object({
|
|
637
732
|
color: dynamicSchema(colorSchema).optional(),
|
|
638
733
|
thickness: dynamicSchema(lengthSchema).optional()
|
|
639
734
|
});
|
|
640
|
-
var spacerPropsSchema =
|
|
735
|
+
var spacerPropsSchema = z4.object({
|
|
641
736
|
size: dynamicSchema(lengthSchema).optional()
|
|
642
737
|
});
|
|
643
|
-
var buttonPropsSchema =
|
|
644
|
-
label:
|
|
645
|
-
action:
|
|
738
|
+
var buttonPropsSchema = z4.object({
|
|
739
|
+
label: templatedStringSchema,
|
|
740
|
+
action: z4.string(),
|
|
741
|
+
disabled: z4.union([z4.boolean(), refSchema]).optional()
|
|
646
742
|
});
|
|
647
|
-
var togglePropsSchema =
|
|
648
|
-
value: dynamicSchema(
|
|
649
|
-
onToggle:
|
|
743
|
+
var togglePropsSchema = z4.object({
|
|
744
|
+
value: dynamicSchema(z4.boolean()),
|
|
745
|
+
onToggle: z4.string(),
|
|
746
|
+
disabled: dynamicSchema(z4.boolean()).optional()
|
|
650
747
|
});
|
|
651
748
|
|
|
652
749
|
// src/primitives.ts
|
|
653
|
-
import { z as
|
|
654
|
-
var
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
750
|
+
import { z as z5 } from "zod";
|
|
751
|
+
var fragmentUseNodeSchema = z5.object({
|
|
752
|
+
$use: z5.string(),
|
|
753
|
+
$if: conditionSchema.optional()
|
|
754
|
+
}).strict();
|
|
755
|
+
var forLoopSchema = z5.object({
|
|
756
|
+
for: z5.string(),
|
|
757
|
+
in: z5.string(),
|
|
758
|
+
template: z5.lazy(() => renderableNodeSchema)
|
|
658
759
|
});
|
|
659
|
-
var childrenSchema =
|
|
660
|
-
|
|
760
|
+
var childrenSchema = z5.union([
|
|
761
|
+
z5.array(z5.lazy(() => renderableNodeSchema)),
|
|
661
762
|
forLoopSchema
|
|
662
763
|
]);
|
|
663
764
|
var baseFields = {
|
|
664
|
-
|
|
765
|
+
$if: conditionSchema.optional(),
|
|
766
|
+
style: stylePropsSchema.optional(),
|
|
767
|
+
responsive: responsivePropsSchema.optional()
|
|
665
768
|
};
|
|
666
|
-
var boxNodeSchema =
|
|
667
|
-
type:
|
|
769
|
+
var boxNodeSchema = z5.object({
|
|
770
|
+
type: z5.literal("Box"),
|
|
668
771
|
children: childrenSchema.optional(),
|
|
669
772
|
...baseFields
|
|
670
773
|
});
|
|
671
|
-
var rowNodeSchema =
|
|
672
|
-
type:
|
|
774
|
+
var rowNodeSchema = z5.object({
|
|
775
|
+
type: z5.literal("Row"),
|
|
673
776
|
children: childrenSchema.optional(),
|
|
674
777
|
...baseFields
|
|
675
778
|
});
|
|
676
|
-
var columnNodeSchema =
|
|
677
|
-
type:
|
|
779
|
+
var columnNodeSchema = z5.object({
|
|
780
|
+
type: z5.literal("Column"),
|
|
678
781
|
children: childrenSchema.optional(),
|
|
679
782
|
...baseFields
|
|
680
783
|
});
|
|
681
|
-
var stackNodeSchema =
|
|
682
|
-
type:
|
|
784
|
+
var stackNodeSchema = z5.object({
|
|
785
|
+
type: z5.literal("Stack"),
|
|
683
786
|
children: childrenSchema.optional(),
|
|
684
787
|
...baseFields
|
|
685
788
|
});
|
|
686
|
-
var gridNodeSchema =
|
|
687
|
-
type:
|
|
789
|
+
var gridNodeSchema = z5.object({
|
|
790
|
+
type: z5.literal("Grid"),
|
|
688
791
|
children: childrenSchema.optional(),
|
|
689
792
|
...baseFields
|
|
690
793
|
});
|
|
691
|
-
var textNodeSchema =
|
|
692
|
-
type:
|
|
794
|
+
var textNodeSchema = z5.object({
|
|
795
|
+
type: z5.literal("Text"),
|
|
693
796
|
...textPropsSchema.shape,
|
|
694
797
|
...baseFields
|
|
695
798
|
});
|
|
696
|
-
var imageNodeSchema =
|
|
697
|
-
type:
|
|
799
|
+
var imageNodeSchema = z5.object({
|
|
800
|
+
type: z5.literal("Image"),
|
|
698
801
|
...imagePropsSchema.shape,
|
|
699
802
|
...baseFields
|
|
700
803
|
});
|
|
701
|
-
var progressBarNodeSchema =
|
|
702
|
-
type:
|
|
804
|
+
var progressBarNodeSchema = z5.object({
|
|
805
|
+
type: z5.literal("ProgressBar"),
|
|
703
806
|
...progressBarPropsSchema.shape,
|
|
704
807
|
...baseFields
|
|
705
808
|
});
|
|
706
|
-
var avatarNodeSchema =
|
|
707
|
-
type:
|
|
809
|
+
var avatarNodeSchema = z5.object({
|
|
810
|
+
type: z5.literal("Avatar"),
|
|
708
811
|
...avatarPropsSchema.shape,
|
|
709
812
|
...baseFields
|
|
710
813
|
});
|
|
711
|
-
var iconNodeSchema =
|
|
712
|
-
type:
|
|
814
|
+
var iconNodeSchema = z5.object({
|
|
815
|
+
type: z5.literal("Icon"),
|
|
713
816
|
...iconPropsSchema.shape,
|
|
714
817
|
...baseFields
|
|
715
818
|
});
|
|
716
|
-
var badgeNodeSchema =
|
|
717
|
-
type:
|
|
819
|
+
var badgeNodeSchema = z5.object({
|
|
820
|
+
type: z5.literal("Badge"),
|
|
718
821
|
...badgePropsSchema.shape,
|
|
719
822
|
...baseFields
|
|
720
823
|
});
|
|
721
|
-
var chipNodeSchema =
|
|
722
|
-
type:
|
|
824
|
+
var chipNodeSchema = z5.object({
|
|
825
|
+
type: z5.literal("Chip"),
|
|
723
826
|
...chipPropsSchema.shape,
|
|
724
827
|
...baseFields
|
|
725
828
|
});
|
|
726
|
-
var dividerNodeSchema =
|
|
727
|
-
type:
|
|
829
|
+
var dividerNodeSchema = z5.object({
|
|
830
|
+
type: z5.literal("Divider"),
|
|
728
831
|
...dividerPropsSchema.shape,
|
|
729
832
|
...baseFields
|
|
730
833
|
});
|
|
731
|
-
var spacerNodeSchema =
|
|
732
|
-
type:
|
|
834
|
+
var spacerNodeSchema = z5.object({
|
|
835
|
+
type: z5.literal("Spacer"),
|
|
733
836
|
...spacerPropsSchema.shape,
|
|
734
837
|
...baseFields
|
|
735
838
|
});
|
|
736
|
-
var buttonNodeSchema =
|
|
737
|
-
type:
|
|
839
|
+
var buttonNodeSchema = z5.object({
|
|
840
|
+
type: z5.literal("Button"),
|
|
738
841
|
...buttonPropsSchema.shape,
|
|
739
842
|
...baseFields
|
|
740
843
|
});
|
|
741
|
-
var toggleNodeSchema =
|
|
742
|
-
type:
|
|
844
|
+
var toggleNodeSchema = z5.object({
|
|
845
|
+
type: z5.literal("Toggle"),
|
|
743
846
|
...togglePropsSchema.shape,
|
|
744
847
|
...baseFields
|
|
745
848
|
});
|
|
746
|
-
var
|
|
747
|
-
|
|
849
|
+
var interactiveItemIdSchema = z5.string().min(1).max(64);
|
|
850
|
+
var accordionItemSchema = z5.object({
|
|
851
|
+
id: interactiveItemIdSchema,
|
|
852
|
+
label: templatedStringSchema,
|
|
853
|
+
content: z5.lazy(() => renderableNodeSchema),
|
|
854
|
+
disabled: dynamicSchema(z5.boolean()).optional()
|
|
855
|
+
}).strict();
|
|
856
|
+
var tabsItemSchema = z5.object({
|
|
857
|
+
id: interactiveItemIdSchema,
|
|
858
|
+
label: templatedStringSchema,
|
|
859
|
+
content: z5.lazy(() => renderableNodeSchema),
|
|
860
|
+
disabled: dynamicSchema(z5.boolean()).optional()
|
|
861
|
+
}).strict();
|
|
862
|
+
var accordionNodeSchema = z5.object({
|
|
863
|
+
type: z5.literal("Accordion"),
|
|
864
|
+
items: z5.array(accordionItemSchema).min(1).max(MAX_INTERACTIVE_ITEMS),
|
|
865
|
+
allowMultiple: z5.boolean().optional(),
|
|
866
|
+
defaultExpanded: z5.array(interactiveItemIdSchema).max(MAX_INTERACTIVE_ITEMS).optional(),
|
|
867
|
+
...baseFields
|
|
868
|
+
});
|
|
869
|
+
var tabsNodeSchema = z5.object({
|
|
870
|
+
type: z5.literal("Tabs"),
|
|
871
|
+
tabs: z5.array(tabsItemSchema).min(1).max(MAX_INTERACTIVE_ITEMS),
|
|
872
|
+
defaultTab: interactiveItemIdSchema.optional(),
|
|
873
|
+
...baseFields
|
|
874
|
+
});
|
|
875
|
+
var ugcNodeSchema = z5.lazy(
|
|
876
|
+
() => z5.discriminatedUnion("type", [
|
|
748
877
|
boxNodeSchema,
|
|
749
878
|
rowNodeSchema,
|
|
750
879
|
columnNodeSchema,
|
|
@@ -760,11 +889,19 @@ var ugcNodeSchema = z4.lazy(
|
|
|
760
889
|
dividerNodeSchema,
|
|
761
890
|
spacerNodeSchema,
|
|
762
891
|
buttonNodeSchema,
|
|
763
|
-
toggleNodeSchema
|
|
892
|
+
toggleNodeSchema,
|
|
893
|
+
accordionNodeSchema,
|
|
894
|
+
tabsNodeSchema
|
|
895
|
+
])
|
|
896
|
+
);
|
|
897
|
+
var renderableNodeSchema = z5.lazy(
|
|
898
|
+
() => z5.union([
|
|
899
|
+
ugcNodeSchema,
|
|
900
|
+
fragmentUseNodeSchema
|
|
764
901
|
])
|
|
765
902
|
);
|
|
766
|
-
var phase1NodeSchema =
|
|
767
|
-
() =>
|
|
903
|
+
var phase1NodeSchema = z5.lazy(
|
|
904
|
+
() => z5.discriminatedUnion("type", [
|
|
768
905
|
boxNodeSchema,
|
|
769
906
|
rowNodeSchema,
|
|
770
907
|
columnNodeSchema,
|
|
@@ -774,24 +911,26 @@ var phase1NodeSchema = z4.lazy(
|
|
|
774
911
|
);
|
|
775
912
|
|
|
776
913
|
// src/card.ts
|
|
777
|
-
import { z as
|
|
778
|
-
var cardMetaSchema =
|
|
779
|
-
name:
|
|
780
|
-
version:
|
|
914
|
+
import { z as z6 } from "zod";
|
|
915
|
+
var cardMetaSchema = z6.object({
|
|
916
|
+
name: z6.string(),
|
|
917
|
+
version: z6.string()
|
|
781
918
|
});
|
|
782
919
|
var styleNamePattern = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
783
|
-
var ugcCardSchema =
|
|
920
|
+
var ugcCardSchema = z6.object({
|
|
784
921
|
meta: cardMetaSchema,
|
|
785
|
-
assets:
|
|
786
|
-
state:
|
|
787
|
-
styles:
|
|
788
|
-
|
|
922
|
+
assets: z6.record(z6.string(), z6.string()).optional(),
|
|
923
|
+
state: z6.record(z6.string(), z6.unknown()).optional(),
|
|
924
|
+
styles: z6.record(z6.string().regex(styleNamePattern), stylePropsSchema).optional(),
|
|
925
|
+
fragments: z6.record(z6.string().regex(styleNamePattern), ugcNodeSchema).optional(),
|
|
926
|
+
views: z6.record(z6.string(), renderableNodeSchema)
|
|
789
927
|
});
|
|
790
928
|
export {
|
|
791
929
|
ALLOWED_FONT_FAMILIES,
|
|
792
930
|
ALLOWED_OVERFLOW_VALUES,
|
|
793
931
|
ALLOWED_TRANSITION_PROPERTIES,
|
|
794
932
|
ALL_COMPONENT_TYPES,
|
|
933
|
+
ASPECT_RATIO_PATTERN,
|
|
795
934
|
ASSET_INDIVIDUAL_MAX_BYTES,
|
|
796
935
|
ASSET_TOTAL_MAX_BYTES,
|
|
797
936
|
BORDER_RADIUS_MAX,
|
|
@@ -799,6 +938,7 @@ export {
|
|
|
799
938
|
BOX_SHADOW_MAX_COUNT,
|
|
800
939
|
BOX_SHADOW_SPREAD_MAX,
|
|
801
940
|
CARD_JSON_MAX_BYTES,
|
|
941
|
+
COMPACT_BREAKPOINT_MAX_WIDTH,
|
|
802
942
|
CSS_NAMED_COLORS,
|
|
803
943
|
DANGEROUS_CSS_FUNCTIONS,
|
|
804
944
|
FONT_SIZE_MAX,
|
|
@@ -807,6 +947,8 @@ export {
|
|
|
807
947
|
FORBIDDEN_STYLE_PROPERTIES,
|
|
808
948
|
LETTER_SPACING_MAX,
|
|
809
949
|
LETTER_SPACING_MIN,
|
|
950
|
+
MAX_CONDITION_DEPTH,
|
|
951
|
+
MAX_INTERACTIVE_ITEMS,
|
|
810
952
|
MAX_LOOP_ITERATIONS,
|
|
811
953
|
MAX_NESTED_LOOPS,
|
|
812
954
|
MAX_NODE_COUNT,
|
|
@@ -829,6 +971,8 @@ export {
|
|
|
829
971
|
TRANSITION_MAX_COUNT,
|
|
830
972
|
ZINDEX_MAX,
|
|
831
973
|
ZINDEX_MIN,
|
|
974
|
+
accordionItemSchema,
|
|
975
|
+
accordionNodeSchema,
|
|
832
976
|
alignItemsValueSchema,
|
|
833
977
|
alignSelfValueSchema,
|
|
834
978
|
assetPathSchema,
|
|
@@ -846,6 +990,11 @@ export {
|
|
|
846
990
|
chipPropsSchema,
|
|
847
991
|
colorSchema,
|
|
848
992
|
columnNodeSchema,
|
|
993
|
+
comparisonConditionOpSchema,
|
|
994
|
+
comparisonConditionSchema,
|
|
995
|
+
conditionOperandLiteralSchema,
|
|
996
|
+
conditionOperandSchema,
|
|
997
|
+
conditionSchema,
|
|
849
998
|
displayValueSchema,
|
|
850
999
|
dividerNodeSchema,
|
|
851
1000
|
dividerPropsSchema,
|
|
@@ -857,6 +1006,7 @@ export {
|
|
|
857
1006
|
fontStyleValueSchema,
|
|
858
1007
|
fontWeightValueSchema,
|
|
859
1008
|
forLoopSchema,
|
|
1009
|
+
fragmentUseNodeSchema,
|
|
860
1010
|
gradientObjectSchema,
|
|
861
1011
|
gradientStopSchema,
|
|
862
1012
|
gridNodeSchema,
|
|
@@ -869,6 +1019,7 @@ export {
|
|
|
869
1019
|
isAssetPath,
|
|
870
1020
|
isDynamic,
|
|
871
1021
|
isRef,
|
|
1022
|
+
isTemplateValue,
|
|
872
1023
|
justifyContentValueSchema,
|
|
873
1024
|
lengthSchema,
|
|
874
1025
|
linearGradientSchema,
|
|
@@ -881,18 +1032,28 @@ export {
|
|
|
881
1032
|
radialGradientSchema,
|
|
882
1033
|
refOnlySchema,
|
|
883
1034
|
refSchema,
|
|
1035
|
+
renderableNodeSchema,
|
|
884
1036
|
repeatingLinearGradientSchema,
|
|
1037
|
+
responsivePropsSchema,
|
|
1038
|
+
responsiveStylePropsSchema,
|
|
885
1039
|
rowNodeSchema,
|
|
886
1040
|
shadowObjectSchema,
|
|
887
1041
|
spacerNodeSchema,
|
|
888
1042
|
spacerPropsSchema,
|
|
889
1043
|
stackNodeSchema,
|
|
890
1044
|
stylePropsSchema,
|
|
1045
|
+
tabsItemSchema,
|
|
1046
|
+
tabsNodeSchema,
|
|
1047
|
+
templatePartSchema,
|
|
1048
|
+
templateValueSchema,
|
|
1049
|
+
templatedStringSchema,
|
|
891
1050
|
textAlignValueSchema,
|
|
892
1051
|
textDecorationValueSchema,
|
|
893
1052
|
textNodeSchema,
|
|
894
1053
|
textPropsSchema,
|
|
895
1054
|
textShadowObjectSchema,
|
|
1055
|
+
textSpanSchema,
|
|
1056
|
+
textSpanStyleSchema,
|
|
896
1057
|
toggleNodeSchema,
|
|
897
1058
|
togglePropsSchema,
|
|
898
1059
|
transformObjectSchema,
|