@chaibuilder/sdk 3.1.26 → 3.1.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{IconPicker-CluS-5Mv.js → IconPicker-6JSublJp.js} +1 -1
- package/dist/{IconPicker-BWE43eMO.cjs → IconPicker-DpQQDK_Q.cjs} +1 -1
- package/dist/{apply-binding-COFSiTeM.js → apply-binding-BwPhgnhk.js} +326 -198
- package/dist/apply-binding-Dblf6wMG.cjs +1 -0
- package/dist/{code-display-BOOy3Lpy.js → code-display-DuH-UOhl.js} +1 -1
- package/dist/{code-display-B1O2gN5f.cjs → code-display-Dw1tAwiJ.cjs} +1 -1
- package/dist/code-editor-DosOD_MJ.cjs +1 -0
- package/dist/{code-editor-TDs5CPAW.js → code-editor-W1Kvc_mp.js} +6 -5
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +13 -2
- package/dist/core.js +3 -3
- package/dist/{css-import-modal-sHoiyimv.js → css-import-modal-CFB2YjDT.js} +1 -1
- package/dist/{css-import-modal-CrlmcFy4.cjs → css-import-modal-bGWZSlqv.cjs} +1 -1
- package/dist/{index-DFvi9z_N.js → index-hrVqQhCa.js} +2853 -2530
- package/dist/index-tOL3lzGY.cjs +154 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +9 -0
- package/dist/render.js +69 -66
- package/dist/{rte-widget-modal-DX07GFaV.cjs → rte-widget-modal-BFwz3uU8.cjs} +1 -1
- package/dist/{rte-widget-modal-3KfJEwf3.js → rte-widget-modal-DioHGWr7.js} +2 -2
- package/dist/{tooltip-CzZ7Fvt7.cjs → tooltip-Ba1-8jmj.cjs} +1 -1
- package/dist/{tooltip-Bz2MxMHf.js → tooltip-DUosa-uC.js} +83 -83
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +14 -14
- package/dist/ui.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -1
- package/package.json +3 -2
- package/dist/apply-binding-Dvnd_Vhq.cjs +0 -1
- package/dist/code-editor-B7JGUrWa.cjs +0 -1
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/index-C4b6LcwL.cjs +0 -154
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { isEmpty as
|
|
3
|
-
import { parse as
|
|
4
|
-
import { getRegisteredChaiBlock as
|
|
5
|
-
import { twMerge as
|
|
6
|
-
const
|
|
7
|
-
if (e = e.replace(
|
|
1
|
+
import { g as rt, c as H } from "./common-functions-D2lMFR6K.js";
|
|
2
|
+
import { isEmpty as x, flatten as ct, flatMapDeep as pt, get as d, set as E, startsWith as k, find as m, startCase as ut, forEach as S, camelCase as dt, includes as w, has as A, filter as Q, some as ht, unset as P, map as et, compact as yt, trim as mt, capitalize as gt, memoize as bt, cloneDeep as M, keys as R, isString as $, isArray as I, each as xt, last as ft } from "lodash-es";
|
|
3
|
+
import { parse as _t, stringify as D } from "himalaya";
|
|
4
|
+
import { getRegisteredChaiBlock as kt } from "@chaibuilder/runtime";
|
|
5
|
+
import { twMerge as vt } from "tailwind-merge";
|
|
6
|
+
const f = "#styles:", jt = "__ADD_BLOCK_INTERNAL_ROOT", qt = "@", wt = "#", st = (e) => {
|
|
7
|
+
if (e = e.replace(f, ""), !e) return { baseClasses: "", classes: "" };
|
|
8
8
|
const a = e.split(/,(?![^\[]*\])/);
|
|
9
9
|
if (a.length === 1)
|
|
10
10
|
return { baseClasses: "", classes: a[0].trim() };
|
|
@@ -41,19 +41,19 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
for (let a in e) {
|
|
44
|
-
const t = st(`${
|
|
44
|
+
const t = st(`${f}${a}`);
|
|
45
45
|
expect(t).toEqual(e[a]);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
-
const
|
|
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
|
-
},
|
|
53
|
-
if (
|
|
54
|
-
const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t),
|
|
55
|
-
return
|
|
56
|
-
},
|
|
52
|
+
}, Tt = (e) => {
|
|
53
|
+
if (x(e)) return e;
|
|
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
|
+
return o && (l.test(o) || i.test(o)) ? o : e;
|
|
56
|
+
}, nt = ["chai-name", "data-chai-name"], Et = {
|
|
57
57
|
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
58
58
|
video: {
|
|
59
59
|
src: "url",
|
|
@@ -89,58 +89,58 @@ const kt = (e) => {
|
|
|
89
89
|
form: {
|
|
90
90
|
action: "action"
|
|
91
91
|
}
|
|
92
|
-
},
|
|
92
|
+
}, $t = (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", "") :
|
|
96
|
-
const a =
|
|
95
|
+
), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : x(a.children) ? "" : j(a.children)).join(""), W = (e) => e === null ? "" : e, at = (e) => {
|
|
96
|
+
const a = yt(et(e.split(/\s+/), mt)), t = m(a, (i) => /^w-/.test(i)), s = m(a, (i) => /^h-/.test(i));
|
|
97
97
|
if (!s || !t) return { height: "", width: "" };
|
|
98
|
-
const n = (
|
|
99
|
-
if (!
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
return /^\d+(\.\d+)?$/.test(
|
|
105
|
-
},
|
|
98
|
+
const n = (i) => {
|
|
99
|
+
if (!i) return;
|
|
100
|
+
const h = i.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
|
|
101
|
+
if (!h) return;
|
|
102
|
+
if (h[1]) return h[1];
|
|
103
|
+
const r = h[2];
|
|
104
|
+
return /^\d+(\.\d+)?$/.test(r) ? `${Number(r) * 4}px` : r === "auto" || w(r, "%") ? r : "16px";
|
|
105
|
+
}, o = n(t), l = n(s);
|
|
106
106
|
return {
|
|
107
|
-
width:
|
|
108
|
-
height:
|
|
107
|
+
width: w(o, "px") ? o : "16px",
|
|
108
|
+
height: w(l, "px") ? l : "16px"
|
|
109
109
|
};
|
|
110
|
-
},
|
|
110
|
+
}, tt = (e) => {
|
|
111
111
|
if (e.tagName === "svg") return {};
|
|
112
|
-
const a = {}, t =
|
|
113
|
-
return
|
|
114
|
-
if (!
|
|
115
|
-
if (n === "bid" && (a._bid =
|
|
116
|
-
if (e.tagName === "img" && n === "src" && !
|
|
117
|
-
const
|
|
118
|
-
|
|
112
|
+
const a = {}, t = Et[e.tagName] || {}, s = e.attributes;
|
|
113
|
+
return S(s, ({ key: n, value: o }) => {
|
|
114
|
+
if (!w(nt, n))
|
|
115
|
+
if (n === "bid" && (a._bid = W(o)), t[n]) {
|
|
116
|
+
if (e.tagName === "img" && n === "src" && !o.startsWith("http")) {
|
|
117
|
+
const l = m(e.attributes, { key: "width" }), i = m(e.attributes, { key: "height" });
|
|
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
|
|
120
|
+
E(a, t[n], W(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}`] = W(o));
|
|
122
122
|
}), delete a.class, a;
|
|
123
|
-
},
|
|
124
|
-
if (!e.attributes) return { [a]: `${
|
|
123
|
+
}, St = (e, a = "styles") => {
|
|
124
|
+
if (!e.attributes) return { [a]: `${f},` };
|
|
125
125
|
const t = m(e.attributes, { key: "class" });
|
|
126
126
|
if (t) {
|
|
127
127
|
const s = t.value;
|
|
128
|
-
return { [a]: `${
|
|
128
|
+
return { [a]: `${f},${s}` };
|
|
129
129
|
}
|
|
130
|
-
return { [a]: `${
|
|
131
|
-
},
|
|
132
|
-
const a = d(e, "attributes", []), t = a.find((
|
|
133
|
-
(
|
|
134
|
-
),
|
|
135
|
-
(
|
|
136
|
-
),
|
|
130
|
+
return { [a]: `${f},` };
|
|
131
|
+
}, Nt = (e) => {
|
|
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
|
+
(r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
|
|
134
|
+
), l = a.find(
|
|
135
|
+
(r) => r.key === "data-chai-dropdown-content" || r.key === "chai-dropdown-content"
|
|
136
|
+
), i = a.find((r) => r.key === "class"), h = i && i.value.split(/\s+/).includes("rte");
|
|
137
137
|
if (n)
|
|
138
138
|
return { _type: "Dropdown" };
|
|
139
|
-
if (r)
|
|
140
|
-
return { _type: "DropdownButton" };
|
|
141
139
|
if (o)
|
|
140
|
+
return { _type: "DropdownButton" };
|
|
141
|
+
if (l)
|
|
142
142
|
return { _type: "DropdownContent" };
|
|
143
|
-
if (t ||
|
|
143
|
+
if (t || h)
|
|
144
144
|
return { _type: "Paragraph" };
|
|
145
145
|
if (s)
|
|
146
146
|
return { _type: "LightBoxLink" };
|
|
@@ -222,58 +222,58 @@ const kt = (e) => {
|
|
|
222
222
|
case "tfoot":
|
|
223
223
|
return { _type: "TableFooter" };
|
|
224
224
|
default: {
|
|
225
|
-
const
|
|
225
|
+
const r = d(e, "children", []).length > 0 ? "Box" : "EmptyBox";
|
|
226
226
|
return {
|
|
227
|
-
_type:
|
|
227
|
+
_type: r,
|
|
228
228
|
tag: e.tagName,
|
|
229
|
-
_name:
|
|
229
|
+
_name: r == "EmptyBox" || e.tagName === "div" ? r : gt(e.tagName)
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
}, q = (e, a = null) =>
|
|
234
|
-
var
|
|
233
|
+
}, q = (e, a = null) => pt(e, (t) => {
|
|
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: rt() };
|
|
237
237
|
if (a && (s._parent = a.block._id), t.type === "text")
|
|
238
|
-
return
|
|
239
|
-
if (
|
|
240
|
-
const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) ||
|
|
241
|
-
s._type = u,
|
|
242
|
-
if (
|
|
243
|
-
if (
|
|
244
|
-
s._id =
|
|
238
|
+
return x(d(t, "content", "")) ? [] : a && $t(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
|
|
239
|
+
if (k(t.tagName, "chai-")) {
|
|
240
|
+
const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || ut(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
241
|
+
s._type = u, S(c, ({ key: g, value: G }) => {
|
|
242
|
+
if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
|
|
243
|
+
if (g === "id") {
|
|
244
|
+
s._id = G;
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
|
-
const
|
|
248
|
-
let
|
|
249
|
-
typeof
|
|
247
|
+
const lt = k(g, "_") ? g : dt(g);
|
|
248
|
+
let N = W(G);
|
|
249
|
+
typeof N == "string" && k(N, "#styles:") && (N = N.replace("#styles:", "#styles:,")), s[lt] = N;
|
|
250
250
|
});
|
|
251
|
-
const
|
|
252
|
-
return [s, ...
|
|
251
|
+
const y = q(t.children, { block: s, node: t });
|
|
252
|
+
return [s, ...y];
|
|
253
253
|
}
|
|
254
|
-
const n = d(t, "attributes", []),
|
|
254
|
+
const n = d(t, "attributes", []), o = n.find(
|
|
255
255
|
(c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"
|
|
256
|
-
),
|
|
256
|
+
), l = n.find((c) => c.key === "class"), i = l && l.value.split(/\s+/).includes("rte"), h = n.find(
|
|
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
|
+
), B = 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
|
+
...Nt(t),
|
|
268
|
+
...tt(t),
|
|
269
|
+
...St(t)
|
|
270
270
|
}, t.attributes) {
|
|
271
|
-
const c = t.attributes.find((p) =>
|
|
271
|
+
const c = t.attributes.find((p) => w(nt, p.key));
|
|
272
272
|
c && (s._name = c.value);
|
|
273
273
|
}
|
|
274
|
-
if (
|
|
275
|
-
return s.content =
|
|
276
|
-
if (
|
|
274
|
+
if (o || i)
|
|
275
|
+
return s.content = D(t.children), 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];
|
|
276
|
+
if (h) {
|
|
277
277
|
const c = [
|
|
278
278
|
"data-chai-lightbox",
|
|
279
279
|
"chai-lightbox",
|
|
@@ -286,30 +286,30 @@ const kt = (e) => {
|
|
|
286
286
|
];
|
|
287
287
|
s = {
|
|
288
288
|
...s,
|
|
289
|
-
href: ((
|
|
290
|
-
hrefType: ((
|
|
291
|
-
autoplay: ((
|
|
292
|
-
maxWidth: ((
|
|
293
|
-
backdropColor: ((
|
|
294
|
-
galleryName: ((
|
|
295
|
-
},
|
|
289
|
+
href: ((O = n.find((p) => p.key === "href")) == null ? void 0 : O.value) || "",
|
|
290
|
+
hrefType: ((V = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : V.value) || "video",
|
|
291
|
+
autoplay: ((J = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : J.value) === "true" ? "true" : "false",
|
|
292
|
+
maxWidth: ((F = (z = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : F.replace("px", "")) || "",
|
|
293
|
+
backdropColor: ((U = n.find((p) => p.key === "data-overlay")) == null ? void 0 : U.value) || "",
|
|
294
|
+
galleryName: ((Y = n.find((p) => p.key === "data-gall")) == null ? void 0 : Y.value) || ""
|
|
295
|
+
}, S(c, (p) => {
|
|
296
296
|
A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
-
if (
|
|
299
|
+
if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs, B) {
|
|
300
300
|
delete s.styles_attrs;
|
|
301
|
-
const c =
|
|
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" && ht(u.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg")
|
|
306
306
|
);
|
|
307
307
|
if (p) {
|
|
308
|
-
const u = m(p.children || [], (
|
|
308
|
+
const u = m(p.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg");
|
|
309
309
|
if (u) {
|
|
310
|
-
s.icon =
|
|
311
|
-
const { height:
|
|
312
|
-
s.iconHeight =
|
|
310
|
+
s.icon = D([u]);
|
|
311
|
+
const { height: y, width: g } = It(u, "16px", "16px");
|
|
312
|
+
s.iconHeight = y, s.iconWidth = g;
|
|
313
313
|
}
|
|
314
314
|
}
|
|
315
315
|
return [s];
|
|
@@ -318,122 +318,249 @@ const kt = (e) => {
|
|
|
318
318
|
const c = s.inputType || "text";
|
|
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
|
-
const c =
|
|
322
|
-
return
|
|
321
|
+
const c = D([t]);
|
|
322
|
+
return Bt(c) && (E(s, "_type", "Video"), E(s, "url", Tt(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 } = at(c);
|
|
325
325
|
if (p && u)
|
|
326
|
-
s.styles = `${
|
|
326
|
+
s.styles = `${f}, ${H(`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
|
-
const
|
|
329
|
-
|
|
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}, ${H(`w-[${g}px] h-[${y}px]`, c)}`.trim(), s.height = y, s.width = g) : s.styles = `${f}, ${H("w-full h-full", c)}`.trim();
|
|
330
330
|
}
|
|
331
|
-
return t.attributes =
|
|
332
|
-
} else if (t.tagName == "option" && a && ((
|
|
331
|
+
return t.attributes = Q(t.attributes, (y) => !w(["style", "width", "height", "class"], y.key)), s.icon = D([t]), [s];
|
|
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
|
+
...tt(t)
|
|
336
336
|
}), [];
|
|
337
337
|
const T = q(t.children, { block: s, node: t });
|
|
338
338
|
return [s, ...T];
|
|
339
|
-
}),
|
|
340
|
-
var
|
|
341
|
-
const s = d(e, "attributes", []), { height: n, width:
|
|
339
|
+
}), It = (e, a, t) => {
|
|
340
|
+
var h, r;
|
|
341
|
+
const s = d(e, "attributes", []), { height: n, width: o } = at(
|
|
342
342
|
d(m(s, { key: "class" }), "value", "")
|
|
343
343
|
);
|
|
344
|
-
if (n &&
|
|
344
|
+
if (n && o)
|
|
345
345
|
return {
|
|
346
346
|
height: `[${n}px]`,
|
|
347
|
-
width: `[${
|
|
347
|
+
width: `[${o}px]`
|
|
348
348
|
};
|
|
349
|
-
const
|
|
349
|
+
const l = (h = m(s, { key: "height" })) == null ? void 0 : h.value, i = (r = m(s, { key: "width" })) == null ? void 0 : r.value;
|
|
350
350
|
return {
|
|
351
|
-
height:
|
|
352
|
-
width:
|
|
351
|
+
height: l ? `[${l}px]` : t,
|
|
352
|
+
width: i ? `[${i}px]` : a
|
|
353
353
|
};
|
|
354
|
-
},
|
|
355
|
-
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n,
|
|
356
|
-
let
|
|
357
|
-
return
|
|
354
|
+
}, Ct = (e) => {
|
|
355
|
+
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, o) => {
|
|
356
|
+
let l = o.replace(/\\"/g, '"');
|
|
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 =
|
|
361
|
+
}, Dt = (e, a) => m(e, { _id: a }), Mt = (e, a) => x(a) ? e.map((t) => (P(t, "_bid"), t)) : et(e, (t) => {
|
|
362
|
+
const s = x(t._bid) ? void 0 : Dt(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 P(n, "_bid"), n;
|
|
367
367
|
}
|
|
368
|
-
return
|
|
369
|
-
}),
|
|
370
|
-
const a =
|
|
371
|
-
return
|
|
368
|
+
return P(t, "_bid"), t;
|
|
369
|
+
}), Ot = (e) => {
|
|
370
|
+
const a = _t(Ct(e));
|
|
371
|
+
return x(e) ? [] : ct(q(a));
|
|
372
372
|
};
|
|
373
|
-
function
|
|
373
|
+
function Vt(e, a, t) {
|
|
374
374
|
const s = d(t, "i18nProps", []);
|
|
375
|
-
if (
|
|
375
|
+
if (x(a) || x(s)) return e;
|
|
376
376
|
const n = M(e);
|
|
377
|
-
return
|
|
378
|
-
if (
|
|
379
|
-
const
|
|
380
|
-
|
|
377
|
+
return S(R(n), (o) => {
|
|
378
|
+
if (w(s, o) && !x(a)) {
|
|
379
|
+
const l = d(n, o), i = d(n, `${o}-${a}`, "");
|
|
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:
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
384
|
+
const ot = (e, a) => {
|
|
385
|
+
const { baseClasses: t, classes: s } = st(e), o = s.split(" ").filter((i) => i.startsWith("dt-")).map((i) => {
|
|
386
|
+
var h;
|
|
387
|
+
return (h = a[i.replace("dt-", "")]) == null ? void 0 : h.value;
|
|
388
|
+
}), l = s.split(" ").filter((i) => !i.startsWith("dt-")).join(" ");
|
|
389
|
+
return vt.apply(null, [t, ...o, l]);
|
|
390
|
+
};
|
|
391
|
+
function Lt(e, a) {
|
|
389
392
|
return d(e, `${a}_attrs`, {});
|
|
390
393
|
}
|
|
391
|
-
function
|
|
392
|
-
const
|
|
393
|
-
return Object.keys(e).forEach((
|
|
394
|
-
if (
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
...!
|
|
398
|
-
...
|
|
394
|
+
function Jt(e, a = !0, t = {}) {
|
|
395
|
+
const s = {};
|
|
396
|
+
return Object.keys(e).forEach((n) => {
|
|
397
|
+
if ($(e[n]) && e[n].startsWith(f)) {
|
|
398
|
+
const o = ot(e[n], t), l = Lt(e, n);
|
|
399
|
+
s[n] = {
|
|
400
|
+
...!x(o) && { className: o },
|
|
401
|
+
...l,
|
|
399
402
|
...a ? {
|
|
400
|
-
"data-style-prop":
|
|
403
|
+
"data-style-prop": n,
|
|
401
404
|
"data-block-parent": e._id,
|
|
402
|
-
"data-style-id": `${
|
|
405
|
+
"data-style-id": `${n}-${e._id}`
|
|
403
406
|
} : {}
|
|
404
407
|
};
|
|
405
408
|
}
|
|
406
|
-
}),
|
|
409
|
+
}), s;
|
|
407
410
|
}
|
|
408
|
-
const zt =
|
|
409
|
-
const a =
|
|
411
|
+
const zt = bt((e) => {
|
|
412
|
+
const a = kt(e), t = d(a, "schema.properties", {});
|
|
410
413
|
return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
|
|
411
|
-
}),
|
|
412
|
-
if (!
|
|
414
|
+
}), Ft = (e, a) => {
|
|
415
|
+
if (!I(e)) return e;
|
|
413
416
|
let t = e, s;
|
|
414
417
|
return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
|
|
415
|
-
},
|
|
418
|
+
}, Ut = (e, a) => {
|
|
416
419
|
const t = M(e);
|
|
417
|
-
return
|
|
418
|
-
if (
|
|
420
|
+
return S(R(t), (s) => {
|
|
421
|
+
if ($(t[s]) && !k(s, "_")) {
|
|
419
422
|
let n = t[s];
|
|
420
423
|
s === "repeaterItems" && (t.repeaterItemsBinding = n);
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
let
|
|
424
|
-
const
|
|
425
|
-
n =
|
|
424
|
+
const o = /\{\{(.*?)\}\}/g, l = n.match(o);
|
|
425
|
+
l && l.forEach((i) => {
|
|
426
|
+
let h = i.slice(2, -2);
|
|
427
|
+
const r = d(a, h, i);
|
|
428
|
+
n = I(r) ? r : n.replace(i, r);
|
|
426
429
|
}), t[s] = n;
|
|
427
430
|
}
|
|
428
431
|
}), t;
|
|
429
|
-
},
|
|
430
|
-
const
|
|
432
|
+
}, _ = (e, a) => e.map((t) => {
|
|
433
|
+
const s = R(t).filter((n) => $(t[n]) && t[n].startsWith(f));
|
|
434
|
+
return xt(s, (n) => {
|
|
435
|
+
t[n] = `${f},${ot(t[n], a)}`;
|
|
436
|
+
}), t;
|
|
437
|
+
});
|
|
438
|
+
import.meta.vitest && describe("applyDesignTokens", () => {
|
|
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" }
|
|
443
|
+
}, a = [
|
|
444
|
+
{
|
|
445
|
+
_id: "block1",
|
|
446
|
+
_type: "div",
|
|
447
|
+
styles: "#styles:,dt-token1bg-white text-sm",
|
|
448
|
+
className: "#styles:,dt-token2 dt-token3",
|
|
449
|
+
otherProp: "not-a-style",
|
|
450
|
+
_name: "Test Block"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
_id: "block2",
|
|
454
|
+
_type: "button",
|
|
455
|
+
styles: "#styles:bg-red-500",
|
|
456
|
+
nonStringProp: 123,
|
|
457
|
+
_name: "Button Block"
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
_id: "block3",
|
|
461
|
+
_type: "span",
|
|
462
|
+
noStyles: "regular-string",
|
|
463
|
+
_name: "No Styles Block"
|
|
464
|
+
}
|
|
465
|
+
];
|
|
466
|
+
it("should process blocks and replace style properties with generated class names", () => {
|
|
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");
|
|
469
|
+
}), it("should handle blocks with no style properties", () => {
|
|
470
|
+
const t = _(a, e);
|
|
471
|
+
expect(t[2].noStyles).toBe("regular-string"), expect(t[2]._id).toBe("block3");
|
|
472
|
+
}), it("should handle empty blocks array", () => {
|
|
473
|
+
const t = _([], e);
|
|
474
|
+
expect(t).toEqual([]);
|
|
475
|
+
}), it("should handle empty design tokens", () => {
|
|
476
|
+
const t = _(a, {});
|
|
477
|
+
expect(t[0].styles).toBe("#styles:,text-sm");
|
|
478
|
+
}), it("should handle blocks with only style prefix", () => {
|
|
479
|
+
const s = _([
|
|
480
|
+
{
|
|
481
|
+
_id: "block1",
|
|
482
|
+
_type: "div",
|
|
483
|
+
styles: "#styles:",
|
|
484
|
+
_name: "Prefix Only"
|
|
485
|
+
}
|
|
486
|
+
], e);
|
|
487
|
+
expect(s[0].styles).toBe("#styles:,");
|
|
488
|
+
}), it("should handle blocks with multiple style properties", () => {
|
|
489
|
+
const s = _([
|
|
490
|
+
{
|
|
491
|
+
_id: "block1",
|
|
492
|
+
_type: "div",
|
|
493
|
+
styles: "#styles:bg-white dt-token1",
|
|
494
|
+
hoverStyles: "#styles:bg-gray-100 dt-token2",
|
|
495
|
+
focusStyles: "#styles:outline-none dt-token3",
|
|
496
|
+
_name: "Multi Style"
|
|
497
|
+
}
|
|
498
|
+
], e);
|
|
499
|
+
expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].hoverStyles).toBe("#styles:,text-lg bg-gray-100"), expect(s[0].focusStyles).toBe("#styles:,p-4 outline-none");
|
|
500
|
+
}), it("should not modify non-string properties that start with #styles:", () => {
|
|
501
|
+
const s = _([
|
|
502
|
+
{
|
|
503
|
+
_id: "block1",
|
|
504
|
+
_type: "div",
|
|
505
|
+
styles: "#styles:bg-white",
|
|
506
|
+
objectStyles: { startsWith: "#styles:" },
|
|
507
|
+
arrayStyles: ["#styles:bg-red-500"],
|
|
508
|
+
_name: "Non String Styles"
|
|
509
|
+
}
|
|
510
|
+
], e);
|
|
511
|
+
expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].objectStyles).toEqual({ startsWith: "#styles:" }), expect(s[0].arrayStyles).toEqual(["#styles:bg-red-500"]);
|
|
512
|
+
}), it("should handle undefined and null values", () => {
|
|
513
|
+
const s = _([
|
|
514
|
+
{
|
|
515
|
+
_id: "block1",
|
|
516
|
+
_type: "div",
|
|
517
|
+
styles: "#styles:bg-white",
|
|
518
|
+
nullStyles: null,
|
|
519
|
+
undefinedStyles: void 0,
|
|
520
|
+
_name: " Null Undefined"
|
|
521
|
+
}
|
|
522
|
+
], e);
|
|
523
|
+
expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].nullStyles).toBeNull(), expect(s[0].undefinedStyles).toBeUndefined();
|
|
524
|
+
}), it("should preserve block structure and non-style properties", () => {
|
|
525
|
+
_(a, e).forEach((s, n) => {
|
|
526
|
+
expect(s._id).toBe(a[n]._id), expect(s._type).toBe(a[n]._type), expect(s._name).toBe(a[n]._name);
|
|
527
|
+
});
|
|
528
|
+
}), it("should handle complex design token values", () => {
|
|
529
|
+
const n = _([
|
|
530
|
+
{
|
|
531
|
+
_id: "block1",
|
|
532
|
+
_type: "div",
|
|
533
|
+
styles: "#styles:bg-white dt-complex1",
|
|
534
|
+
_name: "Complex Tokens"
|
|
535
|
+
}
|
|
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" }
|
|
539
|
+
});
|
|
540
|
+
expect(n[0].styles).toBe("#styles:,hover:bg-blue-600 focus:outline-none transition-colors bg-white");
|
|
541
|
+
}), it("should handle tokens with empty values", () => {
|
|
542
|
+
const n = _([
|
|
543
|
+
{
|
|
544
|
+
_id: "block1",
|
|
545
|
+
_type: "div",
|
|
546
|
+
styles: "#styles:bg-white dt-empty1 dt-valid1",
|
|
547
|
+
_name: "Empty Value Tokens"
|
|
548
|
+
}
|
|
549
|
+
], {
|
|
550
|
+
empty1: { name: "empty-token", value: "" },
|
|
551
|
+
valid1: { name: "valid-token", value: "bg-green-500" }
|
|
552
|
+
});
|
|
553
|
+
expect(n[0].styles).toBe("#styles:,bg-white");
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
const v = (e) => {
|
|
557
|
+
const a = ft(e);
|
|
431
558
|
return e.map((t) => {
|
|
432
559
|
const s = Object.keys(t);
|
|
433
560
|
for (let n = 0; n < s.length; n++)
|
|
434
|
-
if (
|
|
435
|
-
const
|
|
436
|
-
t[s[n]] = `${t[s[n]].trim()}${
|
|
561
|
+
if ($(t[s[n]]) && k(s[n], "content")) {
|
|
562
|
+
const o = t === a ? "" : " ";
|
|
563
|
+
t[s[n]] = `${t[s[n]].trim()}${o}`;
|
|
437
564
|
}
|
|
438
565
|
return t;
|
|
439
566
|
});
|
|
@@ -442,50 +569,50 @@ if (import.meta.vitest) {
|
|
|
442
569
|
const { describe: e, it: a, expect: t } = import.meta.vitest;
|
|
443
570
|
e("adjustSpacingInContentBlocks", () => {
|
|
444
571
|
a("should add space after content fields except for the last block", () => {
|
|
445
|
-
const n =
|
|
572
|
+
const n = v([
|
|
446
573
|
{ _id: "1", _type: "Text", content: "First" },
|
|
447
574
|
{ _id: "2", _type: "Text", content: "Second" },
|
|
448
575
|
{ _id: "3", _type: "Text", content: "Third" }
|
|
449
576
|
]);
|
|
450
577
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
|
|
451
578
|
}), a("should trim whitespace from content before adding space", () => {
|
|
452
|
-
const n =
|
|
579
|
+
const n = v([
|
|
453
580
|
{ _id: "1", _type: "Text", content: " First " },
|
|
454
581
|
{ _id: "2", _type: "Text", content: " Second " }
|
|
455
582
|
]);
|
|
456
583
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
|
|
457
584
|
}), a("should handle multiple content fields in a single block", () => {
|
|
458
|
-
const n =
|
|
585
|
+
const n = v([
|
|
459
586
|
{ _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
|
|
460
587
|
{ _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
|
|
461
588
|
]);
|
|
462
589
|
t(n[0].content).toBe("Main "), t(n[0].contentAlt).toBe("Alt "), t(n[1].content).toBe("Last"), t(n[1].contentSecondary).toBe("Secondary");
|
|
463
590
|
}), a("should only process fields that start with 'content'", () => {
|
|
464
|
-
const n =
|
|
591
|
+
const n = v([
|
|
465
592
|
{ _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
|
|
466
593
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
467
594
|
]);
|
|
468
595
|
t(n[0].content).toBe("Text "), t(n[0].title).toBe("Title"), t(n[0].text).toBe("Text"), t(n[1].content).toBe("Last");
|
|
469
596
|
}), a("should handle empty array", () => {
|
|
470
|
-
const n =
|
|
597
|
+
const n = v([]);
|
|
471
598
|
t(n).toEqual([]);
|
|
472
599
|
}), a("should handle single block", () => {
|
|
473
|
-
const n =
|
|
600
|
+
const n = v([{ _id: "1", _type: "Text", content: "Only" }]);
|
|
474
601
|
t(n[0].content).toBe("Only");
|
|
475
602
|
}), a("should handle blocks without content fields", () => {
|
|
476
|
-
const n =
|
|
603
|
+
const n = v([
|
|
477
604
|
{ _id: "1", _type: "Container", title: "Title" },
|
|
478
605
|
{ _id: "2", _type: "Container", name: "Name" }
|
|
479
606
|
]);
|
|
480
607
|
t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
|
|
481
608
|
}), a("should handle blocks with non-string content fields", () => {
|
|
482
|
-
const n =
|
|
609
|
+
const n = v([
|
|
483
610
|
{ _id: "1", _type: "Text", content: "Text", contentNum: 123 },
|
|
484
611
|
{ _id: "2", _type: "Text", content: "Last", contentBool: !0 }
|
|
485
612
|
]);
|
|
486
613
|
t(n[0].content).toBe("Text "), t(n[0].contentNum).toBe(123), t(n[1].content).toBe("Last"), t(n[1].contentBool).toBe(!0);
|
|
487
614
|
}), a("should handle empty string content", () => {
|
|
488
|
-
const n =
|
|
615
|
+
const n = v([
|
|
489
616
|
{ _id: "1", _type: "Text", content: "" },
|
|
490
617
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
491
618
|
]);
|
|
@@ -494,32 +621,32 @@ if (import.meta.vitest) {
|
|
|
494
621
|
});
|
|
495
622
|
}
|
|
496
623
|
const b = (e, a, { index: t, key: s }, n) => {
|
|
497
|
-
if (
|
|
498
|
-
let
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
let
|
|
504
|
-
t !== -1 &&
|
|
505
|
-
const T = d(a,
|
|
506
|
-
T === void 0 ?
|
|
624
|
+
if ($(e)) {
|
|
625
|
+
let o = e;
|
|
626
|
+
const l = /\{\{(.*?)\}\}/g, i = e.match(l);
|
|
627
|
+
if (i) {
|
|
628
|
+
const h = n === "image" || n === "mobileImage";
|
|
629
|
+
i.forEach((r) => {
|
|
630
|
+
let B = r.slice(2, -2).trim(), C = s.slice(2, -2).trim();
|
|
631
|
+
t !== -1 && k(B, "$index.") ? B = `${C}.${t}.${B.slice(7)}` : t !== -1 && k(B, "$index") && (B = `${C}.${t}`);
|
|
632
|
+
const T = d(a, B);
|
|
633
|
+
T === void 0 ? o = o.replace(r, "") : h && !I(T) ? o = T : o = I(T) ? T : o.replace(r, T);
|
|
507
634
|
});
|
|
508
635
|
}
|
|
509
|
-
return
|
|
636
|
+
return o;
|
|
510
637
|
}
|
|
511
|
-
if (
|
|
512
|
-
return e.map((
|
|
638
|
+
if (I(e))
|
|
639
|
+
return e.map((o) => b(o, a, { index: t, key: s }, n));
|
|
513
640
|
if (e && typeof e == "object") {
|
|
514
|
-
const
|
|
515
|
-
return
|
|
516
|
-
!
|
|
517
|
-
}),
|
|
641
|
+
const o = {};
|
|
642
|
+
return S(R(e), (l) => {
|
|
643
|
+
!k(l, "_") && l !== "$repeaterItemsKey" ? o[l] = b(e[l], a, { index: t, key: s }, l) : o[l] = e[l];
|
|
644
|
+
}), o;
|
|
518
645
|
}
|
|
519
646
|
return e;
|
|
520
647
|
}, L = (e, a, { index: t, key: s }) => {
|
|
521
648
|
let n = M(e);
|
|
522
|
-
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems,
|
|
649
|
+
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, k(n.repeaterItems, `{{${wt}`) && (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 });
|
|
523
650
|
};
|
|
524
651
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
525
652
|
it("should handle string values with bindings", () => {
|
|
@@ -693,18 +820,19 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
693
820
|
});
|
|
694
821
|
}));
|
|
695
822
|
export {
|
|
696
|
-
|
|
823
|
+
wt as C,
|
|
697
824
|
qt as R,
|
|
698
|
-
|
|
825
|
+
f as S,
|
|
699
826
|
L as a,
|
|
700
|
-
|
|
827
|
+
Vt as b,
|
|
701
828
|
zt as c,
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
829
|
+
Ft as d,
|
|
830
|
+
v as e,
|
|
831
|
+
Ut as f,
|
|
832
|
+
Jt as g,
|
|
833
|
+
Ot as h,
|
|
834
|
+
_ as i,
|
|
835
|
+
st as j,
|
|
836
|
+
jt as k,
|
|
709
837
|
Mt as m
|
|
710
838
|
};
|