/**
 * @fileoverview added by tsickle
 * Generated from: components/textarea/textarea.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/*
    MIT License

    Copyright (c) 2019 Temainfo Software

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
*/
import { ChangeDetectorRef, Component, ContentChild, EventEmitter, forwardRef, Input, Output, ViewChild } from '@angular/core';
import { FormControlName, NG_VALUE_ACCESSOR, NgModel } from '@angular/forms';
import { CdkOverlayOrigin } from '@angular/cdk/overlay';
import { ValueAccessorBase } from '../input/core/value-accessor';
export class TlTextarea extends ValueAccessorBase {
    /**
     * @param {?} change
     */
    constructor(change) {
        super();
        this.change = change;
        this.label = '';
        this.labelPlacement = 'left';
        this.labelSize = '100px';
        this.name = '';
        this.placeholder = '';
        this.height = '80px';
        this.tabindex = 0;
        this.maxlength = -1;
        this.textAlign = 'left';
        this.readonly = null;
        this.disabled = null;
        this.clearButton = false;
        this.color = 'basic';
        this.withBorder = true;
        this.resize = false;
        this.showCount = false;
        this.click = new EventEmitter();
        this.focus = new EventEmitter();
        this.blur = new EventEmitter();
        this.clear = new EventEmitter();
        this.overlayOrigin = new EventEmitter();
        this.required = false;
        this.isShowingMessages = false;
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.overlayOrigin.emit(this.cdkOverlayOrigin);
    }
    /**
     * @return {?}
     */
    ngAfterViewInit() {
        this.setRequired();
        this.handleValidator();
    }
    /**
     * @return {?}
     */
    setRequired() {
        /** @type {?} */
        const currentControl = this.controlName ? this.controlName : this.model;
        if (currentControl && currentControl.control.errors) {
            if (currentControl.control.errors['required']) {
                this.required = true;
                this.change.detectChanges();
            }
        }
    }
    /**
     * @return {?}
     */
    handleValidator() {
        /** @type {?} */
        const currentControl = this.controlName ? this.controlName : this.model;
        if (currentControl) {
            this.hasValidator = currentControl.control.validator;
            this.change.detectChanges();
        }
    }
    /**
     * @return {?}
     */
    setFocus() {
        this.textarea.nativeElement.focus();
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    stopEvent($event) {
        $event.preventDefault();
        $event.stopPropagation();
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    onTextareaClick($event) {
        this.stopEvent($event);
        this.isShowingMessages = true;
        this.click.emit($event);
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    onTextareaFocus($event) {
        this.isShowingMessages = true;
        this.focus.emit($event);
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    onTextareaBlur($event) {
        this.isShowingMessages = false;
        this.blur.emit($event);
    }
    /**
     * @param {?=} $event
     * @return {?}
     */
    clearTextarea($event) {
        this.value = '';
        this.setFocus();
        this.clear.emit($event);
    }
}
TlTextarea.decorators = [
    { type: Component, args: [{
                selector: 'tl-textarea',
                template: "<div [class]=\"'tl-textarea ' + color\">\n\n  <tl-label *ngIf=\"label\"\n            [style.vertical-align]=\"'top'\"\n            [labelTitle]=\"label\"\n            [required]=\"required\"\n            [labelPlacement]=\"labelPlacement\"\n            [labelSize]=\"labelSize\"></tl-label>\n\n  <div class=\"ui-wrapper-textarea\" [style.height]=\"height\">\n    <textarea #textarea\n              class=\"field\"\n              [ngClass]=\"{\n                 'invalid': controlName?.control?.errors || model?.control?.errors,\n                 'withValidators': hasValidator,\n                 'withoutValidators': !hasValidator,\n                 'withBorder': withBorder,\n                 'withoutBorder': !withBorder\n               }\"\n              [style.resize]=\"resize ? 'auto' : 'none'\"\n              [style.height]=\"height\"\n              [style.text-align]=\"textAlign\"\n              [tabindex]=\"tabindex\"\n              [disabled]=\"disabled || isDisabled\"\n              [attr.name]=\"name\"\n              [placeholder]=\"placeholder\"\n              [attr.readonly]=\"readonly ? true : null\"\n              [attr.maxlength]=\"maxlength\"\n              [(ngModel)]=\"value\"\n              (click)=\"onTextareaClick($event)\"\n              (blur)=\"onTextareaBlur($event)\"\n              (focus)=\"onTextareaFocus($event)\"></textarea>\n    <tl-icon *ngIf=\"clearButton && value\"\n             [style.lineHeight]=\"height\"\n             (click)=\"clearTextarea($event)\"\n             [lib]=\"'ion'\"\n             [style]=\"'ios'\"\n             class=\"clearButton\">close</tl-icon>\n    <div class=\"count-characters\" *ngIf=\"showCount\">\n      {{ ( maxlength > 0 ) ? textarea.value.length + '/' + maxlength : textarea.value.length | number }}\n    </div>\n  </div>\n</div>\n",
                providers: [{
                        provide: NG_VALUE_ACCESSOR,
                        useExisting: forwardRef((/**
                         * @return {?}
                         */
                        () => TlTextarea)),
                        multi: true
                    }],
                styles: ["*{box-sizing:border-box}.tl-textarea{border-collapse:separate;display:table;height:100%;width:100%}.tl-textarea,.tl-textarea>.ui-wrapper-textarea{position:relative}.tl-textarea>.ui-wrapper-textarea>textarea::-webkit-scrollbar{width:8px}.tl-textarea>.ui-wrapper-textarea>.field{border-radius:3px;display:table-cell;font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:1em;font-weight:400;height:23px;padding:4px 20px 4px 6px;transition:background-color .23s ease-in-out;width:100%}.tl-textarea>.ui-wrapper-textarea>.count-characters{border-bottom-left-radius:3px;font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:.7em;margin:-22px 2px 0 0;padding:0 10px;position:absolute;right:0}.tl-textarea>.ui-wrapper-textarea>.field::-moz-placeholder{font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:1em}.tl-textarea>.ui-wrapper-textarea>.field:-ms-input-placeholder{font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:1em}.tl-textarea>.ui-wrapper-textarea>.field::-ms-input-placeholder{font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:1em}.tl-textarea>.ui-wrapper-textarea>.field::placeholder{font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:1em}.tl-textarea>.ui-wrapper-textarea>.field.-cursorblocked{cursor:not-allowed}.tl-textarea>.ui-wrapper-textarea>.field.-disabled{cursor:default!important}.tl-textarea>.ui-wrapper-textarea>.clearButton{font-size:16px;line-height:40px;padding-right:15px;position:absolute;right:0;top:0}.tl-textarea>.ui-wrapper-textarea>.clearButton:hover{cursor:pointer}"]
            }] }
];
/** @nocollapse */
TlTextarea.ctorParameters = () => [
    { type: ChangeDetectorRef }
];
TlTextarea.propDecorators = {
    label: [{ type: Input }],
    labelPlacement: [{ type: Input }],
    labelSize: [{ type: Input }],
    name: [{ type: Input }],
    placeholder: [{ type: Input }],
    height: [{ type: Input }],
    tabindex: [{ type: Input }],
    maxlength: [{ type: Input }],
    textAlign: [{ type: Input }],
    readonly: [{ type: Input }],
    disabled: [{ type: Input }],
    clearButton: [{ type: Input }],
    color: [{ type: Input }],
    withBorder: [{ type: Input }],
    resize: [{ type: Input }],
    showCount: [{ type: Input }],
    textarea: [{ type: ViewChild, args: ['textarea', { static: true },] }],
    cdkOverlayOrigin: [{ type: ViewChild, args: [CdkOverlayOrigin, { static: true },] }],
    model: [{ type: ContentChild, args: [NgModel, { static: true },] }],
    controlName: [{ type: ContentChild, args: [FormControlName, { static: true },] }],
    click: [{ type: Output }],
    focus: [{ type: Output }],
    blur: [{ type: Output }],
    clear: [{ type: Output }],
    overlayOrigin: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    TlTextarea.prototype.label;
    /** @type {?} */
    TlTextarea.prototype.labelPlacement;
    /** @type {?} */
    TlTextarea.prototype.labelSize;
    /** @type {?} */
    TlTextarea.prototype.name;
    /** @type {?} */
    TlTextarea.prototype.placeholder;
    /** @type {?} */
    TlTextarea.prototype.height;
    /** @type {?} */
    TlTextarea.prototype.tabindex;
    /** @type {?} */
    TlTextarea.prototype.maxlength;
    /** @type {?} */
    TlTextarea.prototype.textAlign;
    /** @type {?} */
    TlTextarea.prototype.readonly;
    /** @type {?} */
    TlTextarea.prototype.disabled;
    /** @type {?} */
    TlTextarea.prototype.clearButton;
    /** @type {?} */
    TlTextarea.prototype.color;
    /** @type {?} */
    TlTextarea.prototype.withBorder;
    /** @type {?} */
    TlTextarea.prototype.resize;
    /** @type {?} */
    TlTextarea.prototype.showCount;
    /** @type {?} */
    TlTextarea.prototype.textarea;
    /** @type {?} */
    TlTextarea.prototype.cdkOverlayOrigin;
    /** @type {?} */
    TlTextarea.prototype.model;
    /** @type {?} */
    TlTextarea.prototype.controlName;
    /** @type {?} */
    TlTextarea.prototype.click;
    /** @type {?} */
    TlTextarea.prototype.focus;
    /** @type {?} */
    TlTextarea.prototype.blur;
    /** @type {?} */
    TlTextarea.prototype.clear;
    /** @type {?} */
    TlTextarea.prototype.overlayOrigin;
    /** @type {?} */
    TlTextarea.prototype.required;
    /** @type {?} */
    TlTextarea.prototype.isShowingMessages;
    /** @type {?} */
    TlTextarea.prototype.hasValidator;
    /**
     * @type {?}
     * @private
     */
    TlTextarea.prototype.change;
}
//# sourceMappingURL=data:application/json;base64, 