@faasjs/ant-design 0.0.3-beta.2 → 0.0.3-beta.21
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 +51 -314
- package/dist/index.d.ts +59 -100
- package/dist/index.js +264 -183
- package/dist/index.mjs +180 -96
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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';
|
|
8
7
|
import * as antd_es_form_Form from 'antd/es/form/Form';
|
|
@@ -10,10 +9,10 @@ import { RuleObject } from 'rc-field-form/lib/interface';
|
|
|
10
9
|
import { RouteProps } from 'react-router-dom';
|
|
11
10
|
import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
interface BlankProps {
|
|
14
13
|
value?: any;
|
|
15
14
|
text?: string;
|
|
16
|
-
}
|
|
15
|
+
}
|
|
17
16
|
/**
|
|
18
17
|
* If value is undefined or null, return text, otherwise return value.
|
|
19
18
|
*
|
|
@@ -28,8 +27,7 @@ type BlankProps = {
|
|
|
28
27
|
*/
|
|
29
28
|
declare function Blank(options?: BlankProps): JSX.Element;
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
antd?: ConfigProviderProps$1;
|
|
30
|
+
interface ConfigProviderProps {
|
|
33
31
|
lang?: string;
|
|
34
32
|
common?: {
|
|
35
33
|
blank?: string;
|
|
@@ -60,7 +58,7 @@ type ConfigProviderProps = {
|
|
|
60
58
|
target?: string;
|
|
61
59
|
style?: CSSProperties;
|
|
62
60
|
};
|
|
63
|
-
}
|
|
61
|
+
}
|
|
64
62
|
declare const ConfigContext: react.Context<ConfigProviderProps>;
|
|
65
63
|
/**
|
|
66
64
|
* Config for @faasjs/ant-design components.
|
|
@@ -98,50 +96,57 @@ type BaseOption = string | number | {
|
|
|
98
96
|
label: string;
|
|
99
97
|
value?: string | number;
|
|
100
98
|
};
|
|
101
|
-
|
|
99
|
+
interface BaseItemProps {
|
|
102
100
|
id: string;
|
|
103
101
|
title?: string;
|
|
104
102
|
options?: BaseOption[];
|
|
105
|
-
}
|
|
106
|
-
|
|
103
|
+
}
|
|
104
|
+
interface FaasItemProps extends BaseItemProps {
|
|
107
105
|
/**
|
|
108
|
-
* Support string, string[], number, number[], boolean
|
|
106
|
+
* Support string, string[], number, number[], boolean, date, time, object, object[]
|
|
109
107
|
* @default 'string'
|
|
110
108
|
*/
|
|
111
109
|
type?: FaasItemType;
|
|
112
|
-
}
|
|
110
|
+
}
|
|
113
111
|
declare function transferOptions(options: BaseOption[]): {
|
|
114
112
|
label: string;
|
|
115
113
|
value?: string | number;
|
|
116
114
|
}[];
|
|
117
115
|
declare function transferValue(type: FaasItemType, value: any): any;
|
|
118
116
|
|
|
119
|
-
|
|
120
|
-
children?: JSX.Element
|
|
121
|
-
render?: (value: any, values: any) =>
|
|
122
|
-
}
|
|
117
|
+
interface ExtendDescriptionTypeProps {
|
|
118
|
+
children?: JSX.Element;
|
|
119
|
+
render?: (value: any, values: any) => JSX.Element;
|
|
120
|
+
}
|
|
123
121
|
type ExtendDescriptionItemProps = BaseItemProps;
|
|
124
|
-
|
|
122
|
+
interface DescriptionItemProps<T = any> extends FaasItemProps {
|
|
125
123
|
children?: JSX.Element;
|
|
126
|
-
render?: (value: T, values: any) =>
|
|
124
|
+
render?: (value: T, values: any) => JSX.Element;
|
|
127
125
|
if?: (values: Record<string, any>) => boolean;
|
|
128
|
-
} & FaasItemProps & {
|
|
129
126
|
object?: DescriptionItemProps[];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
renderTitle?: ((values: T) => ReactNode
|
|
127
|
+
}
|
|
128
|
+
interface DescriptionProps<T = any, ExtendItemProps = any> extends DescriptionsProps {
|
|
129
|
+
renderTitle?: ((values: T) => ReactNode);
|
|
133
130
|
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
134
131
|
extendTypes?: {
|
|
135
132
|
[key: string]: ExtendDescriptionTypeProps;
|
|
136
133
|
};
|
|
137
134
|
dataSource?: T;
|
|
138
135
|
faasData?: FaasDataWrapperProps<T>;
|
|
139
|
-
}
|
|
136
|
+
}
|
|
137
|
+
interface DescriptionItemContentProps<T = any> {
|
|
138
|
+
item: DescriptionItemProps;
|
|
139
|
+
value: T;
|
|
140
|
+
values?: any;
|
|
141
|
+
extendTypes?: {
|
|
142
|
+
[key: string]: ExtendDescriptionTypeProps;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
140
145
|
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
141
146
|
|
|
142
|
-
|
|
147
|
+
interface DrawerProps extends DrawerProps$1 {
|
|
143
148
|
children?: JSX.Element | JSX.Element[];
|
|
144
|
-
}
|
|
149
|
+
}
|
|
145
150
|
type setDrawerProps = (changes: Partial<DrawerProps>) => void;
|
|
146
151
|
/**
|
|
147
152
|
* Hook style drawer.
|
|
@@ -166,57 +171,6 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
166
171
|
setDrawerProps(changes: Partial<DrawerProps>): void;
|
|
167
172
|
};
|
|
168
173
|
|
|
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
174
|
type ExtendFormTypeProps = {
|
|
221
175
|
children?: ReactNode;
|
|
222
176
|
};
|
|
@@ -224,9 +178,15 @@ type ExtendTypes = {
|
|
|
224
178
|
[type: string]: ExtendFormTypeProps;
|
|
225
179
|
};
|
|
226
180
|
type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
181
|
+
interface FormItemProps<T = any> extends FaasItemProps, Omit<FormItemProps$1<T>, 'id' | 'children'> {
|
|
182
|
+
input?: InputProps | InputNumberProps | SwitchProps | SelectProps<T> | DatePickerProps | TimePickerProps;
|
|
183
|
+
maxCount?: number;
|
|
184
|
+
object?: FormItemProps[];
|
|
185
|
+
disabled?: boolean;
|
|
186
|
+
required?: boolean;
|
|
187
|
+
col?: number;
|
|
188
|
+
children?: JSX.Element;
|
|
189
|
+
render?: () => JSX.Element;
|
|
230
190
|
rules?: RuleObject[];
|
|
231
191
|
label?: string | false;
|
|
232
192
|
extendTypes?: ExtendTypes;
|
|
@@ -234,24 +194,24 @@ type FormItemProps<T = any> = {
|
|
|
234
194
|
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
235
195
|
/** trigger when any item's value changed */
|
|
236
196
|
if?: (values: Record<string, any>) => boolean;
|
|
237
|
-
}
|
|
197
|
+
}
|
|
238
198
|
/**
|
|
239
199
|
* FormItem, can be used without Form.
|
|
240
200
|
*
|
|
241
201
|
* ```ts
|
|
242
202
|
* // use inline type
|
|
243
|
-
* <FormItem
|
|
203
|
+
* <FormItem type='string' id='name' />
|
|
244
204
|
*
|
|
245
205
|
* // use custom type
|
|
246
|
-
* <FormItem
|
|
206
|
+
* <FormItem id='password'>
|
|
247
207
|
* <Input.Password />
|
|
248
208
|
* </>
|
|
249
209
|
* ```
|
|
250
210
|
*/
|
|
251
211
|
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
252
212
|
|
|
253
|
-
|
|
254
|
-
items?: (FormItemProps | ExtendItemProps)[];
|
|
213
|
+
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps = any> extends Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> {
|
|
214
|
+
items?: (FormItemProps | ExtendItemProps | JSX.Element)[];
|
|
255
215
|
/** Default: { text: 'Submit' }, set false to disable it */
|
|
256
216
|
submit?: false | {
|
|
257
217
|
/** Default: Submit */
|
|
@@ -293,7 +253,7 @@ type FormProps<Values extends Record<string, any> = any, ExtendItemProps = any>
|
|
|
293
253
|
extendTypes?: ExtendTypes;
|
|
294
254
|
children?: ReactNode;
|
|
295
255
|
initialValues?: Values;
|
|
296
|
-
}
|
|
256
|
+
}
|
|
297
257
|
/**
|
|
298
258
|
* Form component with Ant Design & FaasJS
|
|
299
259
|
*
|
|
@@ -304,28 +264,28 @@ declare namespace Form {
|
|
|
304
264
|
var useForm: typeof antd_es_form_Form.useForm;
|
|
305
265
|
}
|
|
306
266
|
|
|
307
|
-
|
|
267
|
+
interface LinkProps {
|
|
308
268
|
href: string;
|
|
309
269
|
target?: string;
|
|
310
270
|
text?: string | number;
|
|
311
271
|
children?: ReactNode;
|
|
312
272
|
style?: CSSProperties;
|
|
313
273
|
button?: ButtonProps;
|
|
314
|
-
}
|
|
274
|
+
}
|
|
315
275
|
/**
|
|
316
276
|
* ```ts
|
|
317
277
|
* // pure link
|
|
318
278
|
* <Link href="/">Home</Link>
|
|
319
279
|
*
|
|
320
280
|
* // link with button
|
|
321
|
-
* <Link href="/" button={{type:'primary'}}>Home</Link>
|
|
281
|
+
* <Link href="/" button={{ type:'primary' }}>Home</Link>
|
|
322
282
|
* ```
|
|
323
283
|
*/
|
|
324
284
|
declare function Link({ href, target, text, children, style, button, }: LinkProps): JSX.Element;
|
|
325
285
|
|
|
326
|
-
|
|
286
|
+
interface ModalProps extends ModalProps$1 {
|
|
327
287
|
children?: JSX.Element | JSX.Element[] | string;
|
|
328
|
-
}
|
|
288
|
+
}
|
|
329
289
|
type setModalProps = (changes: Partial<ModalProps>) => void;
|
|
330
290
|
/**
|
|
331
291
|
* Hook style modal.
|
|
@@ -348,13 +308,13 @@ declare function useModal(init?: ModalProps): {
|
|
|
348
308
|
};
|
|
349
309
|
|
|
350
310
|
declare function PageNotFound(): JSX.Element;
|
|
351
|
-
|
|
311
|
+
interface RoutesProps {
|
|
352
312
|
routes: (RouteProps & {
|
|
353
313
|
page?: LazyExoticComponent<ComponentType<any>>;
|
|
354
314
|
})[];
|
|
355
315
|
fallback?: JSX.Element;
|
|
356
316
|
notFound?: JSX.Element;
|
|
357
|
-
}
|
|
317
|
+
}
|
|
358
318
|
/**
|
|
359
319
|
* Routes with lazy loading and 404 page.
|
|
360
320
|
*
|
|
@@ -376,14 +336,13 @@ type RoutesProps = {
|
|
|
376
336
|
*/
|
|
377
337
|
declare function Routes(props: RoutesProps): JSX.Element;
|
|
378
338
|
|
|
379
|
-
|
|
339
|
+
interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T>, 'title' | 'children'> {
|
|
380
340
|
optionsType?: 'auto';
|
|
381
|
-
|
|
382
|
-
children?: JSX.Element | null;
|
|
341
|
+
children?: JSX.Element;
|
|
383
342
|
object?: TableItemProps[];
|
|
384
|
-
}
|
|
343
|
+
}
|
|
385
344
|
type ExtendTableTypeProps = {
|
|
386
|
-
children?: JSX.Element
|
|
345
|
+
children?: JSX.Element;
|
|
387
346
|
render?: (value: any, values: any, index: number) => JSX.Element | string | number | boolean | null;
|
|
388
347
|
};
|
|
389
348
|
type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
@@ -407,7 +366,7 @@ type TableProps<T = any, ExtendTypes = any> = {
|
|
|
407
366
|
*/
|
|
408
367
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
409
368
|
|
|
410
|
-
|
|
369
|
+
interface TitleProps {
|
|
411
370
|
title: string | string[];
|
|
412
371
|
/** ` - ` as default */
|
|
413
372
|
separator?: string;
|
|
@@ -421,7 +380,7 @@ type TitleProps = {
|
|
|
421
380
|
plain?: boolean;
|
|
422
381
|
/** return children */
|
|
423
382
|
children?: JSX.Element;
|
|
424
|
-
}
|
|
383
|
+
}
|
|
425
384
|
/**
|
|
426
385
|
* Title is used to change the title of the page.
|
|
427
386
|
* Return null by default.
|
|
@@ -441,4 +400,4 @@ type TitleProps = {
|
|
|
441
400
|
*/
|
|
442
401
|
declare function Title(props: TitleProps): JSX.Element;
|
|
443
402
|
|
|
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 };
|
|
403
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemContentProps, 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 };
|