UNPKG

17.3 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/animations"),require("@angular/common"),require("primeng/dom"),require("primeng/api"),require("primeng/focustrap")):"function"==typeof define&&define.amd?define("primeng/dialog",["exports","@angular/core","@angular/animations","@angular/common","primeng/dom","primeng/api","primeng/focustrap"],t):t(((e=e||self).primeng=e.primeng||{},e.primeng.dialog={}),e.ng.core,e.ng.animations,e.ng.common,e.primeng.dom,e.primeng.api,e.primeng.focustrap)}(this,(function(e,t,i,n,o,s,r){"use strict";var a=this&&this.__assign||function(){return(a=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},l=this&&this.__decorate||function(e,t,i,n){var o,s=arguments.length,r=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(r=(s<3?o(r):s>3?o(t,i,r):o(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r},d=0,p=i.animation([i.style({transform:"{{transform}}",opacity:0}),i.animate("{{transition}}",i.style({transform:"none",opacity:1}))]),c=i.animation([i.animate("{{transition}}",i.style({transform:"{{transform}}",opacity:0}))]),u=function(){function e(e,i,n,o){this.el=e,this.renderer=i,this.zone=n,this.cd=o,this.draggable=!0,this.resizable=!0,this.closeOnEscape=!0,this.closable=!0,this.showHeader=!0,this.blockScroll=!1,this.autoZIndex=!0,this.baseZIndex=0,this.minX=0,this.minY=0,this.focusOnShow=!0,this.keepInViewport=!0,this.focusTrap=!0,this.transitionOptions="150ms cubic-bezier(0, 0, 0.2, 1)",this.closeIcon="pi pi-times",this.minimizeIcon="pi pi-window-minimize",this.maximizeIcon="pi pi-window-maximize",this.onShow=new t.EventEmitter,this.onHide=new t.EventEmitter,this.visibleChange=new t.EventEmitter,this.onResizeInit=new t.EventEmitter,this.onResizeEnd=new t.EventEmitter,this.id="ui-dialog-"+d++,this._style={},this._position="center",this.transformOptions="scale(0.7)"}return Object.defineProperty(e.prototype,"positionLeft",{get:function(){return 0},set:function(e){console.log("positionLeft property is deprecated.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positionTop",{get:function(){return 0},set:function(e){console.log("positionTop property is deprecated.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"responsive",{get:function(){return!1},set:function(e){console.log("Responsive property is deprecated.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"breakpoint",{get:function(){return 649},set:function(e){console.log("Breakpoint property is not utilized and deprecated, use CSS media queries instead.")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._visible},set:function(e){this._visible=e,this._visible&&!this.maskVisible&&(this.maskVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"style",{get:function(){return this._style},set:function(e){e&&(this._style=a({},e),this.originalStyle=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(e){switch(this._position=e,e){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)"}},enumerable:!0,configurable:!0}),e.prototype.focus=function(){var e=o.DomHandler.findSingle(this.container,"button");e&&this.zone.runOutsideAngular((function(){setTimeout((function(){return e.focus()}),5)}))},e.prototype.close=function(e){this.visibleChange.emit(!1),e.preventDefault()},e.prototype.enableModality=function(){var e=this;this.closable&&this.dismissableMask&&(this.maskClickListener=this.renderer.listen(this.wrapper,"click",(function(t){e.container.isSameNode(t.target)||e.container.contains(t.target)||e.close(t)}))),this.modal&&o.DomHandler.addClass(document.body,"ui-overflow-hidden")},e.prototype.disableModality=function(){this.wrapper&&(this.dismissableMask&&this.unbindMaskClickListener(),this.modal&&o.DomHandler.removeClass(document.body,"ui-overflow-hidden"),this.cd.destroyed||this.cd.detectChanges())},e.prototype.maximize=function(){this.maximized=!this.maximized,this.modal||this.blockScroll||(this.maximized?o.DomHandler.addClass(document.body,"ui-overflow-hidden"):o.DomHandler.removeClass(document.body,"ui-overflow-hidden"))},e.prototype.unbindMaskClickListener=function(){this.maskClickListener&&(this.maskClickListener(),this.maskClickListener=null)},e.prototype.moveOnTop=function(){this.autoZIndex&&(this.container.style.zIndex=String(this.baseZIndex+ ++o.DomHandler.zindex),this.wrapper.style.zIndex=String(this.baseZIndex+(o.DomHandler.zindex-1)))},e.prototype.getMaskClass=function(){var e={"ui-dialog-mask":!0,"ui-widget-overlay":this.modal,"ui-dialog-visible":this.maskVisible,"ui-dialog-mask-scrollblocker":this.modal||this.blockScroll};return e[this.getPositionClass().toString()]=!0,e},e.prototype.getPositionClass=function(){var e=this,t=["left","right","top","topleft","topright","bottom","bottomleft","bottomright"].find((function(t){return t===e.position}));return t?"ui-dialog-"+t:""},e.prototype.initDrag=function(e){o.DomHandler.hasClass(e.target,"ui-dialog-titlebar-icon")||o.DomHandler.hasClass(e.target.parentElement,"ui-dialog-titlebar-icon")||this.draggable&&(this.dragging=!0,this.lastPageX=e.pageX,this.lastPageY=e.pageY,this.container.style.margin="0",o.DomHandler.addClass(document.body,"ui-unselectable-text"))},e.prototype.onKeydown=function(e){if(this.focusTrap&&9===e.which){e.preventDefault();var t=o.DomHandler.getFocusableElements(this.container);if(t&&t.length>0)if(document.activeElement){var i=t.indexOf(document.activeElement);e.shiftKey?-1==i||0===i?t[t.length-1].focus():t[i-1].focus():-1==i||i===t.length-1?t[0].focus():t[i+1].focus()}else t[0].focus()}},e.prototype.onDrag=function(e){if(this.dragging){var t=o.DomHandler.getOuterWidth(this.container),i=o.DomHandler.getOuterHeight(this.container),n=e.pageX-this.lastPageX,s=e.pageY-this.lastPageY,r=o.DomHandler.getOffset(this.container),a=r.left+n,l=r.top+s,d=o.DomHandler.getViewport();this.container.style.position="fixed",this.keepInViewport?(a>=this.minX&&a+t<d.width&&(this._style.left=a+"px",this.lastPageX=e.pageX,this.container.style.left=a+"px"),l>=this.minY&&l+i<d.height&&(this._style.top=l+"px",this.lastPageY=e.pageY,this.container.style.top=l+"px")):(this.lastPageX=e.pageX,this.container.style.left=a+"px",this.lastPageY=e.pageY,this.container.style.top=l+"px")}},e.prototype.endDrag=function(e){this.draggable&&(this.dragging=!1,o.DomHandler.removeClass(document.body,"ui-unselectable-text"),this.cd.detectChanges())},e.prototype.resetPosition=function(){this.container.style.position="",this.container.style.left="",this.container.style.top="",this.container.style.margin=""},e.prototype.initResize=function(e){this.resizable&&(this.resizing=!0,this.lastPageX=e.pageX,this.lastPageY=e.pageY,o.DomHandler.addClass(document.body,"ui-unselectable-text"),this.onResizeInit.emit(e))},e.prototype.onResize=function(e){if(this.resizing){var t=e.pageX-this.lastPageX,i=e.pageY-this.lastPageY,n=o.DomHandler.getOuterWidth(this.container),s=o.DomHandler.getOuterHeight(this.container),r=o.DomHandler.getOuterHeight(this.contentViewChild.nativeElement),a=n+t,l=s+i,d=this.container.style.minWidth,p=this.container.style.minHeight,c=o.DomHandler.getOffset(this.container),u=o.DomHandler.getViewport();(!d||a>parseInt(d))&&c.left+a<u.width&&(this._style.width=a+"px",this.container.style.width=this._style.width),(!p||l>parseInt(p))&&c.top+l<u.height&&(this.contentViewChild.nativeElement.style.height=r+i+"px"),this.lastPageX=e.pageX,this.lastPageY=e.pageY}},e.prototype.resizeEnd=function(e){this.resizing&&(this.resizing=!1,o.DomHandler.removeClass(document.body,"ui-unselectable-text"),this.onResizeEnd.emit(e))},e.prototype.bindGlobalListeners=function(){this.draggable&&(this.bindDocumentDragListener(),this.bindDocumentDragEndListener()),this.resizable&&this.bindDocumentResizeListeners(),this.closeOnEscape&&this.closable&&this.bindDocumentEscapeListener()},e.prototype.unbindGlobalListeners=function(){this.unbindDocumentDragListener(),this.unbindDocumentDragEndListener(),this.unbindDocumentResizeListeners(),this.unbindDocumentEscapeListener()},e.prototype.bindDocumentDragListener=function(){var e=this;this.zone.runOutsideAngular((function(){e.documentDragListener=e.onDrag.bind(e),window.document.addEventListener("mousemove",e.documentDragListener)}))},e.prototype.unbindDocumentDragListener=function(){this.documentDragListener&&(window.document.removeEventListener("mousemove",this.documentDragListener),this.documentDragListener=null)},e.prototype.bindDocumentDragEndListener=function(){var e=this;this.zone.runOutsideAngular((function(){e.documentDragEndListener=e.endDrag.bind(e),window.document.addEventListener("mouseup",e.documentDragEndListener)}))},e.prototype.unbindDocumentDragEndListener=function(){this.documentDragEndListener&&(window.document.removeEventListener("mouseup",this.documentDragEndListener),this.documentDragEndListener=null)},e.prototype.bindDocumentResizeListeners=function(){var e=this;this.zone.runOutsideAngular((function(){e.documentResizeListener=e.onResize.bind(e),e.documentResizeEndListener=e.resizeEnd.bind(e),window.document.addEventListener("mousemove",e.documentResizeListener),window.document.addEventListener("mouseup",e.documentResizeEndListener)}))},e.prototype.unbindDocumentResizeListeners=function(){this.documentResizeListener&&this.documentResizeEndListener&&(window.document.removeEventListener("mousemove",this.documentResizeListener),window.document.removeEventListener("mouseup",this.documentResizeEndListener),this.documentResizeListener=null,this.documentResizeEndListener=null)},e.prototype.bindDocumentEscapeListener=function(){var e=this;this.documentEscapeListener=this.renderer.listen("document","keydown",(function(t){27==t.which&&parseInt(e.container.style.zIndex)===o.DomHandler.zindex+e.baseZIndex&&e.close(t)}))},e.prototype.unbindDocumentEscapeListener=function(){this.documentEscapeListener&&(this.documentEscapeListener(),this.documentEscapeListener=null)},e.prototype.appendContainer=function(){this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.wrapper):o.DomHandler.appendChild(this.wrapper,this.appendTo))},e.prototype.restoreAppend=function(){this.container&&this.appendTo&&this.el.nativeElement.appendChild(this.wrapper)},e.prototype.onAnimationStart=function(e){switch(e.toState){case"visible":this.container=e.element,this.wrapper=this.container.parentElement,this.onShow.emit({}),this.appendContainer(),this.moveOnTop(),this.bindGlobalListeners(),this.modal&&this.enableModality(),!this.modal&&this.blockScroll&&o.DomHandler.addClass(document.body,"ui-overflow-hidden"),this.focusOnShow&&this.focus()}},e.prototype.onAnimationEnd=function(e){switch(e.toState){case"void":this.onContainerDestroy(),this.onHide.emit({})}},e.prototype.onContainerDestroy=function(){this.unbindGlobalListeners(),this.dragging=!1,this.maskVisible=!1,this.maximized&&(o.DomHandler.removeClass(document.body,"ui-overflow-hidden"),this.maximized=!1),this.modal&&this.disableModality(),this.blockScroll&&o.DomHandler.removeClass(document.body,"ui-overflow-hidden"),this.container=null,this.wrapper=null,this._style=this.originalStyle?a({},this.originalStyle):{}},e.prototype.ngOnDestroy=function(){this.container&&(this.restoreAppend(),this.onContainerDestroy())},e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2},{type:t.NgZone},{type:t.ChangeDetectorRef}]},l([t.Input()],e.prototype,"header",void 0),l([t.Input()],e.prototype,"draggable",void 0),l([t.Input()],e.prototype,"resizable",void 0),l([t.Input()],e.prototype,"positionLeft",null),l([t.Input()],e.prototype,"positionTop",null),l([t.Input()],e.prototype,"contentStyle",void 0),l([t.Input()],e.prototype,"modal",void 0),l([t.Input()],e.prototype,"closeOnEscape",void 0),l([t.Input()],e.prototype,"dismissableMask",void 0),l([t.Input()],e.prototype,"rtl",void 0),l([t.Input()],e.prototype,"closable",void 0),l([t.Input()],e.prototype,"responsive",null),l([t.Input()],e.prototype,"appendTo",void 0),l([t.Input()],e.prototype,"styleClass",void 0),l([t.Input()],e.prototype,"maskStyleClass",void 0),l([t.Input()],e.prototype,"showHeader",void 0),l([t.Input()],e.prototype,"breakpoint",null),l([t.Input()],e.prototype,"blockScroll",void 0),l([t.Input()],e.prototype,"autoZIndex",void 0),l([t.Input()],e.prototype,"baseZIndex",void 0),l([t.Input()],e.prototype,"minX",void 0),l([t.Input()],e.prototype,"minY",void 0),l([t.Input()],e.prototype,"focusOnShow",void 0),l([t.Input()],e.prototype,"maximizable",void 0),l([t.Input()],e.prototype,"keepInViewport",void 0),l([t.Input()],e.prototype,"focusTrap",void 0),l([t.Input()],e.prototype,"transitionOptions",void 0),l([t.Input()],e.prototype,"closeIcon",void 0),l([t.Input()],e.prototype,"minimizeIcon",void 0),l([t.Input()],e.prototype,"maximizeIcon",void 0),l([t.ContentChildren(s.Header,{descendants:!1})],e.prototype,"headerFacet",void 0),l([t.ContentChildren(s.Footer,{descendants:!1})],e.prototype,"footerFacet",void 0),l([t.ViewChild("titlebar")],e.prototype,"headerViewChild",void 0),l([t.ViewChild("content")],e.prototype,"contentViewChild",void 0),l([t.ViewChild("footer")],e.prototype,"footerViewChild",void 0),l([t.Output()],e.prototype,"onShow",void 0),l([t.Output()],e.prototype,"onHide",void 0),l([t.Output()],e.prototype,"visibleChange",void 0),l([t.Output()],e.prototype,"onResizeInit",void 0),l([t.Output()],e.prototype,"onResizeEnd",void 0),l([t.Input()],e.prototype,"visible",null),l([t.Input()],e.prototype,"style",null),l([t.Input()],e.prototype,"position",null),e=l([t.Component({selector:"p-dialog",template:'\n <div [class]="maskStyleClass" [ngClass]="getMaskClass()" *ngIf="maskVisible">\n <div #container [ngClass]="{\'ui-dialog ui-widget ui-widget-content ui-corner-all ui-shadow\':true, \'ui-dialog-rtl\':rtl,\'ui-dialog-draggable\':draggable,\'ui-dialog-resizable\':resizable, \'ui-dialog-maximized\': maximized}"\n [ngStyle]="style" [class]="styleClass" *ngIf="visible" pFocusTrap [pFocusTrapDisabled]="focusTrap === false"\n [@animation]="{value: \'visible\', params: {transform: transformOptions, transition: transitionOptions}}" (@animation.start)="onAnimationStart($event)" (@animation.done)="onAnimationEnd($event)" role="dialog" [attr.aria-labelledby]="id + \'-label\'">\n <div #titlebar class="ui-dialog-titlebar ui-widget-header ui-helper-clearfix ui-corner-top" (mousedown)="initDrag($event)" *ngIf="showHeader">\n <span [attr.id]="id + \'-label\'" class="ui-dialog-title" *ngIf="header">{{header}}</span>\n <span [attr.id]="id + \'-label\'" class="ui-dialog-title" *ngIf="headerFacet && headerFacet.first">\n <ng-content select="p-header"></ng-content>\n </span>\n <div class="ui-dialog-titlebar-icons">\n <a *ngIf="maximizable" [ngClass]="{\'ui-dialog-titlebar-icon ui-dialog-titlebar-maximize ui-corner-all\':true}" tabindex="0" role="button" (click)="maximize()" (keydown.enter)="maximize()">\n <span [ngClass]="maximized ? minimizeIcon : maximizeIcon"></span>\n </a>\n <a *ngIf="closable" [ngClass]="{\'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all\':true}" tabindex="0" role="button" (click)="close($event)" (keydown.enter)="close($event)">\n <span [class]="closeIcon"></span>\n </a>\n </div>\n </div>\n <div #content class="ui-dialog-content ui-widget-content" [ngStyle]="contentStyle">\n <ng-content></ng-content>\n </div>\n <div #footer class="ui-dialog-footer ui-widget-content" *ngIf="footerFacet && footerFacet.first">\n <ng-content select="p-footer"></ng-content>\n </div>\n <div *ngIf="resizable" class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se" style="z-index: 90;" (mousedown)="initResize($event)"></div>\n </div>\n </div>\n ',animations:[i.trigger("animation",[i.transition("void => visible",[i.useAnimation(p)]),i.transition("visible => void",[i.useAnimation(c)])])],changeDetection:t.ChangeDetectionStrategy.Default})],e)}(),h=function(){function e(){}return e=l([t.NgModule({imports:[n.CommonModule,r.FocusTrapModule],exports:[u,s.SharedModule],declarations:[u]})],e)}();e.Dialog=u,e.DialogModule=h,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-dialog.umd.min.js.map
\No newline at end of file