buefy
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
3 lines (2 loc) • 3.15 kB
JavaScript
/*! Buefy v3.0.4 | MIT License | github.com/buefy/buefy */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Switch={},e.Vue)}(this,(function(e,t){"use strict";let l=!0;const a=t.defineComponent({name:"BSwitch",props:{modelValue:[String,Number,Boolean,Function,Object,Array,Date],nativeValue:[String,Number,Boolean,Function,Object,Array,Date],disabled:Boolean,type:String,passiveType:String,name:String,required:Boolean,size:String,ariaLabelledby:String,trueValue:{type:[String,Number,Boolean,Function,Object,Array,Date],default:!0},falseValue:{type:[String,Number,Boolean,Function,Object,Array,Date],default:!1},rounded:{type:Boolean,default:()=>l},outlined:{type:Boolean,default:!1},leftLabel:{type:Boolean,default:!1}},emits:["update:modelValue"],data(){return{newValue:this.modelValue,isMouseDown:!1}},computed:{computedValue:{get(){return this.newValue},set(e){this.newValue=e,this.$emit("update:modelValue",e)}},newClass(){return[this.size,{"is-disabled":this.disabled,"is-rounded":this.rounded,"is-outlined":this.outlined,"has-left-label":this.leftLabel}]},checkClasses(){return[{"is-elastic":this.isMouseDown&&!this.disabled},this.passiveType&&`${this.passiveType}-passive`,this.type]},showControlLabel(){return!!this.$slots.default},disabledOrUndefined(){return this.disabled||void 0}},watch:{modelValue(e){this.newValue=e}},methods:{focus(){this.$refs.input.focus()}}});const n=["disabled"],o=["disabled","name","required","value","true-value","false-value","aria-labelledby"],s=["id"];var i=((e,t)=>{const l=e.__vccOpts||e;for(const[e,a]of t)l[e]=a;return l})(a,[["render",function(e,l,a,i,u,r){return t.openBlock(),t.createElementBlock("label",{class:t.normalizeClass(["switch",e.newClass]),ref:"label",disabled:e.disabledOrUndefined,onClick:l[2]||(l[2]=(...t)=>e.focus&&e.focus(...t)),onKeydown:l[3]||(l[3]=t.withKeys(t.withModifiers((t=>e.$refs.label.click()),["prevent"]),["enter"])),onMousedown:l[4]||(l[4]=t=>e.isMouseDown=!0),onMouseup:l[5]||(l[5]=t=>e.isMouseDown=!1),onMouseout:l[6]||(l[6]=t=>e.isMouseDown=!1),onBlur:l[7]||(l[7]=t=>e.isMouseDown=!1)},[t.withDirectives(t.createElementVNode("input",{"onUpdate:modelValue":l[0]||(l[0]=t=>e.computedValue=t),type:"checkbox",ref:"input",onClick:l[1]||(l[1]=t.withModifiers((()=>{}),["stop"])),disabled:e.disabledOrUndefined,name:e.name,required:e.required,value:e.nativeValue,"true-value":e.trueValue,"false-value":e.falseValue,"aria-labelledby":e.ariaLabelledby},null,8,o),[[t.vModelCheckbox,e.computedValue]]),t.createElementVNode("span",{class:t.normalizeClass(["check",e.checkClasses])},null,2),e.showControlLabel?(t.openBlock(),t.createElementBlock("span",{key:0,id:e.ariaLabelledby,class:"control-label"},[t.renderSlot(e.$slots,"default")],8,s)):t.createCommentVNode("v-if",!0)],42,n)}]]);const u={install(e){((e,t)=>{const l=t.name;if(null==l)throw new Error("Buefy.registerComponent: missing component name");e.component(l,t)})(e,i)}};e.BSwitch=i,e.default=u,Object.defineProperty(e,"__esModule",{value:!0})}));