@yahoo/uds-create-config 5.100.6 → 5.101.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/capture/capture-to-spec.js +1 -1
- package/dist/capture/icon-resolver.js +11 -1
- package/dist/capture/node-ops.js +8 -3
- package/dist/entities/canvas/node-gestures.js +24 -9
- package/dist/entities/canvas/node-patches.d.ts +4 -4
- package/dist/entities/canvas/node-patches.js +33 -8
- package/dist/framework/class-names.js +1 -1
- package/dist/framework/render-spec.js +28 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -277,7 +277,7 @@ var Converter = class {
|
|
|
277
277
|
convert(el) {
|
|
278
278
|
if (!visible(el)) return [];
|
|
279
279
|
const path = el.getAttribute("data-uds-component");
|
|
280
|
-
if (path && el.getAttribute("data-uds-layer") === "root") {
|
|
280
|
+
if (path && el.getAttribute("data-uds-layer") === "root" && this.options.config.resolve("component", path)) {
|
|
281
281
|
const key = this.component(el, path);
|
|
282
282
|
return key ? [key] : [];
|
|
283
283
|
}
|
|
@@ -166,7 +166,7 @@ function nameIconsInTree({ tree, hook }) {
|
|
|
166
166
|
unresolved += 1;
|
|
167
167
|
return node;
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
const named = {
|
|
170
170
|
tag: "span",
|
|
171
171
|
attrs: {
|
|
172
172
|
"data-uds-component": answer.component,
|
|
@@ -174,6 +174,16 @@ function nameIconsInTree({ tree, hook }) {
|
|
|
174
174
|
"data-uds-props": JSON.stringify(answer.props)
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
|
+
if (component) return {
|
|
178
|
+
tag: "span",
|
|
179
|
+
attrs: {
|
|
180
|
+
"data-uds-component": component,
|
|
181
|
+
"data-uds-layer": node.attrs?.["data-uds-layer"] ?? "",
|
|
182
|
+
...node.attrs?.class ? { class: node.attrs.class } : {}
|
|
183
|
+
},
|
|
184
|
+
children: [named]
|
|
185
|
+
};
|
|
186
|
+
return named;
|
|
177
187
|
}
|
|
178
188
|
if (component && isRoot && hook.renderers.has(component)) {
|
|
179
189
|
const svg = (node.children ?? []).find((child) => typeof child !== "string" && child.tag === "svg");
|
package/dist/capture/node-ops.js
CHANGED
|
@@ -58,7 +58,7 @@ function artboardsOn(config, page) {
|
|
|
58
58
|
return out.sort((a, b) => a.order - b.order || a.id.localeCompare(b.id));
|
|
59
59
|
}
|
|
60
60
|
function convert(config, input) {
|
|
61
|
-
const {
|
|
61
|
+
const { system } = attachedSystem(config);
|
|
62
62
|
const data = input.data;
|
|
63
63
|
if (config.resolve("node", input.path)) return rejectData(`Node "${input.path}" already exists; pick a path that is free.`, ["path"]);
|
|
64
64
|
if (!data.page) return rejectData(`Pass \`page\` (and \`label\`) to place node "${input.path}".`, ["data", "page"]);
|
|
@@ -86,12 +86,17 @@ function convert(config, input) {
|
|
|
86
86
|
label: data.label ?? input.path,
|
|
87
87
|
order: front && Number.isFinite(front.order) ? front.order + 1 : 1
|
|
88
88
|
};
|
|
89
|
+
const framed = data.frame !== void 0;
|
|
89
90
|
return specToNodePatches({
|
|
90
91
|
config,
|
|
91
92
|
nodeId: input.path,
|
|
92
93
|
spec: converted.spec,
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
placement,
|
|
95
|
+
field: (key) => framed && key === converted.spec.root ? [
|
|
96
|
+
"data",
|
|
97
|
+
"frame",
|
|
98
|
+
"type"
|
|
99
|
+
] : ["data", "tree"]
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
102
|
const fromHtmlExample = () => ({
|
|
@@ -5,7 +5,7 @@ import { childrenPolicy } from "../system/element.js";
|
|
|
5
5
|
import { surfaceProps } from "../../framework/prop-surface.js";
|
|
6
6
|
import { forceModeProp, forceModeProps } from "../../framework/class-names.js";
|
|
7
7
|
import { slotOf } from "../../spec/slot.js";
|
|
8
|
-
import { PLACED_NODE_KEY, attachedSystem, elementTypeRef, postOrder } from "./node-patches.js";
|
|
8
|
+
import { PLACED_NODE_KEY, attachedSystem, elementTypeRef, placedTypeRef, postOrder } from "./node-patches.js";
|
|
9
9
|
import { z } from "zod";
|
|
10
10
|
//#region src/entities/canvas/node-gestures.ts
|
|
11
11
|
const specSchema = z.object({
|
|
@@ -112,7 +112,7 @@ function childrenOf(body) {
|
|
|
112
112
|
return [...body.children ?? []];
|
|
113
113
|
}
|
|
114
114
|
function insert(config, input) {
|
|
115
|
-
const { slug } = attachedSystem(config);
|
|
115
|
+
const { slug, system } = attachedSystem(config);
|
|
116
116
|
const parent = bodyOf(config, input.path, ["path"]);
|
|
117
117
|
const spec = input.data.subtree;
|
|
118
118
|
const elements = spec.elements;
|
|
@@ -130,6 +130,18 @@ function insert(config, input) {
|
|
|
130
130
|
for (const key of order) {
|
|
131
131
|
const element = elements[key];
|
|
132
132
|
if (!element) continue;
|
|
133
|
+
const type = placedTypeRef({
|
|
134
|
+
type: element.type,
|
|
135
|
+
slug,
|
|
136
|
+
system,
|
|
137
|
+
field: [
|
|
138
|
+
"data",
|
|
139
|
+
"subtree",
|
|
140
|
+
"elements",
|
|
141
|
+
key,
|
|
142
|
+
"type"
|
|
143
|
+
]
|
|
144
|
+
});
|
|
133
145
|
const slots = {};
|
|
134
146
|
for (const [name, fills] of Object.entries(element.slots ?? {})) slots[name] = fills.map(sub);
|
|
135
147
|
patches.push({
|
|
@@ -137,10 +149,7 @@ function insert(config, input) {
|
|
|
137
149
|
operation: "create",
|
|
138
150
|
path: pathFor.get(key),
|
|
139
151
|
data: {
|
|
140
|
-
type
|
|
141
|
-
type: element.type,
|
|
142
|
-
slug
|
|
143
|
-
}),
|
|
152
|
+
type,
|
|
144
153
|
props: element.props ?? {},
|
|
145
154
|
...element.children?.length ? { children: element.children.map(sub) } : {},
|
|
146
155
|
...Object.keys(slots).length > 0 ? { slots } : {},
|
|
@@ -435,13 +444,19 @@ function reparent({ config, path, parent, slotProp: slot, index }) {
|
|
|
435
444
|
}];
|
|
436
445
|
}
|
|
437
446
|
function wrap(config, input) {
|
|
438
|
-
const { slug } = attachedSystem(config);
|
|
447
|
+
const { slug, system } = attachedSystem(config);
|
|
439
448
|
const children = childrenOf(bodyOf(config, input.path, ["path"]));
|
|
440
449
|
const wrapped = new Set(input.data.elements);
|
|
441
450
|
for (const element of input.data.elements) if (!children.some((child) => pathOf(child) === element)) return rejectData(`"${element}" is not a child of "${input.path}"; wrap acts on a node's direct children.`, ["data", "elements"]);
|
|
442
|
-
const type =
|
|
451
|
+
const type = placedTypeRef({
|
|
443
452
|
type: input.data.container.type,
|
|
444
|
-
slug
|
|
453
|
+
slug,
|
|
454
|
+
system,
|
|
455
|
+
field: [
|
|
456
|
+
"data",
|
|
457
|
+
"container",
|
|
458
|
+
"type"
|
|
459
|
+
]
|
|
445
460
|
});
|
|
446
461
|
const slotName = input.data.container.slotProp ?? "children";
|
|
447
462
|
const component = componentOf({
|
|
@@ -21,14 +21,14 @@ declare function specToNodePatches({
|
|
|
21
21
|
config,
|
|
22
22
|
nodeId,
|
|
23
23
|
spec,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
placement,
|
|
25
|
+
field
|
|
26
26
|
}: {
|
|
27
27
|
readonly config: Config;
|
|
28
28
|
readonly nodeId: string;
|
|
29
29
|
readonly spec: Spec;
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
30
|
+
readonly placement: Placement; /** Where a refused element's type sits in the caller's input. */
|
|
31
|
+
readonly field?: (key: string) => (string | number)[];
|
|
32
32
|
}): Patch[];
|
|
33
33
|
//#endregion
|
|
34
34
|
export { PLACED_NODE_KEY, specToNodePatches };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref } from "../../framework/utils/refs.js";
|
|
1
|
+
import { kindOf, pathOf, ref } from "../../framework/utils/refs.js";
|
|
2
2
|
import { rejectData } from "../../framework/rejection.js";
|
|
3
3
|
//#region src/entities/canvas/node-patches.ts
|
|
4
4
|
/**
|
|
@@ -28,15 +28,30 @@ function elementTypeRef({ type, slug }) {
|
|
|
28
28
|
if (SPEC_PRIMITIVES.has(type)) return ref("spec", type);
|
|
29
29
|
return ref("component", type, slug);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* `elementTypeRef` for a row a write creates. It refuses a type naming a component the attached
|
|
33
|
+
* system doesn't have, since an unknown component renders nothing, children included. HTML tags and
|
|
34
|
+
* spec primitives pass.
|
|
35
|
+
*/
|
|
36
|
+
function placedTypeRef({ type, slug, system, field }) {
|
|
37
|
+
const placed = elementTypeRef({
|
|
38
|
+
type,
|
|
39
|
+
slug
|
|
40
|
+
});
|
|
41
|
+
if (kindOf(placed) === "component" && !system.resolve("component", pathOf(placed))) return rejectData(`The system has no component "${pathOf(placed)}".`, field);
|
|
42
|
+
return placed;
|
|
43
|
+
}
|
|
31
44
|
/** The content fields of one element as a node row holds them. */
|
|
32
|
-
function elementNodeFields({ element, nodeId, slug }) {
|
|
45
|
+
function elementNodeFields({ element, nodeId, slug, system, field }) {
|
|
33
46
|
const sub = (key) => ref("node", `${nodeId}/${key}`);
|
|
34
47
|
const slots = {};
|
|
35
48
|
for (const [name, fills] of Object.entries(element.slots ?? {})) slots[name] = fills.map(sub);
|
|
36
49
|
return {
|
|
37
|
-
type:
|
|
50
|
+
type: placedTypeRef({
|
|
38
51
|
type: element.type,
|
|
39
|
-
slug
|
|
52
|
+
slug,
|
|
53
|
+
system,
|
|
54
|
+
field
|
|
40
55
|
}),
|
|
41
56
|
props: element.props ?? {},
|
|
42
57
|
...element.children?.length ? { children: element.children.map(sub) } : {},
|
|
@@ -67,7 +82,13 @@ function postOrder(spec) {
|
|
|
67
82
|
* rows that point at them, then the placed node itself with its placement. The node must not exist
|
|
68
83
|
* yet; a paste mints a fresh id, so a path that is taken is the caller's mistake, not a refill.
|
|
69
84
|
*/
|
|
70
|
-
function specToNodePatches({ config, nodeId, spec,
|
|
85
|
+
function specToNodePatches({ config, nodeId, spec, placement, field = (key) => [
|
|
86
|
+
"spec",
|
|
87
|
+
"elements",
|
|
88
|
+
key,
|
|
89
|
+
"type"
|
|
90
|
+
] }) {
|
|
91
|
+
const { slug, system } = attachedSystem(config);
|
|
71
92
|
if (config.resolve("node", nodeId)) throw new Error(`Node "${nodeId}" already exists; pick a path that is free.`);
|
|
72
93
|
const patches = [];
|
|
73
94
|
for (const key of postOrder(spec)) {
|
|
@@ -79,7 +100,9 @@ function specToNodePatches({ config, nodeId, spec, slug, placement }) {
|
|
|
79
100
|
data: elementNodeFields({
|
|
80
101
|
element: spec.elements[key],
|
|
81
102
|
nodeId,
|
|
82
|
-
slug
|
|
103
|
+
slug,
|
|
104
|
+
system,
|
|
105
|
+
field: field(key)
|
|
83
106
|
})
|
|
84
107
|
});
|
|
85
108
|
}
|
|
@@ -91,7 +114,9 @@ function specToNodePatches({ config, nodeId, spec, slug, placement }) {
|
|
|
91
114
|
...elementNodeFields({
|
|
92
115
|
element: spec.elements[spec.root],
|
|
93
116
|
nodeId,
|
|
94
|
-
slug
|
|
117
|
+
slug,
|
|
118
|
+
system,
|
|
119
|
+
field: field(spec.root)
|
|
95
120
|
}),
|
|
96
121
|
meta: spec.meta,
|
|
97
122
|
page: ref("page", placement.page),
|
|
@@ -109,4 +134,4 @@ function specToNodePatches({ config, nodeId, spec, slug, placement }) {
|
|
|
109
134
|
return patches;
|
|
110
135
|
}
|
|
111
136
|
//#endregion
|
|
112
|
-
export { PLACED_NODE_KEY, attachedSystem, elementTypeRef, postOrder, specToNodePatches };
|
|
137
|
+
export { PLACED_NODE_KEY, attachedSystem, elementTypeRef, placedTypeRef, postOrder, specToNodePatches };
|
|
@@ -1236,4 +1236,4 @@ function splitVariants(cls) {
|
|
|
1236
1236
|
return segments;
|
|
1237
1237
|
}
|
|
1238
1238
|
//#endregion
|
|
1239
|
-
export { arbitraryClassName, arbitraryNeedsClass, classLeaf, classSelector, clearsCompositeDefault, componentClassBase, componentCompositeClasses, componentLayerClass, componentMotionClasses, componentPropClasses, componentPropComposites, componentRuleClasses, componentStateAttribute, componentStateAttributes, compositeMemberBag, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, forceStateSelector, forcedModifierAttributes, forwardedCompositeClears, inlineRuleComposites, isForceModeProp, kebabComponent, layerJsMotionPresets, layerRoutedProps, modifierUtilitiesUsed, motionClassName, motionKeyframesName, ruleCondition, splitRuleComposites, splitStyleProps, splitVariants, stylePropClassBase, stylePropClassName, stylePropClasses, stylePropOffScaleLiteral, stylePropOwnClasses, styleRuleMotionClasses };
|
|
1239
|
+
export { arbitraryClassName, arbitraryNeedsClass, classLeaf, classSelector, clearsCompositeDefault, componentClassBase, componentCompositeClasses, componentLayerClass, componentMotionClasses, componentPropClasses, componentPropComposites, componentRuleClasses, componentStateAttribute, componentStateAttributes, compositeMemberBag, forceModeAttribute, forceModeAttributeOf, forceModeProp, forceModePropGroup, forceModePropValue, forceModeProps, forceStateAttribute, forceStateSelector, forcedModifierAttributes, forwardedCompositeClears, inlineRuleComposites, isForceModeProp, kebabComponent, layerJsMotionPresets, layerRoutedProps, modifierUtilitiesUsed, motionClassName, motionKeyframesName, reactStyleKey, ruleCondition, splitRuleComposites, splitStyleProps, splitVariants, stylePropClassBase, stylePropClassName, stylePropClasses, stylePropOffScaleLiteral, stylePropOwnClasses, styleRuleMotionClasses };
|
|
@@ -11,7 +11,7 @@ import { withRequiredContentHidden } from "../entities/system/required-content-l
|
|
|
11
11
|
import { inlineMotionProps, jsMotionPresets } from "../entities/system/motion-presets.js";
|
|
12
12
|
import { COPY_OF_ATTR, graftPreviewElements } from "../spec/preview-elements.js";
|
|
13
13
|
import { conditionHolds } from "./layer-styles.js";
|
|
14
|
-
import { componentLayerClass, componentPropClasses, componentRuleClasses, componentStateAttributes, forcedModifierAttributes, layerJsMotionPresets, layerRoutedProps, splitStyleProps, styleRuleMotionClasses } from "./class-names.js";
|
|
14
|
+
import { componentLayerClass, componentPropClasses, componentRuleClasses, componentStateAttributes, forcedModifierAttributes, layerJsMotionPresets, layerRoutedProps, reactStyleKey, splitStyleProps, styleRuleMotionClasses } from "./class-names.js";
|
|
15
15
|
import { FORM_FIELDS } from "./dom-attributes.js";
|
|
16
16
|
//#region src/framework/render-spec.ts
|
|
17
17
|
/** Whether a value is a {@link LayerBagValue}. */
|
|
@@ -1413,6 +1413,25 @@ function ruleKeysFor(config, path, layer, state, pins) {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
return keys;
|
|
1415
1415
|
}
|
|
1416
|
+
/**
|
|
1417
|
+
* A call site's layer bag as it lands over the layer's split props: its `style` joins the one the
|
|
1418
|
+
* split wrote for off-scale values rather than replacing it, and wins per property. A built app paints
|
|
1419
|
+
* those values as classes, so there a `layerProps` style and a `height="[860px]"` both hold.
|
|
1420
|
+
*/
|
|
1421
|
+
function overSplitStyle({ bag, split }) {
|
|
1422
|
+
const own = bag?.style;
|
|
1423
|
+
const written = split?.style;
|
|
1424
|
+
if (!own || typeof own !== "object" || !written || typeof written !== "object") return bag;
|
|
1425
|
+
const given = {};
|
|
1426
|
+
for (const [property, value] of Object.entries(own)) given[reactStyleKey(property)] = value;
|
|
1427
|
+
return {
|
|
1428
|
+
...bag,
|
|
1429
|
+
style: {
|
|
1430
|
+
...written,
|
|
1431
|
+
...given
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1416
1435
|
/** A bag without the given keys. */
|
|
1417
1436
|
function withoutKeys(bag, keys) {
|
|
1418
1437
|
if (keys.size === 0) return bag;
|
|
@@ -1677,7 +1696,10 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1677
1696
|
...forwarded[layer],
|
|
1678
1697
|
...Object.fromEntries(routes.filter(({ from, into }) => state[from] !== void 0 && into !== "className").map(({ from, into }) => [into, state[from]])),
|
|
1679
1698
|
...split?.rest,
|
|
1680
|
-
...
|
|
1699
|
+
...overSplitStyle({
|
|
1700
|
+
bag: layerProps[layer],
|
|
1701
|
+
split: split?.rest
|
|
1702
|
+
}),
|
|
1681
1703
|
className: classesFor(config, path, layer, state, [
|
|
1682
1704
|
split?.className,
|
|
1683
1705
|
...routes.filter(({ into }) => into === "className").map(({ from }) => state[from]),
|
|
@@ -1840,7 +1862,10 @@ function expandInstance(sink, path, instanceProps, content, hint, instanceSlots)
|
|
|
1840
1862
|
...isRoot ? rest : forwardedSplits.get(layer)?.rest,
|
|
1841
1863
|
...siblingValues,
|
|
1842
1864
|
...slot && slotValue !== void 0 ? { [intoName(slot.into)]: slotValue } : {},
|
|
1843
|
-
...
|
|
1865
|
+
...overSplitStyle({
|
|
1866
|
+
bag: layerProps[layer],
|
|
1867
|
+
split: isRoot ? rest : forwardedSplits.get(layer)?.rest
|
|
1868
|
+
}),
|
|
1844
1869
|
...written,
|
|
1845
1870
|
className: classesFor(config, path, layer, state, [
|
|
1846
1871
|
isRoot ? styleClasses : forwardedSplits.get(layer)?.className,
|