@faasjs/ant-design 0.0.3-beta.31 → 0.0.3-beta.32
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 +120 -23
- package/dist/index.d.ts +161 -125
- package/dist/index.js +62 -19
- package/dist/index.mjs +85 -43
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -62,6 +62,7 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
|
|
|
62
62
|
- [RoutesProps](interfaces/RoutesProps.md)
|
|
63
63
|
- [TableItemProps](interfaces/TableItemProps.md)
|
|
64
64
|
- [TitleProps](interfaces/TitleProps.md)
|
|
65
|
+
- [UnionFaasItemProps](interfaces/UnionFaasItemProps.md)
|
|
65
66
|
|
|
66
67
|
### Type Aliases
|
|
67
68
|
|
|
@@ -77,7 +78,12 @@ Form are based on [Ant Design's Form.Item component](https://ant.design/componen
|
|
|
77
78
|
- [FaasItemType](#faasitemtype)
|
|
78
79
|
- [FaasItemTypeValue](#faasitemtypevalue)
|
|
79
80
|
- [FormSubmitProps](#formsubmitprops)
|
|
81
|
+
- [LoadingProps](#loadingprops)
|
|
80
82
|
- [TableProps](#tableprops)
|
|
83
|
+
- [UnionFaasItemElement](#unionfaasitemelement)
|
|
84
|
+
- [UnionFaasItemInjection](#unionfaasiteminjection)
|
|
85
|
+
- [UnionFaasItemRender](#unionfaasitemrender)
|
|
86
|
+
- [UnionScene](#unionscene)
|
|
81
87
|
- [setDrawerProps](#setdrawerprops)
|
|
82
88
|
- [setModalProps](#setmodalprops)
|
|
83
89
|
|
|
@@ -127,13 +133,19 @@ ___
|
|
|
127
133
|
|
|
128
134
|
### ExtendFormTypeProps
|
|
129
135
|
|
|
130
|
-
Ƭ **ExtendFormTypeProps
|
|
136
|
+
Ƭ **ExtendFormTypeProps**<`T`\>: `Object`
|
|
137
|
+
|
|
138
|
+
#### Type parameters
|
|
139
|
+
|
|
140
|
+
| Name | Type |
|
|
141
|
+
| :------ | :------ |
|
|
142
|
+
| `T` | `any` |
|
|
131
143
|
|
|
132
144
|
#### Type declaration
|
|
133
145
|
|
|
134
146
|
| Name | Type |
|
|
135
147
|
| :------ | :------ |
|
|
136
|
-
| `children?` | `
|
|
148
|
+
| `children?` | [`UnionFaasItemElement`](#unionfaasitemelement)<`T`\> |
|
|
137
149
|
|
|
138
150
|
___
|
|
139
151
|
|
|
@@ -151,14 +163,20 @@ ___
|
|
|
151
163
|
|
|
152
164
|
### ExtendTableTypeProps
|
|
153
165
|
|
|
154
|
-
Ƭ **ExtendTableTypeProps
|
|
166
|
+
Ƭ **ExtendTableTypeProps**<`T`\>: `Object`
|
|
167
|
+
|
|
168
|
+
#### Type parameters
|
|
169
|
+
|
|
170
|
+
| Name | Type |
|
|
171
|
+
| :------ | :------ |
|
|
172
|
+
| `T` | `any` |
|
|
155
173
|
|
|
156
174
|
#### Type declaration
|
|
157
175
|
|
|
158
176
|
| Name | Type |
|
|
159
177
|
| :------ | :------ |
|
|
160
178
|
| `children?` | `JSX.Element` |
|
|
161
|
-
| `render?` |
|
|
179
|
+
| `render?` | [`UnionFaasItemRender`](#unionfaasitemrender)<`T`\> |
|
|
162
180
|
|
|
163
181
|
___
|
|
164
182
|
|
|
@@ -204,26 +222,13 @@ ___
|
|
|
204
222
|
|
|
205
223
|
### FaasDataWrapperProps
|
|
206
224
|
|
|
207
|
-
Ƭ **FaasDataWrapperProps**<`
|
|
225
|
+
Ƭ **FaasDataWrapperProps**<`T`\>: `OriginProps`<`T`\> & { `loading?`: `JSX.Element` ; `loadingProps?`: [`LoadingProps`](#loadingprops) }
|
|
208
226
|
|
|
209
227
|
#### Type parameters
|
|
210
228
|
|
|
211
229
|
| Name | Type |
|
|
212
230
|
| :------ | :------ |
|
|
213
|
-
| `
|
|
214
|
-
|
|
215
|
-
#### Type declaration
|
|
216
|
-
|
|
217
|
-
| Name | Type | Description |
|
|
218
|
-
| :------ | :------ | :------ |
|
|
219
|
-
| `action` | `string` | - |
|
|
220
|
-
| `children?` | `JSX.Element` | - |
|
|
221
|
-
| `data?` | `FaasData`<`PathOrData`\> | use custom data, should work with setData |
|
|
222
|
-
| `fallback?` | `JSX.Element` \| ``false`` | - |
|
|
223
|
-
| `params?` | `FaasParams`<`PathOrData`\> | - |
|
|
224
|
-
| `setData?` | `React.Dispatch`<`React.SetStateAction`<`FaasData`<`PathOrData`\>\>\> | use custom setData, should work with data |
|
|
225
|
-
| `onDataChange?` | (`args`: [`FaasDataInjection`](#faasdatainjection)<`FaasData`<`PathOrData`\>\>) => `void` | - |
|
|
226
|
-
| `render?` | (`args`: [`FaasDataInjection`](#faasdatainjection)<`FaasData`<`PathOrData`\>\>) => `Element` \| `Element`[] | - |
|
|
231
|
+
| `T` | `any` |
|
|
227
232
|
|
|
228
233
|
___
|
|
229
234
|
|
|
@@ -273,6 +278,21 @@ ___
|
|
|
273
278
|
|
|
274
279
|
___
|
|
275
280
|
|
|
281
|
+
### LoadingProps
|
|
282
|
+
|
|
283
|
+
Ƭ **LoadingProps**: `Object`
|
|
284
|
+
|
|
285
|
+
#### Type declaration
|
|
286
|
+
|
|
287
|
+
| Name | Type |
|
|
288
|
+
| :------ | :------ |
|
|
289
|
+
| `children?` | `React.ReactNode` |
|
|
290
|
+
| `loading?` | `boolean` |
|
|
291
|
+
| `size?` | ``"small"`` \| ``"default"`` \| ``"large"`` |
|
|
292
|
+
| `style?` | `React.CSSProperties` |
|
|
293
|
+
|
|
294
|
+
___
|
|
295
|
+
|
|
276
296
|
### TableProps
|
|
277
297
|
|
|
278
298
|
Ƭ **TableProps**<`T`, `ExtendTypes`\>: { `extendTypes?`: { `[key: string]`: [`ExtendTableTypeProps`](#extendtabletypeprops); } ; `faasData?`: [`FaasDataWrapperProps`](#faasdatawrapperprops)<`T`\> ; `items`: ([`TableItemProps`](interfaces/TableItemProps.md) \| `ExtendTypes` & [`ExtendTableItemProps`](#extendtableitemprops))[] ; `onChange?`: (`pagination`: `TablePaginationConfig`, `filters`: `Record`<`string`, `FilterValue` \| ``null``\>, `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[], `extra`: `TableCurrentDataSource`<`T`\>) => { `extra`: `TableCurrentDataSource`<`T`\> ; `filters`: `Record`<`string`, `FilterValue` \| ``null``\> ; `pagination`: `TablePaginationConfig` ; `sorter`: `SorterResult`<`T`\> \| `SorterResult`<`T`\>[] } } & `AntdTableProps`<`T`\>
|
|
@@ -286,6 +306,77 @@ ___
|
|
|
286
306
|
|
|
287
307
|
___
|
|
288
308
|
|
|
309
|
+
### UnionFaasItemElement
|
|
310
|
+
|
|
311
|
+
Ƭ **UnionFaasItemElement**<`Value`, `Values`\>: `ReactElement`<[`UnionFaasItemInjection`](#unionfaasiteminjection)<`Value`, `Values`\>\> \| ``null``
|
|
312
|
+
|
|
313
|
+
#### Type parameters
|
|
314
|
+
|
|
315
|
+
| Name | Type |
|
|
316
|
+
| :------ | :------ |
|
|
317
|
+
| `Value` | `any` |
|
|
318
|
+
| `Values` | `any` |
|
|
319
|
+
|
|
320
|
+
___
|
|
321
|
+
|
|
322
|
+
### UnionFaasItemInjection
|
|
323
|
+
|
|
324
|
+
Ƭ **UnionFaasItemInjection**<`Value`, `Values`\>: `Object`
|
|
325
|
+
|
|
326
|
+
#### Type parameters
|
|
327
|
+
|
|
328
|
+
| Name | Type |
|
|
329
|
+
| :------ | :------ |
|
|
330
|
+
| `Value` | `any` |
|
|
331
|
+
| `Values` | `any` |
|
|
332
|
+
|
|
333
|
+
#### Type declaration
|
|
334
|
+
|
|
335
|
+
| Name | Type |
|
|
336
|
+
| :------ | :------ |
|
|
337
|
+
| `index?` | `number` |
|
|
338
|
+
| `scene?` | [`UnionScene`](#unionscene) |
|
|
339
|
+
| `value?` | `Value` |
|
|
340
|
+
| `values?` | `Values` |
|
|
341
|
+
|
|
342
|
+
___
|
|
343
|
+
|
|
344
|
+
### UnionFaasItemRender
|
|
345
|
+
|
|
346
|
+
Ƭ **UnionFaasItemRender**<`Value`, `Values`\>: (`value`: `Value`, `values`: `Values`, `index`: `number`, `scene`: [`UnionScene`](#unionscene)) => `JSX.Element` \| ``null``
|
|
347
|
+
|
|
348
|
+
#### Type parameters
|
|
349
|
+
|
|
350
|
+
| Name | Type |
|
|
351
|
+
| :------ | :------ |
|
|
352
|
+
| `Value` | `any` |
|
|
353
|
+
| `Values` | `any` |
|
|
354
|
+
|
|
355
|
+
#### Type declaration
|
|
356
|
+
|
|
357
|
+
▸ (`value`, `values`, `index`, `scene`): `JSX.Element` \| ``null``
|
|
358
|
+
|
|
359
|
+
##### Parameters
|
|
360
|
+
|
|
361
|
+
| Name | Type |
|
|
362
|
+
| :------ | :------ |
|
|
363
|
+
| `value` | `Value` |
|
|
364
|
+
| `values` | `Values` |
|
|
365
|
+
| `index` | `number` |
|
|
366
|
+
| `scene` | [`UnionScene`](#unionscene) |
|
|
367
|
+
|
|
368
|
+
##### Returns
|
|
369
|
+
|
|
370
|
+
`JSX.Element` \| ``null``
|
|
371
|
+
|
|
372
|
+
___
|
|
373
|
+
|
|
374
|
+
### UnionScene
|
|
375
|
+
|
|
376
|
+
Ƭ **UnionScene**: ``"form"`` \| ``"description"`` \| ``"table"``
|
|
377
|
+
|
|
378
|
+
___
|
|
379
|
+
|
|
289
380
|
### setDrawerProps
|
|
290
381
|
|
|
291
382
|
Ƭ **setDrawerProps**: (`changes`: `Partial`<[`DrawerProps`](interfaces/DrawerProps.md)\>) => `void`
|
|
@@ -528,13 +619,19 @@ ___
|
|
|
528
619
|
|
|
529
620
|
Loading component based on Spin
|
|
530
621
|
|
|
622
|
+
```tsx
|
|
623
|
+
<Loading /> // display loading
|
|
624
|
+
|
|
625
|
+
<Loading loading={ !remoteData }>
|
|
626
|
+
<div>{remoteData}</div>
|
|
627
|
+
</Loading>
|
|
628
|
+
```
|
|
629
|
+
|
|
531
630
|
#### Parameters
|
|
532
631
|
|
|
533
632
|
| Name | Type |
|
|
534
633
|
| :------ | :------ |
|
|
535
|
-
| `props` | `
|
|
536
|
-
| `props.size?` | ``"default"`` \| ``"small"`` \| ``"large"`` |
|
|
537
|
-
| `props.style?` | `CSSProperties` |
|
|
634
|
+
| `props` | [`LoadingProps`](#loadingprops) |
|
|
538
635
|
|
|
539
636
|
#### Returns
|
|
540
637
|
|
|
@@ -600,7 +697,7 @@ https://ant.design/components/table/
|
|
|
600
697
|
|
|
601
698
|
| Name | Type |
|
|
602
699
|
| :------ | :------ |
|
|
603
|
-
| `T` | `any
|
|
700
|
+
| `T` | extends `Record`<`string`, `any`\> |
|
|
604
701
|
| `ExtendTypes` | `any` |
|
|
605
702
|
|
|
606
703
|
#### Parameters
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { CSSProperties, ReactNode, LazyExoticComponent, ComponentType } from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode, ReactElement, LazyExoticComponent, ComponentType } from 'react';
|
|
3
3
|
import { Dayjs } from 'dayjs';
|
|
4
|
-
import {
|
|
4
|
+
import { FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, DatePickerProps, TimePickerProps, FormInstance, DescriptionsProps, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, DrawerProps as DrawerProps$1, FormProps as FormProps$1, ButtonProps, ModalProps as ModalProps$1 } from 'antd';
|
|
5
5
|
export { Drawer, Modal } from 'antd';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
7
|
+
import { FaasDataWrapperProps as FaasDataWrapperProps$1 } from '@faasjs/react';
|
|
8
|
+
export { FaasDataInjection } from '@faasjs/react';
|
|
9
|
+
import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
|
|
8
10
|
import * as antd_es_form_context from 'antd/es/form/context';
|
|
9
11
|
import * as antd_es_form_ErrorList from 'antd/es/form/ErrorList';
|
|
10
12
|
import * as antd_es_form from 'antd/es/form';
|
|
11
13
|
import * as rc_field_form_es_useWatch from 'rc-field-form/es/useWatch';
|
|
12
14
|
import * as antd_es_form_hooks_useFormInstance from 'antd/es/form/hooks/useFormInstance';
|
|
13
15
|
import * as antd_es_form_Form from 'antd/es/form/Form';
|
|
14
|
-
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
15
16
|
import { RouteProps } from 'react-router-dom';
|
|
16
|
-
import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/es/table/interface';
|
|
17
17
|
|
|
18
18
|
interface BlankProps {
|
|
19
19
|
value?: any;
|
|
@@ -87,56 +87,92 @@ declare function ConfigProvider({ config, children }: {
|
|
|
87
87
|
}): JSX.Element;
|
|
88
88
|
declare function useConfigContext(): ConfigProviderProps;
|
|
89
89
|
|
|
90
|
-
type
|
|
91
|
-
|
|
92
|
-
type FaasItemTypeValue = {
|
|
93
|
-
string: string;
|
|
94
|
-
'string[]': string[];
|
|
95
|
-
number: number;
|
|
96
|
-
'number[]': number[];
|
|
97
|
-
boolean: boolean;
|
|
98
|
-
date: Dayjs;
|
|
99
|
-
time: Dayjs;
|
|
100
|
-
object: any;
|
|
101
|
-
'object[]': any[];
|
|
90
|
+
type ExtendFormTypeProps<T = any> = {
|
|
91
|
+
children?: UnionFaasItemElement<T>;
|
|
102
92
|
};
|
|
103
|
-
type
|
|
104
|
-
|
|
105
|
-
value?: string | number;
|
|
93
|
+
type ExtendTypes = {
|
|
94
|
+
[type: string]: ExtendFormTypeProps;
|
|
106
95
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
97
|
+
interface FormItemProps<T = any> extends FaasItemProps, Omit<FormItemProps$1<T>, 'id' | 'children' | 'render'> {
|
|
98
|
+
input?: InputProps | InputNumberProps | SwitchProps | SelectProps<T> | DatePickerProps | TimePickerProps;
|
|
99
|
+
maxCount?: number;
|
|
100
|
+
object?: FormItemProps[];
|
|
101
|
+
disabled?: boolean;
|
|
102
|
+
required?: boolean;
|
|
103
|
+
col?: number;
|
|
104
|
+
children?: UnionFaasItemElement<T>;
|
|
105
|
+
formChildren?: UnionFaasItemElement<T>;
|
|
106
|
+
render?: UnionFaasItemRender<T>;
|
|
107
|
+
formRender?: UnionFaasItemRender<T>;
|
|
108
|
+
rules?: RuleObject[];
|
|
109
|
+
label?: string | false;
|
|
110
|
+
extendTypes?: ExtendTypes;
|
|
111
|
+
/** trigger when current item's value changed */
|
|
112
|
+
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
113
|
+
/** trigger when any item's value changed */
|
|
114
|
+
if?: (values: Record<string, any>) => boolean;
|
|
111
115
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
/**
|
|
117
|
+
* FormItem, can be used without Form.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* // use inline type
|
|
121
|
+
* <FormItem type='string' id='name' />
|
|
122
|
+
*
|
|
123
|
+
* // use custom type
|
|
124
|
+
* <FormItem id='password'>
|
|
125
|
+
* <Input.Password />
|
|
126
|
+
* </>
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
130
|
+
declare namespace FormItem {
|
|
131
|
+
var useStatus: () => {
|
|
132
|
+
status?: "" | "warning" | "error" | "success" | "validating";
|
|
133
|
+
};
|
|
118
134
|
}
|
|
119
|
-
declare function transferOptions(options: BaseOption[]): {
|
|
120
|
-
label: string;
|
|
121
|
-
value?: string | number;
|
|
122
|
-
}[];
|
|
123
|
-
declare function transferValue(type: FaasItemType, value: any): any;
|
|
124
135
|
|
|
136
|
+
type LoadingProps = {
|
|
137
|
+
style?: React.CSSProperties;
|
|
138
|
+
size?: 'small' | 'default' | 'large';
|
|
139
|
+
loading?: boolean;
|
|
140
|
+
children?: React.ReactNode;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Loading component based on Spin
|
|
144
|
+
*
|
|
145
|
+
* ```tsx
|
|
146
|
+
* <Loading /> // display loading
|
|
147
|
+
*
|
|
148
|
+
* <Loading loading={ !remoteData }>
|
|
149
|
+
* <div>{remoteData}</div>
|
|
150
|
+
* </Loading>
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function Loading(props: LoadingProps): JSX.Element;
|
|
154
|
+
|
|
155
|
+
type FaasDataWrapperProps<T = any> = FaasDataWrapperProps$1<T> & {
|
|
156
|
+
loadingProps?: LoadingProps;
|
|
157
|
+
loading?: JSX.Element;
|
|
158
|
+
};
|
|
125
159
|
/**
|
|
126
160
|
* FaasDataWrapper component with Loading and ErrorBoundary
|
|
127
161
|
*/
|
|
128
162
|
declare function FaasDataWrapper<T = any>(props: FaasDataWrapperProps<T>): JSX.Element;
|
|
129
163
|
|
|
130
|
-
interface ExtendDescriptionTypeProps {
|
|
131
|
-
children?:
|
|
132
|
-
render?:
|
|
164
|
+
interface ExtendDescriptionTypeProps<T = any> {
|
|
165
|
+
children?: UnionFaasItemElement<T>;
|
|
166
|
+
render?: UnionFaasItemRender<T>;
|
|
133
167
|
}
|
|
134
168
|
type ExtendDescriptionItemProps = BaseItemProps;
|
|
135
169
|
interface DescriptionItemProps<T = any> extends FaasItemProps {
|
|
136
|
-
children?:
|
|
137
|
-
|
|
170
|
+
children?: UnionFaasItemElement<T>;
|
|
171
|
+
descriptionChildren?: UnionFaasItemElement<T>;
|
|
172
|
+
render?: UnionFaasItemRender<T>;
|
|
173
|
+
descriptionRender?: UnionFaasItemRender<T>;
|
|
138
174
|
if?: (values: Record<string, any>) => boolean;
|
|
139
|
-
object?: DescriptionItemProps[];
|
|
175
|
+
object?: DescriptionItemProps<T>[];
|
|
140
176
|
}
|
|
141
177
|
interface DescriptionProps<T = any, ExtendItemProps = any> extends DescriptionsProps {
|
|
142
178
|
renderTitle?: ((values: T) => ReactNode);
|
|
@@ -160,6 +196,88 @@ interface DescriptionItemContentProps<T = any> {
|
|
|
160
196
|
*/
|
|
161
197
|
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
162
198
|
|
|
199
|
+
interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T>, 'title' | 'children' | 'render'> {
|
|
200
|
+
optionsType?: 'auto';
|
|
201
|
+
children?: UnionFaasItemElement<T>;
|
|
202
|
+
tableChildren?: UnionFaasItemElement<T>;
|
|
203
|
+
render?: UnionFaasItemRender<T>;
|
|
204
|
+
tableRender?: UnionFaasItemRender<T>;
|
|
205
|
+
object?: TableItemProps<T>[];
|
|
206
|
+
}
|
|
207
|
+
type ExtendTableTypeProps<T = any> = {
|
|
208
|
+
children?: JSX.Element;
|
|
209
|
+
render?: UnionFaasItemRender<T>;
|
|
210
|
+
};
|
|
211
|
+
type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
212
|
+
type TableProps<T = any, ExtendTypes = any> = {
|
|
213
|
+
items: (TableItemProps | (ExtendTypes & ExtendTableItemProps))[];
|
|
214
|
+
extendTypes?: {
|
|
215
|
+
[key: string]: ExtendTableTypeProps;
|
|
216
|
+
};
|
|
217
|
+
faasData?: FaasDataWrapperProps<T>;
|
|
218
|
+
onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<T> | SorterResult<T>[], extra: TableCurrentDataSource<T>) => {
|
|
219
|
+
pagination: TablePaginationConfig;
|
|
220
|
+
filters: Record<string, FilterValue | null>;
|
|
221
|
+
sorter: SorterResult<T> | SorterResult<T>[];
|
|
222
|
+
extra: TableCurrentDataSource<T>;
|
|
223
|
+
};
|
|
224
|
+
} & TableProps$1<T>;
|
|
225
|
+
/**
|
|
226
|
+
* Table component with Ant Design & FaasJS
|
|
227
|
+
*
|
|
228
|
+
* @ref https://ant.design/components/table/
|
|
229
|
+
*/
|
|
230
|
+
declare function Table<T extends Record<string, any>, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
231
|
+
|
|
232
|
+
type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean' | 'date' | 'time' | 'object' | 'object[]';
|
|
233
|
+
/** FaasItemType's value type */
|
|
234
|
+
type FaasItemTypeValue = {
|
|
235
|
+
string: string;
|
|
236
|
+
'string[]': string[];
|
|
237
|
+
number: number;
|
|
238
|
+
'number[]': number[];
|
|
239
|
+
boolean: boolean;
|
|
240
|
+
date: Dayjs;
|
|
241
|
+
time: Dayjs;
|
|
242
|
+
object: any;
|
|
243
|
+
'object[]': any[];
|
|
244
|
+
};
|
|
245
|
+
type BaseOption = string | number | {
|
|
246
|
+
label: string;
|
|
247
|
+
value?: string | number;
|
|
248
|
+
};
|
|
249
|
+
interface BaseItemProps {
|
|
250
|
+
id: string;
|
|
251
|
+
title?: string;
|
|
252
|
+
options?: BaseOption[];
|
|
253
|
+
}
|
|
254
|
+
interface FaasItemProps extends BaseItemProps {
|
|
255
|
+
/**
|
|
256
|
+
* Support string, string[], number, number[], boolean, date, time, object, object[]
|
|
257
|
+
* @default 'string'
|
|
258
|
+
*/
|
|
259
|
+
type?: FaasItemType;
|
|
260
|
+
}
|
|
261
|
+
declare function transferOptions(options: BaseOption[]): {
|
|
262
|
+
label: string;
|
|
263
|
+
value?: string | number;
|
|
264
|
+
}[];
|
|
265
|
+
declare function transferValue(type: FaasItemType, value: any): any;
|
|
266
|
+
type UnionScene = 'form' | 'description' | 'table';
|
|
267
|
+
type UnionFaasItemInjection<Value = any, Values = any> = {
|
|
268
|
+
scene?: UnionScene;
|
|
269
|
+
value?: Value;
|
|
270
|
+
values?: Values;
|
|
271
|
+
index?: number;
|
|
272
|
+
};
|
|
273
|
+
type UnionFaasItemRender<Value = any, Values = any> = (value: Value, values: Values, index: number, scene: UnionScene) => JSX.Element | null;
|
|
274
|
+
type UnionFaasItemElement<Value = any, Values = any> = ReactElement<UnionFaasItemInjection<Value, Values>> | null;
|
|
275
|
+
interface UnionFaasItemProps<Value = any, Values = any> extends FormItemProps, DescriptionItemProps, TableItemProps {
|
|
276
|
+
children?: UnionFaasItemElement<UnionFaasItemProps<Value, Values>> | null;
|
|
277
|
+
render?: UnionFaasItemRender;
|
|
278
|
+
object?: UnionFaasItemProps<Value, Values>[];
|
|
279
|
+
}
|
|
280
|
+
|
|
163
281
|
interface DrawerProps extends DrawerProps$1 {
|
|
164
282
|
children?: JSX.Element | JSX.Element[];
|
|
165
283
|
}
|
|
@@ -188,50 +306,6 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
188
306
|
setDrawerProps(changes: Partial<DrawerProps>): void;
|
|
189
307
|
};
|
|
190
308
|
|
|
191
|
-
type ExtendFormTypeProps = {
|
|
192
|
-
children?: ReactNode;
|
|
193
|
-
};
|
|
194
|
-
type ExtendTypes = {
|
|
195
|
-
[type: string]: ExtendFormTypeProps;
|
|
196
|
-
};
|
|
197
|
-
type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
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;
|
|
207
|
-
rules?: RuleObject[];
|
|
208
|
-
label?: string | false;
|
|
209
|
-
extendTypes?: ExtendTypes;
|
|
210
|
-
/** trigger when current item's value changed */
|
|
211
|
-
onValueChange?: (value: T, values: any, form: FormInstance) => void;
|
|
212
|
-
/** trigger when any item's value changed */
|
|
213
|
-
if?: (values: Record<string, any>) => boolean;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* FormItem, can be used without Form.
|
|
217
|
-
*
|
|
218
|
-
* ```ts
|
|
219
|
-
* // use inline type
|
|
220
|
-
* <FormItem type='string' id='name' />
|
|
221
|
-
*
|
|
222
|
-
* // use custom type
|
|
223
|
-
* <FormItem id='password'>
|
|
224
|
-
* <Input.Password />
|
|
225
|
-
* </>
|
|
226
|
-
* ```
|
|
227
|
-
*/
|
|
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
|
-
}
|
|
234
|
-
|
|
235
309
|
type FormSubmitProps = {
|
|
236
310
|
/** Default: Submit */
|
|
237
311
|
text?: string;
|
|
@@ -317,14 +391,6 @@ interface LinkProps {
|
|
|
317
391
|
*/
|
|
318
392
|
declare function Link({ href, target, text, children, style, button, }: LinkProps): JSX.Element;
|
|
319
393
|
|
|
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
394
|
interface ModalProps extends ModalProps$1 {
|
|
329
395
|
children?: JSX.Element | JSX.Element[] | string;
|
|
330
396
|
}
|
|
@@ -378,36 +444,6 @@ interface RoutesProps {
|
|
|
378
444
|
*/
|
|
379
445
|
declare function Routes(props: RoutesProps): JSX.Element;
|
|
380
446
|
|
|
381
|
-
interface TableItemProps<T = any> extends FaasItemProps, Omit<TableColumnProps<T>, 'title' | 'children'> {
|
|
382
|
-
optionsType?: 'auto';
|
|
383
|
-
children?: JSX.Element;
|
|
384
|
-
object?: TableItemProps[];
|
|
385
|
-
}
|
|
386
|
-
type ExtendTableTypeProps = {
|
|
387
|
-
children?: JSX.Element;
|
|
388
|
-
render?: (value: any, values: any, index: number) => JSX.Element | string | number | boolean | null;
|
|
389
|
-
};
|
|
390
|
-
type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
391
|
-
type TableProps<T = any, ExtendTypes = any> = {
|
|
392
|
-
items: (TableItemProps | (ExtendTypes & ExtendTableItemProps))[];
|
|
393
|
-
extendTypes?: {
|
|
394
|
-
[key: string]: ExtendTableTypeProps;
|
|
395
|
-
};
|
|
396
|
-
faasData?: FaasDataWrapperProps<T>;
|
|
397
|
-
onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<T> | SorterResult<T>[], extra: TableCurrentDataSource<T>) => {
|
|
398
|
-
pagination: TablePaginationConfig;
|
|
399
|
-
filters: Record<string, FilterValue | null>;
|
|
400
|
-
sorter: SorterResult<T> | SorterResult<T>[];
|
|
401
|
-
extra: TableCurrentDataSource<T>;
|
|
402
|
-
};
|
|
403
|
-
} & TableProps$1<T>;
|
|
404
|
-
/**
|
|
405
|
-
* Table component with Ant Design & FaasJS
|
|
406
|
-
*
|
|
407
|
-
* @ref https://ant.design/components/table/
|
|
408
|
-
*/
|
|
409
|
-
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
410
|
-
|
|
411
447
|
interface TitleProps {
|
|
412
448
|
title: string | string[];
|
|
413
449
|
/** ` - ` as default */
|
|
@@ -442,4 +478,4 @@ interface TitleProps {
|
|
|
442
478
|
*/
|
|
443
479
|
declare function Title(props: TitleProps): JSX.Element;
|
|
444
480
|
|
|
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 };
|
|
481
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, ConfigContext, ConfigProvider, ConfigProviderProps, Description, DescriptionItemContentProps, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, ExtendTypes, 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, useConfigContext, useDrawer, useModal };
|
package/dist/index.js
CHANGED
|
@@ -174,6 +174,10 @@ var import_react3 = require("@faasjs/react");
|
|
|
174
174
|
var import_antd2 = require("antd");
|
|
175
175
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
176
176
|
function Loading(props) {
|
|
177
|
+
if (props.loading === false)
|
|
178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
179
|
+
children: props.children
|
|
180
|
+
});
|
|
177
181
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
178
182
|
style: {
|
|
179
183
|
...props.style || {},
|
|
@@ -194,7 +198,9 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
194
198
|
function FaasDataWrapper(props) {
|
|
195
199
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Alert.ErrorBoundary, {
|
|
196
200
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.FaasDataWrapper, {
|
|
197
|
-
fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
|
|
201
|
+
fallback: props.loading || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
|
|
202
|
+
...props.loadingProps
|
|
203
|
+
}),
|
|
198
204
|
...props
|
|
199
205
|
})
|
|
200
206
|
});
|
|
@@ -238,25 +244,37 @@ function DescriptionItemContent(props) {
|
|
|
238
244
|
return (0, import_react4.cloneElement)(
|
|
239
245
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
240
246
|
{
|
|
247
|
+
scene: "description",
|
|
241
248
|
value: computedProps.value,
|
|
242
249
|
values: computedProps.values
|
|
243
250
|
}
|
|
244
251
|
);
|
|
245
252
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
246
253
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
247
|
-
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
|
|
254
|
+
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
|
|
248
255
|
});
|
|
249
256
|
else
|
|
250
257
|
throw Error(computedProps.item.type + " requires children or render");
|
|
258
|
+
if (computedProps.item.descriptionChildren === null)
|
|
259
|
+
return null;
|
|
260
|
+
if (computedProps.item.descriptionChildren)
|
|
261
|
+
return (0, import_react4.cloneElement)(computedProps.item.descriptionChildren, {
|
|
262
|
+
scene: "description",
|
|
263
|
+
value: computedProps.value,
|
|
264
|
+
values: computedProps.values
|
|
265
|
+
});
|
|
266
|
+
if (computedProps.item.children === null)
|
|
267
|
+
return null;
|
|
251
268
|
if (computedProps.item.children)
|
|
252
269
|
return (0, import_react4.cloneElement)(computedProps.item.children, {
|
|
270
|
+
scene: "description",
|
|
253
271
|
value: computedProps.value,
|
|
254
272
|
values: computedProps.values
|
|
255
273
|
});
|
|
274
|
+
if (computedProps.item.descriptionRender)
|
|
275
|
+
return computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description");
|
|
256
276
|
if (computedProps.item.render)
|
|
257
|
-
return
|
|
258
|
-
children: computedProps.item.render(computedProps.value, computedProps.values)
|
|
259
|
-
});
|
|
277
|
+
return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
|
|
260
278
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
261
279
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
262
280
|
switch (computedProps.item.type) {
|
|
@@ -331,9 +349,6 @@ function Description(props) {
|
|
|
331
349
|
}).filter(Boolean)
|
|
332
350
|
});
|
|
333
351
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
334
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Skeleton, {
|
|
335
|
-
active: true
|
|
336
|
-
}),
|
|
337
352
|
render: ({ data }) => {
|
|
338
353
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Descriptions, {
|
|
339
354
|
...props,
|
|
@@ -482,15 +497,29 @@ function FormItem(props) {
|
|
|
482
497
|
...computedProps,
|
|
483
498
|
children: extendTypes[computedProps.type].children
|
|
484
499
|
});
|
|
500
|
+
if (computedProps.formChildren === null)
|
|
501
|
+
return null;
|
|
502
|
+
if (computedProps.formChildren)
|
|
503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
504
|
+
...computedProps,
|
|
505
|
+
children: (0, import_react6.cloneElement)(computedProps.formChildren, { scene: "form" })
|
|
506
|
+
});
|
|
507
|
+
if (computedProps.children === null)
|
|
508
|
+
return null;
|
|
485
509
|
if (computedProps.children)
|
|
486
510
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
487
511
|
...computedProps,
|
|
488
|
-
children: computedProps.children
|
|
512
|
+
children: (0, import_react6.cloneElement)(computedProps.children, { scene: "form" })
|
|
513
|
+
});
|
|
514
|
+
if (computedProps.formRender)
|
|
515
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
516
|
+
...computedProps,
|
|
517
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
489
518
|
});
|
|
490
519
|
if (computedProps.render)
|
|
491
520
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
492
521
|
...computedProps,
|
|
493
|
-
children: computedProps.render()
|
|
522
|
+
children: computedProps.render(null, null, 0, "form")
|
|
494
523
|
});
|
|
495
524
|
switch (computedProps.type) {
|
|
496
525
|
case "string":
|
|
@@ -1061,10 +1090,24 @@ function Table(props) {
|
|
|
1061
1090
|
value: null
|
|
1062
1091
|
});
|
|
1063
1092
|
}
|
|
1064
|
-
if (item.
|
|
1093
|
+
if (item.tableChildren === null)
|
|
1094
|
+
item.render = () => null;
|
|
1095
|
+
else if (item.tableChildren)
|
|
1096
|
+
item.render = (value, values) => (0, import_react11.cloneElement)(
|
|
1097
|
+
item.tableChildren,
|
|
1098
|
+
{
|
|
1099
|
+
scene: "table",
|
|
1100
|
+
value,
|
|
1101
|
+
values
|
|
1102
|
+
}
|
|
1103
|
+
);
|
|
1104
|
+
else if (item.children === null)
|
|
1105
|
+
item.render = () => null;
|
|
1106
|
+
else if (item.children)
|
|
1065
1107
|
item.render = (value, values) => (0, import_react11.cloneElement)(
|
|
1066
1108
|
item.children,
|
|
1067
1109
|
{
|
|
1110
|
+
scene: "table",
|
|
1068
1111
|
value,
|
|
1069
1112
|
values
|
|
1070
1113
|
}
|
|
@@ -1074,6 +1117,7 @@ function Table(props) {
|
|
|
1074
1117
|
item.render = (value, values) => (0, import_react11.cloneElement)(
|
|
1075
1118
|
props.extendTypes[item.type].children,
|
|
1076
1119
|
{
|
|
1120
|
+
scene: "table",
|
|
1077
1121
|
value,
|
|
1078
1122
|
values
|
|
1079
1123
|
}
|
|
@@ -1299,11 +1343,13 @@ function Table(props) {
|
|
|
1299
1343
|
break;
|
|
1300
1344
|
case "object[]":
|
|
1301
1345
|
if (!item.render)
|
|
1302
|
-
item.render = (value) =>
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1346
|
+
item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
1347
|
+
children: value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
1348
|
+
items: item.object,
|
|
1349
|
+
dataSource: v || [],
|
|
1350
|
+
column: 1
|
|
1351
|
+
}, i))
|
|
1352
|
+
});
|
|
1307
1353
|
break;
|
|
1308
1354
|
default:
|
|
1309
1355
|
if (!item.render)
|
|
@@ -1351,9 +1397,6 @@ function Table(props) {
|
|
|
1351
1397
|
dataSource: props.dataSource
|
|
1352
1398
|
});
|
|
1353
1399
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
1354
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Skeleton, {
|
|
1355
|
-
active: true
|
|
1356
|
-
}),
|
|
1357
1400
|
...props.faasData,
|
|
1358
1401
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataTable, {
|
|
1359
1402
|
props,
|
package/dist/index.mjs
CHANGED
|
@@ -119,7 +119,6 @@ function transferValue(type, value) {
|
|
|
119
119
|
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
120
120
|
import {
|
|
121
121
|
Descriptions,
|
|
122
|
-
Skeleton,
|
|
123
122
|
Space
|
|
124
123
|
} from "antd";
|
|
125
124
|
import { isFunction, upperFirst as upperFirst2 } from "lodash-es";
|
|
@@ -134,8 +133,12 @@ import { FaasDataWrapper as Origin } from "@faasjs/react";
|
|
|
134
133
|
|
|
135
134
|
// src/Loading.tsx
|
|
136
135
|
import { Spin } from "antd";
|
|
137
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
136
|
+
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
138
137
|
function Loading(props) {
|
|
138
|
+
if (props.loading === false)
|
|
139
|
+
return /* @__PURE__ */ jsx3(Fragment, {
|
|
140
|
+
children: props.children
|
|
141
|
+
});
|
|
139
142
|
return /* @__PURE__ */ jsx3("div", {
|
|
140
143
|
style: {
|
|
141
144
|
...props.style || {},
|
|
@@ -156,14 +159,16 @@ import { jsx as jsx4 } from "react/jsx-runtime";
|
|
|
156
159
|
function FaasDataWrapper(props) {
|
|
157
160
|
return /* @__PURE__ */ jsx4(Alert.ErrorBoundary, {
|
|
158
161
|
children: /* @__PURE__ */ jsx4(Origin, {
|
|
159
|
-
fallback: /* @__PURE__ */ jsx4(Loading, {
|
|
162
|
+
fallback: props.loading || /* @__PURE__ */ jsx4(Loading, {
|
|
163
|
+
...props.loadingProps
|
|
164
|
+
}),
|
|
160
165
|
...props
|
|
161
166
|
})
|
|
162
167
|
});
|
|
163
168
|
}
|
|
164
169
|
|
|
165
170
|
// src/Description.tsx
|
|
166
|
-
import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
|
|
171
|
+
import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
|
|
167
172
|
function DescriptionItemContent(props) {
|
|
168
173
|
var _a;
|
|
169
174
|
const [computedProps, setComputedProps] = useState2();
|
|
@@ -200,36 +205,48 @@ function DescriptionItemContent(props) {
|
|
|
200
205
|
return cloneElement(
|
|
201
206
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
202
207
|
{
|
|
208
|
+
scene: "description",
|
|
203
209
|
value: computedProps.value,
|
|
204
210
|
values: computedProps.values
|
|
205
211
|
}
|
|
206
212
|
);
|
|
207
213
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
208
|
-
return /* @__PURE__ */ jsx5(
|
|
209
|
-
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
|
|
214
|
+
return /* @__PURE__ */ jsx5(Fragment2, {
|
|
215
|
+
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
|
|
210
216
|
});
|
|
211
217
|
else
|
|
212
218
|
throw Error(computedProps.item.type + " requires children or render");
|
|
219
|
+
if (computedProps.item.descriptionChildren === null)
|
|
220
|
+
return null;
|
|
221
|
+
if (computedProps.item.descriptionChildren)
|
|
222
|
+
return cloneElement(computedProps.item.descriptionChildren, {
|
|
223
|
+
scene: "description",
|
|
224
|
+
value: computedProps.value,
|
|
225
|
+
values: computedProps.values
|
|
226
|
+
});
|
|
227
|
+
if (computedProps.item.children === null)
|
|
228
|
+
return null;
|
|
213
229
|
if (computedProps.item.children)
|
|
214
230
|
return cloneElement(computedProps.item.children, {
|
|
231
|
+
scene: "description",
|
|
215
232
|
value: computedProps.value,
|
|
216
233
|
values: computedProps.values
|
|
217
234
|
});
|
|
235
|
+
if (computedProps.item.descriptionRender)
|
|
236
|
+
return computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description");
|
|
218
237
|
if (computedProps.item.render)
|
|
219
|
-
return
|
|
220
|
-
children: computedProps.item.render(computedProps.value, computedProps.values)
|
|
221
|
-
});
|
|
238
|
+
return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
|
|
222
239
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
223
240
|
return /* @__PURE__ */ jsx5(Blank, {});
|
|
224
241
|
switch (computedProps.item.type) {
|
|
225
242
|
case "string[]":
|
|
226
|
-
return /* @__PURE__ */ jsx5(
|
|
243
|
+
return /* @__PURE__ */ jsx5(Fragment2, {
|
|
227
244
|
children: computedProps.value.join(", ")
|
|
228
245
|
});
|
|
229
246
|
case "number":
|
|
230
247
|
return computedProps.value || null;
|
|
231
248
|
case "number[]":
|
|
232
|
-
return /* @__PURE__ */ jsx5(
|
|
249
|
+
return /* @__PURE__ */ jsx5(Fragment2, {
|
|
233
250
|
children: computedProps.value.join(", ")
|
|
234
251
|
});
|
|
235
252
|
case "boolean":
|
|
@@ -245,11 +262,11 @@ function DescriptionItemContent(props) {
|
|
|
245
262
|
}
|
|
246
263
|
});
|
|
247
264
|
case "time":
|
|
248
|
-
return /* @__PURE__ */ jsx5(
|
|
265
|
+
return /* @__PURE__ */ jsx5(Fragment2, {
|
|
249
266
|
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
250
267
|
});
|
|
251
268
|
case "date":
|
|
252
|
-
return /* @__PURE__ */ jsx5(
|
|
269
|
+
return /* @__PURE__ */ jsx5(Fragment2, {
|
|
253
270
|
children: computedProps.value.format("YYYY-MM-DD")
|
|
254
271
|
});
|
|
255
272
|
case "object":
|
|
@@ -293,9 +310,6 @@ function Description(props) {
|
|
|
293
310
|
}).filter(Boolean)
|
|
294
311
|
});
|
|
295
312
|
return /* @__PURE__ */ jsx5(FaasDataWrapper, {
|
|
296
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ jsx5(Skeleton, {
|
|
297
|
-
active: true
|
|
298
|
-
}),
|
|
299
313
|
render: ({ data }) => {
|
|
300
314
|
return /* @__PURE__ */ jsx5(Descriptions, {
|
|
301
315
|
...props,
|
|
@@ -372,11 +386,12 @@ import {
|
|
|
372
386
|
} from "antd";
|
|
373
387
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
374
388
|
import {
|
|
389
|
+
cloneElement as cloneElement2,
|
|
375
390
|
useEffect as useEffect3,
|
|
376
391
|
useState as useState4
|
|
377
392
|
} from "react";
|
|
378
393
|
import { upperFirst as upperFirst3 } from "lodash-es";
|
|
379
|
-
import { Fragment as
|
|
394
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs } from "react/jsx-runtime";
|
|
380
395
|
function processProps(propsCopy, config) {
|
|
381
396
|
if (!propsCopy.title)
|
|
382
397
|
propsCopy.title = upperFirst3(propsCopy.id);
|
|
@@ -466,15 +481,29 @@ function FormItem(props) {
|
|
|
466
481
|
...computedProps,
|
|
467
482
|
children: extendTypes[computedProps.type].children
|
|
468
483
|
});
|
|
484
|
+
if (computedProps.formChildren === null)
|
|
485
|
+
return null;
|
|
486
|
+
if (computedProps.formChildren)
|
|
487
|
+
return /* @__PURE__ */ jsx7(AntdForm.Item, {
|
|
488
|
+
...computedProps,
|
|
489
|
+
children: cloneElement2(computedProps.formChildren, { scene: "form" })
|
|
490
|
+
});
|
|
491
|
+
if (computedProps.children === null)
|
|
492
|
+
return null;
|
|
469
493
|
if (computedProps.children)
|
|
470
494
|
return /* @__PURE__ */ jsx7(AntdForm.Item, {
|
|
471
495
|
...computedProps,
|
|
472
|
-
children: computedProps.children
|
|
496
|
+
children: cloneElement2(computedProps.children, { scene: "form" })
|
|
497
|
+
});
|
|
498
|
+
if (computedProps.formRender)
|
|
499
|
+
return /* @__PURE__ */ jsx7(AntdForm.Item, {
|
|
500
|
+
...computedProps,
|
|
501
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
473
502
|
});
|
|
474
503
|
if (computedProps.render)
|
|
475
504
|
return /* @__PURE__ */ jsx7(AntdForm.Item, {
|
|
476
505
|
...computedProps,
|
|
477
|
-
children: computedProps.render()
|
|
506
|
+
children: computedProps.render(null, null, 0, "form")
|
|
478
507
|
});
|
|
479
508
|
switch (computedProps.type) {
|
|
480
509
|
case "string":
|
|
@@ -500,7 +529,7 @@ function FormItem(props) {
|
|
|
500
529
|
rules: computedProps.rules,
|
|
501
530
|
children: (fields, { add, remove }, { errors }) => {
|
|
502
531
|
var _a2;
|
|
503
|
-
return /* @__PURE__ */ jsxs(
|
|
532
|
+
return /* @__PURE__ */ jsxs(Fragment3, {
|
|
504
533
|
children: [
|
|
505
534
|
computedProps.label && /* @__PURE__ */ jsx7("div", {
|
|
506
535
|
className: "ant-form-item-label",
|
|
@@ -581,7 +610,7 @@ function FormItem(props) {
|
|
|
581
610
|
rules: computedProps.rules,
|
|
582
611
|
children: (fields, { add, remove }, { errors }) => {
|
|
583
612
|
var _a2, _b;
|
|
584
|
-
return /* @__PURE__ */ jsxs(
|
|
613
|
+
return /* @__PURE__ */ jsxs(Fragment3, {
|
|
585
614
|
children: [
|
|
586
615
|
computedProps.label && /* @__PURE__ */ jsx7("div", {
|
|
587
616
|
className: "ant-form-item-label",
|
|
@@ -661,7 +690,7 @@ function FormItem(props) {
|
|
|
661
690
|
})
|
|
662
691
|
});
|
|
663
692
|
case "object":
|
|
664
|
-
return /* @__PURE__ */ jsxs(
|
|
693
|
+
return /* @__PURE__ */ jsxs(Fragment3, {
|
|
665
694
|
children: [
|
|
666
695
|
computedProps.label && /* @__PURE__ */ jsx7("div", {
|
|
667
696
|
className: "ant-form-item-label",
|
|
@@ -679,7 +708,7 @@ function FormItem(props) {
|
|
|
679
708
|
return /* @__PURE__ */ jsx7(AntdForm.List, {
|
|
680
709
|
name: computedProps.name,
|
|
681
710
|
rules: computedProps.rules,
|
|
682
|
-
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(
|
|
711
|
+
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs(Fragment3, {
|
|
683
712
|
children: [
|
|
684
713
|
fields.map((field) => /* @__PURE__ */ jsxs(AntdForm.Item, {
|
|
685
714
|
style: { marginBottom: 0 },
|
|
@@ -956,7 +985,7 @@ function useModal(init) {
|
|
|
956
985
|
// src/Routers.tsx
|
|
957
986
|
import {
|
|
958
987
|
Result,
|
|
959
|
-
Skeleton
|
|
988
|
+
Skeleton,
|
|
960
989
|
Alert as Alert2
|
|
961
990
|
} from "antd";
|
|
962
991
|
import {
|
|
@@ -983,7 +1012,7 @@ function Routes(props) {
|
|
|
983
1012
|
element: r.element || /* @__PURE__ */ jsx11(Suspense, {
|
|
984
1013
|
fallback: props.fallback || /* @__PURE__ */ jsx11("div", {
|
|
985
1014
|
style: { padding: "24px" },
|
|
986
|
-
children: /* @__PURE__ */ jsx11(
|
|
1015
|
+
children: /* @__PURE__ */ jsx11(Skeleton, {
|
|
987
1016
|
active: true
|
|
988
1017
|
})
|
|
989
1018
|
}),
|
|
@@ -1003,12 +1032,11 @@ function Routes(props) {
|
|
|
1003
1032
|
import {
|
|
1004
1033
|
useState as useState7,
|
|
1005
1034
|
useEffect as useEffect5,
|
|
1006
|
-
cloneElement as
|
|
1035
|
+
cloneElement as cloneElement3
|
|
1007
1036
|
} from "react";
|
|
1008
1037
|
import {
|
|
1009
1038
|
Table as AntdTable,
|
|
1010
1039
|
Radio,
|
|
1011
|
-
Skeleton as Skeleton3,
|
|
1012
1040
|
Input as Input2
|
|
1013
1041
|
} from "antd";
|
|
1014
1042
|
import dayjs2 from "dayjs";
|
|
@@ -1018,7 +1046,7 @@ import {
|
|
|
1018
1046
|
uniqBy,
|
|
1019
1047
|
upperFirst as upperFirst4
|
|
1020
1048
|
} from "lodash-es";
|
|
1021
|
-
import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1049
|
+
import { Fragment as Fragment4, jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1022
1050
|
function processValue(item, value) {
|
|
1023
1051
|
var _a;
|
|
1024
1052
|
const transferred = transferValue(item.type, value);
|
|
@@ -1067,19 +1095,34 @@ function Table(props) {
|
|
|
1067
1095
|
value: null
|
|
1068
1096
|
});
|
|
1069
1097
|
}
|
|
1070
|
-
if (item.
|
|
1071
|
-
item.render = (
|
|
1098
|
+
if (item.tableChildren === null)
|
|
1099
|
+
item.render = () => null;
|
|
1100
|
+
else if (item.tableChildren)
|
|
1101
|
+
item.render = (value, values) => cloneElement3(
|
|
1102
|
+
item.tableChildren,
|
|
1103
|
+
{
|
|
1104
|
+
scene: "table",
|
|
1105
|
+
value,
|
|
1106
|
+
values
|
|
1107
|
+
}
|
|
1108
|
+
);
|
|
1109
|
+
else if (item.children === null)
|
|
1110
|
+
item.render = () => null;
|
|
1111
|
+
else if (item.children)
|
|
1112
|
+
item.render = (value, values) => cloneElement3(
|
|
1072
1113
|
item.children,
|
|
1073
1114
|
{
|
|
1115
|
+
scene: "table",
|
|
1074
1116
|
value,
|
|
1075
1117
|
values
|
|
1076
1118
|
}
|
|
1077
1119
|
);
|
|
1078
1120
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1079
1121
|
if (props.extendTypes[item.type].children)
|
|
1080
|
-
item.render = (value, values) =>
|
|
1122
|
+
item.render = (value, values) => cloneElement3(
|
|
1081
1123
|
props.extendTypes[item.type].children,
|
|
1082
1124
|
{
|
|
1125
|
+
scene: "table",
|
|
1083
1126
|
value,
|
|
1084
1127
|
values
|
|
1085
1128
|
}
|
|
@@ -1305,11 +1348,13 @@ function Table(props) {
|
|
|
1305
1348
|
break;
|
|
1306
1349
|
case "object[]":
|
|
1307
1350
|
if (!item.render)
|
|
1308
|
-
item.render = (value) =>
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1351
|
+
item.render = (value) => /* @__PURE__ */ jsx12(Fragment4, {
|
|
1352
|
+
children: value.map((v, i) => /* @__PURE__ */ jsx12(Description, {
|
|
1353
|
+
items: item.object,
|
|
1354
|
+
dataSource: v || [],
|
|
1355
|
+
column: 1
|
|
1356
|
+
}, i))
|
|
1357
|
+
});
|
|
1313
1358
|
break;
|
|
1314
1359
|
default:
|
|
1315
1360
|
if (!item.render)
|
|
@@ -1357,9 +1402,6 @@ function Table(props) {
|
|
|
1357
1402
|
dataSource: props.dataSource
|
|
1358
1403
|
});
|
|
1359
1404
|
return /* @__PURE__ */ jsx12(FaasDataWrapper, {
|
|
1360
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ jsx12(Skeleton3, {
|
|
1361
|
-
active: true
|
|
1362
|
-
}),
|
|
1363
1405
|
...props.faasData,
|
|
1364
1406
|
children: /* @__PURE__ */ jsx12(FaasDataTable, {
|
|
1365
1407
|
props,
|
|
@@ -1455,8 +1497,8 @@ function FaasDataTable({
|
|
|
1455
1497
|
}
|
|
1456
1498
|
|
|
1457
1499
|
// src/Title.tsx
|
|
1458
|
-
import { useEffect as useEffect6, cloneElement as
|
|
1459
|
-
import { Fragment as
|
|
1500
|
+
import { useEffect as useEffect6, cloneElement as cloneElement4 } from "react";
|
|
1501
|
+
import { Fragment as Fragment5, jsx as jsx13 } from "react/jsx-runtime";
|
|
1460
1502
|
function Title(props) {
|
|
1461
1503
|
const { Title: Title2 } = useConfigContext();
|
|
1462
1504
|
useEffect6(() => {
|
|
@@ -1475,11 +1517,11 @@ function Title(props) {
|
|
|
1475
1517
|
});
|
|
1476
1518
|
}
|
|
1477
1519
|
if (props.plain)
|
|
1478
|
-
return /* @__PURE__ */ jsx13(
|
|
1520
|
+
return /* @__PURE__ */ jsx13(Fragment5, {
|
|
1479
1521
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1480
1522
|
});
|
|
1481
1523
|
if (props.children)
|
|
1482
|
-
return
|
|
1524
|
+
return cloneElement4(props.children, { title: props.title });
|
|
1483
1525
|
return null;
|
|
1484
1526
|
}
|
|
1485
1527
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.3-beta.
|
|
3
|
+
"version": "0.0.3-beta.32",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash-es": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.3-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.3-beta.32",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|