@charisol/plexo-sdk 1.0.26 → 1.0.28

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/compiler.js CHANGED
@@ -1,461 +1,2 @@
1
- //#region src/utilities/compiler.ts
2
- var e = "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif";
3
- function t(e) {
4
- if (!e || typeof e != "object") return null;
5
- if (Array.isArray(e.columns) && e.columns.length > 0) return e;
6
- let t = (e.type || "").toLowerCase(), n = e.props || e.content || e.attributes || e.data || e.payload || e, r = e.style || {};
7
- switch (t) {
8
- case "hero": {
9
- let t = n.headline || n.title || n.text || "Build faster. Scale smarter.", i = n.subheadline || n.description || n.subtitle || "", a = n.primaryButton || n.button || n.cta || "Get Started", o = n.secondaryButton || "", s = [{
10
- type: "heading",
11
- style: {
12
- fontSize: "48px",
13
- fontWeight: "800",
14
- textAlign: "center",
15
- marginBottom: "16px"
16
- },
17
- attributes: { text: t }
18
- }];
19
- return i && s.push({
20
- type: "paragraph",
21
- style: {
22
- fontSize: "18px",
23
- color: "#94a3b8",
24
- textAlign: "center",
25
- maxWidth: "700px",
26
- margin: "0 auto 32px auto"
27
- },
28
- attributes: { text: i }
29
- }), a && s.push({
30
- type: "button",
31
- style: {
32
- textAlign: "center",
33
- backgroundColor: "#8b5cf6",
34
- color: "#ffffff",
35
- borderRadius: "12px",
36
- paddingTop: "14px",
37
- paddingBottom: "14px",
38
- paddingLeft: "28px",
39
- paddingRight: "28px",
40
- fontSize: "16px",
41
- fontWeight: "600"
42
- },
43
- attributes: {
44
- text: a,
45
- href: "#signup"
46
- }
47
- }), o && s.push({
48
- type: "button",
49
- style: {
50
- textAlign: "center",
51
- backgroundColor: "rgba(255,255,255,0.1)",
52
- color: "#ffffff",
53
- borderRadius: "12px",
54
- paddingTop: "14px",
55
- paddingBottom: "14px",
56
- paddingLeft: "28px",
57
- paddingRight: "28px",
58
- fontSize: "16px",
59
- fontWeight: "600",
60
- marginLeft: "12px"
61
- },
62
- attributes: {
63
- text: o,
64
- href: "#demo"
65
- }
66
- }), {
67
- id: e.id || `row-hero-${Math.random().toString(36).substring(2, 7)}`,
68
- style: {
69
- paddingTop: "80px",
70
- paddingBottom: "80px",
71
- textAlign: "center",
72
- ...r
73
- },
74
- columns: [{
75
- id: `col-hero-${Math.random().toString(36).substring(2, 7)}`,
76
- width: "100%",
77
- elements: s
78
- }]
79
- };
80
- }
81
- case "features": {
82
- let t = n.title || n.headline || "Features", i = Array.isArray(n.items) ? n.items : Array.isArray(n.features) ? n.features : [], a = [{
83
- type: "heading",
84
- style: {
85
- fontSize: "32px",
86
- fontWeight: "700",
87
- textAlign: "center",
88
- marginBottom: "40px"
89
- },
90
- attributes: { text: t }
91
- }], o = [];
92
- if (i.length > 0) {
93
- let e = i.length === 2 ? "50%" : i.length >= 3 ? "33.33%" : "100%";
94
- i.forEach((t, n) => {
95
- let r = typeof t == "string" ? t : t.title || t.name || `Feature ${n + 1}`, i = typeof t == "string" ? "" : t.description || t.text || "";
96
- o.push({
97
- id: `col-feat-${n}`,
98
- width: e,
99
- elements: [{
100
- type: "card",
101
- style: {
102
- backgroundColor: "#111827",
103
- borderRadius: "16px",
104
- padding: "24px",
105
- borderWidth: "1px",
106
- borderColor: "rgba(255,255,255,0.08)"
107
- },
108
- attributes: {
109
- title: r,
110
- description: i || "Powerful functionality built for performance and scale."
111
- }
112
- }]
113
- });
114
- });
115
- }
116
- return {
117
- id: e.id || `row-features-${Math.random().toString(36).substring(2, 7)}`,
118
- style: {
119
- paddingTop: "60px",
120
- paddingBottom: "60px",
121
- ...r
122
- },
123
- columns: o.length > 0 ? o : [{
124
- id: "col-feat-fallback",
125
- width: "100%",
126
- elements: a
127
- }]
128
- };
129
- }
130
- case "footer": {
131
- let t = n.text || n.copyright || n.headline || n.title || "";
132
- return (Array.isArray(n.links) ? n.links : []).length > 0 || !t ? null : {
133
- id: e.id || `row-footer-${Math.random().toString(36).substring(2, 7)}`,
134
- style: {
135
- paddingTop: "32px",
136
- paddingBottom: "32px",
137
- textAlign: "center",
138
- ...r
139
- },
140
- columns: [{
141
- id: `col-footer-${Math.random().toString(36).substring(2, 7)}`,
142
- width: "100%",
143
- elements: [{
144
- type: "paragraph",
145
- style: {
146
- fontSize: "14px",
147
- color: "#94a3b8",
148
- textAlign: "center"
149
- },
150
- attributes: { text: t }
151
- }]
152
- }]
153
- };
154
- }
155
- case "cta": {
156
- let t = n.headline || n.title || "Ready to transform your workflow?", i = n.button || n.primaryButton || n.cta || "Get Started";
157
- return {
158
- id: e.id || `row-cta-${Math.random().toString(36).substring(2, 7)}`,
159
- style: {
160
- backgroundColor: "rgba(139, 92, 246, 0.12)",
161
- borderRadius: "24px",
162
- padding: "48px",
163
- textAlign: "center",
164
- marginTop: "40px",
165
- marginBottom: "60px",
166
- borderWidth: "1px",
167
- borderColor: "rgba(139, 92, 246, 0.3)",
168
- ...r
169
- },
170
- columns: [{
171
- id: `col-cta-${Math.random().toString(36).substring(2, 7)}`,
172
- width: "100%",
173
- elements: [{
174
- type: "heading",
175
- style: {
176
- fontSize: "32px",
177
- color: "#ffffff",
178
- fontWeight: "700",
179
- textAlign: "center",
180
- marginBottom: "20px"
181
- },
182
- attributes: { text: t }
183
- }, {
184
- type: "button",
185
- style: {
186
- textAlign: "center",
187
- backgroundColor: "#8b5cf6",
188
- color: "#ffffff",
189
- borderRadius: "12px",
190
- paddingTop: "14px",
191
- paddingBottom: "14px",
192
- paddingLeft: "28px",
193
- paddingRight: "28px",
194
- fontWeight: "700"
195
- },
196
- attributes: {
197
- text: i,
198
- href: "#signup"
199
- }
200
- }]
201
- }]
202
- };
203
- }
204
- default: {
205
- if (Object.values(n).some((e) => Array.isArray(e) && e.length > 0)) return null;
206
- let t = n.headline || n.title || n.text || "", i = n.subheadline || n.description || n.subtitle || "", a = n.button || n.primaryButton || n.cta || "", o = [];
207
- return t && o.push({
208
- type: "heading",
209
- style: {
210
- fontSize: "32px",
211
- fontWeight: "700",
212
- marginBottom: "16px"
213
- },
214
- attributes: { text: t }
215
- }), i && o.push({
216
- type: "paragraph",
217
- style: {
218
- fontSize: "16px",
219
- color: "#94a3b8",
220
- marginBottom: "24px"
221
- },
222
- attributes: { text: i }
223
- }), a && o.push({
224
- type: "button",
225
- style: {
226
- backgroundColor: "#8b5cf6",
227
- color: "#ffffff",
228
- borderRadius: "12px",
229
- paddingTop: "12px",
230
- paddingBottom: "12px",
231
- paddingLeft: "24px",
232
- paddingRight: "24px"
233
- },
234
- attributes: {
235
- text: a,
236
- href: "#action"
237
- }
238
- }), {
239
- id: e.id || `row-generic-${Math.random().toString(36).substring(2, 7)}`,
240
- style: {
241
- paddingTop: "40px",
242
- paddingBottom: "40px",
243
- ...r
244
- },
245
- columns: [{
246
- id: `col-generic-${Math.random().toString(36).substring(2, 7)}`,
247
- width: "100%",
248
- elements: o.length > 0 ? o : [{
249
- type: "heading",
250
- attributes: { text: "Section" }
251
- }]
252
- }]
253
- };
254
- }
255
- }
256
- }
257
- var n = (e = {}) => !e || typeof e != "object" ? "" : Object.entries(e).filter(([e, t]) => t != null && t !== "").map(([e, t]) => {
258
- let n = e.replace(/([A-Z])/g, "-$1").toLowerCase(), r = t;
259
- return typeof t == "number" && [
260
- "padding",
261
- "margin",
262
- "fontSize",
263
- "borderRadius",
264
- "borderWidth",
265
- "width",
266
- "height"
267
- ].some((t) => e.toLowerCase().includes(t)) && (r = `${t}px`), `${n}: ${r};`;
268
- }).join(" "), r = () => ({
269
- backgroundColor: "#ffffff",
270
- borderRadius: "20px",
271
- width: "100%",
272
- padding: "24px",
273
- paddingTop: "24px",
274
- paddingRight: "24px",
275
- paddingBottom: "24px",
276
- paddingLeft: "24px",
277
- fieldSpacing: "12px",
278
- borderWidth: "1px",
279
- borderStyle: "solid",
280
- borderColor: "#dbe4f0",
281
- boxShadow: "0 18px 40px rgba(15, 23, 42, 0.08)",
282
- buttonBackgroundColor: "#0f172a",
283
- buttonTextColor: "#ffffff",
284
- buttonBorderRadius: "12px",
285
- buttonPaddingTop: "10px",
286
- buttonPaddingBottom: "10px",
287
- buttonPaddingLeft: "14px",
288
- buttonPaddingRight: "14px",
289
- buttonFontSize: "13px",
290
- buttonFontWeight: "700"
291
- }), i = (e) => (e || "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), a = (e, t) => {
292
- if (typeof t != "string") return "";
293
- let n = t.trim();
294
- return n ? ` ${e}="${i(n)}"` : "";
295
- }, o = [
296
- "fieldSpacing",
297
- "buttonBackgroundColor",
298
- "buttonTextColor",
299
- "buttonBorderRadius",
300
- "buttonPaddingTop",
301
- "buttonPaddingBottom",
302
- "buttonPaddingLeft",
303
- "buttonPaddingRight",
304
- "buttonFontSize",
305
- "buttonFontWeight"
306
- ], s = (e) => {
307
- if (!e || typeof e != "object") return "";
308
- let t = e.kind || "text", r = i(e.name || e.label || "field"), a = e.required ? " required" : "", o = n({
309
- fontSize: e.fontSize,
310
- borderRadius: e.borderRadius,
311
- borderWidth: e.borderWidth,
312
- borderColor: e.borderColor,
313
- borderStyle: "solid",
314
- color: e.inputTextColor
315
- }), s = e.showLabel === !1 ? "" : `<label style="display: block; margin-bottom: 4px; font-size: ${e.fontSize || "12px"}; font-weight: ${e.labelFontWeight || "700"}; color: ${e.labelColor || "inherit"};">${e.label || ""}${e.required ? " <span style=\"color:#e11d48;\">*</span>" : ""}</label>`;
316
- return t === "textarea" ? `${s}<textarea name="${r}" placeholder="${i(e.placeholder || "")}" style="width: 100%; box-sizing: border-box; padding: 10px 12px; ${o}"${a}></textarea>` : t === "select" ? `${s}<select name="${r}" style="width: 100%; box-sizing: border-box; padding: 10px 12px; ${o}"${a}>${(Array.isArray(e.options) ? e.options : []).map((e) => `<option value="${i(e?.value ?? "")}">${e?.label ?? e?.value ?? ""}</option>`).join("")}</select>` : t === "radio" || t === "checkbox" ? `${s}<div style="display: flex; flex-wrap: wrap; gap: 8px;">${(Array.isArray(e.options) && e.options.length > 0 ? e.options : [{
317
- label: e.label || "Option",
318
- value: e.name || "option"
319
- }]).map((n) => `<label style="display: inline-flex; align-items: center; gap: 6px; font-size: ${e.fontSize || "12px"};"><input type="${t}" name="${r}" value="${i(n?.value ?? "")}" />${n?.label ?? n?.value ?? ""}</label>`).join("")}</div>` : `${s}<input type="${i(t)}" name="${r}" placeholder="${i(e.placeholder || "")}" style="width: 100%; box-sizing: border-box; padding: 10px 12px; ${o}"${a} />`;
320
- }, c = (e) => {
321
- if (!e || typeof e != "object") return "";
322
- let t = e.style || {}, a = n(e.type === "form_container" ? {
323
- ...r(),
324
- ...t
325
- } : t), c = e.attributes || {};
326
- switch (e.type) {
327
- case "heading": return `<h2 style="margin-top: 0; margin-bottom: 8px; ${a}">${c.text || "Heading"}</h2>`;
328
- case "paragraph": return `<p style="margin-top: 0; margin-bottom: 12px; ${a}">${c.text || "Paragraph text content."}</p>`;
329
- case "text": return `<div style="${a}">${c.text || ""}</div>`;
330
- case "button": return `<div style="text-align: ${t.textAlign || "center"};"><a href="${c.href || "#"}" target="${c.openInNewTab ? "_blank" : "_self"}" style="display: inline-block; text-decoration: none; ${a}">${c.text || "Button"}</a></div>`;
331
- case "image": {
332
- let e = t.textAlign === "center" ? "margin: 0 auto; display: block;" : t.textAlign === "right" ? "margin-left: auto; display: block;" : "display: inline-block;";
333
- return `<img src="${c.src || "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe"}" alt="${c.alt || ""}" style="${a} ${e}" />`;
334
- }
335
- case "divider": return `<hr style="border: 0; border-top: ${t.borderWidth || "1px"} ${t.borderStyle || "solid"} ${t.borderColor || "#334155"}; ${a}" />`;
336
- case "spacer": return `<div style="height: ${t.height || "24px"};"></div>`;
337
- case "card": return `<div style="${a}">
338
- <h3 style="margin-top: 0; margin-bottom: 8px; color: #ffffff;">${c.title || "Card Title"}</h3>
339
- <p style="margin: 0; color: #94a3b8; font-size: 14px;">${c.description || "Card description."}</p>
340
- </div>`;
341
- case "form_container": {
342
- let e = {
343
- ...r(),
344
- ...t
345
- }, a = {};
346
- for (let t of Object.keys(e)) o.includes(t) || (a[t] = e[t]);
347
- let l = n(a), u = Array.isArray(c.fields) ? c.fields : [], d = e.fieldSpacing || "12px", f = u.map((e) => `<div style="margin-bottom: ${d};">${s(e)}</div>`).join(""), p = n({
348
- backgroundColor: e.buttonBackgroundColor,
349
- color: e.buttonTextColor,
350
- borderRadius: e.buttonBorderRadius,
351
- paddingTop: e.buttonPaddingTop,
352
- paddingBottom: e.buttonPaddingBottom,
353
- paddingLeft: e.buttonPaddingLeft,
354
- paddingRight: e.buttonPaddingRight,
355
- fontSize: e.buttonFontSize,
356
- fontWeight: e.buttonFontWeight
357
- });
358
- return `<form action="${i(c.actionUrl || c.action || "#")}" method="${i(c.method || "POST")}" style="${l}">${f}<button type="submit" style="border: 0; cursor: pointer; ${p}">${c.submitLabel || "Submit"}</button></form>`;
359
- }
360
- case "input": {
361
- let e = c.inputType || c.type || "text", t = i(c.name || c.fieldName || "field"), n = i(c.placeholder || ""), r = c.required ? " required" : "";
362
- return `<input type="${i(e)}" name="${t}" placeholder="${n}" style="width: 100%; box-sizing: border-box; padding: 10px 12px; ${a}"${r} />`;
363
- }
364
- case "textarea": return `<textarea name="${i(c.name || c.fieldName || "field")}" placeholder="${i(c.placeholder || "")}" style="width: 100%; box-sizing: border-box; padding: 10px 12px; ${a}"${c.required ? " required" : ""}></textarea>`;
365
- case "select": return `<select name="${i(c.name || c.fieldName || "field")}" style="width: 100%; box-sizing: border-box; padding: 10px 12px; ${a}"${c.required ? " required" : ""}>${(Array.isArray(c.options) ? c.options : []).map((e) => `<option value="${i(e?.value ?? "")}">${e?.label ?? e?.value ?? ""}</option>`).join("")}</select>`;
366
- case "html": return `<div style="${a}">${c.htmlContent || c.text || ""}</div>`;
367
- default: return `<!-- Unsupported block ${e.type} -->`;
368
- }
369
- }, l = (e) => {
370
- if (!e || typeof e != "object") return "";
371
- let r = t(e);
372
- if (!r) return `\n <!-- ROW SKIPPED (type="${typeof e.type == "string" ? e.type : "unknown"}"${e.id ? `, id="${e.id}"` : ""}): this row has no 'columns' array and its shorthand content (e.g. a list of items/links) can't be auto-converted without losing data. Provide a fully hydrated row with 'columns' and 'elements' instead. -->`;
373
- let i = n(r.style || {}), o = a("id", r.htmlId), s = a("class", r.htmlClass), u = `\n <!-- ROW START: ${r.id || "row"} -->`;
374
- u += `\n <div${o}${s} class="plexo-row" style="display: flex; flex-wrap: wrap; margin-left: -8px; margin-right: -8px; ${i}">`;
375
- let d = Array.isArray(r.columns) ? r.columns : [];
376
- for (let e of d) {
377
- if (!e) continue;
378
- let t = n(e.styles || e.style || {}), r = a("id", e.attrs?.htmlId), i = e.attrs?.htmlClass ? ` ${e.attrs.htmlClass}` : "";
379
- u += `\n <!-- COLUMN START: ${e.id || "col"} -->`, u += `\n <div${r} class="plexo-col${i}" style="box-sizing: border-box; padding-left: 8px; padding-right: 8px; width: ${e.width || "100%"}; ${t}">`;
380
- let o = Array.isArray(e.elements) ? e.elements : [];
381
- for (let e of o) {
382
- if (!e) continue;
383
- let t = e.attributes || {}, n = typeof t.htmlClassNames == "string" ? t.htmlClassNames : typeof t.htmlClass == "string" ? t.htmlClass : typeof t.className == "string" ? t.className : "", r = a("id", t.htmlId), i = a("class", n), o = e.style?.display, s = o === "inline-block" || o === "inline" || o === "inline-flex" ? `margin-bottom: 16px; display: ${o}; vertical-align: top;` : "margin-bottom: 16px;";
384
- u += `\n <div${r}${i} style="${s}">`, u += `\n ${c(e)}`, u += "\n </div>";
385
- }
386
- let s = Array.isArray(e.nestedRows) ? e.nestedRows : [];
387
- for (let e of s) u += l(e);
388
- u += "\n </div>";
389
- }
390
- return u += "\n </div>", u;
391
- }, u = (t) => {
392
- if (!t || typeof t != "object") return "<!-- Empty template -->";
393
- let r = t.designJson || t.template || t, o = r.body || (Array.isArray(r.rows) ? {
394
- style: r.style || {},
395
- rows: r.rows
396
- } : {
397
- style: {},
398
- rows: []
399
- }), s = { ...o.style || {} };
400
- for (let e of [
401
- "backgroundColor",
402
- "background",
403
- "color",
404
- "textColor",
405
- "fontFamily",
406
- "htmlTitle"
407
- ]) s[e] === void 0 && (o[e] === void 0 ? r[e] !== void 0 && (s[e] = r[e]) : s[e] = o[e]);
408
- s.backgroundColor && !s.background ? s.background = s.backgroundColor : s.background && !s.backgroundColor && (s.backgroundColor = s.background), s.textColor && !s.color && (s.color = s.textColor);
409
- let c = [
410
- "htmlTitle",
411
- "htmlId",
412
- "htmlClass",
413
- "customCss",
414
- "customJs",
415
- "textColor"
416
- ], u = {};
417
- for (let e of Object.keys(s)) c.includes(e) || (u[e] = s[e]);
418
- let d = n(u), f = typeof s.htmlTitle == "string" && s.htmlTitle.trim() ? s.htmlTitle.trim() : typeof t?.name == "string" && t.name.trim() ? t.name.trim() : "Plexo Rendered Page", p = a("id", s.htmlId), m = a("class", s.htmlClass), h = typeof s.customCss == "string" && s.customCss.trim() ? s.customCss.trim() : "", g = typeof s.customJs == "string" && s.customJs.trim() ? s.customJs.trim() : "", _ = `<!DOCTYPE html>
419
- <html>
420
- <head>
421
- <meta charset="utf-8">
422
- <title>${i(f)}</title>
423
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
424
- <style>
425
- body { margin: 0; font-family: ${e}; }
426
- .plexo-row {
427
- display: flex;
428
- flex-wrap: wrap;
429
- }
430
- @media (max-width: 768px) {
431
- .plexo-row {
432
- flex-direction: column !important;
433
- }
434
- .plexo-col {
435
- width: 100% !important;
436
- max-width: 100% !important;
437
- margin-bottom: 16px;
438
- }
439
- }
440
- </style>
441
- ${h ? `<style>\n${h}\n </style>` : ""}
442
- </head>
443
- <body${p}${m} style="${d}">
444
- <div style="max-width: 1200px; margin: 0 auto; width: 100%;">`, v = Array.isArray(o.rows) ? o.rows : Array.isArray(r.rows) ? r.rows : Array.isArray(t.rows) ? t.rows : [];
445
- for (let e of v) _ += l(e);
446
- return _ += `\n </div>
447
- ${g ? ` <script>\n${g}\n <\/script>` : ""}
448
- </body>
449
- </html>`, _ = _.replace(/<span[^>]*data-merge-val="([^"]*)"[^>]*>[\s\S]*?<\/span>/gi, "$1"), _;
450
- };
451
- function d(e) {
452
- return u(e).replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
453
- }
454
- function f(e) {
455
- return u(e);
456
- }
457
- function p(e) {
458
- return e;
459
- }
460
- //#endregion
461
- export { e as DEFAULT_BODY_FONT_FAMILY, u as compileToHTML, f as compileToHTMLWithStrataAuto, d as compileToPlainText, t as convertSectionRowToPlexoRow, p as injectStrataBundle };
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./compiler-Bn4rYU81.js";
2
+ export { a as DEFAULT_BODY_FONT_FAMILY, n as compileToHTML, i as compileToHTMLWithStrataAuto, t as compileToPlainText, e as convertSectionRowToPlexoRow, r as injectStrataBundle };