@yahoo/uds-create-config 3.0.6 → 3.0.8
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/configs/CanvasConfig.d.ts +24 -0
- package/dist/configs/react-native-system.d.ts +20 -2
- package/dist/configs/react-native-system.js +1 -1
- package/dist/configs/system.d.ts +18 -0
- package/dist/configs/system.js +5 -1
- package/dist/entities/native/NativeStyleProperty.d.ts +2 -2
- package/dist/entities/system/Component.d.ts +12 -0
- package/dist/entities/system/Component.js +6 -0
- package/dist/entities/system/Font.d.ts +25 -1
- package/dist/entities/system/Font.js +34 -1
- package/dist/entities/system/Token.js +1 -1
- package/dist/entities/system/defineComponent.d.ts +60 -14
- package/dist/entities/system/defineComponent.js +10 -1
- package/dist/entities/system/icon-library.js +5 -1
- package/dist/entities/system/style-bag.js +1 -0
- package/dist/framework/Config.d.ts +16 -1
- package/dist/framework/Config.js +33 -1
- package/dist/framework/projections.d.ts +23 -2
- package/dist/framework/projections.js +67 -11
- package/dist/framework/render-spec.js +16 -1
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/utils/field-schema.js +3 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/migrations/2.0.0/v1-artifact.d.ts +20 -0
- package/dist/migrations/2.0.0/v1-artifact.js +358 -18
- package/dist/migrations/20260912161840_preview_conditions.d.ts +9 -0
- package/dist/migrations/20260912161840_preview_conditions.js +10 -0
- package/dist/migrations/20260912164927_font_variable.d.ts +18 -0
- package/dist/migrations/20260912164927_font_variable.js +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -255,6 +255,10 @@ declare const Node: EntityClass<z.ZodObject<{
|
|
|
255
255
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
256
256
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
257
257
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
258
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
259
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
260
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
261
|
+
}, z.core.$strip>>>;
|
|
258
262
|
file: z.ZodOptional<z.ZodObject<{
|
|
259
263
|
__ref: z.ZodString;
|
|
260
264
|
}, z.core.$strip>>;
|
|
@@ -369,6 +373,10 @@ declare const Node: EntityClass<z.ZodObject<{
|
|
|
369
373
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
370
374
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
371
375
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
376
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
377
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
378
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
379
|
+
}, z.core.$strip>>>;
|
|
372
380
|
file: z.ZodOptional<z.ZodObject<{
|
|
373
381
|
__ref: z.ZodString;
|
|
374
382
|
}, z.core.$strip>>;
|
|
@@ -1113,6 +1121,10 @@ declare const CanvasConfig: ConfigClass<{
|
|
|
1113
1121
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
1114
1122
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
1115
1123
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1124
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1125
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1126
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1127
|
+
}, z.core.$strip>>>;
|
|
1116
1128
|
file: z.ZodOptional<z.ZodObject<{
|
|
1117
1129
|
__ref: z.ZodString;
|
|
1118
1130
|
}, z.core.$strip>>;
|
|
@@ -1227,6 +1239,10 @@ declare const CanvasConfig: ConfigClass<{
|
|
|
1227
1239
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
1228
1240
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
1229
1241
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1242
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1243
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1244
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
1245
|
+
}, z.core.$strip>>>;
|
|
1230
1246
|
file: z.ZodOptional<z.ZodObject<{
|
|
1231
1247
|
__ref: z.ZodString;
|
|
1232
1248
|
}, z.core.$strip>>;
|
|
@@ -2236,6 +2252,10 @@ declare function createCanvasConfig(system: AnySystemConfig): ConfigInstance<{
|
|
|
2236
2252
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
2237
2253
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
2238
2254
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2255
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2256
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2257
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2258
|
+
}, z.core.$strip>>>;
|
|
2239
2259
|
file: z.ZodOptional<z.ZodObject<{
|
|
2240
2260
|
__ref: z.ZodString;
|
|
2241
2261
|
}, z.core.$strip>>;
|
|
@@ -2350,6 +2370,10 @@ declare function createCanvasConfig(system: AnySystemConfig): ConfigInstance<{
|
|
|
2350
2370
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
2351
2371
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
2352
2372
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2373
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
2374
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2375
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
2376
|
+
}, z.core.$strip>>>;
|
|
2353
2377
|
file: z.ZodOptional<z.ZodObject<{
|
|
2354
2378
|
__ref: z.ZodString;
|
|
2355
2379
|
}, z.core.$strip>>;
|
|
@@ -182,6 +182,10 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
182
182
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
183
183
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
184
184
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
185
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
186
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
187
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
188
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
185
189
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
186
190
|
__ref: _$zod.ZodString;
|
|
187
191
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -296,6 +300,10 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
296
300
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
297
301
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
298
302
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
303
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
304
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
305
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
306
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
299
307
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
300
308
|
__ref: _$zod.ZodString;
|
|
301
309
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -874,6 +882,7 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
874
882
|
overflow: "overflow";
|
|
875
883
|
padding: "padding";
|
|
876
884
|
width: "width";
|
|
885
|
+
fontFamily: "fontFamily";
|
|
877
886
|
alignContent: "alignContent";
|
|
878
887
|
alignItems: "alignItems";
|
|
879
888
|
alignSelf: "alignSelf";
|
|
@@ -925,7 +934,6 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
925
934
|
flexGrow: "flexGrow";
|
|
926
935
|
flexShrink: "flexShrink";
|
|
927
936
|
flexWrap: "flexWrap";
|
|
928
|
-
fontFamily: "fontFamily";
|
|
929
937
|
fontSize: "fontSize";
|
|
930
938
|
fontStyle: "fontStyle";
|
|
931
939
|
fontVariant: "fontVariant";
|
|
@@ -1041,6 +1049,7 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
1041
1049
|
postscriptName: _$zod.ZodOptional<_$zod.ZodString>;
|
|
1042
1050
|
}, _$zod_v4_core0.$strip>>>;
|
|
1043
1051
|
fallbackStack: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
|
|
1052
|
+
variable: _$zod.ZodOptional<_$zod.ZodString>;
|
|
1044
1053
|
isVariableFont: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
1045
1054
|
}, _$zod_v4_core0.$strict>, _$zod.ZodObject<{
|
|
1046
1055
|
version: _$zod.ZodOptional<_$zod.ZodString>;
|
|
@@ -1676,6 +1685,10 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
1676
1685
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
1677
1686
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
1678
1687
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
1688
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
1689
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1690
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1691
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
1679
1692
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
1680
1693
|
__ref: _$zod.ZodString;
|
|
1681
1694
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -1790,6 +1803,10 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
1790
1803
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
1791
1804
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
1792
1805
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
1806
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
1807
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1808
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1809
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
1793
1810
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
1794
1811
|
__ref: _$zod.ZodString;
|
|
1795
1812
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -2368,6 +2385,7 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
2368
2385
|
overflow: "overflow";
|
|
2369
2386
|
padding: "padding";
|
|
2370
2387
|
width: "width";
|
|
2388
|
+
fontFamily: "fontFamily";
|
|
2371
2389
|
alignContent: "alignContent";
|
|
2372
2390
|
alignItems: "alignItems";
|
|
2373
2391
|
alignSelf: "alignSelf";
|
|
@@ -2419,7 +2437,6 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
2419
2437
|
flexGrow: "flexGrow";
|
|
2420
2438
|
flexShrink: "flexShrink";
|
|
2421
2439
|
flexWrap: "flexWrap";
|
|
2422
|
-
fontFamily: "fontFamily";
|
|
2423
2440
|
fontSize: "fontSize";
|
|
2424
2441
|
fontStyle: "fontStyle";
|
|
2425
2442
|
fontVariant: "fontVariant";
|
|
@@ -2535,6 +2552,7 @@ declare const ReactNativeSystem: ConfigClass<{
|
|
|
2535
2552
|
postscriptName: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2536
2553
|
}, _$zod_v4_core0.$strip>>>;
|
|
2537
2554
|
fallbackStack: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
|
|
2555
|
+
variable: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2538
2556
|
isVariableFont: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
2539
2557
|
}, _$zod_v4_core0.$strict>, _$zod.ZodObject<{
|
|
2540
2558
|
version: _$zod.ZodOptional<_$zod.ZodString>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Font } from "../entities/system/Font.js";
|
|
1
2
|
import { Composite } from "../entities/system/Composite.js";
|
|
2
3
|
import { Package } from "../entities/system/Package.js";
|
|
3
4
|
import { File } from "../entities/system/File.js";
|
|
@@ -9,7 +10,6 @@ import { Tool } from "../entities/system/Tool.js";
|
|
|
9
10
|
import { registerSchemaMigrations, registeredSchemaMigrations } from "../framework/schema-version.js";
|
|
10
11
|
import { defineConfig } from "../framework/defineConfig.js";
|
|
11
12
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
12
|
-
import { Font } from "../entities/system/Font.js";
|
|
13
13
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
14
14
|
import { NATIVE_CONFIG_NAME } from "./platform.js";
|
|
15
15
|
import { LinkedSystem } from "../entities/system/LinkedSystem.js";
|
package/dist/configs/system.d.ts
CHANGED
|
@@ -170,6 +170,10 @@ declare const System: ConfigClass<{
|
|
|
170
170
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
171
171
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
172
172
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
173
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
174
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
175
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
176
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
173
177
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
174
178
|
__ref: _$zod.ZodString;
|
|
175
179
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -284,6 +288,10 @@ declare const System: ConfigClass<{
|
|
|
284
288
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
285
289
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
286
290
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
291
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
292
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
293
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
294
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
287
295
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
288
296
|
__ref: _$zod.ZodString;
|
|
289
297
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -892,6 +900,7 @@ declare const System: ConfigClass<{
|
|
|
892
900
|
postscriptName: _$zod.ZodOptional<_$zod.ZodString>;
|
|
893
901
|
}, _$zod_v4_core0.$strip>>>;
|
|
894
902
|
fallbackStack: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
|
|
903
|
+
variable: _$zod.ZodOptional<_$zod.ZodString>;
|
|
895
904
|
isVariableFont: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
896
905
|
}, _$zod_v4_core0.$strict>, _$zod.ZodObject<{
|
|
897
906
|
version: _$zod.ZodOptional<_$zod.ZodString>;
|
|
@@ -1536,6 +1545,10 @@ declare const System: ConfigClass<{
|
|
|
1536
1545
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
1537
1546
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
1538
1547
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
1548
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
1549
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1550
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1551
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
1539
1552
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
1540
1553
|
__ref: _$zod.ZodString;
|
|
1541
1554
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -1650,6 +1663,10 @@ declare const System: ConfigClass<{
|
|
|
1650
1663
|
anatomy: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<ComponentElementBody, unknown, _$zod_v4_core0.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
1651
1664
|
defaultProps: _$zod.ZodOptional<SubEntityClass<_$zod.ZodType<StyleValue, unknown, _$zod_v4_core0.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
1652
1665
|
previewProps: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>>;
|
|
1666
|
+
previewWhen: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodObject<{
|
|
1667
|
+
when: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1668
|
+
props: _$zod.ZodRecord<_$zod.ZodString, _$zod.ZodUnknown>;
|
|
1669
|
+
}, _$zod_v4_core0.$strip>>>;
|
|
1653
1670
|
file: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
1654
1671
|
__ref: _$zod.ZodString;
|
|
1655
1672
|
}, _$zod_v4_core0.$strip>>;
|
|
@@ -2258,6 +2275,7 @@ declare const System: ConfigClass<{
|
|
|
2258
2275
|
postscriptName: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2259
2276
|
}, _$zod_v4_core0.$strip>>>;
|
|
2260
2277
|
fallbackStack: _$zod.ZodOptional<_$zod.ZodArray<_$zod.ZodString>>;
|
|
2278
|
+
variable: _$zod.ZodOptional<_$zod.ZodString>;
|
|
2261
2279
|
isVariableFont: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
2262
2280
|
}, _$zod_v4_core0.$strict>, _$zod.ZodObject<{
|
|
2263
2281
|
version: _$zod.ZodOptional<_$zod.ZodString>;
|
package/dist/configs/system.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Font } from "../entities/system/Font.js";
|
|
1
2
|
import { Composite } from "../entities/system/Composite.js";
|
|
2
3
|
import { Modifier } from "../entities/system/Modifier.js";
|
|
3
4
|
import { Settings } from "../entities/system/Settings.js";
|
|
@@ -12,7 +13,6 @@ import { Tool } from "../entities/system/Tool.js";
|
|
|
12
13
|
import { registerSchemaMigrations, registeredSchemaMigrations } from "../framework/schema-version.js";
|
|
13
14
|
import { defineConfig } from "../framework/defineConfig.js";
|
|
14
15
|
import { CanvasRole } from "../entities/system/CanvasRole.js";
|
|
15
|
-
import { Font } from "../entities/system/Font.js";
|
|
16
16
|
import { GlobalStyle } from "../entities/system/GlobalStyle.js";
|
|
17
17
|
import { Guidance } from "../entities/system/Guidance.js";
|
|
18
18
|
import { GuidanceStyle } from "../entities/system/GuidanceStyle.js";
|
|
@@ -25,6 +25,8 @@ import { settingsAsKindMigration } from "../migrations/20260908171448_settings_a
|
|
|
25
25
|
import { visibleStatePointerMigration } from "../migrations/20260908194245_visible_state_pointer.js";
|
|
26
26
|
import { iconKnockoutVariantsMigration } from "../migrations/20260909183001_icon_knockout_variants.js";
|
|
27
27
|
import { linkedSystemLinkOpsMigration } from "../migrations/20260910212453_linked_system_link_ops.js";
|
|
28
|
+
import { previewConditionsMigration } from "../migrations/20260912161840_preview_conditions.js";
|
|
29
|
+
import { fontVariableMigration } from "../migrations/20260912164927_font_variable.js";
|
|
28
30
|
//#region src/configs/system.ts
|
|
29
31
|
/**
|
|
30
32
|
* `System` — the design-system config TYPE. Declares the exact kinds a design system owns (tokens,
|
|
@@ -70,5 +72,7 @@ if (!registeredSchemaMigrations().has(20260908171448)) registerSchemaMigrations(
|
|
|
70
72
|
if (!registeredSchemaMigrations().has(20260908194245)) registerSchemaMigrations(visibleStatePointerMigration);
|
|
71
73
|
if (!registeredSchemaMigrations().has(20260909183001)) registerSchemaMigrations(iconKnockoutVariantsMigration);
|
|
72
74
|
if (!registeredSchemaMigrations().has(20260910212453)) registerSchemaMigrations(linkedSystemLinkOpsMigration);
|
|
75
|
+
if (!registeredSchemaMigrations().has(20260912161840)) registerSchemaMigrations(previewConditionsMigration);
|
|
76
|
+
if (!registeredSchemaMigrations().has(20260912164927)) registerSchemaMigrations(fontVariableMigration);
|
|
73
77
|
//#endregion
|
|
74
78
|
export { System };
|
|
@@ -30,6 +30,7 @@ declare const rnStyleKey: z.ZodEnum<{
|
|
|
30
30
|
overflow: "overflow";
|
|
31
31
|
padding: "padding";
|
|
32
32
|
width: "width";
|
|
33
|
+
fontFamily: "fontFamily";
|
|
33
34
|
alignContent: "alignContent";
|
|
34
35
|
alignItems: "alignItems";
|
|
35
36
|
alignSelf: "alignSelf";
|
|
@@ -81,7 +82,6 @@ declare const rnStyleKey: z.ZodEnum<{
|
|
|
81
82
|
flexGrow: "flexGrow";
|
|
82
83
|
flexShrink: "flexShrink";
|
|
83
84
|
flexWrap: "flexWrap";
|
|
84
|
-
fontFamily: "fontFamily";
|
|
85
85
|
fontSize: "fontSize";
|
|
86
86
|
fontStyle: "fontStyle";
|
|
87
87
|
fontVariant: "fontVariant";
|
|
@@ -197,6 +197,7 @@ declare const NativeStyleProperty: EntityClass<z.ZodObject<Omit<{
|
|
|
197
197
|
overflow: "overflow";
|
|
198
198
|
padding: "padding";
|
|
199
199
|
width: "width";
|
|
200
|
+
fontFamily: "fontFamily";
|
|
200
201
|
alignContent: "alignContent";
|
|
201
202
|
alignItems: "alignItems";
|
|
202
203
|
alignSelf: "alignSelf";
|
|
@@ -248,7 +249,6 @@ declare const NativeStyleProperty: EntityClass<z.ZodObject<Omit<{
|
|
|
248
249
|
flexGrow: "flexGrow";
|
|
249
250
|
flexShrink: "flexShrink";
|
|
250
251
|
flexWrap: "flexWrap";
|
|
251
|
-
fontFamily: "fontFamily";
|
|
252
252
|
fontSize: "fontSize";
|
|
253
253
|
fontStyle: "fontStyle";
|
|
254
254
|
fontVariant: "fontVariant";
|
|
@@ -421,6 +421,10 @@ declare const componentFields: z.ZodObject<{
|
|
|
421
421
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
422
422
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
423
423
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
424
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
425
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
426
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
427
|
+
}, z.core.$strip>>>;
|
|
424
428
|
file: z.ZodOptional<z.ZodObject<{
|
|
425
429
|
__ref: z.ZodString;
|
|
426
430
|
}, z.core.$strip>>;
|
|
@@ -540,6 +544,10 @@ declare const ComponentEntity: EntityClass<z.ZodObject<{
|
|
|
540
544
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
541
545
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
542
546
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
547
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
548
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
549
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
550
|
+
}, z.core.$strip>>>;
|
|
543
551
|
file: z.ZodOptional<z.ZodObject<{
|
|
544
552
|
__ref: z.ZodString;
|
|
545
553
|
}, z.core.$strip>>;
|
|
@@ -654,6 +662,10 @@ declare const ComponentEntity: EntityClass<z.ZodObject<{
|
|
|
654
662
|
anatomy: z.ZodOptional<SubEntityClass<z.ZodType<ComponentElementBody, unknown, z.core.$ZodTypeInternals<ComponentElementBody, unknown>>>>;
|
|
655
663
|
defaultProps: z.ZodOptional<SubEntityClass<z.ZodType<StyleValue, unknown, z.core.$ZodTypeInternals<StyleValue, unknown>>>>;
|
|
656
664
|
previewProps: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
665
|
+
previewWhen: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
666
|
+
when: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
667
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
668
|
+
}, z.core.$strip>>>;
|
|
657
669
|
file: z.ZodOptional<z.ZodObject<{
|
|
658
670
|
__ref: z.ZodString;
|
|
659
671
|
}, z.core.$strip>>;
|
|
@@ -1207,6 +1207,12 @@ const componentFields = z.strictObject({
|
|
|
1207
1207
|
* into the tree by invoking a render with them, so a tile's example icon ends up stored as
|
|
1208
1208
|
* part of the component itself. */
|
|
1209
1209
|
previewProps: z.record(z.string(), z.unknown()).optional().describe("The props the catalogue tile and the variant matrix render with. A component whose root takes children renders empty until this or `defaultProps` carries some."),
|
|
1210
|
+
/** Preview props that hold under a condition on the cell — see `preview({ when })`. Like
|
|
1211
|
+
* `previewProps`, read off `.preview()` at build and never authored as data. */
|
|
1212
|
+
previewWhen: z.array(z.object({
|
|
1213
|
+
when: z.record(z.string(), z.unknown()),
|
|
1214
|
+
props: z.record(z.string(), z.unknown())
|
|
1215
|
+
})).optional().describe("Preview props that hold only when the cell matches `when`, in the grammar a style rule uses: `{ \"when\": { \"type\": \"image\" }, \"props\": { \"src\": \"…\" } }`. A condition on a prop no rule styles makes that prop a preview axis with the value named."),
|
|
1210
1216
|
/**
|
|
1211
1217
|
* The source that implements this component — a ref, because the file is an entity the seal owns.
|
|
1212
1218
|
*
|
|
@@ -40,9 +40,33 @@ declare const Font: EntityClass<z.ZodObject<{
|
|
|
40
40
|
postscriptName: z.ZodOptional<z.ZodString>;
|
|
41
41
|
}, z.core.$strip>>>;
|
|
42
42
|
fallbackStack: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
variable: z.ZodOptional<z.ZodString>;
|
|
43
44
|
isVariableFont: z.ZodOptional<z.ZodBoolean>;
|
|
44
45
|
}, z.core.$strict>, z.ZodObject<{
|
|
45
46
|
version: z.ZodOptional<z.ZodString>;
|
|
46
47
|
}, z.core.$strict>, "font", Record<never, never>, Record<never, never>, false>;
|
|
48
|
+
/**
|
|
49
|
+
* The `font-family` value a family stands for: its own name, quoted, then its fallback stack as
|
|
50
|
+
* authored — `"YA Sans VF", Helvetica Neue, Arial, sans-serif`.
|
|
51
|
+
*
|
|
52
|
+
* This is what a `font:` ref DENOTES wherever a value is wanted: a `fontFamily/sans` token valued
|
|
53
|
+
* `Font.ref('fonts/yas')` emits this string as its custom property, a Studio specimen paints in it,
|
|
54
|
+
* and a picker matches the active card against it. One derivation, so the three cannot disagree —
|
|
55
|
+
* and the reason a token's stack is not a second field of its own: the family already knows it.
|
|
56
|
+
*
|
|
57
|
+
* The family name is always quoted (a name with spaces needs it; a name without tolerates it), the
|
|
58
|
+
* fallbacks are not — `sans-serif` is a generic keyword, and quoting one turns it into a family
|
|
59
|
+
* nothing has. Blank fallbacks are dropped rather than emitted as empty list members.
|
|
60
|
+
*
|
|
61
|
+
* A family the host loads under a custom property (`variable`) reads that property FIRST, with the
|
|
62
|
+
* whole named stack as the property's fallback: `var(--uds-font-family-inter, "Inter", ui-sans-serif,
|
|
63
|
+
* …)`. The host's face wins where it is defined, and where it is not — a consumer without the loader,
|
|
64
|
+
* a canvas the host did not wrap — the family by name and its fallbacks paint as they would anyway.
|
|
65
|
+
*/
|
|
66
|
+
declare function fontFamilyStack(font: {
|
|
67
|
+
readonly fontFamily: string;
|
|
68
|
+
readonly fallbackStack?: readonly string[] | undefined;
|
|
69
|
+
readonly variable?: string | undefined;
|
|
70
|
+
}): string;
|
|
47
71
|
//#endregion
|
|
48
|
-
export { Font, FontFile };
|
|
72
|
+
export { Font, FontFile, fontFamilyStack };
|
|
@@ -46,11 +46,44 @@ const Font = defineEntity({
|
|
|
46
46
|
files: FontFile.optional(),
|
|
47
47
|
/** Families to fall back to after this one, for a `font-family` stack. */
|
|
48
48
|
fallbackStack: z.array(z.string()).optional(),
|
|
49
|
+
/**
|
|
50
|
+
* A CSS custom property the HOST publishes the loaded face's family under — `next/font`'s
|
|
51
|
+
* `variable` option (`--uds-font-family-inter`), or any loader that hands the page a variable
|
|
52
|
+
* rather than a `@font-face`. When set, the family's stack reads the property first and falls
|
|
53
|
+
* back to the family by name: `var(--uds-font-family-inter, "Inter", ui-sans-serif, …)`. That
|
|
54
|
+
* is how a token can be `Font.ref(…)` to such a family and still render the host's face, whose
|
|
55
|
+
* real family name (`__Inter_a1b2c3`) nothing in a config can know.
|
|
56
|
+
*/
|
|
57
|
+
variable: z.string().regex(/^--[A-Za-z0-9_-]+$/, "a CSS custom property name: `--name`").optional(),
|
|
49
58
|
/** Set explicitly; otherwise inferred from a file declaring a weight RANGE. */
|
|
50
59
|
isVariableFont: z.boolean().optional()
|
|
51
60
|
}),
|
|
52
61
|
groupFields: z.strictObject({ version: z.string().optional() }),
|
|
53
62
|
subEntities: { files: FontFile }
|
|
54
63
|
});
|
|
64
|
+
/**
|
|
65
|
+
* The `font-family` value a family stands for: its own name, quoted, then its fallback stack as
|
|
66
|
+
* authored — `"YA Sans VF", Helvetica Neue, Arial, sans-serif`.
|
|
67
|
+
*
|
|
68
|
+
* This is what a `font:` ref DENOTES wherever a value is wanted: a `fontFamily/sans` token valued
|
|
69
|
+
* `Font.ref('fonts/yas')` emits this string as its custom property, a Studio specimen paints in it,
|
|
70
|
+
* and a picker matches the active card against it. One derivation, so the three cannot disagree —
|
|
71
|
+
* and the reason a token's stack is not a second field of its own: the family already knows it.
|
|
72
|
+
*
|
|
73
|
+
* The family name is always quoted (a name with spaces needs it; a name without tolerates it), the
|
|
74
|
+
* fallbacks are not — `sans-serif` is a generic keyword, and quoting one turns it into a family
|
|
75
|
+
* nothing has. Blank fallbacks are dropped rather than emitted as empty list members.
|
|
76
|
+
*
|
|
77
|
+
* A family the host loads under a custom property (`variable`) reads that property FIRST, with the
|
|
78
|
+
* whole named stack as the property's fallback: `var(--uds-font-family-inter, "Inter", ui-sans-serif,
|
|
79
|
+
* …)`. The host's face wins where it is defined, and where it is not — a consumer without the loader,
|
|
80
|
+
* a canvas the host did not wrap — the family by name and its fallbacks paint as they would anyway.
|
|
81
|
+
*/
|
|
82
|
+
function fontFamilyStack(font) {
|
|
83
|
+
const family = `"${font.fontFamily.replace(/^['"]|['"]$/g, "")}"`;
|
|
84
|
+
const fallbacks = (font.fallbackStack ?? []).map((name) => name.trim()).filter((name) => name.length > 0);
|
|
85
|
+
const named = fallbacks.length > 0 ? `${family}, ${fallbacks.join(", ")}` : family;
|
|
86
|
+
return font.variable ? `var(${font.variable}, ${named})` : named;
|
|
87
|
+
}
|
|
55
88
|
//#endregion
|
|
56
|
-
export { Font, FontFile };
|
|
89
|
+
export { Font, FontFile, fontFamilyStack };
|
|
@@ -2,8 +2,8 @@ import { isRef, pathOf, ref, sourceOf } from "../../framework/utils/refs.js";
|
|
|
2
2
|
import { defineEntity } from "../../framework/defineEntity.js";
|
|
3
3
|
import { defineSubEntity } from "../../framework/defineSubEntity.js";
|
|
4
4
|
import { derivedColor, gradient } from "./color.js";
|
|
5
|
-
import { Modifier } from "./Modifier.js";
|
|
6
5
|
import { Font } from "./Font.js";
|
|
6
|
+
import { Modifier } from "./Modifier.js";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
//#region src/entities/system/Token.ts
|
|
9
9
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Ref } from "../../framework/utils/refs.js";
|
|
1
|
+
import { Ref as Ref$1 } from "../../framework/utils/refs.js";
|
|
2
2
|
import { Authored } from "../../framework/authoring.js";
|
|
3
3
|
import { StyleValue } from "./style-bag.js";
|
|
4
4
|
import { VariantValues } from "./Component.js";
|
|
5
|
-
import { ComponentPropsWithoutRef, JSX, ReactNode } from "react";
|
|
5
|
+
import { ComponentPropsWithoutRef, ElementType, JSX, ReactNode, Ref } from "react";
|
|
6
6
|
|
|
7
7
|
//#region src/entities/system/defineComponent.d.ts
|
|
8
8
|
/**
|
|
@@ -34,7 +34,7 @@ type PackageElement = ((...args: never[]) => unknown) | (abstract new (...args:
|
|
|
34
34
|
* it names exposes are gone by the time anything could read them, and a component built on `Pressable`
|
|
35
35
|
* typed `onClick` as nothing at all.
|
|
36
36
|
*/
|
|
37
|
-
type LayerElement = string | ComponentElement | Ref | PackageElement;
|
|
37
|
+
type LayerElement = string | ComponentElement | Ref$1 | PackageElement;
|
|
38
38
|
/**
|
|
39
39
|
* A component's layers. `root` is REQUIRED and is the element a consumer addresses: its React props
|
|
40
40
|
* are the component's props, and a component that doesn't declare one has no element to be.
|
|
@@ -87,7 +87,7 @@ interface SlotDecl {
|
|
|
87
87
|
* into a hole. A route into a value prop has nothing to narrow: which values are valid is that prop's
|
|
88
88
|
* own declaration.
|
|
89
89
|
*/
|
|
90
|
-
accepts?: Ref | Ref[];
|
|
90
|
+
accepts?: Ref$1 | Ref$1[];
|
|
91
91
|
text?: boolean;
|
|
92
92
|
required?: boolean;
|
|
93
93
|
}
|
|
@@ -120,14 +120,14 @@ type Forwarded = '*' | readonly string[];
|
|
|
120
120
|
interface ForwardDecl<Path extends string = string> {
|
|
121
121
|
type: 'forward';
|
|
122
122
|
/** `<layer>/<prop>` as authored; a `layerRef` once stored, with the prop moved to `into`. */
|
|
123
|
-
target: Path | Ref;
|
|
123
|
+
target: Path | Ref$1;
|
|
124
124
|
/** STORED only — a member ref at the prop on that layer's element
|
|
125
125
|
* (`component:Input#props/disabled`). Minted at registration, when the layer's element has a path. */
|
|
126
|
-
into?: string | Ref;
|
|
126
|
+
into?: string | Ref$1;
|
|
127
127
|
/** Only where this route LANDS on a hole — it means exactly what {@link SlotDecl.accepts} means.
|
|
128
128
|
* That the target is a hole is computed from it (`routesContent`), so the rule is checked rather
|
|
129
129
|
* than trusted, and a route into a value prop is refused by name. */
|
|
130
|
-
accepts?: Ref | Ref[];
|
|
130
|
+
accepts?: Ref$1 | Ref$1[];
|
|
131
131
|
text?: boolean;
|
|
132
132
|
required?: boolean;
|
|
133
133
|
}
|
|
@@ -151,15 +151,15 @@ interface ForwardDecl<Path extends string = string> {
|
|
|
151
151
|
*/
|
|
152
152
|
type PropDecl<Path extends string = string> = SlotDecl | ForwardDecl<Path> | {
|
|
153
153
|
type: 'variant';
|
|
154
|
-
value: readonly string[] | VariantValues | Ref;
|
|
154
|
+
value: readonly string[] | VariantValues | Ref$1;
|
|
155
155
|
required?: boolean;
|
|
156
156
|
} | {
|
|
157
157
|
type: 'styleProperty';
|
|
158
|
-
value: Ref;
|
|
158
|
+
value: Ref$1;
|
|
159
159
|
required?: boolean;
|
|
160
160
|
} | {
|
|
161
161
|
type: 'composite';
|
|
162
|
-
value: Ref;
|
|
162
|
+
value: Ref$1;
|
|
163
163
|
required?: boolean;
|
|
164
164
|
} | {
|
|
165
165
|
type: 'motion';
|
|
@@ -180,7 +180,7 @@ type PropDecl<Path extends string = string> = SlotDecl | ForwardDecl<Path> | {
|
|
|
180
180
|
* every reader switches on. (v1 did the same in its authoring adapter — it just assumed every bare ref
|
|
181
181
|
* was a style property, where this reads the kind.)
|
|
182
182
|
*/
|
|
183
|
-
type AuthoredProp<Path extends string = string> = PropDecl<Path> | Ref | readonly string[];
|
|
183
|
+
type AuthoredProp<Path extends string = string> = PropDecl<Path> | Ref$1 | readonly string[];
|
|
184
184
|
/**
|
|
185
185
|
* A component's prop declarations. `null` is the OMIT tombstone the stored schema already accepts: a
|
|
186
186
|
* component that `.forwards({ root: '*' })` drops one of the base's props by declaring it `null`, which is
|
|
@@ -279,7 +279,17 @@ type ElementOf<L extends LayerMap, D> = D extends {
|
|
|
279
279
|
*
|
|
280
280
|
* Open at the end on purpose: a component's style-prop surface is the system's, not this file's.
|
|
281
281
|
*/
|
|
282
|
-
type ComponentPropsOf<L extends LayerMap, P extends PropMap, D = Record<never, never>, E = Record<never, never>, F extends string = never> = Partial<DeclaredProps<P
|
|
282
|
+
type ComponentPropsOf<L extends LayerMap, P extends PropMap, D = Record<never, never>, E = Record<never, never>, F extends string = never> = Without<Partial<DeclaredProps<P>>, keyof E> & Partial<E> & Omit<ElementPropsOf<ElementOf<L, D>>, keyof P | keyof E> & Omit<ForwardedPropsOf<L, F>, keyof P | keyof E> & Record<string, unknown>;
|
|
283
|
+
/**
|
|
284
|
+
* The element a call site picks with `as`, and the props that element brings — the polymorphic half
|
|
285
|
+
* of the phantom signature. `<Box<'img', ImgHTMLAttributes<HTMLImageElement>> as="img" src=…>` names
|
|
286
|
+
* the element (and, optionally, the attribute surface it wants typed) as type arguments, the way v1's
|
|
287
|
+
* generated components took them. Without it a consumer's `<Box<'button'>>` was "Expected 0 type
|
|
288
|
+
* arguments" at every site that had compiled for a year.
|
|
289
|
+
*/
|
|
290
|
+
type AsPropsOf<As, P, E> = [As] extends [never] ? Record<never, never> : {
|
|
291
|
+
as?: As;
|
|
292
|
+
} & ([As] extends [keyof JSX.IntrinsicElements] ? Omit<ComponentPropsWithoutRef<As>, keyof P | keyof E> : Record<never, never>);
|
|
283
293
|
/**
|
|
284
294
|
* The props a component picks up from the layers it FORWARDS.
|
|
285
295
|
*
|
|
@@ -305,9 +315,25 @@ type ForwardedPropsOf<L extends LayerMap, F extends string> = [NonRootForward<L,
|
|
|
305
315
|
type DefaultsOf<P extends PropMap> = Partial<DeclaredProps<P>> & {
|
|
306
316
|
[key: string]: unknown;
|
|
307
317
|
};
|
|
318
|
+
/**
|
|
319
|
+
* `T` without the keys in `K` — `Omit` that leaves an index signature alone.
|
|
320
|
+
*
|
|
321
|
+
* `Omit<T, K>` is `Pick<T, Exclude<keyof T, K>>`, and on a type that is open at the end (`RenderArgs`,
|
|
322
|
+
* every component's props) `keyof T` is `string`, so the pick collapses every named key to the index
|
|
323
|
+
* type: `props` came back `unknown` and a render could not read `props.root`. A mapped type with an
|
|
324
|
+
* `as` clause drops exactly the named keys and keeps the rest as declared.
|
|
325
|
+
*/
|
|
326
|
+
type Without<T, K extends PropertyKey> = string extends K ? T : { [Key in keyof T as Key extends K ? never : Key]: T[Key] };
|
|
308
327
|
/** What a render receives: the generated per-layer bundle, plus the props the component declared. */
|
|
309
328
|
type RenderArgs<L extends LayerMap, P extends PropMap> = {
|
|
310
329
|
readonly props: Record<keyof L & string, Record<string, unknown>>;
|
|
330
|
+
/**
|
|
331
|
+
* The ref the emitted module forwards to the render, for the element it chooses to attach it to.
|
|
332
|
+
* `any` rather than a union of element types: a React ref is contravariant in its element, so
|
|
333
|
+
* only `any` lets one declared type land on `<svg ref={ref}>` in one component and
|
|
334
|
+
* `<input ref={ref}>` in another — and which element is the render's decision.
|
|
335
|
+
*/
|
|
336
|
+
readonly ref?: Ref<any>;
|
|
311
337
|
} & DeclaredProps<P> & Record<string, unknown>;
|
|
312
338
|
interface ComponentBuilder<L extends LayerMap, P extends PropMap,
|
|
313
339
|
/** Props the RENDER takes that the config doesn't describe — React handlers, mostly (`onPress`).
|
|
@@ -326,7 +352,13 @@ F extends string = never> extends Authored {
|
|
|
326
352
|
* A phantom call signature — the authored value is NEVER rendered (the build substitutes the
|
|
327
353
|
* emitted module), but `export type ButtonProps = ComponentProps<typeof Button>` is how a consumer
|
|
328
354
|
* names its props, and that reads this type.
|
|
355
|
+
*
|
|
356
|
+
* Two signatures. The GENERIC one takes the element a call site picks (`<Box<'img', Attrs>>`) — see
|
|
357
|
+
* {@link AsPropsOf}. The plain one stays LAST, because `React.ComponentProps<typeof Box>` infers
|
|
358
|
+
* from the last overload, and a consumer's `BoxProps` must not widen into a union over every
|
|
359
|
+
* intrinsic element the moment `as` becomes typeable.
|
|
329
360
|
*/
|
|
361
|
+
<As extends ElementType = never, Extra = Record<never, never>>(props: ComponentPropsOf<L, P, D, E, F> & AsPropsOf<As, P, E> & Partial<Extra>): null;
|
|
330
362
|
(props: ComponentPropsOf<L, P, D, E, F>): null;
|
|
331
363
|
readonly kind: 'component';
|
|
332
364
|
/** The authored body, readable so codegen can pair it with the render found in the source. */
|
|
@@ -387,7 +419,7 @@ F extends string = never> extends Authored {
|
|
|
387
419
|
* it from the source and copies it verbatim, so what it returns is irrelevant; declaring it is
|
|
388
420
|
* what puts it in the file.
|
|
389
421
|
*/
|
|
390
|
-
render<E2 = E>(fn: (args: RenderArgs<L, P> & E2) => unknown): ComponentBuilder<L, P, E2, D, F>;
|
|
422
|
+
render<E2 = E>(fn: (args: Without<RenderArgs<L, P>, keyof E2> & E2) => unknown): ComponentBuilder<L, P, E2, D, F>;
|
|
391
423
|
/**
|
|
392
424
|
* An optional browser-canvas anatomy for a native component.
|
|
393
425
|
*
|
|
@@ -395,7 +427,7 @@ F extends string = never> extends Authored {
|
|
|
395
427
|
* Use this only when the phone anatomy is a poor fit for a browser canvas (a full-screen safe-area
|
|
396
428
|
* wrapper, for example). Like `render`, it is source-read build input and stores no config data.
|
|
397
429
|
*/
|
|
398
|
-
renderCanvas<E2 extends E = E>(fn: (args: RenderArgs<L, P> & E2) => unknown): ComponentBuilder<L, P, E, D, F>;
|
|
430
|
+
renderCanvas<E2 extends E = E>(fn: (args: Without<RenderArgs<L, P>, keyof E2> & E2) => unknown): ComponentBuilder<L, P, E, D, F>;
|
|
399
431
|
/**
|
|
400
432
|
* What a preview of this component STARTS from — the props a single tile is rendered with.
|
|
401
433
|
*
|
|
@@ -407,10 +439,24 @@ F extends string = never> extends Authored {
|
|
|
407
439
|
*/
|
|
408
440
|
preview(spec: {
|
|
409
441
|
defaultProps?: DefaultsOf<P>;
|
|
442
|
+
/**
|
|
443
|
+
* Preview props that hold only under a condition — the same `when` grammar a style rule uses.
|
|
444
|
+
* The grid is derived from the styles; what it cannot derive is the CONTENT a cell needs at a
|
|
445
|
+
* given point on an axis: `{ when: { type: 'image' }, props: { src } }` gives the image kind a
|
|
446
|
+
* photo, `{ when: { invalid: true }, props: { selected: true } }` shows the invalid state checked.
|
|
447
|
+
* A condition naming a prop no rule styles makes that prop an axis too, with the value named —
|
|
448
|
+
* so a preview can say a boolean is worth a column the way a rule would.
|
|
449
|
+
*/
|
|
450
|
+
when?: readonly PreviewCondition<P>[];
|
|
410
451
|
}): ComponentBuilder<L, P, E, D, F>;
|
|
411
452
|
toStored(): Record<string, unknown>;
|
|
412
453
|
assignPath(path: string): void;
|
|
413
454
|
}
|
|
455
|
+
/** Preview props that hold under a condition on the cell's props — see `preview({ when })`. */
|
|
456
|
+
interface PreviewCondition<P extends PropMap = PropMap> {
|
|
457
|
+
readonly when: Partial<Record<keyof P & string, unknown>>;
|
|
458
|
+
readonly props: DefaultsOf<P>;
|
|
459
|
+
}
|
|
414
460
|
/** A component under authorship, with its declarations forgotten — what a registry holds. */
|
|
415
461
|
type AuthoredComponent = ComponentBuilder<LayerMap, PropMap, unknown, unknown>;
|
|
416
462
|
interface DefineComponent {
|
|
@@ -19,7 +19,12 @@ function build(body) {
|
|
|
19
19
|
metadata: (meta) => next(meta),
|
|
20
20
|
render: () => handle,
|
|
21
21
|
renderCanvas: () => handle,
|
|
22
|
-
preview: (spec) =>
|
|
22
|
+
preview: (spec) => {
|
|
23
|
+
const patch = {};
|
|
24
|
+
if (spec?.defaultProps !== void 0) patch.previewProps = spec.defaultProps;
|
|
25
|
+
if (spec?.when?.length) patch.previewWhen = spec.when;
|
|
26
|
+
return Object.keys(patch).length === 0 ? handle : next(patch);
|
|
27
|
+
},
|
|
23
28
|
toStored: () => toStored(body),
|
|
24
29
|
assignPath(path) {
|
|
25
30
|
handle.path = path;
|
|
@@ -282,6 +287,10 @@ function toStored(body) {
|
|
|
282
287
|
if (previewProps === void 0) delete stored.previewProps;
|
|
283
288
|
else stored.previewProps = previewProps;
|
|
284
289
|
}
|
|
290
|
+
if (Array.isArray(body.previewWhen)) stored.previewWhen = body.previewWhen.map(({ when, props }) => ({
|
|
291
|
+
when,
|
|
292
|
+
props: storableProps(props) ?? {}
|
|
293
|
+
}));
|
|
285
294
|
if (body.props && typeof body.props === "object") {
|
|
286
295
|
const props = {};
|
|
287
296
|
for (const [name, decl] of Object.entries(body.props)) props[name] = storedProp(decl, body.layers);
|