@sphereon/ui-components.ssi-react 0.1.3-unstable.96 → 0.1.3-unstable.98
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/BitterballenIcon/index.d.ts +8 -0
- package/dist/components/assets/icons/BitterballenIcon/index.js +7 -0
- package/dist/components/assets/icons/DeleteIcon/index.d.ts +8 -0
- package/dist/components/assets/icons/DeleteIcon/index.js +7 -0
- package/dist/components/buttons/RowActionMenuButton/index.d.ts +13 -0
- package/dist/components/buttons/RowActionMenuButton/index.js +28 -0
- package/dist/components/buttons/SSIIconButton/index.js +8 -2
- package/dist/components/views/SSITableView/index.d.ts +2 -1
- package/dist/components/views/SSITableView/index.js +13 -2
- package/dist/styles/components/components/RowActionMenuButton/index.d.ts +4 -0
- package/dist/styles/components/components/RowActionMenuButton/index.js +27 -0
- package/dist/styles/components/components/index.d.ts +1 -0
- package/dist/styles/components/components/index.js +1 -0
- package/dist/types/table/index.d.ts +11 -0
- package/package.json +3 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { fontColors } from '@sphereon/ui-components.core';
|
|
3
|
+
const BitterballenIcon = (props) => {
|
|
4
|
+
const { size = 42, color = fontColors.dark, style } = props;
|
|
5
|
+
return (_jsx("div", { style: { ...style, width: size, aspectRatio: 1, display: 'flex' }, children: _jsxs("svg", { width: "42", height: "43", viewBox: "0 0 42 43", fill: color, xmlns: "http://www.w3.org/2000/svg", children: [_jsx("circle", { cx: "13", cy: "21.5", r: "2", fill: "#303030" }), _jsx("circle", { cx: "21", cy: "21.5", r: "2", fill: "#303030" }), _jsx("circle", { cx: "29", cy: "21.5", r: "2", fill: "#303030" })] }) }));
|
|
6
|
+
};
|
|
7
|
+
export default BitterballenIcon;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fontColors } from '@sphereon/ui-components.core';
|
|
3
|
+
const DeleteIcon = (props) => {
|
|
4
|
+
const { size = 21, color = fontColors.dark, style } = props;
|
|
5
|
+
return (_jsx("div", { style: { ...style, width: size, aspectRatio: 1, display: 'flex' }, children: _jsx("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: color, xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M24.8277 8.98905V24.6058C24.8277 26.4672 23.3113 28 21.4699 28H10.5336C8.68863 28 7.1722 26.4672 7.1722 24.6058V8.98905H5.97712C4.9409 8.98905 4.9409 7.39781 5.97712 7.39781H12.1114V5.87226C12.1114 4.87591 12.8841 4 13.8914 4H18.1121C19.1158 4 19.8921 4.87956 19.8921 5.87226V7.39781H26.0228C27.059 7.39781 27.059 8.98905 26.0228 8.98905H24.8277ZM13.6856 7.39781H18.3143V5.87226C18.3143 5.75547 18.2457 5.59124 18.1121 5.59124H13.8914C13.7542 5.59124 13.6856 5.75547 13.6856 5.87226V7.39781ZM19.43 21.9635C19.43 23.0073 17.8558 23.0073 17.8558 21.9635V13.2993C17.8558 12.2555 19.43 12.2555 19.43 13.2993V21.9635ZM14.1441 21.9635C14.1441 23.0073 12.5699 23.0073 12.5699 21.9635V13.2993C12.5699 12.2555 14.1441 12.2518 14.1441 13.2993V21.9635ZM23.2535 8.98905C18.419 8.98905 13.5845 8.98905 8.75001 8.98905V24.6058C8.75001 25.5985 9.54793 26.4088 10.5336 26.4088H21.4699C22.452 26.4088 23.2535 25.5985 23.2535 24.6058V8.98905Z", fill: "#D74500" }) }) }));
|
|
6
|
+
};
|
|
7
|
+
export default DeleteIcon;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, FC } from 'react';
|
|
2
|
+
import { ButtonIcon } from '@sphereon/ui-components.core';
|
|
3
|
+
import { ActionButton } from '../../../index';
|
|
4
|
+
import { Row } from '@tanstack/react-table';
|
|
5
|
+
type Props = {
|
|
6
|
+
actions: ActionButton[];
|
|
7
|
+
icon: ButtonIcon;
|
|
8
|
+
color?: string;
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
rowData?: Row<any>;
|
|
11
|
+
};
|
|
12
|
+
declare const RowActionMenuButton: FC<Props>;
|
|
13
|
+
export default RowActionMenuButton;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import { ButtonIcon } from '@sphereon/ui-components.core';
|
|
4
|
+
import { SSIIconButton } from '../../../index';
|
|
5
|
+
import { RowActionMenuButtonContainerStyled as ButtonContainer, RowActionDropdownContainerStyled as DropdownContainer, ActionItemContainerStyled as ActionItemContainer, ActionItemCaptionStyled as ItemCaption, } from '../../../styles';
|
|
6
|
+
const RowActionMenuButton = ({ actions, icon, color, style = {}, rowData }) => {
|
|
7
|
+
const [isDropdownVisible, setIsDropdownVisible] = useState(false);
|
|
8
|
+
const dropdownRef = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const handleClickOutside = (event) => {
|
|
11
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
12
|
+
setIsDropdownVisible(false);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
16
|
+
return () => {
|
|
17
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
18
|
+
};
|
|
19
|
+
}, [dropdownRef]);
|
|
20
|
+
const toggleDropdown = async () => {
|
|
21
|
+
setIsDropdownVisible(!isDropdownVisible);
|
|
22
|
+
};
|
|
23
|
+
const renderDropdown = () => {
|
|
24
|
+
return (_jsx(DropdownContainer, { ref: dropdownRef, style: { display: isDropdownVisible ? 'block' : 'none' }, children: actions.map((action, index) => (_jsxs(ActionItemContainer, { onClick: () => action.onClick(rowData), children: [_jsx(ItemCaption, { style: { marginLeft: '10px' }, children: action.caption }), action.icon && _jsx(SSIIconButton, { onClick: () => action.onClick(rowData), icon: action.icon })] }, index))) }));
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs(ButtonContainer, { style: { ...style }, children: [_jsx(SSIIconButton, { icon: icon || ButtonIcon.BITTERBALLEN, color: color, onClick: toggleDropdown }), renderDropdown()] }));
|
|
27
|
+
};
|
|
28
|
+
export default RowActionMenuButton;
|
|
@@ -4,6 +4,8 @@ import SSIAddIcon from '../../assets/icons/SSIAddIcon';
|
|
|
4
4
|
import SSIFilterIcon from '../../assets/icons/SSIFilterIcon';
|
|
5
5
|
import SSIArrowDownIcon from '../../assets/icons/SSIArrowDownIcon';
|
|
6
6
|
import { SSIIconButtonContainerStyled as Container } from '../../../styles';
|
|
7
|
+
import BitterballenIcon from '../../assets/icons/BitterballenIcon';
|
|
8
|
+
import DeleteIcon from '../../assets/icons/DeleteIcon';
|
|
7
9
|
const SSIIconButton = (props) => {
|
|
8
10
|
const { icon, onClick, disabled = false, color = fontColors.dark } = props;
|
|
9
11
|
return _jsx(Container, { onClick: onClick, children: getIcon(icon, color) });
|
|
@@ -12,10 +14,14 @@ const getIcon = (icon, color) => {
|
|
|
12
14
|
switch (icon) {
|
|
13
15
|
case ButtonIcon.ADD:
|
|
14
16
|
return _jsx(SSIAddIcon, { color: color });
|
|
15
|
-
case ButtonIcon.FILTER:
|
|
16
|
-
return _jsx(SSIFilterIcon, { color: color });
|
|
17
17
|
case ButtonIcon.ARROW_DOWN:
|
|
18
18
|
return _jsx(SSIArrowDownIcon, { color: color });
|
|
19
|
+
case ButtonIcon.BITTERBALLEN:
|
|
20
|
+
return _jsx(BitterballenIcon, { color: color });
|
|
21
|
+
case ButtonIcon.DELETE:
|
|
22
|
+
return _jsx(DeleteIcon, { color: color });
|
|
23
|
+
case ButtonIcon.FILTER:
|
|
24
|
+
return _jsx(SSIFilterIcon, { color: color });
|
|
19
25
|
default:
|
|
20
26
|
return _jsx("div", {});
|
|
21
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { ColumnResizeMode, Row } from '@tanstack/react-table';
|
|
3
|
-
import { Button, ColumnHeader } from '../../../types';
|
|
3
|
+
import { ActionGroup, Button, ColumnHeader } from '../../../types';
|
|
4
4
|
type Props<T> = {
|
|
5
5
|
data: Array<T>;
|
|
6
6
|
columns: Array<ColumnHeader<T>>;
|
|
@@ -11,6 +11,7 @@ type Props<T> = {
|
|
|
11
11
|
enableResultCount?: boolean;
|
|
12
12
|
columnResizeMode?: ColumnResizeMode;
|
|
13
13
|
actions?: Array<Button>;
|
|
14
|
+
actionGroup?: ActionGroup;
|
|
14
15
|
};
|
|
15
16
|
declare const SSITableView: <T extends {}>(props: Props<T>) => ReactElement;
|
|
16
17
|
export default SSITableView;
|
|
@@ -1,13 +1,14 @@
|
|
|
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
|
+
import { ButtonIcon, Localization } from '@sphereon/ui-components.core';
|
|
5
5
|
import SSITableViewHeader from './SSITableViewHeader';
|
|
6
6
|
import SSITypeLabel from '../../labels/SSITypeLabel';
|
|
7
7
|
import SSIHoverText from '../../fields/SSIHoverText';
|
|
8
8
|
import { SSITableViewCellContainerStyled as CellContainer, SSITableViewContainerStyled as Container, SSITableViewHeaderCellContainerStyled as HeaderCellContainer, SSITableViewLabelCellStyled as LabelCell, SSITableViewResultCountCaptionStyled as ResultCountCaption, SSITableViewRowContainerStyled as RowContainer, SSITableViewTableContainerStyled as TableContainer, } from '../../../styles';
|
|
9
9
|
import { TableCellType } from '../../../types';
|
|
10
10
|
import { CredentialMiniCardView, SSIStatusLabel } from '../../../index';
|
|
11
|
+
import RowActionMenuButton from '../../buttons/RowActionMenuButton';
|
|
11
12
|
function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
|
|
12
13
|
const ref = React.useRef(null);
|
|
13
14
|
React.useEffect(() => {
|
|
@@ -37,7 +38,7 @@ const getCellFormatting = (type, value, opts) => {
|
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
40
|
const SSITableView = (props) => {
|
|
40
|
-
const { columns, data, enableRowSelection = false, enableFiltering = false, enableMostRecent = false, enableResultCount = false, columnResizeMode = 'onChange', actions = [], onRowClick, } = props;
|
|
41
|
+
const { columns, data, enableRowSelection = false, enableFiltering = false, enableMostRecent = false, enableResultCount = false, columnResizeMode = 'onChange', actions = [], actionGroup, onRowClick, } = props;
|
|
41
42
|
const [rowSelection, setRowSelection] = React.useState({});
|
|
42
43
|
const columnHelper = createColumnHelper();
|
|
43
44
|
let availableColumns = columns.map((header) => columnHelper.accessor(header.accessor, {
|
|
@@ -67,6 +68,16 @@ const SSITableView = (props) => {
|
|
|
67
68
|
...availableColumns,
|
|
68
69
|
];
|
|
69
70
|
}
|
|
71
|
+
if (actionGroup) {
|
|
72
|
+
availableColumns = [
|
|
73
|
+
...availableColumns,
|
|
74
|
+
{
|
|
75
|
+
id: 'actions',
|
|
76
|
+
header: actionGroup.caption,
|
|
77
|
+
cell: ({ row }) => (_jsx("div", { className: "px-1", children: _jsx(RowActionMenuButton, { actions: actionGroup.actions, icon: ButtonIcon.BITTERBALLEN, rowData: row }) })),
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
}
|
|
70
81
|
const table = useReactTable({
|
|
71
82
|
defaultColumn: {
|
|
72
83
|
size: 0,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const RowActionMenuButtonContainerStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const ActionItemContainerStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const ActionItemCaptionStyled: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
4
|
+
export declare const RowActionDropdownContainerStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const RowActionMenuButtonContainerStyled = styled.div `
|
|
3
|
+
position: relative;
|
|
4
|
+
`;
|
|
5
|
+
export const ActionItemContainerStyled = styled.div `
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
align-items: center;
|
|
9
|
+
padding: 5px;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
max-width: 250px;
|
|
12
|
+
`;
|
|
13
|
+
export const ActionItemCaptionStyled = styled.span `
|
|
14
|
+
font-family: Poppins;
|
|
15
|
+
font-size: 16px;
|
|
16
|
+
font-weight: 400;
|
|
17
|
+
line-height: 24px;
|
|
18
|
+
letter-spacing: 0em;
|
|
19
|
+
text-align: left;
|
|
20
|
+
`;
|
|
21
|
+
export const RowActionDropdownContainerStyled = styled.div `
|
|
22
|
+
position: absolute;
|
|
23
|
+
z-index: 1000;
|
|
24
|
+
background-color: #fff;
|
|
25
|
+
width: auto;
|
|
26
|
+
padding: 10px;
|
|
27
|
+
`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AccessorFn, DeepKeys } from '@tanstack/react-table';
|
|
2
|
+
import { ButtonIcon } from '@sphereon/ui-components.core';
|
|
2
3
|
export declare enum TableCellType {
|
|
3
4
|
TEXT = "text",
|
|
4
5
|
LABEL = "label",
|
|
@@ -18,3 +19,13 @@ export type TableCellOptions = {
|
|
|
18
19
|
columnMaxWidth?: number;
|
|
19
20
|
columnWidth?: number;
|
|
20
21
|
};
|
|
22
|
+
export type ActionGroup = {
|
|
23
|
+
caption: string;
|
|
24
|
+
actions: ActionButton[];
|
|
25
|
+
};
|
|
26
|
+
export type ActionButton = {
|
|
27
|
+
caption: string;
|
|
28
|
+
onClick: (rowData: any) => Promise<void>;
|
|
29
|
+
icon?: ButtonIcon;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
};
|
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.3-unstable.
|
|
4
|
+
"version": "0.1.3-unstable.98+04b3a9f",
|
|
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.3-unstable.
|
|
31
|
+
"@sphereon/ui-components.core": "0.1.3-unstable.98+04b3a9f",
|
|
32
32
|
"@tanstack/react-table": "^8.9.3",
|
|
33
33
|
"react-loader-spinner": "^5.4.5",
|
|
34
34
|
"react-toastify": "^9.1.3",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": ">= 16.8.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "04b3a9f8779dc02b73dd05d9e2a81b5131822ba5"
|
|
46
46
|
}
|