You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
1.1 KiB
2 lines
1.1 KiB
import{c as C,q as h,n as b,d as l,h as k,w}from"./index-f3701452.js";import{L as S}from"./index-1e934f0e.js";import{d as y,b as t}from"./index-f4658ae7.js";const[z,c]=C("switch"),L={size:b,loading:Boolean,disabled:Boolean,modelValue:l,activeColor:String,inactiveColor:String,activeValue:{type:l,default:!0},inactiveValue:{type:l,default:!1}};var P=y({name:z,props:L,emits:["change","update:modelValue"],setup(e,{emit:d,slots:o}){const n=()=>e.modelValue===e.activeValue,s=()=>{if(!e.disabled&&!e.loading){const a=n()?e.inactiveValue:e.activeValue;d("update:modelValue",a),d("change",a)}},u=()=>{if(e.loading){const a=n()?e.activeColor:e.inactiveColor;return t(S,{class:c("loading"),color:a},null)}if(o.node)return o.node()};return h(()=>e.modelValue),()=>{var a;const{size:m,loading:v,disabled:r,activeColor:g,inactiveColor:V}=e,i=n(),f={fontSize:k(m),backgroundColor:i?g:V};return t("div",{role:"switch",class:c({on:i,loading:v,disabled:r}),style:f,tabindex:r?void 0:0,"aria-checked":i,onClick:s},[t("div",{class:c("node")},[u()]),(a=o.background)==null?void 0:a.call(o)])}}});const _=w(P);export{_ as S};
|