@faasjs/ant-design 0.0.2-beta.339 → 0.0.2-beta.343
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/dist/index.d.ts +37 -23
- package/dist/index.js +61 -25
- package/dist/index.mjs +62 -26
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -23,20 +23,25 @@ declare type FaasItemProps = BaseItemType & {
|
|
|
23
23
|
type?: FaasItemType;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
declare type
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
30
|
-
};
|
|
26
|
+
declare type ExtendDescriptionTypeProps = {
|
|
27
|
+
children?: JSX.Element | null;
|
|
28
|
+
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
31
29
|
};
|
|
30
|
+
declare type ExtendDescriptionItemProps = BaseItemType;
|
|
32
31
|
declare type DescriptionItemProps<T = any> = {
|
|
33
32
|
children?: JSX.Element;
|
|
34
33
|
render?: (value: T, values: any) => JSX.Element | string | number | boolean | null;
|
|
35
34
|
} & FaasItemProps;
|
|
36
35
|
declare type DescriptionProps<T = any, ExtendItemProps = any> = {
|
|
37
36
|
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
38
|
-
dataSource
|
|
39
|
-
|
|
37
|
+
dataSource?: T;
|
|
38
|
+
faasData?: {
|
|
39
|
+
action: string;
|
|
40
|
+
params?: Record<string, any>;
|
|
41
|
+
};
|
|
42
|
+
extendTypes?: {
|
|
43
|
+
[key: string]: ExtendDescriptionTypeProps;
|
|
44
|
+
};
|
|
40
45
|
} & DescriptionsProps;
|
|
41
46
|
declare function Description(props: DescriptionProps): JSX.Element;
|
|
42
47
|
|
|
@@ -74,16 +79,17 @@ declare type OptionsProps<T = any> = {
|
|
|
74
79
|
input?: SelectProps<any>;
|
|
75
80
|
};
|
|
76
81
|
declare type FormItemInputProps<T = any> = StringProps | StringListProps | NumberProps | NumberListProps | BooleanProps | OptionsProps<T>;
|
|
77
|
-
declare type
|
|
78
|
-
|
|
79
|
-
children?: JSX.Element | null;
|
|
80
|
-
};
|
|
82
|
+
declare type ExtendFormTypeProps = {
|
|
83
|
+
children?: JSX.Element | null;
|
|
81
84
|
};
|
|
85
|
+
declare type ExtendFormItemProps = BaseItemType & FormItemProps$1;
|
|
82
86
|
declare type FormItemProps<T = any> = {
|
|
83
87
|
children?: JSX.Element;
|
|
84
88
|
rules?: RuleObject[];
|
|
85
89
|
label?: string | false;
|
|
86
|
-
extendTypes?:
|
|
90
|
+
extendTypes?: {
|
|
91
|
+
[type: string]: ExtendFormTypeProps;
|
|
92
|
+
};
|
|
87
93
|
} & FormItemInputProps<T> & FaasItemProps & FormItemProps$1<T>;
|
|
88
94
|
declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
|
|
89
95
|
|
|
@@ -94,24 +100,32 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
|
|
|
94
100
|
/** Default: Submit */
|
|
95
101
|
text?: string;
|
|
96
102
|
};
|
|
97
|
-
extendTypes?:
|
|
103
|
+
extendTypes?: {
|
|
104
|
+
[type: string]: ExtendFormTypeProps;
|
|
105
|
+
};
|
|
98
106
|
} & FormProps$1<Values>;
|
|
99
107
|
declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
|
|
100
108
|
declare namespace Form {
|
|
101
109
|
var useForm: typeof antd_lib_form_Form.useForm;
|
|
110
|
+
var Item: typeof FormItem;
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
declare type TableItemProps<T = any> = FaasItemProps & TableColumnProps<T>;
|
|
105
|
-
declare type
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
declare type TableProps<T = any, ExtendTypes = any> = TableProps$1<T> & {
|
|
112
|
-
items: (TableItemProps | ExtendTypes)[];
|
|
113
|
-
extendTypes?: ExtendTableItemProps;
|
|
114
|
+
declare type ExtendTableTypeProps = {
|
|
115
|
+
children?: JSX.Element | null;
|
|
116
|
+
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
114
117
|
};
|
|
118
|
+
declare type ExtendTableItemProps<T = any> = BaseItemType & TableColumnProps<T>;
|
|
119
|
+
declare type TableProps<T = any, ExtendTypes = any> = {
|
|
120
|
+
items: (TableItemProps | (ExtendTypes & BaseItemType))[];
|
|
121
|
+
extendTypes?: {
|
|
122
|
+
[key: string]: ExtendTableTypeProps;
|
|
123
|
+
};
|
|
124
|
+
faasData?: {
|
|
125
|
+
action: string;
|
|
126
|
+
params?: Record<string, any>;
|
|
127
|
+
};
|
|
128
|
+
} & TableProps$1<T>;
|
|
115
129
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
116
130
|
|
|
117
|
-
export { BaseItemType, Description, DescriptionItemProps, DescriptionProps, ExtendDescriptionItemProps, ExtendFormItemProps, ExtendTableItemProps, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Table, TableItemProps, TableProps };
|
|
131
|
+
export { BaseItemType, Description, DescriptionItemProps, DescriptionProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Table, TableItemProps, TableProps };
|
package/dist/index.js
CHANGED
|
@@ -59,10 +59,34 @@ var import_react = __toESM(require("react"));
|
|
|
59
59
|
var import_icons = require("@ant-design/icons");
|
|
60
60
|
var import_antd = require("antd");
|
|
61
61
|
var import_lodash = require("lodash");
|
|
62
|
+
var import_react4 = require("react");
|
|
63
|
+
|
|
64
|
+
// src/FaasWrapper.tsx
|
|
62
65
|
var import_react2 = require("react");
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
var import_react3 = require("@faasjs/react");
|
|
67
|
+
function FaasDataWrapper({
|
|
68
|
+
dataSource,
|
|
69
|
+
faasData,
|
|
70
|
+
render,
|
|
71
|
+
fallback
|
|
72
|
+
}) {
|
|
73
|
+
const [data, setData] = (0, import_react2.useState)();
|
|
65
74
|
(0, import_react2.useEffect)(() => {
|
|
75
|
+
if (!faasData)
|
|
76
|
+
return;
|
|
77
|
+
(0, import_react3.getClient)().faas(faasData.action, faasData.action).then((res) => setData(res.data));
|
|
78
|
+
}, [JSON.stringify(faasData)]);
|
|
79
|
+
if (dataSource)
|
|
80
|
+
return render({ data: dataSource });
|
|
81
|
+
if (!data)
|
|
82
|
+
return fallback || null;
|
|
83
|
+
return render({ data });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/Description.tsx
|
|
87
|
+
function DescriptionItemContent(props) {
|
|
88
|
+
const [computedProps, setComputedProps] = (0, import_react4.useState)();
|
|
89
|
+
(0, import_react4.useEffect)(() => {
|
|
66
90
|
const propsCopy = __spreadValues({}, props);
|
|
67
91
|
if (!propsCopy.item.title)
|
|
68
92
|
propsCopy.item.title = (0, import_lodash.upperFirst)(propsCopy.item.id);
|
|
@@ -70,11 +94,11 @@ function DescriptionItemContent(props) {
|
|
|
70
94
|
propsCopy.item.type = "string";
|
|
71
95
|
setComputedProps(propsCopy);
|
|
72
96
|
}, [props]);
|
|
73
|
-
if (!computedProps
|
|
97
|
+
if (!computedProps)
|
|
74
98
|
return null;
|
|
75
99
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
76
100
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
77
|
-
return (0,
|
|
101
|
+
return (0, import_react4.cloneElement)(computedProps.extendTypes[computedProps.item.type].children, {
|
|
78
102
|
value: computedProps.value,
|
|
79
103
|
values: computedProps.values
|
|
80
104
|
});
|
|
@@ -83,9 +107,11 @@ function DescriptionItemContent(props) {
|
|
|
83
107
|
else
|
|
84
108
|
throw Error(computedProps.item.type + " requires children or render");
|
|
85
109
|
if (computedProps.item.children)
|
|
86
|
-
return (0,
|
|
110
|
+
return (0, import_react4.cloneElement)(computedProps.item.children, { value: computedProps.value });
|
|
87
111
|
if (computedProps.item.render)
|
|
88
112
|
return computedProps.item.render(computedProps.value, computedProps.values);
|
|
113
|
+
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
114
|
+
return null;
|
|
89
115
|
switch (computedProps.item.type) {
|
|
90
116
|
case "string[]":
|
|
91
117
|
return computedProps.value.join(", ");
|
|
@@ -104,15 +130,19 @@ function DescriptionItemContent(props) {
|
|
|
104
130
|
}
|
|
105
131
|
}
|
|
106
132
|
function Description(props) {
|
|
107
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
133
|
+
return /* @__PURE__ */ import_react.default.createElement(FaasDataWrapper, {
|
|
134
|
+
dataSource: props.dataSource,
|
|
135
|
+
faasData: props.faasData,
|
|
136
|
+
render: ({ data }) => /* @__PURE__ */ import_react.default.createElement(import_antd.Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ import_react.default.createElement(import_antd.Descriptions.Item, {
|
|
137
|
+
key: item.id,
|
|
138
|
+
label: item.title || (0, import_lodash.upperFirst)(item.id)
|
|
139
|
+
}, /* @__PURE__ */ import_react.default.createElement(DescriptionItemContent, {
|
|
140
|
+
item,
|
|
141
|
+
value: data[item.id],
|
|
142
|
+
values: data,
|
|
143
|
+
extendTypes: props.extendTypes
|
|
144
|
+
}))))
|
|
145
|
+
});
|
|
116
146
|
}
|
|
117
147
|
|
|
118
148
|
// src/Form.tsx
|
|
@@ -121,11 +151,11 @@ var import_antd3 = require("antd");
|
|
|
121
151
|
// src/FormItem.tsx
|
|
122
152
|
var import_antd2 = require("antd");
|
|
123
153
|
var import_icons2 = require("@ant-design/icons");
|
|
124
|
-
var
|
|
154
|
+
var import_react5 = require("react");
|
|
125
155
|
var import_lodash2 = require("lodash");
|
|
126
156
|
function FormItem(props) {
|
|
127
|
-
const [computedProps, setComputedProps] = (0,
|
|
128
|
-
(0,
|
|
157
|
+
const [computedProps, setComputedProps] = (0, import_react5.useState)();
|
|
158
|
+
(0, import_react5.useEffect)(() => {
|
|
129
159
|
const propsCopy = __spreadValues({}, props);
|
|
130
160
|
if (!propsCopy.title)
|
|
131
161
|
propsCopy.title = (0, import_lodash2.upperFirst)(propsCopy.id);
|
|
@@ -285,15 +315,16 @@ function Form(props) {
|
|
|
285
315
|
}, ((_b = props.submit) == null ? void 0 : _b.text) || "Submit"));
|
|
286
316
|
}
|
|
287
317
|
Form.useForm = import_antd3.Form.useForm;
|
|
318
|
+
Form.Item = FormItem;
|
|
288
319
|
|
|
289
320
|
// src/Table.tsx
|
|
290
|
-
var
|
|
321
|
+
var import_react6 = require("react");
|
|
291
322
|
var import_antd4 = require("antd");
|
|
292
323
|
var import_icons3 = require("@ant-design/icons");
|
|
293
324
|
var import_lodash3 = require("lodash");
|
|
294
325
|
function Table(props) {
|
|
295
|
-
const [columns, setColumns] = (0,
|
|
296
|
-
(0,
|
|
326
|
+
const [columns, setColumns] = (0, import_react6.useState)();
|
|
327
|
+
(0, import_react6.useEffect)(() => {
|
|
297
328
|
for (const item of props.items) {
|
|
298
329
|
if (!item.key)
|
|
299
330
|
item.key = item.id;
|
|
@@ -307,7 +338,7 @@ function Table(props) {
|
|
|
307
338
|
continue;
|
|
308
339
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
309
340
|
if (props.extendTypes[item.type].children) {
|
|
310
|
-
item.render = (value, values) => (0,
|
|
341
|
+
item.render = (value, values) => (0, import_react6.cloneElement)(props.extendTypes[item.type].children, {
|
|
311
342
|
value,
|
|
312
343
|
values
|
|
313
344
|
});
|
|
@@ -337,10 +368,15 @@ function Table(props) {
|
|
|
337
368
|
}, [props.items]);
|
|
338
369
|
if (!columns)
|
|
339
370
|
return null;
|
|
340
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
371
|
+
return /* @__PURE__ */ import_react.default.createElement(FaasDataWrapper, {
|
|
372
|
+
dataSource: props.dataSource,
|
|
373
|
+
faasData: props.faasData,
|
|
374
|
+
render: ({ data }) => /* @__PURE__ */ import_react.default.createElement(import_antd4.Table, __spreadProps(__spreadValues({}, props), {
|
|
375
|
+
rowKey: props.rowKey || "id",
|
|
376
|
+
columns,
|
|
377
|
+
dataSource: data
|
|
378
|
+
}))
|
|
379
|
+
});
|
|
344
380
|
}
|
|
345
381
|
module.exports = __toCommonJS(src_exports);
|
|
346
382
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -27,12 +27,36 @@ import { Descriptions } from "antd";
|
|
|
27
27
|
import { upperFirst } from "lodash";
|
|
28
28
|
import {
|
|
29
29
|
cloneElement,
|
|
30
|
-
useEffect,
|
|
31
|
-
useState
|
|
30
|
+
useEffect as useEffect2,
|
|
31
|
+
useState as useState2
|
|
32
32
|
} from "react";
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
|
|
34
|
+
// src/FaasWrapper.tsx
|
|
35
|
+
import { useEffect, useState } from "react";
|
|
36
|
+
import { getClient } from "@faasjs/react";
|
|
37
|
+
function FaasDataWrapper({
|
|
38
|
+
dataSource,
|
|
39
|
+
faasData,
|
|
40
|
+
render,
|
|
41
|
+
fallback
|
|
42
|
+
}) {
|
|
43
|
+
const [data, setData] = useState();
|
|
35
44
|
useEffect(() => {
|
|
45
|
+
if (!faasData)
|
|
46
|
+
return;
|
|
47
|
+
getClient().faas(faasData.action, faasData.action).then((res) => setData(res.data));
|
|
48
|
+
}, [JSON.stringify(faasData)]);
|
|
49
|
+
if (dataSource)
|
|
50
|
+
return render({ data: dataSource });
|
|
51
|
+
if (!data)
|
|
52
|
+
return fallback || null;
|
|
53
|
+
return render({ data });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/Description.tsx
|
|
57
|
+
function DescriptionItemContent(props) {
|
|
58
|
+
const [computedProps, setComputedProps] = useState2();
|
|
59
|
+
useEffect2(() => {
|
|
36
60
|
const propsCopy = __spreadValues({}, props);
|
|
37
61
|
if (!propsCopy.item.title)
|
|
38
62
|
propsCopy.item.title = upperFirst(propsCopy.item.id);
|
|
@@ -40,7 +64,7 @@ function DescriptionItemContent(props) {
|
|
|
40
64
|
propsCopy.item.type = "string";
|
|
41
65
|
setComputedProps(propsCopy);
|
|
42
66
|
}, [props]);
|
|
43
|
-
if (!computedProps
|
|
67
|
+
if (!computedProps)
|
|
44
68
|
return null;
|
|
45
69
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
46
70
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
@@ -56,6 +80,8 @@ function DescriptionItemContent(props) {
|
|
|
56
80
|
return cloneElement(computedProps.item.children, { value: computedProps.value });
|
|
57
81
|
if (computedProps.item.render)
|
|
58
82
|
return computedProps.item.render(computedProps.value, computedProps.values);
|
|
83
|
+
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
84
|
+
return null;
|
|
59
85
|
switch (computedProps.item.type) {
|
|
60
86
|
case "string[]":
|
|
61
87
|
return computedProps.value.join(", ");
|
|
@@ -74,15 +100,19 @@ function DescriptionItemContent(props) {
|
|
|
74
100
|
}
|
|
75
101
|
}
|
|
76
102
|
function Description(props) {
|
|
77
|
-
return /* @__PURE__ */ React.createElement(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
103
|
+
return /* @__PURE__ */ React.createElement(FaasDataWrapper, {
|
|
104
|
+
dataSource: props.dataSource,
|
|
105
|
+
faasData: props.faasData,
|
|
106
|
+
render: ({ data }) => /* @__PURE__ */ React.createElement(Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ React.createElement(Descriptions.Item, {
|
|
107
|
+
key: item.id,
|
|
108
|
+
label: item.title || upperFirst(item.id)
|
|
109
|
+
}, /* @__PURE__ */ React.createElement(DescriptionItemContent, {
|
|
110
|
+
item,
|
|
111
|
+
value: data[item.id],
|
|
112
|
+
values: data,
|
|
113
|
+
extendTypes: props.extendTypes
|
|
114
|
+
}))))
|
|
115
|
+
});
|
|
86
116
|
}
|
|
87
117
|
|
|
88
118
|
// src/Form.tsx
|
|
@@ -104,13 +134,13 @@ import {
|
|
|
104
134
|
} from "antd";
|
|
105
135
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
106
136
|
import {
|
|
107
|
-
useEffect as
|
|
108
|
-
useState as
|
|
137
|
+
useEffect as useEffect3,
|
|
138
|
+
useState as useState3
|
|
109
139
|
} from "react";
|
|
110
140
|
import { upperFirst as upperFirst2 } from "lodash";
|
|
111
141
|
function FormItem(props) {
|
|
112
|
-
const [computedProps, setComputedProps] =
|
|
113
|
-
|
|
142
|
+
const [computedProps, setComputedProps] = useState3();
|
|
143
|
+
useEffect3(() => {
|
|
114
144
|
const propsCopy = __spreadValues({}, props);
|
|
115
145
|
if (!propsCopy.title)
|
|
116
146
|
propsCopy.title = upperFirst2(propsCopy.id);
|
|
@@ -270,11 +300,12 @@ function Form(props) {
|
|
|
270
300
|
}, ((_b = props.submit) == null ? void 0 : _b.text) || "Submit"));
|
|
271
301
|
}
|
|
272
302
|
Form.useForm = AntdForm2.useForm;
|
|
303
|
+
Form.Item = FormItem;
|
|
273
304
|
|
|
274
305
|
// src/Table.tsx
|
|
275
306
|
import {
|
|
276
|
-
useState as
|
|
277
|
-
useEffect as
|
|
307
|
+
useState as useState4,
|
|
308
|
+
useEffect as useEffect4,
|
|
278
309
|
cloneElement as cloneElement2
|
|
279
310
|
} from "react";
|
|
280
311
|
import {
|
|
@@ -283,8 +314,8 @@ import {
|
|
|
283
314
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
284
315
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
285
316
|
function Table(props) {
|
|
286
|
-
const [columns, setColumns] =
|
|
287
|
-
|
|
317
|
+
const [columns, setColumns] = useState4();
|
|
318
|
+
useEffect4(() => {
|
|
288
319
|
for (const item of props.items) {
|
|
289
320
|
if (!item.key)
|
|
290
321
|
item.key = item.id;
|
|
@@ -328,10 +359,15 @@ function Table(props) {
|
|
|
328
359
|
}, [props.items]);
|
|
329
360
|
if (!columns)
|
|
330
361
|
return null;
|
|
331
|
-
return /* @__PURE__ */ React.createElement(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
362
|
+
return /* @__PURE__ */ React.createElement(FaasDataWrapper, {
|
|
363
|
+
dataSource: props.dataSource,
|
|
364
|
+
faasData: props.faasData,
|
|
365
|
+
render: ({ data }) => /* @__PURE__ */ React.createElement(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
366
|
+
rowKey: props.rowKey || "id",
|
|
367
|
+
columns,
|
|
368
|
+
dataSource: data
|
|
369
|
+
}))
|
|
370
|
+
});
|
|
335
371
|
}
|
|
336
372
|
export {
|
|
337
373
|
Description,
|
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.343",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"lodash": "*",
|
|
28
28
|
"react": "*",
|
|
29
29
|
"react-dom": "*",
|
|
30
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
30
|
+
"@faasjs/react": "^0.0.2-beta.343"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/lodash": "*",
|