@integrigo/integrigo-ui 1.6.18-b → 1.6.18-d
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.d.ts +2 -1
- 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/atoms/Dot/Dot.stories.d.ts +3 -3
- package/lib/src/components/atoms/Icon/Icon.d.ts +1 -0
- package/lib/src/components/atoms/Icon/Icon.stories.d.ts +2 -2
- package/lib/src/components/atoms/Icon/icons/ArrowCircleRight.d.ts +3 -0
- package/lib/src/components/molecules/Checkbox/Checkbox.stories.d.ts +4 -4
- package/lib/src/components/molecules/IconButton/IconButton.d.ts +7 -0
- package/lib/src/components/molecules/IconButton/IconButton.stories.d.ts +5 -0
- package/lib/src/components/molecules/IconButton/index.d.ts +1 -0
- package/lib/src/components/molecules/Input/Input.d.ts +1 -1
- package/lib/src/components/molecules/Input/Input.stories.d.ts +9 -9
- package/lib/src/components/molecules/Radio/Radio.stories.d.ts +4 -4
- package/lib/src/components/molecules/TextArea/TextArea.d.ts +4 -2
- package/lib/src/components/molecules/index.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/lib/src/index.d.ts +4 -4
- 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/atoms/Icon/Icon.tsx +2 -0
- package/src/components/atoms/Icon/icons/ArrowCircleRight.tsx +9 -0
- package/src/components/molecules/Button/__snapshots__/Button.test.tsx.snap +3 -3
- package/src/components/molecules/IconButton/IconButton.stories.tsx +18 -0
- package/src/components/molecules/IconButton/IconButton.tsx +36 -0
- package/src/components/molecules/IconButton/index.ts +1 -0
- package/src/components/molecules/Profile/__snapshots__/Profile.test.tsx.snap +26 -0
- package/src/components/molecules/TextArea/TextArea.tsx +9 -5
- package/src/components/molecules/index.ts +2 -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
- package/src/index.ts +5 -4
@@ -0,0 +1,36 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import styled from "styled-components";
|
3
|
+
import { Color } from "../../../styles";
|
4
|
+
import { Icon } from "../../atoms";
|
5
|
+
import { IconType } from "../../atoms/Icon";
|
6
|
+
|
7
|
+
export interface IconButtonProps {
|
8
|
+
size?: "m" | "l";
|
9
|
+
icon: IconType;
|
10
|
+
}
|
11
|
+
|
12
|
+
const sizeVariant = {
|
13
|
+
m: 36,
|
14
|
+
l: 48,
|
15
|
+
};
|
16
|
+
|
17
|
+
export const IconButton: React.FC<IconButtonProps> = ({ size = "m", icon }) => {
|
18
|
+
const iconSize = (5 / 9) * sizeVariant[size];
|
19
|
+
|
20
|
+
return (
|
21
|
+
<Root size={size}>
|
22
|
+
<Icon type={icon} width={iconSize} height={iconSize} fill={Color.Orange}/>
|
23
|
+
</Root>
|
24
|
+
);
|
25
|
+
};
|
26
|
+
|
27
|
+
const Root = styled.button<{ size: "m" | "l" }>`
|
28
|
+
border: none;
|
29
|
+
display: flex;
|
30
|
+
align-items: center;
|
31
|
+
justify-content: center;
|
32
|
+
width: ${(p) => sizeVariant[p.size]}px;
|
33
|
+
height: ${(p) => sizeVariant[p.size]}px;
|
34
|
+
border-radius: calc(${(p) => sizeVariant[p.size]}px / 2);
|
35
|
+
background-color: var(--color-ecru);
|
36
|
+
`;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { IconButton } from "./IconButton";
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`<Profile /> profile should match snapshot 1`] = `
|
4
|
+
<div>
|
5
|
+
<div
|
6
|
+
class="sc-dJjYzT bsksSc"
|
7
|
+
>
|
8
|
+
<img
|
9
|
+
alt="Jane Doe"
|
10
|
+
class="sc-jRQBWg hjrVkd"
|
11
|
+
height="32"
|
12
|
+
src="https://img.freepik.com/darmowe-zdjecie/dosc-usmiechnieta-radosnie-kobieta-o-jasnych-wlosach-ubrana-swobodnie-wygladajaca-z-zadowoleniem_176420-15187.jpg?w=1380&t=st=1660198496~exp=1660199096~hmac=7401572065d2cd7bb67d9f43dbde5c116b90aad419b179fffac1196df24869f2"
|
13
|
+
width="32"
|
14
|
+
/>
|
15
|
+
<div
|
16
|
+
class="sc-dlVxhl ctocLT"
|
17
|
+
>
|
18
|
+
<span
|
19
|
+
class="sc-hGPBjI kWwFIh"
|
20
|
+
>
|
21
|
+
Jane Doe
|
22
|
+
</span>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
`;
|
@@ -1,18 +1,20 @@
|
|
1
|
+
import { FieldProps } from 'formik';
|
1
2
|
import React from 'react';
|
2
3
|
import styled from 'styled-components';
|
3
4
|
import { getValidationTypeProps } from '../../../helpers/validation';
|
4
5
|
import { ValidationType } from '../../../types/validation';
|
6
|
+
import { fieldSizeVariants } from '../../atoms/Field';
|
5
7
|
|
6
|
-
export
|
7
|
-
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
8
|
+
export type TextAreaProps = Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'size'> & FieldProps & {
|
8
9
|
validationType?: ValidationType;
|
10
|
+
size?: "xl" | "l" | "m" | "s";
|
9
11
|
}
|
10
12
|
|
11
|
-
export const TextArea: React.FC<TextAreaProps> = (props) => {
|
12
|
-
return <TextAreaElement rows={4} {...props} />;
|
13
|
+
export const TextArea: React.FC<TextAreaProps> = ({ field, ...props }) => {
|
14
|
+
return <TextAreaElement rows={4} {...field} {...props} />;
|
13
15
|
};
|
14
16
|
|
15
|
-
const TextAreaElement = styled.textarea<Pick<TextAreaProps, 'validationType'>>`
|
17
|
+
const TextAreaElement = styled.textarea<Pick<TextAreaProps, 'validationType' | 'size'>>`
|
16
18
|
background-color: var(--color-white);
|
17
19
|
border: 2px solid var(--shades-of-grey-80);
|
18
20
|
border-radius: var(--padding-s);
|
@@ -21,6 +23,8 @@ const TextAreaElement = styled.textarea<Pick<TextAreaProps, 'validationType'>>`
|
|
21
23
|
overflow: hidden;
|
22
24
|
color: var(--shades-of-grey-100);
|
23
25
|
font-weight: var(--font-bold);
|
26
|
+
font-size: ${(p) => fieldSizeVariants[p.size || 'm'].font};
|
27
|
+
padding: ${(p) => fieldSizeVariants[p.size || 'm'].padding};
|
24
28
|
transition: border var(--transition-speed),
|
25
29
|
background-color var(--transition-speed);
|
26
30
|
width: 100%;
|
@@ -4,7 +4,7 @@ import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
4
4
|
|
5
5
|
import {
|
6
6
|
Column,
|
7
|
-
createColumnHelper,
|
7
|
+
createColumnHelper, Row,
|
8
8
|
} from '@tanstack/react-table';
|
9
9
|
import { Button, Profile } from '../../molecules';
|
10
10
|
|
@@ -49,7 +49,7 @@ export const Primary: ComponentStory<typeof Table> = (args) => {
|
|
49
49
|
progress: number
|
50
50
|
};
|
51
51
|
|
52
|
-
const
|
52
|
+
const data: Person[] = [
|
53
53
|
{
|
54
54
|
firstName: 'tanner',
|
55
55
|
lastName: 'linsley',
|
@@ -76,52 +76,52 @@ export const Primary: ComponentStory<typeof Table> = (args) => {
|
|
76
76
|
},
|
77
77
|
];
|
78
78
|
|
79
|
-
const
|
79
|
+
const columnHelper = createColumnHelper<Person>();
|
80
80
|
|
81
81
|
const personColumns = [
|
82
|
-
|
82
|
+
columnHelper.accessor('firstName', {
|
83
83
|
cell: info => info.getValue(),
|
84
84
|
footer: info => info.column.id,
|
85
85
|
}),
|
86
|
-
|
86
|
+
columnHelper.accessor(row => row.lastName, {
|
87
87
|
id: 'lastName',
|
88
88
|
cell: info => info.getValue(),
|
89
89
|
header: () => 'Last Name',
|
90
90
|
footer: info => info.column.id,
|
91
91
|
}),
|
92
|
-
|
92
|
+
columnHelper.accessor('age', {
|
93
93
|
header: () => 'Age',
|
94
94
|
cell: info => info.renderValue(),
|
95
95
|
footer: info => info.column.id,
|
96
96
|
}),
|
97
|
-
|
97
|
+
columnHelper.accessor('visits', {
|
98
98
|
header: () => 'Visits',
|
99
99
|
footer: info => info.column.id,
|
100
100
|
}),
|
101
|
-
|
101
|
+
columnHelper.accessor('status', {
|
102
102
|
header: 'Status',
|
103
103
|
footer: info => info.column.id,
|
104
104
|
}),
|
105
|
-
|
105
|
+
columnHelper.accessor('progress', {
|
106
106
|
header: 'Profile Progress',
|
107
107
|
footer: info => info.column.id,
|
108
108
|
}),
|
109
109
|
] as Column<Person>[];
|
110
110
|
|
111
111
|
return (
|
112
|
-
<Table columns={personColumns} data={
|
112
|
+
<Table columns={personColumns} data={data} variant={args.variant} textAlign={args.textAlign}/>
|
113
113
|
);
|
114
114
|
};
|
115
115
|
|
116
116
|
export const WithProfile: ComponentStory<typeof Table> = (args) => {
|
117
|
-
type
|
117
|
+
type Profile = {
|
118
118
|
fullName: string;
|
119
119
|
points: number;
|
120
120
|
avatar: string;
|
121
121
|
email: string;
|
122
122
|
};
|
123
123
|
|
124
|
-
const data:
|
124
|
+
const data: Profile[] = [
|
125
125
|
{
|
126
126
|
fullName: 'Tanner Linsley',
|
127
127
|
points: 24,
|
@@ -142,10 +142,10 @@ export const WithProfile: ComponentStory<typeof Table> = (args) => {
|
|
142
142
|
},
|
143
143
|
];
|
144
144
|
|
145
|
-
const
|
145
|
+
const columnHelper = createColumnHelper<Profile>();
|
146
146
|
|
147
147
|
const columns = [
|
148
|
-
|
148
|
+
columnHelper.accessor('fullName', {
|
149
149
|
cell: info => {
|
150
150
|
return (
|
151
151
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
@@ -162,19 +162,109 @@ export const WithProfile: ComponentStory<typeof Table> = (args) => {
|
|
162
162
|
header: () => 'Team member',
|
163
163
|
footer: info => info.column.id,
|
164
164
|
}),
|
165
|
-
|
165
|
+
columnHelper.accessor('points', {
|
166
166
|
header: () => 'Points',
|
167
167
|
cell: info => info.renderValue(),
|
168
168
|
footer: info => info.column.id,
|
169
169
|
}),
|
170
|
-
|
170
|
+
columnHelper.display({
|
171
171
|
header: 'Actions',
|
172
172
|
id: 'Actions',
|
173
173
|
cell: () => <div style={{ width: '30px' }}><Button direction={'ltr'} icon={'edit'} ghost>Edit</Button></div>,
|
174
174
|
}),
|
175
|
-
] as Column<
|
175
|
+
] as Column<Profile>[];
|
176
176
|
|
177
177
|
return (
|
178
|
-
<Table columns={columns} data={data} variant={args.variant} width={'100%'} textAlign={
|
178
|
+
<Table columns={columns} data={data} variant={args.variant} width={'100%'} textAlign={'left'}/>
|
179
179
|
);
|
180
|
+
};
|
181
|
+
|
182
|
+
export const ExpandableRows: ComponentStory<typeof Table> = (args) => {
|
183
|
+
type Person = {
|
184
|
+
firstName: string
|
185
|
+
lastName: string
|
186
|
+
age: number
|
187
|
+
visits: number
|
188
|
+
status: string
|
189
|
+
progress: number
|
190
|
+
};
|
191
|
+
|
192
|
+
const data: Person[] = [
|
193
|
+
{
|
194
|
+
firstName: 'tanner',
|
195
|
+
lastName: 'linsley',
|
196
|
+
age: 24,
|
197
|
+
visits: 100,
|
198
|
+
status: 'In Relationship',
|
199
|
+
progress: 50,
|
200
|
+
},
|
201
|
+
{
|
202
|
+
firstName: 'tandy',
|
203
|
+
lastName: 'miller',
|
204
|
+
age: 40,
|
205
|
+
visits: 40,
|
206
|
+
status: 'Single',
|
207
|
+
progress: 80,
|
208
|
+
},
|
209
|
+
{
|
210
|
+
firstName: 'joe',
|
211
|
+
lastName: 'dirte',
|
212
|
+
age: 45,
|
213
|
+
visits: 20,
|
214
|
+
status: 'Complicated',
|
215
|
+
progress: 10,
|
216
|
+
},
|
217
|
+
];
|
218
|
+
|
219
|
+
const columnHelper = createColumnHelper<Person>();
|
220
|
+
|
221
|
+
const personColumns = [
|
222
|
+
columnHelper.accessor('firstName', {
|
223
|
+
header: 'First Name',
|
224
|
+
cell: info => info.getValue(),
|
225
|
+
footer: info => info.column.id,
|
226
|
+
}),
|
227
|
+
columnHelper.accessor(row => row.lastName, {
|
228
|
+
id: 'lastName',
|
229
|
+
cell: info => info.getValue(),
|
230
|
+
header: () => 'Last Name',
|
231
|
+
footer: info => info.column.id,
|
232
|
+
}),
|
233
|
+
columnHelper.accessor('age', {
|
234
|
+
header: () => 'Age',
|
235
|
+
cell: info => info.renderValue(),
|
236
|
+
footer: info => info.column.id,
|
237
|
+
}),
|
238
|
+
columnHelper.accessor('visits', {
|
239
|
+
header: () => 'Visits',
|
240
|
+
footer: info => info.column.id,
|
241
|
+
}),
|
242
|
+
columnHelper.accessor('status', {
|
243
|
+
header: 'Status',
|
244
|
+
footer: info => info.column.id,
|
245
|
+
}),
|
246
|
+
columnHelper.accessor('progress', {
|
247
|
+
header: 'Profile Progress',
|
248
|
+
footer: info => info.column.id,
|
249
|
+
}),
|
250
|
+
] as Column<Person>[];
|
251
|
+
|
252
|
+
return (
|
253
|
+
<Table
|
254
|
+
columns={personColumns}
|
255
|
+
data={data}
|
256
|
+
variant={args.variant}
|
257
|
+
textAlign={args.textAlign}
|
258
|
+
renderExpandCollapseComponent={(row: Row<Person>) => (
|
259
|
+
<div
|
260
|
+
style={{ cursor: 'pointer' }}
|
261
|
+
onClick={() => row.toggleExpanded()}>
|
262
|
+
Edit
|
263
|
+
</div>
|
264
|
+
)}
|
265
|
+
renderExpandableRowComponent={(row: Row<Person>) => (
|
266
|
+
<div>Hello {row.original.firstName} {row.original.lastName}</div>
|
267
|
+
)}
|
268
|
+
/>
|
269
|
+
);
|
180
270
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { render } from '@testing-library/react';
|
2
|
+
import { fireEvent, render } from '@testing-library/react';
|
3
|
+
import { Column, createColumnHelper, Row } from '@tanstack/react-table';
|
3
4
|
import { Table } from './Table';
|
4
|
-
import { Column, createColumnHelper } from '@tanstack/react-table';
|
5
5
|
|
6
6
|
type Person = {
|
7
7
|
firstName: string
|
@@ -43,6 +43,7 @@ const columnHelper = createColumnHelper<Person>();
|
|
43
43
|
|
44
44
|
const columns = [
|
45
45
|
columnHelper.accessor('firstName', {
|
46
|
+
header: 'First Name',
|
46
47
|
cell: info => info.getValue(),
|
47
48
|
footer: info => info.column.id,
|
48
49
|
}),
|
@@ -73,10 +74,77 @@ const columns = [
|
|
73
74
|
|
74
75
|
describe('<Table />', () => {
|
75
76
|
it('should render', () => {
|
76
|
-
render(<Table columns={columns} data={data}/>);
|
77
|
+
const { container, getByText } = render(<Table columns={columns} data={data}/>);
|
78
|
+
expect(container.getElementsByTagName('table').length).toEqual(1);
|
79
|
+
expect(container.getElementsByTagName('th').length).toEqual(6);
|
80
|
+
expect(getByText(/First Name/)).toBeInTheDocument();
|
81
|
+
expect(getByText(/Last Name/)).toBeInTheDocument();
|
82
|
+
expect(getByText(/Age/)).toBeInTheDocument();
|
83
|
+
expect(getByText(/Visits/)).toBeInTheDocument();
|
84
|
+
expect(getByText(/Profile Progress/)).toBeInTheDocument();
|
77
85
|
});
|
78
86
|
it('enabled - should match snapshot', () => {
|
79
87
|
const { container } = render(<Table columns={columns} data={data}/>);
|
80
88
|
expect(container).toMatchSnapshot();
|
81
89
|
});
|
90
|
+
it('expandable rows - should match snapshot',() => {
|
91
|
+
const { container } = render(
|
92
|
+
<Table
|
93
|
+
columns={columns}
|
94
|
+
data={data}
|
95
|
+
renderExpandCollapseComponent={(row: Row<Person>) => (
|
96
|
+
<div
|
97
|
+
style={{ cursor: 'pointer' }}
|
98
|
+
onClick={() => {
|
99
|
+
console.log('click');
|
100
|
+
row.toggleExpanded();
|
101
|
+
}}
|
102
|
+
data-testid={`expand-button-${row.index}`}
|
103
|
+
>
|
104
|
+
Edit
|
105
|
+
</div>
|
106
|
+
)}
|
107
|
+
renderExpandableRowComponent={(row: Row<Person>) => (
|
108
|
+
<div data-testid={`expand-content-${row.index}`}>Hello {row.original.firstName} {row.original.lastName}</div>
|
109
|
+
)}
|
110
|
+
/>,
|
111
|
+
);
|
112
|
+
expect(container).toMatchSnapshot();
|
113
|
+
});
|
114
|
+
it('should render expandable rows', () => {
|
115
|
+
const { container, getByTestId, queryByTestId } = render(
|
116
|
+
<Table
|
117
|
+
columns={columns}
|
118
|
+
data={data}
|
119
|
+
renderExpandCollapseComponent={(row: Row<Person>) => (
|
120
|
+
<div
|
121
|
+
style={{ cursor: 'pointer' }}
|
122
|
+
onClick={() => row.toggleExpanded()}
|
123
|
+
data-testid={`expand-button-${row.index}`}
|
124
|
+
>
|
125
|
+
Edit
|
126
|
+
</div>
|
127
|
+
)}
|
128
|
+
renderExpandableRowComponent={(row: Row<Person>) => (
|
129
|
+
<div data-testid={`expand-content-${row.index}`}>Hello {row.original.firstName} {row.original.lastName}</div>
|
130
|
+
)}
|
131
|
+
/>,
|
132
|
+
);
|
133
|
+
expect(container.getElementsByTagName('table').length).toEqual(1);
|
134
|
+
expect(container.getElementsByTagName('th').length).toEqual(7);
|
135
|
+
expect(getByTestId(/expand-button-1/)).toBeInTheDocument();
|
136
|
+
expect(queryByTestId(/expand-content-1/)).not.toBeInTheDocument();
|
137
|
+
|
138
|
+
const expandCollapseButton = getByTestId(/expand-button-1/);
|
139
|
+
|
140
|
+
fireEvent.click(expandCollapseButton);
|
141
|
+
|
142
|
+
expect(getByTestId(/expand-content-1/)).toBeInTheDocument();
|
143
|
+
|
144
|
+
// I don't know why, but it does not work when used with the expandCollapseButton above
|
145
|
+
const sameExpandCollapseButton = getByTestId(/expand-button-1/);
|
146
|
+
fireEvent.click(sameExpandCollapseButton);
|
147
|
+
|
148
|
+
expect(queryByTestId(/expand-content-1/)).not.toBeInTheDocument();
|
149
|
+
});
|
82
150
|
});
|
@@ -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
|
+
`;
|
package/src/index.ts
CHANGED
@@ -12,7 +12,7 @@ export {
|
|
12
12
|
Chip,
|
13
13
|
Dot,
|
14
14
|
Gradient,
|
15
|
-
} from
|
15
|
+
} from "./components/atoms";
|
16
16
|
|
17
17
|
export {
|
18
18
|
InfoCard,
|
@@ -25,8 +25,9 @@ export {
|
|
25
25
|
Radio,
|
26
26
|
Tile,
|
27
27
|
Switch,
|
28
|
-
|
28
|
+
IconButton,
|
29
|
+
} from "./components/molecules";
|
29
30
|
|
30
|
-
export { Menu, Setting, Modal, Select, Table } from
|
31
|
+
export { Menu, Setting, Modal, Select, Table } from "./components/organisms";
|
31
32
|
|
32
|
-
export { GlobalStyles as IntegrigoUI, Color } from
|
33
|
+
export { GlobalStyles as IntegrigoUI, Color } from "./styles";
|