@chaibuilder/sdk 2.1.1 → 2.1.3
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/{CodeEditor-BG4oToVY.cjs → CodeEditor-Ca96GgCc.cjs} +1 -1
- package/dist/{CodeEditor-CdNhJvdd.js → CodeEditor-gWBq2ypP.js} +1 -1
- package/dist/{chai-theme-helpers-BpnwYsLZ.js → chai-theme-helpers-CVkLfKt7.js} +4 -5
- package/dist/chai-theme-helpers-GQ1UI3nD.cjs +22 -0
- package/dist/core.cjs +6 -6
- package/dist/core.d.ts +9 -21
- package/dist/core.js +4088 -7394
- package/dist/{plugin-D56-CF7U.js → plugin-DRtv2KR5.js} +1 -1
- package/dist/{plugin-PDQQ8m4D.cjs → plugin-uUPBh-_c.cjs} +1 -1
- package/dist/render.cjs +1 -1
- package/dist/render.js +3 -3
- package/dist/tailwind.cjs +1 -1
- package/dist/tailwind.js +1 -1
- package/dist/tooltip-BU2vOhlU.js +821 -0
- package/dist/tooltip-CUA6Xg5r.cjs +1 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +2 -2
- package/package.json +3 -3
- package/dist/chai-theme-helpers-D2bHv81c.cjs +0 -22
- package/dist/tooltip-CkYl0YhP.cjs +0 -1
- package/dist/tooltip-D9DF_nUo.js +0 -1900
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),C=require("@radix-ui/react-icons"),v=require("@react-hookz/web"),n=require("react"),j=require("react-i18next"),g=require("./tooltip-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),C=require("@radix-ui/react-icons"),v=require("@react-hookz/web"),n=require("react"),j=require("react-i18next"),g=require("./tooltip-CUA6Xg5r.cjs"),a=require("./core.cjs"),u=o=>{const s=document.createElement("div");return s.innerHTML=o,s.innerHTML};function y(){const{t:o}=j.useTranslation(),[s,x]=n.useState(!1),[i,m]=n.useState(""),[t,r]=a.useCodeEditor(),[d]=a.useSelectedBlockIds(),b=a.useUpdateBlocksProps(),f=a.useUpdateBlocksPropsRealtime(),p=v.useThrottledCallback(l=>{const c=u(l);f([t.blockId],{[t.blockProp]:c})},[],300),h=n.useCallback(()=>{if(s){const l=u(i);b([t.blockId],{[t.blockProp]:l})}},[s,i]);n.useEffect(()=>{d.includes(t==null?void 0:t.blockId)||(h(),r(null))},[d]);const k=()=>{r(null)};return e.jsxs("div",{className:"h-full text-white bg-black border-t-4 border-black rounded-t-lg",children:[e.jsx("button",{onClick:k,className:"fixed inset-0 z-[100000] cursor-default bg-gray-400/20"}),e.jsxs("div",{className:"relative z-[100001] h-full w-full flex-col gap-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between px-2 py-2 -mt-1",children:[e.jsxs("h3",{className:"space-x-3 text-sm font-semibold",children:[e.jsx("span",{children:o("HTML Code Editor |")}),e.jsx("span",{className:"text-xs text-gray-400",children:o("Scripts will be only executed in preview and live mode.")})]}),e.jsx("div",{className:"flex gap-x-2",children:e.jsx(g.Button,{onClick:()=>r(null),size:"sm",variant:"destructive",className:"h-6 w-fit",children:e.jsx(C.Cross2Icon,{})})})]}),e.jsx("textarea",{className:"w-full h-full p-2 font-mono text-xs bg-black text-white/90",value:i||t.initialCode,onChange:l=>{const c=l.target.value;x(!0),m(c),p(c)}})]})]})}exports.default=y;
|
|
@@ -3,7 +3,7 @@ import { Cross2Icon as k } from "@radix-ui/react-icons";
|
|
|
3
3
|
import { useThrottledCallback as C } from "@react-hookz/web";
|
|
4
4
|
import { useState as d, useCallback as v, useEffect as g } from "react";
|
|
5
5
|
import { useTranslation as N } from "react-i18next";
|
|
6
|
-
import { B as w } from "./tooltip-
|
|
6
|
+
import { B as w } from "./tooltip-BU2vOhlU.js";
|
|
7
7
|
import { useCodeEditor as y, useSelectedBlockIds as T, useUpdateBlocksProps as B, useUpdateBlocksPropsRealtime as E } from "./core.js";
|
|
8
8
|
const u = (o) => {
|
|
9
9
|
const l = document.createElement("div");
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { getAllRegisteredFonts as _ } from "@chaibuilder/runtime";
|
|
2
2
|
import { uniqBy as c, keys as b, flatten as v, get as P } from "lodash-es";
|
|
3
|
-
function h(e) {
|
|
4
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
5
|
-
}
|
|
6
3
|
const k = {
|
|
7
4
|
fontFamily: {
|
|
8
5
|
"font-heading": "Inter",
|
|
@@ -76,6 +73,9 @@ const k = {
|
|
|
76
73
|
}
|
|
77
74
|
]
|
|
78
75
|
};
|
|
76
|
+
function h(e) {
|
|
77
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
78
|
+
}
|
|
79
79
|
var s = {}, d = {}, p;
|
|
80
80
|
function j() {
|
|
81
81
|
return p || (p = 1, function(e) {
|
|
@@ -212,8 +212,7 @@ export {
|
|
|
212
212
|
A as b,
|
|
213
213
|
w as c,
|
|
214
214
|
k as d,
|
|
215
|
-
|
|
216
|
-
x as f,
|
|
215
|
+
x as e,
|
|
217
216
|
S as g,
|
|
218
217
|
q as p
|
|
219
218
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";const h=require("@chaibuilder/runtime"),F=require("lodash-es"),_={fontFamily:{"font-heading":"Inter","font-body":"Inter"},borderRadius:"10px",colors:[{group:"Body",items:{background:["#FFFFFF","#121212"],foreground:["#121212","#FFFFFF"]}},{group:"Primary",items:{primary:["#2563EB","#3B82F6"],"primary-foreground":["#FFFFFF","#FFFFFF"]}},{group:"Secondary",items:{secondary:["#F3F4F6","#374151"],"secondary-foreground":["#1F2937","#F9FAFB"]}},{group:"Border, Input & Ring",items:{border:["#E5E7EB","#374151"],input:["#E5E7EB","#374151"],ring:["#2563EB","#3B82F6"]}},{group:"Card",items:{card:["#FFFFFF","#1F2937"],"card-foreground":["#121212","#FFFFFF"]}},{group:"Popover",items:{popover:["#FFFFFF","#1F2937"],"popover-foreground":["#121212","#FFFFFF"]}},{group:"Muted",items:{muted:["#F3F4F6","#374151"],"muted-foreground":["#6B7280","#9CA3AF"]}},{group:"Accent",items:{accent:["#F3F4F6","#374151"],"accent-foreground":["#1F2937","#FFFFFF"]}},{group:"Destructive",items:{destructive:["#DC2626","#EF4444"],"destructive-foreground":["#FFFFFF","#FFFFFF"]}}]};function b(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var d={},c={},m;function v(){return m||(m=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});function r(n,o){return{handler:n,config:o}}r.withOptions=function(n,o=()=>({})){const u=function(i){return{__options:i,handler:n(i),config:o(i)}};return u.__isOptionsFunction=!0,u.__pluginFunction=n,u.__configFunction=o,u};const t=r}(c)),c}var p;function C(){return p||(p=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const r=t(v());function t(o){return o&&o.__esModule?o:{default:o}}const n=r.default}(d)),d}var f,y;function P(){if(y)return f;y=1;let e=C();return f=(e.__esModule?e:{default:e}).default,f}var j=P();const B=b(j),M=e=>({fontFamily:e.fontFamily?F.keys(e.fontFamily).reduce((t,n)=>({...t,[n.replace("font-","")]:`var(--${n})`}),{}):{},borderRadius:e.borderRadius?{lg:"var(--radius)",md:"calc(var(--radius) - 2px)",sm:"calc(var(--radius) - 4px)"}:{},colors:e.colors?F.flatten(e.colors.map(t=>Object.entries(t.items))).reduce((t,[n])=>({...t,[n]:`hsl(var(--${n}))`}),{}):{}});function $(e){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);let t=parseInt(r[1],16),n=parseInt(r[2],16),o=parseInt(r[3],16);t/=255,n/=255,o/=255;const u=Math.max(t,n,o),i=Math.min(t,n,o);let a,s;const g=(u+i)/2;if(u==i)a=s=0;else{const l=u-i;switch(s=g>.5?l/(2-u-i):l/(u+i),u){case t:a=(n-o)/l+(n<o?6:0);break;case n:a=(o-t)/l+2;break;case o:a=(t-n)/l+4;break}a/=6}return`${Math.round(a*360)} ${Math.round(s*100)}% ${Math.round(g*100)}%`}const q=e=>{const t=h.getAllRegisteredFonts().find(n=>n.family===e);return`"${e}", ${F.get(t,"fallback","")}`},E=e=>`:root {
|
|
2
|
+
${e.fontFamily&&Object.entries(e.fontFamily).map(([r,t])=>`--font-${r}: ${q(t)};`).join(`
|
|
3
|
+
`)}
|
|
4
|
+
${e.borderRadius&&`--radius: ${e.borderRadius};`}
|
|
5
|
+
${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${$(t[0])};`).join(`
|
|
6
|
+
`)}
|
|
7
|
+
}
|
|
8
|
+
.dark {
|
|
9
|
+
${e.colors&&Object.entries(e.colors).map(([r,t])=>`--${r}: ${$(t[1])};`).join(`
|
|
10
|
+
`)}
|
|
11
|
+
}`,O=e=>!e||e.length===0?"":F.uniqBy(e,"family").map(r=>`<link rel="stylesheet" href="${r.url}" />`).join(`
|
|
12
|
+
`),k=e=>!e||e.length===0?"":F.uniqBy(e,"family").map(r=>`@import url("${r.url}");`).join(`
|
|
13
|
+
`),R=e=>!e||e.length===0?"":F.uniqBy(e,"family").map(r=>r.src.map(t=>`@font-face {
|
|
14
|
+
font-family: "${r.family}";
|
|
15
|
+
src: url("${t.url}") format("${t.format}");
|
|
16
|
+
font-display: swap;
|
|
17
|
+
${t.fontWeight?`font-weight: ${t.fontWeight};`:""}
|
|
18
|
+
${t.fontStyle?`font-style: ${t.fontStyle};`:""}
|
|
19
|
+
${t.fontStretch?`font-stretch: ${t.fontStretch};`:""}
|
|
20
|
+
}`).join(`
|
|
21
|
+
`)).join(`
|
|
22
|
+
`);exports.defaultThemeOptions=_;exports.getChaiThemeCssVariables=E;exports.getChaiThemeOptions=M;exports.getThemeCustomFontFace=R;exports.getThemeFontsCSSImport=k;exports.getThemeFontsLinkMarkup=O;exports.plugin=B;
|