buefy
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
3 lines (2 loc) • 3.56 kB
JavaScript
/*! Buefy v3.0.2 | MIT License | github.com/buefy/buefy */
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).Radio={},e.Vue)}(this,(function(e,i){"use strict";var n=i.defineComponent({props:{modelValue:[String,Number,Boolean,Function,Object,Array],nativeValue:[String,Number,Boolean,Function,Object,Array],type:String,disabled:Boolean,required:Boolean,name:String,size:String},emits:{"update:modelValue":e=>!0},data(){return{newValue:this.modelValue}},computed:{computedValue:{get(){return this.newValue},set(e){this.newValue=e,this.$emit("update:modelValue",e)}},disabledOrUndefined(){return this.disabled||void 0},requiredOrUndefined(){return this.required||void 0}},watch:{modelValue(e){this.newValue=e}},methods:{focus(){this.$refs.input.focus()}}});const t=i.defineComponent({name:"BRadio",mixins:[n]});var d=(e,i)=>{const n=e.__vccOpts||e;for(const[e,t]of i)n[e]=t;return n};const l=["disabled"],o=["disabled","required","name","value"],a={class:"control-label"};var s=d(t,[["render",function(e,n,t,d,s,r){return i.openBlock(),i.createElementBlock("label",{class:i.normalizeClass(["b-radio radio",[e.size,{"is-disabled":e.disabled}]]),ref:"label",disabled:e.disabledOrUndefined,onClick:n[2]||(n[2]=(...i)=>e.focus&&e.focus(...i)),onKeydown:n[3]||(n[3]=i.withKeys(i.withModifiers((i=>e.$refs.label.click()),["prevent"]),["enter"]))},[i.withDirectives(i.createElementVNode("input",{"onUpdate:modelValue":n[0]||(n[0]=i=>e.computedValue=i),type:"radio",ref:"input",onClick:n[1]||(n[1]=i.withModifiers((()=>{}),["stop"])),disabled:e.disabledOrUndefined,required:e.requiredOrUndefined,name:e.name,value:e.nativeValue},null,8,o),[[i.vModelRadio,e.computedValue]]),i.createElementVNode("span",{class:i.normalizeClass(["check",e.type])},null,2),i.createElementVNode("span",a,[i.renderSlot(e.$slots,"default")])],42,l)}]]);const r=i.defineComponent({name:"BRadioButton",mixins:[n],props:{type:{type:String,default:"is-primary"},expanded:Boolean},data:()=>({isFocused:!1}),computed:{isSelected(){return this.newValue===this.nativeValue},labelClass(){return[this.isSelected?this.type:null,this.size,{"is-selected":this.isSelected,"is-disabled":this.disabled,"is-focused":this.isFocused}]}}}),u=["disabled"],c=["disabled","required","name","value"];var p=d(r,[["render",function(e,n,t,d,l,o){return i.openBlock(),i.createElementBlock("div",{class:i.normalizeClass(["control",{"is-expanded":e.expanded}])},[i.createElementVNode("label",{class:i.normalizeClass(["b-radio radio button",e.labelClass]),ref:"label",disabled:e.disabledOrUndefined,onClick:n[4]||(n[4]=(...i)=>e.focus&&e.focus(...i)),onKeydown:n[5]||(n[5]=i.withKeys(i.withModifiers((i=>e.$refs.label.click()),["prevent"]),["enter"]))},[i.renderSlot(e.$slots,"default"),i.withDirectives(i.createElementVNode("input",{"onUpdate:modelValue":n[0]||(n[0]=i=>e.computedValue=i),type:"radio",ref:"input",onClick:n[1]||(n[1]=i.withModifiers((()=>{}),["stop"])),disabled:e.disabledOrUndefined,required:e.requiredOrUndefined,name:e.name,value:e.nativeValue,onFocus:n[2]||(n[2]=i=>e.isFocused=!0),onBlur:n[3]||(n[3]=i=>e.isFocused=!1)},null,40,c),[[i.vModelRadio,e.computedValue]])],42,u)],2)}]]);const f=(e,i,n)=>{const t=i.name;if(null==t)throw new Error("Buefy.registerComponent: missing component name");e.component(t,i)},m={install(e){f(e,s),f(e,p)}};e.BRadio=s,e.BRadioButton=p,e.default=m,Object.defineProperty(e,"__esModule",{value:!0})}));