@chaibuilder/sdk 2.3.8 → 2.4.1
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/core.cjs +1 -1
- package/dist/core.d.ts +2 -0
- package/dist/core.js +42 -25
- package/dist/render.cjs +2 -2
- package/dist/render.js +114 -103
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +335 -342
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -724,21 +724,49 @@ const useBrandingOptions = () => {
|
|
|
724
724
|
}, useThemeOptions = () => {
|
|
725
725
|
const o = useBuilderProp("themeOptions", (r) => r);
|
|
726
726
|
return useMemo(() => o(defaultThemeOptions), [o]);
|
|
727
|
-
}, rightPanelAtom = atom("block"), useRightPanel = () => useAtom$1(rightPanelAtom),
|
|
727
|
+
}, rightPanelAtom = atom("block"), useRightPanel = () => useAtom$1(rightPanelAtom), languageAtom = atom("");
|
|
728
|
+
languageAtom.debugLabel = "selectedLanguageAtom";
|
|
729
|
+
const useLanguages = () => {
|
|
730
|
+
const o = useBuilderProp("languages", []), n = useBuilderProp("fallbackLang", "en"), [r, a] = useAtom$1(languageAtom), l = (i) => {
|
|
731
|
+
a(n === i ? "" : i);
|
|
732
|
+
};
|
|
733
|
+
return {
|
|
734
|
+
languages: o == null ? void 0 : o.filter((i) => i !== n),
|
|
735
|
+
fallbackLang: n,
|
|
736
|
+
selectedLang: r,
|
|
737
|
+
setSelectedLang: l
|
|
738
|
+
};
|
|
739
|
+
}, builderSaveStateAtom = atom("SAVED");
|
|
728
740
|
builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
|
|
741
|
+
const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
742
|
+
if (!(r != null && r._type) || r._type === "PartialBlock")
|
|
743
|
+
return !1;
|
|
744
|
+
try {
|
|
745
|
+
const a = getRegisteredChaiBlock(r._type);
|
|
746
|
+
return a ? (has(a, "i18nProps") ? a.i18nProps : []).some((i) => {
|
|
747
|
+
const c = `${i}-${n}`;
|
|
748
|
+
return !r[c] || isEmpty(r[c]);
|
|
749
|
+
}) : !1;
|
|
750
|
+
} catch (a) {
|
|
751
|
+
return console.warn(`Failed to get block definition for type: ${r._type}`, a), !1;
|
|
752
|
+
}
|
|
753
|
+
}) : !1, useSavePage = () => {
|
|
754
|
+
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (m) => {
|
|
755
|
+
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), u = () => {
|
|
756
|
+
const m = l();
|
|
757
|
+
return !d || d === p ? !1 : checkMissingTranslations(m.blocks || [], d);
|
|
758
|
+
};
|
|
732
759
|
return { savePage: useThrottledCallback(
|
|
733
|
-
async (
|
|
760
|
+
async (m = !1) => {
|
|
734
761
|
if (!c("save_page"))
|
|
735
762
|
return;
|
|
736
763
|
n("SAVING"), a("SAVING");
|
|
737
|
-
const
|
|
764
|
+
const f = l();
|
|
738
765
|
return await r({
|
|
739
|
-
autoSave:
|
|
740
|
-
blocks:
|
|
741
|
-
theme: i
|
|
766
|
+
autoSave: m,
|
|
767
|
+
blocks: f.blocks,
|
|
768
|
+
theme: i,
|
|
769
|
+
needTranslations: u()
|
|
742
770
|
}), setTimeout(() => {
|
|
743
771
|
n("SAVED"), a("SAVED");
|
|
744
772
|
}, 100), !0;
|
|
@@ -750,15 +778,16 @@ const useSavePage = () => {
|
|
|
750
778
|
if (!c("save_page"))
|
|
751
779
|
return;
|
|
752
780
|
n("SAVING"), a("SAVING");
|
|
753
|
-
const
|
|
781
|
+
const m = l();
|
|
754
782
|
return await r({
|
|
755
783
|
autoSave: !0,
|
|
756
|
-
blocks:
|
|
757
|
-
theme: i
|
|
784
|
+
blocks: m.blocks,
|
|
785
|
+
theme: i,
|
|
786
|
+
needTranslations: u()
|
|
758
787
|
}), setTimeout(() => {
|
|
759
788
|
n("SAVED"), a("SAVED");
|
|
760
789
|
}, 100), !0;
|
|
761
|
-
}, saveState: o, setSaveState: n };
|
|
790
|
+
}, saveState: o, setSaveState: n, needTranslations: u };
|
|
762
791
|
}, undoManager = new UndoManager();
|
|
763
792
|
undoManager.setLimit(50);
|
|
764
793
|
const undoRedoStateAtom = atom({
|
|
@@ -2248,18 +2277,6 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
|
|
|
2248
2277
|
yo: "Yoruba",
|
|
2249
2278
|
za: "Zhuang, Chuang",
|
|
2250
2279
|
zu: "Zulu"
|
|
2251
|
-
}, languageAtom = atom("");
|
|
2252
|
-
languageAtom.debugLabel = "selectedLanguageAtom";
|
|
2253
|
-
const useLanguages = () => {
|
|
2254
|
-
const o = useBuilderProp("languages", []), n = useBuilderProp("fallbackLang", "en"), [r, a] = useAtom$1(languageAtom), l = (i) => {
|
|
2255
|
-
a(n === i ? "" : i);
|
|
2256
|
-
};
|
|
2257
|
-
return {
|
|
2258
|
-
languages: o == null ? void 0 : o.filter((i) => i !== n),
|
|
2259
|
-
fallbackLang: n,
|
|
2260
|
-
selectedLang: r,
|
|
2261
|
-
setSelectedLang: l
|
|
2262
|
-
};
|
|
2263
2280
|
}, updatePropsForLanguage = (o, n, r) => {
|
|
2264
2281
|
const a = getRegisteredChaiBlock(get(r, "_type"));
|
|
2265
2282
|
if (!a) return o;
|
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./plugin-CSgw-f78.cjs"),p=require("./apply-binding-DpBwzIf9.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./plugin-CSgw-f78.cjs"),p=require("./apply-binding-DpBwzIf9.cjs"),t=require("lodash-es"),q=require("@tailwindcss/aspect-ratio"),$=require("@tailwindcss/forms"),E=require("@tailwindcss/typography");require("tailwindcss-animate");const F=require("./get-chai-builder-theme-B1tr_NJB.cjs"),L=require("@mhsdesign/jit-browser-tailwindcss"),R=require("@tailwindcss/container-queries"),m=require("react/jsx-runtime"),u=require("react"),D=require("@chaibuilder/runtime");function M(e,a){const r=e.filter(({_type:n})=>n==="GlobalBlock"||n==="PartialBlock");for(let n=0;n<r.length;n++){const l=r[n],s=t.get(l,"partialBlockId",t.get(l,"globalBlock",""));if(s==="")continue;let i=t.cloneDeep(t.get(a,s,[]));l._parent&&(i==null?void 0:i.length)>0&&(i=i.map(c=>(t.isEmpty(c._parent)&&(c._parent=l._parent),c)));const o=e.indexOf(l);e.splice(o,1,...i)}return e}const O=e=>{if(!e)return[];try{return JSON.parse(j(e)).filter(r=>!r._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function j(e){const a=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(a,r=>{const n=decodeURIComponent(r),l=n.indexOf("public");return l!==-1?n.substring(l+6):n})}async function K(e,a,r=[],n="",l){return await L.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:r,theme:{extend:F.getChaiBuilderTheme(e)},plugins:[$,E,q,R,y.chaiBuilderPlugin],corePlugins:{preflight:l},...n?{prefix:`${n}`}:{}}}).generateStylesFromContent(` ${l?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,
|
|
3
|
+
@tailwind utilities;`,a)}const A=(e,a,r)=>{const n=JSON.stringify(e).replace(/#styles:([^"]*)/g,(l,s)=>`#styles:${s.replace(/,/g," ")}`.replace(/#styles:/g,""));return K(a,[n],[],"",r)},N=async(e,a=y.defaultThemeOptions,r=!1)=>await A(e,a,r),_=new Map;function J(e){return JSON.stringify({blockType:t.omit(e.block,"_id","_name","_parent"),lang:e.lang})}async function V(e){const a={pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1},r=J(t.pick(a,["block","lang"]));let n=_.get(r);n||(n=Promise.resolve(e.dataProvider(a)),_.set(r,n),setTimeout(()=>{_.delete(r)},5*1e3));const l=await n;return t.has(l,"$metadata")&&t.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,l.$metadata),e.children({...t.omit(l,"$metadata")})}const U=()=>m.jsx("div",{}),W=e=>{const{block:a,lang:r,fallbackLang:n,children:l,externalData:s,blocks:i,draft:o,pageProps:c,dataProviderMetadataCallback:h}=e,d=D.getRegisteredChaiBlock(a._type),f=t.get(d,"component",null),k=t.get(e.repeaterData,"index",-1),C=t.get(e.repeaterData,"dataKey",""),w=r===n?"":r,g=p.applyBindingToBlockProps(p.applyLanguage(a,w,d),s,{index:k,key:C}),S=p.getBlockTagAttributes(a,!1),T=G(i,a._id,p.getBlockRuntimeProps(a._type)),v=t.has(d,"dataProvider")&&t.isFunction(d.dataProvider),P={...g,...S,...T},b={blockProps:{},inBuilder:!1,lang:r||n,...P};if(t.isNull(f))return null;if(v){const x=t.get(d,"suspenseFallback",U);return m.jsx(u.Suspense,{fallback:u.createElement(x),children:m.jsx(V,{lang:r,pageProps:c,block:P,dataProvider:d.dataProvider,...h?{dataProviderMetadataCallback:h}:{},draft:o,children:I=>u.createElement(f,{...b,...I,children:l({_id:a._id,_type:a._type,...t.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,a),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})})}return m.jsx(u.Suspense,{children:u.createElement(f,{...b,children:l({_id:a._id,_type:a._type,...t.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,a),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})},B=e=>{const{blocks:a,parent:r,repeaterData:n}=e;let l=t.uniqBy(t.filter(a,i=>t.has(i,"_id")&&(t.isEmpty(r)?!i._parent:i._parent===r)),"_id");const s=i=>t.filter(a,o=>o._parent===i).length>0;return t.map(l,i=>i?u.createElement(W,{...e,key:i._id,block:i},({_id:o,_type:c,repeaterItems:h,$repeaterItemsKey:d})=>c==="Repeater"?t.isArray(h)&&h.map((f,k)=>u.createElement(B,{...e,parent:i._id,key:`${t.get(i,"_parent","root")}-${i._id}-${k}`,repeaterData:{index:k,dataKey:d}})):s(o)?u.createElement(B,{...e,parent:i._id,key:`${t.get(i,"_parent","root")}-${i._id}`,repeaterData:n}):null):null)},G=(e,a,r)=>t.isEmpty(r)?{}:Object.entries(r).reduce((n,[l,s])=>{const i=[];let o=t.find(e,{_id:a});for(;o;)i.push(o),o=t.find(e,{_id:o._parent});const c=t.find(i,{_type:s.block});return c&&(n[l]=t.get(c,t.get(s,"prop"),null)),n},{});function z(e){if(t.isEmpty(e.lang)&&!t.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(t.isEmpty(e.blocks))return null;const a=e.lang??"en",r=e.fallbackLang??a;return m.jsx(B,{...e,lang:a,fallbackLang:r})}exports.getChaiThemeCssVariables=y.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=y.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=y.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=p.applyChaiDataBinding;exports.RenderChaiBlocks=z;exports.convertToBlocks=O;exports.getMergedPartialBlocks=M;exports.getStylesForBlocks=N;
|
package/dist/render.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { d as F, c as
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as
|
|
4
|
-
import { e as
|
|
5
|
-
import { get as s, cloneDeep as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import { d as F, c as M } from "./plugin-BOcGV_IY.js";
|
|
2
|
+
import { a as Ie, b as $e, e as Te } from "./plugin-BOcGV_IY.js";
|
|
3
|
+
import { a as A, b as N, g as J, c as E, d as v } from "./apply-binding-CkrtJykq.js";
|
|
4
|
+
import { e as De } from "./apply-binding-CkrtJykq.js";
|
|
5
|
+
import { get as s, cloneDeep as j, isEmpty as g, pick as q, has as B, isFunction as I, omit as $, isNull as U, isArray as P, uniqBy as V, filter as S, map as W, find as y } from "lodash-es";
|
|
6
|
+
import G from "@tailwindcss/aspect-ratio";
|
|
7
|
+
import z from "@tailwindcss/forms";
|
|
8
|
+
import H from "@tailwindcss/typography";
|
|
9
9
|
import "tailwindcss-animate";
|
|
10
|
-
import { g as
|
|
11
|
-
import { createTailwindcss as
|
|
12
|
-
import
|
|
13
|
-
import { jsx as
|
|
14
|
-
import { Suspense as
|
|
15
|
-
import { getRegisteredChaiBlock as
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
for (let
|
|
19
|
-
const i = r
|
|
20
|
-
if (
|
|
21
|
-
let
|
|
22
|
-
i._parent && (
|
|
23
|
-
const
|
|
24
|
-
e.splice(
|
|
10
|
+
import { g as Q } from "./get-chai-builder-theme-BarMkcGH.js";
|
|
11
|
+
import { createTailwindcss as X } from "@mhsdesign/jit-browser-tailwindcss";
|
|
12
|
+
import Y from "@tailwindcss/container-queries";
|
|
13
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
14
|
+
import { Suspense as x, createElement as u } from "react";
|
|
15
|
+
import { getRegisteredChaiBlock as Z } from "@chaibuilder/runtime";
|
|
16
|
+
function Be(e, t) {
|
|
17
|
+
const a = e.filter(({ _type: r }) => r === "GlobalBlock" || r === "PartialBlock");
|
|
18
|
+
for (let r = 0; r < a.length; r++) {
|
|
19
|
+
const i = a[r], o = s(i, "partialBlockId", s(i, "globalBlock", ""));
|
|
20
|
+
if (o === "") continue;
|
|
21
|
+
let n = j(s(t, o, []));
|
|
22
|
+
i._parent && (n == null ? void 0 : n.length) > 0 && (n = n.map((c) => (g(c._parent) && (c._parent = i._parent), c)));
|
|
23
|
+
const l = e.indexOf(i);
|
|
24
|
+
e.splice(l, 1, ...n);
|
|
25
25
|
}
|
|
26
26
|
return e;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const we = (e) => {
|
|
29
29
|
if (!e) return [];
|
|
30
30
|
try {
|
|
31
|
-
return JSON.parse(
|
|
31
|
+
return JSON.parse(ee(e)).filter((a) => !a._type.startsWith("@chai"));
|
|
32
32
|
} catch {
|
|
33
33
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
function
|
|
36
|
+
function ee(e) {
|
|
37
37
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
38
|
-
return e.replace(t, (
|
|
39
|
-
const
|
|
40
|
-
return i !== -1 ?
|
|
38
|
+
return e.replace(t, (a) => {
|
|
39
|
+
const r = decodeURIComponent(a), i = r.indexOf("public");
|
|
40
|
+
return i !== -1 ? r.substring(i + 6) : r;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
44
|
-
return await
|
|
43
|
+
async function te(e, t, a = [], r = "", i) {
|
|
44
|
+
return await X({
|
|
45
45
|
tailwindConfig: {
|
|
46
46
|
darkMode: "class",
|
|
47
|
-
safelist:
|
|
48
|
-
theme: { extend:
|
|
49
|
-
plugins: [
|
|
47
|
+
safelist: a,
|
|
48
|
+
theme: { extend: Q(e) },
|
|
49
|
+
plugins: [z, H, G, Y, M],
|
|
50
50
|
corePlugins: { preflight: i },
|
|
51
|
-
...
|
|
51
|
+
...r ? { prefix: `${r}` } : {}
|
|
52
52
|
}
|
|
53
53
|
}).generateStylesFromContent(
|
|
54
54
|
` ${i ? "@tailwind base;" : ""}
|
|
@@ -57,57 +57,68 @@ async function Z(e, t, r = [], n = "", i) {
|
|
|
57
57
|
t
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
return
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const ae = (e, t, a) => {
|
|
61
|
+
const r = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, o) => `#styles:${o.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
62
|
+
return te(t, [r], [], "", a);
|
|
63
|
+
}, Ce = async (e, t = F, a = !1) => await ae(e, t, a), _ = /* @__PURE__ */ new Map();
|
|
64
|
+
function re(e) {
|
|
65
|
+
return JSON.stringify({
|
|
66
|
+
blockType: $(e.block, "_id", "_name", "_parent"),
|
|
67
|
+
lang: e.lang
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async function ne(e) {
|
|
71
|
+
const t = {
|
|
66
72
|
pageProps: e.pageProps,
|
|
67
73
|
block: e.block,
|
|
68
74
|
lang: e.lang,
|
|
69
75
|
draft: e.draft,
|
|
70
76
|
inBuilder: !1
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
}, a = re(q(t, ["block", "lang"]));
|
|
78
|
+
let r = _.get(a);
|
|
79
|
+
r || (r = Promise.resolve(e.dataProvider(t)), _.set(a, r), setTimeout(() => {
|
|
80
|
+
_.delete(a);
|
|
81
|
+
}, 5 * 1e3));
|
|
82
|
+
const i = await r;
|
|
83
|
+
return B(i, "$metadata") && I(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, i.$metadata), e.children({
|
|
84
|
+
...$(i, "$metadata")
|
|
74
85
|
});
|
|
75
86
|
}
|
|
76
|
-
const
|
|
77
|
-
const { block: t, lang:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{ index: k, key:
|
|
81
|
-
),
|
|
87
|
+
const ie = () => /* @__PURE__ */ f("div", {}), oe = (e) => {
|
|
88
|
+
const { block: t, lang: a, fallbackLang: r, children: i, externalData: o, blocks: n, draft: l, pageProps: c, dataProviderMetadataCallback: m } = e, d = Z(t._type), h = s(d, "component", null), k = s(e.repeaterData, "index", -1), T = s(e.repeaterData, "dataKey", ""), p = A(
|
|
89
|
+
N(t, a === r ? "" : a, d),
|
|
90
|
+
o,
|
|
91
|
+
{ index: k, key: T }
|
|
92
|
+
), L = J(t, !1), D = le(n, t._id, E(t._type)), K = B(d, "dataProvider") && I(d.dataProvider), w = {
|
|
82
93
|
...p,
|
|
83
|
-
|
|
84
|
-
...
|
|
85
|
-
},
|
|
94
|
+
...L,
|
|
95
|
+
...D
|
|
96
|
+
}, C = {
|
|
86
97
|
blockProps: {},
|
|
87
98
|
inBuilder: !1,
|
|
88
|
-
lang:
|
|
89
|
-
...
|
|
99
|
+
lang: a || r,
|
|
100
|
+
...w
|
|
90
101
|
};
|
|
91
|
-
if (
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
94
|
-
return /* @__PURE__ */
|
|
95
|
-
|
|
102
|
+
if (U(h)) return null;
|
|
103
|
+
if (K) {
|
|
104
|
+
const O = s(d, "suspenseFallback", ie);
|
|
105
|
+
return /* @__PURE__ */ f(x, { fallback: u(O), children: /* @__PURE__ */ f(
|
|
106
|
+
ne,
|
|
96
107
|
{
|
|
97
|
-
lang:
|
|
108
|
+
lang: a,
|
|
98
109
|
pageProps: c,
|
|
99
|
-
block:
|
|
110
|
+
block: w,
|
|
100
111
|
dataProvider: d.dataProvider,
|
|
101
|
-
...
|
|
102
|
-
draft:
|
|
103
|
-
children: (R) =>
|
|
104
|
-
...
|
|
112
|
+
...m ? { dataProviderMetadataCallback: m } : {},
|
|
113
|
+
draft: l,
|
|
114
|
+
children: (R) => u(h, {
|
|
115
|
+
...C,
|
|
105
116
|
...R,
|
|
106
117
|
children: i({
|
|
107
118
|
_id: t._id,
|
|
108
119
|
_type: t._type,
|
|
109
|
-
...
|
|
110
|
-
repeaterItems:
|
|
120
|
+
...P(p.repeaterItems) ? {
|
|
121
|
+
repeaterItems: v(p.repeaterItems, t),
|
|
111
122
|
$repeaterItemsKey: p.$repeaterItemsKey
|
|
112
123
|
} : {}
|
|
113
124
|
})
|
|
@@ -115,64 +126,64 @@ const ae = () => /* @__PURE__ */ m("div", {}), re = (e) => {
|
|
|
115
126
|
}
|
|
116
127
|
) });
|
|
117
128
|
}
|
|
118
|
-
return /* @__PURE__ */
|
|
119
|
-
...
|
|
129
|
+
return /* @__PURE__ */ f(x, { children: u(h, {
|
|
130
|
+
...C,
|
|
120
131
|
children: i({
|
|
121
132
|
_id: t._id,
|
|
122
133
|
_type: t._type,
|
|
123
|
-
...
|
|
124
|
-
repeaterItems:
|
|
134
|
+
...P(p.repeaterItems) ? {
|
|
135
|
+
repeaterItems: v(p.repeaterItems, t),
|
|
125
136
|
$repeaterItemsKey: p.$repeaterItemsKey
|
|
126
137
|
} : {}
|
|
127
138
|
})
|
|
128
139
|
}) });
|
|
129
140
|
}, b = (e) => {
|
|
130
|
-
const { blocks: t, parent:
|
|
131
|
-
let i =
|
|
132
|
-
S(t, (
|
|
141
|
+
const { blocks: t, parent: a, repeaterData: r } = e;
|
|
142
|
+
let i = V(
|
|
143
|
+
S(t, (n) => B(n, "_id") && (g(a) ? !n._parent : n._parent === a)),
|
|
133
144
|
"_id"
|
|
134
145
|
);
|
|
135
|
-
const
|
|
136
|
-
return
|
|
146
|
+
const o = (n) => S(t, (l) => l._parent === n).length > 0;
|
|
147
|
+
return W(i, (n) => n ? /* @__PURE__ */ u(oe, { ...e, key: n._id, block: n }, ({ _id: l, _type: c, repeaterItems: m, $repeaterItemsKey: d }) => c === "Repeater" ? P(m) && m.map((h, k) => /* @__PURE__ */ u(
|
|
137
148
|
b,
|
|
138
149
|
{
|
|
139
150
|
...e,
|
|
140
|
-
parent:
|
|
141
|
-
key: `${s(
|
|
151
|
+
parent: n._id,
|
|
152
|
+
key: `${s(n, "_parent", "root")}-${n._id}-${k}`,
|
|
142
153
|
repeaterData: { index: k, dataKey: d }
|
|
143
154
|
}
|
|
144
|
-
)) : l
|
|
155
|
+
)) : o(l) ? /* @__PURE__ */ u(
|
|
145
156
|
b,
|
|
146
157
|
{
|
|
147
158
|
...e,
|
|
148
|
-
parent:
|
|
149
|
-
key: `${s(
|
|
150
|
-
repeaterData:
|
|
159
|
+
parent: n._id,
|
|
160
|
+
key: `${s(n, "_parent", "root")}-${n._id}`,
|
|
161
|
+
repeaterData: r
|
|
151
162
|
}
|
|
152
163
|
) : null) : null);
|
|
153
|
-
},
|
|
154
|
-
const
|
|
155
|
-
let
|
|
156
|
-
for (;
|
|
157
|
-
|
|
158
|
-
const c = y(
|
|
159
|
-
return c && (
|
|
164
|
+
}, le = (e, t, a) => g(a) ? {} : Object.entries(a).reduce((r, [i, o]) => {
|
|
165
|
+
const n = [];
|
|
166
|
+
let l = y(e, { _id: t });
|
|
167
|
+
for (; l; )
|
|
168
|
+
n.push(l), l = y(e, { _id: l._parent });
|
|
169
|
+
const c = y(n, { _type: o.block });
|
|
170
|
+
return c && (r[i] = s(c, s(o, "prop"), null)), r;
|
|
160
171
|
}, {});
|
|
161
|
-
function
|
|
162
|
-
if (
|
|
172
|
+
function ve(e) {
|
|
173
|
+
if (g(e.lang) && !g(e.fallbackLang))
|
|
163
174
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
164
|
-
if (
|
|
175
|
+
if (g(e.blocks))
|
|
165
176
|
return null;
|
|
166
|
-
const t = e.lang ?? "en",
|
|
167
|
-
return /* @__PURE__ */
|
|
177
|
+
const t = e.lang ?? "en", a = e.fallbackLang ?? t;
|
|
178
|
+
return /* @__PURE__ */ f(b, { ...e, lang: t, fallbackLang: a });
|
|
168
179
|
}
|
|
169
180
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
ve as RenderChaiBlocks,
|
|
182
|
+
De as applyChaiDataBinding,
|
|
183
|
+
we as convertToBlocks,
|
|
184
|
+
Ie as getChaiThemeCssVariables,
|
|
185
|
+
Be as getMergedPartialBlocks,
|
|
186
|
+
Ce as getStylesForBlocks,
|
|
187
|
+
$e as getThemeFontsCSSImport,
|
|
188
|
+
Te as getThemeFontsLinkMarkup
|
|
178
189
|
};
|