UNPKG

2.13 kBTypeScriptView Raw
1import type { CommonInputProps } from 'rc-input/lib/interface';
2import type { TextAreaProps } from 'rc-textarea';
3import React from 'react';
4import type { OptionProps } from './Option';
5import Option from './Option';
6import { filterOption as defaultFilterOption, validateSearch as defaultValidateSearch } from './util';
7type BaseTextareaAttrs = Omit<TextAreaProps, 'prefix' | 'onChange' | 'onSelect' | 'showCount' | 'classNames'>;
8export type Placement = 'top' | 'bottom';
9export type Direction = 'ltr' | 'rtl';
10export interface DataDrivenOptionProps extends Omit<OptionProps, 'children'> {
11 label?: React.ReactNode;
12}
13export interface MentionsProps extends BaseTextareaAttrs {
14 autoFocus?: boolean;
15 className?: string;
16 defaultValue?: string;
17 notFoundContent?: React.ReactNode;
18 split?: string;
19 style?: React.CSSProperties;
20 transitionName?: string;
21 placement?: Placement;
22 direction?: Direction;
23 prefix?: string | string[];
24 prefixCls?: string;
25 value?: string;
26 silent?: boolean;
27 filterOption?: false | typeof defaultFilterOption;
28 validateSearch?: typeof defaultValidateSearch;
29 onChange?: (text: string) => void;
30 onSelect?: (option: OptionProps, prefix: string) => void;
31 onSearch?: (text: string, prefix: string) => void;
32 onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
33 onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
34 getPopupContainer?: () => HTMLElement;
35 dropdownClassName?: string;
36 /** @private Testing usage. Do not use in prod. It will not work as your expect. */
37 open?: boolean;
38 children?: React.ReactNode;
39 options?: DataDrivenOptionProps[];
40 classNames?: CommonInputProps['classNames'] & {
41 mentions?: string;
42 };
43}
44export interface MentionsRef {
45 focus: VoidFunction;
46 blur: VoidFunction;
47 /** @deprecated It may not work as expected */
48 textarea: HTMLTextAreaElement | null;
49 nativeElement: HTMLElement;
50}
51declare const Mentions: React.ForwardRefExoticComponent<MentionsProps & React.RefAttributes<MentionsRef>> & {
52 Option: typeof Option;
53};
54export default Mentions;