forked from baidu/amis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
151 lines (138 loc) · 3.15 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
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
import {SchemaApiObject} from './Schema';
export interface ApiObject extends SchemaApiObject {
config?: {
withCredentials?: boolean;
cancelExecutor?: (cancel: Function) => void;
};
body?: PlainObject;
query?: PlainObject;
adaptor?: (payload: object, response: fetcherResult, api: ApiObject) => any;
requestAdaptor?: (api: ApiObject) => ApiObject;
}
export type ApiString = string;
export type Api = ApiString | ApiObject;
export interface fetcherResult {
data?: {
data: object;
status: number;
msg: string;
msgTimeout?: number;
errors?: {
[propName: string]: string;
};
};
status: number;
headers: object;
}
export interface fetchOptions {
method?: 'get' | 'post' | 'put' | 'patch' | 'delete';
successMessage?: string;
errorMessage?: string;
autoAppend?: boolean;
beforeSend?: (data: any) => any;
onSuccess?: (json: Payload) => any;
silent?: boolean;
[propName: string]: any;
}
export interface Payload {
ok: boolean;
msg: string;
msgTimeout?: number;
data: any;
status: number;
errors?: {
[propName: string]: string;
};
}
export interface Schema {
type: string;
detectField?: string;
visibleOn?: string;
hiddenOn?: string;
children?: JSX.Element | ((props: any, schema?: any) => JSX.Element) | null;
definitions?: Definitions;
[propName: string]: any;
}
export interface Button {
type: 'submit' | 'button' | 'reset';
label?: string;
icon?: string;
size?: string;
disabled?: boolean;
className?: string;
}
export type SchemaNode = Schema | string | Array<Schema | string>;
export interface SchemaArray extends Array<SchemaNode> {}
export interface Definitions {
[propName: string]: SchemaNode;
}
export interface Action extends Button {
actionType?:
| 'submit'
| 'copy'
| 'reload'
| 'ajax'
| 'dialog'
| 'drawer'
| 'jump'
| 'link'
| 'url'
| 'close'
| 'confirm'
| 'add'
| 'remove'
| 'delete'
| 'edit'
| 'cancel'
| 'next'
| 'prev'
| 'reset'
| 'reset-and-submit'
| 'clear'
| 'clear-and-submit';
api?: Api;
asyncApi?: Api;
payload?: any;
dialog?: SchemaNode;
to?: string;
target?: string;
link?: string;
url?: string;
mergeData?: boolean;
reload?: string;
messages?: {
success?: string;
failed?: string;
};
feedback?: any;
required?: Array<string>;
[propName: string]: any;
}
export interface Location {
pathname: string;
search: string;
state: any;
hash: string;
key?: string;
query?: any;
}
export interface PlainObject {
[propsName: string]: any;
}
export interface RendererData {
[propsName: string]: any;
__prev?: RendererDataAlias;
__super?: RendererData;
}
type RendererDataAlias = RendererData;
export type FunctionPropertyNames<T> = {
[K in keyof T]: T[K] extends Function ? K : never;
}[keyof T];
export interface JSONSchema {
[propsName: string]: any;
}
// export type Omit<T, K extends keyof T & any> = Pick<T, Exclude<keyof T, K>>;
// export type Override<M, N> = Omit<M, Extract<keyof M, keyof N>> & N;
// export type ExtractProps<
// TComponentOrTProps
// > = TComponentOrTProps extends React.ComponentType<infer P> ? P : never;