UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

234 lines 16.8 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; import { Directive, ElementRef, Input, Optional, Renderer2 } from '@angular/core'; import { merge, EMPTY, Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { NzUpdateHostClassService } from '../core/services/update-host-class.service'; import { isNotNil } from '../core/util'; import { InputBoolean } from '../core/util/convert'; import { NzMenuService } from './nz-menu.service'; import { NzSubmenuService } from './nz-submenu.service'; var NzMenuItemDirective = /** @class */ (function () { function NzMenuItemDirective(nzUpdateHostClassService, nzMenuService, nzSubmenuService, renderer, elementRef) { this.nzUpdateHostClassService = nzUpdateHostClassService; this.nzMenuService = nzMenuService; this.nzSubmenuService = nzSubmenuService; this.renderer = renderer; this.elementRef = elementRef; this.el = this.elementRef.nativeElement; this.destroy$ = new Subject(); this.originalPadding = null; this.selected$ = new Subject(); this.nzDisabled = false; this.nzSelected = false; } /** 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(); }; /** * @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(); }; /** * @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]', providers: [NzUpdateHostClassService], host: { '(click)': 'clickMenuItem($event)' } },] } ]; /** @nocollapse */ NzMenuItemDirective.ctorParameters = function () { return [ { type: NzUpdateHostClassService }, { type: NzMenuService }, { type: NzSubmenuService, decorators: [{ type: Optional }] }, { type: Renderer2 }, { type: ElementRef } ]; }; NzMenuItemDirective.propDecorators = { nzPaddingLeft: [{ type: Input }], nzDisabled: [{ type: Input }], nzSelected: [{ type: Input }] }; tslib_1.__decorate([ InputBoolean(), tslib_1.__metadata("design:type", Object) ], NzMenuItemDirective.prototype, "nzDisabled", void 0); tslib_1.__decorate([ InputBoolean(), tslib_1.__metadata("design:type", Object) ], NzMenuItemDirective.prototype, "nzSelected", void 0); return NzMenuItemDirective; }()); export { 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.nzPaddingLeft; /** @type {?} */ NzMenuItemDirective.prototype.nzDisabled; /** @type {?} */ NzMenuItemDirective.prototype.nzSelected; /** * @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; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotbWVudS1pdGVtLmRpcmVjdGl2ZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nLXpvcnJvLWFudGQteWovIiwic291cmNlcyI6WyJtZW51L256LW1lbnUtaXRlbS5kaXJlY3RpdmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxPQUFPLEVBQ0wsU0FBUyxFQUNULFVBQVUsRUFDVixLQUFLLEVBSUwsUUFBUSxFQUNSLFNBQVMsRUFFVixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQUUsS0FBSyxFQUFFLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxNQUFNLENBQUM7QUFDN0MsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBQzNDLE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDRDQUE0QyxDQUFDO0FBQ3RGL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29uc3QgcGFkZGluZ0xlZnQgPSB0aGlzLmVsLnN0eWxlLnBhZGRpbmdMZWZ0O1xuICAgIGlmIChwYWRkaW5nTGVmdCkge1xuICAgICAgdGhpcy5vcmlnaW5hbFBhZGRpbmcgPSBwYXJzZUludChwYWRkaW5nTGVmdCwgMTApO1xuICAgIH1cbiAgICBtZXJnZShcbiAgICAgIHRoaXMubnpNZW51U2VydmljZS5tb2RlJCxcbiAgICAgIHRoaXMubnpNZW51U2VydmljZS5pbmxpbmVJbmRlbnQkLFxuICAgICAgdGhpcy5uelN1Ym1lbnVTZXJ2aWNlID8gdGhpcy5uelN1Ym1lbnVTZXJ2aWNlLmxldmVsJCA6IEVNUFRZXG4gICAgKVxuICAgICAgLnBpcGUodGFrZVVudGlsKHRoaXMuZGVzdHJveSQpKVxuICAgICAgLnN1YnNjcmliZSgoKSA9PiB7XG4gICAgICAgIGxldCBwYWRkaW5nOiBudW1iZXIgfCBudWxsID0gbnVsbDtcbiAgICAgICAgaWYgKHRoaXMubnpNZW51U2VydmljZS5tb2RlID09PSAnaW5saW5lJykge1xuICAgICAgICAgIGlmIChpc05vdE5pbCh0aGlzLm56UGFkZGluZ0xlZnQpKSB7XG4gICAgICAgICAgICBwYWRkaW5nID0gdGhpcy5uelBhZGRpbmdMZWZ0O1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBsZXZlbCA9IHRoaXMubnpTdWJtZW51U2VydmljZSA/IHRoaXMubnpTdWJtZW51U2VydmljZS5sZXZlbCArIDEgOiAxO1xuICAgICAgICAgICAgcGFkZGluZyA9IGxldmVsICogdGhpcy5uek1lbnVTZXJ2aWNlLmlubGluZUluZGVudDtcbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGFkZGluZyA9IHRoaXMub3JpZ2luYWxQYWRkaW5nO1xuICAgICAgICB9XG4gICAgICAgIGlmIChwYWRkaW5nKSB7XG4gICAgICAgICAgdGhpcy5yZW5kZX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