@sphereon/ui-components.ssi-react 0.1.2-next.11 → 0.1.2-next.13
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,9 +1,10 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { ColumnResizeMode } from '@tanstack/react-table';
|
|
2
|
+
import { ColumnResizeMode, Row } from '@tanstack/react-table';
|
|
3
3
|
import { Button, ColumnHeader } from '../../../types';
|
|
4
4
|
export type Props<T> = {
|
|
5
5
|
data: Array<T>;
|
|
6
6
|
columns: Array<ColumnHeader<T>>;
|
|
7
|
+
onRowClick?: (data: Row<T>) => Promise<void>;
|
|
7
8
|
enableRowSelection?: boolean;
|
|
8
9
|
enableFiltering?: boolean;
|
|
9
10
|
columnResizeMode?: ColumnResizeMode;
|
|
@@ -27,7 +27,7 @@ const getCellFormatting = (type, value) => {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
const SSITableView = (props) => {
|
|
30
|
-
const { columns, data, enableRowSelection = false, enableFiltering = false, columnResizeMode = 'onChange', actions = [] } = props;
|
|
30
|
+
const { columns, data, enableRowSelection = false, enableFiltering = false, columnResizeMode = 'onChange', actions = [], onRowClick } = props;
|
|
31
31
|
const [rowSelection, setRowSelection] = React.useState({});
|
|
32
32
|
const columnHelper = createColumnHelper();
|
|
33
33
|
let availableColumns = columns.map((header) => columnHelper.accessor(header.accessor, {
|
|
@@ -65,10 +65,15 @@ const SSITableView = (props) => {
|
|
|
65
65
|
columnResizeMode,
|
|
66
66
|
getCoreRowModel: getCoreRowModel(),
|
|
67
67
|
});
|
|
68
|
+
const onRowClicked = async (row) => {
|
|
69
|
+
if (onRowClick) {
|
|
70
|
+
await onRowClick(row);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
68
73
|
return (_jsx(SSITableViewContainerStyled, { children: _jsxs("div", { className: "overflow-x-auto", children: [_jsx(SSITableViewHeader, { actions: actions, enableFiltering: enableFiltering }), _jsxs(SSITableViewTableContainerStyled, { style: { width: table.getCenterTotalSize() }, children: [_jsx("thead", { children: table.getHeaderGroups().map((headerGroup) => (_jsx(SSITableViewRowContainerStyled, { children: headerGroup.headers.map((header) => (_jsxs(SSITableViewHeaderCellContainerStyled, { colSpan: header.colSpan, style: { width: header.getSize() }, children: [header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()), _jsx("div", { className: `resizer ${header.column.getIsResizing() ? 'isResizing' : ''}`, onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), style: {
|
|
69
74
|
transform: columnResizeMode === 'onEnd' && header.column.getIsResizing()
|
|
70
75
|
? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)`
|
|
71
76
|
: '',
|
|
72
|
-
} })] }, header.id))) }, headerGroup.id))) }), _jsx("tbody", { children: table.getRowModel().rows.map((row) => (_jsx(SSITableViewRowContainerStyled, { children: row.getVisibleCells().map((cell) => (_jsx(SSITableViewCellContainerStyled, { style: { width: cell.column.getSize() }, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] })] }) }));
|
|
77
|
+
} })] }, header.id))) }, headerGroup.id))) }), _jsx("tbody", { children: table.getRowModel().rows.map((row) => (_jsx(SSITableViewRowContainerStyled, { onClick: () => onRowClicked(row), children: row.getVisibleCells().map((cell) => (_jsx(SSITableViewCellContainerStyled, { style: { width: cell.column.getSize() }, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] })] }) }));
|
|
73
78
|
};
|
|
74
79
|
export default SSITableView;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ui-components.ssi-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.2-next.
|
|
4
|
+
"version": "0.1.2-next.13+9f87811",
|
|
5
5
|
"description": "SSI UI components for React",
|
|
6
6
|
"repository": "git@github.com:Sphereon-Opensource/UI-Components.git",
|
|
7
7
|
"author": "Sphereon <dev@sphereon.com>",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@sphereon/ui-components.core": "0.1.2-next.
|
|
31
|
+
"@sphereon/ui-components.core": "0.1.2-next.13+9f87811",
|
|
32
32
|
"@tanstack/react-table": "^8.9.3",
|
|
33
33
|
"styled-components": "^5.3.3"
|
|
34
34
|
},
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">= 16.8.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "9f87811aeb9436f1a8ddbb7757aba7eebb1ef855"
|
|
44
44
|
}
|