@transferwise/components 0.0.0-experimental-a9e2e05 → 0.0.0-experimental-e92f7ac
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 +2 -9
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +2 -9
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/button/{LegacyButton/Button.js → Button.js} +24 -25
- package/build/button/Button.js.map +1 -0
- package/build/button/{LegacyButton/Button.mjs → Button.mjs} +24 -25
- package/build/button/Button.mjs.map +1 -0
- package/build/button/classMap.js +42 -0
- package/build/button/classMap.js.map +1 -0
- package/build/button/classMap.mjs +39 -0
- package/build/button/classMap.mjs.map +1 -0
- package/build/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.js +21 -21
- package/build/button/legacyUtils/legacyUtils.js.map +1 -0
- package/build/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.mjs +21 -21
- package/build/button/legacyUtils/legacyUtils.mjs.map +1 -0
- package/build/circularButton/CircularButton.js +1 -1
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +1 -1
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/action/Action.js +1 -1
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +1 -1
- package/build/common/action/Action.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/index.js +1 -1
- package/build/index.mjs +1 -1
- package/build/link/Link.js +3 -8
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +3 -8
- package/build/link/Link.mjs.map +1 -1
- package/build/main.css +29 -288
- package/build/nudge/Nudge.js +1 -1
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +1 -1
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/select/Select.js +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/styles/avatarLayout/AvatarLayout.css +0 -11
- package/build/styles/iconButton/IconButton.css +29 -24
- package/build/styles/main.css +29 -288
- package/build/types/avatarLayout/AvatarLayout.d.ts +2 -1
- package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
- package/build/types/avatarLayout/index.d.ts +0 -1
- package/build/types/avatarLayout/index.d.ts.map +1 -1
- package/build/types/button/{LegacyButton/Button.d.ts → Button.d.ts} +5 -8
- package/build/types/button/Button.d.ts.map +1 -0
- package/build/types/button/classMap.d.ts.map +1 -0
- package/build/types/button/index.d.ts +2 -2
- package/build/types/button/index.d.ts.map +1 -1
- package/build/types/button/legacyUtils/index.d.ts.map +1 -0
- package/build/types/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.d.ts +1 -1
- package/build/types/button/legacyUtils/legacyUtils.d.ts.map +1 -0
- package/build/types/link/Link.d.ts +2 -2
- package/build/types/link/Link.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/package.json +3 -3
- package/src/avatarLayout/AvatarLayout.css +0 -11
- package/src/avatarLayout/AvatarLayout.less +1 -18
- package/src/avatarLayout/AvatarLayout.tsx +3 -11
- package/src/avatarLayout/index.ts +0 -1
- package/src/avatarWrapper/AvatarWrapper.story.tsx +0 -2
- package/src/button/{LegacyButton/Button.less → Button.less} +1 -1
- package/src/button/{LegacyButton/Button.spec.tsx → Button.spec.tsx} +3 -3
- package/src/button/Button.story.tsx +163 -0
- package/src/button/{LegacyButton/Button.tsx → Button.tsx} +9 -14
- package/src/button/{LegacyButton/classMap.ts → classMap.ts} +1 -1
- package/src/button/index.ts +3 -2
- package/src/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.spec.tsx +2 -2
- package/src/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.ts +2 -2
- package/src/circularButton/CircularButton.tsx +1 -1
- package/src/common/action/Action.tsx +1 -1
- package/src/iconButton/IconButton.css +29 -24
- package/src/iconButton/IconButton.less +4 -4
- package/src/link/Link.tsx +6 -15
- package/src/main.css +29 -288
- package/src/main.less +1 -2
- package/src/nudge/Nudge.tsx +1 -1
- package/src/phoneNumberInput/PhoneNumberInput.spec.tsx +283 -0
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +1 -1
- package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -1
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +1 -1
- package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +3 -2
- package/src/test-utils/index.tsx +1 -0
- package/build/button/Button/src/Button.js +0 -93
- package/build/button/Button/src/Button.js.map +0 -1
- package/build/button/Button/src/Button.mjs +0 -91
- package/build/button/Button/src/Button.mjs.map +0 -1
- package/build/button/LegacyButton/Button.js.map +0 -1
- package/build/button/LegacyButton/Button.mjs.map +0 -1
- package/build/button/LegacyButton/classMap.js +0 -42
- package/build/button/LegacyButton/classMap.js.map +0 -1
- package/build/button/LegacyButton/classMap.mjs +0 -39
- package/build/button/LegacyButton/classMap.mjs.map +0 -1
- package/build/button/LegacyButton/legacyUtils/legacyUtils.js.map +0 -1
- package/build/button/LegacyButton/legacyUtils/legacyUtils.mjs.map +0 -1
- package/build/button/src/Button.js +0 -66
- package/build/button/src/Button.js.map +0 -1
- package/build/button/src/Button.mjs +0 -64
- package/build/button/src/Button.mjs.map +0 -1
- package/build/styles/button/Button/less/Button.css +0 -253
- package/build/styles/button/Button/less/Button.vars.css +0 -57
- package/build/types/button/Button/index.d.ts +0 -3
- package/build/types/button/Button/index.d.ts.map +0 -1
- package/build/types/button/Button/src/Button.d.ts +0 -4
- package/build/types/button/Button/src/Button.d.ts.map +0 -1
- package/build/types/button/Button/src/Button.types.d.ts +0 -50
- package/build/types/button/Button/src/Button.types.d.ts.map +0 -1
- package/build/types/button/Button/src/index.d.ts +0 -2
- package/build/types/button/Button/src/index.d.ts.map +0 -1
- package/build/types/button/LegacyButton/Button.d.ts.map +0 -1
- package/build/types/button/LegacyButton/classMap.d.ts.map +0 -1
- package/build/types/button/LegacyButton/index.d.ts +0 -3
- package/build/types/button/LegacyButton/index.d.ts.map +0 -1
- package/build/types/button/LegacyButton/legacyUtils/index.d.ts.map +0 -1
- package/build/types/button/LegacyButton/legacyUtils/legacyUtils.d.ts.map +0 -1
- package/build/types/button/src/Button.d.ts +0 -47
- package/build/types/button/src/Button.d.ts.map +0 -1
- package/build/types/button/src/index.d.ts +0 -3
- package/build/types/button/src/index.d.ts.map +0 -1
- package/src/button/Button/index.ts +0 -2
- package/src/button/Button/less/Button.css +0 -253
- package/src/button/Button/less/Button.less +0 -221
- package/src/button/Button/less/Button.vars.css +0 -57
- package/src/button/Button/less/Button.vars.less +0 -65
- package/src/button/Button/src/Button.tsx +0 -116
- package/src/button/Button/src/Button.types.ts +0 -70
- package/src/button/Button/src/index.ts +0 -1
- package/src/button/Button/stories/Button.story.tsx +0 -314
- package/src/button/Button/stories/Button.tests.story.tsx +0 -288
- package/src/button/Button/test/Button.spec.tsx +0 -328
- package/src/button/LegacyButton/Button.story.tsx +0 -224
- package/src/button/LegacyButton/index.ts +0 -3
- package/src/button/src/Button.tsx +0 -87
- package/src/button/src/index.ts +0 -2
- package/src/button/test/Button.spec.tsx +0 -32
- package/src/phoneNumberInput/PhoneNumberInput.rtl.spec.tsx +0 -32
- package/src/phoneNumberInput/PhoneNumberInput.spec.js +0 -356
- /package/build/styles/button/{LegacyButton/Button.css → Button.css} +0 -0
- /package/build/types/button/{LegacyButton/classMap.d.ts → classMap.d.ts} +0 -0
- /package/build/types/button/{LegacyButton/legacyUtils → legacyUtils}/index.d.ts +0 -0
- /package/src/button/{LegacyButton/Button.css → Button.css} +0 -0
- /package/src/button/{LegacyButton/__snapshots__ → __snapshots__}/Button.spec.tsx.snap +0 -0
- /package/src/button/{LegacyButton/legacyUtils → legacyUtils}/index.ts +0 -0
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import { userEvent, within, fn, expect } from '@storybook/test';
|
|
3
|
-
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import Button from '..';
|
|
6
|
-
|
|
7
|
-
const withContainer = (Story: any) => (
|
|
8
|
-
<div
|
|
9
|
-
style={{
|
|
10
|
-
display: 'flex',
|
|
11
|
-
flexDirection: 'initial',
|
|
12
|
-
justifyContent: 'center',
|
|
13
|
-
flexFlow: 'column',
|
|
14
|
-
alignItems: 'center',
|
|
15
|
-
}}
|
|
16
|
-
>
|
|
17
|
-
<Story />
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const meta: Meta<typeof Button> = {
|
|
22
|
-
component: Button,
|
|
23
|
-
title: 'Actions/Button/Legacy',
|
|
24
|
-
args: {
|
|
25
|
-
children: 'Button text',
|
|
26
|
-
loading: false,
|
|
27
|
-
type: undefined,
|
|
28
|
-
onClick: fn(),
|
|
29
|
-
onBlur: fn(),
|
|
30
|
-
onFocus: fn(),
|
|
31
|
-
href: 'https://example.com',
|
|
32
|
-
},
|
|
33
|
-
argTypes: {
|
|
34
|
-
as: {
|
|
35
|
-
control: {
|
|
36
|
-
type: 'select',
|
|
37
|
-
options: ['button', 'a'],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
type: {
|
|
41
|
-
type: {
|
|
42
|
-
name: 'enum',
|
|
43
|
-
value: ['accent', 'positive', 'negative'],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
size: {
|
|
47
|
-
type: {
|
|
48
|
-
name: 'enum',
|
|
49
|
-
value: ['xs', 'sm', 'md', 'lg'],
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
priority: {
|
|
53
|
-
type: {
|
|
54
|
-
name: 'enum',
|
|
55
|
-
value: ['primary', 'secondary', 'tertiary'],
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
appearance: {
|
|
59
|
-
table: {
|
|
60
|
-
disable: true,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
iconLeft: {
|
|
64
|
-
table: {
|
|
65
|
-
disable: true,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
iconRight: {
|
|
69
|
-
table: {
|
|
70
|
-
disable: true,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
avatars: {
|
|
74
|
-
table: {
|
|
75
|
-
disable: true,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
'data-testid': {
|
|
79
|
-
table: {
|
|
80
|
-
disable: true,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
tags: ['autodocs'],
|
|
85
|
-
decorators: [withContainer],
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export default meta;
|
|
89
|
-
|
|
90
|
-
type Story = StoryObj<typeof Button>;
|
|
91
|
-
|
|
92
|
-
export const Basic: Story = {};
|
|
93
|
-
|
|
94
|
-
export const Secondary: Story = {
|
|
95
|
-
args: {
|
|
96
|
-
type: 'accent',
|
|
97
|
-
priority: 'secondary',
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export const Tertiary: Story = {
|
|
102
|
-
args: {
|
|
103
|
-
type: 'accent',
|
|
104
|
-
priority: 'tertiary',
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const Negative: Story = {
|
|
109
|
-
args: {
|
|
110
|
-
type: 'negative',
|
|
111
|
-
priority: 'primary',
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const Loading: Story = {
|
|
116
|
-
args: {
|
|
117
|
-
loading: true,
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const Variants: Story = {
|
|
122
|
-
render: () => {
|
|
123
|
-
return (
|
|
124
|
-
<div className="d-flex flex-column p-b-2 align-items-start">
|
|
125
|
-
<div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
126
|
-
<Button type="accent" priority="primary">
|
|
127
|
-
Primary Accent
|
|
128
|
-
</Button>
|
|
129
|
-
<Button type="accent" priority="secondary">
|
|
130
|
-
Secondary Accent
|
|
131
|
-
</Button>
|
|
132
|
-
<Button type="accent" priority="tertiary">
|
|
133
|
-
Tertiary Accent
|
|
134
|
-
</Button>
|
|
135
|
-
</div>
|
|
136
|
-
<div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
137
|
-
<Button type="positive" priority="primary">
|
|
138
|
-
Primary Positive
|
|
139
|
-
</Button>
|
|
140
|
-
<Button type="positive" priority="secondary">
|
|
141
|
-
Secondary Accent
|
|
142
|
-
</Button>
|
|
143
|
-
</div>
|
|
144
|
-
<div className="d-flex flex-row flex- p-b-2" style={{ gap: 'var(--size-16)' }}>
|
|
145
|
-
<Button type="negative" priority="primary">
|
|
146
|
-
Primary Negative
|
|
147
|
-
</Button>
|
|
148
|
-
<Button type="negative" priority="secondary">
|
|
149
|
-
Secondary Negative
|
|
150
|
-
</Button>
|
|
151
|
-
</div>
|
|
152
|
-
<div className="d-flex flex-row p-b-1" style={{ gap: 'var(--size-16)' }}>
|
|
153
|
-
<Button type="accent" priority="primary" disabled>
|
|
154
|
-
Button Disabled
|
|
155
|
-
</Button>
|
|
156
|
-
<Button type="accent" priority="secondary" disabled>
|
|
157
|
-
Button Disabled
|
|
158
|
-
</Button>
|
|
159
|
-
<Button type="accent" priority="tertiary" disabled>
|
|
160
|
-
Button Disabled
|
|
161
|
-
</Button>
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const wait = async (duration = 500) =>
|
|
169
|
-
new Promise<void>((resolve) => {
|
|
170
|
-
setTimeout(resolve, duration);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
export const Focused: Story = {
|
|
174
|
-
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
175
|
-
const canvas = within(canvasElement);
|
|
176
|
-
const button = canvas.getByRole('button');
|
|
177
|
-
await userEvent.tab();
|
|
178
|
-
await expect(button).toHaveFocus();
|
|
179
|
-
await expect(button).toHaveTextContent('Focused!');
|
|
180
|
-
},
|
|
181
|
-
render: function Render(args: React.ComponentProps<typeof Button>) {
|
|
182
|
-
const [focused, setFocused] = useState(false);
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<Button {...args} onFocus={() => setFocused(true)}>
|
|
186
|
-
{focused ? 'Focused!' : 'Button text'}
|
|
187
|
-
</Button>
|
|
188
|
-
);
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export const SocialMedia: Story = {
|
|
193
|
-
render: () => {
|
|
194
|
-
return (
|
|
195
|
-
<>
|
|
196
|
-
<div className="m-b-2">
|
|
197
|
-
<button type="button" className="btn btn-google">
|
|
198
|
-
Login with Google
|
|
199
|
-
</button>
|
|
200
|
-
</div>
|
|
201
|
-
<div className="m-b-2">
|
|
202
|
-
<button type="button" className="btn btn-facebook">
|
|
203
|
-
Login with Facebook
|
|
204
|
-
</button>
|
|
205
|
-
</div>
|
|
206
|
-
<div className="m-b-2">
|
|
207
|
-
<button type="button" className="btn btn-lg btn-facebook">
|
|
208
|
-
Large Button
|
|
209
|
-
</button>
|
|
210
|
-
</div>
|
|
211
|
-
<div className="m-b-2">
|
|
212
|
-
<button type="button" className="btn btn-block btn-facebook">
|
|
213
|
-
Block Button
|
|
214
|
-
</button>
|
|
215
|
-
</div>
|
|
216
|
-
<div className="m-b-2">
|
|
217
|
-
<button type="button" className="btn btn-lg btn-block btn-facebook">
|
|
218
|
-
Large Block Button
|
|
219
|
-
</button>
|
|
220
|
-
</div>
|
|
221
|
-
</>
|
|
222
|
-
);
|
|
223
|
-
},
|
|
224
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import LegacyButton, { ButtonProps as LegacyButtonProps } from '../LegacyButton';
|
|
4
|
-
import NewButton from '../Button';
|
|
5
|
-
import { ButtonProps as NewButtonProps } from '../Button/src/Button.types';
|
|
6
|
-
|
|
7
|
-
type LegacyButtonType =
|
|
8
|
-
| 'accent'
|
|
9
|
-
| 'negative'
|
|
10
|
-
| 'positive'
|
|
11
|
-
| 'primary'
|
|
12
|
-
| 'pay'
|
|
13
|
-
| 'secondary'
|
|
14
|
-
| 'danger'
|
|
15
|
-
| 'link'
|
|
16
|
-
| null
|
|
17
|
-
| undefined;
|
|
18
|
-
type NewButtonType = 'button' | 'submit' | 'reset' | LegacyButtonType | undefined;
|
|
19
|
-
|
|
20
|
-
export type ButtonProps =
|
|
21
|
-
| (LegacyButtonProps & { type?: LegacyButtonType; useNewButton?: false })
|
|
22
|
-
| (Omit<NewButtonProps, 'type'> & { type?: NewButtonType; useNewButton: true });
|
|
23
|
-
|
|
24
|
-
const mapProps = (props: LegacyButtonProps): NewButtonProps => {
|
|
25
|
-
const { priority, size, type, as, ...newProps } = props;
|
|
26
|
-
|
|
27
|
-
const priorityMapping: Record<string, Record<string, NewButtonProps['priority']>> = {
|
|
28
|
-
accent: {
|
|
29
|
-
primary: 'primary',
|
|
30
|
-
secondary: 'tertiary',
|
|
31
|
-
tertiary: 'minimal',
|
|
32
|
-
},
|
|
33
|
-
positive: {
|
|
34
|
-
primary: 'primary',
|
|
35
|
-
secondary: 'tertiary',
|
|
36
|
-
tertiary: 'tertiary',
|
|
37
|
-
},
|
|
38
|
-
negative: {
|
|
39
|
-
primary: 'primary',
|
|
40
|
-
secondary: 'secondary',
|
|
41
|
-
tertiary: 'secondary',
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const mappedPriority =
|
|
46
|
-
type && priority ? priorityMapping[type]?.[priority] || priority : priority || null;
|
|
47
|
-
const mappedAppearance = type === 'negative' ? 'negative' : null;
|
|
48
|
-
|
|
49
|
-
const legacyButtonTypes: LegacyButtonType[] = [
|
|
50
|
-
'accent',
|
|
51
|
-
'negative',
|
|
52
|
-
'positive',
|
|
53
|
-
'primary',
|
|
54
|
-
'pay',
|
|
55
|
-
'secondary',
|
|
56
|
-
'danger',
|
|
57
|
-
'link',
|
|
58
|
-
];
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
...newProps,
|
|
62
|
-
size:
|
|
63
|
-
size === 'xs' || size === 'sm' ? 'sm' : size === 'md' ? 'md' : size === 'lg' ? 'lg' : size,
|
|
64
|
-
priority: mappedPriority,
|
|
65
|
-
appearance: mappedAppearance || ('appearance' in props ? props.appearance : null),
|
|
66
|
-
type:
|
|
67
|
-
as === 'button' && !legacyButtonTypes.includes(type as LegacyButtonType)
|
|
68
|
-
? props.htmlType
|
|
69
|
-
: null,
|
|
70
|
-
href: as === 'a' ? props.href || '' : null,
|
|
71
|
-
} as NewButtonProps;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const Button = forwardRef<any, ButtonProps>((props, ref) => {
|
|
75
|
-
const { useNewButton, ...rest } = props;
|
|
76
|
-
|
|
77
|
-
if (useNewButton) {
|
|
78
|
-
const mappedProps = mapProps(props as LegacyButtonProps);
|
|
79
|
-
return <NewButton {...mappedProps} ref={ref as any} />;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return <LegacyButton {...(rest as LegacyButtonProps)} ref={ref as any} />;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
Button.displayName = 'Button';
|
|
86
|
-
|
|
87
|
-
export default Button;
|
package/src/button/src/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { render, screen } from '../../test-utils';
|
|
2
|
-
import Button, { ButtonProps } from '..';
|
|
3
|
-
|
|
4
|
-
describe('Button', () => {
|
|
5
|
-
const legacyProps: ButtonProps = {
|
|
6
|
-
priority: 'primary',
|
|
7
|
-
size: 'md',
|
|
8
|
-
type: 'accent',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const newProps: ButtonProps = {
|
|
12
|
-
useNewButton: true,
|
|
13
|
-
priority: 'primary',
|
|
14
|
-
size: 'md',
|
|
15
|
-
type: 'accent',
|
|
16
|
-
testId: 'new-button',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
it('renders LegacyButton when useNewButton is false', () => {
|
|
20
|
-
render(<Button {...legacyProps}>Legacy Button</Button>);
|
|
21
|
-
const button = screen.getByText('Legacy Button');
|
|
22
|
-
expect(button).toBeInTheDocument();
|
|
23
|
-
expect(button).toHaveClass('btn btn-md np-btn np-btn-md btn-accent btn-priority-1');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('renders the new Button when useNewButton is true', () => {
|
|
27
|
-
render(<Button {...newProps}>New Button</Button>);
|
|
28
|
-
const button = screen.getByTestId('new-button');
|
|
29
|
-
expect(button).toBeInTheDocument();
|
|
30
|
-
expect(button).toHaveClass('wds-Button wds-Button--medium wds-Button--primary');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Field } from '../field/Field';
|
|
2
|
-
import { mockMatchMedia, mockResizeObserver, render, screen, within } from '../test-utils';
|
|
3
|
-
|
|
4
|
-
import PhoneNumberInput from './PhoneNumberInput';
|
|
5
|
-
|
|
6
|
-
mockMatchMedia();
|
|
7
|
-
mockResizeObserver();
|
|
8
|
-
|
|
9
|
-
describe('PhoneNumberInput', () => {
|
|
10
|
-
it('supports custom `aria-labelledby` attribute', () => {
|
|
11
|
-
render(
|
|
12
|
-
<>
|
|
13
|
-
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
|
14
|
-
<label id="prioritized-label">Prioritized label</label>
|
|
15
|
-
<PhoneNumberInput aria-labelledby="prioritized-label" onChange={() => {}} />
|
|
16
|
-
</>,
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
expect(
|
|
20
|
-
within(screen.getByLabelText('Prioritized label')).getByRole('textbox'),
|
|
21
|
-
).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('supports `Field` for labeling', () => {
|
|
25
|
-
render(
|
|
26
|
-
<Field label="Phone number">
|
|
27
|
-
<PhoneNumberInput initialValue="+12345678" onChange={() => {}} />
|
|
28
|
-
</Field>,
|
|
29
|
-
);
|
|
30
|
-
expect(screen.getAllByRole('group')[0]).toHaveAccessibleName(/^Phone number/);
|
|
31
|
-
});
|
|
32
|
-
});
|