@sparkstudio/storage-ui 1.0.19 → 1.0.21
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/index.cjs +79 -60
- package/dist/index.d.cts +2 -13
- package/dist/index.d.ts +2 -13
- package/dist/index.js +79 -60
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -294,20 +294,20 @@ var UploadDropzone = ({
|
|
|
294
294
|
style,
|
|
295
295
|
children
|
|
296
296
|
}) => {
|
|
297
|
-
const baseClass = "rounded-3 d-flex flex-column align-items-center justify-content-center
|
|
298
|
-
const stateClass = isDragging ? "bg-
|
|
299
|
-
const combinedClassName = `${baseClass}${stateClass} ${className}`.trim();
|
|
297
|
+
const baseClass = "rounded-3 d-flex flex-column align-items-center justify-content-center";
|
|
298
|
+
const stateClass = isDragging ? "bg-body-secondary" : "";
|
|
299
|
+
const combinedClassName = `${baseClass} ${stateClass} ${className}`.trim();
|
|
300
300
|
const handleDragOver = (e) => {
|
|
301
301
|
e.preventDefault();
|
|
302
|
-
|
|
302
|
+
onDragOver?.(e);
|
|
303
303
|
};
|
|
304
304
|
const handleDragLeave = (e) => {
|
|
305
305
|
e.preventDefault();
|
|
306
|
-
|
|
306
|
+
onDragLeave?.(e);
|
|
307
307
|
};
|
|
308
308
|
const handleDrop = (e) => {
|
|
309
309
|
e.preventDefault();
|
|
310
|
-
|
|
310
|
+
onDrop?.(e);
|
|
311
311
|
};
|
|
312
312
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
313
313
|
"div",
|
|
@@ -498,7 +498,7 @@ var UploadProgressList = ({
|
|
|
498
498
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
499
499
|
"div",
|
|
500
500
|
{
|
|
501
|
-
className: "
|
|
501
|
+
className: "border rounded-3 d-flex align-items-center justify-content-center mb-1 shadow-sm position-relative",
|
|
502
502
|
style: {
|
|
503
503
|
width: 64,
|
|
504
504
|
height: 64
|
|
@@ -741,7 +741,7 @@ var DesktopFileIcon = ({
|
|
|
741
741
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
742
742
|
"div",
|
|
743
743
|
{
|
|
744
|
-
className: "
|
|
744
|
+
className: "border rounded-3 d-flex align-items-center justify-content-center mb-1 shadow-sm position-relative",
|
|
745
745
|
style: {
|
|
746
746
|
width: 64,
|
|
747
747
|
height: 64
|
|
@@ -866,6 +866,31 @@ var UploadContainer = ({
|
|
|
866
866
|
className: "w-100",
|
|
867
867
|
style: { minHeight: "260px", alignItems: "stretch" },
|
|
868
868
|
children: [
|
|
869
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "w-100", children: [
|
|
870
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
871
|
+
"input",
|
|
872
|
+
{
|
|
873
|
+
id: "filePicker",
|
|
874
|
+
type: "file",
|
|
875
|
+
multiple: true,
|
|
876
|
+
className: "d-none",
|
|
877
|
+
onChange: (e) => {
|
|
878
|
+
if (!e.target.files) return;
|
|
879
|
+
onFilesSelected?.(e.target.files);
|
|
880
|
+
startUploadsIfNeeded(e.target.files);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
),
|
|
884
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-start", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
885
|
+
"button",
|
|
886
|
+
{
|
|
887
|
+
type: "button",
|
|
888
|
+
className: "btn btn-primary float-start",
|
|
889
|
+
onClick: () => document.getElementById("filePicker")?.click(),
|
|
890
|
+
children: "Browse files\u2026"
|
|
891
|
+
}
|
|
892
|
+
) })
|
|
893
|
+
] }),
|
|
869
894
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-100 mb-3", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "d-flex flex-column flex-md-row align-items-start align-items-md-center justify-content-between gap-3", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "flex-grow-1 w-100", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UploadProgressList, { uploads }) }) }) }),
|
|
870
895
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
871
896
|
"div",
|
|
@@ -1079,7 +1104,11 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1079
1104
|
setProgress(0);
|
|
1080
1105
|
setErrorMessage(null);
|
|
1081
1106
|
const presignedUrl = await getPresignedUrl(selectedFile);
|
|
1082
|
-
await UploadFileToS3(
|
|
1107
|
+
await UploadFileToS3(
|
|
1108
|
+
selectedFile,
|
|
1109
|
+
presignedUrl?.PresignedUrl ?? "",
|
|
1110
|
+
(p) => setProgress(p)
|
|
1111
|
+
);
|
|
1083
1112
|
setStatus("success");
|
|
1084
1113
|
onUploadComplete?.(selectedFile, presignedUrl);
|
|
1085
1114
|
} catch (err) {
|
|
@@ -1095,23 +1124,28 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1095
1124
|
return "Unknown error during upload.";
|
|
1096
1125
|
}
|
|
1097
1126
|
const isUploading = status === "uploading";
|
|
1098
|
-
|
|
1099
|
-
|
|
1127
|
+
const dropzoneClasses = [
|
|
1128
|
+
"border",
|
|
1129
|
+
"border-2",
|
|
1130
|
+
"rounded",
|
|
1131
|
+
"p-3",
|
|
1132
|
+
"text-center",
|
|
1133
|
+
"user-select-none",
|
|
1134
|
+
disabled ? "opacity-50" : "cursor-pointer",
|
|
1135
|
+
isDragging ? "bg-info-subtle" : "bg-transparent"
|
|
1136
|
+
].join(" ");
|
|
1137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "d-flex flex-column gap-2", children: [
|
|
1138
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { className: "form-label fw-semibold", children: label }),
|
|
1100
1139
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1101
1140
|
"div",
|
|
1102
1141
|
{
|
|
1142
|
+
className: dropzoneClasses,
|
|
1103
1143
|
onDragOver: handleDragOver,
|
|
1104
1144
|
onDragLeave: handleDragLeave,
|
|
1105
1145
|
onDrop: handleDrop,
|
|
1106
1146
|
onClick: handleBrowseClick,
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
borderRadius: 8,
|
|
1110
|
-
padding: 16,
|
|
1111
|
-
textAlign: "center",
|
|
1112
|
-
cursor: disabled ? "not-allowed" : "pointer",
|
|
1113
|
-
backgroundColor: isDragging ? "#f0f8ff" : "#fafafa"
|
|
1114
|
-
},
|
|
1147
|
+
role: "button",
|
|
1148
|
+
"aria-disabled": disabled,
|
|
1115
1149
|
children: [
|
|
1116
1150
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1117
1151
|
"input",
|
|
@@ -1119,55 +1153,47 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1119
1153
|
ref: fileInputRef,
|
|
1120
1154
|
type: "file",
|
|
1121
1155
|
accept,
|
|
1122
|
-
|
|
1156
|
+
className: "d-none",
|
|
1123
1157
|
onChange: handleInputChange,
|
|
1124
1158
|
disabled
|
|
1125
1159
|
}
|
|
1126
1160
|
),
|
|
1127
|
-
selectedFile ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1161
|
+
selectedFile ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1128
1162
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1129
1163
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: "Selected file:" }),
|
|
1130
1164
|
" ",
|
|
1131
1165
|
selectedFile.name
|
|
1132
1166
|
] }),
|
|
1133
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
|
|
1134
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
|
|
1167
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "Click here to change file or drag a new one." })
|
|
1168
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1135
1169
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: "Drag & drop a file here" }),
|
|
1136
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
|
|
1170
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "text-muted", children: "or click to browse" })
|
|
1137
1171
|
] })
|
|
1138
1172
|
]
|
|
1139
1173
|
}
|
|
1140
1174
|
),
|
|
1141
|
-
isUploading && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
|
|
1142
|
-
"
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1175
|
+
isUploading && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small", children: [
|
|
1176
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "d-flex justify-content-between mb-1", children: [
|
|
1177
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "Uploading..." }),
|
|
1178
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1179
|
+
progress ?? 0,
|
|
1180
|
+
"%"
|
|
1181
|
+
] })
|
|
1182
|
+
] }),
|
|
1183
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "progress", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1146
1184
|
"div",
|
|
1147
1185
|
{
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
},
|
|
1155
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1156
|
-
"div",
|
|
1157
|
-
{
|
|
1158
|
-
style: {
|
|
1159
|
-
height: "100%",
|
|
1160
|
-
width: `${progress ?? 0}%`,
|
|
1161
|
-
backgroundColor: "#007bff",
|
|
1162
|
-
transition: "width 0.2s ease-out"
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
)
|
|
1186
|
+
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1187
|
+
role: "progressbar",
|
|
1188
|
+
"aria-valuemin": 0,
|
|
1189
|
+
"aria-valuemax": 100,
|
|
1190
|
+
"aria-valuenow": progress ?? 0,
|
|
1191
|
+
style: { width: `${progress ?? 0}%` }
|
|
1166
1192
|
}
|
|
1167
|
-
)
|
|
1193
|
+
) })
|
|
1168
1194
|
] }),
|
|
1169
|
-
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", {
|
|
1170
|
-
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", {
|
|
1195
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "small text-success", children: "Upload complete \u2705" }),
|
|
1196
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "small text-danger", children: [
|
|
1171
1197
|
"Upload failed: ",
|
|
1172
1198
|
errorMessage
|
|
1173
1199
|
] }),
|
|
@@ -1177,15 +1203,7 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1177
1203
|
type: "button",
|
|
1178
1204
|
onClick: handleProcessClick,
|
|
1179
1205
|
disabled: !selectedFile || isUploading || disabled,
|
|
1180
|
-
|
|
1181
|
-
padding: "8px 16px",
|
|
1182
|
-
borderRadius: 4,
|
|
1183
|
-
border: "none",
|
|
1184
|
-
backgroundColor: !selectedFile || isUploading || disabled ? "#ccc" : "#007bff",
|
|
1185
|
-
color: "#fff",
|
|
1186
|
-
fontWeight: 600,
|
|
1187
|
-
cursor: !selectedFile || isUploading || disabled ? "not-allowed" : "pointer"
|
|
1188
|
-
},
|
|
1206
|
+
className: "btn btn-primary mt-2",
|
|
1189
1207
|
children: isUploading ? "Processing..." : "Process"
|
|
1190
1208
|
}
|
|
1191
1209
|
)
|
|
@@ -1214,7 +1232,8 @@ function HomeContent() {
|
|
|
1214
1232
|
"https://localhost:5001"
|
|
1215
1233
|
);
|
|
1216
1234
|
const contentType = file.type || "application/octet-stream";
|
|
1217
|
-
|
|
1235
|
+
const result = await res.s3.GetTemporaryPreSignedUrl(new TemporaryFileDTO({ Name: file.name, ContentType: contentType }));
|
|
1236
|
+
return result;
|
|
1218
1237
|
}
|
|
1219
1238
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
1220
1239
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_authentication_ui.UserInfoCard, {}),
|
package/dist/index.d.cts
CHANGED
|
@@ -132,19 +132,10 @@ interface DesktopFileIconProps {
|
|
|
132
132
|
declare const DesktopFileIcon: React__default.FC<DesktopFileIconProps>;
|
|
133
133
|
|
|
134
134
|
interface SingleFileProcessUploaderProps {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Called after the upload succeeds.
|
|
139
|
-
* You can use s3Url (the presigned URL you provided) in another component
|
|
140
|
-
* or have your backend process the file from S3.
|
|
141
|
-
*/
|
|
142
|
-
onUploadComplete?: (file: File, s3Url: string) => void;
|
|
143
|
-
/** Optional: restrict file types, e.g. "image/*" or ".png,.jpg" */
|
|
135
|
+
getPresignedUrl: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
136
|
+
onUploadComplete?: (file: File, s3Url: AWSPresignedUrlDTO) => void;
|
|
144
137
|
accept?: string;
|
|
145
|
-
/** Optional: label shown above the control */
|
|
146
138
|
label?: string;
|
|
147
|
-
/** Optional: disable the control entirely */
|
|
148
139
|
disabled?: boolean;
|
|
149
140
|
}
|
|
150
141
|
declare const SingleFileProcessUploader: React__default.FC<SingleFileProcessUploaderProps>;
|
|
@@ -170,10 +161,8 @@ interface UploadDropzoneProps {
|
|
|
170
161
|
onDragOver?: (e: React__default.DragEvent<HTMLDivElement>) => void;
|
|
171
162
|
onDragLeave?: (e: React__default.DragEvent<HTMLDivElement>) => void;
|
|
172
163
|
onDrop?: (e: React__default.DragEvent<HTMLDivElement>) => void;
|
|
173
|
-
/** Extra className so you can make this the root wrapper */
|
|
174
164
|
className?: string;
|
|
175
165
|
style?: React__default.CSSProperties;
|
|
176
|
-
/** Custom content to render inside the dropzone */
|
|
177
166
|
children?: React__default.ReactNode;
|
|
178
167
|
}
|
|
179
168
|
declare const UploadDropzone: React__default.FC<UploadDropzoneProps>;
|
package/dist/index.d.ts
CHANGED
|
@@ -132,19 +132,10 @@ interface DesktopFileIconProps {
|
|
|
132
132
|
declare const DesktopFileIcon: React__default.FC<DesktopFileIconProps>;
|
|
133
133
|
|
|
134
134
|
interface SingleFileProcessUploaderProps {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Called after the upload succeeds.
|
|
139
|
-
* You can use s3Url (the presigned URL you provided) in another component
|
|
140
|
-
* or have your backend process the file from S3.
|
|
141
|
-
*/
|
|
142
|
-
onUploadComplete?: (file: File, s3Url: string) => void;
|
|
143
|
-
/** Optional: restrict file types, e.g. "image/*" or ".png,.jpg" */
|
|
135
|
+
getPresignedUrl: (file: File) => Promise<AWSPresignedUrlDTO>;
|
|
136
|
+
onUploadComplete?: (file: File, s3Url: AWSPresignedUrlDTO) => void;
|
|
144
137
|
accept?: string;
|
|
145
|
-
/** Optional: label shown above the control */
|
|
146
138
|
label?: string;
|
|
147
|
-
/** Optional: disable the control entirely */
|
|
148
139
|
disabled?: boolean;
|
|
149
140
|
}
|
|
150
141
|
declare const SingleFileProcessUploader: React__default.FC<SingleFileProcessUploaderProps>;
|
|
@@ -170,10 +161,8 @@ interface UploadDropzoneProps {
|
|
|
170
161
|
onDragOver?: (e: React__default.DragEvent<HTMLDivElement>) => void;
|
|
171
162
|
onDragLeave?: (e: React__default.DragEvent<HTMLDivElement>) => void;
|
|
172
163
|
onDrop?: (e: React__default.DragEvent<HTMLDivElement>) => void;
|
|
173
|
-
/** Extra className so you can make this the root wrapper */
|
|
174
164
|
className?: string;
|
|
175
165
|
style?: React__default.CSSProperties;
|
|
176
|
-
/** Custom content to render inside the dropzone */
|
|
177
166
|
children?: React__default.ReactNode;
|
|
178
167
|
}
|
|
179
168
|
declare const UploadDropzone: React__default.FC<UploadDropzoneProps>;
|
package/dist/index.js
CHANGED
|
@@ -251,20 +251,20 @@ var UploadDropzone = ({
|
|
|
251
251
|
style,
|
|
252
252
|
children
|
|
253
253
|
}) => {
|
|
254
|
-
const baseClass = "rounded-3 d-flex flex-column align-items-center justify-content-center
|
|
255
|
-
const stateClass = isDragging ? "bg-
|
|
256
|
-
const combinedClassName = `${baseClass}${stateClass} ${className}`.trim();
|
|
254
|
+
const baseClass = "rounded-3 d-flex flex-column align-items-center justify-content-center";
|
|
255
|
+
const stateClass = isDragging ? "bg-body-secondary" : "";
|
|
256
|
+
const combinedClassName = `${baseClass} ${stateClass} ${className}`.trim();
|
|
257
257
|
const handleDragOver = (e) => {
|
|
258
258
|
e.preventDefault();
|
|
259
|
-
|
|
259
|
+
onDragOver?.(e);
|
|
260
260
|
};
|
|
261
261
|
const handleDragLeave = (e) => {
|
|
262
262
|
e.preventDefault();
|
|
263
|
-
|
|
263
|
+
onDragLeave?.(e);
|
|
264
264
|
};
|
|
265
265
|
const handleDrop = (e) => {
|
|
266
266
|
e.preventDefault();
|
|
267
|
-
|
|
267
|
+
onDrop?.(e);
|
|
268
268
|
};
|
|
269
269
|
return /* @__PURE__ */ jsx(
|
|
270
270
|
"div",
|
|
@@ -455,7 +455,7 @@ var UploadProgressList = ({
|
|
|
455
455
|
/* @__PURE__ */ jsxs(
|
|
456
456
|
"div",
|
|
457
457
|
{
|
|
458
|
-
className: "
|
|
458
|
+
className: "border rounded-3 d-flex align-items-center justify-content-center mb-1 shadow-sm position-relative",
|
|
459
459
|
style: {
|
|
460
460
|
width: 64,
|
|
461
461
|
height: 64
|
|
@@ -708,7 +708,7 @@ var DesktopFileIcon = ({
|
|
|
708
708
|
/* @__PURE__ */ jsxs2(
|
|
709
709
|
"div",
|
|
710
710
|
{
|
|
711
|
-
className: "
|
|
711
|
+
className: "border rounded-3 d-flex align-items-center justify-content-center mb-1 shadow-sm position-relative",
|
|
712
712
|
style: {
|
|
713
713
|
width: 64,
|
|
714
714
|
height: 64
|
|
@@ -833,6 +833,31 @@ var UploadContainer = ({
|
|
|
833
833
|
className: "w-100",
|
|
834
834
|
style: { minHeight: "260px", alignItems: "stretch" },
|
|
835
835
|
children: [
|
|
836
|
+
/* @__PURE__ */ jsxs3("div", { className: "w-100", children: [
|
|
837
|
+
/* @__PURE__ */ jsx4(
|
|
838
|
+
"input",
|
|
839
|
+
{
|
|
840
|
+
id: "filePicker",
|
|
841
|
+
type: "file",
|
|
842
|
+
multiple: true,
|
|
843
|
+
className: "d-none",
|
|
844
|
+
onChange: (e) => {
|
|
845
|
+
if (!e.target.files) return;
|
|
846
|
+
onFilesSelected?.(e.target.files);
|
|
847
|
+
startUploadsIfNeeded(e.target.files);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
),
|
|
851
|
+
/* @__PURE__ */ jsx4("div", { className: "text-start", children: /* @__PURE__ */ jsx4(
|
|
852
|
+
"button",
|
|
853
|
+
{
|
|
854
|
+
type: "button",
|
|
855
|
+
className: "btn btn-primary float-start",
|
|
856
|
+
onClick: () => document.getElementById("filePicker")?.click(),
|
|
857
|
+
children: "Browse files\u2026"
|
|
858
|
+
}
|
|
859
|
+
) })
|
|
860
|
+
] }),
|
|
836
861
|
/* @__PURE__ */ jsx4("div", { className: "w-100 mb-3", children: /* @__PURE__ */ jsx4("div", { className: "d-flex flex-column flex-md-row align-items-start align-items-md-center justify-content-between gap-3", children: /* @__PURE__ */ jsx4("div", { className: "flex-grow-1 w-100", children: /* @__PURE__ */ jsx4(UploadProgressList, { uploads }) }) }) }),
|
|
837
862
|
/* @__PURE__ */ jsx4(
|
|
838
863
|
"div",
|
|
@@ -1046,7 +1071,11 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1046
1071
|
setProgress(0);
|
|
1047
1072
|
setErrorMessage(null);
|
|
1048
1073
|
const presignedUrl = await getPresignedUrl(selectedFile);
|
|
1049
|
-
await UploadFileToS3(
|
|
1074
|
+
await UploadFileToS3(
|
|
1075
|
+
selectedFile,
|
|
1076
|
+
presignedUrl?.PresignedUrl ?? "",
|
|
1077
|
+
(p) => setProgress(p)
|
|
1078
|
+
);
|
|
1050
1079
|
setStatus("success");
|
|
1051
1080
|
onUploadComplete?.(selectedFile, presignedUrl);
|
|
1052
1081
|
} catch (err) {
|
|
@@ -1062,23 +1091,28 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1062
1091
|
return "Unknown error during upload.";
|
|
1063
1092
|
}
|
|
1064
1093
|
const isUploading = status === "uploading";
|
|
1065
|
-
|
|
1066
|
-
|
|
1094
|
+
const dropzoneClasses = [
|
|
1095
|
+
"border",
|
|
1096
|
+
"border-2",
|
|
1097
|
+
"rounded",
|
|
1098
|
+
"p-3",
|
|
1099
|
+
"text-center",
|
|
1100
|
+
"user-select-none",
|
|
1101
|
+
disabled ? "opacity-50" : "cursor-pointer",
|
|
1102
|
+
isDragging ? "bg-info-subtle" : "bg-transparent"
|
|
1103
|
+
].join(" ");
|
|
1104
|
+
return /* @__PURE__ */ jsxs4("div", { className: "d-flex flex-column gap-2", children: [
|
|
1105
|
+
label && /* @__PURE__ */ jsx6("label", { className: "form-label fw-semibold", children: label }),
|
|
1067
1106
|
/* @__PURE__ */ jsxs4(
|
|
1068
1107
|
"div",
|
|
1069
1108
|
{
|
|
1109
|
+
className: dropzoneClasses,
|
|
1070
1110
|
onDragOver: handleDragOver,
|
|
1071
1111
|
onDragLeave: handleDragLeave,
|
|
1072
1112
|
onDrop: handleDrop,
|
|
1073
1113
|
onClick: handleBrowseClick,
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
borderRadius: 8,
|
|
1077
|
-
padding: 16,
|
|
1078
|
-
textAlign: "center",
|
|
1079
|
-
cursor: disabled ? "not-allowed" : "pointer",
|
|
1080
|
-
backgroundColor: isDragging ? "#f0f8ff" : "#fafafa"
|
|
1081
|
-
},
|
|
1114
|
+
role: "button",
|
|
1115
|
+
"aria-disabled": disabled,
|
|
1082
1116
|
children: [
|
|
1083
1117
|
/* @__PURE__ */ jsx6(
|
|
1084
1118
|
"input",
|
|
@@ -1086,55 +1120,47 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1086
1120
|
ref: fileInputRef,
|
|
1087
1121
|
type: "file",
|
|
1088
1122
|
accept,
|
|
1089
|
-
|
|
1123
|
+
className: "d-none",
|
|
1090
1124
|
onChange: handleInputChange,
|
|
1091
1125
|
disabled
|
|
1092
1126
|
}
|
|
1093
1127
|
),
|
|
1094
|
-
selectedFile ? /* @__PURE__ */ jsxs4("div", { children: [
|
|
1128
|
+
selectedFile ? /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1095
1129
|
/* @__PURE__ */ jsxs4("div", { children: [
|
|
1096
1130
|
/* @__PURE__ */ jsx6("strong", { children: "Selected file:" }),
|
|
1097
1131
|
" ",
|
|
1098
1132
|
selectedFile.name
|
|
1099
1133
|
] }),
|
|
1100
|
-
/* @__PURE__ */ jsx6("div", {
|
|
1101
|
-
] }) : /* @__PURE__ */ jsxs4("div", { children: [
|
|
1134
|
+
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "Click here to change file or drag a new one." })
|
|
1135
|
+
] }) : /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1102
1136
|
/* @__PURE__ */ jsx6("div", { children: "Drag & drop a file here" }),
|
|
1103
|
-
/* @__PURE__ */ jsx6("div", {
|
|
1137
|
+
/* @__PURE__ */ jsx6("div", { className: "text-muted", children: "or click to browse" })
|
|
1104
1138
|
] })
|
|
1105
1139
|
]
|
|
1106
1140
|
}
|
|
1107
1141
|
),
|
|
1108
|
-
isUploading && /* @__PURE__ */ jsxs4("div", {
|
|
1109
|
-
"
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1142
|
+
isUploading && /* @__PURE__ */ jsxs4("div", { className: "small", children: [
|
|
1143
|
+
/* @__PURE__ */ jsxs4("div", { className: "d-flex justify-content-between mb-1", children: [
|
|
1144
|
+
/* @__PURE__ */ jsx6("span", { children: "Uploading..." }),
|
|
1145
|
+
/* @__PURE__ */ jsxs4("span", { children: [
|
|
1146
|
+
progress ?? 0,
|
|
1147
|
+
"%"
|
|
1148
|
+
] })
|
|
1149
|
+
] }),
|
|
1150
|
+
/* @__PURE__ */ jsx6("div", { className: "progress", children: /* @__PURE__ */ jsx6(
|
|
1113
1151
|
"div",
|
|
1114
1152
|
{
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
},
|
|
1122
|
-
children: /* @__PURE__ */ jsx6(
|
|
1123
|
-
"div",
|
|
1124
|
-
{
|
|
1125
|
-
style: {
|
|
1126
|
-
height: "100%",
|
|
1127
|
-
width: `${progress ?? 0}%`,
|
|
1128
|
-
backgroundColor: "#007bff",
|
|
1129
|
-
transition: "width 0.2s ease-out"
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
)
|
|
1153
|
+
className: "progress-bar progress-bar-striped progress-bar-animated",
|
|
1154
|
+
role: "progressbar",
|
|
1155
|
+
"aria-valuemin": 0,
|
|
1156
|
+
"aria-valuemax": 100,
|
|
1157
|
+
"aria-valuenow": progress ?? 0,
|
|
1158
|
+
style: { width: `${progress ?? 0}%` }
|
|
1133
1159
|
}
|
|
1134
|
-
)
|
|
1160
|
+
) })
|
|
1135
1161
|
] }),
|
|
1136
|
-
status === "success" && /* @__PURE__ */ jsx6("div", {
|
|
1137
|
-
status === "error" && /* @__PURE__ */ jsxs4("div", {
|
|
1162
|
+
status === "success" && /* @__PURE__ */ jsx6("div", { className: "small text-success", children: "Upload complete \u2705" }),
|
|
1163
|
+
status === "error" && /* @__PURE__ */ jsxs4("div", { className: "small text-danger", children: [
|
|
1138
1164
|
"Upload failed: ",
|
|
1139
1165
|
errorMessage
|
|
1140
1166
|
] }),
|
|
@@ -1144,15 +1170,7 @@ var SingleFileProcessUploader = ({ getPresignedUrl, onUploadComplete, accept, la
|
|
|
1144
1170
|
type: "button",
|
|
1145
1171
|
onClick: handleProcessClick,
|
|
1146
1172
|
disabled: !selectedFile || isUploading || disabled,
|
|
1147
|
-
|
|
1148
|
-
padding: "8px 16px",
|
|
1149
|
-
borderRadius: 4,
|
|
1150
|
-
border: "none",
|
|
1151
|
-
backgroundColor: !selectedFile || isUploading || disabled ? "#ccc" : "#007bff",
|
|
1152
|
-
color: "#fff",
|
|
1153
|
-
fontWeight: 600,
|
|
1154
|
-
cursor: !selectedFile || isUploading || disabled ? "not-allowed" : "pointer"
|
|
1155
|
-
},
|
|
1173
|
+
className: "btn btn-primary mt-2",
|
|
1156
1174
|
children: isUploading ? "Processing..." : "Process"
|
|
1157
1175
|
}
|
|
1158
1176
|
)
|
|
@@ -1186,7 +1204,8 @@ function HomeContent() {
|
|
|
1186
1204
|
"https://localhost:5001"
|
|
1187
1205
|
);
|
|
1188
1206
|
const contentType = file.type || "application/octet-stream";
|
|
1189
|
-
|
|
1207
|
+
const result = await res.s3.GetTemporaryPreSignedUrl(new TemporaryFileDTO({ Name: file.name, ContentType: contentType }));
|
|
1208
|
+
return result;
|
|
1190
1209
|
}
|
|
1191
1210
|
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1192
1211
|
/* @__PURE__ */ jsx7(UserInfoCard, {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkstudio/storage-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@fortawesome/free-solid-svg-icons": "^7.1.0",
|
|
41
41
|
"@fortawesome/react-fontawesome": "^3.1.1",
|
|
42
42
|
"@sparkstudio/authentication-ui": "^1.0.29",
|
|
43
|
-
"@sparkstudio/common-ui": "^1.0.
|
|
43
|
+
"@sparkstudio/common-ui": "^1.0.26",
|
|
44
44
|
"barrelsby": "^2.8.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|