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