/** * @license * Copyright Google LLC 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://angular.io/license */ import { Directive, ElementRef, Inject, NgZone, Optional } from '@angular/core'; import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations'; import { take } from 'rxjs/operators'; import { _MAT_INK_BAR_POSITIONER } from '@angular/material/tabs'; import * as i0 from "@angular/core"; /** * The ink-bar is used to display and animate the line underneath the current active tab label. * @docs-private * @deprecated Use `MatInkBar` from `@angular/material/tabs` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. * @breaking-change 17.0.0 */ export class MatLegacyInkBar { constructor(_elementRef, _ngZone, _inkBarPositioner, _animationMode) { this._elementRef = _elementRef; this._ngZone = _ngZone; this._inkBarPositioner = _inkBarPositioner; this._animationMode = _animationMode; } /** * Calculates the styles from the provided element in order to align the ink-bar to that element. * Shows the ink bar if previously set as hidden. * @param element */ alignToElement(element) { this.show(); // `onStable` might not run for a while if the zone has already stabilized. // Wrap the call in `NgZone.run` to ensure that it runs relatively soon. this._ngZone.run(() => { this._ngZone.onStable.pipe(take(1)).subscribe(() => { const positions = this._inkBarPositioner(element); const inkBar = this._elementRef.nativeElement; inkBar.style.left = positions.left; inkBar.style.width = positions.width; }); }); } /** Shows the ink bar. */ show() { this._elementRef.nativeElement.style.visibility = 'visible'; } /** Hides the ink bar. */ hide() { this._elementRef.nativeElement.style.visibility = 'hidden'; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatLegacyInkBar, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: _MAT_INK_BAR_POSITIONER }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatLegacyInkBar, selector: "mat-ink-bar", host: { properties: { "class._mat-animation-noopable": "_animationMode === 'NoopAnimations'" }, classAttribute: "mat-ink-bar" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatLegacyInkBar, decorators: [{ type: Directive, args: [{ selector: 'mat-ink-bar', host: { 'class': 'mat-ink-bar', '[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`, }, }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: undefined, decorators: [{ type: Inject, args: [_MAT_INK_BAR_POSITIONER] }] }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE] }] }]; } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5rLWJhci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9sZWdhY3ktdGFicy9pbmstYmFyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxTQUFTLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBRSxNQUFNLEVBQUUsUUFBUSxFQUFDLE1BQU0sZUFBZSxDQUFDO0FBQzlFLE9BQU8sRUFBQyxxQkFBcUIsRUFBQyxNQUFNLHNDQUFzQyxDQUFDO0FBQzNFLE9BQU8sRUFBQyxJQUFJLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUNwQyxPQUFPLEVBQUMsdUJBQXVCLEVBQXVCLE1BQU0sd0JBQXdCLENBQUM7O0FBRXJGOzs7OztHQUtHO0FBUUgsTUFBTSxPQUFPLGVBQWU7SUFDMUIsWUFDVSxXQUFvQyxFQUNwQyxPQUFlLEVBQ2tCLGlCQUF1QyxFQUM5QixjQUF1QjtRQUhqRSxnQkFBVyxHQUFYLFdBQVcsQ0FBeUI7UUFDcEMsWUFBTyxHQUFQLE9BQU8sQ0FBUTtRQUNrQixz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