@sphereon/ui-components.ssi-react 0.1.2-unstable.30 → 0.1.2-unstable.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.
- package/dist/components/assets/icons/SSIArrowDownIcon/index.d.ts +2 -1
- package/dist/components/assets/icons/SSIArrowDownIcon/index.js +2 -2
- package/dist/components/assets/icons/SSIFilterIcon/index.d.ts +2 -1
- package/dist/components/assets/icons/SSIFilterIcon/index.js +2 -2
- package/dist/components/views/SSITableView/SSITableViewHeader/index.d.ts +1 -0
- package/dist/components/views/SSITableView/SSITableViewHeader/index.js +3 -2
- package/dist/components/views/SSITableView/index.d.ts +2 -0
- package/dist/components/views/SSITableView/index.js +13 -12
- package/dist/styles/components/components/SSITableView/index.d.ts +1 -0
- package/dist/styles/components/components/SSITableView/index.js +5 -1
- package/dist/types/component/index.d.ts +1 -4
- package/dist/types/component/index.js +0 -1
- package/package.json +3 -3
- package/dist/components/labels/SSIGenericStatusLabel/index.d.ts +0 -11
- package/dist/components/labels/SSIGenericStatusLabel/index.js +0 -8
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { CSSProperties, FC } from 'react';
|
|
2
2
|
export interface IProps {
|
|
3
3
|
width?: number;
|
|
4
4
|
height?: number;
|
|
5
5
|
color?: string;
|
|
6
|
+
style?: CSSProperties;
|
|
6
7
|
}
|
|
7
8
|
declare const SSIArrowDownIcon: FC<IProps>;
|
|
8
9
|
export default SSIArrowDownIcon;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { fontColors } from '@sphereon/ui-components.core';
|
|
3
3
|
const SSIArrowDownIcon = (props) => {
|
|
4
|
-
const { width = 16, height = 8, color = fontColors.dark } = props;
|
|
5
|
-
return (_jsx("div", { style: { width, height, display: 'flex' }, children: _jsx("svg", { width: "16", height: "8", viewBox: "0 0 16 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M8.03265 7.74886C8.14951 7.74175 8.26065 7.69465 8.34825 7.61511L15.3133 1.19499C15.367 1.1489 15.411 1.09224 15.4429 1.02837C15.4747 0.964504 15.4937 0.894731 15.4987 0.823204C15.5037 0.751676 15.4946 0.67985 15.4719 0.611995C15.4493 0.54414 15.4135 0.481647 15.3668 0.428216C15.3201 0.374784 15.2634 0.331504 15.2001 0.300961C15.1367 0.270419 15.068 0.253238 14.9981 0.250423C14.9281 0.247608 14.8583 0.259221 14.7928 0.28458C14.7273 0.309939 14.6675 0.348517 14.6168 0.398032L8 6.49492L1.38317 0.398032C1.33252 0.348517 1.27268 0.309939 1.20718 0.28458C1.14169 0.259221 1.07189 0.247597 1.00193 0.250412C0.931963 0.253227 0.863266 0.270419 0.799918 0.300961C0.736569 0.331504 0.679861 0.374784 0.633164 0.428216C0.586466 0.481647 0.550732 0.54414 0.528085 0.611995C0.505437 0.67985 0.496338 0.751676 0.501329 0.823204C0.506319 0.894731 0.525297 0.964504 0.557135 1.02837C0.588973 1.09224 0.633022 1.1489 0.686663 1.19499L7.65174 7.61511C7.70344 7.6621 7.76372 7.69811 7.82911 7.72107C7.89449 7.74403 7.96367 7.75348 8.03265 7.74886Z", fill: color }) }) }));
|
|
4
|
+
const { width = 16, height = 8, color = fontColors.dark, style } = props;
|
|
5
|
+
return (_jsx("div", { style: { ...style, width, height, display: 'flex' }, children: _jsx("svg", { width: "16", height: "8", viewBox: "0 0 16 8", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M8.03265 7.74886C8.14951 7.74175 8.26065 7.69465 8.34825 7.61511L15.3133 1.19499C15.367 1.1489 15.411 1.09224 15.4429 1.02837C15.4747 0.964504 15.4937 0.894731 15.4987 0.823204C15.5037 0.751676 15.4946 0.67985 15.4719 0.611995C15.4493 0.54414 15.4135 0.481647 15.3668 0.428216C15.3201 0.374784 15.2634 0.331504 15.2001 0.300961C15.1367 0.270419 15.068 0.253238 14.9981 0.250423C14.9281 0.247608 14.8583 0.259221 14.7928 0.28458C14.7273 0.309939 14.6675 0.348517 14.6168 0.398032L8 6.49492L1.38317 0.398032C1.33252 0.348517 1.27268 0.309939 1.20718 0.28458C1.14169 0.259221 1.07189 0.247597 1.00193 0.250412C0.931963 0.253227 0.863266 0.270419 0.799918 0.300961C0.736569 0.331504 0.679861 0.374784 0.633164 0.428216C0.586466 0.481647 0.550732 0.54414 0.528085 0.611995C0.505437 0.67985 0.496338 0.751676 0.501329 0.823204C0.506319 0.894731 0.525297 0.964504 0.557135 1.02837C0.588973 1.09224 0.633022 1.1489 0.686663 1.19499L7.65174 7.61511C7.70344 7.6621 7.76372 7.69811 7.82911 7.72107C7.89449 7.74403 7.96367 7.75348 8.03265 7.74886Z", fill: color }) }) }));
|
|
6
6
|
};
|
|
7
7
|
export default SSIArrowDownIcon;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { fontColors } from '@sphereon/ui-components.core';
|
|
3
3
|
const SSIFilterIcon = (props) => {
|
|
4
|
-
const { height = 16, width = 18, color = fontColors.dark } = props;
|
|
5
|
-
return (_jsx("div", { style: { width, height, display: 'flex' }, children: _jsx("svg", { width: "18", height: "16", viewBox: "0 0 18 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M16.5 1.5H1.5L7.5 8.33222V13.0556L10.5 14.5V8.33222L16.5 1.5Z", stroke: color, strokeOpacity: "0.8", strokeWidth: "1.29412", strokeLinecap: "round", strokeLinejoin: "round" }) }) }));
|
|
4
|
+
const { height = 16, width = 18, color = fontColors.dark, style } = props;
|
|
5
|
+
return (_jsx("div", { style: { ...style, width, height, display: 'flex' }, children: _jsx("svg", { width: "18", height: "16", viewBox: "0 0 18 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M16.5 1.5H1.5L7.5 8.33222V13.0556L10.5 14.5V8.33222L16.5 1.5Z", stroke: color, strokeOpacity: "0.8", strokeWidth: "1.29412", strokeLinecap: "round", strokeLinejoin: "round" }) }) }));
|
|
6
6
|
};
|
|
7
7
|
export default SSIFilterIcon;
|
|
@@ -6,7 +6,8 @@ import SSIDropDownList from '../../../lists/SSIDropDownList';
|
|
|
6
6
|
import SSIPrimaryButton from '../../../buttons/SSIPrimaryButton';
|
|
7
7
|
import { SSITableViewHeaderActionsContainerStyled as ActionsContainer, SSITableViewHeaderContainerStyled as Container, SSITableViewHeaderContentContainerStyled as ContentContainer, SSITextH3Styled as FilterCaption, SSITableViewHeaderFilterContainerStyled as FilterContainer, SSITableViewHeaderShowOptionContainerStyled as ShowOptionContainer, } from '../../../../styles/components';
|
|
8
8
|
const SSITableViewHeader = (props) => {
|
|
9
|
-
const { enableFiltering = false, actions = [] } = props;
|
|
10
|
-
return (_jsx(Container, { children: _jsx(ContentContainer, { children: _jsxs(ActionsContainer, { children: [enableFiltering && (_jsxs(FilterContainer, { children: [_jsx(SSIIconButton, { icon: ButtonIconsEnum.FILTER, onClick: async () => console.log('add filter clicked') }), _jsx(FilterCaption, { children: Localization.translate('action_filter_caption') })] })),
|
|
9
|
+
const { enableFiltering = false, enableMostRecent = false, actions = [] } = props;
|
|
10
|
+
return (_jsx(Container, { children: _jsx(ContentContainer, { children: _jsxs(ActionsContainer, { children: [enableFiltering && (_jsxs(FilterContainer, { children: [_jsx(SSIIconButton, { icon: ButtonIconsEnum.FILTER, onClick: async () => console.log('add filter clicked') }), _jsx(FilterCaption, { children: Localization.translate('action_filter_caption') })] })), enableMostRecent &&
|
|
11
|
+
_jsx(ShowOptionContainer, { children: _jsx(SSIDropDownList, { label: Localization.translate('action_show_caption'), initialValue: 'Most recent' }) }), actions.map((action, index) => (_jsx(SSIPrimaryButton, { caption: action.caption, onClick: action.onClick, icon: action.icon }, index)))] }) }) }));
|
|
11
12
|
};
|
|
12
13
|
export default SSITableViewHeader;
|
|
@@ -7,6 +7,8 @@ export type Props<T> = {
|
|
|
7
7
|
onRowClick?: (data: Row<T>) => Promise<void>;
|
|
8
8
|
enableRowSelection?: boolean;
|
|
9
9
|
enableFiltering?: boolean;
|
|
10
|
+
enableMostRecent?: boolean;
|
|
11
|
+
enableResultCount?: boolean;
|
|
10
12
|
columnResizeMode?: ColumnResizeMode;
|
|
11
13
|
actions?: Array<Button>;
|
|
12
14
|
};
|
|
@@ -1,12 +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 SSIGenericStatusLabel from "../../labels/SSIGenericStatusLabel";
|
|
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';
|
|
10
10
|
function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
|
|
11
11
|
const ref = React.useRef(null);
|
|
12
12
|
React.useEffect(() => {
|
|
@@ -16,30 +16,26 @@ function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
|
|
|
16
16
|
}, [ref, indeterminate]);
|
|
17
17
|
return _jsx("input", { type: "checkbox", ref: ref, className: className + ' cursor-pointer', ...rest });
|
|
18
18
|
}
|
|
19
|
-
const getCellFormatting = (
|
|
20
|
-
const { type, value, truncationLength, statusLabel } = props;
|
|
19
|
+
const getCellFormatting = (type, value, truncationLength) => {
|
|
21
20
|
switch (type) {
|
|
22
21
|
case TableCellTypeEnum.TEXT:
|
|
23
22
|
return _jsx(SSIText, { value: value, ...(truncationLength && { truncationLength }) });
|
|
24
23
|
case TableCellTypeEnum.LABEL: {
|
|
25
24
|
const labels = Array.isArray(value) ? value.map((label) => _jsx(SSITypeLabel, { type: label })) : _jsx(SSITypeLabel, { type: value });
|
|
26
|
-
return _jsx(
|
|
27
|
-
}
|
|
28
|
-
case TableCellTypeEnum.STATUS: {
|
|
29
|
-
return _jsx(SSIGenericStatusLabel, { status: value, textColorMapping: statusLabel.textColorMapping, showIcon: statusLabel?.showIcon, style: statusLabel?.style, getStatusBadge: statusLabel?.getStatusBadge, getStatusTranslation: statusLabel?.getStatusTranslation });
|
|
25
|
+
return _jsx(LabelCell, { children: labels });
|
|
30
26
|
}
|
|
31
27
|
default:
|
|
32
28
|
return _jsx("div", {});
|
|
33
29
|
}
|
|
34
30
|
};
|
|
35
31
|
const SSITableView = (props) => {
|
|
36
|
-
const { columns, data, enableRowSelection = false, enableFiltering = false, columnResizeMode = 'onChange', actions = [], onRowClick } = props;
|
|
32
|
+
const { columns, data, enableRowSelection = false, enableFiltering = false, enableMostRecent = false, enableResultCount = false, columnResizeMode = 'onChange', actions = [], onRowClick } = props;
|
|
37
33
|
const [rowSelection, setRowSelection] = React.useState({});
|
|
38
34
|
const columnHelper = createColumnHelper();
|
|
39
35
|
let availableColumns = columns.map((header) => columnHelper.accessor(header.accessor, {
|
|
40
36
|
id: header.accessor,
|
|
41
37
|
header: header.label,
|
|
42
|
-
cell: (info) => getCellFormatting(
|
|
38
|
+
cell: (info) => getCellFormatting(header.type, info.getValue(), header.truncationLength),
|
|
43
39
|
}));
|
|
44
40
|
if (enableRowSelection) {
|
|
45
41
|
availableColumns = [
|
|
@@ -76,10 +72,15 @@ const SSITableView = (props) => {
|
|
|
76
72
|
await onRowClick(row);
|
|
77
73
|
}
|
|
78
74
|
};
|
|
79
|
-
return (_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: {
|
|
80
81
|
transform: columnResizeMode === 'onEnd' && header.column.getIsResizing()
|
|
81
82
|
? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)`
|
|
82
83
|
: '',
|
|
83
|
-
} })] }, 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))) })] })] }) }));
|
|
84
85
|
};
|
|
85
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
|
+
`;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { AccessorFn, DeepKeys } from '@tanstack/react-table';
|
|
3
|
-
import { StatusLabelProps } from "../../components/labels/SSIGenericStatusLabel";
|
|
4
3
|
export type TabRoute = {
|
|
5
4
|
key: string;
|
|
6
5
|
title: string;
|
|
@@ -21,7 +20,6 @@ export type ColumnHeader<T> = {
|
|
|
21
20
|
accessor: AccessorFn<T> | DeepKeys<T>;
|
|
22
21
|
type: TableCellTypeEnum;
|
|
23
22
|
label?: string;
|
|
24
|
-
statusLabel?: Omit<StatusLabelProps, 'status'>;
|
|
25
23
|
truncationLength?: number;
|
|
26
24
|
};
|
|
27
25
|
export type Button = {
|
|
@@ -36,6 +34,5 @@ export declare enum LabelTypeEnum {
|
|
|
36
34
|
}
|
|
37
35
|
export declare enum TableCellTypeEnum {
|
|
38
36
|
TEXT = "text",
|
|
39
|
-
LABEL = "label"
|
|
40
|
-
STATUS = "status"
|
|
37
|
+
LABEL = "label"
|
|
41
38
|
}
|
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-unstable.
|
|
4
|
+
"version": "0.1.2-unstable.31+f20578f",
|
|
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-unstable.
|
|
31
|
+
"@sphereon/ui-components.core": "0.1.2-unstable.31+f20578f",
|
|
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": "f20578f76e5c503146c1963305d54cd7afac000a"
|
|
44
44
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, FC, ReactElement } from "react";
|
|
2
|
-
export type StatusLabelProps = {
|
|
3
|
-
status: string;
|
|
4
|
-
showIcon?: boolean;
|
|
5
|
-
textColorMapping: Map<string, string>;
|
|
6
|
-
style?: CSSProperties;
|
|
7
|
-
getStatusBadge?: (status: string, backgroundColor?: string) => ReactElement;
|
|
8
|
-
getStatusTranslation?: (status: string) => string;
|
|
9
|
-
};
|
|
10
|
-
declare const SSIGenericStatusLabel: FC<StatusLabelProps>;
|
|
11
|
-
export default SSIGenericStatusLabel;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { SSIStatusLabelBadgeContainer as BadgeContainer, SSIStatusLabelContainerStyled as Container, SSIStatusLabelStatusCaptionStyled as StatusCaption } from "../../../styles/components";
|
|
3
|
-
const SSIGenericStatusLabel = (props) => {
|
|
4
|
-
const { getStatusBadge, getStatusTranslation, status, textColorMapping, style, showIcon = false } = props;
|
|
5
|
-
const color = textColorMapping?.has(status) ? textColorMapping.get(status) : 'black';
|
|
6
|
-
return (_jsxs(Container, { style: { ...style, borderColor: color }, children: [showIcon && getStatusBadge && _jsx(BadgeContainer, { children: getStatusBadge(status, color) }), _jsx(StatusCaption, { style: { color }, children: getStatusTranslation ? getStatusTranslation(status) : status })] }));
|
|
7
|
-
};
|
|
8
|
-
export default SSIGenericStatusLabel;
|