"use strict";

exports.__esModule = true;
exports.default = void 0;
var _noop2 = _interopRequireDefault(require("lodash/fp/noop"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _getClassState = _interopRequireDefault(require("../../util/get-class-state"));
var _style = _interopRequireDefault(require("./style.css"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const InputColor = props => {
  const {
    title,
    name,
    placeholder,
    value,
    defaultValue,
    onChange = _noop2.default,
    error,
    description,
    modified = false
  } = props;
  const inlineStyle = {
    backgroundColor: value
  };
  const handleChange = (0, _react.useMemo)(() => e => onChange(e.target.value), [onChange]);
  const className = (0, _getClassState.default)(_style.default.defaultStyle, _style.default.modified, _style.default.error, modified, error);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: className
  }, /*#__PURE__*/_react.default.createElement("label", null, /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.title
  }, `${title} `), /*#__PURE__*/_react.default.createElement("input", {
    type: "text",
    name: name,
    className: _style.default.input,
    placeholder: placeholder,
    defaultValue: defaultValue,
    value: value,
    onInput: handleChange,
    onChange: _noop2.default
  }), /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.preview,
    style: inlineStyle
  })), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.description
  }, description));
};
InputColor.propTypes = process.env.NODE_ENV !== "production" ? {
  title: _propTypes.default.string.isRequired,
  name: _propTypes.default.string,
  placeholder: _propTypes.default.string.isRequired,
  defaultValue: _propTypes.default.string,
  value: _propTypes.default.string,
  error: _propTypes.default.string,
  onChange: _propTypes.default.func,
  description: _propTypes.default.string,
  modified: _propTypes.default.bool
} : {};
var _default = exports.default = InputColor;
//# sourceMappingURL=index.js.map