@unlayer/react-elements 0.1.11 → 0.1.12
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/index.cjs +25 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -508,7 +508,7 @@ interface ImageProps extends ItemComponentProps<ImageSemanticProps> {
|
|
|
508
508
|
*/
|
|
509
509
|
declare const Image: React$1.FC<ItemComponentProps<ImageSemanticProps>>;
|
|
510
510
|
|
|
511
|
-
type MenuSemanticProps = Omit<SemanticProps<MenuValues>, "padding"> & {
|
|
511
|
+
type MenuSemanticProps = Omit<SemanticProps<MenuValues>, "padding" | "fontFamily" | "fontWeight" | "fontSize" | "letterSpacing"> & Omit<TextStyleProps, "color" | "lineHeight"> & {
|
|
512
512
|
/** Menu items shorthand */
|
|
513
513
|
items?: MenuItem[];
|
|
514
514
|
/** Inner padding — a number (→ px) or CSS string. */
|
package/dist/index.d.ts
CHANGED
|
@@ -508,7 +508,7 @@ interface ImageProps extends ItemComponentProps<ImageSemanticProps> {
|
|
|
508
508
|
*/
|
|
509
509
|
declare const Image: React$1.FC<ItemComponentProps<ImageSemanticProps>>;
|
|
510
510
|
|
|
511
|
-
type MenuSemanticProps = Omit<SemanticProps<MenuValues>, "padding"> & {
|
|
511
|
+
type MenuSemanticProps = Omit<SemanticProps<MenuValues>, "padding" | "fontFamily" | "fontWeight" | "fontSize" | "letterSpacing"> & Omit<TextStyleProps, "color" | "lineHeight"> & {
|
|
512
512
|
/** Menu items shorthand */
|
|
513
513
|
items?: MenuItem[];
|
|
514
514
|
/** Inner padding — a number (→ px) or CSS string. */
|
package/dist/index.js
CHANGED
|
@@ -1546,6 +1546,29 @@ function getDisplayName2(element) {
|
|
|
1546
1546
|
const type = element.type;
|
|
1547
1547
|
return type?.displayName || type?.name;
|
|
1548
1548
|
}
|
|
1549
|
+
var VALID_ROOTS = /* @__PURE__ */ new Set(["Body", "Email", "Page", "Document"]);
|
|
1550
|
+
function unwrapRoot(element) {
|
|
1551
|
+
let current = element;
|
|
1552
|
+
for (let depth = 0; depth < 10; depth++) {
|
|
1553
|
+
const name = getDisplayName2(current);
|
|
1554
|
+
if (name && VALID_ROOTS.has(name)) break;
|
|
1555
|
+
const type = current.type;
|
|
1556
|
+
const isPlainFunctionComponent = typeof type === "function" && !type.prototype?.isReactComponent;
|
|
1557
|
+
if (!isPlainFunctionComponent) break;
|
|
1558
|
+
let produced;
|
|
1559
|
+
try {
|
|
1560
|
+
produced = type({ ...current.props });
|
|
1561
|
+
} catch (cause) {
|
|
1562
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
1563
|
+
throw new Error(
|
|
1564
|
+
`[Unlayer] renderToJson: could not unwrap <${name || "wrapper"}>. A wrapper must be a plain component that synchronously returns a root (<Email>, <Page>, <Document>, or <Body>) and uses no React hooks. Pass the root element directly \u2014 e.g. renderToJson(<Email>\u2026</Email>). (${detail})`
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
if (!React.isValidElement(produced)) break;
|
|
1568
|
+
current = produced;
|
|
1569
|
+
}
|
|
1570
|
+
return current;
|
|
1571
|
+
}
|
|
1549
1572
|
function collectChildren2(node) {
|
|
1550
1573
|
const result = [];
|
|
1551
1574
|
React.Children.forEach(node, (child) => {
|
|
@@ -1762,9 +1785,9 @@ function renderRowToJson(element) {
|
|
|
1762
1785
|
return processRow(element, counters);
|
|
1763
1786
|
}
|
|
1764
1787
|
function renderToJson(element) {
|
|
1788
|
+
element = unwrapRoot(element);
|
|
1765
1789
|
const displayName = getDisplayName2(element);
|
|
1766
|
-
|
|
1767
|
-
if (!displayName || !validRoots.has(displayName)) {
|
|
1790
|
+
if (!displayName || !VALID_ROOTS.has(displayName)) {
|
|
1768
1791
|
throw new Error(
|
|
1769
1792
|
`[Unlayer] renderToJson: Root element must be <Body>, <Email>, <Page>, or <Document>, but got <${displayName || "unknown"}>. Wrap your content: <Body><Row><Column>...</Column></Row></Body>`
|
|
1770
1793
|
);
|