@chaibuilder/sdk 3.1.26 → 3.1.28
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/{IconPicker-CluS-5Mv.js → IconPicker-6JSublJp.js} +1 -1
- package/dist/{IconPicker-BWE43eMO.cjs → IconPicker-DpQQDK_Q.cjs} +1 -1
- package/dist/{apply-binding-COFSiTeM.js → apply-binding-BwPhgnhk.js} +326 -198
- package/dist/apply-binding-Dblf6wMG.cjs +1 -0
- package/dist/{code-display-BOOy3Lpy.js → code-display-DuH-UOhl.js} +1 -1
- package/dist/{code-display-B1O2gN5f.cjs → code-display-Dw1tAwiJ.cjs} +1 -1
- package/dist/code-editor-DosOD_MJ.cjs +1 -0
- package/dist/{code-editor-TDs5CPAW.js → code-editor-W1Kvc_mp.js} +6 -5
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +13 -2
- package/dist/core.js +3 -3
- package/dist/{css-import-modal-sHoiyimv.js → css-import-modal-CFB2YjDT.js} +1 -1
- package/dist/{css-import-modal-CrlmcFy4.cjs → css-import-modal-bGWZSlqv.cjs} +1 -1
- package/dist/{index-DFvi9z_N.js → index-hrVqQhCa.js} +2853 -2530
- package/dist/index-tOL3lzGY.cjs +154 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +9 -0
- package/dist/render.js +69 -66
- package/dist/{rte-widget-modal-DX07GFaV.cjs → rte-widget-modal-BFwz3uU8.cjs} +1 -1
- package/dist/{rte-widget-modal-3KfJEwf3.js → rte-widget-modal-DioHGWr7.js} +2 -2
- package/dist/{tooltip-CzZ7Fvt7.cjs → tooltip-Ba1-8jmj.cjs} +1 -1
- package/dist/{tooltip-Bz2MxMHf.js → tooltip-DUosa-uC.js} +83 -83
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +14 -14
- package/dist/ui.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +1 -1
- package/package.json +3 -2
- package/dist/apply-binding-Dvnd_Vhq.cjs +0 -1
- package/dist/code-editor-B7JGUrWa.cjs +0 -1
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/index-C4b6LcwL.cjs +0 -154
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const T=require("./common-functions-B3a4xKt_.cjs"),e=require("lodash-es"),k=require("himalaya"),J=require("@chaibuilder/runtime"),z=require("tailwind-merge"),m="#styles:",U="__ADD_BLOCK_INTERNAL_ROOT",Y="@",q="#",V=t=>{if(t=t.replace(m,""),!t)return{baseClasses:"",classes:""};const l=t.split(/,(?![^\[]*\])/);if(l.length===1)return{baseClasses:"",classes:l[0].trim()};const[n,...s]=l;return{baseClasses:n.trim(),classes:s.join(",").trim().replace(/ +(?= )/g,"")}},K=t=>{const l=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,n=/(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;return l.test(t)||n.test(t)},X=t=>{if(e.isEmpty(t))return t;const l=/<video[^>]+src=['"]([^'">]+)['"]/,n=/<iframe[^>]+src=['"]([^'">]+)['"]/,s=t.match(l),a=t.match(n),i=s?s[1]:a?a[1]:null,o=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/,r=/(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;return i&&(o.test(i)||r.test(i))?i:t},H=["chai-name","data-chai-name"],Z={img:{alt:"alt",width:"width",height:"height",src:"image"},video:{src:"url",autoplay:"controls.autoPlay",muted:"controls.muted",loop:"controls.loop",controls:"controls.widgets"},a:{href:"link.href",target:"link.target",type:""},input:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},textarea:{placeholder:"placeholder",required:"required",type:"inputType",name:"fieldName"},select:{placeholder:"placeholder",required:"required",multiple:"multiple",name:"fieldName"},form:{action:"action"}},G=(t,l)=>t.children.length===1&&e.includes(["Heading","Paragraph","Span","ListItem","Button","Label","TableCell","Link","RichText"],l._type),v=t=>t.map(l=>l.type==="text"?e.get(l,"content",""):e.isEmpty(l.children)?"":v(l.children)).join(""),B=t=>t===null?"":t,M=t=>{const l=e.compact(e.map(t.split(/\s+/),e.trim)),n=e.find(l,r=>/^w-/.test(r)),s=e.find(l,r=>/^h-/.test(r));if(!s||!n)return{height:"",width:""};const a=r=>{if(!r)return;const y=r.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);if(!y)return;if(y[1])return y[1];const c=y[2];return/^\d+(\.\d+)?$/.test(c)?`${Number(c)*4}px`:c==="auto"||e.includes(c,"%")?c:"16px"},i=a(n),o=a(s);return{width:e.includes(i,"px")?i:"16px",height:e.includes(o,"px")?o:"16px"}},j=t=>{if(t.tagName==="svg")return{};const l={},n=Z[t.tagName]||{},s=t.attributes;return e.forEach(s,({key:a,value:i})=>{if(!e.includes(H,a))if(a==="bid"&&(l._bid=B(i)),n[a]){if(t.tagName==="img"&&a==="src"&&!i.startsWith("http")){const o=e.find(t.attributes,{key:"width"}),r=e.find(t.attributes,{key:"height"});o&&r?i=`https://picsum.photos/${o==null?void 0:o.value}x${r==null?void 0:r.value}`:i="https://picsum.photos/150x150"}e.set(l,n[a],B(i))}else e.includes(["style","class","srcset","bid"],a)||(e.has(l,"styles_attrs")||(l.styles_attrs={}),e.startsWith(a,"@")&&(a=a.replace("@","x-on:")),l.styles_attrs[`${a}`]=B(i))}),delete l.class,l},Q=(t,l="styles")=>{if(!t.attributes)return{[l]:`${m},`};const n=e.find(t.attributes,{key:"class"});if(n){const s=n.value;return{[l]:`${m},${s}`}}return{[l]:`${m},`}},ee=t=>{const l=e.get(t,"attributes",[]),n=l.find(c=>c.key==="data-chai-richtext"||c.key==="chai-richtext"),s=l.find(c=>c.key==="data-chai-lightbox"||c.key==="chai-lightbox"),a=l.find(c=>c.key==="data-chai-dropdown"||c.key==="chai-dropdown"),i=l.find(c=>c.key==="data-chai-dropdown-button"||c.key==="chai-dropdown-button"),o=l.find(c=>c.key==="data-chai-dropdown-content"||c.key==="chai-dropdown-content"),r=l.find(c=>c.key==="class"),y=r&&r.value.split(/\s+/).includes("rte");if(a)return{_type:"Dropdown"};if(i)return{_type:"DropdownButton"};if(o)return{_type:"DropdownContent"};if(n||y)return{_type:"Paragraph"};if(s)return{_type:"LightBoxLink"};switch(t.tagName){case"img":return{_type:"Image"};case"input":return{_type:"Input",showLabel:!1};case"hr":return{_type:"Divider"};case"br":return{_type:"LineBreak"};case"textarea":return{_type:"TextArea",showLabel:!1};case"audio":return{_type:"Audio"};case"canvas":return{_type:"Canvas"};case"video":case"iframe":return{_type:"CustomHTML"};case"svg":return{_type:"Icon"};case"select":return{_type:"Select",options:[]};case"option":return{_type:"Option"};case"ul":case"ol":case"dl":return{_type:"List",tag:t.tagName,_listType:t.tagName==="ol"?"list-decimal":"list-none"};case"li":case"dt":return{_type:"ListItem",tag:t.tagName};case"span":case"figcaption":case"legend":return{_type:"Span",tag:t.tagName};case"p":return{_type:"Paragraph",content:""};case"a":return{_type:"Link"};case"form":return{_type:"Form"};case"label":return{_type:"Label"};case"button":return{_type:"Button"};case"code":return{_type:"Box",_name:"Code"};case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return{_type:"Heading",tag:t.tagName};case"table":return{_type:"Table"};case"tr":return{_type:"TableRow"};case"td":case"th":return{_type:"TableCell",tag:t.tagName};case"thead":return{_type:"TableHead"};case"tbody":return{_type:"TableBody"};case"tfoot":return{_type:"TableFooter"};default:{const c=e.get(t,"children",[]).length>0?"Box":"EmptyBox";return{_type:c,tag:t.tagName,_name:c=="EmptyBox"||t.tagName==="div"?c:e.capitalize(t.tagName)}}}},E=(t,l=null)=>e.flatMapDeep(t,n=>{var S,D,C,I,$,N,L,W,A,P;if(n.type==="comment")return[];let s={_id:T.generateUUID()};if(l&&(s._parent=l.block._id),n.type==="text")return e.isEmpty(e.get(n,"content",""))?[]:l&&G(l.node,l.block)?(e.set(l,"block.content",e.get(n,"content","")),[]):{...s,_type:"Text",content:e.get(n,"content","")};if(e.startsWith(n.tagName,"chai-")){const p=n.attributes,u=e.find(p,{key:"chai-type"}),d=(u==null?void 0:u.value)||e.startCase(n.tagName.replace("chai-","")).replace(/\s+/g,"");s._type=d,e.forEach(p,({key:h,value:R})=>{if(h==="about-this-component"||h==="chai-type"||h==="can-move"||h==="can-delete")return;if(h==="id"){s._id=R;return}const F=e.startsWith(h,"_")?h:e.camelCase(h);let f=B(R);typeof f=="string"&&e.startsWith(f,"#styles:")&&(f=f.replace("#styles:","#styles:,")),s[F]=f});const g=E(n.children,{block:s,node:n});return[s,...g]}const a=e.get(n,"attributes",[]),i=a.find(p=>p.key==="data-chai-richtext"||p.key==="chai-richtext"),o=a.find(p=>p.key==="class"),r=o&&o.value.split(/\s+/).includes("rte"),y=a.find(p=>p.key==="data-chai-lightbox"||p.key==="chai-lightbox"),c=a.find(p=>p.key==="data-chai-dropdown"||p.key==="chai-dropdown"),b=a.find(p=>p.key==="data-chai-dropdown-button"||p.key==="chai-dropdown-button"),_=a.find(p=>p.key==="data-chai-dropdown-content"||p.key==="chai-dropdown-content");if(s={...s,...ee(n),...j(n),...Q(n)},n.attributes){const p=n.attributes.find(u=>e.includes(H,u.key));p&&(s._name=p.value)}if(i||r)return s.content=k.stringify(n.children),e.has(s,"styles_attrs.data-chai-richtext")&&delete s.styles_attrs["data-chai-richtext"],e.has(s,"styles_attrs.chai-richtext")&&delete s.styles_attrs["chai-richtext"],[s];if(y){const p=["data-chai-lightbox","chai-lightbox","data-vbtype","data-autoplay","data-maxwidth","data-overlay","data-gall","href"];s={...s,href:((S=a.find(u=>u.key==="href"))==null?void 0:S.value)||"",hrefType:((D=a.find(u=>u.key==="data-vbtype"))==null?void 0:D.value)||"video",autoplay:((C=a.find(u=>u.key==="data-autoplay"))==null?void 0:C.value)==="true"?"true":"false",maxWidth:(($=(I=a.find(u=>u.key==="data-maxwidth"))==null?void 0:I.value)==null?void 0:$.replace("px",""))||"",backdropColor:((N=a.find(u=>u.key==="data-overlay"))==null?void 0:N.value)||"",galleryName:((L=a.find(u=>u.key==="data-gall"))==null?void 0:L.value)||""},e.forEach(p,u=>{e.has(s,`styles_attrs.${u}`)&&delete s.styles_attrs[u]})}if(c&&(delete s.styles_attrs,s.showDropdown=!1),_&&delete s.styles_attrs,b){delete s.styles_attrs;const p=e.filter(n.children||[],d=>(d==null?void 0:d.tagName)!=="span");s.content=v(p);const u=e.find(n.children||[],d=>(d==null?void 0:d.tagName)==="span"&&e.some(d.children||[],g=>(g==null?void 0:g.tagName)==="svg"));if(u){const d=e.find(u.children||[],g=>(g==null?void 0:g.tagName)==="svg");if(d){s.icon=k.stringify([d]);const{height:g,width:h}=te(d,"16px","16px");s.iconHeight=g,s.iconWidth=h}}return[s]}if(s._type==="Input"){const p=s.inputType||"text";p==="checkbox"?e.set(s,"_type","Checkbox"):p==="radio"&&e.set(s,"_type","Radio")}else if(n.tagName==="video"||n.tagName==="iframe"){const p=k.stringify([n]);return K(p)&&(e.set(s,"_type","Video"),e.set(s,"url",X(p)),e.set(s,"styles",`${m},`),e.set(s,"controls",{autoPlay:!1,muted:!0,loop:!1,controls:!1})),s.content=p,[s]}else if(n.tagName==="svg"){const p=e.get(e.find(n.attributes,{key:"class"}),"value",""),{height:u,width:d}=M(p);if(u&&d)s.styles=`${m}, ${T.cn(`w-${d} h-${u}`,p)}`.trim(),s.height=u==null?void 0:u.replace("px",""),s.width=d==null?void 0:d.replace("px","");else{const g=(W=e.find(n.attributes,{key:"height"}))==null?void 0:W.value,h=(A=e.find(n.attributes,{key:"width"}))==null?void 0:A.value;g&&h?(s.styles=`${m}, ${T.cn(`w-[${h}px] h-[${g}px]`,p)}`.trim(),s.height=g,s.width=h):s.styles=`${m}, ${T.cn("w-full h-full",p)}`.trim()}return n.attributes=e.filter(n.attributes,g=>!e.includes(["style","width","height","class"],g.key)),s.icon=k.stringify([n]),[s]}else if(n.tagName=="option"&&l&&((P=l.block)==null?void 0:P._type)==="Select")return l.block.options.push({label:v(n.children),...j(n)}),[];const x=E(n.children,{block:s,node:n});return[s,...x]}),te=(t,l,n)=>{var y,c;const s=e.get(t,"attributes",[]),{height:a,width:i}=M(e.get(e.find(s,{key:"class"}),"value",""));if(a&&i)return{height:`[${a}px]`,width:`[${i}px]`};const o=(y=e.find(s,{key:"height"}))==null?void 0:y.value,r=(c=e.find(s,{key:"width"}))==null?void 0:c.value;return{height:o?`[${o}px]`:n,width:r?`[${r}px]`:l}},se=t=>{t=t.replace(/(\w+)=\\?"(.*?)\\?"/g,(s,a,i)=>{let o=i.replace(/\\"/g,'"');return o=o.replace(/{([^}]+)}/g,r=>r.replace(/"/g,'\\"')),`${a}="${o.replace(/\\"/g,'"')}"`}),t=t.replace(/\\n/g,"").replace(/\\\\/g,"").replace(/\\([/<>])/g,"$1").replace(/\\./g,"").replace(/[\n\r\t\f\v]/g,""),t=t.replace(/\$name="[^"]*"/g,"");const l=t.match(/<body[^>]*>[\s\S]*?<\/body>/);return(l&&l.length>0?l[0].replace(/<body/,"<div").replace(/<\/body>/,"</div>"):t).replace(/\s+/g," ").replaceAll("> <","><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").trim()},ne=(t,l)=>e.find(t,{_id:l}),ae=(t,l)=>e.isEmpty(l)?t.map(n=>(e.unset(n,"_bid"),n)):e.map(t,n=>{const s=e.isEmpty(n._bid)?void 0:ne(l,n._bid);if(s){s._type==="Icon"&&e.get(n,"icon","").match(/chai-default-svg/)&&delete n.icon;const a={...s,...n};return e.unset(a,"_bid"),a}return e.unset(n,"_bid"),n}),le=t=>{const l=k.parse(se(t));return e.isEmpty(t)?[]:e.flatten(E(l))};function ie(t,l,n){const s=e.get(n,"i18nProps",[]);if(e.isEmpty(l)||e.isEmpty(s))return t;const a=e.cloneDeep(t);return e.forEach(e.keys(a),i=>{if(e.includes(s,i)&&!e.isEmpty(l)){const o=e.get(a,i),r=e.get(a,`${i}-${l}`,"");e.isString(o)?a[i]=e.isString(r)&&!e.isEmpty(r.trim())&&r.trimStart()||o:a[i]=e.isEmpty(r)?o:r}}),a}const O=(t,l)=>{const{baseClasses:n,classes:s}=V(t),i=s.split(" ").filter(r=>r.startsWith("dt-")).map(r=>{var y;return(y=l[r.replace("dt-","")])==null?void 0:y.value}),o=s.split(" ").filter(r=>!r.startsWith("dt-")).join(" ");return z.twMerge.apply(null,[n,...i,o])};function oe(t,l){return e.get(t,`${l}_attrs`,{})}function re(t,l=!0,n={}){const s={};return Object.keys(t).forEach(a=>{if(e.isString(t[a])&&t[a].startsWith(m)){const i=O(t[a],n),o=oe(t,a);s[a]={...!e.isEmpty(i)&&{className:i},...o,...l?{"data-style-prop":a,"data-block-parent":t._id,"data-style-id":`${a}-${t._id}`}:{}}}}),s}const ce=e.memoize(t=>{const l=J.getRegisteredChaiBlock(t),n=e.get(l,"schema.properties",{});return Object.fromEntries(Object.entries(n).filter(([,s])=>e.get(s,"runtime",!1)))}),pe=(t,l)=>{if(!e.isArray(t))return t;let n=t,s;return typeof l.limit=="number"&&l.limit>0&&(s=l.limit),s!==void 0&&(n=n.slice(0,s)),n},ue=(t,l)=>{const n=e.cloneDeep(t);return e.forEach(e.keys(n),s=>{if(e.isString(n[s])&&!e.startsWith(s,"_")){let a=n[s];s==="repeaterItems"&&(n.repeaterItemsBinding=a);const i=/\{\{(.*?)\}\}/g,o=a.match(i);o&&o.forEach(r=>{let y=r.slice(2,-2);const c=e.get(l,y,r);a=e.isArray(c)?c:a.replace(r,c)}),n[s]=a}}),n},de=(t,l)=>t.map(n=>{const s=e.keys(n).filter(a=>e.isString(n[a])&&n[a].startsWith(m));return e.each(s,a=>{n[a]=`${m},${O(n[a],l)}`}),n}),ye=t=>{const l=e.last(t);return t.map(n=>{const s=Object.keys(n);for(let a=0;a<s.length;a++)if(e.isString(n[s[a]])&&e.startsWith(s[a],"content")){const i=n===l?"":" ";n[s[a]]=`${n[s[a]].trim()}${i}`}return n})},w=(t,l,{index:n,key:s},a)=>{if(e.isString(t)){let i=t;const o=/\{\{(.*?)\}\}/g,r=t.match(o);if(r){const y=a==="image"||a==="mobileImage";r.forEach(c=>{let b=c.slice(2,-2).trim(),_=s.slice(2,-2).trim();n!==-1&&e.startsWith(b,"$index.")?b=`${_}.${n}.${b.slice(7)}`:n!==-1&&e.startsWith(b,"$index")&&(b=`${_}.${n}`);const x=e.get(l,b);x===void 0?i=i.replace(c,""):y&&!e.isArray(x)?i=x:i=e.isArray(x)?x:i.replace(c,x)})}return i}if(e.isArray(t))return t.map(i=>w(i,l,{index:n,key:s},a));if(t&&typeof t=="object"){const i={};return e.forEach(e.keys(t),o=>{!e.startsWith(o,"_")&&o!=="$repeaterItemsKey"?i[o]=w(t[o],l,{index:n,key:s},o):i[o]=t[o]}),i}return t},ge=(t,l,{index:n,key:s})=>{let a=e.cloneDeep(t);return a.repeaterItems&&(a.$repeaterItemsKey=a.repeaterItems,e.startsWith(a.repeaterItems,`{{${q}`)&&(a.$repeaterItemsKey=a.repeaterItems=`${a.repeaterItems.replace("}}",`/${a._id}}}`)}`),!e.isEmpty(a.repeaterItems)&&a.pagination&&(a.repeaterTotalItems=`${a.repeaterItems.replace("}}",`/${a._id}/totalItems}}`)}`)),w(a,l,{index:n,key:s})};exports.COLLECTION_PREFIX=q;exports.REPEATER_PREFIX=Y;exports.ROOT_TEMP_KEY=U;exports.STYLES_KEY=m;exports.adjustSpacingInContentBlocks=ye;exports.applyBindingToBlockProps=ge;exports.applyChaiDataBinding=ue;exports.applyDesignTokens=de;exports.applyLanguage=ie;exports.applyLimit=pe;exports.getBlockRuntimeProps=ce;exports.getBlockTagAttributes=re;exports.getBlocksFromHTML=le;exports.getSplitChaiClasses=V;exports.mergeBlocksWithExisting=ae;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { v as l } from "./tooltip-
|
|
2
|
+
import { v as l } from "./tooltip-DUosa-uC.js";
|
|
3
3
|
import m from "@monaco-editor/react";
|
|
4
4
|
import { CheckIcon as h, CopyIcon as C, DownloadIcon as y } from "@radix-ui/react-icons";
|
|
5
5
|
import { useState as s } from "react";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./tooltip-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./tooltip-Ba1-8jmj.cjs"),m=require("@monaco-editor/react"),o=require("@radix-ui/react-icons"),l=require("react");function j({code:r,onCopy:d,language:s="javascript",onDownload:c,downloadText:u="Download"}){const[n,a]=l.useState(!1),[t,p]=l.useState(r),f=()=>{d(t),a(!0),setTimeout(()=>{a(!1)},2e3)},h=()=>{c(t)};return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"h-[500px] max-h-full overflow-hidden rounded-md border py-2",children:e.jsx(m,{height:"100%",defaultLanguage:s,language:s,value:t,onChange:x=>p(x||""),theme:"vs-light",options:{minimap:{enabled:!1},fontSize:12,lineNumbers:"off",roundedSelection:!1,scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,insertSpaces:!0,wordWrap:"on",bracketPairColorization:{enabled:!0},suggest:{showKeywords:!1,showSnippets:!1}}})}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsxs(i.Button,{type:"button",variant:"outline",onClick:f,children:[n?e.jsx(o.CheckIcon,{className:"text-green-500"}):e.jsx(o.CopyIcon,{})," ",n?"Copied":"Copy"]}),e.jsxs(i.Button,{type:"button",onClick:h,children:[e.jsx(o.DownloadIcon,{})," ",u]})]})]})}exports.default=j;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("./index-tOL3lzGY.cjs");require("clsx");require("lodash-es");require("nanoid");require("tailwind-merge");require("tree-model");const c=require("react");require("jotai");require("@chaibuilder/runtime");require("sonner");const q=require("react-i18next"),r=require("./tooltip-Ba1-8jmj.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]=c.useState(!1),[a,p]=c.useState(""),[t,d]=i.useCodeEditor(),[u]=i.useSelectedBlockIds(),b=i.useUpdateBlocksProps(),f=i.useUpdateBlocksPropsRealtime(),C=g.useThrottledCallback(o=>{const l=m(o);f([t.blockId],{[t.blockProp]:l})},[],300),x=c.useCallback(()=>{if(s){const o=m(a);b([t.blockId],{[t.blockProp]:o})}},[s,a]);c.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;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as o, jsxs as d } from "react/jsx-runtime";
|
|
2
|
-
import { u as C, a as k, b as v, c as g } from "./index-
|
|
3
|
-
import "lodash-es";
|
|
2
|
+
import { u as C, a as k, b as v, c as g } from "./index-hrVqQhCa.js";
|
|
4
3
|
import "clsx";
|
|
4
|
+
import "lodash-es";
|
|
5
|
+
import "nanoid";
|
|
5
6
|
import "tailwind-merge";
|
|
6
7
|
import "tree-model";
|
|
7
8
|
import { useState as m, useCallback as T, useEffect as y } from "react";
|
|
@@ -9,13 +10,13 @@ import "jotai";
|
|
|
9
10
|
import "@chaibuilder/runtime";
|
|
10
11
|
import "sonner";
|
|
11
12
|
import { useTranslation as w } from "react-i18next";
|
|
12
|
-
import { a1 as N, a3 as E, a6 as D, a9 as H, b1 as P } from "./tooltip-
|
|
13
|
+
import { a1 as N, a3 as E, a6 as D, a9 as H, b1 as P } from "./tooltip-DUosa-uC.js";
|
|
13
14
|
import { useThrottledCallback as B } from "@react-hookz/web";
|
|
14
15
|
const p = (a) => {
|
|
15
16
|
const t = document.createElement("div");
|
|
16
17
|
return t.innerHTML = a, t.innerHTML;
|
|
17
18
|
};
|
|
18
|
-
function
|
|
19
|
+
function Q() {
|
|
19
20
|
const { t: a } = w(), [t, u] = m(!1), [r, f] = m(""), [e, n] = C(), [i] = k(), h = v(), x = g(), b = B(
|
|
20
21
|
(s) => {
|
|
21
22
|
const l = p(s);
|
|
@@ -54,5 +55,5 @@ function K() {
|
|
|
54
55
|
] }) });
|
|
55
56
|
}
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
+
Q as default
|
|
58
59
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("clsx");require("lodash-es");const r=require("nanoid"),t=require("tailwind-merge");function c(e=6){return r.nanoid(e)}const o=e=>e>=1536?"2XL":e>=1280?"XL":e>=1024?"LG":e>=768?"MD":e>=640?"SM":"XS",a=(...e)=>t.twMerge(n.clsx(e));exports.cn=a;exports.generateUUID=c;exports.getBreakpointValue=o;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { clsx as r } from "clsx";
|
|
2
|
+
import "lodash-es";
|
|
3
|
+
import { nanoid as e } from "nanoid";
|
|
4
|
+
import { twMerge as n } from "tailwind-merge";
|
|
5
|
+
function p(o = 6) {
|
|
6
|
+
return e(o);
|
|
7
|
+
}
|
|
8
|
+
const s = (o) => o >= 1536 ? "2XL" : o >= 1280 ? "XL" : o >= 1024 ? "LG" : o >= 768 ? "MD" : o >= 640 ? "SM" : "XS", f = (...o) => n(r(o));
|
|
9
|
+
export {
|
|
10
|
+
s as a,
|
|
11
|
+
f as c,
|
|
12
|
+
p as g
|
|
13
|
+
};
|
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-tOL3lzGY.cjs"),s=require("./common-functions-B3a4xKt_.cjs"),a=require("./apply-binding-Dblf6wMG.cjs"),l=require("react-i18next"),i=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.ChaiDraggableBlock=e.ChaiDraggableBlock;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:()=>l.useTranslation});exports.i18n=i;
|
package/dist/core.d.ts
CHANGED
|
@@ -272,8 +272,11 @@ export declare interface ChaiBuilderEditorProps {
|
|
|
272
272
|
gotoSettings?: boolean;
|
|
273
273
|
dragAndDrop?: boolean;
|
|
274
274
|
validateStructure?: boolean;
|
|
275
|
+
designTokens?: boolean;
|
|
275
276
|
};
|
|
276
277
|
structureRules?: StructureRule[];
|
|
278
|
+
designTokens?: DesignTokens;
|
|
279
|
+
onDesignTokenChange?: (designTokens: DesignTokens) => void;
|
|
277
280
|
}
|
|
278
281
|
|
|
279
282
|
declare type ChaiBuilderThemeOptions = {
|
|
@@ -475,6 +478,13 @@ declare type CopiedValue = string | null;
|
|
|
475
478
|
|
|
476
479
|
declare type CopyFn = (text: string) => Promise<boolean>;
|
|
477
480
|
|
|
481
|
+
declare interface DesignTokens {
|
|
482
|
+
[uniqueId: string]: {
|
|
483
|
+
name: string;
|
|
484
|
+
value: string;
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
|
|
478
488
|
declare type ExcludedBuilderProps = "blocks" | "subPages" | "brandingOptions" | "dataProviders";
|
|
479
489
|
|
|
480
490
|
declare type FilterOptions = {
|
|
@@ -486,7 +496,7 @@ declare type FilterOptions = {
|
|
|
486
496
|
/**
|
|
487
497
|
* Get the unique uuid
|
|
488
498
|
*/
|
|
489
|
-
export declare function generateBlockId(length?: number
|
|
499
|
+
export declare function generateBlockId(length?: number): string;
|
|
490
500
|
|
|
491
501
|
/**
|
|
492
502
|
*
|
|
@@ -596,6 +606,7 @@ declare type SavePageData = {
|
|
|
596
606
|
blocks: ChaiBlock[];
|
|
597
607
|
theme?: ChaiThemeValues;
|
|
598
608
|
needTranslations?: boolean;
|
|
609
|
+
designTokens: DesignTokens;
|
|
599
610
|
};
|
|
600
611
|
|
|
601
612
|
declare type SaveToLibraryProps = {
|
|
@@ -810,7 +821,7 @@ export declare const useResetBlockStyles: () => {
|
|
|
810
821
|
readonly reset: (styleId: string) => void;
|
|
811
822
|
};
|
|
812
823
|
|
|
813
|
-
export declare const useRightPanel: () => ["
|
|
824
|
+
export declare const useRightPanel: () => ["block" | "theme" | "ai" | "settings", (args_0: "block" | "theme" | "ai" | "settings" | ((prev: "block" | "theme" | "ai" | "settings") => "block" | "theme" | "ai" | "settings")) => void];
|
|
814
825
|
|
|
815
826
|
export declare const useSavePage: () => {
|
|
816
827
|
savePage: ThrottledFunction<(autoSave?: boolean, force?: boolean) => Promise<boolean>>;
|
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, m as B, E as k, I as g, L as n, g as h, T as p, U as S, h as m, z as P, P as F, n as A, o as T, p as b, q as M, r as y, F as I, G as v, t as L, v as f, s as H, w as R, x as D, y as E, O as U, Q as x, R as W, S as O, V as w, W as z, aC as j, X as q, Y as G, Z as V, aE as Z, aD as J, _ as K, H as N, J as Q, u 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, ab as ca, M as da, ac as Ca, ad as Ba, ae as ka, af as ga, ag as na, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, ao as Ta, aF as ba, ap as Ma, aq as ya, ar as Ia, a as va, as as La, at as fa, aG as Ha, au as Ra, aH as Da, av as Ea, aw as Ua, ax as xa, ay as Wa, az as Oa, K as wa, aA as za, b as ja, c as qa, aB as Ga } from "./index-
|
|
2
|
-
import { g as Za, c as Ja } from "./common-functions-
|
|
3
|
-
import { h as Na, h as Qa } from "./apply-binding-
|
|
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, m as B, E as k, I as g, L as n, g as h, T as p, U as S, h as m, z as P, P as F, n as A, o as T, p as b, q as M, r as y, F as I, G as v, t as L, v as f, s as H, w as R, x as D, y as E, O as U, Q as x, R as W, S as O, V as w, W as z, aC as j, X as q, Y as G, Z as V, aE as Z, aD as J, _ as K, H as N, J as Q, u 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, ab as ca, M as da, ac as Ca, ad as Ba, ae as ka, af as ga, ag as na, ah as ha, ai as pa, aj as Sa, ak as ma, al as Pa, am as Fa, an as Aa, ao as Ta, aF as ba, ap as Ma, aq as ya, ar as Ia, a as va, as as La, at as fa, aG as Ha, au as Ra, aH as Da, av as Ea, aw as Ua, ax as xa, ay as Wa, az as Oa, K as wa, aA as za, b as ja, c as qa, aB as Ga } from "./index-hrVqQhCa.js";
|
|
2
|
+
import { g as Za, c as Ja } from "./common-functions-D2lMFR6K.js";
|
|
3
|
+
import { h as Na, h as Qa } from "./apply-binding-BwPhgnhk.js";
|
|
4
4
|
import { useTranslation as Ya } from "react-i18next";
|
|
5
5
|
import { default as $a } from "i18next";
|
|
6
6
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as i, jsxs as m } from "react/jsx-runtime";
|
|
2
2
|
import * as x from "react";
|
|
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-
|
|
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-DUosa-uC.js";
|
|
4
4
|
import * as b from "culori";
|
|
5
5
|
import { getAllRegisteredFonts as P } from "@chaibuilder/runtime";
|
|
6
6
|
import { useTranslation as H } 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"),c=require("./tooltip-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),w=require("react"),c=require("./tooltip-Ba1-8jmj.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;
|