@nethru/ui 1.0.41 → 1.0.42

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.
@@ -1,5 +1,7 @@
1
- import { useMemo, useState } from "react";
2
- import { DataGrid } from "@mui/x-data-grid";
1
+ import { forwardRef, useMemo, useState } from "react";
2
+ import MenuItem from "@mui/material/MenuItem";
3
+ import { DataGrid, useGridApiContext } from "@mui/x-data-grid";
4
+ import Select from "./Select";
3
5
  import { jsx as _jsx } from "react/jsx-runtime";
4
6
  export default function PropertyTable({
5
7
  columns,
@@ -52,6 +54,12 @@ export default function PropertyTable({
52
54
  return !params.row.deletable ? 'fixed' : '';
53
55
  };
54
56
  }
57
+ if (column.type === 'singleSelect' && column.valueOptions) {
58
+ newColumn.renderEditCell = params => /*#__PURE__*/_jsx(SingleSelect, {
59
+ options: column.valueOptions,
60
+ ...params
61
+ });
62
+ }
55
63
  return newColumn;
56
64
  });
57
65
  }, [columns, readOnly]);
@@ -82,4 +90,31 @@ export default function PropertyTable({
82
90
  },
83
91
  ...props
84
92
  });
85
- }
93
+ }
94
+ const SingleSelect = /*#__PURE__*/forwardRef((props, ref) => {
95
+ const {
96
+ id,
97
+ value,
98
+ field,
99
+ options
100
+ } = props;
101
+ const apiRef = useGridApiContext();
102
+ const handleChange = (event, data) => {
103
+ apiRef.current.setEditCellValue({
104
+ id,
105
+ field,
106
+ value: data.props.value
107
+ });
108
+ };
109
+ return /*#__PURE__*/_jsx(Select, {
110
+ fontSize: 14,
111
+ ref: ref,
112
+ value: value,
113
+ onChange: handleChange,
114
+ fullWidth: true,
115
+ children: options.map(option => /*#__PURE__*/_jsx(MenuItem, {
116
+ value: option.value,
117
+ children: option.label
118
+ }, option.value))
119
+ });
120
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "/dist"