2025-04-13 22:29:23 +03:00
|
|
|
import { ComboMulti } from '@/components/input/combo-multi';
|
2025-02-21 21:15:05 +03:00
|
|
|
import { type Styling } from '@/components/props';
|
2025-02-10 01:32:55 +03:00
|
|
|
|
2025-04-13 17:18:09 +03:00
|
|
|
import { labelGrammeme } from '../labels';
|
|
|
|
import { type Grammeme, supportedGrammemes } from '../models/language';
|
|
|
|
import { getCompatibleGrams } from '../models/language-api';
|
2023-12-08 19:24:08 +03:00
|
|
|
|
2025-04-13 17:18:09 +03:00
|
|
|
interface SelectMultiGrammemeProps extends Styling {
|
|
|
|
id?: string;
|
|
|
|
value: Grammeme[];
|
|
|
|
onChange: (newValue: Grammeme[]) => void;
|
2023-12-28 14:04:44 +03:00
|
|
|
placeholder?: string;
|
2023-12-08 19:24:08 +03:00
|
|
|
}
|
|
|
|
|
2025-02-15 16:43:10 +03:00
|
|
|
export function SelectMultiGrammeme({ value, onChange, ...restProps }: SelectMultiGrammemeProps) {
|
2025-04-13 17:18:09 +03:00
|
|
|
const compatible = getCompatibleGrams(value);
|
|
|
|
const items: Grammeme[] = [...supportedGrammemes.filter(gram => compatible.includes(gram))];
|
2023-12-08 19:24:08 +03:00
|
|
|
|
|
|
|
return (
|
2025-04-13 17:18:09 +03:00
|
|
|
<ComboMulti
|
|
|
|
noSearch
|
|
|
|
items={items}
|
2023-12-28 14:04:44 +03:00
|
|
|
value={value}
|
2025-04-13 17:18:09 +03:00
|
|
|
onChange={onChange}
|
|
|
|
idFunc={gram => gram}
|
|
|
|
labelOptionFunc={gram => labelGrammeme(gram)}
|
|
|
|
labelValueFunc={gram => labelGrammeme(gram)}
|
2023-12-28 14:04:44 +03:00
|
|
|
{...restProps}
|
|
|
|
/>
|
|
|
|
);
|
2023-12-08 19:24:08 +03:00
|
|
|
}
|