You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
7.3 KiB
139 lines
7.3 KiB
import * as i0 from '@angular/core';
|
|
import { Component, ChangeDetectionStrategy, ViewEncapsulation, Input, ContentChildren, ViewChild, NgModule } from '@angular/core';
|
|
import * as i2 from '@angular/common';
|
|
import { CommonModule } from '@angular/common';
|
|
import * as i1 from 'primeng/api';
|
|
import { PrimeTemplate } from 'primeng/api';
|
|
import { ZIndexUtils } from 'primeng/utils';
|
|
import { DomHandler } from 'primeng/dom';
|
|
|
|
class BlockUI {
|
|
constructor(el, cd, config) {
|
|
this.el = el;
|
|
this.cd = cd;
|
|
this.config = config;
|
|
this.autoZIndex = true;
|
|
this.baseZIndex = 0;
|
|
}
|
|
get blocked() {
|
|
return this._blocked;
|
|
}
|
|
set blocked(val) {
|
|
if (this.mask && this.mask.nativeElement) {
|
|
if (val)
|
|
this.block();
|
|
else
|
|
this.unblock();
|
|
}
|
|
else {
|
|
this._blocked = val;
|
|
}
|
|
}
|
|
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() {
|
|
this._blocked = true;
|
|
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) {
|
|
ZIndexUtils.set('modal', this.mask.nativeElement, this.baseZIndex + this.config.zIndex.modal);
|
|
}
|
|
}
|
|
unblock() {
|
|
this.animationEndListener = this.destroyModal.bind(this);
|
|
this.mask.nativeElement.addEventListener('animationend', this.animationEndListener);
|
|
DomHandler.addClass(this.mask.nativeElement, 'p-component-overlay-leave');
|
|
}
|
|
destroyModal() {
|
|
this._blocked = false;
|
|
DomHandler.removeClass(this.mask.nativeElement, 'p-component-overlay-leave');
|
|
ZIndexUtils.clear(this.mask.nativeElement);
|
|
this.el.nativeElement.appendChild(this.mask.nativeElement);
|
|
this.unbindAnimationEndListener();
|
|
this.cd.markForCheck();
|
|
}
|
|
unbindAnimationEndListener() {
|
|
if (this.animationEndListener && this.mask) {
|
|
this.mask.nativeElement.removeEventListener('animationend', this.animationEndListener);
|
|
this.animationEndListener = null;
|
|
}
|
|
}
|
|
ngOnDestroy() {
|
|
this.unblock();
|
|
this.destroyModal();
|
|
}
|
|
}
|
|
BlockUI.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BlockUI, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1.PrimeNGConfig }], target: i0.ɵɵFactoryTarget.Component });
|
|
BlockUI.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: BlockUI, selector: "p-blockUI", inputs: { target: "target", autoZIndex: "autoZIndex", baseZIndex: "baseZIndex", styleClass: "styleClass", blocked: "blocked" }, host: { classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "mask", first: true, predicate: ["mask"], descendants: true }], ngImport: i0, template: `
|
|
<div #mask [class]="styleClass" [ngClass]="{'p-blockui-document':!target, 'p-blockui p-component-overlay p-component-overlay-enter': true}" [ngStyle]="{display: blocked ? 'flex' : 'none'}">
|
|
<ng-content></ng-content>
|
|
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
|
|
</div>
|
|
`, isInline: true, styles: [".p-blockui{position:absolute;top:0;left:0;width:100%;height:100%;background-color:transparent;transition-property:background-color;display:flex;align-items:center;justify-content:center}.p-blockui.p-component-overlay{position:absolute}.p-blockui-document.p-component-overlay{position:fixed}.p-blockui-leave.p-component-overlay{background-color:transparent}\n"], directives: [{ type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BlockUI, decorators: [{
|
|
type: Component,
|
|
args: [{ selector: 'p-blockUI', template: `
|
|
<div #mask [class]="styleClass" [ngClass]="{'p-blockui-document':!target, 'p-blockui p-component-overlay p-component-overlay-enter': true}" [ngStyle]="{display: blocked ? 'flex' : 'none'}">
|
|
<ng-content></ng-content>
|
|
<ng-container *ngTemplateOutlet="contentTemplate"></ng-container>
|
|
</div>
|
|
`, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
'class': 'p-element'
|
|
}, styles: [".p-blockui{position:absolute;top:0;left:0;width:100%;height:100%;background-color:transparent;transition-property:background-color;display:flex;align-items:center;justify-content:center}.p-blockui.p-component-overlay{position:absolute}.p-blockui-document.p-component-overlay{position:fixed}.p-blockui-leave.p-component-overlay{background-color:transparent}\n"] }]
|
|
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i1.PrimeNGConfig }]; }, 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.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BlockUIModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
BlockUIModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BlockUIModule, declarations: [BlockUI], imports: [CommonModule], exports: [BlockUI] });
|
|
BlockUIModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BlockUIModule, imports: [[CommonModule]] });
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BlockUIModule, decorators: [{
|
|
type: NgModule,
|
|
args: [{
|
|
imports: [CommonModule],
|
|
exports: [BlockUI],
|
|
declarations: [BlockUI]
|
|
}]
|
|
}] });
|
|
|
|
/**
|
|
* Generated bundle index. Do not edit.
|
|
*/
|
|
|
|
export { BlockUI, BlockUIModule };
|
|
//# sourceMappingURL=primeng-blockui.mjs.map
|