UNPKG

@angular-mdc/web

Version:
211 lines (207 loc) 6.43 kB
/** * @license * Copyright (c) Dominic Carretto * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/trimox/angular-mdc-web/blob/master/LICENSE */ import { Directive, NgZone, ElementRef, Input, NgModule } from '@angular/core'; import { __extends } from 'tslib'; import { Subject, fromEvent } from 'rxjs'; import { takeUntil, filter } from 'rxjs/operators'; import { MDCComponent } from '@angular-mdc/web/base'; import { MDCFloatingLabelFoundation, cssClasses } from '@material/floating-label'; /** * @fileoverview added by tsickle * Generated from: floating-label/floating-label.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MdcFloatingLabel = /** @class */ (function (_super) { __extends(MdcFloatingLabel, _super); function MdcFloatingLabel(_ngZone, elementRef) { var _this = _super.call(this, elementRef) || this; _this._ngZone = _ngZone; _this.elementRef = elementRef; /** * Emits whenever the component is destroyed. */ _this._destroy = new Subject(); return _this; } /** * @return {?} */ MdcFloatingLabel.prototype.getDefaultFoundation = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var adapter = { addClass: (/** * @param {?} className * @return {?} */ function (className) { return _this._getHostElement().classList.add(className); }), removeClass: (/** * @param {?} className * @return {?} */ function (className) { return _this._getHostElement().classList.remove(className); }), getWidth: (/** * @return {?} */ function () { return _this._getHostElement().scrollWidth; }), registerInteractionHandler: (/** * @return {?} */ function () { }), deregisterInteractionHandler: (/** * @return {?} */ function () { }) }; return new MDCFloatingLabelFoundation(adapter); }; /** * @return {?} */ MdcFloatingLabel.prototype.ngAfterContentInit = /** * @return {?} */ function () { this._loadListeners(); }; /** * @return {?} */ MdcFloatingLabel.prototype.ngOnDestroy = /** * @return {?} */ function () { this._destroy.next(); this._destroy.complete(); }; /** Returns the width of the label element. */ /** * Returns the width of the label element. * @return {?} */ MdcFloatingLabel.prototype.getWidth = /** * Returns the width of the label element. * @return {?} */ function () { return this._foundation.getWidth(); }; /** Styles the label to produce the label shake for errors. */ /** * Styles the label to produce the label shake for errors. * @param {?} shouldShake * @return {?} */ MdcFloatingLabel.prototype.shake = /** * Styles the label to produce the label shake for errors. * @param {?} shouldShake * @return {?} */ function (shouldShake) { this._foundation.shake(shouldShake); }; /** Styles the label to float or dock. */ /** * Styles the label to float or dock. * @param {?} shouldFloat * @return {?} */ MdcFloatingLabel.prototype.float = /** * Styles the label to float or dock. * @param {?} shouldFloat * @return {?} */ function (shouldFloat) { this._foundation.float(shouldFloat); }; /** * @private * @return {?} */ MdcFloatingLabel.prototype._loadListeners = /** * @private * @return {?} */ function () { var _this = this; this._ngZone.runOutsideAngular((/** * @return {?} */ function () { return fromEvent(_this._getHostElement(), 'animationend') .pipe(takeUntil(_this._destroy), filter((/** * @param {?} e * @return {?} */ function (e) { return e.target === _this._getHostElement(); }))) .subscribe((/** * @return {?} */ function () { return _this._ngZone.run((/** * @return {?} */ function () { return _this._getHostElement().classList.remove(cssClasses.LABEL_SHAKE); })); })); })); }; /** Retrieves the DOM element of the component host. */ /** * Retrieves the DOM element of the component host. * @private * @return {?} */ MdcFloatingLabel.prototype._getHostElement = /** * Retrieves the DOM element of the component host. * @private * @return {?} */ function () { return this.elementRef.nativeElement; }; MdcFloatingLabel.decorators = [ { type: Directive, args: [{ selector: 'label[mdcFloatingLabel], mdc-floating-label', exportAs: 'mdcFloatingLabel', host: { 'class': 'mdc-floating-label', '[for]': 'for' } },] }, ]; /** @nocollapse */ MdcFloatingLabel.ctorParameters = function () { return [ { type: NgZone }, { type: ElementRef } ]; }; MdcFloatingLabel.propDecorators = { for: [{ type: Input }] }; return MdcFloatingLabel; }(MDCComponent)); /** * @fileoverview added by tsickle * Generated from: floating-label/module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var MdcFloatingLabelModule = /** @class */ (function () { function MdcFloatingLabelModule() { } MdcFloatingLabelModule.decorators = [ { type: NgModule, args: [{ exports: [MdcFloatingLabel], declarations: [MdcFloatingLabel] },] }, ]; return MdcFloatingLabelModule; }()); export { MdcFloatingLabel, MdcFloatingLabelModule }; //# sourceMappingURL=floating-label.es5.js.map