UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![npm downloads](https://img.shields.io/npm/dm/primeng.sv

104 lines (100 loc) 3.58 kB
import { Component, ChangeDetectionStrategy, ViewEncapsulation, ElementRef, ChangeDetectorRef, Input, ContentChildren, ViewChild, NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { DomHandler } from 'primeng/dom'; import { PrimeTemplate } from 'primeng/api'; class BlockUI { constructor(el, cd) { this.el = el; this.cd = cd; this.autoZIndex = true; this.baseZIndex = 0; } get blocked() { return this._blocked; } set blocked(val) { this._blocked = val; if (this.mask && this.mask.nativeElement) { if (this._blocked) this.block(); else this.unblock(); } } ngAfterViewInit() { if (this.target && !this.target.getBlockableElement) { throw 'Target of BlockUI must implement BlockableUI interface'; } } ngAfterContentInit() { this.templates.forEach((item) => { switch (item.getType()) { case 'content': this.contentTemplate = item.template; break; default: this.contentTemplate = item.template; break; } }); } block() { if (this.target) { this.target.getBlockableElement().appendChild(this.mask.nativeElement); this.target.getBlockableElement().style.position = 'relative'; } else { document.body.appendChild(this.mask.nativeElement); } if (this.autoZIndex) { this.mask.nativeElement.style.zIndex = String(this.baseZIndex + (++DomHandler.zindex)); } } unblock() { this.el.nativeElement.appendChild(this.mask.nativeElement); } ngOnDestroy() { this.unblock(); } } BlockUI.decorators = [ { type: Component, args: [{ selector: 'p-blockUI', template: ` <div #mask [class]="styleClass" [ngClass]="{'p-blockui-document':!target, 'p-blockui p-component-overlay': true}" [ngStyle]="{display: blocked ? 'flex' : 'none'}"> <ng-content></ng-content> <ng-container *ngTemplateOutlet="contentTemplate"></ng-container> </div> `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, styles: [".p-blockui{align-items:center;background-color:transparent;display:flex;height:100%;justify-content:center;left:0;top:0;transition-property:background-color;width:100%}.p-blockui,.p-blockui.p-component-overlay{position:absolute}.p-blockui-document.p-component-overlay{position:fixed}.p-blockui-leave.p-component-overlay{background-color:transparent}"] },] } ]; BlockUI.ctorParameters = () => [ { type: ElementRef }, { type: ChangeDetectorRef } ]; BlockUI.propDecorators = { target: [{ type: Input }], autoZIndex: [{ type: Input }], baseZIndex: [{ type: Input }], styleClass: [{ type: Input }], templates: [{ type: ContentChildren, args: [PrimeTemplate,] }], mask: [{ type: ViewChild, args: ['mask',] }], blocked: [{ type: Input }] }; class BlockUIModule { } BlockUIModule.decorators = [ { type: NgModule, args: [{ imports: [CommonModule], exports: [BlockUI], declarations: [BlockUI] },] } ]; /** * Generated bundle index. Do not edit. */ export { BlockUI, BlockUIModule }; //# sourceMappingURL=primeng-blockui.js.map