"use strict";

exports.__esModule = true;
exports.default = void 0;
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _noop2 = _interopRequireDefault(require("lodash/fp/noop"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _provider = _interopRequireDefault(require("../provider"));
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 Search = props => {
  const {
    value,
    placeholder,
    onChange = _noop2.default,
    onClear = _noop2.default,
    onFocus,
    onBlur,
    theme = 'default',
    dataTestId
  } = props;
  const handleChange = (0, _react.useMemo)(() => e => onChange(e.target.value), [onChange]);
  const cmStyle = (0, _classnames.default)(_style.default.coorpmanager);
  const isDefaultTheme = theme === 'default';
  return /*#__PURE__*/_react.default.createElement("div", {
    className: isDefaultTheme ? _style.default.wrapperSearch : cmStyle
  }, /*#__PURE__*/_react.default.createElement("label", {
    htmlFor: "search",
    title: placeholder
  }, !isDefaultTheme ? /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademySearchThin, {
    className: _style.default.searchIcon
  }) : /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademySearch, {
    className: _style.default.searchIcon
  }), !isDefaultTheme ? /*#__PURE__*/_react.default.createElement("span", {
    className: (0, _classnames.default)(_style.default.title, (0, _isEmpty2.default)(value) && _style.default.noValue)
  }, placeholder) : null), /*#__PURE__*/_react.default.createElement("input", {
    "data-name": "search-input",
    "data-testid": dataTestId,
    className: _style.default.search,
    "aria-label": placeholder,
    type: "text",
    name: "search",
    id: "search",
    placeholder: placeholder,
    title: placeholder,
    value: value,
    onInput: handleChange,
    onFocus: onFocus,
    onChange: _noop2.default,
    onBlur: onBlur
  }), value && !isDefaultTheme ? /*#__PURE__*/_react.default.createElement(_novaIcons.NovaSolidStatusClose, {
    onClick: onClear,
    className: _style.default.clearIcon
  }) : null);
};
Search.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
Search.propTypes = process.env.NODE_ENV !== "production" ? {
  value: _propTypes.default.string,
  placeholder: _propTypes.default.string.isRequired,
  onChange: _propTypes.default.func,
  onClear: _propTypes.default.func,
  onFocus: _propTypes.default.func,
  onBlur: _propTypes.default.func,
  theme: _propTypes.default.oneOf(['default', 'coorpmanager']),
  dataTestId: _propTypes.default.string
} : {};
var _default = exports.default = Search;
//# sourceMappingURL=index.js.map