UNPKG

@taiga-ui/kit

Version:
57 lines (52 loc) 1.71 kB
import { __decorate, __param } from 'tslib'; import { ElementRef, Inject, Input, Directive, NgModule } from '@angular/core'; import { tuiDefaultProp } from '@taiga-ui/cdk'; /** * A directive for projecting classes from nested children to host */ let TuiProjectClassDirective = class TuiProjectClassDirective { constructor(elementRef) { this.elementRef = elementRef; this.classNames = []; } ngAfterViewChecked() { if (!this.classNames.length) { return; } this.classNames.forEach(className => { const hostElement = this.elementRef.nativeElement; if (hostElement.querySelector(`.${className}`)) { hostElement.classList.add(className); } else { hostElement.classList.remove(className); } }); } }; TuiProjectClassDirective.ctorParameters = () => [ { type: ElementRef, decorators: [{ type: Inject, args: [ElementRef,] }] } ]; __decorate([ Input('tuiProjectClass'), tuiDefaultProp() ], TuiProjectClassDirective.prototype, "classNames", void 0); TuiProjectClassDirective = __decorate([ Directive({ selector: '[tuiProjectClass]', }), __param(0, Inject(ElementRef)) ], TuiProjectClassDirective); let TuiProjectClassModule = class TuiProjectClassModule { }; TuiProjectClassModule = __decorate([ NgModule({ declarations: [TuiProjectClassDirective], exports: [TuiProjectClassDirective], }) ], TuiProjectClassModule); /** * Generated bundle index. Do not edit. */ export { TuiProjectClassDirective, TuiProjectClassModule }; //# sourceMappingURL=taiga-ui-kit-directives-project-class.js.map