@kingteza/crud-component 1.0.14 → 1.0.16
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/components/common/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/common/DatePicker/DatePicker.js +42 -42
- package/dist/components/common/DatePicker/TimePicker.cjs +1 -1
- package/dist/components/common/DatePicker/TimePicker.js +39 -39
- package/dist/components/common/appearance/Hider.cjs +1 -1
- package/dist/components/common/appearance/Hider.js +3 -3
- package/dist/components/common/button/Button.cjs +1 -1
- package/dist/components/common/button/Button.js +19 -19
- package/dist/components/common/button/CloneButtonTable.cjs +1 -1
- package/dist/components/common/button/CloneButtonTable.js +11 -11
- package/dist/components/common/button/DeleteButtonTable.cjs +1 -1
- package/dist/components/common/button/DeleteButtonTable.js +29 -29
- package/dist/components/common/button/ExportButton.cjs +1 -1
- package/dist/components/common/button/ExportButton.js +17 -17
- package/dist/components/common/button/HideButtonTable.cjs +1 -1
- package/dist/components/common/button/HideButtonTable.js +35 -35
- package/dist/components/common/button/ImportButton.cjs +1 -1
- package/dist/components/common/button/ImportButton.js +28 -28
- package/dist/components/common/button/NewButton.cjs +1 -1
- package/dist/components/common/button/NewButton.js +14 -14
- package/dist/components/common/button/PrintButton.cjs +1 -1
- package/dist/components/common/button/PrintButton.js +14 -14
- package/dist/components/common/button/RefreshButton.cjs +1 -1
- package/dist/components/common/button/RefreshButton.js +16 -16
- package/dist/components/common/button/UnHideButton.cjs +1 -1
- package/dist/components/common/button/UnHideButton.js +37 -37
- package/dist/components/common/button/UpdateButtonTable.cjs +1 -1
- package/dist/components/common/button/UpdateButtonTable.js +11 -11
- package/dist/components/common/button/ViewButtonTable.cjs +1 -1
- package/dist/components/common/button/ViewButtonTable.js +10 -10
- package/dist/components/common/check-box/CheckBox.cjs +1 -1
- package/dist/components/common/check-box/CheckBox.js +20 -20
- package/dist/components/common/description/DescList.cjs +1 -1
- package/dist/components/common/description/DescList.js +9 -9
- package/dist/components/common/layout/VerticalSpace.cjs +1 -1
- package/dist/components/common/layout/VerticalSpace.js +3 -3
- package/dist/components/common/loading/LoadingIndicator.cjs +1 -1
- package/dist/components/common/loading/LoadingIndicator.js +12 -12
- package/dist/components/common/picker/ImagePicker.cjs +1 -1
- package/dist/components/common/picker/ImagePicker.js +173 -176
- package/dist/components/common/radio/RadioGroupComponent.cjs +1 -1
- package/dist/components/common/radio/RadioGroupComponent.js +6 -6
- package/dist/components/common/report/SelectFieldInReport.cjs +1 -1
- package/dist/components/common/report/SelectFieldInReport.js +11 -11
- package/dist/components/common/select/CustomSelectOption.cjs +1 -1
- package/dist/components/common/select/CustomSelectOption.js +7 -7
- package/dist/components/common/select/SelectComponent.cjs +1 -1
- package/dist/components/common/select/SelectComponent.js +36 -36
- package/dist/components/common/show-more/index.cjs +1 -1
- package/dist/components/common/show-more/index.js +5 -5
- package/dist/components/common/tab/TabViewWithRoute.cjs +1 -1
- package/dist/components/common/tab/TabViewWithRoute.js +23 -22
- package/dist/components/common/table/table.cjs +1 -1
- package/dist/components/common/table/table.js +12 -12
- package/dist/components/common/tag/StatusTag.cjs +1 -1
- package/dist/components/common/tag/StatusTag.js +13 -13
- package/dist/components/common/text-field/NumberField.cjs +1 -1
- package/dist/components/common/text-field/NumberField.js +43 -43
- package/dist/components/common/text-field/PhoneNumberField.cjs +1 -1
- package/dist/components/common/text-field/PhoneNumberField.js +4 -4
- package/dist/components/common/text-field/TextArea.cjs +1 -1
- package/dist/components/common/text-field/TextArea.js +20 -20
- package/dist/components/common/text-field/TextField.cjs +1 -1
- package/dist/components/common/text-field/TextField.js +47 -47
- package/dist/components/common/tooltip/TooltipComponent.cjs +1 -1
- package/dist/components/common/tooltip/TooltipComponent.js +3 -3
- package/dist/components/common/wizard/WizardResult.cjs +1 -1
- package/dist/components/common/wizard/WizardResult.js +37 -38
- package/dist/components/common/wizard/WizardViewForm.cjs +1 -1
- package/dist/components/common/wizard/WizardViewForm.js +43 -43
- package/dist/components/crud/CrudComponent.cjs +1 -1
- package/dist/components/crud/CrudComponent.js +130 -130
- package/dist/components/crud/CrudField.cjs +1 -1
- package/dist/components/crud/CrudField.js +217 -217
- package/dist/components/crud/CrudForm.cjs +1 -1
- package/dist/components/crud/CrudForm.js +55 -55
- package/dist/components/crud/CrudFormWizard.cjs +1 -1
- package/dist/components/crud/CrudFormWizard.js +82 -84
- package/dist/components/crud/CrudReportComponent.cjs +3 -3
- package/dist/components/crud/CrudReportComponent.js +123 -123
- package/dist/components/crud/CrudSearchComponent.cjs +1 -1
- package/dist/components/crud/CrudSearchComponent.js +43 -43
- package/dist/components/crud/FileCrudField.cjs +1 -1
- package/dist/components/crud/FileCrudField.js +118 -125
- package/dist/components/crud/ImageCrudField.cjs +1 -1
- package/dist/components/crud/ImageCrudField.js +56 -56
- package/dist/components/crud/import/CrudImportButton.cjs +1 -1
- package/dist/components/crud/import/CrudImportButton.js +18 -18
- package/dist/components/crud/import/CrudImportComponent.cjs +2 -2
- package/dist/components/crud/import/CrudImportComponent.js +108 -109
- package/dist/components/crud/view/CrudDecListView.cjs +1 -1
- package/dist/components/crud/view/CrudDecListView.js +22 -22
- package/dist/components/crud/view/CrudViewer.cjs +1 -1
- package/dist/components/crud/view/CrudViewer.js +152 -152
- package/dist/components/crud/view/CrudViewerUtil.cjs +1 -1
- package/dist/components/crud/view/CrudViewerUtil.js +33 -34
- package/dist/locale/index.cjs +1 -1
- package/dist/locale/index.js +2 -2
- package/dist/util/DateUtil.cjs +1 -1
- package/dist/util/DateUtil.js +4 -4
- package/dist/util/ImageUtil.cjs +1 -1
- package/dist/util/ImageUtil.js +1 -1
- package/dist/util/ValidationUtil.cjs +1 -1
- package/dist/util/ValidationUtil.js +1 -1
- package/package.json +1 -1
|
@@ -1,197 +1,190 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs as f, jsx as s, Fragment as O } from "react/jsx-runtime";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import m from "../../node_modules/@ant-design/icons/es/icons/FileWordOutlined.js";
|
|
15
|
-
import v from "../../node_modules/@ant-design/icons/es/icons/FilePdfOutlined.js";
|
|
16
|
-
import y from "../../node_modules/@ant-design/icons/es/icons/FileImageOutlined.js";
|
|
17
|
-
import { useTranslation as T } from "../../node_modules/react-i18next/dist/es/useTranslation.js";
|
|
18
|
-
import tt from "../../node_modules/@ant-design/icons/es/icons/ExportOutlined.js";
|
|
19
|
-
function It({
|
|
20
|
-
name: o,
|
|
3
|
+
import { FileOutlined as G, FilePptOutlined as J, FileExcelOutlined as K, FileTextOutlined as Q, FileWordOutlined as X, FilePdfOutlined as Y, FileImageOutlined as Z, ExportOutlined as v } from "@ant-design/icons";
|
|
4
|
+
import { Form as P, Upload as y, Modal as m } from "antd";
|
|
5
|
+
import $ from "mime";
|
|
6
|
+
import { useState as p, useCallback as U, useEffect as j, useMemo as k } from "react";
|
|
7
|
+
import { useTranslation as T } from "react-i18next";
|
|
8
|
+
import { TRANSLATION_NAMESPACE as tt } from "../../locale/hooks/translation-constants.js";
|
|
9
|
+
import et from "../../util/ValidationUtil.js";
|
|
10
|
+
import C from "../common/button/Button.js";
|
|
11
|
+
import st from "../common/layout/VerticalSpace.js";
|
|
12
|
+
function wt({
|
|
13
|
+
name: n,
|
|
21
14
|
label: t,
|
|
22
15
|
required: r,
|
|
23
|
-
provider:
|
|
24
|
-
onUploading:
|
|
25
|
-
onRemoved:
|
|
26
|
-
fieldClassName:
|
|
16
|
+
provider: e,
|
|
17
|
+
onUploading: a,
|
|
18
|
+
onRemoved: u,
|
|
19
|
+
fieldClassName: w,
|
|
27
20
|
accept: I,
|
|
28
|
-
rules:
|
|
29
|
-
maxCount:
|
|
30
|
-
block:
|
|
31
|
-
...
|
|
21
|
+
rules: _,
|
|
22
|
+
maxCount: V = 1,
|
|
23
|
+
block: L,
|
|
24
|
+
...W
|
|
32
25
|
}) {
|
|
33
|
-
const
|
|
34
|
-
async (
|
|
35
|
-
var c,
|
|
26
|
+
const d = P.useFormInstance(), h = P.useWatch(n, d), [b, A] = p(!1), [D, q] = p(!1), B = U(
|
|
27
|
+
async (l) => {
|
|
28
|
+
var c, o;
|
|
36
29
|
try {
|
|
37
|
-
const { file: i } =
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
console.log({ filePath:
|
|
41
|
-
const
|
|
30
|
+
const { file: i } = l, x = i.name;
|
|
31
|
+
A(!0), q(!0), a == null || a(!0);
|
|
32
|
+
const g = x ?? "", N = g.split("."), R = N[N.length - 1], z = e.generateFileName(g), M = `${await e.getInitialPath()}/${z}.${R}`;
|
|
33
|
+
console.log({ filePath: M });
|
|
34
|
+
const S = await e.upload(
|
|
42
35
|
{ ...i, originFileObj: i },
|
|
43
|
-
|
|
36
|
+
M
|
|
44
37
|
);
|
|
45
|
-
|
|
38
|
+
a == null || a(!1), d.setFieldValue(n, S), (c = l.onSuccess) == null || c.call(l, S);
|
|
46
39
|
} catch (i) {
|
|
47
|
-
(
|
|
40
|
+
(o = l.onError) == null || o.call(l, i);
|
|
48
41
|
} finally {
|
|
49
|
-
|
|
42
|
+
A(!1);
|
|
50
43
|
}
|
|
51
44
|
},
|
|
52
|
-
[
|
|
53
|
-
), [
|
|
54
|
-
|
|
55
|
-
!
|
|
45
|
+
[d, n, a, e]
|
|
46
|
+
), [F, E] = p([]);
|
|
47
|
+
j(() => {
|
|
48
|
+
!D && h && Promise.all(
|
|
56
49
|
(Array.isArray(h) ? h : [h]).map(
|
|
57
|
-
async (
|
|
58
|
-
const c =
|
|
50
|
+
async (l) => {
|
|
51
|
+
const c = $.getType(l), o = l.split("/").pop(), i = await e.getRealUrl(l);
|
|
59
52
|
return {
|
|
60
|
-
uid:
|
|
53
|
+
uid: l,
|
|
61
54
|
url: i,
|
|
62
55
|
type: c,
|
|
63
|
-
name:
|
|
56
|
+
name: o
|
|
64
57
|
};
|
|
65
58
|
}
|
|
66
59
|
)
|
|
67
|
-
).then((
|
|
68
|
-
const c =
|
|
60
|
+
).then((l) => E(() => {
|
|
61
|
+
const c = l.map(({ url: o, type: i, uid: x, name: g }) => ({ uid: x, url: o, type: i, response: x, thumbUrl: o, name: g }));
|
|
69
62
|
return console.log(c), c;
|
|
70
63
|
}));
|
|
71
|
-
}, [h,
|
|
72
|
-
const
|
|
73
|
-
async (
|
|
74
|
-
const c =
|
|
75
|
-
await
|
|
64
|
+
}, [h, D, b, e]);
|
|
65
|
+
const H = U(
|
|
66
|
+
async (l) => {
|
|
67
|
+
const c = l.response, o = c || d.getFieldValue(n);
|
|
68
|
+
await e.delete(o), u == null || u(), l && d.setFieldsValue({ [n]: null });
|
|
76
69
|
},
|
|
77
|
-
[
|
|
70
|
+
[d, n, u, e]
|
|
78
71
|
);
|
|
79
|
-
return /* @__PURE__ */
|
|
80
|
-
|
|
72
|
+
return /* @__PURE__ */ f(
|
|
73
|
+
P.Item,
|
|
81
74
|
{
|
|
82
75
|
label: t,
|
|
83
76
|
required: r,
|
|
84
|
-
name:
|
|
85
|
-
className:
|
|
77
|
+
name: n,
|
|
78
|
+
className: w,
|
|
86
79
|
rules: [
|
|
87
|
-
...r ?
|
|
88
|
-
...
|
|
80
|
+
...r ? et.required(t) : [],
|
|
81
|
+
..._ ?? []
|
|
89
82
|
],
|
|
90
83
|
children: [
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
|
|
84
|
+
/* @__PURE__ */ s("input", { hidden: !0 }),
|
|
85
|
+
/* @__PURE__ */ s(
|
|
86
|
+
y,
|
|
94
87
|
{
|
|
95
|
-
...
|
|
96
|
-
fileList:
|
|
97
|
-
className: ((
|
|
98
|
-
maxCount:
|
|
99
|
-
customRequest:
|
|
100
|
-
onRemove:
|
|
88
|
+
...W,
|
|
89
|
+
fileList: F,
|
|
90
|
+
className: ((F == null ? void 0 : F.length) ?? 0) >= V ? "hide-upload" : "",
|
|
91
|
+
maxCount: V,
|
|
92
|
+
customRequest: B,
|
|
93
|
+
onRemove: H,
|
|
101
94
|
listType: "picture",
|
|
102
|
-
onChange: ({ fileList:
|
|
103
|
-
|
|
95
|
+
onChange: ({ fileList: l }) => {
|
|
96
|
+
E(l);
|
|
104
97
|
},
|
|
105
|
-
style:
|
|
106
|
-
children: /* @__PURE__ */
|
|
98
|
+
style: L ? { width: "100%" } : void 0,
|
|
99
|
+
children: /* @__PURE__ */ s(C, { loading: b, children: "Upload File" })
|
|
107
100
|
}
|
|
108
101
|
)
|
|
109
102
|
]
|
|
110
103
|
}
|
|
111
104
|
);
|
|
112
105
|
}
|
|
113
|
-
const
|
|
114
|
-
const [r,
|
|
115
|
-
return
|
|
116
|
-
t &&
|
|
117
|
-
|
|
118
|
-
mimeType:
|
|
119
|
-
url:
|
|
106
|
+
const Ft = ({ provider: n, value: t }) => {
|
|
107
|
+
const [r, e] = p();
|
|
108
|
+
return j(() => {
|
|
109
|
+
t && n.getRealUrl(t).then((a) => {
|
|
110
|
+
e({
|
|
111
|
+
mimeType: $.getType(t),
|
|
112
|
+
url: a,
|
|
120
113
|
fileName: t.split("/").pop() ?? t
|
|
121
114
|
});
|
|
122
115
|
});
|
|
123
|
-
}, [
|
|
124
|
-
|
|
116
|
+
}, [n, t]), r ? /* @__PURE__ */ s(
|
|
117
|
+
rt,
|
|
125
118
|
{
|
|
126
119
|
fileName: r.fileName,
|
|
127
120
|
url: r == null ? void 0 : r.url,
|
|
128
121
|
mimeType: r == null ? void 0 : r.mimeType
|
|
129
122
|
}
|
|
130
|
-
) : /* @__PURE__ */
|
|
131
|
-
},
|
|
132
|
-
const
|
|
133
|
-
switch (
|
|
123
|
+
) : /* @__PURE__ */ s(O, {});
|
|
124
|
+
}, rt = ({ url: n, mimeType: t = "", fileName: r }) => {
|
|
125
|
+
const e = k(() => t != null && t.includes("image") ? "image" : t != null && t.includes("pdf") ? "pdf" : t != null && t.includes("word") ? "word" : t != null && t.includes("text") ? "text" : t != null && t.includes("presentation") ? "presentation" : t != null && t.includes("excel") || t != null && t.includes("spreadsheet") ? "excel" : "file", [t]), a = k(() => {
|
|
126
|
+
switch (e) {
|
|
134
127
|
case "image":
|
|
135
|
-
return /* @__PURE__ */
|
|
128
|
+
return /* @__PURE__ */ s(Z, {});
|
|
136
129
|
case "pdf":
|
|
137
|
-
return /* @__PURE__ */
|
|
130
|
+
return /* @__PURE__ */ s(Y, {});
|
|
138
131
|
case "word":
|
|
139
|
-
return /* @__PURE__ */
|
|
132
|
+
return /* @__PURE__ */ s(X, {});
|
|
140
133
|
case "text":
|
|
141
|
-
return /* @__PURE__ */
|
|
134
|
+
return /* @__PURE__ */ s(Q, {});
|
|
142
135
|
case "excel":
|
|
143
|
-
return /* @__PURE__ */
|
|
136
|
+
return /* @__PURE__ */ s(K, {});
|
|
144
137
|
case "presentation":
|
|
145
|
-
return /* @__PURE__ */
|
|
138
|
+
return /* @__PURE__ */ s(J, {});
|
|
146
139
|
default:
|
|
147
|
-
return /* @__PURE__ */
|
|
140
|
+
return /* @__PURE__ */ s(G, {});
|
|
148
141
|
}
|
|
149
|
-
}, [
|
|
150
|
-
return
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
|
|
142
|
+
}, [e]), [u, w] = p(!1), { t: I } = T(tt);
|
|
143
|
+
return e !== "file" && e !== "text" ? /* @__PURE__ */ f(O, { children: [
|
|
144
|
+
/* @__PURE__ */ s(
|
|
145
|
+
m,
|
|
153
146
|
{
|
|
154
|
-
open:
|
|
147
|
+
open: u,
|
|
155
148
|
title: r,
|
|
156
|
-
onCancel: () =>
|
|
157
|
-
footer: /* @__PURE__ */
|
|
149
|
+
onCancel: () => w(!1),
|
|
150
|
+
footer: /* @__PURE__ */ s(O, {}),
|
|
158
151
|
width: "100%",
|
|
159
152
|
style: { top: "8px", minHeight: "700px" },
|
|
160
153
|
destroyOnClose: !0,
|
|
161
|
-
children: /* @__PURE__ */
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
|
|
154
|
+
children: /* @__PURE__ */ f(st, { children: [
|
|
155
|
+
/* @__PURE__ */ s(
|
|
156
|
+
C,
|
|
164
157
|
{
|
|
165
158
|
tooltip: r,
|
|
166
|
-
icon: /* @__PURE__ */
|
|
159
|
+
icon: /* @__PURE__ */ s(v, {}),
|
|
167
160
|
target: "_blank",
|
|
168
|
-
href:
|
|
161
|
+
href: n,
|
|
169
162
|
style: { textDecoration: "none" },
|
|
170
163
|
children: I("str.openInNewTab")
|
|
171
164
|
}
|
|
172
165
|
),
|
|
173
|
-
|
|
166
|
+
e === "image" ? /* @__PURE__ */ s("img", { src: n, alt: r, style: { width: "100%" } }) : e === "pdf" ? /* @__PURE__ */ f("iframe", { title: r, src: n, width: "100%", height: "700px", children: [
|
|
174
167
|
"This browser does not support PDFs. Please download the PDF to view it:",
|
|
175
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ s("a", { href: n, children: "Download PDF" }),
|
|
176
169
|
"."
|
|
177
|
-
] }) : /* @__PURE__ */
|
|
170
|
+
] }) : /* @__PURE__ */ f(
|
|
178
171
|
"iframe",
|
|
179
172
|
{
|
|
180
173
|
title: r,
|
|
181
174
|
src: `https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(
|
|
182
|
-
|
|
175
|
+
n
|
|
183
176
|
)}`,
|
|
184
177
|
width: "100%",
|
|
185
178
|
height: "700px",
|
|
186
179
|
children: [
|
|
187
180
|
"This browser does not support open ",
|
|
188
|
-
|
|
181
|
+
e.toUpperCase(),
|
|
189
182
|
". Please download the",
|
|
190
|
-
|
|
183
|
+
e.toUpperCase(),
|
|
191
184
|
" to view it:",
|
|
192
|
-
/* @__PURE__ */
|
|
185
|
+
/* @__PURE__ */ f("a", { href: n, children: [
|
|
193
186
|
"Download ",
|
|
194
|
-
|
|
187
|
+
e.toUpperCase()
|
|
195
188
|
] }),
|
|
196
189
|
"."
|
|
197
190
|
]
|
|
@@ -200,28 +193,28 @@ const Ct = ({ provider: o, value: t }) => {
|
|
|
200
193
|
] })
|
|
201
194
|
}
|
|
202
195
|
),
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
-
|
|
196
|
+
/* @__PURE__ */ s(
|
|
197
|
+
C,
|
|
205
198
|
{
|
|
206
199
|
tooltip: r,
|
|
207
|
-
icon:
|
|
200
|
+
icon: a,
|
|
208
201
|
shape: "circle",
|
|
209
|
-
onClick: () =>
|
|
202
|
+
onClick: () => w(!0)
|
|
210
203
|
}
|
|
211
204
|
)
|
|
212
|
-
] }) : /* @__PURE__ */
|
|
213
|
-
|
|
205
|
+
] }) : /* @__PURE__ */ s(
|
|
206
|
+
C,
|
|
214
207
|
{
|
|
215
208
|
tooltip: r,
|
|
216
|
-
icon:
|
|
209
|
+
icon: a,
|
|
217
210
|
target: "_blank",
|
|
218
|
-
href:
|
|
211
|
+
href: n,
|
|
219
212
|
shape: "circle"
|
|
220
213
|
}
|
|
221
214
|
);
|
|
222
215
|
};
|
|
223
216
|
export {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
rt as FileCellValue,
|
|
218
|
+
Ft as FileCrudCellValue,
|
|
219
|
+
wt as default
|
|
227
220
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var k=Object.defineProperty;var E=(e,a,t)=>a in e?k(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t;var F=(e,a,t)=>E(e,typeof a!="symbol"?a+"":a,t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime");;/* empty css */const p=require("@ant-design/icons"),u=require("antd"),g=require("path-browserify"),i=require("react"),A=require("../../util/NumberUtil.cjs"),D=require("../../util/ValidationUtil.cjs"),M=require("uuid"),T=require("../common/picker/ImagePicker.cjs");class q{}class W extends q{constructor(t="",s=""){super();F(this,"rootPath");F(this,"subPath");this.rootPath=t,this.subPath=s}cloneFilePath(t){const s=g.parse(t),r=`${s.name}_cloned_${A.default.randInt(1e5)}`;return g.format({dir:s.dir,ext:s.ext,name:r})}generateFileName(t){return`${t.split(".")[0]}_${M.v4().replace("-","")}`}}function z({name:e,label:a,required:t,provider:s,onUploading:r,aspectRatio:P,onRemoved:o,fieldClassName:C,hideLabel:N=!1,listType:V}){const c=u.Form.useFormInstance(),h=u.Form.useWatch(e,c),[x,y]=i.useState(!1),I=i.useCallback(async(n,$)=>{if($){r==null||r(!0);const f=n.name,m=f.split("."),b=m[m.length-1],S=s.generateFileName(f),_=`${await s.getInitialPath()}/${S}.${b}`,O=await s.upload(n,_);y(!0),r==null||r(!1),c.setFieldValue(e,O)}else{console.log(n);const f=c.getFieldsValue(),m=await s.delete(f[e]);o==null||o(),m&&c.setFieldsValue({[e]:null})}},[c,e,o,r,s]),[d,j]=i.useState();return i.useEffect(()=>{!x&&h?s.getRealUrl(h).then(j):j(d)},[h,x,s,d]),l.jsx(l.Fragment,{children:l.jsxs(u.Form.Item,{rules:t?D.required(a):[],label:N?null:a,required:t,name:e,children:[l.jsx(T.default,{noStyle:!0,listType:V,aspectRatio:P,values:d,onRemove:n=>{n&&I(n,!1)},onAdd:async n=>{n&&await I(n,!0)},className:C}),l.jsx(u.Input,{hidden:!0})]})})}const B=({provider:e,value:a})=>{const[t,s]=i.useState();return i.useEffect(()=>{a&&e.getRealUrl(a).then(s)},[e,a]),t?l.jsx(w,{url:t}):l.jsx(l.Fragment,{})},w=({url:e})=>l.jsx(u.Avatar,{className:"p-0",children:l.jsx(u.Image,{className:"m-0 p-0 position-relative",src:e,preview:{mask:l.jsx(p.EyeOutlined,{})}})});exports.FileDownloadProvider=q;exports.FileUploadProvider=W;exports.ImageCellValue=w;exports.ImageCrudCellValue=B;exports.default=z;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var A = Object.defineProperty;
|
|
2
2
|
var E = (e, a, t) => a in e ? A(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
3
|
var h = (e, a, t) => E(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
-
import {
|
|
4
|
+
import { jsx as n, Fragment as V, jsxs as S } from "react/jsx-runtime";
|
|
5
5
|
/* empty css */
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
class
|
|
6
|
+
import { EyeOutlined as D } from "@ant-design/icons";
|
|
7
|
+
import { Form as F, Input as W, Avatar as q, Image as z } from "antd";
|
|
8
|
+
import w from "path-browserify";
|
|
9
|
+
import { useState as P, useCallback as B, useEffect as x } from "react";
|
|
10
|
+
import G from "../../util/NumberUtil.js";
|
|
11
|
+
import H from "../../util/ValidationUtil.js";
|
|
12
|
+
import { v4 as J } from "uuid";
|
|
13
|
+
import K from "../common/picker/ImagePicker.js";
|
|
14
|
+
class L {
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class ae extends L {
|
|
17
17
|
constructor(t = "", s = "") {
|
|
18
18
|
super();
|
|
19
19
|
h(this, "rootPath");
|
|
@@ -21,93 +21,93 @@ class te extends J {
|
|
|
21
21
|
this.rootPath = t, this.subPath = s;
|
|
22
22
|
}
|
|
23
23
|
cloneFilePath(t) {
|
|
24
|
-
const s =
|
|
25
|
-
return
|
|
24
|
+
const s = w.parse(t), l = `${s.name}_cloned_${G.randInt(1e5)}`;
|
|
25
|
+
return w.format({
|
|
26
26
|
dir: s.dir,
|
|
27
27
|
ext: s.ext,
|
|
28
|
-
name:
|
|
28
|
+
name: l
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
generateFileName(t) {
|
|
32
|
-
return `${t.split(".")[0]}_${
|
|
32
|
+
return `${t.split(".")[0]}_${J().replace("-", "")}`;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function le({
|
|
36
36
|
name: e,
|
|
37
37
|
label: a,
|
|
38
38
|
required: t,
|
|
39
39
|
provider: s,
|
|
40
|
-
onUploading:
|
|
40
|
+
onUploading: l,
|
|
41
41
|
aspectRatio: I,
|
|
42
42
|
onRemoved: c,
|
|
43
|
-
fieldClassName:
|
|
44
|
-
hideLabel:
|
|
45
|
-
listType:
|
|
43
|
+
fieldClassName: y,
|
|
44
|
+
hideLabel: C = !1,
|
|
45
|
+
listType: $
|
|
46
46
|
}) {
|
|
47
|
-
const i =
|
|
48
|
-
async (
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
const m =
|
|
52
|
-
|
|
47
|
+
const i = F.useFormInstance(), u = F.useWatch(e, i), [p, g] = P(!1), N = B(
|
|
48
|
+
async (r, b) => {
|
|
49
|
+
if (b) {
|
|
50
|
+
l == null || l(!0);
|
|
51
|
+
const m = r.name, o = m.split("."), k = o[o.length - 1], O = s.generateFileName(m), _ = `${await s.getInitialPath()}/${O}.${k}`, j = await s.upload(r, _);
|
|
52
|
+
g(!0), l == null || l(!1), i.setFieldValue(e, j);
|
|
53
53
|
} else {
|
|
54
|
-
console.log(
|
|
54
|
+
console.log(r);
|
|
55
55
|
const m = i.getFieldsValue(), o = await s.delete(m[e]);
|
|
56
56
|
c == null || c(), o && i.setFieldsValue({ [e]: null });
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
[i, e, c,
|
|
60
|
-
), [f,
|
|
61
|
-
return
|
|
62
|
-
!
|
|
63
|
-
}, [u,
|
|
64
|
-
|
|
59
|
+
[i, e, c, l, s]
|
|
60
|
+
), [f, d] = P();
|
|
61
|
+
return x(() => {
|
|
62
|
+
!p && u ? s.getRealUrl(u).then(d) : d(f);
|
|
63
|
+
}, [u, p, s, f]), /* @__PURE__ */ n(V, { children: /* @__PURE__ */ S(
|
|
64
|
+
F.Item,
|
|
65
65
|
{
|
|
66
|
-
rules: t ?
|
|
67
|
-
label:
|
|
66
|
+
rules: t ? H.required(a) : [],
|
|
67
|
+
label: C ? null : a,
|
|
68
68
|
required: t,
|
|
69
69
|
name: e,
|
|
70
70
|
children: [
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
|
|
71
|
+
/* @__PURE__ */ n(
|
|
72
|
+
K,
|
|
73
73
|
{
|
|
74
74
|
noStyle: !0,
|
|
75
|
-
listType:
|
|
75
|
+
listType: $,
|
|
76
76
|
aspectRatio: I,
|
|
77
77
|
values: f,
|
|
78
|
-
onRemove: (
|
|
79
|
-
|
|
78
|
+
onRemove: (r) => {
|
|
79
|
+
r && N(r, !1);
|
|
80
80
|
},
|
|
81
|
-
onAdd: async (
|
|
82
|
-
|
|
81
|
+
onAdd: async (r) => {
|
|
82
|
+
r && await N(r, !0);
|
|
83
83
|
},
|
|
84
|
-
className:
|
|
84
|
+
className: y
|
|
85
85
|
}
|
|
86
86
|
),
|
|
87
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ n(W, { hidden: !0 })
|
|
88
88
|
]
|
|
89
89
|
}
|
|
90
90
|
) });
|
|
91
91
|
}
|
|
92
|
-
const
|
|
93
|
-
const [t, s] =
|
|
94
|
-
return
|
|
92
|
+
const re = ({ provider: e, value: a }) => {
|
|
93
|
+
const [t, s] = P();
|
|
94
|
+
return x(() => {
|
|
95
95
|
a && e.getRealUrl(a).then(s);
|
|
96
|
-
}, [e, a]), t ? /* @__PURE__ */
|
|
97
|
-
},
|
|
98
|
-
|
|
96
|
+
}, [e, a]), t ? /* @__PURE__ */ n(M, { url: t }) : /* @__PURE__ */ n(V, {});
|
|
97
|
+
}, M = ({ url: e }) => /* @__PURE__ */ n(q, { className: "p-0", children: /* @__PURE__ */ n(
|
|
98
|
+
z,
|
|
99
99
|
{
|
|
100
100
|
className: "m-0 p-0 position-relative",
|
|
101
101
|
src: e,
|
|
102
102
|
preview: {
|
|
103
|
-
mask: /* @__PURE__ */
|
|
103
|
+
mask: /* @__PURE__ */ n(D, {})
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
) });
|
|
107
107
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
L as FileDownloadProvider,
|
|
109
|
+
ae as FileUploadProvider,
|
|
110
|
+
M as ImageCellValue,
|
|
111
|
+
re as ImageCrudCellValue,
|
|
112
|
+
le as default
|
|
113
113
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),s=require("@ant-design/icons"),i=require("react"),u=require("react-i18next"),c=require("../../../locale/hooks/translation-constants.cjs"),p=require("./CrudImportComponent.cjs"),a=require("../../common/button/Button.cjs");function m(n){const{t:r}=u.useTranslation(c.TRANSLATION_NAMESPACE),[o,e]=i.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(p,{open:o,onCloseMethod:e,...n}),t.jsx(a,{icon:t.jsx(s.ImportOutlined,{}),onClick:()=>e(!0),children:r("str.import")})]})}module.exports=m;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function
|
|
9
|
-
const { t:
|
|
10
|
-
return /* @__PURE__ */
|
|
11
|
-
/* @__PURE__ */ o
|
|
12
|
-
|
|
1
|
+
import { jsxs as e, Fragment as p, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { ImportOutlined as i } from "@ant-design/icons";
|
|
3
|
+
import { useState as s } from "react";
|
|
4
|
+
import { useTranslation as u } from "react-i18next";
|
|
5
|
+
import { TRANSLATION_NAMESPACE as f } from "../../../locale/hooks/translation-constants.js";
|
|
6
|
+
import l from "./CrudImportComponent.js";
|
|
7
|
+
import a from "../../common/button/Button.js";
|
|
8
|
+
function N(r) {
|
|
9
|
+
const { t: m } = u(f), [n, t] = s(!1);
|
|
10
|
+
return /* @__PURE__ */ e(p, { children: [
|
|
11
|
+
/* @__PURE__ */ o(
|
|
12
|
+
l,
|
|
13
13
|
{
|
|
14
|
-
open:
|
|
14
|
+
open: n,
|
|
15
15
|
onCloseMethod: t,
|
|
16
16
|
...r
|
|
17
17
|
}
|
|
18
18
|
),
|
|
19
|
-
/* @__PURE__ */ o
|
|
20
|
-
|
|
19
|
+
/* @__PURE__ */ o(
|
|
20
|
+
a,
|
|
21
21
|
{
|
|
22
|
-
icon: /* @__PURE__ */ o
|
|
22
|
+
icon: /* @__PURE__ */ o(i, {}),
|
|
23
23
|
onClick: () => t(!0),
|
|
24
|
-
children:
|
|
24
|
+
children: m("str.import")
|
|
25
25
|
}
|
|
26
26
|
)
|
|
27
27
|
] });
|
|
28
28
|
}
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
N as default
|
|
31
31
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),T=require("@ant-design/icons"),B=require("papaparse"),d=require("antd"),O=require("file-saver"),a=require("react"),V=require("react-i18next"),R=require("../../../locale/hooks/translation-constants.cjs"),W=require("../view/CrudViewer.cjs"),L=require("../../../util/DateUtil.cjs"),z=require("../../common/button/Button.cjs"),_=require("../../common/button/ImportButton.cjs");function $({onCloseMethod:C,open:h,fields:g,importProps:o}){const[u,v]=a.useState([]),[y,k]=a.useState(!1),[A,N]=a.useState(0);a.useEffect(()=>{h||(v([]),k(!1))},[h]);const x=a.useMemo(()=>new Map(g.filter(e=>{var t;return!e.hidden&&!((t=e.importProps)!=null&&t.hidden)&&!e.readonly}).map(e=>[e.name,e])),[g]),S=a.useMemo(()=>Array.from(x.values()).flatMap(e=>{var t;return[e.name,...((t=e.importProps)==null?void 0:t.extraFields)??[]]}),[x]),E=a.useCallback(async function(){const e=`${S.join(",")}
|
|
2
|
+
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});O.saveAs(t,(o==null?void 0:o.name)+" - "+L.formatDateTimeWithSecond(new Date).replaceAll(":","-")+".csv")},[S,o==null?void 0:o.name]),{t:i}=V.useTranslation(R.TRANSLATION_NAMESPACE),F=a.useCallback(async e=>{const t=new FileReader;t.onerror=console.error,t.onload=async n=>{var s;const c=(s=n==null?void 0:n.target)==null?void 0:s.result,l=B.parse(c,{header:!0});v(l.data)},t.readAsText(e)},[]),j=a.useMemo(()=>{var t,n,c;let e=!1;for(const l of u)for(const[s,f]of x.entries()){const b=l[s],m=b||!isNaN(b);if(f.required&&!m)if((n=(t=f.importProps)==null?void 0:t.extraFields)!=null&&n.length)for(const w of((c=f.importProps)==null?void 0:c.extraFields)??[])if(l[w]||!isNaN(l[w])){e=!1;break}else return!0;else return!0}return e},[u,x]),p=a.useCallback(e=>(t,n)=>{var l,s,f;const c=t||!isNaN(t);if(e.required&&!c){let b=i("err.validation.required");if((s=(l=e.importProps)==null?void 0:l.extraFields)!=null&&s.length){const m=(f=e.importProps)==null?void 0:f.extraFields;(m==null?void 0:m.find(I=>!n[I]))&&(b="Either one of these fields is required: "+[e.name,...m].join(", "))}return r.jsxs(d.Tooltip,{className:"d-flex",title:b,children:[r.jsx(T.WarningTwoTone,{twoToneColor:"#ee9702"}),t]})}return t},[i]),D=a.useCallback(async e=>{N(e)},[]),q=a.useCallback(async()=>{try{k(!0),await o.onClickImport(u,D),C(!1)}finally{k(!1),N(0)}},[u,o,C,D]),M=a.useCallback(async()=>{j?d.Modal.warn({title:i("str.warning"),content:i("qus.importWithIssues"),okText:i("str.import"),onOk:q,okCancel:!0,closable:!0}):q()},[j,q,i]);return r.jsxs(d.Modal,{title:[i("str.import"),o==null?void 0:o.name].filter(Boolean).join(" "),width:"100%",open:h,onOk:M,destroyOnClose:!0,onCancel:()=>C(!1),okText:i("str.import"),confirmLoading:y,okButtonProps:{disabled:!(u!=null&&u.length)},footer:(e,{OkBtn:t,CancelBtn:n})=>r.jsxs(d.Space,{children:[r.jsx(n,{}),r.jsx(t,{}),j&&r.jsx(d.Tooltip,{className:"d-flex",title:"Some fields have issue. Please review before submit.",children:r.jsx(T.WarningTwoTone,{twoToneColor:"#ee9702"})})]}),children:[r.jsxs(d.Space,{children:[r.jsx(z,{onClick:E,icon:r.jsx(T.DownloadOutlined,{}),children:i("str.downloadCsvTemplate")}),r.jsx(_.ImportButton,{disabled:y,type:"default",onClick:F,accept:".csv",children:i("str.importCsvFile")})]}),r.jsx(d.Spin,{spinning:y,indicator:A?r.jsx(d.Progress,{type:"circle",percent:A*100,size:50,format:e=>`${parseInt(e)}%`}):void 0,children:r.jsx(W,{data:u,bordered:!0,size:"small",fields:Array.from(x.values()).flatMap(e=>{var t,n,c,l;return e.type==="text"?[{...e,label:e.name,render:p(e)},...((n=(t=e.importProps)==null?void 0:t.extraFields)==null?void 0:n.map(s=>({...e,name:s,label:s,render:p(e)})))??[]]:e.type==="select"?[{...e,label:e.name,type:"text",render:p(e)},...((l=(c=e.importProps)==null?void 0:c.extraFields)==null?void 0:l.map(s=>({...e,name:s,label:s,type:"text",render:p(e)})))??[]]:[{...e,label:e.name,render:p(e)}]})})})]})}module.exports=$;
|