@ntohq/buefy-next
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
3 lines (2 loc) • 16.8 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).Tabs={},e.Vue)}(this,(function(e,t){"use strict";let n={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};var i=Object.defineProperty,a=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(e,t,n)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,r=(e,t)=>{for(var n in t||(t={}))l.call(t,n)&&s(e,n,t[n]);if(a)for(var n of a(t))o.call(t,n)&&s(e,n,t[n]);return e};function u(e,t){return(e&t)===t}function c(e,t,n){return Math.max(t,Math.min(n,e))}const d=e=>"object"==typeof e&&!Array.isArray(e),f=(e,t,n=!1)=>{if(n||!Object.assign){const i=n=>d(t[n])&&null!==e&&Object.prototype.hasOwnProperty.call(e,n)&&d(e[n]),a=Object.getOwnPropertyNames(t).map((a=>({[a]:i(a)?f(e[a],t[a]||{},n):t[a]}))).reduce(((e,t)=>r(r({},e),t)),{});return r(r({},e),a)}return Object.assign(e,t)},p=f;function h(e){return null!=e&&null!=e.$&&null!=e.$.vnode}const m={sizes:{default:"mdi-24px","is-small":null,"is-medium":"mdi-36px","is-large":"mdi-48px"},iconPrefix:"mdi-"},b=()=>{const e=n&&n.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 v=()=>{let e={mdi:m,fa:b(),fas:b(),far:b(),fad:b(),fab:b(),fal:b(),"fa-solid":b(),"fa-regular":b(),"fa-light":b(),"fa-thin":b(),"fa-duotone":b(),"fa-brands":b()};return n&&n.customIconPacks&&(e=p(e,n.customIconPacks,!0)),e},y=(e,t)=>{const n=e.__vccOpts||e;for(const[e,i]of t)n[e]=i;return n};var g=y(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 v()[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.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||n.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,n,i,a,l,o){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"]]);"production"===process.env.NODE_ENV||Object.freeze({}),"production"===process.env.NODE_ENV||Object.freeze([]);const k=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},I=/-(\w)/g,x=k((e=>e.replace(I,((e,t)=>t?t.toUpperCase():"")))),C=/\B([A-Z])/g,w=k((e=>e.replace(C,"-$1").toLowerCase())),S=k((e=>e.charAt(0).toUpperCase()+e.slice(1))),T=k((e=>e?`on${S(e)}`:""));var B=t.defineComponent({name:"BSlotComponent",props:{component:{type:Object,required:!0},name:{type:String,default:"default"},scoped:{type:Boolean},props:{type:Object},tag:{type:String,default:"div"},event:{type:String,default:"vue:updated"}},data:()=>({updatedHook:void 0,handlerKey:void 0}),methods:{refresh(){this.$forceUpdate()}},created(){if(h(this.component))if("vue:updated"===this.event)this.updatedHook=t.onUpdated(this.refresh,this.component.$);else{const{vnode:e}=this.component.$;let t=T(this.event);if(null==e.props)e.props={[t]:this.refresh};else{const{props:n}=e;null==n[this.handlerKey]&&(t=T(x(this.event)),null==n[t]&&(t=T(w(this.event)))),null==n[t]?(t=T(this.event),n[t]=this.refresh):Array.isArray(n[t])?n[t].push(this.refresh):n[t]=[n[t],this.refresh]}this.handlerKey=t}},beforeUnmount(){if(h(this.component))if(null!=this.updatedHook){const e=this.component.$.u.indexOf(this.updatedHook);-1!==e&&this.component.$.u.splice(e,1)}else if(null!=this.handlerKey){const{props:e}=this.component.$.vnode;if(null!=e)if(Array.isArray(e[this.handlerKey])){const t=e[this.handlerKey].indexOf(this.refresh);t>-1&&(e[this.handlerKey].splice(t,1),1===e[this.handlerKey].length&&(e[this.handlerKey]=e[this.handlerKey][0]))}else delete e[this.handlerKey]}},render(){return t.h(this.tag,{},this.component.$slots?this.scoped?this.component.$slots[this.name](this.props):this.component.$slots[this.name]():void 0)}}),O=Object.defineProperty,P=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,z=(e,t,n)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var V,N=(e,t)=>{const n={provide(){return{["b"+e]:this}}};return void 0!==t&&u(t,1)&&(n.data=function(){return((e,t)=>{for(var n in t||(t={}))$.call(t,n)&&z(e,n,t[n]);if(P)for(var n of P(t))D.call(t,n)&&z(e,n,t[n]);return e})({childItems:[]},u(t,3)?{nextIndex:0}:{})},n.methods={_registerItem(e){u(t,3)&&(e.dynamicIndex=this.nextIndex,++this.nextIndex),this.childItems.push(e)},_unregisterItem(e){this.childItems=this.childItems.filter((t=>t.uniqueValue!==e.uniqueValue))}},u(t,3)&&(n.computed={sortedItems(){return this.childItems.slice().sort(((e,t)=>e.index-t.index))}})),n},j=t.defineComponent({name:"BTabs",components:{BIcon:g,BSlotComponent:B},mixins:[(V="tab",t.defineComponent({components:{BIcon:g,BSlotComponent:B},mixins:[N(V,3)],props:{modelValue:{type:[String,Number,null],default:void 0},size:String,animated:{type:Boolean,default:!0},animation:String,animateInitially:Boolean,vertical:{type:Boolean,default:!1},position:String,destroyOnHide:{type:Boolean,default:!1}},emits:{"update:modelValue":e=>!0},data(){return{activeId:this.modelValue,defaultSlots:[],contentHeight:0,isTransitioning:!1}},computed:{activeItem(){const e=this.childItems;return void 0===this.activeId?this.items[0]:null===this.activeId?null:e.find((e=>e.uniqueValue===this.activeId))},items(){return this.sortedItems}},watch:{modelValue(e){"number"==typeof e?(e=c(e,0,this.items.length-1),this.activeId=this.items[e].uniqueValue):this.activeId=e},activeId(e,t){const n=null!=t?this.childItems.find((e=>e.uniqueValue===t)):null;n&&this.activeItem&&(n.deactivate(this.activeItem.index),this.activeItem.activate(n.index)),(e=this.activeItem?"number"==typeof this.modelValue?this.items.indexOf(this.activeItem):this.activeItem.uniqueValue:void 0)!==this.modelValue&&this.$emit("update:modelValue",e)}},methods:{childClick(e){this.activeId=e.uniqueValue},getNextItemIdx(e,t=!1){let n=null;for(let i=0;i<this.items.length;i++){const a=this.items[i];if(e<a.index&&a.visible&&(!t||t&&!a.disabled)){n=a.index;break}}return n},getPrevItemIdx(e,t=!1){let n=null;for(let i=this.items.length-1;i>=0;i--){const a=this.items[i];if(a.index<e&&a.visible&&(!t||t&&!a.disabled)){n=a.index;break}}return n}},mounted(){if("number"==typeof this.modelValue){const e=c(this.modelValue,0,this.items.length-1);this.activeId=this.items[e].uniqueValue}else this.activeId=this.modelValue}}))],props:{expanded:{type:Boolean,default:()=>n.defaultTabsExpanded},type:{type:[String,Object],default:()=>n.defaultTabsType},animated:{type:Boolean,default:()=>n.defaultTabsAnimated},multiline:Boolean},data:()=>({currentFocus:null}),computed:{mainClasses(){return{"is-fullwidth":this.expanded,"is-vertical":this.vertical,"is-multiline":this.multiline,[this.position]:this.position&&this.vertical}},navClasses(){return[this.type,this.size,{[this.position]:this.position&&!this.vertical,"is-fullwidth":this.expanded,"is-toggle":"is-toggle-rounded"===this.type}]}},methods:{giveFocusToTab(e){Array.isArray(e)&&null==(e=e[0])||(e.$el&&e.$el.focus?e.$el.focus():e.focus&&e.focus())},manageTablistKeydown(e){const{key:t}=e;switch(t){case this.vertical?"ArrowUp":"ArrowLeft":case this.vertical?"Up":"Left":{let t=this.getPrevItemIdx(this.currentFocus,!0);null===t&&(t=this.getPrevItemIdx(1/0,!0));const n=this.items.find((e=>e.index===t));n&&this.$refs[`tabLink${t}`]&&!n.disabled&&this.giveFocusToTab(this.$refs[`tabLink${t}`]),e.preventDefault();break}case this.vertical?"ArrowDown":"ArrowRight":case this.vertical?"Down":"Right":{let t=this.getNextItemIdx(this.currentFocus,!0);null===t&&(t=this.getNextItemIdx(-1,!0));const n=this.items.find((e=>e.index===t));n&&this.$refs[`tabLink${t}`]&&!n.disabled&&this.giveFocusToTab(this.$refs[`tabLink${t}`]),e.preventDefault();break}}},manageTabKeydown(e,t){const{key:n}=e;switch(n){case" ":case"Space":case"Spacebar":case"Enter":this.childClick(t),e.preventDefault()}}}});const A=["aria-orientation"],E=["aria-controls","aria-selected"],F=["id","tabindex","onFocus","onClick","onKeydown"];var K=y(j,[["render",function(e,n,i,a,l,o){const s=t.resolveComponent("b-slot-component"),r=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["b-tabs",e.mainClasses])},[t.createElementVNode("nav",{class:t.normalizeClass(["tabs",e.navClasses]),onKeydown:n[0]||(n[0]=(...t)=>e.manageTablistKeydown&&e.manageTablistKeydown(...t))},[t.renderSlot(e.$slots,"start"),t.createElementVNode("ul",{"aria-orientation":e.vertical?"vertical":"horizontal",role:"tablist"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.items,(n=>t.withDirectives((t.openBlock(),t.createElementBlock("li",{key:n.uniqueValue,class:t.normalizeClass([n.headerClass,{"is-active":n.isActive,"is-disabled":n.disabled}]),role:"tab","aria-controls":`${n.uniqueValue}-content`,"aria-selected":`${n.isActive}`},[n.$slots.header?(t.openBlock(),t.createBlock(s,{key:0,ref_for:!0,ref:`tabLink${n.index}`,component:n,name:"header",tag:"a",id:`${n.uniqueValue}-label`,tabindex:n.isActive?0:-1,onFocus:t=>e.currentFocus=n.index,onClick:t=>e.childClick(n),onKeydown:t=>e.manageTabKeydown(t,n)},null,8,["component","id","tabindex","onFocus","onClick","onKeydown"])):(t.openBlock(),t.createElementBlock("a",{key:1,ref_for:!0,ref:`tabLink${n.index}`,id:`${n.uniqueValue}-label`,tabindex:n.isActive?0:-1,onFocus:t=>e.currentFocus=n.index,onClick:t=>e.childClick(n),onKeydown:t=>e.manageTabKeydown(t,n)},[n.icon?(t.openBlock(),t.createBlock(r,{key:0,icon:n.icon,pack:n.iconPack,size:e.size},null,8,["icon","pack","size"])):t.createCommentVNode("v-if",!0),t.createElementVNode("span",null,t.toDisplayString(n.label),1)],40,F))],10,E)),[[t.vShow,n.visible]]))),128))],8,A),t.renderSlot(e.$slots,"end")],34),t.createElementVNode("section",{class:t.normalizeClass(["tab-content",{"is-transitioning":e.isTransitioning}])},[t.renderSlot(e.$slots,"default")],2)],2)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/tabs/Tabs.vue"]]),q=Object.defineProperty,_=Object.defineProperties,L=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,U=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,W=(e,t)=>{for(var n in t||(t={}))R.call(t,n)&&U(e,n,t[n]);if(M)for(var n of M(t))H.call(t,n)&&U(e,n,t[n]);return e},Y=(e,t)=>_(e,L(t));var Q,Z=(e,t)=>{const n={inject:{parent:{from:"b"+e,default:""}},props:{value:{type:String,default:null}},computed:{uniqueValue(){return null!=this.value?this.value:this.$.uid}},created(){if(this.parent)this.parent._registerItem&&this.parent._registerItem(this);else if(void 0!==t&&!u(t,2))throw new Error("You should wrap "+this.$options.name+" in a "+e)},beforeUnmount(){this.parent&&this.parent._unregisterItem&&this.parent._unregisterItem(this)}};return void 0!==t&&u(t,1)&&(n.props=Y(W({},n.props),{order:{type:Number,required:!1}}),n.data=()=>({dynamicIndex:void 0}),n.computed=Y(W({},n.computed),{index(){return null!=this.order?this.order:this.dynamicIndex}})),n},G=y(t.defineComponent({name:"BTabItem",mixins:[(Q="tab",t.defineComponent({mixins:[Z(Q,1)],props:{label:String,icon:String,iconPack:String,visible:{type:Boolean,default:!0},headerClass:{type:[String,Array,Object],default:null}},data:()=>({transitionName:null,elementClass:"item",elementRole:null}),computed:{isActive(){return this.parent.activeItem===this}},methods:{activate(e){this.transitionName=this.index<e?this.parent.vertical?"slide-down":"slide-next":this.parent.vertical?"slide-up":"slide-prev"},deactivate(e){this.transitionName=e<this.index?this.parent.vertical?"slide-down":"slide-next":this.parent.vertical?"slide-up":"slide-prev"}},render(){var e;if(this.parent.destroyOnHide&&(!this.isActive||!this.visible))return;const n=t.withDirectives(t.h("div",{class:this.elementClass,role:this.elementRole,id:`${this.uniqueValue}-content`,"aria-labelledby":this.elementRole?`${this.uniqueValue}-label`:null,tabindex:this.isActive?0:-1},this.$slots),[[t.vShow,this.isActive&&this.visible]]);return this.parent.animated?t.h(t.Transition,{name:null!=(e=this.parent.animation||this.transitionName)?e:void 0,appear:!0===this.parent.animateInitially||void 0,onBeforeEnter:()=>{this.parent.isTransitioning=!0},onAfterEnter:()=>{this.parent.isTransitioning=!1}},{default:()=>n}):n}}))],props:{disabled:Boolean},data:()=>({elementClass:"tab-item",elementRole:"tabpanel"})}),[["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/tabs/TabItem.vue"]]);const J=(e,t,n)=>{const i=n||t.name;if(null==i)throw new Error("Buefy.registerComponent: missing component name");e.component(i,t)},X={install(e){J(e,K),J(e,G)}};e.BTabItem=G,e.BTabs=K,e.default=X,Object.defineProperty(e,"__esModule",{value:!0})}));