@nethru/ui 1.0.41 → 1.0.43
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/PropertyTable.js +42 -5
- package/package.json +1 -1
package/dist/PropertyTable.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { useMemo, useState } from "react";
|
|
2
|
-
import
|
|
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
|
+
const PropertyTable = /*#__PURE__*/forwardRef(({
|
|
5
7
|
columns,
|
|
6
8
|
rows,
|
|
7
9
|
onUpdate,
|
|
8
10
|
readOnly,
|
|
9
11
|
sx,
|
|
10
12
|
...props
|
|
11
|
-
}) {
|
|
13
|
+
}, ref) => {
|
|
12
14
|
const styles = useMemo(() => {
|
|
13
15
|
const result = {
|
|
14
16
|
'&.MuiDataGrid-root': {
|
|
@@ -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]);
|
|
@@ -64,6 +72,7 @@ export default function PropertyTable({
|
|
|
64
72
|
return row;
|
|
65
73
|
};
|
|
66
74
|
return /*#__PURE__*/_jsx(DataGrid, {
|
|
75
|
+
ref: ref,
|
|
67
76
|
columns: arrangedColumns,
|
|
68
77
|
rows: rows,
|
|
69
78
|
columnHeaderHeight: 35,
|
|
@@ -82,4 +91,32 @@ export default function PropertyTable({
|
|
|
82
91
|
},
|
|
83
92
|
...props
|
|
84
93
|
});
|
|
85
|
-
}
|
|
94
|
+
});
|
|
95
|
+
const SingleSelect = /*#__PURE__*/forwardRef((props, ref) => {
|
|
96
|
+
const {
|
|
97
|
+
id,
|
|
98
|
+
value,
|
|
99
|
+
field,
|
|
100
|
+
options
|
|
101
|
+
} = props;
|
|
102
|
+
const apiRef = useGridApiContext();
|
|
103
|
+
const handleChange = (event, data) => {
|
|
104
|
+
apiRef.current.setEditCellValue({
|
|
105
|
+
id,
|
|
106
|
+
field,
|
|
107
|
+
value: data.props.value
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
return /*#__PURE__*/_jsx(Select, {
|
|
111
|
+
fontSize: 14,
|
|
112
|
+
ref: ref,
|
|
113
|
+
value: value,
|
|
114
|
+
onChange: handleChange,
|
|
115
|
+
fullWidth: true,
|
|
116
|
+
children: options.map(option => /*#__PURE__*/_jsx(MenuItem, {
|
|
117
|
+
value: option.value,
|
|
118
|
+
children: option.label
|
|
119
|
+
}, option.value))
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
export default PropertyTable;
|