@clickhouse/click-ui 0.0.221 → 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 +308 -35
- package/dist/click-ui.bundled.es.js.map +1 -0
- package/dist/click-ui.bundled.umd.js +308 -35
- package/dist/click-ui.bundled.umd.js.map +1 -0
- package/dist/click-ui.es.js +308 -35
- package/dist/click-ui.es.js.map +1 -0
- package/dist/click-ui.umd.js +308 -35
- package/dist/click-ui.umd.js.map +1 -0
- package/dist/components/FileUpload/FileMultiUpload.d.ts +19 -0
- package/dist/components/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/click-ui.es.js
CHANGED
|
@@ -16591,7 +16591,7 @@ const truncateFilename = (filename, maxLength = 40, delimiter = "~") => {
|
|
|
16591
16591
|
const truncatedName = nameWithoutExtension.slice(0, maxLength) + delimiter;
|
|
16592
16592
|
return truncatedName + extension;
|
|
16593
16593
|
};
|
|
16594
|
-
const UploadArea = styled$1.div.withConfig({
|
|
16594
|
+
const UploadArea$1 = styled$1.div.withConfig({
|
|
16595
16595
|
componentId: "sc-1rzizve-0"
|
|
16596
16596
|
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:", ";align-items:center;justify-content:", ";gap:", ";cursor:", ";transition:", ";", " ", ""], ({
|
|
16597
16597
|
theme: theme2
|
|
@@ -16618,7 +16618,7 @@ const UploadArea = styled$1.div.withConfig({
|
|
|
16618
16618
|
}) => theme2.click.fileUpload.color.stroke.active)), (props) => props.$isError && css$1(["background-color:", ";border:none;"], ({
|
|
16619
16619
|
theme: theme2
|
|
16620
16620
|
}) => theme2.click.fileUpload.color.background.error));
|
|
16621
|
-
const FileUploadTitle = styled$1(Title$2).withConfig({
|
|
16621
|
+
const FileUploadTitle$1 = styled$1(Title$2).withConfig({
|
|
16622
16622
|
componentId: "sc-1rzizve-1"
|
|
16623
16623
|
})(["font:", ";color:", ";"], ({
|
|
16624
16624
|
theme: theme2
|
|
@@ -16626,14 +16626,14 @@ const FileUploadTitle = styled$1(Title$2).withConfig({
|
|
|
16626
16626
|
theme: theme2,
|
|
16627
16627
|
$isNotSupported
|
|
16628
16628
|
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
16629
|
-
const FileUploadDescription = styled$1(Text).withConfig({
|
|
16629
|
+
const FileUploadDescription$1 = styled$1(Text).withConfig({
|
|
16630
16630
|
componentId: "sc-1rzizve-2"
|
|
16631
16631
|
})(["font:", ";color:", ";"], ({
|
|
16632
16632
|
theme: theme2
|
|
16633
16633
|
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
16634
16634
|
theme: theme2
|
|
16635
16635
|
}) => theme2.click.fileUpload.color.description.default);
|
|
16636
|
-
const DocumentIcon = styled$1(SvgImage).withConfig({
|
|
16636
|
+
const DocumentIcon$1 = styled$1(SvgImage).withConfig({
|
|
16637
16637
|
componentId: "sc-1rzizve-3"
|
|
16638
16638
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16639
16639
|
theme: theme2
|
|
@@ -16642,7 +16642,7 @@ const DocumentIcon = styled$1(SvgImage).withConfig({
|
|
|
16642
16642
|
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
16643
16643
|
theme: theme2
|
|
16644
16644
|
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
16645
|
-
const UploadIcon = styled$1(SvgImage).withConfig({
|
|
16645
|
+
const UploadIcon$1 = styled$1(SvgImage).withConfig({
|
|
16646
16646
|
componentId: "sc-1rzizve-4"
|
|
16647
16647
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16648
16648
|
theme: theme2
|
|
@@ -16651,41 +16651,41 @@ const UploadIcon = styled$1(SvgImage).withConfig({
|
|
|
16651
16651
|
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
16652
16652
|
theme: theme2
|
|
16653
16653
|
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
16654
|
-
const UploadText = styled$1.div.withConfig({
|
|
16654
|
+
const UploadText$1 = styled$1.div.withConfig({
|
|
16655
16655
|
componentId: "sc-1rzizve-5"
|
|
16656
16656
|
})(["text-align:", ";", " ", ""], (props) => props.$hasFile || props.$size === "sm" ? "left" : "center", (props) => (props.$hasFile || props.$size === "sm") && css$1(["flex:1;"]), (props) => !props.$hasFile && props.$size === "md" && css$1(["display:flex;flex-direction:column;align-items:center;width:100%;"]));
|
|
16657
|
-
const FileInfoHeader = styled$1.div.withConfig({
|
|
16657
|
+
const FileInfoHeader$1 = styled$1.div.withConfig({
|
|
16658
16658
|
componentId: "sc-1rzizve-6"
|
|
16659
16659
|
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
16660
16660
|
theme: theme2
|
|
16661
16661
|
}) => theme2.click.fileUpload.sm.space.gap);
|
|
16662
|
-
const FileInfo = styled$1.div.withConfig({
|
|
16662
|
+
const FileInfo$1 = styled$1.div.withConfig({
|
|
16663
16663
|
componentId: "sc-1rzizve-7"
|
|
16664
16664
|
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
16665
16665
|
theme: theme2
|
|
16666
16666
|
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
16667
|
-
const FileDetails = styled$1.div.withConfig({
|
|
16667
|
+
const FileDetails$1 = styled$1.div.withConfig({
|
|
16668
16668
|
componentId: "sc-1rzizve-8"
|
|
16669
16669
|
})(["display:flex;gap:", ";border:none;"], ({
|
|
16670
16670
|
theme: theme2
|
|
16671
16671
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
16672
|
-
const FileActions = styled$1.div.withConfig({
|
|
16672
|
+
const FileActions$1 = styled$1.div.withConfig({
|
|
16673
16673
|
componentId: "sc-1rzizve-9"
|
|
16674
16674
|
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
16675
|
-
const ProgressContainer$
|
|
16675
|
+
const ProgressContainer$2 = styled$1.div.withConfig({
|
|
16676
16676
|
componentId: "sc-1rzizve-10"
|
|
16677
16677
|
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
16678
|
-
const ProgressBarContainer = styled$1.div.withConfig({
|
|
16678
|
+
const ProgressBarContainer$1 = styled$1.div.withConfig({
|
|
16679
16679
|
componentId: "sc-1rzizve-11"
|
|
16680
16680
|
})(["width:100%;flex:1;"]);
|
|
16681
|
-
const ProgressPercentage = styled$1(Text).withConfig({
|
|
16681
|
+
const ProgressPercentage$1 = styled$1(Text).withConfig({
|
|
16682
16682
|
componentId: "sc-1rzizve-12"
|
|
16683
16683
|
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
16684
16684
|
theme: theme2
|
|
16685
16685
|
}) => theme2.sizes[10], ({
|
|
16686
16686
|
theme: theme2
|
|
16687
16687
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
16688
|
-
const formatFileSize = (sizeInBytes) => {
|
|
16688
|
+
const formatFileSize$1 = (sizeInBytes) => {
|
|
16689
16689
|
if (sizeInBytes < 1024) {
|
|
16690
16690
|
return `${sizeInBytes.toFixed(1)} B`;
|
|
16691
16691
|
} else if (sizeInBytes < 1024 * 1024) {
|
|
@@ -16696,7 +16696,7 @@ const formatFileSize = (sizeInBytes) => {
|
|
|
16696
16696
|
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
16697
16697
|
}
|
|
16698
16698
|
};
|
|
16699
|
-
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
16699
|
+
const isFiletypeSupported$1 = (filename, supportedTypes) => {
|
|
16700
16700
|
if (!supportedTypes.length) return true;
|
|
16701
16701
|
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
16702
16702
|
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
@@ -16766,13 +16766,10 @@ const FileUpload = ({
|
|
|
16766
16766
|
};
|
|
16767
16767
|
}, []);
|
|
16768
16768
|
const processFile = useCallback((file2) => {
|
|
16769
|
-
if (!isFiletypeSupported(file2.name, supportedFileTypes)) {
|
|
16769
|
+
if (!isFiletypeSupported$1(file2.name, supportedFileTypes)) {
|
|
16770
|
+
setIsNotSupported(true);
|
|
16770
16771
|
if (onFileFailure) {
|
|
16771
16772
|
onFileFailure();
|
|
16772
|
-
console.log("File type not supported");
|
|
16773
|
-
setIsNotSupported(true);
|
|
16774
|
-
} else {
|
|
16775
|
-
console.warn(`File type not supported: ${file2.name}`);
|
|
16776
16773
|
}
|
|
16777
16774
|
return;
|
|
16778
16775
|
}
|
|
@@ -16781,9 +16778,9 @@ const FileUpload = ({
|
|
|
16781
16778
|
size: file2.size
|
|
16782
16779
|
};
|
|
16783
16780
|
setFile(newFile);
|
|
16781
|
+
setIsNotSupported(false);
|
|
16784
16782
|
if (onFileSelect) {
|
|
16785
16783
|
onFileSelect(file2);
|
|
16786
|
-
setIsNotSupported(false);
|
|
16787
16784
|
}
|
|
16788
16785
|
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
16789
16786
|
const handleDrop = useCallback((e) => {
|
|
@@ -16823,11 +16820,11 @@ const FileUpload = ({
|
|
|
16823
16820
|
}, [onRetry]);
|
|
16824
16821
|
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
16825
16822
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
16826
|
-
/* @__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: [
|
|
16827
|
-
/* @__PURE__ */ jsx(UploadIcon, { name: "upload" }),
|
|
16828
|
-
/* @__PURE__ */ jsxs(UploadText, { $size: size2, $hasFile: false, children: [
|
|
16829
|
-
isNotSupported ? /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: isNotSupported, type: "h1", children: title }),
|
|
16830
|
-
/* @__PURE__ */ jsxs(FileUploadDescription, { children: [
|
|
16823
|
+
/* @__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: [
|
|
16824
|
+
/* @__PURE__ */ jsx(UploadIcon$1, { name: "upload" }),
|
|
16825
|
+
/* @__PURE__ */ jsxs(UploadText$1, { $size: size2, $hasFile: false, children: [
|
|
16826
|
+
isNotSupported ? /* @__PURE__ */ jsx(FileUploadTitle$1, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsx(FileUploadTitle$1, { $isNotSupported: isNotSupported, type: "h1", children: title }),
|
|
16827
|
+
/* @__PURE__ */ jsxs(FileUploadDescription$1, { children: [
|
|
16831
16828
|
"Files supported: ",
|
|
16832
16829
|
supportedFileTypes.join(", ")
|
|
16833
16830
|
] })
|
|
@@ -16836,23 +16833,23 @@ const FileUpload = ({
|
|
|
16836
16833
|
e.stopPropagation();
|
|
16837
16834
|
handleBrowseClick();
|
|
16838
16835
|
}, children: "Browse file" })
|
|
16839
|
-
] }) : /* @__PURE__ */ jsxs(FileInfo, { children: [
|
|
16840
|
-
/* @__PURE__ */ jsxs(FileInfoHeader, { children: [
|
|
16841
|
-
/* @__PURE__ */ jsx(DocumentIcon, { name: "document" }),
|
|
16842
|
-
/* @__PURE__ */ jsxs(FileDetails, { children: [
|
|
16836
|
+
] }) : /* @__PURE__ */ jsxs(FileInfo$1, { children: [
|
|
16837
|
+
/* @__PURE__ */ jsxs(FileInfoHeader$1, { children: [
|
|
16838
|
+
/* @__PURE__ */ jsx(DocumentIcon$1, { name: "document" }),
|
|
16839
|
+
/* @__PURE__ */ jsxs(FileDetails$1, { children: [
|
|
16843
16840
|
/* @__PURE__ */ jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
16844
|
-
(showSuccess || showProgress) && /* @__PURE__ */ jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
16841
|
+
(showSuccess || showProgress) && /* @__PURE__ */ jsx(Text, { size: "md", color: "muted", children: formatFileSize$1(file.size) }),
|
|
16845
16842
|
!showProgress && !showSuccess && /* @__PURE__ */ jsx(Text, { size: "md", color: "danger", children: failureMessage }),
|
|
16846
16843
|
showSuccess && /* @__PURE__ */ jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
16847
16844
|
] }),
|
|
16848
|
-
/* @__PURE__ */ jsxs(FileActions, { children: [
|
|
16845
|
+
/* @__PURE__ */ jsxs(FileActions$1, { children: [
|
|
16849
16846
|
!showProgress && !showSuccess && /* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: handleRetryUpload }),
|
|
16850
16847
|
/* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: handleRemoveFile })
|
|
16851
16848
|
] })
|
|
16852
16849
|
] }),
|
|
16853
|
-
showProgress && /* @__PURE__ */ jsxs(ProgressContainer$
|
|
16854
|
-
/* @__PURE__ */ jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsx(ProgressBar, { progress, type: "small" }) }),
|
|
16855
|
-
/* @__PURE__ */ jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
16850
|
+
showProgress && /* @__PURE__ */ jsxs(ProgressContainer$2, { children: [
|
|
16851
|
+
/* @__PURE__ */ jsx(ProgressBarContainer$1, { children: /* @__PURE__ */ jsx(ProgressBar, { progress, type: "small" }) }),
|
|
16852
|
+
/* @__PURE__ */ jsxs(ProgressPercentage$1, { size: "sm", color: "muted", children: [
|
|
16856
16853
|
progress,
|
|
16857
16854
|
"%"
|
|
16858
16855
|
] })
|
|
@@ -16863,6 +16860,280 @@ const FileUpload = ({
|
|
|
16863
16860
|
} })
|
|
16864
16861
|
] });
|
|
16865
16862
|
};
|
|
16863
|
+
const UploadArea = styled$1.div.withConfig({
|
|
16864
|
+
componentId: "sc-1w9rsfj-0"
|
|
16865
|
+
})(["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:", ";", ""], ({
|
|
16866
|
+
theme: theme2
|
|
16867
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
16868
|
+
theme: theme2
|
|
16869
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
16870
|
+
theme: theme2
|
|
16871
|
+
}) => theme2.click.fileUpload.md.radii.all, ({
|
|
16872
|
+
theme: theme2
|
|
16873
|
+
}) => `${theme2.click.fileUpload.md.space.y} ${theme2.click.fileUpload.md.space.x}`, ({
|
|
16874
|
+
theme: theme2
|
|
16875
|
+
}) => theme2.click.fileUpload.md.space.gap, ({
|
|
16876
|
+
theme: theme2
|
|
16877
|
+
}) => theme2.click.fileUpload.transitions.all, ({
|
|
16878
|
+
theme: theme2
|
|
16879
|
+
}) => theme2.click.fileUpload.color.stroke.default, (props) => props.$isDragging && css$1(["background-color:", ";border-color:", ";"], ({
|
|
16880
|
+
theme: theme2
|
|
16881
|
+
}) => theme2.click.fileUpload.color.background.active, ({
|
|
16882
|
+
theme: theme2
|
|
16883
|
+
}) => theme2.click.fileUpload.color.stroke.active));
|
|
16884
|
+
const FileUploadTitle = styled$1(Title$2).withConfig({
|
|
16885
|
+
componentId: "sc-1w9rsfj-1"
|
|
16886
|
+
})(["font:", ";color:", ";"], ({
|
|
16887
|
+
theme: theme2
|
|
16888
|
+
}) => theme2.click.fileUpload.typography.title.default, ({
|
|
16889
|
+
theme: theme2,
|
|
16890
|
+
$isNotSupported
|
|
16891
|
+
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
16892
|
+
const FileUploadDescription = styled$1(Text).withConfig({
|
|
16893
|
+
componentId: "sc-1w9rsfj-2"
|
|
16894
|
+
})(["font:", ";color:", ";"], ({
|
|
16895
|
+
theme: theme2
|
|
16896
|
+
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
16897
|
+
theme: theme2
|
|
16898
|
+
}) => theme2.click.fileUpload.color.description.default);
|
|
16899
|
+
const UploadIcon = styled$1(SvgImage).withConfig({
|
|
16900
|
+
componentId: "sc-1w9rsfj-3"
|
|
16901
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16902
|
+
theme: theme2
|
|
16903
|
+
}) => theme2.click.fileUpload.md.icon.size.width, ({
|
|
16904
|
+
theme: theme2
|
|
16905
|
+
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
16906
|
+
theme: theme2
|
|
16907
|
+
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
16908
|
+
const UploadText = styled$1.div.withConfig({
|
|
16909
|
+
componentId: "sc-1w9rsfj-4"
|
|
16910
|
+
})(["text-align:center;display:flex;flex-direction:column;align-items:center;width:100%;"]);
|
|
16911
|
+
const FilesList = styled$1.div.withConfig({
|
|
16912
|
+
componentId: "sc-1w9rsfj-5"
|
|
16913
|
+
})(["display:flex;flex-direction:column;gap:", ";width:100%;margin-top:", ";"], ({
|
|
16914
|
+
theme: theme2
|
|
16915
|
+
}) => theme2.click.fileUpload.sm.space.gap, ({
|
|
16916
|
+
theme: theme2
|
|
16917
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
16918
|
+
const FileItem = styled$1.div.withConfig({
|
|
16919
|
+
componentId: "sc-1w9rsfj-6"
|
|
16920
|
+
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:", ";", ""], ({
|
|
16921
|
+
theme: theme2
|
|
16922
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
16923
|
+
theme: theme2
|
|
16924
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
16925
|
+
theme: theme2
|
|
16926
|
+
}) => theme2.click.fileUpload.sm.radii.all, ({
|
|
16927
|
+
theme: theme2
|
|
16928
|
+
}) => `${theme2.click.fileUpload.sm.space.y} ${theme2.click.fileUpload.sm.space.x}`, ({
|
|
16929
|
+
theme: theme2
|
|
16930
|
+
}) => theme2.click.fileUpload.sm.space.gap, (props) => props.$isError && css$1(["background-color:", ";border:none;"], ({
|
|
16931
|
+
theme: theme2
|
|
16932
|
+
}) => theme2.click.fileUpload.color.background.error));
|
|
16933
|
+
const DocumentIcon = styled$1(SvgImage).withConfig({
|
|
16934
|
+
componentId: "sc-1w9rsfj-7"
|
|
16935
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16936
|
+
theme: theme2
|
|
16937
|
+
}) => theme2.click.fileUpload.sm.icon.size.width, ({
|
|
16938
|
+
theme: theme2
|
|
16939
|
+
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
16940
|
+
theme: theme2
|
|
16941
|
+
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
16942
|
+
const FileInfoHeader = styled$1.div.withConfig({
|
|
16943
|
+
componentId: "sc-1w9rsfj-8"
|
|
16944
|
+
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
16945
|
+
theme: theme2
|
|
16946
|
+
}) => theme2.click.fileUpload.sm.space.gap);
|
|
16947
|
+
const FileInfo = styled$1.div.withConfig({
|
|
16948
|
+
componentId: "sc-1w9rsfj-9"
|
|
16949
|
+
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
16950
|
+
theme: theme2
|
|
16951
|
+
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
16952
|
+
const FileDetails = styled$1.div.withConfig({
|
|
16953
|
+
componentId: "sc-1w9rsfj-10"
|
|
16954
|
+
})(["display:flex;gap:", ";border:none;"], ({
|
|
16955
|
+
theme: theme2
|
|
16956
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
16957
|
+
const FileActions = styled$1.div.withConfig({
|
|
16958
|
+
componentId: "sc-1w9rsfj-11"
|
|
16959
|
+
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
16960
|
+
const ProgressContainer$1 = styled$1.div.withConfig({
|
|
16961
|
+
componentId: "sc-1w9rsfj-12"
|
|
16962
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
16963
|
+
const ProgressBarContainer = styled$1.div.withConfig({
|
|
16964
|
+
componentId: "sc-1w9rsfj-13"
|
|
16965
|
+
})(["width:100%;flex:1;"]);
|
|
16966
|
+
const ProgressPercentage = styled$1(Text).withConfig({
|
|
16967
|
+
componentId: "sc-1w9rsfj-14"
|
|
16968
|
+
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
16969
|
+
theme: theme2
|
|
16970
|
+
}) => theme2.sizes[10], ({
|
|
16971
|
+
theme: theme2
|
|
16972
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
16973
|
+
const formatFileSize = (sizeInBytes) => {
|
|
16974
|
+
if (sizeInBytes < 1024) {
|
|
16975
|
+
return `${sizeInBytes.toFixed(1)} B`;
|
|
16976
|
+
} else if (sizeInBytes < 1024 * 1024) {
|
|
16977
|
+
return `${(sizeInBytes / 1024).toFixed(1)} KB`;
|
|
16978
|
+
} else if (sizeInBytes < 1024 * 1024 * 1024) {
|
|
16979
|
+
return `${(sizeInBytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
16980
|
+
} else {
|
|
16981
|
+
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
16982
|
+
}
|
|
16983
|
+
};
|
|
16984
|
+
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
16985
|
+
if (!supportedTypes.length) return true;
|
|
16986
|
+
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
16987
|
+
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
16988
|
+
};
|
|
16989
|
+
const FileMultiUpload = ({
|
|
16990
|
+
title,
|
|
16991
|
+
supportedFileTypes = [".txt", ".sql"],
|
|
16992
|
+
files,
|
|
16993
|
+
onFileSelect,
|
|
16994
|
+
onFileRetry,
|
|
16995
|
+
onFileRemove,
|
|
16996
|
+
onFileFailure
|
|
16997
|
+
}) => {
|
|
16998
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
16999
|
+
const [isSupported, setIsSupported] = useState(true);
|
|
17000
|
+
const fileInputRef = useRef(null);
|
|
17001
|
+
const dragCounterRef = useRef(0);
|
|
17002
|
+
useEffect(() => {
|
|
17003
|
+
let timeoutId;
|
|
17004
|
+
if (!isSupported) {
|
|
17005
|
+
timeoutId = setTimeout(() => {
|
|
17006
|
+
setIsSupported(true);
|
|
17007
|
+
}, 2e3);
|
|
17008
|
+
}
|
|
17009
|
+
return () => {
|
|
17010
|
+
if (timeoutId) {
|
|
17011
|
+
clearTimeout(timeoutId);
|
|
17012
|
+
}
|
|
17013
|
+
};
|
|
17014
|
+
}, [isSupported]);
|
|
17015
|
+
const handleDragEnter = useCallback((e) => {
|
|
17016
|
+
e.preventDefault();
|
|
17017
|
+
e.stopPropagation();
|
|
17018
|
+
dragCounterRef.current += 1;
|
|
17019
|
+
setIsDragging(true);
|
|
17020
|
+
}, []);
|
|
17021
|
+
const handleDragLeave = useCallback((e) => {
|
|
17022
|
+
e.preventDefault();
|
|
17023
|
+
e.stopPropagation();
|
|
17024
|
+
dragCounterRef.current -= 1;
|
|
17025
|
+
if (dragCounterRef.current <= 0) {
|
|
17026
|
+
setIsDragging(false);
|
|
17027
|
+
dragCounterRef.current = 0;
|
|
17028
|
+
}
|
|
17029
|
+
}, []);
|
|
17030
|
+
const handleDragOver = useCallback((e) => {
|
|
17031
|
+
e.preventDefault();
|
|
17032
|
+
e.stopPropagation();
|
|
17033
|
+
}, []);
|
|
17034
|
+
useEffect(() => {
|
|
17035
|
+
const handleDragEnd = () => {
|
|
17036
|
+
setIsDragging(false);
|
|
17037
|
+
dragCounterRef.current = 0;
|
|
17038
|
+
};
|
|
17039
|
+
window.addEventListener("dragend", handleDragEnd);
|
|
17040
|
+
document.addEventListener("drop", handleDragEnd);
|
|
17041
|
+
document.addEventListener("mouseleave", handleDragEnd);
|
|
17042
|
+
return () => {
|
|
17043
|
+
window.removeEventListener("dragend", handleDragEnd);
|
|
17044
|
+
document.removeEventListener("drop", handleDragEnd);
|
|
17045
|
+
document.removeEventListener("mouseleave", handleDragEnd);
|
|
17046
|
+
};
|
|
17047
|
+
}, []);
|
|
17048
|
+
const processFile = useCallback((file) => {
|
|
17049
|
+
if (!isFiletypeSupported(file.name, supportedFileTypes)) {
|
|
17050
|
+
setIsSupported(false);
|
|
17051
|
+
if (onFileFailure) {
|
|
17052
|
+
onFileFailure();
|
|
17053
|
+
}
|
|
17054
|
+
return;
|
|
17055
|
+
}
|
|
17056
|
+
setIsSupported(true);
|
|
17057
|
+
if (onFileSelect) {
|
|
17058
|
+
onFileSelect(file);
|
|
17059
|
+
}
|
|
17060
|
+
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
17061
|
+
const handleDrop = useCallback((e) => {
|
|
17062
|
+
e.preventDefault();
|
|
17063
|
+
e.stopPropagation();
|
|
17064
|
+
setIsDragging(false);
|
|
17065
|
+
dragCounterRef.current = 0;
|
|
17066
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
17067
|
+
Array.from(e.dataTransfer.files).forEach((file) => {
|
|
17068
|
+
processFile(file);
|
|
17069
|
+
});
|
|
17070
|
+
}
|
|
17071
|
+
}, [processFile]);
|
|
17072
|
+
const handleFileSelect = useCallback((e) => {
|
|
17073
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
17074
|
+
Array.from(e.target.files).forEach((file) => {
|
|
17075
|
+
processFile(file);
|
|
17076
|
+
});
|
|
17077
|
+
}
|
|
17078
|
+
}, [processFile]);
|
|
17079
|
+
const handleBrowseClick = useCallback(() => {
|
|
17080
|
+
if (fileInputRef.current) {
|
|
17081
|
+
fileInputRef.current.click();
|
|
17082
|
+
}
|
|
17083
|
+
}, []);
|
|
17084
|
+
const handleRemoveFile = useCallback((fileId) => {
|
|
17085
|
+
if (onFileRemove) {
|
|
17086
|
+
onFileRemove(fileId);
|
|
17087
|
+
}
|
|
17088
|
+
}, [onFileRemove]);
|
|
17089
|
+
const handleRetryUpload = useCallback((fileId) => {
|
|
17090
|
+
if (onFileRetry) {
|
|
17091
|
+
onFileRetry(fileId);
|
|
17092
|
+
}
|
|
17093
|
+
}, [onFileRetry]);
|
|
17094
|
+
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
17095
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
17096
|
+
/* @__PURE__ */ jsxs(UploadArea, { $isDragging: isDragging, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleBrowseClick, children: [
|
|
17097
|
+
/* @__PURE__ */ jsx(UploadIcon, { name: "upload" }),
|
|
17098
|
+
/* @__PURE__ */ jsxs(UploadText, { children: [
|
|
17099
|
+
!isSupported ? /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsx(FileUploadTitle, { $isNotSupported: !isSupported, type: "h1", children: title }),
|
|
17100
|
+
/* @__PURE__ */ jsxs(FileUploadDescription, { children: [
|
|
17101
|
+
"Files supported: ",
|
|
17102
|
+
supportedFileTypes.join(", ")
|
|
17103
|
+
] })
|
|
17104
|
+
] }),
|
|
17105
|
+
/* @__PURE__ */ jsx(Button, { type: "secondary", onClick: (e) => {
|
|
17106
|
+
e.stopPropagation();
|
|
17107
|
+
handleBrowseClick();
|
|
17108
|
+
}, children: "Browse files" })
|
|
17109
|
+
] }),
|
|
17110
|
+
files.length > 0 && /* @__PURE__ */ jsx(FilesList, { children: files.map((file) => /* @__PURE__ */ jsx(FileItem, { $isError: file.status === "error", children: /* @__PURE__ */ jsxs(FileInfo, { children: [
|
|
17111
|
+
/* @__PURE__ */ jsxs(FileInfoHeader, { children: [
|
|
17112
|
+
/* @__PURE__ */ jsx(DocumentIcon, { name: "document" }),
|
|
17113
|
+
/* @__PURE__ */ jsxs(FileDetails, { children: [
|
|
17114
|
+
/* @__PURE__ */ jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
17115
|
+
(file.status === "success" || file.status === "uploading") && /* @__PURE__ */ jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
17116
|
+
file.status === "error" && /* @__PURE__ */ jsx(Text, { size: "md", color: "danger", children: file.errorMessage || "Upload failed" }),
|
|
17117
|
+
file.status === "success" && /* @__PURE__ */ jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
17118
|
+
] }),
|
|
17119
|
+
/* @__PURE__ */ jsxs(FileActions, { children: [
|
|
17120
|
+
file.status === "error" && /* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: () => handleRetryUpload(file.id) }),
|
|
17121
|
+
/* @__PURE__ */ jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: () => handleRemoveFile(file.id) })
|
|
17122
|
+
] })
|
|
17123
|
+
] }),
|
|
17124
|
+
file.status === "uploading" && /* @__PURE__ */ jsxs(ProgressContainer$1, { children: [
|
|
17125
|
+
/* @__PURE__ */ jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsx(ProgressBar, { progress: file.progress, type: "small" }) }),
|
|
17126
|
+
/* @__PURE__ */ jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
17127
|
+
file.progress,
|
|
17128
|
+
"%"
|
|
17129
|
+
] })
|
|
17130
|
+
] })
|
|
17131
|
+
] }) }, file.id)) }),
|
|
17132
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: fileInputRef, accept: acceptedFileTypes, onChange: handleFileSelect, multiple: true, style: {
|
|
17133
|
+
display: "none"
|
|
17134
|
+
} })
|
|
17135
|
+
] });
|
|
17136
|
+
};
|
|
16866
17137
|
const Flyout = ({
|
|
16867
17138
|
modal = false,
|
|
16868
17139
|
...props
|
|
@@ -50944,6 +51215,7 @@ export {
|
|
|
50944
51215
|
Dialog,
|
|
50945
51216
|
Dropdown,
|
|
50946
51217
|
EllipsisContent,
|
|
51218
|
+
FileMultiUpload,
|
|
50947
51219
|
FileTabElement,
|
|
50948
51220
|
FileTabs,
|
|
50949
51221
|
FileUpload,
|
|
@@ -51000,3 +51272,4 @@ export {
|
|
|
51000
51272
|
useCUITheme,
|
|
51001
51273
|
useToast
|
|
51002
51274
|
};
|
|
51275
|
+
//# sourceMappingURL=click-ui.es.js.map
|