@chaibuilder/sdk 1.2.102 → 1.2.103

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 CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("lodash-es"),a=require("./STRINGS-Yl7cSWDc.cjs"),d=require("./jsx-runtime-JYMCiFoE.cjs"),E=require("react"),x=require("tailwind-merge"),B=require("@chaibuilder/runtime"),C=require("@mhsdesign/jit-browser-tailwindcss"),Y=require("@tailwindcss/forms"),q=require("@tailwindcss/typography"),O=require("@tailwindcss/aspect-ratio"),j=require("./plugin-3Y9Uv3RT.cjs");require("tailwindcss-palette-generator");require("./plugin-KIpT3NWi.cjs");const _=(t,r="")=>{const s=t.replace(a.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const u=l.split(":");return u[u.length-1]=r+n.last(u),u.join(":")}return`${r}${l}`}).join(" "));return n.flattenDeep(s).join(" ")},R=t=>{if(!t)return[];try{return JSON.parse(K(t)).filter(e=>!e._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function K(t){const r=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return t.replace(r,e=>{const s=decodeURIComponent(e),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}const L=t=>{const r={};return Object.keys(t).forEach(e=>{n.isString(t[e])&&t[e].startsWith(a.SLOT_KEY)&&(r[e]=t[e].replace(a.SLOT_KEY,"").split(","))}),r},A=n.memoize((t,r)=>{const e=t.replace(a.STYLES_KEY,"").split(","),s=x.twMerge(e[0],e[1]);return r===""?s.replace(a.STYLES_KEY,"").trim():_(s,r).replace(a.STYLES_KEY,"").trim()});function N(t,r){const e=n.get(t,`${r}_attrs`,{});n.has(e,"data-ai-key")&&delete e["data-ai-key"];const s=n.keys(e).join(" ");return n.includes(s,"x-show")&&!n.includes(s,"x-transition")&&(e["x-transition"]=""),e}function $(t,r){const e={};return Object.keys(t).forEach(s=>{if(n.isString(t[s])&&t[s].startsWith(a.STYLES_KEY)){const i=A(t[s],r);e[s]={className:i,...N(t,s)}}}),e}function P(t,r){const e=n.get(t,"_bindings",{});return n.isEmpty(e)?{...t}:(n.each(e,(s,i)=>{n.isString(s)&&n.get(r,s,null)&&(t[i]=n.get(r,s,null))}),t)}function v(t,r,e){if(n.isEmpty(r))return t;const s=n.cloneDeep(t);return n.forEach(n.keys(s),i=>{n.get(e,["props",i,"i18n"])&&!n.isEmpty(r)&&(s[i]=n.get(s,`${i}-${r}`,s[i]))}),s}function y({blocks:t,parent:r,classPrefix:e="",externalData:s={},blockModifierCallback:i,lang:p}){const f=t,l=o=>$(o,e),u=r?n.filter(t,{_parent:r}):n.filter(t,o=>n.isEmpty(o._parent));return d.jsxRuntimeExports.jsx(d.jsxRuntimeExports.Fragment,{children:E.Children.toArray(u.map((o,T)=>{const S=L(o),h={};n.isEmpty(S)||Object.keys(S).forEach(c=>{h[c]=E.Children.toArray(S[c].map(m=>d.jsxRuntimeExports.jsx(y,{externalData:s,classPrefix:e,blocks:f,parent:m,lang:p})))});const w=n.filter(f,{_parent:o._id});h.children=w.length>0?d.jsxRuntimeExports.jsx(y,{externalData:s,classPrefix:e,parent:o._id,blocks:f,lang:p}):null;const g=B.getBlockComponent(o._type);if(g!==null){let c=o;const m=g.component;return c={...g.defaults,...o},i&&(c=i(c)),E.createElement(m,n.omit({blockProps:{},inBuilder:!1,...c,index:T,...P(v(o,p,g),s),...l(c),...h},["_parent"]))}return d.jsxRuntimeExports.jsxs("noscript",{children:[o._type," not found"]})}))})}async function I(t,r,e=[],s="",i=!1){return await C.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:e,theme:j.getChaiBuilderTheme(t),plugins:[Y,q,O,j.chaiBuilderPlugin],corePlugins:{preflight:i},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("lodash-es"),a=require("./STRINGS-Yl7cSWDc.cjs"),d=require("./jsx-runtime-JYMCiFoE.cjs"),E=require("react"),x=require("tailwind-merge"),B=require("@chaibuilder/runtime"),C=require("@mhsdesign/jit-browser-tailwindcss"),Y=require("@tailwindcss/forms"),q=require("@tailwindcss/typography"),O=require("@tailwindcss/aspect-ratio"),j=require("./plugin-3Y9Uv3RT.cjs");require("tailwindcss-palette-generator");require("./plugin-KIpT3NWi.cjs");const _=(t,r="")=>{const s=t.replace(a.STYLES_KEY,"").split(",").map(i=>i.split(" ").map(l=>{if(l==="")return"";if(l.includes(":")){const u=l.split(":");return u[u.length-1]=r+n.last(u),u.join(":")}return`${r}${l}`}).join(" "));return n.flattenDeep(s).join(" ")},R=t=>{if(!t)return[];try{return JSON.parse(K(t)).filter(e=>!e._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function K(t){const r=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return t.replace(r,e=>{const s=decodeURIComponent(e),i=s.indexOf("public");return i!==-1?s.substring(i+6):s})}const L=t=>{const r={};return Object.keys(t).forEach(e=>{n.isString(t[e])&&t[e].startsWith(a.SLOT_KEY)&&(r[e]=t[e].replace(a.SLOT_KEY,"").split(","))}),r},A=n.memoize((t,r)=>{const e=t.replace(a.STYLES_KEY,"").split(","),s=x.twMerge(e[0],e[1]);return r===""?s.replace(a.STYLES_KEY,"").trim():_(s,r).replace(a.STYLES_KEY,"").trim()});function N(t,r){const e=n.get(t,`${r}_attrs`,{});n.has(e,"data-ai-key")&&delete e["data-ai-key"];const s=n.keys(e).join(" ");return n.includes(s,"x-show")&&!n.includes(s,"x-transition")&&(e["x-transition"]=""),e}function $(t,r){const e={};return Object.keys(t).forEach(s=>{if(n.isString(t[s])&&t[s].startsWith(a.STYLES_KEY)){const i=A(t[s],r);e[s]={className:i,...N(t,s)}}}),e}function P(t,r){const e=n.get(t,"_bindings",{});return n.isEmpty(e)?{...t}:(n.each(e,(s,i)=>{n.isString(s)&&n.get(r,s,null)&&(t[i]=n.get(r,s,null))}),t)}function v(t,r,e){if(n.isEmpty(r))return t;const s=n.cloneDeep(t);return n.forEach(n.keys(s),i=>{n.get(e,["props",i,"i18n"])&&!n.isEmpty(r)&&(s[i]=n.get(s,`${i}-${r}`,s[i]))}),s}function y({blocks:t,parent:r,classPrefix:e="",externalData:s={},blockModifierCallback:i,lang:p}){const f=t,l=o=>$(o,e),u=r?n.filter(t,{_parent:r}):n.filter(t,o=>n.isEmpty(o._parent));return d.jsxRuntimeExports.jsx(d.jsxRuntimeExports.Fragment,{children:E.Children.toArray(u.map((o,T)=>{const S=L(o),h={};n.isEmpty(S)||Object.keys(S).forEach(c=>{h[c]=E.Children.toArray(S[c].map(m=>d.jsxRuntimeExports.jsx(y,{externalData:s,classPrefix:e,blocks:f,parent:m,lang:p})))});const w=n.filter(f,{_parent:o._id});h.children=w.length>0?d.jsxRuntimeExports.jsx(y,{externalData:s,classPrefix:e,parent:o._id,blocks:f,lang:p}):null;const g=B.getBlockComponent(o._type);if(g!==null){let c=o;const m=g.component;return c={...g.defaults,...o},i&&(c=i(c)),E.createElement(m,n.omit({blockProps:{},inBuilder:!1,...c,index:T,...P(v(o,p,g),s),...l(c),...h},["_parent"]))}return d.jsxRuntimeExports.jsxs("noscript",{children:[o._type," not found"]})}))})}async function I(t,r,e=[],s="",i=!1){return await C.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:e,theme:{extend:j.getChaiBuilderTheme(t)},plugins:[Y,q,O,j.chaiBuilderPlugin],corePlugins:{preflight:i},...s?{prefix:`${s}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
2
2
  @tailwind components;
3
- @tailwind utilities;`,r)}const J=(t,r)=>t.map(e=>{const s={};return Object.keys(e).forEach(i=>{n.startsWith(e[i],a.STYLES_KEY)&&(s[i]=_(e[i],r))}),s}),W=(t,r,e="",s=!1)=>I(r,[n.replace(JSON.stringify(J(t,e)),/#styles:/g,"")],[],e,s),F=async(t,r={},e="",s=!0)=>await W(t,r,e,s);exports.RenderChaiBlocks=y;exports.convertToBlocks=R;exports.getStylesForBlocks=F;
3
+ @tailwind utilities;`,r)}const J=(t,r)=>t.map(e=>{const s={};return Object.keys(e).forEach(i=>{n.startsWith(e[i],a.STYLES_KEY)&&(s[i]=_(e[i],r))}),s}),W=(t,r,e="",s=!1)=>I(r,[n.replace(JSON.stringify(J(t,e)),/#styles:,?/g,"")],[],e,s),F=async(t,r={},e="",s=!0)=>await W(t,r,e,s);exports.RenderChaiBlocks=y;exports.convertToBlocks=R;exports.getStylesForBlocks=F;
package/dist/render.d.ts CHANGED
@@ -26,7 +26,7 @@ declare type ChaiBuilderTailwindTheme<T extends Record<string, unknown> = {}> =
26
26
  */
27
27
  export declare const convertToBlocks: (chaiFormatContent: string) => ChaiBlock[];
28
28
 
29
- export declare const getStylesForBlocks: (blocks: ChaiBlock[], theme?: ChaiBuilderTailwindTheme | {}, classPrefix?: string, includeBaseStyles?: boolean) => Promise<string>;
29
+ export declare const getStylesForBlocks: (blocks: ChaiBlock[], theme?: ChaiBuilderTailwindTheme | Record<string, string>, classPrefix?: string, includeBaseStyles?: boolean) => Promise<string>;
30
30
 
31
31
  export declare function RenderChaiBlocks({ blocks, parent, classPrefix, externalData, blockModifierCallback, lang, }: {
32
32
  blocks: ChaiBlock[];
package/dist/render.js CHANGED
@@ -1,4 +1,4 @@
1
- import { last as $, flattenDeep as N, memoize as P, filter as _, isEmpty as m, omit as R, isString as j, get as l, each as J, cloneDeep as W, forEach as I, keys as O, has as K, includes as C, replace as L, startsWith as Y } from "lodash-es";
1
+ import { last as $, flattenDeep as N, memoize as P, filter as _, isEmpty as d, omit as R, isString as j, get as l, each as J, cloneDeep as W, forEach as I, keys as x, has as K, includes as C, replace as L, startsWith as Y } from "lodash-es";
2
2
  import { S as p, a as B } from "./STRINGS-Xxstm-7I.js";
3
3
  import { j as f } from "./jsx-runtime-Sp0orL4X.js";
4
4
  import w from "react";
@@ -11,17 +11,17 @@ import q from "@tailwindcss/aspect-ratio";
11
11
  import { g as D, c as G } from "./plugin-LKCHtO27.js";
12
12
  import "tailwindcss-palette-generator";
13
13
  import "./plugin-ooqqxWRQ.js";
14
- const x = (t, e = "") => {
15
- const r = t.replace(p, "").split(",").map((n) => n.split(" ").map((a) => {
14
+ const O = (t, r = "") => {
15
+ const e = t.replace(p, "").split(",").map((n) => n.split(" ").map((a) => {
16
16
  if (a === "")
17
17
  return "";
18
18
  if (a.includes(":")) {
19
19
  const c = a.split(":");
20
- return c[c.length - 1] = e + $(c), c.join(":");
20
+ return c[c.length - 1] = r + $(c), c.join(":");
21
21
  }
22
- return `${e}${a}`;
22
+ return `${r}${a}`;
23
23
  }).join(" "));
24
- return N(r).join(" ");
24
+ return N(e).join(" ");
25
25
  }, ht = (t) => {
26
26
  if (!t)
27
27
  return [];
@@ -32,87 +32,87 @@ const x = (t, e = "") => {
32
32
  }
33
33
  };
34
34
  function H(t) {
35
- const e = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
36
- return t.replace(e, (s) => {
37
- const r = decodeURIComponent(s), n = r.indexOf("public");
38
- return n !== -1 ? r.substring(n + 6) : r;
35
+ const r = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
36
+ return t.replace(r, (s) => {
37
+ const e = decodeURIComponent(s), n = e.indexOf("public");
38
+ return n !== -1 ? e.substring(n + 6) : e;
39
39
  });
40
40
  }
41
41
  const Q = (t) => {
42
- const e = {};
42
+ const r = {};
43
43
  return Object.keys(t).forEach((s) => {
44
- j(t[s]) && t[s].startsWith(B) && (e[s] = t[s].replace(B, "").split(","));
45
- }), e;
46
- }, V = P((t, e) => {
47
- const s = t.replace(p, "").split(","), r = v(s[0], s[1]);
48
- return e === "" ? r.replace(p, "").trim() : x(r, e).replace(p, "").trim();
44
+ j(t[s]) && t[s].startsWith(B) && (r[s] = t[s].replace(B, "").split(","));
45
+ }), r;
46
+ }, V = P((t, r) => {
47
+ const s = t.replace(p, "").split(","), e = v(s[0], s[1]);
48
+ return r === "" ? e.replace(p, "").trim() : O(e, r).replace(p, "").trim();
49
49
  });
50
- function X(t, e) {
51
- const s = l(t, `${e}_attrs`, {});
50
+ function X(t, r) {
51
+ const s = l(t, `${r}_attrs`, {});
52
52
  K(s, "data-ai-key") && delete s["data-ai-key"];
53
- const r = O(s).join(" ");
54
- return C(r, "x-show") && !C(r, "x-transition") && (s["x-transition"] = ""), s;
53
+ const e = x(s).join(" ");
54
+ return C(e, "x-show") && !C(e, "x-transition") && (s["x-transition"] = ""), s;
55
55
  }
56
- function Z(t, e) {
56
+ function Z(t, r) {
57
57
  const s = {};
58
- return Object.keys(t).forEach((r) => {
59
- if (j(t[r]) && t[r].startsWith(p)) {
60
- const n = V(t[r], e);
61
- s[r] = {
58
+ return Object.keys(t).forEach((e) => {
59
+ if (j(t[e]) && t[e].startsWith(p)) {
60
+ const n = V(t[e], r);
61
+ s[e] = {
62
62
  className: n,
63
- ...X(t, r)
63
+ ...X(t, e)
64
64
  };
65
65
  }
66
66
  }), s;
67
67
  }
68
- function b(t, e) {
68
+ function b(t, r) {
69
69
  const s = l(t, "_bindings", {});
70
- return m(s) ? { ...t } : (J(s, (r, n) => {
71
- j(r) && l(e, r, null) && (t[n] = l(e, r, null));
70
+ return d(s) ? { ...t } : (J(s, (e, n) => {
71
+ j(e) && l(r, e, null) && (t[n] = l(r, e, null));
72
72
  }), t);
73
73
  }
74
- function k(t, e, s) {
75
- if (m(e))
74
+ function k(t, r, s) {
75
+ if (d(r))
76
76
  return t;
77
- const r = W(t);
78
- return I(O(r), (n) => {
79
- l(s, ["props", n, "i18n"]) && !m(e) && (r[n] = l(r, `${n}-${e}`, r[n]));
80
- }), r;
77
+ const e = W(t);
78
+ return I(x(e), (n) => {
79
+ l(s, ["props", n, "i18n"]) && !d(r) && (e[n] = l(e, `${n}-${r}`, e[n]));
80
+ }), e;
81
81
  }
82
82
  function E({
83
83
  blocks: t,
84
- parent: e,
84
+ parent: r,
85
85
  classPrefix: s = "",
86
- externalData: r = {},
86
+ externalData: e = {},
87
87
  blockModifierCallback: n,
88
88
  lang: u
89
89
  }) {
90
- const d = t, a = (i) => Z(i, s), c = e ? _(t, { _parent: e }) : _(t, (i) => m(i._parent));
90
+ const m = t, a = (i) => Z(i, s), c = r ? _(t, { _parent: r }) : _(t, (i) => d(i._parent));
91
91
  return /* @__PURE__ */ f.jsx(f.Fragment, { children: w.Children.toArray(
92
92
  c.map((i, T) => {
93
93
  const h = Q(i), y = {};
94
- m(h) || Object.keys(h).forEach((o) => {
94
+ d(h) || Object.keys(h).forEach((o) => {
95
95
  y[o] = w.Children.toArray(
96
96
  h[o].map((S) => /* @__PURE__ */ f.jsx(
97
97
  E,
98
98
  {
99
- externalData: r,
99
+ externalData: e,
100
100
  classPrefix: s,
101
- blocks: d,
101
+ blocks: m,
102
102
  parent: S,
103
103
  lang: u
104
104
  }
105
105
  ))
106
106
  );
107
107
  });
108
- const A = _(d, { _parent: i._id });
108
+ const A = _(m, { _parent: i._id });
109
109
  y.children = A.length > 0 ? /* @__PURE__ */ f.jsx(
110
110
  E,
111
111
  {
112
- externalData: r,
112
+ externalData: e,
113
113
  classPrefix: s,
114
114
  parent: i._id,
115
- blocks: d,
115
+ blocks: m,
116
116
  lang: u
117
117
  }
118
118
  ) : null;
@@ -128,7 +128,7 @@ function E({
128
128
  inBuilder: !1,
129
129
  ...o,
130
130
  index: T,
131
- ...b(k(i, u, g), r),
131
+ ...b(k(i, u, g), e),
132
132
  ...a(o),
133
133
  ...y
134
134
  },
@@ -143,35 +143,35 @@ function E({
143
143
  })
144
144
  ) });
145
145
  }
146
- async function tt(t, e, s = [], r = "", n = !1) {
146
+ async function tt(t, r, s = [], e = "", n = !1) {
147
147
  return await U({
148
148
  tailwindConfig: {
149
149
  darkMode: "class",
150
150
  safelist: s,
151
- theme: D(t),
151
+ theme: { extend: D(t) },
152
152
  plugins: [z, M, q, G],
153
153
  corePlugins: { preflight: n },
154
- ...r ? { prefix: `${r}` } : {}
154
+ ...e ? { prefix: `${e}` } : {}
155
155
  }
156
156
  }).generateStylesFromContent(
157
157
  ` ${n ? "@tailwind base;" : ""}
158
158
  @tailwind components;
159
159
  @tailwind utilities;`,
160
- e
160
+ r
161
161
  );
162
162
  }
163
- const st = (t, e) => t.map((s) => {
164
- const r = {};
163
+ const st = (t, r) => t.map((s) => {
164
+ const e = {};
165
165
  return Object.keys(s).forEach((n) => {
166
- Y(s[n], p) && (r[n] = x(s[n], e));
167
- }), r;
168
- }), rt = (t, e, s = "", r = !1) => tt(
169
- e,
170
- [L(JSON.stringify(st(t, s)), /#styles:/g, "")],
166
+ Y(s[n], p) && (e[n] = O(s[n], r));
167
+ }), e;
168
+ }), et = (t, r, s = "", e = !1) => tt(
169
+ r,
170
+ [L(JSON.stringify(st(t, s)), /#styles:,?/g, "")],
171
171
  [],
172
172
  s,
173
- r
174
- ), yt = async (t, e = {}, s = "", r = !0) => await rt(t, e, s, r);
173
+ e
174
+ ), yt = async (t, r = {}, s = "", e = !0) => await et(t, r, s, e);
175
175
  export {
176
176
  E as RenderChaiBlocks,
177
177
  ht as convertToBlocks,
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": "1.2.102",
8
+ "version": "1.2.103",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",