@patternfly/react-table 6.0.0-alpha.2 → 6.0.0-alpha.21
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 +316 -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/Caption.js +1 -1
- package/dist/esm/components/Table/Caption.js.map +1 -1
- package/dist/esm/components/Table/CollapseColumn.js +1 -1
- package/dist/esm/components/Table/CollapseColumn.js.map +1 -1
- package/dist/esm/components/Table/DraggableRowWrapper.js +2 -2
- package/dist/esm/components/Table/DraggableRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/EditColumn.js +1 -1
- package/dist/esm/components/Table/EditColumn.js.map +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js +3 -3
- package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
- package/dist/esm/components/Table/EditableTextCell.js +3 -3
- package/dist/esm/components/Table/EditableTextCell.js.map +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js +1 -1
- package/dist/esm/components/Table/ExpandableRowContent.js.map +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js +1 -1
- package/dist/esm/components/Table/HeaderCellInfoWrapper.js.map +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js +1 -1
- package/dist/esm/components/Table/InnerScrollContainer.js.map +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.js +1 -1
- package/dist/esm/components/Table/OuterScrollContainer.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 +3 -3
- package/dist/esm/components/Table/SortColumn.js.map +1 -1
- package/dist/esm/components/Table/Table.js +3 -3
- package/dist/esm/components/Table/Table.js.map +1 -1
- 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 +13 -11
- 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/Tbody.js +1 -1
- package/dist/esm/components/Table/Tbody.js.map +1 -1
- package/dist/esm/components/Table/Td.js +3 -3
- package/dist/esm/components/Table/Td.js.map +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 +16 -9
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/Thead.js +1 -1
- package/dist/esm/components/Table/Thead.js.map +1 -1
- package/dist/esm/components/Table/Tr.js +2 -2
- package/dist/esm/components/Table/Tr.js.map +1 -1
- package/dist/esm/components/Table/TreeRowWrapper.js +2 -2
- package/dist/esm/components/Table/TreeRowWrapper.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/cellActions.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellActions.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js +1 -1
- package/dist/esm/components/Table/utils/decorators/cellWidth.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js +1 -1
- package/dist/esm/components/Table/utils/decorators/classNames.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js +1 -1
- package/dist/esm/components/Table/utils/decorators/compoundExpand.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/editable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/favoritable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/info.js +1 -1
- package/dist/esm/components/Table/utils/decorators/info.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 +4 -4
- 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 +7 -4
- package/dist/esm/components/Table/utils/decorators/sortable.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/treeRow.js +2 -2
- package/dist/esm/components/Table/utils/decorators/treeRow.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js +1 -1
- package/dist/esm/components/Table/utils/decorators/wrappable.js.map +1 -1
- package/dist/esm/demos/index.d.ts +2 -0
- package/dist/esm/demos/index.d.ts.map +1 -0
- package/dist/esm/demos/index.js +2 -0
- package/dist/esm/demos/index.js.map +1 -0
- package/dist/esm/demos/sampleData.d.ts +13 -0
- package/dist/esm/demos/sampleData.d.ts.map +1 -0
- package/dist/esm/demos/sampleData.js +764 -0
- package/dist/esm/demos/sampleData.js.map +1 -0
- package/dist/esm/deprecated/components/Table/Table.js +1 -1
- package/dist/esm/deprecated/components/Table/Table.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/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/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/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/demos/index.d.ts +2 -0
- package/dist/js/demos/index.d.ts.map +1 -0
- package/dist/js/demos/index.js +5 -0
- package/dist/js/demos/index.js.map +1 -0
- package/dist/js/demos/sampleData.d.ts +13 -0
- package/dist/js/demos/sampleData.d.ts.map +1 -0
- package/dist/js/demos/sampleData.js +767 -0
- package/dist/js/demos/sampleData.js.map +1 -0
- package/dist/js/index.d.ts +1 -0
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -0
- package/dist/js/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/TableText.tsx +19 -9
- package/src/components/Table/TableTypes.tsx +3 -0
- package/src/components/Table/Th.tsx +16 -5
- package/src/components/Table/examples/TableEmptyState.tsx +1 -8
- package/src/components/Table/examples/TableStickyColumnsAndHeader.tsx +5 -4
- package/src/components/Table/utils/decorators/selectable.tsx +2 -1
- package/src/components/Table/utils/decorators/sortable.tsx +8 -2
- package/src/components/Table/utils/transformers.test.tsx +1 -0
- package/src/demos/Table.md +159 -0
- package/src/demos/examples/TableAutomaticPagination.tsx +101 -0
- package/src/{docs/demos/table-demos/BulkSelect.jsx → demos/examples/TableBulkSelect.tsx} +42 -21
- package/src/demos/examples/TableColumnManagement.tsx +486 -0
- package/src/demos/examples/TableColumnManagementWithDraggable.tsx +641 -0
- package/src/{docs/demos/table-demos/Compact.jsx → demos/examples/TableCompact.tsx} +32 -16
- package/src/{docs/demos/table-demos/CompoundExpansion.jsx → demos/examples/TableCompoundExpansion.tsx} +25 -12
- package/src/demos/examples/TableEmptyStateDefault.tsx +58 -0
- package/src/demos/examples/TableEmptyStateError.tsx +42 -0
- package/src/demos/examples/TableEmptyStateLoading.tsx +33 -0
- package/src/{docs/demos/table-demos/ExpandCollapseAll.jsx → demos/examples/TableExpandCollapseAll.tsx} +17 -10
- package/src/demos/examples/TableFilterable.tsx +387 -0
- package/src/{docs/demos/table-demos/SortableResponsive.jsx → demos/examples/TableSortableResponsive.tsx} +31 -28
- package/src/{docs/demos/table-demos/StaticBottomPagination.jsx → demos/examples/TableStaticBottomPagination.tsx} +22 -9
- package/src/{docs/demos/table-demos/StickyFirstColumn.jsx → demos/examples/TableStickyFirstColumn.tsx} +31 -9
- package/src/{docs/demos/table-demos/StickyHeader.jsx → demos/examples/TableStickyHeader.tsx} +3 -3
- package/src/demos/index.ts +1 -0
- package/src/{docs/demos/table-demos/sampleData.js → demos/sampleData.tsx} +88 -77
- package/src/deprecated/components/Table/__tests__/Table.test.tsx +4 -9
- package/src/deprecated/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +8 -8
- package/src/deprecated/components/Table/examples/LegacyTableEmptyState.tsx +6 -8
- package/src/index.ts +1 -0
- package/src/docs/demos/Table.md +0 -1620
- package/src/docs/demos/table-demos/ColumnManagement.jsx +0 -471
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.21",
|
|
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.21",
|
|
44
|
+
"@patternfly/react-icons": "^6.0.0-alpha.10",
|
|
45
|
+
"@patternfly/react-styles": "^6.0.0-alpha.10",
|
|
46
|
+
"@patternfly/react-tokens": "^6.0.0-alpha.10",
|
|
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": "1794095e336814dc8ed16282e1bae4a171ebaa46"
|
|
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>
|
|
@@ -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 & {
|
|
@@ -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
|
) : (
|
|
@@ -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>
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
Td,
|
|
9
9
|
InnerScrollContainer,
|
|
10
10
|
OuterScrollContainer,
|
|
11
|
-
ThProps
|
|
11
|
+
ThProps,
|
|
12
|
+
ISortBy
|
|
12
13
|
} from '@patternfly/react-table';
|
|
13
14
|
import BlueprintIcon from '@patternfly/react-icons/dist/esm/icons/blueprint-icon';
|
|
14
15
|
|
|
@@ -53,10 +54,10 @@ export const TableStickyColumnsAndHeader: React.FunctionComponent = () => {
|
|
|
53
54
|
// Index of the currently sorted column
|
|
54
55
|
// Note: if you intend to make columns reorderable, you may instead want to use a non-numeric key
|
|
55
56
|
// as the identifier of the sorted column. See the "Compound expandable" example.
|
|
56
|
-
const [activeSortIndex, setActiveSortIndex] = React.useState
|
|
57
|
+
const [activeSortIndex, setActiveSortIndex] = React.useState(-1);
|
|
57
58
|
|
|
58
59
|
// Sort direction of the currently sorted column
|
|
59
|
-
const [activeSortDirection, setActiveSortDirection] = React.useState<'
|
|
60
|
+
const [activeSortDirection, setActiveSortDirection] = React.useState<ISortBy['direction']>();
|
|
60
61
|
|
|
61
62
|
// Since OnSort specifies sorted columns by index, we need sortable values for our object by column index.
|
|
62
63
|
// This example is trivial since our data objects just contain strings, but if the data was more complex
|
|
@@ -69,7 +70,7 @@ export const TableStickyColumnsAndHeader: React.FunctionComponent = () => {
|
|
|
69
70
|
// Note that we perform the sort as part of the component's render logic and not in onSort.
|
|
70
71
|
// We shouldn't store the list of data in state because we don't want to have to sync that with props.
|
|
71
72
|
let sortedFacts = facts;
|
|
72
|
-
if (activeSortIndex
|
|
73
|
+
if (activeSortIndex > -1) {
|
|
73
74
|
sortedFacts = facts.sort((a, b) => {
|
|
74
75
|
const aValue = getSortableRowValues(a)[activeSortIndex];
|
|
75
76
|
const bValue = getSortableRowValues(b)[activeSortIndex];
|
|
@@ -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>
|
|
@@ -76,6 +76,7 @@ const testCellActions = async ({
|
|
|
76
76
|
const { container } = render(returnedData.children as React.ReactElement<any>);
|
|
77
77
|
await user.click(screen.getAllByRole('button')[0]);
|
|
78
78
|
await waitFor(() =>
|
|
79
|
+
// eslint-disable-next-line testing-library/no-container
|
|
79
80
|
expect(container.querySelectorAll(`.${dropdownStyles.dropdownMenu} li button`)).toHaveLength(
|
|
80
81
|
expectDisabled ? 0 : 1
|
|
81
82
|
)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Table
|
|
3
|
+
section: components
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Checkbox,
|
|
8
|
+
Label,
|
|
9
|
+
PageSection,
|
|
10
|
+
ToolbarExpandIconWrapper,
|
|
11
|
+
ToolbarContent,
|
|
12
|
+
Toolbar,
|
|
13
|
+
ToolbarItem,
|
|
14
|
+
SearchInput,
|
|
15
|
+
Masthead,
|
|
16
|
+
MastheadToggle,
|
|
17
|
+
MastheadMain,
|
|
18
|
+
MastheadContent,
|
|
19
|
+
SkipToContent,
|
|
20
|
+
Breadcrumb,
|
|
21
|
+
BreadcrumbItem,
|
|
22
|
+
Page,
|
|
23
|
+
PageSectionVariants,
|
|
24
|
+
TextContent,
|
|
25
|
+
Text,
|
|
26
|
+
Divider } from '@patternfly/react-core';
|
|
27
|
+
import { Table as TableDeprecated, TableHeader, TableBody } from '@patternfly/react-table/deprecated';
|
|
28
|
+
import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';
|
|
29
|
+
import CloneIcon from '@patternfly/react-icons/dist/esm/icons/clone-icon';
|
|
30
|
+
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
31
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
32
|
+
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
33
|
+
import EditIcon from '@patternfly/react-icons/dist/esm/icons/edit-icon';
|
|
34
|
+
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
35
|
+
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
36
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
37
|
+
import SyncIcon from '@patternfly/react-icons/dist/esm/icons/sync-icon';
|
|
38
|
+
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
39
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
40
|
+
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
41
|
+
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
42
|
+
import globalDangerColor200 from '@patternfly/react-tokens/dist/esm/global_danger_color_200';
|
|
43
|
+
import imgBrand from '@patternfly/react-core/src/components/assets/pfLogo.svg';
|
|
44
|
+
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
|
|
45
|
+
import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
|
|
46
|
+
import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-icon';
|
|
47
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
48
|
+
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
49
|
+
import BlueprintIcon from '@patternfly/react-icons/dist/esm/icons/blueprint-icon';
|
|
50
|
+
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
51
|
+
import { DashboardWrapper } from '@patternfly/react-core/dist/esm/demos/DashboardWrapper';
|
|
52
|
+
import { rows, columns } from '@patternfly/react-table/dist/esm/demos/sampleData';
|
|
53
|
+
import spacing from '@patternfly/react-styles/css/utilities/Spacing/spacing';
|
|
54
|
+
|
|
55
|
+
## Demos
|
|
56
|
+
|
|
57
|
+
### Bulk select
|
|
58
|
+
|
|
59
|
+
```js isFullscreen file="./examples/TableBulkSelect.tsx"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Expand/collapse all
|
|
63
|
+
|
|
64
|
+
```js isFullscreen file="./examples/TableExpandCollapseAll.tsx"
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Compact
|
|
69
|
+
|
|
70
|
+
```js isFullscreen file="./examples/TableCompact.tsx"
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Compound expansion
|
|
75
|
+
|
|
76
|
+
```js isFullscreen file="./examples/TableCompoundExpansion.tsx"
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Column management
|
|
81
|
+
|
|
82
|
+
```js isFullscreen file="./examples/TableColumnManagement.tsx"
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Column management with draggable
|
|
87
|
+
|
|
88
|
+
```js isFullscreen file="./examples/TableColumnManagementWithDraggable.tsx"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Filterable
|
|
92
|
+
|
|
93
|
+
```js isFullscreen file="./examples/TableFilterable.tsx"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Sortable - responsive
|
|
97
|
+
|
|
98
|
+
```js isFullscreen file="./examples/TableSortableResponsive.tsx"
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Automatic pagination
|
|
103
|
+
|
|
104
|
+
The below example illustrates the `isLastFullPageShown` prop, which makes the following changes when the user sets the number of items to display per page to an amount that exceeds the remaining amount of data:
|
|
105
|
+
|
|
106
|
+
- The component automatically changes the page back to the last full page of results, rather than defaulting to the final page of results.
|
|
107
|
+
|
|
108
|
+
To demonstrate this, navigate to the last page of data below using the `>>` navigation arrows, then use the dropdown selector to change the view to 5 per page.
|
|
109
|
+
|
|
110
|
+
- The default behavior would show the last page of results, which would only contain the last two rows (rows 11 - 12).
|
|
111
|
+
- The `isLastFullPageShown` prop navigates you back to the previous page which does contain a full page of 5 rows (rows 6 - 10).
|
|
112
|
+
|
|
113
|
+
```js isFullscreen file="./examples/TableAutomaticPagination.tsx"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Static bottom pagination on mobile
|
|
117
|
+
|
|
118
|
+
```ts isFullscreen file="./examples/TableStaticBottomPagination.tsx"
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Sticky header
|
|
123
|
+
|
|
124
|
+
```js isFullscreen file="./examples/TableStickyHeader.tsx"
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Sticky first column
|
|
129
|
+
|
|
130
|
+
```js isFullscreen file="./examples/TableStickyFirstColumn.tsx"
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Sticky columns and header with toolbar
|
|
135
|
+
|
|
136
|
+
A toolbar may be added above a sticky table either inside or outside the `OuterScrollContainer`.
|
|
137
|
+
|
|
138
|
+
```js isFullscreen file="../components/Table/examples/TableStickyColumnsAndHeader.tsx"
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Empty states
|
|
143
|
+
|
|
144
|
+
These examples demonstrate the use of an [Empty State component](/components/empty-state) inside of a [Table](/components/table). Empty states are useful in a table when a filter returns no results, while data is loading, or when any type of error or exception condition occurs.
|
|
145
|
+
|
|
146
|
+
### Empty
|
|
147
|
+
|
|
148
|
+
```js isFullscreen file="./examples/TableEmptyStateDefault.tsx"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Loading
|
|
152
|
+
|
|
153
|
+
```js isFullscreen file="./examples/TableEmptyStateLoading.tsx"
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Error
|
|
157
|
+
|
|
158
|
+
```js isFullscreen file="./examples/TableEmptyStateError.tsx"
|
|
159
|
+
```
|