import _isEmpty from "lodash/fp/isEmpty";
import _noop from "lodash/fp/noop";
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { NovaCompositionCoorpacademySearchThin as CMSearchIcon, NovaCompositionCoorpacademySearch as SearchIcon, NovaSolidStatusClose as CloseIcon } from '@coorpacademy/nova-icons';
import Provider from '../provider';
import style from './style.css';
const Search = props => {
  const {
    value,
    placeholder,
    onChange = _noop,
    onClear = _noop,
    onFocus,
    onBlur,
    theme = 'default',
    dataTestId
  } = props;
  const handleChange = useMemo(() => e => onChange(e.target.value), [onChange]);
  const cmStyle = classnames(style.coorpmanager);
  const isDefaultTheme = theme === 'default';
  return /*#__PURE__*/React.createElement("div", {
    className: isDefaultTheme ? style.wrapperSearch : cmStyle
  }, /*#__PURE__*/React.createElement("label", {
    htmlFor: "search",
    title: placeholder
  }, !isDefaultTheme ? /*#__PURE__*/React.createElement(CMSearchIcon, {
    className: style.searchIcon
  }) : /*#__PURE__*/React.createElement(SearchIcon, {
    className: style.searchIcon
  }), !isDefaultTheme ? /*#__PURE__*/React.createElement("span", {
    className: classnames(style.title, _isEmpty(value) && style.noValue)
  }, placeholder) : null), /*#__PURE__*/React.createElement("input", {
    "data-name": "search-input",
    "data-testid": dataTestId,
    className: style.search,
    "aria-label": placeholder,
    type: "text",
    name: "search",
    id: "search",
    placeholder: placeholder,
    title: placeholder,
    value: value,
    onInput: handleChange,
    onFocus: onFocus,
    onChange: _noop,
    onBlur: onBlur
  }), value && !isDefaultTheme ? /*#__PURE__*/React.createElement(CloseIcon, {
    onClick: onClear,
    className: style.clearIcon
  }) : null);
};
Search.contextTypes = {
  skin: Provider.childContextTypes.skin
};
Search.propTypes = process.env.NODE_ENV !== "production" ? {
  value: PropTypes.string,
  placeholder: PropTypes.string.isRequired,
  onChange: PropTypes.func,
  onClear: PropTypes.func,
  onFocus: PropTypes.func,
  onBlur: PropTypes.func,
  theme: PropTypes.oneOf(['default', 'coorpmanager']),
  dataTestId: PropTypes.string
} : {};
export default Search;
//# sourceMappingURL=index.js.map