@nethru/ui 1.0.29 → 1.0.31

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.
@@ -0,0 +1,62 @@
1
+ import { List, Stack } from "@mui/material";
2
+ import ListItem from "./ListItem";
3
+ import ListItemGrid from "./ListItemGrid";
4
+ import { useMemo } from "react";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ export default function ColumnedSection({
8
+ columns,
9
+ labels = [],
10
+ contents = [],
11
+ sx
12
+ }) {
13
+ const width = useMemo(() => {
14
+ return `${100 / columns}%`;
15
+ }, [columns]);
16
+ const styles = useMemo(() => {
17
+ return {
18
+ width: width,
19
+ bgcolor: '#f8f9fa',
20
+ p: '10px 20px',
21
+ borderRadius: '7px'
22
+ };
23
+ }, [width]);
24
+ return /*#__PURE__*/_jsx(List, {
25
+ children: /*#__PURE__*/_jsxs(ListItem, {
26
+ grid: true,
27
+ children: [labels.length > 0 && /*#__PURE__*/_jsx(ListItemGrid, {
28
+ xs: 12,
29
+ children: /*#__PURE__*/_jsx(Stack, {
30
+ direction: "row",
31
+ gap: 1,
32
+ children: labels.map((label, index) => /*#__PURE__*/_jsx(Stack, {
33
+ spacing: 1,
34
+ sx: {
35
+ width: width
36
+ },
37
+ children: /*#__PURE__*/_jsx(Stack, {
38
+ direction: "row",
39
+ alignItems: "baseline",
40
+ spacing: 1,
41
+ children: label
42
+ })
43
+ }, index))
44
+ })
45
+ }), /*#__PURE__*/_jsx(ListItemGrid, {
46
+ xs: 12,
47
+ children: /*#__PURE__*/_jsx(Stack, {
48
+ direction: "row",
49
+ gap: 1,
50
+ children: contents.map((content, index) => /*#__PURE__*/_jsx(Stack, {
51
+ spacing: 1,
52
+ sx: {
53
+ ...styles,
54
+ ...sx
55
+ },
56
+ children: content
57
+ }, index))
58
+ })
59
+ })]
60
+ })
61
+ });
62
+ }
@@ -0,0 +1,63 @@
1
+ import { useMemo, useState } from "react";
2
+ import { DataGrid } from "@mui/x-data-grid";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ export default function PropertyTable({
5
+ columns,
6
+ rows,
7
+ onUpdate
8
+ }) {
9
+ const [updatedRows, setUpdatedRows] = useState(rows);
10
+ const columnsWithClassName = useMemo(() => {
11
+ return columns.map(column => {
12
+ const newColumn = {
13
+ ...column
14
+ };
15
+ if (column.fixed) {
16
+ newColumn.cellClassName = params => {
17
+ return !params.row.deletable ? 'fixed' : '';
18
+ };
19
+ } else if (column.dimmed) newColumn.cellClassName = 'dimmed';
20
+ return newColumn;
21
+ });
22
+ }, [columns]);
23
+ const processRowUpdate = row => {
24
+ const newRows = updatedRows.filter(r => r.id !== row.id);
25
+ newRows.push(row);
26
+ setUpdatedRows(newRows);
27
+ if (onUpdate) onUpdate(row, newRows);
28
+ return row;
29
+ };
30
+ return /*#__PURE__*/_jsx(DataGrid, {
31
+ columns: columnsWithClassName,
32
+ rows: rows,
33
+ columnHeaderHeight: 35,
34
+ rowHeight: 30,
35
+ isCellEditable: params => {
36
+ return params.row.deletable || !params.colDef.fixed;
37
+ },
38
+ processRowUpdate: processRowUpdate,
39
+ onProcessRowUpdateError: error => console.log(error),
40
+ disableColumnMenu: true,
41
+ disableRowSelectionOnClick: true,
42
+ hideFooter: true,
43
+ sx: styles
44
+ });
45
+ }
46
+ const styles = {
47
+ '.MuiDataGrid-columnHeaders': {
48
+ backgroundColor: '#f8f9fa'
49
+ },
50
+ '.MuiDataGrid-columnSeparator': {
51
+ visibility: 'hidden !important'
52
+ },
53
+ '.MuiDataGrid-cell.fixed': {
54
+ fontWeight: 'bold'
55
+ },
56
+ '.MuiDataGrid-cell.dimmed': {
57
+ color: '#666'
58
+ },
59
+ '& .Mui-error': {
60
+ backgroundColor: 'rgb(126,10,15, 0.1)',
61
+ color: '#750f0f'
62
+ }
63
+ };
package/dist/index.js CHANGED
@@ -7,6 +7,7 @@ export { default as AppendableFormList } from "./AppendableFormList";
7
7
  export { default as AvatarDropdown } from "./AvatarDropdown";
8
8
  export { default as Checkbox } from "./Checkbox";
9
9
  export { default as CircularProgress } from "./CircularProgress";
10
+ export { default as ColumnedSection } from "./ColumnedSection";
10
11
  export { default as ConfirmDialog } from "./ConfirmDialog";
11
12
  export { default as DataGrid } from "./DataGrid";
12
13
  export { default as Dialog } from "./Dialog";
@@ -19,6 +20,7 @@ export { default as ListItemDivider } from "./ListItemDivider";
19
20
  export { default as ListItemGrid } from "./ListItemGrid";
20
21
  export { default as ListItemText } from "./ListItemText";
21
22
  export { default as MainHeader } from "./MainHeader";
23
+ export { default as PropertyTable } from "./PropertyTable";
22
24
  export { default as ReferenceChipList } from "./ReferenceChipList";
23
25
  export { default as SearchTextField } from "./SearchTextField";
24
26
  export { default as Section } from "./Section";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "/dist"