@kingteza/crud-component 1.0.29 → 1.0.31
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/common/index.cjs +1 -1
- package/common/index.d.ts +1 -1
- package/common/index.js +2 -2
- package/crud/CrudComponent.cjs +1 -0
- package/crud/CrudComponent.d.ts +237 -0
- package/crud/CrudComponent.js +210 -0
- package/crud/CrudField.cjs +1 -0
- package/crud/CrudField.d.ts +4 -0
- package/crud/CrudField.js +459 -0
- package/crud/CrudForm.cjs +1 -0
- package/crud/CrudForm.d.ts +14 -0
- package/crud/CrudForm.js +91 -0
- package/crud/CrudFormWizard.cjs +1 -0
- package/crud/CrudFormWizard.d.ts +14 -0
- package/crud/CrudFormWizard.js +140 -0
- package/crud/CrudReportComponent.cjs +4 -0
- package/crud/CrudReportComponent.d.ts +44 -0
- package/crud/CrudReportComponent.js +255 -0
- package/crud/CrudSearchComponent.cjs +1 -0
- package/crud/CrudSearchComponent.d.ts +21 -0
- package/crud/CrudSearchComponent.js +95 -0
- package/crud/FileCrudField.cjs +1 -0
- package/crud/FileCrudField.d.ts +25 -0
- package/crud/FileCrudField.js +220 -0
- package/crud/ImageCrudField.cjs +1 -0
- package/crud/ImageCrudField.d.ts +38 -0
- package/crud/ImageCrudField.js +113 -0
- package/crud/import/CrudImportButton.cjs +1 -0
- package/crud/import/CrudImportButton.d.ts +3 -0
- package/crud/import/CrudImportButton.js +31 -0
- package/crud/import/CrudImportComponent.cjs +2 -0
- package/crud/import/CrudImportComponent.d.ts +14 -0
- package/crud/import/CrudImportComponent.js +223 -0
- package/crud/index.d.ts +18 -0
- package/crud/view/CrudDecListView.cjs +1 -0
- package/crud/view/CrudDecListView.d.ts +14 -0
- package/crud/view/CrudDecListView.js +42 -0
- package/crud/view/CrudViewer.cjs +1 -0
- package/crud/view/CrudViewer.d.ts +43 -0
- package/crud/view/CrudViewer.js +217 -0
- package/crud/view/CrudViewerUtil.cjs +1 -0
- package/crud/view/CrudViewerUtil.d.ts +2 -0
- package/crud/view/CrudViewerUtil.js +57 -0
- package/crud/view/index.d.ts +5 -0
- package/index.cjs +1 -1
- package/index.d.ts +2 -2
- package/index.js +15 -11
- package/package.json +2 -2
- /package/common/{DatePicker → date-picker}/DatePicker.cjs +0 -0
- /package/common/{DatePicker → date-picker}/DatePicker.d.ts +0 -0
- /package/common/{DatePicker → date-picker}/DatePicker.js +0 -0
- /package/common/{DatePicker → date-picker}/TimePicker.cjs +0 -0
- /package/common/{DatePicker → date-picker}/TimePicker.d.ts +0 -0
- /package/common/{DatePicker → date-picker}/TimePicker.js +0 -0
- /package/common/{DatePicker → date-picker}/index.d.ts +0 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import { jsx as a, Fragment as O, jsxs as U } from "react/jsx-runtime";
|
|
2
|
+
import { Form as S, Radio as q, Select as A, ColorPicker as $ } from "antd";
|
|
3
|
+
import { useEffect as P, useState as D, useCallback as z } from "react";
|
|
4
|
+
import J from "react-highlight-words";
|
|
5
|
+
import { useTranslation as K } from "react-i18next";
|
|
6
|
+
import { TRANSLATION_NAMESPACE as Q } from "../locale/hooks/translation-constants.js";
|
|
7
|
+
import X from "./FileCrudField.js";
|
|
8
|
+
import Y from "./ImageCrudField.js";
|
|
9
|
+
import Z from "../common/date-picker/DatePicker.js";
|
|
10
|
+
import V from "../common/date-picker/TimePicker.js";
|
|
11
|
+
import ee from "../common/check-box/CheckBox.js";
|
|
12
|
+
import M from "../common/select/SelectComponent.js";
|
|
13
|
+
import re from "../common/text-field/NumberField.js";
|
|
14
|
+
import te from "../common/text-field/TextField.js";
|
|
15
|
+
import oe from "../common/text-field/TextArea.js";
|
|
16
|
+
import ae from "../common/tooltip/TooltipComponent.js";
|
|
17
|
+
function Ne(x) {
|
|
18
|
+
const {
|
|
19
|
+
label: i,
|
|
20
|
+
name: c,
|
|
21
|
+
type: b,
|
|
22
|
+
required: s,
|
|
23
|
+
hidden: F,
|
|
24
|
+
rules: u = [],
|
|
25
|
+
updatable: h = !0,
|
|
26
|
+
readonly: w = !1,
|
|
27
|
+
fieldClassName: f,
|
|
28
|
+
customFormFieldRender: k,
|
|
29
|
+
fieldTooltip: v,
|
|
30
|
+
...e
|
|
31
|
+
} = x, p = S.useFormInstance();
|
|
32
|
+
P(() => {
|
|
33
|
+
if (b === "select") {
|
|
34
|
+
const {
|
|
35
|
+
items: t = [],
|
|
36
|
+
onSearch: n,
|
|
37
|
+
searchOnType: o
|
|
38
|
+
} = e;
|
|
39
|
+
!(t != null && t.length) && !o && (n == null || n(void 0, p, e == null ? void 0 : e.updatingValue));
|
|
40
|
+
}
|
|
41
|
+
}, [p, e, b, e == null ? void 0 : e.updatingValue]);
|
|
42
|
+
const { t: N } = K(Q);
|
|
43
|
+
if (w || F) return /* @__PURE__ */ a(O, {});
|
|
44
|
+
if (k)
|
|
45
|
+
return k(p, x);
|
|
46
|
+
switch (b) {
|
|
47
|
+
case "text":
|
|
48
|
+
case "email":
|
|
49
|
+
case "password": {
|
|
50
|
+
const { onChange: t, placeholder: n } = e;
|
|
51
|
+
return /* @__PURE__ */ a(
|
|
52
|
+
te,
|
|
53
|
+
{
|
|
54
|
+
placeholder: n,
|
|
55
|
+
disabled: !h,
|
|
56
|
+
rules: u,
|
|
57
|
+
required: s,
|
|
58
|
+
onChange: t ? (o) => t(o, p) : void 0,
|
|
59
|
+
type: b,
|
|
60
|
+
name: c,
|
|
61
|
+
tooltip: v,
|
|
62
|
+
label: i,
|
|
63
|
+
className: f,
|
|
64
|
+
autoComplete: "new-password"
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
case "number": {
|
|
69
|
+
const { onChange: t, placeholder: n, allowMinus: o } = e;
|
|
70
|
+
return /* @__PURE__ */ a(
|
|
71
|
+
re,
|
|
72
|
+
{
|
|
73
|
+
placeholder: n,
|
|
74
|
+
disabled: !h,
|
|
75
|
+
moneyField: !!e.formatted,
|
|
76
|
+
type: b,
|
|
77
|
+
onChange: t ? (g) => t(g, p) : void 0,
|
|
78
|
+
rules: u,
|
|
79
|
+
autoComplete: "false",
|
|
80
|
+
required: s,
|
|
81
|
+
tooltip: v,
|
|
82
|
+
className: f,
|
|
83
|
+
min: o ? null : void 0,
|
|
84
|
+
name: c,
|
|
85
|
+
label: i
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
case "date": {
|
|
90
|
+
const {
|
|
91
|
+
range: t,
|
|
92
|
+
disableToday: n,
|
|
93
|
+
disabledFutureDays: o,
|
|
94
|
+
disabledPastDays: g,
|
|
95
|
+
onChange: C,
|
|
96
|
+
placeholder: m,
|
|
97
|
+
format: T
|
|
98
|
+
} = e;
|
|
99
|
+
return /* @__PURE__ */ a(
|
|
100
|
+
Z,
|
|
101
|
+
{
|
|
102
|
+
placeholder: m,
|
|
103
|
+
required: s,
|
|
104
|
+
disabled: !h,
|
|
105
|
+
type: b,
|
|
106
|
+
format: T,
|
|
107
|
+
tooltip: v,
|
|
108
|
+
range: t,
|
|
109
|
+
name: c,
|
|
110
|
+
label: i,
|
|
111
|
+
onChange: C ? (l) => C(l, p) : void 0,
|
|
112
|
+
className: f,
|
|
113
|
+
disableToday: n,
|
|
114
|
+
disabledFutureDays: o,
|
|
115
|
+
disabledPastDays: g
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
case "time": {
|
|
120
|
+
const {
|
|
121
|
+
range: t = !1,
|
|
122
|
+
disableCurrent: n,
|
|
123
|
+
disabledFuture: o,
|
|
124
|
+
disabledPast: g,
|
|
125
|
+
onChange: C,
|
|
126
|
+
use12Hours: m,
|
|
127
|
+
format: T,
|
|
128
|
+
placeholder: l
|
|
129
|
+
} = e;
|
|
130
|
+
return /* @__PURE__ */ a(
|
|
131
|
+
V,
|
|
132
|
+
{
|
|
133
|
+
placeholder: l,
|
|
134
|
+
required: s,
|
|
135
|
+
format: T,
|
|
136
|
+
disabled: !h,
|
|
137
|
+
type: b,
|
|
138
|
+
tooltip: v,
|
|
139
|
+
range: t,
|
|
140
|
+
use12Hours: m,
|
|
141
|
+
name: c,
|
|
142
|
+
label: i,
|
|
143
|
+
onChange: C ? (y) => C(y, p) : void 0,
|
|
144
|
+
className: f,
|
|
145
|
+
disableCurrent: n,
|
|
146
|
+
disabledFuture: o,
|
|
147
|
+
disabledPast: g
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
case "textarea": {
|
|
152
|
+
const { onChange: t, placeholder: n, rows: o, cols: g } = e;
|
|
153
|
+
return /* @__PURE__ */ a(
|
|
154
|
+
oe,
|
|
155
|
+
{
|
|
156
|
+
rules: u,
|
|
157
|
+
placeholder: n,
|
|
158
|
+
onChange: t ? (C) => {
|
|
159
|
+
var m;
|
|
160
|
+
return t((m = C == null ? void 0 : C.target) == null ? void 0 : m.value, p);
|
|
161
|
+
} : void 0,
|
|
162
|
+
tooltip: v,
|
|
163
|
+
required: s,
|
|
164
|
+
disabled: !h,
|
|
165
|
+
name: c,
|
|
166
|
+
label: i,
|
|
167
|
+
className: f,
|
|
168
|
+
rows: o,
|
|
169
|
+
cols: g
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
case "image":
|
|
174
|
+
return /* @__PURE__ */ a(
|
|
175
|
+
Y,
|
|
176
|
+
{
|
|
177
|
+
...e,
|
|
178
|
+
required: s,
|
|
179
|
+
name: c,
|
|
180
|
+
label: i,
|
|
181
|
+
rules: u,
|
|
182
|
+
fieldClassName: f,
|
|
183
|
+
onRemoved: e.onRemoved,
|
|
184
|
+
onUploading: e.onUploading,
|
|
185
|
+
provider: e.provider
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
case "file":
|
|
189
|
+
return /* @__PURE__ */ a(
|
|
190
|
+
X,
|
|
191
|
+
{
|
|
192
|
+
...e,
|
|
193
|
+
required: s,
|
|
194
|
+
name: c,
|
|
195
|
+
label: i,
|
|
196
|
+
rules: u,
|
|
197
|
+
fieldClassName: f,
|
|
198
|
+
onRemoved: e.onRemoved,
|
|
199
|
+
onUploading: e.onUploading,
|
|
200
|
+
provider: e.provider
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
case "select":
|
|
204
|
+
return /* @__PURE__ */ a(
|
|
205
|
+
le,
|
|
206
|
+
{
|
|
207
|
+
...e,
|
|
208
|
+
required: s,
|
|
209
|
+
name: c,
|
|
210
|
+
label: i,
|
|
211
|
+
rules: u,
|
|
212
|
+
fieldClassName: f,
|
|
213
|
+
form: p,
|
|
214
|
+
updatable: h,
|
|
215
|
+
readonly: w,
|
|
216
|
+
fieldTooltip: v
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
case "enum": {
|
|
220
|
+
const {
|
|
221
|
+
enum: t,
|
|
222
|
+
radio: n = !1,
|
|
223
|
+
translation: o,
|
|
224
|
+
onChange: g,
|
|
225
|
+
onSearch: C,
|
|
226
|
+
multiple: m
|
|
227
|
+
} = e, T = Array.isArray(t) ? t : Object.keys(t);
|
|
228
|
+
return n ? /* @__PURE__ */ a(
|
|
229
|
+
S.Item,
|
|
230
|
+
{
|
|
231
|
+
...e,
|
|
232
|
+
name: c,
|
|
233
|
+
required: s,
|
|
234
|
+
tooltip: v,
|
|
235
|
+
rules: u,
|
|
236
|
+
label: i,
|
|
237
|
+
className: ["w-100", f].join(" "),
|
|
238
|
+
children: /* @__PURE__ */ a(
|
|
239
|
+
q.Group,
|
|
240
|
+
{
|
|
241
|
+
...e,
|
|
242
|
+
onChange: g ? (l) => {
|
|
243
|
+
var y;
|
|
244
|
+
return g((y = l == null ? void 0 : l.target) == null ? void 0 : y.value, p);
|
|
245
|
+
} : void 0,
|
|
246
|
+
children: T.map((l) => /* @__PURE__ */ a(q, { disabled: !h, value: l, children: o ? N(o[l]) : l }, l))
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
) : /* @__PURE__ */ a(
|
|
251
|
+
M,
|
|
252
|
+
{
|
|
253
|
+
...e,
|
|
254
|
+
onChange: g ? (l) => g(l, p) : void 0,
|
|
255
|
+
className: ["w-100", f].join(" "),
|
|
256
|
+
name: c,
|
|
257
|
+
items: T,
|
|
258
|
+
required: s,
|
|
259
|
+
tooltip: v,
|
|
260
|
+
rules: u,
|
|
261
|
+
label: i,
|
|
262
|
+
disabled: !h,
|
|
263
|
+
onSearch: C ? (l) => C(l, p) : void 0,
|
|
264
|
+
allowClear: !0,
|
|
265
|
+
mode: m ? "multiple" : void 0,
|
|
266
|
+
itemBuilder: (l) => /* @__PURE__ */ a(A.Option, { value: l, children: o ? N(o[l]) : l }, l)
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
case "checkbox": {
|
|
271
|
+
const { onChange: t } = e;
|
|
272
|
+
return /* @__PURE__ */ a(
|
|
273
|
+
ee,
|
|
274
|
+
{
|
|
275
|
+
className: f,
|
|
276
|
+
rules: u,
|
|
277
|
+
onChange: t ? (n) => t(n, p) : void 0,
|
|
278
|
+
label: i,
|
|
279
|
+
tooltip: v,
|
|
280
|
+
disabled: !h,
|
|
281
|
+
name: c
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
case "color":
|
|
286
|
+
return /* @__PURE__ */ a(
|
|
287
|
+
ne,
|
|
288
|
+
{
|
|
289
|
+
...e,
|
|
290
|
+
type: "color",
|
|
291
|
+
required: s,
|
|
292
|
+
name: c,
|
|
293
|
+
label: i,
|
|
294
|
+
rules: u,
|
|
295
|
+
fieldClassName: f,
|
|
296
|
+
updatable: h,
|
|
297
|
+
readonly: w,
|
|
298
|
+
fieldTooltip: v
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
default:
|
|
302
|
+
return /* @__PURE__ */ a(O, { children: `${b} Not Implemented` });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function le(x) {
|
|
306
|
+
const {
|
|
307
|
+
items: i = [],
|
|
308
|
+
loading: c,
|
|
309
|
+
searchOnType: b,
|
|
310
|
+
onSearch: s,
|
|
311
|
+
multiple: F,
|
|
312
|
+
onChange: u,
|
|
313
|
+
highlightSearch: h,
|
|
314
|
+
required: w,
|
|
315
|
+
fieldClassName: f,
|
|
316
|
+
rules: k,
|
|
317
|
+
fieldTooltip: v,
|
|
318
|
+
updatable: e,
|
|
319
|
+
label: p,
|
|
320
|
+
name: N,
|
|
321
|
+
tagRender: t,
|
|
322
|
+
updatingValue: n,
|
|
323
|
+
onSet: o,
|
|
324
|
+
placeholder: g,
|
|
325
|
+
allowClear: C = !0
|
|
326
|
+
} = x, m = x.form, [T, l] = D(""), y = S.useWatch(N, m), [R, j] = D(!0);
|
|
327
|
+
P(() => {
|
|
328
|
+
o && R && y && (o == null || o(y, i, m), j(!1));
|
|
329
|
+
}, [R, m, i, N, o, y]), P(() => {
|
|
330
|
+
y && j(!0);
|
|
331
|
+
}, [y]);
|
|
332
|
+
const W = z(
|
|
333
|
+
async (r) => {
|
|
334
|
+
l(r), b && (s == null || s(r, m, n));
|
|
335
|
+
},
|
|
336
|
+
[m, s, b, n]
|
|
337
|
+
);
|
|
338
|
+
return /* @__PURE__ */ a(
|
|
339
|
+
M,
|
|
340
|
+
{
|
|
341
|
+
...x,
|
|
342
|
+
maxTagCount: "responsive",
|
|
343
|
+
maxTagPlaceholder: (r) => /* @__PURE__ */ U(
|
|
344
|
+
ae,
|
|
345
|
+
{
|
|
346
|
+
title: /* @__PURE__ */ a(O, { children: r.map((d) => /* @__PURE__ */ U(O, { children: [
|
|
347
|
+
d.label,
|
|
348
|
+
" ",
|
|
349
|
+
/* @__PURE__ */ a("br", {})
|
|
350
|
+
] })) }),
|
|
351
|
+
children: [
|
|
352
|
+
"+",
|
|
353
|
+
r == null ? void 0 : r.length
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
),
|
|
357
|
+
placeholder: g,
|
|
358
|
+
onSelect: (r) => {
|
|
359
|
+
o == null || o(r == null ? void 0 : r.key, i, m);
|
|
360
|
+
},
|
|
361
|
+
onChange: u ? (r) => {
|
|
362
|
+
l(""), u(r, m);
|
|
363
|
+
} : void 0,
|
|
364
|
+
mode: F ? "multiple" : void 0,
|
|
365
|
+
className: ["w-100", f].join(" "),
|
|
366
|
+
name: N,
|
|
367
|
+
items: i,
|
|
368
|
+
required: w,
|
|
369
|
+
tooltip: v,
|
|
370
|
+
tagRender: t,
|
|
371
|
+
rules: k,
|
|
372
|
+
disabled: !e,
|
|
373
|
+
label: p,
|
|
374
|
+
allowClear: C,
|
|
375
|
+
onSearch: W,
|
|
376
|
+
loading: c,
|
|
377
|
+
filterOption: h ? (r, d) => {
|
|
378
|
+
var I, L, B;
|
|
379
|
+
try {
|
|
380
|
+
const E = r.toLowerCase().split(/\s+/), _ = ((typeof (d == null ? void 0 : d.children) == "string" ? d == null ? void 0 : d.children : (L = (I = d == null ? void 0 : d.children) == null ? void 0 : I.props) == null ? void 0 : L.textToHighlight) ?? "").toLowerCase(), G = (((B = d == null ? void 0 : d.value) == null ? void 0 : B.toString()) ?? "").toLowerCase();
|
|
381
|
+
return E.every(
|
|
382
|
+
(H) => _.indexOf(H) >= 0 || G.indexOf(H) >= 0
|
|
383
|
+
);
|
|
384
|
+
} catch {
|
|
385
|
+
return !0;
|
|
386
|
+
}
|
|
387
|
+
} : void 0,
|
|
388
|
+
itemBuilder: h ? (r) => {
|
|
389
|
+
const d = r.value ? String(r.value) : void 0;
|
|
390
|
+
return /* @__PURE__ */ a(
|
|
391
|
+
A.Option,
|
|
392
|
+
{
|
|
393
|
+
value: r.key,
|
|
394
|
+
title: d,
|
|
395
|
+
disabled: r.disabled,
|
|
396
|
+
children: /* @__PURE__ */ a(
|
|
397
|
+
J,
|
|
398
|
+
{
|
|
399
|
+
highlightClassName: "highlight-text",
|
|
400
|
+
searchWords: (T ?? "").split(" "),
|
|
401
|
+
autoEscape: !0,
|
|
402
|
+
textToHighlight: d ?? ""
|
|
403
|
+
}
|
|
404
|
+
)
|
|
405
|
+
},
|
|
406
|
+
r.key
|
|
407
|
+
);
|
|
408
|
+
} : (r) => /* @__PURE__ */ a(
|
|
409
|
+
A.Option,
|
|
410
|
+
{
|
|
411
|
+
value: r.key,
|
|
412
|
+
title: r.value,
|
|
413
|
+
disabled: r.disabled,
|
|
414
|
+
children: r.value
|
|
415
|
+
},
|
|
416
|
+
r.key
|
|
417
|
+
)
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
function ne(x) {
|
|
422
|
+
const {
|
|
423
|
+
required: i,
|
|
424
|
+
fieldClassName: c,
|
|
425
|
+
rules: b,
|
|
426
|
+
fieldTooltip: s,
|
|
427
|
+
updatable: F,
|
|
428
|
+
label: u,
|
|
429
|
+
name: h
|
|
430
|
+
} = x;
|
|
431
|
+
return /* @__PURE__ */ a(
|
|
432
|
+
S.Item,
|
|
433
|
+
{
|
|
434
|
+
label: u,
|
|
435
|
+
name: h,
|
|
436
|
+
required: i,
|
|
437
|
+
rules: b,
|
|
438
|
+
tooltip: s,
|
|
439
|
+
children: /* @__PURE__ */ a(
|
|
440
|
+
$,
|
|
441
|
+
{
|
|
442
|
+
disabledAlpha: !0,
|
|
443
|
+
format: "hex",
|
|
444
|
+
defaultFormat: "hex",
|
|
445
|
+
showText: !0,
|
|
446
|
+
trigger: "click",
|
|
447
|
+
className: c,
|
|
448
|
+
disabled: !F,
|
|
449
|
+
...x.innerProps
|
|
450
|
+
}
|
|
451
|
+
)
|
|
452
|
+
}
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
export {
|
|
456
|
+
ne as ColorCrudFieldComponent,
|
|
457
|
+
le as SelectCrudFieldComponent,
|
|
458
|
+
Ne as default
|
|
459
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),u=require("antd"),g=require("./CrudField.cjs");function h({form:d,purpose:m="new",...s}){return t.jsx(t.Fragment,{children:t.jsx(u.Form,{form:d,layout:"vertical",children:t.jsx(y,{...s,purpose:m})})})}function y({fields:d,formBuilder:m,grid:s,onDeleteFile:l,onUploadFile:o,purpose:c}){const f=i.useMemo(()=>d.filter(r=>!r.readonly).map(r=>{const a={onUploading:e=>{var n;r.onUploading&&((n=r.onUploading)==null||n.call(r,e)),o==null||o(e)},onDelete:e=>{var n;r.onUploading&&((n=r.onDelete)==null||n.call(r,e)),l==null||l(e)}};return t.jsx(i.Fragment,{children:r.grid&&s?t.jsx(u.Col,{...r.grid,children:i.createElement(g.default,{...r,...a,key:typeof r.name=="string"?r.name:String(r.name),updatable:c!=="update"?!0:r.updatable})}):i.createElement(g.default,{...r,...a,key:typeof r.name=="string"?r.name:String(r.name),updatable:c!=="update"?!0:r.updatable})},r.name)}),[d,s,l,o,c]),j=i.useCallback((r,a={})=>{const e=d.find(n=>n.name===r);if(e!=null&&e.hidden)return t.jsx(t.Fragment,{});if(e){const n=i.createElement(g.default,{...e,...a,key:typeof e.name=="string"?e.name:String(e.name),updatable:c!=="update"?!0:e.updatable});return a.render?a.render(n):n}return t.jsx(t.Fragment,{})},[d,c]);return t.jsx(t.Fragment,{children:m?t.jsxs(t.Fragment,{children:[m(j,{isAnyFieldHidden(...r){const a=Array.isArray(r)?r:[r];return d.filter(n=>a.includes(n.name)).some(n=>n.hidden)},isAllFieldsHidden(...r){const a=Array.isArray(r)?r:[r];return d.filter(n=>a.includes(n.name)).every(n=>n.hidden)}}),t.jsxs(u.Form.Item,{hidden:!0,noStyle:!0,children:[t.jsx(u.Input,{name:"id"}),t.jsx(u.Input,{})]})]}):s?t.jsx(u.Row,{gutter:[8,8],children:f}):f})}exports.CrudForm=h;exports.CrudFormFields=y;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormInstance } from 'antd';
|
|
2
|
+
import { CrudFieldProps, CrudPurpose, FormBuilderFunc } from './CrudComponent';
|
|
3
|
+
export interface CurdFormFieldsProps<T> {
|
|
4
|
+
onDeleteFile?: (e: any) => void;
|
|
5
|
+
onUploadFile?: (e: any) => void;
|
|
6
|
+
grid?: boolean;
|
|
7
|
+
formBuilder?: FormBuilderFunc<T>;
|
|
8
|
+
fields: CrudFieldProps<T>[];
|
|
9
|
+
purpose?: CrudPurpose;
|
|
10
|
+
}
|
|
11
|
+
export declare function CrudForm<T>({ form, purpose, ...props }: CurdFormFieldsProps<T> & {
|
|
12
|
+
form: FormInstance;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function CrudFormFields<T>({ fields, formBuilder, grid, onDeleteFile, onUploadFile, purpose, }: CurdFormFieldsProps<T>): import("react/jsx-runtime").JSX.Element;
|
package/crud/CrudForm.js
ADDED
|
@@ -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,14 @@
|
|
|
1
|
+
import { CrudFieldProps, CrudPurpose, CrudWizardProp } from './CrudComponent';
|
|
2
|
+
export interface CrudFormWizardProps<T> {
|
|
3
|
+
onDeleteFile?: (e: any) => void;
|
|
4
|
+
onUploadFile?: (e: any) => void;
|
|
5
|
+
fields: CrudFieldProps<T>[];
|
|
6
|
+
purpose?: CrudPurpose;
|
|
7
|
+
wizard?: CrudWizardProp<T>[];
|
|
8
|
+
className?: string;
|
|
9
|
+
onSave: (e: T) => void;
|
|
10
|
+
updatingValue?: T;
|
|
11
|
+
submitting?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare function CrudFormWizard<T>({ fields, className, onDeleteFile, onUploadFile, purpose, wizard, updatingValue, onSave, submitting, }: CrudFormWizardProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default CrudFormWizard;
|