@digigov/react-core 2.2.3 → 2.2.4-govgr-3925.02-06-26-09-54
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/CHANGELOG.md +9 -1
- package/TableDataCell/index.d.ts +7 -0
- package/TableDataCell/index.js +20 -3
- package/index.js +1 -1
- package/package.json +3 -3
- package/src/TableDataCell/index.tsx +36 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# Change Log - @digigov/react-core
|
|
2
2
|
|
|
3
|
-
<!-- This log was last generated on
|
|
3
|
+
<!-- This log was last generated on Tue, 02 Jun 2026 09:54:09 GMT and should not be manually modified. -->
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 2.2.4-govgr-3925.02-06-26-09-54
|
|
8
|
+
|
|
9
|
+
Tue, 02 Jun 2026 09:54:09 GMT
|
|
10
|
+
|
|
11
|
+
### Minor changes
|
|
12
|
+
|
|
13
|
+
- fix(libs-ui/TableDataCell): add a protective div to preserve cell-width when action positions absolute (cpapakon@admin.grnet.gr)
|
|
14
|
+
|
|
7
15
|
## 2.2.3
|
|
8
16
|
|
|
9
17
|
Thu, 28 May 2026 09:16:18 GMT
|
package/TableDataCell/index.d.ts
CHANGED
|
@@ -45,6 +45,13 @@ export interface TableDataCellProps extends BaseProps<'td'> {
|
|
|
45
45
|
* @default false
|
|
46
46
|
*/
|
|
47
47
|
maxWidthWithOverflow?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* maxWidthWithOverflow is optional.
|
|
50
|
+
* Use this prop to add an invisible element that has the same width as the cell content to preserve the cell width when the content is positioned absolute.
|
|
51
|
+
* This is useful in cells that contain for example action dropdowns (see dilosi) to prevent the table from collapsing the cell width when the dropdown is open.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
preserveCellWidth?: boolean;
|
|
48
55
|
}
|
|
49
56
|
/**
|
|
50
57
|
* Use TableDataCell inside the Table component to fill the data of a cell in a table.
|
package/TableDataCell/index.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import react from "react";
|
|
1
|
+
import react, { useEffect, useId } from "react";
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import Base from "../Base/index.js";
|
|
4
4
|
import VisuallyHidden from "../VisuallyHidden/index.js";
|
|
5
|
-
const TableDataCell_TableDataCell = /*#__PURE__*/ react.forwardRef(function({ dataType = 'text', variant = 'border', wordBreak = 'none', highlight, highlightAssistiveText, maxWidthWithOverflow = false, className, children, ...props }, ref) {
|
|
5
|
+
const TableDataCell_TableDataCell = /*#__PURE__*/ react.forwardRef(function({ dataType = 'text', variant = 'border', wordBreak = 'none', highlight, highlightAssistiveText, maxWidthWithOverflow = false, preserveCellWidth = false, className, children, ...props }, ref) {
|
|
6
|
+
const cellUniqueId = useId();
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
if (preserveCellWidth) {
|
|
9
|
+
const correctiveWidthEl = document.getElementById(cellUniqueId);
|
|
10
|
+
if (correctiveWidthEl) {
|
|
11
|
+
const contentWidth = correctiveWidthEl.getBoundingClientRect().width;
|
|
12
|
+
correctiveWidthEl.style.width = `${contentWidth}px`;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
6
16
|
const calculatedHighlightAssistiveText = highlightAssistiveText || ('warning' === highlight ? 'Προσοχή' : 'error' === highlight ? 'Λανθασμένο πεδίο' : void 0);
|
|
7
17
|
return /*#__PURE__*/ react.createElement(Base, {
|
|
8
18
|
as: "td",
|
|
@@ -19,7 +29,14 @@ const TableDataCell_TableDataCell = /*#__PURE__*/ react.forwardRef(function({ da
|
|
|
19
29
|
...props
|
|
20
30
|
}, maxWidthWithOverflow ? /*#__PURE__*/ react.createElement("div", {
|
|
21
31
|
className: "ds-table__cell__content"
|
|
22
|
-
}, calculatedHighlightAssistiveText && /*#__PURE__*/ react.createElement(VisuallyHidden, null, calculatedHighlightAssistiveText), children) : /*#__PURE__*/ react.createElement(react.Fragment, null, calculatedHighlightAssistiveText && /*#__PURE__*/ react.createElement(VisuallyHidden, null, calculatedHighlightAssistiveText),
|
|
32
|
+
}, calculatedHighlightAssistiveText && /*#__PURE__*/ react.createElement(VisuallyHidden, null, calculatedHighlightAssistiveText), children) : /*#__PURE__*/ react.createElement(react.Fragment, null, calculatedHighlightAssistiveText && /*#__PURE__*/ react.createElement(VisuallyHidden, null, calculatedHighlightAssistiveText), preserveCellWidth && /*#__PURE__*/ react.createElement("div", {
|
|
33
|
+
id: cellUniqueId,
|
|
34
|
+
className: "table-cell-corrective-width-element",
|
|
35
|
+
style: {
|
|
36
|
+
height: '1px',
|
|
37
|
+
marginTop: '-1px'
|
|
38
|
+
}
|
|
39
|
+
}), children));
|
|
23
40
|
});
|
|
24
41
|
const src_TableDataCell = TableDataCell_TableDataCell;
|
|
25
42
|
export { TableDataCell_TableDataCell as TableDataCell, src_TableDataCell as default };
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/react-core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4-govgr-3925.02-06-26-09-54",
|
|
4
4
|
"description": "@digigov react core components",
|
|
5
5
|
"author": "GRNET Developers <devs@lists.grnet.gr>",
|
|
6
6
|
"license": "BSD-2-Clause",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"react-native-svg": "^15.2.0",
|
|
18
18
|
"expo-router": "^3.5.14",
|
|
19
19
|
"nativewind": "^4.1.1",
|
|
20
|
-
"@digigov/css": "2.2.
|
|
21
|
-
"@digigov/react-icons": "2.2.
|
|
20
|
+
"@digigov/css": "2.2.4-govgr-3925.02-06-26-09-54",
|
|
21
|
+
"@digigov/react-icons": "2.2.4-govgr-3925.02-06-26-09-54"
|
|
22
22
|
},
|
|
23
23
|
"peerDependenciesMeta": {
|
|
24
24
|
"react-native": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useId } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import Base, { BaseProps } from '@digigov/react-core/Base';
|
|
4
4
|
import VisuallyHidden from '@digigov/react-core/VisuallyHidden';
|
|
@@ -52,6 +52,13 @@ export interface TableDataCellProps extends BaseProps<'td'> {
|
|
|
52
52
|
* @default false
|
|
53
53
|
*/
|
|
54
54
|
maxWidthWithOverflow?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* maxWidthWithOverflow is optional.
|
|
57
|
+
* Use this prop to add an invisible element that has the same width as the cell content to preserve the cell width when the content is positioned absolute.
|
|
58
|
+
* This is useful in cells that contain for example action dropdowns (see dilosi) to prevent the table from collapsing the cell width when the dropdown is open.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
preserveCellWidth?: boolean;
|
|
55
62
|
}
|
|
56
63
|
/**
|
|
57
64
|
* Use TableDataCell inside the Table component to fill the data of a cell in a table.
|
|
@@ -67,12 +74,33 @@ export const TableDataCell = React.forwardRef<
|
|
|
67
74
|
highlight,
|
|
68
75
|
highlightAssistiveText,
|
|
69
76
|
maxWidthWithOverflow = false,
|
|
77
|
+
preserveCellWidth = false,
|
|
70
78
|
className,
|
|
71
79
|
children,
|
|
72
80
|
...props
|
|
73
81
|
},
|
|
74
82
|
ref
|
|
75
83
|
) {
|
|
84
|
+
const cellUniqueId = useId();
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
// If preserveCellWidth is true, the cell contains an action dropdown
|
|
88
|
+
// (see dilosi), so we need to set the width of the corrective-width-element
|
|
89
|
+
// to the width of the content to allow the table to keep the correct width
|
|
90
|
+
// for the cell even when the cell content needs to position itself absolute.
|
|
91
|
+
if (preserveCellWidth) {
|
|
92
|
+
const correctiveWidthEl = document.getElementById(
|
|
93
|
+
cellUniqueId
|
|
94
|
+
) as HTMLElement;
|
|
95
|
+
if (correctiveWidthEl) {
|
|
96
|
+
// Get the width after rendering and set it to the corrective element
|
|
97
|
+
// explicitly in pixels
|
|
98
|
+
const contentWidth = correctiveWidthEl.getBoundingClientRect().width;
|
|
99
|
+
correctiveWidthEl.style.width = `${contentWidth}px`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, []);
|
|
103
|
+
|
|
76
104
|
const calculatedHighlightAssistiveText =
|
|
77
105
|
highlightAssistiveText ||
|
|
78
106
|
(highlight === 'warning'
|
|
@@ -108,6 +136,13 @@ export const TableDataCell = React.forwardRef<
|
|
|
108
136
|
{calculatedHighlightAssistiveText && (
|
|
109
137
|
<VisuallyHidden>{calculatedHighlightAssistiveText}</VisuallyHidden>
|
|
110
138
|
)}
|
|
139
|
+
{preserveCellWidth && (
|
|
140
|
+
<div
|
|
141
|
+
id={cellUniqueId}
|
|
142
|
+
className="table-cell-corrective-width-element"
|
|
143
|
+
style={{ height: '1px', marginTop: '-1px' }}
|
|
144
|
+
></div>
|
|
145
|
+
)}
|
|
111
146
|
{children}
|
|
112
147
|
</>
|
|
113
148
|
)}
|