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