@chaibuilder/sdk 3.1.7 → 3.1.9
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/{code-editor-D1w8nUwt.js → code-editor-B1G67AXy.js} +1 -1
- package/dist/{code-editor-DEY4IkBJ.cjs → code-editor-CgrS41Jk.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +4 -1
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-P7f5SEKA.cjs → css-import-modal-BLAkS06W.cjs} +2 -2
- package/dist/{css-import-modal-DK2j6oGY.js → css-import-modal-DgLi5BIu.js} +25 -25
- package/dist/{index-Cj8rTugy.js → index-Do47CY7C.js} +853 -837
- package/dist/{index-CONV5Fbc.cjs → index-kbs2fSny.cjs} +5 -5
- package/dist/{rte-widget-modal-CsOaIXCW.js → rte-widget-modal-BiZPyPF3.js} +1 -1
- package/dist/{rte-widget-modal-D_Yor38o.cjs → rte-widget-modal-CB3K6Mon.cjs} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("./index-kbs2fSny.cjs");require("lodash-es");require("clsx");require("tailwind-merge");require("tree-model");const i=require("react");require("jotai");require("@chaibuilder/runtime");require("sonner");const q=require("react-i18next"),r=require("./tooltip-C2BCZ8Al.cjs"),g=require("@react-hookz/web"),m=n=>{const s=document.createElement("div");return s.innerHTML=n,s.innerHTML};function j(){const{t:n}=q.useTranslation(),[s,h]=i.useState(!1),[a,p]=i.useState(""),[t,d]=c.useCodeEditor(),[u]=c.useSelectedBlockIds(),b=c.useUpdateBlocksProps(),f=c.useUpdateBlocksPropsRealtime(),C=g.useThrottledCallback(o=>{const l=m(o);f([t.blockId],{[t.blockProp]:l})},[],300),x=i.useCallback(()=>{if(s){const o=m(a);b([t.blockId],{[t.blockProp]:o})}},[s,a]);i.useEffect(()=>{u.includes(t==null?void 0:t.blockId)||(x(),d(null))},[u]);const k=()=>{x(),d(null)};return e.jsx(r.Dialog,{open:!0,onOpenChange:k,children:e.jsxs(r.DialogContent,{className:"flex max-h-[400px] min-h-[200px] max-w-4xl flex-col border-gray-700 text-black",children:[e.jsx(r.DialogHeader,{className:"shrink-0 border-b border-gray-700 pb-3",children:e.jsx(r.DialogTitle,{className:"flex items-center justify-between text-black",children:e.jsxs("div",{className:"space-x-3 text-sm font-semibold",children:[e.jsx("span",{children:n("HTML Code Editor |")}),e.jsx("span",{className:"text-xs text-gray-400",children:n("Scripts will be only executed in preview and live mode.")})]})})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(r.Textarea,{className:"h-full w-full resize-none font-mono text-xs",value:a||t.initialCode,onChange:o=>{const l=o.target.value;h(!0),p(l),C(l)},rows:10,placeholder:"Enter your code here..."})})]})})}exports.default=j;
|
package/dist/core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-kbs2fSny.cjs"),s=require("./common-functions-BZmyleS1.cjs"),a=require("./apply-binding-CExho6DS.cjs"),i=require("react-i18next"),l=require("i18next");exports.ChaiAddBlocksDialog=e.AddBlocksDialog;exports.ChaiAddBlocksPanel=e.AddBlocksPanel;exports.ChaiAskAiUserPrompt=e.AIUserPrompt;exports.ChaiBlockAttributesEditor=e.BlockAttributesEditor;exports.ChaiBlockPropsEditor=e.BlockSettings;exports.ChaiBlockStyleEditor=e.BlockStyling;exports.ChaiBuilderCanvas=e.CanvasArea;exports.ChaiBuilderEditor=e.ChaiBuilderEditor;exports.ChaiDarkModeSwitcher=e.DarkMode;exports.ChaiDefaultBlocks=e.DefaultChaiBlocks;exports.ChaiExportCodeModal=e.ExportCodeModal;exports.ChaiImportHTML=e.ImportHTML;exports.ChaiOutline=e.ListTree;exports.ChaiScreenSizes=e.Breakpoints;exports.ChaiThemeConfigPanel=e.ThemeConfigPanel;exports.ChaiUILibrariesPanel=e.UILibrariesPanel;exports.ChaiUndoRedo=e.UndoRedo;exports.IfChaiFeatureFlag=e.IfChaiFeatureFlag;exports.PERMISSIONS=e.PERMISSIONS;exports.getClassValueAndUnit=e.getClassValueAndUnit;exports.registerBlockSettingField=e.registerBlockSettingField;exports.registerBlockSettingTemplate=e.registerBlockSettingTemplate;exports.registerBlockSettingWidget=e.registerBlockSettingWidget;exports.registerChaiAddBlockTab=e.registerChaiAddBlockTab;exports.registerChaiFeatureFlag=e.registerChaiFeatureFlag;exports.registerChaiFeatureFlags=e.registerChaiFeatureFlags;exports.registerChaiLibrary=e.registerChaiLibrary;exports.registerChaiMediaManager=e.registerChaiMediaManager;exports.registerChaiPreImportHTMLHook=e.registerChaiPreImportHTMLHook;exports.registerChaiSaveToLibrary=e.registerChaiSaveToLibrary;exports.registerChaiSidebarPanel=e.registerChaiSidebarPanel;exports.registerChaiTopBar=e.registerChaiTopBar;exports.useAddBlock=e.useAddBlock;exports.useAddClassesToBlocks=e.useAddClassesToBlocks;exports.useAskAi=e.useAskAi;exports.useBlockHighlight=e.useBlockHighlight;exports.useBlocksHtmlForAi=e.useBlocksHtmlForAi;exports.useBlocksStore=e.useBlocksStore;exports.useBlocksStoreUndoableActions=e.useBlocksStoreUndoableActions;exports.useBrandingOptions=e.useBrandingOptions;exports.useBuilderProp=e.useBuilderProp;exports.useBuilderReset=e.useBuilderReset;exports.useCanvasDisplayWidth=e.useCanvasDisplayWidth;exports.useCanvasWidth=e.useCanvasWidth;exports.useCanvasZoom=e.useCanvasZoom;exports.useChaiFeatureFlag=e.useChaiFeatureFlag;exports.useChaiFeatureFlags=e.useChaiFeatureFlags;exports.useCodeEditor=e.useCodeEditor;exports.useCopyBlockIds=e.useCopyBlocks;exports.useCopyToClipboard=e.useCopyToClipboard;exports.useCurrentPage=e.useCurrentPage;exports.useCutBlockIds=e.useCutBlockIds;exports.useDarkMode=e.useDarkMode;exports.useDuplicateBlocks=e.useDuplicateBlocks;exports.useHighlightBlockId=e.useHighlightBlockId;exports.useHtmlToBlocks=e.useHtmlToBlocks;exports.useI18nBlocks=e.useI18nBlocks;exports.useInlineEditing=e.useInlineEditing;exports.useIsPageLoaded=e.useIsPageLoaded;exports.useLanguages=e.useLanguages;exports.useLibraryBlocks=e.useLibraryBlocks;exports.useMediaManagerComponent=e.useMediaManagerComponent;exports.usePartailBlocksStore=e.usePartialBlocksStore;exports.usePartialBlocksList=e.usePartialBlocksList;exports.usePasteBlocks=e.usePasteBlocks;exports.usePermissions=e.usePermissions;exports.usePreviewMode=e.usePreviewMode;exports.usePubSub=e.usePubSub;exports.useRemoveAllClassesForBlock=e.useRemoveAllClassesForBlock;exports.useRemoveBlocks=e.useRemoveBlocks;exports.useRemoveClassesFromBlocks=e.useRemoveClassesFromBlocks;exports.useReplaceBlock=e.useReplaceBlock;exports.useResetBlockStyles=e.useResetBlockStyles;exports.useRightPanel=e.useRightPanel;exports.useSavePage=e.useSavePage;exports.useScreenSizeWidth=e.useScreenSizeWidth;exports.useSelectedBlock=e.useSelectedBlock;exports.useSelectedBlockAllClasses=e.useSelectedBlockAllClasses;exports.useSelectedBlockCurrentClasses=e.useSelectedBlockCurrentClasses;exports.useSelectedBlockIds=e.useSelectedBlockIds;exports.useSelectedBlocksDisplayChild=e.useSelectedBlocksDisplayChild;exports.useSelectedBreakpoints=e.useSelectedBreakpoints;exports.useSelectedLibrary=e.useSelectedLibrary;exports.useSelectedStylingBlocks=e.useSelectedStylingBlocks;exports.useSidebarActivePanel=e.useSidebarActivePanel;exports.useStreamMultipleBlocksProps=e.useStreamMultipleBlocksProps;exports.useStylingBreakpoint=e.useStylingBreakpoint;exports.useStylingState=e.useStylingState;exports.useTheme=e.useTheme;exports.useThemeOptions=e.useThemeOptions;exports.useToggleChaiFeatureFlag=e.useToggleChaiFeatureFlag;exports.useUndoManager=e.useUndoManager;exports.useUpdateBlocksProps=e.useUpdateBlocksProps;exports.useUpdateBlocksPropsRealtime=e.useUpdateBlocksPropsRealtime;exports.useWrapperBlock=e.useWrapperBlock;exports.generateBlockId=s.generateUUID;exports.mergeClasses=s.cn;exports.convertHTMLToChaiBlocks=a.getBlocksFromHTML;exports.getBlocksFromHTML=a.getBlocksFromHTML;Object.defineProperty(exports,"useTranslation",{enumerable:!0,get:()=>i.useTranslation});exports.i18n=l;
|
package/dist/core.d.ts
CHANGED
|
@@ -266,6 +266,7 @@ export declare interface ChaiBuilderEditorProps {
|
|
|
266
266
|
dataBinding?: boolean;
|
|
267
267
|
importHtml?: boolean;
|
|
268
268
|
importTheme?: boolean;
|
|
269
|
+
gotoSettings?: boolean;
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
272
|
|
|
@@ -337,10 +338,12 @@ declare type ChaiLibraryConfig<T> = {
|
|
|
337
338
|
|
|
338
339
|
export declare const ChaiOutline: () => JSX.Element;
|
|
339
340
|
|
|
340
|
-
export declare const ChaiScreenSizes: ({ openDelay, canvas, tooltip, }: {
|
|
341
|
+
export declare const ChaiScreenSizes: ({ openDelay, canvas, tooltip, buttonClass, activeButtonClass, }: {
|
|
341
342
|
openDelay?: number;
|
|
342
343
|
canvas?: boolean;
|
|
343
344
|
tooltip?: boolean;
|
|
345
|
+
buttonClass?: string;
|
|
346
|
+
activeButtonClass?: string;
|
|
344
347
|
}) => JSX.Element;
|
|
345
348
|
|
|
346
349
|
export declare interface ChaiSidebarPanel {
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as e, A as o, f as i, k as l, B as r, e as t, C as u, i as c, D as d, l as C, E as B, I as k, L as n, g, T as h, U as p, h as S, y as m, P, m as F, n as A, o as T, p as M, r as b, z as y, F as I, s as v, t as L, q as f, v as R, w as E, x as H, M as D, O as U, Q as x, R as W, S as O, V as w, aB as z, W as j, X as q, Y as G, aD as V, aC as Z, Z as J, G as K, H as N, u as Q, _ as X, $ as Y, a0 as _, a1 as $, a2 as aa, a3 as sa, a4 as ea, a5 as oa, a6 as ia, a7 as la, a8 as ra, a9 as ta, aa as ua, K as ca, ab as da, ac as Ca, ad as Ba, ae as ka, af as na, ag as ga, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, aE as Ta, ao as Ma, ap as ba, aq as ya, a as Ia, ar as va, as as La, aF as fa, at as Ra, aG as Ea, au as Ha, av as Da, aw as Ua, ax as xa, ay as Wa, J as Oa, az as wa, b as za, c as ja, aA as qa } from "./index-
|
|
1
|
+
import { j as e, A as o, f as i, k as l, B as r, e as t, C as u, i as c, D as d, l as C, E as B, I as k, L as n, g, T as h, U as p, h as S, y as m, P, m as F, n as A, o as T, p as M, r as b, z as y, F as I, s as v, t as L, q as f, v as R, w as E, x as H, M as D, O as U, Q as x, R as W, S as O, V as w, aB as z, W as j, X as q, Y as G, aD as V, aC as Z, Z as J, G as K, H as N, u as Q, _ as X, $ as Y, a0 as _, a1 as $, a2 as aa, a3 as sa, a4 as ea, a5 as oa, a6 as ia, a7 as la, a8 as ra, a9 as ta, aa as ua, K as ca, ab as da, ac as Ca, ad as Ba, ae as ka, af as na, ag as ga, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, aE as Ta, ao as Ma, ap as ba, aq as ya, a as Ia, ar as va, as as La, aF as fa, at as Ra, aG as Ea, au as Ha, av as Da, aw as Ua, ax as xa, ay as Wa, J as Oa, az as wa, b as za, c as ja, aA as qa } from "./index-Do47CY7C.js";
|
|
2
2
|
import { g as Va, c as Za } from "./common-functions-BGzDsf1z.js";
|
|
3
3
|
import { h as Ka, h as Na } from "./apply-binding-w7OMcHcu.js";
|
|
4
4
|
import { useTranslation as Xa } from "react-i18next";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),w=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),w=require("react"),c=require("./tooltip-C2BCZ8Al.cjs"),T=require("culori"),V=require("@chaibuilder/runtime"),N=require("react-i18next");function $(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const S=$(w),y=$(T),f=e=>e?e%1===0?e:e.toFixed(4):"0",R=e=>`hsl(${f(e.h)} ${f(e.s*100)}% ${f(e.l*100)}%)`,E=(e,o="hsl",t="4")=>{try{const r=y.parse(e);if(!r)throw new Error("Invalid color input");switch(o){case"hsl":{const s=y.converter("hsl")(r);return t==="4"?R(s):`${f(s.h)} ${f(s.s*100)}% ${f(s.l*100)}%`}case"rgb":return y.formatRgb(r);case"oklch":{const s=y.converter("oklch")(r);return`oklch(${f(s.l)} ${f(s.c)} ${f(s.h)})`}case"hex":return y.formatHex(r);default:return e}}catch(r){return console.error(`Failed to convert color: ${e}`,r),e}},b=e=>E(e,"hex"),I=e=>{const o={fontFamily:{heading:"",body:""},borderRadius:"",colors:{}};try{const t=F(e);if(!t.isValid)return console.warn("CSS validation failed:",t.error),k();const r=C(e,":root"),s=C(e,".dark"),l=m(r,"--font-sans")||m(r,"--font-family")||m(r,"--font-heading")||m(r,"--font-body"),a=D(l);o.fontFamily={heading:a,body:a};const u=m(r,"--radius")||m(r,"--border-radius")||"0.5rem";o.borderRadius=P(u),["background","foreground","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","destructive","destructive-foreground","border","input","ring","card","card-foreground","popover","popover-foreground"].forEach(i=>{const p=m(r,`--${i}`),g=m(s,`--${i}`);if(p||g){const d=p?v(p):"#000000",x=g?v(g):d;o.colors[i]=[d,x]}})}catch(t){return console.error("Error parsing CSS to ChaiThemeValues:",t),k()}return o},C=(e,o)=>{var r,s;const t=new RegExp(`${j(o)}\\s*{([^}]+)}`);return((s=(r=e.match(t))==null?void 0:r[1])==null?void 0:s.trim())||null},m=(e,o)=>{var s;if(!e)return null;const t=new RegExp(`${j(o)}\\s*:\\s*([^;]+)`),r=e.match(t);return((s=r==null?void 0:r[1])==null?void 0:s.trim())||null},v=e=>{if(!e||typeof e!="string")return"#000000";try{const o=e.replace(/var\([^)]+\)/g,"").trim();if(!o)return"#000000";if(/^[a-z]+$/i.test(o))return b(o)||"#000000";if(/^#?([0-9A-F]{3,4}|[0-9A-F]{6}|[0-9A-F]{8})$/i.test(o.replace(/#/g,""))){const r=o.startsWith("#")?o:`#${o}`;return r.length<=5?`#${r.slice(1).split("").map(s=>s+s).join("")}`.slice(0,7):r.length>7?r.slice(0,7):r}if(/^(rgb|hsl|oklch)a?\(/i.test(o))return b(o)||"#000000";const t=o.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);if(t){const[r,s,l,a]=t,u=`hsl(${s} ${l}% ${a}%)`;return b(u)||"#000000"}if(/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(o)){const r=o.split(/[\s,]+/).filter(Boolean);if(r.length>=3){const l=r.some(a=>a.includes("%"))?`hsl(${r[0]} ${r[1]} ${r[2]})`:`rgb(${r[0]}, ${r[1]}, ${r[2]})`;return b(l)||"#000000"}}return b(o)||"#000000"}catch(o){return console.warn("Failed to process color:",e,o),"#000000"}},D=e=>{const o=V.getAllRegisteredFonts();if(!e)return"ui-sans-serif, system-ui, sans-serif";try{const r=e.replace(/["']/g,"").trim().split(",")[0].trim(),s=o.find(l=>l.family.toLowerCase()===r.toLowerCase());return(s==null?void 0:s.family)||"ui-sans-serif, system-ui, sans-serif"}catch(t){return console.warn("Error processing font family:",e,t),"ui-sans-serif, system-ui, sans-serif"}},P=e=>{if(!e)return"8px";try{const o=e.trim();if(o.endsWith("px"))return o;if(o.endsWith("rem")){const r=parseFloat(o.replace("rem",""));if(!isNaN(r))return`${Math.round(r*16)}px`}if(o.endsWith("em")){const r=parseFloat(o.replace("em",""));if(!isNaN(r))return`${Math.round(r*16)}px`}const t=parseFloat(o);return isNaN(t)?"8px":`${Math.round(t)}px`}catch(o){return console.warn("Error converting border radius to px:",e,o),"8px"}},k=()=>({fontFamily:{heading:"ui-sans-serif, system-ui, sans-serif",body:"ui-sans-serif, system-ui, sans-serif"},borderRadius:"8px",colors:{background:["#ffffff","#000000"],foreground:["#000000","#ffffff"],primary:["#3b82f6","#60a5fa"],"primary-foreground":["#ffffff","#1e293b"],secondary:["#f1f5f9","#334155"],"secondary-foreground":["#0f172a","#f8fafc"],muted:["#f8fafc","#1e293b"],"muted-foreground":["#64748b","#94a3b8"],accent:["#f1f5f9","#334155"],"accent-foreground":["#0f172a","#f8fafc"],destructive:["#ef4444","#f87171"],"destructive-foreground":["#ffffff","#1e293b"],border:["#e2e8f0","#475569"],input:["#e2e8f0","#475569"],ring:["#3b82f6","#60a5fa"],card:["#ffffff","#0f172a"],"card-foreground":["#000000","#f8fafc"],popover:["#ffffff","#0f172a"],"popover-foreground":["#000000","#f8fafc"]}}),j=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),q=e=>["background","foreground","primary","primary-foreground"].every(r=>e.colors[r]&&Array.isArray(e.colors[r])&&e.colors[r].length>=2)&&!!e.fontFamily.heading&&!!e.fontFamily.body&&!!e.borderRadius,F=e=>{if(!e||typeof e!="string")return{isValid:!1,error:"Please enter valid CSS content"};const o=e.trim();if(!o)return{isValid:!1,error:"Please enter CSS content"};try{if(!o.includes("{")||!o.includes("}"))return{isValid:!1,error:"Invalid CSS format. CSS should contain proper block structure with { }"};const t=(o.match(/{/g)||[]).length,r=(o.match(/}/g)||[]).length;return t!==r?{isValid:!1,error:"Invalid CSS format. Unmatched braces detected"}:!o.includes("--")||!o.includes(":")?{isValid:!1,error:"Invalid CSS format. CSS should contain variable definitions like --primary: #color"}:!o.includes(":root")&&!o.includes(".dark")?{isValid:!1,error:"CSS should contain at least :root or .dark selector with theme variables"}:{isValid:!0}}catch(t){return console.error("CSS validation error:",t),{isValid:!1,error:"Failed to parse CSS. Please check your syntax."}}},M=`:root {
|
|
2
2
|
--background: 0 0% 100%;
|
|
3
3
|
--foreground: oklch(0.52 0.13 144.17);
|
|
4
4
|
--primary: #3e2723;
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
--foreground: hsl(37.50 36.36% 95.69%);
|
|
11
11
|
--primary: rgb(46, 125, 50);
|
|
12
12
|
--primary-foreground: #ffffff;
|
|
13
|
-
}`,_=({open:e,onOpenChange:o,onImport:t})=>{const[r,s]=S.useState(""),[
|
|
13
|
+
}`,_=({open:e,onOpenChange:o,onImport:t})=>{const[r,s]=S.useState(""),[l,a]=S.useState(null),[u,h]=S.useState(!1),{t:i}=N.useTranslation(),p=async()=>{h(!0),a(null);try{const d=F(r);if(!d.isValid){a(d.error||i("Invalid CSS format")),setTimeout(()=>{a(null)},5e3),h(!1);return}const x=I(r);if(!q(x)){a(i("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors.")),setTimeout(()=>{a(null)},5e3),h(!1);return}t(x),s(""),a(null),o(!1)}catch(d){console.error("Error importing CSS:",d),a(i("Failed to parse CSS. Please check your syntax and try again.")),setTimeout(()=>{a(null)},5e3)}finally{h(!1)}},g=()=>{s(""),a(null),o(!1)};return n.jsx(c.Dialog,{open:e,onOpenChange:o,children:n.jsxs(c.DialogContent,{className:"flex max-h-[80vh] max-w-2xl flex-col",children:[n.jsxs(c.DialogHeader,{children:[n.jsx(c.DialogTitle,{children:i("Import CSS Theme")}),n.jsxs(c.DialogDescription,{className:"space-y-2",children:[n.jsx("p",{children:i("Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties.")}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("p",{className:"font-bold",children:"Get theme resources:"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://tweakcn.com/","_blank"),children:"TweakCN"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://ui.shadcn.com/themes#themes","_blank"),children:"shadcn/ui Themes"}),n.jsx(c.Button,{variant:"link",size:"sm",onClick:()=>window.open("https://zippystarter.com/tools/shadcn-ui-theme-generator","_blank"),children:"ZippyStarter"})]})]})]}),n.jsxs("div",{className:"flex-1 space-y-4 overflow-hidden",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(c.Label,{htmlFor:"css-input",children:i("CSS Variables")}),n.jsx(c.Textarea,{id:"css-input",placeholder:M,value:r,onChange:d=>s(d.target.value),className:"min-h-[300px] resize-none font-mono text-sm",disabled:u})]}),l&&n.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 p-3",children:n.jsx("p",{className:"text-sm text-red-600",children:l})})]}),n.jsxs(c.DialogFooter,{className:"gap-2",children:[n.jsx(c.Button,{variant:"outline",onClick:g,disabled:u,children:i("Cancel")}),n.jsx(c.Button,{onClick:p,disabled:!r.trim()||u,children:i(u?"Importing...":"Import Theme")})]})]})})};exports.CssImportModal=_;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import * as x from "react";
|
|
3
3
|
import { a1 as V, a3 as T, a6 as N, a9 as R, a4 as E, v as y, au as I, b1 as D, a5 as A } from "./tooltip-4-b9QGDK.js";
|
|
4
4
|
import * as b from "culori";
|
|
@@ -40,7 +40,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
40
40
|
const s = w(o);
|
|
41
41
|
if (!s.isValid)
|
|
42
42
|
return console.warn("CSS validation failed:", s.error), $();
|
|
43
|
-
const r = v(o, ":root"), t = v(o, ".dark"),
|
|
43
|
+
const r = v(o, ":root"), t = v(o, ".dark"), l = u(r, "--font-sans") || u(r, "--font-family") || u(r, "--font-heading") || u(r, "--font-body"), n = B(l);
|
|
44
44
|
e.fontFamily = {
|
|
45
45
|
heading: n,
|
|
46
46
|
body: n
|
|
@@ -66,11 +66,11 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
66
66
|
"card-foreground",
|
|
67
67
|
"popover",
|
|
68
68
|
"popover-foreground"
|
|
69
|
-
].forEach((
|
|
70
|
-
const p = u(r, `--${
|
|
69
|
+
].forEach((a) => {
|
|
70
|
+
const p = u(r, `--${a}`), g = u(t, `--${a}`);
|
|
71
71
|
if (p || g) {
|
|
72
72
|
const c = p ? k(p) : "#000000", C = g ? k(g) : c;
|
|
73
|
-
e.colors[
|
|
73
|
+
e.colors[a] = [c, C];
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
} catch (s) {
|
|
@@ -102,14 +102,14 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
102
102
|
return S(e) || "#000000";
|
|
103
103
|
const s = e.match(/^(\d+\.?\d*)\s+(\d+\.?\d*)%\s+(\d+\.?\d*)%$/);
|
|
104
104
|
if (s) {
|
|
105
|
-
const [r, t,
|
|
105
|
+
const [r, t, l, n] = s, f = `hsl(${t} ${l}% ${n}%)`;
|
|
106
106
|
return S(f) || "#000000";
|
|
107
107
|
}
|
|
108
108
|
if (/^[\d.]+[\s,]+[\d.]+[\s,]+[\d.]+(?:[\s,/]+[\d.]+)?$/.test(e)) {
|
|
109
109
|
const r = e.split(/[\s,]+/).filter(Boolean);
|
|
110
110
|
if (r.length >= 3) {
|
|
111
|
-
const
|
|
112
|
-
return S(
|
|
111
|
+
const l = r.some((n) => n.includes("%")) ? `hsl(${r[0]} ${r[1]} ${r[2]})` : `rgb(${r[0]}, ${r[1]}, ${r[2]})`;
|
|
112
|
+
return S(l) || "#000000";
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
return S(e) || "#000000";
|
|
@@ -121,7 +121,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
121
121
|
if (!o)
|
|
122
122
|
return "ui-sans-serif, system-ui, sans-serif";
|
|
123
123
|
try {
|
|
124
|
-
const r = o.replace(/["']/g, "").trim().split(",")[0].trim(), t = e.find((
|
|
124
|
+
const r = o.replace(/["']/g, "").trim().split(",")[0].trim(), t = e.find((l) => l.family.toLowerCase() === r.toLowerCase());
|
|
125
125
|
return (t == null ? void 0 : t.family) || "ui-sans-serif, system-ui, sans-serif";
|
|
126
126
|
} catch (s) {
|
|
127
127
|
return console.warn("Error processing font family:", o, s), "ui-sans-serif, system-ui, sans-serif";
|
|
@@ -216,12 +216,12 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
216
216
|
--primary: rgb(46, 125, 50);
|
|
217
217
|
--primary-foreground: #ffffff;
|
|
218
218
|
}`, Z = ({ open: o, onOpenChange: e, onImport: s }) => {
|
|
219
|
-
const [r, t] = x.useState(""), [
|
|
219
|
+
const [r, t] = x.useState(""), [l, n] = x.useState(null), [f, h] = x.useState(!1), { t: a } = H(), p = async () => {
|
|
220
220
|
h(!0), n(null);
|
|
221
221
|
try {
|
|
222
222
|
const c = w(r);
|
|
223
223
|
if (!c.isValid) {
|
|
224
|
-
n(c.error || "Invalid CSS format"), setTimeout(() => {
|
|
224
|
+
n(c.error || a("Invalid CSS format")), setTimeout(() => {
|
|
225
225
|
n(null);
|
|
226
226
|
}, 5e3), h(!1);
|
|
227
227
|
return;
|
|
@@ -229,7 +229,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
229
229
|
const C = z(r);
|
|
230
230
|
if (!q(C)) {
|
|
231
231
|
n(
|
|
232
|
-
"The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors."
|
|
232
|
+
a("The CSS doesn't contain enough theme information. Please ensure it includes at least background, foreground, primary, and primary-foreground colors.")
|
|
233
233
|
), setTimeout(() => {
|
|
234
234
|
n(null);
|
|
235
235
|
}, 5e3), h(!1);
|
|
@@ -237,7 +237,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
237
237
|
}
|
|
238
238
|
s(C), t(""), n(null), e(!1);
|
|
239
239
|
} catch (c) {
|
|
240
|
-
console.error("Error importing CSS:", c), n("Failed to parse CSS. Please check your syntax and try again."), setTimeout(() => {
|
|
240
|
+
console.error("Error importing CSS:", c), n(a("Failed to parse CSS. Please check your syntax and try again.")), setTimeout(() => {
|
|
241
241
|
n(null);
|
|
242
242
|
}, 5e3);
|
|
243
243
|
} finally {
|
|
@@ -246,17 +246,17 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
246
246
|
}, g = () => {
|
|
247
247
|
t(""), n(null), e(!1);
|
|
248
248
|
};
|
|
249
|
-
return /* @__PURE__ */
|
|
249
|
+
return /* @__PURE__ */ i(V, { open: o, onOpenChange: e, children: /* @__PURE__ */ m(T, { className: "flex max-h-[80vh] max-w-2xl flex-col", children: [
|
|
250
250
|
/* @__PURE__ */ m(N, { children: [
|
|
251
|
-
/* @__PURE__ */
|
|
251
|
+
/* @__PURE__ */ i(R, { children: a("Import CSS Theme") }),
|
|
252
252
|
/* @__PURE__ */ m(E, { className: "space-y-2", children: [
|
|
253
|
-
/* @__PURE__ */
|
|
253
|
+
/* @__PURE__ */ i("p", { children: a(
|
|
254
254
|
"Paste your CSS variables to import a custom theme. The CSS should contain :root and .dark blocks with CSS custom properties."
|
|
255
255
|
) }),
|
|
256
256
|
/* @__PURE__ */ m("div", { className: "flex items-center", children: [
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
-
/* @__PURE__ */
|
|
259
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ i("p", { className: "font-bold", children: "Get theme resources:" }),
|
|
258
|
+
/* @__PURE__ */ i(y, { variant: "link", size: "sm", onClick: () => window.open("https://tweakcn.com/", "_blank"), children: "TweakCN" }),
|
|
259
|
+
/* @__PURE__ */ i(
|
|
260
260
|
y,
|
|
261
261
|
{
|
|
262
262
|
variant: "link",
|
|
@@ -265,7 +265,7 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
265
265
|
children: "shadcn/ui Themes"
|
|
266
266
|
}
|
|
267
267
|
),
|
|
268
|
-
/* @__PURE__ */
|
|
268
|
+
/* @__PURE__ */ i(
|
|
269
269
|
y,
|
|
270
270
|
{
|
|
271
271
|
variant: "link",
|
|
@@ -279,8 +279,8 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
279
279
|
] }),
|
|
280
280
|
/* @__PURE__ */ m("div", { className: "flex-1 space-y-4 overflow-hidden", children: [
|
|
281
281
|
/* @__PURE__ */ m("div", { className: "space-y-2", children: [
|
|
282
|
-
/* @__PURE__ */
|
|
283
|
-
/* @__PURE__ */
|
|
282
|
+
/* @__PURE__ */ i(I, { htmlFor: "css-input", children: a("CSS Variables") }),
|
|
283
|
+
/* @__PURE__ */ i(
|
|
284
284
|
D,
|
|
285
285
|
{
|
|
286
286
|
id: "css-input",
|
|
@@ -292,11 +292,11 @@ const d = (o) => o ? o % 1 === 0 ? o : o.toFixed(4) : "0", L = (o) => `hsl(${d(o
|
|
|
292
292
|
}
|
|
293
293
|
)
|
|
294
294
|
] }),
|
|
295
|
-
|
|
295
|
+
l && /* @__PURE__ */ i("div", { className: "rounded-md border border-red-200 bg-red-50 p-3", children: /* @__PURE__ */ i("p", { className: "text-sm text-red-600", children: l }) })
|
|
296
296
|
] }),
|
|
297
297
|
/* @__PURE__ */ m(A, { className: "gap-2", children: [
|
|
298
|
-
/* @__PURE__ */
|
|
299
|
-
/* @__PURE__ */
|
|
298
|
+
/* @__PURE__ */ i(y, { variant: "outline", onClick: g, disabled: f, children: a("Cancel") }),
|
|
299
|
+
/* @__PURE__ */ i(y, { onClick: p, disabled: !r.trim() || f, children: a(f ? "Importing..." : "Import Theme") })
|
|
300
300
|
] })
|
|
301
301
|
] }) });
|
|
302
302
|
};
|