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