@pnkx-lib/ui 1.9.463 → 1.9.465
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/GenericUploadModal.js +50 -32
- package/es/ui/UploadComponent.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Modal, Spin } from 'antd';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import React__default, { isValidElement, version as version$1, useRef, useLayoutEffect, useEffect, Component, useContext, forwardRef, useMemo as useMemo$1, useState, Children, useImperativeHandle } from 'react';
|
|
@@ -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 { ViewPdf } from './ViewPdf.js';
|
|
16
17
|
import { R as RefIcon$b } from '../chunks/InboxOutlined-W7xl_mLq.js';
|
|
17
18
|
|
|
18
19
|
// This icon file is generated automatically.
|
|
@@ -11485,6 +11486,7 @@ function GenericUploadModal({
|
|
|
11485
11486
|
texts
|
|
11486
11487
|
}) {
|
|
11487
11488
|
const [displayFileList, setDisplayFileList] = useState([]);
|
|
11489
|
+
const [previewPdf, setPreviewPdf] = useState(null);
|
|
11488
11490
|
useEffect(() => {
|
|
11489
11491
|
if (open) {
|
|
11490
11492
|
const recordFiles = record?.map((item) => ({
|
|
@@ -11528,13 +11530,19 @@ function GenericUploadModal({
|
|
|
11528
11530
|
return false;
|
|
11529
11531
|
},
|
|
11530
11532
|
onPreview: (file) => {
|
|
11531
|
-
const
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11533
|
+
const fileUrl = file.url || (file.originFileObj ? URL.createObjectURL(file.originFileObj) : "");
|
|
11534
|
+
const extension = file.name?.split(".").pop()?.toLowerCase();
|
|
11535
|
+
if (extension === "pdf") {
|
|
11536
|
+
setPreviewPdf(fileUrl);
|
|
11537
|
+
} else {
|
|
11538
|
+
const link = document.createElement("a");
|
|
11539
|
+
link.href = fileUrl;
|
|
11540
|
+
link.download = file.name || "download";
|
|
11541
|
+
link.target = "_blank";
|
|
11542
|
+
document.body.appendChild(link);
|
|
11543
|
+
link.click();
|
|
11544
|
+
document.body.removeChild(link);
|
|
11545
|
+
}
|
|
11538
11546
|
},
|
|
11539
11547
|
onRemove: (file) => {
|
|
11540
11548
|
const newList = displayFileList.filter((item) => item.uid !== file.uid);
|
|
@@ -11544,7 +11552,7 @@ function GenericUploadModal({
|
|
|
11544
11552
|
return true;
|
|
11545
11553
|
}
|
|
11546
11554
|
});
|
|
11547
|
-
return /* @__PURE__ */
|
|
11555
|
+
return /* @__PURE__ */ jsxs(
|
|
11548
11556
|
Modal,
|
|
11549
11557
|
{
|
|
11550
11558
|
open,
|
|
@@ -11554,30 +11562,40 @@ function GenericUploadModal({
|
|
|
11554
11562
|
onCancel,
|
|
11555
11563
|
onOk: onCancel,
|
|
11556
11564
|
width: 800,
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
const props = createUploadProps(onChange);
|
|
11565
|
-
return /* @__PURE__ */ jsx(Spin, { spinning: false, tip: texts?.uploading ?? "Uploading...", children: /* @__PURE__ */ jsxs(
|
|
11566
|
-
Dragger,
|
|
11567
|
-
{
|
|
11568
|
-
...props,
|
|
11569
|
-
accept: allowedExtensions.map((ext) => `.${ext}`).join(","),
|
|
11570
|
-
children: [
|
|
11571
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon$b, {}) }),
|
|
11572
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: texts?.dragText ?? "Click or drag files to this area to upload" }),
|
|
11573
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint1 ?? "Max size 5MB" }),
|
|
11574
|
-
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint2 ?? "Supported formats: " + allowedExtensions.join(", ") })
|
|
11575
|
-
]
|
|
11576
|
-
}
|
|
11577
|
-
) });
|
|
11565
|
+
centered: true,
|
|
11566
|
+
children: [
|
|
11567
|
+
previewPdf && /* @__PURE__ */ jsx(
|
|
11568
|
+
ViewPdf,
|
|
11569
|
+
{
|
|
11570
|
+
workerUrl: "https://unpkg.com/pdfjs-dist@3.4.120/build/pdf.worker.min.js",
|
|
11571
|
+
fileUrl: previewPdf
|
|
11578
11572
|
}
|
|
11579
|
-
|
|
11580
|
-
|
|
11573
|
+
),
|
|
11574
|
+
/* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(
|
|
11575
|
+
Controller,
|
|
11576
|
+
{
|
|
11577
|
+
name: "file",
|
|
11578
|
+
control,
|
|
11579
|
+
render: ({ field }) => {
|
|
11580
|
+
const { onChange } = field;
|
|
11581
|
+
const props = createUploadProps(onChange);
|
|
11582
|
+
return /* @__PURE__ */ jsx(Spin, { spinning: false, tip: texts?.uploading ?? "Uploading...", children: /* @__PURE__ */ jsxs(
|
|
11583
|
+
Dragger,
|
|
11584
|
+
{
|
|
11585
|
+
...props,
|
|
11586
|
+
accept: allowedExtensions.map((ext) => `.${ext}`).join(","),
|
|
11587
|
+
children: [
|
|
11588
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-drag-icon", children: /* @__PURE__ */ jsx(RefIcon$b, {}) }),
|
|
11589
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-text", children: texts?.dragText ?? "Click or drag files to this area to upload" }),
|
|
11590
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint1 ?? "Max size 5MB" }),
|
|
11591
|
+
/* @__PURE__ */ jsx("p", { className: "ant-upload-hint", children: texts?.hint2 ?? "Supported formats: " + allowedExtensions.join(", ") })
|
|
11592
|
+
]
|
|
11593
|
+
}
|
|
11594
|
+
) });
|
|
11595
|
+
}
|
|
11596
|
+
}
|
|
11597
|
+
) })
|
|
11598
|
+
]
|
|
11581
11599
|
}
|
|
11582
11600
|
);
|
|
11583
11601
|
}
|
package/es/ui/UploadComponent.js
CHANGED
|
@@ -41,7 +41,7 @@ const UploadComponent = ({
|
|
|
41
41
|
customRequest: async (options) => {
|
|
42
42
|
const { file, onSuccess, onError } = options;
|
|
43
43
|
try {
|
|
44
|
-
|
|
44
|
+
customRequest?.(file, field.onChange);
|
|
45
45
|
onSuccess?.({}, file);
|
|
46
46
|
} catch (err) {
|
|
47
47
|
onError?.(err);
|