@etsoo/materialui 1.3.25 → 1.3.27

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.
@@ -127,5 +127,5 @@ export function ComboBoxMultiple(props) {
127
127
  // Custom
128
128
  if (onChange != null)
129
129
  onChange(event, value, reason, details);
130
- }, openOnFocus: openOnFocus, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { ...addReadOnly(params), label: label, name: name + "Input", margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText, value: getValue(stateValue) })) : (React.createElement(InputField, { ...addReadOnly(params), label: label, name: name + "Input", margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText, value: getValue(stateValue) })), options: localOptions, renderOption: renderOption, noOptionsText: noOptionsText, loadingText: loadingText, ...rest })));
130
+ }, openOnFocus: openOnFocus, sx: sx, renderInput: (params) => search ? (React.createElement(SearchField, { ...addReadOnly(params), label: label, name: name + "Input", margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText })) : (React.createElement(InputField, { ...addReadOnly(params), label: label, name: name + "Input", margin: inputMargin, variant: inputVariant, required: inputRequired, error: inputError, helperText: inputHelperText })), options: localOptions, renderOption: renderOption, noOptionsText: noOptionsText, loadingText: loadingText, ...rest })));
131
131
  }
@@ -3,7 +3,7 @@ import { ButtonProps, MenuProps } from "@mui/material";
3
3
  import React from "react";
4
4
  export type MenuButtonProps<T extends DataTypes.IdItem> = Omit<MenuProps, "open"> & {
5
5
  items: T[];
6
- labelField: DataTypes.Keys<T, string>;
6
+ labelField: DataTypes.Keys<T, string> | ((data: T) => string);
7
7
  button: ((clickHandler: React.MouseEventHandler<HTMLButtonElement>) => React.ReactNode) | ButtonProps;
8
8
  };
9
9
  export declare function MenuButton<T extends DataTypes.IdItem>(props: MenuButtonProps<T>): React.JSX.Element;
package/lib/MenuButton.js CHANGED
@@ -25,6 +25,9 @@ export function MenuButton(props) {
25
25
  const handleMenuClose = () => {
26
26
  setAnchorEl(undefined);
27
27
  };
28
+ const labelFormatter = typeof labelField === "function"
29
+ ? labelField
30
+ : (item) => item[labelField];
28
31
  return (React.createElement(React.Fragment, null,
29
32
  typeof button === "function" ? (button(handleMenuOpen)) : (React.createElement(Button, { onClick: handleMenuOpen, ...button })),
30
33
  React.createElement(Menu, { slotProps: {
@@ -54,7 +57,7 @@ export function MenuButton(props) {
54
57
  }
55
58
  }
56
59
  }, disableScrollLock: true, anchorEl: anchorEl, anchorOrigin: anchorOrigin, keepMounted: true, transformOrigin: transformOrigin, open: isMenuOpen, transitionDuration: 0, onClose: handleMenuClose, ...rest }, items.map((item) => {
57
- const label = item[labelField];
60
+ const label = labelFormatter(item);
58
61
  return (React.createElement(MenuItem, { key: item.id, disabled: true }, label));
59
62
  }))));
60
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.3.25",
3
+ "version": "1.3.27",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -50,18 +50,18 @@
50
50
  "@emotion/css": "^11.11.2",
51
51
  "@emotion/react": "^11.11.1",
52
52
  "@emotion/styled": "^11.11.0",
53
- "@etsoo/appscript": "^1.4.56",
53
+ "@etsoo/appscript": "^1.4.57",
54
54
  "@etsoo/notificationbase": "^1.1.28",
55
- "@etsoo/react": "^1.7.16",
55
+ "@etsoo/react": "^1.7.17",
56
56
  "@etsoo/shared": "^1.2.15",
57
- "@mui/icons-material": "^5.14.12",
58
- "@mui/material": "^5.14.12",
59
- "@mui/x-data-grid": "^6.16.1",
57
+ "@mui/icons-material": "^5.14.13",
58
+ "@mui/material": "^5.14.13",
59
+ "@mui/x-data-grid": "^6.16.2",
60
60
  "@types/pica": "^9.0.2",
61
61
  "@types/pulltorefreshjs": "^0.1.5",
62
- "@types/react": "^18.2.27",
62
+ "@types/react": "^18.2.28",
63
63
  "@types/react-avatar-editor": "^13.0.0",
64
- "@types/react-dom": "^18.2.12",
64
+ "@types/react-dom": "^18.2.13",
65
65
  "@types/react-input-mask": "^3.0.3",
66
66
  "chart.js": "^4.4.0",
67
67
  "chartjs-plugin-datalabels": "^2.2.0",
@@ -76,13 +76,13 @@
76
76
  },
77
77
  "devDependencies": {
78
78
  "@babel/cli": "^7.23.0",
79
- "@babel/core": "^7.23.0",
80
- "@babel/plugin-transform-runtime": "^7.22.15",
81
- "@babel/preset-env": "^7.22.20",
79
+ "@babel/core": "^7.23.2",
80
+ "@babel/plugin-transform-runtime": "^7.23.2",
81
+ "@babel/preset-env": "^7.23.2",
82
82
  "@babel/preset-react": "^7.22.15",
83
- "@babel/preset-typescript": "^7.23.0",
84
- "@babel/runtime-corejs3": "^7.23.1",
85
- "@testing-library/jest-dom": "^6.1.3",
83
+ "@babel/preset-typescript": "^7.23.2",
84
+ "@babel/runtime-corejs3": "^7.23.2",
85
+ "@testing-library/jest-dom": "^6.1.4",
86
86
  "@testing-library/react": "^14.0.0",
87
87
  "@types/jest": "^29.5.5",
88
88
  "@typescript-eslint/eslint-plugin": "^6.7.5",
@@ -285,7 +285,6 @@ export function ComboBoxMultiple<
285
285
  required={inputRequired}
286
286
  error={inputError}
287
287
  helperText={inputHelperText}
288
- value={getValue(stateValue)}
289
288
  />
290
289
  ) : (
291
290
  <InputField
@@ -297,7 +296,6 @@ export function ComboBoxMultiple<
297
296
  required={inputRequired}
298
297
  error={inputError}
299
298
  helperText={inputHelperText}
300
- value={getValue(stateValue)}
301
299
  />
302
300
  )
303
301
  }
@@ -7,7 +7,7 @@ export type MenuButtonProps<T extends DataTypes.IdItem> = Omit<
7
7
  "open"
8
8
  > & {
9
9
  items: T[];
10
- labelField: DataTypes.Keys<T, string>;
10
+ labelField: DataTypes.Keys<T, string> | ((data: T) => string);
11
11
  button:
12
12
  | ((
13
13
  clickHandler: React.MouseEventHandler<HTMLButtonElement>
@@ -57,6 +57,11 @@ export function MenuButton<T extends DataTypes.IdItem>(
57
57
  setAnchorEl(undefined);
58
58
  };
59
59
 
60
+ const labelFormatter =
61
+ typeof labelField === "function"
62
+ ? labelField
63
+ : (item: T) => item[labelField] as string;
64
+
60
65
  return (
61
66
  <React.Fragment>
62
67
  {typeof button === "function" ? (
@@ -104,7 +109,7 @@ export function MenuButton<T extends DataTypes.IdItem>(
104
109
  {...rest}
105
110
  >
106
111
  {items.map((item) => {
107
- const label = item[labelField] as string;
112
+ const label = labelFormatter(item);
108
113
  return (
109
114
  <MenuItem key={item.id} disabled>
110
115
  {label}