@chaibuilder/sdk 2.0.0-beta.31 → 2.0.0-beta.32
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/render.cjs +2 -2
- package/dist/render.js +6 -5
- package/package.json +1 -1
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lodash-es"),m=require("./STRINGS-26RPxXyi.cjs"),a=require("./jsx-runtime-JYMCiFoE.cjs"),p=require("react"),_=require("tailwind-merge"),B=require("@chaibuilder/runtime"),R=require("@mhsdesign/jit-browser-tailwindcss"),P=require("@tailwindcss/forms"),q=require("@tailwindcss/typography"),Y=require("@tailwindcss/aspect-ratio"),E=require("./plugin-4xaTkTNB.cjs"),f=require("./ChaiThemeFn-bugxb1Cl.cjs"),v=(e,s="")=>{const t=e.replace(m.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const u=l.split(":");return u[u.length-1]=s+r.last(u),u.join(":")}return`${s}${l}`}).join(" "));return r.flattenDeep(t).join(" ")},A=e=>{if(!e)return[];try{return JSON.parse(F(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function F(e){const s=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(s,n=>{const t=decodeURIComponent(n),i=t.indexOf("public");return i!==-1?t.substring(i+6):t})}async function L(e){const s=await(e==null?void 0:e.dataProvider(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("lodash-es"),m=require("./STRINGS-26RPxXyi.cjs"),a=require("./jsx-runtime-JYMCiFoE.cjs"),p=require("react"),_=require("tailwind-merge"),B=require("@chaibuilder/runtime"),R=require("@mhsdesign/jit-browser-tailwindcss"),P=require("@tailwindcss/forms"),q=require("@tailwindcss/typography"),Y=require("@tailwindcss/aspect-ratio"),E=require("./plugin-4xaTkTNB.cjs"),f=require("./ChaiThemeFn-bugxb1Cl.cjs"),v=(e,s="")=>{const t=e.replace(m.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const u=l.split(":");return u[u.length-1]=s+r.last(u),u.join(":")}return`${s}${l}`}).join(" "));return r.flattenDeep(t).join(" ")},A=e=>{if(!e)return[];try{return JSON.parse(F(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function F(e){const s=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(s,n=>{const t=decodeURIComponent(n),i=t.indexOf("public");return i!==-1?t.substring(i+6):t})}async function L(e){const s=await(e==null?void 0:e.dataProvider(e.block,e.lang,e.metadata));return a.jsxRuntimeExports.jsx(p.Suspense,{children:p.createElement(e.component,{...e.props,...s})})}const O=r.memoize((e,s)=>{const n=e.replace(m.STYLES_KEY,"").split(","),t=_.twMerge(n[0],n[1]);return s===""?t.replace(m.STYLES_KEY,"").trim():v(t,s).replace(m.STYLES_KEY,"").trim()});function N(e,s){const n=r.get(e,`${s}_attrs`,{}),t=r.keys(n).join(" ");return r.includes(t,"x-show")&&!r.includes(t,"x-transition")&&(n["x-transition"]=""),n}function $(e,s){const n={};return Object.keys(e).forEach(t=>{if(r.isString(e[t])&&e[t].startsWith(m.STYLES_KEY)){const i=O(e[t],s);n[t]={className:i,...N(e,t)}}}),n}function I(e,s){const n=r.get(e,"_bindings",{});return r.isEmpty(n)?{...e}:(r.each(n,(t,i)=>{r.isString(t)&&r.get(s,t,null)&&(e[i]=r.get(s,t,null))}),e)}function K(e,s,n){if(r.isEmpty(s))return e;const t=r.cloneDeep(e),i=r.get(n,"i18nProps",[]);return r.forEach(r.keys(t),c=>{i.includes(c)&&!r.isEmpty(s)&&(t[c]=r.get(t,`${c}-${s}`,t[c]))}),t}function j({blocks:e,parent:s,classPrefix:n="",externalData:t={},blockModifierCallback:i=null,lang:c="",metadata:h={}}){const l=e,u=o=>$(o,n),T=s?r.filter(e,{_parent:s}):r.filter(e,o=>r.isEmpty(o._parent));return a.jsxRuntimeExports.jsx(a.jsxRuntimeExports.Fragment,{children:p.Children.toArray(T.map((o,C)=>{const S={},w=r.filter(l,{_parent:o._id});S.children=w.length>0?a.jsxRuntimeExports.jsx(j,{externalData:t,classPrefix:n,parent:o._id,blocks:l,lang:c??"",metadata:h}):null;const d=B.getRegisteredChaiBlock(o._type);if(d!==null){let g=o;const y=d.component;g={...d.defaults,...o},i&&(g=i(g));const x=r.omit({blockProps:{},inBuilder:!1,...g,index:C,...I(K(o,c,d),t),...u(g),...S,metadata:h,lang:c??""},["_parent"]);return r.has(d,"dataProvider")?a.jsxRuntimeExports.jsx(p.Suspense,{children:a.jsxRuntimeExports.jsx(L,{lang:c??"",metadata:h,dataProvider:d.dataProvider,block:o,component:y,props:x})}):a.jsxRuntimeExports.jsx(p.Suspense,{children:p.createElement(y,x)})}return a.jsxRuntimeExports.jsxs("noscript",{children:[o._type," not found"]})}))})}async function M(e,s,n=[],t="",i){return await R.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:E.getChaiBuilderTheme(e)},plugins:[P,q,Y,E.chaiBuilderPlugin],corePlugins:{preflight:i},...t?{prefix:`${t}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,s)}const
|
|
3
|
+
@tailwind utilities;`,s)}const J=(e,s,n)=>M(s,[r.replace(JSON.stringify(e),/#styles:,?/g,"")],[],"",n),k=async(e,s=f.defaultThemeOptions,n=!1)=>await J(e,s,n);exports.getChaiThemeCssVariables=f.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=f.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=f.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=j;exports.convertToBlocks=A;exports.getStylesForBlocks=k;
|
package/dist/render.js
CHANGED
|
@@ -39,7 +39,7 @@ function G(t) {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
async function H(t) {
|
|
42
|
-
const n = await (t == null ? void 0 : t.dataProvider(
|
|
42
|
+
const n = await (t == null ? void 0 : t.dataProvider(t.block, t.lang, t.metadata));
|
|
43
43
|
return /* @__PURE__ */ a.jsx(S, { children: y.createElement(t.component, { ...t.props, ...n }) });
|
|
44
44
|
}
|
|
45
45
|
const Q = $((t, n) => {
|
|
@@ -81,8 +81,8 @@ function tt({
|
|
|
81
81
|
parent: n,
|
|
82
82
|
classPrefix: r = "",
|
|
83
83
|
externalData: e = {},
|
|
84
|
-
blockModifierCallback: s,
|
|
85
|
-
lang: o,
|
|
84
|
+
blockModifierCallback: s = null,
|
|
85
|
+
lang: o = "",
|
|
86
86
|
metadata: f = {}
|
|
87
87
|
}) {
|
|
88
88
|
const c = t, l = (i) => Z(i, r), B = n ? h(t, { _parent: n }) : h(t, (i) => g(i._parent));
|
|
@@ -96,7 +96,7 @@ function tt({
|
|
|
96
96
|
classPrefix: r,
|
|
97
97
|
parent: i._id,
|
|
98
98
|
blocks: c,
|
|
99
|
-
lang: o,
|
|
99
|
+
lang: o ?? "",
|
|
100
100
|
metadata: f
|
|
101
101
|
}
|
|
102
102
|
) : null;
|
|
@@ -115,13 +115,14 @@ function tt({
|
|
|
115
115
|
...l(p),
|
|
116
116
|
...w,
|
|
117
117
|
metadata: f,
|
|
118
|
-
lang: o
|
|
118
|
+
lang: o ?? ""
|
|
119
119
|
},
|
|
120
120
|
["_parent"]
|
|
121
121
|
);
|
|
122
122
|
return N(u, "dataProvider") ? /* @__PURE__ */ a.jsx(S, { children: /* @__PURE__ */ a.jsx(
|
|
123
123
|
H,
|
|
124
124
|
{
|
|
125
|
+
lang: o ?? "",
|
|
125
126
|
metadata: f,
|
|
126
127
|
dataProvider: u.dataProvider,
|
|
127
128
|
block: i,
|