@kingteza/crud-component 1.44.0 → 1.44.2
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/common/picker/ImagePicker.cjs.js +1 -1
- package/dist/common/picker/ImagePicker.d.ts +4 -2
- package/dist/common/picker/ImagePicker.es.js +291 -251
- package/dist/crud/FileCrudField.cjs.js +1 -1
- package/dist/crud/FileCrudField.es.js +18 -17
- package/dist/crud/ImageCrudField.cjs.js +1 -1
- package/dist/crud/ImageCrudField.d.ts +1 -1
- package/dist/crud/ImageCrudField.es.js +127 -92
- package/dist/crud/modal/index.cjs.js +1 -1
- package/dist/crud/modal/index.es.js +120 -109
- package/package.json +1 -1
|
@@ -1,171 +1,182 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Form as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { CrudForm as
|
|
5
|
-
import
|
|
6
|
-
import { useTranslationLib as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { setValueByPath as
|
|
10
|
-
const
|
|
11
|
-
fields:
|
|
12
|
-
wizard:
|
|
13
|
-
grid:
|
|
14
|
-
fullWidthModal:
|
|
1
|
+
import { jsx as A, jsxs as z } from "react/jsx-runtime";
|
|
2
|
+
import { Form as ee, Modal as te, Spin as oe } from "antd";
|
|
3
|
+
import { forwardRef as ae, useState as c, useCallback as F, useMemo as ne, useImperativeHandle as le, useEffect as se } from "react";
|
|
4
|
+
import { CrudForm as ie } from "../CrudForm.es.js";
|
|
5
|
+
import re from "../CrudFormWizard.es.js";
|
|
6
|
+
import { useTranslationLib as ce } from "../../locale/index.es.js";
|
|
7
|
+
import h from "../../util/CrudUtil.es.js";
|
|
8
|
+
import ue from "dayjs";
|
|
9
|
+
import { setValueByPath as u, getValueByPath as de } from "../../util/ObjectUtil.es.js";
|
|
10
|
+
const pe = ({
|
|
11
|
+
fields: s,
|
|
12
|
+
wizard: r,
|
|
13
|
+
grid: L,
|
|
14
|
+
fullWidthModal: E,
|
|
15
15
|
isCreating: C,
|
|
16
16
|
isUpdating: j,
|
|
17
17
|
onCreate: B,
|
|
18
18
|
onUpdate: V,
|
|
19
|
-
idField:
|
|
20
|
-
formBuilder:
|
|
21
|
-
onValuesChange:
|
|
22
|
-
},
|
|
23
|
-
const [
|
|
24
|
-
async (
|
|
25
|
-
var
|
|
26
|
-
const
|
|
27
|
-
for (const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
typeof e == "string" ? e : (
|
|
19
|
+
idField: N = "id",
|
|
20
|
+
formBuilder: $,
|
|
21
|
+
onValuesChange: w
|
|
22
|
+
}, q) => {
|
|
23
|
+
const [n] = ee.useForm(), { t: P } = ce(), [k, g] = c(!1), [f, R] = c("new"), [m, b] = c(), [G, v] = c(), [J, O] = c(!1), [K, M] = c(!1), [Q, W] = c(!1), D = F(
|
|
24
|
+
async (t) => {
|
|
25
|
+
var p;
|
|
26
|
+
const d = r ? t : await n.validateFields(), l = s.filter((o) => o.type === "color"), a = {};
|
|
27
|
+
for (const o of l) {
|
|
28
|
+
const i = h.getRealName(o.name, "upsertFieldName"), e = n.getFieldValue(i);
|
|
29
|
+
u(
|
|
30
|
+
a,
|
|
31
|
+
i,
|
|
32
|
+
typeof e == "string" ? e : (p = e == null ? void 0 : e.toHexString()) == null ? void 0 : p.toUpperCase()
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
|
-
Object.assign(
|
|
36
|
-
...
|
|
37
|
-
[
|
|
38
|
-
}),
|
|
35
|
+
Object.assign(d, a), m && V ? (await V({
|
|
36
|
+
...d,
|
|
37
|
+
[N]: m[N]
|
|
38
|
+
}), b(void 0)) : !m && B && await B(d), v(void 0), U(/* @__PURE__ */ new Map()), n.resetFields(), g(!1);
|
|
39
39
|
},
|
|
40
|
-
[
|
|
41
|
-
), H =
|
|
42
|
-
O(
|
|
43
|
-
}, []), I =
|
|
40
|
+
[s, n, N, B, V, m, r]
|
|
41
|
+
), H = F(async (t) => {
|
|
42
|
+
O(t), M(!0);
|
|
43
|
+
}, []), I = F(async () => {
|
|
44
44
|
M(!0);
|
|
45
|
-
}, []), T =
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
...
|
|
49
|
-
updatable:
|
|
50
|
-
} :
|
|
51
|
-
async (
|
|
45
|
+
}, []), T = F(() => {
|
|
46
|
+
g(!0), R("new"), n.resetFields(), b(void 0), v(void 0);
|
|
47
|
+
}, [n]), [S, U] = c(/* @__PURE__ */ new Map()), X = ne(() => S.size === 0 ? s : s.map((t) => typeof t.updatable == "function" ? {
|
|
48
|
+
...t,
|
|
49
|
+
updatable: S.get(h.getRealName(t.name, "name")) ?? t.updatable
|
|
50
|
+
} : t), [s, S]), _ = F(
|
|
51
|
+
async (t, d = !0, l = !1) => {
|
|
52
52
|
try {
|
|
53
|
-
W(!0),
|
|
54
|
-
const
|
|
55
|
-
for (const
|
|
56
|
-
const
|
|
57
|
-
|
|
53
|
+
W(!0), g(!0), R(l ? "clone" : "update");
|
|
54
|
+
const a = {};
|
|
55
|
+
for (const o of s) {
|
|
56
|
+
const i = h.getRealName(
|
|
57
|
+
o.name,
|
|
58
58
|
"upsertFieldName"
|
|
59
|
-
), e =
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
59
|
+
), e = de(t, i);
|
|
60
|
+
if (l && o.type === "image") {
|
|
61
|
+
const y = e;
|
|
62
62
|
try {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
if (Array.isArray(y)) {
|
|
64
|
+
const x = await Promise.all(
|
|
65
|
+
y.map((Z) => o.provider.clone(Z))
|
|
66
|
+
);
|
|
67
|
+
u(a, i, x);
|
|
68
|
+
} else if (y) {
|
|
69
|
+
const x = await o.provider.clone(y);
|
|
70
|
+
u(a, i, x);
|
|
71
|
+
}
|
|
65
72
|
continue;
|
|
66
73
|
} catch {
|
|
67
74
|
continue;
|
|
68
75
|
}
|
|
69
76
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
e.map((
|
|
74
|
-
) : e && typeof e == "object" ?
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
e[
|
|
78
|
-
) : (e && typeof e == "string" || typeof e == "number") &&
|
|
77
|
+
o.type === "date" || o.type === "time" ? e && u(a, i, ue(e)) : o.type === "select" ? o.multiple && Array.isArray(e) ? u(
|
|
78
|
+
a,
|
|
79
|
+
i,
|
|
80
|
+
e.map((y) => y[o.innerFieldId ?? "id"])
|
|
81
|
+
) : e && typeof e == "object" ? u(
|
|
82
|
+
a,
|
|
83
|
+
i,
|
|
84
|
+
e[o.innerFieldId ?? "id"]
|
|
85
|
+
) : (e && typeof e == "string" || typeof e == "number") && u(a, i, e) : u(a, i, e);
|
|
79
86
|
}
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
for (const
|
|
83
|
-
typeof
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
n.setFieldsValue(a);
|
|
88
|
+
const p = /* @__PURE__ */ new Map();
|
|
89
|
+
for (const o of s)
|
|
90
|
+
typeof o.updatable == "function" && p.set(
|
|
91
|
+
h.getRealName(o.name, "name"),
|
|
92
|
+
o.updatable(t)
|
|
86
93
|
);
|
|
87
|
-
|
|
94
|
+
U(p), v(a), d && b(t);
|
|
88
95
|
} finally {
|
|
89
96
|
W(!1);
|
|
90
97
|
}
|
|
91
98
|
},
|
|
92
|
-
[
|
|
99
|
+
[s, n]
|
|
93
100
|
);
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
le(
|
|
102
|
+
q,
|
|
96
103
|
() => ({
|
|
97
104
|
create: T,
|
|
98
105
|
update: _
|
|
99
106
|
}),
|
|
100
107
|
[T, _]
|
|
101
|
-
),
|
|
108
|
+
), se(() => {
|
|
102
109
|
k && (O(!1), M(!1));
|
|
103
110
|
}, [k]);
|
|
104
|
-
const
|
|
105
|
-
|
|
111
|
+
const Y = F(async () => {
|
|
112
|
+
U(/* @__PURE__ */ new Map());
|
|
106
113
|
try {
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
for (const
|
|
110
|
-
|
|
114
|
+
if (f === "clone") {
|
|
115
|
+
const t = r ? m : n.getFieldsValue(), d = s.filter((l) => l.type === "image");
|
|
116
|
+
for (const l of d)
|
|
117
|
+
if (t[l.name]) {
|
|
118
|
+
const a = Array.isArray(t[l.name]) ? t[l.name] : [t[l.name]];
|
|
119
|
+
for (const p of a)
|
|
120
|
+
l.provider.delete(p);
|
|
121
|
+
}
|
|
111
122
|
}
|
|
112
123
|
} finally {
|
|
113
124
|
}
|
|
114
|
-
|
|
115
|
-
}, [
|
|
116
|
-
return /* @__PURE__ */
|
|
117
|
-
|
|
125
|
+
r || n.resetFields(), v(void 0), b(void 0), g(!1);
|
|
126
|
+
}, [f, r, n, m, s]);
|
|
127
|
+
return /* @__PURE__ */ A(
|
|
128
|
+
te,
|
|
118
129
|
{
|
|
119
|
-
width:
|
|
120
|
-
title:
|
|
130
|
+
width: E ? "100%" : void 0,
|
|
131
|
+
title: P("str." + (f ?? "new")),
|
|
121
132
|
open: k,
|
|
122
133
|
confirmLoading: C || j,
|
|
123
|
-
okText:
|
|
124
|
-
cancelText:
|
|
134
|
+
okText: P("str." + (f === "update" ? "update" : "save")),
|
|
135
|
+
cancelText: P("str.cancel"),
|
|
125
136
|
cancelButtonProps: {
|
|
126
|
-
disabled:
|
|
127
|
-
hidden: !!
|
|
137
|
+
disabled: K,
|
|
138
|
+
hidden: !!r
|
|
128
139
|
},
|
|
129
140
|
okButtonProps: {
|
|
130
|
-
disabled:
|
|
131
|
-
hidden: !!
|
|
141
|
+
disabled: J,
|
|
142
|
+
hidden: !!r
|
|
132
143
|
},
|
|
133
|
-
onCancel:
|
|
144
|
+
onCancel: Y,
|
|
134
145
|
onOk: () => D(),
|
|
135
146
|
destroyOnHidden: !0,
|
|
136
|
-
children: /* @__PURE__ */
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
children: /* @__PURE__ */ z(oe, { spinning: Q, children: [
|
|
148
|
+
r ? null : /* @__PURE__ */ A(
|
|
149
|
+
ie,
|
|
139
150
|
{
|
|
140
|
-
purpose:
|
|
141
|
-
fields:
|
|
142
|
-
form:
|
|
143
|
-
formBuilder:
|
|
144
|
-
grid:
|
|
151
|
+
purpose: f,
|
|
152
|
+
fields: X,
|
|
153
|
+
form: n,
|
|
154
|
+
formBuilder: $,
|
|
155
|
+
grid: L,
|
|
145
156
|
onDeleteFile: I,
|
|
146
157
|
onUploadFile: H,
|
|
147
|
-
onValuesChange:
|
|
158
|
+
onValuesChange: w
|
|
148
159
|
}
|
|
149
160
|
),
|
|
150
|
-
|
|
151
|
-
|
|
161
|
+
r && /* @__PURE__ */ A(
|
|
162
|
+
re,
|
|
152
163
|
{
|
|
153
164
|
submitting: C || j,
|
|
154
165
|
className: "mt-2",
|
|
155
166
|
onSave: D,
|
|
156
|
-
updatingValue:
|
|
157
|
-
fields:
|
|
167
|
+
updatingValue: G,
|
|
168
|
+
fields: s,
|
|
158
169
|
onDeleteFile: I,
|
|
159
170
|
onUploadFile: H,
|
|
160
|
-
purpose:
|
|
161
|
-
wizard:
|
|
162
|
-
onValuesChange:
|
|
171
|
+
purpose: f,
|
|
172
|
+
wizard: r,
|
|
173
|
+
onValuesChange: w
|
|
163
174
|
}
|
|
164
175
|
)
|
|
165
176
|
] })
|
|
166
177
|
}
|
|
167
178
|
);
|
|
168
|
-
}, Ve =
|
|
179
|
+
}, Ve = ae(pe);
|
|
169
180
|
export {
|
|
170
181
|
Ve as default
|
|
171
182
|
};
|