"use strict";

exports.__esModule = true;
exports.default = void 0;
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _inputSearch = _interopRequireDefault(require("../../atom/input-search"));
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 }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const SearchForm = (props, context) => {
  const {
    action,
    method,
    onSubmit,
    onReset,
    search,
    onSearchFocus,
    onSearchBlur,
    'search-reset-aria-label': searchResetAriaLabel,
    dataTestId
  } = props;
  const handleSubmit = (0, _react.useMemo)(() => evt => {
    evt.preventDefault();
    return onSubmit && onSubmit(evt);
  }, [onSubmit]);
  const {
    skin
  } = context;
  const dark = (0, _get2.default)('common.dark', skin);
  return /*#__PURE__*/_react.default.createElement("form", {
    className: _style.default.form,
    action: action,
    method: method,
    onSubmit: handleSubmit,
    "data-name": "searchForm",
    "aria-label": search.placeholder
  }, /*#__PURE__*/_react.default.createElement(_inputSearch.default, _extends({}, search, {
    onFocus: onSearchFocus,
    onBlur: onSearchBlur,
    dataTestId: dataTestId
  })), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "search-form-reset",
    "aria-label": searchResetAriaLabel,
    onClick: onReset,
    className: search.value ? _style.default.wrapperClear : _style.default.wrapperNoClear
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionNavigationMore, {
    style: {
      color: dark
    },
    className: _style.default.clear
  })));
};
SearchForm.propTypes = process.env.NODE_ENV !== "production" ? {
  action: _propTypes.default.string,
  method: _propTypes.default.string,
  onSubmit: _propTypes.default.func,
  onReset: _propTypes.default.func,
  onSearchFocus: _propTypes.default.func,
  onSearchBlur: _propTypes.default.func,
  search: _propTypes.default.shape(_inputSearch.default.propTypes),
  'search-reset-aria-label': _propTypes.default.string,
  dataTestId: _propTypes.default.string
} : {};
var _default = exports.default = SearchForm;
//# sourceMappingURL=index.js.map