ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,254 lines (1,241 loc) • 44.6 kB
JavaScript
import { __extends, __decorate, __metadata, __spread, __read } from 'tslib';
import { Injectable, SkipSelf, Optional, Directive, Renderer2, ElementRef, Input, ContentChildren, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, ChangeDetectorRef, Host, Output, ViewChild, NgModule } from '@angular/core';
import { BehaviorSubject, Subject, combineLatest, merge, EMPTY } from 'rxjs';
import { map, tap, auditTime, distinctUntilChanged, takeUntil, filter, startWith, flatMap } from 'rxjs/operators';
import { NzMenuBaseService, isNotNil, NzUpdateHostClassService, InputBoolean, DEFAULT_SUBMENU_POSITIONS, getPlacementName, POSITION_MAP, collapseMotion, zoomBigMotion, slideMotion, NzNoAnimationDirective, NzDropdownHigherOrderServiceToken, NzNoAnimationModule, NzAddOnModule } from 'ng-zorro-antd/core';
import { NavigationEnd, RouterLink, RouterLinkWithHref, Router } from '@angular/router';
import { CdkConnectedOverlay, CdkOverlayOrigin, OverlayModule } from '@angular/cdk/overlay';
import { Platform, PlatformModule } from '@angular/cdk/platform';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzIconModule } from 'ng-zorro-antd/icon';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzMenuService = /** @class */ (function (_super) {
__extends(NzMenuService, _super);
function NzMenuService() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.isInDropDown = false;
return _this;
}
NzMenuService.decorators = [
{ type: Injectable }
];
return NzMenuService;
}(NzMenuBaseService));
if (false) {
/** @type {?} */
NzMenuService.prototype.isInDropDown;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSubmenuService = /** @class */ (function () {
function NzSubmenuService(nzHostSubmenuService, nzMenuService) {
var _this = this;
this.nzHostSubmenuService = nzHostSubmenuService;
this.nzMenuService = nzMenuService;
this.disabled = false;
this.mode = 'vertical';
this.mode$ = this.nzMenuService.mode$.pipe(map((/**
* @param {?} mode
* @return {?}
*/
function (mode) {
if (mode === 'inline') {
return 'inline';
}
else if (mode === 'vertical' || _this.nzHostSubmenuService) {
return 'vertical';
}
else {
return 'horizontal';
}
})), tap((/**
* @param {?} mode
* @return {?}
*/
function (mode) { return (_this.mode = (/** @type {?} */ (mode))); })));
this.level = 1;
this.level$ = new BehaviorSubject(1);
this.subMenuOpen$ = new BehaviorSubject(false);
this.open$ = new BehaviorSubject(false);
this.mouseEnterLeave$ = new Subject();
this.menuOpen$ = combineLatest(this.subMenuOpen$, this.mouseEnterLeave$).pipe(map((/**
* @param {?} value
* @return {?}
*/
function (value) { return value[0] || value[1]; })), auditTime(150), distinctUntilChanged(), tap((/**
* @param {?} data
* @return {?}
*/
function (data) {
_this.setOpenState(data);
if (_this.nzHostSubmenuService) {
_this.nzHostSubmenuService.subMenuOpen$.next(data);
}
})));
if (this.nzHostSubmenuService) {
this.setLevel(this.nzHostSubmenuService.level + 1);
}
}
/**
* @param {?} value
* @return {?}
*/
NzSubmenuService.prototype.setOpenState = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.open$.next(value);
};
/**
* @return {?}
*/
NzSubmenuService.prototype.onMenuItemClick = /**
* @return {?}
*/
function () {
this.setMouseEnterState(false);
};
/**
* @param {?} value
* @return {?}
*/
NzSubmenuService.prototype.setLevel = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.level$.next(value);
this.level = value;
};
/**
* @param {?} value
* @return {?}
*/
NzSubmenuService.prototype.setMouseEnterState = /**
* @param {?} value
* @return {?}
*/
function (value) {
if ((this.mode === 'horizontal' || this.mode === 'vertical' || this.nzMenuService.isInDropDown) && !this.disabled) {
this.mouseEnterLeave$.next(value);
}
};
NzSubmenuService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
NzSubmenuService.ctorParameters = function () { return [
{ type: NzSubmenuService, decorators: [{ type: SkipSelf }, { type: Optional }] },
{ type: NzMenuService }
]; };
return NzSubmenuService;
}());
if (false) {
/** @type {?} */
NzSubmenuService.prototype.disabled;
/** @type {?} */
NzSubmenuService.prototype.mode;
/** @type {?} */
NzSubmenuService.prototype.mode$;
/** @type {?} */
NzSubmenuService.prototype.level;
/** @type {?} */
NzSubmenuService.prototype.level$;
/** @type {?} */
NzSubmenuService.prototype.subMenuOpen$;
/** @type {?} */
NzSubmenuService.prototype.open$;
/** @type {?} */
NzSubmenuService.prototype.mouseEnterLeave$;
/** @type {?} */
NzSubmenuService.prototype.menuOpen$;
/**
* @type {?}
* @private
*/
NzSubmenuService.prototype.nzHostSubmenuService;
/** @type {?} */
NzSubmenuService.prototype.nzMenuService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzMenuItemDirective = /** @class */ (function () {
function NzMenuItemDirective(nzUpdateHostClassService, nzMenuService, nzSubmenuService, renderer, elementRef, routerLink, routerLinkWithHref, router) {
var _this = this;
this.nzUpdateHostClassService = nzUpdateHostClassService;
this.nzMenuService = nzMenuService;
this.nzSubmenuService = nzSubmenuService;
this.renderer = renderer;
this.elementRef = elementRef;
this.routerLink = routerLink;
this.routerLinkWithHref = routerLinkWithHref;
this.router = router;
this.el = this.elementRef.nativeElement;
this.destroy$ = new Subject();
this.originalPadding = null;
this.selected$ = new Subject();
this.nzDisabled = false;
this.nzSelected = false;
this.nzMatchRouterExact = false;
this.nzMatchRouter = false;
if (router) {
(/** @type {?} */ (this.router)).events.pipe(takeUntil(this.destroy$), filter((/**
* @param {?} e
* @return {?}
*/
function (e) { return e instanceof NavigationEnd; }))).subscribe((/**
* @return {?}
*/
function () {
_this.updateRouterActive();
}));
}
}
/** clear all item selected status except this */
/**
* clear all item selected status except this
* @param {?} e
* @return {?}
*/
NzMenuItemDirective.prototype.clickMenuItem = /**
* clear all item selected status except this
* @param {?} e
* @return {?}
*/
function (e) {
if (this.nzDisabled) {
e.preventDefault();
e.stopPropagation();
return;
}
this.nzMenuService.onMenuItemClick(this);
if (this.nzSubmenuService) {
this.nzSubmenuService.onMenuItemClick();
}
};
/**
* @return {?}
*/
NzMenuItemDirective.prototype.setClassMap = /**
* @return {?}
*/
function () {
var _a;
/** @type {?} */
var prefixName = this.nzMenuService.isInDropDown ? 'ant-dropdown-menu-item' : 'ant-menu-item';
this.nzUpdateHostClassService.updateHostClass(this.el, (_a = {},
_a["" + prefixName] = true,
_a[prefixName + "-selected"] = this.nzSelected,
_a[prefixName + "-disabled"] = this.nzDisabled,
_a));
};
/**
* @param {?} value
* @return {?}
*/
NzMenuItemDirective.prototype.setSelectedState = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.nzSelected = value;
this.selected$.next(value);
this.setClassMap();
};
/**
* @private
* @return {?}
*/
NzMenuItemDirective.prototype.updateRouterActive = /**
* @private
* @return {?}
*/
function () {
var _this = this;
if (!this.listOfRouterLink ||
!this.listOfRouterLinkWithHref ||
!this.router ||
!this.router.navigated ||
!this.nzMatchRouter) {
return;
}
Promise.resolve().then((/**
* @return {?}
*/
function () {
/** @type {?} */
var hasActiveLinks = _this.hasActiveLinks();
if (_this.nzSelected !== hasActiveLinks) {
_this.nzSelected = hasActiveLinks;
_this.setSelectedState(_this.nzSelected);
}
}));
};
/**
* @private
* @return {?}
*/
NzMenuItemDirective.prototype.hasActiveLinks = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var isActiveCheckFn = this.isLinkActive((/** @type {?} */ (this.router)));
return ((this.routerLink && isActiveCheckFn(this.routerLink)) ||
(this.routerLinkWithHref && isActiveCheckFn(this.routerLinkWithHref)) ||
this.listOfRouterLink.some(isActiveCheckFn) ||
this.listOfRouterLinkWithHref.some(isActiveCheckFn));
};
/**
* @private
* @param {?} router
* @return {?}
*/
NzMenuItemDirective.prototype.isLinkActive = /**
* @private
* @param {?} router
* @return {?}
*/
function (router) {
var _this = this;
return (/**
* @param {?} link
* @return {?}
*/
function (link) { return router.isActive(link.urlTree, _this.nzMatchRouterExact); });
};
/**
* @return {?}
*/
NzMenuItemDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
/**
* store origin padding in padding
* @type {?}
*/
var paddingLeft = this.el.style.paddingLeft;
if (paddingLeft) {
this.originalPadding = parseInt(paddingLeft, 10);
}
merge(this.nzMenuService.mode$, this.nzMenuService.inlineIndent$, this.nzSubmenuService ? this.nzSubmenuService.level$ : EMPTY)
.pipe(takeUntil(this.destroy$))
.subscribe((/**
* @return {?}
*/
function () {
/** @type {?} */
var padding = null;
if (_this.nzMenuService.mode === 'inline') {
if (isNotNil(_this.nzPaddingLeft)) {
padding = _this.nzPaddingLeft;
}
else {
/** @type {?} */
var level = _this.nzSubmenuService ? _this.nzSubmenuService.level + 1 : 1;
padding = level * _this.nzMenuService.inlineIndent;
}
}
else {
padding = _this.originalPadding;
}
if (padding) {
_this.renderer.setStyle(_this.el, 'padding-left', padding + "px");
}
else {
_this.renderer.removeStyle(_this.el, 'padding-left');
}
}));
this.setClassMap();
};
/**
* @return {?}
*/
NzMenuItemDirective.prototype.ngAfterContentInit = /**
* @return {?}
*/
function () {
var _this = this;
this.listOfRouterLink.changes.pipe(takeUntil(this.destroy$)).subscribe((/**
* @return {?}
*/
function () { return _this.updateRouterActive(); }));
this.listOfRouterLinkWithHref.changes.pipe(takeUntil(this.destroy$)).subscribe((/**
* @return {?}
*/
function () { return _this.updateRouterActive(); }));
this.updateRouterActive();
};
/**
* @param {?} changes
* @return {?}
*/
NzMenuItemDirective.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.nzSelected) {
this.setSelectedState(this.nzSelected);
}
if (changes.nzDisabled) {
this.setClassMap();
}
};
/**
* @return {?}
*/
NzMenuItemDirective.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.destroy$.next();
this.destroy$.complete();
};
NzMenuItemDirective.decorators = [
{ type: Directive, args: [{
selector: '[nz-menu-item]',
exportAs: 'nzMenuItem',
providers: [NzUpdateHostClassService],
host: {
'(click)': 'clickMenuItem($event)'
}
},] }
];
/** @nocollapse */
NzMenuItemDirective.ctorParameters = function () { return [
{ type: NzUpdateHostClassService },
{ type: NzMenuBaseService },
{ type: NzSubmenuService, decorators: [{ type: Optional }] },
{ type: Renderer2 },
{ type: ElementRef },
{ type: RouterLink, decorators: [{ type: Optional }] },
{ type: RouterLinkWithHref, decorators: [{ type: Optional }] },
{ type: Router, decorators: [{ type: Optional }] }
]; };
NzMenuItemDirective.propDecorators = {
nzDisabled: [{ type: Input }],
nzSelected: [{ type: Input }],
nzPaddingLeft: [{ type: Input }],
nzMatchRouterExact: [{ type: Input }],
nzMatchRouter: [{ type: Input }],
listOfRouterLink: [{ type: ContentChildren, args: [RouterLink, { descendants: true },] }],
listOfRouterLinkWithHref: [{ type: ContentChildren, args: [RouterLinkWithHref, { descendants: true },] }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzMenuItemDirective.prototype, "nzDisabled", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzMenuItemDirective.prototype, "nzSelected", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzMenuItemDirective.prototype, "nzMatchRouterExact", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzMenuItemDirective.prototype, "nzMatchRouter", void 0);
return NzMenuItemDirective;
}());
if (false) {
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.el;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.destroy$;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.originalPadding;
/** @type {?} */
NzMenuItemDirective.prototype.selected$;
/** @type {?} */
NzMenuItemDirective.prototype.nzDisabled;
/** @type {?} */
NzMenuItemDirective.prototype.nzSelected;
/** @type {?} */
NzMenuItemDirective.prototype.nzPaddingLeft;
/** @type {?} */
NzMenuItemDirective.prototype.nzMatchRouterExact;
/** @type {?} */
NzMenuItemDirective.prototype.nzMatchRouter;
/** @type {?} */
NzMenuItemDirective.prototype.listOfRouterLink;
/** @type {?} */
NzMenuItemDirective.prototype.listOfRouterLinkWithHref;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.nzUpdateHostClassService;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.nzMenuService;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.nzSubmenuService;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.renderer;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.elementRef;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.routerLink;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.routerLinkWithHref;
/**
* @type {?}
* @private
*/
NzMenuItemDirective.prototype.router;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
/**
* @param {?} higherOrderService
* @param {?} menuService
* @return {?}
*/
function NzMenuServiceFactory(higherOrderService, menuService) {
return higherOrderService ? higherOrderService : menuService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSubMenuComponent = /** @class */ (function () {
function NzSubMenuComponent(elementRef, nzMenuService, cdr, nzSubmenuService, nzUpdateHostClassService, platform, noAnimation) {
this.elementRef = elementRef;
this.nzMenuService = nzMenuService;
this.cdr = cdr;
this.nzSubmenuService = nzSubmenuService;
this.nzUpdateHostClassService = nzUpdateHostClassService;
this.platform = platform;
this.noAnimation = noAnimation;
this.nzOpen = false;
this.nzDisabled = false;
this.nzOpenChange = new EventEmitter();
this.placement = 'rightTop';
this.expandState = 'collapsed';
this.overlayPositions = __spread(DEFAULT_SUBMENU_POSITIONS);
this.destroy$ = new Subject();
this.isChildMenuSelected = false;
this.isMouseHover = false;
}
/**
* @param {?} open
* @return {?}
*/
NzSubMenuComponent.prototype.setOpenState = /**
* @param {?} open
* @return {?}
*/
function (open) {
this.nzSubmenuService.setOpenState(open);
};
/**
* @return {?}
*/
NzSubMenuComponent.prototype.clickSubMenuTitle = /**
* @return {?}
*/
function () {
if (this.nzSubmenuService.mode === 'inline' && !this.nzMenuService.isInDropDown && !this.nzDisabled) {
this.setOpenState(!this.nzOpen);
}
};
/**
* @param {?} value
* @return {?}
*/
NzSubMenuComponent.prototype.setMouseEnterState = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.isMouseHover = value;
this.setClassMap();
this.nzSubmenuService.setMouseEnterState(value);
};
/**
* @return {?}
*/
NzSubMenuComponent.prototype.setTriggerWidth = /**
* @return {?}
*/
function () {
if (this.nzSubmenuService.mode === 'horizontal' && this.platform.isBrowser) {
this.triggerWidth = this.cdkOverlayOrigin.nativeElement.getBoundingClientRect().width;
}
};
/**
* @param {?} position
* @return {?}
*/
NzSubMenuComponent.prototype.onPositionChange = /**
* @param {?} position
* @return {?}
*/
function (position) {
this.placement = (/** @type {?} */ (getPlacementName(position)));
this.cdr.markForCheck();
};
/**
* @return {?}
*/
NzSubMenuComponent.prototype.setClassMap = /**
* @return {?}
*/
function () {
var _a;
/** @type {?} */
var prefixName = this.nzMenuService.isInDropDown ? 'ant-dropdown-menu-submenu' : 'ant-menu-submenu';
this.nzUpdateHostClassService.updateHostClass(this.elementRef.nativeElement, (_a = {},
_a["" + prefixName] = true,
_a[prefixName + "-disabled"] = this.nzDisabled,
_a[prefixName + "-open"] = this.nzOpen,
_a[prefixName + "-selected"] = this.isChildMenuSelected,
_a[prefixName + "-" + this.nzSubmenuService.mode] = true,
_a[prefixName + "-active"] = this.isMouseHover && !this.nzDisabled,
_a));
};
/**
* @return {?}
*/
NzSubMenuComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
combineLatest([this.nzSubmenuService.mode$, this.nzSubmenuService.open$])
.pipe(takeUntil(this.destroy$))
.subscribe((/**
* @param {?} __0
* @return {?}
*/
function (_a) {
var _b = __read(_a, 2), mode = _b[0], open = _b[1];
if (open && mode === 'inline') {
_this.expandState = 'expanded';
}
else if (open && mode === 'horizontal') {
_this.expandState = 'bottom';
}
else if (open && mode === 'vertical') {
_this.expandState = 'active';
}
else {
_this.isMouseHover = false;
_this.expandState = 'collapsed';
}
_this.overlayPositions =
mode === 'horizontal' ? [POSITION_MAP.bottomLeft] : [POSITION_MAP.rightTop, POSITION_MAP.leftTop];
if (open !== _this.nzOpen) {
_this.setTriggerWidth();
_this.nzOpen = open;
_this.nzOpenChange.emit(_this.nzOpen);
}
_this.setClassMap();
}));
this.nzSubmenuService.menuOpen$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} data
* @return {?}
*/
function (data) {
_this.nzMenuService.menuOpen$.next(data);
}));
merge(this.nzMenuService.mode$, this.nzMenuService.inlineIndent$, this.nzSubmenuService.level$, this.nzSubmenuService.open$, this.nzSubmenuService.mode$)
.pipe(takeUntil(this.destroy$))
.subscribe((/**
* @return {?}
*/
function () {
_this.cdr.markForCheck();
}));
};
/**
* @return {?}
*/
NzSubMenuComponent.prototype.ngAfterContentInit = /**
* @return {?}
*/
function () {
var _this = this;
this.setTriggerWidth();
this.listOfNzMenuItemDirective.changes
.pipe(startWith(true), flatMap((/**
* @return {?}
*/
function () {
return merge.apply(void 0, __spread([_this.listOfNzMenuItemDirective.changes], _this.listOfNzMenuItemDirective.map((/**
* @param {?} menu
* @return {?}
*/
function (menu) { return menu.selected$; }))));
})), startWith(true), map((/**
* @return {?}
*/
function () { return _this.listOfNzMenuItemDirective.some((/**
* @param {?} e
* @return {?}
*/
function (e) { return e.nzSelected; })); })), takeUntil(this.destroy$))
.subscribe((/**
* @param {?} selected
* @return {?}
*/
function (selected) {
_this.isChildMenuSelected = selected;
_this.setClassMap();
}));
};
/**
* @param {?} changes
* @return {?}
*/
NzSubMenuComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.nzOpen) {
this.nzSubmenuService.setOpenState(this.nzOpen);
this.setTriggerWidth();
}
if (changes.nzDisabled) {
this.nzSubmenuService.disabled = this.nzDisabled;
this.setClassMap();
}
};
/**
* @return {?}
*/
NzSubMenuComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.destroy$.next();
this.destroy$.complete();
};
NzSubMenuComponent.decorators = [
{ type: Component, args: [{
selector: '[nz-submenu]',
exportAs: 'nzSubmenu',
providers: [NzSubmenuService, NzUpdateHostClassService],
animations: [collapseMotion, zoomBigMotion, slideMotion],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
template: "<div cdkOverlayOrigin\n #origin=\"cdkOverlayOrigin\"\n [class.ant-dropdown-menu-submenu-title]=\"nzMenuService.isInDropDown\"\n [class.ant-menu-submenu-title]=\"!nzMenuService.isInDropDown\"\n [style.paddingLeft.px]=\"nzMenuService.mode === 'inline'? (nzPaddingLeft ? nzPaddingLeft : nzSubmenuService.level * nzMenuService.inlineIndent) : null\"\n (mouseenter)=\"setMouseEnterState(true)\"\n (mouseleave)=\"setMouseEnterState(false)\"\n (click)=\"clickSubMenuTitle()\">\n <i nz-icon [nzType]=\"nzIcon\" *ngIf=\"nzIcon\"></i>\n <ng-container *nzStringTemplateOutlet=\"nzTitle\"><span>{{ nzTitle }}</span></ng-container>\n <ng-content select=\"[title]\" *ngIf=\"!nzTitle\"></ng-content>\n <span *ngIf=\"nzMenuService.isInDropDown; else notDropdownTpl\" class=\"ant-dropdown-menu-submenu-arrow\">\n <i nz-icon nzType=\"right\" class=\"anticon-right ant-dropdown-menu-submenu-arrow-icon\"></i>\n </span>\n <ng-template #notDropdownTpl>\n <i class=\"ant-menu-submenu-arrow\"></i>\n </ng-template>\n</div>\n<ul *ngIf=\"nzMenuService.mode === 'inline'\"\n [@collapseMotion]=\"expandState\"\n [@.disabled]=\"noAnimation?.nzNoAnimation\"\n [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n [ngClass]=\"nzMenuClassName\"\n class=\"ant-menu ant-menu-inline ant-menu-sub\">\n <ng-template [ngTemplateOutlet]=\"subMenuTemplate\"></ng-template>\n</ul>\n<ng-template cdkConnectedOverlay\n (positionChange)=\"onPositionChange($event)\"\n [cdkConnectedOverlayPositions]=\"overlayPositions\"\n [cdkConnectedOverlayOrigin]=\"origin\"\n [cdkConnectedOverlayWidth]=\"triggerWidth\"\n [cdkConnectedOverlayOpen]=\"nzOpen && nzMenuService.mode !== 'inline'\">\n <div class=\"ant-menu-submenu ant-menu-submenu-popup\"\n [@slideMotion]=\"expandState\"\n [@zoomBigMotion]=\"expandState\"\n [@.disabled]=\"noAnimation?.nzNoAnimation\"\n [nzNoAnimation]=\"noAnimation?.nzNoAnimation\"\n [class.ant-menu-light]=\"nzMenuService.theme === 'light'\"\n [class.ant-menu-dark]=\"nzMenuService.theme === 'dark'\"\n [class.ant-menu-submenu-placement-bottomLeft]=\"nzSubmenuService.mode === 'horizontal'\"\n [class.ant-menu-submenu-placement-rightTop]=\"nzSubmenuService.mode === 'vertical' && placement === 'rightTop'\"\n [class.ant-menu-submenu-placement-leftTop]=\"nzSubmenuService.mode === 'vertical' && placement === 'leftTop'\"\n (mouseleave)=\"setMouseEnterState(false)\"\n (mouseenter)=\"setMouseEnterState(true)\">\n <ul [class.ant-dropdown-menu]=\"nzMenuService.isInDropDown\"\n [class.ant-menu]=\"!nzMenuService.isInDropDown\"\n [class.ant-dropdown-menu-vertical]=\"nzMenuService.isInDropDown\"\n [class.ant-menu-vertical]=\"!nzMenuService.isInDropDown\"\n [class.ant-dropdown-menu-sub]=\"nzMenuService.isInDropDown\"\n [class.ant-menu-sub]=\"!nzMenuService.isInDropDown\"\n [ngClass]=\"nzMenuClassName\">\n <ng-template [ngTemplateOutlet]=\"subMenuTemplate\"></ng-template>\n </ul>\n </div>\n</ng-template>\n\n<ng-template #subMenuTemplate>\n <ng-content></ng-content>\n</ng-template>\n",
styles: ["\n :root .ant-menu-submenu.ant-menu-submenu-placement-bottomLeft {\n top: 6px;\n position: relative;\n }\n\n :root .ant-menu-submenu.ant-menu-submenu-placement-rightTop {\n left: 4px;\n position: relative;\n }\n\n :root .ant-menu-submenu.ant-menu-submenu-placement-leftTop {\n right: 4px;\n position: relative;\n }\n "]
}] }
];
/** @nocollapse */
NzSubMenuComponent.ctorParameters = function () { return [
{ type: ElementRef },
{ type: NzMenuBaseService },
{ type: ChangeDetectorRef },
{ type: NzSubmenuService },
{ type: NzUpdateHostClassService },
{ type: Platform },
{ type: NzNoAnimationDirective, decorators: [{ type: Host }, { type: Optional }] }
]; };
NzSubMenuComponent.propDecorators = {
nzMenuClassName: [{ type: Input }],
nzPaddingLeft: [{ type: Input }],
nzTitle: [{ type: Input }],
nzIcon: [{ type: Input }],
nzOpen: [{ type: Input }],
nzDisabled: [{ type: Input }],
nzOpenChange: [{ type: Output }],
cdkConnectedOverlay: [{ type: ViewChild, args: [CdkConnectedOverlay, { static: true },] }],
cdkOverlayOrigin: [{ type: ViewChild, args: [CdkOverlayOrigin, { static: true, read: ElementRef },] }],
listOfNzSubMenuComponent: [{ type: ContentChildren, args: [NzSubMenuComponent, { descendants: true },] }],
listOfNzMenuItemDirective: [{ type: ContentChildren, args: [NzMenuItemDirective, { descendants: true },] }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzSubMenuComponent.prototype, "nzOpen", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzSubMenuComponent.prototype, "nzDisabled", void 0);
return NzSubMenuComponent;
}());
if (false) {
/** @type {?} */
NzSubMenuComponent.prototype.nzMenuClassName;
/** @type {?} */
NzSubMenuComponent.prototype.nzPaddingLeft;
/** @type {?} */
NzSubMenuComponent.prototype.nzTitle;
/** @type {?} */
NzSubMenuComponent.prototype.nzIcon;
/** @type {?} */
NzSubMenuComponent.prototype.nzOpen;
/** @type {?} */
NzSubMenuComponent.prototype.nzDisabled;
/** @type {?} */
NzSubMenuComponent.prototype.nzOpenChange;
/** @type {?} */
NzSubMenuComponent.prototype.cdkConnectedOverlay;
/** @type {?} */
NzSubMenuComponent.prototype.cdkOverlayOrigin;
/** @type {?} */
NzSubMenuComponent.prototype.listOfNzSubMenuComponent;
/** @type {?} */
NzSubMenuComponent.prototype.listOfNzMenuItemDirective;
/** @type {?} */
NzSubMenuComponent.prototype.placement;
/** @type {?} */
NzSubMenuComponent.prototype.triggerWidth;
/** @type {?} */
NzSubMenuComponent.prototype.expandState;
/** @type {?} */
NzSubMenuComponent.prototype.overlayPositions;
/**
* @type {?}
* @private
*/
NzSubMenuComponent.prototype.destroy$;
/**
* @type {?}
* @private
*/
NzSubMenuComponent.prototype.isChildMenuSelected;
/**
* @type {?}
* @private
*/
NzSubMenuComponent.prototype.isMouseHover;
/**
* @type {?}
* @private
*/
NzSubMenuComponent.prototype.elementRef;
/** @type {?} */
NzSubMenuComponent.prototype.nzMenuService;
/**
* @type {?}
* @private
*/
NzSubMenuComponent.prototype.cdr;
/** @type {?} */
NzSubMenuComponent.prototype.nzSubmenuService;
/**
* @type {?}
* @private
*/
NzSubMenuComponent.prototype.nzUpdateHostClassService;
/**
* @type {?}
* @private
*/
NzSubMenuComponent.prototype.platform;
/** @type {?} */
NzSubMenuComponent.prototype.noAnimation;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ɵ0 = NzMenuServiceFactory;
var NzMenuDirective = /** @class */ (function () {
function NzMenuDirective(elementRef, nzMenuService, nzUpdateHostClassService) {
this.elementRef = elementRef;
this.nzMenuService = nzMenuService;
this.nzUpdateHostClassService = nzUpdateHostClassService;
this.destroy$ = new Subject();
this.listOfOpenedNzSubMenuComponent = [];
this.nzInlineIndent = 24;
this.nzTheme = 'light';
this.nzMode = 'vertical';
this.nzInDropDown = false;
this.nzInlineCollapsed = false;
this.nzSelectable = !this.nzMenuService.isInDropDown;
this.nzClick = new EventEmitter();
}
/**
* @return {?}
*/
NzMenuDirective.prototype.updateInlineCollapse = /**
* @return {?}
*/
function () {
if (this.listOfNzMenuItemDirective) {
if (this.nzInlineCollapsed) {
this.listOfOpenedNzSubMenuComponent = this.listOfNzSubMenuComponent.filter((/**
* @param {?} submenu
* @return {?}
*/
function (submenu) { return submenu.nzOpen; }));
this.listOfNzSubMenuComponent.forEach((/**
* @param {?} submenu
* @return {?}
*/
function (submenu) { return submenu.setOpenState(false); }));
this.nzMode = 'vertical';
}
else {
this.listOfOpenedNzSubMenuComponent.forEach((/**
* @param {?} submenu
* @return {?}
*/
function (submenu) { return submenu.setOpenState(true); }));
this.listOfOpenedNzSubMenuComponent = [];
this.nzMode = this.cacheMode;
}
this.nzMenuService.setMode(this.nzMode);
}
};
/**
* @return {?}
*/
NzMenuDirective.prototype.setClassMap = /**
* @return {?}
*/
function () {
var _a;
/** @type {?} */
var prefixName = this.nzMenuService.isInDropDown ? 'ant-dropdown-menu' : 'ant-menu';
this.nzUpdateHostClassService.updateHostClass(this.elementRef.nativeElement, (_a = {},
_a["" + prefixName] = true,
_a[prefixName + "-root"] = true,
_a[prefixName + "-" + this.nzTheme] = true,
_a[prefixName + "-" + this.nzMode] = true,
_a[prefixName + "-inline-collapsed"] = this.nzInlineCollapsed,
_a));
};
/**
* @return {?}
*/
NzMenuDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.setClassMap();
this.nzMenuService.menuItemClick$.pipe(takeUntil(this.destroy$)).subscribe((/**
* @param {?} menu
* @return {?}
*/
function (menu) {
_this.nzClick.emit(menu);
if (_this.nzSelectable) {
_this.listOfNzMenuItemDirective.forEach((/**
* @param {?} item
* @return {?}
*/
function (item) { return item.setSelectedState(item === menu); }));
}
}));
};
/**
* @return {?}
*/
NzMenuDirective.prototype.ngAfterContentInit = /**
* @return {?}
*/
function () {
this.cacheMode = this.nzMode;
this.updateInlineCollapse();
};
/**
* @param {?} changes
* @return {?}
*/
NzMenuDirective.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.nzInlineCollapsed) {
this.updateInlineCollapse();
}
if (changes.nzInlineIndent) {
this.nzMenuService.setInlineIndent(this.nzInlineIndent);
}
if (changes.nzInDropDown) {
this.nzMenuService.isInDropDown = this.nzInDropDown;
}
if (changes.nzTheme) {
this.nzMenuService.setTheme(this.nzTheme);
}
if (changes.nzMode) {
this.nzMenuService.setMode(this.nzMode);
if (!changes.nzMode.isFirstChange() && this.listOfNzSubMenuComponent) {
this.listOfNzSubMenuComponent.forEach((/**
* @param {?} submenu
* @return {?}
*/
function (submenu) { return submenu.setOpenState(false); }));
}
}
if (changes.nzTheme || changes.nzMode || changes.nzInlineCollapsed) {
this.setClassMap();
}
};
/**
* @return {?}
*/
NzMenuDirective.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.destroy$.next();
this.destroy$.complete();
};
NzMenuDirective.decorators = [
{ type: Directive, args: [{
selector: '[nz-menu]',
exportAs: 'nzMenu',
providers: [
NzUpdateHostClassService,
NzMenuService,
{
provide: NzMenuBaseService,
useFactory: ɵ0,
deps: [[new SkipSelf(), new Optional(), NzDropdownHigherOrderServiceToken], NzMenuService]
}
]
},] }
];
/** @nocollapse */
NzMenuDirective.ctorParameters = function () { return [
{ type: ElementRef },
{ type: NzMenuBaseService },
{ type: NzUpdateHostClassService }
]; };
NzMenuDirective.propDecorators = {
listOfNzMenuItemDirective: [{ type: ContentChildren, args: [NzMenuItemDirective, { descendants: true },] }],
listOfNzSubMenuComponent: [{ type: ContentChildren, args: [NzSubMenuComponent, { descendants: true },] }],
nzInlineIndent: [{ type: Input }],
nzTheme: [{ type: Input }],
nzMode: [{ type: Input }],
nzInDropDown: [{ type: Input }],
nzInlineCollapsed: [{ type: Input }],
nzSelectable: [{ type: Input }],
nzClick: [{ type: Output }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzMenuDirective.prototype, "nzInDropDown", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzMenuDirective.prototype, "nzInlineCollapsed", void 0);
__decorate([
InputBoolean(),
__metadata("design:type", Object)
], NzMenuDirective.prototype, "nzSelectable", void 0);
return NzMenuDirective;
}());
if (false) {
/**
* @type {?}
* @private
*/
NzMenuDirective.prototype.destroy$;
/**
* @type {?}
* @private
*/
NzMenuDirective.prototype.cacheMode;
/**
* @type {?}
* @private
*/
NzMenuDirective.prototype.listOfOpenedNzSubMenuComponent;
/** @type {?} */
NzMenuDirective.prototype.listOfNzMenuItemDirective;
/** @type {?} */
NzMenuDirective.prototype.listOfNzSubMenuComponent;
/** @type {?} */
NzMenuDirective.prototype.nzInlineIndent;
/** @type {?} */
NzMenuDirective.prototype.nzTheme;
/** @type {?} */
NzMenuDirective.prototype.nzMode;
/** @type {?} */
NzMenuDirective.prototype.nzInDropDown;
/** @type {?} */
NzMenuDirective.prototype.nzInlineCollapsed;
/** @type {?} */
NzMenuDirective.prototype.nzSelectable;
/** @type {?} */
NzMenuDirective.prototype.nzClick;
/** @type {?} */
NzMenuDirective.prototype.elementRef;
/**
* @type {?}
* @private
*/
NzMenuDirective.prototype.nzMenuService;
/**
* @type {?}
* @private
*/
NzMenuDirective.prototype.nzUpdateHostClassService;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzMenuGroupComponent = /** @class */ (function () {
function NzMenuGroupComponent(elementRef, renderer) {
this.elementRef = elementRef;
this.renderer = renderer;
this.renderer.addClass(elementRef.nativeElement, 'ant-menu-item-group');
}
NzMenuGroupComponent.decorators = [
{ type: Component, args: [{
selector: '[nz-menu-group]',
exportAs: 'nzMenuGroup',
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
template: "<div class=\"ant-menu-item-group-title\">\n <ng-container *nzStringTemplateOutlet=\"nzTitle\">{{ nzTitle }}</ng-container>\n <ng-content select=\"[title]\" *ngIf=\"!nzTitle\"></ng-content>\n</div>\n<ul class=\"ant-menu-item-group-list\">\n <ng-content></ng-content>\n</ul>",
preserveWhitespaces: false
}] }
];
/** @nocollapse */
NzMenuGroupComponent.ctorParameters = function () { return [
{ type: ElementRef },
{ type: Renderer2 }
]; };
NzMenuGroupComponent.propDecorators = {
nzTitle: [{ type: Input }]
};
return NzMenuGroupComponent;
}());
if (false) {
/** @type {?} */
NzMenuGroupComponent.prototype.nzTitle;
/** @type {?} */
NzMenuGroupComponent.prototype.elementRef;
/**
* @type {?}
* @private
*/
NzMenuGroupComponent.prototype.renderer;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzMenuDividerDirective = /** @class */ (function () {
function NzMenuDividerDirective(elementRef, renderer) {
this.elementRef = elementRef;
this.renderer = renderer;
this.renderer.addClass(elementRef.nativeElement, 'ant-dropdown-menu-item-divider');
}
NzMenuDividerDirective.decorators = [
{ type: Directive, args: [{
selector: '[nz-menu-divider]',
exportAs: 'nzMenuDivider'
},] }
];
/** @nocollapse */
NzMenuDividerDirective.ctorParameters = function () { return [
{ type: ElementRef },
{ type: Renderer2 }
]; };
return NzMenuDividerDirective;
}());
if (false) {
/** @type {?} */
NzMenuDividerDirective.prototype.elementRef;
/**
* @type {?}
* @private
*/
NzMenuDividerDirective.prototype.renderer;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzMenuModule = /** @class */ (function () {
function NzMenuModule() {
}
NzMenuModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
FormsModule,
PlatformModule,
NzButtonModule,
OverlayModule,
NzIconModule,
NzNoAnimationModule,
NzAddOnModule
],
declarations: [
NzMenuDirective,
NzMenuItemDirective,
NzSubMenuComponent,
NzMenuDividerDirective,
NzMenuGroupComponent
],
exports: [NzMenuDirective, NzMenuItemDirective, NzSubMenuComponent, NzMenuDividerDirective, NzMenuGroupComponent]
},] }
];
return NzMenuModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { NzMenuDirective, NzMenuDividerDirective, NzMenuGroupComponent, NzMenuItemDirective, NzMenuModule, NzMenuService, NzMenuServiceFactory, NzSubMenuComponent, NzSubmenuService };
//# sourceMappingURL=ng-zorro-antd-menu.js.map