@faasjs/ant-design 0.0.3-beta.6 → 0.0.3-beta.61
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 +199 -271
- package/dist/index.d.ts +342 -249
- package/dist/index.js +683 -359
- package/dist/index.mjs +732 -406
- package/package.json +7 -5
package/dist/index.mjs
CHANGED
|
@@ -1,20 +1,157 @@
|
|
|
1
1
|
// react-shim.js
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
|
+
// src/App.tsx
|
|
5
|
+
import {
|
|
6
|
+
ConfigProvider,
|
|
7
|
+
message,
|
|
8
|
+
notification
|
|
9
|
+
} from "antd";
|
|
10
|
+
import { StyleProvider, legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";
|
|
11
|
+
import {
|
|
12
|
+
createContext,
|
|
13
|
+
useContext,
|
|
14
|
+
useEffect,
|
|
15
|
+
useMemo
|
|
16
|
+
} from "react";
|
|
17
|
+
|
|
18
|
+
// src/Modal.tsx
|
|
19
|
+
import { Modal } from "antd";
|
|
20
|
+
import { useState } from "react";
|
|
21
|
+
import { jsx } from "react/jsx-runtime";
|
|
22
|
+
function useModal(init) {
|
|
23
|
+
const [props, setProps] = useState({
|
|
24
|
+
open: false,
|
|
25
|
+
onCancel: () => setProps((prev) => ({
|
|
26
|
+
...prev,
|
|
27
|
+
open: false
|
|
28
|
+
})),
|
|
29
|
+
...init
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
modal: /* @__PURE__ */ jsx(Modal, {
|
|
33
|
+
...props
|
|
34
|
+
}),
|
|
35
|
+
modalProps: props,
|
|
36
|
+
setModalProps(changes) {
|
|
37
|
+
setProps((prev) => ({
|
|
38
|
+
...prev,
|
|
39
|
+
...changes
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/Drawer.tsx
|
|
46
|
+
import { Drawer } from "antd";
|
|
47
|
+
import { useState as useState2 } from "react";
|
|
48
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
49
|
+
function useDrawer(init) {
|
|
50
|
+
const [props, setProps] = useState2({
|
|
51
|
+
open: false,
|
|
52
|
+
onClose: () => setProps((prev) => ({
|
|
53
|
+
...prev,
|
|
54
|
+
open: false
|
|
55
|
+
})),
|
|
56
|
+
...init
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
drawer: /* @__PURE__ */ jsx2(Drawer, {
|
|
60
|
+
...props
|
|
61
|
+
}),
|
|
62
|
+
drawerProps: props,
|
|
63
|
+
setDrawerProps(changes) {
|
|
64
|
+
setProps((prev) => ({
|
|
65
|
+
...prev,
|
|
66
|
+
...changes
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/App.tsx
|
|
73
|
+
import { BrowserRouter, useLocation } from "react-router-dom";
|
|
74
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
75
|
+
var AppContext = createContext({
|
|
76
|
+
message: {},
|
|
77
|
+
notification: {},
|
|
78
|
+
setModalProps: () => void 0,
|
|
79
|
+
setDrawerProps: () => void 0
|
|
80
|
+
});
|
|
81
|
+
function RoutesApp(props) {
|
|
82
|
+
const location = useLocation();
|
|
83
|
+
const { setDrawerProps, setModalProps } = useApp();
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
console.debug("location", location);
|
|
86
|
+
setDrawerProps({ open: false });
|
|
87
|
+
setModalProps({ open: false });
|
|
88
|
+
}, [location]);
|
|
89
|
+
return /* @__PURE__ */ jsx3(Fragment, {
|
|
90
|
+
children: props.children
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function App(props) {
|
|
94
|
+
const [messageApi, messageContextHolder] = message.useMessage();
|
|
95
|
+
const [notificationApi, notificationContextHolder] = notification.useNotification();
|
|
96
|
+
const { modal, setModalProps } = useModal();
|
|
97
|
+
const { drawer, setDrawerProps } = useDrawer();
|
|
98
|
+
const memoizedContextValue = useMemo(
|
|
99
|
+
() => ({
|
|
100
|
+
message: messageApi,
|
|
101
|
+
notification: notificationApi,
|
|
102
|
+
setModalProps,
|
|
103
|
+
setDrawerProps
|
|
104
|
+
}),
|
|
105
|
+
[
|
|
106
|
+
messageApi,
|
|
107
|
+
notificationApi,
|
|
108
|
+
setModalProps,
|
|
109
|
+
setDrawerProps
|
|
110
|
+
]
|
|
111
|
+
);
|
|
112
|
+
return /* @__PURE__ */ jsx3(StyleProvider, {
|
|
113
|
+
...Object.assign(props.styleProviderProps || {}, {
|
|
114
|
+
hashPriority: "high",
|
|
115
|
+
transformers: [legacyLogicalPropertiesTransformer]
|
|
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
|
+
})
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function useApp() {
|
|
138
|
+
return useContext(AppContext);
|
|
139
|
+
}
|
|
140
|
+
App.useApp = useApp;
|
|
141
|
+
|
|
4
142
|
// src/Blank.tsx
|
|
5
143
|
import { Typography } from "antd";
|
|
6
144
|
import { isNil } from "lodash-es";
|
|
7
145
|
|
|
8
146
|
// src/Config.tsx
|
|
9
147
|
import {
|
|
10
|
-
createContext,
|
|
11
|
-
useContext,
|
|
12
|
-
useEffect,
|
|
13
|
-
useState
|
|
148
|
+
createContext as createContext2,
|
|
149
|
+
useContext as useContext2,
|
|
150
|
+
useEffect as useEffect2,
|
|
151
|
+
useState as useState3
|
|
14
152
|
} from "react";
|
|
15
|
-
import { ConfigProvider as AntdConfigProvider } from "antd";
|
|
16
153
|
import { defaultsDeep } from "lodash-es";
|
|
17
|
-
import { jsx } from "react/jsx-runtime";
|
|
154
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
18
155
|
var isZH = /^zh/i.test(navigator.language);
|
|
19
156
|
var zh = {
|
|
20
157
|
lang: "zh",
|
|
@@ -53,13 +190,13 @@ var baseConfig = {
|
|
|
53
190
|
},
|
|
54
191
|
Link: { style: {} }
|
|
55
192
|
};
|
|
56
|
-
var ConfigContext =
|
|
57
|
-
function
|
|
193
|
+
var ConfigContext = createContext2(baseConfig);
|
|
194
|
+
function ConfigProvider2({
|
|
58
195
|
config,
|
|
59
196
|
children
|
|
60
197
|
}) {
|
|
61
|
-
const [values, setValues] =
|
|
62
|
-
|
|
198
|
+
const [values, setValues] = useState3(baseConfig);
|
|
199
|
+
useEffect2(() => {
|
|
63
200
|
if (config.lang === "zh") {
|
|
64
201
|
setValues(defaultsDeep(config, {
|
|
65
202
|
lang: "zh",
|
|
@@ -68,25 +205,22 @@ function ConfigProvider({
|
|
|
68
205
|
Form: { submit: { text: zh.submit } }
|
|
69
206
|
}, baseConfig));
|
|
70
207
|
} else
|
|
71
|
-
setValues(values);
|
|
208
|
+
setValues(defaultsDeep(config, values));
|
|
72
209
|
}, []);
|
|
73
|
-
return /* @__PURE__ */
|
|
210
|
+
return /* @__PURE__ */ jsx4(ConfigContext.Provider, {
|
|
74
211
|
value: values,
|
|
75
|
-
children
|
|
76
|
-
...config.antd,
|
|
77
|
-
children
|
|
78
|
-
})
|
|
212
|
+
children
|
|
79
213
|
});
|
|
80
214
|
}
|
|
81
215
|
function useConfigContext() {
|
|
82
|
-
return
|
|
216
|
+
return useContext2(ConfigContext);
|
|
83
217
|
}
|
|
84
218
|
|
|
85
219
|
// src/Blank.tsx
|
|
86
|
-
import { jsx as
|
|
220
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
87
221
|
function Blank(options) {
|
|
88
222
|
const { Blank: Blank2 } = useConfigContext();
|
|
89
|
-
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */
|
|
223
|
+
return !options || isNil(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ jsx5(Typography.Text, {
|
|
90
224
|
disabled: true,
|
|
91
225
|
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
92
226
|
}) : options.value;
|
|
@@ -123,21 +257,57 @@ function transferValue(type, value) {
|
|
|
123
257
|
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
124
258
|
import {
|
|
125
259
|
Descriptions,
|
|
126
|
-
Skeleton,
|
|
127
260
|
Space
|
|
128
261
|
} from "antd";
|
|
129
262
|
import { isFunction, upperFirst as upperFirst2 } from "lodash-es";
|
|
130
263
|
import {
|
|
131
264
|
cloneElement,
|
|
132
|
-
useEffect as
|
|
133
|
-
useState as
|
|
265
|
+
useEffect as useEffect3,
|
|
266
|
+
useState as useState4
|
|
134
267
|
} from "react";
|
|
135
|
-
|
|
136
|
-
|
|
268
|
+
|
|
269
|
+
// src/FaasDataWrapper.tsx
|
|
270
|
+
import { FaasDataWrapper as Origin } from "@faasjs/react";
|
|
271
|
+
|
|
272
|
+
// src/Loading.tsx
|
|
273
|
+
import { Spin } from "antd";
|
|
274
|
+
import { Fragment as Fragment2, jsx as jsx6 } from "react/jsx-runtime";
|
|
275
|
+
function Loading(props) {
|
|
276
|
+
if (props.loading === false)
|
|
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
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/FaasDataWrapper.tsx
|
|
295
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
296
|
+
function FaasDataWrapper(props) {
|
|
297
|
+
return /* @__PURE__ */ jsx7(Origin, {
|
|
298
|
+
fallback: props.loading || /* @__PURE__ */ jsx7(Loading, {
|
|
299
|
+
...props.loadingProps
|
|
300
|
+
}),
|
|
301
|
+
...props
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/Description.tsx
|
|
306
|
+
import { Fragment as Fragment3, jsx as jsx8 } from "react/jsx-runtime";
|
|
137
307
|
function DescriptionItemContent(props) {
|
|
138
308
|
var _a;
|
|
139
|
-
const [computedProps, setComputedProps] =
|
|
140
|
-
|
|
309
|
+
const [computedProps, setComputedProps] = useState4();
|
|
310
|
+
useEffect3(() => {
|
|
141
311
|
var _a2, _b;
|
|
142
312
|
const propsCopy = { ...props };
|
|
143
313
|
if (!propsCopy.item.title)
|
|
@@ -170,69 +340,84 @@ function DescriptionItemContent(props) {
|
|
|
170
340
|
return cloneElement(
|
|
171
341
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
172
342
|
{
|
|
343
|
+
scene: "description",
|
|
173
344
|
value: computedProps.value,
|
|
174
345
|
values: computedProps.values
|
|
175
346
|
}
|
|
176
347
|
);
|
|
177
348
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
178
|
-
return /* @__PURE__ */
|
|
179
|
-
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
|
|
349
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
350
|
+
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
|
|
180
351
|
});
|
|
181
352
|
else
|
|
182
353
|
throw Error(computedProps.item.type + " requires children or render");
|
|
354
|
+
if (computedProps.item.descriptionChildren === null)
|
|
355
|
+
return null;
|
|
356
|
+
if (computedProps.item.descriptionChildren)
|
|
357
|
+
return cloneElement(computedProps.item.descriptionChildren, {
|
|
358
|
+
scene: "description",
|
|
359
|
+
value: computedProps.value,
|
|
360
|
+
values: computedProps.values
|
|
361
|
+
});
|
|
362
|
+
if (computedProps.item.children === null)
|
|
363
|
+
return null;
|
|
183
364
|
if (computedProps.item.children)
|
|
184
|
-
return cloneElement(computedProps.item.children, {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
365
|
+
return cloneElement(computedProps.item.children, {
|
|
366
|
+
scene: "description",
|
|
367
|
+
value: computedProps.value,
|
|
368
|
+
values: computedProps.values
|
|
188
369
|
});
|
|
370
|
+
if (computedProps.item.descriptionRender)
|
|
371
|
+
return computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description");
|
|
372
|
+
if (computedProps.item.render)
|
|
373
|
+
return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
|
|
189
374
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
190
|
-
return /* @__PURE__ */
|
|
375
|
+
return /* @__PURE__ */ jsx8(Blank, {});
|
|
191
376
|
switch (computedProps.item.type) {
|
|
192
377
|
case "string[]":
|
|
193
|
-
return /* @__PURE__ */
|
|
378
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
194
379
|
children: computedProps.value.join(", ")
|
|
195
380
|
});
|
|
196
381
|
case "number":
|
|
197
382
|
return computedProps.value || null;
|
|
198
383
|
case "number[]":
|
|
199
|
-
return /* @__PURE__ */
|
|
384
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
200
385
|
children: computedProps.value.join(", ")
|
|
201
386
|
});
|
|
202
387
|
case "boolean":
|
|
203
|
-
return computedProps.value ? /* @__PURE__ */
|
|
388
|
+
return computedProps.value ? /* @__PURE__ */ jsx8(CheckOutlined, {
|
|
204
389
|
style: {
|
|
205
390
|
marginTop: "4px",
|
|
206
391
|
color: "#52c41a"
|
|
207
392
|
}
|
|
208
|
-
}) : /* @__PURE__ */
|
|
393
|
+
}) : /* @__PURE__ */ jsx8(CloseOutlined, {
|
|
209
394
|
style: {
|
|
210
395
|
marginTop: "4px",
|
|
211
396
|
color: "#ff4d4f"
|
|
212
397
|
}
|
|
213
398
|
});
|
|
214
399
|
case "time":
|
|
215
|
-
return /* @__PURE__ */
|
|
400
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
216
401
|
children: computedProps.value.format("YYYY-MM-DD HH:mm:ss")
|
|
217
402
|
});
|
|
218
403
|
case "date":
|
|
219
|
-
return /* @__PURE__ */
|
|
404
|
+
return /* @__PURE__ */ jsx8(Fragment3, {
|
|
220
405
|
children: computedProps.value.format("YYYY-MM-DD")
|
|
221
406
|
});
|
|
222
407
|
case "object":
|
|
223
408
|
if (!computedProps.value)
|
|
224
|
-
return /* @__PURE__ */
|
|
225
|
-
return /* @__PURE__ */
|
|
409
|
+
return /* @__PURE__ */ jsx8(Blank, {});
|
|
410
|
+
return /* @__PURE__ */ jsx8(Description, {
|
|
226
411
|
items: computedProps.item.object,
|
|
227
412
|
dataSource: computedProps.value,
|
|
228
413
|
column: 1
|
|
229
414
|
});
|
|
230
415
|
case "object[]":
|
|
231
416
|
if (!((_a = computedProps.value) == null ? void 0 : _a.length))
|
|
232
|
-
return /* @__PURE__ */
|
|
233
|
-
return /* @__PURE__ */
|
|
417
|
+
return /* @__PURE__ */ jsx8(Blank, {});
|
|
418
|
+
return /* @__PURE__ */ jsx8(Space, {
|
|
234
419
|
direction: "vertical",
|
|
235
|
-
children: computedProps.value.map((value, index) => /* @__PURE__ */
|
|
420
|
+
children: computedProps.value.map((value, index) => /* @__PURE__ */ jsx8(Description, {
|
|
236
421
|
items: computedProps.item.object,
|
|
237
422
|
dataSource: value,
|
|
238
423
|
column: 1
|
|
@@ -243,14 +428,14 @@ function DescriptionItemContent(props) {
|
|
|
243
428
|
}
|
|
244
429
|
}
|
|
245
430
|
function Description(props) {
|
|
246
|
-
if (
|
|
247
|
-
return /* @__PURE__ */
|
|
431
|
+
if (props.dataSource)
|
|
432
|
+
return /* @__PURE__ */ jsx8(Descriptions, {
|
|
248
433
|
...props,
|
|
249
434
|
title: isFunction(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
250
435
|
children: props.items.map((item) => {
|
|
251
|
-
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */
|
|
436
|
+
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
|
|
252
437
|
label: item.title || upperFirst2(item.id),
|
|
253
|
-
children: /* @__PURE__ */
|
|
438
|
+
children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
|
|
254
439
|
item,
|
|
255
440
|
value: props.dataSource[item.id],
|
|
256
441
|
values: props.dataSource,
|
|
@@ -259,18 +444,15 @@ function Description(props) {
|
|
|
259
444
|
}, item.id) : null;
|
|
260
445
|
}).filter(Boolean)
|
|
261
446
|
});
|
|
262
|
-
return /* @__PURE__ */
|
|
263
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ jsx3(Skeleton, {
|
|
264
|
-
active: true
|
|
265
|
-
}),
|
|
447
|
+
return /* @__PURE__ */ jsx8(FaasDataWrapper, {
|
|
266
448
|
render: ({ data }) => {
|
|
267
|
-
return /* @__PURE__ */
|
|
449
|
+
return /* @__PURE__ */ jsx8(Descriptions, {
|
|
268
450
|
...props,
|
|
269
451
|
title: isFunction(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
270
452
|
children: props.items.map((item) => {
|
|
271
|
-
return !item.if || item.if(data) ? /* @__PURE__ */
|
|
453
|
+
return !item.if || item.if(data) ? /* @__PURE__ */ jsx8(Descriptions.Item, {
|
|
272
454
|
label: item.title || upperFirst2(item.id),
|
|
273
|
-
children: /* @__PURE__ */
|
|
455
|
+
children: /* @__PURE__ */ jsx8(DescriptionItemContent, {
|
|
274
456
|
item,
|
|
275
457
|
value: data[item.id],
|
|
276
458
|
values: data,
|
|
@@ -284,32 +466,52 @@ function Description(props) {
|
|
|
284
466
|
});
|
|
285
467
|
}
|
|
286
468
|
|
|
287
|
-
// src/
|
|
288
|
-
import {
|
|
289
|
-
import {
|
|
290
|
-
import { jsx as
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
469
|
+
// src/ErrorBoundary.tsx
|
|
470
|
+
import { Component } from "react";
|
|
471
|
+
import { Alert } from "antd";
|
|
472
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
473
|
+
var ErrorBoundary = class extends Component {
|
|
474
|
+
constructor(props) {
|
|
475
|
+
super(props);
|
|
476
|
+
this.state = {
|
|
477
|
+
error: void 0,
|
|
478
|
+
info: { componentStack: "" }
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
componentDidCatch(error, info) {
|
|
482
|
+
this.setState({
|
|
483
|
+
error,
|
|
484
|
+
info
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
render() {
|
|
488
|
+
const {
|
|
489
|
+
message: message2,
|
|
490
|
+
description,
|
|
491
|
+
children
|
|
492
|
+
} = this.props;
|
|
493
|
+
const { error, info } = this.state;
|
|
494
|
+
const componentStack = info && info.componentStack ? info.componentStack : null;
|
|
495
|
+
const errorMessage = typeof message2 === "undefined" ? (error || "").toString() : message2;
|
|
496
|
+
const errorDescription = typeof description === "undefined" ? componentStack : description;
|
|
497
|
+
if (error) {
|
|
498
|
+
if (this.props.onError)
|
|
499
|
+
return this.props.onError(error, info);
|
|
500
|
+
return /* @__PURE__ */ jsx9(Alert, {
|
|
501
|
+
type: "error",
|
|
502
|
+
message: errorMessage,
|
|
503
|
+
description: /* @__PURE__ */ jsx9("pre", {
|
|
504
|
+
style: {
|
|
505
|
+
fontSize: "0.9em",
|
|
506
|
+
overflowX: "auto"
|
|
507
|
+
},
|
|
508
|
+
children: errorDescription
|
|
509
|
+
})
|
|
510
|
+
});
|
|
310
511
|
}
|
|
311
|
-
|
|
312
|
-
}
|
|
512
|
+
return children;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
313
515
|
|
|
314
516
|
// src/Form.tsx
|
|
315
517
|
import { faas } from "@faasjs/react";
|
|
@@ -318,8 +520,8 @@ import {
|
|
|
318
520
|
Form as AntdForm2
|
|
319
521
|
} from "antd";
|
|
320
522
|
import {
|
|
321
|
-
useEffect as
|
|
322
|
-
useState as
|
|
523
|
+
useEffect as useEffect5,
|
|
524
|
+
useState as useState6,
|
|
323
525
|
useCallback,
|
|
324
526
|
isValidElement
|
|
325
527
|
} from "react";
|
|
@@ -339,11 +541,12 @@ import {
|
|
|
339
541
|
} from "antd";
|
|
340
542
|
import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons";
|
|
341
543
|
import {
|
|
342
|
-
|
|
343
|
-
|
|
544
|
+
cloneElement as cloneElement2,
|
|
545
|
+
useEffect as useEffect4,
|
|
546
|
+
useState as useState5
|
|
344
547
|
} from "react";
|
|
345
548
|
import { upperFirst as upperFirst3 } from "lodash-es";
|
|
346
|
-
import { Fragment as
|
|
549
|
+
import { Fragment as Fragment4, jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
347
550
|
function processProps(propsCopy, config) {
|
|
348
551
|
if (!propsCopy.title)
|
|
349
552
|
propsCopy.title = upperFirst3(propsCopy.id);
|
|
@@ -392,11 +595,11 @@ function processProps(propsCopy, config) {
|
|
|
392
595
|
}
|
|
393
596
|
function FormItem(props) {
|
|
394
597
|
var _a;
|
|
395
|
-
const [computedProps, setComputedProps] =
|
|
396
|
-
const [extendTypes, setExtendTypes] =
|
|
598
|
+
const [computedProps, setComputedProps] = useState5();
|
|
599
|
+
const [extendTypes, setExtendTypes] = useState5();
|
|
397
600
|
const { common: common2 } = useConfigContext();
|
|
398
|
-
const [hidden, setHidden] =
|
|
399
|
-
|
|
601
|
+
const [hidden, setHidden] = useState5(props.hidden || false);
|
|
602
|
+
useEffect4(() => {
|
|
400
603
|
const propsCopy = { ...props };
|
|
401
604
|
if (propsCopy.extendTypes) {
|
|
402
605
|
setExtendTypes(propsCopy.extendTypes);
|
|
@@ -404,98 +607,116 @@ function FormItem(props) {
|
|
|
404
607
|
}
|
|
405
608
|
if (propsCopy.if) {
|
|
406
609
|
const condition = propsCopy.if;
|
|
407
|
-
propsCopy.shouldUpdate
|
|
610
|
+
const originShouldUpdate = propsCopy.shouldUpdate;
|
|
611
|
+
propsCopy.shouldUpdate = (prev, cur) => {
|
|
408
612
|
const show = condition(cur);
|
|
613
|
+
const shouldUpdate = hidden !== show;
|
|
409
614
|
setHidden(!show);
|
|
410
|
-
|
|
615
|
+
const origin = originShouldUpdate ? typeof originShouldUpdate === "boolean" ? originShouldUpdate : originShouldUpdate(prev, cur, {}) : true;
|
|
616
|
+
return shouldUpdate || origin;
|
|
411
617
|
};
|
|
412
618
|
delete propsCopy.if;
|
|
619
|
+
delete propsCopy.hidden;
|
|
413
620
|
}
|
|
414
621
|
setComputedProps(processProps(propsCopy, common2));
|
|
415
622
|
}, [props]);
|
|
416
623
|
if (!computedProps)
|
|
417
624
|
return null;
|
|
418
625
|
if (hidden)
|
|
419
|
-
return /* @__PURE__ */
|
|
626
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
420
627
|
...computedProps,
|
|
421
628
|
noStyle: true,
|
|
422
629
|
rules: [],
|
|
423
|
-
children: /* @__PURE__ */
|
|
630
|
+
children: /* @__PURE__ */ jsx10(Input, {
|
|
424
631
|
hidden: true
|
|
425
632
|
})
|
|
426
633
|
});
|
|
427
634
|
if (extendTypes && extendTypes[computedProps.type])
|
|
428
|
-
return /* @__PURE__ */
|
|
635
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
429
636
|
...computedProps,
|
|
430
637
|
children: extendTypes[computedProps.type].children
|
|
431
638
|
});
|
|
639
|
+
if (computedProps.formChildren === null)
|
|
640
|
+
return null;
|
|
641
|
+
if (computedProps.formChildren)
|
|
642
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
643
|
+
...computedProps,
|
|
644
|
+
children: cloneElement2(computedProps.formChildren, { scene: "form" })
|
|
645
|
+
});
|
|
646
|
+
if (computedProps.children === null)
|
|
647
|
+
return null;
|
|
432
648
|
if (computedProps.children)
|
|
433
|
-
return /* @__PURE__ */
|
|
649
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
434
650
|
...computedProps,
|
|
435
|
-
children: computedProps.children
|
|
651
|
+
children: cloneElement2(computedProps.children, { scene: "form" })
|
|
652
|
+
});
|
|
653
|
+
if (computedProps.formRender)
|
|
654
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
655
|
+
...computedProps,
|
|
656
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
436
657
|
});
|
|
437
658
|
if (computedProps.render)
|
|
438
|
-
return /* @__PURE__ */
|
|
659
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
439
660
|
...computedProps,
|
|
440
|
-
children: computedProps.render()
|
|
661
|
+
children: computedProps.render(null, null, 0, "form")
|
|
441
662
|
});
|
|
442
663
|
switch (computedProps.type) {
|
|
443
664
|
case "string":
|
|
444
|
-
return /* @__PURE__ */
|
|
665
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
445
666
|
...computedProps,
|
|
446
|
-
children: computedProps.options ? /* @__PURE__ */
|
|
667
|
+
children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
|
|
447
668
|
...computedProps.input
|
|
448
|
-
}) : /* @__PURE__ */
|
|
669
|
+
}) : /* @__PURE__ */ jsx10(Input, {
|
|
449
670
|
...computedProps.input
|
|
450
671
|
})
|
|
451
672
|
});
|
|
452
673
|
case "string[]":
|
|
453
674
|
if (computedProps.options)
|
|
454
|
-
return /* @__PURE__ */
|
|
675
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
455
676
|
...computedProps,
|
|
456
|
-
children: /* @__PURE__ */
|
|
677
|
+
children: /* @__PURE__ */ jsx10(Select, {
|
|
457
678
|
mode: "multiple",
|
|
458
679
|
...computedProps.input
|
|
459
680
|
})
|
|
460
681
|
});
|
|
461
|
-
return /* @__PURE__ */
|
|
682
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
462
683
|
name: computedProps.name,
|
|
463
684
|
rules: computedProps.rules,
|
|
464
685
|
children: (fields, { add, remove }, { errors }) => {
|
|
465
686
|
var _a2;
|
|
466
|
-
return /* @__PURE__ */
|
|
687
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
467
688
|
children: [
|
|
468
|
-
computedProps.label && /* @__PURE__ */
|
|
689
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
469
690
|
className: "ant-form-item-label",
|
|
470
|
-
children: /* @__PURE__ */
|
|
691
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
471
692
|
className: computedProps.rules.find((r) => r.required) && "ant-form-item-required",
|
|
472
693
|
children: computedProps.label
|
|
473
694
|
})
|
|
474
695
|
}),
|
|
475
696
|
fields.map((field) => {
|
|
476
697
|
var _a3;
|
|
477
|
-
return /* @__PURE__ */
|
|
478
|
-
children: /* @__PURE__ */
|
|
698
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
699
|
+
children: /* @__PURE__ */ jsxs2(Row, {
|
|
479
700
|
gutter: 24,
|
|
480
701
|
style: { flexFlow: "row nowrap" },
|
|
481
702
|
children: [
|
|
482
|
-
/* @__PURE__ */
|
|
703
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
483
704
|
span: 23,
|
|
484
|
-
children: /* @__PURE__ */
|
|
705
|
+
children: /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
485
706
|
...field,
|
|
486
707
|
noStyle: true,
|
|
487
|
-
children: /* @__PURE__ */
|
|
708
|
+
children: /* @__PURE__ */ jsx10(Input, {
|
|
488
709
|
...computedProps.input
|
|
489
710
|
})
|
|
490
711
|
})
|
|
491
712
|
}),
|
|
492
|
-
/* @__PURE__ */
|
|
713
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
493
714
|
span: 1,
|
|
494
|
-
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */
|
|
715
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
495
716
|
danger: true,
|
|
496
717
|
type: "link",
|
|
497
718
|
style: { float: "right" },
|
|
498
|
-
icon: /* @__PURE__ */
|
|
719
|
+
icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
|
|
499
720
|
onClick: () => remove(field.name)
|
|
500
721
|
})
|
|
501
722
|
})
|
|
@@ -503,15 +724,19 @@ function FormItem(props) {
|
|
|
503
724
|
})
|
|
504
725
|
}, field.key);
|
|
505
726
|
}),
|
|
506
|
-
/* @__PURE__ */
|
|
727
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
507
728
|
children: [
|
|
508
|
-
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */
|
|
729
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
|
|
509
730
|
type: "dashed",
|
|
510
731
|
block: true,
|
|
511
732
|
onClick: () => add(),
|
|
512
|
-
icon: /* @__PURE__ */
|
|
733
|
+
icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
|
|
734
|
+
}),
|
|
735
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
736
|
+
className: "ant-form-item-extra",
|
|
737
|
+
children: computedProps.extra
|
|
513
738
|
}),
|
|
514
|
-
/* @__PURE__ */
|
|
739
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
515
740
|
errors
|
|
516
741
|
})
|
|
517
742
|
]
|
|
@@ -521,63 +746,63 @@ function FormItem(props) {
|
|
|
521
746
|
}
|
|
522
747
|
});
|
|
523
748
|
case "number":
|
|
524
|
-
return /* @__PURE__ */
|
|
749
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
525
750
|
...computedProps,
|
|
526
|
-
children: computedProps.options ? /* @__PURE__ */
|
|
751
|
+
children: computedProps.options ? /* @__PURE__ */ jsx10(Select, {
|
|
527
752
|
...computedProps.input
|
|
528
|
-
}) : /* @__PURE__ */
|
|
753
|
+
}) : /* @__PURE__ */ jsx10(InputNumber, {
|
|
529
754
|
style: { width: "100%" },
|
|
530
755
|
...computedProps.input
|
|
531
756
|
})
|
|
532
757
|
});
|
|
533
758
|
case "number[]":
|
|
534
759
|
if (computedProps.options)
|
|
535
|
-
return /* @__PURE__ */
|
|
760
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
536
761
|
...computedProps,
|
|
537
|
-
children: /* @__PURE__ */
|
|
762
|
+
children: /* @__PURE__ */ jsx10(Select, {
|
|
538
763
|
mode: "multiple",
|
|
539
764
|
...computedProps.input
|
|
540
765
|
})
|
|
541
766
|
});
|
|
542
|
-
return /* @__PURE__ */
|
|
767
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
543
768
|
name: computedProps.name,
|
|
544
769
|
rules: computedProps.rules,
|
|
545
770
|
children: (fields, { add, remove }, { errors }) => {
|
|
546
771
|
var _a2, _b;
|
|
547
|
-
return /* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
548
773
|
children: [
|
|
549
|
-
computedProps.label && /* @__PURE__ */
|
|
774
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
550
775
|
className: "ant-form-item-label",
|
|
551
|
-
children: /* @__PURE__ */
|
|
776
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
552
777
|
className: ((_a2 = computedProps.rules) == null ? void 0 : _a2.find((r) => r.required)) && "ant-form-item-required",
|
|
553
778
|
children: computedProps.label
|
|
554
779
|
})
|
|
555
780
|
}),
|
|
556
781
|
fields.map((field) => {
|
|
557
782
|
var _a3;
|
|
558
|
-
return /* @__PURE__ */
|
|
559
|
-
children: /* @__PURE__ */
|
|
783
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
784
|
+
children: /* @__PURE__ */ jsxs2(Row, {
|
|
560
785
|
gutter: 24,
|
|
561
786
|
style: { flexFlow: "row nowrap" },
|
|
562
787
|
children: [
|
|
563
|
-
/* @__PURE__ */
|
|
788
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
564
789
|
span: 23,
|
|
565
|
-
children: /* @__PURE__ */
|
|
790
|
+
children: /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
566
791
|
...field,
|
|
567
792
|
noStyle: true,
|
|
568
|
-
children: /* @__PURE__ */
|
|
793
|
+
children: /* @__PURE__ */ jsx10(InputNumber, {
|
|
569
794
|
style: { width: "100%" },
|
|
570
795
|
...computedProps.input
|
|
571
796
|
})
|
|
572
797
|
})
|
|
573
798
|
}),
|
|
574
|
-
/* @__PURE__ */
|
|
799
|
+
/* @__PURE__ */ jsx10(Col, {
|
|
575
800
|
span: 1,
|
|
576
|
-
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */
|
|
801
|
+
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
577
802
|
danger: true,
|
|
578
803
|
type: "link",
|
|
579
804
|
style: { float: "right" },
|
|
580
|
-
icon: /* @__PURE__ */
|
|
805
|
+
icon: /* @__PURE__ */ jsx10(MinusCircleOutlined, {}),
|
|
581
806
|
onClick: () => remove(field.name)
|
|
582
807
|
})
|
|
583
808
|
})
|
|
@@ -585,15 +810,19 @@ function FormItem(props) {
|
|
|
585
810
|
})
|
|
586
811
|
}, field.key);
|
|
587
812
|
}),
|
|
588
|
-
/* @__PURE__ */
|
|
813
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
589
814
|
children: [
|
|
590
|
-
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */
|
|
815
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsx10(Button, {
|
|
591
816
|
type: "dashed",
|
|
592
817
|
block: true,
|
|
593
818
|
onClick: () => add(),
|
|
594
|
-
icon: /* @__PURE__ */
|
|
819
|
+
icon: /* @__PURE__ */ jsx10(PlusOutlined, {})
|
|
595
820
|
}),
|
|
596
|
-
/* @__PURE__ */
|
|
821
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
822
|
+
className: "ant-form-item-extra",
|
|
823
|
+
children: computedProps.extra
|
|
824
|
+
}),
|
|
825
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
597
826
|
errors
|
|
598
827
|
})
|
|
599
828
|
]
|
|
@@ -603,58 +832,58 @@ function FormItem(props) {
|
|
|
603
832
|
}
|
|
604
833
|
});
|
|
605
834
|
case "boolean":
|
|
606
|
-
return /* @__PURE__ */
|
|
835
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
607
836
|
...computedProps,
|
|
608
|
-
children: /* @__PURE__ */
|
|
837
|
+
children: /* @__PURE__ */ jsx10(Switch, {
|
|
609
838
|
...computedProps.input
|
|
610
839
|
})
|
|
611
840
|
});
|
|
612
841
|
case "date":
|
|
613
|
-
return /* @__PURE__ */
|
|
842
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
614
843
|
...computedProps,
|
|
615
|
-
children: /* @__PURE__ */
|
|
844
|
+
children: /* @__PURE__ */ jsx10(DatePicker, {
|
|
616
845
|
...computedProps.input
|
|
617
846
|
})
|
|
618
847
|
});
|
|
619
848
|
case "time":
|
|
620
|
-
return /* @__PURE__ */
|
|
849
|
+
return /* @__PURE__ */ jsx10(AntdForm.Item, {
|
|
621
850
|
...computedProps,
|
|
622
|
-
children: /* @__PURE__ */
|
|
851
|
+
children: /* @__PURE__ */ jsx10(TimePicker, {
|
|
623
852
|
...computedProps.input
|
|
624
853
|
})
|
|
625
854
|
});
|
|
626
855
|
case "object":
|
|
627
|
-
return /* @__PURE__ */
|
|
856
|
+
return /* @__PURE__ */ jsxs2(Fragment4, {
|
|
628
857
|
children: [
|
|
629
|
-
computedProps.label && /* @__PURE__ */
|
|
858
|
+
computedProps.label && /* @__PURE__ */ jsx10("div", {
|
|
630
859
|
className: "ant-form-item-label",
|
|
631
|
-
children: /* @__PURE__ */
|
|
860
|
+
children: /* @__PURE__ */ jsx10("label", {
|
|
632
861
|
className: ((_a = computedProps.rules) == null ? void 0 : _a.find((r) => r.required)) && "ant-form-item-required",
|
|
633
862
|
children: computedProps.label
|
|
634
863
|
})
|
|
635
864
|
}),
|
|
636
|
-
computedProps.object.map((o) => /* @__PURE__ */
|
|
865
|
+
computedProps.object.map((o) => /* @__PURE__ */ jsx10(FormItem, {
|
|
637
866
|
...o
|
|
638
867
|
}, o.id))
|
|
639
868
|
]
|
|
640
869
|
});
|
|
641
870
|
case "object[]":
|
|
642
|
-
return /* @__PURE__ */
|
|
871
|
+
return /* @__PURE__ */ jsx10(AntdForm.List, {
|
|
643
872
|
name: computedProps.name,
|
|
644
873
|
rules: computedProps.rules,
|
|
645
|
-
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */
|
|
874
|
+
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ jsxs2(Fragment4, {
|
|
646
875
|
children: [
|
|
647
|
-
fields.map((field) => /* @__PURE__ */
|
|
876
|
+
fields.map((field) => /* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
648
877
|
style: { marginBottom: 0 },
|
|
649
878
|
children: [
|
|
650
|
-
/* @__PURE__ */
|
|
879
|
+
/* @__PURE__ */ jsx10("div", {
|
|
651
880
|
className: "ant-form-item-label",
|
|
652
|
-
children: /* @__PURE__ */
|
|
881
|
+
children: /* @__PURE__ */ jsxs2("label", {
|
|
653
882
|
children: [
|
|
654
883
|
computedProps.label,
|
|
655
884
|
" ",
|
|
656
885
|
field.name + 1,
|
|
657
|
-
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */
|
|
886
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ jsx10(Button, {
|
|
658
887
|
danger: true,
|
|
659
888
|
type: "link",
|
|
660
889
|
onClick: () => remove(field.name),
|
|
@@ -663,11 +892,11 @@ function FormItem(props) {
|
|
|
663
892
|
]
|
|
664
893
|
})
|
|
665
894
|
}),
|
|
666
|
-
/* @__PURE__ */
|
|
895
|
+
/* @__PURE__ */ jsx10(Row, {
|
|
667
896
|
gutter: 24,
|
|
668
|
-
children: computedProps.object.map((o) => /* @__PURE__ */
|
|
897
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ jsx10(Col, {
|
|
669
898
|
span: o.col || 24,
|
|
670
|
-
children: /* @__PURE__ */
|
|
899
|
+
children: /* @__PURE__ */ jsx10(FormItem, {
|
|
671
900
|
...o,
|
|
672
901
|
name: [field.name, o.id]
|
|
673
902
|
})
|
|
@@ -675,20 +904,24 @@ function FormItem(props) {
|
|
|
675
904
|
})
|
|
676
905
|
]
|
|
677
906
|
}, field.key)),
|
|
678
|
-
/* @__PURE__ */
|
|
907
|
+
/* @__PURE__ */ jsxs2(AntdForm.Item, {
|
|
679
908
|
children: [
|
|
680
|
-
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */
|
|
909
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ jsxs2(Button, {
|
|
681
910
|
type: "dashed",
|
|
682
911
|
block: true,
|
|
683
912
|
onClick: () => add(),
|
|
684
|
-
icon: /* @__PURE__ */
|
|
913
|
+
icon: /* @__PURE__ */ jsx10(PlusOutlined, {}),
|
|
685
914
|
children: [
|
|
686
915
|
common2.add,
|
|
687
916
|
" ",
|
|
688
917
|
computedProps.label
|
|
689
918
|
]
|
|
690
919
|
}),
|
|
691
|
-
/* @__PURE__ */
|
|
920
|
+
computedProps.extra && /* @__PURE__ */ jsx10("div", {
|
|
921
|
+
className: "ant-form-item-extra",
|
|
922
|
+
children: computedProps.extra
|
|
923
|
+
}),
|
|
924
|
+
/* @__PURE__ */ jsx10(AntdForm.ErrorList, {
|
|
692
925
|
errors
|
|
693
926
|
})
|
|
694
927
|
]
|
|
@@ -700,27 +933,28 @@ function FormItem(props) {
|
|
|
700
933
|
return null;
|
|
701
934
|
}
|
|
702
935
|
}
|
|
936
|
+
FormItem.useStatus = AntdForm.Item.useStatus;
|
|
703
937
|
|
|
704
938
|
// src/Form.tsx
|
|
705
|
-
import { jsx as
|
|
939
|
+
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
706
940
|
function Form(props) {
|
|
707
941
|
var _a, _b;
|
|
708
|
-
const [loading, setLoading] =
|
|
709
|
-
const [computedProps, setComputedProps] =
|
|
942
|
+
const [loading, setLoading] = useState6(false);
|
|
943
|
+
const [computedProps, setComputedProps] = useState6();
|
|
710
944
|
const config = useConfigContext();
|
|
711
|
-
const [extendTypes, setExtendTypes] =
|
|
945
|
+
const [extendTypes, setExtendTypes] = useState6();
|
|
712
946
|
const [form] = AntdForm2.useForm(props.form);
|
|
713
|
-
const [initialValues, setInitialValues] =
|
|
714
|
-
|
|
715
|
-
var _a2, _b2;
|
|
947
|
+
const [initialValues, setInitialValues] = useState6(props.initialValues);
|
|
948
|
+
useEffect5(() => {
|
|
949
|
+
var _a2, _b2, _c;
|
|
716
950
|
const propsCopy = {
|
|
717
951
|
...props,
|
|
718
952
|
form
|
|
719
953
|
};
|
|
720
|
-
if (propsCopy.initialValues) {
|
|
954
|
+
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
721
955
|
for (const key in propsCopy.initialValues) {
|
|
722
956
|
propsCopy.initialValues[key] = transferValue(
|
|
723
|
-
(
|
|
957
|
+
(_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
|
|
724
958
|
propsCopy.initialValues[key]
|
|
725
959
|
);
|
|
726
960
|
const item = propsCopy.items.find((item2) => item2.id === key);
|
|
@@ -751,13 +985,25 @@ function Form(props) {
|
|
|
751
985
|
}
|
|
752
986
|
setLoading(false);
|
|
753
987
|
};
|
|
754
|
-
} else if (propsCopy.submit && ((
|
|
988
|
+
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
755
989
|
propsCopy.onFinish = async (values) => {
|
|
756
990
|
setLoading(true);
|
|
757
991
|
return faas(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
758
992
|
...values,
|
|
759
993
|
...propsCopy.submit.to.params
|
|
760
|
-
} : values).
|
|
994
|
+
} : values).then((result) => {
|
|
995
|
+
if (propsCopy.submit.to.then)
|
|
996
|
+
propsCopy.submit.to.then(result);
|
|
997
|
+
return result;
|
|
998
|
+
}).catch((error) => {
|
|
999
|
+
if (propsCopy.submit.to.catch)
|
|
1000
|
+
propsCopy.submit.to.catch(error);
|
|
1001
|
+
return Promise.reject(error);
|
|
1002
|
+
}).finally(() => {
|
|
1003
|
+
if (propsCopy.submit.to.finally)
|
|
1004
|
+
propsCopy.submit.to.finally();
|
|
1005
|
+
setLoading(false);
|
|
1006
|
+
});
|
|
761
1007
|
};
|
|
762
1008
|
}
|
|
763
1009
|
if (propsCopy.extendTypes) {
|
|
@@ -779,7 +1025,7 @@ function Form(props) {
|
|
|
779
1025
|
item.onValueChange(changedValues[key], allValues, form);
|
|
780
1026
|
}
|
|
781
1027
|
}, [computedProps]);
|
|
782
|
-
|
|
1028
|
+
useEffect5(() => {
|
|
783
1029
|
if (!initialValues)
|
|
784
1030
|
return;
|
|
785
1031
|
console.debug("Form:initialValues", initialValues);
|
|
@@ -788,17 +1034,17 @@ function Form(props) {
|
|
|
788
1034
|
}, [computedProps]);
|
|
789
1035
|
if (!computedProps)
|
|
790
1036
|
return null;
|
|
791
|
-
return /* @__PURE__ */
|
|
1037
|
+
return /* @__PURE__ */ jsxs3(AntdForm2, {
|
|
792
1038
|
...computedProps,
|
|
793
1039
|
onValuesChange,
|
|
794
1040
|
children: [
|
|
795
1041
|
computedProps.beforeItems,
|
|
796
|
-
(_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */
|
|
1042
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => isValidElement(item) ? item : /* @__PURE__ */ jsx11(FormItem, {
|
|
797
1043
|
...item,
|
|
798
1044
|
extendTypes
|
|
799
1045
|
}, item.id)),
|
|
800
1046
|
computedProps.children,
|
|
801
|
-
computedProps.submit !== false && /* @__PURE__ */
|
|
1047
|
+
computedProps.submit !== false && /* @__PURE__ */ jsx11(Button2, {
|
|
802
1048
|
htmlType: "submit",
|
|
803
1049
|
type: "primary",
|
|
804
1050
|
loading,
|
|
@@ -809,98 +1055,66 @@ function Form(props) {
|
|
|
809
1055
|
});
|
|
810
1056
|
}
|
|
811
1057
|
Form.useForm = AntdForm2.useForm;
|
|
1058
|
+
Form.useFormInstance = AntdForm2.useFormInstance;
|
|
1059
|
+
Form.useWatch = AntdForm2.useWatch;
|
|
1060
|
+
Form.Item = FormItem;
|
|
1061
|
+
Form.List = AntdForm2.List;
|
|
1062
|
+
Form.ErrorList = AntdForm2.ErrorList;
|
|
1063
|
+
Form.Provider = AntdForm2.Provider;
|
|
812
1064
|
|
|
813
1065
|
// src/Link.tsx
|
|
814
1066
|
import { Link as RouterLink } from "react-router-dom";
|
|
815
1067
|
import { Button as Button3 } from "antd";
|
|
816
|
-
import { jsx as
|
|
817
|
-
function Link({
|
|
818
|
-
|
|
819
|
-
target,
|
|
820
|
-
text,
|
|
821
|
-
children,
|
|
822
|
-
style,
|
|
823
|
-
button
|
|
824
|
-
}) {
|
|
1068
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1069
|
+
function Link(props) {
|
|
1070
|
+
var _a, _b, _c, _d;
|
|
825
1071
|
const { Link: Link2 } = useConfigContext();
|
|
826
|
-
style =
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
1072
|
+
let style = {
|
|
1073
|
+
...Link2.style || {},
|
|
1074
|
+
cursor: "pointer",
|
|
1075
|
+
...props.style
|
|
1076
|
+
};
|
|
1077
|
+
if (props.block)
|
|
1078
|
+
style = Object.assign({
|
|
1079
|
+
display: "block",
|
|
1080
|
+
width: "100%"
|
|
1081
|
+
}, style);
|
|
1082
|
+
if (props.href.startsWith("http")) {
|
|
1083
|
+
if (props.button)
|
|
1084
|
+
return /* @__PURE__ */ jsx12(Button3, {
|
|
1085
|
+
...props.button,
|
|
1086
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1087
|
+
style,
|
|
1088
|
+
href: props.href,
|
|
1089
|
+
children: (_a = props.text) != null ? _a : props.children
|
|
840
1090
|
});
|
|
841
|
-
return /* @__PURE__ */
|
|
842
|
-
href,
|
|
843
|
-
target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
844
|
-
style
|
|
845
|
-
|
|
846
|
-
...style || {}
|
|
847
|
-
},
|
|
848
|
-
children: text || children
|
|
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
|
|
849
1096
|
});
|
|
850
1097
|
}
|
|
851
|
-
if (button)
|
|
852
|
-
return /* @__PURE__ */
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
style
|
|
858
|
-
|
|
859
|
-
...style || {}
|
|
860
|
-
},
|
|
861
|
-
children: text || children
|
|
1098
|
+
if (props.button)
|
|
1099
|
+
return /* @__PURE__ */ jsx12(RouterLink, {
|
|
1100
|
+
to: props.href,
|
|
1101
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1102
|
+
children: /* @__PURE__ */ jsx12(Button3, {
|
|
1103
|
+
...props.button,
|
|
1104
|
+
style,
|
|
1105
|
+
children: (_c = props.text) != null ? _c : props.children
|
|
862
1106
|
})
|
|
863
1107
|
});
|
|
864
|
-
return /* @__PURE__ */
|
|
865
|
-
to: href,
|
|
866
|
-
target: target || (Link2 == null ? void 0 : Link2.target),
|
|
867
|
-
style
|
|
868
|
-
|
|
869
|
-
...style || {}
|
|
870
|
-
},
|
|
871
|
-
children: text || children
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
// src/Modal.tsx
|
|
876
|
-
import { Modal } from "antd";
|
|
877
|
-
import { useState as useState6 } from "react";
|
|
878
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
879
|
-
function useModal(init) {
|
|
880
|
-
const [props, setProps] = useState6({
|
|
881
|
-
open: false,
|
|
882
|
-
onCancel: () => setProps((prev) => ({
|
|
883
|
-
...prev,
|
|
884
|
-
open: false
|
|
885
|
-
})),
|
|
886
|
-
...init
|
|
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
|
|
887
1113
|
});
|
|
888
|
-
return {
|
|
889
|
-
modal: /* @__PURE__ */ jsx8(Modal, {
|
|
890
|
-
...props
|
|
891
|
-
}),
|
|
892
|
-
modalProps: props,
|
|
893
|
-
setModalProps(changes) {
|
|
894
|
-
setProps((prev) => ({
|
|
895
|
-
...prev,
|
|
896
|
-
...changes
|
|
897
|
-
}));
|
|
898
|
-
}
|
|
899
|
-
};
|
|
900
1114
|
}
|
|
901
1115
|
|
|
902
1116
|
// src/Routers.tsx
|
|
903
|
-
import { Result, Skeleton
|
|
1117
|
+
import { Result, Skeleton } from "antd";
|
|
904
1118
|
import {
|
|
905
1119
|
Suspense
|
|
906
1120
|
} from "react";
|
|
@@ -908,32 +1122,33 @@ import {
|
|
|
908
1122
|
Routes as OriginRoutes,
|
|
909
1123
|
Route
|
|
910
1124
|
} from "react-router-dom";
|
|
911
|
-
import {
|
|
1125
|
+
import { lazy } from "react";
|
|
1126
|
+
import { jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
912
1127
|
function PageNotFound() {
|
|
913
1128
|
const config = useConfigContext();
|
|
914
|
-
return /* @__PURE__ */
|
|
1129
|
+
return /* @__PURE__ */ jsx13(Result, {
|
|
915
1130
|
status: "404",
|
|
916
1131
|
title: config.common.pageNotFound
|
|
917
1132
|
});
|
|
918
1133
|
}
|
|
919
1134
|
function Routes(props) {
|
|
920
|
-
return /* @__PURE__ */
|
|
1135
|
+
return /* @__PURE__ */ jsxs4(OriginRoutes, {
|
|
921
1136
|
children: [
|
|
922
|
-
props.routes.map((r) => /* @__PURE__ */
|
|
1137
|
+
props.routes.map((r) => /* @__PURE__ */ jsx13(Route, {
|
|
923
1138
|
...r,
|
|
924
|
-
element: r.element || /* @__PURE__ */
|
|
925
|
-
fallback: props.fallback || /* @__PURE__ */
|
|
1139
|
+
element: r.element || /* @__PURE__ */ jsx13(Suspense, {
|
|
1140
|
+
fallback: props.fallback || /* @__PURE__ */ jsx13("div", {
|
|
926
1141
|
style: { padding: "24px" },
|
|
927
|
-
children: /* @__PURE__ */
|
|
1142
|
+
children: /* @__PURE__ */ jsx13(Skeleton, {
|
|
928
1143
|
active: true
|
|
929
1144
|
})
|
|
930
1145
|
}),
|
|
931
|
-
children: /* @__PURE__ */
|
|
1146
|
+
children: /* @__PURE__ */ jsx13(r.page, {})
|
|
932
1147
|
})
|
|
933
1148
|
}, r.path)),
|
|
934
|
-
/* @__PURE__ */
|
|
1149
|
+
/* @__PURE__ */ jsx13(Route, {
|
|
935
1150
|
path: "*",
|
|
936
|
-
element: props.notFound || /* @__PURE__ */
|
|
1151
|
+
element: props.notFound || /* @__PURE__ */ jsx13(PageNotFound, {})
|
|
937
1152
|
}, "*")
|
|
938
1153
|
]
|
|
939
1154
|
});
|
|
@@ -942,15 +1157,14 @@ function Routes(props) {
|
|
|
942
1157
|
// src/Table.tsx
|
|
943
1158
|
import {
|
|
944
1159
|
useState as useState7,
|
|
945
|
-
useEffect as
|
|
946
|
-
cloneElement as
|
|
1160
|
+
useEffect as useEffect6,
|
|
1161
|
+
cloneElement as cloneElement3
|
|
947
1162
|
} from "react";
|
|
948
1163
|
import {
|
|
949
1164
|
Table as AntdTable,
|
|
950
1165
|
Radio,
|
|
951
|
-
Skeleton as Skeleton3,
|
|
952
1166
|
Input as Input2,
|
|
953
|
-
|
|
1167
|
+
Select as Select2
|
|
954
1168
|
} from "antd";
|
|
955
1169
|
import dayjs2 from "dayjs";
|
|
956
1170
|
import { CheckOutlined as CheckOutlined2, CloseOutlined as CloseOutlined2 } from "@ant-design/icons";
|
|
@@ -959,13 +1173,12 @@ import {
|
|
|
959
1173
|
uniqBy,
|
|
960
1174
|
upperFirst as upperFirst4
|
|
961
1175
|
} from "lodash-es";
|
|
962
|
-
import {
|
|
963
|
-
import { jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1176
|
+
import { Fragment as Fragment5, jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
964
1177
|
function processValue(item, value) {
|
|
965
1178
|
var _a;
|
|
966
1179
|
const transferred = transferValue(item.type, value);
|
|
967
1180
|
if (transferred === null || Array.isArray(transferred) && transferred.length === 0)
|
|
968
|
-
return /* @__PURE__ */
|
|
1181
|
+
return /* @__PURE__ */ jsx14(Blank, {});
|
|
969
1182
|
if (item.options) {
|
|
970
1183
|
if (item.type.endsWith("[]"))
|
|
971
1184
|
return transferred.map((v) => {
|
|
@@ -987,8 +1200,8 @@ function processValue(item, value) {
|
|
|
987
1200
|
}
|
|
988
1201
|
function Table(props) {
|
|
989
1202
|
const [columns, setColumns] = useState7();
|
|
990
|
-
const { common: common2
|
|
991
|
-
|
|
1203
|
+
const { common: common2 } = useConfigContext();
|
|
1204
|
+
useEffect6(() => {
|
|
992
1205
|
var _a;
|
|
993
1206
|
for (const item of props.items) {
|
|
994
1207
|
if (!item.key)
|
|
@@ -1004,15 +1217,39 @@ function Table(props) {
|
|
|
1004
1217
|
item.filters = item.options.map((o) => ({
|
|
1005
1218
|
text: o.label,
|
|
1006
1219
|
value: o.value
|
|
1007
|
-
}))
|
|
1220
|
+
})).concat({
|
|
1221
|
+
text: /* @__PURE__ */ jsx14(Blank, {}),
|
|
1222
|
+
value: null
|
|
1223
|
+
});
|
|
1008
1224
|
}
|
|
1009
|
-
if (item.
|
|
1010
|
-
|
|
1225
|
+
if (item.tableChildren === null)
|
|
1226
|
+
item.render = () => null;
|
|
1227
|
+
else if (item.tableChildren)
|
|
1228
|
+
item.render = (value, values) => cloneElement3(
|
|
1229
|
+
item.tableChildren,
|
|
1230
|
+
{
|
|
1231
|
+
scene: "table",
|
|
1232
|
+
value,
|
|
1233
|
+
values
|
|
1234
|
+
}
|
|
1235
|
+
);
|
|
1236
|
+
else if (item.children === null)
|
|
1237
|
+
item.render = () => null;
|
|
1238
|
+
else if (item.children)
|
|
1239
|
+
item.render = (value, values) => cloneElement3(
|
|
1240
|
+
item.children,
|
|
1241
|
+
{
|
|
1242
|
+
scene: "table",
|
|
1243
|
+
value,
|
|
1244
|
+
values
|
|
1245
|
+
}
|
|
1246
|
+
);
|
|
1011
1247
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1012
1248
|
if (props.extendTypes[item.type].children)
|
|
1013
|
-
item.render = (value, values) =>
|
|
1249
|
+
item.render = (value, values) => cloneElement3(
|
|
1014
1250
|
props.extendTypes[item.type].children,
|
|
1015
1251
|
{
|
|
1252
|
+
scene: "table",
|
|
1016
1253
|
value,
|
|
1017
1254
|
values
|
|
1018
1255
|
}
|
|
@@ -1031,16 +1268,18 @@ function Table(props) {
|
|
|
1031
1268
|
item.onFilter = (value, row) => {
|
|
1032
1269
|
if (value === null && isNil2(row[item.id]))
|
|
1033
1270
|
return true;
|
|
1034
|
-
if (!row[item.id])
|
|
1271
|
+
if (!row[item.id] || !value)
|
|
1035
1272
|
return false;
|
|
1036
1273
|
return row[item.id].toLowerCase().includes(value.toLowerCase());
|
|
1037
1274
|
};
|
|
1038
|
-
if (
|
|
1275
|
+
if (item.filterDropdown === false || item.filterDropdown)
|
|
1276
|
+
break;
|
|
1277
|
+
if (!item.filters && item.optionsType !== "auto")
|
|
1039
1278
|
item.filterDropdown = ({
|
|
1040
1279
|
setSelectedKeys,
|
|
1041
1280
|
confirm,
|
|
1042
1281
|
clearFilters
|
|
1043
|
-
}) => /* @__PURE__ */
|
|
1282
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1044
1283
|
placeholder: `${common2.search} ${item.title}`,
|
|
1045
1284
|
allowClear: true,
|
|
1046
1285
|
onSearch: (v) => {
|
|
@@ -1061,16 +1300,18 @@ function Table(props) {
|
|
|
1061
1300
|
item.onFilter = (value, row) => {
|
|
1062
1301
|
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1063
1302
|
return true;
|
|
1064
|
-
if (!row[item.id] || !row[item.id].length)
|
|
1303
|
+
if (!row[item.id] || !row[item.id].length || !value)
|
|
1065
1304
|
return false;
|
|
1066
1305
|
return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
|
|
1067
1306
|
};
|
|
1068
|
-
if (
|
|
1307
|
+
if (item.filterDropdown === false || item.filterDropdown)
|
|
1308
|
+
break;
|
|
1309
|
+
if (!item.filters && item.optionsType !== "auto")
|
|
1069
1310
|
item.filterDropdown = ({
|
|
1070
1311
|
setSelectedKeys,
|
|
1071
1312
|
confirm,
|
|
1072
1313
|
clearFilters
|
|
1073
|
-
}) => /* @__PURE__ */
|
|
1314
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1074
1315
|
placeholder: `${common2.search} ${item.title}`,
|
|
1075
1316
|
allowClear: true,
|
|
1076
1317
|
onSearch: (v) => {
|
|
@@ -1093,14 +1334,16 @@ function Table(props) {
|
|
|
1093
1334
|
item.onFilter = (value, row) => {
|
|
1094
1335
|
if (value === null && isNil2(row[item.id]))
|
|
1095
1336
|
return true;
|
|
1096
|
-
return value
|
|
1337
|
+
return value == row[item.id];
|
|
1097
1338
|
};
|
|
1098
|
-
if (
|
|
1339
|
+
if (item.filterDropdown === false || item.filterDropdown)
|
|
1340
|
+
break;
|
|
1341
|
+
if (!item.filters)
|
|
1099
1342
|
item.filterDropdown = ({
|
|
1100
1343
|
setSelectedKeys,
|
|
1101
1344
|
confirm,
|
|
1102
1345
|
clearFilters
|
|
1103
|
-
}) => /* @__PURE__ */
|
|
1346
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1104
1347
|
placeholder: `${common2.search} ${item.title}`,
|
|
1105
1348
|
allowClear: true,
|
|
1106
1349
|
onSearch: (v) => {
|
|
@@ -1123,14 +1366,16 @@ function Table(props) {
|
|
|
1123
1366
|
return true;
|
|
1124
1367
|
if (!row[item.id] || !row[item.id].length)
|
|
1125
1368
|
return false;
|
|
1126
|
-
return row[item.id].includes(value);
|
|
1369
|
+
return row[item.id].includes(Number(value));
|
|
1127
1370
|
};
|
|
1128
|
-
if (
|
|
1371
|
+
if (item.filterDropdown === false || item.filterDropdown)
|
|
1372
|
+
break;
|
|
1373
|
+
if (!item.filters)
|
|
1129
1374
|
item.filterDropdown = ({
|
|
1130
1375
|
setSelectedKeys,
|
|
1131
1376
|
confirm,
|
|
1132
1377
|
clearFilters
|
|
1133
|
-
}) => /* @__PURE__ */
|
|
1378
|
+
}) => /* @__PURE__ */ jsx14(Input2.Search, {
|
|
1134
1379
|
placeholder: `${common2.search} ${item.title}`,
|
|
1135
1380
|
allowClear: true,
|
|
1136
1381
|
onSearch: (v) => {
|
|
@@ -1146,12 +1391,12 @@ function Table(props) {
|
|
|
1146
1391
|
break;
|
|
1147
1392
|
case "boolean":
|
|
1148
1393
|
if (!item.render)
|
|
1149
|
-
item.render = (value) =>
|
|
1394
|
+
item.render = (value) => isNil2(value) ? /* @__PURE__ */ jsx14(Blank, {}) : value ? /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1150
1395
|
style: {
|
|
1151
1396
|
marginTop: "4px",
|
|
1152
1397
|
color: "#52c41a"
|
|
1153
1398
|
}
|
|
1154
|
-
}) : /* @__PURE__ */
|
|
1399
|
+
}) : /* @__PURE__ */ jsx14(CloseOutlined2, {
|
|
1155
1400
|
style: {
|
|
1156
1401
|
marginTop: "4px",
|
|
1157
1402
|
color: "#ff4d4f"
|
|
@@ -1162,38 +1407,43 @@ function Table(props) {
|
|
|
1162
1407
|
setSelectedKeys,
|
|
1163
1408
|
selectedKeys,
|
|
1164
1409
|
confirm
|
|
1165
|
-
}) => /* @__PURE__ */
|
|
1410
|
+
}) => /* @__PURE__ */ jsxs5(Radio.Group, {
|
|
1166
1411
|
style: { padding: 8 },
|
|
1167
1412
|
buttonStyle: "solid",
|
|
1168
1413
|
value: selectedKeys[0],
|
|
1169
1414
|
onChange: (e) => {
|
|
1170
|
-
|
|
1415
|
+
const Values = {
|
|
1416
|
+
true: true,
|
|
1417
|
+
false: false,
|
|
1418
|
+
null: null
|
|
1419
|
+
};
|
|
1420
|
+
setSelectedKeys(e.target.value ? [Values[e.target.value]] : []);
|
|
1171
1421
|
confirm();
|
|
1172
1422
|
},
|
|
1173
1423
|
children: [
|
|
1174
|
-
/* @__PURE__ */
|
|
1424
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1175
1425
|
children: common2.all
|
|
1176
1426
|
}),
|
|
1177
|
-
/* @__PURE__ */
|
|
1427
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1178
1428
|
value: "true",
|
|
1179
|
-
children: /* @__PURE__ */
|
|
1429
|
+
children: /* @__PURE__ */ jsx14(CheckOutlined2, {
|
|
1180
1430
|
style: {
|
|
1181
1431
|
color: "#52c41a",
|
|
1182
1432
|
verticalAlign: "middle"
|
|
1183
1433
|
}
|
|
1184
1434
|
})
|
|
1185
1435
|
}),
|
|
1186
|
-
/* @__PURE__ */
|
|
1436
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1187
1437
|
value: "false",
|
|
1188
|
-
children: /* @__PURE__ */
|
|
1438
|
+
children: /* @__PURE__ */ jsx14(CloseOutlined2, {
|
|
1189
1439
|
style: {
|
|
1190
1440
|
verticalAlign: "middle",
|
|
1191
1441
|
color: "#ff4d4f"
|
|
1192
1442
|
}
|
|
1193
1443
|
})
|
|
1194
1444
|
}),
|
|
1195
|
-
/* @__PURE__ */
|
|
1196
|
-
value: "
|
|
1445
|
+
/* @__PURE__ */ jsx14(Radio.Button, {
|
|
1446
|
+
value: "null",
|
|
1197
1447
|
children: common2.blank
|
|
1198
1448
|
})
|
|
1199
1449
|
]
|
|
@@ -1201,14 +1451,12 @@ function Table(props) {
|
|
|
1201
1451
|
if (!item.onFilter)
|
|
1202
1452
|
item.onFilter = (value, row) => {
|
|
1203
1453
|
switch (value) {
|
|
1204
|
-
case
|
|
1205
|
-
return !isNil2(row[item.id]) &&
|
|
1206
|
-
case
|
|
1454
|
+
case true:
|
|
1455
|
+
return !isNil2(row[item.id]) && row[item.id] !== false;
|
|
1456
|
+
case false:
|
|
1207
1457
|
return !isNil2(row[item.id]) && !row[item.id];
|
|
1208
|
-
case "empty":
|
|
1209
|
-
return isNil2(row[item.id]);
|
|
1210
1458
|
default:
|
|
1211
|
-
return
|
|
1459
|
+
return isNil2(row[item.id]);
|
|
1212
1460
|
}
|
|
1213
1461
|
};
|
|
1214
1462
|
break;
|
|
@@ -1216,9 +1464,15 @@ function Table(props) {
|
|
|
1216
1464
|
if (!item.render)
|
|
1217
1465
|
item.render = (value) => processValue(item, value);
|
|
1218
1466
|
if (!item.onFilter)
|
|
1219
|
-
item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
|
|
1467
|
+
item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value), "date");
|
|
1220
1468
|
if (!item.sorter)
|
|
1221
|
-
item.sorter = (a, b) =>
|
|
1469
|
+
item.sorter = (a, b, order) => {
|
|
1470
|
+
if (isNil2(a[item.id]))
|
|
1471
|
+
return order === "ascend" ? 1 : -1;
|
|
1472
|
+
if (isNil2(b[item.id]))
|
|
1473
|
+
return order === "ascend" ? -1 : 1;
|
|
1474
|
+
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1475
|
+
};
|
|
1222
1476
|
break;
|
|
1223
1477
|
case "time":
|
|
1224
1478
|
if (!item.render)
|
|
@@ -1226,11 +1480,17 @@ function Table(props) {
|
|
|
1226
1480
|
if (!item.onFilter)
|
|
1227
1481
|
item.onFilter = (value, row) => dayjs2(row[item.id]).isSame(dayjs2(value));
|
|
1228
1482
|
if (!item.sorter)
|
|
1229
|
-
item.sorter = (a, b) =>
|
|
1483
|
+
item.sorter = (a, b, order) => {
|
|
1484
|
+
if (isNil2(a[item.id]))
|
|
1485
|
+
return order === "ascend" ? 1 : -1;
|
|
1486
|
+
if (isNil2(b[item.id]))
|
|
1487
|
+
return order === "ascend" ? -1 : 1;
|
|
1488
|
+
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1489
|
+
};
|
|
1230
1490
|
break;
|
|
1231
1491
|
case "object":
|
|
1232
1492
|
if (!item.render)
|
|
1233
|
-
item.render = (value) => /* @__PURE__ */
|
|
1493
|
+
item.render = (value) => /* @__PURE__ */ jsx14(Description, {
|
|
1234
1494
|
items: item.object,
|
|
1235
1495
|
dataSource: value || {},
|
|
1236
1496
|
column: 1
|
|
@@ -1238,11 +1498,13 @@ function Table(props) {
|
|
|
1238
1498
|
break;
|
|
1239
1499
|
case "object[]":
|
|
1240
1500
|
if (!item.render)
|
|
1241
|
-
item.render = (value) =>
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1501
|
+
item.render = (value) => /* @__PURE__ */ jsx14(Fragment5, {
|
|
1502
|
+
children: value.map((v, i) => /* @__PURE__ */ jsx14(Description, {
|
|
1503
|
+
items: item.object,
|
|
1504
|
+
dataSource: v || [],
|
|
1505
|
+
column: 1
|
|
1506
|
+
}, i))
|
|
1507
|
+
});
|
|
1246
1508
|
break;
|
|
1247
1509
|
default:
|
|
1248
1510
|
if (!item.render)
|
|
@@ -1258,147 +1520,211 @@ function Table(props) {
|
|
|
1258
1520
|
}
|
|
1259
1521
|
setColumns(props.items);
|
|
1260
1522
|
}, [props.items]);
|
|
1261
|
-
|
|
1523
|
+
useEffect6(() => {
|
|
1262
1524
|
if (!props.dataSource || !columns)
|
|
1263
1525
|
return;
|
|
1264
1526
|
for (const column of columns) {
|
|
1265
1527
|
if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1528
|
+
const filters = uniqBy(props.dataSource, column.id).map((v) => ({
|
|
1529
|
+
text: v[column.id],
|
|
1530
|
+
value: v[column.id]
|
|
1531
|
+
}));
|
|
1532
|
+
if (filters.length)
|
|
1533
|
+
setColumns((prev) => {
|
|
1534
|
+
const newColumns = [...prev];
|
|
1535
|
+
const index = newColumns.findIndex((item) => item.id === column.id);
|
|
1536
|
+
if (filters.length < 11)
|
|
1537
|
+
newColumns[index].filters = filters.concat({
|
|
1538
|
+
text: /* @__PURE__ */ jsx14(Blank, {}),
|
|
1539
|
+
value: null
|
|
1540
|
+
});
|
|
1541
|
+
else
|
|
1542
|
+
newColumns[index].filterDropdown = ({
|
|
1543
|
+
setSelectedKeys,
|
|
1544
|
+
selectedKeys,
|
|
1545
|
+
confirm
|
|
1546
|
+
}) => /* @__PURE__ */ jsx14("div", {
|
|
1547
|
+
style: {
|
|
1548
|
+
padding: 8,
|
|
1549
|
+
width: "200px"
|
|
1550
|
+
},
|
|
1551
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
1552
|
+
children: /* @__PURE__ */ jsx14(Select2, {
|
|
1553
|
+
options: filters.map((f) => ({
|
|
1554
|
+
label: f.text,
|
|
1555
|
+
value: f.value
|
|
1556
|
+
})),
|
|
1557
|
+
allowClear: true,
|
|
1558
|
+
showSearch: true,
|
|
1559
|
+
style: { width: "100%" },
|
|
1560
|
+
placeholder: `${common2.search} ${newColumns[index].title}`,
|
|
1561
|
+
value: selectedKeys,
|
|
1562
|
+
onChange: (v) => {
|
|
1563
|
+
setSelectedKeys((v == null ? void 0 : v.length) ? v : []);
|
|
1564
|
+
confirm();
|
|
1565
|
+
},
|
|
1566
|
+
mode: "multiple"
|
|
1567
|
+
})
|
|
1568
|
+
});
|
|
1569
|
+
return newColumns;
|
|
1275
1570
|
});
|
|
1276
|
-
return newColumns;
|
|
1277
|
-
});
|
|
1278
1571
|
}
|
|
1279
1572
|
}
|
|
1280
1573
|
}, [props.dataSource, columns]);
|
|
1281
1574
|
if (!columns)
|
|
1282
1575
|
return null;
|
|
1283
|
-
if (
|
|
1284
|
-
return /* @__PURE__ */
|
|
1285
|
-
...
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
columns,
|
|
1290
|
-
dataSource: props.dataSource
|
|
1291
|
-
})
|
|
1576
|
+
if (props.dataSource)
|
|
1577
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1578
|
+
...props,
|
|
1579
|
+
rowKey: props.rowKey || "id",
|
|
1580
|
+
columns,
|
|
1581
|
+
dataSource: props.dataSource
|
|
1292
1582
|
});
|
|
1293
|
-
return /* @__PURE__ */
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
})
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
pagination: processed.pagination,
|
|
1339
|
-
filters: processed.filters,
|
|
1340
|
-
sorter: processed.sorter
|
|
1341
|
-
});
|
|
1342
|
-
return;
|
|
1343
|
-
}
|
|
1344
|
-
reload({
|
|
1345
|
-
...params,
|
|
1346
|
-
pagination,
|
|
1347
|
-
filters,
|
|
1348
|
-
sorter
|
|
1583
|
+
return /* @__PURE__ */ jsx14(FaasDataWrapper, {
|
|
1584
|
+
...props.faasData,
|
|
1585
|
+
children: /* @__PURE__ */ jsx14(FaasDataTable, {
|
|
1586
|
+
props,
|
|
1587
|
+
columns
|
|
1588
|
+
})
|
|
1589
|
+
});
|
|
1590
|
+
}
|
|
1591
|
+
function FaasDataTable({
|
|
1592
|
+
props,
|
|
1593
|
+
columns,
|
|
1594
|
+
data,
|
|
1595
|
+
params,
|
|
1596
|
+
reload
|
|
1597
|
+
}) {
|
|
1598
|
+
const [currentColumns, setCurrentColumns] = useState7(columns);
|
|
1599
|
+
useEffect6(() => {
|
|
1600
|
+
if (!data || Array.isArray(data))
|
|
1601
|
+
return;
|
|
1602
|
+
setCurrentColumns((prev) => {
|
|
1603
|
+
const newColumns = [...prev];
|
|
1604
|
+
for (const column of newColumns) {
|
|
1605
|
+
if (data["options"] && data.options[column.id]) {
|
|
1606
|
+
column.options = data["options"][column.id];
|
|
1607
|
+
column.filters = data["options"][column.id].map((v) => ({
|
|
1608
|
+
text: v.label,
|
|
1609
|
+
value: v.value
|
|
1610
|
+
})).concat({
|
|
1611
|
+
text: /* @__PURE__ */ jsx14(Blank, {}),
|
|
1612
|
+
value: null
|
|
1613
|
+
});
|
|
1614
|
+
column.render = (value) => processValue(column, value);
|
|
1615
|
+
if (column.filterDropdown)
|
|
1616
|
+
delete column.filterDropdown;
|
|
1617
|
+
continue;
|
|
1618
|
+
}
|
|
1619
|
+
if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1620
|
+
const filters = uniqBy(props.dataSource, column.id).map((v) => ({
|
|
1621
|
+
text: v[column.id],
|
|
1622
|
+
value: v[column.id]
|
|
1623
|
+
}));
|
|
1624
|
+
if (filters.length)
|
|
1625
|
+
column.filters = filters.concat({
|
|
1626
|
+
text: /* @__PURE__ */ jsx14(Blank, {}),
|
|
1627
|
+
value: null
|
|
1349
1628
|
});
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
return newColumns;
|
|
1632
|
+
});
|
|
1633
|
+
}, [columns, data]);
|
|
1634
|
+
if (!data)
|
|
1635
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1636
|
+
...props,
|
|
1637
|
+
rowKey: props.rowKey || "id",
|
|
1638
|
+
columns: currentColumns,
|
|
1639
|
+
dataSource: []
|
|
1640
|
+
});
|
|
1641
|
+
if (Array.isArray(data))
|
|
1642
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1643
|
+
...props,
|
|
1644
|
+
rowKey: props.rowKey || "id",
|
|
1645
|
+
columns: currentColumns,
|
|
1646
|
+
dataSource: data
|
|
1647
|
+
});
|
|
1648
|
+
return /* @__PURE__ */ jsx14(AntdTable, {
|
|
1649
|
+
...props,
|
|
1650
|
+
rowKey: props.rowKey || "id",
|
|
1651
|
+
columns: currentColumns,
|
|
1652
|
+
dataSource: data.rows,
|
|
1653
|
+
pagination: {
|
|
1654
|
+
...props.pagination,
|
|
1655
|
+
...data.pagination
|
|
1353
1656
|
},
|
|
1354
|
-
|
|
1657
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
1658
|
+
if (props.onChange) {
|
|
1659
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1660
|
+
reload({
|
|
1661
|
+
...params,
|
|
1662
|
+
pagination: processed.pagination,
|
|
1663
|
+
filters: processed.filters,
|
|
1664
|
+
sorter: processed.sorter
|
|
1665
|
+
});
|
|
1666
|
+
return;
|
|
1667
|
+
}
|
|
1668
|
+
reload({
|
|
1669
|
+
...params,
|
|
1670
|
+
pagination,
|
|
1671
|
+
filters,
|
|
1672
|
+
sorter
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1355
1675
|
});
|
|
1356
1676
|
}
|
|
1357
1677
|
|
|
1358
1678
|
// src/Title.tsx
|
|
1359
|
-
import { useEffect as
|
|
1360
|
-
import { Fragment as
|
|
1679
|
+
import { useEffect as useEffect7, cloneElement as cloneElement4 } from "react";
|
|
1680
|
+
import { Fragment as Fragment6, jsx as jsx15 } from "react/jsx-runtime";
|
|
1361
1681
|
function Title(props) {
|
|
1362
1682
|
const { Title: Title2 } = useConfigContext();
|
|
1363
|
-
|
|
1683
|
+
useEffect7(() => {
|
|
1364
1684
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1365
1685
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1366
1686
|
}, [props]);
|
|
1367
1687
|
if (props.h1) {
|
|
1368
1688
|
if (typeof props.h1 === "boolean")
|
|
1369
|
-
return /* @__PURE__ */
|
|
1689
|
+
return /* @__PURE__ */ jsx15("h1", {
|
|
1370
1690
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1371
1691
|
});
|
|
1372
|
-
return /* @__PURE__ */
|
|
1692
|
+
return /* @__PURE__ */ jsx15("h1", {
|
|
1373
1693
|
className: props.h1.className,
|
|
1374
1694
|
style: props.h1.style,
|
|
1375
1695
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1376
1696
|
});
|
|
1377
1697
|
}
|
|
1378
1698
|
if (props.plain)
|
|
1379
|
-
return /* @__PURE__ */
|
|
1699
|
+
return /* @__PURE__ */ jsx15(Fragment6, {
|
|
1380
1700
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1381
1701
|
});
|
|
1382
1702
|
if (props.children)
|
|
1383
|
-
return
|
|
1703
|
+
return cloneElement4(props.children, { title: props.title });
|
|
1384
1704
|
return null;
|
|
1385
1705
|
}
|
|
1386
1706
|
export {
|
|
1707
|
+
App,
|
|
1387
1708
|
Blank,
|
|
1388
1709
|
ConfigContext,
|
|
1389
|
-
ConfigProvider,
|
|
1710
|
+
ConfigProvider2 as ConfigProvider,
|
|
1390
1711
|
Description,
|
|
1391
1712
|
Drawer,
|
|
1713
|
+
ErrorBoundary,
|
|
1714
|
+
FaasDataWrapper,
|
|
1392
1715
|
Form,
|
|
1393
1716
|
FormItem,
|
|
1394
1717
|
Link,
|
|
1718
|
+
Loading,
|
|
1395
1719
|
Modal,
|
|
1396
1720
|
PageNotFound,
|
|
1397
1721
|
Routes,
|
|
1398
1722
|
Table,
|
|
1399
1723
|
Title,
|
|
1724
|
+
lazy,
|
|
1400
1725
|
transferOptions,
|
|
1401
1726
|
transferValue,
|
|
1727
|
+
useApp,
|
|
1402
1728
|
useConfigContext,
|
|
1403
1729
|
useDrawer,
|
|
1404
1730
|
useModal
|