@charisol/plexo-sdk 1.3.0 → 1.4.1

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.
@@ -1,215 +0,0 @@
1
- import { d as e, f as t, g as n, h as r, m as i, o as a, p as o, t as s, u as c, x as l, y as u } from "./iconSvgStatic-CGue7nyp.js";
2
- //#region src/utilities/instrumentation.ts
3
- var d = "plexo-node";
4
- function f(e) {
5
- return `plexo-node-${e}`;
6
- }
7
- //#endregion
8
- //#region src/utilities/compilerClient.ts
9
- var p = "https://cdn.jsdelivr.net/npm/@charisol/plexo-sdk@latest/dist/social-icons", m = /* @__PURE__ */ new Set([
10
- "selectable",
11
- "draggable",
12
- "duplicatable",
13
- "deletable",
14
- "hideable",
15
- "locked"
16
- ]), h = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), g = (e = {}) => Object.entries(e).filter(([, e]) => e != null && String(e).trim() !== "").map(([e, t]) => `${e.replace(/([A-Z])/g, "-$1").toLowerCase()}:${String(t)};`).join(""), _ = (...e) => e.map((e) => String(e ?? "").trim()).filter(Boolean).join(" "), v = (e, t, n) => n ? _(e, d, f(t)) : e, y = (e, t) => {
17
- let n = v("", e, t);
18
- return n ? ` css-class="${h(n)}"` : "";
19
- }, b = (e, t) => {
20
- let n = v("", e, t);
21
- return n ? ` class="${h(n)}"` : "";
22
- }, x = (e, t) => {
23
- let n = { ...e.attributes || {} };
24
- if (t === "email") for (let e of m) delete n[e];
25
- return n;
26
- }, S = (e, t, n) => {
27
- let r = x(e, t), i = g(e.style || {}), a = v(_(r.htmlClassNames, r.htmlClass, r.validationClass, r.validationClassName), e.id, t === "landing_page" && n), o = h(r.name || r.fieldName || "field"), s = h(r.placeholder || ""), c = r.required ? " required" : "";
28
- if (t === "email") return `<mj-table${y(e.id, n)}><tr><td style="padding:10px 12px;border:1px solid #d1d5db;border-radius:6px;color:#64748b;${i}">${s || o}</td></tr></mj-table>`;
29
- let l = h(r.inputType || r.type || (e.type === "input" ? r.kind || "text" : e.type)), u = r.htmlId ? ` id="${h(r.htmlId)}"` : "", d = a ? ` class="${h(a)}"` : "";
30
- return e.type === "textarea" ? `<textarea${u}${d} name="${o}" placeholder="${s}" style="${i}"${c}>${h(r.value || "")}</textarea>` : e.type === "select" ? `<select${u}${d} name="${o}" style="${i}"${c}>${(r.options || []).map((e) => `<option value="${h(e.value)}">${h(e.label)}</option>`).join("")}</select>` : `<input${u}${d} type="${l}" name="${o}" placeholder="${s}" value="${h(r.value || "")}" style="${i}"${c} />`;
31
- }, C = (e, t, n) => {
32
- let r = x(e, t), i = g(e.style || {}), a = v(_(r.htmlClassNames, r.htmlClass), e.id, t === "landing_page" && n), o = r.htmlId ? ` id="${h(r.htmlId)}"` : "", s = a ? ` class="${h(a)}"` : "", c = h(r.actionUrl || r.action || "#"), l = h(r.method || "POST"), u = r.fields || [], d = h(r.submitLabel || "Submit");
33
- return t === "email" ? `<mj-table${y(e.id, n)}><tr><td style="${i}"><table role="presentation" width="100%">${u.map((e) => `<tr><td style="padding:8px 0;font-family:Arial,sans-serif;color:#334155;"><strong>${h(e.label || e.name || "Field")}</strong><br/><span style="display:inline-block;margin-top:4px;padding:10px 12px;border:1px solid #d1d5db;border-radius:6px;color:#64748b;">${h(e.placeholder || "") || "&nbsp;"}</span></td></tr>`).join("")}<tr><td style="padding-top:12px;"><a href="${h(r.href || r.submitHref || "#")}" style="display:inline-block;padding:10px 16px;background:#0f172a;color:#ffffff;text-decoration:none;border-radius:6px;">${d}</a></td></tr></table></td></tr></mj-table>` : `<form${o}${s} action="${c}" method="${l}" style="${i}">${u.map((t) => S({
34
- id: `${e.id}-${String(t.name || t.label || "field")}`,
35
- type: t.kind === "textarea" || t.kind === "select" ? t.kind : "input",
36
- style: {
37
- ...e.style || {},
38
- ...t.style || {}
39
- },
40
- attributes: t
41
- }, "landing_page", n)).join("")}<button type="submit">${d}</button></form>`;
42
- }, w = [], T = !1, E = 148, D = [
43
- ["borderRadius", "border-radius"],
44
- ["borderWidth", "border-width"],
45
- ["borderStyle", "border-style"],
46
- ["borderColor", "border-color"],
47
- ["boxShadow", "box-shadow"]
48
- ], O = (e, t, n = []) => {
49
- let r = [...D.filter(([t]) => e[t]).map(([t, n]) => `${n}: ${h(String(e[t]))}`), ...n];
50
- if (r.length === 0) return "";
51
- let i = `plexo-extra-style-${t}`;
52
- return w.push(`.${i} { ${r.join("; ")}; }`), i;
53
- }, k = (e = {}, t = {}) => {
54
- let n = ["padding=\"0\""], r = e.fontSize || t.fontSize, i = e.fontWeight || t.fontWeight;
55
- return r && n.push(`font-size="${h(String(r))}"`), i && n.push(`font-weight="${h(String(i))}"`), e.color && n.push(`color="${h(String(e.color))}"`), e.fontFamily && n.push(`font-family="${h(String(e.fontFamily))}"`), e.lineHeight && n.push(`line-height="${h(String(e.lineHeight))}"`), e.letterSpacing && n.push(`letter-spacing="${h(String(e.letterSpacing))}"`), e.textAlign && n.push(`align="${h(String(e.textAlign))}"`), n.join(" ");
56
- }, A = (e = {}) => {
57
- let t = e.backgroundColor || e.background;
58
- return t ? ` background-color="${h(String(t))}"` : "";
59
- }, j = (e, t, n) => {
60
- if (e[t]) return String(e[t]);
61
- let [r, i, a, o] = n;
62
- if (e[r] || e[i] || e[a] || e[o]) return `${e[r] || "0px"} ${e[i] || "0px"} ${e[a] || "0px"} ${e[o] || "0px"}`;
63
- }, M = (e = {}) => {
64
- let t = [];
65
- e.backgroundColor && t.push(`background-color="${h(String(e.backgroundColor))}"`), e.color && t.push(`color="${h(String(e.color))}"`), e.fontSize && t.push(`font-size="${h(String(e.fontSize))}"`), e.fontWeight && t.push(`font-weight="${h(String(e.fontWeight))}"`), e.fontFamily && t.push(`font-family="${h(String(e.fontFamily))}"`), e.lineHeight && t.push(`line-height="${h(String(e.lineHeight))}"`), e.letterSpacing && t.push(`letter-spacing="${h(String(e.letterSpacing))}"`), e.textAlign && t.push(`align="${h(String(e.textAlign))}"`);
66
- let n = j(e, "borderRadius", [
67
- "borderTopLeftRadius",
68
- "borderTopRightRadius",
69
- "borderBottomRightRadius",
70
- "borderBottomLeftRadius"
71
- ]);
72
- return n && t.push(`border-radius="${h(n)}"`), t.join(" ");
73
- }, N = (l, d, f) => {
74
- let m = x(l, d), T = g(l.style || {}), E = m.htmlId ? ` id="${h(m.htmlId)}"` : "", D = _(m.htmlClassNames, m.htmlClass, d === "landing_page" && m.hideOnMobile ? "hidden md:block" : ""), O = d === "landing_page" ? v(D, l.id, f) : D, A = O ? ` class="${h(O)}"` : "", N = typeof m.customCss == "string" && m.customCss.trim() ? m.customCss.trim() : "", P = N && d === "landing_page" ? `<style>${N}</style>` : "";
75
- if (l.type === "form_container") return `${P}${C(l, d, f)}`;
76
- if (l.type === "input" || l.type === "select" || l.type === "textarea") return `${P}${S(l, d, f)}`;
77
- if (d === "email") {
78
- if (l.type === "button") {
79
- let e = h(m.href || "#"), t = h(m.text || "Button"), n = a(l).width, r = n === "auto" ? "" : ` width="${h(n)}"`, i = l.style || {}, o = M(i), s = j(i, "padding", [
80
- "paddingTop",
81
- "paddingRight",
82
- "paddingBottom",
83
- "paddingLeft"
84
- ]) || "10px 16px";
85
- return `<mj-button href="${e}" css-class="${v(m.hideOnDesktop ? "desktop-hide" : "", l.id, f)}" padding="0" inner-padding="${h(s)}"${r}${o ? ` ${o}` : ""}>${t}</mj-button>`;
86
- }
87
- if (l.type === "image") {
88
- let e = c(l), t = e.width && e.width !== "100%" ? ` width="${h(e.width)}"` : "", n = e.height && e.height !== "auto" ? ` height="${h(e.height)}"` : "", r = y(l.id, f);
89
- return `<mj-image src="${h(m.src || "")}" alt="${h(m.alt || "")}"${t}${n}${r} />`;
90
- }
91
- if (l.type === "social") {
92
- let e = t(l);
93
- if (!e.length) return "";
94
- let n = l.style || {}, r = n.textAlign === "center" ? "center" : n.textAlign === "right" ? "flex-end" : "flex-start", i = n.iconSpacing || "8px", a = j(n, "padding", [
95
- "paddingTop",
96
- "paddingRight",
97
- "paddingBottom",
98
- "paddingLeft"
99
- ]) || "8px", o = j(n, "margin", [
100
- "marginTop",
101
- "marginRight",
102
- "marginBottom",
103
- "marginLeft"
104
- ]), s = (e) => e === "square" ? "14px" : "9999px", c = e.map((e) => {
105
- let t = `<img src="${`${p}/${u[e.provider] ? e.provider : "fallback"}.png`}" alt="" width="${parseInt(e.size, 10) || 36}" style="display:block;width:60%;height:60%;border:0;" />`;
106
- return `<a href="${h(e.url)}" style="display:inline-flex;align-items:center;justify-content:center;width:${h(e.size)};height:${h(e.size)};background-color:${h(e.backgroundColor)};border-radius:${s(e.iconType)};text-decoration:none;">${t}</a>`;
107
- }).join(""), d = `display:flex;flex-wrap:wrap;justify-content:${r};gap:${h(String(i))};padding:${h(a)};${o ? `margin:${h(o)};` : ""}`;
108
- return `<mj-raw><div${b(l.id, f)} style="${d}">${c}</div></mj-raw>`;
109
- }
110
- if (l.type === "menu") {
111
- let t = e(l);
112
- return `<mj-navbar hamburger="hamburger"${y(l.id, f)}>${t.map((e) => `<mj-navbar-link href="${h(e.href)}">${h(e.label)}</mj-navbar-link>`).join("")}</mj-navbar>`;
113
- }
114
- if (l.type === "table") {
115
- let e = o(l), t = l.style || {}, n = `${t.borderWidth || "1px"} ${t.borderStyle || "solid"} ${t.borderColor || "#cbd5e1"}`, r = (r, i, a, o) => {
116
- let s = o ? "th" : "td", c = o ? t.headerBgColor || "#f8fafc" : e.striped && i % 2 == 1 ? "#f8fafc" : t.contentBgColor || "#ffffff", u = o ? t.headerTextColor || "#1e293b" : t.contentTextColor || "#475569";
117
- return `<tr>${r.map((e, r) => {
118
- let i = f ? ` data-plexo-cell="${h(l.id)}|${a}-${r}"` : "";
119
- return `<${s}${i} style="padding: ${t.cellPadding || "8px"}; border: ${n}; background-color: ${c}; color: ${u};">${h(e) || "&nbsp;"}</${s}>`;
120
- }).join("")}</tr>`;
121
- }, i = +!!e.enableHeader, a = e.enableFooter ? e.cells.length - 1 : e.cells.length, s = e.enableHeader && e.cells.length > 0 ? `<thead>${r(e.cells[0], 0, 0, !0)}</thead>` : "", c = e.cells.slice(i, Math.max(i, a)).map((e, t) => r(e, t, i + t, !1)).join(""), u = e.enableFooter && e.cells.length > i ? `<tfoot>${r(e.cells[e.cells.length - 1], e.cells.length - 1, e.cells.length - 1, !1)}</tfoot>` : "";
122
- return `<mj-table${y(l.id, f)}><table role="presentation" style="border-collapse: collapse; width: 100%;">${s}<tbody>${c}</tbody>${u}</table></mj-table>`;
123
- }
124
- if (l.type === "video") {
125
- let e = n(m.videoUrl), t = m.linkType === "email" ? `mailto:${m.href || ""}` : m.href || m.videoUrl || "#", r = y(l.id, f);
126
- return `<mj-image src="${h(e.thumbnailUrl)}" href="${h(t)}" alt="${h(m.alt || "Video preview")}"${r} />`;
127
- }
128
- if (l.type === "timer") {
129
- let e = r(m.targetDate, m.timezone), t = m.showLabels !== !1;
130
- return `<mj-text align="center"${y(l.id, f)}><div style="font-size: 28px; font-weight: 800;">${e.days}d ${e.hours}h ${e.minutes}m ${e.seconds}s</div>${t ? `<div style="font-size: 12px; color: #64748b;">Countdown to ${h(m.targetDate || "")}</div>` : ""}</mj-text>`;
131
- }
132
- if (l.type === "carousel") {
133
- let e = Array.isArray(m.images) ? m.images : [], t = y(l.id, f);
134
- return e.length === 0 ? `<mj-text align="center"${t}>No images in carousel</mj-text>` : `<mj-carousel${t}>${e.map((e) => `<mj-carousel-image src="${h(e.src)}" alt="${h(e.alt || "")}" />`).join("")}</mj-carousel>`;
135
- }
136
- if (l.type === "icon") {
137
- let e = parseInt(String(m.iconSize || 48), 10) || 48, t = l.style?.color || "#1e293b", n = s(m.iconName, e, t);
138
- return `<mj-text align="center"${y(l.id, f)}>${n}</mj-text>`;
139
- }
140
- let d = v(m.hideOnDesktop ? "desktop-hide" : "", l.id, f);
141
- if (l.type === "heading" || l.type === "paragraph" || l.type === "text") {
142
- let e = l.type === "heading" ? {
143
- fontSize: "24px",
144
- fontWeight: "700"
145
- } : { fontSize: "14px" }, t = l.style || {}, n = k(t, e), r = i(l).autoWidth, a = /* @__PURE__ */ new Set([
146
- "fontSize",
147
- "fontWeight",
148
- "color",
149
- "fontFamily",
150
- "lineHeight",
151
- "letterSpacing",
152
- "textAlign"
153
- ]), o = Object.entries(t).filter(([e, t]) => !a.has(e) && e !== "width" && t != null && t !== "").map(([e, t]) => `${e.replace(/([A-Z])/g, "-$1").toLowerCase()}: ${h(String(t))}`);
154
- r ? o.push("display: inline-block") : t.width && o.push(`width: ${h(String(t.width))}`), t.height && o.push("overflow: hidden");
155
- let s = "";
156
- o.length > 0 && (s = `plexo-textbox-${l.id}`, w.push(`.${s} > div { ${o.join("; ")}; }`));
157
- let c = _(s, d);
158
- return `<mj-text${n ? ` ${n}` : ""} css-class="${c}">${m.text || ""}</mj-text>`;
159
- }
160
- if (l.type === "spacer") {
161
- let e = l.style?.height || "24px", t = y(l.id, f);
162
- return `<mj-spacer height="${h(String(e))}"${t} />`;
163
- }
164
- if (l.type === "divider") {
165
- let e = l.style || {}, t = y(l.id, f);
166
- return `<mj-divider border-width="${h(String(e.borderWidth || "1px"))}" border-style="${h(String(e.borderStyle || "solid"))}" border-color="${h(String(e.borderColor || "#334155"))}"${t} />`;
167
- }
168
- return l.type === "card" ? `<mj-text css-class="${d}"><strong style="display:block;margin-bottom:8px;">${h(m.title || "Card Title")}</strong><span style="font-size:14px;color:#64748b;">${h(m.description || "Card description.")}</span></mj-text>` : l.type === "html" ? `<mj-text css-class="${d}">${m.htmlContent || m.text || ""}</mj-text>` : `<mj-text${E}${A} css-class="${d}">${h(m.text || m.htmlContent || "")}</mj-text>`;
169
- }
170
- switch (l.type) {
171
- case "heading": return `${P}<h2${E}${A} style="${T}">${h(m.text || "Heading")}</h2>`;
172
- case "paragraph":
173
- case "text": return `${P}<p${E}${A} style="${T}">${h(m.text || "")}</p>`;
174
- case "button": return `${P}<a${E}${A} href="${h(m.href || "#")}" style="${T}">${h(m.text || "Button")}</a>`;
175
- case "image": return `${P}<img${E}${A} src="${h(m.src || "")}" alt="${h(m.alt || "")}" style="${T}" />`;
176
- case "html": return `${P}<div${E}${A} style="${T}">${String(m.htmlContent || "")}</div>`;
177
- case "blog_title":
178
- case "blog_content":
179
- case "blog_featured_image":
180
- case "blog_date":
181
- case "blog_author":
182
- case "blog_categories":
183
- case "blog_comments":
184
- case "blog_post_list": return `${P}<div${E}${A} data-plexo-blog-${l.type.replace(/^blog_/, "").replace(/_([a-z])/g, (e, t) => t.toUpperCase())}="true"${m.prefix ? ` data-plexo-blog-prefix="${h(m.prefix)}"` : ""} style="${T}"></div>`;
185
- default: return `${P}<div${E}${A} style="${T}">${h(m.text || "")}</div>`;
186
- }
187
- }, P = (e, t, n) => {
188
- if (t === "email") {
189
- let r = new Map(e.elements.map((e) => [e.id, e])), i = new Map((Array.isArray(e.nestedRows) ? e.nestedRows : []).map((e) => [e.id, e])), a = l(e).map((e) => {
190
- let a = r.get(e);
191
- if (a) return N(a, t, n);
192
- let o = i.get(e);
193
- return o ? `<mj-raw><tr><td style="font-size:16px;">${F(o, "landing_page", n)}</td></tr></mj-raw>` : "";
194
- }).join(""), o = A(e.styles || {}), s = e.elements.length === 0 && (!Array.isArray(e.nestedRows) || e.nestedRows.length === 0), c = _(T && s ? O({}, e.id, [`min-height: ${E}px`]) : "", v("", e.id, n)), u = c ? ` css-class="${h(c)}"` : "";
195
- return `<mj-column width="${h(e.width || "100%")}"${o}${u}>${a}</mj-column>`;
196
- }
197
- let r = g(e.styles || {}), i = new Map(e.elements.map((e) => [e.id, e])), a = new Map((Array.isArray(e.nestedRows) ? e.nestedRows : []).map((e) => [e.id, e])), o = l(e).map((e) => {
198
- let r = i.get(e);
199
- if (r) return N(r, t, n);
200
- let o = a.get(e);
201
- return o ? F(o, t, n) : "";
202
- }).join(""), s = b(e.id, n), c = e.elements.length === 0 && (!Array.isArray(e.nestedRows) || e.nestedRows.length === 0), u = T && c ? `min-height: ${E}px;` : "";
203
- return `<div${s} style="width:${h(e.width || "100%")};${u}${r}">${o}</div>`;
204
- }, F = (e, t, n) => {
205
- if (t === "email") return `<mj-section css-class="${v(e.style?.hideOnDesktop ? "desktop-hide" : "", e.id, n)}"${A(e.style || {})}>${e.columns.map((e) => P(e, t, n)).join("")}</mj-section>`;
206
- let r = g(e.style || {}), i = e.columns.map((e) => P(e, t, n)).join("");
207
- return `<section${b(e.id, n)} style="display:flex;flex-wrap:wrap;${r}">${i}</section>`;
208
- }, I = (e, t, n) => {
209
- let r = n?.instrument ?? !1;
210
- w = [], T = n?.canvasEditorPadding ?? !1;
211
- let i = (e.body?.rows || []).map((e) => F(e, t, r)).join(""), a = g(e.body?.style || {});
212
- return t === "email" ? `<mjml><mj-head><mj-style>.desktop-hide { display:none !important; max-height:0; overflow:hidden; }${w.length > 0 ? ` ${w.join(" ")}` : ""}</mj-style></mj-head><mj-body><mj-section><mj-column><mj-text css-class="preheader" padding="0" font-size="1px" color="#ffffff">&nbsp;</mj-text></mj-column></mj-section>${i}</mj-body></mjml>`.replace(/<span[^>]*data-merge-val="([^"]*)"[^>]*>[\s\S]*?<\/span>/gi, "$1") : `<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /></head><body style="${a}"><main>${i}</main></body></html>`;
213
- };
214
- //#endregion
215
- export { I as t };