@integrigo/integrigo-ui 1.6.18-b → 1.6.18-c
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/lib/index.esm.js +1 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/src/components/molecules/TextArea/TextArea.d.ts +1 -0
- package/lib/src/components/organisms/Table/Table.d.ts +5 -3
- package/lib/src/components/organisms/Table/Table.stories.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/atoms/Chip/__snapshots__/Chip.test.tsx.snap +7 -21
- package/src/components/atoms/Dot/__snapshots__/Dot.test.tsx.snap +11 -0
- package/src/components/molecules/Button/__snapshots__/Button.test.tsx.snap +3 -3
- package/src/components/molecules/Profile/__snapshots__/Profile.test.tsx.snap +26 -0
- package/src/components/molecules/TextArea/TextArea.tsx +5 -1
- package/src/components/organisms/Table/Table.stories.tsx +108 -18
- package/src/components/organisms/Table/Table.test.tsx +71 -3
- package/src/components/organisms/Table/Table.tsx +39 -7
- package/src/components/organisms/Table/__snapshots__/Table.test.tsx.snap +129 -4
@@ -1,9 +1,10 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { ReactNode } from 'react';
|
2
2
|
import {
|
3
3
|
Column,
|
4
4
|
flexRender,
|
5
5
|
getCoreRowModel,
|
6
6
|
useReactTable,
|
7
|
+
Row,
|
7
8
|
} from '@tanstack/react-table';
|
8
9
|
import styled from 'styled-components';
|
9
10
|
|
@@ -25,7 +26,9 @@ export interface Props <T extends Record<string, unknown>> extends React.TableHT
|
|
25
26
|
data: T[];
|
26
27
|
columns: Column<T>[];
|
27
28
|
variant?: Variant;
|
28
|
-
textAlign?: Alignment
|
29
|
+
textAlign?: Alignment;
|
30
|
+
renderExpandableRowComponent?: (row: Row<T>) => ReactNode;
|
31
|
+
renderExpandCollapseComponent?: (row: Row<T>) => ReactNode;
|
29
32
|
}
|
30
33
|
|
31
34
|
export const Table = <T extends Record<string, unknown>>({
|
@@ -33,12 +36,34 @@ export const Table = <T extends Record<string, unknown>>({
|
|
33
36
|
columns,
|
34
37
|
variant = 'primary',
|
35
38
|
textAlign = 'center',
|
39
|
+
renderExpandableRowComponent,
|
40
|
+
renderExpandCollapseComponent,
|
36
41
|
...props
|
37
42
|
}: Props<T>) => {
|
38
43
|
|
44
|
+
const tableColumns = [
|
45
|
+
...columns,
|
46
|
+
...(typeof renderExpandableRowComponent !== 'undefined' && typeof renderExpandCollapseComponent !== 'undefined'
|
47
|
+
? [
|
48
|
+
{
|
49
|
+
accessorKey: 'expandable-column',
|
50
|
+
header: '',
|
51
|
+
cell: ({ row }: { row: Row<T> }) => {
|
52
|
+
return (
|
53
|
+
<>
|
54
|
+
{renderExpandCollapseComponent(row)}
|
55
|
+
</>
|
56
|
+
);
|
57
|
+
},
|
58
|
+
enableSorting: false,
|
59
|
+
},
|
60
|
+
]
|
61
|
+
: []),
|
62
|
+
];
|
63
|
+
|
39
64
|
const table = useReactTable({
|
40
65
|
data,
|
41
|
-
columns,
|
66
|
+
columns: tableColumns,
|
42
67
|
getCoreRowModel: getCoreRowModel(),
|
43
68
|
});
|
44
69
|
|
@@ -63,13 +88,22 @@ export const Table = <T extends Record<string, unknown>>({
|
|
63
88
|
</StyledHead>
|
64
89
|
<StyledBody textAlign={textAlign}>
|
65
90
|
{table.getRowModel().rows.map(row => (
|
66
|
-
<
|
91
|
+
<React.Fragment key={row.id}>
|
92
|
+
<tr>
|
67
93
|
{row.getVisibleCells().map(cell => (
|
68
94
|
<td key={cell.id}>
|
69
95
|
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
70
96
|
</td>
|
71
97
|
))}
|
72
98
|
</tr>
|
99
|
+
{row.getIsExpanded() && typeof renderExpandableRowComponent !== 'undefined' && (
|
100
|
+
<tr>
|
101
|
+
<td colSpan={tableColumns.length + 1}>
|
102
|
+
{renderExpandableRowComponent(row)}
|
103
|
+
</td>
|
104
|
+
</tr>
|
105
|
+
)}
|
106
|
+
</React.Fragment>
|
73
107
|
))}
|
74
108
|
</StyledBody>
|
75
109
|
</StyledTable>
|
@@ -77,9 +111,7 @@ export const Table = <T extends Record<string, unknown>>({
|
|
77
111
|
);
|
78
112
|
};
|
79
113
|
|
80
|
-
const StyledTable = styled.table
|
81
|
-
|
82
|
-
`;
|
114
|
+
const StyledTable = styled.table``;
|
83
115
|
|
84
116
|
StyledTable.displayName = 'StyledTable';
|
85
117
|
|
@@ -5,14 +5,14 @@ exports[`<Table /> enabled - should match snapshot 1`] = `
|
|
5
5
|
<div>
|
6
6
|
<table
|
7
7
|
cellspacing="0"
|
8
|
-
class="sc-
|
8
|
+
class="sc-bdvvtL gGYjnV"
|
9
9
|
>
|
10
10
|
<thead
|
11
|
-
class="sc-
|
11
|
+
class="sc-gsDKAQ goIZuE"
|
12
12
|
>
|
13
13
|
<tr>
|
14
14
|
<th>
|
15
|
-
|
15
|
+
First Name
|
16
16
|
</th>
|
17
17
|
<th>
|
18
18
|
Last Name
|
@@ -32,7 +32,7 @@ exports[`<Table /> enabled - should match snapshot 1`] = `
|
|
32
32
|
</tr>
|
33
33
|
</thead>
|
34
34
|
<tbody
|
35
|
-
class="sc-
|
35
|
+
class="sc-dkPtRN eONmCs"
|
36
36
|
>
|
37
37
|
<tr>
|
38
38
|
<td>
|
@@ -99,3 +99,128 @@ exports[`<Table /> enabled - should match snapshot 1`] = `
|
|
99
99
|
</div>
|
100
100
|
</div>
|
101
101
|
`;
|
102
|
+
|
103
|
+
exports[`<Table /> expandable rows - should match snapshot 1`] = `
|
104
|
+
<div>
|
105
|
+
<div>
|
106
|
+
<table
|
107
|
+
cellspacing="0"
|
108
|
+
class="sc-bdvvtL gGYjnV"
|
109
|
+
>
|
110
|
+
<thead
|
111
|
+
class="sc-gsDKAQ goIZuE"
|
112
|
+
>
|
113
|
+
<tr>
|
114
|
+
<th>
|
115
|
+
First Name
|
116
|
+
</th>
|
117
|
+
<th>
|
118
|
+
Last Name
|
119
|
+
</th>
|
120
|
+
<th>
|
121
|
+
Age
|
122
|
+
</th>
|
123
|
+
<th>
|
124
|
+
Visits
|
125
|
+
</th>
|
126
|
+
<th>
|
127
|
+
Status
|
128
|
+
</th>
|
129
|
+
<th>
|
130
|
+
Profile Progress
|
131
|
+
</th>
|
132
|
+
<th />
|
133
|
+
</tr>
|
134
|
+
</thead>
|
135
|
+
<tbody
|
136
|
+
class="sc-dkPtRN eONmCs"
|
137
|
+
>
|
138
|
+
<tr>
|
139
|
+
<td>
|
140
|
+
tanner
|
141
|
+
</td>
|
142
|
+
<td>
|
143
|
+
linsley
|
144
|
+
</td>
|
145
|
+
<td>
|
146
|
+
24
|
147
|
+
</td>
|
148
|
+
<td>
|
149
|
+
100
|
150
|
+
</td>
|
151
|
+
<td>
|
152
|
+
In Relationship
|
153
|
+
</td>
|
154
|
+
<td>
|
155
|
+
50
|
156
|
+
</td>
|
157
|
+
<td>
|
158
|
+
<div
|
159
|
+
data-testid="expand-button-0"
|
160
|
+
style="cursor: pointer;"
|
161
|
+
>
|
162
|
+
Edit
|
163
|
+
</div>
|
164
|
+
</td>
|
165
|
+
</tr>
|
166
|
+
<tr>
|
167
|
+
<td>
|
168
|
+
tandy
|
169
|
+
</td>
|
170
|
+
<td>
|
171
|
+
miller
|
172
|
+
</td>
|
173
|
+
<td>
|
174
|
+
40
|
175
|
+
</td>
|
176
|
+
<td>
|
177
|
+
40
|
178
|
+
</td>
|
179
|
+
<td>
|
180
|
+
Single
|
181
|
+
</td>
|
182
|
+
<td>
|
183
|
+
80
|
184
|
+
</td>
|
185
|
+
<td>
|
186
|
+
<div
|
187
|
+
data-testid="expand-button-1"
|
188
|
+
style="cursor: pointer;"
|
189
|
+
>
|
190
|
+
Edit
|
191
|
+
</div>
|
192
|
+
</td>
|
193
|
+
</tr>
|
194
|
+
<tr>
|
195
|
+
<td>
|
196
|
+
joe
|
197
|
+
</td>
|
198
|
+
<td>
|
199
|
+
dirte
|
200
|
+
</td>
|
201
|
+
<td>
|
202
|
+
45
|
203
|
+
</td>
|
204
|
+
<td>
|
205
|
+
20
|
206
|
+
</td>
|
207
|
+
<td>
|
208
|
+
Complicated
|
209
|
+
</td>
|
210
|
+
<td>
|
211
|
+
10
|
212
|
+
</td>
|
213
|
+
<td>
|
214
|
+
<div
|
215
|
+
data-testid="expand-button-2"
|
216
|
+
style="cursor: pointer;"
|
217
|
+
>
|
218
|
+
Edit
|
219
|
+
</div>
|
220
|
+
</td>
|
221
|
+
</tr>
|
222
|
+
</tbody>
|
223
|
+
</table>
|
224
|
+
</div>
|
225
|
+
</div>
|
226
|
+
`;
|