@transferwise/components 0.0.0-experimental-6fa7ff3 → 0.0.0-experimental-1775875

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 (112) 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/Button.js +79 -78
  6. package/build/button/Button.js.map +1 -1
  7. package/build/button/Button.mjs +80 -79
  8. package/build/button/Button.mjs.map +1 -1
  9. package/build/criticalBanner/CriticalCommsBanner.js +2 -2
  10. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  11. package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
  12. package/build/header/Header.js +2 -2
  13. package/build/header/Header.js.map +1 -1
  14. package/build/header/Header.mjs +1 -1
  15. package/build/index.js +2 -2
  16. package/build/index.mjs +1 -1
  17. package/build/link/Link.js +3 -8
  18. package/build/link/Link.js.map +1 -1
  19. package/build/link/Link.mjs +3 -8
  20. package/build/link/Link.mjs.map +1 -1
  21. package/build/main.css +0 -258
  22. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +3 -1
  23. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  24. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +3 -1
  25. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  26. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +4 -1
  27. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  28. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +4 -1
  29. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  30. package/build/select/Select.js +3 -5
  31. package/build/select/Select.js.map +1 -1
  32. package/build/select/Select.mjs +2 -4
  33. package/build/select/Select.mjs.map +1 -1
  34. package/build/styles/avatarLayout/AvatarLayout.css +0 -11
  35. package/build/styles/button/Button.css +16 -240
  36. package/build/styles/main.css +0 -258
  37. package/build/types/avatarLayout/AvatarLayout.d.ts +2 -1
  38. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  39. package/build/types/avatarLayout/index.d.ts +0 -1
  40. package/build/types/avatarLayout/index.d.ts.map +1 -1
  41. package/build/types/button/Button.d.ts +23 -1
  42. package/build/types/button/Button.d.ts.map +1 -1
  43. package/build/types/button/index.d.ts +2 -2
  44. package/build/types/button/index.d.ts.map +1 -1
  45. package/build/types/link/Link.d.ts +2 -2
  46. package/build/types/link/Link.d.ts.map +1 -1
  47. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  48. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +1 -5
  49. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  50. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  51. package/build/types/select/Select.d.ts.map +1 -1
  52. package/build/upload/steps/completeStep/completeStep.js +2 -2
  53. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  54. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  55. package/build/upload/steps/processingStep/processingStep.js +2 -2
  56. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  57. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  58. package/build/uploadInput/UploadInput.js +3 -3
  59. package/build/uploadInput/UploadInput.js.map +1 -1
  60. package/build/uploadInput/UploadInput.mjs +1 -1
  61. package/package.json +4 -4
  62. package/src/avatarLayout/AvatarLayout.css +0 -11
  63. package/src/avatarLayout/AvatarLayout.less +1 -18
  64. package/src/avatarLayout/AvatarLayout.tsx +3 -11
  65. package/src/avatarLayout/index.ts +0 -1
  66. package/src/button/Button.css +16 -240
  67. package/src/button/Button.less +14 -208
  68. package/src/button/Button.spec.tsx +231 -54
  69. package/src/button/Button.story.tsx +137 -612
  70. package/src/button/Button.tsx +132 -88
  71. package/src/button/__snapshots__/Button.spec.tsx.snap +309 -0
  72. package/src/button/index.ts +3 -2
  73. package/src/drawer/Drawer.spec.tsx +93 -0
  74. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -1
  75. package/src/inputs/SelectInput.story.tsx +1 -1
  76. package/src/link/Link.tsx +6 -15
  77. package/src/main.css +0 -258
  78. package/src/main.less +0 -1
  79. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +7 -1
  80. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +1 -6
  81. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +3 -1
  82. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +8 -1
  83. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +5 -2
  84. package/src/select/Select.tsx +0 -1
  85. package/build/button/Button.resolver.js +0 -78
  86. package/build/button/Button.resolver.js.map +0 -1
  87. package/build/button/Button.resolver.mjs +0 -76
  88. package/build/button/Button.resolver.mjs.map +0 -1
  89. package/build/button/LegacyButton.js +0 -114
  90. package/build/button/LegacyButton.js.map +0 -1
  91. package/build/button/LegacyButton.mjs +0 -112
  92. package/build/button/LegacyButton.mjs.map +0 -1
  93. package/build/styles/button/Button.vars.css +0 -55
  94. package/build/styles/button/LegacyButton.css +0 -23
  95. package/build/types/button/Button.resolver.d.ts +0 -31
  96. package/build/types/button/Button.resolver.d.ts.map +0 -1
  97. package/build/types/button/Button.types.d.ts +0 -65
  98. package/build/types/button/Button.types.d.ts.map +0 -1
  99. package/build/types/button/LegacyButton.d.ts +0 -30
  100. package/build/types/button/LegacyButton.d.ts.map +0 -1
  101. package/src/button/Button.resolver.tsx +0 -120
  102. package/src/button/Button.types.ts +0 -86
  103. package/src/button/Button.vars.css +0 -55
  104. package/src/button/Button.vars.less +0 -69
  105. package/src/button/LegacyButton.css +0 -23
  106. package/src/button/LegacyButton.less +0 -24
  107. package/src/button/LegacyButton.spec.tsx +0 -146
  108. package/src/button/LegacyButton.story.tsx +0 -224
  109. package/src/button/LegacyButton.tsx +0 -161
  110. package/src/drawer/Drawer.rtl.spec.tsx +0 -59
  111. package/src/drawer/Drawer.spec.js +0 -101
  112. package/src/drawer/__snapshots__/Drawer.rtl.spec.tsx.snap +0 -55
@@ -1,110 +1,154 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
2
- import { forwardRef } from 'react';
3
- import { ButtonProps as NewButtonProps } from './Button.types';
4
- import { PrimitiveAnchor, PrimitiveButton } from '../primitives';
5
- import AvatarLayout from '../avatarLayout';
6
- import ProcessIndicator from '../processIndicator';
7
1
  import { clsx } from 'clsx';
8
- import { Typography } from '../common';
9
- import Body from '../body';
2
+ import { ElementType, forwardRef, MouseEvent } from 'react';
3
+ import { useIntl } from 'react-intl';
4
+
5
+ import {
6
+ Size,
7
+ ControlType,
8
+ Priority,
9
+ ControlTypeAccent,
10
+ ControlTypeNegative,
11
+ ControlTypePositive,
12
+ PriorityPrimary,
13
+ PrioritySecondary,
14
+ PriorityTertiary,
15
+ SizeExtraSmall,
16
+ SizeSmall,
17
+ SizeMedium,
18
+ SizeLarge,
19
+ } from '../common';
20
+ import ProcessIndicator from '../processIndicator';
21
+
22
+ import messages from '../i18n/commonMessages/Button.messages';
23
+ import { typeClassMap, priorityClassMap } from './classMap';
24
+ import { establishNewPriority, establishNewType, logDeprecationNotices } from './legacyUtils';
25
+
26
+ /** @deprecated */
27
+ type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
28
+
29
+ /** @deprecated */
30
+ type DeprecatedSizes = SizeExtraSmall;
31
+
32
+ type CommonProps = {
33
+ block?: boolean;
34
+ disabled?: boolean;
35
+ loading?: boolean;
36
+ type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
37
+ priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
38
+ size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
39
+ };
10
40
 
11
- const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, NewButtonProps>(
41
+ type ButtonProps = CommonProps &
42
+ Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
43
+ as?: 'button';
44
+ htmlType?: 'submit' | 'reset' | 'button';
45
+ };
46
+
47
+ type AnchorProps = CommonProps &
48
+ Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
49
+ as?: 'a';
50
+ };
51
+
52
+ export type Props = ButtonProps | AnchorProps;
53
+
54
+ export type ButtonReferenceType = HTMLButtonElement | HTMLAnchorElement;
55
+
56
+ const Button = forwardRef<ButtonReferenceType, Props>(
12
57
  (
13
58
  {
14
- as = 'button',
59
+ as: component,
60
+ block = false,
15
61
  children,
16
62
  className,
17
- size = 'lg',
18
- href,
19
- disabled = false,
20
- priority = 'primary',
21
- sentiment = 'default',
22
- iconStart: IconStart,
23
- iconEnd: IconEnd,
24
- avatars,
25
- type = 'button',
63
+ disabled,
26
64
  loading = false,
27
- block = false,
28
- ...props
29
- },
30
- ref,
65
+ priority = Priority.PRIMARY,
66
+ size = Size.MEDIUM,
67
+ type = ControlType.ACCENT,
68
+ onClick,
69
+ ...rest
70
+ }: Props,
71
+ reference,
31
72
  ) => {
32
- const classNames = clsx(
33
- 'wds-Button',
73
+ const intl = useIntl();
74
+
75
+ logDeprecationNotices({ size, type });
76
+
77
+ const newType = establishNewType(type);
78
+ const newPriority = establishNewPriority(priority, type);
79
+
80
+ const classes = clsx(
81
+ `btn btn-${size}`,
82
+ `np-btn np-btn-${size}`,
34
83
  {
35
- [`wds-Button--block`]: block,
36
- [`wds-Button--disabled`]: disabled,
37
- [`wds-Button--loading`]: loading,
84
+ 'btn-loading': loading,
85
+ 'btn-block np-btn-block': block,
86
+ disabled,
38
87
  },
39
- `wds-Button--${{ sm: 'small', md: 'medium', lg: 'large' }[size]}`,
40
- `wds-Button--${priority}`,
41
- `wds-Button--${sentiment}`,
88
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
89
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
90
+ typeClassMap[newType],
91
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
92
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
93
+ priorityClassMap[newPriority],
42
94
  className,
43
95
  );
44
96
 
45
- const contentClassNames = clsx('wds-Button-content', {
46
- [`wds-Button-content--loading`]: loading,
47
- });
97
+ function processIndicatorSize() {
98
+ return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
99
+ }
48
100
 
49
- const content = (
50
- <Body
51
- as="span"
52
- type={size === 'sm' ? Typography.BODY_DEFAULT_BOLD : Typography.BODY_LARGE_BOLD}
53
- className={contentClassNames}
54
- >
55
- {loading && (
56
- <ProcessIndicator
57
- size="xs"
58
- className="wds-Button-loader"
59
- data-testid="button-loader-indicator"
60
- />
61
- )}
62
- <span className="wds-Button-label" aria-hidden={loading}>
63
- {size === 'lg' ? (
64
- children
65
- ) : (
66
- <>
67
- {size === 'md' && avatars && (
68
- <span className="wds-Button-avatars">
69
- <AvatarLayout orientation="horizontal" avatars={avatars} size={24} />
70
- </span>
71
- )}
72
- {!avatars && IconStart && (
73
- <IconStart className="wds-Button-icon wds-Button-icon--start" />
74
- )}
75
- {children}
76
- {IconEnd && <IconEnd className="wds-Button-icon wds-Button-icon--end" />}
77
- </>
78
- )}
79
- </span>
80
- </Body>
81
- );
101
+ const Element = (component as ElementType) ?? 'button';
102
+ let props;
82
103
 
83
- if (as === 'a') {
84
- return (
85
- <PrimitiveAnchor
86
- ref={ref as React.Ref<HTMLAnchorElement>}
87
- {...(props as any)}
88
- href={href}
89
- className={classNames}
90
- disabled={disabled}
91
- >
92
- {content}
93
- </PrimitiveAnchor>
94
- );
104
+ if (Element === 'button') {
105
+ const { htmlType = 'button', ...restProps } = rest as ButtonProps;
106
+ props = {
107
+ ...restProps,
108
+ disabled,
109
+ 'aria-disabled': loading,
110
+ type: htmlType,
111
+ };
112
+ } else {
113
+ props = {
114
+ ...rest,
115
+ 'aria-disabled': loading,
116
+ } as AnchorProps;
95
117
  }
96
118
 
119
+ /**
120
+ * Ensures that the button cannot be activated in loading or disabled mode,
121
+ * when `aria-disabled` might be used over the `disabled` HTML attribute
122
+ */
123
+ const handleClick =
124
+ (handler: Props['onClick']) =>
125
+ (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {
126
+ if (disabled || loading) {
127
+ event.preventDefault();
128
+ } else if (typeof handler === 'function') {
129
+ handler(event);
130
+ }
131
+ };
132
+
97
133
  return (
98
- <PrimitiveButton
99
- ref={ref as React.Ref<HTMLButtonElement>}
100
- {...(props as any)}
101
- className={classNames}
102
- disabled={disabled}
103
- loading={loading}
104
- type={type}
134
+ <Element
135
+ ref={reference}
136
+ className={classes}
137
+ onClick={handleClick(onClick)}
138
+ {...props}
139
+ aria-live={loading ? 'polite' : 'off'}
140
+ aria-busy={loading}
141
+ aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}
105
142
  >
106
- {content}
107
- </PrimitiveButton>
143
+ {children}
144
+ {loading && (
145
+ <ProcessIndicator
146
+ size={processIndicatorSize()}
147
+ className="btn-loader"
148
+ data-testid="ButtonProgressIndicator"
149
+ />
150
+ )}
151
+ </Element>
108
152
  );
109
153
  },
110
154
  );
@@ -0,0 +1,309 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Button by default renders a medium button of type accent and priority primary 1`] = `
4
+ <div>
5
+ <button
6
+ aria-busy="false"
7
+ aria-disabled="false"
8
+ aria-live="off"
9
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
10
+ type="button"
11
+ >
12
+ Send money
13
+ </button>
14
+ </div>
15
+ `;
16
+
17
+ exports[`Button by default renders an anchor tag with button styles of type accent and priority primary 1`] = `
18
+ <div>
19
+ <a
20
+ aria-busy="false"
21
+ aria-disabled="false"
22
+ aria-live="off"
23
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
24
+ href="#"
25
+ >
26
+ Send money
27
+ </a>
28
+ </div>
29
+ `;
30
+
31
+ exports[`Button deprecated types renders danger as negative buttons with priority secondary and logs a warning 1`] = `
32
+ <div>
33
+ <button
34
+ aria-busy="false"
35
+ aria-disabled="false"
36
+ aria-live="off"
37
+ class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
38
+ type="button"
39
+ >
40
+ Send money
41
+ </button>
42
+ </div>
43
+ `;
44
+
45
+ exports[`Button deprecated types renders link as accent buttons with priority tertiary and logs a warning 1`] = `
46
+ <div>
47
+ <button
48
+ aria-busy="false"
49
+ aria-disabled="false"
50
+ aria-live="off"
51
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
52
+ type="button"
53
+ >
54
+ Send money
55
+ </button>
56
+ </div>
57
+ `;
58
+
59
+ exports[`Button deprecated types renders pay as positive buttons and logs a warning 1`] = `
60
+ <div>
61
+ <button
62
+ aria-busy="false"
63
+ aria-disabled="false"
64
+ aria-live="off"
65
+ class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
66
+ type="button"
67
+ >
68
+ Send money
69
+ </button>
70
+ </div>
71
+ `;
72
+
73
+ exports[`Button deprecated types renders primary as accent buttons and logs a warning 1`] = `
74
+ <div>
75
+ <button
76
+ aria-busy="false"
77
+ aria-disabled="false"
78
+ aria-live="off"
79
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
80
+ type="button"
81
+ >
82
+ Send money
83
+ </button>
84
+ </div>
85
+ `;
86
+
87
+ exports[`Button other states renders as block if block is true 1`] = `
88
+ <div>
89
+ <button
90
+ aria-busy="false"
91
+ aria-disabled="false"
92
+ aria-live="off"
93
+ class="btn btn-md np-btn np-btn-md btn-block np-btn-block btn-accent btn-priority-1"
94
+ type="button"
95
+ >
96
+ Send money
97
+ </button>
98
+ </div>
99
+ `;
100
+
101
+ exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 1`] = `
102
+ <div>
103
+ <button
104
+ aria-busy="false"
105
+ aria-disabled="false"
106
+ aria-live="off"
107
+ class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
108
+ type="button"
109
+ >
110
+ Send money
111
+ </button>
112
+ </div>
113
+ `;
114
+
115
+ exports[`Button priorities defaults tertiary buttons to secondary for positive buttons 2`] = `
116
+ <div>
117
+ <button
118
+ aria-busy="false"
119
+ aria-disabled="false"
120
+ aria-live="off"
121
+ class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
122
+ type="button"
123
+ >
124
+ Send money
125
+ </button>
126
+ </div>
127
+ `;
128
+
129
+ exports[`Button priorities renders primary buttons 1`] = `
130
+ <div>
131
+ <button
132
+ aria-busy="false"
133
+ aria-disabled="false"
134
+ aria-live="off"
135
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
136
+ type="button"
137
+ >
138
+ Send money
139
+ </button>
140
+ </div>
141
+ `;
142
+
143
+ exports[`Button priorities renders primary buttons 2`] = `
144
+ <div>
145
+ <button
146
+ aria-busy="false"
147
+ aria-disabled="false"
148
+ aria-live="off"
149
+ class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
150
+ type="button"
151
+ >
152
+ Send money
153
+ </button>
154
+ </div>
155
+ `;
156
+
157
+ exports[`Button priorities renders primary buttons 3`] = `
158
+ <div>
159
+ <button
160
+ aria-busy="false"
161
+ aria-disabled="false"
162
+ aria-live="off"
163
+ class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
164
+ type="button"
165
+ >
166
+ Send money
167
+ </button>
168
+ </div>
169
+ `;
170
+
171
+ exports[`Button priorities renders secondary buttons 1`] = `
172
+ <div>
173
+ <button
174
+ aria-busy="false"
175
+ aria-disabled="false"
176
+ aria-live="off"
177
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-2"
178
+ type="button"
179
+ >
180
+ Send money
181
+ </button>
182
+ </div>
183
+ `;
184
+
185
+ exports[`Button priorities renders secondary buttons 2`] = `
186
+ <div>
187
+ <button
188
+ aria-busy="false"
189
+ aria-disabled="false"
190
+ aria-live="off"
191
+ class="btn btn-md np-btn np-btn-md btn-positive btn-priority-2"
192
+ type="button"
193
+ >
194
+ Send money
195
+ </button>
196
+ </div>
197
+ `;
198
+
199
+ exports[`Button priorities renders secondary buttons 3`] = `
200
+ <div>
201
+ <button
202
+ aria-busy="false"
203
+ aria-disabled="false"
204
+ aria-live="off"
205
+ class="btn btn-md np-btn np-btn-md btn-negative btn-priority-2"
206
+ type="button"
207
+ >
208
+ Send money
209
+ </button>
210
+ </div>
211
+ `;
212
+
213
+ exports[`Button priorities renders tertiary buttons 1`] = `
214
+ <div>
215
+ <button
216
+ aria-busy="false"
217
+ aria-disabled="false"
218
+ aria-live="off"
219
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-3"
220
+ type="button"
221
+ >
222
+ Send money
223
+ </button>
224
+ </div>
225
+ `;
226
+
227
+ exports[`Button sizes renders large buttons 1`] = `
228
+ <div>
229
+ <button
230
+ aria-busy="false"
231
+ aria-disabled="false"
232
+ aria-live="off"
233
+ class="btn btn-lg np-btn np-btn-lg btn-accent btn-priority-1"
234
+ type="button"
235
+ >
236
+ Send money
237
+ </button>
238
+ </div>
239
+ `;
240
+
241
+ exports[`Button sizes renders medium buttons 1`] = `
242
+ <div>
243
+ <button
244
+ aria-busy="false"
245
+ aria-disabled="false"
246
+ aria-live="off"
247
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
248
+ type="button"
249
+ >
250
+ Send money
251
+ </button>
252
+ </div>
253
+ `;
254
+
255
+ exports[`Button sizes renders small buttons 1`] = `
256
+ <div>
257
+ <button
258
+ aria-busy="false"
259
+ aria-disabled="false"
260
+ aria-live="off"
261
+ class="btn btn-sm np-btn np-btn-sm btn-accent btn-priority-1"
262
+ type="button"
263
+ >
264
+ Send money
265
+ </button>
266
+ </div>
267
+ `;
268
+
269
+ exports[`Button types renders accent buttons 1`] = `
270
+ <div>
271
+ <button
272
+ aria-busy="false"
273
+ aria-disabled="false"
274
+ aria-live="off"
275
+ class="btn btn-md np-btn np-btn-md btn-accent btn-priority-1"
276
+ type="button"
277
+ >
278
+ Send money
279
+ </button>
280
+ </div>
281
+ `;
282
+
283
+ exports[`Button types renders negative buttons 1`] = `
284
+ <div>
285
+ <button
286
+ aria-busy="false"
287
+ aria-disabled="false"
288
+ aria-live="off"
289
+ class="btn btn-md np-btn np-btn-md btn-negative btn-priority-1"
290
+ type="button"
291
+ >
292
+ Send money
293
+ </button>
294
+ </div>
295
+ `;
296
+
297
+ exports[`Button types renders positive buttons 1`] = `
298
+ <div>
299
+ <button
300
+ aria-busy="false"
301
+ aria-disabled="false"
302
+ aria-live="off"
303
+ class="btn btn-md np-btn np-btn-md btn-positive btn-priority-1"
304
+ type="button"
305
+ >
306
+ Send money
307
+ </button>
308
+ </div>
309
+ `;
@@ -1,2 +1,3 @@
1
- export { default } from './Button.resolver';
2
- export type { ButtonProps } from './Button.resolver';
1
+ export { default } from './Button';
2
+
3
+ export type { Props as ButtonProps } from './Button';
@@ -0,0 +1,93 @@
1
+ import { render, screen, userEvent, mockMatchMedia } from '../test-utils';
2
+ import { Position } from '../common';
3
+
4
+ import Drawer from './Drawer';
5
+
6
+ jest.mock('../common/DOMOperations');
7
+ mockMatchMedia();
8
+
9
+ describe('Drawer', () => {
10
+ const renderedComponent = (props: React.ComponentProps<typeof Drawer>) =>
11
+ render(<Drawer {...props} />);
12
+
13
+ const props = {
14
+ open: true,
15
+ onClose: jest.fn(),
16
+ headerTitle: 'Drawer Title',
17
+ footerContent: <div>Footer Content</div>,
18
+ children: <p>Drawer Content</p>,
19
+ className: 'drawer-class',
20
+ };
21
+
22
+ beforeEach(() => {
23
+ jest.clearAllMocks();
24
+ });
25
+
26
+ it('renders the Drawer component', () => {
27
+ renderedComponent(props);
28
+ expect(screen.getByRole('dialog')).toBeInTheDocument();
29
+ });
30
+
31
+ it('renders the header title', () => {
32
+ renderedComponent(props);
33
+ expect(screen.getByText('Drawer Title')).toBeInTheDocument();
34
+ });
35
+
36
+ it('renders the footer content', () => {
37
+ renderedComponent(props);
38
+ expect(screen.getByText('Footer Content')).toBeInTheDocument();
39
+ });
40
+
41
+ it('renders the children content', () => {
42
+ renderedComponent(props);
43
+ expect(screen.getByText('Drawer Content')).toBeInTheDocument();
44
+ });
45
+
46
+ it('passes through the className prop', () => {
47
+ renderedComponent({ ...props, className: 'drawer-class' });
48
+ expect(screen.getByRole('dialog')).toHaveClass('drawer-class');
49
+ });
50
+
51
+ it('calls onClose when the close button is clicked', async () => {
52
+ renderedComponent(props);
53
+ await userEvent.click(screen.getByLabelText('Close'));
54
+ expect(props.onClose).toHaveBeenCalled();
55
+ });
56
+
57
+ it('calls onClose if the dimmer is clicked', async () => {
58
+ render(<Drawer {...props} />);
59
+ await userEvent.click(screen.getByRole('button'));
60
+ expect(props.onClose).toHaveBeenCalledTimes(1);
61
+ });
62
+
63
+ it('does not call onClose if the drawer content is clicked', async () => {
64
+ render(<Drawer {...props}>Drawer Content</Drawer>);
65
+ await userEvent.click(screen.getByText('Drawer Content'));
66
+ expect(props.onClose).not.toHaveBeenCalled();
67
+ });
68
+
69
+ it('does not render the Drawer when open is false', () => {
70
+ renderedComponent({ ...props, open: false });
71
+ expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
72
+ });
73
+
74
+ it('renders the Drawer with the correct aria-labelledby attribute', () => {
75
+ renderedComponent(props);
76
+ expect(screen.getByRole('dialog')).toHaveAttribute('aria-labelledby');
77
+ });
78
+
79
+ it('renders the Drawer with the correct position', () => {
80
+ renderedComponent({ ...props, position: Position.LEFT });
81
+ expect(screen.getByRole('dialog').parentElement).toHaveClass('sliding-panel--open-left');
82
+ });
83
+
84
+ it('renders the Drawer with the correct role attribute', () => {
85
+ renderedComponent(props);
86
+ expect(screen.getByRole('dialog')).toHaveAttribute('role', 'dialog');
87
+ });
88
+
89
+ it('renders the Drawer with the correct aria-modal attribute', () => {
90
+ renderedComponent(props);
91
+ expect(screen.getByRole('dialog')).toHaveAttribute('aria-modal', 'true');
92
+ });
93
+ });
@@ -12,7 +12,7 @@ exports[`FlowNavigation on mobile renders as expected 1`] = `
12
12
  aria-disabled="false"
13
13
  aria-label="back to previous step"
14
14
  aria-live="off"
15
- class="np-circle d-flex align-items-center justify-content-center np-icon-button np-icon-button-tertiary-default"
15
+ class="wds-Button np-circle d-flex align-items-center justify-content-center np-icon-button np-icon-button-tertiary-default"
16
16
  style="--circle-size: 40px; --circle-icon-size: 20px; --circle-font-size: 18px;"
17
17
  type="button"
18
18
  >
@@ -5,7 +5,7 @@ import { Flag } from '@wise/art';
5
5
  import { clsx } from 'clsx';
6
6
  import { useState } from 'react';
7
7
 
8
- import Button from '../button';
8
+ import Button from '../button/Button';
9
9
  import { getMonthNames } from '../common/dateUtils';
10
10
  import Drawer from '../drawer';
11
11
  import { Field } from '../field/Field';