@yahoo/uds-create-config 5.91.9 → 5.93.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__fixtures__/yos-native.d.ts +4 -4
- package/dist/authoring/intersperse.d.ts +9 -0
- package/dist/authoring/intersperse.js +41 -0
- package/dist/configs/react-native-system.d.ts +4 -4
- package/dist/entities/native/NativeSettings.d.ts +1 -1
- package/dist/entities/native/NativeStyleProperty.d.ts +4 -4
- package/dist/entities/system/Component.js +13 -1
- package/dist/entities/system/Motion.d.ts +4 -4
- package/dist/entities/system/StyleProperty.d.ts +2 -2
- package/dist/entities/system/reanimated-motion.d.ts +4 -4
- package/dist/entities/system/token-semantics.d.ts +30 -0
- package/dist/entities/system/token-semantics.js +121 -0
- package/dist/framework/render-spec.d.ts +15 -1
- package/dist/framework/render-spec.js +101 -6
- package/dist/framework/slot-host.d.ts +2 -2
- package/dist/framework/slot-host.js +9 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -3
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +2 -2
- package/dist/spec/preview-elements.d.ts +17 -3
- package/dist/spec/preview-elements.js +46 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -81,7 +81,7 @@ export declare function yosNative(): import("..").ConfigInstance<{
|
|
|
81
81
|
output: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
82
82
|
}, import("zod/v4/core").$strict>]>>;
|
|
83
83
|
}, import("zod/v4/core").$strict>>;
|
|
84
|
-
}, "
|
|
84
|
+
}, "canvas" | "css" | "playground"> & {
|
|
85
85
|
canvas: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
86
86
|
packageAliases: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
|
|
87
87
|
}, import("zod/v4/core").$strict>>;
|
|
@@ -195,10 +195,11 @@ export declare function yosNative(): import("..").ConfigInstance<{
|
|
|
195
195
|
responsive: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
196
196
|
classPrefix: import("zod").ZodOptional<import("zod").ZodString>;
|
|
197
197
|
arbitrary: import("zod").ZodDefault<import("zod").ZodUnion<readonly [import("zod").ZodBoolean, import("zod").ZodEnum<{
|
|
198
|
+
em: "em";
|
|
199
|
+
s: "s";
|
|
198
200
|
ch: "ch";
|
|
199
201
|
dvh: "dvh";
|
|
200
202
|
dvw: "dvw";
|
|
201
|
-
em: "em";
|
|
202
203
|
ex: "ex";
|
|
203
204
|
lvh: "lvh";
|
|
204
205
|
lvw: "lvw";
|
|
@@ -214,7 +215,6 @@ export declare function yosNative(): import("..").ConfigInstance<{
|
|
|
214
215
|
deg: "deg";
|
|
215
216
|
rad: "rad";
|
|
216
217
|
turn: "turn";
|
|
217
|
-
s: "s";
|
|
218
218
|
ms: "ms";
|
|
219
219
|
unitless: "unitless";
|
|
220
220
|
lh: "lh";
|
|
@@ -234,8 +234,8 @@ export declare function yosNative(): import("..").ConfigInstance<{
|
|
|
234
234
|
opacityOf: import("zod").ZodOptional<import("zod").ZodLazy<import("zod").ZodType<import("..").Ref, unknown, import("zod/v4/core").$ZodTypeInternals<import("..").Ref, unknown>>>>;
|
|
235
235
|
}, "values" | "alpha" | "properties" | "selector" | "classPrefix" | "declarations"> & {
|
|
236
236
|
properties: import("zod").ZodArray<import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>, import("zod").ZodEnum<{
|
|
237
|
-
transform: "transform";
|
|
238
237
|
filter: "filter";
|
|
238
|
+
transform: "transform";
|
|
239
239
|
color: "color";
|
|
240
240
|
inset: "inset";
|
|
241
241
|
position: "position";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/authoring/intersperse.d.ts
|
|
4
|
+
/** A separator, or a function of the index of the item it comes before (from 1). */
|
|
5
|
+
type IntersperseSeparator = ReactNode | ((index: number) => ReactNode);
|
|
6
|
+
/** The children with the separator between each pair of them, each copy keyed by its position. */
|
|
7
|
+
declare function intersperse(children: ReactNode, separator: IntersperseSeparator | null | undefined): ReactNode;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { IntersperseSeparator, intersperse };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Children, Fragment, cloneElement, isValidElement } from "react";
|
|
2
|
+
//#region src/authoring/intersperse.ts
|
|
3
|
+
/**
|
|
4
|
+
* Places a separator between a render's children: `<Box>{intersperse(children, separator)}</Box>`.
|
|
5
|
+
* The anatomy reader recognises the call by its import, so the component editor paints a copy of the
|
|
6
|
+
* separator between the items, as the module does. With no separator the children render as given.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The children as a list, a fragment's children spread in its place. A design-file canvas hands a
|
|
10
|
+
* container its empty-slot placeholder (an element whose `element` prop is a `Slot`) among the
|
|
11
|
+
* children, which is a drop target rather than an item, so it gets no separator.
|
|
12
|
+
*/
|
|
13
|
+
function itemsOf(children, parentKey = "") {
|
|
14
|
+
const items = [];
|
|
15
|
+
for (const child of Children.toArray(children)) {
|
|
16
|
+
if (isValidElement(child)) {
|
|
17
|
+
const props = child.props;
|
|
18
|
+
if (props.element?.type === "Slot") continue;
|
|
19
|
+
if (child.type === Fragment) {
|
|
20
|
+
items.push(...itemsOf(props.children, `${parentKey}${child.key}/`));
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
items.push(parentKey ? cloneElement(child, { key: `${parentKey}${child.key}` }) : child);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
items.push(child);
|
|
27
|
+
}
|
|
28
|
+
return items;
|
|
29
|
+
}
|
|
30
|
+
/** The children with the separator between each pair of them, each copy keyed by its position. */
|
|
31
|
+
function intersperse(children, separator) {
|
|
32
|
+
if (separator == null || separator === false) return children;
|
|
33
|
+
return itemsOf(children).flatMap((item, index) => {
|
|
34
|
+
if (index === 0) return [item];
|
|
35
|
+
const node = typeof separator === "function" ? separator(index) : separator;
|
|
36
|
+
if (node == null || typeof node === "boolean") return [item];
|
|
37
|
+
return [isValidElement(node) ? cloneElement(node, { key: `separator-${index}` }) : node, item];
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { intersperse };
|
|
@@ -99,7 +99,7 @@ declare const ReactNativeSystemDefinition: ConfigClass<{
|
|
|
99
99
|
output: _$zod.ZodOptional<_$zod.ZodBoolean>;
|
|
100
100
|
}, _$zod_v4_core0.$strict>]>>;
|
|
101
101
|
}, _$zod_v4_core0.$strict>>;
|
|
102
|
-
}, "
|
|
102
|
+
}, "canvas" | "css" | "playground"> & {
|
|
103
103
|
canvas: _$zod.ZodOptional<_$zod.ZodObject<{
|
|
104
104
|
packageAliases: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodString>>;
|
|
105
105
|
}, _$zod_v4_core0.$strict>>;
|
|
@@ -216,10 +216,11 @@ declare const ReactNativeSystemDefinition: ConfigClass<{
|
|
|
216
216
|
responsive: _$zod.ZodDefault<_$zod.ZodBoolean>;
|
|
217
217
|
classPrefix: _$zod.ZodOptional<_$zod.ZodString>;
|
|
218
218
|
arbitrary: _$zod.ZodDefault<_$zod.ZodUnion<readonly [_$zod.ZodBoolean, _$zod.ZodEnum<{
|
|
219
|
+
em: "em";
|
|
220
|
+
s: "s";
|
|
219
221
|
ch: "ch";
|
|
220
222
|
dvh: "dvh";
|
|
221
223
|
dvw: "dvw";
|
|
222
|
-
em: "em";
|
|
223
224
|
ex: "ex";
|
|
224
225
|
lvh: "lvh";
|
|
225
226
|
lvw: "lvw";
|
|
@@ -235,7 +236,6 @@ declare const ReactNativeSystemDefinition: ConfigClass<{
|
|
|
235
236
|
deg: "deg";
|
|
236
237
|
rad: "rad";
|
|
237
238
|
turn: "turn";
|
|
238
|
-
s: "s";
|
|
239
239
|
ms: "ms";
|
|
240
240
|
unitless: "unitless";
|
|
241
241
|
lh: "lh";
|
|
@@ -255,8 +255,8 @@ declare const ReactNativeSystemDefinition: ConfigClass<{
|
|
|
255
255
|
opacityOf: _$zod.ZodOptional<_$zod.ZodLazy<_$zod.ZodType<Ref, unknown, _$zod_v4_core0.$ZodTypeInternals<Ref, unknown>>>>;
|
|
256
256
|
}, "values" | "alpha" | "properties" | "selector" | "classPrefix" | "declarations"> & {
|
|
257
257
|
properties: _$zod.ZodArray<_$zod.ZodPipe<_$zod.ZodPipe<_$zod.ZodString, _$zod.ZodTransform<string, string>>, _$zod.ZodEnum<{
|
|
258
|
-
transform: "transform";
|
|
259
258
|
filter: "filter";
|
|
259
|
+
transform: "transform";
|
|
260
260
|
color: "color";
|
|
261
261
|
inset: "inset";
|
|
262
262
|
position: "position";
|
|
@@ -88,7 +88,7 @@ declare const NativeSettings: EntityClass<z.ZodObject<Omit<{
|
|
|
88
88
|
output: z.ZodOptional<z.ZodBoolean>;
|
|
89
89
|
}, z.core.$strict>]>>;
|
|
90
90
|
}, z.core.$strict>>;
|
|
91
|
-
}, "
|
|
91
|
+
}, "canvas" | "css" | "playground"> & {
|
|
92
92
|
canvas: z.ZodOptional<z.ZodObject<{
|
|
93
93
|
packageAliases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
94
94
|
}, z.core.$strict>>;
|
|
@@ -6,8 +6,8 @@ import { z } from "zod";
|
|
|
6
6
|
//#region src/entities/native/NativeStyleProperty.d.ts
|
|
7
7
|
/** One React Native style key, as RN's own types declare them. */
|
|
8
8
|
declare const rnStyleKey: z.ZodEnum<{
|
|
9
|
-
transform: "transform";
|
|
10
9
|
filter: "filter";
|
|
10
|
+
transform: "transform";
|
|
11
11
|
color: "color";
|
|
12
12
|
inset: "inset";
|
|
13
13
|
position: "position";
|
|
@@ -169,10 +169,11 @@ declare const NativeStyleProperty: EntityClass<z.ZodObject<Omit<{
|
|
|
169
169
|
responsive: z.ZodDefault<z.ZodBoolean>;
|
|
170
170
|
classPrefix: z.ZodOptional<z.ZodString>;
|
|
171
171
|
arbitrary: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
|
|
172
|
+
em: "em";
|
|
173
|
+
s: "s";
|
|
172
174
|
ch: "ch";
|
|
173
175
|
dvh: "dvh";
|
|
174
176
|
dvw: "dvw";
|
|
175
|
-
em: "em";
|
|
176
177
|
ex: "ex";
|
|
177
178
|
lvh: "lvh";
|
|
178
179
|
lvw: "lvw";
|
|
@@ -188,7 +189,6 @@ declare const NativeStyleProperty: EntityClass<z.ZodObject<Omit<{
|
|
|
188
189
|
deg: "deg";
|
|
189
190
|
rad: "rad";
|
|
190
191
|
turn: "turn";
|
|
191
|
-
s: "s";
|
|
192
192
|
ms: "ms";
|
|
193
193
|
unitless: "unitless";
|
|
194
194
|
lh: "lh";
|
|
@@ -208,8 +208,8 @@ declare const NativeStyleProperty: EntityClass<z.ZodObject<Omit<{
|
|
|
208
208
|
opacityOf: z.ZodOptional<z.ZodLazy<z.ZodType<Ref, unknown, z.core.$ZodTypeInternals<Ref, unknown>>>>;
|
|
209
209
|
}, "values" | "alpha" | "properties" | "selector" | "classPrefix" | "declarations"> & {
|
|
210
210
|
properties: z.ZodArray<z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodEnum<{
|
|
211
|
-
transform: "transform";
|
|
212
211
|
filter: "filter";
|
|
212
|
+
transform: "transform";
|
|
213
213
|
color: "color";
|
|
214
214
|
inset: "inset";
|
|
215
215
|
position: "position";
|
|
@@ -1753,7 +1753,7 @@ const AnatomyNode = defineSubEntity({
|
|
|
1753
1753
|
}
|
|
1754
1754
|
});
|
|
1755
1755
|
if (slotAnatomyProp !== void 0) {
|
|
1756
|
-
if (node.children?.length || node.slots || node.text !== void 0 || node.visible !== void 0 || Object.keys(node.props ?? {}).some((prop) => prop !== "name")) ctx.issues.push({
|
|
1756
|
+
if (node.children?.length || node.slots || node.text !== void 0 || node.visible !== void 0 || Object.keys(node.props ?? {}).some((prop) => prop !== "name" && prop !== "separator")) ctx.issues.push({
|
|
1757
1757
|
code: "custom",
|
|
1758
1758
|
input: node,
|
|
1759
1759
|
message: "a Slot node carries nothing of its own — its content arrives from the instance"
|
|
@@ -1764,6 +1764,18 @@ const AnatomyNode = defineSubEntity({
|
|
|
1764
1764
|
input: node,
|
|
1765
1765
|
message: `a Slot node must name a slot prop — "${slotAnatomyProp}" routes no content`
|
|
1766
1766
|
});
|
|
1767
|
+
const separator = {
|
|
1768
|
+
...current?.props,
|
|
1769
|
+
...node.props
|
|
1770
|
+
}.separator;
|
|
1771
|
+
if (separator !== void 0) {
|
|
1772
|
+
const separatorDecl = body.props?.[separator];
|
|
1773
|
+
if (typeof separator !== "string" || separator === slotAnatomyProp || separatorDecl && separatorDecl.type !== "slot") ctx.issues.push({
|
|
1774
|
+
code: "custom",
|
|
1775
|
+
input: node,
|
|
1776
|
+
message: `a Slot node's \`separator\` must name another slot prop — "${String(separator)}" is not one`
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1767
1779
|
for (const [sibling, member] of Object.entries(body.anatomy ?? {})) {
|
|
1768
1780
|
if (sibling === key) continue;
|
|
1769
1781
|
if (slotAnatomyPropOf(member) === slotAnatomyProp) {
|
|
@@ -37,8 +37,8 @@ declare const MotionEntity: EntityClass<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
37
37
|
type: z.ZodLiteral<"react-native-reanimated">;
|
|
38
38
|
value: z.ZodUnion<readonly [z.ZodObject<{
|
|
39
39
|
transitionProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
40
|
-
transform: "transform";
|
|
41
40
|
filter: "filter";
|
|
41
|
+
transform: "transform";
|
|
42
42
|
color: "color";
|
|
43
43
|
none: "none";
|
|
44
44
|
inset: "inset";
|
|
@@ -196,8 +196,8 @@ declare const MotionEntity: EntityClass<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
196
196
|
zIndex: "zIndex";
|
|
197
197
|
all: "all";
|
|
198
198
|
}>, z.ZodArray<z.ZodEnum<{
|
|
199
|
-
transform: "transform";
|
|
200
199
|
filter: "filter";
|
|
200
|
+
transform: "transform";
|
|
201
201
|
color: "color";
|
|
202
202
|
inset: "inset";
|
|
203
203
|
position: "position";
|
|
@@ -393,8 +393,8 @@ declare const MotionEntity: EntityClass<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
393
393
|
"allow-discrete": "allow-discrete";
|
|
394
394
|
}>>]>>;
|
|
395
395
|
animationName: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
396
|
-
transform: "transform";
|
|
397
396
|
filter: "filter";
|
|
397
|
+
transform: "transform";
|
|
398
398
|
color: "color";
|
|
399
399
|
inset: "inset";
|
|
400
400
|
position: "position";
|
|
@@ -569,8 +569,8 @@ declare const MotionEntity: EntityClass<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
569
569
|
}>, z.ZodObject<{
|
|
570
570
|
cubicBezier: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
571
571
|
}, z.core.$strict>]>]>>>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
572
|
-
transform: "transform";
|
|
573
572
|
filter: "filter";
|
|
573
|
+
transform: "transform";
|
|
574
574
|
color: "color";
|
|
575
575
|
inset: "inset";
|
|
576
576
|
position: "position";
|
|
@@ -148,10 +148,11 @@ declare const StylePropertyEntity: EntityClass<z.ZodObject<{
|
|
|
148
148
|
responsive: z.ZodDefault<z.ZodBoolean>;
|
|
149
149
|
classPrefix: z.ZodOptional<z.ZodString>;
|
|
150
150
|
arbitrary: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodEnum<{
|
|
151
|
+
em: "em";
|
|
152
|
+
s: "s";
|
|
151
153
|
ch: "ch";
|
|
152
154
|
dvh: "dvh";
|
|
153
155
|
dvw: "dvw";
|
|
154
|
-
em: "em";
|
|
155
156
|
ex: "ex";
|
|
156
157
|
lvh: "lvh";
|
|
157
158
|
lvw: "lvw";
|
|
@@ -167,7 +168,6 @@ declare const StylePropertyEntity: EntityClass<z.ZodObject<{
|
|
|
167
168
|
deg: "deg";
|
|
168
169
|
rad: "rad";
|
|
169
170
|
turn: "turn";
|
|
170
|
-
s: "s";
|
|
171
171
|
ms: "ms";
|
|
172
172
|
unitless: "unitless";
|
|
173
173
|
lh: "lh";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const reanimatedStyle: z.ZodObject<{
|
|
3
3
|
transitionProperty: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
4
|
-
transform: "transform";
|
|
5
4
|
filter: "filter";
|
|
5
|
+
transform: "transform";
|
|
6
6
|
color: "color";
|
|
7
7
|
none: "none";
|
|
8
8
|
inset: "inset";
|
|
@@ -160,8 +160,8 @@ export declare const reanimatedStyle: z.ZodObject<{
|
|
|
160
160
|
zIndex: "zIndex";
|
|
161
161
|
all: "all";
|
|
162
162
|
}>, z.ZodArray<z.ZodEnum<{
|
|
163
|
-
transform: "transform";
|
|
164
163
|
filter: "filter";
|
|
164
|
+
transform: "transform";
|
|
165
165
|
color: "color";
|
|
166
166
|
inset: "inset";
|
|
167
167
|
position: "position";
|
|
@@ -357,8 +357,8 @@ export declare const reanimatedStyle: z.ZodObject<{
|
|
|
357
357
|
"allow-discrete": "allow-discrete";
|
|
358
358
|
}>>]>>;
|
|
359
359
|
animationName: z.ZodOptional<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
360
|
-
transform: "transform";
|
|
361
360
|
filter: "filter";
|
|
361
|
+
transform: "transform";
|
|
362
362
|
color: "color";
|
|
363
363
|
inset: "inset";
|
|
364
364
|
position: "position";
|
|
@@ -533,8 +533,8 @@ export declare const reanimatedStyle: z.ZodObject<{
|
|
|
533
533
|
}>, z.ZodObject<{
|
|
534
534
|
cubicBezier: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
535
535
|
}, z.core.$strict>]>]>>>, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
536
|
-
transform: "transform";
|
|
537
536
|
filter: "filter";
|
|
537
|
+
transform: "transform";
|
|
538
538
|
color: "color";
|
|
539
539
|
inset: "inset";
|
|
540
540
|
position: "position";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Config } from "../../framework/Config.js";
|
|
2
|
+
|
|
3
|
+
//#region src/entities/system/token-semantics.d.ts
|
|
4
|
+
/** A token's representative CSS use, independent of its path. */
|
|
5
|
+
type TokenSemantics = {
|
|
6
|
+
readonly kind: 'color';
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'radius';
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'spacing';
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: 'dimension';
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'typography';
|
|
15
|
+
readonly property: 'font-family' | 'font-size' | 'font-weight' | 'font-style' | 'line-height' | 'letter-spacing' | 'word-spacing';
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'unknown';
|
|
18
|
+
};
|
|
19
|
+
/** Declared types and the CSS properties that offer or use a token, with aliases followed. */
|
|
20
|
+
declare function tokenSemantics({
|
|
21
|
+
config,
|
|
22
|
+
path,
|
|
23
|
+
condition
|
|
24
|
+
}: {
|
|
25
|
+
readonly config: Config;
|
|
26
|
+
readonly path: string;
|
|
27
|
+
readonly condition?: string | null;
|
|
28
|
+
}): TokenSemantics;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { TokenSemantics, tokenSemantics };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { isRef, kindOf, ref, splitRef } from "../../framework/utils/refs.js";
|
|
2
|
+
import { cssProperty } from "../../css/values.js";
|
|
3
|
+
import { createSliceMemo } from "../../framework/memo.js";
|
|
4
|
+
import { resolveValueType } from "../../css/value-type.js";
|
|
5
|
+
import { StyleProperty, cssPropertyNames } from "./StyleProperty.js";
|
|
6
|
+
import { stylePropEntries } from "../../framework/projections.js";
|
|
7
|
+
import { Token } from "./Token.js";
|
|
8
|
+
import { tokenBinding } from "./token-index.js";
|
|
9
|
+
//#region src/entities/system/token-semantics.ts
|
|
10
|
+
function semanticsOfProperty(property) {
|
|
11
|
+
if (!cssProperty(property)) return void 0;
|
|
12
|
+
switch (property) {
|
|
13
|
+
case "font-family":
|
|
14
|
+
case "font-size":
|
|
15
|
+
case "font-weight":
|
|
16
|
+
case "font-style":
|
|
17
|
+
case "line-height":
|
|
18
|
+
case "letter-spacing":
|
|
19
|
+
case "word-spacing": return {
|
|
20
|
+
kind: "typography",
|
|
21
|
+
property
|
|
22
|
+
};
|
|
23
|
+
case "color":
|
|
24
|
+
case "background":
|
|
25
|
+
case "fill":
|
|
26
|
+
case "stroke": return { kind: "color" };
|
|
27
|
+
}
|
|
28
|
+
if (/^border(?:-[a-z]+)*-radius$/.test(property)) return { kind: "radius" };
|
|
29
|
+
if (property.endsWith("-color")) return { kind: "color" };
|
|
30
|
+
if (/^(?:padding|margin|gap|row-gap|column-gap)(?:-|$)/.test(property)) return { kind: "spacing" };
|
|
31
|
+
if (/^(?:(?:min|max)-)?(?:width|height|inline-size|block-size)$/.test(property)) return { kind: "dimension" };
|
|
32
|
+
}
|
|
33
|
+
const offeredProperties = createSliceMemo({
|
|
34
|
+
kinds: ["token", "style-property"],
|
|
35
|
+
compute: (config) => {
|
|
36
|
+
const properties = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const prop of StyleProperty.list(config)) for (const entry of stylePropEntries(config, prop.path)) {
|
|
38
|
+
let found = properties.get(entry.value);
|
|
39
|
+
if (!found) {
|
|
40
|
+
found = /* @__PURE__ */ new Set();
|
|
41
|
+
properties.set(entry.value, found);
|
|
42
|
+
}
|
|
43
|
+
for (const css of cssPropertyNames(prop)) found.add(css);
|
|
44
|
+
}
|
|
45
|
+
return properties;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
function usageProperties({ config, path }) {
|
|
49
|
+
const found = new Set(offeredProperties(config).get(path));
|
|
50
|
+
for (const dependent of config.dependentsOf("token", path)) {
|
|
51
|
+
const kind = kindOf(dependent);
|
|
52
|
+
const entity = config.resolveRef(dependent);
|
|
53
|
+
if (!entity) continue;
|
|
54
|
+
for (const { bag } of config.entityOf(kind)?.styleBags?.(entity.body) ?? []) for (const [name, value] of Object.entries(bag)) {
|
|
55
|
+
if (!isRef(value)) continue;
|
|
56
|
+
const target = splitRef(value);
|
|
57
|
+
if (target.kind !== "token" || target.qualifiedPath !== path) continue;
|
|
58
|
+
const property = StyleProperty.get(config, name);
|
|
59
|
+
if (!property) continue;
|
|
60
|
+
for (const css of cssPropertyNames(property)) found.add(css);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return found;
|
|
64
|
+
}
|
|
65
|
+
/** Declared types and the CSS properties that offer or use a token, with aliases followed. */
|
|
66
|
+
function tokenSemantics({ config, path, condition = null }) {
|
|
67
|
+
const binding = tokenBinding(config, ref("token", path), { under: condition });
|
|
68
|
+
if (!binding) return { kind: "unknown" };
|
|
69
|
+
const properties = /* @__PURE__ */ new Set();
|
|
70
|
+
const visited = /* @__PURE__ */ new Map();
|
|
71
|
+
let holder = config;
|
|
72
|
+
let current = path;
|
|
73
|
+
let declared;
|
|
74
|
+
while (holder) {
|
|
75
|
+
for (const property of usageProperties({
|
|
76
|
+
config: holder,
|
|
77
|
+
path: current
|
|
78
|
+
})) properties.add(property);
|
|
79
|
+
const target = ref("token", current);
|
|
80
|
+
const owner = holder.configFor(target);
|
|
81
|
+
const at = splitRef(target).path;
|
|
82
|
+
if (!owner) break;
|
|
83
|
+
let seen = visited.get(owner);
|
|
84
|
+
if (!seen) {
|
|
85
|
+
seen = /* @__PURE__ */ new Set();
|
|
86
|
+
visited.set(owner, seen);
|
|
87
|
+
}
|
|
88
|
+
if (seen.has(at)) break;
|
|
89
|
+
seen.add(at);
|
|
90
|
+
if (owner !== holder || at !== current) for (const property of usageProperties({
|
|
91
|
+
config: owner,
|
|
92
|
+
path: at
|
|
93
|
+
})) properties.add(property);
|
|
94
|
+
const token = Token.get(owner, at);
|
|
95
|
+
declared ??= token?.type;
|
|
96
|
+
const value = (condition ? token?.overrides?.[condition]?.value : void 0) ?? token?.value;
|
|
97
|
+
if (!isRef(value) || kindOf(value) !== "token") break;
|
|
98
|
+
holder = owner;
|
|
99
|
+
current = splitRef(value).qualifiedPath;
|
|
100
|
+
}
|
|
101
|
+
const type = resolveValueType({
|
|
102
|
+
type: declared,
|
|
103
|
+
value: binding.value
|
|
104
|
+
});
|
|
105
|
+
if (type === "color" || type === "gradient") return { kind: "color" };
|
|
106
|
+
if (declared === "string") return { kind: "unknown" };
|
|
107
|
+
const explicit = type ? semanticsOfProperty(type) : void 0;
|
|
108
|
+
if (explicit) return explicit;
|
|
109
|
+
const meanings = /* @__PURE__ */ new Map();
|
|
110
|
+
for (const property of properties) {
|
|
111
|
+
const meaning = semanticsOfProperty(property);
|
|
112
|
+
if (meaning) meanings.set(JSON.stringify(meaning), meaning);
|
|
113
|
+
}
|
|
114
|
+
const choices = [...meanings.values()];
|
|
115
|
+
if (choices.length === 1 && choices[0]) return choices[0];
|
|
116
|
+
if (choices.some((choice) => choice.kind === "spacing") && choices.every((choice) => choice.kind === "spacing" || choice.kind === "dimension")) return { kind: "spacing" };
|
|
117
|
+
if (type === "length" || type === "length-percentage" || type === "percentage") return { kind: "dimension" };
|
|
118
|
+
return { kind: "unknown" };
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { tokenSemantics };
|
|
@@ -82,6 +82,15 @@ interface MeasuredValue {
|
|
|
82
82
|
readonly value: unknown;
|
|
83
83
|
readonly initial?: unknown;
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* One of the component's own layer bags, handed to an element its render composes: `label:
|
|
87
|
+
* props.text` inside `<Divider layerProps={{ … }}>`. The expansion settles it to what the module's
|
|
88
|
+
* `props.<layer>` holds there, the owner's markers and classes included, so the composed element
|
|
89
|
+
* paints and selects as the owner's layer.
|
|
90
|
+
*/
|
|
91
|
+
interface LayerBagValue {
|
|
92
|
+
readonly $layer: string;
|
|
93
|
+
}
|
|
85
94
|
/** One read off a layer's painted element: a size in pixels, or a computed style property. */
|
|
86
95
|
type MeasureRead = {
|
|
87
96
|
readonly $layout: MeasureLayout;
|
|
@@ -480,6 +489,11 @@ interface SlotTarget {
|
|
|
480
489
|
* root when the anatomy records no position for it, which is where the expansion renders it.
|
|
481
490
|
*/
|
|
482
491
|
declare function slotTargetsOf(config: Config, path: string): SlotTarget[];
|
|
492
|
+
/**
|
|
493
|
+
* The slots whose items a render places with a separator between them
|
|
494
|
+
* (`intersperse(children, separator)`), each mapped to the slot that holds the separator.
|
|
495
|
+
*/
|
|
496
|
+
declare function slotSeparatorsOf(config: Config, path: string): ReadonlyMap<string, string>;
|
|
483
497
|
/**
|
|
484
498
|
* Layer → the forwards that hand a VALUE to one of its props.
|
|
485
499
|
*
|
|
@@ -583,4 +597,4 @@ declare function expandSpec(config: Config, spec: RenderSpec, options?: ExpandOp
|
|
|
583
597
|
*/
|
|
584
598
|
declare function expandComponent(config: Config, path: string, props?: Record<string, unknown>, options?: ExpandOptions): ExpansionResult;
|
|
585
599
|
//#endregion
|
|
586
|
-
export { ANATOMY_MARKER, ComponentSpec, ComponentSpecs, ComputedFunctions, ComputedValue, ExpandOptions, ExpansionResult, MEASURE_LAYOUTS, MOTION_FACTORY, MeasureLayout, MeasureRead, MeasureReader, MeasureRequest, MeasuredValue, RenderElement, RenderSpec, RepeatRow, RepeatSpec, ResolveContext, SlotTarget, VisibilityOperator, VisibilityTerm, anatomyElementComponent, anatomyTextProp, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, reportedStates, resolveValue, resolveVisibility, routeOf, routesOf, slotTargetsOf, specWithResolvedVisibility, statePointerProp, unrollRows, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|
|
600
|
+
export { ANATOMY_MARKER, ComponentSpec, ComponentSpecs, ComputedFunctions, ComputedValue, ExpandOptions, ExpansionResult, LayerBagValue, MEASURE_LAYOUTS, MOTION_FACTORY, MeasureLayout, MeasureRead, MeasureReader, MeasureRequest, MeasuredValue, RenderElement, RenderSpec, RepeatRow, RepeatSpec, ResolveContext, SlotTarget, VisibilityOperator, VisibilityTerm, anatomyElementComponent, anatomyTextProp, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, reportedStates, resolveValue, resolveVisibility, routeOf, routesOf, slotSeparatorsOf, slotTargetsOf, specWithResolvedVisibility, statePointerProp, unrollRows, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|