zview-plus
Version:
基于 Vue3 的 UI 组件库
2 lines (1 loc) • 2.79 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("./switch.js"),p={key:0},v={key:1},k={name:"ZSwitch"},z=e.defineComponent({...k,props:d.SwitchProps,emits:["update:modelValue","change"],setup(s,{emit:n}){const a=s,t=e.ref(a.modelValue),i=e.computed(()=>({"is-disabled":a.disabled})),c=e.computed(()=>({[`z-switch--${a.size}`]:a.size})),r=e.computed(()=>({backgroundColor:t.value?a.activeColor:a.inactiveColor})),u=()=>{a.disabled||(t.value=!t.value,n("update:modelValue",t.value),n("change",t.value))};return(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["z-switch-default",e.unref(c)])},[l.inactiveText&&!l.inlinePrompt?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["z-switch-label z-switch-label-left",[t.value?"":"is-active"]])},e.toDisplayString(l.inactiveText),3)):e.createCommentVNode("",!0),l.inactiveIcon&&!l.inlinePrompt?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(["z-switch-label z-switch-label-left",[t.value?"":"is-active"]])},[e.createElementVNode("i",{class:e.normalizeClass(`z-icon-${l.inactiveIcon}`)},null,2)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["z-switch-content",e.unref(i)]),onClick:u},[e.withDirectives(e.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":o[0]||(o[0]=m=>t.value=m)},null,512),[[e.vModelCheckbox,t.value]]),e.createElementVNode("span",{class:e.normalizeClass(["core",[t.value?"on":"off"]]),style:e.normalizeStyle(e.unref(r))},[l.inlinePrompt?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["z-switch-inner",`z-switch-inner--${l.size}`])},[l.activeText?(e.openBlock(),e.createElementBlock("span",p,e.toDisplayString(t.value?l.activeText:l.inactiveText),1)):e.createCommentVNode("",!0),l.activeIcon?(e.openBlock(),e.createElementBlock("span",v,[t.value?(e.openBlock(),e.createElementBlock("i",{key:1,class:e.normalizeClass(`z-icon-${l.inactiveIcon}`)},null,2)):(e.openBlock(),e.createElementBlock("i",{key:0,class:e.normalizeClass(`z-icon-${l.activeIcon}`)},null,2))])):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)],6)],2),l.activeText&&!l.inlinePrompt?(e.openBlock(),e.createElementBlock("span",{key:2,class:e.normalizeClass(["z-switch-label z-switch-label-right",[t.value?"is-active":""]])},e.toDisplayString(l.activeText),3)):e.createCommentVNode("",!0),l.activeIcon&&!l.inlinePrompt?(e.openBlock(),e.createElementBlock("span",{key:3,class:e.normalizeClass(["z-switch-label z-switch-label-right",[t.value?"is-active":""]])},[e.createElementVNode("i",{class:e.normalizeClass(`z-icon-${l.activeIcon}`)},null,2)],2)):e.createCommentVNode("",!0)],2))}});exports.default=z;