@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
|
@@ -17775,7 +17775,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17775
17775
|
const truncatedName = nameWithoutExtension.slice(0, maxLength) + delimiter2;
|
|
17776
17776
|
return truncatedName + extension;
|
|
17777
17777
|
};
|
|
17778
|
-
const UploadArea = pt.div.withConfig({
|
|
17778
|
+
const UploadArea$1 = pt.div.withConfig({
|
|
17779
17779
|
componentId: "sc-1rzizve-0"
|
|
17780
17780
|
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:", ";align-items:center;justify-content:", ";gap:", ";cursor:", ";transition:", ";", " ", ""], ({
|
|
17781
17781
|
theme: theme2
|
|
@@ -17802,7 +17802,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17802
17802
|
}) => theme2.click.fileUpload.color.stroke.active)), (props) => props.$isError && ct(["background-color:", ";border:none;"], ({
|
|
17803
17803
|
theme: theme2
|
|
17804
17804
|
}) => theme2.click.fileUpload.color.background.error));
|
|
17805
|
-
const FileUploadTitle = pt(Title$2).withConfig({
|
|
17805
|
+
const FileUploadTitle$1 = pt(Title$2).withConfig({
|
|
17806
17806
|
componentId: "sc-1rzizve-1"
|
|
17807
17807
|
})(["font:", ";color:", ";"], ({
|
|
17808
17808
|
theme: theme2
|
|
@@ -17810,14 +17810,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17810
17810
|
theme: theme2,
|
|
17811
17811
|
$isNotSupported
|
|
17812
17812
|
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
17813
|
-
const FileUploadDescription = pt(Text).withConfig({
|
|
17813
|
+
const FileUploadDescription$1 = pt(Text).withConfig({
|
|
17814
17814
|
componentId: "sc-1rzizve-2"
|
|
17815
17815
|
})(["font:", ";color:", ";"], ({
|
|
17816
17816
|
theme: theme2
|
|
17817
17817
|
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
17818
17818
|
theme: theme2
|
|
17819
17819
|
}) => theme2.click.fileUpload.color.description.default);
|
|
17820
|
-
const DocumentIcon = pt(SvgImage).withConfig({
|
|
17820
|
+
const DocumentIcon$1 = pt(SvgImage).withConfig({
|
|
17821
17821
|
componentId: "sc-1rzizve-3"
|
|
17822
17822
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
17823
17823
|
theme: theme2
|
|
@@ -17826,7 +17826,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17826
17826
|
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
17827
17827
|
theme: theme2
|
|
17828
17828
|
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
17829
|
-
const UploadIcon = pt(SvgImage).withConfig({
|
|
17829
|
+
const UploadIcon$1 = pt(SvgImage).withConfig({
|
|
17830
17830
|
componentId: "sc-1rzizve-4"
|
|
17831
17831
|
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
17832
17832
|
theme: theme2
|
|
@@ -17835,41 +17835,41 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17835
17835
|
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
17836
17836
|
theme: theme2
|
|
17837
17837
|
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
17838
|
-
const UploadText = pt.div.withConfig({
|
|
17838
|
+
const UploadText$1 = pt.div.withConfig({
|
|
17839
17839
|
componentId: "sc-1rzizve-5"
|
|
17840
17840
|
})(["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%;"]));
|
|
17841
|
-
const FileInfoHeader = pt.div.withConfig({
|
|
17841
|
+
const FileInfoHeader$1 = pt.div.withConfig({
|
|
17842
17842
|
componentId: "sc-1rzizve-6"
|
|
17843
17843
|
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
17844
17844
|
theme: theme2
|
|
17845
17845
|
}) => theme2.click.fileUpload.sm.space.gap);
|
|
17846
|
-
const FileInfo = pt.div.withConfig({
|
|
17846
|
+
const FileInfo$1 = pt.div.withConfig({
|
|
17847
17847
|
componentId: "sc-1rzizve-7"
|
|
17848
17848
|
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
17849
17849
|
theme: theme2
|
|
17850
17850
|
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
17851
|
-
const FileDetails = pt.div.withConfig({
|
|
17851
|
+
const FileDetails$1 = pt.div.withConfig({
|
|
17852
17852
|
componentId: "sc-1rzizve-8"
|
|
17853
17853
|
})(["display:flex;gap:", ";border:none;"], ({
|
|
17854
17854
|
theme: theme2
|
|
17855
17855
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
17856
|
-
const FileActions = pt.div.withConfig({
|
|
17856
|
+
const FileActions$1 = pt.div.withConfig({
|
|
17857
17857
|
componentId: "sc-1rzizve-9"
|
|
17858
17858
|
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
17859
|
-
const ProgressContainer$
|
|
17859
|
+
const ProgressContainer$2 = pt.div.withConfig({
|
|
17860
17860
|
componentId: "sc-1rzizve-10"
|
|
17861
17861
|
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
17862
|
-
const ProgressBarContainer = pt.div.withConfig({
|
|
17862
|
+
const ProgressBarContainer$1 = pt.div.withConfig({
|
|
17863
17863
|
componentId: "sc-1rzizve-11"
|
|
17864
17864
|
})(["width:100%;flex:1;"]);
|
|
17865
|
-
const ProgressPercentage = pt(Text).withConfig({
|
|
17865
|
+
const ProgressPercentage$1 = pt(Text).withConfig({
|
|
17866
17866
|
componentId: "sc-1rzizve-12"
|
|
17867
17867
|
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
17868
17868
|
theme: theme2
|
|
17869
17869
|
}) => theme2.sizes[10], ({
|
|
17870
17870
|
theme: theme2
|
|
17871
17871
|
}) => theme2.click.fileUpload.md.space.gap);
|
|
17872
|
-
const formatFileSize = (sizeInBytes) => {
|
|
17872
|
+
const formatFileSize$1 = (sizeInBytes) => {
|
|
17873
17873
|
if (sizeInBytes < 1024) {
|
|
17874
17874
|
return `${sizeInBytes.toFixed(1)} B`;
|
|
17875
17875
|
} else if (sizeInBytes < 1024 * 1024) {
|
|
@@ -17880,7 +17880,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17880
17880
|
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
17881
17881
|
}
|
|
17882
17882
|
};
|
|
17883
|
-
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
17883
|
+
const isFiletypeSupported$1 = (filename, supportedTypes) => {
|
|
17884
17884
|
if (!supportedTypes.length) return true;
|
|
17885
17885
|
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
17886
17886
|
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
@@ -17950,13 +17950,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17950
17950
|
};
|
|
17951
17951
|
}, []);
|
|
17952
17952
|
const processFile = React.useCallback((file2) => {
|
|
17953
|
-
if (!isFiletypeSupported(file2.name, supportedFileTypes)) {
|
|
17953
|
+
if (!isFiletypeSupported$1(file2.name, supportedFileTypes)) {
|
|
17954
|
+
setIsNotSupported(true);
|
|
17954
17955
|
if (onFileFailure) {
|
|
17955
17956
|
onFileFailure();
|
|
17956
|
-
console.log("File type not supported");
|
|
17957
|
-
setIsNotSupported(true);
|
|
17958
|
-
} else {
|
|
17959
|
-
console.warn(`File type not supported: ${file2.name}`);
|
|
17960
17957
|
}
|
|
17961
17958
|
return;
|
|
17962
17959
|
}
|
|
@@ -17965,9 +17962,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
17965
17962
|
size: file2.size
|
|
17966
17963
|
};
|
|
17967
17964
|
setFile(newFile);
|
|
17965
|
+
setIsNotSupported(false);
|
|
17968
17966
|
if (onFileSelect) {
|
|
17969
17967
|
onFileSelect(file2);
|
|
17970
|
-
setIsNotSupported(false);
|
|
17971
17968
|
}
|
|
17972
17969
|
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
17973
17970
|
const handleDrop = React.useCallback((e) => {
|
|
@@ -18007,11 +18004,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18007
18004
|
}, [onRetry]);
|
|
18008
18005
|
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
18009
18006
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
18010
|
-
/* @__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: [
|
|
18011
|
-
/* @__PURE__ */ jsxRuntime.jsx(UploadIcon, { name: "upload" }),
|
|
18012
|
-
/* @__PURE__ */ jsxRuntime.jsxs(UploadText, { $size: size2, $hasFile: false, children: [
|
|
18013
|
-
isNotSupported ? /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: isNotSupported, type: "h1", children: title }),
|
|
18014
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileUploadDescription, { children: [
|
|
18007
|
+
/* @__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: [
|
|
18008
|
+
/* @__PURE__ */ jsxRuntime.jsx(UploadIcon$1, { name: "upload" }),
|
|
18009
|
+
/* @__PURE__ */ jsxRuntime.jsxs(UploadText$1, { $size: size2, $hasFile: false, children: [
|
|
18010
|
+
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 }),
|
|
18011
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileUploadDescription$1, { children: [
|
|
18015
18012
|
"Files supported: ",
|
|
18016
18013
|
supportedFileTypes.join(", ")
|
|
18017
18014
|
] })
|
|
@@ -18020,23 +18017,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18020
18017
|
e.stopPropagation();
|
|
18021
18018
|
handleBrowseClick();
|
|
18022
18019
|
}, children: "Browse file" })
|
|
18023
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(FileInfo, { children: [
|
|
18024
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileInfoHeader, { children: [
|
|
18025
|
-
/* @__PURE__ */ jsxRuntime.jsx(DocumentIcon, { name: "document" }),
|
|
18026
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileDetails, { children: [
|
|
18020
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(FileInfo$1, { children: [
|
|
18021
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileInfoHeader$1, { children: [
|
|
18022
|
+
/* @__PURE__ */ jsxRuntime.jsx(DocumentIcon$1, { name: "document" }),
|
|
18023
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileDetails$1, { children: [
|
|
18027
18024
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
18028
|
-
(showSuccess || showProgress) && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
18025
|
+
(showSuccess || showProgress) && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "muted", children: formatFileSize$1(file.size) }),
|
|
18029
18026
|
!showProgress && !showSuccess && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "danger", children: failureMessage }),
|
|
18030
18027
|
showSuccess && /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
18031
18028
|
] }),
|
|
18032
|
-
/* @__PURE__ */ jsxRuntime.jsxs(FileActions, { children: [
|
|
18029
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileActions$1, { children: [
|
|
18033
18030
|
!showProgress && !showSuccess && /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: handleRetryUpload }),
|
|
18034
18031
|
/* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: handleRemoveFile })
|
|
18035
18032
|
] })
|
|
18036
18033
|
] }),
|
|
18037
|
-
showProgress && /* @__PURE__ */ jsxRuntime.jsxs(ProgressContainer$
|
|
18038
|
-
/* @__PURE__ */ jsxRuntime.jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress, type: "small" }) }),
|
|
18039
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
18034
|
+
showProgress && /* @__PURE__ */ jsxRuntime.jsxs(ProgressContainer$2, { children: [
|
|
18035
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProgressBarContainer$1, { children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress, type: "small" }) }),
|
|
18036
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProgressPercentage$1, { size: "sm", color: "muted", children: [
|
|
18040
18037
|
progress,
|
|
18041
18038
|
"%"
|
|
18042
18039
|
] })
|
|
@@ -18047,6 +18044,280 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
18047
18044
|
} })
|
|
18048
18045
|
] });
|
|
18049
18046
|
};
|
|
18047
|
+
const UploadArea = pt.div.withConfig({
|
|
18048
|
+
componentId: "sc-1w9rsfj-0"
|
|
18049
|
+
})(["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:", ";", ""], ({
|
|
18050
|
+
theme: theme2
|
|
18051
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
18052
|
+
theme: theme2
|
|
18053
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
18054
|
+
theme: theme2
|
|
18055
|
+
}) => theme2.click.fileUpload.md.radii.all, ({
|
|
18056
|
+
theme: theme2
|
|
18057
|
+
}) => `${theme2.click.fileUpload.md.space.y} ${theme2.click.fileUpload.md.space.x}`, ({
|
|
18058
|
+
theme: theme2
|
|
18059
|
+
}) => theme2.click.fileUpload.md.space.gap, ({
|
|
18060
|
+
theme: theme2
|
|
18061
|
+
}) => theme2.click.fileUpload.transitions.all, ({
|
|
18062
|
+
theme: theme2
|
|
18063
|
+
}) => theme2.click.fileUpload.color.stroke.default, (props) => props.$isDragging && ct(["background-color:", ";border-color:", ";"], ({
|
|
18064
|
+
theme: theme2
|
|
18065
|
+
}) => theme2.click.fileUpload.color.background.active, ({
|
|
18066
|
+
theme: theme2
|
|
18067
|
+
}) => theme2.click.fileUpload.color.stroke.active));
|
|
18068
|
+
const FileUploadTitle = pt(Title$2).withConfig({
|
|
18069
|
+
componentId: "sc-1w9rsfj-1"
|
|
18070
|
+
})(["font:", ";color:", ";"], ({
|
|
18071
|
+
theme: theme2
|
|
18072
|
+
}) => theme2.click.fileUpload.typography.title.default, ({
|
|
18073
|
+
theme: theme2,
|
|
18074
|
+
$isNotSupported
|
|
18075
|
+
}) => $isNotSupported ? theme2.click.fileUpload.color.title.error : theme2.click.fileUpload.color.title.default);
|
|
18076
|
+
const FileUploadDescription = pt(Text).withConfig({
|
|
18077
|
+
componentId: "sc-1w9rsfj-2"
|
|
18078
|
+
})(["font:", ";color:", ";"], ({
|
|
18079
|
+
theme: theme2
|
|
18080
|
+
}) => theme2.click.fileUpload.typography.description.default, ({
|
|
18081
|
+
theme: theme2
|
|
18082
|
+
}) => theme2.click.fileUpload.color.description.default);
|
|
18083
|
+
const UploadIcon = pt(SvgImage).withConfig({
|
|
18084
|
+
componentId: "sc-1w9rsfj-3"
|
|
18085
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
18086
|
+
theme: theme2
|
|
18087
|
+
}) => theme2.click.fileUpload.md.icon.size.width, ({
|
|
18088
|
+
theme: theme2
|
|
18089
|
+
}) => theme2.click.fileUpload.md.icon.size.height, ({
|
|
18090
|
+
theme: theme2
|
|
18091
|
+
}) => theme2.click.fileUpload.md.color.icon.default);
|
|
18092
|
+
const UploadText = pt.div.withConfig({
|
|
18093
|
+
componentId: "sc-1w9rsfj-4"
|
|
18094
|
+
})(["text-align:center;display:flex;flex-direction:column;align-items:center;width:100%;"]);
|
|
18095
|
+
const FilesList = pt.div.withConfig({
|
|
18096
|
+
componentId: "sc-1w9rsfj-5"
|
|
18097
|
+
})(["display:flex;flex-direction:column;gap:", ";width:100%;margin-top:", ";"], ({
|
|
18098
|
+
theme: theme2
|
|
18099
|
+
}) => theme2.click.fileUpload.sm.space.gap, ({
|
|
18100
|
+
theme: theme2
|
|
18101
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
18102
|
+
const FileItem = pt.div.withConfig({
|
|
18103
|
+
componentId: "sc-1w9rsfj-6"
|
|
18104
|
+
})(["background-color:", ";border:", ";border-radius:", ";padding:", ";display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:", ";", ""], ({
|
|
18105
|
+
theme: theme2
|
|
18106
|
+
}) => theme2.click.fileUpload.color.background.default, ({
|
|
18107
|
+
theme: theme2
|
|
18108
|
+
}) => `1px solid ${theme2.click.fileUpload.color.stroke.default}`, ({
|
|
18109
|
+
theme: theme2
|
|
18110
|
+
}) => theme2.click.fileUpload.sm.radii.all, ({
|
|
18111
|
+
theme: theme2
|
|
18112
|
+
}) => `${theme2.click.fileUpload.sm.space.y} ${theme2.click.fileUpload.sm.space.x}`, ({
|
|
18113
|
+
theme: theme2
|
|
18114
|
+
}) => theme2.click.fileUpload.sm.space.gap, (props) => props.$isError && ct(["background-color:", ";border:none;"], ({
|
|
18115
|
+
theme: theme2
|
|
18116
|
+
}) => theme2.click.fileUpload.color.background.error));
|
|
18117
|
+
const DocumentIcon = pt(SvgImage).withConfig({
|
|
18118
|
+
componentId: "sc-1w9rsfj-7"
|
|
18119
|
+
})(["svg{width:", ";height:", ";color:", ";}"], ({
|
|
18120
|
+
theme: theme2
|
|
18121
|
+
}) => theme2.click.fileUpload.sm.icon.size.width, ({
|
|
18122
|
+
theme: theme2
|
|
18123
|
+
}) => theme2.click.fileUpload.sm.icon.size.height, ({
|
|
18124
|
+
theme: theme2
|
|
18125
|
+
}) => theme2.click.fileUpload.sm.color.icon.default);
|
|
18126
|
+
const FileInfoHeader = pt.div.withConfig({
|
|
18127
|
+
componentId: "sc-1w9rsfj-8"
|
|
18128
|
+
})(["display:flex;align-items:center;gap:", ";width:100%;"], ({
|
|
18129
|
+
theme: theme2
|
|
18130
|
+
}) => theme2.click.fileUpload.sm.space.gap);
|
|
18131
|
+
const FileInfo = pt.div.withConfig({
|
|
18132
|
+
componentId: "sc-1w9rsfj-9"
|
|
18133
|
+
})(["display:flex;flex-direction:column;gap:", ";flex:1;"], ({
|
|
18134
|
+
theme: theme2
|
|
18135
|
+
}) => theme2.click.fileUpload.hasFile.header.space.gap);
|
|
18136
|
+
const FileDetails = pt.div.withConfig({
|
|
18137
|
+
componentId: "sc-1w9rsfj-10"
|
|
18138
|
+
})(["display:flex;gap:", ";border:none;"], ({
|
|
18139
|
+
theme: theme2
|
|
18140
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
18141
|
+
const FileActions = pt.div.withConfig({
|
|
18142
|
+
componentId: "sc-1w9rsfj-11"
|
|
18143
|
+
})(["display:flex;align-items:center;margin-left:auto;gap:0;"]);
|
|
18144
|
+
const ProgressContainer$1 = pt.div.withConfig({
|
|
18145
|
+
componentId: "sc-1w9rsfj-12"
|
|
18146
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;"]);
|
|
18147
|
+
const ProgressBarContainer = pt.div.withConfig({
|
|
18148
|
+
componentId: "sc-1w9rsfj-13"
|
|
18149
|
+
})(["width:100%;flex:1;"]);
|
|
18150
|
+
const ProgressPercentage = pt(Text).withConfig({
|
|
18151
|
+
componentId: "sc-1w9rsfj-14"
|
|
18152
|
+
})(["min-width:", ";text-align:right;padding-right:", ";"], ({
|
|
18153
|
+
theme: theme2
|
|
18154
|
+
}) => theme2.sizes[10], ({
|
|
18155
|
+
theme: theme2
|
|
18156
|
+
}) => theme2.click.fileUpload.md.space.gap);
|
|
18157
|
+
const formatFileSize = (sizeInBytes) => {
|
|
18158
|
+
if (sizeInBytes < 1024) {
|
|
18159
|
+
return `${sizeInBytes.toFixed(1)} B`;
|
|
18160
|
+
} else if (sizeInBytes < 1024 * 1024) {
|
|
18161
|
+
return `${(sizeInBytes / 1024).toFixed(1)} KB`;
|
|
18162
|
+
} else if (sizeInBytes < 1024 * 1024 * 1024) {
|
|
18163
|
+
return `${(sizeInBytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
18164
|
+
} else {
|
|
18165
|
+
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
18166
|
+
}
|
|
18167
|
+
};
|
|
18168
|
+
const isFiletypeSupported = (filename, supportedTypes) => {
|
|
18169
|
+
if (!supportedTypes.length) return true;
|
|
18170
|
+
const extension = filename.toLowerCase().slice(filename.lastIndexOf("."));
|
|
18171
|
+
return supportedTypes.some((type) => type.toLowerCase() === extension.toLowerCase());
|
|
18172
|
+
};
|
|
18173
|
+
const FileMultiUpload = ({
|
|
18174
|
+
title,
|
|
18175
|
+
supportedFileTypes = [".txt", ".sql"],
|
|
18176
|
+
files,
|
|
18177
|
+
onFileSelect,
|
|
18178
|
+
onFileRetry,
|
|
18179
|
+
onFileRemove,
|
|
18180
|
+
onFileFailure
|
|
18181
|
+
}) => {
|
|
18182
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
18183
|
+
const [isSupported, setIsSupported] = React.useState(true);
|
|
18184
|
+
const fileInputRef = React.useRef(null);
|
|
18185
|
+
const dragCounterRef = React.useRef(0);
|
|
18186
|
+
React.useEffect(() => {
|
|
18187
|
+
let timeoutId;
|
|
18188
|
+
if (!isSupported) {
|
|
18189
|
+
timeoutId = setTimeout(() => {
|
|
18190
|
+
setIsSupported(true);
|
|
18191
|
+
}, 2e3);
|
|
18192
|
+
}
|
|
18193
|
+
return () => {
|
|
18194
|
+
if (timeoutId) {
|
|
18195
|
+
clearTimeout(timeoutId);
|
|
18196
|
+
}
|
|
18197
|
+
};
|
|
18198
|
+
}, [isSupported]);
|
|
18199
|
+
const handleDragEnter = React.useCallback((e) => {
|
|
18200
|
+
e.preventDefault();
|
|
18201
|
+
e.stopPropagation();
|
|
18202
|
+
dragCounterRef.current += 1;
|
|
18203
|
+
setIsDragging(true);
|
|
18204
|
+
}, []);
|
|
18205
|
+
const handleDragLeave = React.useCallback((e) => {
|
|
18206
|
+
e.preventDefault();
|
|
18207
|
+
e.stopPropagation();
|
|
18208
|
+
dragCounterRef.current -= 1;
|
|
18209
|
+
if (dragCounterRef.current <= 0) {
|
|
18210
|
+
setIsDragging(false);
|
|
18211
|
+
dragCounterRef.current = 0;
|
|
18212
|
+
}
|
|
18213
|
+
}, []);
|
|
18214
|
+
const handleDragOver = React.useCallback((e) => {
|
|
18215
|
+
e.preventDefault();
|
|
18216
|
+
e.stopPropagation();
|
|
18217
|
+
}, []);
|
|
18218
|
+
React.useEffect(() => {
|
|
18219
|
+
const handleDragEnd = () => {
|
|
18220
|
+
setIsDragging(false);
|
|
18221
|
+
dragCounterRef.current = 0;
|
|
18222
|
+
};
|
|
18223
|
+
window.addEventListener("dragend", handleDragEnd);
|
|
18224
|
+
document.addEventListener("drop", handleDragEnd);
|
|
18225
|
+
document.addEventListener("mouseleave", handleDragEnd);
|
|
18226
|
+
return () => {
|
|
18227
|
+
window.removeEventListener("dragend", handleDragEnd);
|
|
18228
|
+
document.removeEventListener("drop", handleDragEnd);
|
|
18229
|
+
document.removeEventListener("mouseleave", handleDragEnd);
|
|
18230
|
+
};
|
|
18231
|
+
}, []);
|
|
18232
|
+
const processFile = React.useCallback((file) => {
|
|
18233
|
+
if (!isFiletypeSupported(file.name, supportedFileTypes)) {
|
|
18234
|
+
setIsSupported(false);
|
|
18235
|
+
if (onFileFailure) {
|
|
18236
|
+
onFileFailure();
|
|
18237
|
+
}
|
|
18238
|
+
return;
|
|
18239
|
+
}
|
|
18240
|
+
setIsSupported(true);
|
|
18241
|
+
if (onFileSelect) {
|
|
18242
|
+
onFileSelect(file);
|
|
18243
|
+
}
|
|
18244
|
+
}, [onFileSelect, supportedFileTypes, onFileFailure]);
|
|
18245
|
+
const handleDrop = React.useCallback((e) => {
|
|
18246
|
+
e.preventDefault();
|
|
18247
|
+
e.stopPropagation();
|
|
18248
|
+
setIsDragging(false);
|
|
18249
|
+
dragCounterRef.current = 0;
|
|
18250
|
+
if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
|
|
18251
|
+
Array.from(e.dataTransfer.files).forEach((file) => {
|
|
18252
|
+
processFile(file);
|
|
18253
|
+
});
|
|
18254
|
+
}
|
|
18255
|
+
}, [processFile]);
|
|
18256
|
+
const handleFileSelect = React.useCallback((e) => {
|
|
18257
|
+
if (e.target.files && e.target.files.length > 0) {
|
|
18258
|
+
Array.from(e.target.files).forEach((file) => {
|
|
18259
|
+
processFile(file);
|
|
18260
|
+
});
|
|
18261
|
+
}
|
|
18262
|
+
}, [processFile]);
|
|
18263
|
+
const handleBrowseClick = React.useCallback(() => {
|
|
18264
|
+
if (fileInputRef.current) {
|
|
18265
|
+
fileInputRef.current.click();
|
|
18266
|
+
}
|
|
18267
|
+
}, []);
|
|
18268
|
+
const handleRemoveFile = React.useCallback((fileId) => {
|
|
18269
|
+
if (onFileRemove) {
|
|
18270
|
+
onFileRemove(fileId);
|
|
18271
|
+
}
|
|
18272
|
+
}, [onFileRemove]);
|
|
18273
|
+
const handleRetryUpload = React.useCallback((fileId) => {
|
|
18274
|
+
if (onFileRetry) {
|
|
18275
|
+
onFileRetry(fileId);
|
|
18276
|
+
}
|
|
18277
|
+
}, [onFileRetry]);
|
|
18278
|
+
const acceptedFileTypes = supportedFileTypes.join(",");
|
|
18279
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
18280
|
+
/* @__PURE__ */ jsxRuntime.jsxs(UploadArea, { $isDragging: isDragging, onDragEnter: handleDragEnter, onDragLeave: handleDragLeave, onDragOver: handleDragOver, onDrop: handleDrop, onClick: handleBrowseClick, children: [
|
|
18281
|
+
/* @__PURE__ */ jsxRuntime.jsx(UploadIcon, { name: "upload" }),
|
|
18282
|
+
/* @__PURE__ */ jsxRuntime.jsxs(UploadText, { children: [
|
|
18283
|
+
!isSupported ? /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: true, type: "h1", children: "Unsupported file type" }) : /* @__PURE__ */ jsxRuntime.jsx(FileUploadTitle, { $isNotSupported: !isSupported, type: "h1", children: title }),
|
|
18284
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileUploadDescription, { children: [
|
|
18285
|
+
"Files supported: ",
|
|
18286
|
+
supportedFileTypes.join(", ")
|
|
18287
|
+
] })
|
|
18288
|
+
] }),
|
|
18289
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { type: "secondary", onClick: (e) => {
|
|
18290
|
+
e.stopPropagation();
|
|
18291
|
+
handleBrowseClick();
|
|
18292
|
+
}, children: "Browse files" })
|
|
18293
|
+
] }),
|
|
18294
|
+
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: [
|
|
18295
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileInfoHeader, { children: [
|
|
18296
|
+
/* @__PURE__ */ jsxRuntime.jsx(DocumentIcon, { name: "document" }),
|
|
18297
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileDetails, { children: [
|
|
18298
|
+
/* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", children: truncateFilename(file.name) }),
|
|
18299
|
+
(file.status === "success" || file.status === "uploading") && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "muted", children: formatFileSize(file.size) }),
|
|
18300
|
+
file.status === "error" && /* @__PURE__ */ jsxRuntime.jsx(Text, { size: "md", color: "danger", children: file.errorMessage || "Upload failed" }),
|
|
18301
|
+
file.status === "success" && /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { size: "xs", state: "success", name: "check" })
|
|
18302
|
+
] }),
|
|
18303
|
+
/* @__PURE__ */ jsxRuntime.jsxs(FileActions, { children: [
|
|
18304
|
+
file.status === "error" && /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "refresh", type: "ghost", onClick: () => handleRetryUpload(file.id) }),
|
|
18305
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { size: "sm", icon: "cross", type: "ghost", onClick: () => handleRemoveFile(file.id) })
|
|
18306
|
+
] })
|
|
18307
|
+
] }),
|
|
18308
|
+
file.status === "uploading" && /* @__PURE__ */ jsxRuntime.jsxs(ProgressContainer$1, { children: [
|
|
18309
|
+
/* @__PURE__ */ jsxRuntime.jsx(ProgressBarContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(ProgressBar, { progress: file.progress, type: "small" }) }),
|
|
18310
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ProgressPercentage, { size: "sm", color: "muted", children: [
|
|
18311
|
+
file.progress,
|
|
18312
|
+
"%"
|
|
18313
|
+
] })
|
|
18314
|
+
] })
|
|
18315
|
+
] }) }, file.id)) }),
|
|
18316
|
+
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "file", ref: fileInputRef, accept: acceptedFileTypes, onChange: handleFileSelect, multiple: true, style: {
|
|
18317
|
+
display: "none"
|
|
18318
|
+
} })
|
|
18319
|
+
] });
|
|
18320
|
+
};
|
|
18050
18321
|
const Flyout = ({
|
|
18051
18322
|
modal = false,
|
|
18052
18323
|
...props
|
|
@@ -52127,6 +52398,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
52127
52398
|
exports2.Dialog = Dialog;
|
|
52128
52399
|
exports2.Dropdown = Dropdown;
|
|
52129
52400
|
exports2.EllipsisContent = EllipsisContent;
|
|
52401
|
+
exports2.FileMultiUpload = FileMultiUpload;
|
|
52130
52402
|
exports2.FileTabElement = FileTabElement;
|
|
52131
52403
|
exports2.FileTabs = FileTabs;
|
|
52132
52404
|
exports2.FileUpload = FileUpload;
|
|
@@ -52184,3 +52456,4 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
52184
52456
|
exports2.useToast = useToast;
|
|
52185
52457
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
52186
52458
|
});
|
|
52459
|
+
//# sourceMappingURL=click-ui.bundled.umd.js.map
|