cloudmr-ux 1.8.9 → 1.9.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.js CHANGED
@@ -317,7 +317,7 @@ function CmrUploadWindow({
317
317
  const handleClose = () => {
318
318
  setOpen(false);
319
319
  };
320
- const checkExtension = (filename, allowed) => {
320
+ const checkExtension2 = (filename, allowed) => {
321
321
  if (!filename)
322
322
  return false;
323
323
  const name = filename.toLowerCase();
@@ -474,7 +474,7 @@ function CmrUploadWindow({
474
474
  let draggedFiles = e.dataTransfer.files;
475
475
  if (draggedFiles.length > 1) {
476
476
  setUploadBoxWarning("Only one file can be uploaded at a time");
477
- } else if (fileExtension != void 0 && draggedFiles.length !== 0 && !checkExtension(draggedFiles[0].name, fileExtension)) {
477
+ } else if (fileExtension != void 0 && draggedFiles.length !== 0 && !checkExtension2(draggedFiles[0].name, fileExtension)) {
478
478
  setUploadBoxWarning(
479
479
  `Only accepting files with extension(s): ${Array.isArray(fileExtension) ? fileExtension.join(", ") : fileExtension}`
480
480
  );
@@ -495,7 +495,7 @@ function CmrUploadWindow({
495
495
  setWarningText("Only one file can be uploaded at a time");
496
496
  setTimeout(() => setInfoOpen(false), 2500);
497
497
  return;
498
- } else if (fileExtension !== void 0 && !checkExtension(files[0].name, fileExtension)) {
498
+ } else if (fileExtension !== void 0 && !checkExtension2(files[0].name, fileExtension)) {
499
499
  setInfoOpen(true);
500
500
  setInfoStyle("warning");
501
501
  setWarningText(
@@ -1119,6 +1119,16 @@ var import_DialogContent6 = __toESM(require("@mui/material/DialogContent"));
1119
1119
  var import_DialogContentText5 = __toESM(require("@mui/material/DialogContentText"));
1120
1120
  var import_Box3 = __toESM(require("@mui/material/Box"));
1121
1121
  var import_jsx_runtime18 = require("react/jsx-runtime");
1122
+ function checkExtension(filename, allowed) {
1123
+ if (!filename || !allowed)
1124
+ return true;
1125
+ const name = filename.toLowerCase();
1126
+ if (Array.isArray(allowed)) {
1127
+ return allowed.some((ext) => name.endsWith(ext.startsWith(".") ? ext : "." + ext));
1128
+ } else {
1129
+ return name.endsWith(allowed.startsWith(".") ? allowed : "." + allowed);
1130
+ }
1131
+ }
1122
1132
  var CMRSelectUpload = (props) => {
1123
1133
  let [open, setOpen] = import_react8.default.useState(false);
1124
1134
  let [fileIndex, selectFileIndex] = import_react8.default.useState(-1);
@@ -1144,7 +1154,7 @@ var CMRSelectUpload = (props) => {
1144
1154
  {
1145
1155
  classNamePrefix: "cmr-select",
1146
1156
  isDisabled: uploading,
1147
- options: props.fileSelection.map((file) => ({
1157
+ options: props.fileSelection.filter((file) => checkExtension(file.fileName, props.fileExtension)).map((file) => ({
1148
1158
  value: file.id,
1149
1159
  label: file.fileName
1150
1160
  })),
package/dist/index.mjs CHANGED
@@ -269,7 +269,7 @@ function CmrUploadWindow({
269
269
  const handleClose = () => {
270
270
  setOpen(false);
271
271
  };
272
- const checkExtension = (filename, allowed) => {
272
+ const checkExtension2 = (filename, allowed) => {
273
273
  if (!filename)
274
274
  return false;
275
275
  const name = filename.toLowerCase();
@@ -426,7 +426,7 @@ function CmrUploadWindow({
426
426
  let draggedFiles = e.dataTransfer.files;
427
427
  if (draggedFiles.length > 1) {
428
428
  setUploadBoxWarning("Only one file can be uploaded at a time");
429
- } else if (fileExtension != void 0 && draggedFiles.length !== 0 && !checkExtension(draggedFiles[0].name, fileExtension)) {
429
+ } else if (fileExtension != void 0 && draggedFiles.length !== 0 && !checkExtension2(draggedFiles[0].name, fileExtension)) {
430
430
  setUploadBoxWarning(
431
431
  `Only accepting files with extension(s): ${Array.isArray(fileExtension) ? fileExtension.join(", ") : fileExtension}`
432
432
  );
@@ -447,7 +447,7 @@ function CmrUploadWindow({
447
447
  setWarningText("Only one file can be uploaded at a time");
448
448
  setTimeout(() => setInfoOpen(false), 2500);
449
449
  return;
450
- } else if (fileExtension !== void 0 && !checkExtension(files[0].name, fileExtension)) {
450
+ } else if (fileExtension !== void 0 && !checkExtension2(files[0].name, fileExtension)) {
451
451
  setInfoOpen(true);
452
452
  setInfoStyle("warning");
453
453
  setWarningText(
@@ -1071,6 +1071,16 @@ import DialogContent6 from "@mui/material/DialogContent";
1071
1071
  import DialogContentText5 from "@mui/material/DialogContentText";
1072
1072
  import Box4 from "@mui/material/Box";
1073
1073
  import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
1074
+ function checkExtension(filename, allowed) {
1075
+ if (!filename || !allowed)
1076
+ return true;
1077
+ const name = filename.toLowerCase();
1078
+ if (Array.isArray(allowed)) {
1079
+ return allowed.some((ext) => name.endsWith(ext.startsWith(".") ? ext : "." + ext));
1080
+ } else {
1081
+ return name.endsWith(allowed.startsWith(".") ? allowed : "." + allowed);
1082
+ }
1083
+ }
1074
1084
  var CMRSelectUpload = (props) => {
1075
1085
  let [open, setOpen] = React11.useState(false);
1076
1086
  let [fileIndex, selectFileIndex] = React11.useState(-1);
@@ -1096,7 +1106,7 @@ var CMRSelectUpload = (props) => {
1096
1106
  {
1097
1107
  classNamePrefix: "cmr-select",
1098
1108
  isDisabled: uploading,
1099
- options: props.fileSelection.map((file) => ({
1109
+ options: props.fileSelection.filter((file) => checkExtension(file.fileName, props.fileExtension)).map((file) => ({
1100
1110
  value: file.id,
1101
1111
  label: file.fileName
1102
1112
  })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "1.8.9",
3
+ "version": "1.9.0",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",