@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.3
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/README.md +27 -20
- package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
- package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
- package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
- package/dist/AP7HFJJL-CymCmW14.js +9214 -0
- package/dist/IconPicker-B1rWC-Ex.js +59 -0
- package/dist/IconPicker-DREyo007.cjs +1 -0
- package/dist/WDYDFRGG-BUVnbAci.js +33 -0
- package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
- package/dist/active-in-another-tab-CyjngVA6.js +34 -0
- package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
- package/dist/add-new-language-page-WmlCnytQ.js +401 -0
- package/dist/add-new-page-VW2wAYZp.js +31 -0
- package/dist/add-new-page-soZ8GAkN.cjs +1 -0
- package/dist/ai-panel-content-7zCil042.cjs +1 -0
- package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
- package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
- package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
- package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
- package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
- package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
- package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
- package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/code-display-BnqzqzoP.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
- package/dist/code-editor-DRIAnNbb.js +50 -0
- package/dist/code-editor-o3___nu2.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
- package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
- package/dist/delete-design-token-BRZZiWtQ.js +40 -0
- package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
- package/dist/delete-page-BzyX9TN-.js +70 -0
- package/dist/delete-page-DxX7PFIE.cjs +1 -0
- package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
- package/dist/design-token-usage-xQs6SlaJ.js +113 -0
- package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
- package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
- package/dist/duplicate-page-BR7Dlo9d.js +133 -0
- package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
- package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DV8kUKhl.js +108 -0
- package/dist/image-editor-G-K28aTS.cjs +1 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-Ct7ElCGK.js +19069 -0
- package/dist/index-DF5DEvqb.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-WQwzsC7A.cjs +5 -0
- package/dist/index-ZuacEL1j.js +4732 -0
- package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
- package/dist/json-diff-viewer-krslPepD.js +258 -0
- package/dist/lang-panel-BwIewMyw.js +215 -0
- package/dist/lang-panel-DT96k1xg.cjs +1 -0
- package/dist/manage-design-tokens-Caz_20VK.js +240 -0
- package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
- package/dist/mark-as-template-D295ZQtU.js +156 -0
- package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
- package/dist/no-language-page-content-BvqRBP6y.js +42 -0
- package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
- package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
- package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
- package/dist/page-creator-C4gc5NSC.cjs +1 -0
- package/dist/page-creator-DiOITEMw.js +795 -0
- package/dist/page-lock-BdYmCks0.cjs +1 -0
- package/dist/page-lock-Bfbs6RgL.js +30 -0
- package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
- package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
- package/dist/page-manager-new-CHDueBDk.cjs +1 -0
- package/dist/page-manager-new-CzX22g2n.js +394 -0
- package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
- package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
- package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +491 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-D9aixMN5.js +178 -0
- package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
- package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
- package/dist/save-to-lib-eiOc_SSN.js +422 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-BgRY82CT.cjs +16 -0
- package/dist/selected-block-display-CBFePS19.js +319 -0
- package/dist/seo-panel-C1-iMOR1.js +798 -0
- package/dist/seo-panel-DfAb8U7W.cjs +2 -0
- package/dist/shared-json-ld-B4PxAM_0.js +565 -0
- package/dist/shared-json-ld-DzG398hr.cjs +1 -0
- package/dist/slug-input-AwNJs9im.js +86 -0
- package/dist/slug-input-C_ijLQ_X.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-BNxcjY2j.cjs +1 -0
- package/dist/take-over-request-C4FeDtN_.js +63 -0
- package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
- package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
- package/dist/translation-warning-modal-B64YqlbI.js +26 -0
- package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
- package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
- package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
- package/dist/unpublish-page-D4VwOlxc.js +27 -0
- package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +248 -241
- package/dist/web-preview-Cio70gk5.cjs +1 -0
- package/dist/web-preview-Djy6WIyj.js +73 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -1,711 +0,0 @@
|
|
|
1
|
-
import { g as ot, c as R } from "./common-functions-BGzDsf1z.js";
|
|
2
|
-
import { isEmpty as f, flatten as ct, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as pt, forEach as $, camelCase as ut, includes as v, has as A, filter as G, some as dt, map as tt, compact as ht, trim as gt, capitalize as mt, memoize as et, cloneDeep as M, keys as P, isString as B, isArray as C, last as yt } from "lodash-es";
|
|
3
|
-
import { parse as bt, stringify as N } from "himalaya";
|
|
4
|
-
import { unset as H } from "lodash";
|
|
5
|
-
import { getRegisteredChaiBlock as ft } from "@chaibuilder/runtime";
|
|
6
|
-
import { twMerge as xt } from "tailwind-merge";
|
|
7
|
-
const x = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", _t = "#", st = (e) => {
|
|
8
|
-
if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
|
|
9
|
-
const a = e.split(/,(?![^\[]*\])/);
|
|
10
|
-
if (a.length === 1)
|
|
11
|
-
return { baseClasses: "", classes: a[0].trim() };
|
|
12
|
-
const [t, ...s] = a;
|
|
13
|
-
return {
|
|
14
|
-
baseClasses: t.trim(),
|
|
15
|
-
classes: s.join(",").trim().replace(/ +(?= )/g, "")
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
19
|
-
it("should return the base classes and the classes", () => {
|
|
20
|
-
const e = {
|
|
21
|
-
",styles-2": { baseClasses: "", classes: "styles-2" },
|
|
22
|
-
"styles-1,styles-2": { baseClasses: "styles-1", classes: "styles-2" },
|
|
23
|
-
",bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
24
|
-
baseClasses: "",
|
|
25
|
-
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
26
|
-
},
|
|
27
|
-
"styles-1,bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
28
|
-
baseClasses: "styles-1",
|
|
29
|
-
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
30
|
-
},
|
|
31
|
-
someclass: {
|
|
32
|
-
baseClasses: "",
|
|
33
|
-
classes: "someclass"
|
|
34
|
-
},
|
|
35
|
-
",bg-red-500 text-center font-bold": {
|
|
36
|
-
baseClasses: "",
|
|
37
|
-
classes: "bg-red-500 text-center font-bold"
|
|
38
|
-
},
|
|
39
|
-
"bg-[linear-gradient(-10deg,black,transparent_100%)], bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
40
|
-
baseClasses: "bg-[linear-gradient(-10deg,black,transparent_100%)]",
|
|
41
|
-
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
for (let a in e) {
|
|
45
|
-
const t = st(`${x}${a}`);
|
|
46
|
-
expect(t).toEqual(e[a]);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
const kt = (e) => {
|
|
51
|
-
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/;
|
|
52
|
-
return a.test(e) || t.test(e);
|
|
53
|
-
}, vt = (e) => {
|
|
54
|
-
if (f(e)) return e;
|
|
55
|
-
const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t), r = s ? s[1] : n ? n[1] : null, o = /(?: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/;
|
|
56
|
-
return r && (o.test(r) || l.test(r)) ? r : e;
|
|
57
|
-
}, at = ["chai-name", "data-chai-name"], wt = {
|
|
58
|
-
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
59
|
-
video: {
|
|
60
|
-
src: "url",
|
|
61
|
-
autoplay: "controls.autoPlay",
|
|
62
|
-
muted: "controls.muted",
|
|
63
|
-
loop: "controls.loop",
|
|
64
|
-
controls: "controls.widgets"
|
|
65
|
-
},
|
|
66
|
-
a: {
|
|
67
|
-
href: "link.href",
|
|
68
|
-
target: "link.target",
|
|
69
|
-
type: ""
|
|
70
|
-
// @TODO: Detect here what to url, email, phone, elementId
|
|
71
|
-
},
|
|
72
|
-
input: {
|
|
73
|
-
placeholder: "placeholder",
|
|
74
|
-
required: "required",
|
|
75
|
-
type: "inputType",
|
|
76
|
-
name: "fieldName"
|
|
77
|
-
},
|
|
78
|
-
textarea: {
|
|
79
|
-
placeholder: "placeholder",
|
|
80
|
-
required: "required",
|
|
81
|
-
type: "inputType",
|
|
82
|
-
name: "fieldName"
|
|
83
|
-
},
|
|
84
|
-
select: {
|
|
85
|
-
placeholder: "placeholder",
|
|
86
|
-
required: "required",
|
|
87
|
-
multiple: "multiple",
|
|
88
|
-
name: "fieldName"
|
|
89
|
-
},
|
|
90
|
-
form: {
|
|
91
|
-
action: "action"
|
|
92
|
-
}
|
|
93
|
-
}, Tt = (e, a) => e.children.length === 1 && v(
|
|
94
|
-
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
95
|
-
a._type
|
|
96
|
-
), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : f(a.children) ? "" : j(a.children)).join(""), S = (e) => e === null ? "" : e, nt = (e) => {
|
|
97
|
-
const a = ht(tt(e.split(/\s+/), gt)), t = m(a, (l) => /^w-/.test(l)), s = m(a, (l) => /^h-/.test(l));
|
|
98
|
-
if (!s || !t) return { height: "", width: "" };
|
|
99
|
-
const n = (l) => {
|
|
100
|
-
if (!l) return;
|
|
101
|
-
const g = l.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
|
|
102
|
-
if (!g) return;
|
|
103
|
-
if (g[1]) return g[1];
|
|
104
|
-
const i = g[2];
|
|
105
|
-
return /^\d+(\.\d+)?$/.test(i) ? `${Number(i) * 4}px` : i === "auto" || v(i, "%") ? i : "16px";
|
|
106
|
-
}, r = n(t), o = n(s);
|
|
107
|
-
return {
|
|
108
|
-
width: v(r, "px") ? r : "16px",
|
|
109
|
-
height: v(o, "px") ? o : "16px"
|
|
110
|
-
};
|
|
111
|
-
}, Q = (e) => {
|
|
112
|
-
if (e.tagName === "svg") return {};
|
|
113
|
-
const a = {}, t = wt[e.tagName] || {}, s = e.attributes;
|
|
114
|
-
return $(s, ({ key: n, value: r }) => {
|
|
115
|
-
if (!v(at, n))
|
|
116
|
-
if (n === "bid" && (a._bid = S(r)), t[n]) {
|
|
117
|
-
if (e.tagName === "img" && n === "src" && !r.startsWith("http")) {
|
|
118
|
-
const o = m(e.attributes, { key: "width" }), l = m(e.attributes, { key: "height" });
|
|
119
|
-
o && l ? r = `https://picsum.photos/${o == null ? void 0 : o.value}x${l == null ? void 0 : l.value}` : r = "https://picsum.photos/150x150";
|
|
120
|
-
}
|
|
121
|
-
E(a, t[n], S(r));
|
|
122
|
-
} else v(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), _(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = S(r));
|
|
123
|
-
}), delete a.class, a;
|
|
124
|
-
}, Et = (e, a = "styles") => {
|
|
125
|
-
if (!e.attributes) return { [a]: `${x},` };
|
|
126
|
-
const t = m(e.attributes, { key: "class" });
|
|
127
|
-
if (t) {
|
|
128
|
-
const s = t.value;
|
|
129
|
-
return { [a]: `${x},${s}` };
|
|
130
|
-
}
|
|
131
|
-
return { [a]: `${x},` };
|
|
132
|
-
}, $t = (e) => {
|
|
133
|
-
const a = d(e, "attributes", []), t = a.find((i) => i.key === "data-chai-richtext" || i.key === "chai-richtext"), s = a.find((i) => i.key === "data-chai-lightbox" || i.key === "chai-lightbox"), n = a.find((i) => i.key === "data-chai-dropdown" || i.key === "chai-dropdown"), r = a.find(
|
|
134
|
-
(i) => i.key === "data-chai-dropdown-button" || i.key === "chai-dropdown-button"
|
|
135
|
-
), o = a.find(
|
|
136
|
-
(i) => i.key === "data-chai-dropdown-content" || i.key === "chai-dropdown-content"
|
|
137
|
-
), l = a.find((i) => i.key === "class"), g = l && l.value.split(/\s+/).includes("rte");
|
|
138
|
-
if (n)
|
|
139
|
-
return { _type: "Dropdown" };
|
|
140
|
-
if (r)
|
|
141
|
-
return { _type: "DropdownButton" };
|
|
142
|
-
if (o)
|
|
143
|
-
return { _type: "DropdownContent" };
|
|
144
|
-
if (t || g)
|
|
145
|
-
return { _type: "Paragraph" };
|
|
146
|
-
if (s)
|
|
147
|
-
return { _type: "LightBoxLink" };
|
|
148
|
-
switch (e.tagName) {
|
|
149
|
-
// self closing tags
|
|
150
|
-
case "img":
|
|
151
|
-
return { _type: "Image" };
|
|
152
|
-
case "input":
|
|
153
|
-
return { _type: "Input", showLabel: !1 };
|
|
154
|
-
// showLabel: hiding default block label
|
|
155
|
-
case "hr":
|
|
156
|
-
return { _type: "Divider" };
|
|
157
|
-
case "br":
|
|
158
|
-
return { _type: "LineBreak" };
|
|
159
|
-
case "textarea":
|
|
160
|
-
return { _type: "TextArea", showLabel: !1 };
|
|
161
|
-
case "audio":
|
|
162
|
-
return { _type: "Audio" };
|
|
163
|
-
case "canvas":
|
|
164
|
-
return { _type: "Canvas" };
|
|
165
|
-
case "video":
|
|
166
|
-
case "iframe":
|
|
167
|
-
return { _type: "CustomHTML" };
|
|
168
|
-
case "svg":
|
|
169
|
-
return { _type: "Icon" };
|
|
170
|
-
// non self closing tags
|
|
171
|
-
// fixed structure
|
|
172
|
-
case "select":
|
|
173
|
-
return { _type: "Select", options: [] };
|
|
174
|
-
case "option":
|
|
175
|
-
return { _type: "Option" };
|
|
176
|
-
case "ul":
|
|
177
|
-
case "ol":
|
|
178
|
-
case "dl":
|
|
179
|
-
return {
|
|
180
|
-
_type: "List",
|
|
181
|
-
tag: e.tagName,
|
|
182
|
-
_listType: e.tagName === "ol" ? "list-decimal" : "list-none"
|
|
183
|
-
};
|
|
184
|
-
case "li":
|
|
185
|
-
case "dt":
|
|
186
|
-
return { _type: "ListItem", tag: e.tagName };
|
|
187
|
-
// non self closing tags
|
|
188
|
-
// free flow structure
|
|
189
|
-
case "span":
|
|
190
|
-
case "figcaption":
|
|
191
|
-
case "legend":
|
|
192
|
-
return { _type: "Span", tag: e.tagName };
|
|
193
|
-
case "p":
|
|
194
|
-
return { _type: "Paragraph", content: "" };
|
|
195
|
-
case "a":
|
|
196
|
-
return { _type: "Link" };
|
|
197
|
-
case "form":
|
|
198
|
-
return { _type: "Form" };
|
|
199
|
-
case "label":
|
|
200
|
-
return { _type: "Label" };
|
|
201
|
-
case "button":
|
|
202
|
-
return { _type: "Button" };
|
|
203
|
-
case "code":
|
|
204
|
-
return { _type: "Box", _name: "Code" };
|
|
205
|
-
case "h1":
|
|
206
|
-
case "h2":
|
|
207
|
-
case "h3":
|
|
208
|
-
case "h4":
|
|
209
|
-
case "h5":
|
|
210
|
-
case "h6":
|
|
211
|
-
return { _type: "Heading", tag: e.tagName };
|
|
212
|
-
case "table":
|
|
213
|
-
return { _type: "Table" };
|
|
214
|
-
case "tr":
|
|
215
|
-
return { _type: "TableRow" };
|
|
216
|
-
case "td":
|
|
217
|
-
case "th":
|
|
218
|
-
return { _type: "TableCell", tag: e.tagName };
|
|
219
|
-
case "thead":
|
|
220
|
-
return { _type: "TableHead" };
|
|
221
|
-
case "tbody":
|
|
222
|
-
return { _type: "TableBody" };
|
|
223
|
-
case "tfoot":
|
|
224
|
-
return { _type: "TableFooter" };
|
|
225
|
-
default: {
|
|
226
|
-
const i = d(e, "children", []).length > 0 ? "Box" : "EmptyBox";
|
|
227
|
-
return {
|
|
228
|
-
_type: i,
|
|
229
|
-
tag: e.tagName,
|
|
230
|
-
_name: i == "EmptyBox" || e.tagName === "div" ? i : mt(e.tagName)
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}, q = (e, a = null) => lt(e, (t) => {
|
|
235
|
-
var J, O, z, V, W, F, U, Y, K, X;
|
|
236
|
-
if (t.type === "comment") return [];
|
|
237
|
-
let s = { _id: ot() };
|
|
238
|
-
if (a && (s._parent = a.block._id), t.type === "text")
|
|
239
|
-
return f(d(t, "content", "")) ? [] : a && Tt(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
|
|
240
|
-
if (_(t.tagName, "chai-")) {
|
|
241
|
-
const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || pt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
242
|
-
s._type = u, $(c, ({ key: y, value: Z }) => {
|
|
243
|
-
if (y === "about-this-component" || y === "chai-type" || y === "can-move" || y === "can-delete") return;
|
|
244
|
-
if (y === "id") {
|
|
245
|
-
s._id = Z;
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const rt = _(y, "_") ? y : ut(y);
|
|
249
|
-
let I = S(Z);
|
|
250
|
-
typeof I == "string" && _(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")), s[rt] = I;
|
|
251
|
-
});
|
|
252
|
-
const h = q(t.children, { block: s, node: t });
|
|
253
|
-
return [s, ...h];
|
|
254
|
-
}
|
|
255
|
-
const n = d(t, "attributes", []), r = n.find(
|
|
256
|
-
(c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"
|
|
257
|
-
), o = n.find((c) => c.key === "class"), l = o && o.value.split(/\s+/).includes("rte"), g = n.find(
|
|
258
|
-
(c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
|
|
259
|
-
), i = n.find(
|
|
260
|
-
(c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
|
|
261
|
-
), w = n.find(
|
|
262
|
-
(c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
|
|
263
|
-
), D = n.find(
|
|
264
|
-
(c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
|
|
265
|
-
);
|
|
266
|
-
if (s = {
|
|
267
|
-
...s,
|
|
268
|
-
...$t(t),
|
|
269
|
-
...Q(t),
|
|
270
|
-
...Et(t)
|
|
271
|
-
}, t.attributes) {
|
|
272
|
-
const c = t.attributes.find((p) => v(at, p.key));
|
|
273
|
-
c && (s._name = c.value);
|
|
274
|
-
}
|
|
275
|
-
if (r || l)
|
|
276
|
-
return s.content = N(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];
|
|
277
|
-
if (g) {
|
|
278
|
-
const c = [
|
|
279
|
-
"data-chai-lightbox",
|
|
280
|
-
"chai-lightbox",
|
|
281
|
-
"data-vbtype",
|
|
282
|
-
"data-autoplay",
|
|
283
|
-
"data-maxwidth",
|
|
284
|
-
"data-overlay",
|
|
285
|
-
"data-gall",
|
|
286
|
-
"href"
|
|
287
|
-
];
|
|
288
|
-
s = {
|
|
289
|
-
...s,
|
|
290
|
-
href: ((J = n.find((p) => p.key === "href")) == null ? void 0 : J.value) || "",
|
|
291
|
-
hrefType: ((O = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : O.value) || "video",
|
|
292
|
-
autoplay: ((z = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : z.value) === "true" ? "true" : "false",
|
|
293
|
-
maxWidth: ((W = (V = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : V.value) == null ? void 0 : W.replace("px", "")) || "",
|
|
294
|
-
backdropColor: ((F = n.find((p) => p.key === "data-overlay")) == null ? void 0 : F.value) || "",
|
|
295
|
-
galleryName: ((U = n.find((p) => p.key === "data-gall")) == null ? void 0 : U.value) || ""
|
|
296
|
-
}, $(c, (p) => {
|
|
297
|
-
A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
if (i && (delete s.styles_attrs, s.showDropdown = !1), D && delete s.styles_attrs, w) {
|
|
301
|
-
delete s.styles_attrs;
|
|
302
|
-
const c = G(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
|
|
303
|
-
s.content = j(c);
|
|
304
|
-
const p = m(
|
|
305
|
-
t.children || [],
|
|
306
|
-
(u) => (u == null ? void 0 : u.tagName) === "span" && dt(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
307
|
-
);
|
|
308
|
-
if (p) {
|
|
309
|
-
const u = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
310
|
-
if (u) {
|
|
311
|
-
s.icon = N([u]);
|
|
312
|
-
const { height: h, width: y } = Bt(u, "16px", "16px");
|
|
313
|
-
s.iconHeight = h, s.iconWidth = y;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
return [s];
|
|
317
|
-
}
|
|
318
|
-
if (s._type === "Input") {
|
|
319
|
-
const c = s.inputType || "text";
|
|
320
|
-
c === "checkbox" ? E(s, "_type", "Checkbox") : c === "radio" && E(s, "_type", "Radio");
|
|
321
|
-
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
322
|
-
const c = N([t]);
|
|
323
|
-
return kt(c) && (E(s, "_type", "Video"), E(s, "url", vt(c)), E(s, "styles", `${x},`), E(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
|
|
324
|
-
} else if (t.tagName === "svg") {
|
|
325
|
-
const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = nt(c);
|
|
326
|
-
if (p && u)
|
|
327
|
-
s.styles = `${x}, ${R(`w-${u} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = u == null ? void 0 : u.replace("px", "");
|
|
328
|
-
else {
|
|
329
|
-
const h = (Y = m(t.attributes, { key: "height" })) == null ? void 0 : Y.value, y = (K = m(t.attributes, { key: "width" })) == null ? void 0 : K.value;
|
|
330
|
-
h && y ? (s.styles = `${x}, ${R(`w-[${y}px] h-[${h}px]`, c)}`.trim(), s.height = h, s.width = y) : s.styles = `${x}, ${R("w-full h-full", c)}`.trim();
|
|
331
|
-
}
|
|
332
|
-
return t.attributes = G(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)), s.icon = N([t]), [s];
|
|
333
|
-
} else if (t.tagName == "option" && a && ((X = a.block) == null ? void 0 : X._type) === "Select")
|
|
334
|
-
return a.block.options.push({
|
|
335
|
-
label: j(t.children),
|
|
336
|
-
...Q(t)
|
|
337
|
-
}), [];
|
|
338
|
-
const T = q(t.children, { block: s, node: t });
|
|
339
|
-
return [s, ...T];
|
|
340
|
-
}), Bt = (e, a, t) => {
|
|
341
|
-
var g, i;
|
|
342
|
-
const s = d(e, "attributes", []), { height: n, width: r } = nt(
|
|
343
|
-
d(m(s, { key: "class" }), "value", "")
|
|
344
|
-
);
|
|
345
|
-
if (n && r)
|
|
346
|
-
return {
|
|
347
|
-
height: `[${n}px]`,
|
|
348
|
-
width: `[${r}px]`
|
|
349
|
-
};
|
|
350
|
-
const o = (g = m(s, { key: "height" })) == null ? void 0 : g.value, l = (i = m(s, { key: "width" })) == null ? void 0 : i.value;
|
|
351
|
-
return {
|
|
352
|
-
height: o ? `[${o}px]` : t,
|
|
353
|
-
width: l ? `[${l}px]` : a
|
|
354
|
-
};
|
|
355
|
-
}, It = (e) => {
|
|
356
|
-
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, r) => {
|
|
357
|
-
let o = r.replace(/\\"/g, '"');
|
|
358
|
-
return o = o.replace(/{([^}]+)}/g, (l) => l.replace(/"/g, '\\"')), `${n}="${o.replace(/\\"/g, '"')}"`;
|
|
359
|
-
}), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
|
|
360
|
-
const a = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
361
|
-
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();
|
|
362
|
-
}, Ct = (e, a) => m(e, { _id: a }), Pt = (e, a) => f(a) ? e.map((t) => (H(t, "_bid"), t)) : tt(e, (t) => {
|
|
363
|
-
const s = f(t._bid) ? void 0 : Ct(a, t._bid);
|
|
364
|
-
if (s) {
|
|
365
|
-
s._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
|
|
366
|
-
const n = { ...s, ...t };
|
|
367
|
-
return H(n, "_bid"), n;
|
|
368
|
-
}
|
|
369
|
-
return H(t, "_bid"), t;
|
|
370
|
-
}), Jt = (e) => {
|
|
371
|
-
const a = bt(It(e));
|
|
372
|
-
return f(e) ? [] : ct(q(a));
|
|
373
|
-
};
|
|
374
|
-
function Ot(e, a, t) {
|
|
375
|
-
const s = d(t, "i18nProps", []);
|
|
376
|
-
if (f(a) || f(s)) return e;
|
|
377
|
-
const n = M(e);
|
|
378
|
-
return $(P(n), (r) => {
|
|
379
|
-
if (v(s, r) && !f(a)) {
|
|
380
|
-
const o = d(n, r), l = d(n, `${r}-${a}`, "");
|
|
381
|
-
B(o) ? n[r] = B(l) && !f(l.trim()) && l.trimStart() || o : n[r] = f(l) ? o : l;
|
|
382
|
-
}
|
|
383
|
-
}), n;
|
|
384
|
-
}
|
|
385
|
-
const Dt = et((e) => {
|
|
386
|
-
const { baseClasses: a, classes: t } = st(e);
|
|
387
|
-
return xt(a, t);
|
|
388
|
-
});
|
|
389
|
-
function Nt(e, a) {
|
|
390
|
-
return d(e, `${a}_attrs`, {});
|
|
391
|
-
}
|
|
392
|
-
function zt(e, a = !0) {
|
|
393
|
-
const t = {};
|
|
394
|
-
return Object.keys(e).forEach((s) => {
|
|
395
|
-
if (B(e[s]) && e[s].startsWith(x)) {
|
|
396
|
-
const n = Dt(e[s]), r = Nt(e, s);
|
|
397
|
-
t[s] = {
|
|
398
|
-
...!f(n) && { className: n },
|
|
399
|
-
...r,
|
|
400
|
-
...a ? {
|
|
401
|
-
"data-style-prop": s,
|
|
402
|
-
"data-block-parent": e._id,
|
|
403
|
-
"data-style-id": `${s}-${e._id}`
|
|
404
|
-
} : {}
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
}), t;
|
|
408
|
-
}
|
|
409
|
-
const Vt = et((e) => {
|
|
410
|
-
const a = ft(e), t = d(a, "schema.properties", {});
|
|
411
|
-
return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
|
|
412
|
-
}), Wt = (e, a) => {
|
|
413
|
-
if (!C(e)) return e;
|
|
414
|
-
let t = e, s;
|
|
415
|
-
return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
|
|
416
|
-
}, Ft = (e, a) => {
|
|
417
|
-
const t = M(e);
|
|
418
|
-
return $(P(t), (s) => {
|
|
419
|
-
if (B(t[s]) && !_(s, "_")) {
|
|
420
|
-
let n = t[s];
|
|
421
|
-
s === "repeaterItems" && (t.repeaterItemsBinding = n);
|
|
422
|
-
const r = /\{\{(.*?)\}\}/g, o = n.match(r);
|
|
423
|
-
o && o.forEach((l) => {
|
|
424
|
-
let g = l.slice(2, -2);
|
|
425
|
-
const i = d(a, g, l);
|
|
426
|
-
n = C(i) ? i : n.replace(l, i);
|
|
427
|
-
}), t[s] = n;
|
|
428
|
-
}
|
|
429
|
-
}), t;
|
|
430
|
-
}, k = (e) => {
|
|
431
|
-
const a = yt(e);
|
|
432
|
-
return e.map((t) => {
|
|
433
|
-
const s = Object.keys(t);
|
|
434
|
-
for (let n = 0; n < s.length; n++)
|
|
435
|
-
if (B(t[s[n]]) && _(s[n], "content")) {
|
|
436
|
-
const r = t === a ? "" : " ";
|
|
437
|
-
t[s[n]] = `${t[s[n]].trim()}${r}`;
|
|
438
|
-
}
|
|
439
|
-
return t;
|
|
440
|
-
});
|
|
441
|
-
};
|
|
442
|
-
if (import.meta.vitest) {
|
|
443
|
-
const { describe: e, it: a, expect: t } = import.meta.vitest;
|
|
444
|
-
e("adjustSpacingInContentBlocks", () => {
|
|
445
|
-
a("should add space after content fields except for the last block", () => {
|
|
446
|
-
const n = k([
|
|
447
|
-
{ _id: "1", _type: "Text", content: "First" },
|
|
448
|
-
{ _id: "2", _type: "Text", content: "Second" },
|
|
449
|
-
{ _id: "3", _type: "Text", content: "Third" }
|
|
450
|
-
]);
|
|
451
|
-
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
|
|
452
|
-
}), a("should trim whitespace from content before adding space", () => {
|
|
453
|
-
const n = k([
|
|
454
|
-
{ _id: "1", _type: "Text", content: " First " },
|
|
455
|
-
{ _id: "2", _type: "Text", content: " Second " }
|
|
456
|
-
]);
|
|
457
|
-
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
|
|
458
|
-
}), a("should handle multiple content fields in a single block", () => {
|
|
459
|
-
const n = k([
|
|
460
|
-
{ _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
|
|
461
|
-
{ _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
|
|
462
|
-
]);
|
|
463
|
-
t(n[0].content).toBe("Main "), t(n[0].contentAlt).toBe("Alt "), t(n[1].content).toBe("Last"), t(n[1].contentSecondary).toBe("Secondary");
|
|
464
|
-
}), a("should only process fields that start with 'content'", () => {
|
|
465
|
-
const n = k([
|
|
466
|
-
{ _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
|
|
467
|
-
{ _id: "2", _type: "Text", content: "Last" }
|
|
468
|
-
]);
|
|
469
|
-
t(n[0].content).toBe("Text "), t(n[0].title).toBe("Title"), t(n[0].text).toBe("Text"), t(n[1].content).toBe("Last");
|
|
470
|
-
}), a("should handle empty array", () => {
|
|
471
|
-
const n = k([]);
|
|
472
|
-
t(n).toEqual([]);
|
|
473
|
-
}), a("should handle single block", () => {
|
|
474
|
-
const n = k([{ _id: "1", _type: "Text", content: "Only" }]);
|
|
475
|
-
t(n[0].content).toBe("Only");
|
|
476
|
-
}), a("should handle blocks without content fields", () => {
|
|
477
|
-
const n = k([
|
|
478
|
-
{ _id: "1", _type: "Container", title: "Title" },
|
|
479
|
-
{ _id: "2", _type: "Container", name: "Name" }
|
|
480
|
-
]);
|
|
481
|
-
t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
|
|
482
|
-
}), a("should handle blocks with non-string content fields", () => {
|
|
483
|
-
const n = k([
|
|
484
|
-
{ _id: "1", _type: "Text", content: "Text", contentNum: 123 },
|
|
485
|
-
{ _id: "2", _type: "Text", content: "Last", contentBool: !0 }
|
|
486
|
-
]);
|
|
487
|
-
t(n[0].content).toBe("Text "), t(n[0].contentNum).toBe(123), t(n[1].content).toBe("Last"), t(n[1].contentBool).toBe(!0);
|
|
488
|
-
}), a("should handle empty string content", () => {
|
|
489
|
-
const n = k([
|
|
490
|
-
{ _id: "1", _type: "Text", content: "" },
|
|
491
|
-
{ _id: "2", _type: "Text", content: "Last" }
|
|
492
|
-
]);
|
|
493
|
-
t(n[0].content).toBe(" "), t(n[1].content).toBe("Last");
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
const b = (e, a, { index: t, key: s }, n) => {
|
|
498
|
-
if (B(e)) {
|
|
499
|
-
let r = e;
|
|
500
|
-
const o = /\{\{(.*?)\}\}/g, l = e.match(o);
|
|
501
|
-
if (l) {
|
|
502
|
-
const g = n === "image" || n === "mobileImage";
|
|
503
|
-
l.forEach((i) => {
|
|
504
|
-
let w = i.slice(2, -2).trim(), D = s.slice(2, -2).trim();
|
|
505
|
-
t !== -1 && _(w, "$index.") ? w = `${D}.${t}.${w.slice(7)}` : t !== -1 && _(w, "$index") && (w = `${D}.${t}`);
|
|
506
|
-
const T = d(a, w);
|
|
507
|
-
T === void 0 ? r = r.replace(i, "") : g && !C(T) ? r = T : r = C(T) ? T : r.replace(i, T);
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
return r;
|
|
511
|
-
}
|
|
512
|
-
if (C(e))
|
|
513
|
-
return e.map((r) => b(r, a, { index: t, key: s }, n));
|
|
514
|
-
if (e && typeof e == "object") {
|
|
515
|
-
const r = {};
|
|
516
|
-
return $(P(e), (o) => {
|
|
517
|
-
!_(o, "_") && o !== "$repeaterItemsKey" ? r[o] = b(e[o], a, { index: t, key: s }, o) : r[o] = e[o];
|
|
518
|
-
}), r;
|
|
519
|
-
}
|
|
520
|
-
return e;
|
|
521
|
-
}, L = (e, a, { index: t, key: s }) => {
|
|
522
|
-
let n = M(e);
|
|
523
|
-
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, _(n.repeaterItems, `{{${_t}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, a, { index: t, key: s });
|
|
524
|
-
};
|
|
525
|
-
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
526
|
-
it("should handle string values with bindings", () => {
|
|
527
|
-
const t = b("Hello {{user.name}}", { user: { name: "John" } }, { index: -1, key: "" });
|
|
528
|
-
expect(t).toBe("Hello John");
|
|
529
|
-
}), it("should handle nested object properties", () => {
|
|
530
|
-
const t = b({
|
|
531
|
-
name: "John",
|
|
532
|
-
address: {
|
|
533
|
-
city: "{{user.city}}",
|
|
534
|
-
street: "123 Main St"
|
|
535
|
-
}
|
|
536
|
-
}, { user: { city: "New York" } }, { index: -1, key: "" });
|
|
537
|
-
expect(t).toEqual({
|
|
538
|
-
name: "John",
|
|
539
|
-
address: {
|
|
540
|
-
city: "New York",
|
|
541
|
-
street: "123 Main St"
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
}), it("should handle arrays of values", () => {
|
|
545
|
-
const t = b(["Hello {{user.name}}", "Welcome {{user.role}}"], { user: { name: "John", role: "Admin" } }, { index: -1, key: "" });
|
|
546
|
-
expect(t).toEqual(["Hello John", "Welcome Admin"]);
|
|
547
|
-
}), it("should handle $index binding in repeater context", () => {
|
|
548
|
-
const t = b("Item {{$index}}", { items: ["a", "b", "c"] }, { index: 1, key: "{{items}}" });
|
|
549
|
-
expect(t).toBe("Item b");
|
|
550
|
-
}), it("should handle $index binding with dot notation", () => {
|
|
551
|
-
const t = b("Item {{$index.value}}", { items: [{ value: "apple" }, { value: "banana" }, { value: "cherry" }] }, { index: 1, key: "{{items}}" });
|
|
552
|
-
expect(t).toBe("Item banana");
|
|
553
|
-
}), it("should return an empty string for non-existing bindings", () => {
|
|
554
|
-
const t = b("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
|
|
555
|
-
expect(t).toBe("Hello ");
|
|
556
|
-
}), it("should preserve private properties starting with _", () => {
|
|
557
|
-
const a = b({
|
|
558
|
-
name: "John",
|
|
559
|
-
_private: "secret"
|
|
560
|
-
}, {}, { index: -1, key: "" });
|
|
561
|
-
expect(a).toEqual({
|
|
562
|
-
name: "John",
|
|
563
|
-
_private: "secret"
|
|
564
|
-
});
|
|
565
|
-
}), it("should completely replace image property value when binding exists", () => {
|
|
566
|
-
const t = b({
|
|
567
|
-
image: "https://default.jpg{{user.avatar}}",
|
|
568
|
-
title: "Hello {{user.name}}"
|
|
569
|
-
}, { user: { avatar: "https://avatar.jpg", name: "John" } }, { index: -1, key: "" });
|
|
570
|
-
expect(t).toEqual({
|
|
571
|
-
image: "https://avatar.jpg",
|
|
572
|
-
// Completely replaced, not concatenated
|
|
573
|
-
title: "Hello John"
|
|
574
|
-
// Normal replacement
|
|
575
|
-
});
|
|
576
|
-
}), it("should completely replace mobileImage property value when binding exists", () => {
|
|
577
|
-
const t = b({
|
|
578
|
-
mobileImage: "https://default-mobile.jpg{{user.mobileAvatar}}",
|
|
579
|
-
alt: "Avatar for {{user.name}}"
|
|
580
|
-
}, { user: { mobileAvatar: "https://mobile-avatar.jpg", name: "John" } }, { index: -1, key: "" });
|
|
581
|
-
expect(t).toEqual({
|
|
582
|
-
mobileImage: "https://mobile-avatar.jpg",
|
|
583
|
-
// Completely replaced
|
|
584
|
-
alt: "Avatar for John"
|
|
585
|
-
// Normal replacement
|
|
586
|
-
});
|
|
587
|
-
}), it("should handle image binding with only binding syntax", () => {
|
|
588
|
-
const t = b({
|
|
589
|
-
image: "{{product.thumbnail}}"
|
|
590
|
-
}, { product: { thumbnail: "https://product.jpg" } }, { index: -1, key: "" });
|
|
591
|
-
expect(t).toEqual({
|
|
592
|
-
image: "https://product.jpg"
|
|
593
|
-
});
|
|
594
|
-
}), it("should not affect non-image properties with similar bindings", () => {
|
|
595
|
-
const t = b({
|
|
596
|
-
url: "https://default.com{{page.slug}}",
|
|
597
|
-
link: "https://example.com/{{page.id}}"
|
|
598
|
-
}, { page: { slug: "/about", id: "123" } }, { index: -1, key: "" });
|
|
599
|
-
expect(t).toEqual({
|
|
600
|
-
url: "https://default.com/about",
|
|
601
|
-
// Concatenated normally
|
|
602
|
-
link: "https://example.com/123"
|
|
603
|
-
// Concatenated normally
|
|
604
|
-
});
|
|
605
|
-
});
|
|
606
|
-
}), describe("applyBindingToBlockProps", () => {
|
|
607
|
-
it("should handle basic block with bindings", () => {
|
|
608
|
-
const t = L({
|
|
609
|
-
_id: "test-block",
|
|
610
|
-
_type: "text",
|
|
611
|
-
type: "text",
|
|
612
|
-
content: "Hello {{user.name}}",
|
|
613
|
-
style: {
|
|
614
|
-
color: "{{theme.color}}"
|
|
615
|
-
}
|
|
616
|
-
}, { user: { name: "John" }, theme: { color: "blue" } }, { index: -1, key: "" });
|
|
617
|
-
expect(t).toEqual({
|
|
618
|
-
_id: "test-block",
|
|
619
|
-
_type: "text",
|
|
620
|
-
type: "text",
|
|
621
|
-
content: "Hello John",
|
|
622
|
-
style: {
|
|
623
|
-
color: "blue"
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
}), it("should handle repeaterItems and repeaterItemsBinding", () => {
|
|
627
|
-
const t = L({
|
|
628
|
-
_id: "test-block",
|
|
629
|
-
_type: "repeater",
|
|
630
|
-
type: "repeater",
|
|
631
|
-
repeaterItems: "{{items}}",
|
|
632
|
-
items: ["a", "b", "c"]
|
|
633
|
-
}, { items: ["x", "y", "z"] }, { index: -1, key: "" });
|
|
634
|
-
expect(t).toEqual({
|
|
635
|
-
_id: "test-block",
|
|
636
|
-
_type: "repeater",
|
|
637
|
-
type: "repeater",
|
|
638
|
-
$repeaterItemsKey: "{{items}}",
|
|
639
|
-
repeaterItems: ["x", "y", "z"],
|
|
640
|
-
items: ["a", "b", "c"]
|
|
641
|
-
});
|
|
642
|
-
}), it("should handle nested blocks with bindings", () => {
|
|
643
|
-
const t = L({
|
|
644
|
-
_id: "test-block",
|
|
645
|
-
_type: "container",
|
|
646
|
-
type: "container",
|
|
647
|
-
children: [
|
|
648
|
-
{
|
|
649
|
-
_id: "child-block",
|
|
650
|
-
_type: "text",
|
|
651
|
-
type: "text",
|
|
652
|
-
content: "Item {{$index}}",
|
|
653
|
-
style: {
|
|
654
|
-
color: "{{theme.color}}"
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
]
|
|
658
|
-
}, { theme: { color: "red" }, items: ["x", "y", "z"] }, { index: 2, key: "{{items}}" });
|
|
659
|
-
expect(t).toEqual({
|
|
660
|
-
_id: "test-block",
|
|
661
|
-
_type: "container",
|
|
662
|
-
type: "container",
|
|
663
|
-
children: [
|
|
664
|
-
{
|
|
665
|
-
_id: "child-block",
|
|
666
|
-
_type: "text",
|
|
667
|
-
type: "text",
|
|
668
|
-
content: "Item z",
|
|
669
|
-
style: {
|
|
670
|
-
color: "red"
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
]
|
|
674
|
-
});
|
|
675
|
-
}), it("should handle arrays of blocks", () => {
|
|
676
|
-
const t = L({
|
|
677
|
-
_id: "test-block",
|
|
678
|
-
_type: "list",
|
|
679
|
-
type: "list",
|
|
680
|
-
items: [
|
|
681
|
-
{ _id: "item1", content: "Item {{$index}}" },
|
|
682
|
-
{ _id: "item2", content: "Item {{$index}}" }
|
|
683
|
-
]
|
|
684
|
-
}, { items: ["x", "y", "z"] }, { index: 0, key: "{{items}}" });
|
|
685
|
-
expect(t).toEqual({
|
|
686
|
-
_id: "test-block",
|
|
687
|
-
_type: "list",
|
|
688
|
-
type: "list",
|
|
689
|
-
items: [
|
|
690
|
-
{ _id: "item1", content: "Item x" },
|
|
691
|
-
{ _id: "item2", content: "Item x" }
|
|
692
|
-
]
|
|
693
|
-
});
|
|
694
|
-
});
|
|
695
|
-
}));
|
|
696
|
-
export {
|
|
697
|
-
_t as C,
|
|
698
|
-
Mt as R,
|
|
699
|
-
x as S,
|
|
700
|
-
L as a,
|
|
701
|
-
Ot as b,
|
|
702
|
-
Vt as c,
|
|
703
|
-
Wt as d,
|
|
704
|
-
k as e,
|
|
705
|
-
Ft as f,
|
|
706
|
-
zt as g,
|
|
707
|
-
Jt as h,
|
|
708
|
-
st as i,
|
|
709
|
-
qt as j,
|
|
710
|
-
Pt as m
|
|
711
|
-
};
|