tyh-ui2
Version:
The next generation ui component library of tyh-ui is based on vue3 Version, fully embrace vue3.
2 lines (1 loc) • 1.59 kB
JavaScript
;Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),i=require("./index2.js"),d=e.defineComponent({name:"TyhSwitch"}),p=e.defineComponent({...d,props:i.Props,emits:["update:modelValue","change"],setup(s,{emit:a}){const t=s,o=e.ref(t.modelValue),r=()=>{t.disabled||(o.value=!o.value,a("update:modelValue",o.value),a("change",o.value))},n=e.computed(()=>t.modelValue?t.openColor:t.closeColor),c=e.computed(()=>{const l=e.ref(t.width);return l.value<20&&(l.value=20),{width:`${l.value}px`,height:`${l.value/2}px`,backgroundColor:n.value}}),u=e.computed(()=>{const l=e.ref(t.width);return l.value<20&&(l.value=20),{width:`${l.value/2}px`,height:`${l.value/2}px`,left:t.modelValue?`${l.value/2}px`:"0px",border:`2px solid ${n.value}`}});return(l,h)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[l.closeText?(e.openBlock(),e.createElementBlock("span",{key:0,class:"tyh-switch-closeText",style:e.normalizeStyle([`color:${o.value?"#333":"#3a6ff4"}`])},e.toDisplayString(l.closeText),5)):e.createCommentVNode("",!0),e.createElementVNode("span",{class:e.normalizeClass(["tyh-switch",{"tyh-switch-disabled":l.disabled}]),style:e.normalizeStyle(e.unref(c)),onClick:r},[e.createElementVNode("span",{class:"tyh-switch-roll",style:e.normalizeStyle(e.unref(u))},null,4)],6),l.openText?(e.openBlock(),e.createElementBlock("span",{key:1,class:"tyh-switch-openText",style:e.normalizeStyle([`color:${l.modelValue?"#3a6ff4":"#333"}`])},e.toDisplayString(l.openText),5)):e.createCommentVNode("",!0)],64))}});exports.default=p;