@metamask/design-system-react 0.25.0 → 0.26.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/CHANGELOG.md +20 -1
- package/dist/components/AvatarIcon/AvatarIcon.constants.cjs +2 -2
- package/dist/components/AvatarIcon/AvatarIcon.constants.cjs.map +1 -1
- package/dist/components/AvatarIcon/AvatarIcon.constants.mjs +2 -2
- package/dist/components/AvatarIcon/AvatarIcon.constants.mjs.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.cjs +1 -2
- package/dist/components/AvatarNetwork/AvatarNetwork.cjs.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.d.cts.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.d.mts.map +1 -1
- package/dist/components/AvatarNetwork/AvatarNetwork.mjs +1 -2
- package/dist/components/AvatarNetwork/AvatarNetwork.mjs.map +1 -1
- package/dist/components/AvatarNetwork/index.cjs +2 -2
- package/dist/components/AvatarNetwork/index.cjs.map +1 -1
- package/dist/components/AvatarNetwork/index.d.cts +1 -1
- package/dist/components/AvatarNetwork/index.d.cts.map +1 -1
- package/dist/components/AvatarNetwork/index.d.mts +1 -1
- package/dist/components/AvatarNetwork/index.d.mts.map +1 -1
- package/dist/components/AvatarNetwork/index.mjs +1 -1
- package/dist/components/AvatarNetwork/index.mjs.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.cjs +1 -2
- package/dist/components/BannerAlert/BannerAlert.cjs.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.cjs +8 -9
- package/dist/components/BannerAlert/BannerAlert.constants.cjs.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.d.cts +1 -2
- package/dist/components/BannerAlert/BannerAlert.constants.d.cts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.d.mts +1 -2
- package/dist/components/BannerAlert/BannerAlert.constants.d.mts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.constants.mjs +1 -2
- package/dist/components/BannerAlert/BannerAlert.constants.mjs.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.d.cts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.d.mts.map +1 -1
- package/dist/components/BannerAlert/BannerAlert.mjs +1 -2
- package/dist/components/BannerAlert/BannerAlert.mjs.map +1 -1
- package/dist/components/Icon/Icon.cjs +2 -2
- package/dist/components/Icon/Icon.cjs.map +1 -1
- package/dist/components/Icon/Icon.constants.cjs +6 -6
- package/dist/components/Icon/Icon.constants.cjs.map +1 -1
- package/dist/components/Icon/Icon.constants.d.cts +1 -1
- package/dist/components/Icon/Icon.constants.d.cts.map +1 -1
- package/dist/components/Icon/Icon.constants.d.mts +1 -1
- package/dist/components/Icon/Icon.constants.d.mts.map +1 -1
- package/dist/components/Icon/Icon.constants.mjs +1 -1
- package/dist/components/Icon/Icon.constants.mjs.map +1 -1
- package/dist/components/Icon/Icon.d.cts.map +1 -1
- package/dist/components/Icon/Icon.d.mts.map +1 -1
- package/dist/components/Icon/Icon.mjs +1 -1
- package/dist/components/Icon/Icon.mjs.map +1 -1
- package/dist/components/Icon/index.cjs +4 -4
- package/dist/components/Icon/index.cjs.map +1 -1
- package/dist/components/Icon/index.d.cts +1 -1
- package/dist/components/Icon/index.d.cts.map +1 -1
- package/dist/components/Icon/index.d.mts +1 -1
- package/dist/components/Icon/index.d.mts.map +1 -1
- package/dist/components/Icon/index.mjs +1 -1
- package/dist/components/Icon/index.mjs.map +1 -1
- package/dist/components/Tag/Tag.cjs +51 -0
- package/dist/components/Tag/Tag.cjs.map +1 -0
- package/dist/components/Tag/Tag.constants.cjs +26 -0
- package/dist/components/Tag/Tag.constants.cjs.map +1 -0
- package/dist/components/Tag/Tag.constants.d.cts +5 -0
- package/dist/components/Tag/Tag.constants.d.cts.map +1 -0
- package/dist/components/Tag/Tag.constants.d.mts +5 -0
- package/dist/components/Tag/Tag.constants.d.mts.map +1 -0
- package/dist/components/Tag/Tag.constants.mjs +23 -0
- package/dist/components/Tag/Tag.constants.mjs.map +1 -0
- package/dist/components/Tag/Tag.d.cts +4 -0
- package/dist/components/Tag/Tag.d.cts.map +1 -0
- package/dist/components/Tag/Tag.d.mts +4 -0
- package/dist/components/Tag/Tag.d.mts.map +1 -0
- package/dist/components/Tag/Tag.mjs +32 -0
- package/dist/components/Tag/Tag.mjs.map +1 -0
- package/dist/components/Tag/Tag.types.cjs +3 -0
- package/dist/components/Tag/Tag.types.cjs.map +1 -0
- package/dist/components/Tag/Tag.types.d.cts +31 -0
- package/dist/components/Tag/Tag.types.d.cts.map +1 -0
- package/dist/components/Tag/Tag.types.d.mts +31 -0
- package/dist/components/Tag/Tag.types.d.mts.map +1 -0
- package/dist/components/Tag/Tag.types.mjs +2 -0
- package/dist/components/Tag/Tag.types.mjs.map +1 -0
- package/dist/components/Tag/index.cjs +8 -0
- package/dist/components/Tag/index.cjs.map +1 -0
- package/dist/components/Tag/index.d.cts +4 -0
- package/dist/components/Tag/index.d.cts.map +1 -0
- package/dist/components/Tag/index.d.mts +4 -0
- package/dist/components/Tag/index.d.mts.map +1 -0
- package/dist/components/Tag/index.mjs +3 -0
- package/dist/components/Tag/index.mjs.map +1 -0
- package/dist/components/TextButton/TextButton.cjs +7 -28
- package/dist/components/TextButton/TextButton.cjs.map +1 -1
- package/dist/components/TextButton/TextButton.d.cts.map +1 -1
- package/dist/components/TextButton/TextButton.d.mts.map +1 -1
- package/dist/components/TextButton/TextButton.mjs +7 -28
- package/dist/components/TextButton/TextButton.mjs.map +1 -1
- package/dist/components/TextButton/TextButton.types.cjs.map +1 -1
- package/dist/components/TextButton/TextButton.types.d.cts +9 -25
- package/dist/components/TextButton/TextButton.types.d.cts.map +1 -1
- package/dist/components/TextButton/TextButton.types.d.mts +9 -25
- package/dist/components/TextButton/TextButton.types.d.mts.map +1 -1
- package/dist/components/TextButton/TextButton.types.mjs.map +1 -1
- package/dist/components/TextButton/index.cjs +1 -3
- package/dist/components/TextButton/index.cjs.map +1 -1
- package/dist/components/TextButton/index.d.cts +0 -1
- package/dist/components/TextButton/index.d.cts.map +1 -1
- package/dist/components/TextButton/index.d.mts +0 -1
- package/dist/components/TextButton/index.d.mts.map +1 -1
- package/dist/components/TextButton/index.mjs +0 -1
- package/dist/components/TextButton/index.mjs.map +1 -1
- package/dist/components/Toast/Toast.cjs +73 -0
- package/dist/components/Toast/Toast.cjs.map +1 -0
- package/dist/components/Toast/Toast.constants.cjs +24 -0
- package/dist/components/Toast/Toast.constants.cjs.map +1 -0
- package/dist/components/Toast/Toast.constants.d.cts +16 -0
- package/dist/components/Toast/Toast.constants.d.cts.map +1 -0
- package/dist/components/Toast/Toast.constants.d.mts +16 -0
- package/dist/components/Toast/Toast.constants.d.mts.map +1 -0
- package/dist/components/Toast/Toast.constants.mjs +19 -0
- package/dist/components/Toast/Toast.constants.mjs.map +1 -0
- package/dist/components/Toast/Toast.d.cts +4 -0
- package/dist/components/Toast/Toast.d.cts.map +1 -0
- package/dist/components/Toast/Toast.d.mts +4 -0
- package/dist/components/Toast/Toast.d.mts.map +1 -0
- package/dist/components/Toast/Toast.mjs +54 -0
- package/dist/components/Toast/Toast.mjs.map +1 -0
- package/dist/components/Toast/Toast.types.cjs +3 -0
- package/dist/components/Toast/Toast.types.cjs.map +1 -0
- package/dist/components/Toast/Toast.types.d.cts +60 -0
- package/dist/components/Toast/Toast.types.d.cts.map +1 -0
- package/dist/components/Toast/Toast.types.d.mts +60 -0
- package/dist/components/Toast/Toast.types.d.mts.map +1 -0
- package/dist/components/Toast/Toast.types.mjs +2 -0
- package/dist/components/Toast/Toast.types.mjs.map +1 -0
- package/dist/components/Toast/Toaster.cjs +210 -0
- package/dist/components/Toast/Toaster.cjs.map +1 -0
- package/dist/components/Toast/Toaster.d.cts +11 -0
- package/dist/components/Toast/Toaster.d.cts.map +1 -0
- package/dist/components/Toast/Toaster.d.mts +11 -0
- package/dist/components/Toast/Toaster.d.mts.map +1 -0
- package/dist/components/Toast/Toaster.mjs +191 -0
- package/dist/components/Toast/Toaster.mjs.map +1 -0
- package/dist/components/Toast/index.cjs +11 -0
- package/dist/components/Toast/index.cjs.map +1 -0
- package/dist/components/Toast/index.d.cts +5 -0
- package/dist/components/Toast/index.d.cts.map +1 -0
- package/dist/components/Toast/index.d.mts +5 -0
- package/dist/components/Toast/index.d.mts.map +1 -0
- package/dist/components/Toast/index.mjs +4 -0
- package/dist/components/Toast/index.mjs.map +1 -0
- package/dist/components/index.cjs +10 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +5 -1
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +5 -1
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +3 -1
- package/dist/components/index.mjs.map +1 -1
- package/dist/types/index.cjs +2 -23
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +1 -14
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +1 -14
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +1 -15
- package/dist/types/index.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/components/TextButton/TextButton.constants.cjs +0 -12
- package/dist/components/TextButton/TextButton.constants.cjs.map +0 -1
- package/dist/components/TextButton/TextButton.constants.d.cts +0 -4
- package/dist/components/TextButton/TextButton.constants.d.cts.map +0 -1
- package/dist/components/TextButton/TextButton.constants.d.mts +0 -4
- package/dist/components/TextButton/TextButton.constants.d.mts.map +0 -1
- package/dist/components/TextButton/TextButton.constants.mjs +0 -9
- package/dist/components/TextButton/TextButton.constants.mjs.map +0 -1
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
export type TextButtonProps = Omit<
|
|
1
|
+
import type { TextButtonPropsShared } from "@metamask/design-system-shared";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
import type { TextProps } from "../Text/index.cjs";
|
|
4
|
+
export type TextButtonProps = TextButtonPropsShared & Omit<TextProps, 'asChild' | 'children' | 'color'> & Omit<ComponentProps<'button'>, 'children' | 'color' | 'disabled' | 'onClick'> & {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Called when the user clicks the label. Primary interaction for this control.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
onClick?: ComponentProps<'button'>['onClick'];
|
|
9
9
|
/**
|
|
10
|
-
* Optional
|
|
10
|
+
* Optional boolean that determines if the component should merge its props onto its immediate child
|
|
11
|
+
* instead of rendering a button element.
|
|
11
12
|
*
|
|
12
13
|
* @default false
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Optional prop that when true, disables the button
|
|
17
|
-
*
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
isDisabled?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Optional prop to specify the size of the TextButton
|
|
23
|
-
*
|
|
24
|
-
* @default TextButtonSize.BodyMd
|
|
25
|
-
*/
|
|
26
|
-
size?: TextButtonSize;
|
|
27
|
-
/**
|
|
28
|
-
* Optional CSS styles to be applied to the component.
|
|
29
|
-
* Should be used sparingly and only for dynamic styles that can't be achieved with className.
|
|
30
|
-
*/
|
|
31
|
-
style?: React.CSSProperties;
|
|
15
|
+
asChild?: boolean;
|
|
32
16
|
};
|
|
33
17
|
//# sourceMappingURL=TextButton.types.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextButton.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uCAAuC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,MAAM,MAAM,eAAe,GAAG,qBAAqB,GACjD,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC,GACjD,IAAI,CACF,cAAc,CAAC,QAAQ,CAAC,EACxB,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAC9C,GAAG;IACF;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
export type TextButtonProps = Omit<
|
|
1
|
+
import type { TextButtonPropsShared } from "@metamask/design-system-shared";
|
|
2
|
+
import type { ComponentProps } from "react";
|
|
3
|
+
import type { TextProps } from "../Text/index.mjs";
|
|
4
|
+
export type TextButtonProps = TextButtonPropsShared & Omit<TextProps, 'asChild' | 'children' | 'color'> & Omit<ComponentProps<'button'>, 'children' | 'color' | 'disabled' | 'onClick'> & {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Called when the user clicks the label. Primary interaction for this control.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
onClick?: ComponentProps<'button'>['onClick'];
|
|
9
9
|
/**
|
|
10
|
-
* Optional
|
|
10
|
+
* Optional boolean that determines if the component should merge its props onto its immediate child
|
|
11
|
+
* instead of rendering a button element.
|
|
11
12
|
*
|
|
12
13
|
* @default false
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Optional prop that when true, disables the button
|
|
17
|
-
*
|
|
18
|
-
* @default false
|
|
19
|
-
*/
|
|
20
|
-
isDisabled?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Optional prop to specify the size of the TextButton
|
|
23
|
-
*
|
|
24
|
-
* @default TextButtonSize.BodyMd
|
|
25
|
-
*/
|
|
26
|
-
size?: TextButtonSize;
|
|
27
|
-
/**
|
|
28
|
-
* Optional CSS styles to be applied to the component.
|
|
29
|
-
* Should be used sparingly and only for dynamic styles that can't be achieved with className.
|
|
30
|
-
*/
|
|
31
|
-
style?: React.CSSProperties;
|
|
15
|
+
asChild?: boolean;
|
|
32
16
|
};
|
|
33
17
|
//# sourceMappingURL=TextButton.types.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.types.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TextButton.types.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uCAAuC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,MAAM,MAAM,eAAe,GAAG,qBAAqB,GACjD,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC,GACjD,IAAI,CACF,cAAc,CAAC,QAAQ,CAAC,EACxB,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAC9C,GAAG;IACF;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextButton.types.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"TextButton.types.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/TextButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TextButtonPropsShared } from '@metamask/design-system-shared';\nimport type { ComponentProps } from 'react';\n\nimport type { TextProps } from '../Text';\n\nexport type TextButtonProps = TextButtonPropsShared &\n Omit<TextProps, 'asChild' | 'children' | 'color'> &\n Omit<\n ComponentProps<'button'>,\n 'children' | 'color' | 'disabled' | 'onClick'\n > & {\n /**\n * Called when the user clicks the label. Primary interaction for this control.\n */\n onClick?: ComponentProps<'button'>['onClick'];\n /**\n * Optional boolean that determines if the component should merge its props onto its immediate child\n * instead of rendering a button element.\n *\n * @default false\n */\n asChild?: boolean;\n };\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TextButton =
|
|
4
|
-
var types_1 = require("../../types/index.cjs");
|
|
5
|
-
Object.defineProperty(exports, "TextButtonSize", { enumerable: true, get: function () { return types_1.TextButtonSize; } });
|
|
3
|
+
exports.TextButton = void 0;
|
|
6
4
|
var TextButton_1 = require("./TextButton.cjs");
|
|
7
5
|
Object.defineProperty(exports, "TextButton", { enumerable: true, get: function () { return TextButton_1.TextButton; } });
|
|
8
6
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAAjC,wGAAA,UAAU,OAAA","sourcesContent":["export { TextButton } from './TextButton';\nexport type { TextButtonProps } from './TextButton.types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB;AAC1C,YAAY,EAAE,eAAe,EAAE,+BAA2B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/TextButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,yBAAqB","sourcesContent":["export { TextButton } from './TextButton';\nexport type { TextButtonProps } from './TextButton.types';\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Toast = void 0;
|
|
27
|
+
const design_system_shared_1 = require("@metamask/design-system-shared");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const tw_merge_1 = require("../../utils/tw-merge.cjs");
|
|
30
|
+
const BannerBase_1 = require("../BannerBase/index.cjs");
|
|
31
|
+
const Icon_1 = require("../Icon/index.cjs");
|
|
32
|
+
const Toast_constants_1 = require("./Toast.constants.cjs");
|
|
33
|
+
const renderSeverityAccessory = ({ severity, startAccessory, iconProps, }) => {
|
|
34
|
+
if (startAccessory !== null && startAccessory !== undefined) {
|
|
35
|
+
return startAccessory;
|
|
36
|
+
}
|
|
37
|
+
if (!severity || severity === design_system_shared_1.ToastSeverity.Default) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const { name, color } = Toast_constants_1.TOAST_SEVERITY_ICON_MAP[severity];
|
|
41
|
+
return react_1.default.createElement(Icon_1.Icon, { name: name, color: color, size: design_system_shared_1.IconSize.Lg, ...iconProps });
|
|
42
|
+
};
|
|
43
|
+
exports.Toast = (0, react_1.forwardRef)(({ actionButtonLabel, actionButtonOnClick, actionButtonProps, className, closeButtonProps, iconProps, onClose, severity = design_system_shared_1.ToastSeverity.Default, startAccessory, ...props }, ref) => {
|
|
44
|
+
// Only pass action props through when both the label and handler are set so
|
|
45
|
+
// BannerBase can keep its action button contract simple.
|
|
46
|
+
const resolvedActionProps = actionButtonLabel && actionButtonOnClick
|
|
47
|
+
? {
|
|
48
|
+
actionButtonLabel,
|
|
49
|
+
actionButtonOnClick,
|
|
50
|
+
actionButtonProps: {
|
|
51
|
+
size: design_system_shared_1.ButtonSize.Sm,
|
|
52
|
+
...actionButtonProps,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
: {};
|
|
56
|
+
// Derive the close button config from the Toast API, keeping the button
|
|
57
|
+
// visible whenever the consumer provides dismiss behavior or overrides.
|
|
58
|
+
const resolvedCloseButtonProps = onClose || closeButtonProps
|
|
59
|
+
? {
|
|
60
|
+
ariaLabel: 'Close toast',
|
|
61
|
+
...closeButtonProps,
|
|
62
|
+
}
|
|
63
|
+
: undefined;
|
|
64
|
+
// Toast reuses BannerBase so the web surface stays aligned with the shared
|
|
65
|
+
// banner layout and the React Native Toast API.
|
|
66
|
+
return (react_1.default.createElement(BannerBase_1.BannerBase, { ref: ref, ...resolvedActionProps, ...props, backgroundColor: design_system_shared_1.BoxBackgroundColor.BackgroundSection, borderColor: design_system_shared_1.BoxBorderColor.BorderMuted, borderWidth: 1, className: (0, tw_merge_1.twMerge)('rounded-xl', className), closeButtonProps: resolvedCloseButtonProps, onClose: onClose, startAccessory: renderSeverityAccessory({
|
|
67
|
+
severity,
|
|
68
|
+
startAccessory,
|
|
69
|
+
iconProps,
|
|
70
|
+
}) }));
|
|
71
|
+
});
|
|
72
|
+
exports.Toast.displayName = 'Toast';
|
|
73
|
+
//# sourceMappingURL=Toast.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yEAMwC;AACxC,+CAA0C;AAE1C,uDAA+C;AAC/C,wDAA2C;AAC3C,4CAA+B;AAE/B,2DAA4D;AAG5D,MAAM,uBAAuB,GAAG,CAAC,EAC/B,QAAQ,EACR,cAAc,EACd,SAAS,GACqD,EAAE,EAAE;IAClE,IAAI,cAAc,KAAK,IAAI,IAAI,cAAc,KAAK,SAAS,EAAE;QAC3D,OAAO,cAAc,CAAC;KACvB;IAED,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,oCAAa,CAAC,OAAO,EAAE;QACnD,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,yCAAuB,CAAC,QAAQ,CAAC,CAAC;IAE1D,OAAO,8BAAC,WAAI,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,+BAAQ,CAAC,EAAE,KAAM,SAAS,GAAI,CAAC;AAC9E,CAAC,CAAC;AAEW,QAAA,KAAK,GAAG,IAAA,kBAAU,EAC7B,CACE,EACE,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,QAAQ,GAAG,oCAAa,CAAC,OAAO,EAChC,cAAc,EACd,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,4EAA4E;IAC5E,yDAAyD;IACzD,MAAM,mBAAmB,GACvB,iBAAiB,IAAI,mBAAmB;QACtC,CAAC,CAAC;YACE,iBAAiB;YACjB,mBAAmB;YACnB,iBAAiB,EAAE;gBACjB,IAAI,EAAE,iCAAU,CAAC,EAAE;gBACnB,GAAG,iBAAiB;aACrB;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,wEAAwE;IACxE,wEAAwE;IACxE,MAAM,wBAAwB,GAC5B,OAAO,IAAI,gBAAgB;QACzB,CAAC,CAAC;YACE,SAAS,EAAE,aAAa;YACxB,GAAG,gBAAgB;SACpB;QACH,CAAC,CAAC,SAAS,CAAC;IAEhB,2EAA2E;IAC3E,gDAAgD;IAChD,OAAO,CACL,8BAAC,uBAAU,IACT,GAAG,EAAE,GAAG,KACJ,mBAAmB,KACnB,KAAK,EACT,eAAe,EAAE,yCAAkB,CAAC,iBAAiB,EACrD,WAAW,EAAE,qCAAc,CAAC,WAAW,EACvC,WAAW,EAAE,CAAC,EACd,SAAS,EAAE,IAAA,kBAAO,EAAC,YAAY,EAAE,SAAS,CAAC,EAC3C,gBAAgB,EAAE,wBAAwB,EAC1C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,uBAAuB,CAAC;YACtC,QAAQ;YACR,cAAc;YACd,SAAS;SACV,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,aAAK,CAAC,WAAW,GAAG,OAAO,CAAC","sourcesContent":["import {\n BoxBackgroundColor,\n BoxBorderColor,\n ButtonSize,\n IconSize,\n ToastSeverity,\n} from '@metamask/design-system-shared';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { BannerBase } from '../BannerBase';\nimport { Icon } from '../Icon';\n\nimport { TOAST_SEVERITY_ICON_MAP } from './Toast.constants';\nimport type { ToastProps } from './Toast.types';\n\nconst renderSeverityAccessory = ({\n severity,\n startAccessory,\n iconProps,\n}: Pick<ToastProps, 'severity' | 'startAccessory' | 'iconProps'>) => {\n if (startAccessory !== null && startAccessory !== undefined) {\n return startAccessory;\n }\n\n if (!severity || severity === ToastSeverity.Default) {\n return undefined;\n }\n\n const { name, color } = TOAST_SEVERITY_ICON_MAP[severity];\n\n return <Icon name={name} color={color} size={IconSize.Lg} {...iconProps} />;\n};\n\nexport const Toast = forwardRef<HTMLDivElement, ToastProps>(\n (\n {\n actionButtonLabel,\n actionButtonOnClick,\n actionButtonProps,\n className,\n closeButtonProps,\n iconProps,\n onClose,\n severity = ToastSeverity.Default,\n startAccessory,\n ...props\n },\n ref,\n ) => {\n // Only pass action props through when both the label and handler are set so\n // BannerBase can keep its action button contract simple.\n const resolvedActionProps =\n actionButtonLabel && actionButtonOnClick\n ? {\n actionButtonLabel,\n actionButtonOnClick,\n actionButtonProps: {\n size: ButtonSize.Sm,\n ...actionButtonProps,\n },\n }\n : {};\n\n // Derive the close button config from the Toast API, keeping the button\n // visible whenever the consumer provides dismiss behavior or overrides.\n const resolvedCloseButtonProps =\n onClose || closeButtonProps\n ? {\n ariaLabel: 'Close toast',\n ...closeButtonProps,\n }\n : undefined;\n\n // Toast reuses BannerBase so the web surface stays aligned with the shared\n // banner layout and the React Native Toast API.\n return (\n <BannerBase\n ref={ref}\n {...resolvedActionProps}\n {...props}\n backgroundColor={BoxBackgroundColor.BackgroundSection}\n borderColor={BoxBorderColor.BorderMuted}\n borderWidth={1}\n className={twMerge('rounded-xl', className)}\n closeButtonProps={resolvedCloseButtonProps}\n onClose={onClose}\n startAccessory={renderSeverityAccessory({\n severity,\n startAccessory,\n iconProps,\n })}\n />\n );\n },\n);\n\nToast.displayName = 'Toast';\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOAST_SEVERITY_ICON_MAP = exports.TOAST_VISIBILITY_DURATION = exports.TOAST_ANIMATION_DURATION = void 0;
|
|
4
|
+
const design_system_shared_1 = require("@metamask/design-system-shared");
|
|
5
|
+
var design_system_shared_2 = require("@metamask/design-system-shared");
|
|
6
|
+
Object.defineProperty(exports, "TOAST_ANIMATION_DURATION", { enumerable: true, get: function () { return design_system_shared_2.TOAST_ANIMATION_DURATION; } });
|
|
7
|
+
Object.defineProperty(exports, "TOAST_VISIBILITY_DURATION", { enumerable: true, get: function () { return design_system_shared_2.TOAST_VISIBILITY_DURATION; } });
|
|
8
|
+
// TODO: Replace this map with a web IconAlert component once the shared
|
|
9
|
+
// alert-icon primitive exists in React.
|
|
10
|
+
exports.TOAST_SEVERITY_ICON_MAP = {
|
|
11
|
+
[design_system_shared_1.ToastSeverity.Success]: {
|
|
12
|
+
name: design_system_shared_1.IconName.Confirmation,
|
|
13
|
+
color: design_system_shared_1.IconColor.SuccessDefault,
|
|
14
|
+
},
|
|
15
|
+
[design_system_shared_1.ToastSeverity.Warning]: {
|
|
16
|
+
name: design_system_shared_1.IconName.Danger,
|
|
17
|
+
color: design_system_shared_1.IconColor.WarningDefault,
|
|
18
|
+
},
|
|
19
|
+
[design_system_shared_1.ToastSeverity.Danger]: {
|
|
20
|
+
name: design_system_shared_1.IconName.Danger,
|
|
21
|
+
color: design_system_shared_1.IconColor.ErrorDefault,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=Toast.constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.constants.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":";;;AAAA,yEAIwC;AAExC,uEAGwC;AAFtC,gIAAA,wBAAwB,OAAA;AACxB,iIAAA,yBAAyB,OAAA;AAG3B,wEAAwE;AACxE,wCAAwC;AAC3B,QAAA,uBAAuB,GAAG;IACrC,CAAC,oCAAa,CAAC,OAAO,CAAC,EAAE;QACvB,IAAI,EAAE,+BAAQ,CAAC,YAAY;QAC3B,KAAK,EAAE,gCAAS,CAAC,cAAc;KAChC;IACD,CAAC,oCAAa,CAAC,OAAO,CAAC,EAAE;QACvB,IAAI,EAAE,+BAAQ,CAAC,MAAM;QACrB,KAAK,EAAE,gCAAS,CAAC,cAAc;KAChC;IACD,CAAC,oCAAa,CAAC,MAAM,CAAC,EAAE;QACtB,IAAI,EAAE,+BAAQ,CAAC,MAAM;QACrB,KAAK,EAAE,gCAAS,CAAC,YAAY;KAC9B;CACO,CAAC","sourcesContent":["import {\n IconColor,\n IconName,\n ToastSeverity,\n} from '@metamask/design-system-shared';\n\nexport {\n TOAST_ANIMATION_DURATION,\n TOAST_VISIBILITY_DURATION,\n} from '@metamask/design-system-shared';\n\n// TODO: Replace this map with a web IconAlert component once the shared\n// alert-icon primitive exists in React.\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: {\n name: IconName.Confirmation,\n color: IconColor.SuccessDefault,\n },\n [ToastSeverity.Warning]: {\n name: IconName.Danger,\n color: IconColor.WarningDefault,\n },\n [ToastSeverity.Danger]: {\n name: IconName.Danger,\n color: IconColor.ErrorDefault,\n },\n} as const;\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { TOAST_ANIMATION_DURATION, TOAST_VISIBILITY_DURATION, } from "@metamask/design-system-shared";
|
|
2
|
+
export declare const TOAST_SEVERITY_ICON_MAP: {
|
|
3
|
+
readonly success: {
|
|
4
|
+
readonly name: "Confirmation";
|
|
5
|
+
readonly color: "text-success-default";
|
|
6
|
+
};
|
|
7
|
+
readonly warning: {
|
|
8
|
+
readonly name: "Danger";
|
|
9
|
+
readonly color: "text-warning-default";
|
|
10
|
+
};
|
|
11
|
+
readonly danger: {
|
|
12
|
+
readonly name: "Danger";
|
|
13
|
+
readonly color: "text-error-default";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=Toast.constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.constants.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,uCAAuC;AAIxC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;CAa1B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { TOAST_ANIMATION_DURATION, TOAST_VISIBILITY_DURATION, } from "@metamask/design-system-shared";
|
|
2
|
+
export declare const TOAST_SEVERITY_ICON_MAP: {
|
|
3
|
+
readonly success: {
|
|
4
|
+
readonly name: "Confirmation";
|
|
5
|
+
readonly color: "text-success-default";
|
|
6
|
+
};
|
|
7
|
+
readonly warning: {
|
|
8
|
+
readonly name: "Danger";
|
|
9
|
+
readonly color: "text-warning-default";
|
|
10
|
+
};
|
|
11
|
+
readonly danger: {
|
|
12
|
+
readonly name: "Danger";
|
|
13
|
+
readonly color: "text-error-default";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=Toast.constants.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.constants.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,GAC1B,uCAAuC;AAIxC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;CAa1B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IconColor, IconName, ToastSeverity } from "@metamask/design-system-shared";
|
|
2
|
+
export { TOAST_ANIMATION_DURATION, TOAST_VISIBILITY_DURATION } from "@metamask/design-system-shared";
|
|
3
|
+
// TODO: Replace this map with a web IconAlert component once the shared
|
|
4
|
+
// alert-icon primitive exists in React.
|
|
5
|
+
export const TOAST_SEVERITY_ICON_MAP = {
|
|
6
|
+
[ToastSeverity.Success]: {
|
|
7
|
+
name: IconName.Confirmation,
|
|
8
|
+
color: IconColor.SuccessDefault,
|
|
9
|
+
},
|
|
10
|
+
[ToastSeverity.Warning]: {
|
|
11
|
+
name: IconName.Danger,
|
|
12
|
+
color: IconColor.WarningDefault,
|
|
13
|
+
},
|
|
14
|
+
[ToastSeverity.Danger]: {
|
|
15
|
+
name: IconName.Danger,
|
|
16
|
+
color: IconColor.ErrorDefault,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=Toast.constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.constants.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,aAAa,EACd,uCAAuC;AAExC,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EAC1B,uCAAuC;AAExC,wEAAwE;AACxE,wCAAwC;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,IAAI,EAAE,QAAQ,CAAC,YAAY;QAC3B,KAAK,EAAE,SAAS,CAAC,cAAc;KAChC;IACD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QACvB,IAAI,EAAE,QAAQ,CAAC,MAAM;QACrB,KAAK,EAAE,SAAS,CAAC,cAAc;KAChC;IACD,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;QACtB,IAAI,EAAE,QAAQ,CAAC,MAAM;QACrB,KAAK,EAAE,SAAS,CAAC,YAAY;KAC9B;CACO,CAAC","sourcesContent":["import {\n IconColor,\n IconName,\n ToastSeverity,\n} from '@metamask/design-system-shared';\n\nexport {\n TOAST_ANIMATION_DURATION,\n TOAST_VISIBILITY_DURATION,\n} from '@metamask/design-system-shared';\n\n// TODO: Replace this map with a web IconAlert component once the shared\n// alert-icon primitive exists in React.\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: {\n name: IconName.Confirmation,\n color: IconColor.SuccessDefault,\n },\n [ToastSeverity.Warning]: {\n name: IconName.Danger,\n color: IconColor.WarningDefault,\n },\n [ToastSeverity.Danger]: {\n name: IconName.Danger,\n color: IconColor.ErrorDefault,\n },\n} as const;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAqB,cAAc;AAO1C,OAAO,KAAK,EAAE,UAAU,EAAE,0BAAsB;AAoBhD,eAAO,MAAM,KAAK,gGA6DjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAqB,cAAc;AAO1C,OAAO,KAAK,EAAE,UAAU,EAAE,0BAAsB;AAoBhD,eAAO,MAAM,KAAK,gGA6DjB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
function $importDefault(module) {
|
|
2
|
+
if (module?.__esModule) {
|
|
3
|
+
return module.default;
|
|
4
|
+
}
|
|
5
|
+
return module;
|
|
6
|
+
}
|
|
7
|
+
import { BoxBackgroundColor, BoxBorderColor, ButtonSize, IconSize, ToastSeverity } from "@metamask/design-system-shared";
|
|
8
|
+
import $React, { forwardRef } from "react";
|
|
9
|
+
const React = $importDefault($React);
|
|
10
|
+
import { twMerge } from "../../utils/tw-merge.mjs";
|
|
11
|
+
import { BannerBase } from "../BannerBase/index.mjs";
|
|
12
|
+
import { Icon } from "../Icon/index.mjs";
|
|
13
|
+
import { TOAST_SEVERITY_ICON_MAP } from "./Toast.constants.mjs";
|
|
14
|
+
const renderSeverityAccessory = ({ severity, startAccessory, iconProps, }) => {
|
|
15
|
+
if (startAccessory !== null && startAccessory !== undefined) {
|
|
16
|
+
return startAccessory;
|
|
17
|
+
}
|
|
18
|
+
if (!severity || severity === ToastSeverity.Default) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const { name, color } = TOAST_SEVERITY_ICON_MAP[severity];
|
|
22
|
+
return React.createElement(Icon, { name: name, color: color, size: IconSize.Lg, ...iconProps });
|
|
23
|
+
};
|
|
24
|
+
export const Toast = forwardRef(({ actionButtonLabel, actionButtonOnClick, actionButtonProps, className, closeButtonProps, iconProps, onClose, severity = ToastSeverity.Default, startAccessory, ...props }, ref) => {
|
|
25
|
+
// Only pass action props through when both the label and handler are set so
|
|
26
|
+
// BannerBase can keep its action button contract simple.
|
|
27
|
+
const resolvedActionProps = actionButtonLabel && actionButtonOnClick
|
|
28
|
+
? {
|
|
29
|
+
actionButtonLabel,
|
|
30
|
+
actionButtonOnClick,
|
|
31
|
+
actionButtonProps: {
|
|
32
|
+
size: ButtonSize.Sm,
|
|
33
|
+
...actionButtonProps,
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
: {};
|
|
37
|
+
// Derive the close button config from the Toast API, keeping the button
|
|
38
|
+
// visible whenever the consumer provides dismiss behavior or overrides.
|
|
39
|
+
const resolvedCloseButtonProps = onClose || closeButtonProps
|
|
40
|
+
? {
|
|
41
|
+
ariaLabel: 'Close toast',
|
|
42
|
+
...closeButtonProps,
|
|
43
|
+
}
|
|
44
|
+
: undefined;
|
|
45
|
+
// Toast reuses BannerBase so the web surface stays aligned with the shared
|
|
46
|
+
// banner layout and the React Native Toast API.
|
|
47
|
+
return (React.createElement(BannerBase, { ref: ref, ...resolvedActionProps, ...props, backgroundColor: BoxBackgroundColor.BackgroundSection, borderColor: BoxBorderColor.BorderMuted, borderWidth: 1, className: twMerge('rounded-xl', className), closeButtonProps: resolvedCloseButtonProps, onClose: onClose, startAccessory: renderSeverityAccessory({
|
|
48
|
+
severity,
|
|
49
|
+
startAccessory,
|
|
50
|
+
iconProps,
|
|
51
|
+
}) }));
|
|
52
|
+
});
|
|
53
|
+
Toast.displayName = 'Toast';
|
|
54
|
+
//# sourceMappingURL=Toast.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,QAAQ,EACR,aAAa,EACd,uCAAuC;AACxC,OAAO,QAAO,EAAE,UAAU,EAAE,cAAc;;AAE1C,OAAO,EAAE,OAAO,EAAE,iCAA6B;AAC/C,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAC3C,OAAO,EAAE,IAAI,EAAE,0BAAgB;AAE/B,OAAO,EAAE,uBAAuB,EAAE,8BAA0B;AAG5D,MAAM,uBAAuB,GAAG,CAAC,EAC/B,QAAQ,EACR,cAAc,EACd,SAAS,GACqD,EAAE,EAAE;IAClE,IAAI,cAAc,KAAK,IAAI,IAAI,cAAc,KAAK,SAAS,EAAE;QAC3D,OAAO,cAAc,CAAC;KACvB;IAED,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,aAAa,CAAC,OAAO,EAAE;QACnD,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAE1D,OAAO,oBAAC,IAAI,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,KAAM,SAAS,GAAI,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAC7B,CACE,EACE,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,QAAQ,GAAG,aAAa,CAAC,OAAO,EAChC,cAAc,EACd,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,4EAA4E;IAC5E,yDAAyD;IACzD,MAAM,mBAAmB,GACvB,iBAAiB,IAAI,mBAAmB;QACtC,CAAC,CAAC;YACE,iBAAiB;YACjB,mBAAmB;YACnB,iBAAiB,EAAE;gBACjB,IAAI,EAAE,UAAU,CAAC,EAAE;gBACnB,GAAG,iBAAiB;aACrB;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,wEAAwE;IACxE,wEAAwE;IACxE,MAAM,wBAAwB,GAC5B,OAAO,IAAI,gBAAgB;QACzB,CAAC,CAAC;YACE,SAAS,EAAE,aAAa;YACxB,GAAG,gBAAgB;SACpB;QACH,CAAC,CAAC,SAAS,CAAC;IAEhB,2EAA2E;IAC3E,gDAAgD;IAChD,OAAO,CACL,oBAAC,UAAU,IACT,GAAG,EAAE,GAAG,KACJ,mBAAmB,KACnB,KAAK,EACT,eAAe,EAAE,kBAAkB,CAAC,iBAAiB,EACrD,WAAW,EAAE,cAAc,CAAC,WAAW,EACvC,WAAW,EAAE,CAAC,EACd,SAAS,EAAE,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,EAC3C,gBAAgB,EAAE,wBAAwB,EAC1C,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,uBAAuB,CAAC;YACtC,QAAQ;YACR,cAAc;YACd,SAAS;SACV,CAAC,GACF,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC","sourcesContent":["import {\n BoxBackgroundColor,\n BoxBorderColor,\n ButtonSize,\n IconSize,\n ToastSeverity,\n} from '@metamask/design-system-shared';\nimport React, { forwardRef } from 'react';\n\nimport { twMerge } from '../../utils/tw-merge';\nimport { BannerBase } from '../BannerBase';\nimport { Icon } from '../Icon';\n\nimport { TOAST_SEVERITY_ICON_MAP } from './Toast.constants';\nimport type { ToastProps } from './Toast.types';\n\nconst renderSeverityAccessory = ({\n severity,\n startAccessory,\n iconProps,\n}: Pick<ToastProps, 'severity' | 'startAccessory' | 'iconProps'>) => {\n if (startAccessory !== null && startAccessory !== undefined) {\n return startAccessory;\n }\n\n if (!severity || severity === ToastSeverity.Default) {\n return undefined;\n }\n\n const { name, color } = TOAST_SEVERITY_ICON_MAP[severity];\n\n return <Icon name={name} color={color} size={IconSize.Lg} {...iconProps} />;\n};\n\nexport const Toast = forwardRef<HTMLDivElement, ToastProps>(\n (\n {\n actionButtonLabel,\n actionButtonOnClick,\n actionButtonProps,\n className,\n closeButtonProps,\n iconProps,\n onClose,\n severity = ToastSeverity.Default,\n startAccessory,\n ...props\n },\n ref,\n ) => {\n // Only pass action props through when both the label and handler are set so\n // BannerBase can keep its action button contract simple.\n const resolvedActionProps =\n actionButtonLabel && actionButtonOnClick\n ? {\n actionButtonLabel,\n actionButtonOnClick,\n actionButtonProps: {\n size: ButtonSize.Sm,\n ...actionButtonProps,\n },\n }\n : {};\n\n // Derive the close button config from the Toast API, keeping the button\n // visible whenever the consumer provides dismiss behavior or overrides.\n const resolvedCloseButtonProps =\n onClose || closeButtonProps\n ? {\n ariaLabel: 'Close toast',\n ...closeButtonProps,\n }\n : undefined;\n\n // Toast reuses BannerBase so the web surface stays aligned with the shared\n // banner layout and the React Native Toast API.\n return (\n <BannerBase\n ref={ref}\n {...resolvedActionProps}\n {...props}\n backgroundColor={BoxBackgroundColor.BackgroundSection}\n borderColor={BoxBorderColor.BorderMuted}\n borderWidth={1}\n className={twMerge('rounded-xl', className)}\n closeButtonProps={resolvedCloseButtonProps}\n onClose={onClose}\n startAccessory={renderSeverityAccessory({\n severity,\n startAccessory,\n iconProps,\n })}\n />\n );\n },\n);\n\nToast.displayName = 'Toast';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.types.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ToastPropsShared } from '@metamask/design-system-shared';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon';\n\ntype ToastCloseButtonProps = Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onClick'\n>;\n\n/**\n * Props for the Toast visual component.\n * Extends the platform BannerBase props with severity and an icon override.\n * `onClose` is simplified to `() => void` (no MouseEvent) to align with the\n * React Native API and the imperative `toast()` pattern.\n */\nexport type ToastProps = Omit<BannerBaseProps, 'closeButtonProps' | 'onClose'> &\n ToastPropsShared & {\n /**\n * Optional handler called when the close button is pressed.\n * When provided, a close button is shown.\n */\n onClose?: () => void;\n /**\n * Optional props passed to the severity `Icon`.\n * Only used when `severity` is not `Default` and `startAccessory` is not provided.\n */\n iconProps?: Omit<IconProps, 'name' | 'color'>;\n /**\n * Optional props for the close `ButtonIcon`.\n * `ariaLabel` defaults to `'Close toast'`.\n */\n closeButtonProps?: ToastCloseButtonProps;\n /**\n * Optional test identifier forwarded to the root Toast element.\n */\n 'data-testid'?: string;\n };\n\n/**\n * Options passed to the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastProps & {\n /**\n * When true the toast stays visible until explicitly dismissed.\n * Defaults to false.\n */\n hasNoTimeout?: boolean;\n};\n\n/**\n * Imperative handle exposed by `<Toaster ref={...} />`.\n */\nexport type ToasterRef = {\n showToast: (options: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Props for the `<Toaster />` container component.\n */\nexport type ToasterProps = {\n /**\n * Optional extra CSS classes applied to the fixed outer container.\n */\n className?: string;\n} & Omit<React.HTMLAttributes<HTMLDivElement>, 'style'>;\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ToastPropsShared } from "@metamask/design-system-shared";
|
|
3
|
+
import type { BannerBaseProps } from "../BannerBase/index.cjs";
|
|
4
|
+
import type { IconProps } from "../Icon/index.cjs";
|
|
5
|
+
type ToastCloseButtonProps = Omit<NonNullable<BannerBaseProps['closeButtonProps']>, 'onClick'>;
|
|
6
|
+
/**
|
|
7
|
+
* Props for the Toast visual component.
|
|
8
|
+
* Extends the platform BannerBase props with severity and an icon override.
|
|
9
|
+
* `onClose` is simplified to `() => void` (no MouseEvent) to align with the
|
|
10
|
+
* React Native API and the imperative `toast()` pattern.
|
|
11
|
+
*/
|
|
12
|
+
export type ToastProps = Omit<BannerBaseProps, 'closeButtonProps' | 'onClose'> & ToastPropsShared & {
|
|
13
|
+
/**
|
|
14
|
+
* Optional handler called when the close button is pressed.
|
|
15
|
+
* When provided, a close button is shown.
|
|
16
|
+
*/
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Optional props passed to the severity `Icon`.
|
|
20
|
+
* Only used when `severity` is not `Default` and `startAccessory` is not provided.
|
|
21
|
+
*/
|
|
22
|
+
iconProps?: Omit<IconProps, 'name' | 'color'>;
|
|
23
|
+
/**
|
|
24
|
+
* Optional props for the close `ButtonIcon`.
|
|
25
|
+
* `ariaLabel` defaults to `'Close toast'`.
|
|
26
|
+
*/
|
|
27
|
+
closeButtonProps?: ToastCloseButtonProps;
|
|
28
|
+
/**
|
|
29
|
+
* Optional test identifier forwarded to the root Toast element.
|
|
30
|
+
*/
|
|
31
|
+
'data-testid'?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Options passed to the imperative `toast(...)` API.
|
|
35
|
+
*/
|
|
36
|
+
export type ToastOptions = ToastProps & {
|
|
37
|
+
/**
|
|
38
|
+
* When true the toast stays visible until explicitly dismissed.
|
|
39
|
+
* Defaults to false.
|
|
40
|
+
*/
|
|
41
|
+
hasNoTimeout?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Imperative handle exposed by `<Toaster ref={...} />`.
|
|
45
|
+
*/
|
|
46
|
+
export type ToasterRef = {
|
|
47
|
+
showToast: (options: ToastOptions) => void;
|
|
48
|
+
closeToast: () => void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Props for the `<Toaster />` container component.
|
|
52
|
+
*/
|
|
53
|
+
export type ToasterProps = {
|
|
54
|
+
/**
|
|
55
|
+
* Optional extra CSS classes applied to the fixed outer container.
|
|
56
|
+
*/
|
|
57
|
+
className?: string;
|
|
58
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, 'style'>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=Toast.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.types.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uCAAuC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,KAAK,qBAAqB,GAAG,IAAI,CAC/B,WAAW,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAChD,SAAS,CACV,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,kBAAkB,GAAG,SAAS,CAAC,GAC5E,gBAAgB,GAAG;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC9C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;IACzC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ToastPropsShared } from "@metamask/design-system-shared";
|
|
3
|
+
import type { BannerBaseProps } from "../BannerBase/index.mjs";
|
|
4
|
+
import type { IconProps } from "../Icon/index.mjs";
|
|
5
|
+
type ToastCloseButtonProps = Omit<NonNullable<BannerBaseProps['closeButtonProps']>, 'onClick'>;
|
|
6
|
+
/**
|
|
7
|
+
* Props for the Toast visual component.
|
|
8
|
+
* Extends the platform BannerBase props with severity and an icon override.
|
|
9
|
+
* `onClose` is simplified to `() => void` (no MouseEvent) to align with the
|
|
10
|
+
* React Native API and the imperative `toast()` pattern.
|
|
11
|
+
*/
|
|
12
|
+
export type ToastProps = Omit<BannerBaseProps, 'closeButtonProps' | 'onClose'> & ToastPropsShared & {
|
|
13
|
+
/**
|
|
14
|
+
* Optional handler called when the close button is pressed.
|
|
15
|
+
* When provided, a close button is shown.
|
|
16
|
+
*/
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Optional props passed to the severity `Icon`.
|
|
20
|
+
* Only used when `severity` is not `Default` and `startAccessory` is not provided.
|
|
21
|
+
*/
|
|
22
|
+
iconProps?: Omit<IconProps, 'name' | 'color'>;
|
|
23
|
+
/**
|
|
24
|
+
* Optional props for the close `ButtonIcon`.
|
|
25
|
+
* `ariaLabel` defaults to `'Close toast'`.
|
|
26
|
+
*/
|
|
27
|
+
closeButtonProps?: ToastCloseButtonProps;
|
|
28
|
+
/**
|
|
29
|
+
* Optional test identifier forwarded to the root Toast element.
|
|
30
|
+
*/
|
|
31
|
+
'data-testid'?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Options passed to the imperative `toast(...)` API.
|
|
35
|
+
*/
|
|
36
|
+
export type ToastOptions = ToastProps & {
|
|
37
|
+
/**
|
|
38
|
+
* When true the toast stays visible until explicitly dismissed.
|
|
39
|
+
* Defaults to false.
|
|
40
|
+
*/
|
|
41
|
+
hasNoTimeout?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Imperative handle exposed by `<Toaster ref={...} />`.
|
|
45
|
+
*/
|
|
46
|
+
export type ToasterRef = {
|
|
47
|
+
showToast: (options: ToastOptions) => void;
|
|
48
|
+
closeToast: () => void;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Props for the `<Toaster />` container component.
|
|
52
|
+
*/
|
|
53
|
+
export type ToasterProps = {
|
|
54
|
+
/**
|
|
55
|
+
* Optional extra CSS classes applied to the fixed outer container.
|
|
56
|
+
*/
|
|
57
|
+
className?: string;
|
|
58
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, 'style'>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=Toast.types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.types.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uCAAuC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,gCAAsB;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC,KAAK,qBAAqB,GAAG,IAAI,CAC/B,WAAW,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,EAChD,SAAS,CACV,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,kBAAkB,GAAG,SAAS,CAAC,GAC5E,gBAAgB,GAAG;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;IAC9C;;;OAGG;IACH,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;IACzC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG;IACtC;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.types.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ToastPropsShared } from '@metamask/design-system-shared';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon';\n\ntype ToastCloseButtonProps = Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onClick'\n>;\n\n/**\n * Props for the Toast visual component.\n * Extends the platform BannerBase props with severity and an icon override.\n * `onClose` is simplified to `() => void` (no MouseEvent) to align with the\n * React Native API and the imperative `toast()` pattern.\n */\nexport type ToastProps = Omit<BannerBaseProps, 'closeButtonProps' | 'onClose'> &\n ToastPropsShared & {\n /**\n * Optional handler called when the close button is pressed.\n * When provided, a close button is shown.\n */\n onClose?: () => void;\n /**\n * Optional props passed to the severity `Icon`.\n * Only used when `severity` is not `Default` and `startAccessory` is not provided.\n */\n iconProps?: Omit<IconProps, 'name' | 'color'>;\n /**\n * Optional props for the close `ButtonIcon`.\n * `ariaLabel` defaults to `'Close toast'`.\n */\n closeButtonProps?: ToastCloseButtonProps;\n /**\n * Optional test identifier forwarded to the root Toast element.\n */\n 'data-testid'?: string;\n };\n\n/**\n * Options passed to the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastProps & {\n /**\n * When true the toast stays visible until explicitly dismissed.\n * Defaults to false.\n */\n hasNoTimeout?: boolean;\n};\n\n/**\n * Imperative handle exposed by `<Toaster ref={...} />`.\n */\nexport type ToasterRef = {\n showToast: (options: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Props for the `<Toaster />` container component.\n */\nexport type ToasterProps = {\n /**\n * Optional extra CSS classes applied to the fixed outer container.\n */\n className?: string;\n} & Omit<React.HTMLAttributes<HTMLDivElement>, 'style'>;\n"]}
|