@popsure/dirty-swan 0.54.0 → 0.54.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/dist/cjs/index.js +281 -260
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/table/Table.d.ts +4 -14
- package/dist/cjs/lib/components/table/Table.stories.d.ts +14 -13
- package/dist/cjs/lib/components/table/components/TableCell/TableCell.d.ts +15 -9
- package/dist/cjs/lib/components/table/components/TableContents/TableContents.d.ts +13 -0
- package/dist/cjs/lib/components/table/components/TableSection/TableSection.d.ts +7 -17
- package/dist/cjs/lib/components/table/types.d.ts +17 -0
- package/dist/esm/{Collapsible-ac67187a.js → Collapsible-a355828b.js} +1 -1
- package/dist/esm/Collapsible-a355828b.js.map +1 -0
- package/dist/esm/components/table/Table.js +18 -15
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.stories.js +59 -54
- package/dist/esm/components/table/Table.stories.js.map +1 -1
- package/dist/esm/components/table/Table.test.js +18 -14
- package/dist/esm/components/table/Table.test.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.js +23 -6
- package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
- package/dist/esm/components/table/components/TableCell/TableCell.test.js +4 -4
- package/dist/esm/components/table/components/TableCell/TableCell.test.js.map +1 -1
- package/dist/esm/components/table/components/{TableSection → TableContents}/Collapsible.js +1 -1
- package/dist/esm/components/table/components/TableContents/TableContents.js +56 -0
- package/dist/esm/components/table/components/TableContents/TableContents.js.map +1 -0
- package/dist/esm/components/table/components/TableContents/TableContents.test.js +82 -0
- package/dist/esm/components/table/components/TableContents/TableContents.test.js.map +1 -0
- package/dist/esm/components/table/components/TableControls/TableControls.js +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.js +41 -39
- package/dist/esm/components/table/components/TableSection/TableSection.js.map +1 -1
- package/dist/esm/components/table/components/TableSection/TableSection.test.js +34 -57
- package/dist/esm/components/table/components/TableSection/TableSection.test.js.map +1 -1
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/components/table/Table.d.ts +4 -14
- package/dist/esm/lib/components/table/Table.stories.d.ts +14 -13
- package/dist/esm/lib/components/table/components/TableCell/TableCell.d.ts +15 -9
- package/dist/esm/lib/components/table/components/TableContents/TableContents.d.ts +13 -0
- package/dist/esm/lib/components/table/components/TableSection/TableSection.d.ts +7 -17
- package/dist/esm/lib/components/table/types.d.ts +17 -0
- package/package.json +1 -1
- package/src/lib/components/table/Table.stories.tsx +64 -59
- package/src/lib/components/table/Table.test.tsx +17 -11
- package/src/lib/components/table/Table.tsx +28 -45
- package/src/lib/components/table/components/TableCell/TableCell.module.scss +64 -1
- package/src/lib/components/table/components/TableCell/TableCell.test.tsx +6 -4
- package/src/lib/components/table/components/TableCell/TableCell.tsx +122 -75
- package/src/lib/components/table/components/TableContents/TableContents.module.scss +10 -0
- package/src/lib/components/table/components/TableContents/TableContents.test.tsx +86 -0
- package/src/lib/components/table/components/TableContents/TableContents.tsx +106 -0
- package/src/lib/components/table/components/TableControls/TableControls.module.scss +2 -1
- package/src/lib/components/table/components/TableSection/TableSection.module.scss +13 -8
- package/src/lib/components/table/components/TableSection/TableSection.test.tsx +38 -64
- package/src/lib/components/table/components/TableSection/TableSection.tsx +98 -94
- package/src/lib/components/table/types.ts +23 -0
- package/dist/cjs/lib/components/table/components/TableColumn/TableColumn.d.ts +0 -10
- package/dist/cjs/lib/components/table/components/TableContent/TableContent.d.ts +0 -13
- package/dist/esm/Collapsible-ac67187a.js.map +0 -1
- package/dist/esm/components/table/components/TableColumn/TableColumn.js +0 -22
- package/dist/esm/components/table/components/TableColumn/TableColumn.js.map +0 -1
- package/dist/esm/components/table/components/TableColumn/TableColumn.test.js +0 -40
- package/dist/esm/components/table/components/TableColumn/TableColumn.test.js.map +0 -1
- package/dist/esm/components/table/components/TableContent/TableContent.js +0 -45
- package/dist/esm/components/table/components/TableContent/TableContent.js.map +0 -1
- package/dist/esm/components/table/components/TableContent/TableContent.test.js +0 -61
- package/dist/esm/components/table/components/TableContent/TableContent.test.js.map +0 -1
- package/dist/esm/lib/components/table/components/TableColumn/TableColumn.d.ts +0 -10
- package/dist/esm/lib/components/table/components/TableColumn/TableColumn.test.d.ts +0 -1
- package/dist/esm/lib/components/table/components/TableContent/TableContent.d.ts +0 -13
- package/dist/esm/lib/components/table/components/TableContent/TableContent.test.d.ts +0 -1
- package/src/lib/components/table/components/TableColumn/TableColumn.module.scss +0 -38
- package/src/lib/components/table/components/TableColumn/TableColumn.test.tsx +0 -49
- package/src/lib/components/table/components/TableColumn/TableColumn.tsx +0 -37
- package/src/lib/components/table/components/TableContent/TableContent.module.scss +0 -38
- package/src/lib/components/table/components/TableContent/TableContent.test.tsx +0 -56
- package/src/lib/components/table/components/TableContent/TableContent.tsx +0 -127
- /package/dist/cjs/lib/components/table/components/{TableSection → TableContents}/Collapsible.d.ts +0 -0
- /package/dist/cjs/lib/components/table/components/{TableColumn/TableColumn.test.d.ts → TableContents/TableContents.test.d.ts} +0 -0
- /package/dist/esm/components/table/components/{TableSection → TableContents}/Collapsible.js.map +0 -0
- /package/dist/esm/lib/components/table/components/{TableSection → TableContents}/Collapsible.d.ts +0 -0
- /package/dist/{cjs/lib/components/table/components/TableContent/TableContent.test.d.ts → esm/lib/components/table/components/TableContents/TableContents.test.d.ts} +0 -0
- /package/src/lib/components/table/components/{TableSection → TableContents}/Collapsible.tsx +0 -0
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
import { Table,
|
|
1
|
+
import { Table, TableProps } from './Table';
|
|
2
2
|
import { DentalPlusIcon, PlaneIcon } from '../icon';
|
|
3
|
+
import { TableData } from './types';
|
|
3
4
|
|
|
4
5
|
const initialData: TableData = [
|
|
5
6
|
{
|
|
6
|
-
|
|
7
|
+
rows: [
|
|
7
8
|
[
|
|
8
|
-
{
|
|
9
|
-
{
|
|
10
|
-
{
|
|
11
|
-
{
|
|
9
|
+
{ content: 'Our plans' },
|
|
10
|
+
{ content: 'Surgery', modalContent: 'More info on surgery' },
|
|
11
|
+
{ content: 'Standard' },
|
|
12
|
+
{ content: 'Premium' },
|
|
12
13
|
],
|
|
13
14
|
[
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
{
|
|
16
|
+
content: 'Regular vet visits & medication',
|
|
17
|
+
subContent: 'Annual Only',
|
|
18
|
+
},
|
|
19
|
+
{ content: 'No', subContent: 'Annual Only' },
|
|
20
|
+
{ content: 'Yes' },
|
|
21
|
+
{ content: 'Yes' },
|
|
18
22
|
],
|
|
19
23
|
[
|
|
20
|
-
{
|
|
21
|
-
{
|
|
22
|
-
{
|
|
23
|
-
{
|
|
24
|
+
{ content: 'Operations', modalContent: 'Operations info' },
|
|
25
|
+
{ checkmarkValue: true, modalContent: 'Operations info column 2' },
|
|
26
|
+
{ checkmarkValue: false },
|
|
27
|
+
{ checkmarkValue: true },
|
|
24
28
|
],
|
|
25
29
|
[
|
|
26
|
-
{
|
|
27
|
-
{ rating: { type: 'zap', value: 1 }
|
|
28
|
-
{
|
|
30
|
+
{ content: 'Rating', modalContent: 'Rating info' },
|
|
31
|
+
{ rating: { type: 'zap', value: 1 } },
|
|
32
|
+
{
|
|
33
|
+
rating: { type: 'zap', value: 3 },
|
|
34
|
+
modalContent: 'Rating info column 3',
|
|
35
|
+
},
|
|
29
36
|
{ rating: { type: 'star', value: 3 } },
|
|
30
37
|
],
|
|
31
38
|
],
|
|
@@ -35,22 +42,22 @@ const initialData: TableData = [
|
|
|
35
42
|
icon: <DentalPlusIcon size={24} noMargin />,
|
|
36
43
|
title: 'Dental',
|
|
37
44
|
},
|
|
38
|
-
|
|
45
|
+
rows: [
|
|
39
46
|
[
|
|
40
|
-
{
|
|
41
|
-
{
|
|
42
|
-
{
|
|
43
|
-
{
|
|
47
|
+
{ content: 'Regular vet visits & medication' },
|
|
48
|
+
{ content: 'No' },
|
|
49
|
+
{ content: 'Yes' },
|
|
50
|
+
{ content: 'Yes' },
|
|
44
51
|
],
|
|
45
52
|
[
|
|
46
|
-
{
|
|
47
|
-
{
|
|
48
|
-
{
|
|
49
|
-
{
|
|
53
|
+
{ content: 'Operations', modalContent: 'info' },
|
|
54
|
+
{ checkmarkValue: true, modalContent: 'Maybe' },
|
|
55
|
+
{ checkmarkValue: false },
|
|
56
|
+
{ checkmarkValue: true },
|
|
50
57
|
],
|
|
51
58
|
[
|
|
52
|
-
{
|
|
53
|
-
{ rating: { type: 'zap', value: 1 },
|
|
59
|
+
{ content: 'Rating', modalContent: 'info' },
|
|
60
|
+
{ rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },
|
|
54
61
|
{ rating: { type: 'zap', value: 3 } },
|
|
55
62
|
{ rating: { type: 'star', value: 3 } },
|
|
56
63
|
],
|
|
@@ -61,22 +68,22 @@ const initialData: TableData = [
|
|
|
61
68
|
title: 'Travel',
|
|
62
69
|
icon: <PlaneIcon size={24} noMargin />,
|
|
63
70
|
},
|
|
64
|
-
|
|
71
|
+
rows: [
|
|
65
72
|
[
|
|
66
|
-
{
|
|
67
|
-
{
|
|
68
|
-
{
|
|
69
|
-
{
|
|
73
|
+
{ content: 'Regular vet visits & medication' },
|
|
74
|
+
{ content: 'No', checkmarkValue: false },
|
|
75
|
+
{ content: 'Yes' },
|
|
76
|
+
{ content: 'Yes' },
|
|
70
77
|
],
|
|
71
78
|
[
|
|
72
|
-
{
|
|
73
|
-
{
|
|
74
|
-
{
|
|
75
|
-
{
|
|
79
|
+
{ content: 'Operations', modalContent: 'info' },
|
|
80
|
+
{ checkmarkValue: true, modalContent: 'Maybe' },
|
|
81
|
+
{ checkmarkValue: false },
|
|
82
|
+
{ checkmarkValue: true },
|
|
76
83
|
],
|
|
77
84
|
[
|
|
78
|
-
{
|
|
79
|
-
{ rating: { type: 'zap', value: 1 },
|
|
85
|
+
{ content: 'Rating', modalContent: 'info' },
|
|
86
|
+
{ rating: { type: 'zap', value: 1 }, modalContent: 'Maybe' },
|
|
80
87
|
{ rating: { type: 'zap', value: 3 } },
|
|
81
88
|
{ rating: { type: 'star', value: 3 } },
|
|
82
89
|
],
|
|
@@ -89,41 +96,40 @@ const story = {
|
|
|
89
96
|
component: Table,
|
|
90
97
|
argTypes: {
|
|
91
98
|
data: {
|
|
92
|
-
|
|
99
|
+
subContent:
|
|
93
100
|
'This property allows to set the data of the Table component.',
|
|
94
101
|
},
|
|
95
102
|
title: {
|
|
96
|
-
|
|
103
|
+
subContent:
|
|
97
104
|
'This property allows to add a title to the Table component for accessibility purposes.',
|
|
98
105
|
},
|
|
99
106
|
collapsibleSections: {
|
|
100
|
-
|
|
101
|
-
'This property allows to collapse the sections of the table.',
|
|
107
|
+
subContent: 'This property allows to collapse the sections of the table.',
|
|
102
108
|
},
|
|
103
109
|
hideDetails: {
|
|
104
|
-
|
|
110
|
+
subContent: 'This property allows to hide the details of the table.',
|
|
105
111
|
},
|
|
106
112
|
stickyHeaderTopOffset: {
|
|
107
|
-
|
|
113
|
+
subContent:
|
|
108
114
|
'This property allows to set the offset of the sticky header.',
|
|
109
115
|
},
|
|
110
116
|
className: {
|
|
111
|
-
|
|
117
|
+
subContent:
|
|
112
118
|
'This property allows to set a custom class to the Table component.',
|
|
113
119
|
},
|
|
114
120
|
textOverrides: {
|
|
115
|
-
|
|
121
|
+
subContent:
|
|
116
122
|
'This property allows to set custom text for the show and hide details buttons.',
|
|
117
123
|
},
|
|
118
124
|
onSelectionChanged: {
|
|
119
|
-
|
|
125
|
+
subContent:
|
|
120
126
|
'This event is triggered when a selection is changed. It receives the index of the selection as an argument.',
|
|
121
127
|
table: {
|
|
122
128
|
category: 'Events',
|
|
123
129
|
},
|
|
124
130
|
},
|
|
125
131
|
onModalOpen: {
|
|
126
|
-
|
|
132
|
+
subContent:
|
|
127
133
|
'This event is triggered when a modal is opened. It receives the title and body of the modal as arguments.',
|
|
128
134
|
table: {
|
|
129
135
|
category: 'Events',
|
|
@@ -131,7 +137,7 @@ const story = {
|
|
|
131
137
|
},
|
|
132
138
|
},
|
|
133
139
|
args: {
|
|
134
|
-
|
|
140
|
+
tableData: initialData,
|
|
135
141
|
collapsibleSections: false,
|
|
136
142
|
hideDetails: false,
|
|
137
143
|
stickyHeaderTopOffset: 0,
|
|
@@ -146,7 +152,7 @@ const story = {
|
|
|
146
152
|
|
|
147
153
|
export const TableStory = ({
|
|
148
154
|
collapsibleSections,
|
|
149
|
-
|
|
155
|
+
tableData,
|
|
150
156
|
hideDetails,
|
|
151
157
|
stickyHeaderTopOffset,
|
|
152
158
|
textOverrides,
|
|
@@ -154,7 +160,7 @@ export const TableStory = ({
|
|
|
154
160
|
}: TableProps) => (
|
|
155
161
|
<Table
|
|
156
162
|
collapsibleSections={collapsibleSections}
|
|
157
|
-
|
|
163
|
+
tableData={tableData}
|
|
158
164
|
hideDetails={hideDetails}
|
|
159
165
|
stickyHeaderTopOffset={stickyHeaderTopOffset}
|
|
160
166
|
textOverrides={textOverrides}
|
|
@@ -171,18 +177,17 @@ type TableData = {
|
|
|
171
177
|
title?: string;
|
|
172
178
|
icon?: ReactNode;
|
|
173
179
|
};
|
|
174
|
-
|
|
180
|
+
rows: {
|
|
175
181
|
align?: 'center' | 'left' | 'right';
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
182
|
+
checkmarkValue?: boolean;
|
|
183
|
+
content?: ReactNode;
|
|
184
|
+
modalContent?: ReactNode;
|
|
185
|
+
subContent?: ReactNode;
|
|
180
186
|
rating?: {
|
|
181
187
|
value: number;
|
|
182
188
|
type: 'zap' | 'star';
|
|
183
189
|
}
|
|
184
|
-
|
|
185
|
-
openModal?: (info: ReactNode) => void;
|
|
190
|
+
openModal?: (modalContent: ReactNode) => void;
|
|
186
191
|
}[][];
|
|
187
192
|
}[];
|
|
188
193
|
`}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { render, screen } from '../../util/testUtils';
|
|
2
2
|
import { Table } from './Table';
|
|
3
|
+
import { TableSectionData } from './types';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const tableData: TableSectionData[] = [
|
|
5
6
|
{
|
|
6
7
|
section: {
|
|
7
8
|
title: 'Section 1',
|
|
8
9
|
icon: <span>Icon 1</span>,
|
|
9
10
|
},
|
|
10
|
-
|
|
11
|
+
rows: [[{ content: 'Item 1' }, { content: 'Item 2' }]],
|
|
11
12
|
},
|
|
12
13
|
{
|
|
13
14
|
section: {
|
|
14
15
|
title: 'Section 2',
|
|
15
16
|
icon: <span>Icon 2</span>,
|
|
16
17
|
},
|
|
17
|
-
|
|
18
|
+
rows: [
|
|
19
|
+
[
|
|
20
|
+
{ content: 'Item 3' },
|
|
21
|
+
{ content: 'Item 4', modalContent: 'Additional item' },
|
|
22
|
+
],
|
|
23
|
+
],
|
|
18
24
|
},
|
|
19
25
|
];
|
|
20
26
|
|
|
21
27
|
describe('Table', () => {
|
|
22
28
|
it('renders the table with sections and items', () => {
|
|
23
|
-
render(<Table
|
|
29
|
+
render(<Table tableData={tableData} title="Test Table" />);
|
|
24
30
|
|
|
25
31
|
expect(screen.getByText('Section 1')).toBeInTheDocument();
|
|
26
32
|
expect(screen.getByText('Section 2')).toBeInTheDocument();
|
|
@@ -32,28 +38,28 @@ describe('Table', () => {
|
|
|
32
38
|
});
|
|
33
39
|
|
|
34
40
|
it('renders the table without sections', () => {
|
|
35
|
-
const dataWithoutSections = [{
|
|
41
|
+
const dataWithoutSections = [{ rows: tableData[0].rows }];
|
|
36
42
|
|
|
37
|
-
render(<Table
|
|
43
|
+
render(<Table tableData={dataWithoutSections} title="Test Table" />);
|
|
38
44
|
|
|
39
45
|
expect(screen.getAllByText('Item 1')[0]).toBeVisible();
|
|
40
46
|
expect(screen.getAllByText('Item 2')[0]).toBeVisible();
|
|
41
47
|
});
|
|
42
48
|
|
|
43
49
|
it('hides the show/hide details button if hideDetails is false', () => {
|
|
44
|
-
render(<Table
|
|
50
|
+
render(<Table tableData={tableData} hideDetails title="Test Table" />);
|
|
45
51
|
|
|
46
52
|
expect(screen.queryByTestId('show-hide-details')).toBeInTheDocument();
|
|
47
53
|
});
|
|
48
54
|
|
|
49
55
|
it('shows the show/hide details button if hideDetails is true', () => {
|
|
50
|
-
render(<Table
|
|
56
|
+
render(<Table tableData={tableData} hideDetails title="Test Table" />);
|
|
51
57
|
|
|
52
58
|
expect(screen.getByTestId('show-hide-details')).toBeInTheDocument();
|
|
53
59
|
});
|
|
54
60
|
|
|
55
61
|
it('hides the sections if hideDetails is true', () => {
|
|
56
|
-
render(<Table
|
|
62
|
+
render(<Table tableData={tableData} hideDetails title="Test Table" />);
|
|
57
63
|
|
|
58
64
|
expect(screen.queryByText('Section 2')).not.toBeInTheDocument();
|
|
59
65
|
expect(screen.getByTestId('show-hide-details')).toBeInTheDocument();
|
|
@@ -61,7 +67,7 @@ describe('Table', () => {
|
|
|
61
67
|
|
|
62
68
|
it('hides the sections if hideDetails is true and shows if clicking on button', async () => {
|
|
63
69
|
const { user } = render(
|
|
64
|
-
<Table
|
|
70
|
+
<Table tableData={tableData} hideDetails title="Test Table" />
|
|
65
71
|
);
|
|
66
72
|
|
|
67
73
|
expect(screen.getByText('Show details')).toBeVisible();
|
|
@@ -73,7 +79,7 @@ describe('Table', () => {
|
|
|
73
79
|
});
|
|
74
80
|
|
|
75
81
|
it('shows a modal when clicking on info icon', async () => {
|
|
76
|
-
const { user } = render(<Table
|
|
82
|
+
const { user } = render(<Table tableData={tableData} title="Test Table" />);
|
|
77
83
|
|
|
78
84
|
await user.click(screen.getByText('View more info'));
|
|
79
85
|
|
|
@@ -1,51 +1,30 @@
|
|
|
1
1
|
import { TableCell, TableCellProps } from './components/TableCell/TableCell';
|
|
2
2
|
import { BottomOrRegularModal } from '../modal';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
ChevronDownIcon,
|
|
6
|
-
ChevronLeftIcon,
|
|
7
|
-
ChevronRightIcon,
|
|
8
|
-
ChevronUpIcon,
|
|
9
|
-
} from '../icon';
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { ChevronDownIcon, ChevronUpIcon } from '../icon';
|
|
10
5
|
import { Card } from '../cards/card';
|
|
11
6
|
|
|
12
7
|
import styles from './Table.module.scss';
|
|
13
8
|
import { useMediaQuery } from '../../hooks/useMediaQuery';
|
|
14
|
-
import {
|
|
9
|
+
import { TableContents } from './components/TableContents/TableContents';
|
|
15
10
|
import classNames from 'classnames';
|
|
16
11
|
import { useTableNavigation } from './utils/useTableNavigation/useTableNavigation';
|
|
17
12
|
import { TableControls } from './components/TableControls/TableControls';
|
|
18
|
-
import {
|
|
13
|
+
import { TableSection } from './components/TableSection/TableSection';
|
|
19
14
|
import { useScrollSync } from './utils/useScrollSync/useScrollSync';
|
|
15
|
+
import { ModalData, ModalFunction, TableData } from './types';
|
|
20
16
|
|
|
21
17
|
type TextOverrides = {
|
|
22
18
|
showDetails?: string;
|
|
23
19
|
hideDetails?: string;
|
|
24
20
|
};
|
|
25
21
|
|
|
26
|
-
export type TableSectionType = {
|
|
27
|
-
title?: string;
|
|
28
|
-
icon?: ReactNode;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
interface ModalType {
|
|
32
|
-
title?: ReactNode;
|
|
33
|
-
body?: ReactNode;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
interface TableSectionData {
|
|
37
|
-
section?: TableSectionType;
|
|
38
|
-
items: TableCellProps[][];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type TableData = TableSectionData[];
|
|
42
|
-
|
|
43
22
|
export interface TableProps {
|
|
44
23
|
className?: string;
|
|
45
24
|
collapsibleSections?: boolean;
|
|
46
|
-
|
|
25
|
+
tableData: TableData;
|
|
47
26
|
hideDetails?: boolean;
|
|
48
|
-
onModalOpen?:
|
|
27
|
+
onModalOpen?: ModalFunction;
|
|
49
28
|
onSelectionChanged?: (index: number) => void;
|
|
50
29
|
stickyHeaderTopOffset?: number;
|
|
51
30
|
textOverrides?: TextOverrides;
|
|
@@ -60,7 +39,7 @@ const defaultTextOverrides = {
|
|
|
60
39
|
const Table = ({
|
|
61
40
|
className,
|
|
62
41
|
collapsibleSections,
|
|
63
|
-
|
|
42
|
+
tableData,
|
|
64
43
|
hideDetails,
|
|
65
44
|
onModalOpen,
|
|
66
45
|
onSelectionChanged,
|
|
@@ -70,11 +49,11 @@ const Table = ({
|
|
|
70
49
|
}: TableProps) => {
|
|
71
50
|
const textOverrides = { ...defaultTextOverrides, ...definedTextOverrides };
|
|
72
51
|
const isMobile = useMediaQuery('BELOW_MOBILE');
|
|
73
|
-
const [
|
|
52
|
+
const [infoModalData, setInfoModalData] = useState<ModalData | null>(null);
|
|
74
53
|
const [shouldHideDetails, setShouldHideDetails] = useState(true);
|
|
75
54
|
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
76
55
|
const headerRef = useRef<HTMLDivElement | null>(null);
|
|
77
|
-
const columnsLength =
|
|
56
|
+
const columnsLength = tableData[0].rows[0].length;
|
|
78
57
|
|
|
79
58
|
useScrollSync(headerRef, containerRef, !isMobile);
|
|
80
59
|
|
|
@@ -85,11 +64,11 @@ const Table = ({
|
|
|
85
64
|
onSelectionChanged,
|
|
86
65
|
});
|
|
87
66
|
|
|
88
|
-
const currentActiveSection =
|
|
67
|
+
const currentActiveSection = tableData?.[0]?.rows?.[0]?.[activeSection];
|
|
89
68
|
|
|
90
|
-
const handleOpenModal = (
|
|
91
|
-
onModalOpen?.(
|
|
92
|
-
|
|
69
|
+
const handleOpenModal: ModalFunction = ({ body, title }) => {
|
|
70
|
+
onModalOpen?.({ body, title });
|
|
71
|
+
setInfoModalData({ body, title });
|
|
93
72
|
};
|
|
94
73
|
|
|
95
74
|
return (
|
|
@@ -103,9 +82,13 @@ const Table = ({
|
|
|
103
82
|
>
|
|
104
83
|
<TableCell
|
|
105
84
|
{...currentActiveSection}
|
|
106
|
-
openModal={(
|
|
107
|
-
handleOpenModal(
|
|
85
|
+
openModal={(body) =>
|
|
86
|
+
handleOpenModal({
|
|
87
|
+
body,
|
|
88
|
+
title: currentActiveSection?.content,
|
|
89
|
+
})
|
|
108
90
|
}
|
|
91
|
+
isNavigation
|
|
109
92
|
/>
|
|
110
93
|
</TableControls>
|
|
111
94
|
) : (
|
|
@@ -115,8 +98,8 @@ const Table = ({
|
|
|
115
98
|
style={{ top: `${stickyHeaderTopOffset}px` }}
|
|
116
99
|
>
|
|
117
100
|
<div className={styles.container} ref={headerRef}>
|
|
118
|
-
<
|
|
119
|
-
|
|
101
|
+
<TableSection
|
|
102
|
+
tableCellRows={[tableData?.[0]?.rows?.[0]]}
|
|
120
103
|
title={title}
|
|
121
104
|
className={className}
|
|
122
105
|
openModal={handleOpenModal}
|
|
@@ -126,8 +109,8 @@ const Table = ({
|
|
|
126
109
|
)}
|
|
127
110
|
|
|
128
111
|
<div ref={containerRef} className={classNames(styles.container, 'pb8')}>
|
|
129
|
-
<
|
|
130
|
-
|
|
112
|
+
<TableContents
|
|
113
|
+
tableData={tableData}
|
|
131
114
|
title={title}
|
|
132
115
|
className={className}
|
|
133
116
|
collapsibleSections={collapsibleSections}
|
|
@@ -167,11 +150,11 @@ const Table = ({
|
|
|
167
150
|
)}
|
|
168
151
|
|
|
169
152
|
<BottomOrRegularModal
|
|
170
|
-
isOpen={
|
|
171
|
-
title={
|
|
172
|
-
onClose={() =>
|
|
153
|
+
isOpen={infoModalData?.body ? true : false}
|
|
154
|
+
title={infoModalData?.title}
|
|
155
|
+
onClose={() => setInfoModalData(null)}
|
|
173
156
|
>
|
|
174
|
-
<div className="pt8 p24 wmn6">{
|
|
157
|
+
<div className="pt8 p24 wmn6">{infoModalData?.body}</div>
|
|
175
158
|
</BottomOrRegularModal>
|
|
176
159
|
</div>
|
|
177
160
|
);
|
|
@@ -1,9 +1,72 @@
|
|
|
1
|
+
@use '../../../../scss/public/colors' as *;
|
|
2
|
+
@use '../../../../scss/public/grid' as *;
|
|
3
|
+
|
|
1
4
|
.button {
|
|
2
5
|
min-height: initial;
|
|
3
6
|
height: initial;
|
|
4
7
|
width: initial;
|
|
8
|
+
padding: 0;
|
|
5
9
|
}
|
|
6
10
|
|
|
7
11
|
.icon {
|
|
8
12
|
margin: 2px;
|
|
9
|
-
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.th {
|
|
16
|
+
vertical-align: middle;
|
|
17
|
+
scroll-snap-align: end;
|
|
18
|
+
width: 50%;
|
|
19
|
+
|
|
20
|
+
@include p-size-tablet {
|
|
21
|
+
width: auto;
|
|
22
|
+
scroll-snap-align: unset;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.thRow {
|
|
27
|
+
position: sticky;
|
|
28
|
+
top: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.thCol {
|
|
32
|
+
text-align: left;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.fixedCell {
|
|
36
|
+
position: sticky;
|
|
37
|
+
left: 0;
|
|
38
|
+
z-index: 2;
|
|
39
|
+
|
|
40
|
+
&:after {
|
|
41
|
+
content: '';
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 0;
|
|
44
|
+
bottom: 0;
|
|
45
|
+
right: 0;
|
|
46
|
+
width: 1px;
|
|
47
|
+
background-color: $ds-grey-200;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.topLeftCell {
|
|
52
|
+
position: relative;
|
|
53
|
+
display: none;
|
|
54
|
+
|
|
55
|
+
&:after {
|
|
56
|
+
content: '';
|
|
57
|
+
display: block;
|
|
58
|
+
position: absolute;
|
|
59
|
+
top: calc(
|
|
60
|
+
50% + 16px
|
|
61
|
+
); // Display bottom border at the same distance regardless of cell height
|
|
62
|
+
|
|
63
|
+
height: 4px;
|
|
64
|
+
width: 100%;
|
|
65
|
+
max-width: 140px;
|
|
66
|
+
background-color: $ds-primary-500;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@include p-size-tablet {
|
|
70
|
+
display: flex;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -5,14 +5,14 @@ const openModal = jest.fn();
|
|
|
5
5
|
|
|
6
6
|
describe('TableCell', () => {
|
|
7
7
|
it('renders the component with boolean true', () => {
|
|
8
|
-
render(<TableCell
|
|
8
|
+
render(<TableCell checkmarkValue={true} />);
|
|
9
9
|
|
|
10
10
|
expect(screen.getByTitle('Yes')).toBeInTheDocument();
|
|
11
11
|
expect(screen.getByTestId('table-cell-boolean-yes')).toBeInTheDocument();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it('renders the component with boolean false', () => {
|
|
15
|
-
render(<TableCell
|
|
15
|
+
render(<TableCell checkmarkValue={false} />);
|
|
16
16
|
|
|
17
17
|
expect(screen.getByTitle('No')).toBeInTheDocument();
|
|
18
18
|
expect(screen.getByTestId('table-cell-boolean-no')).toBeInTheDocument();
|
|
@@ -44,7 +44,7 @@ describe('TableCell', () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it('renders the component with text', () => {
|
|
47
|
-
render(<TableCell
|
|
47
|
+
render(<TableCell content="Sample text" />);
|
|
48
48
|
|
|
49
49
|
expect(screen.getByText('Sample text')).toBeInTheDocument();
|
|
50
50
|
});
|
|
@@ -62,7 +62,9 @@ describe('TableCell', () => {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
it('calls openModal when info button is clicked', () => {
|
|
65
|
-
render(
|
|
65
|
+
render(
|
|
66
|
+
<TableCell modalContent="Additional information" openModal={openModal} />
|
|
67
|
+
);
|
|
66
68
|
|
|
67
69
|
// Click info button
|
|
68
70
|
screen.getByText('View more info').click();
|