@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
package/dist/click-ui.umd.js
CHANGED
|
@@ -16606,7 +16606,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16606
16606
|
const truncatedName = nameWithoutExtension.slice(0, maxLength) + delimiter;
|
|
16607
16607
|
return truncatedName + extension;
|
|
16608
16608
|
};
|
|
16609
|
-
const UploadArea = styled.div.withConfig({
|
|
16609
|
+
const UploadArea$1 = styled.div.withConfig({
|
|
16610
16610
|
componentId: "sc-1rzizve-0"
|
|
16611
16611
|
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:", ";align-items:center;justify-content:", ";gap:", ";cursor:", ";transition:", ";", " ", ""], ({
|
|
16612
16612
|
theme: theme2
|
|
@@ -16633,7 +16633,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16633
16633
|
}) => theme2.click.fileUpload.color.stroke.active)), (props) => props.$isError && styled.css(["background-color:", ";border:none;"], ({
|
|
16634
16634
|
theme: theme2
|
|
16635
16635
|
}) => theme2.click.fileUpload.color.background.error));
|
|
16636
|
-
const FileUploadTitle = styled(Title$2).withConfig({
|
|
16636
|
+
const FileUploadTitle$1 = styled(Title$2).withConfig({
|
|
16637
16637
|
componentId: "sc-1rzizve-1"
|
|
16638
16638
|
})(["font:", ";color:", ";"], ({
|
|
16639
16639
|
theme: theme2
|
|
@@ -16641,14 +16641,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16641
16641
|
theme: theme2,
|
|
16642
16642
|
$isNotSupported
|
|
16643
16643
|
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
16644
|
-
const FileUploadDescription = styled(Text).withConfig({
|
|
16644
|
+
const FileUploadDescription$1 = styled(Text).withConfig({
|
|
16645
16645
|
componentId: "sc-1rzizve-2"
|
|
16646
16646
|
})(["font:", ";color:", ";"], ({
|
|
16647
16647
|
theme: theme2
|
|
16648
16648
|
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
16649
16649
|
theme: theme2
|
|
16650
16650
|
}) => theme2.click.fileUpload.color.description.default);
|
|
16651
|
-
const DocumentIcon = styled(SvgImage).withConfig({
|
|
16651
|
+
const DocumentIcon$1 = styled(SvgImage).withConfig({
|
|
16652
16652
|
componentId: "sc-1rzizve-3"
|
|
16653
16653
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16654
16654
|
theme: theme2
|
|
@@ -16657,7 +16657,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16657
16657
|
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
16658
16658
|
theme: theme2
|
|
16659
16659
|
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
16660
|
-
const UploadIcon = styled(SvgImage).withConfig({
|
|
16660
|
+
const UploadIcon$1 = styled(SvgImage).withConfig({
|
|
16661
16661
|
componentId: "sc-1rzizve-4"
|
|
16662
16662
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16663
16663
|
theme: theme2
|
|
@@ -16666,41 +16666,41 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16666
16666
|
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
16667
16667
|
theme: theme2
|
|
16668
16668
|
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
16669
|
-
const UploadText = styled.div.withConfig({
|
|
16669
|
+
const UploadText$1 = styled.div.withConfig({
|
|
16670
16670
|
componentId: "sc-1rzizve-5"
|
|
16671
16671
|
})(["text-align:", ";", " ", ""], (props) => props.$hasFile || props.$size === "sm" ? "left" : "center", (props) => (props.$hasFile || props.$size === "sm") && styled.css(["flex:1;"]), (props) => !props.$hasFile && props.$size === "md" && styled.css(["display:flex;flex-direction:column;align-items:center;width:100%;"]));
|
|
16672
|
-
const FileInfoHeader = styled.div.withConfig({
|
|
16672
|
+
const FileInfoHeader$1 = styled.div.withConfig({
|
|
16673
16673
|
componentId: "sc-1rzizve-6"
|
|
16674
16674
|
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
16675
16675
|
theme: theme2
|
|
16676
16676
|
}) => theme2.click.fileUpload.sm.space.gap);
|
|
16677
|
-
const FileInfo = styled.div.withConfig({
|
|
16677
|
+
const FileInfo$1 = styled.div.withConfig({
|
|
16678
16678
|
componentId: "sc-1rzizve-7"
|
|
16679
16679
|
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
16680
16680
|
theme: theme2
|
|
16681
16681
|
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
16682
|
-
const FileDetails = styled.div.withConfig({
|
|
16682
|
+
const FileDetails$1 = styled.div.withConfig({
|
|
16683
16683
|
componentId: "sc-1rzizve-8"
|
|
16684
16684
|
})(["display:flex;gap:", ";border:none;"], ({
|
|
16685
16685
|
theme: theme2
|
|
16686
16686
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
16687
|
-
const FileActions = styled.div.withConfig({
|
|
16687
|
+
const FileActions$1 = styled.div.withConfig({
|
|
16688
16688
|
componentId: "sc-1rzizve-9"
|
|
16689
16689
|
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
16690
|
-
const ProgressContainer$
|
|
16690
|
+
const ProgressContainer$2 = styled.div.withConfig({
|
|
16691
16691
|
componentId: "sc-1rzizve-10"
|
|
16692
16692
|
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
16693
|
-
const ProgressBarContainer = styled.div.withConfig({
|
|
16693
|
+
const ProgressBarContainer$1 = styled.div.withConfig({
|
|
16694
16694
|
componentId: "sc-1rzizve-11"
|
|
16695
16695
|
})(["width:100%;flex:1;"]);
|
|
16696
|
-
const ProgressPercentage = styled(Text).withConfig({
|
|
16696
|
+
const ProgressPercentage$1 = styled(Text).withConfig({
|
|
16697
16697
|
componentId: "sc-1rzizve-12"
|
|
16698
16698
|
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
16699
16699
|
theme: theme2
|
|
16700
16700
|
}) => theme2.sizes[10], ({
|
|
16701
16701
|
theme: theme2
|
|
16702
16702
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
16703
|
-
const formatFileSize = (sizeInBytes) => {
|
|
16703
|
+
const formatFileSize$1 = (sizeInBytes) => {
|
|
16704
16704
|
if (sizeInBytes < 1024) {
|
|
16705
16705
|
return `${sizeInBytes.toFixed(1)} B`;
|
|
16706
16706
|
} else if (sizeInBytes < 1024 * 1024) {
|
|
@@ -16711,7 +16711,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16711
16711
|
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
16712
16712
|
}
|
|
16713
16713
|
};
|
|
16714
|
-
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
16714
|
+
const isFiletypeSupported$1 = (filename, supportedTypes) => {
|
|
16715
16715
|
if (!supportedTypes.length) return true;
|
|
16716
16716
|
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
16717
16717
|
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
@@ -16781,13 +16781,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16781
16781
|
};
|
|
16782
16782
|
}, []);
|
|
16783
16783
|
const processFile = React.useCallback((file2) => {
|
|
16784
|
-
if (!isFiletypeSupported(file2.name, supportedFileTypes)) {
|
|
16784
|
+
if (!isFiletypeSupported$1(file2.name, supportedFileTypes)) {
|
|
16785
|
+
setIsNotSupported(true);
|
|
16785
16786
|
if (onFileFailure) {
|
|
16786
16787
|
onFileFailure();
|
|
16787
|
-
console.log("File type not supported");
|
|
16788
|
-
setIsNotSupported(true);
|
|
16789
|
-
} else {
|
|
16790
|
-
console.warn(`File type not supported: ${file2.name}`);
|
|
16791
16788
|
}
|
|
16792
16789
|
return;
|
|
16793
16790
|
}
|
|
@@ -16796,9 +16793,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16796
16793
|
size: file2.size
|
|
16797
16794
|
};
|
|
16798
16795
|
setFile(newFile);
|
|
16796
|
+
setIsNotSupported(false);
|
|
16799
16797
|
if (onFileSelect) {
|
|
16800
16798
|
onFileSelect(file2);
|
|
16801
|
-
setIsNotSupported(false);
|
|
16802
16799
|
}
|
|
16803
16800
|
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
16804
16801
|
const handleDrop = React.useCallback((e) => {
|
|
@@ -16838,11 +16835,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16838
16835
|
}, [onRetry]);
|
|
16839
16836
|
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
16840
16837
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
16841
|
-
/* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
16842
|
-
/* @__PURE__ */ jsxRuntime.jsx(UploadIcon, { name: "upload" }),
|
|
16843
|
-
/* @__PURE__ */ jsxRuntime.jsxs(UploadText, { $size: size2, $hasFile: false, children: [
|
|
16844
|
-
isNotSupported ? /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: isNotSupported, type: "h1", children: title }),
|
|
16845
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileUploadDescription, { children: [
|
|
16838
|
+
/* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
16839
|
+
/* @__PURE__ */ jsxRuntime.jsx(UploadIcon$1, { name: "upload" }),
|
|
16840
|
+
/* @__PURE__ */ jsxRuntime.jsxs(UploadText$1, { $size: size2, $hasFile: false, children: [
|
|
16841
|
+
isNotSupported ? /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle$1, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle$1, { $isNotSupported: isNotSupported, type: "h1", children: title }),
|
|
16842
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileUploadDescription$1, { children: [
|
|
16846
16843
|
"Files supported: ",
|
|
16847
16844
|
supportedFileTypes.join(", ")
|
|
16848
16845
|
] })
|
|
@@ -16851,23 +16848,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16851
16848
|
e.stopPropagation();
|
|
16852
16849
|
handleBrowseClick();
|
|
16853
16850
|
}, children: "Browse file" })
|
|
16854
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(FileInfo, { children: [
|
|
16855
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileInfoHeader, { children: [
|
|
16856
|
-
/* @__PURE__ */ jsxRuntime.jsx(DocumentIcon, { name: "document" }),
|
|
16857
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileDetails, { children: [
|
|
16851
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(FileInfo$1, { children: [
|
|
16852
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileInfoHeader$1, { children: [
|
|
16853
|
+
/* @__PURE__ */ jsxRuntime.jsx(DocumentIcon$1, { name: "document" }),
|
|
16854
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileDetails$1, { children: [
|
|
16858
16855
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
16859
|
-
(showSuccess || showProgress) && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
16856
|
+
(showSuccess || showProgress) && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "muted", children: formatFileSize$1(file.size) }),
|
|
16860
16857
|
!showProgress && !showSuccess && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "danger", children: failureMessage }),
|
|
16861
16858
|
showSuccess && /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
16862
16859
|
] }),
|
|
16863
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileActions, { children: [
|
|
16860
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileActions$1, { children: [
|
|
16864
16861
|
!showProgress && !showSuccess && /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: handleRetryUpload }),
|
|
16865
16862
|
/* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: handleRemoveFile })
|
|
16866
16863
|
] })
|
|
16867
16864
|
] }),
|
|
16868
|
-
showProgress && /* @__PURE__ */ jsxRuntime.jsxs(ProgressContainer$
|
|
16869
|
-
/* @__PURE__ */ jsxRuntime.jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress, type: "small" }) }),
|
|
16870
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
16865
|
+
showProgress && /* @__PURE__ */ jsxRuntime.jsxs(ProgressContainer$2, { children: [
|
|
16866
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProgressBarContainer$1, { children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress, type: "small" }) }),
|
|
16867
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProgressPercentage$1, { size: "sm", color: "muted", children: [
|
|
16871
16868
|
progress,
|
|
16872
16869
|
"%"
|
|
16873
16870
|
] })
|
|
@@ -16878,6 +16875,280 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
16878
16875
|
} })
|
|
16879
16876
|
] });
|
|
16880
16877
|
};
|
|
16878
|
+
const UploadArea = styled.div.withConfig({
|
|
16879
|
+
componentId: "sc-1w9rsfj-0"
|
|
16880
|
+
})(["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:", ";", ""], ({
|
|
16881
|
+
theme: theme2
|
|
16882
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
16883
|
+
theme: theme2
|
|
16884
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
16885
|
+
theme: theme2
|
|
16886
|
+
}) => theme2.click.fileUpload.md.radii.all, ({
|
|
16887
|
+
theme: theme2
|
|
16888
|
+
}) => `${theme2.click.fileUpload.md.space.y} ${theme2.click.fileUpload.md.space.x}`, ({
|
|
16889
|
+
theme: theme2
|
|
16890
|
+
}) => theme2.click.fileUpload.md.space.gap, ({
|
|
16891
|
+
theme: theme2
|
|
16892
|
+
}) => theme2.click.fileUpload.transitions.all, ({
|
|
16893
|
+
theme: theme2
|
|
16894
|
+
}) => theme2.click.fileUpload.color.stroke.default, (props) => props.$isDragging && styled.css(["background-color:", ";border-color:", ";"], ({
|
|
16895
|
+
theme: theme2
|
|
16896
|
+
}) => theme2.click.fileUpload.color.background.active, ({
|
|
16897
|
+
theme: theme2
|
|
16898
|
+
}) => theme2.click.fileUpload.color.stroke.active));
|
|
16899
|
+
const FileUploadTitle = styled(Title$2).withConfig({
|
|
16900
|
+
componentId: "sc-1w9rsfj-1"
|
|
16901
|
+
})(["font:", ";color:", ";"], ({
|
|
16902
|
+
theme: theme2
|
|
16903
|
+
}) => theme2.click.fileUpload.typography.title.default, ({
|
|
16904
|
+
theme: theme2,
|
|
16905
|
+
$isNotSupported
|
|
16906
|
+
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
16907
|
+
const FileUploadDescription = styled(Text).withConfig({
|
|
16908
|
+
componentId: "sc-1w9rsfj-2"
|
|
16909
|
+
})(["font:", ";color:", ";"], ({
|
|
16910
|
+
theme: theme2
|
|
16911
|
+
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
16912
|
+
theme: theme2
|
|
16913
|
+
}) => theme2.click.fileUpload.color.description.default);
|
|
16914
|
+
const UploadIcon = styled(SvgImage).withConfig({
|
|
16915
|
+
componentId: "sc-1w9rsfj-3"
|
|
16916
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16917
|
+
theme: theme2
|
|
16918
|
+
}) => theme2.click.fileUpload.md.icon.size.width, ({
|
|
16919
|
+
theme: theme2
|
|
16920
|
+
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
16921
|
+
theme: theme2
|
|
16922
|
+
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
16923
|
+
const UploadText = styled.div.withConfig({
|
|
16924
|
+
componentId: "sc-1w9rsfj-4"
|
|
16925
|
+
})(["text-align:center;display:flex;flex-direction:column;align-items:center;width:100%;"]);
|
|
16926
|
+
const FilesList = styled.div.withConfig({
|
|
16927
|
+
componentId: "sc-1w9rsfj-5"
|
|
16928
|
+
})(["display:flex;flex-direction:column;gap:", ";width:100%;margin-top:", ";"], ({
|
|
16929
|
+
theme: theme2
|
|
16930
|
+
}) => theme2.click.fileUpload.sm.space.gap, ({
|
|
16931
|
+
theme: theme2
|
|
16932
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
16933
|
+
const FileItem = styled.div.withConfig({
|
|
16934
|
+
componentId: "sc-1w9rsfj-6"
|
|
16935
|
+
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:", ";", ""], ({
|
|
16936
|
+
theme: theme2
|
|
16937
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
16938
|
+
theme: theme2
|
|
16939
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
16940
|
+
theme: theme2
|
|
16941
|
+
}) => theme2.click.fileUpload.sm.radii.all, ({
|
|
16942
|
+
theme: theme2
|
|
16943
|
+
}) => `${theme2.click.fileUpload.sm.space.y} ${theme2.click.fileUpload.sm.space.x}`, ({
|
|
16944
|
+
theme: theme2
|
|
16945
|
+
}) => theme2.click.fileUpload.sm.space.gap, (props) => props.$isError && styled.css(["background-color:", ";border:none;"], ({
|
|
16946
|
+
theme: theme2
|
|
16947
|
+
}) => theme2.click.fileUpload.color.background.error));
|
|
16948
|
+
const DocumentIcon = styled(SvgImage).withConfig({
|
|
16949
|
+
componentId: "sc-1w9rsfj-7"
|
|
16950
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
16951
|
+
theme: theme2
|
|
16952
|
+
}) => theme2.click.fileUpload.sm.icon.size.width, ({
|
|
16953
|
+
theme: theme2
|
|
16954
|
+
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
16955
|
+
theme: theme2
|
|
16956
|
+
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
16957
|
+
const FileInfoHeader = styled.div.withConfig({
|
|
16958
|
+
componentId: "sc-1w9rsfj-8"
|
|
16959
|
+
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
16960
|
+
theme: theme2
|
|
16961
|
+
}) => theme2.click.fileUpload.sm.space.gap);
|
|
16962
|
+
const FileInfo = styled.div.withConfig({
|
|
16963
|
+
componentId: "sc-1w9rsfj-9"
|
|
16964
|
+
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
16965
|
+
theme: theme2
|
|
16966
|
+
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
16967
|
+
const FileDetails = styled.div.withConfig({
|
|
16968
|
+
componentId: "sc-1w9rsfj-10"
|
|
16969
|
+
})(["display:flex;gap:", ";border:none;"], ({
|
|
16970
|
+
theme: theme2
|
|
16971
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
16972
|
+
const FileActions = styled.div.withConfig({
|
|
16973
|
+
componentId: "sc-1w9rsfj-11"
|
|
16974
|
+
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
16975
|
+
const ProgressContainer$1 = styled.div.withConfig({
|
|
16976
|
+
componentId: "sc-1w9rsfj-12"
|
|
16977
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
16978
|
+
const ProgressBarContainer = styled.div.withConfig({
|
|
16979
|
+
componentId: "sc-1w9rsfj-13"
|
|
16980
|
+
})(["width:100%;flex:1;"]);
|
|
16981
|
+
const ProgressPercentage = styled(Text).withConfig({
|
|
16982
|
+
componentId: "sc-1w9rsfj-14"
|
|
16983
|
+
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
16984
|
+
theme: theme2
|
|
16985
|
+
}) => theme2.sizes[10], ({
|
|
16986
|
+
theme: theme2
|
|
16987
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
16988
|
+
const formatFileSize = (sizeInBytes) => {
|
|
16989
|
+
if (sizeInBytes < 1024) {
|
|
16990
|
+
return `${sizeInBytes.toFixed(1)} B`;
|
|
16991
|
+
} else if (sizeInBytes < 1024 * 1024) {
|
|
16992
|
+
return `${(sizeInBytes / 1024).toFixed(1)} KB`;
|
|
16993
|
+
} else if (sizeInBytes < 1024 * 1024 * 1024) {
|
|
16994
|
+
return `${(sizeInBytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
16995
|
+
} else {
|
|
16996
|
+
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
16997
|
+
}
|
|
16998
|
+
};
|
|
16999
|
+
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
17000
|
+
if (!supportedTypes.length) return true;
|
|
17001
|
+
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
17002
|
+
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
17003
|
+
};
|
|
17004
|
+
const FileMultiUpload = ({
|
|
17005
|
+
title,
|
|
17006
|
+
supportedFileTypes = [".txt", ".sql"],
|
|
17007
|
+
files,
|
|
17008
|
+
onFileSelect,
|
|
17009
|
+
onFileRetry,
|
|
17010
|
+
onFileRemove,
|
|
17011
|
+
onFileFailure
|
|
17012
|
+
}) => {
|
|
17013
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
17014
|
+
const [isSupported, setIsSupported] = React.useState(true);
|
|
17015
|
+
const fileInputRef = React.useRef(null);
|
|
17016
|
+
const dragCounterRef = React.useRef(0);
|
|
17017
|
+
React.useEffect(() => {
|
|
17018
|
+
let timeoutId;
|
|
17019
|
+
if (!isSupported) {
|
|
17020
|
+
timeoutId = setTimeout(() => {
|
|
17021
|
+
setIsSupported(true);
|
|
17022
|
+
}, 2e3);
|
|
17023
|
+
}
|
|
17024
|
+
return () => {
|
|
17025
|
+
if (timeoutId) {
|
|
17026
|
+
clearTimeout(timeoutId);
|
|
17027
|
+
}
|
|
17028
|
+
};
|
|
17029
|
+
}, [isSupported]);
|
|
17030
|
+
const handleDragEnter = React.useCallback((e) => {
|
|
17031
|
+
e.preventDefault();
|
|
17032
|
+
e.stopPropagation();
|
|
17033
|
+
dragCounterRef.current += 1;
|
|
17034
|
+
setIsDragging(true);
|
|
17035
|
+
}, []);
|
|
17036
|
+
const handleDragLeave = React.useCallback((e) => {
|
|
17037
|
+
e.preventDefault();
|
|
17038
|
+
e.stopPropagation();
|
|
17039
|
+
dragCounterRef.current -= 1;
|
|
17040
|
+
if (dragCounterRef.current <= 0) {
|
|
17041
|
+
setIsDragging(false);
|
|
17042
|
+
dragCounterRef.current = 0;
|
|
17043
|
+
}
|
|
17044
|
+
}, []);
|
|
17045
|
+
const handleDragOver = React.useCallback((e) => {
|
|
17046
|
+
e.preventDefault();
|
|
17047
|
+
e.stopPropagation();
|
|
17048
|
+
}, []);
|
|
17049
|
+
React.useEffect(() => {
|
|
17050
|
+
const handleDragEnd = () => {
|
|
17051
|
+
setIsDragging(false);
|
|
17052
|
+
dragCounterRef.current = 0;
|
|
17053
|
+
};
|
|
17054
|
+
window.addEventListener("dragend", handleDragEnd);
|
|
17055
|
+
document.addEventListener("drop", handleDragEnd);
|
|
17056
|
+
document.addEventListener("mouseleave", handleDragEnd);
|
|
17057
|
+
return () => {
|
|
17058
|
+
window.removeEventListener("dragend", handleDragEnd);
|
|
17059
|
+
document.removeEventListener("drop", handleDragEnd);
|
|
17060
|
+
document.removeEventListener("mouseleave", handleDragEnd);
|
|
17061
|
+
};
|
|
17062
|
+
}, []);
|
|
17063
|
+
const processFile = React.useCallback((file) => {
|
|
17064
|
+
if (!isFiletypeSupported(file.name, supportedFileTypes)) {
|
|
17065
|
+
setIsSupported(false);
|
|
17066
|
+
if (onFileFailure) {
|
|
17067
|
+
onFileFailure();
|
|
17068
|
+
}
|
|
17069
|
+
return;
|
|
17070
|
+
}
|
|
17071
|
+
setIsSupported(true);
|
|
17072
|
+
if (onFileSelect) {
|
|
17073
|
+
onFileSelect(file);
|
|
17074
|
+
}
|
|
17075
|
+
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
17076
|
+
const handleDrop = React.useCallback((e) => {
|
|
17077
|
+
e.preventDefault();
|
|
17078
|
+
e.stopPropagation();
|
|
17079
|
+
setIsDragging(false);
|
|
17080
|
+
dragCounterRef.current = 0;
|
|
17081
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
17082
|
+
Array.from(e.dataTransfer.files).forEach((file) => {
|
|
17083
|
+
processFile(file);
|
|
17084
|
+
});
|
|
17085
|
+
}
|
|
17086
|
+
}, [processFile]);
|
|
17087
|
+
const handleFileSelect = React.useCallback((e) => {
|
|
17088
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
17089
|
+
Array.from(e.target.files).forEach((file) => {
|
|
17090
|
+
processFile(file);
|
|
17091
|
+
});
|
|
17092
|
+
}
|
|
17093
|
+
}, [processFile]);
|
|
17094
|
+
const handleBrowseClick = React.useCallback(() => {
|
|
17095
|
+
if (fileInputRef.current) {
|
|
17096
|
+
fileInputRef.current.click();
|
|
17097
|
+
}
|
|
17098
|
+
}, []);
|
|
17099
|
+
const handleRemoveFile = React.useCallback((fileId) => {
|
|
17100
|
+
if (onFileRemove) {
|
|
17101
|
+
onFileRemove(fileId);
|
|
17102
|
+
}
|
|
17103
|
+
}, [onFileRemove]);
|
|
17104
|
+
const handleRetryUpload = React.useCallback((fileId) => {
|
|
17105
|
+
if (onFileRetry) {
|
|
17106
|
+
onFileRetry(fileId);
|
|
17107
|
+
}
|
|
17108
|
+
}, [onFileRetry]);
|
|
17109
|
+
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
17110
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17111
|
+
/* @__PURE__ */ jsxRuntime.jsxs(UploadArea, { $isDragging: isDragging, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleBrowseClick, children: [
|
|
17112
|
+
/* @__PURE__ */ jsxRuntime.jsx(UploadIcon, { name: "upload" }),
|
|
17113
|
+
/* @__PURE__ */ jsxRuntime.jsxs(UploadText, { children: [
|
|
17114
|
+
!isSupported ? /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: !isSupported, type: "h1", children: title }),
|
|
17115
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileUploadDescription, { children: [
|
|
17116
|
+
"Files supported: ",
|
|
17117
|
+
supportedFileTypes.join(", ")
|
|
17118
|
+
] })
|
|
17119
|
+
] }),
|
|
17120
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "secondary", onClick: (e) => {
|
|
17121
|
+
e.stopPropagation();
|
|
17122
|
+
handleBrowseClick();
|
|
17123
|
+
}, children: "Browse files" })
|
|
17124
|
+
] }),
|
|
17125
|
+
files.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(FilesList, { children: files.map((file) => /* @__PURE__ */ jsxRuntime.jsx(FileItem, { $isError: file.status === "error", children: /* @__PURE__ */ jsxRuntime.jsxs(FileInfo, { children: [
|
|
17126
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileInfoHeader, { children: [
|
|
17127
|
+
/* @__PURE__ */ jsxRuntime.jsx(DocumentIcon, { name: "document" }),
|
|
17128
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileDetails, { children: [
|
|
17129
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
17130
|
+
(file.status === "success" || file.status === "uploading") && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
17131
|
+
file.status === "error" && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "danger", children: file.errorMessage || "Upload failed" }),
|
|
17132
|
+
file.status === "success" && /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
17133
|
+
] }),
|
|
17134
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileActions, { children: [
|
|
17135
|
+
file.status === "error" && /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: () => handleRetryUpload(file.id) }),
|
|
17136
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: () => handleRemoveFile(file.id) })
|
|
17137
|
+
] })
|
|
17138
|
+
] }),
|
|
17139
|
+
file.status === "uploading" && /* @__PURE__ */ jsxRuntime.jsxs(ProgressContainer$1, { children: [
|
|
17140
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress: file.progress, type: "small" }) }),
|
|
17141
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
17142
|
+
file.progress,
|
|
17143
|
+
"%"
|
|
17144
|
+
] })
|
|
17145
|
+
] })
|
|
17146
|
+
] }) }, file.id)) }),
|
|
17147
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "file", ref: fileInputRef, accept: acceptedFileTypes, onChange: handleFileSelect, multiple: true, style: {
|
|
17148
|
+
display: "none"
|
|
17149
|
+
} })
|
|
17150
|
+
] });
|
|
17151
|
+
};
|
|
16881
17152
|
const Flyout = ({
|
|
16882
17153
|
modal = false,
|
|
16883
17154
|
...props
|
|
@@ -50958,6 +51229,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
50958
51229
|
exports2.Dialog = Dialog;
|
|
50959
51230
|
exports2.Dropdown = Dropdown;
|
|
50960
51231
|
exports2.EllipsisContent = EllipsisContent;
|
|
51232
|
+
exports2.FileMultiUpload = FileMultiUpload;
|
|
50961
51233
|
exports2.FileTabElement = FileTabElement;
|
|
50962
51234
|
exports2.FileTabs = FileTabs;
|
|
50963
51235
|
exports2.FileUpload = FileUpload;
|