@chaibuilder/sdk 2.2.18 → 2.2.19

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.
@@ -1 +1 @@
1
- "use strict";const e=require("./plugin-C01tjI6V.cjs"),i=(t=e.defaultThemeOptions)=>({container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...e.getChaiThemeOptions(t)});exports.getChaiBuilderTheme=i;
1
+ "use strict";const e=require("./plugin-CSgw-f78.cjs"),i=(t=e.defaultThemeOptions)=>({container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...e.getChaiThemeOptions(t)});exports.getChaiBuilderTheme=i;
@@ -1,4 +1,4 @@
1
- import { g as t, d as r } from "./plugin-fnBB3TCm.js";
1
+ import { g as t, d as r } from "./plugin-BOcGV_IY.js";
2
2
  const a = (e = r) => ({
3
3
  container: {
4
4
  center: !0,
@@ -1,5 +1,5 @@
1
1
  import { getAllRegisteredFonts as b } from "@chaibuilder/runtime";
2
- import { uniqBy as f, keys as h, flatten as v, get as B } from "lodash-es";
2
+ import { uniqBy as l, keys as h, flatten as v, get as B } from "lodash-es";
3
3
  const O = {
4
4
  fontFamily: {
5
5
  "font-heading": "Inter",
@@ -156,9 +156,9 @@ const _ = (r) => {
156
156
  .dark {
157
157
  ${r.colors && Object.entries(r.colors).map(([t, e]) => `--${t}: ${p(e[1])};`).join(`
158
158
  `)}
159
- }`, w = (r) => !r || r.length === 0 ? "" : f(r, "family").map((t) => `<link rel="stylesheet" href="${t.url}" />`).join(`
160
- `), x = (r) => !r || r.length === 0 ? "" : f(r, "family").map((t) => `@import url("${t.url}");`).join(`
161
- `), D = (r) => !r || r.length === 0 ? "" : f(r, "family").map(
159
+ }`, w = (r) => !r || r.length === 0 ? "" : l(r, "family").map((t) => `<link rel="stylesheet" href="${t.url}" />`).join(`
160
+ `), x = (r) => !r || r.length === 0 ? [] : l(r, "family").map((t) => t.url), D = (r) => !r || r.length === 0 ? "" : l(r, "family").map((t) => `@import url("${t.url}");`).join(`
161
+ `), L = (r) => !r || r.length === 0 ? "" : l(r, "family").map(
162
162
  (t) => t.src.map(
163
163
  (e) => `@font-face {
164
164
  font-family: "${t.family}";
@@ -175,7 +175,7 @@ const _ = (r) => {
175
175
  function E(r) {
176
176
  return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
177
177
  }
178
- var l = {}, s = {}, m;
178
+ var s = {}, c = {}, m;
179
179
  function P() {
180
180
  return m || (m = 1, function(r) {
181
181
  Object.defineProperty(r, "__esModule", {
@@ -203,7 +203,7 @@ function P() {
203
203
  return o.__isOptionsFunction = !0, o.__pluginFunction = n, o.__configFunction = F, o;
204
204
  };
205
205
  const e = t;
206
- }(s)), s;
206
+ }(c)), c;
207
207
  }
208
208
  var y;
209
209
  function A() {
@@ -223,17 +223,17 @@ function A() {
223
223
  };
224
224
  }
225
225
  const n = t.default;
226
- }(l)), l;
226
+ }(s)), s;
227
227
  }
228
- var c, $;
228
+ var f, $;
229
229
  function j() {
230
- if ($) return c;
230
+ if ($) return f;
231
231
  $ = 1;
232
232
  let r = A();
233
- return c = (r.__esModule ? r : { default: r }).default, c;
233
+ return f = (r.__esModule ? r : { default: r }).default, f;
234
234
  }
235
235
  var C = j();
236
- const M = /* @__PURE__ */ E(C), L = M(function({ addBase: r, theme: t }) {
236
+ const M = /* @__PURE__ */ E(C), V = M(function({ addBase: r, theme: t }) {
237
237
  r({
238
238
  "h1,h2,h3,h4,h5,h6": {
239
239
  fontFamily: t("fontFamily.heading")
@@ -247,12 +247,13 @@ const M = /* @__PURE__ */ E(C), L = M(function({ addBase: r, theme: t }) {
247
247
  });
248
248
  export {
249
249
  S as a,
250
- x as b,
251
- L as c,
250
+ D as b,
251
+ V as c,
252
252
  O as d,
253
253
  w as e,
254
254
  I as f,
255
255
  q as g,
256
- D as h,
256
+ x as h,
257
+ L as i,
257
258
  M as p
258
259
  };
@@ -1,4 +1,4 @@
1
- "use strict";const b=require("@chaibuilder/runtime"),i=require("lodash-es"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?i.keys(e.fontFamily).reduce((r,n)=>({...r,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?i.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[n])=>({...r,[n]:`hsl(var(--${n}))`}),{}):{}});function m(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(t[1],16),n=parseInt(t[2],16),o=parseInt(t[3],16);r/=255,n/=255,o/=255;const F=Math.max(r,n,o),u=Math.min(r,n,o);let a,d;const g=(F+u)/2;if(F==u)a=d=0;else{const l=F-u;switch(d=g>.5?l/(2-F-u):l/(F+u),F){case r:a=(n-o)/l+(n<o?6:0);break;case n:a=(o-r)/l+2;break;case o:a=(r-n)/l+4;break}a/=6}return`${Math.round(a*360)} ${Math.round(d*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=b.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${i.get(r,"fallback","")}`},P=e=>`:root {
1
+ "use strict";const b=require("@chaibuilder/runtime"),a=require("lodash-es"),B={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]},v={fontFamily:{heading:"Inter",body:"Inter"},borderRadius:"6px",colors:{background:["#FFFFFF","#09090B"],foreground:["#09090B","#FFFFFF"],primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"],secondary:["#F4F4F5","#27272A"],"secondary-foreground":["#09090B","#FFFFFF"],muted:["#F4F4F5","#27272A"],"muted-foreground":["#71717A","#A1A1AA"],accent:["#F4F4F5","#27272A"],"accent-foreground":["#09090B","#FFFFFF"],destructive:["#EF4444","#7F1D1D"],"destructive-foreground":["#FFFFFF","#FFFFFF"],border:["#E4E4E7","#27272A"],input:["#E4E4E7","#27272A"],ring:["#2563EB","#3B82F6"],card:["#FFFFFF","#09090B"],"card-foreground":["#09090B","#FFFFFF"],popover:["#FFFFFF","#09090B"],"popover-foreground":["#09090B","#FFFFFF"]}},_=e=>({fontFamily:e.fontFamily?a.keys(e.fontFamily).reduce((r,n)=>({...r,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?a.flatten(e.colors.map(r=>Object.entries(r.items))).reduce((r,[n])=>({...r,[n]:`hsl(var(--${n}))`}),{}):{}});function m(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let r=parseInt(t[1],16),n=parseInt(t[2],16),F=parseInt(t[3],16);r/=255,n/=255,F/=255;const o=Math.max(r,n,F),u=Math.min(r,n,F);let i,d;const g=(o+u)/2;if(o==u)i=d=0;else{const l=o-u;switch(d=g>.5?l/(2-o-u):l/(o+u),o){case r:i=(n-F)/l+(n<F?6:0);break;case n:i=(F-r)/l+2;break;case F:i=(r-n)/l+4;break}i/=6}return`${Math.round(i*360)} ${Math.round(d*100)}% ${Math.round(g*100)}%`}const E=e=>{const r=b.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${a.get(r,"fallback","")}`},P=e=>`:root {
2
2
  ${e.fontFamily&&Object.entries(e.fontFamily).map(([t,r])=>`--font-${t}: ${E(r)};`).join(`
3
3
  `)}
4
4
  ${e.borderRadius&&`--radius: ${e.borderRadius};`}
@@ -8,9 +8,9 @@
8
8
  .dark {
9
9
  ${e.colors&&Object.entries(e.colors).map(([t,r])=>`--${t}: ${m(r[1])};`).join(`
10
10
  `)}
11
- }`,C=e=>!e||e.length===0?"":i.uniqBy(e,"family").map(t=>`<link rel="stylesheet" href="${t.url}" />`).join(`
12
- `),A=e=>!e||e.length===0?"":i.uniqBy(e,"family").map(t=>`@import url("${t.url}");`).join(`
13
- `),j=e=>!e||e.length===0?"":i.uniqBy(e,"family").map(t=>t.src.map(r=>`@font-face {
11
+ }`,C=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>`<link rel="stylesheet" href="${t.url}" />`).join(`
12
+ `),A=e=>!e||e.length===0?[]:a.uniqBy(e,"family").map(t=>t.url),j=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>`@import url("${t.url}");`).join(`
13
+ `),k=e=>!e||e.length===0?"":a.uniqBy(e,"family").map(t=>t.src.map(r=>`@font-face {
14
14
  font-family: "${t.family}";
15
15
  src: url("${r.url}") format("${r.format}");
16
16
  font-display: swap;
@@ -19,4 +19,4 @@
19
19
  ${r.fontStretch?`font-stretch: ${r.fontStretch};`:""}
20
20
  }`).join(`
21
21
  `)).join(`
22
- `);function k(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s={},c={},p;function M(){return p||(p=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});function t(n,o){return{handler:n,config:o}}t.withOptions=function(n,o=()=>({})){const F=function(u){return{__options:u,handler:n(u),config:o(u)}};return F.__isOptionsFunction=!0,F.__pluginFunction=n,F.__configFunction=o,F};const r=t}(c)),c}var y;function q(){return y||(y=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const t=r(M());function r(o){return o&&o.__esModule?o:{default:o}}const n=t.default}(s)),s}var f,h;function O(){if(h)return f;h=1;let e=q();return f=(e.__esModule?e:{default:e}).default,f}var R=O();const $=k(R),I=$(function({addBase:e,theme:t}){e({"h1,h2,h3,h4,h5,h6":{fontFamily:t("fontFamily.heading")},body:{fontFamily:t("fontFamily.body"),color:t("colors.foreground"),backgroundColor:t("colors.background")}})});exports.chaiBuilderPlugin=I;exports.defaultThemeOptions=B;exports.defaultThemeValues=v;exports.getChaiThemeCssVariables=P;exports.getChaiThemeOptions=_;exports.getThemeCustomFontFace=j;exports.getThemeFontsCSSImport=A;exports.getThemeFontsLinkMarkup=C;exports.plugin=$;
22
+ `);function q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s={},c={},p;function M(){return p||(p=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});function t(n,F){return{handler:n,config:F}}t.withOptions=function(n,F=()=>({})){const o=function(u){return{__options:u,handler:n(u),config:F(u)}};return o.__isOptionsFunction=!0,o.__pluginFunction=n,o.__configFunction=F,o};const r=t}(c)),c}var y;function O(){return y||(y=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const t=r(M());function r(F){return F&&F.__esModule?F:{default:F}}const n=t.default}(s)),s}var f,h;function R(){if(h)return f;h=1;let e=O();return f=(e.__esModule?e:{default:e}).default,f}var I=R();const $=q(I),S=$(function({addBase:e,theme:t}){e({"h1,h2,h3,h4,h5,h6":{fontFamily:t("fontFamily.heading")},body:{fontFamily:t("fontFamily.body"),color:t("colors.foreground"),backgroundColor:t("colors.background")}})});exports.chaiBuilderPlugin=S;exports.defaultThemeOptions=B;exports.defaultThemeValues=v;exports.getChaiThemeCssVariables=P;exports.getChaiThemeOptions=_;exports.getThemeCustomFontFace=k;exports.getThemeFontsCSSImport=j;exports.getThemeFontsLinkMarkup=C;exports.getThemeFontsUrls=A;exports.plugin=$;
package/dist/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./plugin-C01tjI6V.cjs"),g=require("./apply-binding-k6PclyA3.cjs"),a=require("lodash-es"),x=require("@tailwindcss/aspect-ratio"),I=require("@tailwindcss/forms"),q=require("@tailwindcss/typography");require("tailwindcss-animate");const E=require("./get-chai-builder-theme-CeaKvOZ8.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),L=require("@tailwindcss/container-queries"),m=require("react/jsx-runtime"),p=require("react"),R=require("@chaibuilder/runtime");function j(e,t){const n=e.filter(({_type:i})=>i==="GlobalBlock"||i==="PartialBlock");for(let i=0;i<n.length;i++){const s=n[i],l=a.get(s,"partialBlockId",a.get(s,"globalBlock",""));if(l==="")continue;let r=a.cloneDeep(a.get(t,l,[]));s._parent&&(r==null?void 0:r.length)>0&&(r=r.map(c=>(a.isEmpty(c._parent)&&(c._parent=s._parent),c)));const o=e.indexOf(s);e.splice(o,1,...r)}return e}const D=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),s=i.indexOf("public");return s!==-1?i.substring(s+6):i})}async function O(e,t,n=[],i="",s){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:E.getChaiBuilderTheme(e)},plugins:[I,q,x,L,f.chaiBuilderPlugin],corePlugins:{preflight:s},...i?{prefix:`${i}`}:{}}}).generateStylesFromContent(` ${s?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./plugin-CSgw-f78.cjs"),p=require("./apply-binding-DpBwzIf9.cjs"),a=require("lodash-es"),v=require("@tailwindcss/aspect-ratio"),I=require("@tailwindcss/forms"),q=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"),u=require("react/jsx-runtime"),h=require("react"),R=require("@chaibuilder/runtime");function $(e,t){const r=e.filter(({_type:i})=>i==="GlobalBlock"||i==="PartialBlock");for(let i=0;i<r.length;i++){const l=r[i],s=a.get(l,"partialBlockId",a.get(l,"globalBlock",""));if(s==="")continue;let n=a.cloneDeep(a.get(t,s,[]));l._parent&&(n==null?void 0:n.length)>0&&(n=n.map(o=>(a.isEmpty(o._parent)&&(o._parent=l._parent),o)));const c=e.indexOf(l);e.splice(c,1,...n)}return e}const j=e=>{if(!e)return[];try{return JSON.parse(D(e)).filter(r=>!r._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function D(e){const t=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(t,r=>{const i=decodeURIComponent(r),l=i.indexOf("public");return l!==-1?i.substring(l+6):i})}async function M(e,t,r=[],i="",l){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:r,theme:{extend:E.getChaiBuilderTheme(e)},plugins:[I,q,v,L,f.chaiBuilderPlugin],corePlugins:{preflight:l},...i?{prefix:`${i}`}:{}}}).generateStylesFromContent(` ${l?"@tailwind base;":""}
2
2
  @tailwind components;
3
- @tailwind utilities;`,t)}const $=(e,t,n)=>{const i=JSON.stringify(e).replace(/#styles:([^"]*)/g,(s,l)=>`#styles:${l.replace(/,/g," ")}`.replace(/#styles:/g,""));return O(t,[i],[],"",n)},A=async(e,t=f.defaultThemeOptions,n=!1)=>await $(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 a.has(t,"$metadata")&&a.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,t.$metadata),e.children({...a.omit(t,"$metadata")})}const J=()=>m.jsx("div",{}),K=e=>{const{block:t,lang:n,fallbackLang:i,children:s,externalData:l,blocks:r,draft:o,pageProps:c,dataProviderMetadataCallback:h}=e,d=R.getRegisteredChaiBlock(t._type),k=a.get(d,"component",null),y=a.get(e.repeaterData,"index",-1),_=a.get(e.repeaterData,"dataKey",""),b=n===i?"":n,u=g.applyBindingToBlockProps(g.applyLanguage(t,b,d),l,{index:y,key:_}),w=g.getBlockTagAttributes(t,!1),C=V(r,t._id,g.getBlockRuntimeProps(t._type)),S=a.has(d,"dataProvider")&&a.isFunction(d.dataProvider),P={blockProps:{},inBuilder:!1,lang:n||i,...u,...w,...C};if(a.isNull(k))return null;if(S){const v=a.get(d,"suspenseFallback",J);return m.jsx(p.Suspense,{fallback:p.createElement(v),children:m.jsx(N,{lang:n,pageProps:c,block:t,dataProvider:d.dataProvider,...h?{dataProviderMetadataCallback:h}:{},draft:o,children:T=>p.createElement(k,{...P,...T,children:s({_id:t._id,_type:t._type,...a.isArray(u.repeaterItems)?{repeaterItems:g.applyLimit(u.repeaterItems,t),repeaterItemsBinding:u.repeaterItemsBinding}:{}})})})})}return m.jsx(p.Suspense,{children:p.createElement(k,{...P,children:s({_id:t._id,_type:t._type,...a.isArray(u.repeaterItems)?{repeaterItems:g.applyLimit(u.repeaterItems,t),repeaterItemsBinding:u.repeaterItemsBinding}:{}})})})},B=e=>{const{blocks:t,parent:n,repeaterData:i}=e;let s=a.uniqBy(a.filter(t,r=>a.has(r,"_id")&&(a.isEmpty(n)?!r._parent:r._parent===n)),"_id");const l=r=>a.filter(t,o=>o._parent===r).length>0;return a.map(s,r=>r?p.createElement(K,{...e,key:r._id,block:r},({_id:o,_type:c,repeaterItems:h,repeaterItemsBinding:d})=>c==="Repeater"?a.isArray(h)&&h.map((k,y)=>p.createElement(B,{...e,parent:r._id,key:`${r._id}-${y}`,repeaterData:{index:y,dataKey:d}})):l(o)?m.jsx(B,{...e,parent:r._id,repeaterData:i}):null):null)},V=(e,t,n)=>a.isEmpty(n)?{}:Object.entries(n).reduce((i,[s,l])=>{const r=[];let o=a.find(e,{_id:t});for(;o;)r.push(o),o=a.find(e,{_id:o._parent});const c=a.find(r,{_type:l.block});return c&&(i[s]=a.get(c,a.get(l,"prop"),null)),i},{});function U(e){if(a.has(e,"metadata")&&console.warn(" metadata is deprecated and will be removed in upcoming version, use pageProps instead"),a.isEmpty(e.lang)&&!a.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(a.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=f.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=f.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=f.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=g.applyChaiDataBinding;exports.RenderChaiBlocks=U;exports.convertToBlocks=D;exports.getMergedPartialBlocks=j;exports.getStylesForBlocks=A;
3
+ @tailwind utilities;`,t)}const O=(e,t,r)=>{const i=JSON.stringify(e).replace(/#styles:([^"]*)/g,(l,s)=>`#styles:${s.replace(/,/g," ")}`.replace(/#styles:/g,""));return M(t,[i],[],"",r)},A=async(e,t=f.defaultThemeOptions,r=!1)=>await O(e,t,r);async function K(e){const t=await e.dataProvider({pageProps:e.pageProps,block:e.block,lang:e.lang,draft:e.draft,inBuilder:!1});return a.has(t,"$metadata")&&a.isFunction(e.dataProviderMetadataCallback)&&e.dataProviderMetadataCallback(e.block,t.$metadata),e.children({...a.omit(t,"$metadata")})}const N=()=>u.jsx("div",{}),J=e=>{const{block:t,lang:r,fallbackLang:i,children:l,externalData:s,blocks:n,draft:c,pageProps:o,dataProviderMetadataCallback:m}=e,d=R.getRegisteredChaiBlock(t._type),y=a.get(d,"component",null),k=a.get(e.repeaterData,"index",-1),P=a.get(e.repeaterData,"dataKey",""),b=r===i?"":r,g=p.applyBindingToBlockProps(p.applyLanguage(t,b,d),s,{index:k,key:P}),C=p.getBlockTagAttributes(t,!1),w=V(n,t._id,p.getBlockRuntimeProps(t._type)),S=a.has(d,"dataProvider")&&a.isFunction(d.dataProvider),_={blockProps:{},inBuilder:!1,lang:r||i,...g,...C,...w};if(a.isNull(y))return null;if(S){const T=a.get(d,"suspenseFallback",N);return u.jsx(h.Suspense,{fallback:h.createElement(T),children:u.jsx(K,{lang:r,pageProps:o,block:t,dataProvider:d.dataProvider,...m?{dataProviderMetadataCallback:m}:{},draft:c,children:x=>h.createElement(y,{..._,...x,children:l({_id:t._id,_type:t._type,...a.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,t),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})})}return u.jsx(h.Suspense,{children:h.createElement(y,{..._,children:l({_id:t._id,_type:t._type,...a.isArray(g.repeaterItems)?{repeaterItems:p.applyLimit(g.repeaterItems,t),$repeaterItemsKey:g.$repeaterItemsKey}:{}})})})},B=e=>{const{blocks:t,parent:r,repeaterData:i}=e;let l=a.uniqBy(a.filter(t,n=>a.has(n,"_id")&&(a.isEmpty(r)?!n._parent:n._parent===r)),"_id");const s=n=>a.filter(t,c=>c._parent===n).length>0;return a.map(l,n=>n?h.createElement(J,{...e,key:n._id,block:n},({_id:c,_type:o,repeaterItems:m,$repeaterItemsKey:d})=>o==="Repeater"?a.isArray(m)&&m.map((y,k)=>u.jsx(u.Fragment,{children:h.createElement(B,{...e,parent:n._id,key:`${n._id}-${k}`,repeaterData:{index:k,dataKey:d}})})):s(c)?u.jsx(B,{...e,parent:n._id,repeaterData:i}):null):null)},V=(e,t,r)=>a.isEmpty(r)?{}:Object.entries(r).reduce((i,[l,s])=>{const n=[];let c=a.find(e,{_id:t});for(;c;)n.push(c),c=a.find(e,{_id:c._parent});const o=a.find(n,{_type:s.block});return o&&(i[l]=a.get(o,a.get(s,"prop"),null)),i},{});function U(e){if(a.isEmpty(e.lang)&&!a.isEmpty(e.fallbackLang))throw new Error("lang prop is required when fallbackLang is provided");if(a.isEmpty(e.blocks))return null;const t=e.lang??"en",r=e.fallbackLang??t;return u.jsx(B,{...e,lang:t,fallbackLang:r})}exports.getChaiThemeCssVariables=f.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=f.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=f.getThemeFontsLinkMarkup;exports.applyChaiDataBinding=p.applyChaiDataBinding;exports.RenderChaiBlocks=U;exports.convertToBlocks=j;exports.getMergedPartialBlocks=$;exports.getStylesForBlocks=A;
package/dist/render.js CHANGED
@@ -1,52 +1,52 @@
1
- import { d as F, c as O } from "./plugin-fnBB3TCm.js";
2
- import { a as Ce, b as ve, e as Se } from "./plugin-fnBB3TCm.js";
3
- import { a as $, b as M, g as A, c as N, d as w } from "./apply-binding-Z9D6RXG4.js";
4
- import { e as Ie } from "./apply-binding-Z9D6RXG4.js";
5
- import { get as c, cloneDeep as J, isEmpty as g, has as y, isFunction as S, omit as E, isNull as K, isArray as B, uniqBy as j, filter as C, map as q, find as _ } from "lodash-es";
1
+ import { d as F, c as R } 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 O, b as K, g as M, c as A, d as w } from "./apply-binding-CkrtJykq.js";
4
+ import { e as Te } from "./apply-binding-CkrtJykq.js";
5
+ import { get as c, cloneDeep as N, isEmpty as g, has as P, isFunction as v, omit as J, isNull as E, isArray as _, uniqBy as j, filter as C, map as q, find as y } from "lodash-es";
6
6
  import U from "@tailwindcss/aspect-ratio";
7
7
  import V from "@tailwindcss/forms";
8
8
  import G from "@tailwindcss/typography";
9
9
  import "tailwindcss-animate";
10
- import { g as W } from "./get-chai-builder-theme-ByeXCyGx.js";
10
+ import { g as W } from "./get-chai-builder-theme-BarMkcGH.js";
11
11
  import { createTailwindcss as z } from "@mhsdesign/jit-browser-tailwindcss";
12
12
  import H from "@tailwindcss/container-queries";
13
- import { jsx as u } from "react/jsx-runtime";
14
- import { Suspense as v, createElement as f } from "react";
15
- import { getRegisteredChaiBlock as Q } from "@chaibuilder/runtime";
16
- function ye(e, t) {
13
+ import { jsx as u, Fragment as Q } from "react/jsx-runtime";
14
+ import { Suspense as S, createElement as f } from "react";
15
+ import { getRegisteredChaiBlock as X } from "@chaibuilder/runtime";
16
+ function _e(e, t) {
17
17
  const a = e.filter(({ _type: n }) => n === "GlobalBlock" || n === "PartialBlock");
18
18
  for (let n = 0; n < a.length; n++) {
19
19
  const i = a[n], l = c(i, "partialBlockId", c(i, "globalBlock", ""));
20
20
  if (l === "") continue;
21
- let r = J(c(t, l, []));
21
+ let r = N(c(t, l, []));
22
22
  i._parent && (r == null ? void 0 : r.length) > 0 && (r = r.map((s) => (g(s._parent) && (s._parent = i._parent), s)));
23
23
  const o = e.indexOf(i);
24
24
  e.splice(o, 1, ...r);
25
25
  }
26
26
  return e;
27
27
  }
28
- const _e = (e) => {
28
+ const be = (e) => {
29
29
  if (!e) return [];
30
30
  try {
31
- return JSON.parse(X(e)).filter((a) => !a._type.startsWith("@chai"));
31
+ return JSON.parse(Y(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 X(e) {
36
+ function Y(e) {
37
37
  const t = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
38
38
  return e.replace(t, (a) => {
39
39
  const n = decodeURIComponent(a), i = n.indexOf("public");
40
40
  return i !== -1 ? n.substring(i + 6) : n;
41
41
  });
42
42
  }
43
- async function Y(e, t, a = [], n = "", i) {
43
+ async function Z(e, t, a = [], n = "", i) {
44
44
  return await z({
45
45
  tailwindConfig: {
46
46
  darkMode: "class",
47
47
  safelist: a,
48
48
  theme: { extend: W(e) },
49
- plugins: [V, G, U, H, O],
49
+ plugins: [V, G, U, H, R],
50
50
  corePlugins: { preflight: i },
51
51
  ...n ? { prefix: `${n}` } : {}
52
52
  }
@@ -57,11 +57,11 @@ async function Y(e, t, a = [], n = "", i) {
57
57
  t
58
58
  );
59
59
  }
60
- const Z = (e, t, a) => {
60
+ const ee = (e, t, a) => {
61
61
  const n = JSON.stringify(e).replace(/#styles:([^"]*)/g, (i, l) => `#styles:${l.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
62
- return Y(t, [n], [], "", a);
63
- }, Be = async (e, t = F, a = !1) => await Z(e, t, a);
64
- async function ee(e) {
62
+ return Z(t, [n], [], "", a);
63
+ }, Pe = async (e, t = F, a = !1) => await ee(e, t, a);
64
+ async function te(e) {
65
65
  const t = await e.dataProvider({
66
66
  pageProps: e.pageProps,
67
67
  block: e.block,
@@ -69,19 +69,16 @@ async function ee(e) {
69
69
  draft: e.draft,
70
70
  inBuilder: !1
71
71
  });
72
- return y(t, "$metadata") && S(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
73
- ...E(t, "$metadata")
72
+ return P(t, "$metadata") && v(e.dataProviderMetadataCallback) && e.dataProviderMetadataCallback(e.block, t.$metadata), e.children({
73
+ ...J(t, "$metadata")
74
74
  });
75
75
  }
76
- const te = () => /* @__PURE__ */ u("div", {}), ae = (e) => {
77
- const { block: t, lang: a, fallbackLang: n, children: i, externalData: l, blocks: r, draft: o, pageProps: s, dataProviderMetadataCallback: m } = e, d = Q(t._type), h = c(d, "component", null), k = c(e.repeaterData, "index", -1), x = c(e.repeaterData, "dataKey", ""), p = $(
78
- M(t, a === n ? "" : a, d),
76
+ const ae = () => /* @__PURE__ */ u("div", {}), re = (e) => {
77
+ const { block: t, lang: a, fallbackLang: n, children: i, externalData: l, blocks: r, draft: o, pageProps: s, dataProviderMetadataCallback: m } = e, d = X(t._type), h = c(d, "component", null), k = c(e.repeaterData, "index", -1), x = c(e.repeaterData, "dataKey", ""), p = O(
78
+ K(t, a === n ? "" : a, d),
79
79
  l,
80
- {
81
- index: k,
82
- key: x
83
- }
84
- ), I = A(t, !1), T = re(r, t._id, N(t._type)), L = y(d, "dataProvider") && S(d.dataProvider), P = {
80
+ { index: k, key: x }
81
+ ), I = M(t, !1), T = ne(r, t._id, A(t._type)), $ = P(d, "dataProvider") && v(d.dataProvider), B = {
85
82
  blockProps: {},
86
83
  inBuilder: !1,
87
84
  lang: a || n,
@@ -89,11 +86,11 @@ const te = () => /* @__PURE__ */ u("div", {}), ae = (e) => {
89
86
  ...I,
90
87
  ...T
91
88
  };
92
- if (K(h)) return null;
93
- if (L) {
94
- const D = c(d, "suspenseFallback", te);
95
- return /* @__PURE__ */ u(v, { fallback: f(D), children: /* @__PURE__ */ u(
96
- ee,
89
+ if (E(h)) return null;
90
+ if ($) {
91
+ const L = c(d, "suspenseFallback", ae);
92
+ return /* @__PURE__ */ u(S, { fallback: f(L), children: /* @__PURE__ */ u(
93
+ te,
97
94
  {
98
95
  lang: a,
99
96
  pageProps: s,
@@ -101,40 +98,40 @@ const te = () => /* @__PURE__ */ u("div", {}), ae = (e) => {
101
98
  dataProvider: d.dataProvider,
102
99
  ...m ? { dataProviderMetadataCallback: m } : {},
103
100
  draft: o,
104
- children: (R) => f(h, {
105
- ...P,
106
- ...R,
101
+ children: (D) => f(h, {
102
+ ...B,
103
+ ...D,
107
104
  children: i({
108
105
  _id: t._id,
109
106
  _type: t._type,
110
- ...B(p.repeaterItems) ? {
107
+ ..._(p.repeaterItems) ? {
111
108
  repeaterItems: w(p.repeaterItems, t),
112
- repeaterItemsBinding: p.repeaterItemsBinding
109
+ $repeaterItemsKey: p.$repeaterItemsKey
113
110
  } : {}
114
111
  })
115
112
  })
116
113
  }
117
114
  ) });
118
115
  }
119
- return /* @__PURE__ */ u(v, { children: f(h, {
120
- ...P,
116
+ return /* @__PURE__ */ u(S, { children: f(h, {
117
+ ...B,
121
118
  children: i({
122
119
  _id: t._id,
123
120
  _type: t._type,
124
- ...B(p.repeaterItems) ? {
121
+ ..._(p.repeaterItems) ? {
125
122
  repeaterItems: w(p.repeaterItems, t),
126
- repeaterItemsBinding: p.repeaterItemsBinding
123
+ $repeaterItemsKey: p.$repeaterItemsKey
127
124
  } : {}
128
125
  })
129
126
  }) });
130
127
  }, b = (e) => {
131
128
  const { blocks: t, parent: a, repeaterData: n } = e;
132
129
  let i = j(
133
- C(t, (r) => y(r, "_id") && (g(a) ? !r._parent : r._parent === a)),
130
+ C(t, (r) => P(r, "_id") && (g(a) ? !r._parent : r._parent === a)),
134
131
  "_id"
135
132
  );
136
133
  const l = (r) => C(t, (o) => o._parent === r).length > 0;
137
- return q(i, (r) => r ? /* @__PURE__ */ f(ae, { ...e, key: r._id, block: r }, ({ _id: o, _type: s, repeaterItems: m, repeaterItemsBinding: d }) => s === "Repeater" ? B(m) && m.map((h, k) => /* @__PURE__ */ f(
134
+ return q(i, (r) => r ? /* @__PURE__ */ f(re, { ...e, key: r._id, block: r }, ({ _id: o, _type: s, repeaterItems: m, $repeaterItemsKey: d }) => s === "Repeater" ? _(m) && m.map((h, k) => /* @__PURE__ */ u(Q, { children: /* @__PURE__ */ f(
138
135
  b,
139
136
  {
140
137
  ...e,
@@ -142,17 +139,17 @@ const te = () => /* @__PURE__ */ u("div", {}), ae = (e) => {
142
139
  key: `${r._id}-${k}`,
143
140
  repeaterData: { index: k, dataKey: d }
144
141
  }
145
- )) : l(o) ? /* @__PURE__ */ u(b, { ...e, parent: r._id, repeaterData: n }) : null) : null);
146
- }, re = (e, t, a) => g(a) ? {} : Object.entries(a).reduce((n, [i, l]) => {
142
+ ) })) : l(o) ? /* @__PURE__ */ u(b, { ...e, parent: r._id, repeaterData: n }) : null) : null);
143
+ }, ne = (e, t, a) => g(a) ? {} : Object.entries(a).reduce((n, [i, l]) => {
147
144
  const r = [];
148
- let o = _(e, { _id: t });
145
+ let o = y(e, { _id: t });
149
146
  for (; o; )
150
- r.push(o), o = _(e, { _id: o._parent });
151
- const s = _(r, { _type: l.block });
147
+ r.push(o), o = y(e, { _id: o._parent });
148
+ const s = y(r, { _type: l.block });
152
149
  return s && (n[i] = c(s, c(l, "prop"), null)), n;
153
150
  }, {});
154
- function be(e) {
155
- if (y(e, "metadata") && console.warn(" metadata is deprecated and will be removed in upcoming version, use pageProps instead"), g(e.lang) && !g(e.fallbackLang))
151
+ function Be(e) {
152
+ if (g(e.lang) && !g(e.fallbackLang))
156
153
  throw new Error("lang prop is required when fallbackLang is provided");
157
154
  if (g(e.blocks))
158
155
  return null;
@@ -160,12 +157,12 @@ function be(e) {
160
157
  return /* @__PURE__ */ u(b, { ...e, lang: t, fallbackLang: a });
161
158
  }
162
159
  export {
163
- be as RenderChaiBlocks,
164
- Ie as applyChaiDataBinding,
165
- _e as convertToBlocks,
166
- Ce as getChaiThemeCssVariables,
167
- ye as getMergedPartialBlocks,
168
- Be as getStylesForBlocks,
160
+ Be as RenderChaiBlocks,
161
+ Te as applyChaiDataBinding,
162
+ be as convertToBlocks,
163
+ Se as getChaiThemeCssVariables,
164
+ _e as getMergedPartialBlocks,
165
+ Pe as getStylesForBlocks,
169
166
  ve as getThemeFontsCSSImport,
170
- Se as getThemeFontsLinkMarkup
167
+ xe as getThemeFontsLinkMarkup
171
168
  };
package/dist/tailwind.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./plugin-C01tjI6V.cjs"),o=require("@tailwindcss/aspect-ratio"),a=require("@tailwindcss/forms"),i=require("@tailwindcss/typography"),n=require("tailwindcss-animate"),d=require("./get-chai-builder-theme-CeaKvOZ8.cjs");function t(){return{colors:{border:"hsl(var(--border))",input:"hsl(var(--input))",ring:"hsl(var(--ring))",background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",primary:{DEFAULT:"hsl(var(--primary))",foreground:"hsl(var(--primary-foreground))"},secondary:{DEFAULT:"hsl(var(--secondary))",foreground:"hsl(var(--secondary-foreground))"},destructive:{DEFAULT:"hsl(var(--destructive))",foreground:"hsl(var(--destructive-foreground))"},muted:{DEFAULT:"hsl(var(--muted))",foreground:"hsl(var(--muted-foreground))"},accent:{DEFAULT:"hsl(var(--accent))",foreground:"hsl(var(--accent-foreground))"},popover:{DEFAULT:"hsl(var(--popover))",foreground:"hsl(var(--popover-foreground))"},card:{DEFAULT:"hsl(var(--card))",foreground:"hsl(var(--card-foreground))"}},borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}}const u=r=>({darkMode:"class",content:[...r,"node_modules/@chaibuilder/sdk/dist/*.{js,cjs}"],theme:{extend:t()},plugins:[n,i,a,o]});exports.chaiBuilderPlugin=e.chaiBuilderPlugin;exports.getChaiBuilderTheme=d.getChaiBuilderTheme;exports.getChaiBuilderTailwindConfig=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./plugin-CSgw-f78.cjs"),o=require("@tailwindcss/aspect-ratio"),a=require("@tailwindcss/forms"),i=require("@tailwindcss/typography"),n=require("tailwindcss-animate"),d=require("./get-chai-builder-theme-B1tr_NJB.cjs");function t(){return{colors:{border:"hsl(var(--border))",input:"hsl(var(--input))",ring:"hsl(var(--ring))",background:"hsl(var(--background))",foreground:"hsl(var(--foreground))",primary:{DEFAULT:"hsl(var(--primary))",foreground:"hsl(var(--primary-foreground))"},secondary:{DEFAULT:"hsl(var(--secondary))",foreground:"hsl(var(--secondary-foreground))"},destructive:{DEFAULT:"hsl(var(--destructive))",foreground:"hsl(var(--destructive-foreground))"},muted:{DEFAULT:"hsl(var(--muted))",foreground:"hsl(var(--muted-foreground))"},accent:{DEFAULT:"hsl(var(--accent))",foreground:"hsl(var(--accent-foreground))"},popover:{DEFAULT:"hsl(var(--popover))",foreground:"hsl(var(--popover-foreground))"},card:{DEFAULT:"hsl(var(--card))",foreground:"hsl(var(--card-foreground))"}},borderRadius:{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"},keyframes:{"accordion-down":{from:{height:"0"},to:{height:"var(--radix-accordion-content-height)"}},"accordion-up":{from:{height:"var(--radix-accordion-content-height)"},to:{height:"0"}}},animation:{"accordion-down":"accordion-down 0.2s ease-out","accordion-up":"accordion-up 0.2s ease-out"}}}const u=r=>({darkMode:"class",content:[...r,"node_modules/@chaibuilder/sdk/dist/*.{js,cjs}"],theme:{extend:t()},plugins:[n,i,a,o]});exports.chaiBuilderPlugin=e.chaiBuilderPlugin;exports.getChaiBuilderTheme=d.getChaiBuilderTheme;exports.getChaiBuilderTailwindConfig=u;
package/dist/tailwind.js CHANGED
@@ -1,9 +1,9 @@
1
- import { c as g } from "./plugin-fnBB3TCm.js";
1
+ import { c as g } from "./plugin-BOcGV_IY.js";
2
2
  import o from "@tailwindcss/aspect-ratio";
3
3
  import a from "@tailwindcss/forms";
4
4
  import e from "@tailwindcss/typography";
5
5
  import d from "tailwindcss-animate";
6
- import { g as m } from "./get-chai-builder-theme-ByeXCyGx.js";
6
+ import { g as m } from "./get-chai-builder-theme-BarMkcGH.js";
7
7
  function n() {
8
8
  return {
9
9
  colors: {