ConceptPortal-public/rsconcept/frontend/src/features/rsform/components/select-multi-grammeme.tsx
2025-04-13 22:29:23 +03:00

32 lines
967 B
TypeScript

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';
interface SelectMultiGrammemeProps extends Styling {
id?: string;
value: Grammeme[];
onChange: (newValue: Grammeme[]) => void;
placeholder?: string;
}
export function SelectMultiGrammeme({ value, onChange, ...restProps }: SelectMultiGrammemeProps) {
const compatible = getCompatibleGrams(value);
const items: Grammeme[] = [...supportedGrammemes.filter(gram => compatible.includes(gram))];
return (
<ComboMulti
noSearch
items={items}
value={value}
onChange={onChange}
idFunc={gram => gram}
labelOptionFunc={gram => labelGrammeme(gram)}
labelValueFunc={gram => labelGrammeme(gram)}
{...restProps}
/>
);
}