import _get from "lodash/fp/get";
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); }
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { NovaCompositionNavigationMore as ClearIcon } from '@coorpacademy/nova-icons';
import Search from '../../atom/input-search';
import style from './style.css';
const SearchForm = (props, context) => {
  const {
    action,
    method,
    onSubmit,
    onReset,
    search,
    onSearchFocus,
    onSearchBlur,
    'search-reset-aria-label': searchResetAriaLabel,
    dataTestId
  } = props;
  const handleSubmit = useMemo(() => evt => {
    evt.preventDefault();
    return onSubmit && onSubmit(evt);
  }, [onSubmit]);
  const {
    skin
  } = context;
  const dark = _get('common.dark', skin);
  return /*#__PURE__*/React.createElement("form", {
    className: style.form,
    action: action,
    method: method,
    onSubmit: handleSubmit,
    "data-name": "searchForm",
    "aria-label": search.placeholder
  }, /*#__PURE__*/React.createElement(Search, _extends({}, search, {
    onFocus: onSearchFocus,
    onBlur: onSearchBlur,
    dataTestId: dataTestId
  })), /*#__PURE__*/React.createElement("div", {
    "data-name": "search-form-reset",
    "aria-label": searchResetAriaLabel,
    onClick: onReset,
    className: search.value ? style.wrapperClear : style.wrapperNoClear
  }, /*#__PURE__*/React.createElement(ClearIcon, {
    style: {
      color: dark
    },
    className: style.clear
  })));
};
SearchForm.propTypes = process.env.NODE_ENV !== "production" ? {
  action: PropTypes.string,
  method: PropTypes.string,
  onSubmit: PropTypes.func,
  onReset: PropTypes.func,
  onSearchFocus: PropTypes.func,
  onSearchBlur: PropTypes.func,
  search: PropTypes.shape(Search.propTypes),
  'search-reset-aria-label': PropTypes.string,
  dataTestId: PropTypes.string
} : {};
export default SearchForm;
//# sourceMappingURL=index.js.map