@transferwise/components 0.0.0-experimental-f727c49 → 0.0.0-experimental-854d710
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.
- package/build/common/hooks/useContainerSize.js +30 -0
- package/build/common/hooks/useContainerSize.js.map +1 -0
- package/build/common/hooks/useContainerSize.mjs +28 -0
- package/build/common/hooks/useContainerSize.mjs.map +1 -0
- package/build/common/hooks/useResizeObserver.js +3 -3
- package/build/common/hooks/useResizeObserver.js.map +1 -1
- package/build/common/hooks/useResizeObserver.mjs +3 -3
- package/build/common/hooks/useResizeObserver.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +3 -0
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +3 -0
- package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
- package/build/field/Field.js +3 -2
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +3 -2
- package/build/field/Field.mjs.map +1 -1
- package/build/i18n/en.json +2 -0
- package/build/i18n/en.json.js +2 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +2 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +3 -2
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +3 -2
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +194 -29
- package/build/prompt/ActionPrompt/ActionPrompt.js +8 -40
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +8 -40
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/CriticalBanner/CriticalBanner.js +143 -0
- package/build/prompt/CriticalBanner/CriticalBanner.js.map +1 -0
- package/build/prompt/CriticalBanner/CriticalBanner.mjs +141 -0
- package/build/prompt/CriticalBanner/CriticalBanner.mjs.map +1 -0
- package/build/prompt/CriticalBanner/helpers.js +29 -0
- package/build/prompt/CriticalBanner/helpers.js.map +1 -0
- package/build/prompt/CriticalBanner/helpers.mjs +26 -0
- package/build/prompt/CriticalBanner/helpers.mjs.map +1 -0
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js +11 -4
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs +11 -4
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
- package/build/prompt/common/Expander/Expander.js +35 -0
- package/build/prompt/common/Expander/Expander.js.map +1 -0
- package/build/prompt/common/Expander/Expander.messages.js +17 -0
- package/build/prompt/common/Expander/Expander.messages.js.map +1 -0
- package/build/prompt/common/Expander/Expander.messages.mjs +13 -0
- package/build/prompt/common/Expander/Expander.messages.mjs.map +1 -0
- package/build/prompt/common/Expander/Expander.mjs +33 -0
- package/build/prompt/common/Expander/Expander.mjs.map +1 -0
- package/build/prompt/helpers/promptMedia.js +52 -0
- package/build/prompt/helpers/promptMedia.js.map +1 -0
- package/build/prompt/helpers/promptMedia.mjs +50 -0
- package/build/prompt/helpers/promptMedia.mjs.map +1 -0
- package/build/styles/main.css +194 -29
- package/build/styles/prompt/CriticalBanner/CriticalBanner.css +134 -0
- package/build/styles/prompt/CriticalBanner/CriticalBanner.vars.css +0 -0
- package/build/styles/prompt/common/Expander/Expander.css +8 -0
- package/build/typeahead/Typeahead.js +3 -2
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +3 -2
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/common/hooks/useContainerSize.d.ts +14 -0
- package/build/types/common/hooks/useContainerSize.d.ts.map +1 -0
- package/build/types/common/hooks/useResizeObserver.d.ts +1 -1
- package/build/types/common/hooks/useResizeObserver.d.ts.map +1 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts +3 -0
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +2 -11
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts +39 -0
- package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts.map +1 -0
- package/build/types/prompt/CriticalBanner/helpers.d.ts +18 -0
- package/build/types/prompt/CriticalBanner/helpers.d.ts.map +1 -0
- package/build/types/prompt/CriticalBanner/index.d.ts +3 -0
- package/build/types/prompt/CriticalBanner/index.d.ts.map +1 -0
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +35 -3
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
- package/build/types/prompt/common/Expander/Expander.d.ts +20 -0
- package/build/types/prompt/common/Expander/Expander.d.ts.map +1 -0
- package/build/types/prompt/common/Expander/Expander.messages.d.ts +14 -0
- package/build/types/prompt/common/Expander/Expander.messages.d.ts.map +1 -0
- package/build/types/prompt/helpers/promptMedia.d.ts +22 -0
- package/build/types/prompt/helpers/promptMedia.d.ts.map +1 -0
- package/build/types/prompt/index.d.ts +2 -0
- package/build/types/prompt/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +4 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common/hooks/useContainerSize.test.tsx +125 -0
- package/src/common/hooks/useContainerSize.ts +32 -0
- package/src/common/hooks/useResizeObserver.ts +3 -2
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +4 -0
- package/src/criticalBanner/CriticalCommsBanner.test.story.tsx +1 -1
- package/src/criticalBanner/CriticalCommsBanner.tsx +3 -0
- package/src/i18n/en.json +2 -0
- package/src/index.ts +2 -2
- package/src/main.css +194 -29
- package/src/main.less +3 -1
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +9 -62
- package/src/prompt/CriticalBanner/CriticalBanner.accessibility.docs.mdx +113 -0
- package/src/prompt/CriticalBanner/CriticalBanner.css +134 -0
- package/src/prompt/CriticalBanner/CriticalBanner.less +155 -0
- package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +635 -0
- package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +422 -0
- package/src/prompt/CriticalBanner/CriticalBanner.tsx +179 -0
- package/src/prompt/CriticalBanner/CriticalBanner.vars.css +0 -0
- package/src/prompt/CriticalBanner/CriticalBanner.vars.less +6 -0
- package/src/prompt/CriticalBanner/helpers.ts +39 -0
- package/src/prompt/CriticalBanner/index.ts +2 -0
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +56 -40
- package/src/prompt/common/Expander/Expander.css +8 -0
- package/src/prompt/common/Expander/Expander.less +9 -0
- package/src/prompt/common/Expander/Expander.messages.ts +14 -0
- package/src/prompt/common/Expander/Expander.test.tsx +167 -0
- package/src/prompt/common/Expander/Expander.tsx +83 -0
- package/src/prompt/helpers/promptMedia.tsx +79 -0
- package/src/prompt/index.ts +4 -0
- package/src/sentimentSurface/SentimentSurface.story.tsx +43 -17
package/build/main.css
CHANGED
|
@@ -32235,6 +32235,200 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32235
32235
|
}
|
|
32236
32236
|
}
|
|
32237
32237
|
|
|
32238
|
+
.wds-action-prompt {
|
|
32239
|
+
--Prompt-padding: var(--size-16);
|
|
32240
|
+
--Prompt-actions-gap: var(--size-8);
|
|
32241
|
+
--Prompt-gap: var(--size-10) var(--size-16);
|
|
32242
|
+
--Prompt-border-radius: var(--radius-large);
|
|
32243
|
+
}
|
|
32244
|
+
|
|
32245
|
+
.wds-action-prompt--media-image {
|
|
32246
|
+
width: 48px;
|
|
32247
|
+
width: var(--size-48);
|
|
32248
|
+
height: 48px;
|
|
32249
|
+
height: var(--size-48);
|
|
32250
|
+
-o-object-fit: contain;
|
|
32251
|
+
object-fit: contain;
|
|
32252
|
+
}
|
|
32253
|
+
|
|
32254
|
+
@media (max-width: 767px) {
|
|
32255
|
+
.wds-action-prompt--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
|
|
32256
|
+
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
32257
|
+
min-width: -moz-fit-content;
|
|
32258
|
+
min-width: fit-content;
|
|
32259
|
+
}
|
|
32260
|
+
}
|
|
32261
|
+
|
|
32262
|
+
.wds-action-prompt__content {
|
|
32263
|
+
max-width: calc(48px * 10);
|
|
32264
|
+
max-width: calc(var(--size-48) * 10);
|
|
32265
|
+
}
|
|
32266
|
+
|
|
32267
|
+
.wds-critical-banner {
|
|
32268
|
+
--Prompt-padding: var(--size-16);
|
|
32269
|
+
--Prompt-actions-gap: var(--size-8);
|
|
32270
|
+
--Prompt-gap: var(--size-10) var(--size-16);
|
|
32271
|
+
--Prompt-border-radius: 0;
|
|
32272
|
+
container-type: inline-size;
|
|
32273
|
+
--critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
|
|
32274
|
+
--critical-banner-duration: 150ms;
|
|
32275
|
+
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
32276
|
+
actions only go full-width below mobile-max token (container query) */
|
|
32277
|
+
}
|
|
32278
|
+
|
|
32279
|
+
.wds-critical-banner--media-image {
|
|
32280
|
+
width: 48px;
|
|
32281
|
+
width: var(--size-48);
|
|
32282
|
+
height: 48px;
|
|
32283
|
+
height: var(--size-48);
|
|
32284
|
+
-o-object-fit: contain;
|
|
32285
|
+
object-fit: contain;
|
|
32286
|
+
}
|
|
32287
|
+
|
|
32288
|
+
.wds-critical-banner__title {
|
|
32289
|
+
display: -webkit-box;
|
|
32290
|
+
-webkit-line-clamp: 8;
|
|
32291
|
+
line-clamp: 8;
|
|
32292
|
+
-webkit-box-orient: vertical;
|
|
32293
|
+
max-height: 192px;
|
|
32294
|
+
overflow: hidden;
|
|
32295
|
+
transition: max-height var(--critical-banner-duration) var(--critical-banner-easing);
|
|
32296
|
+
}
|
|
32297
|
+
|
|
32298
|
+
.wds-critical-banner--collapsed .wds-critical-banner__title {
|
|
32299
|
+
-webkit-line-clamp: 2;
|
|
32300
|
+
line-clamp: 2;
|
|
32301
|
+
max-height: 48px;
|
|
32302
|
+
}
|
|
32303
|
+
|
|
32304
|
+
.wds-critical-banner__description {
|
|
32305
|
+
max-height: 30vh;
|
|
32306
|
+
opacity: 1;
|
|
32307
|
+
overflow: hidden;
|
|
32308
|
+
transition: max-height var(--critical-banner-duration) var(--critical-banner-easing), opacity var(--critical-banner-duration) var(--critical-banner-easing);
|
|
32309
|
+
}
|
|
32310
|
+
|
|
32311
|
+
.wds-critical-banner--collapsed .wds-critical-banner__description--with-title {
|
|
32312
|
+
max-height: 0;
|
|
32313
|
+
opacity: 0;
|
|
32314
|
+
}
|
|
32315
|
+
|
|
32316
|
+
.wds-critical-banner--collapsed .wds-critical-banner__description:not(.wds-critical-banner__description--with-title) {
|
|
32317
|
+
display: -webkit-box;
|
|
32318
|
+
-webkit-line-clamp: 2;
|
|
32319
|
+
line-clamp: 2;
|
|
32320
|
+
-webkit-box-orient: vertical;
|
|
32321
|
+
overflow: hidden;
|
|
32322
|
+
}
|
|
32323
|
+
|
|
32324
|
+
.wds-critical-banner .wds-prompt__content-wrapper {
|
|
32325
|
+
grid-template-columns: auto 1fr auto;
|
|
32326
|
+
align-items: flex-start;
|
|
32327
|
+
transition: row-gap var(--critical-banner-duration) var(--critical-banner-easing);
|
|
32328
|
+
}
|
|
32329
|
+
|
|
32330
|
+
.wds-critical-banner--collapsed .wds-prompt__content-wrapper {
|
|
32331
|
+
row-gap: 0;
|
|
32332
|
+
}
|
|
32333
|
+
|
|
32334
|
+
.wds-critical-banner__text-wrapper {
|
|
32335
|
+
position: relative;
|
|
32336
|
+
display: flex;
|
|
32337
|
+
flex-direction: column;
|
|
32338
|
+
justify-content: center;
|
|
32339
|
+
align-items: flex-start;
|
|
32340
|
+
text-align: start;
|
|
32341
|
+
min-width: 0;
|
|
32342
|
+
max-width: 480px;
|
|
32343
|
+
height: 100%;
|
|
32344
|
+
padding-top: 3px;
|
|
32345
|
+
}
|
|
32346
|
+
|
|
32347
|
+
@media (max-width: 320px) {
|
|
32348
|
+
.wds-critical-banner__text-wrapper {
|
|
32349
|
+
padding-top: 0;
|
|
32350
|
+
}
|
|
32351
|
+
}
|
|
32352
|
+
|
|
32353
|
+
@container (max-width: 320px) {
|
|
32354
|
+
.wds-critical-banner__text-wrapper {
|
|
32355
|
+
padding-top: 0;
|
|
32356
|
+
}
|
|
32357
|
+
}
|
|
32358
|
+
|
|
32359
|
+
.wds-critical-banner--collapsed .wds-critical-banner__title,
|
|
32360
|
+
.wds-critical-banner--collapsed .wds-critical-banner__description {
|
|
32361
|
+
transform: translateY(0);
|
|
32362
|
+
}
|
|
32363
|
+
|
|
32364
|
+
.wds-critical-banner__toggle {
|
|
32365
|
+
flex-shrink: 0;
|
|
32366
|
+
transition: transform var(--critical-banner-duration) var(--critical-banner-easing);
|
|
32367
|
+
}
|
|
32368
|
+
|
|
32369
|
+
.wds-critical-banner__toggle--collapsed {
|
|
32370
|
+
transform: rotate(180deg);
|
|
32371
|
+
}
|
|
32372
|
+
|
|
32373
|
+
@container (min-width: 768px) {
|
|
32374
|
+
.wds-critical-banner__toggle {
|
|
32375
|
+
display: none;
|
|
32376
|
+
}
|
|
32377
|
+
}
|
|
32378
|
+
|
|
32379
|
+
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
32380
|
+
grid-column-start: 2;
|
|
32381
|
+
grid-column-end: 3;
|
|
32382
|
+
max-height: 200px;
|
|
32383
|
+
opacity: 1;
|
|
32384
|
+
overflow: visible;
|
|
32385
|
+
}
|
|
32386
|
+
|
|
32387
|
+
@container (max-width: 600px) {
|
|
32388
|
+
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
32389
|
+
grid-column: span 3;
|
|
32390
|
+
width: 100%;
|
|
32391
|
+
}
|
|
32392
|
+
.wds-critical-banner .wds-prompt__actions-wrapper .wds-Button {
|
|
32393
|
+
flex: 1 1 100%;
|
|
32394
|
+
width: 100%;
|
|
32395
|
+
}
|
|
32396
|
+
}
|
|
32397
|
+
|
|
32398
|
+
.wds-critical-banner--collapsed .wds-prompt__actions-wrapper {
|
|
32399
|
+
max-height: 0;
|
|
32400
|
+
opacity: 0;
|
|
32401
|
+
overflow: hidden;
|
|
32402
|
+
pointer-events: none;
|
|
32403
|
+
}
|
|
32404
|
+
|
|
32405
|
+
@container (max-width: 600px) {
|
|
32406
|
+
.wds-critical-banner--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
|
|
32407
|
+
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
32408
|
+
min-width: -moz-fit-content;
|
|
32409
|
+
min-width: fit-content;
|
|
32410
|
+
}
|
|
32411
|
+
}
|
|
32412
|
+
|
|
32413
|
+
@media (prefers-reduced-motion: reduce) {
|
|
32414
|
+
.wds-critical-banner__description,
|
|
32415
|
+
.wds-critical-banner__title,
|
|
32416
|
+
.wds-critical-banner .wds-prompt__content-wrapper,
|
|
32417
|
+
.wds-critical-banner__toggle {
|
|
32418
|
+
transition: none !important;
|
|
32419
|
+
}
|
|
32420
|
+
}
|
|
32421
|
+
|
|
32422
|
+
.wds-expander-toggle {
|
|
32423
|
+
align-self: flex-start;
|
|
32424
|
+
flex-shrink: 0;
|
|
32425
|
+
transition: transform 0.2s ease-in-out;
|
|
32426
|
+
}
|
|
32427
|
+
|
|
32428
|
+
.wds-expander-toggle--collapsed {
|
|
32429
|
+
transform: rotate(180deg);
|
|
32430
|
+
}
|
|
32431
|
+
|
|
32238
32432
|
.wds-radio-group .np-radio:last-child label {
|
|
32239
32433
|
margin-bottom: 0;
|
|
32240
32434
|
}
|
|
@@ -34660,32 +34854,3 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
34660
34854
|
.np-list-item__action {
|
|
34661
34855
|
flex-shrink: 0;
|
|
34662
34856
|
}
|
|
34663
|
-
|
|
34664
|
-
.wds-action-prompt {
|
|
34665
|
-
--Prompt-padding: var(--size-16);
|
|
34666
|
-
--Prompt-actions-gap: var(--size-8);
|
|
34667
|
-
--Prompt-gap: var(--size-10) var(--size-16);
|
|
34668
|
-
--Prompt-border-radius: var(--radius-large);
|
|
34669
|
-
}
|
|
34670
|
-
|
|
34671
|
-
.wds-action-prompt--media-image {
|
|
34672
|
-
width: 48px;
|
|
34673
|
-
width: var(--size-48);
|
|
34674
|
-
height: 48px;
|
|
34675
|
-
height: var(--size-48);
|
|
34676
|
-
-o-object-fit: contain;
|
|
34677
|
-
object-fit: contain;
|
|
34678
|
-
}
|
|
34679
|
-
|
|
34680
|
-
@media (max-width: 767px) {
|
|
34681
|
-
.wds-action-prompt--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
|
|
34682
|
-
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
34683
|
-
min-width: -moz-fit-content;
|
|
34684
|
-
min-width: fit-content;
|
|
34685
|
-
}
|
|
34686
|
-
}
|
|
34687
|
-
|
|
34688
|
-
.wds-action-prompt__content {
|
|
34689
|
-
max-width: calc(48px * 10);
|
|
34690
|
-
max-width: calc(var(--size-48) * 10);
|
|
34691
|
-
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var clsx = require('clsx');
|
|
5
|
-
var StatusIcon = require('../../statusIcon/StatusIcon.js');
|
|
6
5
|
var Body = require('../../body/Body.js');
|
|
7
6
|
var Button_resolver = require('../../button/Button.resolver.js');
|
|
8
7
|
require('../../common/theme.js');
|
|
@@ -25,14 +24,13 @@ require('../../common/propsValues/scroll.js');
|
|
|
25
24
|
require('../../common/propsValues/markdownNodeType.js');
|
|
26
25
|
require('../../common/fileType.js');
|
|
27
26
|
require('@transferwise/formatting');
|
|
28
|
-
|
|
27
|
+
require('@transferwise/icons');
|
|
29
28
|
require('react-intl');
|
|
30
29
|
require('../../common/closeButton/CloseButton.messages.js');
|
|
31
30
|
var jsxRuntime = require('react/jsx-runtime');
|
|
32
|
-
var AvatarView = require('../../avatarView/AvatarView.js');
|
|
33
|
-
var Image = require('../../image/Image.js');
|
|
34
31
|
var PrimitivePrompt = require('../PrimitivePrompt/PrimitivePrompt.js');
|
|
35
32
|
var useScreenSize = require('../../common/hooks/useScreenSize.js');
|
|
33
|
+
var promptMedia = require('../helpers/promptMedia.js');
|
|
36
34
|
|
|
37
35
|
const ActionPrompt = ({
|
|
38
36
|
sentiment = 'neutral',
|
|
@@ -52,42 +50,12 @@ const ActionPrompt = ({
|
|
|
52
50
|
const titleId = React.useId();
|
|
53
51
|
const descId = React.useId();
|
|
54
52
|
const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, ariaLabel ? undefined : titleId].filter(Boolean).join(' ');
|
|
55
|
-
const renderMedia = () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
alt: media['aria-label'] ?? ''
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
if (media?.avatar) {
|
|
65
|
-
const badge = media.avatar.badge ? media.avatar.badge : sentiment === 'proposition' ? {} : {
|
|
66
|
-
status: sentiment
|
|
67
|
-
};
|
|
68
|
-
return /*#__PURE__*/jsxRuntime.jsx(AvatarView.default, {
|
|
69
|
-
...media.avatar,
|
|
70
|
-
badge: badge,
|
|
71
|
-
"aria-label": media['aria-label'],
|
|
72
|
-
"aria-hidden": media['aria-hidden'],
|
|
73
|
-
id: mediaId,
|
|
74
|
-
size: 48,
|
|
75
|
-
children: media.avatar.asset
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
return sentiment === 'proposition' ? /*#__PURE__*/jsxRuntime.jsx(AvatarView.default, {
|
|
79
|
-
id: mediaId,
|
|
80
|
-
size: 48,
|
|
81
|
-
"aria-label": media['aria-label'],
|
|
82
|
-
"aria-hidden": media['aria-hidden'],
|
|
83
|
-
children: /*#__PURE__*/jsxRuntime.jsx(icons.GiftBox, {})
|
|
84
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(StatusIcon.default, {
|
|
85
|
-
id: mediaId,
|
|
86
|
-
size: 48,
|
|
87
|
-
sentiment: sentiment,
|
|
88
|
-
iconLabel: media['aria-hidden'] ? null : media['aria-label']
|
|
89
|
-
});
|
|
90
|
-
};
|
|
53
|
+
const renderMedia = () => promptMedia.renderPromptMedia({
|
|
54
|
+
media,
|
|
55
|
+
sentiment,
|
|
56
|
+
mediaId,
|
|
57
|
+
imgClassName: 'wds-action-prompt--media-image'
|
|
58
|
+
});
|
|
91
59
|
return /*#__PURE__*/jsxRuntime.jsx(PrimitivePrompt.PrimitivePrompt, {
|
|
92
60
|
id: id,
|
|
93
61
|
sentiment: sentiment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionPrompt.js","sources":["../../../src/prompt/ActionPrompt/ActionPrompt.tsx"],"sourcesContent":["import { AriaAttributes, ReactNode, useId } from 'react';\nimport { clsx } from 'clsx';\n\nimport
|
|
1
|
+
{"version":3,"file":"ActionPrompt.js","sources":["../../../src/prompt/ActionPrompt/ActionPrompt.tsx"],"sourcesContent":["import { AriaAttributes, ReactNode, useId } from 'react';\nimport { clsx } from 'clsx';\n\nimport Body from '../../body';\nimport Button from '../../button';\nimport { Breakpoint, Typography } from '../../common';\nimport { ButtonProps } from '../../button/Button.types';\nimport { PrimitivePrompt, PrimitivePromptProps } from '../PrimitivePrompt';\nimport { useScreenSize } from '../../common/hooks/useScreenSize';\nimport { renderPromptMedia, PromptMedia } from '../helpers/promptMedia';\n\nexport type ActionPromptProps = {\n title: ReactNode;\n description?: ReactNode;\n /** @default {} */\n media?: PromptMedia;\n action: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n label: ButtonProps['children'];\n };\n actionSecondary?: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n label: ButtonProps['children'];\n };\n 'aria-label'?: AriaAttributes['aria-label'];\n} & Pick<PrimitivePromptProps, 'id' | 'className' | 'data-testid' | 'onDismiss'> & {\n /**\n * The sentiment determines the colour scheme\n * @default 'neutral'\n */\n sentiment?: PrimitivePromptProps['sentiment'];\n };\n\n/**\n * Use an action prompt for optional feedback that doesn't require immediate action, such as feature upsells, warnings, or suggestions. These prompts are typically used outside of core product flows (e.g., Launchpad, Recipient, or Transaction screens) and can be addressed at the user's convenience.\n *\n * If your message is about immediate user feedback (e.g., form submission errors, download failures, missing data warnings), use an [info prompt](https://storybook.wise.design/?path=/docs/prompts-infoprompt--docs) instead.\n *\n * Guidance can be found in the [design system](https://wise.design/components/action-prompt).\n */\nexport const ActionPrompt = ({\n sentiment = 'neutral',\n title,\n description,\n onDismiss,\n media = {},\n action,\n actionSecondary,\n id,\n className,\n 'data-testid': testId,\n 'aria-label': ariaLabel,\n}: ActionPromptProps) => {\n const isMobile = !useScreenSize(Breakpoint.MEDIUM);\n\n const mediaId = useId();\n const titleId = useId();\n const descId = useId();\n\n const ariaLabelledByIds = [\n media['aria-hidden'] ? undefined : mediaId,\n ariaLabel ? undefined : titleId,\n ]\n .filter(Boolean)\n .join(' ');\n\n const renderMedia = () =>\n renderPromptMedia({\n media,\n sentiment,\n mediaId,\n imgClassName: 'wds-action-prompt--media-image',\n });\n\n return (\n <PrimitivePrompt\n id={id}\n sentiment={sentiment}\n data-testid={testId}\n className={clsx(\n 'wds-action-prompt',\n { 'wds-action-prompt--with-two-actions': !!actionSecondary },\n className,\n )}\n media={renderMedia()}\n actions={\n <>\n {actionSecondary && (\n // @ts-expect-error onClick type mismatch\n <Button\n v2\n size=\"md\"\n priority=\"secondary\"\n href={actionSecondary.href}\n block={isMobile}\n onClick={actionSecondary?.onClick}\n >\n {actionSecondary.label}\n </Button>\n )}\n {/* @ts-expect-error onClick type mismatch */}\n <Button\n v2\n size=\"md\"\n priority=\"primary\"\n href={action.href}\n block={isMobile}\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n </>\n }\n role=\"region\"\n onDismiss={onDismiss}\n {...(ariaLabel\n ? { 'aria-label': ariaLabel }\n : {\n 'aria-labelledby': ariaLabelledByIds,\n 'aria-describedby': descId,\n })}\n >\n <div className={clsx('d-flex', 'flex-column', 'justify-content-center')}>\n <Body id={titleId} type={Typography.BODY_LARGE_BOLD} className=\"wds-action-prompt__content\">\n {title}\n </Body>\n {description && (\n <Body id={descId} className=\"wds-action-prompt__content\">\n {description}\n </Body>\n )}\n </div>\n </PrimitivePrompt>\n );\n};\n\nexport default ActionPrompt;\n"],"names":["ActionPrompt","sentiment","title","description","onDismiss","media","action","actionSecondary","id","className","testId","ariaLabel","isMobile","useScreenSize","Breakpoint","MEDIUM","mediaId","useId","titleId","descId","ariaLabelledByIds","undefined","filter","Boolean","join","renderMedia","renderPromptMedia","imgClassName","_jsx","PrimitivePrompt","clsx","actions","_jsxs","_Fragment","children","Button","v2","size","priority","href","block","onClick","label","role","Body","type","Typography","BODY_LARGE_BOLD"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,MAAMA,YAAY,GAAGA,CAAC;AAC3BC,EAAAA,SAAS,GAAG,SAAS;EACrBC,KAAK;EACLC,WAAW;EACXC,SAAS;EACTC,KAAK,GAAG,EAAE;EACVC,MAAM;EACNC,eAAe;EACfC,EAAE;EACFC,SAAS;AACT,EAAA,aAAa,EAAEC,MAAM;AACrB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;EACtB,MAAMC,QAAQ,GAAG,CAACC,2BAAa,CAACC,qBAAU,CAACC,MAAM,CAAC;AAElD,EAAA,MAAMC,OAAO,GAAGC,WAAK,EAAE;AACvB,EAAA,MAAMC,OAAO,GAAGD,WAAK,EAAE;AACvB,EAAA,MAAME,MAAM,GAAGF,WAAK,EAAE;EAEtB,MAAMG,iBAAiB,GAAG,CACxBf,KAAK,CAAC,aAAa,CAAC,GAAGgB,SAAS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KAAA,CACD;AACDC,IAAAA,IAAI,EAAC,QAAQ;AACbvC,IAAAA,SAAS,EAAEA,SAAU;AAAA,IAAA,IAChBO,SAAS,GACV;AAAE,MAAA,YAAY,EAAEA;AAAS,KAAE,GAC3B;AACE,MAAA,iBAAiB,EAAES,iBAAiB;AACpC,MAAA,kBAAkB,EAAED;KACrB,CAAA;AAAAe,IAAAA,QAAA,eAELF,eAAA,CAAA,KAAA,EAAA;MAAKvB,SAAS,EAAEqB,SAAI,CAAC,QAAQ,EAAE,aAAa,EAAE,wBAAwB,CAAE;MAAAI,QAAA,EAAA,cACtEN,cAAA,CAACgB,YAAI,EAAA;AAACpC,QAAAA,EAAE,EAAEU,OAAQ;QAAC2B,IAAI,EAAEC,qBAAU,CAACC,eAAgB;AAACtC,QAAAA,SAAS,EAAC,4BAA4B;AAAAyB,QAAAA,QAAA,EACxFhC;AAAK,OACF,CACN,EAACC,WAAW,iBACVyB,cAAA,CAACgB,YAAI,EAAA;AAACpC,QAAAA,EAAE,EAAEW,MAAO;AAACV,QAAAA,SAAS,EAAC,4BAA4B;AAAAyB,QAAAA,QAAA,EACrD/B;AAAW,OACR,CACP;KACE;AACP,GAAiB,CAAC;AAEtB;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useId } from 'react';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import StatusIcon from '../../statusIcon/StatusIcon.mjs';
|
|
4
3
|
import Body from '../../body/Body.mjs';
|
|
5
4
|
import Button from '../../button/Button.resolver.mjs';
|
|
6
5
|
import '../../common/theme.mjs';
|
|
@@ -23,14 +22,13 @@ import '../../common/propsValues/scroll.mjs';
|
|
|
23
22
|
import '../../common/propsValues/markdownNodeType.mjs';
|
|
24
23
|
import '../../common/fileType.mjs';
|
|
25
24
|
import '@transferwise/formatting';
|
|
26
|
-
import
|
|
25
|
+
import '@transferwise/icons';
|
|
27
26
|
import 'react-intl';
|
|
28
27
|
import '../../common/closeButton/CloseButton.messages.mjs';
|
|
29
28
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
30
|
-
import AvatarView from '../../avatarView/AvatarView.mjs';
|
|
31
|
-
import Image from '../../image/Image.mjs';
|
|
32
29
|
import { PrimitivePrompt } from '../PrimitivePrompt/PrimitivePrompt.mjs';
|
|
33
30
|
import { useScreenSize } from '../../common/hooks/useScreenSize.mjs';
|
|
31
|
+
import { renderPromptMedia } from '../helpers/promptMedia.mjs';
|
|
34
32
|
|
|
35
33
|
const ActionPrompt = ({
|
|
36
34
|
sentiment = 'neutral',
|
|
@@ -50,42 +48,12 @@ const ActionPrompt = ({
|
|
|
50
48
|
const titleId = useId();
|
|
51
49
|
const descId = useId();
|
|
52
50
|
const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, ariaLabel ? undefined : titleId].filter(Boolean).join(' ');
|
|
53
|
-
const renderMedia = () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
alt: media['aria-label'] ?? ''
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
if (media?.avatar) {
|
|
63
|
-
const badge = media.avatar.badge ? media.avatar.badge : sentiment === 'proposition' ? {} : {
|
|
64
|
-
status: sentiment
|
|
65
|
-
};
|
|
66
|
-
return /*#__PURE__*/jsx(AvatarView, {
|
|
67
|
-
...media.avatar,
|
|
68
|
-
badge: badge,
|
|
69
|
-
"aria-label": media['aria-label'],
|
|
70
|
-
"aria-hidden": media['aria-hidden'],
|
|
71
|
-
id: mediaId,
|
|
72
|
-
size: 48,
|
|
73
|
-
children: media.avatar.asset
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return sentiment === 'proposition' ? /*#__PURE__*/jsx(AvatarView, {
|
|
77
|
-
id: mediaId,
|
|
78
|
-
size: 48,
|
|
79
|
-
"aria-label": media['aria-label'],
|
|
80
|
-
"aria-hidden": media['aria-hidden'],
|
|
81
|
-
children: /*#__PURE__*/jsx(GiftBox, {})
|
|
82
|
-
}) : /*#__PURE__*/jsx(StatusIcon, {
|
|
83
|
-
id: mediaId,
|
|
84
|
-
size: 48,
|
|
85
|
-
sentiment: sentiment,
|
|
86
|
-
iconLabel: media['aria-hidden'] ? null : media['aria-label']
|
|
87
|
-
});
|
|
88
|
-
};
|
|
51
|
+
const renderMedia = () => renderPromptMedia({
|
|
52
|
+
media,
|
|
53
|
+
sentiment,
|
|
54
|
+
mediaId,
|
|
55
|
+
imgClassName: 'wds-action-prompt--media-image'
|
|
56
|
+
});
|
|
89
57
|
return /*#__PURE__*/jsx(PrimitivePrompt, {
|
|
90
58
|
id: id,
|
|
91
59
|
sentiment: sentiment,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionPrompt.mjs","sources":["../../../src/prompt/ActionPrompt/ActionPrompt.tsx"],"sourcesContent":["import { AriaAttributes, ReactNode, useId } from 'react';\nimport { clsx } from 'clsx';\n\nimport
|
|
1
|
+
{"version":3,"file":"ActionPrompt.mjs","sources":["../../../src/prompt/ActionPrompt/ActionPrompt.tsx"],"sourcesContent":["import { AriaAttributes, ReactNode, useId } from 'react';\nimport { clsx } from 'clsx';\n\nimport Body from '../../body';\nimport Button from '../../button';\nimport { Breakpoint, Typography } from '../../common';\nimport { ButtonProps } from '../../button/Button.types';\nimport { PrimitivePrompt, PrimitivePromptProps } from '../PrimitivePrompt';\nimport { useScreenSize } from '../../common/hooks/useScreenSize';\nimport { renderPromptMedia, PromptMedia } from '../helpers/promptMedia';\n\nexport type ActionPromptProps = {\n title: ReactNode;\n description?: ReactNode;\n /** @default {} */\n media?: PromptMedia;\n action: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n label: ButtonProps['children'];\n };\n actionSecondary?: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n label: ButtonProps['children'];\n };\n 'aria-label'?: AriaAttributes['aria-label'];\n} & Pick<PrimitivePromptProps, 'id' | 'className' | 'data-testid' | 'onDismiss'> & {\n /**\n * The sentiment determines the colour scheme\n * @default 'neutral'\n */\n sentiment?: PrimitivePromptProps['sentiment'];\n };\n\n/**\n * Use an action prompt for optional feedback that doesn't require immediate action, such as feature upsells, warnings, or suggestions. These prompts are typically used outside of core product flows (e.g., Launchpad, Recipient, or Transaction screens) and can be addressed at the user's convenience.\n *\n * If your message is about immediate user feedback (e.g., form submission errors, download failures, missing data warnings), use an [info prompt](https://storybook.wise.design/?path=/docs/prompts-infoprompt--docs) instead.\n *\n * Guidance can be found in the [design system](https://wise.design/components/action-prompt).\n */\nexport const ActionPrompt = ({\n sentiment = 'neutral',\n title,\n description,\n onDismiss,\n media = {},\n action,\n actionSecondary,\n id,\n className,\n 'data-testid': testId,\n 'aria-label': ariaLabel,\n}: ActionPromptProps) => {\n const isMobile = !useScreenSize(Breakpoint.MEDIUM);\n\n const mediaId = useId();\n const titleId = useId();\n const descId = useId();\n\n const ariaLabelledByIds = [\n media['aria-hidden'] ? undefined : mediaId,\n ariaLabel ? undefined : titleId,\n ]\n .filter(Boolean)\n .join(' ');\n\n const renderMedia = () =>\n renderPromptMedia({\n media,\n sentiment,\n mediaId,\n imgClassName: 'wds-action-prompt--media-image',\n });\n\n return (\n <PrimitivePrompt\n id={id}\n sentiment={sentiment}\n data-testid={testId}\n className={clsx(\n 'wds-action-prompt',\n { 'wds-action-prompt--with-two-actions': !!actionSecondary },\n className,\n )}\n media={renderMedia()}\n actions={\n <>\n {actionSecondary && (\n // @ts-expect-error onClick type mismatch\n <Button\n v2\n size=\"md\"\n priority=\"secondary\"\n href={actionSecondary.href}\n block={isMobile}\n onClick={actionSecondary?.onClick}\n >\n {actionSecondary.label}\n </Button>\n )}\n {/* @ts-expect-error onClick type mismatch */}\n <Button\n v2\n size=\"md\"\n priority=\"primary\"\n href={action.href}\n block={isMobile}\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n </>\n }\n role=\"region\"\n onDismiss={onDismiss}\n {...(ariaLabel\n ? { 'aria-label': ariaLabel }\n : {\n 'aria-labelledby': ariaLabelledByIds,\n 'aria-describedby': descId,\n })}\n >\n <div className={clsx('d-flex', 'flex-column', 'justify-content-center')}>\n <Body id={titleId} type={Typography.BODY_LARGE_BOLD} className=\"wds-action-prompt__content\">\n {title}\n </Body>\n {description && (\n <Body id={descId} className=\"wds-action-prompt__content\">\n {description}\n </Body>\n )}\n </div>\n </PrimitivePrompt>\n );\n};\n\nexport default ActionPrompt;\n"],"names":["ActionPrompt","sentiment","title","description","onDismiss","media","action","actionSecondary","id","className","testId","ariaLabel","isMobile","useScreenSize","Breakpoint","MEDIUM","mediaId","useId","titleId","descId","ariaLabelledByIds","undefined","filter","Boolean","join","renderMedia","renderPromptMedia","imgClassName","_jsx","PrimitivePrompt","clsx","actions","_jsxs","_Fragment","children","Button","v2","size","priority","href","block","onClick","label","role","Body","type","Typography","BODY_LARGE_BOLD"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,MAAMA,YAAY,GAAGA,CAAC;AAC3BC,EAAAA,SAAS,GAAG,SAAS;EACrBC,KAAK;EACLC,WAAW;EACXC,SAAS;EACTC,KAAK,GAAG,EAAE;EACVC,MAAM;EACNC,eAAe;EACfC,EAAE;EACFC,SAAS;AACT,EAAA,aAAa,EAAEC,MAAM;AACrB,EAAA,YAAY,EAAEC;AAAS,CACL,KAAI;EACtB,MAAMC,QAAQ,GAAG,CAACC,aAAa,CAACC,UAAU,CAACC,MAAM,CAAC;AAElD,EAAA,MAAMC,OAAO,GAAGC,KAAK,EAAE;AACvB,EAAA,MAAMC,OAAO,GAAGD,KAAK,EAAE;AACvB,EAAA,MAAME,MAAM,GAAGF,KAAK,EAAE;EAEtB,MAAMG,iBAAiB,GAAG,CACxBf,KAAK,CAAC,aAAa,CAAC,GAAGgB,SAAS,GAAGL,OAAO,EAC1CL,SAAS,GAAGU,SAAS,GAAGH,OAAO,CAChC,CACEI,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,GAAG,CAAC;AAEZ,EAAA,MAA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,GAC3B;AACE,MAAA,iBAAiB,EAAES,iBAAiB;AACpC,MAAA,kBAAkB,EAAED;KACrB,CAAA;AAAAe,IAAAA,QAAA,eAELF,IAAA,CAAA,KAAA,EAAA;MAAKvB,SAAS,EAAEqB,IAAI,CAAC,QAAQ,EAAE,aAAa,EAAE,wBAAwB,CAAE;MAAAI,QAAA,EAAA,cACtEN,GAAA,CAACgB,IAAI,EAAA;AAACpC,QAAAA,EAAE,EAAEU,OAAQ;QAAC2B,IAAI,EAAEC,UAAU,CAACC,eAAgB;AAACtC,QAAAA,SAAS,EAAC,4BAA4B;AAAAyB,QAAAA,QAAA,EACxFhC;AAAK,OACF,CACN,EAACC,WAAW,iBACVyB,GAAA,CAACgB,IAAI,EAAA;AAACpC,QAAAA,EAAE,EAAEW,MAAO;AAACV,QAAAA,SAAS,EAAC,4BAA4B;AAAAyB,QAAAA,QAAA,EACrD/B;AAAW,OACR,CACP;KACE;AACP,GAAiB,CAAC;AAEtB;;;;"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var Body = require('../../body/Body.js');
|
|
6
|
+
var Button_resolver = require('../../button/Button.resolver.js');
|
|
7
|
+
require('../../common/theme.js');
|
|
8
|
+
require('../../common/direction.js');
|
|
9
|
+
require('../../common/propsValues/control.js');
|
|
10
|
+
var breakpoint = require('../../common/propsValues/breakpoint.js');
|
|
11
|
+
require('../../common/propsValues/size.js');
|
|
12
|
+
var typography = require('../../common/propsValues/typography.js');
|
|
13
|
+
require('../../common/propsValues/width.js');
|
|
14
|
+
require('../../common/propsValues/type.js');
|
|
15
|
+
require('../../common/propsValues/dateMode.js');
|
|
16
|
+
require('../../common/propsValues/monthFormat.js');
|
|
17
|
+
require('../../common/propsValues/position.js');
|
|
18
|
+
require('../../common/propsValues/layouts.js');
|
|
19
|
+
require('../../common/propsValues/status.js');
|
|
20
|
+
require('../../common/propsValues/sentiment.js');
|
|
21
|
+
require('../../common/propsValues/profileType.js');
|
|
22
|
+
require('../../common/propsValues/variant.js');
|
|
23
|
+
require('../../common/propsValues/scroll.js');
|
|
24
|
+
require('../../common/propsValues/markdownNodeType.js');
|
|
25
|
+
require('../../common/fileType.js');
|
|
26
|
+
require('@transferwise/formatting');
|
|
27
|
+
require('@transferwise/icons');
|
|
28
|
+
require('react-intl');
|
|
29
|
+
require('../../common/closeButton/CloseButton.messages.js');
|
|
30
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
31
|
+
var LiveRegion = require('../../common/liveRegion/LiveRegion.js');
|
|
32
|
+
var PrimitivePrompt = require('../PrimitivePrompt/PrimitivePrompt.js');
|
|
33
|
+
var promptMedia = require('../helpers/promptMedia.js');
|
|
34
|
+
var Expander = require('../common/Expander/Expander.js');
|
|
35
|
+
var helpers = require('./helpers.js');
|
|
36
|
+
var useContainerSize = require('../../common/hooks/useContainerSize.js');
|
|
37
|
+
|
|
38
|
+
const CriticalBanner = ({
|
|
39
|
+
sentiment = 'negative',
|
|
40
|
+
title,
|
|
41
|
+
description,
|
|
42
|
+
media = {},
|
|
43
|
+
action,
|
|
44
|
+
actionSecondary,
|
|
45
|
+
expanded: expandedProp,
|
|
46
|
+
onToggle,
|
|
47
|
+
id,
|
|
48
|
+
className,
|
|
49
|
+
'data-testid': testId
|
|
50
|
+
}) => {
|
|
51
|
+
const [containerRef, isDesktop] = useContainerSize.useContainerSize(breakpoint.Breakpoint.MEDIUM);
|
|
52
|
+
const isControlled = expandedProp !== undefined && onToggle !== undefined;
|
|
53
|
+
const [internalExpanded, setInternalExpanded] = React.useState(true);
|
|
54
|
+
const resolvedExpanded = isDesktop ? true : isControlled ? expandedProp : internalExpanded;
|
|
55
|
+
const handleToggle = isControlled ? onToggle : () => setInternalExpanded(previousExpanded => !previousExpanded);
|
|
56
|
+
const hasActions = action ?? actionSecondary;
|
|
57
|
+
const mediaId = React.useId();
|
|
58
|
+
const titleId = React.useId();
|
|
59
|
+
const descId = React.useId();
|
|
60
|
+
const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, !title ? undefined : titleId].filter(Boolean).join(' ');
|
|
61
|
+
return /*#__PURE__*/jsxRuntime.jsx(LiveRegion.LiveRegion, {
|
|
62
|
+
"aria-live": "assertive",
|
|
63
|
+
announceOnChange: helpers.buildAnnouncementString({
|
|
64
|
+
title,
|
|
65
|
+
description,
|
|
66
|
+
expanded: resolvedExpanded,
|
|
67
|
+
actionLabel: action?.label,
|
|
68
|
+
actionSecondaryLabel: actionSecondary?.label
|
|
69
|
+
}),
|
|
70
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(PrimitivePrompt.PrimitivePrompt, {
|
|
71
|
+
ref: containerRef,
|
|
72
|
+
id: id,
|
|
73
|
+
sentiment: sentiment,
|
|
74
|
+
emphasis: sentiment === 'neutral' ? 'base' : 'elevated',
|
|
75
|
+
"data-testid": testId,
|
|
76
|
+
className: clsx.clsx('wds-critical-banner', {
|
|
77
|
+
'wds-critical-banner--collapsed': !resolvedExpanded,
|
|
78
|
+
'wds-critical-banner--with-two-actions': !!actionSecondary
|
|
79
|
+
}, className),
|
|
80
|
+
media: promptMedia.renderPromptMedia({
|
|
81
|
+
media,
|
|
82
|
+
sentiment,
|
|
83
|
+
mediaId,
|
|
84
|
+
imgClassName: 'wds-critical-banner--media-image'
|
|
85
|
+
}),
|
|
86
|
+
actions: hasActions ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
87
|
+
"aria-hidden": !resolvedExpanded ? true : undefined,
|
|
88
|
+
style: {
|
|
89
|
+
display: 'contents'
|
|
90
|
+
},
|
|
91
|
+
children: [actionSecondary &&
|
|
92
|
+
/*#__PURE__*/
|
|
93
|
+
// @ts-expect-error onClick type mismatch
|
|
94
|
+
jsxRuntime.jsx(Button_resolver.default, {
|
|
95
|
+
v2: true,
|
|
96
|
+
size: "md",
|
|
97
|
+
priority: "secondary",
|
|
98
|
+
href: actionSecondary.href,
|
|
99
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
100
|
+
onClick: actionSecondary?.onClick,
|
|
101
|
+
children: actionSecondary.label
|
|
102
|
+
}), action &&
|
|
103
|
+
/*#__PURE__*/
|
|
104
|
+
// @ts-expect-error onClick type mismatch
|
|
105
|
+
jsxRuntime.jsx(Button_resolver.default, {
|
|
106
|
+
v2: true,
|
|
107
|
+
size: "md",
|
|
108
|
+
priority: "primary",
|
|
109
|
+
href: action.href,
|
|
110
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
111
|
+
onClick: action.onClick,
|
|
112
|
+
children: action.label
|
|
113
|
+
})]
|
|
114
|
+
}) : undefined,
|
|
115
|
+
role: "region",
|
|
116
|
+
"aria-labelledby": ariaLabelledByIds || undefined,
|
|
117
|
+
"aria-describedby": description ? descId : undefined,
|
|
118
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
119
|
+
className: "wds-critical-banner__text-wrapper",
|
|
120
|
+
children: [title && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
121
|
+
id: titleId,
|
|
122
|
+
type: typography.Typography.BODY_LARGE_BOLD,
|
|
123
|
+
className: "wds-critical-banner__content wds-critical-banner__title",
|
|
124
|
+
children: title
|
|
125
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
126
|
+
id: descId,
|
|
127
|
+
className: clsx.clsx('wds-critical-banner__content', 'wds-critical-banner__description', {
|
|
128
|
+
'wds-critical-banner__description--with-title': !!title
|
|
129
|
+
}),
|
|
130
|
+
children: description
|
|
131
|
+
})]
|
|
132
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Expander.ExpanderToggle, {
|
|
133
|
+
expanded: resolvedExpanded,
|
|
134
|
+
size: 24,
|
|
135
|
+
className: "wds-critical-banner__toggle",
|
|
136
|
+
onToggle: handleToggle
|
|
137
|
+
})]
|
|
138
|
+
})
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
exports.CriticalBanner = CriticalBanner;
|
|
143
|
+
//# sourceMappingURL=CriticalBanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CriticalBanner.js","sources":["../../../src/prompt/CriticalBanner/CriticalBanner.tsx"],"sourcesContent":["import { ReactNode, useId, useState } from 'react';\nimport { clsx } from 'clsx';\n\nimport Body from '../../body';\nimport Button from '../../button';\nimport { Breakpoint, LiveRegion, Typography } from '../../common';\nimport { ButtonProps } from '../../button/Button.types';\nimport { PrimitivePrompt, PrimitivePromptProps } from '../PrimitivePrompt';\n\nimport { renderPromptMedia, PromptMedia } from '../helpers/promptMedia';\nimport { ExpanderToggle } from '../common/Expander/Expander';\nimport { buildAnnouncementString } from './helpers';\nimport { useContainerSize } from '../../common/hooks/useContainerSize';\n\nexport type CriticalBannerProps = {\n title?: ReactNode;\n description: ReactNode;\n media?: PromptMedia;\n action?: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n label: ButtonProps['children'];\n };\n actionSecondary?: Pick<ButtonProps, 'onClick' | 'href' | 'target'> & {\n label: ButtonProps['children'];\n };\n sentiment?: Exclude<PrimitivePromptProps['sentiment'], 'proposition'>;\n /**\n * Controls whether the description and actions are visible, as a controlled component.\n * When collapsed with a title, only the title is shown.\n * When collapsed without a title, the description is trimmed to 2 lines.\n *\n * Note: On desktop (container width >= 768px), the banner is always expanded\n * regardless of this prop value.\n */\n expanded?: boolean;\n /**\n * Called when the user clicks the chevron toggle.\n * If not provided, the component will manage expanded state internally.\n */\n onToggle?: () => void;\n} & Pick<PrimitivePromptProps, 'id' | 'className' | 'data-testid'>;\n\n/**\n * A full-width, non-dismissible banner for critical messages such as account blocks or\n * time-sensitive actions that require immediate user attention.\n\n * @see {@link https://wise.design/components/critical-banner Design Spec}\n */\nexport const CriticalBanner = ({\n sentiment = 'negative',\n title,\n description,\n media = {},\n action,\n actionSecondary,\n expanded: expandedProp,\n onToggle,\n id,\n className,\n 'data-testid': testId,\n}: CriticalBannerProps) => {\n const [containerRef, isDesktop] = useContainerSize(Breakpoint.MEDIUM);\n const isControlled = expandedProp !== undefined && onToggle !== undefined;\n const [internalExpanded, setInternalExpanded] = useState(true);\n const resolvedExpanded = isDesktop ? true : isControlled ? expandedProp : internalExpanded;\n const handleToggle = isControlled\n ? onToggle\n : () => setInternalExpanded((previousExpanded) => !previousExpanded);\n const hasActions = action ?? actionSecondary;\n const mediaId = useId();\n const titleId = useId();\n const descId = useId();\n\n const ariaLabelledByIds = [\n media['aria-hidden'] ? undefined : mediaId,\n !title ? undefined : titleId,\n ]\n .filter(Boolean)\n .join(' ');\n\n return (\n <LiveRegion\n aria-live=\"assertive\"\n announceOnChange={buildAnnouncementString({\n title,\n description,\n expanded: resolvedExpanded,\n actionLabel: action?.label,\n actionSecondaryLabel: actionSecondary?.label,\n })}\n >\n <PrimitivePrompt\n ref={containerRef}\n id={id}\n sentiment={sentiment}\n emphasis={sentiment === 'neutral' ? 'base' : 'elevated'}\n data-testid={testId}\n className={clsx(\n 'wds-critical-banner',\n {\n 'wds-critical-banner--collapsed': !resolvedExpanded,\n 'wds-critical-banner--with-two-actions': !!actionSecondary,\n },\n className,\n )}\n media={renderPromptMedia({\n media,\n sentiment,\n mediaId,\n imgClassName: 'wds-critical-banner--media-image',\n })}\n actions={\n hasActions ? (\n <div aria-hidden={!resolvedExpanded ? true : undefined} style={{ display: 'contents' }}>\n {actionSecondary && (\n // @ts-expect-error onClick type mismatch\n <Button\n v2\n size=\"md\"\n priority=\"secondary\"\n href={actionSecondary.href}\n tabIndex={resolvedExpanded ? undefined : -1}\n onClick={actionSecondary?.onClick}\n >\n {actionSecondary.label}\n </Button>\n )}\n {action && (\n // @ts-expect-error onClick type mismatch\n <Button\n v2\n size=\"md\"\n priority=\"primary\"\n href={action.href}\n tabIndex={resolvedExpanded ? undefined : -1}\n onClick={action.onClick}\n >\n {action.label}\n </Button>\n )}\n </div>\n ) : undefined\n }\n role=\"region\"\n aria-labelledby={ariaLabelledByIds || undefined}\n aria-describedby={description ? descId : undefined}\n >\n <div className=\"wds-critical-banner__text-wrapper\">\n {title && (\n <Body\n id={titleId}\n type={Typography.BODY_LARGE_BOLD}\n className=\"wds-critical-banner__content wds-critical-banner__title\"\n >\n {title}\n </Body>\n )}\n {description && (\n <Body\n id={descId}\n className={clsx('wds-critical-banner__content', 'wds-critical-banner__description', {\n 'wds-critical-banner__description--with-title': !!title,\n })}\n >\n {description}\n </Body>\n )}\n </div>\n <ExpanderToggle\n expanded={resolvedExpanded}\n size={24}\n className=\"wds-critical-banner__toggle\"\n onToggle={handleToggle}\n />\n </PrimitivePrompt>\n </LiveRegion>\n );\n};\n\nexport default CriticalBanner;\n"],"names":["CriticalBanner","sentiment","title","description","media","action","actionSecondary","expanded","expandedProp","onToggle","id","className","testId","containerRef","isDesktop","useContainerSize","Breakpoint","MEDIUM","isControlled","undefined","internalExpanded","setInternalExpanded","useState","resolvedExpanded","handleToggle","previousExpanded","hasActions","mediaId","useId","titleId","descId","ariaLabelledByIds","filter","Boolean","join","_jsx","LiveRegion","announceOnChange","buildAnnouncementString","actionLabel","label","actionSecondaryLabel","children","_jsxs","PrimitivePrompt","ref","emphasis","clsx","renderPromptMedia","imgClassName","actions","style","display","Button","v2","size","priority","href","tabIndex","onClick","role","Body","type","Typography","BODY_LARGE_BOLD","ExpanderToggle"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAMA,cAAc,GAAGA,CAAC;AAC7BC,EAAAA,SAAS,GAAG,UAAU;EACtBC,KAAK;EACLC,WAAW;EACXC,KAAK,GAAG,EAAE;EACVC,MAAM;EACNC,eAAe;AACfC,EAAAA,QAAQ,EAAEC,YAAY;EACtBC,QAAQ;EACRC,EAAE;EACFC,SAAS;AACT,EAAA,aAAa,EAAEC;AAAM,CACD,KAAI;EACxB,MAAM,CAACC,YAAY,EAAEC,SAAS,CAAC,GAAGC,iCAAgB,CAACC,qBAAU,CAACC,MAAM,CAAC;EACrE,MAAM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