@faasjs/ant-design 0.0.3-beta.64 → 0.0.3-beta.66
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/README.md +57 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +770 -737
- package/dist/index.mjs +744 -715
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
-
var __spreadValues = (a, b) => {
|
|
14
|
-
for (var prop in b || (b = {}))
|
|
15
|
-
if (__hasOwnProp.call(b, prop))
|
|
16
|
-
__defNormalProp(a, prop, b[prop]);
|
|
17
|
-
if (__getOwnPropSymbols)
|
|
18
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
-
if (__propIsEnum.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
}
|
|
22
|
-
return a;
|
|
23
|
-
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
8
|
var __export = (target, all) => {
|
|
26
9
|
for (var name in all)
|
|
27
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -35,10 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
35
18
|
return to;
|
|
36
19
|
};
|
|
37
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
38
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
39
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
40
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
41
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
42
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
43
22
|
mod
|
|
44
23
|
));
|
|
@@ -54,7 +33,7 @@ __export(src_exports, {
|
|
|
54
33
|
Description: () => Description,
|
|
55
34
|
Drawer: () => import_antd2.Drawer,
|
|
56
35
|
ErrorBoundary: () => ErrorBoundary,
|
|
57
|
-
FaasDataWrapper: () =>
|
|
36
|
+
FaasDataWrapper: () => FaasDataWrapper,
|
|
58
37
|
Form: () => Form,
|
|
59
38
|
FormItem: () => FormItem,
|
|
60
39
|
Link: () => Link,
|
|
@@ -64,7 +43,7 @@ __export(src_exports, {
|
|
|
64
43
|
Routes: () => Routes,
|
|
65
44
|
Table: () => Table,
|
|
66
45
|
Title: () => Title,
|
|
67
|
-
lazy: () =>
|
|
46
|
+
lazy: () => import_react13.lazy,
|
|
68
47
|
transferOptions: () => transferOptions,
|
|
69
48
|
transferValue: () => transferValue,
|
|
70
49
|
useApp: () => useApp,
|
|
@@ -87,17 +66,24 @@ var import_antd = require("antd");
|
|
|
87
66
|
var import_react2 = require("react");
|
|
88
67
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
89
68
|
function useModal(init) {
|
|
90
|
-
const [props, setProps] = (0, import_react2.useState)(
|
|
69
|
+
const [props, setProps] = (0, import_react2.useState)({
|
|
91
70
|
open: false,
|
|
92
|
-
onCancel: () => setProps((prev) =>
|
|
71
|
+
onCancel: () => setProps((prev) => ({
|
|
72
|
+
...prev,
|
|
93
73
|
open: false
|
|
94
|
-
}))
|
|
95
|
-
|
|
74
|
+
})),
|
|
75
|
+
...init
|
|
76
|
+
});
|
|
96
77
|
return {
|
|
97
|
-
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Modal,
|
|
78
|
+
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Modal, {
|
|
79
|
+
...props
|
|
80
|
+
}),
|
|
98
81
|
modalProps: props,
|
|
99
82
|
setModalProps(changes) {
|
|
100
|
-
setProps((prev) =>
|
|
83
|
+
setProps((prev) => ({
|
|
84
|
+
...prev,
|
|
85
|
+
...changes
|
|
86
|
+
}));
|
|
101
87
|
}
|
|
102
88
|
};
|
|
103
89
|
}
|
|
@@ -105,26 +91,33 @@ function useModal(init) {
|
|
|
105
91
|
// src/Drawer.tsx
|
|
106
92
|
var import_antd2 = require("antd");
|
|
107
93
|
var import_react3 = require("react");
|
|
108
|
-
var
|
|
94
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
109
95
|
function useDrawer(init) {
|
|
110
|
-
const [props, setProps] = (0, import_react3.useState)(
|
|
96
|
+
const [props, setProps] = (0, import_react3.useState)({
|
|
111
97
|
open: false,
|
|
112
|
-
onClose: () => setProps((prev) =>
|
|
98
|
+
onClose: () => setProps((prev) => ({
|
|
99
|
+
...prev,
|
|
113
100
|
open: false
|
|
114
|
-
}))
|
|
115
|
-
|
|
101
|
+
})),
|
|
102
|
+
...init
|
|
103
|
+
});
|
|
116
104
|
return {
|
|
117
|
-
drawer: /* @__PURE__ */ (0,
|
|
105
|
+
drawer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Drawer, {
|
|
106
|
+
...props
|
|
107
|
+
}),
|
|
118
108
|
drawerProps: props,
|
|
119
109
|
setDrawerProps(changes) {
|
|
120
|
-
setProps((prev) =>
|
|
110
|
+
setProps((prev) => ({
|
|
111
|
+
...prev,
|
|
112
|
+
...changes
|
|
113
|
+
}));
|
|
121
114
|
}
|
|
122
115
|
};
|
|
123
116
|
}
|
|
124
117
|
|
|
125
118
|
// src/App.tsx
|
|
126
119
|
var import_react_router_dom = require("react-router-dom");
|
|
127
|
-
var
|
|
120
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
128
121
|
var AppContext = (0, import_react4.createContext)({
|
|
129
122
|
message: {},
|
|
130
123
|
notification: {},
|
|
@@ -139,7 +132,9 @@ function RoutesApp(props) {
|
|
|
139
132
|
setDrawerProps({ open: false });
|
|
140
133
|
setModalProps({ open: false });
|
|
141
134
|
}, [location]);
|
|
142
|
-
return /* @__PURE__ */ (0,
|
|
135
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
136
|
+
children: props.children
|
|
137
|
+
});
|
|
143
138
|
}
|
|
144
139
|
function App(props) {
|
|
145
140
|
const [messageApi, messageContextHolder] = import_antd3.message.useMessage();
|
|
@@ -160,21 +155,30 @@ function App(props) {
|
|
|
160
155
|
setDrawerProps
|
|
161
156
|
]
|
|
162
157
|
);
|
|
163
|
-
return /* @__PURE__ */ (0,
|
|
164
|
-
|
|
165
|
-
__spreadProps(__spreadValues({}, Object.assign(props.styleProviderProps || {}, {
|
|
158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cssinjs.StyleProvider, {
|
|
159
|
+
...Object.assign(props.styleProviderProps || {}, {
|
|
166
160
|
hashPriority: "high",
|
|
167
161
|
transformers: [import_cssinjs.legacyLogicalPropertiesTransformer]
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
162
|
+
}),
|
|
163
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.ConfigProvider, {
|
|
164
|
+
...props.configProviderProps,
|
|
165
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AppContext.Provider, {
|
|
166
|
+
value: memoizedContextValue,
|
|
167
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_router_dom.BrowserRouter, {
|
|
168
|
+
...props.browserRouterProps,
|
|
169
|
+
children: [
|
|
170
|
+
messageContextHolder,
|
|
171
|
+
notificationContextHolder,
|
|
172
|
+
modal,
|
|
173
|
+
drawer,
|
|
174
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RoutesApp, {
|
|
175
|
+
children: props.children
|
|
176
|
+
})
|
|
177
|
+
]
|
|
178
|
+
})
|
|
179
|
+
})
|
|
176
180
|
})
|
|
177
|
-
);
|
|
181
|
+
});
|
|
178
182
|
}
|
|
179
183
|
function useApp() {
|
|
180
184
|
return (0, import_react4.useContext)(AppContext);
|
|
@@ -188,7 +192,7 @@ var import_lodash_es2 = require("lodash-es");
|
|
|
188
192
|
// src/Config.tsx
|
|
189
193
|
var import_react5 = require("react");
|
|
190
194
|
var import_lodash_es = require("lodash-es");
|
|
191
|
-
var
|
|
195
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
192
196
|
var isZH = /^zh/i.test(navigator.language);
|
|
193
197
|
var zh = {
|
|
194
198
|
lang: "zh",
|
|
@@ -244,17 +248,23 @@ function ConfigProvider2({
|
|
|
244
248
|
} else
|
|
245
249
|
setValues((0, import_lodash_es.defaultsDeep)(config, values));
|
|
246
250
|
}, []);
|
|
247
|
-
return /* @__PURE__ */ (0,
|
|
251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
|
|
252
|
+
value: values,
|
|
253
|
+
children
|
|
254
|
+
});
|
|
248
255
|
}
|
|
249
256
|
function useConfigContext() {
|
|
250
257
|
return (0, import_react5.useContext)(ConfigContext);
|
|
251
258
|
}
|
|
252
259
|
|
|
253
260
|
// src/Blank.tsx
|
|
254
|
-
var
|
|
261
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
255
262
|
function Blank(options) {
|
|
256
263
|
const { Blank: Blank2 } = useConfigContext();
|
|
257
|
-
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0,
|
|
264
|
+
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Typography.Text, {
|
|
265
|
+
disabled: true,
|
|
266
|
+
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
267
|
+
}) : options.value;
|
|
258
268
|
}
|
|
259
269
|
|
|
260
270
|
// src/data.ts
|
|
@@ -288,63 +298,52 @@ function transferValue(type, value) {
|
|
|
288
298
|
var import_icons = require("@ant-design/icons");
|
|
289
299
|
var import_antd6 = require("antd");
|
|
290
300
|
var import_lodash_es4 = require("lodash-es");
|
|
291
|
-
var
|
|
301
|
+
var import_react7 = require("react");
|
|
292
302
|
|
|
293
|
-
//
|
|
294
|
-
var import_react6 = require("react");
|
|
295
|
-
var clients = {};
|
|
296
|
-
function getClient(domain) {
|
|
297
|
-
const client = clients[domain || Object.keys(clients)[0]];
|
|
298
|
-
if (!client)
|
|
299
|
-
throw Error("FaasReactClient is not initialized");
|
|
300
|
-
return client;
|
|
301
|
-
}
|
|
302
|
-
async function faas(action, params) {
|
|
303
|
-
return getClient().faas(action, params);
|
|
304
|
-
}
|
|
305
|
-
function FaasDataWrapper(props) {
|
|
306
|
-
const [client, setClient] = (0, import_react6.useState)();
|
|
307
|
-
(0, import_react6.useEffect)(() => {
|
|
308
|
-
if (client)
|
|
309
|
-
return;
|
|
310
|
-
setClient(getClient());
|
|
311
|
-
}, []);
|
|
312
|
-
if (!client)
|
|
313
|
-
return props.fallback || null;
|
|
314
|
-
return (0, import_react6.createElement)(client.FaasDataWrapper, props);
|
|
315
|
-
}
|
|
303
|
+
// src/FaasDataWrapper.tsx
|
|
304
|
+
var import_react6 = require("@faasjs/react");
|
|
316
305
|
|
|
317
306
|
// src/Loading.tsx
|
|
318
307
|
var import_antd5 = require("antd");
|
|
319
|
-
var
|
|
308
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
320
309
|
function Loading(props) {
|
|
321
310
|
if (props.loading === false)
|
|
322
|
-
return /* @__PURE__ */ (0,
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
312
|
+
children: props.children
|
|
313
|
+
});
|
|
314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
315
|
+
style: {
|
|
316
|
+
...props.style || {},
|
|
317
|
+
...!props.size || props.size === "large" ? {
|
|
318
|
+
margin: "20vh auto",
|
|
319
|
+
textAlign: "center"
|
|
320
|
+
} : {}
|
|
321
|
+
},
|
|
322
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Spin, {
|
|
323
|
+
size: props.size || "large"
|
|
324
|
+
})
|
|
325
|
+
});
|
|
327
326
|
}
|
|
328
327
|
|
|
329
328
|
// src/FaasDataWrapper.tsx
|
|
330
|
-
var
|
|
331
|
-
function
|
|
332
|
-
return /* @__PURE__ */ (0,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
);
|
|
329
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
330
|
+
function FaasDataWrapper(props) {
|
|
331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react6.FaasDataWrapper, {
|
|
332
|
+
fallback: props.loading || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
|
|
333
|
+
...props.loadingProps
|
|
334
|
+
}),
|
|
335
|
+
...props
|
|
336
|
+
});
|
|
338
337
|
}
|
|
339
338
|
|
|
340
339
|
// src/Description.tsx
|
|
341
|
-
var
|
|
340
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
342
341
|
function DescriptionItemContent(props) {
|
|
343
342
|
var _a;
|
|
344
|
-
const [computedProps, setComputedProps] = (0,
|
|
345
|
-
(0,
|
|
343
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
344
|
+
(0, import_react7.useEffect)(() => {
|
|
346
345
|
var _a2, _b;
|
|
347
|
-
const propsCopy =
|
|
346
|
+
const propsCopy = { ...props };
|
|
348
347
|
if (!propsCopy.item.title)
|
|
349
348
|
propsCopy.item.title = (0, import_lodash_es4.upperFirst)(propsCopy.item.id);
|
|
350
349
|
if (!propsCopy.item.type)
|
|
@@ -372,7 +371,7 @@ function DescriptionItemContent(props) {
|
|
|
372
371
|
return null;
|
|
373
372
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
374
373
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
375
|
-
return (0,
|
|
374
|
+
return (0, import_react7.cloneElement)(
|
|
376
375
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
377
376
|
{
|
|
378
377
|
scene: "description",
|
|
@@ -381,13 +380,15 @@ function DescriptionItemContent(props) {
|
|
|
381
380
|
}
|
|
382
381
|
);
|
|
383
382
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
384
|
-
return /* @__PURE__ */ (0,
|
|
383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
384
|
+
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
|
|
385
|
+
});
|
|
385
386
|
else
|
|
386
387
|
throw Error(computedProps.item.type + " requires children or render");
|
|
387
388
|
if (computedProps.item.descriptionChildren === null)
|
|
388
389
|
return null;
|
|
389
390
|
if (computedProps.item.descriptionChildren)
|
|
390
|
-
return (0,
|
|
391
|
+
return (0, import_react7.cloneElement)(computedProps.item.descriptionChildren, {
|
|
391
392
|
scene: "description",
|
|
392
393
|
value: computedProps.value,
|
|
393
394
|
values: computedProps.values
|
|
@@ -395,127 +396,119 @@ function DescriptionItemContent(props) {
|
|
|
395
396
|
if (computedProps.item.children === null)
|
|
396
397
|
return null;
|
|
397
398
|
if (computedProps.item.children)
|
|
398
|
-
return (0,
|
|
399
|
+
return (0, import_react7.cloneElement)(computedProps.item.children, {
|
|
399
400
|
scene: "description",
|
|
400
401
|
value: computedProps.value,
|
|
401
402
|
values: computedProps.values
|
|
402
403
|
});
|
|
403
404
|
if (computedProps.item.descriptionRender)
|
|
404
|
-
return
|
|
405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
406
|
+
children: computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description")
|
|
407
|
+
});
|
|
405
408
|
if (computedProps.item.render)
|
|
406
|
-
return
|
|
409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
410
|
+
children: computedProps.item.render(computedProps.value, computedProps.values, 0, "description")
|
|
411
|
+
});
|
|
407
412
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
408
|
-
return /* @__PURE__ */ (0,
|
|
413
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
409
414
|
switch (computedProps.item.type) {
|
|
410
415
|
case "string[]":
|
|
411
|
-
return /* @__PURE__ */ (0,
|
|
416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
417
|
+
children: computedProps.value.join(", ")
|
|
418
|
+
});
|
|
412
419
|
case "number":
|
|
413
420
|
return computedProps.value || null;
|
|
414
421
|
case "number[]":
|
|
415
|
-
return /* @__PURE__ */ (0,
|
|
422
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
423
|
+
children: computedProps.value.join(", ")
|
|
424
|
+
});
|
|
416
425
|
case "boolean":
|
|
417
|
-
return computedProps.value ? /* @__PURE__ */ (0,
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
426
|
+
return computedProps.value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CheckOutlined, {
|
|
427
|
+
style: {
|
|
428
|
+
marginTop: "4px",
|
|
429
|
+
color: "#52c41a"
|
|
430
|
+
}
|
|
431
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseOutlined, {
|
|
432
|
+
style: {
|
|
433
|
+
marginTop: "4px",
|
|
434
|
+
color: "#ff4d4f"
|
|
435
|
+
}
|
|
436
|
+
});
|
|
424
437
|
case "time":
|
|
425
|
-
return /* @__PURE__ */ (0,
|
|
438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
439
|
+
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
440
|
+
});
|
|
426
441
|
case "date":
|
|
427
|
-
return /* @__PURE__ */ (0,
|
|
442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
443
|
+
children: computedProps.value.format("YYYY-MM-DD")
|
|
444
|
+
});
|
|
428
445
|
case "object":
|
|
429
446
|
if (!computedProps.value)
|
|
430
|
-
return /* @__PURE__ */ (0,
|
|
431
|
-
return /* @__PURE__ */ (0,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
column: 1
|
|
437
|
-
}
|
|
438
|
-
);
|
|
447
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
449
|
+
items: computedProps.item.object,
|
|
450
|
+
dataSource: computedProps.value,
|
|
451
|
+
column: 1
|
|
452
|
+
});
|
|
439
453
|
case "object[]":
|
|
440
454
|
if (!((_a = computedProps.value) == null ? void 0 : _a.length))
|
|
441
|
-
return /* @__PURE__ */ (0,
|
|
442
|
-
return /* @__PURE__ */ (0,
|
|
443
|
-
|
|
444
|
-
{
|
|
455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Space, {
|
|
457
|
+
direction: "vertical",
|
|
458
|
+
children: computedProps.value.map((value, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
445
459
|
items: computedProps.item.object,
|
|
446
460
|
dataSource: value,
|
|
447
461
|
column: 1
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
)) });
|
|
462
|
+
}, index))
|
|
463
|
+
});
|
|
451
464
|
default:
|
|
452
465
|
return computedProps.value || null;
|
|
453
466
|
}
|
|
454
467
|
}
|
|
455
468
|
function Description(props) {
|
|
456
469
|
if (props.dataSource)
|
|
457
|
-
return /* @__PURE__ */ (0,
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
470
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions, {
|
|
471
|
+
...props,
|
|
472
|
+
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
473
|
+
children: props.items.map((item) => {
|
|
474
|
+
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions.Item, {
|
|
475
|
+
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
476
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
477
|
+
item,
|
|
478
|
+
value: props.dataSource[item.id],
|
|
479
|
+
values: props.dataSource,
|
|
480
|
+
extendTypes: props.extendTypes
|
|
481
|
+
})
|
|
482
|
+
}, item.id) : null;
|
|
483
|
+
}).filter(Boolean)
|
|
484
|
+
});
|
|
485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
486
|
+
render: ({ data }) => {
|
|
487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions, {
|
|
488
|
+
...props,
|
|
489
|
+
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
461
490
|
children: props.items.map((item) => {
|
|
462
|
-
return !item.if || item.if(
|
|
463
|
-
|
|
464
|
-
{
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
values: props.dataSource,
|
|
472
|
-
extendTypes: props.extendTypes
|
|
473
|
-
}
|
|
474
|
-
)
|
|
475
|
-
},
|
|
476
|
-
item.id
|
|
477
|
-
) : null;
|
|
491
|
+
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions.Item, {
|
|
492
|
+
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
493
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
494
|
+
item,
|
|
495
|
+
value: data[item.id],
|
|
496
|
+
values: data,
|
|
497
|
+
extendTypes: props.extendTypes
|
|
498
|
+
})
|
|
499
|
+
}, item.id) : null;
|
|
478
500
|
}).filter(Boolean)
|
|
479
|
-
})
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
__spreadValues({
|
|
484
|
-
render: ({ data }) => {
|
|
485
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
486
|
-
import_antd6.Descriptions,
|
|
487
|
-
__spreadProps(__spreadValues({}, props), {
|
|
488
|
-
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
489
|
-
children: props.items.map((item) => {
|
|
490
|
-
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
491
|
-
import_antd6.Descriptions.Item,
|
|
492
|
-
{
|
|
493
|
-
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
494
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
495
|
-
DescriptionItemContent,
|
|
496
|
-
{
|
|
497
|
-
item,
|
|
498
|
-
value: data[item.id],
|
|
499
|
-
values: data,
|
|
500
|
-
extendTypes: props.extendTypes
|
|
501
|
-
}
|
|
502
|
-
)
|
|
503
|
-
},
|
|
504
|
-
item.id
|
|
505
|
-
) : null;
|
|
506
|
-
}).filter(Boolean)
|
|
507
|
-
})
|
|
508
|
-
);
|
|
509
|
-
}
|
|
510
|
-
}, props.faasData)
|
|
511
|
-
);
|
|
501
|
+
});
|
|
502
|
+
},
|
|
503
|
+
...props.faasData
|
|
504
|
+
});
|
|
512
505
|
}
|
|
513
506
|
|
|
514
507
|
// src/ErrorBoundary.tsx
|
|
515
|
-
var
|
|
508
|
+
var import_react8 = require("react");
|
|
516
509
|
var import_antd7 = require("antd");
|
|
517
|
-
var
|
|
518
|
-
var ErrorBoundary = class extends
|
|
510
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
511
|
+
var ErrorBoundary = class extends import_react8.Component {
|
|
519
512
|
constructor(props) {
|
|
520
513
|
super(props);
|
|
521
514
|
this.state = {
|
|
@@ -542,32 +535,33 @@ var ErrorBoundary = class extends import_react9.Component {
|
|
|
542
535
|
if (error) {
|
|
543
536
|
if (this.props.onError)
|
|
544
537
|
return this.props.onError(error, info);
|
|
545
|
-
return /* @__PURE__ */ (0,
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
description: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("pre", { style: {
|
|
538
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Alert, {
|
|
539
|
+
type: "error",
|
|
540
|
+
message: errorMessage,
|
|
541
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
|
|
542
|
+
style: {
|
|
551
543
|
fontSize: "0.9em",
|
|
552
544
|
overflowX: "auto"
|
|
553
|
-
},
|
|
554
|
-
|
|
555
|
-
|
|
545
|
+
},
|
|
546
|
+
children: errorDescription
|
|
547
|
+
})
|
|
548
|
+
});
|
|
556
549
|
}
|
|
557
550
|
return children;
|
|
558
551
|
}
|
|
559
552
|
};
|
|
560
553
|
|
|
561
554
|
// src/Form.tsx
|
|
555
|
+
var import_react10 = require("@faasjs/react");
|
|
562
556
|
var import_antd9 = require("antd");
|
|
563
|
-
var
|
|
557
|
+
var import_react11 = require("react");
|
|
564
558
|
|
|
565
559
|
// src/FormItem.tsx
|
|
566
560
|
var import_antd8 = require("antd");
|
|
567
561
|
var import_icons2 = require("@ant-design/icons");
|
|
568
|
-
var
|
|
562
|
+
var import_react9 = require("react");
|
|
569
563
|
var import_lodash_es5 = require("lodash-es");
|
|
570
|
-
var
|
|
564
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
571
565
|
function processProps(propsCopy, config) {
|
|
572
566
|
if (!propsCopy.title)
|
|
573
567
|
propsCopy.title = (0, import_lodash_es5.upperFirst)(propsCopy.id);
|
|
@@ -616,12 +610,12 @@ function processProps(propsCopy, config) {
|
|
|
616
610
|
}
|
|
617
611
|
function FormItem(props) {
|
|
618
612
|
var _a;
|
|
619
|
-
const [computedProps, setComputedProps] = (0,
|
|
620
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
613
|
+
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
614
|
+
const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
|
|
621
615
|
const { common: common2 } = useConfigContext();
|
|
622
|
-
const [hidden, setHidden] = (0,
|
|
623
|
-
(0,
|
|
624
|
-
const propsCopy =
|
|
616
|
+
const [hidden, setHidden] = (0, import_react9.useState)(props.hidden || false);
|
|
617
|
+
(0, import_react9.useEffect)(() => {
|
|
618
|
+
const propsCopy = { ...props };
|
|
625
619
|
if (propsCopy.extendTypes) {
|
|
626
620
|
setExtendTypes(propsCopy.extendTypes);
|
|
627
621
|
delete propsCopy.extendTypes;
|
|
@@ -644,248 +638,312 @@ function FormItem(props) {
|
|
|
644
638
|
if (!computedProps)
|
|
645
639
|
return null;
|
|
646
640
|
if (hidden)
|
|
647
|
-
return /* @__PURE__ */ (0,
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
642
|
+
...computedProps,
|
|
643
|
+
noStyle: true,
|
|
644
|
+
rules: [],
|
|
645
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Input, {
|
|
646
|
+
hidden: true
|
|
653
647
|
})
|
|
654
|
-
);
|
|
648
|
+
});
|
|
655
649
|
if (extendTypes && extendTypes[computedProps.type])
|
|
656
|
-
return /* @__PURE__ */ (0,
|
|
650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
651
|
+
...computedProps,
|
|
652
|
+
children: extendTypes[computedProps.type].children
|
|
653
|
+
});
|
|
657
654
|
if (computedProps.formChildren === null)
|
|
658
655
|
return null;
|
|
659
656
|
if (computedProps.formChildren)
|
|
660
|
-
return /* @__PURE__ */ (0,
|
|
657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
658
|
+
...computedProps,
|
|
659
|
+
children: (0, import_react9.cloneElement)(computedProps.formChildren, { scene: "form" })
|
|
660
|
+
});
|
|
661
661
|
if (computedProps.children === null)
|
|
662
662
|
return null;
|
|
663
663
|
if (computedProps.children)
|
|
664
|
-
return /* @__PURE__ */ (0,
|
|
664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
665
|
+
...computedProps,
|
|
666
|
+
children: (0, import_react9.cloneElement)(computedProps.children, { scene: "form" })
|
|
667
|
+
});
|
|
665
668
|
if (computedProps.formRender)
|
|
666
|
-
return /* @__PURE__ */ (0,
|
|
669
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
670
|
+
...computedProps,
|
|
671
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
672
|
+
});
|
|
667
673
|
if (computedProps.render)
|
|
668
|
-
return /* @__PURE__ */ (0,
|
|
674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
675
|
+
...computedProps,
|
|
676
|
+
children: computedProps.render(null, null, 0, "form")
|
|
677
|
+
});
|
|
669
678
|
switch (computedProps.type) {
|
|
670
679
|
case "string":
|
|
671
|
-
return /* @__PURE__ */ (0,
|
|
680
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
681
|
+
...computedProps,
|
|
682
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
683
|
+
...computedProps.input
|
|
684
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Input, {
|
|
685
|
+
...computedProps.input
|
|
686
|
+
})
|
|
687
|
+
});
|
|
672
688
|
case "string[]":
|
|
673
689
|
if (computedProps.options)
|
|
674
|
-
return /* @__PURE__ */ (0,
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
mode: "multiple"
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
computedProps.label && /* @__PURE__ */ (0,
|
|
690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
691
|
+
...computedProps,
|
|
692
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
693
|
+
mode: "multiple",
|
|
694
|
+
...computedProps.input
|
|
695
|
+
})
|
|
696
|
+
});
|
|
697
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.List, {
|
|
698
|
+
name: computedProps.name,
|
|
699
|
+
rules: computedProps.rules,
|
|
700
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
701
|
+
var _a2;
|
|
702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
703
|
+
children: [
|
|
704
|
+
computedProps.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
705
|
+
className: "ant-form-item-label",
|
|
706
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
|
|
707
|
+
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
|
|
708
|
+
children: computedProps.label
|
|
709
|
+
})
|
|
710
|
+
}),
|
|
689
711
|
fields.map((field) => {
|
|
690
712
|
var _a3;
|
|
691
|
-
return /* @__PURE__ */ (0,
|
|
692
|
-
import_antd8.Row,
|
|
693
|
-
{
|
|
713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
714
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Row, {
|
|
694
715
|
gutter: 24,
|
|
695
716
|
style: { flexFlow: "row nowrap" },
|
|
696
717
|
children: [
|
|
697
|
-
/* @__PURE__ */ (0,
|
|
698
|
-
|
|
699
|
-
|
|
718
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
719
|
+
span: 23,
|
|
720
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
721
|
+
...field,
|
|
700
722
|
noStyle: true,
|
|
701
|
-
children: /* @__PURE__ */ (0,
|
|
723
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Input, {
|
|
724
|
+
...computedProps.input
|
|
725
|
+
})
|
|
702
726
|
})
|
|
703
|
-
|
|
704
|
-
/* @__PURE__ */ (0,
|
|
705
|
-
|
|
706
|
-
{
|
|
727
|
+
}),
|
|
728
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
729
|
+
span: 1,
|
|
730
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
707
731
|
danger: true,
|
|
708
732
|
type: "link",
|
|
709
733
|
style: { float: "right" },
|
|
710
|
-
icon: /* @__PURE__ */ (0,
|
|
734
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.MinusCircleOutlined, {}),
|
|
711
735
|
onClick: () => remove(field.name)
|
|
712
|
-
}
|
|
713
|
-
|
|
736
|
+
})
|
|
737
|
+
})
|
|
714
738
|
]
|
|
715
|
-
}
|
|
716
|
-
|
|
739
|
+
})
|
|
740
|
+
}, field.key);
|
|
717
741
|
}),
|
|
718
|
-
/* @__PURE__ */ (0,
|
|
719
|
-
|
|
720
|
-
import_antd8.Button,
|
|
721
|
-
{
|
|
742
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
743
|
+
children: [
|
|
744
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
722
745
|
type: "dashed",
|
|
723
746
|
block: true,
|
|
724
747
|
onClick: () => add(),
|
|
725
|
-
icon: /* @__PURE__ */ (0,
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
748
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
749
|
+
}),
|
|
750
|
+
computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
751
|
+
className: "ant-form-item-extra",
|
|
752
|
+
children: computedProps.extra
|
|
753
|
+
}),
|
|
754
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.ErrorList, {
|
|
755
|
+
errors
|
|
756
|
+
})
|
|
757
|
+
]
|
|
758
|
+
})
|
|
759
|
+
]
|
|
760
|
+
});
|
|
733
761
|
}
|
|
734
|
-
);
|
|
762
|
+
});
|
|
735
763
|
case "number":
|
|
736
|
-
return /* @__PURE__ */ (0,
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
},
|
|
741
|
-
|
|
764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
765
|
+
...computedProps,
|
|
766
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
767
|
+
...computedProps.input
|
|
768
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.InputNumber, {
|
|
769
|
+
style: { width: "100%" },
|
|
770
|
+
...computedProps.input
|
|
771
|
+
})
|
|
772
|
+
});
|
|
742
773
|
case "number[]":
|
|
743
774
|
if (computedProps.options)
|
|
744
|
-
return /* @__PURE__ */ (0,
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
mode: "multiple"
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
computedProps.label && /* @__PURE__ */ (0,
|
|
775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
776
|
+
...computedProps,
|
|
777
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
778
|
+
mode: "multiple",
|
|
779
|
+
...computedProps.input
|
|
780
|
+
})
|
|
781
|
+
});
|
|
782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.List, {
|
|
783
|
+
name: computedProps.name,
|
|
784
|
+
rules: computedProps.rules,
|
|
785
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
786
|
+
var _a2, _b;
|
|
787
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
788
|
+
children: [
|
|
789
|
+
computedProps.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
790
|
+
className: "ant-form-item-label",
|
|
791
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
|
|
792
|
+
className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
|
|
793
|
+
children: computedProps.label
|
|
794
|
+
})
|
|
795
|
+
}),
|
|
759
796
|
fields.map((field) => {
|
|
760
797
|
var _a3;
|
|
761
|
-
return /* @__PURE__ */ (0,
|
|
762
|
-
import_antd8.Row,
|
|
763
|
-
{
|
|
798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
799
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Row, {
|
|
764
800
|
gutter: 24,
|
|
765
801
|
style: { flexFlow: "row nowrap" },
|
|
766
802
|
children: [
|
|
767
|
-
/* @__PURE__ */ (0,
|
|
768
|
-
|
|
769
|
-
|
|
803
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
804
|
+
span: 23,
|
|
805
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
806
|
+
...field,
|
|
770
807
|
noStyle: true,
|
|
771
|
-
children: /* @__PURE__ */ (0,
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}, computedProps.input)
|
|
776
|
-
)
|
|
808
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.InputNumber, {
|
|
809
|
+
style: { width: "100%" },
|
|
810
|
+
...computedProps.input
|
|
811
|
+
})
|
|
777
812
|
})
|
|
778
|
-
|
|
779
|
-
/* @__PURE__ */ (0,
|
|
780
|
-
|
|
781
|
-
{
|
|
813
|
+
}),
|
|
814
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
815
|
+
span: 1,
|
|
816
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
782
817
|
danger: true,
|
|
783
818
|
type: "link",
|
|
784
819
|
style: { float: "right" },
|
|
785
|
-
icon: /* @__PURE__ */ (0,
|
|
820
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.MinusCircleOutlined, {}),
|
|
786
821
|
onClick: () => remove(field.name)
|
|
787
|
-
}
|
|
788
|
-
|
|
822
|
+
})
|
|
823
|
+
})
|
|
789
824
|
]
|
|
790
|
-
}
|
|
791
|
-
|
|
825
|
+
})
|
|
826
|
+
}, field.key);
|
|
792
827
|
}),
|
|
793
|
-
/* @__PURE__ */ (0,
|
|
794
|
-
|
|
795
|
-
import_antd8.Button,
|
|
796
|
-
{
|
|
828
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
829
|
+
children: [
|
|
830
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
797
831
|
type: "dashed",
|
|
798
832
|
block: true,
|
|
799
833
|
onClick: () => add(),
|
|
800
|
-
icon: /* @__PURE__ */ (0,
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
834
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
835
|
+
}),
|
|
836
|
+
computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
837
|
+
className: "ant-form-item-extra",
|
|
838
|
+
children: computedProps.extra
|
|
839
|
+
}),
|
|
840
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.ErrorList, {
|
|
841
|
+
errors
|
|
842
|
+
})
|
|
843
|
+
]
|
|
844
|
+
})
|
|
845
|
+
]
|
|
846
|
+
});
|
|
808
847
|
}
|
|
809
|
-
);
|
|
848
|
+
});
|
|
810
849
|
case "boolean":
|
|
811
|
-
return /* @__PURE__ */ (0,
|
|
850
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
851
|
+
...computedProps,
|
|
852
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Switch, {
|
|
853
|
+
...computedProps.input
|
|
854
|
+
})
|
|
855
|
+
});
|
|
812
856
|
case "date":
|
|
813
|
-
return /* @__PURE__ */ (0,
|
|
857
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
858
|
+
...computedProps,
|
|
859
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.DatePicker, {
|
|
860
|
+
...computedProps.input
|
|
861
|
+
})
|
|
862
|
+
});
|
|
814
863
|
case "time":
|
|
815
|
-
return /* @__PURE__ */ (0,
|
|
864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
865
|
+
...computedProps,
|
|
866
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.TimePicker, {
|
|
867
|
+
...computedProps.input
|
|
868
|
+
})
|
|
869
|
+
});
|
|
816
870
|
case "object":
|
|
817
|
-
return /* @__PURE__ */ (0,
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
871
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
872
|
+
children: [
|
|
873
|
+
computedProps.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
874
|
+
className: "ant-form-item-label",
|
|
875
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
|
|
876
|
+
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
|
|
877
|
+
children: computedProps.label
|
|
878
|
+
})
|
|
879
|
+
}),
|
|
880
|
+
computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
881
|
+
...o
|
|
882
|
+
}, o.id))
|
|
883
|
+
]
|
|
884
|
+
});
|
|
825
885
|
case "object[]":
|
|
826
|
-
return /* @__PURE__ */ (0,
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
import_antd8.Button,
|
|
843
|
-
{
|
|
886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.List, {
|
|
887
|
+
name: computedProps.name,
|
|
888
|
+
rules: computedProps.rules,
|
|
889
|
+
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
890
|
+
children: [
|
|
891
|
+
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
892
|
+
style: { marginBottom: 0 },
|
|
893
|
+
children: [
|
|
894
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
895
|
+
className: "ant-form-item-label",
|
|
896
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
897
|
+
children: [
|
|
898
|
+
computedProps.label,
|
|
899
|
+
" ",
|
|
900
|
+
field.name + 1,
|
|
901
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
844
902
|
danger: true,
|
|
845
903
|
type: "link",
|
|
846
904
|
onClick: () => remove(field.name),
|
|
847
905
|
children: common2.delete
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
)),
|
|
868
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_antd8.Form.Item, { children: [
|
|
869
|
-
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
870
|
-
import_antd8.Button,
|
|
871
|
-
{
|
|
906
|
+
})
|
|
907
|
+
]
|
|
908
|
+
})
|
|
909
|
+
}),
|
|
910
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Row, {
|
|
911
|
+
gutter: 24,
|
|
912
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
913
|
+
span: o.col || 24,
|
|
914
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
915
|
+
...o,
|
|
916
|
+
name: [field.name, o.id]
|
|
917
|
+
})
|
|
918
|
+
}, o.id))
|
|
919
|
+
})
|
|
920
|
+
]
|
|
921
|
+
}, field.key)),
|
|
922
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
923
|
+
children: [
|
|
924
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Button, {
|
|
872
925
|
type: "dashed",
|
|
873
926
|
block: true,
|
|
874
927
|
onClick: () => add(),
|
|
875
|
-
icon: /* @__PURE__ */ (0,
|
|
928
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {}),
|
|
876
929
|
children: [
|
|
877
930
|
common2.add,
|
|
878
931
|
" ",
|
|
879
932
|
computedProps.label
|
|
880
933
|
]
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
934
|
+
}),
|
|
935
|
+
computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
936
|
+
className: "ant-form-item-extra",
|
|
937
|
+
children: computedProps.extra
|
|
938
|
+
}),
|
|
939
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.ErrorList, {
|
|
940
|
+
errors
|
|
941
|
+
})
|
|
942
|
+
]
|
|
943
|
+
})
|
|
944
|
+
]
|
|
945
|
+
})
|
|
946
|
+
});
|
|
889
947
|
default:
|
|
890
948
|
return null;
|
|
891
949
|
}
|
|
@@ -893,20 +951,21 @@ function FormItem(props) {
|
|
|
893
951
|
FormItem.useStatus = import_antd8.Form.Item.useStatus;
|
|
894
952
|
|
|
895
953
|
// src/Form.tsx
|
|
896
|
-
var
|
|
954
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
897
955
|
function Form(props) {
|
|
898
956
|
var _a, _b;
|
|
899
|
-
const [loading, setLoading] = (0,
|
|
900
|
-
const [computedProps, setComputedProps] = (0,
|
|
957
|
+
const [loading, setLoading] = (0, import_react11.useState)(false);
|
|
958
|
+
const [computedProps, setComputedProps] = (0, import_react11.useState)();
|
|
901
959
|
const config = useConfigContext();
|
|
902
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
960
|
+
const [extendTypes, setExtendTypes] = (0, import_react11.useState)();
|
|
903
961
|
const [form] = import_antd9.Form.useForm(props.form);
|
|
904
|
-
const [initialValues, setInitialValues] = (0,
|
|
905
|
-
(0,
|
|
962
|
+
const [initialValues, setInitialValues] = (0, import_react11.useState)(props.initialValues);
|
|
963
|
+
(0, import_react11.useEffect)(() => {
|
|
906
964
|
var _a2, _b2, _c;
|
|
907
|
-
const propsCopy =
|
|
965
|
+
const propsCopy = {
|
|
966
|
+
...props,
|
|
908
967
|
form
|
|
909
|
-
}
|
|
968
|
+
};
|
|
910
969
|
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
911
970
|
for (const key in propsCopy.initialValues) {
|
|
912
971
|
propsCopy.initialValues[key] = transferValue(
|
|
@@ -930,7 +989,10 @@ function Form(props) {
|
|
|
930
989
|
setLoading(true);
|
|
931
990
|
try {
|
|
932
991
|
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
933
|
-
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
992
|
+
await props.onFinish(values, async (values2) => (0, import_react10.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
993
|
+
...values2,
|
|
994
|
+
...propsCopy.submit.to.params
|
|
995
|
+
} : values2));
|
|
934
996
|
} else
|
|
935
997
|
await props.onFinish(values);
|
|
936
998
|
} catch (error) {
|
|
@@ -941,7 +1003,10 @@ function Form(props) {
|
|
|
941
1003
|
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
942
1004
|
propsCopy.onFinish = async (values) => {
|
|
943
1005
|
setLoading(true);
|
|
944
|
-
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
1006
|
+
return (0, import_react10.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
1007
|
+
...values,
|
|
1008
|
+
...propsCopy.submit.to.params
|
|
1009
|
+
} : values).then((result) => {
|
|
945
1010
|
if (propsCopy.submit.to.then)
|
|
946
1011
|
propsCopy.submit.to.then(result);
|
|
947
1012
|
return result;
|
|
@@ -962,7 +1027,7 @@ function Form(props) {
|
|
|
962
1027
|
}
|
|
963
1028
|
setComputedProps(propsCopy);
|
|
964
1029
|
}, [props]);
|
|
965
|
-
const onValuesChange = (0,
|
|
1030
|
+
const onValuesChange = (0, import_react11.useCallback)((changedValues, allValues) => {
|
|
966
1031
|
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
967
1032
|
if (props.onValuesChange) {
|
|
968
1033
|
props.onValuesChange(changedValues, allValues);
|
|
@@ -975,7 +1040,7 @@ function Form(props) {
|
|
|
975
1040
|
item.onValueChange(changedValues[key], allValues, form);
|
|
976
1041
|
}
|
|
977
1042
|
}, [computedProps]);
|
|
978
|
-
(0,
|
|
1043
|
+
(0, import_react11.useEffect)(() => {
|
|
979
1044
|
if (!initialValues)
|
|
980
1045
|
return;
|
|
981
1046
|
console.debug("Form:initialValues", initialValues);
|
|
@@ -984,33 +1049,25 @@ function Form(props) {
|
|
|
984
1049
|
}, [computedProps]);
|
|
985
1050
|
if (!computedProps)
|
|
986
1051
|
return null;
|
|
987
|
-
return /* @__PURE__ */ (0,
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
computedProps.submit
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
loading,
|
|
1007
|
-
children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
|
|
1008
|
-
}
|
|
1009
|
-
),
|
|
1010
|
-
computedProps.footer
|
|
1011
|
-
]
|
|
1012
|
-
})
|
|
1013
|
-
);
|
|
1052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd9.Form, {
|
|
1053
|
+
...computedProps,
|
|
1054
|
+
onValuesChange,
|
|
1055
|
+
children: [
|
|
1056
|
+
computedProps.beforeItems,
|
|
1057
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react11.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
1058
|
+
...item,
|
|
1059
|
+
extendTypes
|
|
1060
|
+
}, item.id)),
|
|
1061
|
+
computedProps.children,
|
|
1062
|
+
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Button, {
|
|
1063
|
+
htmlType: "submit",
|
|
1064
|
+
type: "primary",
|
|
1065
|
+
loading,
|
|
1066
|
+
children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
|
|
1067
|
+
}),
|
|
1068
|
+
computedProps.footer
|
|
1069
|
+
]
|
|
1070
|
+
});
|
|
1014
1071
|
}
|
|
1015
1072
|
Form.useForm = import_antd9.Form.useForm;
|
|
1016
1073
|
Form.useFormInstance = import_antd9.Form.useFormInstance;
|
|
@@ -1023,13 +1080,15 @@ Form.Provider = import_antd9.Form.Provider;
|
|
|
1023
1080
|
// src/Link.tsx
|
|
1024
1081
|
var import_react_router_dom2 = require("react-router-dom");
|
|
1025
1082
|
var import_antd10 = require("antd");
|
|
1026
|
-
var
|
|
1083
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1027
1084
|
function Link(props) {
|
|
1028
1085
|
var _a, _b, _c, _d;
|
|
1029
1086
|
const { Link: Link2 } = useConfigContext();
|
|
1030
|
-
let style =
|
|
1031
|
-
|
|
1032
|
-
|
|
1087
|
+
let style = {
|
|
1088
|
+
...Link2.style || {},
|
|
1089
|
+
cursor: "pointer",
|
|
1090
|
+
...props.style
|
|
1091
|
+
};
|
|
1033
1092
|
if (props.block)
|
|
1034
1093
|
style = Object.assign({
|
|
1035
1094
|
display: "block",
|
|
@@ -1037,99 +1096,86 @@ function Link(props) {
|
|
|
1037
1096
|
}, style);
|
|
1038
1097
|
if (props.href.startsWith("http")) {
|
|
1039
1098
|
if (props.button)
|
|
1040
|
-
return /* @__PURE__ */ (0,
|
|
1041
|
-
|
|
1042
|
-
__spreadProps(__spreadValues({}, props.button), {
|
|
1043
|
-
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1044
|
-
style,
|
|
1045
|
-
href: props.href,
|
|
1046
|
-
children: (_a = props.text) != null ? _a : props.children
|
|
1047
|
-
})
|
|
1048
|
-
);
|
|
1049
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1050
|
-
"a",
|
|
1051
|
-
{
|
|
1052
|
-
href: props.href,
|
|
1099
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Button, {
|
|
1100
|
+
...props.button,
|
|
1053
1101
|
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1054
1102
|
style,
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1103
|
+
href: props.href,
|
|
1104
|
+
children: (_a = props.text) != null ? _a : props.children
|
|
1105
|
+
});
|
|
1106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
1107
|
+
href: props.href,
|
|
1108
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1109
|
+
style,
|
|
1110
|
+
children: (_b = props.text) != null ? _b : props.children
|
|
1111
|
+
});
|
|
1058
1112
|
}
|
|
1059
1113
|
if (props.button)
|
|
1060
|
-
return /* @__PURE__ */ (0,
|
|
1061
|
-
import_react_router_dom2.Link,
|
|
1062
|
-
{
|
|
1063
|
-
to: props.href,
|
|
1064
|
-
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1065
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1066
|
-
import_antd10.Button,
|
|
1067
|
-
__spreadProps(__spreadValues({}, props.button), {
|
|
1068
|
-
style,
|
|
1069
|
-
children: (_c = props.text) != null ? _c : props.children
|
|
1070
|
-
})
|
|
1071
|
-
)
|
|
1072
|
-
}
|
|
1073
|
-
);
|
|
1074
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1075
|
-
import_react_router_dom2.Link,
|
|
1076
|
-
{
|
|
1114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Link, {
|
|
1077
1115
|
to: props.href,
|
|
1078
1116
|
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1117
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Button, {
|
|
1118
|
+
...props.button,
|
|
1119
|
+
style,
|
|
1120
|
+
children: (_c = props.text) != null ? _c : props.children
|
|
1121
|
+
})
|
|
1122
|
+
});
|
|
1123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Link, {
|
|
1124
|
+
to: props.href,
|
|
1125
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1126
|
+
style,
|
|
1127
|
+
children: (_d = props.text) != null ? _d : props.children
|
|
1128
|
+
});
|
|
1083
1129
|
}
|
|
1084
1130
|
|
|
1085
1131
|
// src/Routers.tsx
|
|
1086
1132
|
var import_antd11 = require("antd");
|
|
1087
|
-
var
|
|
1133
|
+
var import_react12 = require("react");
|
|
1088
1134
|
var import_react_router_dom3 = require("react-router-dom");
|
|
1089
|
-
var
|
|
1090
|
-
var
|
|
1135
|
+
var import_react13 = require("react");
|
|
1136
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1091
1137
|
function PageNotFound() {
|
|
1092
1138
|
const config = useConfigContext();
|
|
1093
|
-
return /* @__PURE__ */ (0,
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
title: config.common.pageNotFound
|
|
1098
|
-
}
|
|
1099
|
-
);
|
|
1139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Result, {
|
|
1140
|
+
status: "404",
|
|
1141
|
+
title: config.common.pageNotFound
|
|
1142
|
+
});
|
|
1100
1143
|
}
|
|
1101
1144
|
function Routes(props) {
|
|
1102
|
-
return /* @__PURE__ */ (0,
|
|
1103
|
-
|
|
1104
|
-
import_react_router_dom3.Route,
|
|
1105
|
-
|
|
1106
|
-
element: r.element || /* @__PURE__ */ (0,
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_router_dom3.Routes, {
|
|
1146
|
+
children: [
|
|
1147
|
+
props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom3.Route, {
|
|
1148
|
+
...r,
|
|
1149
|
+
element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react12.Suspense, {
|
|
1150
|
+
fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1151
|
+
style: { padding: "24px" },
|
|
1152
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Skeleton, {
|
|
1153
|
+
active: true
|
|
1154
|
+
})
|
|
1155
|
+
}),
|
|
1156
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(r.page, {})
|
|
1157
|
+
})
|
|
1158
|
+
}, r.path)),
|
|
1159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom3.Route, {
|
|
1113
1160
|
path: "*",
|
|
1114
|
-
element: props.notFound || /* @__PURE__ */ (0,
|
|
1115
|
-
},
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
] });
|
|
1161
|
+
element: props.notFound || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PageNotFound, {})
|
|
1162
|
+
}, "*")
|
|
1163
|
+
]
|
|
1164
|
+
});
|
|
1119
1165
|
}
|
|
1120
1166
|
|
|
1121
1167
|
// src/Table.tsx
|
|
1122
|
-
var
|
|
1168
|
+
var import_react14 = require("react");
|
|
1123
1169
|
var import_antd12 = require("antd");
|
|
1124
1170
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
1125
1171
|
var import_icons3 = require("@ant-design/icons");
|
|
1126
1172
|
var import_lodash_es6 = require("lodash-es");
|
|
1127
|
-
var
|
|
1173
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1128
1174
|
function processValue(item, value) {
|
|
1129
1175
|
var _a;
|
|
1130
1176
|
const transferred = transferValue(item.type, value);
|
|
1131
1177
|
if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
|
|
1132
|
-
return /* @__PURE__ */ (0,
|
|
1178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
1133
1179
|
if (item.options) {
|
|
1134
1180
|
if (item.type.endsWith("[]"))
|
|
1135
1181
|
return transferred.map((v) => {
|
|
@@ -1150,9 +1196,52 @@ function processValue(item, value) {
|
|
|
1150
1196
|
return value;
|
|
1151
1197
|
}
|
|
1152
1198
|
function Table(props) {
|
|
1153
|
-
const [columns, setColumns] = (0,
|
|
1199
|
+
const [columns, setColumns] = (0, import_react14.useState)();
|
|
1154
1200
|
const { common: common2 } = useConfigContext();
|
|
1155
|
-
|
|
1201
|
+
const generateFilterDropdown = (item) => {
|
|
1202
|
+
if (typeof item.filterDropdown !== "undefined")
|
|
1203
|
+
return;
|
|
1204
|
+
if (item.options.length < 11) {
|
|
1205
|
+
if (!item.filters)
|
|
1206
|
+
item.filters = item.options.map((o) => ({
|
|
1207
|
+
text: o.label,
|
|
1208
|
+
value: o.value
|
|
1209
|
+
}));
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
item.filterDropdown = ({
|
|
1213
|
+
setSelectedKeys,
|
|
1214
|
+
selectedKeys,
|
|
1215
|
+
confirm
|
|
1216
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1217
|
+
style: {
|
|
1218
|
+
padding: 8,
|
|
1219
|
+
width: "200px"
|
|
1220
|
+
},
|
|
1221
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1222
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Select, {
|
|
1223
|
+
options: item.options,
|
|
1224
|
+
allowClear: true,
|
|
1225
|
+
showSearch: true,
|
|
1226
|
+
style: { width: "100%" },
|
|
1227
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1228
|
+
value: selectedKeys,
|
|
1229
|
+
onChange: (v) => {
|
|
1230
|
+
setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
|
|
1231
|
+
confirm();
|
|
1232
|
+
},
|
|
1233
|
+
mode: "multiple",
|
|
1234
|
+
filterOption: (input, option) => {
|
|
1235
|
+
if (!input || !option || !option.label)
|
|
1236
|
+
return true;
|
|
1237
|
+
input = input.trim();
|
|
1238
|
+
return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
|
|
1239
|
+
}
|
|
1240
|
+
})
|
|
1241
|
+
});
|
|
1242
|
+
return item;
|
|
1243
|
+
};
|
|
1244
|
+
(0, import_react14.useEffect)(() => {
|
|
1156
1245
|
var _a;
|
|
1157
1246
|
for (const item of props.items) {
|
|
1158
1247
|
if (!item.key)
|
|
@@ -1169,14 +1258,15 @@ function Table(props) {
|
|
|
1169
1258
|
text: o.label,
|
|
1170
1259
|
value: o.value
|
|
1171
1260
|
})).concat({
|
|
1172
|
-
text: /* @__PURE__ */ (0,
|
|
1261
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1173
1262
|
value: null
|
|
1174
1263
|
});
|
|
1264
|
+
generateFilterDropdown(item);
|
|
1175
1265
|
}
|
|
1176
1266
|
if (item.tableChildren === null)
|
|
1177
1267
|
item.render = () => null;
|
|
1178
1268
|
else if (item.tableChildren)
|
|
1179
|
-
item.render = (value, values) => (0,
|
|
1269
|
+
item.render = (value, values) => (0, import_react14.cloneElement)(
|
|
1180
1270
|
item.tableChildren,
|
|
1181
1271
|
{
|
|
1182
1272
|
scene: "table",
|
|
@@ -1187,7 +1277,7 @@ function Table(props) {
|
|
|
1187
1277
|
else if (item.children === null)
|
|
1188
1278
|
item.render = () => null;
|
|
1189
1279
|
else if (item.children)
|
|
1190
|
-
item.render = (value, values) => (0,
|
|
1280
|
+
item.render = (value, values) => (0, import_react14.cloneElement)(
|
|
1191
1281
|
item.children,
|
|
1192
1282
|
{
|
|
1193
1283
|
scene: "table",
|
|
@@ -1197,7 +1287,7 @@ function Table(props) {
|
|
|
1197
1287
|
);
|
|
1198
1288
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1199
1289
|
if (props.extendTypes[item.type].children)
|
|
1200
|
-
item.render = (value, values) => (0,
|
|
1290
|
+
item.render = (value, values) => (0, import_react14.cloneElement)(
|
|
1201
1291
|
props.extendTypes[item.type].children,
|
|
1202
1292
|
{
|
|
1203
1293
|
scene: "table",
|
|
@@ -1230,22 +1320,19 @@ function Table(props) {
|
|
|
1230
1320
|
setSelectedKeys,
|
|
1231
1321
|
confirm,
|
|
1232
1322
|
clearFilters
|
|
1233
|
-
}) => /* @__PURE__ */ (0,
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
setSelectedKeys([]);
|
|
1243
|
-
clearFilters();
|
|
1244
|
-
}
|
|
1245
|
-
confirm();
|
|
1323
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1324
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1325
|
+
allowClear: true,
|
|
1326
|
+
onSearch: (v) => {
|
|
1327
|
+
if (v) {
|
|
1328
|
+
setSelectedKeys([v]);
|
|
1329
|
+
} else {
|
|
1330
|
+
setSelectedKeys([]);
|
|
1331
|
+
clearFilters();
|
|
1246
1332
|
}
|
|
1333
|
+
confirm();
|
|
1247
1334
|
}
|
|
1248
|
-
);
|
|
1335
|
+
});
|
|
1249
1336
|
break;
|
|
1250
1337
|
case "string[]":
|
|
1251
1338
|
if (!item.render)
|
|
@@ -1265,22 +1352,19 @@ function Table(props) {
|
|
|
1265
1352
|
setSelectedKeys,
|
|
1266
1353
|
confirm,
|
|
1267
1354
|
clearFilters
|
|
1268
|
-
}) => /* @__PURE__ */ (0,
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
setSelectedKeys([]);
|
|
1278
|
-
clearFilters();
|
|
1279
|
-
}
|
|
1280
|
-
confirm();
|
|
1355
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1356
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1357
|
+
allowClear: true,
|
|
1358
|
+
onSearch: (v) => {
|
|
1359
|
+
if (v) {
|
|
1360
|
+
setSelectedKeys([v]);
|
|
1361
|
+
} else {
|
|
1362
|
+
setSelectedKeys([]);
|
|
1363
|
+
clearFilters();
|
|
1281
1364
|
}
|
|
1365
|
+
confirm();
|
|
1282
1366
|
}
|
|
1283
|
-
);
|
|
1367
|
+
});
|
|
1284
1368
|
break;
|
|
1285
1369
|
case "number":
|
|
1286
1370
|
if (!item.render)
|
|
@@ -1302,22 +1386,19 @@ function Table(props) {
|
|
|
1302
1386
|
setSelectedKeys,
|
|
1303
1387
|
confirm,
|
|
1304
1388
|
clearFilters
|
|
1305
|
-
}) => /* @__PURE__ */ (0,
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
setSelectedKeys([]);
|
|
1315
|
-
clearFilters();
|
|
1316
|
-
}
|
|
1317
|
-
confirm();
|
|
1389
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1390
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1391
|
+
allowClear: true,
|
|
1392
|
+
onSearch: (v) => {
|
|
1393
|
+
if (v) {
|
|
1394
|
+
setSelectedKeys([Number(v)]);
|
|
1395
|
+
} else {
|
|
1396
|
+
setSelectedKeys([]);
|
|
1397
|
+
clearFilters();
|
|
1318
1398
|
}
|
|
1399
|
+
confirm();
|
|
1319
1400
|
}
|
|
1320
|
-
);
|
|
1401
|
+
});
|
|
1321
1402
|
break;
|
|
1322
1403
|
case "number[]":
|
|
1323
1404
|
if (!item.render)
|
|
@@ -1337,66 +1418,79 @@ function Table(props) {
|
|
|
1337
1418
|
setSelectedKeys,
|
|
1338
1419
|
confirm,
|
|
1339
1420
|
clearFilters
|
|
1340
|
-
}) => /* @__PURE__ */ (0,
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
setSelectedKeys([]);
|
|
1350
|
-
clearFilters();
|
|
1351
|
-
}
|
|
1352
|
-
confirm();
|
|
1421
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1422
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1423
|
+
allowClear: true,
|
|
1424
|
+
onSearch: (v) => {
|
|
1425
|
+
if (v) {
|
|
1426
|
+
setSelectedKeys([Number(v)]);
|
|
1427
|
+
} else {
|
|
1428
|
+
setSelectedKeys([]);
|
|
1429
|
+
clearFilters();
|
|
1353
1430
|
}
|
|
1431
|
+
confirm();
|
|
1354
1432
|
}
|
|
1355
|
-
);
|
|
1433
|
+
});
|
|
1356
1434
|
break;
|
|
1357
1435
|
case "boolean":
|
|
1358
1436
|
if (!item.render)
|
|
1359
|
-
item.render = (value) => (0, import_lodash_es6.isNil)(value) ? /* @__PURE__ */ (0,
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1437
|
+
item.render = (value) => (0, import_lodash_es6.isNil)(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}) : value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1438
|
+
style: {
|
|
1439
|
+
marginTop: "4px",
|
|
1440
|
+
color: "#52c41a"
|
|
1441
|
+
}
|
|
1442
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
|
|
1443
|
+
style: {
|
|
1444
|
+
marginTop: "4px",
|
|
1445
|
+
color: "#ff4d4f"
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1366
1448
|
if (item.filterDropdown !== false)
|
|
1367
1449
|
item.filterDropdown = ({
|
|
1368
1450
|
setSelectedKeys,
|
|
1369
1451
|
selectedKeys,
|
|
1370
1452
|
confirm
|
|
1371
|
-
}) => /* @__PURE__ */ (0,
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1453
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd12.Radio.Group, {
|
|
1454
|
+
style: { padding: 8 },
|
|
1455
|
+
buttonStyle: "solid",
|
|
1456
|
+
value: JSON.stringify(selectedKeys[0]),
|
|
1457
|
+
onChange: (e) => {
|
|
1458
|
+
const Values = {
|
|
1459
|
+
true: true,
|
|
1460
|
+
false: false,
|
|
1461
|
+
null: null
|
|
1462
|
+
};
|
|
1463
|
+
setSelectedKeys(e.target.value ? [Values[e.target.value]] : []);
|
|
1464
|
+
confirm();
|
|
1465
|
+
},
|
|
1466
|
+
children: [
|
|
1467
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1468
|
+
children: common2.all
|
|
1469
|
+
}),
|
|
1470
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1471
|
+
value: "true",
|
|
1472
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1473
|
+
style: {
|
|
1474
|
+
color: "#52c41a",
|
|
1475
|
+
verticalAlign: "middle"
|
|
1476
|
+
}
|
|
1477
|
+
})
|
|
1478
|
+
}),
|
|
1479
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1480
|
+
value: "false",
|
|
1481
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
|
|
1482
|
+
style: {
|
|
1483
|
+
verticalAlign: "middle",
|
|
1484
|
+
color: "#ff4d4f"
|
|
1485
|
+
}
|
|
1486
|
+
})
|
|
1487
|
+
}),
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1489
|
+
value: "null",
|
|
1490
|
+
children: common2.blank
|
|
1491
|
+
})
|
|
1492
|
+
]
|
|
1493
|
+
});
|
|
1400
1494
|
if (!item.onFilter)
|
|
1401
1495
|
item.onFilter = (value, row) => {
|
|
1402
1496
|
switch (value) {
|
|
@@ -1424,15 +1518,12 @@ function Table(props) {
|
|
|
1424
1518
|
item.filterDropdown = ({
|
|
1425
1519
|
setSelectedKeys,
|
|
1426
1520
|
confirm
|
|
1427
|
-
}) => /* @__PURE__ */ (0,
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1432
|
-
confirm();
|
|
1433
|
-
}
|
|
1521
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.DatePicker.RangePicker, {
|
|
1522
|
+
onChange: (dates) => {
|
|
1523
|
+
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1524
|
+
confirm();
|
|
1434
1525
|
}
|
|
1435
|
-
);
|
|
1526
|
+
});
|
|
1436
1527
|
if (!item.onFilter)
|
|
1437
1528
|
item.onFilter = (value, row) => {
|
|
1438
1529
|
if ((0, import_lodash_es6.isNil)(value[0]))
|
|
@@ -1457,15 +1548,12 @@ function Table(props) {
|
|
|
1457
1548
|
item.filterDropdown = ({
|
|
1458
1549
|
setSelectedKeys,
|
|
1459
1550
|
confirm
|
|
1460
|
-
}) => /* @__PURE__ */ (0,
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1465
|
-
confirm();
|
|
1466
|
-
}
|
|
1551
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.DatePicker.RangePicker, {
|
|
1552
|
+
onChange: (dates) => {
|
|
1553
|
+
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1554
|
+
confirm();
|
|
1467
1555
|
}
|
|
1468
|
-
);
|
|
1556
|
+
});
|
|
1469
1557
|
if (!item.onFilter)
|
|
1470
1558
|
item.onFilter = (value, row) => {
|
|
1471
1559
|
if ((0, import_lodash_es6.isNil)(value[0]))
|
|
@@ -1477,26 +1565,21 @@ function Table(props) {
|
|
|
1477
1565
|
break;
|
|
1478
1566
|
case "object":
|
|
1479
1567
|
if (!item.render)
|
|
1480
|
-
item.render = (value) => /* @__PURE__ */ (0,
|
|
1481
|
-
|
|
1482
|
-
{
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
column: 1
|
|
1486
|
-
}
|
|
1487
|
-
);
|
|
1568
|
+
item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
1569
|
+
items: item.object,
|
|
1570
|
+
dataSource: value || {},
|
|
1571
|
+
column: 1
|
|
1572
|
+
});
|
|
1488
1573
|
break;
|
|
1489
1574
|
case "object[]":
|
|
1490
1575
|
if (!item.render)
|
|
1491
|
-
item.render = (value) => /* @__PURE__ */ (0,
|
|
1492
|
-
Description,
|
|
1493
|
-
{
|
|
1576
|
+
item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
1577
|
+
children: value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
1494
1578
|
items: item.object,
|
|
1495
1579
|
dataSource: v || [],
|
|
1496
1580
|
column: 1
|
|
1497
|
-
},
|
|
1498
|
-
|
|
1499
|
-
)) });
|
|
1581
|
+
}, i))
|
|
1582
|
+
});
|
|
1500
1583
|
break;
|
|
1501
1584
|
default:
|
|
1502
1585
|
if (!item.render)
|
|
@@ -1512,64 +1595,21 @@ function Table(props) {
|
|
|
1512
1595
|
}
|
|
1513
1596
|
setColumns(props.items);
|
|
1514
1597
|
}, [props.items]);
|
|
1515
|
-
(0,
|
|
1598
|
+
(0, import_react14.useEffect)(() => {
|
|
1516
1599
|
if (!props.dataSource || !columns)
|
|
1517
1600
|
return;
|
|
1518
1601
|
for (const column of columns) {
|
|
1519
1602
|
if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1603
|
+
const options = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
|
|
1604
|
+
label: v[column.id],
|
|
1522
1605
|
value: v[column.id]
|
|
1523
1606
|
}));
|
|
1524
|
-
if (
|
|
1607
|
+
if (options.length)
|
|
1525
1608
|
setColumns((prev) => {
|
|
1526
1609
|
const newColumns = [...prev];
|
|
1527
1610
|
const index = newColumns.findIndex((item) => item.id === column.id);
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
text: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Blank, {}),
|
|
1531
|
-
value: null
|
|
1532
|
-
});
|
|
1533
|
-
else
|
|
1534
|
-
newColumns[index].filterDropdown = ({
|
|
1535
|
-
setSelectedKeys,
|
|
1536
|
-
selectedKeys,
|
|
1537
|
-
confirm
|
|
1538
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1539
|
-
"div",
|
|
1540
|
-
{
|
|
1541
|
-
style: {
|
|
1542
|
-
padding: 8,
|
|
1543
|
-
width: "200px"
|
|
1544
|
-
},
|
|
1545
|
-
onKeyDown: (e) => e.stopPropagation(),
|
|
1546
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1547
|
-
import_antd12.Select,
|
|
1548
|
-
{
|
|
1549
|
-
options: filters.map((f) => ({
|
|
1550
|
-
label: f.text,
|
|
1551
|
-
value: f.value
|
|
1552
|
-
})),
|
|
1553
|
-
allowClear: true,
|
|
1554
|
-
showSearch: true,
|
|
1555
|
-
style: { width: "100%" },
|
|
1556
|
-
placeholder: `${common2.search} ${newColumns[index].title}`,
|
|
1557
|
-
value: selectedKeys,
|
|
1558
|
-
onChange: (v) => {
|
|
1559
|
-
setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
|
|
1560
|
-
confirm();
|
|
1561
|
-
},
|
|
1562
|
-
mode: "multiple",
|
|
1563
|
-
filterOption: (input, option) => {
|
|
1564
|
-
if (!input || !option || !option.label)
|
|
1565
|
-
return true;
|
|
1566
|
-
input = input.trim();
|
|
1567
|
-
return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
|
|
1568
|
-
}
|
|
1569
|
-
}
|
|
1570
|
-
)
|
|
1571
|
-
}
|
|
1572
|
-
);
|
|
1611
|
+
newColumns[index].options = options;
|
|
1612
|
+
generateFilterDropdown(newColumns[index]);
|
|
1573
1613
|
return newColumns;
|
|
1574
1614
|
});
|
|
1575
1615
|
}
|
|
@@ -1578,26 +1618,19 @@ function Table(props) {
|
|
|
1578
1618
|
if (!columns)
|
|
1579
1619
|
return null;
|
|
1580
1620
|
if (props.dataSource)
|
|
1581
|
-
return /* @__PURE__ */ (0,
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1593
|
-
FaasDataTable,
|
|
1594
|
-
{
|
|
1595
|
-
props,
|
|
1596
|
-
columns
|
|
1597
|
-
}
|
|
1598
|
-
)
|
|
1621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1622
|
+
...props,
|
|
1623
|
+
rowKey: props.rowKey || "id",
|
|
1624
|
+
columns,
|
|
1625
|
+
dataSource: props.dataSource
|
|
1626
|
+
});
|
|
1627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
1628
|
+
...props.faasData,
|
|
1629
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataTable, {
|
|
1630
|
+
props,
|
|
1631
|
+
columns
|
|
1599
1632
|
})
|
|
1600
|
-
);
|
|
1633
|
+
});
|
|
1601
1634
|
}
|
|
1602
1635
|
function FaasDataTable({
|
|
1603
1636
|
props,
|
|
@@ -1606,8 +1639,8 @@ function FaasDataTable({
|
|
|
1606
1639
|
params,
|
|
1607
1640
|
reload
|
|
1608
1641
|
}) {
|
|
1609
|
-
const [currentColumns, setCurrentColumns] = (0,
|
|
1610
|
-
(0,
|
|
1642
|
+
const [currentColumns, setCurrentColumns] = (0, import_react14.useState)(columns);
|
|
1643
|
+
(0, import_react14.useEffect)(() => {
|
|
1611
1644
|
if (!data || Array.isArray(data))
|
|
1612
1645
|
return;
|
|
1613
1646
|
setCurrentColumns((prev) => {
|
|
@@ -1619,7 +1652,7 @@ function FaasDataTable({
|
|
|
1619
1652
|
text: v.label,
|
|
1620
1653
|
value: v.value
|
|
1621
1654
|
})).concat({
|
|
1622
|
-
text: /* @__PURE__ */ (0,
|
|
1655
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1623
1656
|
value: null
|
|
1624
1657
|
});
|
|
1625
1658
|
column.render = (value) => processValue(column, value);
|
|
@@ -1634,7 +1667,7 @@ function FaasDataTable({
|
|
|
1634
1667
|
}));
|
|
1635
1668
|
if (filters.length)
|
|
1636
1669
|
column.filters = filters.concat({
|
|
1637
|
-
text: /* @__PURE__ */ (0,
|
|
1670
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1638
1671
|
value: null
|
|
1639
1672
|
});
|
|
1640
1673
|
}
|
|
@@ -1643,75 +1676,75 @@ function FaasDataTable({
|
|
|
1643
1676
|
});
|
|
1644
1677
|
}, [columns, data]);
|
|
1645
1678
|
if (!data)
|
|
1646
|
-
return /* @__PURE__ */ (0,
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
})
|
|
1653
|
-
);
|
|
1679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1680
|
+
...props,
|
|
1681
|
+
rowKey: props.rowKey || "id",
|
|
1682
|
+
columns: currentColumns,
|
|
1683
|
+
dataSource: []
|
|
1684
|
+
});
|
|
1654
1685
|
if (Array.isArray(data))
|
|
1655
|
-
return /* @__PURE__ */ (0,
|
|
1656
|
-
|
|
1657
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1658
|
-
rowKey: props.rowKey || "id",
|
|
1659
|
-
columns: currentColumns,
|
|
1660
|
-
dataSource: data
|
|
1661
|
-
})
|
|
1662
|
-
);
|
|
1663
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1664
|
-
import_antd12.Table,
|
|
1665
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1687
|
+
...props,
|
|
1666
1688
|
rowKey: props.rowKey || "id",
|
|
1667
1689
|
columns: currentColumns,
|
|
1668
|
-
dataSource: data
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1690
|
+
dataSource: data
|
|
1691
|
+
});
|
|
1692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1693
|
+
...props,
|
|
1694
|
+
rowKey: props.rowKey || "id",
|
|
1695
|
+
columns: currentColumns,
|
|
1696
|
+
dataSource: data.rows,
|
|
1697
|
+
pagination: {
|
|
1698
|
+
...props.pagination,
|
|
1699
|
+
...data.pagination
|
|
1700
|
+
},
|
|
1701
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
1702
|
+
if (props.onChange) {
|
|
1703
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1704
|
+
reload({
|
|
1705
|
+
...params,
|
|
1706
|
+
pagination: processed.pagination,
|
|
1707
|
+
filters: processed.filters,
|
|
1708
|
+
sorter: processed.sorter
|
|
1709
|
+
});
|
|
1710
|
+
return;
|
|
1685
1711
|
}
|
|
1686
|
-
|
|
1687
|
-
|
|
1712
|
+
reload({
|
|
1713
|
+
...params,
|
|
1714
|
+
pagination,
|
|
1715
|
+
filters,
|
|
1716
|
+
sorter
|
|
1717
|
+
});
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1688
1720
|
}
|
|
1689
1721
|
|
|
1690
1722
|
// src/Title.tsx
|
|
1691
|
-
var
|
|
1692
|
-
var
|
|
1723
|
+
var import_react15 = require("react");
|
|
1724
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1693
1725
|
function Title(props) {
|
|
1694
1726
|
const { Title: Title2 } = useConfigContext();
|
|
1695
|
-
(0,
|
|
1727
|
+
(0, import_react15.useEffect)(() => {
|
|
1696
1728
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1697
1729
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1698
1730
|
}, [props]);
|
|
1699
1731
|
if (props.h1) {
|
|
1700
1732
|
if (typeof props.h1 === "boolean")
|
|
1701
|
-
return /* @__PURE__ */ (0,
|
|
1702
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1703
|
-
"h1",
|
|
1704
|
-
{
|
|
1705
|
-
className: props.h1.className,
|
|
1706
|
-
style: props.h1.style,
|
|
1733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
1707
1734
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1708
|
-
}
|
|
1709
|
-
)
|
|
1735
|
+
});
|
|
1736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
1737
|
+
className: props.h1.className,
|
|
1738
|
+
style: props.h1.style,
|
|
1739
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1740
|
+
});
|
|
1710
1741
|
}
|
|
1711
1742
|
if (props.plain)
|
|
1712
|
-
return /* @__PURE__ */ (0,
|
|
1743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
1744
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1745
|
+
});
|
|
1713
1746
|
if (props.children)
|
|
1714
|
-
return (0,
|
|
1747
|
+
return (0, import_react15.cloneElement)(props.children, { title: props.title });
|
|
1715
1748
|
return null;
|
|
1716
1749
|
}
|
|
1717
1750
|
// Annotate the CommonJS export names for ESM import in node:
|