import { Component, EventEmitter, forwardRef, Input, Output, ChangeDetectionStrategy, } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { EvoBaseControl } from '../../common/evo-base-control';
import { EvoControlStates } from '../../common/evo-control-state-manager/evo-control-states.enum';
import * as i0 from "@angular/core";
import * as i1 from "../evo-control-error/evo-control-error.component";
import * as i2 from "../../directives/evo-ui-class.directive";
import * as i3 from "@angular/common";
export class EvoTextareaComponent extends EvoBaseControl {
    constructor(injector, cdr) {
        super(injector);
        this.injector = injector;
        this.cdr = cdr;
        this.size = 'normal';
        this.placeholder = '';
        this.rows = 3;
        this.blur = new EventEmitter();
        this.value = '';
        this._focused = false;
        this._disabled = false;
        this.onChange = (_) => { };
        this.onTouched = () => { };
    }
    get textareaClasses() {
        return {
            focused: this._focused,
            disabled: this._disabled,
            valid: this.currentState[EvoControlStates.valid],
            invalid: this.currentState[EvoControlStates.invalid],
            [`size_${this.size}`]: this.size !== 'normal',
        };
    }
    handleOnChange(event) {
        const target = event.target;
        this.value = target.value;
        this.onChange(this.value);
    }
    onFocus() {
        if (!this._focused && !this._disabled) {
            this._focused = true;
            this.cdr.markForCheck();
        }
    }
    onBlur() {
        this._focused = false;
        if (this.value) {
            this.value = this.value.trim();
        }
        this.onTouched();
        this.blur.emit();
        this.cdr.markForCheck();
    }
    registerOnChange(fn) {
        this.onChange = fn;
    }
    registerOnTouched(fn) {
        this.onTouched = fn;
    }
    setDisabledState(isDisabled) {
        this._disabled = isDisabled;
        this.cdr.markForCheck();
    }
    writeValue(value) {
        this.value = value !== null && value !== void 0 ? value : '';
        this.cdr.markForCheck();
    }
}
EvoTextareaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: EvoTextareaComponent, deps: [{ token: i0.Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
EvoTextareaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: EvoTextareaComponent, selector: "evo-textarea", inputs: { size: "size", placeholder: "placeholder", rows: "rows" }, outputs: { blur: "blur" }, providers: [
        {
            provide: NG_VALUE_ACCESSOR,
            useExisting: forwardRef(() => EvoTextareaComponent),
            multi: true,
        },
    ], usesInheritance: true, ngImport: i0, template: "<textarea\n    class=\"evo-textarea\"\n    [evoUiClass]=\"textareaClasses\"\n    [placeholder]=\"placeholder\"\n    [rows]=\"rows\"\n    [value]=\"value\"\n    (input)=\"handleOnChange($event)\"\n    (focus)=\"onFocus()\"\n    (blur)=\"onBlur()\"\n></textarea>\n<evo-control-error\n    *ngIf=\"control?.invalid && control?.dirty && control?.touched\"\n    [errors]=\"control?.errors\"\n    [errorsMessages]=\"errorsMessages\"\n></evo-control-error>\n", styles: ["@keyframes evo-fx-blink{50%{transform:scale(1);opacity:1}to{opacity:0}}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes gradient{0%{background-position:0 50%}50%{background-position:50vw 50%}to{background-position:100vw 50%}}@keyframes evo-ellipsis-animation{0%{content:\"\"}25%{content:\".\"}50%{content:\"..\"}75%{content:\"...\"}to{content:\"\"}}:host{display:inline-block;--evo-input-prefix-content-margin: 4px 8px 4px 4px}.evo-input{--evo-input-padding-left: 12px;--evo-input-padding-right: 12px;--evo-input-padding-top: 8px;--evo-input-padding-bottom: 8px;position:relative;cursor:text}.evo-input_focused{border:solid 1px #74706F}.evo-input_disabled{color:#b0b0b0!important;background-color:#f9fafb!important;border:1px solid #E3E3E3!important;cursor:default;pointer-events:none}.evo-input_invalid{border-color:#ff1817!important}.evo-input_theme-default{--evo-input-height: 40px;--evo-input-border-radius: 4px;--evo-input-font-size: 14px;--evo-input-line-height: 24px;display:flex;align-items:center;height:var(--evo-input-height);color:#212121;font-weight:normal;font-size:var(--evo-input-font-size);font-family:var(--evo-font);line-height:var(--evo-input-line-height);white-space:nowrap;background-color:#fff;border:1px solid #C6C6C6;border-radius:var(--evo-input-border-radius);outline:none;transition:color .3s,box-shadow .3s,background .3s,border .3s}.evo-input_theme-default:hover{border:1px solid #9B9B9B}.evo-input_theme-default.evo-input_size-small{--evo-input-height: 40px;--evo-input-border-radius: 4px;--evo-input-font-size: 14px;--evo-input-line-height: 24px;--evo-input-height: 32px;display:flex;align-items:center;height:var(--evo-input-height);color:#212121;font-weight:normal;font-size:var(--evo-input-font-size);font-family:var(--evo-font);line-height:var(--evo-input-line-height);white-space:nowrap;background-color:#fff;border:1px solid #C6C6C6;border-radius:var(--evo-input-border-radius);outline:none;transition:color .3s,box-shadow .3s,background .3s,border .3s}.evo-input_theme-default.evo-input_size-small:hover{border:1px solid #9B9B9B}.evo-input_theme-default.evo-input_size-small .evo-input__field{--evo-input-padding-left: 12px;--evo-input-padding-right: 12px;--evo-input-padding-top: 4px;--evo-input-padding-bottom: 4px}.evo-input_theme-default.evo-input_size-small .evo-input__field:not(:last-child){--evo-input-padding-right: 0}.evo-input_theme-rounded{--evo-input-height: 40px;--evo-input-border-radius: 4px;--evo-input-font-size: 14px;--evo-input-line-height: 24px;--evo-input-border-radius: 256px;display:flex;align-items:center;height:var(--evo-input-height);color:#212121;font-weight:normal;font-size:var(--evo-input-font-size);font-family:var(--evo-font);line-height:var(--evo-input-line-height);white-space:nowrap;background-color:#fff;border:1px solid #C6C6C6;border-radius:var(--evo-input-border-radius);outline:none;transition:color .3s,box-shadow .3s,background .3s,border .3s}.evo-input_theme-rounded:hover{border:1px solid #9B9B9B}.evo-input_theme-rounded.evo-input_size-small{--evo-input-border-radius: 4px;--evo-input-line-height: 24px;--evo-input-font-size: 14px;--evo-input-height: 40px;--evo-input-border-radius: 256px;display:flex;align-items:center;height:var(--evo-input-height);color:#212121;font-weight:normal;font-size:var(--evo-input-font-size);font-family:var(--evo-font);line-height:var(--evo-input-line-height);white-space:nowrap;background-color:#fff;border:1px solid #C6C6C6;border-radius:var(--evo-input-border-radius);outline:none;transition:color .3s,box-shadow .3s,background .3s,border .3s}.evo-input_theme-rounded.evo-input_size-small:hover{border:1px solid #9B9B9B}.evo-input_theme-rounded.evo-input_size-small .evo-input__field{--evo-input-padding-left: 12px}.evo-input_theme-rounded.evo-input_size-small .evo-input__field:last-child{--evo-input-padding-right: 12px}.evo-input_size-small{height:32px}.evo-input_size-small .evo-input__icon{margin-right:8px}.evo-input_size-small .evo-input__icon img{max-height:16px}.evo-input_size-small .evo-input__tooltip-container{top:100%}.evo-input_size-small .evo-input__tooltip-container:before{left:calc(100% - 28px)}@media (min-width: 1200px){.evo-input_size-small .evo-input__tooltip-container{top:calc(100% + 4px)}.evo-input_size-small .evo-input__tooltip-container:before{left:calc(50% - 6px)}}.evo-input__prefix-icon{display:flex;flex-shrink:0;justify-content:center;align-items:center;width:24px;height:24px;margin-left:8px;fill:#91b1b8}.evo-input__prefix-icon:empty{display:none}.evo-input__prefix-icon:not(:empty)~.evo-input__field{--evo-input-padding-left: 8px}.evo-input__prefix-content{display:inline-flex;flex-shrink:0;justify-content:center;align-items:center;margin:var(--evo-input-prefix-content-margin)}.evo-input__prefix-content:empty{display:none}.evo-input__prefix-content:not(:empty)~.evo-input__field{--evo-input-padding-left: 0}.evo-input__field{width:100%;height:100%;margin:0;padding:var(--evo-input-padding-top) var(--evo-input-padding-right) var(--evo-input-padding-bottom) var(--evo-input-padding-left);color:inherit;font-weight:inherit;font-size:inherit;border:none;border-radius:inherit;outline:none}.evo-input__field::-webkit-input-placeholder{color:#9b9b9b}.evo-input__field::-moz-placeholder{color:#9b9b9b;opacity:1}.evo-input__field:-ms-input-placeholder{color:#9b9b9b}.evo-input__field:disabled{color:#b0b0b0;background-color:#f9fafb!important}.evo-input__field:not(:last-child){--evo-input-padding-right: 0}.evo-input__prefix{padding-left:12px;transition:color .2s;color:#9b9b9b}.evo-input__prefix:not(:empty)~.evo-input__field{--evo-input-padding-left: 0}.evo-input__tooltip{flex:0 0 24px;width:24px;height:24px;margin:0 8px;cursor:pointer;-webkit-user-select:none;user-select:none;fill:#91b1b8}.evo-input__icon-clear{width:24px;height:24px;margin:0 8px;cursor:pointer;-webkit-user-select:none;user-select:none;fill:#91b1b8}.evo-input__icon{margin:0 8px}.evo-input__icon img{display:block;width:100%;max-width:60px;height:auto;max-height:22px}.evo-input__tooltip-container{position:absolute;top:calc(100% - 2px);left:0;z-index:1;display:flex;width:100%;padding:10px 10px 10px 20px;color:#212121;line-height:normal;white-space:normal;background-color:#fff8e6;border-radius:4px;box-shadow:0 4px 12px #0003;cursor:default}.evo-input__tooltip-container[hidden]{display:none!important}.evo-input__tooltip-container:before{position:absolute;top:-20px;left:calc(100% - 34px);border:10px solid transparent;border-bottom-color:#fff8e6;pointer-events:none;content:\"\"}@media (min-width: 1200px){.evo-input__tooltip-container{left:calc(50% - 22px)}.evo-input__tooltip-container:before{left:calc(50% - 12px)}}.evo-input__clearable{display:flex;justify-content:center;align-items:center}.evo-input__clearable+.evo-input__additional{margin-left:-10px}.evo-input__additional{display:flex;justify-content:center;align-items:center}.evo-input__additional:not(:last-child) .evo-input__icon{margin-right:8px}.evo-input__additional+.evo-input__loading-spinner{margin-left:0}.evo-input__loading-spinner{flex:0 0 24px;width:24px;height:24px;margin:0 8px;--evo-circular-loader-color: #91B1B8}:host{display:inline-block;vertical-align:top}.evo-textarea{--evo-input-height: 40px;--evo-input-border-radius: 4px;--evo-input-font-size: 14px;--evo-input-line-height: 24px;display:flex;align-items:center;height:var(--evo-input-height);color:#212121;font-weight:normal;font-size:var(--evo-input-font-size);font-family:var(--evo-font);line-height:var(--evo-input-line-height);white-space:nowrap;background-color:#fff;border:1px solid #C6C6C6;border-radius:var(--evo-input-border-radius);outline:none;transition:color .3s,box-shadow .3s,background .3s,border .3s;width:100%;height:auto;padding:8px 12px;white-space:normal;transition:box-shadow .3s,border .3s;resize:vertical}.evo-textarea:hover{border:1px solid #9B9B9B}.evo-textarea_focused{border:solid 1px #74706F}.evo-textarea_disabled{color:#b0b0b0!important;background-color:#f9fafb!important;border:1px solid #E3E3E3!important;cursor:default;pointer-events:none}.evo-textarea_invalid{border-color:#ff1817!important}.evo-textarea_size_small{padding:4px 12px}.evo-textarea::placeholder{color:#9b9b9b}.evo-textarea[disabled]{white-space:normal;background:#F9FAFB}\n"], components: [{ type: i1.EvoControlErrorComponent, selector: "evo-control-error", inputs: ["errors", "errorsMessages", "showCount"] }], directives: [{ type: i2.EvoUiClassDirective, selector: "[evoUiClass]", inputs: ["class", "evoUiClass"] }, { type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: EvoTextareaComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'evo-textarea',
                    templateUrl: './evo-textarea.component.html',
                    styleUrls: ['./evo-textarea.component.scss'],
                    providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(() => EvoTextareaComponent),
                            multi: true,
                        },
                    ],
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }], ctorParameters: function () { return [{ type: i0.Injector }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { size: [{
                type: Input
            }], placeholder: [{
                type: Input
            }], rows: [{
                type: Input
            }], blur: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 