@kingteza/crud-component 1.0.22 → 1.0.24
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/package.json +19 -19
- package/dist/App.d.ts +0 -2
- package/dist/components/common/DatePicker/DatePicker.cjs +0 -1
- package/dist/components/common/DatePicker/DatePicker.d.ts +0 -37
- package/dist/components/common/DatePicker/DatePicker.js +0 -88
- package/dist/components/common/DatePicker/TimePicker.cjs +0 -1
- package/dist/components/common/DatePicker/TimePicker.d.ts +0 -34
- package/dist/components/common/DatePicker/TimePicker.js +0 -78
- package/dist/components/common/DatePicker/index.d.ts +0 -3
- package/dist/components/common/appearance/Hider.cjs +0 -1
- package/dist/components/common/appearance/Hider.d.ts +0 -6
- package/dist/components/common/appearance/Hider.js +0 -5
- package/dist/components/common/appearance/index.d.ts +0 -0
- package/dist/components/common/button/Button.cjs +0 -1
- package/dist/components/common/button/Button.d.ts +0 -12
- package/dist/components/common/button/Button.js +0 -79
- package/dist/components/common/button/CloneButtonTable.cjs +0 -1
- package/dist/components/common/button/CloneButtonTable.d.ts +0 -6
- package/dist/components/common/button/CloneButtonTable.js +0 -20
- package/dist/components/common/button/DeleteButtonTable.cjs +0 -1
- package/dist/components/common/button/DeleteButtonTable.d.ts +0 -13
- package/dist/components/common/button/DeleteButtonTable.js +0 -68
- package/dist/components/common/button/ExportButton.cjs +0 -1
- package/dist/components/common/button/ExportButton.d.ts +0 -4
- package/dist/components/common/button/ExportButton.js +0 -27
- package/dist/components/common/button/HideButtonTable.cjs +0 -1
- package/dist/components/common/button/HideButtonTable.d.ts +0 -13
- package/dist/components/common/button/HideButtonTable.js +0 -68
- package/dist/components/common/button/ImportButton.cjs +0 -1
- package/dist/components/common/button/ImportButton.d.ts +0 -9
- package/dist/components/common/button/ImportButton.js +0 -56
- package/dist/components/common/button/NewButton.cjs +0 -1
- package/dist/components/common/button/NewButton.d.ts +0 -12
- package/dist/components/common/button/NewButton.js +0 -24
- package/dist/components/common/button/PrintButton.cjs +0 -1
- package/dist/components/common/button/PrintButton.d.ts +0 -12
- package/dist/components/common/button/PrintButton.js +0 -26
- package/dist/components/common/button/RefreshButton.cjs +0 -1
- package/dist/components/common/button/RefreshButton.d.ts +0 -11
- package/dist/components/common/button/RefreshButton.js +0 -24
- package/dist/components/common/button/UnHideButton.cjs +0 -1
- package/dist/components/common/button/UnHideButton.d.ts +0 -14
- package/dist/components/common/button/UnHideButton.js +0 -70
- package/dist/components/common/button/UpdateButtonTable.cjs +0 -1
- package/dist/components/common/button/UpdateButtonTable.d.ts +0 -6
- package/dist/components/common/button/UpdateButtonTable.js +0 -20
- package/dist/components/common/button/ViewButtonTable.cjs +0 -1
- package/dist/components/common/button/ViewButtonTable.d.ts +0 -6
- package/dist/components/common/button/ViewButtonTable.js +0 -20
- package/dist/components/common/button/index.d.ts +0 -14
- package/dist/components/common/check-box/CheckBox.cjs +0 -1
- package/dist/components/common/check-box/CheckBox.d.ts +0 -9
- package/dist/components/common/check-box/CheckBox.js +0 -40
- package/dist/components/common/check-box/index.d.ts +0 -2
- package/dist/components/common/description/DescList.cjs +0 -1
- package/dist/components/common/description/DescList.d.ts +0 -18
- package/dist/components/common/description/DescList.js +0 -16
- package/dist/components/common/description/DescriptionComponent.d.ts +0 -7
- package/dist/components/common/description/index.d.ts +0 -3
- package/dist/components/common/index.d.ts +0 -22
- package/dist/components/common/layout/VerticalSpace.cjs +0 -1
- package/dist/components/common/layout/VerticalSpace.d.ts +0 -5
- package/dist/components/common/layout/VerticalSpace.js +0 -6
- package/dist/components/common/layout/index.d.ts +0 -2
- package/dist/components/common/loading/LoadingIndicator.cjs +0 -1
- package/dist/components/common/loading/LoadingIndicator.d.ts +0 -6
- package/dist/components/common/loading/LoadingIndicator.js +0 -24
- package/dist/components/common/loading/index.d.ts +0 -2
- package/dist/components/common/picker/ImagePicker.cjs +0 -1
- package/dist/components/common/picker/ImagePicker.d.ts +0 -56
- package/dist/components/common/picker/ImagePicker.js +0 -282
- package/dist/components/common/picker/index.d.ts +0 -2
- package/dist/components/common/radio/RadioGroupComponent.cjs +0 -1
- package/dist/components/common/radio/RadioGroupComponent.d.ts +0 -18
- package/dist/components/common/radio/RadioGroupComponent.js +0 -19
- package/dist/components/common/radio/index.d.ts +0 -2
- package/dist/components/common/report/SelectFieldInReport.cjs +0 -1
- package/dist/components/common/report/SelectFieldInReport.d.ts +0 -16
- package/dist/components/common/report/SelectFieldInReport.js +0 -30
- package/dist/components/common/report/index.d.ts +0 -3
- package/dist/components/common/select/CustomSelectOption.cjs +0 -1
- package/dist/components/common/select/CustomSelectOption.d.ts +0 -7
- package/dist/components/common/select/CustomSelectOption.js +0 -13
- package/dist/components/common/select/SelectComponent.cjs +0 -1
- package/dist/components/common/select/SelectComponent.d.ts +0 -21
- package/dist/components/common/select/SelectComponent.js +0 -89
- package/dist/components/common/select/index.d.ts +0 -3
- package/dist/components/common/show-more/index.cjs +0 -1
- package/dist/components/common/show-more/index.d.ts +0 -4
- package/dist/components/common/show-more/index.js +0 -8
- package/dist/components/common/tab/TabViewWithRoute.cjs +0 -1
- package/dist/components/common/tab/TabViewWithRoute.d.ts +0 -13
- package/dist/components/common/tab/TabViewWithRoute.js +0 -38
- package/dist/components/common/tab/index.d.ts +0 -2
- package/dist/components/common/table/index.d.ts +0 -3
- package/dist/components/common/table/table.cjs +0 -1
- package/dist/components/common/table/table.d.ts +0 -19
- package/dist/components/common/table/table.js +0 -40
- package/dist/components/common/tag/StatusTag.cjs +0 -1
- package/dist/components/common/tag/StatusTag.d.ts +0 -14
- package/dist/components/common/tag/StatusTag.js +0 -30
- package/dist/components/common/tag/index.d.ts +0 -2
- package/dist/components/common/text/index.cjs +0 -1
- package/dist/components/common/text/index.d.ts +0 -3
- package/dist/components/common/text/index.js +0 -5
- package/dist/components/common/text/title/TitleWithHeadTitle.d.ts +0 -7
- package/dist/components/common/text/title/index.cjs +0 -1
- package/dist/components/common/text/title/index.d.ts +0 -1
- package/dist/components/common/text/title/index.js +0 -5
- package/dist/components/common/text-field/NumberField.cjs +0 -1
- package/dist/components/common/text-field/NumberField.d.ts +0 -13
- package/dist/components/common/text-field/NumberField.js +0 -83
- package/dist/components/common/text-field/PhoneNumberField.cjs +0 -1
- package/dist/components/common/text-field/PhoneNumberField.d.ts +0 -4
- package/dist/components/common/text-field/PhoneNumberField.js +0 -18
- package/dist/components/common/text-field/TextArea.cjs +0 -1
- package/dist/components/common/text-field/TextArea.d.ts +0 -17
- package/dist/components/common/text-field/TextArea.js +0 -47
- package/dist/components/common/text-field/TextField.cjs +0 -1
- package/dist/components/common/text-field/TextField.d.ts +0 -27
- package/dist/components/common/text-field/TextField.js +0 -73
- package/dist/components/common/text-field/index.d.ts +0 -5
- package/dist/components/common/tooltip/TooltipComponent.cjs +0 -1
- package/dist/components/common/tooltip/TooltipComponent.d.ts +0 -5
- package/dist/components/common/tooltip/TooltipComponent.js +0 -9
- package/dist/components/common/tooltip/index.d.ts +0 -2
- package/dist/components/common/wizard/WizardResult.cjs +0 -1
- package/dist/components/common/wizard/WizardResult.d.ts +0 -16
- package/dist/components/common/wizard/WizardResult.js +0 -60
- package/dist/components/common/wizard/WizardViewForm.cjs +0 -1
- package/dist/components/common/wizard/WizardViewForm.d.ts +0 -24
- package/dist/components/common/wizard/WizardViewForm.js +0 -74
- package/dist/components/common/wizard/index.d.ts +0 -3
- package/dist/components/crud/CrudComponent.cjs +0 -1
- package/dist/components/crud/CrudComponent.d.ts +0 -237
- package/dist/components/crud/CrudComponent.js +0 -210
- package/dist/components/crud/CrudField.cjs +0 -1
- package/dist/components/crud/CrudField.d.ts +0 -4
- package/dist/components/crud/CrudField.js +0 -459
- package/dist/components/crud/CrudForm.cjs +0 -1
- package/dist/components/crud/CrudForm.d.ts +0 -14
- package/dist/components/crud/CrudForm.js +0 -91
- package/dist/components/crud/CrudFormWizard.cjs +0 -1
- package/dist/components/crud/CrudFormWizard.d.ts +0 -14
- package/dist/components/crud/CrudFormWizard.js +0 -140
- package/dist/components/crud/CrudReportComponent.cjs +0 -4
- package/dist/components/crud/CrudReportComponent.d.ts +0 -44
- package/dist/components/crud/CrudReportComponent.js +0 -255
- package/dist/components/crud/CrudSearchComponent.cjs +0 -1
- package/dist/components/crud/CrudSearchComponent.d.ts +0 -21
- package/dist/components/crud/CrudSearchComponent.js +0 -95
- package/dist/components/crud/FileCrudField.cjs +0 -1
- package/dist/components/crud/FileCrudField.d.ts +0 -25
- package/dist/components/crud/FileCrudField.js +0 -220
- package/dist/components/crud/ImageCrudField.cjs +0 -1
- package/dist/components/crud/ImageCrudField.d.ts +0 -38
- package/dist/components/crud/ImageCrudField.js +0 -113
- package/dist/components/crud/import/CrudImportButton.cjs +0 -1
- package/dist/components/crud/import/CrudImportButton.d.ts +0 -3
- package/dist/components/crud/import/CrudImportButton.js +0 -31
- package/dist/components/crud/import/CrudImportComponent.cjs +0 -2
- package/dist/components/crud/import/CrudImportComponent.d.ts +0 -14
- package/dist/components/crud/import/CrudImportComponent.js +0 -223
- package/dist/components/crud/index.d.ts +0 -15
- package/dist/components/crud/view/CrudDecListView.cjs +0 -1
- package/dist/components/crud/view/CrudDecListView.d.ts +0 -14
- package/dist/components/crud/view/CrudDecListView.js +0 -42
- package/dist/components/crud/view/CrudViewer.cjs +0 -1
- package/dist/components/crud/view/CrudViewer.d.ts +0 -43
- package/dist/components/crud/view/CrudViewer.js +0 -217
- package/dist/components/crud/view/CrudViewerUtil.cjs +0 -1
- package/dist/components/crud/view/CrudViewerUtil.d.ts +0 -2
- package/dist/components/crud/view/CrudViewerUtil.js +0 -57
- package/dist/components/crud/view/index.d.ts +0 -5
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -32
- package/dist/locale/hooks/translation-constants.cjs +0 -1
- package/dist/locale/hooks/translation-constants.d.ts +0 -1
- package/dist/locale/hooks/translation-constants.js +0 -4
- package/dist/locale/index.cjs +0 -1
- package/dist/locale/index.d.ts +0 -74
- package/dist/locale/index.js +0 -37
- package/dist/locale/translations/en.cjs +0 -1
- package/dist/locale/translations/en.d.ts +0 -58
- package/dist/locale/translations/en.js +0 -60
- package/dist/main.d.ts +0 -0
- package/dist/util/DateUtil.cjs +0 -1
- package/dist/util/DateUtil.d.ts +0 -7
- package/dist/util/DateUtil.js +0 -6
- package/dist/util/ImageUtil.cjs +0 -1
- package/dist/util/ImageUtil.d.ts +0 -14
- package/dist/util/ImageUtil.js +0 -63
- package/dist/util/NumberUtil.cjs +0 -1
- package/dist/util/NumberUtil.d.ts +0 -17
- package/dist/util/NumberUtil.js +0 -60
- package/dist/util/ValidationUtil.cjs +0 -1
- package/dist/util/ValidationUtil.d.ts +0 -14
- package/dist/util/ValidationUtil.js +0 -60
- package/dist/util/index.cjs +0 -1
- package/dist/util/index.d.ts +0 -4
- package/dist/util/index.js +0 -10
- package/dist/vite-env.d.ts +0 -1
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { jsx as t, Fragment as T, jsxs as F } from "react/jsx-runtime";
|
|
2
|
-
import { LeftOutlined as v, SaveOutlined as w, RightOutlined as x } from "@ant-design/icons";
|
|
3
|
-
import { Form as k, Divider as A, Row as E, Col as S } from "antd";
|
|
4
|
-
import { useMemo as y, useEffect as O } from "react";
|
|
5
|
-
import { useTranslation as W } from "react-i18next";
|
|
6
|
-
import { TRANSLATION_NAMESPACE as j } from "../../locale/hooks/translation-constants.js";
|
|
7
|
-
import { CrudFormFields as z } from "./CrudForm.js";
|
|
8
|
-
import C from "../common/button/Button.js";
|
|
9
|
-
import B from "../common/wizard/WizardViewForm.js";
|
|
10
|
-
function H({
|
|
11
|
-
fields: d,
|
|
12
|
-
className: f,
|
|
13
|
-
onDeleteFile: u,
|
|
14
|
-
onUploadFile: l,
|
|
15
|
-
purpose: m,
|
|
16
|
-
wizard: e = [],
|
|
17
|
-
updatingValue: s,
|
|
18
|
-
onSave: h,
|
|
19
|
-
submitting: g
|
|
20
|
-
}) {
|
|
21
|
-
const a = y(() => e.map((o) => {
|
|
22
|
-
let r = !0;
|
|
23
|
-
const n = d.filter(
|
|
24
|
-
(i) => o.fields.includes(i.name)
|
|
25
|
-
);
|
|
26
|
-
return n.forEach((i) => r && (r = i.hidden ?? !1)), {
|
|
27
|
-
...o,
|
|
28
|
-
hidden: r,
|
|
29
|
-
fieldThatShouldShowing: n
|
|
30
|
-
};
|
|
31
|
-
}), [d, e]), c = y(
|
|
32
|
-
() => a.filter((o) => !o.hidden),
|
|
33
|
-
[a]
|
|
34
|
-
);
|
|
35
|
-
return /* @__PURE__ */ t(T, { children: /* @__PURE__ */ t(
|
|
36
|
-
B,
|
|
37
|
-
{
|
|
38
|
-
onSubmit: (o, r) => {
|
|
39
|
-
console.log(r), h(r);
|
|
40
|
-
},
|
|
41
|
-
className: f,
|
|
42
|
-
pages: c.map(
|
|
43
|
-
({ title: o, icon: r, fieldThatShouldShowing: n, hidden: i }, p) => ({
|
|
44
|
-
title: o,
|
|
45
|
-
icon: r,
|
|
46
|
-
hidden: i,
|
|
47
|
-
component: (b) => /* @__PURE__ */ t(
|
|
48
|
-
N,
|
|
49
|
-
{
|
|
50
|
-
fields: n,
|
|
51
|
-
onDeleteFile: u,
|
|
52
|
-
onUploadFile: l,
|
|
53
|
-
purpose: m,
|
|
54
|
-
i: p,
|
|
55
|
-
updatingValue: s,
|
|
56
|
-
backward: b.backward,
|
|
57
|
-
forward: b.forward,
|
|
58
|
-
wizard: c,
|
|
59
|
-
submitting: g
|
|
60
|
-
},
|
|
61
|
-
p
|
|
62
|
-
)
|
|
63
|
-
})
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
|
-
) });
|
|
67
|
-
}
|
|
68
|
-
function N({
|
|
69
|
-
fields: d,
|
|
70
|
-
onDeleteFile: f,
|
|
71
|
-
onUploadFile: u,
|
|
72
|
-
purpose: l,
|
|
73
|
-
wizard: m = [],
|
|
74
|
-
i: e,
|
|
75
|
-
forward: s,
|
|
76
|
-
backward: h,
|
|
77
|
-
submitting: g,
|
|
78
|
-
updatingValue: a
|
|
79
|
-
}) {
|
|
80
|
-
const c = m[e], { t: o } = W(j), [r] = k.useForm();
|
|
81
|
-
return O(() => {
|
|
82
|
-
if (a && (l === "update" || l === "clone")) {
|
|
83
|
-
const n = {};
|
|
84
|
-
for (const i of d)
|
|
85
|
-
n[i.name] = a[i.name];
|
|
86
|
-
r.setFieldsValue(n);
|
|
87
|
-
}
|
|
88
|
-
}, [d, r, l, a]), /* @__PURE__ */ F(k, { name: String(e), form: r, layout: "vertical", children: [
|
|
89
|
-
/* @__PURE__ */ t(
|
|
90
|
-
z,
|
|
91
|
-
{
|
|
92
|
-
fields: d,
|
|
93
|
-
formBuilder: c.formBuilder,
|
|
94
|
-
grid: c.grid,
|
|
95
|
-
onDeleteFile: f,
|
|
96
|
-
onUploadFile: u,
|
|
97
|
-
purpose: l
|
|
98
|
-
}
|
|
99
|
-
),
|
|
100
|
-
/* @__PURE__ */ t(A, {}),
|
|
101
|
-
/* @__PURE__ */ F(E, { gutter: [8, 8], children: [
|
|
102
|
-
e > 0 && /* @__PURE__ */ t(S, { md: 12, children: /* @__PURE__ */ t(
|
|
103
|
-
C,
|
|
104
|
-
{
|
|
105
|
-
block: !0,
|
|
106
|
-
icon: /* @__PURE__ */ t(v, {}),
|
|
107
|
-
htmlType: "button",
|
|
108
|
-
type: "default",
|
|
109
|
-
size: "large",
|
|
110
|
-
onClick: () => h(),
|
|
111
|
-
children: o("str.back")
|
|
112
|
-
}
|
|
113
|
-
) }),
|
|
114
|
-
/* @__PURE__ */ t(S, { md: e > 0 ? 12 : 24, children: /* @__PURE__ */ t(
|
|
115
|
-
C,
|
|
116
|
-
{
|
|
117
|
-
block: !0,
|
|
118
|
-
icon: m.length - 1 === e ? /* @__PURE__ */ t(w, {}) : /* @__PURE__ */ t(x, {}),
|
|
119
|
-
htmlType: "submit",
|
|
120
|
-
type: "primary",
|
|
121
|
-
loading: g,
|
|
122
|
-
size: "large",
|
|
123
|
-
onClick: () => {
|
|
124
|
-
r.validateFields().then((n) => {
|
|
125
|
-
s(
|
|
126
|
-
n,
|
|
127
|
-
m.length - 1 === e,
|
|
128
|
-
m.length - 1 === e
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
children: m.length - 1 === e ? o("str." + (l === "update" ? "update" : "save")) : o("str.next")
|
|
133
|
-
}
|
|
134
|
-
) })
|
|
135
|
-
] })
|
|
136
|
-
] });
|
|
137
|
-
}
|
|
138
|
-
export {
|
|
139
|
-
H as default
|
|
140
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),J=require("@ant-design/icons"),s=require("antd"),i=require("react"),j=require("./CrudField.cjs"),K=require("./view/CrudViewer.cjs"),v=require("../common/button/Button.cjs"),M=require("../common/button/PrintButton.cjs"),Q=require("../common/report/SelectFieldInReport.cjs"),W=require("../common/select/SelectComponent.cjs"),V=require("./view/CrudViewerUtil.cjs"),A={lg:6,md:8,sm:12,xs:24},X={lg:12,md:16,sm:24,xs:24};function Y({fields:d,data:u,idField:L,loadingData:p,onSubmit:x,paginateProps:G,size:O,onClickPrint:h,onClickExcelExport:y,minusHeight:U,extraSearchFields:R,searchOnMount:B,summary:_}){const{searchable:$,selectable:c,sortable:F,defaultSort:m}=i.useMemo(()=>{var b,f,N,T,I;const e=[],t=[],o=[];let a;for(const l of d.filter(H=>!H.hidden))l.type==="image"||!l.report||((b=l.report)!=null&&b.searchable&&e.push(l),(f=l.report)!=null&&f.sortable&&(t.push(l),!a&&((N=l.report)!=null&&N.defaultSort)&&(a=l)),l.hideInTable||o.push({id:l.name,label:l.label,lock:(T=l.report)==null?void 0:T.lock,alreadySelected:(I=l.report)==null?void 0:I.alreadySelected}));return{defaultSort:a,searchable:e,sortable:t,selectable:o}},[d]),[S,w]=i.useState([]),g=i.useCallback(async({sortBy:e,sortByType:t,showFields:o=[],...a})=>{const b=[];e&&b.push({field:e,sort:t??"DESC"}),w(d.filter(f=>o.includes(f.name)).map(f=>({...f,hideInTable:!1}))),x({showFields:o,sortBy:b,...a})},[d,x]),[n]=s.Form.useForm(),[q,z]=i.useState(!1),[C,D]=i.useState(!0);return i.useEffect(()=>{if(B&&C){const e=setTimeout(()=>{n.validateFields().then(t=>{g(t)}),D(!1)},200);return()=>clearTimeout(e)}},[g,n,C,B]),i.useEffect(()=>{var t,o,a;!n.getFieldValue("sortBy")&&m&&(console.log((t=m.report)==null?void 0:t.defaultSort),n.setFieldsValue({sortBy:m.name,sortByType:typeof((o=m.report)==null?void 0:o.defaultSort)=="string"?(a=m.report)==null?void 0:a.defaultSort:"ASC"}))},[m,n]),i.useEffect(()=>{if(q){const e=c.filter(t=>t.alreadySelected).map(t=>t.id);w(d.filter(t=>e.includes(t.name)).map(t=>({...t,hideInTable:!1}))),z(!1)}},[d,q,c]),r.jsx(r.Fragment,{children:r.jsxs(s.Space,{className:"w-100",direction:"vertical",children:[r.jsxs(s.Form,{form:n,layout:"vertical",onFinish:g,children:[r.jsxs(s.Row,{gutter:[8,8],children:[$.map(e=>{var t,o,a;return r.jsx(s.Col,{...e.grid??A,style:{alignSelf:"end"},children:(t=e.report)!=null&&t.customRender?e.report.customRender(n):e.type==="date"?r.jsx(j.default,{...e,type:"date",range:(o=e.report)==null?void 0:o.range,required:!!((a=e.report)!=null&&a.required),readonly:!1,fieldClassName:"mb-0"}):e.type==="select"?r.jsx(j.default,{...e,type:"select",multiple:!0,required:!1,readonly:!1,fieldClassName:"mb-0"}):r.jsx(j.default,{...e,readonly:!1,required:!1,fieldClassName:"mb-0"})},e.name)}),!!(c!=null&&c.length)&&r.jsx(s.Col,{...X,children:r.jsx(Q.SelectFieldInReport,{items:c,name:"showFields",mode:"multiple",label:"Show Fields",className:"mb-0"})}),!!F.length&&r.jsx(s.Col,{...A,children:r.jsx(W,{label:"Sort By",name:"sortBy",items:F.map(e=>({id:e.name,label:e.label})),nameFieldInArray:"label",fieldId:"id",className:"mb-0",dropdownRender:e=>r.jsxs(r.Fragment,{children:[e,r.jsx(s.Form.Item,{name:"sortByType",noStyle:!0,className:"mt-3",children:r.jsx(s.Radio.Group,{className:"w-100",defaultValue:"DESC",optionType:"button",children:r.jsxs(s.Row,{children:[r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopRightRadius:0,borderBottomRightRadius:0},value:"ASC",children:"Ascending"})}),r.jsx(s.Col,{xs:12,children:r.jsx(s.Radio,{className:"w-100",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},value:"DESC",children:"Descending"})})]})})})]})})}),R?R(n):null]}),r.jsx(v,{className:"mt-3",type:"primary",block:!0,htmlType:"submit",disabled:p,children:"Submit"})]}),r.jsxs(s.Space,{children:[!!h&&r.jsx(M.PrintButton,{disabled:p||!u.length,onClick:()=>h==null?void 0:h({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:V.getRendererValueCrudViewer(e)}))})}),!!y&&r.jsx(v,{disabled:p||!u.length,onClick:()=>y==null?void 0:y({tableId:"#crud-table table",data:u,fields:S.map(e=>({...e,render:V.getRendererValueCrudViewer(e)}))}),icon:r.jsx(J.FileExcelOutlined,{}),className:`group
|
|
2
|
-
${p||!u.length?"":"!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
|
|
3
|
-
|
|
4
|
-
`,children:"Excel"})]}),_,r.jsx(K,{minusHeight:U,data:u,size:O,fields:S,idField:L,loadingData:p,paginateProps:G,viewable:!1})]})})}module.exports=Y;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
2
|
-
import { FormInstance } from 'antd/lib';
|
|
3
|
-
import { default as React, ReactElement } from 'react';
|
|
4
|
-
import { CrudFieldProps, CrudPaginateProps } from './CrudComponent';
|
|
5
|
-
export type CrudReportSubmitForm<T> = {
|
|
6
|
-
sortBy: {
|
|
7
|
-
field: keyof T;
|
|
8
|
-
sort: "ASC" | "DESC";
|
|
9
|
-
}[];
|
|
10
|
-
showFields: string[];
|
|
11
|
-
} & T;
|
|
12
|
-
export type SearchOnlyFields<F> = CrudFieldProps<F> & {
|
|
13
|
-
hideInTable: true;
|
|
14
|
-
};
|
|
15
|
-
export type ReportCrudFields<T, F> = CrudFieldProps<T> | SearchOnlyFields<F>;
|
|
16
|
-
export interface CrudReportComponentProps<T_Data, F_Search> {
|
|
17
|
-
summary?: React.ReactNode;
|
|
18
|
-
fields: ReportCrudFields<T_Data, F_Search>[];
|
|
19
|
-
onSubmit: (value: CrudReportSubmitForm<F_Search>) => void;
|
|
20
|
-
data: T_Data[];
|
|
21
|
-
idField?: string;
|
|
22
|
-
loadingData?: boolean;
|
|
23
|
-
size?: SizeType;
|
|
24
|
-
paginateProps?: CrudPaginateProps;
|
|
25
|
-
onClickPrint?: (props: {
|
|
26
|
-
fields: CrudFieldProps<T_Data>[] & {
|
|
27
|
-
render: (value: any, obj: T_Data, index: number) => any;
|
|
28
|
-
}[];
|
|
29
|
-
data: T_Data[];
|
|
30
|
-
tableId: string;
|
|
31
|
-
}) => void;
|
|
32
|
-
onClickExcelExport?: (props: {
|
|
33
|
-
fields: CrudFieldProps<T_Data>[] & {
|
|
34
|
-
render: (value: any, obj: T_Data, index: number) => any;
|
|
35
|
-
}[];
|
|
36
|
-
data: T_Data[];
|
|
37
|
-
tableId: string;
|
|
38
|
-
}) => void;
|
|
39
|
-
minusHeight?: string;
|
|
40
|
-
extraSearchFields?: (form: FormInstance<any>) => ReactElement;
|
|
41
|
-
searchOnMount?: boolean;
|
|
42
|
-
}
|
|
43
|
-
declare function CrudReportComponent<T, F = T>({ fields, data, idField, loadingData, onSubmit, paginateProps, size, onClickPrint, onClickExcelExport, minusHeight, extraSearchFields, searchOnMount, summary, }: CrudReportComponentProps<T, F>): import("react/jsx-runtime").JSX.Element;
|
|
44
|
-
export default CrudReportComponent;
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { jsx as t, Fragment as O, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { FileExcelOutlined as x } from "@ant-design/icons";
|
|
3
|
-
import { Form as B, Space as _, Row as $, Col as b, Radio as R } from "antd";
|
|
4
|
-
import { useMemo as k, useState as w, useCallback as E, useEffect as F } from "react";
|
|
5
|
-
import N from "./CrudField.js";
|
|
6
|
-
import P from "./view/CrudViewer.js";
|
|
7
|
-
import z from "../common/button/Button.js";
|
|
8
|
-
import { PrintButton as ee } from "../common/button/PrintButton.js";
|
|
9
|
-
import { SelectFieldInReport as re } from "../common/report/SelectFieldInReport.js";
|
|
10
|
-
import te from "../common/select/SelectComponent.js";
|
|
11
|
-
import { getRendererValueCrudViewer as D } from "./view/CrudViewerUtil.js";
|
|
12
|
-
const H = { lg: 6, md: 8, sm: 12, xs: 24 }, le = { lg: 12, md: 16, sm: 24, xs: 24 };
|
|
13
|
-
function be({
|
|
14
|
-
fields: n,
|
|
15
|
-
data: d,
|
|
16
|
-
idField: J,
|
|
17
|
-
loadingData: p,
|
|
18
|
-
onSubmit: T,
|
|
19
|
-
paginateProps: K,
|
|
20
|
-
size: M,
|
|
21
|
-
onClickPrint: h,
|
|
22
|
-
onClickExcelExport: y,
|
|
23
|
-
minusHeight: Q,
|
|
24
|
-
extraSearchFields: v,
|
|
25
|
-
searchOnMount: C,
|
|
26
|
-
summary: U
|
|
27
|
-
}) {
|
|
28
|
-
const { searchable: W, selectable: i, sortable: I, defaultSort: m } = k(() => {
|
|
29
|
-
var f, u, j, L, G;
|
|
30
|
-
const e = [], r = [], o = [];
|
|
31
|
-
let s;
|
|
32
|
-
for (const l of n.filter((Z) => !Z.hidden))
|
|
33
|
-
l.type === "image" || !l.report || ((f = l.report) != null && f.searchable && e.push(l), (u = l.report) != null && u.sortable && (r.push(l), !s && ((j = l.report) != null && j.defaultSort) && (s = l)), l.hideInTable || o.push({
|
|
34
|
-
id: l.name,
|
|
35
|
-
label: l.label,
|
|
36
|
-
lock: (L = l.report) == null ? void 0 : L.lock,
|
|
37
|
-
alreadySelected: (G = l.report) == null ? void 0 : G.alreadySelected
|
|
38
|
-
}));
|
|
39
|
-
return {
|
|
40
|
-
defaultSort: s,
|
|
41
|
-
searchable: e,
|
|
42
|
-
sortable: r,
|
|
43
|
-
selectable: o
|
|
44
|
-
};
|
|
45
|
-
}, [n]), [g, V] = w(
|
|
46
|
-
[]
|
|
47
|
-
), S = E(
|
|
48
|
-
async ({
|
|
49
|
-
sortBy: e,
|
|
50
|
-
sortByType: r,
|
|
51
|
-
showFields: o = [],
|
|
52
|
-
...s
|
|
53
|
-
}) => {
|
|
54
|
-
const f = [];
|
|
55
|
-
e && f.push({
|
|
56
|
-
field: e,
|
|
57
|
-
sort: r ?? "DESC"
|
|
58
|
-
}), V(
|
|
59
|
-
n.filter((u) => o.includes(u.name)).map((u) => ({ ...u, hideInTable: !1 }))
|
|
60
|
-
), T({ showFields: o, sortBy: f, ...s });
|
|
61
|
-
},
|
|
62
|
-
[n, T]
|
|
63
|
-
), [a] = B.useForm(), [q, X] = w(!1), [A, Y] = w(!0);
|
|
64
|
-
return F(() => {
|
|
65
|
-
if (C && A) {
|
|
66
|
-
const e = setTimeout(() => {
|
|
67
|
-
a.validateFields().then((r) => {
|
|
68
|
-
S(r);
|
|
69
|
-
}), Y(!1);
|
|
70
|
-
}, 200);
|
|
71
|
-
return () => clearTimeout(e);
|
|
72
|
-
}
|
|
73
|
-
}, [S, a, A, C]), F(() => {
|
|
74
|
-
var r, o, s;
|
|
75
|
-
!a.getFieldValue("sortBy") && m && (console.log((r = m.report) == null ? void 0 : r.defaultSort), a.setFieldsValue({
|
|
76
|
-
sortBy: m.name,
|
|
77
|
-
sortByType: typeof ((o = m.report) == null ? void 0 : o.defaultSort) == "string" ? (s = m.report) == null ? void 0 : s.defaultSort : "ASC"
|
|
78
|
-
}));
|
|
79
|
-
}, [m, a]), F(() => {
|
|
80
|
-
if (q) {
|
|
81
|
-
const e = i.filter((r) => r.alreadySelected).map((r) => r.id);
|
|
82
|
-
V(
|
|
83
|
-
n.filter((r) => e.includes(r.name)).map((r) => ({ ...r, hideInTable: !1 }))
|
|
84
|
-
), X(!1);
|
|
85
|
-
}
|
|
86
|
-
}, [n, q, i]), /* @__PURE__ */ t(O, { children: /* @__PURE__ */ c(_, { className: "w-100", direction: "vertical", children: [
|
|
87
|
-
/* @__PURE__ */ c(B, { form: a, layout: "vertical", onFinish: S, children: [
|
|
88
|
-
/* @__PURE__ */ c($, { gutter: [8, 8], children: [
|
|
89
|
-
W.map((e) => {
|
|
90
|
-
var r, o, s;
|
|
91
|
-
return /* @__PURE__ */ t(
|
|
92
|
-
b,
|
|
93
|
-
{
|
|
94
|
-
...e.grid ?? H,
|
|
95
|
-
style: { alignSelf: "end" },
|
|
96
|
-
children: (r = e.report) != null && r.customRender ? e.report.customRender(a) : e.type === "date" ? /* @__PURE__ */ t(
|
|
97
|
-
N,
|
|
98
|
-
{
|
|
99
|
-
...e,
|
|
100
|
-
type: "date",
|
|
101
|
-
range: (o = e.report) == null ? void 0 : o.range,
|
|
102
|
-
required: !!((s = e.report) != null && s.required),
|
|
103
|
-
readonly: !1,
|
|
104
|
-
fieldClassName: "mb-0"
|
|
105
|
-
}
|
|
106
|
-
) : e.type === "select" ? /* @__PURE__ */ t(
|
|
107
|
-
N,
|
|
108
|
-
{
|
|
109
|
-
...e,
|
|
110
|
-
type: "select",
|
|
111
|
-
multiple: !0,
|
|
112
|
-
required: !1,
|
|
113
|
-
readonly: !1,
|
|
114
|
-
fieldClassName: "mb-0"
|
|
115
|
-
}
|
|
116
|
-
) : /* @__PURE__ */ t(
|
|
117
|
-
N,
|
|
118
|
-
{
|
|
119
|
-
...e,
|
|
120
|
-
readonly: !1,
|
|
121
|
-
required: !1,
|
|
122
|
-
fieldClassName: "mb-0"
|
|
123
|
-
}
|
|
124
|
-
)
|
|
125
|
-
},
|
|
126
|
-
e.name
|
|
127
|
-
);
|
|
128
|
-
}),
|
|
129
|
-
!!(i != null && i.length) && /* @__PURE__ */ t(b, { ...le, children: /* @__PURE__ */ t(
|
|
130
|
-
re,
|
|
131
|
-
{
|
|
132
|
-
items: i,
|
|
133
|
-
name: "showFields",
|
|
134
|
-
mode: "multiple",
|
|
135
|
-
label: "Show Fields",
|
|
136
|
-
className: "mb-0"
|
|
137
|
-
}
|
|
138
|
-
) }),
|
|
139
|
-
!!I.length && /* @__PURE__ */ t(b, { ...H, children: /* @__PURE__ */ t(
|
|
140
|
-
te,
|
|
141
|
-
{
|
|
142
|
-
label: "Sort By",
|
|
143
|
-
name: "sortBy",
|
|
144
|
-
items: I.map((e) => ({ id: e.name, label: e.label })),
|
|
145
|
-
nameFieldInArray: "label",
|
|
146
|
-
fieldId: "id",
|
|
147
|
-
className: "mb-0",
|
|
148
|
-
dropdownRender: (e) => /* @__PURE__ */ c(O, { children: [
|
|
149
|
-
e,
|
|
150
|
-
/* @__PURE__ */ t(B.Item, { name: "sortByType", noStyle: !0, className: "mt-3", children: /* @__PURE__ */ t(
|
|
151
|
-
R.Group,
|
|
152
|
-
{
|
|
153
|
-
className: "w-100",
|
|
154
|
-
defaultValue: "DESC",
|
|
155
|
-
optionType: "button",
|
|
156
|
-
children: /* @__PURE__ */ c($, { children: [
|
|
157
|
-
/* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
|
|
158
|
-
R,
|
|
159
|
-
{
|
|
160
|
-
className: "w-100",
|
|
161
|
-
style: {
|
|
162
|
-
borderTopRightRadius: 0,
|
|
163
|
-
borderBottomRightRadius: 0
|
|
164
|
-
},
|
|
165
|
-
value: "ASC",
|
|
166
|
-
children: "Ascending"
|
|
167
|
-
}
|
|
168
|
-
) }),
|
|
169
|
-
/* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
|
|
170
|
-
R,
|
|
171
|
-
{
|
|
172
|
-
className: "w-100",
|
|
173
|
-
style: {
|
|
174
|
-
borderTopLeftRadius: 0,
|
|
175
|
-
borderBottomLeftRadius: 0
|
|
176
|
-
},
|
|
177
|
-
value: "DESC",
|
|
178
|
-
children: "Descending"
|
|
179
|
-
}
|
|
180
|
-
) })
|
|
181
|
-
] })
|
|
182
|
-
}
|
|
183
|
-
) })
|
|
184
|
-
] })
|
|
185
|
-
}
|
|
186
|
-
) }),
|
|
187
|
-
v ? v(a) : null
|
|
188
|
-
] }),
|
|
189
|
-
/* @__PURE__ */ t(
|
|
190
|
-
z,
|
|
191
|
-
{
|
|
192
|
-
className: "mt-3",
|
|
193
|
-
type: "primary",
|
|
194
|
-
block: !0,
|
|
195
|
-
htmlType: "submit",
|
|
196
|
-
disabled: p,
|
|
197
|
-
children: "Submit"
|
|
198
|
-
}
|
|
199
|
-
)
|
|
200
|
-
] }),
|
|
201
|
-
/* @__PURE__ */ c(_, { children: [
|
|
202
|
-
!!h && /* @__PURE__ */ t(
|
|
203
|
-
ee,
|
|
204
|
-
{
|
|
205
|
-
disabled: p || !d.length,
|
|
206
|
-
onClick: () => h == null ? void 0 : h({
|
|
207
|
-
tableId: "#crud-table table",
|
|
208
|
-
data: d,
|
|
209
|
-
fields: g.map((e) => ({
|
|
210
|
-
...e,
|
|
211
|
-
render: D(e)
|
|
212
|
-
}))
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
),
|
|
216
|
-
!!y && /* @__PURE__ */ t(
|
|
217
|
-
z,
|
|
218
|
-
{
|
|
219
|
-
disabled: p || !d.length,
|
|
220
|
-
onClick: () => y == null ? void 0 : y({
|
|
221
|
-
tableId: "#crud-table table",
|
|
222
|
-
data: d,
|
|
223
|
-
fields: g.map((e) => ({
|
|
224
|
-
...e,
|
|
225
|
-
render: D(e)
|
|
226
|
-
}))
|
|
227
|
-
}),
|
|
228
|
-
icon: /* @__PURE__ */ t(x, {}),
|
|
229
|
-
className: `group
|
|
230
|
-
${p || !d.length ? "" : "!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
|
|
231
|
-
|
|
232
|
-
`,
|
|
233
|
-
children: "Excel"
|
|
234
|
-
}
|
|
235
|
-
)
|
|
236
|
-
] }),
|
|
237
|
-
U,
|
|
238
|
-
/* @__PURE__ */ t(
|
|
239
|
-
P,
|
|
240
|
-
{
|
|
241
|
-
minusHeight: Q,
|
|
242
|
-
data: d,
|
|
243
|
-
size: M,
|
|
244
|
-
fields: g,
|
|
245
|
-
idField: J,
|
|
246
|
-
loadingData: p,
|
|
247
|
-
paginateProps: K,
|
|
248
|
-
viewable: !1
|
|
249
|
-
}
|
|
250
|
-
)
|
|
251
|
-
] }) });
|
|
252
|
-
}
|
|
253
|
-
export {
|
|
254
|
-
be as default
|
|
255
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),o=require("react"),w=require("@ant-design/icons"),f=require("antd"),M=require("./CrudField.cjs"),N=require("../common/button/Button.cjs");function a({searchFields:t=[],fields:b,searchOnChange:x,onSearch:g,searchDefaultValues:m,searchFieldsCustomColumnProps:r}){const p=o.useMemo(()=>t.map(n=>typeof n=="string"?{...b.find(c=>n===c.name),required:!1}:{...b.find(i=>(n==null?void 0:n.name)===i.name),...n}).filter(n=>n&&!(n!=null&&n.hidden)),[t,b]),y=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),j=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),q=o.useMemo(()=>t.length===1?{field:21,button:3}:t.length===2?{field:11,button:2}:t.length===3?{field:24,button:24}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),[u]=f.Form.useForm(),d=o.useCallback(async n=>{if((n||x)&&g){const l=await u.validateFields();g(l)}},[u,g,x]);return o.useEffect(()=>{m&&(u.setFieldsValue(m),d(!0))},[u,m]),t!=null&&t.length?e.jsx(f.Form,{form:u,onFinish:()=>d(!0),layout:"vertical",className:"mb-2",onChange:()=>d(!1),children:e.jsxs(f.Row,{gutter:[4,8],className:"w-100",children:[p.map((n,l)=>{const i=(r==null?void 0:r[l])??{md:y.field,sm:j.field,xs:q.field};return o.createElement(f.Col,{...i,key:`search_field_${String(n.name)}`,className:"align-self-end"},e.jsx(M.default,{...n,readonly:!1,fieldClassName:"mb-0"}))}),e.jsx(f.Col,{md:y.button,sm:j.button,xs:q.button,style:{alignSelf:"end"},children:e.jsx(N,{type:"primary",htmlType:"submit",block:!0,icon:e.jsx(w.SearchOutlined,{})})})]})}):e.jsx(e.Fragment,{})}module.exports=a;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ColProps } from 'antd/lib';
|
|
2
|
-
import { CrudFieldProps } from './CrudComponent';
|
|
3
|
-
export type CrudSearchOption<T> = {
|
|
4
|
-
required?: boolean;
|
|
5
|
-
} & ({
|
|
6
|
-
type: "text";
|
|
7
|
-
name: keyof T;
|
|
8
|
-
} | {
|
|
9
|
-
type: "select";
|
|
10
|
-
name: keyof T;
|
|
11
|
-
multiple?: boolean;
|
|
12
|
-
});
|
|
13
|
-
export interface CrudSearchComponentProps<T, FormType> {
|
|
14
|
-
searchFields?: Array<keyof T | CrudSearchOption<T>>;
|
|
15
|
-
fields: CrudFieldProps<T>[];
|
|
16
|
-
searchOnChange?: boolean;
|
|
17
|
-
searchDefaultValues?: FormType;
|
|
18
|
-
onSearch?: (values: Partial<FormType>) => void;
|
|
19
|
-
searchFieldsCustomColumnProps?: ColProps[];
|
|
20
|
-
}
|
|
21
|
-
export default function CrudSearchComponent<T, FormType>({ searchFields, fields, searchOnChange, onSearch, searchDefaultValues, searchFieldsCustomColumnProps, }: CrudSearchComponentProps<T, FormType>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { jsx as o, Fragment as j, jsxs as v } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as u, useCallback as E, useEffect as S, createElement as _ } from "react";
|
|
3
|
-
import { SearchOutlined as q } from "@ant-design/icons";
|
|
4
|
-
import { Form as w, Row as B, Col as N } from "antd";
|
|
5
|
-
import M from "./CrudField.js";
|
|
6
|
-
import R from "../common/button/Button.js";
|
|
7
|
-
function I({
|
|
8
|
-
searchFields: t = [],
|
|
9
|
-
fields: e,
|
|
10
|
-
searchOnChange: p,
|
|
11
|
-
onSearch: b,
|
|
12
|
-
searchDefaultValues: g,
|
|
13
|
-
searchFieldsCustomColumnProps: i
|
|
14
|
-
}) {
|
|
15
|
-
const k = u(
|
|
16
|
-
() => t.map((n) => typeof n == "string" ? {
|
|
17
|
-
...e.find((a) => n === a.name),
|
|
18
|
-
required: !1
|
|
19
|
-
} : {
|
|
20
|
-
...e.find(
|
|
21
|
-
(l) => (n == null ? void 0 : n.name) === l.name
|
|
22
|
-
),
|
|
23
|
-
...n
|
|
24
|
-
}).filter((n) => n && !(n != null && n.hidden)),
|
|
25
|
-
[t, e]
|
|
26
|
-
), d = u(
|
|
27
|
-
() => t.length === 1 ? { field: 22, button: 2 } : t.length === 2 ? { field: 11, button: 2 } : t.length === 3 ? { field: 6, button: 6 } : t.length === 4 ? { field: 5, button: 4 } : t.length === 5 ? { field: 4, button: 4 } : { field: 4, button: 4 },
|
|
28
|
-
[t.length]
|
|
29
|
-
), y = u(
|
|
30
|
-
() => t.length === 1 ? { field: 22, button: 2 } : t.length === 2 ? { field: 11, button: 2 } : t.length === 3 ? { field: 6, button: 6 } : t.length === 4 ? { field: 5, button: 4 } : t.length === 5 ? { field: 4, button: 4 } : { field: 4, button: 4 },
|
|
31
|
-
[t.length]
|
|
32
|
-
), x = u(
|
|
33
|
-
() => t.length === 1 ? { field: 21, button: 3 } : t.length === 2 ? { field: 11, button: 2 } : t.length === 3 ? { field: 24, button: 24 } : t.length === 4 ? { field: 5, button: 4 } : t.length === 5 ? { field: 4, button: 4 } : { field: 4, button: 4 },
|
|
34
|
-
[t.length]
|
|
35
|
-
), [f] = w.useForm(), r = E(
|
|
36
|
-
async (n) => {
|
|
37
|
-
if ((n || p) && b) {
|
|
38
|
-
const m = await f.validateFields();
|
|
39
|
-
b(m);
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
[f, b, p]
|
|
43
|
-
);
|
|
44
|
-
return S(() => {
|
|
45
|
-
g && (f.setFieldsValue(g), r(!0));
|
|
46
|
-
}, [f, g]), t != null && t.length ? /* @__PURE__ */ o(
|
|
47
|
-
w,
|
|
48
|
-
{
|
|
49
|
-
form: f,
|
|
50
|
-
onFinish: () => r(!0),
|
|
51
|
-
layout: "vertical",
|
|
52
|
-
className: "mb-2",
|
|
53
|
-
onChange: () => r(!1),
|
|
54
|
-
children: /* @__PURE__ */ v(B, { gutter: [4, 8], className: "w-100", children: [
|
|
55
|
-
k.map((n, m) => {
|
|
56
|
-
const l = (i == null ? void 0 : i[m]) ?? {
|
|
57
|
-
md: d.field,
|
|
58
|
-
sm: y.field,
|
|
59
|
-
xs: x.field
|
|
60
|
-
};
|
|
61
|
-
return /* @__PURE__ */ _(
|
|
62
|
-
N,
|
|
63
|
-
{
|
|
64
|
-
...l,
|
|
65
|
-
key: `search_field_${String(n.name)}`,
|
|
66
|
-
className: "align-self-end"
|
|
67
|
-
},
|
|
68
|
-
/* @__PURE__ */ o(M, { ...n, readonly: !1, fieldClassName: "mb-0" })
|
|
69
|
-
);
|
|
70
|
-
}),
|
|
71
|
-
/* @__PURE__ */ o(
|
|
72
|
-
N,
|
|
73
|
-
{
|
|
74
|
-
md: d.button,
|
|
75
|
-
sm: y.button,
|
|
76
|
-
xs: x.button,
|
|
77
|
-
style: { alignSelf: "end" },
|
|
78
|
-
children: /* @__PURE__ */ o(
|
|
79
|
-
R,
|
|
80
|
-
{
|
|
81
|
-
type: "primary",
|
|
82
|
-
htmlType: "submit",
|
|
83
|
-
block: !0,
|
|
84
|
-
icon: /* @__PURE__ */ o(q, {})
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
)
|
|
89
|
-
] })
|
|
90
|
-
}
|
|
91
|
-
) : /* @__PURE__ */ o(j, {});
|
|
92
|
-
}
|
|
93
|
-
export {
|
|
94
|
-
I as default
|
|
95
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime");;/* empty css */const d=require("@ant-design/icons"),F=require("antd"),A=require("mime"),c=require("react"),B=require("react-i18next"),H=require("../../locale/hooks/translation-constants.cjs"),z=require("../../util/ValidationUtil.cjs"),P=require("../common/button/Button.cjs"),G=require("../common/layout/VerticalSpace.cjs");function J({name:n,label:e,required:l,provider:s,onUploading:a,onRemoved:h,fieldClassName:j,accept:p,rules:N,maxCount:O=1,block:k,...U}){const f=F.Form.useFormInstance(),x=F.Form.useWatch(n,f),[q,S]=c.useState(!1),[b,_]=c.useState(!1),$=c.useCallback(async r=>{var i,u;try{const{file:o}=r,g=o.name;S(!0),_(!0),a==null||a(!0);const C=g??"",V=C.split("."),L=V[V.length-1],W=s.generateFileName(C),M=`${await s.getInitialPath()}/${W}.${L}`;console.log({filePath:M});const E=await s.upload({...o,originFileObj:o},M);a==null||a(!1),f.setFieldValue(n,E),(i=r.onSuccess)==null||i.call(r,E)}catch(o){(u=r.onError)==null||u.call(r,o)}finally{S(!1)}},[f,n,a,s]),[w,I]=c.useState([]);c.useEffect(()=>{!b&&x&&Promise.all((Array.isArray(x)?x:[x]).map(async r=>{const i=A.getType(r),u=r.split("/").pop(),o=await s.getRealUrl(r);return{uid:r,url:o,type:i,name:u}})).then(r=>I(()=>{const i=r.map(({url:u,type:o,uid:g,name:C})=>({uid:g,url:u,type:o,response:g,thumbUrl:u,name:C}));return console.log(i),i}))},[x,b,q,s]);const R=c.useCallback(async r=>{const i=r.response,u=i||f.getFieldValue(n);await s.delete(u),h==null||h(),r&&f.setFieldsValue({[n]:null})},[f,n,h,s]);return t.jsxs(F.Form.Item,{label:e,required:l,name:n,className:j,rules:[...l?z.required(e):[],...N??[]],children:[t.jsx("input",{hidden:!0}),t.jsx(F.Upload,{...U,fileList:w,className:((w==null?void 0:w.length)??0)>=O?"hide-upload":"",maxCount:O,customRequest:$,onRemove:R,listType:"picture",onChange:({fileList:r})=>{I(r)},style:k?{width:"100%"}:void 0,children:t.jsx(P,{loading:q,children:"Upload File"})})]})}const K=({provider:n,value:e})=>{const[l,s]=c.useState();return c.useEffect(()=>{e&&n.getRealUrl(e).then(a=>{s({mimeType:A.getType(e),url:a,fileName:e.split("/").pop()??e})})},[n,e]),l?t.jsx(D,{fileName:l.fileName,url:l==null?void 0:l.url,mimeType:l==null?void 0:l.mimeType}):t.jsx(t.Fragment,{})},D=({url:n,mimeType:e="",fileName:l})=>{const s=c.useMemo(()=>e!=null&&e.includes("image")?"image":e!=null&&e.includes("pdf")?"pdf":e!=null&&e.includes("word")?"word":e!=null&&e.includes("text")?"text":e!=null&&e.includes("presentation")?"presentation":e!=null&&e.includes("excel")||e!=null&&e.includes("spreadsheet")?"excel":"file",[e]),a=c.useMemo(()=>{switch(s){case"image":return t.jsx(d.FileImageOutlined,{});case"pdf":return t.jsx(d.FilePdfOutlined,{});case"word":return t.jsx(d.FileWordOutlined,{});case"text":return t.jsx(d.FileTextOutlined,{});case"excel":return t.jsx(d.FileExcelOutlined,{});case"presentation":return t.jsx(d.FilePptOutlined,{});default:return t.jsx(d.FileOutlined,{})}},[s]),[h,j]=c.useState(!1),{t:p}=B.useTranslation(H.TRANSLATION_NAMESPACE);return s!=="file"&&s!=="text"?t.jsxs(t.Fragment,{children:[t.jsx(F.Modal,{open:h,title:l,onCancel:()=>j(!1),footer:t.jsx(t.Fragment,{}),width:"100%",style:{top:"8px",minHeight:"700px"},destroyOnClose:!0,children:t.jsxs(G,{children:[t.jsx(P,{tooltip:l,icon:t.jsx(d.ExportOutlined,{}),target:"_blank",href:n,style:{textDecoration:"none"},children:p("str.openInNewTab")}),s==="image"?t.jsx("img",{src:n,alt:l,style:{width:"100%"}}):s==="pdf"?t.jsxs("iframe",{title:l,src:n,width:"100%",height:"700px",children:["This browser does not support PDFs. Please download the PDF to view it:",t.jsx("a",{href:n,children:"Download PDF"}),"."]}):t.jsxs("iframe",{title:l,src:`https://view.officeapps.live.com/op/view.aspx?src=${encodeURIComponent(n)}`,width:"100%",height:"700px",children:["This browser does not support open ",s.toUpperCase(),". Please download the",s.toUpperCase()," to view it:",t.jsxs("a",{href:n,children:["Download ",s.toUpperCase()]}),"."]})]})}),t.jsx(P,{tooltip:l,icon:a,shape:"circle",onClick:()=>j(!0)})]}):t.jsx(P,{tooltip:l,icon:a,target:"_blank",href:n,shape:"circle"})};exports.FileCellValue=D;exports.FileCrudCellValue=K;exports.default=J;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { InitialCrudField } from './CrudComponent';
|
|
3
|
-
import { FileDownloadProvider, FileUploadProvider } from './ImageCrudField';
|
|
4
|
-
export interface FileCrudField<T> extends _FileCrudField<T> {
|
|
5
|
-
type: "file";
|
|
6
|
-
}
|
|
7
|
-
export interface _FileCrudField<T> extends InitialCrudField<T> {
|
|
8
|
-
provider: FileUploadProvider;
|
|
9
|
-
onUploading?: (isUploading: boolean) => void;
|
|
10
|
-
onRemoved?: () => void;
|
|
11
|
-
fieldClassName?: string;
|
|
12
|
-
accept?: string;
|
|
13
|
-
maxCount?: number;
|
|
14
|
-
block?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export default function FileCrudFieldComponent<T>({ name, label, required, provider, onUploading, onRemoved, fieldClassName, accept, rules, maxCount, block, ...props }: _FileCrudField<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
export declare const FileCrudCellValue: FC<{
|
|
18
|
-
value: string;
|
|
19
|
-
provider: FileDownloadProvider;
|
|
20
|
-
}>;
|
|
21
|
-
export declare const FileCellValue: FC<{
|
|
22
|
-
url: string;
|
|
23
|
-
mimeType?: string | null;
|
|
24
|
-
fileName: string;
|
|
25
|
-
}>;
|