@faasjs/ant-design 0.0.3-beta.5 → 0.0.3-beta.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +199 -271
- package/dist/index.d.ts +270 -200
- package/dist/index.js +488 -283
- package/dist/index.mjs +505 -305
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -31,10 +31,13 @@ __export(src_exports, {
|
|
|
31
31
|
ConfigProvider: () => ConfigProvider,
|
|
32
32
|
Description: () => Description,
|
|
33
33
|
Drawer: () => import_antd4.Drawer,
|
|
34
|
+
ErrorBoundary: () => ErrorBoundary,
|
|
35
|
+
FaasDataWrapper: () => FaasDataWrapper,
|
|
34
36
|
Form: () => Form,
|
|
35
37
|
FormItem: () => FormItem,
|
|
36
38
|
Link: () => Link,
|
|
37
|
-
|
|
39
|
+
Loading: () => Loading,
|
|
40
|
+
Modal: () => import_antd9.Modal,
|
|
38
41
|
PageNotFound: () => PageNotFound,
|
|
39
42
|
Routes: () => Routes,
|
|
40
43
|
Table: () => Table,
|
|
@@ -51,12 +54,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
51
54
|
var import_react = __toESM(require("react"));
|
|
52
55
|
|
|
53
56
|
// src/Blank.tsx
|
|
54
|
-
var
|
|
57
|
+
var import_antd = require("antd");
|
|
55
58
|
var import_lodash_es2 = require("lodash-es");
|
|
56
59
|
|
|
57
60
|
// src/Config.tsx
|
|
58
61
|
var import_react2 = require("react");
|
|
59
|
-
var import_antd = require("antd");
|
|
60
62
|
var import_lodash_es = require("lodash-es");
|
|
61
63
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
64
|
var isZH = /^zh/i.test(navigator.language);
|
|
@@ -112,14 +114,11 @@ function ConfigProvider({
|
|
|
112
114
|
Form: { submit: { text: zh.submit } }
|
|
113
115
|
}, baseConfig));
|
|
114
116
|
} else
|
|
115
|
-
setValues(values);
|
|
117
|
+
setValues((0, import_lodash_es.defaultsDeep)(config, values));
|
|
116
118
|
}, []);
|
|
117
119
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
|
|
118
120
|
value: values,
|
|
119
|
-
children
|
|
120
|
-
...config.antd,
|
|
121
|
-
children
|
|
122
|
-
})
|
|
121
|
+
children
|
|
123
122
|
});
|
|
124
123
|
}
|
|
125
124
|
function useConfigContext() {
|
|
@@ -130,7 +129,7 @@ function useConfigContext() {
|
|
|
130
129
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
131
130
|
function Blank(options) {
|
|
132
131
|
const { Blank: Blank2 } = useConfigContext();
|
|
133
|
-
return !options || (0, import_lodash_es2.isNil)(options.value) || Array.isArray(options.value) && !options.value.length || options.value === "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
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)(import_antd.Typography.Text, {
|
|
134
133
|
disabled: true,
|
|
135
134
|
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
136
135
|
}) : options.value;
|
|
@@ -167,13 +166,50 @@ function transferValue(type, value) {
|
|
|
167
166
|
var import_icons = require("@ant-design/icons");
|
|
168
167
|
var import_antd3 = require("antd");
|
|
169
168
|
var import_lodash_es4 = require("lodash-es");
|
|
170
|
-
var
|
|
171
|
-
|
|
169
|
+
var import_react4 = require("react");
|
|
170
|
+
|
|
171
|
+
// src/FaasDataWrapper.tsx
|
|
172
|
+
var import_react3 = require("@faasjs/react");
|
|
173
|
+
|
|
174
|
+
// src/Loading.tsx
|
|
175
|
+
var import_antd2 = require("antd");
|
|
176
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
177
|
+
function Loading(props) {
|
|
178
|
+
if (props.loading === false)
|
|
179
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
180
|
+
children: props.children
|
|
181
|
+
});
|
|
182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
183
|
+
style: {
|
|
184
|
+
...props.style || {},
|
|
185
|
+
...!props.size || props.size === "large" ? {
|
|
186
|
+
margin: "20vh auto",
|
|
187
|
+
textAlign: "center"
|
|
188
|
+
} : {}
|
|
189
|
+
},
|
|
190
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Spin, {
|
|
191
|
+
size: props.size || "large"
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// src/FaasDataWrapper.tsx
|
|
197
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
198
|
+
function FaasDataWrapper(props) {
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react3.FaasDataWrapper, {
|
|
200
|
+
fallback: props.loading || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {
|
|
201
|
+
...props.loadingProps
|
|
202
|
+
}),
|
|
203
|
+
...props
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// src/Description.tsx
|
|
172
208
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
173
209
|
function DescriptionItemContent(props) {
|
|
174
210
|
var _a;
|
|
175
|
-
const [computedProps, setComputedProps] = (0,
|
|
176
|
-
(0,
|
|
211
|
+
const [computedProps, setComputedProps] = (0, import_react4.useState)();
|
|
212
|
+
(0, import_react4.useEffect)(() => {
|
|
177
213
|
var _a2, _b;
|
|
178
214
|
const propsCopy = { ...props };
|
|
179
215
|
if (!propsCopy.item.title)
|
|
@@ -203,25 +239,40 @@ function DescriptionItemContent(props) {
|
|
|
203
239
|
return null;
|
|
204
240
|
if (computedProps.extendTypes && computedProps.extendTypes[computedProps.item.type])
|
|
205
241
|
if (computedProps.extendTypes[computedProps.item.type].children)
|
|
206
|
-
return (0,
|
|
242
|
+
return (0, import_react4.cloneElement)(
|
|
207
243
|
computedProps.extendTypes[computedProps.item.type].children,
|
|
208
244
|
{
|
|
245
|
+
scene: "description",
|
|
209
246
|
value: computedProps.value,
|
|
210
247
|
values: computedProps.values
|
|
211
248
|
}
|
|
212
249
|
);
|
|
213
250
|
else if (computedProps.extendTypes[computedProps.item.type].render)
|
|
214
251
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
215
|
-
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values)
|
|
252
|
+
children: computedProps.extendTypes[computedProps.item.type].render(computedProps.value, computedProps.values, 0, "description")
|
|
216
253
|
});
|
|
217
254
|
else
|
|
218
255
|
throw Error(computedProps.item.type + " requires children or render");
|
|
256
|
+
if (computedProps.item.descriptionChildren === null)
|
|
257
|
+
return null;
|
|
258
|
+
if (computedProps.item.descriptionChildren)
|
|
259
|
+
return (0, import_react4.cloneElement)(computedProps.item.descriptionChildren, {
|
|
260
|
+
scene: "description",
|
|
261
|
+
value: computedProps.value,
|
|
262
|
+
values: computedProps.values
|
|
263
|
+
});
|
|
264
|
+
if (computedProps.item.children === null)
|
|
265
|
+
return null;
|
|
219
266
|
if (computedProps.item.children)
|
|
220
|
-
return (0,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
267
|
+
return (0, import_react4.cloneElement)(computedProps.item.children, {
|
|
268
|
+
scene: "description",
|
|
269
|
+
value: computedProps.value,
|
|
270
|
+
values: computedProps.values
|
|
224
271
|
});
|
|
272
|
+
if (computedProps.item.descriptionRender)
|
|
273
|
+
return computedProps.item.descriptionRender(computedProps.value, computedProps.values, 0, "description");
|
|
274
|
+
if (computedProps.item.render)
|
|
275
|
+
return computedProps.item.render(computedProps.value, computedProps.values, 0, "description");
|
|
225
276
|
if (computedProps.value === null || Array.isArray(computedProps.value) && !computedProps.value.length)
|
|
226
277
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
227
278
|
switch (computedProps.item.type) {
|
|
@@ -279,7 +330,7 @@ function DescriptionItemContent(props) {
|
|
|
279
330
|
}
|
|
280
331
|
}
|
|
281
332
|
function Description(props) {
|
|
282
|
-
if (
|
|
333
|
+
if (props.dataSource)
|
|
283
334
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
|
|
284
335
|
...props,
|
|
285
336
|
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
@@ -295,10 +346,7 @@ function Description(props) {
|
|
|
295
346
|
}, item.id) : null;
|
|
296
347
|
}).filter(Boolean)
|
|
297
348
|
});
|
|
298
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
299
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Skeleton, {
|
|
300
|
-
active: true
|
|
301
|
-
}),
|
|
349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
302
350
|
render: ({ data }) => {
|
|
303
351
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Descriptions, {
|
|
304
352
|
...props,
|
|
@@ -347,15 +395,62 @@ function useDrawer(init) {
|
|
|
347
395
|
};
|
|
348
396
|
}
|
|
349
397
|
|
|
398
|
+
// src/ErrorBoundary.tsx
|
|
399
|
+
var import_react6 = require("react");
|
|
400
|
+
var import_antd5 = require("antd");
|
|
401
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
402
|
+
var ErrorBoundary = class extends import_react6.Component {
|
|
403
|
+
constructor(props) {
|
|
404
|
+
super(props);
|
|
405
|
+
this.state = {
|
|
406
|
+
error: void 0,
|
|
407
|
+
info: { componentStack: "" }
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
componentDidCatch(error, info) {
|
|
411
|
+
this.setState({
|
|
412
|
+
error,
|
|
413
|
+
info
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
render() {
|
|
417
|
+
const {
|
|
418
|
+
message,
|
|
419
|
+
description,
|
|
420
|
+
children
|
|
421
|
+
} = this.props;
|
|
422
|
+
const { error, info } = this.state;
|
|
423
|
+
const componentStack = info && info.componentStack ? info.componentStack : null;
|
|
424
|
+
const errorMessage = typeof message === "undefined" ? (error || "").toString() : message;
|
|
425
|
+
const errorDescription = typeof description === "undefined" ? componentStack : description;
|
|
426
|
+
if (error) {
|
|
427
|
+
if (this.props.onError)
|
|
428
|
+
return this.props.onError(error, info);
|
|
429
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Alert, {
|
|
430
|
+
type: "error",
|
|
431
|
+
message: errorMessage,
|
|
432
|
+
description: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
|
|
433
|
+
style: {
|
|
434
|
+
fontSize: "0.9em",
|
|
435
|
+
overflowX: "auto"
|
|
436
|
+
},
|
|
437
|
+
children: errorDescription
|
|
438
|
+
})
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
return children;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
350
445
|
// src/Form.tsx
|
|
351
|
-
var
|
|
352
|
-
var
|
|
353
|
-
var
|
|
446
|
+
var import_react8 = require("@faasjs/react");
|
|
447
|
+
var import_antd7 = require("antd");
|
|
448
|
+
var import_react9 = require("react");
|
|
354
449
|
|
|
355
450
|
// src/FormItem.tsx
|
|
356
|
-
var
|
|
451
|
+
var import_antd6 = require("antd");
|
|
357
452
|
var import_icons2 = require("@ant-design/icons");
|
|
358
|
-
var
|
|
453
|
+
var import_react7 = require("react");
|
|
359
454
|
var import_lodash_es5 = require("lodash-es");
|
|
360
455
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
361
456
|
function processProps(propsCopy, config) {
|
|
@@ -406,11 +501,11 @@ function processProps(propsCopy, config) {
|
|
|
406
501
|
}
|
|
407
502
|
function FormItem(props) {
|
|
408
503
|
var _a;
|
|
409
|
-
const [computedProps, setComputedProps] = (0,
|
|
410
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
504
|
+
const [computedProps, setComputedProps] = (0, import_react7.useState)();
|
|
505
|
+
const [extendTypes, setExtendTypes] = (0, import_react7.useState)();
|
|
411
506
|
const { common: common2 } = useConfigContext();
|
|
412
|
-
const [hidden, setHidden] = (0,
|
|
413
|
-
(0,
|
|
507
|
+
const [hidden, setHidden] = (0, import_react7.useState)(props.hidden || false);
|
|
508
|
+
(0, import_react7.useEffect)(() => {
|
|
414
509
|
const propsCopy = { ...props };
|
|
415
510
|
if (propsCopy.extendTypes) {
|
|
416
511
|
setExtendTypes(propsCopy.extendTypes);
|
|
@@ -418,61 +513,79 @@ function FormItem(props) {
|
|
|
418
513
|
}
|
|
419
514
|
if (propsCopy.if) {
|
|
420
515
|
const condition = propsCopy.if;
|
|
421
|
-
propsCopy.shouldUpdate
|
|
516
|
+
const originShouldUpdate = propsCopy.shouldUpdate;
|
|
517
|
+
propsCopy.shouldUpdate = (prev, cur) => {
|
|
422
518
|
const show = condition(cur);
|
|
519
|
+
const shouldUpdate = hidden !== show;
|
|
423
520
|
setHidden(!show);
|
|
424
|
-
|
|
521
|
+
const origin = originShouldUpdate ? typeof originShouldUpdate === "boolean" ? originShouldUpdate : originShouldUpdate(prev, cur, {}) : true;
|
|
522
|
+
return shouldUpdate || origin;
|
|
425
523
|
};
|
|
426
524
|
delete propsCopy.if;
|
|
525
|
+
delete propsCopy.hidden;
|
|
427
526
|
}
|
|
428
527
|
setComputedProps(processProps(propsCopy, common2));
|
|
429
528
|
}, [props]);
|
|
430
529
|
if (!computedProps)
|
|
431
530
|
return null;
|
|
432
531
|
if (hidden)
|
|
433
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
532
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
434
533
|
...computedProps,
|
|
435
534
|
noStyle: true,
|
|
436
535
|
rules: [],
|
|
437
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
536
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
|
|
438
537
|
hidden: true
|
|
439
538
|
})
|
|
440
539
|
});
|
|
441
540
|
if (extendTypes && extendTypes[computedProps.type])
|
|
442
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
443
542
|
...computedProps,
|
|
444
543
|
children: extendTypes[computedProps.type].children
|
|
445
544
|
});
|
|
545
|
+
if (computedProps.formChildren === null)
|
|
546
|
+
return null;
|
|
547
|
+
if (computedProps.formChildren)
|
|
548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
549
|
+
...computedProps,
|
|
550
|
+
children: (0, import_react7.cloneElement)(computedProps.formChildren, { scene: "form" })
|
|
551
|
+
});
|
|
552
|
+
if (computedProps.children === null)
|
|
553
|
+
return null;
|
|
446
554
|
if (computedProps.children)
|
|
447
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
448
556
|
...computedProps,
|
|
449
|
-
children: computedProps.children
|
|
557
|
+
children: (0, import_react7.cloneElement)(computedProps.children, { scene: "form" })
|
|
558
|
+
});
|
|
559
|
+
if (computedProps.formRender)
|
|
560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
561
|
+
...computedProps,
|
|
562
|
+
children: computedProps.formRender(null, null, 0, "form")
|
|
450
563
|
});
|
|
451
564
|
if (computedProps.render)
|
|
452
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
453
566
|
...computedProps,
|
|
454
|
-
children: computedProps.render()
|
|
567
|
+
children: computedProps.render(null, null, 0, "form")
|
|
455
568
|
});
|
|
456
569
|
switch (computedProps.type) {
|
|
457
570
|
case "string":
|
|
458
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
571
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
459
572
|
...computedProps,
|
|
460
|
-
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
573
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
461
574
|
...computedProps.input
|
|
462
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
575
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
|
|
463
576
|
...computedProps.input
|
|
464
577
|
})
|
|
465
578
|
});
|
|
466
579
|
case "string[]":
|
|
467
580
|
if (computedProps.options)
|
|
468
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
469
582
|
...computedProps,
|
|
470
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
583
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
471
584
|
mode: "multiple",
|
|
472
585
|
...computedProps.input
|
|
473
586
|
})
|
|
474
587
|
});
|
|
475
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
|
|
476
589
|
name: computedProps.name,
|
|
477
590
|
rules: computedProps.rules,
|
|
478
591
|
children: (fields, { add, remove }, { errors }) => {
|
|
@@ -488,24 +601,24 @@ function FormItem(props) {
|
|
|
488
601
|
}),
|
|
489
602
|
fields.map((field) => {
|
|
490
603
|
var _a3;
|
|
491
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
492
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
605
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Row, {
|
|
493
606
|
gutter: 24,
|
|
494
607
|
style: { flexFlow: "row nowrap" },
|
|
495
608
|
children: [
|
|
496
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
497
610
|
span: 23,
|
|
498
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
611
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
499
612
|
...field,
|
|
500
613
|
noStyle: true,
|
|
501
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
614
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Input, {
|
|
502
615
|
...computedProps.input
|
|
503
616
|
})
|
|
504
617
|
})
|
|
505
618
|
}),
|
|
506
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
619
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
507
620
|
span: 1,
|
|
508
|
-
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
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)(import_antd6.Button, {
|
|
509
622
|
danger: true,
|
|
510
623
|
type: "link",
|
|
511
624
|
style: { float: "right" },
|
|
@@ -517,15 +630,19 @@ function FormItem(props) {
|
|
|
517
630
|
})
|
|
518
631
|
}, field.key);
|
|
519
632
|
}),
|
|
520
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
633
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
521
634
|
children: [
|
|
522
|
-
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
635
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
523
636
|
type: "dashed",
|
|
524
637
|
block: true,
|
|
525
638
|
onClick: () => add(),
|
|
526
639
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
527
640
|
}),
|
|
528
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
641
|
+
computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
642
|
+
className: "ant-form-item-extra",
|
|
643
|
+
children: computedProps.extra
|
|
644
|
+
}),
|
|
645
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
|
|
529
646
|
errors
|
|
530
647
|
})
|
|
531
648
|
]
|
|
@@ -535,25 +652,25 @@ function FormItem(props) {
|
|
|
535
652
|
}
|
|
536
653
|
});
|
|
537
654
|
case "number":
|
|
538
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
539
656
|
...computedProps,
|
|
540
|
-
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
657
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
541
658
|
...computedProps.input
|
|
542
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
659
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
|
|
543
660
|
style: { width: "100%" },
|
|
544
661
|
...computedProps.input
|
|
545
662
|
})
|
|
546
663
|
});
|
|
547
664
|
case "number[]":
|
|
548
665
|
if (computedProps.options)
|
|
549
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
550
667
|
...computedProps,
|
|
551
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
668
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Select, {
|
|
552
669
|
mode: "multiple",
|
|
553
670
|
...computedProps.input
|
|
554
671
|
})
|
|
555
672
|
});
|
|
556
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
|
|
557
674
|
name: computedProps.name,
|
|
558
675
|
rules: computedProps.rules,
|
|
559
676
|
children: (fields, { add, remove }, { errors }) => {
|
|
@@ -569,25 +686,25 @@ function FormItem(props) {
|
|
|
569
686
|
}),
|
|
570
687
|
fields.map((field) => {
|
|
571
688
|
var _a3;
|
|
572
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
573
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
689
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
690
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Row, {
|
|
574
691
|
gutter: 24,
|
|
575
692
|
style: { flexFlow: "row nowrap" },
|
|
576
693
|
children: [
|
|
577
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
694
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
578
695
|
span: 23,
|
|
579
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
696
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
580
697
|
...field,
|
|
581
698
|
noStyle: true,
|
|
582
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
699
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.InputNumber, {
|
|
583
700
|
style: { width: "100%" },
|
|
584
701
|
...computedProps.input
|
|
585
702
|
})
|
|
586
703
|
})
|
|
587
704
|
}),
|
|
588
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
589
706
|
span: 1,
|
|
590
|
-
children: !((_a3 = computedProps.input) == null ? void 0 : _a3.disabled) && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
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)(import_antd6.Button, {
|
|
591
708
|
danger: true,
|
|
592
709
|
type: "link",
|
|
593
710
|
style: { float: "right" },
|
|
@@ -599,15 +716,19 @@ function FormItem(props) {
|
|
|
599
716
|
})
|
|
600
717
|
}, field.key);
|
|
601
718
|
}),
|
|
602
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
719
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
603
720
|
children: [
|
|
604
|
-
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
721
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
605
722
|
type: "dashed",
|
|
606
723
|
block: true,
|
|
607
724
|
onClick: () => add(),
|
|
608
725
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
609
726
|
}),
|
|
610
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
727
|
+
computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
728
|
+
className: "ant-form-item-extra",
|
|
729
|
+
children: computedProps.extra
|
|
730
|
+
}),
|
|
731
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
|
|
611
732
|
errors
|
|
612
733
|
})
|
|
613
734
|
]
|
|
@@ -617,23 +738,23 @@ function FormItem(props) {
|
|
|
617
738
|
}
|
|
618
739
|
});
|
|
619
740
|
case "boolean":
|
|
620
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
621
742
|
...computedProps,
|
|
622
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
743
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Switch, {
|
|
623
744
|
...computedProps.input
|
|
624
745
|
})
|
|
625
746
|
});
|
|
626
747
|
case "date":
|
|
627
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
628
749
|
...computedProps,
|
|
629
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
750
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.DatePicker, {
|
|
630
751
|
...computedProps.input
|
|
631
752
|
})
|
|
632
753
|
});
|
|
633
754
|
case "time":
|
|
634
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.Item, {
|
|
635
756
|
...computedProps,
|
|
636
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
757
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.TimePicker, {
|
|
637
758
|
...computedProps.input
|
|
638
759
|
})
|
|
639
760
|
});
|
|
@@ -653,12 +774,12 @@ function FormItem(props) {
|
|
|
653
774
|
]
|
|
654
775
|
});
|
|
655
776
|
case "object[]":
|
|
656
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.List, {
|
|
657
778
|
name: computedProps.name,
|
|
658
779
|
rules: computedProps.rules,
|
|
659
780
|
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
660
781
|
children: [
|
|
661
|
-
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
782
|
+
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
662
783
|
style: { marginBottom: 0 },
|
|
663
784
|
children: [
|
|
664
785
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
@@ -668,7 +789,7 @@ function FormItem(props) {
|
|
|
668
789
|
computedProps.label,
|
|
669
790
|
" ",
|
|
670
791
|
field.name + 1,
|
|
671
|
-
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
792
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
672
793
|
danger: true,
|
|
673
794
|
type: "link",
|
|
674
795
|
onClick: () => remove(field.name),
|
|
@@ -677,9 +798,9 @@ function FormItem(props) {
|
|
|
677
798
|
]
|
|
678
799
|
})
|
|
679
800
|
}),
|
|
680
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Row, {
|
|
681
802
|
gutter: 24,
|
|
682
|
-
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
803
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Col, {
|
|
683
804
|
span: o.col || 24,
|
|
684
805
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
685
806
|
...o,
|
|
@@ -689,9 +810,9 @@ function FormItem(props) {
|
|
|
689
810
|
})
|
|
690
811
|
]
|
|
691
812
|
}, field.key)),
|
|
692
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
813
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Form.Item, {
|
|
693
814
|
children: [
|
|
694
|
-
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
815
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd6.Button, {
|
|
695
816
|
type: "dashed",
|
|
696
817
|
block: true,
|
|
697
818
|
onClick: () => add(),
|
|
@@ -702,7 +823,11 @@ function FormItem(props) {
|
|
|
702
823
|
computedProps.label
|
|
703
824
|
]
|
|
704
825
|
}),
|
|
705
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
826
|
+
computedProps.extra && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
827
|
+
className: "ant-form-item-extra",
|
|
828
|
+
children: computedProps.extra
|
|
829
|
+
}),
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Form.ErrorList, {
|
|
706
831
|
errors
|
|
707
832
|
})
|
|
708
833
|
]
|
|
@@ -714,27 +839,28 @@ function FormItem(props) {
|
|
|
714
839
|
return null;
|
|
715
840
|
}
|
|
716
841
|
}
|
|
842
|
+
FormItem.useStatus = import_antd6.Form.Item.useStatus;
|
|
717
843
|
|
|
718
844
|
// src/Form.tsx
|
|
719
845
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
720
846
|
function Form(props) {
|
|
721
847
|
var _a, _b;
|
|
722
|
-
const [loading, setLoading] = (0,
|
|
723
|
-
const [computedProps, setComputedProps] = (0,
|
|
848
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
849
|
+
const [computedProps, setComputedProps] = (0, import_react9.useState)();
|
|
724
850
|
const config = useConfigContext();
|
|
725
|
-
const [extendTypes, setExtendTypes] = (0,
|
|
726
|
-
const [form] =
|
|
727
|
-
const [initialValues, setInitialValues] = (0,
|
|
728
|
-
(0,
|
|
729
|
-
var _a2, _b2;
|
|
851
|
+
const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
|
|
852
|
+
const [form] = import_antd7.Form.useForm(props.form);
|
|
853
|
+
const [initialValues, setInitialValues] = (0, import_react9.useState)(props.initialValues);
|
|
854
|
+
(0, import_react9.useEffect)(() => {
|
|
855
|
+
var _a2, _b2, _c;
|
|
730
856
|
const propsCopy = {
|
|
731
857
|
...props,
|
|
732
858
|
form
|
|
733
859
|
};
|
|
734
|
-
if (propsCopy.initialValues) {
|
|
860
|
+
if (propsCopy.initialValues && ((_a2 = propsCopy.items) == null ? void 0 : _a2.length)) {
|
|
735
861
|
for (const key in propsCopy.initialValues) {
|
|
736
862
|
propsCopy.initialValues[key] = transferValue(
|
|
737
|
-
(
|
|
863
|
+
(_b2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _b2.type,
|
|
738
864
|
propsCopy.initialValues[key]
|
|
739
865
|
);
|
|
740
866
|
const item = propsCopy.items.find((item2) => item2.id === key);
|
|
@@ -754,7 +880,7 @@ function Form(props) {
|
|
|
754
880
|
setLoading(true);
|
|
755
881
|
try {
|
|
756
882
|
if (propsCopy.submit && ((_a3 = propsCopy.submit.to) == null ? void 0 : _a3.action)) {
|
|
757
|
-
await props.onFinish(values, async (values2) => (0,
|
|
883
|
+
await props.onFinish(values, async (values2) => (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
758
884
|
...values2,
|
|
759
885
|
...propsCopy.submit.to.params
|
|
760
886
|
} : values2));
|
|
@@ -765,13 +891,25 @@ function Form(props) {
|
|
|
765
891
|
}
|
|
766
892
|
setLoading(false);
|
|
767
893
|
};
|
|
768
|
-
} else if (propsCopy.submit && ((
|
|
894
|
+
} else if (propsCopy.submit && ((_c = propsCopy.submit.to) == null ? void 0 : _c.action)) {
|
|
769
895
|
propsCopy.onFinish = async (values) => {
|
|
770
896
|
setLoading(true);
|
|
771
|
-
return (0,
|
|
897
|
+
return (0, import_react8.faas)(propsCopy.submit.to.action, propsCopy.submit.to.params ? {
|
|
772
898
|
...values,
|
|
773
899
|
...propsCopy.submit.to.params
|
|
774
|
-
} : values).
|
|
900
|
+
} : values).then((result) => {
|
|
901
|
+
if (propsCopy.submit.to.then)
|
|
902
|
+
propsCopy.submit.to.then(result);
|
|
903
|
+
return result;
|
|
904
|
+
}).catch((error) => {
|
|
905
|
+
if (propsCopy.submit.to.catch)
|
|
906
|
+
propsCopy.submit.to.catch(error);
|
|
907
|
+
return Promise.reject(error);
|
|
908
|
+
}).finally(() => {
|
|
909
|
+
if (propsCopy.submit.to.finally)
|
|
910
|
+
propsCopy.submit.to.finally();
|
|
911
|
+
setLoading(false);
|
|
912
|
+
});
|
|
775
913
|
};
|
|
776
914
|
}
|
|
777
915
|
if (propsCopy.extendTypes) {
|
|
@@ -780,7 +918,7 @@ function Form(props) {
|
|
|
780
918
|
}
|
|
781
919
|
setComputedProps(propsCopy);
|
|
782
920
|
}, [props]);
|
|
783
|
-
const onValuesChange = (0,
|
|
921
|
+
const onValuesChange = (0, import_react9.useCallback)((changedValues, allValues) => {
|
|
784
922
|
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
785
923
|
if (props.onValuesChange) {
|
|
786
924
|
props.onValuesChange(changedValues, allValues);
|
|
@@ -793,7 +931,7 @@ function Form(props) {
|
|
|
793
931
|
item.onValueChange(changedValues[key], allValues, form);
|
|
794
932
|
}
|
|
795
933
|
}, [computedProps]);
|
|
796
|
-
(0,
|
|
934
|
+
(0, import_react9.useEffect)(() => {
|
|
797
935
|
if (!initialValues)
|
|
798
936
|
return;
|
|
799
937
|
console.debug("Form:initialValues", initialValues);
|
|
@@ -802,17 +940,17 @@ function Form(props) {
|
|
|
802
940
|
}, [computedProps]);
|
|
803
941
|
if (!computedProps)
|
|
804
942
|
return null;
|
|
805
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd7.Form, {
|
|
806
944
|
...computedProps,
|
|
807
945
|
onValuesChange,
|
|
808
946
|
children: [
|
|
809
947
|
computedProps.beforeItems,
|
|
810
|
-
(_a = computedProps.items) == null ? void 0 : _a.map((item) => (0,
|
|
948
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react9.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
811
949
|
...item,
|
|
812
950
|
extendTypes
|
|
813
951
|
}, item.id)),
|
|
814
952
|
computedProps.children,
|
|
815
|
-
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
953
|
+
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Button, {
|
|
816
954
|
htmlType: "submit",
|
|
817
955
|
type: "primary",
|
|
818
956
|
loading,
|
|
@@ -822,76 +960,71 @@ function Form(props) {
|
|
|
822
960
|
]
|
|
823
961
|
});
|
|
824
962
|
}
|
|
825
|
-
Form.useForm =
|
|
963
|
+
Form.useForm = import_antd7.Form.useForm;
|
|
964
|
+
Form.useFormInstance = import_antd7.Form.useFormInstance;
|
|
965
|
+
Form.useWatch = import_antd7.Form.useWatch;
|
|
966
|
+
Form.Item = FormItem;
|
|
967
|
+
Form.List = import_antd7.Form.List;
|
|
968
|
+
Form.ErrorList = import_antd7.Form.ErrorList;
|
|
969
|
+
Form.Provider = import_antd7.Form.Provider;
|
|
826
970
|
|
|
827
971
|
// src/Link.tsx
|
|
828
972
|
var import_react_router_dom = require("react-router-dom");
|
|
829
|
-
var
|
|
973
|
+
var import_antd8 = require("antd");
|
|
830
974
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
831
|
-
function Link({
|
|
832
|
-
|
|
833
|
-
target,
|
|
834
|
-
text,
|
|
835
|
-
children,
|
|
836
|
-
style,
|
|
837
|
-
button
|
|
838
|
-
}) {
|
|
975
|
+
function Link(props) {
|
|
976
|
+
var _a, _b, _c, _d;
|
|
839
977
|
const { Link: Link2 } = useConfigContext();
|
|
840
|
-
style =
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
978
|
+
let style = {
|
|
979
|
+
...Link2.style || {},
|
|
980
|
+
cursor: "pointer",
|
|
981
|
+
...props.style
|
|
982
|
+
};
|
|
983
|
+
if (props.block)
|
|
984
|
+
style = Object.assign({
|
|
985
|
+
display: "block",
|
|
986
|
+
width: "100%"
|
|
987
|
+
}, style);
|
|
988
|
+
if (props.href.startsWith("http")) {
|
|
989
|
+
if (props.button)
|
|
990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
991
|
+
...props.button,
|
|
992
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
993
|
+
style,
|
|
994
|
+
href: props.href,
|
|
995
|
+
children: (_a = props.text) != null ? _a : props.children
|
|
854
996
|
});
|
|
855
997
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
856
|
-
href,
|
|
857
|
-
target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
858
|
-
style
|
|
859
|
-
|
|
860
|
-
...style || {}
|
|
861
|
-
},
|
|
862
|
-
children: text || children
|
|
998
|
+
href: props.href,
|
|
999
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
1000
|
+
style,
|
|
1001
|
+
children: (_b = props.text) != null ? _b : props.children
|
|
863
1002
|
});
|
|
864
1003
|
}
|
|
865
|
-
if (button)
|
|
866
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
style
|
|
872
|
-
|
|
873
|
-
...style || {}
|
|
874
|
-
},
|
|
875
|
-
children: text || children
|
|
1004
|
+
if (props.button)
|
|
1005
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
|
|
1006
|
+
to: props.href,
|
|
1007
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1008
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Button, {
|
|
1009
|
+
...props.button,
|
|
1010
|
+
style,
|
|
1011
|
+
children: (_c = props.text) != null ? _c : props.children
|
|
876
1012
|
})
|
|
877
1013
|
});
|
|
878
1014
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
|
|
879
|
-
to: href,
|
|
880
|
-
target: target || (Link2 == null ? void 0 : Link2.target),
|
|
881
|
-
style
|
|
882
|
-
|
|
883
|
-
...style || {}
|
|
884
|
-
},
|
|
885
|
-
children: text || children
|
|
1015
|
+
to: props.href,
|
|
1016
|
+
target: props.target || (Link2 == null ? void 0 : Link2.target),
|
|
1017
|
+
style,
|
|
1018
|
+
children: (_d = props.text) != null ? _d : props.children
|
|
886
1019
|
});
|
|
887
1020
|
}
|
|
888
1021
|
|
|
889
1022
|
// src/Modal.tsx
|
|
890
|
-
var
|
|
891
|
-
var
|
|
1023
|
+
var import_antd9 = require("antd");
|
|
1024
|
+
var import_react10 = require("react");
|
|
892
1025
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
893
1026
|
function useModal(init) {
|
|
894
|
-
const [props, setProps] = (0,
|
|
1027
|
+
const [props, setProps] = (0, import_react10.useState)({
|
|
895
1028
|
open: false,
|
|
896
1029
|
onCancel: () => setProps((prev) => ({
|
|
897
1030
|
...prev,
|
|
@@ -900,7 +1033,7 @@ function useModal(init) {
|
|
|
900
1033
|
...init
|
|
901
1034
|
});
|
|
902
1035
|
return {
|
|
903
|
-
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1036
|
+
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Modal, {
|
|
904
1037
|
...props
|
|
905
1038
|
}),
|
|
906
1039
|
modalProps: props,
|
|
@@ -914,13 +1047,13 @@ function useModal(init) {
|
|
|
914
1047
|
}
|
|
915
1048
|
|
|
916
1049
|
// src/Routers.tsx
|
|
917
|
-
var
|
|
918
|
-
var
|
|
1050
|
+
var import_antd10 = require("antd");
|
|
1051
|
+
var import_react11 = require("react");
|
|
919
1052
|
var import_react_router_dom2 = require("react-router-dom");
|
|
920
1053
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
921
1054
|
function PageNotFound() {
|
|
922
1055
|
const config = useConfigContext();
|
|
923
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1056
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Result, {
|
|
924
1057
|
status: "404",
|
|
925
1058
|
title: config.common.pageNotFound
|
|
926
1059
|
});
|
|
@@ -930,10 +1063,10 @@ function Routes(props) {
|
|
|
930
1063
|
children: [
|
|
931
1064
|
props.routes.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom2.Route, {
|
|
932
1065
|
...r,
|
|
933
|
-
element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1066
|
+
element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react11.Suspense, {
|
|
934
1067
|
fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
935
1068
|
style: { padding: "24px" },
|
|
936
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1069
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd10.Skeleton, {
|
|
937
1070
|
active: true
|
|
938
1071
|
})
|
|
939
1072
|
}),
|
|
@@ -949,12 +1082,11 @@ function Routes(props) {
|
|
|
949
1082
|
}
|
|
950
1083
|
|
|
951
1084
|
// src/Table.tsx
|
|
952
|
-
var
|
|
953
|
-
var
|
|
1085
|
+
var import_react12 = require("react");
|
|
1086
|
+
var import_antd11 = require("antd");
|
|
954
1087
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
955
1088
|
var import_icons3 = require("@ant-design/icons");
|
|
956
1089
|
var import_lodash_es6 = require("lodash-es");
|
|
957
|
-
var import_react12 = require("@faasjs/react");
|
|
958
1090
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
959
1091
|
function processValue(item, value) {
|
|
960
1092
|
var _a;
|
|
@@ -981,9 +1113,9 @@ function processValue(item, value) {
|
|
|
981
1113
|
return value;
|
|
982
1114
|
}
|
|
983
1115
|
function Table(props) {
|
|
984
|
-
const [columns, setColumns] = (0,
|
|
985
|
-
const { common: common2
|
|
986
|
-
(0,
|
|
1116
|
+
const [columns, setColumns] = (0, import_react12.useState)();
|
|
1117
|
+
const { common: common2 } = useConfigContext();
|
|
1118
|
+
(0, import_react12.useEffect)(() => {
|
|
987
1119
|
var _a;
|
|
988
1120
|
for (const item of props.items) {
|
|
989
1121
|
if (!item.key)
|
|
@@ -999,15 +1131,39 @@ function Table(props) {
|
|
|
999
1131
|
item.filters = item.options.map((o) => ({
|
|
1000
1132
|
text: o.label,
|
|
1001
1133
|
value: o.value
|
|
1002
|
-
}))
|
|
1134
|
+
})).concat({
|
|
1135
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1136
|
+
value: null
|
|
1137
|
+
});
|
|
1003
1138
|
}
|
|
1004
|
-
if (item.
|
|
1005
|
-
|
|
1139
|
+
if (item.tableChildren === null)
|
|
1140
|
+
item.render = () => null;
|
|
1141
|
+
else if (item.tableChildren)
|
|
1142
|
+
item.render = (value, values) => (0, import_react12.cloneElement)(
|
|
1143
|
+
item.tableChildren,
|
|
1144
|
+
{
|
|
1145
|
+
scene: "table",
|
|
1146
|
+
value,
|
|
1147
|
+
values
|
|
1148
|
+
}
|
|
1149
|
+
);
|
|
1150
|
+
else if (item.children === null)
|
|
1151
|
+
item.render = () => null;
|
|
1152
|
+
else if (item.children)
|
|
1153
|
+
item.render = (value, values) => (0, import_react12.cloneElement)(
|
|
1154
|
+
item.children,
|
|
1155
|
+
{
|
|
1156
|
+
scene: "table",
|
|
1157
|
+
value,
|
|
1158
|
+
values
|
|
1159
|
+
}
|
|
1160
|
+
);
|
|
1006
1161
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
1007
1162
|
if (props.extendTypes[item.type].children)
|
|
1008
|
-
item.render = (value, values) => (0,
|
|
1163
|
+
item.render = (value, values) => (0, import_react12.cloneElement)(
|
|
1009
1164
|
props.extendTypes[item.type].children,
|
|
1010
1165
|
{
|
|
1166
|
+
scene: "table",
|
|
1011
1167
|
value,
|
|
1012
1168
|
values
|
|
1013
1169
|
}
|
|
@@ -1035,7 +1191,7 @@ function Table(props) {
|
|
|
1035
1191
|
setSelectedKeys,
|
|
1036
1192
|
confirm,
|
|
1037
1193
|
clearFilters
|
|
1038
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1194
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1039
1195
|
placeholder: `${common2.search} ${item.title}`,
|
|
1040
1196
|
allowClear: true,
|
|
1041
1197
|
onSearch: (v) => {
|
|
@@ -1065,7 +1221,7 @@ function Table(props) {
|
|
|
1065
1221
|
setSelectedKeys,
|
|
1066
1222
|
confirm,
|
|
1067
1223
|
clearFilters
|
|
1068
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1224
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1069
1225
|
placeholder: `${common2.search} ${item.title}`,
|
|
1070
1226
|
allowClear: true,
|
|
1071
1227
|
onSearch: (v) => {
|
|
@@ -1088,14 +1244,14 @@ function Table(props) {
|
|
|
1088
1244
|
item.onFilter = (value, row) => {
|
|
1089
1245
|
if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
|
|
1090
1246
|
return true;
|
|
1091
|
-
return value
|
|
1247
|
+
return value == row[item.id];
|
|
1092
1248
|
};
|
|
1093
1249
|
if (!item.filters && item.filterDropdown !== false)
|
|
1094
1250
|
item.filterDropdown = ({
|
|
1095
1251
|
setSelectedKeys,
|
|
1096
1252
|
confirm,
|
|
1097
1253
|
clearFilters
|
|
1098
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1254
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1099
1255
|
placeholder: `${common2.search} ${item.title}`,
|
|
1100
1256
|
allowClear: true,
|
|
1101
1257
|
onSearch: (v) => {
|
|
@@ -1118,14 +1274,14 @@ function Table(props) {
|
|
|
1118
1274
|
return true;
|
|
1119
1275
|
if (!row[item.id] || !row[item.id].length)
|
|
1120
1276
|
return false;
|
|
1121
|
-
return row[item.id].includes(value);
|
|
1277
|
+
return row[item.id].includes(Number(value));
|
|
1122
1278
|
};
|
|
1123
1279
|
if (!item.filters && item.filterDropdown !== false)
|
|
1124
1280
|
item.filterDropdown = ({
|
|
1125
1281
|
setSelectedKeys,
|
|
1126
1282
|
confirm,
|
|
1127
1283
|
clearFilters
|
|
1128
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1284
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Input.Search, {
|
|
1129
1285
|
placeholder: `${common2.search} ${item.title}`,
|
|
1130
1286
|
allowClear: true,
|
|
1131
1287
|
onSearch: (v) => {
|
|
@@ -1141,7 +1297,7 @@ function Table(props) {
|
|
|
1141
1297
|
break;
|
|
1142
1298
|
case "boolean":
|
|
1143
1299
|
if (!item.render)
|
|
1144
|
-
item.render = (value) =>
|
|
1300
|
+
item.render = (value) => (0, import_lodash_es6.isNil)(value) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}) : value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1145
1301
|
style: {
|
|
1146
1302
|
marginTop: "4px",
|
|
1147
1303
|
color: "#52c41a"
|
|
@@ -1157,19 +1313,24 @@ function Table(props) {
|
|
|
1157
1313
|
setSelectedKeys,
|
|
1158
1314
|
selectedKeys,
|
|
1159
1315
|
confirm
|
|
1160
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1316
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd11.Radio.Group, {
|
|
1161
1317
|
style: { padding: 8 },
|
|
1162
1318
|
buttonStyle: "solid",
|
|
1163
1319
|
value: selectedKeys[0],
|
|
1164
1320
|
onChange: (e) => {
|
|
1165
|
-
|
|
1321
|
+
const Values = {
|
|
1322
|
+
true: true,
|
|
1323
|
+
false: false,
|
|
1324
|
+
null: null
|
|
1325
|
+
};
|
|
1326
|
+
setSelectedKeys(e.target.value ? [Values[e.target.value]] : []);
|
|
1166
1327
|
confirm();
|
|
1167
1328
|
},
|
|
1168
1329
|
children: [
|
|
1169
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1330
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1170
1331
|
children: common2.all
|
|
1171
1332
|
}),
|
|
1172
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1173
1334
|
value: "true",
|
|
1174
1335
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1175
1336
|
style: {
|
|
@@ -1178,7 +1339,7 @@ function Table(props) {
|
|
|
1178
1339
|
}
|
|
1179
1340
|
})
|
|
1180
1341
|
}),
|
|
1181
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1342
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1182
1343
|
value: "false",
|
|
1183
1344
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
|
|
1184
1345
|
style: {
|
|
@@ -1187,8 +1348,8 @@ function Table(props) {
|
|
|
1187
1348
|
}
|
|
1188
1349
|
})
|
|
1189
1350
|
}),
|
|
1190
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1191
|
-
value: "
|
|
1351
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Radio.Button, {
|
|
1352
|
+
value: "null",
|
|
1192
1353
|
children: common2.blank
|
|
1193
1354
|
})
|
|
1194
1355
|
]
|
|
@@ -1196,14 +1357,12 @@ function Table(props) {
|
|
|
1196
1357
|
if (!item.onFilter)
|
|
1197
1358
|
item.onFilter = (value, row) => {
|
|
1198
1359
|
switch (value) {
|
|
1199
|
-
case
|
|
1200
|
-
return !(0, import_lodash_es6.isNil)(row[item.id]) &&
|
|
1201
|
-
case
|
|
1360
|
+
case true:
|
|
1361
|
+
return !(0, import_lodash_es6.isNil)(row[item.id]) && row[item.id] !== false;
|
|
1362
|
+
case false:
|
|
1202
1363
|
return !(0, import_lodash_es6.isNil)(row[item.id]) && !row[item.id];
|
|
1203
|
-
case "empty":
|
|
1204
|
-
return (0, import_lodash_es6.isNil)(row[item.id]);
|
|
1205
1364
|
default:
|
|
1206
|
-
return
|
|
1365
|
+
return (0, import_lodash_es6.isNil)(row[item.id]);
|
|
1207
1366
|
}
|
|
1208
1367
|
};
|
|
1209
1368
|
break;
|
|
@@ -1211,9 +1370,15 @@ function Table(props) {
|
|
|
1211
1370
|
if (!item.render)
|
|
1212
1371
|
item.render = (value) => processValue(item, value);
|
|
1213
1372
|
if (!item.onFilter)
|
|
1214
|
-
item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value));
|
|
1373
|
+
item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value), "date");
|
|
1215
1374
|
if (!item.sorter)
|
|
1216
|
-
item.sorter = (a, b
|
|
1375
|
+
item.sorter = (a, b, order) => {
|
|
1376
|
+
if ((0, import_lodash_es6.isNil)(a[item.id]))
|
|
1377
|
+
return order === "ascend" ? 1 : -1;
|
|
1378
|
+
if ((0, import_lodash_es6.isNil)(b[item.id]))
|
|
1379
|
+
return order === "ascend" ? -1 : 1;
|
|
1380
|
+
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1381
|
+
};
|
|
1217
1382
|
break;
|
|
1218
1383
|
case "time":
|
|
1219
1384
|
if (!item.render)
|
|
@@ -1221,7 +1386,13 @@ function Table(props) {
|
|
|
1221
1386
|
if (!item.onFilter)
|
|
1222
1387
|
item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value));
|
|
1223
1388
|
if (!item.sorter)
|
|
1224
|
-
item.sorter = (a, b
|
|
1389
|
+
item.sorter = (a, b, order) => {
|
|
1390
|
+
if ((0, import_lodash_es6.isNil)(a[item.id]))
|
|
1391
|
+
return order === "ascend" ? 1 : -1;
|
|
1392
|
+
if ((0, import_lodash_es6.isNil)(b[item.id]))
|
|
1393
|
+
return order === "ascend" ? -1 : 1;
|
|
1394
|
+
return new Date(a[item.id]).getTime() < new Date(b[item.id]).getTime() ? -1 : 1;
|
|
1395
|
+
};
|
|
1225
1396
|
break;
|
|
1226
1397
|
case "object":
|
|
1227
1398
|
if (!item.render)
|
|
@@ -1233,11 +1404,13 @@ function Table(props) {
|
|
|
1233
1404
|
break;
|
|
1234
1405
|
case "object[]":
|
|
1235
1406
|
if (!item.render)
|
|
1236
|
-
item.render = (value) =>
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1407
|
+
item.render = (value) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
1408
|
+
children: value.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
1409
|
+
items: item.object,
|
|
1410
|
+
dataSource: v || [],
|
|
1411
|
+
column: 1
|
|
1412
|
+
}, i))
|
|
1413
|
+
});
|
|
1241
1414
|
break;
|
|
1242
1415
|
default:
|
|
1243
1416
|
if (!item.render)
|
|
@@ -1253,100 +1426,129 @@ function Table(props) {
|
|
|
1253
1426
|
}
|
|
1254
1427
|
setColumns(props.items);
|
|
1255
1428
|
}, [props.items]);
|
|
1256
|
-
(0,
|
|
1429
|
+
(0, import_react12.useEffect)(() => {
|
|
1257
1430
|
if (!props.dataSource || !columns)
|
|
1258
1431
|
return;
|
|
1259
1432
|
for (const column of columns) {
|
|
1260
1433
|
if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1434
|
+
const filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
|
|
1435
|
+
text: v[column.id],
|
|
1436
|
+
value: v[column.id]
|
|
1437
|
+
}));
|
|
1438
|
+
if (filters.length)
|
|
1439
|
+
setColumns((prev) => {
|
|
1440
|
+
const newColumns = [...prev];
|
|
1441
|
+
const index = newColumns.findIndex((item) => item.id === column.id);
|
|
1442
|
+
newColumns[index].filters = filters.concat({
|
|
1443
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1444
|
+
value: null
|
|
1445
|
+
});
|
|
1446
|
+
return newColumns;
|
|
1270
1447
|
});
|
|
1271
|
-
return newColumns;
|
|
1272
|
-
});
|
|
1273
1448
|
}
|
|
1274
1449
|
}
|
|
1275
1450
|
}, [props.dataSource, columns]);
|
|
1276
1451
|
if (!columns)
|
|
1277
1452
|
return null;
|
|
1278
|
-
if (
|
|
1279
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1280
|
-
...
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
columns,
|
|
1285
|
-
dataSource: props.dataSource
|
|
1286
|
-
})
|
|
1453
|
+
if (props.dataSource)
|
|
1454
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1455
|
+
...props,
|
|
1456
|
+
rowKey: props.rowKey || "id",
|
|
1457
|
+
columns,
|
|
1458
|
+
dataSource: props.dataSource
|
|
1287
1459
|
});
|
|
1288
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
})
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
pagination: processed.pagination,
|
|
1334
|
-
filters: processed.filters,
|
|
1335
|
-
sorter: processed.sorter
|
|
1336
|
-
});
|
|
1337
|
-
return;
|
|
1338
|
-
}
|
|
1339
|
-
reload({
|
|
1340
|
-
...params,
|
|
1341
|
-
pagination,
|
|
1342
|
-
filters,
|
|
1343
|
-
sorter
|
|
1460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataWrapper, {
|
|
1461
|
+
...props.faasData,
|
|
1462
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaasDataTable, {
|
|
1463
|
+
props,
|
|
1464
|
+
columns
|
|
1465
|
+
})
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
function FaasDataTable({
|
|
1469
|
+
props,
|
|
1470
|
+
columns,
|
|
1471
|
+
data,
|
|
1472
|
+
params,
|
|
1473
|
+
reload
|
|
1474
|
+
}) {
|
|
1475
|
+
const [currentColumns, setCurrentColumns] = (0, import_react12.useState)(columns);
|
|
1476
|
+
(0, import_react12.useEffect)(() => {
|
|
1477
|
+
if (!data || Array.isArray(data))
|
|
1478
|
+
return;
|
|
1479
|
+
setCurrentColumns((prev) => {
|
|
1480
|
+
const newColumns = [...prev];
|
|
1481
|
+
for (const column of newColumns) {
|
|
1482
|
+
if (data["options"] && data.options[column.id]) {
|
|
1483
|
+
column.options = data["options"][column.id];
|
|
1484
|
+
column.filters = data["options"][column.id].map((v) => ({
|
|
1485
|
+
text: v.label,
|
|
1486
|
+
value: v.value
|
|
1487
|
+
})).concat({
|
|
1488
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1489
|
+
value: null
|
|
1490
|
+
});
|
|
1491
|
+
column.render = (value) => processValue(column, value);
|
|
1492
|
+
if (column.filterDropdown)
|
|
1493
|
+
delete column.filterDropdown;
|
|
1494
|
+
continue;
|
|
1495
|
+
}
|
|
1496
|
+
if (column.optionsType === "auto" && !column.options && !column.filters) {
|
|
1497
|
+
const filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
|
|
1498
|
+
text: v[column.id],
|
|
1499
|
+
value: v[column.id]
|
|
1500
|
+
}));
|
|
1501
|
+
if (filters.length)
|
|
1502
|
+
column.filters = filters.concat({
|
|
1503
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1504
|
+
value: null
|
|
1344
1505
|
});
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
return newColumns;
|
|
1509
|
+
});
|
|
1510
|
+
}, [columns, data]);
|
|
1511
|
+
if (!data)
|
|
1512
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1513
|
+
...props,
|
|
1514
|
+
rowKey: props.rowKey || "id",
|
|
1515
|
+
columns: currentColumns,
|
|
1516
|
+
dataSource: []
|
|
1517
|
+
});
|
|
1518
|
+
if (Array.isArray(data))
|
|
1519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1520
|
+
...props,
|
|
1521
|
+
rowKey: props.rowKey || "id",
|
|
1522
|
+
columns: currentColumns,
|
|
1523
|
+
dataSource: data
|
|
1524
|
+
});
|
|
1525
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd11.Table, {
|
|
1526
|
+
...props,
|
|
1527
|
+
rowKey: props.rowKey || "id",
|
|
1528
|
+
columns: currentColumns,
|
|
1529
|
+
dataSource: data.rows,
|
|
1530
|
+
pagination: {
|
|
1531
|
+
...props.pagination,
|
|
1532
|
+
...data.pagination
|
|
1348
1533
|
},
|
|
1349
|
-
|
|
1534
|
+
onChange: (pagination, filters, sorter, extra) => {
|
|
1535
|
+
if (props.onChange) {
|
|
1536
|
+
const processed = props.onChange(pagination, filters, sorter, extra);
|
|
1537
|
+
reload({
|
|
1538
|
+
...params,
|
|
1539
|
+
pagination: processed.pagination,
|
|
1540
|
+
filters: processed.filters,
|
|
1541
|
+
sorter: processed.sorter
|
|
1542
|
+
});
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
reload({
|
|
1546
|
+
...params,
|
|
1547
|
+
pagination,
|
|
1548
|
+
filters,
|
|
1549
|
+
sorter
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1350
1552
|
});
|
|
1351
1553
|
}
|
|
1352
1554
|
|
|
@@ -1385,9 +1587,12 @@ function Title(props) {
|
|
|
1385
1587
|
ConfigProvider,
|
|
1386
1588
|
Description,
|
|
1387
1589
|
Drawer,
|
|
1590
|
+
ErrorBoundary,
|
|
1591
|
+
FaasDataWrapper,
|
|
1388
1592
|
Form,
|
|
1389
1593
|
FormItem,
|
|
1390
1594
|
Link,
|
|
1595
|
+
Loading,
|
|
1391
1596
|
Modal,
|
|
1392
1597
|
PageNotFound,
|
|
1393
1598
|
Routes,
|