@kingteza/crud-component 1.0.13 → 1.0.15
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/components/common/DatePicker/DatePicker.cjs +1 -0
- package/dist/components/common/DatePicker/DatePicker.js +88 -0
- package/dist/components/common/DatePicker/TimePicker.cjs +1 -0
- package/dist/components/common/DatePicker/TimePicker.js +78 -0
- package/dist/components/common/appearance/Hider.cjs +1 -0
- package/dist/components/common/appearance/Hider.js +5 -0
- package/dist/components/common/button/Button.cjs +1 -0
- package/dist/components/common/button/Button.js +64 -0
- package/dist/components/common/button/CloneButtonTable.cjs +1 -0
- package/dist/components/common/button/CloneButtonTable.js +20 -0
- package/dist/components/common/button/DeleteButtonTable.cjs +1 -0
- package/dist/components/common/button/DeleteButtonTable.js +68 -0
- package/dist/components/common/button/ExportButton.cjs +1 -0
- package/dist/components/common/button/ExportButton.js +27 -0
- package/dist/components/common/button/HideButtonTable.cjs +1 -0
- package/dist/components/common/button/HideButtonTable.js +68 -0
- package/dist/components/common/button/ImportButton.cjs +1 -0
- package/dist/components/common/button/ImportButton.js +56 -0
- package/dist/components/common/button/NewButton.cjs +1 -0
- package/dist/components/common/button/NewButton.js +24 -0
- package/dist/components/common/button/PrintButton.cjs +1 -0
- package/dist/components/common/button/PrintButton.js +26 -0
- package/dist/components/common/button/RefreshButton.cjs +1 -0
- package/dist/components/common/button/RefreshButton.js +24 -0
- package/dist/components/common/button/UnHideButton.cjs +1 -0
- package/dist/components/common/button/UnHideButton.js +70 -0
- package/dist/components/common/button/UpdateButtonTable.cjs +1 -0
- package/dist/components/common/button/UpdateButtonTable.js +20 -0
- package/dist/components/common/button/ViewButtonTable.cjs +1 -0
- package/dist/components/common/button/ViewButtonTable.js +20 -0
- package/dist/components/common/check-box/CheckBox.cjs +1 -0
- package/dist/components/common/check-box/CheckBox.js +40 -0
- package/dist/components/common/description/DescList.cjs +1 -0
- package/dist/components/common/description/DescList.js +16 -0
- package/dist/components/common/layout/VerticalSpace.cjs +1 -0
- package/dist/components/common/layout/VerticalSpace.js +6 -0
- package/dist/components/common/loading/LoadingIndicator.cjs +1 -0
- package/dist/components/common/loading/LoadingIndicator.js +24 -0
- package/dist/components/common/picker/ImagePicker.cjs +1 -0
- package/dist/components/common/picker/ImagePicker.js +282 -0
- package/dist/components/common/radio/RadioGroupComponent.cjs +1 -0
- package/dist/components/common/radio/RadioGroupComponent.js +19 -0
- package/dist/components/common/report/SelectFieldInReport.cjs +1 -0
- package/dist/components/common/report/SelectFieldInReport.js +30 -0
- package/dist/components/common/select/CustomSelectOption.cjs +1 -0
- package/dist/components/common/select/CustomSelectOption.js +13 -0
- package/dist/components/common/select/SelectComponent.cjs +1 -0
- package/dist/components/common/select/SelectComponent.js +89 -0
- package/dist/components/common/show-more/index.cjs +1 -0
- package/dist/components/common/show-more/index.js +8 -0
- package/dist/components/common/tab/TabViewWithRoute.cjs +1 -0
- package/dist/components/common/tab/TabViewWithRoute.js +38 -0
- package/dist/components/common/table/table.cjs +1 -0
- package/dist/components/common/table/table.js +40 -0
- package/dist/components/common/tag/StatusTag.cjs +1 -0
- package/dist/components/common/tag/StatusTag.js +30 -0
- package/dist/components/common/text/index.cjs +1 -0
- package/dist/components/common/text/index.js +5 -0
- package/dist/components/common/text/title/index.cjs +1 -0
- package/dist/components/common/text/title/index.js +5 -0
- package/dist/components/common/text-field/NumberField.cjs +1 -0
- package/dist/components/common/text-field/NumberField.js +83 -0
- package/dist/components/common/text-field/PhoneNumberField.cjs +1 -0
- package/dist/components/common/text-field/PhoneNumberField.js +18 -0
- package/dist/components/common/text-field/TextArea.cjs +1 -0
- package/dist/components/common/text-field/TextArea.js +47 -0
- package/dist/components/common/text-field/TextField.cjs +1 -0
- package/dist/components/common/text-field/TextField.js +73 -0
- package/dist/components/common/tooltip/TooltipComponent.cjs +1 -0
- package/dist/components/common/tooltip/TooltipComponent.js +9 -0
- package/dist/components/common/wizard/WizardResult.cjs +1 -0
- package/dist/components/common/wizard/WizardResult.js +60 -0
- package/dist/components/common/wizard/WizardViewForm.cjs +1 -0
- package/dist/components/common/wizard/WizardViewForm.js +74 -0
- package/dist/components/crud/CrudComponent.cjs +1 -0
- package/dist/components/crud/CrudComponent.js +210 -0
- package/dist/components/crud/CrudField.cjs +1 -0
- package/dist/components/crud/CrudField.js +459 -0
- package/dist/components/crud/CrudForm.cjs +1 -0
- package/dist/components/crud/CrudForm.js +91 -0
- package/dist/components/crud/CrudFormWizard.cjs +1 -0
- package/dist/components/crud/CrudFormWizard.js +140 -0
- package/dist/components/crud/CrudReportComponent.cjs +4 -0
- package/dist/components/crud/CrudReportComponent.js +255 -0
- package/dist/components/crud/CrudSearchComponent.cjs +1 -0
- package/dist/components/crud/CrudSearchComponent.js +95 -0
- package/dist/components/crud/FileCrudField.cjs +1 -0
- package/dist/components/crud/FileCrudField.js +220 -0
- package/dist/components/crud/ImageCrudField.cjs +1 -0
- package/dist/components/crud/ImageCrudField.js +113 -0
- package/dist/components/crud/import/CrudImportButton.cjs +1 -0
- package/dist/components/crud/import/CrudImportButton.js +31 -0
- package/dist/components/crud/import/CrudImportComponent.cjs +2 -0
- package/dist/components/crud/import/CrudImportComponent.js +221 -0
- package/dist/components/crud/view/CrudDecListView.cjs +1 -0
- package/dist/components/crud/view/CrudDecListView.js +42 -0
- package/dist/components/crud/view/CrudViewer.cjs +1 -0
- package/dist/components/crud/view/CrudViewer.js +217 -0
- package/dist/components/crud/view/CrudViewerUtil.cjs +1 -0
- package/dist/components/crud/view/CrudViewerUtil.js +57 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +10 -10
- package/dist/locale/hooks/translation-constants.cjs +1 -0
- package/dist/locale/hooks/translation-constants.js +4 -0
- package/dist/locale/index.cjs +1 -0
- package/dist/locale/index.js +33 -0
- package/dist/locale/translations/en.cjs +1 -0
- package/dist/locale/translations/en.js +60 -0
- package/dist/util/DateUtil.cjs +1 -0
- package/dist/util/DateUtil.js +6 -0
- package/dist/util/ImageUtil.cjs +1 -0
- package/dist/util/ImageUtil.js +63 -0
- package/dist/util/NumberUtil.cjs +1 -0
- package/dist/util/NumberUtil.js +60 -0
- package/dist/util/ValidationUtil.cjs +1 -0
- package/dist/util/ValidationUtil.js +60 -0
- package/dist/util/index.cjs +1 -1
- package/dist/util/index.js +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { jsx as d, Fragment as m, jsxs as g } from "react/jsx-runtime";
|
|
2
|
+
import A, { useMemo as C, createElement as f, useCallback as k } from "react";
|
|
3
|
+
import { Form as p, Col as S, Input as h, Row as j } from "antd";
|
|
4
|
+
import s from "./CrudField.js";
|
|
5
|
+
function x({
|
|
6
|
+
form: e,
|
|
7
|
+
purpose: c = "new",
|
|
8
|
+
...i
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ d(m, { children: /* @__PURE__ */ d(p, { form: e, layout: "vertical", children: /* @__PURE__ */ d(v, { ...i, purpose: c }) }) });
|
|
11
|
+
}
|
|
12
|
+
function v({
|
|
13
|
+
fields: e,
|
|
14
|
+
formBuilder: c,
|
|
15
|
+
grid: i,
|
|
16
|
+
onDeleteFile: o,
|
|
17
|
+
onUploadFile: l,
|
|
18
|
+
purpose: u
|
|
19
|
+
}) {
|
|
20
|
+
const y = C(
|
|
21
|
+
() => e.filter((r) => !r.readonly).map((r) => {
|
|
22
|
+
const a = {
|
|
23
|
+
onUploading: (t) => {
|
|
24
|
+
var n;
|
|
25
|
+
r.onUploading && ((n = r.onUploading) == null || n.call(r, t)), l == null || l(t);
|
|
26
|
+
},
|
|
27
|
+
onDelete: (t) => {
|
|
28
|
+
var n;
|
|
29
|
+
r.onUploading && ((n = r.onDelete) == null || n.call(r, t)), o == null || o(t);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ d(A.Fragment, { children: r.grid && i ? /* @__PURE__ */ d(S, { ...r.grid, children: /* @__PURE__ */ f(
|
|
33
|
+
s,
|
|
34
|
+
{
|
|
35
|
+
...r,
|
|
36
|
+
...a,
|
|
37
|
+
key: typeof r.name == "string" ? r.name : String(r.name),
|
|
38
|
+
updatable: u !== "update" ? !0 : r.updatable
|
|
39
|
+
}
|
|
40
|
+
) }) : /* @__PURE__ */ f(
|
|
41
|
+
s,
|
|
42
|
+
{
|
|
43
|
+
...r,
|
|
44
|
+
...a,
|
|
45
|
+
key: typeof r.name == "string" ? r.name : String(r.name),
|
|
46
|
+
updatable: u !== "update" ? !0 : r.updatable
|
|
47
|
+
}
|
|
48
|
+
) }, r.name);
|
|
49
|
+
}),
|
|
50
|
+
[e, i, o, l, u]
|
|
51
|
+
), b = k(
|
|
52
|
+
(r, a = {}) => {
|
|
53
|
+
const t = e.find((n) => n.name === r);
|
|
54
|
+
if (t != null && t.hidden) return /* @__PURE__ */ d(m, {});
|
|
55
|
+
if (t) {
|
|
56
|
+
const n = /* @__PURE__ */ f(
|
|
57
|
+
s,
|
|
58
|
+
{
|
|
59
|
+
...t,
|
|
60
|
+
...a,
|
|
61
|
+
key: typeof t.name == "string" ? t.name : String(t.name),
|
|
62
|
+
updatable: u !== "update" ? !0 : t.updatable
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
return a.render ? a.render(n) : n;
|
|
66
|
+
}
|
|
67
|
+
return /* @__PURE__ */ d(m, {});
|
|
68
|
+
},
|
|
69
|
+
[e, u]
|
|
70
|
+
);
|
|
71
|
+
return /* @__PURE__ */ d(m, { children: c ? /* @__PURE__ */ g(m, { children: [
|
|
72
|
+
c(b, {
|
|
73
|
+
isAnyFieldHidden(...r) {
|
|
74
|
+
const a = Array.isArray(r) ? r : [r];
|
|
75
|
+
return e.filter((n) => a.includes(n.name)).some((n) => n.hidden);
|
|
76
|
+
},
|
|
77
|
+
isAllFieldsHidden(...r) {
|
|
78
|
+
const a = Array.isArray(r) ? r : [r];
|
|
79
|
+
return e.filter((n) => a.includes(n.name)).every((n) => n.hidden);
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ g(p.Item, { hidden: !0, noStyle: !0, children: [
|
|
83
|
+
/* @__PURE__ */ d(h, { name: "id" }),
|
|
84
|
+
/* @__PURE__ */ d(h, {})
|
|
85
|
+
] })
|
|
86
|
+
] }) : i ? /* @__PURE__ */ d(j, { gutter: [8, 8], children: y }) : y });
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
x as CrudForm,
|
|
90
|
+
v as CrudFormFields
|
|
91
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),g=require("@ant-design/icons"),u=require("antd"),F=require("react"),k=require("react-i18next"),S=require("../../locale/hooks/translation-constants.cjs"),y=require("./CrudForm.cjs"),C=require("../common/button/Button.cjs"),T=require("../common/wizard/WizardViewForm.cjs");function v({fields:l,className:m,onDeleteFile:h,onUploadFile:i,purpose:c,wizard:r=[],updatingValue:f,onSave:x,submitting:j}){const d=F.useMemo(()=>r.map(n=>{let t=!0;const o=l.filter(s=>n.fields.includes(s.name));return o.forEach(s=>t&&(t=s.hidden??!1)),{...n,hidden:t,fieldThatShouldShowing:o}}),[l,r]),a=F.useMemo(()=>d.filter(n=>!n.hidden),[d]);return e.jsx(e.Fragment,{children:e.jsx(T,{onSubmit:(n,t)=>{console.log(t),x(t)},className:m,pages:a.map(({title:n,icon:t,fieldThatShouldShowing:o,hidden:s},b)=>({title:n,icon:t,hidden:s,component:q=>e.jsx(R,{fields:o,onDeleteFile:h,onUploadFile:i,purpose:c,i:b,updatingValue:f,backward:q.backward,forward:q.forward,wizard:a,submitting:j},b)}))})})}function R({fields:l,onDeleteFile:m,onUploadFile:h,purpose:i,wizard:c=[],i:r,forward:f,backward:x,submitting:j,updatingValue:d}){const a=c[r],{t:n}=k.useTranslation(S.TRANSLATION_NAMESPACE),[t]=u.Form.useForm();return F.useEffect(()=>{if(d&&(i==="update"||i==="clone")){const o={};for(const s of l)o[s.name]=d[s.name];t.setFieldsValue(o)}},[l,t,i,d]),e.jsxs(u.Form,{name:String(r),form:t,layout:"vertical",children:[e.jsx(y.CrudFormFields,{fields:l,formBuilder:a.formBuilder,grid:a.grid,onDeleteFile:m,onUploadFile:h,purpose:i}),e.jsx(u.Divider,{}),e.jsxs(u.Row,{gutter:[8,8],children:[r>0&&e.jsx(u.Col,{md:12,children:e.jsx(C,{block:!0,icon:e.jsx(g.LeftOutlined,{}),htmlType:"button",type:"default",size:"large",onClick:()=>x(),children:n("str.back")})}),e.jsx(u.Col,{md:r>0?12:24,children:e.jsx(C,{block:!0,icon:c.length-1===r?e.jsx(g.SaveOutlined,{}):e.jsx(g.RightOutlined,{}),htmlType:"submit",type:"primary",loading:j,size:"large",onClick:()=>{t.validateFields().then(o=>{f(o,c.length-1===r,c.length-1===r)})},children:c.length-1===r?n("str."+(i==="update"?"update":"save")):n("str.next")})})]})]})}module.exports=v;
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,255 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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;
|