function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import noop from 'lodash/noop.js';
import React, { lazy } from 'react';
import { cssClass, filterStyles, selectStyles } from '../../utils/index.js';
import useSelectTheme from './select-theme.js';
const ReactSelect = /*#__PURE__*/lazy(() => import('react-select'));
const SelectComponent = ReactSelect.default || ReactSelect;
export const Select = props => {
  const {
    value,
    onChange,
    variant,
    ...selectProps
  } = props;
  const {
    theme,
    selectTheme
  } = useSelectTheme();
  const styles = variant === 'filter' ? filterStyles(theme) : selectStyles(theme);
  const handleChange = selected => {
    if (typeof onChange === 'function') onChange(selected);
  };
  return /*#__PURE__*/React.createElement(SelectComponent, _extends({
    className: cssClass('Select'),
    value: value,
    theme: selectTheme,
    styles: styles,
    onChange: handleChange,
    isClearable: true
  }, selectProps));
};
Select.defaultProps = {
  variant: 'default',
  onChange: noop
};
export default Select;