@faasjs/ant-design 0.0.3-beta.52 → 0.0.3-beta.53
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.ts +74 -56
- package/dist/index.js +265 -205
- package/dist/index.mjs +304 -238
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,24 +26,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
26
26
|
// src/index.ts
|
|
27
27
|
var src_exports = {};
|
|
28
28
|
__export(src_exports, {
|
|
29
|
+
App: () => App,
|
|
29
30
|
Blank: () => Blank,
|
|
30
31
|
ConfigContext: () => ConfigContext,
|
|
31
|
-
ConfigProvider: () =>
|
|
32
|
+
ConfigProvider: () => ConfigProvider2,
|
|
32
33
|
Description: () => Description,
|
|
33
|
-
Drawer: () =>
|
|
34
|
+
Drawer: () => import_antd2.Drawer,
|
|
34
35
|
ErrorBoundary: () => ErrorBoundary,
|
|
35
36
|
FaasDataWrapper: () => FaasDataWrapper,
|
|
36
37
|
Form: () => Form,
|
|
37
38
|
FormItem: () => FormItem,
|
|
38
39
|
Link: () => Link,
|
|
39
40
|
Loading: () => Loading,
|
|
40
|
-
Modal: () =>
|
|
41
|
+
Modal: () => import_antd.Modal,
|
|
41
42
|
PageNotFound: () => PageNotFound,
|
|
42
43
|
Routes: () => Routes,
|
|
43
44
|
Table: () => Table,
|
|
44
45
|
Title: () => Title,
|
|
45
46
|
transferOptions: () => transferOptions,
|
|
46
47
|
transferValue: () => transferValue,
|
|
48
|
+
useApp: () => useApp,
|
|
47
49
|
useConfigContext: () => useConfigContext,
|
|
48
50
|
useDrawer: () => useDrawer,
|
|
49
51
|
useModal: () => useModal
|
|
@@ -53,12 +55,122 @@ module.exports = __toCommonJS(src_exports);
|
|
|
53
55
|
// react-shim.js
|
|
54
56
|
var import_react = __toESM(require("react"));
|
|
55
57
|
|
|
56
|
-
// src/
|
|
58
|
+
// src/App.tsx
|
|
59
|
+
var import_antd3 = require("antd");
|
|
60
|
+
var import_cssinjs = require("@ant-design/cssinjs");
|
|
61
|
+
var import_react4 = require("react");
|
|
62
|
+
|
|
63
|
+
// src/Modal.tsx
|
|
57
64
|
var import_antd = require("antd");
|
|
65
|
+
var import_react2 = require("react");
|
|
66
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
67
|
+
function useModal(init) {
|
|
68
|
+
const [props, setProps] = (0, import_react2.useState)({
|
|
69
|
+
open: false,
|
|
70
|
+
onCancel: () => setProps((prev) => ({
|
|
71
|
+
...prev,
|
|
72
|
+
open: false
|
|
73
|
+
})),
|
|
74
|
+
...init
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Modal, {
|
|
78
|
+
...props
|
|
79
|
+
}),
|
|
80
|
+
modalProps: props,
|
|
81
|
+
setModalProps(changes) {
|
|
82
|
+
setProps((prev) => ({
|
|
83
|
+
...prev,
|
|
84
|
+
...changes
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/Drawer.tsx
|
|
91
|
+
var import_antd2 = require("antd");
|
|
92
|
+
var import_react3 = require("react");
|
|
93
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
94
|
+
function useDrawer(init) {
|
|
95
|
+
const [props, setProps] = (0, import_react3.useState)({
|
|
96
|
+
open: false,
|
|
97
|
+
onClose: () => setProps((prev) => ({
|
|
98
|
+
...prev,
|
|
99
|
+
open: false
|
|
100
|
+
})),
|
|
101
|
+
...init
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
drawer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Drawer, {
|
|
105
|
+
...props
|
|
106
|
+
}),
|
|
107
|
+
drawerProps: props,
|
|
108
|
+
setDrawerProps(changes) {
|
|
109
|
+
setProps((prev) => ({
|
|
110
|
+
...prev,
|
|
111
|
+
...changes
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/App.tsx
|
|
118
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
119
|
+
var AppContext = (0, import_react4.createContext)({
|
|
120
|
+
message: {},
|
|
121
|
+
notification: {},
|
|
122
|
+
setModalProps: () => void 0,
|
|
123
|
+
setDrawerProps: () => void 0
|
|
124
|
+
});
|
|
125
|
+
function App(props) {
|
|
126
|
+
const [messageApi, messageContextHolder] = import_antd3.message.useMessage();
|
|
127
|
+
const [notificationApi, notificationContextHolder] = import_antd3.notification.useNotification();
|
|
128
|
+
const { modal, setModalProps } = useModal();
|
|
129
|
+
const { drawer, setDrawerProps } = useDrawer();
|
|
130
|
+
const memoizedContextValue = (0, import_react4.useMemo)(
|
|
131
|
+
() => ({
|
|
132
|
+
message: messageApi,
|
|
133
|
+
notification: notificationApi,
|
|
134
|
+
setModalProps,
|
|
135
|
+
setDrawerProps
|
|
136
|
+
}),
|
|
137
|
+
[
|
|
138
|
+
messageApi,
|
|
139
|
+
notificationApi,
|
|
140
|
+
setModalProps,
|
|
141
|
+
setDrawerProps
|
|
142
|
+
]
|
|
143
|
+
);
|
|
144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_cssinjs.StyleProvider, {
|
|
145
|
+
...props.styleProviderProps || {},
|
|
146
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.ConfigProvider, {
|
|
147
|
+
...Object.assign(props.configProviderProps || {}, {
|
|
148
|
+
hashPriority: "high",
|
|
149
|
+
transformers: [import_cssinjs.legacyLogicalPropertiesTransformer]
|
|
150
|
+
}),
|
|
151
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AppContext.Provider, {
|
|
152
|
+
value: memoizedContextValue,
|
|
153
|
+
children: [
|
|
154
|
+
messageContextHolder,
|
|
155
|
+
notificationContextHolder,
|
|
156
|
+
modal,
|
|
157
|
+
drawer,
|
|
158
|
+
props.children
|
|
159
|
+
]
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function useApp() {
|
|
165
|
+
return (0, import_react4.useContext)(AppContext);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// src/Blank.tsx
|
|
169
|
+
var import_antd4 = require("antd");
|
|
58
170
|
var import_lodash_es2 = require("lodash-es");
|
|
59
171
|
|
|
60
172
|
// src/Config.tsx
|
|
61
|
-
var
|
|
173
|
+
var import_react5 = require("react");
|
|
62
174
|
var import_lodash_es = require("lodash-es");
|
|
63
175
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
64
176
|
var isZH = /^zh/i.test(navigator.language);
|
|
@@ -99,13 +211,13 @@ var baseConfig = {
|
|
|
99
211
|
},
|
|
100
212
|
Link: { style: {} }
|
|
101
213
|
};
|
|
102
|
-
var ConfigContext = (0,
|
|
103
|
-
function
|
|
214
|
+
var ConfigContext = (0, import_react5.createContext)(baseConfig);
|
|
215
|
+
function ConfigProvider2({
|
|
104
216
|
config,
|
|
105
217
|
children
|
|
106
218
|
}) {
|
|
107
|
-
const [values, setValues] = (0,
|
|
108
|
-
(0,
|
|
219
|
+
const [values, setValues] = (0, import_react5.useState)(baseConfig);
|
|
220
|
+
(0, import_react5.useEffect)(() => {
|
|
109
221
|
if (config.lang === "zh") {
|
|
110
222
|
setValues((0, import_lodash_es.defaultsDeep)(config, {
|
|
111
223
|
lang: "zh",
|
|
@@ -122,14 +234,14 @@ function ConfigProvider({
|
|
|
122
234
|
});
|
|
123
235
|
}
|
|
124
236
|
function useConfigContext() {
|
|
125
|
-
return (0,
|
|
237
|
+
return (0, import_react5.useContext)(ConfigContext);
|
|
126
238
|
}
|
|
127
239
|
|
|
128
240
|
// src/Blank.tsx
|
|
129
241
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
130
242
|
function Blank(options) {
|
|
131
243
|
const { Blank: Blank2 } = useConfigContext();
|
|
132
|
-
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
244
|
+
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Typography.Text, {
|
|
133
245
|
disabled: true,
|
|
134
246
|
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
135
247
|
}) : options.value;
|
|
@@ -164,15 +276,15 @@ function transferValue(type, value) {
|
|
|
164
276
|
|
|
165
277
|
// src/Description.tsx
|
|
166
278
|
var import_icons = require("@ant-design/icons");
|
|
167
|
-
var
|
|
279
|
+
var import_antd6 = require("antd");
|
|
168
280
|
var import_lodash_es4 = require("lodash-es");
|
|
169
|
-
var
|
|
281
|
+
var import_react7 = require("react");
|
|
170
282
|
|
|
171
283
|
// src/FaasDataWrapper.tsx
|
|
172
|
-
var
|
|
284
|
+
var import_react6 = require("@faasjs/react");
|
|
173
285
|
|
|
174
286
|
// src/Loading.tsx
|
|
175
|
-
var
|
|
287
|
+
var import_antd5 = require("antd");
|
|
176
288
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
177
289
|
function Loading(props) {
|
|
178
290
|
if (props.loading === false)
|
|
@@ -187,7 +299,7 @@ function Loading(props) {
|
|
|
187
299
|
textAlign: "center"
|
|
188
300
|
} : {}
|
|
189
301
|
},
|
|
190
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
302
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Spin, {
|
|
191
303
|
size: props.size || "large"
|
|
192
304
|
})
|
|
193
305
|
});
|
|
@@ -196,7 +308,7 @@ function Loading(props) {
|
|
|
196
308
|
// src/FaasDataWrapper.tsx
|
|
197
309
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
198
310
|
function FaasDataWrapper(props) {
|
|
199
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react6.FaasDataWrapper, {
|
|
200
312
|
fallback: props.loading || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
|
|
201
313
|
...props.loadingProps
|
|
202
314
|
}),
|
|
@@ -208,8 +320,8 @@ function FaasDataWrapper(props) {
|
|
|
208
320
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
209
321
|
function DescriptionItemContent(props) {
|
|
210
322
|
var _a;
|
|
211
|
-
const [computedProps, setComputedProps] = (0,
|
|
212
|
-
(0,
|
|
323
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
324
|
+
(0, import_react7.useEffect)(() => {
|
|
213
325
|
var _a2, _b;
|
|
214
326
|
const propsCopy = { ...props };
|
|
215
327
|
if (!propsCopy.item.title)
|
|
@@ -239,7 +351,7 @@ function DescriptionItemContent(props) {
|
|
|
239
351
|
return null;
|
|
240
352
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
241
353
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
242
|
-
return (0,
|
|
354
|
+
return (0, import_react7.cloneElement)(
|
|
243
355
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
244
356
|
{
|
|
245
357
|
scene: "description",
|
|
@@ -256,7 +368,7 @@ function DescriptionItemContent(props) {
|
|
|
256
368
|
if (computedProps.item.descriptionChildren === null)
|
|
257
369
|
return null;
|
|
258
370
|
if (computedProps.item.descriptionChildren)
|
|
259
|
-
return (0,
|
|
371
|
+
return (0, import_react7.cloneElement)(computedProps.item.descriptionChildren, {
|
|
260
372
|
scene: "description",
|
|
261
373
|
value: computedProps.value,
|
|
262
374
|
values: computedProps.values
|
|
@@ -264,7 +376,7 @@ function DescriptionItemContent(props) {
|
|
|
264
376
|
if (computedProps.item.children === null)
|
|
265
377
|
return null;
|
|
266
378
|
if (computedProps.item.children)
|
|
267
|
-
return (0,
|
|
379
|
+
return (0, import_react7.cloneElement)(computedProps.item.children, {
|
|
268
380
|
scene: "description",
|
|
269
381
|
value: computedProps.value,
|
|
270
382
|
values: computedProps.values
|
|
@@ -317,7 +429,7 @@ function DescriptionItemContent(props) {
|
|
|
317
429
|
case "object[]":
|
|
318
430
|
if (!((_a = computedProps.value) == null ? void 0 : _a.length))
|
|
319
431
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
320
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Space, {
|
|
321
433
|
direction: "vertical",
|
|
322
434
|
children: computedProps.value.map((value, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
323
435
|
items: computedProps.item.object,
|
|
@@ -331,11 +443,11 @@ function DescriptionItemContent(props) {
|
|
|
331
443
|
}
|
|
332
444
|
function Description(props) {
|
|
333
445
|
if (props.dataSource)
|
|
334
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
446
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions, {
|
|
335
447
|
...props,
|
|
336
448
|
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
337
449
|
children: props.items.map((item) => {
|
|
338
|
-
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
450
|
+
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions.Item, {
|
|
339
451
|
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
340
452
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
341
453
|
item,
|
|
@@ -348,11 +460,11 @@ function Description(props) {
|
|
|
348
460
|
});
|
|
349
461
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
350
462
|
render: ({ data }) => {
|
|
351
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
463
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions, {
|
|
352
464
|
...props,
|
|
353
465
|
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
354
466
|
children: props.items.map((item) => {
|
|
355
|
-
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
467
|
+
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Descriptions.Item, {
|
|
356
468
|
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
357
469
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
358
470
|
item,
|
|
@@ -368,38 +480,11 @@ function Description(props) {
|
|
|
368
480
|
});
|
|
369
481
|
}
|
|
370
482
|
|
|
371
|
-
// src/Drawer.tsx
|
|
372
|
-
var import_antd4 = require("antd");
|
|
373
|
-
var import_react5 = require("react");
|
|
374
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
375
|
-
function useDrawer(init) {
|
|
376
|
-
const [props, setProps] = (0, import_react5.useState)({
|
|
377
|
-
open: false,
|
|
378
|
-
onClose: () => setProps((prev) => ({
|
|
379
|
-
...prev,
|
|
380
|
-
open: false
|
|
381
|
-
})),
|
|
382
|
-
...init
|
|
383
|
-
});
|
|
384
|
-
return {
|
|
385
|
-
drawer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Drawer, {
|
|
386
|
-
...props
|
|
387
|
-
}),
|
|
388
|
-
drawerProps: props,
|
|
389
|
-
setDrawerProps(changes) {
|
|
390
|
-
setProps((prev) => ({
|
|
391
|
-
...prev,
|
|
392
|
-
...changes
|
|
393
|
-
}));
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
|
|
398
483
|
// src/ErrorBoundary.tsx
|
|
399
|
-
var
|
|
400
|
-
var
|
|
484
|
+
var import_react8 = require("react");
|
|
485
|
+
var import_antd7 = require("antd");
|
|
401
486
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
402
|
-
var ErrorBoundary = class extends
|
|
487
|
+
var ErrorBoundary = class extends import_react8.Component {
|
|
403
488
|
constructor(props) {
|
|
404
489
|
super(props);
|
|
405
490
|
this.state = {
|
|
@@ -415,18 +500,18 @@ var ErrorBoundary = class extends import_react6.Component {
|
|
|
415
500
|
}
|
|
416
501
|
render() {
|
|
417
502
|
const {
|
|
418
|
-
message,
|
|
503
|
+
message: message2,
|
|
419
504
|
description,
|
|
420
505
|
children
|
|
421
506
|
} = this.props;
|
|
422
507
|
const { error, info } = this.state;
|
|
423
508
|
const componentStack = info && info.componentStack ? info.componentStack : null;
|
|
424
|
-
const errorMessage = typeof
|
|
509
|
+
const errorMessage = typeof message2 === "undefined" ? (error || "").toString() : message2;
|
|
425
510
|
const errorDescription = typeof description === "undefined" ? componentStack : description;
|
|
426
511
|
if (error) {
|
|
427
512
|
if (this.props.onError)
|
|
428
513
|
return this.props.onError(error, info);
|
|
429
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
514
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Alert, {
|
|
430
515
|
type: "error",
|
|
431
516
|
message: errorMessage,
|
|
432
517
|
description: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
|
|
@@ -443,14 +528,14 @@ var ErrorBoundary = class extends import_react6.Component {
|
|
|
443
528
|
};
|
|
444
529
|
|
|
445
530
|
// src/Form.tsx
|
|
446
|
-
var
|
|
447
|
-
var
|
|
448
|
-
var
|
|
531
|
+
var import_react10 = require("@faasjs/react");
|
|
532
|
+
var import_antd9 = require("antd");
|
|
533
|
+
var import_react11 = require("react");
|
|
449
534
|
|
|
450
535
|
// src/FormItem.tsx
|
|
451
|
-
var
|
|
536
|
+
var import_antd8 = require("antd");
|
|
452
537
|
var import_icons2 = require("@ant-design/icons");
|
|
453
|
-
var
|
|
538
|
+
var import_react9 = require("react");
|
|
454
539
|
var import_lodash_es5 = require("lodash-es");
|
|
455
540
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
456
541
|
function processProps(propsCopy, config) {
|
|
@@ -501,11 +586,11 @@ function processProps(propsCopy, config) {
|
|
|
501
586
|
}
|
|
502
587
|
function FormItem(props) {
|
|
503
588
|
var _a;
|
|
504
|
-
const [computedProps, setComputedProps] = (0,
|
|
505
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
589
|
+
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
590
|
+
const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
|
|
506
591
|
const { common: common2 } = useConfigContext();
|
|
507
|
-
const [hidden, setHidden] = (0,
|
|
508
|
-
(0,
|
|
592
|
+
const [hidden, setHidden] = (0, import_react9.useState)(props.hidden || false);
|
|
593
|
+
(0, import_react9.useEffect)(() => {
|
|
509
594
|
const propsCopy = { ...props };
|
|
510
595
|
if (propsCopy.extendTypes) {
|
|
511
596
|
setExtendTypes(propsCopy.extendTypes);
|
|
@@ -529,63 +614,63 @@ function FormItem(props) {
|
|
|
529
614
|
if (!computedProps)
|
|
530
615
|
return null;
|
|
531
616
|
if (hidden)
|
|
532
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
617
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
533
618
|
...computedProps,
|
|
534
619
|
noStyle: true,
|
|
535
620
|
rules: [],
|
|
536
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
621
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Input, {
|
|
537
622
|
hidden: true
|
|
538
623
|
})
|
|
539
624
|
});
|
|
540
625
|
if (extendTypes && extendTypes[computedProps.type])
|
|
541
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
626
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
542
627
|
...computedProps,
|
|
543
628
|
children: extendTypes[computedProps.type].children
|
|
544
629
|
});
|
|
545
630
|
if (computedProps.formChildren === null)
|
|
546
631
|
return null;
|
|
547
632
|
if (computedProps.formChildren)
|
|
548
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
549
634
|
...computedProps,
|
|
550
|
-
children: (0,
|
|
635
|
+
children: (0, import_react9.cloneElement)(computedProps.formChildren, { scene: "form" })
|
|
551
636
|
});
|
|
552
637
|
if (computedProps.children === null)
|
|
553
638
|
return null;
|
|
554
639
|
if (computedProps.children)
|
|
555
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
556
641
|
...computedProps,
|
|
557
|
-
children: (0,
|
|
642
|
+
children: (0, import_react9.cloneElement)(computedProps.children, { scene: "form" })
|
|
558
643
|
});
|
|
559
644
|
if (computedProps.formRender)
|
|
560
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
645
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
561
646
|
...computedProps,
|
|
562
647
|
children: computedProps.formRender(null, null, 0, "form")
|
|
563
648
|
});
|
|
564
649
|
if (computedProps.render)
|
|
565
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
566
651
|
...computedProps,
|
|
567
652
|
children: computedProps.render(null, null, 0, "form")
|
|
568
653
|
});
|
|
569
654
|
switch (computedProps.type) {
|
|
570
655
|
case "string":
|
|
571
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
572
657
|
...computedProps,
|
|
573
|
-
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
658
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
574
659
|
...computedProps.input
|
|
575
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
660
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Input, {
|
|
576
661
|
...computedProps.input
|
|
577
662
|
})
|
|
578
663
|
});
|
|
579
664
|
case "string[]":
|
|
580
665
|
if (computedProps.options)
|
|
581
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
582
667
|
...computedProps,
|
|
583
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
668
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
584
669
|
mode: "multiple",
|
|
585
670
|
...computedProps.input
|
|
586
671
|
})
|
|
587
672
|
});
|
|
588
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.List, {
|
|
589
674
|
name: computedProps.name,
|
|
590
675
|
rules: computedProps.rules,
|
|
591
676
|
children: (fields, { add, remove }, { errors }) => {
|
|
@@ -601,24 +686,24 @@ function FormItem(props) {
|
|
|
601
686
|
}),
|
|
602
687
|
fields.map((field) => {
|
|
603
688
|
var _a3;
|
|
604
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
605
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
690
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Row, {
|
|
606
691
|
gutter: 24,
|
|
607
692
|
style: { flexFlow: "row nowrap" },
|
|
608
693
|
children: [
|
|
609
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
694
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
610
695
|
span: 23,
|
|
611
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
612
697
|
...field,
|
|
613
698
|
noStyle: true,
|
|
614
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
699
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Input, {
|
|
615
700
|
...computedProps.input
|
|
616
701
|
})
|
|
617
702
|
})
|
|
618
703
|
}),
|
|
619
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
620
705
|
span: 1,
|
|
621
|
-
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
706
|
+
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, {
|
|
622
707
|
danger: true,
|
|
623
708
|
type: "link",
|
|
624
709
|
style: { float: "right" },
|
|
@@ -630,9 +715,9 @@ function FormItem(props) {
|
|
|
630
715
|
})
|
|
631
716
|
}, field.key);
|
|
632
717
|
}),
|
|
633
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
718
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
634
719
|
children: [
|
|
635
|
-
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
720
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
636
721
|
type: "dashed",
|
|
637
722
|
block: true,
|
|
638
723
|
onClick: () => add(),
|
|
@@ -642,7 +727,7 @@ function FormItem(props) {
|
|
|
642
727
|
className: "ant-form-item-extra",
|
|
643
728
|
children: computedProps.extra
|
|
644
729
|
}),
|
|
645
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
730
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.ErrorList, {
|
|
646
731
|
errors
|
|
647
732
|
})
|
|
648
733
|
]
|
|
@@ -652,25 +737,25 @@ function FormItem(props) {
|
|
|
652
737
|
}
|
|
653
738
|
});
|
|
654
739
|
case "number":
|
|
655
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
656
741
|
...computedProps,
|
|
657
|
-
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
742
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
658
743
|
...computedProps.input
|
|
659
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
744
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.InputNumber, {
|
|
660
745
|
style: { width: "100%" },
|
|
661
746
|
...computedProps.input
|
|
662
747
|
})
|
|
663
748
|
});
|
|
664
749
|
case "number[]":
|
|
665
750
|
if (computedProps.options)
|
|
666
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
751
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
667
752
|
...computedProps,
|
|
668
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
753
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Select, {
|
|
669
754
|
mode: "multiple",
|
|
670
755
|
...computedProps.input
|
|
671
756
|
})
|
|
672
757
|
});
|
|
673
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
758
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.List, {
|
|
674
759
|
name: computedProps.name,
|
|
675
760
|
rules: computedProps.rules,
|
|
676
761
|
children: (fields, { add, remove }, { errors }) => {
|
|
@@ -686,25 +771,25 @@ function FormItem(props) {
|
|
|
686
771
|
}),
|
|
687
772
|
fields.map((field) => {
|
|
688
773
|
var _a3;
|
|
689
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
690
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
774
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
775
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Row, {
|
|
691
776
|
gutter: 24,
|
|
692
777
|
style: { flexFlow: "row nowrap" },
|
|
693
778
|
children: [
|
|
694
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
779
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
695
780
|
span: 23,
|
|
696
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
781
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
697
782
|
...field,
|
|
698
783
|
noStyle: true,
|
|
699
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
784
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.InputNumber, {
|
|
700
785
|
style: { width: "100%" },
|
|
701
786
|
...computedProps.input
|
|
702
787
|
})
|
|
703
788
|
})
|
|
704
789
|
}),
|
|
705
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
790
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
706
791
|
span: 1,
|
|
707
|
-
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
792
|
+
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, {
|
|
708
793
|
danger: true,
|
|
709
794
|
type: "link",
|
|
710
795
|
style: { float: "right" },
|
|
@@ -716,9 +801,9 @@ function FormItem(props) {
|
|
|
716
801
|
})
|
|
717
802
|
}, field.key);
|
|
718
803
|
}),
|
|
719
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
804
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
720
805
|
children: [
|
|
721
|
-
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
806
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
722
807
|
type: "dashed",
|
|
723
808
|
block: true,
|
|
724
809
|
onClick: () => add(),
|
|
@@ -728,7 +813,7 @@ function FormItem(props) {
|
|
|
728
813
|
className: "ant-form-item-extra",
|
|
729
814
|
children: computedProps.extra
|
|
730
815
|
}),
|
|
731
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
816
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.ErrorList, {
|
|
732
817
|
errors
|
|
733
818
|
})
|
|
734
819
|
]
|
|
@@ -738,23 +823,23 @@ function FormItem(props) {
|
|
|
738
823
|
}
|
|
739
824
|
});
|
|
740
825
|
case "boolean":
|
|
741
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
826
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
742
827
|
...computedProps,
|
|
743
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Switch, {
|
|
744
829
|
...computedProps.input
|
|
745
830
|
})
|
|
746
831
|
});
|
|
747
832
|
case "date":
|
|
748
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
749
834
|
...computedProps,
|
|
750
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
835
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.DatePicker, {
|
|
751
836
|
...computedProps.input
|
|
752
837
|
})
|
|
753
838
|
});
|
|
754
839
|
case "time":
|
|
755
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.Item, {
|
|
756
841
|
...computedProps,
|
|
757
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.TimePicker, {
|
|
758
843
|
...computedProps.input
|
|
759
844
|
})
|
|
760
845
|
});
|
|
@@ -774,12 +859,12 @@ function FormItem(props) {
|
|
|
774
859
|
]
|
|
775
860
|
});
|
|
776
861
|
case "object[]":
|
|
777
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
862
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.List, {
|
|
778
863
|
name: computedProps.name,
|
|
779
864
|
rules: computedProps.rules,
|
|
780
865
|
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
781
866
|
children: [
|
|
782
|
-
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
867
|
+
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
783
868
|
style: { marginBottom: 0 },
|
|
784
869
|
children: [
|
|
785
870
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
@@ -789,7 +874,7 @@ function FormItem(props) {
|
|
|
789
874
|
computedProps.label,
|
|
790
875
|
" ",
|
|
791
876
|
field.name + 1,
|
|
792
|
-
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
877
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
793
878
|
danger: true,
|
|
794
879
|
type: "link",
|
|
795
880
|
onClick: () => remove(field.name),
|
|
@@ -798,9 +883,9 @@ function FormItem(props) {
|
|
|
798
883
|
]
|
|
799
884
|
})
|
|
800
885
|
}),
|
|
801
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
886
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Row, {
|
|
802
887
|
gutter: 24,
|
|
803
|
-
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
888
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Col, {
|
|
804
889
|
span: o.col || 24,
|
|
805
890
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
806
891
|
...o,
|
|
@@ -810,9 +895,9 @@ function FormItem(props) {
|
|
|
810
895
|
})
|
|
811
896
|
]
|
|
812
897
|
}, field.key)),
|
|
813
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
898
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Form.Item, {
|
|
814
899
|
children: [
|
|
815
|
-
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
900
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd8.Button, {
|
|
816
901
|
type: "dashed",
|
|
817
902
|
block: true,
|
|
818
903
|
onClick: () => add(),
|
|
@@ -827,7 +912,7 @@ function FormItem(props) {
|
|
|
827
912
|
className: "ant-form-item-extra",
|
|
828
913
|
children: computedProps.extra
|
|
829
914
|
}),
|
|
830
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
915
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Form.ErrorList, {
|
|
831
916
|
errors
|
|
832
917
|
})
|
|
833
918
|
]
|
|
@@ -839,19 +924,19 @@ function FormItem(props) {
|
|
|
839
924
|
return null;
|
|
840
925
|
}
|
|
841
926
|
}
|
|
842
|
-
FormItem.useStatus =
|
|
927
|
+
FormItem.useStatus = import_antd8.Form.Item.useStatus;
|
|
843
928
|
|
|
844
929
|
// src/Form.tsx
|
|
845
930
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
846
931
|
function Form(props) {
|
|
847
932
|
var _a, _b;
|
|
848
|
-
const [loading, setLoading] = (0,
|
|
849
|
-
const [computedProps, setComputedProps] = (0,
|
|
933
|
+
const [loading, setLoading] = (0, import_react11.useState)(false);
|
|
934
|
+
const [computedProps, setComputedProps] = (0, import_react11.useState)();
|
|
850
935
|
const config = useConfigContext();
|
|
851
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
852
|
-
const [form] =
|
|
853
|
-
const [initialValues, setInitialValues] = (0,
|
|
854
|
-
(0,
|
|
936
|
+
const [extendTypes, setExtendTypes] = (0, import_react11.useState)();
|
|
937
|
+
const [form] = import_antd9.Form.useForm(props.form);
|
|
938
|
+
const [initialValues, setInitialValues] = (0, import_react11.useState)(props.initialValues);
|
|
939
|
+
(0, import_react11.useEffect)(() => {
|
|
855
940
|
var _a2, _b2, _c;
|
|
856
941
|
const propsCopy = {
|
|
857
942
|
...props,
|
|
@@ -880,7 +965,7 @@ function Form(props) {
|
|
|
880
965
|
setLoading(true);
|
|
881
966
|
try {
|
|
882
967
|
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
883
|
-
await props.onFinish(values, async (values2) => (0,
|
|
968
|
+
await props.onFinish(values, async (values2) => (0, import_react10.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
884
969
|
...values2,
|
|
885
970
|
...propsCopy.submit.to.params
|
|
886
971
|
} : values2));
|
|
@@ -894,7 +979,7 @@ function Form(props) {
|
|
|
894
979
|
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
895
980
|
propsCopy.onFinish = async (values) => {
|
|
896
981
|
setLoading(true);
|
|
897
|
-
return (0,
|
|
982
|
+
return (0, import_react10.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
898
983
|
...values,
|
|
899
984
|
...propsCopy.submit.to.params
|
|
900
985
|
} : values).then((result) => {
|
|
@@ -918,7 +1003,7 @@ function Form(props) {
|
|
|
918
1003
|
}
|
|
919
1004
|
setComputedProps(propsCopy);
|
|
920
1005
|
}, [props]);
|
|
921
|
-
const onValuesChange = (0,
|
|
1006
|
+
const onValuesChange = (0, import_react11.useCallback)((changedValues, allValues) => {
|
|
922
1007
|
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
923
1008
|
if (props.onValuesChange) {
|
|
924
1009
|
props.onValuesChange(changedValues, allValues);
|
|
@@ -931,7 +1016,7 @@ function Form(props) {
|
|
|
931
1016
|
item.onValueChange(changedValues[key], allValues, form);
|
|
932
1017
|
}
|
|
933
1018
|
}, [computedProps]);
|
|
934
|
-
(0,
|
|
1019
|
+
(0, import_react11.useEffect)(() => {
|
|
935
1020
|
if (!initialValues)
|
|
936
1021
|
return;
|
|
937
1022
|
console.debug("Form:initialValues", initialValues);
|
|
@@ -940,17 +1025,17 @@ function Form(props) {
|
|
|
940
1025
|
}, [computedProps]);
|
|
941
1026
|
if (!computedProps)
|
|
942
1027
|
return null;
|
|
943
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd9.Form, {
|
|
944
1029
|
...computedProps,
|
|
945
1030
|
onValuesChange,
|
|
946
1031
|
children: [
|
|
947
1032
|
computedProps.beforeItems,
|
|
948
|
-
(_a = computedProps.items) == null ? void 0 : _a.map((item) => (0,
|
|
1033
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react11.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
949
1034
|
...item,
|
|
950
1035
|
extendTypes
|
|
951
1036
|
}, item.id)),
|
|
952
1037
|
computedProps.children,
|
|
953
|
-
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1038
|
+
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Button, {
|
|
954
1039
|
htmlType: "submit",
|
|
955
1040
|
type: "primary",
|
|
956
1041
|
loading,
|
|
@@ -960,17 +1045,17 @@ function Form(props) {
|
|
|
960
1045
|
]
|
|
961
1046
|
});
|
|
962
1047
|
}
|
|
963
|
-
Form.useForm =
|
|
964
|
-
Form.useFormInstance =
|
|
965
|
-
Form.useWatch =
|
|
1048
|
+
Form.useForm = import_antd9.Form.useForm;
|
|
1049
|
+
Form.useFormInstance = import_antd9.Form.useFormInstance;
|
|
1050
|
+
Form.useWatch = import_antd9.Form.useWatch;
|
|
966
1051
|
Form.Item = FormItem;
|
|
967
|
-
Form.List =
|
|
968
|
-
Form.ErrorList =
|
|
969
|
-
Form.Provider =
|
|
1052
|
+
Form.List = import_antd9.Form.List;
|
|
1053
|
+
Form.ErrorList = import_antd9.Form.ErrorList;
|
|
1054
|
+
Form.Provider = import_antd9.Form.Provider;
|
|
970
1055
|
|
|
971
1056
|
// src/Link.tsx
|
|
972
1057
|
var import_react_router_dom = require("react-router-dom");
|
|
973
|
-
var
|
|
1058
|
+
var import_antd10 = require("antd");
|
|
974
1059
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
975
1060
|
function Link(props) {
|
|
976
1061
|
var _a, _b, _c, _d;
|
|
@@ -987,7 +1072,7 @@ function Link(props) {
|
|
|
987
1072
|
}, style);
|
|
988
1073
|
if (props.href.startsWith("http")) {
|
|
989
1074
|
if (props.button)
|
|
990
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Button, {
|
|
991
1076
|
...props.button,
|
|
992
1077
|
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
993
1078
|
style,
|
|
@@ -1005,7 +1090,7 @@ function Link(props) {
|
|
|
1005
1090
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
|
|
1006
1091
|
to: props.href,
|
|
1007
1092
|
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1008
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1093
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Button, {
|
|
1009
1094
|
...props.button,
|
|
1010
1095
|
style,
|
|
1011
1096
|
children: (_c = props.text) != null ? _c : props.children
|
|
@@ -1019,41 +1104,14 @@ function Link(props) {
|
|
|
1019
1104
|
});
|
|
1020
1105
|
}
|
|
1021
1106
|
|
|
1022
|
-
// src/Modal.tsx
|
|
1023
|
-
var import_antd9 = require("antd");
|
|
1024
|
-
var import_react10 = require("react");
|
|
1025
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1026
|
-
function useModal(init) {
|
|
1027
|
-
const [props, setProps] = (0, import_react10.useState)({
|
|
1028
|
-
open: false,
|
|
1029
|
-
onCancel: () => setProps((prev) => ({
|
|
1030
|
-
...prev,
|
|
1031
|
-
open: false
|
|
1032
|
-
})),
|
|
1033
|
-
...init
|
|
1034
|
-
});
|
|
1035
|
-
return {
|
|
1036
|
-
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Modal, {
|
|
1037
|
-
...props
|
|
1038
|
-
}),
|
|
1039
|
-
modalProps: props,
|
|
1040
|
-
setModalProps(changes) {
|
|
1041
|
-
setProps((prev) => ({
|
|
1042
|
-
...prev,
|
|
1043
|
-
...changes
|
|
1044
|
-
}));
|
|
1045
|
-
}
|
|
1046
|
-
};
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
1107
|
// src/Routers.tsx
|
|
1050
|
-
var
|
|
1051
|
-
var
|
|
1108
|
+
var import_antd11 = require("antd");
|
|
1109
|
+
var import_react12 = require("react");
|
|
1052
1110
|
var import_react_router_dom2 = require("react-router-dom");
|
|
1053
1111
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1054
1112
|
function PageNotFound() {
|
|
1055
1113
|
const config = useConfigContext();
|
|
1056
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1114
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Result, {
|
|
1057
1115
|
status: "404",
|
|
1058
1116
|
title: config.common.pageNotFound
|
|
1059
1117
|
});
|
|
@@ -1063,10 +1121,10 @@ function Routes(props) {
|
|
|
1063
1121
|
children: [
|
|
1064
1122
|
props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Route, {
|
|
1065
1123
|
...r,
|
|
1066
|
-
element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1124
|
+
element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react12.Suspense, {
|
|
1067
1125
|
fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
1068
1126
|
style: { padding: "24px" },
|
|
1069
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1127
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Skeleton, {
|
|
1070
1128
|
active: true
|
|
1071
1129
|
})
|
|
1072
1130
|
}),
|
|
@@ -1082,8 +1140,8 @@ function Routes(props) {
|
|
|
1082
1140
|
}
|
|
1083
1141
|
|
|
1084
1142
|
// src/Table.tsx
|
|
1085
|
-
var
|
|
1086
|
-
var
|
|
1143
|
+
var import_react13 = require("react");
|
|
1144
|
+
var import_antd12 = require("antd");
|
|
1087
1145
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
1088
1146
|
var import_icons3 = require("@ant-design/icons");
|
|
1089
1147
|
var import_lodash_es6 = require("lodash-es");
|
|
@@ -1113,9 +1171,9 @@ function processValue(item, value) {
|
|
|
1113
1171
|
return value;
|
|
1114
1172
|
}
|
|
1115
1173
|
function Table(props) {
|
|
1116
|
-
const [columns, setColumns] = (0,
|
|
1174
|
+
const [columns, setColumns] = (0, import_react13.useState)();
|
|
1117
1175
|
const { common: common2 } = useConfigContext();
|
|
1118
|
-
(0,
|
|
1176
|
+
(0, import_react13.useEffect)(() => {
|
|
1119
1177
|
var _a;
|
|
1120
1178
|
for (const item of props.items) {
|
|
1121
1179
|
if (!item.key)
|
|
@@ -1139,7 +1197,7 @@ function Table(props) {
|
|
|
1139
1197
|
if (item.tableChildren === null)
|
|
1140
1198
|
item.render = () => null;
|
|
1141
1199
|
else if (item.tableChildren)
|
|
1142
|
-
item.render = (value, values) => (0,
|
|
1200
|
+
item.render = (value, values) => (0, import_react13.cloneElement)(
|
|
1143
1201
|
item.tableChildren,
|
|
1144
1202
|
{
|
|
1145
1203
|
scene: "table",
|
|
@@ -1150,7 +1208,7 @@ function Table(props) {
|
|
|
1150
1208
|
else if (item.children === null)
|
|
1151
1209
|
item.render = () => null;
|
|
1152
1210
|
else if (item.children)
|
|
1153
|
-
item.render = (value, values) => (0,
|
|
1211
|
+
item.render = (value, values) => (0, import_react13.cloneElement)(
|
|
1154
1212
|
item.children,
|
|
1155
1213
|
{
|
|
1156
1214
|
scene: "table",
|
|
@@ -1160,7 +1218,7 @@ function Table(props) {
|
|
|
1160
1218
|
);
|
|
1161
1219
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1162
1220
|
if (props.extendTypes[item.type].children)
|
|
1163
|
-
item.render = (value, values) => (0,
|
|
1221
|
+
item.render = (value, values) => (0, import_react13.cloneElement)(
|
|
1164
1222
|
props.extendTypes[item.type].children,
|
|
1165
1223
|
{
|
|
1166
1224
|
scene: "table",
|
|
@@ -1191,7 +1249,7 @@ function Table(props) {
|
|
|
1191
1249
|
setSelectedKeys,
|
|
1192
1250
|
confirm,
|
|
1193
1251
|
clearFilters
|
|
1194
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1252
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1195
1253
|
placeholder: `${common2.search} ${item.title}`,
|
|
1196
1254
|
allowClear: true,
|
|
1197
1255
|
onSearch: (v) => {
|
|
@@ -1221,7 +1279,7 @@ function Table(props) {
|
|
|
1221
1279
|
setSelectedKeys,
|
|
1222
1280
|
confirm,
|
|
1223
1281
|
clearFilters
|
|
1224
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1282
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1225
1283
|
placeholder: `${common2.search} ${item.title}`,
|
|
1226
1284
|
allowClear: true,
|
|
1227
1285
|
onSearch: (v) => {
|
|
@@ -1251,7 +1309,7 @@ function Table(props) {
|
|
|
1251
1309
|
setSelectedKeys,
|
|
1252
1310
|
confirm,
|
|
1253
1311
|
clearFilters
|
|
1254
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1312
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1255
1313
|
placeholder: `${common2.search} ${item.title}`,
|
|
1256
1314
|
allowClear: true,
|
|
1257
1315
|
onSearch: (v) => {
|
|
@@ -1281,7 +1339,7 @@ function Table(props) {
|
|
|
1281
1339
|
setSelectedKeys,
|
|
1282
1340
|
confirm,
|
|
1283
1341
|
clearFilters
|
|
1284
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1342
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Input.Search, {
|
|
1285
1343
|
placeholder: `${common2.search} ${item.title}`,
|
|
1286
1344
|
allowClear: true,
|
|
1287
1345
|
onSearch: (v) => {
|
|
@@ -1313,7 +1371,7 @@ function Table(props) {
|
|
|
1313
1371
|
setSelectedKeys,
|
|
1314
1372
|
selectedKeys,
|
|
1315
1373
|
confirm
|
|
1316
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1374
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd12.Radio.Group, {
|
|
1317
1375
|
style: { padding: 8 },
|
|
1318
1376
|
buttonStyle: "solid",
|
|
1319
1377
|
value: selectedKeys[0],
|
|
@@ -1327,10 +1385,10 @@ function Table(props) {
|
|
|
1327
1385
|
confirm();
|
|
1328
1386
|
},
|
|
1329
1387
|
children: [
|
|
1330
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1331
1389
|
children: common2.all
|
|
1332
1390
|
}),
|
|
1333
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1391
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1334
1392
|
value: "true",
|
|
1335
1393
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1336
1394
|
style: {
|
|
@@ -1339,7 +1397,7 @@ function Table(props) {
|
|
|
1339
1397
|
}
|
|
1340
1398
|
})
|
|
1341
1399
|
}),
|
|
1342
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1400
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1343
1401
|
value: "false",
|
|
1344
1402
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
|
|
1345
1403
|
style: {
|
|
@@ -1348,7 +1406,7 @@ function Table(props) {
|
|
|
1348
1406
|
}
|
|
1349
1407
|
})
|
|
1350
1408
|
}),
|
|
1351
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1409
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Radio.Button, {
|
|
1352
1410
|
value: "null",
|
|
1353
1411
|
children: common2.blank
|
|
1354
1412
|
})
|
|
@@ -1426,7 +1484,7 @@ function Table(props) {
|
|
|
1426
1484
|
}
|
|
1427
1485
|
setColumns(props.items);
|
|
1428
1486
|
}, [props.items]);
|
|
1429
|
-
(0,
|
|
1487
|
+
(0, import_react13.useEffect)(() => {
|
|
1430
1488
|
if (!props.dataSource || !columns)
|
|
1431
1489
|
return;
|
|
1432
1490
|
for (const column of columns) {
|
|
@@ -1451,7 +1509,7 @@ function Table(props) {
|
|
|
1451
1509
|
if (!columns)
|
|
1452
1510
|
return null;
|
|
1453
1511
|
if (props.dataSource)
|
|
1454
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1455
1513
|
...props,
|
|
1456
1514
|
rowKey: props.rowKey || "id",
|
|
1457
1515
|
columns,
|
|
@@ -1472,8 +1530,8 @@ function FaasDataTable({
|
|
|
1472
1530
|
params,
|
|
1473
1531
|
reload
|
|
1474
1532
|
}) {
|
|
1475
|
-
const [currentColumns, setCurrentColumns] = (0,
|
|
1476
|
-
(0,
|
|
1533
|
+
const [currentColumns, setCurrentColumns] = (0, import_react13.useState)(columns);
|
|
1534
|
+
(0, import_react13.useEffect)(() => {
|
|
1477
1535
|
if (!data || Array.isArray(data))
|
|
1478
1536
|
return;
|
|
1479
1537
|
setCurrentColumns((prev) => {
|
|
@@ -1509,20 +1567,20 @@ function FaasDataTable({
|
|
|
1509
1567
|
});
|
|
1510
1568
|
}, [columns, data]);
|
|
1511
1569
|
if (!data)
|
|
1512
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1513
1571
|
...props,
|
|
1514
1572
|
rowKey: props.rowKey || "id",
|
|
1515
1573
|
columns: currentColumns,
|
|
1516
1574
|
dataSource: []
|
|
1517
1575
|
});
|
|
1518
1576
|
if (Array.isArray(data))
|
|
1519
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1520
1578
|
...props,
|
|
1521
1579
|
rowKey: props.rowKey || "id",
|
|
1522
1580
|
columns: currentColumns,
|
|
1523
1581
|
dataSource: data
|
|
1524
1582
|
});
|
|
1525
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd12.Table, {
|
|
1526
1584
|
...props,
|
|
1527
1585
|
rowKey: props.rowKey || "id",
|
|
1528
1586
|
columns: currentColumns,
|
|
@@ -1553,11 +1611,11 @@ function FaasDataTable({
|
|
|
1553
1611
|
}
|
|
1554
1612
|
|
|
1555
1613
|
// src/Title.tsx
|
|
1556
|
-
var
|
|
1614
|
+
var import_react14 = require("react");
|
|
1557
1615
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1558
1616
|
function Title(props) {
|
|
1559
1617
|
const { Title: Title2 } = useConfigContext();
|
|
1560
|
-
(0,
|
|
1618
|
+
(0, import_react14.useEffect)(() => {
|
|
1561
1619
|
const title = Array.isArray(props.title) ? props.title : [props.title];
|
|
1562
1620
|
document.title = title.concat(props.suffix || Title2.suffix).filter((t) => !!t).join(props.separator || Title2.separator);
|
|
1563
1621
|
}, [props]);
|
|
@@ -1577,11 +1635,12 @@ function Title(props) {
|
|
|
1577
1635
|
children: Array.isArray(props.title) ? props.title[0] : props.title
|
|
1578
1636
|
});
|
|
1579
1637
|
if (props.children)
|
|
1580
|
-
return (0,
|
|
1638
|
+
return (0, import_react14.cloneElement)(props.children, { title: props.title });
|
|
1581
1639
|
return null;
|
|
1582
1640
|
}
|
|
1583
1641
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1584
1642
|
0 && (module.exports = {
|
|
1643
|
+
App,
|
|
1585
1644
|
Blank,
|
|
1586
1645
|
ConfigContext,
|
|
1587
1646
|
ConfigProvider,
|
|
@@ -1600,6 +1659,7 @@ function Title(props) {
|
|
|
1600
1659
|
Title,
|
|
1601
1660
|
transferOptions,
|
|
1602
1661
|
transferValue,
|
|
1662
|
+
useApp,
|
|
1603
1663
|
useConfigContext,
|
|
1604
1664
|
useDrawer,
|
|
1605
1665
|
useModal
|