Mentions.d.ts
3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import * as React from 'react';
import TextArea, { TextAreaProps } from 'rc-textarea';
import { OptionProps } from './Option';
import { filterOption as defaultFilterOption, Omit, validateSearch as defaultValidateSearch } from './util';
declare type BaseTextareaAttrs = Omit<TextAreaProps, 'prefix' | 'onChange' | 'onSelect'>;
export declare type Placement = 'top' | 'bottom';
export declare type Direction = 'ltr' | 'rtl';
export interface MentionsProps extends BaseTextareaAttrs {
autoFocus?: boolean;
className?: string;
defaultValue?: string;
notFoundContent?: React.ReactNode;
split?: string;
style?: React.CSSProperties;
transitionName?: string;
placement?: Placement;
direction?: Direction;
prefix?: string | string[];
prefixCls?: string;
value?: string;
filterOption?: false | typeof defaultFilterOption;
validateSearch?: typeof defaultValidateSearch;
onChange?: (text: string) => void;
onSelect?: (option: OptionProps, prefix: string) => void;
onSearch?: (text: string, prefix: string) => void;
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
getPopupContainer?: () => HTMLElement;
}
interface MentionsState {
value: string;
measuring: boolean;
measureText: string | null;
measurePrefix: string;
measureLocation: number;
activeIndex: number;
isFocus: boolean;
}
declare class Mentions extends React.Component<MentionsProps, MentionsState> {
static Option: React.SFC<OptionProps>;
textarea?: HTMLTextAreaElement;
measure?: HTMLDivElement;
focusId: number | undefined;
static defaultProps: {
prefixCls: string;
prefix: string;
split: string;
validateSearch: typeof defaultValidateSearch;
filterOption: typeof defaultFilterOption;
notFoundContent: string;
rows: number;
};
static getDerivedStateFromProps(props: MentionsProps, prevState: MentionsState): Partial<MentionsState>;
constructor(props: MentionsProps);
componentDidUpdate(): void;
triggerChange: (value: string) => void;
onChange: React.ChangeEventHandler<HTMLTextAreaElement>;
onKeyDown: React.KeyboardEventHandler<HTMLTextAreaElement>;
/**
* When to start measure:
* 1. When user press `prefix`
* 2. When measureText !== prevMeasureText
* - If measure hit
* - If measuring
*
* When to stop measure:
* 1. Selection is out of range
* 2. Contains `space`
* 3. ESC or select one
*/
onKeyUp: React.KeyboardEventHandler<HTMLTextAreaElement>;
onPressEnter: React.KeyboardEventHandler<HTMLTextAreaElement>;
onInputFocus: React.FocusEventHandler<HTMLTextAreaElement>;
onInputBlur: React.FocusEventHandler<HTMLTextAreaElement>;
onDropdownFocus: () => void;
onDropdownBlur: () => void;
onFocus: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
onBlur: (event?: React.FocusEvent<HTMLTextAreaElement>) => void;
selectOption: (option: OptionProps) => void;
setActiveIndex: (activeIndex: number) => void;
setTextAreaRef: (element: TextArea) => void;
setMeasureRef: (element: HTMLDivElement) => void;
getOptions: (measureText?: string) => OptionProps[];
startMeasure(measureText: string, measurePrefix: string, measureLocation: number): void;
stopMeasure(callback?: () => void): void;
focus(): void;
blur(): void;
render(): JSX.Element;
}
export default Mentions;