@kingteza/crud-component 1.10.0 → 1.10.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UploadListType } from 'antd/es/upload/interface';
|
|
2
2
|
import { UploadFile } from 'antd/lib';
|
|
3
|
-
import {
|
|
3
|
+
import { FC, ReactElement, Ref } from 'react';
|
|
4
4
|
import { InitialCrudField } from './CrudComponent';
|
|
5
5
|
export interface _ImageCrudField<T> extends InitialCrudField<T> {
|
|
6
6
|
provider: FileUploadProvider;
|
|
@@ -31,9 +31,10 @@ export declare abstract class FileUploadProvider extends FileDownloadProvider {
|
|
|
31
31
|
export interface ImageCrudFieldRef {
|
|
32
32
|
uploadBlob: (blob: Blob, fileName: string) => Promise<void>;
|
|
33
33
|
}
|
|
34
|
-
declare
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
declare const ImageCrudField: <T>(p: Readonly<_ImageCrudField<T>> & {
|
|
35
|
+
ref?: Ref<ImageCrudFieldRef>;
|
|
36
|
+
}) => ReactElement;
|
|
37
|
+
export default ImageCrudField;
|
|
37
38
|
export declare const ImageCrudCellValue: FC<{
|
|
38
39
|
value: string;
|
|
39
40
|
provider: FileDownloadProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var A = Object.defineProperty;
|
|
2
2
|
var B = (e, s, t) => s in e ? A(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
|
|
3
|
-
var
|
|
3
|
+
var p = (e, s, t) => B(e, typeof s != "symbol" ? s + "" : s, t);
|
|
4
4
|
import { jsx as n, Fragment as E, jsxs as H } from "react/jsx-runtime";
|
|
5
5
|
/* empty css */
|
|
6
6
|
import { EyeOutlined as D } from "@ant-design/icons";
|
|
@@ -14,11 +14,11 @@ import R from "../common/picker/ImagePicker.es.js";
|
|
|
14
14
|
import T from "../util/ImageUtil.es.js";
|
|
15
15
|
class X {
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class ue extends X {
|
|
18
18
|
constructor(t = "", a = "") {
|
|
19
19
|
super();
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
p(this, "rootPath");
|
|
21
|
+
p(this, "subPath");
|
|
22
22
|
this.rootPath = t, this.subPath = a;
|
|
23
23
|
}
|
|
24
24
|
cloneFilePath(t) {
|
|
@@ -40,46 +40,46 @@ function Y({
|
|
|
40
40
|
provider: a,
|
|
41
41
|
onUploading: l,
|
|
42
42
|
aspectRatio: P,
|
|
43
|
-
onRemoved:
|
|
44
|
-
fieldClassName:
|
|
45
|
-
hideLabel:
|
|
46
|
-
listType:
|
|
43
|
+
onRemoved: u,
|
|
44
|
+
fieldClassName: V,
|
|
45
|
+
hideLabel: x = !1,
|
|
46
|
+
listType: C,
|
|
47
47
|
fieldHelper: $
|
|
48
48
|
}, b) {
|
|
49
|
-
const
|
|
49
|
+
const o = d.useFormInstance(), h = d.useWatch(e, o), [w, O] = I(!1), m = G(
|
|
50
50
|
async (r, f) => {
|
|
51
51
|
if (f) {
|
|
52
52
|
l == null || l(!0);
|
|
53
|
-
const i = r.name,
|
|
54
|
-
O(!0), l == null || l(!1),
|
|
53
|
+
const i = r.name, c = i.split("."), j = c[c.length - 1], k = a.generateFileName(i), S = `${await a.getInitialPath()}/${k}.${j}`, _ = await a.upload(r, S);
|
|
54
|
+
O(!0), l == null || l(!1), o.setFieldValue(e, _);
|
|
55
55
|
} else {
|
|
56
|
-
const i =
|
|
57
|
-
|
|
56
|
+
const i = o.getFieldsValue(), c = await a.delete(i[e]);
|
|
57
|
+
u == null || u(), c && o.setFieldsValue({ [e]: null });
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
[
|
|
61
|
-
), [
|
|
60
|
+
[o, e, u, l, a]
|
|
61
|
+
), [F, g] = I();
|
|
62
62
|
return y(() => {
|
|
63
|
-
!w && h ? a.getRealUrl(h).then(g) : g(
|
|
64
|
-
}, [h, w, a,
|
|
63
|
+
!w && h ? a.getRealUrl(h).then(g) : g(F);
|
|
64
|
+
}, [h, w, a, F]), J(
|
|
65
65
|
b,
|
|
66
66
|
() => ({
|
|
67
67
|
async uploadBlob(r, f) {
|
|
68
|
-
const i = await T.getBase64(r),
|
|
68
|
+
const i = await T.getBase64(r), c = {
|
|
69
69
|
name: f,
|
|
70
70
|
uid: f + Math.random().toString(36).substring(2, 15),
|
|
71
71
|
url: i,
|
|
72
72
|
originFileObj: r
|
|
73
73
|
};
|
|
74
|
-
return
|
|
74
|
+
return m(c, !0);
|
|
75
75
|
}
|
|
76
76
|
}),
|
|
77
|
-
[
|
|
77
|
+
[m]
|
|
78
78
|
), /* @__PURE__ */ H(
|
|
79
79
|
d.Item,
|
|
80
80
|
{
|
|
81
81
|
rules: t ? L.required(s) : [],
|
|
82
|
-
label:
|
|
82
|
+
label: x ? null : s,
|
|
83
83
|
required: t,
|
|
84
84
|
name: e,
|
|
85
85
|
help: $,
|
|
@@ -88,16 +88,16 @@ function Y({
|
|
|
88
88
|
R,
|
|
89
89
|
{
|
|
90
90
|
noStyle: !0,
|
|
91
|
-
listType:
|
|
91
|
+
listType: C,
|
|
92
92
|
aspectRatio: P,
|
|
93
|
-
values:
|
|
93
|
+
values: F,
|
|
94
94
|
onRemove: (r) => {
|
|
95
|
-
r &&
|
|
95
|
+
r && m(r, !1);
|
|
96
96
|
},
|
|
97
97
|
onAdd: async (r) => {
|
|
98
|
-
r && await
|
|
98
|
+
r && await m(r, !0);
|
|
99
99
|
},
|
|
100
|
-
className:
|
|
100
|
+
className: V
|
|
101
101
|
}
|
|
102
102
|
),
|
|
103
103
|
/* @__PURE__ */ n(q, { hidden: !0 })
|
|
@@ -105,7 +105,7 @@ function Y({
|
|
|
105
105
|
}
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
|
-
const
|
|
108
|
+
const me = z.forwardRef(Y), fe = ({ provider: e, value: s }) => {
|
|
109
109
|
const [t, a] = I();
|
|
110
110
|
return y(() => {
|
|
111
111
|
s && e.getRealUrl(s).then(a);
|
|
@@ -122,8 +122,8 @@ const ue = z.forwardRef(Y), fe = ({ provider: e, value: s }) => {
|
|
|
122
122
|
) });
|
|
123
123
|
export {
|
|
124
124
|
X as FileDownloadProvider,
|
|
125
|
-
|
|
125
|
+
ue as FileUploadProvider,
|
|
126
126
|
Z as ImageCellValue,
|
|
127
127
|
fe as ImageCrudCellValue,
|
|
128
|
-
|
|
128
|
+
me as default
|
|
129
129
|
};
|