@chaibuilder/sdk 2.2.33 → 2.2.35
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-r_v4m0s7.js → code-editor-DCGe1BPZ.js} +1 -1
- package/dist/{code-editor-DydX0A0c.cjs → code-editor-ZNSGKU5A.cjs} +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.d.ts +13 -0
- package/dist/core.js +438 -392
- package/dist/render.cjs +2 -2
- package/dist/render.js +68 -66
- package/dist/toggle-BFR6fqvM.js +1083 -0
- package/dist/toggle-BO_bUdZF.cjs +1 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +128 -358
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +127 -127
- package/package.json +1 -1
- package/dist/sooner-CPeN3CGR.cjs +0 -1
- package/dist/sooner-H65duPYc.js +0 -831
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"),r=require("lodash-es"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./plugin-CSgw-f78.cjs"),p=require("./apply-binding-DpBwzIf9.cjs"),r=require("lodash-es"),I=require("@tailwindcss/aspect-ratio"),q=require("@tailwindcss/forms"),$=require("@tailwindcss/typography");require("tailwindcss-animate");const E=require("./get-chai-builder-theme-B1tr_NJB.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),L=require("@tailwindcss/container-queries"),m=require("react/jsx-runtime"),u=require("react"),R=require("@chaibuilder/runtime");function D(e,t){const n=e.filter(({_type:i})=>i==="GlobalBlock"||i==="PartialBlock");for(let i=0;i<n.length;i++){const l=n[i],s=r.get(l,"partialBlockId",r.get(l,"globalBlock",""));if(s==="")continue;let a=r.cloneDeep(r.get(t,s,[]));l._parent&&(a==null?void 0:a.length)>0&&(a=a.map(c=>(r.isEmpty(c._parent)&&(c._parent=l._parent),c)));const o=e.indexOf(l);e.splice(o,1,...a)}return e}const j=e=>{if(!e)return[];try{return JSON.parse(M(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function M(e){const t=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(t,n=>{const i=decodeURIComponent(n),l=i.indexOf("public");return l!==-1?i.substring(l+6):i})}async function O(e,t,n=[],i="",l){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:E.getChaiBuilderTheme(e)},plugins:[q,$,I,L,y.chaiBuilderPlugin],corePlugins:{preflight:l},...i?{prefix:`${i}`}:{}}}).generateStylesFromContent(` ${l?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,t)}const
|
|
3
|
+
@tailwind utilities;`,t)}const A=(e,t,n)=>{const i=JSON.stringify(e).replace(/#styles:([^"]*)/g,(l,s)=>`#styles:${s.replace(/,/g," ")}`.replace(/#styles:/g,""));return O(t,[i],[],"",n)},K=async(e,t=y.defaultThemeOptions,n=!1)=>await A(e,t,n);async function N(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")&&r.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,t.$metadata),e.children({...r.omit(t,"$metadata")})}const J=()=>m.jsx("div",{}),V=e=>{const{block:t,lang:n,fallbackLang:i,children:l,externalData:s,blocks:a,draft:o,pageProps:c,dataProviderMetadataCallback:h}=e,d=R.getRegisteredChaiBlock(t._type),f=r.get(d,"component",null),k=r.get(e.repeaterData,"index",-1),b=r.get(e.repeaterData,"dataKey",""),C=n===i?"":n,g=p.applyBindingToBlockProps(p.applyLanguage(t,C,d),s,{index:k,key:b}),w=p.getBlockTagAttributes(t,!1),S=U(a,t._id,p.getBlockRuntimeProps(t._type)),T=r.has(d,"dataProvider")&&r.isFunction(d.dataProvider),_={...g,...w,...S},P={blockProps:{},inBuilder:!1,lang:n||i,..._};if(r.isNull(f))return null;if(T){const v=r.get(d,"suspenseFallback",J);return m.jsx(u.Suspense,{fallback:u.createElement(v),children:m.jsx(N,{lang:n,pageProps:c,block:_,dataProvider:d.dataProvider,...h?{dataProviderMetadataCallback:h}:{},draft:o,children:x=>u.createElement(f,{...P,...x,children:l({_id:t._id,_type:t._type,...r.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,t),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})})}return m.jsx(u.Suspense,{children:u.createElement(f,{...P,children:l({_id:t._id,_type:t._type,...r.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,t),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})},B=e=>{const{blocks:t,parent:n,repeaterData:i}=e;let l=r.uniqBy(r.filter(t,a=>r.has(a,"_id")&&(r.isEmpty(n)?!a._parent:a._parent===n)),"_id");const s=a=>r.filter(t,o=>o._parent===a).length>0;return r.map(l,a=>a?u.createElement(V,{...e,key:a._id,block:a},({_id:o,_type:c,repeaterItems:h,$repeaterItemsKey:d})=>c==="Repeater"?r.isArray(h)&&h.map((f,k)=>u.createElement(B,{...e,parent:a._id,key:`${r.get(a,"_parent","root")}-${a._id}-${k}`,repeaterData:{index:k,dataKey:d}})):s(o)?u.createElement(B,{...e,parent:a._id,key:`${r.get(a,"_parent","root")}-${a._id}`,repeaterData:i}):null):null)},U=(e,t,n)=>r.isEmpty(n)?{}:Object.entries(n).reduce((i,[l,s])=>{const a=[];let o=r.find(e,{_id:t});for(;o;)a.push(o),o=r.find(e,{_id:o._parent});const c=r.find(a,{_type:s.block});return c&&(i[l]=r.get(c,r.get(s,"prop"),null)),i},{});function W(e){if(r.isEmpty(e.lang)&&!r.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(r.isEmpty(e.blocks))return null;const t=e.lang??"en",n=e.fallbackLang??t;return m.jsx(B,{...e,lang:t,fallbackLang:n})}exports.getChaiThemeCssVariables=y.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=y.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=y.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=p.applyChaiDataBinding;exports.RenderChaiBlocks=W;exports.convertToBlocks=j;exports.getMergedPartialBlocks=D;exports.getStylesForBlocks=K;
|
package/dist/render.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as
|
|
4
|
-
import { e as
|
|
5
|
-
import { get as s, cloneDeep as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { d as F, c as O } from "./plugin-BOcGV_IY.js";
|
|
2
|
+
import { a as Se, b as ve, e as xe } from "./plugin-BOcGV_IY.js";
|
|
3
|
+
import { a as K, b as M, g as A, c as N, d as C } from "./apply-binding-CkrtJykq.js";
|
|
4
|
+
import { e as $e } from "./apply-binding-CkrtJykq.js";
|
|
5
|
+
import { get as s, cloneDeep as J, isEmpty as u, has as B, isFunction as x, omit as E, isNull as j, isArray as _, uniqBy as q, filter as S, map as U, find as y } from "lodash-es";
|
|
6
|
+
import V from "@tailwindcss/aspect-ratio";
|
|
7
|
+
import W from "@tailwindcss/forms";
|
|
8
8
|
import G from "@tailwindcss/typography";
|
|
9
9
|
import "tailwindcss-animate";
|
|
10
|
-
import { g as
|
|
11
|
-
import { createTailwindcss as
|
|
12
|
-
import
|
|
10
|
+
import { g as z } from "./get-chai-builder-theme-BarMkcGH.js";
|
|
11
|
+
import { createTailwindcss as H } from "@mhsdesign/jit-browser-tailwindcss";
|
|
12
|
+
import Q from "@tailwindcss/container-queries";
|
|
13
13
|
import { jsx as m } from "react/jsx-runtime";
|
|
14
|
-
import { Suspense as
|
|
15
|
-
import { getRegisteredChaiBlock as
|
|
16
|
-
function
|
|
14
|
+
import { Suspense as v, createElement as g } from "react";
|
|
15
|
+
import { getRegisteredChaiBlock as X } from "@chaibuilder/runtime";
|
|
16
|
+
function _e(e, t) {
|
|
17
17
|
const r = e.filter(({ _type: n }) => n === "GlobalBlock" || n === "PartialBlock");
|
|
18
18
|
for (let n = 0; n < r.length; n++) {
|
|
19
19
|
const i = r[n], l = s(i, "partialBlockId", s(i, "globalBlock", ""));
|
|
20
20
|
if (l === "") continue;
|
|
21
|
-
let a =
|
|
21
|
+
let a = J(s(t, l, []));
|
|
22
22
|
i._parent && (a == null ? void 0 : a.length) > 0 && (a = a.map((c) => (u(c._parent) && (c._parent = i._parent), c)));
|
|
23
23
|
const o = e.indexOf(i);
|
|
24
24
|
e.splice(o, 1, ...a);
|
|
25
25
|
}
|
|
26
26
|
return e;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const be = (e) => {
|
|
29
29
|
if (!e) return [];
|
|
30
30
|
try {
|
|
31
|
-
return JSON.parse(
|
|
31
|
+
return JSON.parse(Y(e)).filter((r) => !r._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 Y(e) {
|
|
37
37
|
const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
38
38
|
return e.replace(t, (r) => {
|
|
39
39
|
const n = decodeURIComponent(r), i = n.indexOf("public");
|
|
40
40
|
return i !== -1 ? n.substring(i + 6) : n;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
44
|
-
return await
|
|
43
|
+
async function Z(e, t, r = [], n = "", i) {
|
|
44
|
+
return await H({
|
|
45
45
|
tailwindConfig: {
|
|
46
46
|
darkMode: "class",
|
|
47
47
|
safelist: r,
|
|
48
|
-
theme: { extend:
|
|
49
|
-
plugins: [
|
|
48
|
+
theme: { extend: z(e) },
|
|
49
|
+
plugins: [W, G, V, Q, O],
|
|
50
50
|
corePlugins: { preflight: i },
|
|
51
51
|
...n ? { prefix: `${n}` } : {}
|
|
52
52
|
}
|
|
@@ -57,11 +57,11 @@ async function Y(e, t, r = [], n = "", i) {
|
|
|
57
57
|
t
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
const
|
|
60
|
+
const ee = (e, t, r) => {
|
|
61
61
|
const n = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, l) => `#styles:${l.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
62
|
-
return
|
|
63
|
-
},
|
|
64
|
-
async function
|
|
62
|
+
return Z(t, [n], [], "", r);
|
|
63
|
+
}, Be = async (e, t = F, r = !1) => await ee(e, t, r);
|
|
64
|
+
async function te(e) {
|
|
65
65
|
const t = await e.dataProvider({
|
|
66
66
|
pageProps: e.pageProps,
|
|
67
67
|
block: e.block,
|
|
@@ -69,43 +69,45 @@ async function ee(e) {
|
|
|
69
69
|
draft: e.draft,
|
|
70
70
|
inBuilder: !1
|
|
71
71
|
});
|
|
72
|
-
return B(t, "$metadata") &&
|
|
73
|
-
...
|
|
72
|
+
return B(t, "$metadata") && x(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
|
|
73
|
+
...E(t, "$metadata")
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
const
|
|
77
|
-
const { block: t, lang: r, fallbackLang: n, children: i, externalData: l, blocks: a, draft: o, pageProps: c, dataProviderMetadataCallback: f } = e, d =
|
|
78
|
-
|
|
76
|
+
const ae = () => /* @__PURE__ */ m("div", {}), re = (e) => {
|
|
77
|
+
const { block: t, lang: r, fallbackLang: n, children: i, externalData: l, blocks: a, draft: o, pageProps: c, dataProviderMetadataCallback: f } = e, d = X(t._type), h = s(d, "component", null), k = s(e.repeaterData, "index", -1), I = s(e.repeaterData, "dataKey", ""), p = K(
|
|
78
|
+
M(t, r === n ? "" : r, d),
|
|
79
79
|
l,
|
|
80
|
-
{ index: k, key:
|
|
81
|
-
),
|
|
80
|
+
{ index: k, key: I }
|
|
81
|
+
), $ = A(t, !1), T = ne(a, t._id, N(t._type)), L = B(d, "dataProvider") && x(d.dataProvider), P = {
|
|
82
|
+
...p,
|
|
83
|
+
...$,
|
|
84
|
+
...T
|
|
85
|
+
}, w = {
|
|
82
86
|
blockProps: {},
|
|
83
87
|
inBuilder: !1,
|
|
84
88
|
lang: r || n,
|
|
85
|
-
...
|
|
86
|
-
...I,
|
|
87
|
-
...$
|
|
89
|
+
...P
|
|
88
90
|
};
|
|
89
|
-
if (
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
return /* @__PURE__ */ m(
|
|
93
|
-
|
|
91
|
+
if (j(h)) return null;
|
|
92
|
+
if (L) {
|
|
93
|
+
const D = s(d, "suspenseFallback", ae);
|
|
94
|
+
return /* @__PURE__ */ m(v, { fallback: g(D), children: /* @__PURE__ */ m(
|
|
95
|
+
te,
|
|
94
96
|
{
|
|
95
97
|
lang: r,
|
|
96
98
|
pageProps: c,
|
|
97
|
-
block:
|
|
99
|
+
block: P,
|
|
98
100
|
dataProvider: d.dataProvider,
|
|
99
101
|
...f ? { dataProviderMetadataCallback: f } : {},
|
|
100
102
|
draft: o,
|
|
101
|
-
children: (
|
|
102
|
-
...
|
|
103
|
-
...
|
|
103
|
+
children: (R) => g(h, {
|
|
104
|
+
...w,
|
|
105
|
+
...R,
|
|
104
106
|
children: i({
|
|
105
107
|
_id: t._id,
|
|
106
108
|
_type: t._type,
|
|
107
109
|
..._(p.repeaterItems) ? {
|
|
108
|
-
repeaterItems:
|
|
110
|
+
repeaterItems: C(p.repeaterItems, t),
|
|
109
111
|
$repeaterItemsKey: p.$repeaterItemsKey
|
|
110
112
|
} : {}
|
|
111
113
|
})
|
|
@@ -113,26 +115,26 @@ const te = () => /* @__PURE__ */ m("div", {}), ae = (e) => {
|
|
|
113
115
|
}
|
|
114
116
|
) });
|
|
115
117
|
}
|
|
116
|
-
return /* @__PURE__ */ m(
|
|
117
|
-
...
|
|
118
|
+
return /* @__PURE__ */ m(v, { children: g(h, {
|
|
119
|
+
...w,
|
|
118
120
|
children: i({
|
|
119
121
|
_id: t._id,
|
|
120
122
|
_type: t._type,
|
|
121
123
|
..._(p.repeaterItems) ? {
|
|
122
|
-
repeaterItems:
|
|
124
|
+
repeaterItems: C(p.repeaterItems, t),
|
|
123
125
|
$repeaterItemsKey: p.$repeaterItemsKey
|
|
124
126
|
} : {}
|
|
125
127
|
})
|
|
126
128
|
}) });
|
|
127
|
-
},
|
|
129
|
+
}, b = (e) => {
|
|
128
130
|
const { blocks: t, parent: r, repeaterData: n } = e;
|
|
129
|
-
let i =
|
|
130
|
-
|
|
131
|
+
let i = q(
|
|
132
|
+
S(t, (a) => B(a, "_id") && (u(r) ? !a._parent : a._parent === r)),
|
|
131
133
|
"_id"
|
|
132
134
|
);
|
|
133
|
-
const l = (a) =>
|
|
134
|
-
return
|
|
135
|
-
|
|
135
|
+
const l = (a) => S(t, (o) => o._parent === a).length > 0;
|
|
136
|
+
return U(i, (a) => a ? /* @__PURE__ */ g(re, { ...e, key: a._id, block: a }, ({ _id: o, _type: c, repeaterItems: f, $repeaterItemsKey: d }) => c === "Repeater" ? _(f) && f.map((h, k) => /* @__PURE__ */ g(
|
|
137
|
+
b,
|
|
136
138
|
{
|
|
137
139
|
...e,
|
|
138
140
|
parent: a._id,
|
|
@@ -140,7 +142,7 @@ const te = () => /* @__PURE__ */ m("div", {}), ae = (e) => {
|
|
|
140
142
|
repeaterData: { index: k, dataKey: d }
|
|
141
143
|
}
|
|
142
144
|
)) : l(o) ? /* @__PURE__ */ g(
|
|
143
|
-
|
|
145
|
+
b,
|
|
144
146
|
{
|
|
145
147
|
...e,
|
|
146
148
|
parent: a._id,
|
|
@@ -148,7 +150,7 @@ const te = () => /* @__PURE__ */ m("div", {}), ae = (e) => {
|
|
|
148
150
|
repeaterData: n
|
|
149
151
|
}
|
|
150
152
|
) : null) : null);
|
|
151
|
-
},
|
|
153
|
+
}, ne = (e, t, r) => u(r) ? {} : Object.entries(r).reduce((n, [i, l]) => {
|
|
152
154
|
const a = [];
|
|
153
155
|
let o = y(e, { _id: t });
|
|
154
156
|
for (; o; )
|
|
@@ -156,21 +158,21 @@ const te = () => /* @__PURE__ */ m("div", {}), ae = (e) => {
|
|
|
156
158
|
const c = y(a, { _type: l.block });
|
|
157
159
|
return c && (n[i] = s(c, s(l, "prop"), null)), n;
|
|
158
160
|
}, {});
|
|
159
|
-
function
|
|
161
|
+
function Pe(e) {
|
|
160
162
|
if (u(e.lang) && !u(e.fallbackLang))
|
|
161
163
|
throw new Error("lang prop is required when fallbackLang is provided");
|
|
162
164
|
if (u(e.blocks))
|
|
163
165
|
return null;
|
|
164
166
|
const t = e.lang ?? "en", r = e.fallbackLang ?? t;
|
|
165
|
-
return /* @__PURE__ */ m(
|
|
167
|
+
return /* @__PURE__ */ m(b, { ...e, lang: t, fallbackLang: r });
|
|
166
168
|
}
|
|
167
169
|
export {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
Pe as RenderChaiBlocks,
|
|
171
|
+
$e as applyChaiDataBinding,
|
|
172
|
+
be as convertToBlocks,
|
|
173
|
+
Se as getChaiThemeCssVariables,
|
|
174
|
+
_e as getMergedPartialBlocks,
|
|
175
|
+
Be as getStylesForBlocks,
|
|
176
|
+
ve as getThemeFontsCSSImport,
|
|
177
|
+
xe as getThemeFontsLinkMarkup
|
|
176
178
|
};
|