@chaibuilder/sdk 2.2.6 → 2.2.7
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/code-editor-B7r9YjDC.cjs +1 -0
- package/dist/{code-editor-BP81Fo3h.js → code-editor-HKrlrH8b.js} +25 -25
- package/dist/core.cjs +66 -1
- package/dist/core.js +9524 -87
- package/dist/new-blocks-render-helpers-BrYtxlrw.js +109 -0
- package/dist/new-blocks-render-helpers-DxkhHL0n.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.js +105 -66
- package/package.json +1 -1
- package/dist/code-editor-CRaw45ej.cjs +0 -1
- package/dist/index-CPwl7tLt.cjs +0 -66
- package/dist/index-DojHY3B4.js +0 -9620
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { getRegisteredChaiBlock as B } from "@chaibuilder/runtime";
|
|
2
|
+
import { memoize as f, get as i, isEmpty as p, cloneDeep as u, forEach as C, keys as _, includes as O, isString as h, startsWith as m, isArray as $ } from "lodash-es";
|
|
3
|
+
import { twMerge as R } from "tailwind-merge";
|
|
4
|
+
const d = "#styles:", N = "__ADD_BLOCK_INTERNAL_ROOT", E = (s) => {
|
|
5
|
+
if (s = s.replace(d, ""), !s) return { baseClasses: "", classes: "" };
|
|
6
|
+
const e = s.split(/,(?![^\[]*\])/);
|
|
7
|
+
if (e.length === 1)
|
|
8
|
+
return { baseClasses: "", classes: e[0].trim() };
|
|
9
|
+
const [t, ...a] = e;
|
|
10
|
+
return {
|
|
11
|
+
baseClasses: t.trim(),
|
|
12
|
+
classes: a.join(",").trim().replace(/ +(?= )/g, "")
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
16
|
+
it("should return the base classes and the classes", () => {
|
|
17
|
+
const s = {
|
|
18
|
+
",styles-2": { baseClasses: "", classes: "styles-2" },
|
|
19
|
+
"styles-1,styles-2": { baseClasses: "styles-1", classes: "styles-2" },
|
|
20
|
+
",bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
21
|
+
baseClasses: "",
|
|
22
|
+
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
23
|
+
},
|
|
24
|
+
"styles-1,bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
25
|
+
baseClasses: "styles-1",
|
|
26
|
+
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
27
|
+
},
|
|
28
|
+
someclass: {
|
|
29
|
+
baseClasses: "",
|
|
30
|
+
classes: "someclass"
|
|
31
|
+
},
|
|
32
|
+
",bg-red-500 text-center font-bold": {
|
|
33
|
+
baseClasses: "",
|
|
34
|
+
classes: "bg-red-500 text-center font-bold"
|
|
35
|
+
},
|
|
36
|
+
"bg-[linear-gradient(-10deg,black,transparent_100%)], bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
37
|
+
baseClasses: "bg-[linear-gradient(-10deg,black,transparent_100%)]",
|
|
38
|
+
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
for (let e in s) {
|
|
42
|
+
const t = E(`${d}${e}`);
|
|
43
|
+
expect(t).toEqual(s[e]);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
function P(s, e, t) {
|
|
48
|
+
const a = i(t, "i18nProps", []);
|
|
49
|
+
if (p(e) || p(a)) return s;
|
|
50
|
+
const r = u(s);
|
|
51
|
+
return C(_(r), (n) => {
|
|
52
|
+
O(a, n) && !p(e) && (r[n] = i(r, `${n}-${e}`, r[n]));
|
|
53
|
+
}), r;
|
|
54
|
+
}
|
|
55
|
+
const D = (s, e, { index: t, key: a }) => {
|
|
56
|
+
const r = u(s);
|
|
57
|
+
return C(_(r), (n) => {
|
|
58
|
+
if (h(r[n]) && !m(n, "_")) {
|
|
59
|
+
let l = r[n];
|
|
60
|
+
n === "repeaterItems" && (r.repeaterItemsBinding = l);
|
|
61
|
+
const y = /\{\{(.*?)\}\}/g, b = l.match(y);
|
|
62
|
+
b && b.forEach((o) => {
|
|
63
|
+
let c = o.slice(2, -2);
|
|
64
|
+
t !== -1 && a !== "" && m(c, "$index.") && (c = `${a.replace(/\{\{(.*)\}\}/g, "$1")}.${c.replace("$index", `${t}`)}`);
|
|
65
|
+
const g = i(e, c, o);
|
|
66
|
+
l = $(g) ? g : l.replace(o, g);
|
|
67
|
+
}), r[n] = l;
|
|
68
|
+
}
|
|
69
|
+
}), r;
|
|
70
|
+
}, x = f((s) => {
|
|
71
|
+
const { baseClasses: e, classes: t } = E(s);
|
|
72
|
+
return R(e, t);
|
|
73
|
+
});
|
|
74
|
+
function T(s, e) {
|
|
75
|
+
return i(s, `${e}_attrs`, {});
|
|
76
|
+
}
|
|
77
|
+
function I(s) {
|
|
78
|
+
const e = {};
|
|
79
|
+
return Object.keys(s).forEach((t) => {
|
|
80
|
+
if (h(s[t]) && s[t].startsWith(d)) {
|
|
81
|
+
const a = x(s[t]), r = T(s, t);
|
|
82
|
+
e[t] = {
|
|
83
|
+
className: a,
|
|
84
|
+
"data-style-prop": t,
|
|
85
|
+
"data-block-parent": s._id,
|
|
86
|
+
"data-style-id": `${t}-${s._id}`,
|
|
87
|
+
...r
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}), e;
|
|
91
|
+
}
|
|
92
|
+
const L = f((s) => {
|
|
93
|
+
const e = B(s), t = i(e, "schema.properties", {});
|
|
94
|
+
return Object.fromEntries(Object.entries(t).filter(([, a]) => i(a, "runtime", !1)));
|
|
95
|
+
}), M = (s, e) => {
|
|
96
|
+
if (!$(s)) return s;
|
|
97
|
+
let t = s, a;
|
|
98
|
+
return typeof e.limit == "number" && e.limit > 0 && (a = e.limit), a !== void 0 && (t = t.slice(0, a)), t;
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
N as R,
|
|
102
|
+
d as S,
|
|
103
|
+
D as a,
|
|
104
|
+
P as b,
|
|
105
|
+
L as c,
|
|
106
|
+
M as d,
|
|
107
|
+
E as e,
|
|
108
|
+
I as g
|
|
109
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const m=require("@chaibuilder/runtime"),e=require("lodash-es"),f=require("tailwind-merge"),p="#styles:",C="__ADD_BLOCK_INTERNAL_ROOT",u=s=>{if(s=s.replace(p,""),!s)return{baseClasses:"",classes:""};const t=s.split(/,(?![^\[]*\])/);if(t.length===1)return{baseClasses:"",classes:t[0].trim()};const[a,...r]=t;return{baseClasses:a.trim(),classes:r.join(",").trim().replace(/ +(?= )/g,"")}};function _(s,t,a){const r=e.get(a,"i18nProps",[]);if(e.isEmpty(t)||e.isEmpty(r))return s;const n=e.cloneDeep(s);return e.forEach(e.keys(n),i=>{e.includes(r,i)&&!e.isEmpty(t)&&(n[i]=e.get(n,`${i}-${t}`,n[i]))}),n}const E=(s,t,{index:a,key:r})=>{const n=e.cloneDeep(s);return e.forEach(e.keys(n),i=>{if(e.isString(n[i])&&!e.startsWith(i,"_")){let l=n[i];i==="repeaterItems"&&(n.repeaterItemsBinding=l);const b=/\{\{(.*?)\}\}/g,d=l.match(b);d&&d.forEach(g=>{let c=g.slice(2,-2);a!==-1&&r!==""&&e.startsWith(c,"$index.")&&(c=`${r.replace(/\{\{(.*)\}\}/g,"$1")}.${c.replace("$index",`${a}`)}`);const o=e.get(t,c,g);l=e.isArray(o)?o:l.replace(g,o)}),n[i]=l}}),n},h=e.memoize(s=>{const{baseClasses:t,classes:a}=u(s);return f.twMerge(t,a)});function y(s,t){return e.get(s,`${t}_attrs`,{})}function $(s){const t={};return Object.keys(s).forEach(a=>{if(e.isString(s[a])&&s[a].startsWith(p)){const r=h(s[a]),n=y(s,a);t[a]={className:r,"data-style-prop":a,"data-block-parent":s._id,"data-style-id":`${a}-${s._id}`,...n}}}),t}const B=e.memoize(s=>{const t=m.getRegisteredChaiBlock(s),a=e.get(t,"schema.properties",{});return Object.fromEntries(Object.entries(a).filter(([,r])=>e.get(r,"runtime",!1)))}),T=(s,t)=>{if(!e.isArray(s))return s;let a=s,r;return typeof t.limit=="number"&&t.limit>0&&(r=t.limit),r!==void 0&&(a=a.slice(0,r)),a};exports.ROOT_TEMP_KEY=C;exports.STYLES_KEY=p;exports.applyBinding=E;exports.applyLanguage=_;exports.applyLimit=T;exports.getBlockRuntimeProps=B;exports.getBlockTagAttributes=$;exports.getSplitChaiClasses=u;
|
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./plugin-C01tjI6V.cjs"),p=require("./new-blocks-render-helpers-DxkhHL0n.cjs"),r=require("lodash-es"),x=require("@tailwindcss/aspect-ratio"),q=require("@tailwindcss/forms"),I=require("@tailwindcss/typography");require("tailwindcss-animate");const R=require("./get-chai-builder-theme-CeaKvOZ8.cjs"),j=require("@mhsdesign/jit-browser-tailwindcss"),F=require("@tailwindcss/container-queries"),u=require("react/jsx-runtime"),m=require("react"),L=require("@chaibuilder/runtime"),E=e=>{if(!e)return[];try{return JSON.parse(O(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function O(e){const t=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(t,n=>{const a=decodeURIComponent(n),s=a.indexOf("public");return s!==-1?a.substring(s+6):a})}async function A(e,t,n=[],a="",s){return await j.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:R.getChaiBuilderTheme(e)},plugins:[q,I,x,F,h.chaiBuilderPlugin],corePlugins:{preflight:s},...a?{prefix:`${a}`}:{}}}).generateStylesFromContent(` ${s?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,t)}const
|
|
3
|
+
@tailwind utilities;`,t)}const D=(e,t,n)=>{const a=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,o)=>`#styles:${o.replace(/,/g," ")}`.replace(/#styles:/g,""));return A(t,[a],[],"",n)},M=async(e,t=h.defaultThemeOptions,n=!1)=>await D(e,t,n);async function $(e){const t=await e.dataProvider({pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1});return r.has(t,"$metadata")&&e.dataProviderMetadataCallback(e.block,t.$metadata),e.children({...r.omit(t,"$metadata")})}const N=()=>u.jsx("div",{}),J=e=>{const{block:t,lang:n,fallbackLang:a,children:s,externalData:o,blocks:i,draft:l,pageProps:g,dataProviderMetadataCallback:k}=e,c=L.getRegisteredChaiBlock(t._type),f=r.get(c,"component",null),y=r.get(e.repeaterData,"index",-1),P=r.get(e.repeaterData,"dataKey",""),_=n===a?"":n,d=p.applyBinding(p.applyLanguage(t,_,c),o,{index:y,key:P}),w=p.getBlockTagAttributes(t),C=K(i,t._id,p.getBlockRuntimeProps(t._type)),S=r.has(c,"dataProvider")&&r.isFunction(c.dataProvider),B={blockProps:{},inBuilder:!1,lang:n||a,...d,...w,...C};if(r.isNull(f))return null;if(S){const v=r.get(c,"suspenseFallback",N);return u.jsx(m.Suspense,{fallback:m.createElement(v),children:u.jsx($,{lang:n,pageProps:g,block:t,dataProvider:c.dataProvider,dataProviderMetadataCallback:k,draft:l,children:T=>m.createElement(f,{...B,...T,children:s({_id:t._id,_type:t._type,...r.isArray(d.repeaterItems)?{repeaterItems:p.applyLimit(d.repeaterItems,t),repeaterItemsBinding:d.repeaterItemsBinding}:{}})})})})}return u.jsx(m.Suspense,{children:m.createElement(f,{...B,children:s({_id:t._id,_type:t._type,...r.isArray(d.repeaterItems)?{repeaterItems:p.applyLimit(d.repeaterItems,t),repeaterItemsBinding:d.repeaterItemsBinding}:{}})})})},b=e=>{const{blocks:t,parent:n,repeaterData:a}=e,s=r.filter(t,i=>r.has(i,"_id")&&(r.isEmpty(n)?!i._parent:i._parent===n)),o=i=>r.filter(t,l=>l._parent===i).length>0;return r.map(s,i=>i?m.createElement(J,{...e,key:i._id,block:i},({_id:l,_type:g,repeaterItems:k,repeaterItemsBinding:c})=>g==="Repeater"?r.isArray(k)&&k.map((f,y)=>u.jsx(b,{...e,parent:i._id,repeaterData:{index:y,dataKey:c}})):o(l)?u.jsx(b,{...e,parent:i._id,repeaterData:a}):null):null)},K=(e,t,n)=>r.isEmpty(n)?{}:Object.entries(n).reduce((a,[s,o])=>{const i=[];let l=r.find(e,{_id:t});for(;l;)i.push(l),l=r.find(e,{_id:l._parent});const g=r.find(i,{_type:o.block});return g&&(a[s]=r.get(g,r.get(o,"prop"),null)),a},{});function V(e){if(r.has(e,"metadata")&&console.warn(" metadata is deprecated and will be removed in upcoming version, use pageProps instead"),r.isEmpty(e.lang)&&!r.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");const t=e.lang??"en",n=e.fallbackLang??t;return u.jsx(b,{...e,lang:t,fallbackLang:n})}exports.getChaiThemeCssVariables=h.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=h.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=h.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=V;exports.convertToBlocks=E;exports.getStylesForBlocks=M;
|
package/dist/render.js
CHANGED
|
@@ -1,101 +1,140 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { d as F, c as D } from "./plugin-fnBB3TCm.js";
|
|
2
|
+
import { a as Pe, b as we, e as Be } from "./plugin-fnBB3TCm.js";
|
|
3
|
+
import { a as O, b as $, g as A, c as N, d as B } from "./new-blocks-render-helpers-BrYtxlrw.js";
|
|
4
|
+
import { has as k, omit as J, get as g, isFunction as M, isNull as E, isArray as _, filter as v, isEmpty as h, map as K, find as y } from "lodash-es";
|
|
5
|
+
import j from "@tailwindcss/aspect-ratio";
|
|
6
|
+
import U from "@tailwindcss/forms";
|
|
7
|
+
import V from "@tailwindcss/typography";
|
|
8
8
|
import "tailwindcss-animate";
|
|
9
|
-
import { g as
|
|
10
|
-
import { createTailwindcss as
|
|
11
|
-
import
|
|
9
|
+
import { g as q } from "./get-chai-builder-theme-ByeXCyGx.js";
|
|
10
|
+
import { createTailwindcss as W } from "@mhsdesign/jit-browser-tailwindcss";
|
|
11
|
+
import z from "@tailwindcss/container-queries";
|
|
12
12
|
import { jsx as d } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
import { getRegisteredChaiBlock as
|
|
15
|
-
const
|
|
13
|
+
import { Suspense as C, createElement as f } from "react";
|
|
14
|
+
import { getRegisteredChaiBlock as G } from "@chaibuilder/runtime";
|
|
15
|
+
const he = (e) => {
|
|
16
16
|
if (!e) return [];
|
|
17
17
|
try {
|
|
18
|
-
return JSON.parse(
|
|
18
|
+
return JSON.parse(H(e)).filter((a) => !a._type.startsWith("@chai"));
|
|
19
19
|
} catch {
|
|
20
20
|
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
function
|
|
23
|
+
function H(e) {
|
|
24
24
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
25
|
-
return e.replace(t, (
|
|
26
|
-
const
|
|
27
|
-
return
|
|
25
|
+
return e.replace(t, (a) => {
|
|
26
|
+
const r = decodeURIComponent(a), i = r.indexOf("public");
|
|
27
|
+
return i !== -1 ? r.substring(i + 6) : r;
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
return await
|
|
30
|
+
async function Q(e, t, a = [], r = "", i) {
|
|
31
|
+
return await W({
|
|
32
32
|
tailwindConfig: {
|
|
33
33
|
darkMode: "class",
|
|
34
|
-
safelist:
|
|
35
|
-
theme: { extend:
|
|
36
|
-
plugins: [
|
|
37
|
-
corePlugins: { preflight:
|
|
38
|
-
...
|
|
34
|
+
safelist: a,
|
|
35
|
+
theme: { extend: q(e) },
|
|
36
|
+
plugins: [U, V, j, z, D],
|
|
37
|
+
corePlugins: { preflight: i },
|
|
38
|
+
...r ? { prefix: `${r}` } : {}
|
|
39
39
|
}
|
|
40
40
|
}).generateStylesFromContent(
|
|
41
|
-
` ${
|
|
41
|
+
` ${i ? "@tailwind base;" : ""}
|
|
42
42
|
@tailwind components;
|
|
43
43
|
@tailwind utilities;`,
|
|
44
44
|
t
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
return
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
const X = (e, t, a) => {
|
|
48
|
+
const r = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, o) => `#styles:${o.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
49
|
+
return Q(t, [r], [], "", a);
|
|
50
|
+
}, ke = async (e, t = F, a = !1) => await X(e, t, a);
|
|
51
|
+
async function Y(e) {
|
|
52
|
+
const t = await e.dataProvider({
|
|
53
|
+
pageProps: e.pageProps,
|
|
54
|
+
block: e.block,
|
|
55
|
+
lang: e.lang,
|
|
56
|
+
draft: e.draft,
|
|
57
|
+
inBuilder: !1
|
|
58
|
+
});
|
|
59
|
+
return k(t, "$metadata") && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
|
|
60
|
+
...J(t, "$metadata")
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const Z = () => /* @__PURE__ */ d("div", {}), ee = (e) => {
|
|
64
|
+
const { block: t, lang: a, fallbackLang: r, children: i, externalData: o, blocks: n, draft: s, pageProps: p, dataProviderMetadataCallback: m } = e, l = G(t._type), u = g(l, "component", null), b = g(e.repeaterData, "index", -1), S = g(e.repeaterData, "dataKey", ""), c = O($(t, a === r ? "" : a, l), o, {
|
|
65
|
+
index: b,
|
|
66
|
+
key: S
|
|
67
|
+
}), x = A(t), I = te(n, t._id, N(t._type)), T = k(l, "dataProvider") && M(l.dataProvider), w = {
|
|
55
68
|
blockProps: {},
|
|
56
69
|
inBuilder: !1,
|
|
57
|
-
lang:
|
|
58
|
-
...
|
|
59
|
-
...
|
|
60
|
-
...
|
|
61
|
-
...x
|
|
70
|
+
lang: a || r,
|
|
71
|
+
...c,
|
|
72
|
+
...x,
|
|
73
|
+
...I
|
|
62
74
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
if (E(u)) return null;
|
|
76
|
+
if (T) {
|
|
77
|
+
const L = g(l, "suspenseFallback", Z);
|
|
78
|
+
return /* @__PURE__ */ d(C, { fallback: f(L), children: /* @__PURE__ */ d(
|
|
79
|
+
Y,
|
|
80
|
+
{
|
|
81
|
+
lang: a,
|
|
82
|
+
pageProps: p,
|
|
83
|
+
block: t,
|
|
84
|
+
dataProvider: l.dataProvider,
|
|
85
|
+
dataProviderMetadataCallback: m,
|
|
86
|
+
draft: s,
|
|
87
|
+
children: (R) => f(u, {
|
|
88
|
+
...w,
|
|
89
|
+
...R,
|
|
90
|
+
children: i({
|
|
91
|
+
_id: t._id,
|
|
92
|
+
_type: t._type,
|
|
93
|
+
..._(c.repeaterItems) ? {
|
|
94
|
+
repeaterItems: B(c.repeaterItems, t),
|
|
95
|
+
repeaterItemsBinding: c.repeaterItemsBinding
|
|
96
|
+
} : {}
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
) });
|
|
101
|
+
}
|
|
102
|
+
return /* @__PURE__ */ d(C, { children: f(u, {
|
|
103
|
+
...w,
|
|
104
|
+
children: i({
|
|
66
105
|
_id: t._id,
|
|
67
106
|
_type: t._type,
|
|
68
|
-
...
|
|
69
|
-
repeaterItems:
|
|
70
|
-
repeaterItemsBinding:
|
|
107
|
+
..._(c.repeaterItems) ? {
|
|
108
|
+
repeaterItems: B(c.repeaterItems, t),
|
|
109
|
+
repeaterItemsBinding: c.repeaterItemsBinding
|
|
71
110
|
} : {}
|
|
72
111
|
})
|
|
73
112
|
}) });
|
|
74
|
-
},
|
|
75
|
-
const { blocks: t, parent: r } = e, i =
|
|
113
|
+
}, P = (e) => {
|
|
114
|
+
const { blocks: t, parent: a, repeaterData: r } = e, i = v(
|
|
76
115
|
t,
|
|
77
|
-
(n) =>
|
|
78
|
-
),
|
|
79
|
-
return
|
|
80
|
-
},
|
|
81
|
-
const
|
|
82
|
-
let s =
|
|
116
|
+
(n) => k(n, "_id") && (h(a) ? !n._parent : n._parent === a)
|
|
117
|
+
), o = (n) => v(t, (s) => s._parent === n).length > 0;
|
|
118
|
+
return K(i, (n) => n ? /* @__PURE__ */ f(ee, { ...e, key: n._id, block: n }, ({ _id: s, _type: p, repeaterItems: m, repeaterItemsBinding: l }) => p === "Repeater" ? _(m) && m.map((u, b) => /* @__PURE__ */ d(P, { ...e, parent: n._id, repeaterData: { index: b, dataKey: l } })) : o(s) ? /* @__PURE__ */ d(P, { ...e, parent: n._id, repeaterData: r }) : null) : null);
|
|
119
|
+
}, te = (e, t, a) => h(a) ? {} : Object.entries(a).reduce((r, [i, o]) => {
|
|
120
|
+
const n = [];
|
|
121
|
+
let s = y(e, { _id: t });
|
|
83
122
|
for (; s; )
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
return
|
|
123
|
+
n.push(s), s = y(e, { _id: s._parent });
|
|
124
|
+
const p = y(n, { _type: o.block });
|
|
125
|
+
return p && (r[i] = g(p, g(o, "prop"), null)), r;
|
|
87
126
|
}, {});
|
|
88
|
-
function
|
|
89
|
-
if (
|
|
127
|
+
function be(e) {
|
|
128
|
+
if (k(e, "metadata") && console.warn(" metadata is deprecated and will be removed in upcoming version, use pageProps instead"), h(e.lang) && !h(e.fallbackLang))
|
|
90
129
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
91
|
-
const t = e.lang ?? "en",
|
|
92
|
-
return /* @__PURE__ */ d(
|
|
130
|
+
const t = e.lang ?? "en", a = e.fallbackLang ?? t;
|
|
131
|
+
return /* @__PURE__ */ d(P, { ...e, lang: t, fallbackLang: a });
|
|
93
132
|
}
|
|
94
133
|
export {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
134
|
+
be as RenderChaiBlocks,
|
|
135
|
+
he as convertToBlocks,
|
|
136
|
+
Pe as getChaiThemeCssVariables,
|
|
137
|
+
ke as getStylesForBlocks,
|
|
138
|
+
we as getThemeFontsCSSImport,
|
|
139
|
+
Be as getThemeFontsLinkMarkup
|
|
101
140
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-CPwl7tLt.cjs");require("lodash-es");require("clsx");require("tailwind-merge");require("tree-model");const c=require("react");require("jotai");require("@chaibuilder/runtime");const C=require("react-i18next"),v=require("./sooner-AJ7QkeLS.cjs"),j=require("@radix-ui/react-icons"),q=require("@react-hookz/web"),d=o=>{const s=document.createElement("div");return s.innerHTML=o,s.innerHTML};function g(){const{t:o}=C.useTranslation(),[s,x]=c.useState(!1),[i,m]=c.useState(""),[t,a]=n.useCodeEditor(),[u]=n.useSelectedBlockIds(),b=n.useUpdateBlocksProps(),f=n.useUpdateBlocksPropsRealtime(),h=q.useThrottledCallback(l=>{const r=d(l);f([t.blockId],{[t.blockProp]:r})},[],300),p=c.useCallback(()=>{if(s){const l=d(i);b([t.blockId],{[t.blockProp]:l})}},[s,i]);c.useEffect(()=>{u.includes(t==null?void 0:t.blockId)||(p(),a(null))},[u]);const k=()=>{a(null)};return e.jsxs("div",{className:"h-full rounded-t-lg border-t-4 border-black bg-black text-white",children:[e.jsx("button",{onClick:k,className:"fixed inset-0 z-[100000] cursor-default bg-gray-400/20"}),e.jsxs("div",{className:"relative z-[100001] h-full w-full flex-col gap-y-1",children:[e.jsxs("div",{className:"-mt-1 flex items-center justify-between px-2 py-2",children:[e.jsxs("h3",{className:"space-x-3 text-sm font-semibold",children:[e.jsx("span",{children:o("HTML Code Editor |")}),e.jsx("span",{className:"text-xs text-gray-400",children:o("Scripts will be only executed in preview and live mode.")})]}),e.jsx("div",{className:"flex gap-x-2",children:e.jsx(v.Button,{onClick:()=>a(null),size:"sm",variant:"destructive",className:"h-6 w-fit",children:e.jsx(j.Cross2Icon,{})})})]}),e.jsx("textarea",{className:"h-full w-full bg-black p-2 font-mono text-xs text-white/90",value:i||t.initialCode,onChange:l=>{const r=l.target.value;x(!0),m(r),h(r)}})]})]})}exports.default=g;
|