@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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { Button } from '../../../button';
|
|
3
3
|
import {
|
|
4
4
|
CheckIcon,
|
|
@@ -11,29 +11,55 @@ import classNames from 'classnames';
|
|
|
11
11
|
|
|
12
12
|
import styles from './TableCell.module.scss';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
interface BaseTableCellProps {
|
|
15
15
|
align?: 'center' | 'left' | 'right';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
checkmarkValue?: boolean;
|
|
17
|
+
content?: ReactNode;
|
|
18
|
+
modalContent?: ReactNode;
|
|
19
|
+
openModal?: (modalContent: ReactNode) => void;
|
|
20
|
+
subContent?: ReactNode;
|
|
20
21
|
rating?: {
|
|
21
22
|
value: number;
|
|
22
23
|
type: 'zap' | 'star';
|
|
23
24
|
};
|
|
24
|
-
text?: ReactNode;
|
|
25
|
-
openModal?: (info: ReactNode) => void;
|
|
26
25
|
}
|
|
27
26
|
|
|
27
|
+
interface PositionalTableCellProps {
|
|
28
|
+
isHeader?: boolean;
|
|
29
|
+
isFirstCellInRow?: boolean;
|
|
30
|
+
isTopLeftCell?: boolean;
|
|
31
|
+
isNavigation?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type TableCellProps = BaseTableCellProps & PositionalTableCellProps;
|
|
35
|
+
|
|
28
36
|
const TableCell = ({
|
|
29
37
|
align = 'center',
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
checkmarkValue,
|
|
39
|
+
content = '',
|
|
40
|
+
isFirstCellInRow = false,
|
|
41
|
+
isHeader = false,
|
|
42
|
+
isNavigation = false,
|
|
43
|
+
isTopLeftCell = false,
|
|
44
|
+
modalContent = '',
|
|
33
45
|
openModal,
|
|
34
46
|
rating,
|
|
35
|
-
|
|
47
|
+
subContent = '',
|
|
36
48
|
}: TableCellProps) => {
|
|
49
|
+
// prettier-ignore
|
|
50
|
+
const Tag = isNavigation
|
|
51
|
+
? 'div'
|
|
52
|
+
: isHeader || isFirstCellInRow ? 'th' : 'td';
|
|
53
|
+
|
|
54
|
+
// prettier-ignore
|
|
55
|
+
const thScope = isHeader
|
|
56
|
+
? 'col'
|
|
57
|
+
: isFirstCellInRow ? 'row' : undefined;
|
|
58
|
+
|
|
59
|
+
const scope = {
|
|
60
|
+
scope: thScope,
|
|
61
|
+
};
|
|
62
|
+
|
|
37
63
|
const alignClassName = {
|
|
38
64
|
center: 'ta-center jc-center',
|
|
39
65
|
left: 'ta-left jc-start',
|
|
@@ -44,75 +70,96 @@ const TableCell = ({
|
|
|
44
70
|
const SelectedIcon = rating?.type === 'zap' ? ZapFilledIcon : StarFilledIcon;
|
|
45
71
|
|
|
46
72
|
return (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
<Tag
|
|
74
|
+
{...scope}
|
|
75
|
+
className={classNames('bg-white py24 px8', styles.th, {
|
|
76
|
+
'ta-left': isFirstCellInRow,
|
|
77
|
+
[styles.fixedCell]: isFirstCellInRow,
|
|
78
|
+
pl32: isFirstCellInRow,
|
|
79
|
+
})}
|
|
80
|
+
>
|
|
81
|
+
<div className="d-flex fd-column gap8">
|
|
82
|
+
<div className={classNames('d-flex gap8 ai-center', alignClassName)}>
|
|
83
|
+
{rating?.value && (
|
|
84
|
+
<span
|
|
85
|
+
data-testid="table-cell-rating"
|
|
86
|
+
title={`${rating?.value} out of 3`}
|
|
87
|
+
>
|
|
88
|
+
{validRatingValues.map((value) => (
|
|
89
|
+
<SelectedIcon
|
|
90
|
+
aria-hidden="true"
|
|
91
|
+
key={value}
|
|
92
|
+
color={value <= rating?.value ? 'primary-500' : 'grey-400'}
|
|
93
|
+
className={styles.icon}
|
|
94
|
+
/>
|
|
95
|
+
))}
|
|
96
|
+
</span>
|
|
97
|
+
)}
|
|
64
98
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
{checkmarkValue !== undefined && (
|
|
100
|
+
<span title={checkmarkValue ? 'Yes' : 'No'}>
|
|
101
|
+
{checkmarkValue ? (
|
|
102
|
+
<CheckIcon
|
|
103
|
+
data-testid="table-cell-boolean-yes"
|
|
104
|
+
size={24}
|
|
105
|
+
aria-hidden
|
|
106
|
+
color="primary-500"
|
|
107
|
+
/>
|
|
108
|
+
) : (
|
|
109
|
+
<XIcon
|
|
110
|
+
data-testid="table-cell-boolean-no"
|
|
111
|
+
size={24}
|
|
112
|
+
aria-hidden
|
|
113
|
+
color="grey-400"
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
</span>
|
|
117
|
+
)}
|
|
84
118
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
119
|
+
{content && !isTopLeftCell && (
|
|
120
|
+
<div className="p-p" data-testid="table-cell-content">
|
|
121
|
+
{content}
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
90
124
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)}
|
|
103
|
-
</div>
|
|
125
|
+
{content && isTopLeftCell && (
|
|
126
|
+
<div
|
|
127
|
+
aria-hidden
|
|
128
|
+
className={classNames(
|
|
129
|
+
'tc-grey-800 p-h2 p--serif',
|
|
130
|
+
styles.topLeftCell
|
|
131
|
+
)}
|
|
132
|
+
>
|
|
133
|
+
{content}
|
|
134
|
+
</div>
|
|
135
|
+
)}
|
|
104
136
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
137
|
+
{modalContent && openModal && (
|
|
138
|
+
<Button
|
|
139
|
+
className={styles.button}
|
|
140
|
+
hideLabel
|
|
141
|
+
leftIcon={<InfoIcon size={20} />}
|
|
142
|
+
onClick={() => openModal(modalContent)}
|
|
143
|
+
type="button"
|
|
144
|
+
variant="textColor"
|
|
145
|
+
>
|
|
146
|
+
View more info
|
|
147
|
+
</Button>
|
|
110
148
|
)}
|
|
111
|
-
>
|
|
112
|
-
{description}
|
|
113
149
|
</div>
|
|
114
|
-
|
|
115
|
-
|
|
150
|
+
|
|
151
|
+
{subContent && (
|
|
152
|
+
<div
|
|
153
|
+
className={classNames(
|
|
154
|
+
'd-flex p-p--small tc-grey-500',
|
|
155
|
+
alignClassName
|
|
156
|
+
)}
|
|
157
|
+
>
|
|
158
|
+
{subContent}
|
|
159
|
+
</div>
|
|
160
|
+
)}
|
|
161
|
+
</div>
|
|
162
|
+
</Tag>
|
|
116
163
|
);
|
|
117
164
|
};
|
|
118
165
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { render, screen } from '../../../../util/testUtils';
|
|
2
|
+
import { TableContents, TableSectionProps } from './TableContents';
|
|
3
|
+
|
|
4
|
+
const mockData: TableSectionProps['tableData'] = [
|
|
5
|
+
{
|
|
6
|
+
rows: [
|
|
7
|
+
[{ content: 'Item 1.1.1' }, { content: 'Item 1.1.2' }],
|
|
8
|
+
[{ content: 'Item 1.2.1' }, { content: 'Item 1.2.2' }],
|
|
9
|
+
],
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
section: {
|
|
13
|
+
title: 'Section 2',
|
|
14
|
+
},
|
|
15
|
+
rows: [
|
|
16
|
+
[{ content: 'Item 2.1.1' }, { content: 'Item 2.1.2' }],
|
|
17
|
+
[{ content: 'Item 2.2.1' }, { content: 'Item 2.2.2' }],
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
describe('TableContents', () => {
|
|
23
|
+
it('renders the table sections with sections', () => {
|
|
24
|
+
render(
|
|
25
|
+
<TableContents collapsibleSections tableData={mockData} title="Table" />
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
expect(screen.getByText('Section 2')).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders the table sections with sections data', () => {
|
|
32
|
+
render(
|
|
33
|
+
<TableContents collapsibleSections tableData={mockData} title="Table" />
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(screen.getByText('Item 1.2.1')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getByText('Item 1.2.2')).toBeInTheDocument();
|
|
38
|
+
expect(screen.getByText('Item 2.1.2')).toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText('Item 2.2.1')).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('hides the table sections when hideDetails and shouldHideDetails is true', () => {
|
|
43
|
+
render(
|
|
44
|
+
<TableContents
|
|
45
|
+
hideDetails
|
|
46
|
+
shouldHideDetails
|
|
47
|
+
tableData={mockData}
|
|
48
|
+
title="Table"
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
expect(screen.queryByText('Section 2')).not.toBeInTheDocument();
|
|
53
|
+
expect(screen.queryByText('Item 2.1.1')).not.toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('hides the table sections details when collapsibleSections is true', () => {
|
|
57
|
+
render(
|
|
58
|
+
<TableContents
|
|
59
|
+
collapsibleSections
|
|
60
|
+
isMobile
|
|
61
|
+
tableData={mockData}
|
|
62
|
+
title="Table"
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
expect(screen.getByText('Section 2')).toBeVisible();
|
|
67
|
+
expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('shows the table sections when hideDetails is collapsibleSections true has expanded ', async () => {
|
|
71
|
+
const { user } = render(
|
|
72
|
+
<TableContents
|
|
73
|
+
collapsibleSections
|
|
74
|
+
isMobile
|
|
75
|
+
tableData={mockData}
|
|
76
|
+
title="Table"
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect(screen.queryByText('Item 2.1.1')).not.toBeVisible();
|
|
81
|
+
|
|
82
|
+
await user.click(screen.getByText('Section 2'));
|
|
83
|
+
|
|
84
|
+
expect(screen.getByText('Item 2.1.1')).toBeVisible();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { TableSection } from '../TableSection/TableSection';
|
|
3
|
+
import { ChevronDownIcon, ChevronUpIcon } from '../../../icon';
|
|
4
|
+
import { Card } from '../../../cards/card';
|
|
5
|
+
|
|
6
|
+
import styles from './TableContents.module.scss';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import { Collapsible } from './Collapsible';
|
|
9
|
+
import { ModalFunction, TableData } from '../../types';
|
|
10
|
+
|
|
11
|
+
export interface TableContentsProps {
|
|
12
|
+
className?: string;
|
|
13
|
+
collapsibleSections?: boolean;
|
|
14
|
+
tableData: TableData;
|
|
15
|
+
hideDetails?: boolean;
|
|
16
|
+
isMobile?: boolean;
|
|
17
|
+
openModal?: ModalFunction;
|
|
18
|
+
shouldHideDetails?: boolean;
|
|
19
|
+
title: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const TableContents = ({
|
|
23
|
+
className,
|
|
24
|
+
collapsibleSections,
|
|
25
|
+
tableData,
|
|
26
|
+
hideDetails,
|
|
27
|
+
isMobile,
|
|
28
|
+
openModal,
|
|
29
|
+
shouldHideDetails,
|
|
30
|
+
title,
|
|
31
|
+
}: TableContentsProps) => {
|
|
32
|
+
const [isSectionOpen, setOpenSection] = useState<number | null>(null);
|
|
33
|
+
const firstHeadRow = tableData?.[0]?.rows?.[0];
|
|
34
|
+
const tableWidth = isMobile ? `${firstHeadRow?.length * 50}%` : '';
|
|
35
|
+
const handleToggleSection = (index: number) => {
|
|
36
|
+
setOpenSection((currentSection) =>
|
|
37
|
+
currentSection === index ? null : index
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div style={{ width: tableWidth }}>
|
|
43
|
+
{tableData.map(({ rows, section = {} }, index) => {
|
|
44
|
+
const isFirstSection = index === 0;
|
|
45
|
+
const isExpanded = !collapsibleSections
|
|
46
|
+
? true
|
|
47
|
+
: isSectionOpen === index || isFirstSection;
|
|
48
|
+
const isVisible = hideDetails ? !shouldHideDetails : true;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
(isFirstSection || isVisible) && (
|
|
52
|
+
<div key={index}>
|
|
53
|
+
{section?.title && (
|
|
54
|
+
<div className={styles.cardWrapper}>
|
|
55
|
+
<div className={classNames(styles.card, 'p8')}>
|
|
56
|
+
<Card
|
|
57
|
+
actionIcon={
|
|
58
|
+
isExpanded ? (
|
|
59
|
+
<ChevronUpIcon size={24} />
|
|
60
|
+
) : (
|
|
61
|
+
<ChevronDownIcon size={24} />
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
aria-expanded={isExpanded ? 'true' : 'false'}
|
|
65
|
+
aria-hidden
|
|
66
|
+
classNames={{
|
|
67
|
+
wrapper: 'bg-grey-200',
|
|
68
|
+
icon: 'tc-grey-900',
|
|
69
|
+
}}
|
|
70
|
+
dropShadow={false}
|
|
71
|
+
icon={section?.icon}
|
|
72
|
+
title={section.title}
|
|
73
|
+
titleVariant="medium"
|
|
74
|
+
{...(collapsibleSections
|
|
75
|
+
? {
|
|
76
|
+
onClick: () => handleToggleSection(index),
|
|
77
|
+
}
|
|
78
|
+
: {})}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
|
|
84
|
+
<Collapsible isExpanded={isExpanded} isMobile={isMobile}>
|
|
85
|
+
<TableSection
|
|
86
|
+
className={classNames(className, 'mb24')}
|
|
87
|
+
tableCellRows={
|
|
88
|
+
isFirstSection ? rows : [firstHeadRow, ...rows]
|
|
89
|
+
}
|
|
90
|
+
hideHeader
|
|
91
|
+
openModal={openModal}
|
|
92
|
+
title={`${title}${
|
|
93
|
+
section?.title ? ` - ${section.title}` : ''
|
|
94
|
+
}`}
|
|
95
|
+
width={tableWidth}
|
|
96
|
+
/>
|
|
97
|
+
</Collapsible>
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { TableContents };
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
@use '../../../../scss/public/colors' as *;
|
|
2
|
+
@use '../../../../scss/public/grid' as *;
|
|
3
|
+
|
|
4
|
+
.table {
|
|
5
|
+
border-collapse: collapse;
|
|
6
|
+
table-layout: fixed;
|
|
7
|
+
|
|
8
|
+
@include p-size-tablet {
|
|
9
|
+
min-width: 845px;
|
|
10
|
+
}
|
|
3
11
|
}
|
|
4
12
|
|
|
5
|
-
.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
right: 0;
|
|
9
|
-
z-index: 3;
|
|
10
|
-
}
|
|
13
|
+
.tr {
|
|
14
|
+
min-height: 72px;
|
|
15
|
+
}
|
|
@@ -1,82 +1,56 @@
|
|
|
1
1
|
import { render, screen } from '../../../../util/testUtils';
|
|
2
|
-
import { TableSection,
|
|
2
|
+
import { TableSection, TableContentProps } from './TableSection';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
[{ text: 'Item 1.1.1' }, { text: 'Item 1.1.2' }],
|
|
8
|
-
[{ text: 'Item 1.2.1' }, { text: 'Item 1.2.2' }],
|
|
9
|
-
],
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
section: {
|
|
13
|
-
title: 'Section 2',
|
|
14
|
-
},
|
|
15
|
-
items: [
|
|
16
|
-
[{ text: 'Item 2.1.1' }, { text: 'Item 2.1.2' }],
|
|
17
|
-
[{ text: 'Item 2.2.1' }, { text: 'Item 2.2.2' }],
|
|
18
|
-
],
|
|
19
|
-
},
|
|
4
|
+
const tableCellRows: TableContentProps['tableCellRows'] = [
|
|
5
|
+
[{ content: 'Cell 1.1' }, { content: 'Cell 1.2' }, { content: 'Cell 1.3' }],
|
|
6
|
+
[{ content: 'Cell 2.1' }, { content: 'Cell 2.2' }, { content: 'Cell 2.3' }],
|
|
20
7
|
];
|
|
21
8
|
|
|
22
|
-
|
|
23
|
-
it('renders the table sections with sections', () => {
|
|
24
|
-
render(<TableSection collapsibleSections data={mockData} title="Table" />);
|
|
25
|
-
|
|
26
|
-
expect(screen.getByText('Section 2')).toBeInTheDocument();
|
|
27
|
-
});
|
|
9
|
+
const mockTitle = 'Test Table';
|
|
28
10
|
|
|
29
|
-
|
|
30
|
-
render(<TableSection collapsibleSections data={mockData} title="Table" />);
|
|
11
|
+
const mockOpenModal = jest.fn();
|
|
31
12
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
const defaultProps: TableContentProps = {
|
|
14
|
+
tableCellRows,
|
|
15
|
+
title: mockTitle,
|
|
16
|
+
openModal: mockOpenModal,
|
|
17
|
+
};
|
|
37
18
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
hideDetails
|
|
42
|
-
shouldHideDetails
|
|
43
|
-
data={mockData}
|
|
44
|
-
title="Table"
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
19
|
+
describe('TableSection', () => {
|
|
20
|
+
it('renders the table caption', () => {
|
|
21
|
+
render(<TableSection {...defaultProps} />);
|
|
47
22
|
|
|
48
|
-
expect(screen.
|
|
49
|
-
expect(screen.queryByText('Item 2.1.1')).not.toBeInTheDocument();
|
|
23
|
+
expect(screen.getByText(mockTitle)).toBeInTheDocument();
|
|
50
24
|
});
|
|
51
25
|
|
|
52
|
-
it('
|
|
53
|
-
render(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
title="Table"
|
|
59
|
-
/>
|
|
60
|
-
);
|
|
26
|
+
it('renders the table with correct data', () => {
|
|
27
|
+
render(<TableSection {...defaultProps} />);
|
|
28
|
+
|
|
29
|
+
expect(screen.getByText('Cell 1.1')).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByText('Cell 1.2')).toBeInTheDocument();
|
|
31
|
+
expect(screen.getByText('Cell 1.3')).toBeInTheDocument();
|
|
61
32
|
|
|
62
|
-
expect(screen.getByText('
|
|
63
|
-
expect(screen.
|
|
33
|
+
expect(screen.getByText('Cell 2.1')).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText('Cell 2.2')).toBeInTheDocument();
|
|
35
|
+
expect(screen.getByText('Cell 2.3')).toBeInTheDocument();
|
|
64
36
|
});
|
|
65
37
|
|
|
66
|
-
it('
|
|
67
|
-
const {
|
|
68
|
-
<TableSection
|
|
69
|
-
collapsibleSections
|
|
70
|
-
isMobile
|
|
71
|
-
data={mockData}
|
|
72
|
-
title="Table"
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
38
|
+
it('should render table headers', () => {
|
|
39
|
+
const { container } = render(<TableSection {...defaultProps} />);
|
|
75
40
|
|
|
76
|
-
|
|
41
|
+
const thElements = container.querySelectorAll('th');
|
|
42
|
+
|
|
43
|
+
expect(thElements.length).toBe(4);
|
|
44
|
+
expect(thElements[0]).toHaveTextContent('Cell 1.1');
|
|
45
|
+
expect(thElements[3]).toHaveTextContent('Cell 2.1');
|
|
46
|
+
});
|
|
77
47
|
|
|
78
|
-
|
|
48
|
+
it('should render table data cells', () => {
|
|
49
|
+
const { container } = render(<TableSection {...defaultProps} />);
|
|
79
50
|
|
|
80
|
-
|
|
51
|
+
const tdElements = container.querySelectorAll('td');
|
|
52
|
+
expect(tdElements.length).toBe(2);
|
|
53
|
+
expect(tdElements[0]).toHaveTextContent('Cell 2.2');
|
|
54
|
+
expect(tdElements[1]).toHaveTextContent('Cell 2.3');
|
|
81
55
|
});
|
|
82
56
|
});
|