/**
 * This file is part of the MedSafe application which is commercial software created by MedVision360 B.V.
 * The source code is proprietary and confidential.
 *
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 *
 * Copyright (c) by MedVision360 B.V. All rights reserved.
 *
 * For the application name: io.medrecord.medsafe
 */
import { __decorate, __param } from "tslib";
import { Component, Input, Optional, Self, ViewChild } from '@angular/core';
import { NgControl } from '@angular/forms';
import { showError } from '../../../../../core/utils/form-controls.util';
import { IconType } from '../../../../models';
var TextareaComponent = /** @class */ (function () {
    function TextareaComponent(ngControl) {
        this.ngControl = ngControl;
        this.rightIconPadding = 45;
        this.defaultRightPadding = 17;
        this.placeholder = '';
        this.hint = '';
        this.defaultOptions = {};
        this.preparedOptions = this.defaultOptions;
        this.disabled = false;
        this.onChange = function () { };
        this.onTouched = function () { };
        ngControl.valueAccessor = this;
    }
    Object.defineProperty(TextareaComponent.prototype, "options", {
        set: function (options) {
            this.preparedOptions = Object.assign({}, this.defaultOptions, options);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextareaComponent.prototype, "inputId", {
        get: function () {
            return this.ngControl.name;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextareaComponent.prototype, "preparedIconRight", {
        get: function () {
            return this.preparedOptions.iconRight;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextareaComponent.prototype, "showError", {
        get: function () {
            return showError(this.ngControl.errors, this.ngControl.touched);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextareaComponent.prototype, "warningIcon", {
        get: function () {
            return IconType.warning;
        },
        enumerable: true,
        configurable: true
    });
    // ControlValueAccessor implementations
    TextareaComponent.prototype.writeValue = function (value) {
        this.textareaElementRef.nativeElement.value = value;
    };
    TextareaComponent.prototype.registerOnChange = function (fn) {
        this.onChange = fn;
    };
    TextareaComponent.prototype.registerOnTouched = function (fn) {
        this.onTouched = fn;
    };
    TextareaComponent.prototype.setDisabledState = function (disabled) {
        this.disabled = disabled;
    };
    TextareaComponent.ctorParameters = function () { return [
        { type: NgControl, decorators: [{ type: Self }, { type: Optional }] }
    ]; };
    __decorate([
        ViewChild('textarea', { static: true })
    ], TextareaComponent.prototype, "textareaElementRef", void 0);
    __decorate([
        Input()
    ], TextareaComponent.prototype, "label", void 0);
    __decorate([
        Input()
    ], TextareaComponent.prototype, "minHeight", void 0);
    __decorate([
        Input()
    ], TextareaComponent.prototype, "placeholder", void 0);
    __decorate([
        Input()
    ], TextareaComponent.prototype, "labelDescription", void 0);
    __decorate([
        Input()
    ], TextareaComponent.prototype, "description", void 0);
    __decorate([
        Input()
    ], TextareaComponent.prototype, "hint", void 0);
    __decorate([
        Input()
    ], TextareaComponent.prototype, "options", null);
    TextareaComponent = __decorate([
        Component({
            selector: 'app-textarea',
            template: "<app-label\n  [label]=\"label\"\n  [labelDescription]=\"labelDescription\"\n  [hint]=\"hint\"\n  [fieldId]=\"inputId\"\n></app-label>\n\n<div class=\"input-wrapper\">\n  <textarea\n    #textarea\n    [style.padding-right.px]=\"showError || preparedOptions.iconRight ? rightIconPadding : defaultRightPadding\"\n    [style.min-height.px]=\"minHeight\"\n    [ngClass]=\"{\n      'textarea_warning': showError\n    }\"\n    class=\"textarea\"\n    (input)=\"onChange($event.target.value)\"\n    (blur)=\"onTouched()\"\n    [placeholder]=\"placeholder\"\n    [disabled]=\"disabled\"\n    [id]=\"inputId\">\n\n  </textarea>\n\n  <span class=\"icon-right\">\n    <span>\n      <app-icon\n        *ngIf=\"preparedIconRight\"\n        [icon]=\"preparedIconRight\"></app-icon>\n    </span>\n  </span>\n\n  <span [ngClass]=\"{'icon-warning_optional-offset': preparedIconRight}\" class=\"icon-warning\" *ngIf=\"showError\">\n    <app-icon [icon]=\"warningIcon\"></app-icon>\n  </span>\n</div>\n\n<div *ngIf=\"description\" class=\"description\">\n  {{ description }}\n</div>\n\n<app-input-errors [errors]=\"ngControl.errors\" [touched]=\"ngControl.touched\"></app-input-errors>\n",
            styles: ["/*!\n * This file is part of the MedSafe application which is commercial software created by MedVision360 B.V.\n *  The source code is proprietary and confidential.\n *\n *  Unauthorized copying of this file, via any medium is strictly prohibited.\n *\n *  Copyright (c) by MedVision360 B.V. All rights reserved.\n *\n *  For the application name: io.medrecord.medsafe\n */:host{margin-bottom:24px;display:block}:host label{font-size:14px;display:inline-block;line-height:1;margin-bottom:10px;font-weight:500}:host label span{font-weight:400}.textarea{background-color:var(--athens-darken-color);border-radius:5px;border:2px solid transparent;outline:0;padding:11px 17px;max-width:100%;min-width:100%;min-height:118px}.textarea::-moz-placeholder{color:var(--secondary-color)}.textarea:-ms-input-placeholder{color:var(--secondary-color)}.textarea:-moz-placeholder{color:var(--secondary-color)}.textarea:hover{border-color:var(--athens-darken-hover-color);background-color:var(--athens-darken-hover-color)}.textarea:focus{border-color:var(--geyser-color);background-color:var(--white-color)}.textarea_warning{border-color:var(--warning-color)!important;background-color:var(--athens-darken-color)}.textarea_warning:focus{border-color:var(--geyser-color)!important;background-color:var(--white-color)}.textarea_warning:hover{border-color:var(--warning-hover-color)!important;background-color:var(--athens-darken-hover-color)}.textarea::-webkit-input-placeholder{color:var(--secondary-color);color:var(--hit-gray-color)}.textarea::-moz-placeholder{color:var(--hit-gray-color)}.textarea:-ms-input-placeholder{color:var(--hit-gray-color)}.textarea:-moz-placeholder{color:var(--hit-gray-color)}.label-wrapper{display:flex}.label-wrapper label{font-size:14px;font-weight:600;display:inline-block;line-height:1;margin-bottom:10px;margin-right:5px}.label-wrapper app-hint{margin-left:5px;margin-right:10px}.label-wrapper .label-desc{font-weight:400}.input-wrapper{position:relative;width:100%}.icon-right{position:absolute;top:50%;transform:translate(0,-50%);right:20px}.description{margin-top:10px;margin-bottom:10px}.icon-warning{position:absolute;top:50%;transform:translate(0,-50%);right:20px}.icon-warning_optional-offset{right:50px}.icon-warning_disabled{pointer-events:none}.label-hint{display:inline-block;margin-left:4px;vertical-align:middle}"]
        }),
        __param(0, Self()), __param(0, Optional())
    ], TextareaComponent);
    return TextareaComponent;
}());
export { TextareaComponent };
//# sourceMappingURL=data:application/json;base64, 