forked from FishandRichardsonPC/react-mentions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
executable file
·173 lines (160 loc) · 5.03 KB
/
index.d.ts
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// Type definitions for react-mentions 4.1
// Project: https://github.com/signavio/react-mentions
// Definitions by: Scott Willeke <https://github.com/activescott>
// Eugene Fedorenko <https://github.com/efedorenko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5
import * as React from 'react'
export {}
/**
* MentionsInput is the main component rendering the textarea control. It takes one or multiple Mention components as its children.
*/
export const MentionsInput: MentionsInputClass
/**
* Each Mention component represents a data source for a specific class of mentionable objects, such as users, template variables, issues, etc.
*/
export const Mention: React.FC<MentionProps>
/**
* The properties for the @see MentionsInput component.
*/
export interface MentionsInputProps
extends Omit<
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
'onChange' | 'onBlur' | 'onKeyDown' | 'onSelect'
> {
/**
* If set to `true` a regular text input element will be rendered
* instead of a textarea
*/
singleLine?: boolean | undefined
/**
* If set to `true` spaces will not interrupt matching suggestions
*/
allowSpaceInQuery?: boolean | undefined
allowSuggestionsAboveCursor?: boolean | undefined
forceSuggestionsAboveCursor?: boolean | undefined
ignoreAccents?: boolean | undefined
value?: string | undefined
onChange?: OnChangeHandlerFunc | undefined
placeholder?: string | undefined
onBlur?:
| ((
event:
| React.FocusEvent<HTMLInputElement>
| React.FocusEvent<HTMLTextAreaElement>,
clickedSuggestion: boolean
) => void)
| undefined
onSelect?: ((event: React.UIEvent) => void) | undefined
onKeyDown?:
| ((
event:
| React.KeyboardEvent<HTMLTextAreaElement>
| React.KeyboardEvent<HTMLInputElement>
) => void)
| undefined
children:
| React.ReactElement<MentionProps>
| Array<React.ReactElement<MentionProps>>
className?: string | undefined
classNames?: any
style?: any
customSuggestionsContainer?: (
children: React.ReactNode
) => React.ReactNode | undefined
suggestionsPortalHost?: Element | undefined
inputRef?:
| React.Ref<HTMLTextAreaElement>
| React.Ref<HTMLInputElement>
| undefined
renderInput?: React.ReactElement | undefined
/**
* This label would be exposed to screen readers when suggestion popup appears
* @default ''
*/
a11ySuggestionsListLabel?: string | undefined
}
/**
* Exposes the type for use with the @see MentionsInputComponent.wrappedInstance which is added by react-mentions' use of substyle (https://github.com/jfschwarz/substyle).
*/
export interface MentionsInputComponentUnrwapped
extends React.Component<MentionsInputProps> {
/**
* @deprecated since version 2.4.0. Please use @see MentionsInputProps.inputRef
*/
inputRef?: HTMLInputElement | HTMLTextAreaElement | undefined
}
/**
* Used with @see React.RefObject<MentionsInputComponent>.
*/
export interface MentionsInputComponent
extends React.Component<MentionsInputProps> {
// MentionsInput uses substyle (https://github.com/jfschwarz/substyle) which adds this wrappedInstance
wrappedInstance?: MentionsInputComponentUnrwapped | undefined
}
/**
* Used to reference MentionsInput element in a TSX file.
*/
export interface MentionsInputClass
extends React.ComponentClass<MentionsInputProps> {}
/**
* Props definition for a mention subelement.
*/
export interface MentionProps {
onAdd?: ((id: string | number, display: string) => void) | undefined
renderSuggestion?:
| ((
suggestion: SuggestionDataItem,
search: string,
highlightedDisplay: React.ReactNode,
index: number,
focused: boolean
) => React.ReactNode)
| undefined
className?: string | undefined
markup?: string | undefined
displayTransform?: DisplayTransformFunc | undefined
trigger: string | RegExp
isLoading?: boolean | undefined
data: SuggestionDataItem[] | DataFunc
style?: any
appendSpaceOnAdd?: boolean | undefined
regex?: RegExp | undefined
}
/**
* The shape of a mention.
*/
export interface MentionItem {
display: string
id: string
childIndex: number
index: number
plainTextIndex: number
}
/**
* The shape of suggestion items.
*/
export interface SuggestionDataItem {
id: string | number
display?: string
}
/**
* Defines the function signature for implementing @see MentionsInputProps.displayTransform
*/
export type DisplayTransformFunc = (id: string, display: string) => string
/**
* Defines the function signature for implementing @see MentionsInputProps.onChange
*/
export type OnChangeHandlerFunc = (
event: { target: { value: string } },
newValue: string,
newPlainTextValue: string,
mentions: MentionItem[]
) => void
/**
* The function to implement asynchronous loading of suggestions in @see MentionProps.data .
*/
export type DataFunc = (
query: string,
callback: (data: SuggestionDataItem[]) => void
) => Promise<void> | void | Promise<SuggestionDataItem[]> | SuggestionDataItem[]