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