@transferwise/components 0.0.0-experimental-d4fb387 → 0.0.0-experimental-93ed47e
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/alert/Alert.js +29 -17
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +26 -14
- package/build/alert/Alert.mjs.map +1 -1
- package/build/common/action/Action.js +3 -2
- package/build/common/action/Action.js.map +1 -1
- package/build/common/action/Action.mjs +3 -2
- package/build/common/action/Action.mjs.map +1 -1
- package/build/common/propsValues/sentiment.js +1 -0
- package/build/common/propsValues/sentiment.js.map +1 -1
- package/build/common/propsValues/sentiment.mjs +1 -0
- package/build/common/propsValues/sentiment.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +13 -74
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +14 -75
- package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/main.css +11 -72
- package/build/statusIcon/StatusIcon.js +5 -1
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.js +3 -0
- package/build/statusIcon/StatusIcon.messages.js.map +1 -1
- package/build/statusIcon/StatusIcon.messages.mjs +3 -0
- package/build/statusIcon/StatusIcon.messages.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +5 -1
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/styles/criticalBanner/CriticalCommsBanner.css +7 -72
- package/build/styles/main.css +11 -72
- package/build/styles/statusIcon/StatusIcon.css +4 -0
- package/build/types/alert/Alert.d.ts +2 -1
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/common/action/Action.d.ts +3 -1
- package/build/types/common/action/Action.d.ts.map +1 -1
- package/build/types/common/propsValues/sentiment.d.ts +1 -0
- package/build/types/common/propsValues/sentiment.d.ts.map +1 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts +3 -1
- package/build/types/criticalBanner/CriticalCommsBanner.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.messages.d.ts +5 -0
- package/build/types/statusIcon/StatusIcon.messages.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.less +4 -0
- package/src/alert/Alert.story.tsx +36 -0
- package/src/alert/Alert.tsx +26 -8
- package/src/button/Button.story.tsx +7 -2
- package/src/button/LegacyButton.story.tsx +4 -1
- package/src/common/action/Action.tsx +8 -2
- package/src/common/propsValues/sentiment.ts +1 -0
- package/src/criticalBanner/CriticalCommsBanner.css +7 -72
- package/src/criticalBanner/CriticalCommsBanner.less +12 -73
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +2 -0
- package/src/criticalBanner/CriticalCommsBanner.tsx +18 -51
- package/src/i18n/en.json +1 -0
- package/src/main.css +11 -72
- package/src/statusIcon/StatusIcon.css +4 -0
- package/src/statusIcon/StatusIcon.less +4 -0
- package/src/statusIcon/StatusIcon.messages.ts +6 -0
- package/src/statusIcon/StatusIcon.tsx +8 -1
package/build/alert/Alert.js
CHANGED
|
@@ -9,7 +9,7 @@ require('../common/theme.js');
|
|
|
9
9
|
require('../common/direction.js');
|
|
10
10
|
require('../common/propsValues/control.js');
|
|
11
11
|
require('../common/propsValues/breakpoint.js');
|
|
12
|
-
|
|
12
|
+
require('../common/propsValues/size.js');
|
|
13
13
|
var typography = require('../common/propsValues/typography.js');
|
|
14
14
|
require('../common/propsValues/width.js');
|
|
15
15
|
require('../common/propsValues/type.js');
|
|
@@ -66,7 +66,7 @@ function Alert({
|
|
|
66
66
|
variant = 'desktop',
|
|
67
67
|
arrow,
|
|
68
68
|
children,
|
|
69
|
-
size
|
|
69
|
+
size,
|
|
70
70
|
dismissible
|
|
71
71
|
}) {
|
|
72
72
|
React.useEffect(() => {
|
|
@@ -85,10 +85,10 @@ function Alert({
|
|
|
85
85
|
}
|
|
86
86
|
}, [dismissible]);
|
|
87
87
|
React.useEffect(() => {
|
|
88
|
-
if (size
|
|
88
|
+
if (size !== undefined) {
|
|
89
89
|
logActionRequired.logActionRequired("Alert component doesn't support 'size' anymore, please remove that prop.");
|
|
90
90
|
}
|
|
91
|
-
}, [size
|
|
91
|
+
}, [size]);
|
|
92
92
|
const resolvedType = resolveType(type);
|
|
93
93
|
React.useEffect(() => {
|
|
94
94
|
if (resolvedType !== type) {
|
|
@@ -103,8 +103,14 @@ function Alert({
|
|
|
103
103
|
}, constants.WDS_LIVE_REGION_DELAY_MS);
|
|
104
104
|
}, []);
|
|
105
105
|
const closeButtonReference = React.useRef(null);
|
|
106
|
+
const showButtonBelow = () => {
|
|
107
|
+
if (variant === 'desktop' && resolvedType === 'critical') {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
106
112
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
107
|
-
role: resolvedType === sentiment.Sentiment.NEGATIVE ? 'alert' : 'status',
|
|
113
|
+
role: resolvedType === sentiment.Sentiment.NEGATIVE || resolvedType === sentiment.Sentiment.CRITICAL ? 'alert' : 'status',
|
|
108
114
|
className: "wds-alert__liveRegion",
|
|
109
115
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
110
116
|
"aria-hidden": shouldAnnounce ? undefined : 'true',
|
|
@@ -124,17 +130,17 @@ function Alert({
|
|
|
124
130
|
setShouldFire(false);
|
|
125
131
|
},
|
|
126
132
|
onTouchMove: () => setShouldFire(false),
|
|
127
|
-
children: [/*#__PURE__*/jsxRuntime.
|
|
128
|
-
className:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
className: "alert__icon",
|
|
132
|
-
children: icon
|
|
133
|
-
}) : /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
|
|
134
|
-
size: size.Size.LARGE,
|
|
133
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
134
|
+
className: "alert__icon",
|
|
135
|
+
children: icon || /*#__PURE__*/jsxRuntime.jsx(StatusIcon, {
|
|
136
|
+
size: 48,
|
|
135
137
|
sentiment: resolvedType,
|
|
136
138
|
iconLabel: statusIconLabel
|
|
137
|
-
})
|
|
139
|
+
})
|
|
140
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
141
|
+
className: clsx.clsx('alert__content', 'd-flex', 'flex-grow-1', variant),
|
|
142
|
+
"data-testid": variant,
|
|
143
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
138
144
|
className: "alert__message",
|
|
139
145
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
140
146
|
children: [title && /*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
@@ -149,12 +155,18 @@ function Alert({
|
|
|
149
155
|
children: message
|
|
150
156
|
})
|
|
151
157
|
})]
|
|
152
|
-
}), action && /*#__PURE__*/jsxRuntime.jsx(Action.Action, {
|
|
158
|
+
}), action && showButtonBelow() && /*#__PURE__*/jsxRuntime.jsx(Action.Action, {
|
|
153
159
|
action: action,
|
|
154
160
|
variant: "action-button",
|
|
155
|
-
className: "m-t-
|
|
161
|
+
className: "m-t-2"
|
|
156
162
|
})]
|
|
157
|
-
})
|
|
163
|
+
})
|
|
164
|
+
}), action && !showButtonBelow() && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
165
|
+
className: "action__desktop",
|
|
166
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Action.Action, {
|
|
167
|
+
action: action,
|
|
168
|
+
variant: "action-button"
|
|
169
|
+
})
|
|
158
170
|
}), onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton.CloseButton, {
|
|
159
171
|
ref: closeButtonReference,
|
|
160
172
|
className: "m-l-2",
|
package/build/alert/Alert.js.map
CHANGED
|
@@ -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 {\n CloseButton,\n Sentiment,\n Size,\n Typography,\n Variant,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\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 /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\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 action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n variant = 'desktop',\n arrow,\n children,\n size,\n dismissible,\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<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n return (\n <div\n role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\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} iconLabel={statusIconLabel} />\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} variant=\"action-button\" className=\"m-t-1\" />}\n </div>\n </div>\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\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","action","className","icon","statusIconLabel","onDismiss","message","title","variant","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","setTimeout","WDS_LIVE_REGION_DELAY_MS","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","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Action","CloseButton","ref","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCYA,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;AAgCD,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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BAAU,CAACI,UAAW;AAAA/C,cAAAA,QAAA,EAC7DA,QAAQ,iBAAIgB,cAAA,CAACgC,cAAc,EAAA;AAAAhD,gBAAAA,QAAA,EAAEJ,OAAAA;eAAwB,CAAA;AAAC,aACnD,CACR,CAAA;AAAA,WAAK,CACL,EAACL,MAAM,iBAAIyB,cAAA,CAACiC,aAAM,EAAA;AAAC1D,YAAAA,MAAM,EAAEA,MAAO;AAACO,YAAAA,OAAO,EAAC,eAAe;AAACN,YAAAA,SAAS,EAAC,OAAA;AAAO,YAAG,CAAA;AAAA,SAC5E,CACP,CAAA;AAAA,OAAK,CACL,EAACG,SAAS,iBACRqB,cAAA,CAACkC,uBAAW,EAAA;AAACC,QAAAA,GAAG,EAAErC,oBAAqB;AAACtB,QAAAA,SAAS,EAAC,OAAO;AAAC4D,QAAAA,OAAO,EAAEzD,SAAAA;AAAU,OAAG,CACjF,CAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV,CAAA;AAEA,SAAS2B,oBAAoBA,CAACvB,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 {\n CloseButton,\n Sentiment,\n Size,\n Typography,\n Variant,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\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\n | Sentiment.CRITICAL}`;\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 /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\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 /** @deprecated They both look behave the same. */\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 action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n variant = 'desktop',\n arrow,\n children,\n size,\n dismissible,\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<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n const showButtonBelow = () => {\n if (variant === 'desktop' && resolvedType === 'critical') {\n return false;\n }\n return true;\n };\n\n return (\n <div\n role={\n resolvedType === Sentiment.NEGATIVE || resolvedType === Sentiment.CRITICAL\n ? 'alert'\n : 'status'\n }\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\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 className=\"alert__icon\">\n {icon || <StatusIcon size={48} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div\n className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}\n data-testid={variant}\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 && showButtonBelow() && (\n <Action action={action} variant=\"action-button\" className=\"m-t-2\" />\n )}\n </div>\n </div>\n {action && !showButtonBelow() && (\n <div className=\"action__desktop\">\n <Action action={action} variant=\"action-button\" />\n </div>\n )}\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\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","action","className","icon","statusIconLabel","onDismiss","message","title","variant","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","setTimeout","WDS_LIVE_REGION_DELAY_MS","closeButtonReference","useRef","showButtonBelow","_jsx","role","Sentiment","NEGATIVE","CRITICAL","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","sentiment","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Action","CloseButton","ref","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCYA,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;AAiCD,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,CAAC;EAC5BC,MAAM;EACNC,SAAS;EACT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Y;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;;;;"}
|
package/build/alert/Alert.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import '../common/theme.mjs';
|
|
|
5
5
|
import '../common/direction.mjs';
|
|
6
6
|
import '../common/propsValues/control.mjs';
|
|
7
7
|
import '../common/propsValues/breakpoint.mjs';
|
|
8
|
-
import
|
|
8
|
+
import '../common/propsValues/size.mjs';
|
|
9
9
|
import { Typography } from '../common/propsValues/typography.mjs';
|
|
10
10
|
import '../common/propsValues/width.mjs';
|
|
11
11
|
import '../common/propsValues/type.mjs';
|
|
@@ -99,8 +99,14 @@ function Alert({
|
|
|
99
99
|
}, WDS_LIVE_REGION_DELAY_MS);
|
|
100
100
|
}, []);
|
|
101
101
|
const closeButtonReference = useRef(null);
|
|
102
|
+
const showButtonBelow = () => {
|
|
103
|
+
if (variant === 'desktop' && resolvedType === 'critical') {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
102
108
|
return /*#__PURE__*/jsx("div", {
|
|
103
|
-
role: resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status',
|
|
109
|
+
role: resolvedType === Sentiment.NEGATIVE || resolvedType === Sentiment.CRITICAL ? 'alert' : 'status',
|
|
104
110
|
className: "wds-alert__liveRegion",
|
|
105
111
|
children: /*#__PURE__*/jsxs("div", {
|
|
106
112
|
"aria-hidden": shouldAnnounce ? undefined : 'true',
|
|
@@ -120,17 +126,17 @@ function Alert({
|
|
|
120
126
|
setShouldFire(false);
|
|
121
127
|
},
|
|
122
128
|
onTouchMove: () => setShouldFire(false),
|
|
123
|
-
children: [/*#__PURE__*/
|
|
124
|
-
className:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
className: "alert__icon",
|
|
128
|
-
children: icon
|
|
129
|
-
}) : /*#__PURE__*/jsx(StatusIcon, {
|
|
130
|
-
size: Size.LARGE,
|
|
129
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
130
|
+
className: "alert__icon",
|
|
131
|
+
children: icon || /*#__PURE__*/jsx(StatusIcon, {
|
|
132
|
+
size: 48,
|
|
131
133
|
sentiment: resolvedType,
|
|
132
134
|
iconLabel: statusIconLabel
|
|
133
|
-
})
|
|
135
|
+
})
|
|
136
|
+
}), /*#__PURE__*/jsx("div", {
|
|
137
|
+
className: clsx('alert__content', 'd-flex', 'flex-grow-1', variant),
|
|
138
|
+
"data-testid": variant,
|
|
139
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
134
140
|
className: "alert__message",
|
|
135
141
|
children: [/*#__PURE__*/jsxs("div", {
|
|
136
142
|
children: [title && /*#__PURE__*/jsx(Title, {
|
|
@@ -145,12 +151,18 @@ function Alert({
|
|
|
145
151
|
children: message
|
|
146
152
|
})
|
|
147
153
|
})]
|
|
148
|
-
}), action && /*#__PURE__*/jsx(Action, {
|
|
154
|
+
}), action && showButtonBelow() && /*#__PURE__*/jsx(Action, {
|
|
149
155
|
action: action,
|
|
150
156
|
variant: "action-button",
|
|
151
|
-
className: "m-t-
|
|
157
|
+
className: "m-t-2"
|
|
152
158
|
})]
|
|
153
|
-
})
|
|
159
|
+
})
|
|
160
|
+
}), action && !showButtonBelow() && /*#__PURE__*/jsx("div", {
|
|
161
|
+
className: "action__desktop",
|
|
162
|
+
children: /*#__PURE__*/jsx(Action, {
|
|
163
|
+
action: action,
|
|
164
|
+
variant: "action-button"
|
|
165
|
+
})
|
|
154
166
|
}), onDismiss && /*#__PURE__*/jsx(CloseButton, {
|
|
155
167
|
ref: closeButtonReference,
|
|
156
168
|
className: "m-l-2",
|
|
@@ -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 {\n CloseButton,\n Sentiment,\n Size,\n Typography,\n Variant,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\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 /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\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 action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n variant = 'desktop',\n arrow,\n children,\n size,\n dismissible,\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<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n return (\n <div\n role={resolvedType === Sentiment.NEGATIVE ? 'alert' : 'status'}\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\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} iconLabel={statusIconLabel} />\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} variant=\"action-button\" className=\"m-t-1\" />}\n </div>\n </div>\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\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","action","className","icon","statusIconLabel","onDismiss","message","title","variant","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","setTimeout","WDS_LIVE_REGION_DELAY_MS","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","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Action","CloseButton","ref","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqCYA,mBAOX;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,kBAAkB,KAAlBA,kBAAkB,GAO7B,EAAA,CAAA,CAAA,CAAA;AAgCD,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,CAAC;EAC5BC,MAAM;EACNC,SAAS;EACTC,IAAI;EACJC,eAAe;EACfC,SAAS;EACTC,OAAO;EACPC,KAAK;AACLR,EAAAA,IAA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AAEJ,OAAAA;eAAwB,CAAA;AAAC,aACnD,CACR,CAAA;AAAA,WAAK,CACL,EAACL,MAAM,iBAAIyB,GAAA,CAACiC,MAAM,EAAA;AAAC1D,YAAAA,MAAM,EAAEA,MAAO;AAACO,YAAAA,OAAO,EAAC,eAAe;AAACN,YAAAA,SAAS,EAAC,OAAA;AAAO,YAAG,CAAA;AAAA,SAC5E,CACP,CAAA;AAAA,OAAK,CACL,EAACG,SAAS,iBACRqB,GAAA,CAACkC,WAAW,EAAA;AAACC,QAAAA,GAAG,EAAErC,oBAAqB;AAACtB,QAAAA,SAAS,EAAC,OAAO;AAAC4D,QAAAA,OAAO,EAAEzD,SAAAA;AAAU,OAAG,CACjF,CAAA;KACE,CAAA;AACP,GAAK,CAAC,CAAA;AAEV,CAAA;AAEA,SAAS2B,oBAAoBA,CAACvB,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.mjs","sources":["../../src/alert/Alert.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useState, useRef, useEffect } from 'react';\n\nimport Body from '../body/Body';\nimport {\n CloseButton,\n Sentiment,\n Size,\n Typography,\n Variant,\n WDS_LIVE_REGION_DELAY_MS,\n} from '../common';\n\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\n | Sentiment.CRITICAL}`;\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 /**\n * Override for [StatusIcon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n statusIconLabel?: string;\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 /** @deprecated They both look behave the same. */\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 action,\n className,\n icon,\n statusIconLabel,\n onDismiss,\n message,\n title,\n type = 'neutral',\n variant = 'desktop',\n arrow,\n children,\n size,\n dismissible,\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<boolean>();\n\n const [shouldAnnounce, setShouldAnnounce] = useState<boolean>(false);\n useEffect(() => {\n setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n const showButtonBelow = () => {\n if (variant === 'desktop' && resolvedType === 'critical') {\n return false;\n }\n return true;\n };\n\n return (\n <div\n role={\n resolvedType === Sentiment.NEGATIVE || resolvedType === Sentiment.CRITICAL\n ? 'alert'\n : 'status'\n }\n className=\"wds-alert__liveRegion\"\n >\n <div\n aria-hidden={shouldAnnounce ? undefined : 'true'}\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 className=\"alert__icon\">\n {icon || <StatusIcon size={48} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div\n className={clsx('alert__content', 'd-flex', 'flex-grow-1', variant)}\n data-testid={variant}\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 && showButtonBelow() && (\n <Action action={action} variant=\"action-button\" className=\"m-t-2\" />\n )}\n </div>\n </div>\n {action && !showButtonBelow() && (\n <div className=\"action__desktop\">\n <Action action={action} variant=\"action-button\" />\n </div>\n )}\n {onDismiss && (\n <CloseButton ref={closeButtonReference} className=\"m-l-2\" onClick={onDismiss} />\n )}\n </div>\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","action","className","icon","statusIconLabel","onDismiss","message","title","variant","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","setTimeout","WDS_LIVE_REGION_DELAY_MS","closeButtonReference","useRef","showButtonBelow","_jsx","role","Sentiment","NEGATIVE","CRITICAL","_jsxs","clsx","alertArrowClassNames","onTouchStart","onTouchEnd","event","href","target","Node","current","contains","window","top","open","location","assign","onTouchMove","StatusIcon","sentiment","iconLabel","Title","Typography","TITLE_BODY","Body","as","BODY_LARGE","InlineMarkdown","Action","CloseButton","ref","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsCYA,mBAOX;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,kBAAkB,KAAlBA,kBAAkB,GAO7B,EAAA,CAAA,CAAA,CAAA;AAiCD,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,CAAC;EAC5BC,MAAM;EACNC,SAAS;EACTC,IAAI;EACJC,eAAe;EACfC,SAAS;EACTC,OAAO;EACPC,KAAK;AACLR,EAAAA,IAAI,GAAG,SAAS;AAChBS,EAAAA,OAAO,GAAG,SAA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,OAAO,mBAAmB,CAAA;AAC5B,IAAA,KAAK,SAAS,CAAA;AACd,IAAA;AACE,MAAA,OAAO,OAAO,CAAA;AAClB,GAAA;AACF;;;;"}
|
|
@@ -10,7 +10,8 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
10
10
|
function Action({
|
|
11
11
|
action,
|
|
12
12
|
className,
|
|
13
|
-
variant = 'button'
|
|
13
|
+
variant = 'button',
|
|
14
|
+
priority = control.Priority.SECONDARY
|
|
14
15
|
}) {
|
|
15
16
|
if ('href' in action) {
|
|
16
17
|
return /*#__PURE__*/jsxRuntime.jsx(Link, {
|
|
@@ -31,7 +32,7 @@ function Action({
|
|
|
31
32
|
children: action.text
|
|
32
33
|
}) : /*#__PURE__*/jsxRuntime.jsx(ActionButton, {
|
|
33
34
|
"aria-label": action['aria-label'],
|
|
34
|
-
priority:
|
|
35
|
+
priority: priority,
|
|
35
36
|
className: clsx.clsx(className),
|
|
36
37
|
onClick: action.onClick,
|
|
37
38
|
children: action.text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.js","sources":["../../../src/common/action/Action.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport Link from '../../link';\nimport { Typography } from '../propsValues/typography';\nimport ActionButton from '../../actionButton';\nimport { Priority } from '../propsValues/control';\n\nexport type ActionOptions = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\ntype Props = {\n variant?: 'button' | 'action-button';\n action: ActionOptions;\n className?: string;\n};\n\nexport function Action({
|
|
1
|
+
{"version":3,"file":"Action.js","sources":["../../../src/common/action/Action.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport Link from '../../link';\nimport { Typography } from '../propsValues/typography';\nimport ActionButton from '../../actionButton';\nimport { Priority } from '../propsValues/control';\n\nexport type ActionOptions = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\ntype Props = {\n variant?: 'button' | 'action-button';\n action: ActionOptions;\n className?: string;\n priority?: Priority;\n};\n\nexport function Action({\n action,\n className,\n variant = 'button',\n priority = Priority.SECONDARY,\n}: Props) {\n if ('href' in action) {\n return (\n <Link\n href={action.href}\n className={className}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n );\n }\n\n return variant === 'button' ? (\n <button\n type=\"button\"\n aria-label={action['aria-label']}\n className={clsx('btn-unstyled np-text-link-large', className)}\n onClick={action.onClick}\n >\n {action.text}\n </button>\n ) : (\n <ActionButton\n aria-label={action['aria-label']}\n priority={priority}\n className={clsx(className)}\n onClick={action.onClick}\n >\n {action.text}\n </ActionButton>\n );\n}\n"],"names":["Action","action","className","variant","priority","Priority","SECONDARY","_jsx","Link","href","target","type","Typography","LINK_LARGE","onClick","children","text","clsx","ActionButton"],"mappings":";;;;;;;;;SAqBgBA,MAAMA,CAAC;EACrBC,MAAM;EACNC,SAAS;AACTC,EAAAA,OAAO,GAAG,QAAQ;EAClBC,QAAQ,GAAGC,gBAAQ,CAACC,SAAAA;AACd,CAAA,EAAA;EACN,IAAI,MAAM,IAAIL,MAAM,EAAE;IACpB,oBACEM,cAAA,CAACC,IAAI,EAAA;MACHC,IAAI,EAAER,MAAM,CAACQ,IAAK;AAClBP,MAAAA,SAAS,EAAEA,SAAU;MACrB,YAAYD,EAAAA,MAAM,CAAC,YAAY,CAAE;MACjCS,MAAM,EAAET,MAAM,CAACS,MAAO;MACtBC,IAAI,EAAEC,qBAAU,CAACC,UAAW;MAC5BC,OAAO,EAAEb,MAAM,CAACa,OAAQ;MAAAC,QAAA,EAEvBd,MAAM,CAACe,IAAAA;AAAI,KACR,CAAC,CAAA;AAEX,GAAA;AAEA,EAAA,OAAOb,OAAO,KAAK,QAAQ,gBACzBI,cAAA,CAAA,QAAA,EAAA;AACEI,IAAAA,IAAI,EAAC,QAAQ;IACb,YAAYV,EAAAA,MAAM,CAAC,YAAY,CAAE;AACjCC,IAAAA,SAAS,EAAEe,SAAI,CAAC,iCAAiC,EAAEf,SAAS,CAAE;IAC9DY,OAAO,EAAEb,MAAM,CAACa,OAAQ;IAAAC,QAAA,EAEvBd,MAAM,CAACe,IAAAA;AAAI,GACN,CAAC,gBAETT,cAAA,CAACW,YAAY,EAAA;IACX,YAAYjB,EAAAA,MAAM,CAAC,YAAY,CAAE;AACjCG,IAAAA,QAAQ,EAAEA,QAAS;AACnBF,IAAAA,SAAS,EAAEe,SAAI,CAACf,SAAS,CAAE;IAC3BY,OAAO,EAAEb,MAAM,CAACa,OAAQ;IAAAC,QAAA,EAEvBd,MAAM,CAACe,IAAAA;AAAI,GACA,CACf,CAAA;AACH;;;;"}
|
|
@@ -8,7 +8,8 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
8
8
|
function Action({
|
|
9
9
|
action,
|
|
10
10
|
className,
|
|
11
|
-
variant = 'button'
|
|
11
|
+
variant = 'button',
|
|
12
|
+
priority = Priority.SECONDARY
|
|
12
13
|
}) {
|
|
13
14
|
if ('href' in action) {
|
|
14
15
|
return /*#__PURE__*/jsx(Link, {
|
|
@@ -29,7 +30,7 @@ function Action({
|
|
|
29
30
|
children: action.text
|
|
30
31
|
}) : /*#__PURE__*/jsx(ActionButton, {
|
|
31
32
|
"aria-label": action['aria-label'],
|
|
32
|
-
priority:
|
|
33
|
+
priority: priority,
|
|
33
34
|
className: clsx(className),
|
|
34
35
|
onClick: action.onClick,
|
|
35
36
|
children: action.text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.mjs","sources":["../../../src/common/action/Action.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport Link from '../../link';\nimport { Typography } from '../propsValues/typography';\nimport ActionButton from '../../actionButton';\nimport { Priority } from '../propsValues/control';\n\nexport type ActionOptions = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\ntype Props = {\n variant?: 'button' | 'action-button';\n action: ActionOptions;\n className?: string;\n};\n\nexport function Action({
|
|
1
|
+
{"version":3,"file":"Action.mjs","sources":["../../../src/common/action/Action.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport Link from '../../link';\nimport { Typography } from '../propsValues/typography';\nimport ActionButton from '../../actionButton';\nimport { Priority } from '../propsValues/control';\n\nexport type ActionOptions = {\n 'aria-label'?: string;\n href?: string;\n target?: string;\n text: React.ReactNode;\n onClick?: () => void;\n};\n\ntype Props = {\n variant?: 'button' | 'action-button';\n action: ActionOptions;\n className?: string;\n priority?: Priority;\n};\n\nexport function Action({\n action,\n className,\n variant = 'button',\n priority = Priority.SECONDARY,\n}: Props) {\n if ('href' in action) {\n return (\n <Link\n href={action.href}\n className={className}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n );\n }\n\n return variant === 'button' ? (\n <button\n type=\"button\"\n aria-label={action['aria-label']}\n className={clsx('btn-unstyled np-text-link-large', className)}\n onClick={action.onClick}\n >\n {action.text}\n </button>\n ) : (\n <ActionButton\n aria-label={action['aria-label']}\n priority={priority}\n className={clsx(className)}\n onClick={action.onClick}\n >\n {action.text}\n </ActionButton>\n );\n}\n"],"names":["Action","action","className","variant","priority","Priority","SECONDARY","_jsx","Link","href","target","type","Typography","LINK_LARGE","onClick","children","text","clsx","ActionButton"],"mappings":";;;;;;;SAqBgBA,MAAMA,CAAC;EACrBC,MAAM;EACNC,SAAS;AACTC,EAAAA,OAAO,GAAG,QAAQ;EAClBC,QAAQ,GAAGC,QAAQ,CAACC,SAAAA;AACd,CAAA,EAAA;EACN,IAAI,MAAM,IAAIL,MAAM,EAAE;IACpB,oBACEM,GAAA,CAACC,IAAI,EAAA;MACHC,IAAI,EAAER,MAAM,CAACQ,IAAK;AAClBP,MAAAA,SAAS,EAAEA,SAAU;MACrB,YAAYD,EAAAA,MAAM,CAAC,YAAY,CAAE;MACjCS,MAAM,EAAET,MAAM,CAACS,MAAO;MACtBC,IAAI,EAAEC,UAAU,CAACC,UAAW;MAC5BC,OAAO,EAAEb,MAAM,CAACa,OAAQ;MAAAC,QAAA,EAEvBd,MAAM,CAACe,IAAAA;AAAI,KACR,CAAC,CAAA;AAEX,GAAA;AAEA,EAAA,OAAOb,OAAO,KAAK,QAAQ,gBACzBI,GAAA,CAAA,QAAA,EAAA;AACEI,IAAAA,IAAI,EAAC,QAAQ;IACb,YAAYV,EAAAA,MAAM,CAAC,YAAY,CAAE;AACjCC,IAAAA,SAAS,EAAEe,IAAI,CAAC,iCAAiC,EAAEf,SAAS,CAAE;IAC9DY,OAAO,EAAEb,MAAM,CAACa,OAAQ;IAAAC,QAAA,EAEvBd,MAAM,CAACe,IAAAA;AAAI,GACN,CAAC,gBAETT,GAAA,CAACW,YAAY,EAAA;IACX,YAAYjB,EAAAA,MAAM,CAAC,YAAY,CAAE;AACjCG,IAAAA,QAAQ,EAAEA,QAAS;AACnBF,IAAAA,SAAS,EAAEe,IAAI,CAACf,SAAS,CAAE;IAC3BY,OAAO,EAAEb,MAAM,CAACa,OAAQ;IAAAC,QAAA,EAEvBd,MAAM,CAACe,IAAAA;AAAI,GACA,CACf,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentiment.js","sources":["../../../src/common/propsValues/sentiment.ts"],"sourcesContent":["export enum Sentiment {\n NEGATIVE = 'negative',\n NEUTRAL = 'neutral',\n POSITIVE = 'positive',\n WARNING = 'warning',\n PENDING = 'pending',\n\n /**\n * @deprecated\n */\n INFO = 'info',\n /**\n * @deprecated\n */\n ERROR = 'error',\n /**\n * @deprecated\n */\n SUCCESS = 'success',\n}\n"],"names":["Sentiment"],"mappings":";;AAAYA,
|
|
1
|
+
{"version":3,"file":"sentiment.js","sources":["../../../src/common/propsValues/sentiment.ts"],"sourcesContent":["export enum Sentiment {\n NEGATIVE = 'negative',\n NEUTRAL = 'neutral',\n POSITIVE = 'positive',\n WARNING = 'warning',\n PENDING = 'pending',\n CRITICAL = 'critical',\n\n /**\n * @deprecated\n */\n INFO = 'info',\n /**\n * @deprecated\n */\n ERROR = 'error',\n /**\n * @deprecated\n */\n SUCCESS = 'success',\n}\n"],"names":["Sentiment"],"mappings":";;AAAYA,2BAoBX;AApBD,CAAA,UAAYA,SAAS,EAAA;AACnBA,EAAAA,SAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrBA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnBA,EAAAA,SAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrBA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnBA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnBA,EAAAA,SAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AAErB;;AAEG;AACHA,EAAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb;;AAEG;AACHA,EAAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf;;AAEG;AACHA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACrB,CAAC,EApBWA,iBAAS,KAATA,iBAAS,GAoBpB,EAAA,CAAA,CAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentiment.mjs","sources":["../../../src/common/propsValues/sentiment.ts"],"sourcesContent":["export enum Sentiment {\n NEGATIVE = 'negative',\n NEUTRAL = 'neutral',\n POSITIVE = 'positive',\n WARNING = 'warning',\n PENDING = 'pending',\n\n /**\n * @deprecated\n */\n INFO = 'info',\n /**\n * @deprecated\n */\n ERROR = 'error',\n /**\n * @deprecated\n */\n SUCCESS = 'success',\n}\n"],"names":["Sentiment"],"mappings":"IAAYA,
|
|
1
|
+
{"version":3,"file":"sentiment.mjs","sources":["../../../src/common/propsValues/sentiment.ts"],"sourcesContent":["export enum Sentiment {\n NEGATIVE = 'negative',\n NEUTRAL = 'neutral',\n POSITIVE = 'positive',\n WARNING = 'warning',\n PENDING = 'pending',\n CRITICAL = 'critical',\n\n /**\n * @deprecated\n */\n INFO = 'info',\n /**\n * @deprecated\n */\n ERROR = 'error',\n /**\n * @deprecated\n */\n SUCCESS = 'success',\n}\n"],"names":["Sentiment"],"mappings":"IAAYA,UAoBX;AApBD,CAAA,UAAYA,SAAS,EAAA;AACnBA,EAAAA,SAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrBA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnBA,EAAAA,SAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrBA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnBA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnBA,EAAAA,SAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AAErB;;AAEG;AACHA,EAAAA,SAAA,CAAA,MAAA,CAAA,GAAA,MAAa,CAAA;AACb;;AAEG;AACHA,EAAAA,SAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf;;AAEG;AACHA,EAAAA,SAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACrB,CAAC,EApBWA,SAAS,KAATA,SAAS,GAoBpB,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,89 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var componentsTheming = require('@wise/components-theming');
|
|
3
|
+
var Alert = require('../alert/Alert.js');
|
|
5
4
|
var clsx = require('clsx');
|
|
6
|
-
var avatarTypes = require('../avatar/avatarTypes.js');
|
|
7
|
-
var Avatar = require('../avatar/Avatar.js');
|
|
8
|
-
var Body = require('../body/Body.js');
|
|
9
|
-
var Button_resolver = require('../button/Button.resolver.js');
|
|
10
|
-
require('../common/theme.js');
|
|
11
|
-
require('../common/direction.js');
|
|
12
|
-
var control = require('../common/propsValues/control.js');
|
|
13
|
-
require('../common/propsValues/breakpoint.js');
|
|
14
|
-
var size = require('../common/propsValues/size.js');
|
|
15
|
-
var typography = require('../common/propsValues/typography.js');
|
|
16
|
-
require('../common/propsValues/width.js');
|
|
17
|
-
require('../common/propsValues/type.js');
|
|
18
|
-
require('../common/propsValues/dateMode.js');
|
|
19
|
-
require('../common/propsValues/monthFormat.js');
|
|
20
|
-
require('../common/propsValues/position.js');
|
|
21
|
-
require('../common/propsValues/layouts.js');
|
|
22
|
-
require('../common/propsValues/status.js');
|
|
23
|
-
require('../common/propsValues/sentiment.js');
|
|
24
|
-
require('../common/propsValues/profileType.js');
|
|
25
|
-
require('../common/propsValues/variant.js');
|
|
26
|
-
require('../common/propsValues/scroll.js');
|
|
27
|
-
require('../common/propsValues/markdownNodeType.js');
|
|
28
|
-
require('../common/fileType.js');
|
|
29
|
-
require('react');
|
|
30
|
-
require('react-intl');
|
|
31
|
-
require('../common/closeButton/CloseButton.messages.js');
|
|
32
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
33
|
-
var Title = require('../title/Title.js');
|
|
34
6
|
|
|
35
7
|
function CriticalCommsBanner({
|
|
36
8
|
title,
|
|
37
9
|
subtitle,
|
|
38
10
|
action,
|
|
39
|
-
className
|
|
11
|
+
className,
|
|
12
|
+
variant
|
|
40
13
|
}) {
|
|
41
|
-
const {
|
|
42
|
-
isModern
|
|
43
|
-
} = componentsTheming.useTheme();
|
|
44
14
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
45
15
|
className: clsx.clsx('critical-comms', className),
|
|
46
|
-
children: /*#__PURE__*/jsxRuntime.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
57
|
-
className: "critical-comms-content d-flex align-items-center flex-grow-1",
|
|
58
|
-
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
59
|
-
className: clsx.clsx('flex-grow-1', {
|
|
60
|
-
'p-x-2': !isModern
|
|
61
|
-
}),
|
|
62
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Title, {
|
|
63
|
-
type: isModern ? typography.Typography.TITLE_BODY : typography.Typography.TITLE_GROUP,
|
|
64
|
-
className: "critical-comms--title",
|
|
65
|
-
children: title
|
|
66
|
-
}), /*#__PURE__*/jsxRuntime.jsx(Body, {
|
|
67
|
-
className: "critical-comms--subtitle",
|
|
68
|
-
children: subtitle
|
|
69
|
-
})]
|
|
70
|
-
}), action ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
71
|
-
className: "critical-comms--cta",
|
|
72
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Button_resolver, {
|
|
73
|
-
block: isModern,
|
|
74
|
-
size: size.Size.SMALL,
|
|
75
|
-
type: control.ControlType.NEGATIVE,
|
|
76
|
-
priority: isModern ? control.Priority.SECONDARY : control.Priority.PRIMARY,
|
|
77
|
-
className: "cta-btn",
|
|
78
|
-
onClick: () => {
|
|
79
|
-
if (action) {
|
|
80
|
-
window.location.href = action.href;
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
children: action.label
|
|
84
|
-
})
|
|
85
|
-
}) : null]
|
|
86
|
-
})]
|
|
16
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Alert.default, {
|
|
17
|
+
title: title,
|
|
18
|
+
message: subtitle,
|
|
19
|
+
action: {
|
|
20
|
+
target: action?.href,
|
|
21
|
+
text: action?.label
|
|
22
|
+
},
|
|
23
|
+
className: className,
|
|
24
|
+
type: "critical",
|
|
25
|
+
variant: variant
|
|
87
26
|
})
|
|
88
27
|
});
|
|
89
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CriticalCommsBanner.js","sources":["../../src/criticalBanner/CriticalCommsBanner.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"CriticalCommsBanner.js","sources":["../../src/criticalBanner/CriticalCommsBanner.tsx"],"sourcesContent":["import Alert from '../alert';\nimport { clsx } from 'clsx';\nimport { Variant } from '../common';\n\nexport type CriticalCommsBannerProps = {\n title: string;\n subtitle?: string;\n action?: {\n label: string;\n href: string;\n };\n className?: string;\n variant?: Variant;\n};\n\nfunction CriticalCommsBanner({\n title,\n subtitle,\n action,\n className,\n variant,\n}: CriticalCommsBannerProps) {\n return (\n <div className={clsx('critical-comms', className)}>\n <Alert\n title={title}\n message={subtitle}\n action={{ target: action?.href, text: action?.label }}\n className={className}\n type=\"critical\"\n variant={variant}\n />\n </div>\n );\n}\n\nexport default CriticalCommsBanner;\n"],"names":["CriticalCommsBanner","title","subtitle","action","className","variant","_jsx","clsx","children","Alert","message","target","href","text","label","type"],"mappings":";;;;;;AAeA,SAASA,mBAAmBA,CAAC;EAC3BC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC,SAAS;AACTC,EAAAA,OAAAA;AACyB,CAAA,EAAA;AACzB,EAAA,oBACEC,cAAA,CAAA,KAAA,EAAA;AAAKF,IAAAA,SAAS,EAAEG,SAAI,CAAC,gBAAgB,EAAEH,SAAS,CAAE;IAAAI,QAAA,eAChDF,cAAA,CAACG,aAAK,EAAA;AACJR,MAAAA,KAAK,EAAEA,KAAM;AACbS,MAAAA,OAAO,EAAER,QAAS;AAClBC,MAAAA,MAAM,EAAE;QAAEQ,MAAM,EAAER,MAAM,EAAES,IAAI;QAAEC,IAAI,EAAEV,MAAM,EAAEW,KAAAA;OAAQ;AACtDV,MAAAA,SAAS,EAAEA,SAAU;AACrBW,MAAAA,IAAI,EAAC,UAAU;AACfV,MAAAA,OAAO,EAAEA,OAAAA;KAEb,CAAA;AAAA,GAAK,CAAC,CAAA;AAEV;;;;"}
|