@patternfly/react-table 6.0.0-alpha.4 → 6.0.0-alpha.40
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 +500 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/Table/package.json +1 -1
- package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
- package/dist/dynamic/components/Table/utils/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/esm/components/Table/EditableTextCell.js +1 -1
- package/dist/esm/components/Table/EditableTextCell.js.map +1 -1
- package/dist/esm/components/Table/SelectColumn.d.ts +5 -0
- package/dist/esm/components/Table/SelectColumn.d.ts.map +1 -1
- package/dist/esm/components/Table/SelectColumn.js +6 -3
- package/dist/esm/components/Table/SelectColumn.js.map +1 -1
- package/dist/esm/components/Table/SortColumn.d.ts +4 -0
- package/dist/esm/components/Table/SortColumn.d.ts.map +1 -1
- package/dist/esm/components/Table/SortColumn.js +2 -2
- package/dist/esm/components/Table/SortColumn.js.map +1 -1
- package/dist/esm/components/Table/Table.js +2 -2
- package/dist/esm/components/Table/TableText.d.ts +3 -1
- package/dist/esm/components/Table/TableText.d.ts.map +1 -1
- package/dist/esm/components/Table/TableText.js +12 -10
- package/dist/esm/components/Table/TableText.js.map +1 -1
- package/dist/esm/components/Table/TableTypes.d.ts +3 -0
- package/dist/esm/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/esm/components/Table/Td.d.ts +1 -1
- package/dist/esm/components/Table/Th.d.ts +3 -0
- package/dist/esm/components/Table/Th.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.js +14 -7
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/selectable.d.ts.map +1 -1
- package/dist/esm/components/Table/utils/decorators/selectable.js +2 -2
- package/dist/esm/components/Table/utils/decorators/selectable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.d.ts.map +1 -1
- package/dist/esm/components/Table/utils/decorators/sortable.js +6 -3
- package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/treeRow.d.ts +1 -1
- package/dist/esm/demos/DashboardHeader.d.ts +8 -0
- package/dist/esm/demos/DashboardHeader.d.ts.map +1 -0
- package/dist/esm/demos/DashboardHeader.js +77 -0
- package/dist/esm/demos/DashboardHeader.js.map +1 -0
- package/dist/esm/demos/DashboardWrapper.d.ts +85 -0
- package/dist/esm/demos/DashboardWrapper.d.ts.map +1 -0
- package/dist/esm/demos/DashboardWrapper.js +41 -0
- package/dist/esm/demos/DashboardWrapper.js.map +1 -0
- package/dist/esm/demos/index.d.ts +2 -0
- package/dist/esm/demos/index.d.ts.map +1 -1
- package/dist/esm/demos/index.js +2 -0
- package/dist/esm/demos/index.js.map +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.js +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/js/components/Table/EditableTextCell.js +1 -1
- package/dist/js/components/Table/EditableTextCell.js.map +1 -1
- package/dist/js/components/Table/SelectColumn.d.ts +5 -0
- package/dist/js/components/Table/SelectColumn.d.ts.map +1 -1
- package/dist/js/components/Table/SelectColumn.js +6 -3
- package/dist/js/components/Table/SelectColumn.js.map +1 -1
- package/dist/js/components/Table/SortColumn.d.ts +4 -0
- package/dist/js/components/Table/SortColumn.d.ts.map +1 -1
- package/dist/js/components/Table/SortColumn.js +3 -2
- package/dist/js/components/Table/SortColumn.js.map +1 -1
- package/dist/js/components/Table/Table.js +2 -2
- package/dist/js/components/Table/TableText.d.ts +3 -1
- package/dist/js/components/Table/TableText.d.ts.map +1 -1
- package/dist/js/components/Table/TableText.js +12 -10
- package/dist/js/components/Table/TableText.js.map +1 -1
- package/dist/js/components/Table/TableTypes.d.ts +3 -0
- package/dist/js/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/js/components/Table/Td.d.ts +1 -1
- package/dist/js/components/Table/Th.d.ts +3 -0
- package/dist/js/components/Table/Th.d.ts.map +1 -1
- package/dist/js/components/Table/Th.js +14 -7
- package/dist/js/components/Table/Th.js.map +1 -1
- package/dist/js/components/Table/utils/decorators/selectable.d.ts.map +1 -1
- package/dist/js/components/Table/utils/decorators/selectable.js +2 -2
- package/dist/js/components/Table/utils/decorators/selectable.js.map +1 -1
- package/dist/js/components/Table/utils/decorators/sortable.d.ts.map +1 -1
- package/dist/js/components/Table/utils/decorators/sortable.js +6 -3
- package/dist/js/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/js/components/Table/utils/decorators/treeRow.d.ts +1 -1
- package/dist/js/demos/DashboardHeader.d.ts +8 -0
- package/dist/js/demos/DashboardHeader.d.ts.map +1 -0
- package/dist/js/demos/DashboardHeader.js +82 -0
- package/dist/js/demos/DashboardHeader.js.map +1 -0
- package/dist/js/demos/DashboardWrapper.d.ts +85 -0
- package/dist/js/demos/DashboardWrapper.d.ts.map +1 -0
- package/dist/js/demos/DashboardWrapper.js +45 -0
- package/dist/js/demos/DashboardWrapper.js.map +1 -0
- package/dist/js/demos/index.d.ts +2 -0
- package/dist/js/demos/index.d.ts.map +1 -1
- package/dist/js/demos/index.js +2 -0
- package/dist/js/demos/index.js.map +1 -1
- package/dist/umd/react-table.min.js +3 -3
- package/package.json +6 -6
- package/single-packages.config.json +3 -6
- package/src/components/Table/EditableSelectInputCell.tsx +1 -1
- package/src/components/Table/EditableTextCell.tsx +1 -1
- package/src/components/Table/SelectColumn.tsx +27 -8
- package/src/components/Table/SortColumn.tsx +15 -1
- package/src/components/Table/Table.tsx +2 -2
- package/src/components/Table/TableText.tsx +19 -9
- package/src/components/Table/TableTypes.tsx +3 -0
- package/src/components/Table/Td.tsx +1 -1
- package/src/components/Table/Th.tsx +16 -5
- package/src/components/Table/__tests__/__snapshots__/RowWrapper.test.tsx.snap +2 -2
- package/src/components/Table/examples/TableEmptyState.tsx +1 -8
- package/src/components/Table/utils/__snapshots__/transformers.test.tsx.snap +2 -2
- package/src/components/Table/utils/decorators/selectable.tsx +2 -1
- package/src/components/Table/utils/decorators/sortable.tsx +8 -2
- package/src/demos/DashboardHeader.tsx +198 -0
- package/src/demos/DashboardWrapper.tsx +199 -0
- package/src/demos/Table.md +28 -4
- package/src/demos/assets/avatarImg.svg +18 -0
- package/src/demos/assets/index.d.ts +4 -0
- package/src/demos/assets/pf-logo.svg +28 -0
- package/src/demos/examples/TableBulkSelect.tsx +1 -1
- package/src/demos/examples/TableColumnManagement.tsx +1 -1
- package/src/demos/examples/TableCompact.tsx +1 -1
- package/src/demos/examples/TableCompoundExpansion.tsx +1 -1
- package/src/demos/examples/TableEmptyStateDefault.tsx +1 -1
- package/src/demos/examples/TableEmptyStateError.tsx +1 -1
- package/src/demos/examples/TableEmptyStateLoading.tsx +1 -1
- package/src/demos/examples/TableExpandCollapseAll.tsx +1 -1
- package/src/demos/examples/TableSortableResponsive.tsx +4 -3
- package/src/demos/examples/TableStaticBottomPagination.tsx +1 -1
- package/src/demos/examples/TableStickyFirstColumn.tsx +1 -1
- package/src/demos/examples/TableStickyHeader.tsx +1 -1
- package/src/demos/index.ts +2 -0
- package/src/deprecated/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +1665 -1665
- package/src/deprecated/components/Table/examples/LegacyTableEmptyState.tsx +6 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.40",
|
|
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",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@patternfly/react-core": "^6.0.0-alpha.
|
|
44
|
-
"@patternfly/react-icons": "^6.0.0-alpha.
|
|
45
|
-
"@patternfly/react-styles": "^6.0.0-alpha.
|
|
46
|
-
"@patternfly/react-tokens": "^6.0.0-alpha.
|
|
43
|
+
"@patternfly/react-core": "^6.0.0-alpha.40",
|
|
44
|
+
"@patternfly/react-icons": "^6.0.0-alpha.15",
|
|
45
|
+
"@patternfly/react-styles": "^6.0.0-alpha.15",
|
|
46
|
+
"@patternfly/react-tokens": "^6.0.0-alpha.15",
|
|
47
47
|
"lodash": "^4.17.19",
|
|
48
48
|
"tslib": "^2.5.0"
|
|
49
49
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react": "^17 || ^18",
|
|
56
56
|
"react-dom": "^17 || ^18"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "296ac2be2f24ef201a347384c1561a311d0c8c54"
|
|
59
59
|
}
|
|
@@ -76,7 +76,7 @@ export const EditableSelectInputCell: React.FunctionComponent<IEditableSelectInp
|
|
|
76
76
|
<div className={inlineStyles.inlineEditValue}>{Array.isArray(value) ? value.join(', ') : value}</div>
|
|
77
77
|
<div className={inlineStyles.inlineEditInput}>
|
|
78
78
|
{select}
|
|
79
|
-
<div className={css(formStyles.formHelperText
|
|
79
|
+
<div className={css(formStyles.formHelperText)} aria-live="polite">
|
|
80
80
|
{props.errorText}
|
|
81
81
|
</div>
|
|
82
82
|
</div>
|
|
@@ -49,7 +49,7 @@ export const EditableTextCell: React.FunctionComponent<IEditableTextCell> = ({
|
|
|
49
49
|
}}
|
|
50
50
|
aria-label={inputAriaLabel}
|
|
51
51
|
/>
|
|
52
|
-
<div className={css(formStyles.formHelperText
|
|
52
|
+
<div className={css(formStyles.formHelperText)} aria-live="polite">
|
|
53
53
|
{props.errorText}
|
|
54
54
|
</div>
|
|
55
55
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { Tooltip, TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
|
|
2
3
|
|
|
3
4
|
export enum RowSelectVariant {
|
|
4
5
|
radio = 'radio',
|
|
@@ -11,6 +12,10 @@ export interface SelectColumnProps {
|
|
|
11
12
|
className?: string;
|
|
12
13
|
onSelect?: (event: React.FormEvent<HTMLInputElement>) => void;
|
|
13
14
|
selectVariant?: RowSelectVariant;
|
|
15
|
+
/** text to display on the tooltip */
|
|
16
|
+
tooltip?: React.ReactNode;
|
|
17
|
+
/** other props to pass to the tooltip */
|
|
18
|
+
tooltipProps?: Omit<TooltipProps, 'content'>;
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export const SelectColumn: React.FunctionComponent<SelectColumnProps> = ({
|
|
@@ -19,13 +24,27 @@ export const SelectColumn: React.FunctionComponent<SelectColumnProps> = ({
|
|
|
19
24
|
className,
|
|
20
25
|
onSelect = null as (event: React.FormEvent<HTMLInputElement>) => void,
|
|
21
26
|
selectVariant,
|
|
27
|
+
tooltip,
|
|
28
|
+
tooltipProps,
|
|
22
29
|
...props
|
|
23
|
-
}: SelectColumnProps) =>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
}: SelectColumnProps) => {
|
|
31
|
+
const inputRef = React.createRef<HTMLInputElement>();
|
|
32
|
+
|
|
33
|
+
const content = (
|
|
34
|
+
<React.Fragment>
|
|
35
|
+
<label>
|
|
36
|
+
<input {...props} ref={inputRef} type={selectVariant} onChange={onSelect} />
|
|
37
|
+
</label>
|
|
38
|
+
{children}
|
|
39
|
+
</React.Fragment>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return tooltip ? (
|
|
43
|
+
<Tooltip triggerRef={inputRef} content={tooltip} {...tooltipProps}>
|
|
44
|
+
{content}
|
|
45
|
+
</Tooltip>
|
|
46
|
+
) : (
|
|
47
|
+
content
|
|
48
|
+
);
|
|
49
|
+
};
|
|
31
50
|
SelectColumn.displayName = 'SelectColumn';
|
|
@@ -5,6 +5,7 @@ import ArrowsAltVIcon from '@patternfly/react-icons/dist/esm/icons/arrows-alt-v-
|
|
|
5
5
|
import { css } from '@patternfly/react-styles';
|
|
6
6
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
7
7
|
import { TableText } from './TableText';
|
|
8
|
+
import { TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
|
|
8
9
|
|
|
9
10
|
export enum SortByDirection {
|
|
10
11
|
asc = 'asc',
|
|
@@ -17,6 +18,9 @@ export interface SortColumnProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
17
18
|
isSortedBy?: boolean;
|
|
18
19
|
onSort?: Function;
|
|
19
20
|
sortDirection?: string;
|
|
21
|
+
tooltip?: React.ReactNode;
|
|
22
|
+
tooltipProps?: Omit<TooltipProps, 'content'>;
|
|
23
|
+
tooltipHasDefaultBehavior?: boolean;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
|
|
@@ -26,6 +30,9 @@ export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
|
|
|
26
30
|
onSort = null,
|
|
27
31
|
sortDirection = '',
|
|
28
32
|
type = 'button',
|
|
33
|
+
tooltip,
|
|
34
|
+
tooltipProps,
|
|
35
|
+
tooltipHasDefaultBehavior,
|
|
29
36
|
...props
|
|
30
37
|
}: SortColumnProps) => {
|
|
31
38
|
let SortedByIcon;
|
|
@@ -45,7 +52,14 @@ export const SortColumn: React.FunctionComponent<SortColumnProps> = ({
|
|
|
45
52
|
onBlur={() => setFocused(false)}
|
|
46
53
|
>
|
|
47
54
|
<div className={css(className, styles.tableButtonContent)}>
|
|
48
|
-
<TableText
|
|
55
|
+
<TableText
|
|
56
|
+
tooltip={tooltip}
|
|
57
|
+
tooltipProps={tooltipProps}
|
|
58
|
+
tooltipHasDefaultBehavior={tooltipHasDefaultBehavior}
|
|
59
|
+
focused={focused}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</TableText>
|
|
49
63
|
<span className={css(styles.tableSortIndicator)}>
|
|
50
64
|
<SortedByIcon />
|
|
51
65
|
</span>
|
|
@@ -124,7 +124,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
124
124
|
setTableCaption(
|
|
125
125
|
<caption>
|
|
126
126
|
{selectableRowCaptionText}
|
|
127
|
-
<div className="pf-
|
|
127
|
+
<div className="pf-v6-screen-reader">
|
|
128
128
|
This table has selectable rows. It can be navigated by row using tab, and each row can be selected using
|
|
129
129
|
space or enter.
|
|
130
130
|
</div>
|
|
@@ -132,7 +132,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
132
132
|
);
|
|
133
133
|
} else {
|
|
134
134
|
setTableCaption(
|
|
135
|
-
<caption className="pf-
|
|
135
|
+
<caption className="pf-v6-screen-reader">
|
|
136
136
|
This table has selectable rows. It can be navigated by row using tab, and each row can be selected using space
|
|
137
137
|
or enter.
|
|
138
138
|
</caption>
|
|
@@ -26,13 +26,15 @@ export interface TableTextProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
26
26
|
/** Determines which wrapping modifier to apply to the table text */
|
|
27
27
|
wrapModifier?: WrapModifier | 'wrap' | 'nowrap' | 'truncate' | 'breakWord' | 'fitContent';
|
|
28
28
|
/** text to display on the tooltip */
|
|
29
|
-
tooltip?:
|
|
29
|
+
tooltip?: React.ReactNode;
|
|
30
30
|
/** other props to pass to the tooltip */
|
|
31
31
|
tooltipProps?: Omit<TooltipProps, 'content'>;
|
|
32
32
|
/** callback used to create the tooltip if text is truncated */
|
|
33
33
|
onMouseEnter?: (event: any) => void;
|
|
34
34
|
/** Determines if the TableText is focused by parent component */
|
|
35
35
|
focused?: boolean;
|
|
36
|
+
/** Determines if tooltip should have normal visbility behavior. If false, the tooltip will only be shown when children is not entirely visible */
|
|
37
|
+
tooltipHasDefaultBehavior?: boolean;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export const TableText: React.FunctionComponent<TableTextProps> = ({
|
|
@@ -44,12 +46,13 @@ export const TableText: React.FunctionComponent<TableTextProps> = ({
|
|
|
44
46
|
tooltipProps = {},
|
|
45
47
|
onMouseEnter: onMouseEnterProp = () => {},
|
|
46
48
|
focused = false,
|
|
49
|
+
tooltipHasDefaultBehavior = false,
|
|
47
50
|
...props
|
|
48
51
|
}: TableTextProps) => {
|
|
49
52
|
const Component: TableTextVariant | 'span' | 'div' = variant;
|
|
50
53
|
const textRef = React.createRef<HTMLElement>();
|
|
51
54
|
|
|
52
|
-
const [tooltip, setTooltip] = React.useState(
|
|
55
|
+
const [tooltip, setTooltip] = React.useState(tooltipProp);
|
|
53
56
|
const onMouseEnter = (event: any) => {
|
|
54
57
|
if (event.target.offsetWidth < event.target.scrollWidth) {
|
|
55
58
|
setTooltip(tooltipProp || event.target.innerText);
|
|
@@ -70,7 +73,7 @@ export const TableText: React.FunctionComponent<TableTextProps> = ({
|
|
|
70
73
|
const text = (
|
|
71
74
|
<Component
|
|
72
75
|
ref={textRef as React.Ref<HTMLDivElement>}
|
|
73
|
-
onMouseEnter={onMouseEnter}
|
|
76
|
+
onMouseEnter={!tooltipHasDefaultBehavior ? onMouseEnter : undefined}
|
|
74
77
|
className={css(className, wrapModifier && styles.modifiers[wrapModifier], styles.tableText)}
|
|
75
78
|
{...props}
|
|
76
79
|
>
|
|
@@ -79,15 +82,22 @@ export const TableText: React.FunctionComponent<TableTextProps> = ({
|
|
|
79
82
|
);
|
|
80
83
|
|
|
81
84
|
React.useEffect(() => {
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
if (!tooltipHasDefaultBehavior) {
|
|
86
|
+
if (focused) {
|
|
87
|
+
onFocus(textRef.current);
|
|
88
|
+
} else {
|
|
89
|
+
setTooltip('');
|
|
90
|
+
}
|
|
86
91
|
}
|
|
87
|
-
}, [focused]);
|
|
92
|
+
}, [focused, tooltipHasDefaultBehavior]);
|
|
88
93
|
|
|
89
94
|
return tooltip !== '' ? (
|
|
90
|
-
<Tooltip
|
|
95
|
+
<Tooltip
|
|
96
|
+
triggerRef={textRef}
|
|
97
|
+
content={tooltip}
|
|
98
|
+
{...(!tooltipHasDefaultBehavior && { isVisible: true })}
|
|
99
|
+
{...tooltipProps}
|
|
100
|
+
>
|
|
91
101
|
{text}
|
|
92
102
|
</Tooltip>
|
|
93
103
|
) : (
|
|
@@ -132,6 +132,9 @@ export interface IExtra extends IExtraData {
|
|
|
132
132
|
rowData?: IRowData;
|
|
133
133
|
className?: string;
|
|
134
134
|
ariaLabel?: string;
|
|
135
|
+
tooltip?: React.ReactNode;
|
|
136
|
+
tooltipProps?: Omit<TooltipProps, 'content'>;
|
|
137
|
+
tooltipHasDefaultBehavior?: boolean;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
140
|
export type IFormatterValueType = formatterValueType & {
|
|
@@ -55,7 +55,7 @@ export interface TdProps extends BaseCellProps, Omit<React.HTMLProps<HTMLTableDa
|
|
|
55
55
|
draggableRow?: TdDraggableType;
|
|
56
56
|
/** True to remove padding */
|
|
57
57
|
noPadding?: boolean;
|
|
58
|
-
/** Applies pf-
|
|
58
|
+
/** Applies pf-v6-c-table__action to td */
|
|
59
59
|
isActionCell?: boolean;
|
|
60
60
|
/**
|
|
61
61
|
* Tooltip to show on the body cell.
|
|
@@ -6,7 +6,7 @@ import { info, sortable, sortableFavorites, selectable, collapsible, cellWidth,
|
|
|
6
6
|
import { ThInfoType, ThSelectType, ThExpandType, ThSortType, formatterValueType } from './base/types';
|
|
7
7
|
import { mergeProps } from './base/merge-props';
|
|
8
8
|
import { IVisibility } from './utils/decorators/classNames';
|
|
9
|
-
import { Tooltip } from '@patternfly/react-core/dist/esm/components/Tooltip
|
|
9
|
+
import { Tooltip, TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
|
|
10
10
|
import { BaseCellProps } from './Table';
|
|
11
11
|
import { IFormatterValueType, IColumn } from './TableTypes';
|
|
12
12
|
import cssStickyCellMinWidth from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_MinWidth';
|
|
@@ -34,6 +34,8 @@ export interface ThProps
|
|
|
34
34
|
* To disable it completely you can set it to null.
|
|
35
35
|
*/
|
|
36
36
|
tooltip?: React.ReactNode;
|
|
37
|
+
/** other props to pass to the tooltip */
|
|
38
|
+
tooltipProps?: Omit<TooltipProps, 'content'>;
|
|
37
39
|
/** Callback on mouse enter */
|
|
38
40
|
onMouseEnter?: (event: any) => void;
|
|
39
41
|
/** Adds tooltip/popover info button */
|
|
@@ -68,6 +70,7 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
68
70
|
select = null,
|
|
69
71
|
expand: collapse = null,
|
|
70
72
|
tooltip = '',
|
|
73
|
+
tooltipProps,
|
|
71
74
|
onMouseEnter: onMouseEnterProp = () => {},
|
|
72
75
|
width,
|
|
73
76
|
visibility,
|
|
@@ -99,7 +102,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
99
102
|
sortParams = sortableFavorites({
|
|
100
103
|
onSort: sort?.onSort,
|
|
101
104
|
columnIndex: sort.columnIndex,
|
|
102
|
-
sortBy: sort.sortBy
|
|
105
|
+
sortBy: sort.sortBy,
|
|
106
|
+
tooltip: tooltip as string,
|
|
107
|
+
tooltipProps
|
|
103
108
|
})();
|
|
104
109
|
} else {
|
|
105
110
|
sortParams = sortable(children as IFormatterValueType, {
|
|
@@ -109,7 +114,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
109
114
|
sortBy: sort.sortBy,
|
|
110
115
|
onSort: sort?.onSort
|
|
111
116
|
}
|
|
112
|
-
} as IColumn
|
|
117
|
+
} as IColumn,
|
|
118
|
+
tooltip: tooltip as string,
|
|
119
|
+
tooltipProps
|
|
113
120
|
});
|
|
114
121
|
}
|
|
115
122
|
}
|
|
@@ -127,7 +134,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
127
134
|
allRowsSelected: select.isSelected,
|
|
128
135
|
isHeaderSelectDisabled: !!select.isHeaderSelectDisabled
|
|
129
136
|
}
|
|
130
|
-
}
|
|
137
|
+
},
|
|
138
|
+
tooltip: tooltip as string,
|
|
139
|
+
tooltipProps
|
|
131
140
|
})
|
|
132
141
|
: null;
|
|
133
142
|
const collapseParams = collapse
|
|
@@ -208,13 +217,15 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
208
217
|
);
|
|
209
218
|
|
|
210
219
|
const canMakeDefaultTooltip = tooltip === '' ? typeof transformedChildren === 'string' : true;
|
|
211
|
-
|
|
220
|
+
const childControlsTooltip = sortParams || selectParams;
|
|
221
|
+
return tooltip !== null && canMakeDefaultTooltip && !childControlsTooltip && showTooltip ? (
|
|
212
222
|
<>
|
|
213
223
|
{cell}
|
|
214
224
|
<Tooltip
|
|
215
225
|
triggerRef={cellRef as React.RefObject<any>}
|
|
216
226
|
content={tooltip || (tooltip === '' && children)}
|
|
217
227
|
isVisible
|
|
228
|
+
{...tooltipProps}
|
|
218
229
|
/>
|
|
219
230
|
</>
|
|
220
231
|
) : (
|
|
@@ -5,7 +5,7 @@ exports[`RowWrapper renders correctly 1`] = `
|
|
|
5
5
|
<table>
|
|
6
6
|
<tbody>
|
|
7
7
|
<tr
|
|
8
|
-
class="pf-
|
|
8
|
+
class="pf-v6-c-table__tr"
|
|
9
9
|
data-ouia-component-id="OUIA-Generated-TableRow-1"
|
|
10
10
|
data-ouia-component-type="PF5/TableRow"
|
|
11
11
|
data-ouia-safe="true"
|
|
@@ -20,7 +20,7 @@ exports[`RowWrapper renders expanded correctly 1`] = `
|
|
|
20
20
|
<table>
|
|
21
21
|
<tbody>
|
|
22
22
|
<tr
|
|
23
|
-
class="pf-
|
|
23
|
+
class="pf-v6-c-table__tr pf-v6-c-table__expandable-row pf-m-expanded"
|
|
24
24
|
data-ouia-component-id="OUIA-Generated-TableRow-2"
|
|
25
25
|
data-ouia-component-type="PF5/TableRow"
|
|
26
26
|
data-ouia-safe="true"
|
|
@@ -4,10 +4,8 @@ import {
|
|
|
4
4
|
Bullseye,
|
|
5
5
|
EmptyState,
|
|
6
6
|
EmptyStateVariant,
|
|
7
|
-
EmptyStateIcon,
|
|
8
7
|
EmptyStateBody,
|
|
9
8
|
Button,
|
|
10
|
-
EmptyStateHeader,
|
|
11
9
|
EmptyStateFooter,
|
|
12
10
|
EmptyStateActions
|
|
13
11
|
} from '@patternfly/react-core';
|
|
@@ -31,12 +29,7 @@ export const TableEmptyState: React.FunctionComponent = () => (
|
|
|
31
29
|
<Tr>
|
|
32
30
|
<Td colSpan={8}>
|
|
33
31
|
<Bullseye>
|
|
34
|
-
<EmptyState variant={EmptyStateVariant.sm}>
|
|
35
|
-
<EmptyStateHeader
|
|
36
|
-
icon={<EmptyStateIcon icon={SearchIcon} />}
|
|
37
|
-
titleText="No results found"
|
|
38
|
-
headingLevel="h2"
|
|
39
|
-
/>
|
|
32
|
+
<EmptyState headingLevel="h2" titleText="No results found" icon={SearchIcon} variant={EmptyStateVariant.sm}>
|
|
40
33
|
<EmptyStateBody>Clear all filters and try again.</EmptyStateBody>
|
|
41
34
|
<EmptyStateFooter>
|
|
42
35
|
<EmptyStateActions>
|
|
@@ -10,7 +10,7 @@ Object {
|
|
|
10
10
|
>
|
|
11
11
|
|
|
12
12
|
</SelectColumn>,
|
|
13
|
-
"className": "pf-
|
|
13
|
+
"className": "pf-v6-c-table__check",
|
|
14
14
|
"component": "td",
|
|
15
15
|
"isVisible": true,
|
|
16
16
|
}
|
|
@@ -26,6 +26,6 @@ Object {
|
|
|
26
26
|
>
|
|
27
27
|
|
|
28
28
|
</SortColumn>,
|
|
29
|
-
"className": "pf-
|
|
29
|
+
"className": "pf-v6-c-table__sort pf-m-selected",
|
|
30
30
|
}
|
|
31
31
|
`;
|
|
@@ -7,7 +7,7 @@ import checkStyles from '@patternfly/react-styles/css/components/Check/check';
|
|
|
7
7
|
|
|
8
8
|
export const selectable: ITransform = (
|
|
9
9
|
label: IFormatterValueType,
|
|
10
|
-
{ rowIndex, columnIndex, rowData, column, property }: IExtra
|
|
10
|
+
{ rowIndex, columnIndex, rowData, column, property, tooltip }: IExtra
|
|
11
11
|
) => {
|
|
12
12
|
const {
|
|
13
13
|
extraParams: { onSelect, selectVariant, allRowsSelected, isHeaderSelectDisabled }
|
|
@@ -69,6 +69,7 @@ export const selectable: ITransform = (
|
|
|
69
69
|
selectVariant={selectVariant as RowSelectVariant}
|
|
70
70
|
onSelect={selectClick}
|
|
71
71
|
name={selectName}
|
|
72
|
+
tooltip={tooltip}
|
|
72
73
|
>
|
|
73
74
|
{label as React.ReactNode}
|
|
74
75
|
</SelectColumn>
|
|
@@ -15,12 +15,15 @@ export const sortableFavorites = (sort: any) => () =>
|
|
|
15
15
|
sortBy: sort.sortBy,
|
|
16
16
|
onSort: sort?.onSort
|
|
17
17
|
}
|
|
18
|
-
}
|
|
18
|
+
},
|
|
19
|
+
tooltip: sort.tooltip,
|
|
20
|
+
tooltipProps: sort.tooltipProps,
|
|
21
|
+
tooltipHasDefaultBehavior: true
|
|
19
22
|
});
|
|
20
23
|
|
|
21
24
|
export const sortable: ITransform = (
|
|
22
25
|
label: IFormatterValueType,
|
|
23
|
-
{ columnIndex, column, property, className, ariaLabel }: IExtra
|
|
26
|
+
{ columnIndex, column, property, className, ariaLabel, tooltip, tooltipProps, tooltipHasDefaultBehavior }: IExtra
|
|
24
27
|
) => {
|
|
25
28
|
const {
|
|
26
29
|
extraParams: { sortBy, onSort }
|
|
@@ -56,6 +59,9 @@ export const sortable: ITransform = (
|
|
|
56
59
|
sortDirection={isSortedBy ? sortBy.direction : ''}
|
|
57
60
|
onSort={sortClicked}
|
|
58
61
|
aria-label={ariaLabel}
|
|
62
|
+
tooltip={tooltip}
|
|
63
|
+
tooltipProps={tooltipProps}
|
|
64
|
+
tooltipHasDefaultBehavior={tooltipHasDefaultBehavior}
|
|
59
65
|
>
|
|
60
66
|
{label as React.ReactNode}
|
|
61
67
|
</SortColumn>
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Avatar,
|
|
4
|
+
Brand,
|
|
5
|
+
Button,
|
|
6
|
+
ButtonVariant,
|
|
7
|
+
Divider,
|
|
8
|
+
Dropdown,
|
|
9
|
+
DropdownGroup,
|
|
10
|
+
DropdownItem,
|
|
11
|
+
DropdownList,
|
|
12
|
+
Masthead,
|
|
13
|
+
MastheadToggle,
|
|
14
|
+
MastheadMain,
|
|
15
|
+
MastheadBrand,
|
|
16
|
+
MastheadContent,
|
|
17
|
+
MenuToggle,
|
|
18
|
+
Toolbar,
|
|
19
|
+
ToolbarContent,
|
|
20
|
+
ToolbarGroup,
|
|
21
|
+
ToolbarItem,
|
|
22
|
+
PageToggleButton
|
|
23
|
+
} from '@patternfly/react-core';
|
|
24
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
25
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
26
|
+
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
27
|
+
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
28
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
29
|
+
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
30
|
+
import imgAvatar from '@patternfly/react-table/src/demos/assets/avatarImg.svg';
|
|
31
|
+
import pfLogo from '@patternfly/react-table/src/demos/assets/pf-logo.svg';
|
|
32
|
+
|
|
33
|
+
interface DashboardHeaderProps {
|
|
34
|
+
/** Render custom notification badge */
|
|
35
|
+
notificationBadge?: React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const DashboardHeader: React.FC<DashboardHeaderProps> = ({ notificationBadge }) => {
|
|
39
|
+
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
40
|
+
const [isKebabDropdownOpen, setIsKebabDropdownOpen] = useState(false);
|
|
41
|
+
const [isFullKebabDropdownOpen, setIsFullKebabDropdownOpen] = useState(false);
|
|
42
|
+
|
|
43
|
+
const kebabDropdownItems = (
|
|
44
|
+
<>
|
|
45
|
+
<DropdownItem>
|
|
46
|
+
<CogIcon /> Settings
|
|
47
|
+
</DropdownItem>
|
|
48
|
+
<DropdownItem>
|
|
49
|
+
<HelpIcon /> Help
|
|
50
|
+
</DropdownItem>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const userDropdownItems = (
|
|
55
|
+
<>
|
|
56
|
+
<DropdownItem key="group 2 profile">My profile</DropdownItem>
|
|
57
|
+
<DropdownItem key="group 2 user">User management</DropdownItem>
|
|
58
|
+
<DropdownItem key="group 2 logout">Logout</DropdownItem>
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const onDropdownToggle = () => {
|
|
63
|
+
setIsDropdownOpen(!isDropdownOpen);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const onDropdownSelect = () => {
|
|
67
|
+
setIsDropdownOpen(false);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onKebabDropdownToggle = () => {
|
|
71
|
+
setIsKebabDropdownOpen(!isKebabDropdownOpen);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const onKebabDropdownSelect = () => {
|
|
75
|
+
setIsKebabDropdownOpen(false);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const onFullKebabToggle = () => {
|
|
79
|
+
setIsFullKebabDropdownOpen(!isFullKebabDropdownOpen);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const onFullKebabSelect = () => {
|
|
83
|
+
setIsFullKebabDropdownOpen(false);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<Masthead>
|
|
88
|
+
<MastheadToggle>
|
|
89
|
+
<PageToggleButton variant="plain" aria-label="Global navigation">
|
|
90
|
+
<BarsIcon />
|
|
91
|
+
</PageToggleButton>
|
|
92
|
+
</MastheadToggle>
|
|
93
|
+
<MastheadMain>
|
|
94
|
+
<MastheadBrand>
|
|
95
|
+
<Brand src={pfLogo} alt="PatternFly" heights={{ default: '36px' }} />
|
|
96
|
+
</MastheadBrand>
|
|
97
|
+
</MastheadMain>
|
|
98
|
+
<MastheadContent>
|
|
99
|
+
<Toolbar id="toolbar" isFullHeight isStatic>
|
|
100
|
+
<ToolbarContent>
|
|
101
|
+
<ToolbarGroup
|
|
102
|
+
variant="icon-button-group"
|
|
103
|
+
align={{ default: 'alignRight' }}
|
|
104
|
+
spacer={{ default: 'spacerNone', md: 'spacerMd' }}
|
|
105
|
+
>
|
|
106
|
+
{notificationBadge ?? (
|
|
107
|
+
<ToolbarItem>
|
|
108
|
+
<Button
|
|
109
|
+
aria-label="Notifications"
|
|
110
|
+
variant={ButtonVariant.plain}
|
|
111
|
+
icon={<BellIcon />}
|
|
112
|
+
onClick={() => {}}
|
|
113
|
+
/>
|
|
114
|
+
</ToolbarItem>
|
|
115
|
+
)}
|
|
116
|
+
<ToolbarGroup variant="icon-button-group" visibility={{ default: 'hidden', lg: 'visible' }}>
|
|
117
|
+
<ToolbarItem>
|
|
118
|
+
<Button aria-label="Settings" variant={ButtonVariant.plain} icon={<CogIcon />} />
|
|
119
|
+
</ToolbarItem>
|
|
120
|
+
<ToolbarItem>
|
|
121
|
+
<Button aria-label="Help" variant={ButtonVariant.plain} icon={<QuestionCircleIcon />} />
|
|
122
|
+
</ToolbarItem>
|
|
123
|
+
</ToolbarGroup>
|
|
124
|
+
<ToolbarItem visibility={{ default: 'hidden', md: 'visible', lg: 'hidden' }}>
|
|
125
|
+
<Dropdown
|
|
126
|
+
isOpen={isKebabDropdownOpen}
|
|
127
|
+
onSelect={onKebabDropdownSelect}
|
|
128
|
+
onOpenChange={setIsKebabDropdownOpen}
|
|
129
|
+
popperProps={{ position: 'right' }}
|
|
130
|
+
toggle={(toggleRef: React.RefObject<any>) => (
|
|
131
|
+
<MenuToggle
|
|
132
|
+
ref={toggleRef}
|
|
133
|
+
isExpanded={isKebabDropdownOpen}
|
|
134
|
+
onClick={onKebabDropdownToggle}
|
|
135
|
+
variant="plain"
|
|
136
|
+
aria-label="Settings and help"
|
|
137
|
+
>
|
|
138
|
+
<EllipsisVIcon aria-hidden="true" />
|
|
139
|
+
</MenuToggle>
|
|
140
|
+
)}
|
|
141
|
+
>
|
|
142
|
+
<DropdownList>{kebabDropdownItems}</DropdownList>
|
|
143
|
+
</Dropdown>
|
|
144
|
+
</ToolbarItem>
|
|
145
|
+
<ToolbarItem visibility={{ md: 'hidden' }}>
|
|
146
|
+
<Dropdown
|
|
147
|
+
isOpen={isFullKebabDropdownOpen}
|
|
148
|
+
onSelect={onFullKebabSelect}
|
|
149
|
+
onOpenChange={setIsFullKebabDropdownOpen}
|
|
150
|
+
popperProps={{ position: 'right' }}
|
|
151
|
+
toggle={(toggleRef: React.RefObject<any>) => (
|
|
152
|
+
<MenuToggle
|
|
153
|
+
ref={toggleRef}
|
|
154
|
+
isExpanded={isFullKebabDropdownOpen}
|
|
155
|
+
onClick={onFullKebabToggle}
|
|
156
|
+
variant="plain"
|
|
157
|
+
aria-label="Toolbar menu"
|
|
158
|
+
>
|
|
159
|
+
<EllipsisVIcon aria-hidden="true" />
|
|
160
|
+
</MenuToggle>
|
|
161
|
+
)}
|
|
162
|
+
>
|
|
163
|
+
<DropdownGroup key="group 2" aria-label="User actions">
|
|
164
|
+
<DropdownList>{userDropdownItems}</DropdownList>
|
|
165
|
+
</DropdownGroup>
|
|
166
|
+
<Divider />
|
|
167
|
+
<DropdownList>{kebabDropdownItems}</DropdownList>
|
|
168
|
+
</Dropdown>
|
|
169
|
+
</ToolbarItem>
|
|
170
|
+
</ToolbarGroup>
|
|
171
|
+
<ToolbarItem visibility={{ default: 'hidden', md: 'visible' }}>
|
|
172
|
+
<Dropdown
|
|
173
|
+
isOpen={isDropdownOpen}
|
|
174
|
+
onSelect={onDropdownSelect}
|
|
175
|
+
onOpenChange={setIsDropdownOpen}
|
|
176
|
+
popperProps={{ position: 'right' }}
|
|
177
|
+
toggle={(toggleRef: React.RefObject<any>) => (
|
|
178
|
+
<MenuToggle
|
|
179
|
+
ref={toggleRef}
|
|
180
|
+
isExpanded={isDropdownOpen}
|
|
181
|
+
onClick={onDropdownToggle}
|
|
182
|
+
icon={<Avatar src={imgAvatar} alt="" />}
|
|
183
|
+
isFullHeight
|
|
184
|
+
>
|
|
185
|
+
Ned Username
|
|
186
|
+
</MenuToggle>
|
|
187
|
+
)}
|
|
188
|
+
>
|
|
189
|
+
<DropdownList>{userDropdownItems}</DropdownList>
|
|
190
|
+
</Dropdown>
|
|
191
|
+
</ToolbarItem>
|
|
192
|
+
</ToolbarContent>
|
|
193
|
+
</Toolbar>
|
|
194
|
+
</MastheadContent>
|
|
195
|
+
</Masthead>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
DashboardHeader.displayName = 'DashboardHeader';
|