@chaibuilder/sdk 2.1.9 → 2.2.1

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