@transferwise/components 46.132.1 → 46.133.0

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 (49) hide show
  1. package/build/inputs/InputGroup.js +10 -1
  2. package/build/inputs/InputGroup.js.map +1 -1
  3. package/build/inputs/InputGroup.mjs +10 -1
  4. package/build/inputs/InputGroup.mjs.map +1 -1
  5. package/build/main.css +18 -2
  6. package/build/phoneNumberInput/PhoneNumberInput.js +6 -1
  7. package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
  8. package/build/phoneNumberInput/PhoneNumberInput.mjs +6 -1
  9. package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
  10. package/build/styles/inputs/InputGroup.css +10 -2
  11. package/build/styles/main.css +18 -2
  12. package/build/styles/phoneNumberInput/PhoneNumberInput.css +5 -0
  13. package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
  14. package/package.json +21 -21
  15. package/src/button/_stories/Button.accessibility.docs.mdx +10 -6
  16. package/src/button/_stories/Button.story.tsx +0 -2
  17. package/src/common/bottomSheet/BottomSheet.story.tsx +11 -9
  18. package/src/common/bottomSheet/BottomSheet.test.story.tsx +28 -15
  19. package/src/divider/Divider.accessibility.docs.mdx +1 -10
  20. package/src/divider/Divider.story.tsx +0 -1
  21. package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +1 -2
  22. package/src/header/Header.accessibility.docs.mdx +9 -5
  23. package/src/inputs/InputGroup.css +10 -2
  24. package/src/inputs/InputGroup.less +12 -2
  25. package/src/inputs/InputGroup.story.tsx +27 -0
  26. package/src/inputs/InputGroup.tsx +10 -0
  27. package/src/inputs/SelectInput/_stories/SelectInput.story.tsx +0 -1
  28. package/src/legacylistItem/LegacyListItem.test.story.tsx +1 -1
  29. package/src/listItem/AdditionalInfo/ListItemAdditionalInfo.story.tsx +0 -1
  30. package/src/listItem/AvatarLayout/ListItemAvatarLayout.story.tsx +0 -1
  31. package/src/listItem/AvatarView/ListItemAvatarView.story.tsx +0 -1
  32. package/src/listItem/Button/ListItemButton.story.tsx +0 -1
  33. package/src/listItem/Checkbox/ListItemCheckbox.story.tsx +0 -1
  34. package/src/listItem/IconButton/ListItemIconButton.story.tsx +0 -1
  35. package/src/listItem/Navigation/ListItemNavigation.story.tsx +0 -1
  36. package/src/listItem/Prompt/ListItemPrompt.story.tsx +0 -1
  37. package/src/listItem/Radio/ListItemRadio.story.tsx +0 -1
  38. package/src/listItem/Switch/ListItemSwitch.story.tsx +0 -1
  39. package/src/listItem/_stories/ListItem.story.tsx +1 -0
  40. package/src/main.css +18 -2
  41. package/src/phoneNumberInput/PhoneNumberInput.css +5 -0
  42. package/src/phoneNumberInput/PhoneNumberInput.less +7 -0
  43. package/src/phoneNumberInput/PhoneNumberInput.tsx +10 -1
  44. package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +0 -1
  45. package/src/section/Section.story.tsx +12 -7
  46. package/src/sentimentSurface/SentimentSurface.story.tsx +1 -1
  47. package/src/snackbar/Snackbar.test.story.tsx +16 -104
  48. package/src/summary/Summary.test.story.tsx +1 -1
  49. package/src/switchOption/SwitchOption.story.tsx +0 -1
@@ -3,6 +3,7 @@ import { useIntl } from 'react-intl';
3
3
 
4
4
  import { Size, SizeLarge, SizeMedium, SizeSmall } from '../common';
5
5
  import { useFieldLabelRef, useInputAttributes } from '../inputs/contexts';
6
+ import { useInputPaddings } from '../inputs/InputGroup';
6
7
  import { SelectInput, SelectInputOptionContent, SelectInputProps } from '../inputs/SelectInput';
7
8
  import messages from './PhoneNumberInput.messages';
8
9
  import countries from './data/countries';
@@ -67,6 +68,8 @@ const PhoneNumberInput = ({
67
68
  const countryCodeSelectRef = useRef<HTMLButtonElement>(null);
68
69
  const phoneNumberInputRef = useRef<HTMLInputElement>(null);
69
70
  const inputAttributes = useInputAttributes({ nonLabelable: true });
71
+ const { paddingInlineStart } = useInputPaddings();
72
+ const hasInputGroupAddonStart = paddingInlineStart != null;
70
73
  const fieldLabelRef = useFieldLabelRef();
71
74
  const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];
72
75
 
@@ -197,7 +200,13 @@ const PhoneNumberInput = ({
197
200
  <label className="sr-only" id={ids.countryCode.label} htmlFor={ids.countryCode.select}>
198
201
  {formatMessage(messages.countryCodeLabel)}
199
202
  </label>
200
- <div className="tw-telephone__country-select">
203
+ <div
204
+ className={`tw-telephone__country-select${
205
+ hasInputGroupAddonStart
206
+ ? ' tw-telephone__country-select--with-input-group-addon-start'
207
+ : ''
208
+ }`}
209
+ >
201
210
  <SelectInput
202
211
  triggerRef={countryCodeSelectRef}
203
212
  placeholder={formatMessage(messages.selectInputPlaceholder)}
@@ -96,7 +96,6 @@ const getPropsForPreview = (
96
96
  };
97
97
 
98
98
  export const Playground: StoryObj<PreviewStoryArgs> = {
99
- tags: ['!autodocs'],
100
99
  argTypes: previewArgTypes,
101
100
  args: {
102
101
  previewMedia: false,
@@ -1,11 +1,10 @@
1
1
  import { FastFlag as FastFlagIcon } from '@transferwise/icons';
2
2
  import { useState } from 'react';
3
-
3
+ import { action } from 'storybook/actions';
4
4
  import Accordion from '../accordion';
5
5
  import Card from '../card';
6
6
  import Header from '../header';
7
- import NavigationOption from '../navigationOption';
8
-
7
+ import ListItem from '../listItem';
9
8
  import Section from './Section';
10
9
 
11
10
  export default {
@@ -105,12 +104,18 @@ export const WithCards = () => {
105
104
  );
106
105
  };
107
106
 
108
- export const WithNavigationOptions = () => {
107
+ export const WithListItems = () => {
109
108
  return (
110
109
  <Section>
111
- <Header title="Section with options" />
112
- <NavigationOption title="Option 1" onClick={() => alert('Option 1')} />
113
- <NavigationOption title="Option 2" onClick={() => alert('Option 2')} />
110
+ <Header title="Section with list items" />
111
+ <ListItem
112
+ title="Item 1"
113
+ control={<ListItem.Navigation onClick={() => action('Item 1')} />}
114
+ />
115
+ <ListItem
116
+ title="Item 2"
117
+ control={<ListItem.Navigation onClick={() => action('Item 2')} />}
118
+ />
114
119
  </Section>
115
120
  );
116
121
  };
@@ -32,6 +32,7 @@ const withComponentGrid = (Story: () => JSX.Element) => (
32
32
  const meta: Meta<typeof SentimentSurface> = {
33
33
  component: SentimentSurface,
34
34
  title: 'Foundations/SentimentSurface',
35
+ tags: ['early-access'],
35
36
  argTypes: {
36
37
  sentiment: {
37
38
  control: 'select',
@@ -124,7 +125,6 @@ export const Playground: Story = {
124
125
  </div>
125
126
  ),
126
127
  },
127
- tags: ['!autodocs'],
128
128
  };
129
129
 
130
130
  const sentiments: Sentiment[] = ['negative', 'warning', 'neutral', 'success', 'proposition'];
@@ -1,13 +1,12 @@
1
- import { userEvent, within } from 'storybook/test';
1
+ import { userEvent, within, expect } from 'storybook/test';
2
2
  import { action } from 'storybook/actions';
3
- import { Mobile as MobileIcon, Theme, Switch, Bulb, Info, Coins, Team } from '@transferwise/icons';
3
+ import { withVariantConfig } from '../../.storybook/helpers';
4
+ import { lorem20 } from '../test-utils';
5
+ import { wait } from '../test-utils/wait';
6
+ import Button from '../button';
4
7
  import { Snackbar, type SnackbarProps } from './Snackbar';
5
8
  import { SnackbarConsumer } from './SnackbarContext';
6
9
  import SnackbarProvider from './SnackbarProvider';
7
- import Button from '../button';
8
- import CheckboxOption from '../checkboxOption';
9
- import { wait } from '../test-utils/wait';
10
- import { withVariantConfig } from '../../.storybook/helpers';
11
10
 
12
11
  export default {
13
12
  title: 'Dialogs/Snackbar/Tests',
@@ -43,6 +42,7 @@ const Default = {
43
42
  {({ createSnackbar }) => (
44
43
  <>
45
44
  <Button
45
+ v2
46
46
  block
47
47
  onClick={() => {
48
48
  createSnackbar({
@@ -69,36 +69,6 @@ export const Basic = {
69
69
  ...Default,
70
70
  args: {
71
71
  ...Default.args,
72
- extraContext: (
73
- <div className="p-t-3">
74
- <CheckboxOption
75
- title="In light mode, snackbar has drop shadow"
76
- content={
77
- <a
78
- href="https://transferwise.atlassian.net/browse/DS-4477"
79
- target="_blank"
80
- rel="noreferrer"
81
- >
82
- Bug DS-4477
83
- </a>
84
- }
85
- media={<Bulb />}
86
- />
87
- <CheckboxOption
88
- title="Font size is 14 px, not 16px"
89
- content={
90
- <a
91
- href="https://transferwise.atlassian.net/browse/DS-3716"
92
- target="_blank"
93
- rel="noreferrer"
94
- >
95
- Bug DS-3716
96
- </a>
97
- }
98
- media={<Info size="16" />}
99
- />
100
- </div>
101
- ) as React.ReactNode,
102
72
  },
103
73
  };
104
74
 
@@ -106,14 +76,6 @@ export const Mobile = {
106
76
  ...Default,
107
77
  args: {
108
78
  ...Default.args,
109
- extraContext: (
110
- <div className="p-t-3">
111
- <CheckboxOption
112
- title="In mobile view, snackbar is full-width, not centered"
113
- media={<MobileIcon />}
114
- />
115
- </div>
116
- ) as React.ReactNode,
117
79
  },
118
80
  ...withVariantConfig(['mobile'], Default),
119
81
  };
@@ -136,15 +98,6 @@ export const DarkMode = {
136
98
  ...Default,
137
99
  args: {
138
100
  ...Default.args,
139
- extraContext: (
140
- <div className="p-t-3">
141
- <CheckboxOption title="In dark mode, snackbar has no drop shadow" media={<Theme />} />
142
- <CheckboxOption
143
- title="In dark mode, snackbar is inverted and has light background"
144
- media={<Theme />}
145
- />
146
- </div>
147
- ) as React.ReactNode,
148
101
  },
149
102
  play: switchToDarkMode,
150
103
  ...withVariantConfig(['dark'], Default),
@@ -167,36 +120,6 @@ export const RTL = {
167
120
  ...Default,
168
121
  args: {
169
122
  ...Default.args,
170
- extraContext: (
171
- <div className="p-t-3">
172
- <CheckboxOption
173
- title="In RTL, snackbar is not left aligned"
174
- content={
175
- <a
176
- href="https://transferwise.atlassian.net/browse/DS-4642"
177
- target="_blank"
178
- rel="noreferrer"
179
- >
180
- Bug DS-4642
181
- </a>
182
- }
183
- media={<Switch />}
184
- />
185
- <CheckboxOption
186
- title="In RTL, snackbar has proper padding on left and right of button"
187
- content={
188
- <a
189
- href="https://transferwise.atlassian.net/browse/DS-4643"
190
- target="_blank"
191
- rel="noreferrer"
192
- >
193
- Bug DS-4643
194
- </a>
195
- }
196
- media={<Switch />}
197
- />
198
- </div>
199
- ) as React.ReactNode,
200
123
  },
201
124
  play: switchToRTL,
202
125
  ...withVariantConfig(['rtl'], Default),
@@ -217,42 +140,31 @@ export const Zoom400 = {
217
140
  ...Default.args,
218
141
  extraContext: (
219
142
  <div className="p-t-3">
220
- <CheckboxOption
221
- content="Snackbar isn't transparent (I'm going to make this text very long so that it will fill up the entire page and go behind the snackbar. This way, when you look at it you will easily be able to tell if the snackbar is transparent and recognize the bug because we don't want it to be transparent. Transparent is bad. When we first did rebrand we had a lot of problems with transparencies. I don't know what happened to them. I don't see them a lot anymore but I also don't remember anybody fixing them.)"
222
- title={
223
- <a
224
- href="https://transferwise.atlassian.net/browse/DS-3716"
225
- target="_blank"
226
- rel="noreferrer"
227
- >
228
- Bug DS-3716
229
- </a>
230
- }
231
- media={<Coins />}
232
- />
143
+ Snackbar isn&#39;t transparent (I&#39;m going to make this text very long so that it will
144
+ fill up the entire page and go behind the snackbar. This way, when you look at it you will
145
+ easily be able to tell if the snackbar is transparent and recognize the bug because we
146
+ don&#39;t want it to be transparent. Transparent is bad. When we first did rebrand we had a
147
+ lot of problems with transparencies. {lorem20}
233
148
  </div>
234
149
  ),
235
150
  },
236
151
  ...withVariantConfig(['400%'], Default),
237
152
  };
238
153
 
154
+ /**
155
+ * Snackbar is only shown once even if trigger is clicked many times
156
+ */
239
157
  export const MultipleClicks = {
240
158
  ...Default,
241
159
  args: {
242
160
  ...Default.args,
243
- extraContext: (
244
- <div className="p-t-3">
245
- <CheckboxOption
246
- title="Snackbar is only shown once even if clicked many times"
247
- media={<Team />}
248
- />
249
- </div>
250
- ),
251
161
  },
252
162
  play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
253
163
  const canvas = within(canvasElement);
254
164
  for (let i = 0; i < 8; i += 1) {
255
165
  await userEvent.click(canvas.getByRole('button'));
256
166
  }
167
+
168
+ await expect(within(document.body).getAllByRole('alert')).toHaveLength(1);
257
169
  },
258
170
  };
@@ -5,7 +5,7 @@ import Summary, { type SummaryProps } from '.';
5
5
  export default {
6
6
  component: Summary,
7
7
  title: 'Content/Summary/Tests',
8
- tags: ['deprecated', '!manifest'],
8
+ tags: ['!manifest', 'deprecated'],
9
9
  };
10
10
 
11
11
  export const LongText = () => {
@@ -46,7 +46,6 @@ function Template(args: SwitchOptionProps) {
46
46
 
47
47
  export const Playground = {
48
48
  render: (args: SwitchOptionProps) => <Template {...args} />,
49
- tags: ['!autodocs'],
50
49
  };
51
50
 
52
51
  export const Multiple = {