@faasjs/ant-design 0.0.3-beta.64 → 0.0.3-beta.65
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.js +744 -722
- package/dist/index.mjs +717 -699
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
1
|
// react-shim.js
|
|
22
2
|
import React from "react";
|
|
23
3
|
|
|
@@ -40,17 +20,24 @@ import { Modal } from "antd";
|
|
|
40
20
|
import { useState } from "react";
|
|
41
21
|
import { jsx } from "react/jsx-runtime";
|
|
42
22
|
function useModal(init) {
|
|
43
|
-
const [props, setProps] = useState(
|
|
23
|
+
const [props, setProps] = useState({
|
|
44
24
|
open: false,
|
|
45
|
-
onCancel: () => setProps((prev) =>
|
|
25
|
+
onCancel: () => setProps((prev) => ({
|
|
26
|
+
...prev,
|
|
46
27
|
open: false
|
|
47
|
-
}))
|
|
48
|
-
|
|
28
|
+
})),
|
|
29
|
+
...init
|
|
30
|
+
});
|
|
49
31
|
return {
|
|
50
|
-
modal: /* @__PURE__ */ jsx(Modal,
|
|
32
|
+
modal: /* @__PURE__ */ jsx(Modal, {
|
|
33
|
+
...props
|
|
34
|
+
}),
|
|
51
35
|
modalProps: props,
|
|
52
36
|
setModalProps(changes) {
|
|
53
|
-
setProps((prev) =>
|
|
37
|
+
setProps((prev) => ({
|
|
38
|
+
...prev,
|
|
39
|
+
...changes
|
|
40
|
+
}));
|
|
54
41
|
}
|
|
55
42
|
};
|
|
56
43
|
}
|
|
@@ -60,17 +47,24 @@ import { Drawer } from "antd";
|
|
|
60
47
|
import { useState as useState2 } from "react";
|
|
61
48
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
62
49
|
function useDrawer(init) {
|
|
63
|
-
const [props, setProps] = useState2(
|
|
50
|
+
const [props, setProps] = useState2({
|
|
64
51
|
open: false,
|
|
65
|
-
onClose: () => setProps((prev) =>
|
|
52
|
+
onClose: () => setProps((prev) => ({
|
|
53
|
+
...prev,
|
|
66
54
|
open: false
|
|
67
|
-
}))
|
|
68
|
-
|
|
55
|
+
})),
|
|
56
|
+
...init
|
|
57
|
+
});
|
|
69
58
|
return {
|
|
70
|
-
drawer: /* @__PURE__ */ jsx2(Drawer,
|
|
59
|
+
drawer: /* @__PURE__ */ jsx2(Drawer, {
|
|
60
|
+
...props
|
|
61
|
+
}),
|
|
71
62
|
drawerProps: props,
|
|
72
63
|
setDrawerProps(changes) {
|
|
73
|
-
setProps((prev) =>
|
|
64
|
+
setProps((prev) => ({
|
|
65
|
+
...prev,
|
|
66
|
+
...changes
|
|
67
|
+
}));
|
|
74
68
|
}
|
|
75
69
|
};
|
|
76
70
|
}
|
|
@@ -92,7 +86,9 @@ function RoutesApp(props) {
|
|
|
92
86
|
setDrawerProps({ open: false });
|
|
93
87
|
setModalProps({ open: false });
|
|
94
88
|
}, [location]);
|
|
95
|
-
return /* @__PURE__ */ jsx3(Fragment, {
|
|
89
|
+
return /* @__PURE__ */ jsx3(Fragment, {
|
|
90
|
+
children: props.children
|
|
91
|
+
});
|
|
96
92
|
}
|
|
97
93
|
function App(props) {
|
|
98
94
|
const [messageApi, messageContextHolder] = message.useMessage();
|
|
@@ -113,21 +109,30 @@ function App(props) {
|
|
|
113
109
|
setDrawerProps
|
|
114
110
|
]
|
|
115
111
|
);
|
|
116
|
-
return /* @__PURE__ */ jsx3(
|
|
117
|
-
|
|
118
|
-
__spreadProps(__spreadValues({}, Object.assign(props.styleProviderProps || {}, {
|
|
112
|
+
return /* @__PURE__ */ jsx3(StyleProvider, {
|
|
113
|
+
...Object.assign(props.styleProviderProps || {}, {
|
|
119
114
|
hashPriority: "high",
|
|
120
115
|
transformers: [legacyLogicalPropertiesTransformer]
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
116
|
+
}),
|
|
117
|
+
children: /* @__PURE__ */ jsx3(ConfigProvider, {
|
|
118
|
+
...props.configProviderProps,
|
|
119
|
+
children: /* @__PURE__ */ jsx3(AppContext.Provider, {
|
|
120
|
+
value: memoizedContextValue,
|
|
121
|
+
children: /* @__PURE__ */ jsxs(BrowserRouter, {
|
|
122
|
+
...props.browserRouterProps,
|
|
123
|
+
children: [
|
|
124
|
+
messageContextHolder,
|
|
125
|
+
notificationContextHolder,
|
|
126
|
+
modal,
|
|
127
|
+
drawer,
|
|
128
|
+
/* @__PURE__ */ jsx3(RoutesApp, {
|
|
129
|
+
children: props.children
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
})
|
|
129
134
|
})
|
|
130
|
-
);
|
|
135
|
+
});
|
|
131
136
|
}
|
|
132
137
|
function useApp() {
|
|
133
138
|
return useContext(AppContext);
|
|
@@ -202,7 +207,10 @@ function ConfigProvider2({
|
|
|
202
207
|
} else
|
|
203
208
|
setValues(defaultsDeep(config, values));
|
|
204
209
|
}, []);
|
|
205
|
-
return /* @__PURE__ */ jsx4(ConfigContext.Provider, {
|
|
210
|
+
return /* @__PURE__ */ jsx4(ConfigContext.Provider, {
|
|
211
|
+
value: values,
|
|
212
|
+
children
|
|
213
|
+
});
|
|
206
214
|
}
|
|
207
215
|
function useConfigContext() {
|
|
208
216
|
return useContext2(ConfigContext);
|
|
@@ -212,7 +220,10 @@ function useConfigContext() {
|
|
|
212
220
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
213
221
|
function Blank(options) {
|
|
214
222
|
const { Blank: Blank2 } = useConfigContext();
|
|
215
|
-
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx5(Typography.Text, {
|
|
223
|
+
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx5(Typography.Text, {
|
|
224
|
+
disabled: true,
|
|
225
|
+
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
226
|
+
}) : options.value;
|
|
216
227
|
}
|
|
217
228
|
|
|
218
229
|
// src/data.ts
|
|
@@ -250,71 +261,55 @@ import {
|
|
|
250
261
|
} from "antd";
|
|
251
262
|
import { isFunction, upperFirst as upperFirst2 } from "lodash-es";
|
|
252
263
|
import {
|
|
253
|
-
cloneElement
|
|
254
|
-
useEffect as useEffect4,
|
|
255
|
-
useState as useState5
|
|
256
|
-
} from "react";
|
|
257
|
-
|
|
258
|
-
// ../react/src/index.tsx
|
|
259
|
-
import {
|
|
260
|
-
useState as useState4,
|
|
264
|
+
cloneElement,
|
|
261
265
|
useEffect as useEffect3,
|
|
262
|
-
|
|
263
|
-
cloneElement
|
|
266
|
+
useState as useState4
|
|
264
267
|
} from "react";
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (!client)
|
|
269
|
-
throw Error("FaasReactClient is not initialized");
|
|
270
|
-
return client;
|
|
271
|
-
}
|
|
272
|
-
async function faas(action, params) {
|
|
273
|
-
return getClient().faas(action, params);
|
|
274
|
-
}
|
|
275
|
-
function FaasDataWrapper(props) {
|
|
276
|
-
const [client, setClient] = useState4();
|
|
277
|
-
useEffect3(() => {
|
|
278
|
-
if (client)
|
|
279
|
-
return;
|
|
280
|
-
setClient(getClient());
|
|
281
|
-
}, []);
|
|
282
|
-
if (!client)
|
|
283
|
-
return props.fallback || null;
|
|
284
|
-
return createElement(client.FaasDataWrapper, props);
|
|
285
|
-
}
|
|
268
|
+
|
|
269
|
+
// src/FaasDataWrapper.tsx
|
|
270
|
+
import { FaasDataWrapper as Origin } from "@faasjs/react";
|
|
286
271
|
|
|
287
272
|
// src/Loading.tsx
|
|
288
273
|
import { Spin } from "antd";
|
|
289
274
|
import { Fragment as Fragment2, jsx as jsx6 } from "react/jsx-runtime";
|
|
290
275
|
function Loading(props) {
|
|
291
276
|
if (props.loading === false)
|
|
292
|
-
return /* @__PURE__ */ jsx6(Fragment2, {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
277
|
+
return /* @__PURE__ */ jsx6(Fragment2, {
|
|
278
|
+
children: props.children
|
|
279
|
+
});
|
|
280
|
+
return /* @__PURE__ */ jsx6("div", {
|
|
281
|
+
style: {
|
|
282
|
+
...props.style || {},
|
|
283
|
+
...!props.size || props.size === "large" ? {
|
|
284
|
+
margin: "20vh auto",
|
|
285
|
+
textAlign: "center"
|
|
286
|
+
} : {}
|
|
287
|
+
},
|
|
288
|
+
children: /* @__PURE__ */ jsx6(Spin, {
|
|
289
|
+
size: props.size || "large"
|
|
290
|
+
})
|
|
291
|
+
});
|
|
297
292
|
}
|
|
298
293
|
|
|
299
294
|
// src/FaasDataWrapper.tsx
|
|
300
295
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
301
|
-
function
|
|
302
|
-
return /* @__PURE__ */ jsx7(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
);
|
|
296
|
+
function FaasDataWrapper(props) {
|
|
297
|
+
return /* @__PURE__ */ jsx7(Origin, {
|
|
298
|
+
fallback: props.loading || /* @__PURE__ */ jsx7(Loading, {
|
|
299
|
+
...props.loadingProps
|
|
300
|
+
}),
|
|
301
|
+
...props
|
|
302
|
+
});
|
|
308
303
|
}
|
|
309
304
|
|
|
310
305
|
// src/Description.tsx
|
|
311
306
|
import { Fragment as Fragment3, jsx as jsx8 } from "react/jsx-runtime";
|
|
312
307
|
function DescriptionItemContent(props) {
|
|
313
308
|
var _a;
|
|
314
|
-
const [computedProps, setComputedProps] =
|
|
315
|
-
|
|
309
|
+
const [computedProps, setComputedProps] = useState4();
|
|
310
|
+
useEffect3(() => {
|
|
316
311
|
var _a2, _b;
|
|
317
|
-
const propsCopy =
|
|
312
|
+
const propsCopy = { ...props };
|
|
318
313
|
if (!propsCopy.item.title)
|
|
319
314
|
propsCopy.item.title = upperFirst2(propsCopy.item.id);
|
|
320
315
|
if (!propsCopy.item.type)
|
|
@@ -342,7 +337,7 @@ function DescriptionItemContent(props) {
|
|
|
342
337
|
return null;
|
|
343
338
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
344
339
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
345
|
-
return
|
|
340
|
+
return cloneElement(
|
|
346
341
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
347
342
|
{
|
|
348
343
|
scene: "description",
|
|
@@ -351,13 +346,15 @@ function DescriptionItemContent(props) {
|
|
|
351
346
|
}
|
|
352
347
|
);
|
|
353
348
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
354
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
349
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
350
|
+
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
|
|
351
|
+
});
|
|
355
352
|
else
|
|
356
353
|
throw Error(computedProps.item.type + " requires children or render");
|
|
357
354
|
if (computedProps.item.descriptionChildren === null)
|
|
358
355
|
return null;
|
|
359
356
|
if (computedProps.item.descriptionChildren)
|
|
360
|
-
return
|
|
357
|
+
return cloneElement(computedProps.item.descriptionChildren, {
|
|
361
358
|
scene: "description",
|
|
362
359
|
value: computedProps.value,
|
|
363
360
|
values: computedProps.values
|
|
@@ -365,7 +362,7 @@ function DescriptionItemContent(props) {
|
|
|
365
362
|
if (computedProps.item.children === null)
|
|
366
363
|
return null;
|
|
367
364
|
if (computedProps.item.children)
|
|
368
|
-
return
|
|
365
|
+
return cloneElement(computedProps.item.children, {
|
|
369
366
|
scene: "description",
|
|
370
367
|
value: computedProps.value,
|
|
371
368
|
values: computedProps.values
|
|
@@ -378,107 +375,95 @@ function DescriptionItemContent(props) {
|
|
|
378
375
|
return /* @__PURE__ */ jsx8(Blank, {});
|
|
379
376
|
switch (computedProps.item.type) {
|
|
380
377
|
case "string[]":
|
|
381
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
378
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
379
|
+
children: computedProps.value.join(", ")
|
|
380
|
+
});
|
|
382
381
|
case "number":
|
|
383
382
|
return computedProps.value || null;
|
|
384
383
|
case "number[]":
|
|
385
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
384
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
385
|
+
children: computedProps.value.join(", ")
|
|
386
|
+
});
|
|
386
387
|
case "boolean":
|
|
387
|
-
return computedProps.value ? /* @__PURE__ */ jsx8(CheckOutlined, {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
388
|
+
return computedProps.value ? /* @__PURE__ */ jsx8(CheckOutlined, {
|
|
389
|
+
style: {
|
|
390
|
+
marginTop: "4px",
|
|
391
|
+
color: "#52c41a"
|
|
392
|
+
}
|
|
393
|
+
}) : /* @__PURE__ */ jsx8(CloseOutlined, {
|
|
394
|
+
style: {
|
|
395
|
+
marginTop: "4px",
|
|
396
|
+
color: "#ff4d4f"
|
|
397
|
+
}
|
|
398
|
+
});
|
|
394
399
|
case "time":
|
|
395
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
400
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
401
|
+
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
402
|
+
});
|
|
396
403
|
case "date":
|
|
397
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
404
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
405
|
+
children: computedProps.value.format("YYYY-MM-DD")
|
|
406
|
+
});
|
|
398
407
|
case "object":
|
|
399
408
|
if (!computedProps.value)
|
|
400
409
|
return /* @__PURE__ */ jsx8(Blank, {});
|
|
401
|
-
return /* @__PURE__ */ jsx8(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
column: 1
|
|
407
|
-
}
|
|
408
|
-
);
|
|
410
|
+
return /* @__PURE__ */ jsx8(Description, {
|
|
411
|
+
items: computedProps.item.object,
|
|
412
|
+
dataSource: computedProps.value,
|
|
413
|
+
column: 1
|
|
414
|
+
});
|
|
409
415
|
case "object[]":
|
|
410
416
|
if (!((_a = computedProps.value) == null ? void 0 : _a.length))
|
|
411
417
|
return /* @__PURE__ */ jsx8(Blank, {});
|
|
412
|
-
return /* @__PURE__ */ jsx8(Space, {
|
|
413
|
-
|
|
414
|
-
{
|
|
418
|
+
return /* @__PURE__ */ jsx8(Space, {
|
|
419
|
+
direction: "vertical",
|
|
420
|
+
children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx8(Description, {
|
|
415
421
|
items: computedProps.item.object,
|
|
416
422
|
dataSource: value,
|
|
417
423
|
column: 1
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
)) });
|
|
424
|
+
}, index))
|
|
425
|
+
});
|
|
421
426
|
default:
|
|
422
427
|
return computedProps.value || null;
|
|
423
428
|
}
|
|
424
429
|
}
|
|
425
430
|
function Description(props) {
|
|
426
431
|
if (props.dataSource)
|
|
427
|
-
return /* @__PURE__ */ jsx8(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
432
|
+
return /* @__PURE__ */ jsx8(Descriptions, {
|
|
433
|
+
...props,
|
|
434
|
+
title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
435
|
+
children: props.items.map((item) => {
|
|
436
|
+
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
|
|
437
|
+
label: item.title || upperFirst2(item.id),
|
|
438
|
+
children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
|
|
439
|
+
item,
|
|
440
|
+
value: props.dataSource[item.id],
|
|
441
|
+
values: props.dataSource,
|
|
442
|
+
extendTypes: props.extendTypes
|
|
443
|
+
})
|
|
444
|
+
}, item.id) : null;
|
|
445
|
+
}).filter(Boolean)
|
|
446
|
+
});
|
|
447
|
+
return /* @__PURE__ */ jsx8(FaasDataWrapper, {
|
|
448
|
+
render: ({ data }) => {
|
|
449
|
+
return /* @__PURE__ */ jsx8(Descriptions, {
|
|
450
|
+
...props,
|
|
451
|
+
title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
431
452
|
children: props.items.map((item) => {
|
|
432
|
-
return !item.if || item.if(
|
|
433
|
-
|
|
434
|
-
{
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
values: props.dataSource,
|
|
442
|
-
extendTypes: props.extendTypes
|
|
443
|
-
}
|
|
444
|
-
)
|
|
445
|
-
},
|
|
446
|
-
item.id
|
|
447
|
-
) : null;
|
|
453
|
+
return !item.if || item.if(data) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
|
|
454
|
+
label: item.title || upperFirst2(item.id),
|
|
455
|
+
children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
|
|
456
|
+
item,
|
|
457
|
+
value: data[item.id],
|
|
458
|
+
values: data,
|
|
459
|
+
extendTypes: props.extendTypes
|
|
460
|
+
})
|
|
461
|
+
}, item.id) : null;
|
|
448
462
|
}).filter(Boolean)
|
|
449
|
-
})
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
__spreadValues({
|
|
454
|
-
render: ({ data }) => {
|
|
455
|
-
return /* @__PURE__ */ jsx8(
|
|
456
|
-
Descriptions,
|
|
457
|
-
__spreadProps(__spreadValues({}, props), {
|
|
458
|
-
title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
459
|
-
children: props.items.map((item) => {
|
|
460
|
-
return !item.if || item.if(data) ? /* @__PURE__ */ jsx8(
|
|
461
|
-
Descriptions.Item,
|
|
462
|
-
{
|
|
463
|
-
label: item.title || upperFirst2(item.id),
|
|
464
|
-
children: /* @__PURE__ */ jsx8(
|
|
465
|
-
DescriptionItemContent,
|
|
466
|
-
{
|
|
467
|
-
item,
|
|
468
|
-
value: data[item.id],
|
|
469
|
-
values: data,
|
|
470
|
-
extendTypes: props.extendTypes
|
|
471
|
-
}
|
|
472
|
-
)
|
|
473
|
-
},
|
|
474
|
-
item.id
|
|
475
|
-
) : null;
|
|
476
|
-
}).filter(Boolean)
|
|
477
|
-
})
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
}, props.faasData)
|
|
481
|
-
);
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
...props.faasData
|
|
466
|
+
});
|
|
482
467
|
}
|
|
483
468
|
|
|
484
469
|
// src/ErrorBoundary.tsx
|
|
@@ -512,30 +497,31 @@ var ErrorBoundary = class extends Component {
|
|
|
512
497
|
if (error) {
|
|
513
498
|
if (this.props.onError)
|
|
514
499
|
return this.props.onError(error, info);
|
|
515
|
-
return /* @__PURE__ */ jsx9(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
description: /* @__PURE__ */ jsx9("pre", { style: {
|
|
500
|
+
return /* @__PURE__ */ jsx9(Alert, {
|
|
501
|
+
type: "error",
|
|
502
|
+
message: errorMessage,
|
|
503
|
+
description: /* @__PURE__ */ jsx9("pre", {
|
|
504
|
+
style: {
|
|
521
505
|
fontSize: "0.9em",
|
|
522
506
|
overflowX: "auto"
|
|
523
|
-
},
|
|
524
|
-
|
|
525
|
-
|
|
507
|
+
},
|
|
508
|
+
children: errorDescription
|
|
509
|
+
})
|
|
510
|
+
});
|
|
526
511
|
}
|
|
527
512
|
return children;
|
|
528
513
|
}
|
|
529
514
|
};
|
|
530
515
|
|
|
531
516
|
// src/Form.tsx
|
|
517
|
+
import { faas } from "@faasjs/react";
|
|
532
518
|
import {
|
|
533
519
|
Button as Button2,
|
|
534
520
|
Form as AntdForm2
|
|
535
521
|
} from "antd";
|
|
536
522
|
import {
|
|
537
|
-
useEffect as
|
|
538
|
-
useState as
|
|
523
|
+
useEffect as useEffect5,
|
|
524
|
+
useState as useState6,
|
|
539
525
|
useCallback,
|
|
540
526
|
isValidElement
|
|
541
527
|
} from "react";
|
|
@@ -555,9 +541,9 @@ import {
|
|
|
555
541
|
} from "antd";
|
|
556
542
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
557
543
|
import {
|
|
558
|
-
cloneElement as
|
|
559
|
-
useEffect as
|
|
560
|
-
useState as
|
|
544
|
+
cloneElement as cloneElement2,
|
|
545
|
+
useEffect as useEffect4,
|
|
546
|
+
useState as useState5
|
|
561
547
|
} from "react";
|
|
562
548
|
import { upperFirst as upperFirst3 } from "lodash-es";
|
|
563
549
|
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -609,12 +595,12 @@ function processProps(propsCopy, config) {
|
|
|
609
595
|
}
|
|
610
596
|
function FormItem(props) {
|
|
611
597
|
var _a;
|
|
612
|
-
const [computedProps, setComputedProps] =
|
|
613
|
-
const [extendTypes, setExtendTypes] =
|
|
598
|
+
const [computedProps, setComputedProps] = useState5();
|
|
599
|
+
const [extendTypes, setExtendTypes] = useState5();
|
|
614
600
|
const { common: common2 } = useConfigContext();
|
|
615
|
-
const [hidden, setHidden] =
|
|
616
|
-
|
|
617
|
-
const propsCopy =
|
|
601
|
+
const [hidden, setHidden] = useState5(props.hidden || false);
|
|
602
|
+
useEffect4(() => {
|
|
603
|
+
const propsCopy = { ...props };
|
|
618
604
|
if (propsCopy.extendTypes) {
|
|
619
605
|
setExtendTypes(propsCopy.extendTypes);
|
|
620
606
|
delete propsCopy.extendTypes;
|
|
@@ -637,231 +623,290 @@ function FormItem(props) {
|
|
|
637
623
|
if (!computedProps)
|
|
638
624
|
return null;
|
|
639
625
|
if (hidden)
|
|
640
|
-
return /* @__PURE__ */ jsx10(
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
626
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
627
|
+
...computedProps,
|
|
628
|
+
noStyle: true,
|
|
629
|
+
rules: [],
|
|
630
|
+
children: /* @__PURE__ */ jsx10(Input, {
|
|
631
|
+
hidden: true
|
|
646
632
|
})
|
|
647
|
-
);
|
|
633
|
+
});
|
|
648
634
|
if (extendTypes && extendTypes[computedProps.type])
|
|
649
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
635
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
636
|
+
...computedProps,
|
|
637
|
+
children: extendTypes[computedProps.type].children
|
|
638
|
+
});
|
|
650
639
|
if (computedProps.formChildren === null)
|
|
651
640
|
return null;
|
|
652
641
|
if (computedProps.formChildren)
|
|
653
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
642
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
643
|
+
...computedProps,
|
|
644
|
+
children: cloneElement2(computedProps.formChildren, { scene: "form" })
|
|
645
|
+
});
|
|
654
646
|
if (computedProps.children === null)
|
|
655
647
|
return null;
|
|
656
648
|
if (computedProps.children)
|
|
657
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
649
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
650
|
+
...computedProps,
|
|
651
|
+
children: cloneElement2(computedProps.children, { scene: "form" })
|
|
652
|
+
});
|
|
658
653
|
if (computedProps.formRender)
|
|
659
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
654
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
655
|
+
...computedProps,
|
|
656
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
657
|
+
});
|
|
660
658
|
if (computedProps.render)
|
|
661
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
659
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
660
|
+
...computedProps,
|
|
661
|
+
children: computedProps.render(null, null, 0, "form")
|
|
662
|
+
});
|
|
662
663
|
switch (computedProps.type) {
|
|
663
664
|
case "string":
|
|
664
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
665
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
666
|
+
...computedProps,
|
|
667
|
+
children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
|
|
668
|
+
...computedProps.input
|
|
669
|
+
}) : /* @__PURE__ */ jsx10(Input, {
|
|
670
|
+
...computedProps.input
|
|
671
|
+
})
|
|
672
|
+
});
|
|
665
673
|
case "string[]":
|
|
666
674
|
if (computedProps.options)
|
|
667
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
mode: "multiple"
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
675
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
676
|
+
...computedProps,
|
|
677
|
+
children: /* @__PURE__ */ jsx10(Select, {
|
|
678
|
+
mode: "multiple",
|
|
679
|
+
...computedProps.input
|
|
680
|
+
})
|
|
681
|
+
});
|
|
682
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
683
|
+
name: computedProps.name,
|
|
684
|
+
rules: computedProps.rules,
|
|
685
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
686
|
+
var _a2;
|
|
687
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
688
|
+
children: [
|
|
689
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
690
|
+
className: "ant-form-item-label",
|
|
691
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
692
|
+
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
|
|
693
|
+
children: computedProps.label
|
|
694
|
+
})
|
|
695
|
+
}),
|
|
682
696
|
fields.map((field) => {
|
|
683
697
|
var _a3;
|
|
684
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
685
|
-
Row,
|
|
686
|
-
{
|
|
698
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
699
|
+
children: /* @__PURE__ */ jsxs2(Row, {
|
|
687
700
|
gutter: 24,
|
|
688
701
|
style: { flexFlow: "row nowrap" },
|
|
689
702
|
children: [
|
|
690
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
691
|
-
|
|
692
|
-
|
|
703
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
704
|
+
span: 23,
|
|
705
|
+
children: /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
706
|
+
...field,
|
|
693
707
|
noStyle: true,
|
|
694
|
-
children: /* @__PURE__ */ jsx10(Input,
|
|
708
|
+
children: /* @__PURE__ */ jsx10(Input, {
|
|
709
|
+
...computedProps.input
|
|
710
|
+
})
|
|
695
711
|
})
|
|
696
|
-
|
|
697
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
698
|
-
|
|
699
|
-
{
|
|
712
|
+
}),
|
|
713
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
714
|
+
span: 1,
|
|
715
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
700
716
|
danger: true,
|
|
701
717
|
type: "link",
|
|
702
718
|
style: { float: "right" },
|
|
703
719
|
icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
|
|
704
720
|
onClick: () => remove(field.name)
|
|
705
|
-
}
|
|
706
|
-
|
|
721
|
+
})
|
|
722
|
+
})
|
|
707
723
|
]
|
|
708
|
-
}
|
|
709
|
-
|
|
724
|
+
})
|
|
725
|
+
}, field.key);
|
|
710
726
|
}),
|
|
711
|
-
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
712
|
-
|
|
713
|
-
Button,
|
|
714
|
-
{
|
|
727
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
728
|
+
children: [
|
|
729
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
|
|
715
730
|
type: "dashed",
|
|
716
731
|
block: true,
|
|
717
732
|
onClick: () => add(),
|
|
718
733
|
icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
734
|
+
}),
|
|
735
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
736
|
+
className: "ant-form-item-extra",
|
|
737
|
+
children: computedProps.extra
|
|
738
|
+
}),
|
|
739
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
740
|
+
errors
|
|
741
|
+
})
|
|
742
|
+
]
|
|
743
|
+
})
|
|
744
|
+
]
|
|
745
|
+
});
|
|
726
746
|
}
|
|
727
|
-
);
|
|
747
|
+
});
|
|
728
748
|
case "number":
|
|
729
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
},
|
|
734
|
-
|
|
749
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
750
|
+
...computedProps,
|
|
751
|
+
children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
|
|
752
|
+
...computedProps.input
|
|
753
|
+
}) : /* @__PURE__ */ jsx10(InputNumber, {
|
|
754
|
+
style: { width: "100%" },
|
|
755
|
+
...computedProps.input
|
|
756
|
+
})
|
|
757
|
+
});
|
|
735
758
|
case "number[]":
|
|
736
759
|
if (computedProps.options)
|
|
737
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
mode: "multiple"
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
760
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
761
|
+
...computedProps,
|
|
762
|
+
children: /* @__PURE__ */ jsx10(Select, {
|
|
763
|
+
mode: "multiple",
|
|
764
|
+
...computedProps.input
|
|
765
|
+
})
|
|
766
|
+
});
|
|
767
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
768
|
+
name: computedProps.name,
|
|
769
|
+
rules: computedProps.rules,
|
|
770
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
771
|
+
var _a2, _b;
|
|
772
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
773
|
+
children: [
|
|
774
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
775
|
+
className: "ant-form-item-label",
|
|
776
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
777
|
+
className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
|
|
778
|
+
children: computedProps.label
|
|
779
|
+
})
|
|
780
|
+
}),
|
|
752
781
|
fields.map((field) => {
|
|
753
782
|
var _a3;
|
|
754
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
755
|
-
Row,
|
|
756
|
-
{
|
|
783
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
784
|
+
children: /* @__PURE__ */ jsxs2(Row, {
|
|
757
785
|
gutter: 24,
|
|
758
786
|
style: { flexFlow: "row nowrap" },
|
|
759
787
|
children: [
|
|
760
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
761
|
-
|
|
762
|
-
|
|
788
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
789
|
+
span: 23,
|
|
790
|
+
children: /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
791
|
+
...field,
|
|
763
792
|
noStyle: true,
|
|
764
|
-
children: /* @__PURE__ */ jsx10(
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}, computedProps.input)
|
|
769
|
-
)
|
|
793
|
+
children: /* @__PURE__ */ jsx10(InputNumber, {
|
|
794
|
+
style: { width: "100%" },
|
|
795
|
+
...computedProps.input
|
|
796
|
+
})
|
|
770
797
|
})
|
|
771
|
-
|
|
772
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
773
|
-
|
|
774
|
-
{
|
|
798
|
+
}),
|
|
799
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
800
|
+
span: 1,
|
|
801
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
775
802
|
danger: true,
|
|
776
803
|
type: "link",
|
|
777
804
|
style: { float: "right" },
|
|
778
805
|
icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
|
|
779
806
|
onClick: () => remove(field.name)
|
|
780
|
-
}
|
|
781
|
-
|
|
807
|
+
})
|
|
808
|
+
})
|
|
782
809
|
]
|
|
783
|
-
}
|
|
784
|
-
|
|
810
|
+
})
|
|
811
|
+
}, field.key);
|
|
785
812
|
}),
|
|
786
|
-
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
787
|
-
|
|
788
|
-
Button,
|
|
789
|
-
{
|
|
813
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
814
|
+
children: [
|
|
815
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
|
|
790
816
|
type: "dashed",
|
|
791
817
|
block: true,
|
|
792
818
|
onClick: () => add(),
|
|
793
819
|
icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
820
|
+
}),
|
|
821
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
822
|
+
className: "ant-form-item-extra",
|
|
823
|
+
children: computedProps.extra
|
|
824
|
+
}),
|
|
825
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
826
|
+
errors
|
|
827
|
+
})
|
|
828
|
+
]
|
|
829
|
+
})
|
|
830
|
+
]
|
|
831
|
+
});
|
|
801
832
|
}
|
|
802
|
-
);
|
|
833
|
+
});
|
|
803
834
|
case "boolean":
|
|
804
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
835
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
836
|
+
...computedProps,
|
|
837
|
+
children: /* @__PURE__ */ jsx10(Switch, {
|
|
838
|
+
...computedProps.input
|
|
839
|
+
})
|
|
840
|
+
});
|
|
805
841
|
case "date":
|
|
806
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
842
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
843
|
+
...computedProps,
|
|
844
|
+
children: /* @__PURE__ */ jsx10(DatePicker, {
|
|
845
|
+
...computedProps.input
|
|
846
|
+
})
|
|
847
|
+
});
|
|
807
848
|
case "time":
|
|
808
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
849
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
850
|
+
...computedProps,
|
|
851
|
+
children: /* @__PURE__ */ jsx10(TimePicker, {
|
|
852
|
+
...computedProps.input
|
|
853
|
+
})
|
|
854
|
+
});
|
|
809
855
|
case "object":
|
|
810
|
-
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
856
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
857
|
+
children: [
|
|
858
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
859
|
+
className: "ant-form-item-label",
|
|
860
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
861
|
+
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
|
|
862
|
+
children: computedProps.label
|
|
863
|
+
})
|
|
864
|
+
}),
|
|
865
|
+
computedProps.object.map((o) => /* @__PURE__ */ jsx10(FormItem, {
|
|
866
|
+
...o
|
|
867
|
+
}, o.id))
|
|
868
|
+
]
|
|
869
|
+
});
|
|
818
870
|
case "object[]":
|
|
819
|
-
return /* @__PURE__ */ jsx10(
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
Button,
|
|
836
|
-
{
|
|
871
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
872
|
+
name: computedProps.name,
|
|
873
|
+
rules: computedProps.rules,
|
|
874
|
+
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs2(Fragment4, {
|
|
875
|
+
children: [
|
|
876
|
+
fields.map((field) => /* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
877
|
+
style: { marginBottom: 0 },
|
|
878
|
+
children: [
|
|
879
|
+
/* @__PURE__ */ jsx10("div", {
|
|
880
|
+
className: "ant-form-item-label",
|
|
881
|
+
children: /* @__PURE__ */ jsxs2("label", {
|
|
882
|
+
children: [
|
|
883
|
+
computedProps.label,
|
|
884
|
+
" ",
|
|
885
|
+
field.name + 1,
|
|
886
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
837
887
|
danger: true,
|
|
838
888
|
type: "link",
|
|
839
889
|
onClick: () => remove(field.name),
|
|
840
890
|
children: common2.delete
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
)),
|
|
861
|
-
/* @__PURE__ */ jsxs2(AntdForm.Item, { children: [
|
|
862
|
-
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs2(
|
|
863
|
-
Button,
|
|
864
|
-
{
|
|
891
|
+
})
|
|
892
|
+
]
|
|
893
|
+
})
|
|
894
|
+
}),
|
|
895
|
+
/* @__PURE__ */ jsx10(Row, {
|
|
896
|
+
gutter: 24,
|
|
897
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ jsx10(Col, {
|
|
898
|
+
span: o.col || 24,
|
|
899
|
+
children: /* @__PURE__ */ jsx10(FormItem, {
|
|
900
|
+
...o,
|
|
901
|
+
name: [field.name, o.id]
|
|
902
|
+
})
|
|
903
|
+
}, o.id))
|
|
904
|
+
})
|
|
905
|
+
]
|
|
906
|
+
}, field.key)),
|
|
907
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
908
|
+
children: [
|
|
909
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs2(Button, {
|
|
865
910
|
type: "dashed",
|
|
866
911
|
block: true,
|
|
867
912
|
onClick: () => add(),
|
|
@@ -871,14 +916,19 @@ function FormItem(props) {
|
|
|
871
916
|
" ",
|
|
872
917
|
computedProps.label
|
|
873
918
|
]
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
919
|
+
}),
|
|
920
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
921
|
+
className: "ant-form-item-extra",
|
|
922
|
+
children: computedProps.extra
|
|
923
|
+
}),
|
|
924
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
925
|
+
errors
|
|
926
|
+
})
|
|
927
|
+
]
|
|
928
|
+
})
|
|
929
|
+
]
|
|
930
|
+
})
|
|
931
|
+
});
|
|
882
932
|
default:
|
|
883
933
|
return null;
|
|
884
934
|
}
|
|
@@ -889,17 +939,18 @@ FormItem.useStatus = AntdForm.Item.useStatus;
|
|
|
889
939
|
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
890
940
|
function Form(props) {
|
|
891
941
|
var _a, _b;
|
|
892
|
-
const [loading, setLoading] =
|
|
893
|
-
const [computedProps, setComputedProps] =
|
|
942
|
+
const [loading, setLoading] = useState6(false);
|
|
943
|
+
const [computedProps, setComputedProps] = useState6();
|
|
894
944
|
const config = useConfigContext();
|
|
895
|
-
const [extendTypes, setExtendTypes] =
|
|
945
|
+
const [extendTypes, setExtendTypes] = useState6();
|
|
896
946
|
const [form] = AntdForm2.useForm(props.form);
|
|
897
|
-
const [initialValues, setInitialValues] =
|
|
898
|
-
|
|
947
|
+
const [initialValues, setInitialValues] = useState6(props.initialValues);
|
|
948
|
+
useEffect5(() => {
|
|
899
949
|
var _a2, _b2, _c;
|
|
900
|
-
const propsCopy =
|
|
950
|
+
const propsCopy = {
|
|
951
|
+
...props,
|
|
901
952
|
form
|
|
902
|
-
}
|
|
953
|
+
};
|
|
903
954
|
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
904
955
|
for (const key in propsCopy.initialValues) {
|
|
905
956
|
propsCopy.initialValues[key] = transferValue(
|
|
@@ -923,7 +974,10 @@ function Form(props) {
|
|
|
923
974
|
setLoading(true);
|
|
924
975
|
try {
|
|
925
976
|
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
926
|
-
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
977
|
+
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
978
|
+
...values2,
|
|
979
|
+
...propsCopy.submit.to.params
|
|
980
|
+
} : values2));
|
|
927
981
|
} else
|
|
928
982
|
await props.onFinish(values);
|
|
929
983
|
} catch (error) {
|
|
@@ -934,7 +988,10 @@ function Form(props) {
|
|
|
934
988
|
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
935
989
|
propsCopy.onFinish = async (values) => {
|
|
936
990
|
setLoading(true);
|
|
937
|
-
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
991
|
+
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
992
|
+
...values,
|
|
993
|
+
...propsCopy.submit.to.params
|
|
994
|
+
} : values).then((result) => {
|
|
938
995
|
if (propsCopy.submit.to.then)
|
|
939
996
|
propsCopy.submit.to.then(result);
|
|
940
997
|
return result;
|
|
@@ -968,7 +1025,7 @@ function Form(props) {
|
|
|
968
1025
|
item.onValueChange(changedValues[key], allValues, form);
|
|
969
1026
|
}
|
|
970
1027
|
}, [computedProps]);
|
|
971
|
-
|
|
1028
|
+
useEffect5(() => {
|
|
972
1029
|
if (!initialValues)
|
|
973
1030
|
return;
|
|
974
1031
|
console.debug("Form:initialValues", initialValues);
|
|
@@ -977,33 +1034,25 @@ function Form(props) {
|
|
|
977
1034
|
}, [computedProps]);
|
|
978
1035
|
if (!computedProps)
|
|
979
1036
|
return null;
|
|
980
|
-
return /* @__PURE__ */ jsxs3(
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
computedProps.submit
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
loading,
|
|
1000
|
-
children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
|
|
1001
|
-
}
|
|
1002
|
-
),
|
|
1003
|
-
computedProps.footer
|
|
1004
|
-
]
|
|
1005
|
-
})
|
|
1006
|
-
);
|
|
1037
|
+
return /* @__PURE__ */ jsxs3(AntdForm2, {
|
|
1038
|
+
...computedProps,
|
|
1039
|
+
onValuesChange,
|
|
1040
|
+
children: [
|
|
1041
|
+
computedProps.beforeItems,
|
|
1042
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx11(FormItem, {
|
|
1043
|
+
...item,
|
|
1044
|
+
extendTypes
|
|
1045
|
+
}, item.id)),
|
|
1046
|
+
computedProps.children,
|
|
1047
|
+
computedProps.submit !== false && /* @__PURE__ */ jsx11(Button2, {
|
|
1048
|
+
htmlType: "submit",
|
|
1049
|
+
type: "primary",
|
|
1050
|
+
loading,
|
|
1051
|
+
children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
|
|
1052
|
+
}),
|
|
1053
|
+
computedProps.footer
|
|
1054
|
+
]
|
|
1055
|
+
});
|
|
1007
1056
|
}
|
|
1008
1057
|
Form.useForm = AntdForm2.useForm;
|
|
1009
1058
|
Form.useFormInstance = AntdForm2.useFormInstance;
|
|
@@ -1020,9 +1069,11 @@ import { jsx as jsx12 } from "react/jsx-runtime";
|
|
|
1020
1069
|
function Link(props) {
|
|
1021
1070
|
var _a, _b, _c, _d;
|
|
1022
1071
|
const { Link: Link2 } = useConfigContext();
|
|
1023
|
-
let style =
|
|
1024
|
-
|
|
1025
|
-
|
|
1072
|
+
let style = {
|
|
1073
|
+
...Link2.style || {},
|
|
1074
|
+
cursor: "pointer",
|
|
1075
|
+
...props.style
|
|
1076
|
+
};
|
|
1026
1077
|
if (props.block)
|
|
1027
1078
|
style = Object.assign({
|
|
1028
1079
|
display: "block",
|
|
@@ -1030,49 +1081,36 @@ function Link(props) {
|
|
|
1030
1081
|
}, style);
|
|
1031
1082
|
if (props.href.startsWith("http")) {
|
|
1032
1083
|
if (props.button)
|
|
1033
|
-
return /* @__PURE__ */ jsx12(
|
|
1034
|
-
|
|
1035
|
-
__spreadProps(__spreadValues({}, props.button), {
|
|
1036
|
-
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1037
|
-
style,
|
|
1038
|
-
href: props.href,
|
|
1039
|
-
children: (_a = props.text) != null ? _a : props.children
|
|
1040
|
-
})
|
|
1041
|
-
);
|
|
1042
|
-
return /* @__PURE__ */ jsx12(
|
|
1043
|
-
"a",
|
|
1044
|
-
{
|
|
1045
|
-
href: props.href,
|
|
1084
|
+
return /* @__PURE__ */ jsx12(Button3, {
|
|
1085
|
+
...props.button,
|
|
1046
1086
|
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1047
1087
|
style,
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1088
|
+
href: props.href,
|
|
1089
|
+
children: (_a = props.text) != null ? _a : props.children
|
|
1090
|
+
});
|
|
1091
|
+
return /* @__PURE__ */ jsx12("a", {
|
|
1092
|
+
href: props.href,
|
|
1093
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1094
|
+
style,
|
|
1095
|
+
children: (_b = props.text) != null ? _b : props.children
|
|
1096
|
+
});
|
|
1051
1097
|
}
|
|
1052
1098
|
if (props.button)
|
|
1053
|
-
return /* @__PURE__ */ jsx12(
|
|
1054
|
-
RouterLink,
|
|
1055
|
-
{
|
|
1056
|
-
to: props.href,
|
|
1057
|
-
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1058
|
-
children: /* @__PURE__ */ jsx12(
|
|
1059
|
-
Button3,
|
|
1060
|
-
__spreadProps(__spreadValues({}, props.button), {
|
|
1061
|
-
style,
|
|
1062
|
-
children: (_c = props.text) != null ? _c : props.children
|
|
1063
|
-
})
|
|
1064
|
-
)
|
|
1065
|
-
}
|
|
1066
|
-
);
|
|
1067
|
-
return /* @__PURE__ */ jsx12(
|
|
1068
|
-
RouterLink,
|
|
1069
|
-
{
|
|
1099
|
+
return /* @__PURE__ */ jsx12(RouterLink, {
|
|
1070
1100
|
to: props.href,
|
|
1071
1101
|
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1102
|
+
children: /* @__PURE__ */ jsx12(Button3, {
|
|
1103
|
+
...props.button,
|
|
1104
|
+
style,
|
|
1105
|
+
children: (_c = props.text) != null ? _c : props.children
|
|
1106
|
+
})
|
|
1107
|
+
});
|
|
1108
|
+
return /* @__PURE__ */ jsx12(RouterLink, {
|
|
1109
|
+
to: props.href,
|
|
1110
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1111
|
+
style,
|
|
1112
|
+
children: (_d = props.text) != null ? _d : props.children
|
|
1113
|
+
});
|
|
1076
1114
|
}
|
|
1077
1115
|
|
|
1078
1116
|
// src/Routers.tsx
|
|
@@ -1088,39 +1126,39 @@ import { lazy } from "react";
|
|
|
1088
1126
|
import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1089
1127
|
function PageNotFound() {
|
|
1090
1128
|
const config = useConfigContext();
|
|
1091
|
-
return /* @__PURE__ */ jsx13(
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
title: config.common.pageNotFound
|
|
1096
|
-
}
|
|
1097
|
-
);
|
|
1129
|
+
return /* @__PURE__ */ jsx13(Result, {
|
|
1130
|
+
status: "404",
|
|
1131
|
+
title: config.common.pageNotFound
|
|
1132
|
+
});
|
|
1098
1133
|
}
|
|
1099
1134
|
function Routes(props) {
|
|
1100
|
-
return /* @__PURE__ */ jsxs4(OriginRoutes, {
|
|
1101
|
-
|
|
1102
|
-
Route,
|
|
1103
|
-
|
|
1104
|
-
element: r.element || /* @__PURE__ */ jsx13(Suspense, {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1135
|
+
return /* @__PURE__ */ jsxs4(OriginRoutes, {
|
|
1136
|
+
children: [
|
|
1137
|
+
props.routes.map((r) => /* @__PURE__ */ jsx13(Route, {
|
|
1138
|
+
...r,
|
|
1139
|
+
element: r.element || /* @__PURE__ */ jsx13(Suspense, {
|
|
1140
|
+
fallback: props.fallback || /* @__PURE__ */ jsx13("div", {
|
|
1141
|
+
style: { padding: "24px" },
|
|
1142
|
+
children: /* @__PURE__ */ jsx13(Skeleton, {
|
|
1143
|
+
active: true
|
|
1144
|
+
})
|
|
1145
|
+
}),
|
|
1146
|
+
children: /* @__PURE__ */ jsx13(r.page, {})
|
|
1147
|
+
})
|
|
1148
|
+
}, r.path)),
|
|
1149
|
+
/* @__PURE__ */ jsx13(Route, {
|
|
1111
1150
|
path: "*",
|
|
1112
1151
|
element: props.notFound || /* @__PURE__ */ jsx13(PageNotFound, {})
|
|
1113
|
-
},
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
] });
|
|
1152
|
+
}, "*")
|
|
1153
|
+
]
|
|
1154
|
+
});
|
|
1117
1155
|
}
|
|
1118
1156
|
|
|
1119
1157
|
// src/Table.tsx
|
|
1120
1158
|
import {
|
|
1121
|
-
useState as
|
|
1122
|
-
useEffect as
|
|
1123
|
-
cloneElement as
|
|
1159
|
+
useState as useState7,
|
|
1160
|
+
useEffect as useEffect6,
|
|
1161
|
+
cloneElement as cloneElement3
|
|
1124
1162
|
} from "react";
|
|
1125
1163
|
import {
|
|
1126
1164
|
Table as AntdTable,
|
|
@@ -1162,9 +1200,9 @@ function processValue(item, value) {
|
|
|
1162
1200
|
return value;
|
|
1163
1201
|
}
|
|
1164
1202
|
function Table(props) {
|
|
1165
|
-
const [columns, setColumns] =
|
|
1203
|
+
const [columns, setColumns] = useState7();
|
|
1166
1204
|
const { common: common2 } = useConfigContext();
|
|
1167
|
-
|
|
1205
|
+
useEffect6(() => {
|
|
1168
1206
|
var _a;
|
|
1169
1207
|
for (const item of props.items) {
|
|
1170
1208
|
if (!item.key)
|
|
@@ -1188,7 +1226,7 @@ function Table(props) {
|
|
|
1188
1226
|
if (item.tableChildren === null)
|
|
1189
1227
|
item.render = () => null;
|
|
1190
1228
|
else if (item.tableChildren)
|
|
1191
|
-
item.render = (value, values) =>
|
|
1229
|
+
item.render = (value, values) => cloneElement3(
|
|
1192
1230
|
item.tableChildren,
|
|
1193
1231
|
{
|
|
1194
1232
|
scene: "table",
|
|
@@ -1199,7 +1237,7 @@ function Table(props) {
|
|
|
1199
1237
|
else if (item.children === null)
|
|
1200
1238
|
item.render = () => null;
|
|
1201
1239
|
else if (item.children)
|
|
1202
|
-
item.render = (value, values) =>
|
|
1240
|
+
item.render = (value, values) => cloneElement3(
|
|
1203
1241
|
item.children,
|
|
1204
1242
|
{
|
|
1205
1243
|
scene: "table",
|
|
@@ -1209,7 +1247,7 @@ function Table(props) {
|
|
|
1209
1247
|
);
|
|
1210
1248
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1211
1249
|
if (props.extendTypes[item.type].children)
|
|
1212
|
-
item.render = (value, values) =>
|
|
1250
|
+
item.render = (value, values) => cloneElement3(
|
|
1213
1251
|
props.extendTypes[item.type].children,
|
|
1214
1252
|
{
|
|
1215
1253
|
scene: "table",
|
|
@@ -1242,22 +1280,19 @@ function Table(props) {
|
|
|
1242
1280
|
setSelectedKeys,
|
|
1243
1281
|
confirm,
|
|
1244
1282
|
clearFilters
|
|
1245
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
setSelectedKeys([]);
|
|
1255
|
-
clearFilters();
|
|
1256
|
-
}
|
|
1257
|
-
confirm();
|
|
1283
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1284
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1285
|
+
allowClear: true,
|
|
1286
|
+
onSearch: (v) => {
|
|
1287
|
+
if (v) {
|
|
1288
|
+
setSelectedKeys([v]);
|
|
1289
|
+
} else {
|
|
1290
|
+
setSelectedKeys([]);
|
|
1291
|
+
clearFilters();
|
|
1258
1292
|
}
|
|
1293
|
+
confirm();
|
|
1259
1294
|
}
|
|
1260
|
-
);
|
|
1295
|
+
});
|
|
1261
1296
|
break;
|
|
1262
1297
|
case "string[]":
|
|
1263
1298
|
if (!item.render)
|
|
@@ -1277,22 +1312,19 @@ function Table(props) {
|
|
|
1277
1312
|
setSelectedKeys,
|
|
1278
1313
|
confirm,
|
|
1279
1314
|
clearFilters
|
|
1280
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
setSelectedKeys([]);
|
|
1290
|
-
clearFilters();
|
|
1291
|
-
}
|
|
1292
|
-
confirm();
|
|
1315
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1316
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1317
|
+
allowClear: true,
|
|
1318
|
+
onSearch: (v) => {
|
|
1319
|
+
if (v) {
|
|
1320
|
+
setSelectedKeys([v]);
|
|
1321
|
+
} else {
|
|
1322
|
+
setSelectedKeys([]);
|
|
1323
|
+
clearFilters();
|
|
1293
1324
|
}
|
|
1325
|
+
confirm();
|
|
1294
1326
|
}
|
|
1295
|
-
);
|
|
1327
|
+
});
|
|
1296
1328
|
break;
|
|
1297
1329
|
case "number":
|
|
1298
1330
|
if (!item.render)
|
|
@@ -1314,22 +1346,19 @@ function Table(props) {
|
|
|
1314
1346
|
setSelectedKeys,
|
|
1315
1347
|
confirm,
|
|
1316
1348
|
clearFilters
|
|
1317
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
setSelectedKeys([]);
|
|
1327
|
-
clearFilters();
|
|
1328
|
-
}
|
|
1329
|
-
confirm();
|
|
1349
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1350
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1351
|
+
allowClear: true,
|
|
1352
|
+
onSearch: (v) => {
|
|
1353
|
+
if (v) {
|
|
1354
|
+
setSelectedKeys([Number(v)]);
|
|
1355
|
+
} else {
|
|
1356
|
+
setSelectedKeys([]);
|
|
1357
|
+
clearFilters();
|
|
1330
1358
|
}
|
|
1359
|
+
confirm();
|
|
1331
1360
|
}
|
|
1332
|
-
);
|
|
1361
|
+
});
|
|
1333
1362
|
break;
|
|
1334
1363
|
case "number[]":
|
|
1335
1364
|
if (!item.render)
|
|
@@ -1349,66 +1378,79 @@ function Table(props) {
|
|
|
1349
1378
|
setSelectedKeys,
|
|
1350
1379
|
confirm,
|
|
1351
1380
|
clearFilters
|
|
1352
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
setSelectedKeys([]);
|
|
1362
|
-
clearFilters();
|
|
1363
|
-
}
|
|
1364
|
-
confirm();
|
|
1381
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1382
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1383
|
+
allowClear: true,
|
|
1384
|
+
onSearch: (v) => {
|
|
1385
|
+
if (v) {
|
|
1386
|
+
setSelectedKeys([Number(v)]);
|
|
1387
|
+
} else {
|
|
1388
|
+
setSelectedKeys([]);
|
|
1389
|
+
clearFilters();
|
|
1365
1390
|
}
|
|
1391
|
+
confirm();
|
|
1366
1392
|
}
|
|
1367
|
-
);
|
|
1393
|
+
});
|
|
1368
1394
|
break;
|
|
1369
1395
|
case "boolean":
|
|
1370
1396
|
if (!item.render)
|
|
1371
|
-
item.render = (value) => isNil2(value) ? /* @__PURE__ */ jsx14(Blank, {}) : value ? /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1397
|
+
item.render = (value) => isNil2(value) ? /* @__PURE__ */ jsx14(Blank, {}) : value ? /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1398
|
+
style: {
|
|
1399
|
+
marginTop: "4px",
|
|
1400
|
+
color: "#52c41a"
|
|
1401
|
+
}
|
|
1402
|
+
}) : /* @__PURE__ */ jsx14(CloseOutlined2, {
|
|
1403
|
+
style: {
|
|
1404
|
+
marginTop: "4px",
|
|
1405
|
+
color: "#ff4d4f"
|
|
1406
|
+
}
|
|
1407
|
+
});
|
|
1378
1408
|
if (item.filterDropdown !== false)
|
|
1379
1409
|
item.filterDropdown = ({
|
|
1380
1410
|
setSelectedKeys,
|
|
1381
1411
|
selectedKeys,
|
|
1382
1412
|
confirm
|
|
1383
|
-
}) => /* @__PURE__ */ jsxs5(
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1413
|
+
}) => /* @__PURE__ */ jsxs5(Radio.Group, {
|
|
1414
|
+
style: { padding: 8 },
|
|
1415
|
+
buttonStyle: "solid",
|
|
1416
|
+
value: JSON.stringify(selectedKeys[0]),
|
|
1417
|
+
onChange: (e) => {
|
|
1418
|
+
const Values = {
|
|
1419
|
+
true: true,
|
|
1420
|
+
false: false,
|
|
1421
|
+
null: null
|
|
1422
|
+
};
|
|
1423
|
+
setSelectedKeys(e.target.value ? [Values[e.target.value]] : []);
|
|
1424
|
+
confirm();
|
|
1425
|
+
},
|
|
1426
|
+
children: [
|
|
1427
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1428
|
+
children: common2.all
|
|
1429
|
+
}),
|
|
1430
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1431
|
+
value: "true",
|
|
1432
|
+
children: /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1433
|
+
style: {
|
|
1434
|
+
color: "#52c41a",
|
|
1435
|
+
verticalAlign: "middle"
|
|
1436
|
+
}
|
|
1437
|
+
})
|
|
1438
|
+
}),
|
|
1439
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1440
|
+
value: "false",
|
|
1441
|
+
children: /* @__PURE__ */ jsx14(CloseOutlined2, {
|
|
1442
|
+
style: {
|
|
1443
|
+
verticalAlign: "middle",
|
|
1444
|
+
color: "#ff4d4f"
|
|
1445
|
+
}
|
|
1446
|
+
})
|
|
1447
|
+
}),
|
|
1448
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1449
|
+
value: "null",
|
|
1450
|
+
children: common2.blank
|
|
1451
|
+
})
|
|
1452
|
+
]
|
|
1453
|
+
});
|
|
1412
1454
|
if (!item.onFilter)
|
|
1413
1455
|
item.onFilter = (value, row) => {
|
|
1414
1456
|
switch (value) {
|
|
@@ -1436,15 +1478,12 @@ function Table(props) {
|
|
|
1436
1478
|
item.filterDropdown = ({
|
|
1437
1479
|
setSelectedKeys,
|
|
1438
1480
|
confirm
|
|
1439
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1444
|
-
confirm();
|
|
1445
|
-
}
|
|
1481
|
+
}) => /* @__PURE__ */ jsx14(DatePicker2.RangePicker, {
|
|
1482
|
+
onChange: (dates) => {
|
|
1483
|
+
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1484
|
+
confirm();
|
|
1446
1485
|
}
|
|
1447
|
-
);
|
|
1486
|
+
});
|
|
1448
1487
|
if (!item.onFilter)
|
|
1449
1488
|
item.onFilter = (value, row) => {
|
|
1450
1489
|
if (isNil2(value[0]))
|
|
@@ -1469,15 +1508,12 @@ function Table(props) {
|
|
|
1469
1508
|
item.filterDropdown = ({
|
|
1470
1509
|
setSelectedKeys,
|
|
1471
1510
|
confirm
|
|
1472
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1477
|
-
confirm();
|
|
1478
|
-
}
|
|
1511
|
+
}) => /* @__PURE__ */ jsx14(DatePicker2.RangePicker, {
|
|
1512
|
+
onChange: (dates) => {
|
|
1513
|
+
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1514
|
+
confirm();
|
|
1479
1515
|
}
|
|
1480
|
-
);
|
|
1516
|
+
});
|
|
1481
1517
|
if (!item.onFilter)
|
|
1482
1518
|
item.onFilter = (value, row) => {
|
|
1483
1519
|
if (isNil2(value[0]))
|
|
@@ -1489,26 +1525,21 @@ function Table(props) {
|
|
|
1489
1525
|
break;
|
|
1490
1526
|
case "object":
|
|
1491
1527
|
if (!item.render)
|
|
1492
|
-
item.render = (value) => /* @__PURE__ */ jsx14(
|
|
1493
|
-
|
|
1494
|
-
{
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
column: 1
|
|
1498
|
-
}
|
|
1499
|
-
);
|
|
1528
|
+
item.render = (value) => /* @__PURE__ */ jsx14(Description, {
|
|
1529
|
+
items: item.object,
|
|
1530
|
+
dataSource: value || {},
|
|
1531
|
+
column: 1
|
|
1532
|
+
});
|
|
1500
1533
|
break;
|
|
1501
1534
|
case "object[]":
|
|
1502
1535
|
if (!item.render)
|
|
1503
|
-
item.render = (value) => /* @__PURE__ */ jsx14(Fragment5, {
|
|
1504
|
-
Description,
|
|
1505
|
-
{
|
|
1536
|
+
item.render = (value) => /* @__PURE__ */ jsx14(Fragment5, {
|
|
1537
|
+
children: value.map((v, i) => /* @__PURE__ */ jsx14(Description, {
|
|
1506
1538
|
items: item.object,
|
|
1507
1539
|
dataSource: v || [],
|
|
1508
1540
|
column: 1
|
|
1509
|
-
},
|
|
1510
|
-
|
|
1511
|
-
)) });
|
|
1541
|
+
}, i))
|
|
1542
|
+
});
|
|
1512
1543
|
break;
|
|
1513
1544
|
default:
|
|
1514
1545
|
if (!item.render)
|
|
@@ -1524,7 +1555,7 @@ function Table(props) {
|
|
|
1524
1555
|
}
|
|
1525
1556
|
setColumns(props.items);
|
|
1526
1557
|
}, [props.items]);
|
|
1527
|
-
|
|
1558
|
+
useEffect6(() => {
|
|
1528
1559
|
if (!props.dataSource || !columns)
|
|
1529
1560
|
return;
|
|
1530
1561
|
for (const column of columns) {
|
|
@@ -1547,41 +1578,35 @@ function Table(props) {
|
|
|
1547
1578
|
setSelectedKeys,
|
|
1548
1579
|
selectedKeys,
|
|
1549
1580
|
confirm
|
|
1550
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1581
|
+
}) => /* @__PURE__ */ jsx14("div", {
|
|
1582
|
+
style: {
|
|
1583
|
+
padding: 8,
|
|
1584
|
+
width: "200px"
|
|
1585
|
+
},
|
|
1586
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1587
|
+
children: /* @__PURE__ */ jsx14(Select2, {
|
|
1588
|
+
options: filters.map((f) => ({
|
|
1589
|
+
label: f.text,
|
|
1590
|
+
value: f.value
|
|
1591
|
+
})),
|
|
1592
|
+
allowClear: true,
|
|
1593
|
+
showSearch: true,
|
|
1594
|
+
style: { width: "100%" },
|
|
1595
|
+
placeholder: `${common2.search} ${newColumns[index].title}`,
|
|
1596
|
+
value: selectedKeys,
|
|
1597
|
+
onChange: (v) => {
|
|
1598
|
+
setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
|
|
1599
|
+
confirm();
|
|
1556
1600
|
},
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
showSearch: true,
|
|
1567
|
-
style: { width: "100%" },
|
|
1568
|
-
placeholder: `${common2.search} ${newColumns[index].title}`,
|
|
1569
|
-
value: selectedKeys,
|
|
1570
|
-
onChange: (v) => {
|
|
1571
|
-
setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
|
|
1572
|
-
confirm();
|
|
1573
|
-
},
|
|
1574
|
-
mode: "multiple",
|
|
1575
|
-
filterOption: (input, option) => {
|
|
1576
|
-
if (!input || !option || !option.label)
|
|
1577
|
-
return true;
|
|
1578
|
-
input = input.trim();
|
|
1579
|
-
return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
)
|
|
1583
|
-
}
|
|
1584
|
-
);
|
|
1601
|
+
mode: "multiple",
|
|
1602
|
+
filterOption: (input, option) => {
|
|
1603
|
+
if (!input || !option || !option.label)
|
|
1604
|
+
return true;
|
|
1605
|
+
input = input.trim();
|
|
1606
|
+
return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
|
|
1607
|
+
}
|
|
1608
|
+
})
|
|
1609
|
+
});
|
|
1585
1610
|
return newColumns;
|
|
1586
1611
|
});
|
|
1587
1612
|
}
|
|
@@ -1590,26 +1615,19 @@ function Table(props) {
|
|
|
1590
1615
|
if (!columns)
|
|
1591
1616
|
return null;
|
|
1592
1617
|
if (props.dataSource)
|
|
1593
|
-
return /* @__PURE__ */ jsx14(
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
children: /* @__PURE__ */ jsx14(
|
|
1605
|
-
FaasDataTable,
|
|
1606
|
-
{
|
|
1607
|
-
props,
|
|
1608
|
-
columns
|
|
1609
|
-
}
|
|
1610
|
-
)
|
|
1618
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1619
|
+
...props,
|
|
1620
|
+
rowKey: props.rowKey || "id",
|
|
1621
|
+
columns,
|
|
1622
|
+
dataSource: props.dataSource
|
|
1623
|
+
});
|
|
1624
|
+
return /* @__PURE__ */ jsx14(FaasDataWrapper, {
|
|
1625
|
+
...props.faasData,
|
|
1626
|
+
children: /* @__PURE__ */ jsx14(FaasDataTable, {
|
|
1627
|
+
props,
|
|
1628
|
+
columns
|
|
1611
1629
|
})
|
|
1612
|
-
);
|
|
1630
|
+
});
|
|
1613
1631
|
}
|
|
1614
1632
|
function FaasDataTable({
|
|
1615
1633
|
props,
|
|
@@ -1618,8 +1636,8 @@ function FaasDataTable({
|
|
|
1618
1636
|
params,
|
|
1619
1637
|
reload
|
|
1620
1638
|
}) {
|
|
1621
|
-
const [currentColumns, setCurrentColumns] =
|
|
1622
|
-
|
|
1639
|
+
const [currentColumns, setCurrentColumns] = useState7(columns);
|
|
1640
|
+
useEffect6(() => {
|
|
1623
1641
|
if (!data || Array.isArray(data))
|
|
1624
1642
|
return;
|
|
1625
1643
|
setCurrentColumns((prev) => {
|
|
@@ -1655,75 +1673,75 @@ function FaasDataTable({
|
|
|
1655
1673
|
});
|
|
1656
1674
|
}, [columns, data]);
|
|
1657
1675
|
if (!data)
|
|
1658
|
-
return /* @__PURE__ */ jsx14(
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
})
|
|
1665
|
-
);
|
|
1676
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1677
|
+
...props,
|
|
1678
|
+
rowKey: props.rowKey || "id",
|
|
1679
|
+
columns: currentColumns,
|
|
1680
|
+
dataSource: []
|
|
1681
|
+
});
|
|
1666
1682
|
if (Array.isArray(data))
|
|
1667
|
-
return /* @__PURE__ */ jsx14(
|
|
1668
|
-
|
|
1669
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1670
|
-
rowKey: props.rowKey || "id",
|
|
1671
|
-
columns: currentColumns,
|
|
1672
|
-
dataSource: data
|
|
1673
|
-
})
|
|
1674
|
-
);
|
|
1675
|
-
return /* @__PURE__ */ jsx14(
|
|
1676
|
-
AntdTable,
|
|
1677
|
-
__spreadProps(__spreadValues({}, props), {
|
|
1683
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1684
|
+
...props,
|
|
1678
1685
|
rowKey: props.rowKey || "id",
|
|
1679
1686
|
columns: currentColumns,
|
|
1680
|
-
dataSource: data
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1687
|
+
dataSource: data
|
|
1688
|
+
});
|
|
1689
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1690
|
+
...props,
|
|
1691
|
+
rowKey: props.rowKey || "id",
|
|
1692
|
+
columns: currentColumns,
|
|
1693
|
+
dataSource: data.rows,
|
|
1694
|
+
pagination: {
|
|
1695
|
+
...props.pagination,
|
|
1696
|
+
...data.pagination
|
|
1697
|
+
},
|
|
1698
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
1699
|
+
if (props.onChange) {
|
|
1700
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1701
|
+
reload({
|
|
1702
|
+
...params,
|
|
1703
|
+
pagination: processed.pagination,
|
|
1704
|
+
filters: processed.filters,
|
|
1705
|
+
sorter: processed.sorter
|
|
1706
|
+
});
|
|
1707
|
+
return;
|
|
1697
1708
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1709
|
+
reload({
|
|
1710
|
+
...params,
|
|
1711
|
+
pagination,
|
|
1712
|
+
filters,
|
|
1713
|
+
sorter
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
});
|
|
1700
1717
|
}
|
|
1701
1718
|
|
|
1702
1719
|
// src/Title.tsx
|
|
1703
|
-
import { useEffect as
|
|
1720
|
+
import { useEffect as useEffect7, cloneElement as cloneElement4 } from "react";
|
|
1704
1721
|
import { Fragment as Fragment6, jsx as jsx15 } from "react/jsx-runtime";
|
|
1705
1722
|
function Title(props) {
|
|
1706
1723
|
const { Title: Title2 } = useConfigContext();
|
|
1707
|
-
|
|
1724
|
+
useEffect7(() => {
|
|
1708
1725
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1709
1726
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1710
1727
|
}, [props]);
|
|
1711
1728
|
if (props.h1) {
|
|
1712
1729
|
if (typeof props.h1 === "boolean")
|
|
1713
|
-
return /* @__PURE__ */ jsx15("h1", {
|
|
1714
|
-
return /* @__PURE__ */ jsx15(
|
|
1715
|
-
"h1",
|
|
1716
|
-
{
|
|
1717
|
-
className: props.h1.className,
|
|
1718
|
-
style: props.h1.style,
|
|
1730
|
+
return /* @__PURE__ */ jsx15("h1", {
|
|
1719
1731
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1732
|
+
});
|
|
1733
|
+
return /* @__PURE__ */ jsx15("h1", {
|
|
1734
|
+
className: props.h1.className,
|
|
1735
|
+
style: props.h1.style,
|
|
1736
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1737
|
+
});
|
|
1722
1738
|
}
|
|
1723
1739
|
if (props.plain)
|
|
1724
|
-
return /* @__PURE__ */ jsx15(Fragment6, {
|
|
1740
|
+
return /* @__PURE__ */ jsx15(Fragment6, {
|
|
1741
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1742
|
+
});
|
|
1725
1743
|
if (props.children)
|
|
1726
|
-
return
|
|
1744
|
+
return cloneElement4(props.children, { title: props.title });
|
|
1727
1745
|
return null;
|
|
1728
1746
|
}
|
|
1729
1747
|
export {
|
|
@@ -1734,7 +1752,7 @@ export {
|
|
|
1734
1752
|
Description,
|
|
1735
1753
|
Drawer,
|
|
1736
1754
|
ErrorBoundary,
|
|
1737
|
-
|
|
1755
|
+
FaasDataWrapper,
|
|
1738
1756
|
Form,
|
|
1739
1757
|
FormItem,
|
|
1740
1758
|
Link,
|