@transferwise/components 0.0.0-experimental-fa9fbe9 → 0.0.0-experimental-162ecb1

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 (152) hide show
  1. package/build/common/hooks/useResizeObserver.js +3 -3
  2. package/build/common/hooks/useResizeObserver.js.map +1 -1
  3. package/build/common/hooks/useResizeObserver.mjs +3 -3
  4. package/build/common/hooks/useResizeObserver.mjs.map +1 -1
  5. package/build/criticalBanner/CriticalCommsBanner.js +0 -3
  6. package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
  7. package/build/criticalBanner/CriticalCommsBanner.mjs +0 -3
  8. package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
  9. package/build/field/Field.js +2 -3
  10. package/build/field/Field.js.map +1 -1
  11. package/build/field/Field.mjs +2 -3
  12. package/build/field/Field.mjs.map +1 -1
  13. package/build/i18n/en.json +0 -2
  14. package/build/i18n/en.json.js +0 -2
  15. package/build/i18n/en.json.js.map +1 -1
  16. package/build/i18n/en.json.mjs +0 -2
  17. package/build/i18n/en.json.mjs.map +1 -1
  18. package/build/index.js +0 -2
  19. package/build/index.js.map +1 -1
  20. package/build/index.mjs +0 -1
  21. package/build/index.mjs.map +1 -1
  22. package/build/listItem/Prompt/ListItemPrompt.js +2 -3
  23. package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
  24. package/build/listItem/Prompt/ListItemPrompt.mjs +2 -3
  25. package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
  26. package/build/logo/Logo.js +70 -25
  27. package/build/logo/Logo.js.map +1 -1
  28. package/build/logo/Logo.mjs +72 -27
  29. package/build/logo/Logo.mjs.map +1 -1
  30. package/build/logo/logo-assets.js +68 -97
  31. package/build/logo/logo-assets.js.map +1 -1
  32. package/build/logo/logo-assets.mjs +62 -90
  33. package/build/logo/logo-assets.mjs.map +1 -1
  34. package/build/main.css +32 -224
  35. package/build/prompt/ActionPrompt/ActionPrompt.js +40 -8
  36. package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
  37. package/build/prompt/ActionPrompt/ActionPrompt.mjs +40 -8
  38. package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
  39. package/build/prompt/PrimitivePrompt/PrimitivePrompt.js +4 -11
  40. package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
  41. package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs +4 -11
  42. package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
  43. package/build/styles/logo/Logo.css +3 -24
  44. package/build/styles/main.css +32 -224
  45. package/build/table/Table.js +6 -5
  46. package/build/table/Table.js.map +1 -1
  47. package/build/table/Table.mjs +6 -5
  48. package/build/table/Table.mjs.map +1 -1
  49. package/build/typeahead/Typeahead.js +2 -3
  50. package/build/typeahead/Typeahead.js.map +1 -1
  51. package/build/typeahead/Typeahead.mjs +2 -3
  52. package/build/typeahead/Typeahead.mjs.map +1 -1
  53. package/build/types/common/hooks/useResizeObserver.d.ts +1 -1
  54. package/build/types/common/hooks/useResizeObserver.d.ts.map +1 -1
  55. package/build/types/criticalBanner/CriticalCommsBanner.d.ts +0 -3
  56. package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
  57. package/build/types/index.d.ts +2 -2
  58. package/build/types/index.d.ts.map +1 -1
  59. package/build/types/logo/Logo.d.ts +32 -1
  60. package/build/types/logo/Logo.d.ts.map +1 -1
  61. package/build/types/logo/logo-assets.d.ts +33 -9
  62. package/build/types/logo/logo-assets.d.ts.map +1 -1
  63. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +11 -2
  64. package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
  65. package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +3 -35
  66. package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
  67. package/build/types/prompt/index.d.ts +0 -2
  68. package/build/types/prompt/index.d.ts.map +1 -1
  69. package/build/types/table/Table.d.ts.map +1 -1
  70. package/build/types/test-utils/index.d.ts +0 -4
  71. package/build/types/test-utils/index.d.ts.map +1 -1
  72. package/package.json +3 -3
  73. package/src/common/bottomSheet/BottomSheet.test.story.tsx +6 -5
  74. package/src/common/hooks/useResizeObserver.ts +2 -3
  75. package/src/criticalBanner/CriticalCommsBanner.story.tsx +0 -4
  76. package/src/criticalBanner/CriticalCommsBanner.test.story.tsx +1 -1
  77. package/src/criticalBanner/CriticalCommsBanner.tsx +0 -3
  78. package/src/i18n/en.json +0 -2
  79. package/src/index.ts +2 -2
  80. package/src/logo/Logo.css +3 -24
  81. package/src/logo/Logo.less +3 -30
  82. package/src/logo/Logo.story.tsx +123 -89
  83. package/src/logo/Logo.test.story.tsx +12 -23
  84. package/src/logo/Logo.tsx +87 -28
  85. package/src/logo/logo-assets.tsx +36 -92
  86. package/src/main.css +32 -224
  87. package/src/main.less +1 -3
  88. package/src/prompt/ActionPrompt/ActionPrompt.tsx +62 -9
  89. package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +40 -56
  90. package/src/prompt/index.ts +0 -4
  91. package/src/sentimentSurface/SentimentSurface.story.tsx +17 -43
  92. package/src/table/Table.story.tsx +1 -1
  93. package/src/table/Table.tsx +6 -5
  94. package/build/common/hooks/useContainerSize.js +0 -30
  95. package/build/common/hooks/useContainerSize.js.map +0 -1
  96. package/build/common/hooks/useContainerSize.mjs +0 -28
  97. package/build/common/hooks/useContainerSize.mjs.map +0 -1
  98. package/build/prompt/CriticalBanner/CriticalBanner.js +0 -142
  99. package/build/prompt/CriticalBanner/CriticalBanner.js.map +0 -1
  100. package/build/prompt/CriticalBanner/CriticalBanner.mjs +0 -140
  101. package/build/prompt/CriticalBanner/CriticalBanner.mjs.map +0 -1
  102. package/build/prompt/CriticalBanner/helpers.js +0 -29
  103. package/build/prompt/CriticalBanner/helpers.js.map +0 -1
  104. package/build/prompt/CriticalBanner/helpers.mjs +0 -26
  105. package/build/prompt/CriticalBanner/helpers.mjs.map +0 -1
  106. package/build/prompt/common/Expander/Expander.js +0 -35
  107. package/build/prompt/common/Expander/Expander.js.map +0 -1
  108. package/build/prompt/common/Expander/Expander.messages.js +0 -17
  109. package/build/prompt/common/Expander/Expander.messages.js.map +0 -1
  110. package/build/prompt/common/Expander/Expander.messages.mjs +0 -13
  111. package/build/prompt/common/Expander/Expander.messages.mjs.map +0 -1
  112. package/build/prompt/common/Expander/Expander.mjs +0 -33
  113. package/build/prompt/common/Expander/Expander.mjs.map +0 -1
  114. package/build/prompt/helpers/promptMedia.js +0 -52
  115. package/build/prompt/helpers/promptMedia.js.map +0 -1
  116. package/build/prompt/helpers/promptMedia.mjs +0 -50
  117. package/build/prompt/helpers/promptMedia.mjs.map +0 -1
  118. package/build/styles/prompt/CriticalBanner/CriticalBanner.css +0 -134
  119. package/build/styles/prompt/CriticalBanner/CriticalBanner.vars.css +0 -0
  120. package/build/styles/prompt/common/Expander/Expander.css +0 -8
  121. package/build/types/common/hooks/useContainerSize.d.ts +0 -14
  122. package/build/types/common/hooks/useContainerSize.d.ts.map +0 -1
  123. package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts +0 -39
  124. package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts.map +0 -1
  125. package/build/types/prompt/CriticalBanner/helpers.d.ts +0 -18
  126. package/build/types/prompt/CriticalBanner/helpers.d.ts.map +0 -1
  127. package/build/types/prompt/CriticalBanner/index.d.ts +0 -3
  128. package/build/types/prompt/CriticalBanner/index.d.ts.map +0 -1
  129. package/build/types/prompt/common/Expander/Expander.d.ts +0 -20
  130. package/build/types/prompt/common/Expander/Expander.d.ts.map +0 -1
  131. package/build/types/prompt/common/Expander/Expander.messages.d.ts +0 -14
  132. package/build/types/prompt/common/Expander/Expander.messages.d.ts.map +0 -1
  133. package/build/types/prompt/helpers/promptMedia.d.ts +0 -22
  134. package/build/types/prompt/helpers/promptMedia.d.ts.map +0 -1
  135. package/src/common/hooks/useContainerSize.test.tsx +0 -121
  136. package/src/common/hooks/useContainerSize.ts +0 -32
  137. package/src/prompt/CriticalBanner/CriticalBanner.accessibility.docs.mdx +0 -113
  138. package/src/prompt/CriticalBanner/CriticalBanner.css +0 -134
  139. package/src/prompt/CriticalBanner/CriticalBanner.less +0 -155
  140. package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +0 -635
  141. package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +0 -422
  142. package/src/prompt/CriticalBanner/CriticalBanner.tsx +0 -178
  143. package/src/prompt/CriticalBanner/CriticalBanner.vars.css +0 -0
  144. package/src/prompt/CriticalBanner/CriticalBanner.vars.less +0 -6
  145. package/src/prompt/CriticalBanner/helpers.ts +0 -39
  146. package/src/prompt/CriticalBanner/index.ts +0 -2
  147. package/src/prompt/common/Expander/Expander.css +0 -8
  148. package/src/prompt/common/Expander/Expander.less +0 -9
  149. package/src/prompt/common/Expander/Expander.messages.ts +0 -14
  150. package/src/prompt/common/Expander/Expander.test.tsx +0 -167
  151. package/src/prompt/common/Expander/Expander.tsx +0 -83
  152. package/src/prompt/helpers/promptMedia.tsx +0 -79
package/src/main.css CHANGED
@@ -31066,36 +31066,9 @@ button.np-link {
31066
31066
  }
31067
31067
 
31068
31068
  .np-logo {
31069
- display: inline-block;
31070
- }
31071
-
31072
- .np-theme-personal--forest-green .np-logo-svg path,
31073
- .np-theme-personal--bright-green .np-logo-svg path {
31074
- fill: var(--color-interactive-primary);
31075
- }
31076
-
31077
- .np-theme-personal--dark .np-logo-svg path {
31078
- fill: var(--color-white);
31079
- }
31080
-
31081
- .np-logo-svg--size-sm {
31082
- display: block;
31083
- }
31084
-
31085
- @media (min-width: 576px) {
31086
- .np-logo-svg--size-sm {
31087
- display: none;
31088
- }
31089
- }
31090
-
31091
- .np-logo-svg--size-md {
31092
- display: none;
31093
- }
31094
-
31095
- @media (min-width: 576px) {
31096
- .np-logo-svg--size-md {
31097
- display: block;
31098
- }
31069
+ color: var(--color-interactive-primary);
31070
+ width: var(--wds-logo-width);
31071
+ height: var(--wds-logo-height);
31099
31072
  }
31100
31073
 
31101
31074
  .tw-modal--scrollable {
@@ -32233,200 +32206,6 @@ html:not([dir="rtl"]) .np-navigation-option {
32233
32206
  padding: 0;
32234
32207
  }
32235
32208
 
32236
- .wds-action-prompt {
32237
- --Prompt-padding: var(--size-16);
32238
- --Prompt-actions-gap: var(--size-8);
32239
- --Prompt-gap: var(--size-10) var(--size-16);
32240
- --Prompt-border-radius: var(--radius-large);
32241
- }
32242
-
32243
- .wds-action-prompt--media-image {
32244
- width: 48px;
32245
- width: var(--size-48);
32246
- height: 48px;
32247
- height: var(--size-48);
32248
- -o-object-fit: contain;
32249
- object-fit: contain;
32250
- }
32251
-
32252
- @media (max-width: 767px) {
32253
- .wds-action-prompt--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
32254
- flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
32255
- min-width: -moz-fit-content;
32256
- min-width: fit-content;
32257
- }
32258
- }
32259
-
32260
- .wds-action-prompt__content {
32261
- max-width: calc(48px * 10);
32262
- max-width: calc(var(--size-48) * 10);
32263
- }
32264
-
32265
- .wds-critical-banner {
32266
- --Prompt-padding: var(--size-16);
32267
- --Prompt-actions-gap: var(--size-8);
32268
- --Prompt-gap: var(--size-10) var(--size-16);
32269
- --Prompt-border-radius: 0;
32270
- container-type: inline-size;
32271
- --critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
32272
- --critical-banner-duration: 150ms;
32273
- /* Override PrimitivePrompt's --screen-sm-max actions behaviour:
32274
- actions only go full-width below mobile-max token (container query) */
32275
- }
32276
-
32277
- .wds-critical-banner--media-image {
32278
- width: 48px;
32279
- width: var(--size-48);
32280
- height: 48px;
32281
- height: var(--size-48);
32282
- -o-object-fit: contain;
32283
- object-fit: contain;
32284
- }
32285
-
32286
- .wds-critical-banner__title {
32287
- display: -webkit-box;
32288
- -webkit-line-clamp: 8;
32289
- line-clamp: 8;
32290
- -webkit-box-orient: vertical;
32291
- max-height: 192px;
32292
- overflow: hidden;
32293
- transition: max-height var(--critical-banner-duration) var(--critical-banner-easing);
32294
- }
32295
-
32296
- .wds-critical-banner--collapsed .wds-critical-banner__title {
32297
- -webkit-line-clamp: 2;
32298
- line-clamp: 2;
32299
- max-height: 48px;
32300
- }
32301
-
32302
- .wds-critical-banner__description {
32303
- max-height: 30vh;
32304
- opacity: 1;
32305
- overflow: hidden;
32306
- transition: max-height var(--critical-banner-duration) var(--critical-banner-easing), opacity var(--critical-banner-duration) var(--critical-banner-easing);
32307
- }
32308
-
32309
- .wds-critical-banner--collapsed .wds-critical-banner__description--with-title {
32310
- max-height: 0;
32311
- opacity: 0;
32312
- }
32313
-
32314
- .wds-critical-banner--collapsed .wds-critical-banner__description:not(.wds-critical-banner__description--with-title) {
32315
- display: -webkit-box;
32316
- -webkit-line-clamp: 2;
32317
- line-clamp: 2;
32318
- -webkit-box-orient: vertical;
32319
- overflow: hidden;
32320
- }
32321
-
32322
- .wds-critical-banner .wds-prompt__content-wrapper {
32323
- grid-template-columns: auto 1fr auto;
32324
- align-items: flex-start;
32325
- transition: row-gap var(--critical-banner-duration) var(--critical-banner-easing);
32326
- }
32327
-
32328
- .wds-critical-banner--collapsed .wds-prompt__content-wrapper {
32329
- row-gap: 0;
32330
- }
32331
-
32332
- .wds-critical-banner__text-wrapper {
32333
- position: relative;
32334
- display: flex;
32335
- flex-direction: column;
32336
- justify-content: center;
32337
- align-items: flex-start;
32338
- text-align: start;
32339
- min-width: 0;
32340
- max-width: 480px;
32341
- height: 100%;
32342
- padding-top: 3px;
32343
- }
32344
-
32345
- @media (max-width: 320px) {
32346
- .wds-critical-banner__text-wrapper {
32347
- padding-top: 0;
32348
- }
32349
- }
32350
-
32351
- @container (--screen-400-zoom) {
32352
- .wds-critical-banner__text-wrapper {
32353
- padding-top: 0px;
32354
- }
32355
- }
32356
-
32357
- .wds-critical-banner--collapsed .wds-critical-banner__title,
32358
- .wds-critical-banner--collapsed .wds-critical-banner__description {
32359
- transform: translateY(0);
32360
- }
32361
-
32362
- .wds-critical-banner__toggle {
32363
- flex-shrink: 0;
32364
- transition: transform var(--critical-banner-duration) var(--critical-banner-easing);
32365
- }
32366
-
32367
- .wds-critical-banner__toggle--collapsed {
32368
- transform: rotate(180deg);
32369
- }
32370
-
32371
- @container (min-width: 768px) {
32372
- .wds-critical-banner__toggle {
32373
- display: none;
32374
- }
32375
- }
32376
-
32377
- .wds-critical-banner .wds-prompt__actions-wrapper {
32378
- grid-column-start: 2;
32379
- grid-column-end: 3;
32380
- max-height: 200px;
32381
- opacity: 1;
32382
- overflow: visible;
32383
- }
32384
-
32385
- @container (max-width: 600px) {
32386
- .wds-critical-banner .wds-prompt__actions-wrapper {
32387
- grid-column: span 3;
32388
- width: 100%;
32389
- }
32390
- .wds-critical-banner .wds-prompt__actions-wrapper .wds-Button {
32391
- flex: 1 1 100%;
32392
- width: 100%;
32393
- }
32394
- }
32395
-
32396
- .wds-critical-banner--collapsed .wds-prompt__actions-wrapper {
32397
- max-height: 0;
32398
- opacity: 0;
32399
- overflow: hidden;
32400
- pointer-events: none;
32401
- }
32402
-
32403
- @container (max-width: 600px) {
32404
- .wds-critical-banner--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
32405
- flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
32406
- min-width: -moz-fit-content;
32407
- min-width: fit-content;
32408
- }
32409
- }
32410
-
32411
- @media (prefers-reduced-motion: reduce) {
32412
- .wds-critical-banner__description,
32413
- .wds-critical-banner__title,
32414
- .wds-critical-banner .wds-prompt__content-wrapper,
32415
- .wds-critical-banner__toggle {
32416
- transition: none !important;
32417
- }
32418
- }
32419
-
32420
- .wds-expander-toggle {
32421
- align-self: flex-start;
32422
- flex-shrink: 0;
32423
- transition: transform 0.2s ease-in-out;
32424
- }
32425
-
32426
- .wds-expander-toggle--collapsed {
32427
- transform: rotate(180deg);
32428
- }
32429
-
32430
32209
  .wds-radio-group .np-radio:last-child label {
32431
32210
  margin-bottom: 0;
32432
32211
  }
@@ -34852,3 +34631,32 @@ html:not([dir="rtl"]) .np-navigation-option {
34852
34631
  .np-list-item__action {
34853
34632
  flex-shrink: 0;
34854
34633
  }
34634
+
34635
+ .wds-action-prompt {
34636
+ --Prompt-padding: var(--size-16);
34637
+ --Prompt-actions-gap: var(--size-8);
34638
+ --Prompt-gap: var(--size-10) var(--size-16);
34639
+ --Prompt-border-radius: var(--radius-large);
34640
+ }
34641
+
34642
+ .wds-action-prompt--media-image {
34643
+ width: 48px;
34644
+ width: var(--size-48);
34645
+ height: 48px;
34646
+ height: var(--size-48);
34647
+ -o-object-fit: contain;
34648
+ object-fit: contain;
34649
+ }
34650
+
34651
+ @media (max-width: 767px) {
34652
+ .wds-action-prompt--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
34653
+ flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
34654
+ min-width: -moz-fit-content;
34655
+ min-width: fit-content;
34656
+ }
34657
+ }
34658
+
34659
+ .wds-action-prompt__content {
34660
+ max-width: calc(48px * 10);
34661
+ max-width: calc(var(--size-48) * 10);
34662
+ }
package/src/main.less CHANGED
@@ -67,9 +67,6 @@
67
67
  @import "./prompt/PrimitivePrompt/PrimitivePrompt.less";
68
68
  @import "./prompt/InlinePrompt/InlinePrompt.less";
69
69
  @import "./prompt/InfoPrompt/InfoPrompt.less";
70
- @import "./prompt/ActionPrompt/ActionPrompt.less";
71
- @import "./prompt/CriticalBanner/CriticalBanner.less";
72
- @import "./prompt/common/Expander/Expander.less";
73
70
  @import "./radioGroup/RadioGroup.less";
74
71
  @import "./section/Section.less";
75
72
  @import "./slidingPanel/SlidingPanel.less";
@@ -94,6 +91,7 @@
94
91
  @import "./progress/Progress.less";
95
92
  @import "./progressBar/ProgressBar.less";
96
93
  @import "./legacylistItem/LegacyListItem.less";
94
+ @import "./prompt/ActionPrompt/ActionPrompt.less";
97
95
 
98
96
  // List all less files in src in alphabetical order: find -s src -type f -name '*.less' ! -name 'main.less'
99
97
  // Make sure you are not referencing main.less itself in this file!
@@ -1,19 +1,31 @@
1
1
  import { AriaAttributes, ReactNode, useId } from 'react';
2
2
  import { clsx } from 'clsx';
3
3
 
4
+ import StatusIcon from '../../statusIcon';
4
5
  import Body from '../../body';
5
6
  import Button from '../../button';
6
7
  import { Breakpoint, Typography } from '../../common';
8
+ import AvatarView, { AvatarViewProps } from '../../avatarView';
9
+ import Image from '../../image';
7
10
  import { ButtonProps } from '../../button/Button.types';
8
11
  import { PrimitivePrompt, PrimitivePromptProps } from '../PrimitivePrompt';
12
+ import { BadgeAssetsProps } from '../../badge';
13
+ import { GiftBox } from '@transferwise/icons';
9
14
  import { useScreenSize } from '../../common/hooks/useScreenSize';
10
- import { renderPromptMedia, PromptMedia } from '../helpers/promptMedia';
11
15
 
12
16
  export type ActionPromptProps = {
13
17
  title: ReactNode;
14
18
  description?: ReactNode;
15
19
  /** @default {} */
16
- media?: PromptMedia;
20
+ media?: {
21
+ imgSrc?: string;
22
+ avatar?: Pick<AvatarViewProps, 'imgSrc' | 'profileName' | 'profileType'> & {
23
+ asset?: AvatarViewProps['children'];
24
+ badge?: Pick<BadgeAssetsProps, 'flagCode'>;
25
+ };
26
+ 'aria-label'?: string;
27
+ 'aria-hidden'?: boolean;
28
+ };
17
29
  action: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {
18
30
  label: ButtonProps['children'];
19
31
  };
@@ -62,13 +74,54 @@ export const ActionPrompt = ({
62
74
  .filter(Boolean)
63
75
  .join(' ');
64
76
 
65
- const renderMedia = () =>
66
- renderPromptMedia({
67
- media,
68
- sentiment,
69
- mediaId,
70
- imgClassName: 'wds-action-prompt--media-image',
71
- });
77
+ const renderMedia = () => {
78
+ if (media?.imgSrc) {
79
+ return (
80
+ <Image
81
+ id={mediaId}
82
+ src={media.imgSrc}
83
+ className="wds-action-prompt--media-image"
84
+ alt={media['aria-label'] ?? ''}
85
+ />
86
+ );
87
+ }
88
+ if (media?.avatar) {
89
+ const badge = media.avatar.badge
90
+ ? media.avatar.badge
91
+ : sentiment === 'proposition'
92
+ ? {}
93
+ : { status: sentiment };
94
+ return (
95
+ <AvatarView
96
+ {...media.avatar}
97
+ badge={badge}
98
+ aria-label={media['aria-label']}
99
+ aria-hidden={media['aria-hidden']}
100
+ id={mediaId}
101
+ size={48}
102
+ >
103
+ {media.avatar.asset}
104
+ </AvatarView>
105
+ );
106
+ }
107
+ return sentiment === 'proposition' ? (
108
+ <AvatarView
109
+ id={mediaId}
110
+ size={48}
111
+ aria-label={media['aria-label']}
112
+ aria-hidden={media['aria-hidden']}
113
+ >
114
+ <GiftBox />
115
+ </AvatarView>
116
+ ) : (
117
+ <StatusIcon
118
+ id={mediaId}
119
+ size={48}
120
+ sentiment={sentiment}
121
+ iconLabel={media['aria-hidden'] ? null : media['aria-label']}
122
+ />
123
+ );
124
+ };
72
125
 
73
126
  return (
74
127
  <PrimitivePrompt
@@ -1,22 +1,17 @@
1
1
  import { Cross } from '@transferwise/icons';
2
2
  import { clsx } from 'clsx';
3
- import SentimentSurface, { Emphasis, Sentiment } from '../../sentimentSurface';
3
+ 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 { forwardRef, HTMLAttributes, ReactNode } from 'react';
7
+ import { HTMLAttributes, ReactNode } from 'react';
8
8
 
9
9
  export type PrimitivePromptProps = HTMLAttributes<HTMLDivElement> & {
10
10
  /**
11
- * The sentiment determines the colour scheme.
11
+ * The sentiment determines the colour scheme
12
12
  * @default success
13
13
  */
14
14
  sentiment?: Sentiment;
15
- /**
16
- * The emphasis level affecting background and text contrast.
17
- * @default 'base
18
- */
19
- emphasis?: Emphasis;
20
15
  /**
21
16
  * Media to be displayed on the prompt (icon/image/etc).
22
17
  */
@@ -38,53 +33,42 @@ export type PrimitivePromptProps = HTMLAttributes<HTMLDivElement> & {
38
33
  /**
39
34
  * PrimitivePrompt is a low-level component that provides the structure, sentiment support and styling for various prompts.
40
35
  * Uses several css variables to handle styling from within the consuming component, e.g. --Prompt-padding. */
41
- export const PrimitivePrompt = forwardRef<HTMLDivElement, PrimitivePromptProps>(
42
- (
43
- {
44
- sentiment = 'success',
45
- emphasis = 'base',
46
- media,
47
- actions,
48
- onDismiss,
49
- className,
50
- children,
51
- ...restProps
52
- },
53
- ref,
54
- ) => {
55
- const intl = useIntl();
36
+ export const PrimitivePrompt = ({
37
+ sentiment = 'success',
38
+ media,
39
+ actions,
40
+ onDismiss,
41
+ className,
42
+ children,
43
+ ...restProps
44
+ }: PrimitivePromptProps) => {
45
+ const intl = useIntl();
56
46
 
57
- return (
58
- <SentimentSurface
59
- // @ts-expect-error - SentimentSurface forwardRef types don't expose ref in props
60
- ref={ref}
61
- sentiment={sentiment}
62
- emphasis={emphasis}
63
- className={clsx('wds-prompt', `wds-prompt--${sentiment}`, className)}
64
- {...restProps}
47
+ return (
48
+ <SentimentSurface
49
+ sentiment={sentiment}
50
+ className={clsx('wds-prompt', `wds-prompt--${sentiment}`, className)}
51
+ {...restProps}
52
+ >
53
+ <div
54
+ className={clsx('wds-prompt__content-wrapper', {
55
+ 'wds-prompt__content-wrapper--with-dismiss': !!onDismiss,
56
+ })}
65
57
  >
66
- <div
67
- className={clsx('wds-prompt__content-wrapper', {
68
- 'wds-prompt__content-wrapper--with-dismiss': !!onDismiss,
69
- })}
70
- >
71
- <div className={clsx('wds-prompt__media-wrapper')}>{media}</div>
72
- {children}
73
- {onDismiss && (
74
- <IconButton
75
- size={24}
76
- priority="secondary"
77
- aria-label={intl.formatMessage(closeBtnMessages.ariaLabel)}
78
- onClick={onDismiss}
79
- >
80
- <Cross />
81
- </IconButton>
82
- )}
83
- {actions && <div className="wds-prompt__actions-wrapper">{actions}</div>}
84
- </div>
85
- </SentimentSurface>
86
- );
87
- },
88
- );
89
-
90
- PrimitivePrompt.displayName = 'PrimitivePrompt';
58
+ <div className={clsx('wds-prompt__media-wrapper')}>{media}</div>
59
+ {children}
60
+ {onDismiss && (
61
+ <IconButton
62
+ size={24}
63
+ priority="secondary"
64
+ aria-label={intl.formatMessage(closeBtnMessages.ariaLabel)}
65
+ onClick={onDismiss}
66
+ >
67
+ <Cross />
68
+ </IconButton>
69
+ )}
70
+ {actions && <div className="wds-prompt__actions-wrapper">{actions}</div>}
71
+ </div>
72
+ </SentimentSurface>
73
+ );
74
+ };
@@ -12,7 +12,3 @@ export { ActionPrompt } from './ActionPrompt';
12
12
  // InfoPrompt
13
13
  export type { InfoPromptProps, InfoPromptAction, InfoPromptMedia } from './InfoPrompt';
14
14
  export { InfoPrompt } from './InfoPrompt';
15
-
16
- // CriticalBanner
17
- export type { CriticalBannerProps } from './CriticalBanner';
18
- export { CriticalBanner } from './CriticalBanner';
@@ -202,26 +202,18 @@ const TokenSwatch = ({ token }: { token: string }) => (
202
202
  export const EmphasisLevels: Story = {
203
203
  render: (args) => (
204
204
  <>
205
- {sentiments.map((sentiment) => (
206
- <div key={sentiment}>
207
- <SentimentSurface
208
- key={`${sentiment}-base`}
209
- {...args}
210
- sentiment={sentiment}
211
- emphasis="base"
212
- >
213
- <div className="p-a-2 text-capitalize">{sentiment} - Base emphasis</div>
214
- </SentimentSurface>
215
- <SentimentSurface
216
- key={`${sentiment}-elevated`}
217
- {...args}
218
- sentiment={sentiment}
219
- emphasis="elevated"
220
- >
221
- <div className="p-a-2 text-capitalize">{sentiment} - Elevated emphasis</div>
222
- </SentimentSurface>
223
- </div>
224
- ))}
205
+ <SentimentSurface {...args} sentiment="negative" emphasis="base">
206
+ <div className="p-a-2">Negative - Base emphasis</div>
207
+ </SentimentSurface>
208
+ <SentimentSurface {...args} sentiment="negative" emphasis="elevated">
209
+ <div className="p-a-2">Negative - Elevated emphasis</div>
210
+ </SentimentSurface>
211
+ <SentimentSurface {...args} sentiment="success" emphasis="base">
212
+ <div className="p-a-2">Success - Base emphasis</div>
213
+ </SentimentSurface>
214
+ <SentimentSurface {...args} sentiment="success" emphasis="elevated">
215
+ <div className="p-a-2">Success - Elevated emphasis</div>
216
+ </SentimentSurface>
225
217
  </>
226
218
  ),
227
219
  parameters: {
@@ -377,8 +369,8 @@ export const SentimentAwareComponents: Story = {
377
369
  {STATUS_NEGATIVE}
378
370
  </div>
379
371
 
380
- <Header level="group" title="Success sentiment surface - Base emphasis" />
381
- <SentimentSurface sentiment="success" emphasis="base">
372
+ <Header level="group" title="Success sentiment surface" />
373
+ <SentimentSurface sentiment="success">
382
374
  <div className="p-a-2 m-b-2 sentimentAwareComponent">
383
375
  {BODY}
384
376
  {AVATAR_SUCCESS}
@@ -386,26 +378,8 @@ export const SentimentAwareComponents: Story = {
386
378
  </div>
387
379
  </SentimentSurface>
388
380
 
389
- <Header level="group" title="Success sentiment surface - Elevated emphasis" />
390
- <SentimentSurface sentiment="success" emphasis="elevated">
391
- <div className="p-a-2 m-b-2 sentimentAwareComponent">
392
- {BODY}
393
- {AVATAR_SUCCESS}
394
- {STATUS_SUCCESS}
395
- </div>
396
- </SentimentSurface>
397
-
398
- <Header level="group" title="Negative sentiment surface - Base emphasis" />
399
- <SentimentSurface sentiment="negative" emphasis="base">
400
- <div className="p-a-2 m-b-2 sentimentAwareComponent">
401
- {BODY}
402
- {AVATAR_NEGATIVE}
403
- {STATUS_NEGATIVE}
404
- </div>
405
- </SentimentSurface>
406
-
407
- <Header level="group" title="Negative sentiment surface - Elevated emphasis" />
408
- <SentimentSurface sentiment="negative" emphasis="elevated">
381
+ <Header level="group" title="Negative sentiment surface" />
382
+ <SentimentSurface sentiment="negative">
409
383
  <div className="p-a-2 m-b-2 sentimentAwareComponent">
410
384
  {BODY}
411
385
  {AVATAR_NEGATIVE}
@@ -453,7 +427,7 @@ function CustomCard({ children, className }: { className?: string; children: Rea
453
427
 
454
428
  export const CustomComponents: Story = {
455
429
  tags: ['!autodocs', '!dev'],
456
- render: () => (
430
+ render: (args) => (
457
431
  <>
458
432
  <style>{`
459
433
  .custom-card {
@@ -400,7 +400,7 @@ export const WithError: Story = {
400
400
  error: {
401
401
  message: 'Something went wrong during data fetching',
402
402
  action: {
403
- href: '/?path=/story/option-table--with-error',
403
+ href: '/?path=/story/content-table--with-error',
404
404
  text: 'To Refresh page, click here',
405
405
  },
406
406
  },
@@ -2,7 +2,7 @@ import { useIntl } from 'react-intl';
2
2
  import TableCell from './TableCell';
3
3
  import TableHeader, { TableHeaderType } from './TableHeader';
4
4
  import TableRow, { TableRowClickableType, TableRowType } from './TableRow';
5
- import Alert from '../alert';
5
+ import { InfoPrompt } from '../prompt/InfoPrompt';
6
6
 
7
7
  import messages from './Table.messages';
8
8
  import Loader from '../loader';
@@ -87,13 +87,14 @@ const Table = ({
87
87
 
88
88
  if (error) {
89
89
  return (
90
- <Alert
90
+ <InfoPrompt
91
91
  className="np-table-error"
92
- message={error.message}
93
- type={Sentiment.NEGATIVE}
92
+ aria-live="assertive"
93
+ description={error.message ?? ''}
94
+ sentiment="negative"
94
95
  action={{
95
96
  href: error?.action?.href ?? '/',
96
- text: error?.action?.text ?? formatMessage(messages.refreshPage),
97
+ label: error?.action?.text ?? formatMessage(messages.refreshPage),
97
98
  }}
98
99
  data-testid="np-table-error"
99
100
  />
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var useResizeObserver = require('./useResizeObserver.js');
5
-
6
- /**
7
- * Hook that returns a ref and a boolean indicating if the container
8
- * has a width >= the specified breakpoint.
9
- *
10
- * Useful for synchronizing React state with CSS container queries.
11
- *
12
- * Uses content-box measurements to match CSS container query behavior
13
- * (excludes padding and border).
14
- *
15
- * @param breakpoint - Minimum width in pixels
16
- * @returns [ref, isAboveBreakpoint] tuple
17
- */
18
- function useContainerSize(breakpoint) {
19
- const ref = React.useRef(null);
20
- const [isAboveBreakpoint, setIsAboveBreakpoint] = React.useState(false);
21
- useResizeObserver.useResizeObserver(ref, entry => {
22
- // Use contentRect.width to match CSS container query box model (content-box)
23
- const inlineSize = entry.contentRect.width;
24
- setIsAboveBreakpoint(inlineSize >= breakpoint);
25
- }, 'content-box');
26
- return [ref, isAboveBreakpoint];
27
- }
28
-
29
- exports.useContainerSize = useContainerSize;
30
- //# sourceMappingURL=useContainerSize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useContainerSize.js","sources":["../../../src/common/hooks/useContainerSize.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\nimport { useResizeObserver } from './useResizeObserver';\n\n/**\n * Hook that returns a ref and a boolean indicating if the container\n * has a width >= the specified breakpoint.\n *\n * Useful for synchronizing React state with CSS container queries.\n *\n * Uses content-box measurements to match CSS container query behavior\n * (excludes padding and border).\n *\n * @param breakpoint - Minimum width in pixels\n * @returns [ref, isAboveBreakpoint] tuple\n */\nexport function useContainerSize(breakpoint: number): [React.RefObject<HTMLDivElement>, boolean] {\n const ref = useRef<HTMLDivElement>(null);\n const [isAboveBreakpoint, setIsAboveBreakpoint] = useState(false);\n\n useResizeObserver(\n ref,\n (entry) => {\n // Use contentRect.width to match CSS container query box model (content-box)\n const inlineSize = entry.contentRect.width;\n setIsAboveBreakpoint(inlineSize >= breakpoint);\n },\n 'content-box',\n );\n\n return [ref, isAboveBreakpoint];\n}\n"],"names":["useContainerSize","breakpoint","ref","useRef","isAboveBreakpoint","setIsAboveBreakpoint","useState","useResizeObserver","entry","inlineSize","contentRect","width"],"mappings":";;;;;AAIA;;;;;;;;;;;AAWG;AACG,SAAUA,gBAAgBA,CAACC,UAAkB,EAAA;AACjD,EAAA,MAAMC,GAAG,GAAGC,YAAM,CAAiB,IAAI,CAAC;EACxC,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;AAEjEC,EAAAA,mCAAiB,CACfL,GAAG,EACFM,KAAK,IAAI;AACR;AACA,IAAA,MAAMC,UAAU,GAAGD,KAAK,CAACE,WAAW,CAACC,KAAK;AAC1CN,IAAAA,oBAAoB,CAACI,UAAU,IAAIR,UAAU,CAAC;EAChD,CAAC,EACD,aAAa,CACd;AAED,EAAA,OAAO,CAACC,GAAG,EAAEE,iBAAiB,CAAC;AACjC;;;;"}