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