| 1 |
import{r as A,a as $e,i as J,g as we,k as N,j as e,h as V,_ as P,f as M,l as E,ea as ee,cH as se,bI as H,cB as z,cC as D,cD as je,cE as ke,ct as Ne,cs as Ve,at as _e}from"./main-762.js";import{C as _,$ as oe}from"./bf-874-177.js";import{N as G}from"./bf-517-178.js";import{G as te}from"./bf-734-179.js";import{S as ae}from"./bf-111-180.js";import{S as Ae}from"./bf-610-181.js";import"./bf-775-182.js";import"./bf-685-46.js";import"./bf-81-43.js";import"./bf-871-60.js";/* empty css */import"./bf-435-62.js";import"./bf-653-63.js";function Be({stateObjName:Q,propertyPath:a,hslaPaths:r,canSetVariable:re,id:p,fldKey:C}){const{css:n}=$e(),[L,ne]=J(Ne),[o,v]=A.useState(),{element:B,fieldKey:F}=we(),[,T]=A.useTransition(),ce=typeof o=="string",[U,le]=A.useState(ce?"Var":"Custom"),[w,ie]=J(Ve),[me,W]=J(_e),be=[{label:"Custom",icn:"Custom color",show:["icn"],tip:"Custom color"},{label:"Var",icn:"Variables",show:["icn"],tip:"Variable color"}],{"--global-bg-color":de,"--global-fld-bdr-clr":ue,"--global-fld-bg-color":ge,"--global-font-color":fe,"--global-accent-color":xe}=w,S=Array.isArray(a)?a[0]:a;A.useEffect(()=>{var c;switch(Q){case"themeColors":const h=N(w,a);v(G(h));break;case"themeVars":const $=N(L,a);v(G($));break;case"styles":const j=Array.isArray(a)?a[0]:a,l=N(me,j);let b=l;if(((c=l==null?void 0:l.match(/var/gi))==null?void 0:c[0])==="var"){const t=l==null?void 0:l.replace(/\(|var|,.*|\)|(!important)|\s/gi,"");b=L[t]?L[t]:w[t]}l!=null&&l.match(/(!important)/gi)&&(b=l==null?void 0:l.replace(/(!important)|\s/gi,"")),v(G(b));break;case"field-accent-color":const d=N(w,a);v(G(d));break}},[p]);const q=(c,h,$,j,l="")=>{const[b,d,t,k,u]=ke(c,h,$,j);switch(Q){case"themeColors":ie(g=>M(g,s=>{if(s[a]=u,r&&("h"in r&&(s[r.h]=b),"s"in r&&(s[r.s]=`${d}%`),"l"in r&&(s[r.l]=`${t}%`),"a"in r&&(s[r.a]=`${k}%`)),a==="--global-accent-color"){const m=ee(b,d,t),f=se(m);s["--fld-focs-i-fltr"]=f.filter}if(a==="--global-bg-color")for(let m=0;m<105;m+=5){let f="";t>50&&t-m<=0?f=`hsl(${Math.round(b)}, ${Math.round(d)}%, 0%)`:t<50&&t+m>=100?f=`hsl(${Math.round(b)}, ${Math.round(d)}%, 100%)`:f=`hsl(${Math.round(b)}, ${Math.round(d)}%, ${Math.round(t>50?t-m:t+m)}%)`,s[`--bg-${m}`]=f}})),H(z(B,F,S,u,{themeColors:D("themeColors")}));break;case"themeVars":ne(g=>M(g,s=>{s[a]=u,r&&("h"in r&&(s[r.h]=b),"s"in r&&(s[r.s]=`${d}%`),"l"in r&&(s[r.l]=`${t}%`),"a"in r&&(s[r.a]=`${k}%`))})),H(z(B,F,S,u,{themeVars:D("themeVars")}));break;case"field-accent-color":W(g=>M(g,s=>{const m=`${u}!important`,f=`0px 0px 0px 3px hsla(${b}, ${d}%, ${t}%, 0.30)!important`;s.fields[C].classes[`.${C}-fld:focus`]["border-color"]=m,s.fields[C].classes[`.${C}-fld:focus`]["box-shadow"]=f,s.fields[C].classes[`.${C}-fld:hover`]["border-color"]=m})),H(z(B,F,S,u,{styles:D("styles")}));break;case"styles":W(g=>M(g,s=>{var K;let m=u;const f=Array.isArray(a)?a[0]:a,y=N(s,f),he=(K=y==null?void 0:y.match(/(!important)/gi))==null?void 0:K[0],pe=`0px 0px 0px 3px hsla(${b}, ${d}%, ${t}%, 0.30) !important`;he&&(m=`${m} !important`);const Z=l||m;Array.isArray(a)?a.forEach(I=>{const R=I.split("->"),O=R.length-1;if(R[O]==="box-shadow")E(s,I,pe);else if(R[O]==="filter"){const Ce=ee(b,d,t),ve=se(Ce);E(s,I,ve.filter)}else E(s,I,Z)}):E(s,a,Z)})),H(z(B,F,S,u,{styles:D("styles")}));break}},x=c=>{if(typeof c=="object")v(c),T(()=>{q(c.h,c.s,c.v,c.a)});else{const h=`var(${c})`,$=w[c];if($){const[j,l,b,d]=$.match(/[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)/gi),[t,k,u,g]=je(j,l,b,d);v({h:t,s:k,v:u,a:g}),T(()=>{q(t,k,u,g,h)})}else T(()=>{q("","","","",h)})}},X=c=>{const h={h:0,s:0,v:0,a:0};c.target.checked?x(h):x("--global-accent-color")},Y=()=>(o==null?void 0:o.h)===0&&(o==null?void 0:o.s)===0&&(o==null?void 0:o.v)===0&&(o==null?void 0:o.a)===0;return e.jsx("div",{className:n(i.preview_wrp),children:re?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:n(i.mb),children:e.jsx(Ae,{square:!0,noShadow:!0,defaultActive:"Custom",options:be,size:60,component:"button",onChange:c=>le(c),show:["icn"],variant:"lightgray",width:"100%",wideTab:!0})}),e.jsx(te,{open:U==="Var",children:e.jsxs("div",{className:n(i.varClr),children:[e.jsxs("button",{className:`${n(i.clrItem)} ${n(o==="--global-bg-color"&&i.active)}`,type:"button",onClick:()=>x("--global-bg-color"),"data-testid":`${p}-g-bg-c`,children:[e.jsx(_,{bg:de,className:n(V.mr2)}),e.jsx("span",{children:"Background Color"})]}),e.jsxs("button",{className:n(i.clrItem,o==="--global-accent-color"&&i.active),type:"button",onClick:()=>x("--global-accent-color"),"data-testid":`${p}-g-a-c`,children:[e.jsx(_,{bg:xe,className:n(V.mr2)}),e.jsx("span",{children:"Background Accent Color"})]}),e.jsxs("button",{className:n(i.clrItem,o==="--global-font-color"&&i.active),type:"button",onClick:()=>x("--global-font-color"),"data-testid":`${p}-g-f-c`,children:[e.jsx(_,{bg:fe,className:n(V.mr2)}),e.jsx("span",{children:"Font Color"})]}),e.jsxs("button",{className:n(i.clrItem,o==="--global-fld-bdr-clr"&&i.active),type:"button",onClick:()=>x("--global-fld-bdr-clr"),"data-testid":`${p}-g-f-b`,children:[e.jsx(_,{bg:ue,className:n(V.mr2)}),e.jsx("span",{children:"Field Border Color"})]}),e.jsxs("button",{className:n(i.clrItem,o==="--global-fld-bg-color"&&i.active),type:"button",onClick:()=>x("--global-fld-bg-color"),"data-testid":`${p}-g-f-bg-c`,children:[e.jsx(_,{bg:ge,className:n(V.mr2)}),e.jsx("span",{children:"Field Background Color"})]})]})}),e.jsx(te,{open:U==="Custom",children:e.jsxs("div",{className:n(i.container),children:[e.jsx("div",{className:n(i.subContainer),children:e.jsx(ae,{title:P("Transparent"),action:X,isChecked:Y(),id:"color-transparent"})}),e.jsx(oe,{showParams:!0,showPreview:!0,onChange:x,value:o})]})})]}):e.jsxs("div",{className:n(i.container),children:[e.jsx("div",{className:n(i.subContainer),children:e.jsx(ae,{title:P("Transparent"),action:X,isChecked:Y(),id:"color-transparent"})}),e.jsx(oe,{showParams:!0,showPreview:!0,onChange:x,value:o})]})})}var Re=A.memo(Be);const i={preview_wrp:{w:248,'& div[role="group"]':{p:4,b:0},"& input":{brs:8,b:"1px solid lightgray",p:"3px 8px",mnh:"10px !important",fs:12,mb:3,bs:"none",":focus":{focusShadow:1,b:"1px solid var(--b-50)"}},"& .common-module_transBackground__2AOKu":{brs:8,ow:"hidden"}},container:{dy:"flex",fd:"column","& .styles-module_container__2LiHz":{w:"100%"}},subContainer:{m:5,"& span":{fs:12},"& input":{m:0}},varClr:{my:5,w:"100%"},active:{bcr:"var(--b-50) !important",bd:"#f3f8ff"},clrItem:{dy:"block",flx:"align-center",bd:"transparent",b:"2px solid var(--white-0-93)",p:3,mb:8,brs:10,fs:12,cur:"pointer",w:"100%",tn:"background .3s",":hover":{bd:"var(--white-0-97)"}},mb:{mb:5}};export{Re as default}; |