@kingteza/crud-component 1.45.0 → 1.46.1
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/rich/index.cjs.js +2 -2
- package/dist/common/rich/index.es.js +79 -75
- 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 +1 -0
- package/dist/crud/ImageCrudField.es.js +114 -103
- package/package.json +1 -1
|
@@ -1,176 +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
|
|
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
13
|
import ae from "../util/ImageUtil.es.js";
|
|
14
|
-
class
|
|
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
|
-
|
|
51
|
-
|
|
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,
|
|
52
53
|
maxCount: h = 1
|
|
53
|
-
},
|
|
54
|
-
const
|
|
55
|
-
(
|
|
56
|
-
[
|
|
57
|
-
),
|
|
58
|
-
async (
|
|
59
|
-
if (
|
|
60
|
-
|
|
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);
|
|
61
62
|
try {
|
|
62
|
-
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);
|
|
63
66
|
if (h > 1) {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
...
|
|
67
|
+
const q = Array.isArray(w) ? w : w ? [w] : [];
|
|
68
|
+
f.setFieldValue(u, [
|
|
69
|
+
...q,
|
|
67
70
|
V
|
|
68
71
|
].filter(Boolean));
|
|
69
72
|
} else
|
|
70
|
-
|
|
73
|
+
f.setFieldValue(u, V);
|
|
71
74
|
return V;
|
|
72
75
|
} finally {
|
|
73
|
-
|
|
76
|
+
i == null || i(!1);
|
|
74
77
|
}
|
|
75
78
|
} else {
|
|
76
|
-
const
|
|
79
|
+
const n = f.getFieldValue(u);
|
|
77
80
|
if (h > 1) {
|
|
78
|
-
const c =
|
|
81
|
+
const c = a.response ?? (typeof a.uid == "string" ? a.uid : void 0);
|
|
79
82
|
if (!c) return;
|
|
80
|
-
await
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
+
await r.delete(c), o == null || o();
|
|
84
|
+
const g = (Array.isArray(n) ? n : n ? [n] : []).filter((I) => I !== c);
|
|
85
|
+
f.setFieldValue(
|
|
83
86
|
u,
|
|
84
|
-
|
|
87
|
+
g.length ? g : null
|
|
85
88
|
);
|
|
86
89
|
} else {
|
|
87
|
-
const c = await
|
|
88
|
-
|
|
90
|
+
const c = await r.delete(n);
|
|
91
|
+
o == null || o(), c && f.setFieldValue(u, null);
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
94
|
},
|
|
92
|
-
[
|
|
95
|
+
[
|
|
96
|
+
f,
|
|
97
|
+
h,
|
|
98
|
+
u,
|
|
99
|
+
o,
|
|
100
|
+
F,
|
|
101
|
+
i,
|
|
102
|
+
r
|
|
103
|
+
]
|
|
93
104
|
);
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
R(
|
|
106
|
+
M,
|
|
96
107
|
() => ({
|
|
97
|
-
async uploadBlob(
|
|
98
|
-
const
|
|
99
|
-
name:
|
|
100
|
-
uid:
|
|
101
|
-
url:
|
|
102
|
-
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
|
|
103
114
|
};
|
|
104
|
-
await
|
|
115
|
+
await P(c, !0);
|
|
105
116
|
}
|
|
106
117
|
}),
|
|
107
|
-
[
|
|
118
|
+
[P]
|
|
108
119
|
);
|
|
109
|
-
const
|
|
110
|
-
return /* @__PURE__ */
|
|
111
|
-
|
|
120
|
+
const W = U(() => y ? (Array.isArray(y), y) : h > 1 ? [] : void 0, [y, h]);
|
|
121
|
+
return /* @__PURE__ */ K(
|
|
122
|
+
N.Item,
|
|
112
123
|
{
|
|
113
|
-
rules: l ?
|
|
114
|
-
label:
|
|
124
|
+
rules: l ? ee.required(t) : [],
|
|
125
|
+
label: j ? null : t,
|
|
115
126
|
required: l,
|
|
116
127
|
name: u,
|
|
117
|
-
help:
|
|
128
|
+
help: S,
|
|
118
129
|
...s,
|
|
119
|
-
className:
|
|
130
|
+
className: p,
|
|
120
131
|
children: [
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
|
|
132
|
+
/* @__PURE__ */ m(
|
|
133
|
+
re,
|
|
123
134
|
{
|
|
124
135
|
noStyle: !0,
|
|
125
|
-
asyncUpload:
|
|
126
|
-
listType:
|
|
127
|
-
aspectRatio:
|
|
128
|
-
values:
|
|
129
|
-
getRealUrl:
|
|
130
|
-
onRemove: (
|
|
131
|
-
|
|
136
|
+
asyncUpload: H,
|
|
137
|
+
listType: z,
|
|
138
|
+
aspectRatio: O,
|
|
139
|
+
values: W,
|
|
140
|
+
getRealUrl: D,
|
|
141
|
+
onRemove: (a) => {
|
|
142
|
+
a && P(a, !1);
|
|
132
143
|
},
|
|
133
|
-
onAdd: async (
|
|
134
|
-
if (
|
|
144
|
+
onAdd: async (a) => {
|
|
145
|
+
if (a) return P(a, !0);
|
|
135
146
|
},
|
|
136
|
-
className:
|
|
137
|
-
showSkipCropButton:
|
|
138
|
-
skipCrop:
|
|
139
|
-
skipResize:
|
|
147
|
+
className: p,
|
|
148
|
+
showSkipCropButton: _,
|
|
149
|
+
skipCrop: x,
|
|
150
|
+
skipResize: E,
|
|
140
151
|
maxCount: h
|
|
141
152
|
}
|
|
142
153
|
),
|
|
143
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ m(X, { hidden: !0 })
|
|
144
155
|
]
|
|
145
156
|
}
|
|
146
157
|
);
|
|
147
158
|
}
|
|
148
|
-
const
|
|
149
|
-
const [t, l] =
|
|
150
|
-
return
|
|
159
|
+
const Ve = Y.forwardRef(le), we = ({ provider: s, value: e }) => {
|
|
160
|
+
const [t, l] = Z([]);
|
|
161
|
+
return C(() => {
|
|
151
162
|
if (!e) {
|
|
152
163
|
l([]);
|
|
153
164
|
return;
|
|
154
165
|
}
|
|
155
|
-
const
|
|
156
|
-
Promise.all(
|
|
166
|
+
const r = Array.isArray(e) ? e : [e];
|
|
167
|
+
Promise.all(r.filter(Boolean).map((i) => s.getRealUrl(i))).then(
|
|
157
168
|
l
|
|
158
169
|
);
|
|
159
|
-
}, [s, e]), t.length ? /* @__PURE__ */
|
|
160
|
-
},
|
|
161
|
-
|
|
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,
|
|
162
173
|
{
|
|
163
174
|
className: "m-0 p-0 position-relative",
|
|
164
175
|
src: s,
|
|
165
176
|
preview: {
|
|
166
|
-
mask: /* @__PURE__ */
|
|
177
|
+
mask: /* @__PURE__ */ m(L, {})
|
|
167
178
|
}
|
|
168
179
|
}
|
|
169
180
|
) });
|
|
170
181
|
export {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
182
|
+
se as FileDownloadProvider,
|
|
183
|
+
ge as FileUploadProvider,
|
|
184
|
+
ie as ImageCellValue,
|
|
185
|
+
we as ImageCrudCellValue,
|
|
186
|
+
Ve as default
|
|
176
187
|
};
|