import { useCommonReactSelectStyles } from "@contember/ui";
import { useStateManager } from "react-select";
import { SearchInput } from "./SearchInput.js";
const useCommonReactSelectProps = ({
  reactSelectProps,
  placeholder,
  data,
  isInvalid,
  menuZIndex,
  onSearch
}) => {
  const styles = useCommonReactSelectStyles({ isInvalid, menuZIndex });
  const reactSelectState = useStateManager({
    onInputChange: onSearch,
    onFocus: (e) => {
      onSearch?.(e.target.value);
    }
  });
  return {
    ...reactSelectProps,
    ...reactSelectState,
    placeholder,
    styles: {
      ...styles,
      ...reactSelectProps?.styles
    },
    options: data,
    getOptionValue: (datum) => datum.key,
    components: {
      Input: SearchInput
    },
    filterOption: () => true,
    menuPosition: "fixed"
  };
};
export {
  useCommonReactSelectProps
};
//# sourceMappingURL=useCommonReactSelectProps.js.map
