cloudmr-ux 1.6.8 → 1.7.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.d.ts +1 -1
- package/dist/index.js +37 -19
- package/dist/index.mjs +38 -20
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -274,7 +274,7 @@ interface UploadWindowProps {
|
|
|
274
274
|
upload: (file: File, fileAlias: string, fileDatabase: string) => Promise<number>;
|
|
275
275
|
open: boolean;
|
|
276
276
|
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
277
|
-
fileExtension?: string;
|
|
277
|
+
fileExtension?: string | string[];
|
|
278
278
|
template?: {
|
|
279
279
|
showFileName?: boolean;
|
|
280
280
|
showDatabase?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -317,6 +317,16 @@ function CmrUploadWindow({
|
|
|
317
317
|
const handleClose = () => {
|
|
318
318
|
setOpen(false);
|
|
319
319
|
};
|
|
320
|
+
const checkExtension = (filename, allowed) => {
|
|
321
|
+
if (!filename)
|
|
322
|
+
return false;
|
|
323
|
+
const name = filename.toLowerCase();
|
|
324
|
+
if (Array.isArray(allowed)) {
|
|
325
|
+
return allowed.some((ext) => name.endsWith(ext.startsWith(".") ? ext : "." + ext));
|
|
326
|
+
} else {
|
|
327
|
+
return name.endsWith(allowed.startsWith(".") ? allowed : "." + allowed);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
320
330
|
const getExtension = (fileName) => {
|
|
321
331
|
if (fileName == void 0)
|
|
322
332
|
return;
|
|
@@ -464,8 +474,10 @@ function CmrUploadWindow({
|
|
|
464
474
|
let draggedFiles = e.dataTransfer.files;
|
|
465
475
|
if (draggedFiles.length > 1) {
|
|
466
476
|
setUploadBoxWarning("Only one file can be uploaded at a time");
|
|
467
|
-
} else if (fileExtension != void 0 && draggedFiles.length
|
|
468
|
-
setUploadBoxWarning(
|
|
477
|
+
} else if (fileExtension != void 0 && draggedFiles.length !== 0 && !checkExtension(draggedFiles[0].name, fileExtension)) {
|
|
478
|
+
setUploadBoxWarning(
|
|
479
|
+
`Only accepting files with extension(s): ${Array.isArray(fileExtension) ? fileExtension.join(", ") : fileExtension}`
|
|
480
|
+
);
|
|
469
481
|
}
|
|
470
482
|
}
|
|
471
483
|
e.dataTransfer.dropEffect = "copy";
|
|
@@ -481,10 +493,12 @@ function CmrUploadWindow({
|
|
|
481
493
|
setWarningText("Only one file can be uploaded at a time");
|
|
482
494
|
setTimeout(() => setInfoOpen(false), 2500);
|
|
483
495
|
return;
|
|
484
|
-
} else if (fileExtension
|
|
496
|
+
} else if (fileExtension !== void 0 && !checkExtension(files[0].name, fileExtension)) {
|
|
485
497
|
setInfoOpen(true);
|
|
486
498
|
setInfoStyle("warning");
|
|
487
|
-
setWarningText(
|
|
499
|
+
setWarningText(
|
|
500
|
+
`Only accepting files with extension(s): ${Array.isArray(fileExtension) ? fileExtension.join(", ") : fileExtension}`
|
|
501
|
+
);
|
|
488
502
|
setTimeout(() => setInfoOpen(false), 2500);
|
|
489
503
|
return;
|
|
490
504
|
}
|
|
@@ -551,7 +565,7 @@ function CmrUploadWindow({
|
|
|
551
565
|
type: "file",
|
|
552
566
|
id: "file-window",
|
|
553
567
|
multiple: true,
|
|
554
|
-
accept: fileExtension
|
|
568
|
+
accept: fileExtension === void 0 ? "*" : Array.isArray(fileExtension) ? fileExtension.join(",") : fileExtension,
|
|
555
569
|
style: { display: "none" },
|
|
556
570
|
onChange: loadSelectedFiles
|
|
557
571
|
}
|
|
@@ -1096,12 +1110,13 @@ var InputNumber_default = CmrInputNumber;
|
|
|
1096
1110
|
// src/CmrComponents/select-upload/SelectUpload.tsx
|
|
1097
1111
|
var import_react8 = __toESM(require("react"));
|
|
1098
1112
|
var import_material12 = require("@mui/material");
|
|
1099
|
-
var import_Select = __toESM(require("@mui/material/Select"));
|
|
1100
1113
|
var import_Dialog6 = __toESM(require("@mui/material/Dialog"));
|
|
1101
1114
|
var import_DialogTitle6 = __toESM(require("@mui/material/DialogTitle"));
|
|
1102
1115
|
var import_DialogContent6 = __toESM(require("@mui/material/DialogContent"));
|
|
1103
1116
|
var import_DialogContentText5 = __toESM(require("@mui/material/DialogContentText"));
|
|
1104
1117
|
var import_Box3 = __toESM(require("@mui/material/Box"));
|
|
1118
|
+
var import_Autocomplete = __toESM(require("@mui/material/Autocomplete"));
|
|
1119
|
+
var import_TextField5 = __toESM(require("@mui/material/TextField"));
|
|
1105
1120
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1106
1121
|
var CMRSelectUpload = (props) => {
|
|
1107
1122
|
let [open, setOpen] = import_react8.default.useState(false);
|
|
@@ -1115,9 +1130,6 @@ var CMRSelectUpload = (props) => {
|
|
|
1115
1130
|
const handleClose = () => {
|
|
1116
1131
|
setOpen(false);
|
|
1117
1132
|
};
|
|
1118
|
-
const handleChange = (event) => {
|
|
1119
|
-
selectFileIndex(event.target.value);
|
|
1120
|
-
};
|
|
1121
1133
|
const onSet = () => {
|
|
1122
1134
|
props.onSelected(props.fileSelection[fileIndex]);
|
|
1123
1135
|
setOpen(false);
|
|
@@ -1126,18 +1138,24 @@ var CMRSelectUpload = (props) => {
|
|
|
1126
1138
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_DialogTitle6.default, { children: "Select or Upload" }),
|
|
1127
1139
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_DialogContent6.default, { sx: { width: 520 }, children: [
|
|
1128
1140
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_DialogContentText5.default, { sx: { pl: 1, pr: 1, pb: 0 }, children: uploading ? "Please wait for the upload to finish." : "" }),
|
|
1129
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_DialogContent6.default, { sx: { p: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.
|
|
1130
|
-
|
|
1141
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_DialogContent6.default, { sx: { p: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1142
|
+
import_Autocomplete.default,
|
|
1131
1143
|
{
|
|
1132
|
-
value: fileIndex,
|
|
1133
|
-
onChange: handleChange,
|
|
1134
1144
|
disabled: uploading,
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1145
|
+
options: props.fileSelection,
|
|
1146
|
+
getOptionLabel: (option) => option.fileName,
|
|
1147
|
+
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
1148
|
+
value: fileIndex === -1 ? null : props.fileSelection[fileIndex],
|
|
1149
|
+
onChange: (event, newValue) => {
|
|
1150
|
+
if (newValue) {
|
|
1151
|
+
const index = props.fileSelection.findIndex((file) => file.id === newValue.id);
|
|
1152
|
+
selectFileIndex(index);
|
|
1153
|
+
} else {
|
|
1154
|
+
selectFileIndex(-1);
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_TextField5.default, { ...params, label: "Select a Stored File" }),
|
|
1158
|
+
sx: { width: "100%" }
|
|
1141
1159
|
}
|
|
1142
1160
|
) }),
|
|
1143
1161
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_Box3.default, { sx: { pt: 2, justifyContent: "center", display: "flex", padding: "8px" }, children: [
|
package/dist/index.mjs
CHANGED
|
@@ -269,6 +269,16 @@ function CmrUploadWindow({
|
|
|
269
269
|
const handleClose = () => {
|
|
270
270
|
setOpen(false);
|
|
271
271
|
};
|
|
272
|
+
const checkExtension = (filename, allowed) => {
|
|
273
|
+
if (!filename)
|
|
274
|
+
return false;
|
|
275
|
+
const name = filename.toLowerCase();
|
|
276
|
+
if (Array.isArray(allowed)) {
|
|
277
|
+
return allowed.some((ext) => name.endsWith(ext.startsWith(".") ? ext : "." + ext));
|
|
278
|
+
} else {
|
|
279
|
+
return name.endsWith(allowed.startsWith(".") ? allowed : "." + allowed);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
272
282
|
const getExtension = (fileName) => {
|
|
273
283
|
if (fileName == void 0)
|
|
274
284
|
return;
|
|
@@ -416,8 +426,10 @@ function CmrUploadWindow({
|
|
|
416
426
|
let draggedFiles = e.dataTransfer.files;
|
|
417
427
|
if (draggedFiles.length > 1) {
|
|
418
428
|
setUploadBoxWarning("Only one file can be uploaded at a time");
|
|
419
|
-
} else if (fileExtension != void 0 && draggedFiles.length
|
|
420
|
-
setUploadBoxWarning(
|
|
429
|
+
} else if (fileExtension != void 0 && draggedFiles.length !== 0 && !checkExtension(draggedFiles[0].name, fileExtension)) {
|
|
430
|
+
setUploadBoxWarning(
|
|
431
|
+
`Only accepting files with extension(s): ${Array.isArray(fileExtension) ? fileExtension.join(", ") : fileExtension}`
|
|
432
|
+
);
|
|
421
433
|
}
|
|
422
434
|
}
|
|
423
435
|
e.dataTransfer.dropEffect = "copy";
|
|
@@ -433,10 +445,12 @@ function CmrUploadWindow({
|
|
|
433
445
|
setWarningText("Only one file can be uploaded at a time");
|
|
434
446
|
setTimeout(() => setInfoOpen(false), 2500);
|
|
435
447
|
return;
|
|
436
|
-
} else if (fileExtension
|
|
448
|
+
} else if (fileExtension !== void 0 && !checkExtension(files[0].name, fileExtension)) {
|
|
437
449
|
setInfoOpen(true);
|
|
438
450
|
setInfoStyle("warning");
|
|
439
|
-
setWarningText(
|
|
451
|
+
setWarningText(
|
|
452
|
+
`Only accepting files with extension(s): ${Array.isArray(fileExtension) ? fileExtension.join(", ") : fileExtension}`
|
|
453
|
+
);
|
|
440
454
|
setTimeout(() => setInfoOpen(false), 2500);
|
|
441
455
|
return;
|
|
442
456
|
}
|
|
@@ -503,7 +517,7 @@ function CmrUploadWindow({
|
|
|
503
517
|
type: "file",
|
|
504
518
|
id: "file-window",
|
|
505
519
|
multiple: true,
|
|
506
|
-
accept: fileExtension
|
|
520
|
+
accept: fileExtension === void 0 ? "*" : Array.isArray(fileExtension) ? fileExtension.join(",") : fileExtension,
|
|
507
521
|
style: { display: "none" },
|
|
508
522
|
onChange: loadSelectedFiles
|
|
509
523
|
}
|
|
@@ -1047,13 +1061,14 @@ var InputNumber_default = CmrInputNumber;
|
|
|
1047
1061
|
|
|
1048
1062
|
// src/CmrComponents/select-upload/SelectUpload.tsx
|
|
1049
1063
|
import React11, { Fragment } from "react";
|
|
1050
|
-
import { Button as Button4
|
|
1051
|
-
import Select2 from "@mui/material/Select";
|
|
1064
|
+
import { Button as Button4 } from "@mui/material";
|
|
1052
1065
|
import Dialog6 from "@mui/material/Dialog";
|
|
1053
1066
|
import DialogTitle6 from "@mui/material/DialogTitle";
|
|
1054
1067
|
import DialogContent6 from "@mui/material/DialogContent";
|
|
1055
1068
|
import DialogContentText5 from "@mui/material/DialogContentText";
|
|
1056
1069
|
import Box4 from "@mui/material/Box";
|
|
1070
|
+
import Autocomplete from "@mui/material/Autocomplete";
|
|
1071
|
+
import TextField5 from "@mui/material/TextField";
|
|
1057
1072
|
import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1058
1073
|
var CMRSelectUpload = (props) => {
|
|
1059
1074
|
let [open, setOpen] = React11.useState(false);
|
|
@@ -1067,9 +1082,6 @@ var CMRSelectUpload = (props) => {
|
|
|
1067
1082
|
const handleClose = () => {
|
|
1068
1083
|
setOpen(false);
|
|
1069
1084
|
};
|
|
1070
|
-
const handleChange = (event) => {
|
|
1071
|
-
selectFileIndex(event.target.value);
|
|
1072
|
-
};
|
|
1073
1085
|
const onSet = () => {
|
|
1074
1086
|
props.onSelected(props.fileSelection[fileIndex]);
|
|
1075
1087
|
setOpen(false);
|
|
@@ -1078,18 +1090,24 @@ var CMRSelectUpload = (props) => {
|
|
|
1078
1090
|
/* @__PURE__ */ jsx18(DialogTitle6, { children: "Select or Upload" }),
|
|
1079
1091
|
/* @__PURE__ */ jsxs12(DialogContent6, { sx: { width: 520 }, children: [
|
|
1080
1092
|
/* @__PURE__ */ jsx18(DialogContentText5, { sx: { pl: 1, pr: 1, pb: 0 }, children: uploading ? "Please wait for the upload to finish." : "" }),
|
|
1081
|
-
/* @__PURE__ */ jsx18(DialogContent6, { sx: { p: 1 }, children: /* @__PURE__ */
|
|
1082
|
-
|
|
1093
|
+
/* @__PURE__ */ jsx18(DialogContent6, { sx: { p: 1 }, children: /* @__PURE__ */ jsx18(
|
|
1094
|
+
Autocomplete,
|
|
1083
1095
|
{
|
|
1084
|
-
value: fileIndex,
|
|
1085
|
-
onChange: handleChange,
|
|
1086
1096
|
disabled: uploading,
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1097
|
+
options: props.fileSelection,
|
|
1098
|
+
getOptionLabel: (option) => option.fileName,
|
|
1099
|
+
isOptionEqualToValue: (option, value) => option.id === value.id,
|
|
1100
|
+
value: fileIndex === -1 ? null : props.fileSelection[fileIndex],
|
|
1101
|
+
onChange: (event, newValue) => {
|
|
1102
|
+
if (newValue) {
|
|
1103
|
+
const index = props.fileSelection.findIndex((file) => file.id === newValue.id);
|
|
1104
|
+
selectFileIndex(index);
|
|
1105
|
+
} else {
|
|
1106
|
+
selectFileIndex(-1);
|
|
1107
|
+
}
|
|
1108
|
+
},
|
|
1109
|
+
renderInput: (params) => /* @__PURE__ */ jsx18(TextField5, { ...params, label: "Select a Stored File" }),
|
|
1110
|
+
sx: { width: "100%" }
|
|
1093
1111
|
}
|
|
1094
1112
|
) }),
|
|
1095
1113
|
/* @__PURE__ */ jsxs12(Box4, { sx: { pt: 2, justifyContent: "center", display: "flex", padding: "8px" }, children: [
|