@transferwise/components 0.0.0-experimental-d73d39f → 0.0.0-experimental-807a5a3
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/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 +164 -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 +142 -0
- package/build/prompt/CriticalBanner/CriticalBanner.js.map +1 -0
- package/build/prompt/CriticalBanner/CriticalBanner.mjs +140 -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 +164 -29
- package/build/styles/prompt/CriticalBanner/CriticalBanner.css +108 -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/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 +121 -0
- package/src/common/hooks/useContainerSize.ts +32 -0
- package/src/common/hooks/useResizeObserver.ts +3 -2
- package/src/i18n/en.json +2 -0
- package/src/index.ts +2 -2
- package/src/main.css +164 -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 +108 -0
- package/src/prompt/CriticalBanner/CriticalBanner.less +127 -0
- package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +633 -0
- package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +422 -0
- package/src/prompt/CriticalBanner/CriticalBanner.tsx +178 -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
|
@@ -32187,6 +32187,170 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32187
32187
|
padding: 0;
|
|
32188
32188
|
}
|
|
32189
32189
|
|
|
32190
|
+
.wds-action-prompt {
|
|
32191
|
+
--Prompt-padding: var(--size-16);
|
|
32192
|
+
--Prompt-actions-gap: var(--size-8);
|
|
32193
|
+
--Prompt-gap: var(--size-10) var(--size-16);
|
|
32194
|
+
--Prompt-border-radius: var(--radius-large);
|
|
32195
|
+
}
|
|
32196
|
+
|
|
32197
|
+
.wds-action-prompt--media-image {
|
|
32198
|
+
width: 48px;
|
|
32199
|
+
width: var(--size-48);
|
|
32200
|
+
height: 48px;
|
|
32201
|
+
height: var(--size-48);
|
|
32202
|
+
-o-object-fit: contain;
|
|
32203
|
+
object-fit: contain;
|
|
32204
|
+
}
|
|
32205
|
+
|
|
32206
|
+
@media (max-width: 767px) {
|
|
32207
|
+
.wds-action-prompt--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
|
|
32208
|
+
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
32209
|
+
min-width: -moz-fit-content;
|
|
32210
|
+
min-width: fit-content;
|
|
32211
|
+
}
|
|
32212
|
+
}
|
|
32213
|
+
|
|
32214
|
+
.wds-action-prompt__content {
|
|
32215
|
+
max-width: calc(48px * 10);
|
|
32216
|
+
max-width: calc(var(--size-48) * 10);
|
|
32217
|
+
}
|
|
32218
|
+
|
|
32219
|
+
.wds-critical-banner {
|
|
32220
|
+
--Prompt-padding: var(--size-16);
|
|
32221
|
+
--Prompt-actions-gap: var(--size-8);
|
|
32222
|
+
--Prompt-gap: var(--size-10) var(--size-16);
|
|
32223
|
+
--Prompt-border-radius: 0;
|
|
32224
|
+
container-type: inline-size;
|
|
32225
|
+
--critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
|
|
32226
|
+
--critical-banner-duration: 150ms;
|
|
32227
|
+
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
32228
|
+
actions only go full-width below mobile-max token (container query) */
|
|
32229
|
+
}
|
|
32230
|
+
|
|
32231
|
+
.wds-critical-banner--media-image {
|
|
32232
|
+
width: 48px;
|
|
32233
|
+
width: var(--size-48);
|
|
32234
|
+
height: 48px;
|
|
32235
|
+
height: var(--size-48);
|
|
32236
|
+
-o-object-fit: contain;
|
|
32237
|
+
object-fit: contain;
|
|
32238
|
+
}
|
|
32239
|
+
|
|
32240
|
+
.wds-critical-banner--collapsed .wds-critical-banner__title {
|
|
32241
|
+
display: -webkit-box;
|
|
32242
|
+
-webkit-line-clamp: 2;
|
|
32243
|
+
line-clamp: 2;
|
|
32244
|
+
-webkit-box-orient: vertical;
|
|
32245
|
+
overflow: hidden;
|
|
32246
|
+
}
|
|
32247
|
+
|
|
32248
|
+
.wds-critical-banner__description {
|
|
32249
|
+
max-height: 30vh;
|
|
32250
|
+
opacity: 1;
|
|
32251
|
+
overflow: hidden;
|
|
32252
|
+
transition: max-height var(--critical-banner-duration) var(--critical-banner-easing), opacity var(--critical-banner-duration) var(--critical-banner-easing);
|
|
32253
|
+
}
|
|
32254
|
+
|
|
32255
|
+
.wds-critical-banner--collapsed .wds-critical-banner__description--with-title {
|
|
32256
|
+
max-height: 0;
|
|
32257
|
+
opacity: 0;
|
|
32258
|
+
}
|
|
32259
|
+
|
|
32260
|
+
.wds-critical-banner--collapsed .wds-critical-banner__description:not(.wds-critical-banner__description--with-title) {
|
|
32261
|
+
display: -webkit-box;
|
|
32262
|
+
-webkit-line-clamp: 2;
|
|
32263
|
+
line-clamp: 2;
|
|
32264
|
+
-webkit-box-orient: vertical;
|
|
32265
|
+
overflow: hidden;
|
|
32266
|
+
}
|
|
32267
|
+
|
|
32268
|
+
.wds-critical-banner .wds-prompt__content-wrapper {
|
|
32269
|
+
grid-template-columns: auto 1fr auto;
|
|
32270
|
+
align-items: flex-start;
|
|
32271
|
+
transition: row-gap var(--critical-banner-duration) var(--critical-banner-easing);
|
|
32272
|
+
}
|
|
32273
|
+
|
|
32274
|
+
.wds-critical-banner--collapsed .wds-prompt__content-wrapper {
|
|
32275
|
+
row-gap: 0;
|
|
32276
|
+
}
|
|
32277
|
+
|
|
32278
|
+
.wds-critical-banner__text-wrapper {
|
|
32279
|
+
display: flex;
|
|
32280
|
+
flex-direction: column;
|
|
32281
|
+
justify-content: center;
|
|
32282
|
+
min-width: 0;
|
|
32283
|
+
max-width: 480px;
|
|
32284
|
+
height: 100%;
|
|
32285
|
+
}
|
|
32286
|
+
|
|
32287
|
+
.wds-critical-banner__toggle {
|
|
32288
|
+
flex-shrink: 0;
|
|
32289
|
+
transition: transform var(--critical-banner-duration) var(--critical-banner-easing);
|
|
32290
|
+
}
|
|
32291
|
+
|
|
32292
|
+
.wds-critical-banner__toggle--collapsed {
|
|
32293
|
+
transform: rotate(180deg);
|
|
32294
|
+
}
|
|
32295
|
+
|
|
32296
|
+
@container (min-width: 768px) {
|
|
32297
|
+
.wds-critical-banner__toggle {
|
|
32298
|
+
display: none;
|
|
32299
|
+
}
|
|
32300
|
+
}
|
|
32301
|
+
|
|
32302
|
+
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
32303
|
+
grid-column-start: 2;
|
|
32304
|
+
grid-column-end: 3;
|
|
32305
|
+
max-height: 200px;
|
|
32306
|
+
opacity: 1;
|
|
32307
|
+
overflow: visible;
|
|
32308
|
+
}
|
|
32309
|
+
|
|
32310
|
+
@container (max-width: 480px) {
|
|
32311
|
+
.wds-critical-banner .wds-prompt__actions-wrapper {
|
|
32312
|
+
grid-column: span 3;
|
|
32313
|
+
width: 100%;
|
|
32314
|
+
}
|
|
32315
|
+
.wds-critical-banner .wds-prompt__actions-wrapper .wds-Button {
|
|
32316
|
+
flex: 1 1 100%;
|
|
32317
|
+
width: 100%;
|
|
32318
|
+
}
|
|
32319
|
+
}
|
|
32320
|
+
|
|
32321
|
+
.wds-critical-banner--collapsed .wds-prompt__actions-wrapper {
|
|
32322
|
+
max-height: 0;
|
|
32323
|
+
opacity: 0;
|
|
32324
|
+
overflow: hidden;
|
|
32325
|
+
pointer-events: none;
|
|
32326
|
+
}
|
|
32327
|
+
|
|
32328
|
+
@container (max-width: 480px) {
|
|
32329
|
+
.wds-critical-banner--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
|
|
32330
|
+
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
32331
|
+
min-width: -moz-fit-content;
|
|
32332
|
+
min-width: fit-content;
|
|
32333
|
+
}
|
|
32334
|
+
}
|
|
32335
|
+
|
|
32336
|
+
@media (prefers-reduced-motion: reduce) {
|
|
32337
|
+
.wds-critical-banner__description,
|
|
32338
|
+
.wds-critical-banner .wds-prompt__content-wrapper,
|
|
32339
|
+
.wds-critical-banner__toggle {
|
|
32340
|
+
transition: none !important;
|
|
32341
|
+
}
|
|
32342
|
+
}
|
|
32343
|
+
|
|
32344
|
+
.wds-expander-toggle {
|
|
32345
|
+
align-self: flex-start;
|
|
32346
|
+
flex-shrink: 0;
|
|
32347
|
+
transition: transform 0.2s ease-in-out;
|
|
32348
|
+
}
|
|
32349
|
+
|
|
32350
|
+
.wds-expander-toggle--collapsed {
|
|
32351
|
+
transform: rotate(180deg);
|
|
32352
|
+
}
|
|
32353
|
+
|
|
32190
32354
|
.wds-radio-group .np-radio:last-child label {
|
|
32191
32355
|
margin-bottom: 0;
|
|
32192
32356
|
}
|
|
@@ -34612,32 +34776,3 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
34612
34776
|
.np-list-item__action {
|
|
34613
34777
|
flex-shrink: 0;
|
|
34614
34778
|
}
|
|
34615
|
-
|
|
34616
|
-
.wds-action-prompt {
|
|
34617
|
-
--Prompt-padding: var(--size-16);
|
|
34618
|
-
--Prompt-actions-gap: var(--size-8);
|
|
34619
|
-
--Prompt-gap: var(--size-10) var(--size-16);
|
|
34620
|
-
--Prompt-border-radius: var(--radius-large);
|
|
34621
|
-
}
|
|
34622
|
-
|
|
34623
|
-
.wds-action-prompt--media-image {
|
|
34624
|
-
width: 48px;
|
|
34625
|
-
width: var(--size-48);
|
|
34626
|
-
height: 48px;
|
|
34627
|
-
height: var(--size-48);
|
|
34628
|
-
-o-object-fit: contain;
|
|
34629
|
-
object-fit: contain;
|
|
34630
|
-
}
|
|
34631
|
-
|
|
34632
|
-
@media (max-width: 767px) {
|
|
34633
|
-
.wds-action-prompt--with-two-actions .wds-prompt__actions-wrapper .wds-Button {
|
|
34634
|
-
flex: 1 1 calc(50% - (var(--Prompt-actions-gap) / 2));
|
|
34635
|
-
min-width: -moz-fit-content;
|
|
34636
|
-
min-width: fit-content;
|
|
34637
|
-
}
|
|
34638
|
-
}
|
|
34639
|
-
|
|
34640
|
-
.wds-action-prompt__content {
|
|
34641
|
-
max-width: calc(48px * 10);
|
|
34642
|
-
max-width: calc(var(--size-48) * 10);
|
|
34643
|
-
}
|
|
@@ -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,GAA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BC,QAAAA,KAAK,EAAE5B,QAAS;QAChB6B,OAAO,EAAEnC,MAAM,CAACmC,OAAQ;QAAAP,QAAA,EAEvB5B,MAAM,CAACoC;AAAK,OACP,CACV;AAAA,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,GAAG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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,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,142 @@
|
|
|
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 [internalExpanded, setInternalExpanded] = React.useState(isDesktop ? true : onToggle && expandedProp !== undefined ? expandedProp : true);
|
|
53
|
+
const resolvedExpanded = isDesktop ? true : expandedProp ?? internalExpanded;
|
|
54
|
+
const handleToggle = onToggle ?? (() => setInternalExpanded(!internalExpanded));
|
|
55
|
+
const hasActions = action ?? actionSecondary;
|
|
56
|
+
const mediaId = React.useId();
|
|
57
|
+
const titleId = React.useId();
|
|
58
|
+
const descId = React.useId();
|
|
59
|
+
const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, !title ? undefined : titleId].filter(Boolean).join(' ');
|
|
60
|
+
return /*#__PURE__*/jsxRuntime.jsx(LiveRegion.LiveRegion, {
|
|
61
|
+
"aria-live": "assertive",
|
|
62
|
+
announceOnChange: helpers.buildAnnouncementString({
|
|
63
|
+
title,
|
|
64
|
+
description,
|
|
65
|
+
expanded: resolvedExpanded,
|
|
66
|
+
actionLabel: action?.label,
|
|
67
|
+
actionSecondaryLabel: actionSecondary?.label
|
|
68
|
+
}),
|
|
69
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(PrimitivePrompt.PrimitivePrompt, {
|
|
70
|
+
ref: containerRef,
|
|
71
|
+
id: id,
|
|
72
|
+
sentiment: sentiment,
|
|
73
|
+
emphasis: sentiment === 'neutral' ? 'base' : 'elevated',
|
|
74
|
+
"data-testid": testId,
|
|
75
|
+
className: clsx.clsx('wds-critical-banner', {
|
|
76
|
+
'wds-critical-banner--collapsed': !resolvedExpanded,
|
|
77
|
+
'wds-critical-banner--with-two-actions': !!actionSecondary
|
|
78
|
+
}, className),
|
|
79
|
+
media: promptMedia.renderPromptMedia({
|
|
80
|
+
media,
|
|
81
|
+
sentiment,
|
|
82
|
+
mediaId,
|
|
83
|
+
imgClassName: 'wds-critical-banner--media-image'
|
|
84
|
+
}),
|
|
85
|
+
actions: hasActions ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
86
|
+
"aria-hidden": !resolvedExpanded ? true : undefined,
|
|
87
|
+
style: {
|
|
88
|
+
display: 'contents'
|
|
89
|
+
},
|
|
90
|
+
children: [actionSecondary &&
|
|
91
|
+
/*#__PURE__*/
|
|
92
|
+
// @ts-expect-error onClick type mismatch
|
|
93
|
+
jsxRuntime.jsx(Button_resolver.default, {
|
|
94
|
+
v2: true,
|
|
95
|
+
size: "md",
|
|
96
|
+
priority: "secondary",
|
|
97
|
+
href: actionSecondary.href,
|
|
98
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
99
|
+
onClick: actionSecondary?.onClick,
|
|
100
|
+
children: actionSecondary.label
|
|
101
|
+
}), action &&
|
|
102
|
+
/*#__PURE__*/
|
|
103
|
+
// @ts-expect-error onClick type mismatch
|
|
104
|
+
jsxRuntime.jsx(Button_resolver.default, {
|
|
105
|
+
v2: true,
|
|
106
|
+
size: "md",
|
|
107
|
+
priority: "primary",
|
|
108
|
+
href: action.href,
|
|
109
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
110
|
+
onClick: action.onClick,
|
|
111
|
+
children: action.label
|
|
112
|
+
})]
|
|
113
|
+
}) : undefined,
|
|
114
|
+
role: "region",
|
|
115
|
+
"aria-labelledby": ariaLabelledByIds,
|
|
116
|
+
"aria-describedby": descId,
|
|
117
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
118
|
+
className: "wds-critical-banner__text-wrapper",
|
|
119
|
+
children: [title && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
120
|
+
id: titleId,
|
|
121
|
+
type: typography.Typography.BODY_LARGE_BOLD,
|
|
122
|
+
className: "wds-critical-banner__content wds-critical-banner__title",
|
|
123
|
+
children: title
|
|
124
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
125
|
+
id: descId,
|
|
126
|
+
className: clsx.clsx('wds-critical-banner__content', 'wds-critical-banner__description', {
|
|
127
|
+
'wds-critical-banner__description--with-title': !!title
|
|
128
|
+
}),
|
|
129
|
+
children: description
|
|
130
|
+
})]
|
|
131
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Expander.ExpanderToggle, {
|
|
132
|
+
expanded: resolvedExpanded,
|
|
133
|
+
size: 24,
|
|
134
|
+
className: "wds-critical-banner__toggle",
|
|
135
|
+
onToggle: handleToggle
|
|
136
|
+
})]
|
|
137
|
+
})
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
exports.CriticalBanner = CriticalBanner;
|
|
142
|
+
//# sourceMappingURL=CriticalBanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CriticalBanner.js","sources":["../../../src/prompt/CriticalBanner/CriticalBanner.tsx"],"sourcesContent":["import { ReactNode, useEffect, 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 >= 480px), 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 [internalExpanded, setInternalExpanded] = useState(\n isDesktop ? true : onToggle && expandedProp !== undefined ? expandedProp : true,\n );\n const resolvedExpanded = isDesktop ? true : (expandedProp ?? internalExpanded);\n const handleToggle = onToggle ?? (() => setInternalExpanded(!internalExpanded));\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}\n aria-describedby={descId}\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","internalExpanded","setInternalExpanded","useState","undefined","resolvedExpanded","handleToggle","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,C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