import _isEmpty from "lodash/fp/isEmpty";
import _keys from "lodash/fp/keys";
import _noop from "lodash/fp/noop";
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { NovaSolidStatusCheckCircle2 as CheckIcon, NovaSolidStatusClose as ErrorIcon, NovaCompositionCoorpacademyInformationIcon as InfoIcon } from '@coorpacademy/nova-icons';
import getClassState from '../../util/get-class-state';
import style from './style.css';
const themeStyle = {
  setup: style.setup,
  coorpmanager: style.coorpmanager,
  cockpit: style.cockpit,
  default: style.defaultStyle
};
const InputTextarea = props => {
  const {
    title: propsTitle,
    name,
    placeholder,
    value,
    hint,
    theme = 'default',
    onChange = _noop,
    error,
    valid,
    description,
    disabled,
    modified = false
  } = props;
  const mainClass = themeStyle[theme];
  const className = getClassState(style.defaultStyle, style.modified, style.error, modified, error);
  const handleChange = useMemo(() => e => onChange(e.target.value), [onChange]);
  const descriptionView = description && theme !== 'coorpmanager' ? /*#__PURE__*/React.createElement("div", {
    className: style.description
  }, description) : null;
  const toolTipView = description && theme === 'coorpmanager' ? /*#__PURE__*/React.createElement("div", {
    className: style.infoIconWrapper
  }, /*#__PURE__*/React.createElement(InfoIcon, {
    className: style.infoIcon
  }), /*#__PURE__*/React.createElement("div", {
    className: style.descriptionLabel
  }, description)) : null;
  const hintView = theme === 'coorpmanager' ? /*#__PURE__*/React.createElement("div", {
    className: style.hint
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: error || hint
    }
  }) : null;
  const errorIconView = error ? /*#__PURE__*/React.createElement(ErrorIcon, {
    className: style.leftIcon
  }) : null;
  const validIconView = valid ? /*#__PURE__*/React.createElement(CheckIcon, {
    className: style.leftIcon
  }) : null;
  return /*#__PURE__*/React.createElement("div", {
    className: classnames(mainClass, className, disabled && style.disabled)
  }, /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("span", {
    className: classnames(style.title, _isEmpty(value) && style.noValue)
  }, propsTitle, toolTipView), /*#__PURE__*/React.createElement("textarea", {
    name: name,
    value: value,
    placeholder: placeholder,
    onChange: handleChange,
    disabled: disabled,
    "data-testid": name
  }), errorIconView, validIconView, hintView), descriptionView);
};
InputTextarea.propTypes = process.env.NODE_ENV !== "production" ? {
  placeholder: PropTypes.string,
  title: PropTypes.string,
  name: PropTypes.string,
  theme: PropTypes.oneOf(_keys(themeStyle)),
  disabled: PropTypes.bool,
  value: PropTypes.string,
  hint: PropTypes.string,
  error: PropTypes.string,
  onChange: PropTypes.func,
  description: PropTypes.string,
  modified: PropTypes.bool,
  valid: PropTypes.bool
} : {};
export default InputTextarea;
//# sourceMappingURL=index.js.map