@transferwise/components 46.82.1 → 46.83.1
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/avatarLayout/AvatarLayout.js +115 -0
- package/build/avatarLayout/AvatarLayout.js.map +1 -0
- package/build/avatarLayout/AvatarLayout.mjs +113 -0
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -0
- package/build/button/Button.js +1 -1
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +1 -1
- package/build/button/Button.mjs.map +1 -1
- package/build/i18n/commonMessages/Button.messages.js.map +1 -0
- package/build/i18n/commonMessages/Button.messages.mjs.map +1 -0
- package/build/i18n/es.json +5 -0
- package/build/i18n/es.json.js +5 -0
- package/build/i18n/es.json.js.map +1 -1
- package/build/i18n/es.json.mjs +5 -0
- package/build/i18n/es.json.mjs.map +1 -1
- package/build/i18n/pl.json +5 -0
- package/build/i18n/pl.json.js +5 -0
- package/build/i18n/pl.json.js.map +1 -1
- package/build/i18n/pl.json.mjs +5 -0
- package/build/i18n/pl.json.mjs.map +1 -1
- package/build/i18n/ro.json +5 -0
- package/build/i18n/ro.json.js +5 -0
- package/build/i18n/ro.json.js.map +1 -1
- package/build/i18n/ro.json.mjs +5 -0
- package/build/i18n/ro.json.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/main.css +30 -0
- package/build/styles/avatarLayout/AvatarLayout.css +30 -0
- package/build/styles/main.css +30 -0
- package/build/types/avatarLayout/AvatarLayout.d.ts +11 -0
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -0
- package/build/types/avatarLayout/index.d.ts +3 -0
- package/build/types/avatarLayout/index.d.ts.map +1 -0
- package/build/types/i18n/commonMessages/Button.messages.d.ts.map +1 -0
- package/build/types/index.d.ts +2 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/primitives/PrimitiveAnchor/index.d.ts +3 -0
- package/build/types/primitives/PrimitiveAnchor/index.d.ts.map +1 -0
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts +14 -0
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -0
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +21 -0
- package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -0
- package/build/types/primitives/PrimitiveAnchor/src/index.d.ts +3 -0
- package/build/types/primitives/PrimitiveAnchor/src/index.d.ts.map +1 -0
- package/build/types/primitives/PrimitiveButton/index.d.ts +3 -0
- package/build/types/primitives/PrimitiveButton/index.d.ts.map +1 -0
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts +14 -0
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -0
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.types.d.ts +21 -0
- package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.types.d.ts.map +1 -0
- package/build/types/primitives/PrimitiveButton/src/index.d.ts +3 -0
- package/build/types/primitives/PrimitiveButton/src/index.d.ts.map +1 -0
- package/build/types/primitives/index.d.ts +6 -0
- package/build/types/primitives/index.d.ts.map +1 -0
- package/build/types/primitives/types.d.ts +34 -0
- package/build/types/primitives/types.d.ts.map +1 -0
- package/build/types/table/Table.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/avatarLayout/AvatarLayout.css +30 -0
- package/src/avatarLayout/AvatarLayout.less +39 -0
- package/src/avatarLayout/AvatarLayout.story.tsx +285 -0
- package/src/avatarLayout/AvatarLayout.tsx +93 -0
- package/src/avatarLayout/index.ts +2 -0
- package/src/button/Button.spec.tsx +1 -1
- package/src/button/Button.tsx +1 -1
- package/src/i18n/es.json +5 -0
- package/src/i18n/pl.json +5 -0
- package/src/i18n/ro.json +5 -0
- package/src/index.ts +2 -0
- package/src/main.css +30 -0
- package/src/main.less +1 -0
- package/src/primitives/PrimitiveAnchor/index.ts +2 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +122 -0
- package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +28 -0
- package/src/primitives/PrimitiveAnchor/src/index.ts +6 -0
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +77 -0
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.tests.story.tsx +169 -0
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +95 -0
- package/src/primitives/PrimitiveButton/index.ts +2 -0
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +131 -0
- package/src/primitives/PrimitiveButton/src/PrimitiveButton.types.ts +28 -0
- package/src/primitives/PrimitiveButton/src/index.ts +6 -0
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +73 -0
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.tests.story.tsx +230 -0
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +114 -0
- package/src/primitives/index.ts +14 -0
- package/src/primitives/types.ts +40 -0
- package/src/table/Table.tsx +3 -2
- package/src/test-utils/index.tsx +1 -0
- package/build/button/Button.messages.js.map +0 -1
- package/build/button/Button.messages.mjs.map +0 -1
- package/build/types/button/Button.messages.d.ts.map +0 -1
- /package/build/{button → i18n/commonMessages}/Button.messages.js +0 -0
- /package/build/{button → i18n/commonMessages}/Button.messages.mjs +0 -0
- /package/build/types/{button → i18n/commonMessages}/Button.messages.d.ts +0 -0
- /package/src/{button → i18n/commonMessages}/Button.messages.ts +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { userEvent, within, expect } from '@storybook/test';
|
|
3
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import PrimitiveButton from '..';
|
|
5
|
+
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Primitives/Button/Tests',
|
|
8
|
+
component: PrimitiveButton,
|
|
9
|
+
args: {
|
|
10
|
+
children: 'Button text',
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
} satisfies Meta<typeof PrimitiveButton>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
const wait = async (duration = 500) =>
|
|
20
|
+
new Promise<void>((resolve) => {
|
|
21
|
+
setTimeout(resolve, duration);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const ClickInteraction: Story = {
|
|
25
|
+
play: async ({ canvasElement }) => {
|
|
26
|
+
const canvas = within(canvasElement);
|
|
27
|
+
const button = canvas.getByRole('button');
|
|
28
|
+
await userEvent.click(button);
|
|
29
|
+
await expect(button).toHaveTextContent('Clicked!');
|
|
30
|
+
},
|
|
31
|
+
render: function Render(args) {
|
|
32
|
+
const [clicked, setClicked] = useState(false);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<PrimitiveButton {...args} onClick={() => setClicked(true)}>
|
|
36
|
+
{clicked ? 'Clicked!' : 'Button text'}
|
|
37
|
+
</PrimitiveButton>
|
|
38
|
+
);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const FocusInteraction: Story = {
|
|
43
|
+
play: async ({ canvasElement }) => {
|
|
44
|
+
const canvas = within(canvasElement);
|
|
45
|
+
const button = canvas.getByRole('button');
|
|
46
|
+
await userEvent.tab();
|
|
47
|
+
await expect(button).toHaveFocus();
|
|
48
|
+
await expect(button).toHaveTextContent('Focused!');
|
|
49
|
+
},
|
|
50
|
+
render: function Render(args) {
|
|
51
|
+
const [focused, setFocused] = useState(false);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<PrimitiveButton {...args} onFocus={() => setFocused(true)}>
|
|
55
|
+
{focused ? 'Focused!' : 'Button text'}
|
|
56
|
+
</PrimitiveButton>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const BlurInteraction: Story = {
|
|
62
|
+
play: async ({ canvasElement }) => {
|
|
63
|
+
const canvas = within(canvasElement);
|
|
64
|
+
const button = canvas.getByRole('button');
|
|
65
|
+
await userEvent.tab();
|
|
66
|
+
await expect(button).toHaveFocus();
|
|
67
|
+
await userEvent.tab();
|
|
68
|
+
await expect(button).not.toHaveFocus();
|
|
69
|
+
await expect(button).toHaveTextContent('Blurred!');
|
|
70
|
+
},
|
|
71
|
+
render: function Render(args) {
|
|
72
|
+
const [blurred, setBlurred] = useState(false);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<PrimitiveButton {...args} onBlur={() => setBlurred(true)}>
|
|
76
|
+
{blurred ? 'Blurred!' : 'Button text'}
|
|
77
|
+
</PrimitiveButton>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const MouseEnterInteraction: Story = {
|
|
83
|
+
play: async ({ canvasElement }) => {
|
|
84
|
+
const canvas = within(canvasElement);
|
|
85
|
+
const button = canvas.getByRole('button');
|
|
86
|
+
await userEvent.hover(button);
|
|
87
|
+
await expect(button).toHaveTextContent('Hovered!');
|
|
88
|
+
},
|
|
89
|
+
render: function Render(args) {
|
|
90
|
+
const [hovered, setHovered] = useState(false);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<PrimitiveButton {...args} onMouseEnter={() => setHovered(true)}>
|
|
94
|
+
{hovered ? 'Hovered!' : 'Button text'}
|
|
95
|
+
</PrimitiveButton>
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const MouseLeaveInteraction: Story = {
|
|
101
|
+
play: async ({ canvasElement }) => {
|
|
102
|
+
const canvas = within(canvasElement);
|
|
103
|
+
const button = canvas.getByRole('button');
|
|
104
|
+
await userEvent.unhover(button);
|
|
105
|
+
await expect(button).toHaveTextContent('Left!');
|
|
106
|
+
},
|
|
107
|
+
render: function Render(args) {
|
|
108
|
+
const [left, setLeft] = useState(false);
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<PrimitiveButton {...args} onMouseLeave={() => setLeft(true)}>
|
|
112
|
+
{left ? 'Left!' : 'Button text'}
|
|
113
|
+
</PrimitiveButton>
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const KeyDownInteraction: Story = {
|
|
119
|
+
play: async ({ canvasElement }) => {
|
|
120
|
+
const canvas = within(canvasElement);
|
|
121
|
+
const button = canvas.getByRole('button');
|
|
122
|
+
await userEvent.type(button, '{enter}');
|
|
123
|
+
await expect(button).toHaveTextContent('Key Pressed!');
|
|
124
|
+
},
|
|
125
|
+
render: function Render(args) {
|
|
126
|
+
const [keyPressed, setKeyPressed] = useState(false);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<PrimitiveButton {...args} onKeyDown={() => setKeyPressed(true)}>
|
|
130
|
+
{keyPressed ? 'Key Pressed!' : 'Button text'}
|
|
131
|
+
</PrimitiveButton>
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const DisabledClickInteraction: Story = {
|
|
137
|
+
play: async ({ canvasElement }) => {
|
|
138
|
+
const canvas = within(canvasElement);
|
|
139
|
+
const button = canvas.getByRole('button');
|
|
140
|
+
await userEvent.click(button);
|
|
141
|
+
await expect(button).toHaveTextContent('Button text');
|
|
142
|
+
},
|
|
143
|
+
render: function Render(args) {
|
|
144
|
+
return (
|
|
145
|
+
<PrimitiveButton {...args} disabled>
|
|
146
|
+
Button text
|
|
147
|
+
</PrimitiveButton>
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const DisabledFocusInteraction: Story = {
|
|
153
|
+
play: async ({ canvasElement }) => {
|
|
154
|
+
const canvas = within(canvasElement);
|
|
155
|
+
const button = canvas.getByRole('button');
|
|
156
|
+
await userEvent.tab();
|
|
157
|
+
await expect(button).not.toHaveFocus();
|
|
158
|
+
},
|
|
159
|
+
render: function Render(args) {
|
|
160
|
+
return (
|
|
161
|
+
<PrimitiveButton {...args} disabled>
|
|
162
|
+
Button text
|
|
163
|
+
</PrimitiveButton>
|
|
164
|
+
);
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export const DisabledBlurInteraction: Story = {
|
|
169
|
+
play: async ({ canvasElement }) => {
|
|
170
|
+
const canvas = within(canvasElement);
|
|
171
|
+
const button = canvas.getByRole('button');
|
|
172
|
+
await userEvent.tab();
|
|
173
|
+
await expect(button).not.toHaveFocus();
|
|
174
|
+
},
|
|
175
|
+
render: function Render(args) {
|
|
176
|
+
return (
|
|
177
|
+
<PrimitiveButton {...args} disabled>
|
|
178
|
+
Button text
|
|
179
|
+
</PrimitiveButton>
|
|
180
|
+
);
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const DisabledKeyDownInteraction: Story = {
|
|
185
|
+
play: async ({ canvasElement }) => {
|
|
186
|
+
const canvas = within(canvasElement);
|
|
187
|
+
const button = canvas.getByRole('button');
|
|
188
|
+
await userEvent.type(button, '{enter}');
|
|
189
|
+
await expect(button).toHaveTextContent('Button text');
|
|
190
|
+
},
|
|
191
|
+
render: function Render(args) {
|
|
192
|
+
return (
|
|
193
|
+
<PrimitiveButton {...args} disabled>
|
|
194
|
+
Button text
|
|
195
|
+
</PrimitiveButton>
|
|
196
|
+
);
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const DisabledMouseEnterInteraction: Story = {
|
|
201
|
+
play: async ({ canvasElement }) => {
|
|
202
|
+
const canvas = within(canvasElement);
|
|
203
|
+
const button = canvas.getByRole('button');
|
|
204
|
+
await userEvent.hover(button);
|
|
205
|
+
await expect(button).toHaveTextContent('Button text');
|
|
206
|
+
},
|
|
207
|
+
render: function Render(args) {
|
|
208
|
+
return (
|
|
209
|
+
<PrimitiveButton {...args} disabled>
|
|
210
|
+
Button text
|
|
211
|
+
</PrimitiveButton>
|
|
212
|
+
);
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export const DisabledMouseLeaveInteraction: Story = {
|
|
217
|
+
play: async ({ canvasElement }) => {
|
|
218
|
+
const canvas = within(canvasElement);
|
|
219
|
+
const button = canvas.getByRole('button');
|
|
220
|
+
await userEvent.unhover(button);
|
|
221
|
+
await expect(button).toHaveTextContent('Button text');
|
|
222
|
+
},
|
|
223
|
+
render: function Render(args) {
|
|
224
|
+
return (
|
|
225
|
+
<PrimitiveButton {...args} disabled>
|
|
226
|
+
Button text
|
|
227
|
+
</PrimitiveButton>
|
|
228
|
+
);
|
|
229
|
+
},
|
|
230
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { fireEvent, screen } from '@testing-library/react';
|
|
2
|
+
import { userEvent } from '@testing-library/user-event';
|
|
3
|
+
import PrimitiveButton from '..';
|
|
4
|
+
import messages from '../../../i18n/commonMessages/Button.messages';
|
|
5
|
+
import { render } from '../../../test-utils';
|
|
6
|
+
|
|
7
|
+
describe('Button', () => {
|
|
8
|
+
const defaultProps = {
|
|
9
|
+
children: 'Click me',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const renderButton = (
|
|
13
|
+
props?: Partial<typeof defaultProps>,
|
|
14
|
+
locale = 'en',
|
|
15
|
+
localeMessages = messages,
|
|
16
|
+
) => {
|
|
17
|
+
return render(
|
|
18
|
+
<PrimitiveButton {...defaultProps} {...props} />,
|
|
19
|
+
// @ts-expect-error: props be missing properties from type
|
|
20
|
+
{ locale, messages: localeMessages },
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
it('renders a button by default', () => {
|
|
25
|
+
renderButton();
|
|
26
|
+
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
27
|
+
expect(screen.getByRole('button')).toHaveTextContent('Click me');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('applies the correct classes based on props', () => {
|
|
31
|
+
const props = {
|
|
32
|
+
...defaultProps,
|
|
33
|
+
className: 'custom-class',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
renderButton(props);
|
|
37
|
+
|
|
38
|
+
const button = screen.getByRole('button');
|
|
39
|
+
expect(button).toHaveClass('wds-Button');
|
|
40
|
+
expect(button).toHaveClass('custom-class');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('disables the button when disabled is true', () => {
|
|
44
|
+
const props = {
|
|
45
|
+
...defaultProps,
|
|
46
|
+
disabled: true,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
renderButton(props);
|
|
50
|
+
|
|
51
|
+
const button = screen.getByRole('button');
|
|
52
|
+
expect(button).toHaveClass('wds-Button--disabled');
|
|
53
|
+
expect(button).toBeDisabled();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('sets data-testid attribute', () => {
|
|
57
|
+
const props = {
|
|
58
|
+
...defaultProps,
|
|
59
|
+
testId: 'custom-id',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
renderButton(props);
|
|
63
|
+
|
|
64
|
+
const button = screen.getByTestId('custom-id');
|
|
65
|
+
expect(button).toBeInTheDocument();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('sets the type attribute to submit', () => {
|
|
69
|
+
const props = {
|
|
70
|
+
...defaultProps,
|
|
71
|
+
type: 'submit',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
renderButton(props);
|
|
75
|
+
|
|
76
|
+
const button = screen.getByRole('button');
|
|
77
|
+
expect(button).toHaveAttribute('type', 'submit');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('sets the type attribute to reset', () => {
|
|
81
|
+
const props = {
|
|
82
|
+
...defaultProps,
|
|
83
|
+
type: 'reset',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
renderButton(props);
|
|
87
|
+
|
|
88
|
+
const button = screen.getByRole('button');
|
|
89
|
+
expect(button).toHaveAttribute('type', 'reset');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('sets the type attribute to button by default', () => {
|
|
93
|
+
renderButton();
|
|
94
|
+
const button = screen.getByRole('button');
|
|
95
|
+
expect(button).toHaveAttribute('type', 'button');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('displays the aria-label in Spanish when loading', () => {
|
|
99
|
+
const props = {
|
|
100
|
+
...defaultProps,
|
|
101
|
+
loading: true,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const spanishMessages = {
|
|
105
|
+
...messages,
|
|
106
|
+
'neptune.Button.loadingAriaLabel': 'cargando',
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
renderButton(props, 'es', spanishMessages);
|
|
110
|
+
|
|
111
|
+
const button = screen.getByRole('button');
|
|
112
|
+
expect(button).toHaveAttribute('aria-label', 'cargando');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { default as PrimitiveButton } from './PrimitiveButton';
|
|
2
|
+
export { default as PrimitiveAnchor } from './PrimitiveAnchor';
|
|
3
|
+
|
|
4
|
+
export type { BasePrimitiveProps, StyleProp } from './types';
|
|
5
|
+
export type {
|
|
6
|
+
PrimitiveButtonProps,
|
|
7
|
+
PrimitiveButtonAttributes,
|
|
8
|
+
PrimitiveButtonElementRef,
|
|
9
|
+
} from './PrimitiveButton';
|
|
10
|
+
export type {
|
|
11
|
+
PrimitiveAnchorProps,
|
|
12
|
+
PrimitiveAnchorAttributes,
|
|
13
|
+
PrimitiveAnchorElementRef,
|
|
14
|
+
} from './PrimitiveAnchor';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type BasePrimitiveProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Additional CSS classes to apply.
|
|
6
|
+
*/
|
|
7
|
+
className?: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier for the component.
|
|
11
|
+
*/
|
|
12
|
+
id?: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
|
|
16
|
+
*/
|
|
17
|
+
testId?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `data-testid` is strictly controlled through the `testId` prop.
|
|
21
|
+
* This lets consumers know that this data attribute will not be applied.
|
|
22
|
+
*/
|
|
23
|
+
'data-testid'?: never;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Accessible role.
|
|
27
|
+
*/
|
|
28
|
+
role?: RoleProp['role'];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Inline styles to be applied to the primitive. Only apply as a last resort, or where
|
|
33
|
+
* styles cannot otherwise be calculated outside of the runtime of the component they're applied.
|
|
34
|
+
*/
|
|
35
|
+
export type StyleProp = Pick<HTMLAttributes<HTMLElement>, 'style'>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Accessible role.
|
|
39
|
+
*/
|
|
40
|
+
export type RoleProp = Pick<HTMLAttributes<HTMLElement>, 'role'>;
|
package/src/table/Table.tsx
CHANGED
|
@@ -41,6 +41,7 @@ const Table = ({
|
|
|
41
41
|
}: TableProps) => {
|
|
42
42
|
const { formatMessage } = useIntl();
|
|
43
43
|
const { theme } = useTheme();
|
|
44
|
+
const isEmptyHeader = loading ?? (data?.headers && !data?.headers.length);
|
|
44
45
|
|
|
45
46
|
const getRowLength = () => {
|
|
46
47
|
const columnsLength = data?.headers?.length ?? 0;
|
|
@@ -124,9 +125,9 @@ const Table = ({
|
|
|
124
125
|
>
|
|
125
126
|
<div className="np-table-inner-container">
|
|
126
127
|
<table className="np-table">
|
|
127
|
-
<thead
|
|
128
|
+
<thead aria-hidden={isEmptyHeader}>
|
|
128
129
|
<tr>
|
|
129
|
-
{
|
|
130
|
+
{isEmptyHeader ? (
|
|
130
131
|
<TableHeader />
|
|
131
132
|
) : (
|
|
132
133
|
data?.headers?.map((headerItem: TableHeaderType, index) => (
|
package/src/test-utils/index.tsx
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.messages.js","sources":["../../src/button/Button.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n loadingAriaLabel: {\n id: 'neptune.Button.loadingAriaLabel',\n defaultMessage: 'loading',\n description: 'Description of button while loading',\n },\n});\n"],"names":["defineMessages","loadingAriaLabel","id"],"mappings":";;;;AAEA,eAAeA,wBAAc,CAAC;AAC5BC,EAAAA,gBAAgB,EAAE;IAChBC,EAAE,EAAA,iCAAA;AAGH,GAAA;AACF,CAAA,CAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.messages.mjs","sources":["../../src/button/Button.messages.ts"],"sourcesContent":["import { defineMessages } from 'react-intl';\n\nexport default defineMessages({\n loadingAriaLabel: {\n id: 'neptune.Button.loadingAriaLabel',\n defaultMessage: 'loading',\n description: 'Description of button while loading',\n },\n});\n"],"names":["defineMessages","loadingAriaLabel","id"],"mappings":";;AAEA,eAAeA,cAAc,CAAC;AAC5BC,EAAAA,gBAAgB,EAAE;IAChBC,EAAE,EAAA,iCAAA;AAGH,GAAA;AACF,CAAA,CAAC;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Button.messages.d.ts","sourceRoot":"","sources":["../../../src/button/Button.messages.ts"],"names":[],"mappings":";;;;;;;AAEA,wBAMG"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|