@nethru/ui 1.0.32 → 1.0.33

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,15 +5,45 @@ export default function PropertyTable({
5
5
  columns,
6
6
  rows,
7
7
  onUpdate,
8
+ readOnly,
8
9
  sx,
9
10
  ...props
10
11
  }) {
11
- const [updatedRows, setUpdatedRows] = useState(rows);
12
- const columnsWithClassName = useMemo(() => {
12
+ const styles = useMemo(() => {
13
+ const result = {
14
+ '.MuiDataGrid-columnHeaders': {
15
+ backgroundColor: '#f8f9fa'
16
+ },
17
+ '.MuiDataGrid-columnSeparator': {
18
+ visibility: 'hidden !important'
19
+ },
20
+ '&.MuiDataGrid-root .MuiDataGrid-columnHeader:focus': {
21
+ outline: 'none !important'
22
+ },
23
+ '.MuiDataGrid-cell.fixed': {
24
+ fontWeight: 'bold'
25
+ },
26
+ '.MuiDataGrid-cell.dimmed': {
27
+ color: '#666'
28
+ },
29
+ '& .Mui-error': {
30
+ backgroundColor: 'rgb(126,10,15, 0.1)',
31
+ color: '#750f0f'
32
+ }
33
+ };
34
+ if (readOnly) {
35
+ result['&.MuiDataGrid-root .MuiDataGrid-cell:focus'] = {
36
+ outline: 'none !important'
37
+ };
38
+ }
39
+ return result;
40
+ }, [readOnly]);
41
+ const arrangedColumns = useMemo(() => {
13
42
  return columns.map(column => {
14
43
  const newColumn = {
15
44
  ...column
16
45
  };
46
+ if (readOnly) newColumn.editable = false;
17
47
  if (column.fixed) {
18
48
  newColumn.cellClassName = params => {
19
49
  return !params.row.deletable ? 'fixed' : '';
@@ -21,7 +51,8 @@ export default function PropertyTable({
21
51
  } else if (column.dimmed) newColumn.cellClassName = 'dimmed';
22
52
  return newColumn;
23
53
  });
24
- }, [columns]);
54
+ }, [columns, readOnly]);
55
+ const [updatedRows, setUpdatedRows] = useState(rows);
25
56
  const processRowUpdate = row => {
26
57
  const newRows = updatedRows.filter(r => r.id !== row.id);
27
58
  newRows.push(row);
@@ -30,7 +61,7 @@ export default function PropertyTable({
30
61
  return row;
31
62
  };
32
63
  return /*#__PURE__*/_jsx(DataGrid, {
33
- columns: columnsWithClassName,
64
+ columns: arrangedColumns,
34
65
  rows: rows,
35
66
  columnHeaderHeight: 35,
36
67
  rowHeight: 30,
@@ -40,6 +71,7 @@ export default function PropertyTable({
40
71
  processRowUpdate: processRowUpdate,
41
72
  onProcessRowUpdateError: error => console.log(error),
42
73
  disableColumnMenu: true,
74
+ disableRowSelectionOnClick: readOnly,
43
75
  hideFooter: true,
44
76
  sx: {
45
77
  ...styles,
@@ -47,22 +79,4 @@ export default function PropertyTable({
47
79
  },
48
80
  ...props
49
81
  });
50
- }
51
- const styles = {
52
- '.MuiDataGrid-columnHeaders': {
53
- backgroundColor: '#f8f9fa'
54
- },
55
- '.MuiDataGrid-columnSeparator': {
56
- visibility: 'hidden !important'
57
- },
58
- '.MuiDataGrid-cell.fixed': {
59
- fontWeight: 'bold'
60
- },
61
- '.MuiDataGrid-cell.dimmed': {
62
- color: '#666'
63
- },
64
- '& .Mui-error': {
65
- backgroundColor: 'rgb(126,10,15, 0.1)',
66
- color: '#750f0f'
67
- }
68
- };
82
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "1.0.32",
3
+ "version": "1.0.33",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "/dist"