@yahoo/uds-create-config 5.100.7 → 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.
@@ -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
  }
@@ -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 { slug, system } = attachedSystem(config);
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
- slug,
94
- placement
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 = () => ({
@@ -1,11 +1,11 @@
1
- import { kindOf, pathOf, ref } from "../../framework/utils/refs.js";
1
+ import { 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";
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({
@@ -130,14 +130,10 @@ 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({
133
+ const type = placedTypeRef({
134
134
  type: element.type,
135
- slug
136
- });
137
- requireComponent({
135
+ slug,
138
136
  system,
139
- type,
140
- spelled: element.type,
141
137
  field: [
142
138
  "data",
143
139
  "subtree",
@@ -201,15 +197,6 @@ function componentOf({ config, body }) {
201
197
  path: entity.path
202
198
  } : void 0;
203
199
  }
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
- }
213
200
  function placeOf(config, path, field) {
214
201
  const root = rootOf(path);
215
202
  if (path === root) return rejectData(`"${path}" is a placed node; this acts on an element inside one.`, field);
@@ -457,18 +444,14 @@ function reparent({ config, path, parent, slotProp: slot, index }) {
457
444
  }];
458
445
  }
459
446
  function wrap(config, input) {
460
- const { slug } = attachedSystem(config);
447
+ const { slug, system } = attachedSystem(config);
461
448
  const children = childrenOf(bodyOf(config, input.path, ["path"]));
462
449
  const wrapped = new Set(input.data.elements);
463
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"]);
464
- const type = elementTypeRef({
451
+ const type = placedTypeRef({
465
452
  type: input.data.container.type,
466
- slug
467
- });
468
- requireComponent({
469
- system: attachedSystem(config).system,
470
- type,
471
- spelled: input.data.container.type,
453
+ slug,
454
+ system,
472
455
  field: [
473
456
  "data",
474
457
  "container",
@@ -21,14 +21,14 @@ declare function specToNodePatches({
21
21
  config,
22
22
  nodeId,
23
23
  spec,
24
- slug,
25
- placement
24
+ placement,
25
+ field
26
26
  }: {
27
27
  readonly config: Config;
28
28
  readonly nodeId: string;
29
29
  readonly spec: Spec;
30
- readonly slug: string;
31
- readonly placement: Placement;
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: elementTypeRef({
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, slug, placement }) {
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
- ...layerProps[layer],
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
- ...layerProps[layer],
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,