forked from aksonov/react-native-tableview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
315 lines (277 loc) · 6.33 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
// Type definitions for react-native-tableview
// Project: https://github.com/aksonov/react-native-tableview
// Definitions by: Kyle Roach <https://github.com/iRoachie>
// TypeScript Version: 2.6
import * as React from 'react'
import { ViewStyle, Insets, PointPropType, NativeSyntheticEvent, NativeScrollEvent } from 'react-native'
type FontWeight = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 'bold' | 'normal'
type FontStyle = 'italic' | 'normal' | 'oblique'
interface CallBack {
cancelBubble: boolean
target: number
}
interface AccessoryCallBack extends CallBack {
accessoryIndex: number
accessorySection: number
accessoryType: number
children: string
footerLabel?: string
label?: string
}
interface DisplayCallBack extends CallBack {
row: number
section: number
}
interface OnPressCallBack extends CallBack {
children: string
selectedIndex: number
selectedSection: number
selectedOrigin: PointPropType
footerLabel?: string
label?: string
}
interface OnChangeCallBack extends CallBack {
sourceIndex: number
sourceSection: number
destinationIndex?: number
destinationSection?: number
mode: 'move' | 'delete'
canMove?: boolean
canEdit?: boolean
children?: string
label?: string
}
export interface Constants {
Style: {
Plain: number
Grouped: number
}
CellStyle: {
Default: number
Value1: number
Value2: number
Subtitle: number
}
CellEditingStyle: {
None: number
Delete: number
Insert: number
}
CellSelectionStyle: {
None: number
Blue: number
Gray: number
Default: number
}
SeparatorStyle: {
None: number
Line: number
}
AccessoryType: {
None: number
DisclosureIndicator: number
DisclosureButton: number
Checkmark: number
DetailButton: number
}
}
export enum AccessoryType {
None = 0,
DisclosureIndicator,
DisclosureButton,
Checkmark,
DetailButton,
}
export enum TableViewStyle {
Plain = 0,
Grouped,
}
export enum TableViewCellStyle {
Default = 0,
Value1,
Value2,
Subtitle,
}
export enum CellEditingStyle {
None = 0,
Delete,
Insert,
}
export enum SeparatorStyle {
None = 0,
Line,
}
export enum CellSelectionStyle {
None = 0,
Blue,
Gray,
Default,
}
interface SectionProps {
/**
* Show the DisclosureIndicator accessory type
*/
arrow?: boolean
/**
* If cell is allowed to be dragged in editing mode
*/
canMove?: boolean
/**
* If cell can be deleted in editing mode
*/
canEdit?: boolean
/**
* Title for header
*/
label?: string
/**
* Title for header
*/
footerLabel?: string
/**
* Height of header
*/
headerHeight?: number
/**
* Height of footer
*/
footerHeight?: number
}
interface ItemProps {
/**
* This value will be returned on event callbacks
*/
value?: string | number
/**
* Show the Checkmark accessory type
*/
selected?: boolean
/**
* Detail text to show
*/
detail?: string
/**
* Accessory type
*/
accessoryType?: AccessoryType
/**
* If cell is allowed to be dragged in editing mode
*/
canMove?: boolean
/**
* If cell can be deleted in editing mode
*/
canEdit?: boolean
/**
* Cell selection style
*/
selectionStyle?: CellSelectionStyle
/**
* Allow transparent cell background
*/
transparent?: boolean
/**
* Callback fired on pressing an accessory
*/
onAccessoryPress?(event: AccessoryCallBack): void
/**
* Callback fired on pressing an item
*/
onPress?(event: OnPressCallBack): void
}
interface TableViewProps {
style?: ViewStyle
tableViewStyle?: TableViewStyle
tableViewCellStyle?: TableViewCellStyle
tableViewCellEditingStyle?: CellEditingStyle
separatorStyle?: SeparatorStyle
editing?: boolean
autoFocusAnimate?: boolean
autoFocus?: boolean
alwaysBounceVertical?: boolean
scrollEnabled?: boolean
allowsToggle?: boolean
allowsMultipleSelection?: boolean
sectionIndexTitlesEnabled?: boolean
showsHorizontalScrollIndicator?: boolean
showsVerticalScrollIndicator?: boolean
moveWithinSectionOnly?: boolean
reactModuleForCell?: string
/**
* If the tableview can pull to refresh
*/
canRefresh?: boolean
/**
* Current refreshing status.
*
* Used to hide or show the loading indicator while refreshing
*/
refreshing?: boolean
selectedValue?: string | number
json?: string
filter?: string
contentInset?: Insets
contentOffset?: PointPropType
scrollIndicatorInsets?: Insets
textColor?: string
detailTextColor?: string
tintColor?: string
headerTextColor?: string
headerBackgroundColor?: string
footerTextColor?: string
separatorColor?: string
fontSize?: number
fontWeight?: FontWeight
fontStyle?: FontStyle
fontFamily?: string
detailFontSize?: number
detailFontWeight?: FontWeight
detailFontStyle?: FontStyle
detailFontFamily?: string
headerFontSize?: number
headerFontWeight?: FontWeight
headerFontStyle?: FontStyle
headerFontFamily?: string
footerFontSize?: number
footerFontWeight?: FontWeight
footerFontStyle?: FontStyle
footerFontFamily?: string
onScroll?(event: NativeSyntheticEvent<NativeScrollEvent>): void
onPress?(event: OnPressCallBack): void
onChange?(event: OnChangeCallBack): void
/**
* Fired when pull to refresh is active
*/
onRefresh?(): void
onAccessoryPress?(event: AccessoryCallBack): void
onWillDisplayCell?(event: DisplayCallBack): void
onEndDisplayingCell?(event: DisplayCallBack): void
cellSeparatorInset?: Insets
cellLayoutMargins?: Insets
}
declare class TableView extends React.Component<TableViewProps> {
/**
* Scroll to coordinates
*
* @param x Horizontal pixels to scroll
* @param y Vertical pixels to scroll
* @param animated With animation or not
*/
scrollTo(x: number, y: number, animated: boolean): void
/**
* Scroll to an index
*
* @param params scroll params
* @param params.index index of the cell
* @param params.section index of the section @default 0
* @param params.animated scroll with animation @default true
*/
scrollToIndex(params: { index: number; section?: number; animated?: boolean }): void
}
declare namespace TableView {
const Consts: Constants
class Section extends React.Component<SectionProps> {}
class Item extends React.Component<ItemProps> {}
class Cell extends React.Component<ItemProps> {}
}
export default TableView