UNPKG

@angular-mdc/web

Version:
255 lines (241 loc) 8.91 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 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular-mdc/web/base'), require('@material/floating-label')) : typeof define === 'function' && define.amd ? define('@angular-mdc/web/floating-label', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular-mdc/web/base', '@material/floating-label'], factory) : (global = global || self, factory((global.ng = global.ng || {}, global.ng.web = global.ng.web || {}, global.ng.web.floatingLabel = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.web.base, global.mdc.floatingLabel)); }(this, (function (exports, core, rxjs, operators, base, floatingLabel) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var _extendStatics = function extendStatics(d, b) { _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; } || function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) d[p] = b[p]; } }; return _extendStatics(d, b); }; function __extends(d, b) { _extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } /** * @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 rxjs.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 floatingLabel.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 rxjs.fromEvent(_this._getHostElement(), 'animationend') .pipe(operators.takeUntil(_this._destroy), operators.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(floatingLabel.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: core.Directive, args: [{ selector: 'label[mdcFloatingLabel], mdc-floating-label', exportAs: 'mdcFloatingLabel', host: { 'class': 'mdc-floating-label', '[for]': 'for' } },] }, ]; /** @nocollapse */ MdcFloatingLabel.ctorParameters = function () { return [ { type: core.NgZone }, { type: core.ElementRef } ]; }; MdcFloatingLabel.propDecorators = { for: [{ type: core.Input }] }; return MdcFloatingLabel; }(base.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: core.NgModule, args: [{ exports: [MdcFloatingLabel], declarations: [MdcFloatingLabel] },] }, ]; return MdcFloatingLabelModule; }()); exports.MdcFloatingLabel = MdcFloatingLabel; exports.MdcFloatingLabelModule = MdcFloatingLabelModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=web-floating-label.umd.js.map