@kingteza/crud-component 1.2.1 → 1.2.2
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/Play.d.ts +2 -0
- package/dist/README.md +89 -0
- package/dist/common/appearance/Hider.cjs.js +1 -0
- package/dist/common/appearance/Hider.d.ts +6 -0
- package/dist/common/appearance/Hider.es.js +5 -0
- package/dist/common/appearance/index.d.ts +1 -0
- package/dist/common/button/Button.cjs.js +1 -0
- package/dist/common/button/Button.d.ts +11 -0
- package/dist/common/button/Button.es.js +57 -0
- package/dist/common/button/CloneButtonTable.cjs.js +1 -0
- package/dist/common/button/CloneButtonTable.d.ts +6 -0
- package/dist/common/button/CloneButtonTable.es.js +19 -0
- package/dist/common/button/DeleteButtonTable.cjs.js +1 -0
- package/dist/common/button/DeleteButtonTable.d.ts +13 -0
- package/dist/common/button/DeleteButtonTable.es.js +64 -0
- package/dist/common/button/ExportButton.cjs.js +1 -0
- package/dist/common/button/ExportButton.d.ts +4 -0
- package/dist/common/button/ExportButton.es.js +26 -0
- package/dist/common/button/HideButtonTable.cjs.js +1 -0
- package/dist/common/button/HideButtonTable.d.ts +13 -0
- package/dist/common/button/HideButtonTable.es.js +67 -0
- package/dist/common/button/ImportButton.cjs.js +1 -0
- package/dist/common/button/ImportButton.d.ts +9 -0
- package/dist/common/button/ImportButton.es.js +55 -0
- package/dist/common/button/NewButton.cjs.js +1 -0
- package/dist/common/button/NewButton.d.ts +12 -0
- package/dist/common/button/NewButton.es.js +23 -0
- package/dist/common/button/PrintButton.cjs.js +1 -0
- package/dist/common/button/PrintButton.d.ts +12 -0
- package/dist/common/button/PrintButton.es.js +25 -0
- package/dist/common/button/RefreshButton.cjs.js +1 -0
- package/dist/common/button/RefreshButton.d.ts +11 -0
- package/dist/common/button/RefreshButton.es.js +23 -0
- package/dist/common/button/UnHideButton.cjs.js +1 -0
- package/dist/common/button/UnHideButton.d.ts +14 -0
- package/dist/common/button/UnHideButton.es.js +69 -0
- package/dist/common/button/UpdateButtonTable.cjs.js +1 -0
- package/dist/common/button/UpdateButtonTable.d.ts +6 -0
- package/dist/common/button/UpdateButtonTable.es.js +19 -0
- package/dist/common/button/ViewButtonTable.cjs.js +1 -0
- package/dist/common/button/ViewButtonTable.d.ts +6 -0
- package/dist/common/button/ViewButtonTable.es.js +19 -0
- package/dist/common/button/index.d.ts +14 -0
- package/dist/common/check-box/CheckBox.cjs.js +1 -0
- package/dist/common/check-box/CheckBox.d.ts +9 -0
- package/dist/common/check-box/CheckBox.es.js +40 -0
- package/dist/common/check-box/index.d.ts +2 -0
- package/dist/common/date-picker/DatePicker.cjs.js +1 -0
- package/dist/common/date-picker/DatePicker.d.ts +37 -0
- package/dist/common/date-picker/DatePicker.es.js +87 -0
- package/dist/common/date-picker/TimePicker.cjs.js +1 -0
- package/dist/common/date-picker/TimePicker.d.ts +34 -0
- package/dist/common/date-picker/TimePicker.es.js +77 -0
- package/dist/common/date-picker/index.d.ts +3 -0
- package/dist/common/description/DescList.cjs.js +1 -0
- package/dist/common/description/DescList.d.ts +18 -0
- package/dist/common/description/DescList.es.js +16 -0
- package/dist/common/description/DescriptionComponent.d.ts +7 -0
- package/dist/common/description/index.d.ts +3 -0
- package/dist/common/icon/KIcon.cjs.js +1 -0
- package/dist/common/icon/KIcon.d.ts +9 -0
- package/dist/common/icon/KIcon.es.js +11 -0
- package/dist/common/index.cjs.js +1 -0
- package/dist/common/index.d.ts +20 -0
- package/dist/common/index.es.js +78 -0
- package/dist/common/layout/VerticalSpace.cjs.js +1 -0
- package/dist/common/layout/VerticalSpace.d.ts +5 -0
- package/dist/common/layout/VerticalSpace.es.js +6 -0
- package/dist/common/layout/index.d.ts +2 -0
- package/dist/common/loading/LoadingIndicator.cjs.js +1 -0
- package/dist/common/loading/LoadingIndicator.d.ts +6 -0
- package/dist/common/loading/LoadingIndicator.es.js +23 -0
- package/dist/common/loading/index.d.ts +2 -0
- package/dist/common/picker/ImagePicker.cjs.js +1 -0
- package/dist/common/picker/ImagePicker.d.ts +56 -0
- package/dist/common/picker/ImagePicker.es.js +320 -0
- package/dist/common/picker/index.d.ts +2 -0
- package/dist/common/radio/RadioGroupComponent.cjs.js +1 -0
- package/dist/common/radio/RadioGroupComponent.d.ts +18 -0
- package/dist/common/radio/RadioGroupComponent.es.js +19 -0
- package/dist/common/radio/index.d.ts +2 -0
- package/dist/common/report/SelectFieldInReport.cjs.js +1 -0
- package/dist/common/report/SelectFieldInReport.d.ts +16 -0
- package/dist/common/report/SelectFieldInReport.es.js +30 -0
- package/dist/common/report/index.d.ts +3 -0
- package/dist/common/rich/index.cjs.js +1 -0
- package/dist/common/rich/index.d.ts +10 -0
- package/dist/common/rich/index.es.js +66 -0
- package/dist/common/select/CustomSelectOption.cjs.js +1 -0
- package/dist/common/select/CustomSelectOption.d.ts +7 -0
- package/dist/common/select/CustomSelectOption.es.js +13 -0
- package/dist/common/select/SelectComponent.cjs.js +1 -0
- package/dist/common/select/SelectComponent.d.ts +21 -0
- package/dist/common/select/SelectComponent.es.js +85 -0
- package/dist/common/select/index.d.ts +3 -0
- package/dist/common/show-more/index.cjs.js +1 -0
- package/dist/common/show-more/index.d.ts +4 -0
- package/dist/common/show-more/index.es.js +8 -0
- package/dist/common/tab/TabViewWithRoute.cjs.js +1 -0
- package/dist/common/tab/TabViewWithRoute.d.ts +13 -0
- package/dist/common/tab/TabViewWithRoute.es.js +38 -0
- package/dist/common/tab/index.d.ts +2 -0
- package/dist/common/table/index.d.ts +3 -0
- package/dist/common/table/table.cjs.js +1 -0
- package/dist/common/table/table.d.ts +19 -0
- package/dist/common/table/table.es.js +40 -0
- package/dist/common/tag/StatusTag.cjs.js +1 -0
- package/dist/common/tag/StatusTag.d.ts +14 -0
- package/dist/common/tag/StatusTag.es.js +29 -0
- package/dist/common/tag/index.d.ts +2 -0
- package/dist/common/text/index.cjs.js +1 -0
- package/dist/common/text/index.d.ts +3 -0
- package/dist/common/text/index.es.js +5 -0
- package/dist/common/text/title/TitleWithHeadTitle.d.ts +7 -0
- package/dist/common/text/title/index.cjs.js +1 -0
- package/dist/common/text/title/index.d.ts +1 -0
- package/dist/common/text/title/index.es.js +5 -0
- package/dist/common/text-field/NumberField.cjs.js +1 -0
- package/dist/common/text-field/NumberField.d.ts +13 -0
- package/dist/common/text-field/NumberField.es.js +83 -0
- package/dist/common/text-field/PhoneNumberField.cjs.js +1 -0
- package/dist/common/text-field/PhoneNumberField.d.ts +4 -0
- package/dist/common/text-field/PhoneNumberField.es.js +18 -0
- package/dist/common/text-field/TextArea.cjs.js +1 -0
- package/dist/common/text-field/TextArea.d.ts +17 -0
- package/dist/common/text-field/TextArea.es.js +46 -0
- package/dist/common/text-field/TextField.cjs.js +1 -0
- package/dist/common/text-field/TextField.d.ts +27 -0
- package/dist/common/text-field/TextField.es.js +72 -0
- package/dist/common/text-field/index.d.ts +5 -0
- package/dist/common/tooltip/TooltipComponent.cjs.js +1 -0
- package/dist/common/tooltip/TooltipComponent.d.ts +5 -0
- package/dist/common/tooltip/TooltipComponent.es.js +9 -0
- package/dist/common/tooltip/index.d.ts +2 -0
- package/dist/common/wizard/WizardResult.cjs.js +1 -0
- package/dist/common/wizard/WizardResult.d.ts +16 -0
- package/dist/common/wizard/WizardResult.es.js +58 -0
- package/dist/common/wizard/WizardViewForm.cjs.js +1 -0
- package/dist/common/wizard/WizardViewForm.d.ts +24 -0
- package/dist/common/wizard/WizardViewForm.es.js +74 -0
- package/dist/common/wizard/index.d.ts +3 -0
- package/dist/context/WindowDimension.cjs.js +1 -0
- package/dist/context/WindowDimension.d.ts +4 -0
- package/dist/context/WindowDimension.es.js +8 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/crud/CrudComponent.cjs.js +1 -0
- package/dist/crud/CrudComponent.d.ts +245 -0
- package/dist/crud/CrudComponent.es.js +123 -0
- package/dist/crud/CrudField.cjs.js +1 -0
- package/dist/crud/CrudField.d.ts +4 -0
- package/dist/crud/CrudField.es.js +461 -0
- package/dist/crud/CrudForm.cjs.js +1 -0
- package/dist/crud/CrudForm.d.ts +14 -0
- package/dist/crud/CrudForm.es.js +103 -0
- package/dist/crud/CrudFormWizard.cjs.js +1 -0
- package/dist/crud/CrudFormWizard.d.ts +14 -0
- package/dist/crud/CrudFormWizard.es.js +140 -0
- package/dist/crud/CrudReportComponent.cjs.js +4 -0
- package/dist/crud/CrudReportComponent.d.ts +44 -0
- package/dist/crud/CrudReportComponent.es.js +255 -0
- package/dist/crud/CrudSearchComponent.cjs.js +1 -0
- package/dist/crud/CrudSearchComponent.d.ts +21 -0
- package/dist/crud/CrudSearchComponent.es.js +96 -0
- package/dist/crud/CrudTextAreaComponent.cjs.js +1 -0
- package/dist/crud/CrudTextAreaComponent.d.ts +22 -0
- package/dist/crud/CrudTextAreaComponent.es.js +52 -0
- package/dist/crud/FileCrudField.cjs.js +1 -0
- package/dist/crud/FileCrudField.d.ts +25 -0
- package/dist/crud/FileCrudField.es.js +221 -0
- package/dist/crud/ImageCrudField.cjs.js +1 -0
- package/dist/crud/ImageCrudField.d.ts +38 -0
- package/dist/crud/ImageCrudField.es.js +115 -0
- package/dist/crud/actions/index.cjs.js +1 -0
- package/dist/crud/actions/index.d.ts +26 -0
- package/dist/crud/actions/index.es.js +88 -0
- package/dist/crud/import/CrudImportButton.cjs.js +1 -0
- package/dist/crud/import/CrudImportButton.d.ts +3 -0
- package/dist/crud/import/CrudImportButton.es.js +30 -0
- package/dist/crud/import/CrudImportComponent.cjs.js +2 -0
- package/dist/crud/import/CrudImportComponent.d.ts +14 -0
- package/dist/crud/import/CrudImportComponent.es.js +222 -0
- package/dist/crud/index.d.ts +23 -0
- package/dist/crud/modal/index.cjs.js +1 -0
- package/dist/crud/modal/index.d.ts +24 -0
- package/dist/crud/modal/index.es.js +146 -0
- package/dist/crud/view/CrudDecListView.cjs.js +1 -0
- package/dist/crud/view/CrudDecListView.d.ts +15 -0
- package/dist/crud/view/CrudDecListView.es.js +57 -0
- package/dist/crud/view/CrudViewer.cjs.js +1 -0
- package/dist/crud/view/CrudViewer.d.ts +43 -0
- package/dist/crud/view/CrudViewer.es.js +304 -0
- package/dist/crud/view/CrudViewerUtil.cjs.js +1 -0
- package/dist/crud/view/CrudViewerUtil.d.ts +2 -0
- package/dist/crud/view/CrudViewerUtil.es.js +98 -0
- package/dist/crud/view/index.d.ts +5 -0
- package/dist/crud-component.css +6 -0
- package/dist/hooks/NavigatorHooks.cjs.js +1 -0
- package/dist/hooks/NavigatorHooks.d.ts +1 -0
- package/dist/hooks/NavigatorHooks.es.js +9 -0
- package/dist/icons/FlipHIcon.cjs.js +1 -0
- package/dist/icons/FlipHIcon.d.ts +3 -0
- package/dist/icons/FlipHIcon.es.js +28 -0
- package/dist/icons/FlipVIcon.cjs.js +1 -0
- package/dist/icons/FlipVIcon.d.ts +3 -0
- package/dist/icons/FlipVIcon.es.js +28 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +46 -0
- package/dist/locale/hooks/translation-constants.cjs.js +1 -0
- package/dist/locale/hooks/translation-constants.d.ts +1 -0
- package/dist/locale/hooks/translation-constants.es.js +4 -0
- package/dist/locale/index.cjs.js +1 -0
- package/dist/locale/index.d.ts +85 -0
- package/dist/locale/index.es.js +57 -0
- package/dist/locale/translations/en.cjs.js +1 -0
- package/dist/locale/translations/en.d.ts +63 -0
- package/dist/locale/translations/en.es.js +65 -0
- package/dist/package.json +122 -0
- package/dist/types/DialogComponentProp.d.ts +8 -0
- package/dist/types/Id.d.ts +10 -0
- package/dist/util/CrudUtil.cjs.js +1 -0
- package/dist/util/CrudUtil.d.ts +5 -0
- package/dist/util/CrudUtil.es.js +8 -0
- package/dist/util/DateUtil.cjs.js +1 -0
- package/dist/util/DateUtil.d.ts +7 -0
- package/dist/util/DateUtil.es.js +18 -0
- package/dist/util/ImageUtil.cjs.js +1 -0
- package/dist/util/ImageUtil.d.ts +14 -0
- package/dist/util/ImageUtil.es.js +63 -0
- package/dist/util/NumberUtil.cjs.js +1 -0
- package/dist/util/NumberUtil.d.ts +17 -0
- package/dist/util/NumberUtil.es.js +60 -0
- package/dist/util/ValidationUtil.cjs.js +1 -0
- package/dist/util/ValidationUtil.d.ts +14 -0
- package/dist/util/ValidationUtil.es.js +63 -0
- package/dist/util/index.cjs.js +1 -0
- package/dist/util/index.d.ts +4 -0
- package/dist/util/index.es.js +10 -0
- package/dist/vite-env.d.ts +1 -0
- package/package.json +4 -12
- package/release.config.cjs +0 -27
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsxs as E, Fragment as H, jsx as j } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as x, useCallback as V } from "react";
|
|
3
|
+
import F from "../../common/button/CloneButtonTable.es.js";
|
|
4
|
+
import k from "../../common/button/DeleteButtonTable.es.js";
|
|
5
|
+
import { ExportButton as r } from "../../common/button/ExportButton.es.js";
|
|
6
|
+
import C from "../../common/button/HideButtonTable.es.js";
|
|
7
|
+
import R from "../../common/button/UpdateButtonTable.es.js";
|
|
8
|
+
import I from "../modal/index.es.js";
|
|
9
|
+
function a({
|
|
10
|
+
data: y,
|
|
11
|
+
idField: b = "id",
|
|
12
|
+
extraAction: q,
|
|
13
|
+
onUpdate: z,
|
|
14
|
+
onClickUpdate: h,
|
|
15
|
+
onClickClone: T,
|
|
16
|
+
onDelete: u,
|
|
17
|
+
onHide: G,
|
|
18
|
+
onExport: J,
|
|
19
|
+
isHiding: L,
|
|
20
|
+
isDeleting: N,
|
|
21
|
+
confirmHiding: _,
|
|
22
|
+
confirmDeleting: $,
|
|
23
|
+
closeViewOnClickUpdate: w,
|
|
24
|
+
recentUpdateOrDeleteId: Q,
|
|
25
|
+
setRecentUpdateOrDeleteId: v,
|
|
26
|
+
setOpenView: K,
|
|
27
|
+
inBuiltModalProps: f
|
|
28
|
+
}) {
|
|
29
|
+
var X;
|
|
30
|
+
const g = q == null ? void 0 : q(y), S = x(null), W = V(
|
|
31
|
+
(m, A = !0, Y = !1) => {
|
|
32
|
+
var Z;
|
|
33
|
+
v == null || v(m[b]), f ? (Z = S.current) == null || Z.update(m, A, Y) : Y ? T == null || T(m) : h == null || h(m), w && (K == null || K(void 0));
|
|
34
|
+
},
|
|
35
|
+
[f, h]
|
|
36
|
+
);
|
|
37
|
+
return console.log({
|
|
38
|
+
onUpdate: z,
|
|
39
|
+
onClickUpdate: h,
|
|
40
|
+
onClickClone: T,
|
|
41
|
+
onDelete: u
|
|
42
|
+
}), (Array.isArray(g) ? (X = g == null ? void 0 : g.filter(Boolean)) != null && X.length : g) || z || h || f != null && f.onUpdate || T || f != null && f.onCreate || u || J || G ? /* @__PURE__ */ E(H, { children: [
|
|
43
|
+
f && /* @__PURE__ */ j(I, { ref: S, ...f }),
|
|
44
|
+
g,
|
|
45
|
+
(z || h || (f == null ? void 0 : f.onUpdate)) && /* @__PURE__ */ j(R, { value: y, onClick: (m) => W(m) }),
|
|
46
|
+
(T || (f == null ? void 0 : f.onCreate)) && /* @__PURE__ */ j(
|
|
47
|
+
F,
|
|
48
|
+
{
|
|
49
|
+
value: y,
|
|
50
|
+
onClick: (m) => W(m, !1, !0)
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
J && /* @__PURE__ */ j(
|
|
54
|
+
r,
|
|
55
|
+
{
|
|
56
|
+
value: y,
|
|
57
|
+
onClick: async (m) => await J(m)
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
G && /* @__PURE__ */ j(
|
|
61
|
+
C,
|
|
62
|
+
{
|
|
63
|
+
value: y,
|
|
64
|
+
disabled: L,
|
|
65
|
+
shouldConfirm: _,
|
|
66
|
+
loading: L && y[b] === Q,
|
|
67
|
+
onClick: async (m) => {
|
|
68
|
+
v == null || v(m[b]), await G({ [b]: m[b] });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
u && /* @__PURE__ */ j(
|
|
73
|
+
k,
|
|
74
|
+
{
|
|
75
|
+
value: y,
|
|
76
|
+
disabled: N,
|
|
77
|
+
shouldConfirm: $,
|
|
78
|
+
loading: N && y[b] === Q,
|
|
79
|
+
onClick: async (m) => {
|
|
80
|
+
v == null || v(m[b]), await u({ [b]: m[b] });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
] }) : void 0;
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
a as default
|
|
88
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),s=require("@ant-design/icons"),i=require("react"),u=require("../../locale/index.cjs.js"),c=require("./CrudImportComponent.cjs.js"),p=require("../../common/button/Button.cjs.js");function m(n){const{t:r}=u.useTranslationLib(),[o,e]=i.useState(!1);return t.jsxs(t.Fragment,{children:[t.jsx(c,{open:o,onCloseMethod:e,...n}),t.jsx(p,{icon:t.jsx(s.ImportOutlined,{}),onClick:()=>e(!0),children:r("str.import")})]})}module.exports=m;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { useTranslationLib as u } from "../../locale/index.es.js";
|
|
5
|
+
import f from "./CrudImportComponent.es.js";
|
|
6
|
+
import l from "../../common/button/Button.es.js";
|
|
7
|
+
function x(r) {
|
|
8
|
+
const { t: n } = u(), [m, t] = s(!1);
|
|
9
|
+
return /* @__PURE__ */ e(p, { children: [
|
|
10
|
+
/* @__PURE__ */ o(
|
|
11
|
+
f,
|
|
12
|
+
{
|
|
13
|
+
open: m,
|
|
14
|
+
onCloseMethod: t,
|
|
15
|
+
...r
|
|
16
|
+
}
|
|
17
|
+
),
|
|
18
|
+
/* @__PURE__ */ o(
|
|
19
|
+
l,
|
|
20
|
+
{
|
|
21
|
+
icon: /* @__PURE__ */ o(i, {}),
|
|
22
|
+
onClick: () => t(!0),
|
|
23
|
+
children: n("str.import")
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
] });
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
x as default
|
|
30
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),q=require("@ant-design/icons"),V=require("papaparse"),d=require("antd"),W=require("file-saver"),a=require("react"),O=require("../../locale/index.cjs.js"),L=require("../view/CrudViewer.cjs.js"),R=require("../../util/DateUtil.cjs.js"),z=require("../../common/button/Button.cjs.js"),$=require("../../common/button/ImportButton.cjs.js");function H({onCloseMethod:w,open:y,fields:T,importProps:o}){const[u,v]=a.useState([]),[C,k]=a.useState(!1),[A,D]=a.useState(0);a.useEffect(()=>{y||(v([]),k(!1))},[y]);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]),I=a.useMemo(()=>Array.from(p.values()).flatMap(e=>{var t;return[e.name,...((t=e.importProps)==null?void 0:t.extraFields)??[]]}),[p]),E=a.useCallback(async function(){const e=`${I.join(",")}
|
|
2
|
+
`,t=new Blob([e],{type:"text/csv;charset=utf-8;"});W.saveAs(t,(o==null?void 0:o.name)+" - "+R.formatDateTimeWithSecond(new Date).replaceAll(":","-")+".csv")},[I,o==null?void 0:o.name]),{t:i}=O.useTranslationLib(),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=V.parse(c,{header:!0});v(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(N=>!r[N]))&&(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]),S=a.useCallback(async e=>{D(e)},[]),b=a.useCallback(async()=>{try{k(!0),await o.onClickImport(u,S),w(!1)}finally{k(!1),D(0)}},[u,o,w,S]),{modal:F}=d.App.useApp(),M=a.useCallback(async()=>{g?F.warning?F.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:y,onOk:M,destroyOnHidden:!0,onCancel:()=>w(!1),okText:i("str.import"),confirmLoading:C,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(z,{onClick:E,icon:n.jsx(q.DownloadOutlined,{}),children:i("str.downloadCsvTemplate")}),n.jsx($.ImportButton,{disabled:C,type:"default",onClick:B,accept:".csv",children:i("str.importCsvFile")})]}),n.jsx(d.Spin,{spinning:C,indicator:A?n.jsx(d.Progress,{type:"circle",percent:A*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=H;
|
|
@@ -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,222 @@
|
|
|
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 $ from "papaparse";
|
|
4
|
+
import { Tooltip as V, App as H, Modal as R, Space as O, Spin as U, Progress as Y } from "antd";
|
|
5
|
+
import { saveAs as _ } from "file-saver";
|
|
6
|
+
import { useState as T, useEffect as G, useMemo as A, useCallback as f } from "react";
|
|
7
|
+
import { useTranslationLib as J } from "../../locale/index.es.js";
|
|
8
|
+
import K from "../view/CrudViewer.es.js";
|
|
9
|
+
import Q from "../../util/DateUtil.es.js";
|
|
10
|
+
import X from "../../common/button/Button.es.js";
|
|
11
|
+
import { ImportButton as Z } from "../../common/button/ImportButton.es.js";
|
|
12
|
+
function de({
|
|
13
|
+
onCloseMethod: b,
|
|
14
|
+
open: x,
|
|
15
|
+
fields: D,
|
|
16
|
+
importProps: o
|
|
17
|
+
}) {
|
|
18
|
+
const [c, F] = T([]), [g, C] = T(!1), [N, I] = T(0);
|
|
19
|
+
G(() => {
|
|
20
|
+
x || (F([]), C(!1));
|
|
21
|
+
}, [x]);
|
|
22
|
+
const u = A(
|
|
23
|
+
() => new Map(
|
|
24
|
+
D.filter((e) => {
|
|
25
|
+
var t;
|
|
26
|
+
return !e.hidden && !((t = e.importProps) != null && t.hidden) && !e.readonly;
|
|
27
|
+
}).map((e) => [e.name, e])
|
|
28
|
+
),
|
|
29
|
+
[D]
|
|
30
|
+
), E = A(
|
|
31
|
+
() => Array.from(u.values()).flatMap((e) => {
|
|
32
|
+
var t;
|
|
33
|
+
return [
|
|
34
|
+
e.name,
|
|
35
|
+
...((t = e.importProps) == null ? void 0 : t.extraFields) ?? []
|
|
36
|
+
];
|
|
37
|
+
}),
|
|
38
|
+
[u]
|
|
39
|
+
), W = f(
|
|
40
|
+
async function() {
|
|
41
|
+
const e = `${E.join(",")}
|
|
42
|
+
`, t = new Blob([e], { type: "text/csv;charset=utf-8;" });
|
|
43
|
+
_(
|
|
44
|
+
t,
|
|
45
|
+
(o == null ? void 0 : o.name) + " - " + Q.formatDateTimeWithSecond(/* @__PURE__ */ new Date()).replaceAll(":", "-") + ".csv"
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
[E, o == null ? void 0 : o.name]
|
|
49
|
+
), { t: s } = J(), L = f(async (e) => {
|
|
50
|
+
const t = new FileReader();
|
|
51
|
+
t.onerror = console.error, t.onload = async (r) => {
|
|
52
|
+
var n;
|
|
53
|
+
const l = (n = r == null ? void 0 : r.target) == null ? void 0 : n.result, a = $.parse(l, { header: !0 });
|
|
54
|
+
F(a.data);
|
|
55
|
+
}, t.readAsText(e);
|
|
56
|
+
}, []), k = A(() => {
|
|
57
|
+
var t, r, l;
|
|
58
|
+
let e = !1;
|
|
59
|
+
for (const a of c)
|
|
60
|
+
for (const [n, d] of u.entries()) {
|
|
61
|
+
const h = a[n], m = h || !isNaN(h);
|
|
62
|
+
if (d.required && !m)
|
|
63
|
+
if ((r = (t = d.importProps) == null ? void 0 : t.extraFields) != null && r.length)
|
|
64
|
+
for (const v of ((l = d.importProps) == null ? void 0 : l.extraFields) ?? [])
|
|
65
|
+
if (a[v] || !isNaN(a[v])) {
|
|
66
|
+
e = !1;
|
|
67
|
+
break;
|
|
68
|
+
} else return !0;
|
|
69
|
+
else return !0;
|
|
70
|
+
}
|
|
71
|
+
return e;
|
|
72
|
+
}, [c, u]), p = f(
|
|
73
|
+
(e) => (t, r) => {
|
|
74
|
+
var a, n, d;
|
|
75
|
+
const l = t || !isNaN(t);
|
|
76
|
+
if (e.required && !l) {
|
|
77
|
+
let h = s("err.validation.required");
|
|
78
|
+
if ((n = (a = e.importProps) == null ? void 0 : a.extraFields) != null && n.length) {
|
|
79
|
+
const m = (d = e.importProps) == null ? void 0 : d.extraFields;
|
|
80
|
+
(m == null ? void 0 : m.find((j) => !r[j])) && (h = "Either one of these fields is required: " + [e.name, ...m].join(", "));
|
|
81
|
+
}
|
|
82
|
+
return /* @__PURE__ */ w(V, { className: "d-flex", title: h, children: [
|
|
83
|
+
/* @__PURE__ */ i(B, { twoToneColor: "#ee9702" }),
|
|
84
|
+
t
|
|
85
|
+
] });
|
|
86
|
+
}
|
|
87
|
+
return t;
|
|
88
|
+
},
|
|
89
|
+
[s]
|
|
90
|
+
), q = f(async (e) => {
|
|
91
|
+
I(e);
|
|
92
|
+
}, []), y = f(async () => {
|
|
93
|
+
try {
|
|
94
|
+
C(!0), await o.onClickImport(c, q), b(!1);
|
|
95
|
+
} finally {
|
|
96
|
+
C(!1), I(0);
|
|
97
|
+
}
|
|
98
|
+
}, [c, o, b, q]), { modal: S } = H.useApp(), M = f(async () => {
|
|
99
|
+
k ? S.warning ? S.warning({
|
|
100
|
+
title: s("str.warning"),
|
|
101
|
+
content: s("qus.importWithIssues"),
|
|
102
|
+
okText: s("str.import"),
|
|
103
|
+
onOk: y,
|
|
104
|
+
okCancel: !0,
|
|
105
|
+
closable: !0
|
|
106
|
+
}) : (console.error(
|
|
107
|
+
"You must wrap your react app with App component. https://ant.design/components/app"
|
|
108
|
+
), window.confirm(s("qus.importWithIssues")) && y()) : y();
|
|
109
|
+
}, [k, y, s]);
|
|
110
|
+
return /* @__PURE__ */ w(
|
|
111
|
+
R,
|
|
112
|
+
{
|
|
113
|
+
title: [s("str.import"), o == null ? void 0 : o.name].filter(Boolean).join(" "),
|
|
114
|
+
width: "100%",
|
|
115
|
+
open: x,
|
|
116
|
+
onOk: M,
|
|
117
|
+
destroyOnHidden: !0,
|
|
118
|
+
onCancel: () => b(!1),
|
|
119
|
+
okText: s("str.import"),
|
|
120
|
+
confirmLoading: g,
|
|
121
|
+
okButtonProps: {
|
|
122
|
+
disabled: !(c != null && c.length)
|
|
123
|
+
},
|
|
124
|
+
footer: (e, { OkBtn: t, CancelBtn: r }) => /* @__PURE__ */ w(O, { children: [
|
|
125
|
+
/* @__PURE__ */ i(r, {}),
|
|
126
|
+
/* @__PURE__ */ i(t, {}),
|
|
127
|
+
k && /* @__PURE__ */ i(
|
|
128
|
+
V,
|
|
129
|
+
{
|
|
130
|
+
className: "d-flex",
|
|
131
|
+
title: "Some fields have issue. Please review before submit.",
|
|
132
|
+
children: /* @__PURE__ */ i(B, { twoToneColor: "#ee9702" })
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
] }),
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ w(O, { children: [
|
|
138
|
+
/* @__PURE__ */ i(
|
|
139
|
+
X,
|
|
140
|
+
{
|
|
141
|
+
onClick: W,
|
|
142
|
+
icon: /* @__PURE__ */ i(z, {}),
|
|
143
|
+
children: s("str.downloadCsvTemplate")
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
/* @__PURE__ */ i(
|
|
147
|
+
Z,
|
|
148
|
+
{
|
|
149
|
+
disabled: g,
|
|
150
|
+
type: "default",
|
|
151
|
+
onClick: L,
|
|
152
|
+
accept: ".csv",
|
|
153
|
+
children: s("str.importCsvFile")
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
] }),
|
|
157
|
+
/* @__PURE__ */ i(
|
|
158
|
+
U,
|
|
159
|
+
{
|
|
160
|
+
spinning: g,
|
|
161
|
+
indicator: N ? /* @__PURE__ */ i(
|
|
162
|
+
Y,
|
|
163
|
+
{
|
|
164
|
+
type: "circle",
|
|
165
|
+
percent: N * 100,
|
|
166
|
+
size: 50,
|
|
167
|
+
format: (e) => `${parseInt(e)}%`
|
|
168
|
+
}
|
|
169
|
+
) : void 0,
|
|
170
|
+
children: /* @__PURE__ */ i(
|
|
171
|
+
K,
|
|
172
|
+
{
|
|
173
|
+
data: c,
|
|
174
|
+
bordered: !0,
|
|
175
|
+
size: "small",
|
|
176
|
+
fields: Array.from(u.values()).flatMap((e) => {
|
|
177
|
+
var t, r, l, a;
|
|
178
|
+
return e.type === "text" ? [
|
|
179
|
+
{
|
|
180
|
+
...e,
|
|
181
|
+
label: e.name,
|
|
182
|
+
render: p(e)
|
|
183
|
+
},
|
|
184
|
+
...((r = (t = e.importProps) == null ? void 0 : t.extraFields) == null ? void 0 : r.map((n) => ({
|
|
185
|
+
...e,
|
|
186
|
+
name: n,
|
|
187
|
+
label: n,
|
|
188
|
+
render: p(e)
|
|
189
|
+
}))) ?? []
|
|
190
|
+
] : e.type === "select" ? [
|
|
191
|
+
{
|
|
192
|
+
...e,
|
|
193
|
+
label: e.name,
|
|
194
|
+
type: "text",
|
|
195
|
+
render: p(e)
|
|
196
|
+
},
|
|
197
|
+
...((a = (l = e.importProps) == null ? void 0 : l.extraFields) == null ? void 0 : a.map((n) => ({
|
|
198
|
+
...e,
|
|
199
|
+
name: n,
|
|
200
|
+
label: n,
|
|
201
|
+
type: "text",
|
|
202
|
+
render: p(e)
|
|
203
|
+
}))) ?? []
|
|
204
|
+
] : [
|
|
205
|
+
{
|
|
206
|
+
...e,
|
|
207
|
+
label: e.name,
|
|
208
|
+
render: p(e)
|
|
209
|
+
}
|
|
210
|
+
];
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
export {
|
|
221
|
+
de as default
|
|
222
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type { CheckboxBasedFieldProps, ColorPickerFieldProps, CrudComponentProps, CrudFieldGrid, CrudFieldProps, CrudPaginateProps, CrudPurpose, CrudWizardProp, DateBasedFieldProps, EnumCrudField, FormBuilderFunc, FormBuilderFunc0, GetFormFieldOptions, InitialCrudField, NumberBasedFieldProps, ObjectCrudField, SelectCrudField, SelectFieldItem, 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';
|
|
16
|
+
export { default as CrudImportComponent } from './import/CrudImportComponent';
|
|
17
|
+
export type { CrudImportComponentProps, CrudImportProps, } from './import/CrudImportComponent';
|
|
18
|
+
export { default as CrudImportButton } from './import/CrudImportButton';
|
|
19
|
+
export { default as CrudActions } from './actions';
|
|
20
|
+
export type { CrudActionsProps } from './actions';
|
|
21
|
+
export { default as CrudModal } from './modal';
|
|
22
|
+
export type { CrudModalProps, CrudModalRef } from './modal';
|
|
23
|
+
export * from './view';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const g=require("react/jsx-runtime"),B=require("antd"),t=require("react"),G=require("../CrudForm.cjs.js"),J=require("../CrudFormWizard.cjs.js"),K=require("../../locale/index.cjs.js"),H=require("../../util/CrudUtil.cjs.js"),Q=require("dayjs"),X=({fields:u,wizard:l,grid:I,fullWidthModal:M,isCreating:h,isUpdating:j,onCreate:b,onUpdate:v,idField:k="id",formBuilder:T},W)=>{const[s]=B.Form.useForm(),{t:C}=K.useTranslationLib(),[S,m]=t.useState(!1),[p,q]=t.useState("new"),[f,F]=t.useState(),[_,y]=t.useState(),[A,N]=t.useState(!1),[L,x]=t.useState(!1),[E,V]=t.useState(!1),P=t.useCallback(async c=>{var n;const d=l?c:await s.validateFields(),i=u.filter(a=>a.type==="color"),o={};for(const a of i){const e=H.getRealName(a.name,"upsertFieldName"),r=s.getFieldValue(e);o[e]=typeof r=="string"?r:(n=r==null?void 0:r.toHexString())==null?void 0:n.toUpperCase()}Object.assign(d,o),f&&v?(await v({...d,[k]:f[k]}),F(void 0)):!f&&b&&await b(d),y(void 0),s.resetFields(),m(!1)},[u,s,k,b,v,f,l]),R=t.useCallback(async c=>{N(c),x(!0)},[]),U=t.useCallback(async()=>{x(!0)},[]),O=t.useCallback(()=>{m(!0),q("new"),s.resetFields(),F(void 0),y(void 0)},[s]),D=t.useCallback(async(c,d=!0,i=!1)=>{try{V(!0),m(!0),q(i?"clone":"update");const o={};for(const n of u){const a=H.getRealName(n.name,"upsertFieldName"),e=c[a];if(i&&n.type==="image"){const r=e;try{const w=await n.provider.clone(r);o[a]=w;continue}catch{continue}}n.type==="date"||n.type==="time"?e&&(o[a]=Q(e)):n.type==="select"?n.multiple&&Array.isArray(e)?o[a]=e.map(r=>r[n.innerFieldId??"id"]):e&&typeof e=="object"?o[a]=e[n.innerFieldId??"id"]:(e&&typeof e=="string"||typeof e=="number")&&(o[a]=e):o[a]=e}s.setFieldsValue(o),y(o),d&&F(c)}finally{V(!1)}},[u,s]);t.useImperativeHandle(W,()=>({create:O,update:D}),[O,D]),t.useEffect(()=>{S&&(N(!1),x(!1))},[S]);const $=t.useCallback(async()=>{try{if(p==="clone"){const c=l?f:s.getFieldsValue(),d=u.filter(i=>i.type==="image");for(const i of d)c[i.name]&&i.provider.delete(c[i.name])}}finally{}l||s.resetFields(),y(void 0),F(void 0),m(!1)},[p,l,s,f,u]);return g.jsx(B.Modal,{width:M?"100%":void 0,title:C(p??"new"),open:S,confirmLoading:h||j,okText:C("str."+(p==="update"?"update":"save")),cancelText:C("str.cancel"),cancelButtonProps:{disabled:L,hidden:!!l},okButtonProps:{disabled:A,hidden:!!l},onCancel:$,onOk:()=>P(),destroyOnHidden:!0,children:g.jsxs(B.Spin,{spinning:E,children:[l?null:g.jsx(G.CrudForm,{purpose:p,fields:u,form:s,formBuilder:T,grid:I,onDeleteFile:U,onUploadFile:R}),l&&g.jsx(J,{submitting:h||j,className:"mt-2",onSave:P,updatingValue:_,fields:u,onDeleteFile:U,onUploadFile:R,purpose:p,wizard:l})]})})},Y=t.forwardRef(X);module.exports=Y;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { CrudFieldProps, CrudWizardProp, FormBuilderFunc } from '../CrudComponent';
|
|
3
|
+
import { default as IdProps } from '../../types/Id';
|
|
4
|
+
export interface CrudModalProps<T, FormType> {
|
|
5
|
+
fields: CrudFieldProps<T>[];
|
|
6
|
+
wizard?: CrudWizardProp<T>[];
|
|
7
|
+
grid?: boolean;
|
|
8
|
+
fullWidthModal?: boolean;
|
|
9
|
+
isCreating?: boolean;
|
|
10
|
+
isUpdating?: boolean;
|
|
11
|
+
onCreate?: (data: FormType) => Promise<any>;
|
|
12
|
+
onUpdate?: (data: FormType & IdProps) => Promise<any>;
|
|
13
|
+
idField?: string;
|
|
14
|
+
formBuilder?: FormBuilderFunc<T>;
|
|
15
|
+
}
|
|
16
|
+
export interface CrudModalRef<T> {
|
|
17
|
+
create: () => void;
|
|
18
|
+
update: (data: T, shouldSetUpdatingField?: boolean, isClone?: boolean) => Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
declare const CrudModal: <T, FormType = T>({ fields, wizard, grid, fullWidthModal, isCreating, isUpdating, onCreate, onUpdate, idField, formBuilder, }: CrudModalProps<T, FormType>, ref: Ref<CrudModalRef<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare const _default: <T, FormType = T>(props: CrudModalProps<T, FormType> & {
|
|
22
|
+
ref?: Ref<CrudModalRef<T>>;
|
|
23
|
+
}) => ReturnType<typeof CrudModal>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { jsx as N, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { Form as J, Modal as K, Spin as Q } from "antd";
|
|
3
|
+
import { forwardRef as X, useState as u, useCallback as m, useImperativeHandle as Y, useEffect as Z } from "react";
|
|
4
|
+
import { CrudForm as z } from "../CrudForm.es.js";
|
|
5
|
+
import ee from "../CrudFormWizard.es.js";
|
|
6
|
+
import { useTranslationLib as te } from "../../locale/index.es.js";
|
|
7
|
+
import M from "../../util/CrudUtil.es.js";
|
|
8
|
+
import oe from "dayjs";
|
|
9
|
+
const ne = ({
|
|
10
|
+
fields: c,
|
|
11
|
+
wizard: l,
|
|
12
|
+
grid: R,
|
|
13
|
+
fullWidthModal: T,
|
|
14
|
+
isCreating: S,
|
|
15
|
+
isUpdating: V,
|
|
16
|
+
onCreate: v,
|
|
17
|
+
onUpdate: b,
|
|
18
|
+
idField: B = "id",
|
|
19
|
+
formBuilder: W
|
|
20
|
+
}, _) => {
|
|
21
|
+
const [t] = J.useForm(), { t: h } = te(), [k, F] = u(!1), [p, x] = u("new"), [f, y] = u(), [A, g] = u(), [L, j] = u(!1), [E, C] = u(!1), [$, P] = u(!1), U = m(
|
|
22
|
+
async (i) => {
|
|
23
|
+
var o;
|
|
24
|
+
const d = l ? i : await t.validateFields(), a = c.filter((s) => s.type === "color"), n = {};
|
|
25
|
+
for (const s of a) {
|
|
26
|
+
const e = M.getRealName(s.name, "upsertFieldName"), r = t.getFieldValue(e);
|
|
27
|
+
n[e] = typeof r == "string" ? r : (o = r == null ? void 0 : r.toHexString()) == null ? void 0 : o.toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
Object.assign(d, n), f && b ? (await b({
|
|
30
|
+
...d,
|
|
31
|
+
[B]: f[B]
|
|
32
|
+
}), y(void 0)) : !f && v && await v(d), g(void 0), t.resetFields(), F(!1);
|
|
33
|
+
},
|
|
34
|
+
[c, t, B, v, b, f, l]
|
|
35
|
+
), O = m(async (i) => {
|
|
36
|
+
j(i), C(!0);
|
|
37
|
+
}, []), D = m(async () => {
|
|
38
|
+
C(!0);
|
|
39
|
+
}, []), H = m(() => {
|
|
40
|
+
F(!0), x("new"), t.resetFields(), y(void 0), g(void 0);
|
|
41
|
+
}, [t]), I = m(
|
|
42
|
+
async (i, d = !0, a = !1) => {
|
|
43
|
+
try {
|
|
44
|
+
P(!0), F(!0), x(a ? "clone" : "update");
|
|
45
|
+
const n = {};
|
|
46
|
+
for (const o of c) {
|
|
47
|
+
const s = M.getRealName(
|
|
48
|
+
o.name,
|
|
49
|
+
"upsertFieldName"
|
|
50
|
+
), e = i[s];
|
|
51
|
+
if (a && o.type === "image") {
|
|
52
|
+
const r = e;
|
|
53
|
+
try {
|
|
54
|
+
const w = await o.provider.clone(r);
|
|
55
|
+
n[s] = w;
|
|
56
|
+
continue;
|
|
57
|
+
} catch {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
o.type === "date" || o.type === "time" ? e && (n[s] = oe(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? n[s] = e.map(
|
|
62
|
+
(r) => r[o.innerFieldId ?? "id"]
|
|
63
|
+
) : e && typeof e == "object" ? n[s] = e[o.innerFieldId ?? "id"] : (e && typeof e == "string" || typeof e == "number") && (n[s] = e) : n[s] = e;
|
|
64
|
+
}
|
|
65
|
+
t.setFieldsValue(n), g(n), d && y(i);
|
|
66
|
+
} finally {
|
|
67
|
+
P(!1);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
[c, t]
|
|
71
|
+
);
|
|
72
|
+
Y(
|
|
73
|
+
_,
|
|
74
|
+
() => ({
|
|
75
|
+
create: H,
|
|
76
|
+
update: I
|
|
77
|
+
}),
|
|
78
|
+
[H, I]
|
|
79
|
+
), Z(() => {
|
|
80
|
+
k && (j(!1), C(!1));
|
|
81
|
+
}, [k]);
|
|
82
|
+
const q = m(async () => {
|
|
83
|
+
try {
|
|
84
|
+
if (p === "clone") {
|
|
85
|
+
const i = l ? f : t.getFieldsValue(), d = c.filter((a) => a.type === "image");
|
|
86
|
+
for (const a of d)
|
|
87
|
+
i[a.name] && a.provider.delete(i[a.name]);
|
|
88
|
+
}
|
|
89
|
+
} finally {
|
|
90
|
+
}
|
|
91
|
+
l || t.resetFields(), g(void 0), y(void 0), F(!1);
|
|
92
|
+
}, [p, l, t, f, c]);
|
|
93
|
+
return /* @__PURE__ */ N(
|
|
94
|
+
K,
|
|
95
|
+
{
|
|
96
|
+
width: T ? "100%" : void 0,
|
|
97
|
+
title: h(p ?? "new"),
|
|
98
|
+
open: k,
|
|
99
|
+
confirmLoading: S || V,
|
|
100
|
+
okText: h("str." + (p === "update" ? "update" : "save")),
|
|
101
|
+
cancelText: h("str.cancel"),
|
|
102
|
+
cancelButtonProps: {
|
|
103
|
+
disabled: E,
|
|
104
|
+
hidden: !!l
|
|
105
|
+
},
|
|
106
|
+
okButtonProps: {
|
|
107
|
+
disabled: L,
|
|
108
|
+
hidden: !!l
|
|
109
|
+
},
|
|
110
|
+
onCancel: q,
|
|
111
|
+
onOk: () => U(),
|
|
112
|
+
destroyOnHidden: !0,
|
|
113
|
+
children: /* @__PURE__ */ G(Q, { spinning: $, children: [
|
|
114
|
+
l ? null : /* @__PURE__ */ N(
|
|
115
|
+
z,
|
|
116
|
+
{
|
|
117
|
+
purpose: p,
|
|
118
|
+
fields: c,
|
|
119
|
+
form: t,
|
|
120
|
+
formBuilder: W,
|
|
121
|
+
grid: R,
|
|
122
|
+
onDeleteFile: D,
|
|
123
|
+
onUploadFile: O
|
|
124
|
+
}
|
|
125
|
+
),
|
|
126
|
+
l && /* @__PURE__ */ N(
|
|
127
|
+
ee,
|
|
128
|
+
{
|
|
129
|
+
submitting: S || V,
|
|
130
|
+
className: "mt-2",
|
|
131
|
+
onSave: U,
|
|
132
|
+
updatingValue: A,
|
|
133
|
+
fields: c,
|
|
134
|
+
onDeleteFile: D,
|
|
135
|
+
onUploadFile: O,
|
|
136
|
+
purpose: p,
|
|
137
|
+
wizard: l
|
|
138
|
+
}
|
|
139
|
+
)
|
|
140
|
+
] })
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
}, pe = X(ne);
|
|
144
|
+
export {
|
|
145
|
+
pe as default
|
|
146
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),d=require("../../common/description/DescList.cjs.js"),j=require("react"),v=require("../../locale/index.cjs.js"),V=require("./CrudViewerUtil.cjs.js"),f=require("../../util/CrudUtil.cjs.js"),p=require("../actions/index.cjs.js");function w({className:m,fields:i,data:e,descListColumn:b={xs:1,md:3,sm:2,lg:4},layout:g,keepEmptyValues:q,inBuiltModalProps:u,...s}){const{t:o}=v.useTranslationLib(),x=j.useMemo(()=>{const l=i.filter(({hidden:r,hideInDescList:n})=>!r&&!n).map((r,n)=>{const C=f.getRealName(r.name);return{label:r.label,noFormatting:!0,value:V.getRendererValueCrudViewer(r)(e==null?void 0:e[C],e,n)}}),c=e?t.jsx(p,{data:e,...s,inBuiltModalProps:u?{...u,fields:i}:void 0}):void 0;return c&&l.push({label:o("str.action"),value:c}),l},[e,i,o,s]);return e?t.jsx(d,{keepEmptyValues:q,bordered:!0,column:b,className:m,layout:g,list:x}):t.jsx(t.Fragment,{})}exports.CrudDecListView=w;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Breakpoint } from 'antd';
|
|
2
|
+
import { CrudFieldProps } from '../CrudComponent';
|
|
3
|
+
import { CrudActionsProps } from '../actions';
|
|
4
|
+
import { CrudModalProps } from '../modal';
|
|
5
|
+
export type DescListColumn = number | Partial<Record<Breakpoint, number>> | undefined;
|
|
6
|
+
export interface CrudDecListViewProps<T, FormType = T> extends Omit<CrudActionsProps<T, FormType>, "inBuiltModalProps"> {
|
|
7
|
+
fields: CrudFieldProps<T>[];
|
|
8
|
+
data: T | undefined;
|
|
9
|
+
className?: string;
|
|
10
|
+
descListColumn?: DescListColumn;
|
|
11
|
+
layout?: "horizontal" | "vertical";
|
|
12
|
+
keepEmptyValues?: boolean;
|
|
13
|
+
inBuiltModalProps?: Omit<CrudModalProps<T, FormType>, "fields">;
|
|
14
|
+
}
|
|
15
|
+
export declare function CrudDecListView<T, FormType = T>({ className, fields, data, descListColumn, layout, keepEmptyValues, inBuiltModalProps, ...crudActionsProps }: Readonly<CrudDecListViewProps<T, FormType>>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as i, Fragment as v } from "react/jsx-runtime";
|
|
2
|
+
import x from "../../common/description/DescList.es.js";
|
|
3
|
+
import { useMemo as F } from "react";
|
|
4
|
+
import { useTranslationLib as L } from "../../locale/index.es.js";
|
|
5
|
+
import { getRendererValueCrudViewer as V } from "./CrudViewerUtil.es.js";
|
|
6
|
+
import w from "../../util/CrudUtil.es.js";
|
|
7
|
+
import D from "../actions/index.es.js";
|
|
8
|
+
function _({
|
|
9
|
+
className: p,
|
|
10
|
+
fields: o,
|
|
11
|
+
data: r,
|
|
12
|
+
descListColumn: c = { xs: 1, md: 3, sm: 2, lg: 4 },
|
|
13
|
+
layout: f,
|
|
14
|
+
keepEmptyValues: b,
|
|
15
|
+
inBuiltModalProps: m,
|
|
16
|
+
...n
|
|
17
|
+
}) {
|
|
18
|
+
const { t: u } = L(), g = F(() => {
|
|
19
|
+
const l = o.filter(({ hidden: e, hideInDescList: t }) => !e && !t).map((e, t) => {
|
|
20
|
+
const C = w.getRealName(e.name);
|
|
21
|
+
return {
|
|
22
|
+
label: e.label,
|
|
23
|
+
noFormatting: !0,
|
|
24
|
+
value: V(e)(
|
|
25
|
+
r == null ? void 0 : r[C],
|
|
26
|
+
r,
|
|
27
|
+
t
|
|
28
|
+
)
|
|
29
|
+
};
|
|
30
|
+
}), s = r ? /* @__PURE__ */ i(
|
|
31
|
+
D,
|
|
32
|
+
{
|
|
33
|
+
data: r,
|
|
34
|
+
...n,
|
|
35
|
+
inBuiltModalProps: m ? { ...m, fields: o } : void 0
|
|
36
|
+
}
|
|
37
|
+
) : void 0;
|
|
38
|
+
return s && l.push({
|
|
39
|
+
label: u("str.action"),
|
|
40
|
+
value: s
|
|
41
|
+
}), l;
|
|
42
|
+
}, [r, o, u, n]);
|
|
43
|
+
return r ? /* @__PURE__ */ i(
|
|
44
|
+
x,
|
|
45
|
+
{
|
|
46
|
+
keepEmptyValues: b,
|
|
47
|
+
bordered: !0,
|
|
48
|
+
column: c,
|
|
49
|
+
className: p,
|
|
50
|
+
layout: f,
|
|
51
|
+
list: g
|
|
52
|
+
}
|
|
53
|
+
) : /* @__PURE__ */ i(v, {});
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
_ as CrudDecListView
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),xt=require("antd"),ft=require("@dnd-kit/core"),jt=require("@dnd-kit/modifiers"),yt=require("@dnd-kit/utilities"),d=require("@dnd-kit/sortable"),ht=require("../../common/button/Button.cjs.js"),qt=require("../../common/button/RefreshButton.cjs.js"),Ct=require("../../common/button/ViewButtonTable.cjs.js"),St=require("../actions/index.cjs.js"),It=require("../../common/table/table.cjs.js"),r=require("react"),lt=require("../../locale/index.cjs.js"),Rt=require("../CrudSearchComponent.cjs.js"),Mt=require("./CrudDecListView.cjs.js"),tt=require("./CrudViewerUtil.cjs.js"),dt=require("@ant-design/icons"),et=require("../../util/CrudUtil.cjs.js"),Tt=require("../../common/layout/VerticalSpace.cjs.js"),Bt=r.memo(It);function Dt({idField:n="id",loadingData:h,fields:m,isDeleting:T,isHiding:l,viewable:c=!1,paginateProps:j,onDelete:q,onHide:B,onUpdate:C,data:S=[],extraAction:D,onClickUpdate:V,minusHeight:E,scroll:k,onClickClone:v,className:z,expandable:$,size:p,bordered:A,descListColumn:ot,extraView:L,decListLayout:st,scrollToTop:Et,onClickRefresh:_,closeViewOnClickUpdate:G,onExport:J,confirmHiding:K,confirmDeleting:Q,rowClassName:X,actionWidth:Y=190,draggable:t,...rt}){const{t:Z}=lt.useTranslationLib(),P=r.useMemo(()=>m.map(({hideInTable:o,hidden:s,width:u,label:x,halign:I,...M})=>{const N=et.getRealName(M.name);return{title:x,width:u,key:N,dataIndex:N,hidden:o||s,align:I??(M.type==="number"?"right":void 0),render:tt.getRendererValueCrudViewer(M)}}),[m]),[i,R]=r.useState(),[W,H]=r.useState(),[y,U]=r.useState([]);r.useEffect(()=>{S&&U(S)},[S]),r.useEffect(()=>{S&&R(o=>{if(o)return S.find(s=>s[n]===o[n])})},[S,n,i]);const w=r.useCallback(o=>{var x;const{active:s,over:u}=o;if(t!=null&&t.onDragEnd&&(t==null||t.onDragEnd(o)),s.id!==(u==null?void 0:u.id)){const I=y.findIndex(f=>f[n]===s.id),M=y.findIndex(f=>f[n]===(u==null?void 0:u.id)),N=d.arrayMove(y,I,M);U(f=>{const it=f.findIndex(O=>O[n]===(s==null?void 0:s.id)),mt=f.findIndex(O=>O[n]===(u==null?void 0:u.id));return d.arrayMove(f,it,mt)}),(x=t==null?void 0:t.onDrag)==null||x.call(t,{newOrder:N.map(f=>f[n])})}},[y,n,t]),ct=r.useMemo(()=>{let o=typeof c=="string"?i==null?void 0:i[c]:void 0;if(typeof o=="object"){const s=m.find(u=>et.getRealName(u.name)===c);o=tt.getRendererValueCrudViewer(s)(o,i,0)}return o},[c,i,m]),a=r.useMemo(()=>({rowClassName:X,className:z,scroll:k??(E?{y:`calc(100vh - ${E})`}:void 0),id:"crud-table",bordered:A,size:p,expandable:$}),[X,z,k,E,A,p,$]),F=r.useMemo(()=>j?{total:j.count,onChange:j.setPage,current:j.page,pageSize:j.pageSize}:void 0,[j]),b=r.useMemo(()=>{const o=C||V||q||D||c,s=[];return t&&s.push({key:"key",align:"center",width:5,title:t==null?void 0:t.columnLabel,render:()=>e.jsx(Vt,{tooltip:t==null?void 0:t.tooltip})}),s.push(...P),o&&o&&s.push({title:Z("str.action"),fixed:"right",width:Y,render:(u,x)=>e.jsxs(e.Fragment,{children:[c&&e.jsx(Ct,{value:x,onClick:typeof c=="object"?()=>{var I;return(I=c.onClick)==null?void 0:I.call(c,x)}:R}),e.jsx(St,{data:x,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:l,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:W,setRecentUpdateOrDeleteId:H,setOpenView:R})]})}),s},[P,C,V,q,D,c,Z,Y]),g=r.useMemo(()=>y.map(o=>o[n]),[y,n]),ut=r.useCallback(()=>{const o=e.jsx(Bt,{...a,dataSource:y,loading:h,components:t?{body:{row:Nt}}:void 0,pagination:F,columns:b});return t?e.jsx(ft.DndContext,{modifiers:[jt.restrictToVerticalAxis],onDragEnd:w,children:e.jsx(d.SortableContext,{items:g,strategy:d.verticalListSortingStrategy,children:o})}):o},[a,y,h,F,b,t,g,w]);return e.jsxs("div",{children:[typeof c=="boolean"||typeof c=="string"&&e.jsx(xt.Modal,{width:"100%",open:!!i,title:ct??e.jsx("div",{children:" "}),footer:e.jsx(e.Fragment,{}),closable:!0,onCancel:()=>R(void 0),children:!!i&&e.jsxs("div",{children:[e.jsx(Mt.CrudDecListView,{layout:st,descListColumn:ot,data:i,fields:m,idField:n,extraAction:D,onUpdate:C,onClickUpdate:V,onClickClone:v,onDelete:q,onHide:B,onExport:J,isHiding:l,isDeleting:T,confirmHiding:K,confirmDeleting:Q,closeViewOnClickUpdate:G,recentUpdateOrDeleteId:W,setRecentUpdateOrDeleteId:H,setOpenView:R}),L==null?void 0:L(i)]},i==null?void 0:i[n])}),e.jsx(Rt,{fields:m,...rt}),e.jsxs(Tt,{children:[!!_&&e.jsx(qt.RefreshButton,{onClick:_}),ut()]})]})}const nt=r.createContext({}),Vt=({tooltip:n})=>{const{setActivatorNodeRef:h,listeners:m}=r.useContext(nt);return e.jsx(ht,{type:"text",size:"small",tooltip:n,icon:e.jsx(dt.HolderOutlined,{}),style:{cursor:"move",border:"none"},ref:h,...m})},Nt=n=>{const{attributes:h,listeners:m,setNodeRef:T,setActivatorNodeRef:l,transform:c,transition:j,isDragging:q}=d.useSortable({id:n["data-row-key"]}),B={...n.style,transform:yt.CSS.Translate.toString(c),transition:j,...q?{position:"relative",zIndex:9999}:{}},C=r.useMemo(()=>({setActivatorNodeRef:l,listeners:m}),[l,m]);return e.jsx(nt.Provider,{value:C,children:e.jsx("tr",{...n,ref:T,style:B,...h})})};module.exports=Dt;
|