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

class TextBox extends ValidatorComponent {
  // constructor(props) {
  //   super(props);
  // }
  render() {
    const {
      id,
      name,
      label,
      value,
      type,
      asterisk,
      readonly,
      inputGroup,
      placeholder,
      onChange,
      lang,
      langCheckValue
    } = this.props;
    return /*#__PURE__*/React.createElement("div", {
      className: lang === langCheckValue ? "rtl-textBox" : ""
    }, /*#__PURE__*/React.createElement(Form.Group, null, /*#__PURE__*/React.createElement(Form.Label, null, label, asterisk ? /*#__PURE__*/React.createElement("span", {
      className: "asterisk"
    }, "*") : ""), inputGroup !== "" ? /*#__PURE__*/React.createElement(InputGroup, null, /*#__PURE__*/React.createElement(InputGroup.Prepend, null, /*#__PURE__*/React.createElement(InputGroup.Text, null, inputGroup)), /*#__PURE__*/React.createElement(Form.Control, {
      id: id,
      name: name,
      value: value !== null ? value : "",
      type: type,
      placeholder: placeholder,
      readOnly: readonly === "true" ? true : false,
      onChange: onChange,
      ref: r => {
        this.input = r;
      }
    })) : /*#__PURE__*/React.createElement(Form.Control, {
      id: id,
      name: name,
      value: value !== null ? value : "",
      type: type,
      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 TextBox; // {/*const TextBox = ({id, name, label, value, type, asterisk, readonly, placeholder, required, onChange }) => (
//    <div>
//          <Form.Group>
//                  <Form.Label>{label}{asterisk ? <span className='asterisk'>*</span>: ""}</Form.Label>
//                  <Form.Control 
//                         id={id}
//                         name={name} 
//                         value={value!==null ? value : ""}
//                         type={type}
//                         placeholder={translateLabel(placeholder)}
//                         readOnly={readonly === "true" ? true : false }
//                         onChange={onChange}
//                  />
//                  {/* <Form.Text className="text-muted">
//                    We'll never share your email with anyone else.
//                  </Form.Text> 
//          </Form.Group>
//     </div>
//  );
// export default TextBox; */}