@patternfly/react-table 4.110.22 → 4.111.0
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 +11 -0
- package/dist/esm/components/Table/base/provider.d.ts +1 -1
- package/dist/esm/components/Table/base/types.d.ts +1 -1
- package/dist/esm/components/TableComposable/Td.d.ts +10 -1
- package/dist/esm/components/TableComposable/Td.d.ts.map +1 -1
- package/dist/esm/components/TableComposable/Td.js +15 -2
- package/dist/esm/components/TableComposable/Td.js.map +1 -1
- package/dist/esm/components/TableComposable/Th.d.ts +4 -4
- package/dist/esm/components/TableComposable/Th.js +2 -2
- package/dist/esm/components/TableComposable/Th.js.map +1 -1
- package/dist/js/components/Table/base/provider.d.ts +1 -1
- package/dist/js/components/Table/base/types.d.ts +1 -1
- package/dist/js/components/TableComposable/Td.d.ts +10 -1
- package/dist/js/components/TableComposable/Td.d.ts.map +1 -1
- package/dist/js/components/TableComposable/Td.js +15 -2
- package/dist/js/components/TableComposable/Td.js.map +1 -1
- package/dist/js/components/TableComposable/Th.d.ts +4 -4
- package/dist/js/components/TableComposable/Th.js +2 -2
- package/dist/js/components/TableComposable/Th.js.map +1 -1
- package/dist/umd/react-table.css +1397 -1397
- package/dist/umd/react-table.js +16 -4
- package/dist/umd/react-table.min.css +1529 -1529
- package/dist/umd/react-table.min.js +1 -1
- package/package.json +3 -3
- package/src/components/TableComposable/Td.tsx +33 -1
- package/src/components/TableComposable/Th.tsx +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.111.0",
|
|
4
4
|
"description": "This library provides a set of React table components for use with the PatternFly 4",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"clean": "rimraf dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@patternfly/react-core": "^4.
|
|
34
|
+
"@patternfly/react-core": "^4.248.0",
|
|
35
35
|
"@patternfly/react-icons": "^4.92.5",
|
|
36
36
|
"@patternfly/react-styles": "^4.91.5",
|
|
37
37
|
"@patternfly/react-tokens": "^4.93.5",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react": "^16.8 || ^17 || ^18",
|
|
47
47
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "3e99a769dc61cb0c1506c3f2e6a868541a62d0cc"
|
|
50
50
|
}
|
|
@@ -13,6 +13,7 @@ import { draggable } from '../Table/utils/decorators/draggable';
|
|
|
13
13
|
import { treeRow } from '../Table/utils/decorators/treeRow';
|
|
14
14
|
import { mergeProps } from '../Table/base/merge-props';
|
|
15
15
|
import { IVisibility } from '../Table/utils/decorators/classNames';
|
|
16
|
+
import { Tooltip } from '@patternfly/react-core/dist/esm/components/Tooltip/Tooltip';
|
|
16
17
|
import { IFormatterValueType, IExtra } from '../Table/TableTypes';
|
|
17
18
|
import {
|
|
18
19
|
TdActionsType,
|
|
@@ -47,6 +48,15 @@ export interface TdProps extends BaseCellProps, Omit<React.HTMLProps<HTMLTableDa
|
|
|
47
48
|
noPadding?: boolean;
|
|
48
49
|
/** Applies pf-c-table__action to td */
|
|
49
50
|
isActionCell?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Tooltip to show on the body cell.
|
|
53
|
+
* Note: If the body cell is truncated and has simple string content, it will already attempt to display the cell text.
|
|
54
|
+
* If you want to show a tooltip that differs from the cell text, you can set it here.
|
|
55
|
+
* To disable it completely you can set it to null.
|
|
56
|
+
*/
|
|
57
|
+
tooltip?: React.ReactNode;
|
|
58
|
+
/** Callback on mouse enter */
|
|
59
|
+
onMouseEnter?: (event: any) => void;
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
const TdBase: React.FunctionComponent<TdProps> = ({
|
|
@@ -68,8 +78,20 @@ const TdBase: React.FunctionComponent<TdProps> = ({
|
|
|
68
78
|
innerRef,
|
|
69
79
|
favorites = null,
|
|
70
80
|
draggableRow: draggableRowProp = null,
|
|
81
|
+
tooltip = '',
|
|
82
|
+
onMouseEnter: onMouseEnterProp = () => {},
|
|
71
83
|
...props
|
|
72
84
|
}: TdProps) => {
|
|
85
|
+
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
86
|
+
const onMouseEnter = (event: any) => {
|
|
87
|
+
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
88
|
+
!showTooltip && setShowTooltip(true);
|
|
89
|
+
} else {
|
|
90
|
+
showTooltip && setShowTooltip(false);
|
|
91
|
+
}
|
|
92
|
+
onMouseEnterProp(event);
|
|
93
|
+
};
|
|
94
|
+
|
|
73
95
|
const selectParams = select
|
|
74
96
|
? selectable(children as IFormatterValueType, {
|
|
75
97
|
rowIndex: select.rowIndex,
|
|
@@ -208,9 +230,10 @@ const TdBase: React.FunctionComponent<TdProps> = ({
|
|
|
208
230
|
(className && className.includes('pf-c-table__tree-view-title-cell')) ||
|
|
209
231
|
(mergedClassName && mergedClassName.includes('pf-c-table__tree-view-title-cell'));
|
|
210
232
|
|
|
211
|
-
|
|
233
|
+
const cell = (
|
|
212
234
|
<MergedComponent
|
|
213
235
|
{...(!treeTableTitleCell && { 'data-label': dataLabel })}
|
|
236
|
+
onMouseEnter={tooltip !== null ? onMouseEnter : onMouseEnterProp}
|
|
214
237
|
className={css(
|
|
215
238
|
className,
|
|
216
239
|
isActionCell && styles.tableAction,
|
|
@@ -227,6 +250,15 @@ const TdBase: React.FunctionComponent<TdProps> = ({
|
|
|
227
250
|
{mergedChildren || children}
|
|
228
251
|
</MergedComponent>
|
|
229
252
|
);
|
|
253
|
+
|
|
254
|
+
const canMakeDefaultTooltip = tooltip === '' ? typeof children === 'string' : true;
|
|
255
|
+
return tooltip !== null && canMakeDefaultTooltip && showTooltip ? (
|
|
256
|
+
<Tooltip content={tooltip || (tooltip === '' && children)} isVisible>
|
|
257
|
+
{cell}
|
|
258
|
+
</Tooltip>
|
|
259
|
+
) : (
|
|
260
|
+
cell
|
|
261
|
+
);
|
|
230
262
|
};
|
|
231
263
|
|
|
232
264
|
export const Td = React.forwardRef((props: TdProps, ref: React.Ref<HTMLTableDataCellElement>) => (
|
|
@@ -30,10 +30,10 @@ export interface ThProps
|
|
|
30
30
|
/** Formats the header so that its column will be sortable */
|
|
31
31
|
sort?: ThSortType;
|
|
32
32
|
/**
|
|
33
|
-
* Tooltip to show on the header cell
|
|
34
|
-
* Note: If the header cell is truncated and has simple string content, it will already attempt to display the header text
|
|
35
|
-
* If you want to show a tooltip that differs from the header text, you can set it here
|
|
36
|
-
* To disable it completely you can set it to null
|
|
33
|
+
* Tooltip to show on the header cell.
|
|
34
|
+
* Note: If the header cell is truncated and has simple string content, it will already attempt to display the header text.
|
|
35
|
+
* If you want to show a tooltip that differs from the header text, you can set it here.
|
|
36
|
+
* To disable it completely you can set it to null.
|
|
37
37
|
*/
|
|
38
38
|
tooltip?: React.ReactNode;
|
|
39
39
|
/** Callback on mouse enter */
|
|
@@ -183,8 +183,8 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
183
183
|
</MergedComponent>
|
|
184
184
|
);
|
|
185
185
|
|
|
186
|
-
const
|
|
187
|
-
return tooltip !== null &&
|
|
186
|
+
const canMakeDefaultTooltip = tooltip === '' ? typeof children === 'string' : true;
|
|
187
|
+
return tooltip !== null && canMakeDefaultTooltip && showTooltip ? (
|
|
188
188
|
<Tooltip content={tooltip || (tooltip === '' && children)} isVisible>
|
|
189
189
|
{cell}
|
|
190
190
|
</Tooltip>
|