@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,116 +0,0 @@
1
- import React, { forwardRef, useMemo } from 'react';
2
- import { clsx } from 'clsx';
3
- import type { ButtonProps } from './Button.types';
4
- import PrimitiveButton from '../../../primitives/PrimitiveButton';
5
- import PrimitiveAnchor from '../../../primitives/PrimitiveAnchor';
6
- import ProcessIndicator from '../../../processIndicator/ProcessIndicator';
7
- import AvatarView from '../../../avatarView/AvatarView';
8
- import AvatarLayout from '../../../avatarLayout/AvatarLayout';
9
-
10
- const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
11
- (
12
- {
13
- as = 'button',
14
- children,
15
- className,
16
- size = 'md',
17
- href,
18
- priority = 'primary',
19
- appearance = 'default',
20
- iconLeft: LeftIcon,
21
- iconRight: RightIcon,
22
- avatars,
23
- type = 'button',
24
- loading = false,
25
- block = false,
26
- ...props
27
- },
28
- ref,
29
- ) => {
30
- const sizeClass = useMemo(() => {
31
- return size === 'sm' ? 'small' : size === 'md' ? 'medium' : size === 'lg' ? 'large' : '';
32
- }, [size]);
33
-
34
- const classNames = clsx(
35
- {
36
- [`wds-Button`]: as === 'a',
37
- [`wds-Button--block`]: block,
38
- [`wds-Button--${sizeClass}`]: size,
39
- [`wds-Button--${priority}`]: priority,
40
- [`wds-Button--${appearance}`]: appearance,
41
- },
42
- className,
43
- );
44
-
45
- const contentClassNames = clsx('wds-Button-content', {
46
- [`wds-Button-content--loading`]: loading,
47
- });
48
-
49
- const content = (
50
- <span className={contentClassNames}>
51
- {loading && (
52
- <ProcessIndicator
53
- size="xs"
54
- className="wds-Button-loader"
55
- data-testid="button-loader-indicator"
56
- />
57
- )}
58
- <span className="wds-Button-label" aria-hidden={loading}>
59
- {size === 'lg' ? (
60
- children
61
- ) : (
62
- <>
63
- {size === 'md' && avatars && (
64
- <span className="wds-Button-avatars">
65
- {avatars.length === 1 ? (
66
- <AvatarView size={24} {...avatars[0]}>
67
- {avatars[0]?.asset}
68
- </AvatarView>
69
- ) : (
70
- <AvatarLayout orientation="horizontal" avatars={avatars} size={24} />
71
- )}
72
- </span>
73
- )}
74
- {!avatars && LeftIcon && (
75
- <LeftIcon className="wds-Button-icon wds-Button-icon--left" />
76
- )}
77
- {children}
78
- {RightIcon && <RightIcon className="wds-Button-icon wds-Button-icon--right" />}
79
- </>
80
- )}
81
- </span>
82
- </span>
83
- );
84
-
85
- if (as === 'a') {
86
- return (
87
- <PrimitiveAnchor
88
- ref={ref as React.Ref<HTMLAnchorElement>}
89
- {...(props as any)}
90
- href={href}
91
- className={classNames}
92
- disabled={props.disabled}
93
- >
94
- {content}
95
- </PrimitiveAnchor>
96
- );
97
- }
98
-
99
- return (
100
- <PrimitiveButton
101
- ref={ref as React.Ref<HTMLButtonElement>}
102
- {...(props as any)}
103
- className={classNames}
104
- disabled={props.disabled}
105
- loading={loading}
106
- type={type}
107
- >
108
- {content}
109
- </PrimitiveButton>
110
- );
111
- },
112
- );
113
-
114
- Button.displayName = 'Button';
115
-
116
- export default Button;
@@ -1,70 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import type {
3
- PrimitiveButtonProps,
4
- PrimitiveAnchorProps,
5
- PrimitiveButtonElementRef,
6
- PrimitiveAnchorElementRef,
7
- } from '../../../primitives';
8
- import type { SingleAvatarType } from '../../../avatarLayout';
9
-
10
- export type ButtonApperance = 'default' | 'negative';
11
- export type ButtonPriority = 'primary' | 'secondary' | 'tertiary' | 'minimal';
12
- export type ButtonType = 'button' | 'submit' | 'reset' | undefined;
13
- export type ButtonSize = 'sm' | 'md' | 'lg';
14
- export type ButtonRefType = PrimitiveButtonElementRef | PrimitiveAnchorElementRef;
15
-
16
- /**
17
- * Common properties for the Button component.
18
- */
19
- export interface CommonButtonProps {
20
- /** The HTML element to render */
21
- as?: 'button' | 'a' | undefined;
22
-
23
- /** Additional class name(s) to apply to the button */
24
- className?: string;
25
-
26
- /** Content to be displayed inside the button */
27
- children?: ReactNode;
28
-
29
- /** Whether the button is disabled */
30
- disabled?: boolean;
31
-
32
- href?: string;
33
-
34
- /** Whether the button is in a loading state */
35
- loading?: boolean;
36
-
37
- /** Whether the button should take up the full width of its container */
38
- block?: boolean;
39
-
40
- /** Size of the button */
41
- size?: ButtonSize;
42
-
43
- /**
44
- * Priority of the button
45
- * @default 'primary'
46
- */
47
- priority?: ButtonPriority;
48
-
49
- /**
50
- * Appearance of the button
51
- * @default 'default'
52
- */
53
- appearance?: ButtonApperance;
54
-
55
- /** Icon to be displayed on the left side of the button */
56
- iconLeft?: React.ElementType;
57
-
58
- /** Icon to be displayed on the right side of the button */
59
- iconRight?: React.ElementType;
60
-
61
- /** Media to be displayed on the left side of the button */
62
- avatars?: SingleAvatarType[];
63
-
64
- /** Optional property to provide component Ref */
65
- ref?: ButtonRefType;
66
- }
67
-
68
- export type ButtonElementProps = PrimitiveButtonProps & CommonButtonProps;
69
- export type AnchorElementProps = PrimitiveAnchorProps & CommonButtonProps;
70
- export type ButtonProps = ButtonElementProps | AnchorElementProps;
@@ -1 +0,0 @@
1
- export { default } from './Button';
@@ -1,314 +0,0 @@
1
- import { Meta, StoryObj } from '@storybook/react';
2
- import { fn } from '@storybook/test';
3
- import Button from '../../src';
4
- import { Freeze, ArrowRight } from '@transferwise/icons';
5
-
6
- const withContainer = (Story: any) => (
7
- <div style={{ display: 'flex', flexDirection: 'initial', justifyContent: 'center' }}>
8
- <Story />
9
- </div>
10
- );
11
-
12
- const meta: Meta<typeof Button> = {
13
- component: Button,
14
- title: 'Actions/Button',
15
- argTypes: {
16
- as: {
17
- type: {
18
- name: 'enum',
19
- value: ['button', 'a'],
20
- },
21
- },
22
- size: {
23
- type: {
24
- name: 'enum',
25
- value: ['sm', 'md', 'lg'],
26
- },
27
- },
28
- href: {
29
- type: {
30
- name: 'string',
31
- },
32
- },
33
- priority: {
34
- type: {
35
- name: 'enum',
36
- value: ['primary', 'secondary', 'tertiary', 'minimal'],
37
- },
38
- },
39
- appearance: {
40
- type: {
41
- name: 'enum',
42
- value: ['default', 'negative'],
43
- },
44
- },
45
- iconLeft: {
46
- control: 'object',
47
- },
48
- iconRight: {
49
- control: 'object',
50
- },
51
- avatars: {
52
- control: 'object',
53
- },
54
- htmlType: {
55
- table: {
56
- disable: true,
57
- },
58
- },
59
- 'data-testid': {
60
- table: {
61
- disable: true,
62
- },
63
- },
64
- },
65
- args: {
66
- children: 'Button text',
67
- as: 'button',
68
- href: undefined,
69
- disabled: false,
70
- loading: false,
71
- size: 'md',
72
- iconLeft: undefined,
73
- iconRight: undefined,
74
- priority: 'primary',
75
- appearance: 'default',
76
- avatars: undefined,
77
- useNewButton: true,
78
- onClick: fn(),
79
- onBlur: fn(),
80
- onFocus: fn(),
81
- onKeyDown: fn(),
82
- onMouseEnter: fn(),
83
- onMouseLeave: fn(),
84
- },
85
- tags: ['autodocs'],
86
- decorators: [withContainer],
87
- };
88
-
89
- export default meta;
90
-
91
- type Story = StoryObj<typeof Button>;
92
-
93
- export const Basic: Story = {
94
- parameters: {
95
- docs: {
96
- description: {
97
- story: 'A basic example of the Button component.',
98
- },
99
- },
100
- },
101
- };
102
-
103
- export const Secondary: Story = {
104
- args: {
105
- priority: 'secondary',
106
- },
107
- parameters: {
108
- docs: {
109
- description: {
110
- story: 'A Button with secondary priority.',
111
- },
112
- },
113
- },
114
- };
115
-
116
- export const Tertiary: Story = {
117
- args: {
118
- priority: 'tertiary',
119
- },
120
- parameters: {
121
- docs: {
122
- description: {
123
- story: 'A Button with tertiary priority.',
124
- },
125
- },
126
- },
127
- };
128
-
129
- export const Minimal: Story = {
130
- args: {
131
- priority: 'minimal',
132
- },
133
- parameters: {
134
- docs: {
135
- description: {
136
- story: 'A Button with minimal priority.',
137
- },
138
- },
139
- },
140
- };
141
-
142
- export const Negative: Story = {
143
- args: {
144
- appearance: 'negative',
145
- },
146
- parameters: {
147
- docs: {
148
- description: {
149
- story: 'A Button with negative appearance.',
150
- },
151
- },
152
- },
153
- };
154
-
155
- export const NegativeSecondary: Story = {
156
- args: {
157
- appearance: 'negative',
158
- priority: 'secondary',
159
- },
160
- parameters: {
161
- docs: {
162
- description: {
163
- story: 'A Button with negative appearance and secondary priority.',
164
- },
165
- },
166
- },
167
- };
168
-
169
- export const AsAnchor: Story = {
170
- args: {
171
- as: 'a',
172
- href: 'https://wise.com',
173
- },
174
- parameters: {
175
- docs: {
176
- description: {
177
- story: 'A Button rendered as an anchor element.',
178
- },
179
- },
180
- },
181
- };
182
-
183
- export const Disabled: Story = {
184
- args: {
185
- disabled: true,
186
- },
187
- parameters: {
188
- docs: {
189
- description: {
190
- story: 'A disabled Button.',
191
- },
192
- },
193
- },
194
- };
195
-
196
- export const Loading: Story = {
197
- args: {
198
- loading: true,
199
- },
200
- parameters: {
201
- docs: {
202
- description: {
203
- story: 'A Button in a loading state.',
204
- },
205
- },
206
- },
207
- };
208
-
209
- export const SizeSmall: Story = {
210
- args: {
211
- size: 'sm',
212
- },
213
- parameters: {
214
- docs: {
215
- description: {
216
- story: 'A small Button.',
217
- },
218
- },
219
- },
220
- };
221
-
222
- export const SizeLarge: Story = {
223
- args: {
224
- size: 'lg',
225
- },
226
- parameters: {
227
- docs: {
228
- description: {
229
- story: 'A large Button.',
230
- },
231
- },
232
- },
233
- };
234
-
235
- export const DisplayBlock: Story = {
236
- args: {
237
- block: true,
238
- },
239
- parameters: {
240
- docs: {
241
- description: {
242
- story: 'A Button that takes up the full width of its container.',
243
- },
244
- },
245
- },
246
- };
247
-
248
- export const WithIcon: Story = {
249
- args: {
250
- iconRight: ArrowRight,
251
- },
252
- parameters: {
253
- docs: {
254
- description: {
255
- story:
256
- 'A Button with an icon on the right. Can also use `iconLeft` to place the icon on the left or have both at the same time.',
257
- },
258
- },
259
- },
260
- };
261
-
262
- export const WithAvatars: Story = {
263
- args: {
264
- avatars: [{ asset: <Freeze /> }, { asset: <Freeze /> }],
265
- },
266
- parameters: {
267
- docs: {
268
- description: {
269
- story:
270
- 'A Button with avatars. Will supersed any `iconLeft` property and will always render avatars.',
271
- },
272
- },
273
- },
274
- };
275
-
276
- export const WithProfileName: Story = {
277
- args: {
278
- avatars: [{ profileName: 'John Doe' }],
279
- },
280
- parameters: {
281
- docs: {
282
- description: {
283
- story: 'A Button with a Profile name.',
284
- },
285
- },
286
- },
287
- };
288
-
289
- export const WithProfileImage: Story = {
290
- args: {
291
- avatars: [{ imgSrc: '../avatar-rectangle-fox.webp' }],
292
- },
293
- parameters: {
294
- docs: {
295
- description: {
296
- story: 'A Button with a Profile image.',
297
- },
298
- },
299
- },
300
- };
301
-
302
- export const WithAvatarAndIcon: Story = {
303
- args: {
304
- avatars: [{ asset: <Freeze /> }],
305
- iconRight: ArrowRight,
306
- },
307
- parameters: {
308
- docs: {
309
- description: {
310
- story: 'A Button with an avatar and an icon.',
311
- },
312
- },
313
- },
314
- };