@transferwise/components 46.147.0 → 46.148.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/main.css +53 -0
- package/build/prompt/CriticalBanner/CriticalBanner.js +78 -68
- package/build/prompt/CriticalBanner/CriticalBanner.js.map +1 -1
- package/build/prompt/CriticalBanner/CriticalBanner.mjs +79 -69
- package/build/prompt/CriticalBanner/CriticalBanner.mjs.map +1 -1
- package/build/styles/main.css +53 -0
- package/build/styles/prompt/CriticalBanner/CriticalBanner.css +48 -0
- package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/accordion/Accordion.story.tsx +25 -0
- package/src/avatarLayout/AvatarLayout.story.tsx +10 -0
- package/src/avatarView/AvatarView.story.tsx +8 -0
- package/src/body/Body.story.tsx +12 -0
- package/src/button/_stories/Button.story.tsx +7 -1
- package/src/calendar/Calendar.story.tsx +19 -7
- package/src/carousel/Carousel.story.tsx +35 -0
- package/src/checkbox/Checkbox.story.tsx +20 -0
- package/src/checkboxButton/CheckboxButton.story.tsx +16 -0
- package/src/chevron/Chevron.story.tsx +6 -0
- package/src/chips/Chips.story.tsx +23 -0
- package/src/circularButton/CircularButton.story.tsx +13 -0
- package/src/common/baseCard/BaseCard.story.tsx +12 -0
- package/src/common/bottomSheet/BottomSheet.story.tsx +21 -0
- package/src/common/circle/Circle.story.tsx +11 -0
- package/src/container/Container.story.tsx +12 -0
- package/src/dateInput/DateInput.story.tsx +20 -0
- package/src/dateLookup/DateLookup.story.tsx +23 -0
- package/src/decision/Decision.story.tsx +36 -0
- package/src/definitionList/DefinitionList.story.tsx +16 -0
- package/src/dimmer/Dimmer.story.tsx +24 -0
- package/src/display/Display.story.tsx +11 -0
- package/src/divider/Divider.story.tsx +6 -0
- package/src/drawer/Drawer.story.tsx +25 -0
- package/src/dropFade/DropFade.story.tsx +27 -0
- package/src/emphasis/Emphasis.story.tsx +10 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +37 -0
- package/src/field/Field.story.tsx +16 -0
- package/src/flowNavigation/FlowNavigation.story.tsx +25 -0
- package/src/header/Header.story.tsx +17 -0
- package/src/iconButton/IconButton.story.tsx +14 -0
- package/src/image/Image.story.tsx +11 -0
- package/src/info/Info.story.tsx +10 -0
- package/src/inputWithDisplayFormat/InputWithDisplayFormat.story.tsx +23 -0
- package/src/inputs/InputGroup.story.tsx +37 -0
- package/src/inputs/SearchInput.story.tsx +22 -0
- package/src/inputs/SelectInput/_stories/SelectInput.story.tsx +42 -0
- package/src/inputs/TextArea.story.tsx +22 -0
- package/src/instructionsList/InstructionsList.story.tsx +19 -0
- package/src/label/Label.story.tsx +17 -0
- package/src/link/Link.story.tsx +11 -0
- package/src/list/List.story.tsx +19 -0
- package/src/listItem/_stories/ListItem.story.tsx +20 -0
- package/src/loader/Loader.story.tsx +6 -0
- package/src/logo/Logo.story.tsx +6 -0
- package/src/main.css +53 -0
- package/src/markdown/Markdown.story.tsx +17 -0
- package/src/modal/Modal.story.tsx +23 -0
- package/src/money/Money.story.tsx +7 -0
- package/src/moneyInput/MoneyInput.story.tsx +34 -0
- package/src/nudge/Nudge.story.tsx +17 -0
- package/src/overlayHeader/OverlayHeader.story.tsx +10 -0
- package/src/phoneNumberInput/PhoneNumberInput.story.tsx +23 -0
- package/src/popover/Popover.story.tsx +12 -0
- package/src/primitives/PrimitiveAnchor/stories/PrimitiveAnchor.story.tsx +11 -0
- package/src/primitives/PrimitiveButton/stories/PrimitiveButton.story.tsx +11 -0
- package/src/processIndicator/ProcessIndicator.story.tsx +10 -0
- package/src/progress/Progress.story.tsx +6 -0
- package/src/progressBar/ProgressBar.story.tsx +12 -0
- package/src/promoCard/PromoCard.story.tsx +15 -0
- package/src/promoCard/PromoCardGroup.story.tsx +28 -0
- package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +31 -0
- package/src/prompt/CriticalBanner/CriticalBanner.accessibility.docs.mdx +9 -0
- package/src/prompt/CriticalBanner/CriticalBanner.css +48 -0
- package/src/prompt/CriticalBanner/CriticalBanner.less +72 -0
- package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +180 -169
- package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +25 -6
- package/src/prompt/CriticalBanner/CriticalBanner.test.tsx +37 -0
- package/src/prompt/CriticalBanner/CriticalBanner.tsx +92 -83
- package/src/prompt/CriticalBanner/CriticalBanner.vars.less +1 -0
- package/src/prompt/InfoPrompt/InfoPrompt.story.tsx +30 -0
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +14 -0
- package/src/radio/Radio.story.tsx +34 -0
- package/src/radioGroup/RadioGroup.story.tsx +26 -0
- package/src/section/Section.story.tsx +15 -0
- package/src/segmentedControl/SegmentedControl.story.tsx +27 -0
- package/src/sentimentSurface/SentimentSurface.story.tsx +11 -0
- package/src/slidingPanel/SlidingPanel.story.tsx +19 -0
- package/src/snackbar/Snackbar.story.tsx +24 -0
- package/src/statusIcon/StatusIcon.story.tsx +6 -0
- package/src/stepper/Stepper.story.tsx +30 -0
- package/src/sticky/Sticky.story.tsx +22 -1
- package/src/switch/Switch.story.tsx +17 -0
- package/src/table/Table.story.tsx +32 -0
- package/src/tabs/Tabs.story.tsx +31 -0
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +23 -0
- package/src/tile/Tile.story.tsx +13 -0
- package/src/title/Title.story.tsx +12 -0
- package/src/tooltip/Tooltip.story.tsx +8 -0
- package/src/typeahead/Typeahead.story.tsx +33 -0
- package/src/upload/Upload.story.tsx +24 -0
- package/src/uploadInput/UploadInput.story.tsx +31 -0
package/build/main.css
CHANGED
|
@@ -31935,6 +31935,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
31935
31935
|
--Prompt-gap: var(--size-10) var(--size-16);
|
|
31936
31936
|
--Prompt-border-radius: 0;
|
|
31937
31937
|
container-type: inline-size;
|
|
31938
|
+
position: relative;
|
|
31938
31939
|
--critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
|
|
31939
31940
|
--critical-banner-duration: 150ms;
|
|
31940
31941
|
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
@@ -32075,6 +32076,53 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32075
32076
|
}
|
|
32076
32077
|
}
|
|
32077
32078
|
|
|
32079
|
+
.wds-critical-banner-overhang-query {
|
|
32080
|
+
container-name: critical-banner-overhang;
|
|
32081
|
+
container-type: inline-size;
|
|
32082
|
+
inline-size: 100%;
|
|
32083
|
+
}
|
|
32084
|
+
|
|
32085
|
+
.wds-critical-banner__entry-mask {
|
|
32086
|
+
display: grid;
|
|
32087
|
+
grid-template-rows: 0fr;
|
|
32088
|
+
overflow: hidden;
|
|
32089
|
+
animation: wds-critical-banner-reveal-height 400ms cubic-bezier(0.3, 0, 0.1, 1) 500ms both;
|
|
32090
|
+
}
|
|
32091
|
+
|
|
32092
|
+
@container critical-banner-overhang (max-width: 600px) {
|
|
32093
|
+
.wds-critical-banner__entry-mask {
|
|
32094
|
+
--critical-banner-mobile-overhang-size: 32px;
|
|
32095
|
+
}
|
|
32096
|
+
.wds-critical-banner__entry-mask .wds-critical-banner-overhang {
|
|
32097
|
+
margin-bottom: var(--critical-banner-mobile-overhang-size);
|
|
32098
|
+
}
|
|
32099
|
+
.wds-critical-banner__entry-mask .wds-critical-banner-overhang::after {
|
|
32100
|
+
content: "";
|
|
32101
|
+
position: absolute;
|
|
32102
|
+
right: 0;
|
|
32103
|
+
bottom: calc(-1 * var(--critical-banner-mobile-overhang-size));
|
|
32104
|
+
left: 0;
|
|
32105
|
+
height: var(--critical-banner-mobile-overhang-size);
|
|
32106
|
+
pointer-events: none;
|
|
32107
|
+
background: radial-gradient(circle at 100% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 0 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat, radial-gradient(circle at 0% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 100% 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat;
|
|
32108
|
+
}
|
|
32109
|
+
}
|
|
32110
|
+
|
|
32111
|
+
.wds-critical-banner__entry-track {
|
|
32112
|
+
min-height: 0;
|
|
32113
|
+
}
|
|
32114
|
+
|
|
32115
|
+
@keyframes wds-critical-banner-reveal-height {
|
|
32116
|
+
from {
|
|
32117
|
+
grid-template-rows: 0fr;
|
|
32118
|
+
overflow: hidden;
|
|
32119
|
+
}
|
|
32120
|
+
to {
|
|
32121
|
+
grid-template-rows: 1fr;
|
|
32122
|
+
overflow: visible;
|
|
32123
|
+
}
|
|
32124
|
+
}
|
|
32125
|
+
|
|
32078
32126
|
@media (prefers-reduced-motion: reduce) {
|
|
32079
32127
|
.wds-critical-banner__description,
|
|
32080
32128
|
.wds-critical-banner__title,
|
|
@@ -32082,6 +32130,11 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32082
32130
|
.wds-critical-banner__toggle {
|
|
32083
32131
|
transition: none !important;
|
|
32084
32132
|
}
|
|
32133
|
+
.wds-critical-banner__entry-mask {
|
|
32134
|
+
animation: none;
|
|
32135
|
+
grid-template-rows: 1fr;
|
|
32136
|
+
overflow: visible;
|
|
32137
|
+
}
|
|
32085
32138
|
}
|
|
32086
32139
|
|
|
32087
32140
|
.wds-expander-toggle {
|
|
@@ -58,6 +58,75 @@ const CriticalBanner = ({
|
|
|
58
58
|
const titleId = React.useId();
|
|
59
59
|
const descId = React.useId();
|
|
60
60
|
const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, !title ? undefined : titleId].filter(Boolean).join(' ');
|
|
61
|
+
const bannerSurface = /*#__PURE__*/jsxRuntime.jsxs(PrimitivePrompt.PrimitivePrompt, {
|
|
62
|
+
ref: containerRef,
|
|
63
|
+
id: id,
|
|
64
|
+
sentiment: sentiment,
|
|
65
|
+
emphasis: sentiment === 'neutral' ? 'base' : 'elevated',
|
|
66
|
+
"data-testid": testId,
|
|
67
|
+
className: clsx.clsx('wds-critical-banner', 'wds-critical-banner-overhang', {
|
|
68
|
+
'wds-critical-banner--collapsed': !resolvedExpanded,
|
|
69
|
+
'wds-critical-banner--with-two-actions': !!actionSecondary
|
|
70
|
+
}, className),
|
|
71
|
+
media: promptMedia.renderPromptMedia({
|
|
72
|
+
media,
|
|
73
|
+
sentiment,
|
|
74
|
+
mediaId,
|
|
75
|
+
imgClassName: 'wds-critical-banner--media-image'
|
|
76
|
+
}),
|
|
77
|
+
actions: hasActions ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
78
|
+
"aria-hidden": !resolvedExpanded ? true : undefined,
|
|
79
|
+
style: {
|
|
80
|
+
display: 'contents'
|
|
81
|
+
},
|
|
82
|
+
children: [actionSecondary &&
|
|
83
|
+
/*#__PURE__*/
|
|
84
|
+
// @ts-expect-error onClick type mismatch
|
|
85
|
+
jsxRuntime.jsx(Button_resolver.default, {
|
|
86
|
+
v2: true,
|
|
87
|
+
size: "md",
|
|
88
|
+
priority: "secondary",
|
|
89
|
+
href: actionSecondary.href,
|
|
90
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
91
|
+
onClick: actionSecondary?.onClick,
|
|
92
|
+
children: actionSecondary.label
|
|
93
|
+
}), action &&
|
|
94
|
+
/*#__PURE__*/
|
|
95
|
+
// @ts-expect-error onClick type mismatch
|
|
96
|
+
jsxRuntime.jsx(Button_resolver.default, {
|
|
97
|
+
v2: true,
|
|
98
|
+
size: "md",
|
|
99
|
+
priority: "primary",
|
|
100
|
+
href: action.href,
|
|
101
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
102
|
+
onClick: action.onClick,
|
|
103
|
+
children: action.label
|
|
104
|
+
})]
|
|
105
|
+
}) : undefined,
|
|
106
|
+
role: "region",
|
|
107
|
+
"aria-labelledby": ariaLabelledByIds || undefined,
|
|
108
|
+
"aria-describedby": description ? descId : undefined,
|
|
109
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
110
|
+
className: "wds-critical-banner__text-wrapper",
|
|
111
|
+
children: [title && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
112
|
+
id: titleId,
|
|
113
|
+
type: typography.Typography.BODY_LARGE_BOLD,
|
|
114
|
+
className: "wds-critical-banner__content wds-critical-banner__title",
|
|
115
|
+
children: title
|
|
116
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx(Body.default, {
|
|
117
|
+
id: descId,
|
|
118
|
+
className: clsx.clsx('wds-critical-banner__content', 'wds-critical-banner__description', {
|
|
119
|
+
'wds-critical-banner__description--with-title': !!title
|
|
120
|
+
}),
|
|
121
|
+
children: description
|
|
122
|
+
})]
|
|
123
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Expander.ExpanderToggle, {
|
|
124
|
+
expanded: resolvedExpanded,
|
|
125
|
+
size: 24,
|
|
126
|
+
className: "wds-critical-banner__toggle",
|
|
127
|
+
onToggle: handleToggle
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
61
130
|
return /*#__PURE__*/jsxRuntime.jsx(LiveRegion.LiveRegion, {
|
|
62
131
|
"aria-live": "assertive",
|
|
63
132
|
announceOnChange: helpers.buildAnnouncementString({
|
|
@@ -67,74 +136,15 @@ const CriticalBanner = ({
|
|
|
67
136
|
actionLabel: action?.label,
|
|
68
137
|
actionSecondaryLabel: actionSecondary?.label
|
|
69
138
|
}),
|
|
70
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
})]
|
|
139
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
140
|
+
className: "wds-critical-banner-overhang-query",
|
|
141
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
142
|
+
className: "wds-critical-banner__entry-mask",
|
|
143
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
144
|
+
className: "wds-critical-banner__entry-track",
|
|
145
|
+
children: bannerSurface
|
|
146
|
+
})
|
|
147
|
+
})
|
|
138
148
|
})
|
|
139
149
|
});
|
|
140
150
|
};
|
|
@@ -1 +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://docs.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,wBAAU,CAACC,MAAM,CAAC;EACrE,MAAMC,YAAY,GAAGV,YAAY,KAAKW,SAAS,IAAIV,QAAQ,KAAKU,SAAS;EACzE,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGC,cAAQ,CAAC,IAAI,CAAC;EAC9D,MAAMC,gBAAgB,GAAGT,SAAS,GAAG,IAAI,GAAGI,YAAY,GAAGV,YAAY,GAAGY,gBAAgB;AAC1F,EAAA,MAAMI,YAAY,GAAGN,YAAY,GAC7BT,QAAQ,GACR,MAAMY,mBAAmB,CAAEI,gBAAgB,IAAK,CAACA,gBAAgB,CAAC;AACtE,EAAA,MAAMC,UAAU,GAAGrB,MAAM,IAAIC,eAAe;AAC5C,EAAA,MAAMqB,OAAO,GAAGC,WAAK,EAAE;AACvB,EAAA,MAAMC,OAAO,GAAGD,WAAK,EAAE;AACvB,EAAA,MAAME,MAAM,GAAGF,WAAK,EAAE;AAEtB,EAAA,MAAMG,iBAAiB,GAAG,CACxB3B,KAAK,CAAC,aAAa,CAAC,GAAGe,SAAS,GAAGQ,OAAO,EAC1C,CAACzB,KA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,CAAC7C;AACnD,WAAA,CAAE;AAAAwC,UAAAA,QAAA,EAEFvC;AAAW,SACR,CACP;AAAA,OACE,CACL,eAAAgC,cAAA,CAAC8B,uBAAc,EAAA;AACb1D,QAAAA,QAAQ,EAAEgB,gBAAiB;AAC3BgC,QAAAA,IAAI,EAAE,EAAG;AACT5C,QAAAA,SAAS,EAAC,6BAA6B;AACvCF,QAAAA,QAAQ,EAAEe;AAAa,OAAA,CAE3B;KAAiB;AACnB,GAAY,CAAC;AAEjB;;;;"}
|
|
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://docs.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 const bannerSurface = (\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 'wds-critical-banner-overhang',\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 );\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 <div className=\"wds-critical-banner-overhang-query\">\n <div className=\"wds-critical-banner__entry-mask\">\n <div className=\"wds-critical-banner__entry-track\">{bannerSurface}</div>\n </div>\n </div>\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","bannerSurface","_jsxs","PrimitivePrompt","ref","emphasis","clsx","renderPromptMedia","imgClassName","actions","style","display","children","_jsx","Button","v2","size","priority","href","tabIndex","onClick","label","role","Body","type","Typography","BODY_LARGE_BOLD","ExpanderToggle","LiveRegion","announceOnChange","buildAnnouncementString","actionLabel","actionSecondaryLabel"],"mappings":";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ACXI,MAAAA,QAAQ,EAAEgB,gBAAgB;MAC1B0C,WAAW,EAAE5D,MAAM,EAAEkD,KAAK;MAC1BW,oBAAoB,EAAE5D,eAAe,EAAEiD;AACxC,KAAA,CAAE;AAAAT,IAAAA,QAAA,eAEHC,cAAA,CAAA,KAAA,EAAA;AAAKpC,MAAAA,SAAS,EAAC,oCAAoC;AAAAmC,MAAAA,QAAA,eACjDC,cAAA,CAAA,KAAA,EAAA;AAAKpC,QAAAA,SAAS,EAAC,iCAAiC;AAAAmC,QAAAA,QAAA,eAC9CC,cAAA,CAAA,KAAA,EAAA;AAAKpC,UAAAA,SAAS,EAAC,kCAAkC;AAAAmC,UAAAA,QAAA,EAAEX;SAAmB;OACnE;KACF;AACP,GAAY,CAAC;AAEjB;;;;"}
|
|
@@ -25,7 +25,7 @@ import '@transferwise/formatting';
|
|
|
25
25
|
import '@transferwise/icons';
|
|
26
26
|
import 'react-intl';
|
|
27
27
|
import '../../common/closeButton/CloseButton.messages.mjs';
|
|
28
|
-
import {
|
|
28
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
29
29
|
import { LiveRegion } from '../../common/liveRegion/LiveRegion.mjs';
|
|
30
30
|
import { PrimitivePrompt } from '../PrimitivePrompt/PrimitivePrompt.mjs';
|
|
31
31
|
import { renderPromptMedia } from '../helpers/promptMedia.mjs';
|
|
@@ -56,6 +56,75 @@ const CriticalBanner = ({
|
|
|
56
56
|
const titleId = useId();
|
|
57
57
|
const descId = useId();
|
|
58
58
|
const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, !title ? undefined : titleId].filter(Boolean).join(' ');
|
|
59
|
+
const bannerSurface = /*#__PURE__*/jsxs(PrimitivePrompt, {
|
|
60
|
+
ref: containerRef,
|
|
61
|
+
id: id,
|
|
62
|
+
sentiment: sentiment,
|
|
63
|
+
emphasis: sentiment === 'neutral' ? 'base' : 'elevated',
|
|
64
|
+
"data-testid": testId,
|
|
65
|
+
className: clsx('wds-critical-banner', 'wds-critical-banner-overhang', {
|
|
66
|
+
'wds-critical-banner--collapsed': !resolvedExpanded,
|
|
67
|
+
'wds-critical-banner--with-two-actions': !!actionSecondary
|
|
68
|
+
}, className),
|
|
69
|
+
media: renderPromptMedia({
|
|
70
|
+
media,
|
|
71
|
+
sentiment,
|
|
72
|
+
mediaId,
|
|
73
|
+
imgClassName: 'wds-critical-banner--media-image'
|
|
74
|
+
}),
|
|
75
|
+
actions: hasActions ? /*#__PURE__*/jsxs("div", {
|
|
76
|
+
"aria-hidden": !resolvedExpanded ? true : undefined,
|
|
77
|
+
style: {
|
|
78
|
+
display: 'contents'
|
|
79
|
+
},
|
|
80
|
+
children: [actionSecondary &&
|
|
81
|
+
/*#__PURE__*/
|
|
82
|
+
// @ts-expect-error onClick type mismatch
|
|
83
|
+
jsx(Button, {
|
|
84
|
+
v2: true,
|
|
85
|
+
size: "md",
|
|
86
|
+
priority: "secondary",
|
|
87
|
+
href: actionSecondary.href,
|
|
88
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
89
|
+
onClick: actionSecondary?.onClick,
|
|
90
|
+
children: actionSecondary.label
|
|
91
|
+
}), action &&
|
|
92
|
+
/*#__PURE__*/
|
|
93
|
+
// @ts-expect-error onClick type mismatch
|
|
94
|
+
jsx(Button, {
|
|
95
|
+
v2: true,
|
|
96
|
+
size: "md",
|
|
97
|
+
priority: "primary",
|
|
98
|
+
href: action.href,
|
|
99
|
+
tabIndex: resolvedExpanded ? undefined : -1,
|
|
100
|
+
onClick: action.onClick,
|
|
101
|
+
children: action.label
|
|
102
|
+
})]
|
|
103
|
+
}) : undefined,
|
|
104
|
+
role: "region",
|
|
105
|
+
"aria-labelledby": ariaLabelledByIds || undefined,
|
|
106
|
+
"aria-describedby": description ? descId : undefined,
|
|
107
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
108
|
+
className: "wds-critical-banner__text-wrapper",
|
|
109
|
+
children: [title && /*#__PURE__*/jsx(Body, {
|
|
110
|
+
id: titleId,
|
|
111
|
+
type: Typography.BODY_LARGE_BOLD,
|
|
112
|
+
className: "wds-critical-banner__content wds-critical-banner__title",
|
|
113
|
+
children: title
|
|
114
|
+
}), description && /*#__PURE__*/jsx(Body, {
|
|
115
|
+
id: descId,
|
|
116
|
+
className: clsx('wds-critical-banner__content', 'wds-critical-banner__description', {
|
|
117
|
+
'wds-critical-banner__description--with-title': !!title
|
|
118
|
+
}),
|
|
119
|
+
children: description
|
|
120
|
+
})]
|
|
121
|
+
}), /*#__PURE__*/jsx(ExpanderToggle, {
|
|
122
|
+
expanded: resolvedExpanded,
|
|
123
|
+
size: 24,
|
|
124
|
+
className: "wds-critical-banner__toggle",
|
|
125
|
+
onToggle: handleToggle
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
59
128
|
return /*#__PURE__*/jsx(LiveRegion, {
|
|
60
129
|
"aria-live": "assertive",
|
|
61
130
|
announceOnChange: buildAnnouncementString({
|
|
@@ -65,74 +134,15 @@ const CriticalBanner = ({
|
|
|
65
134
|
actionLabel: action?.label,
|
|
66
135
|
actionSecondaryLabel: actionSecondary?.label
|
|
67
136
|
}),
|
|
68
|
-
children: /*#__PURE__*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}, className),
|
|
78
|
-
media: renderPromptMedia({
|
|
79
|
-
media,
|
|
80
|
-
sentiment,
|
|
81
|
-
mediaId,
|
|
82
|
-
imgClassName: 'wds-critical-banner--media-image'
|
|
83
|
-
}),
|
|
84
|
-
actions: hasActions ? /*#__PURE__*/jsxs("div", {
|
|
85
|
-
"aria-hidden": !resolvedExpanded ? true : undefined,
|
|
86
|
-
style: {
|
|
87
|
-
display: 'contents'
|
|
88
|
-
},
|
|
89
|
-
children: [actionSecondary &&
|
|
90
|
-
/*#__PURE__*/
|
|
91
|
-
// @ts-expect-error onClick type mismatch
|
|
92
|
-
jsx(Button, {
|
|
93
|
-
v2: true,
|
|
94
|
-
size: "md",
|
|
95
|
-
priority: "secondary",
|
|
96
|
-
href: actionSecondary.href,
|
|
97
|
-
tabIndex: resolvedExpanded ? undefined : -1,
|
|
98
|
-
onClick: actionSecondary?.onClick,
|
|
99
|
-
children: actionSecondary.label
|
|
100
|
-
}), action &&
|
|
101
|
-
/*#__PURE__*/
|
|
102
|
-
// @ts-expect-error onClick type mismatch
|
|
103
|
-
jsx(Button, {
|
|
104
|
-
v2: true,
|
|
105
|
-
size: "md",
|
|
106
|
-
priority: "primary",
|
|
107
|
-
href: action.href,
|
|
108
|
-
tabIndex: resolvedExpanded ? undefined : -1,
|
|
109
|
-
onClick: action.onClick,
|
|
110
|
-
children: action.label
|
|
111
|
-
})]
|
|
112
|
-
}) : undefined,
|
|
113
|
-
role: "region",
|
|
114
|
-
"aria-labelledby": ariaLabelledByIds || undefined,
|
|
115
|
-
"aria-describedby": description ? descId : undefined,
|
|
116
|
-
children: [/*#__PURE__*/jsxs("div", {
|
|
117
|
-
className: "wds-critical-banner__text-wrapper",
|
|
118
|
-
children: [title && /*#__PURE__*/jsx(Body, {
|
|
119
|
-
id: titleId,
|
|
120
|
-
type: Typography.BODY_LARGE_BOLD,
|
|
121
|
-
className: "wds-critical-banner__content wds-critical-banner__title",
|
|
122
|
-
children: title
|
|
123
|
-
}), description && /*#__PURE__*/jsx(Body, {
|
|
124
|
-
id: descId,
|
|
125
|
-
className: clsx('wds-critical-banner__content', 'wds-critical-banner__description', {
|
|
126
|
-
'wds-critical-banner__description--with-title': !!title
|
|
127
|
-
}),
|
|
128
|
-
children: description
|
|
129
|
-
})]
|
|
130
|
-
}), /*#__PURE__*/jsx(ExpanderToggle, {
|
|
131
|
-
expanded: resolvedExpanded,
|
|
132
|
-
size: 24,
|
|
133
|
-
className: "wds-critical-banner__toggle",
|
|
134
|
-
onToggle: handleToggle
|
|
135
|
-
})]
|
|
137
|
+
children: /*#__PURE__*/jsx("div", {
|
|
138
|
+
className: "wds-critical-banner-overhang-query",
|
|
139
|
+
children: /*#__PURE__*/jsx("div", {
|
|
140
|
+
className: "wds-critical-banner__entry-mask",
|
|
141
|
+
children: /*#__PURE__*/jsx("div", {
|
|
142
|
+
className: "wds-critical-banner__entry-track",
|
|
143
|
+
children: bannerSurface
|
|
144
|
+
})
|
|
145
|
+
})
|
|
136
146
|
})
|
|
137
147
|
});
|
|
138
148
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CriticalBanner.mjs","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://docs.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;EACtB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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://docs.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 const bannerSurface = (\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 'wds-critical-banner-overhang',\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 );\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 <div className=\"wds-critical-banner-overhang-query\">\n <div className=\"wds-critical-banner__entry-mask\">\n <div className=\"wds-critical-banner__entry-track\">{bannerSurface}</div>\n </div>\n </div>\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","bannerSurface","_jsxs","PrimitivePrompt","ref","emphasis","clsx","renderPromptMedia","imgClassName","actions","style","display","children","_jsx","Button","v2","size","priority","href","tabIndex","onClick","label","role","Body","type","Typography","BODY_LARGE_BOLD","ExpanderToggle","LiveRegion","announceOnChange","buildAnnouncementString","actionLabel","actionSecondaryLabel"],"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,gBAAgB,CAACC,UAAU,CAACC,MAAM,CAAC;EACrE,MAAMC,YAAY,GAAGV,Y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AAA,EAAEX;SAAmB;OACnE;KACF;AACP,GAAY,CAAC;AAEjB;;;;"}
|
package/build/styles/main.css
CHANGED
|
@@ -31935,6 +31935,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
31935
31935
|
--Prompt-gap: var(--size-10) var(--size-16);
|
|
31936
31936
|
--Prompt-border-radius: 0;
|
|
31937
31937
|
container-type: inline-size;
|
|
31938
|
+
position: relative;
|
|
31938
31939
|
--critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
|
|
31939
31940
|
--critical-banner-duration: 150ms;
|
|
31940
31941
|
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
@@ -32075,6 +32076,53 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32075
32076
|
}
|
|
32076
32077
|
}
|
|
32077
32078
|
|
|
32079
|
+
.wds-critical-banner-overhang-query {
|
|
32080
|
+
container-name: critical-banner-overhang;
|
|
32081
|
+
container-type: inline-size;
|
|
32082
|
+
inline-size: 100%;
|
|
32083
|
+
}
|
|
32084
|
+
|
|
32085
|
+
.wds-critical-banner__entry-mask {
|
|
32086
|
+
display: grid;
|
|
32087
|
+
grid-template-rows: 0fr;
|
|
32088
|
+
overflow: hidden;
|
|
32089
|
+
animation: wds-critical-banner-reveal-height 400ms cubic-bezier(0.3, 0, 0.1, 1) 500ms both;
|
|
32090
|
+
}
|
|
32091
|
+
|
|
32092
|
+
@container critical-banner-overhang (max-width: 600px) {
|
|
32093
|
+
.wds-critical-banner__entry-mask {
|
|
32094
|
+
--critical-banner-mobile-overhang-size: 32px;
|
|
32095
|
+
}
|
|
32096
|
+
.wds-critical-banner__entry-mask .wds-critical-banner-overhang {
|
|
32097
|
+
margin-bottom: var(--critical-banner-mobile-overhang-size);
|
|
32098
|
+
}
|
|
32099
|
+
.wds-critical-banner__entry-mask .wds-critical-banner-overhang::after {
|
|
32100
|
+
content: "";
|
|
32101
|
+
position: absolute;
|
|
32102
|
+
right: 0;
|
|
32103
|
+
bottom: calc(-1 * var(--critical-banner-mobile-overhang-size));
|
|
32104
|
+
left: 0;
|
|
32105
|
+
height: var(--critical-banner-mobile-overhang-size);
|
|
32106
|
+
pointer-events: none;
|
|
32107
|
+
background: radial-gradient(circle at 100% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 0 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat, radial-gradient(circle at 0% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 100% 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat;
|
|
32108
|
+
}
|
|
32109
|
+
}
|
|
32110
|
+
|
|
32111
|
+
.wds-critical-banner__entry-track {
|
|
32112
|
+
min-height: 0;
|
|
32113
|
+
}
|
|
32114
|
+
|
|
32115
|
+
@keyframes wds-critical-banner-reveal-height {
|
|
32116
|
+
from {
|
|
32117
|
+
grid-template-rows: 0fr;
|
|
32118
|
+
overflow: hidden;
|
|
32119
|
+
}
|
|
32120
|
+
to {
|
|
32121
|
+
grid-template-rows: 1fr;
|
|
32122
|
+
overflow: visible;
|
|
32123
|
+
}
|
|
32124
|
+
}
|
|
32125
|
+
|
|
32078
32126
|
@media (prefers-reduced-motion: reduce) {
|
|
32079
32127
|
.wds-critical-banner__description,
|
|
32080
32128
|
.wds-critical-banner__title,
|
|
@@ -32082,6 +32130,11 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
32082
32130
|
.wds-critical-banner__toggle {
|
|
32083
32131
|
transition: none !important;
|
|
32084
32132
|
}
|
|
32133
|
+
.wds-critical-banner__entry-mask {
|
|
32134
|
+
animation: none;
|
|
32135
|
+
grid-template-rows: 1fr;
|
|
32136
|
+
overflow: visible;
|
|
32137
|
+
}
|
|
32085
32138
|
}
|
|
32086
32139
|
|
|
32087
32140
|
.wds-expander-toggle {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
--Prompt-gap: var(--size-10) var(--size-16);
|
|
5
5
|
--Prompt-border-radius: 0;
|
|
6
6
|
container-type: inline-size;
|
|
7
|
+
position: relative;
|
|
7
8
|
--critical-banner-easing: cubic-bezier(0.9, 0, 0.7, 1);
|
|
8
9
|
--critical-banner-duration: 150ms;
|
|
9
10
|
/* Override PrimitivePrompt's --screen-sm-max actions behaviour:
|
|
@@ -124,6 +125,48 @@
|
|
|
124
125
|
min-width: fit-content;
|
|
125
126
|
}
|
|
126
127
|
}
|
|
128
|
+
.wds-critical-banner-overhang-query {
|
|
129
|
+
container-name: critical-banner-overhang;
|
|
130
|
+
container-type: inline-size;
|
|
131
|
+
inline-size: 100%;
|
|
132
|
+
}
|
|
133
|
+
.wds-critical-banner__entry-mask {
|
|
134
|
+
display: grid;
|
|
135
|
+
grid-template-rows: 0fr;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
animation: wds-critical-banner-reveal-height 400ms cubic-bezier(0.3, 0, 0.1, 1) 500ms both;
|
|
138
|
+
}
|
|
139
|
+
@container critical-banner-overhang (max-width: 600px) {
|
|
140
|
+
.wds-critical-banner__entry-mask {
|
|
141
|
+
--critical-banner-mobile-overhang-size: 32px;
|
|
142
|
+
}
|
|
143
|
+
.wds-critical-banner__entry-mask .wds-critical-banner-overhang {
|
|
144
|
+
margin-bottom: var(--critical-banner-mobile-overhang-size);
|
|
145
|
+
}
|
|
146
|
+
.wds-critical-banner__entry-mask .wds-critical-banner-overhang::after {
|
|
147
|
+
content: "";
|
|
148
|
+
position: absolute;
|
|
149
|
+
right: 0;
|
|
150
|
+
bottom: calc(-1 * var(--critical-banner-mobile-overhang-size));
|
|
151
|
+
left: 0;
|
|
152
|
+
height: var(--critical-banner-mobile-overhang-size);
|
|
153
|
+
pointer-events: none;
|
|
154
|
+
background: radial-gradient(circle at 100% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 0 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat, radial-gradient(circle at 0% 100%, transparent var(--critical-banner-mobile-overhang-size), var(--color-sentiment-background-surface) var(--critical-banner-mobile-overhang-size)) 100% 0 / var(--critical-banner-mobile-overhang-size) var(--critical-banner-mobile-overhang-size) no-repeat;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
.wds-critical-banner__entry-track {
|
|
158
|
+
min-height: 0;
|
|
159
|
+
}
|
|
160
|
+
@keyframes wds-critical-banner-reveal-height {
|
|
161
|
+
from {
|
|
162
|
+
grid-template-rows: 0fr;
|
|
163
|
+
overflow: hidden;
|
|
164
|
+
}
|
|
165
|
+
to {
|
|
166
|
+
grid-template-rows: 1fr;
|
|
167
|
+
overflow: visible;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
127
170
|
@media (prefers-reduced-motion: reduce) {
|
|
128
171
|
.wds-critical-banner__description,
|
|
129
172
|
.wds-critical-banner__title,
|
|
@@ -131,4 +174,9 @@
|
|
|
131
174
|
.wds-critical-banner__toggle {
|
|
132
175
|
transition: none !important;
|
|
133
176
|
}
|
|
177
|
+
.wds-critical-banner__entry-mask {
|
|
178
|
+
animation: none;
|
|
179
|
+
grid-template-rows: 1fr;
|
|
180
|
+
overflow: visible;
|
|
181
|
+
}
|
|
134
182
|
}
|