@patternfly/react-table 6.0.0-alpha.5 → 6.0.0-alpha.51
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 +812 -18
- 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/ActionsColumn.d.ts +2 -0
- package/dist/esm/components/Table/ActionsColumn.d.ts.map +1 -1
- package/dist/esm/components/Table/ActionsColumn.js +4 -5
- package/dist/esm/components/Table/ActionsColumn.js.map +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 +5 -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 +11 -0
- package/dist/esm/components/Table/Th.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.js +20 -9
- 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 +3 -3
- 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/ActionsColumn.d.ts +2 -0
- package/dist/js/components/Table/ActionsColumn.d.ts.map +1 -1
- package/dist/js/components/Table/ActionsColumn.js +4 -5
- package/dist/js/components/Table/ActionsColumn.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 +5 -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 +11 -0
- package/dist/js/components/Table/Th.d.ts.map +1 -1
- package/dist/js/components/Table/Th.js +20 -9
- 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 +3 -3
- 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/ActionsColumn.tsx +35 -31
- 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 +5 -0
- package/src/components/Table/Td.tsx +1 -1
- package/src/components/Table/Th.tsx +36 -7
- package/src/components/Table/__tests__/Th.test.tsx +31 -0
- package/src/components/Table/__tests__/__snapshots__/RowWrapper.test.tsx.snap +2 -2
- package/src/components/Table/examples/TableActions.tsx +2 -2
- package/src/components/Table/examples/TableActionsOverflow.tsx +3 -4
- package/src/components/Table/examples/TableCompoundExpandable.tsx +1 -1
- package/src/components/Table/examples/TableDraggable.tsx +19 -16
- package/src/components/Table/examples/TableEmptyState.tsx +1 -8
- package/src/components/Table/examples/TableExpandable.tsx +1 -1
- package/src/components/Table/examples/TableNestedExpandable.tsx +1 -1
- package/src/components/Table/examples/TableNestedHeaders.tsx +4 -6
- package/src/components/Table/examples/TableNestedStickyHeader.tsx +4 -9
- package/src/components/Table/examples/TableNestedTableExpandable.tsx +1 -1
- package/src/components/Table/examples/TableSelectable.tsx +1 -0
- package/src/components/Table/examples/TableSelectableRadio.tsx +1 -1
- package/src/components/Table/examples/TableSortableCustom.tsx +2 -3
- package/src/components/Table/examples/TableStickyColumnsAndHeader.tsx +1 -1
- package/src/components/Table/examples/TableStripedExpandable.tsx +1 -1
- package/src/components/Table/utils/__snapshots__/transformers.test.tsx.snap +2 -2
- package/src/components/Table/utils/decorators/selectable.tsx +3 -2
- 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 +2 -2
- package/src/demos/examples/TableColumnManagement.tsx +1 -1
- package/src/demos/examples/TableColumnManagementWithDraggable.tsx +2 -6
- package/src/demos/examples/TableCompact.tsx +8 -3
- package/src/demos/examples/TableCompoundExpansion.tsx +4 -3
- 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 +3 -2
- package/src/demos/examples/TableSortableResponsive.tsx +8 -9
- package/src/demos/examples/TableStaticBottomPagination.tsx +8 -3
- 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 +1960 -1878
- package/src/deprecated/components/Table/examples/LegacyTableEmptyState.tsx +6 -8
- package/src/deprecated/components/Table/examples/LegacyTableSortableCustom.tsx +2 -3
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.51",
|
|
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.51",
|
|
44
|
+
"@patternfly/react-icons": "^6.0.0-alpha.20",
|
|
45
|
+
"@patternfly/react-styles": "^6.0.0-alpha.20",
|
|
46
|
+
"@patternfly/react-tokens": "^6.0.0-alpha.20",
|
|
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": "8d93660fcd63d544d8ef0f2ee6494cfe5f09379e"
|
|
59
59
|
}
|
|
@@ -30,6 +30,8 @@ export interface ActionsColumnProps extends Omit<React.HTMLProps<HTMLElement>, '
|
|
|
30
30
|
innerRef?: React.Ref<any>;
|
|
31
31
|
/** Ref to forward to the first item in the popup menu */
|
|
32
32
|
firstActionItemRef?: React.Ref<HTMLButtonElement>;
|
|
33
|
+
/** Flag indicating that the dropdown's onOpenChange callback should not be called. */
|
|
34
|
+
isOnOpenChangeDisabled?: boolean;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
const ActionsColumnBase: React.FunctionComponent<ActionsColumnProps> = ({
|
|
@@ -44,6 +46,7 @@ const ActionsColumnBase: React.FunctionComponent<ActionsColumnProps> = ({
|
|
|
44
46
|
},
|
|
45
47
|
innerRef,
|
|
46
48
|
firstActionItemRef,
|
|
49
|
+
isOnOpenChangeDisabled = false,
|
|
47
50
|
...props
|
|
48
51
|
}: ActionsColumnProps) => {
|
|
49
52
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
@@ -91,7 +94,7 @@ const ActionsColumnBase: React.FunctionComponent<ActionsColumnProps> = ({
|
|
|
91
94
|
|
|
92
95
|
<Dropdown
|
|
93
96
|
isOpen={isOpen}
|
|
94
|
-
onOpenChange={(isOpen: boolean) => setIsOpen(isOpen)}
|
|
97
|
+
onOpenChange={!isOnOpenChangeDisabled ? (isOpen: boolean) => setIsOpen(isOpen) : undefined}
|
|
95
98
|
toggle={(toggleRef: any) =>
|
|
96
99
|
actionsToggle ? (
|
|
97
100
|
actionsToggle({ onToggle, isOpen, isDisabled, toggleRef })
|
|
@@ -103,9 +106,8 @@ const ActionsColumnBase: React.FunctionComponent<ActionsColumnProps> = ({
|
|
|
103
106
|
isExpanded={isOpen}
|
|
104
107
|
isDisabled={isDisabled}
|
|
105
108
|
variant="plain"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</MenuToggle>
|
|
109
|
+
icon={<EllipsisVIcon />}
|
|
110
|
+
/>
|
|
109
111
|
)
|
|
110
112
|
}
|
|
111
113
|
{...(rowData && rowData.actionProps)}
|
|
@@ -116,35 +118,37 @@ const ActionsColumnBase: React.FunctionComponent<ActionsColumnProps> = ({
|
|
|
116
118
|
<DropdownList>
|
|
117
119
|
{items
|
|
118
120
|
.filter((item) => !item.isOutsideDropdown)
|
|
119
|
-
.map(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (tooltipProps?.content) {
|
|
139
|
-
return (
|
|
140
|
-
<Tooltip key={itemKey || index} {...tooltipProps}>
|
|
141
|
-
{item}
|
|
142
|
-
</Tooltip>
|
|
121
|
+
.map(
|
|
122
|
+
({ title, itemKey, onClick, tooltipProps, isSeparator, shouldCloseOnClick = true, ...props }, index) => {
|
|
123
|
+
if (isSeparator) {
|
|
124
|
+
return <Divider key={itemKey || index} data-key={itemKey || index} />;
|
|
125
|
+
}
|
|
126
|
+
const item = (
|
|
127
|
+
<DropdownItem
|
|
128
|
+
onClick={(event: any) => {
|
|
129
|
+
onActionClick(event, onClick);
|
|
130
|
+
shouldCloseOnClick && onToggle();
|
|
131
|
+
}}
|
|
132
|
+
{...props}
|
|
133
|
+
key={itemKey || index}
|
|
134
|
+
data-key={itemKey || index}
|
|
135
|
+
ref={index === 0 ? firstActionItemRef : undefined}
|
|
136
|
+
>
|
|
137
|
+
{title}
|
|
138
|
+
</DropdownItem>
|
|
143
139
|
);
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
|
|
141
|
+
if (tooltipProps?.content) {
|
|
142
|
+
return (
|
|
143
|
+
<Tooltip key={itemKey || index} {...tooltipProps}>
|
|
144
|
+
{item}
|
|
145
|
+
</Tooltip>
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
return item;
|
|
149
|
+
}
|
|
146
150
|
}
|
|
147
|
-
|
|
151
|
+
)}
|
|
148
152
|
</DropdownList>
|
|
149
153
|
</Dropdown>
|
|
150
154
|
</React.Fragment>
|
|
@@ -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 & {
|
|
@@ -163,6 +166,8 @@ export interface IAction extends Omit<DropdownItemProps, 'title' | 'onClick'>, P
|
|
|
163
166
|
onClick?: (event: React.MouseEvent, rowIndex: number, rowData: IRowData, extraData: IExtraData) => void;
|
|
164
167
|
/** Flag indicating this action should be placed outside the actions menu, beside the toggle */
|
|
165
168
|
isOutsideDropdown?: boolean;
|
|
169
|
+
/** Flag indicating whether the actions dropdown should close after an item is clicked. */
|
|
170
|
+
shouldCloseOnClick?: boolean;
|
|
166
171
|
}
|
|
167
172
|
|
|
168
173
|
export interface ISeparator extends IAction {
|
|
@@ -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 */
|
|
@@ -54,6 +56,14 @@ export interface ThProps
|
|
|
54
56
|
stickyRightOffset?: string;
|
|
55
57
|
/** Indicates the <th> is part of a subheader of a nested header */
|
|
56
58
|
isSubheader?: boolean;
|
|
59
|
+
/** Visually hidden text accessible only via assistive technologies. This must be passed in if the
|
|
60
|
+
* th is intended to be visually empty, and must be conveyed as a column header text.
|
|
61
|
+
*/
|
|
62
|
+
screenReaderText?: string;
|
|
63
|
+
/** Provides an accessible name to the th. This should only be passed in when the th contains only non-text
|
|
64
|
+
* content, such as a "select all" checkbox or "expand all" toggle.
|
|
65
|
+
*/
|
|
66
|
+
'aria-label'?: string;
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
const ThBase: React.FunctionComponent<ThProps> = ({
|
|
@@ -68,6 +78,7 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
68
78
|
select = null,
|
|
69
79
|
expand: collapse = null,
|
|
70
80
|
tooltip = '',
|
|
81
|
+
tooltipProps,
|
|
71
82
|
onMouseEnter: onMouseEnterProp = () => {},
|
|
72
83
|
width,
|
|
73
84
|
visibility,
|
|
@@ -80,8 +91,17 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
80
91
|
stickyLeftOffset,
|
|
81
92
|
stickyRightOffset,
|
|
82
93
|
isSubheader = false,
|
|
94
|
+
screenReaderText,
|
|
95
|
+
'aria-label': ariaLabel,
|
|
83
96
|
...props
|
|
84
97
|
}: ThProps) => {
|
|
98
|
+
if (!children && !screenReaderText && !ariaLabel) {
|
|
99
|
+
// eslint-disable-next-line no-console
|
|
100
|
+
console.warn(
|
|
101
|
+
'Th: Table headers must have an accessible name. If the Th is intended to be visually empty, pass in screenReaderText. If the Th contains only non-text, interactive content such as a checkbox or expand toggle, pass in an aria-label.'
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
85
105
|
const [showTooltip, setShowTooltip] = React.useState(false);
|
|
86
106
|
const [truncated, setTruncated] = React.useState(false);
|
|
87
107
|
const cellRef = innerRef ? innerRef : React.createRef();
|
|
@@ -99,7 +119,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
99
119
|
sortParams = sortableFavorites({
|
|
100
120
|
onSort: sort?.onSort,
|
|
101
121
|
columnIndex: sort.columnIndex,
|
|
102
|
-
sortBy: sort.sortBy
|
|
122
|
+
sortBy: sort.sortBy,
|
|
123
|
+
tooltip: tooltip as string,
|
|
124
|
+
tooltipProps
|
|
103
125
|
})();
|
|
104
126
|
} else {
|
|
105
127
|
sortParams = sortable(children as IFormatterValueType, {
|
|
@@ -109,7 +131,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
109
131
|
sortBy: sort.sortBy,
|
|
110
132
|
onSort: sort?.onSort
|
|
111
133
|
}
|
|
112
|
-
} as IColumn
|
|
134
|
+
} as IColumn,
|
|
135
|
+
tooltip: tooltip as string,
|
|
136
|
+
tooltipProps
|
|
113
137
|
});
|
|
114
138
|
}
|
|
115
139
|
}
|
|
@@ -127,7 +151,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
127
151
|
allRowsSelected: select.isSelected,
|
|
128
152
|
isHeaderSelectDisabled: !!select.isHeaderSelectDisabled
|
|
129
153
|
}
|
|
130
|
-
}
|
|
154
|
+
},
|
|
155
|
+
tooltip: tooltip as string,
|
|
156
|
+
tooltipProps
|
|
131
157
|
})
|
|
132
158
|
: null;
|
|
133
159
|
const collapseParams = collapse
|
|
@@ -179,8 +205,9 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
179
205
|
onBlur={() => setShowTooltip(false)}
|
|
180
206
|
data-label={dataLabel}
|
|
181
207
|
onMouseEnter={tooltip !== null ? onMouseEnter : onMouseEnterProp}
|
|
182
|
-
scope={component === 'th'
|
|
208
|
+
scope={component === 'th' ? scope : null}
|
|
183
209
|
ref={cellRef}
|
|
210
|
+
aria-label={ariaLabel}
|
|
184
211
|
className={css(
|
|
185
212
|
styles.tableTh,
|
|
186
213
|
className,
|
|
@@ -203,18 +230,20 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
203
230
|
} as React.CSSProperties
|
|
204
231
|
})}
|
|
205
232
|
>
|
|
206
|
-
{transformedChildren}
|
|
233
|
+
{transformedChildren || (screenReaderText && <span className="pf-v5-screen-reader">{screenReaderText}</span>)}
|
|
207
234
|
</MergedComponent>
|
|
208
235
|
);
|
|
209
236
|
|
|
210
237
|
const canMakeDefaultTooltip = tooltip === '' ? typeof transformedChildren === 'string' : true;
|
|
211
|
-
|
|
238
|
+
const childControlsTooltip = sortParams || selectParams;
|
|
239
|
+
return tooltip !== null && canMakeDefaultTooltip && !childControlsTooltip && showTooltip ? (
|
|
212
240
|
<>
|
|
213
241
|
{cell}
|
|
214
242
|
<Tooltip
|
|
215
243
|
triggerRef={cellRef as React.RefObject<any>}
|
|
216
244
|
content={tooltip || (tooltip === '' && children)}
|
|
217
245
|
isVisible
|
|
246
|
+
{...tooltipProps}
|
|
218
247
|
/>
|
|
219
248
|
</>
|
|
220
249
|
) : (
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { Th } from '../Th';
|
|
4
|
+
|
|
5
|
+
test('Does not render with aria-label by default', () => {
|
|
6
|
+
render(<Th />);
|
|
7
|
+
expect(screen.getByRole('columnheader')).not.toHaveAccessibleName();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('Renders with aria-label when passed in', () => {
|
|
11
|
+
render(<Th aria-label="Test" />);
|
|
12
|
+
expect(screen.getByRole('columnheader')).toHaveAccessibleName('Test');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Does not render with screen reader text by default', () => {
|
|
16
|
+
render(<Th />);
|
|
17
|
+
|
|
18
|
+
expect(screen.getByRole('columnheader')).toBeEmptyDOMElement();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('Does not render with screen reader text when children are passed in', () => {
|
|
22
|
+
render(<Th screenReaderText="Test">Heading label</Th>);
|
|
23
|
+
|
|
24
|
+
expect(screen.getByRole('columnheader')).not.toHaveTextContent('Test');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('Renders with screen reader text when screenReaderText is passed in', () => {
|
|
28
|
+
render(<Th screenReaderText="Test" />);
|
|
29
|
+
|
|
30
|
+
expect(screen.getByRole('columnheader')).toHaveTextContent('Test');
|
|
31
|
+
});
|
|
@@ -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"
|
|
@@ -116,8 +116,8 @@ export const TableActions: React.FunctionComponent = () => {
|
|
|
116
116
|
<Th>{columnNames.prs}</Th>
|
|
117
117
|
<Th>{columnNames.workspaces}</Th>
|
|
118
118
|
<Th>{columnNames.lastCommit}</Th>
|
|
119
|
-
<
|
|
120
|
-
<
|
|
119
|
+
<Th screenReaderText="Primary action" />
|
|
120
|
+
<Th screenReaderText="Secondary action" />
|
|
121
121
|
</Tr>
|
|
122
122
|
</Thead>
|
|
123
123
|
<Tbody>
|
|
@@ -66,7 +66,7 @@ export const TableActions: React.FunctionComponent = () => {
|
|
|
66
66
|
<Th>{columnNames.prs}</Th>
|
|
67
67
|
<Th>{columnNames.workspaces}</Th>
|
|
68
68
|
<Th>{columnNames.lastCommit}</Th>
|
|
69
|
-
<
|
|
69
|
+
<Th screenReaderText="Actions" />
|
|
70
70
|
</Tr>
|
|
71
71
|
</Thead>
|
|
72
72
|
<Tbody>
|
|
@@ -106,9 +106,8 @@ export const TableActions: React.FunctionComponent = () => {
|
|
|
106
106
|
setRepos(repos.map((r) => (r.name !== repo.name ? r : { ...r, isMenuOpen: !r.isMenuOpen })))
|
|
107
107
|
}
|
|
108
108
|
isExpanded={repo.isMenuOpen}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
</MenuToggle>
|
|
109
|
+
icon={<EllipsisVIcon />}
|
|
110
|
+
/>
|
|
112
111
|
)}
|
|
113
112
|
isOpen={repo.isMenuOpen}
|
|
114
113
|
onOpenChange={(isOpen) =>
|
|
@@ -67,7 +67,7 @@ export const TableCompoundExpandable: React.FunctionComponent = () => {
|
|
|
67
67
|
<Th>{columnNames.prs}</Th>
|
|
68
68
|
<Th>{columnNames.workspaces}</Th>
|
|
69
69
|
<Th>{columnNames.lastCommit}</Th>
|
|
70
|
-
<Th />
|
|
70
|
+
<Th screenReaderText="URL" />
|
|
71
71
|
</Tr>
|
|
72
72
|
</Thead>
|
|
73
73
|
{repositories.map((repo: Repository, rowIndex: number) => {
|
|
@@ -140,30 +140,33 @@ export const TableDraggable: React.FunctionComponent = () => {
|
|
|
140
140
|
];
|
|
141
141
|
|
|
142
142
|
return (
|
|
143
|
-
<Table aria-label="Draggable table" className={isDragging
|
|
143
|
+
<Table aria-label="Draggable table" className={isDragging ? styles.modifiers.dragOver : ''}>
|
|
144
144
|
<Thead>
|
|
145
145
|
<Tr>
|
|
146
|
-
<Th />
|
|
146
|
+
<Th screenReaderText="Drag and drop" />
|
|
147
147
|
{columns.map((column, columnIndex) => (
|
|
148
148
|
<Th key={columnIndex}>{column}</Th>
|
|
149
149
|
))}
|
|
150
150
|
</Tr>
|
|
151
151
|
</Thead>
|
|
152
152
|
<Tbody ref={bodyRef} onDragOver={onDragOver} onDrop={onDragOver} onDragLeave={onDragLeave}>
|
|
153
|
-
{rows.map((row, rowIndex) =>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
153
|
+
{rows.map((row, rowIndex) => {
|
|
154
|
+
const rowCellsToBuild = Object.keys(row).filter((rowCell) => rowCell !== 'id');
|
|
155
|
+
return (
|
|
156
|
+
<Tr key={rowIndex} id={row.id} draggable onDrop={onDrop} onDragEnd={onDragEnd} onDragStart={onDragStart}>
|
|
157
|
+
<Td
|
|
158
|
+
draggableRow={{
|
|
159
|
+
id: `draggable-row-${row.id}`
|
|
160
|
+
}}
|
|
161
|
+
/>
|
|
162
|
+
{rowCellsToBuild.map((key, keyIndex) => (
|
|
163
|
+
<Td key={`${rowIndex}_${keyIndex}`} dataLabel={columns[keyIndex]}>
|
|
164
|
+
{row[key]}
|
|
165
|
+
</Td>
|
|
166
|
+
))}
|
|
167
|
+
</Tr>
|
|
168
|
+
);
|
|
169
|
+
})}
|
|
167
170
|
</Tbody>
|
|
168
171
|
</Table>
|
|
169
172
|
);
|