index-c863cf04.js 1.1 KB

1
  1. import{c as f,a6 as h,n as k,a4 as l,L as w,F as b,w as S}from"./index-301fd8e9.js";import{d as y,$ as t}from"./@vue-cb50a1c4.js";const[x,c]=f("switch"),z={size:k,loading:Boolean,disabled:Boolean,modelValue:l,activeColor:String,inactiveColor:String,activeValue:{type:l,default:!0},inactiveValue:{type:l,default:!1}};var L=y({name:x,props:z,emits:["change","update:modelValue"],setup(e,{emit:d,slots:n}){const o=()=>e.modelValue===e.activeValue,u=()=>{if(!e.disabled&&!e.loading){const a=o()?e.inactiveValue:e.activeValue;d("update:modelValue",a),d("change",a)}},r=()=>{if(e.loading){const a=o()?e.activeColor:e.inactiveColor;return t(w,{class:c("loading"),color:a},null)}if(n.node)return n.node()};return h(()=>e.modelValue),()=>{var a;const{size:v,loading:m,disabled:s,activeColor:g,inactiveColor:V}=e,i=o(),C={fontSize:b(v),backgroundColor:i?g:V};return t("div",{role:"switch",class:c({on:i,loading:m,disabled:s}),style:C,tabindex:s?void 0:0,"aria-checked":i,onClick:u},[t("div",{class:c("node")},[r()]),(a=n.background)==null?void 0:a.call(n)])}}});const F=S(L);export{F as S};