cloudmr-ux 1.2.3 → 1.3.0

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.mjs CHANGED
@@ -213,539 +213,146 @@ var CmrPanel = function(props) {
213
213
  };
214
214
  var Panel_default = CmrPanel;
215
215
 
216
- // src/CmrComponents/rename/edit.tsx
216
+ // src/CmrComponents/upload/Upload.tsx
217
+ import React5, { useState as useState4 } from "react";
218
+ import { Button as Button3 } from "@mui/material";
219
+
220
+ // src/CmrComponents/upload/UploadWindow.tsx
217
221
  import * as React4 from "react";
218
- import { Typography } from "@mui/material";
222
+ import Button2 from "@mui/material/Button";
219
223
  import TextField from "@mui/material/TextField";
220
224
  import Dialog from "@mui/material/Dialog";
221
225
  import DialogActions from "@mui/material/DialogActions";
222
226
  import DialogContent from "@mui/material/DialogContent";
227
+ import DialogContentText from "@mui/material/DialogContentText";
223
228
  import DialogTitle from "@mui/material/DialogTitle";
224
- import { useEffect } from "react";
229
+ import Typography from "@mui/material/Typography";
230
+ import Box from "@mui/material/Box";
231
+ import { Alert, Collapse, MenuItem as MenuItem2 } from "@mui/material";
232
+
233
+ // src/CmrComponents/label/Label.tsx
225
234
  import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
226
- function CmrNameDialog(props) {
227
- let { originalName, open, setOpen } = props;
228
- const [helperText, setHelperText] = React4.useState("");
229
- const [text, setText] = React4.useState(originalName);
230
- const [error, setError] = React4.useState(false);
231
- const renamingCallback = props.renamingCallback;
232
- const handleClose = () => {
233
- setOpen(false);
234
- };
235
- useEffect(() => {
236
- checkError(originalName);
237
- }, [originalName]);
238
- const handleConfirm = async () => {
239
- if (await renamingCallback(text))
240
- handleClose();
241
- };
242
- const handleTextFieldChange = (e) => {
243
- setText(e.target.value);
244
- checkError(e.target.value);
245
- };
246
- const checkError = (text2) => {
247
- const fileNameRegex = /^[a-zA-Z0-9_\-]+\.[a-zA-Z]{1,5}$/;
248
- let newExtension = text2.split(".").pop();
249
- let orgExtension = originalName.indexOf(".") >= 0 ? originalName.split(".").pop() : "?";
250
- if (!fileNameRegex.test(text2)) {
251
- setError(true);
252
- if (text2.indexOf(".") < 0) {
253
- setHelperText("Invalid file name, needs a valid extension.");
254
- } else {
255
- setHelperText("Invalid file name, please check.");
256
- }
257
- } else if (newExtension !== orgExtension) {
258
- setHelperText(`You are modifying your file extension from .${orgExtension} to .${newExtension}.`);
259
- setError(false);
260
- } else {
261
- setError(false);
262
- setHelperText("");
263
- }
264
- };
265
- return /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsxs4(
266
- Dialog,
267
- {
268
- open,
269
- onClose: handleClose,
270
- fullWidth: true,
271
- maxWidth: "xs",
272
- children: [
273
- /* @__PURE__ */ jsx8(DialogTitle, { children: /* @__PURE__ */ jsxs4(Typography, { children: [
274
- ' Rename "',
275
- originalName,
276
- '" as:'
277
- ] }) }),
278
- /* @__PURE__ */ jsx8(DialogContent, { children: /* @__PURE__ */ jsx8(
279
- TextField,
280
- {
281
- autoFocus: true,
282
- margin: "dense",
283
- id: "name",
284
- defaultValue: originalName,
285
- onFocus: (event) => {
286
- event.target.select();
287
- },
288
- fullWidth: true,
289
- inputProps: { style: { fontSize: "16px" } },
290
- variant: "standard",
291
- onChange: handleTextFieldChange,
292
- error,
293
- helperText
294
- }
295
- ) }),
296
- /* @__PURE__ */ jsxs4(DialogActions, { children: [
297
- /* @__PURE__ */ jsx8(CmrButton_default, { variant: "outlined", onClick: handleClose, children: "Cancel" }),
298
- /* @__PURE__ */ jsx8(CmrButton_default, { variant: "contained", color: "primary", onClick: handleConfirm, children: "Confirm" })
299
- ] })
300
- ]
301
- }
302
- ) });
303
- }
235
+ var CmrLabel = (props) => {
236
+ const { children, required = false } = props;
237
+ return /* @__PURE__ */ jsxs4("label", { className: "cmr-label", style: { fontSize: "16px", ...props.style }, children: [
238
+ children,
239
+ required && /* @__PURE__ */ jsx8("span", { className: "asterik", children: "*" })
240
+ ] });
241
+ };
242
+ var Label_default = CmrLabel;
304
243
 
305
- // src/CmrComponents/dialogue/Confirmation.tsx
306
- import * as React5 from "react";
307
- import Dialog2 from "@mui/material/Dialog";
308
- import DialogActions2 from "@mui/material/DialogActions";
309
- import DialogContent2 from "@mui/material/DialogContent";
310
- import DialogContentText from "@mui/material/DialogContentText";
311
- import DialogTitle2 from "@mui/material/DialogTitle";
244
+ // src/CmrComponents/upload/UploadWindow.tsx
312
245
  import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
313
- function CmrConfirmation({
314
- name,
315
- message,
316
- cancelText = "Cancel",
317
- color,
246
+ function UploadWindow({
247
+ upload,
318
248
  open,
319
249
  setOpen,
320
- confirmCallback = () => {
321
- },
322
- confirmText = "Confirm",
323
- cancellable = false,
324
- cancelCallback = () => {
325
- },
326
- width
250
+ fileExtension,
251
+ template = { showFileName: true, showDatabase: true, showFileSize: true }
252
+ // default values
327
253
  }) {
328
- const [text, setText] = React5.useState("");
329
- const handleClose = () => {
330
- setOpen(false);
331
- };
332
- const handleConfirm = () => {
333
- confirmCallback();
334
- handleClose();
335
- };
336
- const handleCancel = () => {
337
- cancelCallback();
338
- handleClose();
339
- };
340
- return /* @__PURE__ */ jsxs5(Dialog2, { open, onClose: handleClose, children: [
341
- /* @__PURE__ */ jsx9(DialogTitle2, { children: name ? name : "Confirmation" }),
342
- /* @__PURE__ */ jsxs5(DialogContent2, { sx: { width }, children: [
343
- /* @__PURE__ */ jsx9(DialogContentText, { alignContent: "center", children: message }),
344
- /* @__PURE__ */ jsxs5(DialogActions2, { className: "mt-4", children: [
345
- cancellable && /* @__PURE__ */ jsx9(CmrButton_default, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: cancelText }),
346
- /* @__PURE__ */ jsx9(CmrButton_default, { variant: "contained", color, onClick: handleConfirm, children: confirmText })
347
- ] })
348
- ] })
349
- ] });
350
- }
351
-
352
- // src/CmrComponents/dialogue/DeletionDialog.tsx
353
- import * as React6 from "react";
354
- import TextField2 from "@mui/material/TextField";
355
- import Dialog3 from "@mui/material/Dialog";
356
- import DialogActions3 from "@mui/material/DialogActions";
357
- import DialogContent3 from "@mui/material/DialogContent";
358
- import DialogContentText2 from "@mui/material/DialogContentText";
359
- import DialogTitle3 from "@mui/material/DialogTitle";
360
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
361
- function CmrDeletionDialog(props) {
362
- const [open, setOpen] = React6.useState(true);
363
- const [text, setText] = React6.useState("");
254
+ const [fileOriginalName, setFileOriginalName] = React4.useState("");
255
+ const [fileAlias, setFileAlias] = React4.useState("/");
256
+ const [fileSize, setFileSize] = React4.useState("0 MB");
257
+ const [warningText, setWarningText] = React4.useState("Unknown Status");
258
+ const [infoOpen, setInfoOpen] = React4.useState(false);
259
+ const [locationSelection, setLocationSelection] = React4.useState("s3");
260
+ const [infoStyle, setInfoStyle] = React4.useState("info");
261
+ const [uploadedFiles, setUploaded] = React4.useState([]);
262
+ const [UpBtnDisabled, setUpBtnDisabled] = React4.useState(false);
263
+ const [UpBtnText, setUpBtnText] = React4.useState("Upload");
264
+ const [uploadBoxWarning, setUploadBoxWarning] = React4.useState(void 0);
364
265
  const handleClickOpen = () => {
365
266
  setOpen(true);
366
267
  };
367
268
  const handleClose = () => {
368
269
  setOpen(false);
369
270
  };
271
+ const getExtension = (fileName) => {
272
+ if (fileName == void 0)
273
+ return;
274
+ return fileName.split(".").pop();
275
+ };
370
276
  const handleConfirm = () => {
371
- if (text === props.name) {
372
- props.deletionCallback();
373
- setOpen(false);
277
+ if (uploadedFiles.length === 0) {
278
+ setInfoOpen(true);
279
+ setInfoStyle("error");
280
+ setWarningText("Must select files to upload!");
281
+ setTimeout(() => setInfoOpen(false), 2500);
282
+ return;
283
+ }
284
+ if (fileAlias.length === 0) {
285
+ setInfoOpen(true);
286
+ setInfoStyle("error");
287
+ setWarningText("File name can't be empty");
288
+ setTimeout(() => setInfoOpen(false), 2500);
289
+ return;
374
290
  }
291
+ setOpen(false);
292
+ upload(uploadedFiles[0], fileAlias, locationSelection).then((response) => {
293
+ console.log(response);
294
+ if (response > 0) {
295
+ setInfoOpen(true);
296
+ if (response === 200) {
297
+ setInfoStyle("success");
298
+ setWarningText("Upload successful");
299
+ setTimeout(() => {
300
+ setInfoOpen(false);
301
+ setOpen(false);
302
+ }, 1e3);
303
+ setUpBtnDisabled(false);
304
+ setUpBtnText("Upload");
305
+ } else if (response === 413) {
306
+ setInfoStyle("error");
307
+ setWarningText("File size limit exceeded");
308
+ setTimeout(() => {
309
+ setInfoOpen(false);
310
+ setUpBtnDisabled(false);
311
+ setUpBtnText("Upload");
312
+ }, 2e3);
313
+ } else if (response === 500) {
314
+ setInfoStyle("error");
315
+ setWarningText("Internal server error");
316
+ setTimeout(() => {
317
+ setInfoOpen(false);
318
+ setUpBtnDisabled(false);
319
+ setUpBtnText("Upload");
320
+ }, 1500);
321
+ setOpen(true);
322
+ } else if (response === 400) {
323
+ setInfoStyle("warning");
324
+ setWarningText("File upload cancelled");
325
+ setTimeout(() => {
326
+ setInfoOpen(false);
327
+ setUpBtnDisabled(false);
328
+ setUpBtnText("Upload");
329
+ }, 1e3);
330
+ setOpen(true);
331
+ } else {
332
+ setInfoStyle("warning");
333
+ setWarningText("Unknown status");
334
+ setTimeout(() => {
335
+ setInfoOpen(false);
336
+ setUpBtnDisabled(false);
337
+ setUpBtnText("Upload");
338
+ }, 2e3);
339
+ setOpen(true);
340
+ }
341
+ }
342
+ }).catch((error) => {
343
+ setUpBtnDisabled(false);
344
+ setUpBtnText("Upload");
345
+ setInfoOpen(true);
346
+ setInfoStyle("error");
347
+ setWarningText("Upload unsuccessful: " + error.message);
348
+ setTimeout(() => setInfoOpen(false), 2500);
349
+ console.error("Error:", error);
350
+ });
351
+ setUpBtnDisabled(true);
352
+ setUpBtnText("Uploading");
375
353
  };
376
- const handleTextFieldChange = (e) => {
377
- setText(e.target.value);
378
- };
379
- return /* @__PURE__ */ jsx10("div", { children: /* @__PURE__ */ jsxs6(Dialog3, { open, onClose: handleClose, children: [
380
- /* @__PURE__ */ jsx10(DialogTitle3, { children: "Confirmation" }),
381
- /* @__PURE__ */ jsxs6(DialogContent3, { children: [
382
- /* @__PURE__ */ jsx10(DialogContentText2, { children: "To delete the files, please type your full name below and confirm." }),
383
- /* @__PURE__ */ jsx10(
384
- TextField2,
385
- {
386
- autoFocus: true,
387
- margin: "dense",
388
- id: "name",
389
- type: "email",
390
- placeholder: props.name,
391
- fullWidth: true,
392
- inputProps: { style: { fontSize: "16pt" } },
393
- variant: "standard",
394
- onChange: handleTextFieldChange
395
- }
396
- )
397
- ] }),
398
- /* @__PURE__ */ jsxs6(DialogActions3, { children: [
399
- /* @__PURE__ */ jsx10("button", { className: "btn btn-secondary", onClick: handleClose, children: "Cancel" }),
400
- /* @__PURE__ */ jsx10("button", { className: "btn btn-danger", onClick: handleConfirm, children: "Confirm" })
401
- ] })
402
- ] }) });
403
- }
404
-
405
- // src/CmrComponents/dialogue/EditConfirmation.tsx
406
- import * as React7 from "react";
407
- import TextField3 from "@mui/material/TextField";
408
- import Dialog4 from "@mui/material/Dialog";
409
- import DialogActions4 from "@mui/material/DialogActions";
410
- import DialogContent4 from "@mui/material/DialogContent";
411
- import DialogContentText3 from "@mui/material/DialogContentText";
412
- import DialogTitle4 from "@mui/material/DialogTitle";
413
- import { InputAdornment } from "@mui/material";
414
- import { useEffect as useEffect2 } from "react";
415
- import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
416
- function CmrEditConfirmation({
417
- name,
418
- message,
419
- defaultText = "",
420
- color,
421
- open,
422
- setOpen,
423
- confirmCallback = () => {
424
- },
425
- cancellable = false,
426
- cancelCallback = () => {
427
- },
428
- suffix = ""
429
- }) {
430
- const [text, setText] = React7.useState(defaultText);
431
- useEffect2(() => {
432
- if (open)
433
- setText(defaultText);
434
- }, [open]);
435
- const handleClose = () => {
436
- setOpen(false);
437
- };
438
- const handleConfirm = () => {
439
- confirmCallback(text + suffix);
440
- handleClose();
441
- };
442
- const handleCancel = () => {
443
- cancelCallback(text + suffix);
444
- handleClose();
445
- };
446
- return /* @__PURE__ */ jsxs7(Dialog4, { maxWidth: "xs", fullWidth: true, open, onClose: handleCancel, children: [
447
- /* @__PURE__ */ jsx11(DialogTitle4, { children: name ? name : "Confirmation" }),
448
- /* @__PURE__ */ jsxs7(DialogContent4, { children: [
449
- /* @__PURE__ */ jsx11(DialogContentText3, { alignContent: "center", children: message }),
450
- /* @__PURE__ */ jsx11(DialogActions4, { children: /* @__PURE__ */ jsx11(
451
- TextField3,
452
- {
453
- fullWidth: true,
454
- variant: "standard",
455
- InputProps: {
456
- endAdornment: /* @__PURE__ */ jsx11(InputAdornment, { position: "end", sx: { whiteSpace: "nowrap" }, children: suffix })
457
- },
458
- defaultValue: text,
459
- onChange: (e) => setText(e.target.value)
460
- }
461
- ) }),
462
- /* @__PURE__ */ jsxs7(DialogActions4, { children: [
463
- cancellable && /* @__PURE__ */ jsx11(CmrButton_default, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: "Cancel" }),
464
- /* @__PURE__ */ jsx11(CmrButton_default, { variant: "contained", color, onClick: handleConfirm, children: "Confirm" })
465
- ] })
466
- ] })
467
- ] });
468
- }
469
-
470
- // src/CmrTabs/CmrTabs.tsx
471
- import * as React8 from "react";
472
- import Tabs from "@mui/material/Tabs";
473
- import Tab from "@mui/material/Tab";
474
- import Container from "@mui/material/Container";
475
- import Typography2 from "@mui/material/Typography";
476
- import Box from "@mui/material/Box";
477
- import { cloneElement as cloneElement2 } from "react";
478
- import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
479
- function CustomTabPanel(props) {
480
- const { children, value, index, ...other } = props;
481
- return /* @__PURE__ */ jsx12(
482
- "div",
483
- {
484
- role: "tabpanel",
485
- hidden: value !== index,
486
- id: `simple-tabpanel-${index}`,
487
- "aria-labelledby": `simple-tab-${index}`,
488
- ...other,
489
- children: /* @__PURE__ */ jsx12(Box, { sx: { p: 0 }, style: { display: value === index ? void 0 : "none" }, children: /* @__PURE__ */ jsx12(Typography2, { children }) })
490
- }
491
- );
492
- }
493
- function a11yProps(index) {
494
- return {
495
- id: `simple-tab-${index}`,
496
- "aria-controls": `simple-tabpanel-${index}`
497
- };
498
- }
499
- function CmrTabs(props) {
500
- const [value, setValue] = React8.useState(0);
501
- const handleChange = (event, newValue) => {
502
- setValue(newValue);
503
- if (props.onTabSelected)
504
- props.onTabSelected(newValue);
505
- };
506
- return /* @__PURE__ */ jsxs8(
507
- Container,
508
- {
509
- maxWidth: "lg",
510
- sx: {
511
- flex: 1,
512
- display: "flex",
513
- flexDirection: "column",
514
- mt: 4
515
- },
516
- children: [
517
- /* @__PURE__ */ jsx12(Box, { sx: { borderBottom: 1, borderColor: "divider", mb: 4 }, children: /* @__PURE__ */ jsx12(
518
- Tabs,
519
- {
520
- value,
521
- onChange: handleChange,
522
- "aria-label": "basic tabs example",
523
- textColor: "inherit",
524
- TabIndicatorProps: {
525
- style: {
526
- backgroundColor: "#580F8B"
527
- }
528
- },
529
- children: props.tabList.map((tab, index) => /* @__PURE__ */ jsx12(Tab, { sx: { color: value == index ? "#580F8B" : void 0 }, style: { fontSize: "14px", textTransform: "uppercase", fontWeight: 400 }, label: tab.text, ...a11yProps(index) }))
530
- }
531
- ) }),
532
- props.tabList.map(
533
- (tab, index) => /* @__PURE__ */ jsx12(CustomTabPanel, { value, index, children: cloneElement2(tab.children, {
534
- visible: value == index
535
- }) })
536
- )
537
- ]
538
- }
539
- );
540
- }
541
-
542
- // src/CmrComponents/checkbox/Checkbox.tsx
543
- import { Checkbox as Checkbox2 } from "@mui/material";
544
-
545
- // src/CmrComponents/label/Label.tsx
546
- import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
547
- var CmrLabel = (props) => {
548
- const { children, required = false } = props;
549
- return /* @__PURE__ */ jsxs9("label", { className: "cmr-label", style: { fontSize: "16px", ...props.style }, children: [
550
- children,
551
- required && /* @__PURE__ */ jsx13("span", { className: "asterik", children: "*" })
552
- ] });
553
- };
554
- var Label_default = CmrLabel;
555
-
556
- // src/CmrComponents/checkbox/Checkbox.tsx
557
- import { FormControlLabel as FormControlLabel3 } from "@mui/material";
558
- import { jsx as jsx14 } from "react/jsx-runtime";
559
- var CmrCheckbox = (props) => {
560
- const { defaultChecked, onChange, children, ...rest } = props;
561
- return /* @__PURE__ */ jsx14(
562
- FormControlLabel3,
563
- {
564
- disabled: props.disabled,
565
- style: props.style,
566
- className: props.className,
567
- control: /* @__PURE__ */ jsx14(Checkbox2, { style: props.style, checked: props.checked, defaultChecked, onChange }),
568
- label: /* @__PURE__ */ jsx14(Label_default, { children: props.children }),
569
- sx: props.sx,
570
- labelPlacement: "end"
571
- }
572
- );
573
- };
574
- var Checkbox_default = CmrCheckbox;
575
-
576
- // src/CmrComponents/input-number/InputNumber.tsx
577
- import { InputNumber } from "antd";
578
- import { jsx as jsx15 } from "react/jsx-runtime";
579
- var CmrInputNumber = (props) => {
580
- const { defaultValue, style, max, min, value, onChange, children, ...rest } = props;
581
- return /* @__PURE__ */ jsx15(InputNumber, { defaultValue, max, style, min, value, onChange, ...rest, children });
582
- };
583
- var InputNumber_default = CmrInputNumber;
584
-
585
- // src/CmrComponents/tooltip/Tooltip.tsx
586
- import { Tooltip } from "antd";
587
- import { jsx as jsx16 } from "react/jsx-runtime";
588
- var CmrTooltip = (props) => {
589
- const {
590
- arrowPointAtCenter,
591
- autoAdjustOverflow,
592
- color,
593
- defaultVisible,
594
- mouseEnterDelay,
595
- mouseLeaveDelay,
596
- overlayClassName,
597
- placement,
598
- visible,
599
- ...rest
600
- } = props;
601
- return /* @__PURE__ */ jsx16(
602
- Tooltip,
603
- {
604
- arrowPointAtCenter,
605
- autoAdjustOverflow,
606
- color,
607
- defaultVisible,
608
- mouseEnterDelay,
609
- mouseLeaveDelay,
610
- overlayClassName,
611
- placement,
612
- visible,
613
- ...rest
614
- }
615
- );
616
- };
617
- var Tooltip_default = CmrTooltip;
618
-
619
- // src/CmrComponents/select-upload/SelectUpload.tsx
620
- import React11, { Fragment } from "react";
621
-
622
- // src/CmrComponents/upload/Upload.tsx
623
- import React10, { useState as useState9 } from "react";
624
- import { Button as Button3 } from "@mui/material";
625
-
626
- // src/CmrComponents/upload/UploadWindow.tsx
627
- import * as React9 from "react";
628
- import Button2 from "@mui/material/Button";
629
- import TextField4 from "@mui/material/TextField";
630
- import Dialog5 from "@mui/material/Dialog";
631
- import DialogActions5 from "@mui/material/DialogActions";
632
- import DialogContent5 from "@mui/material/DialogContent";
633
- import DialogContentText4 from "@mui/material/DialogContentText";
634
- import DialogTitle5 from "@mui/material/DialogTitle";
635
- import Typography3 from "@mui/material/Typography";
636
- import Box2 from "@mui/material/Box";
637
- import { Alert, Collapse, MenuItem as MenuItem2 } from "@mui/material";
638
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
639
- function CmrUploadWindow({
640
- upload,
641
- open,
642
- setOpen,
643
- fileExtension,
644
- template = { showFileName: true, showDatabase: true, showFileSize: true }
645
- // default values
646
- }) {
647
- const [fileOriginalName, setFileOriginalName] = React9.useState("");
648
- const [fileAlias, setFileAlias] = React9.useState("/");
649
- const [fileSize, setFileSize] = React9.useState("0 MB");
650
- const [warningText, setWarningText] = React9.useState("Unknown Status");
651
- const [infoOpen, setInfoOpen] = React9.useState(false);
652
- const [locationSelection, setLocationSelection] = React9.useState("s3");
653
- const [infoStyle, setInfoStyle] = React9.useState("info");
654
- const [uploadedFiles, setUploaded] = React9.useState([]);
655
- const [UpBtnDisabled, setUpBtnDisabled] = React9.useState(false);
656
- const [UpBtnText, setUpBtnText] = React9.useState("Upload");
657
- const [uploadBoxWarning, setUploadBoxWarning] = React9.useState(void 0);
658
- const handleClickOpen = () => {
659
- setOpen(true);
660
- };
661
- const handleClose = () => {
662
- setOpen(false);
663
- };
664
- const getExtension = (fileName) => {
665
- if (fileName == void 0)
666
- return;
667
- return fileName.split(".").pop();
668
- };
669
- const handleConfirm = () => {
670
- if (uploadedFiles.length === 0) {
671
- setInfoOpen(true);
672
- setInfoStyle("error");
673
- setWarningText("Must select files to upload!");
674
- setTimeout(() => setInfoOpen(false), 2500);
675
- return;
676
- }
677
- if (fileAlias.length === 0) {
678
- setInfoOpen(true);
679
- setInfoStyle("error");
680
- setWarningText("File name can't be empty");
681
- setTimeout(() => setInfoOpen(false), 2500);
682
- return;
683
- }
684
- setOpen(false);
685
- upload(uploadedFiles[0], fileAlias, locationSelection).then((response) => {
686
- console.log(response);
687
- if (response > 0) {
688
- setInfoOpen(true);
689
- if (response === 200) {
690
- setInfoStyle("success");
691
- setWarningText("Upload successful");
692
- setTimeout(() => {
693
- setInfoOpen(false);
694
- setOpen(false);
695
- }, 1e3);
696
- setUpBtnDisabled(false);
697
- setUpBtnText("Upload");
698
- } else if (response === 413) {
699
- setInfoStyle("error");
700
- setWarningText("File size limit exceeded");
701
- setTimeout(() => {
702
- setInfoOpen(false);
703
- setUpBtnDisabled(false);
704
- setUpBtnText("Upload");
705
- }, 2e3);
706
- } else if (response === 500) {
707
- setInfoStyle("error");
708
- setWarningText("Internal server error");
709
- setTimeout(() => {
710
- setInfoOpen(false);
711
- setUpBtnDisabled(false);
712
- setUpBtnText("Upload");
713
- }, 1500);
714
- setOpen(true);
715
- } else if (response === 400) {
716
- setInfoStyle("warning");
717
- setWarningText("File upload cancelled");
718
- setTimeout(() => {
719
- setInfoOpen(false);
720
- setUpBtnDisabled(false);
721
- setUpBtnText("Upload");
722
- }, 1e3);
723
- setOpen(true);
724
- } else {
725
- setInfoStyle("warning");
726
- setWarningText("Unknown status");
727
- setTimeout(() => {
728
- setInfoOpen(false);
729
- setUpBtnDisabled(false);
730
- setUpBtnText("Upload");
731
- }, 2e3);
732
- setOpen(true);
733
- }
734
- }
735
- }).catch((error) => {
736
- setUpBtnDisabled(false);
737
- setUpBtnText("Upload");
738
- setInfoOpen(true);
739
- setInfoStyle("error");
740
- setWarningText("Upload unsuccessful: " + error.message);
741
- setTimeout(() => setInfoOpen(false), 2500);
742
- console.error("Error:", error);
743
- });
744
- setUpBtnDisabled(true);
745
- setUpBtnText("Uploading");
746
- };
747
- const changeFileName = (e) => {
748
- setFileAlias(e.target.value);
354
+ const changeFileName = (e) => {
355
+ setFileAlias(e.target.value);
749
356
  };
750
357
  function loadFiles(files) {
751
358
  if (files.length == 0) {
@@ -843,13 +450,13 @@ function CmrUploadWindow({
843
450
  const fileElem = document.getElementById("file-window");
844
451
  loadFiles(fileElem.files);
845
452
  };
846
- return /* @__PURE__ */ jsx17("div", { children: /* @__PURE__ */ jsxs10(Dialog5, { open, onClose: handleClose, children: [
847
- /* @__PURE__ */ jsx17(DialogTitle5, { children: "File Upload" }),
848
- /* @__PURE__ */ jsxs10(DialogContent5, { children: [
849
- /* @__PURE__ */ jsx17(DialogContentText4, {}),
850
- /* @__PURE__ */ jsxs10(DialogContent5, { dividers: true, children: [
851
- /* @__PURE__ */ jsx17(
852
- Box2,
453
+ return /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsxs5(Dialog, { open, onClose: handleClose, children: [
454
+ /* @__PURE__ */ jsx9(DialogTitle, { children: "File Upload" }),
455
+ /* @__PURE__ */ jsxs5(DialogContent, { children: [
456
+ /* @__PURE__ */ jsx9(DialogContentText, {}),
457
+ /* @__PURE__ */ jsxs5(DialogContent, { dividers: true, children: [
458
+ /* @__PURE__ */ jsx9(
459
+ Box,
853
460
  {
854
461
  width: 500,
855
462
  height: 250,
@@ -858,8 +465,8 @@ function CmrUploadWindow({
858
465
  borderRadius: "5pt",
859
466
  borderColor: uploadBoxWarning == void 0 ? "lightGray" : "#BA3C3C"
860
467
  },
861
- children: /* @__PURE__ */ jsx17(Typography3, { component: "div", style: { height: "100%" }, children: /* @__PURE__ */ jsxs10(
862
- Box2,
468
+ children: /* @__PURE__ */ jsx9(Typography, { component: "div", style: { height: "100%" }, children: /* @__PURE__ */ jsxs5(
469
+ Box,
863
470
  {
864
471
  style: {
865
472
  display: "flex",
@@ -871,17 +478,17 @@ function CmrUploadWindow({
871
478
  onClick: fileInputClick,
872
479
  ref: fileInput,
873
480
  children: [
874
- /* @__PURE__ */ jsxs10(Typography3, { variant: "body1", align: "center", style: { marginTop: "auto" }, children: [
481
+ /* @__PURE__ */ jsxs5(Typography, { variant: "body1", align: "center", style: { marginTop: "auto" }, children: [
875
482
  "Drag & Drop or Click to Upload Your File Here ",
876
- /* @__PURE__ */ jsx17("sup", { children: "*" })
483
+ /* @__PURE__ */ jsx9("sup", { children: "*" })
877
484
  ] }),
878
- /* @__PURE__ */ jsx17(Typography3, { 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." })
485
+ /* @__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." })
879
486
  ]
880
487
  }
881
488
  ) })
882
489
  }
883
490
  ),
884
- /* @__PURE__ */ jsx17(
491
+ /* @__PURE__ */ jsx9(
885
492
  "input",
886
493
  {
887
494
  type: "file",
@@ -892,10 +499,10 @@ function CmrUploadWindow({
892
499
  onChange: loadSelectedFiles
893
500
  }
894
501
  ),
895
- /* @__PURE__ */ jsxs10(Box2, { component: "form", sx: { "& .MuiTextField-root": { m: 2, width: "25ch", mb: 0 } }, children: [
896
- /* @__PURE__ */ jsxs10("div", { children: [
897
- template.showFileName && /* @__PURE__ */ jsx17(
898
- TextField4,
502
+ /* @__PURE__ */ jsxs5(Box, { component: "form", sx: { "& .MuiTextField-root": { m: 2, width: "25ch", mb: 0 } }, children: [
503
+ /* @__PURE__ */ jsxs5("div", { children: [
504
+ template.showFileName && /* @__PURE__ */ jsx9(
505
+ TextField,
899
506
  {
900
507
  required: true,
901
508
  style: { marginTop: "30px" },
@@ -905,22 +512,22 @@ function CmrUploadWindow({
905
512
  onChange: changeFileName
906
513
  }
907
514
  ),
908
- fileOriginalName != "" && /* @__PURE__ */ jsx17(Label_default, { style: { marginLeft: "16px", fontSize: "9pt", color: "#267833" }, children: fileOriginalName }),
909
- template.showDatabase && /* @__PURE__ */ jsx17(
910
- TextField4,
515
+ fileOriginalName != "" && /* @__PURE__ */ jsx9(Label_default, { style: { marginLeft: "16px", fontSize: "9pt", color: "#267833" }, children: fileOriginalName }),
516
+ template.showDatabase && /* @__PURE__ */ jsx9(
517
+ TextField,
911
518
  {
912
519
  select: true,
913
520
  label: "Database:",
914
521
  defaultValue: "s3",
915
522
  helperText: "Upstream Storage Location",
916
523
  variant: "standard",
917
- children: [{ value: "s3", label: "S3" }].map((option) => /* @__PURE__ */ jsx17(MenuItem2, { value: option.value, children: option.label }, option.value))
524
+ children: [{ value: "s3", label: "S3" }].map((option) => /* @__PURE__ */ jsx9(MenuItem2, { value: option.value, children: option.label }, option.value))
918
525
  }
919
526
  )
920
527
  ] }),
921
- /* @__PURE__ */ jsxs10("div", { children: [
922
- template.showFileSize && /* @__PURE__ */ jsx17(
923
- TextField4,
528
+ /* @__PURE__ */ jsxs5("div", { children: [
529
+ template.showFileSize && /* @__PURE__ */ jsx9(
530
+ TextField,
924
531
  {
925
532
  label: "File Size:",
926
533
  value: fileSize,
@@ -930,12 +537,12 @@ function CmrUploadWindow({
930
537
  variant: "standard"
931
538
  }
932
539
  ),
933
- /* @__PURE__ */ jsx17(Collapse, { in: infoOpen, children: /* @__PURE__ */ jsx17(Alert, { severity: infoStyle, sx: { m: 1 }, children: warningText }) })
540
+ /* @__PURE__ */ jsx9(Collapse, { in: infoOpen, children: /* @__PURE__ */ jsx9(Alert, { severity: infoStyle, sx: { m: 1 }, children: warningText }) })
934
541
  ] })
935
542
  ] })
936
543
  ] }),
937
- /* @__PURE__ */ jsxs10(DialogActions5, { children: [
938
- /* @__PURE__ */ jsx17(
544
+ /* @__PURE__ */ jsxs5(DialogActions, { children: [
545
+ /* @__PURE__ */ jsx9(
939
546
  Button2,
940
547
  {
941
548
  color: "inherit",
@@ -945,7 +552,7 @@ function CmrUploadWindow({
945
552
  children: "Cancel"
946
553
  }
947
554
  ),
948
- /* @__PURE__ */ jsx17(
555
+ /* @__PURE__ */ jsx9(
949
556
  Button2,
950
557
  {
951
558
  variant: "contained",
@@ -961,12 +568,12 @@ function CmrUploadWindow({
961
568
 
962
569
  // src/CmrComponents/upload/Upload.tsx
963
570
  import axios from "axios";
964
- import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
571
+ import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
965
572
  var CmrUpload = (props) => {
966
- let [open, setOpen] = useState9(false);
967
- let [uploading, setUploading] = useState9(false);
968
- let [progress, setProgress] = useState9(0);
969
- let [uploadedFile, setUploadedFile] = useState9(void 0);
573
+ let [open, setOpen] = useState4(false);
574
+ let [uploading, setUploading] = useState4(false);
575
+ let [progress, setProgress] = useState4(0);
576
+ let [uploadedFile, setUploadedFile] = useState4(void 0);
970
577
  const upload = async (file, fileAlias, fileDatabase) => {
971
578
  setUploading(true);
972
579
  const onProgress = (progress2) => {
@@ -1027,154 +634,411 @@ var CmrUpload = (props) => {
1027
634
  setProgress(0);
1028
635
  return status;
1029
636
  };
1030
- function failUpload() {
1031
- setUploading(false);
1032
- setProgress(0);
1033
- if (props.uploadFailed)
1034
- return props.uploadFailed();
1035
- return 0;
1036
- }
1037
- return /* @__PURE__ */ jsxs11(React10.Fragment, { children: [
1038
- !uploading ? /* @__PURE__ */ jsxs11(
1039
- Button3,
1040
- {
1041
- fullWidth: props.fullWidth,
1042
- style: props.style,
1043
- variant: uploadedFile == void 0 ? "contained" : "outlined",
1044
- onClick: () => {
1045
- setOpen(true);
1046
- },
1047
- color: props.color || "primary",
1048
- sx: props.sx,
1049
- children: [
1050
- props.changeNameAfterUpload ? uploadedFile === void 0 ? props.uploadButtonName ? props.uploadButtonName : "Upload" : uploadedFile : props.uploadButtonName ? props.uploadButtonName : "Upload",
1051
- " "
1052
- ]
1053
- }
1054
- ) : /* @__PURE__ */ jsxs11(Button3, { fullWidth: props.fullWidth, style: props.style, variant: "contained", sx: { overflowWrap: "inherit" }, color: "primary", disabled: true, children: [
1055
- "Uploading ",
1056
- progress,
1057
- "%"
1058
- ] }),
1059
- /* @__PURE__ */ jsx18(
1060
- CmrUploadWindow,
1061
- {
1062
- open,
1063
- setOpen,
1064
- upload,
1065
- fileExtension: props.fileExtension,
1066
- template: { showFileName: true, showFileSize: true }
1067
- }
1068
- )
637
+ function failUpload() {
638
+ setUploading(false);
639
+ setProgress(0);
640
+ if (props.uploadFailed)
641
+ return props.uploadFailed();
642
+ return 0;
643
+ }
644
+ return /* @__PURE__ */ jsxs6(React5.Fragment, { children: [
645
+ !uploading ? /* @__PURE__ */ jsxs6(
646
+ Button3,
647
+ {
648
+ fullWidth: props.fullWidth,
649
+ style: props.style,
650
+ variant: uploadedFile == void 0 ? "contained" : "outlined",
651
+ onClick: () => {
652
+ setOpen(true);
653
+ },
654
+ color: props.color || "primary",
655
+ sx: props.sx,
656
+ children: [
657
+ props.changeNameAfterUpload ? uploadedFile === void 0 ? props.uploadButtonName ? props.uploadButtonName : "Upload" : uploadedFile : props.uploadButtonName ? props.uploadButtonName : "Upload",
658
+ " "
659
+ ]
660
+ }
661
+ ) : /* @__PURE__ */ jsxs6(Button3, { fullWidth: props.fullWidth, style: props.style, variant: "contained", sx: { overflowWrap: "inherit" }, color: "primary", disabled: true, children: [
662
+ "Uploading ",
663
+ progress,
664
+ "%"
665
+ ] }),
666
+ /* @__PURE__ */ jsx10(
667
+ UploadWindow,
668
+ {
669
+ open,
670
+ setOpen,
671
+ upload,
672
+ fileExtension: props.fileExtension,
673
+ template: { showFileName: true, showFileSize: true }
674
+ }
675
+ )
676
+ ] });
677
+ };
678
+ CmrUpload.defaultProps = {
679
+ changeNameAfterUpload: true
680
+ };
681
+ var Upload_default = CmrUpload;
682
+
683
+ // src/CmrComponents/rename/edit.tsx
684
+ import * as React6 from "react";
685
+ import { Typography as Typography2 } from "@mui/material";
686
+ import TextField2 from "@mui/material/TextField";
687
+ import Dialog2 from "@mui/material/Dialog";
688
+ import DialogActions2 from "@mui/material/DialogActions";
689
+ import DialogContent2 from "@mui/material/DialogContent";
690
+ import DialogTitle2 from "@mui/material/DialogTitle";
691
+ import { useEffect } from "react";
692
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
693
+ function CmrNameDialog(props) {
694
+ let { originalName, open, setOpen } = props;
695
+ const [helperText, setHelperText] = React6.useState("");
696
+ const [text, setText] = React6.useState(originalName);
697
+ const [error, setError] = React6.useState(false);
698
+ const renamingCallback = props.renamingCallback;
699
+ const handleClose = () => {
700
+ setOpen(false);
701
+ };
702
+ useEffect(() => {
703
+ checkError(originalName);
704
+ }, [originalName]);
705
+ const handleConfirm = async () => {
706
+ if (await renamingCallback(text))
707
+ handleClose();
708
+ };
709
+ const handleTextFieldChange = (e) => {
710
+ setText(e.target.value);
711
+ checkError(e.target.value);
712
+ };
713
+ const checkError = (text2) => {
714
+ const fileNameRegex = /^[a-zA-Z0-9_\-]+\.[a-zA-Z]{1,5}$/;
715
+ let newExtension = text2.split(".").pop();
716
+ let orgExtension = originalName.indexOf(".") >= 0 ? originalName.split(".").pop() : "?";
717
+ if (!fileNameRegex.test(text2)) {
718
+ setError(true);
719
+ if (text2.indexOf(".") < 0) {
720
+ setHelperText("Invalid file name, needs a valid extension.");
721
+ } else {
722
+ setHelperText("Invalid file name, please check.");
723
+ }
724
+ } else if (newExtension !== orgExtension) {
725
+ setHelperText(`You are modifying your file extension from .${orgExtension} to .${newExtension}.`);
726
+ setError(false);
727
+ } else {
728
+ setError(false);
729
+ setHelperText("");
730
+ }
731
+ };
732
+ return /* @__PURE__ */ jsx11("div", { children: /* @__PURE__ */ jsxs7(
733
+ Dialog2,
734
+ {
735
+ open,
736
+ onClose: handleClose,
737
+ fullWidth: true,
738
+ maxWidth: "xs",
739
+ children: [
740
+ /* @__PURE__ */ jsx11(DialogTitle2, { children: /* @__PURE__ */ jsxs7(Typography2, { children: [
741
+ " Rename the File ",
742
+ originalName,
743
+ " as:"
744
+ ] }) }),
745
+ /* @__PURE__ */ jsx11(DialogContent2, { children: /* @__PURE__ */ jsx11(
746
+ TextField2,
747
+ {
748
+ autoFocus: true,
749
+ margin: "dense",
750
+ id: "name",
751
+ defaultValue: originalName,
752
+ onFocus: (event) => {
753
+ event.target.select();
754
+ },
755
+ fullWidth: true,
756
+ inputProps: { style: { fontSize: "16px" } },
757
+ variant: "standard",
758
+ onChange: handleTextFieldChange,
759
+ error,
760
+ helperText
761
+ }
762
+ ) }),
763
+ /* @__PURE__ */ jsxs7(DialogActions2, { children: [
764
+ /* @__PURE__ */ jsx11(CmrButton_default, { variant: "outlined", onClick: handleClose, children: "Cancel" }),
765
+ /* @__PURE__ */ jsx11(CmrButton_default, { variant: "contained", color: "primary", onClick: handleConfirm, children: "Confirm" })
766
+ ] })
767
+ ]
768
+ }
769
+ ) });
770
+ }
771
+
772
+ // src/CmrComponents/dialogue/Confirmation.tsx
773
+ import * as React7 from "react";
774
+ import Dialog3 from "@mui/material/Dialog";
775
+ import DialogActions3 from "@mui/material/DialogActions";
776
+ import DialogContent3 from "@mui/material/DialogContent";
777
+ import DialogContentText2 from "@mui/material/DialogContentText";
778
+ import DialogTitle3 from "@mui/material/DialogTitle";
779
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
780
+ function CmrConfirmation({
781
+ name,
782
+ message,
783
+ cancelText = "Cancel",
784
+ color,
785
+ open,
786
+ setOpen,
787
+ confirmCallback = () => {
788
+ },
789
+ confirmText = "Confirm",
790
+ cancellable = false,
791
+ cancelCallback = () => {
792
+ },
793
+ width
794
+ }) {
795
+ const [text, setText] = React7.useState("");
796
+ const handleClose = () => {
797
+ setOpen(false);
798
+ };
799
+ const handleConfirm = () => {
800
+ confirmCallback();
801
+ handleClose();
802
+ };
803
+ const handleCancel = () => {
804
+ cancelCallback();
805
+ handleClose();
806
+ };
807
+ return /* @__PURE__ */ jsxs8(Dialog3, { open, onClose: handleClose, children: [
808
+ /* @__PURE__ */ jsx12(DialogTitle3, { children: name ? name : "Confirmation" }),
809
+ /* @__PURE__ */ jsxs8(DialogContent3, { sx: { width }, children: [
810
+ /* @__PURE__ */ jsx12(DialogContentText2, { alignContent: "center", children: message }),
811
+ /* @__PURE__ */ jsxs8(DialogActions3, { className: "mt-4", children: [
812
+ cancellable && /* @__PURE__ */ jsx12(CmrButton_default, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: cancelText }),
813
+ /* @__PURE__ */ jsx12(CmrButton_default, { variant: "contained", color, onClick: handleConfirm, children: confirmText })
814
+ ] })
815
+ ] })
1069
816
  ] });
1070
- };
1071
- CmrUpload.defaultProps = {
1072
- changeNameAfterUpload: true
1073
- };
1074
- var Upload_default = CmrUpload;
817
+ }
1075
818
 
1076
- // src/CmrComponents/select-upload/SelectUpload.tsx
1077
- import { Button as Button4, MenuItem as MenuItem3 } from "@mui/material";
1078
- import Select2 from "@mui/material/Select";
1079
- import Dialog6 from "@mui/material/Dialog";
1080
- import DialogTitle6 from "@mui/material/DialogTitle";
1081
- import DialogContent6 from "@mui/material/DialogContent";
1082
- import DialogContentText5 from "@mui/material/DialogContentText";
1083
- import Box4 from "@mui/material/Box";
1084
- import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
1085
- var CMRSelectUpload = (props) => {
1086
- let [open, setOpen] = React11.useState(false);
1087
- let [fileIndex, selectFileIndex] = React11.useState(-1);
1088
- let [uploading, setUploading] = React11.useState(false);
1089
- const [progress, setProgress] = React11.useState(0);
819
+ // src/CmrComponents/dialogue/DeletionDialog.tsx
820
+ import * as React8 from "react";
821
+ import TextField3 from "@mui/material/TextField";
822
+ import Dialog4 from "@mui/material/Dialog";
823
+ import DialogActions4 from "@mui/material/DialogActions";
824
+ import DialogContent4 from "@mui/material/DialogContent";
825
+ import DialogContentText3 from "@mui/material/DialogContentText";
826
+ import DialogTitle4 from "@mui/material/DialogTitle";
827
+ import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
828
+ function CmrDeletionDialog(props) {
829
+ const [open, setOpen] = React8.useState(true);
830
+ const [text, setText] = React8.useState("");
1090
831
  const handleClickOpen = () => {
1091
- selectFileIndex(-1);
1092
832
  setOpen(true);
1093
833
  };
1094
834
  const handleClose = () => {
1095
835
  setOpen(false);
1096
836
  };
1097
- const handleChange = (event) => {
1098
- selectFileIndex(event.target.value);
837
+ const handleConfirm = () => {
838
+ if (text === props.name) {
839
+ props.deletionCallback();
840
+ setOpen(false);
841
+ }
842
+ };
843
+ const handleTextFieldChange = (e) => {
844
+ setText(e.target.value);
1099
845
  };
1100
- const onSet = () => {
1101
- props.onSelected(props.fileSelection[fileIndex]);
846
+ return /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsxs9(Dialog4, { open, onClose: handleClose, children: [
847
+ /* @__PURE__ */ jsx13(DialogTitle4, { children: "Confirmation" }),
848
+ /* @__PURE__ */ jsxs9(DialogContent4, { children: [
849
+ /* @__PURE__ */ jsx13(DialogContentText3, { children: "To delete the files, please type your full name below and confirm." }),
850
+ /* @__PURE__ */ jsx13(
851
+ TextField3,
852
+ {
853
+ autoFocus: true,
854
+ margin: "dense",
855
+ id: "name",
856
+ type: "email",
857
+ placeholder: props.name,
858
+ fullWidth: true,
859
+ inputProps: { style: { fontSize: "16pt" } },
860
+ variant: "standard",
861
+ onChange: handleTextFieldChange
862
+ }
863
+ )
864
+ ] }),
865
+ /* @__PURE__ */ jsxs9(DialogActions4, { children: [
866
+ /* @__PURE__ */ jsx13("button", { className: "btn btn-secondary", onClick: handleClose, children: "Cancel" }),
867
+ /* @__PURE__ */ jsx13("button", { className: "btn btn-danger", onClick: handleConfirm, children: "Confirm" })
868
+ ] })
869
+ ] }) });
870
+ }
871
+
872
+ // src/CmrComponents/dialogue/EditConfirmation.tsx
873
+ import * as React9 from "react";
874
+ import TextField4 from "@mui/material/TextField";
875
+ import Dialog5 from "@mui/material/Dialog";
876
+ import DialogActions5 from "@mui/material/DialogActions";
877
+ import DialogContent5 from "@mui/material/DialogContent";
878
+ import DialogContentText4 from "@mui/material/DialogContentText";
879
+ import DialogTitle5 from "@mui/material/DialogTitle";
880
+ import { InputAdornment } from "@mui/material";
881
+ import { useEffect as useEffect2 } from "react";
882
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
883
+ function CmrEditConfirmation({
884
+ name,
885
+ message,
886
+ defaultText = "",
887
+ color,
888
+ open,
889
+ setOpen,
890
+ confirmCallback = () => {
891
+ },
892
+ cancellable = false,
893
+ cancelCallback = () => {
894
+ },
895
+ suffix = ""
896
+ }) {
897
+ const [text, setText] = React9.useState(defaultText);
898
+ useEffect2(() => {
899
+ if (open)
900
+ setText(defaultText);
901
+ }, [open]);
902
+ const handleClose = () => {
1102
903
  setOpen(false);
1103
904
  };
1104
- const selectionDialog = /* @__PURE__ */ jsxs12(Dialog6, { open, onClose: handleClose, children: [
1105
- /* @__PURE__ */ jsx19(DialogTitle6, { children: "Select or Upload" }),
1106
- /* @__PURE__ */ jsxs12(DialogContent6, { sx: { width: 520 }, children: [
1107
- /* @__PURE__ */ jsx19(DialogContentText5, { sx: { pl: 1, pr: 1, pb: 0 }, children: uploading ? "Please wait for the upload to finish." : "" }),
1108
- /* @__PURE__ */ jsx19(DialogContent6, { sx: { p: 1 }, children: /* @__PURE__ */ jsxs12(
1109
- Select2,
905
+ const handleConfirm = () => {
906
+ confirmCallback(text + suffix);
907
+ handleClose();
908
+ };
909
+ const handleCancel = () => {
910
+ cancelCallback(text + suffix);
911
+ handleClose();
912
+ };
913
+ return /* @__PURE__ */ jsxs10(Dialog5, { maxWidth: "xs", fullWidth: true, open, onClose: handleCancel, children: [
914
+ /* @__PURE__ */ jsx14(DialogTitle5, { children: name ? name : "Confirmation" }),
915
+ /* @__PURE__ */ jsxs10(DialogContent5, { children: [
916
+ /* @__PURE__ */ jsx14(DialogContentText4, { alignContent: "center", children: message }),
917
+ /* @__PURE__ */ jsx14(DialogActions5, { children: /* @__PURE__ */ jsx14(
918
+ TextField4,
1110
919
  {
1111
- value: fileIndex,
1112
- onChange: handleChange,
1113
- disabled: uploading,
1114
- inputProps: { "aria-label": "Without label" },
1115
- sx: { width: "100%" },
1116
- children: [
1117
- /* @__PURE__ */ jsx19(MenuItem3, { value: -1, children: props.fileSelection.length < 1 ? /* @__PURE__ */ jsx19("em", { children: "No Stored Files" }) : /* @__PURE__ */ jsx19("em", { children: "Select a Stored File" }) }),
1118
- (props.fileSelection != void 0 ? props.fileSelection : []).map((option, index) => /* @__PURE__ */ jsx19(MenuItem3, { value: index, children: option.fileName }, index))
1119
- ]
920
+ fullWidth: true,
921
+ variant: "standard",
922
+ InputProps: {
923
+ endAdornment: /* @__PURE__ */ jsx14(InputAdornment, { position: "end", sx: { whiteSpace: "nowrap" }, children: suffix })
924
+ },
925
+ defaultValue: text,
926
+ onChange: (e) => setText(e.target.value)
1120
927
  }
1121
928
  ) }),
1122
- /* @__PURE__ */ jsxs12(Box4, { sx: { pt: 2, justifyContent: "center", display: "flex", padding: "8px" }, children: [
1123
- /* @__PURE__ */ jsx19(Button4, { fullWidth: true, variant: "outlined", sx: { marginRight: "8px" }, onClick: handleClose, children: "Cancel" }),
1124
- fileIndex !== -1 && !uploading && /* @__PURE__ */ jsx19(Button4, { fullWidth: true, sx: { marginLeft: "8px" }, variant: "contained", onClick: onSet, children: "OK" }),
1125
- fileIndex == -1 && /* @__PURE__ */ jsx19(
1126
- Upload_default,
929
+ /* @__PURE__ */ jsxs10(DialogActions5, { children: [
930
+ cancellable && /* @__PURE__ */ jsx14(CmrButton_default, { variant: "outlined", color: "inherit", sx: { color: "#333" }, onClick: handleCancel, children: "Cancel" }),
931
+ /* @__PURE__ */ jsx14(CmrButton_default, { variant: "contained", color, onClick: handleConfirm, children: "Confirm" })
932
+ ] })
933
+ ] })
934
+ ] });
935
+ }
936
+
937
+ // src/CmrTabs/CmrTabs.tsx
938
+ import * as React10 from "react";
939
+ import Tabs from "@mui/material/Tabs";
940
+ import Tab from "@mui/material/Tab";
941
+ import Container from "@mui/material/Container";
942
+ import Typography3 from "@mui/material/Typography";
943
+ import Box3 from "@mui/material/Box";
944
+ import { cloneElement as cloneElement2 } from "react";
945
+ import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
946
+ function CustomTabPanel(props) {
947
+ const { children, value, index, ...other } = props;
948
+ return /* @__PURE__ */ jsx15(
949
+ "div",
950
+ {
951
+ role: "tabpanel",
952
+ hidden: value !== index,
953
+ id: `simple-tabpanel-${index}`,
954
+ "aria-labelledby": `simple-tab-${index}`,
955
+ ...other,
956
+ children: /* @__PURE__ */ jsx15(Box3, { sx: { p: 0 }, style: { display: value === index ? void 0 : "none" }, children: /* @__PURE__ */ jsx15(Typography3, { children }) })
957
+ }
958
+ );
959
+ }
960
+ function a11yProps(index) {
961
+ return {
962
+ id: `simple-tab-${index}`,
963
+ "aria-controls": `simple-tabpanel-${index}`
964
+ };
965
+ }
966
+ function CmrTabs(props) {
967
+ const [value, setValue] = React10.useState(0);
968
+ const handleChange = (event, newValue) => {
969
+ setValue(newValue);
970
+ if (props.onTabSelected)
971
+ props.onTabSelected(newValue);
972
+ };
973
+ return /* @__PURE__ */ jsxs11(
974
+ Container,
975
+ {
976
+ maxWidth: "lg",
977
+ sx: {
978
+ flex: 1,
979
+ display: "flex",
980
+ flexDirection: "column",
981
+ mt: 4
982
+ },
983
+ children: [
984
+ /* @__PURE__ */ jsx15(Box3, { sx: { borderBottom: 1, borderColor: "divider", mb: 4 }, children: /* @__PURE__ */ jsx15(
985
+ Tabs,
1127
986
  {
1128
- ...props,
1129
- color: "info",
1130
- fullWidth: true,
1131
- onUploaded: (res, file) => {
1132
- console.log("calling Setup level on uploaded");
1133
- console.log(props.onUploaded);
1134
- selectFileIndex(props.fileSelection.length);
1135
- props.onUploaded(res, file);
1136
- setOpen(false);
1137
- },
1138
- fileExtension: props.fileExtension,
1139
- uploadHandler: props.uploadHandler,
1140
- uploadStarted: () => {
1141
- setUploading(true);
1142
- props.onSelected(void 0);
1143
- },
1144
- uploadProgressed: (progress2) => {
1145
- setOpen(false);
1146
- setProgress(progress2);
987
+ value,
988
+ onChange: handleChange,
989
+ "aria-label": "basic tabs example",
990
+ textColor: "inherit",
991
+ TabIndicatorProps: {
992
+ style: {
993
+ backgroundColor: "#580F8B"
994
+ }
1147
995
  },
1148
- uploadEnded: () => setUploading(false)
996
+ children: props.tabList.map((tab, index) => /* @__PURE__ */ jsx15(Tab, { sx: { color: value == index ? "#580F8B" : void 0 }, style: { fontSize: "14px", textTransform: "uppercase", fontWeight: 400 }, label: tab.text, ...a11yProps(index) }))
1149
997
  }
998
+ ) }),
999
+ props.tabList.map(
1000
+ (tab, index) => /* @__PURE__ */ jsx15(CustomTabPanel, { value, index, children: cloneElement2(tab.children, {
1001
+ visible: value == index
1002
+ }) })
1150
1003
  )
1151
- ] })
1152
- ] })
1153
- ] });
1154
- return /* @__PURE__ */ jsxs12(Fragment, { children: [
1155
- uploading ? /* @__PURE__ */ jsxs12(Button4, { variant: "contained", style: { ...props.style, textTransform: "none" }, sx: { overflowWrap: "inherit" }, color: "primary", disabled: uploading, children: [
1156
- "Uploading ",
1157
- progress,
1158
- "%"
1159
- ] }) : /* @__PURE__ */ jsx19(
1160
- Button4,
1161
- {
1162
- variant: props.chosenFile == void 0 ? "contained" : "outlined",
1163
- color: "info",
1164
- onClick: handleClickOpen,
1165
- sx: { marginRight: "10pt" },
1166
- style: { ...props.style, textTransform: "none" },
1167
- children: props.chosenFile == void 0 ? props.buttonText ? props.buttonText : "Choose" : props.chosenFile
1168
- }
1169
- ),
1170
- selectionDialog
1171
- ] });
1004
+ ]
1005
+ }
1006
+ );
1007
+ }
1008
+
1009
+ // src/CmrComponents/checkbox/Checkbox.tsx
1010
+ import { Checkbox as Checkbox2 } from "@mui/material";
1011
+ import { FormControlLabel as FormControlLabel3 } from "@mui/material";
1012
+ import { jsx as jsx16 } from "react/jsx-runtime";
1013
+ var CmrCheckbox = (props) => {
1014
+ const { defaultChecked, onChange, children, ...rest } = props;
1015
+ return /* @__PURE__ */ jsx16(
1016
+ FormControlLabel3,
1017
+ {
1018
+ disabled: props.disabled,
1019
+ style: props.style,
1020
+ className: props.className,
1021
+ control: /* @__PURE__ */ jsx16(Checkbox2, { style: props.style, checked: props.checked, defaultChecked, onChange }),
1022
+ label: /* @__PURE__ */ jsx16(Label_default, { children: props.children }),
1023
+ sx: props.sx,
1024
+ labelPlacement: "end"
1025
+ }
1026
+ );
1172
1027
  };
1173
- var SelectUpload_default = CMRSelectUpload;
1028
+ var Checkbox_default = CmrCheckbox;
1029
+
1030
+ // src/CmrComponents/input-number/InputNumber.tsx
1031
+ import { InputNumber } from "antd";
1032
+ import { jsx as jsx17 } from "react/jsx-runtime";
1033
+ var CmrInputNumber = (props) => {
1034
+ const { defaultValue, style, max, min, value, onChange, children, ...rest } = props;
1035
+ return /* @__PURE__ */ jsx17(InputNumber, { defaultValue, max, style, min, value, onChange, ...rest, children });
1036
+ };
1037
+ var InputNumber_default = CmrInputNumber;
1174
1038
 
1175
1039
  // src/CmrTable/CmrTable.tsx
1176
1040
  import { DataGrid } from "@mui/x-data-grid";
1177
- import { jsx as jsx20 } from "react/jsx-runtime";
1041
+ import { jsx as jsx18 } from "react/jsx-runtime";
1178
1042
  var CmrTable = (props) => {
1179
1043
  const {
1180
1044
  dataSource,
@@ -1186,7 +1050,7 @@ var CmrTable = (props) => {
1186
1050
  showCheckbox = true,
1187
1051
  ...rest
1188
1052
  } = props;
1189
- return /* @__PURE__ */ jsx20("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx20(
1053
+ return /* @__PURE__ */ jsx18("div", { style: style ?? { height: "400px", width: "100%" }, className: className ?? "", children: /* @__PURE__ */ jsx18(
1190
1054
  DataGrid,
1191
1055
  {
1192
1056
  rows: dataSource ? dataSource.map((row) => ({
@@ -1211,7 +1075,6 @@ var CmrTable_default = CmrTable;
1211
1075
  // src/index.ts
1212
1076
  var CmrTable2 = CmrTable_default;
1213
1077
  export {
1214
- SelectUpload_default as CMRSelectUpload,
1215
1078
  Upload_default as CMRUpload,
1216
1079
  CmrButton_default as CmrButton,
1217
1080
  Checkbox_default as CmrCheckbox,
@@ -1227,7 +1090,5 @@ export {
1227
1090
  CmrRadioGroup_default as CmrRadioGroup,
1228
1091
  CmrSelect_default as CmrSelect,
1229
1092
  CmrTable2 as CmrTable,
1230
- CmrTabs,
1231
- Tooltip_default as CmrTooltip,
1232
- CmrUploadWindow
1093
+ CmrTabs
1233
1094
  };