primeng
Version:
PrimeNG is an open source UI library for Angular featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeB
1,324 lines (1,300 loc) • 72 kB
JavaScript
import { animation, style, animate, trigger, transition, useAnimation } from '@angular/animations';
import * as i1 from '@angular/common';
import { isPlatformBrowser, CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Injectable, EventEmitter, inject, NgZone, booleanAttribute, numberAttribute, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, ViewChild, ContentChild, ContentChildren, NgModule } from '@angular/core';
import { uuid, blockBodyScroll, unblockBodyScroll, setAttribute, hasClass, addClass, getOuterWidth, getOuterHeight, getViewport, removeClass, appendChild } from '@primeuix/utils';
import { TranslationKeys, PrimeTemplate, SharedModule } from 'primeng/api';
import { BaseComponent } from 'primeng/basecomponent';
import { Button } from 'primeng/button';
import { DomHandler } from 'primeng/dom';
import { FocusTrap } from 'primeng/focustrap';
import { TimesIcon, WindowMaximizeIcon, WindowMinimizeIcon } from 'primeng/icons';
import { ZIndexUtils } from 'primeng/utils';
import { BaseStyle } from 'primeng/base';
const theme = ({ dt }) => `
.p-dialog {
max-height: 90%;
transform: scale(1);
border-radius: ${dt('dialog.border.radius')};
box-shadow: ${dt('dialog.shadow')};
background: ${dt('dialog.background')};
border: 1px solid ${dt('dialog.border.color')};
color: ${dt('dialog.color')};
display: flex;
flex-direction: column;
pointer-events: auto
}
.p-dialog-content {
overflow-y: auto;
padding: ${dt('dialog.content.padding')};
flex-grow: 1;
}
.p-dialog-header {
display: flex;
align-items: center;
justify-content: space-between;
flex-shrink: 0;
padding: ${dt('dialog.header.padding')};
}
.p-dialog-title {
font-weight: ${dt('dialog.title.font.weight')};
font-size: ${dt('dialog.title.font.size')};
}
.p-dialog-footer {
flex-shrink: 0;
padding: ${dt('dialog.footer.padding')};
display: flex;
justify-content: flex-end;
gap: ${dt('dialog.footer.gap')};
}
.p-dialog-header-actions {
display: flex;
align-items: center;
gap: ${dt('dialog.header.gap')};
}
.p-dialog-enter-active {
transition: all 150ms cubic-bezier(0, 0, 0.2, 1);
}
.p-dialog-leave-active {
transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}
.p-dialog-enter-from,
.p-dialog-leave-to {
opacity: 0;
transform: scale(0.7);
}
.p-dialog-top .p-dialog,
.p-dialog-bottom .p-dialog,
.p-dialog-left .p-dialog,
.p-dialog-right .p-dialog,
.p-dialog-topleft .p-dialog,
.p-dialog-topright .p-dialog,
.p-dialog-bottomleft .p-dialog,
.p-dialog-bottomright .p-dialog {
margin: 0.75rem;
transform: translate3d(0px, 0px, 0px);
}
.p-dialog-top .p-dialog-enter-active,
.p-dialog-top .p-dialog-leave-active,
.p-dialog-bottom .p-dialog-enter-active,
.p-dialog-bottom .p-dialog-leave-active,
.p-dialog-left .p-dialog-enter-active,
.p-dialog-left .p-dialog-leave-active,
.p-dialog-right .p-dialog-enter-active,
.p-dialog-right .p-dialog-leave-active,
.p-dialog-topleft .p-dialog-enter-active,
.p-dialog-topleft .p-dialog-leave-active,
.p-dialog-topright .p-dialog-enter-active,
.p-dialog-topright .p-dialog-leave-active,
.p-dialog-bottomleft .p-dialog-enter-active,
.p-dialog-bottomleft .p-dialog-leave-active,
.p-dialog-bottomright .p-dialog-enter-active,
.p-dialog-bottomright .p-dialog-leave-active {
transition: all 0.3s ease-out;
}
.p-dialog-top .p-dialog-enter-from,
.p-dialog-top .p-dialog-leave-to {
transform: translate3d(0px, -100%, 0px);
}
.p-dialog-bottom .p-dialog-enter-from,
.p-dialog-bottom .p-dialog-leave-to {
transform: translate3d(0px, 100%, 0px);
}
.p-dialog-left .p-dialog-enter-from,
.p-dialog-left .p-dialog-leave-to,
.p-dialog-topleft .p-dialog-enter-from,
.p-dialog-topleft .p-dialog-leave-to,
.p-dialog-bottomleft .p-dialog-enter-from,
.p-dialog-bottomleft .p-dialog-leave-to {
transform: translate3d(-100%, 0px, 0px);
}
.p-dialog-right .p-dialog-enter-from,
.p-dialog-right .p-dialog-leave-to,
.p-dialog-topright .p-dialog-enter-from,
.p-dialog-topright .p-dialog-leave-to,
.p-dialog-bottomright .p-dialog-enter-from,
.p-dialog-bottomright .p-dialog-leave-to {
transform: translate3d(100%, 0px, 0px);
}
.p-dialog-left:dir(rtl) .p-dialog-enter-from,
.p-dialog-left:dir(rtl) .p-dialog-leave-to,
.p-dialog-topleft:dir(rtl) .p-dialog-enter-from,
.p-dialog-topleft:dir(rtl) .p-dialog-leave-to,
.p-dialog-bottomleft:dir(rtl) .p-dialog-enter-from,
.p-dialog-bottomleft:dir(rtl) .p-dialog-leave-to {
transform: translate3d(100%, 0px, 0px);
}
.p-dialog-right:dir(rtl) .p-dialog-enter-from,
.p-dialog-right:dir(rtl) .p-dialog-leave-to,
.p-dialog-topright:dir(rtl) .p-dialog-enter-from,
.p-dialog-topright:dir(rtl) .p-dialog-leave-to,
.p-dialog-bottomright:dir(rtl) .p-dialog-enter-from,
.p-dialog-bottomright:dir(rtl) .p-dialog-leave-to {
transform: translate3d(-100%, 0px, 0px);
}
.p-dialog-maximized {
width: 100vw !important;
height: 100vh !important;
top: 0px !important;
left: 0px !important;
max-height: 100%;
height: 100%;
border-radius: 0;
}
.p-dialog-maximized .p-dialog-content {
flex-grow: 1;
}
.p-overlay-mask:dir(rtl) {
flex-direction: row-reverse;
}
/* For PrimeNG */
.p-dialog .p-resizable-handle {
position: absolute;
font-size: 0.1px;
display: block;
cursor: se-resize;
width: 12px;
height: 12px;
right: 1px;
bottom: 1px;
}
.p-confirm-dialog .p-dialog-content {
display: flex;
align-items: center;
}
`;
/* Position */
const inlineStyles = {
mask: ({ instance }) => ({
position: 'fixed',
height: '100%',
width: '100%',
left: 0,
top: 0,
display: 'flex',
justifyContent: instance.position === 'left' || instance.position === 'topleft' || instance.position === 'bottomleft'
? 'flex-start'
: instance.position === 'right' || instance.position === 'topright' || instance.position === 'bottomright'
? 'flex-end'
: 'center',
alignItems: instance.position === 'top' || instance.position === 'topleft' || instance.position === 'topright'
? 'flex-start'
: instance.position === 'bottom' || instance.position === 'bottomleft' || instance.position === 'bottomright'
? 'flex-end'
: 'center',
pointerEvents: instance.modal ? 'auto' : 'none'
}),
root: {
display: 'flex',
flexDirection: 'column',
pointerEvents: 'auto'
}
};
const classes = {
mask: ({ instance }) => {
const positions = ['left', 'right', 'top', 'topleft', 'topright', 'bottom', 'bottomleft', 'bottomright'];
const pos = positions.find((item) => item === instance.position);
return {
'p-dialog-mask': true,
'p-overlay-mask p-overlay-mask-enter': instance.modal,
[`p-dialog-${pos}`]: pos
};
},
root: ({ instance }) => ({ 'p-dialog p-component': true, 'p-dialog-maximized': instance.maximizable && instance.maximized }),
header: 'p-dialog-header',
title: 'p-dialog-title',
resizeHandle: 'p-resizable-handle',
headerActions: 'p-dialog-header-actions',
pcMaximizeButton: 'p-dialog-maximize-button',
pcCloseButton: 'p-dialog-close-button',
content: 'p-dialog-content',
footer: 'p-dialog-footer'
};
class DialogStyle extends BaseStyle {
name = 'dialog';
theme = theme;
classes = classes;
inlineStyles = inlineStyles;
static ɵfac = /*@__PURE__*/ (() => { let ɵDialogStyle_BaseFactory; return function DialogStyle_Factory(__ngFactoryType__) { return (ɵDialogStyle_BaseFactory || (ɵDialogStyle_BaseFactory = i0.ɵɵgetInheritedFactory(DialogStyle)))(__ngFactoryType__ || DialogStyle); }; })();
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DialogStyle, factory: DialogStyle.ɵfac });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DialogStyle, [{
type: Injectable
}], null, null); })();
/**
*
* Dialog is a container to display content in an overlay window.
*
* [Live Demo](https://www.primeng.org/dialog)
*
* @module dialogstyle
*
*/
var DialogClasses;
(function (DialogClasses) {
/**
* Class name of the mask element
*/
DialogClasses["mask"] = "p-dialog-mask";
/**
* Class name of the root element
*/
DialogClasses["root"] = "p-dialog";
/**
* Class name of the header element
*/
DialogClasses["header"] = "p-dialog-header";
/**
* Class name of the title element
*/
DialogClasses["title"] = "p-dialog-title";
/**
* Class name of the header actions element
*/
DialogClasses["headerActions"] = "p-dialog-header-actions";
/**
* Class name of the maximize button element
*/
DialogClasses["pcMaximizeButton"] = "p-dialog-maximize-button";
/**
* Class name of the close button element
*/
DialogClasses["pcCloseButton"] = "p-dialog-close-button";
/**
* Class name of the content element
*/
DialogClasses["content"] = "p-dialog-content";
/**
* Class name of the footer element
*/
DialogClasses["footer"] = "p-dialog-footer";
})(DialogClasses || (DialogClasses = {}));
const _c0 = ["header"];
const _c1 = ["content"];
const _c2 = ["footer"];
const _c3 = ["closeicon"];
const _c4 = ["maximizeicon"];
const _c5 = ["minimizeicon"];
const _c6 = ["headless"];
const _c7 = ["titlebar"];
const _c8 = ["*", [["p-footer"]]];
const _c9 = ["*", "p-footer"];
const _c10 = (a0, a1, a2) => ({ position: "fixed", height: "100%", width: "100%", left: 0, top: 0, display: "flex", "justify-content": a0, "align-items": a1, "pointer-events": a2 });
const _c11 = a0 => ({ "p-dialog p-component": true, "p-dialog-maximized": a0 });
const _c12 = () => ({ display: "flex", "flex-direction": "column", "pointer-events": "auto" });
const _c13 = (a0, a1) => ({ transform: a0, transition: a1 });
const _c14 = a0 => ({ value: "visible", params: a0 });
function Dialog_div_0_div_1_ng_container_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }
function Dialog_div_0_div_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainerStart(0);
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_container_2_ng_container_1_Template, 1, 0, "ng-container", 11);
i0.ɵɵelementContainerEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(3);
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r1._headlessTemplate || ctx_r1.headlessTemplate || ctx_r1.headlessT);
} }
function Dialog_div_0_div_1_ng_template_3_div_0_Template(rf, ctx) { if (rf & 1) {
const _r4 = i0.ɵɵgetCurrentView();
i0.ɵɵelementStart(0, "div", 19);
i0.ɵɵlistener("mousedown", function Dialog_div_0_div_1_ng_template_3_div_0_Template_div_mousedown_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r1.initResize($event)); });
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(4);
i0.ɵɵproperty("ngClass", ctx_r1.cx("resizeHandle"));
} }
function Dialog_div_0_div_1_ng_template_3_span_3_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "span", 20);
i0.ɵɵtext(1);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(4);
i0.ɵɵproperty("id", ctx_r1.ariaLabelledBy)("ngClass", ctx_r1.cx("title"));
i0.ɵɵadvance();
i0.ɵɵtextInterpolate(ctx_r1.header);
} }
function Dialog_div_0_div_1_ng_template_3_ng_container_4_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_span_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "span", 15);
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(5);
i0.ɵɵproperty("ngClass", ctx_r1.maximized ? ctx_r1.minimizeIcon : ctx_r1.maximizeIcon);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_2_WindowMaximizeIcon_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "WindowMaximizeIcon");
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_2_WindowMinimizeIcon_2_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "WindowMinimizeIcon");
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_2_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainerStart(0);
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_2_WindowMaximizeIcon_1_Template, 1, 0, "WindowMaximizeIcon", 22)(2, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_2_WindowMinimizeIcon_2_Template, 1, 0, "WindowMinimizeIcon", 22);
i0.ɵɵelementContainerEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(5);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", !ctx_r1.maximized && !ctx_r1._maximizeiconTemplate && !ctx_r1.maximizeIconTemplate && !ctx_r1.maximizeIconT);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1.maximized && !ctx_r1._minimizeiconTemplate && !ctx_r1.minimizeIconTemplate && !ctx_r1.minimizeIconT);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_3_1_ng_template_0_Template(rf, ctx) { }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_3_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵtemplate(0, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_3_1_ng_template_0_Template, 0, 0, "ng-template");
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_3_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainerStart(0);
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_3_1_Template, 1, 0, null, 11);
i0.ɵɵelementContainerEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(5);
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r1._maximizeiconTemplate || ctx_r1.maximizeIconTemplate || ctx_r1.maximizeIconT);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_4_1_ng_template_0_Template(rf, ctx) { }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_4_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵtemplate(0, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_4_1_ng_template_0_Template, 0, 0, "ng-template");
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_4_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainerStart(0);
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_4_1_Template, 1, 0, null, 11);
i0.ɵɵelementContainerEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(5);
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r1._minimizeiconTemplate || ctx_r1.minimizeIconTemplate || ctx_r1.minimizeIconT);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_6_Template(rf, ctx) { if (rf & 1) {
const _r5 = i0.ɵɵgetCurrentView();
i0.ɵɵelementStart(0, "p-button", 21);
i0.ɵɵlistener("onClick", function Dialog_div_0_div_1_ng_template_3_p_button_6_Template_p_button_onClick_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r1.maximize()); })("keydown.enter", function Dialog_div_0_div_1_ng_template_3_p_button_6_Template_p_button_keydown_enter_0_listener() { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r1.maximize()); });
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_template_3_p_button_6_span_1_Template, 1, 1, "span", 18)(2, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_2_Template, 3, 2, "ng-container", 22)(3, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_3_Template, 2, 1, "ng-container", 22)(4, Dialog_div_0_div_1_ng_template_3_p_button_6_ng_container_4_Template, 2, 1, "ng-container", 22);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(4);
i0.ɵɵproperty("styleClass", ctx_r1.cx("pcMaximizeButton"))("tabindex", ctx_r1.maximizable ? "0" : "-1")("ariaLabel", ctx_r1.maximizeLabel)("buttonProps", ctx_r1.maximizeButtonProps);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1.maximizeIcon && !ctx_r1._maximizeiconTemplate && !ctx_r1._minimizeiconTemplate);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", !ctx_r1.maximizeIcon && !(ctx_r1.maximizeButtonProps == null ? null : ctx_r1.maximizeButtonProps.icon));
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", !ctx_r1.maximized);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1.maximized);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_ng_container_0_span_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "span", 15);
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(7);
i0.ɵɵproperty("ngClass", ctx_r1.closeIcon);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_ng_container_0_TimesIcon_2_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelement(0, "TimesIcon");
} }
function Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_ng_container_0_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainerStart(0);
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_ng_container_0_span_1_Template, 1, 1, "span", 18)(2, Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_ng_container_0_TimesIcon_2_Template, 1, 0, "TimesIcon", 22);
i0.ɵɵelementContainerEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(6);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1.closeIcon);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", !ctx_r1.closeIcon);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_span_1_1_ng_template_0_Template(rf, ctx) { }
function Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_span_1_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵtemplate(0, Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_span_1_1_ng_template_0_Template, 0, 0, "ng-template");
} }
function Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_span_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "span");
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_span_1_1_Template, 1, 0, null, 11);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(6);
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r1._closeiconTemplate || ctx_r1.closeIconTemplate || ctx_r1.closeIconT);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵtemplate(0, Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_ng_container_0_Template, 3, 2, "ng-container", 22)(1, Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_span_1_Template, 2, 1, "span", 22);
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(5);
i0.ɵɵproperty("ngIf", !ctx_r1._closeiconTemplate && !ctx_r1.closeIconTemplate && !ctx_r1.closeIconT && !(ctx_r1.closeButtonProps == null ? null : ctx_r1.closeButtonProps.icon));
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1._closeiconTemplate || ctx_r1.closeIconTemplate || ctx_r1.closeIconT);
} }
function Dialog_div_0_div_1_ng_template_3_p_button_7_Template(rf, ctx) { if (rf & 1) {
const _r6 = i0.ɵɵgetCurrentView();
i0.ɵɵelementStart(0, "p-button", 23);
i0.ɵɵlistener("onClick", function Dialog_div_0_div_1_ng_template_3_p_button_7_Template_p_button_onClick_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r1.close($event)); })("keydown.enter", function Dialog_div_0_div_1_ng_template_3_p_button_7_Template_p_button_keydown_enter_0_listener($event) { i0.ɵɵrestoreView(_r6); const ctx_r1 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r1.close($event)); });
i0.ɵɵtemplate(1, Dialog_div_0_div_1_ng_template_3_p_button_7_ng_template_1_Template, 2, 2, "ng-template", null, 4, i0.ɵɵtemplateRefExtractor);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(4);
i0.ɵɵproperty("styleClass", ctx_r1.cx("pcCloseButton"))("ariaLabel", ctx_r1.closeAriaLabel)("tabindex", ctx_r1.closeTabindex)("buttonProps", ctx_r1.closeButtonProps);
} }
function Dialog_div_0_div_1_ng_template_3_ng_container_11_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }
function Dialog_div_0_div_1_ng_template_3_div_12_ng_container_3_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementContainer(0);
} }
function Dialog_div_0_div_1_ng_template_3_div_12_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 15, 5);
i0.ɵɵprojection(2, 1);
i0.ɵɵtemplate(3, Dialog_div_0_div_1_ng_template_3_div_12_ng_container_3_Template, 1, 0, "ng-container", 11);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(4);
i0.ɵɵproperty("ngClass", ctx_r1.cx("footer"));
i0.ɵɵadvance(3);
i0.ɵɵproperty("ngTemplateOutlet", ctx_r1._footerTemplate || ctx_r1.footerTemplate || ctx_r1.footerT);
} }
function Dialog_div_0_div_1_ng_template_3_Template(rf, ctx) { if (rf & 1) {
const _r3 = i0.ɵɵgetCurrentView();
i0.ɵɵtemplate(0, Dialog_div_0_div_1_ng_template_3_div_0_Template, 1, 1, "div", 12);
i0.ɵɵelementStart(1, "div", 13, 2);
i0.ɵɵlistener("mousedown", function Dialog_div_0_div_1_ng_template_3_Template_div_mousedown_1_listener($event) { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(3); return i0.ɵɵresetView(ctx_r1.initDrag($event)); });
i0.ɵɵtemplate(3, Dialog_div_0_div_1_ng_template_3_span_3_Template, 2, 3, "span", 14)(4, Dialog_div_0_div_1_ng_template_3_ng_container_4_Template, 1, 0, "ng-container", 11);
i0.ɵɵelementStart(5, "div", 15);
i0.ɵɵtemplate(6, Dialog_div_0_div_1_ng_template_3_p_button_6_Template, 5, 8, "p-button", 16)(7, Dialog_div_0_div_1_ng_template_3_p_button_7_Template, 3, 4, "p-button", 17);
i0.ɵɵelementEnd()();
i0.ɵɵelementStart(8, "div", 7, 3);
i0.ɵɵprojection(10);
i0.ɵɵtemplate(11, Dialog_div_0_div_1_ng_template_3_ng_container_11_Template, 1, 0, "ng-container", 11);
i0.ɵɵelementEnd();
i0.ɵɵtemplate(12, Dialog_div_0_div_1_ng_template_3_div_12_Template, 4, 2, "div", 18);
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext(3);
i0.ɵɵproperty("ngIf", ctx_r1.resizable);
i0.ɵɵadvance();
i0.ɵɵproperty("ngClass", ctx_r1.cx("header"));
i0.ɵɵadvance(2);
i0.ɵɵproperty("ngIf", !ctx_r1._headerTemplate && !ctx_r1.headerTemplate && !ctx_r1.headerT);
i0.ɵɵadvance();
i0.ɵɵproperty("ngTemplateOutlet", ctx_r1._headerTemplate || ctx_r1.headerTemplate || ctx_r1.headerT);
i0.ɵɵadvance();
i0.ɵɵproperty("ngClass", ctx_r1.cx("headerActions"));
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1.maximizable);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1.closable);
i0.ɵɵadvance();
i0.ɵɵclassMap(ctx_r1.contentStyleClass);
i0.ɵɵproperty("ngClass", ctx_r1.cx("content"))("ngStyle", ctx_r1.contentStyle);
i0.ɵɵattribute("data-pc-section", "content");
i0.ɵɵadvance(3);
i0.ɵɵproperty("ngTemplateOutlet", ctx_r1._contentTemplate || ctx_r1.contentTemplate || ctx_r1.contentT);
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1._footerTemplate || ctx_r1.footerTemplate || ctx_r1.footerT);
} }
function Dialog_div_0_div_1_Template(rf, ctx) { if (rf & 1) {
const _r1 = i0.ɵɵgetCurrentView();
i0.ɵɵelementStart(0, "div", 9, 0);
i0.ɵɵlistener("@animation.start", function Dialog_div_0_div_1_Template_div_animation_animation_start_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.onAnimationStart($event)); })("@animation.done", function Dialog_div_0_div_1_Template_div_animation_animation_done_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.onAnimationEnd($event)); });
i0.ɵɵtemplate(2, Dialog_div_0_div_1_ng_container_2_Template, 2, 1, "ng-container", 10)(3, Dialog_div_0_div_1_ng_template_3_Template, 13, 14, "ng-template", null, 1, i0.ɵɵtemplateRefExtractor);
i0.ɵɵelementEnd();
} if (rf & 2) {
const notHeadless_r7 = i0.ɵɵreference(4);
const ctx_r1 = i0.ɵɵnextContext(2);
i0.ɵɵstyleMap(ctx_r1.style);
i0.ɵɵclassMap(ctx_r1.styleClass);
i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(13, _c11, ctx_r1.maximizable && ctx_r1.maximized))("ngStyle", i0.ɵɵpureFunction0(15, _c12))("pFocusTrapDisabled", ctx_r1.focusTrap === false)("@animation", i0.ɵɵpureFunction1(19, _c14, i0.ɵɵpureFunction2(16, _c13, ctx_r1.transformOptions, ctx_r1.transitionOptions)));
i0.ɵɵattribute("role", ctx_r1.role)("aria-labelledby", ctx_r1.ariaLabelledBy)("aria-modal", true);
i0.ɵɵadvance(2);
i0.ɵɵproperty("ngIf", ctx_r1._headlessTemplate || ctx_r1.headlessTemplate || ctx_r1.headlessT)("ngIfElse", notHeadless_r7);
} }
function Dialog_div_0_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "div", 7);
i0.ɵɵtemplate(1, Dialog_div_0_div_1_Template, 5, 21, "div", 8);
i0.ɵɵelementEnd();
} if (rf & 2) {
const ctx_r1 = i0.ɵɵnextContext();
i0.ɵɵstyleMap(ctx_r1.maskStyle);
i0.ɵɵclassMap(ctx_r1.maskStyleClass);
i0.ɵɵproperty("ngClass", ctx_r1.maskClass)("ngStyle", i0.ɵɵpureFunction3(7, _c10, ctx_r1.position === "left" || ctx_r1.position === "topleft" || ctx_r1.position === "bottomleft" ? "flex-start" : ctx_r1.position === "right" || ctx_r1.position === "topright" || ctx_r1.position === "bottomright" ? "flex-end" : "center", ctx_r1.position === "top" || ctx_r1.position === "topleft" || ctx_r1.position === "topright" ? "flex-start" : ctx_r1.position === "bottom" || ctx_r1.position === "bottomleft" || ctx_r1.position === "bottomright" ? "flex-end" : "center", ctx_r1.modal ? "auto" : "none"));
i0.ɵɵadvance();
i0.ɵɵproperty("ngIf", ctx_r1.visible);
} }
const showAnimation = animation([style({ transform: '{{transform}}', opacity: 0 }), animate('{{transition}}')]);
const hideAnimation = animation([animate('{{transition}}', style({ transform: '{{transform}}', opacity: 0 }))]);
/**
* Dialog is a container to display content in an overlay window.
* @group Components
*/
class Dialog extends BaseComponent {
/**
* Title text of the dialog.
* @group Props
*/
header;
/**
* Enables dragging to change the position using header.
* @group Props
*/
draggable = true;
/**
* Enables resizing of the content.
* @group Props
*/
resizable = true;
/**
* Defines the left offset of dialog.
* @group Props
* @deprecated positionLeft property is deprecated.
*/
get positionLeft() {
return 0;
}
set positionLeft(_positionLeft) {
console.log('positionLeft property is deprecated.');
}
/**
* Defines the top offset of dialog.
* @group Props
* @deprecated positionTop property is deprecated.
*/
get positionTop() {
return 0;
}
set positionTop(_positionTop) {
console.log('positionTop property is deprecated.');
}
/**
* Style of the content section.
* @group Props
*/
contentStyle;
/**
* Style class of the content.
* @group Props
*/
contentStyleClass;
/**
* Defines if background should be blocked when dialog is displayed.
* @group Props
*/
modal = false;
/**
* Specifies if pressing escape key should hide the dialog.
* @group Props
*/
closeOnEscape = true;
/**
* Specifies if clicking the modal background should hide the dialog.
* @group Props
*/
dismissableMask = false;
/**
* When enabled dialog is displayed in RTL direction.
* @group Props
*/
rtl = false;
/**
* Adds a close icon to the header to hide the dialog.
* @group Props
*/
closable = true;
/**
* Defines if the component is responsive.
* @group Props
* @deprecated Responsive property is deprecated.
*/
get responsive() {
return false;
}
set responsive(_responsive) {
console.log('Responsive property is deprecated.');
}
/**
* Target element to attach the dialog, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).
* @group Props
*/
appendTo;
/**
* Object literal to define widths per screen size.
* @group Props
*/
breakpoints;
/**
* Style class of the component.
* @group Props
*/
styleClass;
/**
* Style class of the mask.
* @group Props
*/
maskStyleClass;
/**
* Style of the mask.
* @group Props
*/
maskStyle;
/**
* Whether to show the header or not.
* @group Props
*/
showHeader = true;
/**
* Defines the breakpoint of the component responsive.
* @group Props
* @deprecated Breakpoint property is not utilized and deprecated. Use breakpoints or CSS media queries instead.
*/
get breakpoint() {
return 649;
}
set breakpoint(_breakpoint) {
console.log('Breakpoint property is not utilized and deprecated, use breakpoints or CSS media queries instead.');
}
/**
* Whether background scroll should be blocked when dialog is visible.
* @group Props
*/
blockScroll = false;
/**
* Whether to automatically manage layering.
* @group Props
*/
autoZIndex = true;
/**
* Base zIndex value to use in layering.
* @group Props
*/
baseZIndex = 0;
/**
* Minimum value for the left coordinate of dialog in dragging.
* @group Props
*/
minX = 0;
/**
* Minimum value for the top coordinate of dialog in dragging.
* @group Props
*/
minY = 0;
/**
* When enabled, first focusable element receives focus on show.
* @group Props
*/
focusOnShow = true;
/**
* Whether the dialog can be displayed full screen.
* @group Props
*/
maximizable = false;
/**
* Keeps dialog in the viewport.
* @group Props
*/
keepInViewport = true;
/**
* When enabled, can only focus on elements inside the dialog.
* @group Props
*/
focusTrap = true;
/**
* Transition options of the animation.
* @group Props
*/
transitionOptions = '150ms cubic-bezier(0, 0, 0.2, 1)';
/**
* Name of the close icon.
* @group Props
*/
closeIcon;
/**
* Defines a string that labels the close button for accessibility.
* @group Props
*/
closeAriaLabel;
/**
* Index of the close button in tabbing order.
* @group Props
*/
closeTabindex = '0';
/**
* Name of the minimize icon.
* @group Props
*/
minimizeIcon;
/**
* Name of the maximize icon.
* @group Props
*/
maximizeIcon;
/**
* Used to pass all properties of the ButtonProps to the Button component.
* @group Props
*/
closeButtonProps = {
severity: 'secondary',
text: true,
rounded: true
};
/**
* Used to pass all properties of the ButtonProps to the Button component.
* @group Props
*/
maximizeButtonProps = {
severity: 'secondary',
text: true,
rounded: true
};
/**
* Specifies the visibility of the dialog.
* @group Props
*/
get visible() {
return this._visible;
}
set visible(value) {
this._visible = value;
if (this._visible && !this.maskVisible) {
this.maskVisible = true;
}
}
/**
* Inline style of the component.
* @group Props
*/
get style() {
return this._style;
}
set style(value) {
if (value) {
this._style = { ...value };
this.originalStyle = value;
}
}
/**
* Position of the dialog.
* @group Props
*/
get position() {
return this._position;
}
set position(value) {
this._position = value;
switch (value) {
case 'topleft':
case 'bottomleft':
case 'left':
this.transformOptions = 'translate3d(-100%, 0px, 0px)';
break;
case 'topright':
case 'bottomright':
case 'right':
this.transformOptions = 'translate3d(100%, 0px, 0px)';
break;
case 'bottom':
this.transformOptions = 'translate3d(0px, 100%, 0px)';
break;
case 'top':
this.transformOptions = 'translate3d(0px, -100%, 0px)';
break;
default:
this.transformOptions = 'scale(0.7)';
break;
}
}
/**
* Role attribute of html element.
* @group Emits
*/
role = 'dialog';
/**
* Callback to invoke when dialog is shown.
* @group Emits
*/
onShow = new EventEmitter();
/**
* Callback to invoke when dialog is hidden.
* @group Emits
*/
onHide = new EventEmitter();
/**
* This EventEmitter is used to notify changes in the visibility state of a component.
* @param {boolean} value - New value.
* @group Emits
*/
visibleChange = new EventEmitter();
/**
* Callback to invoke when dialog resizing is initiated.
* @param {MouseEvent} event - Mouse event.
* @group Emits
*/
onResizeInit = new EventEmitter();
/**
* Callback to invoke when dialog resizing is completed.
* @param {MouseEvent} event - Mouse event.
* @group Emits
*/
onResizeEnd = new EventEmitter();
/**
* Callback to invoke when dialog dragging is completed.
* @param {DragEvent} event - Drag event.
* @group Emits
*/
onDragEnd = new EventEmitter();
/**
* Callback to invoke when dialog maximized or unmaximized.
* @group Emits
*/
onMaximize = new EventEmitter();
headerViewChild;
contentViewChild;
footerViewChild;
/**
* Header template.
* @group Props
*/
headerTemplate;
/**
* Content template.
* @group Props
*/
contentTemplate;
/**
* Footer template.
* @group Props
*/
footerTemplate;
/**
* Close icon template.
* @group Props
*/
closeIconTemplate;
/**
* Maximize icon template.
* @group Props
*/
maximizeIconTemplate;
/**
* Minimize icon template.
* @group Props
*/
minimizeIconTemplate;
/**
* Headless template.
* @group Props
*/
headlessTemplate;
_headerTemplate;
_contentTemplate;
_footerTemplate;
_closeiconTemplate;
_maximizeiconTemplate;
_minimizeiconTemplate;
_headlessTemplate;
_visible = false;
maskVisible;
container;
wrapper;
dragging;
ariaLabelledBy = this.getAriaLabelledBy();
documentDragListener;
documentDragEndListener;
resizing;
documentResizeListener;
documentResizeEndListener;
documentEscapeListener;
maskClickListener;
lastPageX;
lastPageY;
preventVisibleChangePropagation;
maximized;
preMaximizeContentHeight;
preMaximizeContainerWidth;
preMaximizeContainerHeight;
preMaximizePageX;
preMaximizePageY;
id = uuid('pn_id_');
_style = {};
_position = 'center';
originalStyle;
transformOptions = 'scale(0.7)';
styleElement;
window;
_componentStyle = inject(DialogStyle);
headerT;
contentT;
footerT;
closeIconT;
maximizeIconT;
minimizeIconT;
headlessT;
get maximizeLabel() {
return this.config.getTranslation(TranslationKeys.ARIA)['maximizeLabel'];
}
zone = inject(NgZone);
get maskClass() {
const positions = ['left', 'right', 'top', 'topleft', 'topright', 'bottom', 'bottomleft', 'bottomright'];
const pos = positions.find((item) => item === this.position);
return {
'p-dialog-mask': true,
'p-overlay-mask p-overlay-mask-enter': this.modal || this.dismissableMask,
[`p-dialog-${pos}`]: pos
};
}
ngOnInit() {
super.ngOnInit();
if (this.breakpoints) {
this.createStyle();
}
}
templates;
ngAfterContentInit() {
this.templates?.forEach((item) => {
switch (item.getType()) {
case 'header':
this.headerT = item.template;
break;
case 'content':
this.contentT = item.template;
break;
case 'footer':
this.footerT = item.template;
break;
case 'closeicon':
this.closeIconT = item.template;
break;
case 'maximizeicon':
this.maximizeIconT = item.template;
break;
case 'minimizeicon':
this.minimizeIconT = item.template;
break;
case 'headless':
this.headlessT = item.template;
break;
default:
this.contentT = item.template;
break;
}
});
}
getAriaLabelledBy() {
return this.header !== null ? uuid('pn_id_') + '_header' : null;
}
parseDurationToMilliseconds(durationString) {
const transitionTimeRegex = /([\d\.]+)(ms|s)\b/g;
let totalMilliseconds = 0;
let match;
while ((match = transitionTimeRegex.exec(durationString)) !== null) {
const value = parseFloat(match[1]);
const unit = match[2];
if (unit === 'ms') {
totalMilliseconds += value;
}
else if (unit === 's') {
totalMilliseconds += value * 1000;
}
}
if (totalMilliseconds === 0) {
return undefined;
}
return totalMilliseconds;
}
_focus(focusParentElement) {
if (focusParentElement) {
const timeoutDuration = this.parseDurationToMilliseconds(this.transitionOptions);
let _focusableElements = DomHandler.getFocusableElements(focusParentElement);
if (_focusableElements && _focusableElements.length > 0) {
this.zone.runOutsideAngular(() => {
setTimeout(() => _focusableElements[0].focus(), timeoutDuration || 5);
});
return true;
}
}
return false;
}
focus(focusParentElement) {
let focused = this._focus(focusParentElement);
if (!focused) {
focused = this._focus(this.footerViewChild?.nativeElement);
if (!focused) {
focused = this._focus(this.headerViewChild?.nativeElement);
if (!focused) {
this._focus(this.contentViewChild?.nativeElement);
}
}
}
}
close(event) {
this.visibleChange.emit(false);
event.preventDefault();
}
enableModality() {
if (this.closable && this.dismissableMask) {
this.maskClickListener = this.renderer.listen(this.wrapper, 'mousedown', (event) => {
if (this.wrapper && this.wrapper.isSameNode(event.target)) {
this.close(event);
}
});
}
if (this.modal) {
blockBodyScroll();
}
}
disableModality() {
if (this.wrapper) {
if (this.dismissableMask) {
this.unbindMaskClickListener();
}
// for nested dialogs w/modal
const scrollBlockers = document.querySelectorAll('.p-dialog-mask-scrollblocker');
if (this.modal && scrollBlockers && scrollBlockers.length == 1) {
unblockBodyScroll();
}
if (!this.cd.destroyed) {
this.cd.detectChanges();
}
}
}
maximize() {
this.maximized = !this.maximized;
if (!this.modal && !this.blockScroll) {
if (this.maximized) {
blockBodyScroll();
}
else {
unblockBodyScroll();
}
}
this.onMaximize.emit({ maximized: this.maximized });
}
unbindMaskClickListener() {
if (this.maskClickListener) {
this.maskClickListener();
this.maskClickListener = null;
}
}
moveOnTop() {
if (this.autoZIndex) {
ZIndexUtils.set('modal', this.container, this.baseZIndex + this.config.zIndex.modal);
this.wrapper.style.zIndex = String(parseInt(this.container.style.zIndex, 10) - 1);
}
}
createStyle() {
if (isPlatformBrowser(this.platformId)) {
if (!this.styleElement) {
this.styleElement = this.renderer.createElement('style');
this.styleElement.type = 'text/css';
this.renderer.appendChild(this.document.head, this.styleElement);
let innerHTML = '';
for (let breakpoint in this.breakpoints) {
innerHTML += `
@media screen and (max-width: ${breakpoint}) {
.p-dialog[${this.id}]:not(.p-dialog-maximized) {
width: ${this.breakpoints[breakpoint]} !important;
}
}
`;
}
this.renderer.setProperty(this.styleElement, 'innerHTML', innerHTML);
setAttribute(this.styleElement, 'nonce', this.config?.csp()?.nonce);
}
}
}
initDrag(event) {
if (hasClass(event.target, 'p-dialog-maximize-icon') || hasClass(event.target, 'p-dialog-header-close-icon') || hasClass(event.target.parentElement, 'p-dialog-header-icon')) {
return;
}
if (this.draggable) {
this.dragging = true;
this.lastPageX = event.pageX;
this.lastPageY = event.pageY;
this.container.style.margin = '0';
addClass(this.document.body, 'p-unselectable-text');
}
}
onDrag(event) {
if (this.dragging) {
const containerWidth = getOuterWidth(this.container);
const containerHeight = getOuterHeight(this.container);
const deltaX = event.pageX - this.lastPageX;
const deltaY = event.pageY - this.lastPageY;
const offset = this.container.getBoundingClientRect();
const containerComputedStyle = getComputedStyle(this.container);
const leftMargin = parseFloat(containerComputedStyle.marginLeft);
const topMargin = parseFloat(containerComputedStyle.marginTop);
const leftPos = offset.left + deltaX - leftMargin;
const topPos = offset.top + deltaY - topMargin;
const viewport = getViewport();
this.container.style.position = 'fixed';
if (this.keepInViewport) {
if (leftPos >= this.minX && leftPos + containerWidth < viewport.width) {
this._style.left = `${leftPos}px`;
this.lastPageX = event.pageX;
this.container.style.left = `${leftPos}px`;
}
if (topPos >= this.minY && topPos + containerHeight < viewport.height) {
this._style.top = `${topPos}px`;
this.lastPageY = event.pageY;
this.container.style.top = `${topPos}px`;
}
}
else {
this.lastPageX = event.pageX;
this.container.style.left = `${leftPos}px`;
this.lastPageY = event.pageY;
this.container.style.top = `${topPos}px`;
}
}
}
endDrag(event) {
if (this.dragging) {
this.dragging = false;
removeClass(this.document.body, 'p-unselectable-text');
this.cd.detectChanges();
this.onDragEnd.emit(event);
}
}
resetPosition() {
this.container.style.position = '';
this.container.style.left = '';
this.container.style.top = '';
this.container.style.margin = '';
}
//backward compatibility
center() {
this.resetPosition();
}
initResize(event) {
if (this.resizable) {
this.resizing = true;
this.lastPageX = event.pageX;
this.lastPageY = event.pageY;
addClass(this.document.body, 'p-unselectable-text');
this.onResizeInit.emit(event);
}
}
onResize(event) {
if (this.resizing) {
let deltaX = event.pageX - this.lastPageX;
let deltaY = event.pageY - this.lastPageY;
let containerWidth = getOuterWidth(this.container);
let containerHeight = getOuterHeight(this.container);
let contentHeight = getOuterHeight(this.contentViewChild?.nativeElement);
let newWidth = containerWidth + deltaX;
let newHeight = containerHeight + deltaY;
let minWidth = this.container.style.minWidth;
let minHeight = this.container.style.minHeight;
let offset = this.container.getBoundingClientRect();
let viewport = getViewport();
let hasBeenDragged = !parseInt(this.container.style.top) || !parseInt(this.container.style.left);
if (hasBeenDragged) {
newWidth += deltaX;
newHeight += deltaY;
}
if ((!minWidth || newWidth > parseInt(minWidth)) && offset.left + newWidth < viewport.width) {
this._style.width = newWidth + 'px';
this.container.style.width = this._style.width;
}
if ((!minHeight || newHeight > parseInt(minHeight)) && offset.top + newHeight < viewport.height) {
this.contentViewChild.nativeElement.style.height = contentHeight + newHeight - containerHeight + 'px';
if (this._style.height) {
this._style.height = newHeight + 'px';
this.container.style.height = this._style.height;
}
}
this.lastPageX = event.pageX;
this.lastPageY = event.pageY;
}
}
resizeEnd(event) {
if (this.resizing) {
this.resizing = false;
removeClass(this.document.body, 'p-unselectable-text');
this.onResizeEnd.emit(event);
}
}
bindGlobalListeners() {
if (this.draggable) {
this.bindDocumentDragListener();
this.bindDocumentDragEndListener();
}
if (this.resizable) {
this.bindDocumentResizeListeners();
}
if (this.closeOnEscape && this.closable) {
this.bindDocumentEscapeListener();
}
}
unbindGlobalListeners() {
this.unbindDocumentDragListener();
this.unbindDocumentDragEndListener();
this.unbindDocumentResizeListeners();
this.unbindDocumentEscapeListener();
}
bindDocumentDragListener() {
if (!this.documentDragListener) {
this.zone.runOutsideAngular(() => {
this.documentDragListener = this.renderer.listen(this.document.defaultView, 'mousemove', this.onDrag.bind(this));
});
}
}
unbindDocumentDragListener() {
if (this.documentDragListener) {
this.documentDragListener();
this.documentDragListener = null;
}
}
bindDocumentDragEndListener() {
if (!this.documentDragEndListener) {
this.zone.runOutsideAngular(() => {
this.documentDragEndListener = this.renderer.listen(this.document.defaultView, 'mouseup', this.endDrag.bind(this));
});
}
}
unbindDocumentDragEndListener() {
if (this.documentDragEndListener) {
this.documentDragEndListener();
this.documentDragEndListener = null;
}
}
bindDocumentResizeListeners() {
if (!this.documentResizeListener && !this.documentResizeEndListener) {
this.zone.runOutsideAngular(() => {
this.documentResizeListener = this.renderer.listen(this.document.defaultView, 'mousemove', this.onResize.bind(this));
this.documentResizeEndListener = this.renderer.listen(this.document.defaultView, 'mouseup', this.resizeEnd.bind(this));
});
}
}
unbindDocumentResizeListeners() {
if (this.documentResizeListener && this.documentResizeEndListener) {
this.documentResizeListener();
this.documentResizeEndListener();
this.documentResizeListener = null;
this.documentResizeEndListener = null;
}
}
bindDocumentEscapeListener() {
const documentTarget = this.el ? this.el.nativeElement.ownerDocument : 'document';
this.documentEscapeListener = this.renderer.listen(documentTarget, 'keydown', (event) => {
if (event.key == 'Escape') {
this.close(event);
}
});
}
unbindDocumentEscapeListener() {
if (this.documentEscapeListener) {
this.documentEscapeListener();
this.documentEscapeListener = null;
}
}
appendContainer() {
if (this.appendTo) {
if (this.appendTo === 'body')
this.renderer.appendChild(this.document.body, this.wrapper);
else
appendChild(this.appendTo, this.wrapper);
}
}
restoreAppend() {
if (this.container && this.appendTo) {
this.renderer.appendChild(this.e