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

16 lines (14 loc) 11.2 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/animations"),require("@angular/common"),require("primeng/dom"),require("@angular/router"),require("primeng/ripple")):"function"==typeof define&&define.amd?define("primeng/menu",["exports","@angular/core","@angular/animations","@angular/common","primeng/dom","@angular/router","primeng/ripple"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).primeng=e.primeng||{},e.primeng.menu={}),e.ng.core,e.ng.animations,e.ng.common,e.primeng.dom,e.ng.router,e.primeng.ripple)}(this,(function(e,t,n,i,s,r,a){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */Object.create;function o(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}Object.create;var l=function(e){this.menu=e};l.decorators=[{type:t.Component,args:[{selector:"[pMenuItemContent]",template:'\n <a *ngIf="!item.routerLink" [attr.href]="item.url||null" class="p-menuitem-link" [attr.tabindex]="item.disabled ? null : \'0\'" [attr.data-automationid]="item.automationId" [attr.target]="item.target" [attr.title]="item.title" [attr.id]="item.id"\n [ngClass]="{\'p-disabled\':item.disabled}" (click)="menu.itemClick($event, item)" role="menuitem">\n <span class="p-menuitem-icon" *ngIf="item.icon" [ngClass]="item.icon"></span>\n <span class="p-menuitem-text" *ngIf="item.escape !== false; else htmlLabel">{{item.label}}</span>\n <ng-template #htmlLabel><span class="p-menuitem-text" [innerHTML]="item.label"></span></ng-template>\n </a>\n <a *ngIf="item.routerLink" [routerLink]="item.routerLink" [attr.data-automationid]="item.automationId" [queryParams]="item.queryParams" [routerLinkActive]="\'p-menuitem-link-active\'"\n [routerLinkActiveOptions]="item.routerLinkActiveOptions||{exact:false}" class="p-menuitem-link" [attr.target]="item.target" [attr.id]="item.id" [attr.tabindex]="item.disabled ? null : \'0\'"\n [attr.title]="item.title" [ngClass]="{\'p-disabled\':item.disabled}" (click)="menu.itemClick($event, item)" role="menuitem" pRipple\n [fragment]="item.fragment" [queryParamsHandling]="item.queryParamsHandling" [preserveFragment]="item.preserveFragment" [skipLocationChange]="item.skipLocationChange" [replaceUrl]="item.replaceUrl" [state]="item.state">\n <span class="p-menuitem-icon" *ngIf="item.icon" [ngClass]="item.icon"></span>\n <span class="p-menuitem-text" *ngIf="item.escape !== false; else htmlRouteLabel">{{item.label}}</span>\n <ng-template #htmlRouteLabel><span class="p-menuitem-text" [innerHTML]="item.label"></span></ng-template>\n </a>\n ',encapsulation:t.ViewEncapsulation.None}]}],l.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[t.forwardRef((function(){return p}))]}]}]},l.propDecorators={item:[{type:t.Input,args:["pMenuItemContent"]}]};var p=function(){function e(e,n,i){this.el=e,this.renderer=n,this.cd=i,this.autoZIndex=!0,this.baseZIndex=0,this.showTransitionOptions=".12s cubic-bezier(0, 0, 0.2, 1)",this.hideTransitionOptions=".1s linear",this.onShow=new t.EventEmitter,this.onHide=new t.EventEmitter}return e.prototype.toggle=function(e){this.visible?this.hide():this.show(e),this.preventDocumentDefault=!0},e.prototype.show=function(e){this.target=e.currentTarget,this.relativeAlign=e.relativeAlign,this.visible=!0,this.preventDocumentDefault=!0,this.cd.markForCheck()},e.prototype.onOverlayAnimationStart=function(e){switch(e.toState){case"visible":this.popup&&(this.container=e.element,this.moveOnTop(),this.onShow.emit({}),this.appendOverlay(),this.alignOverlay(),this.bindDocumentClickListener(),this.bindDocumentResizeListener(),this.bindScrollListener());break;case"void":this.onOverlayHide(),this.onHide.emit({})}},e.prototype.alignOverlay=function(){this.relativeAlign?s.DomHandler.relativePosition(this.container,this.target):s.DomHandler.absolutePosition(this.container,this.target)},e.prototype.appendOverlay=function(){this.appendTo&&("body"===this.appendTo?document.body.appendChild(this.container):s.DomHandler.appendChild(this.container,this.appendTo))},e.prototype.restoreOverlayAppend=function(){this.container&&this.appendTo&&this.el.nativeElement.appendChild(this.container)},e.prototype.moveOnTop=function(){this.autoZIndex&&(this.container.style.zIndex=String(this.baseZIndex+ ++s.DomHandler.zindex))},e.prototype.hide=function(){this.visible=!1,this.relativeAlign=!1,this.cd.markForCheck()},e.prototype.onWindowResize=function(){this.hide()},e.prototype.itemClick=function(e,t){t.disabled?e.preventDefault():(t.url||e.preventDefault(),t.command&&t.command({originalEvent:e,item:t}),this.popup&&this.hide())},e.prototype.bindDocumentClickListener=function(){var e=this;if(!this.documentClickListener){var t=this.el?this.el.nativeElement.ownerDocument:"document";this.documentClickListener=this.renderer.listen(t,"click",(function(){e.preventDocumentDefault||e.hide(),e.preventDocumentDefault=!1}))}},e.prototype.unbindDocumentClickListener=function(){this.documentClickListener&&(this.documentClickListener(),this.documentClickListener=null)},e.prototype.bindDocumentResizeListener=function(){this.documentResizeListener=this.onWindowResize.bind(this),window.addEventListener("resize",this.documentResizeListener)},e.prototype.unbindDocumentResizeListener=function(){this.documentResizeListener&&(window.removeEventListener("resize",this.documentResizeListener),this.documentResizeListener=null)},e.prototype.bindScrollListener=function(){var e=this;this.scrollHandler||(this.scrollHandler=new s.ConnectedOverlayScrollHandler(this.target,(function(){e.visible&&e.hide()}))),this.scrollHandler.bindScrollListener()},e.prototype.unbindScrollListener=function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},e.prototype.onOverlayHide=function(){this.unbindDocumentClickListener(),this.unbindDocumentResizeListener(),this.unbindScrollListener(),this.preventDocumentDefault=!1,this.target=null},e.prototype.ngOnDestroy=function(){this.popup&&(this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.restoreOverlayAppend(),this.onOverlayHide())},e.prototype.hasSubMenu=function(){var e,t;if(this.model)try{for(var n=o(this.model),i=n.next();!i.done;i=n.next()){if(i.value.items)return!0}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return!1},e}();p.decorators=[{type:t.Component,args:[{selector:"p-menu",template:'\n <div #container [ngClass]="{\'p-menu p-component\': true, \'p-menu-overlay\': popup}"\n [class]="styleClass" [ngStyle]="style" (click)="preventDocumentDefault=true" *ngIf="!popup || visible"\n [@overlayAnimation]="{value: \'visible\', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" [@.disabled]="popup !== true" (@overlayAnimation.start)="onOverlayAnimationStart($event)">\n <ul class="p-menu-list p-reset">\n <ng-template ngFor let-submenu [ngForOf]="model" *ngIf="hasSubMenu()">\n <li class="p-menu-separator" *ngIf="submenu.separator" [ngClass]="{\'p-hidden\': submenu.visible === false}"></li>\n <li class="p-submenu-header" [attr.data-automationid]="submenu.automationId" *ngIf="!submenu.separator" [ngClass]="{\'p-hidden\': submenu.visible === false}">\n <span *ngIf="submenu.escape !== false; else htmlSubmenuLabel">{{submenu.label}}</span>\n <ng-template #htmlSubmenuLabel><span [innerHTML]="submenu.label"></span></ng-template>\n </li>\n <ng-template ngFor let-item [ngForOf]="submenu.items">\n <li class="p-menu-separator" *ngIf="item.separator" [ngClass]="{\'p-hidden\': (item.visible === false || submenu.visible === false)}"></li>\n <li class="p-menuitem" *ngIf="!item.separator" [pMenuItemContent]="item" [ngClass]="{\'p-hidden\': (item.visible === false || submenu.visible === false)}" [ngStyle]="item.style" [class]="item.styleClass"></li>\n </ng-template>\n </ng-template>\n <ng-template ngFor let-item [ngForOf]="model" *ngIf="!hasSubMenu()">\n <li class="p-menu-separator" *ngIf="item.separator" [ngClass]="{\'p-hidden\': item.visible === false}"></li>\n <li class="p-menuitem" *ngIf="!item.separator" [pMenuItemContent]="item" [ngClass]="{\'p-hidden\': item.visible === false}" [ngStyle]="item.style" [class]="item.styleClass"></li>\n </ng-template>\n </ul>\n </div>\n ',animations:[n.trigger("overlayAnimation",[n.transition(":enter",[n.style({opacity:0,transform:"scaleY(0.8)"}),n.animate("{{showTransitionParams}}")]),n.transition(":leave",[n.animate("{{hideTransitionParams}}",n.style({opacity:0}))])])],changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None,styles:[".p-menu-overlay{position:absolute}.p-menu ul{list-style:none;margin:0;padding:0}.p-menu .p-menuitem-link{align-items:center;cursor:pointer;display:flex;overflow:hidden;position:relative;text-decoration:none}.p-menu .p-menuitem-text{line-height:1}"]}]}],p.ctorParameters=function(){return[{type:t.ElementRef},{type:t.Renderer2},{type:t.ChangeDetectorRef}]},p.propDecorators={model:[{type:t.Input}],popup:[{type:t.Input}],style:[{type:t.Input}],styleClass:[{type:t.Input}],appendTo:[{type:t.Input}],autoZIndex:[{type:t.Input}],baseZIndex:[{type:t.Input}],showTransitionOptions:[{type:t.Input}],hideTransitionOptions:[{type:t.Input}],containerViewChild:[{type:t.ViewChild,args:["container"]}],onShow:[{type:t.Output}],onHide:[{type:t.Output}]};var m=function(){};m.decorators=[{type:t.NgModule,args:[{imports:[i.CommonModule,r.RouterModule,a.RippleModule],exports:[p,r.RouterModule],declarations:[p,l]}]}],e.Menu=p,e.MenuItemContent=l,e.MenuModule=m,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=primeng-menu.umd.min.js.map