UNPKG

@ntohq/buefy-next

Version:

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

3 lines (2 loc) 12 kB
/*! 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).Message={},e.Vue)}(this,(function(e,t){"use strict";var a=t.defineComponent({props:{modelValue:{type:Boolean,default:!0},title:String,closable:{type:Boolean,default:!0},message:String,type:String,hasIcon:Boolean,size:String,icon:String,iconPack:String,iconSize:String,autoClose:{type:Boolean,default:!1},duration:{type:Number,default:2e3},progressBar:{type:Boolean,default:!1}},emits:{click:()=>!0,close:()=>!0,"update:modelValue":e=>!0},data(){return{isActive:this.modelValue,remainingTime:this.duration/1e3,newIconSize:this.iconSize||this.size||"is-large",timer:void 0}},computed:{computedIcon(){if(this.icon)return this.icon;switch(this.type){case"is-info":return"information";case"is-success":return"check-circle";case"is-warning":return"alert";case"is-danger":return"alert-circle";default:return null}}},watch:{modelValue(e){this.isActive=e},isActive(e){e?(this.setAutoClose(),this.setDurationProgress()):this.timer&&clearTimeout(this.timer)}},methods:{close(){this.isActive=!1,this.resetDurationProgress(),this.$emit("close"),this.$emit("update:modelValue",!1)},click(){this.$emit("click")},setAutoClose(){this.autoClose&&(this.timer=setTimeout((()=>{this.isActive&&this.close()}),this.duration))},setDurationProgress(){(this.progressBar||this.autoClose)&&(this.$buefy.globalNoticeInterval=setInterval((()=>{0!==this.remainingTime?this.remainingTime-=1:this.resetDurationProgress()}),1e3))},resetDurationProgress(){setTimeout((()=>{this.remainingTime=this.duration/1e3,clearInterval(this.$buefy.globalNoticeInterval)}),100)}},mounted(){this.setAutoClose()}});let o={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,n=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,s=(e,t,a)=>t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,u=(e,t)=>{for(var a in t||(t={}))l.call(t,a)&&s(e,a,t[a]);if(n)for(var a of n(t))r.call(t,a)&&s(e,a,t[a]);return e};const c=e=>"object"==typeof e&&!Array.isArray(e),d=(e,t,a=!1)=>{if(a||!Object.assign){const o=a=>c(t[a])&&null!==e&&Object.prototype.hasOwnProperty.call(e,a)&&c(e[a]),i=Object.getOwnPropertyNames(t).map((i=>({[i]:o(i)?d(e[i],t[i]||{},a):t[i]}))).reduce(((e,t)=>u(u({},e),t)),{});return u(u({},e),i)}return Object.assign(e,t)},f=d,m={sizes:{default:"mdi-24px","is-small":null,"is-medium":"mdi-36px","is-large":"mdi-48px"},iconPrefix:"mdi-"},p=()=>{const e=o&&o.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 h=()=>{let e={mdi:m,fa:p(),fas:p(),far:p(),fad:p(),fab:p(),fal:p(),"fa-solid":p(),"fa-regular":p(),"fa-light":p(),"fa-thin":p(),"fa-duotone":p(),"fa-brands":p()};return o&&o.customIconPacks&&(e=f(e,o.customIconPacks,!0)),e},g=(e,t)=>{const a=e.__vccOpts||e;for(const[e,o]of t)a[e]=o;return a};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 h()[this.newPack]},iconPrefix(){return this.iconConfig&&this.iconConfig.iconPrefix?this.iconConfig.iconPrefix:""},newIcon(){return`${this.iconPrefix}${this.getEquivalentIconOf(this.icon)}`},newPack(){return this.pack||o.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||o.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,a,o,i,n,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"]]);const k=Symbol("bprogress"),b=t.defineComponent({name:"BProgress",provide(){return{[k]:this}},props:{type:{type:[String,Object],default:"is-darkgrey"},size:{type:String},rounded:{type:Boolean,default:!0},value:{type:Number,default:void 0},max:{type:Number,default:100},showValue:{type:Boolean,default:!1},format:{type:String,default:"raw",validator:e=>["raw","percent"].indexOf(e)>=0},precision:{type:Number,default:2},keepTrailingZeroes:{type:Boolean,default:!1},locale:{type:[String,Array],default:()=>o.defaultLocale,validator:e=>Array.isArray(e)?e.every((e=>"string"==typeof e)):"string"==typeof e}},computed:{isIndeterminate(){return void 0===this.value||null===this.value},newType(){return[this.size,this.type,{"is-more-than-half":this.value&&this.value>this.max/2}]},newValue(){return this.calculateValue(this.value)},isNative(){return void 0===this.$slots.bar},wrapperClasses(){return{"is-not-native":!this.isNative,[void 0===this.size?"":this.size]:"string"==typeof this.size&&!this.isNative}}},watch:{isIndeterminate(e){this.$nextTick((()=>{this.$refs.progress&&(e?this.$refs.progress.removeAttribute("value"):this.$refs.progress.setAttribute("value",this.value.toString()))}))}},methods:{calculateValue(e){if(null==e||isNaN(e))return;const t=this.keepTrailingZeroes?this.precision:0,a=this.precision;return"percent"===this.format?new Intl.NumberFormat(this.locale,{style:"percent",minimumFractionDigits:t,maximumFractionDigits:a}).format(e/this.max):new Intl.NumberFormat(this.locale,{minimumFractionDigits:t,maximumFractionDigits:a}).format(e)}}});const v=["max","value"],C={key:2,class:"progress-value"};var B=g(b,[["render",function(e,a,o,i,n,l){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["progress-wrapper",[e.wrapperClasses,{"is-squared":!e.rounded}]])},[e.isNative?(t.openBlock(),t.createElementBlock("progress",{key:0,ref:"progress",class:t.normalizeClass(["progress",[e.newType,{"is-squared":!e.rounded}]]),max:e.max,value:e.value},t.toDisplayString(e.newValue),11,v)):t.renderSlot(e.$slots,"bar",{key:1}),e.isNative&&e.showValue?(t.openBlock(),t.createElementBlock("p",C,[t.renderSlot(e.$slots,"default",{},(()=>[t.createTextVNode(t.toDisplayString(e.newValue),1)]))])):t.createCommentVNode("v-if",!0)],2)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/progress/Progress.vue"]]);const w=t.defineComponent({name:"BMessage",components:{BIcon:y,BProgress:B},mixins:[a],props:{ariaCloseLabel:String}});const S={key:0,class:"message-header"},I={key:0},x={key:1},z=["aria-label"],P={key:1,class:"message-body"},N={class:"media"},D={key:0,class:"media-left"},T={class:"media-content"};var V=g(w,[["render",function(e,a,o,i,n,l){const r=t.resolveComponent("b-icon"),s=t.resolveComponent("b-progress");return t.openBlock(),t.createBlock(t.Transition,{name:"fade",persisted:""},{default:t.withCtx((()=>[t.withDirectives(t.createElementVNode("article",{class:t.normalizeClass(["message",[e.type,e.size]])},[e.$slots.header||e.title?(t.openBlock(),t.createElementBlock("header",S,[e.$slots.header?(t.openBlock(),t.createElementBlock("div",I,[t.renderSlot(e.$slots,"header")])):e.title?(t.openBlock(),t.createElementBlock("p",x,t.toDisplayString(e.title),1)):t.createCommentVNode("v-if",!0),e.closable?(t.openBlock(),t.createElementBlock("button",{key:2,type:"button",class:"delete",onClick:a[0]||(a[0]=(...t)=>e.close&&e.close(...t)),"aria-label":e.ariaCloseLabel},null,8,z)):t.createCommentVNode("v-if",!0)])):t.createCommentVNode("v-if",!0),e.$slots.default?(t.openBlock(),t.createElementBlock("section",P,[t.createElementVNode("div",N,[e.computedIcon&&e.hasIcon?(t.openBlock(),t.createElementBlock("div",D,[t.createVNode(r,{icon:e.computedIcon,pack:e.iconPack,class:t.normalizeClass(e.type),both:"",size:e.newIconSize},null,8,["icon","pack","class","size"])])):t.createCommentVNode("v-if",!0),t.createElementVNode("div",T,[t.renderSlot(e.$slots,"default")])])])):t.createCommentVNode("v-if",!0),e.progressBar?(t.openBlock(),t.createBlock(s,{key:2,class:"auto-close-progress",value:e.remainingTime-1,max:e.duration/1e3-1,type:e.type,rounded:!1},null,8,["value","max","type"])):t.createCommentVNode("v-if",!0)],2),[[t.vShow,e.isActive]])])),_:3})}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/message/Message.vue"]]);const O={install(e){((e,t,a)=>{const o=a||t.name;if(null==o)throw new Error("Buefy.registerComponent: missing component name");e.component(o,t)})(e,V)}};e.BMessage=V,e.default=O,Object.defineProperty(e,"__esModule",{value:!0})}));