@faasjs/ant-design 0.0.3-beta.2 → 0.0.3-beta.20
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 +51 -314
- package/dist/index.d.ts +59 -100
- package/dist/index.js +177 -139
- package/dist/index.mjs +87 -48
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -30,11 +30,11 @@ __export(src_exports, {
|
|
|
30
30
|
ConfigContext: () => ConfigContext,
|
|
31
31
|
ConfigProvider: () => ConfigProvider,
|
|
32
32
|
Description: () => Description,
|
|
33
|
-
Drawer: () =>
|
|
33
|
+
Drawer: () => import_antd3.Drawer,
|
|
34
34
|
Form: () => Form,
|
|
35
35
|
FormItem: () => FormItem,
|
|
36
36
|
Link: () => Link,
|
|
37
|
-
Modal: () =>
|
|
37
|
+
Modal: () => import_antd7.Modal,
|
|
38
38
|
PageNotFound: () => PageNotFound,
|
|
39
39
|
Routes: () => Routes,
|
|
40
40
|
Table: () => Table,
|
|
@@ -51,12 +51,11 @@ module.exports = __toCommonJS(src_exports);
|
|
|
51
51
|
var import_react = __toESM(require("react"));
|
|
52
52
|
|
|
53
53
|
// src/Blank.tsx
|
|
54
|
-
var
|
|
54
|
+
var import_antd = require("antd");
|
|
55
55
|
var import_lodash_es2 = require("lodash-es");
|
|
56
56
|
|
|
57
57
|
// src/Config.tsx
|
|
58
58
|
var import_react2 = require("react");
|
|
59
|
-
var import_antd = require("antd");
|
|
60
59
|
var import_lodash_es = require("lodash-es");
|
|
61
60
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
62
61
|
var isZH = /^zh/i.test(navigator.language);
|
|
@@ -116,10 +115,7 @@ function ConfigProvider({
|
|
|
116
115
|
}, []);
|
|
117
116
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
|
|
118
117
|
value: values,
|
|
119
|
-
children
|
|
120
|
-
...config.antd,
|
|
121
|
-
children
|
|
122
|
-
})
|
|
118
|
+
children
|
|
123
119
|
});
|
|
124
120
|
}
|
|
125
121
|
function useConfigContext() {
|
|
@@ -130,7 +126,7 @@ function useConfigContext() {
|
|
|
130
126
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
131
127
|
function Blank(options) {
|
|
132
128
|
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)(
|
|
129
|
+
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
130
|
disabled: true,
|
|
135
131
|
children: (options == null ? void 0 : options.text) || Blank2.text
|
|
136
132
|
}) : options.value;
|
|
@@ -165,7 +161,7 @@ function transferValue(type, value) {
|
|
|
165
161
|
|
|
166
162
|
// src/Description.tsx
|
|
167
163
|
var import_icons = require("@ant-design/icons");
|
|
168
|
-
var
|
|
164
|
+
var import_antd2 = require("antd");
|
|
169
165
|
var import_lodash_es4 = require("lodash-es");
|
|
170
166
|
var import_react3 = require("react");
|
|
171
167
|
var import_react4 = require("@faasjs/react");
|
|
@@ -217,7 +213,10 @@ function DescriptionItemContent(props) {
|
|
|
217
213
|
else
|
|
218
214
|
throw Error(computedProps.item.type + " requires children or render");
|
|
219
215
|
if (computedProps.item.children)
|
|
220
|
-
return (0, import_react3.cloneElement)(computedProps.item.children, {
|
|
216
|
+
return (0, import_react3.cloneElement)(computedProps.item.children, {
|
|
217
|
+
value: computedProps.value,
|
|
218
|
+
values: computedProps.values
|
|
219
|
+
});
|
|
221
220
|
if (computedProps.item.render)
|
|
222
221
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
223
222
|
children: computedProps.item.render(computedProps.value, computedProps.values)
|
|
@@ -266,7 +265,7 @@ function DescriptionItemContent(props) {
|
|
|
266
265
|
case "object[]":
|
|
267
266
|
if (!((_a = computedProps.value) == null ? void 0 : _a.length))
|
|
268
267
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {});
|
|
269
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Space, {
|
|
270
269
|
direction: "vertical",
|
|
271
270
|
children: computedProps.value.map((value, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Description, {
|
|
272
271
|
items: computedProps.item.object,
|
|
@@ -280,11 +279,11 @@ function DescriptionItemContent(props) {
|
|
|
280
279
|
}
|
|
281
280
|
function Description(props) {
|
|
282
281
|
if (!props.faasData)
|
|
283
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Descriptions, {
|
|
284
283
|
...props,
|
|
285
284
|
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(props.dataSource) : props.title,
|
|
286
285
|
children: props.items.map((item) => {
|
|
287
|
-
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
286
|
+
return !item.if || item.if(props.dataSource) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Descriptions.Item, {
|
|
288
287
|
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
289
288
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
290
289
|
item,
|
|
@@ -296,15 +295,15 @@ function Description(props) {
|
|
|
296
295
|
}).filter(Boolean)
|
|
297
296
|
});
|
|
298
297
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react4.FaasDataWrapper, {
|
|
299
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
298
|
+
fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Skeleton, {
|
|
300
299
|
active: true
|
|
301
300
|
}),
|
|
302
301
|
render: ({ data }) => {
|
|
303
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Descriptions, {
|
|
304
303
|
...props,
|
|
305
304
|
title: (0, import_lodash_es4.isFunction)(props.renderTitle) ? props.renderTitle(data) : props.title,
|
|
306
305
|
children: props.items.map((item) => {
|
|
307
|
-
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
306
|
+
return !item.if || item.if(data) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd2.Descriptions.Item, {
|
|
308
307
|
label: item.title || (0, import_lodash_es4.upperFirst)(item.id),
|
|
309
308
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DescriptionItemContent, {
|
|
310
309
|
item,
|
|
@@ -321,7 +320,7 @@ function Description(props) {
|
|
|
321
320
|
}
|
|
322
321
|
|
|
323
322
|
// src/Drawer.tsx
|
|
324
|
-
var
|
|
323
|
+
var import_antd3 = require("antd");
|
|
325
324
|
var import_react5 = require("react");
|
|
326
325
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
327
326
|
function useDrawer(init) {
|
|
@@ -334,7 +333,7 @@ function useDrawer(init) {
|
|
|
334
333
|
...init
|
|
335
334
|
});
|
|
336
335
|
return {
|
|
337
|
-
drawer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
336
|
+
drawer: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd3.Drawer, {
|
|
338
337
|
...props
|
|
339
338
|
}),
|
|
340
339
|
drawerProps: props,
|
|
@@ -349,11 +348,11 @@ function useDrawer(init) {
|
|
|
349
348
|
|
|
350
349
|
// src/Form.tsx
|
|
351
350
|
var import_react7 = require("@faasjs/react");
|
|
352
|
-
var
|
|
351
|
+
var import_antd5 = require("antd");
|
|
353
352
|
var import_react8 = require("react");
|
|
354
353
|
|
|
355
354
|
// src/FormItem.tsx
|
|
356
|
-
var
|
|
355
|
+
var import_antd4 = require("antd");
|
|
357
356
|
var import_icons2 = require("@ant-design/icons");
|
|
358
357
|
var import_react6 = require("react");
|
|
359
358
|
var import_lodash_es5 = require("lodash-es");
|
|
@@ -375,13 +374,13 @@ function processProps(propsCopy, config) {
|
|
|
375
374
|
required: true,
|
|
376
375
|
validator: async (_, values) => {
|
|
377
376
|
if (!values || values.length < 1)
|
|
378
|
-
return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.
|
|
377
|
+
return Promise.reject(Error(`${propsCopy.label || propsCopy.title} ${config.required}`));
|
|
379
378
|
}
|
|
380
379
|
});
|
|
381
380
|
else
|
|
382
381
|
propsCopy.rules.push({
|
|
383
382
|
required: true,
|
|
384
|
-
message: `${propsCopy.label || propsCopy.title} ${config.
|
|
383
|
+
message: `${propsCopy.label || propsCopy.title} ${config.required}`
|
|
385
384
|
});
|
|
386
385
|
}
|
|
387
386
|
if (!propsCopy.input)
|
|
@@ -408,8 +407,8 @@ function FormItem(props) {
|
|
|
408
407
|
var _a;
|
|
409
408
|
const [computedProps, setComputedProps] = (0, import_react6.useState)();
|
|
410
409
|
const [extendTypes, setExtendTypes] = (0, import_react6.useState)();
|
|
411
|
-
const
|
|
412
|
-
const [hidden, setHidden] = (0, import_react6.useState)(false);
|
|
410
|
+
const { common: common2 } = useConfigContext();
|
|
411
|
+
const [hidden, setHidden] = (0, import_react6.useState)(props.hidden || false);
|
|
413
412
|
(0, import_react6.useEffect)(() => {
|
|
414
413
|
const propsCopy = { ...props };
|
|
415
414
|
if (propsCopy.extendTypes) {
|
|
@@ -418,61 +417,65 @@ function FormItem(props) {
|
|
|
418
417
|
}
|
|
419
418
|
if (propsCopy.if) {
|
|
420
419
|
const condition = propsCopy.if;
|
|
421
|
-
propsCopy.shouldUpdate
|
|
420
|
+
const originShouldUpdate = propsCopy.shouldUpdate;
|
|
421
|
+
propsCopy.shouldUpdate = (prev, cur) => {
|
|
422
422
|
const show = condition(cur);
|
|
423
|
+
const shouldUpdate = hidden !== show;
|
|
423
424
|
setHidden(!show);
|
|
424
|
-
|
|
425
|
+
const origin = originShouldUpdate ? typeof originShouldUpdate === "boolean" ? originShouldUpdate : originShouldUpdate(prev, cur, {}) : true;
|
|
426
|
+
return shouldUpdate || origin;
|
|
425
427
|
};
|
|
426
428
|
delete propsCopy.if;
|
|
429
|
+
delete propsCopy.hidden;
|
|
427
430
|
}
|
|
428
|
-
setComputedProps(processProps(propsCopy,
|
|
431
|
+
setComputedProps(processProps(propsCopy, common2));
|
|
429
432
|
}, [props]);
|
|
430
433
|
if (!computedProps)
|
|
431
434
|
return null;
|
|
432
435
|
if (hidden)
|
|
433
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
434
437
|
...computedProps,
|
|
435
438
|
noStyle: true,
|
|
436
439
|
rules: [],
|
|
437
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
440
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Input, {
|
|
438
441
|
hidden: true
|
|
439
442
|
})
|
|
440
443
|
});
|
|
441
444
|
if (extendTypes && extendTypes[computedProps.type])
|
|
442
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
443
446
|
...computedProps,
|
|
444
447
|
children: extendTypes[computedProps.type].children
|
|
445
448
|
});
|
|
446
449
|
if (computedProps.children)
|
|
447
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
448
451
|
...computedProps,
|
|
449
452
|
children: computedProps.children
|
|
450
453
|
});
|
|
451
454
|
if (computedProps.render)
|
|
452
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
453
456
|
...computedProps,
|
|
454
457
|
children: computedProps.render()
|
|
455
458
|
});
|
|
456
459
|
switch (computedProps.type) {
|
|
457
460
|
case "string":
|
|
458
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
459
462
|
...computedProps,
|
|
460
|
-
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
463
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Select, {
|
|
461
464
|
...computedProps.input
|
|
462
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
465
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Input, {
|
|
463
466
|
...computedProps.input
|
|
464
467
|
})
|
|
465
468
|
});
|
|
466
469
|
case "string[]":
|
|
467
470
|
if (computedProps.options)
|
|
468
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
469
472
|
...computedProps,
|
|
470
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
473
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Select, {
|
|
471
474
|
mode: "multiple",
|
|
472
475
|
...computedProps.input
|
|
473
476
|
})
|
|
474
477
|
});
|
|
475
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.List, {
|
|
476
479
|
name: computedProps.name,
|
|
477
480
|
rules: computedProps.rules,
|
|
478
481
|
children: (fields, { add, remove }, { errors }) => {
|
|
@@ -488,24 +491,24 @@ function FormItem(props) {
|
|
|
488
491
|
}),
|
|
489
492
|
fields.map((field) => {
|
|
490
493
|
var _a3;
|
|
491
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
492
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
495
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd4.Row, {
|
|
493
496
|
gutter: 24,
|
|
494
497
|
style: { flexFlow: "row nowrap" },
|
|
495
498
|
children: [
|
|
496
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Col, {
|
|
497
500
|
span: 23,
|
|
498
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
501
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
499
502
|
...field,
|
|
500
503
|
noStyle: true,
|
|
501
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
504
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Input, {
|
|
502
505
|
...computedProps.input
|
|
503
506
|
})
|
|
504
507
|
})
|
|
505
508
|
}),
|
|
506
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
509
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Col, {
|
|
507
510
|
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)(
|
|
511
|
+
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_antd4.Button, {
|
|
509
512
|
danger: true,
|
|
510
513
|
type: "link",
|
|
511
514
|
style: { float: "right" },
|
|
@@ -517,15 +520,15 @@ function FormItem(props) {
|
|
|
517
520
|
})
|
|
518
521
|
}, field.key);
|
|
519
522
|
}),
|
|
520
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
523
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd4.Form.Item, {
|
|
521
524
|
children: [
|
|
522
|
-
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
525
|
+
!((_a2 = computedProps.input) == null ? void 0 : _a2.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Button, {
|
|
523
526
|
type: "dashed",
|
|
524
527
|
block: true,
|
|
525
528
|
onClick: () => add(),
|
|
526
529
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
527
530
|
}),
|
|
528
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
531
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.ErrorList, {
|
|
529
532
|
errors
|
|
530
533
|
})
|
|
531
534
|
]
|
|
@@ -535,25 +538,25 @@ function FormItem(props) {
|
|
|
535
538
|
}
|
|
536
539
|
});
|
|
537
540
|
case "number":
|
|
538
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
539
542
|
...computedProps,
|
|
540
|
-
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
543
|
+
children: computedProps.options ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Select, {
|
|
541
544
|
...computedProps.input
|
|
542
|
-
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
545
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.InputNumber, {
|
|
543
546
|
style: { width: "100%" },
|
|
544
547
|
...computedProps.input
|
|
545
548
|
})
|
|
546
549
|
});
|
|
547
550
|
case "number[]":
|
|
548
551
|
if (computedProps.options)
|
|
549
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
550
553
|
...computedProps,
|
|
551
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
554
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Select, {
|
|
552
555
|
mode: "multiple",
|
|
553
556
|
...computedProps.input
|
|
554
557
|
})
|
|
555
558
|
});
|
|
556
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.List, {
|
|
557
560
|
name: computedProps.name,
|
|
558
561
|
rules: computedProps.rules,
|
|
559
562
|
children: (fields, { add, remove }, { errors }) => {
|
|
@@ -569,25 +572,25 @@ function FormItem(props) {
|
|
|
569
572
|
}),
|
|
570
573
|
fields.map((field) => {
|
|
571
574
|
var _a3;
|
|
572
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
573
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
576
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd4.Row, {
|
|
574
577
|
gutter: 24,
|
|
575
578
|
style: { flexFlow: "row nowrap" },
|
|
576
579
|
children: [
|
|
577
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Col, {
|
|
578
581
|
span: 23,
|
|
579
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
582
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
580
583
|
...field,
|
|
581
584
|
noStyle: true,
|
|
582
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
585
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.InputNumber, {
|
|
583
586
|
style: { width: "100%" },
|
|
584
587
|
...computedProps.input
|
|
585
588
|
})
|
|
586
589
|
})
|
|
587
590
|
}),
|
|
588
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
591
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Col, {
|
|
589
592
|
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)(
|
|
593
|
+
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_antd4.Button, {
|
|
591
594
|
danger: true,
|
|
592
595
|
type: "link",
|
|
593
596
|
style: { float: "right" },
|
|
@@ -599,15 +602,15 @@ function FormItem(props) {
|
|
|
599
602
|
})
|
|
600
603
|
}, field.key);
|
|
601
604
|
}),
|
|
602
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
605
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd4.Form.Item, {
|
|
603
606
|
children: [
|
|
604
|
-
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
607
|
+
!((_b = computedProps.input) == null ? void 0 : _b.disabled) && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Button, {
|
|
605
608
|
type: "dashed",
|
|
606
609
|
block: true,
|
|
607
610
|
onClick: () => add(),
|
|
608
611
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {})
|
|
609
612
|
}),
|
|
610
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
613
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.ErrorList, {
|
|
611
614
|
errors
|
|
612
615
|
})
|
|
613
616
|
]
|
|
@@ -617,23 +620,23 @@ function FormItem(props) {
|
|
|
617
620
|
}
|
|
618
621
|
});
|
|
619
622
|
case "boolean":
|
|
620
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
621
624
|
...computedProps,
|
|
622
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
625
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Switch, {
|
|
623
626
|
...computedProps.input
|
|
624
627
|
})
|
|
625
628
|
});
|
|
626
629
|
case "date":
|
|
627
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
628
631
|
...computedProps,
|
|
629
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
632
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.DatePicker, {
|
|
630
633
|
...computedProps.input
|
|
631
634
|
})
|
|
632
635
|
});
|
|
633
636
|
case "time":
|
|
634
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.Item, {
|
|
635
638
|
...computedProps,
|
|
636
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
639
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.TimePicker, {
|
|
637
640
|
...computedProps.input
|
|
638
641
|
})
|
|
639
642
|
});
|
|
@@ -653,12 +656,12 @@ function FormItem(props) {
|
|
|
653
656
|
]
|
|
654
657
|
});
|
|
655
658
|
case "object[]":
|
|
656
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
659
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.List, {
|
|
657
660
|
name: computedProps.name,
|
|
658
661
|
rules: computedProps.rules,
|
|
659
662
|
children: (fields, { add, remove }, { errors }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
660
663
|
children: [
|
|
661
|
-
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
664
|
+
fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd4.Form.Item, {
|
|
662
665
|
style: { marginBottom: 0 },
|
|
663
666
|
children: [
|
|
664
667
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
@@ -668,18 +671,18 @@ function FormItem(props) {
|
|
|
668
671
|
computedProps.label,
|
|
669
672
|
" ",
|
|
670
673
|
field.name + 1,
|
|
671
|
-
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
674
|
+
!computedProps.disabled && (!computedProps.rules.find((r) => r.required) || field.key > 0) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Button, {
|
|
672
675
|
danger: true,
|
|
673
676
|
type: "link",
|
|
674
677
|
onClick: () => remove(field.name),
|
|
675
|
-
children:
|
|
678
|
+
children: common2.delete
|
|
676
679
|
})
|
|
677
680
|
]
|
|
678
681
|
})
|
|
679
682
|
}),
|
|
680
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
683
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Row, {
|
|
681
684
|
gutter: 24,
|
|
682
|
-
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
685
|
+
children: computedProps.object.map((o) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Col, {
|
|
683
686
|
span: o.col || 24,
|
|
684
687
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
685
688
|
...o,
|
|
@@ -689,20 +692,20 @@ function FormItem(props) {
|
|
|
689
692
|
})
|
|
690
693
|
]
|
|
691
694
|
}, field.key)),
|
|
692
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
695
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd4.Form.Item, {
|
|
693
696
|
children: [
|
|
694
|
-
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
697
|
+
!computedProps.disabled && (!computedProps.maxCount || computedProps.maxCount > fields.length) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd4.Button, {
|
|
695
698
|
type: "dashed",
|
|
696
699
|
block: true,
|
|
697
700
|
onClick: () => add(),
|
|
698
701
|
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons2.PlusOutlined, {}),
|
|
699
702
|
children: [
|
|
700
|
-
|
|
703
|
+
common2.add,
|
|
701
704
|
" ",
|
|
702
705
|
computedProps.label
|
|
703
706
|
]
|
|
704
707
|
}),
|
|
705
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
708
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd4.Form.ErrorList, {
|
|
706
709
|
errors
|
|
707
710
|
})
|
|
708
711
|
]
|
|
@@ -723,7 +726,7 @@ function Form(props) {
|
|
|
723
726
|
const [computedProps, setComputedProps] = (0, import_react8.useState)();
|
|
724
727
|
const config = useConfigContext();
|
|
725
728
|
const [extendTypes, setExtendTypes] = (0, import_react8.useState)();
|
|
726
|
-
const [form] =
|
|
729
|
+
const [form] = import_antd5.Form.useForm(props.form);
|
|
727
730
|
const [initialValues, setInitialValues] = (0, import_react8.useState)(props.initialValues);
|
|
728
731
|
(0, import_react8.useEffect)(() => {
|
|
729
732
|
var _a2, _b2;
|
|
@@ -732,11 +735,19 @@ function Form(props) {
|
|
|
732
735
|
form
|
|
733
736
|
};
|
|
734
737
|
if (propsCopy.initialValues) {
|
|
735
|
-
for (const key in propsCopy.initialValues)
|
|
738
|
+
for (const key in propsCopy.initialValues) {
|
|
736
739
|
propsCopy.initialValues[key] = transferValue(
|
|
737
|
-
(_a2 = propsCopy.items.find((
|
|
740
|
+
(_a2 = propsCopy.items.find((item2) => item2.id === key)) == null ? void 0 : _a2.type,
|
|
738
741
|
propsCopy.initialValues[key]
|
|
739
742
|
);
|
|
743
|
+
const item = propsCopy.items.find((item2) => item2.id === key);
|
|
744
|
+
if (item == null ? void 0 : item.if)
|
|
745
|
+
item.hidden = !item.if(propsCopy.initialValues);
|
|
746
|
+
}
|
|
747
|
+
for (const item of propsCopy.items) {
|
|
748
|
+
if (item.if)
|
|
749
|
+
item.hidden = !item.if(propsCopy.initialValues);
|
|
750
|
+
}
|
|
740
751
|
setInitialValues(propsCopy.initialValues);
|
|
741
752
|
delete propsCopy.initialValues;
|
|
742
753
|
}
|
|
@@ -773,6 +784,7 @@ function Form(props) {
|
|
|
773
784
|
setComputedProps(propsCopy);
|
|
774
785
|
}, [props]);
|
|
775
786
|
const onValuesChange = (0, import_react8.useCallback)((changedValues, allValues) => {
|
|
787
|
+
console.debug("Form:onValuesChange", changedValues, allValues);
|
|
776
788
|
if (props.onValuesChange) {
|
|
777
789
|
props.onValuesChange(changedValues, allValues);
|
|
778
790
|
}
|
|
@@ -787,22 +799,23 @@ function Form(props) {
|
|
|
787
799
|
(0, import_react8.useEffect)(() => {
|
|
788
800
|
if (!initialValues)
|
|
789
801
|
return;
|
|
802
|
+
console.debug("Form:initialValues", initialValues);
|
|
790
803
|
form.setFieldsValue(initialValues);
|
|
791
804
|
setInitialValues(null);
|
|
792
805
|
}, [computedProps]);
|
|
793
806
|
if (!computedProps)
|
|
794
807
|
return null;
|
|
795
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd5.Form, {
|
|
796
809
|
...computedProps,
|
|
797
810
|
onValuesChange,
|
|
798
811
|
children: [
|
|
799
812
|
computedProps.beforeItems,
|
|
800
|
-
(_a = computedProps.items) == null ? void 0 : _a.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
813
|
+
(_a = computedProps.items) == null ? void 0 : _a.map((item) => (0, import_react8.isValidElement)(item) ? item : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormItem, {
|
|
801
814
|
...item,
|
|
802
815
|
extendTypes
|
|
803
816
|
}, item.id)),
|
|
804
817
|
computedProps.children,
|
|
805
|
-
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
818
|
+
computedProps.submit !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd5.Button, {
|
|
806
819
|
htmlType: "submit",
|
|
807
820
|
type: "primary",
|
|
808
821
|
loading,
|
|
@@ -812,11 +825,11 @@ function Form(props) {
|
|
|
812
825
|
]
|
|
813
826
|
});
|
|
814
827
|
}
|
|
815
|
-
Form.useForm =
|
|
828
|
+
Form.useForm = import_antd5.Form.useForm;
|
|
816
829
|
|
|
817
830
|
// src/Link.tsx
|
|
818
831
|
var import_react_router_dom = require("react-router-dom");
|
|
819
|
-
var
|
|
832
|
+
var import_antd6 = require("antd");
|
|
820
833
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
821
834
|
function Link({
|
|
822
835
|
href,
|
|
@@ -830,17 +843,15 @@ function Link({
|
|
|
830
843
|
style = Object.assign({ cursor: "pointer" }, style);
|
|
831
844
|
if (href.startsWith("http")) {
|
|
832
845
|
if (button)
|
|
833
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
834
847
|
...button,
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
style
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
children: text || children
|
|
843
|
-
})
|
|
848
|
+
target: target || (Link2 == null ? void 0 : Link2.target) || "_blank",
|
|
849
|
+
style: {
|
|
850
|
+
...Link2.style,
|
|
851
|
+
...style || {}
|
|
852
|
+
},
|
|
853
|
+
href,
|
|
854
|
+
children: text != null ? text : children
|
|
844
855
|
});
|
|
845
856
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
846
857
|
href,
|
|
@@ -849,20 +860,20 @@ function Link({
|
|
|
849
860
|
...Link2.style,
|
|
850
861
|
...style || {}
|
|
851
862
|
},
|
|
852
|
-
children: text
|
|
863
|
+
children: text != null ? text : children
|
|
853
864
|
});
|
|
854
865
|
}
|
|
855
866
|
if (button)
|
|
856
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
867
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
|
|
868
|
+
to: href,
|
|
869
|
+
target: target || (Link2 == null ? void 0 : Link2.target),
|
|
870
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd6.Button, {
|
|
871
|
+
...button,
|
|
861
872
|
style: {
|
|
862
873
|
...Link2.style,
|
|
863
874
|
...style || {}
|
|
864
875
|
},
|
|
865
|
-
children: text
|
|
876
|
+
children: text != null ? text : children
|
|
866
877
|
})
|
|
867
878
|
});
|
|
868
879
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Link, {
|
|
@@ -872,12 +883,12 @@ function Link({
|
|
|
872
883
|
...Link2.style,
|
|
873
884
|
...style || {}
|
|
874
885
|
},
|
|
875
|
-
children: text
|
|
886
|
+
children: text != null ? text : children
|
|
876
887
|
});
|
|
877
888
|
}
|
|
878
889
|
|
|
879
890
|
// src/Modal.tsx
|
|
880
|
-
var
|
|
891
|
+
var import_antd7 = require("antd");
|
|
881
892
|
var import_react9 = require("react");
|
|
882
893
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
883
894
|
function useModal(init) {
|
|
@@ -890,7 +901,7 @@ function useModal(init) {
|
|
|
890
901
|
...init
|
|
891
902
|
});
|
|
892
903
|
return {
|
|
893
|
-
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
904
|
+
modal: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd7.Modal, {
|
|
894
905
|
...props
|
|
895
906
|
}),
|
|
896
907
|
modalProps: props,
|
|
@@ -904,13 +915,13 @@ function useModal(init) {
|
|
|
904
915
|
}
|
|
905
916
|
|
|
906
917
|
// src/Routers.tsx
|
|
907
|
-
var
|
|
918
|
+
var import_antd8 = require("antd");
|
|
908
919
|
var import_react10 = require("react");
|
|
909
920
|
var import_react_router_dom2 = require("react-router-dom");
|
|
910
921
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
911
922
|
function PageNotFound() {
|
|
912
923
|
const config = useConfigContext();
|
|
913
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
924
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Result, {
|
|
914
925
|
status: "404",
|
|
915
926
|
title: config.common.pageNotFound
|
|
916
927
|
});
|
|
@@ -923,7 +934,7 @@ function Routes(props) {
|
|
|
923
934
|
element: r.element || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react10.Suspense, {
|
|
924
935
|
fallback: props.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
925
936
|
style: { padding: "24px" },
|
|
926
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
937
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd8.Skeleton, {
|
|
927
938
|
active: true
|
|
928
939
|
})
|
|
929
940
|
}),
|
|
@@ -940,7 +951,7 @@ function Routes(props) {
|
|
|
940
951
|
|
|
941
952
|
// src/Table.tsx
|
|
942
953
|
var import_react11 = require("react");
|
|
943
|
-
var
|
|
954
|
+
var import_antd9 = require("antd");
|
|
944
955
|
var import_dayjs2 = __toESM(require("dayjs"));
|
|
945
956
|
var import_icons3 = require("@ant-design/icons");
|
|
946
957
|
var import_lodash_es6 = require("lodash-es");
|
|
@@ -992,7 +1003,13 @@ function Table(props) {
|
|
|
992
1003
|
}));
|
|
993
1004
|
}
|
|
994
1005
|
if (item.children)
|
|
995
|
-
|
|
1006
|
+
item.render = (value, values) => (0, import_react11.cloneElement)(
|
|
1007
|
+
item.children,
|
|
1008
|
+
{
|
|
1009
|
+
value,
|
|
1010
|
+
values
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
996
1013
|
if (props.extendTypes && props.extendTypes[item.type]) {
|
|
997
1014
|
if (props.extendTypes[item.type].children)
|
|
998
1015
|
item.render = (value, values) => (0, import_react11.cloneElement)(
|
|
@@ -1012,8 +1029,10 @@ function Table(props) {
|
|
|
1012
1029
|
case "string":
|
|
1013
1030
|
if (!item.render)
|
|
1014
1031
|
item.render = (value) => processValue(item, value);
|
|
1015
|
-
if (!item.onFilter)
|
|
1032
|
+
if (!props.faasData && !item.onFilter)
|
|
1016
1033
|
item.onFilter = (value, row) => {
|
|
1034
|
+
if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
|
|
1035
|
+
return true;
|
|
1017
1036
|
if (!row[item.id])
|
|
1018
1037
|
return false;
|
|
1019
1038
|
return row[item.id].toLowerCase().includes(value.toLowerCase());
|
|
@@ -1023,7 +1042,7 @@ function Table(props) {
|
|
|
1023
1042
|
setSelectedKeys,
|
|
1024
1043
|
confirm,
|
|
1025
1044
|
clearFilters
|
|
1026
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1045
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Input.Search, {
|
|
1027
1046
|
placeholder: `${common2.search} ${item.title}`,
|
|
1028
1047
|
allowClear: true,
|
|
1029
1048
|
onSearch: (v) => {
|
|
@@ -1040,8 +1059,10 @@ function Table(props) {
|
|
|
1040
1059
|
case "string[]":
|
|
1041
1060
|
if (!item.render)
|
|
1042
1061
|
item.render = (value) => processValue(item, value);
|
|
1043
|
-
if (!item.onFilter)
|
|
1062
|
+
if (!props.faasData && !item.onFilter)
|
|
1044
1063
|
item.onFilter = (value, row) => {
|
|
1064
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1065
|
+
return true;
|
|
1045
1066
|
if (!row[item.id] || !row[item.id].length)
|
|
1046
1067
|
return false;
|
|
1047
1068
|
return row[item.id].some((v) => v.toLowerCase().includes(value.toLowerCase()));
|
|
@@ -1051,7 +1072,7 @@ function Table(props) {
|
|
|
1051
1072
|
setSelectedKeys,
|
|
1052
1073
|
confirm,
|
|
1053
1074
|
clearFilters
|
|
1054
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1075
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Input.Search, {
|
|
1055
1076
|
placeholder: `${common2.search} ${item.title}`,
|
|
1056
1077
|
allowClear: true,
|
|
1057
1078
|
onSearch: (v) => {
|
|
@@ -1070,14 +1091,18 @@ function Table(props) {
|
|
|
1070
1091
|
item.render = (value) => processValue(item, value);
|
|
1071
1092
|
if (!item.sorter)
|
|
1072
1093
|
item.sorter = (a, b) => a[item.id] - b[item.id];
|
|
1073
|
-
if (!item.onFilter)
|
|
1074
|
-
item.onFilter = (value, row) =>
|
|
1094
|
+
if (!props.faasData && !item.onFilter)
|
|
1095
|
+
item.onFilter = (value, row) => {
|
|
1096
|
+
if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
|
|
1097
|
+
return true;
|
|
1098
|
+
return value == row[item.id];
|
|
1099
|
+
};
|
|
1075
1100
|
if (!item.filters && item.filterDropdown !== false)
|
|
1076
1101
|
item.filterDropdown = ({
|
|
1077
1102
|
setSelectedKeys,
|
|
1078
1103
|
confirm,
|
|
1079
1104
|
clearFilters
|
|
1080
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1105
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Input.Search, {
|
|
1081
1106
|
placeholder: `${common2.search} ${item.title}`,
|
|
1082
1107
|
allowClear: true,
|
|
1083
1108
|
onSearch: (v) => {
|
|
@@ -1094,14 +1119,20 @@ function Table(props) {
|
|
|
1094
1119
|
case "number[]":
|
|
1095
1120
|
if (!item.render)
|
|
1096
1121
|
item.render = (value) => processValue(item, value).join(", ");
|
|
1097
|
-
if (!item.onFilter)
|
|
1098
|
-
item.onFilter = (value, row) =>
|
|
1122
|
+
if (!props.faasData && !item.onFilter)
|
|
1123
|
+
item.onFilter = (value, row) => {
|
|
1124
|
+
if (value === null && (!row[item.id] || !row[item.id].length))
|
|
1125
|
+
return true;
|
|
1126
|
+
if (!row[item.id] || !row[item.id].length)
|
|
1127
|
+
return false;
|
|
1128
|
+
return row[item.id].includes(Number(value));
|
|
1129
|
+
};
|
|
1099
1130
|
if (!item.filters && item.filterDropdown !== false)
|
|
1100
1131
|
item.filterDropdown = ({
|
|
1101
1132
|
setSelectedKeys,
|
|
1102
1133
|
confirm,
|
|
1103
1134
|
clearFilters
|
|
1104
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1135
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Input.Search, {
|
|
1105
1136
|
placeholder: `${common2.search} ${item.title}`,
|
|
1106
1137
|
allowClear: true,
|
|
1107
1138
|
onSearch: (v) => {
|
|
@@ -1133,7 +1164,7 @@ function Table(props) {
|
|
|
1133
1164
|
setSelectedKeys,
|
|
1134
1165
|
selectedKeys,
|
|
1135
1166
|
confirm
|
|
1136
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1167
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_antd9.Radio.Group, {
|
|
1137
1168
|
style: { padding: 8 },
|
|
1138
1169
|
buttonStyle: "solid",
|
|
1139
1170
|
value: selectedKeys[0],
|
|
@@ -1142,10 +1173,10 @@ function Table(props) {
|
|
|
1142
1173
|
confirm();
|
|
1143
1174
|
},
|
|
1144
1175
|
children: [
|
|
1145
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1176
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Radio.Button, {
|
|
1146
1177
|
children: common2.all
|
|
1147
1178
|
}),
|
|
1148
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1179
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Radio.Button, {
|
|
1149
1180
|
value: "true",
|
|
1150
1181
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CheckOutlined, {
|
|
1151
1182
|
style: {
|
|
@@ -1154,7 +1185,7 @@ function Table(props) {
|
|
|
1154
1185
|
}
|
|
1155
1186
|
})
|
|
1156
1187
|
}),
|
|
1157
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1188
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Radio.Button, {
|
|
1158
1189
|
value: "false",
|
|
1159
1190
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons3.CloseOutlined, {
|
|
1160
1191
|
style: {
|
|
@@ -1163,13 +1194,13 @@ function Table(props) {
|
|
|
1163
1194
|
}
|
|
1164
1195
|
})
|
|
1165
1196
|
}),
|
|
1166
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Radio.Button, {
|
|
1167
1198
|
value: "empty",
|
|
1168
1199
|
children: common2.blank
|
|
1169
1200
|
})
|
|
1170
1201
|
]
|
|
1171
1202
|
});
|
|
1172
|
-
if (!item.onFilter)
|
|
1203
|
+
if (!props.faasData && !item.onFilter)
|
|
1173
1204
|
item.onFilter = (value, row) => {
|
|
1174
1205
|
switch (value) {
|
|
1175
1206
|
case "true":
|
|
@@ -1186,7 +1217,7 @@ function Table(props) {
|
|
|
1186
1217
|
case "date":
|
|
1187
1218
|
if (!item.render)
|
|
1188
1219
|
item.render = (value) => processValue(item, value);
|
|
1189
|
-
if (!item.onFilter)
|
|
1220
|
+
if (!props.faasData && !item.onFilter)
|
|
1190
1221
|
item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value));
|
|
1191
1222
|
if (!item.sorter)
|
|
1192
1223
|
item.sorter = (a, b) => (0, import_dayjs2.default)(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
|
|
@@ -1194,7 +1225,7 @@ function Table(props) {
|
|
|
1194
1225
|
case "time":
|
|
1195
1226
|
if (!item.render)
|
|
1196
1227
|
item.render = (value) => processValue(item, value);
|
|
1197
|
-
if (!item.onFilter)
|
|
1228
|
+
if (!props.faasData && !item.onFilter)
|
|
1198
1229
|
item.onFilter = (value, row) => (0, import_dayjs2.default)(row[item.id]).isSame((0, import_dayjs2.default)(value));
|
|
1199
1230
|
if (!item.sorter)
|
|
1200
1231
|
item.sorter = (a, b) => (0, import_dayjs2.default)(a[item.id]).isBefore(b[item.id]) ? -1 : 1;
|
|
@@ -1219,7 +1250,11 @@ function Table(props) {
|
|
|
1219
1250
|
if (!item.render)
|
|
1220
1251
|
item.render = (value) => processValue(item, value);
|
|
1221
1252
|
if (!item.onFilter)
|
|
1222
|
-
item.onFilter = (value, row) =>
|
|
1253
|
+
item.onFilter = (value, row) => {
|
|
1254
|
+
if (value === null && (0, import_lodash_es6.isNil)(row[item.id]))
|
|
1255
|
+
return true;
|
|
1256
|
+
return value === row[item.id];
|
|
1257
|
+
};
|
|
1223
1258
|
break;
|
|
1224
1259
|
}
|
|
1225
1260
|
}
|
|
@@ -1236,7 +1271,10 @@ function Table(props) {
|
|
|
1236
1271
|
newColumns[index].filters = (0, import_lodash_es6.uniqBy)(props.dataSource, column.id).map((v) => ({
|
|
1237
1272
|
text: v[column.id],
|
|
1238
1273
|
value: v[column.id]
|
|
1239
|
-
}))
|
|
1274
|
+
})).concat({
|
|
1275
|
+
text: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Blank, {}),
|
|
1276
|
+
value: null
|
|
1277
|
+
});
|
|
1240
1278
|
return newColumns;
|
|
1241
1279
|
});
|
|
1242
1280
|
}
|
|
@@ -1245,14 +1283,14 @@ function Table(props) {
|
|
|
1245
1283
|
if (!columns)
|
|
1246
1284
|
return null;
|
|
1247
1285
|
if (!props.faasData)
|
|
1248
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Table, {
|
|
1249
1287
|
...props,
|
|
1250
1288
|
rowKey: props.rowKey || "id",
|
|
1251
1289
|
columns,
|
|
1252
1290
|
dataSource: props.dataSource
|
|
1253
1291
|
});
|
|
1254
1292
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react12.FaasDataWrapper, {
|
|
1255
|
-
fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1293
|
+
fallback: props.faasData.fallback || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Skeleton, {
|
|
1256
1294
|
active: true
|
|
1257
1295
|
}),
|
|
1258
1296
|
render: ({
|
|
@@ -1261,20 +1299,20 @@ function Table(props) {
|
|
|
1261
1299
|
reload
|
|
1262
1300
|
}) => {
|
|
1263
1301
|
if (!data)
|
|
1264
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Table, {
|
|
1265
1303
|
...props,
|
|
1266
1304
|
rowKey: props.rowKey || "id",
|
|
1267
1305
|
columns,
|
|
1268
1306
|
dataSource: []
|
|
1269
1307
|
});
|
|
1270
1308
|
if (Array.isArray(data))
|
|
1271
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Table, {
|
|
1272
1310
|
...props,
|
|
1273
1311
|
rowKey: props.rowKey || "id",
|
|
1274
1312
|
columns,
|
|
1275
1313
|
dataSource: data
|
|
1276
1314
|
});
|
|
1277
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd9.Table, {
|
|
1278
1316
|
...props,
|
|
1279
1317
|
rowKey: props.rowKey || "id",
|
|
1280
1318
|
columns,
|