@kingteza/crud-component 1.0.14 → 1.0.16
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 -1
- package/dist/components/common/DatePicker/DatePicker.js +42 -42
- package/dist/components/common/DatePicker/TimePicker.cjs +1 -1
- package/dist/components/common/DatePicker/TimePicker.js +39 -39
- package/dist/components/common/appearance/Hider.cjs +1 -1
- package/dist/components/common/appearance/Hider.js +3 -3
- package/dist/components/common/button/Button.cjs +1 -1
- package/dist/components/common/button/Button.js +19 -19
- package/dist/components/common/button/CloneButtonTable.cjs +1 -1
- package/dist/components/common/button/CloneButtonTable.js +11 -11
- package/dist/components/common/button/DeleteButtonTable.cjs +1 -1
- package/dist/components/common/button/DeleteButtonTable.js +29 -29
- package/dist/components/common/button/ExportButton.cjs +1 -1
- package/dist/components/common/button/ExportButton.js +17 -17
- package/dist/components/common/button/HideButtonTable.cjs +1 -1
- package/dist/components/common/button/HideButtonTable.js +35 -35
- package/dist/components/common/button/ImportButton.cjs +1 -1
- package/dist/components/common/button/ImportButton.js +28 -28
- package/dist/components/common/button/NewButton.cjs +1 -1
- package/dist/components/common/button/NewButton.js +14 -14
- package/dist/components/common/button/PrintButton.cjs +1 -1
- package/dist/components/common/button/PrintButton.js +14 -14
- package/dist/components/common/button/RefreshButton.cjs +1 -1
- package/dist/components/common/button/RefreshButton.js +16 -16
- package/dist/components/common/button/UnHideButton.cjs +1 -1
- package/dist/components/common/button/UnHideButton.js +37 -37
- package/dist/components/common/button/UpdateButtonTable.cjs +1 -1
- package/dist/components/common/button/UpdateButtonTable.js +11 -11
- package/dist/components/common/button/ViewButtonTable.cjs +1 -1
- package/dist/components/common/button/ViewButtonTable.js +10 -10
- package/dist/components/common/check-box/CheckBox.cjs +1 -1
- package/dist/components/common/check-box/CheckBox.js +20 -20
- package/dist/components/common/description/DescList.cjs +1 -1
- package/dist/components/common/description/DescList.js +9 -9
- package/dist/components/common/layout/VerticalSpace.cjs +1 -1
- package/dist/components/common/layout/VerticalSpace.js +3 -3
- package/dist/components/common/loading/LoadingIndicator.cjs +1 -1
- package/dist/components/common/loading/LoadingIndicator.js +12 -12
- package/dist/components/common/picker/ImagePicker.cjs +1 -1
- package/dist/components/common/picker/ImagePicker.js +173 -176
- package/dist/components/common/radio/RadioGroupComponent.cjs +1 -1
- package/dist/components/common/radio/RadioGroupComponent.js +6 -6
- package/dist/components/common/report/SelectFieldInReport.cjs +1 -1
- package/dist/components/common/report/SelectFieldInReport.js +11 -11
- package/dist/components/common/select/CustomSelectOption.cjs +1 -1
- package/dist/components/common/select/CustomSelectOption.js +7 -7
- package/dist/components/common/select/SelectComponent.cjs +1 -1
- package/dist/components/common/select/SelectComponent.js +36 -36
- package/dist/components/common/show-more/index.cjs +1 -1
- package/dist/components/common/show-more/index.js +5 -5
- package/dist/components/common/tab/TabViewWithRoute.cjs +1 -1
- package/dist/components/common/tab/TabViewWithRoute.js +23 -22
- package/dist/components/common/table/table.cjs +1 -1
- package/dist/components/common/table/table.js +12 -12
- package/dist/components/common/tag/StatusTag.cjs +1 -1
- package/dist/components/common/tag/StatusTag.js +13 -13
- package/dist/components/common/text-field/NumberField.cjs +1 -1
- package/dist/components/common/text-field/NumberField.js +43 -43
- package/dist/components/common/text-field/PhoneNumberField.cjs +1 -1
- package/dist/components/common/text-field/PhoneNumberField.js +4 -4
- package/dist/components/common/text-field/TextArea.cjs +1 -1
- package/dist/components/common/text-field/TextArea.js +20 -20
- package/dist/components/common/text-field/TextField.cjs +1 -1
- package/dist/components/common/text-field/TextField.js +47 -47
- package/dist/components/common/tooltip/TooltipComponent.cjs +1 -1
- package/dist/components/common/tooltip/TooltipComponent.js +3 -3
- package/dist/components/common/wizard/WizardResult.cjs +1 -1
- package/dist/components/common/wizard/WizardResult.js +37 -38
- package/dist/components/common/wizard/WizardViewForm.cjs +1 -1
- package/dist/components/common/wizard/WizardViewForm.js +43 -43
- package/dist/components/crud/CrudComponent.cjs +1 -1
- package/dist/components/crud/CrudComponent.js +130 -130
- package/dist/components/crud/CrudField.cjs +1 -1
- package/dist/components/crud/CrudField.js +217 -217
- package/dist/components/crud/CrudForm.cjs +1 -1
- package/dist/components/crud/CrudForm.js +55 -55
- package/dist/components/crud/CrudFormWizard.cjs +1 -1
- package/dist/components/crud/CrudFormWizard.js +82 -84
- package/dist/components/crud/CrudReportComponent.cjs +3 -3
- package/dist/components/crud/CrudReportComponent.js +123 -123
- package/dist/components/crud/CrudSearchComponent.cjs +1 -1
- package/dist/components/crud/CrudSearchComponent.js +43 -43
- package/dist/components/crud/FileCrudField.cjs +1 -1
- package/dist/components/crud/FileCrudField.js +118 -125
- package/dist/components/crud/ImageCrudField.cjs +1 -1
- package/dist/components/crud/ImageCrudField.js +56 -56
- package/dist/components/crud/import/CrudImportButton.cjs +1 -1
- package/dist/components/crud/import/CrudImportButton.js +18 -18
- package/dist/components/crud/import/CrudImportComponent.cjs +2 -2
- package/dist/components/crud/import/CrudImportComponent.js +108 -109
- package/dist/components/crud/view/CrudDecListView.cjs +1 -1
- package/dist/components/crud/view/CrudDecListView.js +22 -22
- package/dist/components/crud/view/CrudViewer.cjs +1 -1
- package/dist/components/crud/view/CrudViewer.js +152 -152
- package/dist/components/crud/view/CrudViewerUtil.cjs +1 -1
- package/dist/components/crud/view/CrudViewerUtil.js +33 -34
- package/dist/locale/index.cjs +1 -1
- package/dist/locale/index.js +2 -2
- package/dist/util/DateUtil.cjs +1 -1
- package/dist/util/DateUtil.js +4 -4
- package/dist/util/ImageUtil.cjs +1 -1
- package/dist/util/ImageUtil.js +1 -1
- package/dist/util/ValidationUtil.cjs +1 -1
- package/dist/util/ValidationUtil.js +1 -1
- package/package.json +1 -1
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
const
|
|
13
|
-
function
|
|
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
14
|
fields: n,
|
|
15
15
|
data: d,
|
|
16
|
-
idField:
|
|
17
|
-
loadingData:
|
|
18
|
-
onSubmit:
|
|
19
|
-
paginateProps:
|
|
20
|
-
size:
|
|
21
|
-
onClickPrint:
|
|
22
|
-
onClickExcelExport:
|
|
23
|
-
minusHeight:
|
|
24
|
-
extraSearchFields:
|
|
25
|
-
searchOnMount:
|
|
26
|
-
summary:
|
|
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
27
|
}) {
|
|
28
|
-
const { searchable:
|
|
29
|
-
var
|
|
30
|
-
const e = [],
|
|
31
|
-
let
|
|
32
|
-
for (const
|
|
33
|
-
|
|
34
|
-
id:
|
|
35
|
-
label:
|
|
36
|
-
lock: (
|
|
37
|
-
alreadySelected: (
|
|
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
38
|
}));
|
|
39
39
|
return {
|
|
40
|
-
defaultSort:
|
|
40
|
+
defaultSort: s,
|
|
41
41
|
searchable: e,
|
|
42
|
-
sortable:
|
|
43
|
-
selectable:
|
|
42
|
+
sortable: r,
|
|
43
|
+
selectable: o
|
|
44
44
|
};
|
|
45
|
-
}, [n]), [
|
|
45
|
+
}, [n]), [g, V] = w(
|
|
46
46
|
[]
|
|
47
|
-
),
|
|
47
|
+
), S = E(
|
|
48
48
|
async ({
|
|
49
49
|
sortBy: e,
|
|
50
|
-
sortByType:
|
|
51
|
-
showFields:
|
|
52
|
-
...
|
|
50
|
+
sortByType: r,
|
|
51
|
+
showFields: o = [],
|
|
52
|
+
...s
|
|
53
53
|
}) => {
|
|
54
|
-
const
|
|
55
|
-
e &&
|
|
54
|
+
const f = [];
|
|
55
|
+
e && f.push({
|
|
56
56
|
field: e,
|
|
57
|
-
sort:
|
|
58
|
-
}),
|
|
59
|
-
n.filter((u) =>
|
|
60
|
-
),
|
|
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
61
|
},
|
|
62
|
-
[n,
|
|
63
|
-
), [a] =
|
|
64
|
-
return
|
|
65
|
-
if (
|
|
62
|
+
[n, T]
|
|
63
|
+
), [a] = B.useForm(), [q, X] = w(!1), [A, Y] = w(!0);
|
|
64
|
+
return F(() => {
|
|
65
|
+
if (C && A) {
|
|
66
66
|
const e = setTimeout(() => {
|
|
67
|
-
a.validateFields().then((
|
|
68
|
-
|
|
69
|
-
}),
|
|
67
|
+
a.validateFields().then((r) => {
|
|
68
|
+
S(r);
|
|
69
|
+
}), Y(!1);
|
|
70
70
|
}, 200);
|
|
71
71
|
return () => clearTimeout(e);
|
|
72
72
|
}
|
|
73
|
-
}, [
|
|
74
|
-
var
|
|
75
|
-
!a.getFieldValue("sortBy") && m && (console.log((
|
|
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
76
|
sortBy: m.name,
|
|
77
|
-
sortByType: typeof ((
|
|
77
|
+
sortByType: typeof ((o = m.report) == null ? void 0 : o.defaultSort) == "string" ? (s = m.report) == null ? void 0 : s.defaultSort : "ASC"
|
|
78
78
|
}));
|
|
79
|
-
}, [m, a]),
|
|
80
|
-
if (
|
|
81
|
-
const e = i.filter((
|
|
82
|
-
|
|
83
|
-
n.filter((
|
|
84
|
-
),
|
|
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
85
|
}
|
|
86
|
-
}, [n,
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
-
|
|
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
93
|
{
|
|
94
|
-
...e.grid ??
|
|
94
|
+
...e.grid ?? H,
|
|
95
95
|
style: { alignSelf: "end" },
|
|
96
|
-
children: (
|
|
97
|
-
|
|
96
|
+
children: (r = e.report) != null && r.customRender ? e.report.customRender(a) : e.type === "date" ? /* @__PURE__ */ t(
|
|
97
|
+
N,
|
|
98
98
|
{
|
|
99
99
|
...e,
|
|
100
100
|
type: "date",
|
|
101
|
-
range: (
|
|
102
|
-
required: !!((
|
|
101
|
+
range: (o = e.report) == null ? void 0 : o.range,
|
|
102
|
+
required: !!((s = e.report) != null && s.required),
|
|
103
103
|
readonly: !1,
|
|
104
104
|
fieldClassName: "mb-0"
|
|
105
105
|
}
|
|
106
|
-
) : e.type === "select" ? /* @__PURE__ */
|
|
107
|
-
|
|
106
|
+
) : e.type === "select" ? /* @__PURE__ */ t(
|
|
107
|
+
N,
|
|
108
108
|
{
|
|
109
109
|
...e,
|
|
110
110
|
type: "select",
|
|
@@ -113,8 +113,8 @@ function pe({
|
|
|
113
113
|
readonly: !1,
|
|
114
114
|
fieldClassName: "mb-0"
|
|
115
115
|
}
|
|
116
|
-
) : /* @__PURE__ */
|
|
117
|
-
|
|
116
|
+
) : /* @__PURE__ */ t(
|
|
117
|
+
N,
|
|
118
118
|
{
|
|
119
119
|
...e,
|
|
120
120
|
readonly: !1,
|
|
@@ -126,8 +126,8 @@ function pe({
|
|
|
126
126
|
e.name
|
|
127
127
|
);
|
|
128
128
|
}),
|
|
129
|
-
!!(i != null && i.length) && /* @__PURE__ */
|
|
130
|
-
|
|
129
|
+
!!(i != null && i.length) && /* @__PURE__ */ t(b, { ...le, children: /* @__PURE__ */ t(
|
|
130
|
+
re,
|
|
131
131
|
{
|
|
132
132
|
items: i,
|
|
133
133
|
name: "showFields",
|
|
@@ -136,26 +136,26 @@ function pe({
|
|
|
136
136
|
className: "mb-0"
|
|
137
137
|
}
|
|
138
138
|
) }),
|
|
139
|
-
!!
|
|
140
|
-
|
|
139
|
+
!!I.length && /* @__PURE__ */ t(b, { ...H, children: /* @__PURE__ */ t(
|
|
140
|
+
te,
|
|
141
141
|
{
|
|
142
142
|
label: "Sort By",
|
|
143
143
|
name: "sortBy",
|
|
144
|
-
items:
|
|
144
|
+
items: I.map((e) => ({ id: e.name, label: e.label })),
|
|
145
145
|
nameFieldInArray: "label",
|
|
146
146
|
fieldId: "id",
|
|
147
147
|
className: "mb-0",
|
|
148
|
-
dropdownRender: (e) => /* @__PURE__ */
|
|
148
|
+
dropdownRender: (e) => /* @__PURE__ */ c(O, { children: [
|
|
149
149
|
e,
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
|
|
150
|
+
/* @__PURE__ */ t(B.Item, { name: "sortByType", noStyle: !0, className: "mt-3", children: /* @__PURE__ */ t(
|
|
151
|
+
R.Group,
|
|
152
152
|
{
|
|
153
153
|
className: "w-100",
|
|
154
154
|
defaultValue: "DESC",
|
|
155
155
|
optionType: "button",
|
|
156
|
-
children: /* @__PURE__ */
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
|
|
156
|
+
children: /* @__PURE__ */ c($, { children: [
|
|
157
|
+
/* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
|
|
158
|
+
R,
|
|
159
159
|
{
|
|
160
160
|
className: "w-100",
|
|
161
161
|
style: {
|
|
@@ -166,8 +166,8 @@ function pe({
|
|
|
166
166
|
children: "Ascending"
|
|
167
167
|
}
|
|
168
168
|
) }),
|
|
169
|
-
/* @__PURE__ */
|
|
170
|
-
|
|
169
|
+
/* @__PURE__ */ t(b, { xs: 12, children: /* @__PURE__ */ t(
|
|
170
|
+
R,
|
|
171
171
|
{
|
|
172
172
|
className: "w-100",
|
|
173
173
|
style: {
|
|
@@ -184,72 +184,72 @@ function pe({
|
|
|
184
184
|
] })
|
|
185
185
|
}
|
|
186
186
|
) }),
|
|
187
|
-
|
|
187
|
+
v ? v(a) : null
|
|
188
188
|
] }),
|
|
189
|
-
/* @__PURE__ */
|
|
190
|
-
|
|
189
|
+
/* @__PURE__ */ t(
|
|
190
|
+
z,
|
|
191
191
|
{
|
|
192
192
|
className: "mt-3",
|
|
193
193
|
type: "primary",
|
|
194
194
|
block: !0,
|
|
195
195
|
htmlType: "submit",
|
|
196
|
-
disabled:
|
|
196
|
+
disabled: p,
|
|
197
197
|
children: "Submit"
|
|
198
198
|
}
|
|
199
199
|
)
|
|
200
200
|
] }),
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
!!
|
|
203
|
-
|
|
201
|
+
/* @__PURE__ */ c(_, { children: [
|
|
202
|
+
!!h && /* @__PURE__ */ t(
|
|
203
|
+
ee,
|
|
204
204
|
{
|
|
205
|
-
disabled:
|
|
206
|
-
onClick: () =>
|
|
205
|
+
disabled: p || !d.length,
|
|
206
|
+
onClick: () => h == null ? void 0 : h({
|
|
207
207
|
tableId: "#crud-table table",
|
|
208
208
|
data: d,
|
|
209
|
-
fields:
|
|
209
|
+
fields: g.map((e) => ({
|
|
210
210
|
...e,
|
|
211
|
-
render:
|
|
211
|
+
render: D(e)
|
|
212
212
|
}))
|
|
213
213
|
})
|
|
214
214
|
}
|
|
215
215
|
),
|
|
216
|
-
!!
|
|
217
|
-
|
|
216
|
+
!!y && /* @__PURE__ */ t(
|
|
217
|
+
z,
|
|
218
218
|
{
|
|
219
|
-
disabled:
|
|
220
|
-
onClick: () =>
|
|
219
|
+
disabled: p || !d.length,
|
|
220
|
+
onClick: () => y == null ? void 0 : y({
|
|
221
221
|
tableId: "#crud-table table",
|
|
222
222
|
data: d,
|
|
223
|
-
fields:
|
|
223
|
+
fields: g.map((e) => ({
|
|
224
224
|
...e,
|
|
225
|
-
render:
|
|
225
|
+
render: D(e)
|
|
226
226
|
}))
|
|
227
227
|
}),
|
|
228
|
-
icon: /* @__PURE__ */
|
|
228
|
+
icon: /* @__PURE__ */ t(x, {}),
|
|
229
229
|
className: `group
|
|
230
|
-
${
|
|
230
|
+
${p || !d.length ? "" : "!bg-green-700 hover:!bg-green-600 !text-white !border-green-700 hover:!border-green-600"}
|
|
231
231
|
|
|
232
232
|
`,
|
|
233
233
|
children: "Excel"
|
|
234
234
|
}
|
|
235
235
|
)
|
|
236
236
|
] }),
|
|
237
|
-
|
|
238
|
-
/* @__PURE__ */
|
|
239
|
-
|
|
237
|
+
U,
|
|
238
|
+
/* @__PURE__ */ t(
|
|
239
|
+
P,
|
|
240
240
|
{
|
|
241
|
-
minusHeight:
|
|
241
|
+
minusHeight: Q,
|
|
242
242
|
data: d,
|
|
243
|
-
size:
|
|
244
|
-
fields:
|
|
245
|
-
idField:
|
|
246
|
-
loadingData:
|
|
247
|
-
paginateProps:
|
|
243
|
+
size: M,
|
|
244
|
+
fields: g,
|
|
245
|
+
idField: J,
|
|
246
|
+
loadingData: p,
|
|
247
|
+
paginateProps: K,
|
|
248
248
|
viewable: !1
|
|
249
249
|
}
|
|
250
250
|
)
|
|
251
251
|
] }) });
|
|
252
252
|
}
|
|
253
253
|
export {
|
|
254
|
-
|
|
254
|
+
be as default
|
|
255
255
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),o=require("react"),w=require("@ant-design/icons"),f=require("antd"),M=require("./CrudField.cjs"),N=require("../common/button/Button.cjs");function a({searchFields:t=[],fields:b,searchOnChange:x,onSearch:g,searchDefaultValues:m,searchFieldsCustomColumnProps:r}){const p=o.useMemo(()=>t.map(n=>typeof n=="string"?{...b.find(c=>n===c.name),required:!1}:{...b.find(i=>(n==null?void 0:n.name)===i.name),...n}).filter(n=>n&&!(n!=null&&n.hidden)),[t,b]),y=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),j=o.useMemo(()=>t.length===1?{field:22,button:2}:t.length===2?{field:11,button:2}:t.length===3?{field:6,button:6}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),q=o.useMemo(()=>t.length===1?{field:21,button:3}:t.length===2?{field:11,button:2}:t.length===3?{field:24,button:24}:t.length===4?{field:5,button:4}:t.length===5?{field:4,button:4}:{field:4,button:4},[t.length]),[u]=f.Form.useForm(),d=o.useCallback(async n=>{if((n||x)&&g){const l=await u.validateFields();g(l)}},[u,g,x]);return o.useEffect(()=>{m&&(u.setFieldsValue(m),d(!0))},[u,m]),t!=null&&t.length?e.jsx(f.Form,{form:u,onFinish:()=>d(!0),layout:"vertical",className:"mb-2",onChange:()=>d(!1),children:e.jsxs(f.Row,{gutter:[4,8],className:"w-100",children:[p.map((n,l)=>{const i=(r==null?void 0:r[l])??{md:y.field,sm:j.field,xs:q.field};return o.createElement(f.Col,{...i,key:`search_field_${String(n.name)}`,className:"align-self-end"},e.jsx(M.default,{...n,readonly:!1,fieldClassName:"mb-0"}))}),e.jsx(f.Col,{md:y.button,sm:j.button,xs:q.button,style:{alignSelf:"end"},children:e.jsx(N,{type:"primary",htmlType:"submit",block:!0,icon:e.jsx(w.SearchOutlined,{})})})]})}):e.jsx(e.Fragment,{})}module.exports=a;
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function
|
|
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
8
|
searchFields: t = [],
|
|
9
9
|
fields: e,
|
|
10
|
-
searchOnChange:
|
|
10
|
+
searchOnChange: p,
|
|
11
11
|
onSearch: b,
|
|
12
12
|
searchDefaultValues: g,
|
|
13
13
|
searchFieldsCustomColumnProps: i
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
15
|
+
const k = u(
|
|
16
16
|
() => t.map((n) => typeof n == "string" ? {
|
|
17
|
-
...e.find((
|
|
17
|
+
...e.find((a) => n === a.name),
|
|
18
18
|
required: !1
|
|
19
19
|
} : {
|
|
20
20
|
...e.find(
|
|
21
|
-
(
|
|
21
|
+
(l) => (n == null ? void 0 : n.name) === l.name
|
|
22
22
|
),
|
|
23
23
|
...n
|
|
24
24
|
}).filter((n) => n && !(n != null && n.hidden)),
|
|
25
25
|
[t, e]
|
|
26
|
-
),
|
|
26
|
+
), d = u(
|
|
27
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
28
|
[t.length]
|
|
29
|
-
),
|
|
29
|
+
), y = u(
|
|
30
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
31
|
[t.length]
|
|
32
|
-
),
|
|
32
|
+
), x = u(
|
|
33
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
34
|
[t.length]
|
|
35
|
-
), [f] =
|
|
35
|
+
), [f] = w.useForm(), r = E(
|
|
36
36
|
async (n) => {
|
|
37
|
-
if ((n ||
|
|
37
|
+
if ((n || p) && b) {
|
|
38
38
|
const m = await f.validateFields();
|
|
39
39
|
b(m);
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
-
[f, b,
|
|
42
|
+
[f, b, p]
|
|
43
43
|
);
|
|
44
|
-
return
|
|
45
|
-
g && (f.setFieldsValue(g),
|
|
46
|
-
}, [f, g]), t != null && t.length ? /* @__PURE__ */ o
|
|
47
|
-
|
|
44
|
+
return S(() => {
|
|
45
|
+
g && (f.setFieldsValue(g), r(!0));
|
|
46
|
+
}, [f, g]), t != null && t.length ? /* @__PURE__ */ o(
|
|
47
|
+
w,
|
|
48
48
|
{
|
|
49
49
|
form: f,
|
|
50
|
-
onFinish: () =>
|
|
50
|
+
onFinish: () => r(!0),
|
|
51
51
|
layout: "vertical",
|
|
52
52
|
className: "mb-2",
|
|
53
|
-
onChange: () =>
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
md:
|
|
58
|
-
sm:
|
|
59
|
-
xs:
|
|
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
60
|
};
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
-
|
|
61
|
+
return /* @__PURE__ */ _(
|
|
62
|
+
N,
|
|
63
63
|
{
|
|
64
|
-
...
|
|
64
|
+
...l,
|
|
65
65
|
key: `search_field_${String(n.name)}`,
|
|
66
66
|
className: "align-self-end"
|
|
67
67
|
},
|
|
68
|
-
/* @__PURE__ */ o
|
|
68
|
+
/* @__PURE__ */ o(M, { ...n, readonly: !1, fieldClassName: "mb-0" })
|
|
69
69
|
);
|
|
70
70
|
}),
|
|
71
|
-
/* @__PURE__ */ o
|
|
72
|
-
|
|
71
|
+
/* @__PURE__ */ o(
|
|
72
|
+
N,
|
|
73
73
|
{
|
|
74
|
-
md:
|
|
75
|
-
sm:
|
|
76
|
-
xs:
|
|
74
|
+
md: d.button,
|
|
75
|
+
sm: y.button,
|
|
76
|
+
xs: x.button,
|
|
77
77
|
style: { alignSelf: "end" },
|
|
78
|
-
children: /* @__PURE__ */ o
|
|
79
|
-
|
|
78
|
+
children: /* @__PURE__ */ o(
|
|
79
|
+
R,
|
|
80
80
|
{
|
|
81
81
|
type: "primary",
|
|
82
82
|
htmlType: "submit",
|
|
83
83
|
block: !0,
|
|
84
|
-
icon: /* @__PURE__ */ o
|
|
84
|
+
icon: /* @__PURE__ */ o(q, {})
|
|
85
85
|
}
|
|
86
86
|
)
|
|
87
87
|
}
|
|
88
88
|
)
|
|
89
89
|
] })
|
|
90
90
|
}
|
|
91
|
-
) : /* @__PURE__ */ o
|
|
91
|
+
) : /* @__PURE__ */ o(j, {});
|
|
92
92
|
}
|
|
93
93
|
export {
|
|
94
|
-
|
|
94
|
+
I as default
|
|
95
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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;
|