-
Notifications
You must be signed in to change notification settings - Fork 0
/
typeDeclarations.ts
192 lines (179 loc) · 6.06 KB
/
typeDeclarations.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
import SimpleSchema2Bridge from 'uniforms-bridge-simple-schema-2'
import {Mongo} from 'meteor/mongo'
import SimpleSchema from 'simpl-schema'
import {FC} from 'react'
export interface RoleObject {
role: string | Array<string>
scope?: string
forAnyScope?: boolean
}
export type Role = string | Array<string> | RoleObject | ((id: string) => boolean)
export interface createTableDataAPIParams {
sourceName: string
sourceSchema: SimpleSchema
collection: Mongo.Collection<object>
useObjectIds?: boolean
listSchema?: SimpleSchema
formSchema?: SimpleSchema
queryEditorSchema?: SimpleSchema
canEdit?: boolean
canSearch?: boolean
canUseQueryEditor?: boolean
canSort?: boolean
canAdd?: boolean
canDelete?: boolean
canExport?: boolean
viewTableRole?: Role
editRole?: Role
addRole?: Role
deleteRole?: Role
exportTableRole?: Role
query?: object
initialSortColumn?: string
initialSortDirection?: 'ASC' | 'DESC'
perLoad?: number
getPreSelectPipeline?: ({pub}?: {pub: object}) => Array<Object>
getProcessorPipeline?: ({pub}?: {pub: object}) => Array<Object>
getRowsPipeline?:
(_: {
pub: object,
search: string,
query?: Mongo.Query<any>,
sort?: Mongo.SortSpecifier
limit?: number
skip?: number}) => Array<object>
getRowCountPipeline?:
(options: {
pub: object,
search: string,
query?: Mongo.Query<any>}) => Array<object>
getExportPipeline?:
(options: {
search: string,
query?: Mongo.Query<any>,
sort?: Mongo.SortSpecifier}) => Array<object>
makeFormDataFetchMethodRunFkt?:
(options: {
collection: Mongo.Collection<any>
transFormIdToMongo: (id: any) => any
transFormIdToMiniMongo: (id: any) => any
}) => (options: {id: string}) => Mongo.Cursor<any>
makeSubmitMethodRunFkt?:
(options: {
collection: Mongo.Collection<any>
transFormIdToMongo: (id: any) => any
transFormIdToMiniMongo: (id: any) => any
}) => (options: {data: object, id: string}) => void
makeDeleteMethodRunFkt?:
(options: {
collection: Mongo.Collection<any>
transFormIdToMongo: (id: any) => any
transFormIdToMiniMongo: (id: any) => any
}) => (options: {id: string}) => void
debounceDelay?: number
observers?: Array<any>
setupNewItem?: () => object
onSubmit?: (object) => any
showRowCount?: boolean
checkDisableEditForRow?: boolean
checkDisableDeleteForRow?: boolean
}
export interface createTableDataAPIReturn {
sourceName: string
listSchemaBridge: SimpleSchema2Bridge
formSchemaBridge: SimpleSchema2Bridge
queryEditorSchemaBridge: SimpleSchema2Bridge
rowsCollection: Mongo.Collection<any>
rowCountCollection: Mongo.Collection<any>
canEdit?: boolean
canSearch?: boolean
canUseQueryEditor?: boolean
canSort?: boolean
canAdd?: boolean
canDelete?: boolean
deleteConfirmation?: string
canExport?: boolean
viewTableRole?: string | Array<string>
editRole?: string | Array<string>
addRole?: string | Array<string>
deleteRole?: string | Array<string>
exportTableRole?: string | Array<string>
setupNewItem?: () => object
onSubmit?: (object) => any
onDelete?: ({id}: {id: string}) => Promise<any>
onChangeField?: ({_id, changeData}: {_id: string, changeData: object}) => any
query?: object
initialSortColumn?: string
initialSortDirection?: 'ASC' | 'DESC'
showRowCount?: boolean
perLoad: number
}
export declare function createTableDataAPI(options: createTableDataAPIParams): createTableDataAPIReturn
// This is for additional options we can shove into our Components
export interface additionalDataTableOptions {
onRowClick?: ({rowData, index}: {rowData: any, index: number}) => void
autoFormChildren?: [any]
formDisabled?: boolean
formReadOnly?: boolean
loadEditorData?: ({id}: {id: string}) => Promise<any>
queryUiObject?: object
}
export type DataTableOptions = createTableDataAPIReturn & additionalDataTableOptions
export interface additionalDataTableDisplayOptions {
rows: [any]
totalRowCount: number
loadMoreRows: ({startIndex, stopIndex}: {startIndex: number, stopIndex: number}) => Promise<any>
sortColumn: string
sortDirection: 'ASC' | 'DESC'
onChangeSort: ({sortColumn, sortDirection}: {sortColumn: string, sortDirection: 'ASC' | 'DESC'}) => void
search: 'string'
onChangeSearch: (searchString: string) => void
onDelete: ({id}: {id: string}) => Promise<any>
onChangeQueryUiObject: (queryUiObject: object) => void
mayAdd?: boolean
onAdd?: () => void
mayDelete?: boolean
mayEdit?: boolean
mayExport?: boolean
onExportTable?: () => void
isLoading?: boolean
overscanRowCount?: number
customComponents: customComponents
}
export type DataTableDisplayOptions = DataTableOptions & additionalDataTableDisplayOptions
export declare function DataTableDisplayComponent(options: DataTableDisplayOptions): FC
export interface DataTableHeaderOptions {
listSchemaBridge: SimpleSchema2Bridge
queryEditorSchemaBridge: SimpleSchema2Bridge
loadedRowCount: number
totalRowCount: number
canSearch?: boolean
search?: string
onChangeSearch?: (searchString: string) => void
canUseQueryEditor?: boolean
queryUiObject?: object
onChangeQueryUiObject: (queryUiObject: object) => void
canExport?: boolean
mayExport?: boolean
onExportTable?: () => void
canAdd?: boolean
mayAdd?: boolean
onAdd?: () => void
canSort?: boolean
sortColumn?: string
sortDirection?: 'ASC' | 'DESC'
onChangeSort: ({sortColumn, sortDirection}: {sortColumn: string, sortDirection: 'ASC' | 'DESC'}) => void
AdditionalHeaderButtonsLeft?: FC
AdditionalHeaderButtonsRight?: FC
// query?: object
// onChangeQuery?: (query: object) => void
}
export declare function DefaultHeader(options: DataTableHeaderOptions): FC
// TODO [TS] gather types of all implemented customComponent props
export type customComponents = {[key: string]: FC}
export interface MeteorTableDataHandlerOptions {
dataOptions: DataTableOptions
DisplayComponent: typeof DataTableDisplayComponent
customComponents: customComponents
}
export declare function MeteorTableDataHandler(options: MeteorTableDataHandlerOptions): FC