@schema-engine/layout 0.5.1 → 0.5.2
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/README.md +10 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +4 -4
- package/dist/lib/grid-placement.d.ts +51 -4
- package/dist/lib/grid-placement.js +1 -1
- package/dist/lib/grid-placement.js.map +3 -3
- package/dist/lib/grid-styles.d.ts +79 -5
- package/dist/lib/grid-styles.js +2 -2
- package/dist/lib/grid-styles.js.map +3 -3
- package/dist/lib/layout-theme.js +4 -4
- package/dist/lib/layout-theme.js.map +3 -3
- package/dist/recipes/bind-recipe.d.ts +3 -3
- package/dist/recipes/bind-recipe.js +1 -1
- package/dist/recipes/bind-recipe.js.map +2 -2
- package/dist/recipes/define-recipe-spec.d.ts +37 -13
- package/dist/recipes/define-recipe-spec.js +1 -1
- package/dist/recipes/define-recipe-spec.js.map +4 -4
- package/dist/recipes/protocol.d.ts +5 -2
- package/dist/recipes/protocol.js +1 -1
- package/dist/recipes/protocol.js.map +3 -3
- package/dist/recipes/resolve-recipe-view.d.ts +2 -0
- package/dist/recipes/resolve-recipe-view.js +1 -1
- package/dist/recipes/resolve-recipe-view.js.map +4 -4
- package/dist/recipes/types.d.ts +21 -6
- package/dist/recipes/view-model.d.ts +2 -2
- package/dist/recipes/view-model.js +1 -1
- package/dist/recipes/view-model.js.map +2 -2
- package/dist/schemas/grid.d.ts +28 -15
- package/dist/schemas/grid.js +1 -1
- package/dist/schemas/grid.js.map +2 -2
- package/package.json +5 -2
- package/skill/SKILL.md +26 -25
- package/skill/reference/layout.md +61 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
/**
|
|
3
3
|
* What every recipe renderer receives, whatever the domain: the recipe's kind and the resolved view.
|
|
4
4
|
*
|
|
@@ -17,4 +17,4 @@ export interface RecipeViewModel<TKind extends string = string> {
|
|
|
17
17
|
* block's own strict schema would reject a custom recipe whose slot schema extends the block's
|
|
18
18
|
* with extra keys.
|
|
19
19
|
*/
|
|
20
|
-
export declare function readSlotConfig<TSchema extends
|
|
20
|
+
export declare function readSlotConfig<TSchema extends StandardSchemaV1>(viewConfig: Record<string, unknown>, slot: string, _schema: TSchema): StandardSchemaV1.InferOutput<TSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a(e,n,t){return e[n]}export{a as readSlotConfig};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/recipes/view-model.ts"],
|
|
4
|
-
"sourcesContent": ["import type
|
|
5
|
-
"mappings": "AAqBO,SAASA,EACfC,EACAC,EACAC,
|
|
4
|
+
"sourcesContent": ["import type { StandardSchemaV1 } from '@standard-schema/spec';\n\n/**\n * What every recipe renderer receives, whatever the domain: the recipe's kind and the resolved view.\n *\n * @remarks\n * A domain extends it with what its renderers also need, for example the steps of a form.\n */\nexport interface RecipeViewModel<TKind extends string = string> {\n\tkind: TKind;\n\tviewConfig: Record<string, unknown>;\n}\n\n/**\n * Reads one slot's complete config from a resolved view.\n *\n * @remarks\n * `schema` only types the result. The view is already complete, and parsing it again with the\n * block's own strict schema would reject a custom recipe whose slot schema extends the block's\n * with extra keys.\n */\nexport function readSlotConfig<TSchema extends StandardSchemaV1>(\n\tviewConfig: Record<string, unknown>,\n\tslot: string,\n\t_schema: TSchema,\n): StandardSchemaV1.InferOutput<TSchema> {\n\treturn viewConfig[slot] as StandardSchemaV1.InferOutput<TSchema>;\n}\n"],
|
|
5
|
+
"mappings": "AAqBO,SAASA,EACfC,EACAC,EACAC,EACwC,CACxC,OAAOF,EAAWC,CAAI,CACvB",
|
|
6
6
|
"names": ["readSlotConfig", "viewConfig", "slot", "_schema"]
|
|
7
7
|
}
|
package/dist/schemas/grid.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare const GridGapValueSchema: z.ZodMiniUnion<readonly [z.ZodMiniEnum<
|
|
|
27
27
|
wide: "wide";
|
|
28
28
|
}>, z.ZodMiniString<string>]>;
|
|
29
29
|
export declare const GridBreakpointConfigSchema: z.ZodMiniObject<{
|
|
30
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
30
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
31
31
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
32
32
|
default: "default";
|
|
33
33
|
none: "none";
|
|
@@ -60,7 +60,7 @@ export declare const GridLayoutConfigSchema: z.ZodMiniObject<{
|
|
|
60
60
|
xl: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
61
61
|
'2xl': z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
62
62
|
}, z.core.$strict>]>>;
|
|
63
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
63
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
64
64
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
65
65
|
default: "default";
|
|
66
66
|
none: "none";
|
|
@@ -115,9 +115,13 @@ export declare const GridLayoutConfigSchema: z.ZodMiniObject<{
|
|
|
115
115
|
"space-evenly": "space-evenly";
|
|
116
116
|
}>>;
|
|
117
117
|
placeContent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
118
|
+
autoFlow: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
119
|
+
row: "row";
|
|
120
|
+
dense: "dense";
|
|
121
|
+
}>>;
|
|
118
122
|
responsive: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
119
123
|
default: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
120
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
124
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
121
125
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
122
126
|
default: "default";
|
|
123
127
|
none: "none";
|
|
@@ -142,7 +146,7 @@ export declare const GridLayoutConfigSchema: z.ZodMiniObject<{
|
|
|
142
146
|
minColumnWidth: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
143
147
|
}, z.core.$strict>>;
|
|
144
148
|
sm: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
145
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
149
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
146
150
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
147
151
|
default: "default";
|
|
148
152
|
none: "none";
|
|
@@ -167,7 +171,7 @@ export declare const GridLayoutConfigSchema: z.ZodMiniObject<{
|
|
|
167
171
|
minColumnWidth: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
168
172
|
}, z.core.$strict>>;
|
|
169
173
|
md: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
170
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
174
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
171
175
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
172
176
|
default: "default";
|
|
173
177
|
none: "none";
|
|
@@ -192,7 +196,7 @@ export declare const GridLayoutConfigSchema: z.ZodMiniObject<{
|
|
|
192
196
|
minColumnWidth: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
193
197
|
}, z.core.$strict>>;
|
|
194
198
|
lg: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
195
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
199
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
196
200
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
197
201
|
default: "default";
|
|
198
202
|
none: "none";
|
|
@@ -217,7 +221,7 @@ export declare const GridLayoutConfigSchema: z.ZodMiniObject<{
|
|
|
217
221
|
minColumnWidth: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
218
222
|
}, z.core.$strict>>;
|
|
219
223
|
xl: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
220
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
224
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
221
225
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
222
226
|
default: "default";
|
|
223
227
|
none: "none";
|
|
@@ -242,7 +246,7 @@ export declare const GridLayoutConfigSchema: z.ZodMiniObject<{
|
|
|
242
246
|
minColumnWidth: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
243
247
|
}, z.core.$strict>>;
|
|
244
248
|
'2xl': z.ZodMiniOptional<z.ZodMiniObject<{
|
|
245
|
-
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.
|
|
249
|
+
columns: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniInt, z.ZodMiniLiteral<"auto">]>>;
|
|
246
250
|
gap: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
247
251
|
default: "default";
|
|
248
252
|
none: "none";
|
|
@@ -283,6 +287,8 @@ export type GridWidthName = (typeof GridWidthNames)[number];
|
|
|
283
287
|
export declare const GridOffsetNames: readonly ["three-quarters", "two-thirds", "half", "third", "quarter"];
|
|
284
288
|
export type GridOffsetName = (typeof GridOffsetNames)[number];
|
|
285
289
|
export declare const ItemGridBreakpointSchema: z.ZodMiniObject<{
|
|
290
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
291
|
+
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
286
292
|
area: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
287
293
|
width: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
288
294
|
full: "full";
|
|
@@ -300,7 +306,6 @@ export declare const ItemGridBreakpointSchema: z.ZodMiniObject<{
|
|
|
300
306
|
quarter: "quarter";
|
|
301
307
|
}>>;
|
|
302
308
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
303
|
-
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
304
309
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
305
310
|
start: "start";
|
|
306
311
|
end: "end";
|
|
@@ -346,6 +351,7 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
346
351
|
third: "third";
|
|
347
352
|
quarter: "quarter";
|
|
348
353
|
}>>;
|
|
354
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
349
355
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
350
356
|
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
351
357
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
@@ -361,6 +367,7 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
361
367
|
stretch: "stretch";
|
|
362
368
|
}>>;
|
|
363
369
|
placeSelf: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
370
|
+
subgrid: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
364
371
|
marginBlockStart: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniEnum<{
|
|
365
372
|
default: "default";
|
|
366
373
|
none: "none";
|
|
@@ -377,6 +384,8 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
377
384
|
}>, z.ZodMiniString<string>]>>;
|
|
378
385
|
responsive: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
379
386
|
default: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
387
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
388
|
+
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
380
389
|
area: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
381
390
|
width: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
382
391
|
full: "full";
|
|
@@ -394,7 +403,6 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
394
403
|
quarter: "quarter";
|
|
395
404
|
}>>;
|
|
396
405
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
397
|
-
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
398
406
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
399
407
|
start: "start";
|
|
400
408
|
end: "end";
|
|
@@ -424,6 +432,8 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
424
432
|
hidden: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
425
433
|
}, z.core.$strict>>;
|
|
426
434
|
sm: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
435
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
436
|
+
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
427
437
|
area: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
428
438
|
width: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
429
439
|
full: "full";
|
|
@@ -441,7 +451,6 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
441
451
|
quarter: "quarter";
|
|
442
452
|
}>>;
|
|
443
453
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
444
|
-
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
445
454
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
446
455
|
start: "start";
|
|
447
456
|
end: "end";
|
|
@@ -471,6 +480,8 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
471
480
|
hidden: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
472
481
|
}, z.core.$strict>>;
|
|
473
482
|
md: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
483
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
484
|
+
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
474
485
|
area: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
475
486
|
width: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
476
487
|
full: "full";
|
|
@@ -488,7 +499,6 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
488
499
|
quarter: "quarter";
|
|
489
500
|
}>>;
|
|
490
501
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
491
|
-
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
492
502
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
493
503
|
start: "start";
|
|
494
504
|
end: "end";
|
|
@@ -518,6 +528,8 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
518
528
|
hidden: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
519
529
|
}, z.core.$strict>>;
|
|
520
530
|
lg: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
531
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
532
|
+
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
521
533
|
area: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
522
534
|
width: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
523
535
|
full: "full";
|
|
@@ -535,7 +547,6 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
535
547
|
quarter: "quarter";
|
|
536
548
|
}>>;
|
|
537
549
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
538
|
-
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
539
550
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
540
551
|
start: "start";
|
|
541
552
|
end: "end";
|
|
@@ -565,6 +576,8 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
565
576
|
hidden: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
566
577
|
}, z.core.$strict>>;
|
|
567
578
|
xl: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
579
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
580
|
+
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
568
581
|
area: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
569
582
|
width: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
570
583
|
full: "full";
|
|
@@ -582,7 +595,6 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
582
595
|
quarter: "quarter";
|
|
583
596
|
}>>;
|
|
584
597
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
585
|
-
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
586
598
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
587
599
|
start: "start";
|
|
588
600
|
end: "end";
|
|
@@ -612,6 +624,8 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
612
624
|
hidden: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
613
625
|
}, z.core.$strict>>;
|
|
614
626
|
'2xl': z.ZodMiniOptional<z.ZodMiniObject<{
|
|
627
|
+
span: z.ZodMiniOptional<z.ZodMiniInt>;
|
|
628
|
+
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
615
629
|
area: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
616
630
|
width: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
617
631
|
full: "full";
|
|
@@ -629,7 +643,6 @@ export declare const ElementGridConfigSchema: z.ZodMiniObject<{
|
|
|
629
643
|
quarter: "quarter";
|
|
630
644
|
}>>;
|
|
631
645
|
column: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
632
|
-
row: z.ZodMiniOptional<z.ZodMiniUnion<readonly [z.ZodMiniNumber<number>, z.ZodMiniString<string>]>>;
|
|
633
646
|
justifySelf: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
634
647
|
start: "start";
|
|
635
648
|
end: "end";
|
package/dist/schemas/grid.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"zod/mini";var z=["none","compact","default","loose","wide"],o=e.union([e.enum(z),e.string()]).check(e.describe("Semantic gap token (none | compact | default | loose | wide) or a raw CSS length.")),m=["auto","span","none","default","inherit","initial","unset","revert","revert-layer"];function u(t){return t.split("").map(n=>/[a-z]/i.test(n)?`[${n.toLowerCase()}${n.toUpperCase()}]`:n).join("")}var r=`(?!(?:${m.map(u).join("|")})(?![\\w-]))-?[_a-zA-Z][_a-zA-Z0-9-]*`,
|
|
1
|
+
import*as e from"zod/mini";var z=["none","compact","default","loose","wide"],o=e.union([e.enum(z),e.string()]).check(e.describe("Semantic gap token (none | compact | default | loose | wide) or a raw CSS length.")),m=["auto","span","none","default","inherit","initial","unset","revert","revert-layer"];function u(t){return t.split("").map(n=>/[a-z]/i.test(n)?`[${n.toLowerCase()}${n.toUpperCase()}]`:n).join("")}var r=`(?!(?:${m.map(u).join("|")})(?![\\w-]))-?[_a-zA-Z][_a-zA-Z0-9-]*`,h=e.string().check(e.regex(new RegExp(`^${r}$`),'Area names are CSS identifiers such as "header" or "side-2".'),e.describe('Name of a cell group in the grid template: a CSS identifier such as "header" or "side-2".'));function p(t){return e.strictObject({default:e.optional(t),sm:e.optional(t),md:e.optional(t),lg:e.optional(t),xl:e.optional(t),"2xl":e.optional(t)})}function c(t){return e.optional(p(t))}var f=e.string().check(e.regex(new RegExp(`^\\s*(?:\\.+|${r})(?:\\s+(?:\\.+|${r}))*\\s*$`),'A grid areas row lists area names (CSS identifiers) or "." for an empty cell, separated by spaces.')),i=e.array(f).check(e.minLength(1)),g=e.union([i,p(i)]).check(e.describe('Rows of area names separated by spaces ("." is an empty cell), or a record of them per breakpoint (default, sm ... 2xl).')),l=e.strictObject({areas:e.optional(g),columns:e.optional(e.union([e.int().check(e.positive()),e.literal("auto")])),gap:e.optional(o),gapX:e.optional(o),gapY:e.optional(o),minColumnWidth:e.optional(e.string()),justifyItems:e.optional(e.enum(["start","end","center","stretch"])),alignItems:e.optional(e.enum(["start","end","center","stretch"])),placeItems:e.optional(e.string()),justifyContent:e.optional(e.enum(["start","end","center","stretch","space-around","space-between","space-evenly"])),alignContent:e.optional(e.enum(["start","end","center","stretch","space-around","space-between","space-evenly"])),placeContent:e.optional(e.string()),autoFlow:e.optional(e.enum(["row","dense"])).check(e.describe("How items without a position fill the tracks: 'row' in source order, 'dense' backfills earlier gaps with later, smaller items. Dense changes the visual order, not the DOM or focus order. Top level only."))}),k=e.pick(l,{columns:!0,gap:!0,gapX:!0,gapY:!0,minColumnWidth:!0}),S=e.extend(l,{responsive:c(k)}),a=["full","three-quarters","two-thirds","half","third","quarter"],s=["three-quarters","two-thirds","half","third","quarter"],d=e.strictObject({area:e.optional(h).check(e.describe("Name of the cell group this item fills in the grid areas template.")),width:e.optional(e.enum(a)).check(e.describe(`Named share of the row (${a.join(" | ")}).`)),offset:e.optional(e.enum(s)).check(e.describe(`Named empty space before the item (${s.join(" | ")}).`)),span:e.optional(e.int().check(e.positive())).check(e.describe('Number of tracks to span, never more than the grid has. Needs a grid with a known track count, so not `columns: "auto"`.')),column:e.optional(e.union([e.number(),e.string()])),row:e.optional(e.union([e.number(),e.string()])),justifySelf:e.optional(e.enum(["start","end","center","stretch"])),alignSelf:e.optional(e.enum(["start","end","center","stretch"])),placeSelf:e.optional(e.string()),subgrid:e.optional(e.boolean()).check(e.describe("Spans the parent grid's full row and lays this element's children on the parent's column tracks and gap. Set on a container element, never per breakpoint.")),marginBlockStart:e.optional(o).check(e.describe("Extra space before this element, on top of the grid row gap.")),marginBlockEnd:e.optional(o).check(e.describe("Extra space after this element, on top of the grid row gap."))}),y=e.extend(e.omit(d,{placeSelf:!0,subgrid:!0}),{hidden:e.optional(e.boolean())}),b=e.extend(d,{responsive:c(y)});export{b as ElementGridConfigSchema,k as GridBreakpointConfigSchema,z as GridGapTokens,o as GridGapValueSchema,S as GridLayoutConfigSchema,s as GridOffsetNames,a as GridWidthNames,y as ItemGridBreakpointSchema};
|
package/dist/schemas/grid.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/schemas/grid.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod/mini';\n\n/**\n * Semantic gap tokens for grid layouts.\n *\n * @remarks\n * Tokens are indirections to overridable CSS variables: the renderer emits\n * `var(--se-grid-gap-<token>)`, so hosts restyle every grid by overriding the\n * token at `:root`. Raw CSS strings (e.g. `'1.5rem'`) are the one-off escape\n * hatch.\n */\nexport const GridGapTokens = ['none', 'compact', 'default', 'loose', 'wide'] as const;\n\nexport type GridGapToken = (typeof GridGapTokens)[number];\n\n/**\n * Semantic gap token or a raw CSS length.\n *\n * @remarks\n * The enum branch is redundant for validation \u2014 the string branch accepts the\n * same values \u2014 and `z.infer` collapses the union to `string`. It is kept\n * because `z.toJSONSchema` emits it as `anyOf: [{enum: [...]}, {type: string}]`,\n * which is how the token vocabulary reaches registry and docs consumers.\n */\nexport const GridGapValueSchema = z\n\t.union([z.enum(GridGapTokens), z.string()])\n\t.check(z.describe('Semantic gap token (none | compact | default | loose | wide) or a raw CSS length.'));\n\n/**\n * Words that are not valid grid area names: `grid-area` reads `auto` and `span`\n * as placement keywords, the CSS-wide keywords reset a declaration, and `none`\n * and `default` are excluded from a `<custom-ident>` by the CSS grammar.\n */\nconst RESERVED_AREA_NAMES = [\n\t'auto',\n\t'span',\n\t'none',\n\t'default',\n\t'inherit',\n\t'initial',\n\t'unset',\n\t'revert',\n\t'revert-layer',\n];\n\n/**\n * A word as a pattern that matches it in any letter case.\n *\n * @remarks\n * Spelled with character classes instead of an `i` flag because the JSON Schema\n * export keeps only a regex's source, so a flag would be lost and editors would\n * accept `AUTO` and reject `Street`.\n */\nfunction anyCase(word: string): string {\n\treturn word\n\t\t.split('')\n\t\t.map((char) => (/[a-z]/i.test(char) ? `[${char.toLowerCase()}${char.toUpperCase()}]` : char))\n\t\t.join('');\n}\n\nconst AREA_NAME_SOURCE = `(?!(?:${RESERVED_AREA_NAMES.map(anyCase).join('|')})(?![\\\\w-]))-?[_a-zA-Z][_a-zA-Z0-9-]*`;\n\n/**\n * Name of a grid area: an ASCII CSS identifier that is not a reserved word.\n *\n * @remarks\n * Names are written into a custom property that the stylesheet reads as CSS, so\n * the pattern is the injection guard. Nothing outside `[A-Za-z0-9_-]` can reach the\n * property, which rules out quotes, semicolons, braces and whitespace.\n */\nconst GridAreaNameSchema = z\n\t.string()\n\t.check(\n\t\tz.regex(new RegExp(`^${AREA_NAME_SOURCE}$`), 'Area names are CSS identifiers such as \"header\" or \"side-2\".'),\n\t\tz.describe('Name of a cell group in the grid template: a CSS identifier such as \"header\" or \"side-2\".'),\n\t);\n\n/** A value per cascade slot (`default`, `sm` ... `2xl`), each optional. */\nfunction perBreakpoint<T extends z.ZodMiniType>(schema: T) {\n\treturn z.strictObject({\n\t\tdefault: z.optional(schema),\n\t\tsm: z.optional(schema),\n\t\tmd: z.optional(schema),\n\t\tlg: z.optional(schema),\n\t\txl: z.optional(schema),\n\t\t'2xl': z.optional(schema),\n\t});\n}\n\nfunction responsiveSchema<T extends z.ZodMiniType>(schema: T) {\n\treturn z.optional(perBreakpoint(schema));\n}\n\n/** One row of a template: area names or `.` for an empty cell, separated by spaces. */\nconst GridAreaRowSchema = z\n\t.string()\n\t.check(\n\t\tz.regex(\n\t\t\tnew RegExp(`^\\\\s*(?:\\\\.+|${AREA_NAME_SOURCE})(?:\\\\s+(?:\\\\.+|${AREA_NAME_SOURCE}))*\\\\s*$`),\n\t\t\t'A grid areas row lists area names (CSS identifiers) or \".\" for an empty cell, separated by spaces.',\n\t\t),\n\t);\n\nconst GridAreaRowsSchema = z.array(GridAreaRowSchema).check(z.minLength(1));\n\n/**\n * A drawn layout: rows of area names, optionally per breakpoint.\n *\n * @remarks\n * The column count comes from the rows, so a grid with `areas` sets no\n * `columns`. Rows of one template must be the same length and each name must\n * fill a rectangle; the domain validator checks both, as CSS drops a template that\n * breaks either.\n */\nconst GridAreasSchema = z\n\t.union([GridAreaRowsSchema, perBreakpoint(GridAreaRowsSchema)])\n\t.check(\n\t\tz.describe(\n\t\t\t'Rows of area names separated by spaces (\".\" is an empty cell), or a record of them per breakpoint (default, sm ... 2xl).',\n\t\t),\n\t);\n\nconst GridLayoutPropertiesSchema = z.strictObject({\n\tareas: z.optional(GridAreasSchema),\n\tcolumns: z.optional(z.union([z.
|
|
5
|
-
"mappings": "AAAA,UAAYA,MAAO,WAWZ,IAAMC,EAAgB,CAAC,OAAQ,UAAW,UAAW,QAAS,MAAM,EAa9DC,EACX,QAAM,CAAG,OAAKD,CAAa,EAAK,SAAO,CAAC,CAAC,EACzC,MAAQ,WAAS,mFAAmF,CAAC,EAOjGE,EAAsB,CAC3B,OACA,OACA,OACA,UACA,UACA,UACA,QACA,SACA,cACD,EAUA,SAASC,EAAQC,EAAsB,CACtC,OAAOA,EACL,MAAM,EAAE,EACR,IAAKC,GAAU,SAAS,KAAKA,CAAI,EAAI,IAAIA,EAAK,YAAY,CAAC,GAAGA,EAAK,YAAY,CAAC,IAAMA,CAAK,EAC3F,KAAK,EAAE,CACV,CAEA,IAAMC,EAAmB,SAASJ,EAAoB,IAAIC,CAAO,EAAE,KAAK,GAAG,CAAC,wCAUtEI,EACJ,SAAO,EACP,MACE,QAAM,IAAI,OAAO,IAAID,CAAgB,GAAG,EAAG,8DAA8D,EACzG,WAAS,2FAA2F,CACvG,EAGD,SAASE,EAAuCC,EAAW,CAC1D,OAAS,eAAa,CACrB,QAAW,WAASA,CAAM,EAC1B,GAAM,WAASA,CAAM,EACrB,GAAM,WAASA,CAAM,EACrB,GAAM,WAASA,CAAM,EACrB,GAAM,WAASA,CAAM,EACrB,MAAS,WAASA,CAAM,CACzB,CAAC,CACF,CAEA,SAASC,EAA0CD,EAAW,CAC7D,OAAS,WAASD,EAAcC,CAAM,CAAC,CACxC,CAGA,IAAME,EACJ,SAAO,EACP,MACE,QACD,IAAI,OAAO,gBAAgBL,CAAgB,mBAAmBA,CAAgB,UAAU,EACxF,oGACD,CACD,EAEKM,EAAuB,QAAMD,CAAiB,EAAE,MAAQ,YAAU,CAAC,CAAC,EAWpEE,EACJ,QAAM,CAACD,EAAoBJ,EAAcI,CAAkB,CAAC,CAAC,EAC7D,MACE,WACD,0HACD,CACD,EAEKE,EAA+B,eAAa,CACjD,MAAS,WAASD,CAAe,EACjC,QAAW,WAAW,QAAM,CAAG,
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod/mini';\n\n/**\n * Semantic gap tokens for grid layouts.\n *\n * @remarks\n * Tokens are indirections to overridable CSS variables: the renderer emits\n * `var(--se-grid-gap-<token>)`, so hosts restyle every grid by overriding the\n * token at `:root`. Raw CSS strings (e.g. `'1.5rem'`) are the one-off escape\n * hatch.\n */\nexport const GridGapTokens = ['none', 'compact', 'default', 'loose', 'wide'] as const;\n\nexport type GridGapToken = (typeof GridGapTokens)[number];\n\n/**\n * Semantic gap token or a raw CSS length.\n *\n * @remarks\n * The enum branch is redundant for validation \u2014 the string branch accepts the\n * same values \u2014 and `z.infer` collapses the union to `string`. It is kept\n * because `z.toJSONSchema` emits it as `anyOf: [{enum: [...]}, {type: string}]`,\n * which is how the token vocabulary reaches registry and docs consumers.\n */\nexport const GridGapValueSchema = z\n\t.union([z.enum(GridGapTokens), z.string()])\n\t.check(z.describe('Semantic gap token (none | compact | default | loose | wide) or a raw CSS length.'));\n\n/**\n * Words that are not valid grid area names: `grid-area` reads `auto` and `span`\n * as placement keywords, the CSS-wide keywords reset a declaration, and `none`\n * and `default` are excluded from a `<custom-ident>` by the CSS grammar.\n */\nconst RESERVED_AREA_NAMES = [\n\t'auto',\n\t'span',\n\t'none',\n\t'default',\n\t'inherit',\n\t'initial',\n\t'unset',\n\t'revert',\n\t'revert-layer',\n];\n\n/**\n * A word as a pattern that matches it in any letter case.\n *\n * @remarks\n * Spelled with character classes instead of an `i` flag because the JSON Schema\n * export keeps only a regex's source, so a flag would be lost and editors would\n * accept `AUTO` and reject `Street`.\n */\nfunction anyCase(word: string): string {\n\treturn word\n\t\t.split('')\n\t\t.map((char) => (/[a-z]/i.test(char) ? `[${char.toLowerCase()}${char.toUpperCase()}]` : char))\n\t\t.join('');\n}\n\nconst AREA_NAME_SOURCE = `(?!(?:${RESERVED_AREA_NAMES.map(anyCase).join('|')})(?![\\\\w-]))-?[_a-zA-Z][_a-zA-Z0-9-]*`;\n\n/**\n * Name of a grid area: an ASCII CSS identifier that is not a reserved word.\n *\n * @remarks\n * Names are written into a custom property that the stylesheet reads as CSS, so\n * the pattern is the injection guard. Nothing outside `[A-Za-z0-9_-]` can reach the\n * property, which rules out quotes, semicolons, braces and whitespace.\n */\nconst GridAreaNameSchema = z\n\t.string()\n\t.check(\n\t\tz.regex(new RegExp(`^${AREA_NAME_SOURCE}$`), 'Area names are CSS identifiers such as \"header\" or \"side-2\".'),\n\t\tz.describe('Name of a cell group in the grid template: a CSS identifier such as \"header\" or \"side-2\".'),\n\t);\n\n/** A value per cascade slot (`default`, `sm` ... `2xl`), each optional. */\nfunction perBreakpoint<T extends z.ZodMiniType>(schema: T) {\n\treturn z.strictObject({\n\t\tdefault: z.optional(schema),\n\t\tsm: z.optional(schema),\n\t\tmd: z.optional(schema),\n\t\tlg: z.optional(schema),\n\t\txl: z.optional(schema),\n\t\t'2xl': z.optional(schema),\n\t});\n}\n\nfunction responsiveSchema<T extends z.ZodMiniType>(schema: T) {\n\treturn z.optional(perBreakpoint(schema));\n}\n\n/** One row of a template: area names or `.` for an empty cell, separated by spaces. */\nconst GridAreaRowSchema = z\n\t.string()\n\t.check(\n\t\tz.regex(\n\t\t\tnew RegExp(`^\\\\s*(?:\\\\.+|${AREA_NAME_SOURCE})(?:\\\\s+(?:\\\\.+|${AREA_NAME_SOURCE}))*\\\\s*$`),\n\t\t\t'A grid areas row lists area names (CSS identifiers) or \".\" for an empty cell, separated by spaces.',\n\t\t),\n\t);\n\nconst GridAreaRowsSchema = z.array(GridAreaRowSchema).check(z.minLength(1));\n\n/**\n * A drawn layout: rows of area names, optionally per breakpoint.\n *\n * @remarks\n * The column count comes from the rows, so a grid with `areas` sets no\n * `columns`. Rows of one template must be the same length and each name must\n * fill a rectangle; the domain validator checks both, as CSS drops a template that\n * breaks either.\n */\nconst GridAreasSchema = z\n\t.union([GridAreaRowsSchema, perBreakpoint(GridAreaRowsSchema)])\n\t.check(\n\t\tz.describe(\n\t\t\t'Rows of area names separated by spaces (\".\" is an empty cell), or a record of them per breakpoint (default, sm ... 2xl).',\n\t\t),\n\t);\n\nconst GridLayoutPropertiesSchema = z.strictObject({\n\tareas: z.optional(GridAreasSchema),\n\tcolumns: z.optional(z.union([z.int().check(z.positive()), z.literal('auto')])),\n\tgap: z.optional(GridGapValueSchema),\n\tgapX: z.optional(GridGapValueSchema),\n\tgapY: z.optional(GridGapValueSchema),\n\tminColumnWidth: z.optional(z.string()),\n\tjustifyItems: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\talignItems: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\tplaceItems: z.optional(z.string()),\n\tjustifyContent: z.optional(\n\t\tz.enum(['start', 'end', 'center', 'stretch', 'space-around', 'space-between', 'space-evenly']),\n\t),\n\talignContent: z.optional(\n\t\tz.enum(['start', 'end', 'center', 'stretch', 'space-around', 'space-between', 'space-evenly']),\n\t),\n\tplaceContent: z.optional(z.string()),\n\tautoFlow: z\n\t\t.optional(z.enum(['row', 'dense']))\n\t\t.check(\n\t\t\tz.describe(\n\t\t\t\t\"How items without a position fill the tracks: 'row' in source order, 'dense' backfills earlier gaps with later, smaller items. Dense changes the visual order, not the DOM or focus order. Top level only.\",\n\t\t\t),\n\t\t),\n});\n\nexport const GridBreakpointConfigSchema = z.pick(GridLayoutPropertiesSchema, {\n\tcolumns: true,\n\tgap: true,\n\tgapX: true,\n\tgapY: true,\n\tminColumnWidth: true,\n});\n\nexport const GridLayoutConfigSchema = z.extend(GridLayoutPropertiesSchema, {\n\tresponsive: responsiveSchema(GridBreakpointConfigSchema),\n});\n\n/**\n * Named item widths, as shares of the row.\n *\n * @remarks\n * A grid whose items use `width` or `offset` is laid out on 12 tracks, so\n * every name is a whole number of tracks: `full` 12, `three-quarters` 9,\n * `two-thirds` 8, `half` 6, `third` 4, `quarter` 3. An item that sets no width\n * fills the row.\n */\nexport const GridWidthNames = ['full', 'three-quarters', 'two-thirds', 'half', 'third', 'quarter'] as const;\n\nexport type GridWidthName = (typeof GridWidthNames)[number];\n\n/** Named offsets: the widths that are a fraction of the row, without `full`. */\nexport const GridOffsetNames = ['three-quarters', 'two-thirds', 'half', 'third', 'quarter'] as const;\n\nexport type GridOffsetName = (typeof GridOffsetNames)[number];\n\nconst ElementGridPropertiesSchema = z.strictObject({\n\tarea: z\n\t\t.optional(GridAreaNameSchema)\n\t\t.check(z.describe('Name of the cell group this item fills in the grid areas template.')),\n\twidth: z\n\t\t.optional(z.enum(GridWidthNames))\n\t\t.check(z.describe(`Named share of the row (${GridWidthNames.join(' | ')}).`)),\n\toffset: z\n\t\t.optional(z.enum(GridOffsetNames))\n\t\t.check(z.describe(`Named empty space before the item (${GridOffsetNames.join(' | ')}).`)),\n\tspan: z\n\t\t.optional(z.int().check(z.positive()))\n\t\t.check(\n\t\t\tz.describe(\n\t\t\t\t'Number of tracks to span, never more than the grid has. Needs a grid with a known track count, so not `columns: \"auto\"`.',\n\t\t\t),\n\t\t),\n\tcolumn: z.optional(z.union([z.number(), z.string()])),\n\trow: z.optional(z.union([z.number(), z.string()])),\n\tjustifySelf: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\talignSelf: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\tplaceSelf: z.optional(z.string()),\n\tsubgrid: z\n\t\t.optional(z.boolean())\n\t\t.check(\n\t\t\tz.describe(\n\t\t\t\t\"Spans the parent grid's full row and lays this element's children on the parent's column tracks and gap. Set on a container element, never per breakpoint.\",\n\t\t\t),\n\t\t),\n\tmarginBlockStart: z\n\t\t.optional(GridGapValueSchema)\n\t\t.check(z.describe('Extra space before this element, on top of the grid row gap.')),\n\tmarginBlockEnd: z\n\t\t.optional(GridGapValueSchema)\n\t\t.check(z.describe('Extra space after this element, on top of the grid row gap.')),\n});\n\nexport const ItemGridBreakpointSchema = z.extend(\n\tz.omit(ElementGridPropertiesSchema, { placeSelf: true, subgrid: true }),\n\t{\n\t\thidden: z.optional(z.boolean()),\n\t},\n);\n\nexport const ElementGridConfigSchema = z.extend(ElementGridPropertiesSchema, {\n\tresponsive: responsiveSchema(ItemGridBreakpointSchema),\n});\n\nexport type GridBreakpointConfig = z.infer<typeof GridBreakpointConfigSchema>;\nexport type ItemGridBreakpointConfig = z.infer<typeof ItemGridBreakpointSchema>;\nexport type ElementGridConfig = z.infer<typeof ElementGridConfigSchema>;\nexport type GridLayoutConfig = z.infer<typeof GridLayoutConfigSchema>;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["z", "GridGapTokens", "GridGapValueSchema", "RESERVED_AREA_NAMES", "anyCase", "word", "char", "AREA_NAME_SOURCE", "GridAreaNameSchema", "perBreakpoint", "schema", "responsiveSchema", "GridAreaRowSchema", "GridAreaRowsSchema", "GridAreasSchema", "GridLayoutPropertiesSchema", "GridBreakpointConfigSchema", "GridLayoutConfigSchema", "GridWidthNames", "GridOffsetNames", "ElementGridPropertiesSchema", "ItemGridBreakpointSchema", "ElementGridConfigSchema"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schema-engine/layout",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"description": "Domain-neutral layout for Schema Engine: a named grid, appearance axes and a theme compiler",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"schema-engine",
|
|
@@ -52,10 +52,13 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@standard-schema/spec": "^1.1.0",
|
|
55
|
-
"@schema-engine/registry": "^0.5.
|
|
55
|
+
"@schema-engine/registry": "^0.5.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
+
"@vitest/browser": "^5.1.1",
|
|
59
|
+
"@vitest/browser-playwright": "^5.1.1",
|
|
58
60
|
"esbuild": "^0.27.0",
|
|
61
|
+
"playwright": "^1.63.0",
|
|
59
62
|
"tsc-alias": "^1.8.16",
|
|
60
63
|
"typescript": "^5.9.3",
|
|
61
64
|
"vitest": "^5.1.1",
|
package/skill/SKILL.md
CHANGED
|
@@ -19,7 +19,7 @@ This file is the router. It defines the concepts once; the references assume the
|
|
|
19
19
|
## Core concepts
|
|
20
20
|
|
|
21
21
|
- **registration**: `{ $type, schema, metadata, ... }`, where `$type` is the stable key, `schema` is any Standard Schema that describes its config, and `metadata` names it. Elements, recipes, actions, validation rules and appearance axes are all registrations.
|
|
22
|
-
- **registry**: a read-only registry, `createRegistry(kind, registrations)` from `@schema-engine/registry`, built once from a list. The last registration of a `$type` wins without a warning, which is how you replace a built-in.
|
|
22
|
+
- **registry**: a read-only registry, `createRegistry(kind, registrations)` from `@schema-engine/registry`, built once from a list. The last registration of a `$type` wins without a warning, which is how you replace a built-in; pass `{ duplicates: 'error' }` to make a repeat a build error instead.
|
|
23
23
|
- **document**: serializable data whose every node names a registration by `$type`. It is checked against the registrations at the boundary, so what is rendered or run has passed its schema.
|
|
24
24
|
- **action**: a registration with `execute` that runs on a trigger. Actions run as a sequence, an inner array is a parallel group, and a failure that sets `shouldContinue: false` stops what follows and cancels the group's siblings through their `signal`.
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ This file is the router. It defines the concepts once; the references assume the
|
|
|
27
27
|
|
|
28
28
|
- **config**: a form is plain data, a `FormConfig` of steps holding elements, each with a `$type`, a `name`, `rules` and `constraints`. `engine.defineForm()` (typed, in TypeScript) or `engine.validateForm(unknown)` (portable JSON) checks it against the engine's registrations and returns a frozen `NormalizedFormConfig` that the engine owns.
|
|
29
29
|
- **container**: the form's state, a `FormStateContainer` from `@schema-engine/forms/state-container`. It owns the nested values, errors, warnings, touched and dirty marks, field-array row ids and the validation in flight. Paths are dotted (`contacts.1.email`) and `FORM_ROOT` is the form itself. Every change is a command (`setValue`, `blur`, `reportNative`, `validate`, `submit`, `reset`, `fieldArray`), and every read is a pure selector over an immutable snapshot.
|
|
30
|
-
- **runtime**: `createFormRuntime` is the lifecycle every renderer shares. It builds the container and owns the submission, the wizard steps and their navigation, `form_mount` and `form_change`, and every action dispatch. A renderer supplies only what an element can do, such as focus.
|
|
30
|
+
- **runtime**: for renderer authors, `createFormRuntime` is the lifecycle every renderer shares, and a renderer creates one for each form it draws. It builds the container and owns the submission, the wizard steps and their navigation, `form_mount` and `form_change`, and every action dispatch. A renderer supplies only what an element can do, such as focus. An app does not create one: it gives the engine and a config to a renderer.
|
|
31
31
|
- **issues and the formatter**: the engine reports what is wrong as an issue (`type`, `source`, `ruleId`, `params`, `message`) and never makes up text. `formatIssue`, a function of the application, turns an issue into the words shown, and falls back to the issue's own `message`.
|
|
32
32
|
|
|
33
33
|
Outcomes use one vocabulary: a check or a submission ends `passed`, `invalid` or `overtaken`. `overtaken` means an edit or a reset outran the check, so there is no verdict and nothing to show.
|
|
@@ -49,31 +49,32 @@ A symbol has one import path. `@schema-engine/forms` has these entries: `.` (the
|
|
|
49
49
|
|
|
50
50
|
Each package ships this router as its own `skill/SKILL.md` and its references in its `skill/reference/` folder, so a reference is `node_modules/@schema-engine/<package>/skill/reference/<file>`, and any installed package has the router. Read the rows of the packages the project depends on and skip the others: a package that is not installed has no file. The deployed site serves the latest version of the router and of every reference at `/skill/`, with the references flat at `/skill/reference/<file>`.
|
|
51
51
|
|
|
52
|
-
| To do
|
|
53
|
-
|
|
|
54
|
-
| Register something, build a registry, or read a YAML document
|
|
55
|
-
| Parse, dispatch or cancel actions outside a form
|
|
56
|
-
| Build a grid, an appearance axis or a layout theme
|
|
57
|
-
| Create an engine, author a config, use the container
|
|
58
|
-
| Add a rule, explain a validation result, or translate messages
|
|
59
|
-
| Handle submit, server errors, CSRF or wizard steps
|
|
60
|
-
| Run code on a form event, or define a form action
|
|
61
|
-
| Render a form in React, or use its hooks
|
|
62
|
-
| Write or change a React field widget, and test it
|
|
63
|
-
| Render a form in Radiant, or reach the container from an element
|
|
64
|
-
| Write or change a Radiant field widget, and test it
|
|
52
|
+
| To do | Package | Reference |
|
|
53
|
+
| ---------------------------------------------------------------- | ------------------------------ | ------------------------------------ |
|
|
54
|
+
| Register something, build a registry, or read a YAML document | `@schema-engine/registry` | `reference/registry.md` |
|
|
55
|
+
| Parse, dispatch or cancel actions outside a form | `@schema-engine/actions` | `reference/actions.md` |
|
|
56
|
+
| Build a grid, an appearance axis or a layout theme | `@schema-engine/layout` | `reference/layout.md` |
|
|
57
|
+
| Create an engine, author a config, or use the container directly | `@schema-engine/forms` | `reference/forms.md` |
|
|
58
|
+
| Add a rule, explain a validation result, or translate messages | `@schema-engine/forms` | `reference/forms-validation.md` |
|
|
59
|
+
| Handle submit, server errors, CSRF or wizard steps | `@schema-engine/forms` | `reference/forms-submission.md` |
|
|
60
|
+
| Run code on a form event, or define a form action | `@schema-engine/forms` | `reference/forms-actions.md` |
|
|
61
|
+
| Render a form in React, or use its hooks | `@schema-engine/forms-react` | `reference/forms-react.md` |
|
|
62
|
+
| Write or change a React field widget, and test it | `@schema-engine/forms-react` | `reference/forms-react-widgets.md` |
|
|
63
|
+
| Render a form in Radiant, or reach the container from an element | `@schema-engine/forms-radiant` | `reference/forms-radiant.md` |
|
|
64
|
+
| Write or change a Radiant field widget, and test it | `@schema-engine/forms-radiant` | `reference/forms-radiant-widgets.md` |
|
|
65
65
|
|
|
66
66
|
## Documentation map
|
|
67
67
|
|
|
68
68
|
The full documentation is at `/docs` on the deployed site. The LLM-exported corpus is `/llms.txt` (index) and `/docs-llm/<section>/<slug>.md` (page bodies).
|
|
69
69
|
|
|
70
|
-
| Section | Path prefix
|
|
71
|
-
| ------------------------------ |
|
|
72
|
-
| Schema Engine | `/docs/schema-engine/introduction`
|
|
73
|
-
| `@schema-engine/registry` | `/docs/registry/overview`
|
|
74
|
-
| `@schema-engine/actions` | `/docs/actions/overview`
|
|
75
|
-
| `@schema-engine/forms` | `/docs/forms/overview`
|
|
76
|
-
| `@schema-engine/forms-react` | `/docs/forms-react/overview`
|
|
77
|
-
| `@schema-engine/forms-radiant` | `/docs/forms-radiant/overview`
|
|
78
|
-
| `@schema-engine/layout` | `/docs/layout/overview`
|
|
79
|
-
| Examples | `/docs/examples/overview`
|
|
70
|
+
| Section | Path prefix |
|
|
71
|
+
| ------------------------------ | ----------------------------------------- |
|
|
72
|
+
| Schema Engine | `/docs/schema-engine/introduction` |
|
|
73
|
+
| `@schema-engine/registry` | `/docs/registry/overview` |
|
|
74
|
+
| `@schema-engine/actions` | `/docs/actions/overview` |
|
|
75
|
+
| `@schema-engine/forms` | `/docs/forms/overview` |
|
|
76
|
+
| `@schema-engine/forms-react` | `/docs/forms-react/overview` |
|
|
77
|
+
| `@schema-engine/forms-radiant` | `/docs/forms-radiant/overview` |
|
|
78
|
+
| `@schema-engine/layout` | `/docs/layout/overview` |
|
|
79
|
+
| Examples | `/docs/examples/overview` |
|
|
80
|
+
| Renderer authors | `/docs/renderer-authors/write-a-renderer` |
|
|
@@ -37,12 +37,71 @@ export const containerStyle = getGridVariables({ columns: 2 }, theme.grid, []);
|
|
|
37
37
|
|
|
38
38
|
An axis is one independent dimension of appearance with 2 to 5 named values, each a set of semantic CSS tokens (`--` keys) that components read; components never read the value itself. `defineAxis({ $type, values, default, metadata })` builds one and throws on a bad name, a bad value count, a token that is not a custom property or a `default` that is not a value. `builtInAxes` is `size` (`compact`, `default`, `comfortable`) and `surface` (`flat`, `outlined`, `elevated`); axes are registrations, so a later axis of the same `$type` replaces the earlier one, and a list without `builtInAxes` has neither. An axis becomes a `data-se-<axis>` attribute, so a domain passes the attribute names it already writes as `reservedNames`.
|
|
39
39
|
|
|
40
|
+
An axis is for a look an author picks among a few. A value that every entity of a domain has for itself (a colour per machine, per brand, per tenant) is domain data, so it is not an axis, and `defineAxis` refuses more than five values. Write the domain's own attribute from the data (`data-machine="sampler"`, never a `data-se-*` name, which the renderers own), and have the host stylesheet map each value to the semantic tokens that components already read (`[data-machine="sampler"] { --primary: #e4572e; }`), generated from the same data. An axis value may read such a token (`'--se-surface-background': 'color-mix(in srgb, var(--primary) 12%, transparent)'`), so the pick stays a choice among a few looks while the colour stays the entity's. Choose an axis when an author picks among 2 to 5 looks, and identity tokens when every entity has its own value.
|
|
41
|
+
|
|
40
42
|
The pure helpers: `checkAppearance(authored, options)` validates a pick, `mergeAppearance(inherited, own)` lays a child over its parent, `pickSupportedAppearance(picks, axes)` keeps what an owner supports and `getAppearanceAttributes(selection)` produces the `data-se-*` attributes. Walking a document to inherit picks belongs to each domain. `createAppearanceSchema(registry)` is the closed schema of a pick, for JSON Schema export.
|
|
41
43
|
|
|
42
44
|
## Grid
|
|
43
45
|
|
|
44
|
-
A grid container takes `columns`, `gap`, `gapX`, `gapY`, `areas`, alignment and a `responsive` map by breakpoint; an item takes `width`, `offset`, `area`, `column`, `row`, self-alignment and block margins, and a `responsive` map by breakpoint that can also set `hidden`. `getGridVariables(grid, theme.grid, items)` and `getGridItemVariables(item.grid)` return records of `--se-grid-*` and `--se-item-*` custom properties that fit a React `style` and a plain `style` object. A renderer puts `GRID_CLASS` on every container, `GRID_ITEM_CLASS` on every item and `data-se-theme="<id>"` on both; the stylesheet selects only those hooks.
|
|
46
|
+
A grid container takes `columns`, `gap`, `gapX`, `gapY`, `areas`, alignment and a `responsive` map by breakpoint; a container also takes `autoFlow` (`'row'` or `'dense'`, top level only); an item takes `width`, `offset`, `span`, `area`, `column`, `row`, self-alignment and block margins, and a `responsive` map by breakpoint that can also set `hidden`. `getGridVariables(grid, theme.grid, items)` and `getGridItemVariables(item.grid)` return records of `--se-grid-*` and `--se-item-*` custom properties that fit a React `style` and a plain `style` object. A renderer puts `GRID_CLASS` on every container, `GRID_ITEM_CLASS` on every item and `data-se-theme="<id>"` on both; the stylesheet selects only those hooks.
|
|
47
|
+
|
|
48
|
+
Breakpoints measure the window by default (`@media`). `createLayoutTheme({ grid: { query: 'container' } })` makes the same breakpoints, gap ramps and cascade measure the grid's own wrapper (`@container se-grid`), for a grid in a card, sidebar or panel; the document does not change, only the theme. The wrapper is an element with `GRID_CONTAINER_CLASS` and `data-se-theme="<id>"` around each grid, nested grids included, because a grid and its items must query one box and an element cannot query its own size. The forms renderers add it only in container mode. A grid with no wrapper keeps its narrowest layout. The wrapper has inline-size containment: it collapses in a shrink-to-fit parent, contains `position: fixed` descendants, and an `em` breakpoint resolves against its font size. The two modes are different themes with different ids.
|
|
49
|
+
|
|
50
|
+
`grid: { subgrid: true }` on an item makes it span its parent's full row (`1 / -1`) and lay its own children on the parent's column tracks and gap, so nested fields line up with the fields around them. It is top level only, never in `responsive`, and the item may not set `width`, `offset`, `span`, `column`, `area`, `justifySelf` or `placeSelf` (`subgridPlacementIssue` reports the key). Put `GRID_SUBGRID_CLASS` and `data-se-theme` on the item, on every box between it and the inner grid, and on the inner `GRID_CLASS` grid, which gets no inline track variables and no `GRID_CONTAINER_CLASS` wrapper; a box that is not a subgrid, or that has `container-type`, silently makes the children one column. Keep a `<fieldset>` out of the chain, because Chromium does not make one a subgrid: use a `div` with `role="group"` and `aria-labelledby` its heading. Pass the children of every subgrid among the items you give `getGridVariables`, so the parent gets 12 tracks when they use `width`. The edge fields are inset by the item's border and padding; interior lines match exactly.
|
|
51
|
+
|
|
52
|
+
`span: n` (a positive integer, top level or per breakpoint) sizes an item in tracks and never past the grid's own: it compiles to `span min(n, var(--se-grid-track-count, 1))`. The grid publishes the count it draws as `--se-grid-tracks[-slot]` (`getGridVariables` writes it beside every template: `columns: n` gives `n`, named widths 12, `areas` the row length), the stylesheet resolves it through the same gated cascade as the template, so the clamp switches at the width the tracks do, in a media theme and in a container theme, and a subgrid inherits the resolved count of its parent grid. An item and the grid it contains must be different elements. `columns: 'auto'` has no countable tracks in CSS: a span there is one track, and `gridSpanIssues(grid, elements)` reports it (the path starts with the element's index) so a domain rejects it; give the grid `columns` per breakpoint instead, with a container theme. `spanPlacementIssue(element)` reports a `span` that shares a slot with `width`, `offset`, `column` or `area`. `autoFlow: 'dense'` backfills earlier gaps with later, smaller items; it changes visual order, not DOM or focus order. There is no `width: 'auto'`: content sizing is `columns: 'auto'` with `minColumnWidth`.
|
|
45
53
|
|
|
46
54
|
## Recipe protocol
|
|
47
55
|
|
|
48
|
-
A recipe composes named slots into a view. `defineRecipeProtocol` declares a domain's slots and kinds once; `defineProtocolRecipeSpec`, `bindRecipe` and `createRecipeRegistry` build the recipes of that protocol. Forms is the first protocol.
|
|
56
|
+
A recipe composes named slots into a view. `defineRecipeProtocol` declares a domain's slots and kinds once; `defineProtocolRecipeSpec`, `bindRecipe` and `createRecipeRegistry` build the recipes of that protocol. Forms is the first protocol, and nothing in the contract is form-specific. A spec's `slotSchemas` take any Standard Schema that validates synchronously (Zod Mini, Valibot or one you write), and `spec.schema` is a Standard Schema, not a Zod one: validate it with `safeParseStandardSchema` (`@schema-engine/registry`). A slot that declares `appearanceAxes` must take an `appearance` key in its schema input, which the types check. `bindRecipe` keeps the slot schemas on the registration as `slotSchemas`, which `createRecipeRegistry` checks against the recipe's `slots`.
|
|
57
|
+
|
|
58
|
+
## Recipes outside forms
|
|
59
|
+
|
|
60
|
+
The recipe holds the shell and the config of each slot: the slot schemas, `slotDefaults` and `appearanceAxes`, plus a render payload that `bindRecipe` attaches (a React component for one renderer, a Radiant one for another; the package never reads it). The document holds which recipe it takes, as a `view` (the recipe's `$type` and the config of its slots), and the content of the slots, which is plain data the recipe does not read. `resolveRecipeView(recipe, view, { axes, inherited })` lays the recipe's defaults under the view, resolves each slot's appearance and parses the result, returning `{ issues, view }` or `{ issues, schemaIssues }`; `readSlotConfig(view, slot, schema)` reads one slot typed. The same spec bound twice, once for each renderer, draws the same document in both.
|
|
61
|
+
|
|
62
|
+
```ts title="layout/card-recipe.ts"
|
|
63
|
+
import * as v from 'valibot';
|
|
64
|
+
import {
|
|
65
|
+
bindRecipe,
|
|
66
|
+
createRecipeRegistry,
|
|
67
|
+
defineProtocolRecipeSpec,
|
|
68
|
+
defineRecipeProtocol,
|
|
69
|
+
getDefaultLayoutTheme,
|
|
70
|
+
readSlotConfig,
|
|
71
|
+
resolveRecipeView,
|
|
72
|
+
} from '@schema-engine/layout';
|
|
73
|
+
|
|
74
|
+
export const cardProtocol = defineRecipeProtocol({
|
|
75
|
+
slots: ['shell', 'header', 'body', 'footer'],
|
|
76
|
+
kinds: ['card'],
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const cardSpec = defineProtocolRecipeSpec(cardProtocol, {
|
|
80
|
+
$type: 'card',
|
|
81
|
+
kind: 'card',
|
|
82
|
+
metadata: { name: 'Card' },
|
|
83
|
+
slotSchemas: {
|
|
84
|
+
shell: v.strictObject({ appearance: v.optional(v.record(v.string(), v.string())) }),
|
|
85
|
+
header: v.strictObject({ level: v.optional(v.picklist([1, 2, 3, 4, 5, 6]), 2) }),
|
|
86
|
+
body: v.strictObject({ gap: v.optional(v.picklist(['sm', 'md']), 'md') }),
|
|
87
|
+
footer: v.strictObject({ align: v.optional(v.picklist(['start', 'end']), 'start') }),
|
|
88
|
+
},
|
|
89
|
+
slotDefaults: { header: { level: 3 } },
|
|
90
|
+
appearanceAxes: { shell: ['size', 'surface'] },
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const recipes = createRecipeRegistry(cardProtocol, [bindRecipe(cardSpec, { tag: 'article' })]);
|
|
94
|
+
|
|
95
|
+
const recipe = recipes.get('card')!;
|
|
96
|
+
const scope = { axes: getDefaultLayoutTheme().axes, inherited: {} };
|
|
97
|
+
|
|
98
|
+
export const resolved = resolveRecipeView(
|
|
99
|
+
recipe,
|
|
100
|
+
{ $type: 'card', shell: { appearance: { surface: 'outlined' } }, footer: { align: 'end' } },
|
|
101
|
+
scope,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
export const undeclared = resolveRecipeView(recipe, { $type: 'card', aside: {} }, scope);
|
|
105
|
+
|
|
106
|
+
export const footer = resolved.view && readSlotConfig(resolved.view, 'footer', cardSpec.slotSchemas.footer);
|
|
107
|
+
```
|