@faasjs/ant-design 0.0.2-beta.355 → 0.0.2-beta.356
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 +8 -21
- package/dist/index.js +69 -56
- package/dist/index.mjs +68 -57
- package/package.json +2 -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,23 +66,6 @@ declare function transferOptions(options: BaseOption[]): {
|
|
|
65
66
|
value?: string | number;
|
|
66
67
|
}[];
|
|
67
68
|
|
|
68
|
-
declare type FaasDataProps<T = any> = {
|
|
69
|
-
action: string;
|
|
70
|
-
params?: Record<string, any>;
|
|
71
|
-
data?: T;
|
|
72
|
-
setData?: Dispatch<SetStateAction<T>>;
|
|
73
|
-
};
|
|
74
|
-
declare type FaasDataRender<T = any> = (args: {
|
|
75
|
-
data: T;
|
|
76
|
-
}) => JSX.Element;
|
|
77
|
-
declare type FaasDataWrapperProps<T = any> = {
|
|
78
|
-
dataSource?: T;
|
|
79
|
-
faasData?: FaasDataProps<T>;
|
|
80
|
-
render?: FaasDataRender<T>;
|
|
81
|
-
fallback?: JSX.Element;
|
|
82
|
-
};
|
|
83
|
-
declare function FaasDataWrapper<T = any>({ dataSource, faasData, render, fallback, }: FaasDataWrapperProps<T>): JSX.Element;
|
|
84
|
-
|
|
85
69
|
declare type ExtendDescriptionTypeProps = {
|
|
86
70
|
children?: JSX.Element | null;
|
|
87
71
|
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
@@ -96,7 +80,9 @@ declare type DescriptionProps<T = any, ExtendItemProps = any> = {
|
|
|
96
80
|
extendTypes?: {
|
|
97
81
|
[key: string]: ExtendDescriptionTypeProps;
|
|
98
82
|
};
|
|
99
|
-
|
|
83
|
+
dataSource?: T;
|
|
84
|
+
faasData?: FaasDataWrapperProps<T>;
|
|
85
|
+
} & DescriptionsProps;
|
|
100
86
|
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
101
87
|
|
|
102
88
|
declare type DrawerProps = DrawerProps$1 & {
|
|
@@ -190,7 +176,8 @@ declare type TableProps<T = any, ExtendTypes = any> = {
|
|
|
190
176
|
extendTypes?: {
|
|
191
177
|
[key: string]: ExtendTableTypeProps;
|
|
192
178
|
};
|
|
193
|
-
|
|
179
|
+
faasData?: FaasDataWrapperProps<T>;
|
|
180
|
+
} & TableProps$1<T>;
|
|
194
181
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
195
182
|
|
|
196
183
|
declare type TitleProps = {
|
|
@@ -201,4 +188,4 @@ declare type TitleProps = {
|
|
|
201
188
|
};
|
|
202
189
|
declare function Title(props: TitleProps): JSX.Element;
|
|
203
190
|
|
|
204
|
-
export { BaseItemProps, BaseOption, Blank, BlankProps, Config, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps,
|
|
191
|
+
export { BaseItemProps, BaseOption, Blank, BlankProps, Config, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, FaasItemProps, FaasItemType, FaasItemTypeValue, FaasState, Form, FormItem, FormItemProps, FormProps, Routes, RoutesProps, Table, TableItemProps, TableProps, Title, TitleProps, transferOptions, useDrawer, useFaasState };
|
package/dist/index.js
CHANGED
|
@@ -50,7 +50,6 @@ __export(src_exports, {
|
|
|
50
50
|
Config: () => Config,
|
|
51
51
|
Description: () => Description,
|
|
52
52
|
Drawer: () => import_antd3.Drawer,
|
|
53
|
-
FaasDataWrapper: () => FaasDataWrapper,
|
|
54
53
|
Form: () => Form,
|
|
55
54
|
FormItem: () => FormItem,
|
|
56
55
|
Routes: () => Routes,
|
|
@@ -117,39 +116,11 @@ function transferOptions(options) {
|
|
|
117
116
|
var import_icons = require("@ant-design/icons");
|
|
118
117
|
var import_antd2 = require("antd");
|
|
119
118
|
var import_lodash3 = require("lodash");
|
|
120
|
-
var import_react5 = require("react");
|
|
121
|
-
|
|
122
|
-
// src/FaasDataWrapper.tsx
|
|
123
119
|
var import_react3 = require("react");
|
|
124
120
|
var import_react4 = require("@faasjs/react");
|
|
125
|
-
function FaasDataWrapper({
|
|
126
|
-
dataSource,
|
|
127
|
-
faasData,
|
|
128
|
-
render,
|
|
129
|
-
fallback
|
|
130
|
-
}) {
|
|
131
|
-
const [data, setData] = (0, import_react3.useState)();
|
|
132
|
-
(0, import_react3.useEffect)(() => {
|
|
133
|
-
if (!faasData)
|
|
134
|
-
return;
|
|
135
|
-
(0, import_react4.getClient)().faas(faasData.action, faasData.params).then((res) => {
|
|
136
|
-
if (faasData.setData)
|
|
137
|
-
faasData.setData(res.data);
|
|
138
|
-
else
|
|
139
|
-
setData(res.data);
|
|
140
|
-
});
|
|
141
|
-
}, [JSON.stringify([faasData == null ? void 0 : faasData.action, faasData == null ? void 0 : faasData.params])]);
|
|
142
|
-
if (dataSource)
|
|
143
|
-
return render({ data: dataSource });
|
|
144
|
-
if (!data && !faasData.data)
|
|
145
|
-
return fallback || null;
|
|
146
|
-
return render({ data: faasData.data || data });
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// src/Description.tsx
|
|
150
121
|
function DescriptionItemContent(props) {
|
|
151
|
-
const [computedProps, setComputedProps] = (0,
|
|
152
|
-
(0,
|
|
122
|
+
const [computedProps, setComputedProps] = (0, import_react3.useState)();
|
|
123
|
+
(0, import_react3.useEffect)(() => {
|
|
153
124
|
var _a2, _b2;
|
|
154
125
|
const propsCopy = __spreadValues({}, props);
|
|
155
126
|
if (!propsCopy.item.title)
|
|
@@ -174,7 +145,7 @@ function DescriptionItemContent(props) {
|
|
|
174
145
|
return null;
|
|
175
146
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
176
147
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
177
|
-
return (0,
|
|
148
|
+
return (0, import_react3.cloneElement)(computedProps.extendTypes[computedProps.item.type].children, {
|
|
178
149
|
value: computedProps.value,
|
|
179
150
|
values: computedProps.values
|
|
180
151
|
});
|
|
@@ -183,7 +154,7 @@ function DescriptionItemContent(props) {
|
|
|
183
154
|
else
|
|
184
155
|
throw Error(computedProps.item.type + " requires children or render");
|
|
185
156
|
if (computedProps.item.children)
|
|
186
|
-
return (0,
|
|
157
|
+
return (0, import_react3.cloneElement)(computedProps.item.children, { value: computedProps.value });
|
|
187
158
|
if (computedProps.item.render)
|
|
188
159
|
return computedProps.item.render(computedProps.value, computedProps.values);
|
|
189
160
|
if (typeof computedProps.value === "undefined" || computedProps.value === null)
|
|
@@ -212,7 +183,17 @@ function DescriptionItemContent(props) {
|
|
|
212
183
|
}
|
|
213
184
|
}
|
|
214
185
|
function Description(props) {
|
|
215
|
-
|
|
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({
|
|
216
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, {
|
|
217
198
|
key: item.id,
|
|
218
199
|
label: item.title || (0, import_lodash3.upperFirst)(item.id)
|
|
@@ -222,14 +203,14 @@ function Description(props) {
|
|
|
222
203
|
values: data,
|
|
223
204
|
extendTypes: props.extendTypes
|
|
224
205
|
}))))
|
|
225
|
-
}));
|
|
206
|
+
}, props.faasData));
|
|
226
207
|
}
|
|
227
208
|
|
|
228
209
|
// src/Drawer.tsx
|
|
229
210
|
var import_antd3 = require("antd");
|
|
230
|
-
var
|
|
211
|
+
var import_react5 = require("react");
|
|
231
212
|
function useDrawer(init) {
|
|
232
|
-
const [props, setProps] = (0,
|
|
213
|
+
const [props, setProps] = (0, import_react5.useState)(__spreadValues({
|
|
233
214
|
visible: false,
|
|
234
215
|
onClose: () => setProps((prev) => __spreadProps(__spreadValues({}, prev), {
|
|
235
216
|
visible: false
|
|
@@ -246,16 +227,16 @@ function useDrawer(init) {
|
|
|
246
227
|
|
|
247
228
|
// src/Form.tsx
|
|
248
229
|
var import_antd5 = require("antd");
|
|
249
|
-
var
|
|
230
|
+
var import_react7 = require("react");
|
|
250
231
|
|
|
251
232
|
// src/FormItem.tsx
|
|
252
233
|
var import_antd4 = require("antd");
|
|
253
234
|
var import_icons2 = require("@ant-design/icons");
|
|
254
|
-
var
|
|
235
|
+
var import_react6 = require("react");
|
|
255
236
|
var import_lodash4 = require("lodash");
|
|
256
237
|
function FormItem(props) {
|
|
257
|
-
const [computedProps, setComputedProps] = (0,
|
|
258
|
-
(0,
|
|
238
|
+
const [computedProps, setComputedProps] = (0, import_react6.useState)();
|
|
239
|
+
(0, import_react6.useEffect)(() => {
|
|
259
240
|
const propsCopy = __spreadValues({}, props);
|
|
260
241
|
if (!propsCopy.title)
|
|
261
242
|
propsCopy.title = (0, import_lodash4.upperFirst)(propsCopy.id);
|
|
@@ -395,10 +376,10 @@ function FormItem(props) {
|
|
|
395
376
|
// src/Form.tsx
|
|
396
377
|
function Form(props) {
|
|
397
378
|
var _a2, _b2;
|
|
398
|
-
const [loading, setLoading] = (0,
|
|
399
|
-
const [computedProps, setComputedProps] = (0,
|
|
379
|
+
const [loading, setLoading] = (0, import_react7.useState)(false);
|
|
380
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
400
381
|
const [config] = useFaasState();
|
|
401
|
-
(0,
|
|
382
|
+
(0, import_react7.useEffect)(() => {
|
|
402
383
|
const propsCopy = __spreadValues({}, props);
|
|
403
384
|
if (propsCopy.onFinish) {
|
|
404
385
|
propsCopy.onFinish = async (values) => {
|
|
@@ -430,7 +411,7 @@ Form.Item = FormItem;
|
|
|
430
411
|
|
|
431
412
|
// src/Routers.tsx
|
|
432
413
|
var import_antd6 = require("antd");
|
|
433
|
-
var
|
|
414
|
+
var import_react8 = require("react");
|
|
434
415
|
var import_react_router_dom = require("react-router-dom");
|
|
435
416
|
function NoMatch() {
|
|
436
417
|
return /* @__PURE__ */ import_react.default.createElement(import_antd6.Result, {
|
|
@@ -443,7 +424,7 @@ function Routes(props) {
|
|
|
443
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({
|
|
444
425
|
key: r.path
|
|
445
426
|
}, r), {
|
|
446
|
-
element: r.element || /* @__PURE__ */ import_react.default.createElement(
|
|
427
|
+
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react8.Suspense, {
|
|
447
428
|
fallback: /* @__PURE__ */ import_react.default.createElement(import_antd6.Skeleton, {
|
|
448
429
|
active: true
|
|
449
430
|
})
|
|
@@ -456,10 +437,11 @@ function Routes(props) {
|
|
|
456
437
|
}
|
|
457
438
|
|
|
458
439
|
// src/Table.tsx
|
|
459
|
-
var
|
|
440
|
+
var import_react9 = require("react");
|
|
460
441
|
var import_antd7 = require("antd");
|
|
461
442
|
var import_icons3 = require("@ant-design/icons");
|
|
462
443
|
var import_lodash5 = require("lodash");
|
|
444
|
+
var import_react10 = require("@faasjs/react");
|
|
463
445
|
function processValue(item, value) {
|
|
464
446
|
var _a2;
|
|
465
447
|
if (item.options && typeof value !== "undefined" && value !== null) {
|
|
@@ -474,9 +456,9 @@ function processValue(item, value) {
|
|
|
474
456
|
return value;
|
|
475
457
|
}
|
|
476
458
|
function Table(props) {
|
|
477
|
-
const [columns, setColumns] = (0,
|
|
459
|
+
const [columns, setColumns] = (0, import_react9.useState)();
|
|
478
460
|
const [config] = useFaasState();
|
|
479
|
-
(0,
|
|
461
|
+
(0, import_react9.useEffect)(() => {
|
|
480
462
|
var _a2;
|
|
481
463
|
for (const item of props.items) {
|
|
482
464
|
if (!item.key)
|
|
@@ -500,7 +482,7 @@ function Table(props) {
|
|
|
500
482
|
delete item.children;
|
|
501
483
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
502
484
|
if (props.extendTypes[item.type].children) {
|
|
503
|
-
item.render = (value, values) => (0,
|
|
485
|
+
item.render = (value, values) => (0, import_react9.cloneElement)(props.extendTypes[item.type].children, {
|
|
504
486
|
value,
|
|
505
487
|
values
|
|
506
488
|
});
|
|
@@ -595,13 +577,45 @@ function Table(props) {
|
|
|
595
577
|
}, [props.items]);
|
|
596
578
|
if (!columns)
|
|
597
579
|
return null;
|
|
598
|
-
|
|
599
|
-
|
|
580
|
+
if (!props.faasData)
|
|
581
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd7.Table, __spreadProps(__spreadValues({}, props), {
|
|
600
582
|
rowKey: props.rowKey || "id",
|
|
601
583
|
columns,
|
|
602
|
-
dataSource:
|
|
603
|
-
}))
|
|
604
|
-
|
|
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));
|
|
605
619
|
}
|
|
606
620
|
|
|
607
621
|
// src/Title.tsx
|
|
@@ -621,7 +635,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
621
635
|
Config,
|
|
622
636
|
Description,
|
|
623
637
|
Drawer,
|
|
624
|
-
FaasDataWrapper,
|
|
625
638
|
Form,
|
|
626
639
|
FormItem,
|
|
627
640
|
Routes,
|
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
|
}, []);
|
|
@@ -607,7 +619,6 @@ export {
|
|
|
607
619
|
Config,
|
|
608
620
|
Description,
|
|
609
621
|
Drawer,
|
|
610
|
-
FaasDataWrapper,
|
|
611
622
|
Form,
|
|
612
623
|
FormItem,
|
|
613
624
|
Routes,
|
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.356",
|
|
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.356",
|
|
31
31
|
"react-use": "*",
|
|
32
32
|
"react-router-dom": "*"
|
|
33
33
|
},
|