@patternfly/react-table 6.6.1-prerelease.10 → 6.6.1-prerelease.11
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 +6 -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/dynamic-modules.json +2 -0
- package/dist/esm/components/Table/Table.d.ts +2 -0
- package/dist/esm/components/Table/Table.d.ts.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/Tfoot.d.ts +11 -0
- package/dist/esm/components/Table/Tfoot.d.ts.map +1 -0
- package/dist/esm/components/Table/Tfoot.js +12 -0
- package/dist/esm/components/Table/Tfoot.js.map +1 -0
- package/dist/esm/components/Table/index.d.ts +1 -0
- package/dist/esm/components/Table/index.d.ts.map +1 -1
- package/dist/esm/components/Table/index.js +1 -0
- package/dist/esm/components/Table/index.js.map +1 -1
- package/dist/js/components/Table/Table.d.ts +2 -0
- package/dist/js/components/Table/Table.d.ts.map +1 -1
- package/dist/js/components/Table/Table.js +3 -3
- package/dist/js/components/Table/Table.js.map +1 -1
- package/dist/js/components/Table/Tfoot.d.ts +11 -0
- package/dist/js/components/Table/Tfoot.d.ts.map +1 -0
- package/dist/js/components/Table/Tfoot.js +15 -0
- package/dist/js/components/Table/Tfoot.js.map +1 -0
- package/dist/js/components/Table/index.d.ts +1 -0
- package/dist/js/components/Table/index.d.ts.map +1 -1
- package/dist/js/components/Table/index.js +1 -0
- package/dist/js/components/Table/index.js.map +1 -1
- package/dist/umd/assets/{output-Bs_04JEL.css → output-Ly-wiLto.css} +5663 -5663
- package/dist/umd/react-table.min.js +1 -1
- package/package.json +2 -2
- package/src/components/Table/Table.tsx +4 -0
- package/src/components/Table/Tfoot.tsx +23 -0
- package/src/components/Table/__tests__/Table.test.tsx +12 -0
- package/src/components/Table/__tests__/Tfoot.test.tsx +65 -0
- package/src/components/Table/examples/Table.md +9 -0
- package/src/components/Table/examples/TableStickyFooter.tsx +33 -0
- package/src/components/Table/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "6.6.1-prerelease.
|
|
3
|
+
"version": "6.6.1-prerelease.11",
|
|
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",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"react": "^17 || ^18 || ^19",
|
|
52
52
|
"react-dom": "^17 || ^18 || ^19"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "533d86d3b51cd00bb9aeadd9b81aeb6d0b4aaecf"
|
|
55
55
|
}
|
|
@@ -58,6 +58,8 @@ export interface TableProps extends React.HTMLProps<HTMLTableElement>, OUIAProps
|
|
|
58
58
|
isStickyHeaderBase?: boolean;
|
|
59
59
|
/** @beta Flag indicating the table header should have stuck styling, when the header is not at the top of the scroll container. */
|
|
60
60
|
isStickyHeaderStuck?: boolean;
|
|
61
|
+
/** Flag indicating the table footer should stick to the bottom of its scroll container. */
|
|
62
|
+
isStickyFooter?: boolean;
|
|
61
63
|
/** @hide Forwarded ref */
|
|
62
64
|
innerRef?: React.RefObject<any>;
|
|
63
65
|
/** Flag indicating table is a tree table */
|
|
@@ -104,6 +106,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
104
106
|
isStickyHeader = false,
|
|
105
107
|
isStickyHeaderBase = false,
|
|
106
108
|
isStickyHeaderStuck = false,
|
|
109
|
+
isStickyFooter = false,
|
|
107
110
|
isPlain = false,
|
|
108
111
|
isNoPlainOnGlass = false,
|
|
109
112
|
gridBreakPoint = TableGridBreakpoint.gridMd,
|
|
@@ -233,6 +236,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
233
236
|
isStickyHeader && styles.modifiers.stickyHeader,
|
|
234
237
|
isStickyHeaderBase && styles.modifiers.stickyHeaderBase,
|
|
235
238
|
isStickyHeaderStuck && styles.modifiers.stickyHeaderStuck,
|
|
239
|
+
isStickyFooter && styles.modifiers.stickyFooter,
|
|
236
240
|
isTreeTable && stylesTreeView.modifiers.treeView,
|
|
237
241
|
isStriped && styles.modifiers.striped,
|
|
238
242
|
isExpandable && styles.modifiers.expandable,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { css } from '@patternfly/react-styles';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
4
|
+
|
|
5
|
+
export interface TfootProps extends React.HTMLProps<HTMLTableSectionElement> {
|
|
6
|
+
/** Content rendered inside the <tfoot> row group */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Additional classes added to the <tfoot> element */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** @hide Forwarded ref */
|
|
11
|
+
innerRef?: React.Ref<any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const TfootBase: React.FunctionComponent<TfootProps> = ({ children, className, innerRef, ...props }: TfootProps) => (
|
|
15
|
+
<tfoot className={css(styles.tableTfoot, className)} ref={innerRef} {...props}>
|
|
16
|
+
{children}
|
|
17
|
+
</tfoot>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export const Tfoot = forwardRef((props: TfootProps, ref: React.Ref<HTMLTableSectionElement>) => (
|
|
21
|
+
<TfootBase {...props} innerRef={ref} />
|
|
22
|
+
));
|
|
23
|
+
Tfoot.displayName = 'Tfoot';
|
|
@@ -222,3 +222,15 @@ test(`Does not render with class ${styles.modifiers.stickyHeaderStuck} when isSt
|
|
|
222
222
|
|
|
223
223
|
expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.stickyHeaderStuck);
|
|
224
224
|
});
|
|
225
|
+
|
|
226
|
+
test(`Renders with class ${styles.modifiers.stickyFooter} when isStickyFooter is true`, () => {
|
|
227
|
+
render(<Table isStickyFooter aria-label="Test table" />);
|
|
228
|
+
|
|
229
|
+
expect(screen.getByRole('grid', { name: 'Test table' })).toHaveClass(styles.modifiers.stickyFooter);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test(`Does not render with class ${styles.modifiers.stickyFooter} when isStickyFooter is false`, () => {
|
|
233
|
+
render(<Table isStickyFooter={false} aria-label="Test table" />);
|
|
234
|
+
|
|
235
|
+
expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.stickyFooter);
|
|
236
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { Tfoot } from '../Tfoot';
|
|
3
|
+
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
4
|
+
|
|
5
|
+
test('Renders without children', () => {
|
|
6
|
+
render(
|
|
7
|
+
<table>
|
|
8
|
+
<Tfoot />
|
|
9
|
+
</table>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
expect(screen.getByRole('rowgroup')).toBeInTheDocument();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('Renders with children', () => {
|
|
16
|
+
render(
|
|
17
|
+
<table>
|
|
18
|
+
<Tfoot>Footer content</Tfoot>
|
|
19
|
+
</table>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
expect(screen.getByRole('rowgroup')).toHaveTextContent('Footer content');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test(`Renders with class ${styles.tableTfoot} only by default`, () => {
|
|
26
|
+
render(
|
|
27
|
+
<table>
|
|
28
|
+
<Tfoot />
|
|
29
|
+
</table>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(screen.getByRole('rowgroup')).toHaveClass(styles.tableTfoot, { exact: true });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('Forwards refs to the tfoot element', () => {
|
|
36
|
+
const ref = { current: null } as React.RefObject<HTMLTableSectionElement>;
|
|
37
|
+
|
|
38
|
+
render(
|
|
39
|
+
<table>
|
|
40
|
+
<Tfoot ref={ref} />
|
|
41
|
+
</table>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
expect(ref.current).toBe(screen.getByRole('rowgroup'));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('Renders with custom class names provided via prop', () => {
|
|
48
|
+
render(
|
|
49
|
+
<table>
|
|
50
|
+
<Tfoot className="custom-footer" />
|
|
51
|
+
</table>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
expect(screen.getByRole('rowgroup')).toHaveClass('custom-footer');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('Spreads additional props', () => {
|
|
58
|
+
render(
|
|
59
|
+
<table>
|
|
60
|
+
<Tfoot data-custom="true" />
|
|
61
|
+
</table>
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(screen.getByRole('rowgroup')).toHaveAttribute('data-custom', 'true');
|
|
65
|
+
});
|
|
@@ -10,6 +10,7 @@ propComponents:
|
|
|
10
10
|
'Tr',
|
|
11
11
|
'Th',
|
|
12
12
|
'Td',
|
|
13
|
+
'Tfoot',
|
|
13
14
|
'Caption',
|
|
14
15
|
'TableText',
|
|
15
16
|
'TdActionsType',
|
|
@@ -480,6 +481,14 @@ The second `Tr` represents the second level of sub columns. The `Th` in this row
|
|
|
480
481
|
|
|
481
482
|
```
|
|
482
483
|
|
|
484
|
+
### Sticky footer
|
|
485
|
+
|
|
486
|
+
Use `Tfoot` for semantic table footer rows. Set `isStickyFooter` on `Table` to keep the footer visible while its scroll container is scrolling.
|
|
487
|
+
|
|
488
|
+
```ts file="TableStickyFooter.tsx"
|
|
489
|
+
|
|
490
|
+
```
|
|
491
|
+
|
|
483
492
|
### Striped
|
|
484
493
|
|
|
485
494
|
To apply striping to a basic table, add the `isStriped` property to `Table`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Table, Thead, Tfoot, Tr, Th, Tbody, Td, InnerScrollContainer } from '@patternfly/react-table';
|
|
2
|
+
|
|
3
|
+
export const TableStickyFooter: React.FunctionComponent = () => {
|
|
4
|
+
const rows = Array.from({ length: 12 }, (_, index) => index + 1);
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
<div style={{ height: '400px' }}>
|
|
8
|
+
<InnerScrollContainer>
|
|
9
|
+
<Table aria-label="Sticky footer table" isStickyFooter>
|
|
10
|
+
<Thead>
|
|
11
|
+
<Tr>
|
|
12
|
+
<Th>Item</Th>
|
|
13
|
+
<Th>Value</Th>
|
|
14
|
+
</Tr>
|
|
15
|
+
</Thead>
|
|
16
|
+
<Tbody>
|
|
17
|
+
{rows.map((row) => (
|
|
18
|
+
<Tr key={row}>
|
|
19
|
+
<Td dataLabel="Item">Item {row}</Td>
|
|
20
|
+
<Td dataLabel="Value">Value {row}</Td>
|
|
21
|
+
</Tr>
|
|
22
|
+
))}
|
|
23
|
+
</Tbody>
|
|
24
|
+
<Tfoot>
|
|
25
|
+
<Tr>
|
|
26
|
+
<Td colSpan={2}>Total: {rows.length} items</Td>
|
|
27
|
+
</Tr>
|
|
28
|
+
</Tfoot>
|
|
29
|
+
</Table>
|
|
30
|
+
</InnerScrollContainer>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|