@faasjs/ant-design 0.0.2-beta.348 → 0.0.2-beta.352
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 +26 -16
- package/dist/index.js +53 -19
- package/dist/index.mjs +58 -24
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
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';
|
|
2
2
|
export { Drawer } from 'antd';
|
|
3
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
4
|
import * as antd_lib_form_Form from 'antd/lib/form/Form';
|
|
4
5
|
import { RuleObject } from 'rc-field-form/lib/interface';
|
|
5
6
|
|
|
@@ -37,6 +38,20 @@ declare function transferOptions(options: BaseOption[]): {
|
|
|
37
38
|
value?: string | number;
|
|
38
39
|
}[];
|
|
39
40
|
|
|
41
|
+
declare type FaasDataWrapperProps<T = any> = {
|
|
42
|
+
dataSource?: T;
|
|
43
|
+
faasData?: {
|
|
44
|
+
action: string;
|
|
45
|
+
params?: Record<string, any>;
|
|
46
|
+
data?: T;
|
|
47
|
+
setData?: Dispatch<SetStateAction<T>>;
|
|
48
|
+
};
|
|
49
|
+
render?: (args: {
|
|
50
|
+
data: T;
|
|
51
|
+
}) => JSX.Element;
|
|
52
|
+
fallback?: JSX.Element;
|
|
53
|
+
};
|
|
54
|
+
|
|
40
55
|
declare type ExtendDescriptionTypeProps = {
|
|
41
56
|
children?: JSX.Element | null;
|
|
42
57
|
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
@@ -48,16 +63,11 @@ declare type DescriptionItemProps<T = any> = {
|
|
|
48
63
|
} & FaasItemProps;
|
|
49
64
|
declare type DescriptionProps<T = any, ExtendItemProps = any> = {
|
|
50
65
|
items: (DescriptionItemProps | ExtendItemProps)[];
|
|
51
|
-
dataSource?: T;
|
|
52
|
-
faasData?: {
|
|
53
|
-
action: string;
|
|
54
|
-
params?: Record<string, any>;
|
|
55
|
-
};
|
|
56
66
|
extendTypes?: {
|
|
57
67
|
[key: string]: ExtendDescriptionTypeProps;
|
|
58
68
|
};
|
|
59
|
-
} & DescriptionsProps;
|
|
60
|
-
declare function Description(props: DescriptionProps): JSX.Element;
|
|
69
|
+
} & FaasDataWrapperProps<T> & DescriptionsProps;
|
|
70
|
+
declare function Description<T = any>(props: DescriptionProps<T>): JSX.Element;
|
|
61
71
|
|
|
62
72
|
declare type DrawerProps = DrawerProps$1 & {
|
|
63
73
|
children?: JSX.Element | JSX.Element[];
|
|
@@ -101,7 +111,8 @@ declare type ExtendFormTypeProps = {
|
|
|
101
111
|
};
|
|
102
112
|
declare type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
|
|
103
113
|
declare type FormItemProps<T = any> = {
|
|
104
|
-
children?: JSX.Element;
|
|
114
|
+
children?: JSX.Element | null;
|
|
115
|
+
render?: () => JSX.Element | null;
|
|
105
116
|
rules?: RuleObject[];
|
|
106
117
|
label?: string | false;
|
|
107
118
|
extendTypes?: {
|
|
@@ -127,22 +138,21 @@ declare namespace Form {
|
|
|
127
138
|
var Item: typeof FormItem;
|
|
128
139
|
}
|
|
129
140
|
|
|
130
|
-
declare type TableItemProps<T = any> =
|
|
141
|
+
declare type TableItemProps<T = any> = {
|
|
142
|
+
/** @deprecated use render */
|
|
143
|
+
children?: JSX.Element | null;
|
|
144
|
+
} & FaasItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
131
145
|
declare type ExtendTableTypeProps = {
|
|
132
146
|
children?: JSX.Element | null;
|
|
133
|
-
render?: (value: any, values: any) => JSX.Element | string | number | boolean | null;
|
|
147
|
+
render?: (value: any, values: any, index: number) => JSX.Element | string | number | boolean | null;
|
|
134
148
|
};
|
|
135
|
-
declare type ExtendTableItemProps<T = any> = BaseItemProps & TableColumnProps<T>;
|
|
149
|
+
declare type ExtendTableItemProps<T = any> = BaseItemProps & Omit<TableColumnProps<T>, 'children'>;
|
|
136
150
|
declare type TableProps<T = any, ExtendTypes = any> = {
|
|
137
151
|
items: (TableItemProps | (ExtendTypes & ExtendTableItemProps))[];
|
|
138
152
|
extendTypes?: {
|
|
139
153
|
[key: string]: ExtendTableTypeProps;
|
|
140
154
|
};
|
|
141
|
-
|
|
142
|
-
action: string;
|
|
143
|
-
params?: Record<string, any>;
|
|
144
|
-
};
|
|
145
|
-
} & TableProps$1<T>;
|
|
155
|
+
} & FaasDataWrapperProps<T> & TableProps$1<T>;
|
|
146
156
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
147
157
|
|
|
148
158
|
export { BaseItemProps, BaseOption, Blank, Description, DescriptionItemProps, DescriptionProps, DrawerProps, ExtendDescriptionItemProps, ExtendDescriptionTypeProps, ExtendFormItemProps, ExtendFormTypeProps, ExtendTableItemProps, ExtendTableTypeProps, FaasItemProps, FaasItemType, FaasItemTypeValue, Form, FormItem, FormItemProps, FormProps, Table, TableItemProps, TableProps, transferOptions, useDrawer };
|
package/dist/index.js
CHANGED
|
@@ -87,7 +87,7 @@ var import_antd2 = require("antd");
|
|
|
87
87
|
var import_lodash3 = require("lodash");
|
|
88
88
|
var import_react4 = require("react");
|
|
89
89
|
|
|
90
|
-
// src/
|
|
90
|
+
// src/FaasDataWrapper.tsx
|
|
91
91
|
var import_react2 = require("react");
|
|
92
92
|
var import_react3 = require("@faasjs/react");
|
|
93
93
|
function FaasDataWrapper({
|
|
@@ -100,13 +100,18 @@ function FaasDataWrapper({
|
|
|
100
100
|
(0, import_react2.useEffect)(() => {
|
|
101
101
|
if (!faasData)
|
|
102
102
|
return;
|
|
103
|
-
(0, import_react3.getClient)().faas(faasData.action, faasData.params).then((res) =>
|
|
104
|
-
|
|
103
|
+
(0, import_react3.getClient)().faas(faasData.action, faasData.params).then((res) => {
|
|
104
|
+
if (faasData.setData)
|
|
105
|
+
faasData.setData(res.data);
|
|
106
|
+
else
|
|
107
|
+
setData(res.data);
|
|
108
|
+
});
|
|
109
|
+
}, [JSON.stringify([faasData == null ? void 0 : faasData.action, faasData == null ? void 0 : faasData.params])]);
|
|
105
110
|
if (dataSource)
|
|
106
111
|
return render({ data: dataSource });
|
|
107
|
-
if (!data)
|
|
112
|
+
if (!data && !faasData.data)
|
|
108
113
|
return fallback || null;
|
|
109
|
-
return render({ data });
|
|
114
|
+
return render({ data: faasData.data || data });
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
// src/Description.tsx
|
|
@@ -175,9 +180,7 @@ function DescriptionItemContent(props) {
|
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
182
|
function Description(props) {
|
|
178
|
-
return /* @__PURE__ */ import_react.default.createElement(FaasDataWrapper, {
|
|
179
|
-
dataSource: props.dataSource,
|
|
180
|
-
faasData: props.faasData,
|
|
183
|
+
return /* @__PURE__ */ import_react.default.createElement(FaasDataWrapper, __spreadProps(__spreadValues({}, props), {
|
|
181
184
|
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, {
|
|
182
185
|
key: item.id,
|
|
183
186
|
label: item.title || (0, import_lodash3.upperFirst)(item.id)
|
|
@@ -187,7 +190,7 @@ function Description(props) {
|
|
|
187
190
|
values: data,
|
|
188
191
|
extendTypes: props.extendTypes
|
|
189
192
|
}))))
|
|
190
|
-
});
|
|
193
|
+
}));
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
// src/Drawer.tsx
|
|
@@ -211,6 +214,7 @@ function useDrawer(init) {
|
|
|
211
214
|
|
|
212
215
|
// src/Form.tsx
|
|
213
216
|
var import_antd5 = require("antd");
|
|
217
|
+
var import_react7 = require("react");
|
|
214
218
|
|
|
215
219
|
// src/FormItem.tsx
|
|
216
220
|
var import_antd4 = require("antd");
|
|
@@ -263,6 +267,8 @@ function FormItem(props) {
|
|
|
263
267
|
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), computedProps.extendTypes[computedProps.type].children);
|
|
264
268
|
if (computedProps.children)
|
|
265
269
|
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), computedProps.children);
|
|
270
|
+
if (computedProps.render)
|
|
271
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), computedProps.render());
|
|
266
272
|
switch (computedProps.type) {
|
|
267
273
|
case "string":
|
|
268
274
|
return /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, __spreadValues({}, computedProps), computedProps.options ? /* @__PURE__ */ import_react.default.createElement(import_antd4.Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ import_react.default.createElement(import_antd4.Input, __spreadValues({}, computedProps.input)));
|
|
@@ -357,20 +363,40 @@ function FormItem(props) {
|
|
|
357
363
|
// src/Form.tsx
|
|
358
364
|
function Form(props) {
|
|
359
365
|
var _a2, _b;
|
|
360
|
-
|
|
366
|
+
const [loading, setLoading] = (0, import_react7.useState)(false);
|
|
367
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
368
|
+
(0, import_react7.useEffect)(() => {
|
|
369
|
+
const propsCopy = __spreadValues({}, props);
|
|
370
|
+
if (propsCopy.onFinish) {
|
|
371
|
+
propsCopy.onFinish = async (values) => {
|
|
372
|
+
setLoading(true);
|
|
373
|
+
try {
|
|
374
|
+
await propsCopy.onFinish(values);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
console.error(error);
|
|
377
|
+
}
|
|
378
|
+
setLoading(false);
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
setComputedProps(props);
|
|
382
|
+
}, []);
|
|
383
|
+
if (!computedProps)
|
|
384
|
+
return null;
|
|
385
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), (_a2 = props.items) == null ? void 0 : _a2.map((item) => /* @__PURE__ */ import_react.default.createElement(FormItem, __spreadProps(__spreadValues({
|
|
361
386
|
key: item.id
|
|
362
387
|
}, item), {
|
|
363
388
|
extendTypes: props.extendTypes
|
|
364
389
|
}))), props.children, props.submit !== false && /* @__PURE__ */ import_react.default.createElement(import_antd5.Button, {
|
|
365
390
|
htmlType: "submit",
|
|
366
|
-
type: "primary"
|
|
391
|
+
type: "primary",
|
|
392
|
+
loading
|
|
367
393
|
}, ((_b = props.submit) == null ? void 0 : _b.text) || "Submit"));
|
|
368
394
|
}
|
|
369
395
|
Form.useForm = import_antd5.Form.useForm;
|
|
370
396
|
Form.Item = FormItem;
|
|
371
397
|
|
|
372
398
|
// src/Table.tsx
|
|
373
|
-
var
|
|
399
|
+
var import_react8 = require("react");
|
|
374
400
|
var import_antd6 = require("antd");
|
|
375
401
|
var import_icons3 = require("@ant-design/icons");
|
|
376
402
|
var import_lodash5 = require("lodash");
|
|
@@ -388,8 +414,8 @@ function processValue(item, value) {
|
|
|
388
414
|
return value;
|
|
389
415
|
}
|
|
390
416
|
function Table(props) {
|
|
391
|
-
const [columns, setColumns] = (0,
|
|
392
|
-
(0,
|
|
417
|
+
const [columns, setColumns] = (0, import_react8.useState)();
|
|
418
|
+
(0, import_react8.useEffect)(() => {
|
|
393
419
|
var _a2;
|
|
394
420
|
for (const item of props.items) {
|
|
395
421
|
if (!item.key)
|
|
@@ -409,9 +435,11 @@ function Table(props) {
|
|
|
409
435
|
}
|
|
410
436
|
if (item.render)
|
|
411
437
|
continue;
|
|
438
|
+
if (item.children)
|
|
439
|
+
delete item.children;
|
|
412
440
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
413
441
|
if (props.extendTypes[item.type].children) {
|
|
414
|
-
item.render = (value, values) => (0,
|
|
442
|
+
item.render = (value, values) => (0, import_react8.cloneElement)(props.extendTypes[item.type].children, {
|
|
415
443
|
value,
|
|
416
444
|
values
|
|
417
445
|
});
|
|
@@ -424,14 +452,20 @@ function Table(props) {
|
|
|
424
452
|
switch (item.type) {
|
|
425
453
|
case "string[]":
|
|
426
454
|
item.render = (value) => processValue(item, value).join(", ");
|
|
455
|
+
if (!item.onFilter)
|
|
456
|
+
item.onFilter = (value, row) => row[item.id].includes(value);
|
|
427
457
|
break;
|
|
428
458
|
case "number":
|
|
429
459
|
item.render = (value) => processValue(item, value);
|
|
430
460
|
if (!item.sorter)
|
|
431
461
|
item.sorter = (a, b) => a[item.id] - b[item.id];
|
|
462
|
+
if (!item.onFilter)
|
|
463
|
+
item.onFilter = (value, row) => value === row[item.id];
|
|
432
464
|
break;
|
|
433
465
|
case "number[]":
|
|
434
466
|
item.render = (value) => processValue(item, value).join(", ");
|
|
467
|
+
if (!item.onFilter)
|
|
468
|
+
item.onFilter = (value, row) => row[item.id].includes(value);
|
|
435
469
|
break;
|
|
436
470
|
case "boolean":
|
|
437
471
|
item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ import_react.default.createElement(Blank, null) : value ? /* @__PURE__ */ import_react.default.createElement(import_icons3.CheckOutlined, {
|
|
@@ -494,6 +528,8 @@ function Table(props) {
|
|
|
494
528
|
break;
|
|
495
529
|
default:
|
|
496
530
|
item.render = (value) => processValue(item, value);
|
|
531
|
+
if (!item.onFilter)
|
|
532
|
+
item.onFilter = (value, row) => value === row[item.id];
|
|
497
533
|
break;
|
|
498
534
|
}
|
|
499
535
|
}
|
|
@@ -501,15 +537,13 @@ function Table(props) {
|
|
|
501
537
|
}, [props.items]);
|
|
502
538
|
if (!columns)
|
|
503
539
|
return null;
|
|
504
|
-
return /* @__PURE__ */ import_react.default.createElement(FaasDataWrapper, {
|
|
505
|
-
dataSource: props.dataSource,
|
|
506
|
-
faasData: props.faasData,
|
|
540
|
+
return /* @__PURE__ */ import_react.default.createElement(FaasDataWrapper, __spreadValues({
|
|
507
541
|
render: ({ data }) => /* @__PURE__ */ import_react.default.createElement(import_antd6.Table, __spreadProps(__spreadValues({}, props), {
|
|
508
542
|
rowKey: props.rowKey || "id",
|
|
509
543
|
columns,
|
|
510
544
|
dataSource: data
|
|
511
545
|
}))
|
|
512
|
-
});
|
|
546
|
+
}, props));
|
|
513
547
|
}
|
|
514
548
|
module.exports = __toCommonJS(src_exports);
|
|
515
549
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -53,8 +53,11 @@ import {
|
|
|
53
53
|
useState as useState2
|
|
54
54
|
} from "react";
|
|
55
55
|
|
|
56
|
-
// src/
|
|
57
|
-
import {
|
|
56
|
+
// src/FaasDataWrapper.tsx
|
|
57
|
+
import {
|
|
58
|
+
useEffect,
|
|
59
|
+
useState
|
|
60
|
+
} from "react";
|
|
58
61
|
import { getClient } from "@faasjs/react";
|
|
59
62
|
function FaasDataWrapper({
|
|
60
63
|
dataSource,
|
|
@@ -66,13 +69,18 @@ function FaasDataWrapper({
|
|
|
66
69
|
useEffect(() => {
|
|
67
70
|
if (!faasData)
|
|
68
71
|
return;
|
|
69
|
-
getClient().faas(faasData.action, faasData.params).then((res) =>
|
|
70
|
-
|
|
72
|
+
getClient().faas(faasData.action, faasData.params).then((res) => {
|
|
73
|
+
if (faasData.setData)
|
|
74
|
+
faasData.setData(res.data);
|
|
75
|
+
else
|
|
76
|
+
setData(res.data);
|
|
77
|
+
});
|
|
78
|
+
}, [JSON.stringify([faasData == null ? void 0 : faasData.action, faasData == null ? void 0 : faasData.params])]);
|
|
71
79
|
if (dataSource)
|
|
72
80
|
return render({ data: dataSource });
|
|
73
|
-
if (!data)
|
|
81
|
+
if (!data && !faasData.data)
|
|
74
82
|
return fallback || null;
|
|
75
|
-
return render({ data });
|
|
83
|
+
return render({ data: faasData.data || data });
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
// src/Description.tsx
|
|
@@ -141,9 +149,7 @@ function DescriptionItemContent(props) {
|
|
|
141
149
|
}
|
|
142
150
|
}
|
|
143
151
|
function Description(props) {
|
|
144
|
-
return /* @__PURE__ */ React.createElement(FaasDataWrapper, {
|
|
145
|
-
dataSource: props.dataSource,
|
|
146
|
-
faasData: props.faasData,
|
|
152
|
+
return /* @__PURE__ */ React.createElement(FaasDataWrapper, __spreadProps(__spreadValues({}, props), {
|
|
147
153
|
render: ({ data }) => /* @__PURE__ */ React.createElement(Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ React.createElement(Descriptions.Item, {
|
|
148
154
|
key: item.id,
|
|
149
155
|
label: item.title || upperFirst2(item.id)
|
|
@@ -153,7 +159,7 @@ function Description(props) {
|
|
|
153
159
|
values: data,
|
|
154
160
|
extendTypes: props.extendTypes
|
|
155
161
|
}))))
|
|
156
|
-
});
|
|
162
|
+
}));
|
|
157
163
|
}
|
|
158
164
|
|
|
159
165
|
// src/Drawer.tsx
|
|
@@ -180,6 +186,7 @@ import {
|
|
|
180
186
|
Button as Button2,
|
|
181
187
|
Form as AntdForm2
|
|
182
188
|
} from "antd";
|
|
189
|
+
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
183
190
|
|
|
184
191
|
// src/FormItem.tsx
|
|
185
192
|
import {
|
|
@@ -193,10 +200,7 @@ import {
|
|
|
193
200
|
Select
|
|
194
201
|
} from "antd";
|
|
195
202
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
196
|
-
import {
|
|
197
|
-
useEffect as useEffect3,
|
|
198
|
-
useState as useState4
|
|
199
|
-
} from "react";
|
|
203
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
200
204
|
import { upperFirst as upperFirst3 } from "lodash";
|
|
201
205
|
function FormItem(props) {
|
|
202
206
|
const [computedProps, setComputedProps] = useState4();
|
|
@@ -244,6 +248,8 @@ function FormItem(props) {
|
|
|
244
248
|
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), computedProps.extendTypes[computedProps.type].children);
|
|
245
249
|
if (computedProps.children)
|
|
246
250
|
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), computedProps.children);
|
|
251
|
+
if (computedProps.render)
|
|
252
|
+
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), computedProps.render());
|
|
247
253
|
switch (computedProps.type) {
|
|
248
254
|
case "string":
|
|
249
255
|
return /* @__PURE__ */ React.createElement(AntdForm.Item, __spreadValues({}, computedProps), computedProps.options ? /* @__PURE__ */ React.createElement(Select, __spreadValues({}, computedProps.input)) : /* @__PURE__ */ React.createElement(Input, __spreadValues({}, computedProps.input)));
|
|
@@ -338,13 +344,33 @@ function FormItem(props) {
|
|
|
338
344
|
// src/Form.tsx
|
|
339
345
|
function Form(props) {
|
|
340
346
|
var _a2, _b;
|
|
341
|
-
|
|
347
|
+
const [loading, setLoading] = useState5(false);
|
|
348
|
+
const [computedProps, setComputedProps] = useState5();
|
|
349
|
+
useEffect4(() => {
|
|
350
|
+
const propsCopy = __spreadValues({}, props);
|
|
351
|
+
if (propsCopy.onFinish) {
|
|
352
|
+
propsCopy.onFinish = async (values) => {
|
|
353
|
+
setLoading(true);
|
|
354
|
+
try {
|
|
355
|
+
await propsCopy.onFinish(values);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
console.error(error);
|
|
358
|
+
}
|
|
359
|
+
setLoading(false);
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
setComputedProps(props);
|
|
363
|
+
}, []);
|
|
364
|
+
if (!computedProps)
|
|
365
|
+
return null;
|
|
366
|
+
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), (_a2 = props.items) == null ? void 0 : _a2.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadProps(__spreadValues({
|
|
342
367
|
key: item.id
|
|
343
368
|
}, item), {
|
|
344
369
|
extendTypes: props.extendTypes
|
|
345
370
|
}))), props.children, props.submit !== false && /* @__PURE__ */ React.createElement(Button2, {
|
|
346
371
|
htmlType: "submit",
|
|
347
|
-
type: "primary"
|
|
372
|
+
type: "primary",
|
|
373
|
+
loading
|
|
348
374
|
}, ((_b = props.submit) == null ? void 0 : _b.text) || "Submit"));
|
|
349
375
|
}
|
|
350
376
|
Form.useForm = AntdForm2.useForm;
|
|
@@ -352,8 +378,8 @@ Form.Item = FormItem;
|
|
|
352
378
|
|
|
353
379
|
// src/Table.tsx
|
|
354
380
|
import {
|
|
355
|
-
useState as
|
|
356
|
-
useEffect as
|
|
381
|
+
useState as useState6,
|
|
382
|
+
useEffect as useEffect5,
|
|
357
383
|
cloneElement as cloneElement2
|
|
358
384
|
} from "react";
|
|
359
385
|
import {
|
|
@@ -376,8 +402,8 @@ function processValue(item, value) {
|
|
|
376
402
|
return value;
|
|
377
403
|
}
|
|
378
404
|
function Table(props) {
|
|
379
|
-
const [columns, setColumns] =
|
|
380
|
-
|
|
405
|
+
const [columns, setColumns] = useState6();
|
|
406
|
+
useEffect5(() => {
|
|
381
407
|
var _a2;
|
|
382
408
|
for (const item of props.items) {
|
|
383
409
|
if (!item.key)
|
|
@@ -397,6 +423,8 @@ function Table(props) {
|
|
|
397
423
|
}
|
|
398
424
|
if (item.render)
|
|
399
425
|
continue;
|
|
426
|
+
if (item.children)
|
|
427
|
+
delete item.children;
|
|
400
428
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
401
429
|
if (props.extendTypes[item.type].children) {
|
|
402
430
|
item.render = (value, values) => cloneElement2(props.extendTypes[item.type].children, {
|
|
@@ -412,14 +440,20 @@ function Table(props) {
|
|
|
412
440
|
switch (item.type) {
|
|
413
441
|
case "string[]":
|
|
414
442
|
item.render = (value) => processValue(item, value).join(", ");
|
|
443
|
+
if (!item.onFilter)
|
|
444
|
+
item.onFilter = (value, row) => row[item.id].includes(value);
|
|
415
445
|
break;
|
|
416
446
|
case "number":
|
|
417
447
|
item.render = (value) => processValue(item, value);
|
|
418
448
|
if (!item.sorter)
|
|
419
449
|
item.sorter = (a, b) => a[item.id] - b[item.id];
|
|
450
|
+
if (!item.onFilter)
|
|
451
|
+
item.onFilter = (value, row) => value === row[item.id];
|
|
420
452
|
break;
|
|
421
453
|
case "number[]":
|
|
422
454
|
item.render = (value) => processValue(item, value).join(", ");
|
|
455
|
+
if (!item.onFilter)
|
|
456
|
+
item.onFilter = (value, row) => row[item.id].includes(value);
|
|
423
457
|
break;
|
|
424
458
|
case "boolean":
|
|
425
459
|
item.render = (value) => typeof value === "undefined" ? /* @__PURE__ */ React.createElement(Blank, null) : value ? /* @__PURE__ */ React.createElement(CheckOutlined2, {
|
|
@@ -482,6 +516,8 @@ function Table(props) {
|
|
|
482
516
|
break;
|
|
483
517
|
default:
|
|
484
518
|
item.render = (value) => processValue(item, value);
|
|
519
|
+
if (!item.onFilter)
|
|
520
|
+
item.onFilter = (value, row) => value === row[item.id];
|
|
485
521
|
break;
|
|
486
522
|
}
|
|
487
523
|
}
|
|
@@ -489,15 +525,13 @@ function Table(props) {
|
|
|
489
525
|
}, [props.items]);
|
|
490
526
|
if (!columns)
|
|
491
527
|
return null;
|
|
492
|
-
return /* @__PURE__ */ React.createElement(FaasDataWrapper, {
|
|
493
|
-
dataSource: props.dataSource,
|
|
494
|
-
faasData: props.faasData,
|
|
528
|
+
return /* @__PURE__ */ React.createElement(FaasDataWrapper, __spreadValues({
|
|
495
529
|
render: ({ data }) => /* @__PURE__ */ React.createElement(AntdTable, __spreadProps(__spreadValues({}, props), {
|
|
496
530
|
rowKey: props.rowKey || "id",
|
|
497
531
|
columns,
|
|
498
532
|
dataSource: data
|
|
499
533
|
}))
|
|
500
|
-
});
|
|
534
|
+
}, props));
|
|
501
535
|
}
|
|
502
536
|
export {
|
|
503
537
|
Blank,
|
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.352",
|
|
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.352"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/lodash": "*",
|