@faasjs/ant-design 0.0.2-beta.341 → 0.0.2-beta.342
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 +9 -1
- package/dist/index.js +57 -24
- package/dist/index.mjs +58 -25
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,11 @@ declare type DescriptionItemProps<T = any> = {
|
|
|
34
34
|
} & FaasItemProps;
|
|
35
35
|
declare type DescriptionProps<T = any, ExtendItemProps = any> = {
|
|
36
36
|
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
37
|
-
dataSource
|
|
37
|
+
dataSource?: T;
|
|
38
|
+
faasData?: {
|
|
39
|
+
action: string;
|
|
40
|
+
params?: Record<string, any>;
|
|
41
|
+
};
|
|
38
42
|
extendTypes?: {
|
|
39
43
|
[key: string]: ExtendDescriptionTypeProps;
|
|
40
44
|
};
|
|
@@ -117,6 +121,10 @@ declare type TableProps<T = any, ExtendTypes = any> = {
|
|
|
117
121
|
extendTypes?: {
|
|
118
122
|
[key: string]: ExtendTableTypeProps;
|
|
119
123
|
};
|
|
124
|
+
faasData?: {
|
|
125
|
+
action: string;
|
|
126
|
+
params?: Record<string, any>;
|
|
127
|
+
};
|
|
120
128
|
} & TableProps$1<T>;
|
|
121
129
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
122
130
|
|
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);
|
|
@@ -74,7 +98,7 @@ function DescriptionItemContent(props) {
|
|
|
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,7 +107,7 @@ 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);
|
|
89
113
|
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
@@ -106,15 +130,19 @@ function DescriptionItemContent(props) {
|
|
|
106
130
|
}
|
|
107
131
|
}
|
|
108
132
|
function Description(props) {
|
|
109
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
});
|
|
118
146
|
}
|
|
119
147
|
|
|
120
148
|
// src/Form.tsx
|
|
@@ -123,11 +151,11 @@ var import_antd3 = require("antd");
|
|
|
123
151
|
// src/FormItem.tsx
|
|
124
152
|
var import_antd2 = require("antd");
|
|
125
153
|
var import_icons2 = require("@ant-design/icons");
|
|
126
|
-
var
|
|
154
|
+
var import_react5 = require("react");
|
|
127
155
|
var import_lodash2 = require("lodash");
|
|
128
156
|
function FormItem(props) {
|
|
129
|
-
const [computedProps, setComputedProps] = (0,
|
|
130
|
-
(0,
|
|
157
|
+
const [computedProps, setComputedProps] = (0, import_react5.useState)();
|
|
158
|
+
(0, import_react5.useEffect)(() => {
|
|
131
159
|
const propsCopy = __spreadValues({}, props);
|
|
132
160
|
if (!propsCopy.title)
|
|
133
161
|
propsCopy.title = (0, import_lodash2.upperFirst)(propsCopy.id);
|
|
@@ -290,13 +318,13 @@ Form.useForm = import_antd3.Form.useForm;
|
|
|
290
318
|
Form.Item = FormItem;
|
|
291
319
|
|
|
292
320
|
// src/Table.tsx
|
|
293
|
-
var
|
|
321
|
+
var import_react6 = require("react");
|
|
294
322
|
var import_antd4 = require("antd");
|
|
295
323
|
var import_icons3 = require("@ant-design/icons");
|
|
296
324
|
var import_lodash3 = require("lodash");
|
|
297
325
|
function Table(props) {
|
|
298
|
-
const [columns, setColumns] = (0,
|
|
299
|
-
(0,
|
|
326
|
+
const [columns, setColumns] = (0, import_react6.useState)();
|
|
327
|
+
(0, import_react6.useEffect)(() => {
|
|
300
328
|
for (const item of props.items) {
|
|
301
329
|
if (!item.key)
|
|
302
330
|
item.key = item.id;
|
|
@@ -310,7 +338,7 @@ function Table(props) {
|
|
|
310
338
|
continue;
|
|
311
339
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
312
340
|
if (props.extendTypes[item.type].children) {
|
|
313
|
-
item.render = (value, values) => (0,
|
|
341
|
+
item.render = (value, values) => (0, import_react6.cloneElement)(props.extendTypes[item.type].children, {
|
|
314
342
|
value,
|
|
315
343
|
values
|
|
316
344
|
});
|
|
@@ -340,10 +368,15 @@ function Table(props) {
|
|
|
340
368
|
}, [props.items]);
|
|
341
369
|
if (!columns)
|
|
342
370
|
return null;
|
|
343
|
-
return /* @__PURE__ */ import_react.default.createElement(
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
+
});
|
|
347
380
|
}
|
|
348
381
|
module.exports = __toCommonJS(src_exports);
|
|
349
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);
|
|
@@ -76,15 +100,19 @@ function DescriptionItemContent(props) {
|
|
|
76
100
|
}
|
|
77
101
|
}
|
|
78
102
|
function Description(props) {
|
|
79
|
-
return /* @__PURE__ */ React.createElement(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
});
|
|
88
116
|
}
|
|
89
117
|
|
|
90
118
|
// src/Form.tsx
|
|
@@ -106,13 +134,13 @@ import {
|
|
|
106
134
|
} from "antd";
|
|
107
135
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
108
136
|
import {
|
|
109
|
-
useEffect as
|
|
110
|
-
useState as
|
|
137
|
+
useEffect as useEffect3,
|
|
138
|
+
useState as useState3
|
|
111
139
|
} from "react";
|
|
112
140
|
import { upperFirst as upperFirst2 } from "lodash";
|
|
113
141
|
function FormItem(props) {
|
|
114
|
-
const [computedProps, setComputedProps] =
|
|
115
|
-
|
|
142
|
+
const [computedProps, setComputedProps] = useState3();
|
|
143
|
+
useEffect3(() => {
|
|
116
144
|
const propsCopy = __spreadValues({}, props);
|
|
117
145
|
if (!propsCopy.title)
|
|
118
146
|
propsCopy.title = upperFirst2(propsCopy.id);
|
|
@@ -276,8 +304,8 @@ Form.Item = FormItem;
|
|
|
276
304
|
|
|
277
305
|
// src/Table.tsx
|
|
278
306
|
import {
|
|
279
|
-
useState as
|
|
280
|
-
useEffect as
|
|
307
|
+
useState as useState4,
|
|
308
|
+
useEffect as useEffect4,
|
|
281
309
|
cloneElement as cloneElement2
|
|
282
310
|
} from "react";
|
|
283
311
|
import {
|
|
@@ -286,8 +314,8 @@ import {
|
|
|
286
314
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
287
315
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
288
316
|
function Table(props) {
|
|
289
|
-
const [columns, setColumns] =
|
|
290
|
-
|
|
317
|
+
const [columns, setColumns] = useState4();
|
|
318
|
+
useEffect4(() => {
|
|
291
319
|
for (const item of props.items) {
|
|
292
320
|
if (!item.key)
|
|
293
321
|
item.key = item.id;
|
|
@@ -331,10 +359,15 @@ function Table(props) {
|
|
|
331
359
|
}, [props.items]);
|
|
332
360
|
if (!columns)
|
|
333
361
|
return null;
|
|
334
|
-
return /* @__PURE__ */ React.createElement(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
+
});
|
|
338
371
|
}
|
|
339
372
|
export {
|
|
340
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.342",
|
|
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.342"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/lodash": "*",
|