@faasjs/ant-design 0.0.2-beta.357 → 0.0.2-beta.361
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 +10 -1
- package/dist/index.js +52 -29
- package/dist/index.mjs +59 -32
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as react_use_lib_misc_hookState from 'react-use/lib/misc/hookState';
|
|
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';
|
|
2
|
+
import { DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, SelectProps, FormProps as FormProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1 } from 'antd';
|
|
3
3
|
export { Drawer } from 'antd';
|
|
4
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
7
|
import { LazyExoticComponent, ComponentType } from 'react';
|
|
8
8
|
import { RouteProps } from 'react-router-dom';
|
|
9
|
+
import { FilterValue, SorterResult, TableCurrentDataSource } from 'antd/lib/table/interface';
|
|
9
10
|
|
|
10
11
|
declare type BlankProps = {
|
|
11
12
|
value?: any;
|
|
@@ -18,6 +19,7 @@ declare type FaasState = {
|
|
|
18
19
|
blank: string;
|
|
19
20
|
all: string;
|
|
20
21
|
submit: string;
|
|
22
|
+
pageNotFound: string;
|
|
21
23
|
};
|
|
22
24
|
Blank: {
|
|
23
25
|
text: string;
|
|
@@ -158,6 +160,7 @@ declare type RoutesProps = {
|
|
|
158
160
|
routes: (RouteProps & {
|
|
159
161
|
page?: LazyExoticComponent<ComponentType<any>>;
|
|
160
162
|
})[];
|
|
163
|
+
fallback?: JSX.Element;
|
|
161
164
|
notFound?: JSX.Element;
|
|
162
165
|
};
|
|
163
166
|
declare function Routes(props: RoutesProps): JSX.Element;
|
|
@@ -177,6 +180,12 @@ declare type TableProps<T = any, ExtendTypes = any> = {
|
|
|
177
180
|
[key: string]: ExtendTableTypeProps;
|
|
178
181
|
};
|
|
179
182
|
faasData?: FaasDataWrapperProps<T>;
|
|
183
|
+
onChange?: (pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<T> | SorterResult<T>[], extra: TableCurrentDataSource<T>) => {
|
|
184
|
+
pagination: TablePaginationConfig;
|
|
185
|
+
filters: Record<string, FilterValue | null>;
|
|
186
|
+
sorter: SorterResult<T> | SorterResult<T>[];
|
|
187
|
+
extra: TableCurrentDataSource<T>;
|
|
188
|
+
};
|
|
180
189
|
} & TableProps$1<T>;
|
|
181
190
|
declare function Table<T = any, ExtendTypes = any>(props: TableProps<T, ExtendTypes>): JSX.Element;
|
|
182
191
|
|
package/dist/index.js
CHANGED
|
@@ -70,11 +70,17 @@ var import_lodash = require("lodash");
|
|
|
70
70
|
// src/Config.tsx
|
|
71
71
|
var import_react2 = require("react");
|
|
72
72
|
var import_react_use = require("react-use");
|
|
73
|
-
var
|
|
74
|
-
var common = {
|
|
75
|
-
blank:
|
|
76
|
-
all:
|
|
77
|
-
submit:
|
|
73
|
+
var isCN = /^zh/i.test(navigator.language);
|
|
74
|
+
var common = isCN ? {
|
|
75
|
+
blank: "\u7A7A",
|
|
76
|
+
all: "\u5168\u90E8",
|
|
77
|
+
submit: "\u63D0\u4EA4",
|
|
78
|
+
pageNotFound: "\u9875\u9762\u672A\u627E\u5230"
|
|
79
|
+
} : {
|
|
80
|
+
blank: "Empty",
|
|
81
|
+
all: "All",
|
|
82
|
+
submit: "Submit",
|
|
83
|
+
pageNotFound: "Page Not Found"
|
|
78
84
|
};
|
|
79
85
|
var useFaasState = (0, import_react_use.createGlobalState)({
|
|
80
86
|
common,
|
|
@@ -121,23 +127,23 @@ var import_react4 = require("@faasjs/react");
|
|
|
121
127
|
function DescriptionItemContent(props) {
|
|
122
128
|
const [computedProps, setComputedProps] = (0, import_react3.useState)();
|
|
123
129
|
(0, import_react3.useEffect)(() => {
|
|
124
|
-
var
|
|
130
|
+
var _a, _b;
|
|
125
131
|
const propsCopy = __spreadValues({}, props);
|
|
126
132
|
if (!propsCopy.item.title)
|
|
127
133
|
propsCopy.item.title = (0, import_lodash3.upperFirst)(propsCopy.item.id);
|
|
128
134
|
if (!propsCopy.item.type)
|
|
129
135
|
propsCopy.item.type = "string";
|
|
130
|
-
if ((
|
|
136
|
+
if ((_a = propsCopy.item.options) == null ? void 0 : _a.length) {
|
|
131
137
|
propsCopy.item.options = transferOptions(propsCopy.item.options);
|
|
132
138
|
}
|
|
133
139
|
if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
|
|
134
140
|
if (propsCopy.item.type.endsWith("[]"))
|
|
135
141
|
propsCopy.value = propsCopy.value.map((v) => {
|
|
136
|
-
var
|
|
137
|
-
return ((
|
|
142
|
+
var _a2;
|
|
143
|
+
return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
138
144
|
});
|
|
139
145
|
else
|
|
140
|
-
propsCopy.value = ((
|
|
146
|
+
propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
|
|
141
147
|
}
|
|
142
148
|
setComputedProps(propsCopy);
|
|
143
149
|
}, [props]);
|
|
@@ -194,6 +200,9 @@ function Description(props) {
|
|
|
194
200
|
extendTypes: props.extendTypes
|
|
195
201
|
}))));
|
|
196
202
|
return /* @__PURE__ */ import_react.default.createElement(import_react4.FaasDataWrapper, __spreadValues({
|
|
203
|
+
fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd2.Skeleton, {
|
|
204
|
+
active: true
|
|
205
|
+
}),
|
|
197
206
|
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, {
|
|
198
207
|
key: item.id,
|
|
199
208
|
label: item.title || (0, import_lodash3.upperFirst)(item.id)
|
|
@@ -334,11 +343,11 @@ function FormItem(props) {
|
|
|
334
343
|
name: computedProps.name,
|
|
335
344
|
rules: computedProps.rules
|
|
336
345
|
}, (fields, { add, remove }, { errors }) => {
|
|
337
|
-
var
|
|
346
|
+
var _a;
|
|
338
347
|
return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, computedProps.label && /* @__PURE__ */ import_react.default.createElement("div", {
|
|
339
348
|
className: "ant-form-item-label"
|
|
340
349
|
}, /* @__PURE__ */ import_react.default.createElement("label", {
|
|
341
|
-
className: ((
|
|
350
|
+
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
|
|
342
351
|
}, computedProps.label)), fields.map((field) => /* @__PURE__ */ import_react.default.createElement(import_antd4.Form.Item, {
|
|
343
352
|
key: field.key
|
|
344
353
|
}, /* @__PURE__ */ import_react.default.createElement(import_antd4.Row, {
|
|
@@ -375,7 +384,7 @@ function FormItem(props) {
|
|
|
375
384
|
|
|
376
385
|
// src/Form.tsx
|
|
377
386
|
function Form(props) {
|
|
378
|
-
var
|
|
387
|
+
var _a, _b;
|
|
379
388
|
const [loading, setLoading] = (0, import_react7.useState)(false);
|
|
380
389
|
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
381
390
|
const [config] = useFaasState();
|
|
@@ -396,7 +405,7 @@ function Form(props) {
|
|
|
396
405
|
}, []);
|
|
397
406
|
if (!computedProps)
|
|
398
407
|
return null;
|
|
399
|
-
return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), (
|
|
408
|
+
return /* @__PURE__ */ import_react.default.createElement(import_antd5.Form, __spreadValues({}, computedProps), (_a = props.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ import_react.default.createElement(FormItem, __spreadProps(__spreadValues({
|
|
400
409
|
key: item.id
|
|
401
410
|
}, item), {
|
|
402
411
|
extendTypes: props.extendTypes
|
|
@@ -404,7 +413,7 @@ function Form(props) {
|
|
|
404
413
|
htmlType: "submit",
|
|
405
414
|
type: "primary",
|
|
406
415
|
loading
|
|
407
|
-
}, ((
|
|
416
|
+
}, ((_b = props.submit) == null ? void 0 : _b.text) || config.Form.submit.text));
|
|
408
417
|
}
|
|
409
418
|
Form.useForm = import_antd5.Form.useForm;
|
|
410
419
|
Form.Item = FormItem;
|
|
@@ -413,11 +422,11 @@ Form.Item = FormItem;
|
|
|
413
422
|
var import_antd6 = require("antd");
|
|
414
423
|
var import_react8 = require("react");
|
|
415
424
|
var import_react_router_dom = require("react-router-dom");
|
|
416
|
-
function
|
|
425
|
+
function NotFound() {
|
|
426
|
+
const [config] = useFaasState();
|
|
417
427
|
return /* @__PURE__ */ import_react.default.createElement(import_antd6.Result, {
|
|
418
428
|
status: "404",
|
|
419
|
-
title:
|
|
420
|
-
subTitle: "Page not found"
|
|
429
|
+
title: config.common.pageNotFound
|
|
421
430
|
});
|
|
422
431
|
}
|
|
423
432
|
function Routes(props) {
|
|
@@ -425,14 +434,16 @@ function Routes(props) {
|
|
|
425
434
|
key: r.path
|
|
426
435
|
}, r), {
|
|
427
436
|
element: r.element || /* @__PURE__ */ import_react.default.createElement(import_react8.Suspense, {
|
|
428
|
-
fallback: /* @__PURE__ */ import_react.default.createElement(
|
|
437
|
+
fallback: props.fallback || /* @__PURE__ */ import_react.default.createElement("div", {
|
|
438
|
+
style: { padding: "24px" }
|
|
439
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_antd6.Skeleton, {
|
|
429
440
|
active: true
|
|
430
|
-
})
|
|
441
|
+
}))
|
|
431
442
|
}, /* @__PURE__ */ import_react.default.createElement(r.page, null))
|
|
432
443
|
}))), /* @__PURE__ */ import_react.default.createElement(import_react_router_dom.Route, {
|
|
433
444
|
key: "*",
|
|
434
445
|
path: "*",
|
|
435
|
-
element: props.notFound || /* @__PURE__ */ import_react.default.createElement(
|
|
446
|
+
element: props.notFound || /* @__PURE__ */ import_react.default.createElement(NotFound, null)
|
|
436
447
|
}));
|
|
437
448
|
}
|
|
438
449
|
|
|
@@ -443,15 +454,15 @@ var import_icons3 = require("@ant-design/icons");
|
|
|
443
454
|
var import_lodash5 = require("lodash");
|
|
444
455
|
var import_react10 = require("@faasjs/react");
|
|
445
456
|
function processValue(item, value) {
|
|
446
|
-
var
|
|
457
|
+
var _a;
|
|
447
458
|
if (item.options && typeof value !== "undefined" && value !== null) {
|
|
448
459
|
if (item.type.endsWith("[]"))
|
|
449
460
|
return value.map((v) => {
|
|
450
|
-
var
|
|
451
|
-
return ((
|
|
461
|
+
var _a2;
|
|
462
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
452
463
|
});
|
|
453
464
|
else
|
|
454
|
-
return ((
|
|
465
|
+
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
455
466
|
}
|
|
456
467
|
return value;
|
|
457
468
|
}
|
|
@@ -459,7 +470,7 @@ function Table(props) {
|
|
|
459
470
|
const [columns, setColumns] = (0, import_react9.useState)();
|
|
460
471
|
const [config] = useFaasState();
|
|
461
472
|
(0, import_react9.useEffect)(() => {
|
|
462
|
-
var
|
|
473
|
+
var _a;
|
|
463
474
|
for (const item of props.items) {
|
|
464
475
|
if (!item.key)
|
|
465
476
|
item.key = item.id;
|
|
@@ -469,7 +480,7 @@ function Table(props) {
|
|
|
469
480
|
item.title = (0, import_lodash5.upperFirst)(item.id);
|
|
470
481
|
if (!item.type)
|
|
471
482
|
item.type = "string";
|
|
472
|
-
if ((
|
|
483
|
+
if ((_a = item.options) == null ? void 0 : _a.length) {
|
|
473
484
|
item.options = transferOptions(item.options);
|
|
474
485
|
item.filters = item.options.map((o) => ({
|
|
475
486
|
text: o.label,
|
|
@@ -584,6 +595,9 @@ function Table(props) {
|
|
|
584
595
|
dataSource: props.dataSource
|
|
585
596
|
}));
|
|
586
597
|
return /* @__PURE__ */ import_react.default.createElement(import_react10.FaasDataWrapper, __spreadValues({
|
|
598
|
+
fallback: props.faasData.fallback || /* @__PURE__ */ import_react.default.createElement(import_antd7.Skeleton, {
|
|
599
|
+
active: true
|
|
600
|
+
}),
|
|
587
601
|
render: ({
|
|
588
602
|
data,
|
|
589
603
|
params,
|
|
@@ -605,8 +619,17 @@ function Table(props) {
|
|
|
605
619
|
rowKey: props.rowKey || "id",
|
|
606
620
|
columns,
|
|
607
621
|
dataSource: data.rows,
|
|
608
|
-
pagination: data.pagination,
|
|
609
|
-
onChange: (pagination, filters, sorter) => {
|
|
622
|
+
pagination: __spreadValues(__spreadValues({}, props.pagination), data.pagination),
|
|
623
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
624
|
+
if (props.onChange) {
|
|
625
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
626
|
+
reload(__spreadProps(__spreadValues({}, params), {
|
|
627
|
+
pagination: processed.pagination,
|
|
628
|
+
filters: processed.filters,
|
|
629
|
+
sorter: processed.sorter
|
|
630
|
+
}));
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
610
633
|
reload(__spreadProps(__spreadValues({}, params), {
|
|
611
634
|
pagination,
|
|
612
635
|
filters,
|
package/dist/index.mjs
CHANGED
|
@@ -28,11 +28,17 @@ import { isNil } from "lodash";
|
|
|
28
28
|
// src/Config.tsx
|
|
29
29
|
import { useEffect } from "react";
|
|
30
30
|
import { createGlobalState } from "react-use";
|
|
31
|
-
var
|
|
32
|
-
var common = {
|
|
33
|
-
blank:
|
|
34
|
-
all:
|
|
35
|
-
submit:
|
|
31
|
+
var isCN = /^zh/i.test(navigator.language);
|
|
32
|
+
var common = isCN ? {
|
|
33
|
+
blank: "\u7A7A",
|
|
34
|
+
all: "\u5168\u90E8",
|
|
35
|
+
submit: "\u63D0\u4EA4",
|
|
36
|
+
pageNotFound: "\u9875\u9762\u672A\u627E\u5230"
|
|
37
|
+
} : {
|
|
38
|
+
blank: "Empty",
|
|
39
|
+
all: "All",
|
|
40
|
+
submit: "Submit",
|
|
41
|
+
pageNotFound: "Page Not Found"
|
|
36
42
|
};
|
|
37
43
|
var useFaasState = createGlobalState({
|
|
38
44
|
common,
|
|
@@ -72,7 +78,10 @@ function transferOptions(options) {
|
|
|
72
78
|
|
|
73
79
|
// src/Description.tsx
|
|
74
80
|
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
75
|
-
import {
|
|
81
|
+
import {
|
|
82
|
+
Descriptions,
|
|
83
|
+
Skeleton
|
|
84
|
+
} from "antd";
|
|
76
85
|
import { upperFirst as upperFirst2 } from "lodash";
|
|
77
86
|
import {
|
|
78
87
|
cloneElement,
|
|
@@ -83,23 +92,23 @@ import { FaasDataWrapper } from "@faasjs/react";
|
|
|
83
92
|
function DescriptionItemContent(props) {
|
|
84
93
|
const [computedProps, setComputedProps] = useState();
|
|
85
94
|
useEffect2(() => {
|
|
86
|
-
var
|
|
95
|
+
var _a, _b;
|
|
87
96
|
const propsCopy = __spreadValues({}, props);
|
|
88
97
|
if (!propsCopy.item.title)
|
|
89
98
|
propsCopy.item.title = upperFirst2(propsCopy.item.id);
|
|
90
99
|
if (!propsCopy.item.type)
|
|
91
100
|
propsCopy.item.type = "string";
|
|
92
|
-
if ((
|
|
101
|
+
if ((_a = propsCopy.item.options) == null ? void 0 : _a.length) {
|
|
93
102
|
propsCopy.item.options = transferOptions(propsCopy.item.options);
|
|
94
103
|
}
|
|
95
104
|
if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
|
|
96
105
|
if (propsCopy.item.type.endsWith("[]"))
|
|
97
106
|
propsCopy.value = propsCopy.value.map((v) => {
|
|
98
|
-
var
|
|
99
|
-
return ((
|
|
107
|
+
var _a2;
|
|
108
|
+
return ((_a2 = propsCopy.item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
100
109
|
});
|
|
101
110
|
else
|
|
102
|
-
propsCopy.value = ((
|
|
111
|
+
propsCopy.value = ((_b = props.item.options.find((option) => option.value === props.value)) == null ? void 0 : _b.label) || props.value;
|
|
103
112
|
}
|
|
104
113
|
setComputedProps(propsCopy);
|
|
105
114
|
}, [props]);
|
|
@@ -156,6 +165,9 @@ function Description(props) {
|
|
|
156
165
|
extendTypes: props.extendTypes
|
|
157
166
|
}))));
|
|
158
167
|
return /* @__PURE__ */ React.createElement(FaasDataWrapper, __spreadValues({
|
|
168
|
+
fallback: props.faasData.fallback || /* @__PURE__ */ React.createElement(Skeleton, {
|
|
169
|
+
active: true
|
|
170
|
+
}),
|
|
159
171
|
render: ({ data }) => /* @__PURE__ */ React.createElement(Descriptions, __spreadValues({}, props), props.items.map((item) => /* @__PURE__ */ React.createElement(Descriptions.Item, {
|
|
160
172
|
key: item.id,
|
|
161
173
|
label: item.title || upperFirst2(item.id)
|
|
@@ -308,11 +320,11 @@ function FormItem(props) {
|
|
|
308
320
|
name: computedProps.name,
|
|
309
321
|
rules: computedProps.rules
|
|
310
322
|
}, (fields, { add, remove }, { errors }) => {
|
|
311
|
-
var
|
|
323
|
+
var _a;
|
|
312
324
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, computedProps.label && /* @__PURE__ */ React.createElement("div", {
|
|
313
325
|
className: "ant-form-item-label"
|
|
314
326
|
}, /* @__PURE__ */ React.createElement("label", {
|
|
315
|
-
className: ((
|
|
327
|
+
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required"
|
|
316
328
|
}, computedProps.label)), fields.map((field) => /* @__PURE__ */ React.createElement(AntdForm.Item, {
|
|
317
329
|
key: field.key
|
|
318
330
|
}, /* @__PURE__ */ React.createElement(Row, {
|
|
@@ -349,7 +361,7 @@ function FormItem(props) {
|
|
|
349
361
|
|
|
350
362
|
// src/Form.tsx
|
|
351
363
|
function Form(props) {
|
|
352
|
-
var
|
|
364
|
+
var _a, _b;
|
|
353
365
|
const [loading, setLoading] = useState4(false);
|
|
354
366
|
const [computedProps, setComputedProps] = useState4();
|
|
355
367
|
const [config] = useFaasState();
|
|
@@ -370,7 +382,7 @@ function Form(props) {
|
|
|
370
382
|
}, []);
|
|
371
383
|
if (!computedProps)
|
|
372
384
|
return null;
|
|
373
|
-
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), (
|
|
385
|
+
return /* @__PURE__ */ React.createElement(AntdForm2, __spreadValues({}, computedProps), (_a = props.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ React.createElement(FormItem, __spreadProps(__spreadValues({
|
|
374
386
|
key: item.id
|
|
375
387
|
}, item), {
|
|
376
388
|
extendTypes: props.extendTypes
|
|
@@ -378,13 +390,13 @@ function Form(props) {
|
|
|
378
390
|
htmlType: "submit",
|
|
379
391
|
type: "primary",
|
|
380
392
|
loading
|
|
381
|
-
}, ((
|
|
393
|
+
}, ((_b = props.submit) == null ? void 0 : _b.text) || config.Form.submit.text));
|
|
382
394
|
}
|
|
383
395
|
Form.useForm = AntdForm2.useForm;
|
|
384
396
|
Form.Item = FormItem;
|
|
385
397
|
|
|
386
398
|
// src/Routers.tsx
|
|
387
|
-
import { Result, Skeleton } from "antd";
|
|
399
|
+
import { Result, Skeleton as Skeleton2 } from "antd";
|
|
388
400
|
import {
|
|
389
401
|
Suspense
|
|
390
402
|
} from "react";
|
|
@@ -392,11 +404,11 @@ import {
|
|
|
392
404
|
Routes as OriginRoutes,
|
|
393
405
|
Route
|
|
394
406
|
} from "react-router-dom";
|
|
395
|
-
function
|
|
407
|
+
function NotFound() {
|
|
408
|
+
const [config] = useFaasState();
|
|
396
409
|
return /* @__PURE__ */ React.createElement(Result, {
|
|
397
410
|
status: "404",
|
|
398
|
-
title:
|
|
399
|
-
subTitle: "Page not found"
|
|
411
|
+
title: config.common.pageNotFound
|
|
400
412
|
});
|
|
401
413
|
}
|
|
402
414
|
function Routes(props) {
|
|
@@ -404,14 +416,16 @@ function Routes(props) {
|
|
|
404
416
|
key: r.path
|
|
405
417
|
}, r), {
|
|
406
418
|
element: r.element || /* @__PURE__ */ React.createElement(Suspense, {
|
|
407
|
-
fallback: /* @__PURE__ */ React.createElement(
|
|
419
|
+
fallback: props.fallback || /* @__PURE__ */ React.createElement("div", {
|
|
420
|
+
style: { padding: "24px" }
|
|
421
|
+
}, /* @__PURE__ */ React.createElement(Skeleton2, {
|
|
408
422
|
active: true
|
|
409
|
-
})
|
|
423
|
+
}))
|
|
410
424
|
}, /* @__PURE__ */ React.createElement(r.page, null))
|
|
411
425
|
}))), /* @__PURE__ */ React.createElement(Route, {
|
|
412
426
|
key: "*",
|
|
413
427
|
path: "*",
|
|
414
|
-
element: props.notFound || /* @__PURE__ */ React.createElement(
|
|
428
|
+
element: props.notFound || /* @__PURE__ */ React.createElement(NotFound, null)
|
|
415
429
|
}));
|
|
416
430
|
}
|
|
417
431
|
|
|
@@ -423,21 +437,22 @@ import {
|
|
|
423
437
|
} from "react";
|
|
424
438
|
import {
|
|
425
439
|
Table as AntdTable,
|
|
426
|
-
Radio
|
|
440
|
+
Radio,
|
|
441
|
+
Skeleton as Skeleton3
|
|
427
442
|
} from "antd";
|
|
428
443
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
429
444
|
import { isNil as isNil2, upperFirst as upperFirst4 } from "lodash";
|
|
430
445
|
import { FaasDataWrapper as FaasDataWrapper2 } from "@faasjs/react";
|
|
431
446
|
function processValue(item, value) {
|
|
432
|
-
var
|
|
447
|
+
var _a;
|
|
433
448
|
if (item.options && typeof value !== "undefined" && value !== null) {
|
|
434
449
|
if (item.type.endsWith("[]"))
|
|
435
450
|
return value.map((v) => {
|
|
436
|
-
var
|
|
437
|
-
return ((
|
|
451
|
+
var _a2;
|
|
452
|
+
return ((_a2 = item.options.find((option) => option.value === v)) == null ? void 0 : _a2.label) || v;
|
|
438
453
|
});
|
|
439
454
|
else
|
|
440
|
-
return ((
|
|
455
|
+
return ((_a = item.options.find((option) => option.value === value)) == null ? void 0 : _a.label) || value;
|
|
441
456
|
}
|
|
442
457
|
return value;
|
|
443
458
|
}
|
|
@@ -445,7 +460,7 @@ function Table(props) {
|
|
|
445
460
|
const [columns, setColumns] = useState5();
|
|
446
461
|
const [config] = useFaasState();
|
|
447
462
|
useEffect5(() => {
|
|
448
|
-
var
|
|
463
|
+
var _a;
|
|
449
464
|
for (const item of props.items) {
|
|
450
465
|
if (!item.key)
|
|
451
466
|
item.key = item.id;
|
|
@@ -455,7 +470,7 @@ function Table(props) {
|
|
|
455
470
|
item.title = upperFirst4(item.id);
|
|
456
471
|
if (!item.type)
|
|
457
472
|
item.type = "string";
|
|
458
|
-
if ((
|
|
473
|
+
if ((_a = item.options) == null ? void 0 : _a.length) {
|
|
459
474
|
item.options = transferOptions(item.options);
|
|
460
475
|
item.filters = item.options.map((o) => ({
|
|
461
476
|
text: o.label,
|
|
@@ -570,6 +585,9 @@ function Table(props) {
|
|
|
570
585
|
dataSource: props.dataSource
|
|
571
586
|
}));
|
|
572
587
|
return /* @__PURE__ */ React.createElement(FaasDataWrapper2, __spreadValues({
|
|
588
|
+
fallback: props.faasData.fallback || /* @__PURE__ */ React.createElement(Skeleton3, {
|
|
589
|
+
active: true
|
|
590
|
+
}),
|
|
573
591
|
render: ({
|
|
574
592
|
data,
|
|
575
593
|
params,
|
|
@@ -591,8 +609,17 @@ function Table(props) {
|
|
|
591
609
|
rowKey: props.rowKey || "id",
|
|
592
610
|
columns,
|
|
593
611
|
dataSource: data.rows,
|
|
594
|
-
pagination: data.pagination,
|
|
595
|
-
onChange: (pagination, filters, sorter) => {
|
|
612
|
+
pagination: __spreadValues(__spreadValues({}, props.pagination), data.pagination),
|
|
613
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
614
|
+
if (props.onChange) {
|
|
615
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
616
|
+
reload(__spreadProps(__spreadValues({}, params), {
|
|
617
|
+
pagination: processed.pagination,
|
|
618
|
+
filters: processed.filters,
|
|
619
|
+
sorter: processed.sorter
|
|
620
|
+
}));
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
596
623
|
reload(__spreadProps(__spreadValues({}, params), {
|
|
597
624
|
pagination,
|
|
598
625
|
filters,
|
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.361",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lodash": "*",
|
|
29
29
|
"react": "*",
|
|
30
30
|
"react-dom": "*",
|
|
31
|
-
"@faasjs/react": "^0.0.2-beta.
|
|
31
|
+
"@faasjs/react": "^0.0.2-beta.361",
|
|
32
32
|
"react-use": "*",
|
|
33
33
|
"react-router-dom": "*"
|
|
34
34
|
},
|