@chaibuilder/sdk 2.0.0-beta.75 → 2.0.0-beta.77
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.cjs +4 -4
- package/dist/core.d.ts +7 -0
- package/dist/core.js +1320 -1336
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +6 -0
- package/dist/render.js +89 -77
- package/dist/runtime.d.ts +6 -0
- package/dist/tailwind.d.ts +6 -0
- package/dist/ui.d.ts +6 -0
- package/dist/web-blocks.d.ts +6 -0
- package/dist/web-blocks.js +1 -3
- package/package.json +2 -1
package/dist/render.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./ChaiThemeFn-DQu-2Eh9.cjs"),n=require("lodash-es"),f=require("./getSplitClasses-DodqA_KW.cjs"),F=require("@mhsdesign/jit-browser-tailwindcss"),O=require("@tailwindcss/aspect-ratio"),R=require("@tailwindcss/container-queries"),b=require("@tailwindcss/forms"),k=require("@tailwindcss/typography"),_=require("./plugin-2xcljWGM.cjs"),d=require("react/jsx-runtime"),w=require("@chaibuilder/runtime"),p=require("react"),$=require("tailwind-merge"),N=(e,r="")=>{const{classes:s}=f.getSplitChaiClasses(e),t=s.split(" ").map(i=>i.split(" ").map(c=>{if(c==="")return"";if(c.includes(":")){const l=c.split(":");return l[l.length-1]=r+n.last(l),l.join(":")}return`${r}${c}`}).join(" "));return n.flattenDeep(t).join(" ")},Y=e=>{if(!e)return[];try{return JSON.parse(A(e)).filter(s=>!s._type.startsWith("@chai"))}catch{return[{_type:"Paragraph",_id:"error",content:"Invalid JSON. Please check the JSON string."}]}};function A(e){const r=/(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;return e.replace(r,s=>{const t=decodeURIComponent(s),i=t.indexOf("public");return i!==-1?t.substring(i+6):t})}async function I(e,r,s=[],t="",i){return await F.createTailwindcss({tailwindConfig:{darkMode:"class",safelist:s,theme:{extend:_.getChaiBuilderTheme(e)},plugins:[b,k,O,R,_.chaiBuilderPlugin],corePlugins:{preflight:i},...t?{prefix:`${t}`}:{}}}).generateStylesFromContent(` ${i?"@tailwind base;":""}
|
|
2
2
|
@tailwind components;
|
|
3
|
-
@tailwind utilities;`,
|
|
3
|
+
@tailwind utilities;`,r)}const M=(e,r,s)=>{const t=JSON.stringify(e).replace(/#styles:([^"]*)/g,(i,o)=>`#styles:${o.replace(/,/g," ")}`.replace(/#styles:/g,""));return I(r,[t],[],"",s)},J=async(e,r=m.defaultThemeOptions,s=!1)=>await M(e,r,s);async function K(e){const r=await(e==null?void 0:e.dataProvider(e.block,e.lang,e.metadata));return d.jsx(p.Suspense,{children:p.createElement(e.component,{...e.props,...r})})}const L=n.memoize((e,r)=>{const{baseClasses:s,classes:t}=f.getSplitChaiClasses(e),i=$.twMerge(s,t);return r===""?i.replace(f.STYLES_KEY,"").trim():N(i,r).replace(f.STYLES_KEY,"").trim()}),V=(e,r)=>{const s=n.cloneDeep(e);return n.forEach(n.keys(s),t=>{if(n.isString(s[t])){let i=s[t];const o=/\{\{(.*?)\}\}/g,u=i.match(o);u&&u.forEach(c=>{const l=c.slice(2,-2),S=n.get(r,l,c);i=i.replace(c,S)}),s[t]=i}}),s};function D(e,r){const s=n.get(e,`${r}_attrs`,{}),t=n.keys(s).join(" ");return n.includes(t,"x-show")&&!n.includes(t,"x-transition")&&(s["x-transition"]=""),s}function U(e,r){const s={};return Object.keys(e).forEach(t=>{if(n.isString(e[t])&&e[t].startsWith(f.STYLES_KEY)){const i=L(e[t],r);s[t]={className:i,...D(e,t)}}}),s}function z(e,r,s){if(n.isEmpty(r))return e;const t=n.cloneDeep(e),i=n.get(s,"i18nProps",[]);return n.forEach(n.keys(t),o=>{i.includes(o)&&!n.isEmpty(r)&&(t[o]=n.get(t,`${o}-${r}`,t[o]))}),t}const W=n.memoize(e=>{const r=w.getRegisteredChaiBlock(e),s=n.get(r,"schema.properties",{});return Object.fromEntries(Object.entries(s).filter(([,t])=>n.get(t,"runtime",!1)))}),Q=(e,r,s)=>n.isEmpty(s)?{}:Object.entries(s).reduce((t,[i,o])=>{const u=[];let c=n.find(e,{_id:r});for(;c;)u.push(c),c=n.find(e,{_id:c._parent});const l=n.find(u,{_type:o.block});return l&&(t[i]=n.get(l,n.get(o,"prop"),null)),t},{}),G=()=>d.jsx("span",{children:"Loading..."});function E({blocks:e,parent:r,classPrefix:s="",externalData:t={},blockModifierCallback:i=null,lang:o="",fallbackLang:u="",metadata:c={}}){const l=e,S=a=>U(a,s),j=r?n.filter(e,{_parent:r}):n.filter(e,a=>n.isEmpty(a._parent));return d.jsx(d.Fragment,{children:p.Children.toArray(j.map((a,B)=>{const y={},P=n.filter(l,{_parent:a._id});y.children=P.length>0?d.jsx(E,{externalData:t,classPrefix:s,parent:a._id,blocks:l,lang:o||u,metadata:c}):null;const g=w.getRegisteredChaiBlock(a._type);if(g!==null){let h=a;const C=g.component;h={...g.defaults,...a},i&&(h=i(h));const x=o===u?"":o,q=Q(l,a._id,W(a._type)),T=n.omit({blockProps:{},inBuilder:!1,...h,index:B,...V(z(a,x,g),t),...S(h),...y,...q,metadata:c,lang:o||u},["_parent"]);if(n.has(g,"dataProvider")){const v=n.get(g,"suspenseFallback",G);return d.jsx(p.Suspense,{fallback:p.createElement(v),children:d.jsx(K,{lang:o||u,metadata:c,dataProvider:g.dataProvider,block:a,component:C,props:T})})}return d.jsx(p.Suspense,{children:p.createElement(C,T)})}return d.jsxs("noscript",{children:[a._type," not found"]})}))})}exports.getChaiThemeCssVariables=m.getChaiThemeCssVariables;exports.getThemeFontsCSSImport=m.getThemeFontsCSSImport;exports.getThemeFontsLinkMarkup=m.getThemeFontsLinkMarkup;exports.RenderChaiBlocks=E;exports.convertToBlocks=Y;exports.getStylesForBlocks=J;
|
package/dist/render.d.ts
CHANGED
package/dist/render.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { a as
|
|
3
|
-
import { last as
|
|
4
|
-
import { g as
|
|
5
|
-
import { createTailwindcss as
|
|
1
|
+
import { d as U } from "./ChaiThemeFn-Cort9tch.js";
|
|
2
|
+
import { a as Rt, b as $t, c as Ft } from "./ChaiThemeFn-Cort9tch.js";
|
|
3
|
+
import { last as V, flattenDeep as k, memoize as j, get as u, filter as h, isEmpty as f, omit as D, has as K, cloneDeep as x, forEach as O, keys as w, isString as v, find as S, includes as E } from "lodash-es";
|
|
4
|
+
import { g as b, S as y } from "./getSplitClasses-DphwgQiE.js";
|
|
5
|
+
import { createTailwindcss as M } from "@mhsdesign/jit-browser-tailwindcss";
|
|
6
6
|
import W from "@tailwindcss/aspect-ratio";
|
|
7
7
|
import Y from "@tailwindcss/container-queries";
|
|
8
8
|
import z from "@tailwindcss/forms";
|
|
9
9
|
import L from "@tailwindcss/typography";
|
|
10
10
|
import { g as Q, c as q } from "./plugin-kUMxtQR5.js";
|
|
11
11
|
import { jsx as d, Fragment as G, jsxs as H } from "react/jsx-runtime";
|
|
12
|
-
import { getRegisteredChaiBlock as
|
|
13
|
-
import
|
|
12
|
+
import { getRegisteredChaiBlock as R } from "@chaibuilder/runtime";
|
|
13
|
+
import _, { Suspense as C, createElement as X } from "react";
|
|
14
14
|
import { twMerge as Z } from "tailwind-merge";
|
|
15
15
|
const tt = (t, s = "") => {
|
|
16
|
-
const { classes: n } =
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
return
|
|
16
|
+
const { classes: n } = b(t), e = n.split(" ").map((r) => r.split(" ").map((o) => {
|
|
17
|
+
if (o === "") return "";
|
|
18
|
+
if (o.includes(":")) {
|
|
19
|
+
const a = o.split(":");
|
|
20
|
+
return a[a.length - 1] = s + V(a), a.join(":");
|
|
21
21
|
}
|
|
22
|
-
return `${s}${
|
|
22
|
+
return `${s}${o}`;
|
|
23
23
|
}).join(" "));
|
|
24
|
-
return
|
|
24
|
+
return k(e).join(" ");
|
|
25
25
|
}, xt = (t) => {
|
|
26
26
|
if (!t) return [];
|
|
27
27
|
try {
|
|
@@ -37,8 +37,8 @@ function et(t) {
|
|
|
37
37
|
return r !== -1 ? e.substring(r + 6) : e;
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
41
|
-
return await
|
|
40
|
+
async function nt(t, s, n = [], e = "", r) {
|
|
41
|
+
return await M({
|
|
42
42
|
tailwindConfig: {
|
|
43
43
|
darkMode: "class",
|
|
44
44
|
safelist: n,
|
|
@@ -54,53 +54,65 @@ async function st(t, s, n = [], e = "", r) {
|
|
|
54
54
|
s
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const st = (t, s, n) => {
|
|
58
58
|
const e = JSON.stringify(t).replace(/#styles:([^"]*)/g, (r, i) => `#styles:${i.replace(/,/g, " ")}`.replace(/#styles:/g, ""));
|
|
59
|
-
return
|
|
60
|
-
},
|
|
59
|
+
return nt(s, [e], [], "", n);
|
|
60
|
+
}, Ot = async (t, s = U, n = !1) => await st(t, s, n);
|
|
61
61
|
async function rt(t) {
|
|
62
62
|
const s = await (t == null ? void 0 : t.dataProvider(t.block, t.lang, t.metadata));
|
|
63
|
-
return /* @__PURE__ */ d(
|
|
63
|
+
return /* @__PURE__ */ d(C, { children: _.createElement(t.component, { ...t.props, ...s }) });
|
|
64
64
|
}
|
|
65
|
-
const it =
|
|
66
|
-
const { baseClasses: n, classes: e } =
|
|
65
|
+
const it = j((t, s) => {
|
|
66
|
+
const { baseClasses: n, classes: e } = b(t), r = Z(n, e);
|
|
67
67
|
return s === "" ? r.replace(y, "").trim() : tt(r, s).replace(y, "").trim();
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
}), ot = (t, s) => {
|
|
69
|
+
const n = x(t);
|
|
70
|
+
return O(w(n), (e) => {
|
|
71
|
+
if (v(n[e])) {
|
|
72
|
+
let r = n[e];
|
|
73
|
+
const i = /\{\{(.*?)\}\}/g, l = r.match(i);
|
|
74
|
+
l && l.forEach((o) => {
|
|
75
|
+
const a = o.slice(2, -2), g = u(s, a, o);
|
|
76
|
+
r = r.replace(o, g);
|
|
77
|
+
}), n[e] = r;
|
|
78
|
+
}
|
|
79
|
+
}), n;
|
|
80
|
+
};
|
|
81
|
+
function ct(t, s) {
|
|
82
|
+
const n = u(t, `${s}_attrs`, {}), e = w(n).join(" ");
|
|
83
|
+
return E(e, "x-show") && !E(e, "x-transition") && (n["x-transition"] = ""), n;
|
|
72
84
|
}
|
|
73
85
|
function at(t, s) {
|
|
74
86
|
const n = {};
|
|
75
87
|
return Object.keys(t).forEach((e) => {
|
|
76
|
-
if (
|
|
88
|
+
if (v(t[e]) && t[e].startsWith(y)) {
|
|
77
89
|
const r = it(t[e], s);
|
|
78
90
|
n[e] = {
|
|
79
91
|
className: r,
|
|
80
|
-
...
|
|
92
|
+
...ct(t, e)
|
|
81
93
|
};
|
|
82
94
|
}
|
|
83
95
|
}), n;
|
|
84
96
|
}
|
|
85
|
-
function
|
|
97
|
+
function lt(t, s, n) {
|
|
86
98
|
if (f(s)) return t;
|
|
87
|
-
const e =
|
|
88
|
-
return
|
|
99
|
+
const e = x(t), r = u(n, "i18nProps", []);
|
|
100
|
+
return O(w(e), (i) => {
|
|
89
101
|
r.includes(i) && !f(s) && (e[i] = u(e, `${i}-${s}`, e[i]));
|
|
90
102
|
}), e;
|
|
91
103
|
}
|
|
92
|
-
const
|
|
93
|
-
const s =
|
|
104
|
+
const ut = j((t) => {
|
|
105
|
+
const s = R(t), n = u(s, "schema.properties", {});
|
|
94
106
|
return Object.fromEntries(Object.entries(n).filter(([, e]) => u(e, "runtime", !1)));
|
|
95
|
-
}),
|
|
107
|
+
}), pt = (t, s, n) => f(n) ? {} : Object.entries(n).reduce((e, [r, i]) => {
|
|
96
108
|
const l = [];
|
|
97
|
-
let
|
|
98
|
-
for (;
|
|
99
|
-
l.push(
|
|
100
|
-
const
|
|
101
|
-
return
|
|
102
|
-
}, {}),
|
|
103
|
-
function
|
|
109
|
+
let o = S(t, { _id: s });
|
|
110
|
+
for (; o; )
|
|
111
|
+
l.push(o), o = S(t, { _id: o._parent });
|
|
112
|
+
const a = S(l, { _type: i.block });
|
|
113
|
+
return a && (e[r] = u(a, u(i, "prop"), null)), e;
|
|
114
|
+
}, {}), dt = () => /* @__PURE__ */ d("span", { children: "Loading..." });
|
|
115
|
+
function mt({
|
|
104
116
|
blocks: t,
|
|
105
117
|
parent: s,
|
|
106
118
|
classPrefix: n = "",
|
|
@@ -108,75 +120,75 @@ function dt({
|
|
|
108
120
|
blockModifierCallback: r = null,
|
|
109
121
|
lang: i = "",
|
|
110
122
|
fallbackLang: l = "",
|
|
111
|
-
metadata:
|
|
123
|
+
metadata: o = {}
|
|
112
124
|
}) {
|
|
113
|
-
const
|
|
114
|
-
return /* @__PURE__ */ d(G, { children:
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
125
|
+
const a = t, g = (c) => at(c, n), $ = s ? h(t, { _parent: s }) : h(t, (c) => f(c._parent));
|
|
126
|
+
return /* @__PURE__ */ d(G, { children: _.Children.toArray(
|
|
127
|
+
$.map((c, F) => {
|
|
128
|
+
const P = {}, N = h(a, { _parent: c._id });
|
|
129
|
+
P.children = N.length > 0 ? /* @__PURE__ */ d(
|
|
130
|
+
mt,
|
|
119
131
|
{
|
|
120
132
|
externalData: e,
|
|
121
133
|
classPrefix: n,
|
|
122
|
-
parent:
|
|
123
|
-
blocks:
|
|
134
|
+
parent: c._id,
|
|
135
|
+
blocks: a,
|
|
124
136
|
lang: i || l,
|
|
125
|
-
metadata:
|
|
137
|
+
metadata: o
|
|
126
138
|
}
|
|
127
139
|
) : null;
|
|
128
|
-
const p =
|
|
140
|
+
const p = R(c._type);
|
|
129
141
|
if (p !== null) {
|
|
130
|
-
let m =
|
|
131
|
-
const
|
|
132
|
-
m = { ...p.defaults, ...
|
|
133
|
-
const
|
|
142
|
+
let m = c;
|
|
143
|
+
const B = p.component;
|
|
144
|
+
m = { ...p.defaults, ...c }, r && (m = r(m));
|
|
145
|
+
const A = i === l ? "" : i, I = pt(a, c._id, ut(c._type)), T = D(
|
|
134
146
|
{
|
|
135
147
|
blockProps: {},
|
|
136
148
|
inBuilder: !1,
|
|
137
149
|
...m,
|
|
138
|
-
index:
|
|
139
|
-
...
|
|
140
|
-
...
|
|
141
|
-
...
|
|
142
|
-
...
|
|
143
|
-
metadata:
|
|
150
|
+
index: F,
|
|
151
|
+
...ot(lt(c, A, p), e),
|
|
152
|
+
...g(m),
|
|
153
|
+
...P,
|
|
154
|
+
...I,
|
|
155
|
+
metadata: o,
|
|
144
156
|
lang: i || l
|
|
145
157
|
},
|
|
146
158
|
["_parent"]
|
|
147
159
|
);
|
|
148
|
-
if (
|
|
149
|
-
const
|
|
160
|
+
if (K(p, "dataProvider")) {
|
|
161
|
+
const J = u(
|
|
150
162
|
p,
|
|
151
163
|
"suspenseFallback",
|
|
152
|
-
|
|
164
|
+
dt
|
|
153
165
|
);
|
|
154
|
-
return /* @__PURE__ */ d(
|
|
166
|
+
return /* @__PURE__ */ d(C, { fallback: X(J), children: /* @__PURE__ */ d(
|
|
155
167
|
rt,
|
|
156
168
|
{
|
|
157
169
|
lang: i || l,
|
|
158
|
-
metadata:
|
|
170
|
+
metadata: o,
|
|
159
171
|
dataProvider: p.dataProvider,
|
|
160
|
-
block:
|
|
161
|
-
component:
|
|
162
|
-
props:
|
|
172
|
+
block: c,
|
|
173
|
+
component: B,
|
|
174
|
+
props: T
|
|
163
175
|
}
|
|
164
176
|
) });
|
|
165
177
|
}
|
|
166
|
-
return /* @__PURE__ */ d(
|
|
178
|
+
return /* @__PURE__ */ d(C, { children: _.createElement(B, T) });
|
|
167
179
|
}
|
|
168
180
|
return /* @__PURE__ */ H("noscript", { children: [
|
|
169
|
-
|
|
181
|
+
c._type,
|
|
170
182
|
" not found"
|
|
171
183
|
] });
|
|
172
184
|
})
|
|
173
185
|
) });
|
|
174
186
|
}
|
|
175
187
|
export {
|
|
176
|
-
|
|
188
|
+
mt as RenderChaiBlocks,
|
|
177
189
|
xt as convertToBlocks,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
190
|
+
Rt as getChaiThemeCssVariables,
|
|
191
|
+
Ot as getStylesForBlocks,
|
|
192
|
+
$t as getThemeFontsCSSImport,
|
|
193
|
+
Ft as getThemeFontsLinkMarkup
|
|
182
194
|
};
|
package/dist/runtime.d.ts
CHANGED
package/dist/tailwind.d.ts
CHANGED
package/dist/ui.d.ts
CHANGED
package/dist/web-blocks.d.ts
CHANGED
package/dist/web-blocks.js
CHANGED
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.0.0-beta.
|
|
8
|
+
"version": "2.0.0-beta.77",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -134,6 +134,7 @@
|
|
|
134
134
|
"@commitlint/config-conventional": "19.6.0",
|
|
135
135
|
"@emotion/react": "^11.14.0",
|
|
136
136
|
"@faker-js/faker": "^9.4.0",
|
|
137
|
+
"@microsoft/clarity": "^1.0.0",
|
|
137
138
|
"@playwright/test": "^1.50.0",
|
|
138
139
|
"@tanstack/eslint-plugin-query": "^5.64.2",
|
|
139
140
|
"@testing-library/react": "^16.2.0",
|