cloudmr-ux 1.0.5 → 1.0.7
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.css +31 -0
- package/dist/index.d.ts +111 -3
- package/dist/index.js +589 -2
- package/dist/index.mjs +576 -2
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -149,9 +149,580 @@ var CmrSelect = ({ options, label, disabled }) => {
|
|
|
149
149
|
};
|
|
150
150
|
var CmrSelect_default = CmrSelect;
|
|
151
151
|
|
|
152
|
+
// src/CmrComponents/collapse/Collapse.tsx
|
|
153
|
+
import React3, { cloneElement } from "react";
|
|
154
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
155
|
+
var CmrCollapse = (props) => {
|
|
156
|
+
let { activeKey, defaultActiveKey, onChange, children } = props;
|
|
157
|
+
defaultActiveKey = defaultActiveKey || [];
|
|
158
|
+
const [activeKeys, setActiveKeys] = React3.useState(defaultActiveKey);
|
|
159
|
+
React3.useEffect(() => {
|
|
160
|
+
if (activeKey !== void 0 && activeKey !== activeKeys) {
|
|
161
|
+
if (Array.isArray(activeKey)) {
|
|
162
|
+
setActiveKeys(activeKey);
|
|
163
|
+
} else {
|
|
164
|
+
setActiveKeys([activeKey]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, [activeKey]);
|
|
168
|
+
const onToggle = (key) => {
|
|
169
|
+
const newKeys = [...activeKeys];
|
|
170
|
+
const keyIndex = newKeys.indexOf(key);
|
|
171
|
+
if (keyIndex === -1) {
|
|
172
|
+
newKeys.push(key);
|
|
173
|
+
} else {
|
|
174
|
+
newKeys.splice(keyIndex, 1);
|
|
175
|
+
}
|
|
176
|
+
setActiveKeys(newKeys);
|
|
177
|
+
if (onChange)
|
|
178
|
+
onChange(newKeys);
|
|
179
|
+
};
|
|
180
|
+
const renderChildren = () => {
|
|
181
|
+
if (!children)
|
|
182
|
+
return null;
|
|
183
|
+
if (Array.isArray(children)) {
|
|
184
|
+
return children.map((child, index) => {
|
|
185
|
+
const panelKey = index;
|
|
186
|
+
const expanded = activeKeys.includes(panelKey);
|
|
187
|
+
const header = /* @__PURE__ */ jsx6("div", { onClick: () => onToggle(panelKey), style: { cursor: "pointer" }, children: child.props.header });
|
|
188
|
+
return cloneElement(child, {
|
|
189
|
+
expanded,
|
|
190
|
+
panelKey,
|
|
191
|
+
onToggle,
|
|
192
|
+
header
|
|
193
|
+
// Override header with clickable version
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
} else {
|
|
197
|
+
const panelKey = 0;
|
|
198
|
+
const expanded = activeKeys.includes(panelKey);
|
|
199
|
+
const header = /* @__PURE__ */ jsx6("div", { onClick: () => onToggle(panelKey), style: { cursor: "pointer" }, children: children.props.header });
|
|
200
|
+
return cloneElement(children, {
|
|
201
|
+
expanded,
|
|
202
|
+
panelKey,
|
|
203
|
+
onToggle,
|
|
204
|
+
header
|
|
205
|
+
// Override header with clickable version
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
return /* @__PURE__ */ jsx6("div", { className: "cmr-collapse", children: /* @__PURE__ */ jsx6("div", { children: renderChildren() }) });
|
|
210
|
+
};
|
|
211
|
+
var Collapse_default = CmrCollapse;
|
|
212
|
+
|
|
213
|
+
// src/CmrComponents/panel/Panel.tsx
|
|
214
|
+
import ArrowDropUpIcon from "@mui/icons-material/ArrowDropUp";
|
|
215
|
+
import ArrowDropDownIcon from "@mui/icons-material/ArrowDropDown";
|
|
216
|
+
import { jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
217
|
+
var CmrPanel = function(props) {
|
|
218
|
+
var _a, _b;
|
|
219
|
+
let { expanded, onToggle } = props;
|
|
220
|
+
const toggle = () => {
|
|
221
|
+
if (onToggle)
|
|
222
|
+
onToggle(props.panelKey);
|
|
223
|
+
};
|
|
224
|
+
return /* @__PURE__ */ jsxs3("div", { className: `card ${props.className}`, children: [
|
|
225
|
+
/* @__PURE__ */ jsx7("div", { className: "card-header", style: { background: "white", display: props.header == void 0 ? "none" : void 0 }, children: /* @__PURE__ */ jsxs3("div", { className: "row align-items-center", children: [
|
|
226
|
+
/* @__PURE__ */ jsx7("div", { className: "col", children: props.header }),
|
|
227
|
+
onToggle && /* @__PURE__ */ jsx7("div", { className: "col text-end", children: /* @__PURE__ */ jsx7(
|
|
228
|
+
"span",
|
|
229
|
+
{
|
|
230
|
+
className: "react-collapse float-end btn",
|
|
231
|
+
onClick: (e) => {
|
|
232
|
+
toggle();
|
|
233
|
+
},
|
|
234
|
+
children: !expanded ? /* @__PURE__ */ jsx7(ArrowDropDownIcon, {}) : /* @__PURE__ */ jsx7(ArrowDropUpIcon, {})
|
|
235
|
+
}
|
|
236
|
+
) })
|
|
237
|
+
] }) }),
|
|
238
|
+
!expanded ? /* @__PURE__ */ jsx7("div", { className: `card-body m-0 ${(_a = props.cardProps) == null ? void 0 : _a.className}`, style: {
|
|
239
|
+
maxHeight: "0",
|
|
240
|
+
padding: 0,
|
|
241
|
+
opacity: "0",
|
|
242
|
+
overflow: "hidden",
|
|
243
|
+
visibility: "collapse",
|
|
244
|
+
transition: "all 0.5s"
|
|
245
|
+
}, children: props.children }) : /* @__PURE__ */ jsx7("div", { className: `card-body m-4 ${(_b = props.cardProps) == null ? void 0 : _b.className}`, style: {
|
|
246
|
+
maxHeight: void 0,
|
|
247
|
+
padding: 0,
|
|
248
|
+
opacity: "1",
|
|
249
|
+
visibility: "visible",
|
|
250
|
+
transition: "all 0.5s"
|
|
251
|
+
}, children: props.children })
|
|
252
|
+
] });
|
|
253
|
+
};
|
|
254
|
+
var Panel_default = CmrPanel;
|
|
255
|
+
|
|
256
|
+
// src/CmrComponents/upload/Upload.tsx
|
|
257
|
+
import React5, { useState as useState4 } from "react";
|
|
258
|
+
import { Button as Button3 } from "@mui/material";
|
|
259
|
+
|
|
260
|
+
// src/CmrComponents/upload/UploadWindow.tsx
|
|
261
|
+
import * as React4 from "react";
|
|
262
|
+
import Button2 from "@mui/material/Button";
|
|
263
|
+
import TextField from "@mui/material/TextField";
|
|
264
|
+
import Dialog from "@mui/material/Dialog";
|
|
265
|
+
import DialogActions from "@mui/material/DialogActions";
|
|
266
|
+
import DialogContent from "@mui/material/DialogContent";
|
|
267
|
+
import DialogContentText from "@mui/material/DialogContentText";
|
|
268
|
+
import DialogTitle from "@mui/material/DialogTitle";
|
|
269
|
+
import Typography from "@mui/material/Typography";
|
|
270
|
+
import Box from "@mui/material/Box";
|
|
271
|
+
import { Alert, Collapse, MenuItem as MenuItem2 } from "@mui/material";
|
|
272
|
+
|
|
273
|
+
// src/CmrComponents/label/Label.tsx
|
|
274
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
275
|
+
var CmrLabel = (props) => {
|
|
276
|
+
const { children, required = false } = props;
|
|
277
|
+
return /* @__PURE__ */ jsxs4("label", { className: "cmr-label", style: { fontSize: "16px", ...props.style }, children: [
|
|
278
|
+
children,
|
|
279
|
+
required && /* @__PURE__ */ jsx8("span", { className: "asterik", children: "*" })
|
|
280
|
+
] });
|
|
281
|
+
};
|
|
282
|
+
var Label_default = CmrLabel;
|
|
283
|
+
|
|
284
|
+
// src/CmrComponents/upload/UploadWindow.tsx
|
|
285
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
286
|
+
function UploadWindow({
|
|
287
|
+
upload,
|
|
288
|
+
open,
|
|
289
|
+
setOpen,
|
|
290
|
+
fileExtension,
|
|
291
|
+
template = { showFileName: true, showDatabase: true, showFileSize: true }
|
|
292
|
+
// default values
|
|
293
|
+
}) {
|
|
294
|
+
const [fileOriginalName, setFileOriginalName] = React4.useState("");
|
|
295
|
+
const [fileAlias, setFileAlias] = React4.useState("/");
|
|
296
|
+
const [fileSize, setFileSize] = React4.useState("0 MB");
|
|
297
|
+
const [warningText, setWarningText] = React4.useState("Unknown Status");
|
|
298
|
+
const [infoOpen, setInfoOpen] = React4.useState(false);
|
|
299
|
+
const [locationSelection, setLocationSelection] = React4.useState("s3");
|
|
300
|
+
const [infoStyle, setInfoStyle] = React4.useState("info");
|
|
301
|
+
const [uploadedFiles, setUploaded] = React4.useState([]);
|
|
302
|
+
const [UpBtnDisabled, setUpBtnDisabled] = React4.useState(false);
|
|
303
|
+
const [UpBtnText, setUpBtnText] = React4.useState("Upload");
|
|
304
|
+
const [uploadBoxWarning, setUploadBoxWarning] = React4.useState(void 0);
|
|
305
|
+
const handleClickOpen = () => {
|
|
306
|
+
setOpen(true);
|
|
307
|
+
};
|
|
308
|
+
const handleClose = () => {
|
|
309
|
+
setOpen(false);
|
|
310
|
+
};
|
|
311
|
+
const getExtension = (fileName) => {
|
|
312
|
+
if (fileName == void 0)
|
|
313
|
+
return;
|
|
314
|
+
return fileName.split(".").pop();
|
|
315
|
+
};
|
|
316
|
+
const handleConfirm = () => {
|
|
317
|
+
if (uploadedFiles.length === 0) {
|
|
318
|
+
setInfoOpen(true);
|
|
319
|
+
setInfoStyle("error");
|
|
320
|
+
setWarningText("Must select files to upload!");
|
|
321
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (fileAlias.length === 0) {
|
|
325
|
+
setInfoOpen(true);
|
|
326
|
+
setInfoStyle("error");
|
|
327
|
+
setWarningText("File name can't be empty");
|
|
328
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
setOpen(false);
|
|
332
|
+
upload(uploadedFiles[0], fileAlias, locationSelection).then((response) => {
|
|
333
|
+
console.log(response);
|
|
334
|
+
if (response > 0) {
|
|
335
|
+
setInfoOpen(true);
|
|
336
|
+
if (response === 200) {
|
|
337
|
+
setInfoStyle("success");
|
|
338
|
+
setWarningText("Upload successful");
|
|
339
|
+
setTimeout(() => {
|
|
340
|
+
setInfoOpen(false);
|
|
341
|
+
setOpen(false);
|
|
342
|
+
}, 1e3);
|
|
343
|
+
setUpBtnDisabled(false);
|
|
344
|
+
setUpBtnText("Upload");
|
|
345
|
+
} else if (response === 413) {
|
|
346
|
+
setInfoStyle("error");
|
|
347
|
+
setWarningText("File size limit exceeded");
|
|
348
|
+
setTimeout(() => {
|
|
349
|
+
setInfoOpen(false);
|
|
350
|
+
setUpBtnDisabled(false);
|
|
351
|
+
setUpBtnText("Upload");
|
|
352
|
+
}, 2e3);
|
|
353
|
+
} else if (response === 500) {
|
|
354
|
+
setInfoStyle("error");
|
|
355
|
+
setWarningText("Internal server error");
|
|
356
|
+
setTimeout(() => {
|
|
357
|
+
setInfoOpen(false);
|
|
358
|
+
setUpBtnDisabled(false);
|
|
359
|
+
setUpBtnText("Upload");
|
|
360
|
+
}, 1500);
|
|
361
|
+
setOpen(true);
|
|
362
|
+
} else if (response === 400) {
|
|
363
|
+
setInfoStyle("warning");
|
|
364
|
+
setWarningText("File upload cancelled");
|
|
365
|
+
setTimeout(() => {
|
|
366
|
+
setInfoOpen(false);
|
|
367
|
+
setUpBtnDisabled(false);
|
|
368
|
+
setUpBtnText("Upload");
|
|
369
|
+
}, 1e3);
|
|
370
|
+
setOpen(true);
|
|
371
|
+
} else {
|
|
372
|
+
setInfoStyle("warning");
|
|
373
|
+
setWarningText("Unknown status");
|
|
374
|
+
setTimeout(() => {
|
|
375
|
+
setInfoOpen(false);
|
|
376
|
+
setUpBtnDisabled(false);
|
|
377
|
+
setUpBtnText("Upload");
|
|
378
|
+
}, 2e3);
|
|
379
|
+
setOpen(true);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}).catch((error) => {
|
|
383
|
+
setUpBtnDisabled(false);
|
|
384
|
+
setUpBtnText("Upload");
|
|
385
|
+
setInfoOpen(true);
|
|
386
|
+
setInfoStyle("error");
|
|
387
|
+
setWarningText("Upload unsuccessful: " + error.message);
|
|
388
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
389
|
+
console.error("Error:", error);
|
|
390
|
+
});
|
|
391
|
+
setUpBtnDisabled(true);
|
|
392
|
+
setUpBtnText("Uploading");
|
|
393
|
+
};
|
|
394
|
+
const changeFileName = (e) => {
|
|
395
|
+
setFileAlias(e.target.value);
|
|
396
|
+
};
|
|
397
|
+
function loadFiles(files) {
|
|
398
|
+
if (files.length == 0) {
|
|
399
|
+
setInfoOpen(true);
|
|
400
|
+
setInfoStyle("warning");
|
|
401
|
+
setWarningText("No file selected");
|
|
402
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (files.length > 1) {
|
|
406
|
+
setInfoOpen(true);
|
|
407
|
+
setInfoStyle("warning");
|
|
408
|
+
setWarningText("Only accepts one file at a time");
|
|
409
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
let file = files[0];
|
|
413
|
+
setUploaded([file]);
|
|
414
|
+
function readFile(file2) {
|
|
415
|
+
setFileOriginalName(file2.name);
|
|
416
|
+
setFileAlias(file2.name);
|
|
417
|
+
const units = [
|
|
418
|
+
"B",
|
|
419
|
+
"KB",
|
|
420
|
+
"MB",
|
|
421
|
+
"GB",
|
|
422
|
+
"TB",
|
|
423
|
+
"PB",
|
|
424
|
+
"EB",
|
|
425
|
+
"ZB",
|
|
426
|
+
"YB"
|
|
427
|
+
];
|
|
428
|
+
let numberOfBytes = file2.size;
|
|
429
|
+
const exponent = Math.min(
|
|
430
|
+
Math.floor(Math.log(numberOfBytes) / Math.log(1024)),
|
|
431
|
+
units.length - 1
|
|
432
|
+
);
|
|
433
|
+
const approx = numberOfBytes / 1024 ** exponent;
|
|
434
|
+
const output = exponent === 0 ? `${numberOfBytes} bytes` : `${approx.toFixed(3)} ${units[exponent]}`;
|
|
435
|
+
setFileSize(output);
|
|
436
|
+
}
|
|
437
|
+
readFile(file);
|
|
438
|
+
}
|
|
439
|
+
let initialized = false;
|
|
440
|
+
let fileInput = (inputRef) => {
|
|
441
|
+
if (initialized)
|
|
442
|
+
return;
|
|
443
|
+
inputRef.addEventListener("dragover", function(e) {
|
|
444
|
+
e.stopPropagation();
|
|
445
|
+
e.preventDefault();
|
|
446
|
+
if (e.dataTransfer.files) {
|
|
447
|
+
let draggedFiles = e.dataTransfer.files;
|
|
448
|
+
if (draggedFiles.length > 1) {
|
|
449
|
+
setUploadBoxWarning("Only one file can be uploaded at a time");
|
|
450
|
+
} else if (fileExtension != void 0 && draggedFiles.length != 0 && getExtension(draggedFiles[0].name) != fileExtension) {
|
|
451
|
+
setUploadBoxWarning(`Only accepting files with extension ${fileExtension}`);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
e.dataTransfer.dropEffect = "copy";
|
|
455
|
+
});
|
|
456
|
+
inputRef.addEventListener("drop", function(e) {
|
|
457
|
+
e.stopPropagation();
|
|
458
|
+
e.preventDefault();
|
|
459
|
+
setUploadBoxWarning(void 0);
|
|
460
|
+
let files = e.dataTransfer.files;
|
|
461
|
+
if (files.length > 1) {
|
|
462
|
+
setInfoOpen(true);
|
|
463
|
+
setInfoStyle("warning");
|
|
464
|
+
setWarningText("Only one file can be uploaded at a time");
|
|
465
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
466
|
+
return;
|
|
467
|
+
} else if (fileExtension != void 0 && `.${getExtension(files[0].name)}` != fileExtension) {
|
|
468
|
+
setInfoOpen(true);
|
|
469
|
+
setInfoStyle("warning");
|
|
470
|
+
setWarningText(`Only accepting files with extension ${fileExtension}`);
|
|
471
|
+
setTimeout(() => setInfoOpen(false), 2500);
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
loadFiles(files);
|
|
475
|
+
});
|
|
476
|
+
inputRef.addEventListener("dragleave", () => {
|
|
477
|
+
setUploadBoxWarning(void 0);
|
|
478
|
+
});
|
|
479
|
+
initialized = true;
|
|
480
|
+
};
|
|
481
|
+
const fileInputClick = (e) => {
|
|
482
|
+
const fileElem = document.getElementById("file-window");
|
|
483
|
+
e.preventDefault();
|
|
484
|
+
if (fileElem) {
|
|
485
|
+
fileElem.click();
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
const loadSelectedFiles = (e) => {
|
|
489
|
+
e.preventDefault();
|
|
490
|
+
const fileElem = document.getElementById("file-window");
|
|
491
|
+
loadFiles(fileElem.files);
|
|
492
|
+
};
|
|
493
|
+
return /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsxs5(Dialog, { open, onClose: handleClose, children: [
|
|
494
|
+
/* @__PURE__ */ jsx9(DialogTitle, { children: "File Upload" }),
|
|
495
|
+
/* @__PURE__ */ jsxs5(DialogContent, { children: [
|
|
496
|
+
/* @__PURE__ */ jsx9(DialogContentText, {}),
|
|
497
|
+
/* @__PURE__ */ jsxs5(DialogContent, { dividers: true, children: [
|
|
498
|
+
/* @__PURE__ */ jsx9(
|
|
499
|
+
Box,
|
|
500
|
+
{
|
|
501
|
+
width: 500,
|
|
502
|
+
height: 250,
|
|
503
|
+
style: {
|
|
504
|
+
borderStyle: "dashed",
|
|
505
|
+
borderRadius: "5pt",
|
|
506
|
+
borderColor: uploadBoxWarning == void 0 ? "lightGray" : "#BA3C3C"
|
|
507
|
+
},
|
|
508
|
+
children: /* @__PURE__ */ jsx9(Typography, { component: "div", style: { height: "100%" }, children: /* @__PURE__ */ jsxs5(
|
|
509
|
+
Box,
|
|
510
|
+
{
|
|
511
|
+
style: {
|
|
512
|
+
display: "flex",
|
|
513
|
+
flexDirection: "column",
|
|
514
|
+
justifyContent: "center",
|
|
515
|
+
alignItems: "center",
|
|
516
|
+
height: "100%"
|
|
517
|
+
},
|
|
518
|
+
onClick: fileInputClick,
|
|
519
|
+
ref: fileInput,
|
|
520
|
+
children: [
|
|
521
|
+
/* @__PURE__ */ jsxs5(Typography, { variant: "body1", align: "center", style: { marginTop: "auto" }, children: [
|
|
522
|
+
"Drag & Drop or Click to Upload Your File Here ",
|
|
523
|
+
/* @__PURE__ */ jsx9("sup", { children: "*" })
|
|
524
|
+
] }),
|
|
525
|
+
/* @__PURE__ */ jsx9(Typography, { variant: "body2", align: "center", style: { marginTop: "auto", fontSize: "0.8rem", fontStyle: "italic" }, children: "* Warning: The file you are uploading may contain sensitive information protected under privacy laws. Please ensure all PHI is anonymized before proceeding.Before proceeding. The user is the sole responsible for data anonymization." })
|
|
526
|
+
]
|
|
527
|
+
}
|
|
528
|
+
) })
|
|
529
|
+
}
|
|
530
|
+
),
|
|
531
|
+
/* @__PURE__ */ jsx9(
|
|
532
|
+
"input",
|
|
533
|
+
{
|
|
534
|
+
type: "file",
|
|
535
|
+
id: "file-window",
|
|
536
|
+
multiple: true,
|
|
537
|
+
accept: fileExtension == void 0 ? "*" : fileExtension,
|
|
538
|
+
style: { display: "none" },
|
|
539
|
+
onChange: loadSelectedFiles
|
|
540
|
+
}
|
|
541
|
+
),
|
|
542
|
+
/* @__PURE__ */ jsxs5(Box, { component: "form", sx: { "& .MuiTextField-root": { m: 2, width: "25ch", mb: 0 } }, children: [
|
|
543
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
544
|
+
template.showFileName && /* @__PURE__ */ jsx9(
|
|
545
|
+
TextField,
|
|
546
|
+
{
|
|
547
|
+
required: true,
|
|
548
|
+
style: { marginTop: "30px" },
|
|
549
|
+
label: `File Alias:`,
|
|
550
|
+
value: fileAlias,
|
|
551
|
+
variant: "standard",
|
|
552
|
+
onChange: changeFileName
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
fileOriginalName != "" && /* @__PURE__ */ jsx9(Label_default, { style: { marginLeft: "16px", fontSize: "9pt", color: "#267833" }, children: fileOriginalName }),
|
|
556
|
+
template.showDatabase && /* @__PURE__ */ jsx9(
|
|
557
|
+
TextField,
|
|
558
|
+
{
|
|
559
|
+
select: true,
|
|
560
|
+
label: "Database:",
|
|
561
|
+
defaultValue: "s3",
|
|
562
|
+
helperText: "Upstream Storage Location",
|
|
563
|
+
variant: "standard",
|
|
564
|
+
children: [{ value: "s3", label: "S3" }].map((option) => /* @__PURE__ */ jsx9(MenuItem2, { value: option.value, children: option.label }, option.value))
|
|
565
|
+
}
|
|
566
|
+
)
|
|
567
|
+
] }),
|
|
568
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
569
|
+
template.showFileSize && /* @__PURE__ */ jsx9(
|
|
570
|
+
TextField,
|
|
571
|
+
{
|
|
572
|
+
label: "File Size:",
|
|
573
|
+
value: fileSize,
|
|
574
|
+
InputProps: {
|
|
575
|
+
readOnly: true
|
|
576
|
+
},
|
|
577
|
+
variant: "standard"
|
|
578
|
+
}
|
|
579
|
+
),
|
|
580
|
+
/* @__PURE__ */ jsx9(Collapse, { in: infoOpen, children: /* @__PURE__ */ jsx9(Alert, { severity: infoStyle, sx: { m: 1 }, children: warningText }) })
|
|
581
|
+
] })
|
|
582
|
+
] })
|
|
583
|
+
] }),
|
|
584
|
+
/* @__PURE__ */ jsxs5(DialogActions, { children: [
|
|
585
|
+
/* @__PURE__ */ jsx9(
|
|
586
|
+
Button2,
|
|
587
|
+
{
|
|
588
|
+
color: "inherit",
|
|
589
|
+
sx: { color: "#333" },
|
|
590
|
+
disabled: UpBtnDisabled,
|
|
591
|
+
onClick: handleClose,
|
|
592
|
+
children: "Cancel"
|
|
593
|
+
}
|
|
594
|
+
),
|
|
595
|
+
/* @__PURE__ */ jsx9(
|
|
596
|
+
Button2,
|
|
597
|
+
{
|
|
598
|
+
variant: "contained",
|
|
599
|
+
disabled: UpBtnDisabled,
|
|
600
|
+
onClick: handleConfirm,
|
|
601
|
+
children: UpBtnText
|
|
602
|
+
}
|
|
603
|
+
)
|
|
604
|
+
] })
|
|
605
|
+
] })
|
|
606
|
+
] }) });
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/CmrComponents/upload/Upload.tsx
|
|
610
|
+
import axios from "axios";
|
|
611
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
612
|
+
var CmrUpload = (props) => {
|
|
613
|
+
let [open, setOpen] = useState4(false);
|
|
614
|
+
let [uploading, setUploading] = useState4(false);
|
|
615
|
+
let [progress, setProgress] = useState4(0);
|
|
616
|
+
let [uploadedFile, setUploadedFile] = useState4(void 0);
|
|
617
|
+
const upload = async (file, fileAlias, fileDatabase) => {
|
|
618
|
+
setUploading(true);
|
|
619
|
+
const onProgress = (progress2) => {
|
|
620
|
+
let percentage = progress2 * 99;
|
|
621
|
+
props.uploadProgressed && props.uploadProgressed(+percentage.toFixed(2));
|
|
622
|
+
setProgress(+percentage.toFixed(2));
|
|
623
|
+
};
|
|
624
|
+
if (props.uploadStarted)
|
|
625
|
+
props.uploadStarted();
|
|
626
|
+
let status = 0;
|
|
627
|
+
if (props.beforeUpload != void 0 && !await props.beforeUpload(file)) {
|
|
628
|
+
if (props.uploadEnded)
|
|
629
|
+
props.uploadEnded();
|
|
630
|
+
setUploading(false);
|
|
631
|
+
return 200;
|
|
632
|
+
}
|
|
633
|
+
if (props.preprocess) {
|
|
634
|
+
let processed = await props.preprocess(file);
|
|
635
|
+
if (processed == void 0)
|
|
636
|
+
return failUpload();
|
|
637
|
+
if (typeof processed == "number") {
|
|
638
|
+
setUploading(false);
|
|
639
|
+
return processed;
|
|
640
|
+
}
|
|
641
|
+
file = processed;
|
|
642
|
+
}
|
|
643
|
+
if (props.uploadHandler != void 0) {
|
|
644
|
+
status = await props.uploadHandler(file, fileAlias, fileDatabase, onProgress, props.onUploaded);
|
|
645
|
+
setUploadedFile(props.reusable ? void 0 : file.name);
|
|
646
|
+
} else if (props.createPayload) {
|
|
647
|
+
let payload = await props.createPayload(file, fileAlias, fileDatabase);
|
|
648
|
+
if (payload == void 0) {
|
|
649
|
+
return failUpload();
|
|
650
|
+
}
|
|
651
|
+
payload.config.onUploadProgress = (progressEvent) => {
|
|
652
|
+
if (progressEvent.total == void 0)
|
|
653
|
+
return;
|
|
654
|
+
onProgress(progressEvent.loaded / progressEvent.total);
|
|
655
|
+
};
|
|
656
|
+
const res = await axios.post(payload.destination, payload.lambdaFile, payload.config);
|
|
657
|
+
status = res.status;
|
|
658
|
+
if (status === 200) {
|
|
659
|
+
console.log(res.data);
|
|
660
|
+
await axios.put(res.data.upload_url, payload.file, {
|
|
661
|
+
headers: {
|
|
662
|
+
"Content-Type": payload.file.type
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
await props.onUploaded(res, payload.file);
|
|
666
|
+
setUploadedFile(props.reusable ? void 0 : payload.file.name);
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
return failUpload();
|
|
670
|
+
}
|
|
671
|
+
if (props.uploadEnded)
|
|
672
|
+
props.uploadEnded();
|
|
673
|
+
setUploading(false);
|
|
674
|
+
setProgress(0);
|
|
675
|
+
return status;
|
|
676
|
+
};
|
|
677
|
+
function failUpload() {
|
|
678
|
+
setUploading(false);
|
|
679
|
+
setProgress(0);
|
|
680
|
+
if (props.uploadFailed)
|
|
681
|
+
return props.uploadFailed();
|
|
682
|
+
return 0;
|
|
683
|
+
}
|
|
684
|
+
return /* @__PURE__ */ jsxs6(React5.Fragment, { children: [
|
|
685
|
+
!uploading ? /* @__PURE__ */ jsxs6(
|
|
686
|
+
Button3,
|
|
687
|
+
{
|
|
688
|
+
fullWidth: props.fullWidth,
|
|
689
|
+
style: props.style,
|
|
690
|
+
variant: uploadedFile == void 0 ? "contained" : "outlined",
|
|
691
|
+
onClick: () => {
|
|
692
|
+
setOpen(true);
|
|
693
|
+
},
|
|
694
|
+
color: props.color || "primary",
|
|
695
|
+
sx: props.sx,
|
|
696
|
+
children: [
|
|
697
|
+
props.changeNameAfterUpload ? uploadedFile === void 0 ? props.uploadButtonName ? props.uploadButtonName : "Upload" : uploadedFile : props.uploadButtonName ? props.uploadButtonName : "Upload",
|
|
698
|
+
" "
|
|
699
|
+
]
|
|
700
|
+
}
|
|
701
|
+
) : /* @__PURE__ */ jsxs6(Button3, { fullWidth: props.fullWidth, style: props.style, variant: "contained", sx: { overflowWrap: "inherit" }, color: "primary", disabled: true, children: [
|
|
702
|
+
"Uploading ",
|
|
703
|
+
progress,
|
|
704
|
+
"%"
|
|
705
|
+
] }),
|
|
706
|
+
/* @__PURE__ */ jsx10(
|
|
707
|
+
UploadWindow,
|
|
708
|
+
{
|
|
709
|
+
open,
|
|
710
|
+
setOpen,
|
|
711
|
+
upload,
|
|
712
|
+
fileExtension: props.fileExtension,
|
|
713
|
+
template: { showFileName: true, showFileSize: true }
|
|
714
|
+
}
|
|
715
|
+
)
|
|
716
|
+
] });
|
|
717
|
+
};
|
|
718
|
+
CmrUpload.defaultProps = {
|
|
719
|
+
changeNameAfterUpload: true
|
|
720
|
+
};
|
|
721
|
+
var Upload_default = CmrUpload;
|
|
722
|
+
|
|
152
723
|
// src/CmrTable/CmrTable.tsx
|
|
153
724
|
import { DataGrid } from "@mui/x-data-grid";
|
|
154
|
-
import { jsx as
|
|
725
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
155
726
|
var CmrTable = (props) => {
|
|
156
727
|
const {
|
|
157
728
|
dataSource,
|
|
@@ -163,7 +734,7 @@ var CmrTable = (props) => {
|
|
|
163
734
|
showCheckbox = true,
|
|
164
735
|
...rest
|
|
165
736
|
} = props;
|
|
166
|
-
return /* @__PURE__ */
|
|
737
|
+
return /* @__PURE__ */ jsx11("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx11(
|
|
167
738
|
DataGrid,
|
|
168
739
|
{
|
|
169
740
|
rows: dataSource ? dataSource.map((row) => ({
|
|
@@ -188,9 +759,12 @@ var CmrTable_default = CmrTable;
|
|
|
188
759
|
// src/index.ts
|
|
189
760
|
var CmrTable2 = CmrTable_default;
|
|
190
761
|
export {
|
|
762
|
+
Upload_default as CMRUpload,
|
|
191
763
|
CmrButton,
|
|
192
764
|
CmrCheckbox,
|
|
765
|
+
Collapse_default as CmrCollapse,
|
|
193
766
|
CmrInput,
|
|
767
|
+
Panel_default as CmrPanel,
|
|
194
768
|
CmrRadioGroup_default as CmrRadioGroup,
|
|
195
769
|
CmrSelect_default as CmrSelect,
|
|
196
770
|
CmrTable2 as CmrTable
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudmr-ux",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"author": "erosmontin@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "erosmontin/cloudmr-ux",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@mui/material": "^5.14.2",
|
|
32
32
|
"@mui/x-data-grid": "^6.10.1",
|
|
33
33
|
"antd": "^5.22.1",
|
|
34
|
+
"axios": "^1.9.0",
|
|
34
35
|
"css-loader": "^7.1.2",
|
|
35
36
|
"sass": "^1.81.0",
|
|
36
37
|
"sass-loader": "^16.0.3",
|