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