@chaibuilder/sdk 3.1.32 → 3.2.0
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-BwPhgnhk.js → apply-binding-CSWwWMjY.js} +106 -105
- package/dist/apply-binding-DLHh7HoS.cjs +1 -0
- package/dist/{code-editor-tNvYQ21U.js → code-editor-BZMSNYkF.js} +1 -1
- package/dist/{code-editor-DniWNMiF.cjs → code-editor-DRCY5ruT.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.js +2 -2
- package/dist/{index-x0hEzxrt.js → index-CAiYwkFz.js} +194 -189
- package/dist/{index-Cw-O8A8U.cjs → index-DIVARO6Y.cjs} +2 -2
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-BjpCMgJv.cjs → rte-widget-modal-C7aXKVn4.cjs} +1 -1
- package/dist/{rte-widget-modal-vV5HE2hd.js → rte-widget-modal-DwKI9icC.js} +1 -1
- package/package.json +1 -1
- package/dist/apply-binding-Dblf6wMG.cjs +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { isEmpty as x, flatten as
|
|
3
|
-
import { parse as
|
|
4
|
-
import { getRegisteredChaiBlock as
|
|
5
|
-
import { twMerge as
|
|
6
|
-
const f = "#styles:",
|
|
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 d, set as E, startsWith as k, find as m, startCase as dt, forEach as S, camelCase as ht, includes as w, has as A, filter as Q, some as yt, unset as H, map as st, compact as mt, trim as gt, capitalize as bt, memoize as xt, cloneDeep as M, keys as W, isString as $, isArray as I, each as ft, last as _t } from "lodash-es";
|
|
3
|
+
import { parse as kt, stringify as D } from "himalaya";
|
|
4
|
+
import { getRegisteredChaiBlock as vt } from "@chaibuilder/runtime";
|
|
5
|
+
import { twMerge as wt } from "tailwind-merge";
|
|
6
|
+
const f = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", Tt = "#", tt = "dt#", nt = (e) => {
|
|
7
7
|
if (e = e.replace(f, ""), !e) return { baseClasses: "", classes: "" };
|
|
8
8
|
const a = e.split(/,(?![^\[]*\])/);
|
|
9
9
|
if (a.length === 1)
|
|
@@ -41,7 +41,7 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
for (let a in e) {
|
|
44
|
-
const t =
|
|
44
|
+
const t = nt(`${f}${a}`);
|
|
45
45
|
expect(t).toEqual(e[a]);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
@@ -49,11 +49,11 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
49
49
|
const Bt = (e) => {
|
|
50
50
|
const a = /(?: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
51
|
return a.test(e) || t.test(e);
|
|
52
|
-
},
|
|
52
|
+
}, Et = (e) => {
|
|
53
53
|
if (x(e)) return e;
|
|
54
54
|
const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t), o = s ? s[1] : n ? n[1] : null, l = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, i = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
55
55
|
return o && (l.test(o) || i.test(o)) ? o : e;
|
|
56
|
-
},
|
|
56
|
+
}, at = ["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,11 +89,11 @@ const Bt = (e) => {
|
|
|
89
89
|
form: {
|
|
90
90
|
action: "action"
|
|
91
91
|
}
|
|
92
|
-
},
|
|
92
|
+
}, St = (e, a) => e.children.length === 1 && w(
|
|
93
93
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
94
94
|
a._type
|
|
95
|
-
), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : x(a.children) ? "" : j(a.children)).join(""),
|
|
96
|
-
const a =
|
|
95
|
+
), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : x(a.children) ? "" : j(a.children)).join(""), R = (e) => e === null ? "" : e, ot = (e) => {
|
|
96
|
+
const a = mt(st(e.split(/\s+/), gt)), t = m(a, (i) => /^w-/.test(i)), s = m(a, (i) => /^h-/.test(i));
|
|
97
97
|
if (!s || !t) return { height: "", width: "" };
|
|
98
98
|
const n = (i) => {
|
|
99
99
|
if (!i) return;
|
|
@@ -107,20 +107,20 @@ const Bt = (e) => {
|
|
|
107
107
|
width: w(o, "px") ? o : "16px",
|
|
108
108
|
height: w(l, "px") ? l : "16px"
|
|
109
109
|
};
|
|
110
|
-
},
|
|
110
|
+
}, et = (e) => {
|
|
111
111
|
if (e.tagName === "svg") return {};
|
|
112
|
-
const a = {}, t =
|
|
112
|
+
const a = {}, t = $t[e.tagName] || {}, s = e.attributes;
|
|
113
113
|
return S(s, ({ key: n, value: o }) => {
|
|
114
|
-
if (!w(
|
|
115
|
-
if (n === "bid" && (a._bid =
|
|
114
|
+
if (!w(at, n))
|
|
115
|
+
if (n === "bid" && (a._bid = R(o)), t[n]) {
|
|
116
116
|
if (e.tagName === "img" && n === "src" && !o.startsWith("http")) {
|
|
117
117
|
const l = m(e.attributes, { key: "width" }), i = m(e.attributes, { key: "height" });
|
|
118
118
|
l && i ? o = `https://picsum.photos/${l == null ? void 0 : l.value}x${i == null ? void 0 : i.value}` : o = "https://picsum.photos/150x150";
|
|
119
119
|
}
|
|
120
|
-
E(a, t[n],
|
|
121
|
-
} else w(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), k(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] =
|
|
120
|
+
E(a, t[n], R(o));
|
|
121
|
+
} else w(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), k(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = R(o));
|
|
122
122
|
}), delete a.class, a;
|
|
123
|
-
},
|
|
123
|
+
}, Nt = (e, a = "styles") => {
|
|
124
124
|
if (!e.attributes) return { [a]: `${f},` };
|
|
125
125
|
const t = m(e.attributes, { key: "class" });
|
|
126
126
|
if (t) {
|
|
@@ -128,7 +128,7 @@ const Bt = (e) => {
|
|
|
128
128
|
return { [a]: `${f},${s}` };
|
|
129
129
|
}
|
|
130
130
|
return { [a]: `${f},` };
|
|
131
|
-
},
|
|
131
|
+
}, It = (e) => {
|
|
132
132
|
const a = d(e, "attributes", []), t = a.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), s = a.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), n = a.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = a.find(
|
|
133
133
|
(r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
|
|
134
134
|
), l = a.find(
|
|
@@ -226,27 +226,27 @@ const Bt = (e) => {
|
|
|
226
226
|
return {
|
|
227
227
|
_type: r,
|
|
228
228
|
tag: e.tagName,
|
|
229
|
-
_name: r == "EmptyBox" || e.tagName === "div" ? r :
|
|
229
|
+
_name: r == "EmptyBox" || e.tagName === "div" ? r : bt(e.tagName)
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
}, q = (e, a = null) =>
|
|
233
|
+
}, q = (e, a = null) => ut(e, (t) => {
|
|
234
234
|
var O, V, J, z, F, U, Y, K, X, Z;
|
|
235
235
|
if (t.type === "comment") return [];
|
|
236
|
-
let s = { _id:
|
|
236
|
+
let s = { _id: ct() };
|
|
237
237
|
if (a && (s._parent = a.block._id), t.type === "text")
|
|
238
|
-
return x(d(t, "content", "")) ? [] : a &&
|
|
238
|
+
return x(d(t, "content", "")) ? [] : a && St(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
|
|
239
239
|
if (k(t.tagName, "chai-")) {
|
|
240
|
-
const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) ||
|
|
240
|
+
const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || dt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
241
241
|
s._type = u, S(c, ({ key: g, value: G }) => {
|
|
242
242
|
if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
|
|
243
243
|
if (g === "id") {
|
|
244
244
|
s._id = G;
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
|
-
const
|
|
248
|
-
let N =
|
|
249
|
-
typeof N == "string" && k(N, "#styles:") && (N = N.replace("#styles:", "#styles:,")), s[
|
|
247
|
+
const rt = k(g, "_") ? g : ht(g);
|
|
248
|
+
let N = R(G);
|
|
249
|
+
typeof N == "string" && k(N, "#styles:") && (N = N.replace("#styles:", "#styles:,")), s[rt] = N;
|
|
250
250
|
});
|
|
251
251
|
const y = q(t.children, { block: s, node: t });
|
|
252
252
|
return [s, ...y];
|
|
@@ -257,18 +257,18 @@ const Bt = (e) => {
|
|
|
257
257
|
(c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
|
|
258
258
|
), r = n.find(
|
|
259
259
|
(c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
|
|
260
|
-
),
|
|
260
|
+
), T = n.find(
|
|
261
261
|
(c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
|
|
262
262
|
), C = n.find(
|
|
263
263
|
(c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
|
|
264
264
|
);
|
|
265
265
|
if (s = {
|
|
266
266
|
...s,
|
|
267
|
-
...
|
|
268
|
-
...
|
|
269
|
-
...
|
|
267
|
+
...It(t),
|
|
268
|
+
...et(t),
|
|
269
|
+
...Nt(t)
|
|
270
270
|
}, t.attributes) {
|
|
271
|
-
const c = t.attributes.find((p) => w(
|
|
271
|
+
const c = t.attributes.find((p) => w(at, p.key));
|
|
272
272
|
c && (s._name = c.value);
|
|
273
273
|
}
|
|
274
274
|
if (o || i)
|
|
@@ -296,19 +296,19 @@ const Bt = (e) => {
|
|
|
296
296
|
A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
-
if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs,
|
|
299
|
+
if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs, T) {
|
|
300
300
|
delete s.styles_attrs;
|
|
301
301
|
const c = Q(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
|
|
302
302
|
s.content = j(c);
|
|
303
303
|
const p = m(
|
|
304
304
|
t.children || [],
|
|
305
|
-
(u) => (u == null ? void 0 : u.tagName) === "span" &&
|
|
305
|
+
(u) => (u == null ? void 0 : u.tagName) === "span" && yt(u.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg")
|
|
306
306
|
);
|
|
307
307
|
if (p) {
|
|
308
308
|
const u = m(p.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg");
|
|
309
309
|
if (u) {
|
|
310
310
|
s.icon = D([u]);
|
|
311
|
-
const { height: y, width: g } =
|
|
311
|
+
const { height: y, width: g } = Ct(u, "16px", "16px");
|
|
312
312
|
s.iconHeight = y, s.iconWidth = g;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
@@ -319,26 +319,26 @@ const Bt = (e) => {
|
|
|
319
319
|
c === "checkbox" ? E(s, "_type", "Checkbox") : c === "radio" && E(s, "_type", "Radio");
|
|
320
320
|
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
321
321
|
const c = D([t]);
|
|
322
|
-
return Bt(c) && (E(s, "_type", "Video"), E(s, "url",
|
|
322
|
+
return Bt(c) && (E(s, "_type", "Video"), E(s, "url", Et(c)), E(s, "styles", `${f},`), E(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
|
|
323
323
|
} else if (t.tagName === "svg") {
|
|
324
|
-
const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } =
|
|
324
|
+
const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = ot(c);
|
|
325
325
|
if (p && u)
|
|
326
|
-
s.styles = `${f}, ${
|
|
326
|
+
s.styles = `${f}, ${P(`w-${u} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = u == null ? void 0 : u.replace("px", "");
|
|
327
327
|
else {
|
|
328
328
|
const y = (K = m(t.attributes, { key: "height" })) == null ? void 0 : K.value, g = (X = m(t.attributes, { key: "width" })) == null ? void 0 : X.value;
|
|
329
|
-
y && g ? (s.styles = `${f}, ${
|
|
329
|
+
y && g ? (s.styles = `${f}, ${P(`w-[${g}px] h-[${y}px]`, c)}`.trim(), s.height = y, s.width = g) : s.styles = `${f}, ${P("w-full h-full", c)}`.trim();
|
|
330
330
|
}
|
|
331
331
|
return t.attributes = Q(t.attributes, (y) => !w(["style", "width", "height", "class"], y.key)), s.icon = D([t]), [s];
|
|
332
332
|
} else if (t.tagName == "option" && a && ((Z = a.block) == null ? void 0 : Z._type) === "Select")
|
|
333
333
|
return a.block.options.push({
|
|
334
334
|
label: j(t.children),
|
|
335
|
-
...
|
|
335
|
+
...et(t)
|
|
336
336
|
}), [];
|
|
337
|
-
const
|
|
338
|
-
return [s, ...
|
|
339
|
-
}),
|
|
337
|
+
const B = q(t.children, { block: s, node: t });
|
|
338
|
+
return [s, ...B];
|
|
339
|
+
}), Ct = (e, a, t) => {
|
|
340
340
|
var h, r;
|
|
341
|
-
const s = d(e, "attributes", []), { height: n, width: o } =
|
|
341
|
+
const s = d(e, "attributes", []), { height: n, width: o } = ot(
|
|
342
342
|
d(m(s, { key: "class" }), "value", "")
|
|
343
343
|
);
|
|
344
344
|
if (n && o)
|
|
@@ -351,51 +351,51 @@ const Bt = (e) => {
|
|
|
351
351
|
height: l ? `[${l}px]` : t,
|
|
352
352
|
width: i ? `[${i}px]` : a
|
|
353
353
|
};
|
|
354
|
-
},
|
|
354
|
+
}, Dt = (e) => {
|
|
355
355
|
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, o) => {
|
|
356
356
|
let l = o.replace(/\\"/g, '"');
|
|
357
357
|
return l = l.replace(/{([^}]+)}/g, (i) => i.replace(/"/g, '\\"')), `${n}="${l.replace(/\\"/g, '"')}"`;
|
|
358
358
|
}), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
|
|
359
359
|
const a = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
360
360
|
return (a && a.length > 0 ? a[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
361
|
-
},
|
|
362
|
-
const s = x(t._bid) ? void 0 :
|
|
361
|
+
}, Lt = (e, a) => m(e, { _id: a }), Ot = (e, a) => x(a) ? e.map((t) => (H(t, "_bid"), t)) : st(e, (t) => {
|
|
362
|
+
const s = x(t._bid) ? void 0 : Lt(a, t._bid);
|
|
363
363
|
if (s) {
|
|
364
364
|
s._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
|
|
365
365
|
const n = { ...s, ...t };
|
|
366
|
-
return
|
|
366
|
+
return H(n, "_bid"), n;
|
|
367
367
|
}
|
|
368
|
-
return
|
|
369
|
-
}),
|
|
370
|
-
const a =
|
|
371
|
-
return x(e) ? [] :
|
|
368
|
+
return H(t, "_bid"), t;
|
|
369
|
+
}), Vt = (e) => {
|
|
370
|
+
const a = kt(Dt(e));
|
|
371
|
+
return x(e) ? [] : pt(q(a));
|
|
372
372
|
};
|
|
373
|
-
function
|
|
373
|
+
function Jt(e, a, t) {
|
|
374
374
|
const s = d(t, "i18nProps", []);
|
|
375
375
|
if (x(a) || x(s)) return e;
|
|
376
376
|
const n = M(e);
|
|
377
|
-
return S(
|
|
377
|
+
return S(W(n), (o) => {
|
|
378
378
|
if (w(s, o) && !x(a)) {
|
|
379
379
|
const l = d(n, o), i = d(n, `${o}-${a}`, "");
|
|
380
380
|
$(l) ? n[o] = $(i) && !x(i.trim()) && i.trimStart() || l : n[o] = x(i) ? l : i;
|
|
381
381
|
}
|
|
382
382
|
}), n;
|
|
383
383
|
}
|
|
384
|
-
const
|
|
385
|
-
const { baseClasses: t, classes: s } =
|
|
384
|
+
const lt = (e, a) => {
|
|
385
|
+
const { baseClasses: t, classes: s } = nt(e), o = s.split(" ").filter((i) => i.startsWith(tt)).map((i) => {
|
|
386
386
|
var h;
|
|
387
|
-
return (h = a[i
|
|
388
|
-
}), l = s.split(" ").filter((i) => !i.startsWith(
|
|
389
|
-
return
|
|
387
|
+
return (h = a[i]) == null ? void 0 : h.value;
|
|
388
|
+
}), l = s.split(" ").filter((i) => !i.startsWith(tt)).join(" ");
|
|
389
|
+
return wt.apply(null, [t, ...o, l]);
|
|
390
390
|
};
|
|
391
|
-
function
|
|
391
|
+
function At(e, a) {
|
|
392
392
|
return d(e, `${a}_attrs`, {});
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function zt(e, a = !0, t = {}) {
|
|
395
395
|
const s = {};
|
|
396
396
|
return Object.keys(e).forEach((n) => {
|
|
397
397
|
if ($(e[n]) && e[n].startsWith(f)) {
|
|
398
|
-
const o =
|
|
398
|
+
const o = lt(e[n], t), l = At(e, n);
|
|
399
399
|
s[n] = {
|
|
400
400
|
...!x(o) && { className: o },
|
|
401
401
|
...l,
|
|
@@ -408,16 +408,16 @@ function Jt(e, a = !0, t = {}) {
|
|
|
408
408
|
}
|
|
409
409
|
}), s;
|
|
410
410
|
}
|
|
411
|
-
const
|
|
412
|
-
const a =
|
|
411
|
+
const Ft = xt((e) => {
|
|
412
|
+
const a = vt(e), t = d(a, "schema.properties", {});
|
|
413
413
|
return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
|
|
414
|
-
}),
|
|
414
|
+
}), Ut = (e, a) => {
|
|
415
415
|
if (!I(e)) return e;
|
|
416
416
|
let t = e, s;
|
|
417
417
|
return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
|
|
418
|
-
},
|
|
418
|
+
}, Yt = (e, a) => {
|
|
419
419
|
const t = M(e);
|
|
420
|
-
return S(
|
|
420
|
+
return S(W(t), (s) => {
|
|
421
421
|
if ($(t[s]) && !k(s, "_")) {
|
|
422
422
|
let n = t[s];
|
|
423
423
|
s === "repeaterItems" && (t.repeaterItemsBinding = n);
|
|
@@ -430,22 +430,22 @@ const zt = bt((e) => {
|
|
|
430
430
|
}
|
|
431
431
|
}), t;
|
|
432
432
|
}, _ = (e, a) => e.map((t) => {
|
|
433
|
-
const s =
|
|
434
|
-
return
|
|
435
|
-
t[n] = `${f},${
|
|
433
|
+
const s = W(t).filter((n) => $(t[n]) && t[n].startsWith(f));
|
|
434
|
+
return ft(s, (n) => {
|
|
435
|
+
t[n] = `${f},${lt(t[n], a)}`;
|
|
436
436
|
}), t;
|
|
437
437
|
});
|
|
438
438
|
import.meta.vitest && describe("applyDesignTokens", () => {
|
|
439
439
|
const e = {
|
|
440
|
-
token1: { name: "primary-color", value: "bg-blue-500" },
|
|
441
|
-
token2: { name: "text-size", value: "text-lg" },
|
|
442
|
-
token3: { name: "spacing", value: "p-4" }
|
|
440
|
+
"dt#token1": { name: "primary-color", value: "bg-blue-500" },
|
|
441
|
+
"dt#token2": { name: "text-size", value: "text-lg" },
|
|
442
|
+
"dt#token3": { name: "spacing", value: "p-4" }
|
|
443
443
|
}, a = [
|
|
444
444
|
{
|
|
445
445
|
_id: "block1",
|
|
446
446
|
_type: "div",
|
|
447
|
-
styles: "#styles:,dt-
|
|
448
|
-
className: "#styles:,dt
|
|
447
|
+
styles: "#styles:,dt#token1 bg-white text-sm",
|
|
448
|
+
className: "#styles:,dt#token2 dt#token3",
|
|
449
449
|
otherProp: "not-a-style",
|
|
450
450
|
_name: "Test Block"
|
|
451
451
|
},
|
|
@@ -465,7 +465,7 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
465
465
|
];
|
|
466
466
|
it("should process blocks and replace style properties with generated class names", () => {
|
|
467
467
|
const t = _(a, e);
|
|
468
|
-
expect(t).toHaveLength(3), expect(t[0].styles).toBe("#styles:,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");
|
|
468
|
+
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");
|
|
469
469
|
}), it("should handle blocks with no style properties", () => {
|
|
470
470
|
const t = _(a, e);
|
|
471
471
|
expect(t[2].noStyles).toBe("regular-string"), expect(t[2]._id).toBe("block3");
|
|
@@ -474,7 +474,7 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
474
474
|
expect(t).toEqual([]);
|
|
475
475
|
}), it("should handle empty design tokens", () => {
|
|
476
476
|
const t = _(a, {});
|
|
477
|
-
expect(t[0].styles).toBe("#styles:,text-sm");
|
|
477
|
+
expect(t[0].styles).toBe("#styles:,bg-white text-sm");
|
|
478
478
|
}), it("should handle blocks with only style prefix", () => {
|
|
479
479
|
const s = _([
|
|
480
480
|
{
|
|
@@ -490,9 +490,9 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
490
490
|
{
|
|
491
491
|
_id: "block1",
|
|
492
492
|
_type: "div",
|
|
493
|
-
styles: "#styles:bg-white dt
|
|
494
|
-
hoverStyles: "#styles:bg-gray-100 dt
|
|
495
|
-
focusStyles: "#styles:outline-none dt
|
|
493
|
+
styles: "#styles:bg-white dt#token1",
|
|
494
|
+
hoverStyles: "#styles:bg-gray-100 dt#token2",
|
|
495
|
+
focusStyles: "#styles:outline-none dt#token3",
|
|
496
496
|
_name: "Multi Style"
|
|
497
497
|
}
|
|
498
498
|
], e);
|
|
@@ -530,12 +530,12 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
530
530
|
{
|
|
531
531
|
_id: "block1",
|
|
532
532
|
_type: "div",
|
|
533
|
-
styles: "#styles:bg-white dt
|
|
533
|
+
styles: "#styles:bg-white dt#complex1",
|
|
534
534
|
_name: "Complex Tokens"
|
|
535
535
|
}
|
|
536
536
|
], {
|
|
537
|
-
complex1: { name: "complex-token", value: "hover:bg-blue-600 focus:outline-none transition-colors" },
|
|
538
|
-
complex2: { name: "spacing-token", value: "px-6 py-3 m-2" }
|
|
537
|
+
"dt#complex1": { name: "complex-token", value: "hover:bg-blue-600 focus:outline-none transition-colors" },
|
|
538
|
+
"dt#complex2": { name: "spacing-token", value: "px-6 py-3 m-2" }
|
|
539
539
|
});
|
|
540
540
|
expect(n[0].styles).toBe("#styles:,hover:bg-blue-600 focus:outline-none transition-colors bg-white");
|
|
541
541
|
}), it("should handle tokens with empty values", () => {
|
|
@@ -543,18 +543,18 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
543
543
|
{
|
|
544
544
|
_id: "block1",
|
|
545
545
|
_type: "div",
|
|
546
|
-
styles: "#styles:bg-white dt
|
|
546
|
+
styles: "#styles:bg-white dt#empty1 dt#valid1",
|
|
547
547
|
_name: "Empty Value Tokens"
|
|
548
548
|
}
|
|
549
549
|
], {
|
|
550
|
-
empty1: { name: "empty-token", value: "" },
|
|
551
|
-
valid1: { name: "valid-token", value: "bg-green-500" }
|
|
550
|
+
"dt#empty1": { name: "empty-token", value: "" },
|
|
551
|
+
"dt#valid1": { name: "valid-token", value: "bg-green-500" }
|
|
552
552
|
});
|
|
553
553
|
expect(n[0].styles).toBe("#styles:,bg-white");
|
|
554
554
|
});
|
|
555
555
|
});
|
|
556
556
|
const v = (e) => {
|
|
557
|
-
const a =
|
|
557
|
+
const a = _t(e);
|
|
558
558
|
return e.map((t) => {
|
|
559
559
|
const s = Object.keys(t);
|
|
560
560
|
for (let n = 0; n < s.length; n++)
|
|
@@ -627,10 +627,10 @@ const b = (e, a, { index: t, key: s }, n) => {
|
|
|
627
627
|
if (i) {
|
|
628
628
|
const h = n === "image" || n === "mobileImage";
|
|
629
629
|
i.forEach((r) => {
|
|
630
|
-
let
|
|
631
|
-
t !== -1 && k(
|
|
632
|
-
const
|
|
633
|
-
|
|
630
|
+
let T = r.slice(2, -2).trim(), C = s.slice(2, -2).trim();
|
|
631
|
+
t !== -1 && k(T, "$index.") ? T = `${C}.${t}.${T.slice(7)}` : t !== -1 && k(T, "$index") && (T = `${C}.${t}`);
|
|
632
|
+
const B = d(a, T);
|
|
633
|
+
B === void 0 ? o = o.replace(r, "") : h && !I(B) ? o = B : o = I(B) ? B : o.replace(r, B);
|
|
634
634
|
});
|
|
635
635
|
}
|
|
636
636
|
return o;
|
|
@@ -639,14 +639,14 @@ const b = (e, a, { index: t, key: s }, n) => {
|
|
|
639
639
|
return e.map((o) => b(o, a, { index: t, key: s }, n));
|
|
640
640
|
if (e && typeof e == "object") {
|
|
641
641
|
const o = {};
|
|
642
|
-
return S(
|
|
642
|
+
return S(W(e), (l) => {
|
|
643
643
|
!k(l, "_") && l !== "$repeaterItemsKey" ? o[l] = b(e[l], a, { index: t, key: s }, l) : o[l] = e[l];
|
|
644
644
|
}), o;
|
|
645
645
|
}
|
|
646
646
|
return e;
|
|
647
647
|
}, L = (e, a, { index: t, key: s }) => {
|
|
648
648
|
let n = M(e);
|
|
649
|
-
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, k(n.repeaterItems, `{{${
|
|
649
|
+
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, k(n.repeaterItems, `{{${Tt}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !x(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, a, { index: t, key: s });
|
|
650
650
|
};
|
|
651
651
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
652
652
|
it("should handle string values with bindings", () => {
|
|
@@ -820,19 +820,20 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
820
820
|
});
|
|
821
821
|
}));
|
|
822
822
|
export {
|
|
823
|
-
|
|
824
|
-
|
|
823
|
+
Tt as C,
|
|
824
|
+
tt as D,
|
|
825
|
+
Mt as R,
|
|
825
826
|
f as S,
|
|
826
827
|
L as a,
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
828
|
+
Jt as b,
|
|
829
|
+
Ft as c,
|
|
830
|
+
Ut as d,
|
|
830
831
|
v as e,
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
832
|
+
Yt as f,
|
|
833
|
+
zt as g,
|
|
834
|
+
Vt as h,
|
|
834
835
|
_ as i,
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
836
|
+
nt as j,
|
|
837
|
+
qt as k,
|
|
838
|
+
Ot as m
|
|
838
839
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const T=require("./common-functions-B3a4xKt_.cjs"),t=require("lodash-es"),k=require("himalaya"),z=require("@chaibuilder/runtime"),U=require("tailwind-merge"),m="#styles:",Y="__ADD_BLOCK_INTERNAL_ROOT",K="@",V="#",v="dt#",H=e=>{if(e=e.replace(m,""),!e)return{baseClasses:"",classes:""};const l=e.split(/,(?![^\[]*\])/);if(l.length===1)return{baseClasses:"",classes:l[0].trim()};const[n,...s]=l;return{baseClasses:n.trim(),classes:s.join(",").trim().replace(/ +(?= )/g,"")}},X=e=>{const l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return l.test(e)||n.test(e)},G=e=>{if(t.isEmpty(e))return e;const l=/<video[^>]+src=['"]([^'">]+)['"]/,n=/<iframe[^>]+src=['"]([^'">]+)['"]/,s=e.match(l),a=e.match(n),i=s?s[1]:a?a[1]:null,o=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return i&&(o.test(i)||r.test(i))?i:e},M=["chai-name","data-chai-name"],Z={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},Q=(e,l)=>e.children.length===1&&t.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],l._type),E=e=>e.map(l=>l.type==="text"?t.get(l,"content",""):t.isEmpty(l.children)?"":E(l.children)).join(""),B=e=>e===null?"":e,O=e=>{const l=t.compact(t.map(e.split(/\s+/),t.trim)),n=t.find(l,r=>/^w-/.test(r)),s=t.find(l,r=>/^h-/.test(r));if(!s||!n)return{height:"",width:""};const a=r=>{if(!r)return;const y=r.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!y)return;if(y[1])return y[1];const c=y[2];return/^\d+(\.\d+)?$/.test(c)?`${Number(c)*4}px`:c==="auto"||t.includes(c,"%")?c:"16px"},i=a(n),o=a(s);return{width:t.includes(i,"px")?i:"16px",height:t.includes(o,"px")?o:"16px"}},q=e=>{if(e.tagName==="svg")return{};const l={},n=Z[e.tagName]||{},s=e.attributes;return t.forEach(s,({key:a,value:i})=>{if(!t.includes(M,a))if(a==="bid"&&(l._bid=B(i)),n[a]){if(e.tagName==="img"&&a==="src"&&!i.startsWith("http")){const o=t.find(e.attributes,{key:"width"}),r=t.find(e.attributes,{key:"height"});o&&r?i=`https://picsum.photos/${o==null?void 0:o.value}x${r==null?void 0:r.value}`:i="https://picsum.photos/150x150"}t.set(l,n[a],B(i))}else t.includes(["style","class","srcset","bid"],a)||(t.has(l,"styles_attrs")||(l.styles_attrs={}),t.startsWith(a,"@")&&(a=a.replace("@","x-on:")),l.styles_attrs[`${a}`]=B(i))}),delete l.class,l},tt=(e,l="styles")=>{if(!e.attributes)return{[l]:`${m},`};const n=t.find(e.attributes,{key:"class"});if(n){const s=n.value;return{[l]:`${m},${s}`}}return{[l]:`${m},`}},et=e=>{const l=t.get(e,"attributes",[]),n=l.find(c=>c.key==="data-chai-richtext"||c.key==="chai-richtext"),s=l.find(c=>c.key==="data-chai-lightbox"||c.key==="chai-lightbox"),a=l.find(c=>c.key==="data-chai-dropdown"||c.key==="chai-dropdown"),i=l.find(c=>c.key==="data-chai-dropdown-button"||c.key==="chai-dropdown-button"),o=l.find(c=>c.key==="data-chai-dropdown-content"||c.key==="chai-dropdown-content"),r=l.find(c=>c.key==="class"),y=r&&r.value.split(/\s+/).includes("rte");if(a)return{_type:"Dropdown"};if(i)return{_type:"DropdownButton"};if(o)return{_type:"DropdownContent"};if(n||y)return{_type:"Paragraph"};if(s)return{_type:"LightBoxLink"};switch(e.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:e.tagName,_listType:e.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:e.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:e.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Box",_name:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:e.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:e.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const c=t.get(e,"children",[]).length>0?"Box":"EmptyBox";return{_type:c,tag:e.tagName,_name:c=="EmptyBox"||e.tagName==="div"?c:t.capitalize(e.tagName)}}}},w=(e,l=null)=>t.flatMapDeep(e,n=>{var D,I,C,$,N,L,W,A,P,R;if(n.type==="comment")return[];let s={_id:T.generateUUID()};if(l&&(s._parent=l.block._id),n.type==="text")return t.isEmpty(t.get(n,"content",""))?[]:l&&Q(l.node,l.block)?(t.set(l,"block.content",t.get(n,"content","")),[]):{...s,_type:"Text",content:t.get(n,"content","")};if(t.startsWith(n.tagName,"chai-")){const p=n.attributes,u=t.find(p,{key:"chai-type"}),d=(u==null?void 0:u.value)||t.startCase(n.tagName.replace("chai-","")).replace(/\s+/g,"");s._type=d,t.forEach(p,({key:h,value:j})=>{if(h==="about-this-component"||h==="chai-type"||h==="can-move"||h==="can-delete")return;if(h==="id"){s._id=j;return}const J=t.startsWith(h,"_")?h:t.camelCase(h);let f=B(j);typeof f=="string"&&t.startsWith(f,"#styles:")&&(f=f.replace("#styles:","#styles:,")),s[J]=f});const g=w(n.children,{block:s,node:n});return[s,...g]}const a=t.get(n,"attributes",[]),i=a.find(p=>p.key==="data-chai-richtext"||p.key==="chai-richtext"),o=a.find(p=>p.key==="class"),r=o&&o.value.split(/\s+/).includes("rte"),y=a.find(p=>p.key==="data-chai-lightbox"||p.key==="chai-lightbox"),c=a.find(p=>p.key==="data-chai-dropdown"||p.key==="chai-dropdown"),b=a.find(p=>p.key==="data-chai-dropdown-button"||p.key==="chai-dropdown-button"),_=a.find(p=>p.key==="data-chai-dropdown-content"||p.key==="chai-dropdown-content");if(s={...s,...et(n),...q(n),...tt(n)},n.attributes){const p=n.attributes.find(u=>t.includes(M,u.key));p&&(s._name=p.value)}if(i||r)return s.content=k.stringify(n.children),t.has(s,"styles_attrs.data-chai-richtext")&&delete s.styles_attrs["data-chai-richtext"],t.has(s,"styles_attrs.chai-richtext")&&delete s.styles_attrs["chai-richtext"],[s];if(y){const p=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];s={...s,href:((D=a.find(u=>u.key==="href"))==null?void 0:D.value)||"",hrefType:((I=a.find(u=>u.key==="data-vbtype"))==null?void 0:I.value)||"video",autoplay:((C=a.find(u=>u.key==="data-autoplay"))==null?void 0:C.value)==="true"?"true":"false",maxWidth:((N=($=a.find(u=>u.key==="data-maxwidth"))==null?void 0:$.value)==null?void 0:N.replace("px",""))||"",backdropColor:((L=a.find(u=>u.key==="data-overlay"))==null?void 0:L.value)||"",galleryName:((W=a.find(u=>u.key==="data-gall"))==null?void 0:W.value)||""},t.forEach(p,u=>{t.has(s,`styles_attrs.${u}`)&&delete s.styles_attrs[u]})}if(c&&(delete s.styles_attrs,s.showDropdown=!1),_&&delete s.styles_attrs,b){delete s.styles_attrs;const p=t.filter(n.children||[],d=>(d==null?void 0:d.tagName)!=="span");s.content=E(p);const u=t.find(n.children||[],d=>(d==null?void 0:d.tagName)==="span"&&t.some(d.children||[],g=>(g==null?void 0:g.tagName)==="svg"));if(u){const d=t.find(u.children||[],g=>(g==null?void 0:g.tagName)==="svg");if(d){s.icon=k.stringify([d]);const{height:g,width:h}=st(d,"16px","16px");s.iconHeight=g,s.iconWidth=h}}return[s]}if(s._type==="Input"){const p=s.inputType||"text";p==="checkbox"?t.set(s,"_type","Checkbox"):p==="radio"&&t.set(s,"_type","Radio")}else if(n.tagName==="video"||n.tagName==="iframe"){const p=k.stringify([n]);return X(p)&&(t.set(s,"_type","Video"),t.set(s,"url",G(p)),t.set(s,"styles",`${m},`),t.set(s,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),s.content=p,[s]}else if(n.tagName==="svg"){const p=t.get(t.find(n.attributes,{key:"class"}),"value",""),{height:u,width:d}=O(p);if(u&&d)s.styles=`${m}, ${T.cn(`w-${d} h-${u}`,p)}`.trim(),s.height=u==null?void 0:u.replace("px",""),s.width=d==null?void 0:d.replace("px","");else{const g=(A=t.find(n.attributes,{key:"height"}))==null?void 0:A.value,h=(P=t.find(n.attributes,{key:"width"}))==null?void 0:P.value;g&&h?(s.styles=`${m}, ${T.cn(`w-[${h}px] h-[${g}px]`,p)}`.trim(),s.height=g,s.width=h):s.styles=`${m}, ${T.cn("w-full h-full",p)}`.trim()}return n.attributes=t.filter(n.attributes,g=>!t.includes(["style","width","height","class"],g.key)),s.icon=k.stringify([n]),[s]}else if(n.tagName=="option"&&l&&((R=l.block)==null?void 0:R._type)==="Select")return l.block.options.push({label:E(n.children),...q(n)}),[];const x=w(n.children,{block:s,node:n});return[s,...x]}),st=(e,l,n)=>{var y,c;const s=t.get(e,"attributes",[]),{height:a,width:i}=O(t.get(t.find(s,{key:"class"}),"value",""));if(a&&i)return{height:`[${a}px]`,width:`[${i}px]`};const o=(y=t.find(s,{key:"height"}))==null?void 0:y.value,r=(c=t.find(s,{key:"width"}))==null?void 0:c.value;return{height:o?`[${o}px]`:n,width:r?`[${r}px]`:l}},nt=e=>{e=e.replace(/(\w+)=\\?"(.*?)\\?"/g,(s,a,i)=>{let o=i.replace(/\\"/g,'"');return o=o.replace(/{([^}]+)}/g,r=>r.replace(/"/g,'\\"')),`${a}="${o.replace(/\\"/g,'"')}"`}),e=e.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),e=e.replace(/\$name="[^"]*"/g,"");const l=e.match(/<body[^>]*>[\s\S]*?<\/body>/);return(l&&l.length>0?l[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):e).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},at=(e,l)=>t.find(e,{_id:l}),lt=(e,l)=>t.isEmpty(l)?e.map(n=>(t.unset(n,"_bid"),n)):t.map(e,n=>{const s=t.isEmpty(n._bid)?void 0:at(l,n._bid);if(s){s._type==="Icon"&&t.get(n,"icon","").match(/chai-default-svg/)&&delete n.icon;const a={...s,...n};return t.unset(a,"_bid"),a}return t.unset(n,"_bid"),n}),ot=e=>{const l=k.parse(nt(e));return t.isEmpty(e)?[]:t.flatten(w(l))};function rt(e,l,n){const s=t.get(n,"i18nProps",[]);if(t.isEmpty(l)||t.isEmpty(s))return e;const a=t.cloneDeep(e);return t.forEach(t.keys(a),i=>{if(t.includes(s,i)&&!t.isEmpty(l)){const o=t.get(a,i),r=t.get(a,`${i}-${l}`,"");t.isString(o)?a[i]=t.isString(r)&&!t.isEmpty(r.trim())&&r.trimStart()||o:a[i]=t.isEmpty(r)?o:r}}),a}const F=(e,l)=>{const{baseClasses:n,classes:s}=H(e),i=s.split(" ").filter(r=>r.startsWith(v)).map(r=>{var y;return(y=l[r])==null?void 0:y.value}),o=s.split(" ").filter(r=>!r.startsWith(v)).join(" ");return U.twMerge.apply(null,[n,...i,o])};function ct(e,l){return t.get(e,`${l}_attrs`,{})}function pt(e,l=!0,n={}){const s={};return Object.keys(e).forEach(a=>{if(t.isString(e[a])&&e[a].startsWith(m)){const i=F(e[a],n),o=ct(e,a);s[a]={...!t.isEmpty(i)&&{className:i},...o,...l?{"data-style-prop":a,"data-block-parent":e._id,"data-style-id":`${a}-${e._id}`}:{}}}}),s}const ut=t.memoize(e=>{const l=z.getRegisteredChaiBlock(e),n=t.get(l,"schema.properties",{});return Object.fromEntries(Object.entries(n).filter(([,s])=>t.get(s,"runtime",!1)))}),dt=(e,l)=>{if(!t.isArray(e))return e;let n=e,s;return typeof l.limit=="number"&&l.limit>0&&(s=l.limit),s!==void 0&&(n=n.slice(0,s)),n},yt=(e,l)=>{const n=t.cloneDeep(e);return t.forEach(t.keys(n),s=>{if(t.isString(n[s])&&!t.startsWith(s,"_")){let a=n[s];s==="repeaterItems"&&(n.repeaterItemsBinding=a);const i=/\{\{(.*?)\}\}/g,o=a.match(i);o&&o.forEach(r=>{let y=r.slice(2,-2);const c=t.get(l,y,r);a=t.isArray(c)?c:a.replace(r,c)}),n[s]=a}}),n},gt=(e,l)=>e.map(n=>{const s=t.keys(n).filter(a=>t.isString(n[a])&&n[a].startsWith(m));return t.each(s,a=>{n[a]=`${m},${F(n[a],l)}`}),n}),ht=e=>{const l=t.last(e);return e.map(n=>{const s=Object.keys(n);for(let a=0;a<s.length;a++)if(t.isString(n[s[a]])&&t.startsWith(s[a],"content")){const i=n===l?"":" ";n[s[a]]=`${n[s[a]].trim()}${i}`}return n})},S=(e,l,{index:n,key:s},a)=>{if(t.isString(e)){let i=e;const o=/\{\{(.*?)\}\}/g,r=e.match(o);if(r){const y=a==="image"||a==="mobileImage";r.forEach(c=>{let b=c.slice(2,-2).trim(),_=s.slice(2,-2).trim();n!==-1&&t.startsWith(b,"$index.")?b=`${_}.${n}.${b.slice(7)}`:n!==-1&&t.startsWith(b,"$index")&&(b=`${_}.${n}`);const x=t.get(l,b);x===void 0?i=i.replace(c,""):y&&!t.isArray(x)?i=x:i=t.isArray(x)?x:i.replace(c,x)})}return i}if(t.isArray(e))return e.map(i=>S(i,l,{index:n,key:s},a));if(e&&typeof e=="object"){const i={};return t.forEach(t.keys(e),o=>{!t.startsWith(o,"_")&&o!=="$repeaterItemsKey"?i[o]=S(e[o],l,{index:n,key:s},o):i[o]=e[o]}),i}return e},mt=(e,l,{index:n,key:s})=>{let a=t.cloneDeep(e);return a.repeaterItems&&(a.$repeaterItemsKey=a.repeaterItems,t.startsWith(a.repeaterItems,`{{${V}`)&&(a.$repeaterItemsKey=a.repeaterItems=`${a.repeaterItems.replace("}}",`/${a._id}}}`)}`),!t.isEmpty(a.repeaterItems)&&a.pagination&&(a.repeaterTotalItems=`${a.repeaterItems.replace("}}",`/${a._id}/totalItems}}`)}`)),S(a,l,{index:n,key:s})};exports.COLLECTION_PREFIX=V;exports.DESIGN_TOKEN_PREFIX=v;exports.REPEATER_PREFIX=K;exports.ROOT_TEMP_KEY=Y;exports.STYLES_KEY=m;exports.adjustSpacingInContentBlocks=ht;exports.applyBindingToBlockProps=mt;exports.applyChaiDataBinding=yt;exports.applyDesignTokens=gt;exports.applyLanguage=rt;exports.applyLimit=dt;exports.getBlockRuntimeProps=ut;exports.getBlockTagAttributes=pt;exports.getBlocksFromHTML=ot;exports.getSplitChaiClasses=H;exports.mergeBlocksWithExisting=lt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-DIVARO6Y.cjs");require("clsx");require("lodash-es");require("nanoid");require("tailwind-merge");require("tree-model");const c=require("react");require("jotai");require("@chaibuilder/runtime");require("sonner");const q=require("react-i18next"),r=require("./tooltip-Ba1-8jmj.cjs"),g=require("@react-hookz/web"),m=n=>{const s=document.createElement("div");return s.innerHTML=n,s.innerHTML};function j(){const{t:n}=q.useTranslation(),[s,h]=c.useState(!1),[a,p]=c.useState(""),[t,d]=i.useCodeEditor(),[u]=i.useSelectedBlockIds(),b=i.useUpdateBlocksProps(),f=i.useUpdateBlocksPropsRealtime(),C=g.useThrottledCallback(o=>{const l=m(o);f([t.blockId],{[t.blockProp]:l})},[],300),x=c.useCallback(()=>{if(s){const o=m(a);b([t.blockId],{[t.blockProp]:o})}},[s,a]);c.useEffect(()=>{u.includes(t==null?void 0:t.blockId)||(x(),d(null))},[u]);const k=()=>{x(),d(null)};return e.jsx(r.Dialog,{open:!0,onOpenChange:k,children:e.jsxs(r.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[e.jsx(r.DialogHeader,{className:"shrink-0 border-b border-gray-700 pb-3",children:e.jsx(r.DialogTitle,{className:"flex items-center justify-between text-black",children:e.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[e.jsx("span",{children:n("HTML Code Editor |")}),e.jsx("span",{className:"text-xs text-gray-400",children:n("Scripts will be only executed in preview and live mode.")})]})})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(r.Textarea,{className:"h-full w-full resize-none font-mono text-xs",value:a||t.initialCode,onChange:o=>{const l=o.target.value;h(!0),p(l),C(l)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=j;
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DIVARO6Y.cjs"),s=require("./common-functions-B3a4xKt_.cjs"),a=require("./apply-binding-DLHh7HoS.cjs"),l=require("react-i18next"),i=require("i18next");exports.ChaiAddBlocksDialog=e.AddBlocksDialog;exports.ChaiAddBlocksPanel=e.AddBlocksPanel;exports.ChaiAskAiUserPrompt=e.AIUserPrompt;exports.ChaiBlockAttributesEditor=e.BlockAttributesEditor;exports.ChaiBlockPropsEditor=e.BlockSettings;exports.ChaiBlockStyleEditor=e.BlockStyling;exports.ChaiBuilderCanvas=e.CanvasArea;exports.ChaiBuilderEditor=e.ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=e.DarkMode;exports.ChaiDefaultBlocks=e.DefaultChaiBlocks;exports.ChaiDraggableBlock=e.ChaiDraggableBlock;exports.ChaiExportCodeModal=e.ExportCodeModal;exports.ChaiImportHTML=e.ImportHTML;exports.ChaiOutline=e.ListTree;exports.ChaiScreenSizes=e.Breakpoints;exports.ChaiThemeConfigPanel=e.ThemeConfigPanel;exports.ChaiUILibrariesPanel=e.UILibrariesPanel;exports.ChaiUndoRedo=e.UndoRedo;exports.IfChaiFeatureFlag=e.IfChaiFeatureFlag;exports.PERMISSIONS=e.PERMISSIONS;exports.getClassValueAndUnit=e.getClassValueAndUnit;exports.registerBlockSettingField=e.registerBlockSettingField;exports.registerBlockSettingTemplate=e.registerBlockSettingTemplate;exports.registerBlockSettingWidget=e.registerBlockSettingWidget;exports.registerChaiAddBlockTab=e.registerChaiAddBlockTab;exports.registerChaiFeatureFlag=e.registerChaiFeatureFlag;exports.registerChaiFeatureFlags=e.registerChaiFeatureFlags;exports.registerChaiLibrary=e.registerChaiLibrary;exports.registerChaiMediaManager=e.registerChaiMediaManager;exports.registerChaiPreImportHTMLHook=e.registerChaiPreImportHTMLHook;exports.registerChaiSaveToLibrary=e.registerChaiSaveToLibrary;exports.registerChaiSidebarPanel=e.registerChaiSidebarPanel;exports.registerChaiTopBar=e.registerChaiTopBar;exports.useAddBlock=e.useAddBlock;exports.useAddClassesToBlocks=e.useAddClassesToBlocks;exports.useAskAi=e.useAskAi;exports.useBlockHighlight=e.useBlockHighlight;exports.useBlocksHtmlForAi=e.useBlocksHtmlForAi;exports.useBlocksStore=e.useBlocksStore;exports.useBlocksStoreUndoableActions=e.useBlocksStoreUndoableActions;exports.useBrandingOptions=e.useBrandingOptions;exports.useBuilderProp=e.useBuilderProp;exports.useBuilderReset=e.useBuilderReset;exports.useCanvasDisplayWidth=e.useCanvasDisplayWidth;exports.useCanvasWidth=e.useCanvasWidth;exports.useCanvasZoom=e.useCanvasZoom;exports.useChaiFeatureFlag=e.useChaiFeatureFlag;exports.useChaiFeatureFlags=e.useChaiFeatureFlags;exports.useCodeEditor=e.useCodeEditor;exports.useCopyBlockIds=e.useCopyBlocks;exports.useCopyToClipboard=e.useCopyToClipboard;exports.useCurrentPage=e.useCurrentPage;exports.useCutBlockIds=e.useCutBlockIds;exports.useDarkMode=e.useDarkMode;exports.useDuplicateBlocks=e.useDuplicateBlocks;exports.useHighlightBlockId=e.useHighlightBlockId;exports.useHtmlToBlocks=e.useHtmlToBlocks;exports.useI18nBlocks=e.useI18nBlocks;exports.useInlineEditing=e.useInlineEditing;exports.useIsPageLoaded=e.useIsPageLoaded;exports.useLanguages=e.useLanguages;exports.useLibraryBlocks=e.useLibraryBlocks;exports.useMediaManagerComponent=e.useMediaManagerComponent;exports.usePartailBlocksStore=e.usePartialBlocksStore;exports.usePartialBlocksList=e.usePartialBlocksList;exports.usePasteBlocks=e.usePasteBlocks;exports.usePermissions=e.usePermissions;exports.usePreviewMode=e.usePreviewMode;exports.usePubSub=e.usePubSub;exports.useRemoveAllClassesForBlock=e.useRemoveAllClassesForBlock;exports.useRemoveBlocks=e.useRemoveBlocks;exports.useRemoveClassesFromBlocks=e.useRemoveClassesFromBlocks;exports.useReplaceBlock=e.useReplaceBlock;exports.useResetBlockStyles=e.useResetBlockStyles;exports.useRightPanel=e.useRightPanel;exports.useSavePage=e.useSavePage;exports.useScreenSizeWidth=e.useScreenSizeWidth;exports.useSelectedBlock=e.useSelectedBlock;exports.useSelectedBlockAllClasses=e.useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=e.useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=e.useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=e.useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=e.useSelectedBreakpoints;exports.useSelectedLibrary=e.useSelectedLibrary;exports.useSelectedStylingBlocks=e.useSelectedStylingBlocks;exports.useSidebarActivePanel=e.useSidebarActivePanel;exports.useStreamMultipleBlocksProps=e.useStreamMultipleBlocksProps;exports.useStylingBreakpoint=e.useStylingBreakpoint;exports.useStylingState=e.useStylingState;exports.useTheme=e.useTheme;exports.useThemeOptions=e.useThemeOptions;exports.useToggleChaiFeatureFlag=e.useToggleChaiFeatureFlag;exports.useUndoManager=e.useUndoManager;exports.useUpdateBlocksProps=e.useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=e.useUpdateBlocksPropsRealtime;exports.useWrapperBlock=e.useWrapperBlock;exports.generateBlockId=s.generateUUID;exports.mergeClasses=s.cn;exports.convertHTMLToChaiBlocks=a.getBlocksFromHTML;exports.getBlocksFromHTML=a.getBlocksFromHTML;Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:()=>l.useTranslation});exports.i18n=i;
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as e, A as o, f as i, k as l, B as r, e as t, C as u, i as c, D as d, l as C, m as B, E as k, I as g, L as n, g as h, T as p, U as S, h as m, z as P, P as F, n as A, o as T, p as b, q as M, r as y, F as I, G as v, t as L, v as f, s as H, w as R, x as D, y as E, O as U, Q as x, R as W, S as O, V as w, W as z, aC as j, X as q, Y as G, Z as V, aE as Z, aD as J, _ as K, H as N, J as Q, u as X, $ as Y, a0 as _, a1 as $, a2 as aa, a3 as sa, a4 as ea, a5 as oa, a6 as ia, a7 as la, a8 as ra, a9 as ta, aa as ua, ab as ca, M as da, ac as Ca, ad as Ba, ae as ka, af as ga, ag as na, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, ao as Ta, aF as ba, ap as Ma, aq as ya, ar as Ia, a as va, as as La, at as fa, aG as Ha, au as Ra, aH as Da, av as Ea, aw as Ua, ax as xa, ay as Wa, az as Oa, K as wa, aA as za, b as ja, c as qa, aB as Ga } from "./index-
|
|
1
|
+
import { j as e, A as o, f as i, k as l, B as r, e as t, C as u, i as c, D as d, l as C, m as B, E as k, I as g, L as n, g as h, T as p, U as S, h as m, z as P, P as F, n as A, o as T, p as b, q as M, r as y, F as I, G as v, t as L, v as f, s as H, w as R, x as D, y as E, O as U, Q as x, R as W, S as O, V as w, W as z, aC as j, X as q, Y as G, Z as V, aE as Z, aD as J, _ as K, H as N, J as Q, u as X, $ as Y, a0 as _, a1 as $, a2 as aa, a3 as sa, a4 as ea, a5 as oa, a6 as ia, a7 as la, a8 as ra, a9 as ta, aa as ua, ab as ca, M as da, ac as Ca, ad as Ba, ae as ka, af as ga, ag as na, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, ao as Ta, aF as ba, ap as Ma, aq as ya, ar as Ia, a as va, as as La, at as fa, aG as Ha, au as Ra, aH as Da, av as Ea, aw as Ua, ax as xa, ay as Wa, az as Oa, K as wa, aA as za, b as ja, c as qa, aB as Ga } from "./index-CAiYwkFz.js";
|
|
2
2
|
import { g as Za, c as Ja } from "./common-functions-D2lMFR6K.js";
|
|
3
|
-
import { h as Na, h as Qa } from "./apply-binding-
|
|
3
|
+
import { h as Na, h as Qa } from "./apply-binding-CSWwWMjY.js";
|
|
4
4
|
import { useTranslation as Ya } from "react-i18next";
|
|
5
5
|
import { default as $a } from "i18next";
|
|
6
6
|
export {
|