@veeqo/ui 13.18.1 → 13.19.0-beta-2
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/dist/components/Anchor/Anchor.cjs +5 -11
- package/dist/components/Anchor/Anchor.cjs.map +1 -1
- package/dist/components/Anchor/Anchor.d.ts +1 -1
- package/dist/components/Anchor/Anchor.js +5 -11
- package/dist/components/Anchor/Anchor.js.map +1 -1
- package/dist/components/Anchor/styled.cjs +38 -0
- package/dist/components/Anchor/styled.cjs.map +1 -0
- package/dist/components/Anchor/styled.d.ts +10 -0
- package/dist/components/Anchor/styled.js +29 -0
- package/dist/components/Anchor/styled.js.map +1 -0
- package/dist/components/ToastsLayout/ToastsLayout.cjs +24 -7
- package/dist/components/ToastsLayout/ToastsLayout.cjs.map +1 -1
- package/dist/components/ToastsLayout/ToastsLayout.d.ts +13 -0
- package/dist/components/ToastsLayout/ToastsLayout.js +24 -7
- package/dist/components/ToastsLayout/ToastsLayout.js.map +1 -1
- package/dist/components/ToastsLayout/components/Toast.cjs +23 -38
- package/dist/components/ToastsLayout/components/Toast.cjs.map +1 -1
- package/dist/components/ToastsLayout/components/Toast.d.ts +1 -1
- package/dist/components/ToastsLayout/components/Toast.js +23 -38
- package/dist/components/ToastsLayout/components/Toast.js.map +1 -1
- package/dist/components/ToastsLayout/components/constants.cjs +42 -0
- package/dist/components/ToastsLayout/components/constants.cjs.map +1 -0
- package/dist/components/ToastsLayout/components/constants.d.ts +2 -0
- package/dist/components/ToastsLayout/components/constants.js +36 -0
- package/dist/components/ToastsLayout/components/constants.js.map +1 -0
- package/dist/components/ToastsLayout/components/toast.module.scss.cjs +9 -0
- package/dist/components/ToastsLayout/components/toast.module.scss.cjs.map +1 -0
- package/dist/components/ToastsLayout/components/toast.module.scss.js +7 -0
- package/dist/components/ToastsLayout/components/toast.module.scss.js.map +1 -0
- package/dist/components/ToastsLayout/components/utils.cjs +10 -0
- package/dist/components/ToastsLayout/components/utils.cjs.map +1 -0
- package/dist/components/ToastsLayout/components/utils.d.ts +2 -0
- package/dist/components/ToastsLayout/components/utils.js +8 -0
- package/dist/components/ToastsLayout/components/utils.js.map +1 -0
- package/dist/components/ToastsLayout/index.d.ts +1 -0
- package/dist/components/ToastsLayout/toastsLayout.module.scss.cjs +9 -0
- package/dist/components/ToastsLayout/toastsLayout.module.scss.cjs.map +1 -0
- package/dist/components/ToastsLayout/toastsLayout.module.scss.js +7 -0
- package/dist/components/ToastsLayout/toastsLayout.module.scss.js.map +1 -0
- package/dist/components/ToastsLayout/types.cjs +12 -0
- package/dist/components/ToastsLayout/types.cjs.map +1 -0
- package/dist/components/ToastsLayout/types.d.ts +15 -8
- package/dist/components/ToastsLayout/types.js +12 -0
- package/dist/components/ToastsLayout/types.js.map +1 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/Anchor/Anchor.module.scss.cjs +0 -9
- package/dist/components/Anchor/Anchor.module.scss.cjs.map +0 -1
- package/dist/components/Anchor/Anchor.module.scss.js +0 -7
- package/dist/components/Anchor/Anchor.module.scss.js.map +0 -1
- package/dist/components/ToastsLayout/components/styled.cjs +0 -25
- package/dist/components/ToastsLayout/components/styled.cjs.map +0 -1
- package/dist/components/ToastsLayout/components/styled.d.ts +0 -10
- package/dist/components/ToastsLayout/components/styled.js +0 -15
- package/dist/components/ToastsLayout/components/styled.js.map +0 -1
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var sizes = require('../../theme/modules/sizes.cjs');
|
|
5
5
|
var urlUtils = require('./utils/urlUtils.cjs');
|
|
6
|
-
var
|
|
7
|
-
require('uid/secure');
|
|
8
|
-
var Anchor_module = require('./Anchor.module.scss.cjs');
|
|
6
|
+
var styled = require('./styled.cjs');
|
|
9
7
|
var HelpIcon = require('../../icons/design-system/components/HelpIcon.cjs');
|
|
10
8
|
var LaunchIcon = require('../../icons/design-system/components/LaunchIcon.cjs');
|
|
11
9
|
var isExternalLink = require('./isExternalLink.cjs');
|
|
@@ -25,7 +23,7 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
25
23
|
* @param children - The content of the anchor
|
|
26
24
|
* @param rest - All other standard anchor HTML attributes
|
|
27
25
|
*/
|
|
28
|
-
const Anchor = React__default.default.memo(({ variant = 'base', size = 'base', href, showHelpIcon = false, leftIconSlot = null, hideExternalLinkIcon = false, allowedHostnames = [], children, target, rel,
|
|
26
|
+
const Anchor = React__default.default.memo(({ variant = 'base', size = 'base', href, showHelpIcon = false, leftIconSlot = null, hideExternalLinkIcon = false, allowedHostnames = [], children, target, rel, ...rest }) => {
|
|
29
27
|
// Process the URL to make it context-aware
|
|
30
28
|
const processedHref = href ? urlUtils.createContextAwareUrl(href) : undefined;
|
|
31
29
|
// Determine if link is external based on processed href
|
|
@@ -33,15 +31,11 @@ const Anchor = React__default.default.memo(({ variant = 'base', size = 'base', h
|
|
|
33
31
|
// Set security attributes for external links if not given in props
|
|
34
32
|
const secureTarget = target || (isExternal ? '_blank' : undefined);
|
|
35
33
|
const secureRel = rel || (isExternal ? 'noopener noreferrer' : undefined);
|
|
34
|
+
// Lookup the appropriate styled component based on variant
|
|
35
|
+
const AnchorComponent = styled.AnchorMapping[variant];
|
|
36
36
|
// Show icon when when link is external and/or will open new tab (and not overridden by variant or hideExternalLinkIcon)
|
|
37
37
|
const shouldShowExternalLinkIcon = (isExternal || secureTarget === '_blank') && !hideExternalLinkIcon && variant === 'base';
|
|
38
|
-
|
|
39
|
-
variant !== 'unstyled' && Anchor_module.anchor,
|
|
40
|
-
variant === 'inherit' && Anchor_module.inherit,
|
|
41
|
-
variant !== 'unstyled' && Anchor_module[size],
|
|
42
|
-
className,
|
|
43
|
-
]);
|
|
44
|
-
return (React__default.default.createElement("a", { href: processedHref, target: secureTarget, rel: secureRel, className: classNames, ...rest },
|
|
38
|
+
return (React__default.default.createElement(AnchorComponent, { href: processedHref, target: secureTarget, rel: secureRel, size: size, ...rest },
|
|
45
39
|
leftIconSlot,
|
|
46
40
|
showHelpIcon && !leftIconSlot && (React__default.default.createElement(HelpIcon.ReactComponent, { role: "presentation", "data-testid": "help-icon", style: { marginRight: sizes.sizes.xs } })),
|
|
47
41
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Anchor.cjs","sources":["../../../src/components/Anchor/Anchor.tsx"],"sourcesContent":["import React from 'react';\n\nimport { sizes } from 'Theme/modules/sizes';\nimport { createContextAwareUrl } from './utils/urlUtils';\nimport { AnchorProps } from './types';\nimport {
|
|
1
|
+
{"version":3,"file":"Anchor.cjs","sources":["../../../src/components/Anchor/Anchor.tsx"],"sourcesContent":["import React from 'react';\n\nimport { sizes } from 'Theme/modules/sizes';\nimport { createContextAwareUrl } from './utils/urlUtils';\nimport { AnchorProps } from './types';\nimport { AnchorMapping } from './styled';\n\nimport { HelpIcon, LaunchIcon } from '../../icons';\n\nimport { isExternalLink } from './isExternalLink';\n\n/**\n * Anchor component for handling context-aware links with consistent functionality and styling options.\n *\n * https://www.figma.com/design/KFfBvJvYT4evKe9eiLEnwD/%F0%9F%8E%A8-Design-System?node-id=1170-63891&m=dev\n *\n * @param variant - The visual style variant ('base' or 'unstyled')\n * @param href - The URL the link points to (will be processed to be context-aware)\n * @param showHelpIcon - Whether to show a help icon on the left (defaults to false)\n * @param children - The content of the anchor\n * @param rest - All other standard anchor HTML attributes\n */\nexport const Anchor = React.memo(\n ({\n variant = 'base',\n size = 'base',\n href,\n showHelpIcon = false,\n leftIconSlot = null,\n hideExternalLinkIcon = false,\n allowedHostnames = [],\n children,\n target,\n rel,\n ...rest\n }: AnchorProps) => {\n // Process the URL to make it context-aware\n const processedHref = href ? createContextAwareUrl(href) : undefined;\n\n // Determine if link is external based on processed href\n const isExternal = processedHref ? isExternalLink(processedHref, allowedHostnames) : false;\n\n // Set security attributes for external links if not given in props\n const secureTarget = target || (isExternal ? '_blank' : undefined);\n const secureRel = rel || (isExternal ? 'noopener noreferrer' : undefined);\n\n // Lookup the appropriate styled component based on variant\n const AnchorComponent = AnchorMapping[variant];\n\n // Show icon when when link is external and/or will open new tab (and not overridden by variant or hideExternalLinkIcon)\n const shouldShowExternalLinkIcon =\n (isExternal || secureTarget === '_blank') && !hideExternalLinkIcon && variant === 'base';\n\n return (\n <AnchorComponent\n href={processedHref}\n target={secureTarget}\n rel={secureRel}\n size={size}\n {...rest}\n >\n {leftIconSlot}\n {showHelpIcon && !leftIconSlot && (\n <HelpIcon role=\"presentation\" data-testid=\"help-icon\" style={{ marginRight: sizes.xs }} />\n )}\n\n {children}\n {shouldShowExternalLinkIcon && (\n <LaunchIcon\n role=\"presentation\"\n data-testid=\"external-icon\"\n style={{ marginLeft: sizes.xs }}\n />\n )}\n </AnchorComponent>\n );\n },\n);\n"],"names":["React","createContextAwareUrl","isExternalLink","AnchorMapping","HelpIcon","sizes","LaunchIcon"],"mappings":";;;;;;;;;;;;;;AAWA;;;;;;;;;;AAUG;MACU,MAAM,GAAGA,sBAAK,CAAC,IAAI,CAC9B,CAAC,EACC,OAAO,GAAG,MAAM,EAChB,IAAI,GAAG,MAAM,EACb,IAAI,EACJ,YAAY,GAAG,KAAK,EACpB,YAAY,GAAG,IAAI,EACnB,oBAAoB,GAAG,KAAK,EAC5B,gBAAgB,GAAG,EAAE,EACrB,QAAQ,EACR,MAAM,EACN,GAAG,EACH,GAAG,IAAI,EACK,KAAI;;AAEhB,IAAA,MAAM,aAAa,GAAG,IAAI,GAAGC,8BAAqB,CAAC,IAAI,CAAC,GAAG,SAAS;;AAGpE,IAAA,MAAM,UAAU,GAAG,aAAa,GAAGC,6BAAc,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK;;AAG1F,IAAA,MAAM,YAAY,GAAG,MAAM,KAAK,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAClE,IAAA,MAAM,SAAS,GAAG,GAAG,KAAK,UAAU,GAAG,qBAAqB,GAAG,SAAS,CAAC;;AAGzE,IAAA,MAAM,eAAe,GAAGC,oBAAa,CAAC,OAAO,CAAC;;AAG9C,IAAA,MAAM,0BAA0B,GAC9B,CAAC,UAAU,IAAI,YAAY,KAAK,QAAQ,KAAK,CAAC,oBAAoB,IAAI,OAAO,KAAK,MAAM;IAE1F,QACEH,qCAAC,eAAe,EAAA,EACd,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,IAAI,KACN,IAAI,EAAA;QAEP,YAAY;QACZ,YAAY,IAAI,CAAC,YAAY,KAC5BA,qCAACI,uBAAQ,EAAA,EAAC,IAAI,EAAC,cAAc,EAAA,aAAA,EAAa,WAAW,EAAC,KAAK,EAAE,EAAE,WAAW,EAAEC,WAAK,CAAC,EAAE,EAAE,EAAA,CAAI,CAC3F;QAEA,QAAQ;QACR,0BAA0B,KACzBL,sBAAA,CAAA,aAAA,CAACM,yBAAU,EAAA,EACT,IAAI,EAAC,cAAc,EACP,aAAA,EAAA,eAAe,EAC3B,KAAK,EAAE,EAAE,UAAU,EAAED,WAAK,CAAC,EAAE,EAAE,EAC/B,CAAA,CACH,CACe;AAEtB,CAAC;;;;"}
|
|
@@ -11,4 +11,4 @@ import { AnchorProps } from './types';
|
|
|
11
11
|
* @param children - The content of the anchor
|
|
12
12
|
* @param rest - All other standard anchor HTML attributes
|
|
13
13
|
*/
|
|
14
|
-
export declare const Anchor: React.MemoExoticComponent<({ variant, size, href, showHelpIcon, leftIconSlot, hideExternalLinkIcon, allowedHostnames, children, target, rel,
|
|
14
|
+
export declare const Anchor: React.MemoExoticComponent<({ variant, size, href, showHelpIcon, leftIconSlot, hideExternalLinkIcon, allowedHostnames, children, target, rel, ...rest }: AnchorProps) => React.JSX.Element>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
2
|
import { sizes } from '../../theme/modules/sizes.js';
|
|
3
3
|
import { createContextAwareUrl } from './utils/urlUtils.js';
|
|
4
|
-
import {
|
|
5
|
-
import 'uid/secure';
|
|
6
|
-
import styles from './Anchor.module.scss.js';
|
|
4
|
+
import { AnchorMapping } from './styled.js';
|
|
7
5
|
import { ReactComponent as HelpIcon } from '../../icons/design-system/components/HelpIcon.js';
|
|
8
6
|
import { ReactComponent as LaunchIcon } from '../../icons/design-system/components/LaunchIcon.js';
|
|
9
7
|
import { isExternalLink } from './isExternalLink.js';
|
|
@@ -19,7 +17,7 @@ import { isExternalLink } from './isExternalLink.js';
|
|
|
19
17
|
* @param children - The content of the anchor
|
|
20
18
|
* @param rest - All other standard anchor HTML attributes
|
|
21
19
|
*/
|
|
22
|
-
const Anchor = React__default.memo(({ variant = 'base', size = 'base', href, showHelpIcon = false, leftIconSlot = null, hideExternalLinkIcon = false, allowedHostnames = [], children, target, rel,
|
|
20
|
+
const Anchor = React__default.memo(({ variant = 'base', size = 'base', href, showHelpIcon = false, leftIconSlot = null, hideExternalLinkIcon = false, allowedHostnames = [], children, target, rel, ...rest }) => {
|
|
23
21
|
// Process the URL to make it context-aware
|
|
24
22
|
const processedHref = href ? createContextAwareUrl(href) : undefined;
|
|
25
23
|
// Determine if link is external based on processed href
|
|
@@ -27,15 +25,11 @@ const Anchor = React__default.memo(({ variant = 'base', size = 'base', href, sho
|
|
|
27
25
|
// Set security attributes for external links if not given in props
|
|
28
26
|
const secureTarget = target || (isExternal ? '_blank' : undefined);
|
|
29
27
|
const secureRel = rel || (isExternal ? 'noopener noreferrer' : undefined);
|
|
28
|
+
// Lookup the appropriate styled component based on variant
|
|
29
|
+
const AnchorComponent = AnchorMapping[variant];
|
|
30
30
|
// Show icon when when link is external and/or will open new tab (and not overridden by variant or hideExternalLinkIcon)
|
|
31
31
|
const shouldShowExternalLinkIcon = (isExternal || secureTarget === '_blank') && !hideExternalLinkIcon && variant === 'base';
|
|
32
|
-
|
|
33
|
-
variant !== 'unstyled' && styles.anchor,
|
|
34
|
-
variant === 'inherit' && styles.inherit,
|
|
35
|
-
variant !== 'unstyled' && styles[size],
|
|
36
|
-
className,
|
|
37
|
-
]);
|
|
38
|
-
return (React__default.createElement("a", { href: processedHref, target: secureTarget, rel: secureRel, className: classNames, ...rest },
|
|
32
|
+
return (React__default.createElement(AnchorComponent, { href: processedHref, target: secureTarget, rel: secureRel, size: size, ...rest },
|
|
39
33
|
leftIconSlot,
|
|
40
34
|
showHelpIcon && !leftIconSlot && (React__default.createElement(HelpIcon, { role: "presentation", "data-testid": "help-icon", style: { marginRight: sizes.xs } })),
|
|
41
35
|
children,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Anchor.js","sources":["../../../src/components/Anchor/Anchor.tsx"],"sourcesContent":["import React from 'react';\n\nimport { sizes } from 'Theme/modules/sizes';\nimport { createContextAwareUrl } from './utils/urlUtils';\nimport { AnchorProps } from './types';\nimport {
|
|
1
|
+
{"version":3,"file":"Anchor.js","sources":["../../../src/components/Anchor/Anchor.tsx"],"sourcesContent":["import React from 'react';\n\nimport { sizes } from 'Theme/modules/sizes';\nimport { createContextAwareUrl } from './utils/urlUtils';\nimport { AnchorProps } from './types';\nimport { AnchorMapping } from './styled';\n\nimport { HelpIcon, LaunchIcon } from '../../icons';\n\nimport { isExternalLink } from './isExternalLink';\n\n/**\n * Anchor component for handling context-aware links with consistent functionality and styling options.\n *\n * https://www.figma.com/design/KFfBvJvYT4evKe9eiLEnwD/%F0%9F%8E%A8-Design-System?node-id=1170-63891&m=dev\n *\n * @param variant - The visual style variant ('base' or 'unstyled')\n * @param href - The URL the link points to (will be processed to be context-aware)\n * @param showHelpIcon - Whether to show a help icon on the left (defaults to false)\n * @param children - The content of the anchor\n * @param rest - All other standard anchor HTML attributes\n */\nexport const Anchor = React.memo(\n ({\n variant = 'base',\n size = 'base',\n href,\n showHelpIcon = false,\n leftIconSlot = null,\n hideExternalLinkIcon = false,\n allowedHostnames = [],\n children,\n target,\n rel,\n ...rest\n }: AnchorProps) => {\n // Process the URL to make it context-aware\n const processedHref = href ? createContextAwareUrl(href) : undefined;\n\n // Determine if link is external based on processed href\n const isExternal = processedHref ? isExternalLink(processedHref, allowedHostnames) : false;\n\n // Set security attributes for external links if not given in props\n const secureTarget = target || (isExternal ? '_blank' : undefined);\n const secureRel = rel || (isExternal ? 'noopener noreferrer' : undefined);\n\n // Lookup the appropriate styled component based on variant\n const AnchorComponent = AnchorMapping[variant];\n\n // Show icon when when link is external and/or will open new tab (and not overridden by variant or hideExternalLinkIcon)\n const shouldShowExternalLinkIcon =\n (isExternal || secureTarget === '_blank') && !hideExternalLinkIcon && variant === 'base';\n\n return (\n <AnchorComponent\n href={processedHref}\n target={secureTarget}\n rel={secureRel}\n size={size}\n {...rest}\n >\n {leftIconSlot}\n {showHelpIcon && !leftIconSlot && (\n <HelpIcon role=\"presentation\" data-testid=\"help-icon\" style={{ marginRight: sizes.xs }} />\n )}\n\n {children}\n {shouldShowExternalLinkIcon && (\n <LaunchIcon\n role=\"presentation\"\n data-testid=\"external-icon\"\n style={{ marginLeft: sizes.xs }}\n />\n )}\n </AnchorComponent>\n );\n },\n);\n"],"names":["React"],"mappings":";;;;;;;;AAWA;;;;;;;;;;AAUG;MACU,MAAM,GAAGA,cAAK,CAAC,IAAI,CAC9B,CAAC,EACC,OAAO,GAAG,MAAM,EAChB,IAAI,GAAG,MAAM,EACb,IAAI,EACJ,YAAY,GAAG,KAAK,EACpB,YAAY,GAAG,IAAI,EACnB,oBAAoB,GAAG,KAAK,EAC5B,gBAAgB,GAAG,EAAE,EACrB,QAAQ,EACR,MAAM,EACN,GAAG,EACH,GAAG,IAAI,EACK,KAAI;;AAEhB,IAAA,MAAM,aAAa,GAAG,IAAI,GAAG,qBAAqB,CAAC,IAAI,CAAC,GAAG,SAAS;;AAGpE,IAAA,MAAM,UAAU,GAAG,aAAa,GAAG,cAAc,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,KAAK;;AAG1F,IAAA,MAAM,YAAY,GAAG,MAAM,KAAK,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAClE,IAAA,MAAM,SAAS,GAAG,GAAG,KAAK,UAAU,GAAG,qBAAqB,GAAG,SAAS,CAAC;;AAGzE,IAAA,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,CAAC;;AAG9C,IAAA,MAAM,0BAA0B,GAC9B,CAAC,UAAU,IAAI,YAAY,KAAK,QAAQ,KAAK,CAAC,oBAAoB,IAAI,OAAO,KAAK,MAAM;IAE1F,QACEA,6BAAC,eAAe,EAAA,EACd,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,YAAY,EACpB,GAAG,EAAE,SAAS,EACd,IAAI,EAAE,IAAI,KACN,IAAI,EAAA;QAEP,YAAY;QACZ,YAAY,IAAI,CAAC,YAAY,KAC5BA,6BAAC,QAAQ,EAAA,EAAC,IAAI,EAAC,cAAc,EAAA,aAAA,EAAa,WAAW,EAAC,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE,EAAA,CAAI,CAC3F;QAEA,QAAQ;QACR,0BAA0B,KACzBA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EACT,IAAI,EAAC,cAAc,EACP,aAAA,EAAA,eAAe,EAC3B,KAAK,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,EAAE,EAC/B,CAAA,CACH,CACe;AAEtB,CAAC;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var styled = require('styled-components');
|
|
4
|
+
var utils = require('../../theme/utils.cjs');
|
|
5
|
+
var index = require('../../theme/index.cjs');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
10
|
+
|
|
11
|
+
const sizeMappings = {
|
|
12
|
+
lg: index.theme.sizes.md,
|
|
13
|
+
md: index.theme.sizes[5],
|
|
14
|
+
base: index.theme.sizes.base,
|
|
15
|
+
sm: index.theme.sizes[3],
|
|
16
|
+
};
|
|
17
|
+
const styleMappings = {
|
|
18
|
+
lg: 'linkLarge',
|
|
19
|
+
md: 'linkMedium',
|
|
20
|
+
base: 'link',
|
|
21
|
+
sm: 'linkSmall',
|
|
22
|
+
};
|
|
23
|
+
const UnstyledAnchor = styled__default.default.a.withConfig({ displayName: "vui--UnstyledAnchor", componentId: "vui--1af0loc" }) ``;
|
|
24
|
+
// Standard variant styling
|
|
25
|
+
const StandardAnchor = styled__default.default(UnstyledAnchor).withConfig({ displayName: "vui--StandardAnchor", componentId: "vui--k5ndq9" }) `display:inline-flex;align-items:center;cursor:pointer;transition:color 0.1s ease;text-decoration:none;padding:0 2px;${({ size }) => utils.getTextStyles(index.theme.text[styleMappings[size]])};&:focus{outline:0;border-color:${index.theme.colors.secondary.blue.dark};border-radius:${index.theme.radius.base};box-shadow:0 0 0 2px ${index.theme.colors.secondary.blue.light};}&:hover{color:${index.theme.colors.secondary.blue.dark};}svg{width:${({ size }) => sizeMappings[size]};height:${({ size }) => sizeMappings[size]};vertical-align:middle;flex-shrink:0;}`;
|
|
26
|
+
// Inherit font size and line height from parent
|
|
27
|
+
const InheritAnchor = styled__default.default(StandardAnchor).withConfig({ displayName: "vui--InheritAnchor", componentId: "vui--ut8az0" }) `font-size:inherit;line-height:inherit;`;
|
|
28
|
+
const AnchorMapping = {
|
|
29
|
+
base: StandardAnchor,
|
|
30
|
+
unstyled: UnstyledAnchor,
|
|
31
|
+
inherit: InheritAnchor,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.AnchorMapping = AnchorMapping;
|
|
35
|
+
exports.InheritAnchor = InheritAnchor;
|
|
36
|
+
exports.StandardAnchor = StandardAnchor;
|
|
37
|
+
exports.UnstyledAnchor = UnstyledAnchor;
|
|
38
|
+
//# sourceMappingURL=styled.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styled.cjs","sources":["../../../src/components/Anchor/styled.ts"],"sourcesContent":["import styled, { StyledComponent } from 'styled-components';\nimport { getTextStyles } from '../../theme/utils';\nimport { theme } from '../../theme';\nimport { AnchorProps, AnchorSize } from './types';\n\ntype StyledAnchorProps = {\n size: AnchorSize;\n};\n\nconst sizeMappings: Record<StyledAnchorProps['size'], string> = {\n lg: theme.sizes.md,\n md: theme.sizes[5],\n base: theme.sizes.base,\n sm: theme.sizes[3],\n};\n\nconst styleMappings: Record<StyledAnchorProps['size'], string> = {\n lg: 'linkLarge',\n md: 'linkMedium',\n base: 'link',\n sm: 'linkSmall',\n};\n\nexport const UnstyledAnchor = styled.a<StyledAnchorProps>``;\n\n// Standard variant styling\nexport const StandardAnchor = styled(UnstyledAnchor)<StyledAnchorProps>`\n display: inline-flex;\n align-items: center;\n\n cursor: pointer;\n transition: color 0.1s ease;\n text-decoration: none;\n padding: 0 2px;\n\n ${({ size }) => getTextStyles(theme.text[styleMappings[size]])};\n\n &:focus {\n outline: 0;\n border-color: ${theme.colors.secondary.blue.dark};\n border-radius: ${theme.radius.base};\n box-shadow: 0 0 0 2px ${theme.colors.secondary.blue.light};\n }\n\n &:hover {\n color: ${theme.colors.secondary.blue.dark};\n }\n\n svg {\n width: ${({ size }) => sizeMappings[size]};\n height: ${({ size }) => sizeMappings[size]};\n vertical-align: middle;\n flex-shrink: 0;\n }\n`;\n\n// Inherit font size and line height from parent\nexport const InheritAnchor = styled(StandardAnchor)<StyledAnchorProps>`\n font-size: inherit;\n line-height: inherit;\n`;\n\nexport const AnchorMapping: Record<\n NonNullable<AnchorProps['variant']>,\n StyledComponent<'a', any, StyledAnchorProps>\n> = {\n base: StandardAnchor,\n unstyled: UnstyledAnchor,\n inherit: InheritAnchor,\n};\n"],"names":["theme","styled","getTextStyles"],"mappings":";;;;;;;;;;AASA,MAAM,YAAY,GAA8C;AAC9D,IAAA,EAAE,EAAEA,WAAK,CAAC,KAAK,CAAC,EAAE;AAClB,IAAA,EAAE,EAAEA,WAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAClB,IAAA,IAAI,EAAEA,WAAK,CAAC,KAAK,CAAC,IAAI;AACtB,IAAA,EAAE,EAAEA,WAAK,CAAC,KAAK,CAAC,CAAC,CAAC;CACnB;AAED,MAAM,aAAa,GAA8C;AAC/D,IAAA,EAAE,EAAE,WAAW;AACf,IAAA,EAAE,EAAE,YAAY;AAChB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,EAAE,EAAE,WAAW;CAChB;MAEY,cAAc,GAAGC,uBAAM,CAAC,CAAC;AAEtC;AACa,MAAA,cAAc,GAAGA,uBAAM,CAAC,cAAc,CAAC,CAAA,UAAA,CAAA,EAAA,WAAA,EAAA,qBAAA,EAAA,WAAA,EAAA,aAAA,EAAA,CAAA,CAAA,CAAA,oHAAA,EAShD,CAAC,EAAE,IAAI,EAAE,KAAKC,mBAAa,CAACF,WAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,gCAAA,EAI5CA,WAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,kBAC/BA,WAAK,CAAC,MAAM,CAAC,IAAI,CACV,sBAAA,EAAAA,WAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAA,gBAAA,EAIhDA,WAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,eAIhC,CAAC,EAAE,IAAI,EAAE,KAAK,YAAY,CAAC,IAAI,CAAC,WAC/B,CAAC,EAAE,IAAI,EAAE,KAAK,YAAY,CAAC,IAAI,CAAC;AAM9C;MACa,aAAa,GAAGC,uBAAM,CAAC,cAAc,CAAC,CAAA,UAAA,CAAA,EAAA,WAAA,EAAA,oBAAA,EAAA,WAAA,EAAA,aAAA,EAAA,CAAA,CAAA,CAAA,sCAAA;AAKtC,MAAA,aAAa,GAGtB;AACF,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,QAAQ,EAAE,cAAc;AACxB,IAAA,OAAO,EAAE,aAAa;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StyledComponent } from 'styled-components';
|
|
2
|
+
import { AnchorProps, AnchorSize } from './types';
|
|
3
|
+
type StyledAnchorProps = {
|
|
4
|
+
size: AnchorSize;
|
|
5
|
+
};
|
|
6
|
+
export declare const UnstyledAnchor: StyledComponent<"a", any, StyledAnchorProps, never>;
|
|
7
|
+
export declare const StandardAnchor: StyledComponent<"a", any, StyledAnchorProps, never>;
|
|
8
|
+
export declare const InheritAnchor: StyledComponent<"a", any, StyledAnchorProps, never>;
|
|
9
|
+
export declare const AnchorMapping: Record<NonNullable<AnchorProps['variant']>, StyledComponent<'a', any, StyledAnchorProps>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { getTextStyles } from '../../theme/utils.js';
|
|
3
|
+
import { theme } from '../../theme/index.js';
|
|
4
|
+
|
|
5
|
+
const sizeMappings = {
|
|
6
|
+
lg: theme.sizes.md,
|
|
7
|
+
md: theme.sizes[5],
|
|
8
|
+
base: theme.sizes.base,
|
|
9
|
+
sm: theme.sizes[3],
|
|
10
|
+
};
|
|
11
|
+
const styleMappings = {
|
|
12
|
+
lg: 'linkLarge',
|
|
13
|
+
md: 'linkMedium',
|
|
14
|
+
base: 'link',
|
|
15
|
+
sm: 'linkSmall',
|
|
16
|
+
};
|
|
17
|
+
const UnstyledAnchor = styled.a.withConfig({ displayName: "vui--UnstyledAnchor", componentId: "vui--1af0loc" }) ``;
|
|
18
|
+
// Standard variant styling
|
|
19
|
+
const StandardAnchor = styled(UnstyledAnchor).withConfig({ displayName: "vui--StandardAnchor", componentId: "vui--k5ndq9" }) `display:inline-flex;align-items:center;cursor:pointer;transition:color 0.1s ease;text-decoration:none;padding:0 2px;${({ size }) => getTextStyles(theme.text[styleMappings[size]])};&:focus{outline:0;border-color:${theme.colors.secondary.blue.dark};border-radius:${theme.radius.base};box-shadow:0 0 0 2px ${theme.colors.secondary.blue.light};}&:hover{color:${theme.colors.secondary.blue.dark};}svg{width:${({ size }) => sizeMappings[size]};height:${({ size }) => sizeMappings[size]};vertical-align:middle;flex-shrink:0;}`;
|
|
20
|
+
// Inherit font size and line height from parent
|
|
21
|
+
const InheritAnchor = styled(StandardAnchor).withConfig({ displayName: "vui--InheritAnchor", componentId: "vui--ut8az0" }) `font-size:inherit;line-height:inherit;`;
|
|
22
|
+
const AnchorMapping = {
|
|
23
|
+
base: StandardAnchor,
|
|
24
|
+
unstyled: UnstyledAnchor,
|
|
25
|
+
inherit: InheritAnchor,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { AnchorMapping, InheritAnchor, StandardAnchor, UnstyledAnchor };
|
|
29
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styled.js","sources":["../../../src/components/Anchor/styled.ts"],"sourcesContent":["import styled, { StyledComponent } from 'styled-components';\nimport { getTextStyles } from '../../theme/utils';\nimport { theme } from '../../theme';\nimport { AnchorProps, AnchorSize } from './types';\n\ntype StyledAnchorProps = {\n size: AnchorSize;\n};\n\nconst sizeMappings: Record<StyledAnchorProps['size'], string> = {\n lg: theme.sizes.md,\n md: theme.sizes[5],\n base: theme.sizes.base,\n sm: theme.sizes[3],\n};\n\nconst styleMappings: Record<StyledAnchorProps['size'], string> = {\n lg: 'linkLarge',\n md: 'linkMedium',\n base: 'link',\n sm: 'linkSmall',\n};\n\nexport const UnstyledAnchor = styled.a<StyledAnchorProps>``;\n\n// Standard variant styling\nexport const StandardAnchor = styled(UnstyledAnchor)<StyledAnchorProps>`\n display: inline-flex;\n align-items: center;\n\n cursor: pointer;\n transition: color 0.1s ease;\n text-decoration: none;\n padding: 0 2px;\n\n ${({ size }) => getTextStyles(theme.text[styleMappings[size]])};\n\n &:focus {\n outline: 0;\n border-color: ${theme.colors.secondary.blue.dark};\n border-radius: ${theme.radius.base};\n box-shadow: 0 0 0 2px ${theme.colors.secondary.blue.light};\n }\n\n &:hover {\n color: ${theme.colors.secondary.blue.dark};\n }\n\n svg {\n width: ${({ size }) => sizeMappings[size]};\n height: ${({ size }) => sizeMappings[size]};\n vertical-align: middle;\n flex-shrink: 0;\n }\n`;\n\n// Inherit font size and line height from parent\nexport const InheritAnchor = styled(StandardAnchor)<StyledAnchorProps>`\n font-size: inherit;\n line-height: inherit;\n`;\n\nexport const AnchorMapping: Record<\n NonNullable<AnchorProps['variant']>,\n StyledComponent<'a', any, StyledAnchorProps>\n> = {\n base: StandardAnchor,\n unstyled: UnstyledAnchor,\n inherit: InheritAnchor,\n};\n"],"names":[],"mappings":";;;;AASA,MAAM,YAAY,GAA8C;AAC9D,IAAA,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE;AAClB,IAAA,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAClB,IAAA,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;AACtB,IAAA,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;CACnB;AAED,MAAM,aAAa,GAA8C;AAC/D,IAAA,EAAE,EAAE,WAAW;AACf,IAAA,EAAE,EAAE,YAAY;AAChB,IAAA,IAAI,EAAE,MAAM;AACZ,IAAA,EAAE,EAAE,WAAW;CAChB;MAEY,cAAc,GAAG,MAAM,CAAC,CAAC;AAEtC;AACa,MAAA,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA,UAAA,CAAA,EAAA,WAAA,EAAA,qBAAA,EAAA,WAAA,EAAA,aAAA,EAAA,CAAA,CAAA,CAAA,oHAAA,EAShD,CAAC,EAAE,IAAI,EAAE,KAAK,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,gCAAA,EAI5C,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,kBAC/B,KAAK,CAAC,MAAM,CAAC,IAAI,CACV,sBAAA,EAAA,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAA,gBAAA,EAIhD,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,eAIhC,CAAC,EAAE,IAAI,EAAE,KAAK,YAAY,CAAC,IAAI,CAAC,WAC/B,CAAC,EAAE,IAAI,EAAE,KAAK,YAAY,CAAC,IAAI,CAAC;AAM9C;MACa,aAAa,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA,UAAA,CAAA,EAAA,WAAA,EAAA,oBAAA,EAAA,WAAA,EAAA,aAAA,EAAA,CAAA,CAAA,CAAA,sCAAA;AAKtC,MAAA,aAAa,GAGtB;AACF,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,QAAQ,EAAE,cAAc;AACxB,IAAA,OAAO,EAAE,aAAa;;;;;"}
|
|
@@ -3,21 +3,38 @@
|
|
|
3
3
|
var reactTransitionGroup = require('react-transition-group');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactDom = require('react-dom');
|
|
6
|
-
var styled = require('./components/styled.cjs');
|
|
7
6
|
var Toast = require('./components/Toast.cjs');
|
|
7
|
+
var FlexCol = require('../Flex/FlexCol/FlexCol.cjs');
|
|
8
|
+
var toastsLayout_module = require('./toastsLayout.module.scss.cjs');
|
|
8
9
|
|
|
9
10
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
10
11
|
|
|
11
12
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* ToastsLayout displays toast notifications in a fixed position at the bottom of the screen.
|
|
16
|
+
* Toasts are rendered in a portal and support animations, auto-dismissal, and custom CTAs.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* <ToastsLayout
|
|
21
|
+
* toasts={[{ id: '1', type: 'success', message: 'Saved!' }]}
|
|
22
|
+
* onClose={(id) => removeToast(id)}
|
|
23
|
+
* max={3}
|
|
24
|
+
* />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const ToastsLayout = ({ e2eClassName, toasts, minWidth = '50vw', max = 3, portalTarget = document.body, onClose, }) => {
|
|
14
28
|
React.useEffect(() => {
|
|
15
|
-
if (max && toasts.length > max)
|
|
16
|
-
onClose(toasts[0].
|
|
29
|
+
if (max && toasts.length > max) {
|
|
30
|
+
onClose(toasts[0].id);
|
|
31
|
+
}
|
|
17
32
|
}, [toasts, max, onClose]);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
const containerAriaLabel = `${toasts.length} notification${toasts.length !== 1 ? 's' : ''}.`;
|
|
34
|
+
const content = (React__default.default.createElement(FlexCol.FlexCol, { className: toastsLayout_module.toastsLayoutContainer, alignItems: "center", gap: 4, role: "region", "aria-label": containerAriaLabel },
|
|
35
|
+
React__default.default.createElement(reactTransitionGroup.TransitionGroup, { component: null }, [...toasts].reverse().map((toast, index) => (React__default.default.createElement(reactTransitionGroup.CSSTransition, { key: toast.id, timeout: 225, classNames: "veeqo-components-toast" },
|
|
36
|
+
React__default.default.createElement(Toast.Toast, { e2eClassName: e2eClassName, minWidth: minWidth, last: index === toasts.length - 1, onClose: () => onClose(toast.id), ...toast })))))));
|
|
37
|
+
return reactDom.createPortal(content, portalTarget);
|
|
21
38
|
};
|
|
22
39
|
|
|
23
40
|
exports.ToastsLayout = ToastsLayout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastsLayout.cjs","sources":["../../../src/components/ToastsLayout/ToastsLayout.tsx"],"sourcesContent":["import { CSSTransition, TransitionGroup } from 'react-transition-group';\nimport React, { useEffect, FC } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ToastsLayoutPropTypes } from './types';\nimport {
|
|
1
|
+
{"version":3,"file":"ToastsLayout.cjs","sources":["../../../src/components/ToastsLayout/ToastsLayout.tsx"],"sourcesContent":["import { CSSTransition, TransitionGroup } from 'react-transition-group';\nimport React, { useEffect, FC } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ToastsLayoutPropTypes } from './types';\nimport { Toast } from './components/Toast';\nimport { FlexCol } from '../Flex/FlexCol';\nimport styles from './toastsLayout.module.scss';\n\n/**\n * ToastsLayout displays toast notifications in a fixed position at the bottom of the screen.\n * Toasts are rendered in a portal and support animations, auto-dismissal, and custom CTAs.\n *\n * @example\n * ```tsx\n * <ToastsLayout\n * toasts={[{ id: '1', type: 'success', message: 'Saved!' }]}\n * onClose={(id) => removeToast(id)}\n * max={3}\n * />\n * ```\n */\nexport const ToastsLayout: FC<ToastsLayoutPropTypes> = ({\n e2eClassName,\n toasts,\n minWidth = '50vw',\n max = 3,\n portalTarget = document.body,\n onClose,\n}) => {\n useEffect(() => {\n if (max && toasts.length > max) {\n onClose(toasts[0].id);\n }\n }, [toasts, max, onClose]);\n\n const containerAriaLabel = `${toasts.length} notification${toasts.length !== 1 ? 's' : ''}.`;\n\n const content = (\n <FlexCol\n className={styles.toastsLayoutContainer}\n alignItems=\"center\"\n gap={4}\n role=\"region\"\n aria-label={containerAriaLabel}\n >\n <TransitionGroup component={null}>\n {[...toasts].reverse().map((toast, index) => (\n <CSSTransition key={toast.id} timeout={225} classNames=\"veeqo-components-toast\">\n <Toast\n e2eClassName={e2eClassName}\n minWidth={minWidth}\n last={index === toasts.length - 1}\n onClose={() => onClose(toast.id)}\n {...toast}\n />\n </CSSTransition>\n ))}\n </TransitionGroup>\n </FlexCol>\n );\n\n return createPortal(content, portalTarget);\n};\n"],"names":["useEffect","React","FlexCol","styles","TransitionGroup","CSSTransition","Toast","createPortal"],"mappings":";;;;;;;;;;;;;AAQA;;;;;;;;;;;;AAYG;AACU,MAAA,YAAY,GAA8B,CAAC,EACtD,YAAY,EACZ,MAAM,EACN,QAAQ,GAAG,MAAM,EACjB,GAAG,GAAG,CAAC,EACP,YAAY,GAAG,QAAQ,CAAC,IAAI,EAC5B,OAAO,GACR,KAAI;IACHA,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YAC9B,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtB;KACF,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAE1B,MAAM,kBAAkB,GAAG,CAAG,EAAA,MAAM,CAAC,MAAM,CAAA,aAAA,EAAgB,MAAM,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA,CAAA,CAAG;IAE5F,MAAM,OAAO,IACXC,sBAAC,CAAA,aAAA,CAAAC,eAAO,IACN,SAAS,EAAEC,mBAAM,CAAC,qBAAqB,EACvC,UAAU,EAAC,QAAQ,EACnB,GAAG,EAAE,CAAC,EACN,IAAI,EAAC,QAAQ,EAAA,YAAA,EACD,kBAAkB,EAAA;AAE9B,QAAAF,sBAAA,CAAA,aAAA,CAACG,oCAAe,EAAC,EAAA,SAAS,EAAE,IAAI,IAC7B,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,MACtCH,qCAACI,kCAAa,EAAA,EAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAC,wBAAwB,EAAA;AAC7E,YAAAJ,sBAAA,CAAA,aAAA,CAACK,WAAK,EACJ,EAAA,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,EACjC,OAAO,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAC5B,GAAA,KAAK,GACT,CACY,CACjB,CAAC,CACc,CACV,CACX;AAED,IAAA,OAAOC,qBAAY,CAAC,OAAO,EAAE,YAAY,CAAC;AAC5C;;;;"}
|
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { ToastsLayoutPropTypes } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* ToastsLayout displays toast notifications in a fixed position at the bottom of the screen.
|
|
5
|
+
* Toasts are rendered in a portal and support animations, auto-dismissal, and custom CTAs.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <ToastsLayout
|
|
10
|
+
* toasts={[{ id: '1', type: 'success', message: 'Saved!' }]}
|
|
11
|
+
* onClose={(id) => removeToast(id)}
|
|
12
|
+
* max={3}
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
3
16
|
export declare const ToastsLayout: FC<ToastsLayoutPropTypes>;
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
|
2
2
|
import React__default, { useEffect } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import { ToastsLayoutContainer } from './components/styled.js';
|
|
5
4
|
import { Toast } from './components/Toast.js';
|
|
5
|
+
import { FlexCol } from '../Flex/FlexCol/FlexCol.js';
|
|
6
|
+
import styles from './toastsLayout.module.scss.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* ToastsLayout displays toast notifications in a fixed position at the bottom of the screen.
|
|
10
|
+
* Toasts are rendered in a portal and support animations, auto-dismissal, and custom CTAs.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <ToastsLayout
|
|
15
|
+
* toasts={[{ id: '1', type: 'success', message: 'Saved!' }]}
|
|
16
|
+
* onClose={(id) => removeToast(id)}
|
|
17
|
+
* max={3}
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const ToastsLayout = ({ e2eClassName, toasts, minWidth = '50vw', max = 3, portalTarget = document.body, onClose, }) => {
|
|
8
22
|
useEffect(() => {
|
|
9
|
-
if (max && toasts.length > max)
|
|
10
|
-
onClose(toasts[0].
|
|
23
|
+
if (max && toasts.length > max) {
|
|
24
|
+
onClose(toasts[0].id);
|
|
25
|
+
}
|
|
11
26
|
}, [toasts, max, onClose]);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
const containerAriaLabel = `${toasts.length} notification${toasts.length !== 1 ? 's' : ''}.`;
|
|
28
|
+
const content = (React__default.createElement(FlexCol, { className: styles.toastsLayoutContainer, alignItems: "center", gap: 4, role: "region", "aria-label": containerAriaLabel },
|
|
29
|
+
React__default.createElement(TransitionGroup, { component: null }, [...toasts].reverse().map((toast, index) => (React__default.createElement(CSSTransition, { key: toast.id, timeout: 225, classNames: "veeqo-components-toast" },
|
|
30
|
+
React__default.createElement(Toast, { e2eClassName: e2eClassName, minWidth: minWidth, last: index === toasts.length - 1, onClose: () => onClose(toast.id), ...toast })))))));
|
|
31
|
+
return createPortal(content, portalTarget);
|
|
15
32
|
};
|
|
16
33
|
|
|
17
34
|
export { ToastsLayout };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastsLayout.js","sources":["../../../src/components/ToastsLayout/ToastsLayout.tsx"],"sourcesContent":["import { CSSTransition, TransitionGroup } from 'react-transition-group';\nimport React, { useEffect, FC } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ToastsLayoutPropTypes } from './types';\nimport {
|
|
1
|
+
{"version":3,"file":"ToastsLayout.js","sources":["../../../src/components/ToastsLayout/ToastsLayout.tsx"],"sourcesContent":["import { CSSTransition, TransitionGroup } from 'react-transition-group';\nimport React, { useEffect, FC } from 'react';\nimport { createPortal } from 'react-dom';\nimport { ToastsLayoutPropTypes } from './types';\nimport { Toast } from './components/Toast';\nimport { FlexCol } from '../Flex/FlexCol';\nimport styles from './toastsLayout.module.scss';\n\n/**\n * ToastsLayout displays toast notifications in a fixed position at the bottom of the screen.\n * Toasts are rendered in a portal and support animations, auto-dismissal, and custom CTAs.\n *\n * @example\n * ```tsx\n * <ToastsLayout\n * toasts={[{ id: '1', type: 'success', message: 'Saved!' }]}\n * onClose={(id) => removeToast(id)}\n * max={3}\n * />\n * ```\n */\nexport const ToastsLayout: FC<ToastsLayoutPropTypes> = ({\n e2eClassName,\n toasts,\n minWidth = '50vw',\n max = 3,\n portalTarget = document.body,\n onClose,\n}) => {\n useEffect(() => {\n if (max && toasts.length > max) {\n onClose(toasts[0].id);\n }\n }, [toasts, max, onClose]);\n\n const containerAriaLabel = `${toasts.length} notification${toasts.length !== 1 ? 's' : ''}.`;\n\n const content = (\n <FlexCol\n className={styles.toastsLayoutContainer}\n alignItems=\"center\"\n gap={4}\n role=\"region\"\n aria-label={containerAriaLabel}\n >\n <TransitionGroup component={null}>\n {[...toasts].reverse().map((toast, index) => (\n <CSSTransition key={toast.id} timeout={225} classNames=\"veeqo-components-toast\">\n <Toast\n e2eClassName={e2eClassName}\n minWidth={minWidth}\n last={index === toasts.length - 1}\n onClose={() => onClose(toast.id)}\n {...toast}\n />\n </CSSTransition>\n ))}\n </TransitionGroup>\n </FlexCol>\n );\n\n return createPortal(content, portalTarget);\n};\n"],"names":["React"],"mappings":";;;;;;;AAQA;;;;;;;;;;;;AAYG;AACU,MAAA,YAAY,GAA8B,CAAC,EACtD,YAAY,EACZ,MAAM,EACN,QAAQ,GAAG,MAAM,EACjB,GAAG,GAAG,CAAC,EACP,YAAY,GAAG,QAAQ,CAAC,IAAI,EAC5B,OAAO,GACR,KAAI;IACH,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YAC9B,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtB;KACF,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAE1B,MAAM,kBAAkB,GAAG,CAAG,EAAA,MAAM,CAAC,MAAM,CAAA,aAAA,EAAgB,MAAM,CAAC,MAAM,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,CAAA,CAAA,CAAG;IAE5F,MAAM,OAAO,IACXA,cAAC,CAAA,aAAA,CAAA,OAAO,IACN,SAAS,EAAE,MAAM,CAAC,qBAAqB,EACvC,UAAU,EAAC,QAAQ,EACnB,GAAG,EAAE,CAAC,EACN,IAAI,EAAC,QAAQ,EAAA,YAAA,EACD,kBAAkB,EAAA;AAE9B,QAAAA,cAAA,CAAA,aAAA,CAAC,eAAe,EAAC,EAAA,SAAS,EAAE,IAAI,IAC7B,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,MACtCA,6BAAC,aAAa,EAAA,EAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAC,wBAAwB,EAAA;AAC7E,YAAAA,cAAA,CAAA,aAAA,CAAC,KAAK,EACJ,EAAA,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,EACjC,OAAO,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAC5B,GAAA,KAAK,GACT,CACY,CACjB,CAAC,CACc,CACV,CACX;AAED,IAAA,OAAO,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC;AAC5C;;;;"}
|
|
@@ -1,52 +1,37 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var FlexCol = require('../../Flex/FlexCol/FlexCol.cjs');
|
|
5
|
+
var FlexRow = require('../../Flex/FlexRow/FlexRow.cjs');
|
|
6
|
+
var Text = require('../../Text/Text.cjs');
|
|
6
7
|
var buildClassnames = require('../../../utils/buildClassnames.cjs');
|
|
7
8
|
var Button = require('../../Button/Button.cjs');
|
|
8
|
-
var AttentionIcon = require('../../../icons/design-system/components/AttentionIcon.cjs');
|
|
9
9
|
var CrossIcon = require('../../../icons/design-system/components/CrossIcon.cjs');
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
10
|
+
var toast_module = require('./toast.module.scss.cjs');
|
|
11
|
+
var utils = require('./utils.cjs');
|
|
12
|
+
var constants = require('./constants.cjs');
|
|
13
13
|
|
|
14
14
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
15
15
|
|
|
16
16
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
const generateClassNames = (prefix) => ({
|
|
37
|
-
container: prefix ? `${prefix}-toast-container` : undefined,
|
|
38
|
-
icon: prefix ? `${prefix}-toast-icon` : undefined,
|
|
39
|
-
closeIcon: prefix ? `${prefix}-toast-close-icon` : undefined,
|
|
40
|
-
});
|
|
41
|
-
const Toast = ({ className, e2eClassName, type, iconSlot, text, last, minWidth, cta, onClose, }) => {
|
|
42
|
-
const classNames = generateClassNames(className);
|
|
43
|
-
const e2eClassNames = generateClassNames(e2eClassName);
|
|
44
|
-
return (React__default.default.createElement(styled.Toast, { className: buildClassnames.buildClassnames([classNames === null || classNames === undefined ? undefined : classNames.container, e2eClassNames === null || e2eClassNames === undefined ? undefined : e2eClassNames.container]), direction: "horizontal", alignY: "center", minWidth: minWidth, last: last },
|
|
45
|
-
React__default.default.createElement(styled.IconWrap, { color: toastTypes[type].accentColor, className: buildClassnames.buildClassnames([classNames.icon, e2eClassNames.icon]) }, iconSlot !== null && iconSlot !== undefined ? iconSlot : toastTypes[type].icon),
|
|
46
|
-
React__default.default.createElement(styled.ContentStack, { direction: "horizontal", alignY: "center", alignX: "between" },
|
|
47
|
-
React__default.default.createElement(styled.StyledText, { variant: "body" }, text),
|
|
48
|
-
cta),
|
|
49
|
-
React__default.default.createElement(Button.Button, { variant: "flat", iconSlot: React__default.default.createElement(CrossIcon.ReactComponent, { color: "white" }), onClick: onClose, "aria-label": "Close" })));
|
|
18
|
+
const Toast = ({ e2eClassName, type, iconSlot, message, subMessage, last, minWidth, ctaSlot, onClose, }) => {
|
|
19
|
+
var _a;
|
|
20
|
+
const e2eClassNames = utils.generateToastClassNames(e2eClassName);
|
|
21
|
+
// Default to Info icon
|
|
22
|
+
const { accentColor, icon } = (_a = constants.ToastTypeConfig[type]) !== null && _a !== undefined ? _a : constants.ToastTypeConfig.info;
|
|
23
|
+
const resolvedIcon = iconSlot !== null && iconSlot !== undefined ? iconSlot : icon;
|
|
24
|
+
return (React__default.default.createElement(FlexRow.FlexRow, { className: buildClassnames.buildClassnames([toast_module.toastContainer, e2eClassNames === null || e2eClassNames === undefined ? undefined : e2eClassNames.container]), alignItems: "center", style: {
|
|
25
|
+
'--toast-min-width': minWidth !== null && minWidth !== undefined ? minWidth : undefined,
|
|
26
|
+
'--toast-status-color': accentColor,
|
|
27
|
+
}, "data-toast-last": last !== null && last !== undefined ? last : undefined, gap: "base", role: "alert" },
|
|
28
|
+
resolvedIcon && (React__default.default.createElement(FlexRow.FlexRow, { className: buildClassnames.buildClassnames([toast_module.iconWrapper, e2eClassNames.icon]), alignItems: "center", justifyContent: "center" }, resolvedIcon)),
|
|
29
|
+
React__default.default.createElement(FlexRow.FlexRow, { alignItems: "center", flexGrow: 1, justifyContent: "space-between" },
|
|
30
|
+
React__default.default.createElement(FlexCol.FlexCol, { gap: "none" },
|
|
31
|
+
React__default.default.createElement(Text.Text, { className: toast_module.toastText, variant: "headingSmall", as: "p" }, message),
|
|
32
|
+
subMessage && (React__default.default.createElement(Text.Text, { className: toast_module.toastText, variant: "body", as: "p" }, subMessage))),
|
|
33
|
+
ctaSlot),
|
|
34
|
+
React__default.default.createElement(Button.Button, { className: buildClassnames.buildClassnames([toast_module.toastCloseButton, e2eClassNames === null || e2eClassNames === undefined ? undefined : e2eClassNames.closeIcon]), variant: "flat", iconSlot: React__default.default.createElement(CrossIcon.ReactComponent, { color: "#fff" }), onClick: onClose, "aria-label": "Close" })));
|
|
50
35
|
};
|
|
51
36
|
|
|
52
37
|
exports.Toast = Toast;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.cjs","sources":["../../../../src/components/ToastsLayout/components/Toast.tsx"],"sourcesContent":["import React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"Toast.cjs","sources":["../../../../src/components/ToastsLayout/components/Toast.tsx"],"sourcesContent":["import React from 'react';\nimport { FlexCol } from '../../Flex/FlexCol';\nimport { FlexRow } from '../../Flex/FlexRow';\nimport { Text } from '../../Text';\nimport { ToastPropTypes } from '../types';\nimport { buildClassnames } from '../../../utils/buildClassnames';\nimport { Button } from '../../Button';\nimport { CrossIcon } from '../../../icons';\nimport styles from './toast.module.scss';\nimport { generateToastClassNames } from './utils';\nimport { ToastTypeConfig } from './constants';\n\nexport const Toast = ({\n e2eClassName,\n type,\n iconSlot,\n message,\n subMessage,\n last,\n minWidth,\n ctaSlot,\n onClose,\n}: ToastPropTypes) => {\n const e2eClassNames = generateToastClassNames(e2eClassName);\n\n // Default to Info icon\n const { accentColor, icon } = ToastTypeConfig[type] ?? ToastTypeConfig.info;\n\n const resolvedIcon = iconSlot ?? icon;\n\n return (\n <FlexRow\n className={buildClassnames([styles.toastContainer, e2eClassNames?.container])}\n alignItems=\"center\"\n style={\n {\n '--toast-min-width': minWidth ?? undefined,\n '--toast-status-color': accentColor,\n } as React.CSSProperties\n }\n data-toast-last={last ?? undefined}\n gap=\"base\"\n role=\"alert\"\n >\n {resolvedIcon && (\n <FlexRow\n className={buildClassnames([styles.iconWrapper, e2eClassNames.icon])}\n alignItems=\"center\"\n justifyContent=\"center\"\n >\n {resolvedIcon}\n </FlexRow>\n )}\n <FlexRow alignItems=\"center\" flexGrow={1} justifyContent=\"space-between\">\n <FlexCol gap=\"none\">\n <Text className={styles.toastText} variant=\"headingSmall\" as=\"p\">\n {message}\n </Text>\n {subMessage && (\n <Text className={styles.toastText} variant=\"body\" as=\"p\">\n {subMessage}\n </Text>\n )}\n </FlexCol>\n {ctaSlot}\n </FlexRow>\n <Button\n className={buildClassnames([styles.toastCloseButton, e2eClassNames?.closeIcon])}\n variant=\"flat\"\n iconSlot={<CrossIcon color=\"#fff\" />}\n onClick={onClose}\n aria-label=\"Close\"\n />\n </FlexRow>\n );\n};\n"],"names":["generateToastClassNames","ToastTypeConfig","React","FlexRow","buildClassnames","styles","FlexCol","Text","Button","CrossIcon"],"mappings":";;;;;;;;;;;;;;;;;AAYa,MAAA,KAAK,GAAG,CAAC,EACpB,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,OAAO,GACQ,KAAI;;AACnB,IAAA,MAAM,aAAa,GAAGA,6BAAuB,CAAC,YAAY,CAAC;;AAG3D,IAAA,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,CAAA,EAAA,GAAAC,yBAAe,CAAC,IAAI,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,EAAA,GAAIA,yBAAe,CAAC,IAAI;IAE3E,MAAM,YAAY,GAAG,QAAQ,KAAA,IAAA,IAAR,QAAQ,KAAR,SAAA,GAAA,QAAQ,GAAI,IAAI;AAErC,IAAA,QACEC,sBAAA,CAAA,aAAA,CAACC,eAAO,EAAA,EACN,SAAS,EAAEC,+BAAe,CAAC,CAACC,YAAM,CAAC,cAAc,EAAE,aAAa,KAAb,IAAA,IAAA,aAAa,KAAb,SAAA,GAAA,SAAA,GAAA,aAAa,CAAE,SAAS,CAAC,CAAC,EAC7E,UAAU,EAAC,QAAQ,EACnB,KAAK,EACH;AACE,YAAA,mBAAmB,EAAE,QAAQ,KAAA,IAAA,IAAR,QAAQ,KAAR,SAAA,GAAA,QAAQ,GAAI,SAAS;AAC1C,YAAA,sBAAsB,EAAE,WAAW;AACb,SAAA,EAAA,iBAAA,EAET,IAAI,KAAA,IAAA,IAAJ,IAAI,KAAA,SAAA,GAAJ,IAAI,GAAI,SAAS,EAClC,GAAG,EAAC,MAAM,EACV,IAAI,EAAC,OAAO,EAAA;AAEX,QAAA,YAAY,KACXH,sBAAC,CAAA,aAAA,CAAAC,eAAO,EACN,EAAA,SAAS,EAAEC,+BAAe,CAAC,CAACC,YAAM,CAAC,WAAW,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,EACpE,UAAU,EAAC,QAAQ,EACnB,cAAc,EAAC,QAAQ,EAEtB,EAAA,YAAY,CACL,CACX;AACD,QAAAH,sBAAA,CAAA,aAAA,CAACC,eAAO,EAAA,EAAC,UAAU,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,EAAE,cAAc,EAAC,eAAe,EAAA;AACtE,YAAAD,sBAAA,CAAA,aAAA,CAACI,eAAO,EAAA,EAAC,GAAG,EAAC,MAAM,EAAA;AACjB,gBAAAJ,sBAAA,CAAA,aAAA,CAACK,SAAI,EAAC,EAAA,SAAS,EAAEF,YAAM,CAAC,SAAS,EAAE,OAAO,EAAC,cAAc,EAAC,EAAE,EAAC,GAAG,EAAA,EAC7D,OAAO,CACH;gBACN,UAAU,KACTH,sBAAC,CAAA,aAAA,CAAAK,SAAI,IAAC,SAAS,EAAEF,YAAM,CAAC,SAAS,EAAE,OAAO,EAAC,MAAM,EAAC,EAAE,EAAC,GAAG,EACrD,EAAA,UAAU,CACN,CACR,CACO;AACT,YAAA,OAAO,CACA;AACV,QAAAH,sBAAA,CAAA,aAAA,CAACM,aAAM,EACL,EAAA,SAAS,EAAEJ,+BAAe,CAAC,CAACC,YAAM,CAAC,gBAAgB,EAAE,aAAa,aAAb,aAAa,KAAA,SAAA,GAAA,SAAA,GAAb,aAAa,CAAE,SAAS,CAAC,CAAC,EAC/E,OAAO,EAAC,MAAM,EACd,QAAQ,EAAEH,qCAACO,wBAAS,EAAA,EAAC,KAAK,EAAC,MAAM,GAAG,EACpC,OAAO,EAAE,OAAO,EAAA,YAAA,EACL,OAAO,EAClB,CAAA,CACM;AAEd;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ToastPropTypes } from '../types';
|
|
3
|
-
export declare const Toast: ({
|
|
3
|
+
export declare const Toast: ({ e2eClassName, type, iconSlot, message, subMessage, last, minWidth, ctaSlot, onClose, }: ToastPropTypes) => React.JSX.Element;
|
|
@@ -1,46 +1,31 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FlexCol } from '../../Flex/FlexCol/FlexCol.js';
|
|
3
|
+
import { FlexRow } from '../../Flex/FlexRow/FlexRow.js';
|
|
4
|
+
import { Text } from '../../Text/Text.js';
|
|
4
5
|
import { buildClassnames } from '../../../utils/buildClassnames.js';
|
|
5
6
|
import { Button } from '../../Button/Button.js';
|
|
6
|
-
import { ReactComponent as AttentionIcon } from '../../../icons/design-system/components/AttentionIcon.js';
|
|
7
7
|
import { ReactComponent as CrossIcon } from '../../../icons/design-system/components/CrossIcon.js';
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import styles from './toast.module.scss.js';
|
|
9
|
+
import { generateToastClassNames } from './utils.js';
|
|
10
|
+
import { ToastTypeConfig } from './constants.js';
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
const generateClassNames = (prefix) => ({
|
|
31
|
-
container: prefix ? `${prefix}-toast-container` : undefined,
|
|
32
|
-
icon: prefix ? `${prefix}-toast-icon` : undefined,
|
|
33
|
-
closeIcon: prefix ? `${prefix}-toast-close-icon` : undefined,
|
|
34
|
-
});
|
|
35
|
-
const Toast = ({ className, e2eClassName, type, iconSlot, text, last, minWidth, cta, onClose, }) => {
|
|
36
|
-
const classNames = generateClassNames(className);
|
|
37
|
-
const e2eClassNames = generateClassNames(e2eClassName);
|
|
38
|
-
return (React__default.createElement(Toast$1, { className: buildClassnames([classNames === null || classNames === undefined ? undefined : classNames.container, e2eClassNames === null || e2eClassNames === undefined ? undefined : e2eClassNames.container]), direction: "horizontal", alignY: "center", minWidth: minWidth, last: last },
|
|
39
|
-
React__default.createElement(IconWrap, { color: toastTypes[type].accentColor, className: buildClassnames([classNames.icon, e2eClassNames.icon]) }, iconSlot !== null && iconSlot !== undefined ? iconSlot : toastTypes[type].icon),
|
|
40
|
-
React__default.createElement(ContentStack, { direction: "horizontal", alignY: "center", alignX: "between" },
|
|
41
|
-
React__default.createElement(StyledText, { variant: "body" }, text),
|
|
42
|
-
cta),
|
|
43
|
-
React__default.createElement(Button, { variant: "flat", iconSlot: React__default.createElement(CrossIcon, { color: "white" }), onClick: onClose, "aria-label": "Close" })));
|
|
12
|
+
const Toast = ({ e2eClassName, type, iconSlot, message, subMessage, last, minWidth, ctaSlot, onClose, }) => {
|
|
13
|
+
var _a;
|
|
14
|
+
const e2eClassNames = generateToastClassNames(e2eClassName);
|
|
15
|
+
// Default to Info icon
|
|
16
|
+
const { accentColor, icon } = (_a = ToastTypeConfig[type]) !== null && _a !== undefined ? _a : ToastTypeConfig.info;
|
|
17
|
+
const resolvedIcon = iconSlot !== null && iconSlot !== undefined ? iconSlot : icon;
|
|
18
|
+
return (React__default.createElement(FlexRow, { className: buildClassnames([styles.toastContainer, e2eClassNames === null || e2eClassNames === undefined ? undefined : e2eClassNames.container]), alignItems: "center", style: {
|
|
19
|
+
'--toast-min-width': minWidth !== null && minWidth !== undefined ? minWidth : undefined,
|
|
20
|
+
'--toast-status-color': accentColor,
|
|
21
|
+
}, "data-toast-last": last !== null && last !== undefined ? last : undefined, gap: "base", role: "alert" },
|
|
22
|
+
resolvedIcon && (React__default.createElement(FlexRow, { className: buildClassnames([styles.iconWrapper, e2eClassNames.icon]), alignItems: "center", justifyContent: "center" }, resolvedIcon)),
|
|
23
|
+
React__default.createElement(FlexRow, { alignItems: "center", flexGrow: 1, justifyContent: "space-between" },
|
|
24
|
+
React__default.createElement(FlexCol, { gap: "none" },
|
|
25
|
+
React__default.createElement(Text, { className: styles.toastText, variant: "headingSmall", as: "p" }, message),
|
|
26
|
+
subMessage && (React__default.createElement(Text, { className: styles.toastText, variant: "body", as: "p" }, subMessage))),
|
|
27
|
+
ctaSlot),
|
|
28
|
+
React__default.createElement(Button, { className: buildClassnames([styles.toastCloseButton, e2eClassNames === null || e2eClassNames === undefined ? undefined : e2eClassNames.closeIcon]), variant: "flat", iconSlot: React__default.createElement(CrossIcon, { color: "#fff" }), onClick: onClose, "aria-label": "Close" })));
|
|
44
29
|
};
|
|
45
30
|
|
|
46
31
|
export { Toast };
|