@yahoo/uds-create-config 5.91.9 → 5.92.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/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 +4 -3
- package/dist/index.js +4 -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";
|
|
@@ -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 };
|
|
@@ -9,10 +9,14 @@ import { slotHostLayer } from "./slot-host.js";
|
|
|
9
9
|
import { forwardRoutes, forwardedLayers, intoName, isValueSlot, renderBindingsOf, routesContent } from "./prop-surface.js";
|
|
10
10
|
import { withRequiredContentHidden } from "../entities/system/required-content-layers.js";
|
|
11
11
|
import { inlineMotionProps, jsMotionPresets } from "../entities/system/motion-presets.js";
|
|
12
|
-
import { graftPreviewElements } from "../spec/preview-elements.js";
|
|
12
|
+
import { COPY_OF_ATTR, graftPreviewElements } from "../spec/preview-elements.js";
|
|
13
13
|
import { conditionHolds } from "./layer-styles.js";
|
|
14
14
|
import { componentLayerClass, componentPropClasses, componentRuleClasses, componentStateAttributes, forcedModifierAttributes, layerJsMotionPresets, layerRoutedProps, splitStyleProps, styleRuleMotionClasses } from "./class-names.js";
|
|
15
15
|
//#region src/framework/render-spec.ts
|
|
16
|
+
/** Whether a value is a {@link LayerBagValue}. */
|
|
17
|
+
function isLayerBagValue(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && typeof value.$layer === "string" && Object.keys(value).length === 1;
|
|
19
|
+
}
|
|
16
20
|
/** The element sizes a `{ $layout }` leaf reads. */
|
|
17
21
|
const MEASURE_LAYOUTS = [
|
|
18
22
|
"offsetWidth",
|
|
@@ -105,6 +109,13 @@ const slotAnatomyPropOf = (node) => {
|
|
|
105
109
|
const name = node.props?.name;
|
|
106
110
|
return typeof name === "string" ? name : void 0;
|
|
107
111
|
};
|
|
112
|
+
/** The slot prop whose content a `Slot` node places between each pair of its own items, named by
|
|
113
|
+
* its `separator` prop: what a render's `intersperse(children, separator)` is read as. */
|
|
114
|
+
const slotSeparatorPropOf = (node) => {
|
|
115
|
+
if (slotAnatomyPropOf(node) === void 0) return void 0;
|
|
116
|
+
const separator = node?.props?.separator;
|
|
117
|
+
return typeof separator === "string" ? separator : void 0;
|
|
118
|
+
};
|
|
108
119
|
/**
|
|
109
120
|
* Per component slice, the facts of one component an expansion reads for every instance of it: its
|
|
110
121
|
* serialized body, the props it consumes, and where its slots route. A canvas asks these once per
|
|
@@ -198,6 +209,20 @@ function typeOf(layers, element) {
|
|
|
198
209
|
function authoredProps(config, props) {
|
|
199
210
|
return props ? authoredBag(config, props) : {};
|
|
200
211
|
}
|
|
212
|
+
/** A value with each {@link LayerBagValue} in it replaced by the bag `bagOf` gives for its layer.
|
|
213
|
+
* Copied only where one is found, so a value holding none keeps its identity. */
|
|
214
|
+
function withLayerBags(value, bagOf) {
|
|
215
|
+
if (isLayerBagValue(value)) return bagOf(value.$layer);
|
|
216
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return value;
|
|
217
|
+
let out;
|
|
218
|
+
for (const [key, member] of Object.entries(value)) {
|
|
219
|
+
const settled = withLayerBags(member, bagOf);
|
|
220
|
+
if (settled === member && !out) continue;
|
|
221
|
+
out ??= { ...value };
|
|
222
|
+
out[key] = settled;
|
|
223
|
+
}
|
|
224
|
+
return out ?? value;
|
|
225
|
+
}
|
|
201
226
|
/**
|
|
202
227
|
* A component's anatomy, projected to the json-render spec a canvas reads.
|
|
203
228
|
*
|
|
@@ -257,7 +282,10 @@ function projectSpec(config, path) {
|
|
|
257
282
|
if (!type) return void 0;
|
|
258
283
|
const layer = layerOf(node.element);
|
|
259
284
|
const props = {
|
|
260
|
-
...authoredProps(config, node.props),
|
|
285
|
+
...withLayerBags(authoredProps(config, node.props), (layer) => ({
|
|
286
|
+
"data-uds-component": path,
|
|
287
|
+
"data-uds-layer": layer
|
|
288
|
+
})),
|
|
261
289
|
...node.text !== void 0 ? { children: node.text } : {},
|
|
262
290
|
...layer === void 0 ? { [ANATOMY_MARKER]: key } : {},
|
|
263
291
|
...layer !== void 0 ? {
|
|
@@ -549,6 +577,39 @@ function freeKey(sink, hint) {
|
|
|
549
577
|
while (`${hint}${index}` in sink.elements) index += 1;
|
|
550
578
|
return `${hint}${index}`;
|
|
551
579
|
}
|
|
580
|
+
/** A copy of an emitted tree under fresh keys, each made from its original's key and `suffix`, and
|
|
581
|
+
* each marked {@link COPY_OF_ATTR}. */
|
|
582
|
+
function copyTree(sink, key, suffix) {
|
|
583
|
+
const element = sink.elements[key];
|
|
584
|
+
if (!element) return key;
|
|
585
|
+
const copyKey = freeKey(sink, `${key}${suffix}`);
|
|
586
|
+
sink.elements[copyKey] = element;
|
|
587
|
+
const children = element.children?.map((child) => copyTree(sink, child, suffix));
|
|
588
|
+
const slots = element.slots ? Object.fromEntries(Object.entries(element.slots).map(([name, fills]) => [name, fills.map((fill) => copyTree(sink, fill, suffix))])) : void 0;
|
|
589
|
+
sink.elements[copyKey] = {
|
|
590
|
+
...element,
|
|
591
|
+
props: {
|
|
592
|
+
...element.props,
|
|
593
|
+
[COPY_OF_ATTR]: key
|
|
594
|
+
},
|
|
595
|
+
...children ? { children } : {},
|
|
596
|
+
...slots ? { slots } : {}
|
|
597
|
+
};
|
|
598
|
+
return copyKey;
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Emitted items with the separator's fills between each pair of them, as a render's
|
|
602
|
+
* `intersperse(children, separator)` places them. The first gap takes the fills themselves, so
|
|
603
|
+
* whatever names a fill by its key still finds it, and each later gap takes copies.
|
|
604
|
+
*/
|
|
605
|
+
function interleaved(sink, items, separators) {
|
|
606
|
+
if (separators.length === 0) return [...items];
|
|
607
|
+
return items.flatMap((item, index) => {
|
|
608
|
+
if (index === 0) return [item];
|
|
609
|
+
if (index === 1) return [...separators, item];
|
|
610
|
+
return [...separators.map((separator) => copyTree(sink, separator, `#${index}`)), item];
|
|
611
|
+
});
|
|
612
|
+
}
|
|
552
613
|
/** Whether this expansion should replace `type` with what the config says it's made of. */
|
|
553
614
|
function expandable(sink, type) {
|
|
554
615
|
if (kindOf(type) !== "component") return false;
|
|
@@ -1214,6 +1275,19 @@ function slotTargetsOf(config, path) {
|
|
|
1214
1275
|
})];
|
|
1215
1276
|
}
|
|
1216
1277
|
/**
|
|
1278
|
+
* The slots whose items a render places with a separator between them
|
|
1279
|
+
* (`intersperse(children, separator)`), each mapped to the slot that holds the separator.
|
|
1280
|
+
*/
|
|
1281
|
+
function slotSeparatorsOf(config, path) {
|
|
1282
|
+
const separators = /* @__PURE__ */ new Map();
|
|
1283
|
+
for (const node of Object.values(bodyOf(config, path)?.anatomy ?? {})) {
|
|
1284
|
+
const items = slotAnatomyPropOf(node);
|
|
1285
|
+
const separator = slotSeparatorPropOf(node);
|
|
1286
|
+
if (items !== void 0 && separator !== void 0) separators.set(items, separator);
|
|
1287
|
+
}
|
|
1288
|
+
return separators;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1217
1291
|
* Layer → the forwards that hand a VALUE to one of its props.
|
|
1218
1292
|
*
|
|
1219
1293
|
* `startIcon: { type: 'forward', target: 'startIcon/name' }` and `swatch: { type: 'forward', target:
|
|
@@ -1582,6 +1656,23 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1582
1656
|
});
|
|
1583
1657
|
const layerProps = instanceProps.layerProps ?? {};
|
|
1584
1658
|
const forwarded = layerRoutedProps(config, path, state);
|
|
1659
|
+
const ownLayerBag = (layer) => {
|
|
1660
|
+
const routes = valueRoutes.get(layer) ?? [];
|
|
1661
|
+
const split = forwardedSplits.get(layer);
|
|
1662
|
+
return {
|
|
1663
|
+
"data-uds-component": path,
|
|
1664
|
+
"data-uds-layer": layer,
|
|
1665
|
+
...forwarded[layer],
|
|
1666
|
+
...Object.fromEntries(routes.filter(({ from, into }) => state[from] !== void 0 && into !== "className").map(({ from, into }) => [into, state[from]])),
|
|
1667
|
+
...split?.rest,
|
|
1668
|
+
...layerProps[layer],
|
|
1669
|
+
className: classesFor(config, path, layer, state, [
|
|
1670
|
+
split?.className,
|
|
1671
|
+
...routes.filter(({ into }) => into === "className").map(({ from }) => state[from]),
|
|
1672
|
+
layerProps[layer]?.className
|
|
1673
|
+
]) || void 0
|
|
1674
|
+
};
|
|
1675
|
+
};
|
|
1585
1676
|
const layerMotions = layerJsMotionPresets(config, path, state);
|
|
1586
1677
|
const presetProps = Object.keys(layerMotions).length > 0 ? {
|
|
1587
1678
|
...jsMotionPresets(config),
|
|
@@ -1604,6 +1695,8 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1604
1695
|
for (const node of Object.values(anatomy)) {
|
|
1605
1696
|
const prop = slotAnatomyPropOf(node);
|
|
1606
1697
|
if (prop !== void 0) positioned.add(prop);
|
|
1698
|
+
const separator = slotSeparatorPropOf(node);
|
|
1699
|
+
if (separator !== void 0) positioned.add(separator);
|
|
1607
1700
|
}
|
|
1608
1701
|
const unroutedFills = Object.entries(instanceSlots ?? {}).filter(([from]) => !routedFroms.has(from) && !positioned.has(from)).flatMap(([, fills]) => fills);
|
|
1609
1702
|
const allContent = [...content, ...unroutedFills];
|
|
@@ -1720,7 +1813,7 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1720
1813
|
const slotValue = slot && !subtreeBinds(anatomy, key, slot.from) && !(positioned.has(slot.from) && isText(instanceProps[slot.from])) && !(isText(instanceProps[slot.from]) && computesFrom(node.props?.[intoName(slot.into)], slot.from)) ? instanceProps[slot.from] : void 0;
|
|
1721
1814
|
const siblingRoutes = layer ? (targetedRoutes.get(layer) ?? []).filter((route) => route !== slot) : [];
|
|
1722
1815
|
const siblingValues = Object.fromEntries(siblingRoutes.filter((route) => instanceProps[route.from] !== void 0 && !subtreeBinds(anatomy, key, route.from)).map((route) => [intoName(route.into), instanceProps[route.from]]));
|
|
1723
|
-
const authored = authoredProps(config, node.props);
|
|
1816
|
+
const authored = withLayerBags(authoredProps(config, node.props), ownLayerBag);
|
|
1724
1817
|
const overriding = new Set(layer ? node.overrides ?? [] : []);
|
|
1725
1818
|
const written = Object.fromEntries(Object.entries(authored).filter(([name]) => overriding.has(name)));
|
|
1726
1819
|
const props = layer ? {
|
|
@@ -1787,13 +1880,15 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1787
1880
|
positionedText = String(given);
|
|
1788
1881
|
contentPlaced = contentPlaced || childSlot === untargetedSlot;
|
|
1789
1882
|
}
|
|
1883
|
+
const separator = slotSeparatorPropOf(anatomy[child]);
|
|
1884
|
+
const between = (items) => separator === void 0 ? items : interleaved(nested, items, instanceSlots?.[separator] ?? []);
|
|
1790
1885
|
if (childSlot === untargetedSlot) {
|
|
1791
1886
|
const fills = instanceSlots?.[childSlot] ?? [];
|
|
1792
1887
|
if (allContent.length > 0 || fills.length > 0) {
|
|
1793
|
-
children.push(...allContent, ...fills);
|
|
1888
|
+
children.push(...between([...allContent, ...fills]));
|
|
1794
1889
|
contentPlaced = true;
|
|
1795
1890
|
}
|
|
1796
|
-
} else children.push(...instanceSlots?.[childSlot] ?? []);
|
|
1891
|
+
} else children.push(...between(instanceSlots?.[childSlot] ?? []));
|
|
1797
1892
|
continue;
|
|
1798
1893
|
}
|
|
1799
1894
|
const placed = emit(child, `${keyHint}•${child}`, row);
|
|
@@ -1912,4 +2007,4 @@ function withoutKey(record, key) {
|
|
|
1912
2007
|
return rest;
|
|
1913
2008
|
}
|
|
1914
2009
|
//#endregion
|
|
1915
|
-
export { ANATOMY_MARKER, MEASURE_LAYOUTS, MOTION_FACTORY, anatomyElementComponent, anatomyTextProp, andListOf, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, isExpression, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, reportedStates, resolveValue, resolveVisibility, routeOf, routesOf, slotAnatomyPropOf, slotTargetsOf, specWithResolvedVisibility, spelled, statePointerProp, unrollRows, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|
|
2010
|
+
export { ANATOMY_MARKER, MEASURE_LAYOUTS, MOTION_FACTORY, anatomyElementComponent, anatomyTextProp, andListOf, boundElementType, componentSpec, deriveSpec, entryKeyOf, expandComponent, expandSpec, instanceSpec, isExpression, layerTextProp, liveStateProps, previewSpec, propInto, propsIntoLayer, readStatePointer, reportedStates, resolveValue, resolveVisibility, routeOf, routesOf, slotAnatomyPropOf, slotSeparatorsOf, slotTargetsOf, specWithResolvedVisibility, spelled, statePointerProp, unrollRows, valueForwardsOf, visibilityStateProps, visibilityTerms, withoutTruthyTerm, wrappedElementKey };
|
|
@@ -9,8 +9,8 @@ interface AnatomyNode {
|
|
|
9
9
|
export declare function layerOfElement(element: unknown): string | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* The layer holding a slot prop's content-position node: the nearest layer above the `Slot` node
|
|
12
|
-
* named for the prop,
|
|
13
|
-
* prop, or the node hangs under no layer.
|
|
12
|
+
* named for the prop, or the one that places the prop between its items, itself included.
|
|
13
|
+
* `undefined` when the anatomy records no position for the prop, or the node hangs under no layer.
|
|
14
14
|
*/
|
|
15
15
|
export declare function slotHostLayer(anatomy: Record<string, AnatomyNode> | undefined, from: string): string | undefined;
|
|
16
16
|
export {};
|
|
@@ -16,10 +16,16 @@ function slotNameOf(node) {
|
|
|
16
16
|
const name = node.props?.name;
|
|
17
17
|
return typeof name === "string" ? name : void 0;
|
|
18
18
|
}
|
|
19
|
+
/** The slot prop a `Slot` node places between its items, named by its `separator` prop. */
|
|
20
|
+
function separatorNameOf(node) {
|
|
21
|
+
if (slotNameOf(node) === void 0) return void 0;
|
|
22
|
+
const separator = node?.props?.separator;
|
|
23
|
+
return typeof separator === "string" ? separator : void 0;
|
|
24
|
+
}
|
|
19
25
|
/**
|
|
20
26
|
* The layer holding a slot prop's content-position node: the nearest layer above the `Slot` node
|
|
21
|
-
* named for the prop,
|
|
22
|
-
* prop, or the node hangs under no layer.
|
|
27
|
+
* named for the prop, or the one that places the prop between its items, itself included.
|
|
28
|
+
* `undefined` when the anatomy records no position for the prop, or the node hangs under no layer.
|
|
23
29
|
*/
|
|
24
30
|
function slotHostLayer(anatomy, from) {
|
|
25
31
|
if (!anatomy) return void 0;
|
|
@@ -28,7 +34,7 @@ function slotHostLayer(anatomy, from) {
|
|
|
28
34
|
const held = [...node.children ?? [], ...Object.values(node.slots ?? {}).flat()];
|
|
29
35
|
for (const child of held) parents.set(child, key);
|
|
30
36
|
}
|
|
31
|
-
let key = Object.keys(anatomy).find((candidate) => slotNameOf(anatomy[candidate]) === from);
|
|
37
|
+
let key = Object.keys(anatomy).find((candidate) => slotNameOf(anatomy[candidate]) === from || separatorNameOf(anatomy[candidate]) === from);
|
|
32
38
|
const seen = /* @__PURE__ */ new Set();
|
|
33
39
|
while (key !== void 0 && !seen.has(key)) {
|
|
34
40
|
seen.add(key);
|