@faasjs/ant-design 0.0.3-beta.3 → 0.0.3-beta.30
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 +163 -297
- package/dist/index.d.ts +135 -134
- package/dist/index.js +340 -218
- package/dist/index.mjs +365 -240
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { CSSProperties, ReactNode, LazyExoticComponent, ComponentType } from 'react';
|
|
3
|
-
import { ConfigProviderProps as ConfigProviderProps$1 } from 'antd/es/config-provider';
|
|
4
3
|
import { Dayjs } from 'dayjs';
|
|
5
|
-
import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1,
|
|
4
|
+
import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, DatePickerProps, TimePickerProps, FormInstance, FormProps as FormProps$1, ButtonProps, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1 } from 'antd';
|
|
6
5
|
export { Drawer, Modal } from 'antd';
|
|
7
6
|
import { FaasDataWrapperProps } from '@faasjs/react';
|
|
7
|
+
export { FaasDataInjection, FaasDataWrapperProps } from '@faasjs/react';
|
|
8
|
+
import * as antd_es_form_context from 'antd/es/form/context';
|
|
9
|
+
import * as antd_es_form_ErrorList from 'antd/es/form/ErrorList';
|
|
10
|
+
import * as antd_es_form from 'antd/es/form';
|
|
11
|
+
import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
|
|
12
|
+
import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
|
|
8
13
|
import * as antd_es_form_Form from 'antd/es/form/Form';
|
|
9
14
|
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
10
15
|
import { RouteProps } from 'react-router-dom';
|
|
11
16
|
import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
interface BlankProps {
|
|
14
19
|
value?: any;
|
|
15
20
|
text?: string;
|
|
16
|
-
}
|
|
21
|
+
}
|
|
17
22
|
/**
|
|
23
|
+
* Blank component.
|
|
24
|
+
*
|
|
18
25
|
* If value is undefined or null, return text, otherwise return value.
|
|
19
26
|
*
|
|
20
27
|
* @param options {object}
|
|
@@ -28,8 +35,7 @@ type BlankProps = {
|
|
|
28
35
|
*/
|
|
29
36
|
declare function Blank(options?: BlankProps): JSX.Element;
|
|
30
37
|
|
|
31
|
-
|
|
32
|
-
antd?: ConfigProviderProps$1;
|
|
38
|
+
interface ConfigProviderProps {
|
|
33
39
|
lang?: string;
|
|
34
40
|
common?: {
|
|
35
41
|
blank?: string;
|
|
@@ -60,7 +66,7 @@ type ConfigProviderProps = {
|
|
|
60
66
|
target?: string;
|
|
61
67
|
style?: CSSProperties;
|
|
62
68
|
};
|
|
63
|
-
}
|
|
69
|
+
}
|
|
64
70
|
declare const ConfigContext: react.Context<ConfigProviderProps>;
|
|
65
71
|
/**
|
|
66
72
|
* Config for @faasjs/ant-design components.
|
|
@@ -98,53 +104,69 @@ type BaseOption = string | number | {
|
|
|
98
104
|
label: string;
|
|
99
105
|
value?: string | number;
|
|
100
106
|
};
|
|
101
|
-
|
|
107
|
+
interface BaseItemProps {
|
|
102
108
|
id: string;
|
|
103
109
|
title?: string;
|
|
104
110
|
options?: BaseOption[];
|
|
105
|
-
}
|
|
106
|
-
|
|
111
|
+
}
|
|
112
|
+
interface FaasItemProps extends BaseItemProps {
|
|
107
113
|
/**
|
|
108
|
-
* Support string, string[], number, number[], boolean
|
|
114
|
+
* Support string, string[], number, number[], boolean, date, time, object, object[]
|
|
109
115
|
* @default 'string'
|
|
110
116
|
*/
|
|
111
117
|
type?: FaasItemType;
|
|
112
|
-
}
|
|
118
|
+
}
|
|
113
119
|
declare function transferOptions(options: BaseOption[]): {
|
|
114
120
|
label: string;
|
|
115
121
|
value?: string | number;
|
|
116
122
|
}[];
|
|
117
123
|
declare function transferValue(type: FaasItemType, value: any): any;
|
|
118
124
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
/**
|
|
126
|
+
* FaasDataWrapper component with Loading and ErrorBoundary
|
|
127
|
+
*/
|
|
128
|
+
declare function FaasDataWrapper<T = any>(props: FaasDataWrapperProps<T>): JSX.Element;
|
|
129
|
+
|
|
130
|
+
interface ExtendDescriptionTypeProps {
|
|
131
|
+
children?: JSX.Element;
|
|
132
|
+
render?: (value: any, values: any) => JSX.Element;
|
|
133
|
+
}
|
|
123
134
|
type ExtendDescriptionItemProps = BaseItemProps;
|
|
124
|
-
|
|
135
|
+
interface DescriptionItemProps<T = any> extends FaasItemProps {
|
|
125
136
|
children?: JSX.Element;
|
|
126
|
-
render?: (value: T, values: any) =>
|
|
137
|
+
render?: (value: T, values: any) => JSX.Element;
|
|
127
138
|
if?: (values: Record<string, any>) => boolean;
|
|
128
|
-
} & FaasItemProps & {
|
|
129
139
|
object?: DescriptionItemProps[];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
renderTitle?: ((values: T) => ReactNode
|
|
140
|
+
}
|
|
141
|
+
interface DescriptionProps<T = any, ExtendItemProps = any> extends DescriptionsProps {
|
|
142
|
+
renderTitle?: ((values: T) => ReactNode);
|
|
133
143
|
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
134
144
|
extendTypes?: {
|
|
135
145
|
[key: string]: ExtendDescriptionTypeProps;
|
|
136
146
|
};
|
|
137
147
|
dataSource?: T;
|
|
138
148
|
faasData?: FaasDataWrapperProps<T>;
|
|
139
|
-
}
|
|
149
|
+
}
|
|
150
|
+
interface DescriptionItemContentProps<T = any> {
|
|
151
|
+
item: DescriptionItemProps;
|
|
152
|
+
value: T;
|
|
153
|
+
values?: any;
|
|
154
|
+
extendTypes?: {
|
|
155
|
+
[key: string]: ExtendDescriptionTypeProps;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Description component.
|
|
160
|
+
*/
|
|
140
161
|
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
141
162
|
|
|
142
|
-
|
|
163
|
+
interface DrawerProps extends DrawerProps$1 {
|
|
143
164
|
children?: JSX.Element | JSX.Element[];
|
|
144
|
-
}
|
|
165
|
+
}
|
|
145
166
|
type setDrawerProps = (changes: Partial<DrawerProps>) => void;
|
|
146
167
|
/**
|
|
147
168
|
* Hook style drawer.
|
|
169
|
+
*
|
|
148
170
|
* @param init initial props
|
|
149
171
|
*
|
|
150
172
|
* ```ts
|
|
@@ -166,57 +188,6 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
166
188
|
setDrawerProps(changes: Partial<DrawerProps>): void;
|
|
167
189
|
};
|
|
168
190
|
|
|
169
|
-
type StringProps = {
|
|
170
|
-
type?: 'string';
|
|
171
|
-
input?: InputProps;
|
|
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
191
|
type ExtendFormTypeProps = {
|
|
221
192
|
children?: ReactNode;
|
|
222
193
|
};
|
|
@@ -224,9 +195,15 @@ type ExtendTypes = {
|
|
|
224
195
|
[type: string]: ExtendFormTypeProps;
|
|
225
196
|
};
|
|
226
197
|
type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
198
|
+
interface FormItemProps<T = any> extends FaasItemProps, Omit<FormItemProps$1<T>, 'id' | 'children'> {
|
|
199
|
+
input?: InputProps | InputNumberProps | SwitchProps | SelectProps<T> | DatePickerProps | TimePickerProps;
|
|
200
|
+
maxCount?: number;
|
|
201
|
+
object?: FormItemProps[];
|
|
202
|
+
disabled?: boolean;
|
|
203
|
+
required?: boolean;
|
|
204
|
+
col?: number;
|
|
205
|
+
children?: JSX.Element;
|
|
206
|
+
render?: () => JSX.Element;
|
|
230
207
|
rules?: RuleObject[];
|
|
231
208
|
label?: string | false;
|
|
232
209
|
extendTypes?: ExtendTypes;
|
|
@@ -234,66 +211,75 @@ type FormItemProps<T = any> = {
|
|
|
234
211
|
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
235
212
|
/** trigger when any item's value changed */
|
|
236
213
|
if?: (values: Record<string, any>) => boolean;
|
|
237
|
-
}
|
|
214
|
+
}
|
|
238
215
|
/**
|
|
239
216
|
* FormItem, can be used without Form.
|
|
240
217
|
*
|
|
241
218
|
* ```ts
|
|
242
219
|
* // use inline type
|
|
243
|
-
* <FormItem
|
|
220
|
+
* <FormItem type='string' id='name' />
|
|
244
221
|
*
|
|
245
222
|
* // use custom type
|
|
246
|
-
* <FormItem
|
|
223
|
+
* <FormItem id='password'>
|
|
247
224
|
* <Input.Password />
|
|
248
225
|
* </>
|
|
249
226
|
* ```
|
|
250
227
|
*/
|
|
251
228
|
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
229
|
+
declare namespace FormItem {
|
|
230
|
+
var useStatus: () => {
|
|
231
|
+
status?: "" | "error" | "warning" | "success" | "validating";
|
|
232
|
+
};
|
|
233
|
+
}
|
|
252
234
|
|
|
253
|
-
type
|
|
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
|
-
};
|
|
235
|
+
type FormSubmitProps = {
|
|
236
|
+
/** Default: Submit */
|
|
237
|
+
text?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Submit to FaasJS server.
|
|
240
|
+
*
|
|
241
|
+
* If use onFinish, you should call submit manually.
|
|
242
|
+
* ```ts
|
|
243
|
+
* {
|
|
244
|
+
* submit: {
|
|
245
|
+
* to: {
|
|
246
|
+
* action: 'action_name'
|
|
247
|
+
* }
|
|
248
|
+
* },
|
|
249
|
+
* onFinish: (values, submit) => {
|
|
250
|
+
* // do something before submit
|
|
251
|
+
*
|
|
252
|
+
* // submit
|
|
253
|
+
* await submit({
|
|
254
|
+
* ...values,
|
|
255
|
+
* extraProps: 'some extra props'
|
|
256
|
+
* })
|
|
257
|
+
*
|
|
258
|
+
* // do something after submit
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
to?: {
|
|
264
|
+
action: string;
|
|
265
|
+
/** params will overwrite form values before submit */
|
|
266
|
+
params?: Record<string, any>;
|
|
267
|
+
then?: (result: any) => void;
|
|
268
|
+
catch?: (error: any) => void;
|
|
269
|
+
finally?: () => void;
|
|
289
270
|
};
|
|
271
|
+
};
|
|
272
|
+
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps = any> extends Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> {
|
|
273
|
+
items?: (FormItemProps | ExtendItemProps | JSX.Element)[];
|
|
274
|
+
/** Default: { text: 'Submit' }, set false to disable it */
|
|
275
|
+
submit?: false | FormSubmitProps;
|
|
290
276
|
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
|
291
277
|
beforeItems?: JSX.Element | JSX.Element[];
|
|
292
278
|
footer?: JSX.Element | JSX.Element[];
|
|
293
279
|
extendTypes?: ExtendTypes;
|
|
294
280
|
children?: ReactNode;
|
|
295
281
|
initialValues?: Values;
|
|
296
|
-
}
|
|
282
|
+
}
|
|
297
283
|
/**
|
|
298
284
|
* Form component with Ant Design & FaasJS
|
|
299
285
|
*
|
|
@@ -302,30 +288,46 @@ type FormProps<Values extends Record<string, any> = any, ExtendItemProps = any>
|
|
|
302
288
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
303
289
|
declare namespace Form {
|
|
304
290
|
var useForm: typeof antd_es_form_Form.useForm;
|
|
291
|
+
var useFormInstance: typeof antd_es_form_hooks_useFormInstance.default;
|
|
292
|
+
var useWatch: typeof rc_field_form_es_useWatch.default;
|
|
293
|
+
var Item: typeof FormItem;
|
|
294
|
+
var List: react.FC<antd_es_form.FormListProps>;
|
|
295
|
+
var ErrorList: typeof antd_es_form_ErrorList.default;
|
|
296
|
+
var Provider: react.FC<antd_es_form_context.FormProviderProps>;
|
|
305
297
|
}
|
|
306
298
|
|
|
307
|
-
|
|
299
|
+
interface LinkProps {
|
|
308
300
|
href: string;
|
|
309
301
|
target?: string;
|
|
310
302
|
text?: string | number;
|
|
311
303
|
children?: ReactNode;
|
|
312
304
|
style?: CSSProperties;
|
|
313
305
|
button?: ButtonProps;
|
|
314
|
-
}
|
|
306
|
+
}
|
|
315
307
|
/**
|
|
308
|
+
* Link component with button.
|
|
309
|
+
*
|
|
316
310
|
* ```ts
|
|
317
311
|
* // pure link
|
|
318
312
|
* <Link href="/">Home</Link>
|
|
319
313
|
*
|
|
320
314
|
* // link with button
|
|
321
|
-
* <Link href="/" button={{type:'primary'}}>Home</Link>
|
|
315
|
+
* <Link href="/" button={{ type:'primary' }}>Home</Link>
|
|
322
316
|
* ```
|
|
323
317
|
*/
|
|
324
318
|
declare function Link({ href, target, text, children, style, button, }: LinkProps): JSX.Element;
|
|
325
319
|
|
|
326
|
-
|
|
320
|
+
/**
|
|
321
|
+
* Loading component based on Spin
|
|
322
|
+
*/
|
|
323
|
+
declare function Loading(props: {
|
|
324
|
+
style?: React.CSSProperties;
|
|
325
|
+
size?: 'small' | 'default' | 'large';
|
|
326
|
+
}): JSX.Element;
|
|
327
|
+
|
|
328
|
+
interface ModalProps extends ModalProps$1 {
|
|
327
329
|
children?: JSX.Element | JSX.Element[] | string;
|
|
328
|
-
}
|
|
330
|
+
}
|
|
329
331
|
type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
330
332
|
/**
|
|
331
333
|
* Hook style modal.
|
|
@@ -348,13 +350,13 @@ declare function useModal(init?: ModalProps): {
|
|
|
348
350
|
};
|
|
349
351
|
|
|
350
352
|
declare function PageNotFound(): JSX.Element;
|
|
351
|
-
|
|
353
|
+
interface RoutesProps {
|
|
352
354
|
routes: (RouteProps & {
|
|
353
355
|
page?: LazyExoticComponent<ComponentType<any>>;
|
|
354
356
|
})[];
|
|
355
357
|
fallback?: JSX.Element;
|
|
356
358
|
notFound?: JSX.Element;
|
|
357
|
-
}
|
|
359
|
+
}
|
|
358
360
|
/**
|
|
359
361
|
* Routes with lazy loading and 404 page.
|
|
360
362
|
*
|
|
@@ -376,14 +378,13 @@ type RoutesProps = {
|
|
|
376
378
|
*/
|
|
377
379
|
declare function Routes(props: RoutesProps): JSX.Element;
|
|
378
380
|
|
|
379
|
-
|
|
381
|
+
interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T>, 'title' | 'children'> {
|
|
380
382
|
optionsType?: 'auto';
|
|
381
|
-
|
|
382
|
-
children?: JSX.Element | null;
|
|
383
|
+
children?: JSX.Element;
|
|
383
384
|
object?: TableItemProps[];
|
|
384
|
-
}
|
|
385
|
+
}
|
|
385
386
|
type ExtendTableTypeProps = {
|
|
386
|
-
children?: JSX.Element
|
|
387
|
+
children?: JSX.Element;
|
|
387
388
|
render?: (value: any, values: any, index: number) => JSX.Element | string | number | boolean | null;
|
|
388
389
|
};
|
|
389
390
|
type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
@@ -407,7 +408,7 @@ type TableProps<T = any, ExtendTypes = any> = {
|
|
|
407
408
|
*/
|
|
408
409
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
409
410
|
|
|
410
|
-
|
|
411
|
+
interface TitleProps {
|
|
411
412
|
title: string | string[];
|
|
412
413
|
/** ` - ` as default */
|
|
413
414
|
separator?: string;
|
|
@@ -421,7 +422,7 @@ type TitleProps = {
|
|
|
421
422
|
plain?: boolean;
|
|
422
423
|
/** return children */
|
|
423
424
|
children?: JSX.Element;
|
|
424
|
-
}
|
|
425
|
+
}
|
|
425
426
|
/**
|
|
426
427
|
* Title is used to change the title of the page.
|
|
427
428
|
* Return null by default.
|
|
@@ -441,4 +442,4 @@ type TitleProps = {
|
|
|
441
442
|
*/
|
|
442
443
|
declare function Title(props: TitleProps): JSX.Element;
|
|
443
444
|
|
|
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 };
|
|
445
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemContentProps, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, FaasDataWrapper, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, FormSubmitProps, Link, LinkProps, Loading, ModalProps, PageNotFound, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, setDrawerProps, setModalProps, transferOptions, transferValue, useConfigContext, useDrawer, useModal };
|