@faasjs/ant-design 0.0.3-beta.6 → 0.0.3-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +199 -271
- package/dist/index.d.ts +342 -249
- package/dist/index.js +654 -359
- package/dist/index.mjs +703 -407
- package/package.json +7 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,101 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { CSSProperties, ReactNode, LazyExoticComponent, ComponentType } from 'react';
|
|
3
1
|
import { ConfigProviderProps as ConfigProviderProps$1 } from 'antd/es/config-provider';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { StyleProviderProps } from '@ant-design/cssinjs/lib/StyleContext';
|
|
3
|
+
import { MessageInstance } from 'antd/es/message/interface';
|
|
4
|
+
import { NotificationInstance } from 'antd/es/notification/interface';
|
|
5
|
+
import { ModalProps as ModalProps$1, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, DatePickerProps, TimePickerProps, FormInstance, DescriptionsProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, FormProps as FormProps$1, ButtonProps } from 'antd';
|
|
6
6
|
export { Drawer, Modal } from 'antd';
|
|
7
|
-
import {
|
|
8
|
-
import * as
|
|
7
|
+
import { BrowserRouterProps, RouteProps } from 'react-router-dom';
|
|
8
|
+
import * as react from 'react';
|
|
9
|
+
import { CSSProperties, ReactNode, ReactElement, Component, LazyExoticComponent, ComponentType } from 'react';
|
|
10
|
+
export { lazy } from 'react';
|
|
11
|
+
import { Dayjs } from 'dayjs';
|
|
9
12
|
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
10
|
-
import {
|
|
13
|
+
import { FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1 } from '@faasjs/react';
|
|
11
14
|
import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
|
|
15
|
+
import * as antd_es_form_context from 'antd/es/form/context';
|
|
16
|
+
import * as antd_es_form_ErrorList from 'antd/es/form/ErrorList';
|
|
17
|
+
import * as antd_es_form from 'antd/es/form';
|
|
18
|
+
import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
|
|
19
|
+
import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
|
|
20
|
+
import * as antd_es_form_Form from 'antd/es/form/Form';
|
|
21
|
+
|
|
22
|
+
interface ModalProps extends ModalProps$1 {
|
|
23
|
+
children?: JSX.Element | JSX.Element[] | string;
|
|
24
|
+
}
|
|
25
|
+
type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Hook style modal.
|
|
28
|
+
* @param init initial props
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* function Example() {
|
|
32
|
+
* const { modal, setModalProps } = useModal()
|
|
33
|
+
*
|
|
34
|
+
* return <>
|
|
35
|
+
* <Button onClick={() => setModalProps({ open: true })}>Open Modal</Button>
|
|
36
|
+
* {modal}</>
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare function useModal(init?: ModalProps): {
|
|
41
|
+
modal: JSX.Element;
|
|
42
|
+
modalProps: ModalProps;
|
|
43
|
+
setModalProps(changes: Partial<ModalProps>): void;
|
|
44
|
+
};
|
|
12
45
|
|
|
13
|
-
|
|
46
|
+
interface DrawerProps extends DrawerProps$1 {
|
|
47
|
+
children?: JSX.Element | JSX.Element[];
|
|
48
|
+
}
|
|
49
|
+
type setDrawerProps = (changes: Partial<DrawerProps>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Hook style drawer.
|
|
52
|
+
*
|
|
53
|
+
* @param init initial props
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* function Example() {
|
|
57
|
+
* const { drawer, setDrawerProps } = useDrawer()
|
|
58
|
+
*
|
|
59
|
+
* return <>
|
|
60
|
+
* <Button onClick={ () => setDrawerProps(prev => ({ open: !prev.open})) }>
|
|
61
|
+
* Toggle
|
|
62
|
+
* </Button>
|
|
63
|
+
* {drawer}
|
|
64
|
+
* </>
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare function useDrawer(init?: DrawerProps): {
|
|
69
|
+
drawer: JSX.Element;
|
|
70
|
+
drawerProps: DrawerProps;
|
|
71
|
+
setDrawerProps(changes: Partial<DrawerProps>): void;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
interface AppProps {
|
|
75
|
+
children: React.ReactNode;
|
|
76
|
+
styleProviderProps?: StyleProviderProps;
|
|
77
|
+
configProviderProps?: ConfigProviderProps$1;
|
|
78
|
+
browserRouterProps?: BrowserRouterProps;
|
|
79
|
+
}
|
|
80
|
+
interface useAppProps {
|
|
81
|
+
message: MessageInstance;
|
|
82
|
+
notification: NotificationInstance;
|
|
83
|
+
setModalProps: (changes: Partial<ModalProps>) => void;
|
|
84
|
+
setDrawerProps: (changes: Partial<DrawerProps>) => void;
|
|
85
|
+
}
|
|
86
|
+
declare function App(props: AppProps): JSX.Element;
|
|
87
|
+
declare namespace App {
|
|
88
|
+
var useApp: typeof useApp;
|
|
89
|
+
}
|
|
90
|
+
declare function useApp(): useAppProps;
|
|
91
|
+
|
|
92
|
+
interface BlankProps {
|
|
14
93
|
value?: any;
|
|
15
94
|
text?: string;
|
|
16
|
-
}
|
|
95
|
+
}
|
|
17
96
|
/**
|
|
97
|
+
* Blank component.
|
|
98
|
+
*
|
|
18
99
|
* If value is undefined or null, return text, otherwise return value.
|
|
19
100
|
*
|
|
20
101
|
* @param options {object}
|
|
@@ -28,8 +109,7 @@ type BlankProps = {
|
|
|
28
109
|
*/
|
|
29
110
|
declare function Blank(options?: BlankProps): JSX.Element;
|
|
30
111
|
|
|
31
|
-
|
|
32
|
-
antd?: ConfigProviderProps$1;
|
|
112
|
+
interface ConfigProviderProps {
|
|
33
113
|
lang?: string;
|
|
34
114
|
common?: {
|
|
35
115
|
blank?: string;
|
|
@@ -60,7 +140,7 @@ type ConfigProviderProps = {
|
|
|
60
140
|
target?: string;
|
|
61
141
|
style?: CSSProperties;
|
|
62
142
|
};
|
|
63
|
-
}
|
|
143
|
+
}
|
|
64
144
|
declare const ConfigContext: react.Context<ConfigProviderProps>;
|
|
65
145
|
/**
|
|
66
146
|
* Config for @faasjs/ant-design components.
|
|
@@ -81,6 +161,161 @@ declare function ConfigProvider({ config, children }: {
|
|
|
81
161
|
}): JSX.Element;
|
|
82
162
|
declare function useConfigContext(): ConfigProviderProps;
|
|
83
163
|
|
|
164
|
+
type ExtendFormTypeProps<T = any> = {
|
|
165
|
+
children?: UnionFaasItemElement<T>;
|
|
166
|
+
};
|
|
167
|
+
type ExtendTypes = {
|
|
168
|
+
[type: string]: ExtendFormTypeProps;
|
|
169
|
+
};
|
|
170
|
+
type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
171
|
+
interface FormItemProps<T = any> extends FaasItemProps, Omit<FormItemProps$1<T>, 'id' | 'children' | 'render'> {
|
|
172
|
+
input?: InputProps | InputNumberProps | SwitchProps | SelectProps<T> | DatePickerProps | TimePickerProps;
|
|
173
|
+
maxCount?: number;
|
|
174
|
+
object?: FormItemProps[];
|
|
175
|
+
disabled?: boolean;
|
|
176
|
+
required?: boolean;
|
|
177
|
+
col?: number;
|
|
178
|
+
children?: UnionFaasItemElement<T>;
|
|
179
|
+
formChildren?: UnionFaasItemElement<T>;
|
|
180
|
+
render?: UnionFaasItemRender<T>;
|
|
181
|
+
formRender?: UnionFaasItemRender<T>;
|
|
182
|
+
rules?: RuleObject[];
|
|
183
|
+
label?: string | false;
|
|
184
|
+
extendTypes?: ExtendTypes;
|
|
185
|
+
/** trigger when current item's value changed */
|
|
186
|
+
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
187
|
+
/** trigger when any item's value changed */
|
|
188
|
+
if?: (values: Record<string, any>) => boolean;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* FormItem, can be used without Form.
|
|
192
|
+
*
|
|
193
|
+
* ```ts
|
|
194
|
+
* // use inline type
|
|
195
|
+
* <FormItem type='string' id='name' />
|
|
196
|
+
*
|
|
197
|
+
* // use custom type
|
|
198
|
+
* <FormItem id='password'>
|
|
199
|
+
* <Input.Password />
|
|
200
|
+
* </>
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
204
|
+
declare namespace FormItem {
|
|
205
|
+
var useStatus: () => {
|
|
206
|
+
status?: "" | "success" | "error" | "warning" | "validating";
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
type LoadingProps = {
|
|
211
|
+
style?: React.CSSProperties;
|
|
212
|
+
size?: 'small' | 'default' | 'large';
|
|
213
|
+
loading?: boolean;
|
|
214
|
+
children?: React.ReactNode;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Loading component based on Spin
|
|
218
|
+
*
|
|
219
|
+
* ```tsx
|
|
220
|
+
* <Loading /> // display loading
|
|
221
|
+
*
|
|
222
|
+
* <Loading loading={ !remoteData }>
|
|
223
|
+
* <div>{remoteData}</div>
|
|
224
|
+
* </Loading>
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
declare function Loading(props: LoadingProps): JSX.Element;
|
|
228
|
+
|
|
229
|
+
type FaasDataInjection<T = any> = Partial<FaasDataInjection$1<T>>;
|
|
230
|
+
interface FaasDataWrapperProps<T = any> extends FaasDataWrapperProps$1<T> {
|
|
231
|
+
loadingProps?: LoadingProps;
|
|
232
|
+
loading?: JSX.Element;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* FaasDataWrapper component with Loading
|
|
236
|
+
*
|
|
237
|
+
* ```tsx
|
|
238
|
+
* function MyComponent (props: FaasDataInjection) {
|
|
239
|
+
* return <div>{ props.data }</div>
|
|
240
|
+
* }
|
|
241
|
+
*
|
|
242
|
+
* function MyPage () {
|
|
243
|
+
* return <FaasDataWrapper action="test" params={{ a: 1 }}>
|
|
244
|
+
* <MyComponent />
|
|
245
|
+
* </FaasDataWrapper>
|
|
246
|
+
* }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
declare function FaasDataWrapper<T = any>(props: FaasDataWrapperProps<T>): JSX.Element;
|
|
250
|
+
|
|
251
|
+
interface ExtendDescriptionTypeProps<T = any> {
|
|
252
|
+
children?: UnionFaasItemElement<T>;
|
|
253
|
+
render?: UnionFaasItemRender<T>;
|
|
254
|
+
}
|
|
255
|
+
type ExtendDescriptionItemProps = BaseItemProps;
|
|
256
|
+
interface DescriptionItemProps<T = any> extends FaasItemProps {
|
|
257
|
+
children?: UnionFaasItemElement<T>;
|
|
258
|
+
descriptionChildren?: UnionFaasItemElement<T>;
|
|
259
|
+
render?: UnionFaasItemRender<T>;
|
|
260
|
+
descriptionRender?: UnionFaasItemRender<T>;
|
|
261
|
+
if?: (values: Record<string, any>) => boolean;
|
|
262
|
+
object?: DescriptionItemProps<T>[];
|
|
263
|
+
}
|
|
264
|
+
interface DescriptionProps<T = any, ExtendItemProps = any> extends DescriptionsProps {
|
|
265
|
+
renderTitle?: ((values: T) => ReactNode);
|
|
266
|
+
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
267
|
+
extendTypes?: {
|
|
268
|
+
[key: string]: ExtendDescriptionTypeProps;
|
|
269
|
+
};
|
|
270
|
+
dataSource?: T;
|
|
271
|
+
faasData?: FaasDataWrapperProps<T>;
|
|
272
|
+
}
|
|
273
|
+
interface DescriptionItemContentProps<T = any> {
|
|
274
|
+
item: DescriptionItemProps;
|
|
275
|
+
value: T;
|
|
276
|
+
values?: any;
|
|
277
|
+
extendTypes?: {
|
|
278
|
+
[key: string]: ExtendDescriptionTypeProps;
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Description component.
|
|
283
|
+
*/
|
|
284
|
+
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
285
|
+
|
|
286
|
+
interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T>, 'title' | 'children' | 'render'> {
|
|
287
|
+
optionsType?: 'auto';
|
|
288
|
+
children?: UnionFaasItemElement<T>;
|
|
289
|
+
tableChildren?: UnionFaasItemElement<T>;
|
|
290
|
+
render?: UnionFaasItemRender<T>;
|
|
291
|
+
tableRender?: UnionFaasItemRender<T>;
|
|
292
|
+
object?: TableItemProps<T>[];
|
|
293
|
+
}
|
|
294
|
+
type ExtendTableTypeProps<T = any> = {
|
|
295
|
+
children?: JSX.Element;
|
|
296
|
+
render?: UnionFaasItemRender<T>;
|
|
297
|
+
};
|
|
298
|
+
type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
299
|
+
type TableProps<T = any, ExtendTypes = any> = {
|
|
300
|
+
items: (TableItemProps | (ExtendTypes & ExtendTableItemProps))[];
|
|
301
|
+
extendTypes?: {
|
|
302
|
+
[key: string]: ExtendTableTypeProps;
|
|
303
|
+
};
|
|
304
|
+
faasData?: FaasDataWrapperProps<T>;
|
|
305
|
+
onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<T> | SorterResult<T>[], extra: TableCurrentDataSource<T>) => {
|
|
306
|
+
pagination: TablePaginationConfig;
|
|
307
|
+
filters: Record<string, FilterValue | null>;
|
|
308
|
+
sorter: SorterResult<T> | SorterResult<T>[];
|
|
309
|
+
extra: TableCurrentDataSource<T>;
|
|
310
|
+
};
|
|
311
|
+
} & TableProps$1<T>;
|
|
312
|
+
/**
|
|
313
|
+
* Table component with Ant Design & FaasJS
|
|
314
|
+
*
|
|
315
|
+
* @ref https://ant.design/components/table/
|
|
316
|
+
*/
|
|
317
|
+
declare function Table<T extends Record<string, any>, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
318
|
+
|
|
84
319
|
type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean' | 'date' | 'time' | 'object' | 'object[]';
|
|
85
320
|
/** FaasItemType's value type */
|
|
86
321
|
type FaasItemTypeValue = {
|
|
@@ -98,202 +333,106 @@ type BaseOption = string | number | {
|
|
|
98
333
|
label: string;
|
|
99
334
|
value?: string | number;
|
|
100
335
|
};
|
|
101
|
-
|
|
336
|
+
interface BaseItemProps {
|
|
102
337
|
id: string;
|
|
103
338
|
title?: string;
|
|
104
339
|
options?: BaseOption[];
|
|
105
|
-
}
|
|
106
|
-
|
|
340
|
+
}
|
|
341
|
+
interface FaasItemProps extends BaseItemProps {
|
|
107
342
|
/**
|
|
108
|
-
* Support string, string[], number, number[], boolean
|
|
343
|
+
* Support string, string[], number, number[], boolean, date, time, object, object[]
|
|
109
344
|
* @default 'string'
|
|
110
345
|
*/
|
|
111
346
|
type?: FaasItemType;
|
|
112
|
-
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* convert options to { label, value }[]
|
|
350
|
+
*/
|
|
113
351
|
declare function transferOptions(options: BaseOption[]): {
|
|
114
352
|
label: string;
|
|
115
353
|
value?: string | number;
|
|
116
354
|
}[];
|
|
117
355
|
declare function transferValue(type: FaasItemType, value: any): any;
|
|
118
|
-
|
|
119
|
-
type
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
type DescriptionItemProps<T = any> = {
|
|
125
|
-
children?: JSX.Element;
|
|
126
|
-
render?: (value: T, values: any) => ReactNode | JSX.Element;
|
|
127
|
-
if?: (values: Record<string, any>) => boolean;
|
|
128
|
-
} & FaasItemProps & {
|
|
129
|
-
object?: DescriptionItemProps[];
|
|
130
|
-
};
|
|
131
|
-
type DescriptionProps<T = any, ExtendItemProps = any> = {
|
|
132
|
-
renderTitle?: ((values: T) => ReactNode | JSX.Element);
|
|
133
|
-
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
134
|
-
extendTypes?: {
|
|
135
|
-
[key: string]: ExtendDescriptionTypeProps;
|
|
136
|
-
};
|
|
137
|
-
dataSource?: T;
|
|
138
|
-
faasData?: FaasDataWrapperProps<T>;
|
|
139
|
-
} & DescriptionsProps;
|
|
140
|
-
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
141
|
-
|
|
142
|
-
type DrawerProps = DrawerProps$1 & {
|
|
143
|
-
children?: JSX.Element | JSX.Element[];
|
|
144
|
-
};
|
|
145
|
-
type setDrawerProps = (changes: Partial<DrawerProps>) => void;
|
|
146
|
-
/**
|
|
147
|
-
* Hook style drawer.
|
|
148
|
-
* @param init initial props
|
|
149
|
-
*
|
|
150
|
-
* ```ts
|
|
151
|
-
* function Example() {
|
|
152
|
-
* const { drawer, setDrawerProps } = useDrawer()
|
|
153
|
-
*
|
|
154
|
-
* return <>
|
|
155
|
-
* <Button onClick={ () => setDrawerProps(prev => ({ open: !prev.open})) }>
|
|
156
|
-
* Toggle
|
|
157
|
-
* </Button>
|
|
158
|
-
* {drawer}
|
|
159
|
-
* </>
|
|
160
|
-
* }
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
declare function useDrawer(init?: DrawerProps): {
|
|
164
|
-
drawer: JSX.Element;
|
|
165
|
-
drawerProps: DrawerProps;
|
|
166
|
-
setDrawerProps(changes: Partial<DrawerProps>): void;
|
|
356
|
+
type UnionScene = 'form' | 'description' | 'table';
|
|
357
|
+
type UnionFaasItemInjection<Value = any, Values = any> = {
|
|
358
|
+
scene?: UnionScene;
|
|
359
|
+
value?: Value;
|
|
360
|
+
values?: Values;
|
|
361
|
+
index?: number;
|
|
167
362
|
};
|
|
363
|
+
type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Values, index: number, scene: UnionScene) => JSX.Element | null;
|
|
364
|
+
type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasItemInjection<Value, Values>> | null;
|
|
365
|
+
interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, DescriptionItemProps, TableItemProps {
|
|
366
|
+
children?: UnionFaasItemElement<UnionFaasItemProps<Value, Values>> | null;
|
|
367
|
+
render?: UnionFaasItemRender;
|
|
368
|
+
object?: UnionFaasItemProps<Value, Values>[];
|
|
369
|
+
}
|
|
168
370
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
};
|
|
173
|
-
type StringListProps = {
|
|
174
|
-
type: 'string[]';
|
|
175
|
-
input?: InputProps;
|
|
176
|
-
maxCount?: number;
|
|
177
|
-
};
|
|
178
|
-
type NumberProps = {
|
|
179
|
-
type: 'number';
|
|
180
|
-
input?: InputNumberProps;
|
|
181
|
-
};
|
|
182
|
-
type NumberListProps = {
|
|
183
|
-
type: 'number[]';
|
|
184
|
-
input?: InputNumberProps;
|
|
185
|
-
maxCount?: number;
|
|
186
|
-
};
|
|
187
|
-
type BooleanProps = {
|
|
188
|
-
type: 'boolean';
|
|
189
|
-
input?: SwitchProps;
|
|
190
|
-
};
|
|
191
|
-
type DateProps = {
|
|
192
|
-
type: 'date';
|
|
193
|
-
input?: DatePickerProps;
|
|
194
|
-
};
|
|
195
|
-
type TimeProps = {
|
|
196
|
-
type: 'time';
|
|
197
|
-
input?: TimePickerProps;
|
|
198
|
-
};
|
|
199
|
-
type ObjectProps = {
|
|
200
|
-
type: 'object';
|
|
201
|
-
object: FormItemProps[];
|
|
202
|
-
};
|
|
203
|
-
type ObjectListProps = {
|
|
204
|
-
type: 'object[]';
|
|
205
|
-
object: (FormItemProps & {
|
|
206
|
-
/** default is 6 */
|
|
207
|
-
col?: number;
|
|
208
|
-
})[];
|
|
209
|
-
maxCount?: number;
|
|
210
|
-
};
|
|
211
|
-
type OptionsProps = {
|
|
212
|
-
options?: BaseOption[];
|
|
213
|
-
type?: 'string' | 'string[]' | 'number' | 'number[]';
|
|
214
|
-
input?: SelectProps<any>;
|
|
215
|
-
};
|
|
216
|
-
type FormItemInputProps = (StringProps | StringListProps | NumberProps | NumberListProps | BooleanProps | OptionsProps | DateProps | TimeProps | ObjectProps | ObjectListProps) & {
|
|
217
|
-
disabled?: boolean;
|
|
218
|
-
required?: boolean;
|
|
219
|
-
};
|
|
220
|
-
type ExtendFormTypeProps = {
|
|
371
|
+
interface ErrorBoundaryProps {
|
|
372
|
+
message?: ReactNode;
|
|
373
|
+
description?: ReactNode;
|
|
221
374
|
children?: ReactNode;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
235
|
-
/** trigger when any item's value changed */
|
|
236
|
-
if?: (values: Record<string, any>) => boolean;
|
|
237
|
-
} & FormItemInputProps & FaasItemProps & Omit<FormItemProps$1<T>, 'children'>;
|
|
238
|
-
/**
|
|
239
|
-
* FormItem, can be used without Form.
|
|
240
|
-
*
|
|
241
|
-
* ```ts
|
|
242
|
-
* // use inline type
|
|
243
|
-
* <FormItem type='string' id='name' />
|
|
244
|
-
*
|
|
245
|
-
* // use custom type
|
|
246
|
-
* <FormItem id='password'>
|
|
247
|
-
* <Input.Password />
|
|
248
|
-
* </>
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
375
|
+
onError?: (error: Error | null, info: any) => ReactNode;
|
|
376
|
+
}
|
|
377
|
+
declare class ErrorBoundary extends Component<ErrorBoundaryProps, {
|
|
378
|
+
error?: Error | null;
|
|
379
|
+
info?: {
|
|
380
|
+
componentStack?: string;
|
|
381
|
+
};
|
|
382
|
+
}> {
|
|
383
|
+
constructor(props: ErrorBoundaryProps);
|
|
384
|
+
componentDidCatch(error: Error | null, info: any): void;
|
|
385
|
+
render(): string | number | boolean | react.ReactFragment | JSX.Element;
|
|
386
|
+
}
|
|
252
387
|
|
|
253
|
-
type
|
|
388
|
+
type FormSubmitProps = {
|
|
389
|
+
/** Default: Submit */
|
|
390
|
+
text?: string;
|
|
391
|
+
/**
|
|
392
|
+
* Submit to FaasJS server.
|
|
393
|
+
*
|
|
394
|
+
* If use onFinish, you should call submit manually.
|
|
395
|
+
* ```ts
|
|
396
|
+
* {
|
|
397
|
+
* submit: {
|
|
398
|
+
* to: {
|
|
399
|
+
* action: 'action_name'
|
|
400
|
+
* }
|
|
401
|
+
* },
|
|
402
|
+
* onFinish: (values, submit) => {
|
|
403
|
+
* // do something before submit
|
|
404
|
+
*
|
|
405
|
+
* // submit
|
|
406
|
+
* await submit({
|
|
407
|
+
* ...values,
|
|
408
|
+
* extraProps: 'some extra props'
|
|
409
|
+
* })
|
|
410
|
+
*
|
|
411
|
+
* // do something after submit
|
|
412
|
+
* }
|
|
413
|
+
* }
|
|
414
|
+
* ```
|
|
415
|
+
*/
|
|
416
|
+
to?: {
|
|
417
|
+
action: string;
|
|
418
|
+
/** params will overwrite form values before submit */
|
|
419
|
+
params?: Record<string, any>;
|
|
420
|
+
then?: (result: any) => void;
|
|
421
|
+
catch?: (error: any) => void;
|
|
422
|
+
finally?: () => void;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps = any> extends Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> {
|
|
254
426
|
items?: (FormItemProps | ExtendItemProps | JSX.Element)[];
|
|
255
427
|
/** Default: { text: 'Submit' }, set false to disable it */
|
|
256
|
-
submit?: false |
|
|
257
|
-
/** Default: Submit */
|
|
258
|
-
text?: string;
|
|
259
|
-
/**
|
|
260
|
-
* Submit to FaasJS server.
|
|
261
|
-
*
|
|
262
|
-
* If use onFinish, you should call submit manually.
|
|
263
|
-
* ```ts
|
|
264
|
-
* {
|
|
265
|
-
* submit: {
|
|
266
|
-
* to: {
|
|
267
|
-
* action: 'action_name'
|
|
268
|
-
* }
|
|
269
|
-
* },
|
|
270
|
-
* onFinish: (values, submit) => {
|
|
271
|
-
* // do something before submit
|
|
272
|
-
*
|
|
273
|
-
* // submit
|
|
274
|
-
* await submit({
|
|
275
|
-
* ...values,
|
|
276
|
-
* extraProps: 'some extra props'
|
|
277
|
-
* })
|
|
278
|
-
*
|
|
279
|
-
* // do something after submit
|
|
280
|
-
* }
|
|
281
|
-
* }
|
|
282
|
-
* ```
|
|
283
|
-
*/
|
|
284
|
-
to?: {
|
|
285
|
-
action: string;
|
|
286
|
-
/** params will overwrite form values before submit */
|
|
287
|
-
params?: Record<string, any>;
|
|
288
|
-
};
|
|
289
|
-
};
|
|
428
|
+
submit?: false | FormSubmitProps;
|
|
290
429
|
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
|
291
430
|
beforeItems?: JSX.Element | JSX.Element[];
|
|
292
431
|
footer?: JSX.Element | JSX.Element[];
|
|
293
432
|
extendTypes?: ExtendTypes;
|
|
294
433
|
children?: ReactNode;
|
|
295
434
|
initialValues?: Values;
|
|
296
|
-
}
|
|
435
|
+
}
|
|
297
436
|
/**
|
|
298
437
|
* Form component with Ant Design & FaasJS
|
|
299
438
|
*
|
|
@@ -302,64 +441,49 @@ type FormProps<Values extends Record<string, any> = any, ExtendItemProps = any>
|
|
|
302
441
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
303
442
|
declare namespace Form {
|
|
304
443
|
var useForm: typeof antd_es_form_Form.useForm;
|
|
444
|
+
var useFormInstance: typeof antd_es_form_hooks_useFormInstance.default;
|
|
445
|
+
var useWatch: typeof rc_field_form_es_useWatch.default;
|
|
446
|
+
var Item: typeof FormItem;
|
|
447
|
+
var List: react.FC<antd_es_form.FormListProps>;
|
|
448
|
+
var ErrorList: typeof antd_es_form_ErrorList.default;
|
|
449
|
+
var Provider: react.FC<antd_es_form_context.FormProviderProps>;
|
|
305
450
|
}
|
|
306
451
|
|
|
307
|
-
|
|
452
|
+
interface LinkProps {
|
|
308
453
|
href: string;
|
|
309
454
|
target?: string;
|
|
310
455
|
text?: string | number;
|
|
311
456
|
children?: ReactNode;
|
|
312
457
|
style?: CSSProperties;
|
|
313
458
|
button?: ButtonProps;
|
|
314
|
-
|
|
459
|
+
block?: boolean;
|
|
460
|
+
}
|
|
315
461
|
/**
|
|
462
|
+
* Link component with button.
|
|
463
|
+
*
|
|
316
464
|
* ```ts
|
|
317
465
|
* // pure link
|
|
318
466
|
* <Link href="/">Home</Link>
|
|
319
467
|
*
|
|
320
468
|
* // link with button
|
|
321
|
-
* <Link href="/" button={{type:'primary'}}>Home</Link>
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
declare function Link({ href, target, text, children, style, button, }: LinkProps): JSX.Element;
|
|
325
|
-
|
|
326
|
-
type ModalProps = ModalProps$1 & {
|
|
327
|
-
children?: JSX.Element | JSX.Element[] | string;
|
|
328
|
-
};
|
|
329
|
-
type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
330
|
-
/**
|
|
331
|
-
* Hook style modal.
|
|
332
|
-
* @param init initial props
|
|
333
|
-
*
|
|
334
|
-
* ```ts
|
|
335
|
-
* function Example() {
|
|
336
|
-
* const { modal, setModalProps } = useModal()
|
|
337
|
-
*
|
|
338
|
-
* return <>
|
|
339
|
-
* <Button onClick={() => setModalProps({ open: true })}>Open Modal</Button>
|
|
340
|
-
* {modal}</>
|
|
341
|
-
* }
|
|
469
|
+
* <Link href="/" button={{ type:'primary' }}>Home</Link>
|
|
342
470
|
* ```
|
|
343
471
|
*/
|
|
344
|
-
declare function
|
|
345
|
-
modal: JSX.Element;
|
|
346
|
-
modalProps: ModalProps;
|
|
347
|
-
setModalProps(changes: Partial<ModalProps>): void;
|
|
348
|
-
};
|
|
472
|
+
declare function Link(props: LinkProps): JSX.Element;
|
|
349
473
|
|
|
350
474
|
declare function PageNotFound(): JSX.Element;
|
|
351
|
-
|
|
475
|
+
interface RoutesProps {
|
|
352
476
|
routes: (RouteProps & {
|
|
353
477
|
page?: LazyExoticComponent<ComponentType<any>>;
|
|
354
478
|
})[];
|
|
355
479
|
fallback?: JSX.Element;
|
|
356
480
|
notFound?: JSX.Element;
|
|
357
|
-
}
|
|
481
|
+
}
|
|
358
482
|
/**
|
|
359
483
|
* Routes with lazy loading and 404 page.
|
|
360
484
|
*
|
|
361
485
|
* ```tsx
|
|
362
|
-
* import { lazy } from '
|
|
486
|
+
* import { Routes, lazy } from '@faasjs/ant-design'
|
|
363
487
|
* import { BrowserRouter } from 'react-router-dom'
|
|
364
488
|
*
|
|
365
489
|
* export function App () {
|
|
@@ -376,38 +500,7 @@ type RoutesProps = {
|
|
|
376
500
|
*/
|
|
377
501
|
declare function Routes(props: RoutesProps): JSX.Element;
|
|
378
502
|
|
|
379
|
-
|
|
380
|
-
optionsType?: 'auto';
|
|
381
|
-
/** @deprecated use render */
|
|
382
|
-
children?: JSX.Element | null;
|
|
383
|
-
object?: TableItemProps[];
|
|
384
|
-
} & FaasItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
385
|
-
type ExtendTableTypeProps = {
|
|
386
|
-
children?: JSX.Element | null;
|
|
387
|
-
render?: (value: any, values: any, index: number) => JSX.Element | string | number | boolean | null;
|
|
388
|
-
};
|
|
389
|
-
type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
390
|
-
type TableProps<T = any, ExtendTypes = any> = {
|
|
391
|
-
items: (TableItemProps | (ExtendTypes & ExtendTableItemProps))[];
|
|
392
|
-
extendTypes?: {
|
|
393
|
-
[key: string]: ExtendTableTypeProps;
|
|
394
|
-
};
|
|
395
|
-
faasData?: FaasDataWrapperProps<T>;
|
|
396
|
-
onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<T> | SorterResult<T>[], extra: TableCurrentDataSource<T>) => {
|
|
397
|
-
pagination: TablePaginationConfig;
|
|
398
|
-
filters: Record<string, FilterValue | null>;
|
|
399
|
-
sorter: SorterResult<T> | SorterResult<T>[];
|
|
400
|
-
extra: TableCurrentDataSource<T>;
|
|
401
|
-
};
|
|
402
|
-
} & TableProps$1<T>;
|
|
403
|
-
/**
|
|
404
|
-
* Table component with Ant Design & FaasJS
|
|
405
|
-
*
|
|
406
|
-
* @ref https://ant.design/components/table/
|
|
407
|
-
*/
|
|
408
|
-
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
409
|
-
|
|
410
|
-
type TitleProps = {
|
|
503
|
+
interface TitleProps {
|
|
411
504
|
title: string | string[];
|
|
412
505
|
/** ` - ` as default */
|
|
413
506
|
separator?: string;
|
|
@@ -421,7 +514,7 @@ type TitleProps = {
|
|
|
421
514
|
plain?: boolean;
|
|
422
515
|
/** return children */
|
|
423
516
|
children?: JSX.Element;
|
|
424
|
-
}
|
|
517
|
+
}
|
|
425
518
|
/**
|
|
426
519
|
* Title is used to change the title of the page.
|
|
427
520
|
* Return null by default.
|
|
@@ -441,4 +534,4 @@ type TitleProps = {
|
|
|
441
534
|
*/
|
|
442
535
|
declare function Title(props: TitleProps): JSX.Element;
|
|
443
536
|
|
|
444
|
-
export { BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Link, LinkProps, ModalProps, PageNotFound, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, transferValue, useConfigContext, useDrawer, useModal };
|
|
537
|
+
export { App, AppProps, BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemContentProps, DescriptionItemProps, DescriptionProps, DrawerProps, ErrorBoundary, ErrorBoundaryProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasDataInjection, FaasDataWrapper, FaasDataWrapperProps, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, FormSubmitProps, Link, LinkProps, Loading, LoadingProps, ModalProps, PageNotFound, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, UnionFaasItemElement, UnionFaasItemInjection, UnionFaasItemProps, UnionFaasItemRender, UnionScene, setDrawerProps, setModalProps, transferOptions, transferValue, useApp, useAppProps, useConfigContext, useDrawer, useModal };
|