@faasjs/ant-design 0.0.3-beta.64 → 0.0.3-beta.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +770 -737
- package/dist/index.mjs +744 -715
- package/package.json +1 -1
package/dist/index.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,120 +362,112 @@ 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
|
|
372
369
|
});
|
|
373
370
|
if (computedProps.item.descriptionRender)
|
|
374
|
-
return
|
|
371
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
372
|
+
children: computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description")
|
|
373
|
+
});
|
|
375
374
|
if (computedProps.item.render)
|
|
376
|
-
return
|
|
375
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
376
|
+
children: computedProps.item.render(computedProps.value, computedProps.values, 0, "description")
|
|
377
|
+
});
|
|
377
378
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
378
379
|
return /* @__PURE__ */ jsx8(Blank, {});
|
|
379
380
|
switch (computedProps.item.type) {
|
|
380
381
|
case "string[]":
|
|
381
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
382
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
383
|
+
children: computedProps.value.join(", ")
|
|
384
|
+
});
|
|
382
385
|
case "number":
|
|
383
386
|
return computedProps.value || null;
|
|
384
387
|
case "number[]":
|
|
385
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
388
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
389
|
+
children: computedProps.value.join(", ")
|
|
390
|
+
});
|
|
386
391
|
case "boolean":
|
|
387
|
-
return computedProps.value ? /* @__PURE__ */ jsx8(CheckOutlined, {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
return computedProps.value ? /* @__PURE__ */ jsx8(CheckOutlined, {
|
|
393
|
+
style: {
|
|
394
|
+
marginTop: "4px",
|
|
395
|
+
color: "#52c41a"
|
|
396
|
+
}
|
|
397
|
+
}) : /* @__PURE__ */ jsx8(CloseOutlined, {
|
|
398
|
+
style: {
|
|
399
|
+
marginTop: "4px",
|
|
400
|
+
color: "#ff4d4f"
|
|
401
|
+
}
|
|
402
|
+
});
|
|
394
403
|
case "time":
|
|
395
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
404
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
405
|
+
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
406
|
+
});
|
|
396
407
|
case "date":
|
|
397
|
-
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
408
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
409
|
+
children: computedProps.value.format("YYYY-MM-DD")
|
|
410
|
+
});
|
|
398
411
|
case "object":
|
|
399
412
|
if (!computedProps.value)
|
|
400
413
|
return /* @__PURE__ */ jsx8(Blank, {});
|
|
401
|
-
return /* @__PURE__ */ jsx8(
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
column: 1
|
|
407
|
-
}
|
|
408
|
-
);
|
|
414
|
+
return /* @__PURE__ */ jsx8(Description, {
|
|
415
|
+
items: computedProps.item.object,
|
|
416
|
+
dataSource: computedProps.value,
|
|
417
|
+
column: 1
|
|
418
|
+
});
|
|
409
419
|
case "object[]":
|
|
410
420
|
if (!((_a = computedProps.value) == null ? void 0 : _a.length))
|
|
411
421
|
return /* @__PURE__ */ jsx8(Blank, {});
|
|
412
|
-
return /* @__PURE__ */ jsx8(Space, {
|
|
413
|
-
|
|
414
|
-
{
|
|
422
|
+
return /* @__PURE__ */ jsx8(Space, {
|
|
423
|
+
direction: "vertical",
|
|
424
|
+
children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx8(Description, {
|
|
415
425
|
items: computedProps.item.object,
|
|
416
426
|
dataSource: value,
|
|
417
427
|
column: 1
|
|
418
|
-
},
|
|
419
|
-
|
|
420
|
-
)) });
|
|
428
|
+
}, index))
|
|
429
|
+
});
|
|
421
430
|
default:
|
|
422
431
|
return computedProps.value || null;
|
|
423
432
|
}
|
|
424
433
|
}
|
|
425
434
|
function Description(props) {
|
|
426
435
|
if (props.dataSource)
|
|
427
|
-
return /* @__PURE__ */ jsx8(
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
436
|
+
return /* @__PURE__ */ jsx8(Descriptions, {
|
|
437
|
+
...props,
|
|
438
|
+
title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
439
|
+
children: props.items.map((item) => {
|
|
440
|
+
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
|
|
441
|
+
label: item.title || upperFirst2(item.id),
|
|
442
|
+
children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
|
|
443
|
+
item,
|
|
444
|
+
value: props.dataSource[item.id],
|
|
445
|
+
values: props.dataSource,
|
|
446
|
+
extendTypes: props.extendTypes
|
|
447
|
+
})
|
|
448
|
+
}, item.id) : null;
|
|
449
|
+
}).filter(Boolean)
|
|
450
|
+
});
|
|
451
|
+
return /* @__PURE__ */ jsx8(FaasDataWrapper, {
|
|
452
|
+
render: ({ data }) => {
|
|
453
|
+
return /* @__PURE__ */ jsx8(Descriptions, {
|
|
454
|
+
...props,
|
|
455
|
+
title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
431
456
|
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;
|
|
457
|
+
return !item.if || item.if(data) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
|
|
458
|
+
label: item.title || upperFirst2(item.id),
|
|
459
|
+
children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
|
|
460
|
+
item,
|
|
461
|
+
value: data[item.id],
|
|
462
|
+
values: data,
|
|
463
|
+
extendTypes: props.extendTypes
|
|
464
|
+
})
|
|
465
|
+
}, item.id) : null;
|
|
448
466
|
}).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
|
-
);
|
|
467
|
+
});
|
|
468
|
+
},
|
|
469
|
+
...props.faasData
|
|
470
|
+
});
|
|
482
471
|
}
|
|
483
472
|
|
|
484
473
|
// src/ErrorBoundary.tsx
|
|
@@ -512,30 +501,31 @@ var ErrorBoundary = class extends Component {
|
|
|
512
501
|
if (error) {
|
|
513
502
|
if (this.props.onError)
|
|
514
503
|
return this.props.onError(error, info);
|
|
515
|
-
return /* @__PURE__ */ jsx9(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
description: /* @__PURE__ */ jsx9("pre", { style: {
|
|
504
|
+
return /* @__PURE__ */ jsx9(Alert, {
|
|
505
|
+
type: "error",
|
|
506
|
+
message: errorMessage,
|
|
507
|
+
description: /* @__PURE__ */ jsx9("pre", {
|
|
508
|
+
style: {
|
|
521
509
|
fontSize: "0.9em",
|
|
522
510
|
overflowX: "auto"
|
|
523
|
-
},
|
|
524
|
-
|
|
525
|
-
|
|
511
|
+
},
|
|
512
|
+
children: errorDescription
|
|
513
|
+
})
|
|
514
|
+
});
|
|
526
515
|
}
|
|
527
516
|
return children;
|
|
528
517
|
}
|
|
529
518
|
};
|
|
530
519
|
|
|
531
520
|
// src/Form.tsx
|
|
521
|
+
import { faas } from "@faasjs/react";
|
|
532
522
|
import {
|
|
533
523
|
Button as Button2,
|
|
534
524
|
Form as AntdForm2
|
|
535
525
|
} from "antd";
|
|
536
526
|
import {
|
|
537
|
-
useEffect as
|
|
538
|
-
useState as
|
|
527
|
+
useEffect as useEffect5,
|
|
528
|
+
useState as useState6,
|
|
539
529
|
useCallback,
|
|
540
530
|
isValidElement
|
|
541
531
|
} from "react";
|
|
@@ -555,9 +545,9 @@ import {
|
|
|
555
545
|
} from "antd";
|
|
556
546
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
557
547
|
import {
|
|
558
|
-
cloneElement as
|
|
559
|
-
useEffect as
|
|
560
|
-
useState as
|
|
548
|
+
cloneElement as cloneElement2,
|
|
549
|
+
useEffect as useEffect4,
|
|
550
|
+
useState as useState5
|
|
561
551
|
} from "react";
|
|
562
552
|
import { upperFirst as upperFirst3 } from "lodash-es";
|
|
563
553
|
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
@@ -609,12 +599,12 @@ function processProps(propsCopy, config) {
|
|
|
609
599
|
}
|
|
610
600
|
function FormItem(props) {
|
|
611
601
|
var _a;
|
|
612
|
-
const [computedProps, setComputedProps] =
|
|
613
|
-
const [extendTypes, setExtendTypes] =
|
|
602
|
+
const [computedProps, setComputedProps] = useState5();
|
|
603
|
+
const [extendTypes, setExtendTypes] = useState5();
|
|
614
604
|
const { common: common2 } = useConfigContext();
|
|
615
|
-
const [hidden, setHidden] =
|
|
616
|
-
|
|
617
|
-
const propsCopy =
|
|
605
|
+
const [hidden, setHidden] = useState5(props.hidden || false);
|
|
606
|
+
useEffect4(() => {
|
|
607
|
+
const propsCopy = { ...props };
|
|
618
608
|
if (propsCopy.extendTypes) {
|
|
619
609
|
setExtendTypes(propsCopy.extendTypes);
|
|
620
610
|
delete propsCopy.extendTypes;
|
|
@@ -637,231 +627,290 @@ function FormItem(props) {
|
|
|
637
627
|
if (!computedProps)
|
|
638
628
|
return null;
|
|
639
629
|
if (hidden)
|
|
640
|
-
return /* @__PURE__ */ jsx10(
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
630
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
631
|
+
...computedProps,
|
|
632
|
+
noStyle: true,
|
|
633
|
+
rules: [],
|
|
634
|
+
children: /* @__PURE__ */ jsx10(Input, {
|
|
635
|
+
hidden: true
|
|
646
636
|
})
|
|
647
|
-
);
|
|
637
|
+
});
|
|
648
638
|
if (extendTypes && extendTypes[computedProps.type])
|
|
649
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
639
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
640
|
+
...computedProps,
|
|
641
|
+
children: extendTypes[computedProps.type].children
|
|
642
|
+
});
|
|
650
643
|
if (computedProps.formChildren === null)
|
|
651
644
|
return null;
|
|
652
645
|
if (computedProps.formChildren)
|
|
653
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
646
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
647
|
+
...computedProps,
|
|
648
|
+
children: cloneElement2(computedProps.formChildren, { scene: "form" })
|
|
649
|
+
});
|
|
654
650
|
if (computedProps.children === null)
|
|
655
651
|
return null;
|
|
656
652
|
if (computedProps.children)
|
|
657
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
653
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
654
|
+
...computedProps,
|
|
655
|
+
children: cloneElement2(computedProps.children, { scene: "form" })
|
|
656
|
+
});
|
|
658
657
|
if (computedProps.formRender)
|
|
659
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
658
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
659
|
+
...computedProps,
|
|
660
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
661
|
+
});
|
|
660
662
|
if (computedProps.render)
|
|
661
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
663
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
664
|
+
...computedProps,
|
|
665
|
+
children: computedProps.render(null, null, 0, "form")
|
|
666
|
+
});
|
|
662
667
|
switch (computedProps.type) {
|
|
663
668
|
case "string":
|
|
664
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
669
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
670
|
+
...computedProps,
|
|
671
|
+
children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
|
|
672
|
+
...computedProps.input
|
|
673
|
+
}) : /* @__PURE__ */ jsx10(Input, {
|
|
674
|
+
...computedProps.input
|
|
675
|
+
})
|
|
676
|
+
});
|
|
665
677
|
case "string[]":
|
|
666
678
|
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", {
|
|
679
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
680
|
+
...computedProps,
|
|
681
|
+
children: /* @__PURE__ */ jsx10(Select, {
|
|
682
|
+
mode: "multiple",
|
|
683
|
+
...computedProps.input
|
|
684
|
+
})
|
|
685
|
+
});
|
|
686
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
687
|
+
name: computedProps.name,
|
|
688
|
+
rules: computedProps.rules,
|
|
689
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
690
|
+
var _a2;
|
|
691
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
692
|
+
children: [
|
|
693
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
694
|
+
className: "ant-form-item-label",
|
|
695
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
696
|
+
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
|
|
697
|
+
children: computedProps.label
|
|
698
|
+
})
|
|
699
|
+
}),
|
|
682
700
|
fields.map((field) => {
|
|
683
701
|
var _a3;
|
|
684
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
685
|
-
Row,
|
|
686
|
-
{
|
|
702
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
703
|
+
children: /* @__PURE__ */ jsxs2(Row, {
|
|
687
704
|
gutter: 24,
|
|
688
705
|
style: { flexFlow: "row nowrap" },
|
|
689
706
|
children: [
|
|
690
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
691
|
-
|
|
692
|
-
|
|
707
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
708
|
+
span: 23,
|
|
709
|
+
children: /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
710
|
+
...field,
|
|
693
711
|
noStyle: true,
|
|
694
|
-
children: /* @__PURE__ */ jsx10(Input,
|
|
712
|
+
children: /* @__PURE__ */ jsx10(Input, {
|
|
713
|
+
...computedProps.input
|
|
714
|
+
})
|
|
695
715
|
})
|
|
696
|
-
|
|
697
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
698
|
-
|
|
699
|
-
{
|
|
716
|
+
}),
|
|
717
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
718
|
+
span: 1,
|
|
719
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
700
720
|
danger: true,
|
|
701
721
|
type: "link",
|
|
702
722
|
style: { float: "right" },
|
|
703
723
|
icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
|
|
704
724
|
onClick: () => remove(field.name)
|
|
705
|
-
}
|
|
706
|
-
|
|
725
|
+
})
|
|
726
|
+
})
|
|
707
727
|
]
|
|
708
|
-
}
|
|
709
|
-
|
|
728
|
+
})
|
|
729
|
+
}, field.key);
|
|
710
730
|
}),
|
|
711
|
-
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
712
|
-
|
|
713
|
-
Button,
|
|
714
|
-
{
|
|
731
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
732
|
+
children: [
|
|
733
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
|
|
715
734
|
type: "dashed",
|
|
716
735
|
block: true,
|
|
717
736
|
onClick: () => add(),
|
|
718
737
|
icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
738
|
+
}),
|
|
739
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
740
|
+
className: "ant-form-item-extra",
|
|
741
|
+
children: computedProps.extra
|
|
742
|
+
}),
|
|
743
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
744
|
+
errors
|
|
745
|
+
})
|
|
746
|
+
]
|
|
747
|
+
})
|
|
748
|
+
]
|
|
749
|
+
});
|
|
726
750
|
}
|
|
727
|
-
);
|
|
751
|
+
});
|
|
728
752
|
case "number":
|
|
729
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
},
|
|
734
|
-
|
|
753
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
754
|
+
...computedProps,
|
|
755
|
+
children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
|
|
756
|
+
...computedProps.input
|
|
757
|
+
}) : /* @__PURE__ */ jsx10(InputNumber, {
|
|
758
|
+
style: { width: "100%" },
|
|
759
|
+
...computedProps.input
|
|
760
|
+
})
|
|
761
|
+
});
|
|
735
762
|
case "number[]":
|
|
736
763
|
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", {
|
|
764
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
765
|
+
...computedProps,
|
|
766
|
+
children: /* @__PURE__ */ jsx10(Select, {
|
|
767
|
+
mode: "multiple",
|
|
768
|
+
...computedProps.input
|
|
769
|
+
})
|
|
770
|
+
});
|
|
771
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
772
|
+
name: computedProps.name,
|
|
773
|
+
rules: computedProps.rules,
|
|
774
|
+
children: (fields, { add, remove }, { errors }) => {
|
|
775
|
+
var _a2, _b;
|
|
776
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
777
|
+
children: [
|
|
778
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
779
|
+
className: "ant-form-item-label",
|
|
780
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
781
|
+
className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
|
|
782
|
+
children: computedProps.label
|
|
783
|
+
})
|
|
784
|
+
}),
|
|
752
785
|
fields.map((field) => {
|
|
753
786
|
var _a3;
|
|
754
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
755
|
-
Row,
|
|
756
|
-
{
|
|
787
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
788
|
+
children: /* @__PURE__ */ jsxs2(Row, {
|
|
757
789
|
gutter: 24,
|
|
758
790
|
style: { flexFlow: "row nowrap" },
|
|
759
791
|
children: [
|
|
760
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
761
|
-
|
|
762
|
-
|
|
792
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
793
|
+
span: 23,
|
|
794
|
+
children: /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
795
|
+
...field,
|
|
763
796
|
noStyle: true,
|
|
764
|
-
children: /* @__PURE__ */ jsx10(
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}, computedProps.input)
|
|
769
|
-
)
|
|
797
|
+
children: /* @__PURE__ */ jsx10(InputNumber, {
|
|
798
|
+
style: { width: "100%" },
|
|
799
|
+
...computedProps.input
|
|
800
|
+
})
|
|
770
801
|
})
|
|
771
|
-
|
|
772
|
-
/* @__PURE__ */ jsx10(Col, {
|
|
773
|
-
|
|
774
|
-
{
|
|
802
|
+
}),
|
|
803
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
804
|
+
span: 1,
|
|
805
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
775
806
|
danger: true,
|
|
776
807
|
type: "link",
|
|
777
808
|
style: { float: "right" },
|
|
778
809
|
icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
|
|
779
810
|
onClick: () => remove(field.name)
|
|
780
|
-
}
|
|
781
|
-
|
|
811
|
+
})
|
|
812
|
+
})
|
|
782
813
|
]
|
|
783
|
-
}
|
|
784
|
-
|
|
814
|
+
})
|
|
815
|
+
}, field.key);
|
|
785
816
|
}),
|
|
786
|
-
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
787
|
-
|
|
788
|
-
Button,
|
|
789
|
-
{
|
|
817
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
818
|
+
children: [
|
|
819
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
|
|
790
820
|
type: "dashed",
|
|
791
821
|
block: true,
|
|
792
822
|
onClick: () => add(),
|
|
793
823
|
icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
824
|
+
}),
|
|
825
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
826
|
+
className: "ant-form-item-extra",
|
|
827
|
+
children: computedProps.extra
|
|
828
|
+
}),
|
|
829
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
830
|
+
errors
|
|
831
|
+
})
|
|
832
|
+
]
|
|
833
|
+
})
|
|
834
|
+
]
|
|
835
|
+
});
|
|
801
836
|
}
|
|
802
|
-
);
|
|
837
|
+
});
|
|
803
838
|
case "boolean":
|
|
804
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
839
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
840
|
+
...computedProps,
|
|
841
|
+
children: /* @__PURE__ */ jsx10(Switch, {
|
|
842
|
+
...computedProps.input
|
|
843
|
+
})
|
|
844
|
+
});
|
|
805
845
|
case "date":
|
|
806
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
846
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
847
|
+
...computedProps,
|
|
848
|
+
children: /* @__PURE__ */ jsx10(DatePicker, {
|
|
849
|
+
...computedProps.input
|
|
850
|
+
})
|
|
851
|
+
});
|
|
807
852
|
case "time":
|
|
808
|
-
return /* @__PURE__ */ jsx10(AntdForm.Item,
|
|
853
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
854
|
+
...computedProps,
|
|
855
|
+
children: /* @__PURE__ */ jsx10(TimePicker, {
|
|
856
|
+
...computedProps.input
|
|
857
|
+
})
|
|
858
|
+
});
|
|
809
859
|
case "object":
|
|
810
|
-
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
860
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
861
|
+
children: [
|
|
862
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
863
|
+
className: "ant-form-item-label",
|
|
864
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
865
|
+
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
|
|
866
|
+
children: computedProps.label
|
|
867
|
+
})
|
|
868
|
+
}),
|
|
869
|
+
computedProps.object.map((o) => /* @__PURE__ */ jsx10(FormItem, {
|
|
870
|
+
...o
|
|
871
|
+
}, o.id))
|
|
872
|
+
]
|
|
873
|
+
});
|
|
818
874
|
case "object[]":
|
|
819
|
-
return /* @__PURE__ */ jsx10(
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
Button,
|
|
836
|
-
{
|
|
875
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
876
|
+
name: computedProps.name,
|
|
877
|
+
rules: computedProps.rules,
|
|
878
|
+
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs2(Fragment4, {
|
|
879
|
+
children: [
|
|
880
|
+
fields.map((field) => /* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
881
|
+
style: { marginBottom: 0 },
|
|
882
|
+
children: [
|
|
883
|
+
/* @__PURE__ */ jsx10("div", {
|
|
884
|
+
className: "ant-form-item-label",
|
|
885
|
+
children: /* @__PURE__ */ jsxs2("label", {
|
|
886
|
+
children: [
|
|
887
|
+
computedProps.label,
|
|
888
|
+
" ",
|
|
889
|
+
field.name + 1,
|
|
890
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
837
891
|
danger: true,
|
|
838
892
|
type: "link",
|
|
839
893
|
onClick: () => remove(field.name),
|
|
840
894
|
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
|
-
{
|
|
895
|
+
})
|
|
896
|
+
]
|
|
897
|
+
})
|
|
898
|
+
}),
|
|
899
|
+
/* @__PURE__ */ jsx10(Row, {
|
|
900
|
+
gutter: 24,
|
|
901
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ jsx10(Col, {
|
|
902
|
+
span: o.col || 24,
|
|
903
|
+
children: /* @__PURE__ */ jsx10(FormItem, {
|
|
904
|
+
...o,
|
|
905
|
+
name: [field.name, o.id]
|
|
906
|
+
})
|
|
907
|
+
}, o.id))
|
|
908
|
+
})
|
|
909
|
+
]
|
|
910
|
+
}, field.key)),
|
|
911
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
912
|
+
children: [
|
|
913
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs2(Button, {
|
|
865
914
|
type: "dashed",
|
|
866
915
|
block: true,
|
|
867
916
|
onClick: () => add(),
|
|
@@ -871,14 +920,19 @@ function FormItem(props) {
|
|
|
871
920
|
" ",
|
|
872
921
|
computedProps.label
|
|
873
922
|
]
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
923
|
+
}),
|
|
924
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
925
|
+
className: "ant-form-item-extra",
|
|
926
|
+
children: computedProps.extra
|
|
927
|
+
}),
|
|
928
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
929
|
+
errors
|
|
930
|
+
})
|
|
931
|
+
]
|
|
932
|
+
})
|
|
933
|
+
]
|
|
934
|
+
})
|
|
935
|
+
});
|
|
882
936
|
default:
|
|
883
937
|
return null;
|
|
884
938
|
}
|
|
@@ -889,17 +943,18 @@ FormItem.useStatus = AntdForm.Item.useStatus;
|
|
|
889
943
|
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
890
944
|
function Form(props) {
|
|
891
945
|
var _a, _b;
|
|
892
|
-
const [loading, setLoading] =
|
|
893
|
-
const [computedProps, setComputedProps] =
|
|
946
|
+
const [loading, setLoading] = useState6(false);
|
|
947
|
+
const [computedProps, setComputedProps] = useState6();
|
|
894
948
|
const config = useConfigContext();
|
|
895
|
-
const [extendTypes, setExtendTypes] =
|
|
949
|
+
const [extendTypes, setExtendTypes] = useState6();
|
|
896
950
|
const [form] = AntdForm2.useForm(props.form);
|
|
897
|
-
const [initialValues, setInitialValues] =
|
|
898
|
-
|
|
951
|
+
const [initialValues, setInitialValues] = useState6(props.initialValues);
|
|
952
|
+
useEffect5(() => {
|
|
899
953
|
var _a2, _b2, _c;
|
|
900
|
-
const propsCopy =
|
|
954
|
+
const propsCopy = {
|
|
955
|
+
...props,
|
|
901
956
|
form
|
|
902
|
-
}
|
|
957
|
+
};
|
|
903
958
|
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
904
959
|
for (const key in propsCopy.initialValues) {
|
|
905
960
|
propsCopy.initialValues[key] = transferValue(
|
|
@@ -923,7 +978,10 @@ function Form(props) {
|
|
|
923
978
|
setLoading(true);
|
|
924
979
|
try {
|
|
925
980
|
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 ?
|
|
981
|
+
await props.onFinish(values, async (values2) => faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
982
|
+
...values2,
|
|
983
|
+
...propsCopy.submit.to.params
|
|
984
|
+
} : values2));
|
|
927
985
|
} else
|
|
928
986
|
await props.onFinish(values);
|
|
929
987
|
} catch (error) {
|
|
@@ -934,7 +992,10 @@ function Form(props) {
|
|
|
934
992
|
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
935
993
|
propsCopy.onFinish = async (values) => {
|
|
936
994
|
setLoading(true);
|
|
937
|
-
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ?
|
|
995
|
+
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
996
|
+
...values,
|
|
997
|
+
...propsCopy.submit.to.params
|
|
998
|
+
} : values).then((result) => {
|
|
938
999
|
if (propsCopy.submit.to.then)
|
|
939
1000
|
propsCopy.submit.to.then(result);
|
|
940
1001
|
return result;
|
|
@@ -968,7 +1029,7 @@ function Form(props) {
|
|
|
968
1029
|
item.onValueChange(changedValues[key], allValues, form);
|
|
969
1030
|
}
|
|
970
1031
|
}, [computedProps]);
|
|
971
|
-
|
|
1032
|
+
useEffect5(() => {
|
|
972
1033
|
if (!initialValues)
|
|
973
1034
|
return;
|
|
974
1035
|
console.debug("Form:initialValues", initialValues);
|
|
@@ -977,33 +1038,25 @@ function Form(props) {
|
|
|
977
1038
|
}, [computedProps]);
|
|
978
1039
|
if (!computedProps)
|
|
979
1040
|
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
|
-
);
|
|
1041
|
+
return /* @__PURE__ */ jsxs3(AntdForm2, {
|
|
1042
|
+
...computedProps,
|
|
1043
|
+
onValuesChange,
|
|
1044
|
+
children: [
|
|
1045
|
+
computedProps.beforeItems,
|
|
1046
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx11(FormItem, {
|
|
1047
|
+
...item,
|
|
1048
|
+
extendTypes
|
|
1049
|
+
}, item.id)),
|
|
1050
|
+
computedProps.children,
|
|
1051
|
+
computedProps.submit !== false && /* @__PURE__ */ jsx11(Button2, {
|
|
1052
|
+
htmlType: "submit",
|
|
1053
|
+
type: "primary",
|
|
1054
|
+
loading,
|
|
1055
|
+
children: ((_b = computedProps.submit) == null ? void 0 : _b.text) || config.Form.submit.text
|
|
1056
|
+
}),
|
|
1057
|
+
computedProps.footer
|
|
1058
|
+
]
|
|
1059
|
+
});
|
|
1007
1060
|
}
|
|
1008
1061
|
Form.useForm = AntdForm2.useForm;
|
|
1009
1062
|
Form.useFormInstance = AntdForm2.useFormInstance;
|
|
@@ -1020,9 +1073,11 @@ import { jsx as jsx12 } from "react/jsx-runtime";
|
|
|
1020
1073
|
function Link(props) {
|
|
1021
1074
|
var _a, _b, _c, _d;
|
|
1022
1075
|
const { Link: Link2 } = useConfigContext();
|
|
1023
|
-
let style =
|
|
1024
|
-
|
|
1025
|
-
|
|
1076
|
+
let style = {
|
|
1077
|
+
...Link2.style || {},
|
|
1078
|
+
cursor: "pointer",
|
|
1079
|
+
...props.style
|
|
1080
|
+
};
|
|
1026
1081
|
if (props.block)
|
|
1027
1082
|
style = Object.assign({
|
|
1028
1083
|
display: "block",
|
|
@@ -1030,49 +1085,36 @@ function Link(props) {
|
|
|
1030
1085
|
}, style);
|
|
1031
1086
|
if (props.href.startsWith("http")) {
|
|
1032
1087
|
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,
|
|
1088
|
+
return /* @__PURE__ */ jsx12(Button3, {
|
|
1089
|
+
...props.button,
|
|
1046
1090
|
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1047
1091
|
style,
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1092
|
+
href: props.href,
|
|
1093
|
+
children: (_a = props.text) != null ? _a : props.children
|
|
1094
|
+
});
|
|
1095
|
+
return /* @__PURE__ */ jsx12("a", {
|
|
1096
|
+
href: props.href,
|
|
1097
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1098
|
+
style,
|
|
1099
|
+
children: (_b = props.text) != null ? _b : props.children
|
|
1100
|
+
});
|
|
1051
1101
|
}
|
|
1052
1102
|
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
|
-
{
|
|
1103
|
+
return /* @__PURE__ */ jsx12(RouterLink, {
|
|
1070
1104
|
to: props.href,
|
|
1071
1105
|
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1106
|
+
children: /* @__PURE__ */ jsx12(Button3, {
|
|
1107
|
+
...props.button,
|
|
1108
|
+
style,
|
|
1109
|
+
children: (_c = props.text) != null ? _c : props.children
|
|
1110
|
+
})
|
|
1111
|
+
});
|
|
1112
|
+
return /* @__PURE__ */ jsx12(RouterLink, {
|
|
1113
|
+
to: props.href,
|
|
1114
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1115
|
+
style,
|
|
1116
|
+
children: (_d = props.text) != null ? _d : props.children
|
|
1117
|
+
});
|
|
1076
1118
|
}
|
|
1077
1119
|
|
|
1078
1120
|
// src/Routers.tsx
|
|
@@ -1088,39 +1130,39 @@ import { lazy } from "react";
|
|
|
1088
1130
|
import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1089
1131
|
function PageNotFound() {
|
|
1090
1132
|
const config = useConfigContext();
|
|
1091
|
-
return /* @__PURE__ */ jsx13(
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
title: config.common.pageNotFound
|
|
1096
|
-
}
|
|
1097
|
-
);
|
|
1133
|
+
return /* @__PURE__ */ jsx13(Result, {
|
|
1134
|
+
status: "404",
|
|
1135
|
+
title: config.common.pageNotFound
|
|
1136
|
+
});
|
|
1098
1137
|
}
|
|
1099
1138
|
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
|
-
|
|
1139
|
+
return /* @__PURE__ */ jsxs4(OriginRoutes, {
|
|
1140
|
+
children: [
|
|
1141
|
+
props.routes.map((r) => /* @__PURE__ */ jsx13(Route, {
|
|
1142
|
+
...r,
|
|
1143
|
+
element: r.element || /* @__PURE__ */ jsx13(Suspense, {
|
|
1144
|
+
fallback: props.fallback || /* @__PURE__ */ jsx13("div", {
|
|
1145
|
+
style: { padding: "24px" },
|
|
1146
|
+
children: /* @__PURE__ */ jsx13(Skeleton, {
|
|
1147
|
+
active: true
|
|
1148
|
+
})
|
|
1149
|
+
}),
|
|
1150
|
+
children: /* @__PURE__ */ jsx13(r.page, {})
|
|
1151
|
+
})
|
|
1152
|
+
}, r.path)),
|
|
1153
|
+
/* @__PURE__ */ jsx13(Route, {
|
|
1111
1154
|
path: "*",
|
|
1112
1155
|
element: props.notFound || /* @__PURE__ */ jsx13(PageNotFound, {})
|
|
1113
|
-
},
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
] });
|
|
1156
|
+
}, "*")
|
|
1157
|
+
]
|
|
1158
|
+
});
|
|
1117
1159
|
}
|
|
1118
1160
|
|
|
1119
1161
|
// src/Table.tsx
|
|
1120
1162
|
import {
|
|
1121
|
-
useState as
|
|
1122
|
-
useEffect as
|
|
1123
|
-
cloneElement as
|
|
1163
|
+
useState as useState7,
|
|
1164
|
+
useEffect as useEffect6,
|
|
1165
|
+
cloneElement as cloneElement3
|
|
1124
1166
|
} from "react";
|
|
1125
1167
|
import {
|
|
1126
1168
|
Table as AntdTable,
|
|
@@ -1162,9 +1204,52 @@ function processValue(item, value) {
|
|
|
1162
1204
|
return value;
|
|
1163
1205
|
}
|
|
1164
1206
|
function Table(props) {
|
|
1165
|
-
const [columns, setColumns] =
|
|
1207
|
+
const [columns, setColumns] = useState7();
|
|
1166
1208
|
const { common: common2 } = useConfigContext();
|
|
1167
|
-
|
|
1209
|
+
const generateFilterDropdown = (item) => {
|
|
1210
|
+
if (typeof item.filterDropdown !== "undefined")
|
|
1211
|
+
return;
|
|
1212
|
+
if (item.options.length < 11) {
|
|
1213
|
+
if (!item.filters)
|
|
1214
|
+
item.filters = item.options.map((o) => ({
|
|
1215
|
+
text: o.label,
|
|
1216
|
+
value: o.value
|
|
1217
|
+
}));
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
item.filterDropdown = ({
|
|
1221
|
+
setSelectedKeys,
|
|
1222
|
+
selectedKeys,
|
|
1223
|
+
confirm
|
|
1224
|
+
}) => /* @__PURE__ */ jsx14("div", {
|
|
1225
|
+
style: {
|
|
1226
|
+
padding: 8,
|
|
1227
|
+
width: "200px"
|
|
1228
|
+
},
|
|
1229
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1230
|
+
children: /* @__PURE__ */ jsx14(Select2, {
|
|
1231
|
+
options: item.options,
|
|
1232
|
+
allowClear: true,
|
|
1233
|
+
showSearch: true,
|
|
1234
|
+
style: { width: "100%" },
|
|
1235
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1236
|
+
value: selectedKeys,
|
|
1237
|
+
onChange: (v) => {
|
|
1238
|
+
setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
|
|
1239
|
+
confirm();
|
|
1240
|
+
},
|
|
1241
|
+
mode: "multiple",
|
|
1242
|
+
filterOption: (input, option) => {
|
|
1243
|
+
if (!input || !option || !option.label)
|
|
1244
|
+
return true;
|
|
1245
|
+
input = input.trim();
|
|
1246
|
+
return option.value === input || option.label.toString().toLowerCase().includes(input.toLowerCase());
|
|
1247
|
+
}
|
|
1248
|
+
})
|
|
1249
|
+
});
|
|
1250
|
+
return item;
|
|
1251
|
+
};
|
|
1252
|
+
useEffect6(() => {
|
|
1168
1253
|
var _a;
|
|
1169
1254
|
for (const item of props.items) {
|
|
1170
1255
|
if (!item.key)
|
|
@@ -1184,11 +1269,12 @@ function Table(props) {
|
|
|
1184
1269
|
text: /* @__PURE__ */ jsx14(Blank, {}),
|
|
1185
1270
|
value: null
|
|
1186
1271
|
});
|
|
1272
|
+
generateFilterDropdown(item);
|
|
1187
1273
|
}
|
|
1188
1274
|
if (item.tableChildren === null)
|
|
1189
1275
|
item.render = () => null;
|
|
1190
1276
|
else if (item.tableChildren)
|
|
1191
|
-
item.render = (value, values) =>
|
|
1277
|
+
item.render = (value, values) => cloneElement3(
|
|
1192
1278
|
item.tableChildren,
|
|
1193
1279
|
{
|
|
1194
1280
|
scene: "table",
|
|
@@ -1199,7 +1285,7 @@ function Table(props) {
|
|
|
1199
1285
|
else if (item.children === null)
|
|
1200
1286
|
item.render = () => null;
|
|
1201
1287
|
else if (item.children)
|
|
1202
|
-
item.render = (value, values) =>
|
|
1288
|
+
item.render = (value, values) => cloneElement3(
|
|
1203
1289
|
item.children,
|
|
1204
1290
|
{
|
|
1205
1291
|
scene: "table",
|
|
@@ -1209,7 +1295,7 @@ function Table(props) {
|
|
|
1209
1295
|
);
|
|
1210
1296
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1211
1297
|
if (props.extendTypes[item.type].children)
|
|
1212
|
-
item.render = (value, values) =>
|
|
1298
|
+
item.render = (value, values) => cloneElement3(
|
|
1213
1299
|
props.extendTypes[item.type].children,
|
|
1214
1300
|
{
|
|
1215
1301
|
scene: "table",
|
|
@@ -1242,22 +1328,19 @@ function Table(props) {
|
|
|
1242
1328
|
setSelectedKeys,
|
|
1243
1329
|
confirm,
|
|
1244
1330
|
clearFilters
|
|
1245
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
setSelectedKeys([]);
|
|
1255
|
-
clearFilters();
|
|
1256
|
-
}
|
|
1257
|
-
confirm();
|
|
1331
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1332
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1333
|
+
allowClear: true,
|
|
1334
|
+
onSearch: (v) => {
|
|
1335
|
+
if (v) {
|
|
1336
|
+
setSelectedKeys([v]);
|
|
1337
|
+
} else {
|
|
1338
|
+
setSelectedKeys([]);
|
|
1339
|
+
clearFilters();
|
|
1258
1340
|
}
|
|
1341
|
+
confirm();
|
|
1259
1342
|
}
|
|
1260
|
-
);
|
|
1343
|
+
});
|
|
1261
1344
|
break;
|
|
1262
1345
|
case "string[]":
|
|
1263
1346
|
if (!item.render)
|
|
@@ -1277,22 +1360,19 @@ function Table(props) {
|
|
|
1277
1360
|
setSelectedKeys,
|
|
1278
1361
|
confirm,
|
|
1279
1362
|
clearFilters
|
|
1280
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
setSelectedKeys([]);
|
|
1290
|
-
clearFilters();
|
|
1291
|
-
}
|
|
1292
|
-
confirm();
|
|
1363
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1364
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1365
|
+
allowClear: true,
|
|
1366
|
+
onSearch: (v) => {
|
|
1367
|
+
if (v) {
|
|
1368
|
+
setSelectedKeys([v]);
|
|
1369
|
+
} else {
|
|
1370
|
+
setSelectedKeys([]);
|
|
1371
|
+
clearFilters();
|
|
1293
1372
|
}
|
|
1373
|
+
confirm();
|
|
1294
1374
|
}
|
|
1295
|
-
);
|
|
1375
|
+
});
|
|
1296
1376
|
break;
|
|
1297
1377
|
case "number":
|
|
1298
1378
|
if (!item.render)
|
|
@@ -1314,22 +1394,19 @@ function Table(props) {
|
|
|
1314
1394
|
setSelectedKeys,
|
|
1315
1395
|
confirm,
|
|
1316
1396
|
clearFilters
|
|
1317
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
setSelectedKeys([]);
|
|
1327
|
-
clearFilters();
|
|
1328
|
-
}
|
|
1329
|
-
confirm();
|
|
1397
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1398
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1399
|
+
allowClear: true,
|
|
1400
|
+
onSearch: (v) => {
|
|
1401
|
+
if (v) {
|
|
1402
|
+
setSelectedKeys([Number(v)]);
|
|
1403
|
+
} else {
|
|
1404
|
+
setSelectedKeys([]);
|
|
1405
|
+
clearFilters();
|
|
1330
1406
|
}
|
|
1407
|
+
confirm();
|
|
1331
1408
|
}
|
|
1332
|
-
);
|
|
1409
|
+
});
|
|
1333
1410
|
break;
|
|
1334
1411
|
case "number[]":
|
|
1335
1412
|
if (!item.render)
|
|
@@ -1349,66 +1426,79 @@ function Table(props) {
|
|
|
1349
1426
|
setSelectedKeys,
|
|
1350
1427
|
confirm,
|
|
1351
1428
|
clearFilters
|
|
1352
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
setSelectedKeys([]);
|
|
1362
|
-
clearFilters();
|
|
1363
|
-
}
|
|
1364
|
-
confirm();
|
|
1429
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1430
|
+
placeholder: `${common2.search} ${item.title}`,
|
|
1431
|
+
allowClear: true,
|
|
1432
|
+
onSearch: (v) => {
|
|
1433
|
+
if (v) {
|
|
1434
|
+
setSelectedKeys([Number(v)]);
|
|
1435
|
+
} else {
|
|
1436
|
+
setSelectedKeys([]);
|
|
1437
|
+
clearFilters();
|
|
1365
1438
|
}
|
|
1439
|
+
confirm();
|
|
1366
1440
|
}
|
|
1367
|
-
);
|
|
1441
|
+
});
|
|
1368
1442
|
break;
|
|
1369
1443
|
case "boolean":
|
|
1370
1444
|
if (!item.render)
|
|
1371
|
-
item.render = (value) => isNil2(value) ? /* @__PURE__ */ jsx14(Blank, {}) : value ? /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1445
|
+
item.render = (value) => isNil2(value) ? /* @__PURE__ */ jsx14(Blank, {}) : value ? /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1446
|
+
style: {
|
|
1447
|
+
marginTop: "4px",
|
|
1448
|
+
color: "#52c41a"
|
|
1449
|
+
}
|
|
1450
|
+
}) : /* @__PURE__ */ jsx14(CloseOutlined2, {
|
|
1451
|
+
style: {
|
|
1452
|
+
marginTop: "4px",
|
|
1453
|
+
color: "#ff4d4f"
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1378
1456
|
if (item.filterDropdown !== false)
|
|
1379
1457
|
item.filterDropdown = ({
|
|
1380
1458
|
setSelectedKeys,
|
|
1381
1459
|
selectedKeys,
|
|
1382
1460
|
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
|
-
|
|
1461
|
+
}) => /* @__PURE__ */ jsxs5(Radio.Group, {
|
|
1462
|
+
style: { padding: 8 },
|
|
1463
|
+
buttonStyle: "solid",
|
|
1464
|
+
value: JSON.stringify(selectedKeys[0]),
|
|
1465
|
+
onChange: (e) => {
|
|
1466
|
+
const Values = {
|
|
1467
|
+
true: true,
|
|
1468
|
+
false: false,
|
|
1469
|
+
null: null
|
|
1470
|
+
};
|
|
1471
|
+
setSelectedKeys(e.target.value ? [Values[e.target.value]] : []);
|
|
1472
|
+
confirm();
|
|
1473
|
+
},
|
|
1474
|
+
children: [
|
|
1475
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1476
|
+
children: common2.all
|
|
1477
|
+
}),
|
|
1478
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1479
|
+
value: "true",
|
|
1480
|
+
children: /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1481
|
+
style: {
|
|
1482
|
+
color: "#52c41a",
|
|
1483
|
+
verticalAlign: "middle"
|
|
1484
|
+
}
|
|
1485
|
+
})
|
|
1486
|
+
}),
|
|
1487
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1488
|
+
value: "false",
|
|
1489
|
+
children: /* @__PURE__ */ jsx14(CloseOutlined2, {
|
|
1490
|
+
style: {
|
|
1491
|
+
verticalAlign: "middle",
|
|
1492
|
+
color: "#ff4d4f"
|
|
1493
|
+
}
|
|
1494
|
+
})
|
|
1495
|
+
}),
|
|
1496
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1497
|
+
value: "null",
|
|
1498
|
+
children: common2.blank
|
|
1499
|
+
})
|
|
1500
|
+
]
|
|
1501
|
+
});
|
|
1412
1502
|
if (!item.onFilter)
|
|
1413
1503
|
item.onFilter = (value, row) => {
|
|
1414
1504
|
switch (value) {
|
|
@@ -1436,15 +1526,12 @@ function Table(props) {
|
|
|
1436
1526
|
item.filterDropdown = ({
|
|
1437
1527
|
setSelectedKeys,
|
|
1438
1528
|
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
|
-
}
|
|
1529
|
+
}) => /* @__PURE__ */ jsx14(DatePicker2.RangePicker, {
|
|
1530
|
+
onChange: (dates) => {
|
|
1531
|
+
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1532
|
+
confirm();
|
|
1446
1533
|
}
|
|
1447
|
-
);
|
|
1534
|
+
});
|
|
1448
1535
|
if (!item.onFilter)
|
|
1449
1536
|
item.onFilter = (value, row) => {
|
|
1450
1537
|
if (isNil2(value[0]))
|
|
@@ -1469,15 +1556,12 @@ function Table(props) {
|
|
|
1469
1556
|
item.filterDropdown = ({
|
|
1470
1557
|
setSelectedKeys,
|
|
1471
1558
|
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
|
-
}
|
|
1559
|
+
}) => /* @__PURE__ */ jsx14(DatePicker2.RangePicker, {
|
|
1560
|
+
onChange: (dates) => {
|
|
1561
|
+
setSelectedKeys(dates && dates[0] && dates[1] ? [[dates[0].startOf("day").toISOString(), dates[1].endOf("day").toISOString()]] : []);
|
|
1562
|
+
confirm();
|
|
1479
1563
|
}
|
|
1480
|
-
);
|
|
1564
|
+
});
|
|
1481
1565
|
if (!item.onFilter)
|
|
1482
1566
|
item.onFilter = (value, row) => {
|
|
1483
1567
|
if (isNil2(value[0]))
|
|
@@ -1489,26 +1573,21 @@ function Table(props) {
|
|
|
1489
1573
|
break;
|
|
1490
1574
|
case "object":
|
|
1491
1575
|
if (!item.render)
|
|
1492
|
-
item.render = (value) => /* @__PURE__ */ jsx14(
|
|
1493
|
-
|
|
1494
|
-
{
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
column: 1
|
|
1498
|
-
}
|
|
1499
|
-
);
|
|
1576
|
+
item.render = (value) => /* @__PURE__ */ jsx14(Description, {
|
|
1577
|
+
items: item.object,
|
|
1578
|
+
dataSource: value || {},
|
|
1579
|
+
column: 1
|
|
1580
|
+
});
|
|
1500
1581
|
break;
|
|
1501
1582
|
case "object[]":
|
|
1502
1583
|
if (!item.render)
|
|
1503
|
-
item.render = (value) => /* @__PURE__ */ jsx14(Fragment5, {
|
|
1504
|
-
Description,
|
|
1505
|
-
{
|
|
1584
|
+
item.render = (value) => /* @__PURE__ */ jsx14(Fragment5, {
|
|
1585
|
+
children: value.map((v, i) => /* @__PURE__ */ jsx14(Description, {
|
|
1506
1586
|
items: item.object,
|
|
1507
1587
|
dataSource: v || [],
|
|
1508
1588
|
column: 1
|
|
1509
|
-
},
|
|
1510
|
-
|
|
1511
|
-
)) });
|
|
1589
|
+
}, i))
|
|
1590
|
+
});
|
|
1512
1591
|
break;
|
|
1513
1592
|
default:
|
|
1514
1593
|
if (!item.render)
|
|
@@ -1524,64 +1603,21 @@ function Table(props) {
|
|
|
1524
1603
|
}
|
|
1525
1604
|
setColumns(props.items);
|
|
1526
1605
|
}, [props.items]);
|
|
1527
|
-
|
|
1606
|
+
useEffect6(() => {
|
|
1528
1607
|
if (!props.dataSource || !columns)
|
|
1529
1608
|
return;
|
|
1530
1609
|
for (const column of columns) {
|
|
1531
1610
|
if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1532
|
-
const
|
|
1533
|
-
|
|
1611
|
+
const options = uniqBy(props.dataSource, column.id).map((v) => ({
|
|
1612
|
+
label: v[column.id],
|
|
1534
1613
|
value: v[column.id]
|
|
1535
1614
|
}));
|
|
1536
|
-
if (
|
|
1615
|
+
if (options.length)
|
|
1537
1616
|
setColumns((prev) => {
|
|
1538
1617
|
const newColumns = [...prev];
|
|
1539
1618
|
const index = newColumns.findIndex((item) => item.id === column.id);
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
text: /* @__PURE__ */ jsx14(Blank, {}),
|
|
1543
|
-
value: null
|
|
1544
|
-
});
|
|
1545
|
-
else
|
|
1546
|
-
newColumns[index].filterDropdown = ({
|
|
1547
|
-
setSelectedKeys,
|
|
1548
|
-
selectedKeys,
|
|
1549
|
-
confirm
|
|
1550
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1551
|
-
"div",
|
|
1552
|
-
{
|
|
1553
|
-
style: {
|
|
1554
|
-
padding: 8,
|
|
1555
|
-
width: "200px"
|
|
1556
|
-
},
|
|
1557
|
-
onKeyDown: (e) => e.stopPropagation(),
|
|
1558
|
-
children: /* @__PURE__ */ jsx14(
|
|
1559
|
-
Select2,
|
|
1560
|
-
{
|
|
1561
|
-
options: filters.map((f) => ({
|
|
1562
|
-
label: f.text,
|
|
1563
|
-
value: f.value
|
|
1564
|
-
})),
|
|
1565
|
-
allowClear: true,
|
|
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
|
-
);
|
|
1619
|
+
newColumns[index].options = options;
|
|
1620
|
+
generateFilterDropdown(newColumns[index]);
|
|
1585
1621
|
return newColumns;
|
|
1586
1622
|
});
|
|
1587
1623
|
}
|
|
@@ -1590,26 +1626,19 @@ function Table(props) {
|
|
|
1590
1626
|
if (!columns)
|
|
1591
1627
|
return null;
|
|
1592
1628
|
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
|
-
)
|
|
1629
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1630
|
+
...props,
|
|
1631
|
+
rowKey: props.rowKey || "id",
|
|
1632
|
+
columns,
|
|
1633
|
+
dataSource: props.dataSource
|
|
1634
|
+
});
|
|
1635
|
+
return /* @__PURE__ */ jsx14(FaasDataWrapper, {
|
|
1636
|
+
...props.faasData,
|
|
1637
|
+
children: /* @__PURE__ */ jsx14(FaasDataTable, {
|
|
1638
|
+
props,
|
|
1639
|
+
columns
|
|
1611
1640
|
})
|
|
1612
|
-
);
|
|
1641
|
+
});
|
|
1613
1642
|
}
|
|
1614
1643
|
function FaasDataTable({
|
|
1615
1644
|
props,
|
|
@@ -1618,8 +1647,8 @@ function FaasDataTable({
|
|
|
1618
1647
|
params,
|
|
1619
1648
|
reload
|
|
1620
1649
|
}) {
|
|
1621
|
-
const [currentColumns, setCurrentColumns] =
|
|
1622
|
-
|
|
1650
|
+
const [currentColumns, setCurrentColumns] = useState7(columns);
|
|
1651
|
+
useEffect6(() => {
|
|
1623
1652
|
if (!data || Array.isArray(data))
|
|
1624
1653
|
return;
|
|
1625
1654
|
setCurrentColumns((prev) => {
|
|
@@ -1655,75 +1684,75 @@ function FaasDataTable({
|
|
|
1655
1684
|
});
|
|
1656
1685
|
}, [columns, data]);
|
|
1657
1686
|
if (!data)
|
|
1658
|
-
return /* @__PURE__ */ jsx14(
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
})
|
|
1665
|
-
);
|
|
1687
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1688
|
+
...props,
|
|
1689
|
+
rowKey: props.rowKey || "id",
|
|
1690
|
+
columns: currentColumns,
|
|
1691
|
+
dataSource: []
|
|
1692
|
+
});
|
|
1666
1693
|
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), {
|
|
1694
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1695
|
+
...props,
|
|
1678
1696
|
rowKey: props.rowKey || "id",
|
|
1679
1697
|
columns: currentColumns,
|
|
1680
|
-
dataSource: data
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1698
|
+
dataSource: data
|
|
1699
|
+
});
|
|
1700
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1701
|
+
...props,
|
|
1702
|
+
rowKey: props.rowKey || "id",
|
|
1703
|
+
columns: currentColumns,
|
|
1704
|
+
dataSource: data.rows,
|
|
1705
|
+
pagination: {
|
|
1706
|
+
...props.pagination,
|
|
1707
|
+
...data.pagination
|
|
1708
|
+
},
|
|
1709
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
1710
|
+
if (props.onChange) {
|
|
1711
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1712
|
+
reload({
|
|
1713
|
+
...params,
|
|
1714
|
+
pagination: processed.pagination,
|
|
1715
|
+
filters: processed.filters,
|
|
1716
|
+
sorter: processed.sorter
|
|
1717
|
+
});
|
|
1718
|
+
return;
|
|
1697
1719
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1720
|
+
reload({
|
|
1721
|
+
...params,
|
|
1722
|
+
pagination,
|
|
1723
|
+
filters,
|
|
1724
|
+
sorter
|
|
1725
|
+
});
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1700
1728
|
}
|
|
1701
1729
|
|
|
1702
1730
|
// src/Title.tsx
|
|
1703
|
-
import { useEffect as
|
|
1731
|
+
import { useEffect as useEffect7, cloneElement as cloneElement4 } from "react";
|
|
1704
1732
|
import { Fragment as Fragment6, jsx as jsx15 } from "react/jsx-runtime";
|
|
1705
1733
|
function Title(props) {
|
|
1706
1734
|
const { Title: Title2 } = useConfigContext();
|
|
1707
|
-
|
|
1735
|
+
useEffect7(() => {
|
|
1708
1736
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1709
1737
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1710
1738
|
}, [props]);
|
|
1711
1739
|
if (props.h1) {
|
|
1712
1740
|
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,
|
|
1741
|
+
return /* @__PURE__ */ jsx15("h1", {
|
|
1719
1742
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1720
|
-
}
|
|
1721
|
-
|
|
1743
|
+
});
|
|
1744
|
+
return /* @__PURE__ */ jsx15("h1", {
|
|
1745
|
+
className: props.h1.className,
|
|
1746
|
+
style: props.h1.style,
|
|
1747
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1748
|
+
});
|
|
1722
1749
|
}
|
|
1723
1750
|
if (props.plain)
|
|
1724
|
-
return /* @__PURE__ */ jsx15(Fragment6, {
|
|
1751
|
+
return /* @__PURE__ */ jsx15(Fragment6, {
|
|
1752
|
+
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1753
|
+
});
|
|
1725
1754
|
if (props.children)
|
|
1726
|
-
return
|
|
1755
|
+
return cloneElement4(props.children, { title: props.title });
|
|
1727
1756
|
return null;
|
|
1728
1757
|
}
|
|
1729
1758
|
export {
|
|
@@ -1734,7 +1763,7 @@ export {
|
|
|
1734
1763
|
Description,
|
|
1735
1764
|
Drawer,
|
|
1736
1765
|
ErrorBoundary,
|
|
1737
|
-
|
|
1766
|
+
FaasDataWrapper,
|
|
1738
1767
|
Form,
|
|
1739
1768
|
FormItem,
|
|
1740
1769
|
Link,
|