@ntohq/buefy-next
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
3 lines (2 loc) • 37.1 kB
JavaScript
/*! Buefy v0.2.0 | 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).Taginput={},e.Vue)}(this,(function(e,t){"use strict";var o=Object.defineProperty,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(e,t,i)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,a=(e,t)=>{for(var o in t||(t={}))n.call(t,o)&&l(e,o,t[o]);if(i)for(var o of i(t))s.call(t,o)&&l(e,o,t[o]);return e};function r(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:null),e)}const c=e=>"object"==typeof e&&!Array.isArray(e),d=(e,t,o=!1)=>{if(o||!Object.assign){const i=o=>c(t[o])&&null!==e&&Object.prototype.hasOwnProperty.call(e,o)&&c(e[o]),n=Object.getOwnPropertyNames(t).map((n=>({[n]:i(n)?d(e[n],t[n]||{},o):t[n]}))).reduce(((e,t)=>a(a({},e),t)),{});return a(a({},e),n)}return Object.assign(e,t)},u=d;let h={defaultContainerElement:null,defaultIconPack:"mdi",defaultIconComponent:null,defaultIconPrev:"chevron-left",defaultIconNext:"chevron-right",defaultLocale:void 0,defaultDialogConfirmText:null,defaultDialogCancelText:null,defaultSnackbarDuration:3500,defaultSnackbarPosition:null,defaultToastDuration:2e3,defaultToastPosition:null,defaultNotificationDuration:2e3,defaultNotificationPosition:null,defaultTooltipType:"is-primary",defaultTooltipDelay:null,defaultTooltipCloseDelay:null,defaultSidebarDelay:null,defaultInputAutocomplete:"on",defaultDateFormatter:null,defaultDateParser:null,defaultDateCreator:null,defaultTimeCreator:null,defaultDayNames:null,defaultMonthNames:null,defaultFirstDayOfWeek:null,defaultUnselectableDaysOfWeek:null,defaultTimeFormatter:null,defaultTimeParser:null,defaultDatetimeFormatter:null,defaultDatetimeParser:null,defaultDatetimeCreator:null,defaultClockpickerHoursLabel:null,defaultClockpickerMinutesLabel:null,defaultColorFormatter:null,defaultColorParser:null,defaultModalCanCancel:["escape","x","outside","button"],defaultModalScroll:null,defaultDatepickerMobileNative:!0,defaultTimepickerMobileNative:!0,defaultTimepickerMobileModal:!0,defaultNoticeQueue:!0,defaultInputHasCounter:!0,defaultCompatFallthrough:!0,defaultTaginputHasCounter:!0,defaultUseHtml5Validation:!0,defaultDropdownMobileModal:!0,defaultFieldLabelPosition:null,defaultDatepickerYearsRange:[-100,10],defaultDatepickerNearbyMonthDays:!0,defaultDatepickerNearbySelectableMonthDays:!1,defaultDatepickerShowWeekNumber:!1,defaultDatepickerWeekNumberClickable:!1,defaultDatepickerMobileModal:!0,defaultTrapFocus:!0,defaultAutoFocus:!0,defaultButtonRounded:!1,defaultSwitchRounded:!0,defaultCarouselInterval:3500,defaultTabsExpanded:!1,defaultTabsAnimated:!0,defaultTabsType:null,defaultStatusIcon:!0,defaultProgrammaticPromise:!1,defaultLinkTags:["a","button","input","router-link","nuxt-link","n-link","RouterLink","NuxtLink","NLink"],defaultImageWebpFallback:null,defaultImageLazy:!0,defaultImageResponsive:!0,defaultImageRatio:null,defaultImageSrcsetFormatter:null,defaultBreadcrumbTag:"a",defaultBreadcrumbAlign:"is-left",defaultBreadcrumbSeparator:"",defaultBreadcrumbSize:"is-medium",customIconPacks:null};const p={sizes:{default:"mdi-24px","is-small":null,"is-medium":"mdi-36px","is-large":"mdi-48px"},iconPrefix:"mdi-"},m=()=>{const e=h&&h.defaultIconComponent?"":"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 f=()=>{let e={mdi:p,fa:m(),fas:m(),far:m(),fad:m(),fab:m(),fal:m(),"fa-solid":m(),"fa-regular":m(),"fa-light":m(),"fa-thin":m(),"fa-duotone":m(),"fa-brands":m()};return h&&h.customIconPacks&&(e=u(e,h.customIconPacks,!0)),e},g=(e,t)=>{const o=e.__vccOpts||e;for(const[e,i]of t)o[e]=i;return o};var y=g(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 f()[this.newPack]},iconPrefix(){return this.iconConfig&&this.iconConfig.iconPrefix?this.iconConfig.iconPrefix:""},newIcon(){return`${this.iconPrefix}${this.getEquivalentIconOf(this.icon)}`},newPack(){return this.pack||h.defaultIconPack},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||h.defaultIconComponent}},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,o,i,n,s,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)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/icon/Icon.vue"]]),k=t.defineComponent({name:"BTag",components:{BIcon:y},props:{attached:Boolean,closable:Boolean,type:[String,Object],size:String,rounded:Boolean,disabled:Boolean,ellipsis:Boolean,tabstop:{type:Boolean,default:!0},ariaCloseLabel:String,icon:String,iconType:String,iconPack:String,closeType:String,closeIcon:String,closeIconPack:String,closeIconType:String},emits:{click:e=>!0,close:e=>!0},computed:{disabledOrUndefined(){return this.disabled||void 0}},methods:{close(e){this.disabled||this.$emit("close",e)},click(e){this.disabled||this.$emit("click",e)}}});const v={key:0,class:"tags has-addons inline-tags"},w=["aria-label","tabindex","disabled"],b=["aria-label","disabled","tabindex"];var C=g(k,[["render",function(e,o,i,n,s,l){const a=t.resolveComponent("b-icon");return e.attached&&e.closable?(t.openBlock(),t.createElementBlock("div",v,[t.createElementVNode("span",{class:t.normalizeClass(["tag",[e.type,e.size,{"is-rounded":e.rounded}]])},[e.icon?(t.openBlock(),t.createBlock(a,{key:0,icon:e.icon,size:e.size,type:e.iconType,pack:e.iconPack},null,8,["icon","size","type","pack"])):t.createCommentVNode("v-if",!0),t.createElementVNode("span",{class:t.normalizeClass({"has-ellipsis":e.ellipsis}),onClick:o[0]||(o[0]=(...t)=>e.click&&e.click(...t))},[t.renderSlot(e.$slots,"default")],2)],2),t.createElementVNode("a",{class:t.normalizeClass(["tag",[e.size,e.closeType,{"is-rounded":e.rounded},e.closeIcon?"has-delete-icon":"is-delete"]]),role:"button","aria-label":e.ariaCloseLabel,tabindex:e.tabstop?0:void 0,disabled:e.disabledOrUndefined,onClick:o[1]||(o[1]=(...t)=>e.close&&e.close(...t)),onKeyup:o[2]||(o[2]=t.withKeys(t.withModifiers(((...t)=>e.close&&e.close(...t)),["prevent"]),["delete"]))},[e.closeIcon?(t.openBlock(),t.createBlock(a,{key:0,"custom-class":"",icon:e.closeIcon,size:e.size,type:e.closeIconType,pack:e.closeIconPack},null,8,["icon","size","type","pack"])):t.createCommentVNode("v-if",!0)],42,w)])):(t.openBlock(),t.createElementBlock("span",{key:1,class:t.normalizeClass(["tag",[e.type,e.size,{"is-rounded":e.rounded}]])},[e.icon?(t.openBlock(),t.createBlock(a,{key:0,icon:e.icon,size:e.size,type:e.iconType,pack:e.iconPack},null,8,["icon","size","type","pack"])):t.createCommentVNode("v-if",!0),t.createElementVNode("span",{class:t.normalizeClass({"has-ellipsis":e.ellipsis}),onClick:o[3]||(o[3]=(...t)=>e.click&&e.click(...t))},[t.renderSlot(e.$slots,"default")],2),e.closable?(t.openBlock(),t.createElementBlock("a",{key:1,role:"button","aria-label":e.ariaCloseLabel,class:t.normalizeClass(["delete is-small",e.closeType]),disabled:e.disabledOrUndefined,tabindex:e.tabstop?0:void 0,onClick:o[4]||(o[4]=(...t)=>e.close&&e.close(...t)),onKeyup:o[5]||(o[5]=t.withKeys(t.withModifiers(((...t)=>e.close&&e.close(...t)),["prevent"]),["delete"]))},null,42,b)):t.createCommentVNode("v-if",!0)],2))}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/tag/Tag.vue"]]),S=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,T=t.defineComponent({inheritAttrs:!1,props:{compatFallthrough:{type:Boolean,default:()=>h.defaultCompatFallthrough}},computed:{rootAttrs(){return this.compatFallthrough?{class:this.$attrs.class,style:this.$attrs.style,id:this.$attrs.id}:{}},fallthroughAttrs(){if(this.compatFallthrough){return((e,t)=>{var o={};for(var i in e)B.call(e,i)&&t.indexOf(i)<0&&(o[i]=e[i]);if(null!=e&&S)for(var i of S(e))t.indexOf(i)<0&&x.call(e,i)&&(o[i]=e[i]);return o})(this.$attrs,["style","class","id"])}return this.$attrs}}});var V=t.defineComponent({props:{size:String,expanded:Boolean,loading:Boolean,rounded:Boolean,icon:String,iconPack:String,maxlength:[Number,String],useHtml5Validation:{type:Boolean,default:()=>h.defaultUseHtml5Validation},validationMessage:String,locale:{type:[String,Array],default:()=>h.defaultLocale},statusIcon:{type:Boolean,default:()=>h.defaultStatusIcon}},emits:{blur:e=>!0,focus:e=>!0},data(){return{isValid:!0,isFocused:!1,newIconPack:this.iconPack||h.defaultIconPack,_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)}}}),I=t.defineComponent({name:"BInput",components:{BIcon:y},mixins:[T,V],props:{modelValue:{type:[Number,String]},type:{type:String,default:"text"},lazy:{type:Boolean,default:!1},passwordReveal:Boolean,iconClickable:Boolean,hasCounter:{type:Boolean,default:()=>h.defaultInputHasCounter},customClass:{type:String,default:""},iconRight:String,iconRightClickable:Boolean,iconRightType:String,autocomplete:String},emits:{"icon-click":e=>!0,"icon-right-click":e=>!0,"update:modelValue":e=>!0},data(){return{newValue:this.modelValue,newType:this.type,newAutocomplete:this.autocomplete||h.defaultInputAutocomplete,isPasswordVisible:!1,_elementRef:"textarea"===this.type?"textarea":"input"}},computed:{computedValue:{get(){return this.newValue},set(e){this.newValue=e,this.$emit("update:modelValue",e)}},rootClasses(){return[this.iconPosition,this.size,{"is-expanded":this.expanded,"is-loading":this.loading,"is-clearfix":!this.hasMessage}]},inputClasses(){return[this.statusType,this.size,{"is-rounded":this.rounded}]},hasIconRight(){return this.passwordReveal||this.loading||this.statusIcon&&this.statusTypeIcon||this.iconRight},rightIcon(){return this.passwordReveal?this.passwordVisibleIcon:this.iconRight?this.iconRight:this.statusTypeIcon},rightIconType(){return this.passwordReveal?"is-primary":this.iconRight?this.iconRightType||void 0:this.statusType},iconPosition(){let e="";return this.icon&&(e+="has-icons-left "),this.hasIconRight&&(e+="has-icons-right"),e},statusTypeIcon(){switch(this.statusType){case"is-success":return"check";case"is-danger":return"alert-circle";case"is-info":return"information";case"is-warning":return"alert";default:return}},hasMessage(){return!!this.statusMessage},passwordVisibleIcon(){return this.isPasswordVisible?"eye-off":"eye"},valueLength(){return"string"==typeof this.computedValue?Array.from(this.computedValue).length:"number"==typeof this.computedValue?this.computedValue.toString().length:0}},watch:{modelValue(e){const t=this.computedValue!=e;this.newValue=e,t&&this.$nextTick((()=>{!this.isValid&&this.checkHtml5Validity()}))},type(e){this.newType=e}},methods:{togglePasswordVisibility(){this.isPasswordVisible=!this.isPasswordVisible,this.newType=this.isPasswordVisible?"text":"password",this.$nextTick((()=>{this.focus()}))},iconClick(e,t){this.$emit(e,t),this.$nextTick((()=>{this.focus()}))},rightIconClick(e){this.passwordReveal?this.togglePasswordVisibility():this.iconRightClickable&&this.iconClick("icon-right-click",e)},onInput(e){if(!this.lazy){const t=e.target.value;this.updateValue(t)}},onChange(e){if(this.lazy){const t=e.target.value;this.updateValue(t)}},updateValue(e){this.computedValue=e,!this.isValid&&this.checkHtml5Validity()}}});const $=["type","autocomplete","maxlength","value"],F=["maxlength","value"];var O=g(I,[["render",function(e,o,i,n,s,l){const a=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",t.mergeProps({class:["control",e.rootClasses]},e.rootAttrs),["textarea"!==e.type?(t.openBlock(),t.createElementBlock("input",t.mergeProps({key:0,ref:"input",class:["input",[e.inputClasses,e.customClass]],type:e.newType,autocomplete:e.newAutocomplete,maxlength:e.maxlength,value:e.computedValue},e.fallthroughAttrs,{onInput:o[0]||(o[0]=(...t)=>e.onInput&&e.onInput(...t)),onChange:o[1]||(o[1]=(...t)=>e.onChange&&e.onChange(...t)),onBlur:o[2]||(o[2]=(...t)=>e.onBlur&&e.onBlur(...t)),onFocus:o[3]||(o[3]=(...t)=>e.onFocus&&e.onFocus(...t))}),null,16,$)):(t.openBlock(),t.createElementBlock("textarea",t.mergeProps({key:1,ref:"textarea",class:["textarea",[e.inputClasses,e.customClass]],maxlength:e.maxlength,value:null===e.computedValue?void 0:e.computedValue},e.fallthroughAttrs,{onInput:o[4]||(o[4]=(...t)=>e.onInput&&e.onInput(...t)),onChange:o[5]||(o[5]=(...t)=>e.onChange&&e.onChange(...t)),onBlur:o[6]||(o[6]=(...t)=>e.onBlur&&e.onBlur(...t)),onFocus:o[7]||(o[7]=(...t)=>e.onFocus&&e.onFocus(...t))}),null,16,F)),e.icon?(t.openBlock(),t.createBlock(a,{key:2,class:t.normalizeClass(["is-left",{"is-clickable":e.iconClickable}]),icon:e.icon,pack:e.iconPack,size:e.iconSize,onClick:o[8]||(o[8]=t=>e.iconClick("icon-click",t))},null,8,["class","icon","pack","size"])):t.createCommentVNode("v-if",!0),!e.loading&&e.hasIconRight&&e.rightIcon?(t.openBlock(),t.createBlock(a,{key:3,class:t.normalizeClass(["is-right",{"is-clickable":e.passwordReveal||e.iconRightClickable}]),icon:e.rightIcon,pack:e.iconPack,size:e.iconSize,type:e.rightIconType,both:"",onClick:e.rightIconClick},null,8,["class","icon","pack","size","type","onClick"])):t.createCommentVNode("v-if",!0),e.maxlength&&e.hasCounter&&"number"!==e.type?(t.openBlock(),t.createElementBlock("small",{key:4,class:t.normalizeClass(["help counter",{"is-invisible":!e.isFocused}])},t.toDisplayString(e.valueLength)+" / "+t.toDisplayString(e.maxlength),3)):t.createCommentVNode("v-if",!0)],16)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/input/Input.vue"]]),z=t.defineComponent({name:"BAutocomplete",components:{BInput:O},mixins:[T,V],props:{modelValue:[Number,String,null],data:{type:Array,default:()=>[]},field:{type:String,default:"value"},keepFirst:Boolean,clearOnSelect:Boolean,openOnFocus:Boolean,customFormatter:{type:Function},checkInfiniteScroll:Boolean,keepOpen:Boolean,selectOnClickOutside:Boolean,clearable:Boolean,maxHeight:[String,Number],dropdownPosition:{type:String,default:"auto"},groupField:String,groupOptions:String,iconRight:String,iconRightClickable:Boolean,appendToBody:Boolean,type:{type:String,default:"text"},confirmKeys:{type:Array,default:()=>["Tab","Enter"]},selectableHeader:Boolean,selectableFooter:Boolean,autocomplete:String},emits:{active:e=>!0,blur:e=>!0,focus:e=>!0,"icon-click":e=>!0,"icon-right-click":e=>!0,"infinite-scroll":()=>!0,select:(e,t)=>!0,"select-footer":e=>!0,"select-header":e=>!0,typing:e=>!0,"update:modelValue":e=>!0},data(){return{selected:null,hovered:null,headerHovered:null,footerHovered:null,isActive:!1,newValue:this.modelValue,newAutocomplete:this.autocomplete||"off",ariaAutocomplete:this.keepFirst?"both":"list",isListInViewportVertically:!0,hasFocus:!1,style:{},_isAutocomplete:!0,_elementRef:"input",_bodyEl:void 0,timeOutID:void 0}},computed:{computedData(){const{groupField:e,groupOptions:t}=this;if(e){if(t){const o=[];return this.data.forEach((i=>{const n=r(i,e),s=r(i,t);o.push({group:n,items:s})})),o}{const t={};this.data.forEach((o=>{const i=r(o,e);t[i]||(t[i]=[]),t[i].push(o)}));const o=[];return Object.keys(t).forEach((e=>{o.push({group:e,items:t[e]})})),o}}return[{items:this.data}]},isEmpty(){return!this.computedData||!this.computedData.some((e=>e.items&&e.items.length))},whiteList(){var e;const t=[];if(t.push(this.$refs.input.$el.querySelector("input")),t.push(this.$refs.dropdown),null!=this.$refs.dropdown){const e=this.$refs.dropdown.querySelectorAll("*");for(const o of e)t.push(o)}if((null==(e=this.$parent)?void 0:e.$data)._isTaginput){t.push(this.$parent.$el);const e=this.$parent.$el.querySelectorAll("*");for(const o of e)t.push(o)}return t},hasDefaultSlot(){return!!this.$slots.default},hasGroupSlot(){return!!this.$slots.group},hasEmptySlot(){return!!this.$slots.empty},hasHeaderSlot(){return!!this.$slots.header},hasFooterSlot(){return!!this.$slots.footer},isOpenedTop(){return"top"===this.dropdownPosition||"auto"===this.dropdownPosition&&!this.isListInViewportVertically},newIconRight(){return this.clearable&&this.newValue?"close-circle":this.iconRight},newIconRightClickable(){return!!this.clearable||this.iconRightClickable},contentStyle(){return{maxHeight:(e=this.maxHeight,(void 0===e?null:isNaN(+e)?`${e}`:e+"px")||void 0)};var e}},watch:{isActive(e){"auto"===this.dropdownPosition&&(e?this.calcDropdownInViewportVertical():this.timeOutID=setTimeout((()=>{this.calcDropdownInViewportVertical()}),100)),this.$nextTick((()=>{this.$emit("active",e)}))},checkInfiniteScroll(e){if(!1===(this.$refs.dropdown&&this.$refs.dropdown.querySelector(".dropdown-content")))return;const t=this.$refs.dropdown.querySelector(".dropdown-content");!0!==e?t.removeEventListener("scroll",this.checkIfReachedTheEndOfScroll):t.addEventListener("scroll",this.checkIfReachedTheEndOfScroll)},newValue(e){this.$emit("update:modelValue",e);const t=this.getValue(this.selected);t&&t!==e&&this.setSelected(null,!1),!this.hasFocus||this.openOnFocus&&!e||(this.isActive=!!e)},modelValue(e){this.newValue=e},data(){if(this.keepFirst)this.$nextTick((()=>{this.isActive?this.selectFirstOption(this.computedData):this.setHovered(null)}));else if(this.hovered){const e=this.getValue(this.hovered);this.computedData.map((e=>e.items)).reduce(((e,t)=>[...e,...t]),[]).some((t=>this.getValue(t)===e))||this.setHovered(null)}}},methods:{setHovered(e){void 0!==e&&(this.hovered=e)},setSelected(e,t=!0,o){if(void 0!==e){if(this.selected=e,this.$emit("select",this.selected,o),null!==this.selected){if(this.clearOnSelect){const e=this.$refs.input;e.newValue="";e.$refs.input.value=""}else this.newValue=this.getValue(this.selected);this.setHovered(null)}t&&this.$nextTick((()=>{this.isActive=!1})),this.checkValidity()}},selectFirstOption(e){this.$nextTick((()=>{const t=e.filter((e=>e.items&&e.items.length));if(t.length){const e=t[0].items[0];this.setHovered(e)}else this.setHovered(null)}))},keydown(e){const{key:t}=e;if("Enter"===t&&e.preventDefault(),"Escape"!==t&&"Tab"!==t||(this.isActive=!1),this.confirmKeys.indexOf(t)>=0){","===t&&e.preventDefault();const o=!this.keepOpen||"Tab"===t;if(null===this.hovered)return void this.checkIfHeaderOrFooterSelected(e,null,o);this.setSelected(this.hovered,o,e)}},selectHeaderOrFoterByClick(e,t){this.checkIfHeaderOrFooterSelected(e,{origin:t})},checkIfHeaderOrFooterSelected(e,t,o=!0){this.selectableHeader&&(this.headerHovered||t&&"header"===t.origin)&&(this.$emit("select-header",e),this.headerHovered=!1,t&&this.setHovered(null),o&&(this.isActive=!1)),this.selectableFooter&&(this.footerHovered||t&&"footer"===t.origin)&&(this.$emit("select-footer",e),this.footerHovered=!1,t&&this.setHovered(null),o&&(this.isActive=!1))},clickedOutside(e){const t=null!=(o=this).$root&&"shadowRoot"in o.$root.$options?e.composedPath()[0]:e.target;var o;!this.hasFocus&&this.whiteList.indexOf(t)<0&&(this.keepFirst&&this.hovered&&this.selectOnClickOutside?this.setSelected(this.hovered,!0):this.isActive=!1)},getValue(e){if(null!==e)return void 0!==this.customFormatter?this.customFormatter(e):"object"==typeof e?r(e,this.field):e},checkIfReachedTheEndOfScroll(){const e=this.$refs.dropdown.querySelector(".dropdown-content"),t=this.hasFooterSlot?e.querySelectorAll("div.dropdown-footer")[0].clientHeight:0;e.clientHeight!==e.scrollHeight&&e.scrollTop+e.parentElement.clientHeight+t>=e.scrollHeight&&this.$emit("infinite-scroll")},calcDropdownInViewportVertical(){this.$nextTick((()=>{if(null==this.$refs.dropdown)return;const e=this.$refs.dropdown.getBoundingClientRect();this.isListInViewportVertically=e.top>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight),this.appendToBody&&this.updateAppendToBody()}))},keyArrows(e){const t="down"===e?1:-1;if(this.isActive){const e=this.computedData.map((e=>e.items)).reduce(((e,t)=>[...e,...t]),[]);let o;this.hasHeaderSlot&&this.selectableHeader&&e.unshift(void 0),this.hasFooterSlot&&this.selectableFooter&&e.push(void 0),o=this.headerHovered?0+t:this.footerHovered?e.length-1+t:e.indexOf(this.hovered)+t,o=o>e.length-1?e.length-1:o,o=o<0?0:o,this.footerHovered=!1,this.headerHovered=!1,this.setHovered(void 0!==e[o]?e[o]:null),this.hasFooterSlot&&this.selectableFooter&&o===e.length-1&&(this.footerHovered=!0),this.hasHeaderSlot&&this.selectableHeader&&0===o&&(this.headerHovered=!0);const i=this.$refs.dropdown.querySelector(".dropdown-content");let n="a.dropdown-item:not(.is-disabled)";this.hasHeaderSlot&&this.selectableHeader&&(n+=",div.dropdown-header"),this.hasFooterSlot&&this.selectableFooter&&(n+=",div.dropdown-footer");const s=i.querySelectorAll(n)[o];if(!s)return;const l=i.scrollTop,a=i.scrollTop+i.clientHeight-s.clientHeight;s.offsetTop<l?i.scrollTop=s.offsetTop:s.offsetTop>=a&&(i.scrollTop=s.offsetTop-i.clientHeight+s.clientHeight)}else this.isActive=!0},focused(e){this.getValue(this.selected)===this.newValue&&this.$el.querySelector("input").select(),this.openOnFocus&&(this.isActive=!0,this.keepFirst&&this.selectFirstOption(this.computedData)),this.hasFocus=!0,this.$emit("focus",e)},onBlur(e){this.hasFocus=!1,this.$emit("blur",e)},onInput(){const e=this.getValue(this.selected);e&&e===this.newValue||(this.$emit("typing",this.newValue),this.checkValidity())},rightIconClick(e){this.clearable?(this.newValue="",this.setSelected(null,!1),this.openOnFocus&&this.$refs.input.$el.focus()):this.$emit("icon-right-click",e)},checkValidity(){this.useHtml5Validation&&this.$nextTick((()=>{this.checkHtml5Validity()}))},updateAppendToBody(){const e=this.$refs.dropdown,t=this.$parent.$data._isTaginput?this.$parent.$el:this.$refs.input.$el;if(e&&t){const o=this.$data._bodyEl;o.classList.forEach((e=>o.classList.remove(e))),o.classList.add("autocomplete"),o.classList.add("control"),this.expanded&&o.classList.add("is-expanded");const i=t.getBoundingClientRect();let n=i.top+window.scrollY;const s=i.left+window.scrollX;this.isOpenedTop?n-=e.clientHeight:n+=t.clientHeight,this.style={position:"absolute",top:`${n}px`,left:`${s}px`,width:`${t.clientWidth}px`,maxWidth:`${t.clientWidth}px`,zIndex:"99"}}}},created(){"undefined"!=typeof window&&(document.addEventListener("click",this.clickedOutside),"auto"===this.dropdownPosition&&window.addEventListener("resize",this.calcDropdownInViewportVertical))},mounted(){if(this.checkInfiniteScroll&&this.$refs.dropdown&&this.$refs.dropdown.querySelector(".dropdown-content")){this.$refs.dropdown.querySelector(".dropdown-content").addEventListener("scroll",this.checkIfReachedTheEndOfScroll)}this.appendToBody&&(this.$data._bodyEl=function(e){const t=document.createElement("div");t.style.position="absolute",t.style.left="0px",t.style.top="0px",t.style.width="100%";const o=document.createElement("div");return t.appendChild(o),o.appendChild(e),document.body.appendChild(t),t}(this.$refs.dropdown),this.updateAppendToBody())},beforeUnmount(){if("undefined"!=typeof window&&(document.removeEventListener("click",this.clickedOutside),"auto"===this.dropdownPosition&&window.removeEventListener("resize",this.calcDropdownInViewportVertical)),this.checkInfiniteScroll&&this.$refs.dropdown&&this.$refs.dropdown.querySelector(".dropdown-content")){this.$refs.dropdown.querySelector(".dropdown-content").removeEventListener("scroll",this.checkIfReachedTheEndOfScroll)}var e;this.appendToBody&&(void 0!==(e=this.$data._bodyEl).remove?e.remove():void 0!==e.parentNode&&null!==e.parentNode&&e.parentNode.removeChild(e)),clearTimeout(this.timeOutID)}});const E={key:1,class:"has-text-weight-bold"},P=["onClick"],H={key:1},A={key:1,class:"dropdown-item is-disabled"};var D=g(z,[["render",function(e,o,i,n,s,l){const a=t.resolveComponent("b-input");return t.openBlock(),t.createElementBlock("div",t.mergeProps({class:["autocomplete control",{"is-expanded":e.expanded}]},e.rootAttrs),[t.createVNode(a,t.mergeProps({modelValue:e.newValue,"onUpdate:modelValue":o[0]||(o[0]=t=>e.newValue=t),ref:"input",type:e.type,size:e.size,loading:e.loading,rounded:e.rounded,icon:e.icon,"icon-right":e.newIconRight,"icon-right-clickable":e.newIconRightClickable,"icon-pack":e.iconPack,maxlength:e.maxlength,autocomplete:e.newAutocomplete,"use-html5-validation":!1,"aria-autocomplete":e.ariaAutocomplete},e.fallthroughAttrs,{"onUpdate:modelValue":e.onInput,onFocus:e.focused,onBlur:e.onBlur,onKeydown:[e.keydown,o[1]||(o[1]=t.withKeys(t.withModifiers((t=>e.keyArrows("up")),["prevent"]),["up"])),o[2]||(o[2]=t.withKeys(t.withModifiers((t=>e.keyArrows("down")),["prevent"]),["down"]))],onIconRightClick:e.rightIconClick,onIconClick:o[3]||(o[3]=t=>e.$emit("icon-click",t))}),null,16,["modelValue","type","size","loading","rounded","icon","icon-right","icon-right-clickable","icon-pack","maxlength","autocomplete","aria-autocomplete","onUpdate:modelValue","onFocus","onBlur","onKeydown","onIconRightClick"]),t.createVNode(t.Transition,{name:"fade",persisted:""},{default:t.withCtx((()=>[t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass(["dropdown-menu",{"is-opened-top":e.isOpenedTop&&!e.appendToBody}]),style:t.normalizeStyle(e.style),ref:"dropdown"},[t.withDirectives(t.createElementVNode("div",{class:"dropdown-content",style:t.normalizeStyle(e.contentStyle)},[e.hasHeaderSlot?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["dropdown-item dropdown-header",{"is-hovered":e.headerHovered}]),role:"button",tabindex:"0",onClick:o[4]||(o[4]=t=>e.selectHeaderOrFoterByClick(t,"header"))},[t.renderSlot(e.$slots,"header")],2)):t.createCommentVNode("v-if",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.computedData,((o,i)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[o.group?(t.openBlock(),t.createElementBlock("div",{key:i+"group",class:"dropdown-item"},[e.hasGroupSlot?t.renderSlot(e.$slots,"group",{key:0,group:o.group,index:i}):(t.openBlock(),t.createElementBlock("span",E,t.toDisplayString(o.group),1))])):t.createCommentVNode("v-if",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.items,((o,n)=>(t.openBlock(),t.createElementBlock("a",{key:i+":"+n,class:t.normalizeClass(["dropdown-item",{"is-hovered":o===e.hovered}]),role:"button",tabindex:"0",onClick:t.withModifiers((t=>e.setSelected(o,!e.keepOpen,t)),["stop"])},[e.hasDefaultSlot?t.renderSlot(e.$slots,"default",{key:0,option:o,index:n}):(t.openBlock(),t.createElementBlock("span",H,t.toDisplayString(e.getValue(o)),1))],10,P)))),128))],64)))),256)),e.isEmpty&&e.hasEmptySlot?(t.openBlock(),t.createElementBlock("div",A,[t.renderSlot(e.$slots,"empty")])):t.createCommentVNode("v-if",!0),e.hasFooterSlot?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["dropdown-item dropdown-footer",{"is-hovered":e.footerHovered}]),role:"button",tabindex:"0",onClick:o[5]||(o[5]=t=>e.selectHeaderOrFoterByClick(t,"footer"))},[t.renderSlot(e.$slots,"footer")],2)):t.createCommentVNode("v-if",!0)],4),[[t.vShow,e.isActive]])],6),[[t.vShow,e.isActive&&(!e.isEmpty||e.hasEmptySlot||e.hasHeaderSlot||e.hasFooterSlot)]])])),_:3})],16)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/autocomplete/Autocomplete.vue"]]),N=t.defineComponent({name:"BTaginput",components:{BAutocomplete:D,BTag:C},mixins:[T,V],props:{modelValue:{type:Array,default:()=>[]},data:{type:Array,default:()=>[]},type:String,closeType:String,attached:{type:Boolean,default:!1},maxtags:Number,hasCounter:{type:Boolean,default:()=>h.defaultTaginputHasCounter},field:{type:String,default:"value"},autocomplete:Boolean,groupField:String,groupOptions:String,nativeAutocomplete:String,openOnFocus:Boolean,keepOpen:{type:Boolean,default:!0},keepFirst:Boolean,disabled:Boolean,ellipsis:Boolean,closable:{type:Boolean,default:!0},ariaCloseLabel:String,confirmKeys:{type:Array,default:()=>[",","Tab","Enter"]},removeOnKeys:{type:Array,default:()=>["Backspace"]},allowNew:Boolean,onPasteSeparators:{type:Array,default:()=>[","]},beforeAdding:{type:Function,default:()=>!0},allowDuplicates:{type:Boolean,default:!1},checkInfiniteScroll:{type:Boolean,default:!1},createTag:{type:Function,default:e=>e},appendToBody:Boolean},emits:{add:e=>!0,"infinite-scroll":()=>!0,remove:e=>!0,typing:e=>!0,"update:modelValue":e=>!0},data(){return{tags:Array.isArray(this.modelValue)?this.modelValue.slice(0):this.modelValue||[],newTag:"",isComposing:!1,_elementRef:"autocomplete",_isTaginput:!0,requestID:null}},computed:{rootClasses(){return{"is-expanded":this.expanded}},containerClasses(){return{"is-focused":this.isFocused,"is-focusable":this.hasInput}},valueLength(){return this.newTag.trim().length},hasDefaultSlot(){return!!this.$slots.default},hasEmptySlot(){return!!this.$slots.empty},hasHeaderSlot(){return!!this.$slots.header},hasFooterSlot(){return!!this.$slots.footer},hasInput(){return null==this.maxtags||1===this.maxtags||this.tagsLength<this.maxtags},tagsLength(){return this.tags.length},separatorsAsRegExp(){const e=this.onPasteSeparators;return e.length?new RegExp(e.map((e=>e?e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):null)).join("|"),"g"):null},disabledOrUndefined(){return this.disabled||void 0}},watch:{modelValue(e){this.tags=Array.isArray(e)?e.slice(0):e||[]},hasInput(){this.hasInput||this.onBlur()}},methods:{addTag(e){const t=e||this.newTag.trim();if(t){if(!this.autocomplete){const e=this.separatorsAsRegExp;if(e&&t.match(e))return void t.split(e).map((e=>e.trim())).filter((e=>0!==e.length)).map(this.addTag)}(!!this.allowDuplicates||-1===this.tags.indexOf(t))&&this.beforeAdding(t)&&(1===this.maxtags&&(this.tags=[]),this.tags.push(this.createTag(t)),this.$emit("update:modelValue",this.tags),this.$emit("add",t)),this.requestID=requestAnimationFrame((()=>{this.newTag="",this.$emit("typing","")}))}},getNormalizedTagText(e){return"object"==typeof e&&(e=r(e,this.field)),`${e}`},customOnBlur(e){this.autocomplete||this.addTag(),this.onBlur(e)},onSelect(e){e&&(this.addTag(e),this.$nextTick((()=>{this.newTag=""})))},removeTag(e,t){const o=this.tags.splice(e,1)[0];return this.$emit("update:modelValue",this.tags),this.$emit("remove",o),t&&t.stopPropagation(),this.openOnFocus&&this.$refs.autocomplete&&this.$refs.autocomplete.focus(),o},removeLastTag(){this.tagsLength>0&&this.removeTag(this.tagsLength-1)},keydown(e){const{key:t}=e;if(-1===this.removeOnKeys.indexOf(t)||this.newTag.length||this.removeLastTag(),(!this.autocomplete||this.allowNew)&&this.confirmKeys.indexOf(t)>=0){if("Tab"!==t&&e.preventDefault(),"Enter"===t&&this.isComposing)return;this.addTag()}},onTyping(e){this.$emit("typing","number"==typeof e?e:null==e?void 0:e.trim())},emitInfiniteScroll(){this.$emit("infinite-scroll")}},beforeUnmount(){cancelAnimationFrame(this.requestID)}});const R=["disabled"],L={key:0,class:"help counter"};var _=g(N,[["render",function(e,o,i,n,s,l){const a=t.resolveComponent("b-tag"),r=t.resolveComponent("b-autocomplete");return t.openBlock(),t.createElementBlock("div",t.mergeProps({class:["taginput control",e.rootClasses]},e.rootAttrs),[t.createElementVNode("div",{class:t.normalizeClass(["taginput-container",[e.statusType,e.size,e.containerClasses]]),disabled:e.disabledOrUndefined,onClick:o[6]||(o[6]=t=>e.hasInput&&e.focus())},[t.renderSlot(e.$slots,"selected",{tags:e.tags},(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.tags,((o,i)=>(t.openBlock(),t.createBlock(a,{key:e.getNormalizedTagText(o)+i,type:e.type,"close-type":e.closeType,size:e.size,rounded:e.rounded,attached:e.attached,tabstop:!1,disabled:e.disabledOrUndefined,ellipsis:e.ellipsis,closable:e.closable,"aria-close-label":e.ariaCloseLabel,title:e.ellipsis&&e.getNormalizedTagText(o),onClose:t=>e.removeTag(i,t)},{default:t.withCtx((()=>[t.renderSlot(e.$slots,"tag",{tag:o},(()=>[t.createTextVNode(t.toDisplayString(e.getNormalizedTagText(o)),1)]))])),_:2},1032,["type","close-type","size","rounded","attached","disabled","ellipsis","closable","aria-close-label","title","onClose"])))),128))])),e.hasInput?(t.openBlock(),t.createBlock(r,t.mergeProps({key:0,ref:"autocomplete",modelValue:e.newTag,"onUpdate:modelValue":o[0]||(o[0]=t=>e.newTag=t)},e.fallthroughAttrs,{data:e.data,field:e.field,icon:e.icon,"icon-pack":e.iconPack,maxlength:e.maxlength,"has-counter":!1,size:e.size,disabled:e.disabledOrUndefined,loading:e.loading,autocomplete:e.nativeAutocomplete,"open-on-focus":e.openOnFocus,"keep-open":e.keepOpen,"keep-first":e.keepFirst,"group-field":e.groupField,"group-options":e.groupOptions,"use-html5-validation":e.useHtml5Validation,"check-infinite-scroll":e.checkInfiniteScroll,"append-to-body":e.appendToBody,"confirm-keys":e.confirmKeys,onTyping:e.onTyping,onFocus:o[1]||(o[1]=t=>e.onFocus(t)),onBlur:o[2]||(o[2]=t=>e.customOnBlur(t)),onKeydown:o[3]||(o[3]=t=>e.keydown(t)),onCompositionstart:o[4]||(o[4]=t=>e.isComposing=!0),onCompositionend:o[5]||(o[5]=t=>e.isComposing=!1),onSelect:e.onSelect,onInfiniteScroll:e.emitInfiniteScroll}),t.createSlots({_:2},[e.hasHeaderSlot?{name:"header",fn:t.withCtx((()=>[t.renderSlot(e.$slots,"header")])),key:"0"}:void 0,e.hasDefaultSlot?{name:"default",fn:t.withCtx((o=>[t.renderSlot(e.$slots,"default",{option:o.option,index:o.index})])),key:"1"}:void 0,e.hasEmptySlot?{name:"empty",fn:t.withCtx((()=>[t.renderSlot(e.$slots,"empty")])),key:"2"}:void 0,e.hasFooterSlot?{name:"footer",fn:t.withCtx((()=>[t.renderSlot(e.$slots,"footer")])),key:"3"}:void 0]),1040,["modelValue","data","field","icon","icon-pack","maxlength","size","disabled","loading","autocomplete","open-on-focus","keep-open","keep-first","group-field","group-options","use-html5-validation","check-infinite-scroll","append-to-body","confirm-keys","onTyping","onSelect","onInfiniteScroll"])):t.createCommentVNode("v-if",!0)],10,R),e.hasCounter&&(e.maxtags||e.maxlength)?(t.openBlock(),t.createElementBlock("small",L,[e.maxlength&&e.valueLength>0?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createTextVNode(t.toDisplayString(e.valueLength)+" / "+t.toDisplayString(e.maxlength),1)],64)):e.maxtags?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createTextVNode(t.toDisplayString(e.tagsLength)+" / "+t.toDisplayString(e.maxtags),1)],64)):t.createCommentVNode("v-if",!0)])):t.createCommentVNode("v-if",!0)],16)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/taginput/Taginput.vue"]]);const M={install(e){((e,t,o)=>{const i=o||t.name;if(null==i)throw new Error("Buefy.registerComponent: missing component name");e.component(i,t)})(e,_)}};e.BTaginput=_,e.default=M,Object.defineProperty(e,"__esModule",{value:!0})}));