@unlayer/react-elements 0.1.14 → 0.1.15
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 +44 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -5
- package/dist/index.d.ts +19 -5
- package/dist/index.js +44 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/image-sizing.ts","../../shared/src/config.ts","../../shared/src/layouts.ts","../../shared/src/utils/lexical-helpers.ts","../../shared/src/utils/merge-values.ts","../../shared/src/utils/semantic-props.ts","../../shared/src/utils/html-to-text.ts","../src/utils/create-component.tsx","../src/components/Button.tsx","../src/components/Divider.tsx","../src/components/Heading.tsx","../src/components/Html.tsx","../src/components/Image.tsx","../src/components/Menu.tsx","../src/components/Paragraph.tsx","../src/components/Social.tsx","../src/components/Table.tsx","../src/components/Video.tsx","../src/utils/container-defaults.ts","../src/components/Row.tsx","../src/components/Column.tsx","../src/components/Body.tsx","../src/components/Email.tsx","../src/components/Page.tsx","../src/components/Document.tsx","../src/context/UnlayerProvider.tsx","../src/utils/extract-head.ts","../src/utils/render-to-html.tsx","../src/utils/render-to-json.ts"],"names":["jsx","jsxs","ButtonDefaults","ButtonExporters","DEFAULT_VALUES","DividerDefaults","DividerExporters","HeadingDefaults","HeadingExporters","HtmlDefaults","HtmlExporters","ImageDefaults","ImageExporters","MenuDefaults","MenuExporters","ParagraphDefaults","ParagraphExporters","SocialDefaults","SocialExporters","TableDefaults","TableExporters","VideoDefaults","VideoExporters","BodyDefaults","RowDefaults","ColumnDefaults","RowExporters","React","DEFAULT_CONTAINER_PADDING","ColumnExporters","ContentExporters","BodyExporters","ReactDOMServer","createContext","useMemo","useContext","ensureMeta","heads","renderToStaticMarkup","_schemaVersion","getDisplayName","collectChildren","extractSemanticProps","nextCounter","name"],"mappings":";;;;;;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R,CAAA,2DAAA,EACc,eAAe,SAAS,CAAA,8CAAA;AAAA,KAExC;AAAA,EACF;AAEA,EAAA,MAAM,WAAmC,EAAC;AAC1C,EAAA,OAAO,UAAA,CAAW,SAAS,QAAQ,CAAA;AACrC;AAEO,SAAS,aAAa,OAAA,EAAyC;AAGpE,EAAA,OAAA,GAAU,WAAW,OAAO,CAAA;AAC5B,EAAA,MAAM,WAAA,GAAcA,gBAAe,OAAO,CAAA;AAE1C,EAAA,IAAI,CAAC,WAAA,IAAe,CAAC,WAAA,CAAY,GAAA,CAAI,WAAW,CAAA,EAAG;AACjD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,8FAAA,EACc,eAAe,SAAS,CAAA,kEAAA;AAAA,KAExC;AAAA,EACF;AASA,EAAA,MAAM,WAAmC,EAAC;AAC1C,EAAA,MAAM,IAAA,GAAO,WAAA,CAAY,OAAA,EAAS,QAAQ,CAAA;AAE1C,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * Image display-width resolution.\n *\n * In Unlayer's value model an image's display size is `autoWidth` + `maxWidth`,\n * kept separate from the natural `src.width`/`height`. A fixed display size is\n * `autoWidth: false` with `maxWidth` as a PERCENT of the column's content slot\n * (e.g. `\"50%\"`) — not the natural-size field. Encoding a fixed width that way\n * keeps it stable when the design JSON is opened in an editor, which treats\n * `src.width`/`height` as the intrinsic dimensions and may refresh them.\n *\n * Authors pass pixels, so a px pin is captured as `{ autoWidth:false,\n * maxWidth:<px> }` and converted here to the equivalent percent using the same\n * available-width geometry the renderers use (contentWidth × column share, minus\n * paddings/borders), so the emitted value renders at the requested on-screen size.\n */\n\n/** Parse a CSS length to px, strictly: a number or a numeric string with an\n * optional px unit (\"12\" / \"12px\"). Non-px units (\"1.5em\", \"calc(…)\") return\n * undefined so the pinning pass leaves them untouched instead of misreading\n * them as px (SizeInput allows non-px CSS strings). */\nfunction toPx(value: unknown): number | undefined {\n if (typeof value === \"number\") return Number.isFinite(value) ? value : undefined;\n if (typeof value !== \"string\") return undefined;\n const m = /^(\\d+(?:\\.\\d+)?)(?:px)?$/.exec(value.trim());\n return m ? parseFloat(m[1]) : undefined;\n}\n\n// NOTE: the geometry parsers below use parseFloat on each token, intentionally\n// mirroring the renderer's explodePaddingsOrMargins / explodeBorder (which the\n// image exporter subtracts from the available width). The renderer reads a token\n// like \"10%\" as its numeric value (10), so the slot math must too — switching to\n// strict px parsing here would make the pinned percent diverge from what the\n// editor actually renders. Strict px parsing is only for the display-pin value\n// (toPx, in pinImageSrc), never for the geometry.\n\n/** Left/right edge sizes from a CSS box shorthand (padding/margin), parsed the\n * same way the renderer's explodePaddingsOrMargins does (parseFloat per token). */\nfunction edges(value: unknown): { left: number; right: number } {\n if (value == null) return { left: 0, right: 0 };\n if (typeof value === \"number\") return { left: value, right: value };\n const parts = String(value)\n .trim()\n .split(/\\s+/)\n .map((p) => parseFloat(p) || 0);\n // CSS order: 1 = all; 2 = [v h]; 3 = [t h b]; 4 = [t r b l].\n if (parts.length === 1) return { left: parts[0], right: parts[0] };\n if (parts.length === 2 || parts.length === 3)\n return { left: parts[1], right: parts[1] };\n return { left: parts[3] || 0, right: parts[1] || 0 };\n}\n\n/** Left/right border widths from a per-side border object, parsed the same way\n * the renderer's explodeBorder does (parseFloat per width). */\nfunction borderEdges(border: unknown): { left: number; right: number } {\n if (!border || typeof border !== \"object\") return { left: 0, right: 0 };\n const b = border as Record<string, unknown>;\n const width = (v: unknown) => parseFloat(`${v ?? \"\"}`) || 0;\n return {\n left: width(b.borderLeftWidth),\n right: width(b.borderRightWidth),\n };\n}\n\n/** A body `contentWidth` is \"fixed px\" only when it's a number or a numeric\n * string with an optional px unit (`600`, `\"600px\"`, or `\"600\"`). Percentages\n * and keywords like `\"auto\"` are NOT fixed → `undefined`. */\nfunction fixedContentWidth(contentWidth: unknown): number | undefined {\n if (typeof contentWidth === \"number\")\n return Number.isFinite(contentWidth) ? contentWidth : undefined;\n if (typeof contentWidth === \"string\") {\n const m = /^(\\d+(?:\\.\\d+)?)(?:px)?$/.exec(contentWidth.trim());\n if (m) return parseFloat(m[1]);\n }\n return undefined;\n}\n\n/** Unlayer's body content width fallback when `contentWidth` isn't fixed px. */\nconst FALLBACK_BODY_CONTENT_WIDTH = 500;\n/** Unlayer's default content-block padding when a block sets none. */\nconst DEFAULT_CONTAINER_PADDING = \"10px\";\n\n/**\n * A body `contentWidth` resolved to px: the fixed px value, or `fallback`\n * (500, Unlayer's base width) for non-px values like `\"50%\"` / `\"auto\"`.\n *\n * Shared with Row's grid CSS (`toContentWidthPx`) so the slot geometry here and\n * the renderer's column math agree on what counts as a fixed width — and so a\n * non-px `contentWidth` collapses to the same base everywhere instead of being\n * `parseInt`-ed into a bogus px value (e.g. `\"50%\"` → 50).\n */\nexport function bodyContentWidthPx(\n contentWidth: unknown,\n fallback: number = FALLBACK_BODY_CONTENT_WIDTH\n): number {\n return fixedContentWidth(contentWidth) ?? fallback;\n}\n\nexport interface SlotContext {\n bodyValues?: { contentWidth?: number | string; padding?: unknown; border?: unknown };\n rowValues?: { padding?: unknown; border?: unknown };\n rowCells?: number[];\n columnIndex?: number;\n columnValues?: { padding?: unknown; border?: unknown };\n /** The image block's own containerPadding (defaults to 10px like the editor). */\n containerPadding?: unknown;\n}\n\n/**\n * Width in px available to a content block, mirroring the renderers'\n * available-width math: contentWidth, minus body/row/column/container paddings\n * and borders, scaled by the column's share of the row.\n */\nexport function contentSlotWidth(ctx: SlotContext): number {\n const { bodyValues = {}, rowValues = {}, columnValues = {} } = ctx;\n const rowCells = ctx.rowCells && ctx.rowCells.length ? ctx.rowCells : [1];\n const columnIndex = ctx.columnIndex ?? 0;\n\n const bodyWidth = bodyContentWidthPx(bodyValues.contentWidth);\n\n const bp = edges(bodyValues.padding);\n const bb = borderEdges(bodyValues.border);\n const bodyAvail = bodyWidth - bp.left - bp.right - bb.left - bb.right;\n\n const rp = edges(rowValues.padding);\n const rb = borderEdges(rowValues.border);\n const rowAvail = bodyAvail - rp.left - rp.right - rb.left - rb.right;\n\n const rowSpan = rowCells.reduce((a, b) => a + b, 0) || 1;\n const colSpan = rowCells[columnIndex] || 1;\n const colWidth = (colSpan / rowSpan) * rowAvail;\n\n const cp = edges(columnValues.padding);\n const cb = borderEdges(columnValues.border);\n const colAvail = colWidth - cp.left - cp.right - cb.left - cb.right;\n\n const ip = edges(ctx.containerPadding ?? DEFAULT_CONTAINER_PADDING);\n return colAvail - ip.left - ip.right;\n}\n\nconst PERCENT = /^\\d+(?:\\.\\d+)?%$/;\n\n/** Round to 2 decimals, matching the editor's percent precision. */\nfunction round2(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\n/**\n * Convert a px display pin on an image `src` to the editor's canonical percent.\n *\n * Only touches a pinned image (`autoWidth === false`) whose `maxWidth` is a\n * px/number placeholder; a percent `maxWidth` is already canonical and is left\n * as-is, and a responsive image (`autoWidth !== false`) is untouched. A pin\n * wider than the slot clamps to 100%, mirroring the editor.\n */\nexport function pinImageSrc<T extends Record<string, any> | undefined>(\n src: T,\n availableWidth: number | undefined\n): T {\n if (!src || typeof src !== \"object\") return src;\n if ((src as Record<string, any>).autoWidth !== false) return src;\n\n const maxWidth = (src as Record<string, any>).maxWidth;\n if (typeof maxWidth === \"string\" && PERCENT.test(maxWidth.trim())) return src;\n\n const pinPx = toPx(maxWidth);\n if (pinPx == null) return src;\n\n const avail = availableWidth && availableWidth > 0 ? availableWidth : undefined;\n const pct = avail ? (pinPx >= avail ? 100 : round2((pinPx / avail) * 100)) : 100;\n\n return { ...src, autoWidth: false, maxWidth: `${pct}%` } as T;\n}\n","import type { RenderMode } from \"./types\";\n\nexport interface HeadConfig {\n hasFeature?: (featureName: string) => boolean;\n getInitialValues?: (containerType: string) => Record<string, any>;\n}\n\nexport interface UnlayerConfig {\n cdnBaseUrl: string;\n toSafeHtml?: (text: string, options?: any) => string;\n textDirection?: string;\n mergeTagState?: Record<string, any>;\n mode?: RenderMode;\n headConfig?: HeadConfig;\n}\n\nexport const DEFAULT_CONFIG: UnlayerConfig = {\n cdnBaseUrl: \"https://cdn.tools.unlayer.com\",\n mode: \"web\",\n};\n","/**\n * Column Layouts - All 8 supported column combinations from Unlayer Editor\n *\n * These layouts provide a structured and type-safe way to specify column\n * configurations that match exactly what the Unlayer editor supports.\n *\n * Usage:\n * import { ColumnLayouts } from '@unlayer-internal/shared-elements';\n * <Row layout={ColumnLayouts.TwoEqual}>\n * <Column>...</Column>\n * <Column>...</Column>\n * </Row>\n */\n\nexport interface ColumnLayout {\n name: string;\n description: string;\n cells: number[];\n expectedColumns: number;\n widths: string[]; // e.g., [\"50%\", \"50%\"]\n}\n\nexport const ColumnLayouts = {\n OneColumn: {\n name: 'OneColumn',\n description: 'One full column (100%)',\n cells: [1],\n expectedColumns: 1,\n widths: ['100%'],\n } as ColumnLayout,\n\n TwoEqual: {\n name: 'TwoEqual',\n description: 'Two equal columns (50% + 50%)',\n cells: [1, 1],\n expectedColumns: 2,\n widths: ['50%', '50%'],\n } as ColumnLayout,\n\n TwoWideNarrow: {\n name: 'TwoWideNarrow',\n description: 'Two columns: wide + narrow (67% + 33%)',\n cells: [2, 1],\n expectedColumns: 2,\n widths: ['66.67%', '33.33%'],\n } as ColumnLayout,\n\n TwoNarrowWide: {\n name: 'TwoNarrowWide',\n description: 'Two columns: narrow + wide (33% + 67%)',\n cells: [1, 2],\n expectedColumns: 2,\n widths: ['33.33%', '66.67%'],\n } as ColumnLayout,\n\n ThreeEqual: {\n name: 'ThreeEqual',\n description: 'Three equal columns (33% + 33% + 33%)',\n cells: [1, 1, 1],\n expectedColumns: 3,\n widths: ['33.33%', '33.33%', '33.33%'],\n } as ColumnLayout,\n\n ThreeNarrowWideNarrow: {\n name: 'ThreeNarrowWideNarrow',\n description: 'Three columns: narrow + wide + narrow (25% + 50% + 25%)',\n cells: [1, 2, 1],\n expectedColumns: 3,\n widths: ['25%', '50%', '25%'],\n } as ColumnLayout,\n\n FourEqual: {\n name: 'FourEqual',\n description: 'Four equal columns (25% + 25% + 25% + 25%)',\n cells: [1, 1, 1, 1],\n expectedColumns: 4,\n widths: ['25%', '25%', '25%', '25%'],\n } as ColumnLayout,\n\n FiveEqual: {\n name: 'FiveEqual',\n description: 'Five equal columns (20% + 20% + 20% + 20% + 20%)',\n cells: [1, 1, 1, 1, 1],\n expectedColumns: 5,\n widths: ['20%', '20%', '20%', '20%', '20%'],\n } as ColumnLayout,\n};\n\n// Export the layout type for strict typing\nexport type ValidColumnLayout = (typeof ColumnLayouts)[keyof typeof ColumnLayouts];\n\n/**\n * Validates that a layout has the correct number of Column components\n */\nexport function validateColumnLayout(layout: ColumnLayout, childrenCount: number): void {\n if (layout.expectedColumns !== childrenCount) {\n throw new Error(`${layout.name} layout expects ${layout.expectedColumns} <Column> components, but got ${childrenCount}. Layout: ${layout.description}. Make sure you have exactly ${layout.expectedColumns} <Column> children.`);\n }\n}\n","/**\n * Lexical Helpers for Text JSON Conversion\n *\n * Utilities to convert between plain text, Lexical JSON, and HTML.\n * HTML generation is done via direct JSON tree walking — no Lexical\n * headless editor or DOM required.\n */\n\n/**\n * Empty Lexical JSON structure (used as fallback).\n * Uses extended-paragraph type for Unlayer editor compatibility.\n */\nexport const EMPTY_TEXT_JSON =\n '{\"root\":{\"children\":[{\"children\":[],\"format\":\"\",\"indent\":0,\"type\":\"extended-paragraph\",\"version\":1,\"textFormat\":0,\"textStyle\":\"\"}],\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}';\n\n/**\n * Create Lexical JSON for plain text.\n *\n * Builds the JSON string directly to match the Unlayer editor's\n * ExtendedTextNode / ExtendedParagraphNode serialization format.\n *\n * @param text - Plain text string\n * @returns Lexical JSON string\n *\n * @example\n * ```ts\n * const json = textToTextJson(\"Hello world\");\n * ```\n */\nexport function textToTextJson(text: string): string {\n if (!text) return EMPTY_TEXT_JSON;\n\n const escaped = JSON.stringify(text); // handles quotes/newlines in text\n return `{\"root\":{\"children\":[{\"children\":[{\"detail\":0,\"format\":0,\"mode\":\"normal\",\"style\":\"\",\"text\":${escaped},\"type\":\"extended-text\",\"version\":1}],\"format\":\"\",\"indent\":0,\"type\":\"extended-paragraph\",\"version\":1,\"textFormat\":0,\"textStyle\":\"\"}],\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}`;\n}\n\n// ── Lexical format bitmask → HTML tag mapping ────────────────────────────────\n// Lexical encodes inline formatting in a numeric `format` bitmask on text nodes.\nconst FORMAT_TAGS: Array<[number, string, string]> = [\n [1, \"<strong>\", \"</strong>\"], // bold\n [2, \"<em>\", \"</em>\"], // italic\n [4, \"<s>\", \"</s>\"], // strikethrough\n [8, \"<u>\", \"</u>\"], // underline\n [16, \"<code>\", \"</code>\"], // code\n [32, \"<sub>\", \"</sub>\"], // subscript\n [64, \"<sup>\", \"</sup>\"], // superscript\n];\n\n/**\n * Escape HTML special characters in text content.\n */\nfunction escapeHtml(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n\n/**\n * Convert a Lexical text node to HTML, applying format bitmask.\n */\nfunction textNodeToHtml(node: any): string {\n let html = escapeHtml(node.text || \"\");\n\n // Apply inline style attribute if present\n const style = node.style;\n\n // Wrap in format tags (innermost first)\n const format = node.format || 0;\n let openTags = \"\";\n let closeTags = \"\";\n for (const [bit, open, close] of FORMAT_TAGS) {\n if (format & bit) {\n openTags += open;\n closeTags = close + closeTags;\n }\n }\n html = openTags + html + closeTags;\n\n // Wrap in <span> if inline style is present\n if (style) {\n html = `<span style=\"${escapeHtml(style)}\">${html}</span>`;\n }\n\n return html;\n}\n\n/**\n * Convert a Lexical JSON node (and its children) to HTML.\n * Handles: root, paragraph, heading, text, link, list, listitem, linebreak.\n */\nfunction nodeToHtml(node: any): string {\n if (!node || typeof node !== \"object\") return \"\";\n\n const type = node.type;\n\n // Leaf: text node\n if (type === \"text\" || type === \"extended-text\") {\n return textNodeToHtml(node);\n }\n\n // Leaf: line break\n if (type === \"linebreak\") {\n return \"<br>\";\n }\n\n // Recurse into children\n const childrenHtml = (node.children || []).map(nodeToHtml).join(\"\");\n\n switch (type) {\n case \"root\":\n return childrenHtml;\n\n case \"paragraph\":\n case \"extended-paragraph\": {\n if (!childrenHtml) return \"<p><br></p>\";\n const dir = node.direction ? ` dir=\"${node.direction}\"` : \"\";\n return `<p${dir}>${childrenHtml}</p>`;\n }\n\n case \"heading\": {\n const tag = node.tag || \"h1\"; // h1-h6\n const dir = node.direction ? ` dir=\"${node.direction}\"` : \"\";\n return `<${tag}${dir}>${childrenHtml}</${tag}>`;\n }\n\n case \"link\": {\n const href = node.url ? ` href=\"${escapeHtml(node.url)}\"` : \"\";\n const target = node.target ? ` target=\"${escapeHtml(node.target)}\"` : \"\";\n const rel = node.rel ? ` rel=\"${escapeHtml(node.rel)}\"` : \"\";\n return `<a${href}${target}${rel}>${childrenHtml}</a>`;\n }\n\n case \"list\": {\n const tag = node.listType === \"number\" ? \"ol\" : \"ul\";\n return `<${tag}>${childrenHtml}</${tag}>`;\n }\n\n case \"listitem\":\n return `<li>${childrenHtml}</li>`;\n\n default:\n // Unknown node type — pass through children\n return childrenHtml;\n }\n}\n\n/**\n * Convert Lexical JSON to HTML.\n *\n * Walks the JSON tree directly — no Lexical headless editor or DOM required.\n * Works identically in Node.js and browser environments.\n *\n * @param textJson - Lexical JSON string\n * @returns HTML string\n *\n * @example\n * ```ts\n * const html = generateHtmlFromTextJson('{\"root\":...}');\n * ```\n */\nexport function generateHtmlFromTextJson(textJson: string): string {\n if (!textJson) return \"\";\n\n try {\n const parsed = JSON.parse(textJson);\n\n // Raw HTML passthrough (produced by htmlToTextJson)\n if (parsed.__html) return parsed.__html;\n\n // Walk the Lexical JSON tree and produce HTML\n return nodeToHtml(parsed.root);\n } catch {\n return \"\";\n }\n}\n\n/**\n * Convert an HTML string to a textJson-compatible value.\n *\n * Wraps the HTML in a passthrough format that `generateHtmlFromTextJson`\n * detects and returns directly — avoiding the Lexical headless editor\n * round-trip (HTML → Lexical JSON → HTML) which doesn't work reliably\n * in browser environments.\n *\n * Supports any HTML formatting: bold, italic, underline, strikethrough,\n * code, links, lists, etc.\n *\n * @param html - HTML string with formatting (e.g. `\"Hello <b>bold</b>\"`)\n * @returns JSON string compatible with Paragraph's `textJson` prop\n *\n * @example\n * ```ts\n * const json = htmlToTextJson('Hello <b>world</b> and <a href=\"https://example.com\">link</a>');\n * ```\n */\nexport function htmlToTextJson(html: string): string {\n if (!html) return EMPTY_TEXT_JSON;\n return JSON.stringify({ __html: html });\n}\n","/**\n * Deep-merge user values with defaults.\n * Plain objects are merged recursively; arrays and primitives\n * from userValues override the default entirely.\n */\nexport function mergeValues<T extends Record<string, any>>(\n defaults: T,\n userValues?: Partial<T>\n): T {\n if (!userValues) return defaults;\n\n const result: any = { ...defaults };\n\n for (const key of Object.keys(userValues)) {\n const userVal = (userValues as any)[key];\n const defaultVal = (defaults as any)[key];\n\n if (\n userVal !== null &&\n defaultVal !== null &&\n typeof userVal === \"object\" &&\n typeof defaultVal === \"object\" &&\n !Array.isArray(userVal) &&\n !Array.isArray(defaultVal)\n ) {\n // Recursively merge plain objects\n result[key] = mergeValues(defaultVal, userVal);\n } else {\n result[key] = userVal;\n }\n }\n\n return result as T;\n}\n","/**\n * Universal Semantic Props System\n *\n * Automatically flattens nested properties for ALL components\n * No build-time generation needed - pure TypeScript + runtime detection\n *\n * Example:\n * - ButtonValues has: { buttonColors: { color, backgroundColor }, fontSize }\n * - Users can pass: { color: \"red\", backgroundColor: \"blue\" } OR { buttonColors: { color: \"red\" } }\n * - TypeScript provides autocomplete for ALL properties (flat and nested)\n */\n\nimport { textToTextJson, htmlToTextJson } from \"./lexical-helpers\";\n\n/**\n * Type utility: Extracts all properties from nested objects\n * This provides TypeScript autocomplete for flat props!\n */\ntype FlattenObjectProps<T> = T extends object\n ? {\n [K in keyof T]?: T[K] extends object\n ? T[K] | FlattenObjectProps<T[K]> // Accept nested OR its flattened props\n : T[K];\n } & {\n // Also accept all nested object properties as flat props\n [K in keyof T as T[K] extends object\n ? keyof T[K] extends string\n ? keyof T[K]\n : never\n : never]?: any;\n }\n : T;\n\n/**\n * Semantic props type for any component.\n * Generic TChildren parameter allows each framework to supply its own child type.\n */\nexport type SemanticProps<T, TChildren = any> = FlattenObjectProps<T> & {\n children?: TChildren;\n values?: T; // Escape hatch for full control\n /** HTML string with inline formatting for Paragraph (e.g. `'Hello <b>bold</b>'`) */\n html?: string;\n};\n\n/**\n * Runtime detection of nested object structures\n * Analyzes default values to identify which properties are nested objects.\n * Results are cached per defaultValues object reference to avoid recomputing\n * on every render.\n */\nconst nestedStructureCache = new WeakMap<object, Map<string, Set<string>>>();\n\nfunction analyzeNestedStructure(defaultValues: any): Map<string, Set<string>> {\n const cached = nestedStructureCache.get(defaultValues);\n if (cached) return cached;\n\n const nestedGroups = new Map<string, Set<string>>();\n\n for (const [key, value] of Object.entries(defaultValues)) {\n // Skip special keys\n if (key === \"_meta\" || key === \"text\" || key === \"textJson\" || key === \"children\") {\n continue;\n }\n\n // Check if this is a nested object (plain object, not array, not null)\n if (\n value &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n Object.keys(value).length > 0\n ) {\n const props = new Set(Object.keys(value));\n nestedGroups.set(key, props);\n }\n }\n\n nestedStructureCache.set(defaultValues, nestedGroups);\n return nestedGroups;\n}\n\n/**\n * Coerce CSS-idiom flat prop values to the shapes the exporters expect.\n * Mutates the given props object in place. Each rule fixes a footgun where the\n * natural/CSS form type-checks (flat props are loosely typed) but renders blank\n * or invalid:\n * - `fontFamily: \"Arial\"` → `{ label, value }` (a bare string is otherwise\n * char-spread when merged into the fontFamily group, dropping the font).\n * - `fontWeight: \"700\"` → `700` (numeric string → number; keyword strings like\n * \"bold\"/\"normal\" are valid CSS and left as-is).\n * - `fontSize: 28` → `\"28px\"` (a unitless number is invalid CSS the browser\n * ignores). Same for other bare-number size fields.\n * - `lineHeight: 1.4` → `\"1.4\"` (the field is typed as a string; unitless\n * line-height is valid CSS).\n */\nconst PX_SIZE_KEYS = [\n \"fontSize\",\n \"padding\",\n \"containerPadding\",\n \"borderRadius\",\n \"letterSpacing\",\n] as const;\n\nfunction normalizeCssProps(props: Record<string, any>): void {\n if (typeof props.fontFamily === \"string\") {\n const v = props.fontFamily;\n props.fontFamily = { label: v, value: v };\n }\n if (\n typeof props.fontWeight === \"string\" &&\n /^\\d+$/.test(props.fontWeight.trim())\n ) {\n props.fontWeight = Number(props.fontWeight.trim());\n }\n if (typeof props.lineHeight === \"number\") {\n props.lineHeight = String(props.lineHeight);\n }\n for (const key of PX_SIZE_KEYS) {\n const v = props[key];\n // bare number (28) or a unit-less numeric string (\"0\", \"20\") → \"<n>px\"\n if (typeof v === \"number\") {\n props[key] = `${v}px`;\n } else if (typeof v === \"string\" && /^\\d+$/.test(v.trim())) {\n props[key] = `${v.trim()}px`;\n }\n }\n}\n\n/**\n * Flatten a JSX/ReactNode children tree to its plain text content.\n * Text components store a string (or Lexical JSON derived from one); a raw React\n * element passed as children would otherwise stringify to \"[object Object]\".\n * Duck-types the element shape (`.props.children`) so this stays framework-free.\n * Inline formatting is not preserved — use the `html` prop for rich text.\n */\nfunction flattenChildrenText(node: any): string {\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\") return node;\n if (typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(flattenChildrenText).join(\"\");\n if (typeof node === \"object\" && \"props\" in node) {\n return flattenChildrenText(node.props?.children);\n }\n return \"\";\n}\n\n/**\n * Universal semantic props mapper\n * Works for ANY component - no configuration needed!\n *\n * @param props - User props (can include flat or nested properties)\n * @param defaultValues - Component default values (used to detect structure)\n * @param componentType - Component name (for special handling like Paragraph)\n * @returns Properly structured values object for exporter\n */\nexport function mapSemanticProps<T extends Record<string, any>>(\n props: SemanticProps<T>,\n defaultValues: T,\n componentType: string\n): T {\n const { children, values, ...restProps } = props;\n const userProps: any = { ...restProps };\n\n // Start with escape hatch if provided\n const result: any = values ? { ...values } : {};\n\n // Handle children → text/textJson conversion\n // Paragraph uses textJson (Lexical JSON); all others use text (plain string)\n // Note: editor-types codegen renamed text→textJson for Button/Heading but\n // the exporter still uses plain text at runtime via generateHtmlFromTextJson\n if (children !== undefined && !result.text && !result.textJson) {\n const textContent =\n typeof children === \"string\" ? children : flattenChildrenText(children);\n if (componentType === \"Paragraph\") {\n result.textJson = textToTextJson(textContent);\n } else {\n result.text = textContent;\n }\n }\n\n // Paragraph: auto-convert `text` → `textJson` (Lexical JSON)\n // This allows Paragraph to accept the same `text` field as Heading/Button,\n // making it a drop-in replacement for the legacy Text component.\n // - values.text (escape hatch) = legacy HTML → use htmlToTextJson (preserves HTML)\n // - text prop (API) = plain text → use textToTextJson (wraps in Lexical JSON)\n const textFromEscapeHatch = result.text;\n const textFromProp = userProps.text;\n const textProp = textFromEscapeHatch || textFromProp;\n if (componentType === \"Paragraph\" && textProp && !result.textJson) {\n result.textJson = textFromEscapeHatch\n ? htmlToTextJson(String(textProp))\n : textToTextJson(String(textProp));\n delete result.text;\n delete userProps.text;\n }\n\n // Paragraph: convert `html` (rich HTML string) → `textJson` (Lexical JSON)\n // Supports both: <Paragraph html=\"...\" /> and <Paragraph values={{ html: \"...\" }} />\n const htmlProp = userProps.html || result.html;\n if (componentType === \"Paragraph\" && htmlProp && !result.textJson) {\n result.textJson = htmlToTextJson(String(htmlProp));\n delete userProps.html;\n delete result.html;\n }\n\n // String shorthand for link/action fields (`href=\"https://...\"` or\n // `action=\"https://...\"`) → wrap into the schema's storage shape so that\n // the rest of the pipeline (mergeValues, renderToJson) sees a consistent\n // type. The render-time exporter handoff later resolves this into the\n // exporter's `{ url, target }` shape via `normalizeValuesForExporter`.\n for (const key of [\"href\", \"action\"] as const) {\n const v = userProps[key];\n if (typeof v === \"string\") {\n userProps[key] = {\n name: \"web\",\n values: { href: v, target: \"_blank\" },\n };\n }\n }\n\n // Normalize CSS-idiom prop values to the shapes the exporters expect. Authors\n // (humans and AI) reach for CSS habits — a string `fontFamily`, a numeric\n // `fontSize`, a string `fontWeight` — which type-check (flat props are loose)\n // but otherwise render blank or invalid. Coercing the natural form here makes\n // it render correctly. Applied to flat props only; the `values` escape hatch\n // is the full-control path and is left untouched.\n normalizeCssProps(userProps);\n\n // Analyze default values to detect nested object structure\n const nestedGroups = analyzeNestedStructure(defaultValues);\n\n // Separate flat props from potential nested props\n const nested: Record<string, any> = {};\n const flat: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(userProps)) {\n if (value === undefined) continue;\n\n // Check if user already provided a nested object\n if (nestedGroups.has(key)) {\n // User passed the nested object directly\n nested[key] = value;\n continue;\n }\n\n // Check if this prop belongs to any nested group\n let belongsToGroup = false;\n for (const [groupName, groupProps] of nestedGroups.entries()) {\n if (groupProps.has(key)) {\n // This flat prop should be grouped\n nested[groupName] = nested[groupName] || {};\n nested[groupName][key] = value;\n belongsToGroup = true;\n break;\n }\n }\n\n if (!belongsToGroup) {\n // Regular flat prop\n flat[key] = value;\n }\n }\n\n // Merge everything: escape hatch < flat props < nested groups\n const final: any = {\n ...result,\n ...flat\n };\n\n // Merge nested groups (preserve existing from escape hatch)\n for (const [groupName, groupValues] of Object.entries(nested)) {\n if (Object.keys(groupValues).length > 0) {\n final[groupName] = {\n ...result[groupName],\n ...groupValues\n };\n }\n }\n\n // Some components (e.g. Column) ship an empty `border: {}` default, so the\n // nested-group detector can't see the border sub-keys and flat border-side\n // props (borderTopWidth, …) would land loose and be dropped by the exporter.\n // If the component declares a `border` field, gather them into it.\n if (\n defaultValues &&\n typeof defaultValues === \"object\" &&\n \"border\" in (defaultValues as object)\n ) {\n const borderSideRe = /^border(Top|Right|Bottom|Left)(Width|Style|Color)$/;\n const collected: Record<string, any> = {};\n for (const key of Object.keys(final)) {\n if (borderSideRe.test(key)) {\n collected[key] = final[key];\n delete final[key];\n }\n }\n if (Object.keys(collected).length > 0) {\n final.border = { ...(final.border || {}), ...collected };\n }\n }\n\n return final as T;\n}\n\n/**\n * Convert any of the three link-shaped inputs into the render-value shape\n * the exporter expects: `{ url, target, ...customAttrs }`.\n *\n * The schema stores links as `{ name, values: { href, target } }`, but\n * exporters (consumed via @unlayer/exporters) expect the editor's render\n * value shape `{ url, target, customAttrs?, class?, onClick? }`. The editor\n * runs this conversion via the link property-editor's `renderValue()` —\n * `normalizeValuesForExporter` (in render-time code) mirrors it so React\n * rendered output matches.\n *\n * Accepted inputs:\n * - `\"https://...\"` (string shorthand)\n * - `{ url, target?, customAttrs?, class?, onClick? }` (already render shape)\n * - `{ name, values: { href, target? }, attrs? }` (storage shape from schema)\n *\n * Returns `undefined` for shapes we don't recognize so the caller can fall\n * back to the original value (avoids silently dropping data).\n *\n * IMPORTANT: this is render-time only. Do NOT apply during renderToJson —\n * JSON output is for round-tripping into the editor, which expects the\n * storage shape.\n */\nexport function normalizeLinkValue(value: unknown): Record<string, any> | undefined {\n if (value == null) return undefined;\n if (typeof value === \"string\") {\n return { url: value, target: \"_blank\" };\n }\n if (typeof value !== \"object\") return undefined;\n const v = value as Record<string, any>;\n // Already render-shape (has url) — pass through.\n if (\"url\" in v) return v;\n // Storage shape from the schema: { name, values: { href, target } }.\n if (\"name\" in v && v.values && typeof v.values === \"object\") {\n const inner = v.values as Record<string, any>;\n return {\n url: inner.href ?? \"\",\n target: inner.target ?? \"_blank\",\n ...(v.attrs ?? {}),\n };\n }\n return undefined;\n}\n\n/**\n * Normalize all link/action fields on an item's values to the render-value\n * shape the exporter reads. Returns a shallow clone — does not mutate.\n *\n * Knows about the link-bearing paths per component:\n * - top-level `href` (Button, Video)\n * - top-level `action` (Image, Timer)\n * - `menu.items[].link` (Menu)\n *\n * Only the bridge between mapper and exporter should call this; renderToJson\n * must NOT, because JSON output preserves storage shape.\n */\nexport function normalizeValuesForExporter<T extends Record<string, any>>(\n values: T,\n componentName: string\n): T {\n if (values == null || typeof values !== \"object\") return values;\n\n const out: Record<string, any> = { ...values };\n\n // Top-level link fields used by Button (href), Image (action), Video (href),\n // Timer (action). Cheap to check both keys for every component.\n for (const key of [\"href\", \"action\"]) {\n if (out[key] !== undefined) {\n const normalized = normalizeLinkValue(out[key]);\n if (normalized !== undefined) out[key] = normalized;\n }\n }\n\n // Menu items each carry a `link` field.\n if (componentName === \"Menu\" && out.menu && Array.isArray(out.menu.items)) {\n out.menu = {\n ...out.menu,\n items: out.menu.items.map((item: any) => {\n if (!item || item.link === undefined) return item;\n const normalized = normalizeLinkValue(item.link);\n if (normalized === undefined) return item;\n return { ...item, link: normalized };\n }),\n };\n }\n\n return out as T;\n}\n","/**\n * HTML to Plain Text Converter\n *\n * Pure regex-based HTML-to-text conversion — no DOM dependency.\n * Works in Node.js, edge runtimes, and browsers.\n *\n * Critical for email deliverability: spam filters penalize HTML-only emails.\n */\n\n/**\n * Common HTML entity map for decoding.\n */\nconst HTML_ENTITIES: Record<string, string> = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n \""\": '\"',\n \"'\": \"'\",\n \"'\": \"'\",\n \" \": \" \",\n \"—\": \"—\",\n \"–\": \"–\",\n \"«\": \"«\",\n \"»\": \"»\",\n \"•\": \"•\",\n \"·\": \"·\",\n \"…\": \"…\",\n \"©\": \"©\",\n \"®\": \"®\",\n \"™\": \"™\",\n};\n\n/**\n * Decode HTML entities (named and numeric).\n */\nfunction decodeEntities(text: string): string {\n // Named entities\n let result = text.replace(/&\\w+;/g, (match) => HTML_ENTITIES[match] ?? match);\n\n // Numeric entities: { and \n result = result.replace(/&#(\\d+);/g, (_, code) =>\n String.fromCharCode(parseInt(code, 10))\n );\n result = result.replace(/&#x([0-9a-fA-F]+);/g, (_, code) =>\n String.fromCharCode(parseInt(code, 16))\n );\n\n return result;\n}\n\n/**\n * Convert an HTML string to readable plain text.\n *\n * @param html - HTML string to convert\n * @returns Plain text representation\n *\n * @example\n * ```ts\n * import { htmlToPlainText } from \"@unlayer-internal/shared-elements\";\n *\n * const text = htmlToPlainText(\"<h1>Hello</h1><p>World</p>\");\n * // \"HELLO\\nWorld\"\n * ```\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return \"\";\n\n let text = html;\n\n // 1. Remove elements marked with data-skip-in-text (preview div, etc.)\n text = text.replace(/<[^>]+data-skip-in-text=\"true\"[^>]*>[\\s\\S]*?<\\/[^>]+>/gi, \"\");\n\n // 2. Remove <head>, <style>, <script> blocks entirely\n text = text.replace(/<head[\\s\\S]*?<\\/head>/gi, \"\");\n text = text.replace(/<style[\\s\\S]*?<\\/style>/gi, \"\");\n text = text.replace(/<script[\\s\\S]*?<\\/script>/gi, \"\");\n\n // 3. Convert headings: h1-h2 → UPPERCASE, h3-h6 → as-is\n text = text.replace(/<h[12][^>]*>([\\s\\S]*?)<\\/h[12]>/gi, (_, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n return \"\\n\" + clean.toUpperCase() + \"\\n\";\n });\n text = text.replace(/<h[3-6][^>]*>([\\s\\S]*?)<\\/h[3-6]>/gi, (_, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n return \"\\n\" + clean + \"\\n\";\n });\n\n // 4. Convert links: <a href=\"url\">text</a> → text (url)\n text = text.replace(/<a[^>]+href=[\"']([^\"']+)[\"'][^>]*>([\\s\\S]*?)<\\/a>/gi, (_, href, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n // Skip if link text is the same as URL (avoid duplication)\n if (clean === href || clean === decodeEntities(href)) {\n return clean;\n }\n return `${clean} (${href})`;\n });\n\n // 5. Convert images: <img alt=\"text\"> → [text]\n text = text.replace(/<img[^>]+alt=[\"']([^\"']+)[\"'][^>]*\\/?>/gi, (_, alt) => {\n return `[${alt}]`;\n });\n // Remove images without alt text\n text = text.replace(/<img[^>]*\\/?>/gi, \"\");\n\n // 6. Convert horizontal rules\n text = text.replace(/<hr[^>]*\\/?>/gi, \"\\n---\\n\");\n\n // 7. Convert list items\n text = text.replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, (_, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n return \"- \" + clean + \"\\n\";\n });\n\n // 8. Convert <br> tags\n text = text.replace(/<br\\s*\\/?>/gi, \"\\n\");\n\n // 9. Convert block-level closing tags to newlines\n text = text.replace(/<\\/(?:p|div|tr|blockquote|section|article|header|footer|main|nav|aside)>/gi, \"\\n\");\n text = text.replace(/<\\/(?:ul|ol|table|thead|tbody|tfoot)>/gi, \"\\n\");\n\n // 10. Convert <td> and <th> to tab-separated values\n text = text.replace(/<\\/(?:td|th)>/gi, \"\\t\");\n\n // 11. Remove all remaining HTML tags\n text = text.replace(/<[^>]+>/g, \"\");\n\n // 12. Decode HTML entities\n text = decodeEntities(text);\n\n // 13. Clean up whitespace\n // Replace tabs with spaces\n text = text.replace(/\\t/g, \" \");\n // Collapse multiple spaces (but not newlines) into one\n text = text.replace(/[^\\S\\n]+/g, \" \");\n // Trim each line\n text = text\n .split(\"\\n\")\n .map((line) => line.trim())\n .join(\"\\n\");\n // Collapse 3+ consecutive newlines to 2\n text = text.replace(/\\n{3,}/g, \"\\n\\n\");\n // Trim leading/trailing whitespace\n text = text.trim();\n\n return text;\n}\n","/**\n * Universal Component Factory\n *\n * Eliminates boilerplate by creating components from configuration.\n * This factory handles all the repetitive logic that was duplicated\n * across Button, Heading, Paragraph, etc.\n */\n\nimport React from \"react\";\nimport type { ExporterName } from \"@unlayer/types\";\n\n/** Exporter map keyed by display mode. Defined locally until added to @unlayer/types. */\ntype ItemExporters = Partial<Record<ExporterName, (...args: any[]) => string>>;\nimport type { RenderMode, UnlayerConfig } from \"@unlayer-internal/shared-elements\";\nimport type { SizeInput } from \"../types\";\nimport { contentSlotWidth, pinImageSrc } from \"./image-sizing\";\nimport {\n mergeValues,\n generateHtmlFromTextJson,\n normalizeValuesForExporter,\n DEFAULT_CONFIG,\n} from \"@unlayer-internal/shared-elements\";\n\n\n/**\n * Static property key for the hook-free render function.\n * Column calls this directly instead of the outer component\n * (which uses hooks and would break when called as a plain function).\n */\nexport const UNLAYER_RENDER_KEY = \"__unlayerRender\";\n\n/**\n * Static property key for the item's config (name, defaultValues, propMapper).\n * Used by renderToJson to extract values without rendering to HTML.\n */\nexport const UNLAYER_CONFIG_KEY = \"__unlayerItemConfig\";\n\n/**\n * Base props that all item components support\n */\nexport interface BaseItemComponentProps {\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n mode?: RenderMode;\n /** Padding of the content wrapper around this item — a number (→ px) or a CSS\n * string (\"10px\", \"16px 24px\"). Applied by the containing Column. */\n containerPadding?: SizeInput;\n\n // Internal props (for advanced use)\n index?: number;\n colIndex?: number;\n cells?: any[];\n bodyValues?: any;\n rowValues?: any;\n /** @internal - this column's values, threaded by Column for width-aware exporters */\n columnValues?: any;\n /** @internal - Unlayer config threaded from UnlayerProvider */\n _config?: UnlayerConfig;\n}\n\n/**\n * Configuration for creating an item component\n */\nexport interface ItemComponentConfig<TValues, TSemanticProps> {\n /** Component name (e.g., 'Button', 'Heading') */\n name: string;\n\n /** Default values for the component */\n defaultValues: TValues;\n\n /** Function to map semantic props to values format */\n propMapper: (\n props: TSemanticProps & { children?: React.ReactNode }\n ) => Partial<TValues>;\n\n /** Display name for React DevTools */\n displayName?: string;\n\n /** Per-component exporters map — enables tree-shaking.\n * Keys are display modes ('web', 'email', 'document'), values are exporter functions. */\n exporters: ItemExporters;\n}\n\n/**\n * Props type that combines base props with semantic props\n */\nexport type ItemComponentProps<TSemanticProps> = BaseItemComponentProps &\n TSemanticProps;\n\n// ============================================\n// Internal: rendering helpers (merged from render-component.tsx)\n// ============================================\n\ninterface ErrorFallbackProps {\n type: string;\n error: Error;\n className?: string;\n style?: React.CSSProperties;\n}\n\n/** Error fallback component shown when an exporter throws. */\nconst ErrorFallback: React.FC<ErrorFallbackProps> = ({\n type,\n className,\n style\n}) => (\n <div className={className} style={style}>\n <div\n style={{\n padding: \"20px\",\n backgroundColor: \"#fee\",\n border: \"1px solid #fcc\",\n borderRadius: \"4px\",\n color: \"#c33\",\n textAlign: \"center\",\n fontFamily: \"system-ui, sans-serif\"\n }}\n >\n <strong>{type} failed to render.</strong>\n <br />\n <small>Check console for details.</small>\n </div>\n </div>\n);\n\ninterface RenderConfig<T = any> {\n type: string;\n values: T;\n mode: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n args?: any[];\n /** Column/body context merged into the exporter `meta` (8th arg). */\n metaContext?: Record<string, any>;\n innerHTML?: string;\n _config?: UnlayerConfig;\n exporter: Function;\n}\n\n/**\n * Allocate the next unique HTML id for a prefix, scoped to one render.\n * Counters live on the threaded `_config` (`__ids`), which Body resets per\n * render — so renderToHtml produces unique ids (u_row_1, u_row_2, …) like the\n * editor and like renderToJson, instead of resetting per row. Falls back to\n * `${prefix}_1` when rendered standalone (no _config).\n */\nexport function nextHtmlId(config: any, prefix: string): string {\n if (!config) return `${prefix}_1`;\n const ids: Record<string, number> = (config.__ids ??= {});\n ids[prefix] = (ids[prefix] || 0) + 1;\n return `${prefix}_${ids[prefix]}`;\n}\n\n/** Add _meta fields if not present. */\nfunction ensureMeta(values: any, type: string, index: number = 0): any {\n return {\n ...values,\n _meta: {\n htmlID: `u_content_${type.toLowerCase()}_${index + 1}`,\n htmlClassNames: `u_content_${type.toLowerCase()}`,\n ...(values._meta || {})\n }\n };\n}\n\n/**\n * Render a component by calling its exporter and wrapping the HTML output.\n * Handles error boundaries, exporterConfig construction, and container vs item calling conventions.\n */\nfunction renderComponent<T = any>(config: RenderConfig<T>): JSX.Element {\n const { type, values, mode, className, style, args = [], innerHTML, _config, exporter, metaContext } = config;\n\n try {\n // Build exporterConfig from _config (falls back to defaults)\n const cfg = _config ?? DEFAULT_CONFIG;\n const exporterConfig = {\n generateHtmlFromTextJson,\n toSafeHtml: cfg.toSafeHtml,\n textDirection: cfg.textDirection,\n cdnBaseUrl: cfg.cdnBaseUrl,\n };\n\n // Call exporter with appropriate arguments\n let html: string;\n if (innerHTML !== undefined) {\n // Container components (Row, Body) take innerHTML first\n html = exporter(innerHTML, values, ...args);\n } else {\n // Content components take values first\n // Item exporters signature: (values, index, colIndex, cells, bodyValues, rowValues, embeddedValues, meta)\n // Args 2-7 are deprecated positional params; the 8th arg is a meta object with all context\n const meta = {\n exporterConfig,\n mergeTagState: cfg.mergeTagState,\n ...(metaContext ?? {}),\n };\n html = exporter(values, ...args, undefined, meta);\n }\n\n // Ensure string output\n html = typeof html === \"string\" ? html : String(html);\n\n // Return rendered component\n return (\n <div\n className={className}\n style={style}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n );\n } catch (error) {\n console.error(`${type} rendering failed:`, error);\n return (\n <ErrorFallback\n type={type}\n error={error as Error}\n className={className}\n style={style}\n />\n );\n }\n}\n\n// ============================================\n// Public API\n// ============================================\n\n/**\n * Create an item component (Button, Heading, Paragraph, etc.)\n *\n * This factory eliminates the ~100 lines of boilerplate code that was\n * duplicated across every item component.\n *\n * @example\n * ```tsx\n * const Button = createItemComponent({\n * name: \"Button\",\n * defaultValues: BUTTON_DEFAULTS,\n * propMapper: mapButtonProps,\n * displayName: \"Button\"\n * });\n * ```\n */\nexport function createItemComponent<\n TValues extends Record<string, any> = any,\n TSemanticProps = any\n>(\n config: ItemComponentConfig<TValues, TSemanticProps>\n): React.FC<ItemComponentProps<TSemanticProps>> {\n // Inner render function — no hooks, safe to call as a plain function (Column does this)\n function renderFn(\n props: ItemComponentProps<TSemanticProps>\n ): React.ReactElement | null {\n const {\n // Base props\n mode: modeProp,\n className,\n style,\n\n // Internal props\n index = 0,\n colIndex = 0,\n cells = [],\n bodyValues = {},\n rowValues = {},\n columnValues = {},\n _config,\n\n // Children\n children,\n\n // Rest are semantic props\n ...restProps\n } = props as ItemComponentProps<TSemanticProps>;\n\n // Resolve mode: explicit prop > _config > default\n const mode: RenderMode = modeProp ?? _config?.mode ?? \"web\";\n\n // 1. Map semantic props to values format (handles dual API)\n const mappedValues = config.propMapper({\n children,\n ...restProps\n } as TSemanticProps & { children?: React.ReactNode });\n\n // 2. Merge with defaults\n const finalValues = mergeValues(config.defaultValues, mappedValues);\n\n // 3. Ensure _meta is present\n const valuesWithMeta = ensureMeta(\n finalValues,\n config.name.toLowerCase(),\n index\n );\n\n // 4. Ensure bodyValues has a contentWidth. Default to the schema-shaped\n // \"500px\" (matches BodyDefaults.contentWidth and the exporter's image\n // fallback width), so a standalone item (no Body) sizes the same as the\n // editor and the value is a CSS string everywhere it might be consumed.\n const safeBodyValues = {\n contentWidth: \"500px\",\n ...bodyValues\n };\n\n // 5. Resolve link/action fields to the exporter's render-value shape.\n // Skipped on the renderToJson path (which uses propMapper directly)\n // so JSON output preserves the schema's storage shape.\n const valuesForExporter = normalizeValuesForExporter(\n valuesWithMeta as Record<string, any>,\n config.name\n );\n\n // 5b. Convert a fixed (px) image pin to the editor's canonical percent now\n // that the column geometry is known (Column threads columnValues/cells/\n // bodyValues). Guarded on `src.autoWidth === false`, so only pinned\n // images are touched; responsive images and non-image blocks pass through.\n const exportSrc = (valuesForExporter as Record<string, any>).src;\n if (exportSrc && typeof exportSrc === \"object\" && exportSrc.autoWidth === false) {\n const availableWidth = contentSlotWidth({\n bodyValues: safeBodyValues,\n rowValues,\n rowCells: cells,\n columnIndex: colIndex,\n columnValues,\n containerPadding:\n (props as { containerPadding?: unknown; values?: { containerPadding?: unknown } })\n .containerPadding ??\n (props as { values?: { containerPadding?: unknown } }).values?.containerPadding,\n });\n (valuesForExporter as Record<string, any>).src = pinImageSrc(exportSrc, availableWidth);\n }\n\n // 6. Resolve exporter for this mode (fallback to web)\n const exporter = (config.exporters[mode] || config.exporters.web)!;\n\n // 7. Render using utility (handles all boilerplate)\n return renderComponent<TValues>({\n type: config.name,\n values: valuesForExporter as TValues,\n mode,\n className,\n style,\n args: [index, colIndex, cells, safeBodyValues, rowValues],\n // The 8th arg the exporters actually read: column/body context for\n // width-aware rendering (Image's available-width calc), mirroring the editor.\n metaContext: {\n columnIndex: colIndex,\n columnValues,\n rowCells: cells,\n rowValues,\n bodyValues: safeBodyValues,\n },\n _config,\n exporter,\n });\n }\n\n // Outer React component — hook-free, works in both Server and Client Components\n const ItemComponent: React.FC<ItemComponentProps<TSemanticProps>> = (\n props\n ) => {\n return renderFn(props);\n };\n\n // Set display name for React DevTools\n ItemComponent.displayName = config.displayName || config.name;\n\n // Expose hook-free render for Column to call directly\n (ItemComponent as any)[UNLAYER_RENDER_KEY] = renderFn;\n\n // Expose config for renderToJson to extract values without HTML rendering\n (ItemComponent as any)[UNLAYER_CONFIG_KEY] = {\n name: config.name,\n defaultValues: config.defaultValues,\n propMapper: config.propMapper,\n };\n\n return ItemComponent;\n}\n","import { ButtonExporters, ButtonDefaults } from \"@unlayer/exporters\";\nimport type { ButtonValues, TextStyleProps, SizeInput, BorderInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Button semantic props — agent-friendly text/style types (replacing the loose\n * `any` flat props) plus a CSS-style `width` (number/px pins; \"100%\" full-width).\n */\ntype ButtonSemanticProps = Omit<\n SemanticProps<ButtonValues>,\n keyof TextStyleProps | \"width\" | \"padding\" | \"borderRadius\" | \"border\"\n> &\n TextStyleProps & {\n /** Display width — a number/px pins the button; \"100%\" makes it full-width. */\n width?: SizeInput;\n /** Inner padding — a number (→ px) or CSS string (\"14px 28px\"). */\n padding?: SizeInput;\n /** Corner radius — a number (→ px) or CSS string (\"8px\", \"500px\"). */\n borderRadius?: SizeInput;\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n };\n\n/**\n * Button Component Props\n * Automatically provides autocomplete for ALL properties (flat and nested)\n */\nexport interface ButtonProps extends ItemComponentProps<ButtonSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific additions\nconst DEFAULT_VALUES = {\n ...ButtonDefaults,\n text: \"Button\", // React convenience — not in schema\n} as unknown as ButtonValues;\n\n/**\n * Button - Universal SSR/Client Component with Automatic Semantic Props\n *\n * ✅ TypeScript provides autocomplete for ALL props (flat and nested)\n * ✅ Works for any nested structure - no configuration needed\n * ✅ Escape hatch: values prop for full control\n * ✅ Works on both server and client\n *\n * @example Flat Props (Simple - most common)\n * ```tsx\n * <Button color=\"white\" backgroundColor=\"#3b82f6\" fontSize=\"16px\">\n * Click me\n * </Button>\n * ```\n *\n * @example Advanced (per-side borders)\n * ```tsx\n * <Button\n * backgroundColor=\"blue\"\n * borderTopColor=\"red\"\n * borderTopWidth=\"2px\"\n * borderBottomWidth=\"0px\"\n * >\n * Click me\n * </Button>\n * ```\n *\n * @example Nested Objects (full control)\n * ```tsx\n * <Button\n * buttonColors={{ backgroundColor: \"#3b82f6\", hoverBackgroundColor: \"#2563eb\" }}\n * border={{ borderTopWidth: \"2px\" }}\n * >\n * Click me\n * </Button>\n * ```\n */\nconst Button = createItemComponent<ButtonValues, ButtonSemanticProps>({\n name: \"Button\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const mapped = mapSemanticProps(\n props as SemanticProps<ButtonValues>,\n DEFAULT_VALUES,\n \"Button\"\n );\n // In Unlayer's model a button's display width is size.width, used only when\n // size.autoWidth is false (otherwise the width is auto / content-sized). So a\n // user-provided width sets autoWidth:false. Read the MAPPED size, which\n // already includes the flat prop, the nested prop, AND the `values` escape\n // hatch; mapSemanticProps does not inject the schema default, so a present\n // size.width means the user set it. Honor an explicit autoWidth.\n const size = (mapped as { size?: unknown }).size;\n if (size && typeof size === \"object\" && !Array.isArray(size)) {\n const s = size as { width?: unknown; autoWidth?: unknown };\n // width accepts a number per SizeInput, but the exporter wants a CSS\n // string — coerce a bare number / unit-less numeric string to px.\n if (typeof s.width === \"number\") {\n s.width = `${s.width}px`;\n } else if (typeof s.width === \"string\" && /^\\d+(?:\\.\\d+)?$/.test(s.width.trim())) {\n s.width = `${s.width.trim()}px`;\n }\n if (s.width !== undefined && s.autoWidth === undefined) {\n s.autoWidth = false;\n }\n }\n return mapped;\n },\n displayName: \"Button\",\n exporters: ButtonExporters,\n});\n\nexport default Button;\n","import { DividerExporters, DividerDefaults } from \"@unlayer/exporters\";\nimport type { DividerValues, BorderInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\ntype DividerSemanticProps = Omit<SemanticProps<DividerValues>, \"border\"> & {\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n};\n\nexport interface DividerProps extends ItemComponentProps<DividerSemanticProps> {}\n\n// Defaults from the editor schema\nconst DEFAULT_VALUES = {\n ...DividerDefaults,\n} as unknown as DividerValues;\n\n/**\n * Divider - Universal SSR/Client Component with Automatic Semantic Props\n *\n * @example Flat Props\n * ```tsx\n * <Divider borderTopWidth=\"2px\" borderTopColor=\"#ccc\" width=\"80%\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Divider values={{\n * border: { borderTopWidth: \"2px\", borderTopColor: \"#ccc\" },\n * width: \"80%\"\n * }} />\n * ```\n */\nconst Divider = createItemComponent<DividerValues, DividerSemanticProps>({\n name: \"Divider\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => mapSemanticProps(props as SemanticProps<DividerValues>, DEFAULT_VALUES, \"Divider\"),\n displayName: \"Divider\",\n exporters: DividerExporters,\n});\n\nexport default Divider;\n","import { HeadingExporters, HeadingDefaults } from \"@unlayer/exporters\";\nimport type { HeadingValues, TextStyleProps, HeadingLevel } from \"../types\";\nimport {\n createItemComponent,\n type ItemComponentProps\n} from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Heading semantic props — agent-friendly text/style types (replacing the loose\n * `any` flat props) plus the `level` alias and h1–h6 levels.\n */\ntype HeadingSemanticProps = Omit<\n SemanticProps<HeadingValues>,\n keyof TextStyleProps | \"headingType\"\n> &\n TextStyleProps & {\n /** Heading level h1–h6. */\n headingType?: HeadingLevel;\n /** Alias for `headingType`. */\n level?: HeadingLevel;\n /** Heading text (or use children). */\n text?: string;\n };\n\n/**\n * Heading Component Props\n * Automatically provides autocomplete for ALL properties (flat and nested)\n */\nexport interface HeadingProps extends ItemComponentProps<HeadingSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific additions\nconst DEFAULT_VALUES = {\n ...HeadingDefaults,\n color: \"#000000\", // Not in schema options but used by renderer\n fontWeight: 400, // Not in schema options but used by renderer\n text: \"Heading\", // React convenience — not in schema\n} as unknown as HeadingValues;\n\n/**\n * Heading - Universal SSR/Client Component with Semantic Props API\n *\n * ✅ Semantic flat props (level, color, fontSize, etc.)\n * ✅ Escape hatch: values prop for full control\n * ✅ Works on both server and client\n * ✅ Minimal boilerplate using component factory\n *\n * @example Semantic Props (Recommended)\n * ```tsx\n * <Heading level=\"h1\" color=\"#222\" fontSize=\"32px\">\n * Welcome\n * </Heading>\n * ```\n *\n * @example Full Control via Values\n * ```tsx\n * <Heading values={{ headingType: \"h1\", color: \"#222\" }}>Welcome</Heading>\n * ```\n */\nconst Heading = createItemComponent<HeadingValues, HeadingSemanticProps>({\n name: \"Heading\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { level, ...rest } = props as SemanticProps<HeadingValues> & { level?: HeadingValues[\"headingType\"] };\n const result = mapSemanticProps(rest as SemanticProps<HeadingValues>, DEFAULT_VALUES, \"Heading\");\n // Map level prop to headingType\n if (level && !result.headingType) {\n result.headingType = level;\n }\n return result;\n },\n displayName: \"Heading\",\n exporters: HeadingExporters,\n});\n\nexport default Heading;\n","import { HtmlExporters, HtmlDefaults } from \"@unlayer/exporters\";\nimport type { HtmlValues } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\nexport interface HtmlProps extends ItemComponentProps<SemanticProps<HtmlValues>> {}\n\n// Defaults from the editor schema\nconst DEFAULT_VALUES = {\n ...HtmlDefaults,\n} as unknown as HtmlValues;\n\n/**\n * Html - Universal SSR/Client Component for custom HTML with Automatic Semantic Props\n *\n * @example Flat Props\n * ```tsx\n * <Html html=\"<div>Custom HTML</div>\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Html values={{ html: \"<div>Custom HTML</div>\" }} />\n * ```\n */\nconst Html = createItemComponent<HtmlValues, SemanticProps<HtmlValues>>({\n name: \"Html\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => mapSemanticProps(props, DEFAULT_VALUES, \"Html\"),\n displayName: \"Html\",\n exporters: HtmlExporters,\n});\n\nexport default Html;\n","import { ImageExporters, ImageDefaults } from \"@unlayer/exporters\";\nimport type { ImageValues, ImageSrcInput, SizeInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Image semantic props — agent-friendly `src` (plain URL string or value object)\n * and CSS-style sizing (number/px pins, \"50%\" sets a percentage), replacing the\n * loose `any` flat props.\n */\ntype ImageSemanticProps = Omit<\n SemanticProps<ImageValues>,\n \"src\" | \"width\" | \"maxWidth\"\n> & {\n /** Alt text (alias for altText) */\n alt?: string;\n /** Image URL string, or the value object `{ url, width?, maxWidth?, ... }`. */\n src?: ImageSrcInput;\n /** Display width — number/px pins the image; \"50%\" sets a percentage width. */\n width?: SizeInput;\n /** Display width as a CSS value (\"50%\", \"300px\"). */\n maxWidth?: SizeInput;\n};\n\nexport interface ImageProps extends ItemComponentProps<ImageSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific overrides\nconst DEFAULT_VALUES = {\n ...ImageDefaults,\n // Override src with autoWidth/maxWidth for responsive rendering\n src: {\n ...ImageDefaults.src,\n autoWidth: true,\n maxWidth: \"100%\",\n },\n} as unknown as ImageValues;\n\n/**\n * Image - Renders an image element.\n *\n * @example Shorthand\n * ```tsx\n * <Image src=\"https://example.com/photo.jpg\" alt=\"A photo\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Image values={{\n * src: { url: \"https://example.com/image.jpg\", width: 600 },\n * altText: \"Description\"\n * }} />\n * ```\n */\nconst Image = createItemComponent<ImageValues, ImageSemanticProps>({\n name: \"Image\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n // `width`/`maxWidth` are DISPLAY intent — pull them out so mapSemanticProps\n // can't fold them into the natural-size `src.width` field. They drive\n // autoWidth + maxWidth below; the natural dimensions come only from an\n // object `src` / the loaded image.\n const { alt, src, width: widthProp, maxWidth: maxWidthProp, ...rest } = props;\n\n // Normalize a string `values.src` to { url } before mapping. mapSemanticProps\n // merges flat src props onto the src group by spreading; if the escape-hatch\n // src is a string, spreading it character-spreads the URL into numeric keys\n // ({0:\"h\",1:\"t\",…}) and loses the url. Wrapping it first keeps the merge\n // object-to-object.\n const restValues = (rest as { values?: { src?: unknown } }).values;\n const normalizedRest =\n restValues && typeof restValues.src === \"string\"\n ? { ...rest, values: { ...restValues, src: { url: restValues.src } } }\n : rest;\n\n const base: Partial<ImageValues> = mapSemanticProps(\n normalizedRest as SemanticProps<ImageValues>,\n DEFAULT_VALUES,\n \"Image\"\n );\n\n // Map alt → altText\n if (alt !== undefined) {\n base.altText = alt;\n }\n\n // Build the src value. Note: ImageValues.src is typed as string (codegen\n // bug) but the exporter expects { url, autoWidth?, maxWidth?, width?, ... }.\n // Natural src fields come from the `src` prop (string or object) and the\n // `values.src` escape hatch (which lands on `base.src` via mapSemanticProps);\n // the display `width`/`maxWidth` props were pulled out above. Combine the\n // natural fields (defensively, since base.src may be a string or non-object),\n // then apply the display intent.\n const baseSrc = (base as Record<string, any>).src;\n const fromValues: Record<string, any> =\n baseSrc && typeof baseSrc === \"object\" && !Array.isArray(baseSrc)\n ? (baseSrc as Record<string, any>)\n : typeof baseSrc === \"string\"\n ? { url: baseSrc }\n : {};\n const fromProp: Record<string, any> =\n typeof src === \"string\" ? { url: src } : (src ?? {}) as Record<string, any>;\n const userSrc = { ...fromValues, ...fromProp };\n\n if (src !== undefined || baseSrc !== undefined) {\n // A string url (from the `src` prop or `values.src`) carries no\n // dimensions, so it starts responsive with no placeholder size; an object\n // src starts from the schema defaults.\n const isStringUrl =\n typeof src === \"string\" || (src === undefined && typeof baseSrc === \"string\");\n const start = isStringUrl\n ? { autoWidth: true, maxWidth: \"100%\" }\n : { ...DEFAULT_VALUES.src };\n const merged = { ...start, ...userSrc } as Record<string, any>;\n\n // In Unlayer's value model, `src.width`/`height` are the NATURAL image size\n // and never set the display size. Display size = autoWidth + maxWidth: the\n // default (and \"100%\") is responsive (autoWidth:true); a fixed display size\n // is autoWidth:false + `maxWidth` as a PERCENT of the column's content slot\n // (see image-sizing.ts for why a percent, not the natural-size field). A\n // px/number pin is kept here as a placeholder and converted to that percent\n // by the width-aware pass in renderToHtml / renderToJson, where the column\n // geometry is known. An explicit autoWidth is honored.\n const pctRe = /^\\d+(?:\\.\\d+)?%$/;\n const asPercent = (v: unknown): string | undefined =>\n typeof v === \"string\" && pctRe.test(v.trim()) ? v.trim() : undefined;\n const asPx = (v: unknown): number | undefined => {\n if (typeof v === \"number\" && Number.isFinite(v)) return v;\n if (typeof v === \"string\") {\n const t = v.trim();\n if (pctRe.test(t)) return undefined;\n const m = /^(\\d+(?:\\.\\d+)?)(?:px)?$/.exec(t);\n if (m) return parseFloat(m[1]);\n }\n return undefined;\n };\n\n // Resolve display intent in priority order: flat `width` → flat `maxWidth`\n // → escape-hatch values.src.maxWidth.\n let displayPct: string | undefined;\n let displayPx: number | undefined;\n for (const candidate of [widthProp, maxWidthProp, userSrc.maxWidth]) {\n if (candidate === undefined) continue;\n const pct = asPercent(candidate);\n if (pct) {\n displayPct = pct;\n break;\n }\n const px = asPx(candidate);\n if (px != null) {\n displayPx = px;\n break;\n }\n }\n\n // An explicit escape-hatch `autoWidth` is honored as-is (its own maxWidth\n // stays); otherwise the display intent decides.\n if (userSrc.autoWidth === undefined) {\n if (displayPct && displayPct !== \"100%\") {\n merged.autoWidth = false;\n merged.maxWidth = displayPct;\n } else if (displayPx != null) {\n merged.autoWidth = false;\n merged.maxWidth = displayPx;\n } else {\n merged.autoWidth = true;\n merged.maxWidth = \"100%\";\n }\n }\n\n base.src = merged as ImageValues[\"src\"];\n }\n\n return base;\n },\n displayName: \"Image\",\n exporters: ImageExporters,\n});\n\nexport default Image;\n","import { MenuExporters, MenuDefaults } from \"@unlayer/exporters\";\nimport type { MenuValues, MenuItem, SizeInput, TextStyleProps } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n// Menu carries fontFamily/fontWeight/fontSize/letterSpacing (but not color or\n// lineHeight) — relax those to the same agent-friendly inputs Heading/Paragraph\n// use, so a string fontFamily or a number/em size type-checks (normalized at\n// render time). It has no `color` field (uses linkColor/textColor).\ntype MenuSemanticProps = Omit<\n SemanticProps<MenuValues>,\n \"padding\" | \"fontFamily\" | \"fontWeight\" | \"fontSize\" | \"letterSpacing\"\n> &\n Omit<TextStyleProps, \"color\" | \"lineHeight\"> & {\n /** Menu items shorthand */\n items?: MenuItem[];\n /** Inner padding — a number (→ px) or CSS string. */\n padding?: SizeInput;\n };\n\nexport interface MenuProps extends ItemComponentProps<MenuSemanticProps> {}\n\n// Defaults from the editor schema\nconst DEFAULT_MENU: NonNullable<MenuValues[\"menu\"]> = MenuDefaults.menu ?? { items: [] };\n\nconst DEFAULT_VALUES = {\n ...MenuDefaults,\n} as unknown as MenuValues;\n\n/**\n * Menu - Renders a navigation menu.\n *\n * @example Shorthand\n * ```tsx\n * <Menu items={[{ text: \"Home\", href: \"/\" }, { text: \"About\", href: \"/about\" }]} />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Menu values={{\n * menu: {\n * items: [\n * { key: \"home\", text: \"Home\", link: { name: \"web\", values: { href: \"/\" } } }\n * ]\n * }\n * }} />\n * ```\n */\nconst Menu = createItemComponent<MenuValues, MenuSemanticProps>({\n name: \"Menu\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { items, ...rest } = props;\n\n if (Array.isArray(items)) {\n const mapped = items.map((item: MenuItem, i: number) => ({\n key: String(i + 1),\n text: item.text,\n link: {\n name: \"web\",\n values: { href: item.href, target: item.target ?? \"_blank\" },\n },\n }));\n const base: Partial<MenuValues> = mapSemanticProps(\n rest as SemanticProps<MenuValues>,\n DEFAULT_VALUES,\n \"Menu\"\n );\n base.menu = { items: mapped };\n return base;\n }\n\n return mapSemanticProps(\n props as SemanticProps<MenuValues>,\n DEFAULT_VALUES,\n \"Menu\"\n );\n },\n displayName: \"Menu\",\n exporters: MenuExporters,\n});\n\nexport default Menu;\n","import { ParagraphExporters, ParagraphDefaults } from \"@unlayer/exporters\";\nimport type { ParagraphValues, TextStyleProps } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Paragraph semantic props — agent-friendly text/style types (replacing the\n * loose `any` flat props) plus the `text` shorthand (converted to textJson).\n */\ntype ParagraphSemanticProps = Omit<\n SemanticProps<ParagraphValues>,\n keyof TextStyleProps\n> &\n TextStyleProps & {\n /** Plain-text content (or use `html` for inline formatting, or children). */\n text?: string;\n };\n\n/**\n * Paragraph Component Props\n * Automatically provides autocomplete for ALL properties (flat and nested)\n */\nexport interface ParagraphProps extends ItemComponentProps<ParagraphSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific additions\nconst DEFAULT_VALUES = {\n ...ParagraphDefaults,\n color: \"#000000\", // Not in schema options but used by renderer\n} as unknown as ParagraphValues;\n\n/**\n * Paragraph - Universal SSR/Client Component with Semantic Props API\n *\n * ✅ Semantic flat props (color, fontSize, textAlign, etc.)\n * ✅ Escape hatch: values prop for full control\n * ✅ Works on both server and client\n * ✅ Minimal boilerplate using component factory\n *\n * @example Semantic Props (Recommended)\n * ```tsx\n * <Paragraph color=\"#555\" fontSize=\"14px\" lineHeight=\"1.6\">\n * Your paragraph content here with <strong>rich text</strong> support\n * </Paragraph>\n * ```\n *\n * @example Full Control via Values\n * ```tsx\n * <Paragraph values={{ textJson: \"...\", color: \"#555\" }} />\n * ```\n */\nconst Paragraph = createItemComponent<ParagraphValues, ParagraphSemanticProps>({\n name: \"Paragraph\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) =>\n mapSemanticProps(props as SemanticProps<ParagraphValues>, DEFAULT_VALUES, \"Paragraph\"),\n displayName: \"Paragraph\",\n exporters: ParagraphExporters,\n});\n\nexport default Paragraph;\n","import { SocialExporters, SocialDefaults } from \"@unlayer/exporters\";\nimport type { SocialValues, SocialIcon } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\ntype SocialSemanticProps = SemanticProps<SocialValues> & {\n /** Social icons shorthand (array of {name, url}) */\n icons?: SocialIcon[];\n /** Icon shape */\n iconType?: \"circle\" | \"rounded\" | \"squared\";\n};\n\nexport interface SocialProps extends Omit<ItemComponentProps<SemanticProps<SocialValues>>, \"icons\"> {\n icons?: SocialIcon[] | SocialValues[\"icons\"];\n iconType?: \"circle\" | \"rounded\" | \"squared\";\n}\n\n// Defaults from the editor schema\nconst DEFAULT_ICONS: SocialValues[\"icons\"] = SocialDefaults.icons ?? { iconType: \"circle\", icons: [] };\n\nconst DEFAULT_VALUES = {\n ...SocialDefaults,\n} as unknown as SocialValues;\n\n/**\n * Social - Renders social-media icon links.\n *\n * @example Shorthand\n * ```tsx\n * <Social icons={[{ name: \"Facebook\", url: \"https://facebook.com\" }]} iconType=\"rounded\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Social values={{\n * icons: { icons: [\n * { name: \"Facebook\", url: \"https://facebook.com/...\" },\n * { name: \"Twitter\", url: \"https://twitter.com/...\" }\n * ]}\n * }} />\n * ```\n */\nconst Social = createItemComponent<SocialValues, SocialSemanticProps>({\n name: \"Social\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { icons, iconType, ...rest } = props;\n\n // Map shorthand icons array → exporter format\n if (Array.isArray(icons)) {\n const mapped = icons.map((icon: SocialIcon) => ({\n name: icon.name,\n url: icon.url,\n }));\n const base: Partial<SocialValues> = mapSemanticProps(\n rest as SemanticProps<SocialValues>,\n DEFAULT_VALUES,\n \"Social\"\n );\n base.icons = {\n iconType: iconType ?? base.icons?.iconType ?? \"circle\",\n icons: mapped,\n };\n return base;\n }\n\n // If iconType passed without shorthand icons, thread it into nested group\n if (iconType !== undefined) {\n const base: Partial<SocialValues> = mapSemanticProps(\n rest as SemanticProps<SocialValues>,\n DEFAULT_VALUES,\n \"Social\"\n );\n base.icons = { ...DEFAULT_ICONS, ...base.icons, iconType };\n return base;\n }\n\n return mapSemanticProps(\n props as SemanticProps<SocialValues>,\n DEFAULT_VALUES,\n \"Social\"\n );\n },\n displayName: \"Social\",\n exporters: SocialExporters,\n});\n\nexport default Social;\n","import { TableExporters, TableDefaults } from \"@unlayer/exporters\";\nimport type { TableValues, SizeInput, BorderInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\ntype TableSemanticProps = Omit<SemanticProps<TableValues>, \"padding\" | \"border\"> & {\n /** Column headers as string[] */\n headers?: string[];\n /** Row data as 2D string array */\n data?: string[][];\n /** Inner padding — a number (→ px) or CSS string. */\n padding?: SizeInput;\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n};\n\nexport interface TableProps\n extends Omit<ItemComponentProps<Omit<SemanticProps<TableValues>, \"padding\" | \"border\">>, \"headers\" | \"data\"> {\n headers?: string[];\n data?: string[][];\n /** Inner padding — a number (→ px) or CSS string. */\n padding?: SizeInput;\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n}\n\n// Defaults from the editor schema, plus table data structure\nconst DEFAULT_TABLE: NonNullable<TableValues[\"table\"]> = { headers: [], rows: [], footers: [] };\n\nconst DEFAULT_VALUES = {\n ...TableDefaults,\n table: DEFAULT_TABLE, // Schema doesn't include table data structure\n} as unknown as TableValues;\n\n/**\n * Table - Renders a data table.\n *\n * @example Shorthand\n * ```tsx\n * <Table\n * headers={[\"Name\", \"Email\", \"Role\"]}\n * data={[[\"Alice\", \"alice@co.com\", \"Admin\"], [\"Bob\", \"bob@co.com\", \"User\"]]}\n * />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Table values={{\n * table: {\n * headers: [{ cells: [{ text: \"Name\" }, { text: \"Email\" }] }],\n * rows: [{ cells: [{ text: \"John\" }, { text: \"john@example.com\" }] }]\n * },\n * enableHeader: true\n * }} />\n * ```\n */\nconst Table = createItemComponent<TableValues, TableSemanticProps>({\n name: \"Table\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n // `columns`/`rows` are top-level COUNTS, but the table data lives under the\n // nested `table` group whose keys also include `rows` — so routing the flat\n // `rows` through the generic mapper collides with `table.rows` and makes the\n // exporter iterate a number (crash). Pull them out and handle them here.\n const { headers, data, columns, rows, ...rest } = props as typeof props & {\n columns?: number;\n rows?: number;\n };\n\n if (\n headers ||\n data ||\n typeof columns === \"number\" ||\n typeof rows === \"number\"\n ) {\n const base: Partial<TableValues> = mapSemanticProps(\n rest as SemanticProps<TableValues>,\n DEFAULT_VALUES,\n \"Table\"\n );\n\n const colCount = headers\n ? headers.length\n : typeof columns === \"number\"\n ? columns\n : data?.[0]?.length ?? 0;\n const blankCells = (n: number) =>\n Array.from({ length: n }, () => ({ text: \"\", width: 0 }));\n\n const tableHeaders = headers\n ? [{ cells: headers.map((text: string) => ({ text, width: 0 })), height: 0 }]\n : [];\n\n const tableRows = data\n ? data.map((row: string[]) => ({\n cells: row.map((text: string) => ({ text, width: 0 })),\n height: 0,\n }))\n : typeof rows === \"number\"\n ? // No data: build an empty grid sized by `columns` × `rows`.\n Array.from({ length: rows }, () => ({\n cells: blankCells(colCount),\n height: 0,\n }))\n : [];\n\n base.table = { headers: tableHeaders, rows: tableRows, footers: [] };\n\n if (headers || typeof columns === \"number\") {\n base.columns = colCount;\n }\n if (headers) {\n base.enableHeader = true;\n }\n if (data) {\n base.rows = data.length;\n } else if (typeof rows === \"number\") {\n base.rows = rows;\n }\n\n return base;\n }\n\n return mapSemanticProps(\n props as SemanticProps<TableValues>,\n DEFAULT_VALUES,\n \"Table\"\n );\n },\n displayName: \"Table\",\n exporters: TableExporters,\n});\n\nexport default Table;\n","import { VideoExporters, VideoDefaults } from \"@unlayer/exporters\";\nimport type { VideoValues } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\ntype VideoSemanticProps = SemanticProps<VideoValues> & {\n /** YouTube/Vimeo URL (auto-parsed) */\n videoUrl?: string;\n};\n\nexport interface VideoProps extends ItemComponentProps<SemanticProps<VideoValues>> {\n videoUrl?: string;\n}\n\n// Defaults from the editor schema, plus React-specific video structure\nconst DEFAULT_VIDEO: NonNullable<VideoValues[\"video\"]> = {\n type: \"youtube\",\n videoId: \"\",\n thumbnail: \"\",\n loading: false,\n ...VideoDefaults.video,\n};\n\nconst DEFAULT_VALUES = {\n ...VideoDefaults,\n video: DEFAULT_VIDEO,\n} as unknown as VideoValues;\n\n/**\n * Parses a YouTube or Vimeo URL and returns exporter-ready video data.\n */\nexport function parseVideoUrl(url: string): { type: \"youtube\" | \"vimeo\"; videoId: string; thumbnail: string } | null {\n // YouTube: youtube.com/watch?v=ID, youtu.be/ID, youtube.com/embed/ID\n const ytMatch = url.match(\n /(?:youtube\\.com\\/(?:watch\\?v=|embed\\/)|youtu\\.be\\/)([a-zA-Z0-9_-]{11})/\n );\n if (ytMatch) {\n const videoId = ytMatch[1];\n return {\n type: \"youtube\",\n videoId,\n thumbnail: `https://img.youtube.com/vi/${videoId}/0.jpg`,\n };\n }\n\n // Vimeo: vimeo.com/ID\n const vimeoMatch = url.match(/vimeo\\.com\\/(\\d+)/);\n if (vimeoMatch) {\n return {\n type: \"vimeo\",\n videoId: vimeoMatch[1],\n thumbnail: \"\",\n };\n }\n\n return null;\n}\n\n/**\n * Video - Renders an embedded video player (YouTube/Vimeo).\n *\n * @example Shorthand\n * ```tsx\n * <Video videoUrl=\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Video values={{\n * video: { type: \"youtube\", videoId: \"dQw4w9WgXcQ\", thumbnail: \"...\" }\n * }} />\n * ```\n */\nconst Video = createItemComponent<VideoValues, VideoSemanticProps>({\n name: \"Video\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { videoUrl, ...rest } = props;\n\n if (typeof videoUrl === \"string\") {\n const parsed = parseVideoUrl(videoUrl);\n const base: Partial<VideoValues> = mapSemanticProps(\n rest as SemanticProps<VideoValues>,\n DEFAULT_VALUES,\n \"Video\"\n );\n if (parsed) {\n base.video = { ...DEFAULT_VIDEO, ...parsed };\n }\n return base;\n }\n\n return mapSemanticProps(\n props as SemanticProps<VideoValues>,\n DEFAULT_VALUES,\n \"Video\"\n );\n },\n displayName: \"Video\",\n exporters: VideoExporters,\n});\n\nexport default Video;\n","/**\n * Default values for container components (Body, Row, Column).\n *\n * Runtime values come from @unlayer/exporters (extracted from the editor\n * schema at generation time). Types come from @unlayer/types\n * (generated from the same schema). Both are single source of truth.\n *\n * Imported by both render-to-json.ts and extract-head.ts to ensure the\n * JSON output and head CSS always use consistent defaults.\n */\n\nimport {\n BodyDefaults,\n RowDefaults,\n ColumnDefaults,\n} from \"@unlayer/exporters\";\nimport type { BodyValues, RowValues, ColumnValues } from \"@unlayer-internal/shared-elements\";\n\n// Body defaults from the editor schema.\n// Filter out popup-specific fields that aren't relevant for email/web rendering.\nconst allBodyDefaults = BodyDefaults as Record<string, any>;\nconst {\n popupPosition: _p1,\n popupDisplayDelay: _p2,\n popupWidth: _p3,\n popupHeight: _p4,\n popupBackgroundColor: _p5,\n popupBackgroundImage: _p6,\n popupOverlay_backgroundColor: _p7,\n popupCloseButton_position: _p8,\n popupCloseButton_backgroundColor: _p9,\n popupCloseButton_iconColor: _p10,\n popupCloseButton_borderRadius: _p11,\n popupCloseButton_margin: _p12,\n popupCloseButton_action: _p13,\n ...bodyRest\n} = allBodyDefaults;\n\nexport const BODY_DEFAULTS = bodyRest as BodyValues;\n\nexport const ROW_DEFAULTS = { ...RowDefaults } as RowValues;\n\nexport const COLUMN_DEFAULTS = { ...ColumnDefaults } as ColumnValues;\n","import React from \"react\";\nimport type { RenderMode, UnlayerConfig, RowValues } from \"@unlayer-internal/shared-elements\";\nimport { validateColumnLayout } from \"@unlayer-internal/shared-elements\";\nimport type { ColumnLayout } from \"@unlayer-internal/shared-elements\";\nimport { RowExporters } from \"@unlayer/exporters\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\nimport { nextHtmlId } from \"../utils/create-component\";\nimport { bodyContentWidthPx } from \"../utils/image-sizing\";\nimport type { SizeInput } from \"../types\";\nimport { ROW_DEFAULTS, BODY_DEFAULTS } from \"../utils/container-defaults\";\n\n/**\n * Row - Container for columns in a layout\n *\n * Uses the Row exporter from @unlayer/exporters.\n * Column children call their own exporters.\n *\n * @example\n * ```tsx\n * <Row cells={[1, 1]}>\n * <Column><Button>Click me</Button></Column>\n * <Column><Paragraph>Hello</Paragraph></Column>\n * </Row>\n * ```\n */\n\nconst DEFAULT_VALUES = ROW_DEFAULTS;\n\nconst DEFAULT_BODY_VALUES = BODY_DEFAULTS;\n\nexport type RowProps = Omit<SemanticProps<RowValues>, \"padding\"> & {\n children?: React.ReactNode;\n layout?: ColumnLayout;\n cells?: number[];\n mode?: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n index?: number;\n bodyValues?: any;\n collection?: string;\n /** Padding — a CSS string (\"0 48px\", \"20px 40px\") or a number (px). */\n padding?: SizeInput;\n /** @internal - Unlayer config threaded from UnlayerProvider via Body */\n _config?: UnlayerConfig;\n};\n\n// ============================================\n// Grid CSS (inlined from shared/utils/grid-css.ts)\n// ============================================\n\ninterface WidthPercentage {\n value: number;\n className: string;\n}\n\nfunction getWidthPercentages(cells: number[]): WidthPercentage[] {\n if (cells.length === 0) return [];\n const total = cells.reduce((a, b) => a + b, 0);\n if (total <= 0) return [];\n return cells.map((span) => {\n const value = Math.round((span / total) * 100 * 100) / 100;\n const className = `${value}`.replace(/\\./g, 'p');\n return { value, className };\n });\n}\n\nfunction generateGridCSS(cells: number[], mode: RenderMode, contentWidth: number = 600, mobileBreakpoint: number = 620): string {\n const widths = getWidthPercentages(cells);\n\n if (mode === 'email') {\n const minQuery = `@media only screen and (min-width: ${contentWidth + 20}px)`;\n const maxQuery = `@media only screen and (max-width: ${contentWidth + 20}px)`;\n\n return `\n${minQuery} {\n .u-row { width: ${contentWidth}px !important; }\n .u-row .u-col { vertical-align: top; }\n${widths.map(({ value, className }) => ` .u-row .u-col-${className} { width: ${Math.round((contentWidth * value) / 100)}px !important; }`).join('\\n')}\n}\n\n${maxQuery} {\n .u-row-container { max-width: 100% !important; padding-left: 0px !important; padding-right: 0px !important; }\n .u-row { width: 100% !important; }\n .u-row .u-col { display: block !important; width: 100% !important; min-width: 320px !important; max-width: 100% !important; }\n .u-row .u-col > div { margin: 0 auto; }\n .no-stack .u-col { min-width: 0 !important; display: table-cell !important; }\n${widths.map(({ value, className }) => ` .no-stack .u-col-${className} { width: ${value}% !important; }`).join('\\n')}\n}`;\n }\n\n // Web mode\n const baseCSS = `\n.u-row {\n display: flex;\n flex-wrap: nowrap;\n margin-left: 0;\n margin-right: 0;\n}\n.u-row .u-col {\n position: relative;\n width: 100%;\n padding-right: 0;\n padding-left: 0;\n}`;\n\n const columnCSS = widths\n .map(\n ({ value, className }) =>\n `.u-row .u-col.u-col-${className} { flex: 0 0 ${value}%; max-width: ${value}%; }`,\n )\n .join('\\n');\n\n const responsiveCSS = `\n@media only screen and (max-width: ${mobileBreakpoint}px) {\n .u-row { width: 100% !important; }\n .u-row .u-col {\n display: block !important;\n width: 100% !important;\n min-width: 320px !important;\n max-width: 100% !important;\n }\n .u-row .u-col > div { margin: 0 auto; }\n .no-stack .u-col {\n min-width: 0 !important;\n display: table-cell !important;\n }\n${widths.map(({ value, className }) => ` .no-stack .u-col-${className} { width: ${value}% !important; }`).join('\\n')}\n}`;\n\n return baseCSS + '\\n' + columnCSS + '\\n' + responsiveCSS;\n}\n\n// ============================================\n// Row exporter wrapper (inlined from shared/utils/render-container-to-html.ts)\n// ============================================\n\ntype ContainerExporterFunction = (innerHTML: string, values: Record<string, any>, bodyValues?: Record<string, any>, options?: Record<string, any>) => string;\n\n/**\n * Resolve the row's content width (px number) from body values. contentWidth\n * may be \"600px\" (string), 600 (number), or \"600\" (bare numeric string); the\n * grid CSS needs a number. In EMAIL mode this drives the per-column desktop\n * widths and the stacking breakpoint — so without it, multi-column emails were\n * pinned to 600px regardless of <Body contentWidth>. Web mode uses percentages,\n * so this is a no-op there.\n *\n * Uses the same strict px parse as the image slot geometry (a non-px value like\n * \"50%\" → fallback, not a parseInt artifact like 50) so the two stay in sync.\n */\nfunction toContentWidthPx(bodyValues: any, fallback = 500): number {\n return bodyContentWidthPx(bodyValues?.contentWidth, fallback);\n}\n\nfunction renderRowToHtml(innerHTML: string, values: any, bodyValues: any, mode: RenderMode, cells: number[], collection: string = \"rows\"): string {\n const rowExporter = (RowExporters[mode] || RowExporters.web) as ContainerExporterFunction;\n const html = rowExporter(innerHTML, values, bodyValues, {\n collection,\n variant: mode,\n });\n\n const contentWidth = toContentWidthPx(bodyValues);\n const css = generateGridCSS(cells, mode, contentWidth);\n return css ? `<style>${css}</style>${html}` : html;\n}\n\n// ============================================\n// Children processing\n// ============================================\n\nfunction processChildren(\n children: React.ReactNode,\n cells: number[],\n bodyValues: any,\n rowValues: any,\n mode: RenderMode,\n _config?: UnlayerConfig\n): string {\n if (!children) return \"\";\n\n let innerHTML = \"\";\n const childrenArray = React.Children.toArray(children);\n\n childrenArray.forEach((child, index) => {\n if (!React.isValidElement(child)) {\n if (typeof child === \"string\" || typeof child === \"number\") {\n innerHTML += String(child);\n }\n return;\n }\n\n const componentType = child.type as any;\n const isColumn =\n componentType?.displayName === \"Column\" ||\n componentType?.name === \"Column\";\n\n if (isColumn && typeof child.type === \"function\") {\n // Call Column component with context props\n const rendered = (child.type as Function)({\n ...child.props,\n index,\n cells,\n bodyValues,\n rowValues,\n mode,\n _config\n });\n\n // Extract HTML from dangerouslySetInnerHTML\n if (rendered?.props?.dangerouslySetInnerHTML?.__html) {\n innerHTML += rendered.props.dangerouslySetInnerHTML.__html;\n }\n } else if (React.isValidElement(child)) {\n const name = (child.type as any)?.displayName || (child.type as any)?.name || \"Unknown\";\n console.warn(\n `Row: <${name}> is not a valid Row child. Only <Column> components can be direct children of <Row>. ` +\n `Wrap it in a <Column>: <Row><Column><${name} /></Column></Row>`\n );\n }\n });\n\n return innerHTML;\n}\n\n// ============================================\n// Component\n// ============================================\n\nconst Row: React.FC<RowProps> = (props) => {\n const {\n layout,\n cells: propsCells,\n children,\n mode: modeProp,\n className,\n style,\n index = 0,\n bodyValues = {},\n collection = \"rows\",\n _config,\n ...semanticProps\n } = props;\n\n // Resolve mode: explicit prop > _config > default\n const mode: RenderMode = modeProp ?? _config?.mode ?? \"web\";\n\n // Determine cells from layout or props\n let cells = propsCells || [1];\n if (layout) {\n validateColumnLayout(layout, React.Children.count(children));\n cells = layout.cells;\n }\n\n // Merge body values with defaults\n const safeBodyValues = { ...DEFAULT_BODY_VALUES, ...bodyValues };\n\n // Map semantic props to values\n const values = mapSemanticProps<RowValues>(\n semanticProps as SemanticProps<RowValues>,\n DEFAULT_VALUES,\n \"Row\"\n );\n\n const valuesWithMeta = {\n ...values,\n cells,\n _meta: {\n htmlID: nextHtmlId(_config, \"u_row\"),\n htmlClassNames: \"u_row\",\n ...(values._meta || {})\n }\n };\n\n // Process Column children\n const innerHTML = processChildren(\n children,\n cells,\n safeBodyValues,\n valuesWithMeta,\n mode,\n _config\n );\n\n try {\n const html = renderRowToHtml(innerHTML, valuesWithMeta, safeBodyValues, mode, cells, collection);\n\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n className={className}\n style={style}\n />\n );\n } catch (error) {\n console.error(\"Row rendering failed:\", error);\n return (\n <div className={className} style={style}>\n {children}\n </div>\n );\n }\n};\n\nRow.displayName = \"Row\";\n\nexport default Row;\n","import React from \"react\";\nimport type { RenderMode, UnlayerConfig, ColumnValues } from \"@unlayer-internal/shared-elements\";\nimport { ColumnExporters, ContentExporters } from \"@unlayer/exporters\";\nimport { UNLAYER_RENDER_KEY, nextHtmlId } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\nimport type { SizeInput, BorderInput } from \"../types\";\nimport { COLUMN_DEFAULTS } from \"../utils/container-defaults\";\n\n/** Unlayer's default content-block padding when a block sets none. */\nconst DEFAULT_CONTAINER_PADDING = \"10px\";\n\n/**\n * Column - Single column in a Row layout\n *\n * Calls the Column exporter from @unlayer/exporters.\n * Must be used inside <Row> component.\n *\n * @example\n * ```tsx\n * <Row cells={[1, 1]}>\n * <Column>\n * <Button>Click me</Button>\n * </Column>\n * <Column>\n * <Paragraph>Hello</Paragraph>\n * </Column>\n * </Row>\n * ```\n */\n\nconst DEFAULT_VALUES = COLUMN_DEFAULTS;\n\n// ============================================\n// Column exporter wrapper (inlined from shared/utils/render-container-to-html.ts)\n// ============================================\n\ntype ColumnExporterFunction = (innerHTML: string, values: Record<string, any>, index: number, cells: number[], bodyValues?: Record<string, any>, rowValues?: Record<string, any>) => string;\n\nfunction renderColumnToHtml(innerHTML: string, values: any, index: number, cells: number[], bodyValues: any, rowValues: any, mode: RenderMode): string {\n const columnExporter = (ColumnExporters[mode] || ColumnExporters.web) as ColumnExporterFunction;\n return columnExporter(innerHTML, values, index, cells, bodyValues, rowValues);\n}\n\n// Canonical content-container wrapper (the `u_content_*` block that carries\n// each item's containerPadding). Signature per mode: (innerHTML, values,\n// bodyValues, meta). Delegating to the exporter keeps padding, classes, and the\n// per-mode div/table structure consistent with the canonical exporter output.\ntype ContentExporterFunction = (innerHTML: string, values: Record<string, any>, bodyValues?: Record<string, any>, meta?: Record<string, any>) => string;\n\nfunction renderContentToHtml(innerHTML: string, values: any, bodyValues: any, mode: RenderMode): string {\n const contentExporter = (ContentExporters[mode] || ContentExporters.web) as ContentExporterFunction;\n return contentExporter(innerHTML, values, bodyValues, {});\n}\n\n// ============================================\n// Component\n// ============================================\n\nexport type ColumnProps = Omit<SemanticProps<ColumnValues>, \"padding\" | \"border\" | \"borderRadius\"> & {\n children?: React.ReactNode;\n // Internal props (provided by Row)\n index?: number;\n cells?: number[];\n bodyValues?: any;\n rowValues?: any;\n mode?: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n /** Padding — a CSS string (\"0 24px\", \"10px\") or a number (px). */\n padding?: SizeInput;\n /** Corner radius — a number (→ px) or CSS string (\"8px\"). */\n borderRadius?: SizeInput;\n /** Per-side border object (great for hairline dividers). Width fields accept\n * a number/px string; reuse it as a factored-out const without `as const`. */\n border?: BorderInput;\n /** @internal - Unlayer config threaded from UnlayerProvider via Body/Row */\n _config?: UnlayerConfig;\n};\n\nexport const Column: React.FC<ColumnProps> = (props) => {\n const {\n children,\n index = 0,\n cells = [1],\n bodyValues = {},\n rowValues = {},\n mode: modeProp,\n className,\n style,\n _config,\n ...semanticProps\n } = props;\n\n // Resolve mode: explicit prop > _config > default\n const mode: RenderMode = modeProp ?? _config?.mode ?? \"web\";\n\n // Map semantic props to values\n const values = mapSemanticProps<ColumnValues>(\n semanticProps as SemanticProps<ColumnValues>,\n DEFAULT_VALUES,\n \"Column\"\n );\n\n // Add _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: nextHtmlId(_config, \"u_column\"),\n htmlClassNames: \"u_column\",\n ...(values._meta || {})\n }\n };\n\n // Render children to HTML - extract from dangerouslySetInnerHTML\n let innerHTML = \"\";\n if (children) {\n try {\n const childrenArray = React.Children.toArray(children);\n\n childrenArray.forEach((child, childIndex) => {\n if (typeof child === \"string\" || typeof child === \"number\") {\n innerHTML += String(child);\n } else if (React.isValidElement(child)) {\n // Call component function to get rendered result\n if (typeof child.type === \"function\") {\n const ComponentType = child.type as any;\n // Use __unlayerRender (hook-free) if available, otherwise call directly\n const renderFn: Function = ComponentType[UNLAYER_RENDER_KEY] || ComponentType;\n // Thread the column/body context so width-aware item exporters (Image)\n // can size against the real available width (contentWidth × column\n // fraction) instead of the fallback. Mirrors the editor, which passes\n // this context to the content exporters.\n const rendered = renderFn({\n ...child.props,\n _config,\n colIndex: index,\n cells,\n bodyValues,\n rowValues,\n columnValues: valuesWithMeta,\n });\n\n // Extract HTML from dangerouslySetInnerHTML\n if (\n rendered &&\n typeof rendered === \"object\" &&\n rendered.props &&\n rendered.props.dangerouslySetInnerHTML\n ) {\n const componentHTML =\n rendered.props.dangerouslySetInnerHTML.__html;\n const componentType = child.type as any;\n const componentName = (\n componentType?.displayName ||\n componentType?.name ||\n \"component\"\n ).toLowerCase();\n\n // Resolve the block's OWN containerPadding directly from props.\n // `containerPadding` is a universal base-content prop: it passes\n // straight through mapSemanticProps untouched and is not present in\n // any item's defaultValues, so reading it from props (flat prop +\n // `values` escape hatch) is equivalent to running the item's full\n // value pipeline — without paying for a second propMapper call per\n // child (for Paragraph that re-runs the Lexical textJson convert).\n // Falls back to Unlayer's content default. (Previously this read\n // `child.props.values?.containerPadding` only, which is undefined\n // for the flat-prop API, so every block collapsed to 0px padding.)\n const childProps = child.props as {\n containerPadding?: string | number;\n values?: { containerPadding?: string | number };\n };\n const rawContainerPadding =\n childProps.containerPadding ??\n childProps.values?.containerPadding ??\n DEFAULT_CONTAINER_PADDING;\n // A bare number is treated as px (same idiom as other size props).\n const containerPadding =\n typeof rawContainerPadding === \"number\"\n ? `${rawContainerPadding}px`\n : rawContainerPadding;\n\n // Wrap via the canonical content-container exporter for this mode.\n const contentValues = {\n containerPadding,\n _meta: {\n htmlID: nextHtmlId(_config, `u_content_${componentName}`),\n htmlClassNames: `u_content_${componentName}`,\n },\n };\n innerHTML += renderContentToHtml(\n componentHTML,\n contentValues,\n bodyValues,\n mode\n );\n } else if (rendered) {\n const name = (child.type as any)?.displayName || (child.type as any)?.name || \"Unknown\";\n console.warn(\n `Column: <${name}> did not produce renderable HTML. ` +\n `Ensure it is an Unlayer component (Button, Text, Image, etc.).`\n );\n }\n }\n }\n });\n } catch (error) {\n console.error(\"Column: Failed to render children:\", error);\n innerHTML = \"\";\n }\n }\n\n try {\n const html = renderColumnToHtml(innerHTML, valuesWithMeta, index, cells, bodyValues, rowValues, mode);\n\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n className={className}\n style={style}\n />\n );\n } catch (error) {\n console.error(\"Column rendering failed:\", error);\n return (\n <div className={className} style={style}>\n {children}\n </div>\n );\n }\n};\n\nColumn.displayName = \"Column\";\n\nexport default Column;\n","import React from \"react\";\nimport ReactDOMServer from \"react-dom/server\";\nimport type { RenderMode, UnlayerConfig, BodyValues } from \"@unlayer-internal/shared-elements\";\nimport { DEFAULT_CONFIG, mergeValues } from \"@unlayer-internal/shared-elements\";\nimport { BodyExporters } from \"@unlayer/exporters\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\nimport { nextHtmlId } from \"../utils/create-component\";\nimport type { SizeInput } from \"../types\";\nimport { BODY_DEFAULTS } from \"../utils/container-defaults\";\n\nexport type BodyProps = Omit<SemanticProps<BodyValues>, \"padding\" | \"borderRadius\"> & {\n children?: React.ReactNode;\n mode?: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n index?: number;\n /** Optional config (replaces context-based config for Server Component usage) */\n config?: Partial<UnlayerConfig>;\n /** Preview text shown in email client inboxes (email mode only) */\n previewText?: string;\n /** Padding — a CSS string (\"0 48px\", \"20px\") or a number (px). */\n padding?: SizeInput;\n /** Corner radius — a number (→ px) or CSS string (\"8px\"). */\n borderRadius?: SizeInput;\n};\n\nconst DEFAULT_VALUES = BODY_DEFAULTS;\n\n// ============================================\n// Preview text (inlined from shared/utils/preview.ts)\n// ============================================\n\nconst MAX_PREVIEW_LENGTH = 150;\n\nconst PADDING_CHARS = [\n \"\\u00A0\", \"\\u200C\", \"\\u200B\", \"\\u200D\", \"\\u200E\", \"\\u200F\", \"\\uFEFF\",\n];\n\nfunction generatePreviewHtml(text: string): string {\n if (!text || text.trim().length === 0) return \"\";\n\n const truncated = text.length > MAX_PREVIEW_LENGTH\n ? text.slice(0, MAX_PREVIEW_LENGTH)\n : text;\n\n const paddingLength = Math.max(0, MAX_PREVIEW_LENGTH - truncated.length);\n let padding = \"\";\n for (let i = 0; i < paddingLength; i++) {\n padding += PADDING_CHARS[i % PADDING_CHARS.length];\n }\n\n return (\n `<div data-skip-in-text=\"true\" style=\"display:none;font-size:1px;color:#ffffff;line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;\">` +\n truncated +\n padding +\n `</div>`\n );\n}\n\n// ============================================\n// Body exporter wrapper (inlined from shared/utils/render-container-to-html.ts)\n// ============================================\n\ntype ContainerExporterFunction = (innerHTML: string, values: Record<string, any>, bodyValues?: Record<string, any>, options?: Record<string, any>) => string;\n\nfunction renderBodyToHtml(innerHTML: string, values: any, mode: RenderMode, previewText?: string): string {\n // Prepend preview text HTML in email mode\n let finalInnerHtml = innerHTML;\n if (mode === \"email\" && previewText) {\n const previewHtml = generatePreviewHtml(previewText);\n if (previewHtml) {\n finalInnerHtml = previewHtml + innerHTML;\n }\n }\n\n const bodyExporter = (BodyExporters[mode] || BodyExporters.web) as ContainerExporterFunction;\n // The email body exporter reads body context (contentWidth, contentAlign)\n // from `arg3.bodyValues` — it drives the Outlook (MSO) container table width.\n // Passing `values` directly left `bodyValues` undefined, pinning the Outlook\n // table to 600px regardless of contentWidth (modern clients were fine via the\n // container max-width, so non-600px emails rendered narrow only in Outlook).\n const raw =\n mode === \"document\"\n ? bodyExporter(finalInnerHtml, values, { type: \"\" })\n : mode === \"email\"\n ? // The email body exporter reads body context (contentWidth,\n // contentAlign) from the `bodyValues` field of its 3rd argument.\n // Passing `values` directly left it undefined, so the Outlook (MSO)\n // table fell back to 600px regardless of contentWidth.\n bodyExporter(finalInnerHtml, values, { bodyValues: values })\n : bodyExporter(finalInnerHtml, values, values);\n\n return raw\n .replace('min-height: 100vh; ', '')\n .replace('min-height: 100vh;', '');\n}\n\n// ============================================\n// Component\n// ============================================\n\n/**\n * Body - Universal Server/Client Component\n *\n * Works in both Server Components and Client Components.\n * In Server Components, pass config as a prop.\n * In Client Components, config can come from UnlayerProvider context or props.\n *\n * @example Server Component\n * ```tsx\n * <Body backgroundColor=\"#F7F8F9\" contentWidth=\"600px\" mode=\"web\">\n * <Row><Column><Paragraph values={{...}} mode=\"web\" /></Column></Row>\n * </Body>\n * ```\n *\n * @example Client Component with Provider\n * ```tsx\n * <UnlayerProvider config={{ mode: \"email\" }}>\n * <Body>...</Body>\n * </UnlayerProvider>\n * ```\n */\nconst Body: React.FC<BodyProps> = (props) => {\n const { children, mode: modeProp, className, style, index = 0, config: configProp, previewText, ...semanticProps } = props;\n\n // Resolve config: explicit prop > default (no hooks, Server Component safe)\n const resolvedConfig: UnlayerConfig = { ...DEFAULT_CONFIG, ...configProp };\n\n // Resolve mode: explicit prop > config > default\n const mode: RenderMode = modeProp ?? resolvedConfig.mode ?? \"web\";\n\n // Build _config to thread through children. Reset the per-render id counters so\n // unique ids are allocated across the whole tree (shared by reference downward).\n const _config: UnlayerConfig = { ...resolvedConfig, mode };\n (_config as { __ids?: Record<string, number> }).__ids = {};\n\n // Map semantic props, then merge BODY_DEFAULTS on top so the body always\n // carries its full default values (notably contentWidth \"500px\", textColor\n // \"#000000\") before rendering — the same way item components merge their\n // defaults. Without this the body exporter / grid CSS fall back to their own\n // internal defaults (e.g. 600px) instead of the schema default, so the\n // Outlook table, container, and grid CSS disagree. Mapped values win.\n const values = mergeValues<BodyValues>(\n DEFAULT_VALUES,\n mapSemanticProps<BodyValues>(semanticProps as SemanticProps<BodyValues>, DEFAULT_VALUES, \"Body\")\n );\n\n // Ensure _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: nextHtmlId(_config, \"u_body\"),\n htmlClassNames: \"u_body\",\n ...(values._meta || {})\n }\n };\n\n // Clone children with _config AND the body's resolved values so Row/Column\n // inherit body-level context — notably `contentWidth`, which determines the\n // row container max-width (and therefore each column's width) in web mode.\n // Without this, Row falls back to BODY_DEFAULTS.contentWidth (\"500px\") and\n // <Body contentWidth=\"…\"> is silently ignored for layout.\n let enrichedChildren = children;\n if (children) {\n enrichedChildren = React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child as React.ReactElement<any>, {\n _config,\n bodyValues: values,\n });\n }\n return child;\n });\n }\n\n // Process children to innerHTML\n let innerHTML = \"\";\n if (enrichedChildren) {\n try {\n innerHTML = ReactDOMServer.renderToString(enrichedChildren as React.ReactElement);\n } catch (error) {\n console.error(\"Body: Failed to render children:\", error);\n innerHTML = \"\";\n }\n }\n\n try {\n const html = renderBodyToHtml(innerHTML, valuesWithMeta, mode, previewText);\n\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n className={className}\n style={style}\n />\n );\n } catch (error) {\n console.error(\"Body rendering failed:\", error);\n return (\n <div className={className} style={style}>\n {children}\n </div>\n );\n }\n};\n\nBody.displayName = \"Body\";\n\nexport default Body;\n","import Body, { type BodyProps } from \"./Body\";\n\nexport type EmailProps = Omit<BodyProps, \"mode\">;\n\n/**\n * Email - Renders email-client safe HTML (tables for Outlook, Gmail, Yahoo).\n *\n * Thin wrapper around Body with mode locked to \"email\".\n *\n * @example\n * ```tsx\n * <Email backgroundColor=\"#f4f4f5\" contentWidth=\"560px\" previewText=\"Welcome!\">\n * <Row><Column><Paragraph text=\"Hello\" /></Column></Row>\n * </Email>\n * ```\n */\nexport default function Email(props: EmailProps) {\n return <Body {...props} mode=\"email\" />;\n}\n\nEmail.displayName = \"Email\";\n","import Body, { type BodyProps } from \"./Body\";\n\nexport type PageProps = Omit<BodyProps, \"mode\">;\n\n/**\n * Page - Renders with div/flexbox for responsive web display.\n *\n * Thin wrapper around Body with mode locked to \"web\".\n *\n * @example\n * ```tsx\n * <Page backgroundColor=\"#ffffff\" contentWidth=\"960px\">\n * <Row><Column><Paragraph text=\"Hello\" /></Column></Row>\n * </Page>\n * ```\n */\nexport default function Page(props: PageProps) {\n return <Body {...props} mode=\"web\" />;\n}\n\nPage.displayName = \"Page\";\n","import Body, { type BodyProps } from \"./Body\";\n\nexport type DocumentProps = Omit<BodyProps, \"mode\">;\n\n/**\n * Document - Print-optimized rendering for PDF generation.\n *\n * Thin wrapper around Body with mode locked to \"document\".\n *\n * @example\n * ```tsx\n * <Document backgroundColor=\"#ffffff\" contentWidth=\"700px\">\n * <Row><Column><Paragraph text=\"Hello\" /></Column></Row>\n * </Document>\n * ```\n */\nexport default function Document(props: DocumentProps) {\n return <Body {...props} mode=\"document\" />;\n}\n\nDocument.displayName = \"Document\";\n","\"use client\";\n\nimport React, { createContext, useContext, useMemo } from \"react\";\nimport type { UnlayerConfig } from \"@unlayer-internal/shared-elements\";\nimport { DEFAULT_CONFIG } from \"@unlayer-internal/shared-elements\";\n\n/**\n * @internal Flag added to context value when a provider is active.\n * Used by item components to detect provider-without-Body usage.\n */\nexport const PROVIDER_ACTIVE_KEY = \"__unlayerProviderActive\";\n\n// Lazy-init: createContext is not available in React Server Component modules.\n// Deferring the call ensures it only runs when UnlayerProvider or\n// useUnlayerConfig is actually invoked (always in a client context).\nlet _UnlayerContext: React.Context<UnlayerConfig> | null = null;\nfunction getUnlayerContext(): React.Context<UnlayerConfig> {\n if (!_UnlayerContext) {\n _UnlayerContext = createContext<UnlayerConfig>(DEFAULT_CONFIG);\n }\n return _UnlayerContext;\n}\n\nexport interface UnlayerProviderProps {\n config: Partial<UnlayerConfig>;\n children: React.ReactNode;\n}\n\nexport const UnlayerProvider: React.FC<UnlayerProviderProps> = ({\n config,\n children,\n}) => {\n const merged = useMemo(\n () => ({ ...DEFAULT_CONFIG, ...config, [PROVIDER_ACTIVE_KEY]: true }),\n [config]\n );\n\n const Context = getUnlayerContext();\n return (\n <Context.Provider value={merged}>\n {children}\n </Context.Provider>\n );\n};\n\nUnlayerProvider.displayName = \"UnlayerProvider\";\n\nexport function useUnlayerConfig(): UnlayerConfig {\n return useContext(getUnlayerContext());\n}\n","/**\n * extractHeadFromTree — Walk a React element tree and collect <head> CSS/JS\n * from the exporters' head functions.\n *\n * Mirrors the editor's extractHead.ts but works with the React element tree\n * instead of the Redux design state. Uses the same pattern as render-to-json.ts\n * to walk Body > Row > Column > Item structure.\n */\n\nimport React from \"react\";\nimport { heads } from \"@unlayer/exporters\";\nimport { mergeValues } from \"@unlayer-internal/shared-elements\";\nimport type { RenderMode, HeadConfig } from \"@unlayer-internal/shared-elements\";\nimport { mapSemanticProps } from \"./semantic-props\";\nimport { UNLAYER_CONFIG_KEY } from \"./create-component\";\nimport { BODY_DEFAULTS, ROW_DEFAULTS, COLUMN_DEFAULTS } from \"./container-defaults\";\n\n/** Args every head builder receives: (values, bodyValues, meta). */\ntype HeadArgs = [Record<string, any>, Record<string, any>, Record<string, any>];\n\n/**\n * Local type for a component's head contributions — the optional css/js/tags\n * builders this file invokes to collect the <head> CSS/JS/tags.\n */\ntype ComponentHead = {\n css?: (...args: HeadArgs) => string | undefined;\n js?: (...args: HeadArgs) => string | undefined;\n tags?: (...args: HeadArgs) => string[] | undefined;\n};\n\n// ============================================\n// Inlined helpers\n// ============================================\n\n/** Add _meta fields if not present. */\nfunction ensureMeta(values: any, type: string, index: number = 0): any {\n return {\n ...values,\n _meta: {\n htmlID: `u_content_${type.toLowerCase()}_${index + 1}`,\n htmlClassNames: `u_content_${type.toLowerCase()}`,\n ...(values._meta || {})\n }\n };\n}\n\n/** Get the displayName of a React element's component type. */\nfunction getDisplayName(element: React.ReactElement): string | undefined {\n const type = element.type as any;\n return type?.displayName || type?.name;\n}\n\n/** Collect valid React element children from a node. */\nfunction collectChildren(node: React.ReactNode): React.ReactElement[] {\n const result: React.ReactElement[] = [];\n React.Children.forEach(node, (child) => {\n if (React.isValidElement(child)) {\n result.push(child);\n }\n });\n return result;\n}\n\n/**\n * Strip internal/base props from an element's props,\n * returning only the semantic props that should be mapped to values.\n */\nfunction extractSemanticProps(\n props: Record<string, any>,\n extraKeys: string[] = []\n): Record<string, any> {\n const internalKeys = new Set([\n \"children\",\n \"mode\",\n \"className\",\n \"style\",\n \"index\",\n \"colIndex\",\n \"cells\",\n \"bodyValues\",\n \"rowValues\",\n \"_config\",\n \"config\",\n \"previewText\",\n \"layout\",\n \"collection\",\n ...extraKeys,\n ]);\n\n const result: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!internalKeys.has(key) && value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\n/** Increment and return counter for a given key. */\nfunction nextCounter(counters: Record<string, number>, key: string): number {\n counters[key] = (counters[key] || 0) + 1;\n return counters[key];\n}\n\n// ============================================\n// Types\n// ============================================\n\nexport interface ExtractHeadResult {\n /** Combined CSS from all head functions */\n css: string;\n /** Combined JS from all head functions */\n js: string;\n /** Unique HTML tags (meta, link, etc.) from all head functions */\n tags: string[];\n}\n\nexport interface ExtractHeadOptions {\n /** Display mode for rendering */\n displayMode: RenderMode;\n /** Optional head config for feature flags and initial values */\n headConfig?: HeadConfig;\n}\n\n/**\n * Call a head's css/js/tags functions and collect the results.\n */\nfunction callHead(\n head: ComponentHead | undefined,\n values: Record<string, any>,\n bodyValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n if (!head) return;\n\n const headArgs: [Record<string, any>, Record<string, any>, Record<string, any>] = [\n values,\n bodyValues,\n {\n displayMode,\n isViewer: false,\n variant: null,\n type: \"rows\",\n headConfig,\n },\n ];\n\n const css = head.css?.(...headArgs);\n if (css) styles.push(css);\n\n const js = head.js?.(...headArgs);\n if (js) scripts.push(js);\n\n const headTags = head.tags?.(...headArgs);\n if (headTags) tags.push(...headTags);\n}\n\n// ============================================\n// Tree walkers\n// ============================================\n\nfunction walkItem(\n element: React.ReactElement,\n bodyValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n counters: Record<string, number>,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n const componentType = element.type as any;\n const config = componentType[UNLAYER_CONFIG_KEY];\n if (!config) return;\n\n const { name, defaultValues, propMapper } = config;\n\n // Map and merge values (same as render-to-json and create-component)\n const { children, ...restProps } = element.props;\n const mappedValues = propMapper({ children, ...restProps });\n const finalValues = mergeValues(defaultValues, mappedValues);\n\n // Track component index (same counter pattern as render-to-json.ts)\n const contentType = name.toLowerCase();\n const count = nextCounter(counters, `u_content_${contentType}`);\n const valuesWithMeta = ensureMeta(finalValues, contentType, count - 1);\n\n // Look up head by component name\n const head = (heads as Record<string, ComponentHead | undefined>)[name];\n callHead(head, valuesWithMeta, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n}\n\nfunction walkColumn(\n element: React.ReactElement,\n bodyValues: Record<string, any>,\n rowValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n counters: Record<string, number>,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n // Column head\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, COLUMN_DEFAULTS, \"Column\");\n const count = nextCounter(counters, \"u_column\");\n const columnValues = ensureMeta(mergeValues(COLUMN_DEFAULTS, mapped), \"column\", count - 1);\n\n const columnHead = (heads as Record<string, ComponentHead | undefined>)[\"Column\"];\n callHead(columnHead, columnValues, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n // Walk item children\n const children = collectChildren(element.props.children);\n for (const child of children) {\n walkItem(child, bodyValues, displayMode, headConfig, counters, styles, scripts, tags);\n }\n}\n\nfunction walkRow(\n element: React.ReactElement,\n bodyValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n counters: Record<string, number>,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n // Row head\n const semanticProps = extractSemanticProps(element.props, [\"layout\"]);\n const mapped = mapSemanticProps(semanticProps, ROW_DEFAULTS, \"Row\");\n const count = nextCounter(counters, \"u_row\");\n const rowValues = ensureMeta(mergeValues(ROW_DEFAULTS, mapped), \"row\", count - 1);\n\n const rowHead = (heads as Record<string, ComponentHead | undefined>)[\"Row\"];\n callHead(rowHead, rowValues, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n // Walk column children\n const children = collectChildren(element.props.children);\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Column\") {\n walkColumn(child, bodyValues, rowValues, displayMode, headConfig, counters, styles, scripts, tags);\n }\n }\n}\n\n// ============================================\n// Public API\n// ============================================\n\n/**\n * Extract head CSS/JS/tags from a React element tree.\n *\n * Walks the tree statically (same approach as renderToJson) and calls\n * each component's head function from @unlayer/exporters.\n *\n * @param element - Root element (Body, Email, Page, or Document)\n * @param options - Display mode and optional head config\n * @returns Combined CSS, JS, and tags from all head functions\n */\nexport function extractHeadFromTree(\n element: React.ReactElement,\n options: ExtractHeadOptions\n): ExtractHeadResult {\n const { displayMode } = options;\n const headConfig: HeadConfig = {\n hasFeature: options.headConfig?.hasFeature ?? (() => false),\n getInitialValues: options.headConfig?.getInitialValues ?? (() => ({})),\n };\n\n const styles: string[] = [];\n const scripts: string[] = [];\n const tags: string[] = [];\n const counters: Record<string, number> = {};\n\n // Extract body values\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, BODY_DEFAULTS, \"Body\");\n const bodyValues = ensureMeta(mergeValues(BODY_DEFAULTS, mapped), \"body\", 0);\n\n // Body head\n const bodyHead = (heads as Record<string, ComponentHead | undefined>)[\"Body\"];\n callHead(bodyHead, bodyValues, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n // Walk rows\n const children = collectChildren(element.props.children);\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Row\") {\n walkRow(child, bodyValues, displayMode, headConfig, counters, styles, scripts, tags);\n }\n }\n\n // Deduplicate tags\n const uniqueTags = [...new Set(tags.filter(Boolean))];\n\n return {\n css: styles.filter(Boolean).join(\"\\n\"),\n js: scripts.filter(Boolean).join(\"\\n\"),\n tags: uniqueTags,\n };\n}\n","import React from \"react\";\nimport { renderToStaticMarkup } from \"react-dom/server\";\nimport type { UnlayerConfig } from \"@unlayer-internal/shared-elements\";\nimport { DEFAULT_CONFIG } from \"@unlayer-internal/shared-elements\";\nimport { htmlToPlainText } from \"@unlayer-internal/shared-elements\";\nimport type { RenderMode } from \"@unlayer-internal/shared-elements\";\nimport { extractHeadFromTree } from \"./extract-head\";\n\n/**\n * Renders an Unlayer element tree to an HTML string.\n *\n * - Passes merged config via the `config` prop (no React context — works in Server Components)\n * - Uses `renderToStaticMarkup` — no React hydration markers, clean HTML for email/PDF\n * - Synchronous\n *\n * @param element - A React element tree (e.g. `<Body><Row>...</Row></Body>`)\n * @param config - Optional config overrides (mode, cdnBaseUrl, etc.)\n * @returns Clean HTML string\n * @throws {Error} If rendering fails, with a helpful message\n *\n * @example\n * ```tsx\n * import { renderToHtml, Body, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const html = renderToHtml(\n * <Body><Row><Column><Paragraph>Hello</Paragraph></Column></Row></Body>,\n * { mode: \"email\", cdnBaseUrl: \"https://my-cdn.com\" }\n * );\n * ```\n */\nexport function renderToHtml(\n element: React.ReactElement,\n config?: Partial<UnlayerConfig>\n): string {\n const mergedConfig = { ...DEFAULT_CONFIG, ...config };\n\n try {\n // Pass config via prop (not context) so this works in React Server Components.\n // Body reads `config` prop and threads it as `_config` to children via cloneElement.\n const enriched = React.cloneElement(element, { config: mergedConfig });\n return renderToStaticMarkup(enriched);\n } catch (error) {\n const message =\n error instanceof Error ? error.message : String(error);\n throw new Error(\n `[Unlayer] renderToHtml failed: ${message}\\n` +\n `Tip: Ensure your tree uses Body > Row > Column > Item structure.`\n );\n }\n}\n\n/**\n * Renders an Unlayer element tree to a plain text string.\n *\n * Internally calls `renderToHtml` then converts to plain text using\n * `htmlToPlainText`. Useful for generating the text/plain MIME part\n * of multipart emails (critical for deliverability).\n *\n * @param element - A React element tree (e.g. `<Body><Row>...</Row></Body>`)\n * @param config - Optional config overrides (mode, cdnBaseUrl, etc.)\n * @returns Plain text representation of the email\n *\n * @example\n * ```tsx\n * import { renderToPlainText, Body, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const text = renderToPlainText(\n * <Body mode=\"email\"><Row><Column><Paragraph>Hello World</Paragraph></Column></Row></Body>\n * );\n * // \"Hello World\"\n * ```\n */\nexport function renderToPlainText(\n element: React.ReactElement,\n config?: Partial<UnlayerConfig>\n): string {\n const html = renderToHtml(element, config);\n return htmlToPlainText(html);\n}\n\n/**\n * Result of renderToHtmlParts — head and body as separate strings.\n */\nexport interface HtmlParts {\n /** `<head>` content: `<style>` blocks with component CSS, optional `<script>` tags */\n head: string;\n /** `<body>` content: the rendered HTML (same output as `renderToHtml`) */\n body: string;\n}\n\n/**\n * Renders an Unlayer element tree to separate head and body HTML strings.\n *\n * This is the recommended API for sending emails, because email clients need\n * the `<style>` block in `<head>` for hover effects, responsive breakpoints,\n * and font declarations that cannot be expressed as inline styles.\n *\n * - `head` contains `<style>` tags with CSS generated by each component's\n * head function (button hover colors, body fonts, link styles, etc.)\n * - `body` is identical to what `renderToHtml()` returns\n *\n * @param element - A React element tree (e.g. `<Email><Row>...</Row></Email>`)\n * @param config - Optional config overrides (mode, cdnBaseUrl, etc.)\n * @returns `{ head, body }` — drop these into your HTML document template\n *\n * @example\n * ```tsx\n * import { renderToHtmlParts, Email, Row, Column, Button } from \"@unlayer/react-elements\";\n *\n * const { head, body } = renderToHtmlParts(\n * <Email>\n * <Row><Column><Button>Click</Button></Column></Row>\n * </Email>\n * );\n *\n * const html = `<!DOCTYPE html>\n * <html><head>${head}</head>${body}</html>`;\n * ```\n */\nexport function renderToHtmlParts(\n element: React.ReactElement,\n config?: Partial<UnlayerConfig>\n): HtmlParts {\n // Render body HTML (same as renderToHtml)\n const body = renderToHtml(element, config);\n\n // Resolve display mode from config or element props\n const mergedConfig = { ...DEFAULT_CONFIG, ...config };\n const displayMode: RenderMode =\n (element.props as any).mode ?? mergedConfig.mode ?? \"web\";\n\n // Extract head CSS/JS/tags by walking the element tree\n const { css, js, tags } = extractHeadFromTree(element, {\n displayMode,\n headConfig: mergedConfig.headConfig,\n });\n\n // Build head string\n const headParts: string[] = [];\n\n if (css) {\n headParts.push(`<style>${css}</style>`);\n }\n\n if (js) {\n headParts.push(`<script>${js}</script>`);\n }\n\n if (tags.length > 0) {\n headParts.push(...tags);\n }\n\n return {\n head: headParts.join(\"\\n\"),\n body,\n };\n}\n","/**\n * renderToJson — Convert a React element tree to Unlayer's DesignJSON format.\n *\n * Walks the React element tree statically via React.Children and extracts\n * values at each level. No HTML rendering is performed.\n *\n * Produces the { body: { rows, values }, counters, schemaVersion } structure\n * that the Unlayer editor uses, enabling round-tripping: build with React\n * components → export as JSON → load into the Unlayer editor.\n */\n\nimport React from \"react\";\nimport type {\n DesignJSON,\n DesignBody,\n DesignRow,\n DesignColumn,\n DesignContent,\n} from \"@unlayer-internal/shared-elements\";\nimport { mergeValues } from \"@unlayer-internal/shared-elements\";\n// Schema version from the exporters bundle — matches the editor's currentVersion\n// at the time the exporters were generated. This ensures renderToJson output is\n// recognized as current by the editor, skipping unnecessary migrations.\n// Falls back to 24 for older exporters packages that don't export this yet.\nimport { schemaVersion as _schemaVersion } from \"@unlayer/exporters\";\nconst schemaVersion: number = _schemaVersion ?? 24;\nimport { mapSemanticProps } from \"./semantic-props\";\nimport { UNLAYER_CONFIG_KEY } from \"./create-component\";\nimport { BODY_DEFAULTS, ROW_DEFAULTS, COLUMN_DEFAULTS } from \"./container-defaults\";\nimport { contentSlotWidth, pinImageSrc, type SlotContext } from \"./image-sizing\";\n\n/** Layout context threaded down the walk so an image can be sized against the\n * real column slot (contentWidth × column share, minus paddings/borders). */\ntype LayoutContext = Pick<\n SlotContext,\n \"bodyValues\" | \"rowValues\" | \"rowCells\" | \"columnIndex\" | \"columnValues\"\n>;\n\n// ============================================\n// Tree helpers (inlined)\n// ============================================\n\n/** Get the displayName of a React element's component type. */\nfunction getDisplayName(element: React.ReactElement): string | undefined {\n const type = element.type as any;\n return type?.displayName || type?.name;\n}\n\n/** The root components renderToJson understands. */\nconst VALID_ROOTS = new Set([\"Body\", \"Email\", \"Page\", \"Document\"]);\n\n/**\n * Unwrap a user wrapper component down to the underlying root element.\n * `renderToHtml` renders wrappers through React; `renderToJson` walks the element\n * tree, so a custom component that *returns* <Email>/<Body>/<Page>/<Document>\n * (e.g. `renderToJson(<MyEmail/>)`) must be invoked first. Only plain function\n * components are unwrapped — anything else (class / forwardRef / memo) falls\n * through to the clear root-type error.\n */\nfunction unwrapRoot(element: React.ReactElement): React.ReactElement {\n let current = element;\n for (let depth = 0; depth < 10; depth++) {\n const name = getDisplayName(current);\n if (name && VALID_ROOTS.has(name)) break;\n const type = current.type as any;\n const isPlainFunctionComponent =\n typeof type === \"function\" && !type.prototype?.isReactComponent;\n if (!isPlainFunctionComponent) break;\n // Invoking the wrapper can throw (e.g. it uses React hooks, which aren't\n // valid when called outside React's render). Turn that into an actionable\n // message instead of a bare \"Invalid hook call\".\n let produced: unknown;\n try {\n produced = type({ ...(current.props as Record<string, unknown>) });\n } catch (cause) {\n const detail = cause instanceof Error ? cause.message : String(cause);\n throw new Error(\n `[Unlayer] renderToJson: could not unwrap <${name || \"wrapper\"}>. A wrapper must ` +\n `be a plain component that synchronously returns a root (<Email>, <Page>, ` +\n `<Document>, or <Body>) and uses no React hooks. Pass the root element directly — ` +\n `e.g. renderToJson(<Email>…</Email>). (${detail})`\n );\n }\n if (!React.isValidElement(produced)) break;\n current = produced;\n }\n return current;\n}\n\n/** Collect valid React element children from a node. */\nfunction collectChildren(node: React.ReactNode): React.ReactElement[] {\n const result: React.ReactElement[] = [];\n React.Children.forEach(node, (child) => {\n if (React.isValidElement(child)) {\n result.push(child);\n }\n });\n return result;\n}\n\n/**\n * Strip internal/base props from an element's props,\n * returning only the semantic props that should be mapped to values.\n */\nfunction extractSemanticProps(\n props: Record<string, any>,\n extraKeys: string[] = []\n): Record<string, any> {\n const internalKeys = new Set([\n \"children\",\n \"mode\",\n \"className\",\n \"style\",\n \"index\",\n \"colIndex\",\n \"cells\",\n \"bodyValues\",\n \"rowValues\",\n \"_config\",\n \"config\",\n \"previewText\",\n \"layout\",\n \"collection\",\n ...extraKeys,\n ]);\n\n const result: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!internalKeys.has(key) && value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\n/** Increment and return counter for a given key. */\nfunction nextCounter(counters: Record<string, number>, key: string): number {\n counters[key] = (counters[key] || 0) + 1;\n return counters[key];\n}\n\n// ============================================\n// Helpers\n// ============================================\n\n/** Map component displayName to Unlayer content type.\n * Paragraph maps to \"text\" (the legacy content type that uses plain HTML\n * values.text) for universal editor compatibility. The newer \"paragraph\"\n * content type uses Lexical textJson which requires specific editor support.\n */\nfunction toContentType(displayName: string): string {\n if (displayName === \"Paragraph\") return \"text\";\n return displayName.toLowerCase();\n}\n\n/** Generate a unique ID like \"u_row_1\", \"u_content_button_2\" */\nfunction makeId(prefix: string, counter: number): string {\n return `${prefix}_${counter}`;\n}\n\n/**\n * Extract plain text/HTML from a textJson string without needing a DOM.\n * Handles both Lexical JSON format and the __html passthrough format.\n */\nfunction extractTextFromTextJson(textJson: string): string {\n try {\n const parsed = JSON.parse(textJson);\n\n // __html passthrough (from htmlToTextJson)\n if (parsed.__html) return parsed.__html;\n\n // Lexical JSON — walk the tree and extract text content\n const root = parsed?.root;\n if (!root?.children) return \"\";\n\n const paragraphs: string[] = [];\n for (const paragraph of root.children) {\n if (!paragraph?.children) continue;\n const parts: string[] = [];\n for (const node of paragraph.children) {\n if (node?.text) parts.push(node.text);\n }\n paragraphs.push(parts.join(\"\"));\n }\n return paragraphs.join(\"\\n\");\n } catch {\n return \"\";\n }\n}\n\n// ============================================\n// Tree processors\n// ============================================\n\nfunction processItem(\n element: React.ReactElement,\n counters: Record<string, number>,\n layout: LayoutContext = {}\n): DesignContent {\n const componentType = element.type as any;\n const config = componentType[UNLAYER_CONFIG_KEY];\n\n if (!config) {\n const name = getDisplayName(element) || \"Unknown\";\n throw new Error(\n `[Unlayer] renderToJson: <${name}> is not a recognized Unlayer item component. ` +\n `Only components created with createItemComponent are supported.`\n );\n }\n\n const { name, defaultValues, propMapper } = config;\n const contentType = toContentType(name);\n const count = nextCounter(counters, `u_content_${contentType}`);\n const id = makeId(`u_content_${contentType}`, count);\n\n // Map props through the item's own propMapper, then merge with defaults\n const { children, ...restProps } = element.props;\n const mappedValues = propMapper({ children, ...restProps });\n const finalValues = mergeValues(defaultValues, mappedValues);\n\n // Paragraph maps to \"text\" content type — convert textJson to plain text/HTML.\n // Extract text directly from the Lexical JSON structure (no DOM needed).\n if (contentType === \"text\" && finalValues.textJson) {\n finalValues.text = extractTextFromTextJson(finalValues.textJson);\n delete finalValues.textJson;\n }\n\n // Add containerPadding (base content option) and _meta\n const values = {\n containerPadding: \"10px\",\n ...finalValues,\n _meta: {\n htmlID: id,\n htmlClassNames: `u_content_${contentType}`,\n ...(finalValues._meta || {}),\n },\n selectable: true,\n draggable: true,\n duplicatable: true,\n deletable: true,\n hideable: true,\n };\n\n // Convert a fixed (px) image pin to a percent of the column slot using the\n // threaded geometry, so the display width survives the JSON round-trip into an\n // editor. Guarded on `src.autoWidth === false`, so only pinned images change.\n const itemSrc = (values as Record<string, any>).src;\n if (itemSrc && typeof itemSrc === \"object\" && itemSrc.autoWidth === false) {\n const availableWidth = contentSlotWidth({\n ...layout,\n containerPadding: (values as Record<string, any>).containerPadding,\n });\n (values as Record<string, any>).src = pinImageSrc(itemSrc, availableWidth);\n }\n\n return { type: contentType, values };\n}\n\nfunction processColumn(\n element: React.ReactElement,\n counters: Record<string, number>,\n layout: Omit<LayoutContext, \"columnValues\"> = {}\n): DesignColumn {\n const count = nextCounter(counters, \"u_column\");\n const id = makeId(\"u_column\", count);\n\n // Extract semantic props for column values, then merge with defaults\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, COLUMN_DEFAULTS, \"Column\");\n const values = mergeValues(COLUMN_DEFAULTS, mapped);\n\n // Add _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: id,\n htmlClassNames: \"u_column\",\n ...(values._meta || {}),\n },\n };\n\n // Process item children\n const contents: DesignContent[] = [];\n const children = collectChildren(element.props.children);\n\n const itemLayout: LayoutContext = { ...layout, columnValues: valuesWithMeta };\n for (const child of children) {\n contents.push(processItem(child, counters, itemLayout));\n }\n\n return { contents, values: valuesWithMeta };\n}\n\nfunction processRow(\n element: React.ReactElement,\n counters: Record<string, number>,\n parentLayout: Pick<LayoutContext, \"bodyValues\"> = {}\n): DesignRow {\n const count = nextCounter(counters, \"u_row\");\n const id = makeId(\"u_row\", count);\n\n // Determine cells from layout or cells prop\n const { layout, cells: propsCells } = element.props;\n let cells: number[];\n if (layout) {\n cells = layout.cells;\n } else if (propsCells) {\n cells = propsCells;\n } else {\n // Default: one equal cell per Column child. Count only <Column> children —\n // any stray non-Column child is warned and skipped below, so including it\n // would make `cells` longer than the column list and distort both the row\n // layout and the column-share math used for image sizing.\n const columnCount = Math.max(\n 1,\n collectChildren(element.props.children).filter(\n (child) => getDisplayName(child) === \"Column\"\n ).length\n );\n cells = Array(columnCount).fill(1);\n }\n\n // Extract semantic props for row values, then merge with defaults\n const semanticProps = extractSemanticProps(element.props, [\"layout\"]);\n const mapped = mapSemanticProps(semanticProps, ROW_DEFAULTS, \"Row\");\n const values = mergeValues(ROW_DEFAULTS, mapped);\n\n // Add cells, columns flag, editor flags, and _meta\n const valuesWithMeta = {\n ...values,\n columns: values.columns ?? false,\n cells,\n _meta: {\n htmlID: id,\n htmlClassNames: \"u_row\",\n ...(values._meta || {}),\n },\n selectable: true,\n draggable: true,\n duplicatable: true,\n deletable: true,\n hideable: true,\n };\n\n // Process Column children\n const columns: DesignColumn[] = [];\n const children = collectChildren(element.props.children);\n\n const columnLayout: Omit<LayoutContext, \"columnValues\"> = {\n bodyValues: parentLayout.bodyValues,\n rowValues: valuesWithMeta,\n rowCells: cells,\n };\n let columnIndex = 0;\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Column\") {\n columns.push(\n processColumn(child, counters, { ...columnLayout, columnIndex })\n );\n columnIndex += 1;\n } else {\n console.warn(\n `[Unlayer] renderToJson: <${name}> is not a valid Row child. Only <Column> is allowed.`\n );\n }\n }\n\n return { cells, columns, values: valuesWithMeta };\n}\n\nfunction processBody(\n element: React.ReactElement,\n counters: Record<string, number>\n): DesignBody {\n const id = \"u_body\";\n\n // Extract semantic props for body values, then merge with defaults\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, BODY_DEFAULTS, \"Body\");\n const values = mergeValues(BODY_DEFAULTS, mapped);\n\n // `previewText` is the React alias for the schema's `preheaderText`. It is\n // excluded from the mapped values (it drives the email preview HTML at render\n // time), so thread it into the JSON here so it is preserved in the output.\n const previewText = (element.props as { previewText?: string }).previewText;\n if (previewText !== undefined) {\n (values as Record<string, unknown>).preheaderText = previewText;\n }\n\n // Add _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: id,\n htmlClassNames: \"u_body\",\n ...(values._meta || {}),\n },\n };\n\n // Process Row children\n const rows: DesignRow[] = [];\n const children = collectChildren(element.props.children);\n\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Row\") {\n rows.push(processRow(child, counters, { bodyValues: valuesWithMeta }));\n } else {\n console.warn(\n `[Unlayer] renderToJson: <${name}> is not a valid Body child. Only <Row> is allowed.`\n );\n }\n }\n\n return {\n rows,\n values: valuesWithMeta,\n } as DesignBody;\n}\n\n// ============================================\n// Public API\n// ============================================\n\n/**\n * Convert a React element tree to Unlayer's DesignJSON format.\n *\n * The root element must be a `<Body>`, `<Email>`, `<Page>`, or `<Document>`.\n * The tree is walked statically — no HTML rendering is performed.\n *\n * @param element - A React element tree with Body > Row > Column > Item structure\n * @returns DesignJSON object compatible with the Unlayer editor\n * @throws {Error} If the root element is not a recognized container component\n *\n * @example\n * ```tsx\n * import { renderToJson, Body, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const design = renderToJson(\n * <Body backgroundColor=\"#ffffff\" contentWidth=\"600px\">\n * <Row>\n * <Column>\n * <Paragraph>Hello World</Paragraph>\n * </Column>\n * </Row>\n * </Body>\n * );\n * ```\n */\n/**\n * Convert a single `<Row>` element to Unlayer's row JSON format.\n *\n * Use this when targeting a Block Editor, which works with individual rows\n * rather than full design JSON. For full designs, use `renderToJson` instead.\n *\n * @param element - A React element tree with Row > Column > Item structure\n * @returns A DesignRow object compatible with the Unlayer block editor\n * @throws {Error} If the element is not a `<Row>`\n *\n * @example\n * ```tsx\n * import { renderRowToJson, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const row = renderRowToJson(\n * <Row>\n * <Column>\n * <Paragraph>Hello World</Paragraph>\n * </Column>\n * </Row>\n * );\n * ```\n */\nexport function renderRowToJson(element: React.ReactElement): DesignRow {\n const displayName = getDisplayName(element);\n\n if (displayName !== \"Row\") {\n throw new Error(\n `[Unlayer] renderRowToJson: Element must be <Row>, ` +\n `but got <${displayName || \"unknown\"}>. ` +\n `For full designs, use renderToJson instead.`\n );\n }\n\n const counters: Record<string, number> = {};\n return processRow(element, counters);\n}\n\nexport function renderToJson(element: React.ReactElement): DesignJSON {\n // Accept a user wrapper component (e.g. <MyEmail/>) by unwrapping to its root,\n // matching renderToHtml which renders wrappers through React.\n element = unwrapRoot(element);\n const displayName = getDisplayName(element);\n\n if (!displayName || !VALID_ROOTS.has(displayName)) {\n throw new Error(\n `[Unlayer] renderToJson: Root element must be <Body>, <Email>, <Page>, or <Document>, ` +\n `but got <${displayName || \"unknown\"}>. ` +\n `Wrap your content: <Body><Row><Column>...</Column></Row></Body>`\n );\n }\n\n // Email/Page/Document are thin wrappers around Body — for JSON purposes,\n // we treat them identically: extract props directly from the wrapper element.\n // The wrapper's own render function would re-render as Body, but we don't\n // call render — we just walk the element tree.\n\n // For Email/Page/Document, the children and semantic props are on the\n // wrapper element directly, same as Body.\n const counters: Record<string, number> = {};\n const body = processBody(element, counters);\n\n return {\n counters,\n body,\n schemaVersion,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/image-sizing.ts","../../shared/src/config.ts","../../shared/src/layouts.ts","../../shared/src/utils/lexical-helpers.ts","../../shared/src/utils/merge-values.ts","../../shared/src/utils/semantic-props.ts","../../shared/src/utils/html-to-text.ts","../src/utils/create-component.tsx","../src/components/Button.tsx","../src/components/Divider.tsx","../src/components/Heading.tsx","../src/components/Html.tsx","../src/components/Image.tsx","../src/components/Menu.tsx","../src/components/Paragraph.tsx","../src/components/Social.tsx","../src/components/Table.tsx","../src/components/Video.tsx","../src/utils/container-defaults.ts","../src/components/Row.tsx","../src/components/Column.tsx","../src/components/Body.tsx","../src/components/Email.tsx","../src/components/Page.tsx","../src/components/Document.tsx","../src/context/UnlayerProvider.tsx","../src/utils/extract-head.ts","../src/utils/render-to-html.tsx","../src/utils/render-to-json.ts"],"names":["jsx","jsxs","ButtonDefaults","ButtonExporters","DEFAULT_VALUES","DividerDefaults","DividerExporters","HeadingDefaults","HeadingExporters","HtmlDefaults","HtmlExporters","ImageDefaults","ImageExporters","MenuDefaults","MenuExporters","ParagraphDefaults","ParagraphExporters","SocialDefaults","SocialExporters","TableDefaults","TableExporters","VideoDefaults","VideoExporters","BodyDefaults","RowDefaults","ColumnDefaults","RowExporters","React","DEFAULT_CONTAINER_PADDING","ColumnExporters","ContentExporters","BodyExporters","ReactDOMServer","createContext","useMemo","useContext","ensureMeta","heads","renderToStaticMarkup","_schemaVersion","getDisplayName","collectChildren","extractSemanticProps","nextCounter","name"],"mappings":";;;;;;;;;;;;;;;AAoBA,SAAS,KAAK,KAAA,EAAoC;AAChD,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU,OAAO,OAAO,QAAA,CAAS,KAAK,IAAI,KAAA,GAAQ,MAAA;AACvE,E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AA,CAAY,OAAA,EAAS,QAAQ,CAAA;AAE1C,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACF;AACF","file":"index.cjs","sourcesContent":["/**\n * Image display-width resolution.\n *\n * In Unlayer's value model an image's display size is `autoWidth` + `maxWidth`,\n * kept separate from the natural `src.width`/`height`. A fixed display size is\n * `autoWidth: false` with `maxWidth` as a PERCENT of the column's content slot\n * (e.g. `\"50%\"`) — not the natural-size field. Encoding a fixed width that way\n * keeps it stable when the design JSON is opened in an editor, which treats\n * `src.width`/`height` as the intrinsic dimensions and may refresh them.\n *\n * Authors pass pixels, so a px pin is captured as `{ autoWidth:false,\n * maxWidth:<px> }` and converted here to the equivalent percent using the same\n * available-width geometry the renderers use (contentWidth × column share, minus\n * paddings/borders), so the emitted value renders at the requested on-screen size.\n */\n\n/** Parse a CSS length to px, strictly: a number or a numeric string with an\n * optional px unit (\"12\" / \"12px\"). Non-px units (\"1.5em\", \"calc(…)\") return\n * undefined so the pinning pass leaves them untouched instead of misreading\n * them as px (SizeInput allows non-px CSS strings). */\nfunction toPx(value: unknown): number | undefined {\n if (typeof value === \"number\") return Number.isFinite(value) ? value : undefined;\n if (typeof value !== \"string\") return undefined;\n const m = /^(\\d+(?:\\.\\d+)?)(?:px)?$/.exec(value.trim());\n return m ? parseFloat(m[1]) : undefined;\n}\n\n// NOTE: the geometry parsers below use parseFloat on each token, intentionally\n// mirroring the renderer's explodePaddingsOrMargins / explodeBorder (which the\n// image exporter subtracts from the available width). The renderer reads a token\n// like \"10%\" as its numeric value (10), so the slot math must too — switching to\n// strict px parsing here would make the pinned percent diverge from what the\n// editor actually renders. Strict px parsing is only for the display-pin value\n// (toPx, in pinImageSrc), never for the geometry.\n\n/** Left/right edge sizes from a CSS box shorthand (padding/margin), parsed the\n * same way the renderer's explodePaddingsOrMargins does (parseFloat per token). */\nfunction edges(value: unknown): { left: number; right: number } {\n if (value == null) return { left: 0, right: 0 };\n if (typeof value === \"number\") return { left: value, right: value };\n const parts = String(value)\n .trim()\n .split(/\\s+/)\n .map((p) => parseFloat(p) || 0);\n // CSS order: 1 = all; 2 = [v h]; 3 = [t h b]; 4 = [t r b l].\n if (parts.length === 1) return { left: parts[0], right: parts[0] };\n if (parts.length === 2 || parts.length === 3)\n return { left: parts[1], right: parts[1] };\n return { left: parts[3] || 0, right: parts[1] || 0 };\n}\n\n/** Left/right border widths from a per-side border object, parsed the same way\n * the renderer's explodeBorder does (parseFloat per width). */\nfunction borderEdges(border: unknown): { left: number; right: number } {\n if (!border || typeof border !== \"object\") return { left: 0, right: 0 };\n const b = border as Record<string, unknown>;\n const width = (v: unknown) => parseFloat(`${v ?? \"\"}`) || 0;\n return {\n left: width(b.borderLeftWidth),\n right: width(b.borderRightWidth),\n };\n}\n\n/** A body `contentWidth` is \"fixed px\" only when it's a number or a numeric\n * string with an optional px unit (`600`, `\"600px\"`, or `\"600\"`). Percentages\n * and keywords like `\"auto\"` are NOT fixed → `undefined`. */\nfunction fixedContentWidth(contentWidth: unknown): number | undefined {\n if (typeof contentWidth === \"number\")\n return Number.isFinite(contentWidth) ? contentWidth : undefined;\n if (typeof contentWidth === \"string\") {\n const m = /^(\\d+(?:\\.\\d+)?)(?:px)?$/.exec(contentWidth.trim());\n if (m) return parseFloat(m[1]);\n }\n return undefined;\n}\n\n/** Unlayer's body content width fallback when `contentWidth` isn't fixed px. */\nconst FALLBACK_BODY_CONTENT_WIDTH = 500;\n/** Unlayer's default content-block padding when a block sets none. */\nconst DEFAULT_CONTAINER_PADDING = \"10px\";\n\n/**\n * A body `contentWidth` resolved to px: the fixed px value, or `fallback`\n * (500, Unlayer's base width) for non-px values like `\"50%\"` / `\"auto\"`.\n *\n * Shared with Row's grid CSS (`toContentWidthPx`) so the slot geometry here and\n * the renderer's column math agree on what counts as a fixed width — and so a\n * non-px `contentWidth` collapses to the same base everywhere instead of being\n * `parseInt`-ed into a bogus px value (e.g. `\"50%\"` → 50).\n */\nexport function bodyContentWidthPx(\n contentWidth: unknown,\n fallback: number = FALLBACK_BODY_CONTENT_WIDTH\n): number {\n return fixedContentWidth(contentWidth) ?? fallback;\n}\n\nexport interface SlotContext {\n bodyValues?: { contentWidth?: number | string; padding?: unknown; border?: unknown };\n rowValues?: { padding?: unknown; border?: unknown };\n rowCells?: number[];\n columnIndex?: number;\n columnValues?: { padding?: unknown; border?: unknown };\n /** The image block's own containerPadding (defaults to 10px like the editor). */\n containerPadding?: unknown;\n}\n\n/**\n * Width in px available to a content block, mirroring the renderers'\n * available-width math: contentWidth, minus body/row/column/container paddings\n * and borders, scaled by the column's share of the row.\n */\nexport function contentSlotWidth(ctx: SlotContext): number {\n const { bodyValues = {}, rowValues = {}, columnValues = {} } = ctx;\n const rowCells = ctx.rowCells && ctx.rowCells.length ? ctx.rowCells : [1];\n const columnIndex = ctx.columnIndex ?? 0;\n\n const bodyWidth = bodyContentWidthPx(bodyValues.contentWidth);\n\n const bp = edges(bodyValues.padding);\n const bb = borderEdges(bodyValues.border);\n const bodyAvail = bodyWidth - bp.left - bp.right - bb.left - bb.right;\n\n const rp = edges(rowValues.padding);\n const rb = borderEdges(rowValues.border);\n const rowAvail = bodyAvail - rp.left - rp.right - rb.left - rb.right;\n\n const rowSpan = rowCells.reduce((a, b) => a + b, 0) || 1;\n const colSpan = rowCells[columnIndex] || 1;\n const colWidth = (colSpan / rowSpan) * rowAvail;\n\n const cp = edges(columnValues.padding);\n const cb = borderEdges(columnValues.border);\n const colAvail = colWidth - cp.left - cp.right - cb.left - cb.right;\n\n const ip = edges(ctx.containerPadding ?? DEFAULT_CONTAINER_PADDING);\n return colAvail - ip.left - ip.right;\n}\n\nconst PERCENT = /^\\d+(?:\\.\\d+)?%$/;\n\n/** Round to 2 decimals, matching the editor's percent precision. */\nfunction round2(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\n/**\n * Convert a px display pin on an image `src` to the editor's canonical percent.\n *\n * Only touches a pinned image (`autoWidth === false`) whose `maxWidth` is a\n * px/number placeholder; a percent `maxWidth` is already canonical and is left\n * as-is, and a responsive image (`autoWidth !== false`) is untouched. A pin\n * wider than the slot clamps to 100%, mirroring the editor.\n */\nexport function pinImageSrc<T extends Record<string, any> | undefined>(\n src: T,\n availableWidth: number | undefined\n): T {\n if (!src || typeof src !== \"object\") return src;\n if ((src as Record<string, any>).autoWidth !== false) return src;\n\n const maxWidth = (src as Record<string, any>).maxWidth;\n if (typeof maxWidth === \"string\" && PERCENT.test(maxWidth.trim())) return src;\n\n const pinPx = toPx(maxWidth);\n if (pinPx == null) return src;\n\n const avail = availableWidth && availableWidth > 0 ? availableWidth : undefined;\n const pct = avail ? (pinPx >= avail ? 100 : round2((pinPx / avail) * 100)) : 100;\n\n return { ...src, autoWidth: false, maxWidth: `${pct}%` } as T;\n}\n","import type { RenderMode } from \"./types\";\n\nexport interface HeadConfig {\n hasFeature?: (featureName: string) => boolean;\n getInitialValues?: (containerType: string) => Record<string, any>;\n}\n\nexport interface UnlayerConfig {\n cdnBaseUrl: string;\n toSafeHtml?: (text: string, options?: any) => string;\n textDirection?: string;\n mergeTagState?: Record<string, any>;\n mode?: RenderMode;\n headConfig?: HeadConfig;\n}\n\nexport const DEFAULT_CONFIG: UnlayerConfig = {\n cdnBaseUrl: \"https://cdn.tools.unlayer.com\",\n mode: \"web\",\n};\n","/**\n * Column Layouts - All 8 supported column combinations from Unlayer Editor\n *\n * These layouts provide a structured and type-safe way to specify column\n * configurations that match exactly what the Unlayer editor supports.\n *\n * Usage:\n * import { ColumnLayouts } from '@unlayer/react-elements';\n * <Row layout={ColumnLayouts.TwoEqual}>\n * <Column>...</Column>\n * <Column>...</Column>\n * </Row>\n */\n\nexport interface ColumnLayout {\n name: string;\n description: string;\n cells: number[];\n expectedColumns: number;\n widths: string[]; // e.g., [\"50%\", \"50%\"]\n}\n\nexport const ColumnLayouts = {\n OneColumn: {\n name: 'OneColumn',\n description: 'One full column (100%)',\n cells: [1],\n expectedColumns: 1,\n widths: ['100%'],\n } as ColumnLayout,\n\n TwoEqual: {\n name: 'TwoEqual',\n description: 'Two equal columns (50% + 50%)',\n cells: [1, 1],\n expectedColumns: 2,\n widths: ['50%', '50%'],\n } as ColumnLayout,\n\n TwoWideNarrow: {\n name: 'TwoWideNarrow',\n description: 'Two columns: wide + narrow (67% + 33%)',\n cells: [2, 1],\n expectedColumns: 2,\n widths: ['66.67%', '33.33%'],\n } as ColumnLayout,\n\n TwoNarrowWide: {\n name: 'TwoNarrowWide',\n description: 'Two columns: narrow + wide (33% + 67%)',\n cells: [1, 2],\n expectedColumns: 2,\n widths: ['33.33%', '66.67%'],\n } as ColumnLayout,\n\n ThreeEqual: {\n name: 'ThreeEqual',\n description: 'Three equal columns (33% + 33% + 33%)',\n cells: [1, 1, 1],\n expectedColumns: 3,\n widths: ['33.33%', '33.33%', '33.33%'],\n } as ColumnLayout,\n\n ThreeNarrowWideNarrow: {\n name: 'ThreeNarrowWideNarrow',\n description: 'Three columns: narrow + wide + narrow (25% + 50% + 25%)',\n cells: [1, 2, 1],\n expectedColumns: 3,\n widths: ['25%', '50%', '25%'],\n } as ColumnLayout,\n\n FourEqual: {\n name: 'FourEqual',\n description: 'Four equal columns (25% + 25% + 25% + 25%)',\n cells: [1, 1, 1, 1],\n expectedColumns: 4,\n widths: ['25%', '25%', '25%', '25%'],\n } as ColumnLayout,\n\n FiveEqual: {\n name: 'FiveEqual',\n description: 'Five equal columns (20% + 20% + 20% + 20% + 20%)',\n cells: [1, 1, 1, 1, 1],\n expectedColumns: 5,\n widths: ['20%', '20%', '20%', '20%', '20%'],\n } as ColumnLayout,\n};\n\n// Export the layout type for strict typing\nexport type ValidColumnLayout = (typeof ColumnLayouts)[keyof typeof ColumnLayouts];\n\n/**\n * Validates that a layout has the correct number of Column components\n */\nexport function validateColumnLayout(layout: ColumnLayout, childrenCount: number): void {\n if (layout.expectedColumns !== childrenCount) {\n throw new Error(`${layout.name} layout expects ${layout.expectedColumns} <Column> components, but got ${childrenCount}. Layout: ${layout.description}. Make sure you have exactly ${layout.expectedColumns} <Column> children.`);\n }\n}\n","/**\n * Lexical Helpers for Text JSON Conversion\n *\n * Utilities to convert between plain text, Lexical JSON, and HTML.\n * HTML generation is done via direct JSON tree walking — no Lexical\n * headless editor or DOM required.\n */\n\n/**\n * Empty Lexical JSON structure (used as fallback).\n * Uses extended-paragraph type for Unlayer editor compatibility.\n */\nexport const EMPTY_TEXT_JSON =\n '{\"root\":{\"children\":[{\"children\":[],\"format\":\"\",\"indent\":0,\"type\":\"extended-paragraph\",\"version\":1,\"textFormat\":0,\"textStyle\":\"\"}],\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}';\n\n/**\n * Create Lexical JSON for plain text.\n *\n * Builds the JSON string directly to match the Unlayer editor's\n * ExtendedTextNode / ExtendedParagraphNode serialization format.\n *\n * @param text - Plain text string\n * @returns Lexical JSON string\n *\n * @example\n * ```ts\n * const json = textToTextJson(\"Hello world\");\n * ```\n */\nexport function textToTextJson(text: string): string {\n if (!text) return EMPTY_TEXT_JSON;\n\n const escaped = JSON.stringify(text); // handles quotes/newlines in text\n return `{\"root\":{\"children\":[{\"children\":[{\"detail\":0,\"format\":0,\"mode\":\"normal\",\"style\":\"\",\"text\":${escaped},\"type\":\"extended-text\",\"version\":1}],\"format\":\"\",\"indent\":0,\"type\":\"extended-paragraph\",\"version\":1,\"textFormat\":0,\"textStyle\":\"\"}],\"format\":\"\",\"indent\":0,\"type\":\"root\",\"version\":1}}`;\n}\n\n// ── Lexical format bitmask → HTML tag mapping ────────────────────────────────\n// Lexical encodes inline formatting in a numeric `format` bitmask on text nodes.\nconst FORMAT_TAGS: Array<[number, string, string]> = [\n [1, \"<strong>\", \"</strong>\"], // bold\n [2, \"<em>\", \"</em>\"], // italic\n [4, \"<s>\", \"</s>\"], // strikethrough\n [8, \"<u>\", \"</u>\"], // underline\n [16, \"<code>\", \"</code>\"], // code\n [32, \"<sub>\", \"</sub>\"], // subscript\n [64, \"<sup>\", \"</sup>\"], // superscript\n];\n\n/**\n * Escape HTML special characters in text content.\n */\nfunction escapeHtml(text: string): string {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n\n/**\n * Convert a Lexical text node to HTML, applying format bitmask.\n */\nfunction textNodeToHtml(node: any): string {\n let html = escapeHtml(node.text || \"\");\n\n // Apply inline style attribute if present\n const style = node.style;\n\n // Wrap in format tags (innermost first)\n const format = node.format || 0;\n let openTags = \"\";\n let closeTags = \"\";\n for (const [bit, open, close] of FORMAT_TAGS) {\n if (format & bit) {\n openTags += open;\n closeTags = close + closeTags;\n }\n }\n html = openTags + html + closeTags;\n\n // Wrap in <span> if inline style is present\n if (style) {\n html = `<span style=\"${escapeHtml(style)}\">${html}</span>`;\n }\n\n return html;\n}\n\n/**\n * Convert a Lexical JSON node (and its children) to HTML.\n * Handles: root, paragraph, heading, text, link, list, listitem, linebreak.\n */\nfunction nodeToHtml(node: any): string {\n if (!node || typeof node !== \"object\") return \"\";\n\n const type = node.type;\n\n // Leaf: text node\n if (type === \"text\" || type === \"extended-text\") {\n return textNodeToHtml(node);\n }\n\n // Leaf: line break\n if (type === \"linebreak\") {\n return \"<br>\";\n }\n\n // Recurse into children\n const childrenHtml = (node.children || []).map(nodeToHtml).join(\"\");\n\n switch (type) {\n case \"root\":\n return childrenHtml;\n\n case \"paragraph\":\n case \"extended-paragraph\": {\n if (!childrenHtml) return \"<p><br></p>\";\n const dir = node.direction ? ` dir=\"${node.direction}\"` : \"\";\n return `<p${dir}>${childrenHtml}</p>`;\n }\n\n case \"heading\": {\n const tag = node.tag || \"h1\"; // h1-h6\n const dir = node.direction ? ` dir=\"${node.direction}\"` : \"\";\n return `<${tag}${dir}>${childrenHtml}</${tag}>`;\n }\n\n case \"link\": {\n const href = node.url ? ` href=\"${escapeHtml(node.url)}\"` : \"\";\n const target = node.target ? ` target=\"${escapeHtml(node.target)}\"` : \"\";\n const rel = node.rel ? ` rel=\"${escapeHtml(node.rel)}\"` : \"\";\n return `<a${href}${target}${rel}>${childrenHtml}</a>`;\n }\n\n case \"list\": {\n const tag = node.listType === \"number\" ? \"ol\" : \"ul\";\n return `<${tag}>${childrenHtml}</${tag}>`;\n }\n\n case \"listitem\":\n return `<li>${childrenHtml}</li>`;\n\n default:\n // Unknown node type — pass through children\n return childrenHtml;\n }\n}\n\n/**\n * Convert Lexical JSON to HTML.\n *\n * Walks the JSON tree directly — no Lexical headless editor or DOM required.\n * Works identically in Node.js and browser environments.\n *\n * @param textJson - Lexical JSON string\n * @returns HTML string\n *\n * @example\n * ```ts\n * const html = generateHtmlFromTextJson('{\"root\":...}');\n * ```\n */\nexport function generateHtmlFromTextJson(textJson: string): string {\n if (!textJson) return \"\";\n\n try {\n const parsed = JSON.parse(textJson);\n\n // Raw HTML passthrough (produced by htmlToTextJson)\n if (parsed.__html) return parsed.__html;\n\n // Walk the Lexical JSON tree and produce HTML\n return nodeToHtml(parsed.root);\n } catch {\n return \"\";\n }\n}\n\n/**\n * Convert an HTML string to a textJson-compatible value.\n *\n * Wraps the HTML in a passthrough format that `generateHtmlFromTextJson`\n * detects and returns directly — avoiding the Lexical headless editor\n * round-trip (HTML → Lexical JSON → HTML) which doesn't work reliably\n * in browser environments.\n *\n * Supports any HTML formatting: bold, italic, underline, strikethrough,\n * code, links, lists, etc.\n *\n * @param html - HTML string with formatting (e.g. `\"Hello <b>bold</b>\"`)\n * @returns JSON string compatible with Paragraph's `textJson` prop\n *\n * @example\n * ```ts\n * const json = htmlToTextJson('Hello <b>world</b> and <a href=\"https://example.com\">link</a>');\n * ```\n */\nexport function htmlToTextJson(html: string): string {\n if (!html) return EMPTY_TEXT_JSON;\n return JSON.stringify({ __html: html });\n}\n","/**\n * Deep-merge user values with defaults.\n * Plain objects are merged recursively; arrays and primitives\n * from userValues override the default entirely.\n */\nexport function mergeValues<T extends Record<string, any>>(\n defaults: T,\n userValues?: Partial<T>\n): T {\n if (!userValues) return defaults;\n\n const result: any = { ...defaults };\n\n for (const key of Object.keys(userValues)) {\n const userVal = (userValues as any)[key];\n const defaultVal = (defaults as any)[key];\n\n if (\n userVal !== null &&\n defaultVal !== null &&\n typeof userVal === \"object\" &&\n typeof defaultVal === \"object\" &&\n !Array.isArray(userVal) &&\n !Array.isArray(defaultVal)\n ) {\n // Recursively merge plain objects\n result[key] = mergeValues(defaultVal, userVal);\n } else {\n result[key] = userVal;\n }\n }\n\n return result as T;\n}\n","/**\n * Universal Semantic Props System\n *\n * Automatically flattens nested properties for ALL components\n * No build-time generation needed - pure TypeScript + runtime detection\n *\n * Example:\n * - ButtonValues has: { buttonColors: { color, backgroundColor }, fontSize }\n * - Users can pass: { color: \"red\", backgroundColor: \"blue\" } OR { buttonColors: { color: \"red\" } }\n * - TypeScript provides autocomplete for ALL properties (flat and nested)\n */\n\nimport { textToTextJson, htmlToTextJson } from \"./lexical-helpers\";\n\n/**\n * Type utility: Extracts all properties from nested objects\n * This provides TypeScript autocomplete for flat props!\n */\ntype FlattenObjectProps<T> = T extends object\n ? {\n [K in keyof T]?: T[K] extends object\n ? T[K] | FlattenObjectProps<T[K]> // Accept nested OR its flattened props\n : T[K];\n } & {\n // Also accept all nested object properties as flat props\n [K in keyof T as T[K] extends object\n ? keyof T[K] extends string\n ? keyof T[K]\n : never\n : never]?: any;\n }\n : T;\n\n/**\n * Semantic props type for any component.\n * Generic TChildren parameter allows each framework to supply its own child type.\n */\nexport type SemanticProps<T, TChildren = any> = FlattenObjectProps<T> & {\n children?: TChildren;\n values?: T; // Escape hatch for full control\n /** HTML string with inline formatting for Paragraph (e.g. `'Hello <b>bold</b>'`) */\n html?: string;\n};\n\n/**\n * Runtime detection of nested object structures\n * Analyzes default values to identify which properties are nested objects.\n * Results are cached per defaultValues object reference to avoid recomputing\n * on every render.\n */\nconst nestedStructureCache = new WeakMap<object, Map<string, Set<string>>>();\n\nfunction analyzeNestedStructure(defaultValues: any): Map<string, Set<string>> {\n const cached = nestedStructureCache.get(defaultValues);\n if (cached) return cached;\n\n const nestedGroups = new Map<string, Set<string>>();\n\n for (const [key, value] of Object.entries(defaultValues)) {\n // Skip special keys\n if (key === \"_meta\" || key === \"text\" || key === \"textJson\" || key === \"children\") {\n continue;\n }\n\n // Check if this is a nested object (plain object, not array, not null)\n if (\n value &&\n typeof value === \"object\" &&\n !Array.isArray(value) &&\n Object.keys(value).length > 0\n ) {\n const props = new Set(Object.keys(value));\n nestedGroups.set(key, props);\n }\n }\n\n nestedStructureCache.set(defaultValues, nestedGroups);\n return nestedGroups;\n}\n\n/**\n * Coerce CSS-idiom flat prop values to the shapes the exporters expect.\n * Mutates the given props object in place. Each rule fixes a footgun where the\n * natural/CSS form type-checks (flat props are loosely typed) but renders blank\n * or invalid:\n * - `fontFamily: \"Arial\"` → `{ label, value }` (a bare string is otherwise\n * char-spread when merged into the fontFamily group, dropping the font).\n * - `fontWeight: \"700\"` → `700` (numeric string → number; keyword strings like\n * \"bold\"/\"normal\" are valid CSS and left as-is).\n * - `fontSize: 28` → `\"28px\"` (a unitless number is invalid CSS the browser\n * ignores). Same for other bare-number size fields.\n * - `lineHeight: 1.4` → `\"1.4\"` (the field is typed as a string; unitless\n * line-height is valid CSS).\n */\nconst PX_SIZE_KEYS = [\n \"fontSize\",\n \"padding\",\n \"containerPadding\",\n \"borderRadius\",\n \"letterSpacing\",\n] as const;\n\nfunction normalizeCssProps(props: Record<string, any>): void {\n if (typeof props.fontFamily === \"string\") {\n const v = props.fontFamily;\n props.fontFamily = { label: v, value: v };\n }\n if (\n typeof props.fontWeight === \"string\" &&\n /^\\d+$/.test(props.fontWeight.trim())\n ) {\n props.fontWeight = Number(props.fontWeight.trim());\n }\n if (typeof props.lineHeight === \"number\") {\n props.lineHeight = String(props.lineHeight);\n }\n for (const key of PX_SIZE_KEYS) {\n const v = props[key];\n // bare number (28) or a unit-less numeric string (\"0\", \"20\") → \"<n>px\"\n if (typeof v === \"number\") {\n props[key] = `${v}px`;\n } else if (typeof v === \"string\" && /^\\d+$/.test(v.trim())) {\n props[key] = `${v.trim()}px`;\n }\n }\n}\n\n/**\n * Flatten a JSX/ReactNode children tree to its plain text content.\n * Text components store a string (or Lexical JSON derived from one); a raw React\n * element passed as children would otherwise stringify to \"[object Object]\".\n * Duck-types the element shape (`.props.children`) so this stays framework-free.\n * Inline formatting is not preserved — use the `html` prop for rich text.\n */\nfunction flattenChildrenText(node: any): string {\n if (node == null || typeof node === \"boolean\") return \"\";\n if (typeof node === \"string\") return node;\n if (typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(flattenChildrenText).join(\"\");\n if (typeof node === \"object\" && \"props\" in node) {\n return flattenChildrenText(node.props?.children);\n }\n return \"\";\n}\n\n/**\n * Universal semantic props mapper\n * Works for ANY component - no configuration needed!\n *\n * @param props - User props (can include flat or nested properties)\n * @param defaultValues - Component default values (used to detect structure)\n * @param componentType - Component name (for special handling like Paragraph)\n * @returns Properly structured values object for exporter\n */\nexport function mapSemanticProps<T extends Record<string, any>>(\n props: SemanticProps<T>,\n defaultValues: T,\n componentType: string\n): T {\n const { children, values, ...restProps } = props;\n const userProps: any = { ...restProps };\n\n // Start with escape hatch if provided\n const result: any = values ? { ...values } : {};\n\n // Handle children → text/textJson conversion\n // Paragraph uses textJson (Lexical JSON); all others use text (plain string)\n // Note: editor-types codegen renamed text→textJson for Button/Heading but\n // the exporter still uses plain text at runtime via generateHtmlFromTextJson\n if (children !== undefined && !result.text && !result.textJson) {\n const textContent =\n typeof children === \"string\" ? children : flattenChildrenText(children);\n if (componentType === \"Paragraph\") {\n result.textJson = textToTextJson(textContent);\n } else {\n result.text = textContent;\n }\n }\n\n // Paragraph: auto-convert `text` → `textJson` (Lexical JSON)\n // This allows Paragraph to accept the same `text` field as Heading/Button,\n // making it a drop-in replacement for the legacy Text component.\n // - values.text (escape hatch) = legacy HTML → use htmlToTextJson (preserves HTML)\n // - text prop (API) = plain text → use textToTextJson (wraps in Lexical JSON)\n const textFromEscapeHatch = result.text;\n const textFromProp = userProps.text;\n const textProp = textFromEscapeHatch || textFromProp;\n if (componentType === \"Paragraph\" && textProp && !result.textJson) {\n result.textJson = textFromEscapeHatch\n ? htmlToTextJson(String(textProp))\n : textToTextJson(String(textProp));\n delete result.text;\n delete userProps.text;\n }\n\n // Paragraph: convert `html` (rich HTML string) → `textJson` (Lexical JSON)\n // Supports both: <Paragraph html=\"...\" /> and <Paragraph values={{ html: \"...\" }} />\n const htmlProp = userProps.html || result.html;\n if (componentType === \"Paragraph\" && htmlProp && !result.textJson) {\n result.textJson = htmlToTextJson(String(htmlProp));\n delete userProps.html;\n delete result.html;\n }\n\n // Canonicalize link/action fields to the schema's storage shape so the rest of\n // the pipeline (mergeValues, renderToJson, AND the editor) sees a consistent\n // type:\n // - `\"https://…\"` string shorthand → `{ name:\"web\", values:{ href, target } }`.\n // - a link placed in `attrs` (the canonical Href type also surfaces\n // `attrs:{ href, target }`) is moved into `values.href`/`target`, where the\n // editor reads it — so the link round-trips into the Builder, not just into\n // renderToHtml. Genuine custom attrs (class, data-*, …) are preserved.\n // Applied to both the flat prop and the `values` escape hatch. (Render-time\n // `normalizeLinkValue` also reads `attrs` as a defensive fallback.)\n const canonicalizeLink = (v: any): any => {\n if (typeof v === \"string\") {\n return { name: \"web\", values: { href: v, target: \"_blank\" } };\n }\n if (v && typeof v === \"object\" && \"name\" in v && v.attrs && typeof v.attrs === \"object\") {\n const { href: attrsHref, target: attrsTarget, ...customAttrs } = v.attrs;\n if (attrsHref !== undefined || attrsTarget !== undefined) {\n const linkValues = { ...(v.values as Record<string, any> | undefined) };\n if (!linkValues.href && attrsHref !== undefined) linkValues.href = attrsHref;\n if (!linkValues.target && attrsTarget !== undefined) linkValues.target = attrsTarget;\n const next: Record<string, any> = { ...v, values: linkValues };\n if (Object.keys(customAttrs).length) next.attrs = customAttrs;\n else delete next.attrs;\n return next;\n }\n }\n return v;\n };\n for (const key of [\"href\", \"action\"] as const) {\n if (userProps[key] !== undefined) userProps[key] = canonicalizeLink(userProps[key]);\n if (result[key] !== undefined) result[key] = canonicalizeLink(result[key]);\n }\n\n // Normalize CSS-idiom prop values to the shapes the exporters expect. Authors\n // (humans and AI) reach for CSS habits — a string `fontFamily`, a numeric\n // `fontSize`, a string `fontWeight` — which type-check (flat props are loose)\n // but otherwise render blank or invalid. Coercing the natural form here makes\n // it render correctly. Applied to flat props only; the `values` escape hatch\n // is the full-control path and is left untouched.\n normalizeCssProps(userProps);\n\n // Analyze default values to detect nested object structure\n const nestedGroups = analyzeNestedStructure(defaultValues);\n\n // Separate flat props from potential nested props\n const nested: Record<string, any> = {};\n const flat: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(userProps)) {\n if (value === undefined) continue;\n\n // Check if user already provided a nested object\n if (nestedGroups.has(key)) {\n // User passed the nested object directly\n nested[key] = value;\n continue;\n }\n\n // Check if this prop belongs to any nested group\n let belongsToGroup = false;\n for (const [groupName, groupProps] of nestedGroups.entries()) {\n if (groupProps.has(key)) {\n // This flat prop should be grouped\n nested[groupName] = nested[groupName] || {};\n nested[groupName][key] = value;\n belongsToGroup = true;\n break;\n }\n }\n\n if (!belongsToGroup) {\n // Regular flat prop\n flat[key] = value;\n }\n }\n\n // Merge everything: escape hatch < flat props < nested groups\n const final: any = {\n ...result,\n ...flat\n };\n\n // Merge nested groups (preserve existing from escape hatch)\n for (const [groupName, groupValues] of Object.entries(nested)) {\n if (Object.keys(groupValues).length > 0) {\n final[groupName] = {\n ...result[groupName],\n ...groupValues\n };\n }\n }\n\n // Some components (e.g. Column) ship an empty `border: {}` default, so the\n // nested-group detector can't see the border sub-keys and flat border-side\n // props (borderTopWidth, …) would land loose and be dropped by the exporter.\n // If the component declares a `border` field, gather them into it.\n if (\n defaultValues &&\n typeof defaultValues === \"object\" &&\n \"border\" in (defaultValues as object)\n ) {\n const borderSideRe = /^border(Top|Right|Bottom|Left)(Width|Style|Color)$/;\n const collected: Record<string, any> = {};\n for (const key of Object.keys(final)) {\n if (borderSideRe.test(key)) {\n collected[key] = final[key];\n delete final[key];\n }\n }\n if (Object.keys(collected).length > 0) {\n final.border = { ...(final.border || {}), ...collected };\n }\n }\n\n return final as T;\n}\n\n/**\n * Convert any of the three link-shaped inputs into the render-value shape\n * the exporter expects: `{ url, target, ...customAttrs }`.\n *\n * The schema stores links as `{ name, values: { href, target } }`, but\n * exporters (consumed via @unlayer/exporters) expect the editor's render\n * value shape `{ url, target, customAttrs?, class?, onClick? }`. The editor\n * runs this conversion via the link property-editor's `renderValue()` —\n * `normalizeValuesForExporter` (in render-time code) mirrors it so React\n * rendered output matches.\n *\n * Accepted inputs:\n * - `\"https://...\"` (string shorthand)\n * - `{ url, target?, customAttrs?, class?, onClick? }` (already render shape)\n * - `{ name, values: { href, target? }, attrs? }` (storage shape from schema)\n *\n * Returns `undefined` for shapes we don't recognize so the caller can fall\n * back to the original value (avoids silently dropping data).\n *\n * IMPORTANT: this is render-time only. Do NOT apply during renderToJson —\n * JSON output is for round-tripping into the editor, which expects the\n * storage shape.\n */\nexport function normalizeLinkValue(value: unknown): Record<string, any> | undefined {\n if (value == null) return undefined;\n if (typeof value === \"string\") {\n return { url: value, target: \"_blank\" };\n }\n if (typeof value !== \"object\") return undefined;\n const v = value as Record<string, any>;\n // Already render-shape (has url) — pass through.\n if (\"url\" in v) return v;\n // Storage shape from the schema: { name, values: { href, target }, attrs? }.\n // The canonical Href type also surfaces `attrs: { href, target }`, so authors\n // reasonably put the link there — read href/target from `values` first, then\n // fall back to `attrs`, and spread any remaining `attrs` as custom attributes.\n // (Without this, `{ name, attrs: { href } }` type-checks but renders href=\"\".)\n if (\n \"name\" in v &&\n ((v.values && typeof v.values === \"object\") || (v.attrs && typeof v.attrs === \"object\"))\n ) {\n const inner = v.values && typeof v.values === \"object\" ? (v.values as Record<string, any>) : {};\n const attrs = v.attrs && typeof v.attrs === \"object\" ? (v.attrs as Record<string, any>) : {};\n const { href: attrsHref, target: attrsTarget, ...customAttrs } = attrs;\n // `||` not `??`: the schema default merges in `values: { href: \"\" }`, so an\n // empty `values.href` must fall through to the `attrs` href, not win over it.\n return {\n url: inner.href || attrsHref || \"\",\n target: inner.target || attrsTarget || \"_blank\",\n ...customAttrs,\n };\n }\n return undefined;\n}\n\n/**\n * Normalize all link/action fields on an item's values to the render-value\n * shape the exporter reads. Returns a shallow clone — does not mutate.\n *\n * Knows about the link-bearing paths per component:\n * - top-level `href` (Button, Video)\n * - top-level `action` (Image, Timer)\n * - `menu.items[].link` (Menu)\n *\n * Only the bridge between mapper and exporter should call this; renderToJson\n * must NOT, because JSON output preserves storage shape.\n */\nexport function normalizeValuesForExporter<T extends Record<string, any>>(\n values: T,\n componentName: string\n): T {\n if (values == null || typeof values !== \"object\") return values;\n\n const out: Record<string, any> = { ...values };\n\n // Top-level link fields used by Button (href), Image (action), Video (href),\n // Timer (action). Cheap to check both keys for every component.\n for (const key of [\"href\", \"action\"]) {\n if (out[key] !== undefined) {\n const normalized = normalizeLinkValue(out[key]);\n if (normalized !== undefined) out[key] = normalized;\n }\n }\n\n // Menu items each carry a `link` field.\n if (componentName === \"Menu\" && out.menu && Array.isArray(out.menu.items)) {\n out.menu = {\n ...out.menu,\n items: out.menu.items.map((item: any) => {\n if (!item || item.link === undefined) return item;\n const normalized = normalizeLinkValue(item.link);\n if (normalized === undefined) return item;\n return { ...item, link: normalized };\n }),\n };\n }\n\n return out as T;\n}\n","/**\n * HTML to Plain Text Converter\n *\n * Pure regex-based HTML-to-text conversion — no DOM dependency.\n * Works in Node.js, edge runtimes, and browsers.\n *\n * Critical for email deliverability: spam filters penalize HTML-only emails.\n */\n\n/**\n * Common HTML entity map for decoding.\n */\nconst HTML_ENTITIES: Record<string, string> = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n \""\": '\"',\n \"'\": \"'\",\n \"'\": \"'\",\n \" \": \" \",\n \"—\": \"—\",\n \"–\": \"–\",\n \"«\": \"«\",\n \"»\": \"»\",\n \"•\": \"•\",\n \"·\": \"·\",\n \"…\": \"…\",\n \"©\": \"©\",\n \"®\": \"®\",\n \"™\": \"™\",\n};\n\n/**\n * Decode HTML entities (named and numeric).\n */\nfunction decodeEntities(text: string): string {\n // Named entities\n let result = text.replace(/&\\w+;/g, (match) => HTML_ENTITIES[match] ?? match);\n\n // Numeric entities: { and \n result = result.replace(/&#(\\d+);/g, (_, code) =>\n String.fromCharCode(parseInt(code, 10))\n );\n result = result.replace(/&#x([0-9a-fA-F]+);/g, (_, code) =>\n String.fromCharCode(parseInt(code, 16))\n );\n\n return result;\n}\n\n/**\n * Convert an HTML string to readable plain text.\n *\n * @param html - HTML string to convert\n * @returns Plain text representation\n *\n * @example\n * ```ts\n * import { htmlToPlainText } from \"@unlayer-internal/shared-elements\";\n *\n * const text = htmlToPlainText(\"<h1>Hello</h1><p>World</p>\");\n * // \"HELLO\\nWorld\"\n * ```\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return \"\";\n\n let text = html;\n\n // 1. Remove elements marked with data-skip-in-text (preview div, etc.)\n text = text.replace(/<[^>]+data-skip-in-text=\"true\"[^>]*>[\\s\\S]*?<\\/[^>]+>/gi, \"\");\n\n // 2. Remove <head>, <style>, <script> blocks entirely\n text = text.replace(/<head[\\s\\S]*?<\\/head>/gi, \"\");\n text = text.replace(/<style[\\s\\S]*?<\\/style>/gi, \"\");\n text = text.replace(/<script[\\s\\S]*?<\\/script>/gi, \"\");\n\n // 3. Convert headings: h1-h2 → UPPERCASE, h3-h6 → as-is\n text = text.replace(/<h[12][^>]*>([\\s\\S]*?)<\\/h[12]>/gi, (_, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n return \"\\n\" + clean.toUpperCase() + \"\\n\";\n });\n text = text.replace(/<h[3-6][^>]*>([\\s\\S]*?)<\\/h[3-6]>/gi, (_, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n return \"\\n\" + clean + \"\\n\";\n });\n\n // 4. Convert links: <a href=\"url\">text</a> → text (url)\n text = text.replace(/<a[^>]+href=[\"']([^\"']+)[\"'][^>]*>([\\s\\S]*?)<\\/a>/gi, (_, href, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n // Skip if link text is the same as URL (avoid duplication)\n if (clean === href || clean === decodeEntities(href)) {\n return clean;\n }\n return `${clean} (${href})`;\n });\n\n // 5. Convert images: <img alt=\"text\"> → [text]\n text = text.replace(/<img[^>]+alt=[\"']([^\"']+)[\"'][^>]*\\/?>/gi, (_, alt) => {\n return `[${alt}]`;\n });\n // Remove images without alt text\n text = text.replace(/<img[^>]*\\/?>/gi, \"\");\n\n // 6. Convert horizontal rules\n text = text.replace(/<hr[^>]*\\/?>/gi, \"\\n---\\n\");\n\n // 7. Convert list items\n text = text.replace(/<li[^>]*>([\\s\\S]*?)<\\/li>/gi, (_, content) => {\n const clean = content.replace(/<[^>]+>/g, \"\").trim();\n return \"- \" + clean + \"\\n\";\n });\n\n // 8. Convert <br> tags\n text = text.replace(/<br\\s*\\/?>/gi, \"\\n\");\n\n // 9. Convert block-level closing tags to newlines\n text = text.replace(/<\\/(?:p|div|tr|blockquote|section|article|header|footer|main|nav|aside)>/gi, \"\\n\");\n text = text.replace(/<\\/(?:ul|ol|table|thead|tbody|tfoot)>/gi, \"\\n\");\n\n // 10. Convert <td> and <th> to tab-separated values\n text = text.replace(/<\\/(?:td|th)>/gi, \"\\t\");\n\n // 11. Remove all remaining HTML tags\n text = text.replace(/<[^>]+>/g, \"\");\n\n // 12. Decode HTML entities\n text = decodeEntities(text);\n\n // 13. Clean up whitespace\n // Replace tabs with spaces\n text = text.replace(/\\t/g, \" \");\n // Collapse multiple spaces (but not newlines) into one\n text = text.replace(/[^\\S\\n]+/g, \" \");\n // Trim each line\n text = text\n .split(\"\\n\")\n .map((line) => line.trim())\n .join(\"\\n\");\n // Collapse 3+ consecutive newlines to 2\n text = text.replace(/\\n{3,}/g, \"\\n\\n\");\n // Trim leading/trailing whitespace\n text = text.trim();\n\n return text;\n}\n","/**\n * Universal Component Factory\n *\n * Eliminates boilerplate by creating components from configuration.\n * This factory handles all the repetitive logic that was duplicated\n * across Button, Heading, Paragraph, etc.\n */\n\nimport React from \"react\";\nimport type { ExporterName } from \"@unlayer/types\";\n\n/** Exporter map keyed by display mode. Defined locally until added to @unlayer/types. */\ntype ItemExporters = Partial<Record<ExporterName, (...args: any[]) => string>>;\nimport type { RenderMode, UnlayerConfig } from \"@unlayer-internal/shared-elements\";\nimport type { SizeInput } from \"../types\";\nimport { contentSlotWidth, pinImageSrc } from \"./image-sizing\";\nimport {\n mergeValues,\n generateHtmlFromTextJson,\n normalizeValuesForExporter,\n DEFAULT_CONFIG,\n} from \"@unlayer-internal/shared-elements\";\n\n\n/**\n * Static property key for the hook-free render function.\n * Column calls this directly instead of the outer component\n * (which uses hooks and would break when called as a plain function).\n */\nexport const UNLAYER_RENDER_KEY = \"__unlayerRender\";\n\n/**\n * Static property key for the item's config (name, defaultValues, propMapper).\n * Used by renderToJson to extract values without rendering to HTML.\n */\nexport const UNLAYER_CONFIG_KEY = \"__unlayerItemConfig\";\n\n/**\n * Base props that all item components support\n */\nexport interface BaseItemComponentProps {\n children?: React.ReactNode;\n className?: string;\n style?: React.CSSProperties;\n mode?: RenderMode;\n /** Padding of the content wrapper around this item — a number (→ px) or a CSS\n * string (\"10px\", \"16px 24px\"). Applied by the containing Column. */\n containerPadding?: SizeInput;\n\n // Internal props (for advanced use)\n index?: number;\n colIndex?: number;\n cells?: any[];\n bodyValues?: any;\n rowValues?: any;\n /** @internal - this column's values, threaded by Column for width-aware exporters */\n columnValues?: any;\n /** @internal - Unlayer config threaded from UnlayerProvider */\n _config?: UnlayerConfig;\n}\n\n/**\n * Configuration for creating an item component\n */\nexport interface ItemComponentConfig<TValues, TSemanticProps> {\n /** Component name (e.g., 'Button', 'Heading') */\n name: string;\n\n /** Default values for the component */\n defaultValues: TValues;\n\n /** Function to map semantic props to values format */\n propMapper: (\n props: TSemanticProps & { children?: React.ReactNode }\n ) => Partial<TValues>;\n\n /** Display name for React DevTools */\n displayName?: string;\n\n /** Per-component exporters map — enables tree-shaking.\n * Keys are display modes ('web', 'email', 'document'), values are exporter functions. */\n exporters: ItemExporters;\n}\n\n/**\n * Props type that combines base props with semantic props\n */\nexport type ItemComponentProps<TSemanticProps> = BaseItemComponentProps &\n TSemanticProps;\n\n// ============================================\n// Internal: rendering helpers (merged from render-component.tsx)\n// ============================================\n\ninterface ErrorFallbackProps {\n type: string;\n error: Error;\n className?: string;\n style?: React.CSSProperties;\n}\n\n/** Error fallback component shown when an exporter throws. */\nconst ErrorFallback: React.FC<ErrorFallbackProps> = ({\n type,\n className,\n style\n}) => (\n <div className={className} style={style}>\n <div\n style={{\n padding: \"20px\",\n backgroundColor: \"#fee\",\n border: \"1px solid #fcc\",\n borderRadius: \"4px\",\n color: \"#c33\",\n textAlign: \"center\",\n fontFamily: \"system-ui, sans-serif\"\n }}\n >\n <strong>{type} failed to render.</strong>\n <br />\n <small>Check console for details.</small>\n </div>\n </div>\n);\n\ninterface RenderConfig<T = any> {\n type: string;\n values: T;\n mode: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n args?: any[];\n /** Column/body context merged into the exporter `meta` (8th arg). */\n metaContext?: Record<string, any>;\n innerHTML?: string;\n _config?: UnlayerConfig;\n exporter: Function;\n}\n\n/**\n * Allocate the next unique HTML id for a prefix, scoped to one render.\n * Counters live on the threaded `_config` (`__ids`), which Body resets per\n * render — so renderToHtml produces unique ids (u_row_1, u_row_2, …) like the\n * editor and like renderToJson, instead of resetting per row. Falls back to\n * `${prefix}_1` when rendered standalone (no _config).\n */\nexport function nextHtmlId(config: any, prefix: string): string {\n if (!config) return `${prefix}_1`;\n const ids: Record<string, number> = (config.__ids ??= {});\n ids[prefix] = (ids[prefix] || 0) + 1;\n return `${prefix}_${ids[prefix]}`;\n}\n\n/** Add _meta fields if not present. */\nfunction ensureMeta(values: any, type: string, index: number = 0): any {\n return {\n ...values,\n _meta: {\n htmlID: `u_content_${type.toLowerCase()}_${index + 1}`,\n htmlClassNames: `u_content_${type.toLowerCase()}`,\n ...(values._meta || {})\n }\n };\n}\n\n/**\n * Render a component by calling its exporter and wrapping the HTML output.\n * Handles error boundaries, exporterConfig construction, and container vs item calling conventions.\n */\nfunction renderComponent<T = any>(config: RenderConfig<T>): JSX.Element {\n const { type, values, mode, className, style, args = [], innerHTML, _config, exporter, metaContext } = config;\n\n try {\n // Build exporterConfig from _config (falls back to defaults)\n const cfg = _config ?? DEFAULT_CONFIG;\n const exporterConfig = {\n generateHtmlFromTextJson,\n toSafeHtml: cfg.toSafeHtml,\n textDirection: cfg.textDirection,\n cdnBaseUrl: cfg.cdnBaseUrl,\n };\n\n // Call exporter with appropriate arguments\n let html: string;\n if (innerHTML !== undefined) {\n // Container components (Row, Body) take innerHTML first\n html = exporter(innerHTML, values, ...args);\n } else {\n // Content components take values first\n // Item exporters signature: (values, index, colIndex, cells, bodyValues, rowValues, embeddedValues, meta)\n // Args 2-7 are deprecated positional params; the 8th arg is a meta object with all context\n const meta = {\n exporterConfig,\n mergeTagState: cfg.mergeTagState,\n ...(metaContext ?? {}),\n };\n html = exporter(values, ...args, undefined, meta);\n }\n\n // Ensure string output\n html = typeof html === \"string\" ? html : String(html);\n\n // Return rendered component\n return (\n <div\n className={className}\n style={style}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n );\n } catch (error) {\n console.error(`${type} rendering failed:`, error);\n return (\n <ErrorFallback\n type={type}\n error={error as Error}\n className={className}\n style={style}\n />\n );\n }\n}\n\n// ============================================\n// Public API\n// ============================================\n\n/**\n * Create an item component (Button, Heading, Paragraph, etc.)\n *\n * This factory eliminates the ~100 lines of boilerplate code that was\n * duplicated across every item component.\n *\n * @example\n * ```tsx\n * const Button = createItemComponent({\n * name: \"Button\",\n * defaultValues: BUTTON_DEFAULTS,\n * propMapper: mapButtonProps,\n * displayName: \"Button\"\n * });\n * ```\n */\nexport function createItemComponent<\n TValues extends Record<string, any> = any,\n TSemanticProps = any\n>(\n config: ItemComponentConfig<TValues, TSemanticProps>\n): React.FC<ItemComponentProps<TSemanticProps>> {\n // Inner render function — no hooks, safe to call as a plain function (Column does this)\n function renderFn(\n props: ItemComponentProps<TSemanticProps>\n ): React.ReactElement | null {\n const {\n // Base props\n mode: modeProp,\n className,\n style,\n\n // Internal props\n index = 0,\n colIndex = 0,\n cells = [],\n bodyValues = {},\n rowValues = {},\n columnValues = {},\n _config,\n\n // Children\n children,\n\n // Rest are semantic props\n ...restProps\n } = props as ItemComponentProps<TSemanticProps>;\n\n // Resolve mode: explicit prop > _config > default\n const mode: RenderMode = modeProp ?? _config?.mode ?? \"web\";\n\n // 1. Map semantic props to values format (handles dual API)\n const mappedValues = config.propMapper({\n children,\n ...restProps\n } as TSemanticProps & { children?: React.ReactNode });\n\n // 2. Merge with defaults\n const finalValues = mergeValues(config.defaultValues, mappedValues);\n\n // 3. Ensure _meta is present\n const valuesWithMeta = ensureMeta(\n finalValues,\n config.name.toLowerCase(),\n index\n );\n\n // 4. Ensure bodyValues has a contentWidth. Default to the schema-shaped\n // \"500px\" (matches BodyDefaults.contentWidth and the exporter's image\n // fallback width), so a standalone item (no Body) sizes the same as the\n // editor and the value is a CSS string everywhere it might be consumed.\n const safeBodyValues = {\n contentWidth: \"500px\",\n ...bodyValues\n };\n\n // 5. Resolve link/action fields to the exporter's render-value shape.\n // Skipped on the renderToJson path (which uses propMapper directly)\n // so JSON output preserves the schema's storage shape.\n const valuesForExporter = normalizeValuesForExporter(\n valuesWithMeta as Record<string, any>,\n config.name\n );\n\n // 5b. Convert a fixed (px) image pin to the editor's canonical percent now\n // that the column geometry is known (Column threads columnValues/cells/\n // bodyValues). Guarded on `src.autoWidth === false`, so only pinned\n // images are touched; responsive images and non-image blocks pass through.\n const exportSrc = (valuesForExporter as Record<string, any>).src;\n if (exportSrc && typeof exportSrc === \"object\" && exportSrc.autoWidth === false) {\n const availableWidth = contentSlotWidth({\n bodyValues: safeBodyValues,\n rowValues,\n rowCells: cells,\n columnIndex: colIndex,\n columnValues,\n containerPadding:\n (props as { containerPadding?: unknown; values?: { containerPadding?: unknown } })\n .containerPadding ??\n (props as { values?: { containerPadding?: unknown } }).values?.containerPadding,\n });\n (valuesForExporter as Record<string, any>).src = pinImageSrc(exportSrc, availableWidth);\n }\n\n // 6. Resolve exporter for this mode (fallback to web)\n const exporter = (config.exporters[mode] || config.exporters.web)!;\n\n // 7. Render using utility (handles all boilerplate)\n return renderComponent<TValues>({\n type: config.name,\n values: valuesForExporter as TValues,\n mode,\n className,\n style,\n args: [index, colIndex, cells, safeBodyValues, rowValues],\n // The 8th arg the exporters actually read: column/body context for\n // width-aware rendering (Image's available-width calc), mirroring the editor.\n metaContext: {\n columnIndex: colIndex,\n columnValues,\n rowCells: cells,\n rowValues,\n bodyValues: safeBodyValues,\n },\n _config,\n exporter,\n });\n }\n\n // Outer React component — hook-free, works in both Server and Client Components\n const ItemComponent: React.FC<ItemComponentProps<TSemanticProps>> = (\n props\n ) => {\n return renderFn(props);\n };\n\n // Set display name for React DevTools\n ItemComponent.displayName = config.displayName || config.name;\n\n // Expose hook-free render for Column to call directly\n (ItemComponent as any)[UNLAYER_RENDER_KEY] = renderFn;\n\n // Expose config for renderToJson to extract values without HTML rendering\n (ItemComponent as any)[UNLAYER_CONFIG_KEY] = {\n name: config.name,\n defaultValues: config.defaultValues,\n propMapper: config.propMapper,\n };\n\n return ItemComponent;\n}\n","import { ButtonExporters, ButtonDefaults } from \"@unlayer/exporters\";\nimport type { ButtonValues, TextStyleProps, SizeInput, BorderInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Button semantic props — agent-friendly text/style types (replacing the loose\n * `any` flat props) plus a CSS-style `width` (number/px pins; \"100%\" full-width).\n */\ntype ButtonSemanticProps = Omit<\n SemanticProps<ButtonValues>,\n keyof TextStyleProps | \"width\" | \"padding\" | \"borderRadius\" | \"border\"\n> &\n TextStyleProps & {\n /** Display width — a number/px pins the button; \"100%\" makes it full-width. */\n width?: SizeInput;\n /** Inner padding — a number (→ px) or CSS string (\"14px 28px\"). */\n padding?: SizeInput;\n /** Corner radius — a number (→ px) or CSS string (\"8px\", \"500px\"). */\n borderRadius?: SizeInput;\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n };\n\n/**\n * Button Component Props\n * Automatically provides autocomplete for ALL properties (flat and nested)\n */\nexport interface ButtonProps extends ItemComponentProps<ButtonSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific additions\nconst DEFAULT_VALUES = {\n ...ButtonDefaults,\n text: \"Button\", // React convenience — not in schema\n} as unknown as ButtonValues;\n\n/**\n * Button - Universal SSR/Client Component with Automatic Semantic Props\n *\n * ✅ TypeScript provides autocomplete for ALL props (flat and nested)\n * ✅ Works for any nested structure - no configuration needed\n * ✅ Escape hatch: values prop for full control\n * ✅ Works on both server and client\n *\n * @example Flat Props (Simple - most common)\n * ```tsx\n * // `href` accepts a plain URL string (the ergonomic form).\n * <Button href=\"https://example.com\" color=\"white\" backgroundColor=\"#3b82f6\" fontSize=\"16px\">\n * Click me\n * </Button>\n * ```\n *\n * @example Advanced (per-side borders)\n * ```tsx\n * <Button\n * backgroundColor=\"blue\"\n * borderTopColor=\"red\"\n * borderTopWidth=\"2px\"\n * borderBottomWidth=\"0px\"\n * >\n * Click me\n * </Button>\n * ```\n *\n * @example Nested Objects (full control)\n * ```tsx\n * <Button\n * buttonColors={{ backgroundColor: \"#3b82f6\", hoverBackgroundColor: \"#2563eb\" }}\n * border={{ borderTopWidth: \"2px\" }}\n * >\n * Click me\n * </Button>\n * ```\n */\nconst Button = createItemComponent<ButtonValues, ButtonSemanticProps>({\n name: \"Button\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const mapped = mapSemanticProps(\n props as SemanticProps<ButtonValues>,\n DEFAULT_VALUES,\n \"Button\"\n );\n // In Unlayer's model a button's display width is size.width, used only when\n // size.autoWidth is false (otherwise the width is auto / content-sized). So a\n // user-provided width sets autoWidth:false. Read the MAPPED size, which\n // already includes the flat prop, the nested prop, AND the `values` escape\n // hatch; mapSemanticProps does not inject the schema default, so a present\n // size.width means the user set it. Honor an explicit autoWidth.\n const size = (mapped as { size?: unknown }).size;\n if (size && typeof size === \"object\" && !Array.isArray(size)) {\n const s = size as { width?: unknown; autoWidth?: unknown };\n // width accepts a number per SizeInput, but the exporter wants a CSS\n // string — coerce a bare number / unit-less numeric string to px.\n if (typeof s.width === \"number\") {\n s.width = `${s.width}px`;\n } else if (typeof s.width === \"string\" && /^\\d+(?:\\.\\d+)?$/.test(s.width.trim())) {\n s.width = `${s.width.trim()}px`;\n }\n if (s.width !== undefined && s.autoWidth === undefined) {\n s.autoWidth = false;\n }\n }\n return mapped;\n },\n displayName: \"Button\",\n exporters: ButtonExporters,\n});\n\nexport default Button;\n","import { DividerExporters, DividerDefaults } from \"@unlayer/exporters\";\nimport type { DividerValues, BorderInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\ntype DividerSemanticProps = Omit<SemanticProps<DividerValues>, \"border\"> & {\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n};\n\nexport interface DividerProps extends ItemComponentProps<DividerSemanticProps> {}\n\n// Defaults from the editor schema\nconst DEFAULT_VALUES = {\n ...DividerDefaults,\n} as unknown as DividerValues;\n\n/**\n * Divider - Universal SSR/Client Component with Automatic Semantic Props\n *\n * @example Flat Props\n * ```tsx\n * <Divider borderTopWidth=\"2px\" borderTopColor=\"#ccc\" width=\"80%\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Divider values={{\n * border: { borderTopWidth: \"2px\", borderTopColor: \"#ccc\" },\n * width: \"80%\"\n * }} />\n * ```\n */\nconst Divider = createItemComponent<DividerValues, DividerSemanticProps>({\n name: \"Divider\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => mapSemanticProps(props as SemanticProps<DividerValues>, DEFAULT_VALUES, \"Divider\"),\n displayName: \"Divider\",\n exporters: DividerExporters,\n});\n\nexport default Divider;\n","import { HeadingExporters, HeadingDefaults } from \"@unlayer/exporters\";\nimport type { HeadingValues, TextStyleProps, HeadingLevel } from \"../types\";\nimport {\n createItemComponent,\n type ItemComponentProps\n} from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Heading semantic props — agent-friendly text/style types (replacing the loose\n * `any` flat props) plus the `level` alias and h1–h6 levels.\n */\ntype HeadingSemanticProps = Omit<\n SemanticProps<HeadingValues>,\n keyof TextStyleProps | \"headingType\"\n> &\n TextStyleProps & {\n /** Heading level h1–h6. */\n headingType?: HeadingLevel;\n /** Alias for `headingType`. */\n level?: HeadingLevel;\n /** Heading text (or use children). */\n text?: string;\n };\n\n/**\n * Heading Component Props\n * Automatically provides autocomplete for ALL properties (flat and nested)\n */\nexport interface HeadingProps extends ItemComponentProps<HeadingSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific additions\nconst DEFAULT_VALUES = {\n ...HeadingDefaults,\n color: \"#000000\", // Not in schema options but used by renderer\n fontWeight: 400, // Not in schema options but used by renderer\n text: \"Heading\", // React convenience — not in schema\n} as unknown as HeadingValues;\n\n/**\n * Heading - Universal SSR/Client Component with Semantic Props API\n *\n * ✅ Semantic flat props (level, color, fontSize, etc.)\n * ✅ Escape hatch: values prop for full control\n * ✅ Works on both server and client\n * ✅ Minimal boilerplate using component factory\n *\n * @example Semantic Props (Recommended)\n * ```tsx\n * <Heading level=\"h1\" color=\"#222\" fontSize=\"32px\">\n * Welcome\n * </Heading>\n * ```\n *\n * @example Full Control via Values\n * ```tsx\n * <Heading values={{ headingType: \"h1\", color: \"#222\" }}>Welcome</Heading>\n * ```\n */\nconst Heading = createItemComponent<HeadingValues, HeadingSemanticProps>({\n name: \"Heading\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { level, ...rest } = props as SemanticProps<HeadingValues> & { level?: HeadingValues[\"headingType\"] };\n const result = mapSemanticProps(rest as SemanticProps<HeadingValues>, DEFAULT_VALUES, \"Heading\");\n // Map level prop to headingType\n if (level && !result.headingType) {\n result.headingType = level;\n }\n return result;\n },\n displayName: \"Heading\",\n exporters: HeadingExporters,\n});\n\nexport default Heading;\n","import { HtmlExporters, HtmlDefaults } from \"@unlayer/exporters\";\nimport type { HtmlValues } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\nexport interface HtmlProps extends ItemComponentProps<SemanticProps<HtmlValues>> {}\n\n// Defaults from the editor schema\nconst DEFAULT_VALUES = {\n ...HtmlDefaults,\n} as unknown as HtmlValues;\n\n/**\n * Html - Universal SSR/Client Component for custom HTML with Automatic Semantic Props\n *\n * ⚠️ Renders the HTML verbatim — it is NOT sanitized by default. Only pass HTML\n * you trust, and make sure it is valid: notably, an inline SVG inside a `url(...)`\n * must be URL-encoded, because a raw `\"` inside a double-quoted `style=\"…\"`\n * closes the attribute and the rest leaks out as text. To sanitize (matching the\n * editor's HTML block, which strips scripts/event handlers), pass a `toSafeHtml`\n * function via the `UnlayerProvider` config.\n *\n * @example Flat Props\n * ```tsx\n * <Html html=\"<div>Custom HTML</div>\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Html values={{ html: \"<div>Custom HTML</div>\" }} />\n * ```\n */\nconst Html = createItemComponent<HtmlValues, SemanticProps<HtmlValues>>({\n name: \"Html\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => mapSemanticProps(props, DEFAULT_VALUES, \"Html\"),\n displayName: \"Html\",\n exporters: HtmlExporters,\n});\n\nexport default Html;\n","import { ImageExporters, ImageDefaults } from \"@unlayer/exporters\";\nimport type { ImageValues, ImageSrcInput, SizeInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Image semantic props — agent-friendly `src` (plain URL string or value object)\n * and CSS-style sizing (number/px pins, \"50%\" sets a percentage), replacing the\n * loose `any` flat props.\n */\ntype ImageSemanticProps = Omit<\n SemanticProps<ImageValues>,\n \"src\" | \"width\" | \"maxWidth\"\n> & {\n /** Alt text (alias for altText) */\n alt?: string;\n /** Image URL string, or the value object `{ url, width?, maxWidth?, ... }`. */\n src?: ImageSrcInput;\n /** Display width — number/px pins the image; \"50%\" sets a percentage width. */\n width?: SizeInput;\n /** Display width as a CSS value (\"50%\", \"300px\"). */\n maxWidth?: SizeInput;\n};\n\nexport interface ImageProps extends ItemComponentProps<ImageSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific overrides.\n// Drop the schema placeholder's `height` so an image with no explicit dimensions\n// doesn't inherit its 4:1 aspect ratio: the email exporter then omits the `height`\n// attribute (height:auto), letting the real image keep its own ratio instead of\n// being letterboxed (Outlook honors the height attribute). `width` is kept — it\n// drives the responsive display width attribute. Real dimensions, when provided\n// via an object `src`, override these.\nconst { height: _placeholderHeight, ...defaultSrc } = ImageDefaults.src as Record<string, unknown>;\nconst DEFAULT_VALUES = {\n ...ImageDefaults,\n src: {\n ...defaultSrc,\n autoWidth: true,\n maxWidth: \"100%\",\n },\n} as unknown as ImageValues;\n\n/**\n * Image - Renders an image element.\n *\n * @example Shorthand\n * ```tsx\n * <Image src=\"https://example.com/photo.jpg\" alt=\"A photo\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Image values={{\n * src: { url: \"https://example.com/image.jpg\", width: 600 },\n * altText: \"Description\"\n * }} />\n * ```\n */\nconst Image = createItemComponent<ImageValues, ImageSemanticProps>({\n name: \"Image\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n // `width`/`maxWidth` are DISPLAY intent — pull them out so mapSemanticProps\n // can't fold them into the natural-size `src.width` field. They drive\n // autoWidth + maxWidth below; the natural dimensions come only from an\n // object `src` / the loaded image.\n const { alt, src, width: widthProp, maxWidth: maxWidthProp, ...rest } = props;\n\n // Normalize a string `values.src` to { url } before mapping. mapSemanticProps\n // merges flat src props onto the src group by spreading; if the escape-hatch\n // src is a string, spreading it character-spreads the URL into numeric keys\n // ({0:\"h\",1:\"t\",…}) and loses the url. Wrapping it first keeps the merge\n // object-to-object.\n const restValues = (rest as { values?: { src?: unknown } }).values;\n const normalizedRest =\n restValues && typeof restValues.src === \"string\"\n ? { ...rest, values: { ...restValues, src: { url: restValues.src } } }\n : rest;\n\n const base: Partial<ImageValues> = mapSemanticProps(\n normalizedRest as SemanticProps<ImageValues>,\n DEFAULT_VALUES,\n \"Image\"\n );\n\n // Map alt → altText\n if (alt !== undefined) {\n base.altText = alt;\n }\n\n // Build the src value. Note: ImageValues.src is typed as string (codegen\n // bug) but the exporter expects { url, autoWidth?, maxWidth?, width?, ... }.\n // Natural src fields come from the `src` prop (string or object) and the\n // `values.src` escape hatch (which lands on `base.src` via mapSemanticProps);\n // the display `width`/`maxWidth` props were pulled out above. Combine the\n // natural fields (defensively, since base.src may be a string or non-object),\n // then apply the display intent.\n const baseSrc = (base as Record<string, any>).src;\n const fromValues: Record<string, any> =\n baseSrc && typeof baseSrc === \"object\" && !Array.isArray(baseSrc)\n ? (baseSrc as Record<string, any>)\n : typeof baseSrc === \"string\"\n ? { url: baseSrc }\n : {};\n const fromProp: Record<string, any> =\n typeof src === \"string\" ? { url: src } : (src ?? {}) as Record<string, any>;\n const userSrc = { ...fromValues, ...fromProp };\n\n if (src !== undefined || baseSrc !== undefined) {\n // A string url (from the `src` prop or `values.src`) carries no\n // dimensions, so it starts responsive with no placeholder size; an object\n // src starts from the schema defaults.\n const isStringUrl =\n typeof src === \"string\" || (src === undefined && typeof baseSrc === \"string\");\n const start = isStringUrl\n ? { autoWidth: true, maxWidth: \"100%\" }\n : { ...DEFAULT_VALUES.src };\n const merged = { ...start, ...userSrc } as Record<string, any>;\n\n // Display size = autoWidth + maxWidth: the default is responsive\n // (autoWidth:true); a fixed display size is autoWidth:false + `maxWidth` as a\n // PERCENT of the column's content slot (see image-sizing.ts for why a\n // percent, not a raw px). A px/number pin is kept here as a placeholder and\n // converted to that percent by the width-aware pass in renderToHtml /\n // renderToJson, where the column geometry is known.\n //\n // A `width` the author provides — the flat `width` prop OR `src.width`\n // (the documented full-control form) — is treated as that display intent and\n // pins. This is the canonical pinned shape the editor stores, so it survives\n // the round-trip; an `autoWidth` set explicitly on `src` is honored as-is.\n const pctRe = /^\\d+(?:\\.\\d+)?%$/;\n const asPercent = (v: unknown): string | undefined =>\n typeof v === \"string\" && pctRe.test(v.trim()) ? v.trim() : undefined;\n const asPx = (v: unknown): number | undefined => {\n if (typeof v === \"number\" && Number.isFinite(v)) return v;\n if (typeof v === \"string\") {\n const t = v.trim();\n if (pctRe.test(t)) return undefined;\n const m = /^(\\d+(?:\\.\\d+)?)(?:px)?$/.exec(t);\n if (m) return parseFloat(m[1]);\n }\n return undefined;\n };\n\n // Resolve display intent in priority order: flat `width` → flat `maxWidth`\n // → object src `maxWidth` → object src `width`.\n let displayPct: string | undefined;\n let displayPx: number | undefined;\n for (const candidate of [widthProp, maxWidthProp, userSrc.maxWidth, userSrc.width]) {\n if (candidate === undefined) continue;\n const pct = asPercent(candidate);\n if (pct) {\n displayPct = pct;\n break;\n }\n const px = asPx(candidate);\n if (px != null) {\n displayPx = px;\n break;\n }\n }\n\n // An explicit escape-hatch `autoWidth` is honored as-is (its own maxWidth\n // stays); otherwise the display intent decides.\n if (userSrc.autoWidth === undefined) {\n if (displayPct && displayPct !== \"100%\") {\n merged.autoWidth = false;\n merged.maxWidth = displayPct;\n } else if (displayPx != null) {\n merged.autoWidth = false;\n merged.maxWidth = displayPx;\n } else {\n merged.autoWidth = true;\n merged.maxWidth = \"100%\";\n }\n }\n\n base.src = merged as ImageValues[\"src\"];\n }\n\n return base;\n },\n displayName: \"Image\",\n exporters: ImageExporters,\n});\n\nexport default Image;\n","import { MenuExporters, MenuDefaults } from \"@unlayer/exporters\";\nimport type { MenuValues, MenuItem, SizeInput, TextStyleProps } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n// Menu carries fontFamily/fontWeight/fontSize/letterSpacing (but not color or\n// lineHeight) — relax those to the same agent-friendly inputs Heading/Paragraph\n// use, so a string fontFamily or a number/em size type-checks (normalized at\n// render time). It has no `color` field (uses linkColor/textColor).\ntype MenuSemanticProps = Omit<\n SemanticProps<MenuValues>,\n \"padding\" | \"fontFamily\" | \"fontWeight\" | \"fontSize\" | \"letterSpacing\"\n> &\n Omit<TextStyleProps, \"color\" | \"lineHeight\"> & {\n /** Menu items shorthand */\n items?: MenuItem[];\n /** Inner padding — a number (→ px) or CSS string. */\n padding?: SizeInput;\n };\n\nexport interface MenuProps extends ItemComponentProps<MenuSemanticProps> {}\n\n// Defaults from the editor schema\nconst DEFAULT_MENU: NonNullable<MenuValues[\"menu\"]> = MenuDefaults.menu ?? { items: [] };\n\nconst DEFAULT_VALUES = {\n ...MenuDefaults,\n} as unknown as MenuValues;\n\n/**\n * Menu - Renders a navigation menu.\n *\n * @example Shorthand\n * ```tsx\n * <Menu items={[{ text: \"Home\", href: \"/\" }, { text: \"About\", href: \"/about\" }]} />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Menu values={{\n * menu: {\n * items: [\n * { key: \"home\", text: \"Home\", link: { name: \"web\", values: { href: \"/\" } } }\n * ]\n * }\n * }} />\n * ```\n */\nconst Menu = createItemComponent<MenuValues, MenuSemanticProps>({\n name: \"Menu\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { items, ...rest } = props;\n\n if (Array.isArray(items)) {\n const mapped = items.map((item: MenuItem, i: number) => ({\n key: String(i + 1),\n text: item.text,\n link: {\n name: \"web\",\n values: { href: item.href, target: item.target ?? \"_blank\" },\n },\n }));\n const base: Partial<MenuValues> = mapSemanticProps(\n rest as SemanticProps<MenuValues>,\n DEFAULT_VALUES,\n \"Menu\"\n );\n base.menu = { items: mapped };\n return base;\n }\n\n return mapSemanticProps(\n props as SemanticProps<MenuValues>,\n DEFAULT_VALUES,\n \"Menu\"\n );\n },\n displayName: \"Menu\",\n exporters: MenuExporters,\n});\n\nexport default Menu;\n","import { ParagraphExporters, ParagraphDefaults } from \"@unlayer/exporters\";\nimport type { ParagraphValues, TextStyleProps } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n/**\n * Paragraph semantic props — agent-friendly text/style types (replacing the\n * loose `any` flat props) plus the `text` shorthand (converted to textJson).\n */\ntype ParagraphSemanticProps = Omit<\n SemanticProps<ParagraphValues>,\n keyof TextStyleProps\n> &\n TextStyleProps & {\n /** Plain-text content (or use `html` for inline formatting, or children). */\n text?: string;\n };\n\n/**\n * Paragraph Component Props\n * Automatically provides autocomplete for ALL properties (flat and nested)\n */\nexport interface ParagraphProps extends ItemComponentProps<ParagraphSemanticProps> {}\n\n// Defaults from the editor schema, plus React-specific additions\nconst DEFAULT_VALUES = {\n ...ParagraphDefaults,\n color: \"#000000\", // Not in schema options but used by renderer\n} as unknown as ParagraphValues;\n\n/**\n * Paragraph - Universal SSR/Client Component with Semantic Props API\n *\n * ✅ Semantic flat props (color, fontSize, textAlign, etc.)\n * ✅ Escape hatch: values prop for full control\n * ✅ Works on both server and client\n * ✅ Minimal boilerplate using component factory\n *\n * @example Semantic Props (Recommended)\n * ```tsx\n * <Paragraph color=\"#555\" fontSize=\"14px\" lineHeight=\"1.6\">\n * Your paragraph content here with <strong>rich text</strong> support\n * </Paragraph>\n * ```\n *\n * @example Full Control via Values\n * ```tsx\n * <Paragraph values={{ textJson: \"...\", color: \"#555\" }} />\n * ```\n */\nconst Paragraph = createItemComponent<ParagraphValues, ParagraphSemanticProps>({\n name: \"Paragraph\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) =>\n mapSemanticProps(props as SemanticProps<ParagraphValues>, DEFAULT_VALUES, \"Paragraph\"),\n displayName: \"Paragraph\",\n exporters: ParagraphExporters,\n});\n\nexport default Paragraph;\n","import { SocialExporters, SocialDefaults } from \"@unlayer/exporters\";\nimport type { SocialValues, SocialIcon, SizeInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\n// `iconSize`/`spacing` are pixel counts the exporter does arithmetic on, so they\n// must reach it as numbers. Accept a number or a px string for DX and coerce in\n// the mapper — a raw \"34px\" would otherwise render `max-width:NaNpx`.\ntype SocialSemanticProps = Omit<SemanticProps<SocialValues>, \"iconSize\" | \"spacing\"> & {\n /** Social icons shorthand (array of {name, url}) */\n icons?: SocialIcon[];\n /** Icon shape */\n iconType?: \"circle\" | \"rounded\" | \"squared\";\n /** Icon size in px — a number (34) or px string (\"34px\"). */\n iconSize?: SizeInput;\n /** Gap between icons in px — a number or px string. */\n spacing?: SizeInput;\n};\n\nexport interface SocialProps\n extends Omit<ItemComponentProps<SemanticProps<SocialValues>>, \"icons\" | \"iconSize\" | \"spacing\"> {\n icons?: SocialIcon[] | SocialValues[\"icons\"];\n iconType?: \"circle\" | \"rounded\" | \"squared\";\n iconSize?: SizeInput;\n spacing?: SizeInput;\n}\n\n// Defaults from the editor schema\nconst DEFAULT_ICONS: SocialValues[\"icons\"] = SocialDefaults.icons ?? { iconType: \"circle\", icons: [] };\n\nconst DEFAULT_VALUES = {\n ...SocialDefaults,\n} as unknown as SocialValues;\n\n/**\n * Social - Renders social-media icon links.\n *\n * @example Shorthand\n * ```tsx\n * <Social icons={[{ name: \"Facebook\", url: \"https://facebook.com\" }]} iconType=\"rounded\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Social values={{\n * icons: { icons: [\n * { name: \"Facebook\", url: \"https://facebook.com/...\" },\n * { name: \"Twitter\", url: \"https://twitter.com/...\" }\n * ]}\n * }} />\n * ```\n */\nconst Social = createItemComponent<SocialValues, SocialSemanticProps>({\n name: \"Social\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { icons, iconType, ...rest } = props;\n\n // The exporter does arithmetic on iconSize/spacing (icon box sizing and the\n // container max-width), so coerce a px string or number down to a number.\n const coerceSizes = (base: Partial<SocialValues>): Partial<SocialValues> => {\n for (const key of [\"iconSize\", \"spacing\"] as const) {\n const v = (base as Record<string, unknown>)[key];\n if (typeof v === \"string\") {\n // px count only — a non-px unit (\"50%\", \"1.5em\") is invalid here, so\n // drop it and let mergeValues fall back to the schema default.\n const m = /^(\\d+(?:\\.\\d+)?)(?:px)?$/.exec(v.trim());\n if (m) (base as Record<string, unknown>)[key] = parseFloat(m[1]);\n else delete (base as Record<string, unknown>)[key];\n }\n }\n return base;\n };\n\n // Map shorthand icons array → exporter format\n if (Array.isArray(icons)) {\n const mapped = icons.map((icon: SocialIcon) => ({\n name: icon.name,\n url: icon.url,\n }));\n const base: Partial<SocialValues> = mapSemanticProps(\n rest as SemanticProps<SocialValues>,\n DEFAULT_VALUES,\n \"Social\"\n );\n base.icons = {\n iconType: iconType ?? base.icons?.iconType ?? \"circle\",\n icons: mapped,\n };\n return coerceSizes(base);\n }\n\n // If iconType passed without shorthand icons, thread it into nested group\n if (iconType !== undefined) {\n const base: Partial<SocialValues> = mapSemanticProps(\n rest as SemanticProps<SocialValues>,\n DEFAULT_VALUES,\n \"Social\"\n );\n base.icons = { ...DEFAULT_ICONS, ...base.icons, iconType };\n return coerceSizes(base);\n }\n\n return coerceSizes(\n mapSemanticProps(props as SemanticProps<SocialValues>, DEFAULT_VALUES, \"Social\")\n );\n },\n displayName: \"Social\",\n exporters: SocialExporters,\n});\n\nexport default Social;\n","import { TableExporters, TableDefaults } from \"@unlayer/exporters\";\nimport type { TableValues, SizeInput, BorderInput } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\ntype TableSemanticProps = Omit<SemanticProps<TableValues>, \"padding\" | \"border\"> & {\n /** Column headers as string[] */\n headers?: string[];\n /** Row data as 2D string array */\n data?: string[][];\n /** Inner padding — a number (→ px) or CSS string. */\n padding?: SizeInput;\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n};\n\nexport interface TableProps\n extends Omit<ItemComponentProps<Omit<SemanticProps<TableValues>, \"padding\" | \"border\">>, \"headers\" | \"data\"> {\n headers?: string[];\n data?: string[][];\n /** Inner padding — a number (→ px) or CSS string. */\n padding?: SizeInput;\n /** Per-side border object (width fields accept a number/px string). */\n border?: BorderInput;\n}\n\n// Defaults from the editor schema, plus table data structure\nconst DEFAULT_TABLE: NonNullable<TableValues[\"table\"]> = { headers: [], rows: [], footers: [] };\n\nconst DEFAULT_VALUES = {\n ...TableDefaults,\n table: DEFAULT_TABLE, // Schema doesn't include table data structure\n} as unknown as TableValues;\n\n/**\n * Table - Renders a data table.\n *\n * @example Shorthand\n * ```tsx\n * <Table\n * headers={[\"Name\", \"Email\", \"Role\"]}\n * data={[[\"Alice\", \"alice@co.com\", \"Admin\"], [\"Bob\", \"bob@co.com\", \"User\"]]}\n * />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Table values={{\n * table: {\n * headers: [{ cells: [{ text: \"Name\" }, { text: \"Email\" }] }],\n * rows: [{ cells: [{ text: \"John\" }, { text: \"john@example.com\" }] }]\n * },\n * enableHeader: true\n * }} />\n * ```\n */\nconst Table = createItemComponent<TableValues, TableSemanticProps>({\n name: \"Table\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n // `columns`/`rows` are top-level COUNTS, but the table data lives under the\n // nested `table` group whose keys also include `rows` — so routing the flat\n // `rows` through the generic mapper collides with `table.rows` and makes the\n // exporter iterate a number (crash). Pull them out and handle them here.\n const { headers, data, columns, rows, ...rest } = props as typeof props & {\n columns?: number;\n rows?: number;\n };\n\n if (\n headers ||\n data ||\n typeof columns === \"number\" ||\n typeof rows === \"number\"\n ) {\n const base: Partial<TableValues> = mapSemanticProps(\n rest as SemanticProps<TableValues>,\n DEFAULT_VALUES,\n \"Table\"\n );\n\n const colCount = headers\n ? headers.length\n : typeof columns === \"number\"\n ? columns\n : data?.[0]?.length ?? 0;\n const blankCells = (n: number) =>\n Array.from({ length: n }, () => ({ text: \"\", width: 0 }));\n\n const tableHeaders = headers\n ? [{ cells: headers.map((text: string) => ({ text, width: 0 })), height: 0 }]\n : [];\n\n const tableRows = data\n ? data.map((row: string[]) => ({\n cells: row.map((text: string) => ({ text, width: 0 })),\n height: 0,\n }))\n : typeof rows === \"number\"\n ? // No data: build an empty grid sized by `columns` × `rows`.\n Array.from({ length: rows }, () => ({\n cells: blankCells(colCount),\n height: 0,\n }))\n : [];\n\n base.table = { headers: tableHeaders, rows: tableRows, footers: [] };\n\n if (headers || typeof columns === \"number\") {\n base.columns = colCount;\n }\n if (headers) {\n base.enableHeader = true;\n }\n if (data) {\n base.rows = data.length;\n } else if (typeof rows === \"number\") {\n base.rows = rows;\n }\n\n return base;\n }\n\n return mapSemanticProps(\n props as SemanticProps<TableValues>,\n DEFAULT_VALUES,\n \"Table\"\n );\n },\n displayName: \"Table\",\n exporters: TableExporters,\n});\n\nexport default Table;\n","import { VideoExporters, VideoDefaults } from \"@unlayer/exporters\";\nimport type { VideoValues } from \"../types\";\nimport { createItemComponent, type ItemComponentProps } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\n\ntype VideoSemanticProps = SemanticProps<VideoValues> & {\n /** YouTube/Vimeo URL (auto-parsed) */\n videoUrl?: string;\n};\n\nexport interface VideoProps extends ItemComponentProps<SemanticProps<VideoValues>> {\n videoUrl?: string;\n}\n\n// Defaults from the editor schema, plus React-specific video structure\nconst DEFAULT_VIDEO: NonNullable<VideoValues[\"video\"]> = {\n type: \"youtube\",\n videoId: \"\",\n thumbnail: \"\",\n loading: false,\n ...VideoDefaults.video,\n};\n\nconst DEFAULT_VALUES = {\n ...VideoDefaults,\n video: DEFAULT_VIDEO,\n} as unknown as VideoValues;\n\n/**\n * Parses a YouTube or Vimeo URL and returns exporter-ready video data.\n */\nexport function parseVideoUrl(url: string): { type: \"youtube\" | \"vimeo\"; videoId: string; thumbnail: string } | null {\n // YouTube: youtube.com/watch?v=ID, youtu.be/ID, youtube.com/embed/ID\n const ytMatch = url.match(\n /(?:youtube\\.com\\/(?:watch\\?v=|embed\\/)|youtu\\.be\\/)([a-zA-Z0-9_-]{11})/\n );\n if (ytMatch) {\n const videoId = ytMatch[1];\n return {\n type: \"youtube\",\n videoId,\n thumbnail: `https://img.youtube.com/vi/${videoId}/0.jpg`,\n };\n }\n\n // Vimeo: vimeo.com/ID\n const vimeoMatch = url.match(/vimeo\\.com\\/(\\d+)/);\n if (vimeoMatch) {\n return {\n type: \"vimeo\",\n videoId: vimeoMatch[1],\n thumbnail: \"\",\n };\n }\n\n return null;\n}\n\n/**\n * Video - Renders an embedded video player (YouTube/Vimeo).\n *\n * @example Shorthand\n * ```tsx\n * <Video videoUrl=\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\" />\n * ```\n *\n * @example Full Control\n * ```tsx\n * <Video values={{\n * video: { type: \"youtube\", videoId: \"dQw4w9WgXcQ\", thumbnail: \"...\" }\n * }} />\n * ```\n */\nconst Video = createItemComponent<VideoValues, VideoSemanticProps>({\n name: \"Video\",\n defaultValues: DEFAULT_VALUES,\n propMapper: (props) => {\n const { videoUrl, ...rest } = props;\n\n if (typeof videoUrl === \"string\") {\n const parsed = parseVideoUrl(videoUrl);\n const base: Partial<VideoValues> = mapSemanticProps(\n rest as SemanticProps<VideoValues>,\n DEFAULT_VALUES,\n \"Video\"\n );\n if (parsed) {\n base.video = { ...DEFAULT_VIDEO, ...parsed };\n }\n return base;\n }\n\n return mapSemanticProps(\n props as SemanticProps<VideoValues>,\n DEFAULT_VALUES,\n \"Video\"\n );\n },\n displayName: \"Video\",\n exporters: VideoExporters,\n});\n\nexport default Video;\n","/**\n * Default values for container components (Body, Row, Column).\n *\n * Runtime values come from @unlayer/exporters (extracted from the editor\n * schema at generation time). Types come from @unlayer/types\n * (generated from the same schema). Both are single source of truth.\n *\n * Imported by both render-to-json.ts and extract-head.ts to ensure the\n * JSON output and head CSS always use consistent defaults.\n */\n\nimport {\n BodyDefaults,\n RowDefaults,\n ColumnDefaults,\n} from \"@unlayer/exporters\";\nimport type { BodyValues, RowValues, ColumnValues } from \"@unlayer-internal/shared-elements\";\n\n// Body defaults from the editor schema.\n// Filter out popup-specific fields that aren't relevant for email/web rendering.\nconst allBodyDefaults = BodyDefaults as Record<string, any>;\nconst {\n popupPosition: _p1,\n popupDisplayDelay: _p2,\n popupWidth: _p3,\n popupHeight: _p4,\n popupBackgroundColor: _p5,\n popupBackgroundImage: _p6,\n popupOverlay_backgroundColor: _p7,\n popupCloseButton_position: _p8,\n popupCloseButton_backgroundColor: _p9,\n popupCloseButton_iconColor: _p10,\n popupCloseButton_borderRadius: _p11,\n popupCloseButton_margin: _p12,\n popupCloseButton_action: _p13,\n ...bodyRest\n} = allBodyDefaults;\n\nexport const BODY_DEFAULTS = bodyRest as BodyValues;\n\nexport const ROW_DEFAULTS = { ...RowDefaults } as RowValues;\n\nexport const COLUMN_DEFAULTS = { ...ColumnDefaults } as ColumnValues;\n","import React from \"react\";\nimport type { RenderMode, UnlayerConfig, RowValues } from \"@unlayer-internal/shared-elements\";\nimport { validateColumnLayout } from \"@unlayer-internal/shared-elements\";\nimport type { ColumnLayout } from \"@unlayer-internal/shared-elements\";\nimport { RowExporters } from \"@unlayer/exporters\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\nimport { nextHtmlId } from \"../utils/create-component\";\nimport { bodyContentWidthPx } from \"../utils/image-sizing\";\nimport type { SizeInput } from \"../types\";\nimport { ROW_DEFAULTS, BODY_DEFAULTS } from \"../utils/container-defaults\";\n\n/**\n * Row - Container for columns in a layout\n *\n * Uses the Row exporter from @unlayer/exporters.\n * Column children call their own exporters.\n *\n * @example\n * ```tsx\n * <Row cells={[1, 1]}>\n * <Column><Button>Click me</Button></Column>\n * <Column><Paragraph>Hello</Paragraph></Column>\n * </Row>\n * ```\n */\n\nconst DEFAULT_VALUES = ROW_DEFAULTS;\n\nconst DEFAULT_BODY_VALUES = BODY_DEFAULTS;\n\nexport type RowProps = Omit<SemanticProps<RowValues>, \"padding\"> & {\n children?: React.ReactNode;\n layout?: ColumnLayout;\n cells?: number[];\n mode?: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n index?: number;\n bodyValues?: any;\n collection?: string;\n /** Padding — a CSS string (\"0 48px\", \"20px 40px\") or a number (px). */\n padding?: SizeInput;\n /** @internal - Unlayer config threaded from UnlayerProvider via Body */\n _config?: UnlayerConfig;\n};\n\n// ============================================\n// Grid CSS (inlined from shared/utils/grid-css.ts)\n// ============================================\n\ninterface WidthPercentage {\n value: number;\n className: string;\n}\n\nfunction getWidthPercentages(cells: number[]): WidthPercentage[] {\n if (cells.length === 0) return [];\n const total = cells.reduce((a, b) => a + b, 0);\n if (total <= 0) return [];\n return cells.map((span) => {\n const value = Math.round((span / total) * 100 * 100) / 100;\n const className = `${value}`.replace(/\\./g, 'p');\n return { value, className };\n });\n}\n\nfunction generateGridCSS(cells: number[], mode: RenderMode, contentWidth: number = 600, mobileBreakpoint: number = 620): string {\n const widths = getWidthPercentages(cells);\n\n if (mode === 'email') {\n const minQuery = `@media only screen and (min-width: ${contentWidth + 20}px)`;\n const maxQuery = `@media only screen and (max-width: ${contentWidth + 20}px)`;\n\n return `\n${minQuery} {\n .u-row { width: ${contentWidth}px !important; }\n .u-row .u-col { vertical-align: top; }\n${widths.map(({ value, className }) => ` .u-row .u-col-${className} { width: ${Math.round((contentWidth * value) / 100)}px !important; }`).join('\\n')}\n}\n\n${maxQuery} {\n .u-row-container { max-width: 100% !important; padding-left: 0px !important; padding-right: 0px !important; }\n .u-row { width: 100% !important; }\n .u-row .u-col { display: block !important; width: 100% !important; min-width: 320px !important; max-width: 100% !important; }\n .u-row .u-col > div { margin: 0 auto; }\n .no-stack .u-col { min-width: 0 !important; display: table-cell !important; }\n${widths.map(({ value, className }) => ` .no-stack .u-col-${className} { width: ${value}% !important; }`).join('\\n')}\n}`;\n }\n\n // Web mode\n const baseCSS = `\n.u-row {\n display: flex;\n flex-wrap: nowrap;\n margin-left: 0;\n margin-right: 0;\n}\n.u-row .u-col {\n position: relative;\n width: 100%;\n padding-right: 0;\n padding-left: 0;\n}`;\n\n const columnCSS = widths\n .map(\n ({ value, className }) =>\n `.u-row .u-col.u-col-${className} { flex: 0 0 ${value}%; max-width: ${value}%; }`,\n )\n .join('\\n');\n\n const responsiveCSS = `\n@media only screen and (max-width: ${mobileBreakpoint}px) {\n .u-row { width: 100% !important; }\n .u-row .u-col {\n display: block !important;\n width: 100% !important;\n min-width: 320px !important;\n max-width: 100% !important;\n }\n .u-row .u-col > div { margin: 0 auto; }\n .no-stack .u-col {\n min-width: 0 !important;\n display: table-cell !important;\n }\n${widths.map(({ value, className }) => ` .no-stack .u-col-${className} { width: ${value}% !important; }`).join('\\n')}\n}`;\n\n return baseCSS + '\\n' + columnCSS + '\\n' + responsiveCSS;\n}\n\n// ============================================\n// Row exporter wrapper (inlined from shared/utils/render-container-to-html.ts)\n// ============================================\n\ntype ContainerExporterFunction = (innerHTML: string, values: Record<string, any>, bodyValues?: Record<string, any>, options?: Record<string, any>) => string;\n\n/**\n * Resolve the row's content width (px number) from body values. contentWidth\n * may be \"600px\" (string), 600 (number), or \"600\" (bare numeric string); the\n * grid CSS needs a number. In EMAIL mode this drives the per-column desktop\n * widths and the stacking breakpoint — so without it, multi-column emails were\n * pinned to 600px regardless of <Body contentWidth>. Web mode uses percentages,\n * so this is a no-op there.\n *\n * Uses the same strict px parse as the image slot geometry (a non-px value like\n * \"50%\" → fallback, not a parseInt artifact like 50) so the two stay in sync.\n */\nfunction toContentWidthPx(bodyValues: any, fallback = 500): number {\n return bodyContentWidthPx(bodyValues?.contentWidth, fallback);\n}\n\nfunction renderRowToHtml(innerHTML: string, values: any, bodyValues: any, mode: RenderMode, cells: number[], collection: string = \"rows\"): string {\n const rowExporter = (RowExporters[mode] || RowExporters.web) as ContainerExporterFunction;\n const html = rowExporter(innerHTML, values, bodyValues, {\n collection,\n variant: mode,\n });\n\n const contentWidth = toContentWidthPx(bodyValues);\n const css = generateGridCSS(cells, mode, contentWidth);\n return css ? `<style>${css}</style>${html}` : html;\n}\n\n// ============================================\n// Children processing\n// ============================================\n\nfunction processChildren(\n children: React.ReactNode,\n cells: number[],\n bodyValues: any,\n rowValues: any,\n mode: RenderMode,\n _config?: UnlayerConfig\n): string {\n if (!children) return \"\";\n\n let innerHTML = \"\";\n const childrenArray = React.Children.toArray(children);\n\n childrenArray.forEach((child, index) => {\n if (!React.isValidElement(child)) {\n if (typeof child === \"string\" || typeof child === \"number\") {\n innerHTML += String(child);\n }\n return;\n }\n\n const componentType = child.type as any;\n const isColumn =\n componentType?.displayName === \"Column\" ||\n componentType?.name === \"Column\";\n\n if (isColumn && typeof child.type === \"function\") {\n // Call Column component with context props\n const rendered = (child.type as Function)({\n ...child.props,\n index,\n cells,\n bodyValues,\n rowValues,\n mode,\n _config\n });\n\n // Extract HTML from dangerouslySetInnerHTML\n if (rendered?.props?.dangerouslySetInnerHTML?.__html) {\n innerHTML += rendered.props.dangerouslySetInnerHTML.__html;\n }\n } else if (React.isValidElement(child)) {\n const name = (child.type as any)?.displayName || (child.type as any)?.name || \"Unknown\";\n console.warn(\n `Row: <${name}> is not a valid Row child. Only <Column> components can be direct children of <Row>. ` +\n `Wrap it in a <Column>: <Row><Column><${name} /></Column></Row>`\n );\n }\n });\n\n return innerHTML;\n}\n\n// ============================================\n// Component\n// ============================================\n\nconst Row: React.FC<RowProps> = (props) => {\n const {\n layout,\n cells: propsCells,\n children,\n mode: modeProp,\n className,\n style,\n index = 0,\n bodyValues = {},\n collection = \"rows\",\n _config,\n ...semanticProps\n } = props;\n\n // Resolve mode: explicit prop > _config > default\n const mode: RenderMode = modeProp ?? _config?.mode ?? \"web\";\n\n // Determine cells from layout or props\n let cells = propsCells || [1];\n if (layout) {\n validateColumnLayout(layout, React.Children.count(children));\n cells = layout.cells;\n }\n\n // Merge body values with defaults\n const safeBodyValues = { ...DEFAULT_BODY_VALUES, ...bodyValues };\n\n // Map semantic props to values\n const values = mapSemanticProps<RowValues>(\n semanticProps as SemanticProps<RowValues>,\n DEFAULT_VALUES,\n \"Row\"\n );\n\n const valuesWithMeta = {\n ...values,\n cells,\n _meta: {\n htmlID: nextHtmlId(_config, \"u_row\"),\n htmlClassNames: \"u_row\",\n ...(values._meta || {})\n }\n };\n\n // Process Column children\n const innerHTML = processChildren(\n children,\n cells,\n safeBodyValues,\n valuesWithMeta,\n mode,\n _config\n );\n\n try {\n const html = renderRowToHtml(innerHTML, valuesWithMeta, safeBodyValues, mode, cells, collection);\n\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n className={className}\n style={style}\n />\n );\n } catch (error) {\n console.error(\"Row rendering failed:\", error);\n return (\n <div className={className} style={style}>\n {children}\n </div>\n );\n }\n};\n\nRow.displayName = \"Row\";\n\nexport default Row;\n","import React from \"react\";\nimport type { RenderMode, UnlayerConfig, ColumnValues } from \"@unlayer-internal/shared-elements\";\nimport { ColumnExporters, ContentExporters } from \"@unlayer/exporters\";\nimport { UNLAYER_RENDER_KEY, nextHtmlId } from \"../utils/create-component\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\nimport type { SizeInput, BorderInput } from \"../types\";\nimport { COLUMN_DEFAULTS } from \"../utils/container-defaults\";\n\n/** Unlayer's default content-block padding when a block sets none. */\nconst DEFAULT_CONTAINER_PADDING = \"10px\";\n\n/**\n * Column - Single column in a Row layout\n *\n * Calls the Column exporter from @unlayer/exporters.\n * Must be used inside <Row> component.\n *\n * @example\n * ```tsx\n * <Row cells={[1, 1]}>\n * <Column>\n * <Button>Click me</Button>\n * </Column>\n * <Column>\n * <Paragraph>Hello</Paragraph>\n * </Column>\n * </Row>\n * ```\n */\n\nconst DEFAULT_VALUES = COLUMN_DEFAULTS;\n\n// ============================================\n// Column exporter wrapper (inlined from shared/utils/render-container-to-html.ts)\n// ============================================\n\ntype ColumnExporterFunction = (innerHTML: string, values: Record<string, any>, index: number, cells: number[], bodyValues?: Record<string, any>, rowValues?: Record<string, any>) => string;\n\nfunction renderColumnToHtml(innerHTML: string, values: any, index: number, cells: number[], bodyValues: any, rowValues: any, mode: RenderMode): string {\n const columnExporter = (ColumnExporters[mode] || ColumnExporters.web) as ColumnExporterFunction;\n return columnExporter(innerHTML, values, index, cells, bodyValues, rowValues);\n}\n\n// Canonical content-container wrapper (the `u_content_*` block that carries\n// each item's containerPadding). Signature per mode: (innerHTML, values,\n// bodyValues, meta). Delegating to the exporter keeps padding, classes, and the\n// per-mode div/table structure consistent with the canonical exporter output.\ntype ContentExporterFunction = (innerHTML: string, values: Record<string, any>, bodyValues?: Record<string, any>, meta?: Record<string, any>) => string;\n\nfunction renderContentToHtml(innerHTML: string, values: any, bodyValues: any, mode: RenderMode): string {\n const contentExporter = (ContentExporters[mode] || ContentExporters.web) as ContentExporterFunction;\n return contentExporter(innerHTML, values, bodyValues, {});\n}\n\n// ============================================\n// Component\n// ============================================\n\nexport type ColumnProps = Omit<SemanticProps<ColumnValues>, \"padding\" | \"border\" | \"borderRadius\"> & {\n children?: React.ReactNode;\n // Internal props (provided by Row)\n index?: number;\n cells?: number[];\n bodyValues?: any;\n rowValues?: any;\n mode?: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n /** Padding — a CSS string (\"0 24px\", \"10px\") or a number (px). */\n padding?: SizeInput;\n /** Corner radius — a number (→ px) or CSS string (\"8px\"). */\n borderRadius?: SizeInput;\n /** Per-side border object (great for hairline dividers). Width fields accept\n * a number/px string; reuse it as a factored-out const without `as const`. */\n border?: BorderInput;\n /** @internal - Unlayer config threaded from UnlayerProvider via Body/Row */\n _config?: UnlayerConfig;\n};\n\nexport const Column: React.FC<ColumnProps> = (props) => {\n const {\n children,\n index = 0,\n cells = [1],\n bodyValues = {},\n rowValues = {},\n mode: modeProp,\n className,\n style,\n _config,\n ...semanticProps\n } = props;\n\n // Resolve mode: explicit prop > _config > default\n const mode: RenderMode = modeProp ?? _config?.mode ?? \"web\";\n\n // Map semantic props to values\n const values = mapSemanticProps<ColumnValues>(\n semanticProps as SemanticProps<ColumnValues>,\n DEFAULT_VALUES,\n \"Column\"\n );\n\n // Add _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: nextHtmlId(_config, \"u_column\"),\n htmlClassNames: \"u_column\",\n ...(values._meta || {})\n }\n };\n\n // Render children to HTML - extract from dangerouslySetInnerHTML\n let innerHTML = \"\";\n if (children) {\n try {\n const childrenArray = React.Children.toArray(children);\n\n childrenArray.forEach((child, childIndex) => {\n if (typeof child === \"string\" || typeof child === \"number\") {\n innerHTML += String(child);\n } else if (React.isValidElement(child)) {\n // Call component function to get rendered result\n if (typeof child.type === \"function\") {\n const ComponentType = child.type as any;\n // Use __unlayerRender (hook-free) if available, otherwise call directly\n const renderFn: Function = ComponentType[UNLAYER_RENDER_KEY] || ComponentType;\n // Thread the column/body context so width-aware item exporters (Image)\n // can size against the real available width (contentWidth × column\n // fraction) instead of the fallback. Mirrors the editor, which passes\n // this context to the content exporters.\n const rendered = renderFn({\n ...child.props,\n _config,\n colIndex: index,\n cells,\n bodyValues,\n rowValues,\n columnValues: valuesWithMeta,\n });\n\n // Extract HTML from dangerouslySetInnerHTML\n if (\n rendered &&\n typeof rendered === \"object\" &&\n rendered.props &&\n rendered.props.dangerouslySetInnerHTML\n ) {\n const componentHTML =\n rendered.props.dangerouslySetInnerHTML.__html;\n const componentType = child.type as any;\n const componentName = (\n componentType?.displayName ||\n componentType?.name ||\n \"component\"\n ).toLowerCase();\n\n // Resolve the block's OWN containerPadding directly from props.\n // `containerPadding` is a universal base-content prop: it passes\n // straight through mapSemanticProps untouched and is not present in\n // any item's defaultValues, so reading it from props (flat prop +\n // `values` escape hatch) is equivalent to running the item's full\n // value pipeline — without paying for a second propMapper call per\n // child (for Paragraph that re-runs the Lexical textJson convert).\n // Falls back to Unlayer's content default. (Previously this read\n // `child.props.values?.containerPadding` only, which is undefined\n // for the flat-prop API, so every block collapsed to 0px padding.)\n const childProps = child.props as {\n containerPadding?: string | number;\n values?: { containerPadding?: string | number };\n };\n const rawContainerPadding =\n childProps.containerPadding ??\n childProps.values?.containerPadding ??\n DEFAULT_CONTAINER_PADDING;\n // A bare number is treated as px (same idiom as other size props).\n const containerPadding =\n typeof rawContainerPadding === \"number\"\n ? `${rawContainerPadding}px`\n : rawContainerPadding;\n\n // Wrap via the canonical content-container exporter for this mode.\n const contentValues = {\n containerPadding,\n _meta: {\n htmlID: nextHtmlId(_config, `u_content_${componentName}`),\n htmlClassNames: `u_content_${componentName}`,\n },\n };\n innerHTML += renderContentToHtml(\n componentHTML,\n contentValues,\n bodyValues,\n mode\n );\n } else if (rendered) {\n const name = (child.type as any)?.displayName || (child.type as any)?.name || \"Unknown\";\n console.warn(\n `Column: <${name}> did not produce renderable HTML. ` +\n `Ensure it is an Unlayer component (Button, Text, Image, etc.).`\n );\n }\n }\n }\n });\n } catch (error) {\n console.error(\"Column: Failed to render children:\", error);\n innerHTML = \"\";\n }\n }\n\n try {\n const html = renderColumnToHtml(innerHTML, valuesWithMeta, index, cells, bodyValues, rowValues, mode);\n\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n className={className}\n style={style}\n />\n );\n } catch (error) {\n console.error(\"Column rendering failed:\", error);\n return (\n <div className={className} style={style}>\n {children}\n </div>\n );\n }\n};\n\nColumn.displayName = \"Column\";\n\nexport default Column;\n","import React from \"react\";\nimport ReactDOMServer from \"react-dom/server\";\nimport type { RenderMode, UnlayerConfig, BodyValues } from \"@unlayer-internal/shared-elements\";\nimport { DEFAULT_CONFIG, mergeValues } from \"@unlayer-internal/shared-elements\";\nimport { BodyExporters } from \"@unlayer/exporters\";\nimport { mapSemanticProps, type SemanticProps } from \"../utils/semantic-props\";\nimport { nextHtmlId } from \"../utils/create-component\";\nimport type { SizeInput } from \"../types\";\nimport { BODY_DEFAULTS } from \"../utils/container-defaults\";\n\nexport type BodyProps = Omit<SemanticProps<BodyValues>, \"padding\" | \"borderRadius\"> & {\n children?: React.ReactNode;\n mode?: RenderMode;\n className?: string;\n style?: React.CSSProperties;\n index?: number;\n /** Optional config (replaces context-based config for Server Component usage) */\n config?: Partial<UnlayerConfig>;\n /** Preview text shown in email client inboxes (email mode only) */\n previewText?: string;\n /** Padding — a CSS string (\"0 48px\", \"20px\") or a number (px). */\n padding?: SizeInput;\n /** Corner radius — a number (→ px) or CSS string (\"8px\"). */\n borderRadius?: SizeInput;\n};\n\nconst DEFAULT_VALUES = BODY_DEFAULTS;\n\n// ============================================\n// Preview text (inlined from shared/utils/preview.ts)\n// ============================================\n\nconst MAX_PREVIEW_LENGTH = 150;\n\nconst PADDING_CHARS = [\n \"\\u00A0\", \"\\u200C\", \"\\u200B\", \"\\u200D\", \"\\u200E\", \"\\u200F\", \"\\uFEFF\",\n];\n\nfunction generatePreviewHtml(text: string): string {\n if (!text || text.trim().length === 0) return \"\";\n\n const truncated = text.length > MAX_PREVIEW_LENGTH\n ? text.slice(0, MAX_PREVIEW_LENGTH)\n : text;\n\n const paddingLength = Math.max(0, MAX_PREVIEW_LENGTH - truncated.length);\n let padding = \"\";\n for (let i = 0; i < paddingLength; i++) {\n padding += PADDING_CHARS[i % PADDING_CHARS.length];\n }\n\n return (\n `<div data-skip-in-text=\"true\" style=\"display:none;font-size:1px;color:#ffffff;line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;\">` +\n truncated +\n padding +\n `</div>`\n );\n}\n\n// ============================================\n// Body exporter wrapper (inlined from shared/utils/render-container-to-html.ts)\n// ============================================\n\ntype ContainerExporterFunction = (innerHTML: string, values: Record<string, any>, bodyValues?: Record<string, any>, options?: Record<string, any>) => string;\n\nfunction renderBodyToHtml(innerHTML: string, values: any, mode: RenderMode, previewText?: string): string {\n // Prepend preview text HTML in email mode\n let finalInnerHtml = innerHTML;\n if (mode === \"email\" && previewText) {\n const previewHtml = generatePreviewHtml(previewText);\n if (previewHtml) {\n finalInnerHtml = previewHtml + innerHTML;\n }\n }\n\n const bodyExporter = (BodyExporters[mode] || BodyExporters.web) as ContainerExporterFunction;\n // The email body exporter reads body context (contentWidth, contentAlign)\n // from `arg3.bodyValues` — it drives the Outlook (MSO) container table width.\n // Passing `values` directly left `bodyValues` undefined, pinning the Outlook\n // table to 600px regardless of contentWidth (modern clients were fine via the\n // container max-width, so non-600px emails rendered narrow only in Outlook).\n const raw =\n mode === \"document\"\n ? bodyExporter(finalInnerHtml, values, { type: \"\" })\n : mode === \"email\"\n ? // The email body exporter reads body context (contentWidth,\n // contentAlign) from the `bodyValues` field of its 3rd argument.\n // Passing `values` directly left it undefined, so the Outlook (MSO)\n // table fell back to 600px regardless of contentWidth.\n bodyExporter(finalInnerHtml, values, { bodyValues: values })\n : bodyExporter(finalInnerHtml, values, values);\n\n return raw\n .replace('min-height: 100vh; ', '')\n .replace('min-height: 100vh;', '');\n}\n\n// ============================================\n// Component\n// ============================================\n\n/**\n * Body - Universal Server/Client Component\n *\n * Works in both Server Components and Client Components.\n * In Server Components, pass config as a prop.\n * In Client Components, config can come from UnlayerProvider context or props.\n *\n * @example Server Component\n * ```tsx\n * <Body backgroundColor=\"#F7F8F9\" contentWidth=\"600px\" mode=\"web\">\n * <Row><Column><Paragraph values={{...}} mode=\"web\" /></Column></Row>\n * </Body>\n * ```\n *\n * @example Client Component with Provider\n * ```tsx\n * <UnlayerProvider config={{ mode: \"email\" }}>\n * <Body>...</Body>\n * </UnlayerProvider>\n * ```\n */\nconst Body: React.FC<BodyProps> = (props) => {\n const { children, mode: modeProp, className, style, index = 0, config: configProp, previewText, ...semanticProps } = props;\n\n // Resolve config: explicit prop > default (no hooks, Server Component safe)\n const resolvedConfig: UnlayerConfig = { ...DEFAULT_CONFIG, ...configProp };\n\n // Resolve mode: explicit prop > config > default\n const mode: RenderMode = modeProp ?? resolvedConfig.mode ?? \"web\";\n\n // Build _config to thread through children. Reset the per-render id counters so\n // unique ids are allocated across the whole tree (shared by reference downward).\n const _config: UnlayerConfig = { ...resolvedConfig, mode };\n (_config as { __ids?: Record<string, number> }).__ids = {};\n\n // Map semantic props, then merge BODY_DEFAULTS on top so the body always\n // carries its full default values (notably contentWidth \"500px\", textColor\n // \"#000000\") before rendering — the same way item components merge their\n // defaults. Without this the body exporter / grid CSS fall back to their own\n // internal defaults (e.g. 600px) instead of the schema default, so the\n // Outlook table, container, and grid CSS disagree. Mapped values win.\n const values = mergeValues<BodyValues>(\n DEFAULT_VALUES,\n mapSemanticProps<BodyValues>(semanticProps as SemanticProps<BodyValues>, DEFAULT_VALUES, \"Body\")\n );\n\n // Ensure _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: nextHtmlId(_config, \"u_body\"),\n htmlClassNames: \"u_body\",\n ...(values._meta || {})\n }\n };\n\n // Clone children with _config AND the body's resolved values so Row/Column\n // inherit body-level context — notably `contentWidth`, which determines the\n // row container max-width (and therefore each column's width) in web mode.\n // Without this, Row falls back to BODY_DEFAULTS.contentWidth (\"500px\") and\n // <Body contentWidth=\"…\"> is silently ignored for layout.\n let enrichedChildren = children;\n if (children) {\n enrichedChildren = React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return React.cloneElement(child as React.ReactElement<any>, {\n _config,\n bodyValues: values,\n });\n }\n return child;\n });\n }\n\n // Process children to innerHTML\n let innerHTML = \"\";\n if (enrichedChildren) {\n try {\n innerHTML = ReactDOMServer.renderToString(enrichedChildren as React.ReactElement);\n } catch (error) {\n console.error(\"Body: Failed to render children:\", error);\n innerHTML = \"\";\n }\n }\n\n try {\n const html = renderBodyToHtml(innerHTML, valuesWithMeta, mode, previewText);\n\n return (\n <div\n dangerouslySetInnerHTML={{ __html: html }}\n className={className}\n style={style}\n />\n );\n } catch (error) {\n console.error(\"Body rendering failed:\", error);\n return (\n <div className={className} style={style}>\n {children}\n </div>\n );\n }\n};\n\nBody.displayName = \"Body\";\n\nexport default Body;\n","import Body, { type BodyProps } from \"./Body\";\n\nexport type EmailProps = Omit<BodyProps, \"mode\">;\n\n/**\n * Email - Renders email-client safe HTML (tables for Outlook, Gmail, Yahoo).\n *\n * Thin wrapper around Body with mode locked to \"email\".\n *\n * @example\n * ```tsx\n * <Email backgroundColor=\"#f4f4f5\" contentWidth=\"560px\" previewText=\"Welcome!\">\n * <Row><Column><Paragraph text=\"Hello\" /></Column></Row>\n * </Email>\n * ```\n */\nexport default function Email(props: EmailProps) {\n return <Body {...props} mode=\"email\" />;\n}\n\nEmail.displayName = \"Email\";\n","import Body, { type BodyProps } from \"./Body\";\n\nexport type PageProps = Omit<BodyProps, \"mode\">;\n\n/**\n * Page - Renders with div/flexbox for responsive web display.\n *\n * Thin wrapper around Body with mode locked to \"web\".\n *\n * @example\n * ```tsx\n * <Page backgroundColor=\"#ffffff\" contentWidth=\"960px\">\n * <Row><Column><Paragraph text=\"Hello\" /></Column></Row>\n * </Page>\n * ```\n */\nexport default function Page(props: PageProps) {\n return <Body {...props} mode=\"web\" />;\n}\n\nPage.displayName = \"Page\";\n","import Body, { type BodyProps } from \"./Body\";\n\nexport type DocumentProps = Omit<BodyProps, \"mode\">;\n\n/**\n * Document - Print-optimized rendering for PDF generation.\n *\n * Thin wrapper around Body with mode locked to \"document\".\n *\n * @example\n * ```tsx\n * <Document backgroundColor=\"#ffffff\" contentWidth=\"700px\">\n * <Row><Column><Paragraph text=\"Hello\" /></Column></Row>\n * </Document>\n * ```\n */\nexport default function Document(props: DocumentProps) {\n return <Body {...props} mode=\"document\" />;\n}\n\nDocument.displayName = \"Document\";\n","\"use client\";\n\nimport React, { createContext, useContext, useMemo } from \"react\";\nimport type { UnlayerConfig } from \"@unlayer-internal/shared-elements\";\nimport { DEFAULT_CONFIG } from \"@unlayer-internal/shared-elements\";\n\n/**\n * @internal Flag added to context value when a provider is active.\n * Used by item components to detect provider-without-Body usage.\n */\nexport const PROVIDER_ACTIVE_KEY = \"__unlayerProviderActive\";\n\n// Lazy-init: createContext is not available in React Server Component modules.\n// Deferring the call ensures it only runs when UnlayerProvider or\n// useUnlayerConfig is actually invoked (always in a client context).\nlet _UnlayerContext: React.Context<UnlayerConfig> | null = null;\nfunction getUnlayerContext(): React.Context<UnlayerConfig> {\n if (!_UnlayerContext) {\n _UnlayerContext = createContext<UnlayerConfig>(DEFAULT_CONFIG);\n }\n return _UnlayerContext;\n}\n\nexport interface UnlayerProviderProps {\n config: Partial<UnlayerConfig>;\n children: React.ReactNode;\n}\n\nexport const UnlayerProvider: React.FC<UnlayerProviderProps> = ({\n config,\n children,\n}) => {\n const merged = useMemo(\n () => ({ ...DEFAULT_CONFIG, ...config, [PROVIDER_ACTIVE_KEY]: true }),\n [config]\n );\n\n const Context = getUnlayerContext();\n return (\n <Context.Provider value={merged}>\n {children}\n </Context.Provider>\n );\n};\n\nUnlayerProvider.displayName = \"UnlayerProvider\";\n\nexport function useUnlayerConfig(): UnlayerConfig {\n return useContext(getUnlayerContext());\n}\n","/**\n * extractHeadFromTree — Walk a React element tree and collect <head> CSS/JS\n * from the exporters' head functions.\n *\n * Mirrors the editor's extractHead.ts but works with the React element tree\n * instead of the Redux design state. Uses the same pattern as render-to-json.ts\n * to walk Body > Row > Column > Item structure.\n */\n\nimport React from \"react\";\nimport { heads } from \"@unlayer/exporters\";\nimport { mergeValues } from \"@unlayer-internal/shared-elements\";\nimport type { RenderMode, HeadConfig } from \"@unlayer-internal/shared-elements\";\nimport { mapSemanticProps } from \"./semantic-props\";\nimport { UNLAYER_CONFIG_KEY } from \"./create-component\";\nimport { BODY_DEFAULTS, ROW_DEFAULTS, COLUMN_DEFAULTS } from \"./container-defaults\";\n\n/** Args every head builder receives: (values, bodyValues, meta). */\ntype HeadArgs = [Record<string, any>, Record<string, any>, Record<string, any>];\n\n/**\n * Local type for a component's head contributions — the optional css/js/tags\n * builders this file invokes to collect the <head> CSS/JS/tags.\n */\ntype ComponentHead = {\n css?: (...args: HeadArgs) => string | undefined;\n js?: (...args: HeadArgs) => string | undefined;\n tags?: (...args: HeadArgs) => string[] | undefined;\n};\n\n// ============================================\n// Inlined helpers\n// ============================================\n\n/** Add _meta fields if not present. */\nfunction ensureMeta(values: any, type: string, index: number = 0): any {\n return {\n ...values,\n _meta: {\n htmlID: `u_content_${type.toLowerCase()}_${index + 1}`,\n htmlClassNames: `u_content_${type.toLowerCase()}`,\n ...(values._meta || {})\n }\n };\n}\n\n/** Get the displayName of a React element's component type. */\nfunction getDisplayName(element: React.ReactElement): string | undefined {\n const type = element.type as any;\n return type?.displayName || type?.name;\n}\n\n/** Collect valid React element children from a node. */\nfunction collectChildren(node: React.ReactNode): React.ReactElement[] {\n const result: React.ReactElement[] = [];\n React.Children.forEach(node, (child) => {\n if (React.isValidElement(child)) {\n result.push(child);\n }\n });\n return result;\n}\n\n/**\n * Strip internal/base props from an element's props,\n * returning only the semantic props that should be mapped to values.\n */\nfunction extractSemanticProps(\n props: Record<string, any>,\n extraKeys: string[] = []\n): Record<string, any> {\n const internalKeys = new Set([\n \"children\",\n \"mode\",\n \"className\",\n \"style\",\n \"index\",\n \"colIndex\",\n \"cells\",\n \"bodyValues\",\n \"rowValues\",\n \"_config\",\n \"config\",\n \"previewText\",\n \"layout\",\n \"collection\",\n ...extraKeys,\n ]);\n\n const result: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!internalKeys.has(key) && value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\n/** Increment and return counter for a given key. */\nfunction nextCounter(counters: Record<string, number>, key: string): number {\n counters[key] = (counters[key] || 0) + 1;\n return counters[key];\n}\n\n// ============================================\n// Types\n// ============================================\n\nexport interface ExtractHeadResult {\n /** Combined CSS from all head functions */\n css: string;\n /** Combined JS from all head functions */\n js: string;\n /** Unique HTML tags (meta, link, etc.) from all head functions */\n tags: string[];\n}\n\nexport interface ExtractHeadOptions {\n /** Display mode for rendering */\n displayMode: RenderMode;\n /** Optional head config for feature flags and initial values */\n headConfig?: HeadConfig;\n}\n\n/**\n * Call a head's css/js/tags functions and collect the results.\n */\nfunction callHead(\n head: ComponentHead | undefined,\n values: Record<string, any>,\n bodyValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n if (!head) return;\n\n const headArgs: [Record<string, any>, Record<string, any>, Record<string, any>] = [\n values,\n bodyValues,\n {\n displayMode,\n isViewer: false,\n variant: null,\n type: \"rows\",\n headConfig,\n },\n ];\n\n const css = head.css?.(...headArgs);\n if (css) styles.push(css);\n\n const js = head.js?.(...headArgs);\n if (js) scripts.push(js);\n\n const headTags = head.tags?.(...headArgs);\n if (headTags) tags.push(...headTags);\n}\n\n// ============================================\n// Tree walkers\n// ============================================\n\nfunction walkItem(\n element: React.ReactElement,\n bodyValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n counters: Record<string, number>,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n const componentType = element.type as any;\n const config = componentType[UNLAYER_CONFIG_KEY];\n if (!config) return;\n\n const { name, defaultValues, propMapper } = config;\n\n // Map and merge values (same as render-to-json and create-component)\n const { children, ...restProps } = element.props;\n const mappedValues = propMapper({ children, ...restProps });\n const finalValues = mergeValues(defaultValues, mappedValues);\n\n // Track component index (same counter pattern as render-to-json.ts)\n const contentType = name.toLowerCase();\n const count = nextCounter(counters, `u_content_${contentType}`);\n const valuesWithMeta = ensureMeta(finalValues, contentType, count - 1);\n\n // Look up head by component name\n const head = (heads as Record<string, ComponentHead | undefined>)[name];\n callHead(head, valuesWithMeta, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n}\n\nfunction walkColumn(\n element: React.ReactElement,\n bodyValues: Record<string, any>,\n rowValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n counters: Record<string, number>,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n // Column head\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, COLUMN_DEFAULTS, \"Column\");\n const count = nextCounter(counters, \"u_column\");\n const columnValues = ensureMeta(mergeValues(COLUMN_DEFAULTS, mapped), \"column\", count - 1);\n\n const columnHead = (heads as Record<string, ComponentHead | undefined>)[\"Column\"];\n callHead(columnHead, columnValues, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n // Walk item children\n const children = collectChildren(element.props.children);\n for (const child of children) {\n walkItem(child, bodyValues, displayMode, headConfig, counters, styles, scripts, tags);\n }\n}\n\nfunction walkRow(\n element: React.ReactElement,\n bodyValues: Record<string, any>,\n displayMode: RenderMode,\n headConfig: HeadConfig,\n counters: Record<string, number>,\n styles: string[],\n scripts: string[],\n tags: string[]\n): void {\n // Row head\n const semanticProps = extractSemanticProps(element.props, [\"layout\"]);\n const mapped = mapSemanticProps(semanticProps, ROW_DEFAULTS, \"Row\");\n const count = nextCounter(counters, \"u_row\");\n const rowValues = ensureMeta(mergeValues(ROW_DEFAULTS, mapped), \"row\", count - 1);\n\n const rowHead = (heads as Record<string, ComponentHead | undefined>)[\"Row\"];\n callHead(rowHead, rowValues, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n // Walk column children\n const children = collectChildren(element.props.children);\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Column\") {\n walkColumn(child, bodyValues, rowValues, displayMode, headConfig, counters, styles, scripts, tags);\n }\n }\n}\n\n// ============================================\n// Public API\n// ============================================\n\n/**\n * Extract head CSS/JS/tags from a React element tree.\n *\n * Walks the tree statically (same approach as renderToJson) and calls\n * each component's head function from @unlayer/exporters.\n *\n * @param element - Root element (Body, Email, Page, or Document)\n * @param options - Display mode and optional head config\n * @returns Combined CSS, JS, and tags from all head functions\n */\nexport function extractHeadFromTree(\n element: React.ReactElement,\n options: ExtractHeadOptions\n): ExtractHeadResult {\n const { displayMode } = options;\n const headConfig: HeadConfig = {\n hasFeature: options.headConfig?.hasFeature ?? (() => false),\n getInitialValues: options.headConfig?.getInitialValues ?? (() => ({})),\n };\n\n const styles: string[] = [];\n const scripts: string[] = [];\n const tags: string[] = [];\n const counters: Record<string, number> = {};\n\n // Extract body values\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, BODY_DEFAULTS, \"Body\");\n const bodyValues = ensureMeta(mergeValues(BODY_DEFAULTS, mapped), \"body\", 0);\n\n // Body head\n const bodyHead = (heads as Record<string, ComponentHead | undefined>)[\"Body\"];\n callHead(bodyHead, bodyValues, bodyValues, displayMode, headConfig, styles, scripts, tags);\n\n // Walk rows\n const children = collectChildren(element.props.children);\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Row\") {\n walkRow(child, bodyValues, displayMode, headConfig, counters, styles, scripts, tags);\n }\n }\n\n // Deduplicate tags\n const uniqueTags = [...new Set(tags.filter(Boolean))];\n\n return {\n css: styles.filter(Boolean).join(\"\\n\"),\n js: scripts.filter(Boolean).join(\"\\n\"),\n tags: uniqueTags,\n };\n}\n","import React from \"react\";\nimport { renderToStaticMarkup } from \"react-dom/server\";\nimport type { UnlayerConfig } from \"@unlayer-internal/shared-elements\";\nimport { DEFAULT_CONFIG } from \"@unlayer-internal/shared-elements\";\nimport { htmlToPlainText } from \"@unlayer-internal/shared-elements\";\nimport type { RenderMode } from \"@unlayer-internal/shared-elements\";\nimport { extractHeadFromTree } from \"./extract-head\";\n\n/**\n * Renders an Unlayer element tree to an HTML string.\n *\n * - Passes merged config via the `config` prop (no React context — works in Server Components)\n * - Uses `renderToStaticMarkup` — no React hydration markers, clean HTML for email/PDF\n * - Synchronous\n *\n * @param element - A React element tree (e.g. `<Body><Row>...</Row></Body>`)\n * @param config - Optional config overrides (mode, cdnBaseUrl, etc.)\n * @returns Clean HTML string\n * @throws {Error} If rendering fails, with a helpful message\n *\n * @example\n * ```tsx\n * import { renderToHtml, Body, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const html = renderToHtml(\n * <Body><Row><Column><Paragraph>Hello</Paragraph></Column></Row></Body>,\n * { mode: \"email\", cdnBaseUrl: \"https://my-cdn.com\" }\n * );\n * ```\n */\nexport function renderToHtml(\n element: React.ReactElement,\n config?: Partial<UnlayerConfig>\n): string {\n const mergedConfig = { ...DEFAULT_CONFIG, ...config };\n\n try {\n // Pass config via prop (not context) so this works in React Server Components.\n // Body reads `config` prop and threads it as `_config` to children via cloneElement.\n const enriched = React.cloneElement(element, { config: mergedConfig });\n return renderToStaticMarkup(enriched);\n } catch (error) {\n const message =\n error instanceof Error ? error.message : String(error);\n throw new Error(\n `[Unlayer] renderToHtml failed: ${message}\\n` +\n `Tip: Ensure your tree uses Body > Row > Column > Item structure.`\n );\n }\n}\n\n/**\n * Renders an Unlayer element tree to a plain text string.\n *\n * Internally calls `renderToHtml` then converts to plain text using\n * `htmlToPlainText`. Useful for generating the text/plain MIME part\n * of multipart emails (critical for deliverability).\n *\n * @param element - A React element tree (e.g. `<Body><Row>...</Row></Body>`)\n * @param config - Optional config overrides (mode, cdnBaseUrl, etc.)\n * @returns Plain text representation of the email\n *\n * @example\n * ```tsx\n * import { renderToPlainText, Body, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const text = renderToPlainText(\n * <Body mode=\"email\"><Row><Column><Paragraph>Hello World</Paragraph></Column></Row></Body>\n * );\n * // \"Hello World\"\n * ```\n */\nexport function renderToPlainText(\n element: React.ReactElement,\n config?: Partial<UnlayerConfig>\n): string {\n const html = renderToHtml(element, config);\n return htmlToPlainText(html);\n}\n\n/**\n * Result of renderToHtmlParts — head and body as separate strings.\n */\nexport interface HtmlParts {\n /** `<head>` content: `<style>` blocks with component CSS, optional `<script>` tags */\n head: string;\n /** `<body>` content: the rendered HTML (same output as `renderToHtml`) */\n body: string;\n}\n\n/**\n * Renders an Unlayer element tree to separate head and body HTML strings.\n *\n * This is the recommended API for sending emails, because email clients need\n * the `<style>` block in `<head>` for hover effects, responsive breakpoints,\n * and font declarations that cannot be expressed as inline styles.\n *\n * - `head` contains `<style>` tags with CSS generated by each component's\n * head function (button hover colors, body fonts, link styles, etc.)\n * - `body` is identical to what `renderToHtml()` returns\n *\n * @param element - A React element tree (e.g. `<Email><Row>...</Row></Email>`)\n * @param config - Optional config overrides (mode, cdnBaseUrl, etc.)\n * @returns `{ head, body }` — drop these into your HTML document template\n *\n * @example\n * ```tsx\n * import { renderToHtmlParts, Email, Row, Column, Button } from \"@unlayer/react-elements\";\n *\n * const { head, body } = renderToHtmlParts(\n * <Email>\n * <Row><Column><Button>Click</Button></Column></Row>\n * </Email>\n * );\n *\n * const html = `<!DOCTYPE html>\n * <html><head>${head}</head>${body}</html>`;\n * ```\n */\nexport function renderToHtmlParts(\n element: React.ReactElement,\n config?: Partial<UnlayerConfig>\n): HtmlParts {\n // Render body HTML (same as renderToHtml)\n const body = renderToHtml(element, config);\n\n // Resolve display mode from config or element props\n const mergedConfig = { ...DEFAULT_CONFIG, ...config };\n const displayMode: RenderMode =\n (element.props as any).mode ?? mergedConfig.mode ?? \"web\";\n\n // Extract head CSS/JS/tags by walking the element tree\n const { css, js, tags } = extractHeadFromTree(element, {\n displayMode,\n headConfig: mergedConfig.headConfig,\n });\n\n // Build head string\n const headParts: string[] = [];\n\n if (css) {\n headParts.push(`<style>${css}</style>`);\n }\n\n if (js) {\n headParts.push(`<script>${js}</script>`);\n }\n\n if (tags.length > 0) {\n headParts.push(...tags);\n }\n\n return {\n head: headParts.join(\"\\n\"),\n body,\n };\n}\n","/**\n * renderToJson — Convert a React element tree to Unlayer's DesignJSON format.\n *\n * Walks the React element tree statically via React.Children and extracts\n * values at each level. No HTML rendering is performed.\n *\n * Produces the { body: { rows, values }, counters, schemaVersion } structure\n * that the Unlayer editor uses, enabling round-tripping: build with React\n * components → export as JSON → load into the Unlayer editor.\n */\n\nimport React from \"react\";\nimport type {\n DesignJSON,\n DesignBody,\n DesignRow,\n DesignColumn,\n DesignContent,\n} from \"@unlayer-internal/shared-elements\";\nimport { mergeValues } from \"@unlayer-internal/shared-elements\";\n// Schema version from the exporters bundle — matches the editor's currentVersion\n// at the time the exporters were generated. This ensures renderToJson output is\n// recognized as current by the editor, skipping unnecessary migrations.\n// Falls back to 24 for older exporters packages that don't export this yet.\nimport { schemaVersion as _schemaVersion } from \"@unlayer/exporters\";\nconst schemaVersion: number = _schemaVersion ?? 24;\nimport { mapSemanticProps } from \"./semantic-props\";\nimport { UNLAYER_CONFIG_KEY } from \"./create-component\";\nimport { BODY_DEFAULTS, ROW_DEFAULTS, COLUMN_DEFAULTS } from \"./container-defaults\";\nimport { contentSlotWidth, pinImageSrc, type SlotContext } from \"./image-sizing\";\n\n/** Layout context threaded down the walk so an image can be sized against the\n * real column slot (contentWidth × column share, minus paddings/borders). */\ntype LayoutContext = Pick<\n SlotContext,\n \"bodyValues\" | \"rowValues\" | \"rowCells\" | \"columnIndex\" | \"columnValues\"\n>;\n\n// ============================================\n// Tree helpers (inlined)\n// ============================================\n\n/** Get the displayName of a React element's component type. */\nfunction getDisplayName(element: React.ReactElement): string | undefined {\n const type = element.type as any;\n return type?.displayName || type?.name;\n}\n\n/** The root components renderToJson understands. */\nconst VALID_ROOTS = new Set([\"Body\", \"Email\", \"Page\", \"Document\"]);\n\n/**\n * Unwrap a user wrapper component down to the underlying root element.\n * `renderToHtml` renders wrappers through React; `renderToJson` walks the element\n * tree, so a custom component that *returns* <Email>/<Body>/<Page>/<Document>\n * (e.g. `renderToJson(<MyEmail/>)`) must be invoked first. Only plain function\n * components are unwrapped — anything else (class / forwardRef / memo) falls\n * through to the clear root-type error.\n */\nfunction unwrapRoot(element: React.ReactElement): React.ReactElement {\n let current = element;\n for (let depth = 0; depth < 10; depth++) {\n const name = getDisplayName(current);\n if (name && VALID_ROOTS.has(name)) break;\n const type = current.type as any;\n const isPlainFunctionComponent =\n typeof type === \"function\" && !type.prototype?.isReactComponent;\n if (!isPlainFunctionComponent) break;\n // Invoking the wrapper can throw (e.g. it uses React hooks, which aren't\n // valid when called outside React's render). Turn that into an actionable\n // message instead of a bare \"Invalid hook call\".\n let produced: unknown;\n try {\n produced = type({ ...(current.props as Record<string, unknown>) });\n } catch (cause) {\n const detail = cause instanceof Error ? cause.message : String(cause);\n throw new Error(\n `[Unlayer] renderToJson: could not unwrap <${name || \"wrapper\"}>. A wrapper must ` +\n `be a plain component that synchronously returns a root (<Email>, <Page>, ` +\n `<Document>, or <Body>) and uses no React hooks. Pass the root element directly — ` +\n `e.g. renderToJson(<Email>…</Email>). (${detail})`\n );\n }\n if (!React.isValidElement(produced)) break;\n current = produced;\n }\n return current;\n}\n\n/** Collect valid React element children from a node. */\nfunction collectChildren(node: React.ReactNode): React.ReactElement[] {\n const result: React.ReactElement[] = [];\n React.Children.forEach(node, (child) => {\n if (React.isValidElement(child)) {\n result.push(child);\n }\n });\n return result;\n}\n\n/**\n * Strip internal/base props from an element's props,\n * returning only the semantic props that should be mapped to values.\n */\nfunction extractSemanticProps(\n props: Record<string, any>,\n extraKeys: string[] = []\n): Record<string, any> {\n const internalKeys = new Set([\n \"children\",\n \"mode\",\n \"className\",\n \"style\",\n \"index\",\n \"colIndex\",\n \"cells\",\n \"bodyValues\",\n \"rowValues\",\n \"_config\",\n \"config\",\n \"previewText\",\n \"layout\",\n \"collection\",\n ...extraKeys,\n ]);\n\n const result: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (!internalKeys.has(key) && value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\n/** Increment and return counter for a given key. */\nfunction nextCounter(counters: Record<string, number>, key: string): number {\n counters[key] = (counters[key] || 0) + 1;\n return counters[key];\n}\n\n// ============================================\n// Helpers\n// ============================================\n\n/** Map component displayName to Unlayer content type.\n * Paragraph maps to \"text\" (the legacy content type that uses plain HTML\n * values.text) for universal editor compatibility. The newer \"paragraph\"\n * content type uses Lexical textJson which requires specific editor support.\n */\nfunction toContentType(displayName: string): string {\n if (displayName === \"Paragraph\") return \"text\";\n return displayName.toLowerCase();\n}\n\n/** Generate a unique ID like \"u_row_1\", \"u_content_button_2\" */\nfunction makeId(prefix: string, counter: number): string {\n return `${prefix}_${counter}`;\n}\n\n/**\n * Extract plain text/HTML from a textJson string without needing a DOM.\n * Handles both Lexical JSON format and the __html passthrough format.\n */\nfunction extractTextFromTextJson(textJson: string): string {\n try {\n const parsed = JSON.parse(textJson);\n\n // __html passthrough (from htmlToTextJson)\n if (parsed.__html) return parsed.__html;\n\n // Lexical JSON — walk the tree and extract text content\n const root = parsed?.root;\n if (!root?.children) return \"\";\n\n const paragraphs: string[] = [];\n for (const paragraph of root.children) {\n if (!paragraph?.children) continue;\n const parts: string[] = [];\n for (const node of paragraph.children) {\n if (node?.text) parts.push(node.text);\n }\n paragraphs.push(parts.join(\"\"));\n }\n return paragraphs.join(\"\\n\");\n } catch {\n return \"\";\n }\n}\n\n// ============================================\n// Tree processors\n// ============================================\n\nfunction processItem(\n element: React.ReactElement,\n counters: Record<string, number>,\n layout: LayoutContext = {}\n): DesignContent {\n const componentType = element.type as any;\n const config = componentType[UNLAYER_CONFIG_KEY];\n\n if (!config) {\n const name = getDisplayName(element) || \"Unknown\";\n throw new Error(\n `[Unlayer] renderToJson: <${name}> is not a recognized Unlayer item component. ` +\n `Only components created with createItemComponent are supported.`\n );\n }\n\n const { name, defaultValues, propMapper } = config;\n const contentType = toContentType(name);\n const count = nextCounter(counters, `u_content_${contentType}`);\n const id = makeId(`u_content_${contentType}`, count);\n\n // Map props through the item's own propMapper, then merge with defaults\n const { children, ...restProps } = element.props;\n const mappedValues = propMapper({ children, ...restProps });\n const finalValues = mergeValues(defaultValues, mappedValues);\n\n // Paragraph maps to \"text\" content type — convert textJson to plain text/HTML.\n // Extract text directly from the Lexical JSON structure (no DOM needed).\n if (contentType === \"text\" && finalValues.textJson) {\n finalValues.text = extractTextFromTextJson(finalValues.textJson);\n delete finalValues.textJson;\n }\n\n // Add containerPadding (base content option) and _meta\n const values = {\n containerPadding: \"10px\",\n ...finalValues,\n _meta: {\n htmlID: id,\n htmlClassNames: `u_content_${contentType}`,\n ...(finalValues._meta || {}),\n },\n selectable: true,\n draggable: true,\n duplicatable: true,\n deletable: true,\n hideable: true,\n };\n\n // Convert a fixed (px) image pin to a percent of the column slot using the\n // threaded geometry, so the display width survives the JSON round-trip into an\n // editor. Guarded on `src.autoWidth === false`, so only pinned images change.\n const itemSrc = (values as Record<string, any>).src;\n if (itemSrc && typeof itemSrc === \"object\" && itemSrc.autoWidth === false) {\n const availableWidth = contentSlotWidth({\n ...layout,\n containerPadding: (values as Record<string, any>).containerPadding,\n });\n (values as Record<string, any>).src = pinImageSrc(itemSrc, availableWidth);\n }\n\n return { type: contentType, values };\n}\n\nfunction processColumn(\n element: React.ReactElement,\n counters: Record<string, number>,\n layout: Omit<LayoutContext, \"columnValues\"> = {}\n): DesignColumn {\n const count = nextCounter(counters, \"u_column\");\n const id = makeId(\"u_column\", count);\n\n // Extract semantic props for column values, then merge with defaults\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, COLUMN_DEFAULTS, \"Column\");\n const values = mergeValues(COLUMN_DEFAULTS, mapped);\n\n // Add _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: id,\n htmlClassNames: \"u_column\",\n ...(values._meta || {}),\n },\n };\n\n // Process item children\n const contents: DesignContent[] = [];\n const children = collectChildren(element.props.children);\n\n const itemLayout: LayoutContext = { ...layout, columnValues: valuesWithMeta };\n for (const child of children) {\n contents.push(processItem(child, counters, itemLayout));\n }\n\n return { contents, values: valuesWithMeta };\n}\n\nfunction processRow(\n element: React.ReactElement,\n counters: Record<string, number>,\n parentLayout: Pick<LayoutContext, \"bodyValues\"> = {}\n): DesignRow {\n const count = nextCounter(counters, \"u_row\");\n const id = makeId(\"u_row\", count);\n\n // Determine cells from layout or cells prop\n const { layout, cells: propsCells } = element.props;\n let cells: number[];\n if (layout) {\n cells = layout.cells;\n } else if (propsCells) {\n cells = propsCells;\n } else {\n // Default: one equal cell per Column child. Count only <Column> children —\n // any stray non-Column child is warned and skipped below, so including it\n // would make `cells` longer than the column list and distort both the row\n // layout and the column-share math used for image sizing.\n const columnCount = Math.max(\n 1,\n collectChildren(element.props.children).filter(\n (child) => getDisplayName(child) === \"Column\"\n ).length\n );\n cells = Array(columnCount).fill(1);\n }\n\n // Extract semantic props for row values, then merge with defaults\n const semanticProps = extractSemanticProps(element.props, [\"layout\"]);\n const mapped = mapSemanticProps(semanticProps, ROW_DEFAULTS, \"Row\");\n const values = mergeValues(ROW_DEFAULTS, mapped);\n\n // Add cells, columns flag, editor flags, and _meta\n const valuesWithMeta = {\n ...values,\n columns: values.columns ?? false,\n cells,\n _meta: {\n htmlID: id,\n htmlClassNames: \"u_row\",\n ...(values._meta || {}),\n },\n selectable: true,\n draggable: true,\n duplicatable: true,\n deletable: true,\n hideable: true,\n };\n\n // Process Column children\n const columns: DesignColumn[] = [];\n const children = collectChildren(element.props.children);\n\n const columnLayout: Omit<LayoutContext, \"columnValues\"> = {\n bodyValues: parentLayout.bodyValues,\n rowValues: valuesWithMeta,\n rowCells: cells,\n };\n let columnIndex = 0;\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Column\") {\n columns.push(\n processColumn(child, counters, { ...columnLayout, columnIndex })\n );\n columnIndex += 1;\n } else {\n console.warn(\n `[Unlayer] renderToJson: <${name}> is not a valid Row child. Only <Column> is allowed.`\n );\n }\n }\n\n return { cells, columns, values: valuesWithMeta };\n}\n\nfunction processBody(\n element: React.ReactElement,\n counters: Record<string, number>\n): DesignBody {\n const id = \"u_body\";\n\n // Extract semantic props for body values, then merge with defaults\n const semanticProps = extractSemanticProps(element.props);\n const mapped = mapSemanticProps(semanticProps, BODY_DEFAULTS, \"Body\");\n const values = mergeValues(BODY_DEFAULTS, mapped);\n\n // `previewText` is the React alias for the schema's `preheaderText`. It is\n // excluded from the mapped values (it drives the email preview HTML at render\n // time), so thread it into the JSON here so it is preserved in the output.\n const previewText = (element.props as { previewText?: string }).previewText;\n if (previewText !== undefined) {\n (values as Record<string, unknown>).preheaderText = previewText;\n }\n\n // Add _meta\n const valuesWithMeta = {\n ...values,\n _meta: {\n htmlID: id,\n htmlClassNames: \"u_body\",\n ...(values._meta || {}),\n },\n };\n\n // Process Row children\n const rows: DesignRow[] = [];\n const children = collectChildren(element.props.children);\n\n for (const child of children) {\n const name = getDisplayName(child);\n if (name === \"Row\") {\n rows.push(processRow(child, counters, { bodyValues: valuesWithMeta }));\n } else {\n console.warn(\n `[Unlayer] renderToJson: <${name}> is not a valid Body child. Only <Row> is allowed.`\n );\n }\n }\n\n return {\n rows,\n values: valuesWithMeta,\n } as DesignBody;\n}\n\n// ============================================\n// Public API\n// ============================================\n\n/**\n * Convert a React element tree to Unlayer's DesignJSON format.\n *\n * The root element must be a `<Body>`, `<Email>`, `<Page>`, or `<Document>`.\n * The tree is walked statically — no HTML rendering is performed.\n *\n * @param element - A React element tree with Body > Row > Column > Item structure\n * @returns DesignJSON object compatible with the Unlayer editor\n * @throws {Error} If the root element is not a recognized container component\n *\n * @example\n * ```tsx\n * import { renderToJson, Body, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const design = renderToJson(\n * <Body backgroundColor=\"#ffffff\" contentWidth=\"600px\">\n * <Row>\n * <Column>\n * <Paragraph>Hello World</Paragraph>\n * </Column>\n * </Row>\n * </Body>\n * );\n * ```\n */\n/**\n * Convert a single `<Row>` element to Unlayer's row JSON format.\n *\n * Use this when targeting a Block Editor, which works with individual rows\n * rather than full design JSON. For full designs, use `renderToJson` instead.\n *\n * @param element - A React element tree with Row > Column > Item structure\n * @returns A DesignRow object compatible with the Unlayer block editor\n * @throws {Error} If the element is not a `<Row>`\n *\n * @example\n * ```tsx\n * import { renderRowToJson, Row, Column, Paragraph } from \"@unlayer/react-elements\";\n *\n * const row = renderRowToJson(\n * <Row>\n * <Column>\n * <Paragraph>Hello World</Paragraph>\n * </Column>\n * </Row>\n * );\n * ```\n */\nexport function renderRowToJson(element: React.ReactElement): DesignRow {\n const displayName = getDisplayName(element);\n\n if (displayName !== \"Row\") {\n throw new Error(\n `[Unlayer] renderRowToJson: Element must be <Row>, ` +\n `but got <${displayName || \"unknown\"}>. ` +\n `For full designs, use renderToJson instead.`\n );\n }\n\n const counters: Record<string, number> = {};\n return processRow(element, counters);\n}\n\nexport function renderToJson(element: React.ReactElement): DesignJSON {\n // Accept a user wrapper component (e.g. <MyEmail/>) by unwrapping to its root,\n // matching renderToHtml which renders wrappers through React.\n element = unwrapRoot(element);\n const displayName = getDisplayName(element);\n\n if (!displayName || !VALID_ROOTS.has(displayName)) {\n throw new Error(\n `[Unlayer] renderToJson: Root element must be <Body>, <Email>, <Page>, or <Document>, ` +\n `but got <${displayName || \"unknown\"}>. ` +\n `Wrap your content: <Body><Row><Column>...</Column></Row></Body>`\n );\n }\n\n // Email/Page/Document are thin wrappers around Body — for JSON purposes,\n // we treat them identically: extract props directly from the wrapper element.\n // The wrapper's own render function would re-render as Body, but we don't\n // call render — we just walk the element tree.\n\n // For Email/Page/Document, the children and semantic props are on the\n // wrapper element directly, same as Body.\n const counters: Record<string, number> = {};\n const body = processBody(element, counters);\n\n return {\n counters,\n body,\n schemaVersion,\n };\n}\n"]}
|