@chaibuilder/sdk 3.2.5 → 3.2.7
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/apply-binding-DWIWrG2P.cjs +1 -0
- package/dist/{apply-binding-B11pPFEE.js → apply-binding-IFVE37dG.js} +221 -217
- package/dist/{code-editor-Dnh6rQUv.js → code-editor-Bbeel8oa.js} +1 -1
- package/dist/{code-editor-DZUtFaVp.cjs → code-editor-CWO-tegZ.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.js +82 -81
- package/dist/index-BVbLLob7.cjs +160 -0
- package/dist/index-H6m-0wVZ.js +18661 -0
- package/dist/render.cjs +1 -1
- package/dist/render.d.ts +1 -1
- package/dist/render.js +36 -34
- package/dist/{rte-widget-modal-OhTwfpvx.cjs → rte-widget-modal-3yhyrVpY.cjs} +1 -1
- package/dist/{rte-widget-modal-BGHSjMUE.js → rte-widget-modal-DbOJAIEv.js} +1 -1
- package/package.json +15 -14
- package/dist/apply-binding-DOJpwjiG.cjs +0 -1
- package/dist/index-BNkSb0bl.js +0 -12993
- package/dist/index-WOKO7fh-.cjs +0 -154
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { g as ct, c as P } from "./common-functions-D2lMFR6K.js";
|
|
2
|
-
import { isEmpty as x, flatten as pt, flatMapDeep as ut, get as
|
|
2
|
+
import { isEmpty as x, flatten as pt, flatMapDeep as ut, get as y, set as w, startsWith as k, find as m, startCase as dt, forEach as N, camelCase as yt, includes as T, has as A, filter as Q, some as ht, unset as H, map as st, compact as mt, trim as gt, capitalize as bt, memoize as xt, cloneDeep as M, keys as R, isString as $, isArray as I, each as ft, last as _t } from "lodash-es";
|
|
3
3
|
import { parse as kt, stringify as D } from "himalaya";
|
|
4
4
|
import { getRegisteredChaiBlock as vt } from "@chaibuilder/runtime";
|
|
5
5
|
import { twMerge as wt } from "tailwind-merge";
|
|
6
|
-
const f = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", Tt = "#", tt = "dt#",
|
|
6
|
+
const f = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", Tt = "#", tt = "dt#", at = (e) => {
|
|
7
7
|
if (e = e.replace(f, ""), !e) return { baseClasses: "", classes: "" };
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
return { baseClasses: "", classes:
|
|
11
|
-
const [t, ...s] =
|
|
8
|
+
const n = e.split(/,(?![^\[]*\])/);
|
|
9
|
+
if (n.length === 1)
|
|
10
|
+
return { baseClasses: "", classes: n[0].trim() };
|
|
11
|
+
const [t, ...s] = n;
|
|
12
12
|
return {
|
|
13
13
|
baseClasses: t.trim(),
|
|
14
14
|
classes: s.join(",").trim().replace(/ +(?= )/g, "")
|
|
@@ -40,20 +40,20 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
40
40
|
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
for (let
|
|
44
|
-
const t =
|
|
45
|
-
expect(t).toEqual(e[
|
|
43
|
+
for (let n in e) {
|
|
44
|
+
const t = at(`${f}${n}`);
|
|
45
|
+
expect(t).toEqual(e[n]);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
const Bt = (e) => {
|
|
50
|
-
const
|
|
51
|
-
return
|
|
50
|
+
const n = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, t = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
|
|
51
|
+
return n.test(e) || t.test(e);
|
|
52
52
|
}, Et = (e) => {
|
|
53
53
|
if (x(e)) return e;
|
|
54
|
-
const
|
|
55
|
-
return o && (
|
|
56
|
-
},
|
|
54
|
+
const n = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(n), a = e.match(t), o = s ? s[1] : a ? a[1] : null, i = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, l = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
55
|
+
return o && (i.test(o) || l.test(o)) ? o : e;
|
|
56
|
+
}, nt = ["chai-name", "data-chai-name"], $t = {
|
|
57
57
|
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
58
58
|
video: {
|
|
59
59
|
src: "url",
|
|
@@ -89,58 +89,62 @@ const Bt = (e) => {
|
|
|
89
89
|
form: {
|
|
90
90
|
action: "action"
|
|
91
91
|
}
|
|
92
|
-
}, Nt = (e,
|
|
92
|
+
}, Nt = (e, n) => e.children.length === 1 && T(
|
|
93
93
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
94
|
-
|
|
95
|
-
), j = (e) => e.map((
|
|
96
|
-
const
|
|
94
|
+
n._type
|
|
95
|
+
), j = (e) => e.map((n) => n.type === "text" ? y(n, "content", "") : x(n.children) ? "" : j(n.children)).join(""), W = (e) => e === null ? "" : e, ot = (e) => {
|
|
96
|
+
const n = mt(st(e.split(/\s+/), gt)), t = m(n, (l) => /^w-/.test(l)), s = m(n, (l) => /^h-/.test(l));
|
|
97
97
|
if (!s || !t) return { height: "", width: "" };
|
|
98
|
-
const
|
|
99
|
-
if (!
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
102
|
-
if (
|
|
103
|
-
const r =
|
|
104
|
-
return /^\d+(\.\d+)?$/.test(r) ? `${Number(r) * 4}px` : r === "auto" ||
|
|
105
|
-
}, o =
|
|
98
|
+
const a = (l) => {
|
|
99
|
+
if (!l) return;
|
|
100
|
+
const u = l.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
|
|
101
|
+
if (!u) return;
|
|
102
|
+
if (u[1]) return u[1];
|
|
103
|
+
const r = u[2];
|
|
104
|
+
return /^\d+(\.\d+)?$/.test(r) ? `${Number(r) * 4}px` : r === "auto" || T(r, "%") ? r : "16px";
|
|
105
|
+
}, o = a(t), i = a(s);
|
|
106
106
|
return {
|
|
107
|
-
width:
|
|
108
|
-
height:
|
|
107
|
+
width: T(o, "px") ? o : "16px",
|
|
108
|
+
height: T(i, "px") ? i : "16px"
|
|
109
109
|
};
|
|
110
110
|
}, et = (e) => {
|
|
111
111
|
if (e.tagName === "svg") return {};
|
|
112
|
-
const
|
|
113
|
-
return N(s, ({ key:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
l
|
|
112
|
+
const n = {}, t = $t[e.tagName] || {}, s = e.attributes;
|
|
113
|
+
return N(s, ({ key: a, value: o }) => {
|
|
114
|
+
var i;
|
|
115
|
+
if (!T(nt, a))
|
|
116
|
+
if (a === "bid" && (n._bid = W(o)), t[a]) {
|
|
117
|
+
if (e.tagName === "img" && a === "src" && !o.startsWith("http")) {
|
|
118
|
+
const l = m(e.attributes, { key: "width" }), u = m(e.attributes, { key: "height" });
|
|
119
|
+
l && u ? o = `https://picsum.photos/${l == null ? void 0 : l.value}x${u == null ? void 0 : u.value}` : o = "https://picsum.photos/150x150";
|
|
120
|
+
} else if (e.tagName === "a") {
|
|
121
|
+
const l = m(e.attributes, { key: "href" });
|
|
122
|
+
l && typeof (l == null ? void 0 : l.value) == "string" && ((i = l == null ? void 0 : l.value) != null && i.startsWith("pageType:")) && w(n, "link.type", "pageType");
|
|
119
123
|
}
|
|
120
|
-
|
|
121
|
-
} else
|
|
122
|
-
}), delete
|
|
123
|
-
}, St = (e,
|
|
124
|
-
if (!e.attributes) return { [
|
|
124
|
+
w(n, t[a], W(o));
|
|
125
|
+
} else T(["style", "class", "srcset", "bid"], a) || (A(n, "styles_attrs") || (n.styles_attrs = {}), k(a, "@") && (a = a.replace("@", "x-on:")), n.styles_attrs[`${a}`] = W(o));
|
|
126
|
+
}), delete n.class, n;
|
|
127
|
+
}, St = (e, n = "styles") => {
|
|
128
|
+
if (!e.attributes) return { [n]: `${f},` };
|
|
125
129
|
const t = m(e.attributes, { key: "class" });
|
|
126
130
|
if (t) {
|
|
127
131
|
const s = t.value;
|
|
128
|
-
return { [
|
|
132
|
+
return { [n]: `${f},${s}` };
|
|
129
133
|
}
|
|
130
|
-
return { [
|
|
134
|
+
return { [n]: `${f},` };
|
|
131
135
|
}, It = (e) => {
|
|
132
|
-
const
|
|
136
|
+
const n = y(e, "attributes", []), t = n.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), s = n.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), a = n.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = n.find(
|
|
133
137
|
(r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
|
|
134
|
-
),
|
|
138
|
+
), i = n.find(
|
|
135
139
|
(r) => r.key === "data-chai-dropdown-content" || r.key === "chai-dropdown-content"
|
|
136
|
-
),
|
|
137
|
-
if (
|
|
140
|
+
), l = n.find((r) => r.key === "class"), u = l && l.value.split(/\s+/).includes("rte");
|
|
141
|
+
if (a)
|
|
138
142
|
return { _type: "Dropdown" };
|
|
139
143
|
if (o)
|
|
140
144
|
return { _type: "DropdownButton" };
|
|
141
|
-
if (
|
|
145
|
+
if (i)
|
|
142
146
|
return { _type: "DropdownContent" };
|
|
143
|
-
if (t ||
|
|
147
|
+
if (t || u)
|
|
144
148
|
return { _type: "Paragraph" };
|
|
145
149
|
if (s)
|
|
146
150
|
return { _type: "LightBoxLink" };
|
|
@@ -222,7 +226,7 @@ const Bt = (e) => {
|
|
|
222
226
|
case "tfoot":
|
|
223
227
|
return { _type: "TableFooter" };
|
|
224
228
|
default: {
|
|
225
|
-
const r =
|
|
229
|
+
const r = y(e, "children", []).length > 0 ? "Box" : "EmptyBox";
|
|
226
230
|
return {
|
|
227
231
|
_type: r,
|
|
228
232
|
tag: e.tagName,
|
|
@@ -230,34 +234,34 @@ const Bt = (e) => {
|
|
|
230
234
|
};
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
|
-
}, q = (e,
|
|
237
|
+
}, q = (e, n = null) => ut(e, (t) => {
|
|
234
238
|
var O, V, J, z, F, U, Y, K, X, Z;
|
|
235
239
|
if (t.type === "comment") return [];
|
|
236
240
|
let s = { _id: ct() };
|
|
237
|
-
if (
|
|
238
|
-
return x(
|
|
241
|
+
if (n && (s._parent = n.block._id), t.type === "text")
|
|
242
|
+
return x(y(t, "content", "")) ? [] : n && Nt(n.node, n.block) ? (w(n, "block.content", y(t, "content", "")), []) : { ...s, _type: "Text", content: y(t, "content", "") };
|
|
239
243
|
if (k(t.tagName, "chai-")) {
|
|
240
|
-
const c = t.attributes, p = m(c, { key: "chai-type" }),
|
|
241
|
-
s._type =
|
|
244
|
+
const c = t.attributes, p = m(c, { key: "chai-type" }), d = (p == null ? void 0 : p.value) || dt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
245
|
+
s._type = d, N(c, ({ key: g, value: G }) => {
|
|
242
246
|
if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
|
|
243
247
|
if (g === "id") {
|
|
244
248
|
s._id = G;
|
|
245
249
|
return;
|
|
246
250
|
}
|
|
247
|
-
const rt = k(g, "_") ? g :
|
|
248
|
-
let S =
|
|
251
|
+
const rt = k(g, "_") ? g : yt(g);
|
|
252
|
+
let S = W(G);
|
|
249
253
|
typeof S == "string" && k(S, "#styles:") && (S = S.replace("#styles:", "#styles:,")), s[rt] = S;
|
|
250
254
|
});
|
|
251
|
-
const
|
|
252
|
-
return [s, ...
|
|
255
|
+
const h = q(t.children, { block: s, node: t });
|
|
256
|
+
return [s, ...h];
|
|
253
257
|
}
|
|
254
|
-
const
|
|
258
|
+
const a = y(t, "attributes", []), o = t.tagName === "p" || a.find((c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"), i = a.find((c) => c.key === "class"), l = i && i.value.split(/\s+/).includes("rte"), u = a.find(
|
|
255
259
|
(c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
|
|
256
|
-
), r =
|
|
260
|
+
), r = a.find(
|
|
257
261
|
(c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
|
|
258
|
-
),
|
|
262
|
+
), B = a.find(
|
|
259
263
|
(c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
|
|
260
|
-
), C =
|
|
264
|
+
), C = a.find(
|
|
261
265
|
(c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
|
|
262
266
|
);
|
|
263
267
|
if (s = {
|
|
@@ -266,12 +270,12 @@ const Bt = (e) => {
|
|
|
266
270
|
...et(t),
|
|
267
271
|
...St(t)
|
|
268
272
|
}, t.attributes) {
|
|
269
|
-
const c = t.attributes.find((p) =>
|
|
273
|
+
const c = t.attributes.find((p) => T(nt, p.key));
|
|
270
274
|
c && (s._name = c.value);
|
|
271
275
|
}
|
|
272
|
-
if (o ||
|
|
276
|
+
if (o || l)
|
|
273
277
|
return s.content = `<p>${D(t.children || [])}</p>`, A(s, "styles_attrs.data-chai-richtext") && delete s.styles_attrs["data-chai-richtext"], A(s, "styles_attrs.chai-richtext") && delete s.styles_attrs["chai-richtext"], [s];
|
|
274
|
-
if (
|
|
278
|
+
if (u) {
|
|
275
279
|
const c = [
|
|
276
280
|
"data-chai-lightbox",
|
|
277
281
|
"chai-lightbox",
|
|
@@ -284,153 +288,153 @@ const Bt = (e) => {
|
|
|
284
288
|
];
|
|
285
289
|
s = {
|
|
286
290
|
...s,
|
|
287
|
-
href: ((O =
|
|
288
|
-
hrefType: ((V =
|
|
289
|
-
autoplay: ((J =
|
|
290
|
-
maxWidth: ((F = (z =
|
|
291
|
-
backdropColor: ((U =
|
|
292
|
-
galleryName: ((Y =
|
|
291
|
+
href: ((O = a.find((p) => p.key === "href")) == null ? void 0 : O.value) || "",
|
|
292
|
+
hrefType: ((V = a.find((p) => p.key === "data-vbtype")) == null ? void 0 : V.value) || "video",
|
|
293
|
+
autoplay: ((J = a.find((p) => p.key === "data-autoplay")) == null ? void 0 : J.value) === "true" ? "true" : "false",
|
|
294
|
+
maxWidth: ((F = (z = a.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : F.replace("px", "")) || "",
|
|
295
|
+
backdropColor: ((U = a.find((p) => p.key === "data-overlay")) == null ? void 0 : U.value) || "",
|
|
296
|
+
galleryName: ((Y = a.find((p) => p.key === "data-gall")) == null ? void 0 : Y.value) || ""
|
|
293
297
|
}, N(c, (p) => {
|
|
294
298
|
A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
|
|
295
299
|
});
|
|
296
300
|
}
|
|
297
|
-
if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs,
|
|
301
|
+
if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs, B) {
|
|
298
302
|
delete s.styles_attrs;
|
|
299
|
-
const c = Q(t.children || [], (
|
|
303
|
+
const c = Q(t.children || [], (d) => (d == null ? void 0 : d.tagName) !== "span");
|
|
300
304
|
s.content = j(c);
|
|
301
305
|
const p = m(
|
|
302
306
|
t.children || [],
|
|
303
|
-
(
|
|
307
|
+
(d) => (d == null ? void 0 : d.tagName) === "span" && ht(d.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
304
308
|
);
|
|
305
309
|
if (p) {
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
s.icon = D([
|
|
309
|
-
const { height:
|
|
310
|
-
s.iconHeight =
|
|
310
|
+
const d = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
311
|
+
if (d) {
|
|
312
|
+
s.icon = D([d]);
|
|
313
|
+
const { height: h, width: g } = Ct(d, "16px", "16px");
|
|
314
|
+
s.iconHeight = h, s.iconWidth = g;
|
|
311
315
|
}
|
|
312
316
|
}
|
|
313
317
|
return [s];
|
|
314
318
|
}
|
|
315
319
|
if (s._type === "Input") {
|
|
316
320
|
const c = s.inputType || "text";
|
|
317
|
-
c === "checkbox" ?
|
|
321
|
+
c === "checkbox" ? w(s, "_type", "Checkbox") : c === "radio" && w(s, "_type", "Radio");
|
|
318
322
|
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
319
323
|
const c = D([t]);
|
|
320
|
-
return Bt(c) && (
|
|
324
|
+
return Bt(c) && (w(s, "_type", "Video"), w(s, "url", Et(c)), w(s, "styles", `${f},`), w(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
|
|
321
325
|
} else if (t.tagName === "svg") {
|
|
322
|
-
const c =
|
|
323
|
-
if (p &&
|
|
324
|
-
s.styles = `${f}, ${P(`w-${
|
|
326
|
+
const c = y(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: d } = ot(c);
|
|
327
|
+
if (p && d)
|
|
328
|
+
s.styles = `${f}, ${P(`w-${d} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = d == null ? void 0 : d.replace("px", "");
|
|
325
329
|
else {
|
|
326
|
-
const
|
|
327
|
-
|
|
330
|
+
const h = (K = m(t.attributes, { key: "height" })) == null ? void 0 : K.value, g = (X = m(t.attributes, { key: "width" })) == null ? void 0 : X.value;
|
|
331
|
+
h && g ? (s.styles = `${f}, ${P(`w-[${g}px] h-[${h}px]`, c)}`.trim(), s.height = h, s.width = g) : s.styles = `${f}, ${P("w-full h-full", c)}`.trim();
|
|
328
332
|
}
|
|
329
|
-
return t.attributes = Q(t.attributes, (
|
|
330
|
-
} else if (t.tagName == "option" &&
|
|
331
|
-
return
|
|
333
|
+
return t.attributes = Q(t.attributes, (h) => !T(["style", "width", "height", "class"], h.key)), s.icon = D([t]), [s];
|
|
334
|
+
} else if (t.tagName == "option" && n && ((Z = n.block) == null ? void 0 : Z._type) === "Select")
|
|
335
|
+
return n.block.options.push({
|
|
332
336
|
label: j(t.children),
|
|
333
337
|
...et(t)
|
|
334
338
|
}), [];
|
|
335
|
-
const
|
|
336
|
-
return [s, ...
|
|
337
|
-
}), Ct = (e,
|
|
338
|
-
var
|
|
339
|
-
const s =
|
|
340
|
-
|
|
339
|
+
const E = q(t.children, { block: s, node: t });
|
|
340
|
+
return [s, ...E];
|
|
341
|
+
}), Ct = (e, n, t) => {
|
|
342
|
+
var u, r;
|
|
343
|
+
const s = y(e, "attributes", []), { height: a, width: o } = ot(
|
|
344
|
+
y(m(s, { key: "class" }), "value", "")
|
|
341
345
|
);
|
|
342
|
-
if (
|
|
346
|
+
if (a && o)
|
|
343
347
|
return {
|
|
344
|
-
height: `[${
|
|
348
|
+
height: `[${a}px]`,
|
|
345
349
|
width: `[${o}px]`
|
|
346
350
|
};
|
|
347
|
-
const
|
|
351
|
+
const i = (u = m(s, { key: "height" })) == null ? void 0 : u.value, l = (r = m(s, { key: "width" })) == null ? void 0 : r.value;
|
|
348
352
|
return {
|
|
349
|
-
height:
|
|
350
|
-
width:
|
|
353
|
+
height: i ? `[${i}px]` : t,
|
|
354
|
+
width: l ? `[${l}px]` : n
|
|
351
355
|
};
|
|
352
356
|
}, Dt = (e) => {
|
|
353
|
-
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s,
|
|
354
|
-
let
|
|
355
|
-
return
|
|
357
|
+
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, a, o) => {
|
|
358
|
+
let i = o.replace(/\\"/g, '"');
|
|
359
|
+
return i = i.replace(/{([^}]+)}/g, (l) => l.replace(/"/g, '\\"')), `${a}="${i.replace(/\\"/g, '"')}"`;
|
|
356
360
|
}), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
|
|
357
|
-
const
|
|
358
|
-
return (
|
|
359
|
-
}, Lt = (e,
|
|
360
|
-
const s = x(t._bid) ? void 0 : Lt(
|
|
361
|
+
const n = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
362
|
+
return (n && n.length > 0 ? n[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
363
|
+
}, Lt = (e, n) => m(e, { _id: n }), Ot = (e, n) => x(n) ? e.map((t) => (H(t, "_bid"), t)) : st(e, (t) => {
|
|
364
|
+
const s = x(t._bid) ? void 0 : Lt(n, t._bid);
|
|
361
365
|
if (s) {
|
|
362
|
-
s._type === "Icon" &&
|
|
363
|
-
const
|
|
364
|
-
return H(
|
|
366
|
+
s._type === "Icon" && y(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
|
|
367
|
+
const a = { ...s, ...t };
|
|
368
|
+
return H(a, "_bid"), a;
|
|
365
369
|
}
|
|
366
370
|
return H(t, "_bid"), t;
|
|
367
371
|
}), Vt = (e) => {
|
|
368
|
-
const
|
|
369
|
-
return x(e) ? [] : pt(q(
|
|
372
|
+
const n = kt(Dt(e));
|
|
373
|
+
return x(e) ? [] : pt(q(n));
|
|
370
374
|
};
|
|
371
|
-
function Jt(e,
|
|
372
|
-
const s =
|
|
373
|
-
if (x(
|
|
374
|
-
const
|
|
375
|
-
return N(
|
|
376
|
-
if (
|
|
377
|
-
const
|
|
378
|
-
$(
|
|
375
|
+
function Jt(e, n, t) {
|
|
376
|
+
const s = y(t, "i18nProps", []);
|
|
377
|
+
if (x(n) || x(s)) return e;
|
|
378
|
+
const a = M(e);
|
|
379
|
+
return N(R(a), (o) => {
|
|
380
|
+
if (T(s, o) && !x(n)) {
|
|
381
|
+
const i = y(a, o), l = y(a, `${o}-${n}`, "");
|
|
382
|
+
$(i) ? a[o] = $(l) && !x(l.trim()) && l.trimStart() || i : a[o] = x(l) ? i : l;
|
|
379
383
|
}
|
|
380
|
-
}),
|
|
384
|
+
}), a;
|
|
381
385
|
}
|
|
382
|
-
const lt = (e,
|
|
383
|
-
const { baseClasses: t, classes: s } =
|
|
384
|
-
var
|
|
385
|
-
return (
|
|
386
|
-
}),
|
|
387
|
-
return wt.apply(null, [t, ...o,
|
|
386
|
+
const lt = (e, n) => {
|
|
387
|
+
const { baseClasses: t, classes: s } = at(e), o = s.split(" ").filter((l) => l.startsWith(tt)).map((l) => {
|
|
388
|
+
var u;
|
|
389
|
+
return (u = n[l]) == null ? void 0 : u.value;
|
|
390
|
+
}), i = s.split(" ").filter((l) => !l.startsWith(tt)).join(" ");
|
|
391
|
+
return wt.apply(null, [t, ...o, i]);
|
|
388
392
|
};
|
|
389
|
-
function At(e,
|
|
390
|
-
return
|
|
393
|
+
function At(e, n) {
|
|
394
|
+
return y(e, `${n}_attrs`, {});
|
|
391
395
|
}
|
|
392
|
-
function zt(e,
|
|
396
|
+
function zt(e, n = !0, t = {}) {
|
|
393
397
|
const s = {};
|
|
394
|
-
return Object.keys(e).forEach((
|
|
395
|
-
if ($(e[
|
|
396
|
-
const o = lt(e[
|
|
397
|
-
s[
|
|
398
|
+
return Object.keys(e).forEach((a) => {
|
|
399
|
+
if ($(e[a]) && e[a].startsWith(f)) {
|
|
400
|
+
const o = lt(e[a], t), i = At(e, a);
|
|
401
|
+
s[a] = {
|
|
398
402
|
...!x(o) && { className: o },
|
|
399
|
-
...
|
|
400
|
-
...
|
|
401
|
-
"data-style-prop":
|
|
403
|
+
...i,
|
|
404
|
+
...n ? {
|
|
405
|
+
"data-style-prop": a,
|
|
402
406
|
"data-block-parent": e._id,
|
|
403
|
-
"data-style-id": `${
|
|
407
|
+
"data-style-id": `${a}-${e._id}`
|
|
404
408
|
} : {}
|
|
405
409
|
};
|
|
406
410
|
}
|
|
407
411
|
}), s;
|
|
408
412
|
}
|
|
409
413
|
const Ft = xt((e) => {
|
|
410
|
-
const
|
|
411
|
-
return Object.fromEntries(Object.entries(t).filter(([, s]) =>
|
|
412
|
-
}), Ut = (e,
|
|
414
|
+
const n = vt(e), t = y(n, "schema.properties", {});
|
|
415
|
+
return Object.fromEntries(Object.entries(t).filter(([, s]) => y(s, "runtime", !1)));
|
|
416
|
+
}), Ut = (e, n) => {
|
|
413
417
|
if (!I(e)) return e;
|
|
414
418
|
let t = e, s;
|
|
415
|
-
return typeof
|
|
416
|
-
}, Yt = (e,
|
|
419
|
+
return typeof n.limit == "number" && n.limit > 0 && (s = n.limit), s !== void 0 && (t = t.slice(0, s)), t;
|
|
420
|
+
}, Yt = (e, n) => {
|
|
417
421
|
const t = M(e);
|
|
418
|
-
return N(
|
|
422
|
+
return N(R(t), (s) => {
|
|
419
423
|
if ($(t[s]) && !k(s, "_")) {
|
|
420
|
-
let
|
|
421
|
-
s === "repeaterItems" && (t.repeaterItemsBinding =
|
|
422
|
-
const o = /\{\{(.*?)\}\}/g,
|
|
423
|
-
|
|
424
|
-
let
|
|
425
|
-
const r =
|
|
426
|
-
|
|
427
|
-
}), t[s] =
|
|
424
|
+
let a = t[s];
|
|
425
|
+
s === "repeaterItems" && (t.repeaterItemsBinding = a);
|
|
426
|
+
const o = /\{\{(.*?)\}\}/g, i = a.match(o);
|
|
427
|
+
i && i.forEach((l) => {
|
|
428
|
+
let u = l.slice(2, -2);
|
|
429
|
+
const r = y(n, u, l);
|
|
430
|
+
a = I(r) ? r : a.replace(l, r);
|
|
431
|
+
}), t[s] = a;
|
|
428
432
|
}
|
|
429
433
|
}), t;
|
|
430
|
-
}, _ = (e,
|
|
431
|
-
const s =
|
|
432
|
-
return ft(s, (
|
|
433
|
-
t[
|
|
434
|
+
}, _ = (e, n) => e.map((t) => {
|
|
435
|
+
const s = R(t).filter((a) => $(t[a]) && t[a].startsWith(f));
|
|
436
|
+
return ft(s, (a) => {
|
|
437
|
+
t[a] = `${f},${lt(t[a], n)}`;
|
|
434
438
|
}), t;
|
|
435
439
|
});
|
|
436
440
|
import.meta.vitest && describe("applyDesignTokens", () => {
|
|
@@ -438,7 +442,7 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
438
442
|
"dt#token1": { name: "primary-color", value: "bg-blue-500" },
|
|
439
443
|
"dt#token2": { name: "text-size", value: "text-lg" },
|
|
440
444
|
"dt#token3": { name: "spacing", value: "p-4" }
|
|
441
|
-
},
|
|
445
|
+
}, n = [
|
|
442
446
|
{
|
|
443
447
|
_id: "block1",
|
|
444
448
|
_type: "div",
|
|
@@ -462,16 +466,16 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
462
466
|
}
|
|
463
467
|
];
|
|
464
468
|
it("should process blocks and replace style properties with generated class names", () => {
|
|
465
|
-
const t = _(
|
|
469
|
+
const t = _(n, e);
|
|
466
470
|
expect(t).toHaveLength(3), expect(t[0].styles).toBe("#styles:,bg-white text-sm"), expect(t[0].className).toBe("#styles:,text-lg p-4"), expect(t[0].otherProp).toBe("not-a-style"), expect(t[0]._id).toBe("block1"), expect(t[0]._type).toBe("div");
|
|
467
471
|
}), it("should handle blocks with no style properties", () => {
|
|
468
|
-
const t = _(
|
|
472
|
+
const t = _(n, e);
|
|
469
473
|
expect(t[2].noStyles).toBe("regular-string"), expect(t[2]._id).toBe("block3");
|
|
470
474
|
}), it("should handle empty blocks array", () => {
|
|
471
475
|
const t = _([], e);
|
|
472
476
|
expect(t).toEqual([]);
|
|
473
477
|
}), it("should handle empty design tokens", () => {
|
|
474
|
-
const t = _(
|
|
478
|
+
const t = _(n, {});
|
|
475
479
|
expect(t[0].styles).toBe("#styles:,bg-white text-sm");
|
|
476
480
|
}), it("should handle blocks with only style prefix", () => {
|
|
477
481
|
const s = _([
|
|
@@ -520,11 +524,11 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
520
524
|
], e);
|
|
521
525
|
expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].nullStyles).toBeNull(), expect(s[0].undefinedStyles).toBeUndefined();
|
|
522
526
|
}), it("should preserve block structure and non-style properties", () => {
|
|
523
|
-
_(
|
|
524
|
-
expect(s._id).toBe(a
|
|
527
|
+
_(n, e).forEach((s, a) => {
|
|
528
|
+
expect(s._id).toBe(n[a]._id), expect(s._type).toBe(n[a]._type), expect(s._name).toBe(n[a]._name);
|
|
525
529
|
});
|
|
526
530
|
}), it("should handle complex design token values", () => {
|
|
527
|
-
const
|
|
531
|
+
const a = _([
|
|
528
532
|
{
|
|
529
533
|
_id: "block1",
|
|
530
534
|
_type: "div",
|
|
@@ -535,9 +539,9 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
535
539
|
"dt#complex1": { name: "complex-token", value: "hover:bg-blue-600 focus:outline-none transition-colors" },
|
|
536
540
|
"dt#complex2": { name: "spacing-token", value: "px-6 py-3 m-2" }
|
|
537
541
|
});
|
|
538
|
-
expect(
|
|
542
|
+
expect(a[0].styles).toBe("#styles:,hover:bg-blue-600 focus:outline-none transition-colors bg-white");
|
|
539
543
|
}), it("should handle tokens with empty values", () => {
|
|
540
|
-
const
|
|
544
|
+
const a = _([
|
|
541
545
|
{
|
|
542
546
|
_id: "block1",
|
|
543
547
|
_type: "div",
|
|
@@ -548,103 +552,103 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
548
552
|
"dt#empty1": { name: "empty-token", value: "" },
|
|
549
553
|
"dt#valid1": { name: "valid-token", value: "bg-green-500" }
|
|
550
554
|
});
|
|
551
|
-
expect(
|
|
555
|
+
expect(a[0].styles).toBe("#styles:,bg-white");
|
|
552
556
|
});
|
|
553
557
|
});
|
|
554
558
|
const v = (e) => {
|
|
555
|
-
const
|
|
559
|
+
const n = _t(e);
|
|
556
560
|
return e.map((t) => {
|
|
557
561
|
const s = Object.keys(t);
|
|
558
|
-
for (let
|
|
559
|
-
if ($(t[s[
|
|
560
|
-
const o = t ===
|
|
561
|
-
t[s[
|
|
562
|
+
for (let a = 0; a < s.length; a++)
|
|
563
|
+
if ($(t[s[a]]) && k(s[a], "content")) {
|
|
564
|
+
const o = t === n ? "" : " ";
|
|
565
|
+
t[s[a]] = `${t[s[a]].trim()}${o}`;
|
|
562
566
|
}
|
|
563
567
|
return t;
|
|
564
568
|
});
|
|
565
569
|
};
|
|
566
570
|
if (import.meta.vitest) {
|
|
567
|
-
const { describe: e, it:
|
|
571
|
+
const { describe: e, it: n, expect: t } = import.meta.vitest;
|
|
568
572
|
e("adjustSpacingInContentBlocks", () => {
|
|
569
|
-
|
|
570
|
-
const
|
|
573
|
+
n("should add space after content fields except for the last block", () => {
|
|
574
|
+
const a = v([
|
|
571
575
|
{ _id: "1", _type: "Text", content: "First" },
|
|
572
576
|
{ _id: "2", _type: "Text", content: "Second" },
|
|
573
577
|
{ _id: "3", _type: "Text", content: "Third" }
|
|
574
578
|
]);
|
|
575
|
-
t(
|
|
576
|
-
}),
|
|
577
|
-
const
|
|
579
|
+
t(a[0].content).toBe("First "), t(a[1].content).toBe("Second "), t(a[2].content).toBe("Third");
|
|
580
|
+
}), n("should trim whitespace from content before adding space", () => {
|
|
581
|
+
const a = v([
|
|
578
582
|
{ _id: "1", _type: "Text", content: " First " },
|
|
579
583
|
{ _id: "2", _type: "Text", content: " Second " }
|
|
580
584
|
]);
|
|
581
|
-
t(
|
|
582
|
-
}),
|
|
583
|
-
const
|
|
585
|
+
t(a[0].content).toBe("First "), t(a[1].content).toBe("Second");
|
|
586
|
+
}), n("should handle multiple content fields in a single block", () => {
|
|
587
|
+
const a = v([
|
|
584
588
|
{ _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
|
|
585
589
|
{ _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
|
|
586
590
|
]);
|
|
587
|
-
t(
|
|
588
|
-
}),
|
|
589
|
-
const
|
|
591
|
+
t(a[0].content).toBe("Main "), t(a[0].contentAlt).toBe("Alt "), t(a[1].content).toBe("Last"), t(a[1].contentSecondary).toBe("Secondary");
|
|
592
|
+
}), n("should only process fields that start with 'content'", () => {
|
|
593
|
+
const a = v([
|
|
590
594
|
{ _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
|
|
591
595
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
592
596
|
]);
|
|
593
|
-
t(
|
|
594
|
-
}),
|
|
595
|
-
const
|
|
596
|
-
t(
|
|
597
|
-
}),
|
|
598
|
-
const
|
|
599
|
-
t(
|
|
600
|
-
}),
|
|
601
|
-
const
|
|
597
|
+
t(a[0].content).toBe("Text "), t(a[0].title).toBe("Title"), t(a[0].text).toBe("Text"), t(a[1].content).toBe("Last");
|
|
598
|
+
}), n("should handle empty array", () => {
|
|
599
|
+
const a = v([]);
|
|
600
|
+
t(a).toEqual([]);
|
|
601
|
+
}), n("should handle single block", () => {
|
|
602
|
+
const a = v([{ _id: "1", _type: "Text", content: "Only" }]);
|
|
603
|
+
t(a[0].content).toBe("Only");
|
|
604
|
+
}), n("should handle blocks without content fields", () => {
|
|
605
|
+
const a = v([
|
|
602
606
|
{ _id: "1", _type: "Container", title: "Title" },
|
|
603
607
|
{ _id: "2", _type: "Container", name: "Name" }
|
|
604
608
|
]);
|
|
605
|
-
t(
|
|
606
|
-
}),
|
|
607
|
-
const
|
|
609
|
+
t(a[0].title).toBe("Title"), t(a[1].name).toBe("Name");
|
|
610
|
+
}), n("should handle blocks with non-string content fields", () => {
|
|
611
|
+
const a = v([
|
|
608
612
|
{ _id: "1", _type: "Text", content: "Text", contentNum: 123 },
|
|
609
613
|
{ _id: "2", _type: "Text", content: "Last", contentBool: !0 }
|
|
610
614
|
]);
|
|
611
|
-
t(
|
|
612
|
-
}),
|
|
613
|
-
const
|
|
615
|
+
t(a[0].content).toBe("Text "), t(a[0].contentNum).toBe(123), t(a[1].content).toBe("Last"), t(a[1].contentBool).toBe(!0);
|
|
616
|
+
}), n("should handle empty string content", () => {
|
|
617
|
+
const a = v([
|
|
614
618
|
{ _id: "1", _type: "Text", content: "" },
|
|
615
619
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
616
620
|
]);
|
|
617
|
-
t(
|
|
621
|
+
t(a[0].content).toBe(" "), t(a[1].content).toBe("Last");
|
|
618
622
|
});
|
|
619
623
|
});
|
|
620
624
|
}
|
|
621
|
-
const b = (e,
|
|
625
|
+
const b = (e, n, { index: t, key: s }, a) => {
|
|
622
626
|
if ($(e)) {
|
|
623
627
|
let o = e;
|
|
624
|
-
const
|
|
625
|
-
if (
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
let
|
|
629
|
-
t !== -1 && k(
|
|
630
|
-
const
|
|
631
|
-
|
|
628
|
+
const i = /\{\{(.*?)\}\}/g, l = e.match(i);
|
|
629
|
+
if (l) {
|
|
630
|
+
const u = a === "image" || a === "mobileImage";
|
|
631
|
+
l.forEach((r) => {
|
|
632
|
+
let B = r.slice(2, -2).trim(), C = s.slice(2, -2).trim();
|
|
633
|
+
t !== -1 && k(B, "$index.") ? B = `${C}.${t}.${B.slice(7)}` : t !== -1 && k(B, "$index") && (B = `${C}.${t}`);
|
|
634
|
+
const E = y(n, B);
|
|
635
|
+
E === void 0 ? o = o.replace(r, "") : u && !I(E) ? o = E : o = I(E) ? E : o.replace(r, E);
|
|
632
636
|
});
|
|
633
637
|
}
|
|
634
638
|
return o;
|
|
635
639
|
}
|
|
636
640
|
if (I(e))
|
|
637
|
-
return e.map((o) => b(o,
|
|
641
|
+
return e.map((o) => b(o, n, { index: t, key: s }, a));
|
|
638
642
|
if (e && typeof e == "object") {
|
|
639
643
|
const o = {};
|
|
640
|
-
return N(
|
|
641
|
-
!k(
|
|
644
|
+
return N(R(e), (i) => {
|
|
645
|
+
!k(i, "_") && i !== "$repeaterItemsKey" ? o[i] = b(e[i], n, { index: t, key: s }, i) : o[i] = e[i];
|
|
642
646
|
}), o;
|
|
643
647
|
}
|
|
644
648
|
return e;
|
|
645
|
-
}, L = (e,
|
|
646
|
-
let
|
|
647
|
-
return
|
|
649
|
+
}, L = (e, n, { index: t, key: s }) => {
|
|
650
|
+
let a = M(e);
|
|
651
|
+
return a.repeaterItems && (a.$repeaterItemsKey = a.repeaterItems, k(a.repeaterItems, `{{${Tt}`) && (a.$repeaterItemsKey = a.repeaterItems = `${a.repeaterItems.replace("}}", `/${a._id}}}`)}`), !x(a.repeaterItems) && a.pagination && (a.repeaterTotalItems = `${a.repeaterItems.replace("}}", `/${a._id}/totalItems}}`)}`)), b(a, n, { index: t, key: s });
|
|
648
652
|
};
|
|
649
653
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
650
654
|
it("should handle string values with bindings", () => {
|
|
@@ -678,11 +682,11 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
678
682
|
const t = b("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
|
|
679
683
|
expect(t).toBe("Hello ");
|
|
680
684
|
}), it("should preserve private properties starting with _", () => {
|
|
681
|
-
const
|
|
685
|
+
const n = b({
|
|
682
686
|
name: "John",
|
|
683
687
|
_private: "secret"
|
|
684
688
|
}, {}, { index: -1, key: "" });
|
|
685
|
-
expect(
|
|
689
|
+
expect(n).toEqual({
|
|
686
690
|
name: "John",
|
|
687
691
|
_private: "secret"
|
|
688
692
|
});
|
|
@@ -831,7 +835,7 @@ export {
|
|
|
831
835
|
zt as g,
|
|
832
836
|
Vt as h,
|
|
833
837
|
_ as i,
|
|
834
|
-
|
|
838
|
+
at as j,
|
|
835
839
|
qt as k,
|
|
836
840
|
Ot as m
|
|
837
841
|
};
|