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) [![Discord](https://img.shields.io/discord/557940238991753

2 lines 8.34 kB
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/core"),require("@angular/common"),require("primeng/api"),require("primeng/button"),require("@angular/animations"),require("primeng/dom")):"function"==typeof define&&define.amd?define("primeng/confirmpopup",["exports","@angular/core","@angular/common","primeng/api","primeng/button","@angular/animations","primeng/dom"],n):n(((t="undefined"!=typeof globalThis?globalThis:t||self).primeng=t.primeng||{},t.primeng.confirmpopup={}),t.ng.core,t.ng.common,t.primeng.api,t.primeng.button,t.ng.animations,t.primeng.dom)}(this,(function(t,n,e,i,o,r,s){"use strict";var a=function(){function t(t,e,i,o,r){var s=this;this.el=t,this.confirmationService=e,this.renderer=i,this.cd=o,this.config=r,this.showTransitionOptions=".12s cubic-bezier(0, 0, 0.2, 1)",this.hideTransitionOptions=".1s linear",this.autoZIndex=!0,this.baseZIndex=0,this.subscription=this.confirmationService.requireConfirmation$.subscribe((function(t){t?t.key===s.key&&(s.confirmation=t,s.confirmation.accept&&(s.confirmation.acceptEvent=new n.EventEmitter,s.confirmation.acceptEvent.subscribe(s.confirmation.accept)),s.confirmation.reject&&(s.confirmation.rejectEvent=new n.EventEmitter,s.confirmation.rejectEvent.subscribe(s.confirmation.reject)),s.visible=!0):s.hide()}))}return Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible},set:function(t){this._visible=t,this.cd.markForCheck()},enumerable:!1,configurable:!0}),t.prototype.onAnimationStart=function(t){"open"===t.toState&&(this.container=t.element,document.body.appendChild(this.container),this.align(),this.bindListeners())},t.prototype.onAnimationEnd=function(t){switch(t.toState){case"void":this.onContainerDestroy()}},t.prototype.align=function(){this.autoZIndex&&(this.container.style.zIndex=String(this.baseZIndex+ ++s.DomHandler.zindex)),s.DomHandler.absolutePosition(this.container,this.confirmation.target);var t=s.DomHandler.getOffset(this.container),n=s.DomHandler.getOffset(this.confirmation.target),e=0;t.left<n.left&&(e=n.left-t.left),this.container.style.setProperty("--overlayArrowLeft",e+"px"),t.top<n.top&&s.DomHandler.addClass(this.container,"p-confirm-popup-flipped")},t.prototype.hide=function(){this.visible=!1},t.prototype.accept=function(){this.confirmation.acceptEvent&&this.confirmation.acceptEvent.emit(),this.hide()},t.prototype.reject=function(){this.confirmation.rejectEvent&&this.confirmation.rejectEvent.emit(),this.hide()},t.prototype.bindListeners=function(){this.bindDocumentClickListener(),this.bindDocumentResizeListener(),this.bindScrollListener()},t.prototype.unbindListeners=function(){this.unbindDocumentClickListener(),this.unbindDocumentResizeListener(),this.unbindScrollListener()},t.prototype.bindDocumentClickListener=function(){var t=this;if(!this.documentClickListener){var n=s.DomHandler.isIOS()?"touchstart":"click",e=this.el?this.el.nativeElement.ownerDocument:document;this.documentClickListener=this.renderer.listen(e,n,(function(n){var e=t.confirmation.target;t.container===n.target||t.container.contains(n.target)||e===n.target||e.contains(n.target)||t.hide()}))}},t.prototype.unbindDocumentClickListener=function(){this.documentClickListener&&(this.documentClickListener(),this.documentClickListener=null)},t.prototype.onWindowResize=function(){this.hide()},t.prototype.bindDocumentResizeListener=function(){this.documentResizeListener=this.onWindowResize.bind(this),window.addEventListener("resize",this.documentResizeListener)},t.prototype.unbindDocumentResizeListener=function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)},t.prototype.bindScrollListener=function(){var t=this;this.scrollHandler||(this.scrollHandler=new s.ConnectedOverlayScrollHandler(this.confirmation.target,(function(){t.visible&&t.hide()}))),this.scrollHandler.bindScrollListener()},t.prototype.unbindScrollListener=function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},t.prototype.unsubscribeConfirmationSubscriptions=function(){this.confirmation&&(this.confirmation.acceptEvent&&this.confirmation.acceptEvent.unsubscribe(),this.confirmation.rejectEvent&&this.confirmation.rejectEvent.unsubscribe())},t.prototype.onContainerDestroy=function(){this.unbindListeners(),this.unsubscribeConfirmationSubscriptions(),this.confirmation=null,this.container=null},t.prototype.restoreAppend=function(){this.container&&document.body.removeChild(this.container),this.onContainerDestroy()},Object.defineProperty(t.prototype,"acceptButtonLabel",{get:function(){return this.confirmation.acceptLabel||this.config.getTranslation(i.TranslationKeys.ACCEPT)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rejectButtonLabel",{get:function(){return this.confirmation.rejectLabel||this.config.getTranslation(i.TranslationKeys.REJECT)},enumerable:!1,configurable:!0}),t.prototype.ngOnDestroy=function(){this.restoreAppend(),this.subscription&&this.subscription.unsubscribe()},t}();a.decorators=[{type:n.Component,args:[{selector:"p-confirmPopup",template:'\n <div *ngIf="visible" [ngClass]="\'p-confirm-popup p-component\'" [ngStyle]="style" [class]="styleClass"\n [@animation]="{value: \'open\', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}"\n (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)">\n <div #content class="p-confirm-popup-content">\n <i [ngClass]="\'p-confirm-popup-icon\'" [class]="confirmation.icon" *ngIf="confirmation.icon"></i>\n <span class="p-confirm-popup-message">{{confirmation.message}}</span>\n </div>\n <div class="p-confirm-popup-footer">\n <button type="button" pButton [icon]="confirmation.rejectIcon" [label]="rejectButtonLabel" (click)="reject()" [ngClass]="\'p-confirm-popup-reject p-button-sm\'"\n [class]="confirmation.rejectButtonStyleClass || \'p-button-text\'" *ngIf="confirmation.rejectVisible !== false" [attr.aria-label]="rejectButtonLabel"></button>\n <button type="button" pButton [icon]="confirmation.acceptIcon" [label]="acceptButtonLabel" (click)="accept()" [ngClass]="\'p-confirm-popup-accept p-button-sm\'"\n [class]="confirmation.acceptButtonStyleClass" *ngIf="confirmation.acceptVisible !== false" [attr.aria-label]="acceptButtonLabel"></button>\n </div>\n </div>\n ',animations:[r.trigger("animation",[r.state("void",r.style({transform:"scaleY(0.8)",opacity:0})),r.state("open",r.style({transform:"translateY(0)",opacity:1})),r.transition("void => open",r.animate("{{showTransitionParams}}")),r.transition("open => void",r.animate("{{hideTransitionParams}}"))])],changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None,styles:['.p-confirm-popup{margin-top:10px;position:absolute}.p-confirm-popup-flipped{margin-bottom:10px;margin-top:0}.p-confirm-popup:after,.p-confirm-popup:before{bottom:100%;content:" ";height:0;left:calc(var(--overlayArrowLeft, 0) + 1.25rem);pointer-events:none;position:absolute;width:0}.p-confirm-popup:after{border-width:8px;margin-left:-8px}.p-confirm-popup:before{border-width:10px;margin-left:-10px}.p-confirm-popup-flipped:after,.p-confirm-popup-flipped:before{bottom:auto;top:100%}.p-confirm-popup.p-confirm-popup-flipped:after,.p-confirm-popup.p-confirm-popup-flipped:before{border-bottom-color:transparent}.p-confirm-popup .p-confirm-popup-content{align-items:center;display:flex}']}]}],a.ctorParameters=function(){return[{type:n.ElementRef},{type:i.ConfirmationService},{type:n.Renderer2},{type:n.ChangeDetectorRef},{type:i.PrimeNGConfig}]},a.propDecorators={key:[{type:n.Input}],showTransitionOptions:[{type:n.Input}],hideTransitionOptions:[{type:n.Input}],autoZIndex:[{type:n.Input}],baseZIndex:[{type:n.Input}],style:[{type:n.Input}],styleClass:[{type:n.Input}],visible:[{type:n.Input}]};var c=function(){};c.decorators=[{type:n.NgModule,args:[{imports:[e.CommonModule,o.ButtonModule],exports:[a],declarations:[a]}]}],t.ConfirmPopup=a,t.ConfirmPopupModule=c,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-confirmpopup.umd.min.js.map