@transferwise/components 46.71.8 → 46.72.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.
@@ -49,7 +49,8 @@ function Alert({
49
49
  size: size$1,
50
50
  title,
51
51
  type = 'neutral',
52
- variant = 'desktop'
52
+ variant = 'desktop',
53
+ active = true
53
54
  }) {
54
55
  React.useEffect(() => {
55
56
  if (arrow !== undefined) {
@@ -79,58 +80,60 @@ function Alert({
79
80
  }, [resolvedType, type]);
80
81
  const [shouldFire, setShouldFire] = React.useState(false);
81
82
  const closeButtonReference = React.useRef(null);
82
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
83
- className: clsx.clsx('alert d-flex', `alert-${resolvedType}`, arrow != null && alertArrowClassNames(arrow), className),
84
- "data-testid": "alert",
85
- onTouchStart: () => setShouldFire(true),
86
- onTouchEnd: event => {
87
- if (shouldFire && action?.href &&
88
- // Check if current event is triggered from closeButton
89
- event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
90
- if (action.target === '_blank') {
91
- window.top?.open(action.href);
92
- } else {
93
- window.top?.location.assign(action.href);
83
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
84
+ role: resolvedType === sentiment.Sentiment.NEGATIVE ? 'alert' : 'status',
85
+ children: active && /*#__PURE__*/jsxRuntime.jsxs("div", {
86
+ className: clsx.clsx('alert d-flex', `alert-${resolvedType}`, arrow != null && alertArrowClassNames(arrow), className),
87
+ "data-testid": "alert",
88
+ onTouchStart: () => setShouldFire(true),
89
+ onTouchEnd: event => {
90
+ if (shouldFire && action?.href &&
91
+ // Check if current event is triggered from closeButton
92
+ event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
93
+ if (action.target === '_blank') {
94
+ window.top?.open(action.href);
95
+ } else {
96
+ window.top?.location.assign(action.href);
97
+ }
94
98
  }
95
- }
96
- setShouldFire(false);
97
- },
98
- onTouchMove: () => setShouldFire(false),
99
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
100
- className: clsx.clsx('alert__content', 'd-flex', 'flex-grow-1', variant),
101
- "data-testid": variant,
102
- children: [icon ? /*#__PURE__*/jsxRuntime.jsx("div", {
103
- className: "alert__icon",
104
- children: icon
105
- }) : /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
106
- size: size.Size.LARGE,
107
- sentiment: resolvedType
108
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
109
- className: "alert__message",
110
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
111
- role: sentiment.Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status',
112
- children: [title && /*#__PURE__*/jsxRuntime.jsx(Title, {
113
- className: "m-b-1",
114
- type: typography.Typography.TITLE_BODY,
115
- children: title
116
- }), /*#__PURE__*/jsxRuntime.jsx(Body, {
117
- as: "span",
118
- className: "d-block",
119
- type: typography.Typography.BODY_LARGE,
120
- children: children || /*#__PURE__*/jsxRuntime.jsx(InlineMarkdown, {
121
- children: message
122
- })
99
+ setShouldFire(false);
100
+ },
101
+ onTouchMove: () => setShouldFire(false),
102
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
103
+ className: clsx.clsx('alert__content', 'd-flex', 'flex-grow-1', variant),
104
+ "data-testid": variant,
105
+ children: [icon ? /*#__PURE__*/jsxRuntime.jsx("div", {
106
+ className: "alert__icon",
107
+ children: icon
108
+ }) : /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
109
+ size: size.Size.LARGE,
110
+ sentiment: resolvedType
111
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
112
+ className: "alert__message",
113
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
114
+ children: [title && /*#__PURE__*/jsxRuntime.jsx(Title, {
115
+ className: "m-b-1",
116
+ type: typography.Typography.TITLE_BODY,
117
+ children: title
118
+ }), /*#__PURE__*/jsxRuntime.jsx(Body, {
119
+ as: "span",
120
+ className: "d-block",
121
+ type: typography.Typography.BODY_LARGE,
122
+ children: children || /*#__PURE__*/jsxRuntime.jsx(InlineMarkdown, {
123
+ children: message
124
+ })
125
+ })]
126
+ }), action && /*#__PURE__*/jsxRuntime.jsx(Action.Action, {
127
+ action: action,
128
+ className: "m-t-1"
123
129
  })]
124
- }), action && /*#__PURE__*/jsxRuntime.jsx(Action.Action, {
125
- action: action,
126
- className: "m-t-1"
127
130
  })]
131
+ }), onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton.CloseButton, {
132
+ ref: closeButtonReference,
133
+ className: "m-l-2",
134
+ onClick: onDismiss
128
135
  })]
129
- }), onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton.CloseButton, {
130
- ref: closeButtonReference,
131
- className: "m-l-2",
132
- onClick: onDismiss
133
- })]
136
+ })
134
137
  });
135
138
  }
136
139
  function alertArrowClassNames(arrow) {
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.js","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport { Sentiment, Size, Typography, Variant } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport { Action } from '../common/action/Action';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n variant?: `${Variant}`;\n /** @deprecated Use `InlineAlert` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n arrow,\n action,\n children,\n className,\n dismissible,\n icon,\n onDismiss,\n message,\n size,\n title,\n type = 'neutral',\n variant = 'desktop',\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState(false);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n return (\n <div\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div\n className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}\n data-testid={variant}\n >\n {icon ? (\n <div className=\"alert__icon\">{icon}</div>\n ) : (\n <StatusIcon size={Size.LARGE} sentiment={resolvedType} />\n )}\n <div className=\"alert__message\">\n <div role={Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status'}>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action && <Action action={action} className=\"m-t-1\" />}\n </div>\n </div>\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","arrow","action","children","className","dismissible","icon","onDismiss","message","size","title","variant","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","closeButtonReference","useRef","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","_jsx","StatusIcon","Size","LARGE","sentiment","role","Sentiment","NEGATIVE","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Action","CloseButton","ref","onClick"],"mappings":";;;;;;;;;;;;;;;;;;AA8BYA,oCAOX;AAPD,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,SAAoB,CAAA;AACpBA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,WAAiB,CAAA;AACjBA,EAAAA,kBAAA,CAAA,WAAA,CAAA,GAAA,UAAsB,CAAA;AACtBA,EAAAA,kBAAA,CAAA,aAAA,CAAA,GAAA,WAAyB,CAAA;AACzBA,EAAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,aAAsB,CAAA;AACtBA,EAAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,YAA2B,CAAA;AAC7B,CAAC,EAPWA,0BAAkB,KAAlBA,0BAAkB,GAO7B,EAAA,CAAA,CAAA,CAAA;AA2BD,SAASC,WAAWA,CAACC,IAAe,EAAA;AAClC,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,SAAS;AACZ,MAAA,OAAO,UAAU,CAAA;AACnB,IAAA,KAAK,MAAM;AACT,MAAA,OAAO,SAAS,CAAA;AAClB,IAAA,KAAK,OAAO;AACV,MAAA,OAAO,UAAU,CAAA;AACnB,IAAA;AACE,MAAA,OAAOA,IAAI,CAAA;AACf,GAAA;AACF,CAAA;AAEwB,SAAAC,KAAKA,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C,OAAO;AAACoD,MAAAA,OAAO,EAAEjD,SAAAA;AAAU,KAAG,CACjF,CAAA;AAAA,GACE,CAAC,CAAA;AAEV,CAAA;AAEA,SAASgB,oBAAoBA,CAACtB,KAA8B,EAAA;AAC1D,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC,CAAA;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B,CAAA;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC,CAAA;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB,CAAA;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB,CAAA;AAC5B,IAAA,KAAK,SAAS,CAAA;AACd,IAAA;AACE,MAAA,OAAO,OAAO,CAAA;AAClB,GAAA;AACF;;;;"}
1
+ {"version":3,"file":"Alert.js","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport { Sentiment, Size, Typography, Variant } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport { Action } from '../common/action/Action';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n variant?: `${Variant}`;\n /** Controls rendering of the Alert component. <br /> Toggle this prop instead using conditional rendering and logical AND (&&) operator, to make the component work with screen readers. */\n active?: boolean;\n /** @deprecated Use `InlineAlert` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n arrow,\n action,\n children,\n className,\n dismissible,\n icon,\n onDismiss,\n message,\n size,\n title,\n type = 'neutral',\n variant = 'desktop',\n active = true,\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState(false);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n return (\n <div role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}>\n {active && (\n <div\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div\n className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}\n data-testid={variant}\n >\n {icon ? (\n <div className=\"alert__icon\">{icon}</div>\n ) : (\n <StatusIcon size={Size.LARGE} sentiment={resolvedType} />\n )}\n <div className=\"alert__message\">\n <div>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action && <Action action={action} className=\"m-t-1\" />}\n </div>\n </div>\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\n )}\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","arrow","action","children","className","dismissible","icon","onDismiss","message","size","title","variant","active","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","closeButtonReference","useRef","_jsx","role","Sentiment","NEGATIVE","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","Size","LARGE","sentiment","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Action","CloseButton","ref","onClick"],"mappings":";;;;;;;;;;;;;;;;;;AA8BYA,oCAOX;AAPD,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,SAAoB,CAAA;AACpBA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,WAAiB,CAAA;AACjBA,EAAAA,kBAAA,CAAA,WAAA,CAAA,GAAA,UAAsB,CAAA;AACtBA,EAAAA,kBAAA,CAAA,aAAA,CAAA,GAAA,WAAyB,CAAA;AACzBA,EAAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,aAAsB,CAAA;AACtBA,EAAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,YAA2B,CAAA;AAC7B,CAAC,EAPWA,0BAAkB,KAAlBA,0BAAkB,GAO7B,EAAA,CAAA,CAAA,CAAA;AA6BD,SAASC,WAAWA,CAACC,IAAe,EAAA;AAClC,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,SAAS;AACZ,MAAA,OAAO,UAAU,CAAA;AACnB,IAAA,KAAK,MAAM;AACT,MAAA,OAAO,SAAS,CAAA;AACl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AAA;AAACpD,YAAAA,MAAM,EAAEA,MAAO;AAACE,YAAAA,SAAS,EAAC,OAAA;AAAO,YAAG,CAAA;AAAA,SACpD,CACP,CAAA;AAAA,OAAK,CACL,EAACG,SAAS,iBACRe,cAAA,CAACiC,uBAAW,EAAA;AAACC,QAAAA,GAAG,EAAEpC,oBAAqB;AAAChB,QAAAA,SAAS,EAAC,OAAO;AAACqD,QAAAA,OAAO,EAAElD,SAAAA;AAAU,OAAG,CACjF,CAAA;KACE,CAAA;AACN,GACE,CAAC,CAAA;AAEV,CAAA;AAEA,SAASqB,oBAAoBA,CAAC3B,KAA8B,EAAA;AAC1D,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC,CAAA;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B,CAAA;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC,CAAA;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB,CAAA;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB,CAAA;AAC5B,IAAA,KAAK,SAAS,CAAA;AACd,IAAA;AACE,MAAA,OAAO,OAAO,CAAA;AAClB,GAAA;AACF;;;;"}
@@ -6,7 +6,7 @@ import StatusIcon from '../statusIcon/StatusIcon.mjs';
6
6
  import Title from '../title/Title.mjs';
7
7
  import InlineMarkdown from './inlineMarkdown/InlineMarkdown.mjs';
8
8
  import { Action } from '../common/action/Action.mjs';
9
- import { jsxs, jsx } from 'react/jsx-runtime';
9
+ import { jsx, jsxs } from 'react/jsx-runtime';
10
10
  import { logActionRequired } from '../utilities/logActionRequired.mjs';
11
11
  import { Sentiment } from '../common/propsValues/sentiment.mjs';
12
12
  import { Size } from '../common/propsValues/size.mjs';
@@ -45,7 +45,8 @@ function Alert({
45
45
  size,
46
46
  title,
47
47
  type = 'neutral',
48
- variant = 'desktop'
48
+ variant = 'desktop',
49
+ active = true
49
50
  }) {
50
51
  useEffect(() => {
51
52
  if (arrow !== undefined) {
@@ -75,58 +76,60 @@ function Alert({
75
76
  }, [resolvedType, type]);
76
77
  const [shouldFire, setShouldFire] = useState(false);
77
78
  const closeButtonReference = useRef(null);
78
- return /*#__PURE__*/jsxs("div", {
79
- className: clsx('alert d-flex', `alert-${resolvedType}`, arrow != null && alertArrowClassNames(arrow), className),
80
- "data-testid": "alert",
81
- onTouchStart: () => setShouldFire(true),
82
- onTouchEnd: event => {
83
- if (shouldFire && action?.href &&
84
- // Check if current event is triggered from closeButton
85
- event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
86
- if (action.target === '_blank') {
87
- window.top?.open(action.href);
88
- } else {
89
- window.top?.location.assign(action.href);
79
+ return /*#__PURE__*/jsx("div", {
80
+ role: resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status',
81
+ children: active && /*#__PURE__*/jsxs("div", {
82
+ className: clsx('alert d-flex', `alert-${resolvedType}`, arrow != null && alertArrowClassNames(arrow), className),
83
+ "data-testid": "alert",
84
+ onTouchStart: () => setShouldFire(true),
85
+ onTouchEnd: event => {
86
+ if (shouldFire && action?.href &&
87
+ // Check if current event is triggered from closeButton
88
+ event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
89
+ if (action.target === '_blank') {
90
+ window.top?.open(action.href);
91
+ } else {
92
+ window.top?.location.assign(action.href);
93
+ }
90
94
  }
91
- }
92
- setShouldFire(false);
93
- },
94
- onTouchMove: () => setShouldFire(false),
95
- children: [/*#__PURE__*/jsxs("div", {
96
- className: clsx('alert__content', 'd-flex', 'flex-grow-1', variant),
97
- "data-testid": variant,
98
- children: [icon ? /*#__PURE__*/jsx("div", {
99
- className: "alert__icon",
100
- children: icon
101
- }) : /*#__PURE__*/jsx(StatusIcon, {
102
- size: Size.LARGE,
103
- sentiment: resolvedType
104
- }), /*#__PURE__*/jsxs("div", {
105
- className: "alert__message",
106
- children: [/*#__PURE__*/jsxs("div", {
107
- role: Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status',
108
- children: [title && /*#__PURE__*/jsx(Title, {
109
- className: "m-b-1",
110
- type: Typography.TITLE_BODY,
111
- children: title
112
- }), /*#__PURE__*/jsx(Body, {
113
- as: "span",
114
- className: "d-block",
115
- type: Typography.BODY_LARGE,
116
- children: children || /*#__PURE__*/jsx(InlineMarkdown, {
117
- children: message
118
- })
95
+ setShouldFire(false);
96
+ },
97
+ onTouchMove: () => setShouldFire(false),
98
+ children: [/*#__PURE__*/jsxs("div", {
99
+ className: clsx('alert__content', 'd-flex', 'flex-grow-1', variant),
100
+ "data-testid": variant,
101
+ children: [icon ? /*#__PURE__*/jsx("div", {
102
+ className: "alert__icon",
103
+ children: icon
104
+ }) : /*#__PURE__*/jsx(StatusIcon, {
105
+ size: Size.LARGE,
106
+ sentiment: resolvedType
107
+ }), /*#__PURE__*/jsxs("div", {
108
+ className: "alert__message",
109
+ children: [/*#__PURE__*/jsxs("div", {
110
+ children: [title && /*#__PURE__*/jsx(Title, {
111
+ className: "m-b-1",
112
+ type: Typography.TITLE_BODY,
113
+ children: title
114
+ }), /*#__PURE__*/jsx(Body, {
115
+ as: "span",
116
+ className: "d-block",
117
+ type: Typography.BODY_LARGE,
118
+ children: children || /*#__PURE__*/jsx(InlineMarkdown, {
119
+ children: message
120
+ })
121
+ })]
122
+ }), action && /*#__PURE__*/jsx(Action, {
123
+ action: action,
124
+ className: "m-t-1"
119
125
  })]
120
- }), action && /*#__PURE__*/jsx(Action, {
121
- action: action,
122
- className: "m-t-1"
123
126
  })]
127
+ }), onDismiss && /*#__PURE__*/jsx(CloseButton, {
128
+ ref: closeButtonReference,
129
+ className: "m-l-2",
130
+ onClick: onDismiss
124
131
  })]
125
- }), onDismiss && /*#__PURE__*/jsx(CloseButton, {
126
- ref: closeButtonReference,
127
- className: "m-l-2",
128
- onClick: onDismiss
129
- })]
132
+ })
130
133
  });
131
134
  }
132
135
  function alertArrowClassNames(arrow) {
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.mjs","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport { Sentiment, Size, Typography, Variant } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport { Action } from '../common/action/Action';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n variant?: `${Variant}`;\n /** @deprecated Use `InlineAlert` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n arrow,\n action,\n children,\n className,\n dismissible,\n icon,\n onDismiss,\n message,\n size,\n title,\n type = 'neutral',\n variant = 'desktop',\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState(false);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n return (\n <div\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div\n className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}\n data-testid={variant}\n >\n {icon ? (\n <div className=\"alert__icon\">{icon}</div>\n ) : (\n <StatusIcon size={Size.LARGE} sentiment={resolvedType} />\n )}\n <div className=\"alert__message\">\n <div role={Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status'}>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action && <Action action={action} className=\"m-t-1\" />}\n </div>\n </div>\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","arrow","action","children","className","dismissible","icon","onDismiss","message","size","title","variant","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","closeButtonReference","useRef","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","_jsx","StatusIcon","Size","LARGE","sentiment","role","Sentiment","NEGATIVE","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Action","CloseButton","ref","onClick"],"mappings":";;;;;;;;;;;;;;IA8BYA,mBAOX;AAPD,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,UA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,GAAA;AACF;;;;"}
1
+ {"version":3,"file":"Alert.mjs","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport { Sentiment, Size, Typography, Variant } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport StatusIcon from '../statusIcon';\nimport Title from '../title/Title';\nimport { logActionRequired } from '../utilities';\n\nimport InlineMarkdown from './inlineMarkdown';\nimport { Action } from '../common/action/Action';\n\nexport type AlertAction = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\n/** @deprecated Use `\"top\" | \"bottom\"` instead. */\ntype AlertTypeDeprecated = `${Sentiment.SUCCESS | Sentiment.INFO | Sentiment.ERROR}`;\ntype AlertTypeResolved = `${\n | Sentiment.POSITIVE\n | Sentiment.NEUTRAL\n | Sentiment.WARNING\n | Sentiment.NEGATIVE}`;\nexport type AlertType = AlertTypeResolved | AlertTypeDeprecated;\n\nexport enum AlertArrowPosition {\n TOP_LEFT = 'up-left',\n TOP = 'up-center',\n TOP_RIGHT = 'up-right',\n BOTTOM_LEFT = 'down-left',\n BOTTOM = 'down-center',\n BOTTOM_RIGHT = 'down-right',\n}\n\nexport interface AlertProps {\n /** An optional call to action to sit under the main body of the alert. If your label is short, use aria-label to provide more context */\n action?: AlertAction;\n className?: string;\n /** An optional icon. If not provided, we will default the icon to something appropriate for the type */\n icon?: React.ReactNode;\n /** Title for the alert component */\n title?: string;\n /** The main body of the alert. Accepts plain text and bold words specified with **double stars */\n message?: string;\n /** The presence of the onDismiss handler will trigger the visibility of the close button */\n onDismiss?: React.MouseEventHandler<HTMLButtonElement>;\n /** The type dictates which icon and colour will be used */\n type?: AlertType;\n variant?: `${Variant}`;\n /** Controls rendering of the Alert component. <br /> Toggle this prop instead using conditional rendering and logical AND (&&) operator, to make the component work with screen readers. */\n active?: boolean;\n /** @deprecated Use `InlineAlert` instead. */\n arrow?: `${AlertArrowPosition}`;\n /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */\n children?: React.ReactNode;\n /** @deprecated Use `onDismiss` instead. */\n dismissible?: boolean;\n /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */\n size?: `${Size}`;\n}\n\nfunction resolveType(type: AlertType): AlertTypeResolved {\n switch (type) {\n case 'success':\n return 'positive';\n case 'info':\n return 'neutral';\n case 'error':\n return 'negative';\n default:\n return type;\n }\n}\n\nexport default function Alert({\n arrow,\n action,\n children,\n className,\n dismissible,\n icon,\n onDismiss,\n message,\n size,\n title,\n type = 'neutral',\n variant = 'desktop',\n active = true,\n}: AlertProps) {\n useEffect(() => {\n if (arrow !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'arrow' anymore, use 'InlineAlert' instead.\",\n );\n }\n }, [arrow]);\n\n useEffect(() => {\n if (children !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'children' anymore, use 'message' instead.\",\n );\n }\n }, [children]);\n\n useEffect(() => {\n if (dismissible !== undefined) {\n logActionRequired(\n \"Alert component doesn't support 'dismissible' anymore, use 'onDismiss' instead.\",\n );\n }\n }, [dismissible]);\n\n useEffect(() => {\n if (size !== undefined) {\n logActionRequired(\"Alert component doesn't support 'size' anymore, please remove that prop.\");\n }\n }, [size]);\n\n const resolvedType = resolveType(type);\n useEffect(() => {\n if (resolvedType !== type) {\n logActionRequired(\n `Alert component has deprecated '${type}' value for the 'type' prop. Please use '${resolvedType}' instead.`,\n );\n }\n }, [resolvedType, type]);\n\n const [shouldFire, setShouldFire] = useState(false);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n return (\n <div role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}>\n {active && (\n <div\n className={clsx(\n 'alert d-flex',\n `alert-${resolvedType}`,\n arrow != null && alertArrowClassNames(arrow),\n className,\n )}\n data-testid=\"alert\"\n onTouchStart={() => setShouldFire(true)}\n onTouchEnd={(event) => {\n if (\n shouldFire &&\n action?.href &&\n // Check if current event is triggered from closeButton\n event.target instanceof Node &&\n closeButtonReference.current &&\n !closeButtonReference.current.contains(event.target)\n ) {\n if (action.target === '_blank') {\n window.top?.open(action.href);\n } else {\n window.top?.location.assign(action.href);\n }\n }\n setShouldFire(false);\n }}\n onTouchMove={() => setShouldFire(false)}\n >\n <div\n className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}\n data-testid={variant}\n >\n {icon ? (\n <div className=\"alert__icon\">{icon}</div>\n ) : (\n <StatusIcon size={Size.LARGE} sentiment={resolvedType} />\n )}\n <div className=\"alert__message\">\n <div>\n {title && (\n <Title className=\"m-b-1\" type={Typography.TITLE_BODY}>\n {title}\n </Title>\n )}\n <Body as=\"span\" className=\"d-block\" type={Typography.BODY_LARGE}>\n {children || <InlineMarkdown>{message}</InlineMarkdown>}\n </Body>\n </div>\n {action && <Action action={action} className=\"m-t-1\" />}\n </div>\n </div>\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\n )}\n </div>\n );\n}\n\nfunction alertArrowClassNames(arrow: `${AlertArrowPosition}`) {\n switch (arrow) {\n case 'down-center':\n return 'arrow arrow-bottom arrow-center';\n case 'down-left':\n return 'arrow arrow-bottom arrow-left';\n case 'down-right':\n return 'arrow arrow-bottom arrow-right';\n case 'up-center':\n return 'arrow arrow-center';\n case 'up-right':\n return 'arrow arrow-right';\n case 'up-left':\n default:\n return 'arrow';\n }\n}\n"],"names":["AlertArrowPosition","resolveType","type","Alert","arrow","action","children","className","dismissible","icon","onDismiss","message","size","title","variant","active","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","closeButtonReference","useRef","_jsx","role","Sentiment","NEGATIVE","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","Size","LARGE","sentiment","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMark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AAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC,CAAA;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB,CAAA;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB,CAAA;AAC5B,IAAA,KAAK,SAAS,CAAA;AACd,IAAA;AACE,MAAA,OAAO,OAAO,CAAA;AAClB,GAAA;AACF;;;;"}
@@ -33,6 +33,8 @@ export interface AlertProps {
33
33
  /** The type dictates which icon and colour will be used */
34
34
  type?: AlertType;
35
35
  variant?: `${Variant}`;
36
+ /** Controls rendering of the Alert component. <br /> Toggle this prop instead using conditional rendering and logical AND (&&) operator, to make the component work with screen readers. */
37
+ active?: boolean;
36
38
  /** @deprecated Use `InlineAlert` instead. */
37
39
  arrow?: `${AlertArrowPosition}`;
38
40
  /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */
@@ -42,6 +44,6 @@ export interface AlertProps {
42
44
  /** @deprecated Alert component doesn't support `size` anymore, please remove this prop. */
43
45
  size?: `${Size}`;
44
46
  }
45
- export default function Alert({ arrow, action, children, className, dismissible, icon, onDismiss, message, size, title, type, variant, }: AlertProps): import("react").JSX.Element;
47
+ export default function Alert({ arrow, action, children, className, dismissible, icon, onDismiss, message, size, title, type, variant, active, }: AlertProps): import("react").JSX.Element;
46
48
  export {};
47
49
  //# sourceMappingURL=Alert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Alert.d.ts","sourceRoot":"","sources":["../../../src/alert/Alert.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAc,OAAO,EAAE,MAAM,WAAW,CAAC;AASjE,MAAM,MAAM,WAAW,GAAG;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,CAAC,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AAK,CAAC,EAAE,MAAM,CAAC;IACf,kGAAkG;IAClG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACvD,2DAA2D;IAC3D,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IACvB,4LAA4L;IAC5L,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAChC,oHAAoH;IACpH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,2CAA2C;IAC3C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2FAA2F;IAC3F,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;CAClB;AAeD,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC5B,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,IAAI,EACJ,SAAS,EACT,OAAO,EACP,IAAI,EACJ,KAAK,EACL,IAAgB,EAChB,OAAmB,EACnB,MAAa,GACd,EAAE,UAAU,+BAyGZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transferwise/components",
3
- "version": "46.71.8",
3
+ "version": "46.72.0",
4
4
  "description": "Neptune React components",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -91,9 +91,9 @@
91
91
  "rollup": "^4.18.1",
92
92
  "rollup-preserve-directives": "^1.1.1",
93
93
  "storybook": "^8.2.2",
94
+ "@transferwise/less-config": "3.1.0",
94
95
  "@transferwise/neptune-css": "14.19.1",
95
- "@wise/components-theming": "1.6.1",
96
- "@transferwise/less-config": "3.1.0"
96
+ "@wise/components-theming": "1.6.1"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "@transferwise/icons": "^3.13.1",
@@ -467,4 +467,24 @@ describe('Alert', () => {
467
467
  expect(screen.getByTestId('status-icon')).toBeInTheDocument();
468
468
  });
469
469
  });
470
+
471
+ describe('`active` prop', () => {
472
+ it('should render wrapper and alert if `active` is unset', () => {
473
+ render(<Alert message={message} />);
474
+ expect(screen.getByRole('status')).toBeInTheDocument();
475
+ expect(screen.getByText(message)).toBeInTheDocument();
476
+ });
477
+
478
+ it('should render wrapper and alert if `active={false}', () => {
479
+ render(<Alert message={message} active={false} />);
480
+ expect(screen.getByRole('status')).toBeInTheDocument();
481
+ expect(screen.queryByText(message)).not.toBeInTheDocument();
482
+ });
483
+
484
+ it('should render wrapper and alert if `active` is set', () => {
485
+ render(<Alert message={message} />);
486
+ expect(screen.getByRole('status')).toBeInTheDocument();
487
+ expect(screen.getByText(message)).toBeInTheDocument();
488
+ });
489
+ });
470
490
  });
@@ -1,10 +1,10 @@
1
- /* eslint-disable no-alert */
1
+ import { useState } from 'react';
2
2
  import { Meta, StoryObj } from '@storybook/react';
3
3
  import { action } from '@storybook/addon-actions';
4
4
  import { ClockBorderless } from '@transferwise/icons';
5
5
 
6
6
  import { Sentiment } from '../common';
7
-
7
+ import { Button } from '..';
8
8
  import Alert, { AlertArrowPosition } from './Alert';
9
9
 
10
10
  export default {
@@ -12,6 +12,7 @@ export default {
12
12
  title: 'Feedback/Alert',
13
13
  args: {
14
14
  type: Sentiment.POSITIVE,
15
+ active: true,
15
16
  message:
16
17
  'Payments sent to your bank details **today** might not arrive in time for the holidays.',
17
18
  },
@@ -103,3 +104,50 @@ export const WithTitle: Story = {
103
104
  onDismiss: () => {},
104
105
  },
105
106
  };
107
+
108
+ /**
109
+ * For ARIA live region to function correctly with screen readers,
110
+ * the container with an appropriate ARIA role (in the case of this
111
+ * component, it's `status` or `alert`) must be rendered first.
112
+ * Once present in the accessibility tree, its dynamic contents
113
+ * will be announced correctly.
114
+ *
115
+ * Because of that, using logical AND (&&) operator is discouraged
116
+ * and, instead, engineers should toggle the `active` prop which
117
+ * provides that logic internally.
118
+ */
119
+ export const ConditionallyRendered: Story = {
120
+ render: function Render(args) {
121
+ const [isActive, setIsActive] = useState(false);
122
+
123
+ return (
124
+ <>
125
+ <Button htmlType="button" onClick={() => setIsActive((value) => !value)}>
126
+ Trigger Alert
127
+ </Button>
128
+
129
+ <Alert {...args} active={isActive} className="m-t-5" />
130
+ </>
131
+ );
132
+ },
133
+ parameters: {
134
+ docs: {
135
+ source: {
136
+ code: `
137
+ function Render (args) {
138
+ const [isActive, setIsActive] = useState(false);
139
+
140
+ return (
141
+ <>
142
+ <Button htmlType="button" onClick={() => setIsActive(value => !value)}>
143
+ Trigger Alert
144
+ </Button>
145
+
146
+ <Alert {...args} active={isActive} className="m-t-5" />
147
+ </>
148
+ )
149
+ }`,
150
+ },
151
+ },
152
+ },
153
+ };
@@ -52,6 +52,8 @@ export interface AlertProps {
52
52
  /** The type dictates which icon and colour will be used */
53
53
  type?: AlertType;
54
54
  variant?: `${Variant}`;
55
+ /** Controls rendering of the Alert component. <br /> Toggle this prop instead using conditional rendering and logical AND (&&) operator, to make the component work with screen readers. */
56
+ active?: boolean;
55
57
  /** @deprecated Use `InlineAlert` instead. */
56
58
  arrow?: `${AlertArrowPosition}`;
57
59
  /** @deprecated Use `message` instead. Be aware `message` only accepts plain text or text with **bold** markdown. */
@@ -88,6 +90,7 @@ export default function Alert({
88
90
  title,
89
91
  type = 'neutral',
90
92
  variant = 'desktop',
93
+ active = true,
91
94
  }: AlertProps) {
92
95
  useEffect(() => {
93
96
  if (arrow !== undefined) {
@@ -133,59 +136,63 @@ export default function Alert({
133
136
  const closeButtonReference = useRef<HTMLButtonElement>(null);
134
137
 
135
138
  return (
136
- <div
137
- className={clsx(
138
- 'alert d-flex',
139
- `alert-${resolvedType}`,
140
- arrow != null && alertArrowClassNames(arrow),
141
- className,
142
- )}
143
- data-testid="alert"
144
- onTouchStart={() => setShouldFire(true)}
145
- onTouchEnd={(event) => {
146
- if (
147
- shouldFire &&
148
- action?.href &&
149
- // Check if current event is triggered from closeButton
150
- event.target instanceof Node &&
151
- closeButtonReference.current &&
152
- !closeButtonReference.current.contains(event.target)
153
- ) {
154
- if (action.target === '_blank') {
155
- window.top?.open(action.href);
156
- } else {
157
- window.top?.location.assign(action.href);
158
- }
159
- }
160
- setShouldFire(false);
161
- }}
162
- onTouchMove={() => setShouldFire(false)}
163
- >
164
- <div
165
- className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}
166
- data-testid={variant}
167
- >
168
- {icon ? (
169
- <div className="alert__icon">{icon}</div>
170
- ) : (
171
- <StatusIcon size={Size.LARGE} sentiment={resolvedType} />
172
- )}
173
- <div className="alert__message">
174
- <div role={Sentiment.NEGATIVE === resolvedType ? 'alert' : 'status'}>
175
- {title && (
176
- <Title className="m-b-1" type={Typography.TITLE_BODY}>
177
- {title}
178
- </Title>
139
+ <div role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}>
140
+ {active && (
141
+ <div
142
+ className={clsx(
143
+ 'alert d-flex',
144
+ `alert-${resolvedType}`,
145
+ arrow != null && alertArrowClassNames(arrow),
146
+ className,
147
+ )}
148
+ data-testid="alert"
149
+ onTouchStart={() => setShouldFire(true)}
150
+ onTouchEnd={(event) => {
151
+ if (
152
+ shouldFire &&
153
+ action?.href &&
154
+ // Check if current event is triggered from closeButton
155
+ event.target instanceof Node &&
156
+ closeButtonReference.current &&
157
+ !closeButtonReference.current.contains(event.target)
158
+ ) {
159
+ if (action.target === '_blank') {
160
+ window.top?.open(action.href);
161
+ } else {
162
+ window.top?.location.assign(action.href);
163
+ }
164
+ }
165
+ setShouldFire(false);
166
+ }}
167
+ onTouchMove={() => setShouldFire(false)}
168
+ >
169
+ <div
170
+ className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}
171
+ data-testid={variant}
172
+ >
173
+ {icon ? (
174
+ <div className="alert__icon">{icon}</div>
175
+ ) : (
176
+ <StatusIcon size={Size.LARGE} sentiment={resolvedType} />
179
177
  )}
180
- <Body as="span" className="d-block" type={Typography.BODY_LARGE}>
181
- {children || <InlineMarkdown>{message}</InlineMarkdown>}
182
- </Body>
178
+ <div className="alert__message">
179
+ <div>
180
+ {title && (
181
+ <Title className="m-b-1" type={Typography.TITLE_BODY}>
182
+ {title}
183
+ </Title>
184
+ )}
185
+ <Body as="span" className="d-block" type={Typography.BODY_LARGE}>
186
+ {children || <InlineMarkdown>{message}</InlineMarkdown>}
187
+ </Body>
188
+ </div>
189
+ {action && <Action action={action} className="m-t-1" />}
190
+ </div>
183
191
  </div>
184
- {action && <Action action={action} className="m-t-1" />}
192
+ {onDismiss && (
193
+ <CloseButton ref={closeButtonReference} className="m-l-2" onClick={onDismiss} />
194
+ )}
185
195
  </div>
186
- </div>
187
- {onDismiss && (
188
- <CloseButton ref={closeButtonReference} className="m-l-2" onClick={onDismiss} />
189
196
  )}
190
197
  </div>
191
198
  );