"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var React = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _injectE2E = _interopRequireDefault(require("../../Tools/injectE2E"));

var _interpolation = require("../../Tools/interpolation");

var _Input = require("./Input");

var Container =
/*#__PURE__*/
_styledComponents.default.div.withConfig({
  componentId: "sc-18ar0sn-0"
})(["\n  display: flex;\n  flex-direction: column;\n  width: ", ";\n"], (0, _interpolation.prop)('width'));

var Wrapper =
/*#__PURE__*/
_styledComponents.default.textarea.attrs(_injectE2E.default).withConfig({
  componentId: "sc-18ar0sn-1"
})(["\n  display: block;\n  width: ", ";\n  height: ", ";\n  padding: 0.7rem 1rem;\n  box-sizing: border-box;\n  font-family: ", ";\n  font-size: ", ";\n  color: ", ";\n  border-width: 1px;\n  border-color: ", ";\n  border-style: solid;\n  border-radius: ", ";\n  background-color: ", ";\n  outline-width: 0;\n  user-select: text;\n  resize: none;\n  transition: box-shadow 0.25s ease-out;\n\n  &:disabled {\n    color: ", ";\n    border-color: ", ";\n    background: ", ";\n    cursor: not-allowed;\n  }\n\n  &:active:not(:disabled),\n  &:focus:not(:disabled) {\n    box-shadow: 0 0 0 1px\n      ", ";\n  }\n\n  &::placeholder {\n    color: ", ";\n    font-size: ", ";\n  }\n"], (0, _interpolation.prop)('width'), (0, _interpolation.prop)('height'), (0, _interpolation.theme)('fontPrimary'), (0, _interpolation.fontSize)('md'), (0, _interpolation.theme)('inputColor'), function (props) {
  return props.error != null ? (0, _interpolation.theme)('dangerColor')(props) : (0, _interpolation.theme)('inputBorderColor')(props);
}, (0, _interpolation.theme)('inputBorderRadius'), (0, _interpolation.theme)('inputBackgroundColor'), (0, _interpolation.theme)('inputColor'), (0, _interpolation.theme)('inputBorderColor'), (0, _interpolation.theme)('inputBackgroundColorDisabled'), function (props) {
  return props.error != null ? 'transparent' : (0, _interpolation.theme)('inputActiveColor');
}, (0, _interpolation.theme)('inputPlaceholderColor'), (0, _interpolation.fontSize)('sm'));

var TextArea = function TextArea(_ref) {
  var input = _ref.input,
      rest = (0, _objectWithoutProperties2.default)(_ref, ["input"]);
  var hasLabel = rest.label != null;
  var hasError = rest.error != null;

  if (hasLabel || hasError) {
    return React.createElement(Container, {
      width: rest.width
    }, React.createElement(_Input.InputLabel, {
      disabled: rest.disabled,
      error: hasError,
      name: rest.name
    }, "".concat(rest.label || '').concat(hasLabel && hasError ? ' - ' : '').concat(rest.error || '')), React.createElement(Wrapper, (0, _extends2.default)({}, input, rest)));
  }

  return React.createElement(Wrapper, (0, _extends2.default)({}, input, rest));
};

TextArea.propTypes = process.env.NODE_ENV !== "production" ? {
  disabled: _propTypes.default.bool,
  e2e: _propTypes.default.string,
  height: _propTypes.default.string,
  input: _propTypes.default.object,
  name: _propTypes.default.string,
  value: _propTypes.default.string,
  width: _propTypes.default.string
} : {};
TextArea.defaultProps = {
  disabled: false,
  e2e: 'defaultTextArea',
  height: '100px',
  width: '100%'
};
var _default = TextArea;
exports.default = _default;