@transferwise/components 0.0.0-experimental-6528439 → 0.0.0-experimental-1ffdc56

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 (189) hide show
  1. package/build/alert/Alert.js +33 -17
  2. package/build/alert/Alert.js.map +1 -1
  3. package/build/alert/Alert.mjs +30 -14
  4. package/build/alert/Alert.mjs.map +1 -1
  5. package/build/avatarLayout/AvatarLayout.js +9 -2
  6. package/build/avatarLayout/AvatarLayout.js.map +1 -1
  7. package/build/avatarLayout/AvatarLayout.mjs +9 -2
  8. package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
  9. package/build/button/Button.js +86 -79
  10. package/build/button/Button.js.map +1 -1
  11. package/build/button/Button.mjs +87 -80
  12. package/build/button/Button.mjs.map +1 -1
  13. package/build/button/Button.resolver.js +74 -0
  14. package/build/button/Button.resolver.js.map +1 -0
  15. package/build/button/Button.resolver.mjs +72 -0
  16. package/build/button/Button.resolver.mjs.map +1 -0
  17. package/build/button/LegacyButton.js +114 -0
  18. package/build/button/LegacyButton.js.map +1 -0
  19. package/build/button/LegacyButton.mjs +112 -0
  20. package/build/button/LegacyButton.mjs.map +1 -0
  21. package/build/common/action/Action.js +26 -15
  22. package/build/common/action/Action.js.map +1 -1
  23. package/build/common/action/Action.mjs +26 -15
  24. package/build/common/action/Action.mjs.map +1 -1
  25. package/build/common/propsValues/sentiment.js +1 -0
  26. package/build/common/propsValues/sentiment.js.map +1 -1
  27. package/build/common/propsValues/sentiment.mjs +1 -0
  28. package/build/common/propsValues/sentiment.mjs.map +1 -1
  29. package/build/criticalBanner/CriticalCommsBanner.js +10 -73
  30. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  31. package/build/criticalBanner/CriticalCommsBanner.mjs +11 -74
  32. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  33. package/build/dimmer/Dimmer.js +67 -41
  34. package/build/dimmer/Dimmer.js.map +1 -1
  35. package/build/dimmer/Dimmer.mjs +69 -43
  36. package/build/dimmer/Dimmer.mjs.map +1 -1
  37. package/build/header/Header.js +2 -2
  38. package/build/header/Header.js.map +1 -1
  39. package/build/header/Header.mjs +1 -1
  40. package/build/i18n/en.json +1 -0
  41. package/build/i18n/en.json.js +1 -0
  42. package/build/i18n/en.json.js.map +1 -1
  43. package/build/i18n/en.json.mjs +1 -0
  44. package/build/i18n/en.json.mjs.map +1 -1
  45. package/build/index.js +2 -2
  46. package/build/index.mjs +1 -1
  47. package/build/inputs/_BottomSheet.js +8 -1
  48. package/build/inputs/_BottomSheet.js.map +1 -1
  49. package/build/inputs/_BottomSheet.mjs +9 -2
  50. package/build/inputs/_BottomSheet.mjs.map +1 -1
  51. package/build/inputs/_Popover.js +8 -1
  52. package/build/inputs/_Popover.js.map +1 -1
  53. package/build/inputs/_Popover.mjs +9 -2
  54. package/build/inputs/_Popover.mjs.map +1 -1
  55. package/build/link/Link.js +8 -3
  56. package/build/link/Link.js.map +1 -1
  57. package/build/link/Link.mjs +8 -3
  58. package/build/link/Link.mjs.map +1 -1
  59. package/build/main.css +250 -72
  60. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js +2 -4
  61. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.js.map +1 -1
  62. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs +2 -4
  63. package/build/primitives/PrimitiveAnchor/src/PrimitiveAnchor.mjs.map +1 -1
  64. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js +3 -5
  65. package/build/primitives/PrimitiveButton/src/PrimitiveButton.js.map +1 -1
  66. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs +3 -5
  67. package/build/primitives/PrimitiveButton/src/PrimitiveButton.mjs.map +1 -1
  68. package/build/select/Select.js +2 -2
  69. package/build/select/Select.js.map +1 -1
  70. package/build/select/Select.mjs +1 -1
  71. package/build/statusIcon/StatusIcon.js +5 -1
  72. package/build/statusIcon/StatusIcon.js.map +1 -1
  73. package/build/statusIcon/StatusIcon.messages.js +3 -0
  74. package/build/statusIcon/StatusIcon.messages.js.map +1 -1
  75. package/build/statusIcon/StatusIcon.messages.mjs +3 -0
  76. package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
  77. package/build/statusIcon/StatusIcon.mjs +5 -1
  78. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  79. package/build/styles/avatarLayout/AvatarLayout.css +11 -0
  80. package/build/styles/button/Button.css +220 -15
  81. package/build/styles/button/Button.vars.css +46 -0
  82. package/build/styles/button/LegacyButton.css +23 -0
  83. package/build/styles/criticalBanner/CriticalCommsBanner.css +7 -72
  84. package/build/styles/main.css +250 -72
  85. package/build/styles/statusIcon/StatusIcon.css +4 -0
  86. package/build/types/alert/Alert.d.ts +2 -1
  87. package/build/types/alert/Alert.d.ts.map +1 -1
  88. package/build/types/avatarLayout/AvatarLayout.d.ts.map +1 -1
  89. package/build/types/button/Button.d.ts +2 -23
  90. package/build/types/button/Button.d.ts.map +1 -1
  91. package/build/types/button/Button.resolver.d.ts +35 -0
  92. package/build/types/button/Button.resolver.d.ts.map +1 -0
  93. package/build/types/button/Button.types.d.ts +70 -0
  94. package/build/types/button/Button.types.d.ts.map +1 -0
  95. package/build/types/button/LegacyButton.d.ts +44 -0
  96. package/build/types/button/LegacyButton.d.ts.map +1 -0
  97. package/build/types/button/index.d.ts +2 -2
  98. package/build/types/button/index.d.ts.map +1 -1
  99. package/build/types/common/action/Action.d.ts +4 -1
  100. package/build/types/common/action/Action.d.ts.map +1 -1
  101. package/build/types/common/propsValues/sentiment.d.ts +1 -0
  102. package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
  103. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  104. package/build/types/dimmer/Dimmer.d.ts.map +1 -1
  105. package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
  106. package/build/types/inputs/_Popover.d.ts.map +1 -1
  107. package/build/types/link/Link.d.ts +2 -2
  108. package/build/types/link/Link.d.ts.map +1 -1
  109. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.d.ts.map +1 -1
  110. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts +6 -2
  111. package/build/types/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.d.ts.map +1 -1
  112. package/build/types/primitives/PrimitiveButton/src/PrimitiveButton.d.ts.map +1 -1
  113. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  114. package/build/types/statusIcon/StatusIcon.messages.d.ts +5 -0
  115. package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
  116. package/build/types/test-utils/index.d.ts +2 -0
  117. package/build/types/test-utils/index.d.ts.map +1 -1
  118. package/build/types/test-utils/story-config.d.ts +1 -1
  119. package/build/types/test-utils/story-config.d.ts.map +1 -1
  120. package/build/types/withNextPortal/withNextPortal.d.ts.map +1 -1
  121. package/build/upload/steps/completeStep/completeStep.js +2 -2
  122. package/build/upload/steps/completeStep/completeStep.js.map +1 -1
  123. package/build/upload/steps/completeStep/completeStep.mjs +1 -1
  124. package/build/upload/steps/processingStep/processingStep.js +2 -2
  125. package/build/upload/steps/processingStep/processingStep.js.map +1 -1
  126. package/build/upload/steps/processingStep/processingStep.mjs +1 -1
  127. package/build/uploadInput/UploadInput.js +3 -3
  128. package/build/uploadInput/UploadInput.js.map +1 -1
  129. package/build/uploadInput/UploadInput.mjs +1 -1
  130. package/build/withNextPortal/withNextPortal.js +2 -5
  131. package/build/withNextPortal/withNextPortal.js.map +1 -1
  132. package/build/withNextPortal/withNextPortal.mjs +2 -5
  133. package/build/withNextPortal/withNextPortal.mjs.map +1 -1
  134. package/package.json +5 -5
  135. package/src/alert/Alert.story.tsx +36 -0
  136. package/src/alert/Alert.tests.story.tsx +1 -1
  137. package/src/alert/Alert.tsx +37 -8
  138. package/src/avatarLayout/AvatarLayout.css +11 -0
  139. package/src/avatarLayout/AvatarLayout.less +18 -1
  140. package/src/avatarLayout/AvatarLayout.tsx +10 -2
  141. package/src/button/Button.accessibility.docs.mdx +103 -0
  142. package/src/button/Button.css +220 -15
  143. package/src/button/Button.less +228 -13
  144. package/src/button/Button.resolver.tsx +73 -0
  145. package/src/button/Button.spec.tsx +215 -226
  146. package/src/button/Button.story.tsx +761 -134
  147. package/src/button/Button.tests.story.tsx +27 -0
  148. package/src/button/Button.tsx +99 -132
  149. package/src/button/Button.types.ts +92 -0
  150. package/src/button/Button.vars.css +46 -0
  151. package/src/button/Button.vars.less +57 -0
  152. package/src/button/LegacyButton.css +23 -0
  153. package/src/button/LegacyButton.less +24 -0
  154. package/src/button/LegacyButton.spec.tsx +147 -0
  155. package/src/button/LegacyButton.story.tsx +228 -0
  156. package/src/button/LegacyButton.tsx +177 -0
  157. package/src/button/index.ts +2 -3
  158. package/src/common/action/Action.tsx +39 -21
  159. package/src/common/bottomSheet/BottomSheet.spec.tsx +3 -6
  160. package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +1 -5
  161. package/src/common/propsValues/sentiment.ts +1 -0
  162. package/src/criticalBanner/CriticalCommsBanner.css +7 -72
  163. package/src/criticalBanner/CriticalCommsBanner.less +12 -73
  164. package/src/criticalBanner/CriticalCommsBanner.story.tsx +13 -9
  165. package/src/criticalBanner/CriticalCommsBanner.tsx +8 -50
  166. package/src/dimmer/Dimmer.tsx +72 -44
  167. package/src/field/Field.story.tsx +1 -1
  168. package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +1 -2
  169. package/src/i18n/en.json +1 -0
  170. package/src/inputs/SelectInput.story.tsx +1 -1
  171. package/src/inputs/_BottomSheet.tsx +9 -3
  172. package/src/inputs/_Popover.tsx +10 -4
  173. package/src/label/Label.story.tsx +1 -1
  174. package/src/link/Link.tsx +15 -6
  175. package/src/main.css +250 -72
  176. package/src/main.less +1 -0
  177. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.tsx +2 -8
  178. package/src/primitives/PrimitiveAnchor/src/PrimitiveAnchor.types.ts +7 -2
  179. package/src/primitives/PrimitiveAnchor/test/PrimitiveAnchor.spec.tsx +1 -3
  180. package/src/primitives/PrimitiveButton/src/PrimitiveButton.tsx +4 -12
  181. package/src/primitives/PrimitiveButton/test/PrimitiveButton.spec.tsx +16 -13
  182. package/src/statusIcon/StatusIcon.css +4 -0
  183. package/src/statusIcon/StatusIcon.less +4 -0
  184. package/src/statusIcon/StatusIcon.messages.ts +6 -0
  185. package/src/statusIcon/StatusIcon.tsx +8 -1
  186. package/src/test-utils/Parameters.d.ts +9 -1
  187. package/src/test-utils/story-config.ts +10 -1
  188. package/src/withNextPortal/withNextPortal.tsx +1 -10
  189. package/src/button/__snapshots__/Button.spec.tsx.snap +0 -309
@@ -0,0 +1,228 @@
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
+ import LegacyButton from './LegacyButton';
7
+
8
+ // needed for the SB to show correct name in the Source blocks
9
+ LegacyButton.displayName = 'Button';
10
+
11
+ const withContainer = (Story: any) => (
12
+ <div
13
+ style={{
14
+ display: 'flex',
15
+ flexDirection: 'initial',
16
+ justifyContent: 'center',
17
+ flexFlow: 'column',
18
+ alignItems: 'center',
19
+ }}
20
+ >
21
+ <Story />
22
+ </div>
23
+ );
24
+
25
+ const meta: Meta<typeof LegacyButton> = {
26
+ component: LegacyButton,
27
+ title: 'Actions/Button/Legacy Button',
28
+ args: {
29
+ size: undefined,
30
+ priority: undefined,
31
+ type: undefined,
32
+ block: false,
33
+ disabled: false,
34
+ loading: false,
35
+ href: undefined,
36
+ as: undefined,
37
+ target: undefined,
38
+ htmlType: undefined,
39
+ children: 'Button text',
40
+ onClick: fn(),
41
+ onBlur: fn(),
42
+ onFocus: fn(),
43
+ },
44
+ argTypes: {
45
+ href: {
46
+ control: 'text',
47
+ description: 'If set together with `as="a"`, the component will render as an HTML anchor.',
48
+ },
49
+ as: {
50
+ control: {
51
+ name: 'enum',
52
+ options: ['button', 'a'],
53
+ },
54
+ description: 'If set together with `href`, the component will render as an HTML anchor.',
55
+ },
56
+ type: {
57
+ type: {
58
+ name: 'enum',
59
+ value: ['accent', 'positive', 'negative'],
60
+ },
61
+ description:
62
+ '**NB**: `primary` | `pay` | `secondary` | `danger` | `link` are deprecated.\n\n',
63
+ },
64
+ size: {
65
+ type: {
66
+ name: 'enum',
67
+ value: ['lg', 'md', 'sm', 'xs'],
68
+ },
69
+ description: '**NB**: `xs` is deprecated.\n\n',
70
+ },
71
+ priority: {
72
+ type: {
73
+ name: 'enum',
74
+ value: ['primary', 'secondary', 'tertiary'],
75
+ },
76
+ },
77
+ block: {
78
+ table: {
79
+ defaultValue: { summary: 'false' },
80
+ },
81
+ },
82
+ v2: {
83
+ table: {
84
+ disable: true,
85
+ },
86
+ },
87
+ },
88
+ tags: ['autodocs'],
89
+ decorators: [withContainer],
90
+ };
91
+
92
+ export default meta;
93
+
94
+ type Story = StoryObj<typeof Button>;
95
+
96
+ export const Basic: Story = {};
97
+
98
+ export const Secondary: Story = {
99
+ args: {
100
+ type: 'accent',
101
+ priority: 'secondary',
102
+ },
103
+ };
104
+
105
+ export const Tertiary: Story = {
106
+ args: {
107
+ type: 'accent',
108
+ priority: 'tertiary',
109
+ },
110
+ };
111
+
112
+ export const Negative: Story = {
113
+ args: {
114
+ type: 'negative',
115
+ priority: 'primary',
116
+ },
117
+ };
118
+
119
+ export const Loading: Story = {
120
+ args: {
121
+ loading: true,
122
+ },
123
+ };
124
+
125
+ export const Variants: Story = {
126
+ render: () => {
127
+ return (
128
+ <div className="d-flex flex-column p-b-2 align-items-start">
129
+ <div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
130
+ <Button type="accent" priority="primary">
131
+ Primary Accent
132
+ </Button>
133
+ <Button type="accent" priority="secondary">
134
+ Secondary Accent
135
+ </Button>
136
+ <Button type="accent" priority="tertiary">
137
+ Tertiary Accent
138
+ </Button>
139
+ </div>
140
+ <div className="d-flex flex-row p-b-2" style={{ gap: 'var(--size-16)' }}>
141
+ <Button type="positive" priority="primary">
142
+ Primary Positive
143
+ </Button>
144
+ <Button type="positive" priority="secondary">
145
+ Secondary Accent
146
+ </Button>
147
+ </div>
148
+ <div className="d-flex flex-row flex- p-b-2" style={{ gap: 'var(--size-16)' }}>
149
+ <Button type="negative" priority="primary">
150
+ Primary Negative
151
+ </Button>
152
+ <Button type="negative" priority="secondary">
153
+ Secondary Negative
154
+ </Button>
155
+ </div>
156
+ <div className="d-flex flex-row p-b-1" style={{ gap: 'var(--size-16)' }}>
157
+ <Button type="accent" priority="primary" disabled>
158
+ Button Disabled
159
+ </Button>
160
+ <Button type="accent" priority="secondary" disabled>
161
+ Button Disabled
162
+ </Button>
163
+ <Button type="accent" priority="tertiary" disabled>
164
+ Button Disabled
165
+ </Button>
166
+ </div>
167
+ </div>
168
+ );
169
+ },
170
+ };
171
+
172
+ const wait = async (duration = 500) =>
173
+ new Promise<void>((resolve) => {
174
+ setTimeout(resolve, duration);
175
+ });
176
+
177
+ export const Focused: Story = {
178
+ play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
179
+ const canvas = within(canvasElement);
180
+ const button = canvas.getByRole('button');
181
+ await userEvent.tab();
182
+ await expect(button).toHaveFocus();
183
+ await expect(button).toHaveTextContent('Focused!');
184
+ },
185
+ render: function Render(args: React.ComponentProps<typeof Button>) {
186
+ const [focused, setFocused] = useState(false);
187
+
188
+ return (
189
+ <Button {...args} onFocus={() => setFocused(true)}>
190
+ {focused ? 'Focused!' : 'Button text'}
191
+ </Button>
192
+ );
193
+ },
194
+ };
195
+
196
+ export const SocialMedia: Story = {
197
+ render: () => {
198
+ return (
199
+ <>
200
+ <div className="m-b-2">
201
+ <button type="button" className="btn btn-google">
202
+ Login with Google
203
+ </button>
204
+ </div>
205
+ <div className="m-b-2">
206
+ <button type="button" className="btn btn-facebook">
207
+ Login with Facebook
208
+ </button>
209
+ </div>
210
+ <div className="m-b-2">
211
+ <button type="button" className="btn btn-lg btn-facebook">
212
+ Large Button
213
+ </button>
214
+ </div>
215
+ <div className="m-b-2">
216
+ <button type="button" className="btn btn-block btn-facebook">
217
+ Block Button
218
+ </button>
219
+ </div>
220
+ <div className="m-b-2">
221
+ <button type="button" className="btn btn-lg btn-block btn-facebook">
222
+ Large Block Button
223
+ </button>
224
+ </div>
225
+ </>
226
+ );
227
+ },
228
+ };
@@ -0,0 +1,177 @@
1
+ import { clsx } from 'clsx';
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
+ import { ButtonReferenceType } from './Button.types';
26
+
27
+ /** @deprecated */
28
+ type DeprecatedTypes = 'primary' | 'pay' | 'secondary' | 'danger' | 'link';
29
+
30
+ /** @deprecated */
31
+ type DeprecatedSizes = SizeExtraSmall;
32
+
33
+ type CommonProps = {
34
+ v2?: false;
35
+
36
+ /** Makes the button take up the full width of its container */
37
+ block?: boolean;
38
+
39
+ /**
40
+ * The `target` attribute for HTML anchor.
41
+ * If set to `_blank`, `rel="noopener noreferrer"` is automatically added to the rendered node.
42
+ */
43
+ target?: string;
44
+ /**
45
+ * Toggles the disabled state
46
+ * @default false
47
+ */
48
+
49
+ disabled?: boolean;
50
+ /**
51
+ * Toggles the loading state
52
+ * @default false
53
+ */
54
+ loading?: boolean;
55
+ type?: ControlTypeAccent | ControlTypeNegative | ControlTypePositive | DeprecatedTypes | null;
56
+ priority?: PriorityPrimary | PrioritySecondary | PriorityTertiary | null;
57
+ size?: SizeSmall | SizeMedium | SizeLarge | DeprecatedSizes;
58
+ htmlType?: 'submit' | 'reset' | 'button';
59
+ };
60
+
61
+ type ButtonProps = CommonProps &
62
+ Omit<React.ComponentPropsWithRef<'button'>, 'type'> & {
63
+ as?: 'button';
64
+ };
65
+
66
+ type AnchorProps = CommonProps &
67
+ Omit<React.ComponentPropsWithRef<'a'>, 'type'> & {
68
+ as?: 'a';
69
+ href?: string;
70
+ };
71
+
72
+ export type LegacyButtonProps = ButtonProps | AnchorProps;
73
+
74
+ /**
75
+ * @deprecated make sure you use new Button component via `<Button v2 .. />` and new props
76
+ */
77
+ const LegacyButton = forwardRef<ButtonReferenceType, LegacyButtonProps>(
78
+ (
79
+ {
80
+ as: component = 'button',
81
+ block = false,
82
+ children,
83
+ className,
84
+ disabled,
85
+ loading = false,
86
+ priority = Priority.PRIMARY,
87
+ size = Size.MEDIUM,
88
+ type = ControlType.ACCENT,
89
+ onClick,
90
+ ...rest
91
+ }: LegacyButtonProps,
92
+ ref,
93
+ ) => {
94
+ const intl = useIntl();
95
+
96
+ logDeprecationNotices({ size, type });
97
+
98
+ const newType = establishNewType(type);
99
+ const newPriority = establishNewPriority(priority, type);
100
+
101
+ const classes = clsx(
102
+ `btn btn-${size}`,
103
+ `np-btn np-btn-${size}`,
104
+ {
105
+ 'btn-loading': loading,
106
+ 'btn-block np-btn-block': block,
107
+ disabled,
108
+ },
109
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
110
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
111
+ typeClassMap[newType],
112
+ // @ts-expect-error fix when refactor `typeClassMap` to TypeScript
113
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
114
+ priorityClassMap[newPriority],
115
+ className,
116
+ );
117
+
118
+ function processIndicatorSize() {
119
+ return ['sm', 'xs'].includes(size) ? 'xxs' : 'xs';
120
+ }
121
+
122
+ const Element = (component as ElementType) ?? 'button';
123
+ let props;
124
+
125
+ if (Element === 'button') {
126
+ const { htmlType = 'button', ...restProps } = rest as ButtonProps;
127
+ props = {
128
+ ...restProps,
129
+ disabled,
130
+ 'aria-disabled': loading,
131
+ type: htmlType,
132
+ };
133
+ } else {
134
+ props = {
135
+ ...rest,
136
+ 'aria-disabled': loading,
137
+ } as AnchorProps;
138
+ }
139
+
140
+ /**
141
+ * Ensures that the button cannot be activated in loading or disabled mode,
142
+ * when `aria-disabled` might be used over the `disabled` HTML attribute
143
+ */
144
+ const handleClick =
145
+ (handler: LegacyButtonProps['onClick']) =>
146
+ (event: MouseEvent<HTMLButtonElement> & MouseEvent<HTMLAnchorElement>) => {
147
+ if (disabled || loading) {
148
+ event.preventDefault();
149
+ } else if (typeof handler === 'function') {
150
+ handler(event);
151
+ }
152
+ };
153
+
154
+ return (
155
+ <Element
156
+ ref={ref as React.Ref<ButtonReferenceType>}
157
+ className={classes}
158
+ onClick={handleClick(onClick)}
159
+ {...props}
160
+ aria-live={loading ? 'polite' : 'off'}
161
+ aria-busy={loading}
162
+ aria-label={loading ? intl.formatMessage(messages.loadingAriaLabel) : rest['aria-label']}
163
+ >
164
+ {children}
165
+ {loading && (
166
+ <ProcessIndicator
167
+ size={processIndicatorSize()}
168
+ className="btn-loader"
169
+ data-testid="ButtonProgressIndicator"
170
+ />
171
+ )}
172
+ </Element>
173
+ );
174
+ },
175
+ );
176
+
177
+ export default LegacyButton;
@@ -1,3 +1,2 @@
1
- export { default } from './Button';
2
-
3
- export type { Props as ButtonProps } from './Button';
1
+ export { default } from './Button.resolver';
2
+ export type { ButtonProps } from './Button.resolver';
@@ -1,8 +1,9 @@
1
1
  import { clsx } from 'clsx';
2
2
  import Link from '../../link';
3
3
  import { Typography } from '../propsValues/typography';
4
- import ActionButton from '../../actionButton';
5
4
  import { Priority } from '../propsValues/control';
5
+ import Button from '../../button';
6
+ import { ButtonPriority, ButtonSentiment } from '../../button/Button.types';
6
7
 
7
8
  export type ActionOptions = {
8
9
  'aria-label'?: string;
@@ -14,11 +15,19 @@ export type ActionOptions = {
14
15
 
15
16
  type Props = {
16
17
  variant?: 'button' | 'action-button';
18
+ sentiment?: ButtonSentiment;
17
19
  action: ActionOptions;
18
20
  className?: string;
21
+ priority?: ButtonPriority;
19
22
  };
20
23
 
21
- export function Action({ action, className, variant = 'button' }: Props) {
24
+ export function Action({
25
+ action,
26
+ className,
27
+ variant = 'button',
28
+ priority = Priority.SECONDARY,
29
+ sentiment = 'default',
30
+ }: Props) {
22
31
  if ('href' in action) {
23
32
  return (
24
33
  <Link
@@ -34,23 +43,32 @@ export function Action({ action, className, variant = 'button' }: Props) {
34
43
  );
35
44
  }
36
45
 
37
- return variant === 'button' ? (
38
- <button
39
- type="button"
40
- aria-label={action['aria-label']}
41
- className={clsx('btn-unstyled np-text-link-large', className)}
42
- onClick={action.onClick}
43
- >
44
- {action.text}
45
- </button>
46
- ) : (
47
- <ActionButton
48
- aria-label={action['aria-label']}
49
- priority={Priority.SECONDARY}
50
- className={clsx(className)}
51
- onClick={action.onClick}
52
- >
53
- {action.text}
54
- </ActionButton>
55
- );
46
+ switch (variant) {
47
+ case 'action-button':
48
+ return (
49
+ <Button
50
+ v2
51
+ size="sm"
52
+ sentiment={sentiment}
53
+ aria-label={action['aria-label']}
54
+ priority={priority}
55
+ className={clsx(className)}
56
+ onClick={action.onClick}
57
+ >
58
+ {action.text}
59
+ </Button>
60
+ );
61
+ case 'button':
62
+ default:
63
+ return (
64
+ <button
65
+ type="button"
66
+ aria-label={action['aria-label']}
67
+ className={clsx('btn-unstyled np-text-link-large', className)}
68
+ onClick={action.onClick}
69
+ >
70
+ {action.text}
71
+ </button>
72
+ );
73
+ }
56
74
  }
@@ -1,4 +1,3 @@
1
- import { ThemeProvider } from '@wise/components-theming';
2
1
  import { render, mockMatchMedia } from '../../test-utils';
3
2
 
4
3
  import BottomSheet from './BottomSheet';
@@ -9,11 +8,9 @@ mockMatchMedia();
9
8
  describe('BottomSheet', () => {
10
9
  it('renders content when open', () => {
11
10
  const { baseElement } = render(
12
- <ThemeProvider theme="personal" screenMode="light">
13
- <BottomSheet open onClose={jest.fn()}>
14
- <b>Test Content</b>
15
- </BottomSheet>
16
- </ThemeProvider>,
11
+ <BottomSheet open onClose={jest.fn()}>
12
+ <b>Test Content</b>
13
+ </BottomSheet>,
17
14
  );
18
15
  expect(baseElement).toMatchSnapshot();
19
16
  });
@@ -2,11 +2,7 @@
2
2
 
3
3
  exports[`BottomSheet renders content when open 1`] = `
4
4
  <body>
5
- <div>
6
- <div
7
- class="np-theme-personal"
8
- />
9
- </div>
5
+ <div />
10
6
  <div
11
7
  class="np-theme-personal"
12
8
  >
@@ -4,6 +4,7 @@ export enum Sentiment {
4
4
  POSITIVE = 'positive',
5
5
  WARNING = 'warning',
6
6
  PENDING = 'pending',
7
+ CRITICAL = 'critical',
7
8
 
8
9
  /**
9
10
  * @deprecated
@@ -1,76 +1,11 @@
1
- div.critical-comms {
2
- --critical-comms-background-color: var(--color-background-negative);
3
- --critical-comms-title-color: var(--color-content-negative);
4
- --critical-comms-subtitle-color: var(--color-content-secondary);
5
- --critical-comms-subtitle-color-padding-left: var(--size-16);
6
- --critical-comms-vertical-spacing: var(--size-8);
7
- background-color: rgba(255,135,135,0.10196);
8
- background-color: var(--critical-comms-background-color);
9
- display: flex;
10
- justify-content: center;
11
- align-items: center;
12
- }
13
- .np-theme-personal div.critical-comms,
14
- .np-theme-personal--dark div.critical-comms {
15
- --critical-comms-background-color: var(--color-sentiment-negative);
16
- --critical-comms-title-color: var(--color-contrast);
17
- --critical-comms-subtitle-color: var(--color-contrast);
18
- --critical-comms-subtitle-color-padding-left: 0;
19
- --critical-comms-vertical-spacing: var(--size-16);
20
- padding: 24px;
21
- padding: var(--padding-medium);
22
- }
23
- .np-theme-personal div.critical-comms .tw-icon-alert-circle-fill,
24
- .np-theme-personal--dark div.critical-comms .tw-icon-alert-circle-fill {
25
- color: var(--color-contrast);
26
- }
27
- .np-theme-personal div.critical-comms .tw-icon-alert-circle-fill svg,
28
- .np-theme-personal--dark div.critical-comms .tw-icon-alert-circle-fill svg {
29
- width: 48px;
30
- height: 48px;
31
- }
32
- .np-theme-personal div.critical-comms .cta-btn,
33
- .np-theme-personal--dark div.critical-comms .cta-btn {
34
- background-color: var(--color-contrast);
35
- }
36
- .np-theme-personal div.critical-comms .cta-btn:not(.disabled):not(:disabled):focus,
37
- .np-theme-personal--dark div.critical-comms .cta-btn:not(.disabled):not(:disabled):focus {
38
- outline-color: var(--color-contrast);
1
+ .np-theme-personal .critical-comms .alert-critical {
2
+ color: var(--color-contrast-overlay);
3
+ background-color: var(--color-sentiment-negative) !important;
39
4
  }
40
- @media (max-width: 767px) {
41
- div.critical-comms {
42
- display: inline;
43
- display: initial;
44
- }
5
+ .np-theme-personal .critical-comms .alert-critical .np-text-title-body {
6
+ color: var(--color-contrast-overlay);
45
7
  }
46
- div.critical-comms .critical-comms--title {
47
- color: var(--critical-comms-title-color);
48
- }
49
- div.critical-comms .critical-comms--subtitle {
50
- color: var(--critical-comms-subtitle-color);
51
- }
52
- div.critical-comms .critical-comms--cta {
53
- padding-left: 0;
54
- }
55
- @media (max-width: 767px) {
56
- div.critical-comms .critical-comms--cta {
57
- padding-left: var(--critical-comms-subtitle-color-padding-left);
58
- padding-top: var(--critical-comms-vertical-spacing);
59
- min-width: 100%;
60
- }
61
- }
62
- div.critical-comms .critical-comms-body {
8
+ .np-theme-personal .critical-comms .action__desktop {
63
9
  display: flex;
64
- width: 100%;
65
- }
66
- @media (max-width: 767px) {
67
- div.critical-comms .critical-comms-body {
68
- flex-direction: column;
69
- }
70
- }
71
- @media (max-width: 767px) {
72
- div.critical-comms .critical-comms-content {
73
- padding-top: var(--critical-comms-vertical-spacing);
74
- flex-wrap: wrap;
75
- }
10
+ align-items: center;
76
11
  }