@pnkx-lib/ui 1.9.466 → 1.9.467
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.
|
@@ -13,6 +13,7 @@ import { R as RefIcon$7 } from '../chunks/LoadingOutlined-C5-PNVpb.js';
|
|
|
13
13
|
import { R as RefIcon$8, a as RefIcon$a } from '../chunks/CloseCircleFilled-4jnV3XJV.js';
|
|
14
14
|
import { R as RefIcon$9 } from '../chunks/CloseOutlined-DdLJZQvZ.js';
|
|
15
15
|
import { C as Controller } from '../chunks/index.esm-Dr5ZHcf7.js';
|
|
16
|
+
import { toast } from '@pnkx-lib/core';
|
|
16
17
|
import { R as RefIcon$b } from '../chunks/InboxOutlined-W7xl_mLq.js';
|
|
17
18
|
|
|
18
19
|
// This icon file is generated automatically.
|
|
@@ -11479,7 +11480,6 @@ function GenericUploadModal({
|
|
|
11479
11480
|
control,
|
|
11480
11481
|
setFileList,
|
|
11481
11482
|
record,
|
|
11482
|
-
fileList,
|
|
11483
11483
|
allowedExtensions,
|
|
11484
11484
|
maxSize = 5,
|
|
11485
11485
|
texts
|
|
@@ -11503,17 +11503,17 @@ function GenericUploadModal({
|
|
|
11503
11503
|
showUploadList: true,
|
|
11504
11504
|
fileList: displayFileList,
|
|
11505
11505
|
beforeUpload: async (file) => {
|
|
11506
|
-
const isLtMax = file.size / 1024 / 1024
|
|
11506
|
+
const isLtMax = file.size / 1024 / 1024 <= maxSize;
|
|
11507
11507
|
const fileExtension = file.name.split(".").pop()?.toLowerCase() || "";
|
|
11508
|
-
if (
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
});
|
|
11512
|
-
return false;
|
|
11508
|
+
if (allowedExtensions.includes(fileExtension) && texts?.fileTypeError) {
|
|
11509
|
+
toast.warning(texts?.fileTypeError);
|
|
11510
|
+
return;
|
|
11513
11511
|
}
|
|
11514
11512
|
if (!isLtMax) {
|
|
11515
|
-
|
|
11516
|
-
|
|
11513
|
+
toast.warning(
|
|
11514
|
+
texts?.fileSizeError ?? `File must be smaller than ${maxSize}MB`
|
|
11515
|
+
);
|
|
11516
|
+
return;
|
|
11517
11517
|
}
|
|
11518
11518
|
const newFile = {
|
|
11519
11519
|
uid: file.uid,
|
|
@@ -11522,7 +11522,12 @@ function GenericUploadModal({
|
|
|
11522
11522
|
originFileObj: file
|
|
11523
11523
|
};
|
|
11524
11524
|
const newList = [...displayFileList, newFile];
|
|
11525
|
-
setDisplayFileList(
|
|
11525
|
+
setDisplayFileList((prev) => {
|
|
11526
|
+
const newList2 = [...prev, newFile];
|
|
11527
|
+
setFileList(newList2);
|
|
11528
|
+
onChange(newList2);
|
|
11529
|
+
return newList2;
|
|
11530
|
+
});
|
|
11526
11531
|
setFileList(newList);
|
|
11527
11532
|
onChange(newList);
|
|
11528
11533
|
return false;
|
|
@@ -11564,19 +11569,12 @@ function GenericUploadModal({
|
|
|
11564
11569
|
render: ({ field }) => {
|
|
11565
11570
|
const { onChange } = field;
|
|
11566
11571
|
const props = createUploadProps(onChange);
|
|
11567
|
-
return /* @__PURE__ */ jsx(Spin, { spinning: false, tip: texts?.uploading ?? "Uploading...", children: /* @__PURE__ */ jsxs(
|
|
11568
|
-
|
|
11569
|
-
{
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon$b, {}) }),
|
|
11574
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: texts?.dragText ?? "Click or drag files to this area to upload" }),
|
|
11575
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint1 ?? "Max size 5MB" }),
|
|
11576
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint2 ?? "Supported formats: " + allowedExtensions.join(", ") })
|
|
11577
|
-
]
|
|
11578
|
-
}
|
|
11579
|
-
) });
|
|
11572
|
+
return /* @__PURE__ */ jsx(Spin, { spinning: false, tip: texts?.uploading ?? "Uploading...", children: /* @__PURE__ */ jsxs(Dragger, { ...props, accept: ".pdf,.docx,image/*", children: [
|
|
11573
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon$b, {}) }),
|
|
11574
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: texts?.dragText ?? "Click or drag files to this area to upload" }),
|
|
11575
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint1 ?? "Max size 5MB" }),
|
|
11576
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint2 })
|
|
11577
|
+
] }) });
|
|
11580
11578
|
}
|
|
11581
11579
|
}
|
|
11582
11580
|
) })
|
package/package.json
CHANGED
|
@@ -5,7 +5,6 @@ export interface GenericUploadModalProps {
|
|
|
5
5
|
onCancel: () => void;
|
|
6
6
|
control: Control<any>;
|
|
7
7
|
setFileList(fileList: UploadFile[]): void;
|
|
8
|
-
fileList: UploadFile[];
|
|
9
8
|
/** danh sách file từ API để hiển thị */
|
|
10
9
|
record?: Array<{
|
|
11
10
|
filePath: string;
|
|
@@ -29,4 +28,4 @@ export interface GenericUploadModalProps {
|
|
|
29
28
|
uploading?: string;
|
|
30
29
|
};
|
|
31
30
|
}
|
|
32
|
-
export declare function GenericUploadModal({ open, onCancel, control, setFileList, record,
|
|
31
|
+
export declare function GenericUploadModal({ open, onCancel, control, setFileList, record, allowedExtensions, maxSize, texts, }: GenericUploadModalProps): import("react/jsx-runtime").JSX.Element;
|