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