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