@chaibuilder/sdk 2.0.0-beta.13 → 2.0.0-beta.14

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.
@@ -1,6 +1,8 @@
1
1
  import { Config } from 'tailwindcss/types/config';
2
2
  import { PluginCreator } from 'tailwindcss/types/config';
3
3
 
4
+ declare type BorderRadiusValue = false | string;
5
+
4
6
  /**
5
7
  * This is the tailwind plugin for chai builder
6
8
  * @param {*} theme
@@ -11,17 +13,14 @@ export declare const chaiBuilderPlugin: {
11
13
  config?: Partial<Config>;
12
14
  };
13
15
 
14
- declare type ChaiBuilderTailwindTheme<T extends Record<string, unknown> = Record<string, unknown>> = {
15
- primaryColor: string;
16
- secondaryColor: string;
17
- headingFont: string;
18
- bodyFont: string;
19
- roundedCorners: string;
20
- bodyBgLightColor: string;
21
- bodyBgDarkColor: string;
22
- bodyTextLightColor: string;
23
- bodyTextDarkColor: string;
24
- } & T;
16
+ declare type ChaiBuilderThemeOptions = {
17
+ fontFamily: false | Record<VariableKey, string>;
18
+ borderRadius: BorderRadiusValue;
19
+ colors: false | {
20
+ group: string;
21
+ items: Record<VariableKey, [HSLColor, HSLColor]>;
22
+ }[];
23
+ };
25
24
 
26
25
  export declare const getChaiBuilderTailwindConfig: (content: string[]) => {
27
26
  darkMode: string;
@@ -95,7 +94,18 @@ export declare const getChaiBuilderTailwindConfig: (content: string[]) => {
95
94
  plugins: any[];
96
95
  };
97
96
 
98
- export declare const getChaiBuilderTheme: (theme: ChaiBuilderTailwindTheme) => {
97
+ export declare const getChaiBuilderTheme: (theme: ChaiBuilderThemeOptions) => {
98
+ fontFamily: any;
99
+ borderRadius: {
100
+ lg: string;
101
+ md: string;
102
+ sm: string;
103
+ } | {
104
+ lg?: undefined;
105
+ md?: undefined;
106
+ sm?: undefined;
107
+ };
108
+ colors: any;
99
109
  container: {
100
110
  center: boolean;
101
111
  padding: string;
@@ -103,19 +113,10 @@ export declare const getChaiBuilderTheme: (theme: ChaiBuilderTailwindTheme) => {
103
113
  "2xl": string;
104
114
  };
105
115
  };
106
- fontFamily: {
107
- heading: any[];
108
- body: any[];
109
- };
110
- borderRadius: {
111
- DEFAULT: string;
112
- };
113
- colors: {
114
- [x: string]: string | {
115
- [x: string]: string;
116
- [x: number]: string;
117
- };
118
- };
119
116
  };
120
117
 
118
+ declare type HSLColor = string;
119
+
120
+ declare type VariableKey = string;
121
+
121
122
  export { }
package/dist/tailwind.js CHANGED
@@ -2,9 +2,9 @@ import o from "@tailwindcss/typography";
2
2
  import e from "@tailwindcss/forms";
3
3
  import a from "@tailwindcss/aspect-ratio";
4
4
  import d from "tailwindcss-animate";
5
- import { c as m, g as p } from "./plugin-PFjzFeON.js";
5
+ import { c as m, g as p } from "./plugin-LMd_CSyg.js";
6
+ import "./ChaiThemeFn-i9QJeB_e.js";
6
7
  import "lodash-es";
7
- import "./plugin-ooqqxWRQ.js";
8
8
  function n() {
9
9
  return {
10
10
  colors: {
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.13",
8
+ "version": "2.0.0-beta.14",
9
9
  "type": "module",
10
10
  "repository": {
11
11
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),b=require("@monaco-editor/react"),k=require("./context-menu-4nQs6OxC.cjs"),C=require("react-i18next"),u=require("react"),n=require("./core.cjs"),E=require("@radix-ui/react-icons"),R=require("@react-hookz/web");require("@radix-ui/react-switch");require("@radix-ui/react-accordion");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-hover-card");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("@radix-ui/react-context-menu");require("clsx");require("tailwind-merge");require("lodash-es");require("jotai");require("./iconBase-aZzpqff_.cjs");require("./plugin-KIpT3NWi.cjs");require("lodash");require("tree-model");require("@chaibuilder/runtime");require("react-quill");require("flagged");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("./STRINGS-26RPxXyi.cjs");require("react-wrap-balancer");require("react-dom");require("prop-types");require("react-error-boundary");require("re-resizable");require("lucide-react");require("react-arborist");require("himalaya");require("@rjsf/core");require("@rjsf/validator-ajv8");require("react-icons-picker");require("react-autosuggest");require("fuse.js");require("i18next");require("framer-motion");const a=s=>{const i=document.createElement("div");return i.innerHTML=s,i.innerHTML};function g(){const{t:s}=C.useTranslation(),[i,d]=u.useState(!1),[l,q]=u.useState(""),[r,o]=n.useCodeEditor(),[c]=n.useSelectedBlockIds(),x=n.useUpdateBlocksProps(),m=n.useUpdateBlocksPropsRealtime(),p=R.useThrottledCallback(t=>{const h=a(t);m([r.blockId],{[r.blockProp]:h})},[],300),j=u.useCallback(()=>{if(i){const t=a(l);x([r.blockId],{[r.blockProp]:t})}},[i,l]);u.useEffect(()=>{c.includes(r==null?void 0:r.blockId)||(j(),o(null))},[c]);const f=()=>{o(null)};return e.jsxRuntimeExports.jsxs("div",{className:"h-full rounded-t-lg border-t-4 border-black bg-black text-white",children:[e.jsxRuntimeExports.jsx("button",{onClick:f,className:"fixed inset-0 z-[100000] cursor-default bg-gray-400/20"}),e.jsxRuntimeExports.jsxs("div",{className:"relative z-[100001] h-full w-full flex-col gap-y-1",children:[e.jsxRuntimeExports.jsxs("div",{className:"-mt-1 flex items-center justify-between px-2 py-2",children:[e.jsxRuntimeExports.jsxs("h3",{className:"space-x-3 text-sm font-semibold",children:[e.jsxRuntimeExports.jsx("span",{children:s("HTML Code Editor |")}),e.jsxRuntimeExports.jsx("span",{className:"text-xs text-gray-400",children:s("Scripts will be only executed in preview and live mode.")})]}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-x-2",children:e.jsxRuntimeExports.jsx(k.Button,{onClick:()=>o(null),size:"sm",variant:"destructive",className:"h-6 w-fit",children:e.jsxRuntimeExports.jsx(E.Cross2Icon,{})})})]}),e.jsxRuntimeExports.jsx(b,{onMount:t=>{t.setValue(r.initialCode)},onChange:t=>{d(!0),q(t),p(t)},height:"100%",defaultLanguage:"html",theme:"vs-dark",defaultValue:"",options:{minimap:{enabled:!1}}})]})]})}exports.default=g;
@@ -1 +0,0 @@
1
- "use strict";const _="#styles:",E="__ADD_BLOCK_INTERNAL_ROOT";exports.ROOT_TEMP_KEY=E;exports.STYLES_KEY=_;
@@ -1,5 +0,0 @@
1
- const _ = "#styles:", s = "__ADD_BLOCK_INTERNAL_ROOT";
2
- export {
3
- s as R,
4
- _ as S
5
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime-JYMCiFoE.cjs"),r=require("react"),s=require("./context-menu-4nQs6OxC.cjs");require("react-i18next");const u=require("./core.cjs");require("@radix-ui/react-switch");require("@radix-ui/react-accordion");require("@radix-ui/react-icons");require("@radix-ui/react-alert-dialog");require("@radix-ui/react-slot");require("class-variance-authority");require("@radix-ui/react-dialog");require("@radix-ui/react-label");require("@radix-ui/react-scroll-area");require("@radix-ui/react-tabs");require("@radix-ui/react-tooltip");require("@radix-ui/react-popover");require("@radix-ui/react-hover-card");require("@radix-ui/react-dropdown-menu");require("@radix-ui/react-separator");require("@radix-ui/react-toast");require("@radix-ui/react-context-menu");require("clsx");require("tailwind-merge");require("lodash-es");require("jotai");require("./iconBase-aZzpqff_.cjs");require("./plugin-KIpT3NWi.cjs");require("@react-hookz/web");require("lodash");require("tree-model");require("@chaibuilder/runtime");require("react-quill");require("flagged");require("react-hotkeys-hook");require("@floating-ui/dom");require("@floating-ui/react-dom");require("@tailwindcss/typography");require("@tailwindcss/forms");require("@tailwindcss/aspect-ratio");require("./STRINGS-26RPxXyi.cjs");require("react-wrap-balancer");require("react-dom");require("prop-types");require("react-error-boundary");require("re-resizable");require("lucide-react");require("react-arborist");require("himalaya");require("@rjsf/core");require("@rjsf/validator-ajv8");require("react-icons-picker");require("react-autosuggest");require("fuse.js");require("i18next");require("framer-motion");const o=()=>{const t=u.useBuilderProp("topBarComponents.left",[]),n=u.useBuilderProp("topBarComponents.center",[]),q=u.useBuilderProp("topBarComponents.right",[]);return e.jsxRuntimeExports.jsxs("div",{className:"flex h-14 items-center justify-between px-2",children:[e.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2",children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2 font-bold",children:r.Children.toArray(t.map(i=>e.jsxRuntimeExports.jsx(r.Suspense,{fallback:e.jsxRuntimeExports.jsx(s.Skeleton,{className:"h-10"}),children:e.jsxRuntimeExports.jsx(i,{})})))})}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-2",children:r.Children.toArray(n.map(i=>e.jsxRuntimeExports.jsx(r.Suspense,{fallback:e.jsxRuntimeExports.jsx(s.Skeleton,{className:"h-10"}),children:e.jsxRuntimeExports.jsx(i,{})})))}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center space-x-1",children:r.Children.toArray(q.map(i=>e.jsxRuntimeExports.jsx(r.Suspense,{fallback:e.jsxRuntimeExports.jsx(s.Skeleton,{className:"h-10"}),children:e.jsxRuntimeExports.jsx(i,{})})))})]})};exports.default=o;
@@ -1 +0,0 @@
1
- "use strict";const i=require("lodash-es"),k=require("./plugin-KIpT3NWi.cjs");var F=({hex:r,preserve:t,shades:y})=>{const p=(a=>{const s=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a)||[];try{let o=parseInt(s[1],16),n=parseInt(s[2],16),e=parseInt(s[3],16);o/=255,n/=255,e/=255;const c=Math.max(o,n,e),u=Math.min(o,n,e);let m,h=0,b=(c+u)/2;if(c==u)h=m=0;else{const d=c-u;switch(m=b>.5?d/(2-c-u):d/(c+u),c){case o:h=(n-e)/d+(n<e?6:0);break;case n:h=(e-o)/d+2;break;case e:h=(o-n)/d+4}h/=6}const f={h:0,s:0,l:0};return f.h=Math.round(360*h),f.s=Math.round(100*m),f.l=Math.round(100*b),f}catch{return console.log(a),{h:0,s:0,l:0}}})(r),l={},g=y.reduce((a,{name:s,lightness:o})=>{const{h:n,s:e,l:c}=p,u=(({h:m,s:h,l:b})=>{b/=100;const f=h*Math.min(b,1-b)/100,d=M=>{const x=(M+m/30)%12,T=b-f*Math.max(Math.min(x-3,9-x,1),-1);return Math.round(255*T).toString(16).padStart(2,"0")};return`#${d(0)}${d(8)}${d(4)}`})({h:n,s:e,l:o});return a[s]=u,t&&(l[s]=Math.abs(c-o)),a},{});if(t){const[a]=Object.keys(l).sort((s,o)=>l[s]-l[o]);g[a]=r}return g},C=r=>{typeof r=="string"&&(r={colors:[r]}),typeof r=="object"&&Array.isArray(r)&&(r={colors:r}),r=Object.assign({colors:[],names:["primary","secondary","tertiary","quaternary","quinary","senary","septenary","octonary","nonary","denary"],preserve:!0,shades:[{name:"50",lightness:98},{name:"100",lightness:95},{name:"200",lightness:90},{name:"300",lightness:82},{name:"400",lightness:64},{name:"500",lightness:46},{name:"600",lightness:33},{name:"700",lightness:24},{name:"800",lightness:14},{name:"900",lightness:7},{name:"950",lightness:4}]},r);const{colors:t,names:y,preserve:p,shades:l}=r;return t===void 0||y===void 0||p===void 0||l===void 0?{}:t.reduce((g,a,s)=>{const o=y[s],n=F({hex:a,preserve:p,shades:l});return g[o]=n,g},{})};const D=r=>{const t=i.get(r,"primaryColor","#000"),y=i.get(r,"secondaryColor","#ccc"),p=i.get(r,"headingFont","Inter"),l=i.get(r,"bodyFont","Inter"),g=i.get(r,"roundedCorners","0"),a=i.get(r,"bodyBgLightColor","#fff"),s=i.get(r,"bodyBgDarkColor","#000"),o=i.get(r,"bodyTextLightColor","#000"),n=i.get(r,"bodyTextDarkColor","#fff"),e=C({colors:[t,y],names:["primary","secondary"]});i.set(e,"primary.DEFAULT",t),i.set(e,"secondary.DEFAULT",y);const c={"bg-light":a,"bg-dark":s,"text-dark":n,"text-light":o};return{container:{center:!0,padding:"1rem",screens:{"2xl":"1400px"}},fontFamily:{heading:[p],body:[l]},borderRadius:{DEFAULT:`${g||"0px"}px`},colors:{...e,...c}}},E=k.plugin(function({addBase:r,theme:t}){r({"h1,h2,h3,h4,h5,h6":{fontFamily:t("fontFamily.heading")},body:{fontFamily:t("fontFamily.body"),color:t("colors.text-light"),backgroundColor:t("colors.bg-light")},".dark body":{color:t("colors.text-dark"),backgroundColor:t("colors.bg-dark")}})});exports.chaiBuilderPlugin=E;exports.getChaiBuilderTheme=D;
@@ -1 +0,0 @@
1
- "use strict";function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c={},f={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});function u(n,t){return{handler:n,config:t}}u.withOptions=function(n,t=()=>({})){const r=function(i){return{__options:i,handler:n(i),config:t(i)}};return r.__isOptionsFunction=!0,r.__pluginFunction=n,r.__configFunction=t,r};const l=u})(f);(function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const u=l(f);function l(t){return t&&t.__esModule?t:{default:t}}const n=u.default})(c);let o=c;var _=(o.__esModule?o:{default:o}).default;const d=a(_);exports.getDefaultExportFromCjs=a;exports.plugin=d;
@@ -1,97 +0,0 @@
1
- import { get as d, set as M } from "lodash-es";
2
- import { p as T } from "./plugin-ooqqxWRQ.js";
3
- var D = ({ hex: r, preserve: n, shades: y }) => {
4
- const b = ((e) => {
5
- const a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e) || [];
6
- try {
7
- let o = parseInt(a[1], 16), t = parseInt(a[2], 16), s = parseInt(a[3], 16);
8
- o /= 255, t /= 255, s /= 255;
9
- const c = Math.max(o, t, s), u = Math.min(o, t, s);
10
- let f, g = 0, p = (c + u) / 2;
11
- if (c == u)
12
- g = f = 0;
13
- else {
14
- const l = c - u;
15
- switch (f = p > 0.5 ? l / (2 - c - u) : l / (c + u), c) {
16
- case o:
17
- g = (t - s) / l + (t < s ? 6 : 0);
18
- break;
19
- case t:
20
- g = (s - o) / l + 2;
21
- break;
22
- case s:
23
- g = (o - t) / l + 4;
24
- }
25
- g /= 6;
26
- }
27
- const m = { h: 0, s: 0, l: 0 };
28
- return m.h = Math.round(360 * g), m.s = Math.round(100 * f), m.l = Math.round(100 * p), m;
29
- } catch {
30
- return console.log(e), { h: 0, s: 0, l: 0 };
31
- }
32
- })(r), i = {}, h = y.reduce((e, { name: a, lightness: o }) => {
33
- const { h: t, s, l: c } = b, u = (({ h: f, s: g, l: p }) => {
34
- p /= 100;
35
- const m = g * Math.min(p, 1 - p) / 100, l = (k) => {
36
- const x = (k + f / 30) % 12, F = p - m * Math.max(Math.min(x - 3, 9 - x, 1), -1);
37
- return Math.round(255 * F).toString(16).padStart(2, "0");
38
- };
39
- return `#${l(0)}${l(8)}${l(4)}`;
40
- })({ h: t, s, l: o });
41
- return e[a] = u, n && (i[a] = Math.abs(c - o)), e;
42
- }, {});
43
- if (n) {
44
- const [e] = Object.keys(i).sort((a, o) => i[a] - i[o]);
45
- h[e] = r;
46
- }
47
- return h;
48
- }, C = (r) => {
49
- typeof r == "string" && (r = { colors: [r] }), typeof r == "object" && Array.isArray(r) && (r = { colors: r }), r = Object.assign({ colors: [], names: ["primary", "secondary", "tertiary", "quaternary", "quinary", "senary", "septenary", "octonary", "nonary", "denary"], preserve: !0, shades: [{ name: "50", lightness: 98 }, { name: "100", lightness: 95 }, { name: "200", lightness: 90 }, { name: "300", lightness: 82 }, { name: "400", lightness: 64 }, { name: "500", lightness: 46 }, { name: "600", lightness: 33 }, { name: "700", lightness: 24 }, { name: "800", lightness: 14 }, { name: "900", lightness: 7 }, { name: "950", lightness: 4 }] }, r);
50
- const { colors: n, names: y, preserve: b, shades: i } = r;
51
- return n === void 0 || y === void 0 || b === void 0 || i === void 0 ? {} : n.reduce((h, e, a) => {
52
- const o = y[a], t = D({ hex: e, preserve: b, shades: i });
53
- return h[o] = t, h;
54
- }, {});
55
- };
56
- const _ = (r) => {
57
- const n = d(r, "primaryColor", "#000"), y = d(r, "secondaryColor", "#ccc"), b = d(r, "headingFont", "Inter"), i = d(r, "bodyFont", "Inter"), h = d(r, "roundedCorners", "0"), e = d(r, "bodyBgLightColor", "#fff"), a = d(r, "bodyBgDarkColor", "#000"), o = d(r, "bodyTextLightColor", "#000"), t = d(r, "bodyTextDarkColor", "#fff"), s = C({
58
- colors: [n, y],
59
- names: ["primary", "secondary"]
60
- });
61
- M(s, "primary.DEFAULT", n), M(s, "secondary.DEFAULT", y);
62
- const c = {
63
- "bg-light": e,
64
- "bg-dark": a,
65
- "text-dark": t,
66
- "text-light": o
67
- };
68
- return {
69
- container: {
70
- center: !0,
71
- padding: "1rem",
72
- screens: { "2xl": "1400px" }
73
- },
74
- fontFamily: { heading: [b], body: [i] },
75
- borderRadius: { DEFAULT: `${h || "0px"}px` },
76
- colors: { ...s, ...c }
77
- };
78
- }, A = T(function({ addBase: r, theme: n }) {
79
- r({
80
- "h1,h2,h3,h4,h5,h6": {
81
- fontFamily: n("fontFamily.heading")
82
- },
83
- body: {
84
- fontFamily: n("fontFamily.body"),
85
- color: n("colors.text-light"),
86
- backgroundColor: n("colors.bg-light")
87
- },
88
- ".dark body": {
89
- color: n("colors.text-dark"),
90
- backgroundColor: n("colors.bg-dark")
91
- }
92
- });
93
- });
94
- export {
95
- A as c,
96
- _ as g
97
- };
@@ -1,55 +0,0 @@
1
- function f(e) {
2
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3
- }
4
- var i = {}, c = {};
5
- (function(e) {
6
- Object.defineProperty(e, "__esModule", {
7
- value: !0
8
- }), Object.defineProperty(e, "default", {
9
- enumerable: !0,
10
- get: function() {
11
- return l;
12
- }
13
- });
14
- function u(n, t) {
15
- return {
16
- handler: n,
17
- config: t
18
- };
19
- }
20
- u.withOptions = function(n, t = () => ({})) {
21
- const r = function(a) {
22
- return {
23
- __options: a,
24
- handler: n(a),
25
- config: t(a)
26
- };
27
- };
28
- return r.__isOptionsFunction = !0, r.__pluginFunction = n, r.__configFunction = t, r;
29
- };
30
- const l = u;
31
- })(c);
32
- (function(e) {
33
- Object.defineProperty(e, "__esModule", {
34
- value: !0
35
- }), Object.defineProperty(e, "default", {
36
- enumerable: !0,
37
- get: function() {
38
- return n;
39
- }
40
- });
41
- const u = /* @__PURE__ */ l(c);
42
- function l(t) {
43
- return t && t.__esModule ? t : {
44
- default: t
45
- };
46
- }
47
- const n = u.default;
48
- })(i);
49
- let o = i;
50
- var _ = (o.__esModule ? o : { default: o }).default;
51
- const d = /* @__PURE__ */ f(_);
52
- export {
53
- f as g,
54
- d as p
55
- };