@yahoo/uds-create-config 5.110.0 → 5.111.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.
|
@@ -92,7 +92,13 @@ function specFromCapture(options) {
|
|
|
92
92
|
props: converter.artboardProps(frameRole.component)
|
|
93
93
|
} : void 0);
|
|
94
94
|
let rootKey;
|
|
95
|
-
if (
|
|
95
|
+
if (!options.root && scope === tree && isCapturedPage(tree)) {
|
|
96
|
+
rootKey = "root";
|
|
97
|
+
converter.elements.root = converter.pageArtboard({
|
|
98
|
+
body: tree,
|
|
99
|
+
children: top
|
|
100
|
+
});
|
|
101
|
+
} else if (wrapper) {
|
|
96
102
|
rootKey = "root";
|
|
97
103
|
converter.elements.root = {
|
|
98
104
|
type: wrapper.type,
|
|
@@ -112,6 +118,11 @@ function specFromCapture(options) {
|
|
|
112
118
|
unresolvedIcons: converter.unresolvedIcons
|
|
113
119
|
};
|
|
114
120
|
}
|
|
121
|
+
/** Whether the tree is a captured page's body, which carries the page's own styles; a fragment's
|
|
122
|
+
* tree root carries none. */
|
|
123
|
+
function isCapturedPage(tree) {
|
|
124
|
+
return tree.tagName === "body" && (tree.hasAttribute("data-uds-computed") || tree.hasAttribute("style"));
|
|
125
|
+
}
|
|
115
126
|
/**
|
|
116
127
|
* Marks an unmarked wrapper the capture measured as adding nothing to its one child: the child's box,
|
|
117
128
|
* nothing painted, nothing it positions. It is folded into its content rather than framed, and its
|
|
@@ -737,14 +748,41 @@ var Converter = class {
|
|
|
737
748
|
}
|
|
738
749
|
return props;
|
|
739
750
|
}
|
|
740
|
-
/**
|
|
751
|
+
/**
|
|
752
|
+
* The props that make `component` an artboard: what its content is placed against and clipped to,
|
|
753
|
+
* at the capture's width. A root that states no width hugs its content on the canvas.
|
|
754
|
+
*/
|
|
741
755
|
artboardProps(component) {
|
|
742
756
|
const props = {};
|
|
743
757
|
const grammar = this.grammar.component(component);
|
|
744
|
-
|
|
758
|
+
const width = this.options.width ?? DEFAULT_CAPTURE_WIDTH;
|
|
759
|
+
if (grammar) this.propsFromDeclarations([...ARTBOARD, ["width", `${width}px`]], grammar, props);
|
|
745
760
|
return props;
|
|
746
761
|
}
|
|
747
762
|
/**
|
|
763
|
+
* The artboard a captured page becomes: a plain `div` holding the body's content, painted and set
|
|
764
|
+
* in type as the body was, the capture's width and at least its height. Its size is inline, where
|
|
765
|
+
* the canvas reads a plain root's size.
|
|
766
|
+
*/
|
|
767
|
+
pageArtboard({ body, children }) {
|
|
768
|
+
const { className, style } = this.plainStyle(body);
|
|
769
|
+
const width = this.options.width ?? DEFAULT_CAPTURE_WIDTH;
|
|
770
|
+
const artboard = Object.fromEntries(ARTBOARD.map(([property, value]) => [camelCase(property), value]));
|
|
771
|
+
return {
|
|
772
|
+
type: "div",
|
|
773
|
+
props: {
|
|
774
|
+
...className ? { className } : {},
|
|
775
|
+
style: {
|
|
776
|
+
...style,
|
|
777
|
+
...artboard,
|
|
778
|
+
width: `${width}px`,
|
|
779
|
+
...this.options.height !== void 0 ? { minHeight: `${this.options.height}px` } : {}
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
children
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
748
786
|
* What `el`'s render placed outside its stamped slot layers and claimed layers, walking down to
|
|
749
787
|
* the first thing on each branch that is a piece of its own: a nested component, a glyph (unless
|
|
750
788
|
* `el` draws its own), a field it does not read, or an unmarked element with an inline style.
|
|
@@ -973,6 +1011,10 @@ var Converter = class {
|
|
|
973
1011
|
if (into === "children" && slot !== ownChildren.at(-1)) continue;
|
|
974
1012
|
const holder = into === "children" ? layer : slotLayerNamed(layer, into);
|
|
975
1013
|
if (!holder) continue;
|
|
1014
|
+
if (props[slot] !== void 0) {
|
|
1015
|
+
if (layer === el && holder === layer) rootSlotted = true;
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
976
1018
|
const declaration = declared[slot];
|
|
977
1019
|
const callerMarkup = declaration?.type === "slot" && declaration.text !== true;
|
|
978
1020
|
const fills = holder === layer ? this.convertOutsideLayers(layer, path, callerMarkup) : this.convertChildren(holder);
|