import Autocomplete from "@mui/material/Autocomplete"; import type { AutocompleteProps } from "@mui/material/Autocomplete"; import { TextField, Checkbox } from "@/Components/inputs"; import ListItem from "@mui/material/ListItem"; import Stack from "@mui/material/Stack"; import { useTheme } from "@mui/material/styles"; import { FieldLabel } from "./FieldLabel"; import { ChevronDown } from "lucide-react"; type AutoCompleteInputProps = Omit< AutocompleteProps, "renderInput" > & { renderInput?: AutocompleteProps["renderInput"]; fieldLabel?: string; required?: boolean; }; export const AutoCompleteInput = ({ fieldLabel, required, renderInput, ...props }: AutoCompleteInputProps) => { const theme = useTheme(); const multiple = props.multiple; const defaultRenderInput = (params: any) => ( ); const autocomplete = ( } renderInput={renderInput || defaultRenderInput} getOptionKey={(option) => option.id} renderTags={() => null} renderOption={(props, option, { selected }) => { const { key, ...optionProps } = props; return ( {multiple && } {option.name} ); }} sx={{ "&.MuiAutocomplete-root .MuiAutocomplete-input": { padding: `0 ${theme.spacing(5)}`, }, "& .MuiInputBase-root .MuiAutocomplete-endAdornment": { right: theme.spacing(3), }, }} /> ); if (fieldLabel) { return ( {fieldLabel} {autocomplete} ); } return autocomplete; };