import{b8 as e,q as t,o as a,c as i,w as l,t as o,R as s,G as n,i as u}from"./index-DL8B2Mxu.js";import{_ as d}from"./u-loading.C818sdP8.js";import{r}from"./uni-app.es.BSVEa1f2.js";import{_ as c}from"./_plugin-vue_export-helper.BCo6x5W8.js";const h=c({name:"u-switch",emits:["update:modelValue","input","change"],props:{value:{type:[Number,String,Boolean],default:!1},modelValue:{type:[Number,String,Boolean],default:!1},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},size:{type:[Number,String],default:50},activeColor:{type:String,default:"#2979ff"},inactiveColor:{type:String,default:"#ffffff"},vibrateShort:{type:Boolean,default:!1},activeValue:{type:[Number,String,Boolean],default:!0},inactiveValue:{type:[Number,String,Boolean],default:!1}},data:()=>({}),computed:{valueCom(){return this.modelValue},switchStyle(){let e={};return e.fontSize=this.size+"rpx",e.backgroundColor=this.valueCom?this.activeColor:this.inactiveColor,e},loadingColor(){return this.valueCom?this.activeColor:null}},methods:{onClick(){this.disabled||this.loading||(this.vibrateShort&&e(),this.$emit("input",!this.valueCom),this.$emit("update:modelValue",!this.valueCom),this.$nextTick((()=>{this.$emit("change",this.valueCom?this.activeValue:this.inactiveValue)})))}}},[["render",function(e,c,h,m,p,f){const v=r(t("u-loading"),d),g=u;return a(),i(g,{class:n(["u-switch",[1==f.valueCom?"u-switch--on":"",h.disabled?"u-switch--disabled":""]]),onClick:f.onClick,style:s([f.switchStyle])},{default:l((()=>[o(g,{class:"u-switch__node node-class",style:s({width:e.$u.addUnit(h.size),height:e.$u.addUnit(h.size)})},{default:l((()=>[o(v,{show:h.loading,class:"u-switch__loading",size:.6*h.size,color:f.loadingColor},null,8,["show","size","color"])])),_:1},8,["style"])])),_:1},8,["class","onClick","style"])}],["__scopeId","data-v-87400e0f"]]);const m=c({name:"jnpf-switch",props:{modelValue:{type:[String,Number,Boolean]},activeValue:{type:[String,Number,Boolean],default:1},inactiveValue:{type:[String,Number,Boolean],default:0},size:{default:40},disabled:{type:Boolean,default:!1}},data:()=>({innerValue:""}),watch:{modelValue:{handler(e){this.innerValue=!!Number(e)},immediate:!0}},methods:{onChange(e){this.$emit("update:modelValue",e),this.$emit("change",e)}}},[["render",function(e,s,n,d,c,m){const p=r(t("u-switch"),h),f=u;return a(),i(f,{class:"jnpf-switch"},{default:l((()=>[o(p,{modelValue:c.innerValue,"onUpdate:modelValue":s[0]||(s[0]=e=>c.innerValue=e),"active-value":n.activeValue,"inactive-value":n.inactiveValue,disabled:n.disabled,onChange:m.onChange,size:n.size},null,8,["modelValue","active-value","inactive-value","disabled","onChange","size"])])),_:1})}],["__scopeId","data-v-a6c5e7af"]]);export{m as _};
