@transferwise/components 0.0.0-experimental-c54e90a → 0.0.0-experimental-e611dd1
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/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 +2 -3
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +2 -3
- package/build/field/Field.mjs.map +1 -1
- package/build/i18n/en.json +0 -2
- package/build/i18n/en.json.js +0 -2
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +0 -2
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/index.js +0 -2
- package/build/index.js.map +1 -1
- package/build/index.mjs +0 -1
- package/build/index.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +2 -3
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +2 -3
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +29 -192
- package/build/prompt/ActionPrompt/ActionPrompt.js +40 -8
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +40 -8
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js +4 -11
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs +4 -11
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
- package/build/styles/main.css +29 -192
- package/build/table/Table.js +5 -5
- package/build/table/Table.js.map +1 -1
- package/build/table/Table.mjs +5 -5
- package/build/table/Table.mjs.map +1 -1
- package/build/typeahead/Typeahead.js +2 -3
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +2 -3
- package/build/typeahead/Typeahead.mjs.map +1 -1
- 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 +11 -2
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts +3 -35
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
- package/build/types/prompt/index.d.ts +0 -2
- package/build/types/prompt/index.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +0 -4
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common/bottomSheet/BottomSheet.test.story.tsx +6 -5
- package/src/common/hooks/useResizeObserver.ts +2 -3
- package/src/i18n/en.json +0 -2
- package/src/index.ts +2 -2
- package/src/main.css +29 -192
- package/src/main.less +1 -3
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +62 -9
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +40 -56
- package/src/prompt/index.ts +0 -4
- package/src/sentimentSurface/SentimentSurface.story.tsx +17 -43
- package/src/table/Table.story.tsx +1 -1
- package/src/table/Table.tsx +5 -5
- package/build/common/hooks/useContainerSize.js +0 -30
- package/build/common/hooks/useContainerSize.js.map +0 -1
- package/build/common/hooks/useContainerSize.mjs +0 -28
- package/build/common/hooks/useContainerSize.mjs.map +0 -1
- package/build/prompt/CriticalBanner/CriticalBanner.js +0 -142
- package/build/prompt/CriticalBanner/CriticalBanner.js.map +0 -1
- package/build/prompt/CriticalBanner/CriticalBanner.mjs +0 -140
- package/build/prompt/CriticalBanner/CriticalBanner.mjs.map +0 -1
- package/build/prompt/CriticalBanner/helpers.js +0 -29
- package/build/prompt/CriticalBanner/helpers.js.map +0 -1
- package/build/prompt/CriticalBanner/helpers.mjs +0 -26
- package/build/prompt/CriticalBanner/helpers.mjs.map +0 -1
- package/build/prompt/common/Expander/Expander.js +0 -35
- package/build/prompt/common/Expander/Expander.js.map +0 -1
- package/build/prompt/common/Expander/Expander.messages.js +0 -17
- package/build/prompt/common/Expander/Expander.messages.js.map +0 -1
- package/build/prompt/common/Expander/Expander.messages.mjs +0 -13
- package/build/prompt/common/Expander/Expander.messages.mjs.map +0 -1
- package/build/prompt/common/Expander/Expander.mjs +0 -33
- package/build/prompt/common/Expander/Expander.mjs.map +0 -1
- package/build/prompt/helpers/promptMedia.js +0 -52
- package/build/prompt/helpers/promptMedia.js.map +0 -1
- package/build/prompt/helpers/promptMedia.mjs +0 -50
- package/build/prompt/helpers/promptMedia.mjs.map +0 -1
- package/build/styles/prompt/CriticalBanner/CriticalBanner.css +0 -132
- package/build/styles/prompt/CriticalBanner/CriticalBanner.vars.css +0 -0
- package/build/styles/prompt/common/Expander/Expander.css +0 -8
- package/build/types/common/hooks/useContainerSize.d.ts +0 -14
- package/build/types/common/hooks/useContainerSize.d.ts.map +0 -1
- package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts +0 -39
- package/build/types/prompt/CriticalBanner/CriticalBanner.d.ts.map +0 -1
- package/build/types/prompt/CriticalBanner/helpers.d.ts +0 -18
- package/build/types/prompt/CriticalBanner/helpers.d.ts.map +0 -1
- package/build/types/prompt/CriticalBanner/index.d.ts +0 -3
- package/build/types/prompt/CriticalBanner/index.d.ts.map +0 -1
- package/build/types/prompt/common/Expander/Expander.d.ts +0 -20
- package/build/types/prompt/common/Expander/Expander.d.ts.map +0 -1
- package/build/types/prompt/common/Expander/Expander.messages.d.ts +0 -14
- package/build/types/prompt/common/Expander/Expander.messages.d.ts.map +0 -1
- package/build/types/prompt/helpers/promptMedia.d.ts +0 -22
- package/build/types/prompt/helpers/promptMedia.d.ts.map +0 -1
- package/src/common/hooks/useContainerSize.test.tsx +0 -121
- package/src/common/hooks/useContainerSize.ts +0 -32
- package/src/prompt/CriticalBanner/CriticalBanner.accessibility.docs.mdx +0 -113
- package/src/prompt/CriticalBanner/CriticalBanner.css +0 -132
- package/src/prompt/CriticalBanner/CriticalBanner.less +0 -153
- package/src/prompt/CriticalBanner/CriticalBanner.story.tsx +0 -635
- package/src/prompt/CriticalBanner/CriticalBanner.test.story.tsx +0 -422
- package/src/prompt/CriticalBanner/CriticalBanner.tsx +0 -178
- package/src/prompt/CriticalBanner/CriticalBanner.vars.css +0 -0
- package/src/prompt/CriticalBanner/CriticalBanner.vars.less +0 -6
- package/src/prompt/CriticalBanner/helpers.ts +0 -39
- package/src/prompt/CriticalBanner/index.ts +0 -2
- package/src/prompt/common/Expander/Expander.css +0 -8
- package/src/prompt/common/Expander/Expander.less +0 -9
- package/src/prompt/common/Expander/Expander.messages.ts +0 -14
- package/src/prompt/common/Expander/Expander.test.tsx +0 -167
- package/src/prompt/common/Expander/Expander.tsx +0 -83
- package/src/prompt/helpers/promptMedia.tsx +0 -79
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { Cross } from '@transferwise/icons';
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
|
-
import SentimentSurface, {
|
|
3
|
+
import SentimentSurface, { Sentiment } from '../../sentimentSurface';
|
|
4
4
|
import IconButton from '../../iconButton';
|
|
5
5
|
import { useIntl } from 'react-intl';
|
|
6
6
|
import closeBtnMessages from '../../common/closeButton/CloseButton.messages';
|
|
7
|
-
import {
|
|
7
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
8
8
|
|
|
9
9
|
export type PrimitivePromptProps = HTMLAttributes<HTMLDivElement> & {
|
|
10
10
|
/**
|
|
11
|
-
* The sentiment determines the colour scheme
|
|
11
|
+
* The sentiment determines the colour scheme
|
|
12
12
|
* @default success
|
|
13
13
|
*/
|
|
14
14
|
sentiment?: Sentiment;
|
|
15
|
-
/**
|
|
16
|
-
* The emphasis level affecting background and text contrast.
|
|
17
|
-
* @default 'base
|
|
18
|
-
*/
|
|
19
|
-
emphasis?: Emphasis;
|
|
20
15
|
/**
|
|
21
16
|
* Media to be displayed on the prompt (icon/image/etc).
|
|
22
17
|
*/
|
|
@@ -38,53 +33,42 @@ export type PrimitivePromptProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
38
33
|
/**
|
|
39
34
|
* PrimitivePrompt is a low-level component that provides the structure, sentiment support and styling for various prompts.
|
|
40
35
|
* Uses several css variables to handle styling from within the consuming component, e.g. --Prompt-padding. */
|
|
41
|
-
export const PrimitivePrompt =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
...restProps
|
|
52
|
-
},
|
|
53
|
-
ref,
|
|
54
|
-
) => {
|
|
55
|
-
const intl = useIntl();
|
|
36
|
+
export const PrimitivePrompt = ({
|
|
37
|
+
sentiment = 'success',
|
|
38
|
+
media,
|
|
39
|
+
actions,
|
|
40
|
+
onDismiss,
|
|
41
|
+
className,
|
|
42
|
+
children,
|
|
43
|
+
...restProps
|
|
44
|
+
}: PrimitivePromptProps) => {
|
|
45
|
+
const intl = useIntl();
|
|
56
46
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
{
|
|
47
|
+
return (
|
|
48
|
+
<SentimentSurface
|
|
49
|
+
sentiment={sentiment}
|
|
50
|
+
className={clsx('wds-prompt', `wds-prompt--${sentiment}`, className)}
|
|
51
|
+
{...restProps}
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
className={clsx('wds-prompt__content-wrapper', {
|
|
55
|
+
'wds-prompt__content-wrapper--with-dismiss': !!onDismiss,
|
|
56
|
+
})}
|
|
65
57
|
>
|
|
66
|
-
<div
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{actions && <div className="wds-prompt__actions-wrapper">{actions}</div>}
|
|
84
|
-
</div>
|
|
85
|
-
</SentimentSurface>
|
|
86
|
-
);
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
PrimitivePrompt.displayName = 'PrimitivePrompt';
|
|
58
|
+
<div className={clsx('wds-prompt__media-wrapper')}>{media}</div>
|
|
59
|
+
{children}
|
|
60
|
+
{onDismiss && (
|
|
61
|
+
<IconButton
|
|
62
|
+
size={24}
|
|
63
|
+
priority="secondary"
|
|
64
|
+
aria-label={intl.formatMessage(closeBtnMessages.ariaLabel)}
|
|
65
|
+
onClick={onDismiss}
|
|
66
|
+
>
|
|
67
|
+
<Cross />
|
|
68
|
+
</IconButton>
|
|
69
|
+
)}
|
|
70
|
+
{actions && <div className="wds-prompt__actions-wrapper">{actions}</div>}
|
|
71
|
+
</div>
|
|
72
|
+
</SentimentSurface>
|
|
73
|
+
);
|
|
74
|
+
};
|
package/src/prompt/index.ts
CHANGED
|
@@ -12,7 +12,3 @@ export { ActionPrompt } from './ActionPrompt';
|
|
|
12
12
|
// InfoPrompt
|
|
13
13
|
export type { InfoPromptProps, InfoPromptAction, InfoPromptMedia } from './InfoPrompt';
|
|
14
14
|
export { InfoPrompt } from './InfoPrompt';
|
|
15
|
-
|
|
16
|
-
// CriticalBanner
|
|
17
|
-
export type { CriticalBannerProps } from './CriticalBanner';
|
|
18
|
-
export { CriticalBanner } from './CriticalBanner';
|
|
@@ -202,26 +202,18 @@ const TokenSwatch = ({ token }: { token: string }) => (
|
|
|
202
202
|
export const EmphasisLevels: Story = {
|
|
203
203
|
render: (args) => (
|
|
204
204
|
<>
|
|
205
|
-
{
|
|
206
|
-
<div
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
{...args}
|
|
218
|
-
sentiment={sentiment}
|
|
219
|
-
emphasis="elevated"
|
|
220
|
-
>
|
|
221
|
-
<div className="p-a-2 text-capitalize">{sentiment} - Elevated emphasis</div>
|
|
222
|
-
</SentimentSurface>
|
|
223
|
-
</div>
|
|
224
|
-
))}
|
|
205
|
+
<SentimentSurface {...args} sentiment="negative" emphasis="base">
|
|
206
|
+
<div className="p-a-2">Negative - Base emphasis</div>
|
|
207
|
+
</SentimentSurface>
|
|
208
|
+
<SentimentSurface {...args} sentiment="negative" emphasis="elevated">
|
|
209
|
+
<div className="p-a-2">Negative - Elevated emphasis</div>
|
|
210
|
+
</SentimentSurface>
|
|
211
|
+
<SentimentSurface {...args} sentiment="success" emphasis="base">
|
|
212
|
+
<div className="p-a-2">Success - Base emphasis</div>
|
|
213
|
+
</SentimentSurface>
|
|
214
|
+
<SentimentSurface {...args} sentiment="success" emphasis="elevated">
|
|
215
|
+
<div className="p-a-2">Success - Elevated emphasis</div>
|
|
216
|
+
</SentimentSurface>
|
|
225
217
|
</>
|
|
226
218
|
),
|
|
227
219
|
parameters: {
|
|
@@ -377,8 +369,8 @@ export const SentimentAwareComponents: Story = {
|
|
|
377
369
|
{STATUS_NEGATIVE}
|
|
378
370
|
</div>
|
|
379
371
|
|
|
380
|
-
<Header level="group" title="Success sentiment surface
|
|
381
|
-
<SentimentSurface sentiment="success"
|
|
372
|
+
<Header level="group" title="Success sentiment surface" />
|
|
373
|
+
<SentimentSurface sentiment="success">
|
|
382
374
|
<div className="p-a-2 m-b-2 sentimentAwareComponent">
|
|
383
375
|
{BODY}
|
|
384
376
|
{AVATAR_SUCCESS}
|
|
@@ -386,26 +378,8 @@ export const SentimentAwareComponents: Story = {
|
|
|
386
378
|
</div>
|
|
387
379
|
</SentimentSurface>
|
|
388
380
|
|
|
389
|
-
<Header level="group" title="
|
|
390
|
-
<SentimentSurface sentiment="
|
|
391
|
-
<div className="p-a-2 m-b-2 sentimentAwareComponent">
|
|
392
|
-
{BODY}
|
|
393
|
-
{AVATAR_SUCCESS}
|
|
394
|
-
{STATUS_SUCCESS}
|
|
395
|
-
</div>
|
|
396
|
-
</SentimentSurface>
|
|
397
|
-
|
|
398
|
-
<Header level="group" title="Negative sentiment surface - Base emphasis" />
|
|
399
|
-
<SentimentSurface sentiment="negative" emphasis="base">
|
|
400
|
-
<div className="p-a-2 m-b-2 sentimentAwareComponent">
|
|
401
|
-
{BODY}
|
|
402
|
-
{AVATAR_NEGATIVE}
|
|
403
|
-
{STATUS_NEGATIVE}
|
|
404
|
-
</div>
|
|
405
|
-
</SentimentSurface>
|
|
406
|
-
|
|
407
|
-
<Header level="group" title="Negative sentiment surface - Elevated emphasis" />
|
|
408
|
-
<SentimentSurface sentiment="negative" emphasis="elevated">
|
|
381
|
+
<Header level="group" title="Negative sentiment surface" />
|
|
382
|
+
<SentimentSurface sentiment="negative">
|
|
409
383
|
<div className="p-a-2 m-b-2 sentimentAwareComponent">
|
|
410
384
|
{BODY}
|
|
411
385
|
{AVATAR_NEGATIVE}
|
|
@@ -453,7 +427,7 @@ function CustomCard({ children, className }: { className?: string; children: Rea
|
|
|
453
427
|
|
|
454
428
|
export const CustomComponents: Story = {
|
|
455
429
|
tags: ['!autodocs', '!dev'],
|
|
456
|
-
render: () => (
|
|
430
|
+
render: (args) => (
|
|
457
431
|
<>
|
|
458
432
|
<style>{`
|
|
459
433
|
.custom-card {
|
|
@@ -400,7 +400,7 @@ export const WithError: Story = {
|
|
|
400
400
|
error: {
|
|
401
401
|
message: 'Something went wrong during data fetching',
|
|
402
402
|
action: {
|
|
403
|
-
href: '/?path=/story/
|
|
403
|
+
href: '/?path=/story/content-table--with-error',
|
|
404
404
|
text: 'To Refresh page, click here',
|
|
405
405
|
},
|
|
406
406
|
},
|
package/src/table/Table.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useIntl } from 'react-intl';
|
|
|
2
2
|
import TableCell from './TableCell';
|
|
3
3
|
import TableHeader, { TableHeaderType } from './TableHeader';
|
|
4
4
|
import TableRow, { TableRowClickableType, TableRowType } from './TableRow';
|
|
5
|
-
import
|
|
5
|
+
import { InfoPrompt } from '../prompt/InfoPrompt';
|
|
6
6
|
|
|
7
7
|
import messages from './Table.messages';
|
|
8
8
|
import Loader from '../loader';
|
|
@@ -87,13 +87,13 @@ const Table = ({
|
|
|
87
87
|
|
|
88
88
|
if (error) {
|
|
89
89
|
return (
|
|
90
|
-
<
|
|
90
|
+
<InfoPrompt
|
|
91
91
|
className="np-table-error"
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
description={error.message ?? ''}
|
|
93
|
+
sentiment="negative"
|
|
94
94
|
action={{
|
|
95
95
|
href: error?.action?.href ?? '/',
|
|
96
|
-
|
|
96
|
+
label: error?.action?.text ?? formatMessage(messages.refreshPage),
|
|
97
97
|
}}
|
|
98
98
|
data-testid="np-table-error"
|
|
99
99
|
/>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
var useResizeObserver = require('./useResizeObserver.js');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Hook that returns a ref and a boolean indicating if the container
|
|
8
|
-
* has a width >= the specified breakpoint.
|
|
9
|
-
*
|
|
10
|
-
* Useful for synchronizing React state with CSS container queries.
|
|
11
|
-
*
|
|
12
|
-
* Uses content-box measurements to match CSS container query behavior
|
|
13
|
-
* (excludes padding and border).
|
|
14
|
-
*
|
|
15
|
-
* @param breakpoint - Minimum width in pixels
|
|
16
|
-
* @returns [ref, isAboveBreakpoint] tuple
|
|
17
|
-
*/
|
|
18
|
-
function useContainerSize(breakpoint) {
|
|
19
|
-
const ref = React.useRef(null);
|
|
20
|
-
const [isAboveBreakpoint, setIsAboveBreakpoint] = React.useState(false);
|
|
21
|
-
useResizeObserver.useResizeObserver(ref, entry => {
|
|
22
|
-
// Use contentRect.width to match CSS container query box model (content-box)
|
|
23
|
-
const inlineSize = entry.contentRect.width;
|
|
24
|
-
setIsAboveBreakpoint(inlineSize >= breakpoint);
|
|
25
|
-
}, 'content-box');
|
|
26
|
-
return [ref, isAboveBreakpoint];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exports.useContainerSize = useContainerSize;
|
|
30
|
-
//# sourceMappingURL=useContainerSize.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useContainerSize.js","sources":["../../../src/common/hooks/useContainerSize.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\nimport { useResizeObserver } from './useResizeObserver';\n\n/**\n * Hook that returns a ref and a boolean indicating if the container\n * has a width >= the specified breakpoint.\n *\n * Useful for synchronizing React state with CSS container queries.\n *\n * Uses content-box measurements to match CSS container query behavior\n * (excludes padding and border).\n *\n * @param breakpoint - Minimum width in pixels\n * @returns [ref, isAboveBreakpoint] tuple\n */\nexport function useContainerSize(breakpoint: number): [React.RefObject<HTMLDivElement>, boolean] {\n const ref = useRef<HTMLDivElement>(null);\n const [isAboveBreakpoint, setIsAboveBreakpoint] = useState(false);\n\n useResizeObserver(\n ref,\n (entry) => {\n // Use contentRect.width to match CSS container query box model (content-box)\n const inlineSize = entry.contentRect.width;\n setIsAboveBreakpoint(inlineSize >= breakpoint);\n },\n 'content-box',\n );\n\n return [ref, isAboveBreakpoint];\n}\n"],"names":["useContainerSize","breakpoint","ref","useRef","isAboveBreakpoint","setIsAboveBreakpoint","useState","useResizeObserver","entry","inlineSize","contentRect","width"],"mappings":";;;;;AAIA;;;;;;;;;;;AAWG;AACG,SAAUA,gBAAgBA,CAACC,UAAkB,EAAA;AACjD,EAAA,MAAMC,GAAG,GAAGC,YAAM,CAAiB,IAAI,CAAC;EACxC,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC;AAEjEC,EAAAA,mCAAiB,CACfL,GAAG,EACFM,KAAK,IAAI;AACR;AACA,IAAA,MAAMC,UAAU,GAAGD,KAAK,CAACE,WAAW,CAACC,KAAK;AAC1CN,IAAAA,oBAAoB,CAACI,UAAU,IAAIR,UAAU,CAAC;EAChD,CAAC,EACD,aAAa,CACd;AAED,EAAA,OAAO,CAACC,GAAG,EAAEE,iBAAiB,CAAC;AACjC;;;;"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useRef, useState } from 'react';
|
|
2
|
-
import { useResizeObserver } from './useResizeObserver.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Hook that returns a ref and a boolean indicating if the container
|
|
6
|
-
* has a width >= the specified breakpoint.
|
|
7
|
-
*
|
|
8
|
-
* Useful for synchronizing React state with CSS container queries.
|
|
9
|
-
*
|
|
10
|
-
* Uses content-box measurements to match CSS container query behavior
|
|
11
|
-
* (excludes padding and border).
|
|
12
|
-
*
|
|
13
|
-
* @param breakpoint - Minimum width in pixels
|
|
14
|
-
* @returns [ref, isAboveBreakpoint] tuple
|
|
15
|
-
*/
|
|
16
|
-
function useContainerSize(breakpoint) {
|
|
17
|
-
const ref = useRef(null);
|
|
18
|
-
const [isAboveBreakpoint, setIsAboveBreakpoint] = useState(false);
|
|
19
|
-
useResizeObserver(ref, entry => {
|
|
20
|
-
// Use contentRect.width to match CSS container query box model (content-box)
|
|
21
|
-
const inlineSize = entry.contentRect.width;
|
|
22
|
-
setIsAboveBreakpoint(inlineSize >= breakpoint);
|
|
23
|
-
}, 'content-box');
|
|
24
|
-
return [ref, isAboveBreakpoint];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { useContainerSize };
|
|
28
|
-
//# sourceMappingURL=useContainerSize.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useContainerSize.mjs","sources":["../../../src/common/hooks/useContainerSize.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\nimport { useResizeObserver } from './useResizeObserver';\n\n/**\n * Hook that returns a ref and a boolean indicating if the container\n * has a width >= the specified breakpoint.\n *\n * Useful for synchronizing React state with CSS container queries.\n *\n * Uses content-box measurements to match CSS container query behavior\n * (excludes padding and border).\n *\n * @param breakpoint - Minimum width in pixels\n * @returns [ref, isAboveBreakpoint] tuple\n */\nexport function useContainerSize(breakpoint: number): [React.RefObject<HTMLDivElement>, boolean] {\n const ref = useRef<HTMLDivElement>(null);\n const [isAboveBreakpoint, setIsAboveBreakpoint] = useState(false);\n\n useResizeObserver(\n ref,\n (entry) => {\n // Use contentRect.width to match CSS container query box model (content-box)\n const inlineSize = entry.contentRect.width;\n setIsAboveBreakpoint(inlineSize >= breakpoint);\n },\n 'content-box',\n );\n\n return [ref, isAboveBreakpoint];\n}\n"],"names":["useContainerSize","breakpoint","ref","useRef","isAboveBreakpoint","setIsAboveBreakpoint","useState","useResizeObserver","entry","inlineSize","contentRect","width"],"mappings":";;;AAIA;;;;;;;;;;;AAWG;AACG,SAAUA,gBAAgBA,CAACC,UAAkB,EAAA;AACjD,EAAA,MAAMC,GAAG,GAAGC,MAAM,CAAiB,IAAI,CAAC;EACxC,MAAM,CAACC,iBAAiB,EAAEC,oBAAoB,CAAC,GAAGC,QAAQ,CAAC,KAAK,CAAC;AAEjEC,EAAAA,iBAAiB,CACfL,GAAG,EACFM,KAAK,IAAI;AACR;AACA,IAAA,MAAMC,UAAU,GAAGD,KAAK,CAACE,WAAW,CAACC,KAAK;AAC1CN,IAAAA,oBAAoB,CAACI,UAAU,IAAIR,UAAU,CAAC;EAChD,CAAC,EACD,aAAa,CACd;AAED,EAAA,OAAO,CAACC,GAAG,EAAEE,iBAAiB,CAAC;AACjC;;;;"}
|
|
@@ -1,142 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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 >= 768px), the banner is always expanded\n * regardless of this prop value.\n */\n expanded?: boolean;\n /**\n * Called when the user clicks the chevron toggle.\n * If not provided, the component will manage expanded state internally.\n */\n onToggle?: () => void;\n} & Pick<PrimitivePromptProps, 'id' | 'className' | 'data-testid'>;\n\n/**\n * A full-width, non-dismissible banner for critical messages such as account blocks or\n * time-sensitive actions that require immediate user attention.\n\n * @see {@link https://wise.design/components/critical-banner Design Spec}\n */\nexport const CriticalBanner = ({\n sentiment = 'negative',\n title,\n description,\n media = {},\n action,\n actionSecondary,\n expanded: expandedProp,\n onToggle,\n id,\n className,\n 'data-testid': testId,\n}: CriticalBannerProps) => {\n const [containerRef, isDesktop] = useContainerSize(Breakpoint.MEDIUM);\n const [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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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B;;;;"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { useState, useId } from 'react';
|
|
2
|
-
import { clsx } from 'clsx';
|
|
3
|
-
import Body from '../../body/Body.mjs';
|
|
4
|
-
import Button from '../../button/Button.resolver.mjs';
|
|
5
|
-
import '../../common/theme.mjs';
|
|
6
|
-
import '../../common/direction.mjs';
|
|
7
|
-
import '../../common/propsValues/control.mjs';
|
|
8
|
-
import { Breakpoint } from '../../common/propsValues/breakpoint.mjs';
|
|
9
|
-
import '../../common/propsValues/size.mjs';
|
|
10
|
-
import { Typography } from '../../common/propsValues/typography.mjs';
|
|
11
|
-
import '../../common/propsValues/width.mjs';
|
|
12
|
-
import '../../common/propsValues/type.mjs';
|
|
13
|
-
import '../../common/propsValues/dateMode.mjs';
|
|
14
|
-
import '../../common/propsValues/monthFormat.mjs';
|
|
15
|
-
import '../../common/propsValues/position.mjs';
|
|
16
|
-
import '../../common/propsValues/layouts.mjs';
|
|
17
|
-
import '../../common/propsValues/status.mjs';
|
|
18
|
-
import '../../common/propsValues/sentiment.mjs';
|
|
19
|
-
import '../../common/propsValues/profileType.mjs';
|
|
20
|
-
import '../../common/propsValues/variant.mjs';
|
|
21
|
-
import '../../common/propsValues/scroll.mjs';
|
|
22
|
-
import '../../common/propsValues/markdownNodeType.mjs';
|
|
23
|
-
import '../../common/fileType.mjs';
|
|
24
|
-
import '@transferwise/formatting';
|
|
25
|
-
import '@transferwise/icons';
|
|
26
|
-
import 'react-intl';
|
|
27
|
-
import '../../common/closeButton/CloseButton.messages.mjs';
|
|
28
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
29
|
-
import { LiveRegion } from '../../common/liveRegion/LiveRegion.mjs';
|
|
30
|
-
import { PrimitivePrompt } from '../PrimitivePrompt/PrimitivePrompt.mjs';
|
|
31
|
-
import { renderPromptMedia } from '../helpers/promptMedia.mjs';
|
|
32
|
-
import { ExpanderToggle } from '../common/Expander/Expander.mjs';
|
|
33
|
-
import { buildAnnouncementString } from './helpers.mjs';
|
|
34
|
-
import { useContainerSize } from '../../common/hooks/useContainerSize.mjs';
|
|
35
|
-
|
|
36
|
-
const CriticalBanner = ({
|
|
37
|
-
sentiment = 'negative',
|
|
38
|
-
title,
|
|
39
|
-
description,
|
|
40
|
-
media = {},
|
|
41
|
-
action,
|
|
42
|
-
actionSecondary,
|
|
43
|
-
expanded: expandedProp,
|
|
44
|
-
onToggle,
|
|
45
|
-
id,
|
|
46
|
-
className,
|
|
47
|
-
'data-testid': testId
|
|
48
|
-
}) => {
|
|
49
|
-
const [containerRef, isDesktop] = useContainerSize(Breakpoint.MEDIUM);
|
|
50
|
-
const [internalExpanded, setInternalExpanded] = useState(isDesktop ? true : onToggle && expandedProp !== undefined ? expandedProp : true);
|
|
51
|
-
const resolvedExpanded = isDesktop ? true : expandedProp ?? internalExpanded;
|
|
52
|
-
const handleToggle = onToggle ?? (() => setInternalExpanded(!internalExpanded));
|
|
53
|
-
const hasActions = action ?? actionSecondary;
|
|
54
|
-
const mediaId = useId();
|
|
55
|
-
const titleId = useId();
|
|
56
|
-
const descId = useId();
|
|
57
|
-
const ariaLabelledByIds = [media['aria-hidden'] ? undefined : mediaId, !title ? undefined : titleId].filter(Boolean).join(' ');
|
|
58
|
-
return /*#__PURE__*/jsx(LiveRegion, {
|
|
59
|
-
"aria-live": "assertive",
|
|
60
|
-
announceOnChange: buildAnnouncementString({
|
|
61
|
-
title,
|
|
62
|
-
description,
|
|
63
|
-
expanded: resolvedExpanded,
|
|
64
|
-
actionLabel: action?.label,
|
|
65
|
-
actionSecondaryLabel: actionSecondary?.label
|
|
66
|
-
}),
|
|
67
|
-
children: /*#__PURE__*/jsxs(PrimitivePrompt, {
|
|
68
|
-
ref: containerRef,
|
|
69
|
-
id: id,
|
|
70
|
-
sentiment: sentiment,
|
|
71
|
-
emphasis: sentiment === 'neutral' ? 'base' : 'elevated',
|
|
72
|
-
"data-testid": testId,
|
|
73
|
-
className: clsx('wds-critical-banner', {
|
|
74
|
-
'wds-critical-banner--collapsed': !resolvedExpanded,
|
|
75
|
-
'wds-critical-banner--with-two-actions': !!actionSecondary
|
|
76
|
-
}, className),
|
|
77
|
-
media: renderPromptMedia({
|
|
78
|
-
media,
|
|
79
|
-
sentiment,
|
|
80
|
-
mediaId,
|
|
81
|
-
imgClassName: 'wds-critical-banner--media-image'
|
|
82
|
-
}),
|
|
83
|
-
actions: hasActions ? /*#__PURE__*/jsxs("div", {
|
|
84
|
-
"aria-hidden": !resolvedExpanded ? true : undefined,
|
|
85
|
-
style: {
|
|
86
|
-
display: 'contents'
|
|
87
|
-
},
|
|
88
|
-
children: [actionSecondary &&
|
|
89
|
-
/*#__PURE__*/
|
|
90
|
-
// @ts-expect-error onClick type mismatch
|
|
91
|
-
jsx(Button, {
|
|
92
|
-
v2: true,
|
|
93
|
-
size: "md",
|
|
94
|
-
priority: "secondary",
|
|
95
|
-
href: actionSecondary.href,
|
|
96
|
-
tabIndex: resolvedExpanded ? undefined : -1,
|
|
97
|
-
onClick: actionSecondary?.onClick,
|
|
98
|
-
children: actionSecondary.label
|
|
99
|
-
}), action &&
|
|
100
|
-
/*#__PURE__*/
|
|
101
|
-
// @ts-expect-error onClick type mismatch
|
|
102
|
-
jsx(Button, {
|
|
103
|
-
v2: true,
|
|
104
|
-
size: "md",
|
|
105
|
-
priority: "primary",
|
|
106
|
-
href: action.href,
|
|
107
|
-
tabIndex: resolvedExpanded ? undefined : -1,
|
|
108
|
-
onClick: action.onClick,
|
|
109
|
-
children: action.label
|
|
110
|
-
})]
|
|
111
|
-
}) : undefined,
|
|
112
|
-
role: "region",
|
|
113
|
-
"aria-labelledby": ariaLabelledByIds,
|
|
114
|
-
"aria-describedby": descId,
|
|
115
|
-
children: [/*#__PURE__*/jsxs("div", {
|
|
116
|
-
className: "wds-critical-banner__text-wrapper",
|
|
117
|
-
children: [title && /*#__PURE__*/jsx(Body, {
|
|
118
|
-
id: titleId,
|
|
119
|
-
type: Typography.BODY_LARGE_BOLD,
|
|
120
|
-
className: "wds-critical-banner__content wds-critical-banner__title",
|
|
121
|
-
children: title
|
|
122
|
-
}), description && /*#__PURE__*/jsx(Body, {
|
|
123
|
-
id: descId,
|
|
124
|
-
className: clsx('wds-critical-banner__content', 'wds-critical-banner__description', {
|
|
125
|
-
'wds-critical-banner__description--with-title': !!title
|
|
126
|
-
}),
|
|
127
|
-
children: description
|
|
128
|
-
})]
|
|
129
|
-
}), /*#__PURE__*/jsx(ExpanderToggle, {
|
|
130
|
-
expanded: resolvedExpanded,
|
|
131
|
-
size: 24,
|
|
132
|
-
className: "wds-critical-banner__toggle",
|
|
133
|
-
onToggle: handleToggle
|
|
134
|
-
})]
|
|
135
|
-
})
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export { CriticalBanner };
|
|
140
|
-
//# sourceMappingURL=CriticalBanner.mjs.map
|