ConceptPortal-public/rsconcept/frontend/src/features/rsform/components/select-multi-grammeme.tsx

32 lines
967 B
TypeScript
Raw Normal View History

2025-04-13 22:29:23 +03:00
import { ComboMulti } from '@/components/input/combo-multi';
import { type Styling } from '@/components/props';
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
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) {
const compatible = getCompatibleGrams(value);
const items: Grammeme[] = [...supportedGrammemes.filter(gram => compatible.includes(gram))];
2023-12-08 19:24:08 +03:00
return (
<ComboMulti
noSearch
items={items}
2023-12-28 14:04:44 +03:00
value={value}
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
}