@transferwise/components 46.116.0 → 46.117.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/alert/Alert.js +2 -1
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +2 -1
- package/build/alert/Alert.mjs.map +1 -1
- package/build/main.css +60 -139
- package/build/prompt/InlinePrompt/InlinePrompt.js +14 -8
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +15 -9
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/sentimentSurface/SentimentSurface.js +6 -5
- package/build/sentimentSurface/SentimentSurface.js.map +1 -1
- package/build/sentimentSurface/SentimentSurface.mjs +6 -5
- package/build/sentimentSurface/SentimentSurface.mjs.map +1 -1
- package/build/styles/button/Button.css +17 -17
- package/build/styles/button/Button.vars.css +16 -16
- package/build/styles/iconButton/IconButton.css +8 -8
- package/build/styles/inputs/Input.css +2 -4
- package/build/styles/inputs/TextArea.css +2 -4
- package/build/styles/link/Link.css +1 -0
- package/build/styles/main.css +60 -139
- package/build/styles/popover/Popover.css +2 -4
- package/build/styles/prompt/InlinePrompt/InlinePrompt.css +26 -105
- package/build/styles/sentimentSurface/SentimentSurface.css +4 -1
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts +19 -3
- package/build/types/prompt/InlinePrompt/InlinePrompt.d.ts.map +1 -1
- package/build/types/sentimentSurface/SentimentSurface.d.ts +5 -4
- package/build/types/sentimentSurface/SentimentSurface.d.ts.map +1 -1
- package/build/types/sentimentSurface/SentimentSurface.types.d.ts +4 -16
- package/build/types/sentimentSurface/SentimentSurface.types.d.ts.map +1 -1
- package/build/types/test-utils/story-config.d.ts +24 -0
- package/build/types/test-utils/story-config.d.ts.map +1 -1
- package/package.json +13 -12
- package/src/alert/Alert.tsx +3 -1
- package/src/button/Button.css +17 -17
- package/src/button/Button.less +1 -1
- package/src/button/Button.story.tsx +75 -110
- package/src/button/Button.tests.story.tsx +189 -0
- package/src/button/Button.vars.css +16 -16
- package/src/button/Button.vars.less +58 -18
- package/src/iconButton/IconButton.css +8 -8
- package/src/iconButton/IconButton.less +35 -4
- package/src/iconButton/IconButton.story.tsx +72 -3
- package/src/inputs/Input.css +2 -4
- package/src/inputs/TextArea.css +2 -4
- package/src/link/Link.css +1 -0
- package/src/link/Link.less +1 -0
- package/src/link/Link.story.tsx +28 -0
- package/src/main.css +60 -139
- package/src/popover/Popover.css +2 -4
- package/src/prompt/InlinePrompt/InlinePrompt.css +26 -105
- package/src/prompt/InlinePrompt/InlinePrompt.less +31 -119
- package/src/prompt/InlinePrompt/InlinePrompt.spec.tsx +87 -29
- package/src/prompt/InlinePrompt/InlinePrompt.story.tsx +223 -31
- package/src/prompt/InlinePrompt/InlinePrompt.tsx +42 -11
- package/src/sentimentSurface/SentimentSurface.css +4 -1
- package/src/sentimentSurface/SentimentSurface.docs.mdx +37 -478
- package/src/sentimentSurface/SentimentSurface.less +118 -114
- package/src/sentimentSurface/SentimentSurface.spec.tsx +31 -11
- package/src/sentimentSurface/SentimentSurface.story.tsx +325 -147
- package/src/sentimentSurface/SentimentSurface.tests.story.tsx +85 -86
- package/src/sentimentSurface/SentimentSurface.tsx +16 -9
- package/src/sentimentSurface/SentimentSurface.types.ts +5 -20
- package/src/test-utils/story-config.ts +0 -1
- package/build/sentimentSurface/classMap.js +0 -17
- package/build/sentimentSurface/classMap.js.map +0 -1
- package/build/sentimentSurface/classMap.mjs +0 -14
- package/build/sentimentSurface/classMap.mjs.map +0 -1
- package/build/types/sentimentSurface/classMap.d.ts +0 -4
- package/build/types/sentimentSurface/classMap.d.ts.map +0 -1
- package/src/sentimentSurface/classMap.ts +0 -15
package/build/alert/Alert.js
CHANGED
|
@@ -98,9 +98,10 @@ function Alert({
|
|
|
98
98
|
const [shouldFire, setShouldFire] = React.useState();
|
|
99
99
|
const [shouldAnnounce, setShouldAnnounce] = React.useState(false);
|
|
100
100
|
React.useEffect(() => {
|
|
101
|
-
setTimeout(() => {
|
|
101
|
+
const timeoutId = setTimeout(() => {
|
|
102
102
|
setShouldAnnounce(true);
|
|
103
103
|
}, constants.WDS_LIVE_REGION_DELAY_MS);
|
|
104
|
+
return () => clearTimeout(timeoutId);
|
|
104
105
|
}, []);
|
|
105
106
|
const closeButtonReference = React.useRef(null);
|
|
106
107
|
/**
|
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 Status,\n Typography,\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 Button from '../button';\nimport Link from '../link';\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 // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\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 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 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 /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\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 className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\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 &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\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","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","setTimeout","WDS_LIVE_REGION_DELAY_MS","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_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","Link","LINK_LARGE","tabIndex","onClick","text","Button","v2","priority","CloseButton","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCYA;AAAZ,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA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B,YAAA,EAAY/C,MAAM,CAAC,YAAY,CAAE;AACjC+D,YAAAA,QAAQ,EAAC,mBAAmB;AAC5B9D,YAAAA,SAAS,EAAC,eAAe;AACzByD,YAAAA,QAAQ,EAAElC,kBAAmB;YAC7BmC,OAAO,EAAE3D,MAAM,CAAC2D,OAAQ;YAAAnD,QAAA,EAEvBR,MAAM,CAAC4D;AAAI,WACN,CACT,CAAC;SACD;AACP,OAAK,CACL,EAACxD,SAAS,iBACRqB,cAAA,CAAA,KAAA,EAAA;AAAKxB,QAAAA,SAAS,EAAC,cAAc;QAAAO,QAAA,eAC3BiB,cAAA,CAACuC,uBAAW,EAAA;AACVC,UAAAA,GAAG,EAAE3C,oBAAqB;AAC1Bb,UAAAA,IAAI,EAAC,IAAI;AACTiD,UAAAA,QAAQ,EAAElC,kBAAmB;AAC7BmC,UAAAA,OAAO,EAAEvD;SAAU;AAEvB,OAAK,CACN;KACE;AACP,GAAK,CAAC;AAEV;AAEA,SAAS2B,oBAAoBA,CAACxB,KAA8B,EAAA;AAC1D,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB;AAC5B,IAAA,KAAK,SAAS;AACd,IAAA;AACE,MAAA,OAAO,OAAO;AAClB;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 Status,\n Typography,\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 Button from '../button';\nimport Link from '../link';\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 // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\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 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 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 const timeoutId = setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n\n return () => clearTimeout(timeoutId);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\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 className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\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 &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\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","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","timeoutId","setTimeout","WDS_LIVE_REGION_DELAY_MS","clearTimeout","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_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","Link","LINK_LARGE","tabIndex","onClick","text","Button","v2","priority","CloseButton","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCYA;AAAZ,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,SAAoB;AACpBA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,WAAiB;AACjBA,EAAAA,kBAAA,CAAA,WAAA,CAAA,GAAA,UAAsB;AACtBA,EAAAA,kBAAA,CAAA,aAAA,CAAA,GAAA,WAAyB;AACzBA,EAAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,aAAsB;AACtBA,EAAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,YAA2B;AAC7B,CAAC,EAPWA,0BAAkB,KAAlBA,0BAAkB,GAAA,EAAA,CAAA,CAAA;AAsC9B,SAASC,WAAWA,CAACC,IAAe,EAAA;AAClC,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,SAAS;AACZ,MAAA,OAAO,UAAU;AACnB,IAAA,KAAK,MAAM;AACT,MAAA,O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AC,IAAI;AACTmD,UAAAA,QAAQ,EAAElC,kBAAmB;AAC7BmC,UAAAA,OAAO,EAAEzD;SAAU;AAEvB,OAAK,CACN;KACE;AACP,GAAK,CAAC;AAEV;AAEA,SAAS6B,oBAAoBA,CAAC1B,KAA8B,EAAA;AAC1D,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB;AAC5B,IAAA,KAAK,SAAS;AACd,IAAA;AACE,MAAA,OAAO,OAAO;AAClB;AACF;;;;"}
|
package/build/alert/Alert.mjs
CHANGED
|
@@ -94,9 +94,10 @@ function Alert({
|
|
|
94
94
|
const [shouldFire, setShouldFire] = useState();
|
|
95
95
|
const [shouldAnnounce, setShouldAnnounce] = useState(false);
|
|
96
96
|
useEffect(() => {
|
|
97
|
-
setTimeout(() => {
|
|
97
|
+
const timeoutId = setTimeout(() => {
|
|
98
98
|
setShouldAnnounce(true);
|
|
99
99
|
}, WDS_LIVE_REGION_DELAY_MS);
|
|
100
|
+
return () => clearTimeout(timeoutId);
|
|
100
101
|
}, []);
|
|
101
102
|
const closeButtonReference = useRef(null);
|
|
102
103
|
/**
|
|
@@ -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 Status,\n Typography,\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 Button from '../button';\nimport Link from '../link';\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 // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\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 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 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 /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\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 className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\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 &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\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","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","setTimeout","WDS_LIVE_REGION_DELAY_MS","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_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","Link","LINK_LARGE","tabIndex","onClick","text","Button","v2","priority","CloseButton","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAyCYA;AAAZ,CAAA,UAAYA,kBAAkB,EAAA;AAC5BA,EAAAA,kBAAA,CAAA,UAAA,CAAA,GAAA,SAAoB;AACpBA,EAAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,WAAiB;AACjBA,EAAAA,kBAAA,CAAA,WAAA,CAAA,GAAA,UAAsB;AACtBA,EAAAA,kBAAA,CAAA,aAAA,CAAA,GAAA,WAAyB;AACzBA,EAAAA,kBAAA,CAAA,QAAA,CAAA,GAAA,aAAsB;AACtBA,EAAAA,kBAAA,CAAA,cAAA,CAAA,GAAA,YAA2B;AAC7B,CAAC,EAPWA,kBAAkB,KAAlBA,kBAAkB,GAAA,EAAA,CAAA,CAAA;AAsC9B,SAASC,WAAWA,CAACC,IAAe,EAAA;AAClC,EAAA,QAAQA,IAAI;AACV,IAAA,KAAK,SAAS;AACZ,MAAA,OAAO,UAAU;AACnB,IAAA,KAAK,MAAM;AACT,MAAA,OAAO,SAAS;AAClB,IAAA,KAAK,OAAO;AACV,MAAA,OAAO,UAAU;AACnB,IAAA;AACE,MAAA,OAAOA,IAAI;AACf;AACF;AAE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,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB;AAC5B,IAAA,KAAK,SAAS;AACd,IAAA;AACE,MAAA,OAAO,OAAO;AAClB;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 Status,\n Typography,\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 Button from '../button';\nimport Link from '../link';\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 // remove when all instances of Sentiment.PENDING have been updated to Status.PENDING\n | Sentiment.PENDING\n | Status.PENDING}`;\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 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 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 const timeoutId = setTimeout(() => {\n setShouldAnnounce(true);\n }, WDS_LIVE_REGION_DELAY_MS);\n\n return () => clearTimeout(timeoutId);\n }, []);\n\n const closeButtonReference = useRef<HTMLButtonElement>(null);\n\n /**\n * All focusable elements must be disabled until we announce the alert.\n * @see https://dequeuniversity.com/rules/axe/4.10/aria-hidden-focus?application=axeAPI\n */\n const accessibleTabIndex = shouldAnnounce ? undefined : -1;\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 className=\"alert__icon\">\n {icon || <StatusIcon size={32} sentiment={resolvedType} iconLabel={statusIconLabel} />}\n </div>\n <div className={clsx('alert__content', 'd-flex', 'flex-grow-1')}>\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 &&\n ('href' in action ? (\n <Link\n href={action.href}\n aria-label={action['aria-label']}\n target={action.target}\n type={Typography.LINK_LARGE}\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Link>\n ) : (\n <Button\n v2\n size=\"sm\"\n sentiment=\"default\"\n aria-label={action['aria-label']}\n priority=\"secondary-neutral\"\n className=\"alert__action\"\n tabIndex={accessibleTabIndex}\n onClick={action.onClick}\n >\n {action.text}\n </Button>\n ))}\n </div>\n </div>\n {onDismiss && (\n <div className=\"alert__close\">\n <CloseButton\n ref={closeButtonReference}\n size=\"xs\"\n tabIndex={accessibleTabIndex}\n onClick={onDismiss}\n />\n </div>\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","arrow","children","size","dismissible","useEffect","undefined","logActionRequired","resolvedType","shouldFire","setShouldFire","useState","shouldAnnounce","setShouldAnnounce","timeoutId","setTimeout","WDS_LIVE_REGION_DELAY_MS","clearTimeout","closeButtonReference","useRef","accessibleTabIndex","_jsx","role","Sentiment","NEGATIVE","_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","Link","LINK_LARGE","tabIndex","onClick","text","Button","v2","priority","CloseButton","ref"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;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oC,MAAM,EAAA;YACLC,EAAE,EAAA,IAAA;AACFvD,YAAAA,IAAI,EAAC,IAAI;AACTwC,YAAAA,SAAS,EAAC,SAAS;YACnB,YAAA,EAAYjD,MAAM,CAAC,YAAY,CAAE;AACjCiE,YAAAA,QAAQ,EAAC,mBAAmB;AAC5BhE,YAAAA,SAAS,EAAC,eAAe;AACzB2D,YAAAA,QAAQ,EAAElC,kBAAmB;YAC7BmC,OAAO,EAAE7D,MAAM,CAAC6D,OAAQ;YAAArD,QAAA,EAEvBR,MAAM,CAAC8D;AAAI,WACN,CACT,CAAC;SACD;AACP,OAAK,CACL,EAAC1D,SAAS,iBACRuB,GAAA,CAAA,KAAA,EAAA;AAAK1B,QAAAA,SAAS,EAAC,cAAc;QAAAO,QAAA,eAC3BmB,GAAA,CAACuC,WAAW,EAAA;AACVC,UAAAA,GAAG,EAAE3C,oBAAqB;AAC1Bf,UAAAA,IAAI,EAAC,IAAI;AACTmD,UAAAA,QAAQ,EAAElC,kBAAmB;AAC7BmC,UAAAA,OAAO,EAAEzD;SAAU;AAEvB,OAAK,CACN;KACE;AACP,GAAK,CAAC;AAEV;AAEA,SAAS6B,oBAAoBA,CAAC1B,KAA8B,EAAA;AAC1D,EAAA,QAAQA,KAAK;AACX,IAAA,KAAK,aAAa;AAChB,MAAA,OAAO,iCAAiC;AAC1C,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,+BAA+B;AACxC,IAAA,KAAK,YAAY;AACf,MAAA,OAAO,gCAAgC;AACzC,IAAA,KAAK,WAAW;AACd,MAAA,OAAO,oBAAoB;AAC7B,IAAA,KAAK,UAAU;AACb,MAAA,OAAO,mBAAmB;AAC5B,IAAA,KAAK,SAAS;AACd,IAAA;AACE,MAAA,OAAO,OAAO;AAClB;AACF;;;;"}
|
package/build/main.css
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
.wds-sentiment-surface {
|
|
2
|
+
--ring-outline-color: var(--color-sentiment-content-primary, var(--color-content-primary));
|
|
3
|
+
}
|
|
4
|
+
.wds-sentiment-surface--hasBaseStyles {
|
|
2
5
|
background-color: var(--color-sentiment-background-surface);
|
|
3
6
|
color: var(--color-sentiment-content-primary);
|
|
4
7
|
}
|
|
@@ -36,7 +39,7 @@
|
|
|
36
39
|
--color-sentiment-interactive-secondary-active: #A72027;
|
|
37
40
|
--color-sentiment-interactive-secondary-neutral: #9B141B;
|
|
38
41
|
--color-sentiment-interactive-secondary-neutral-hover: #831116;
|
|
39
|
-
--color-sentiment-interactive-secondary-neutral-active: #
|
|
42
|
+
--color-sentiment-interactive-secondary-neutral-active: #6D0e13;
|
|
40
43
|
--color-sentiment-interactive-control: #CB272F;
|
|
41
44
|
--color-sentiment-interactive-control-hover: #B8232B;
|
|
42
45
|
--color-sentiment-interactive-control-active: #A72027;
|
|
@@ -878,18 +881,35 @@
|
|
|
878
881
|
position: relative;
|
|
879
882
|
z-index: 1;
|
|
880
883
|
}
|
|
884
|
+
.wds-inline-prompt:has(a):hover,
|
|
885
|
+
.wds-inline-prompt:has(button):hover {
|
|
886
|
+
background-color: var(--color-sentiment-background-surface-hover);
|
|
887
|
+
}
|
|
888
|
+
.wds-inline-prompt:has(a):active,
|
|
889
|
+
.wds-inline-prompt:has(button):active {
|
|
890
|
+
background-color: var(--color-sentiment-background-surface-active);
|
|
891
|
+
}
|
|
881
892
|
.wds-inline-prompt--muted {
|
|
882
893
|
opacity: 0.93;
|
|
883
894
|
filter: grayscale(1);
|
|
884
895
|
}
|
|
885
896
|
.wds-inline-prompt a,
|
|
886
897
|
.wds-inline-prompt button {
|
|
898
|
+
color: var(--color-sentiment-content-primary);
|
|
887
899
|
text-underline-offset: calc(4px / 2);
|
|
888
900
|
text-underline-offset: calc(var(--size-4) / 2);
|
|
889
901
|
}
|
|
902
|
+
.wds-inline-prompt a:hover,
|
|
903
|
+
.wds-inline-prompt button:hover {
|
|
904
|
+
color: var(--color-sentiment-content-primary-hover);
|
|
905
|
+
}
|
|
906
|
+
.wds-inline-prompt a:active,
|
|
907
|
+
.wds-inline-prompt button:active {
|
|
908
|
+
color: var(--color-sentiment-content-primary-active);
|
|
909
|
+
}
|
|
890
910
|
.wds-inline-prompt a:first-of-type:before,
|
|
891
911
|
.wds-inline-prompt button:first-of-type:before {
|
|
892
|
-
content:
|
|
912
|
+
content: "";
|
|
893
913
|
position: absolute;
|
|
894
914
|
inset: 0;
|
|
895
915
|
}
|
|
@@ -903,112 +923,16 @@
|
|
|
903
923
|
}
|
|
904
924
|
.wds-inline-prompt__media-wrapper .tw-icon-tags,
|
|
905
925
|
.wds-inline-prompt__media-wrapper .tw-icon-confetti {
|
|
906
|
-
color: var(--color-sentiment-
|
|
907
|
-
}
|
|
908
|
-
.wds-inline-prompt--negative {
|
|
909
|
-
background-color: var(--color-sentiment-negative-secondary);
|
|
910
|
-
color: var(--color-sentiment-negative-primary);
|
|
911
|
-
}
|
|
912
|
-
.wds-inline-prompt--negative a,
|
|
913
|
-
.wds-inline-prompt--negative button {
|
|
914
|
-
color: var(--color-sentiment-negative-primary);
|
|
915
|
-
}
|
|
916
|
-
.wds-inline-prompt--negative a:hover,
|
|
917
|
-
.wds-inline-prompt--negative button:hover {
|
|
918
|
-
color: var(--color-sentiment-negative-primary-hover);
|
|
919
|
-
}
|
|
920
|
-
.wds-inline-prompt--negative a:active,
|
|
921
|
-
.wds-inline-prompt--negative button:active {
|
|
922
|
-
color: var(--color-sentiment-negative-primary-active);
|
|
923
|
-
}
|
|
924
|
-
.wds-inline-prompt.wds-inline-prompt--negative:has(a, button):hover {
|
|
925
|
-
background-color: var(--color-sentiment-negative-secondary-hover);
|
|
926
|
-
}
|
|
927
|
-
.wds-inline-prompt.wds-inline-prompt--negative:has(a, button):active {
|
|
928
|
-
background-color: var(--color-sentiment-negative-secondary-active);
|
|
929
|
-
}
|
|
930
|
-
.wds-inline-prompt--positive {
|
|
931
|
-
background-color: var(--color-sentiment-positive-secondary);
|
|
932
|
-
color: var(--color-sentiment-positive-primary);
|
|
933
|
-
}
|
|
934
|
-
.wds-inline-prompt--positive a,
|
|
935
|
-
.wds-inline-prompt--positive button {
|
|
936
|
-
color: var(--color-sentiment-positive-primary);
|
|
937
|
-
}
|
|
938
|
-
.wds-inline-prompt--positive a:hover,
|
|
939
|
-
.wds-inline-prompt--positive button:hover {
|
|
940
|
-
color: var(--color-sentiment-positive-primary-hover);
|
|
941
|
-
}
|
|
942
|
-
.wds-inline-prompt--positive a:active,
|
|
943
|
-
.wds-inline-prompt--positive button:active {
|
|
944
|
-
color: var(--color-sentiment-positive-primary-active);
|
|
945
|
-
}
|
|
946
|
-
.wds-inline-prompt.wds-inline-prompt--positive:has(a, button):hover {
|
|
947
|
-
background-color: var(--color-sentiment-positive-secondary-hover);
|
|
948
|
-
}
|
|
949
|
-
.wds-inline-prompt.wds-inline-prompt--positive:has(a, button):active {
|
|
950
|
-
background-color: var(--color-sentiment-positive-secondary-active);
|
|
951
|
-
}
|
|
952
|
-
.wds-inline-prompt--proposition {
|
|
953
|
-
background-color: #D2F9F7;
|
|
954
|
-
color: var(--color-interactive-primary);
|
|
955
|
-
}
|
|
956
|
-
.wds-inline-prompt--proposition a,
|
|
957
|
-
.wds-inline-prompt--proposition button {
|
|
958
|
-
color: var(--color-interactive-primary);
|
|
959
|
-
}
|
|
960
|
-
.wds-inline-prompt--proposition a:hover,
|
|
961
|
-
.wds-inline-prompt--proposition button:hover {
|
|
962
|
-
color: var(--color-interactive-primary-hover);
|
|
963
|
-
}
|
|
964
|
-
.wds-inline-prompt--proposition a:active,
|
|
965
|
-
.wds-inline-prompt--proposition button:active {
|
|
966
|
-
color: var(--color-interactive-primary-active);
|
|
967
|
-
}
|
|
968
|
-
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):hover {
|
|
969
|
-
background-color: #B2F4F3;
|
|
970
|
-
}
|
|
971
|
-
.wds-inline-prompt.wds-inline-prompt--proposition:has(a, button):active {
|
|
972
|
-
background-color: #91F0EE;
|
|
973
|
-
}
|
|
974
|
-
.wds-inline-prompt--neutral {
|
|
975
|
-
background-color: rgba(134,167,189,0.10196);
|
|
976
|
-
background-color: var(--color-background-neutral);
|
|
977
|
-
color: #37517e;
|
|
978
|
-
color: var(--color-content-primary);
|
|
979
|
-
}
|
|
980
|
-
.wds-inline-prompt--neutral a,
|
|
981
|
-
.wds-inline-prompt--neutral button {
|
|
982
|
-
color: #37517e;
|
|
983
|
-
color: var(--color-content-primary);
|
|
984
|
-
}
|
|
985
|
-
.wds-inline-prompt.wds-inline-prompt--neutral:has(a, button):hover {
|
|
986
|
-
background-color: var(--color-background-neutral-hover);
|
|
987
|
-
}
|
|
988
|
-
.wds-inline-prompt.wds-inline-prompt--neutral:has(a, button):active {
|
|
989
|
-
background-color: var(--color-background-neutral-active);
|
|
990
|
-
}
|
|
991
|
-
.wds-inline-prompt--warning {
|
|
992
|
-
background-color: var(--color-sentiment-warning-secondary);
|
|
993
|
-
color: var(--color-sentiment-warning-content);
|
|
994
|
-
}
|
|
995
|
-
.wds-inline-prompt--warning a,
|
|
996
|
-
.wds-inline-prompt--warning button {
|
|
997
|
-
color: var(--color-sentiment-warning-content);
|
|
998
|
-
}
|
|
999
|
-
.wds-inline-prompt--warning a:hover,
|
|
1000
|
-
.wds-inline-prompt--warning button:hover {
|
|
1001
|
-
color: var(--color-sentiment-warning-content-hover);
|
|
1002
|
-
}
|
|
1003
|
-
.wds-inline-prompt--warning a:active,
|
|
1004
|
-
.wds-inline-prompt--warning button:active {
|
|
1005
|
-
color: var(--color-sentiment-warning-content-active);
|
|
926
|
+
color: var(--color-sentiment-content-primary);
|
|
1006
927
|
}
|
|
1007
|
-
.wds-inline-prompt.wds-inline-prompt
|
|
1008
|
-
|
|
928
|
+
.wds-inline-prompt .wds-inline-prompt-process-indicator {
|
|
929
|
+
width: 16px;
|
|
930
|
+
width: var(--size-16);
|
|
931
|
+
height: 16px;
|
|
932
|
+
height: var(--size-16);
|
|
1009
933
|
}
|
|
1010
|
-
.wds-inline-prompt.wds-inline-prompt
|
|
1011
|
-
|
|
934
|
+
.wds-inline-prompt .wds-inline-prompt-process-indicator .process-circle {
|
|
935
|
+
stroke: currentColor;
|
|
1012
936
|
}
|
|
1013
937
|
.np-dot {
|
|
1014
938
|
--np-dot-size: 14px;
|
|
@@ -1111,17 +1035,17 @@
|
|
|
1111
1035
|
background-color: var(--color-background-neutral-active);
|
|
1112
1036
|
}
|
|
1113
1037
|
.np-icon-button-primary-default {
|
|
1114
|
-
color: var(--color-interactive-control);
|
|
1038
|
+
color: var(--color-sentiment-interactive-control, var(--color-interactive-control));
|
|
1115
1039
|
background-color: #00a2dd;
|
|
1116
|
-
background-color: var(--color-interactive-accent);
|
|
1040
|
+
background-color: var(--color-sentiment-interactive-primary, var(--color-interactive-accent));
|
|
1117
1041
|
}
|
|
1118
1042
|
.np-icon-button-primary-default:not(.disabled):not(:disabled):hover {
|
|
1119
1043
|
background-color: #008fc9;
|
|
1120
|
-
background-color: var(--color-interactive-accent-hover);
|
|
1044
|
+
background-color: var(--color-sentiment-interactive-primary-hover, var(--color-interactive-accent-hover));
|
|
1121
1045
|
}
|
|
1122
1046
|
.np-icon-button-primary-default:not(.disabled):not(:disabled):active {
|
|
1123
1047
|
background-color: #0081ba;
|
|
1124
|
-
background-color: var(--color-interactive-accent-active);
|
|
1048
|
+
background-color: var(--color-sentiment-interactive-primary-active, var(--color-interactive-accent-active));
|
|
1125
1049
|
}
|
|
1126
1050
|
.np-icon-button-primary-negative {
|
|
1127
1051
|
color: var(--color-contrast-overlay);
|
|
@@ -1149,14 +1073,14 @@
|
|
|
1149
1073
|
background-color: var(--color-background-screen-active);
|
|
1150
1074
|
}
|
|
1151
1075
|
.np-icon-button-secondary-default {
|
|
1152
|
-
color: var(--color-interactive-primary);
|
|
1153
|
-
background-color: var(--color-interactive-neutral);
|
|
1076
|
+
color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
|
|
1077
|
+
background-color: var(--color-sentiment-interactive-secondary-neutral, var(--color-interactive-neutral));
|
|
1154
1078
|
}
|
|
1155
1079
|
.np-icon-button-secondary-default:not(.disabled):not(:disabled):hover {
|
|
1156
|
-
background-color: var(--color-interactive-neutral-hover);
|
|
1080
|
+
background-color: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-interactive-neutral-hover));
|
|
1157
1081
|
}
|
|
1158
1082
|
.np-icon-button-secondary-default:not(.disabled):not(:disabled):active {
|
|
1159
|
-
background-color: var(--color-interactive-neutral-active);
|
|
1083
|
+
background-color: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-interactive-neutral-active));
|
|
1160
1084
|
}
|
|
1161
1085
|
.np-theme-personal--bright-green .np-icon-button-secondary-default,
|
|
1162
1086
|
.np-theme-personal--forest-green .np-icon-button-secondary-default {
|
|
@@ -1270,12 +1194,12 @@
|
|
|
1270
1194
|
pointer-events: auto;
|
|
1271
1195
|
}
|
|
1272
1196
|
.wds-Button {
|
|
1273
|
-
--Button-background: var(--color-interactive-accent);
|
|
1274
|
-
--Button-background-hover: var(--color-interactive-accent-hover);
|
|
1275
|
-
--Button-background-active: var(--color-interactive-accent-active);
|
|
1276
|
-
--Button-color: var(--color-interactive-control);
|
|
1277
|
-
--Button-color-hover: var(--color-interactive-control-hover);
|
|
1278
|
-
--Button-color-active: var(--color-interactive-control-active);
|
|
1197
|
+
--Button-background: var(--color-sentiment-interactive-primary, var(--color-interactive-accent));
|
|
1198
|
+
--Button-background-hover: var(--color-sentiment-interactive-primary-hover, var(--color-interactive-accent-hover));
|
|
1199
|
+
--Button-background-active: var(--color-sentiment-interactive-primary-active, var(--color-interactive-accent-active));
|
|
1200
|
+
--Button-color: var(--color-sentiment-interactive-control, var(--color-interactive-control));
|
|
1201
|
+
--Button-color-hover: var(--color-sentiment-interactive-control-hover, var(--color-interactive-control-hover));
|
|
1202
|
+
--Button-color-active: var(--color-sentiment-interactive-control-active, var(--color-interactive-control-active));
|
|
1279
1203
|
--Button-border-radius: var(--radius-full);
|
|
1280
1204
|
--Button-label-gap: var(--size-4);
|
|
1281
1205
|
--Button-large-padding: var(--size-12) var(--size-16);
|
|
@@ -1284,16 +1208,16 @@
|
|
|
1284
1208
|
--Button-avatar-border-color: var(--color-border-neutral);
|
|
1285
1209
|
--Button-transition-duration: 150ms;
|
|
1286
1210
|
--Button-transition-easing: ease-in-out;
|
|
1287
|
-
--Button-secondary-background: var(--color-interactive-neutral);
|
|
1288
|
-
--Button-secondary-background-hover: var(--color-interactive-neutral-hover);
|
|
1289
|
-
--Button-secondary-background-active: var(--color-interactive-neutral-active);
|
|
1290
|
-
--Button-secondary-color: var(--color-interactive-primary);
|
|
1291
|
-
--Button-secondary-color-hover: var(--color-interactive-primary-hover);
|
|
1292
|
-
--Button-secondary-color-active: var(--color-interactive-primary-active);
|
|
1293
|
-
--Button-secondary-neutral-background: var(--color-background-neutral);
|
|
1294
|
-
--Button-secondary-neutral-background-hover: var(--color-background-neutral-hover);
|
|
1295
|
-
--Button-secondary-neutral-background-active: var(--color-background-neutral-active);
|
|
1296
|
-
--Button-secondary-neutral-color: var(--color-content-primary);
|
|
1211
|
+
--Button-secondary-background: var(--color-sentiment-interactive-secondary-neutral, var(--color-interactive-neutral));
|
|
1212
|
+
--Button-secondary-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-interactive-neutral-hover));
|
|
1213
|
+
--Button-secondary-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-interactive-neutral-active));
|
|
1214
|
+
--Button-secondary-color: var(--color-sentiment-content-primary, var(--color-interactive-primary));
|
|
1215
|
+
--Button-secondary-color-hover: var(--color-sentiment-content-primary-hover, var(--color-interactive-primary-hover));
|
|
1216
|
+
--Button-secondary-color-active: var(--color-sentiment-content-primary-active, var(--color-interactive-primary-active));
|
|
1217
|
+
--Button-secondary-neutral-background: var(--color-sentiment-interactive-secondary-neutral, var(--color-background-neutral));
|
|
1218
|
+
--Button-secondary-neutral-background-hover: var(--color-sentiment-interactive-secondary-neutral-hover, var(--color-background-neutral-hover));
|
|
1219
|
+
--Button-secondary-neutral-background-active: var(--color-sentiment-interactive-secondary-neutral-active, var(--color-background-neutral-active));
|
|
1220
|
+
--Button-secondary-neutral-color: var(--color-sentiment-content-primary, var(--color-content-primary));
|
|
1297
1221
|
--Button-tertiary-background: transparent;
|
|
1298
1222
|
--Button-tertiary-background-hover: var(--color-background-screen-hover);
|
|
1299
1223
|
--Button-tertiary-background-active: var(--color-background-screen-active);
|
|
@@ -1384,7 +1308,7 @@
|
|
|
1384
1308
|
--Button-color-active: var(--Button-secondary-neutral-color);
|
|
1385
1309
|
}
|
|
1386
1310
|
.wds-Button--secondary-neutral .wds-Button-icon--end {
|
|
1387
|
-
color: var(--
|
|
1311
|
+
color: var(--Button-secondary-color);
|
|
1388
1312
|
}
|
|
1389
1313
|
.wds-Button--tertiary {
|
|
1390
1314
|
--Button-background: var(--Button-tertiary-background);
|
|
@@ -3133,8 +3057,7 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
3133
3057
|
}
|
|
3134
3058
|
@supports (hyphenate-limit-chars: 1) {
|
|
3135
3059
|
.np-form-control--size-lg {
|
|
3136
|
-
|
|
3137
|
-
hyphens: auto;
|
|
3060
|
+
hyphens: auto;
|
|
3138
3061
|
hyphenate-limit-chars: 7 3;
|
|
3139
3062
|
}
|
|
3140
3063
|
@media (min-width: 768px) {
|
|
@@ -3150,8 +3073,7 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
3150
3073
|
}
|
|
3151
3074
|
@supports (not (hyphenate-limit-chars: 1)) and (-webkit-hyphenate-limit-before: 1) {
|
|
3152
3075
|
.np-form-control--size-lg {
|
|
3153
|
-
|
|
3154
|
-
hyphens: auto;
|
|
3076
|
+
hyphens: auto;
|
|
3155
3077
|
-webkit-hyphenate-limit-before: 3;
|
|
3156
3078
|
-webkit-hyphenate-limit-after: 3;
|
|
3157
3079
|
}
|
|
@@ -4327,6 +4249,7 @@ html:not([dir="rtl"]) .np-flow-navigation--sm .np-flow-navigation__stepper {
|
|
|
4327
4249
|
a,
|
|
4328
4250
|
button.np-link {
|
|
4329
4251
|
border-radius: 2px;
|
|
4252
|
+
color: var(--color-sentiment-content-primary, var(--color-content-link));
|
|
4330
4253
|
}
|
|
4331
4254
|
.np-link .tw-icon {
|
|
4332
4255
|
display: flex;
|
|
@@ -5189,8 +5112,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5189
5112
|
}
|
|
5190
5113
|
@supports (hyphenate-limit-chars: 1) {
|
|
5191
5114
|
.np-popover__container.np-bottom-sheet .np-popover__title {
|
|
5192
|
-
|
|
5193
|
-
hyphens: auto;
|
|
5115
|
+
hyphens: auto;
|
|
5194
5116
|
hyphenate-limit-chars: 7 3;
|
|
5195
5117
|
}
|
|
5196
5118
|
@media (min-width: 768px) {
|
|
@@ -5206,8 +5128,7 @@ html:not([dir="rtl"]) .np-navigation-option {
|
|
|
5206
5128
|
}
|
|
5207
5129
|
@supports (not (hyphenate-limit-chars: 1)) and (-webkit-hyphenate-limit-before: 1) {
|
|
5208
5130
|
.np-popover__container.np-bottom-sheet .np-popover__title {
|
|
5209
|
-
|
|
5210
|
-
hyphens: auto;
|
|
5131
|
+
hyphens: auto;
|
|
5211
5132
|
-webkit-hyphenate-limit-before: 3;
|
|
5212
5133
|
-webkit-hyphenate-limit-after: 3;
|
|
5213
5134
|
}
|
|
@@ -28,6 +28,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
28
28
|
var ProcessIndicator = require('../../processIndicator/ProcessIndicator.js');
|
|
29
29
|
var StatusIcon = require('../../statusIcon/StatusIcon.js');
|
|
30
30
|
var Body = require('../../body/Body.js');
|
|
31
|
+
var SentimentSurface = require('../../sentimentSurface/SentimentSurface.js');
|
|
31
32
|
|
|
32
33
|
const InlinePrompt = ({
|
|
33
34
|
sentiment: sentiment$1 = sentiment.Sentiment.POSITIVE,
|
|
@@ -36,15 +37,11 @@ const InlinePrompt = ({
|
|
|
36
37
|
className,
|
|
37
38
|
children,
|
|
38
39
|
media = null,
|
|
40
|
+
'data-testid': dataTestId,
|
|
39
41
|
...rest
|
|
40
42
|
}) => {
|
|
43
|
+
const surfaceSentiment = sentiment$1 === sentiment.Sentiment.POSITIVE ? 'success' : sentiment$1;
|
|
41
44
|
const renderMedia = () => {
|
|
42
|
-
if (media && ['proposition', 'positive'].includes(sentiment$1)) {
|
|
43
|
-
return media;
|
|
44
|
-
}
|
|
45
|
-
if (sentiment$1 === 'proposition') {
|
|
46
|
-
return /*#__PURE__*/jsxRuntime.jsx(icons.GiftBox, {});
|
|
47
|
-
}
|
|
48
45
|
if (muted) {
|
|
49
46
|
return /*#__PURE__*/jsxRuntime.jsx(icons.BackslashCircle, {
|
|
50
47
|
size: 16,
|
|
@@ -54,15 +51,24 @@ const InlinePrompt = ({
|
|
|
54
51
|
if (loading) {
|
|
55
52
|
return /*#__PURE__*/jsxRuntime.jsx(ProcessIndicator.default, {
|
|
56
53
|
"data-testid": "InlinePrompt_ProcessIndicator",
|
|
57
|
-
size: "xxs"
|
|
54
|
+
size: "xxs",
|
|
55
|
+
className: "wds-inline-prompt-process-indicator"
|
|
58
56
|
});
|
|
59
57
|
}
|
|
58
|
+
if (sentiment$1 === 'positive' && media) {
|
|
59
|
+
return media;
|
|
60
|
+
}
|
|
61
|
+
if (sentiment$1 === 'proposition') {
|
|
62
|
+
return media || /*#__PURE__*/jsxRuntime.jsx(icons.GiftBox, {});
|
|
63
|
+
}
|
|
60
64
|
return /*#__PURE__*/jsxRuntime.jsx(StatusIcon.default, {
|
|
61
65
|
size: 16,
|
|
62
66
|
sentiment: sentiment$1
|
|
63
67
|
});
|
|
64
68
|
};
|
|
65
|
-
return /*#__PURE__*/jsxRuntime.jsxs(
|
|
69
|
+
return /*#__PURE__*/jsxRuntime.jsxs(SentimentSurface.default, {
|
|
70
|
+
sentiment: surfaceSentiment,
|
|
71
|
+
"data-testid": dataTestId,
|
|
66
72
|
className: clsx.clsx('wds-inline-prompt', `wds-inline-prompt--${sentiment$1}`, {
|
|
67
73
|
'wds-inline-prompt--muted': muted,
|
|
68
74
|
'wds-inline-prompt--loading': loading
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlinePrompt.js","sources":["../../../src/prompt/InlinePrompt/InlinePrompt.tsx"],"sourcesContent":["import { Sentiment } from '../../common';\nimport { BackslashCircle, GiftBox } from '@transferwise/icons';\nimport ProcessIndicator from '../../processIndicator';\nimport StatusIcon from '../../statusIcon';\nimport { clsx } from 'clsx';\nimport Body from '../../body';\n\nexport type InlinePromptProps = {\n sentiment?:\n | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`\n | 'proposition';\n loading?: boolean;\n /**\n *
|
|
1
|
+
{"version":3,"file":"InlinePrompt.js","sources":["../../../src/prompt/InlinePrompt/InlinePrompt.tsx"],"sourcesContent":["import { Sentiment } from '../../common';\nimport { BackslashCircle, GiftBox } from '@transferwise/icons';\nimport ProcessIndicator from '../../processIndicator';\nimport StatusIcon from '../../statusIcon';\nimport { clsx } from 'clsx';\nimport Body from '../../body';\nimport SentimentSurface from '../../sentimentSurface';\n\nexport type InlinePromptProps = {\n /**\n * The sentiment determines the colour scheme\n */\n sentiment?:\n | `${Sentiment.POSITIVE | Sentiment.NEGATIVE | Sentiment.NEUTRAL | Sentiment.WARNING}`\n | 'proposition';\n /**\n * Replaces the icon with a spinner while waiting for the short-lived action to finish.\n * @default false\n */\n loading?: boolean;\n /**\n * While prompts cannot be fully (visually and functionally) disabled, this prop should be enabled\n * they are associated with actually disabled component (e.g. a disabled list item or input).\n * @default false\n */\n muted?: boolean;\n /**\n * Icon override for `proposition` and `positive` sentiments. Unsupported for remaining ones.\n */\n media?: React.ReactNode;\n id?: string;\n className?: string;\n 'data-testid'?: string;\n children: React.ReactNode;\n};\n\n/**\n * Inline prompts appear alongside a specific component on the screen. They help the user stay\n * informed, fix something, or get more out of what they're doing.\n */\nexport const InlinePrompt = ({\n sentiment = Sentiment.POSITIVE,\n muted = false,\n loading = false,\n className,\n children,\n media = null,\n 'data-testid': dataTestId,\n ...rest\n}: InlinePromptProps) => {\n const surfaceSentiment = sentiment === Sentiment.POSITIVE ? 'success' : sentiment;\n\n const renderMedia = () => {\n if (muted) {\n return <BackslashCircle size={16} data-testid=\"InlinePrompt_Muted\" />;\n }\n if (loading) {\n return (\n <ProcessIndicator\n data-testid=\"InlinePrompt_ProcessIndicator\"\n size=\"xxs\"\n className=\"wds-inline-prompt-process-indicator\"\n />\n );\n }\n\n if (sentiment === 'positive' && media) {\n return media;\n }\n\n if (sentiment === 'proposition') {\n return media || <GiftBox />;\n }\n\n return <StatusIcon size={16} sentiment={sentiment} />;\n };\n\n return (\n <SentimentSurface\n sentiment={surfaceSentiment}\n data-testid={dataTestId}\n className={clsx(\n 'wds-inline-prompt',\n `wds-inline-prompt--${sentiment}`,\n {\n 'wds-inline-prompt--muted': muted,\n 'wds-inline-prompt--loading': loading,\n },\n className,\n )}\n {...rest}\n >\n <div className=\"wds-inline-prompt__media-wrapper\">{renderMedia()}</div>\n <Body>{children}</Body>\n </SentimentSurface>\n );\n};\n"],"names":["InlinePrompt","sentiment","Sentiment","POSITIVE","muted","loading","className","children","media","dataTestId","rest","surfaceSentiment","renderMedia","_jsx","BackslashCircle","size","ProcessIndicator","GiftBox","StatusIcon","_jsxs","SentimentSurface","clsx","Body"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,MAAMA,YAAY,GAAGA,CAAC;aAC3BC,WAAS,GAAGC,mBAAS,CAACC,QAAQ;AAC9BC,EAAAA,KAAK,GAAG,KAAK;AACbC,EAAAA,OAAO,GAAG,KAAK;EACfC,SAAS;EACTC,QAAQ;AACRC,EAAAA,KAAK,GAAG,IAAI;AACZ,EAAA,aAAa,EAAEC,UAAU;EACzB,GAAGC;AAAI,CACW,KAAI;EACtB,MAAMC,gBAAgB,GAAGV,WAAS,KAAKC,mBAAS,CAACC,QAAQ,GAAG,SAAS,GAAGF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C;AAEvB;;;;"}
|
|
@@ -17,7 +17,7 @@ import '../../common/propsValues/variant.mjs';
|
|
|
17
17
|
import '../../common/propsValues/scroll.mjs';
|
|
18
18
|
import '../../common/propsValues/markdownNodeType.mjs';
|
|
19
19
|
import '../../common/fileType.mjs';
|
|
20
|
-
import {
|
|
20
|
+
import { BackslashCircle, GiftBox } from '@transferwise/icons';
|
|
21
21
|
import { clsx } from 'clsx';
|
|
22
22
|
import 'react';
|
|
23
23
|
import 'react-intl';
|
|
@@ -26,6 +26,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
26
26
|
import ProcessIndicator from '../../processIndicator/ProcessIndicator.mjs';
|
|
27
27
|
import StatusIcon from '../../statusIcon/StatusIcon.mjs';
|
|
28
28
|
import Body from '../../body/Body.mjs';
|
|
29
|
+
import SentimentSurface from '../../sentimentSurface/SentimentSurface.mjs';
|
|
29
30
|
|
|
30
31
|
const InlinePrompt = ({
|
|
31
32
|
sentiment = Sentiment.POSITIVE,
|
|
@@ -34,15 +35,11 @@ const InlinePrompt = ({
|
|
|
34
35
|
className,
|
|
35
36
|
children,
|
|
36
37
|
media = null,
|
|
38
|
+
'data-testid': dataTestId,
|
|
37
39
|
...rest
|
|
38
40
|
}) => {
|
|
41
|
+
const surfaceSentiment = sentiment === Sentiment.POSITIVE ? 'success' : sentiment;
|
|
39
42
|
const renderMedia = () => {
|
|
40
|
-
if (media && ['proposition', 'positive'].includes(sentiment)) {
|
|
41
|
-
return media;
|
|
42
|
-
}
|
|
43
|
-
if (sentiment === 'proposition') {
|
|
44
|
-
return /*#__PURE__*/jsx(GiftBox, {});
|
|
45
|
-
}
|
|
46
43
|
if (muted) {
|
|
47
44
|
return /*#__PURE__*/jsx(BackslashCircle, {
|
|
48
45
|
size: 16,
|
|
@@ -52,15 +49,24 @@ const InlinePrompt = ({
|
|
|
52
49
|
if (loading) {
|
|
53
50
|
return /*#__PURE__*/jsx(ProcessIndicator, {
|
|
54
51
|
"data-testid": "InlinePrompt_ProcessIndicator",
|
|
55
|
-
size: "xxs"
|
|
52
|
+
size: "xxs",
|
|
53
|
+
className: "wds-inline-prompt-process-indicator"
|
|
56
54
|
});
|
|
57
55
|
}
|
|
56
|
+
if (sentiment === 'positive' && media) {
|
|
57
|
+
return media;
|
|
58
|
+
}
|
|
59
|
+
if (sentiment === 'proposition') {
|
|
60
|
+
return media || /*#__PURE__*/jsx(GiftBox, {});
|
|
61
|
+
}
|
|
58
62
|
return /*#__PURE__*/jsx(StatusIcon, {
|
|
59
63
|
size: 16,
|
|
60
64
|
sentiment: sentiment
|
|
61
65
|
});
|
|
62
66
|
};
|
|
63
|
-
return /*#__PURE__*/jsxs(
|
|
67
|
+
return /*#__PURE__*/jsxs(SentimentSurface, {
|
|
68
|
+
sentiment: surfaceSentiment,
|
|
69
|
+
"data-testid": dataTestId,
|
|
64
70
|
className: clsx('wds-inline-prompt', `wds-inline-prompt--${sentiment}`, {
|
|
65
71
|
'wds-inline-prompt--muted': muted,
|
|
66
72
|
'wds-inline-prompt--loading': loading
|