@kingteza/crud-component 1.44.2 → 1.46.0
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 +2 -0
- package/dist/common/picker/ImagePicker.es.js +141 -135
- package/dist/crud/CrudField.cjs.js +1 -1
- package/dist/crud/CrudField.es.js +103 -101
- package/dist/crud/FileCrudField.cjs.js +1 -1
- package/dist/crud/FileCrudField.d.ts +2 -1
- package/dist/crud/FileCrudField.es.js +133 -132
- package/dist/crud/ImageCrudField.cjs.js +1 -1
- package/dist/crud/ImageCrudField.d.ts +3 -0
- package/dist/crud/ImageCrudField.es.js +115 -102
- package/package.json +1 -1
|
@@ -1,174 +1,187 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { EyeOutlined as
|
|
6
|
-
import { Avatar as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { v4 as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
class
|
|
1
|
+
var G = Object.defineProperty;
|
|
2
|
+
var J = (s, e, t) => e in s ? G(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var A = (s, e, t) => J(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { jsx as m, Fragment as b, jsxs as K } from "react/jsx-runtime";
|
|
5
|
+
import { EyeOutlined as L } from "@ant-design/icons";
|
|
6
|
+
import { Avatar as Q, Image as T, Form as N, Input as X } from "antd";
|
|
7
|
+
import k from "path-browserify";
|
|
8
|
+
import Y, { useState as Z, useEffect as C, useCallback as B, useImperativeHandle as R, useMemo as U } from "react";
|
|
9
|
+
import v from "../util/NumberUtil.es.js";
|
|
10
|
+
import ee from "../util/ValidationUtil.es.js";
|
|
11
|
+
import { v4 as te } from "uuid";
|
|
12
|
+
import re from "../common/picker/ImagePicker.es.js";
|
|
13
|
+
import ae from "../util/ImageUtil.es.js";
|
|
14
|
+
class se {
|
|
15
15
|
}
|
|
16
|
-
class
|
|
16
|
+
class ge extends se {
|
|
17
17
|
constructor(t = "", l = "") {
|
|
18
18
|
super();
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
A(this, "rootPath");
|
|
20
|
+
A(this, "subPath");
|
|
21
21
|
this.rootPath = t, this.subPath = l;
|
|
22
22
|
}
|
|
23
23
|
cloneFilePath(t) {
|
|
24
|
-
const l =
|
|
25
|
-
return
|
|
24
|
+
const l = k.parse(t), r = `${l.name}_cloned_${v.randInt(1e5)}`;
|
|
25
|
+
return k.format({
|
|
26
26
|
dir: l.dir,
|
|
27
27
|
ext: l.ext,
|
|
28
|
-
name:
|
|
28
|
+
name: r
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
generateFileName(t) {
|
|
32
|
-
return `${t.split(".")[0]}_${
|
|
32
|
+
return `${t.split(".")[0]}_${te().replace("-", "")}`;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function le({
|
|
36
36
|
formLayoutProps: s,
|
|
37
37
|
name: e,
|
|
38
38
|
label: t,
|
|
39
39
|
required: l,
|
|
40
|
-
provider:
|
|
41
|
-
onUploading:
|
|
42
|
-
aspectRatio:
|
|
43
|
-
onRemoved:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
provider: r,
|
|
41
|
+
onUploading: i,
|
|
42
|
+
aspectRatio: O,
|
|
43
|
+
onRemoved: o,
|
|
44
|
+
onUploadComplete: F,
|
|
45
|
+
fieldClassName: p,
|
|
46
|
+
hideLabel: j = !1,
|
|
47
|
+
listType: z,
|
|
48
|
+
fieldHelper: S,
|
|
49
|
+
showSkipCropButton: _ = !1,
|
|
50
|
+
skipCrop: x = !1,
|
|
51
|
+
skipResize: E = !1,
|
|
52
|
+
asyncUpload: H = !1,
|
|
51
53
|
maxCount: h = 1
|
|
52
|
-
},
|
|
53
|
-
const
|
|
54
|
-
(
|
|
55
|
-
[
|
|
56
|
-
),
|
|
57
|
-
async (
|
|
58
|
-
if (
|
|
59
|
-
|
|
54
|
+
}, M) {
|
|
55
|
+
const f = N.useFormInstance(), u = e, y = N.useWatch(u, f), D = B(
|
|
56
|
+
(a) => r.getRealUrl(a),
|
|
57
|
+
[r]
|
|
58
|
+
), P = B(
|
|
59
|
+
async (a, d) => {
|
|
60
|
+
if (d) {
|
|
61
|
+
i == null || i(!0);
|
|
60
62
|
try {
|
|
61
|
-
const
|
|
63
|
+
const n = a.name, c = n.split("."), $ = c[c.length - 1], g = r.generateFileName(n), I = `${await r.getInitialPath()}/${g}.${$}`, V = await r.upload(a, I);
|
|
64
|
+
F == null || F(V);
|
|
65
|
+
const w = f.getFieldValue(u);
|
|
62
66
|
if (h > 1) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
...
|
|
67
|
+
const q = Array.isArray(w) ? w : w ? [w] : [];
|
|
68
|
+
f.setFieldValue(u, [
|
|
69
|
+
...q,
|
|
66
70
|
V
|
|
67
71
|
].filter(Boolean));
|
|
68
72
|
} else
|
|
69
|
-
|
|
73
|
+
f.setFieldValue(u, V);
|
|
70
74
|
return V;
|
|
71
75
|
} finally {
|
|
72
|
-
|
|
76
|
+
i == null || i(!1);
|
|
73
77
|
}
|
|
74
78
|
} else {
|
|
75
|
-
const
|
|
79
|
+
const n = f.getFieldValue(u);
|
|
76
80
|
if (h > 1) {
|
|
77
|
-
const c =
|
|
81
|
+
const c = a.response ?? (typeof a.uid == "string" ? a.uid : void 0);
|
|
78
82
|
if (!c) return;
|
|
79
|
-
await
|
|
80
|
-
const
|
|
81
|
-
|
|
83
|
+
await r.delete(c), o == null || o();
|
|
84
|
+
const g = (Array.isArray(n) ? n : n ? [n] : []).filter((I) => I !== c);
|
|
85
|
+
f.setFieldValue(
|
|
82
86
|
u,
|
|
83
|
-
|
|
87
|
+
g.length ? g : null
|
|
84
88
|
);
|
|
85
89
|
} else {
|
|
86
|
-
const c = await
|
|
87
|
-
|
|
90
|
+
const c = await r.delete(n);
|
|
91
|
+
o == null || o(), c && f.setFieldValue(u, null);
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
},
|
|
91
|
-
[
|
|
95
|
+
[
|
|
96
|
+
f,
|
|
97
|
+
h,
|
|
98
|
+
u,
|
|
99
|
+
o,
|
|
100
|
+
F,
|
|
101
|
+
i,
|
|
102
|
+
r
|
|
103
|
+
]
|
|
92
104
|
);
|
|
93
|
-
|
|
94
|
-
|
|
105
|
+
R(
|
|
106
|
+
M,
|
|
95
107
|
() => ({
|
|
96
|
-
async uploadBlob(
|
|
97
|
-
const
|
|
98
|
-
name:
|
|
99
|
-
uid:
|
|
100
|
-
url:
|
|
101
|
-
originFileObj:
|
|
108
|
+
async uploadBlob(a, d) {
|
|
109
|
+
const n = await ae.getBase64(a), c = {
|
|
110
|
+
name: d,
|
|
111
|
+
uid: d + Math.random().toString(36).substring(2, 15),
|
|
112
|
+
url: n,
|
|
113
|
+
originFileObj: a
|
|
102
114
|
};
|
|
103
|
-
await
|
|
115
|
+
await P(c, !0);
|
|
104
116
|
}
|
|
105
117
|
}),
|
|
106
|
-
[
|
|
118
|
+
[P]
|
|
107
119
|
);
|
|
108
|
-
const
|
|
109
|
-
return /* @__PURE__ */
|
|
110
|
-
|
|
120
|
+
const W = U(() => y ? (Array.isArray(y), y) : h > 1 ? [] : void 0, [y, h]);
|
|
121
|
+
return /* @__PURE__ */ K(
|
|
122
|
+
N.Item,
|
|
111
123
|
{
|
|
112
|
-
rules: l ?
|
|
113
|
-
label:
|
|
124
|
+
rules: l ? ee.required(t) : [],
|
|
125
|
+
label: j ? null : t,
|
|
114
126
|
required: l,
|
|
115
127
|
name: u,
|
|
116
|
-
help:
|
|
128
|
+
help: S,
|
|
117
129
|
...s,
|
|
118
|
-
className:
|
|
130
|
+
className: p,
|
|
119
131
|
children: [
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
|
|
132
|
+
/* @__PURE__ */ m(
|
|
133
|
+
re,
|
|
122
134
|
{
|
|
123
135
|
noStyle: !0,
|
|
124
|
-
asyncUpload:
|
|
125
|
-
listType:
|
|
126
|
-
aspectRatio:
|
|
127
|
-
values:
|
|
128
|
-
getRealUrl:
|
|
129
|
-
onRemove: (
|
|
130
|
-
|
|
136
|
+
asyncUpload: H,
|
|
137
|
+
listType: z,
|
|
138
|
+
aspectRatio: O,
|
|
139
|
+
values: W,
|
|
140
|
+
getRealUrl: D,
|
|
141
|
+
onRemove: (a) => {
|
|
142
|
+
a && P(a, !1);
|
|
131
143
|
},
|
|
132
|
-
onAdd: async (
|
|
133
|
-
if (
|
|
144
|
+
onAdd: async (a) => {
|
|
145
|
+
if (a) return P(a, !0);
|
|
134
146
|
},
|
|
135
|
-
className:
|
|
136
|
-
showSkipCropButton:
|
|
137
|
-
|
|
147
|
+
className: p,
|
|
148
|
+
showSkipCropButton: _,
|
|
149
|
+
skipCrop: x,
|
|
150
|
+
skipResize: E,
|
|
138
151
|
maxCount: h
|
|
139
152
|
}
|
|
140
153
|
),
|
|
141
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ m(X, { hidden: !0 })
|
|
142
155
|
]
|
|
143
156
|
}
|
|
144
157
|
);
|
|
145
158
|
}
|
|
146
|
-
const
|
|
147
|
-
const [t, l] =
|
|
148
|
-
return
|
|
159
|
+
const Ve = Y.forwardRef(le), we = ({ provider: s, value: e }) => {
|
|
160
|
+
const [t, l] = Z([]);
|
|
161
|
+
return C(() => {
|
|
149
162
|
if (!e) {
|
|
150
163
|
l([]);
|
|
151
164
|
return;
|
|
152
165
|
}
|
|
153
|
-
const
|
|
154
|
-
Promise.all(
|
|
166
|
+
const r = Array.isArray(e) ? e : [e];
|
|
167
|
+
Promise.all(r.filter(Boolean).map((i) => s.getRealUrl(i))).then(
|
|
155
168
|
l
|
|
156
169
|
);
|
|
157
|
-
}, [s, e]), t.length ? /* @__PURE__ */
|
|
158
|
-
},
|
|
159
|
-
|
|
170
|
+
}, [s, e]), t.length ? /* @__PURE__ */ m(b, { children: t.map((r) => /* @__PURE__ */ m(ie, { url: r }, r)) }) : /* @__PURE__ */ m(b, {});
|
|
171
|
+
}, ie = ({ url: s }) => /* @__PURE__ */ m(Q, { className: "p-0", children: /* @__PURE__ */ m(
|
|
172
|
+
T,
|
|
160
173
|
{
|
|
161
174
|
className: "m-0 p-0 position-relative",
|
|
162
175
|
src: s,
|
|
163
176
|
preview: {
|
|
164
|
-
mask: /* @__PURE__ */
|
|
177
|
+
mask: /* @__PURE__ */ m(L, {})
|
|
165
178
|
}
|
|
166
179
|
}
|
|
167
180
|
) });
|
|
168
181
|
export {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
182
|
+
se as FileDownloadProvider,
|
|
183
|
+
ge as FileUploadProvider,
|
|
184
|
+
ie as ImageCellValue,
|
|
185
|
+
we as ImageCrudCellValue,
|
|
186
|
+
Ve as default
|
|
174
187
|
};
|