UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 2.35 kB
import{DomHandler as e,ZIndexUtils as t}from"primevue/utils";import{openBlock as o,createBlock as n,renderSlot as i}from"vue";var s={name:"BlockUI",emits:["block","unblock"],props:{blocked:{type:Boolean,default:!1},fullScreen:{type:Boolean,default:!1},baseZIndex:{type:Number,default:0},autoZIndex:{type:Boolean,default:!0}},mask:null,mounted(){this.blocked&&this.block()},watch:{blocked(e){!0===e?this.block():this.unblock()}},methods:{block(){this.fullScreen?(this.mask=document.createElement("div"),this.mask.setAttribute("class","p-blockui p-blockui-document"),document.body.appendChild(this.mask),e.addClass(document.body,"p-overflow-hidden"),document.activeElement.blur()):(this.mask=document.createElement("div"),this.mask.setAttribute("class","p-blockui"),this.$refs.container.appendChild(this.mask)),this.mask&&setTimeout((()=>{e.addClass(this.mask,"p-component-overlay")}),1),this.autoZIndex&&t.set("modal",this.mask,this.baseZIndex+this.$primevue.config.zIndex.modal),this.$emit("block")},unblock(){e.addClass(this.mask,"p-blockui-leave"),this.mask.addEventListener("transitionend",(()=>{this.removeMask()}))},removeMask(){t.clear(this.mask),this.fullScreen?(document.body.removeChild(this.mask),e.removeClass(document.body,"p-overflow-hidden")):this.$refs.container.removeChild(this.mask),this.$emit("unblock")}}};const a={ref:"container",class:"p-blockui-container"};!function(e,t){void 0===t&&(t={});var o=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}("\n.p-blockui-container {\n position: relative;\n}\n.p-blockui {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: transparent;\n -webkit-transition-property: background-color;\n transition-property: background-color;\n}\n.p-blockui.p-component-overlay {\n position: absolute;\n}\n.p-blockui-document.p-component-overlay {\n position: fixed;\n}\n.p-blockui.p-blockui-leave.p-component-overlay {\n background-color: transparent;\n}\n"),s.render=function(e,t,s,l,d,c){return o(),n("div",a,[i(e.$slots,"default")],512)};export default s;