@yahoo/uds-create-config 5.100.6 → 5.100.7
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.
|
@@ -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");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pathOf, 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
|
import { pathInput } from "../../framework/schemas.js";
|
|
4
4
|
import { childrenPolicy } from "../system/element.js";
|
|
@@ -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,22 @@ 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 = elementTypeRef({
|
|
134
|
+
type: element.type,
|
|
135
|
+
slug
|
|
136
|
+
});
|
|
137
|
+
requireComponent({
|
|
138
|
+
system,
|
|
139
|
+
type,
|
|
140
|
+
spelled: element.type,
|
|
141
|
+
field: [
|
|
142
|
+
"data",
|
|
143
|
+
"subtree",
|
|
144
|
+
"elements",
|
|
145
|
+
key,
|
|
146
|
+
"type"
|
|
147
|
+
]
|
|
148
|
+
});
|
|
133
149
|
const slots = {};
|
|
134
150
|
for (const [name, fills] of Object.entries(element.slots ?? {})) slots[name] = fills.map(sub);
|
|
135
151
|
patches.push({
|
|
@@ -137,10 +153,7 @@ function insert(config, input) {
|
|
|
137
153
|
operation: "create",
|
|
138
154
|
path: pathFor.get(key),
|
|
139
155
|
data: {
|
|
140
|
-
type
|
|
141
|
-
type: element.type,
|
|
142
|
-
slug
|
|
143
|
-
}),
|
|
156
|
+
type,
|
|
144
157
|
props: element.props ?? {},
|
|
145
158
|
...element.children?.length ? { children: element.children.map(sub) } : {},
|
|
146
159
|
...Object.keys(slots).length > 0 ? { slots } : {},
|
|
@@ -188,6 +201,15 @@ function componentOf({ config, body }) {
|
|
|
188
201
|
path: entity.path
|
|
189
202
|
} : void 0;
|
|
190
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Refuses an element type naming a component the attached system doesn't have. An unknown component
|
|
206
|
+
* renders nothing, children included, so the write would leave an invisible element behind.
|
|
207
|
+
*/
|
|
208
|
+
function requireComponent({ system, type, spelled, field }) {
|
|
209
|
+
if (kindOf(type) !== "component") return;
|
|
210
|
+
if (system.resolve("component", pathOf(type))) return;
|
|
211
|
+
rejectData(`The system has no component "${spelled}".`, field);
|
|
212
|
+
}
|
|
191
213
|
function placeOf(config, path, field) {
|
|
192
214
|
const root = rootOf(path);
|
|
193
215
|
if (path === root) return rejectData(`"${path}" is a placed node; this acts on an element inside one.`, field);
|
|
@@ -443,6 +465,16 @@ function wrap(config, input) {
|
|
|
443
465
|
type: input.data.container.type,
|
|
444
466
|
slug
|
|
445
467
|
});
|
|
468
|
+
requireComponent({
|
|
469
|
+
system: attachedSystem(config).system,
|
|
470
|
+
type,
|
|
471
|
+
spelled: input.data.container.type,
|
|
472
|
+
field: [
|
|
473
|
+
"data",
|
|
474
|
+
"container",
|
|
475
|
+
"type"
|
|
476
|
+
]
|
|
477
|
+
});
|
|
446
478
|
const slotName = input.data.container.slotProp ?? "children";
|
|
447
479
|
const component = componentOf({
|
|
448
480
|
config,
|