@chaibuilder/sdk 2.0.0-beta.98 → 2.0.0-beta.99
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/ChaiThemeFn-Cort9tch.js +201 -0
- package/dist/ChaiThemeFn-DQu-2Eh9.cjs +13 -0
- package/dist/CodeEditor-B2x4yruH.cjs +1 -0
- package/dist/CodeEditor-VcQsGvTM.js +65 -0
- package/dist/Topbar-BQsjWb-A.js +16 -0
- package/dist/Topbar-DEw_kBMz.cjs +1 -0
- package/dist/context-menu-C4lLV8gP.cjs +1 -0
- package/dist/context-menu-D5ViOi6K.js +831 -0
- package/dist/core.cjs +5 -11771
- package/dist/core.js +3993 -6891
- package/dist/getSplitClasses-DodqA_KW.cjs +1 -0
- package/dist/getSplitClasses-DphwgQiE.js +48 -0
- package/dist/iconBase-Cn2BsTrq.cjs +1 -0
- package/dist/iconBase-DHfFLkem.js +124 -0
- package/dist/plugin-2xcljWGM.cjs +1 -0
- package/dist/plugin-kUMxtQR5.js +24 -0
- package/dist/render.cjs +2 -247
- package/dist/render.js +150 -205
- package/dist/runtime.cjs +1 -9
- package/dist/sdk.css +1 -1336
- package/dist/tailwind.cjs +1 -78
- package/dist/tailwind.js +19 -21
- package/dist/ui.cjs +1 -378
- package/dist/ui.js +244 -254
- package/dist/web-blocks.cjs +2 -1679
- package/dist/web-blocks.js +518 -747
- package/package.json +1 -1
- package/dist/ChaiThemeFn-DcE5RdLQ.cjs +0 -236
- package/dist/ChaiThemeFn-DzirXKjI.js +0 -237
- package/dist/CodeEditor-C8_JzwHn.cjs +0 -81
- package/dist/CodeEditor-DdIk_PEV.js +0 -81
- package/dist/Topbar-62QmCKWL.cjs +0 -18
- package/dist/Topbar-Cqt0j3Yt.js +0 -18
- package/dist/context-menu-DHla8ofZ.js +0 -893
- package/dist/context-menu-DawHUIXd.cjs +0 -923
- package/dist/getSplitClasses-BuALfSLX.js +0 -54
- package/dist/getSplitClasses-mbQmvwI3.cjs +0 -53
- package/dist/iconBase-BSrIcOaG.cjs +0 -146
- package/dist/iconBase-CWgVxu0A.js +0 -147
- package/dist/plugin-BcTnEZwx.cjs +0 -26
- package/dist/plugin-DGEKY3uC.js +0 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const a="#styles:",r="__ADD_BLOCK_INTERNAL_ROOT",n=s=>{if(s=s.replace(a,""),!s)return{baseClasses:"",classes:""};const e=s.split(/,(?![^\[]*\])/);if(e.length===1)return{baseClasses:"",classes:e[0].trim()};const[t,...l]=e;return{baseClasses:t.trim(),classes:l.join(",").trim().replace(/ +(?= )/g,"")}};exports.ROOT_TEMP_KEY=r;exports.STYLES_KEY=a;exports.getSplitChaiClasses=n;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const t = "#styles:", n = "__ADD_BLOCK_INTERNAL_ROOT", r = (s) => {
|
|
2
|
+
if (s = s.replace(t, ""), !s) return { baseClasses: "", classes: "" };
|
|
3
|
+
const e = s.split(/,(?![^\[]*\])/);
|
|
4
|
+
if (e.length === 1)
|
|
5
|
+
return { baseClasses: "", classes: e[0].trim() };
|
|
6
|
+
const [a, ...l] = e;
|
|
7
|
+
return {
|
|
8
|
+
baseClasses: a.trim(),
|
|
9
|
+
classes: l.join(",").trim().replace(/ +(?= )/g, "")
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
13
|
+
it("should return the base classes and the classes", () => {
|
|
14
|
+
const s = {
|
|
15
|
+
",styles-2": { baseClasses: "", classes: "styles-2" },
|
|
16
|
+
"styles-1,styles-2": { baseClasses: "styles-1", classes: "styles-2" },
|
|
17
|
+
",bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
18
|
+
baseClasses: "",
|
|
19
|
+
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
20
|
+
},
|
|
21
|
+
"styles-1,bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
22
|
+
baseClasses: "styles-1",
|
|
23
|
+
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
24
|
+
},
|
|
25
|
+
someclass: {
|
|
26
|
+
baseClasses: "",
|
|
27
|
+
classes: "someclass"
|
|
28
|
+
},
|
|
29
|
+
",bg-red-500 text-center font-bold": {
|
|
30
|
+
baseClasses: "",
|
|
31
|
+
classes: "bg-red-500 text-center font-bold"
|
|
32
|
+
},
|
|
33
|
+
"bg-[linear-gradient(-10deg,black,transparent_100%)], bg-[linear-gradient(-10deg,black,transparent_100%)]": {
|
|
34
|
+
baseClasses: "bg-[linear-gradient(-10deg,black,transparent_100%)]",
|
|
35
|
+
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
for (let e in s) {
|
|
39
|
+
const a = r(`${t}${e}`);
|
|
40
|
+
expect(a).toEqual(s[e]);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
n as R,
|
|
46
|
+
t as S,
|
|
47
|
+
r as g
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("lodash-es");const v=require("clsx"),O=require("tailwind-merge"),a=require("react");function y(e=6,t="abcdefghijklmnopqrstuvwxyzABCD"){let r="";for(let n=e;n>0;--n)r+=t[Math.floor(Math.random()*t.length)];return r}const d=e=>e>=1536?"2XL":e>=1280?"XL":e>=1024?"LG":e>=768?"MD":e>=640?"SM":"XS",j=(...e)=>O.twMerge(v.clsx(e));var g={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},f=a.createContext&&a.createContext(g),P=["attr","size","title"];function h(e,t){if(e==null)return{};var r=w(e,t),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function w(e,t){if(e==null)return{};var r={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;r[n]=e[n]}return r}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},c.apply(this,arguments)}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?m(Object(r),!0).forEach(function(n){x(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function x(e,t,r){return t=E(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(e){var t=D(e,"string");return typeof t=="symbol"?t:t+""}function D(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function p(e){return e&&e.map((t,r)=>a.createElement(t.tag,u({key:r},t.attr),p(t.child)))}function S(e){return t=>a.createElement(C,c({attr:u({},e.attr)},t),p(e.child))}function C(e){var t=r=>{var{attr:n,size:i,title:o}=e,b=h(e,P),s=i||r.size||"1em",l;return r.className&&(l=r.className),e.className&&(l=(l?l+" ":"")+e.className),a.createElement("svg",c({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,n,b,{className:l,style:u(u({color:e.color||r.color},r.style),e.style),height:s,width:s,xmlns:"http://www.w3.org/2000/svg"}),o&&a.createElement("title",null,o),e.children)};return f!==void 0?a.createElement(f.Consumer,null,r=>t(r)):t(g)}exports.GenIcon=S;exports.cn=j;exports.generateUUID=y;exports.getBreakpointValue=d;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import "lodash-es";
|
|
2
|
+
import { clsx as v } from "clsx";
|
|
3
|
+
import { twMerge as O } from "tailwind-merge";
|
|
4
|
+
import a from "react";
|
|
5
|
+
function D(e = 6, t = "abcdefghijklmnopqrstuvwxyzABCD") {
|
|
6
|
+
let r = "";
|
|
7
|
+
for (let n = e; n > 0; --n) r += t[Math.floor(Math.random() * t.length)];
|
|
8
|
+
return r;
|
|
9
|
+
}
|
|
10
|
+
const N = (e) => e >= 1536 ? "2XL" : e >= 1280 ? "XL" : e >= 1024 ? "LG" : e >= 768 ? "MD" : e >= 640 ? "SM" : "XS", z = (...e) => O(v(e));
|
|
11
|
+
var p = {
|
|
12
|
+
color: void 0,
|
|
13
|
+
size: void 0,
|
|
14
|
+
className: void 0,
|
|
15
|
+
style: void 0,
|
|
16
|
+
attr: void 0
|
|
17
|
+
}, s = a.createContext && /* @__PURE__ */ a.createContext(p), y = ["attr", "size", "title"];
|
|
18
|
+
function d(e, t) {
|
|
19
|
+
if (e == null) return {};
|
|
20
|
+
var r = j(e, t), n, i;
|
|
21
|
+
if (Object.getOwnPropertySymbols) {
|
|
22
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
23
|
+
for (i = 0; i < o.length; i++)
|
|
24
|
+
n = o[i], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]);
|
|
25
|
+
}
|
|
26
|
+
return r;
|
|
27
|
+
}
|
|
28
|
+
function j(e, t) {
|
|
29
|
+
if (e == null) return {};
|
|
30
|
+
var r = {};
|
|
31
|
+
for (var n in e)
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(e, n)) {
|
|
33
|
+
if (t.indexOf(n) >= 0) continue;
|
|
34
|
+
r[n] = e[n];
|
|
35
|
+
}
|
|
36
|
+
return r;
|
|
37
|
+
}
|
|
38
|
+
function c() {
|
|
39
|
+
return c = Object.assign ? Object.assign.bind() : function(e) {
|
|
40
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
41
|
+
var r = arguments[t];
|
|
42
|
+
for (var n in r)
|
|
43
|
+
Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
|
|
44
|
+
}
|
|
45
|
+
return e;
|
|
46
|
+
}, c.apply(this, arguments);
|
|
47
|
+
}
|
|
48
|
+
function m(e, t) {
|
|
49
|
+
var r = Object.keys(e);
|
|
50
|
+
if (Object.getOwnPropertySymbols) {
|
|
51
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
52
|
+
t && (n = n.filter(function(i) {
|
|
53
|
+
return Object.getOwnPropertyDescriptor(e, i).enumerable;
|
|
54
|
+
})), r.push.apply(r, n);
|
|
55
|
+
}
|
|
56
|
+
return r;
|
|
57
|
+
}
|
|
58
|
+
function u(e) {
|
|
59
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
60
|
+
var r = arguments[t] != null ? arguments[t] : {};
|
|
61
|
+
t % 2 ? m(Object(r), !0).forEach(function(n) {
|
|
62
|
+
P(e, n, r[n]);
|
|
63
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : m(Object(r)).forEach(function(n) {
|
|
64
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return e;
|
|
68
|
+
}
|
|
69
|
+
function P(e, t, r) {
|
|
70
|
+
return t = h(t), t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
|
|
71
|
+
}
|
|
72
|
+
function h(e) {
|
|
73
|
+
var t = w(e, "string");
|
|
74
|
+
return typeof t == "symbol" ? t : t + "";
|
|
75
|
+
}
|
|
76
|
+
function w(e, t) {
|
|
77
|
+
if (typeof e != "object" || !e) return e;
|
|
78
|
+
var r = e[Symbol.toPrimitive];
|
|
79
|
+
if (r !== void 0) {
|
|
80
|
+
var n = r.call(e, t || "default");
|
|
81
|
+
if (typeof n != "object") return n;
|
|
82
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
83
|
+
}
|
|
84
|
+
return (t === "string" ? String : Number)(e);
|
|
85
|
+
}
|
|
86
|
+
function g(e) {
|
|
87
|
+
return e && e.map((t, r) => /* @__PURE__ */ a.createElement(t.tag, u({
|
|
88
|
+
key: r
|
|
89
|
+
}, t.attr), g(t.child)));
|
|
90
|
+
}
|
|
91
|
+
function I(e) {
|
|
92
|
+
return (t) => /* @__PURE__ */ a.createElement(x, c({
|
|
93
|
+
attr: u({}, e.attr)
|
|
94
|
+
}, t), g(e.child));
|
|
95
|
+
}
|
|
96
|
+
function x(e) {
|
|
97
|
+
var t = (r) => {
|
|
98
|
+
var {
|
|
99
|
+
attr: n,
|
|
100
|
+
size: i,
|
|
101
|
+
title: o
|
|
102
|
+
} = e, b = d(e, y), f = i || r.size || "1em", l;
|
|
103
|
+
return r.className && (l = r.className), e.className && (l = (l ? l + " " : "") + e.className), /* @__PURE__ */ a.createElement("svg", c({
|
|
104
|
+
stroke: "currentColor",
|
|
105
|
+
fill: "currentColor",
|
|
106
|
+
strokeWidth: "0"
|
|
107
|
+
}, r.attr, n, b, {
|
|
108
|
+
className: l,
|
|
109
|
+
style: u(u({
|
|
110
|
+
color: e.color || r.color
|
|
111
|
+
}, r.style), e.style),
|
|
112
|
+
height: f,
|
|
113
|
+
width: f,
|
|
114
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
115
|
+
}), o && /* @__PURE__ */ a.createElement("title", null, o), e.children);
|
|
116
|
+
};
|
|
117
|
+
return s !== void 0 ? /* @__PURE__ */ a.createElement(s.Consumer, null, (r) => t(r)) : t(p);
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
I as G,
|
|
121
|
+
N as a,
|
|
122
|
+
z as c,
|
|
123
|
+
D as g
|
|
124
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("./ChaiThemeFn-DQu-2Eh9.cjs"),o=(i=n.defaultThemeOptions)=>({container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},...n.getChaiThemeOptions(i)}),r=n.plugin(function({addBase:i,theme:e}){i({"h1,h2,h3,h4,h5,h6":{fontFamily:e("fontFamily.heading")},body:{fontFamily:e("fontFamily.body"),color:e("colors.foreground"),backgroundColor:e("colors.background")}})});exports.chaiBuilderPlugin=r;exports.getChaiBuilderTheme=o;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { g as r, d as a, p as i } from "./ChaiThemeFn-Cort9tch.js";
|
|
2
|
+
const t = (n = a) => ({
|
|
3
|
+
container: {
|
|
4
|
+
center: !0,
|
|
5
|
+
padding: "1rem",
|
|
6
|
+
screens: { "2xl": "1400px" }
|
|
7
|
+
},
|
|
8
|
+
...r(n)
|
|
9
|
+
}), l = i(function({ addBase: n, theme: o }) {
|
|
10
|
+
n({
|
|
11
|
+
"h1,h2,h3,h4,h5,h6": {
|
|
12
|
+
fontFamily: o("fontFamily.heading")
|
|
13
|
+
},
|
|
14
|
+
body: {
|
|
15
|
+
fontFamily: o("fontFamily.body"),
|
|
16
|
+
color: o("colors.foreground"),
|
|
17
|
+
backgroundColor: o("colors.background")
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
export {
|
|
22
|
+
l as c,
|
|
23
|
+
t as g
|
|
24
|
+
};
|
package/dist/render.cjs
CHANGED
|
@@ -1,248 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const ChaiThemeFn = require("./ChaiThemeFn-DcE5RdLQ.cjs");
|
|
4
|
-
const lodashEs = require("lodash-es");
|
|
5
|
-
const getSplitClasses = require("./getSplitClasses-mbQmvwI3.cjs");
|
|
6
|
-
const jitBrowserTailwindcss = require("@mhsdesign/jit-browser-tailwindcss");
|
|
7
|
-
const aspectRatio = require("@tailwindcss/aspect-ratio");
|
|
8
|
-
const containerQueries = require("@tailwindcss/container-queries");
|
|
9
|
-
const forms = require("@tailwindcss/forms");
|
|
10
|
-
const typography = require("@tailwindcss/typography");
|
|
11
|
-
const plugin = require("./plugin-BcTnEZwx.cjs");
|
|
12
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
const runtime = require("@chaibuilder/runtime");
|
|
14
|
-
const React = require("react");
|
|
15
|
-
const tailwindMerge = require("tailwind-merge");
|
|
16
|
-
const addPrefixToClasses = (classes, prefix = "") => {
|
|
17
|
-
const { classes: classesString } = getSplitClasses.getSplitChaiClasses(classes);
|
|
18
|
-
const array = classesString.split(" ").map((item) => {
|
|
19
|
-
const classes2 = item.split(" ");
|
|
20
|
-
const newClasses = classes2.map((item2) => {
|
|
21
|
-
if (item2 === "") return "";
|
|
22
|
-
if (item2.includes(":")) {
|
|
23
|
-
const values = item2.split(":");
|
|
24
|
-
values[values.length - 1] = prefix + lodashEs.last(values);
|
|
25
|
-
return values.join(":");
|
|
26
|
-
}
|
|
27
|
-
return `${prefix}${item2}`;
|
|
28
|
-
});
|
|
29
|
-
return newClasses.join(" ");
|
|
30
|
-
});
|
|
31
|
-
return lodashEs.flattenDeep(array).join(" ");
|
|
32
|
-
};
|
|
33
|
-
const convertToBlocks = (chaiFormatContent) => {
|
|
34
|
-
if (!chaiFormatContent) return [];
|
|
35
|
-
try {
|
|
36
|
-
const blocks = JSON.parse(removeAssetPrefix(chaiFormatContent));
|
|
37
|
-
return blocks.filter((block) => !block._type.startsWith("@chai"));
|
|
38
|
-
} catch (error) {
|
|
39
|
-
return [{ _type: "Paragraph", _id: "error", content: "Invalid JSON. Please check the JSON string." }];
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
function removeAssetPrefix(input) {
|
|
43
|
-
const regex = /(asset:\/\/|https:\/\/asset\.localhost\/)(?:localhost\/)?[^"']+/g;
|
|
44
|
-
return input.replace(regex, (match) => {
|
|
45
|
-
const decodedUrl = decodeURIComponent(match);
|
|
46
|
-
const publicIndex = decodedUrl.indexOf("public");
|
|
47
|
-
if (publicIndex !== -1) {
|
|
48
|
-
return decodedUrl.substring(publicIndex + 6);
|
|
49
|
-
}
|
|
50
|
-
return decodedUrl;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
async function getTailwindCSS(themeOptions, markupString, safelist = [], prefix = "", includeBaseStyles) {
|
|
54
|
-
const tailwind = jitBrowserTailwindcss.createTailwindcss({
|
|
55
|
-
tailwindConfig: {
|
|
56
|
-
darkMode: "class",
|
|
57
|
-
safelist,
|
|
58
|
-
theme: { extend: plugin.getChaiBuilderTheme(themeOptions) },
|
|
59
|
-
plugins: [forms, typography, aspectRatio, containerQueries, plugin.chaiBuilderPlugin],
|
|
60
|
-
corePlugins: { preflight: includeBaseStyles },
|
|
61
|
-
...prefix ? { prefix: `${prefix}` } : {}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
return await tailwind.generateStylesFromContent(
|
|
65
|
-
` ${includeBaseStyles ? "@tailwind base;" : ""}
|
|
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;":""}
|
|
66
2
|
@tailwind components;
|
|
67
|
-
@tailwind utilities;`,
|
|
68
|
-
markupString
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
const getBlocksTailwindCSS = (blocks, themeOptions, includeBaseStyles) => {
|
|
72
|
-
const blocksString = JSON.stringify(blocks).replace(/#styles:([^"]*)/g, (_match, content) => {
|
|
73
|
-
return `#styles:${content.replace(/,/g, " ")}`.replace(/#styles:/g, "");
|
|
74
|
-
});
|
|
75
|
-
return getTailwindCSS(themeOptions, [blocksString], [], "", includeBaseStyles);
|
|
76
|
-
};
|
|
77
|
-
const getStylesForBlocks = async (blocks, themeOptions = ChaiThemeFn.defaultThemeOptions, includeBaseStyles = false) => {
|
|
78
|
-
return await getBlocksTailwindCSS(blocks, themeOptions, includeBaseStyles);
|
|
79
|
-
};
|
|
80
|
-
async function AsyncPropsBlock(props) {
|
|
81
|
-
const dataProps = await (props == null ? void 0 : props.dataProvider(props.block, props.lang, props.metadata));
|
|
82
|
-
return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { children: React.createElement(props.component, { ...props.props, ...dataProps }) });
|
|
83
|
-
}
|
|
84
|
-
const generateClassNames = lodashEs.memoize((styles, classPrefix) => {
|
|
85
|
-
const { baseClasses, classes: classesString } = getSplitClasses.getSplitChaiClasses(styles);
|
|
86
|
-
const classes = tailwindMerge.twMerge(baseClasses, classesString);
|
|
87
|
-
if (classPrefix === "") return classes.replace(getSplitClasses.STYLES_KEY, "").trim();
|
|
88
|
-
return addPrefixToClasses(classes, classPrefix).replace(getSplitClasses.STYLES_KEY, "").trim();
|
|
89
|
-
});
|
|
90
|
-
const applyBinding = (block, pageExternalData) => {
|
|
91
|
-
const clonedBlock = lodashEs.cloneDeep(block);
|
|
92
|
-
lodashEs.forEach(lodashEs.keys(clonedBlock), (key) => {
|
|
93
|
-
if (lodashEs.isString(clonedBlock[key])) {
|
|
94
|
-
let value = clonedBlock[key];
|
|
95
|
-
const bindingRegex = /\{\{(.*?)\}\}/g;
|
|
96
|
-
const matches = value.match(bindingRegex);
|
|
97
|
-
if (matches) {
|
|
98
|
-
matches.forEach((match) => {
|
|
99
|
-
const binding = match.slice(2, -2);
|
|
100
|
-
const bindingValue = lodashEs.get(pageExternalData, binding, match);
|
|
101
|
-
value = value.replace(match, bindingValue);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
clonedBlock[key] = value;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
return clonedBlock;
|
|
108
|
-
};
|
|
109
|
-
function getElementAttrs(block, key) {
|
|
110
|
-
const attrs = lodashEs.get(block, `${key}_attrs`, {});
|
|
111
|
-
const attrsKeys = lodashEs.keys(attrs).join(" ");
|
|
112
|
-
if (lodashEs.includes(attrsKeys, "x-show") && !lodashEs.includes(attrsKeys, "x-transition")) {
|
|
113
|
-
attrs["x-transition"] = "";
|
|
114
|
-
}
|
|
115
|
-
return attrs;
|
|
116
|
-
}
|
|
117
|
-
function getStyleAttrs(block, classPrefix) {
|
|
118
|
-
const styles = {};
|
|
119
|
-
Object.keys(block).forEach((key) => {
|
|
120
|
-
if (lodashEs.isString(block[key]) && block[key].startsWith(getSplitClasses.STYLES_KEY)) {
|
|
121
|
-
const classes = generateClassNames(block[key], classPrefix);
|
|
122
|
-
styles[key] = {
|
|
123
|
-
className: classes,
|
|
124
|
-
...getElementAttrs(block, key)
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
return styles;
|
|
129
|
-
}
|
|
130
|
-
function applyLanguage(_block, lang, blockDefinition) {
|
|
131
|
-
if (lodashEs.isEmpty(lang)) return _block;
|
|
132
|
-
const block = lodashEs.cloneDeep(_block);
|
|
133
|
-
const i18nProps = lodashEs.get(blockDefinition, "i18nProps", []);
|
|
134
|
-
lodashEs.forEach(lodashEs.keys(block), (key) => {
|
|
135
|
-
if (i18nProps.includes(key) && !lodashEs.isEmpty(lang)) {
|
|
136
|
-
block[key] = lodashEs.get(block, `${key}-${lang}`, block[key]);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
return block;
|
|
140
|
-
}
|
|
141
|
-
const getRuntimeProps = lodashEs.memoize((blockType) => {
|
|
142
|
-
const chaiBlock = runtime.getRegisteredChaiBlock(blockType);
|
|
143
|
-
const props = lodashEs.get(chaiBlock, "schema.properties", {});
|
|
144
|
-
return Object.fromEntries(Object.entries(props).filter(([, value]) => lodashEs.get(value, "runtime", false)));
|
|
145
|
-
});
|
|
146
|
-
const getRuntimePropValues = (allBlocks, blockId, runtimeProps) => {
|
|
147
|
-
if (lodashEs.isEmpty(runtimeProps)) return {};
|
|
148
|
-
return Object.entries(runtimeProps).reduce((acc, [key, schema]) => {
|
|
149
|
-
const hierarchy = [];
|
|
150
|
-
let block = lodashEs.find(allBlocks, { _id: blockId });
|
|
151
|
-
while (block) {
|
|
152
|
-
hierarchy.push(block);
|
|
153
|
-
block = lodashEs.find(allBlocks, { _id: block._parent });
|
|
154
|
-
}
|
|
155
|
-
const matchingBlock = lodashEs.find(hierarchy, { _type: schema.block });
|
|
156
|
-
if (matchingBlock) {
|
|
157
|
-
acc[key] = lodashEs.get(matchingBlock, lodashEs.get(schema, "prop"), null);
|
|
158
|
-
}
|
|
159
|
-
return acc;
|
|
160
|
-
}, {});
|
|
161
|
-
};
|
|
162
|
-
const SuspenseFallback = () => /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Loading..." });
|
|
163
|
-
function RenderChaiBlocks({
|
|
164
|
-
blocks,
|
|
165
|
-
parent,
|
|
166
|
-
classPrefix = "",
|
|
167
|
-
externalData = {},
|
|
168
|
-
blockModifierCallback = null,
|
|
169
|
-
lang = "",
|
|
170
|
-
fallbackLang = "",
|
|
171
|
-
metadata = {}
|
|
172
|
-
}) {
|
|
173
|
-
const allBlocks = blocks;
|
|
174
|
-
const getStyles = (block) => getStyleAttrs(block, classPrefix);
|
|
175
|
-
const filteredBlocks = parent ? lodashEs.filter(blocks, { _parent: parent }) : lodashEs.filter(blocks, (block) => lodashEs.isEmpty(block._parent));
|
|
176
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: React.Children.toArray(
|
|
177
|
-
filteredBlocks.map((block, index) => {
|
|
178
|
-
const attrs = {};
|
|
179
|
-
const blocks2 = lodashEs.filter(allBlocks, { _parent: block._id });
|
|
180
|
-
attrs.children = blocks2.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
181
|
-
RenderChaiBlocks,
|
|
182
|
-
{
|
|
183
|
-
externalData,
|
|
184
|
-
classPrefix,
|
|
185
|
-
parent: block._id,
|
|
186
|
-
blocks: allBlocks,
|
|
187
|
-
lang: lang || fallbackLang,
|
|
188
|
-
metadata
|
|
189
|
-
}
|
|
190
|
-
) : null;
|
|
191
|
-
const blockDefinition = runtime.getRegisteredChaiBlock(block._type);
|
|
192
|
-
if (blockDefinition !== null) {
|
|
193
|
-
let syncedBlock = block;
|
|
194
|
-
const Component = blockDefinition.component;
|
|
195
|
-
syncedBlock = { ...blockDefinition.defaults, ...block };
|
|
196
|
-
if (blockModifierCallback) {
|
|
197
|
-
syncedBlock = blockModifierCallback(syncedBlock);
|
|
198
|
-
}
|
|
199
|
-
const langToUse = lang === fallbackLang ? "" : lang;
|
|
200
|
-
const runtimeProps = getRuntimePropValues(allBlocks, block._id, getRuntimeProps(block._type));
|
|
201
|
-
const props = lodashEs.omit(
|
|
202
|
-
{
|
|
203
|
-
blockProps: {},
|
|
204
|
-
inBuilder: false,
|
|
205
|
-
...syncedBlock,
|
|
206
|
-
index,
|
|
207
|
-
...applyBinding(applyLanguage(block, langToUse, blockDefinition), externalData),
|
|
208
|
-
...getStyles(syncedBlock),
|
|
209
|
-
...attrs,
|
|
210
|
-
...runtimeProps,
|
|
211
|
-
metadata,
|
|
212
|
-
lang: lang || fallbackLang
|
|
213
|
-
},
|
|
214
|
-
["_parent"]
|
|
215
|
-
);
|
|
216
|
-
if (lodashEs.has(blockDefinition, "dataProvider")) {
|
|
217
|
-
const suspenseFallback = lodashEs.get(
|
|
218
|
-
blockDefinition,
|
|
219
|
-
"suspenseFallback",
|
|
220
|
-
SuspenseFallback
|
|
221
|
-
);
|
|
222
|
-
return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: React.createElement(suspenseFallback), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
223
|
-
AsyncPropsBlock,
|
|
224
|
-
{
|
|
225
|
-
lang: lang || fallbackLang,
|
|
226
|
-
metadata,
|
|
227
|
-
dataProvider: blockDefinition.dataProvider,
|
|
228
|
-
block,
|
|
229
|
-
component: Component,
|
|
230
|
-
props
|
|
231
|
-
}
|
|
232
|
-
) });
|
|
233
|
-
}
|
|
234
|
-
return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { children: React.createElement(Component, props) });
|
|
235
|
-
}
|
|
236
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("noscript", { children: [
|
|
237
|
-
block._type,
|
|
238
|
-
" not found"
|
|
239
|
-
] });
|
|
240
|
-
})
|
|
241
|
-
) });
|
|
242
|
-
}
|
|
243
|
-
exports.getChaiThemeCssVariables = ChaiThemeFn.getChaiThemeCssVariables;
|
|
244
|
-
exports.getThemeFontsCSSImport = ChaiThemeFn.getThemeFontsCSSImport;
|
|
245
|
-
exports.getThemeFontsLinkMarkup = ChaiThemeFn.getThemeFontsLinkMarkup;
|
|
246
|
-
exports.RenderChaiBlocks = RenderChaiBlocks;
|
|
247
|
-
exports.convertToBlocks = convertToBlocks;
|
|
248
|
-
exports.getStylesForBlocks = getStylesForBlocks;
|
|
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;
|