import * as tslib_1 from "tslib";
import { Input, Directive, ElementRef, ChangeDetectorRef } from '@angular/core';
import { coerceBooleanProperty } from '../util/coerce';
import { TextareaConfig } from './textarea.config';
import { OnChange } from '../core/decorators';
var TextareaDirective = /** @class */ (function () {
    function TextareaDirective(el, _config, cd) {
        this.el = el;
        this._config = _config;
        this.cd = cd;
        /**
         * textarea theme, there two default themes: 'default' | 'error'
         * @default default
         */
        this.theme = 'default';
        /**
         * Whether the textarea is disabled
         * @default false
         */
        this.disabled = false;
        Object.assign(this, _config);
    }
    TextareaDirective.prototype.ngOnChanges = function (changes) {
        // refresh class list
        if (changes['theme']) {
            this.setClass();
        }
        if (changes['disabled']) {
            this.disabled = coerceBooleanProperty(changes['disabled'].currentValue);
        }
    };
    TextareaDirective.prototype.ngAfterViewInit = function () {
        // init class list
        this.setClass();
    };
    /**
     * set host element classes
     * @docs-private
     */
    TextareaDirective.prototype.setClass = function () {
        var nativeEl = this.el.nativeElement;
        nativeEl.className = this.getClassName();
    };
    /**
     * get host element classes, depends on the theme.
     * @return {string} class names
     * @docs-private
     */
    TextareaDirective.prototype.getClassName = function () {
        return [
            'nb-widget',
            'nb-textarea',
            "nb-textarea-theme-" + (this.theme || 'default')
        ].join(' ');
    };
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], TextareaDirective.prototype, "theme", void 0);
    tslib_1.__decorate([
        OnChange(true),
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], TextareaDirective.prototype, "disabled", void 0);
    TextareaDirective = tslib_1.__decorate([
        Directive({
            selector: '[nbTextarea]',
            exportAs: 'nbTextarea',
            host: {
                '[disabled]': 'disabled || null'
            }
        }),
        tslib_1.__metadata("design:paramtypes", [ElementRef,
            TextareaConfig,
            ChangeDetectorRef])
    ], TextareaDirective);
    return TextareaDirective;
}());
export { TextareaDirective };
//# sourceMappingURL=textarea.js.map