2 lines
2.0 KiB
JavaScript
2 lines
2.0 KiB
JavaScript
import{d as $,eC as b,r as I,c as y,O as V,o as c,a,b as p,F as f,e as _,D as B,f as d,ar as g,B as z,G as F,fc as N,q as T,x as j}from"./index-Bp03Znup.js";const q={class:"w-[250px]"},D={class:"flex flex-wrap gap-[20px]"},E=["onClick"],G={class:"w-full rounded-lg overflow-hidden mt-6 cursor-pointer"},H=["onClick"],L=$({__name:"theme-picker",props:{themeColors:{},modelValue:{}},emits:["update:modelValue","change"],setup(C,{emit:k}){const r=C,i=k,l=b(r,"modelValue",i),m=I([]),x=y(()=>{var e;return((e=r.themeColors.find(o=>o.id===l.value))==null?void 0:e.color)||""}),v=e=>{l.value=e.id,i("change",e),h(e.defaultColor,e.id)},S=e=>{const o=r.themeColors.find(s=>s.id===l.value);o.color=e.color,i("change",o)},w=e=>{const o=e.match(/\d+/g);if(!o||o.length<3)return e;const s=parseInt(o[0]).toString(16).padStart(2,"0"),t=parseInt(o[1]).toString(16).padStart(2,"0"),n=parseInt(o[2]).toString(16).padStart(2,"0");return`#${s}${t}${n}`},h=(e,o)=>{const s=["lightness(80%)","lightness(75%)","lightness(65%)","","blackness(35%)","blackness(45%)","blackness(55%)","blackness(65%)"];m.value=s.map((t,n)=>{const u=n===3?e:`color(${e} ${t})`;return{id:o||l.value,color:w(N.convert(u))}})};return V(l,e=>{if(e!==-1){const o=r.themeColors.findIndex(s=>s.id===e);h(r.themeColors[o].defaultColor)}},{immediate:!0}),(e,o)=>{const s=T;return c(),a("div",q,[p("div",D,[(c(!0),a(f,null,_(e.themeColors,(t,n)=>(c(),a("div",{class:B(["w-[70px] h-[50px] flex items-center text-[14px] shadow rounded-lg cursor-pointer overflow-hidden",{"is-select":d(l)==t.id,unselect:d(l)!=t.id}]),key:n,onClick:u=>v(t)},[p("div",{class:"w-full h-full",style:g(`background: ${t.defaultColor}`)},null,4)],10,E))),128))]),p("div",G,[(c(!0),a(f,null,_(d(m),(t,n)=>(c(),a("div",{key:n,class:"flex items-center justify-end w-full h-[50px] pr-4",style:g(`background: ${t.color}`),onClick:u=>S(t)},[d(l)==t.id&&t.color==d(x)?(c(),z(s,{key:0,name:"el-icon-SuccessFilled",class:"text-white",size:"20"})):F("",!0)],12,H))),128))])])}}}),O=j(L,[["__scopeId","data-v-e402a3c1"]]);export{O as default};
|