import React from 'react';
import { Form } from 'react-bootstrap';
import { ValidatorComponent } from 'react-form-validator-core';
import translateLabel from "../../translation";

class TextArea extends ValidatorComponent {
  // constructor(props) {
  //   super(props);
  // }
  render() {
    const {
      id,
      name,
      label,
      value,
      rows,
      type,
      asterisk,
      readonly,
      placeholder,
      onChange
    } = this.props;
    return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Form.Group, null, /*#__PURE__*/React.createElement(Form.Label, null, label, asterisk ? /*#__PURE__*/React.createElement("span", {
      className: "asterisk"
    }, "*") : ""), /*#__PURE__*/React.createElement(Form.Control, {
      className: "textareabox",
      id: id,
      name: name,
      value: value !== null ? value : "",
      as: type,
      rows: rows,
      placeholder: placeholder,
      readOnly: readonly === "true" ? true : false,
      onChange: onChange,
      ref: r => {
        this.input = r;
      }
    }), this.errorText()));
  }

  errorText() {
    const {
      isValid
    } = this.state;

    if (isValid) {
      return null;
    }

    return /*#__PURE__*/React.createElement("div", {
      className: "errorStr"
    }, translateLabel(this.getErrorMessage()));
  }

}

export default TextArea;