@transferwise/components 0.0.0-experimental-5598332 → 0.0.0-experimental-cbc00a7

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 (82) hide show
  1. package/build/ListItem/ListItem.js +2 -32
  2. package/build/ListItem/ListItem.js.map +1 -1
  3. package/build/ListItem/ListItem.mjs +3 -33
  4. package/build/ListItem/ListItem.mjs.map +1 -1
  5. package/build/Snackbar/Snackbar.js +107 -105
  6. package/build/Snackbar/Snackbar.js.map +1 -1
  7. package/build/Snackbar/Snackbar.mjs +109 -104
  8. package/build/Snackbar/Snackbar.mjs.map +1 -1
  9. package/build/Snackbar/SnackbarContext.js.map +1 -1
  10. package/build/Snackbar/SnackbarContext.mjs.map +1 -1
  11. package/build/Snackbar/SnackbarPortal.js +12 -0
  12. package/build/Snackbar/SnackbarPortal.js.map +1 -0
  13. package/build/Snackbar/SnackbarPortal.mjs +8 -0
  14. package/build/Snackbar/SnackbarPortal.mjs.map +1 -0
  15. package/build/Snackbar/SnackbarProvider.js +23 -27
  16. package/build/Snackbar/SnackbarProvider.js.map +1 -1
  17. package/build/Snackbar/SnackbarProvider.mjs +24 -28
  18. package/build/Snackbar/SnackbarProvider.mjs.map +1 -1
  19. package/build/Snackbar/constants.js +8 -0
  20. package/build/Snackbar/constants.js.map +1 -0
  21. package/build/Snackbar/constants.mjs +5 -0
  22. package/build/Snackbar/constants.mjs.map +1 -0
  23. package/build/Snackbar/useSnackbarManager.js +119 -0
  24. package/build/Snackbar/useSnackbarManager.js.map +1 -0
  25. package/build/Snackbar/useSnackbarManager.mjs +115 -0
  26. package/build/Snackbar/useSnackbarManager.mjs.map +1 -0
  27. package/build/i18n/th.json +1 -1
  28. package/build/i18n/th.json.js +1 -1
  29. package/build/i18n/th.json.mjs +1 -1
  30. package/build/i18n/zh-CN.json +0 -1
  31. package/build/i18n/zh-CN.json.js +0 -1
  32. package/build/i18n/zh-CN.json.js.map +1 -1
  33. package/build/i18n/zh-CN.json.mjs +0 -1
  34. package/build/i18n/zh-CN.json.mjs.map +1 -1
  35. package/build/main.css +113 -61
  36. package/build/styles/Snackbar/Snackbar.css +116 -64
  37. package/build/styles/main.css +113 -61
  38. package/build/types/Body/Body.d.ts +2 -2
  39. package/build/types/IconButton/IconButton.d.ts +1 -1
  40. package/build/types/ListItem/ListItem.d.ts +0 -2
  41. package/build/types/ListItem/ListItem.d.ts.map +1 -1
  42. package/build/types/MoneyInput/MoneyInput.d.ts +1 -1
  43. package/build/types/MoneyInput/MoneyInput.d.ts.map +1 -1
  44. package/build/types/Snackbar/Snackbar.d.ts +10 -8
  45. package/build/types/Snackbar/Snackbar.d.ts.map +1 -1
  46. package/build/types/Snackbar/Snackbar.types.d.ts +19 -0
  47. package/build/types/Snackbar/Snackbar.types.d.ts.map +1 -0
  48. package/build/types/Snackbar/SnackbarContext.d.ts +2 -2
  49. package/build/types/Snackbar/SnackbarContext.d.ts.map +1 -1
  50. package/build/types/Snackbar/SnackbarPortal.d.ts +4 -0
  51. package/build/types/Snackbar/SnackbarPortal.d.ts.map +1 -0
  52. package/build/types/Snackbar/SnackbarProvider.d.ts.map +1 -1
  53. package/build/types/Snackbar/constants.d.ts +3 -0
  54. package/build/types/Snackbar/constants.d.ts.map +1 -0
  55. package/build/types/Snackbar/useSnackbar.d.ts +1 -1
  56. package/build/types/Snackbar/useSnackbar.d.ts.map +1 -1
  57. package/build/types/Snackbar/useSnackbarManager.d.ts +16 -0
  58. package/build/types/Snackbar/useSnackbarManager.d.ts.map +1 -0
  59. package/build/types/Title/Title.d.ts +2 -2
  60. package/build/types/Upload/Steps/UploadImageStep/UploadImageStep.d.ts +1 -1
  61. package/build/types/UploadInput/UploadItem/UploadItemLink.d.ts +1 -1
  62. package/package.json +3 -3
  63. package/src/ListItem/ListItem.test.tsx +0 -42
  64. package/src/ListItem/ListItem.tsx +2 -23
  65. package/src/Snackbar/Snackbar.css +116 -64
  66. package/src/Snackbar/Snackbar.less +121 -60
  67. package/src/Snackbar/Snackbar.test.tsx +122 -133
  68. package/src/Snackbar/Snackbar.tsx +95 -96
  69. package/src/Snackbar/Snackbar.types.ts +21 -0
  70. package/src/Snackbar/SnackbarContext.ts +2 -2
  71. package/src/Snackbar/SnackbarPortal.tsx +8 -0
  72. package/src/Snackbar/SnackbarProvider.test.tsx +289 -0
  73. package/src/Snackbar/SnackbarProvider.tsx +19 -18
  74. package/src/Snackbar/_stories/Snackbar.rtl.test.story.tsx +16 -6
  75. package/src/Snackbar/_stories/Snackbar.story.tsx +62 -1
  76. package/src/Snackbar/_stories/Snackbar.test.story.tsx +26 -5
  77. package/src/Snackbar/constants.ts +2 -0
  78. package/src/Snackbar/useSnackbarManager.ts +122 -0
  79. package/src/i18n/th.json +1 -1
  80. package/src/i18n/zh-CN.json +0 -1
  81. package/src/main.css +113 -61
  82. package/src/ListItem/ListItem.ssr.test.tsx +0 -115
package/src/main.css CHANGED
@@ -26174,83 +26174,135 @@ button.np-link {
26174
26174
  box-shadow: inset 1px 0 0 0 rgba(0,0,0,0.10196);
26175
26175
  box-shadow: inset 1px 0 0 0 var(--color-border-neutral);
26176
26176
  }
26177
- .snackbar {
26178
- text-align: center;
26177
+ .wds-Snackbar {
26178
+ display: flex;
26179
+ justify-content: center;
26180
+ box-sizing: border-box;
26181
+ padding-inline: 16px;
26182
+ padding-inline: var(--size-16);
26183
+ padding-block-end: calc(16px + env(safe-area-inset-bottom));
26184
+ padding-block-end: calc(var(--size-16) + env(safe-area-inset-bottom));
26179
26185
  position: fixed;
26180
26186
  inset-block-end: 0;
26181
- inset-inline-start: 0;
26182
- inset-inline-end: 0;
26187
+ inset-inline: 0;
26183
26188
  z-index: 1060;
26184
26189
  }
26185
- .snackbar__text {
26186
- background: #37517e;
26187
- color: #ffffff;
26188
- display: inline-flex;
26189
- border-radius: 2px;
26190
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
26191
- align-items: center;
26192
- justify-content: space-between;
26190
+ @media (min-width: 600px) {
26191
+ .wds-Snackbar {
26192
+ padding-block-end: 24px;
26193
+ padding-block-end: var(--size-24);
26194
+ }
26195
+ }
26196
+ .wds-Snackbar-container {
26197
+ --Prompt-border-radius: var(--radius-medium);
26198
+ --Prompt-gap: var(--size-8);
26199
+ --Prompt-padding-x: var(--size-12);
26200
+ --Prompt-padding-y: var(--size-12);
26201
+ box-sizing: border-box;
26202
+ max-inline-size: 480px;
26193
26203
  text-align: start;
26194
- font-size: 0.875rem;
26195
- font-size: var(--font-size-14);
26196
- margin-block: 0;
26197
- margin-inline: 16px;
26198
- margin-inline: var(--size-16);
26199
- padding-block: 8px;
26200
- padding-block: var(--size-8);
26201
- padding-inline: 16px;
26202
- padding-inline: var(--size-16);
26203
- inline-size: calc(100% - 32px);
26204
- inline-size: calc(100% - var(--size-32));
26205
- transition: 400ms cubic-bezier(0.215, 0.61, 0.355, 1);
26206
26204
  }
26207
- .np-theme-personal .snackbar__text {
26208
- box-shadow: 0 2px 4px 0 rgba(69, 71, 69, 0.35);
26209
- position: relative;
26210
- background: var(--color-contrast-theme);
26211
- border-radius: 10px;
26212
- border-radius: var(--radius-small);
26213
- color: var(--color-contrast-overlay);
26205
+ .wds-Snackbar-container .wds-prompt__content-wrapper--with-dismiss {
26206
+ grid-template-columns: auto minmax(0, 1fr);
26214
26207
  }
26215
- .np-theme-personal .snackbar__text::after {
26216
- display: block;
26217
- border-radius: inherit;
26218
- block-size: 100%;
26219
- inline-size: 100%;
26220
- content: "";
26221
- position: absolute;
26222
- inset-inline-start: 0;
26223
- inset-block-start: 0;
26224
- z-index: -1;
26225
- background-color: rgba(134,167,189,0.10196);
26226
- background-color: var(--color-background-neutral);
26208
+ @media (min-width: 600px) {
26209
+ .wds-Snackbar-container .wds-prompt__content-wrapper--with-dismiss {
26210
+ grid-template-columns: auto minmax(0, 1fr) auto;
26211
+ }
26227
26212
  }
26228
- .np-theme-personal--dark .snackbar__text,
26229
- .np-theme-personal--forest-green .snackbar__text {
26230
- box-shadow: none;
26213
+ .wds-Snackbar-container .wds-prompt__media-wrapper {
26214
+ display: flex;
26215
+ align-items: center;
26216
+ min-block-size: max(32px, 1lh);
26217
+ min-block-size: max(var(--size-32), 1lh);
26218
+ padding-block-start: 0;
26219
+ color: var(--color-sentiment-content-primary);
26220
+ }
26221
+ .wds-Snackbar-container .wds-prompt__media-wrapper:has(+ .wds-Snackbar__content .wds-Snackbar__action) {
26222
+ min-block-size: max(32px, calc(1lh + 5px * 2));
26223
+ min-block-size: max(var(--size-32), calc(1lh + var(--size-5) * 2));
26224
+ }
26225
+ .wds-Snackbar__media-asset {
26226
+ display: flex;
26227
+ }
26228
+ .wds-Snackbar__media-asset svg {
26229
+ inline-size: 24px;
26230
+ inline-size: var(--size-24);
26231
+ block-size: 24px;
26232
+ block-size: var(--size-24);
26233
+ }
26234
+ .wds-Snackbar-container .wds-prompt__dismiss {
26235
+ display: none;
26236
+ align-self: flex-start;
26237
+ margin-block-start: calc(4px - 1px);
26238
+ margin-block-start: calc(var(--size-4) - 1px);
26231
26239
  }
26232
26240
  @media (min-width: 600px) {
26233
- .snackbar__text {
26234
- inline-size: auto;
26235
- max-inline-size: 600px;
26241
+ .wds-Snackbar-container .wds-prompt__dismiss {
26242
+ display: flex;
26236
26243
  }
26237
26244
  }
26238
- .snackbar__text__action {
26245
+ .wds-Snackbar__action {
26239
26246
  flex-shrink: 0;
26240
- margin-inline-start: 16px;
26241
- margin-inline-start: var(--size-16);
26242
26247
  }
26243
- .snackbar__text-container-enter,
26244
- .snackbar__text-container-exit {
26245
- transform: translateY(calc(100% + 10px));
26248
+ .wds-Snackbar__content {
26249
+ display: flex;
26250
+ align-items: flex-start;
26251
+ gap: 8px;
26252
+ gap: var(--size-8);
26253
+ flex: 1 0 0;
26254
+ min-block-size: 32px;
26255
+ min-block-size: var(--size-32);
26256
+ min-inline-size: 0;
26246
26257
  }
26247
- .snackbar__text-container-enter-active {
26248
- transform: translateY(-16px);
26249
- transform: translateY(calc(-16px - env(safe-area-inset-bottom)));
26258
+ .wds-Snackbar__message {
26259
+ display: flex;
26260
+ flex-direction: column;
26261
+ justify-content: center;
26262
+ inline-size: auto;
26263
+ flex: 1 0 0;
26264
+ min-inline-size: 0;
26265
+ align-self: stretch;
26250
26266
  }
26251
- @media (min-width: 600px) {
26252
- .snackbar__text-container-enter-active {
26253
- transform: translateY(-24px);
26267
+ .wds-Snackbar__body {
26268
+ display: block;
26269
+ font-weight: 500;
26270
+ font-weight: var(--font-weight-medium);
26271
+ }
26272
+ .wds-Snackbar-container-appear,
26273
+ .wds-Snackbar-container-enter {
26274
+ opacity: 0;
26275
+ transform: translateY(80px) scale(0.5);
26276
+ }
26277
+ .wds-Snackbar-container-appear-active,
26278
+ .wds-Snackbar-container-enter-active {
26279
+ opacity: 1;
26280
+ transform: translateY(0) scale(1);
26281
+ transition: opacity 150ms linear, transform var(--Snackbar-enter-duration) cubic-bezier(0, 0, 0, 1);
26282
+ }
26283
+ .wds-Snackbar-container-exit {
26284
+ opacity: 1;
26285
+ transform: translateY(0) scale(1);
26286
+ }
26287
+ .wds-Snackbar-container-exit-active {
26288
+ opacity: 0;
26289
+ transform: translateY(80px) scale(0.5);
26290
+ transition: opacity 50ms linear 50ms, transform var(--Snackbar-exit-duration) cubic-bezier(1, 0, 1, 1);
26291
+ }
26292
+ @media (prefers-reduced-motion: reduce) {
26293
+ .wds-Snackbar-container-appear,
26294
+ .wds-Snackbar-container-appear-active,
26295
+ .wds-Snackbar-container-enter,
26296
+ .wds-Snackbar-container-enter-active,
26297
+ .wds-Snackbar-container-exit {
26298
+ opacity: 1;
26299
+ transform: none;
26300
+ transition: none;
26301
+ }
26302
+ .wds-Snackbar-container-exit-active {
26303
+ opacity: 0;
26304
+ transform: none;
26305
+ transition: none;
26254
26306
  }
26255
26307
  }
26256
26308
  .status-circle.negative,
@@ -1,115 +0,0 @@
1
- import { renderToString } from 'react-dom/server';
2
- import { render } from '@testing-library/react';
3
- import { Edit } from '@transferwise/icons';
4
- import { mockMatchMedia, within } from '../test-utils';
5
- import Provider from '../Provider';
6
- import en from '../i18n/en.json';
7
- import { ListItem } from './ListItem';
8
-
9
- mockMatchMedia();
10
-
11
- describe('ListItem server rendering and hydration', () => {
12
- beforeEach(() => {
13
- jest.spyOn(console, 'error').mockImplementation((message: string) => {
14
- // React 18 warns about the existing layout effects when rendering on the server.
15
- if (!message.startsWith('Warning: useLayoutEffect does nothing on the server')) {
16
- throw new Error(message);
17
- }
18
- });
19
- });
20
-
21
- afterEach(() => {
22
- jest.restoreAllMocks();
23
- });
24
-
25
- const controls = [
26
- { name: 'navigation link', control: <ListItem.Navigation href="/payments" /> },
27
- { name: 'navigation button', control: <ListItem.Navigation /> },
28
- {
29
- name: 'navigation without indicator',
30
- control: <ListItem.Navigation href="/payments" hideIndicator />,
31
- },
32
- { name: 'button', control: <ListItem.Button>Pay</ListItem.Button> },
33
- { name: 'button link', control: <ListItem.Button href="/payments">Pay</ListItem.Button> },
34
- {
35
- name: 'icon button',
36
- control: (
37
- <ListItem.IconButton aria-label="Edit">
38
- <Edit />
39
- </ListItem.IconButton>
40
- ),
41
- },
42
- {
43
- name: 'icon button link',
44
- control: (
45
- <ListItem.IconButton href="/payments" aria-label="Edit">
46
- <Edit />
47
- </ListItem.IconButton>
48
- ),
49
- },
50
- { name: 'checkbox', control: <ListItem.Checkbox /> },
51
- { name: 'radio', control: <ListItem.Radio name="payment" /> },
52
- { name: 'switch', control: <ListItem.Switch onClick={jest.fn()} /> },
53
- ];
54
-
55
- describe.each(['active', 'inactive'] as const)('%s spotlight', (spotlight) => {
56
- it.each(controls)(
57
- 'is present before hydration and unchanged afterwards for $name',
58
- ({ control }) => {
59
- const element = (
60
- <Provider i18n={{ locale: 'en-GB', messages: en }}>
61
- <ListItem title="Payments" spotlight={spotlight} control={control} />
62
- </Provider>
63
- );
64
- const container = document.createElement('div');
65
- container.innerHTML = renderToString(element);
66
- const item = within(container).getByRole('listitem');
67
- expect(item).toHaveClass(
68
- 'wds-list-item-interactive',
69
- 'wds-list-item-spotlight',
70
- `wds-list-item-spotlight-${spotlight}`,
71
- );
72
- expect(item.querySelector('.wds-list-item-spotlight__border') !== null).toBe(
73
- spotlight === 'inactive',
74
- );
75
- const serverMarkup = container.innerHTML;
76
-
77
- render(element, { container, hydrate: true });
78
-
79
- expect(within(container).getByRole('listitem')).toBe(item);
80
- expect(container.innerHTML).toBe(serverMarkup);
81
- },
82
- );
83
-
84
- it.each([
85
- { name: 'no control', control: undefined },
86
- {
87
- name: 'partial button',
88
- control: <ListItem.Button partiallyInteractive>Pay</ListItem.Button>,
89
- },
90
- {
91
- name: 'partial icon button',
92
- control: (
93
- <ListItem.IconButton partiallyInteractive aria-label="Edit">
94
- <Edit />
95
- </ListItem.IconButton>
96
- ),
97
- },
98
- ])('is absent before and after hydration for $name', ({ control }) => {
99
- const element = (
100
- <Provider i18n={{ locale: 'en-GB', messages: en }}>
101
- <ListItem title="Payments" spotlight={spotlight} control={control} />
102
- </Provider>
103
- );
104
- const container = document.createElement('div');
105
- container.innerHTML = renderToString(element);
106
- expect(within(container).getByRole('listitem')).not.toHaveClass('wds-list-item-spotlight');
107
- expect(container.querySelector('.wds-list-item-spotlight__border')).toBeNull();
108
- const serverMarkup = container.innerHTML;
109
-
110
- render(element, { container, hydrate: true });
111
-
112
- expect(container.innerHTML).toBe(serverMarkup);
113
- });
114
- });
115
- });