@faasjs/ant-design 0.0.2-beta.436 → 0.0.2-beta.438
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 +24 -8
- package/dist/index.d.ts +15 -12
- package/dist/index.js +11 -8
- package/dist/index.mjs +11 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -18,7 +18,9 @@ In `@faasjs/ant-design`, we use `FaasItemProps` to provide data structures for c
|
|
|
18
18
|
type FaasItemType =
|
|
19
19
|
'string' | 'string[]' |
|
|
20
20
|
'number' | 'number[]' |
|
|
21
|
-
'boolean'
|
|
21
|
+
'boolean' |
|
|
22
|
+
'date' | 'time' |
|
|
23
|
+
'object' | 'object[]'
|
|
22
24
|
|
|
23
25
|
type FaasItemProps = {
|
|
24
26
|
type: FaasItemTypes
|
|
@@ -181,7 +183,7 @@ ___
|
|
|
181
183
|
|
|
182
184
|
### DescriptionItemProps
|
|
183
185
|
|
|
184
|
-
Ƭ **DescriptionItemProps**<`T`\>: { `children?`: `JSX.Element` ; `render?`: (`value`: `T`, `values`: `any`) => `
|
|
186
|
+
Ƭ **DescriptionItemProps**<`T`\>: { `children?`: `JSX.Element` ; `render?`: (`value`: `T`, `values`: `any`) => `ReactNode` \| `JSX.Element` } & [`FaasItemProps`](#faasitemprops) & { `object?`: [`DescriptionItemProps`](#descriptionitemprops)[] }
|
|
185
187
|
|
|
186
188
|
#### Type parameters
|
|
187
189
|
|
|
@@ -193,7 +195,7 @@ ___
|
|
|
193
195
|
|
|
194
196
|
### DescriptionProps
|
|
195
197
|
|
|
196
|
-
Ƭ **DescriptionProps**<`T`, `ExtendItemProps`\>: { `dataSource?`: `T` ; `extendTypes?`: { `[key: string]`: [`ExtendDescriptionTypeProps`](#extenddescriptiontypeprops); } ; `faasData?`: `FaasDataWrapperProps`<`T`\> ; `items`: ([`DescriptionItemProps`](#descriptionitemprops) \| `ExtendItemProps`)[] ; `renderTitle?`: (`values`: `T`) => `ReactNode` } & `DescriptionsProps`
|
|
198
|
+
Ƭ **DescriptionProps**<`T`, `ExtendItemProps`\>: { `dataSource?`: `T` ; `extendTypes?`: { `[key: string]`: [`ExtendDescriptionTypeProps`](#extenddescriptiontypeprops); } ; `faasData?`: `FaasDataWrapperProps`<`T`\> ; `items`: ([`DescriptionItemProps`](#descriptionitemprops) \| `ExtendItemProps`)[] ; `renderTitle?`: (`values`: `T`) => `ReactNode` \| `JSX.Element` } & `DescriptionsProps`
|
|
197
199
|
|
|
198
200
|
#### Type parameters
|
|
199
201
|
|
|
@@ -225,7 +227,7 @@ ___
|
|
|
225
227
|
| Name | Type |
|
|
226
228
|
| :------ | :------ |
|
|
227
229
|
| `children?` | `JSX.Element` \| ``null`` |
|
|
228
|
-
| `render?` | (`value`: `any`, `values`: `any`) => `
|
|
230
|
+
| `render?` | (`value`: `any`, `values`: `any`) => `ReactNode` \| `JSX.Element` |
|
|
229
231
|
|
|
230
232
|
___
|
|
231
233
|
|
|
@@ -243,7 +245,7 @@ ___
|
|
|
243
245
|
|
|
244
246
|
| Name | Type |
|
|
245
247
|
| :------ | :------ |
|
|
246
|
-
| `children?` | `
|
|
248
|
+
| `children?` | `ReactNode` |
|
|
247
249
|
|
|
248
250
|
___
|
|
249
251
|
|
|
@@ -298,6 +300,8 @@ ___
|
|
|
298
300
|
|
|
299
301
|
Ƭ **FaasItemTypeValue**: `Object`
|
|
300
302
|
|
|
303
|
+
FaasItemType's value type
|
|
304
|
+
|
|
301
305
|
#### Type declaration
|
|
302
306
|
|
|
303
307
|
| Name | Type |
|
|
@@ -316,7 +320,7 @@ ___
|
|
|
316
320
|
|
|
317
321
|
### FormItemProps
|
|
318
322
|
|
|
319
|
-
Ƭ **FormItemProps**<`T`\>: { `children?`: `
|
|
323
|
+
Ƭ **FormItemProps**<`T`\>: { `children?`: `ReactNode` ; `extendTypes?`: [`ExtendTypes`](#extendtypes) ; `label?`: `string` \| ``false`` ; `render?`: (`value?`: `any`) => `ReactNode` \| `JSX.Element` ; `rules?`: `RuleObject`[] } & `FormItemInputProps` & [`FaasItemProps`](#faasitemprops) & `Omit`<`AntdFormItemProps`<`T`\>, ``"children"``\>
|
|
320
324
|
|
|
321
325
|
#### Type parameters
|
|
322
326
|
|
|
@@ -479,7 +483,7 @@ ___
|
|
|
479
483
|
|
|
480
484
|
### Blank
|
|
481
485
|
|
|
482
|
-
▸ **Blank**(`options?`): `
|
|
486
|
+
▸ **Blank**(`options?`): `JSX.Element`
|
|
483
487
|
|
|
484
488
|
If value is undefined or null, return text, otherwise return value.
|
|
485
489
|
|
|
@@ -491,7 +495,7 @@ If value is undefined or null, return text, otherwise return value.
|
|
|
491
495
|
|
|
492
496
|
#### Returns
|
|
493
497
|
|
|
494
|
-
`
|
|
498
|
+
`JSX.Element`
|
|
495
499
|
|
|
496
500
|
```ts
|
|
497
501
|
<Blank value={undefined} text="Empty" />
|
|
@@ -571,6 +575,12 @@ ___
|
|
|
571
575
|
|
|
572
576
|
▸ **Form**<`Values`\>(`props`): `Element`
|
|
573
577
|
|
|
578
|
+
Form component with Ant Design & FaasJS
|
|
579
|
+
|
|
580
|
+
**`Ref`**
|
|
581
|
+
|
|
582
|
+
https://ant.design/components/form/
|
|
583
|
+
|
|
574
584
|
#### Type parameters
|
|
575
585
|
|
|
576
586
|
| Name | Type |
|
|
@@ -695,6 +705,12 @@ ___
|
|
|
695
705
|
|
|
696
706
|
▸ **Table**<`T`, `ExtendTypes`\>(`props`): `Element`
|
|
697
707
|
|
|
708
|
+
Table component with Ant Design & FaasJS
|
|
709
|
+
|
|
710
|
+
**`Ref`**
|
|
711
|
+
|
|
712
|
+
https://ant.design/components/table/
|
|
713
|
+
|
|
698
714
|
#### Type parameters
|
|
699
715
|
|
|
700
716
|
| Name | Type |
|
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ declare function ConfigProvider({ config, children }: {
|
|
|
89
89
|
declare function useConfigContext(): ConfigProviderProps;
|
|
90
90
|
|
|
91
91
|
declare type FaasItemType = 'string' | 'string[]' | 'number' | 'number[]' | 'boolean' | 'date' | 'time' | 'object' | 'object[]';
|
|
92
|
+
/** FaasItemType's value type */
|
|
92
93
|
declare type FaasItemTypeValue = {
|
|
93
94
|
string: string;
|
|
94
95
|
'string[]': string[];
|
|
@@ -187,45 +188,36 @@ declare function useDrawer(init?: DrawerProps): {
|
|
|
187
188
|
declare type StringProps = {
|
|
188
189
|
type?: 'string';
|
|
189
190
|
input?: InputProps;
|
|
190
|
-
required?: boolean;
|
|
191
191
|
};
|
|
192
192
|
declare type StringListProps = {
|
|
193
193
|
type: 'string[]';
|
|
194
194
|
input?: InputProps;
|
|
195
195
|
maxCount?: number;
|
|
196
|
-
required?: boolean;
|
|
197
196
|
};
|
|
198
197
|
declare type NumberProps = {
|
|
199
198
|
type: 'number';
|
|
200
199
|
input?: InputNumberProps;
|
|
201
|
-
required?: boolean;
|
|
202
200
|
};
|
|
203
201
|
declare type NumberListProps = {
|
|
204
202
|
type: 'number[]';
|
|
205
203
|
input?: InputNumberProps;
|
|
206
204
|
maxCount?: number;
|
|
207
|
-
required?: boolean;
|
|
208
205
|
};
|
|
209
206
|
declare type BooleanProps = {
|
|
210
207
|
type: 'boolean';
|
|
211
208
|
input?: SwitchProps;
|
|
212
|
-
required?: boolean;
|
|
213
209
|
};
|
|
214
210
|
declare type DateProps = {
|
|
215
211
|
type: 'date';
|
|
216
212
|
input?: DatePickerProps$1;
|
|
217
|
-
required?: boolean;
|
|
218
213
|
};
|
|
219
214
|
declare type TimeProps = {
|
|
220
215
|
type: 'time';
|
|
221
216
|
input?: TimePickerProps$1;
|
|
222
|
-
required?: boolean;
|
|
223
217
|
};
|
|
224
218
|
declare type ObjectProps = {
|
|
225
219
|
type: 'object';
|
|
226
220
|
object: FormItemProps[];
|
|
227
|
-
disabled?: boolean;
|
|
228
|
-
required?: boolean;
|
|
229
221
|
};
|
|
230
222
|
declare type ObjectListProps = {
|
|
231
223
|
type: 'object[]';
|
|
@@ -234,15 +226,16 @@ declare type ObjectListProps = {
|
|
|
234
226
|
col?: number;
|
|
235
227
|
})[];
|
|
236
228
|
maxCount?: number;
|
|
237
|
-
disabled?: boolean;
|
|
238
|
-
required?: boolean;
|
|
239
229
|
};
|
|
240
230
|
declare type OptionsProps = {
|
|
241
231
|
options?: BaseOption[];
|
|
242
232
|
type?: 'string' | 'string[]' | 'number' | 'number[]';
|
|
243
233
|
input?: SelectProps<any>;
|
|
244
234
|
};
|
|
245
|
-
declare type FormItemInputProps = StringProps | StringListProps | NumberProps | NumberListProps | BooleanProps | OptionsProps | DateProps | TimeProps | ObjectProps | ObjectListProps
|
|
235
|
+
declare type FormItemInputProps = (StringProps | StringListProps | NumberProps | NumberListProps | BooleanProps | OptionsProps | DateProps | TimeProps | ObjectProps | ObjectListProps) & {
|
|
236
|
+
disabled?: boolean;
|
|
237
|
+
required?: boolean;
|
|
238
|
+
};
|
|
246
239
|
declare type ExtendFormTypeProps = {
|
|
247
240
|
children?: ReactNode;
|
|
248
241
|
};
|
|
@@ -315,6 +308,11 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
315
308
|
extendTypes?: ExtendTypes;
|
|
316
309
|
children?: ReactNode;
|
|
317
310
|
} & Omit<FormProps$1<Values>, 'onFinish' | 'children'>;
|
|
311
|
+
/**
|
|
312
|
+
* Form component with Ant Design & FaasJS
|
|
313
|
+
*
|
|
314
|
+
* @ref https://ant.design/components/form/
|
|
315
|
+
*/
|
|
318
316
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
319
317
|
declare namespace Form {
|
|
320
318
|
var useForm: typeof antd_lib_form_Form.useForm;
|
|
@@ -416,6 +414,11 @@ declare type TableProps<T = any, ExtendTypes = any> = {
|
|
|
416
414
|
extra: TableCurrentDataSource<T>;
|
|
417
415
|
};
|
|
418
416
|
} & TableProps$1<T>;
|
|
417
|
+
/**
|
|
418
|
+
* Table component with Ant Design & FaasJS
|
|
419
|
+
*
|
|
420
|
+
* @ref https://ant.design/components/table/
|
|
421
|
+
*/
|
|
419
422
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
420
423
|
|
|
421
424
|
declare type TimePickerProps = Omit<PickerTimeProps<Dayjs>, 'picker'>;
|
package/dist/index.js
CHANGED
|
@@ -923,21 +923,25 @@ var import_react13 = require("@faasjs/react");
|
|
|
923
923
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
924
924
|
function processValue(item, value) {
|
|
925
925
|
var _a;
|
|
926
|
-
if (typeof value === "undefined" || value === null || value === "")
|
|
926
|
+
if (typeof value === "undefined" || value === null || value === "" || Array.isArray(value) && !value.length)
|
|
927
927
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Blank, {});
|
|
928
|
+
if (item.type.endsWith("[]") && typeof value === "string")
|
|
929
|
+
value = value.split(",");
|
|
928
930
|
if (item.options) {
|
|
929
931
|
if (item.type.endsWith("[]"))
|
|
930
932
|
return value.map((v) => {
|
|
931
933
|
var _a2;
|
|
932
934
|
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
+
}).join(", ");
|
|
936
|
+
if ([
|
|
935
937
|
"string",
|
|
936
938
|
"number",
|
|
937
939
|
"boolean"
|
|
938
940
|
].includes(item.type))
|
|
939
941
|
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
940
942
|
}
|
|
943
|
+
if (item.type.endsWith("[]"))
|
|
944
|
+
return value.join(", ");
|
|
941
945
|
if (["date", "time"].includes(item.type)) {
|
|
942
946
|
if (typeof value === "number" && value.toString().length === 10)
|
|
943
947
|
value = value * 1e3;
|
|
@@ -969,7 +973,7 @@ function Table(props) {
|
|
|
969
973
|
if (item.children)
|
|
970
974
|
delete item.children;
|
|
971
975
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
972
|
-
if (props.extendTypes[item.type].children)
|
|
976
|
+
if (props.extendTypes[item.type].children)
|
|
973
977
|
item.render = (value, values) => (0, import_react12.cloneElement)(
|
|
974
978
|
props.extendTypes[item.type].children,
|
|
975
979
|
{
|
|
@@ -977,7 +981,7 @@ function Table(props) {
|
|
|
977
981
|
values
|
|
978
982
|
}
|
|
979
983
|
);
|
|
980
|
-
|
|
984
|
+
else if (props.extendTypes[item.type].render)
|
|
981
985
|
item.render = props.extendTypes[item.type].render;
|
|
982
986
|
else
|
|
983
987
|
throw Error(item.type + " requires children or render");
|
|
@@ -987,13 +991,12 @@ function Table(props) {
|
|
|
987
991
|
case "string":
|
|
988
992
|
if (!item.render)
|
|
989
993
|
item.render = (value) => processValue(item, value);
|
|
990
|
-
if (!item.onFilter)
|
|
994
|
+
if (!item.onFilter)
|
|
991
995
|
item.onFilter = (value, row) => {
|
|
992
996
|
if (!row[item.id])
|
|
993
997
|
return false;
|
|
994
998
|
return row[item.id].includes(value);
|
|
995
999
|
};
|
|
996
|
-
}
|
|
997
1000
|
if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
|
|
998
1001
|
item.filterDropdown = ({
|
|
999
1002
|
setSelectedKeys,
|
|
@@ -1017,7 +1020,7 @@ function Table(props) {
|
|
|
1017
1020
|
break;
|
|
1018
1021
|
case "string[]":
|
|
1019
1022
|
if (!item.render)
|
|
1020
|
-
item.render = (value) => processValue(item, value)
|
|
1023
|
+
item.render = (value) => processValue(item, value);
|
|
1021
1024
|
if (!item.onFilter)
|
|
1022
1025
|
item.onFilter = (value, row) => {
|
|
1023
1026
|
if (!row[item.id] || !row[item.id].length)
|
package/dist/index.mjs
CHANGED
|
@@ -921,21 +921,25 @@ import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
|
921
921
|
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
922
922
|
function processValue(item, value) {
|
|
923
923
|
var _a;
|
|
924
|
-
if (typeof value === "undefined" || value === null || value === "")
|
|
924
|
+
if (typeof value === "undefined" || value === null || value === "" || Array.isArray(value) && !value.length)
|
|
925
925
|
return /* @__PURE__ */ jsx11(Blank, {});
|
|
926
|
+
if (item.type.endsWith("[]") && typeof value === "string")
|
|
927
|
+
value = value.split(",");
|
|
926
928
|
if (item.options) {
|
|
927
929
|
if (item.type.endsWith("[]"))
|
|
928
930
|
return value.map((v) => {
|
|
929
931
|
var _a2;
|
|
930
932
|
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
931
|
-
});
|
|
932
|
-
|
|
933
|
+
}).join(", ");
|
|
934
|
+
if ([
|
|
933
935
|
"string",
|
|
934
936
|
"number",
|
|
935
937
|
"boolean"
|
|
936
938
|
].includes(item.type))
|
|
937
939
|
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
938
940
|
}
|
|
941
|
+
if (item.type.endsWith("[]"))
|
|
942
|
+
return value.join(", ");
|
|
939
943
|
if (["date", "time"].includes(item.type)) {
|
|
940
944
|
if (typeof value === "number" && value.toString().length === 10)
|
|
941
945
|
value = value * 1e3;
|
|
@@ -967,7 +971,7 @@ function Table(props) {
|
|
|
967
971
|
if (item.children)
|
|
968
972
|
delete item.children;
|
|
969
973
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
970
|
-
if (props.extendTypes[item.type].children)
|
|
974
|
+
if (props.extendTypes[item.type].children)
|
|
971
975
|
item.render = (value, values) => cloneElement2(
|
|
972
976
|
props.extendTypes[item.type].children,
|
|
973
977
|
{
|
|
@@ -975,7 +979,7 @@ function Table(props) {
|
|
|
975
979
|
values
|
|
976
980
|
}
|
|
977
981
|
);
|
|
978
|
-
|
|
982
|
+
else if (props.extendTypes[item.type].render)
|
|
979
983
|
item.render = props.extendTypes[item.type].render;
|
|
980
984
|
else
|
|
981
985
|
throw Error(item.type + " requires children or render");
|
|
@@ -985,13 +989,12 @@ function Table(props) {
|
|
|
985
989
|
case "string":
|
|
986
990
|
if (!item.render)
|
|
987
991
|
item.render = (value) => processValue(item, value);
|
|
988
|
-
if (!item.onFilter)
|
|
992
|
+
if (!item.onFilter)
|
|
989
993
|
item.onFilter = (value, row) => {
|
|
990
994
|
if (!row[item.id])
|
|
991
995
|
return false;
|
|
992
996
|
return row[item.id].includes(value);
|
|
993
997
|
};
|
|
994
|
-
}
|
|
995
998
|
if (!item.filters && item.filterDropdown !== false && item.optionsType !== "auto")
|
|
996
999
|
item.filterDropdown = ({
|
|
997
1000
|
setSelectedKeys,
|
|
@@ -1015,7 +1018,7 @@ function Table(props) {
|
|
|
1015
1018
|
break;
|
|
1016
1019
|
case "string[]":
|
|
1017
1020
|
if (!item.render)
|
|
1018
|
-
item.render = (value) => processValue(item, value)
|
|
1021
|
+
item.render = (value) => processValue(item, value);
|
|
1019
1022
|
if (!item.onFilter)
|
|
1020
1023
|
item.onFilter = (value, row) => {
|
|
1021
1024
|
if (!row[item.id] || !row[item.id].length)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.438",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.438",
|
|
32
32
|
"react-router-dom": "*",
|
|
33
33
|
"dayjs": "*"
|
|
34
34
|
},
|