mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
1.1 KiB
JavaScript
2 lines
1.1 KiB
JavaScript
import{c as v,E as C,h as w}from"./use-translate.d2900b8c.js";import{n as k,u as t,w as b}from"./with-install.19a35764.js";import{L as S}from"./index.4e4daaac.js";import{z as y,e as c}from"./vue-libs.b44bc779.js";const[z,l]=v("switch"),L={size:k,loading:Boolean,disabled:Boolean,modelValue:t,activeColor:String,inactiveColor:String,activeValue:{type:t,default:!0},inactiveValue:{type:t,default:!1}},P=y({name:z,props:L,emits:["change","update:modelValue"],setup(e,{emit:d,slots:n}){const o=()=>e.modelValue===e.activeValue,s=()=>{if(!e.disabled&&!e.loading){const a=o()?e.inactiveValue:e.activeValue;d("update:modelValue",a),d("change",a)}},m=()=>{if(e.loading){const a=o()?e.activeColor:e.inactiveColor;return c(S,{class:l("loading"),color:a},null)}if(n.node)return n.node()};return C(()=>e.modelValue),()=>{var u;const{size:a,loading:V,disabled:r,activeColor:f,inactiveColor:g}=e,i=o(),h={fontSize:w(a),backgroundColor:i?f:g};return c("div",{role:"switch",class:l({on:i,loading:V,disabled:r}),style:h,tabindex:r?void 0:0,"aria-checked":i,onClick:s},[c("div",{class:l("node")},[m()]),(u=n.background)==null?void 0:u.call(n)])}}}),x=b(P),I=x;export{x as S,I as V};
|