@sphereon/ui-components.ssi-react 0.1.2 → 0.1.3-next.3
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,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable, } from '@tanstack/react-table';
|
|
4
|
+
import { Localization } from '@sphereon/ui-components.core';
|
|
4
5
|
import { TableCellTypeEnum } from '../../../types';
|
|
5
6
|
import SSITableViewHeader from './SSITableViewHeader';
|
|
6
7
|
import SSITypeLabel from '../../labels/SSITypeLabel';
|
|
7
8
|
import SSIText from '../../labels/SSIText';
|
|
8
|
-
import { SSITableViewCellContainerStyled, SSITableViewContainerStyled, SSITableViewHeaderCellContainerStyled, SSITableViewLabelCellStyled, SSITableViewRowContainerStyled, SSITableViewTableContainerStyled, } from '../../../styles/components';
|
|
9
|
+
import { SSITableViewCellContainerStyled as CellContainer, SSITableViewContainerStyled as Container, SSITableViewHeaderCellContainerStyled as HeaderCellContainer, SSITableViewLabelCellStyled as LabelCell, SSITableViewResultCountCaptionStyled as ResultCountCaption, SSITableViewRowContainerStyled as RowContainer, SSITableViewTableContainerStyled as TableContainer, } from '../../../styles/components';
|
|
9
10
|
function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
|
|
10
11
|
const ref = React.useRef(null);
|
|
11
12
|
React.useEffect(() => {
|
|
@@ -21,14 +22,14 @@ const getCellFormatting = (type, value, truncationLength) => {
|
|
|
21
22
|
return _jsx(SSIText, { value: value, ...(truncationLength && { truncationLength }) });
|
|
22
23
|
case TableCellTypeEnum.LABEL: {
|
|
23
24
|
const labels = Array.isArray(value) ? value.map((label) => _jsx(SSITypeLabel, { type: label })) : _jsx(SSITypeLabel, { type: value });
|
|
24
|
-
return _jsx(
|
|
25
|
+
return _jsx(LabelCell, { children: labels });
|
|
25
26
|
}
|
|
26
27
|
default:
|
|
27
28
|
return _jsx("div", {});
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
const SSITableView = (props) => {
|
|
31
|
-
const { columns, data, enableRowSelection = false, enableFiltering = false, enableMostRecent = false, columnResizeMode = 'onChange', actions = [], onRowClick } = props;
|
|
32
|
+
const { columns, data, enableRowSelection = false, enableFiltering = false, enableMostRecent = false, enableResultCount = false, columnResizeMode = 'onChange', actions = [], onRowClick } = props;
|
|
32
33
|
const [rowSelection, setRowSelection] = React.useState({});
|
|
33
34
|
const columnHelper = createColumnHelper();
|
|
34
35
|
let availableColumns = columns.map((header) => columnHelper.accessor(header.accessor, {
|
|
@@ -71,11 +72,15 @@ const SSITableView = (props) => {
|
|
|
71
72
|
await onRowClick(row);
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
|
-
return (_jsx(
|
|
75
|
-
_jsx(
|
|
75
|
+
return (_jsx(Container, { children: _jsxs("div", { className: "overflow-x-auto", children: [enableResultCount &&
|
|
76
|
+
_jsx(ResultCountCaption, { children: Localization.translate('result_count_label', {
|
|
77
|
+
count: data.length,
|
|
78
|
+
maxCount: data.length,
|
|
79
|
+
}) }), (enableFiltering || enableMostRecent || actions.length > 0) &&
|
|
80
|
+
_jsx(SSITableViewHeader, { actions: actions, enableFiltering: enableFiltering, enableMostRecent: enableMostRecent }), _jsxs(TableContainer, { children: [_jsx("thead", { children: table.getHeaderGroups().map((headerGroup) => (_jsx(RowContainer, { children: headerGroup.headers.map((header) => (_jsxs(HeaderCellContainer, { 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: {
|
|
76
81
|
transform: columnResizeMode === 'onEnd' && header.column.getIsResizing()
|
|
77
82
|
? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)`
|
|
78
83
|
: '',
|
|
79
|
-
} })] }, header.id))) }, headerGroup.id))) }), _jsx("tbody", { children: table.getRowModel().rows.map((row) => (_jsx(
|
|
84
|
+
} })] }, header.id))) }, headerGroup.id))) }), _jsx("tbody", { children: table.getRowModel().rows.map((row) => (_jsx(RowContainer, { onClick: () => onRowClicked(row), children: row.getVisibleCells().map((cell) => (_jsx(CellContainer, { style: { width: cell.column.getSize() }, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))) }, row.id))) })] })] }) }));
|
|
80
85
|
};
|
|
81
86
|
export default SSITableView;
|
|
@@ -4,3 +4,4 @@ export declare const SSITableViewTableContainerStyled: import("styled-components
|
|
|
4
4
|
export declare const SSITableViewRowContainerStyled: import("styled-components").StyledComponent<"tr", any, {}, never>;
|
|
5
5
|
export declare const SSITableViewCellContainerStyled: import("styled-components").StyledComponent<"td", any, {}, never>;
|
|
6
6
|
export declare const SSITableViewHeaderCellContainerStyled: import("styled-components").StyledComponent<"th", any, {}, never>;
|
|
7
|
+
export declare const SSITableViewResultCountCaptionStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -2,7 +2,6 @@ import styled from 'styled-components';
|
|
|
2
2
|
import { backgroundColors, borderColors, fontColors } from '@sphereon/ui-components.core';
|
|
3
3
|
import { SSITextH2Css, SSITextH3Css } from '../../../css';
|
|
4
4
|
export const SSITableViewContainerStyled = styled.div `
|
|
5
|
-
background-color: ${backgroundColors.lightGrey};
|
|
6
5
|
display: flex;
|
|
7
6
|
flex-grow: 1;
|
|
8
7
|
flex-direction: column;
|
|
@@ -16,6 +15,7 @@ export const SSITableViewTableContainerStyled = styled.table `
|
|
|
16
15
|
user-select: text;
|
|
17
16
|
width: 100%;
|
|
18
17
|
border-collapse: collapse;
|
|
18
|
+
background-color: ${backgroundColors.lightGrey};
|
|
19
19
|
`;
|
|
20
20
|
export const SSITableViewRowContainerStyled = styled.tr `
|
|
21
21
|
border-bottom: 1px solid ${borderColors.lightGrey};
|
|
@@ -35,3 +35,7 @@ export const SSITableViewHeaderCellContainerStyled = styled.th `
|
|
|
35
35
|
color: ${fontColors.lightGrey};
|
|
36
36
|
text-align: left;
|
|
37
37
|
`;
|
|
38
|
+
export const SSITableViewResultCountCaptionStyled = styled.div `
|
|
39
|
+
${SSITextH3Css};
|
|
40
|
+
margin-left: 24px;
|
|
41
|
+
`;
|
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.
|
|
4
|
+
"version": "0.1.3-next.3+2c49b98",
|
|
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.
|
|
31
|
+
"@sphereon/ui-components.core": "0.1.3-next.3+2c49b98",
|
|
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": "2c49b98bc1809930ccb738aa579a7fb2a156e773"
|
|
44
44
|
}
|