@patternfly/react-table 4.71.36 → 4.72.1
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 +27 -0
- package/dist/umd/react-table.css +16 -0
- package/dist/umd/react-table.min.css +16 -0
- package/package.json +6 -6
- package/src/components/Table/{RowWrapper.test.tsx → __tests__/RowWrapper.test.tsx} +7 -5
- package/src/components/Table/__tests__/Table.test.tsx +358 -0
- package/src/components/Table/{__snapshots__ → __tests__/__snapshots__}/RowWrapper.test.tsx.snap +4 -4
- package/src/components/Table/{__snapshots__ → __tests__/__snapshots__}/Table.test.tsx.snap +2050 -1954
- package/src/components/Table/utils/__snapshots__/transformers.test.tsx.snap +0 -10
- package/src/components/Table/utils/transformers.test.tsx +37 -33
- package/src/demos/Table.md +0 -2
- package/src/components/Table/Table.test.tsx +0 -344
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 4.72.1 (2022-04-18)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/react-table
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 4.72.0 (2022-04-14)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **MenuToggle:** Add full width modifier ([#7232](https://github.com/patternfly/patternfly-react/issues/7232)) ([789a8a3](https://github.com/patternfly/patternfly-react/commit/789a8a3f1cb1f1d90565f8d0e6c0dbe984c0c66b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 4.71.37 (2022-04-14)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @patternfly/react-table
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## 4.71.36 (2022-04-14)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @patternfly/react-table
|
package/dist/umd/react-table.css
CHANGED
|
@@ -6195,6 +6195,7 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
6195
6195
|
--pf-c-form-control--m-expanded--PaddingBottom: calc(var(--pf-global--spacer--form-element) - var(--pf-c-form-control--focus--BorderBottomWidth));
|
|
6196
6196
|
--pf-c-form-control--m-expanded--BorderBottomColor: var(--pf-global--primary-color--100);
|
|
6197
6197
|
--pf-c-form-control--placeholder--Color: var(--pf-global--Color--dark-200);
|
|
6198
|
+
--pf-c-form-control--placeholder--child--Color: var(--pf-global--Color--100);
|
|
6198
6199
|
--pf-c-form-control--disabled--Color: var(--pf-global--disabled-color--100);
|
|
6199
6200
|
--pf-c-form-control--disabled--BackgroundColor: var(--pf-global--disabled-color--300);
|
|
6200
6201
|
--pf-c-form-control--disabled--BorderColor: transparent;
|
|
@@ -6481,6 +6482,14 @@ select.pf-c-form-control.pf-m-placeholder {
|
|
|
6481
6482
|
color: var(--pf-c-form-control--placeholder--Color);
|
|
6482
6483
|
}
|
|
6483
6484
|
|
|
6485
|
+
select.pf-c-form-control.pf-m-placeholder * {
|
|
6486
|
+
color: var(--pf-c-form-control--placeholder--child--Color);
|
|
6487
|
+
}
|
|
6488
|
+
|
|
6489
|
+
select.pf-c-form-control.pf-m-placeholder *:disabled {
|
|
6490
|
+
color: revert;
|
|
6491
|
+
}
|
|
6492
|
+
|
|
6484
6493
|
textarea.pf-c-form-control {
|
|
6485
6494
|
--pf-c-form-control--success--BackgroundPositionY: var(--pf-c-form-control--textarea--success--BackgroundPositionY);
|
|
6486
6495
|
--pf-c-form-control--invalid--BackgroundPositionY: var(--pf-c-form-control--textarea--invalid--BackgroundPositionY);
|
|
@@ -8865,6 +8874,7 @@ button.pf-c-breadcrumb__link {
|
|
|
8865
8874
|
--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY: var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY--base);
|
|
8866
8875
|
--pf-c-card--m-flat--m-selectable-raised--m-selected-raised--TranslateY: calc(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY--base) + var(--pf-c-card--m-flat--BorderWidth));
|
|
8867
8876
|
--pf-c-card--m-rounded--m-selectable-raised--m-selected-raised--TranslateY: calc(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY--base) + var(--pf-c-card--m-rounded--BorderRadius));
|
|
8877
|
+
--pf-c-card--m-selectable-raised--m-selected-raised--ZIndex: var(--pf-global--ZIndex--xs);
|
|
8868
8878
|
--pf-c-card--m-selectable-raised--m-selected-raised--Transition: transform .25s linear, box-shadow .25s linear;
|
|
8869
8879
|
--pf-c-card--m-selectable-raised--m-selected-raised--before--Transition: transform .25s linear;
|
|
8870
8880
|
--pf-c-card--m-selectable-raised--m-selected-raised--before--TranslateY: calc(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY) * -1);
|
|
@@ -8984,6 +8994,7 @@ button.pf-c-breadcrumb__link {
|
|
|
8984
8994
|
--pf-c-card--m-selectable-raised--before--Transition: var(--pf-c-card--m-selectable-raised--m-selected-raised--before--Transition);
|
|
8985
8995
|
--pf-c-card--m-selectable-raised--before--TranslateY: var(--pf-c-card--m-selectable-raised--m-selected-raised--before--TranslateY);
|
|
8986
8996
|
--pf-c-card--m-selectable-raised--before--ScaleY: var(--pf-c-card--m-selectable-raised--m-selected-raised--before--ScaleY);
|
|
8997
|
+
z-index: var(--pf-c-card--m-selectable-raised--m-selected-raised--ZIndex);
|
|
8987
8998
|
box-shadow: var(--pf-c-card--m-selectable-raised--m-selected-raised--BoxShadow);
|
|
8988
8999
|
transition: var(--pf-c-card--m-selectable-raised--m-selected-raised--Transition);
|
|
8989
9000
|
transform: translateY(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY));
|
|
@@ -22508,6 +22519,11 @@ label.pf-c-radio, .pf-c-radio__label,
|
|
|
22508
22519
|
--pf-c-tabs__link--disabled--before--BorderBottomWidth: 0;
|
|
22509
22520
|
}
|
|
22510
22521
|
|
|
22522
|
+
.pf-c-tabs.pf-m-border-bottom {
|
|
22523
|
+
--pf-c-tabs--before--BorderBottomWidth: var(--pf-c-tabs--before--border-width--base);
|
|
22524
|
+
--pf-c-tabs__link--disabled--before--BorderBottomWidth: var(--pf-c-tabs--before--border-width--base);
|
|
22525
|
+
}
|
|
22526
|
+
|
|
22511
22527
|
.pf-c-tabs.pf-m-box .pf-c-tabs__link, .pf-c-tabs.pf-m-vertical .pf-c-tabs__link {
|
|
22512
22528
|
--pf-c-tabs__link--after--BorderBottomWidth: 0;
|
|
22513
22529
|
}
|
|
@@ -6195,6 +6195,7 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
6195
6195
|
--pf-c-form-control--m-expanded--PaddingBottom: calc(var(--pf-global--spacer--form-element) - var(--pf-c-form-control--focus--BorderBottomWidth));
|
|
6196
6196
|
--pf-c-form-control--m-expanded--BorderBottomColor: var(--pf-global--primary-color--100);
|
|
6197
6197
|
--pf-c-form-control--placeholder--Color: var(--pf-global--Color--dark-200);
|
|
6198
|
+
--pf-c-form-control--placeholder--child--Color: var(--pf-global--Color--100);
|
|
6198
6199
|
--pf-c-form-control--disabled--Color: var(--pf-global--disabled-color--100);
|
|
6199
6200
|
--pf-c-form-control--disabled--BackgroundColor: var(--pf-global--disabled-color--300);
|
|
6200
6201
|
--pf-c-form-control--disabled--BorderColor: transparent;
|
|
@@ -6481,6 +6482,14 @@ select.pf-c-form-control.pf-m-placeholder {
|
|
|
6481
6482
|
color: var(--pf-c-form-control--placeholder--Color);
|
|
6482
6483
|
}
|
|
6483
6484
|
|
|
6485
|
+
select.pf-c-form-control.pf-m-placeholder * {
|
|
6486
|
+
color: var(--pf-c-form-control--placeholder--child--Color);
|
|
6487
|
+
}
|
|
6488
|
+
|
|
6489
|
+
select.pf-c-form-control.pf-m-placeholder *:disabled {
|
|
6490
|
+
color: revert;
|
|
6491
|
+
}
|
|
6492
|
+
|
|
6484
6493
|
textarea.pf-c-form-control {
|
|
6485
6494
|
--pf-c-form-control--success--BackgroundPositionY: var(--pf-c-form-control--textarea--success--BackgroundPositionY);
|
|
6486
6495
|
--pf-c-form-control--invalid--BackgroundPositionY: var(--pf-c-form-control--textarea--invalid--BackgroundPositionY);
|
|
@@ -8865,6 +8874,7 @@ button.pf-c-breadcrumb__link {
|
|
|
8865
8874
|
--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY: var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY--base);
|
|
8866
8875
|
--pf-c-card--m-flat--m-selectable-raised--m-selected-raised--TranslateY: calc(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY--base) + var(--pf-c-card--m-flat--BorderWidth));
|
|
8867
8876
|
--pf-c-card--m-rounded--m-selectable-raised--m-selected-raised--TranslateY: calc(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY--base) + var(--pf-c-card--m-rounded--BorderRadius));
|
|
8877
|
+
--pf-c-card--m-selectable-raised--m-selected-raised--ZIndex: var(--pf-global--ZIndex--xs);
|
|
8868
8878
|
--pf-c-card--m-selectable-raised--m-selected-raised--Transition: transform .25s linear, box-shadow .25s linear;
|
|
8869
8879
|
--pf-c-card--m-selectable-raised--m-selected-raised--before--Transition: transform .25s linear;
|
|
8870
8880
|
--pf-c-card--m-selectable-raised--m-selected-raised--before--TranslateY: calc(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY) * -1);
|
|
@@ -8984,6 +8994,7 @@ button.pf-c-breadcrumb__link {
|
|
|
8984
8994
|
--pf-c-card--m-selectable-raised--before--Transition: var(--pf-c-card--m-selectable-raised--m-selected-raised--before--Transition);
|
|
8985
8995
|
--pf-c-card--m-selectable-raised--before--TranslateY: var(--pf-c-card--m-selectable-raised--m-selected-raised--before--TranslateY);
|
|
8986
8996
|
--pf-c-card--m-selectable-raised--before--ScaleY: var(--pf-c-card--m-selectable-raised--m-selected-raised--before--ScaleY);
|
|
8997
|
+
z-index: var(--pf-c-card--m-selectable-raised--m-selected-raised--ZIndex);
|
|
8987
8998
|
box-shadow: var(--pf-c-card--m-selectable-raised--m-selected-raised--BoxShadow);
|
|
8988
8999
|
transition: var(--pf-c-card--m-selectable-raised--m-selected-raised--Transition);
|
|
8989
9000
|
transform: translateY(var(--pf-c-card--m-selectable-raised--m-selected-raised--TranslateY));
|
|
@@ -22508,6 +22519,11 @@ label.pf-c-radio, .pf-c-radio__label,
|
|
|
22508
22519
|
--pf-c-tabs__link--disabled--before--BorderBottomWidth: 0;
|
|
22509
22520
|
}
|
|
22510
22521
|
|
|
22522
|
+
.pf-c-tabs.pf-m-border-bottom {
|
|
22523
|
+
--pf-c-tabs--before--BorderBottomWidth: var(--pf-c-tabs--before--border-width--base);
|
|
22524
|
+
--pf-c-tabs__link--disabled--before--BorderBottomWidth: var(--pf-c-tabs--before--border-width--base);
|
|
22525
|
+
}
|
|
22526
|
+
|
|
22511
22527
|
.pf-c-tabs.pf-m-box .pf-c-tabs__link, .pf-c-tabs.pf-m-vertical .pf-c-tabs__link {
|
|
22512
22528
|
--pf-c-tabs__link--after--BorderBottomWidth: 0;
|
|
22513
22529
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.72.1",
|
|
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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"clean": "rimraf dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@patternfly/react-core": "^4.
|
|
35
|
-
"@patternfly/react-icons": "^4.
|
|
36
|
-
"@patternfly/react-styles": "^4.
|
|
37
|
-
"@patternfly/react-tokens": "^4.
|
|
34
|
+
"@patternfly/react-core": "^4.203.1",
|
|
35
|
+
"@patternfly/react-icons": "^4.54.1",
|
|
36
|
+
"@patternfly/react-styles": "^4.53.1",
|
|
37
|
+
"@patternfly/react-tokens": "^4.55.1",
|
|
38
38
|
"lodash": "^4.17.19",
|
|
39
39
|
"tslib": "^2.0.0"
|
|
40
40
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react": "^16.8.0 || ^17.0.0",
|
|
47
47
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "2f16e9b81a8ab2c54d9ef945e50c1e4aa7510c49"
|
|
50
50
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
|
-
import { RowWrapper, RowWrapperProps } from '
|
|
3
|
+
import { RowWrapper, RowWrapperProps } from '../RowWrapper';
|
|
4
4
|
|
|
5
5
|
const getRowWrapper = (props: RowWrapperProps) => (
|
|
6
6
|
<table>
|
|
@@ -13,12 +13,14 @@ const getRowWrapper = (props: RowWrapperProps) => (
|
|
|
13
13
|
describe('RowWrapper', () => {
|
|
14
14
|
test('renders correctly', () => {
|
|
15
15
|
const trRef = jest.fn();
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const { asFragment } = render(getRowWrapper({ onScroll: jest.fn(), onResize: jest.fn(), trRef }));
|
|
17
|
+
|
|
18
|
+
expect(asFragment()).toMatchSnapshot();
|
|
18
19
|
expect(trRef.mock.calls).toHaveLength(1);
|
|
19
20
|
});
|
|
21
|
+
|
|
20
22
|
test('renders expanded correctly', () => {
|
|
21
|
-
const
|
|
22
|
-
expect(
|
|
23
|
+
const { asFragment } = render(getRowWrapper({ row: { isExpanded: true } }));
|
|
24
|
+
expect(asFragment()).toMatchSnapshot();
|
|
23
25
|
});
|
|
24
26
|
});
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Table,
|
|
8
|
+
TableHeader,
|
|
9
|
+
TableBody,
|
|
10
|
+
TableGridBreakpoint,
|
|
11
|
+
TableVariant,
|
|
12
|
+
RowSelectVariant,
|
|
13
|
+
cellWidth,
|
|
14
|
+
headerCol,
|
|
15
|
+
sortable,
|
|
16
|
+
expandable,
|
|
17
|
+
compoundExpand,
|
|
18
|
+
IRow,
|
|
19
|
+
OnCollapse,
|
|
20
|
+
OnExpand,
|
|
21
|
+
OnSelect,
|
|
22
|
+
OnRowEdit,
|
|
23
|
+
OnSort,
|
|
24
|
+
wrappable,
|
|
25
|
+
nowrap,
|
|
26
|
+
truncate,
|
|
27
|
+
breakWord,
|
|
28
|
+
fitContent,
|
|
29
|
+
ICell
|
|
30
|
+
} from '../index';
|
|
31
|
+
import { rows, columns, editableRows, editableColumns, actions } from '../../../test-helpers/data-sets';
|
|
32
|
+
import { ColumnsType } from '../base';
|
|
33
|
+
|
|
34
|
+
describe('Table', () => {
|
|
35
|
+
describe('simple', () => {
|
|
36
|
+
test('caption', () => {
|
|
37
|
+
const { asFragment } = render(
|
|
38
|
+
<Table caption="Simple Table" cells={columns} rows={rows}>
|
|
39
|
+
<TableHeader />
|
|
40
|
+
<TableBody />
|
|
41
|
+
</Table>
|
|
42
|
+
);
|
|
43
|
+
expect(asFragment()).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('header', () => {
|
|
47
|
+
const { asFragment } = render(
|
|
48
|
+
<Table header={<h4>Header title</h4>} cells={columns} rows={rows}>
|
|
49
|
+
<TableHeader />
|
|
50
|
+
<TableBody />
|
|
51
|
+
</Table>
|
|
52
|
+
);
|
|
53
|
+
expect(asFragment()).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('aria-label', () => {
|
|
57
|
+
const { asFragment } = render(
|
|
58
|
+
<Table aria-label="Aria labeled" cells={columns} rows={rows}>
|
|
59
|
+
<TableHeader />
|
|
60
|
+
<TableBody />
|
|
61
|
+
</Table>
|
|
62
|
+
);
|
|
63
|
+
expect(asFragment()).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('Editable table', () => {
|
|
67
|
+
const onRowEdit: OnRowEdit = () => undefined;
|
|
68
|
+
const { asFragment } = render(
|
|
69
|
+
<Table caption="Editable Table" cells={editableColumns} rows={editableRows} onRowEdit={onRowEdit}>
|
|
70
|
+
<TableHeader />
|
|
71
|
+
<TableBody />
|
|
72
|
+
</Table>
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
expect(asFragment()).toMatchSnapshot();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('Sortable table', () => {
|
|
79
|
+
columns[0] = { ...(columns[0] as object), transforms: [sortable] };
|
|
80
|
+
|
|
81
|
+
const onSortCall: OnSort = () => undefined;
|
|
82
|
+
const { asFragment } = render(
|
|
83
|
+
<Table aria-label="Aria labeled" onSort={onSortCall} sortBy={{}} cells={columns} rows={rows}>
|
|
84
|
+
<TableHeader />
|
|
85
|
+
<TableBody />
|
|
86
|
+
</Table>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(asFragment()).toMatchSnapshot();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('Row click table', () => {
|
|
93
|
+
const rowClickHandler = jest.fn();
|
|
94
|
+
const { asFragment } = render(
|
|
95
|
+
<Table aria-label="Row click table" cells={columns} rows={rows}>
|
|
96
|
+
<TableHeader />
|
|
97
|
+
<TableBody onRowClick={rowClickHandler} />
|
|
98
|
+
</Table>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
expect(asFragment()).toMatchSnapshot();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('Table variants', () => {
|
|
106
|
+
Object.values(TableGridBreakpoint).forEach(oneBreakpoint => {
|
|
107
|
+
test(`Breakpoint - ${oneBreakpoint}`, () => {
|
|
108
|
+
const { asFragment } = render(
|
|
109
|
+
<Table aria-label="Aria labeled" gridBreakPoint={oneBreakpoint} cells={columns} rows={rows}>
|
|
110
|
+
<TableHeader />
|
|
111
|
+
<TableBody />
|
|
112
|
+
</Table>
|
|
113
|
+
);
|
|
114
|
+
expect(asFragment()).toMatchSnapshot();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
Object.values(TableVariant).forEach(onevariant => {
|
|
119
|
+
test(`Size - ${onevariant}`, () => {
|
|
120
|
+
const { asFragment } = render(
|
|
121
|
+
<Table aria-label="Aria labeled" variant={onevariant} cells={columns} rows={rows}>
|
|
122
|
+
<TableHeader />
|
|
123
|
+
<TableBody />
|
|
124
|
+
</Table>
|
|
125
|
+
);
|
|
126
|
+
expect(asFragment()).toMatchSnapshot();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('Simple Actions table', () => {
|
|
132
|
+
const rowsWithDisabledAction = [
|
|
133
|
+
...rows,
|
|
134
|
+
{
|
|
135
|
+
cells: ['one', 'two', 'three', 'four', 'five'],
|
|
136
|
+
disableActions: true
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
const { asFragment } = render(
|
|
140
|
+
<Table aria-label="Aria labeled" actions={actions} cells={columns} rows={rowsWithDisabledAction}>
|
|
141
|
+
<TableHeader />
|
|
142
|
+
<TableBody />
|
|
143
|
+
</Table>
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
expect(asFragment()).toMatchSnapshot();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('Actions table', () => {
|
|
150
|
+
const { asFragment } = render(
|
|
151
|
+
<Table
|
|
152
|
+
aria-label="Aria labeled"
|
|
153
|
+
actionResolver={() => actions}
|
|
154
|
+
areActionsDisabled={() => false}
|
|
155
|
+
cells={columns}
|
|
156
|
+
rows={rows}
|
|
157
|
+
>
|
|
158
|
+
<TableHeader />
|
|
159
|
+
<TableBody />
|
|
160
|
+
</Table>
|
|
161
|
+
);
|
|
162
|
+
expect(asFragment()).toMatchSnapshot();
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
test('Cell header table', () => {
|
|
166
|
+
columns[0] = { ...(columns[0] as object), cellTransforms: [headerCol('test-headercol-')] };
|
|
167
|
+
const { asFragment } = render(
|
|
168
|
+
<Table aria-label="Aria labeled" cells={columns} rows={rows}>
|
|
169
|
+
<TableHeader />
|
|
170
|
+
<TableBody />
|
|
171
|
+
</Table>
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
expect(asFragment()).toMatchSnapshot();
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test('Collapsible table', () => {
|
|
178
|
+
rows[0] = { ...rows[0], isOpen: true };
|
|
179
|
+
rows[1] = { ...rows[1], parent: 0 };
|
|
180
|
+
rows[3] = { ...rows[3], isOpen: false };
|
|
181
|
+
rows[4] = { ...rows[4], parent: 3 };
|
|
182
|
+
columns[0] = { ...(columns[0] as object), cellFormatters: [expandable] };
|
|
183
|
+
|
|
184
|
+
const onCollapse: OnCollapse = () => undefined;
|
|
185
|
+
const { asFragment } = render(
|
|
186
|
+
<Table aria-label="Aria labeled" onCollapse={onCollapse} cells={columns} rows={rows}>
|
|
187
|
+
<TableHeader />
|
|
188
|
+
<TableBody />
|
|
189
|
+
</Table>
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
expect(asFragment()).toMatchSnapshot();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('Compound Expandable table', () => {
|
|
196
|
+
const compoundColumns: ColumnsType = [
|
|
197
|
+
{ title: 'col1', cellTransforms: [compoundExpand] },
|
|
198
|
+
{ title: 'col2', cellTransforms: [compoundExpand] }
|
|
199
|
+
];
|
|
200
|
+
const compoundRows: IRow[] = [
|
|
201
|
+
{
|
|
202
|
+
isOpen: true,
|
|
203
|
+
cells: [
|
|
204
|
+
{ title: '1', props: { isOpen: true } },
|
|
205
|
+
{ title: '2', props: { isOpen: false } }
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
{ parent: 0, compoundParent: 0, cells: [{ title: 'expanded', props: { colSpan: 2 } }] },
|
|
209
|
+
{
|
|
210
|
+
isOpen: false,
|
|
211
|
+
cells: [
|
|
212
|
+
{ title: '3', props: { isOpen: false } },
|
|
213
|
+
{ title: '4', props: { isOpen: false } }
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{ parent: 2, compoundParent: 0, cells: [{ title: 'expanded', props: { colSpan: 2 } }] }
|
|
217
|
+
];
|
|
218
|
+
|
|
219
|
+
const onExpand: OnExpand = () => undefined;
|
|
220
|
+
const { asFragment } = render(
|
|
221
|
+
<Table aria-label="Aria labeled" onExpand={onExpand} cells={compoundColumns} rows={compoundRows}>
|
|
222
|
+
<TableHeader />
|
|
223
|
+
<TableBody />
|
|
224
|
+
</Table>
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
expect(asFragment()).toMatchSnapshot();
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test('Collapsible nested table', () => {
|
|
231
|
+
rows[0] = { ...rows[0], isOpen: false };
|
|
232
|
+
rows[1] = { ...rows[1], parent: 0, isOpen: true };
|
|
233
|
+
rows[2] = { ...rows[2], parent: 1 };
|
|
234
|
+
|
|
235
|
+
const onCollapse: OnCollapse = () => undefined;
|
|
236
|
+
const { asFragment } = render(
|
|
237
|
+
<Table aria-label="Aria labeled" onCollapse={onCollapse} cells={columns} rows={rows}>
|
|
238
|
+
<TableHeader />
|
|
239
|
+
<TableBody />
|
|
240
|
+
</Table>
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
expect(asFragment()).toMatchSnapshot();
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('Selectable table', () => {
|
|
247
|
+
const onSelect: OnSelect = () => undefined;
|
|
248
|
+
const { asFragment } = render(
|
|
249
|
+
<Table aria-label="Aria labeled" onSelect={onSelect} cells={columns} rows={rows}>
|
|
250
|
+
<TableHeader />
|
|
251
|
+
<TableBody />
|
|
252
|
+
</Table>
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
expect(asFragment()).toMatchSnapshot();
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
test('Selectable table with Radio', () => {
|
|
259
|
+
const onSelect: OnSelect = () => undefined;
|
|
260
|
+
const { asFragment } = render(
|
|
261
|
+
<Table
|
|
262
|
+
aria-label="Aria labeled"
|
|
263
|
+
selectVariant={RowSelectVariant.radio}
|
|
264
|
+
onSelect={onSelect}
|
|
265
|
+
cells={columns}
|
|
266
|
+
rows={rows}
|
|
267
|
+
>
|
|
268
|
+
<TableHeader />
|
|
269
|
+
<TableBody />
|
|
270
|
+
</Table>
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
expect(asFragment()).toMatchSnapshot();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
test('Control text table', () => {
|
|
277
|
+
const controlTextColumns: ICell[] = [
|
|
278
|
+
{ ...(columns[0] as object), transforms: [nowrap] },
|
|
279
|
+
{ title: 'new object column', transforms: [wrappable] },
|
|
280
|
+
{ ...(columns[2] as object), transforms: [breakWord] },
|
|
281
|
+
{ title: 'new object column', transforms: [truncate] },
|
|
282
|
+
{ ...(columns[4] as object), transforms: [fitContent] }
|
|
283
|
+
];
|
|
284
|
+
|
|
285
|
+
const { asFragment } = render(
|
|
286
|
+
<Table aria-label="Aria labeled" cells={controlTextColumns} rows={rows}>
|
|
287
|
+
<TableHeader />
|
|
288
|
+
<TableBody />
|
|
289
|
+
</Table>
|
|
290
|
+
);
|
|
291
|
+
expect(asFragment()).toMatchSnapshot();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test('Header width table', () => {
|
|
295
|
+
columns[0] = { ...(columns[0] as object), transforms: [cellWidth(10)] };
|
|
296
|
+
columns[2] = { ...(columns[2] as object), transforms: [cellWidth(30)] };
|
|
297
|
+
columns[4] = { ...(columns[4] as object), transforms: [cellWidth(100)] };
|
|
298
|
+
const { asFragment } = render(
|
|
299
|
+
<Table aria-label="Aria labeled" cells={columns} rows={rows}>
|
|
300
|
+
<TableHeader />
|
|
301
|
+
<TableBody />
|
|
302
|
+
</Table>
|
|
303
|
+
);
|
|
304
|
+
expect(asFragment()).toMatchSnapshot();
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test('Selectable table with selected expandable row', () => {
|
|
308
|
+
const data = {
|
|
309
|
+
cells: ['column'],
|
|
310
|
+
rows: [
|
|
311
|
+
{
|
|
312
|
+
cells: ['one'],
|
|
313
|
+
selected: true
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
cells: ['one'],
|
|
317
|
+
parent: 0
|
|
318
|
+
}
|
|
319
|
+
],
|
|
320
|
+
onSelect: (e: React.FormEvent<HTMLInputElement>) => e
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const { asFragment } = render(
|
|
324
|
+
<Table aria-label="Aria labeled" {...data}>
|
|
325
|
+
<TableHeader />
|
|
326
|
+
<TableBody />
|
|
327
|
+
</Table>
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
expect(asFragment()).toMatchSnapshot();
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
test('Empty state table', () => {
|
|
334
|
+
const data = {
|
|
335
|
+
cells: ['Hostname', 'IP address', 'Role', 'Team'],
|
|
336
|
+
rows: [
|
|
337
|
+
{
|
|
338
|
+
heightAuto: true,
|
|
339
|
+
cells: [
|
|
340
|
+
{
|
|
341
|
+
title: <div>Empty State Component</div>,
|
|
342
|
+
props: { colSpan: 8 }
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
|
+
]
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
render(
|
|
350
|
+
<Table aria-label="Aria labeled" {...data}>
|
|
351
|
+
<TableHeader />
|
|
352
|
+
<TableBody />
|
|
353
|
+
</Table>
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
expect(screen.getByText('Empty State Component').parentElement.getAttribute('colspan')).toEqual('8');
|
|
357
|
+
});
|
|
358
|
+
});
|
package/src/components/Table/{__snapshots__ → __tests__/__snapshots__}/RowWrapper.test.tsx.snap
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`RowWrapper renders correctly 1`] = `
|
|
4
|
-
<
|
|
4
|
+
<DocumentFragment>
|
|
5
5
|
<table>
|
|
6
6
|
<tbody>
|
|
7
7
|
<tr
|
|
@@ -12,11 +12,11 @@ exports[`RowWrapper renders correctly 1`] = `
|
|
|
12
12
|
/>
|
|
13
13
|
</tbody>
|
|
14
14
|
</table>
|
|
15
|
-
</
|
|
15
|
+
</DocumentFragment>
|
|
16
16
|
`;
|
|
17
17
|
|
|
18
18
|
exports[`RowWrapper renders expanded correctly 1`] = `
|
|
19
|
-
<
|
|
19
|
+
<DocumentFragment>
|
|
20
20
|
<table>
|
|
21
21
|
<tbody>
|
|
22
22
|
<tr
|
|
@@ -27,5 +27,5 @@ exports[`RowWrapper renders expanded correctly 1`] = `
|
|
|
27
27
|
/>
|
|
28
28
|
</tbody>
|
|
29
29
|
</table>
|
|
30
|
-
</
|
|
30
|
+
</DocumentFragment>
|
|
31
31
|
`;
|