import CheckBoxOutlineBlankIcon from "@mui/icons-material/CheckBoxOutlineBlank"; import CheckBoxIcon from "@mui/icons-material/CheckBox"; import Autocomplete from "@mui/material/Autocomplete"; import TextField from "@mui/material/TextField"; import Checkbox from "@mui/material/Checkbox"; import { useSnackbar } from "notistack"; import { useLang } from "services/lang"; export interface Props { label: string; selected: Array; options: readonly T[]; onChange: (i: Array) => void; max?: number; id?: string; className?: string; } export default function InputMultiSelect({ selected = [], options, onChange, label, max = 3, }: Props) { // alias const langStore = useLang(); const snackbr = useSnackbar(); return ( options[i])} onChange={(_, newValues: T[] = []) => { if (newValues.length > max) { snackbr.enqueueSnackbar( langStore.get("VALIDATION_MAX_TAG_SELECTION", { count: "3" }), { variant: "warning", autoHideDuration: 1500, } ); } onChange( newValues .map((v) => options.indexOf(v)) .filter((v) => v > -1) .slice(0, max) ); }} renderOption={(props, option, { selected }) => (
  • } checkedIcon={} style={{ marginRight: 8 }} checked={selected} /> {option}
  • )} renderInput={(params) => ( )} /> ); // style // const { classes } = useInputMultiSelectStyles({ // open, // selected, // maxedOut, // }); // return
    //
    // // {selected.length} // //
    // {options.map((v, i) => { // const selectedCount = selected.indexOf(i); // const isSelected = selectedCount > -1; // return
    { // if (!isSelected) { // if (!maxedOut) { // onChange([...selected, i]) // } // } else { // onChange( // selected.slice(0, selectedCount).concat(selected.slice(selectedCount + 1)) // ) // } // }} // > // {v} // {selectedCount} //
    // })} //
    //
    //
    }