@mtg-rio/mui-mentions
Version:
@mention people in a MUI TextField
33 lines (32 loc) • 1.51 kB
TypeScript
import { TextFieldProps, TextFieldVariants } from '@mui/material';
import { ReactNode } from 'react';
import { BaseSuggestionData, MentionData, SuggestionDataSource } from './types';
interface MentionsTextFieldBaseProps<T extends BaseSuggestionData> {
/**
* The current value of the TextField, potentially containing mention
* markup.
*/
value?: string;
/** The default value. Use when the component is not controlled. */
defaultValue?: string;
/**
* Callback invoked as the value of the TextField changes.
* @param newValue The new markup value of the TextField.
* @param newPlainText The new plain text value of the TextField, with
* mention markup converted to display strings.
* @param mentions A list of mentions in the TextField.
*/
onChange?: (newValue: string, newPlainText: string, mentions: MentionData[]) => void;
/**
* A list of data sources used to populate the suggestions overlay.
*/
dataSources: SuggestionDataSource<T>[];
/**
* The color of the mention highlights.
* @default 'primary.light'
*/
highlightColor?: string;
}
export type MentionsTextFieldProps<T extends BaseSuggestionData, Variant extends TextFieldVariants = TextFieldVariants> = Omit<TextFieldProps<Variant>, 'onChange' | 'defaultValue'> & MentionsTextFieldBaseProps<T>;
declare function MentionsTextField<T extends BaseSuggestionData>(props: MentionsTextFieldProps<T>): ReactNode;
export default MentionsTextField;