-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
88 lines (73 loc) · 2.66 KB
/
types.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
import { CSSProperties } from 'react'
import { ExpandableConfig } from 'antd/lib/table/interface'
export type CreateApi<T> = (record: Partial<T>, props: any) => Promise<void>
export type UpdateApi<T> = (record: Partial<T>, props: any) => Promise<void>
export type DeleteApi<T> = (record: Partial<T>, props: any) => Promise<void>
export interface SelectFilter {
name: string,
options: { value: any, text: string }[]
labelText?: string,
selectStyle?: CSSProperties,
getOptions?: (props?: any) => Promise<{ value: any, text: string }[]>
}
export interface SearchProps {
keyword: string
filters: string[]
pageNum: number
pageSize: number
}
export type SearchApi<T> = (searchProps: SearchProps, props: any) => Promise<{
items: T[],
total: number,
pageNum: number
pageSize: number
}>
export interface ExportProps {
keyword: string
filters: string[]
}
export type ExportApi = (exportProps: ExportProps, props: any) => void
export type BatchDeleteApi<T> = (selectdRecords: Partial<T>[], props: any) => Promise<void>
export type TableOperation<T> = {
type?: 'update'|'delete'|'custom'
icon?: React.ReactNode
text: string
onOperation?: (record: T, props: any) => void
}
export interface ListViewOptions<T> {
title?: string|boolean
itemName: string
className: string
extraWidth: number|'auto'
extraSearchPlaceholder: string
extraAddOn?: (props: any, onRefresh: () => Promise<void>) => (string | JSX.Element)
tableClassName: string
tableColumns: any[]
tableOperations: ('update'|'delete'|TableOperation<T>)[]
tableOperationsStyle: CSSProperties
tableWrapper: 'card'|'none'
tableScroll: ({
x?: string | number | true | undefined
y?: string | number | undefined
} & {
scrollToFirstRowOnChange?: boolean | undefined
}) | undefined
tableExpandable?: ExpandableConfig<object>
filters: (string | SelectFilter)[]
createItemEnabled: boolean
batchDeleteEnabled: boolean
createItem: CreateApi<T>
updateItem: UpdateApi<T>
deleteItem: DeleteApi<T>
fetchItems: SearchApi<T>
batchDeleteItems: BatchDeleteApi<T>
createFormItems?: (props: any) => any[]
updateFormItems?: (record: T, props: any) => any[]
formLabelWidth?: number
detailTitle?: string | React.Component<{}, {}, any> | React.FC<{}> | undefined
createDetailComponent?: (record: T, props: any, quit?: () => void) => React.ReactChildren
creationTitle?: string | React.Component<{}, {}, any> | React.FC<{}> | undefined
createCreationComponent?: (props: any, quit?: () => void) => React.ReactChildren
exportEnabled?: boolean
exportItems?: ExportApi
}