@transferwise/components 46.125.0 → 46.127.1

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 (197) hide show
  1. package/build/avatarView/AvatarView.js.map +1 -1
  2. package/build/avatarView/AvatarView.mjs.map +1 -1
  3. package/build/common/locale/index.js +13 -0
  4. package/build/common/locale/index.js.map +1 -1
  5. package/build/common/locale/index.mjs +13 -1
  6. package/build/common/locale/index.mjs.map +1 -1
  7. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +31 -1
  8. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
  9. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +32 -2
  10. package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
  11. package/build/field/Field.js +1 -0
  12. package/build/field/Field.js.map +1 -1
  13. package/build/field/Field.mjs +1 -0
  14. package/build/field/Field.mjs.map +1 -1
  15. package/build/index.js +3 -0
  16. package/build/index.js.map +1 -1
  17. package/build/index.mjs +2 -1
  18. package/build/index.mjs.map +1 -1
  19. package/build/inputs/Input.js.map +1 -1
  20. package/build/inputs/Input.mjs.map +1 -1
  21. package/build/inputs/SearchInput.js.map +1 -1
  22. package/build/inputs/SearchInput.mjs.map +1 -1
  23. package/build/inputs/SelectInput.js.map +1 -1
  24. package/build/inputs/SelectInput.mjs.map +1 -1
  25. package/build/inputs/TextArea.js.map +1 -1
  26. package/build/inputs/TextArea.mjs.map +1 -1
  27. package/build/listItem/ListItem.js +2 -2
  28. package/build/listItem/ListItem.js.map +1 -1
  29. package/build/listItem/ListItem.mjs +2 -2
  30. package/build/listItem/ListItem.mjs.map +1 -1
  31. package/build/listItem/Prompt/ListItemPrompt.js +6 -4
  32. package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
  33. package/build/listItem/Prompt/ListItemPrompt.mjs +7 -2
  34. package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
  35. package/build/main.css +52 -21
  36. package/build/moneyInput/MoneyInput.js +6 -1
  37. package/build/moneyInput/MoneyInput.js.map +1 -1
  38. package/build/moneyInput/MoneyInput.mjs +6 -1
  39. package/build/moneyInput/MoneyInput.mjs.map +1 -1
  40. package/build/prompt/ActionPrompt/ActionPrompt.js +27 -4
  41. package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
  42. package/build/prompt/ActionPrompt/ActionPrompt.mjs +27 -4
  43. package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
  44. package/build/prompt/InfoPrompt/InfoPrompt.js +113 -0
  45. package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -0
  46. package/build/prompt/InfoPrompt/InfoPrompt.mjs +111 -0
  47. package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -0
  48. package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
  49. package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
  50. package/build/radioOption/RadioOption.js.map +1 -1
  51. package/build/radioOption/RadioOption.mjs.map +1 -1
  52. package/build/slidingPanel/SlidingPanel.js.map +1 -1
  53. package/build/slidingPanel/SlidingPanel.mjs.map +1 -1
  54. package/build/statusIcon/StatusIcon.js +2 -0
  55. package/build/statusIcon/StatusIcon.js.map +1 -1
  56. package/build/statusIcon/StatusIcon.mjs +2 -0
  57. package/build/statusIcon/StatusIcon.mjs.map +1 -1
  58. package/build/styles/main.css +52 -21
  59. package/build/styles/prompt/InfoPrompt/InfoPrompt.css +31 -0
  60. package/build/styles/sentimentSurface/SentimentSurface.css +21 -21
  61. package/build/table/TableCell.js.map +1 -1
  62. package/build/table/TableCell.mjs.map +1 -1
  63. package/build/typeahead/Typeahead.js +1 -0
  64. package/build/typeahead/Typeahead.js.map +1 -1
  65. package/build/typeahead/Typeahead.mjs +1 -0
  66. package/build/typeahead/Typeahead.mjs.map +1 -1
  67. package/build/types/avatarView/AvatarView.d.ts +1 -1
  68. package/build/types/avatarView/AvatarView.d.ts.map +1 -1
  69. package/build/types/common/locale/index.d.ts +8 -0
  70. package/build/types/common/locale/index.d.ts.map +1 -1
  71. package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts.map +1 -1
  72. package/build/types/index.d.ts +3 -2
  73. package/build/types/index.d.ts.map +1 -1
  74. package/build/types/inputs/Input.d.ts.map +1 -1
  75. package/build/types/inputs/SearchInput.d.ts.map +1 -1
  76. package/build/types/inputs/SelectInput.d.ts +1 -1
  77. package/build/types/inputs/SelectInput.d.ts.map +1 -1
  78. package/build/types/inputs/TextArea.d.ts.map +1 -1
  79. package/build/types/listItem/ListItem.d.ts +1 -1
  80. package/build/types/listItem/Prompt/ListItemPrompt.d.ts +2 -3
  81. package/build/types/listItem/Prompt/ListItemPrompt.d.ts.map +1 -1
  82. package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
  83. package/build/types/primitives/PrimitiveAnchor/PrimitiveAnchor.types.d.ts.map +1 -1
  84. package/build/types/primitives/PrimitiveButton/PrimitiveButton.types.d.ts.map +1 -1
  85. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +4 -2
  86. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
  87. package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts +56 -0
  88. package/build/types/prompt/InfoPrompt/InfoPrompt.d.ts.map +1 -0
  89. package/build/types/prompt/InfoPrompt/index.d.ts +3 -0
  90. package/build/types/prompt/InfoPrompt/index.d.ts.map +1 -0
  91. package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +5 -5
  92. package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
  93. package/build/types/prompt/index.d.ts +2 -0
  94. package/build/types/prompt/index.d.ts.map +1 -1
  95. package/build/types/radioOption/RadioOption.d.ts.map +1 -1
  96. package/build/types/slidingPanel/SlidingPanel.d.ts.map +1 -1
  97. package/build/types/statusIcon/StatusIcon.d.ts +2 -1
  98. package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
  99. package/build/types/table/TableCell.d.ts.map +1 -1
  100. package/build/types/withDisplayFormat/WithDisplayFormat.d.ts.map +1 -1
  101. package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
  102. package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
  103. package/package.json +3 -3
  104. package/src/accordion/Accordion.test.js +0 -6
  105. package/src/accordion/AccordionItem/AccordionItem.test.js +0 -10
  106. package/src/actionButton/ActionButton.test.tsx +0 -4
  107. package/src/avatarLayout/AvatarLayout.story.tsx +3 -3
  108. package/src/avatarView/AvatarView.story.tsx +29 -24
  109. package/src/avatarView/AvatarView.tsx +1 -1
  110. package/src/avatarWrapper/AvatarWrapper.test.tsx +0 -53
  111. package/src/checkbox/Checkbox.test.tsx +0 -5
  112. package/src/chevron/Chevron.test.tsx +0 -7
  113. package/src/chips/Chips.test.tsx +0 -8
  114. package/src/common/RadioButton/RadioButton.test.tsx +0 -18
  115. package/src/common/bottomSheet/BottomSheet.test.story.tsx +98 -0
  116. package/src/common/bottomSheet/BottomSheet.test.tsx +0 -9
  117. package/src/common/card/Card.test.tsx +0 -6
  118. package/src/common/closeButton/CloseButton.test.tsx +0 -4
  119. package/src/common/locale/index.test.ts +36 -1
  120. package/src/common/locale/index.ts +13 -0
  121. package/src/common/panel/Panel.test.tsx +0 -6
  122. package/src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx +5 -1
  123. package/src/flowNavigation/FlowNavigation.test.js +0 -10
  124. package/src/index.ts +3 -1
  125. package/src/inputs/Input.tsx +8 -9
  126. package/src/inputs/SearchInput.tsx +8 -9
  127. package/src/inputs/SelectInput.test.story.tsx +86 -0
  128. package/src/inputs/SelectInput.tsx +1 -1
  129. package/src/inputs/TextArea.tsx +6 -7
  130. package/src/listItem/ListItem.tsx +2 -2
  131. package/src/listItem/Prompt/ListItemPrompt.story.tsx +71 -9
  132. package/src/listItem/Prompt/ListItemPrompt.test.tsx +31 -0
  133. package/src/listItem/Prompt/ListItemPrompt.tsx +8 -2
  134. package/src/logo/Logo.story.tsx +24 -5
  135. package/src/main.css +52 -21
  136. package/src/main.less +2 -1
  137. package/src/moneyInput/MoneyInput.test.story.tsx +104 -0
  138. package/src/moneyInput/MoneyInput.tsx +20 -2
  139. package/src/overlayHeader/OverlayHeader.test.tsx +0 -3
  140. package/src/popover/Popover.test.tsx +0 -25
  141. package/src/primitives/PrimitiveAnchor/PrimitiveAnchor.types.ts +1 -3
  142. package/src/primitives/PrimitiveButton/PrimitiveButton.types.ts +1 -3
  143. package/src/promoCard/PromoCard.test.tsx +0 -6
  144. package/src/promoCard/PromoCardGroup.test.tsx +0 -5
  145. package/src/prompt/ActionPrompt/ActionPrompt.accessibility.docs.mdx +65 -0
  146. package/src/prompt/ActionPrompt/ActionPrompt.less +1 -1
  147. package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +4 -1
  148. package/src/prompt/ActionPrompt/ActionPrompt.test.story.tsx +147 -0
  149. package/src/prompt/ActionPrompt/ActionPrompt.test.tsx +2 -7
  150. package/src/prompt/ActionPrompt/ActionPrompt.tsx +48 -7
  151. package/src/prompt/InfoPrompt/InfoPrompt.css +31 -0
  152. package/src/prompt/InfoPrompt/InfoPrompt.less +37 -0
  153. package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +312 -0
  154. package/src/prompt/InfoPrompt/InfoPrompt.test.story.tsx +246 -0
  155. package/src/prompt/InfoPrompt/InfoPrompt.test.tsx +224 -0
  156. package/src/prompt/InfoPrompt/InfoPrompt.tsx +148 -0
  157. package/src/prompt/InfoPrompt/index.ts +2 -0
  158. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +13 -10
  159. package/src/prompt/InlinePrompt/InlinePrompt.test.tsx +13 -1
  160. package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +1 -1
  161. package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +5 -5
  162. package/src/prompt/index.ts +5 -0
  163. package/src/radioOption/RadioOption.tsx +2 -1
  164. package/src/sentimentSurface/SentimentSurface.css +21 -21
  165. package/src/sentimentSurface/SentimentSurface.less +13 -13
  166. package/src/sentimentSurface/SentimentSurface.story.tsx +1 -1
  167. package/src/sentimentSurface/SentimentSurface.test.story.tsx +48 -1
  168. package/src/slidingPanel/SlidingPanel.tsx +4 -2
  169. package/src/ssr.test.tsx +2 -0
  170. package/src/statusIcon/StatusIcon.tsx +8 -1
  171. package/src/table/TableCell.tsx +1 -3
  172. package/src/tile/Tile.test.tsx +0 -10
  173. package/src/tooltip/Tooltip.test.tsx +0 -10
  174. package/src/withDisplayFormat/WithDisplayFormat.tsx +13 -14
  175. package/src/accordion/AccordionItem/__snapshots__/AccordionItem.test.js.snap +0 -124
  176. package/src/accordion/__snapshots__/Accordion.test.js.snap +0 -3
  177. package/src/actionButton/__snapshots__/ActionButton.test.tsx.snap +0 -12
  178. package/src/avatarWrapper/__snapshots__/AvatarWrapper.test.tsx.snap +0 -156
  179. package/src/checkbox/__snapshots__/Checkbox.test.tsx.snap +0 -40
  180. package/src/chevron/__snapshots__/Chevron.test.tsx.snap +0 -24
  181. package/src/chips/__snapshots__/Chips.test.tsx.snap +0 -153
  182. package/src/common/RadioButton/__snapshots__/RadioButton.test.tsx.snap +0 -58
  183. package/src/common/bottomSheet/__snapshots__/BottomSheet.test.tsx.snap +0 -80
  184. package/src/common/card/__snapshots__/Card.test.tsx.snap +0 -10
  185. package/src/common/closeButton/__snapshots__/CloseButton.test.tsx.snap +0 -30
  186. package/src/common/flowHeader/FlowHeader.test.tsx +0 -22
  187. package/src/common/flowHeader/__snapshots__/FlowHeader.test.tsx.snap +0 -33
  188. package/src/common/panel/__snapshots__/Panel.test.tsx.snap +0 -3
  189. package/src/flowNavigation/__snapshots__/FlowNavigation.test.js.snap +0 -262
  190. package/src/logo/Logo.test.tsx +0 -55
  191. package/src/logo/__snapshots__/Logo.test.tsx.snap +0 -281
  192. package/src/overlayHeader/__snapshots__/OverlayHeader.test.tsx.snap +0 -65
  193. package/src/popover/__snapshots__/Popover.test.tsx.snap +0 -51
  194. package/src/promoCard/__snapshots__/PromoCard.test.tsx.snap +0 -40
  195. package/src/promoCard/__snapshots__/PromoCardGroup.test.tsx.snap +0 -80
  196. package/src/tile/__snapshots__/Tile.test.tsx.snap +0 -55
  197. package/src/tooltip/__snapshots__/Tooltip.test.tsx.snap +0 -32
@@ -0,0 +1,224 @@
1
+ import { fireEvent, mockMatchMedia, render, screen, userEvent } from '../../test-utils';
2
+ import { InfoPrompt, InfoPromptProps } from './InfoPrompt';
3
+
4
+ mockMatchMedia();
5
+
6
+ const CUSTOM_MEDIA = <span data-testid="custom-media">Custom Media</span>;
7
+
8
+ describe('InfoPrompt', () => {
9
+ const defaultProps: InfoPromptProps = {
10
+ description: 'Prompt description',
11
+ };
12
+
13
+ it('renders description', () => {
14
+ render(<InfoPrompt {...defaultProps} />);
15
+ expect(screen.getByText('Prompt description')).toBeInTheDocument();
16
+ });
17
+
18
+ it('renders title when provided', () => {
19
+ render(<InfoPrompt {...defaultProps} title="Test Title" />);
20
+ expect(screen.getByText('Test Title')).toBeInTheDocument();
21
+ expect(screen.getByText('Prompt description')).toBeInTheDocument();
22
+ });
23
+
24
+ it('renders with GiftBox icon as default for `proposition` sentiment', () => {
25
+ render(<InfoPrompt {...defaultProps} sentiment="proposition" data-testid="info-prompt" />);
26
+ expect(screen.getByText('Prompt description')).toBeInTheDocument();
27
+ // GiftBox icon should be rendered for proposition sentiment
28
+ const prompt = screen.getByTestId('info-prompt');
29
+ expect(prompt.querySelector('svg')).toBeInTheDocument();
30
+ });
31
+
32
+ describe('sentiments', () => {
33
+ [
34
+ { sentiment: 'negative' as const, surfaceClass: 'wds-prompt--negative' },
35
+ { sentiment: 'warning' as const, surfaceClass: 'wds-prompt--warning' },
36
+ { sentiment: 'neutral' as const, surfaceClass: 'wds-prompt--neutral' },
37
+ { sentiment: 'success' as const, surfaceClass: 'wds-prompt--success' },
38
+ { sentiment: 'proposition' as const, surfaceClass: 'wds-prompt--proposition' },
39
+ ].forEach(({ sentiment, surfaceClass }) => {
40
+ describe(sentiment, () => {
41
+ it('should apply correct styles', () => {
42
+ render(<InfoPrompt {...defaultProps} sentiment={sentiment} data-testid="info-prompt" />);
43
+ expect(screen.getByTestId('info-prompt')).toHaveClass(surfaceClass);
44
+ });
45
+ });
46
+ });
47
+ });
48
+
49
+ describe('custom media', () => {
50
+ it('should render custom media when provided', () => {
51
+ render(<InfoPrompt {...defaultProps} media={{ asset: CUSTOM_MEDIA }} />);
52
+ expect(screen.getByTestId('custom-media')).toBeInTheDocument();
53
+ });
54
+
55
+ it('should render custom media for any sentiment', () => {
56
+ render(<InfoPrompt {...defaultProps} sentiment="neutral" media={{ asset: CUSTOM_MEDIA }} />);
57
+ expect(screen.getByTestId('custom-media')).toBeInTheDocument();
58
+ });
59
+ });
60
+
61
+ describe('action', () => {
62
+ it('should render action link when action is provided with href', () => {
63
+ render(
64
+ <InfoPrompt {...defaultProps} action={{ label: 'Learn more', href: '/learn-more' }} />,
65
+ );
66
+ const actionLink = screen.getByRole('link', { name: 'Learn more' });
67
+ expect(actionLink).toBeInTheDocument();
68
+ expect(actionLink).toHaveAttribute('href', '/learn-more');
69
+ });
70
+
71
+ it('should render action link with target when provided', () => {
72
+ render(
73
+ <InfoPrompt
74
+ {...defaultProps}
75
+ action={{ label: 'External link', href: 'https://example.com', target: '_blank' }}
76
+ />,
77
+ );
78
+ const actionLink = screen.getByRole('link', { name: /External link/i });
79
+ expect(actionLink).toHaveAttribute('target', '_blank');
80
+ });
81
+
82
+ it('should call onClick when action button is clicked', async () => {
83
+ const user = userEvent.setup();
84
+ const onClick = jest.fn();
85
+ render(<InfoPrompt {...defaultProps} action={{ label: 'Click me', onClick }} />);
86
+ const actionButton = screen.getByRole('button', { name: 'Click me' });
87
+ await user.click(actionButton);
88
+ expect(onClick).toHaveBeenCalledTimes(1);
89
+ });
90
+
91
+ it('should not render action when not provided', () => {
92
+ render(<InfoPrompt {...defaultProps} />);
93
+ expect(screen.queryByRole('link', { name: 'Learn more' })).not.toBeInTheDocument();
94
+ });
95
+ });
96
+
97
+ describe('HTML attributes', () => {
98
+ it('applies custom className, id, and data-testid', () => {
99
+ render(
100
+ <InfoPrompt
101
+ {...defaultProps}
102
+ className="custom-class"
103
+ id="custom-id"
104
+ data-testid="custom-test"
105
+ />,
106
+ );
107
+ const el = screen.getByTestId('custom-test');
108
+ expect(el).toHaveClass('custom-class');
109
+ expect(el).toHaveAttribute('id', 'custom-id');
110
+ });
111
+ });
112
+
113
+ describe('SentimentSurface integration', () => {
114
+ it('maps success sentiment correctly for SentimentSurface', () => {
115
+ render(<InfoPrompt {...defaultProps} sentiment="success" data-testid="prompt" />);
116
+ const el = screen.getByTestId('prompt');
117
+ expect(el).toHaveClass('wds-prompt--success');
118
+ expect(el).toHaveClass('wds-sentiment-surface');
119
+ });
120
+
121
+ it('passes through other sentiments unchanged', () => {
122
+ render(<InfoPrompt {...defaultProps} sentiment="negative" data-testid="prompt" />);
123
+ const el = screen.getByTestId('prompt');
124
+ expect(el).toHaveClass('wds-prompt--negative');
125
+ expect(el).toHaveClass('wds-sentiment-surface');
126
+ });
127
+ });
128
+
129
+ describe('touch interactions', () => {
130
+ const originalLocation = window.location;
131
+
132
+ beforeAll(() => {
133
+ jest.spyOn(window, 'open').mockImplementation();
134
+ Object.defineProperty(window, 'location', {
135
+ configurable: true,
136
+ value: {
137
+ ...originalLocation,
138
+ assign: jest.fn(),
139
+ },
140
+ });
141
+ });
142
+
143
+ afterEach(() => {
144
+ jest.clearAllMocks();
145
+ });
146
+
147
+ afterAll(() => {
148
+ Object.defineProperty(window, 'location', {
149
+ configurable: true,
150
+ value: originalLocation,
151
+ });
152
+ });
153
+
154
+ it('should navigate to action href on touch tap', () => {
155
+ render(
156
+ <InfoPrompt
157
+ {...defaultProps}
158
+ action={{ label: 'Learn more', href: '/learn-more' }}
159
+ data-testid="prompt"
160
+ />,
161
+ );
162
+ const prompt = screen.getByTestId('prompt');
163
+
164
+ fireEvent.touchStart(prompt);
165
+ expect(window.location.assign).not.toHaveBeenCalled();
166
+ fireEvent.touchEnd(prompt);
167
+ expect(window.location.assign).toHaveBeenCalledWith('/learn-more');
168
+ });
169
+
170
+ it('should open in new tab when action target is _blank', () => {
171
+ render(
172
+ <InfoPrompt
173
+ {...defaultProps}
174
+ action={{ label: 'External link', href: 'https://example.com', target: '_blank' }}
175
+ data-testid="prompt"
176
+ />,
177
+ );
178
+ const prompt = screen.getByTestId('prompt');
179
+
180
+ fireEvent.touchStart(prompt);
181
+ expect(window.open).not.toHaveBeenCalled();
182
+ fireEvent.touchEnd(prompt);
183
+ expect(window.open).toHaveBeenCalledWith(
184
+ 'https://example.com',
185
+ '_blank',
186
+ 'noopener, noreferrer',
187
+ );
188
+ });
189
+
190
+ it('should not navigate if touch move occurs (scrolling)', () => {
191
+ render(
192
+ <InfoPrompt
193
+ {...defaultProps}
194
+ action={{ label: 'Learn more', href: '/learn-more' }}
195
+ data-testid="prompt"
196
+ />,
197
+ );
198
+ const prompt = screen.getByTestId('prompt');
199
+
200
+ fireEvent.touchStart(prompt);
201
+ expect(window.location.assign).not.toHaveBeenCalled();
202
+ fireEvent.touchMove(prompt);
203
+ expect(window.location.assign).not.toHaveBeenCalled();
204
+ fireEvent.touchEnd(prompt);
205
+ expect(window.location.assign).not.toHaveBeenCalled();
206
+ });
207
+
208
+ it('should not navigate if no action href is provided', () => {
209
+ render(
210
+ <InfoPrompt
211
+ {...defaultProps}
212
+ action={{ label: 'Click me', onClick: jest.fn() }}
213
+ data-testid="prompt"
214
+ />,
215
+ );
216
+ const prompt = screen.getByTestId('prompt');
217
+
218
+ fireEvent.touchStart(prompt);
219
+ fireEvent.touchEnd(prompt);
220
+ expect(window.location.assign).not.toHaveBeenCalled();
221
+ expect(window.open).not.toHaveBeenCalled();
222
+ });
223
+ });
224
+ });
@@ -0,0 +1,148 @@
1
+ import { HTMLAttributes, ReactNode, useState } from 'react';
2
+ import { Sentiment, Typography } from '../../common';
3
+ import { GiftBox } from '@transferwise/icons';
4
+ import type { Sentiment as SurfaceSentiment } from '../../sentimentSurface';
5
+ import StatusIcon from '../../statusIcon';
6
+ import { clsx } from 'clsx';
7
+ import Body from '../../body';
8
+ import Link, { LinkProps } from '../../link';
9
+ import { PrimitivePrompt, PrimitivePromptProps } from '../PrimitivePrompt';
10
+
11
+ export type InfoPromptAction = Pick<LinkProps, 'href' | 'target' | 'onClick'> & {
12
+ /**
13
+ * The label text for the action link
14
+ */
15
+ label: string;
16
+ };
17
+
18
+ export type InfoPromptMedia = {
19
+ /**
20
+ * The icon/image asset to display.
21
+ * The asset should include its own accessibility attributes (e.g. title, aria-label)
22
+ * if it conveys meaning, or aria-hidden="true" if decorative.
23
+ */
24
+ asset: ReactNode;
25
+ };
26
+
27
+ export type InfoPromptProps = Omit<HTMLAttributes<HTMLDivElement>, 'title'> &
28
+ Pick<PrimitivePromptProps, 'data-testid'> & {
29
+ /**
30
+ * The sentiment determines the colour scheme
31
+ * @default 'neutral'
32
+ */
33
+ sentiment?: SurfaceSentiment;
34
+ /**
35
+ * Handler called when the close button is clicked.
36
+ * If not provided, the close button is hidden.
37
+ */
38
+ onDismiss?: () => void;
39
+ /**
40
+ * Custom media to override the default status icon.
41
+ * Success and proposition sentiments support 2 status variations: standard checkmark & confetti.
42
+ */
43
+ media?: InfoPromptMedia;
44
+ /**
45
+ * Action link to be displayed below the description
46
+ */
47
+ action?: InfoPromptAction;
48
+ /**
49
+ * Title content for the prompt
50
+ */
51
+ title?: string;
52
+ /**
53
+ * Description text for the prompt (required)
54
+ */
55
+ description: string;
56
+ };
57
+
58
+ /**
59
+ * InfoPrompt displays important contextual messages to users within a screen.
60
+ * It provides a visually distinct way to communicate information, warnings, errors,
61
+ * or positive feedback with optional actions and dismissal capabilities.
62
+ *
63
+ * Use this component to replace the deprecated Alert component.
64
+ */
65
+ export const InfoPrompt = ({
66
+ sentiment = 'neutral',
67
+ onDismiss,
68
+ media,
69
+ action,
70
+ title,
71
+ description,
72
+ className,
73
+ 'data-testid': dataTestId,
74
+ ...restProps
75
+ }: InfoPromptProps) => {
76
+ const [shouldFire, setShouldFire] = useState<boolean>();
77
+ const statusIconSentiment =
78
+ sentiment === 'success'
79
+ ? Sentiment.POSITIVE
80
+ : (sentiment as Exclude<SurfaceSentiment, 'proposition'>);
81
+
82
+ const handleTouchStart = () => {
83
+ setShouldFire(true);
84
+ };
85
+
86
+ const handleTouchEnd = () => {
87
+ if (shouldFire && action?.href) {
88
+ if (action.target === '_blank') {
89
+ window.top?.open(action.href, '_blank', 'noopener, noreferrer');
90
+ } else {
91
+ window.top?.location.assign(action.href);
92
+ }
93
+ }
94
+ setShouldFire(false);
95
+ };
96
+
97
+ const handleTouchMove = () => {
98
+ setShouldFire(false);
99
+ };
100
+
101
+ const renderMedia = () => {
102
+ if (media) {
103
+ return <span className="wds-info-prompt__media">{media.asset}</span>;
104
+ }
105
+
106
+ if (sentiment === 'proposition') {
107
+ return <GiftBox size={24} />;
108
+ }
109
+
110
+ return <StatusIcon size={24} sentiment={statusIconSentiment} />;
111
+ };
112
+
113
+ return (
114
+ <PrimitivePrompt
115
+ sentiment={sentiment}
116
+ media={renderMedia()}
117
+ data-testid={dataTestId}
118
+ className={clsx('wds-info-prompt', className)}
119
+ {...restProps}
120
+ onTouchStart={handleTouchStart}
121
+ onTouchEnd={handleTouchEnd}
122
+ onTouchMove={handleTouchMove}
123
+ onDismiss={onDismiss}
124
+ >
125
+ <div className="wds-info-prompt__content">
126
+ {title && (
127
+ <Body className="wds-info-prompt__title" type={Typography.BODY_LARGE_BOLD} as="span">
128
+ {title}
129
+ </Body>
130
+ )}
131
+ <Body as="span" className="wds-info-prompt__description">
132
+ {description}
133
+ </Body>
134
+ {action && (
135
+ <Link
136
+ href={action.href}
137
+ target={action.target}
138
+ type={Typography.LINK_DEFAULT}
139
+ className="wds-info-prompt__action"
140
+ onClick={action.onClick}
141
+ >
142
+ {action.label}
143
+ </Link>
144
+ )}
145
+ </div>
146
+ </PrimitivePrompt>
147
+ );
148
+ };
@@ -0,0 +1,2 @@
1
+ export type { InfoPromptProps, InfoPromptAction, InfoPromptMedia } from './InfoPrompt';
2
+ export { InfoPrompt } from './InfoPrompt';
@@ -225,24 +225,27 @@ export const Muted: StoryObj<PreviewStoryArgs> = {
225
225
  * While all main sentiments (`warning`, `negative`, `positive` and`neutral`) are associated with a
226
226
  * default `StatusIcon`s, we also allow for Icon overrides to bring the prompt's visual language
227
227
  * closer to the prompt's content. <br /><br />
228
- * It's also possible to override the default icon's accessible name announced by screen readers
229
- * via `mediaLabel` prop, which is especially useful for the `proposition` sentiment.
228
+ * It's also possible to override the default StatusIcon's accessible name announced by screen
229
+ * readers via `mediaLabel` prop, which is especially useful for the `proposition` sentiment.
230
+ * <br /><br />
231
+ * **NB**: If you're setting a label on a custom Icon, the accessible name should be provided via
232
+ * Icon's `title` prop instead.
230
233
  */
231
234
  export const IconOverrides: StoryObj<PreviewStoryArgs> = {
232
235
  render: (args: PreviewStoryArgs) => {
233
236
  return (
234
237
  <>
235
- <InlinePrompt {...args} media={<Travel />} sentiment="positive" mediaLabel="Success: ">
236
- Your travel account is set up and ready to use.
237
- </InlinePrompt>
238
- <InlinePrompt {...args} media={<Taxi />} sentiment="proposition" mediaLabel="Taxi addon: ">
239
- Connect Wise with your taxi app to get exclusive discounts.
238
+ <InlinePrompt {...args} sentiment="negative" mediaLabel="Rejected: ">
239
+ This prompt uses default Icon, but with a custom label for screen readers.
240
240
  </InlinePrompt>
241
- <InlinePrompt {...args} media={<Clock />} sentiment="warning" mediaLabel="Processing: ">
241
+ <InlinePrompt {...args} media={<Clock title="Processing: " />} sentiment="warning">
242
242
  The account verification is taking longer than usual.
243
243
  </InlinePrompt>
244
- <InlinePrompt {...args} media={<Id />} sentiment="negative" mediaLabel="Error: ">
245
- The identity document you provided has expired.
244
+ <InlinePrompt {...args} media={<Travel title="Activated: " />} sentiment="positive">
245
+ Your travel account is set up and ready to use.
246
+ </InlinePrompt>
247
+ <InlinePrompt {...args} media={<Taxi title="Taxi addon: " />} sentiment="proposition">
248
+ Connect Wise with your taxi app to get exclusive discounts.
246
249
  </InlinePrompt>
247
250
  </>
248
251
  );
@@ -1,3 +1,4 @@
1
+ import { Clock } from '@transferwise/icons';
1
2
  import { mockMatchMedia, render, screen } from '../../test-utils';
2
3
  import { InlinePrompt, InlinePromptProps } from './InlinePrompt';
3
4
  import { Sentiment } from '../../common';
@@ -91,11 +92,22 @@ describe('InlinePrompt', () => {
91
92
  });
92
93
  }
93
94
 
94
- it('should allow for customisation of aria label', () => {
95
+ it('should allow for customisation of aria label for StatusIcon', () => {
95
96
  render(<InlinePrompt {...defaultProps} sentiment={sentiment} mediaLabel={mediaLabel} />);
96
97
  expect(screen.getByLabelText(mediaLabel)).toBeInTheDocument();
97
98
  });
98
99
 
100
+ it('should allow for customisation of aria label for a custom Icon', () => {
101
+ render(
102
+ <InlinePrompt
103
+ {...defaultProps}
104
+ sentiment={sentiment}
105
+ media={<Clock title={mediaLabel} />}
106
+ />,
107
+ );
108
+ expect(screen.getByLabelText(mediaLabel)).toBeInTheDocument();
109
+ });
110
+
99
111
  it('should retain custom label while muted', () => {
100
112
  render(
101
113
  <InlinePrompt {...defaultProps} sentiment={sentiment} mediaLabel={mediaLabel} muted />,
@@ -44,4 +44,4 @@
44
44
  }
45
45
  }
46
46
  }
47
- }
47
+ }
@@ -4,9 +4,9 @@ import SentimentSurface, { Sentiment } from '../../sentimentSurface';
4
4
  import IconButton from '../../iconButton';
5
5
  import { useIntl } from 'react-intl';
6
6
  import closeBtnMessages from '../../common/closeButton/CloseButton.messages';
7
- import { ReactNode } from 'react';
7
+ import { HTMLAttributes, ReactNode } from 'react';
8
8
 
9
- export type PrimitivePromptProps = {
9
+ export type PrimitivePromptProps = HTMLAttributes<HTMLDivElement> & {
10
10
  /**
11
11
  * The sentiment determines the colour scheme
12
12
  * @default success
@@ -24,10 +24,10 @@ export type PrimitivePromptProps = {
24
24
  * Handler called when the close button is clicked. If not provided, then the close button is hidden.
25
25
  */
26
26
  onDismiss?: () => void;
27
- id?: string;
28
- className?: string;
27
+ /**
28
+ * Test ID for testing tools
29
+ */
29
30
  'data-testid'?: string;
30
- children: ReactNode;
31
31
  };
32
32
 
33
33
  /**
@@ -5,5 +5,10 @@
5
5
  export type { InlinePromptProps } from './InlinePrompt';
6
6
  export { InlinePrompt } from './InlinePrompt';
7
7
 
8
+ // ActionPrompt
8
9
  export type { ActionPromptProps } from './ActionPrompt';
9
10
  export { ActionPrompt } from './ActionPrompt';
11
+
12
+ // InfoPrompt
13
+ export type { InfoPromptProps, InfoPromptAction, InfoPromptMedia } from './InfoPrompt';
14
+ export { InfoPrompt } from './InfoPrompt';
@@ -3,7 +3,8 @@ import RadioButton from '../common/RadioButton';
3
3
  import { RadioButtonProps } from '../common/RadioButton/RadioButton';
4
4
 
5
5
  export interface RadioOptionProps<T extends string | number = string>
6
- extends Required<Pick<RadioButtonProps<T>, 'id' | 'name' | 'onChange'>>,
6
+ extends
7
+ Required<Pick<RadioButtonProps<T>, 'id' | 'name' | 'onChange'>>,
7
8
  Omit<RadioButtonProps<T>, 'readOnly' | 'id' | 'name' | 'onChange'> {
8
9
  'aria-label'?: string;
9
10
  media?: React.ReactNode;
@@ -304,18 +304,18 @@
304
304
  --color-sentiment-interactive-primary: #454745;
305
305
  --color-sentiment-interactive-primary-hover: #353635;
306
306
  --color-sentiment-interactive-primary-active: #232423;
307
- --color-sentiment-interactive-secondary: #F1F1ED;
308
- --color-sentiment-interactive-secondary-hover: #E7E7E1;
309
- --color-sentiment-interactive-secondary-active: #DFDED5;
310
- --color-sentiment-interactive-secondary-neutral: #E4E4DC;
311
- --color-sentiment-interactive-secondary-neutral-hover: #DCDCD2;
312
- --color-sentiment-interactive-secondary-neutral-active: #D3D2C6;
307
+ --color-sentiment-interactive-secondary: rgba(62, 59, 7, 0.07);
308
+ --color-sentiment-interactive-secondary-hover: rgba(62, 59, 7, 0.12);
309
+ --color-sentiment-interactive-secondary-active: rgba(62, 59, 7, 0.17);
310
+ --color-sentiment-interactive-secondary-neutral: rgba(62, 59, 7, 0.07);
311
+ --color-sentiment-interactive-secondary-neutral-hover: rgba(62, 59, 7, 0.12);
312
+ --color-sentiment-interactive-secondary-neutral-active: rgba(62, 59, 7, 0.17);
313
313
  --color-sentiment-interactive-control: #F1F1ED;
314
314
  --color-sentiment-interactive-control-hover: #E7E7E1;
315
315
  --color-sentiment-interactive-control-active: #DFDED5;
316
- --color-sentiment-background-surface: #F1F1ED;
317
- --color-sentiment-background-surface-hover: #E7E7E1;
318
- --color-sentiment-background-surface-active: #DFDED5;
316
+ --color-sentiment-background-surface: rgba(62, 59, 7, 0.07);
317
+ --color-sentiment-background-surface-hover: rgba(62, 59, 7, 0.12);
318
+ --color-sentiment-background-surface-active: rgba(62, 59, 7, 0.17);
319
319
  }
320
320
  .np-theme-personal .wds-sentiment-surface-neutral-elevated,
321
321
  .np-theme-business .wds-sentiment-surface-neutral-elevated,
@@ -331,9 +331,9 @@
331
331
  --color-sentiment-interactive-secondary: #454745;
332
332
  --color-sentiment-interactive-secondary-hover: #353635;
333
333
  --color-sentiment-interactive-secondary-active: #232423;
334
- --color-sentiment-interactive-secondary-neutral: #5A5C5A;
335
- --color-sentiment-interactive-secondary-neutral-hover: #6D6F6D;
336
- --color-sentiment-interactive-secondary-neutral-active: #727472;
334
+ --color-sentiment-interactive-secondary-neutral: #585958;
335
+ --color-sentiment-interactive-secondary-neutral-hover: #6A6C6A;
336
+ --color-sentiment-interactive-secondary-neutral-active: #7D7E7D;
337
337
  --color-sentiment-interactive-control: #454745;
338
338
  --color-sentiment-interactive-control-hover: #353635;
339
339
  --color-sentiment-interactive-control-active: #232423;
@@ -352,18 +352,18 @@
352
352
  --color-sentiment-interactive-primary: #F1F1ED;
353
353
  --color-sentiment-interactive-primary-hover: #E7E7E1;
354
354
  --color-sentiment-interactive-primary-active: #DFDED5;
355
- --color-sentiment-interactive-secondary: #2A2C29;
356
- --color-sentiment-interactive-secondary-hover: #414441;
357
- --color-sentiment-interactive-secondary-active: #595B58;
358
- --color-sentiment-interactive-secondary-neutral: #424441;
359
- --color-sentiment-interactive-secondary-neutral-hover: #4C4E4B;
360
- --color-sentiment-interactive-secondary-neutral-active: #565955;
355
+ --color-sentiment-interactive-secondary: rgba(255, 255, 255, 0.1);
356
+ --color-sentiment-interactive-secondary-hover: rgba(255, 255, 255, 0.2);
357
+ --color-sentiment-interactive-secondary-active: rgba(255, 255, 255, 0.3);
358
+ --color-sentiment-interactive-secondary-neutral: rgba(255, 255, 255, 0.1);
359
+ --color-sentiment-interactive-secondary-neutral-hover: rgba(255, 255, 255, 0.2);
360
+ --color-sentiment-interactive-secondary-neutral-active: rgba(255, 255, 255, 0.3);
361
361
  --color-sentiment-interactive-control: #2A2C29;
362
362
  --color-sentiment-interactive-control-hover: #414441;
363
363
  --color-sentiment-interactive-control-active: #595B58;
364
- --color-sentiment-background-surface: #2A2C29;
365
- --color-sentiment-background-surface-hover: #414441;
366
- --color-sentiment-background-surface-active: #595B58;
364
+ --color-sentiment-background-surface: rgba(255, 255, 255, 0.1);
365
+ --color-sentiment-background-surface-hover: rgba(255, 255, 255, 0.2);
366
+ --color-sentiment-background-surface-active: rgba(255, 255, 255, 0.3);
367
367
  }
368
368
  .np-theme-personal--dark .wds-sentiment-surface-neutral-elevated,
369
369
  .np-theme-business--dark .wds-sentiment-surface-neutral-elevated,
@@ -178,12 +178,12 @@
178
178
  .np-theme-business--bright-green & {
179
179
  &-base {
180
180
  .sentiment-surface-tokens(
181
- #454745, #353635, #232423, // content-primary (default, hover, active)
182
- #454745, #353635, #232423, // interactive-primary
183
- #F1F1ED, #E7E7E1, #DFDED5, // interactive-secondary
184
- #E4E4DC, #DCDCD2, #D3D2C6, // interactive-secondary-neutral
185
- #F1F1ED, #E7E7E1, #DFDED5, // interactive-control
186
- #F1F1ED, #E7E7E1, #DFDED5 // background-surface
181
+ #454745, #353635, #232423, // content-primary (default, hover, active)
182
+ #454745, #353635, #232423, // interactive-primary
183
+ rgba(62, 59, 7, 0.07), rgba(62, 59, 7, 0.12), rgba(62, 59, 7, 0.17), // interactive-secondary
184
+ rgba(62, 59, 7, 0.07), rgba(62, 59, 7, 0.12), rgba(62, 59, 7, 0.17), // interactive-secondary-neutral
185
+ #F1F1ED, #E7E7E1, #DFDED5, // interactive-control
186
+ rgba(62, 59, 7, 0.07), rgba(62, 59, 7, 0.12), rgba(62, 59, 7, 0.17) // background-surface
187
187
  );
188
188
  }
189
189
  &-elevated {
@@ -191,7 +191,7 @@
191
191
  #F1F1ED, #E7E7E1, #DFDED5, // content-primary
192
192
  #F1F1ED, #E7E7E1, #DFDED5, // interactive-primary
193
193
  #454745, #353635, #232423, // interactive-secondary
194
- #5A5C5A, #6D6F6D, #727472, // interactive-secondary-neutral
194
+ #585958, #6A6C6A, #7D7E7D, // interactive-secondary-neutral
195
195
  #454745, #353635, #232423, // interactive-control
196
196
  #454745, #353635, #232423 // background-surface
197
197
  );
@@ -205,12 +205,12 @@
205
205
  .np-theme-platform--forest-green & {
206
206
  &-base {
207
207
  .sentiment-surface-tokens(
208
- #F1F1ED, #E7E7E1, #DFDED5, // content-primary
209
- #F1F1ED, #E7E7E1, #DFDED5, // interactive-primary
210
- #2A2C29, #414441, #595B58, // interactive-secondary
211
- #424441, #4C4E4B, #565955, // interactive-secondary-neutral
212
- #2A2C29, #414441, #595B58, // interactive-control
213
- #2A2C29, #414441, #595B58 // background-surface
208
+ #F1F1ED, #E7E7E1, #DFDED5, // content-primary
209
+ #F1F1ED, #E7E7E1, #DFDED5, // interactive-primary
210
+ rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.30), // interactive-secondary
211
+ rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.30), // interactive-secondary-neutral
212
+ #2A2C29, #414441, #595B58, // interactive-control
213
+ rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.20), rgba(255, 255, 255, 0.30) // background-surface
214
214
  );
215
215
  }
216
216
  &-elevated {
@@ -31,7 +31,7 @@ const withComponentGrid = (Story: () => JSX.Element) => (
31
31
  */
32
32
  const meta: Meta<typeof SentimentSurface> = {
33
33
  component: SentimentSurface,
34
- title: 'Foundations/SentimentSurface',
34
+ title: 'Content/SentimentSurface',
35
35
  argTypes: {
36
36
  sentiment: {
37
37
  control: 'select',