@chaibuilder/sdk 2.1.9 → 2.2.0

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.js CHANGED
@@ -6583,7 +6583,7 @@ const BlockCard = ({
6583
6583
  ] });
6584
6584
  const L = filter(w, (y, j) => j % 2 === 0), v = filter(w, (y, j) => j % 2 === 1);
6585
6585
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
6586
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-b border-border p-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
6586
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
6587
6587
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
6588
6588
  /* @__PURE__ */ jsx(
6589
6589
  Input$1,
package/dist/render.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./chai-theme-helpers-BjWE6otR.cjs"),s=require("lodash-es"),m=require("./getSplitClasses-DodqA_KW.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),b=require("@tailwindcss/aspect-ratio"),k=require("@tailwindcss/container-queries"),M=require("@tailwindcss/forms"),N=require("@tailwindcss/typography"),B=require("./plugin-BiiuylVf.cjs"),g=require("react/jsx-runtime"),T=require("@chaibuilder/runtime"),p=require("react"),Y=require("tailwind-merge"),A=(e,i="")=>{const{classes:n}=m.getSplitChaiClasses(e),t=n.split(" ").map(r=>r.split(" ").map(a=>{if(a==="")return"";if(a.includes(":")){const u=a.split(":");return u[u.length-1]=i+s.last(u),u.join(":")}return`${i}${a}`}).join(" "));return s.flattenDeep(t).join(" ")},I=e=>{if(!e)return[];try{return JSON.parse(J(e)).filter(n=>!n._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function J(e){const i=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(i,n=>{const t=decodeURIComponent(n),r=t.indexOf("public");return r!==-1?t.substring(r+6):t})}async function K(e,i,n=[],t="",r){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:n,theme:{extend:B.getChaiBuilderTheme(e)},plugins:[M,N,b,k,B.chaiBuilderPlugin],corePlugins:{preflight:r},...t?{prefix:`${t}`}:{}}}).generateStylesFromContent(` ${r?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./chai-theme-helpers-BjWE6otR.cjs"),n=require("lodash-es"),R=require("@mhsdesign/jit-browser-tailwindcss"),O=require("@tailwindcss/aspect-ratio"),F=require("@tailwindcss/container-queries"),L=require("@tailwindcss/forms"),M=require("@tailwindcss/typography"),C=require("./plugin-BiiuylVf.cjs"),u=require("react/jsx-runtime"),P=require("@chaibuilder/runtime"),f=require("react"),N=require("tailwind-merge"),p=require("./getSplitClasses-DodqA_KW.cjs"),A=e=>{if(!e)return[];try{return JSON.parse(I(e)).filter(t=>!t._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function I(e){const i=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(i,t=>{const s=decodeURIComponent(t),a=s.indexOf("public");return a!==-1?s.substring(a+6):s})}async function J(e,i,t=[],s="",a){return await R.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:t,theme:{extend:C.getChaiBuilderTheme(e)},plugins:[L,M,O,F,C.chaiBuilderPlugin],corePlugins:{preflight:a},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${a?"@tailwind base;":""}
2
2
  @tailwind components;
3
- @tailwind utilities;`,i)}const V=(e,i,n)=>{const t=JSON.stringify(e).replace(/#styles:([^"]*)/g,(r,c)=>`#styles:${c.replace(/,/g," ")}`.replace(/#styles:/g,""));return K(i,[t],[],"",n)},L=async(e,i=S.defaultThemeOptions,n=!1)=>await V(e,i,n);async function U(e){const i=await(e==null?void 0:e.dataProvider(e.block,e.lang,e.metadata));return s.has(i,"$metadata")&&e.dataProviderMetadataCallback(e.block,i.$metadata),g.jsx(p.Suspense,{children:p.createElement(e.component,{...s.omit(e.props,["dataProvider","dataProviderMetadataCallback"]),...s.omit(i,"$metadata"),key:`${e.block._id}-async`})})}const z=s.memoize((e,i)=>{const{baseClasses:n,classes:t}=m.getSplitChaiClasses(e),r=Y.twMerge(n,t);return i===""?r.replace(m.STYLES_KEY,"").trim():A(r,i).replace(m.STYLES_KEY,"").trim()}),j=(e,i)=>{const n=s.cloneDeep(e);return s.forEach(s.keys(n),t=>{if(s.isString(n[t])){let r=n[t];const c=/\{\{(.*?)\}\}/g,l=r.match(c);l&&l.forEach(a=>{const u=a.slice(2,-2),h=s.get(i,u,a);r=r.replace(a,h)}),n[t]=r}s.isObject(n[t])&&(n[t]=j(n[t],i))}),n};function D(e,i){const n=s.get(e,`${i}_attrs`,{}),t=s.keys(n).join(" ");return s.includes(t,"x-show")&&!s.includes(t,"x-transition")&&(n["x-transition"]=""),n}function W(e,i){const n={};return Object.keys(e).forEach(t=>{if(s.isString(e[t])&&e[t].startsWith(m.STYLES_KEY)){const r=z(e[t],i);n[t]={className:r,...D(e,t)}}}),n}function H(e,i,n){if(s.isEmpty(i))return e;const t=s.cloneDeep(e),r=s.get(n,"i18nProps",[]);return s.forEach(s.keys(t),c=>{r.includes(c)&&!s.isEmpty(i)&&(t[c]=s.get(t,`${c}-${i}`,t[c]))}),t}const G=s.memoize(e=>{const i=T.getRegisteredChaiBlock(e),n=s.get(i,"schema.properties",{});return Object.fromEntries(Object.entries(n).filter(([,t])=>s.get(t,"runtime",!1)))}),Q=(e,i,n)=>s.isEmpty(n)?{}:Object.entries(n).reduce((t,[r,c])=>{const l=[];let a=s.find(e,{_id:i});for(;a;)l.push(a),a=s.find(e,{_id:a._parent});const u=s.find(l,{_type:c.block});return u&&(t[r]=s.get(u,s.get(c,"prop"),null)),t},{}),X=()=>g.jsx("span",{children:"Loading..."});function E({blocks:e,parent:i,classPrefix:n="",externalData:t={},blockModifierCallback:r=null,lang:c="",fallbackLang:l="",metadata:a={},dataProviderMetadataCallback:u=()=>{}}){const h=e,P=o=>W(o,n),$=i?s.filter(e,{_parent:i}):s.filter(e,o=>s.isEmpty(o._parent));return s.uniqBy($,"_id").map((o,q)=>{const y={},v=s.filter(h,{_parent:o._id});y.children=v.length>0?g.jsx(E,{externalData:t,classPrefix:n,parent:o._id,blocks:h,lang:c||l,metadata:a,fallbackLang:l,dataProviderMetadataCallback:u},`${o._id}-children`):null;const d=T.getRegisteredChaiBlock(o._type);if(d!==null){let f=o;const _=d.component;f={...d.defaults,...o},r&&(f=r(f));const x=c===l?"":c,O=Q(h,o._id,G(o._type)),C=j(H(o,x,d),t),w=s.omit({blockProps:{},inBuilder:!1,...f,index:q,...C,...P(C),...y,...O,metadata:a,lang:c||l,key:o._id},["_parent"]);if(s.has(d,"dataProvider")){const R=s.get(d,"suspenseFallback",X);return g.jsx(p.Suspense,{fallback:p.createElement(R),children:g.jsx(U,{dataProviderMetadataCallback:u,lang:c||l,metadata:a,dataProvider:d.dataProvider,block:o,component:_,props:w},`${o._id}-async`)},`${o._id}-suspense`)}return g.jsx(p.Suspense,{children:p.createElement(_,w)},`${o._id}-suspense`)}return g.jsxs("noscript",{children:[o._type," not found"]},`${o._id}-noscript`)})}exports.getChaiThemeCssVariables=S.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=S.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=S.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=E;exports.convertToBlocks=I;exports.getStylesForBlocks=L;
3
+ @tailwind utilities;`,i)}const V=(e,i,t)=>{const s=JSON.stringify(e).replace(/#styles:([^"]*)/g,(a,c)=>`#styles:${c.replace(/,/g," ")}`.replace(/#styles:/g,""));return J(i,[s],[],"",t)},Y=async(e,i=m.defaultThemeOptions,t=!1)=>await V(e,i,t);async function K(e){const i=e.forwardProps?await e.dataProvider({...e.forwardProps,...e.block,lang:e.lang,draft:e.draft,inBuilder:e.inBuilder}):await e.dataProvider(e.block,e.lang,e.metadata??{});return n.has(i,"$metadata")&&e.dataProviderMetadataCallback(e.block,i.$metadata),u.jsx(f.Suspense,{children:f.createElement(e.component,{...n.omit(e.props,["dataProvider","dataProviderMetadataCallback"]),...n.omit(i,"$metadata"),key:`${e.block._id}-async`})})}const z=n.memoize(e=>{const{baseClasses:i,classes:t}=p.getSplitChaiClasses(e);return N.twMerge(i,t).replace(p.STYLES_KEY,"").trim()}),T=(e,i)=>{const t=n.cloneDeep(e);return n.forEach(n.keys(t),s=>{if(n.isString(t[s])){let a=t[s];const c=/\{\{(.*?)\}\}/g,l=a.match(c);l&&l.forEach(o=>{const d=o.slice(2,-2),h=n.get(i,d,o);a=a.replace(o,h)}),t[s]=a}n.isObject(t[s])&&(t[s]=T(t[s],i))}),t};function U(e,i){const t=n.get(e,`${i}_attrs`,{}),s=n.keys(t).join(" ");return n.includes(s,"x-show")&&!n.includes(s,"x-transition")&&(t["x-transition"]=""),t}function W(e){const i={};return Object.keys(e).forEach(t=>{if(n.isString(e[t])&&e[t].startsWith(p.STYLES_KEY)){const s=z(e[t]);i[t]={className:s,...U(e,t)}}}),i}function D(e,i,t){if(n.isEmpty(i))return e;const s=n.cloneDeep(e),a=n.get(t,"i18nProps",[]);return n.forEach(n.keys(s),c=>{a.includes(c)&&!n.isEmpty(i)&&(s[c]=n.get(s,`${c}-${i}`,s[c]))}),s}const H=n.memoize(e=>{const i=P.getRegisteredChaiBlock(e),t=n.get(i,"schema.properties",{});return Object.fromEntries(Object.entries(t).filter(([,s])=>n.get(s,"runtime",!1)))}),G=(e,i,t)=>n.isEmpty(t)?{}:Object.entries(t).reduce((s,[a,c])=>{const l=[];let o=n.find(e,{_id:i});for(;o;)l.push(o),o=n.find(e,{_id:o._parent});const d=n.find(l,{_type:c.block});return d&&(s[a]=n.get(d,n.get(c,"prop"),null)),s},{}),Q=()=>u.jsx("span",{children:"Loading..."});function X(e){n.has(e,"metadata")&&console.warn(" metadata is deprecated and will be removed in upcoming version, use forwardProps instead");const i=e.lang??"en",t=e.fallbackLang??i;return u.jsx(j,{...e,lang:i,fallbackLang:t})}function j({blocks:e,parent:i,externalData:t={},lang:s="en",fallbackLang:a="en",metadata:c={},forwardProps:l={},dataProviderMetadataCallback:o=()=>{},draft:d=!1}){const h=e,x=r=>W(r),E=i?n.filter(e,{_parent:i}):n.filter(e,r=>n.isEmpty(r._parent));return n.uniqBy(E,"_id").map((r,b)=>{const S={},k=n.filter(h,{_parent:r._id});S.children=k.length>0?u.jsx(j,{externalData:t,parent:r._id,blocks:h,lang:s,fallbackLang:a,forwardProps:l,dataProviderMetadataCallback:o,draft:d,metadata:c},`${r._id}-children`):null;const g=P.getRegisteredChaiBlock(r._type);if(g!==null){let y=r;const _=g.component;y={...g.defaults,...r};const v=s===a?"":s,$=G(h,r._id,H(r._type)),w=T(D(r,v,g),t),B=n.omit({...l,...y,...w,...x(w),...S,...$,index:b,lang:s,key:r._id,draft:d,blockProps:{},inBuilder:!1},["_parent"]);if(n.has(g,"dataProvider")){const q=n.get(g,"suspenseFallback",Q);return u.jsx(f.Suspense,{fallback:f.createElement(q),children:u.jsx(K,{inBuilder:!1,dataProviderMetadataCallback:o,lang:s,metadata:c,dataProvider:g.dataProvider,block:r,component:_,props:B,forwardProps:l,draft:d},`${r._id}-async`)},`${r._id}-suspense`)}return u.jsx(f.Suspense,{children:f.createElement(_,B)},`${r._id}-suspense`)}return u.jsxs("noscript",{children:[r._type," not found"]},`${r._id}-noscript`)})}exports.getChaiThemeCssVariables=m.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=m.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=m.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=X;exports.convertToBlocks=A;exports.getStylesForBlocks=Y;
package/dist/render.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ChaiFontViaUrl } from '@chaibuilder/runtime';
2
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
2
3
 
3
4
  declare type BorderRadiusValue = false | string;
4
5
 
@@ -34,6 +35,13 @@ export declare const convertToBlocks: (chaiFormatContent: string) => ChaiBlock[]
34
35
 
35
36
  export declare const getChaiThemeCssVariables: (chaiTheme: Partial<ChaiBuilderThemeValues>) => string;
36
37
 
38
+ /**
39
+ * Get the tailwind css for the blocks
40
+ * @param blocks - The blocks to get the tailwind css for
41
+ * @param themeOptions - The theme options to use
42
+ * @param includeBaseStyles - Whether to include the base styles
43
+ * @returns The tailwind css for the blocks
44
+ */
37
45
  export declare const getStylesForBlocks: (blocks: ChaiBlock[], themeOptions?: ChaiBuilderThemeOptions, includeBaseStyles?: boolean) => Promise<string>;
38
46
 
39
47
  export declare const getThemeFontsCSSImport: (fonts: ChaiFontViaUrl[]) => any;
@@ -42,18 +50,18 @@ export declare const getThemeFontsLinkMarkup: (fonts: ChaiFontViaUrl[]) => any;
42
50
 
43
51
  declare type HSLColor = string;
44
52
 
45
- export declare function RenderChaiBlocks({ blocks, parent, classPrefix, externalData, blockModifierCallback, lang, fallbackLang, metadata, dataProviderMetadataCallback, }: RenderChaiBlocksProps): any;
53
+ export declare function RenderChaiBlocks(props: RenderChaiBlocksProps): JSX_2.Element;
46
54
 
47
55
  declare type RenderChaiBlocksProps = {
48
56
  blocks: ChaiBlock[];
49
57
  parent?: string;
50
- classPrefix?: string;
51
58
  externalData?: Record<string, any>;
52
- blockModifierCallback?: (block: ChaiBlock) => ChaiBlock;
53
59
  lang?: string;
54
60
  fallbackLang?: string;
55
- metadata?: Record<string, any>;
61
+ forwardProps?: Record<string, any>;
62
+ draft?: boolean;
56
63
  dataProviderMetadataCallback?: (block: ChaiBlock, meta: Record<string, any>) => void;
64
+ metadata?: Record<string, any>;
57
65
  };
58
66
 
59
67
  declare type VariableKey = string;
package/dist/render.js CHANGED
@@ -1,51 +1,41 @@
1
- import { d as Y } from "./chai-theme-helpers-FO9vdd-R.js";
2
- import { a as At, b as It, c as Jt } from "./chai-theme-helpers-FO9vdd-R.js";
3
- import { last as q, flattenDeep as z, has as v, omit as y, memoize as O, get as d, filter as h, isEmpty as g, uniqBy as D, cloneDeep as E, forEach as x, keys as C, isString as R, isObject as G, find as _, includes as j } from "lodash-es";
4
- import { g as F, S } from "./getSplitClasses-DphwgQiE.js";
5
- import { createTailwindcss as H } from "@mhsdesign/jit-browser-tailwindcss";
6
- import L from "@tailwindcss/aspect-ratio";
7
- import Q from "@tailwindcss/container-queries";
8
- import X from "@tailwindcss/forms";
9
- import Z from "@tailwindcss/typography";
10
- import { g as k, c as tt } from "./plugin-B09c0d5S.js";
11
- import { jsx as p, jsxs as et } from "react/jsx-runtime";
12
- import { getRegisteredChaiBlock as N } from "@chaibuilder/runtime";
13
- import b, { Suspense as w, createElement as nt } from "react";
14
- import { twMerge as st } from "tailwind-merge";
15
- const rt = (t, s = "") => {
16
- const { classes: n } = F(t), e = n.split(" ").map((r) => r.split(" ").map((a) => {
17
- if (a === "") return "";
18
- if (a.includes(":")) {
19
- const l = a.split(":");
20
- return l[l.length - 1] = s + q(l), l.join(":");
21
- }
22
- return `${s}${a}`;
23
- }).join(" "));
24
- return z(e).join(" ");
25
- }, Rt = (t) => {
26
- if (!t) return [];
1
+ import { d as U } from "./chai-theme-helpers-FO9vdd-R.js";
2
+ import { a as ke, b as Fe, c as Ne } from "./chai-theme-helpers-FO9vdd-R.js";
3
+ import { has as S, omit as _, memoize as x, get as l, filter as p, isEmpty as g, uniqBy as W, cloneDeep as O, forEach as T, keys as y, isString as E, isObject as Y, find as h, includes as v } from "lodash-es";
4
+ import { createTailwindcss as q } from "@mhsdesign/jit-browser-tailwindcss";
5
+ import z from "@tailwindcss/aspect-ratio";
6
+ import D from "@tailwindcss/container-queries";
7
+ import G from "@tailwindcss/forms";
8
+ import H from "@tailwindcss/typography";
9
+ import { g as Q, c as X } from "./plugin-B09c0d5S.js";
10
+ import { jsx as m, jsxs as Z } from "react/jsx-runtime";
11
+ import { getRegisteredChaiBlock as R } from "@chaibuilder/runtime";
12
+ import j, { Suspense as w, createElement as ee } from "react";
13
+ import { twMerge as te } from "tailwind-merge";
14
+ import { g as ne, S as k } from "./getSplitClasses-DphwgQiE.js";
15
+ const Oe = (e) => {
16
+ if (!e) return [];
27
17
  try {
28
- return JSON.parse(it(t)).filter((n) => !n._type.startsWith("@chai"));
18
+ return JSON.parse(se(e)).filter((t) => !t._type.startsWith("@chai"));
29
19
  } catch {
30
20
  return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
31
21
  }
32
22
  };
33
- function it(t) {
23
+ function se(e) {
34
24
  const s = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
35
- return t.replace(s, (n) => {
36
- const e = decodeURIComponent(n), r = e.indexOf("public");
37
- return r !== -1 ? e.substring(r + 6) : e;
25
+ return e.replace(s, (t) => {
26
+ const n = decodeURIComponent(t), r = n.indexOf("public");
27
+ return r !== -1 ? n.substring(r + 6) : n;
38
28
  });
39
29
  }
40
- async function ot(t, s, n = [], e = "", r) {
41
- return await H({
30
+ async function ie(e, s, t = [], n = "", r) {
31
+ return await q({
42
32
  tailwindConfig: {
43
33
  darkMode: "class",
44
- safelist: n,
45
- theme: { extend: k(t) },
46
- plugins: [X, Z, L, Q, tt],
34
+ safelist: t,
35
+ theme: { extend: Q(e) },
36
+ plugins: [G, H, z, D, X],
47
37
  corePlugins: { preflight: r },
48
- ...e ? { prefix: `${e}` } : {}
38
+ ...n ? { prefix: `${n}` } : {}
49
39
  }
50
40
  }).generateStylesFromContent(
51
41
  ` ${r ? "@tailwind base;" : ""}
@@ -54,148 +44,168 @@ async function ot(t, s, n = [], e = "", r) {
54
44
  s
55
45
  );
56
46
  }
57
- const at = (t, s, n) => {
58
- const e = JSON.stringify(t).replace(/#styles:([^"]*)/g, (r, o) => `#styles:${o.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
59
- return ot(s, [e], [], "", n);
60
- }, Ft = async (t, s = Y, n = !1) => await at(t, s, n);
61
- async function ct(t) {
62
- const s = await (t == null ? void 0 : t.dataProvider(t.block, t.lang, t.metadata));
63
- return v(s, "$metadata") && t.dataProviderMetadataCallback(t.block, s.$metadata), /* @__PURE__ */ p(w, { children: b.createElement(t.component, {
64
- ...y(t.props, ["dataProvider", "dataProviderMetadataCallback"]),
65
- ...y(s, "$metadata"),
66
- key: `${t.block._id}-async`
47
+ const re = (e, s, t) => {
48
+ const n = JSON.stringify(e).replace(/#styles:([^"]*)/g, (r, a) => `#styles:${a.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
49
+ return ie(s, [n], [], "", t);
50
+ }, Te = async (e, s = U, t = !1) => await re(e, s, t);
51
+ async function ae(e) {
52
+ const s = e.forwardProps ? await e.dataProvider({
53
+ ...e.forwardProps,
54
+ ...e.block,
55
+ lang: e.lang,
56
+ draft: e.draft,
57
+ inBuilder: e.inBuilder
58
+ }) : await e.dataProvider(
59
+ e.block,
60
+ e.lang,
61
+ e.metadata ?? {}
62
+ );
63
+ return S(s, "$metadata") && e.dataProviderMetadataCallback(e.block, s.$metadata), /* @__PURE__ */ m(w, { children: j.createElement(e.component, {
64
+ ..._(e.props, ["dataProvider", "dataProviderMetadataCallback"]),
65
+ ..._(s, "$metadata"),
66
+ key: `${e.block._id}-async`
67
67
  }) });
68
68
  }
69
- const lt = O((t, s) => {
70
- const { baseClasses: n, classes: e } = F(t), r = st(n, e);
71
- return s === "" ? r.replace(S, "").trim() : rt(r, s).replace(S, "").trim();
72
- }), A = (t, s) => {
73
- const n = E(t);
74
- return x(C(n), (e) => {
75
- if (R(n[e])) {
76
- let r = n[e];
77
- const o = /\{\{(.*?)\}\}/g, c = r.match(o);
78
- c && c.forEach((a) => {
79
- const l = a.slice(2, -2), m = d(s, l, a);
80
- r = r.replace(a, m);
81
- }), n[e] = r;
69
+ const oe = x((e) => {
70
+ const { baseClasses: s, classes: t } = ne(e);
71
+ return te(s, t).replace(k, "").trim();
72
+ }), F = (e, s) => {
73
+ const t = O(e);
74
+ return T(y(t), (n) => {
75
+ if (E(t[n])) {
76
+ let r = t[n];
77
+ const a = /\{\{(.*?)\}\}/g, c = r.match(a);
78
+ c && c.forEach((o) => {
79
+ const d = o.slice(2, -2), f = l(s, d, o);
80
+ r = r.replace(o, f);
81
+ }), t[n] = r;
82
82
  }
83
- G(n[e]) && (n[e] = A(n[e], s));
84
- }), n;
83
+ Y(t[n]) && (t[n] = F(t[n], s));
84
+ }), t;
85
85
  };
86
- function dt(t, s) {
87
- const n = d(t, `${s}_attrs`, {}), e = C(n).join(" ");
88
- return j(e, "x-show") && !j(e, "x-transition") && (n["x-transition"] = ""), n;
86
+ function ce(e, s) {
87
+ const t = l(e, `${s}_attrs`, {}), n = y(t).join(" ");
88
+ return v(n, "x-show") && !v(n, "x-transition") && (t["x-transition"] = ""), t;
89
89
  }
90
- function ut(t, s) {
91
- const n = {};
92
- return Object.keys(t).forEach((e) => {
93
- if (R(t[e]) && t[e].startsWith(S)) {
94
- const r = lt(t[e], s);
95
- n[e] = {
96
- className: r,
97
- ...dt(t, e)
90
+ function le(e) {
91
+ const s = {};
92
+ return Object.keys(e).forEach((t) => {
93
+ if (E(e[t]) && e[t].startsWith(k)) {
94
+ const n = oe(e[t]);
95
+ s[t] = {
96
+ className: n,
97
+ ...ce(e, t)
98
98
  };
99
99
  }
100
- }), n;
100
+ }), s;
101
101
  }
102
- function pt(t, s, n) {
103
- if (g(s)) return t;
104
- const e = E(t), r = d(n, "i18nProps", []);
105
- return x(C(e), (o) => {
106
- r.includes(o) && !g(s) && (e[o] = d(e, `${o}-${s}`, e[o]));
107
- }), e;
102
+ function de(e, s, t) {
103
+ if (g(s)) return e;
104
+ const n = O(e), r = l(t, "i18nProps", []);
105
+ return T(y(n), (a) => {
106
+ r.includes(a) && !g(s) && (n[a] = l(n, `${a}-${s}`, n[a]));
107
+ }), n;
108
108
  }
109
- const mt = O((t) => {
110
- const s = N(t), n = d(s, "schema.properties", {});
111
- return Object.fromEntries(Object.entries(n).filter(([, e]) => d(e, "runtime", !1)));
112
- }), ft = (t, s, n) => g(n) ? {} : Object.entries(n).reduce((e, [r, o]) => {
109
+ const ue = x((e) => {
110
+ const s = R(e), t = l(s, "schema.properties", {});
111
+ return Object.fromEntries(Object.entries(t).filter(([, n]) => l(n, "runtime", !1)));
112
+ }), me = (e, s, t) => g(t) ? {} : Object.entries(t).reduce((n, [r, a]) => {
113
113
  const c = [];
114
- let a = _(t, { _id: s });
115
- for (; a; )
116
- c.push(a), a = _(t, { _id: a._parent });
117
- const l = _(c, { _type: o.block });
118
- return l && (e[r] = d(l, d(o, "prop"), null)), e;
119
- }, {}), gt = () => /* @__PURE__ */ p("span", { children: "Loading..." });
120
- function ht({
121
- blocks: t,
114
+ let o = h(e, { _id: s });
115
+ for (; o; )
116
+ c.push(o), o = h(e, { _id: o._parent });
117
+ const d = h(c, { _type: a.block });
118
+ return d && (n[r] = l(d, l(a, "prop"), null)), n;
119
+ }, {}), fe = () => /* @__PURE__ */ m("span", { children: "Loading..." });
120
+ function Ee(e) {
121
+ S(e, "metadata") && console.warn(" metadata is deprecated and will be removed in upcoming version, use forwardProps instead");
122
+ const s = e.lang ?? "en", t = e.fallbackLang ?? s;
123
+ return /* @__PURE__ */ m(N, { ...e, lang: s, fallbackLang: t });
124
+ }
125
+ function N({
126
+ blocks: e,
122
127
  parent: s,
123
- classPrefix: n = "",
124
- externalData: e = {},
125
- blockModifierCallback: r = null,
126
- lang: o = "",
127
- fallbackLang: c = "",
128
+ externalData: t = {},
129
+ lang: n = "en",
130
+ fallbackLang: r = "en",
128
131
  metadata: a = {},
129
- dataProviderMetadataCallback: l = () => {
130
- }
132
+ forwardProps: c = {},
133
+ dataProviderMetadataCallback: o = () => {
134
+ },
135
+ draft: d = !1
131
136
  }) {
132
- const m = t, I = (i) => ut(i, n), J = s ? h(t, { _parent: s }) : h(t, (i) => g(i._parent));
133
- return D(J, "_id").map((i, M) => {
134
- const B = {}, U = h(m, { _parent: i._id });
135
- B.children = U.length > 0 ? /* @__PURE__ */ p(
136
- ht,
137
+ const f = e, A = (i) => le(i), L = s ? p(e, { _parent: s }) : p(e, (i) => g(i._parent));
138
+ return W(L, "_id").map((i, I) => {
139
+ const B = {}, J = p(f, { _parent: i._id });
140
+ B.children = J.length > 0 ? /* @__PURE__ */ m(
141
+ N,
137
142
  {
138
- externalData: e,
139
- classPrefix: n,
143
+ externalData: t,
140
144
  parent: i._id,
141
- blocks: m,
142
- lang: o || c,
143
- metadata: a,
144
- fallbackLang: c,
145
- dataProviderMetadataCallback: l
145
+ blocks: f,
146
+ lang: n,
147
+ fallbackLang: r,
148
+ forwardProps: c,
149
+ dataProviderMetadataCallback: o,
150
+ draft: d,
151
+ metadata: a
146
152
  },
147
153
  `${i._id}-children`
148
154
  ) : null;
149
- const u = N(i._type);
155
+ const u = R(i._type);
150
156
  if (u !== null) {
151
- let f = i;
152
- const P = u.component;
153
- f = { ...u.defaults, ...i }, r && (f = r(f));
154
- const V = o === c ? "" : o, K = ft(m, i._id, mt(i._type)), $ = A(pt(i, V, u), e), T = y(
157
+ let P = i;
158
+ const C = u.component;
159
+ P = { ...u.defaults, ...i };
160
+ const M = n === r ? "" : n, V = me(f, i._id, ue(i._type)), $ = F(de(i, M, u), t), b = _(
155
161
  {
156
- blockProps: {},
157
- inBuilder: !1,
158
- ...f,
159
- index: M,
162
+ ...c,
163
+ ...P,
160
164
  ...$,
161
- ...I($),
165
+ ...A($),
162
166
  ...B,
163
- ...K,
164
- metadata: a,
165
- lang: o || c,
166
- key: i._id
167
+ ...V,
168
+ index: I,
169
+ lang: n,
170
+ key: i._id,
171
+ draft: d,
172
+ blockProps: {},
173
+ inBuilder: !1
167
174
  },
168
175
  ["_parent"]
169
176
  );
170
- if (v(u, "dataProvider")) {
171
- const W = d(u, "suspenseFallback", gt);
172
- return /* @__PURE__ */ p(w, { fallback: nt(W), children: /* @__PURE__ */ p(
173
- ct,
177
+ if (S(u, "dataProvider")) {
178
+ const K = l(u, "suspenseFallback", fe);
179
+ return /* @__PURE__ */ m(w, { fallback: ee(K), children: /* @__PURE__ */ m(
180
+ ae,
174
181
  {
175
- dataProviderMetadataCallback: l,
176
- lang: o || c,
182
+ inBuilder: !1,
183
+ dataProviderMetadataCallback: o,
184
+ lang: n,
177
185
  metadata: a,
178
186
  dataProvider: u.dataProvider,
179
187
  block: i,
180
- component: P,
181
- props: T
188
+ component: C,
189
+ props: b,
190
+ forwardProps: c,
191
+ draft: d
182
192
  },
183
193
  `${i._id}-async`
184
194
  ) }, `${i._id}-suspense`);
185
195
  }
186
- return /* @__PURE__ */ p(w, { children: b.createElement(P, T) }, `${i._id}-suspense`);
196
+ return /* @__PURE__ */ m(w, { children: j.createElement(C, b) }, `${i._id}-suspense`);
187
197
  }
188
- return /* @__PURE__ */ et("noscript", { children: [
198
+ return /* @__PURE__ */ Z("noscript", { children: [
189
199
  i._type,
190
200
  " not found"
191
201
  ] }, `${i._id}-noscript`);
192
202
  });
193
203
  }
194
204
  export {
195
- ht as RenderChaiBlocks,
196
- Rt as convertToBlocks,
197
- At as getChaiThemeCssVariables,
198
- Ft as getStylesForBlocks,
199
- It as getThemeFontsCSSImport,
200
- Jt as getThemeFontsLinkMarkup
205
+ Ee as RenderChaiBlocks,
206
+ Oe as convertToBlocks,
207
+ ke as getChaiThemeCssVariables,
208
+ Te as getStylesForBlocks,
209
+ Fe as getThemeFontsCSSImport,
210
+ Ne as getThemeFontsLinkMarkup
201
211
  };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "Suraj Air",
6
6
  "license": "BSD-3-Clause",
7
7
  "homepage": "https://chaibuilder.com",
8
- "version": "2.1.9",
8
+ "version": "2.2.0",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",
@@ -53,7 +53,7 @@
53
53
  }
54
54
  },
55
55
  "peerDependencies": {
56
- "@chaibuilder/runtime": "2.0.7",
56
+ "@chaibuilder/runtime": "2.0.8",
57
57
  "@types/react": "*",
58
58
  "@types/react-dom": "*",
59
59
  "jotai": "2.12.1",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@ai-sdk/react": "^1.2.2",
73
- "@chaibuilder/runtime": "2.0.7",
73
+ "@chaibuilder/runtime": "2.0.8",
74
74
  "@floating-ui/dom": "1.6.13",
75
75
  "@floating-ui/react-dom": "2.1.2",
76
76
  "@mhsdesign/jit-browser-tailwindcss": "0.4.2",