cloudmr-ux 1.6.9 → 1.7.1

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
@@ -1110,12 +1110,14 @@ var InputNumber_default = CmrInputNumber;
1110
1110
  // src/CmrComponents/select-upload/SelectUpload.tsx
1111
1111
  var import_react8 = __toESM(require("react"));
1112
1112
  var import_material12 = require("@mui/material");
1113
- var import_Select = __toESM(require("@mui/material/Select"));
1114
1113
  var import_Dialog6 = __toESM(require("@mui/material/Dialog"));
1115
1114
  var import_DialogTitle6 = __toESM(require("@mui/material/DialogTitle"));
1116
1115
  var import_DialogContent6 = __toESM(require("@mui/material/DialogContent"));
1117
1116
  var import_DialogContentText5 = __toESM(require("@mui/material/DialogContentText"));
1118
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"));
1120
+ var import_Autocomplete2 = require("@mui/material/Autocomplete");
1119
1121
  var import_jsx_runtime18 = require("react/jsx-runtime");
1120
1122
  var CMRSelectUpload = (props) => {
1121
1123
  let [open, setOpen] = import_react8.default.useState(false);
@@ -1129,29 +1131,43 @@ var CMRSelectUpload = (props) => {
1129
1131
  const handleClose = () => {
1130
1132
  setOpen(false);
1131
1133
  };
1132
- const handleChange = (event) => {
1133
- selectFileIndex(event.target.value);
1134
- };
1135
1134
  const onSet = () => {
1136
1135
  props.onSelected(props.fileSelection[fileIndex]);
1137
1136
  setOpen(false);
1138
1137
  };
1138
+ const sortedFiles = [...props.fileSelection].sort(
1139
+ (a, b) => a.fileName.localeCompare(b.fileName)
1140
+ );
1141
+ const stringMatchFilter = (0, import_Autocomplete2.createFilterOptions)({
1142
+ stringify: (option) => option.fileName || "",
1143
+ trim: true,
1144
+ ignoreCase: true
1145
+ });
1139
1146
  const selectionDialog = /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_Dialog6.default, { open, onClose: handleClose, children: [
1140
1147
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_DialogTitle6.default, { children: "Select or Upload" }),
1141
1148
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_DialogContent6.default, { sx: { width: 520 }, children: [
1142
1149
  /* @__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." : "" }),
1143
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_DialogContent6.default, { sx: { p: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1144
- import_Select.default,
1150
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_DialogContent6.default, { sx: { p: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1151
+ import_Autocomplete.default,
1145
1152
  {
1146
- value: fileIndex,
1147
- onChange: handleChange,
1148
1153
  disabled: uploading,
1149
- inputProps: { "aria-label": "Without label" },
1150
- sx: { width: "100%" },
1151
- children: [
1152
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material12.MenuItem, { value: -1, children: props.fileSelection.length < 1 ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("em", { children: "No Stored Files" }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("em", { children: "Select a Stored File" }) }),
1153
- (props.fileSelection != void 0 ? props.fileSelection : []).map((option, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material12.MenuItem, { value: index, children: option.fileName }, index))
1154
- ]
1154
+ options: sortedFiles,
1155
+ filterOptions: (options, state) => stringMatchFilter(options, state).sort(
1156
+ (a, b) => a.fileName.localeCompare(b.fileName)
1157
+ ),
1158
+ getOptionLabel: (option) => option.fileName,
1159
+ isOptionEqualToValue: (option, value) => option.id === value.id,
1160
+ value: fileIndex === -1 ? null : props.fileSelection[fileIndex],
1161
+ onChange: (event, newValue) => {
1162
+ if (newValue) {
1163
+ const index = props.fileSelection.findIndex((file) => file.id === newValue.id);
1164
+ selectFileIndex(index);
1165
+ } else {
1166
+ selectFileIndex(-1);
1167
+ }
1168
+ },
1169
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_TextField5.default, { ...params, label: "Select a Stored File" }),
1170
+ sx: { width: "100%" }
1155
1171
  }
1156
1172
  ) }),
1157
1173
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_Box3.default, { sx: { pt: 2, justifyContent: "center", display: "flex", padding: "8px" }, children: [
package/dist/index.mjs CHANGED
@@ -1061,13 +1061,15 @@ var InputNumber_default = CmrInputNumber;
1061
1061
 
1062
1062
  // src/CmrComponents/select-upload/SelectUpload.tsx
1063
1063
  import React11, { Fragment } from "react";
1064
- import { Button as Button4, MenuItem as MenuItem3 } from "@mui/material";
1065
- import Select2 from "@mui/material/Select";
1064
+ import { Button as Button4 } from "@mui/material";
1066
1065
  import Dialog6 from "@mui/material/Dialog";
1067
1066
  import DialogTitle6 from "@mui/material/DialogTitle";
1068
1067
  import DialogContent6 from "@mui/material/DialogContent";
1069
1068
  import DialogContentText5 from "@mui/material/DialogContentText";
1070
1069
  import Box4 from "@mui/material/Box";
1070
+ import Autocomplete from "@mui/material/Autocomplete";
1071
+ import TextField5 from "@mui/material/TextField";
1072
+ import { createFilterOptions } from "@mui/material/Autocomplete";
1071
1073
  import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
1072
1074
  var CMRSelectUpload = (props) => {
1073
1075
  let [open, setOpen] = React11.useState(false);
@@ -1081,29 +1083,43 @@ var CMRSelectUpload = (props) => {
1081
1083
  const handleClose = () => {
1082
1084
  setOpen(false);
1083
1085
  };
1084
- const handleChange = (event) => {
1085
- selectFileIndex(event.target.value);
1086
- };
1087
1086
  const onSet = () => {
1088
1087
  props.onSelected(props.fileSelection[fileIndex]);
1089
1088
  setOpen(false);
1090
1089
  };
1090
+ const sortedFiles = [...props.fileSelection].sort(
1091
+ (a, b) => a.fileName.localeCompare(b.fileName)
1092
+ );
1093
+ const stringMatchFilter = createFilterOptions({
1094
+ stringify: (option) => option.fileName || "",
1095
+ trim: true,
1096
+ ignoreCase: true
1097
+ });
1091
1098
  const selectionDialog = /* @__PURE__ */ jsxs12(Dialog6, { open, onClose: handleClose, children: [
1092
1099
  /* @__PURE__ */ jsx18(DialogTitle6, { children: "Select or Upload" }),
1093
1100
  /* @__PURE__ */ jsxs12(DialogContent6, { sx: { width: 520 }, children: [
1094
1101
  /* @__PURE__ */ jsx18(DialogContentText5, { sx: { pl: 1, pr: 1, pb: 0 }, children: uploading ? "Please wait for the upload to finish." : "" }),
1095
- /* @__PURE__ */ jsx18(DialogContent6, { sx: { p: 1 }, children: /* @__PURE__ */ jsxs12(
1096
- Select2,
1102
+ /* @__PURE__ */ jsx18(DialogContent6, { sx: { p: 1 }, children: /* @__PURE__ */ jsx18(
1103
+ Autocomplete,
1097
1104
  {
1098
- value: fileIndex,
1099
- onChange: handleChange,
1100
1105
  disabled: uploading,
1101
- inputProps: { "aria-label": "Without label" },
1102
- sx: { width: "100%" },
1103
- children: [
1104
- /* @__PURE__ */ jsx18(MenuItem3, { value: -1, children: props.fileSelection.length < 1 ? /* @__PURE__ */ jsx18("em", { children: "No Stored Files" }) : /* @__PURE__ */ jsx18("em", { children: "Select a Stored File" }) }),
1105
- (props.fileSelection != void 0 ? props.fileSelection : []).map((option, index) => /* @__PURE__ */ jsx18(MenuItem3, { value: index, children: option.fileName }, index))
1106
- ]
1106
+ options: sortedFiles,
1107
+ filterOptions: (options, state) => stringMatchFilter(options, state).sort(
1108
+ (a, b) => a.fileName.localeCompare(b.fileName)
1109
+ ),
1110
+ getOptionLabel: (option) => option.fileName,
1111
+ isOptionEqualToValue: (option, value) => option.id === value.id,
1112
+ value: fileIndex === -1 ? null : props.fileSelection[fileIndex],
1113
+ onChange: (event, newValue) => {
1114
+ if (newValue) {
1115
+ const index = props.fileSelection.findIndex((file) => file.id === newValue.id);
1116
+ selectFileIndex(index);
1117
+ } else {
1118
+ selectFileIndex(-1);
1119
+ }
1120
+ },
1121
+ renderInput: (params) => /* @__PURE__ */ jsx18(TextField5, { ...params, label: "Select a Stored File" }),
1122
+ sx: { width: "100%" }
1107
1123
  }
1108
1124
  ) }),
1109
1125
  /* @__PURE__ */ jsxs12(Box4, { sx: { pt: 2, justifyContent: "center", display: "flex", padding: "8px" }, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudmr-ux",
3
- "version": "1.6.9",
3
+ "version": "1.7.1",
4
4
  "author": "erosmontin@gmail.com",
5
5
  "license": "MIT",
6
6
  "repository": "erosmontin/cloudmr-ux",