@kingteza/crud-component 1.0.6 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/FileSaver.min.cjs +1 -0
- package/dist/_virtual/FileSaver.min.js +5 -0
- package/dist/_virtual/FileSaver.min2.cjs +1 -0
- package/dist/_virtual/FileSaver.min2.js +4 -0
- package/dist/_virtual/ShowMoreText.cjs +1 -0
- package/dist/_virtual/ShowMoreText.js +7 -0
- package/dist/_virtual/ShowMoreText2.cjs +1 -0
- package/dist/_virtual/ShowMoreText2.js +4 -0
- package/dist/_virtual/Truncate.cjs +1 -0
- package/dist/_virtual/Truncate.js +4 -0
- package/dist/_virtual/_commonjsHelpers.cjs +1 -1
- package/dist/_virtual/_commonjsHelpers.js +5 -3
- package/dist/_virtual/index.cjs +1 -1
- package/dist/_virtual/index.js +4 -4
- package/dist/_virtual/index10.cjs +1 -0
- package/dist/_virtual/index10.js +7 -0
- package/dist/_virtual/index11.cjs +1 -0
- package/dist/_virtual/index11.js +7 -0
- package/dist/_virtual/index12.cjs +1 -0
- package/dist/_virtual/index12.js +4 -0
- package/dist/_virtual/index13.cjs +1 -0
- package/dist/_virtual/index13.js +4 -0
- package/dist/_virtual/index2.cjs +1 -1
- package/dist/_virtual/index2.js +3 -5
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index3.js +5 -2
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index4.js +2 -2
- package/dist/_virtual/index5.js +2 -2
- package/dist/_virtual/index6.cjs +1 -0
- package/dist/_virtual/index6.js +4 -0
- package/dist/_virtual/index7.cjs +1 -0
- package/dist/_virtual/index7.js +4 -0
- package/dist/_virtual/index8.cjs +1 -0
- package/dist/_virtual/index8.js +2 -0
- package/dist/_virtual/index9.cjs +1 -0
- package/dist/_virtual/index9.js +7 -0
- package/dist/_virtual/main.cjs +1 -0
- package/dist/_virtual/main.js +7 -0
- package/dist/_virtual/main2.cjs +1 -0
- package/dist/_virtual/main2.js +4 -0
- package/dist/_virtual/papaparse.min.cjs +1 -0
- package/dist/_virtual/papaparse.min.js +7 -0
- package/dist/_virtual/papaparse.min2.cjs +1 -0
- package/dist/_virtual/papaparse.min2.js +4 -0
- package/dist/_virtual/react-is.development2.cjs +1 -0
- package/dist/_virtual/react-is.development2.js +4 -0
- package/dist/_virtual/react-is.production.min2.cjs +1 -0
- package/dist/_virtual/react-is.production.min2.js +4 -0
- package/dist/src/components/common/DatePicker/DatePicker.cjs +1 -1
- package/dist/src/components/common/DatePicker/DatePicker.js +23 -22
- package/dist/src/components/common/DatePicker/TimePicker.cjs +1 -1
- package/dist/src/components/common/DatePicker/TimePicker.js +14 -13
- package/dist/src/components/common/button/Button.cjs +1 -1
- package/dist/src/components/common/button/Button.js +32 -31
- package/dist/src/components/common/button/CloneButtonTable.cjs +1 -1
- package/dist/src/components/common/button/CloneButtonTable.js +7 -7
- package/dist/src/components/common/button/DeleteButtonTable.cjs +1 -1
- package/dist/src/components/common/button/DeleteButtonTable.js +22 -22
- package/dist/src/components/common/button/ExportButton.cjs +1 -1
- package/dist/src/components/common/button/ExportButton.js +13 -13
- package/dist/src/components/common/button/HideButtonTable.cjs +1 -1
- package/dist/src/components/common/button/HideButtonTable.js +20 -20
- package/dist/src/components/common/button/ImportButton.cjs +1 -1
- package/dist/src/components/common/button/ImportButton.js +25 -25
- package/dist/src/components/common/button/NewButton.cjs +1 -1
- package/dist/src/components/common/button/NewButton.js +15 -15
- package/dist/src/components/common/button/PrintButton.cjs +1 -1
- package/dist/src/components/common/button/PrintButton.js +14 -14
- package/dist/src/components/common/button/RefreshButton.cjs +1 -1
- package/dist/src/components/common/button/RefreshButton.js +12 -12
- package/dist/src/components/common/button/UnHideButton.cjs +1 -1
- package/dist/src/components/common/button/UnHideButton.js +31 -31
- package/dist/src/components/common/button/UpdateButtonTable.cjs +1 -1
- package/dist/src/components/common/button/UpdateButtonTable.js +9 -9
- package/dist/src/components/common/button/ViewButtonTable.cjs +1 -1
- package/dist/src/components/common/button/ViewButtonTable.js +11 -11
- package/dist/src/components/common/check-box/CheckBox.cjs +1 -1
- package/dist/src/components/common/check-box/CheckBox.js +17 -15
- package/dist/src/components/common/description/DescList.cjs +1 -1
- package/dist/src/components/common/description/DescList.js +1 -1
- package/dist/src/components/common/layout/VerticalSpace.cjs +1 -1
- package/dist/src/components/common/layout/VerticalSpace.js +1 -1
- package/dist/src/components/common/loading/LoadingIndicator.cjs +1 -1
- package/dist/src/components/common/loading/LoadingIndicator.js +11 -10
- package/dist/src/components/common/picker/ImagePicker.cjs +1 -1
- package/dist/src/components/common/picker/ImagePicker.js +95 -90
- package/dist/src/components/common/radio/RadioGroupComponent.cjs +1 -1
- package/dist/src/components/common/radio/RadioGroupComponent.js +17 -16
- package/dist/src/components/common/report/SelectFieldInReport.cjs +1 -1
- package/dist/src/components/common/report/SelectFieldInReport.js +17 -16
- package/dist/src/components/common/select/CustomSelectOption.cjs +1 -1
- package/dist/src/components/common/select/CustomSelectOption.js +1 -1
- package/dist/src/components/common/select/SelectComponent.cjs +1 -1
- package/dist/src/components/common/select/SelectComponent.js +36 -33
- package/dist/src/components/common/show-more/index.cjs +1 -1
- package/dist/src/components/common/show-more/index.js +1 -1
- package/dist/src/components/common/tab/TabViewWithRoute.cjs +1 -1
- package/dist/src/components/common/tab/TabViewWithRoute.js +10 -10
- package/dist/src/components/common/table/table.cjs +1 -1
- package/dist/src/components/common/table/table.js +16 -16
- package/dist/src/components/common/tag/StatusTag.cjs +1 -1
- package/dist/src/components/common/tag/StatusTag.js +4 -4
- package/dist/src/components/common/text/index.cjs +1 -1
- package/dist/src/components/common/text/index.js +1 -1
- package/dist/src/components/common/text/title/index.cjs +1 -1
- package/dist/src/components/common/text/title/index.js +1 -1
- package/dist/src/components/common/text-field/NumberField.cjs +1 -1
- package/dist/src/components/common/text-field/NumberField.js +20 -19
- package/dist/src/components/common/text-field/TextArea.cjs +1 -1
- package/dist/src/components/common/text-field/TextArea.js +19 -18
- package/dist/src/components/common/text-field/TextField.cjs +1 -1
- package/dist/src/components/common/text-field/TextField.js +37 -36
- package/dist/src/components/common/tooltip/TooltipComponent.cjs +1 -1
- package/dist/src/components/common/tooltip/TooltipComponent.js +1 -1
- package/dist/src/components/common/wizard/WizardResult.cjs +1 -1
- package/dist/src/components/common/wizard/WizardResult.js +37 -36
- package/dist/src/components/common/wizard/WizardViewForm.cjs +1 -1
- package/dist/src/components/common/wizard/WizardViewForm.js +1 -1
- package/dist/src/components/crud/CrudComponent.cjs +1 -1
- package/dist/src/components/crud/CrudComponent.js +74 -71
- package/dist/src/components/crud/CrudField.cjs +1 -1
- package/dist/src/components/crud/CrudField.js +111 -108
- package/dist/src/components/crud/CrudForm.cjs +1 -1
- package/dist/src/components/crud/CrudForm.js +36 -33
- package/dist/src/components/crud/CrudFormWizard.cjs +1 -1
- package/dist/src/components/crud/CrudFormWizard.js +78 -73
- package/dist/src/components/crud/CrudReportComponent.cjs +3 -3
- package/dist/src/components/crud/CrudReportComponent.js +75 -71
- package/dist/src/components/crud/CrudSearchComponent.cjs +1 -1
- package/dist/src/components/crud/CrudSearchComponent.js +17 -15
- package/dist/src/components/crud/FileCrudField.cjs +1 -1
- package/dist/src/components/crud/FileCrudField.js +103 -94
- package/dist/src/components/crud/ImageCrudField.cjs +1 -1
- package/dist/src/components/crud/ImageCrudField.js +58 -55
- package/dist/src/components/crud/import/CrudImportButton.cjs +1 -1
- package/dist/src/components/crud/import/CrudImportButton.js +10 -10
- package/dist/src/components/crud/import/CrudImportComponent.cjs +2 -2
- package/dist/src/components/crud/import/CrudImportComponent.js +111 -106
- package/dist/src/components/crud/view/CrudViewer.cjs +1 -1
- package/dist/src/components/crud/view/CrudViewer.js +30 -30
- package/dist/src/components/crud/view/CrudViewerUtil.cjs +1 -1
- package/dist/src/components/crud/view/CrudViewerUtil.js +35 -33
- package/dist/src/util/ImageUtil.cjs +1 -1
- package/dist/src/util/ImageUtil.js +1 -1
- package/package.json +7 -9
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (e, a, t) =>
|
|
4
|
-
import { j as
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var E = (e, a, t) => a in e ? A(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
|
+
var h = (e, a, t) => E(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
+
import { j as r } from "../../../_virtual/jsx-runtime.js";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
6
|
+
import N from "../../../_virtual/index.js";
|
|
7
|
+
import { useState as F, useCallback as O, useEffect as w } from "react";
|
|
8
|
+
import S from "../../util/NumberUtil.js";
|
|
9
|
+
import D from "../../util/ValidationUtil.js";
|
|
10
|
+
import W from "../common/picker/ImagePicker.js";
|
|
11
|
+
import x from "../../../node_modules/antd/es/form/index.js";
|
|
12
|
+
import q from "../../../node_modules/antd/es/input/index.js";
|
|
13
|
+
import z from "../../../node_modules/uuid/dist/esm-browser/v4.js";
|
|
14
|
+
import B from "../../../node_modules/antd/es/avatar/index.js";
|
|
15
|
+
import G from "../../../node_modules/antd/es/image/index.js";
|
|
16
|
+
import H from "../../../node_modules/@ant-design/icons/es/icons/EyeOutlined.js";
|
|
14
17
|
class J {
|
|
15
18
|
}
|
|
16
|
-
class
|
|
19
|
+
class re extends J {
|
|
17
20
|
constructor(t = "", s = "") {
|
|
18
21
|
super();
|
|
19
22
|
h(this, "rootPath");
|
|
@@ -21,93 +24,93 @@ class te extends J {
|
|
|
21
24
|
this.rootPath = t, this.subPath = s;
|
|
22
25
|
}
|
|
23
26
|
cloneFilePath(t) {
|
|
24
|
-
const s = N.parse(t),
|
|
27
|
+
const s = N.parse(t), l = `${s.name}_cloned_${S.randInt(1e5)}`;
|
|
25
28
|
return N.format({
|
|
26
29
|
dir: s.dir,
|
|
27
30
|
ext: s.ext,
|
|
28
|
-
name:
|
|
31
|
+
name: l
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
34
|
generateFileName(t) {
|
|
32
|
-
return `${t.split(".")[0]}_${
|
|
35
|
+
return `${t.split(".")[0]}_${z().replace("-", "")}`;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
|
-
function
|
|
38
|
+
function le({
|
|
36
39
|
name: e,
|
|
37
40
|
label: a,
|
|
38
41
|
required: t,
|
|
39
42
|
provider: s,
|
|
40
|
-
onUploading:
|
|
41
|
-
aspectRatio:
|
|
42
|
-
onRemoved:
|
|
43
|
-
fieldClassName:
|
|
43
|
+
onUploading: l,
|
|
44
|
+
aspectRatio: p,
|
|
45
|
+
onRemoved: m,
|
|
46
|
+
fieldClassName: d,
|
|
44
47
|
hideLabel: V = !1,
|
|
45
|
-
listType:
|
|
48
|
+
listType: C
|
|
46
49
|
}) {
|
|
47
|
-
const
|
|
48
|
-
async (
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
50
|
+
const n = x.useFormInstance(), u = x.useWatch(e, n), [I, $] = F(!1), P = O(
|
|
51
|
+
async (i, g) => {
|
|
52
|
+
if (g) {
|
|
53
|
+
l == null || l(!0);
|
|
54
|
+
const o = i.name, c = o.split("."), y = c[c.length - 1], b = s.generateFileName(o), k = `${await s.getInitialPath()}/${b}.${y}`, _ = await s.upload(i, k);
|
|
55
|
+
$(!0), l == null || l(!1), n.setFieldValue(e, _);
|
|
53
56
|
} else {
|
|
54
|
-
console.log(
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
+
console.log(i);
|
|
58
|
+
const o = n.getFieldsValue(), c = await s.delete(o[e]);
|
|
59
|
+
m == null || m(), c && n.setFieldsValue({ [e]: null });
|
|
57
60
|
}
|
|
58
61
|
},
|
|
59
|
-
[
|
|
62
|
+
[n, e, m, l, s]
|
|
60
63
|
), [f, j] = F();
|
|
61
|
-
return
|
|
62
|
-
!
|
|
63
|
-
}, [u,
|
|
64
|
+
return w(() => {
|
|
65
|
+
!I && u ? s.getRealUrl(u).then(j) : j(f);
|
|
66
|
+
}, [u, I, s, f]), /* @__PURE__ */ r.jsx(r.Fragment, { children: /* @__PURE__ */ r.jsxs(
|
|
64
67
|
x.Item,
|
|
65
68
|
{
|
|
66
|
-
rules: t ?
|
|
69
|
+
rules: t ? D.required(a) : [],
|
|
67
70
|
label: V ? null : a,
|
|
68
71
|
required: t,
|
|
69
72
|
name: e,
|
|
70
73
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
|
|
74
|
+
/* @__PURE__ */ r.jsx(
|
|
75
|
+
W,
|
|
73
76
|
{
|
|
74
77
|
noStyle: !0,
|
|
75
|
-
listType:
|
|
76
|
-
aspectRatio:
|
|
78
|
+
listType: C,
|
|
79
|
+
aspectRatio: p,
|
|
77
80
|
values: f,
|
|
78
|
-
onRemove: (
|
|
79
|
-
|
|
81
|
+
onRemove: (i) => {
|
|
82
|
+
i && P(i, !1);
|
|
80
83
|
},
|
|
81
|
-
onAdd: async (
|
|
82
|
-
|
|
84
|
+
onAdd: async (i) => {
|
|
85
|
+
i && await P(i, !0);
|
|
83
86
|
},
|
|
84
|
-
className:
|
|
87
|
+
className: d
|
|
85
88
|
}
|
|
86
89
|
),
|
|
87
|
-
/* @__PURE__ */
|
|
90
|
+
/* @__PURE__ */ r.jsx(q, { hidden: !0 })
|
|
88
91
|
]
|
|
89
92
|
}
|
|
90
93
|
) });
|
|
91
94
|
}
|
|
92
|
-
const
|
|
95
|
+
const ie = ({ provider: e, value: a }) => {
|
|
93
96
|
const [t, s] = F();
|
|
94
|
-
return
|
|
97
|
+
return w(() => {
|
|
95
98
|
a && e.getRealUrl(a).then(s);
|
|
96
|
-
}, [e, a]), t ? /* @__PURE__ */
|
|
97
|
-
}, K = ({ url: e }) => /* @__PURE__ */
|
|
98
|
-
|
|
99
|
+
}, [e, a]), t ? /* @__PURE__ */ r.jsx(K, { url: t }) : /* @__PURE__ */ r.jsx(r.Fragment, {});
|
|
100
|
+
}, K = ({ url: e }) => /* @__PURE__ */ r.jsx(B, { className: "p-0", children: /* @__PURE__ */ r.jsx(
|
|
101
|
+
G,
|
|
99
102
|
{
|
|
100
103
|
className: "m-0 p-0 position-relative",
|
|
101
104
|
src: e,
|
|
102
105
|
preview: {
|
|
103
|
-
mask: /* @__PURE__ */
|
|
106
|
+
mask: /* @__PURE__ */ r.jsx(H, {})
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
) });
|
|
107
110
|
export {
|
|
108
111
|
J as FileDownloadProvider,
|
|
109
|
-
|
|
112
|
+
re as FileUploadProvider,
|
|
110
113
|
K as ImageCellValue,
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
ie as ImageCrudCellValue,
|
|
115
|
+
le as default
|
|
113
116
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../../_virtual/jsx-runtime.cjs"),s=require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../../_virtual/jsx-runtime.cjs"),s=require("react"),u=require("react-i18next"),i=require("../../../locale/hooks/translation-constants.cjs"),c=require("./CrudImportComponent.cjs"),a=require("../../common/button/Button.cjs"),l=require("../../../../node_modules/@ant-design/icons/es/icons/ImportOutlined.cjs");function p(r){const{t:n}=u.useTranslation(i.TRANSLATION_NAMESPACE),[o,e]=s.useState(!1);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(c.default,{open:o,onCloseMethod:e,...r}),t.jsxRuntimeExports.jsx(a.default,{icon:t.jsxRuntimeExports.jsx(l.default,{}),onClick:()=>e(!0),children:n("str.import")})]})}exports.default=p;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { j as o } from "../../../../_virtual/jsx-runtime.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import u from "./CrudImportComponent.js";
|
|
2
|
+
import { useState as e } from "react";
|
|
3
|
+
import { useTranslation as p } from "react-i18next";
|
|
4
|
+
import { TRANSLATION_NAMESPACE as s } from "../../../locale/hooks/translation-constants.js";
|
|
5
|
+
import i from "./CrudImportComponent.js";
|
|
7
6
|
import f from "../../common/button/Button.js";
|
|
7
|
+
import u from "../../../../node_modules/@ant-design/icons/es/icons/ImportOutlined.js";
|
|
8
8
|
function I(r) {
|
|
9
|
-
const { t:
|
|
9
|
+
const { t: n } = p(s), [m, t] = e(!1);
|
|
10
10
|
return /* @__PURE__ */ o.jsxs(o.Fragment, { children: [
|
|
11
11
|
/* @__PURE__ */ o.jsx(
|
|
12
|
-
|
|
12
|
+
i,
|
|
13
13
|
{
|
|
14
|
-
open:
|
|
14
|
+
open: m,
|
|
15
15
|
onCloseMethod: t,
|
|
16
16
|
...r
|
|
17
17
|
}
|
|
@@ -19,9 +19,9 @@ function I(r) {
|
|
|
19
19
|
/* @__PURE__ */ o.jsx(
|
|
20
20
|
f,
|
|
21
21
|
{
|
|
22
|
-
icon: /* @__PURE__ */ o.jsx(
|
|
22
|
+
icon: /* @__PURE__ */ o.jsx(u, {}),
|
|
23
23
|
onClick: () => t(!0),
|
|
24
|
-
children:
|
|
24
|
+
children: n("str.import")
|
|
25
25
|
}
|
|
26
26
|
)
|
|
27
27
|
] });
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../../../../_virtual/jsx-runtime.cjs"),
|
|
2
|
-
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("../../../../_virtual/jsx-runtime.cjs"),B=require("../../../../_virtual/papaparse.min.cjs"),O=require("../../../../_virtual/FileSaver.min.cjs"),a=require("react"),$=require("react-i18next"),V=require("../../../locale/hooks/translation-constants.cjs"),L=require("../view/CrudViewer.cjs"),W=require("../../../util/DateUtil.cjs"),z=require("../../common/button/Button.cjs"),U=require("../../common/button/ImportButton.cjs"),N=require("../../../../node_modules/antd/es/tooltip/index.cjs"),S=require("../../../../node_modules/@ant-design/icons/es/icons/WarningTwoTone.cjs"),F=require("../../../../node_modules/antd/es/modal/index.cjs"),D=require("../../../../node_modules/antd/es/space/index.cjs"),G=require("../../../../node_modules/@ant-design/icons/es/icons/DownloadOutlined.cjs"),H=require("../../../../node_modules/antd/es/spin/index.cjs"),J=require("../../../../node_modules/antd/es/progress/progress.cjs");function K({onCloseMethod:j,open:b,fields:k,importProps:o}){const[c,R]=a.useState([]),[E,C]=a.useState(!1),[g,v]=a.useState(0);a.useEffect(()=>{b||(R([]),C(!1))},[b]);const f=a.useMemo(()=>new Map(k.filter(e=>{var t;return!e.hidden&&!((t=e.importProps)!=null&&t.hidden)&&!e.readonly}).map(e=>[e.name,e])),[k]),w=a.useMemo(()=>Array.from(f.values()).flatMap(e=>{var t;return[e.name,...((t=e.importProps)==null?void 0:t.extraFields)??[]]}),[f]),I=a.useCallback(async function(){const e=`${w.join(",")}
|
|
2
|
+
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});O.FileSaver_minExports.saveAs(t,(o==null?void 0:o.name)+" - "+W.default.formatDateTimeWithSecond(new Date).replaceAll(":","-")+".csv")},[w,o==null?void 0:o.name]),{t:l}=$.useTranslation(V.TRANSLATION_NAMESPACE),M=a.useCallback(async e=>{const t=new FileReader;t.onerror=console.error,t.onload=async r=>{var n;const u=(n=r==null?void 0:r.target)==null?void 0:n.result,i=B.default.parse(u,{header:!0});R(i.data)},t.readAsText(e)},[]),h=a.useMemo(()=>{var t,r,u;let e=!1;for(const i of c)for(const[n,d]of f.entries()){const p=i[n],x=p||!isNaN(p);if(d.required&&!x)if((r=(t=d.importProps)==null?void 0:t.extraFields)!=null&&r.length)for(const y of((u=d.importProps)==null?void 0:u.extraFields)??[])if(i[y]||!isNaN(i[y])){e=!1;break}else return!0;else return!0}return e},[c,f]),m=a.useCallback(e=>(t,r)=>{var i,n,d;const u=t||!isNaN(t);if(e.required&&!u){let p=l("err.validation.required");if((n=(i=e.importProps)==null?void 0:i.extraFields)!=null&&n.length){const x=(d=e.importProps)==null?void 0:d.extraFields;(x==null?void 0:x.find(A=>!r[A]))&&(p="Either one of these fields is required: "+[e.name,...x].join(", "))}return s.jsxRuntimeExports.jsxs(N.default,{className:"d-flex",title:p,children:[s.jsxRuntimeExports.jsx(S.default,{twoToneColor:"#ee9702"}),t]})}return t},[l]),T=a.useCallback(async e=>{v(e)},[]),q=a.useCallback(async()=>{try{C(!0),await o.onClickImport(c,T),j(!1)}finally{C(!1),v(0)}},[c,o,j,T]),_=a.useCallback(async()=>{h?F.default.warn({title:l("str.warning"),content:l("qus.importWithIssues"),okText:l("str.import"),onOk:q,okCancel:!0,closable:!0}):q()},[h,q,l]);return s.jsxRuntimeExports.jsxs(F.default,{title:[l("str.import"),o==null?void 0:o.name].filter(Boolean).join(" "),width:"100%",open:b,onOk:_,destroyOnClose:!0,onCancel:()=>j(!1),okText:l("str.import"),confirmLoading:E,okButtonProps:{disabled:!(c!=null&&c.length)},footer:(e,{OkBtn:t,CancelBtn:r})=>s.jsxRuntimeExports.jsxs(D.default,{children:[s.jsxRuntimeExports.jsx(r,{}),s.jsxRuntimeExports.jsx(t,{}),h&&s.jsxRuntimeExports.jsx(N.default,{className:"d-flex",title:"Some fields have issue. Please review before submit.",children:s.jsxRuntimeExports.jsx(S.default,{twoToneColor:"#ee9702"})})]}),children:[s.jsxRuntimeExports.jsxs(D.default,{children:[s.jsxRuntimeExports.jsx(z.default,{onClick:I,icon:s.jsxRuntimeExports.jsx(G.default,{}),children:l("str.downloadCsvTemplate")}),s.jsxRuntimeExports.jsx(U.ImportButton,{disabled:E,type:"default",onClick:M,accept:".csv",children:l("str.importCsvFile")})]}),s.jsxRuntimeExports.jsx(H.default,{spinning:E,indicator:g?s.jsxRuntimeExports.jsx(J.default,{type:"circle",percent:g*100,size:50,format:e=>`${parseInt(e)}%`}):void 0,children:s.jsxRuntimeExports.jsx(L.default,{data:c,bordered:!0,size:"small",fields:Array.from(f.values()).flatMap(e=>{var t,r,u,i;return e.type==="text"?[{...e,label:e.name,render:m(e)},...((r=(t=e.importProps)==null?void 0:t.extraFields)==null?void 0:r.map(n=>({...e,name:n,label:n,render:m(e)})))??[]]:e.type==="select"?[{...e,label:e.name,type:"text",render:m(e)},...((i=(u=e.importProps)==null?void 0:u.extraFields)==null?void 0:i.map(n=>({...e,name:n,label:n,type:"text",render:m(e)})))??[]]:[{...e,label:e.name,render:m(e)}]})})})]})}exports.default=K;
|
|
@@ -1,68 +1,73 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
1
|
+
import { j as t } from "../../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import L from "../../../../_virtual/papaparse.min.js";
|
|
3
|
+
import { F as _ } from "../../../../_virtual/FileSaver.min.js";
|
|
4
|
+
import { useState as w, useEffect as $, useMemo as v, useCallback as d } from "react";
|
|
5
|
+
import { useTranslation as z } from "react-i18next";
|
|
6
|
+
import { TRANSLATION_NAMESPACE as W } from "../../../locale/hooks/translation-constants.js";
|
|
7
|
+
import U from "../view/CrudViewer.js";
|
|
8
|
+
import G from "../../../util/DateUtil.js";
|
|
9
|
+
import H from "../../common/button/Button.js";
|
|
10
|
+
import { ImportButton as J } from "../../common/button/ImportButton.js";
|
|
11
|
+
import S from "../../../../node_modules/antd/es/tooltip/index.js";
|
|
12
|
+
import q from "../../../../node_modules/@ant-design/icons/es/icons/WarningTwoTone.js";
|
|
13
|
+
import B from "../../../../node_modules/antd/es/modal/index.js";
|
|
14
|
+
import R from "../../../../node_modules/antd/es/space/index.js";
|
|
15
|
+
import K from "../../../../node_modules/@ant-design/icons/es/icons/DownloadOutlined.js";
|
|
16
|
+
import Q from "../../../../node_modules/antd/es/spin/index.js";
|
|
17
|
+
import X from "../../../../node_modules/antd/es/progress/progress.js";
|
|
18
|
+
function pe({
|
|
14
19
|
onCloseMethod: h,
|
|
15
20
|
open: y,
|
|
16
|
-
fields:
|
|
17
|
-
importProps:
|
|
21
|
+
fields: A,
|
|
22
|
+
importProps: s
|
|
18
23
|
}) {
|
|
19
|
-
const [c,
|
|
20
|
-
|
|
21
|
-
y || (
|
|
24
|
+
const [c, N] = w([]), [j, b] = w(!1), [T, E] = w(0);
|
|
25
|
+
$(() => {
|
|
26
|
+
y || (N([]), b(!1));
|
|
22
27
|
}, [y]);
|
|
23
|
-
const u =
|
|
28
|
+
const u = v(
|
|
24
29
|
() => new Map(
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
return !e.hidden && !((
|
|
30
|
+
A.filter((e) => {
|
|
31
|
+
var r;
|
|
32
|
+
return !e.hidden && !((r = e.importProps) != null && r.hidden) && !e.readonly;
|
|
28
33
|
}).map((e) => [e.name, e])
|
|
29
34
|
),
|
|
30
|
-
[
|
|
31
|
-
),
|
|
35
|
+
[A]
|
|
36
|
+
), F = v(
|
|
32
37
|
() => Array.from(u.values()).flatMap((e) => {
|
|
33
|
-
var
|
|
38
|
+
var r;
|
|
34
39
|
return [
|
|
35
40
|
e.name,
|
|
36
|
-
...((
|
|
41
|
+
...((r = e.importProps) == null ? void 0 : r.extraFields) ?? []
|
|
37
42
|
];
|
|
38
43
|
}),
|
|
39
44
|
[u]
|
|
40
|
-
), V =
|
|
45
|
+
), V = d(
|
|
41
46
|
async function() {
|
|
42
|
-
const e = `${
|
|
43
|
-
`,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
(
|
|
47
|
+
const e = `${F.join(",")}
|
|
48
|
+
`, r = new Blob([e], { type: "text/csv;charset=utf-8;" });
|
|
49
|
+
_.saveAs(
|
|
50
|
+
r,
|
|
51
|
+
(s == null ? void 0 : s.name) + " - " + G.formatDateTimeWithSecond(/* @__PURE__ */ new Date()).replaceAll(":", "-") + ".csv"
|
|
47
52
|
);
|
|
48
53
|
},
|
|
49
|
-
[
|
|
50
|
-
), { t:
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
var
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
}, []), C =
|
|
58
|
-
var
|
|
54
|
+
[F, s == null ? void 0 : s.name]
|
|
55
|
+
), { t: i } = z(W), M = d(async (e) => {
|
|
56
|
+
const r = new FileReader();
|
|
57
|
+
r.onerror = console.error, r.onload = async (o) => {
|
|
58
|
+
var n;
|
|
59
|
+
const l = (n = o == null ? void 0 : o.target) == null ? void 0 : n.result, a = L.parse(l, { header: !0 });
|
|
60
|
+
N(a.data);
|
|
61
|
+
}, r.readAsText(e);
|
|
62
|
+
}, []), C = v(() => {
|
|
63
|
+
var r, o, l;
|
|
59
64
|
let e = !1;
|
|
60
65
|
for (const a of c)
|
|
61
|
-
for (const [
|
|
62
|
-
const x = a[
|
|
63
|
-
if (
|
|
64
|
-
if ((
|
|
65
|
-
for (const g of ((
|
|
66
|
+
for (const [n, m] of u.entries()) {
|
|
67
|
+
const x = a[n], f = x || !isNaN(x);
|
|
68
|
+
if (m.required && !f)
|
|
69
|
+
if ((o = (r = m.importProps) == null ? void 0 : r.extraFields) != null && o.length)
|
|
70
|
+
for (const g of ((l = m.importProps) == null ? void 0 : l.extraFields) ?? [])
|
|
66
71
|
if (a[g] || !isNaN(a[g])) {
|
|
67
72
|
e = !1;
|
|
68
73
|
break;
|
|
@@ -70,120 +75,120 @@ function ce({
|
|
|
70
75
|
else return !0;
|
|
71
76
|
}
|
|
72
77
|
return e;
|
|
73
|
-
}, [c, u]), p =
|
|
74
|
-
(e) => (
|
|
75
|
-
var a,
|
|
76
|
-
const
|
|
77
|
-
if (e.required && !
|
|
78
|
-
let x =
|
|
79
|
-
if ((
|
|
80
|
-
const f = (
|
|
81
|
-
(f == null ? void 0 : f.find((
|
|
78
|
+
}, [c, u]), p = d(
|
|
79
|
+
(e) => (r, o) => {
|
|
80
|
+
var a, n, m;
|
|
81
|
+
const l = r || !isNaN(r);
|
|
82
|
+
if (e.required && !l) {
|
|
83
|
+
let x = i("err.validation.required");
|
|
84
|
+
if ((n = (a = e.importProps) == null ? void 0 : a.extraFields) != null && n.length) {
|
|
85
|
+
const f = (m = e.importProps) == null ? void 0 : m.extraFields;
|
|
86
|
+
(f == null ? void 0 : f.find((D) => !o[D])) && (x = "Either one of these fields is required: " + [e.name, ...f].join(", "));
|
|
82
87
|
}
|
|
83
|
-
return /* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
|
|
88
|
+
return /* @__PURE__ */ t.jsxs(S, { className: "d-flex", title: x, children: [
|
|
89
|
+
/* @__PURE__ */ t.jsx(q, { twoToneColor: "#ee9702" }),
|
|
90
|
+
r
|
|
86
91
|
] });
|
|
87
92
|
}
|
|
88
|
-
return
|
|
93
|
+
return r;
|
|
89
94
|
},
|
|
90
|
-
[
|
|
91
|
-
),
|
|
92
|
-
|
|
93
|
-
}, []),
|
|
95
|
+
[i]
|
|
96
|
+
), I = d(async (e) => {
|
|
97
|
+
E(e);
|
|
98
|
+
}, []), k = d(async () => {
|
|
94
99
|
try {
|
|
95
|
-
b(!0), await
|
|
100
|
+
b(!0), await s.onClickImport(c, I), h(!1);
|
|
96
101
|
} finally {
|
|
97
|
-
b(!1),
|
|
102
|
+
b(!1), E(0);
|
|
98
103
|
}
|
|
99
|
-
}, [c,
|
|
104
|
+
}, [c, s, h, I]), O = d(async () => {
|
|
100
105
|
C ? B.warn({
|
|
101
|
-
title:
|
|
102
|
-
content:
|
|
103
|
-
okText:
|
|
104
|
-
onOk:
|
|
106
|
+
title: i("str.warning"),
|
|
107
|
+
content: i("qus.importWithIssues"),
|
|
108
|
+
okText: i("str.import"),
|
|
109
|
+
onOk: k,
|
|
105
110
|
okCancel: !0,
|
|
106
111
|
closable: !0
|
|
107
|
-
}) :
|
|
108
|
-
}, [C,
|
|
109
|
-
return /* @__PURE__ */
|
|
112
|
+
}) : k();
|
|
113
|
+
}, [C, k, i]);
|
|
114
|
+
return /* @__PURE__ */ t.jsxs(
|
|
110
115
|
B,
|
|
111
116
|
{
|
|
112
|
-
title: [
|
|
117
|
+
title: [i("str.import"), s == null ? void 0 : s.name].filter(Boolean).join(" "),
|
|
113
118
|
width: "100%",
|
|
114
119
|
open: y,
|
|
115
|
-
onOk:
|
|
120
|
+
onOk: O,
|
|
116
121
|
destroyOnClose: !0,
|
|
117
122
|
onCancel: () => h(!1),
|
|
118
|
-
okText:
|
|
123
|
+
okText: i("str.import"),
|
|
119
124
|
confirmLoading: j,
|
|
120
125
|
okButtonProps: {
|
|
121
126
|
disabled: !(c != null && c.length)
|
|
122
127
|
},
|
|
123
|
-
footer: (e, { OkBtn:
|
|
124
|
-
/* @__PURE__ */
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
C && /* @__PURE__ */
|
|
127
|
-
|
|
128
|
+
footer: (e, { OkBtn: r, CancelBtn: o }) => /* @__PURE__ */ t.jsxs(R, { children: [
|
|
129
|
+
/* @__PURE__ */ t.jsx(o, {}),
|
|
130
|
+
/* @__PURE__ */ t.jsx(r, {}),
|
|
131
|
+
C && /* @__PURE__ */ t.jsx(
|
|
132
|
+
S,
|
|
128
133
|
{
|
|
129
134
|
className: "d-flex",
|
|
130
135
|
title: "Some fields have issue. Please review before submit.",
|
|
131
|
-
children: /* @__PURE__ */
|
|
136
|
+
children: /* @__PURE__ */ t.jsx(q, { twoToneColor: "#ee9702" })
|
|
132
137
|
}
|
|
133
138
|
)
|
|
134
139
|
] }),
|
|
135
140
|
children: [
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
|
|
141
|
+
/* @__PURE__ */ t.jsxs(R, { children: [
|
|
142
|
+
/* @__PURE__ */ t.jsx(
|
|
143
|
+
H,
|
|
139
144
|
{
|
|
140
145
|
onClick: V,
|
|
141
|
-
icon: /* @__PURE__ */
|
|
142
|
-
children:
|
|
146
|
+
icon: /* @__PURE__ */ t.jsx(K, {}),
|
|
147
|
+
children: i("str.downloadCsvTemplate")
|
|
143
148
|
}
|
|
144
149
|
),
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
|
|
150
|
+
/* @__PURE__ */ t.jsx(
|
|
151
|
+
J,
|
|
147
152
|
{
|
|
148
153
|
disabled: j,
|
|
149
154
|
type: "default",
|
|
150
155
|
onClick: M,
|
|
151
156
|
accept: ".csv",
|
|
152
|
-
children:
|
|
157
|
+
children: i("str.importCsvFile")
|
|
153
158
|
}
|
|
154
159
|
)
|
|
155
160
|
] }),
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
|
|
161
|
+
/* @__PURE__ */ t.jsx(
|
|
162
|
+
Q,
|
|
158
163
|
{
|
|
159
164
|
spinning: j,
|
|
160
|
-
indicator:
|
|
161
|
-
|
|
165
|
+
indicator: T ? /* @__PURE__ */ t.jsx(
|
|
166
|
+
X,
|
|
162
167
|
{
|
|
163
168
|
type: "circle",
|
|
164
|
-
percent:
|
|
169
|
+
percent: T * 100,
|
|
165
170
|
size: 50,
|
|
166
171
|
format: (e) => `${parseInt(e)}%`
|
|
167
172
|
}
|
|
168
173
|
) : void 0,
|
|
169
|
-
children: /* @__PURE__ */
|
|
170
|
-
|
|
174
|
+
children: /* @__PURE__ */ t.jsx(
|
|
175
|
+
U,
|
|
171
176
|
{
|
|
172
177
|
data: c,
|
|
173
178
|
bordered: !0,
|
|
174
179
|
size: "small",
|
|
175
180
|
fields: Array.from(u.values()).flatMap((e) => {
|
|
176
|
-
var
|
|
181
|
+
var r, o, l, a;
|
|
177
182
|
return e.type === "text" ? [
|
|
178
183
|
{
|
|
179
184
|
...e,
|
|
180
185
|
label: e.name,
|
|
181
186
|
render: p(e)
|
|
182
187
|
},
|
|
183
|
-
...((
|
|
188
|
+
...((o = (r = e.importProps) == null ? void 0 : r.extraFields) == null ? void 0 : o.map((n) => ({
|
|
184
189
|
...e,
|
|
185
|
-
name:
|
|
186
|
-
label:
|
|
190
|
+
name: n,
|
|
191
|
+
label: n,
|
|
187
192
|
render: p(e)
|
|
188
193
|
}))) ?? []
|
|
189
194
|
] : e.type === "select" ? [
|
|
@@ -193,10 +198,10 @@ function ce({
|
|
|
193
198
|
type: "text",
|
|
194
199
|
render: p(e)
|
|
195
200
|
},
|
|
196
|
-
...((a = (
|
|
201
|
+
...((a = (l = e.importProps) == null ? void 0 : l.extraFields) == null ? void 0 : a.map((n) => ({
|
|
197
202
|
...e,
|
|
198
|
-
name:
|
|
199
|
-
label:
|
|
203
|
+
name: n,
|
|
204
|
+
label: n,
|
|
200
205
|
type: "text",
|
|
201
206
|
render: p(e)
|
|
202
207
|
}))) ?? []
|
|
@@ -217,5 +222,5 @@ function ce({
|
|
|
217
222
|
);
|
|
218
223
|
}
|
|
219
224
|
export {
|
|
220
|
-
|
|
225
|
+
pe as default
|
|
221
226
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../../_virtual/jsx-runtime.cjs"),D=require("
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../../../../_virtual/jsx-runtime.cjs"),D=require("../../common/button/CloneButtonTable.cjs"),k=require("../../common/button/DeleteButtonTable.cjs"),H=require("../../common/button/ExportButton.cjs"),U=require("../../common/button/HideButtonTable.cjs"),F=require("../../common/button/RefreshButton.cjs"),tt=require("../../common/button/UpdateButtonTable.cjs"),et=require("../../common/button/ViewButtonTable.cjs"),st=require("../../common/layout/VerticalSpace.cjs"),rt=require("../../common/table/table.cjs"),l=require("react"),ut=require("react-i18next"),nt=require("../../../locale/hooks/translation-constants.cjs"),ot=require("../CrudSearchComponent.cjs"),xt=require("./CrudDecListView.cjs"),_=require("./CrudViewerUtil.cjs"),ct=require("../../../../node_modules/antd/es/modal/index.cjs");function jt({idField:r="id",loadingData:L,fields:c,isDeleting:q,isHiding:d,viewable:o=!1,paginateProps:i,onDelete:a,onHide:v,onUpdate:R,data:E=[],extraAction:m,onClickUpdate:x,minusHeight:S,scroll:N,onClickClone:f,className:z,expandable:$,size:w,bordered:A,descListColumn:G,extraView:p,decListLayout:J,scrollToTop:lt,onClickRefresh:g,closeViewOnClickUpdate:b,onExport:B,confirmHiding:C,confirmDeleting:I,rowClassName:K,actionWidth:Q=190,...W}){const{t:X}=ut.useTranslation(nt.TRANSLATION_NAMESPACE),M=l.useMemo(()=>c.map(({hideInTable:e,hidden:s,width:j,name:n,label:Z,halign:P,...O})=>({title:Z,width:j,key:n,dataIndex:n,hidden:e||s,align:P??(O.type==="number"?"right":void 0),render:_.getRendererValueCrudViewer(O)})),[c]),[u,h]=l.useState(),[T,y]=l.useState();l.useEffect(()=>{E&&h(e=>{if(e)return E.find(s=>s[r]===e[r])})},[E,r,u]);const V=l.useCallback(e=>{var j;const s=m==null?void 0:m(e);return(Array.isArray(s)?(j=s==null?void 0:s.filter(Boolean))!=null&&j.length:s)||R||x||f||a?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[s,(R||x)&&t.jsxRuntimeExports.jsx(tt.default,{value:e,onClick:n=>{y(n[r]),x==null||x(e),b&&h(void 0)}}),f&&t.jsxRuntimeExports.jsx(D.default,{value:e,onClick:n=>f(n)}),B&&t.jsxRuntimeExports.jsx(H.ExportButton,{value:e,onClick:async n=>await B(n)}),v&&t.jsxRuntimeExports.jsx(U.default,{value:e,disabled:d,shouldConfirm:C,loading:d&&e[r]===T,onClick:async n=>{y(n[r]),await v({[r]:n[r]})}}),a&&t.jsxRuntimeExports.jsx(k.default,{value:e,disabled:q,shouldConfirm:I,loading:q&&e[r]===T,onClick:async n=>{y(n[r]),await a({[r]:n[r]})}})]}):void 0},[b,I,C,m,r,q,d,f,x,a,B,v,R,T]),Y=l.useMemo(()=>{let e=typeof o=="string"?u==null?void 0:u[o]:void 0;if(typeof e=="object"){const s=c.find(j=>j.name===o);e=_.getRendererValueCrudViewer(s)(e,u,0)}return e},[o,u,c]);return t.jsxRuntimeExports.jsxs("div",{children:[o&&t.jsxRuntimeExports.jsx(ct.default,{width:"100%",open:!!u,title:Y??t.jsxRuntimeExports.jsx("div",{children:" "}),footer:t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{}),closable:!0,onCancel:()=>h(void 0),children:!!u&&t.jsxRuntimeExports.jsxs("div",{children:[t.jsxRuntimeExports.jsx(xt.CrudDecListView,{layout:J,descListColumn:G,data:u,fields:c,action:V(u)}),p==null?void 0:p(u)]},u==null?void 0:u[r])}),t.jsxRuntimeExports.jsx(ot.default,{fields:c,...W}),t.jsxRuntimeExports.jsxs(st.default,{children:[!!g&&t.jsxRuntimeExports.jsx(F.RefreshButton,{onClick:g}),t.jsxRuntimeExports.jsx(rt.default,{rowClassName:K,className:z,scroll:N??(S?{y:`calc(100vh - ${S})`}:void 0),id:"crud-table",dataSource:E,loading:L,bordered:A,size:w,expandable:$,pagination:i?{total:i.count,onChange:i.setPage,current:i.page,pageSize:i.pageSize}:void 0,columns:R||x||a||m||o?[...M,{title:X("str.action"),dataIndex:"",fixed:"right",width:Q,render:(e,s)=>t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[o&&t.jsxRuntimeExports.jsx(et.default,{value:s,onClick:h}),V(s)]})}]:M})]})]})}exports.default=jt;
|