@patternfly/react-table 6.5.0-prerelease.4 → 6.5.0-prerelease.41
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 +148 -0
- package/README.md +1 -1
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/Table/package.json +1 -1
- package/dist/dynamic/components/Table/utils/decorators/package.json +1 -1
- package/dist/dynamic/components/Table/utils/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/base/package.json +1 -1
- package/dist/dynamic/deprecated/components/Table/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.d.ts.map +1 -1
- package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
- 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/Th.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.d.ts.map +1 -1
- package/dist/js/components/Table/EditableSelectInputCell.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/Th.d.ts.map +1 -1
- package/dist/js/components/Table/Th.js.map +1 -1
- package/dist/umd/assets/{output-D_A9f7KQ.css → output-BwG9y--S.css} +6531 -6388
- package/dist/umd/react-table.min.js +5 -5
- package/package.json +7 -7
- package/src/components/Table/EditableSelectInputCell.tsx +4 -2
- package/src/components/Table/Table.tsx +4 -0
- package/src/components/Table/Th.tsx +1 -2
- package/src/components/Table/__tests__/Table.test.tsx +6 -0
- package/src/components/Table/__tests__/__snapshots__/RowWrapper.test.tsx.snap +2 -2
- package/src/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +1 -1
- package/src/components/Table/__tests__/__snapshots__/Tr.test.tsx.snap +2 -2
- package/src/components/Table/examples/Table.md +6 -0
- package/src/components/Table/examples/TableActions.tsx +4 -9
- package/src/components/Table/examples/TableBasic.tsx +5 -10
- package/src/components/Table/examples/TablePlain.tsx +52 -0
- package/src/deprecated/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +1035 -483
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "6.5.0-prerelease.
|
|
3
|
+
"version": "6.5.0-prerelease.41",
|
|
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,16 +40,16 @@
|
|
|
40
40
|
"subpaths": "node ../../scripts/exportSubpaths.mjs --config subpaths.config.json"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@patternfly/react-core": "^6.5.0-prerelease.
|
|
44
|
-
"@patternfly/react-icons": "^6.5.0-prerelease.
|
|
45
|
-
"@patternfly/react-styles": "^6.5.0-prerelease.
|
|
46
|
-
"@patternfly/react-tokens": "^6.5.0-prerelease.
|
|
47
|
-
"lodash": "^4.17.
|
|
43
|
+
"@patternfly/react-core": "^6.5.0-prerelease.40",
|
|
44
|
+
"@patternfly/react-icons": "^6.5.0-prerelease.17",
|
|
45
|
+
"@patternfly/react-styles": "^6.5.0-prerelease.14",
|
|
46
|
+
"@patternfly/react-tokens": "^6.5.0-prerelease.13",
|
|
47
|
+
"lodash": "^4.17.23",
|
|
48
48
|
"tslib": "^2.8.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^17 || ^18 || ^19",
|
|
52
52
|
"react-dom": "^17 || ^18 || ^19"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "550ad935f3c0bb7a084922fd276e21e06b60d043"
|
|
55
55
|
}
|
|
@@ -6,8 +6,10 @@ import inlineStyles from '@patternfly/react-styles/css/components/InlineEdit/inl
|
|
|
6
6
|
import formStyles from '@patternfly/react-styles/css/components/Form/form';
|
|
7
7
|
import { EditableSelectInputProps } from './base/types';
|
|
8
8
|
|
|
9
|
-
export interface IEditableSelectInputCell
|
|
10
|
-
|
|
9
|
+
export interface IEditableSelectInputCell extends Omit<
|
|
10
|
+
React.HTMLProps<HTMLElement | HTMLDivElement>,
|
|
11
|
+
'onSelect' | 'onToggle'
|
|
12
|
+
> {
|
|
11
13
|
/** Row index of this select input cell */
|
|
12
14
|
rowIndex: number;
|
|
13
15
|
/** Cell index of this select input cell */
|
|
@@ -48,6 +48,8 @@ export interface TableProps extends React.HTMLProps<HTMLTableElement>, OUIAProps
|
|
|
48
48
|
gridBreakPoint?: '' | 'grid' | 'grid-md' | 'grid-lg' | 'grid-xl' | 'grid-2xl';
|
|
49
49
|
/** A valid WAI-ARIA role to be applied to the table element */
|
|
50
50
|
role?: string;
|
|
51
|
+
/** @beta Flag indicating if the table should have plain styling with a transparent background */
|
|
52
|
+
isPlain?: boolean;
|
|
51
53
|
/** If set to true, the table header sticks to the top of its container */
|
|
52
54
|
isStickyHeader?: boolean;
|
|
53
55
|
/** @hide Forwarded ref */
|
|
@@ -94,6 +96,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
94
96
|
variant,
|
|
95
97
|
borders = true,
|
|
96
98
|
isStickyHeader = false,
|
|
99
|
+
isPlain = false,
|
|
97
100
|
gridBreakPoint = TableGridBreakpoint.gridMd,
|
|
98
101
|
'aria-label': ariaLabel,
|
|
99
102
|
role = 'grid',
|
|
@@ -222,6 +225,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
222
225
|
isTreeTable && stylesTreeView.modifiers.treeView,
|
|
223
226
|
isStriped && styles.modifiers.striped,
|
|
224
227
|
isExpandable && styles.modifiers.expandable,
|
|
228
|
+
isPlain && styles.modifiers.plain,
|
|
225
229
|
hasNoInset && stylesTreeView.modifiers.noInset,
|
|
226
230
|
isNested && 'pf-m-nested',
|
|
227
231
|
hasAnimations && styles.modifiers.animateExpand
|
|
@@ -15,8 +15,7 @@ import cssStickyCellInlineStart from '@patternfly/react-tokens/dist/esm/c_table_
|
|
|
15
15
|
import cssStickyCellInlineEnd from '@patternfly/react-tokens/dist/esm/c_table__sticky_cell_InsetInlineEnd';
|
|
16
16
|
|
|
17
17
|
export interface ThProps
|
|
18
|
-
extends BaseCellProps,
|
|
19
|
-
Omit<React.HTMLProps<HTMLTableHeaderCellElement>, 'onSelect' | 'width'> {
|
|
18
|
+
extends BaseCellProps, Omit<React.HTMLProps<HTMLTableHeaderCellElement>, 'onSelect' | 'width'> {
|
|
20
19
|
/**
|
|
21
20
|
* The column header the cell corresponds to. Applicable when this component is used as a direct child to <Tr>.
|
|
22
21
|
* This attribute replaces table header in mobile viewport. It is rendered by ::before pseudo element.
|
|
@@ -150,3 +150,9 @@ test('Renders expandable toggle button in Th with pf-m-small class when variant
|
|
|
150
150
|
expect(button).toHaveClass('pf-m-small');
|
|
151
151
|
});
|
|
152
152
|
});
|
|
153
|
+
|
|
154
|
+
test(`Renders with class ${styles.modifiers.plain} when isPlain is true`, () => {
|
|
155
|
+
render(<Table isPlain aria-label="Test table" />);
|
|
156
|
+
|
|
157
|
+
expect(screen.getByRole('grid', { name: 'Test table' })).toHaveClass(styles.modifiers.plain);
|
|
158
|
+
});
|
|
@@ -6,7 +6,7 @@ exports[`RowWrapper renders correctly 1`] = `
|
|
|
6
6
|
<tbody>
|
|
7
7
|
<tr
|
|
8
8
|
class="pf-v6-c-table__tr"
|
|
9
|
-
data-ouia-component-id="OUIA-Generated-TableRow
|
|
9
|
+
data-ouia-component-id="OUIA-Generated-TableRow-:r0:"
|
|
10
10
|
data-ouia-component-type="PF6/TableRow"
|
|
11
11
|
data-ouia-safe="true"
|
|
12
12
|
/>
|
|
@@ -21,7 +21,7 @@ exports[`RowWrapper renders expanded correctly 1`] = `
|
|
|
21
21
|
<tbody>
|
|
22
22
|
<tr
|
|
23
23
|
class="pf-v6-c-table__tr pf-v6-c-table__expandable-row pf-m-expanded"
|
|
24
|
-
data-ouia-component-id="OUIA-Generated-TableRow
|
|
24
|
+
data-ouia-component-id="OUIA-Generated-TableRow-:r1:"
|
|
25
25
|
data-ouia-component-type="PF6/TableRow"
|
|
26
26
|
data-ouia-safe="true"
|
|
27
27
|
/>
|
|
@@ -4,7 +4,7 @@ exports[`Matches snapshot without children 1`] = `
|
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<table
|
|
6
6
|
class="pf-v6-c-table pf-m-grid-md"
|
|
7
|
-
data-ouia-component-id="OUIA-Generated-Table
|
|
7
|
+
data-ouia-component-id="OUIA-Generated-Table-:rb:"
|
|
8
8
|
data-ouia-component-type="PF6/Table"
|
|
9
9
|
data-ouia-safe="true"
|
|
10
10
|
role="grid"
|
|
@@ -6,7 +6,7 @@ exports[`Matches snapshot with children 1`] = `
|
|
|
6
6
|
<tbody>
|
|
7
7
|
<tr
|
|
8
8
|
class="pf-v6-c-table__tr"
|
|
9
|
-
data-ouia-component-id="OUIA-Generated-TableRow
|
|
9
|
+
data-ouia-component-id="OUIA-Generated-TableRow-:r5:"
|
|
10
10
|
data-ouia-component-type="PF6/TableRow"
|
|
11
11
|
data-ouia-safe="true"
|
|
12
12
|
>
|
|
@@ -25,7 +25,7 @@ exports[`Matches snapshot without children 1`] = `
|
|
|
25
25
|
<tbody>
|
|
26
26
|
<tr
|
|
27
27
|
class="pf-v6-c-table__tr"
|
|
28
|
-
data-ouia-component-id="OUIA-Generated-TableRow
|
|
28
|
+
data-ouia-component-id="OUIA-Generated-TableRow-:r4:"
|
|
29
29
|
data-ouia-component-type="PF6/TableRow"
|
|
30
30
|
data-ouia-safe="true"
|
|
31
31
|
/>
|
|
@@ -23,7 +23,7 @@ interface Repository {
|
|
|
23
23
|
singleAction: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
type ExampleType = '
|
|
26
|
+
type ExampleType = 'customToggle';
|
|
27
27
|
|
|
28
28
|
export const TableActions: React.FunctionComponent = () => {
|
|
29
29
|
// In real usage, this data would come from some external source like an API via props.
|
|
@@ -45,10 +45,11 @@ export const TableActions: React.FunctionComponent = () => {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
// This state is just for the ToggleGroup in this example and isn't necessary for Table usage.
|
|
48
|
-
const [exampleChoice, setExampleChoice] = useState<ExampleType>('
|
|
48
|
+
const [exampleChoice, setExampleChoice] = useState<ExampleType | ''>('');
|
|
49
49
|
const onExampleTypeChange: ToggleGroupItemProps['onChange'] = (event, _isSelected) => {
|
|
50
50
|
const id = event.currentTarget.id;
|
|
51
|
-
|
|
51
|
+
// Allow toggling off if clicking the already selected item
|
|
52
|
+
setExampleChoice(exampleChoice === id ? '' : (id as ExampleType));
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
const customActionsToggle = (props: CustomActionsToggleProps) => (
|
|
@@ -95,12 +96,6 @@ export const TableActions: React.FunctionComponent = () => {
|
|
|
95
96
|
return (
|
|
96
97
|
<Fragment>
|
|
97
98
|
<ToggleGroup aria-label="Default uses kebab toggle">
|
|
98
|
-
<ToggleGroupItem
|
|
99
|
-
text="Default actions toggle"
|
|
100
|
-
buttonId="defaultToggle"
|
|
101
|
-
isSelected={exampleChoice === 'defaultToggle'}
|
|
102
|
-
onChange={onExampleTypeChange}
|
|
103
|
-
/>
|
|
104
99
|
<ToggleGroupItem
|
|
105
100
|
text="Custom actions toggle"
|
|
106
101
|
buttonId="customToggle"
|
|
@@ -10,7 +10,7 @@ interface Repository {
|
|
|
10
10
|
lastCommit: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
type ExampleType = '
|
|
13
|
+
type ExampleType = 'compact' | 'compactBorderless';
|
|
14
14
|
|
|
15
15
|
export const TableBasic: React.FunctionComponent = () => {
|
|
16
16
|
// In real usage, this data would come from some external source like an API via props.
|
|
@@ -29,21 +29,16 @@ export const TableBasic: React.FunctionComponent = () => {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// This state is just for the ToggleGroup in this example and isn't necessary for Table usage.
|
|
32
|
-
const [exampleChoice, setExampleChoice] = useState<ExampleType>('
|
|
32
|
+
const [exampleChoice, setExampleChoice] = useState<ExampleType | ''>('');
|
|
33
33
|
const onExampleTypeChange: ToggleGroupItemProps['onChange'] = (event, _isSelected) => {
|
|
34
34
|
const id = event.currentTarget.id;
|
|
35
|
-
|
|
35
|
+
// Allow toggling off if clicking the already selected item
|
|
36
|
+
setExampleChoice(exampleChoice === id ? '' : (id as ExampleType));
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
return (
|
|
39
40
|
<Fragment>
|
|
40
41
|
<ToggleGroup aria-label="Default with single selectable">
|
|
41
|
-
<ToggleGroupItem
|
|
42
|
-
text="Default"
|
|
43
|
-
buttonId="default"
|
|
44
|
-
isSelected={exampleChoice === 'default'}
|
|
45
|
-
onChange={onExampleTypeChange}
|
|
46
|
-
/>
|
|
47
42
|
<ToggleGroupItem
|
|
48
43
|
text="Compact"
|
|
49
44
|
buttonId="compact"
|
|
@@ -59,7 +54,7 @@ export const TableBasic: React.FunctionComponent = () => {
|
|
|
59
54
|
</ToggleGroup>
|
|
60
55
|
<Table
|
|
61
56
|
aria-label="Simple table"
|
|
62
|
-
variant={exampleChoice
|
|
57
|
+
variant={exampleChoice === 'compact' || exampleChoice === 'compactBorderless' ? 'compact' : undefined}
|
|
63
58
|
borders={exampleChoice !== 'compactBorderless'}
|
|
64
59
|
>
|
|
65
60
|
<Caption>Simple table using composable components</Caption>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Table, Caption, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
2
|
+
|
|
3
|
+
interface Repository {
|
|
4
|
+
name: string;
|
|
5
|
+
branches: string | null;
|
|
6
|
+
prs: string | null;
|
|
7
|
+
workspaces: string;
|
|
8
|
+
lastCommit: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const TablePlain: React.FunctionComponent = () => {
|
|
12
|
+
// In real usage, this data would come from some external source like an API via props.
|
|
13
|
+
const repositories: Repository[] = [
|
|
14
|
+
{ name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' },
|
|
15
|
+
{ name: 'one - 2', branches: null, prs: null, workspaces: 'four - 2', lastCommit: 'five - 2' },
|
|
16
|
+
{ name: 'one - 3', branches: 'two - 3', prs: 'three - 3', workspaces: 'four - 3', lastCommit: 'five - 3' }
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const columnNames = {
|
|
20
|
+
name: 'Repositories',
|
|
21
|
+
branches: 'Branches',
|
|
22
|
+
prs: 'Pull requests',
|
|
23
|
+
workspaces: 'Workspaces',
|
|
24
|
+
lastCommit: 'Last commit'
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Table aria-label="Plain table" isPlain={true}>
|
|
29
|
+
<Caption>Simple table with plain styling using composable components</Caption>
|
|
30
|
+
<Thead>
|
|
31
|
+
<Tr>
|
|
32
|
+
<Th>{columnNames.name}</Th>
|
|
33
|
+
<Th>{columnNames.branches}</Th>
|
|
34
|
+
<Th>{columnNames.prs}</Th>
|
|
35
|
+
<Th>{columnNames.workspaces}</Th>
|
|
36
|
+
<Th>{columnNames.lastCommit}</Th>
|
|
37
|
+
</Tr>
|
|
38
|
+
</Thead>
|
|
39
|
+
<Tbody>
|
|
40
|
+
{repositories.map((repo) => (
|
|
41
|
+
<Tr key={repo.name}>
|
|
42
|
+
<Td dataLabel={columnNames.name}>{repo.name}</Td>
|
|
43
|
+
<Td dataLabel={columnNames.branches}>{repo.branches}</Td>
|
|
44
|
+
<Td dataLabel={columnNames.prs}>{repo.prs}</Td>
|
|
45
|
+
<Td dataLabel={columnNames.workspaces}>{repo.workspaces}</Td>
|
|
46
|
+
<Td dataLabel={columnNames.lastCommit}>{repo.lastCommit}</Td>
|
|
47
|
+
</Tr>
|
|
48
|
+
))}
|
|
49
|
+
</Tbody>
|
|
50
|
+
</Table>
|
|
51
|
+
);
|
|
52
|
+
};
|