@chaibuilder/sdk 4.0.0-beta.3 → 4.0.0-beta.4
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/{2SSKDMRQ-BnsZi3K3.cjs → 2SSKDMRQ-CopJgtZb.cjs} +1 -1
- package/dist/{2SSKDMRQ-CnSDkQcy.js → 2SSKDMRQ-Difo_1pg.js} +2 -2
- package/dist/{AP7HFJJL-CymCmW14.js → AP7HFJJL-BPuPBqj4.js} +1 -1
- package/dist/{AP7HFJJL-B31839PG.cjs → AP7HFJJL-DYxDgaOs.cjs} +1 -1
- package/dist/{IconPicker-B1rWC-Ex.js → IconPicker-B2-oriq2.js} +8 -7
- package/dist/IconPicker-C0oycHbs.cjs +1 -0
- package/dist/{WDYDFRGG-BxhOCHc3.cjs → WDYDFRGG-DbejaRPK.cjs} +1 -1
- package/dist/{WDYDFRGG-BUVnbAci.js → WDYDFRGG-KK8pkcW1.js} +2 -2
- package/dist/{actions-registery-YnFmU21O.cjs → actions-registery-JdxhXhT6.cjs} +1 -1
- package/dist/{actions-registery-CZ1w0NKa.js → actions-registery-y_ENc8zj.js} +2 -2
- package/dist/actions.cjs +1 -1
- package/dist/actions.js +2 -2
- package/dist/active-in-another-tab-Cu_ASKtx.cjs +1 -0
- package/dist/active-in-another-tab-DkR2HWI4.js +35 -0
- package/dist/add-new-language-page-BXuwluuU.cjs +1 -0
- package/dist/{add-new-language-page-WmlCnytQ.js → add-new-language-page-CBY0RR6q.js} +54 -53
- package/dist/{add-new-page-soZ8GAkN.cjs → add-new-page-C_PzKby8.cjs} +1 -1
- package/dist/{add-new-page-VW2wAYZp.js → add-new-page-DJLJFLAd.js} +2 -2
- package/dist/{ai-panel-content-D_o7Q_A-.js → ai-panel-content--YM01Aly.js} +12 -11
- package/dist/ai-panel-content-rRmJdH7L.cjs +1 -0
- package/dist/{ai-panel-default-lang-DnElspF0.js → ai-panel-default-lang-BZl0tPYo.js} +40 -40
- package/dist/{ai-panel-default-lang-COYaxNwn.cjs → ai-panel-default-lang-D2zhXvKP.cjs} +2 -2
- package/dist/{ai-panel-other-lang-Dp0E9_Hx.js → ai-panel-other-lang-Bfjk2CYZ.js} +8 -8
- package/dist/{ai-panel-other-lang-CkynNlAU.cjs → ai-panel-other-lang-Y4bEKHoG.cjs} +1 -1
- package/dist/{ai-prompt-input-Bhc0ds7X.js → ai-prompt-input-DueQYNf-.js} +68 -67
- package/dist/ai-prompt-input-N9PcYCFa.cjs +1 -0
- package/dist/{ai-translation-prompt-CZ55HQmo.js → ai-translation-prompt-B36F3d7K.js} +2 -2
- package/dist/ai-translation-prompt-IAdWMNZb.cjs +1 -0
- package/dist/{apply-binding-6iwlED02.js → apply-binding-BvWfJCSZ.js} +204 -196
- package/dist/apply-binding-IsUf6UWJ.cjs +1 -0
- package/dist/{code-display-DhD_RBcg.js → code-display-Ck81Id9K.js} +1 -1
- package/dist/code-display-DloSPyPr.cjs +1 -0
- package/dist/{code-editor-DRIAnNbb.js → code-editor-Bb7JumZy.js} +11 -10
- package/dist/code-editor-DQB8lAOk.cjs +1 -0
- package/dist/{continue-editing-in-this-client-CS2aQ7yY.js → continue-editing-in-this-client-Dm9cCj7K.js} +10 -9
- package/dist/continue-editing-in-this-client-DmGFLHXw.cjs +1 -0
- package/dist/core-Dr7QYemB.js +56 -0
- package/dist/core-Y0lXLwkq.cjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +3 -3
- package/dist/core.js +41 -39
- package/dist/{css-import-modal-Byg6wV0O.js → css-import-modal-9P_0uNa4.js} +5 -3
- package/dist/css-import-modal-Rh1QAVxo.cjs +13 -0
- package/dist/{delete-design-token-DkVs1oBf.cjs → delete-design-token-BG8yHcS5.cjs} +1 -1
- package/dist/{delete-design-token-BRZZiWtQ.js → delete-design-token-COvR4G1S.js} +1 -1
- package/dist/{delete-page-BzyX9TN-.js → delete-page-CNucxe4P.js} +11 -10
- package/dist/delete-page-DAvEjHwF.cjs +1 -0
- package/dist/design-token-usage-CXglXgcJ.cjs +1 -0
- package/dist/{design-token-usage-xQs6SlaJ.js → design-token-usage-MNYsFlPG.js} +14 -13
- package/dist/digital-asset-manager-CB5MRBcW.cjs +1 -0
- package/dist/{digital-asset-manager-DbtwzxRz.js → digital-asset-manager-CqCWBO0s.js} +6 -5
- package/dist/{duplicate-page-BR7Dlo9d.js → duplicate-page-BknLfqr0.js} +19 -18
- package/dist/duplicate-page-DzZByALW.cjs +1 -0
- package/dist/{dynamic-page-selector-Cb5r_W8s.js → dynamic-page-selector-DoW7OyUB.js} +15 -14
- package/dist/dynamic-page-selector-WA007Sni.cjs +1 -0
- package/dist/get-chai-builder-tailwind-config-BFePCEIS.cjs +1 -0
- package/dist/{get-chai-builder-tailwind-config-DjoVOuAf.js → get-chai-builder-tailwind-config-BXf_xLHk.js} +5 -5
- package/dist/{get-chai-builder-theme-Dl72X7cz.cjs → get-chai-builder-theme-BApShjRz.cjs} +1 -1
- package/dist/{get-chai-builder-theme-BYtp20KD.js → get-chai-builder-theme-DDVRJQ6Z.js} +1 -1
- package/dist/{image-editor-DV8kUKhl.js → image-editor-CQnNtak2.js} +1 -1
- package/dist/{image-editor-G-K28aTS.cjs → image-editor-CqwaVxO2.cjs} +1 -1
- package/dist/index-C0-pgg_p.cjs +5 -0
- package/dist/index-C99FhuF1.cjs +160 -0
- package/dist/{index-ZuacEL1j.js → index-Dno42B0a.js} +672 -670
- package/dist/{index-Ct7ElCGK.js → index-rAcNbjk_.js} +3744 -3920
- package/dist/{json-diff-viewer-D7z4zNvv.cjs → json-diff-viewer-CLuUHiPU.cjs} +3 -3
- package/dist/{json-diff-viewer-krslPepD.js → json-diff-viewer-CMvGUvJ2.js} +5 -4
- package/dist/{lang-panel-BwIewMyw.js → lang-panel-CnwTb05j.js} +15 -14
- package/dist/lang-panel-fDCYm5Jm.cjs +1 -0
- package/dist/{manage-design-tokens-Caz_20VK.js → manage-design-tokens-BsSZE9Vs.js} +12 -11
- package/dist/manage-design-tokens-BvH5KTJX.cjs +1 -0
- package/dist/mark-as-template-CpWEBJGd.cjs +1 -0
- package/dist/{mark-as-template-D295ZQtU.js → mark-as-template-DBLshWb5.js} +17 -16
- package/dist/{nested-path-selector-content-CKYYK-C5.js → nested-path-selector-content-6OBJ8LG8.js} +24 -23
- package/dist/nested-path-selector-content-C2sD9dkq.cjs +1 -0
- package/dist/no-language-page-content-BvPDdccK.cjs +1 -0
- package/dist/{no-language-page-content-BvqRBP6y.js → no-language-page-content-CzENgtnu.js} +10 -9
- package/dist/{no-language-page-dialog-PjNqTUpl.js → no-language-page-dialog-CbYI2cVg.js} +2 -2
- package/dist/{no-language-page-dialog-BcEoqyQB.cjs → no-language-page-dialog-CgW4yJBC.cjs} +1 -1
- package/dist/{page-creator-DiOITEMw.js → page-creator-Cc83uQqw.js} +113 -112
- package/dist/page-creator-g8GqgcKH.cjs +1 -0
- package/dist/{page-lock-Bfbs6RgL.js → page-lock-BJUkyxdh.js} +2 -2
- package/dist/{page-lock-BdYmCks0.cjs → page-lock-CT7SmQqp.cjs} +1 -1
- package/dist/page-locked-dialog-Co5b9XIZ.cjs +1 -0
- package/dist/{page-locked-dialog-B6MKTRfY.js → page-locked-dialog-DsEbWRed.js} +18 -15
- package/dist/{page-manager-new-CzX22g2n.js → page-manager-new-5rFP5DyQ.js} +30 -29
- package/dist/page-manager-new-BOkJImo2.cjs +1 -0
- package/dist/page-manager-search-and-filter-Bfm0j1gg.cjs +1 -0
- package/dist/{page-manager-search-and-filter-CM0UMb6U.js → page-manager-search-and-filter-zq-LfhQ1.js} +13 -12
- package/dist/{page-revisions-content-NH9JK4Ey.js → page-revisions-content-D38G2tJM.js} +34 -31
- package/dist/page-revisions-content-ag-MHBGr.cjs +1 -0
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +4 -4
- package/dist/pages.js +1 -1
- package/dist/{plugin-C6rgJDNQ.cjs → plugin-BGlQf0iy.cjs} +1 -1
- package/dist/{plugin-3ZKK6RXm.js → plugin-C-ht41UZ.js} +1 -1
- package/dist/publish-pages-content-BiX-GMLw.cjs +1 -0
- package/dist/{publish-pages-content-D9aixMN5.js → publish-pages-content-CS7f41Ac.js} +66 -65
- package/dist/register-chai-top-bar-BqwKw4uy.cjs +1 -0
- package/dist/register-chai-top-bar-ESJHs5s-.js +237 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +2 -2
- package/dist/render.js +87 -80
- package/dist/rte-widget-modal-BKNx2wln.cjs +1 -0
- package/dist/{rte-widget-modal-DOJEXLIf.js → rte-widget-modal-D6Zik0Ta.js} +15 -14
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +168 -4
- package/dist/runtime.js +68 -38
- package/dist/{save-to-lib-eiOc_SSN.js → save-to-lib-WwOzbgiF.js} +39 -38
- package/dist/save-to-lib-ffjCZYJ5.cjs +1 -0
- package/dist/sdk.css +1 -1
- package/dist/{selected-block-display-CBFePS19.js → selected-block-display-B1SG_UXw.js} +37 -36
- package/dist/selected-block-display-BOgnQRLF.cjs +16 -0
- package/dist/{seo-panel-C1-iMOR1.js → seo-panel-BkOgRoWd.js} +12 -11
- package/dist/seo-panel-FjS1UF_y.cjs +2 -0
- package/dist/{shared-json-ld-B4PxAM_0.js → shared-json-ld-uka9TOgA.js} +68 -67
- package/dist/shared-json-ld-yJkXjENy.cjs +1 -0
- package/dist/slug-input-Cyd6NR6J.cjs +1 -0
- package/dist/{slug-input-AwNJs9im.js → slug-input-DHLmUNrH.js} +9 -8
- package/dist/supabase-actions.cjs +1 -1
- package/dist/supabase-actions.d.ts +1 -1
- package/dist/supabase-actions.js +1 -1
- package/dist/{take-over-request-C4FeDtN_.js → take-over-request-Ca0X-qyf.js} +17 -16
- package/dist/take-over-request-CmpJVe9T.cjs +1 -0
- package/dist/{theme-panel-footer-uBQqSJXm.js → theme-panel-footer-BUXIu252.js} +11 -10
- package/dist/theme-panel-footer-CKO9YYwZ.cjs +1 -0
- package/dist/{translation-warning-modal-B64YqlbI.js → translation-warning-modal-DrpFeI83.js} +9 -8
- package/dist/translation-warning-modal-pSZVKcNW.cjs +1 -0
- package/dist/{unmark-as-template-CZ9sQp_P.js → unmark-as-template-BMqgelv-.js} +11 -10
- package/dist/unmark-as-template-DF1Ms4VN.cjs +1 -0
- package/dist/unpublish-page-BJ0Bsvt2.js +28 -0
- package/dist/unpublish-page-Bsq2yEqQ.cjs +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +2 -2
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +46 -46
- package/dist/{web-preview-Djy6WIyj.js → web-preview-D6h1L2nV.js} +2 -2
- package/dist/web-preview-kres0aG7.cjs +1 -0
- package/package.json +4 -2
- package/dist/IconPicker-DREyo007.cjs +0 -1
- package/dist/active-in-another-tab-B47YjQGN.cjs +0 -1
- package/dist/active-in-another-tab-CyjngVA6.js +0 -34
- package/dist/add-new-language-page-88xzrUy8.cjs +0 -1
- package/dist/ai-panel-content-7zCil042.cjs +0 -1
- package/dist/ai-prompt-input-CThbVp0_.cjs +0 -1
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +0 -1
- package/dist/apply-binding-KKp5PnpZ.cjs +0 -1
- package/dist/code-display-BnqzqzoP.cjs +0 -1
- package/dist/code-editor-o3___nu2.cjs +0 -1
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +0 -1
- package/dist/core-BoRDjj4h.cjs +0 -1
- package/dist/core-yvI6kCyw.js +0 -56
- package/dist/css-import-modal-CyqkXWCO.cjs +0 -13
- package/dist/delete-page-DxX7PFIE.cjs +0 -1
- package/dist/design-token-usage-CAHzEGgJ.cjs +0 -1
- package/dist/digital-asset-manager--uO8Agia.cjs +0 -1
- package/dist/duplicate-page-CaNAbXwV.cjs +0 -1
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +0 -1
- package/dist/get-chai-builder-tailwind-config-B9rCyiQo.cjs +0 -1
- package/dist/index-DF5DEvqb.cjs +0 -160
- package/dist/index-WQwzsC7A.cjs +0 -5
- package/dist/lang-panel-DT96k1xg.cjs +0 -1
- package/dist/manage-design-tokens-CrmLe7UT.cjs +0 -1
- package/dist/mark-as-template-W3LmpiqN.cjs +0 -1
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +0 -1
- package/dist/no-language-page-content-DkfeMl90.cjs +0 -1
- package/dist/page-creator-C4gc5NSC.cjs +0 -1
- package/dist/page-locked-dialog-B1FAtK92.cjs +0 -1
- package/dist/page-manager-new-CHDueBDk.cjs +0 -1
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +0 -1
- package/dist/page-revisions-content-ChY-4f2V.cjs +0 -1
- package/dist/publish-pages-content-x-JuSFJ9.cjs +0 -1
- package/dist/rte-widget-modal-BaHIuEjF.cjs +0 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +0 -1
- package/dist/selected-block-display-BgRY82CT.cjs +0 -16
- package/dist/seo-panel-DfAb8U7W.cjs +0 -2
- package/dist/shared-json-ld-DzG398hr.cjs +0 -1
- package/dist/slug-input-C_ijLQ_X.cjs +0 -1
- package/dist/take-over-request-BNxcjY2j.cjs +0 -1
- package/dist/theme-panel-footer-Cq9pljro.cjs +0 -1
- package/dist/translation-warning-modal-BZAcwM2_.cjs +0 -1
- package/dist/unmark-as-template-EVvk0vmp.cjs +0 -1
- package/dist/unpublish-page-D4VwOlxc.js +0 -27
- package/dist/unpublish-page-bdSmwAVQ.cjs +0 -1
- package/dist/web-preview-Cio70gk5.cjs +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { memoize as
|
|
1
|
+
import { g as rt, c as R } from "./common-functions-D2lMFR6K.js";
|
|
2
|
+
import { memoize as ct, get as y, cloneDeep as q, forEach as N, keys as W, isString as $, startsWith as k, isArray as I, isEmpty as _, includes as B, flatten as pt, flatMapDeep as ut, set as w, find as m, startCase as dt, camelCase as G, has as P, filter as Q, some as yt, capitalize as ht, compact as mt, map as gt, trim as bt, each as xt, last as ft } from "lodash-es";
|
|
3
3
|
import { parse as _t, stringify as C } from "himalaya";
|
|
4
|
-
import { e as kt, i as vt } from "./core-
|
|
4
|
+
import { e as kt, i as vt } from "./core-Dr7QYemB.js";
|
|
5
5
|
import { twMerge as wt } from "tailwind-merge";
|
|
6
|
-
const x = "#styles:",
|
|
7
|
-
if (
|
|
8
|
-
const n =
|
|
6
|
+
const x = "#styles:", Ht = "__ADD_BLOCK_INTERNAL_ROOT", qt = "@", Bt = "#", tt = "dt#", st = (s) => {
|
|
7
|
+
if (s = s.replace(x, ""), !s) return { baseClasses: "", classes: "" };
|
|
8
|
+
const n = s.split(/,(?![^\[]*\])/);
|
|
9
9
|
if (n.length === 1)
|
|
10
10
|
return { baseClasses: "", classes: n[0].trim() };
|
|
11
|
-
const [t, ...
|
|
11
|
+
const [t, ...e] = n;
|
|
12
12
|
return {
|
|
13
13
|
baseClasses: t.trim(),
|
|
14
|
-
classes:
|
|
14
|
+
classes: e.join(",").trim().replace(/ +(?= )/g, "")
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
18
18
|
it("should return the base classes and the classes", () => {
|
|
19
|
-
const
|
|
19
|
+
const s = {
|
|
20
20
|
",styles-2": { baseClasses: "", classes: "styles-2" },
|
|
21
21
|
"styles-1,styles-2": { baseClasses: "styles-1", classes: "styles-2" },
|
|
22
22
|
",bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
@@ -40,79 +40,79 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
40
40
|
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
for (
|
|
44
|
-
const
|
|
45
|
-
expect(
|
|
43
|
+
for (const [n, t] of Object.entries(s)) {
|
|
44
|
+
const e = st(`${x}${n}`);
|
|
45
|
+
expect(e).toEqual(t);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
|
-
function
|
|
50
|
-
const
|
|
51
|
-
if (_(n) || _(
|
|
52
|
-
const a = q(
|
|
53
|
-
return N(
|
|
54
|
-
if (B(
|
|
49
|
+
function Ot(s, n, t) {
|
|
50
|
+
const e = y(t, "i18nProps", []);
|
|
51
|
+
if (_(n) || _(e)) return s;
|
|
52
|
+
const a = q(s);
|
|
53
|
+
return N(W(a), (o) => {
|
|
54
|
+
if (B(e, o) && !_(n)) {
|
|
55
55
|
const i = y(a, o), l = y(a, `${o}-${n}`, "");
|
|
56
56
|
$(i) ? a[o] = $(l) && !_(l.trim()) && l.trimStart() || i : a[o] = _(l) ? i : l;
|
|
57
57
|
}
|
|
58
58
|
}), a;
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
const { baseClasses: t, classes:
|
|
60
|
+
const at = (s, n) => {
|
|
61
|
+
const { baseClasses: t, classes: e } = st(s), o = e.split(" ").filter((l) => l.startsWith(tt)).map((l) => {
|
|
62
62
|
var u;
|
|
63
63
|
return (u = n[l]) == null ? void 0 : u.value;
|
|
64
|
-
}), i =
|
|
64
|
+
}), i = e.split(" ").filter((l) => !l.startsWith(tt)).join(" ");
|
|
65
65
|
return wt.apply(null, [t, ...o, i]);
|
|
66
66
|
};
|
|
67
|
-
function Tt(
|
|
68
|
-
return y(
|
|
67
|
+
function Tt(s, n) {
|
|
68
|
+
return y(s, `${n}_attrs`, {});
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
const
|
|
72
|
-
return Object.keys(
|
|
73
|
-
if ($(
|
|
74
|
-
const o =
|
|
75
|
-
|
|
70
|
+
function Mt(s, n = !0, t = {}) {
|
|
71
|
+
const e = {};
|
|
72
|
+
return Object.keys(s).forEach((a) => {
|
|
73
|
+
if ($(s[a]) && s[a].startsWith(x)) {
|
|
74
|
+
const o = at(s[a], t), i = Tt(s, a);
|
|
75
|
+
e[a] = {
|
|
76
76
|
...!_(o) && { className: o },
|
|
77
77
|
...i,
|
|
78
78
|
...n ? {
|
|
79
79
|
"data-style-prop": a,
|
|
80
|
-
"data-block-parent":
|
|
81
|
-
"data-style-id": `${a}-${
|
|
80
|
+
"data-block-parent": s._id,
|
|
81
|
+
"data-style-id": `${a}-${s._id}`
|
|
82
82
|
} : {}
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
}),
|
|
85
|
+
}), e;
|
|
86
86
|
}
|
|
87
|
-
const Vt =
|
|
88
|
-
const n = kt(
|
|
89
|
-
return Object.fromEntries(Object.entries(t).filter(([,
|
|
90
|
-
}), Jt = (
|
|
91
|
-
if (!I(
|
|
92
|
-
let t =
|
|
93
|
-
return typeof n.limit == "number" && n.limit > 0 && (
|
|
94
|
-
}, zt = (
|
|
95
|
-
const t = q(
|
|
96
|
-
return N(
|
|
97
|
-
if ($(t[
|
|
98
|
-
let a = t[
|
|
99
|
-
|
|
87
|
+
const Vt = ct((s) => {
|
|
88
|
+
const n = kt(s), t = y(n, "schema.properties", {});
|
|
89
|
+
return Object.fromEntries(Object.entries(t).filter(([, e]) => y(e, "runtime", !1)));
|
|
90
|
+
}), Jt = (s, n) => {
|
|
91
|
+
if (!I(s)) return s;
|
|
92
|
+
let t = s, e;
|
|
93
|
+
return typeof n.limit == "number" && n.limit > 0 && (e = n.limit), e !== void 0 && (t = t.slice(0, e)), t;
|
|
94
|
+
}, zt = (s, n) => {
|
|
95
|
+
const t = q(s);
|
|
96
|
+
return N(W(t), (e) => {
|
|
97
|
+
if ($(t[e]) && !k(e, "_")) {
|
|
98
|
+
let a = t[e];
|
|
99
|
+
e === "repeaterItems" && (t.repeaterItemsBinding = a);
|
|
100
100
|
const o = /\{\{(.*?)\}\}/g, i = a.match(o);
|
|
101
101
|
i && i.forEach((l) => {
|
|
102
102
|
let u = l.slice(2, -2);
|
|
103
103
|
const r = y(n, u, l);
|
|
104
104
|
a = I(r) ? r : a.replace(l, r);
|
|
105
|
-
}), t[
|
|
105
|
+
}), t[e] = a;
|
|
106
106
|
}
|
|
107
107
|
}), t;
|
|
108
|
-
}, Et = (
|
|
108
|
+
}, Et = (s) => {
|
|
109
109
|
const n = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, t = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
|
|
110
|
-
return n.test(
|
|
111
|
-
}, $t = (
|
|
112
|
-
if (_(
|
|
113
|
-
const n = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/,
|
|
114
|
-
return o && (i.test(o) || l.test(o)) ? o :
|
|
115
|
-
},
|
|
110
|
+
return n.test(s) || t.test(s);
|
|
111
|
+
}, $t = (s) => {
|
|
112
|
+
if (_(s)) return s;
|
|
113
|
+
const n = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, e = s.match(n), a = s.match(t), o = e ? e[1] : a ? a[1] : null, i = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, l = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
114
|
+
return o && (i.test(o) || l.test(o)) ? o : s;
|
|
115
|
+
}, nt = ["chai-name", "data-chai-name"], Nt = {
|
|
116
116
|
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
117
117
|
video: {
|
|
118
118
|
src: "url",
|
|
@@ -148,12 +148,15 @@ const Vt = rt((e) => {
|
|
|
148
148
|
form: {
|
|
149
149
|
action: "action"
|
|
150
150
|
}
|
|
151
|
-
}, St = (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
}, St = (s, n) => {
|
|
152
|
+
var t;
|
|
153
|
+
return ((t = s.children) == null ? void 0 : t.length) === 1 && B(
|
|
154
|
+
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
155
|
+
n._type
|
|
156
|
+
);
|
|
157
|
+
}, j = (s) => s.map((n) => n.type === "text" ? y(n, "content", "") : _(n.children) ? "" : j(n.children || [])).join(""), A = (s) => s === null ? "" : s, ot = (s) => {
|
|
158
|
+
const n = mt(gt(s.split(/\s+/), bt)), t = m(n, (l) => /^w-/.test(l)), e = m(n, (l) => /^h-/.test(l));
|
|
159
|
+
if (!e || !t) return { height: "", width: "" };
|
|
157
160
|
const a = (l) => {
|
|
158
161
|
if (!l) return;
|
|
159
162
|
const u = l.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
|
|
@@ -161,38 +164,38 @@ const Vt = rt((e) => {
|
|
|
161
164
|
if (u[1]) return u[1];
|
|
162
165
|
const r = u[2];
|
|
163
166
|
return /^\d+(\.\d+)?$/.test(r) ? `${Number(r) * 4}px` : r === "auto" || B(r, "%") ? r : "16px";
|
|
164
|
-
}, o = a(t), i = a(
|
|
167
|
+
}, o = a(t), i = a(e);
|
|
165
168
|
return {
|
|
166
169
|
width: B(o, "px") ? o : "16px",
|
|
167
170
|
height: B(i, "px") ? i : "16px"
|
|
168
171
|
};
|
|
169
|
-
},
|
|
170
|
-
if (
|
|
171
|
-
const n = {}, t = Nt[
|
|
172
|
-
return N(
|
|
172
|
+
}, et = (s) => {
|
|
173
|
+
if (s.tagName === "svg") return {};
|
|
174
|
+
const n = {}, t = Nt[s.tagName || ""] || {}, e = s.attributes || [];
|
|
175
|
+
return N(e, ({ key: a, value: o }) => {
|
|
173
176
|
var i;
|
|
174
|
-
if (!B(
|
|
175
|
-
if (a === "bid" && (n._bid =
|
|
176
|
-
if (
|
|
177
|
-
const l = m(
|
|
177
|
+
if (!B(nt, a))
|
|
178
|
+
if (a === "bid" && (n._bid = A(o)), t[a]) {
|
|
179
|
+
if (s.tagName === "img" && a === "src" && !o.startsWith("http")) {
|
|
180
|
+
const l = m(s.attributes, { key: "width" }), u = m(s.attributes, { key: "height" });
|
|
178
181
|
l && u ? o = `https://picsum.photos/${l == null ? void 0 : l.value}x${u == null ? void 0 : u.value}` : o = "https://picsum.photos/150x150";
|
|
179
|
-
} else if (
|
|
180
|
-
const l = m(
|
|
182
|
+
} else if (s.tagName === "a") {
|
|
183
|
+
const l = m(s.attributes, { key: "href" });
|
|
181
184
|
l && typeof (l == null ? void 0 : l.value) == "string" && ((i = l == null ? void 0 : l.value) != null && i.startsWith("pageType:")) && w(n, "link.type", "pageType");
|
|
182
185
|
}
|
|
183
|
-
w(n, t[a],
|
|
184
|
-
} else B(["style", "class", "srcset", "bid"], a) || (
|
|
186
|
+
w(n, t[a], A(o));
|
|
187
|
+
} else B(["style", "class", "srcset", "bid"], a) || (n.styles_attrs = n.styles_attrs || {}, k(a, "@") && (a = a.replace("@", "x-on:")), n.styles_attrs[`${a}`] = A(o));
|
|
185
188
|
}), delete n.class, n;
|
|
186
|
-
}, It = (
|
|
187
|
-
if (!
|
|
188
|
-
const t = m(
|
|
189
|
+
}, It = (s, n = "styles") => {
|
|
190
|
+
if (!s.attributes) return { [n]: `${x},` };
|
|
191
|
+
const t = m(s.attributes, { key: "class" });
|
|
189
192
|
if (t) {
|
|
190
|
-
const
|
|
191
|
-
return { [n]: `${x},${
|
|
193
|
+
const e = t.value;
|
|
194
|
+
return { [n]: `${x},${e}` };
|
|
192
195
|
}
|
|
193
196
|
return { [n]: `${x},` };
|
|
194
|
-
}, Dt = (
|
|
195
|
-
const n = y(
|
|
197
|
+
}, Dt = (s) => {
|
|
198
|
+
const n = y(s, "attributes", []), t = n.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), e = n.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), a = n.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = n.find(
|
|
196
199
|
(r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
|
|
197
200
|
), i = n.find(
|
|
198
201
|
(r) => r.key === "data-chai-dropdown-content" || r.key === "chai-dropdown-content"
|
|
@@ -205,9 +208,9 @@ const Vt = rt((e) => {
|
|
|
205
208
|
return { _type: "DropdownContent" };
|
|
206
209
|
if (t || u)
|
|
207
210
|
return { _type: "Paragraph" };
|
|
208
|
-
if (
|
|
211
|
+
if (e)
|
|
209
212
|
return { _type: "LightBoxLink" };
|
|
210
|
-
switch (
|
|
213
|
+
switch (s.tagName) {
|
|
211
214
|
// self closing tags
|
|
212
215
|
case "img":
|
|
213
216
|
return { _type: "Image" };
|
|
@@ -240,18 +243,18 @@ const Vt = rt((e) => {
|
|
|
240
243
|
case "dl":
|
|
241
244
|
return {
|
|
242
245
|
_type: "List",
|
|
243
|
-
tag:
|
|
244
|
-
_listType:
|
|
246
|
+
tag: s.tagName,
|
|
247
|
+
_listType: s.tagName === "ol" ? "list-decimal" : "list-none"
|
|
245
248
|
};
|
|
246
249
|
case "li":
|
|
247
250
|
case "dt":
|
|
248
|
-
return { _type: "ListItem", tag:
|
|
251
|
+
return { _type: "ListItem", tag: s.tagName };
|
|
249
252
|
// non self closing tags
|
|
250
253
|
// free flow structure
|
|
251
254
|
case "span":
|
|
252
255
|
case "figcaption":
|
|
253
256
|
case "legend":
|
|
254
|
-
return { _type: "Span", tag:
|
|
257
|
+
return { _type: "Span", tag: s.tagName };
|
|
255
258
|
case "p":
|
|
256
259
|
return { _type: "Paragraph", content: "" };
|
|
257
260
|
case "a":
|
|
@@ -270,14 +273,14 @@ const Vt = rt((e) => {
|
|
|
270
273
|
case "h4":
|
|
271
274
|
case "h5":
|
|
272
275
|
case "h6":
|
|
273
|
-
return { _type: "Heading", tag:
|
|
276
|
+
return { _type: "Heading", tag: s.tagName };
|
|
274
277
|
case "table":
|
|
275
278
|
return { _type: "Table" };
|
|
276
279
|
case "tr":
|
|
277
280
|
return { _type: "TableRow" };
|
|
278
281
|
case "td":
|
|
279
282
|
case "th":
|
|
280
|
-
return { _type: "TableCell", tag:
|
|
283
|
+
return { _type: "TableCell", tag: s.tagName };
|
|
281
284
|
case "thead":
|
|
282
285
|
return { _type: "TableHead" };
|
|
283
286
|
case "tbody":
|
|
@@ -285,34 +288,34 @@ const Vt = rt((e) => {
|
|
|
285
288
|
case "tfoot":
|
|
286
289
|
return { _type: "TableFooter" };
|
|
287
290
|
default: {
|
|
288
|
-
const r = y(
|
|
291
|
+
const r = y(s, "children", []).length > 0 ? "Box" : "EmptyBox";
|
|
289
292
|
return {
|
|
290
293
|
_type: r,
|
|
291
|
-
tag:
|
|
292
|
-
_name: r == "EmptyBox" ||
|
|
294
|
+
tag: s.tagName,
|
|
295
|
+
_name: r == "EmptyBox" || s.tagName === "div" ? r : ht(s.tagName)
|
|
293
296
|
};
|
|
294
297
|
}
|
|
295
298
|
}
|
|
296
|
-
},
|
|
297
|
-
var
|
|
299
|
+
}, H = (s, n = null) => ut(s, (t) => {
|
|
300
|
+
var O, M, V, J, z, F, U, Y, K, X;
|
|
298
301
|
if (t.type === "comment") return [];
|
|
299
|
-
let
|
|
300
|
-
if (n && (
|
|
301
|
-
return _(y(t, "content", "")) ? [] : n && St(n.node, n.block) ? (w(n, "block.content", y(t, "content", "")), []) : { ...
|
|
302
|
+
let e = { _id: rt() };
|
|
303
|
+
if (n && (e._parent = n.block._id), t.type === "text")
|
|
304
|
+
return _(y(t, "content", "")) ? [] : n && St(n.node, n.block) ? (w(n, "block.content", y(t, "content", "")), []) : { ...e, _type: "Text", content: y(t, "content", "") };
|
|
302
305
|
if (k(t.tagName, "chai-")) {
|
|
303
|
-
const c = t.attributes, p = m(c, { key: "chai-type" }), d = (p == null ? void 0 : p.value) ||
|
|
304
|
-
|
|
306
|
+
const c = t.attributes || [], p = m(c, { key: "chai-type" }), d = (p == null ? void 0 : p.value) || dt(G(t.tagName || "")).replace(/ /g, "").replace(/\s+/g, "");
|
|
307
|
+
e._type = d, N(c, ({ key: g, value: Z }) => {
|
|
305
308
|
if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
|
|
306
309
|
if (g === "id") {
|
|
307
|
-
|
|
310
|
+
e._id = Z;
|
|
308
311
|
return;
|
|
309
312
|
}
|
|
310
|
-
const
|
|
311
|
-
let S =
|
|
312
|
-
typeof S == "string" && k(S, "#styles:") && (S = S.replace("#styles:", "#styles:,")),
|
|
313
|
+
const lt = k(g, "_") ? g : G(g);
|
|
314
|
+
let S = A(Z);
|
|
315
|
+
typeof S == "string" && k(S, "#styles:") && (S = S.replace("#styles:", "#styles:,")), e[lt] = S;
|
|
313
316
|
});
|
|
314
|
-
const h =
|
|
315
|
-
return [
|
|
317
|
+
const h = H(t.children || [], { block: e, node: t });
|
|
318
|
+
return [e, ...h];
|
|
316
319
|
}
|
|
317
320
|
const a = y(t, "attributes", []), o = t.tagName === "p" || a.find((c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"), i = a.find((c) => c.key === "class"), l = i && i.value.split(/\s+/).includes("rte"), u = a.find(
|
|
318
321
|
(c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
|
|
@@ -323,17 +326,17 @@ const Vt = rt((e) => {
|
|
|
323
326
|
), D = a.find(
|
|
324
327
|
(c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
|
|
325
328
|
);
|
|
326
|
-
if (
|
|
327
|
-
...
|
|
329
|
+
if (e = {
|
|
330
|
+
...e,
|
|
328
331
|
...Dt(t),
|
|
329
|
-
...
|
|
332
|
+
...et(t),
|
|
330
333
|
...It(t)
|
|
331
334
|
}, t.attributes) {
|
|
332
|
-
const c = t.attributes.find((p) => B(
|
|
333
|
-
c && (
|
|
335
|
+
const c = t.attributes.find((p) => B(nt, p.key));
|
|
336
|
+
c && (e._name = c.value);
|
|
334
337
|
}
|
|
335
338
|
if (o || l)
|
|
336
|
-
return
|
|
339
|
+
return e.content = `<p>${C(t.children || [])}</p>`, P(e, "styles_attrs.data-chai-richtext") && delete e.styles_attrs["data-chai-richtext"], P(e, "styles_attrs.chai-richtext") && delete e.styles_attrs["chai-richtext"], [e];
|
|
337
340
|
if (u) {
|
|
338
341
|
const c = [
|
|
339
342
|
"data-chai-lightbox",
|
|
@@ -345,22 +348,22 @@ const Vt = rt((e) => {
|
|
|
345
348
|
"data-gall",
|
|
346
349
|
"href"
|
|
347
350
|
];
|
|
348
|
-
|
|
349
|
-
...
|
|
350
|
-
href: ((
|
|
351
|
-
hrefType: ((
|
|
351
|
+
e = {
|
|
352
|
+
...e,
|
|
353
|
+
href: ((O = a.find((p) => p.key === "href")) == null ? void 0 : O.value) || "",
|
|
354
|
+
hrefType: ((M = a.find((p) => p.key === "data-vbtype")) == null ? void 0 : M.value) || "video",
|
|
352
355
|
autoplay: ((V = a.find((p) => p.key === "data-autoplay")) == null ? void 0 : V.value) === "true" ? "true" : "false",
|
|
353
356
|
maxWidth: ((z = (J = a.find((p) => p.key === "data-maxwidth")) == null ? void 0 : J.value) == null ? void 0 : z.replace("px", "")) || "",
|
|
354
357
|
backdropColor: ((F = a.find((p) => p.key === "data-overlay")) == null ? void 0 : F.value) || "",
|
|
355
358
|
galleryName: ((U = a.find((p) => p.key === "data-gall")) == null ? void 0 : U.value) || ""
|
|
356
359
|
}, N(c, (p) => {
|
|
357
|
-
|
|
360
|
+
P(e, `styles_attrs.${p}`) && delete e.styles_attrs[p];
|
|
358
361
|
});
|
|
359
362
|
}
|
|
360
|
-
if (r && (delete
|
|
361
|
-
delete
|
|
362
|
-
const c =
|
|
363
|
-
|
|
363
|
+
if (r && (delete e.styles_attrs, e.showDropdown = !1), D && delete e.styles_attrs, T) {
|
|
364
|
+
delete e.styles_attrs;
|
|
365
|
+
const c = Q(t.children || [], (d) => (d == null ? void 0 : d.tagName) !== "span");
|
|
366
|
+
e.content = j(c);
|
|
364
367
|
const p = m(
|
|
365
368
|
t.children || [],
|
|
366
369
|
(d) => (d == null ? void 0 : d.tagName) === "span" && yt(d.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
@@ -368,70 +371,70 @@ const Vt = rt((e) => {
|
|
|
368
371
|
if (p) {
|
|
369
372
|
const d = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
370
373
|
if (d) {
|
|
371
|
-
|
|
374
|
+
e.icon = C([d]);
|
|
372
375
|
const { height: h, width: g } = Ct(d, "16px", "16px");
|
|
373
|
-
|
|
376
|
+
e.iconHeight = h, e.iconWidth = g;
|
|
374
377
|
}
|
|
375
378
|
}
|
|
376
|
-
return [
|
|
379
|
+
return [e];
|
|
377
380
|
}
|
|
378
|
-
if (
|
|
379
|
-
const c =
|
|
380
|
-
c === "checkbox" ? w(
|
|
381
|
+
if (e._type === "Input") {
|
|
382
|
+
const c = e.inputType || "text";
|
|
383
|
+
c === "checkbox" ? w(e, "_type", "Checkbox") : c === "radio" && w(e, "_type", "Radio");
|
|
381
384
|
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
382
385
|
const c = C([t]);
|
|
383
|
-
return Et(c) && (w(
|
|
386
|
+
return Et(c) && (w(e, "_type", "Video"), w(e, "url", $t(c)), w(e, "styles", `${x},`), w(e, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), e.content = c, [e];
|
|
384
387
|
} else if (t.tagName === "svg") {
|
|
385
|
-
const c = y(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: d } =
|
|
388
|
+
const c = y(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: d } = ot(c);
|
|
386
389
|
if (p && d)
|
|
387
|
-
|
|
390
|
+
e.styles = `${x}, ${R(`w-${d} h-${p}`, c)}`.trim(), e.height = p == null ? void 0 : p.replace("px", ""), e.width = d == null ? void 0 : d.replace("px", "");
|
|
388
391
|
else {
|
|
389
392
|
const h = (Y = m(t.attributes, { key: "height" })) == null ? void 0 : Y.value, g = (K = m(t.attributes, { key: "width" })) == null ? void 0 : K.value;
|
|
390
|
-
h && g ? (
|
|
393
|
+
h && g ? (e.styles = `${x}, ${R(`w-[${g}px] h-[${h}px]`, c)}`.trim(), e.height = h, e.width = g) : e.styles = `${x}, ${R("w-full h-full", c)}`.trim();
|
|
391
394
|
}
|
|
392
|
-
return t.attributes =
|
|
395
|
+
return t.attributes = Q(t.attributes, (h) => !B(["style", "width", "height", "class"], h.key)), e.icon = C([t]), [e];
|
|
393
396
|
} else if (t.tagName == "option" && n && ((X = n.block) == null ? void 0 : X._type) === "Select")
|
|
394
397
|
return n.block.options.push({
|
|
395
|
-
label:
|
|
396
|
-
...
|
|
398
|
+
label: j(t.children || []),
|
|
399
|
+
...et(t)
|
|
397
400
|
}), [];
|
|
398
|
-
const E =
|
|
399
|
-
return [
|
|
400
|
-
}), Ct = (
|
|
401
|
+
const E = H(t.children || [], { block: e, node: t });
|
|
402
|
+
return [e, ...E];
|
|
403
|
+
}), Ct = (s, n, t) => {
|
|
401
404
|
var u, r;
|
|
402
|
-
const
|
|
403
|
-
y(m(
|
|
405
|
+
const e = y(s, "attributes", []), { height: a, width: o } = ot(
|
|
406
|
+
y(m(e, { key: "class" }), "value", "")
|
|
404
407
|
);
|
|
405
408
|
if (a && o)
|
|
406
409
|
return {
|
|
407
410
|
height: `[${a}px]`,
|
|
408
411
|
width: `[${o}px]`
|
|
409
412
|
};
|
|
410
|
-
const i = (u = m(
|
|
413
|
+
const i = (u = m(e, { key: "height" })) == null ? void 0 : u.value, l = (r = m(e, { key: "width" })) == null ? void 0 : r.value;
|
|
411
414
|
return {
|
|
412
415
|
height: i ? `[${i}px]` : t,
|
|
413
416
|
width: l ? `[${l}px]` : n
|
|
414
417
|
};
|
|
415
|
-
}, Lt = (
|
|
416
|
-
|
|
418
|
+
}, Lt = (s) => {
|
|
419
|
+
s = s.replace(/(\w+)=\\?"(.*?)\\?"/g, (e, a, o) => {
|
|
417
420
|
let i = o.replace(/\\"/g, '"');
|
|
418
421
|
return i = i.replace(/{([^}]+)}/g, (l) => l.replace(/"/g, '\\"')), `${a}="${i.replace(/\\"/g, '"')}"`;
|
|
419
|
-
}),
|
|
420
|
-
const n =
|
|
421
|
-
return (n && n.length > 0 ? n[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") :
|
|
422
|
-
}, Ft = (
|
|
423
|
-
const n = _t(Lt(
|
|
424
|
-
if (_(
|
|
425
|
-
const t =
|
|
422
|
+
}), s = s.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), s = s.replace(/\$name="[^"]*"/g, "");
|
|
423
|
+
const n = s.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
424
|
+
return (n && n.length > 0 ? n[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : s).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
425
|
+
}, Ft = (s) => {
|
|
426
|
+
const n = _t(Lt(s));
|
|
427
|
+
if (_(s)) return [];
|
|
428
|
+
const t = pt(H(n));
|
|
426
429
|
return vt(t);
|
|
427
|
-
}, f = (
|
|
428
|
-
const
|
|
429
|
-
return xt(
|
|
430
|
-
t[a] = `${x},${
|
|
430
|
+
}, f = (s, n) => s.map((t) => {
|
|
431
|
+
const e = W(t).filter((a) => $(t[a]) && t[a].startsWith(x));
|
|
432
|
+
return xt(e, (a) => {
|
|
433
|
+
t[a] = `${x},${at(t[a], n)}`;
|
|
431
434
|
}), t;
|
|
432
435
|
});
|
|
433
436
|
import.meta.vitest && describe("applyDesignTokens", () => {
|
|
434
|
-
const
|
|
437
|
+
const s = {
|
|
435
438
|
"dt#token1": { name: "primary-color", value: "bg-blue-500" },
|
|
436
439
|
"dt#token2": { name: "text-size", value: "text-lg" },
|
|
437
440
|
"dt#token3": { name: "spacing", value: "p-4" }
|
|
@@ -459,29 +462,29 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
459
462
|
}
|
|
460
463
|
];
|
|
461
464
|
it("should process blocks and replace style properties with generated class names", () => {
|
|
462
|
-
const t = f(n,
|
|
465
|
+
const t = f(n, s);
|
|
463
466
|
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");
|
|
464
467
|
}), it("should handle blocks with no style properties", () => {
|
|
465
|
-
const t = f(n,
|
|
468
|
+
const t = f(n, s);
|
|
466
469
|
expect(t[2].noStyles).toBe("regular-string"), expect(t[2]._id).toBe("block3");
|
|
467
470
|
}), it("should handle empty blocks array", () => {
|
|
468
|
-
const t = f([],
|
|
471
|
+
const t = f([], s);
|
|
469
472
|
expect(t).toEqual([]);
|
|
470
473
|
}), it("should handle empty design tokens", () => {
|
|
471
474
|
const t = f(n, {});
|
|
472
475
|
expect(t[0].styles).toBe("#styles:,bg-white text-sm");
|
|
473
476
|
}), it("should handle blocks with only style prefix", () => {
|
|
474
|
-
const
|
|
477
|
+
const e = f([
|
|
475
478
|
{
|
|
476
479
|
_id: "block1",
|
|
477
480
|
_type: "div",
|
|
478
481
|
styles: "#styles:",
|
|
479
482
|
_name: "Prefix Only"
|
|
480
483
|
}
|
|
481
|
-
],
|
|
482
|
-
expect(
|
|
484
|
+
], s);
|
|
485
|
+
expect(e[0].styles).toBe("#styles:,");
|
|
483
486
|
}), it("should handle blocks with multiple style properties", () => {
|
|
484
|
-
const
|
|
487
|
+
const e = f([
|
|
485
488
|
{
|
|
486
489
|
_id: "block1",
|
|
487
490
|
_type: "div",
|
|
@@ -490,10 +493,10 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
490
493
|
focusStyles: "#styles:outline-none dt#token3",
|
|
491
494
|
_name: "Multi Style"
|
|
492
495
|
}
|
|
493
|
-
],
|
|
494
|
-
expect(
|
|
496
|
+
], s);
|
|
497
|
+
expect(e[0].styles).toBe("#styles:,bg-white"), expect(e[0].hoverStyles).toBe("#styles:,text-lg bg-gray-100"), expect(e[0].focusStyles).toBe("#styles:,p-4 outline-none");
|
|
495
498
|
}), it("should not modify non-string properties that start with #styles:", () => {
|
|
496
|
-
const
|
|
499
|
+
const e = f([
|
|
497
500
|
{
|
|
498
501
|
_id: "block1",
|
|
499
502
|
_type: "div",
|
|
@@ -502,10 +505,10 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
502
505
|
arrayStyles: ["#styles:bg-red-500"],
|
|
503
506
|
_name: "Non String Styles"
|
|
504
507
|
}
|
|
505
|
-
],
|
|
506
|
-
expect(
|
|
508
|
+
], s);
|
|
509
|
+
expect(e[0].styles).toBe("#styles:,bg-white"), expect(e[0].objectStyles).toEqual({ startsWith: "#styles:" }), expect(e[0].arrayStyles).toEqual(["#styles:bg-red-500"]);
|
|
507
510
|
}), it("should handle undefined and null values", () => {
|
|
508
|
-
const
|
|
511
|
+
const e = f([
|
|
509
512
|
{
|
|
510
513
|
_id: "block1",
|
|
511
514
|
_type: "div",
|
|
@@ -514,11 +517,11 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
514
517
|
undefinedStyles: void 0,
|
|
515
518
|
_name: " Null Undefined"
|
|
516
519
|
}
|
|
517
|
-
],
|
|
518
|
-
expect(
|
|
520
|
+
], s);
|
|
521
|
+
expect(e[0].styles).toBe("#styles:,bg-white"), expect(e[0].nullStyles).toBeNull(), expect(e[0].undefinedStyles).toBeUndefined();
|
|
519
522
|
}), it("should preserve block structure and non-style properties", () => {
|
|
520
|
-
f(n,
|
|
521
|
-
expect(
|
|
523
|
+
f(n, s).forEach((e, a) => {
|
|
524
|
+
expect(e._id).toBe(n[a]._id), expect(e._type).toBe(n[a]._type), expect(e._name).toBe(n[a]._name);
|
|
522
525
|
});
|
|
523
526
|
}), it("should handle complex design token values", () => {
|
|
524
527
|
const a = f([
|
|
@@ -548,21 +551,21 @@ import.meta.vitest && describe("applyDesignTokens", () => {
|
|
|
548
551
|
expect(a[0].styles).toBe("#styles:,bg-white");
|
|
549
552
|
});
|
|
550
553
|
});
|
|
551
|
-
const v = (
|
|
552
|
-
const n = ft(
|
|
553
|
-
return
|
|
554
|
-
const
|
|
555
|
-
for (let a = 0; a <
|
|
556
|
-
if ($(t[
|
|
554
|
+
const v = (s) => {
|
|
555
|
+
const n = ft(s);
|
|
556
|
+
return s.map((t) => {
|
|
557
|
+
const e = Object.keys(t);
|
|
558
|
+
for (let a = 0; a < e.length; a++)
|
|
559
|
+
if ($(t[e[a]]) && k(e[a], "content")) {
|
|
557
560
|
const o = t === n ? "" : " ";
|
|
558
|
-
t[
|
|
561
|
+
t[e[a]] = `${t[e[a]].trim()}${o}`;
|
|
559
562
|
}
|
|
560
563
|
return t;
|
|
561
564
|
});
|
|
562
565
|
};
|
|
563
566
|
if (import.meta.vitest) {
|
|
564
|
-
const { describe:
|
|
565
|
-
|
|
567
|
+
const { describe: s, it: n, expect: t } = import.meta.vitest;
|
|
568
|
+
s("adjustSpacingInContentBlocks", () => {
|
|
566
569
|
n("should add space after content fields except for the last block", () => {
|
|
567
570
|
const a = v([
|
|
568
571
|
{ _id: "1", _type: "Text", content: "First" },
|
|
@@ -615,14 +618,14 @@ if (import.meta.vitest) {
|
|
|
615
618
|
});
|
|
616
619
|
});
|
|
617
620
|
}
|
|
618
|
-
const b = (
|
|
619
|
-
if ($(
|
|
620
|
-
let o =
|
|
621
|
-
const i = /\{\{(.*?)\}\}/g, l =
|
|
621
|
+
const b = (s, n, { index: t, key: e }, a) => {
|
|
622
|
+
if ($(s)) {
|
|
623
|
+
let o = s;
|
|
624
|
+
const i = /\{\{(.*?)\}\}/g, l = s.match(i);
|
|
622
625
|
if (l) {
|
|
623
626
|
const u = a === "image" || a === "mobileImage";
|
|
624
627
|
l.forEach((r) => {
|
|
625
|
-
let T = r.slice(2, -2).trim(), D =
|
|
628
|
+
let T = r.slice(2, -2).trim(), D = e.slice(2, -2).trim();
|
|
626
629
|
t !== -1 && k(T, "$index.") ? T = `${D}.${t}.${T.slice(7)}` : t !== -1 && k(T, "$index") && (T = `${D}.${t}`);
|
|
627
630
|
const E = y(n, T);
|
|
628
631
|
E === void 0 ? o = o.replace(r, "") : u && !I(E) ? o = E : o = I(E) ? E : o.replace(r, E);
|
|
@@ -630,18 +633,23 @@ const b = (e, n, { index: t, key: s }, a) => {
|
|
|
630
633
|
}
|
|
631
634
|
return o;
|
|
632
635
|
}
|
|
633
|
-
if (I(
|
|
634
|
-
return
|
|
635
|
-
if (
|
|
636
|
+
if (I(s))
|
|
637
|
+
return s.map((o) => b(o, n, { index: t, key: e }, a));
|
|
638
|
+
if (s && typeof s == "object") {
|
|
636
639
|
const o = {};
|
|
637
|
-
return N(
|
|
638
|
-
!k(i, "_") && i !== "$repeaterItemsKey" ? o[i] = b(
|
|
640
|
+
return N(W(s), (i) => {
|
|
641
|
+
!k(i, "_") && i !== "$repeaterItemsKey" ? o[i] = b(
|
|
642
|
+
s[i],
|
|
643
|
+
n,
|
|
644
|
+
{ index: t, key: e },
|
|
645
|
+
i
|
|
646
|
+
) : o[i] = s[i];
|
|
639
647
|
}), o;
|
|
640
648
|
}
|
|
641
|
-
return
|
|
642
|
-
}, L = (
|
|
643
|
-
let a = q(
|
|
644
|
-
return a.repeaterItems && (a.$repeaterItemsKey = a.repeaterItems, k(a.repeaterItems, `{{${Bt}`) && (a.$repeaterItemsKey = a.repeaterItems = `${a.repeaterItems.replace("}}", `/${a._id}}}`)}`), !_(a.repeaterItems) && a.pagination && (a.repeaterTotalItems = `${a.repeaterItems.replace("}}", `/${a._id}/totalItems}}`)}`)), b(a, n, { index: t, key:
|
|
649
|
+
return s;
|
|
650
|
+
}, L = (s, n, { index: t, key: e }) => {
|
|
651
|
+
let a = q(s);
|
|
652
|
+
return a.repeaterItems && (a.$repeaterItemsKey = a.repeaterItems, k(a.repeaterItems, `{{${Bt}`) && (a.$repeaterItemsKey = a.repeaterItems = `${a.repeaterItems.replace("}}", `/${a._id}}}`)}`), !_(a.repeaterItems) && a.pagination && (a.repeaterTotalItems = `${a.repeaterItems.replace("}}", `/${a._id}/totalItems}}`)}`)), b(a, n, { index: t, key: e });
|
|
645
653
|
};
|
|
646
654
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
647
655
|
it("should handle string values with bindings", () => {
|
|
@@ -816,18 +824,18 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
816
824
|
}));
|
|
817
825
|
export {
|
|
818
826
|
Bt as C,
|
|
819
|
-
|
|
827
|
+
tt as D,
|
|
820
828
|
qt as R,
|
|
821
829
|
x as S,
|
|
822
830
|
L as a,
|
|
823
|
-
|
|
824
|
-
|
|
831
|
+
Ot as b,
|
|
832
|
+
Mt as c,
|
|
825
833
|
Vt as d,
|
|
826
834
|
Jt as e,
|
|
827
835
|
v as f,
|
|
828
836
|
Ft as g,
|
|
829
837
|
zt as h,
|
|
830
838
|
f as i,
|
|
831
|
-
|
|
832
|
-
|
|
839
|
+
st as j,
|
|
840
|
+
Ht as k
|
|
833
841
|
};
|