@patternfly/react-table 6.3.1-prerelease.0 → 6.3.1-prerelease.2
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 +10 -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/CollapseColumn.d.ts +1 -0
- package/dist/esm/components/Table/CollapseColumn.d.ts.map +1 -1
- package/dist/esm/components/Table/CollapseColumn.js +2 -2
- package/dist/esm/components/Table/CollapseColumn.js.map +1 -1
- package/dist/esm/components/Table/Table.d.ts +1 -0
- package/dist/esm/components/Table/Table.d.ts.map +1 -1
- package/dist/esm/components/Table/Table.js +3 -2
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/TableTypes.d.ts +1 -0
- package/dist/esm/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/esm/components/Table/Td.d.ts.map +1 -1
- package/dist/esm/components/Table/Td.js +3 -2
- package/dist/esm/components/Table/Td.js.map +1 -1
- package/dist/esm/components/Table/Th.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.js +5 -2
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.d.ts.map +1 -1
- package/dist/esm/components/Table/utils/decorators/collapsible.js +2 -2
- package/dist/esm/components/Table/utils/decorators/collapsible.js.map +1 -1
- package/dist/js/components/Table/CollapseColumn.d.ts +1 -0
- package/dist/js/components/Table/CollapseColumn.d.ts.map +1 -1
- package/dist/js/components/Table/CollapseColumn.js +2 -2
- package/dist/js/components/Table/CollapseColumn.js.map +1 -1
- package/dist/js/components/Table/Table.d.ts +1 -0
- package/dist/js/components/Table/Table.d.ts.map +1 -1
- package/dist/js/components/Table/Table.js +3 -2
- package/dist/js/components/Table/Table.js.map +1 -1
- package/dist/js/components/Table/TableTypes.d.ts +1 -0
- package/dist/js/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/js/components/Table/Td.d.ts.map +1 -1
- package/dist/js/components/Table/Td.js +3 -2
- package/dist/js/components/Table/Td.js.map +1 -1
- package/dist/js/components/Table/Th.d.ts.map +1 -1
- package/dist/js/components/Table/Th.js +4 -1
- package/dist/js/components/Table/Th.js.map +1 -1
- package/dist/js/components/Table/utils/decorators/collapsible.d.ts.map +1 -1
- package/dist/js/components/Table/utils/decorators/collapsible.js +2 -2
- package/dist/js/components/Table/utils/decorators/collapsible.js.map +1 -1
- package/dist/umd/assets/{output-CKjCu3-7.css → output-BPhtr9PC.css} +4638 -4638
- package/dist/umd/react-table.min.js +1 -1
- package/package.json +3 -3
- package/src/components/Table/CollapseColumn.tsx +3 -0
- package/src/components/Table/Table.tsx +4 -2
- package/src/components/Table/TableTypes.tsx +1 -0
- package/src/components/Table/Td.tsx +5 -3
- package/src/components/Table/Th.tsx +6 -3
- package/src/components/Table/__tests__/Table.test.tsx +62 -0
- package/src/components/Table/utils/decorators/collapsible.tsx +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "6.3.1-prerelease.
|
|
3
|
+
"version": "6.3.1-prerelease.2",
|
|
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,7 +40,7 @@
|
|
|
40
40
|
"subpaths": "node ../../scripts/exportSubpaths.mjs --config subpaths.config.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@patternfly/react-core": "^6.3.1-prerelease.
|
|
43
|
+
"@patternfly/react-core": "^6.3.1-prerelease.1",
|
|
44
44
|
"@patternfly/react-icons": "^6.3.0",
|
|
45
45
|
"@patternfly/react-styles": "^6.3.0",
|
|
46
46
|
"@patternfly/react-tokens": "^6.3.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"react": "^17 || ^18 || ^19",
|
|
52
52
|
"react-dom": "^17 || ^18 || ^19"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "bc7a24267c0b8aff6f4ce5fd085aa6f01d5878bb"
|
|
55
55
|
}
|
|
@@ -11,6 +11,7 @@ export interface CollapseColumnProps {
|
|
|
11
11
|
onToggle?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
12
12
|
isOpen?: boolean;
|
|
13
13
|
'aria-label'?: string;
|
|
14
|
+
variant?: 'compact';
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export const CollapseColumn: React.FunctionComponent<CollapseColumnProps> = ({
|
|
@@ -18,12 +19,14 @@ export const CollapseColumn: React.FunctionComponent<CollapseColumnProps> = ({
|
|
|
18
19
|
children = null as React.ReactNode,
|
|
19
20
|
isOpen,
|
|
20
21
|
onToggle,
|
|
22
|
+
variant,
|
|
21
23
|
...props
|
|
22
24
|
}: CollapseColumnProps) => (
|
|
23
25
|
<Fragment>
|
|
24
26
|
{isOpen !== undefined && (
|
|
25
27
|
<Button
|
|
26
28
|
className={css(className, isOpen && styles.modifiers.expanded)}
|
|
29
|
+
size={variant === 'compact' ? 'sm' : undefined}
|
|
27
30
|
{...props}
|
|
28
31
|
variant="plain"
|
|
29
32
|
aria-label={props['aria-label'] || 'Details'}
|
|
@@ -78,11 +78,13 @@ export interface TableProps extends React.HTMLProps<HTMLTableElement>, OUIAProps
|
|
|
78
78
|
interface TableContextProps {
|
|
79
79
|
registerSelectableRow?: () => void;
|
|
80
80
|
hasAnimations?: boolean;
|
|
81
|
+
variant?: TableVariant | 'compact';
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
export const TableContext = createContext<TableContextProps>({
|
|
84
85
|
registerSelectableRow: () => {},
|
|
85
|
-
hasAnimations: false
|
|
86
|
+
hasAnimations: false,
|
|
87
|
+
variant: undefined
|
|
86
88
|
});
|
|
87
89
|
|
|
88
90
|
const TableBase: React.FunctionComponent<TableProps> = ({
|
|
@@ -204,7 +206,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
204
206
|
};
|
|
205
207
|
|
|
206
208
|
return (
|
|
207
|
-
<TableContext.Provider value={{ registerSelectableRow, hasAnimations }}>
|
|
209
|
+
<TableContext.Provider value={{ registerSelectableRow, hasAnimations, variant }}>
|
|
208
210
|
<table
|
|
209
211
|
aria-label={ariaLabel}
|
|
210
212
|
role={role}
|
|
@@ -182,6 +182,9 @@ const TdBase: React.FunctionComponent<TdProps> = ({
|
|
|
182
182
|
}
|
|
183
183
|
})
|
|
184
184
|
: null;
|
|
185
|
+
|
|
186
|
+
const { hasAnimations, variant } = useContext(TableContext);
|
|
187
|
+
|
|
185
188
|
const expandableParams =
|
|
186
189
|
expand !== null
|
|
187
190
|
? collapsible(null, {
|
|
@@ -193,13 +196,12 @@ const TdBase: React.FunctionComponent<TdProps> = ({
|
|
|
193
196
|
column: {
|
|
194
197
|
extraParams: {
|
|
195
198
|
onCollapse: expand?.onToggle,
|
|
196
|
-
expandId: expand?.expandId
|
|
199
|
+
expandId: expand?.expandId,
|
|
200
|
+
variant
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
})
|
|
200
204
|
: null;
|
|
201
|
-
|
|
202
|
-
const { hasAnimations } = useContext(TableContext);
|
|
203
205
|
const updateAnimationClass = () => {
|
|
204
206
|
const ancestorControlRow = (cellRef as React.RefObject<HTMLElement | null>)?.current?.closest(
|
|
205
207
|
`.${styles.tableTr}.${styles.tableControlRow}`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRef, forwardRef, useEffect, useState } from 'react';
|
|
1
|
+
import { createRef, forwardRef, useEffect, useState, useContext } from 'react';
|
|
2
2
|
import { css } from '@patternfly/react-styles';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
4
4
|
import scrollStyles from '@patternfly/react-styles/css/components/Table/table-scrollable';
|
|
@@ -8,7 +8,7 @@ import { ThInfoType, ThSelectType, ThExpandType, ThSortType, formatterValueType
|
|
|
8
8
|
import { mergeProps } from './base/merge-props';
|
|
9
9
|
import { IVisibility } from './utils/decorators/classNames';
|
|
10
10
|
import { Tooltip, TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
|
|
11
|
-
import { BaseCellProps } from './Table';
|
|
11
|
+
import { BaseCellProps, TableContext } from './Table';
|
|
12
12
|
import { IFormatterValueType, IColumn } from './TableTypes';
|
|
13
13
|
import cssStickyCellMinWidth from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_MinWidth';
|
|
14
14
|
import cssStickyCellInlineStart from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_InsetInlineStart';
|
|
@@ -96,6 +96,8 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
96
96
|
'aria-label': ariaLabel,
|
|
97
97
|
...props
|
|
98
98
|
}: ThProps) => {
|
|
99
|
+
const { variant } = useContext(TableContext);
|
|
100
|
+
|
|
99
101
|
if (!children && !screenReaderText && !ariaLabel) {
|
|
100
102
|
// eslint-disable-next-line no-console
|
|
101
103
|
console.warn(
|
|
@@ -167,7 +169,8 @@ const ThBase: React.FunctionComponent<ThProps> = ({
|
|
|
167
169
|
extraParams: {
|
|
168
170
|
onCollapse: collapse?.onToggle,
|
|
169
171
|
allRowsExpanded: !collapse.areAllExpanded,
|
|
170
|
-
collapseAllAriaLabel: ''
|
|
172
|
+
collapseAllAriaLabel: '',
|
|
173
|
+
variant
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
})
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import { Table } from '../Table';
|
|
3
|
+
import { Td } from '../Td';
|
|
4
|
+
import { Th } from '../Th';
|
|
3
5
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
4
6
|
|
|
5
7
|
test('Renders without children', () => {
|
|
@@ -60,3 +62,63 @@ test('Matches snapshot without children', () => {
|
|
|
60
62
|
|
|
61
63
|
expect(asFragment()).toMatchSnapshot();
|
|
62
64
|
});
|
|
65
|
+
|
|
66
|
+
test('Renders expandable toggle button with pf-m-small class when variant is compact', () => {
|
|
67
|
+
render(
|
|
68
|
+
<Table variant="compact" isExpandable aria-label="Test table">
|
|
69
|
+
<tbody>
|
|
70
|
+
<tr>
|
|
71
|
+
<Td
|
|
72
|
+
expand={{
|
|
73
|
+
rowIndex: 0,
|
|
74
|
+
isExpanded: false,
|
|
75
|
+
onToggle: () => {}
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
<Td>Test content</Td>
|
|
79
|
+
</tr>
|
|
80
|
+
</tbody>
|
|
81
|
+
</Table>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const toggleButton = screen.getByRole('button', { name: 'Details' });
|
|
85
|
+
expect(toggleButton).toHaveClass('pf-m-small');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('Renders expandable toggle button in Th with pf-m-small class when variant is compact', () => {
|
|
89
|
+
render(
|
|
90
|
+
<Table variant="compact" isExpandable aria-label="Test table">
|
|
91
|
+
<thead>
|
|
92
|
+
<tr>
|
|
93
|
+
<Th
|
|
94
|
+
expand={{
|
|
95
|
+
areAllExpanded: false,
|
|
96
|
+
collapseAllAriaLabel: 'Expand all',
|
|
97
|
+
onToggle: () => {}
|
|
98
|
+
}}
|
|
99
|
+
aria-label="Row expansion"
|
|
100
|
+
/>
|
|
101
|
+
<Th>Name</Th>
|
|
102
|
+
</tr>
|
|
103
|
+
</thead>
|
|
104
|
+
<tbody>
|
|
105
|
+
<tr>
|
|
106
|
+
<Td
|
|
107
|
+
expand={{
|
|
108
|
+
rowIndex: 0,
|
|
109
|
+
isExpanded: false,
|
|
110
|
+
onToggle: () => {}
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
<td>Test content</td>
|
|
114
|
+
</tr>
|
|
115
|
+
</tbody>
|
|
116
|
+
</Table>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const toggleButtons = screen.getAllByRole('button');
|
|
120
|
+
expect(toggleButtons).toHaveLength(2); // One in Th, one in Td
|
|
121
|
+
toggleButtons.forEach((button) => {
|
|
122
|
+
expect(button).toHaveClass('pf-m-small');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -14,7 +14,8 @@ export const collapsible: IFormatter = (
|
|
|
14
14
|
rowLabeledBy = 'simple-node',
|
|
15
15
|
expandId = 'expand-toggle',
|
|
16
16
|
allRowsExpanded,
|
|
17
|
-
collapseAllAriaLabel
|
|
17
|
+
collapseAllAriaLabel,
|
|
18
|
+
variant
|
|
18
19
|
}
|
|
19
20
|
} = column;
|
|
20
21
|
const extraData = {
|
|
@@ -55,6 +56,7 @@ export const collapsible: IFormatter = (
|
|
|
55
56
|
aria-labelledby={`${rowLabeledBy}${rowId} ${expandId}${rowId}`}
|
|
56
57
|
onToggle={onToggle}
|
|
57
58
|
id={expandId + rowId}
|
|
59
|
+
variant={variant}
|
|
58
60
|
{...customProps}
|
|
59
61
|
>
|
|
60
62
|
{value as React.ReactNode}
|