UNPKG

ng-zorro-antd

Version:

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

95 lines 12.6 kB
import { NgTemplateOutlet } from '@angular/common'; import { ChangeDetectionStrategy, Component, Input, Optional, ViewEncapsulation } from '@angular/core'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; import { collapseMotion } from 'ng-zorro-antd/core/animation'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/bidi"; export class NzSubmenuInlineChildComponent { constructor(elementRef, renderer, directionality) { this.elementRef = elementRef; this.renderer = renderer; this.directionality = directionality; this.templateOutlet = null; this.menuClass = ''; this.mode = 'vertical'; this.nzOpen = false; this.listOfCacheClassName = []; this.expandState = 'collapsed'; this.dir = 'ltr'; this.destroy$ = new Subject(); } calcMotionState() { if (this.nzOpen) { this.expandState = 'expanded'; } else { this.expandState = 'collapsed'; } } ngOnInit() { this.calcMotionState(); this.dir = this.directionality.value; this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction) => { this.dir = direction; }); } ngOnChanges(changes) { const { mode, nzOpen, menuClass } = changes; if (mode || nzOpen) { this.calcMotionState(); } if (menuClass) { if (this.listOfCacheClassName.length) { this.listOfCacheClassName .filter(item => !!item) .forEach(className => { this.renderer.removeClass(this.elementRef.nativeElement, className); }); } if (this.menuClass) { this.listOfCacheClassName = this.menuClass.split(' '); this.listOfCacheClassName .filter(item => !!item) .forEach(className => { this.renderer.addClass(this.elementRef.nativeElement, className); }); } } } ngOnDestroy() { this.destroy$.next(); this.destroy$.complete(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzSubmenuInlineChildComponent, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i1.Directionality, optional: true }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.4", type: NzSubmenuInlineChildComponent, isStandalone: true, selector: "[nz-submenu-inline-child]", inputs: { templateOutlet: "templateOutlet", menuClass: "menuClass", mode: "mode", nzOpen: "nzOpen" }, host: { properties: { "class.ant-menu-rtl": "dir === 'rtl'", "@collapseMotion": "expandState" }, classAttribute: "ant-menu ant-menu-inline ant-menu-sub" }, exportAs: ["nzSubmenuInlineChild"], usesOnChanges: true, ngImport: i0, template: ` <ng-template [ngTemplateOutlet]="templateOutlet"></ng-template> `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], animations: [collapseMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.4", ngImport: i0, type: NzSubmenuInlineChildComponent, decorators: [{ type: Component, args: [{ selector: '[nz-submenu-inline-child]', animations: [collapseMotion], exportAs: 'nzSubmenuInlineChild', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: ` <ng-template [ngTemplateOutlet]="templateOutlet"></ng-template> `, host: { class: 'ant-menu ant-menu-inline ant-menu-sub', '[class.ant-menu-rtl]': `dir === 'rtl'`, '[@collapseMotion]': 'expandState' }, imports: [NgTemplateOutlet], standalone: true }] }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i1.Directionality, decorators: [{ type: Optional }] }], propDecorators: { templateOutlet: [{ type: Input }], menuClass: [{ type: Input }], mode: [{ type: Input }], nzOpen: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3VibWVudS1pbmxpbmUtY2hpbGQuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vY29tcG9uZW50cy9tZW51L3N1Ym1lbnUtaW5saW5lLWNoaWxkLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1h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