@faasjs/ant-design 0.0.2-beta.353 → 0.0.2-beta.357
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 +7 -17
- package/dist/index.js +69 -54
- package/dist/index.mjs +68 -56
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react_use_lib_misc_hookState from 'react-use/lib/misc/hookState';
|
|
2
2
|
import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, FormProps as FormProps$1, TableColumnProps, TableProps as TableProps$1 } from 'antd';
|
|
3
3
|
export { Drawer } from 'antd';
|
|
4
|
-
import {
|
|
4
|
+
import { FaasDataWrapperProps } from '@faasjs/react';
|
|
5
5
|
import * as antd_lib_form_Form from 'antd/lib/form/Form';
|
|
6
6
|
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
7
|
+
import { LazyExoticComponent, ComponentType } from 'react';
|
|
7
8
|
import { RouteProps } from 'react-router-dom';
|
|
8
9
|
|
|
9
10
|
declare type BlankProps = {
|
|
@@ -65,20 +66,6 @@ declare function transferOptions(options: BaseOption[]): {
|
|
|
65
66
|
value?: string | number;
|
|
66
67
|
}[];
|
|
67
68
|
|
|
68
|
-
declare type FaasDataWrapperProps<T = any> = {
|
|
69
|
-
dataSource?: T;
|
|
70
|
-
faasData?: {
|
|
71
|
-
action: string;
|
|
72
|
-
params?: Record<string, any>;
|
|
73
|
-
data?: T;
|
|
74
|
-
setData?: Dispatch<SetStateAction<T>>;
|
|
75
|
-
};
|
|
76
|
-
render?: (args: {
|
|
77
|
-
data: T;
|
|
78
|
-
}) => JSX.Element;
|
|
79
|
-
fallback?: JSX.Element;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
69
|
declare type ExtendDescriptionTypeProps = {
|
|
83
70
|
children?: JSX.Element | null;
|
|
84
71
|
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
@@ -93,7 +80,9 @@ declare type DescriptionProps<T = any, ExtendItemProps = any> = {
|
|
|
93
80
|
extendTypes?: {
|
|
94
81
|
[key: string]: ExtendDescriptionTypeProps;
|
|
95
82
|
};
|
|
96
|
-
|
|
83
|
+
dataSource?: T;
|
|
84
|
+
faasData?: FaasDataWrapperProps<T>;
|
|
85
|
+
} & DescriptionsProps;
|
|
97
86
|
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
98
87
|
|
|
99
88
|
declare type DrawerProps = DrawerProps$1 & {
|
|
@@ -187,7 +176,8 @@ declare type TableProps<T = any, ExtendTypes = any> = {
|
|
|
187
176
|
extendTypes?: {
|
|
188
177
|
[key: string]: ExtendTableTypeProps;
|
|
189
178
|
};
|
|
190
|
-
|
|
179
|
+
faasData?: FaasDataWrapperProps<T>;
|
|
180
|
+
} & TableProps$1<T>;
|
|
191
181
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
192
182
|
|
|
193
183
|
declare type TitleProps = {
|
package/dist/index.js
CHANGED
|
@@ -116,39 +116,11 @@ function transferOptions(options) {
|
|
|
116
116
|
var import_icons = require("@ant-design/icons");
|
|
117
117
|
var import_antd2 = require("antd");
|
|
118
118
|
var import_lodash3 = require("lodash");
|
|
119
|
-
var import_react5 = require("react");
|
|
120
|
-
|
|
121
|
-
// src/FaasDataWrapper.tsx
|
|
122
119
|
var import_react3 = require("react");
|
|
123
120
|
var import_react4 = require("@faasjs/react");
|
|
124
|
-
function FaasDataWrapper({
|
|
125
|
-
dataSource,
|
|
126
|
-
faasData,
|
|
127
|
-
render,
|
|
128
|
-
fallback
|
|
129
|
-
}) {
|
|
130
|
-
const [data, setData] = (0, import_react3.useState)();
|
|
131
|
-
(0, import_react3.useEffect)(() => {
|
|
132
|
-
if (!faasData)
|
|
133
|
-
return;
|
|
134
|
-
(0, import_react4.getClient)().faas(faasData.action, faasData.params).then((res) => {
|
|
135
|
-
if (faasData.setData)
|
|
136
|
-
faasData.setData(res.data);
|
|
137
|
-
else
|
|
138
|
-
setData(res.data);
|
|
139
|
-
});
|
|
140
|
-
}, [JSON.stringify([faasData == null ? void 0 : faasData.action, faasData == null ? void 0 : faasData.params])]);
|
|
141
|
-
if (dataSource)
|
|
142
|
-
return render({ data: dataSource });
|
|
143
|
-
if (!data && !faasData.data)
|
|
144
|
-
return fallback || null;
|
|
145
|
-
return render({ data: faasData.data || data });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// src/Description.tsx
|
|
149
121
|
function DescriptionItemContent(props) {
|
|
150
|
-
const [computedProps, setComputedProps] = (0,
|
|
151
|
-
(0,
|
|
122
|
+
const [computedProps, setComputedProps] = (0, import_react3.useState)();
|
|
123
|
+
(0, import_react3.useEffect)(() => {
|
|
152
124
|
var _a2, _b2;
|
|
153
125
|
const propsCopy = __spreadValues({}, props);
|
|
154
126
|
if (!propsCopy.item.title)
|
|
@@ -173,7 +145,7 @@ function DescriptionItemContent(props) {
|
|
|
173
145
|
return null;
|
|
174
146
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
175
147
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
176
|
-
return (0,
|
|
148
|
+
return (0, import_react3.cloneElement)(computedProps.extendTypes[computedProps.item.type].children, {
|
|
177
149
|
value: computedProps.value,
|
|
178
150
|
values: computedProps.values
|
|
179
151
|
});
|
|
@@ -182,7 +154,7 @@ function DescriptionItemContent(props) {
|
|
|
182
154
|
else
|
|
183
155
|
throw Error(computedProps.item.type + " requires children or render");
|
|
184
156
|
if (computedProps.item.children)
|
|
185
|
-
return (0,
|
|
157
|
+
return (0, import_react3.cloneElement)(computedProps.item.children, { value: computedProps.value });
|
|
186
158
|
if (computedProps.item.render)
|
|
187
159
|
return computedProps.item.render(computedProps.value, computedProps.values);
|
|
188
160
|
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
@@ -211,7 +183,17 @@ function DescriptionItemContent(props) {
|
|
|
211
183
|
}
|
|
212
184
|
}
|
|
213
185
|
function Description(props) {
|
|
214
|
-
|
|
186
|
+
if (!props.faasData)
|
|
187
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd2.Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ import_react.default.createElement(import_antd2.Descriptions.Item, {
|
|
188
|
+
key: item.id,
|
|
189
|
+
label: item.title || (0, import_lodash3.upperFirst)(item.id)
|
|
190
|
+
}, /* @__PURE__ */ import_react.default.createElement(DescriptionItemContent, {
|
|
191
|
+
item,
|
|
192
|
+
value: props.dataSource[item.id],
|
|
193
|
+
values: props.dataSource,
|
|
194
|
+
extendTypes: props.extendTypes
|
|
195
|
+
}))));
|
|
196
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react4.FaasDataWrapper, __spreadValues({
|
|
215
197
|
render: ({ data }) => /* @__PURE__ */ import_react.default.createElement(import_antd2.Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ import_react.default.createElement(import_antd2.Descriptions.Item, {
|
|
216
198
|
key: item.id,
|
|
217
199
|
label: item.title || (0, import_lodash3.upperFirst)(item.id)
|
|
@@ -221,14 +203,14 @@ function Description(props) {
|
|
|
221
203
|
values: data,
|
|
222
204
|
extendTypes: props.extendTypes
|
|
223
205
|
}))))
|
|
224
|
-
}));
|
|
206
|
+
}, props.faasData));
|
|
225
207
|
}
|
|
226
208
|
|
|
227
209
|
// src/Drawer.tsx
|
|
228
210
|
var import_antd3 = require("antd");
|
|
229
|
-
var
|
|
211
|
+
var import_react5 = require("react");
|
|
230
212
|
function useDrawer(init) {
|
|
231
|
-
const [props, setProps] = (0,
|
|
213
|
+
const [props, setProps] = (0, import_react5.useState)(__spreadValues({
|
|
232
214
|
visible: false,
|
|
233
215
|
onClose: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
234
216
|
visible: false
|
|
@@ -245,16 +227,16 @@ function useDrawer(init) {
|
|
|
245
227
|
|
|
246
228
|
// src/Form.tsx
|
|
247
229
|
var import_antd5 = require("antd");
|
|
248
|
-
var
|
|
230
|
+
var import_react7 = require("react");
|
|
249
231
|
|
|
250
232
|
// src/FormItem.tsx
|
|
251
233
|
var import_antd4 = require("antd");
|
|
252
234
|
var import_icons2 = require("@ant-design/icons");
|
|
253
|
-
var
|
|
235
|
+
var import_react6 = require("react");
|
|
254
236
|
var import_lodash4 = require("lodash");
|
|
255
237
|
function FormItem(props) {
|
|
256
|
-
const [computedProps, setComputedProps] = (0,
|
|
257
|
-
(0,
|
|
238
|
+
const [computedProps, setComputedProps] = (0, import_react6.useState)();
|
|
239
|
+
(0, import_react6.useEffect)(() => {
|
|
258
240
|
const propsCopy = __spreadValues({}, props);
|
|
259
241
|
if (!propsCopy.title)
|
|
260
242
|
propsCopy.title = (0, import_lodash4.upperFirst)(propsCopy.id);
|
|
@@ -394,10 +376,10 @@ function FormItem(props) {
|
|
|
394
376
|
// src/Form.tsx
|
|
395
377
|
function Form(props) {
|
|
396
378
|
var _a2, _b2;
|
|
397
|
-
const [loading, setLoading] = (0,
|
|
398
|
-
const [computedProps, setComputedProps] = (0,
|
|
379
|
+
const [loading, setLoading] = (0, import_react7.useState)(false);
|
|
380
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
399
381
|
const [config] = useFaasState();
|
|
400
|
-
(0,
|
|
382
|
+
(0, import_react7.useEffect)(() => {
|
|
401
383
|
const propsCopy = __spreadValues({}, props);
|
|
402
384
|
if (propsCopy.onFinish) {
|
|
403
385
|
propsCopy.onFinish = async (values) => {
|
|
@@ -429,7 +411,7 @@ Form.Item = FormItem;
|
|
|
429
411
|
|
|
430
412
|
// src/Routers.tsx
|
|
431
413
|
var import_antd6 = require("antd");
|
|
432
|
-
var
|
|
414
|
+
var import_react8 = require("react");
|
|
433
415
|
var import_react_router_dom = require("react-router-dom");
|
|
434
416
|
function NoMatch() {
|
|
435
417
|
return /* @__PURE__ */ import_react.default.createElement(import_antd6.Result, {
|
|
@@ -442,7 +424,7 @@ function Routes(props) {
|
|
|
442
424
|
return /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Routes, null, props.routes.map((r) => /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Route, __spreadProps(__spreadValues({
|
|
443
425
|
key: r.path
|
|
444
426
|
}, r), {
|
|
445
|
-
element: r.element || /* @__PURE__ */ import_react.default.createElement(
|
|
427
|
+
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react8.Suspense, {
|
|
446
428
|
fallback: /* @__PURE__ */ import_react.default.createElement(import_antd6.Skeleton, {
|
|
447
429
|
active: true
|
|
448
430
|
})
|
|
@@ -455,10 +437,11 @@ function Routes(props) {
|
|
|
455
437
|
}
|
|
456
438
|
|
|
457
439
|
// src/Table.tsx
|
|
458
|
-
var
|
|
440
|
+
var import_react9 = require("react");
|
|
459
441
|
var import_antd7 = require("antd");
|
|
460
442
|
var import_icons3 = require("@ant-design/icons");
|
|
461
443
|
var import_lodash5 = require("lodash");
|
|
444
|
+
var import_react10 = require("@faasjs/react");
|
|
462
445
|
function processValue(item, value) {
|
|
463
446
|
var _a2;
|
|
464
447
|
if (item.options && typeof value !== "undefined" && value !== null) {
|
|
@@ -473,9 +456,9 @@ function processValue(item, value) {
|
|
|
473
456
|
return value;
|
|
474
457
|
}
|
|
475
458
|
function Table(props) {
|
|
476
|
-
const [columns, setColumns] = (0,
|
|
459
|
+
const [columns, setColumns] = (0, import_react9.useState)();
|
|
477
460
|
const [config] = useFaasState();
|
|
478
|
-
(0,
|
|
461
|
+
(0, import_react9.useEffect)(() => {
|
|
479
462
|
var _a2;
|
|
480
463
|
for (const item of props.items) {
|
|
481
464
|
if (!item.key)
|
|
@@ -499,7 +482,7 @@ function Table(props) {
|
|
|
499
482
|
delete item.children;
|
|
500
483
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
501
484
|
if (props.extendTypes[item.type].children) {
|
|
502
|
-
item.render = (value, values) => (0,
|
|
485
|
+
item.render = (value, values) => (0, import_react9.cloneElement)(props.extendTypes[item.type].children, {
|
|
503
486
|
value,
|
|
504
487
|
values
|
|
505
488
|
});
|
|
@@ -594,13 +577,45 @@ function Table(props) {
|
|
|
594
577
|
}, [props.items]);
|
|
595
578
|
if (!columns)
|
|
596
579
|
return null;
|
|
597
|
-
|
|
598
|
-
|
|
580
|
+
if (!props.faasData)
|
|
581
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd7.Table, __spreadProps(__spreadValues({}, props), {
|
|
599
582
|
rowKey: props.rowKey || "id",
|
|
600
583
|
columns,
|
|
601
|
-
dataSource:
|
|
602
|
-
}))
|
|
603
|
-
|
|
584
|
+
dataSource: props.dataSource
|
|
585
|
+
}));
|
|
586
|
+
return /* @__PURE__ */ import_react.default.createElement(import_react10.FaasDataWrapper, __spreadValues({
|
|
587
|
+
render: ({
|
|
588
|
+
data,
|
|
589
|
+
params,
|
|
590
|
+
reload
|
|
591
|
+
}) => {
|
|
592
|
+
if (!data)
|
|
593
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd7.Table, __spreadProps(__spreadValues({}, props), {
|
|
594
|
+
rowKey: props.rowKey || "id",
|
|
595
|
+
columns,
|
|
596
|
+
dataSource: []
|
|
597
|
+
}));
|
|
598
|
+
if (Array.isArray(data))
|
|
599
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd7.Table, __spreadProps(__spreadValues({}, props), {
|
|
600
|
+
rowKey: props.rowKey || "id",
|
|
601
|
+
columns,
|
|
602
|
+
dataSource: data
|
|
603
|
+
}));
|
|
604
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd7.Table, __spreadProps(__spreadValues({}, props), {
|
|
605
|
+
rowKey: props.rowKey || "id",
|
|
606
|
+
columns,
|
|
607
|
+
dataSource: data.rows,
|
|
608
|
+
pagination: data.pagination,
|
|
609
|
+
onChange: (pagination, filters, sorter) => {
|
|
610
|
+
reload(__spreadProps(__spreadValues({}, params), {
|
|
611
|
+
pagination,
|
|
612
|
+
filters,
|
|
613
|
+
sorter
|
|
614
|
+
}));
|
|
615
|
+
}
|
|
616
|
+
}));
|
|
617
|
+
}
|
|
618
|
+
}, props.faasData));
|
|
604
619
|
}
|
|
605
620
|
|
|
606
621
|
// src/Title.tsx
|
package/dist/index.mjs
CHANGED
|
@@ -76,44 +76,13 @@ import { Descriptions } from "antd";
|
|
|
76
76
|
import { upperFirst as upperFirst2 } from "lodash";
|
|
77
77
|
import {
|
|
78
78
|
cloneElement,
|
|
79
|
-
useEffect as useEffect3,
|
|
80
|
-
useState as useState2
|
|
81
|
-
} from "react";
|
|
82
|
-
|
|
83
|
-
// src/FaasDataWrapper.tsx
|
|
84
|
-
import {
|
|
85
79
|
useEffect as useEffect2,
|
|
86
80
|
useState
|
|
87
81
|
} from "react";
|
|
88
|
-
import {
|
|
89
|
-
function FaasDataWrapper({
|
|
90
|
-
dataSource,
|
|
91
|
-
faasData,
|
|
92
|
-
render,
|
|
93
|
-
fallback
|
|
94
|
-
}) {
|
|
95
|
-
const [data, setData] = useState();
|
|
96
|
-
useEffect2(() => {
|
|
97
|
-
if (!faasData)
|
|
98
|
-
return;
|
|
99
|
-
getClient().faas(faasData.action, faasData.params).then((res) => {
|
|
100
|
-
if (faasData.setData)
|
|
101
|
-
faasData.setData(res.data);
|
|
102
|
-
else
|
|
103
|
-
setData(res.data);
|
|
104
|
-
});
|
|
105
|
-
}, [JSON.stringify([faasData == null ? void 0 : faasData.action, faasData == null ? void 0 : faasData.params])]);
|
|
106
|
-
if (dataSource)
|
|
107
|
-
return render({ data: dataSource });
|
|
108
|
-
if (!data && !faasData.data)
|
|
109
|
-
return fallback || null;
|
|
110
|
-
return render({ data: faasData.data || data });
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// src/Description.tsx
|
|
82
|
+
import { FaasDataWrapper } from "@faasjs/react";
|
|
114
83
|
function DescriptionItemContent(props) {
|
|
115
|
-
const [computedProps, setComputedProps] =
|
|
116
|
-
|
|
84
|
+
const [computedProps, setComputedProps] = useState();
|
|
85
|
+
useEffect2(() => {
|
|
117
86
|
var _a2, _b2;
|
|
118
87
|
const propsCopy = __spreadValues({}, props);
|
|
119
88
|
if (!propsCopy.item.title)
|
|
@@ -176,7 +145,17 @@ function DescriptionItemContent(props) {
|
|
|
176
145
|
}
|
|
177
146
|
}
|
|
178
147
|
function Description(props) {
|
|
179
|
-
|
|
148
|
+
if (!props.faasData)
|
|
149
|
+
return /* @__PURE__ */ React.createElement(Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ React.createElement(Descriptions.Item, {
|
|
150
|
+
key: item.id,
|
|
151
|
+
label: item.title || upperFirst2(item.id)
|
|
152
|
+
}, /* @__PURE__ */ React.createElement(DescriptionItemContent, {
|
|
153
|
+
item,
|
|
154
|
+
value: props.dataSource[item.id],
|
|
155
|
+
values: props.dataSource,
|
|
156
|
+
extendTypes: props.extendTypes
|
|
157
|
+
}))));
|
|
158
|
+
return /* @__PURE__ */ React.createElement(FaasDataWrapper, __spreadValues({
|
|
180
159
|
render: ({ data }) => /* @__PURE__ */ React.createElement(Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ React.createElement(Descriptions.Item, {
|
|
181
160
|
key: item.id,
|
|
182
161
|
label: item.title || upperFirst2(item.id)
|
|
@@ -186,14 +165,14 @@ function Description(props) {
|
|
|
186
165
|
values: data,
|
|
187
166
|
extendTypes: props.extendTypes
|
|
188
167
|
}))))
|
|
189
|
-
}));
|
|
168
|
+
}, props.faasData));
|
|
190
169
|
}
|
|
191
170
|
|
|
192
171
|
// src/Drawer.tsx
|
|
193
172
|
import { Drawer } from "antd";
|
|
194
|
-
import { useState as
|
|
173
|
+
import { useState as useState2 } from "react";
|
|
195
174
|
function useDrawer(init) {
|
|
196
|
-
const [props, setProps] =
|
|
175
|
+
const [props, setProps] = useState2(__spreadValues({
|
|
197
176
|
visible: false,
|
|
198
177
|
onClose: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
199
178
|
visible: false
|
|
@@ -213,7 +192,7 @@ import {
|
|
|
213
192
|
Button as Button2,
|
|
214
193
|
Form as AntdForm2
|
|
215
194
|
} from "antd";
|
|
216
|
-
import { useEffect as
|
|
195
|
+
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
217
196
|
|
|
218
197
|
// src/FormItem.tsx
|
|
219
198
|
import {
|
|
@@ -227,11 +206,11 @@ import {
|
|
|
227
206
|
Select
|
|
228
207
|
} from "antd";
|
|
229
208
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
230
|
-
import { useEffect as
|
|
209
|
+
import { useEffect as useEffect3, useState as useState3 } from "react";
|
|
231
210
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
232
211
|
function FormItem(props) {
|
|
233
|
-
const [computedProps, setComputedProps] =
|
|
234
|
-
|
|
212
|
+
const [computedProps, setComputedProps] = useState3();
|
|
213
|
+
useEffect3(() => {
|
|
235
214
|
const propsCopy = __spreadValues({}, props);
|
|
236
215
|
if (!propsCopy.title)
|
|
237
216
|
propsCopy.title = upperFirst3(propsCopy.id);
|
|
@@ -371,10 +350,10 @@ function FormItem(props) {
|
|
|
371
350
|
// src/Form.tsx
|
|
372
351
|
function Form(props) {
|
|
373
352
|
var _a2, _b2;
|
|
374
|
-
const [loading, setLoading] =
|
|
375
|
-
const [computedProps, setComputedProps] =
|
|
353
|
+
const [loading, setLoading] = useState4(false);
|
|
354
|
+
const [computedProps, setComputedProps] = useState4();
|
|
376
355
|
const [config] = useFaasState();
|
|
377
|
-
|
|
356
|
+
useEffect4(() => {
|
|
378
357
|
const propsCopy = __spreadValues({}, props);
|
|
379
358
|
if (propsCopy.onFinish) {
|
|
380
359
|
propsCopy.onFinish = async (values) => {
|
|
@@ -438,8 +417,8 @@ function Routes(props) {
|
|
|
438
417
|
|
|
439
418
|
// src/Table.tsx
|
|
440
419
|
import {
|
|
441
|
-
useState as
|
|
442
|
-
useEffect as
|
|
420
|
+
useState as useState5,
|
|
421
|
+
useEffect as useEffect5,
|
|
443
422
|
cloneElement as cloneElement2
|
|
444
423
|
} from "react";
|
|
445
424
|
import {
|
|
@@ -448,6 +427,7 @@ import {
|
|
|
448
427
|
} from "antd";
|
|
449
428
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
450
429
|
import { isNil as isNil2, upperFirst as upperFirst4 } from "lodash";
|
|
430
|
+
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
451
431
|
function processValue(item, value) {
|
|
452
432
|
var _a2;
|
|
453
433
|
if (item.options && typeof value !== "undefined" && value !== null) {
|
|
@@ -462,9 +442,9 @@ function processValue(item, value) {
|
|
|
462
442
|
return value;
|
|
463
443
|
}
|
|
464
444
|
function Table(props) {
|
|
465
|
-
const [columns, setColumns] =
|
|
445
|
+
const [columns, setColumns] = useState5();
|
|
466
446
|
const [config] = useFaasState();
|
|
467
|
-
|
|
447
|
+
useEffect5(() => {
|
|
468
448
|
var _a2;
|
|
469
449
|
for (const item of props.items) {
|
|
470
450
|
if (!item.key)
|
|
@@ -583,20 +563,52 @@ function Table(props) {
|
|
|
583
563
|
}, [props.items]);
|
|
584
564
|
if (!columns)
|
|
585
565
|
return null;
|
|
586
|
-
|
|
587
|
-
|
|
566
|
+
if (!props.faasData)
|
|
567
|
+
return /* @__PURE__ */ React.createElement(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
588
568
|
rowKey: props.rowKey || "id",
|
|
589
569
|
columns,
|
|
590
|
-
dataSource:
|
|
591
|
-
}))
|
|
592
|
-
|
|
570
|
+
dataSource: props.dataSource
|
|
571
|
+
}));
|
|
572
|
+
return /* @__PURE__ */ React.createElement(FaasDataWrapper2, __spreadValues({
|
|
573
|
+
render: ({
|
|
574
|
+
data,
|
|
575
|
+
params,
|
|
576
|
+
reload
|
|
577
|
+
}) => {
|
|
578
|
+
if (!data)
|
|
579
|
+
return /* @__PURE__ */ React.createElement(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
580
|
+
rowKey: props.rowKey || "id",
|
|
581
|
+
columns,
|
|
582
|
+
dataSource: []
|
|
583
|
+
}));
|
|
584
|
+
if (Array.isArray(data))
|
|
585
|
+
return /* @__PURE__ */ React.createElement(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
586
|
+
rowKey: props.rowKey || "id",
|
|
587
|
+
columns,
|
|
588
|
+
dataSource: data
|
|
589
|
+
}));
|
|
590
|
+
return /* @__PURE__ */ React.createElement(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
591
|
+
rowKey: props.rowKey || "id",
|
|
592
|
+
columns,
|
|
593
|
+
dataSource: data.rows,
|
|
594
|
+
pagination: data.pagination,
|
|
595
|
+
onChange: (pagination, filters, sorter) => {
|
|
596
|
+
reload(__spreadProps(__spreadValues({}, params), {
|
|
597
|
+
pagination,
|
|
598
|
+
filters,
|
|
599
|
+
sorter
|
|
600
|
+
}));
|
|
601
|
+
}
|
|
602
|
+
}));
|
|
603
|
+
}
|
|
604
|
+
}, props.faasData));
|
|
593
605
|
}
|
|
594
606
|
|
|
595
607
|
// src/Title.tsx
|
|
596
|
-
import { useEffect as
|
|
608
|
+
import { useEffect as useEffect6 } from "react";
|
|
597
609
|
function Title(props) {
|
|
598
610
|
const [config] = useFaasState();
|
|
599
|
-
|
|
611
|
+
useEffect6(() => {
|
|
600
612
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
601
613
|
document.title = title.concat(props.suffix || config.Title.suffix).filter((t) => !!t).join(props.separator || config.Title.separator);
|
|
602
614
|
}, []);
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/ant-design",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.357",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"homepage": "https://faasjs.com/doc/ant-design.html",
|
|
8
9
|
"repository": {
|
|
@@ -27,7 +28,7 @@
|
|
|
27
28
|
"lodash": "*",
|
|
28
29
|
"react": "*",
|
|
29
30
|
"react-dom": "*",
|
|
30
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.357",
|
|
31
32
|
"react-use": "*",
|
|
32
33
|
"react-router-dom": "*"
|
|
33
34
|
},
|