@deepnoid/ui 0.1.165 → 0.1.167
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/.turbo/turbo-build.log +165 -165
- package/dist/{chunk-OOX5X2MN.mjs → chunk-4XEZQMLU.mjs} +40 -18
- package/dist/components/fileUpload/fileUpload.d.mts +8 -2
- package/dist/components/fileUpload/fileUpload.d.ts +8 -2
- package/dist/components/fileUpload/fileUpload.js +40 -18
- package/dist/components/fileUpload/fileUpload.mjs +1 -1
- package/dist/components/fileUpload/index.d.mts +1 -1
- package/dist/components/fileUpload/index.d.ts +1 -1
- package/dist/components/fileUpload/index.js +40 -18
- package/dist/components/fileUpload/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -18
- package/dist/index.mjs +17 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12342,29 +12342,32 @@ function FileUpload({
|
|
|
12342
12342
|
helperMessage,
|
|
12343
12343
|
showProgress,
|
|
12344
12344
|
name,
|
|
12345
|
-
classNames
|
|
12345
|
+
classNames,
|
|
12346
|
+
defaultFile
|
|
12346
12347
|
}) {
|
|
12347
12348
|
const fileInputRef = (0, import_react37.useRef)(null);
|
|
12348
12349
|
const uploadIntervalRef = (0, import_react37.useRef)(null);
|
|
12349
|
-
const [
|
|
12350
|
+
const [currentFile, setCurrentFile] = (0, import_react37.useState)(null);
|
|
12350
12351
|
const [uploadProgress, setUploadProgress] = (0, import_react37.useState)(0);
|
|
12351
12352
|
const [message, setMessage] = (0, import_react37.useState)(errorMessage);
|
|
12353
|
+
const [displayFileName, setDisplayFileName] = (0, import_react37.useState)(() => (defaultFile == null ? void 0 : defaultFile.name) || "");
|
|
12354
|
+
const [hasUploadedFile, setHasUploadedFile] = (0, import_react37.useState)(false);
|
|
12352
12355
|
const slots = fileUploadStyle();
|
|
12353
12356
|
const handleButtonClick = () => {
|
|
12354
12357
|
var _a;
|
|
12355
12358
|
(_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
12356
12359
|
};
|
|
12357
|
-
const validateFile = (
|
|
12358
|
-
if (accept.length && !accept.includes(
|
|
12360
|
+
const validateFile = (file) => {
|
|
12361
|
+
if (accept.length && !accept.includes(file.type)) {
|
|
12359
12362
|
return acceptErrorMessage;
|
|
12360
12363
|
}
|
|
12361
|
-
const sizeMB =
|
|
12364
|
+
const sizeMB = file.size / 1024 / 1024;
|
|
12362
12365
|
if (sizeMB > maxSizeMB) {
|
|
12363
12366
|
return `${sizeErrorMessage} (${maxSizeMB}MB)`;
|
|
12364
12367
|
}
|
|
12365
12368
|
return null;
|
|
12366
12369
|
};
|
|
12367
|
-
const startUploadSimulation = (
|
|
12370
|
+
const startUploadSimulation = (file) => {
|
|
12368
12371
|
let progress = 0;
|
|
12369
12372
|
setUploadProgress(0);
|
|
12370
12373
|
uploadIntervalRef.current = window.setInterval(() => {
|
|
@@ -12372,7 +12375,7 @@ function FileUpload({
|
|
|
12372
12375
|
setUploadProgress(progress);
|
|
12373
12376
|
if (progress >= 100) {
|
|
12374
12377
|
clearInterval(uploadIntervalRef.current);
|
|
12375
|
-
onFileUpload == null ? void 0 : onFileUpload(
|
|
12378
|
+
onFileUpload == null ? void 0 : onFileUpload(file);
|
|
12376
12379
|
}
|
|
12377
12380
|
}, 100);
|
|
12378
12381
|
};
|
|
@@ -12383,20 +12386,26 @@ function FileUpload({
|
|
|
12383
12386
|
const error = validateFile(selectedFile);
|
|
12384
12387
|
if (error) {
|
|
12385
12388
|
setMessage(error);
|
|
12386
|
-
|
|
12389
|
+
setCurrentFile(null);
|
|
12390
|
+
setDisplayFileName((defaultFile == null ? void 0 : defaultFile.name) || "");
|
|
12391
|
+
setHasUploadedFile(false);
|
|
12387
12392
|
return;
|
|
12388
12393
|
}
|
|
12389
|
-
|
|
12394
|
+
setCurrentFile(selectedFile);
|
|
12395
|
+
setDisplayFileName(selectedFile.name);
|
|
12390
12396
|
setMessage("");
|
|
12397
|
+
setHasUploadedFile(true);
|
|
12391
12398
|
startUploadSimulation(selectedFile);
|
|
12392
12399
|
};
|
|
12393
12400
|
const handleCancelUpload = () => {
|
|
12394
12401
|
if (uploadIntervalRef.current) {
|
|
12395
12402
|
clearInterval(uploadIntervalRef.current);
|
|
12396
12403
|
}
|
|
12397
|
-
|
|
12404
|
+
setCurrentFile(null);
|
|
12398
12405
|
setUploadProgress(0);
|
|
12399
12406
|
setMessage("");
|
|
12407
|
+
setDisplayFileName((defaultFile == null ? void 0 : defaultFile.name) || "");
|
|
12408
|
+
setHasUploadedFile(false);
|
|
12400
12409
|
if (onCancelUpload) onCancelUpload();
|
|
12401
12410
|
};
|
|
12402
12411
|
(0, import_react37.useEffect)(() => {
|
|
@@ -12407,8 +12416,11 @@ function FileUpload({
|
|
|
12407
12416
|
};
|
|
12408
12417
|
}, []);
|
|
12409
12418
|
(0, import_react37.useEffect)(() => {
|
|
12410
|
-
|
|
12411
|
-
|
|
12419
|
+
if (errorMessage !== void 0) {
|
|
12420
|
+
setMessage(errorMessage);
|
|
12421
|
+
}
|
|
12422
|
+
}, [errorMessage]);
|
|
12423
|
+
const shouldShowCloseButton = hasUploadedFile;
|
|
12412
12424
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: slots.base({ class: classNames == null ? void 0 : classNames.base }), children: [
|
|
12413
12425
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: slots.container({ class: classNames == null ? void 0 : classNames.container }), children: [
|
|
12414
12426
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: slots.inputWrapper(), children: [
|
|
@@ -12420,14 +12432,15 @@ function FileUpload({
|
|
|
12420
12432
|
variant: "outline",
|
|
12421
12433
|
full: true,
|
|
12422
12434
|
placeholder,
|
|
12423
|
-
|
|
12424
|
-
errorMessage: message
|
|
12435
|
+
value: displayFileName,
|
|
12436
|
+
errorMessage: message && (message == null ? void 0 : message.length) > 0 ? message : void 0
|
|
12425
12437
|
}
|
|
12426
12438
|
),
|
|
12427
|
-
|
|
12439
|
+
shouldShowCloseButton && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12428
12440
|
icon_button_default,
|
|
12429
12441
|
{
|
|
12430
12442
|
name: "close",
|
|
12443
|
+
size: "sm",
|
|
12431
12444
|
variant: "ghost",
|
|
12432
12445
|
color: "neutral",
|
|
12433
12446
|
onClick: handleCancelUpload,
|
|
@@ -12436,10 +12449,19 @@ function FileUpload({
|
|
|
12436
12449
|
}
|
|
12437
12450
|
)
|
|
12438
12451
|
] }),
|
|
12439
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12452
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
12453
|
+
button_default,
|
|
12454
|
+
{
|
|
12455
|
+
type: "button",
|
|
12456
|
+
variant: "outline",
|
|
12457
|
+
onClick: handleButtonClick,
|
|
12458
|
+
disabled: !!(currentFile && hasUploadedFile),
|
|
12459
|
+
children: buttonText
|
|
12460
|
+
}
|
|
12461
|
+
),
|
|
12440
12462
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("input", { ref: fileInputRef, type: "file", hidden: true, accept: accept.join(","), onChange: handleFileChange })
|
|
12441
12463
|
] }),
|
|
12442
|
-
showProgress &&
|
|
12464
|
+
showProgress && currentFile && hasUploadedFile && uploadProgress < 100 && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(progress_default, { value: uploadProgress }),
|
|
12443
12465
|
!message && helperMessage && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: slots.helperMessage(), children: helperMessage })
|
|
12444
12466
|
] });
|
|
12445
12467
|
}
|
|
@@ -12450,7 +12472,7 @@ var fileUploadStyle = (0, import_tailwind_variants34.tv)({
|
|
|
12450
12472
|
base: ["flex", "flex-col", "gap-[5px]"],
|
|
12451
12473
|
container: ["flex", "gap-[10px]"],
|
|
12452
12474
|
inputWrapper: ["relative", "flex-1"],
|
|
12453
|
-
cancelButton: ["absolute", "top-1/2", "right-0", "-translate-y-1/2"],
|
|
12475
|
+
cancelButton: ["absolute", "top-1/2", "right-0", "-translate-y-1/2", "mr-[4px]"],
|
|
12454
12476
|
errorMessage: ["text-danger-main", "text-sm"],
|
|
12455
12477
|
helperMessage: ["text-neutral-main", "text-sm"]
|
|
12456
12478
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "./chunk-
|
|
3
|
-
import {
|
|
4
|
-
ToastProvider,
|
|
5
|
-
useToast
|
|
6
|
-
} from "./chunk-EQLBG32V.mjs";
|
|
7
|
-
import "./chunk-ZOTHPHXA.mjs";
|
|
2
|
+
import "./chunk-MBLZYQCN.mjs";
|
|
8
3
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
4
|
+
tree_default
|
|
5
|
+
} from "./chunk-WSBUOY2M.mjs";
|
|
11
6
|
import "./chunk-RRAZM5D3.mjs";
|
|
12
7
|
import {
|
|
13
8
|
textarea_default
|
|
14
9
|
} from "./chunk-3CRSSRCH.mjs";
|
|
15
|
-
import "./chunk-MBLZYQCN.mjs";
|
|
16
|
-
import {
|
|
17
|
-
tree_default
|
|
18
|
-
} from "./chunk-WSBUOY2M.mjs";
|
|
19
10
|
import "./chunk-HIE2YRGA.mjs";
|
|
20
11
|
import {
|
|
21
12
|
tooltip_default
|
|
22
13
|
} from "./chunk-5KC3IFNR.mjs";
|
|
23
14
|
import "./chunk-ZMOAFSYE.mjs";
|
|
24
15
|
import "./chunk-WSIADHVC.mjs";
|
|
16
|
+
import "./chunk-LUWGOKLG.mjs";
|
|
17
|
+
import {
|
|
18
|
+
ToastProvider,
|
|
19
|
+
useToast
|
|
20
|
+
} from "./chunk-EQLBG32V.mjs";
|
|
21
|
+
import "./chunk-ZOTHPHXA.mjs";
|
|
22
|
+
import {
|
|
23
|
+
toast_default
|
|
24
|
+
} from "./chunk-6574ITBF.mjs";
|
|
25
25
|
import "./chunk-DX3KXNP6.mjs";
|
|
26
26
|
import {
|
|
27
27
|
definition_table_default
|
|
@@ -69,10 +69,6 @@ import {
|
|
|
69
69
|
select_default
|
|
70
70
|
} from "./chunk-5G6CCE55.mjs";
|
|
71
71
|
import "./chunk-FWFEKWWD.mjs";
|
|
72
|
-
import "./chunk-DJOG6Z35.mjs";
|
|
73
|
-
import {
|
|
74
|
-
modal_default
|
|
75
|
-
} from "./chunk-SCQCMQDP.mjs";
|
|
76
72
|
import "./chunk-7MVEAQ7Z.mjs";
|
|
77
73
|
import {
|
|
78
74
|
list_default
|
|
@@ -80,6 +76,10 @@ import {
|
|
|
80
76
|
import {
|
|
81
77
|
listItem_default
|
|
82
78
|
} from "./chunk-HKLVFMYQ.mjs";
|
|
79
|
+
import "./chunk-DJOG6Z35.mjs";
|
|
80
|
+
import {
|
|
81
|
+
modal_default
|
|
82
|
+
} from "./chunk-SCQCMQDP.mjs";
|
|
83
83
|
import "./chunk-MGEWSREV.mjs";
|
|
84
84
|
import {
|
|
85
85
|
chip_default
|
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
import "./chunk-RLXOHILK.mjs";
|
|
92
92
|
import {
|
|
93
93
|
fileUpload_default
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-4XEZQMLU.mjs";
|
|
95
95
|
import "./chunk-7VOQKIIK.mjs";
|
|
96
96
|
import {
|
|
97
97
|
progress_default
|