View as Markdown

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>;
}
MentionProps members (35)
NameSignatureDescription
childrenoptionalreadonly children?: ReactNode;

One <textarea> or <input> (possibly nested in other markup). Omit it and pass target instead.

targetoptionalreadonly target?: RefObject<HTMLTextAreaElement | HTMLInputElement | null>;

The field to attach to when it is not a child.

editoroptionalreadonly editor?: MentionEditorTarget | null;

A contenteditable surface to attach to instead of a field: the result of createContentEditableMentionTarget(element) or the target a rich text editor provides. Keep it stable across renders; it wins over target and children fields.

dataoptionalreadonly data?: MentionData<T>;

Suggestions for triggers without their own data.

triggersoptionalreadonly triggers?: readonly MentionTrigger<T>[];

Trigger characters, each with optional own data (default [{ char: '@' }]).

requireLeadingSpaceoptionalreadonly requireLeadingSpace?: boolean;

A trigger only counts at the start or after whitespace (default true).

multiWordoptionalreadonly multiWord?: boolean;

The search text may contain spaces.

minSearchLengthoptionalreadonly minSearchLength?: number;

Characters typed after the trigger before the list opens.

maxResultsoptionalreadonly maxResults?: number;

Suggestions shown at most.

searchOperatoroptionalreadonly searchOperator?: MentionSearchOperator<T>;

Default 'contains'.

matchCaseoptionalreadonly matchCase?: boolean;
ignoreAccentsoptionalreadonly ignoreAccents?: boolean;
searchFieldsoptionalreadonly searchFields?: readonly string[];

Fields a remote source searches (default ['label']).

debounceoptionalreadonly debounce?: number;

Delay in ms before a remote read (default 300); local data filters on every keystroke.

highlightMatchesoptionalreadonly highlightMatches?: boolean;

Mark the matched text in each suggestion (<mark>).

getItemValueoptionalreadonly getItemValue?: (item: T) => string | number;
getItemLabeloptionalreadonly getItemLabel?: (item: T) => string;
isItemDisabledoptionalreadonly isItemDisabled?: (item: T) => boolean;
getInsertTextoptionalreadonly getInsertText?: (item: T, trigger: MentionTrigger<T>) => string;

Text inserted for an item (default its label).

onBeforeInsertoptionalreadonly onBeforeInsert?: (event: MentionBeforeInsertEvent<T>) => void;
onInsertoptionalreadonly onInsert?: (event: MentionInsertEvent<T>) => void;
onOpenChangeoptionalreadonly onOpenChange?: (open: boolean, event: MentionOpenChangeEvent) => void;
onSearchChangeoptionalreadonly onSearchChange?: (event: MentionSearchChangeEvent) => void;
onLoadErroroptionalreadonly onLoadError?: (error: unknown) => void;
renderItemoptionalreadonly renderItem?: (context: MentionRenderItemContext<T>) => ReactNode;
renderEmptyoptionalreadonly renderEmpty?: () => ReactNode;
renderLoadingoptionalreadonly renderLoading?: () => ReactNode;
renderErroroptionalreadonly renderError?: (context: { readonly error: unknown; }) => ReactNode;
localeTextoptionalreadonly localeText?: Partial<MentionLocaleText>;
containeroptionalreadonly container?: Element | null;

Portal container of the popup (default the field's closest theme scope, else document.body).

classNameoptionalreadonly className?: string;
styleoptionalreadonly style?: CSSProperties;
classNamesoptionalreadonly classNames?: Partial<Record<MentionPart, string>>;
stylesoptionalreadonly styles?: Partial<Record<MentionPart, CSSProperties>>;
refoptionalreadonly ref?: Ref<HTMLDivElement>;

The root <div> that wraps children.