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