@clickhouse/click-ui 0.0.222 → 0.0.223
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/dist/click-ui.bundled.es.js +307 -35
- package/dist/click-ui.bundled.es.js.map +1 -1
- package/dist/click-ui.bundled.umd.js +307 -35
- package/dist/click-ui.bundled.umd.js.map +1 -1
- package/dist/click-ui.es.js +307 -35
- package/dist/click-ui.es.js.map +1 -1
- package/dist/click-ui.umd.js +307 -35
- package/dist/click-ui.umd.js.map +1 -1
- package/dist/components/FileUpload/FileMultiUpload.d.ts +19 -0
- package/dist/components/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -17759,7 +17759,7 @@ const truncateFilename = (filename, maxLength = 40, delimiter2 = "~") => {
|
|
|
17759
17759
|
const truncatedName = nameWithoutExtension.slice(0, maxLength) + delimiter2;
|
|
17760
17760
|
return truncatedName + extension;
|
|
17761
17761
|
};
|
|
17762
|
-
const UploadArea = pt.div.withConfig({
|
|
17762
|
+
const UploadArea$1 = pt.div.withConfig({
|
|
17763
17763
|
componentId: "sc-1rzizve-0"
|
|
17764
17764
|
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:", ";align-items:center;justify-content:", ";gap:", ";cursor:", ";transition:", ";", " ", ""], ({
|
|
17765
17765
|
theme: theme2
|
|
@@ -17786,7 +17786,7 @@ const UploadArea = pt.div.withConfig({
|
|
|
17786
17786
|
}) => theme2.click.fileUpload.color.stroke.active)), (props) => props.$isError && ct(["background-color:", ";border:none;"], ({
|
|
17787
17787
|
theme: theme2
|
|
17788
17788
|
}) => theme2.click.fileUpload.color.background.error));
|
|
17789
|
-
const FileUploadTitle = pt(Title$2).withConfig({
|
|
17789
|
+
const FileUploadTitle$1 = pt(Title$2).withConfig({
|
|
17790
17790
|
componentId: "sc-1rzizve-1"
|
|
17791
17791
|
})(["font:", ";color:", ";"], ({
|
|
17792
17792
|
theme: theme2
|
|
@@ -17794,14 +17794,14 @@ const FileUploadTitle = pt(Title$2).withConfig({
|
|
|
17794
17794
|
theme: theme2,
|
|
17795
17795
|
$isNotSupported
|
|
17796
17796
|
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
17797
|
-
const FileUploadDescription = pt(Text).withConfig({
|
|
17797
|
+
const FileUploadDescription$1 = pt(Text).withConfig({
|
|
17798
17798
|
componentId: "sc-1rzizve-2"
|
|
17799
17799
|
})(["font:", ";color:", ";"], ({
|
|
17800
17800
|
theme: theme2
|
|
17801
17801
|
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
17802
17802
|
theme: theme2
|
|
17803
17803
|
}) => theme2.click.fileUpload.color.description.default);
|
|
17804
|
-
const DocumentIcon = pt(SvgImage).withConfig({
|
|
17804
|
+
const DocumentIcon$1 = pt(SvgImage).withConfig({
|
|
17805
17805
|
componentId: "sc-1rzizve-3"
|
|
17806
17806
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
17807
17807
|
theme: theme2
|
|
@@ -17810,7 +17810,7 @@ const DocumentIcon = pt(SvgImage).withConfig({
|
|
|
17810
17810
|
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
17811
17811
|
theme: theme2
|
|
17812
17812
|
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
17813
|
-
const UploadIcon = pt(SvgImage).withConfig({
|
|
17813
|
+
const UploadIcon$1 = pt(SvgImage).withConfig({
|
|
17814
17814
|
componentId: "sc-1rzizve-4"
|
|
17815
17815
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
17816
17816
|
theme: theme2
|
|
@@ -17819,41 +17819,41 @@ const UploadIcon = pt(SvgImage).withConfig({
|
|
|
17819
17819
|
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
17820
17820
|
theme: theme2
|
|
17821
17821
|
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
17822
|
-
const UploadText = pt.div.withConfig({
|
|
17822
|
+
const UploadText$1 = pt.div.withConfig({
|
|
17823
17823
|
componentId: "sc-1rzizve-5"
|
|
17824
17824
|
})(["text-align:", ";", " ", ""], (props) => props.$hasFile || props.$size === "sm" ? "left" : "center", (props) => (props.$hasFile || props.$size === "sm") && ct(["flex:1;"]), (props) => !props.$hasFile && props.$size === "md" && ct(["display:flex;flex-direction:column;align-items:center;width:100%;"]));
|
|
17825
|
-
const FileInfoHeader = pt.div.withConfig({
|
|
17825
|
+
const FileInfoHeader$1 = pt.div.withConfig({
|
|
17826
17826
|
componentId: "sc-1rzizve-6"
|
|
17827
17827
|
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
17828
17828
|
theme: theme2
|
|
17829
17829
|
}) => theme2.click.fileUpload.sm.space.gap);
|
|
17830
|
-
const FileInfo = pt.div.withConfig({
|
|
17830
|
+
const FileInfo$1 = pt.div.withConfig({
|
|
17831
17831
|
componentId: "sc-1rzizve-7"
|
|
17832
17832
|
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
17833
17833
|
theme: theme2
|
|
17834
17834
|
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
17835
|
-
const FileDetails = pt.div.withConfig({
|
|
17835
|
+
const FileDetails$1 = pt.div.withConfig({
|
|
17836
17836
|
componentId: "sc-1rzizve-8"
|
|
17837
17837
|
})(["display:flex;gap:", ";border:none;"], ({
|
|
17838
17838
|
theme: theme2
|
|
17839
17839
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
17840
|
-
const FileActions = pt.div.withConfig({
|
|
17840
|
+
const FileActions$1 = pt.div.withConfig({
|
|
17841
17841
|
componentId: "sc-1rzizve-9"
|
|
17842
17842
|
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
17843
|
-
const ProgressContainer$
|
|
17843
|
+
const ProgressContainer$2 = pt.div.withConfig({
|
|
17844
17844
|
componentId: "sc-1rzizve-10"
|
|
17845
17845
|
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
17846
|
-
const ProgressBarContainer = pt.div.withConfig({
|
|
17846
|
+
const ProgressBarContainer$1 = pt.div.withConfig({
|
|
17847
17847
|
componentId: "sc-1rzizve-11"
|
|
17848
17848
|
})(["width:100%;flex:1;"]);
|
|
17849
|
-
const ProgressPercentage = pt(Text).withConfig({
|
|
17849
|
+
const ProgressPercentage$1 = pt(Text).withConfig({
|
|
17850
17850
|
componentId: "sc-1rzizve-12"
|
|
17851
17851
|
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
17852
17852
|
theme: theme2
|
|
17853
17853
|
}) => theme2.sizes[10], ({
|
|
17854
17854
|
theme: theme2
|
|
17855
17855
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
17856
|
-
const formatFileSize = (sizeInBytes) => {
|
|
17856
|
+
const formatFileSize$1 = (sizeInBytes) => {
|
|
17857
17857
|
if (sizeInBytes < 1024) {
|
|
17858
17858
|
return `${sizeInBytes.toFixed(1)} B`;
|
|
17859
17859
|
} else if (sizeInBytes < 1024 * 1024) {
|
|
@@ -17864,7 +17864,7 @@ const formatFileSize = (sizeInBytes) => {
|
|
|
17864
17864
|
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
17865
17865
|
}
|
|
17866
17866
|
};
|
|
17867
|
-
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
17867
|
+
const isFiletypeSupported$1 = (filename, supportedTypes) => {
|
|
17868
17868
|
if (!supportedTypes.length) return true;
|
|
17869
17869
|
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
17870
17870
|
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
@@ -17934,13 +17934,10 @@ const FileUpload = ({
|
|
|
17934
17934
|
};
|
|
17935
17935
|
}, []);
|
|
17936
17936
|
const processFile = useCallback((file2) => {
|
|
17937
|
-
if (!isFiletypeSupported(file2.name, supportedFileTypes)) {
|
|
17937
|
+
if (!isFiletypeSupported$1(file2.name, supportedFileTypes)) {
|
|
17938
|
+
setIsNotSupported(true);
|
|
17938
17939
|
if (onFileFailure) {
|
|
17939
17940
|
onFileFailure();
|
|
17940
|
-
console.log("File type not supported");
|
|
17941
|
-
setIsNotSupported(true);
|
|
17942
|
-
} else {
|
|
17943
|
-
console.warn(`File type not supported: ${file2.name}`);
|
|
17944
17941
|
}
|
|
17945
17942
|
return;
|
|
17946
17943
|
}
|
|
@@ -17949,9 +17946,9 @@ const FileUpload = ({
|
|
|
17949
17946
|
size: file2.size
|
|
17950
17947
|
};
|
|
17951
17948
|
setFile(newFile);
|
|
17949
|
+
setIsNotSupported(false);
|
|
17952
17950
|
if (onFileSelect) {
|
|
17953
17951
|
onFileSelect(file2);
|
|
17954
|
-
setIsNotSupported(false);
|
|
17955
17952
|
}
|
|
17956
17953
|
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
17957
17954
|
const handleDrop = useCallback((e) => {
|
|
@@ -17991,11 +17988,11 @@ const FileUpload = ({
|
|
|
17991
17988
|
}, [onRetry]);
|
|
17992
17989
|
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
17993
17990
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
17994
|
-
/* @__PURE__ */ jsx(UploadArea, { $isDragging: isDragging, $size: size2, $hasFile: !!file, $isError: !!file && !showSuccess && !showProgress, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: !file ? handleBrowseClick : void 0, children: !file ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
17995
|
-
/* @__PURE__ */ jsx(UploadIcon, { name: "upload" }),
|
|
17996
|
-
/* @__PURE__ */ jsxs(UploadText, { $size: size2, $hasFile: false, children: [
|
|
17997
|
-
isNotSupported ? /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: isNotSupported, type: "h1", children: title }),
|
|
17998
|
-
/* @__PURE__ */ jsxs(FileUploadDescription, { children: [
|
|
17991
|
+
/* @__PURE__ */ jsx(UploadArea$1, { $isDragging: isDragging, $size: size2, $hasFile: !!file, $isError: !!file && !showSuccess && !showProgress, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: !file ? handleBrowseClick : void 0, children: !file ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
17992
|
+
/* @__PURE__ */ jsx(UploadIcon$1, { name: "upload" }),
|
|
17993
|
+
/* @__PURE__ */ jsxs(UploadText$1, { $size: size2, $hasFile: false, children: [
|
|
17994
|
+
isNotSupported ? /* @__PURE__ */ jsx(FileUploadTitle$1, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsx(FileUploadTitle$1, { $isNotSupported: isNotSupported, type: "h1", children: title }),
|
|
17995
|
+
/* @__PURE__ */ jsxs(FileUploadDescription$1, { children: [
|
|
17999
17996
|
"Files supported: ",
|
|
18000
17997
|
supportedFileTypes.join(", ")
|
|
18001
17998
|
] })
|
|
@@ -18004,23 +18001,23 @@ const FileUpload = ({
|
|
|
18004
18001
|
e.stopPropagation();
|
|
18005
18002
|
handleBrowseClick();
|
|
18006
18003
|
}, children: "Browse file" })
|
|
18007
|
-
] }) : /* @__PURE__ */ jsxs(FileInfo, { children: [
|
|
18008
|
-
/* @__PURE__ */ jsxs(FileInfoHeader, { children: [
|
|
18009
|
-
/* @__PURE__ */ jsx(DocumentIcon, { name: "document" }),
|
|
18010
|
-
/* @__PURE__ */ jsxs(FileDetails, { children: [
|
|
18004
|
+
] }) : /* @__PURE__ */ jsxs(FileInfo$1, { children: [
|
|
18005
|
+
/* @__PURE__ */ jsxs(FileInfoHeader$1, { children: [
|
|
18006
|
+
/* @__PURE__ */ jsx(DocumentIcon$1, { name: "document" }),
|
|
18007
|
+
/* @__PURE__ */ jsxs(FileDetails$1, { children: [
|
|
18011
18008
|
/* @__PURE__ */ jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
18012
|
-
(showSuccess || showProgress) && /* @__PURE__ */ jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
18009
|
+
(showSuccess || showProgress) && /* @__PURE__ */ jsx(Text, { size: "md", color: "muted", children: formatFileSize$1(file.size) }),
|
|
18013
18010
|
!showProgress && !showSuccess && /* @__PURE__ */ jsx(Text, { size: "md", color: "danger", children: failureMessage }),
|
|
18014
18011
|
showSuccess && /* @__PURE__ */ jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
18015
18012
|
] }),
|
|
18016
|
-
/* @__PURE__ */ jsxs(FileActions, { children: [
|
|
18013
|
+
/* @__PURE__ */ jsxs(FileActions$1, { children: [
|
|
18017
18014
|
!showProgress && !showSuccess && /* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: handleRetryUpload }),
|
|
18018
18015
|
/* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: handleRemoveFile })
|
|
18019
18016
|
] })
|
|
18020
18017
|
] }),
|
|
18021
|
-
showProgress && /* @__PURE__ */ jsxs(ProgressContainer$
|
|
18022
|
-
/* @__PURE__ */ jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsx(ProgressBar, { progress, type: "small" }) }),
|
|
18023
|
-
/* @__PURE__ */ jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
18018
|
+
showProgress && /* @__PURE__ */ jsxs(ProgressContainer$2, { children: [
|
|
18019
|
+
/* @__PURE__ */ jsx(ProgressBarContainer$1, { children: /* @__PURE__ */ jsx(ProgressBar, { progress, type: "small" }) }),
|
|
18020
|
+
/* @__PURE__ */ jsxs(ProgressPercentage$1, { size: "sm", color: "muted", children: [
|
|
18024
18021
|
progress,
|
|
18025
18022
|
"%"
|
|
18026
18023
|
] })
|
|
@@ -18031,6 +18028,280 @@ const FileUpload = ({
|
|
|
18031
18028
|
} })
|
|
18032
18029
|
] });
|
|
18033
18030
|
};
|
|
18031
|
+
const UploadArea = pt.div.withConfig({
|
|
18032
|
+
componentId: "sc-1w9rsfj-0"
|
|
18033
|
+
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:column;align-items:center;justify-content:center;gap:", ";cursor:pointer;transition:", ";border-style:dashed;border-color:", ";", ""], ({
|
|
18034
|
+
theme: theme2
|
|
18035
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
18036
|
+
theme: theme2
|
|
18037
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
18038
|
+
theme: theme2
|
|
18039
|
+
}) => theme2.click.fileUpload.md.radii.all, ({
|
|
18040
|
+
theme: theme2
|
|
18041
|
+
}) => `${theme2.click.fileUpload.md.space.y} ${theme2.click.fileUpload.md.space.x}`, ({
|
|
18042
|
+
theme: theme2
|
|
18043
|
+
}) => theme2.click.fileUpload.md.space.gap, ({
|
|
18044
|
+
theme: theme2
|
|
18045
|
+
}) => theme2.click.fileUpload.transitions.all, ({
|
|
18046
|
+
theme: theme2
|
|
18047
|
+
}) => theme2.click.fileUpload.color.stroke.default, (props) => props.$isDragging && ct(["background-color:", ";border-color:", ";"], ({
|
|
18048
|
+
theme: theme2
|
|
18049
|
+
}) => theme2.click.fileUpload.color.background.active, ({
|
|
18050
|
+
theme: theme2
|
|
18051
|
+
}) => theme2.click.fileUpload.color.stroke.active));
|
|
18052
|
+
const FileUploadTitle = pt(Title$2).withConfig({
|
|
18053
|
+
componentId: "sc-1w9rsfj-1"
|
|
18054
|
+
})(["font:", ";color:", ";"], ({
|
|
18055
|
+
theme: theme2
|
|
18056
|
+
}) => theme2.click.fileUpload.typography.title.default, ({
|
|
18057
|
+
theme: theme2,
|
|
18058
|
+
$isNotSupported
|
|
18059
|
+
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
18060
|
+
const FileUploadDescription = pt(Text).withConfig({
|
|
18061
|
+
componentId: "sc-1w9rsfj-2"
|
|
18062
|
+
})(["font:", ";color:", ";"], ({
|
|
18063
|
+
theme: theme2
|
|
18064
|
+
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
18065
|
+
theme: theme2
|
|
18066
|
+
}) => theme2.click.fileUpload.color.description.default);
|
|
18067
|
+
const UploadIcon = pt(SvgImage).withConfig({
|
|
18068
|
+
componentId: "sc-1w9rsfj-3"
|
|
18069
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
18070
|
+
theme: theme2
|
|
18071
|
+
}) => theme2.click.fileUpload.md.icon.size.width, ({
|
|
18072
|
+
theme: theme2
|
|
18073
|
+
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
18074
|
+
theme: theme2
|
|
18075
|
+
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
18076
|
+
const UploadText = pt.div.withConfig({
|
|
18077
|
+
componentId: "sc-1w9rsfj-4"
|
|
18078
|
+
})(["text-align:center;display:flex;flex-direction:column;align-items:center;width:100%;"]);
|
|
18079
|
+
const FilesList = pt.div.withConfig({
|
|
18080
|
+
componentId: "sc-1w9rsfj-5"
|
|
18081
|
+
})(["display:flex;flex-direction:column;gap:", ";width:100%;margin-top:", ";"], ({
|
|
18082
|
+
theme: theme2
|
|
18083
|
+
}) => theme2.click.fileUpload.sm.space.gap, ({
|
|
18084
|
+
theme: theme2
|
|
18085
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
18086
|
+
const FileItem = pt.div.withConfig({
|
|
18087
|
+
componentId: "sc-1w9rsfj-6"
|
|
18088
|
+
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:", ";", ""], ({
|
|
18089
|
+
theme: theme2
|
|
18090
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
18091
|
+
theme: theme2
|
|
18092
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
18093
|
+
theme: theme2
|
|
18094
|
+
}) => theme2.click.fileUpload.sm.radii.all, ({
|
|
18095
|
+
theme: theme2
|
|
18096
|
+
}) => `${theme2.click.fileUpload.sm.space.y} ${theme2.click.fileUpload.sm.space.x}`, ({
|
|
18097
|
+
theme: theme2
|
|
18098
|
+
}) => theme2.click.fileUpload.sm.space.gap, (props) => props.$isError && ct(["background-color:", ";border:none;"], ({
|
|
18099
|
+
theme: theme2
|
|
18100
|
+
}) => theme2.click.fileUpload.color.background.error));
|
|
18101
|
+
const DocumentIcon = pt(SvgImage).withConfig({
|
|
18102
|
+
componentId: "sc-1w9rsfj-7"
|
|
18103
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
18104
|
+
theme: theme2
|
|
18105
|
+
}) => theme2.click.fileUpload.sm.icon.size.width, ({
|
|
18106
|
+
theme: theme2
|
|
18107
|
+
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
18108
|
+
theme: theme2
|
|
18109
|
+
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
18110
|
+
const FileInfoHeader = pt.div.withConfig({
|
|
18111
|
+
componentId: "sc-1w9rsfj-8"
|
|
18112
|
+
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
18113
|
+
theme: theme2
|
|
18114
|
+
}) => theme2.click.fileUpload.sm.space.gap);
|
|
18115
|
+
const FileInfo = pt.div.withConfig({
|
|
18116
|
+
componentId: "sc-1w9rsfj-9"
|
|
18117
|
+
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
18118
|
+
theme: theme2
|
|
18119
|
+
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
18120
|
+
const FileDetails = pt.div.withConfig({
|
|
18121
|
+
componentId: "sc-1w9rsfj-10"
|
|
18122
|
+
})(["display:flex;gap:", ";border:none;"], ({
|
|
18123
|
+
theme: theme2
|
|
18124
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
18125
|
+
const FileActions = pt.div.withConfig({
|
|
18126
|
+
componentId: "sc-1w9rsfj-11"
|
|
18127
|
+
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
18128
|
+
const ProgressContainer$1 = pt.div.withConfig({
|
|
18129
|
+
componentId: "sc-1w9rsfj-12"
|
|
18130
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
18131
|
+
const ProgressBarContainer = pt.div.withConfig({
|
|
18132
|
+
componentId: "sc-1w9rsfj-13"
|
|
18133
|
+
})(["width:100%;flex:1;"]);
|
|
18134
|
+
const ProgressPercentage = pt(Text).withConfig({
|
|
18135
|
+
componentId: "sc-1w9rsfj-14"
|
|
18136
|
+
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
18137
|
+
theme: theme2
|
|
18138
|
+
}) => theme2.sizes[10], ({
|
|
18139
|
+
theme: theme2
|
|
18140
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
18141
|
+
const formatFileSize = (sizeInBytes) => {
|
|
18142
|
+
if (sizeInBytes < 1024) {
|
|
18143
|
+
return `${sizeInBytes.toFixed(1)} B`;
|
|
18144
|
+
} else if (sizeInBytes < 1024 * 1024) {
|
|
18145
|
+
return `${(sizeInBytes / 1024).toFixed(1)} KB`;
|
|
18146
|
+
} else if (sizeInBytes < 1024 * 1024 * 1024) {
|
|
18147
|
+
return `${(sizeInBytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
18148
|
+
} else {
|
|
18149
|
+
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
18150
|
+
}
|
|
18151
|
+
};
|
|
18152
|
+
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
18153
|
+
if (!supportedTypes.length) return true;
|
|
18154
|
+
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
18155
|
+
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
18156
|
+
};
|
|
18157
|
+
const FileMultiUpload = ({
|
|
18158
|
+
title,
|
|
18159
|
+
supportedFileTypes = [".txt", ".sql"],
|
|
18160
|
+
files,
|
|
18161
|
+
onFileSelect,
|
|
18162
|
+
onFileRetry,
|
|
18163
|
+
onFileRemove,
|
|
18164
|
+
onFileFailure
|
|
18165
|
+
}) => {
|
|
18166
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
18167
|
+
const [isSupported, setIsSupported] = useState(true);
|
|
18168
|
+
const fileInputRef = useRef(null);
|
|
18169
|
+
const dragCounterRef = useRef(0);
|
|
18170
|
+
useEffect(() => {
|
|
18171
|
+
let timeoutId;
|
|
18172
|
+
if (!isSupported) {
|
|
18173
|
+
timeoutId = setTimeout(() => {
|
|
18174
|
+
setIsSupported(true);
|
|
18175
|
+
}, 2e3);
|
|
18176
|
+
}
|
|
18177
|
+
return () => {
|
|
18178
|
+
if (timeoutId) {
|
|
18179
|
+
clearTimeout(timeoutId);
|
|
18180
|
+
}
|
|
18181
|
+
};
|
|
18182
|
+
}, [isSupported]);
|
|
18183
|
+
const handleDragEnter = useCallback((e) => {
|
|
18184
|
+
e.preventDefault();
|
|
18185
|
+
e.stopPropagation();
|
|
18186
|
+
dragCounterRef.current += 1;
|
|
18187
|
+
setIsDragging(true);
|
|
18188
|
+
}, []);
|
|
18189
|
+
const handleDragLeave = useCallback((e) => {
|
|
18190
|
+
e.preventDefault();
|
|
18191
|
+
e.stopPropagation();
|
|
18192
|
+
dragCounterRef.current -= 1;
|
|
18193
|
+
if (dragCounterRef.current <= 0) {
|
|
18194
|
+
setIsDragging(false);
|
|
18195
|
+
dragCounterRef.current = 0;
|
|
18196
|
+
}
|
|
18197
|
+
}, []);
|
|
18198
|
+
const handleDragOver = useCallback((e) => {
|
|
18199
|
+
e.preventDefault();
|
|
18200
|
+
e.stopPropagation();
|
|
18201
|
+
}, []);
|
|
18202
|
+
useEffect(() => {
|
|
18203
|
+
const handleDragEnd = () => {
|
|
18204
|
+
setIsDragging(false);
|
|
18205
|
+
dragCounterRef.current = 0;
|
|
18206
|
+
};
|
|
18207
|
+
window.addEventListener("dragend", handleDragEnd);
|
|
18208
|
+
document.addEventListener("drop", handleDragEnd);
|
|
18209
|
+
document.addEventListener("mouseleave", handleDragEnd);
|
|
18210
|
+
return () => {
|
|
18211
|
+
window.removeEventListener("dragend", handleDragEnd);
|
|
18212
|
+
document.removeEventListener("drop", handleDragEnd);
|
|
18213
|
+
document.removeEventListener("mouseleave", handleDragEnd);
|
|
18214
|
+
};
|
|
18215
|
+
}, []);
|
|
18216
|
+
const processFile = useCallback((file) => {
|
|
18217
|
+
if (!isFiletypeSupported(file.name, supportedFileTypes)) {
|
|
18218
|
+
setIsSupported(false);
|
|
18219
|
+
if (onFileFailure) {
|
|
18220
|
+
onFileFailure();
|
|
18221
|
+
}
|
|
18222
|
+
return;
|
|
18223
|
+
}
|
|
18224
|
+
setIsSupported(true);
|
|
18225
|
+
if (onFileSelect) {
|
|
18226
|
+
onFileSelect(file);
|
|
18227
|
+
}
|
|
18228
|
+
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
18229
|
+
const handleDrop = useCallback((e) => {
|
|
18230
|
+
e.preventDefault();
|
|
18231
|
+
e.stopPropagation();
|
|
18232
|
+
setIsDragging(false);
|
|
18233
|
+
dragCounterRef.current = 0;
|
|
18234
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
18235
|
+
Array.from(e.dataTransfer.files).forEach((file) => {
|
|
18236
|
+
processFile(file);
|
|
18237
|
+
});
|
|
18238
|
+
}
|
|
18239
|
+
}, [processFile]);
|
|
18240
|
+
const handleFileSelect = useCallback((e) => {
|
|
18241
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
18242
|
+
Array.from(e.target.files).forEach((file) => {
|
|
18243
|
+
processFile(file);
|
|
18244
|
+
});
|
|
18245
|
+
}
|
|
18246
|
+
}, [processFile]);
|
|
18247
|
+
const handleBrowseClick = useCallback(() => {
|
|
18248
|
+
if (fileInputRef.current) {
|
|
18249
|
+
fileInputRef.current.click();
|
|
18250
|
+
}
|
|
18251
|
+
}, []);
|
|
18252
|
+
const handleRemoveFile = useCallback((fileId) => {
|
|
18253
|
+
if (onFileRemove) {
|
|
18254
|
+
onFileRemove(fileId);
|
|
18255
|
+
}
|
|
18256
|
+
}, [onFileRemove]);
|
|
18257
|
+
const handleRetryUpload = useCallback((fileId) => {
|
|
18258
|
+
if (onFileRetry) {
|
|
18259
|
+
onFileRetry(fileId);
|
|
18260
|
+
}
|
|
18261
|
+
}, [onFileRetry]);
|
|
18262
|
+
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
18263
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
18264
|
+
/* @__PURE__ */ jsxs(UploadArea, { $isDragging: isDragging, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleBrowseClick, children: [
|
|
18265
|
+
/* @__PURE__ */ jsx(UploadIcon, { name: "upload" }),
|
|
18266
|
+
/* @__PURE__ */ jsxs(UploadText, { children: [
|
|
18267
|
+
!isSupported ? /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: !isSupported, type: "h1", children: title }),
|
|
18268
|
+
/* @__PURE__ */ jsxs(FileUploadDescription, { children: [
|
|
18269
|
+
"Files supported: ",
|
|
18270
|
+
supportedFileTypes.join(", ")
|
|
18271
|
+
] })
|
|
18272
|
+
] }),
|
|
18273
|
+
/* @__PURE__ */ jsx(Button, { type: "secondary", onClick: (e) => {
|
|
18274
|
+
e.stopPropagation();
|
|
18275
|
+
handleBrowseClick();
|
|
18276
|
+
}, children: "Browse files" })
|
|
18277
|
+
] }),
|
|
18278
|
+
files.length > 0 && /* @__PURE__ */ jsx(FilesList, { children: files.map((file) => /* @__PURE__ */ jsx(FileItem, { $isError: file.status === "error", children: /* @__PURE__ */ jsxs(FileInfo, { children: [
|
|
18279
|
+
/* @__PURE__ */ jsxs(FileInfoHeader, { children: [
|
|
18280
|
+
/* @__PURE__ */ jsx(DocumentIcon, { name: "document" }),
|
|
18281
|
+
/* @__PURE__ */ jsxs(FileDetails, { children: [
|
|
18282
|
+
/* @__PURE__ */ jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
18283
|
+
(file.status === "success" || file.status === "uploading") && /* @__PURE__ */ jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
18284
|
+
file.status === "error" && /* @__PURE__ */ jsx(Text, { size: "md", color: "danger", children: file.errorMessage || "Upload failed" }),
|
|
18285
|
+
file.status === "success" && /* @__PURE__ */ jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
18286
|
+
] }),
|
|
18287
|
+
/* @__PURE__ */ jsxs(FileActions, { children: [
|
|
18288
|
+
file.status === "error" && /* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: () => handleRetryUpload(file.id) }),
|
|
18289
|
+
/* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: () => handleRemoveFile(file.id) })
|
|
18290
|
+
] })
|
|
18291
|
+
] }),
|
|
18292
|
+
file.status === "uploading" && /* @__PURE__ */ jsxs(ProgressContainer$1, { children: [
|
|
18293
|
+
/* @__PURE__ */ jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsx(ProgressBar, { progress: file.progress, type: "small" }) }),
|
|
18294
|
+
/* @__PURE__ */ jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
18295
|
+
file.progress,
|
|
18296
|
+
"%"
|
|
18297
|
+
] })
|
|
18298
|
+
] })
|
|
18299
|
+
] }) }, file.id)) }),
|
|
18300
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: fileInputRef, accept: acceptedFileTypes, onChange: handleFileSelect, multiple: true, style: {
|
|
18301
|
+
display: "none"
|
|
18302
|
+
} })
|
|
18303
|
+
] });
|
|
18304
|
+
};
|
|
18034
18305
|
const Flyout = ({
|
|
18035
18306
|
modal = false,
|
|
18036
18307
|
...props
|
|
@@ -52112,6 +52383,7 @@ export {
|
|
|
52112
52383
|
Dialog,
|
|
52113
52384
|
Dropdown,
|
|
52114
52385
|
EllipsisContent,
|
|
52386
|
+
FileMultiUpload,
|
|
52115
52387
|
FileTabElement,
|
|
52116
52388
|
FileTabs,
|
|
52117
52389
|
FileUpload,
|