(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/animations'), require('@angular/common'), require('primeng/ripple'), require('primeng/dom'), require('primeng/api')) : typeof define === 'function' && define.amd ? define('primeng/sidebar', ['exports', '@angular/core', '@angular/animations', '@angular/common', 'primeng/ripple', 'primeng/dom', 'primeng/api'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.primeng = global.primeng || {}, global.primeng.sidebar = {}), global.ng.core, global.ng.animations, global.ng.common, global.primeng.ripple, global.primeng.dom, global.primeng.api)); }(this, (function (exports, core, animations, common, ripple, dom, api) { 'use strict'; var Sidebar = /** @class */ (function () { function Sidebar(el, renderer, cd) { this.el = el; this.renderer = renderer; this.cd = cd; this.position = 'left'; this.blockScroll = false; this.autoZIndex = true; this.baseZIndex = 0; this.modal = true; this.dismissible = true; this.showCloseIcon = true; this.closeOnEscape = true; this.onShow = new core.EventEmitter(); this.onHide = new core.EventEmitter(); this.visibleChange = new core.EventEmitter(); } Sidebar.prototype.ngAfterViewInit = function () { this.initialized = true; if (this.appendTo) { if (this.appendTo === 'body') document.body.appendChild(this.containerViewChild.nativeElement); else dom.DomHandler.appendChild(this.containerViewChild.nativeElement, this.appendTo); } if (this.visible) { this.show(); } }; Sidebar.prototype.ngAfterContentInit = function () { var _this = this; this.templates.forEach(function (item) { switch (item.getType()) { case 'content': _this.contentTemplate = item.template; break; default: _this.contentTemplate = item.template; break; } }); }; Object.defineProperty(Sidebar.prototype, "visible", { get: function () { return this._visible; }, set: function (val) { this._visible = val; if (this.initialized && this.containerViewChild && this.containerViewChild.nativeElement) { if (this._visible) this.show(); else { if (this.preventVisibleChangePropagation) this.preventVisibleChangePropagation = false; else this.hide(); } } }, enumerable: false, configurable: true }); Sidebar.prototype.ngAfterViewChecked = function () { if (this.executePostDisplayActions) { this.onShow.emit({}); this.executePostDisplayActions = false; } }; Sidebar.prototype.show = function () { this.executePostDisplayActions = true; if (this.autoZIndex) { this.containerViewChild.nativeElement.style.zIndex = String(this.baseZIndex + (++dom.DomHandler.zindex)); } if (this.modal) { this.enableModality(); } }; Sidebar.prototype.hide = function () { this.onHide.emit({}); if (this.modal) { this.disableModality(); } }; Sidebar.prototype.close = function (event) { this.preventVisibleChangePropagation = true; this.hide(); this.visibleChange.emit(false); event.preventDefault(); }; Sidebar.prototype.enableModality = function () { var _this = this; if (!this.mask) { this.mask = document.createElement('div'); this.mask.style.zIndex = String(parseInt(this.containerViewChild.nativeElement.style.zIndex) - 1); dom.DomHandler.addMultipleClasses(this.mask, 'p-component-overlay p-sidebar-mask'); if (this.dismissible) { this.maskClickListener = this.renderer.listen(this.mask, 'click', function (event) { if (_this.dismissible) { _this.close(event); } }); } document.body.appendChild(this.mask); if (this.blockScroll) { dom.DomHandler.addClass(document.body, 'p-overflow-hidden'); } } }; Sidebar.prototype.disableModality = function () { if (this.mask) { this.unbindMaskClickListener(); document.body.removeChild(this.mask); if (this.blockScroll) { dom.DomHandler.removeClass(document.body, 'p-overflow-hidden'); } this.mask = null; } }; Sidebar.prototype.onAnimationStart = function (event) { switch (event.toState) { case 'visible': if (this.closeOnEscape) { this.bindDocumentEscapeListener(); } break; case 'hidden': this.unbindGlobalListeners(); break; } }; Sidebar.prototype.bindDocumentEscapeListener = function () { var _this = this; var documentTarget = this.el ? this.el.nativeElement.ownerDocument : 'document'; this.documentEscapeListener = this.renderer.listen(documentTarget, 'keydown', function (event) { if (event.which == 27) { if (parseInt(_this.containerViewChild.nativeElement.style.zIndex) === (dom.DomHandler.zindex + _this.baseZIndex)) { _this.close(event); } } }); }; Sidebar.prototype.unbindDocumentEscapeListener = function () { if (this.documentEscapeListener) { this.documentEscapeListener(); this.documentEscapeListener = null; } }; Sidebar.prototype.unbindMaskClickListener = function () { if (this.maskClickListener) { this.maskClickListener(); this.maskClickListener = null; } }; Sidebar.prototype.unbindGlobalListeners = function () { this.unbindMaskClickListener(); this.unbindDocumentEscapeListener(); }; Sidebar.prototype.ngOnDestroy = function () { this.initialized = false; if (this.visible) { this.hide(); } if (this.appendTo) { this.el.nativeElement.appendChild(this.containerViewChild.nativeElement); } this.unbindGlobalListeners(); }; return Sidebar; }()); Sidebar.decorators = [ { type: core.Component, args: [{ selector: 'p-sidebar', template: "\n