UNPKG

ng2-materialize

Version:

An Angular 2+ wrap around Materialize library

54 lines (53 loc) 2.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var animations_1 = require("@angular/animations"); var core_1 = require("@angular/core"); var MzErrorMessageComponent = (function () { function MzErrorMessageComponent() { this.errorMessage = ''; } MzErrorMessageComponent.prototype.ngOnInit = function () { var _this = this; this.buildErrorMessage(); this.controlStatusChangesSubscription = this.control.statusChanges.subscribe(function () { return _this.buildErrorMessage(); }); }; MzErrorMessageComponent.prototype.ngOnDestroy = function () { this.controlStatusChangesSubscription.unsubscribe(); }; MzErrorMessageComponent.prototype.buildErrorMessage = function () { var _this = this; this.errorMessage = ''; if (this.control.errors && this.errorMessageResource) { Object.keys(this.control.errors).forEach(function (key) { _this.errorMessage += _this.errorMessageResource[key] + ' '; }); } }; return MzErrorMessageComponent; }()); MzErrorMessageComponent.decorators = [ { type: core_1.Component, args: [{ selector: 'mz-error-message', template: "<div [@enterAnimation]=\"errorMessage\" class=\"invalid\" *ngIf=\"(control.touched || control.dirty) && control.invalid && errorMessage\">{{ errorMessage }}</div>", styles: ["div.invalid{color:#e30613;font-size:.8rem;opacity:1;overflow-wrap:break-word}input:not([type=checkbox])+label+:host div.invalid,mz-select-container :host div.invalid,textarea+label+:host div.invalid{margin-top:-19px;min-height:19px}"], animations: [ animations_1.trigger('enterAnimation', [ animations_1.transition(':enter', [ animations_1.style({ transform: 'translateY(-5px)', opacity: 0 }), animations_1.animate('300ms', animations_1.style({ transform: 'translateY(0)', opacity: 1 })), ]), animations_1.transition(':leave', [ animations_1.style({ transform: 'translateY(0)', opacity: 1 }), animations_1.animate('300ms', animations_1.style({ transform: 'translateY(-5px)', opacity: 0 })), ]), ]), ], },] }, ]; /** @nocollapse */ MzErrorMessageComponent.ctorParameters = function () { return []; }; MzErrorMessageComponent.propDecorators = { 'control': [{ type: core_1.Input },], 'errorMessageResource': [{ type: core_1.Input },], }; exports.MzErrorMessageComponent = MzErrorMessageComponent;