UNPKG

buefy

Version:

Lightweight UI components for Vue.js (v3) based on Bulma

3 lines (2 loc) 7.4 kB
/*! 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).Select={},e.Vue)}(this,(function(e,t){"use strict";let i,n="mdi",s=null,o=!0,l=!0,r=!0;const a={sizes:{default:"mdi-24px","is-small":null,"is-medium":"mdi-36px","is-large":"mdi-48px"},iconPrefix:"mdi-"},c=()=>{const e="fa-";return{sizes:{default:null,"is-small":null,"is-medium":e+"lg","is-large":e+"2x"},iconPrefix:e,internalIcons:{information:"info-circle",alert:"exclamation-triangle","alert-circle":"exclamation-circle","chevron-right":"angle-right","chevron-left":"angle-left","chevron-down":"angle-down","eye-off":"eye-slash","menu-down":"caret-down","menu-up":"caret-up","close-circle":"times-circle"}}};var u=(e,t)=>{const i=e.__vccOpts||e;for(const[e,n]of t)i[e]=n;return i};var d=u(t.defineComponent({name:"BIcon",props:{type:[String,Object],component:String,pack:String,icon:{type:String,required:!0},size:String,customSize:String,customClass:String,both:Boolean},computed:{iconConfig(){return{mdi:a,fa:c(),fas:c(),far:c(),fad:c(),fab:c(),fal:c(),"fa-solid":c(),"fa-regular":c(),"fa-light":c(),"fa-thin":c(),"fa-duotone":c(),"fa-brands":c()}[this.newPack]},iconPrefix(){return this.iconConfig&&this.iconConfig.iconPrefix?this.iconConfig.iconPrefix:""},newIcon(){return`${this.iconPrefix}${this.getEquivalentIconOf(this.icon)}`},newPack(){return this.pack||n},newType(){if(!this.type)return;let e=[];if("string"==typeof this.type)e=this.type.split("-");else for(const t in this.type)if(this.type[t]){e=t.split("-");break}if(e.length<=1)return;const[,...t]=e;return`has-text-${t.join("-")}`},newCustomSize(){return this.customSize||this.customSizeByPack},customSizeByPack(){if(this.iconConfig&&this.iconConfig.sizes){if(this.size&&void 0!==this.iconConfig.sizes[this.size])return this.iconConfig.sizes[this.size];if(this.iconConfig.sizes.default)return this.iconConfig.sizes.default}return null},useIconComponent(){return this.component||s}},methods:{getEquivalentIconOf(e){if(!this.both)return e;if(null==this.iconConfig)return e;const t=this.iconConfig;return t&&t.internalIcons&&t.internalIcons[e]?t.internalIcons[e]:e}}}),[["render",function(e,i,n,s,o,l){return t.openBlock(),t.createElementBlock("span",{class:t.normalizeClass(["icon",[e.newType,e.size]])},[e.useIconComponent?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.useIconComponent),{key:1,icon:[e.newPack,e.newIcon],size:e.newCustomSize,class:t.normalizeClass([e.customClass])},null,8,["icon","size","class"])):(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass([e.newPack,e.newIcon,e.newCustomSize,e.customClass])},null,2))],2)}]]),m=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,f=t.defineComponent({inheritAttrs:!1,props:{compatFallthrough:{type:Boolean,default:()=>o}},computed:{rootAttrs(){return this.compatFallthrough?{class:this.$attrs.class,style:this.$attrs.style,id:this.$attrs.id}:{}},fallthroughAttrs(){if(this.compatFallthrough){const e=this.$attrs,{style:t,class:i,id:n}=e;return((e,t)=>{var i={};for(var n in e)h.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&m)for(var n of m(e))t.indexOf(n)<0&&p.call(e,n)&&(i[n]=e[n]);return i})(e,["style","class","id"])}return this.$attrs}}});const g=t.defineComponent({props:{size:String,expanded:Boolean,loading:Boolean,rounded:Boolean,icon:String,iconPack:String,maxlength:[Number,String],useHtml5Validation:{type:Boolean,default:()=>l},validationMessage:String,locale:{type:[String,Array],default:()=>i},statusIcon:{type:Boolean,default:()=>r}},emits:{blur:e=>!0,focus:e=>!0},data(){return{isValid:!0,isFocused:!1,newIconPack:this.iconPack||n,_elementRef:""}},computed:{parentField(){let e=this.$parent;for(let t=0;t<3;t++)e&&!e.$data._isField&&(e=e.$parent);return e},statusType(){const{newType:e}=this.parentField||{};if(e){if("string"==typeof e)return e;for(const t in e)if(e[t])return t}},statusMessage(){if(this.parentField)return this.parentField.newMessage||this.parentField.$slots.message},iconSize(){switch(this.size){case"is-small":return this.size;case"is-medium":return;case"is-large":return"mdi"===this.newIconPack?"is-medium":""}}},methods:{focus(){const e=this.getElement();void 0!==e&&this.$nextTick((()=>{e&&e.focus()}))},onBlur(e){this.isFocused=!1,this.$emit("blur",e),this.checkHtml5Validity()},onFocus(e){this.isFocused=!0,this.$emit("focus",e)},getElement(){let e=this.$refs[this.$data._elementRef];for(;null!=e&&"object"==typeof e&&"$refs"in e;){const t=e;e=t.$refs[t.$data._elementRef]}return e},setInvalid(){const e=this.validationMessage||this.getElement().validationMessage;this.setValidity("is-danger",e)},setValidity(e,t){this.$nextTick((()=>{this.parentField&&(this.parentField.type||(this.parentField.newType=e),this.parentField.message||(this.parentField.newMessage=t))}))},checkHtml5Validity(){if(!this.useHtml5Validation)return!1;const e=this.getElement();return null!=e&&(e.checkValidity()?(this.setValidity(null,null),this.isValid=!0):(this.setInvalid(),this.isValid=!1),this.isValid)}}});var y=t.defineComponent({name:"BSelect",components:{BIcon:d},mixins:[f,g],props:{modelValue:{type:[String,Number,Boolean,Object,Array,Function,Date,null],default:null},placeholder:String,multiple:Boolean,nativeSize:[String,Number]},emits:{blur:e=>!0,focus:e=>!0,"update:modelValue":e=>!0},data(){return{selected:this.modelValue,_elementRef:"select"}},computed:{computedValue:{get(){return this.selected},set(e){this.selected=e,this.$emit("update:modelValue",e),!this.isValid&&this.checkHtml5Validity()}},spanClasses(){return[this.size,this.statusType,{"is-fullwidth":this.expanded,"is-loading":this.loading,"is-multiple":this.multiple,"is-rounded":this.rounded,"is-empty":null===this.selected}]}},watch:{modelValue(e){this.selected=e,!this.isValid&&this.checkHtml5Validity()}}});const k=["multiple","size"],z={key:0,value:null,disabled:"",hidden:""};var C=u(y,[["render",function(e,i,n,s,o,l){const r=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",t.mergeProps({class:["control",{"is-expanded":e.expanded,"has-icons-left":e.icon}]},e.rootAttrs),[t.createElementVNode("span",{class:t.normalizeClass(["select",e.spanClasses])},[t.withDirectives(t.createElementVNode("select",t.mergeProps({"onUpdate:modelValue":i[0]||(i[0]=t=>e.computedValue=t),ref:"select",multiple:e.multiple,size:e.nativeSize},e.fallthroughAttrs,{onBlur:i[1]||(i[1]=(...t)=>e.onBlur&&e.onBlur(...t)),onFocus:i[2]||(i[2]=t=>e.$emit("focus",t))}),[e.placeholder?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[null==e.computedValue?(t.openBlock(),t.createElementBlock("option",z,t.toDisplayString(e.placeholder),1)):t.createCommentVNode("v-if",!0)],64)):t.createCommentVNode("v-if",!0),t.renderSlot(e.$slots,"default")],16,k),[[t.vModelSelect,e.computedValue]])],2),e.icon?(t.openBlock(),t.createBlock(r,{key:0,class:"is-left",icon:e.icon,pack:e.iconPack,size:e.iconSize},null,8,["icon","pack","size"])):t.createCommentVNode("v-if",!0)],16)}]]);const v={install(e){((e,t)=>{const i=t.name;if(null==i)throw new Error("Buefy.registerComponent: missing component name");e.component(i,t)})(e,C)}};e.BSelect=C,e.default=v,Object.defineProperty(e,"__esModule",{value:!0})}));