@gridsuite/commons-ui 0.80.0 → 0.81.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.
@@ -5,6 +5,6 @@ export type MuiSelectInputProps = SelectProps & {
5
5
  options: {
6
6
  id: string;
7
7
  label: string;
8
- }[];
8
+ }[] | string[];
9
9
  };
10
10
  export declare function MuiSelectInput({ name, options, ...props }: MuiSelectInputProps): import("react/jsx-runtime").JSX.Element;
@@ -2,13 +2,19 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { FormattedMessage } from "react-intl";
3
3
  import { Select, MenuItem } from "@mui/material";
4
4
  import { useController } from "react-hook-form";
5
+ function renderMenuItem(option) {
6
+ const key = typeof option === "string" ? option : option.id;
7
+ const value = key;
8
+ const label = typeof option === "string" ? option : /* @__PURE__ */ jsx(FormattedMessage, { id: option.label });
9
+ return /* @__PURE__ */ jsx(MenuItem, { value, children: label }, key);
10
+ }
5
11
  function MuiSelectInput({ name, options, ...props }) {
6
12
  const {
7
13
  field: { value, onChange }
8
14
  } = useController({
9
15
  name
10
16
  });
11
- return /* @__PURE__ */ jsx(Select, { value, onChange, ...props, children: options.map((option) => /* @__PURE__ */ jsx(MenuItem, { value: option.id ?? option, children: /* @__PURE__ */ jsx(FormattedMessage, { id: option.label ?? option }) }, option.id ?? option.label)) });
17
+ return /* @__PURE__ */ jsx(Select, { value, onChange, ...props, children: options.map(renderMenuItem) });
12
18
  }
13
19
  export {
14
20
  MuiSelectInput
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.80.0",
3
+ "version": "0.81.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": ">=9",