@sphereon/ui-components.ssi-react 0.1.2-next.21 → 0.1.2-next.27

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,7 @@
1
+ import { FC } from 'react';
2
+ export type Props = {
3
+ truncationLength?: number;
4
+ value: string;
5
+ };
6
+ declare const SSIText: FC<Props>;
7
+ export default SSIText;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { SSITruncatedTextStyled, SSITruncatedContainerStyled, SSITruncatedFullTextStyled } from '../../../styles/components/components/SSIText';
3
+ const SSIText = (props) => {
4
+ const { value, truncationLength } = props;
5
+ if (truncationLength && value.length > truncationLength) {
6
+ const truncatedText = value.substring(0, truncationLength);
7
+ return (_jsxs(SSITruncatedContainerStyled, { children: [_jsx(SSITruncatedTextStyled, { children: truncatedText }), _jsx(SSITruncatedFullTextStyled, { children: value })] }));
8
+ }
9
+ else {
10
+ return _jsx("p", { children: value });
11
+ }
12
+ };
13
+ export default SSIText;
@@ -4,6 +4,7 @@ import { createColumnHelper, flexRender, getCoreRowModel, useReactTable, } from
4
4
  import { TableCellTypeEnum } from '../../../types';
5
5
  import SSITableViewHeader from './SSITableViewHeader';
6
6
  import SSITypeLabel from '../../labels/SSITypeLabel';
7
+ import SSIText from '../../labels/SSIText';
7
8
  import { SSITableViewCellContainerStyled, SSITableViewContainerStyled, SSITableViewHeaderCellContainerStyled, SSITableViewLabelCellStyled, SSITableViewRowContainerStyled, SSITableViewTableContainerStyled, } from '../../../styles/components';
8
9
  function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
9
10
  const ref = React.useRef(null);
@@ -14,10 +15,10 @@ function IndeterminateCheckbox({ indeterminate, className = '', ...rest }) {
14
15
  }, [ref, indeterminate]);
15
16
  return _jsx("input", { type: "checkbox", ref: ref, className: className + ' cursor-pointer', ...rest });
16
17
  }
17
- const getCellFormatting = (type, value) => {
18
+ const getCellFormatting = (type, value, truncationLength) => {
18
19
  switch (type) {
19
20
  case TableCellTypeEnum.TEXT:
20
- return _jsx("p", { children: value });
21
+ return _jsx(SSIText, { value: value, ...(truncationLength && { truncationLength }) });
21
22
  case TableCellTypeEnum.LABEL: {
22
23
  const labels = Array.isArray(value) ? value.map((label) => _jsx(SSITypeLabel, { type: label })) : _jsx(SSITypeLabel, { type: value });
23
24
  return _jsx(SSITableViewLabelCellStyled, { children: labels });
@@ -33,7 +34,7 @@ const SSITableView = (props) => {
33
34
  let availableColumns = columns.map((header) => columnHelper.accessor(header.accessor, {
34
35
  id: header.accessor,
35
36
  header: header.label,
36
- cell: (info) => getCellFormatting(header.type, info.getValue()),
37
+ cell: (info) => getCellFormatting(header.type, info.getValue(), header.truncationLength),
37
38
  }));
38
39
  if (enableRowSelection) {
39
40
  availableColumns = [
@@ -70,7 +71,7 @@ const SSITableView = (props) => {
70
71
  await onRowClick(row);
71
72
  }
72
73
  };
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: {
74
+ return (_jsx(SSITableViewContainerStyled, { children: _jsxs("div", { className: "overflow-x-auto", children: [_jsx(SSITableViewHeader, { actions: actions, enableFiltering: enableFiltering }), _jsxs(SSITableViewTableContainerStyled, { 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: {
74
75
  transform: columnResizeMode === 'onEnd' && header.column.getIsResizing()
75
76
  ? `translateX(${table.getState().columnSizingInfo.deltaOffset}px)`
76
77
  : '',
@@ -14,7 +14,7 @@ export const SSITableViewLabelCellStyled = styled.div `
14
14
  `;
15
15
  export const SSITableViewTableContainerStyled = styled.table `
16
16
  user-select: text;
17
- width: fit-content;
17
+ width: 100%;
18
18
  border-collapse: collapse;
19
19
  `;
20
20
  export const SSITableViewRowContainerStyled = styled.tr `
@@ -0,0 +1,3 @@
1
+ export declare const SSITruncatedFullTextStyled: import("styled-components").StyledComponent<"span", any, {}, never>;
2
+ export declare const SSITruncatedContainerStyled: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const SSITruncatedTextStyled: import("styled-components").StyledComponent<"span", any, {}, never>;
@@ -0,0 +1,21 @@
1
+ import styled from 'styled-components';
2
+ export const SSITruncatedFullTextStyled = styled.span `
3
+ display: none;
4
+ position: absolute;
5
+ top: 100%;
6
+ left: 0;
7
+ background: #fff;
8
+ border: 1px solid #ccc;
9
+ padding: 5px;
10
+ z-index: 1;
11
+ `;
12
+ export const SSITruncatedContainerStyled = styled.div `
13
+ position: relative;
14
+
15
+ &:hover ${SSITruncatedFullTextStyled} {
16
+ display: block;
17
+ }
18
+ `;
19
+ export const SSITruncatedTextStyled = styled.span `
20
+ display: 'inline';
21
+ `;
@@ -20,6 +20,7 @@ export type ColumnHeader<T> = {
20
20
  accessor: AccessorFn<T> | DeepKeys<T>;
21
21
  type: TableCellTypeEnum;
22
22
  label?: string;
23
+ truncationLength?: number;
23
24
  };
24
25
  export type Button = {
25
26
  caption: string;
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.21+5ebdbbe",
4
+ "version": "0.1.2-next.27+8da7f08",
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.21+5ebdbbe",
31
+ "@sphereon/ui-components.core": "0.1.2-next.27+8da7f08",
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": "5ebdbbe46283cdec64e4fd87e0dcd297551ba310"
43
+ "gitHead": "8da7f088dce61cddd475572c7bf15f0cbd4bf6d0"
44
44
  }