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