buefy
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
3 lines (2 loc) • 4 kB
JavaScript
/*! Buefy v3.0.2 | 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).Loading={},e.Vue)}(this,(function(e,t){"use strict";const o="undefined"==typeof window?Object:window.HTMLElement,n=t.defineComponent({name:"BLoading",props:{modelValue:Boolean,programmatic:Boolean,container:[Object,Function,o],isFullPage:{type:Boolean,default:!0},animation:{type:String,default:"fade"},canCancel:{type:Boolean,default:!1},onCancel:{type:Function,default:()=>{}}},emits:{close:()=>!0,"update:is-full-page":e=>!0,"update:modelValue":e=>!0},data(){return{isActive:this.modelValue||!1,displayInFullPage:this.isFullPage}},watch:{modelValue(e){this.isActive=e},isFullPage(e){this.displayInFullPage=e}},methods:{cancel(){this.canCancel&&this.isActive&&this.close()},close(...e){this.onCancel.apply(null,e),this.$emit("close"),this.$emit("update:modelValue",!1),this.programmatic&&(this.isActive=!1,setTimeout((()=>{var e;void 0!==(e=this.$el).remove?e.remove():void 0!==e.parentNode&&null!==e.parentNode&&e.parentNode.removeChild(e)}),150))},keyPress({key:e}){"Escape"!==e&&"Esc"!==e||this.cancel()}},created(){"undefined"!=typeof window&&document.addEventListener("keyup",this.keyPress)},mounted(){this.programmatic&&(this.container?(this.displayInFullPage=!1,this.$emit("update:is-full-page",!1),this.container.appendChild(this.$el)):document.body.appendChild(this.$el),this.isActive=!0)},beforeUnmount(){"undefined"!=typeof window&&document.removeEventListener("keyup",this.keyPress)}});var i=(e,t)=>{const o=e.__vccOpts||e;for(const[e,n]of t)o[e]=n;return o};const a=t.createElementVNode("div",{class:"loading-icon"},null,-1);var s=i(n,[["render",function(e,o,n,i,s,l){return t.openBlock(),t.createBlock(t.Transition,{name:e.animation},{default:t.withCtx((()=>[e.isActive?t.withDirectives((t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["loading-overlay is-active",{"is-full-page":e.displayInFullPage}])},[t.createElementVNode("div",{class:"loading-background",onClick:o[0]||(o[0]=(...t)=>e.cancel&&e.cancel(...t))}),t.renderSlot(e.$slots,"default",{},(()=>[a]))],2)),[[t.vShow,e.isActive]]):t.createCommentVNode("v-if",!0)])),_:3},8,["name"])}]]);var l=Object.defineProperty,r=Object.defineProperties,c=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,m=(e,t,o)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;class f{constructor(e){var t;m(this,"app"+"",t),this.app=e}open(e){const o=e,n=document.createElement("div"),i=t.createApp({data:()=>({loadingVNode:null}),methods:{close(){const e=function(e){if(!e)return;const{component:t}=e;return t?t.exposed&&t.exposeProxy||t.proxy:void 0}(this.loadingVNode);e&&e.close()}},render(){var e;return this.loadingVNode=t.h(s,(e=((e,t)=>{for(var o in t||(t={}))p.call(t,o)&&m(e,o,t[o]);if(d)for(var o of d(t))u.call(t,o)&&m(e,o,t[o]);return e})({},o),r(e,c({programmatic:!0,onClose(...e){o.onClose&&o.onClose(...e),setTimeout((()=>{i.unmount()}),150)}})))),this.loadingVNode}});return this.app&&function(e,t){const{_context:o}=e,{_context:n}=t;n.config=o.config,n.mixins=o.mixins,n.components=o.components,n.directives=o.directives,n.provides=o.provides,n.optionsCache=o.optionsCache,n.propsCache=o.propsCache,n.emitsCache=o.emitsCache,"__VUE_I18N_SYMBOL__"in e&&(t.__VUE_I18N_SYMBOL__=e.__VUE_I18N_SYMBOL__)}(this.app,i),i.mount(n)}}const h={install(e){((e,t)=>{const o=t.name;if(null==o)throw new Error("Buefy.registerComponent: missing component name");e.component(o,t)})(e,s),((e,t,o)=>{e.config.globalProperties.$buefy||(e.config.globalProperties.$buefy={}),e.config.globalProperties.$buefy[t]=o})(e,"loading",new f(e))}};e.BLoading=s,e.LoadingProgrammatic=f,e.default=h,Object.defineProperty(e,"__esModule",{value:!0})}));