@faasjs/ant-design 0.0.3-development → 0.0.4-beta.1
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/LICENSE +6 -6
- package/README.md +954 -5
- package/dist/index.d.mts +545 -0
- package/dist/index.d.ts +545 -0
- package/dist/index.js +1626 -0
- package/dist/index.mjs +1582 -0
- package/package.json +33 -60
- package/lib/components/Button.d.ts +0 -60
- package/lib/components/Button.stories.d.ts +0 -36
- package/lib/components/Description.d.ts +0 -11
- package/lib/components/Description.stories.d.ts +0 -6
- package/lib/components/Form.d.ts +0 -7
- package/lib/components/Form.stories.d.ts +0 -7
- package/lib/components/FormItem.d.ts +0 -7
- package/lib/components/FormItem.stories.d.ts +0 -11
- package/lib/components/Header.d.ts +0 -19
- package/lib/components/Header.stories.d.ts +0 -24
- package/lib/components/Page.d.ts +0 -22
- package/lib/components/Page.stories.d.ts +0 -24
- package/lib/components/Table.d.ts +0 -8
- package/lib/components/Table.stories.d.ts +0 -6
- package/lib/components/__tests__/Form.test.d.ts +0 -1
- package/lib/components/__tests__/FormItem.test.d.ts +0 -1
- package/lib/components/data.d.ts +0 -17
- package/lib/index.d.ts +0 -2
- package/lib/index.esm.js +0 -57
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js +0 -62
- package/lib/index.js.map +0 -1
- package/lib/jest.setup.d.ts +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import { FaasDataInjection as FaasDataInjection$1, FaasDataWrapperProps as FaasDataWrapperProps$1, ErrorBoundaryProps } from '@faasjs/react';
|
|
2
|
+
export { ErrorBoundaryProps, faas, useFaas } from '@faasjs/react';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { ConfigProviderProps as ConfigProviderProps$1 } from 'antd/es/config-provider';
|
|
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';
|
|
9
|
+
export { Drawer, Modal } from 'antd';
|
|
10
|
+
import { BrowserRouterProps, RouteProps } from 'react-router-dom';
|
|
11
|
+
import * as react from 'react';
|
|
12
|
+
import { CSSProperties, ReactNode, ReactElement, LazyExoticComponent, ComponentType } from 'react';
|
|
13
|
+
export { lazy } from 'react';
|
|
14
|
+
import { Dayjs } from 'dayjs';
|
|
15
|
+
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
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';
|
|
23
|
+
|
|
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 {
|
|
95
|
+
value?: any;
|
|
96
|
+
text?: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Blank component.
|
|
100
|
+
*
|
|
101
|
+
* If value is undefined or null, return text, otherwise return value.
|
|
102
|
+
*
|
|
103
|
+
* @param options {object}
|
|
104
|
+
* @param options.value {any}
|
|
105
|
+
* @param options.text {string} Default is 'Empty'
|
|
106
|
+
* @returns {JSX.Element}
|
|
107
|
+
*
|
|
108
|
+
* ```ts
|
|
109
|
+
* <Blank value={undefined} text="Empty" />
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
declare function Blank(options?: BlankProps): JSX.Element;
|
|
113
|
+
|
|
114
|
+
interface ConfigProviderProps {
|
|
115
|
+
lang?: string;
|
|
116
|
+
common?: {
|
|
117
|
+
blank?: string;
|
|
118
|
+
all?: string;
|
|
119
|
+
submit?: string;
|
|
120
|
+
pageNotFound?: string;
|
|
121
|
+
add?: string;
|
|
122
|
+
delete?: string;
|
|
123
|
+
required?: string;
|
|
124
|
+
search?: string;
|
|
125
|
+
reset?: string;
|
|
126
|
+
};
|
|
127
|
+
Blank?: {
|
|
128
|
+
text?: string;
|
|
129
|
+
};
|
|
130
|
+
Form?: {
|
|
131
|
+
submit?: {
|
|
132
|
+
text?: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
Title?: {
|
|
136
|
+
/** ' - ' as default */
|
|
137
|
+
separator?: string;
|
|
138
|
+
suffix?: string;
|
|
139
|
+
};
|
|
140
|
+
Link?: {
|
|
141
|
+
/** '_blank' as default */
|
|
142
|
+
target?: string;
|
|
143
|
+
style?: CSSProperties;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
declare const ConfigContext: react.Context<ConfigProviderProps>;
|
|
147
|
+
/**
|
|
148
|
+
* Config for @faasjs/ant-design components.
|
|
149
|
+
*
|
|
150
|
+
* ```ts
|
|
151
|
+
* <ConfigProvider config={{
|
|
152
|
+
* common: {
|
|
153
|
+
* blank: 'Empty',
|
|
154
|
+
* },
|
|
155
|
+
* }}>
|
|
156
|
+
* <Blank />
|
|
157
|
+
* </ConfigProvider>
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare function ConfigProvider({ config, children, }: {
|
|
161
|
+
config: ConfigProviderProps;
|
|
162
|
+
children: React.ReactNode;
|
|
163
|
+
}): react_jsx_runtime.JSX.Element;
|
|
164
|
+
declare function useConfigContext(): ConfigProviderProps;
|
|
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
|
+
|
|
323
|
+
type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean' | 'date' | 'time' | 'object' | 'object[]';
|
|
324
|
+
/** FaasItemType's value type */
|
|
325
|
+
type FaasItemTypeValue = {
|
|
326
|
+
string: string;
|
|
327
|
+
'string[]': string[];
|
|
328
|
+
number: number;
|
|
329
|
+
'number[]': number[];
|
|
330
|
+
boolean: boolean;
|
|
331
|
+
date: Dayjs;
|
|
332
|
+
time: Dayjs;
|
|
333
|
+
object: any;
|
|
334
|
+
'object[]': any[];
|
|
335
|
+
};
|
|
336
|
+
type BaseOption = string | number | {
|
|
337
|
+
label: string;
|
|
338
|
+
value?: any;
|
|
339
|
+
};
|
|
340
|
+
interface BaseItemProps {
|
|
341
|
+
id: string;
|
|
342
|
+
title?: string;
|
|
343
|
+
options?: BaseOption[];
|
|
344
|
+
}
|
|
345
|
+
interface FaasItemProps extends BaseItemProps {
|
|
346
|
+
/**
|
|
347
|
+
* Support string, string[], number, number[], boolean, date, time, object, object[]
|
|
348
|
+
* @default 'string'
|
|
349
|
+
*/
|
|
350
|
+
type?: FaasItemType;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* convert options to { label, value }[]
|
|
354
|
+
*/
|
|
355
|
+
declare function transferOptions(options: BaseOption[]): {
|
|
356
|
+
label: string;
|
|
357
|
+
value?: string | number;
|
|
358
|
+
}[];
|
|
359
|
+
declare function transferValue(type: FaasItemType, value: any): any;
|
|
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;
|
|
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
|
+
}
|
|
374
|
+
|
|
375
|
+
declare function ErrorBoundary(props: ErrorBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
376
|
+
|
|
377
|
+
type FormSubmitProps = {
|
|
378
|
+
/** Default: Submit */
|
|
379
|
+
text?: string;
|
|
380
|
+
/**
|
|
381
|
+
* Submit to FaasJS server.
|
|
382
|
+
*
|
|
383
|
+
* If use onFinish, you should call submit manually.
|
|
384
|
+
* ```ts
|
|
385
|
+
* {
|
|
386
|
+
* submit: {
|
|
387
|
+
* to: {
|
|
388
|
+
* action: 'action_name'
|
|
389
|
+
* }
|
|
390
|
+
* },
|
|
391
|
+
* onFinish: (values, submit) => {
|
|
392
|
+
* // do something before submit
|
|
393
|
+
*
|
|
394
|
+
* // submit
|
|
395
|
+
* await submit({
|
|
396
|
+
* ...values,
|
|
397
|
+
* extraProps: 'some extra props'
|
|
398
|
+
* })
|
|
399
|
+
*
|
|
400
|
+
* // do something after submit
|
|
401
|
+
* }
|
|
402
|
+
* }
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
to?: {
|
|
406
|
+
action: string;
|
|
407
|
+
/** params will overwrite form values before submit */
|
|
408
|
+
params?: Record<string, any>;
|
|
409
|
+
then?: (result: any) => void;
|
|
410
|
+
catch?: (error: any) => void;
|
|
411
|
+
finally?: () => void;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
interface FormProps<Values extends Record<string, any> = any, ExtendItemProps = any> extends Omit<FormProps$1<Values>, 'onFinish' | 'children' | 'initialValues'> {
|
|
415
|
+
items?: (FormItemProps | ExtendItemProps | JSX.Element)[];
|
|
416
|
+
/** Default: { text: 'Submit' }, set false to disable it */
|
|
417
|
+
submit?: false | FormSubmitProps;
|
|
418
|
+
onFinish?: (values: Values, submit?: (values: any) => Promise<any>) => Promise<any>;
|
|
419
|
+
beforeItems?: JSX.Element | JSX.Element[];
|
|
420
|
+
footer?: JSX.Element | JSX.Element[];
|
|
421
|
+
extendTypes?: ExtendTypes;
|
|
422
|
+
children?: ReactNode;
|
|
423
|
+
initialValues?: Values;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Form component with Ant Design & FaasJS
|
|
427
|
+
*
|
|
428
|
+
* @ref https://ant.design/components/form/
|
|
429
|
+
*/
|
|
430
|
+
declare function Form<Values = any>(props: FormProps<Values>): react_jsx_runtime.JSX.Element;
|
|
431
|
+
declare namespace Form {
|
|
432
|
+
var useForm: typeof antd_es_form_Form.useForm;
|
|
433
|
+
var useFormInstance: typeof antd_es_form_hooks_useFormInstance.default;
|
|
434
|
+
var useWatch: typeof rc_field_form_es_useWatch.default;
|
|
435
|
+
var Item: typeof FormItem;
|
|
436
|
+
var List: react.FC<antd_es_form.FormListProps>;
|
|
437
|
+
var ErrorList: react.FC<antd_es_form.ErrorListProps>;
|
|
438
|
+
var Provider: react.FC<antd_es_form_context.FormProviderProps>;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
interface LinkProps {
|
|
442
|
+
href: string;
|
|
443
|
+
target?: '_blank';
|
|
444
|
+
text?: string | number;
|
|
445
|
+
children?: ReactNode;
|
|
446
|
+
style?: CSSProperties;
|
|
447
|
+
button?: ButtonProps;
|
|
448
|
+
block?: boolean;
|
|
449
|
+
/** only use for text without button */
|
|
450
|
+
copyable?: boolean;
|
|
451
|
+
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Link component with button.
|
|
455
|
+
*
|
|
456
|
+
* ```ts
|
|
457
|
+
* // pure link
|
|
458
|
+
* <Link href="/">Home</Link>
|
|
459
|
+
*
|
|
460
|
+
* // link with button
|
|
461
|
+
* <Link href="/" button={{ type:'primary' }}>Home</Link>
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
declare function Link(props: LinkProps): react_jsx_runtime.JSX.Element;
|
|
465
|
+
|
|
466
|
+
declare function PageNotFound(): react_jsx_runtime.JSX.Element;
|
|
467
|
+
interface RoutesProps {
|
|
468
|
+
routes: (RouteProps & {
|
|
469
|
+
page?: LazyExoticComponent<ComponentType<any>>;
|
|
470
|
+
})[];
|
|
471
|
+
fallback?: JSX.Element;
|
|
472
|
+
notFound?: JSX.Element;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Routes with lazy loading and 404 page.
|
|
476
|
+
*
|
|
477
|
+
* ```tsx
|
|
478
|
+
* import { Routes, lazy } from '@faasjs/ant-design'
|
|
479
|
+
* import { BrowserRouter } from 'react-router-dom'
|
|
480
|
+
*
|
|
481
|
+
* export function App () {
|
|
482
|
+
* return <BrowserRouter>
|
|
483
|
+
* <Routes routes={[
|
|
484
|
+
* {
|
|
485
|
+
* path: '/',
|
|
486
|
+
* page: lazy(() => import('./pages/home'))
|
|
487
|
+
* }
|
|
488
|
+
* ]} />
|
|
489
|
+
* </BrowserRouter>
|
|
490
|
+
* }
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
declare function Routes(props: RoutesProps): react_jsx_runtime.JSX.Element;
|
|
494
|
+
|
|
495
|
+
interface TabProps extends Partial<Tab> {
|
|
496
|
+
id: string;
|
|
497
|
+
title?: React.ReactNode;
|
|
498
|
+
children: React.ReactNode;
|
|
499
|
+
}
|
|
500
|
+
interface TabsProps extends Omit<TabsProps$1, 'items'> {
|
|
501
|
+
/** auto skip null tab */
|
|
502
|
+
items: (TabProps | null)[];
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Tabs component with Ant Design & FaasJS
|
|
506
|
+
*
|
|
507
|
+
* @ref https://ant.design/components/tabs/
|
|
508
|
+
*/
|
|
509
|
+
declare function Tabs(props: TabsProps): react_jsx_runtime.JSX.Element;
|
|
510
|
+
|
|
511
|
+
interface TitleProps {
|
|
512
|
+
title: string | string[];
|
|
513
|
+
/** ` - ` as default */
|
|
514
|
+
separator?: string;
|
|
515
|
+
suffix?: string;
|
|
516
|
+
/** return a h1 element */
|
|
517
|
+
h1?: boolean | {
|
|
518
|
+
className?: string;
|
|
519
|
+
style?: React.CSSProperties;
|
|
520
|
+
};
|
|
521
|
+
/** return a pure text element */
|
|
522
|
+
plain?: boolean;
|
|
523
|
+
/** return children */
|
|
524
|
+
children?: JSX.Element;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Title is used to change the title of the page.
|
|
528
|
+
* Return null by default.
|
|
529
|
+
*
|
|
530
|
+
* ```ts
|
|
531
|
+
* // return null
|
|
532
|
+
* <Title title='hi' /> // => change the document.title to 'hi'
|
|
533
|
+
* <Title title={['a', 'b']} /> // => change the document.title to 'a - b'
|
|
534
|
+
*
|
|
535
|
+
* // return h1
|
|
536
|
+
* <Title title='hi' h1 /> // => <h1>hi</h1>
|
|
537
|
+
* <Title title={['a', 'b']} h1 /> // => <h1>a</h1>
|
|
538
|
+
*
|
|
539
|
+
* // return children
|
|
540
|
+
* <Title title='hi'><CustomTitle /></Title> // => <CustomTitle />
|
|
541
|
+
* ```
|
|
542
|
+
*/
|
|
543
|
+
declare function Title(props: TitleProps): JSX.Element;
|
|
544
|
+
|
|
545
|
+
export { App, AppProps, BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemContentProps, DescriptionItemProps, DescriptionProps, DrawerProps, ErrorBoundary, 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 };
|