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