@pnkx-lib/ui 1.9.349 → 1.9.352
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/es/ui/UploadComponent.js
CHANGED
|
@@ -19,10 +19,13 @@ const UploadComponent = ({
|
|
|
19
19
|
customStyleContainer,
|
|
20
20
|
content = "Tải hình ảnh lên",
|
|
21
21
|
description = "Ảnh có kích thước 400x400 px và dung lượng ảnh < 1 mb",
|
|
22
|
-
|
|
22
|
+
customRequest,
|
|
23
23
|
...restProps
|
|
24
24
|
}) => {
|
|
25
25
|
const imageUrl = field?.value;
|
|
26
|
+
const handleRemoveImage = () => {
|
|
27
|
+
field.onChange(null);
|
|
28
|
+
};
|
|
26
29
|
return /* @__PURE__ */ jsxs("div", { className: customStyleContainer, children: [
|
|
27
30
|
label && /* @__PURE__ */ jsx(Label, { label, required }),
|
|
28
31
|
/* @__PURE__ */ jsx(
|
|
@@ -32,6 +35,16 @@ const UploadComponent = ({
|
|
|
32
35
|
showUploadList: false,
|
|
33
36
|
className: "custom-upload-wrapper",
|
|
34
37
|
accept: "image/*",
|
|
38
|
+
customRequest: async (options) => {
|
|
39
|
+
const { file, onSuccess, onError } = options;
|
|
40
|
+
try {
|
|
41
|
+
const url = await customRequest?.(file);
|
|
42
|
+
field.onChange(url);
|
|
43
|
+
onSuccess?.({ url }, file);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
onError?.(error);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
35
48
|
children: /* @__PURE__ */ jsx("div", { children: loading ? /* @__PURE__ */ jsx(Spin, {}) : imageUrl || imageUpload ? /* @__PURE__ */ jsx("div", { className: customStyleUpload, children: /* @__PURE__ */ jsxs(
|
|
36
49
|
"div",
|
|
37
50
|
{
|
package/package.json
CHANGED
|
@@ -9,10 +9,9 @@ interface UploadImageProps extends UploadProps {
|
|
|
9
9
|
imageUpload?: string | null;
|
|
10
10
|
errorMessage?: string;
|
|
11
11
|
loading?: boolean;
|
|
12
|
-
setImageUpload?:
|
|
12
|
+
setImageUpload?: (value: string) => void;
|
|
13
13
|
content?: string;
|
|
14
14
|
description?: string;
|
|
15
|
-
handleRemoveImage?: any;
|
|
16
15
|
}
|
|
17
16
|
export declare const UploadComponent: React.FC<UploadImageProps & {
|
|
18
17
|
field: any;
|