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