@transferwise/components 0.0.0-experimental-029bd71 → 0.0.0-experimental-339e531
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/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs.map +1 -1
- package/build/button/legacyUtils/legacyUtils.js.map +1 -1
- package/build/button/legacyUtils/legacyUtils.mjs.map +1 -1
- package/build/i18n/en.json +0 -5
- package/build/i18n/en.json.js +0 -5
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -5
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/main.css +0 -300
- package/build/styles/main.css +0 -300
- package/build/types/button/Button.d.ts +1 -1
- package/build/types/button/Button.d.ts.map +1 -1
- package/build/types/button/legacyUtils/legacyUtils.d.ts +2 -2
- package/build/types/button/legacyUtils/legacyUtils.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +158 -0
- package/build/types/test-utils/index.d.ts.map +1 -0
- package/build/types/test-utils/jest.setup.d.ts +2 -0
- package/build/types/test-utils/jest.setup.d.ts.map +1 -0
- package/package.json +4 -3
- package/src/button/{Button.spec.js → Button.spec.tsx} +3 -2
- package/src/button/Button.tsx +1 -1
- package/src/button/legacyUtils/{legacyUtils.spec.js → legacyUtils.spec.tsx} +1 -1
- package/src/button/legacyUtils/legacyUtils.ts +2 -2
- package/src/i18n/en.json +0 -5
- package/src/main.css +0 -300
- package/src/main.less +0 -1
- package/src/modal/{Modal.rtl.spec.js → Modal.rtl.spec.tsx} +8 -7
- package/src/slidingPanel/SlidingPanel.spec.js +1 -1
- package/src/ssr.spec.tsx +264 -0
- package/src/test-utils/{index.js → index.tsx} +11 -6
- package/src/test-utils/{jest.setup.js → jest.setup.ts} +13 -8
- package/build/styles/table/Table.css +0 -300
- package/build/types/table/Table.d.ts +0 -23
- package/build/types/table/Table.d.ts.map +0 -1
- package/build/types/table/Table.messages.d.ts +0 -24
- package/build/types/table/Table.messages.d.ts.map +0 -1
- package/build/types/table/TableCell.d.ts +0 -44
- package/build/types/table/TableCell.d.ts.map +0 -1
- package/build/types/table/TableHeader.d.ts +0 -13
- package/build/types/table/TableHeader.d.ts.map +0 -1
- package/build/types/table/TableRow.d.ts +0 -17
- package/build/types/table/TableRow.d.ts.map +0 -1
- package/build/types/table/TableStatusText.d.ts +0 -9
- package/build/types/table/TableStatusText.d.ts.map +0 -1
- package/build/types/table/index.d.ts +0 -6
- package/build/types/table/index.d.ts.map +0 -1
- package/src/ssr.spec.js +0 -256
- package/src/table/Table.css +0 -300
- package/src/table/Table.less +0 -361
- package/src/table/Table.messages.ts +0 -24
- package/src/table/Table.spec.tsx +0 -88
- package/src/table/Table.story.tsx +0 -359
- package/src/table/Table.tsx +0 -166
- package/src/table/TableCell.spec.tsx +0 -304
- package/src/table/TableCell.tsx +0 -170
- package/src/table/TableHeader.spec.tsx +0 -55
- package/src/table/TableHeader.tsx +0 -75
- package/src/table/TableRow.spec.tsx +0 -117
- package/src/table/TableRow.tsx +0 -70
- package/src/table/TableStatusText.spec.tsx +0 -53
- package/src/table/TableStatusText.tsx +0 -36
- package/src/table/index.ts +0 -11
- /package/src/button/__snapshots__/{Button.spec.js.snap → Button.spec.tsx.snap} +0 -0
- /package/src/dimmer/{Dimmer.rtl.spec.js → Dimmer.rtl.spec.tsx} +0 -0
- /package/src/info/{Info.spec.js → Info.spec.jsx} +0 -0
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { render, screen, within } from '@testing-library/react';
|
|
2
|
-
import TableRow, { TableRowType, TableRowClickableType } from './TableRow';
|
|
3
|
-
import { IntlProvider } from 'react-intl';
|
|
4
|
-
import { userEvent } from '@testing-library/user-event';
|
|
5
|
-
|
|
6
|
-
describe('TableRow Component', () => {
|
|
7
|
-
const mockData = {
|
|
8
|
-
cells: [
|
|
9
|
-
{
|
|
10
|
-
cell: {
|
|
11
|
-
type: 'text',
|
|
12
|
-
text: 'Cell content 1',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
cell: {
|
|
17
|
-
type: 'text',
|
|
18
|
-
text: 'Cell content 2',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
} satisfies TableRowType;
|
|
23
|
-
|
|
24
|
-
const mockDataClickable = {
|
|
25
|
-
id: 1,
|
|
26
|
-
cells: mockData.cells,
|
|
27
|
-
} satisfies TableRowClickableType;
|
|
28
|
-
|
|
29
|
-
const handleClick = jest.fn();
|
|
30
|
-
|
|
31
|
-
const renderWithIntl = (component: React.ReactElement) => {
|
|
32
|
-
return render(<IntlProvider locale="en">{component}</IntlProvider>);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
it('renders row', () => {
|
|
36
|
-
renderWithIntl(<TableRow />);
|
|
37
|
-
expect(screen.getByTestId('np-table-row')).toBeInTheDocument();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('renders `children` when data is not provided', () => {
|
|
41
|
-
renderWithIntl(
|
|
42
|
-
<TableRow>
|
|
43
|
-
<td>Cell text</td>
|
|
44
|
-
</TableRow>,
|
|
45
|
-
);
|
|
46
|
-
expect(screen.getByText('Cell text')).toBeInTheDocument();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('renders cells when data is provided', () => {
|
|
50
|
-
renderWithIntl(<TableRow rowData={mockData} />);
|
|
51
|
-
expect(screen.getByText('Cell content 1')).toBeInTheDocument();
|
|
52
|
-
expect(screen.getByText('Cell content 2')).toBeInTheDocument();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('renders correct number of cells', () => {
|
|
56
|
-
renderWithIntl(<TableRow rowData={mockData} />);
|
|
57
|
-
expect(screen.getAllByRole('cell')).toHaveLength(mockData.cells.length);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('renders correct number of cells with chevron when clickable', () => {
|
|
61
|
-
renderWithIntl(<TableRow rowData={mockDataClickable} onRowClick={handleClick} />);
|
|
62
|
-
expect(screen.getAllByRole('cell')).toHaveLength(mockDataClickable.cells.length + 1);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('renders a separator row when `hasSeparator` is passed', () => {
|
|
66
|
-
renderWithIntl(<TableRow rowData={mockData} hasSeparator />);
|
|
67
|
-
expect(screen.getAllByTestId('np-table-row')).toHaveLength(1);
|
|
68
|
-
expect(screen.getAllByTestId('np-table-row--separator')).toHaveLength(1);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('renders correct `colSpan` for separator row', () => {
|
|
72
|
-
renderWithIntl(<TableRow rowData={mockData} hasSeparator />);
|
|
73
|
-
const separatorCell = screen.getByTestId('np-table-cell--cosmetic');
|
|
74
|
-
expect(separatorCell).toHaveAttribute('colSpan', mockData.cells.length.toString());
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('renders correct `colSpan` for separator row with clickable row', () => {
|
|
78
|
-
renderWithIntl(<TableRow rowData={mockDataClickable} hasSeparator onRowClick={handleClick} />);
|
|
79
|
-
const separatorCell = screen.getByTestId('np-table-cell--cosmetic');
|
|
80
|
-
expect(separatorCell).toHaveAttribute(
|
|
81
|
-
'colSpan',
|
|
82
|
-
(mockDataClickable.cells.length + 1).toString(),
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('does not render separator row when `hasSeparator` is not provided', () => {
|
|
87
|
-
renderWithIntl(<TableRow rowData={mockData} />);
|
|
88
|
-
expect(screen.queryByTestId('np-table-row--separator')).not.toBeInTheDocument();
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it('does not call `onRowClick` when row is not clickable', async () => {
|
|
92
|
-
renderWithIntl(<TableRow rowData={mockData} />);
|
|
93
|
-
await userEvent.click(screen.getByTestId('np-table-row'));
|
|
94
|
-
expect(handleClick).not.toHaveBeenCalled();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('applies the clickable class when row is clickable', () => {
|
|
98
|
-
renderWithIntl(<TableRow rowData={mockDataClickable} onRowClick={handleClick} />);
|
|
99
|
-
expect(screen.getAllByTestId('np-table-row')[0]).toHaveClass('np-table-row--clickable');
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('calls `onRowClick` when row is clicked for clickable row', async () => {
|
|
103
|
-
renderWithIntl(<TableRow rowData={mockDataClickable} onRowClick={handleClick} />);
|
|
104
|
-
await userEvent.click(screen.getByTestId('np-table-row'));
|
|
105
|
-
expect(handleClick).toHaveBeenCalledWith(mockDataClickable);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('renders a chevron icon when row is clickable', () => {
|
|
109
|
-
renderWithIntl(<TableRow rowData={mockDataClickable} onRowClick={handleClick} />);
|
|
110
|
-
expect(screen.getByTestId('chevron-up-icon')).toBeInTheDocument();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it('does not render a chevron icon when row is not clickable', () => {
|
|
114
|
-
renderWithIntl(<TableRow rowData={mockData} />);
|
|
115
|
-
expect(screen.queryByTestId('chevron-up-icon')).not.toBeInTheDocument();
|
|
116
|
-
});
|
|
117
|
-
});
|
package/src/table/TableRow.tsx
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import TableCell, { TableCellProps } from './TableCell';
|
|
3
|
-
import Chevron from '../chevron';
|
|
4
|
-
import { Position } from '../common';
|
|
5
|
-
import { clsx } from 'clsx';
|
|
6
|
-
|
|
7
|
-
export interface TableRowType {
|
|
8
|
-
cells?: TableCellProps[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface TableRowClickableType extends TableRowType {
|
|
12
|
-
id: number | string; // `id` is mandatory for clickable rows
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface TableRowProps {
|
|
16
|
-
rowData?: TableRowType | TableRowClickableType;
|
|
17
|
-
hasSeparator?: boolean;
|
|
18
|
-
children?: React.ReactNode;
|
|
19
|
-
onRowClick?: (rowData: TableRowType | TableRowClickableType) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const TableRow = ({ rowData, hasSeparator = false, children, onRowClick }: TableRowProps) => {
|
|
23
|
-
return (
|
|
24
|
-
<>
|
|
25
|
-
<tr
|
|
26
|
-
className={clsx('np-table-row', { 'np-table-row--clickable': !!onRowClick })}
|
|
27
|
-
data-testid="np-table-row"
|
|
28
|
-
role={onRowClick ? 'button' : undefined}
|
|
29
|
-
tabIndex={0}
|
|
30
|
-
onClick={onRowClick && rowData ? () => onRowClick(rowData) : undefined}
|
|
31
|
-
onKeyDown={({ key }) => {
|
|
32
|
-
if (onRowClick && rowData && key === 'Enter') {
|
|
33
|
-
onRowClick(rowData);
|
|
34
|
-
}
|
|
35
|
-
}}
|
|
36
|
-
>
|
|
37
|
-
{rowData?.cells
|
|
38
|
-
? rowData?.cells?.map((item, index) => {
|
|
39
|
-
const itemIndex = item.cell?.text ? item.cell?.text.concat(index.toString()) : index;
|
|
40
|
-
return <TableCell key={itemIndex} {...item} />;
|
|
41
|
-
})
|
|
42
|
-
: children}
|
|
43
|
-
{onRowClick && (
|
|
44
|
-
<TableCell className="np-table-cell--action">
|
|
45
|
-
<div aria-hidden="true">
|
|
46
|
-
<Chevron orientation={Position.RIGHT} />
|
|
47
|
-
</div>
|
|
48
|
-
</TableCell>
|
|
49
|
-
)}
|
|
50
|
-
</tr>
|
|
51
|
-
{hasSeparator && (
|
|
52
|
-
<tr
|
|
53
|
-
aria-hidden="true"
|
|
54
|
-
className="np-table-row np-table-row--separator"
|
|
55
|
-
data-testid="np-table-row--separator"
|
|
56
|
-
>
|
|
57
|
-
<td
|
|
58
|
-
className="np-table-cell np-table-cell--cosmetic"
|
|
59
|
-
colSpan={onRowClick ? Number(rowData?.cells?.length) + 1 : rowData?.cells?.length}
|
|
60
|
-
data-testid="np-table-cell--cosmetic"
|
|
61
|
-
>
|
|
62
|
-
<div className="np-table-cell-separator" data-testid="np-table-cell-separator" />
|
|
63
|
-
</td>
|
|
64
|
-
</tr>
|
|
65
|
-
)}
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default TableRow;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '@testing-library/react';
|
|
2
|
-
import TableStatusText, { TableStatusTextProps } from './TableStatusText';
|
|
3
|
-
|
|
4
|
-
describe('TableStatusText Component', () => {
|
|
5
|
-
const renderComponent = (props: Partial<TableStatusTextProps> = {}) => {
|
|
6
|
-
const defaultProps: TableStatusTextProps = {
|
|
7
|
-
text: 'Status Text',
|
|
8
|
-
...props,
|
|
9
|
-
};
|
|
10
|
-
return render(<TableStatusText {...defaultProps} />);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
it('renders the text and applies the default class', () => {
|
|
14
|
-
renderComponent();
|
|
15
|
-
expect(screen.getByText('Status Text')).toBeInTheDocument();
|
|
16
|
-
expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('applies the custom class name', () => {
|
|
20
|
-
renderComponent({ className: 'custom-class' });
|
|
21
|
-
expect(screen.getByText('Status Text')).toHaveClass('custom-class');
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('applies the default typography class when typography is not provided', () => {
|
|
25
|
-
renderComponent();
|
|
26
|
-
expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('applies the typography class when typography equals `default-bold`', () => {
|
|
30
|
-
renderComponent({ typography: 'default-bold' });
|
|
31
|
-
expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default-bold');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('does not render any icon when status is not provided', () => {
|
|
35
|
-
renderComponent();
|
|
36
|
-
expect(screen.queryByTestId('check-icon')).not.toBeInTheDocument();
|
|
37
|
-
expect(screen.queryByTestId('alert-icon')).not.toBeInTheDocument();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('applies the typography and status classes, renders the error icon when status equals `error`', () => {
|
|
41
|
-
renderComponent({ status: 'error' });
|
|
42
|
-
expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default-bold');
|
|
43
|
-
expect(screen.getByText('Status Text')).toHaveClass('np-table-content--error');
|
|
44
|
-
expect(screen.getByTestId('alert-icon')).toBeInTheDocument();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('applies the typography and status classes, renders the success icon when status equals `success`', () => {
|
|
48
|
-
renderComponent({ status: 'success' });
|
|
49
|
-
expect(screen.getByText('Status Text')).toHaveClass('np-text-body-default-bold');
|
|
50
|
-
expect(screen.getByText('Status Text')).toHaveClass('np-table-content--success');
|
|
51
|
-
expect(screen.getByTestId('check-icon')).toBeInTheDocument();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AlertCircle, CheckCircle } from '@transferwise/icons';
|
|
2
|
-
import { clsx } from 'clsx';
|
|
3
|
-
|
|
4
|
-
export interface TableStatusTextProps {
|
|
5
|
-
text: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
status?: 'success' | 'error';
|
|
8
|
-
typography?: 'default' | 'default-bold';
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const TableStatusText = ({
|
|
12
|
-
text,
|
|
13
|
-
className,
|
|
14
|
-
status,
|
|
15
|
-
typography = 'default',
|
|
16
|
-
}: TableStatusTextProps) => {
|
|
17
|
-
let typographyClass = 'np-text-body-default';
|
|
18
|
-
if (status ?? typography === 'default-bold') {
|
|
19
|
-
typographyClass += '-bold';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div
|
|
24
|
-
className={clsx(className, typographyClass, {
|
|
25
|
-
'np-table-content--success': status === 'success',
|
|
26
|
-
'np-table-content--error': status === 'error',
|
|
27
|
-
})}
|
|
28
|
-
>
|
|
29
|
-
{text}
|
|
30
|
-
{status === 'success' && <CheckCircle className="tw-icon--status" data-testid="check-icon" />}
|
|
31
|
-
{status === 'error' && <AlertCircle className="tw-icon--status" data-testid="alert-icon" />}
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default TableStatusText;
|
package/src/table/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { default } from './Table';
|
|
2
|
-
export type { TableProps } from './Table';
|
|
3
|
-
export type { TableRowType, TableRowClickableType } from './TableRow';
|
|
4
|
-
export type { TableHeaderType } from './TableHeader';
|
|
5
|
-
export type {
|
|
6
|
-
TableCellLeading,
|
|
7
|
-
TableCellText,
|
|
8
|
-
TableCellCurrency,
|
|
9
|
-
TableCellStatus,
|
|
10
|
-
TableCellType,
|
|
11
|
-
} from './TableCell';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|