aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/src/components/inputs/ChipInput.tsx
blob: 1fa57084c750442a7cead38e65b2423719ae9ffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { FunctionComponent } from "react";
import { TagsInput } from "@mantine/core";

export interface ChipInputProps {
  defaultValue?: string[] | undefined;
  value?: readonly string[] | null;
  label?: string;
  onChange?: (value: string[]) => void;
}

const ChipInput: FunctionComponent<ChipInputProps> = ({
  defaultValue,
  value,
  label,
  onChange,
}: ChipInputProps) => {
  // TODO: Replace with our own custom implementation instead of just using the
  //       built-in TagsInput. https://mantine.dev/combobox/?e=MultiSelectCreatable
  return (
    <TagsInput
      defaultValue={defaultValue}
      label={label}
      value={value ? value?.map((v) => v) : []}
      onChange={onChange}
      clearable
    ></TagsInput>
  );
};

export default ChipInput;