@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.
Files changed (153) hide show
  1. package/build/avatarLayout/AvatarLayout.js +2 -9
  2. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  3. package/build/avatarLayout/AvatarLayout.mjs +2 -9
  4. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  5. package/build/button/{LegacyButton/Button.js → Button.js} +24 -25
  6. package/build/button/Button.js.map +1 -0
  7. package/build/button/{LegacyButton/Button.mjs → Button.mjs} +24 -25
  8. package/build/button/Button.mjs.map +1 -0
  9. package/build/button/classMap.js +42 -0
  10. package/build/button/classMap.js.map +1 -0
  11. package/build/button/classMap.mjs +39 -0
  12. package/build/button/classMap.mjs.map +1 -0
  13. package/build/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.js +21 -21
  14. package/build/button/legacyUtils/legacyUtils.js.map +1 -0
  15. package/build/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.mjs +21 -21
  16. package/build/button/legacyUtils/legacyUtils.mjs.map +1 -0
  17. package/build/circularButton/CircularButton.js +1 -1
  18. package/build/circularButton/CircularButton.js.map +1 -1
  19. package/build/circularButton/CircularButton.mjs +1 -1
  20. package/build/circularButton/CircularButton.mjs.map +1 -1
  21. package/build/common/action/Action.js +1 -1
  22. package/build/common/action/Action.js.map +1 -1
  23. package/build/common/action/Action.mjs +1 -1
  24. package/build/common/action/Action.mjs.map +1 -1
  25. package/build/criticalBanner/CriticalCommsBanner.js +1 -1
  26. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  27. package/build/header/Header.js +1 -1
  28. package/build/header/Header.mjs +1 -1
  29. package/build/index.js +1 -1
  30. package/build/index.mjs +1 -1
  31. package/build/link/Link.js +3 -8
  32. package/build/link/Link.js.map +1 -1
  33. package/build/link/Link.mjs +3 -8
  34. package/build/link/Link.mjs.map +1 -1
  35. package/build/main.css +29 -288
  36. package/build/nudge/Nudge.js +1 -1
  37. package/build/nudge/Nudge.js.map +1 -1
  38. package/build/nudge/Nudge.mjs +1 -1
  39. package/build/nudge/Nudge.mjs.map +1 -1
  40. package/build/select/Select.js +1 -1
  41. package/build/select/Select.mjs +1 -1
  42. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  43. package/build/styles/iconButton/IconButton.css +29 -24
  44. package/build/styles/main.css +29 -288
  45. package/build/types/avatarLayout/AvatarLayout.d.ts +2 -1
  46. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  47. package/build/types/avatarLayout/index.d.ts +0 -1
  48. package/build/types/avatarLayout/index.d.ts.map +1 -1
  49. package/build/types/button/{LegacyButton/Button.d.ts → Button.d.ts} +5 -8
  50. package/build/types/button/Button.d.ts.map +1 -0
  51. package/build/types/button/classMap.d.ts.map +1 -0
  52. package/build/types/button/index.d.ts +2 -2
  53. package/build/types/button/index.d.ts.map +1 -1
  54. package/build/types/button/legacyUtils/index.d.ts.map +1 -0
  55. package/build/types/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.d.ts +1 -1
  56. package/build/types/button/legacyUtils/legacyUtils.d.ts.map +1 -0
  57. package/build/types/link/Link.d.ts +2 -2
  58. package/build/types/link/Link.d.ts.map +1 -1
  59. package/build/types/test-utils/index.d.ts.map +1 -1
  60. package/build/upload/steps/completeStep/completeStep.js +1 -1
  61. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  62. package/build/upload/steps/processingStep/processingStep.js +1 -1
  63. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  64. package/build/uploadInput/UploadInput.js +1 -1
  65. package/build/uploadInput/UploadInput.mjs +1 -1
  66. package/package.json +3 -3
  67. package/src/avatarLayout/AvatarLayout.css +0 -11
  68. package/src/avatarLayout/AvatarLayout.less +1 -18
  69. package/src/avatarLayout/AvatarLayout.tsx +3 -11
  70. package/src/avatarLayout/index.ts +0 -1
  71. package/src/avatarWrapper/AvatarWrapper.story.tsx +0 -2
  72. package/src/button/{LegacyButton/Button.less → Button.less} +1 -1
  73. package/src/button/{LegacyButton/Button.spec.tsx → Button.spec.tsx} +3 -3
  74. package/src/button/Button.story.tsx +163 -0
  75. package/src/button/{LegacyButton/Button.tsx → Button.tsx} +9 -14
  76. package/src/button/{LegacyButton/classMap.ts → classMap.ts} +1 -1
  77. package/src/button/index.ts +3 -2
  78. package/src/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.spec.tsx +2 -2
  79. package/src/button/{LegacyButton/legacyUtils → legacyUtils}/legacyUtils.ts +2 -2
  80. package/src/circularButton/CircularButton.tsx +1 -1
  81. package/src/common/action/Action.tsx +1 -1
  82. package/src/iconButton/IconButton.css +29 -24
  83. package/src/iconButton/IconButton.less +4 -4
  84. package/src/link/Link.tsx +6 -15
  85. package/src/main.css +29 -288
  86. package/src/main.less +1 -2
  87. package/src/nudge/Nudge.tsx +1 -1
  88. package/src/phoneNumberInput/PhoneNumberInput.spec.tsx +283 -0
  89. package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +1 -1
  90. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -1
  91. package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +1 -1
  92. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +3 -2
  93. package/src/test-utils/index.tsx +1 -0
  94. package/build/button/Button/src/Button.js +0 -93
  95. package/build/button/Button/src/Button.js.map +0 -1
  96. package/build/button/Button/src/Button.mjs +0 -91
  97. package/build/button/Button/src/Button.mjs.map +0 -1
  98. package/build/button/LegacyButton/Button.js.map +0 -1
  99. package/build/button/LegacyButton/Button.mjs.map +0 -1
  100. package/build/button/LegacyButton/classMap.js +0 -42
  101. package/build/button/LegacyButton/classMap.js.map +0 -1
  102. package/build/button/LegacyButton/classMap.mjs +0 -39
  103. package/build/button/LegacyButton/classMap.mjs.map +0 -1
  104. package/build/button/LegacyButton/legacyUtils/legacyUtils.js.map +0 -1
  105. package/build/button/LegacyButton/legacyUtils/legacyUtils.mjs.map +0 -1
  106. package/build/button/src/Button.js +0 -66
  107. package/build/button/src/Button.js.map +0 -1
  108. package/build/button/src/Button.mjs +0 -64
  109. package/build/button/src/Button.mjs.map +0 -1
  110. package/build/styles/button/Button/less/Button.css +0 -253
  111. package/build/styles/button/Button/less/Button.vars.css +0 -57
  112. package/build/types/button/Button/index.d.ts +0 -3
  113. package/build/types/button/Button/index.d.ts.map +0 -1
  114. package/build/types/button/Button/src/Button.d.ts +0 -4
  115. package/build/types/button/Button/src/Button.d.ts.map +0 -1
  116. package/build/types/button/Button/src/Button.types.d.ts +0 -50
  117. package/build/types/button/Button/src/Button.types.d.ts.map +0 -1
  118. package/build/types/button/Button/src/index.d.ts +0 -2
  119. package/build/types/button/Button/src/index.d.ts.map +0 -1
  120. package/build/types/button/LegacyButton/Button.d.ts.map +0 -1
  121. package/build/types/button/LegacyButton/classMap.d.ts.map +0 -1
  122. package/build/types/button/LegacyButton/index.d.ts +0 -3
  123. package/build/types/button/LegacyButton/index.d.ts.map +0 -1
  124. package/build/types/button/LegacyButton/legacyUtils/index.d.ts.map +0 -1
  125. package/build/types/button/LegacyButton/legacyUtils/legacyUtils.d.ts.map +0 -1
  126. package/build/types/button/src/Button.d.ts +0 -47
  127. package/build/types/button/src/Button.d.ts.map +0 -1
  128. package/build/types/button/src/index.d.ts +0 -3
  129. package/build/types/button/src/index.d.ts.map +0 -1
  130. package/src/button/Button/index.ts +0 -2
  131. package/src/button/Button/less/Button.css +0 -253
  132. package/src/button/Button/less/Button.less +0 -221
  133. package/src/button/Button/less/Button.vars.css +0 -57
  134. package/src/button/Button/less/Button.vars.less +0 -65
  135. package/src/button/Button/src/Button.tsx +0 -116
  136. package/src/button/Button/src/Button.types.ts +0 -70
  137. package/src/button/Button/src/index.ts +0 -1
  138. package/src/button/Button/stories/Button.story.tsx +0 -314
  139. package/src/button/Button/stories/Button.tests.story.tsx +0 -288
  140. package/src/button/Button/test/Button.spec.tsx +0 -328
  141. package/src/button/LegacyButton/Button.story.tsx +0 -224
  142. package/src/button/LegacyButton/index.ts +0 -3
  143. package/src/button/src/Button.tsx +0 -87
  144. package/src/button/src/index.ts +0 -2
  145. package/src/button/test/Button.spec.tsx +0 -32
  146. package/src/phoneNumberInput/PhoneNumberInput.rtl.spec.tsx +0 -32
  147. package/src/phoneNumberInput/PhoneNumberInput.spec.js +0 -356
  148. /package/build/styles/button/{LegacyButton/Button.css → Button.css} +0 -0
  149. /package/build/types/button/{LegacyButton/classMap.d.ts → classMap.d.ts} +0 -0
  150. /package/build/types/button/{LegacyButton/legacyUtils → legacyUtils}/index.d.ts +0 -0
  151. /package/src/button/{LegacyButton/Button.css → Button.css} +0 -0
  152. /package/src/button/{LegacyButton/__snapshots__ → __snapshots__}/Button.spec.tsx.snap +0 -0
  153. /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,3 +0,0 @@
1
- export { default } from './Button';
2
-
3
- export type { Props as ButtonProps } from './Button';
@@ -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;
@@ -1,2 +0,0 @@
1
- export { default } from './Button';
2
- export type { ButtonProps } from './Button';
@@ -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
- });