UNPKG

2.19 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 onPopupScroll?: (event: React.UIEvent<HTMLDivElement>) => void;
44}
45export interface MentionsRef {
46 focus: VoidFunction;
47 blur: VoidFunction;
48 /** @deprecated It may not work as expected */
49 textarea: HTMLTextAreaElement | null;
50 nativeElement: HTMLElement;
51}
52declare const Mentions: React.ForwardRefExoticComponent<MentionsProps & React.RefAttributes<MentionsRef>> & {
53 Option: typeof Option;
54};
55export default Mentions;