/** * @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, NgZone } from '@angular/core'; import * as i0 from "@angular/core"; /** Class added when the line ripple is active. */ const ACTIVATE_CLASS = 'mdc-line-ripple--active'; /** Class added when the line ripple is being deactivated. */ const DEACTIVATING_CLASS = 'mdc-line-ripple--deactivating'; /** * Internal directive that creates an instance of the MDC line-ripple component. Using a * directive allows us to conditionally render a line-ripple in the template without having * to manually create and destroy the `MDCLineRipple` component whenever the condition changes. * * The directive sets up the styles for the line-ripple and provides an API for activating * and deactivating the line-ripple. */ export class MatFormFieldLineRipple { constructor(_elementRef, ngZone) { this._elementRef = _elementRef; this._handleTransitionEnd = (event) => { const classList = this._elementRef.nativeElement.classList; const isDeactivating = classList.contains(DEACTIVATING_CLASS); if (event.propertyName === 'opacity' && isDeactivating) { classList.remove(ACTIVATE_CLASS, DEACTIVATING_CLASS); } }; ngZone.runOutsideAngular(() => { _elementRef.nativeElement.addEventListener('transitionend', this._handleTransitionEnd); }); } activate() { const classList = this._elementRef.nativeElement.classList; classList.remove(DEACTIVATING_CLASS); classList.add(ACTIVATE_CLASS); } deactivate() { this._elementRef.nativeElement.classList.add(DEACTIVATING_CLASS); } ngOnDestroy() { this._elementRef.nativeElement.removeEventListener('transitionend', this._handleTransitionEnd); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatFormFieldLineRipple, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatFormFieldLineRipple, selector: "div[matFormFieldLineRipple]", host: { classAttribute: "mdc-line-ripple" }, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatFormFieldLineRipple, decorators: [{ type: Directive, args: [{ selector: 'div[matFormFieldLineRipple]', host: { 'class': 'mdc-line-ripple', }, }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGluZS1yaXBwbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvZm9ybS1maWVsZC9kaXJlY3RpdmVzL2xpbmUtcmlwcGxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxTQUFTLEVBQUUsVUFBVSxFQUFFLE1BQU0sRUFBWSxNQUFNLGVBQWUsQ0FBQzs7QUFFdkUsa0RBQWtEO0FBQ2xELE1BQU0sY0FBYyxHQUFHLHlCQUF5QixDQUFDO0FBRWpELDZEQUE2RDtBQUM3RCxNQUFNLGtCQUFrQixHQUFHLCtCQUErQixDQUFDO0FBRTNEOzs7Ozs7O0dBT0c7QUFPSCxNQUFNLE9BQU8sc0JBQXNCO0lBQ2pDLFlBQW9CLFdBQW9DLEVBQUUsTUFBYztRQUFwRCxnQkFBVyxHQUFYLFdBQVcsQ0FBeUI7UUFnQmhELHlCQUFvQixHQUFHLENBQUMsS0FBc0IsRUFBRSxFQUFFO1lBQ3hELE1BQU0sU0FBUyxHQUFHLElBQUksQ0FBQyxXQUFXLENBQUMsYUFBYSxDQUFDLFNBQVMsQ0FBQztZQUMzRCxNQUFNLGNBQWMsR0FBRyxTQUFTLENBQUMsUUFBUSxDQUFDLGtCQUFrQixDQUFDLENBQUM7WUFFOUQsSUFBSSxLQUFLLENBQUMsWUFBWSxLQUFLLFNBQVMsSUFBSSxjQUFjLEVBQUU7Z0JBQ3RELFNBQVMsQ0FBQyxNQUFNLENBQUMsY0FBYyxFQUFFLGtCQUFrQixDQUFDLENBQUM7YUFDdEQ7UUFD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