API reference: @salmonui/dropdowns/mention
MentionPropsinterface
import type { MentionProps } from '@salmonui/dropdowns/mention';interface MentionProps<T = MentionItem> {
readonly children?: ReactNode;
readonly target?: RefObject<HTMLTextAreaElement | HTMLInputElement | null>;
readonly editor?: MentionEditorTarget | null;
readonly data?: MentionData<T>;
readonly triggers?: readonly MentionTrigger<T>[];
readonly requireLeadingSpace?: boolean;
readonly multiWord?: boolean;
readonly minSearchLength?: number;
readonly maxResults?: number;
readonly searchOperator?: MentionSearchOperator<T>;
readonly matchCase?: boolean;
readonly ignoreAccents?: boolean;
readonly searchFields?: readonly string[];
readonly debounce?: number;
readonly highlightMatches?: boolean;
readonly getItemValue?: (item: T) => string | number;
readonly getItemLabel?: (item: T) => string;
readonly isItemDisabled?: (item: T) => boolean;
readonly getInsertText?: (item: T, trigger: MentionTrigger<T>) => string;
readonly onBeforeInsert?: (event: MentionBeforeInsertEvent<T>) => void;
readonly onInsert?: (event: MentionInsertEvent<T>) => void;
readonly onOpenChange?: (open: boolean, event: MentionOpenChangeEvent) => void;
readonly onSearchChange?: (event: MentionSearchChangeEvent) => void;
readonly onLoadError?: (error: unknown) => void;
readonly renderItem?: (context: MentionRenderItemContext<T>) => ReactNode;
readonly renderEmpty?: () => ReactNode;
readonly renderLoading?: () => ReactNode;
readonly renderError?: (context: {
readonly error: unknown;
}) => ReactNode;
readonly localeText?: Partial<MentionLocaleText>;
readonly container?: Element | null;
readonly className?: string;
readonly style?: CSSProperties;
readonly classNames?: Partial<Record<MentionPart, string>>;
readonly styles?: Partial<Record<MentionPart, CSSProperties>>;
readonly ref?: Ref<HTMLDivElement>;
}
| Name | Signature | Description |
|---|---|---|
childrenoptional | readonly children?: ReactNode; | One |
targetoptional | readonly target?: RefObject<HTMLTextAreaElement | HTMLInputElement | null>; | The field to attach to when it is not a child. |
editoroptional | readonly editor?: MentionEditorTarget | null; | A |
dataoptional | readonly data?: MentionData<T>; | Suggestions for triggers without their own |
triggersoptional | readonly triggers?: readonly MentionTrigger<T>[]; | Trigger characters, each with optional own data (default |
requireLeadingSpaceoptional | readonly requireLeadingSpace?: boolean; | A trigger only counts at the start or after whitespace (default |
multiWordoptional | readonly multiWord?: boolean; | The search text may contain spaces. |
minSearchLengthoptional | readonly minSearchLength?: number; | Characters typed after the trigger before the list opens. |
maxResultsoptional | readonly maxResults?: number; | Suggestions shown at most. |
searchOperatoroptional | readonly searchOperator?: MentionSearchOperator<T>; | Default |
matchCaseoptional | readonly matchCase?: boolean; | |
ignoreAccentsoptional | readonly ignoreAccents?: boolean; | |
searchFieldsoptional | readonly searchFields?: readonly string[]; | Fields a remote source searches (default |
debounceoptional | readonly debounce?: number; | Delay in ms before a remote read (default 300); local data filters on every keystroke. |
highlightMatchesoptional | readonly highlightMatches?: boolean; | Mark the matched text in each suggestion ( |
getItemValueoptional | readonly getItemValue?: (item: T) => string | number; | |
getItemLabeloptional | readonly getItemLabel?: (item: T) => string; | |
isItemDisabledoptional | readonly isItemDisabled?: (item: T) => boolean; | |
getInsertTextoptional | readonly getInsertText?: (item: T, trigger: MentionTrigger<T>) => string; | Text inserted for an item (default its label). |
onBeforeInsertoptional | readonly onBeforeInsert?: (event: MentionBeforeInsertEvent<T>) => void; | |
onInsertoptional | readonly onInsert?: (event: MentionInsertEvent<T>) => void; | |
onOpenChangeoptional | readonly onOpenChange?: (open: boolean, event: MentionOpenChangeEvent) => void; | |
onSearchChangeoptional | readonly onSearchChange?: (event: MentionSearchChangeEvent) => void; | |
onLoadErroroptional | readonly onLoadError?: (error: unknown) => void; | |
renderItemoptional | readonly renderItem?: (context: MentionRenderItemContext<T>) => ReactNode; | |
renderEmptyoptional | readonly renderEmpty?: () => ReactNode; | |
renderLoadingoptional | readonly renderLoading?: () => ReactNode; | |
renderErroroptional | readonly renderError?: (context: {
readonly error: unknown;
}) => ReactNode; | |
localeTextoptional | readonly localeText?: Partial<MentionLocaleText>; | |
containeroptional | readonly container?: Element | null; | Portal container of the popup (default the field's closest theme scope, else |
classNameoptional | readonly className?: string; | |
styleoptional | readonly style?: CSSProperties; | |
classNamesoptional | readonly classNames?: Partial<Record<MentionPart, string>>; | |
stylesoptional | readonly styles?: Partial<Record<MentionPart, CSSProperties>>; | |
refoptional | readonly ref?: Ref<HTMLDivElement>; | The root |