@metamask/design-system-react-native 0.23.0 → 0.24.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 +19 -1
- package/dist/components/Icon/Icon.assets.cjs +12 -0
- package/dist/components/Icon/Icon.assets.cjs.map +1 -1
- package/dist/components/Icon/Icon.assets.d.cts.map +1 -1
- package/dist/components/Icon/Icon.assets.d.mts.map +1 -1
- package/dist/components/Icon/Icon.assets.mjs +12 -0
- package/dist/components/Icon/Icon.assets.mjs.map +1 -1
- package/dist/components/Icon/assets/candlestick.svg +1 -1
- package/dist/components/Icon/assets/group.svg +1 -0
- package/dist/components/Icon/assets/list-arrow.svg +1 -0
- package/dist/components/Icon/assets/musd-filled.svg +1 -0
- package/dist/components/Icon/assets/musd.svg +1 -0
- package/dist/components/Icon/assets/pie-chart.svg +1 -0
- package/dist/components/Icon/assets/predictions.svg +1 -0
- package/dist/components/Toast/Toast.cjs +43 -52
- package/dist/components/Toast/Toast.cjs.map +1 -1
- package/dist/components/Toast/Toast.constants.cjs +8 -1
- package/dist/components/Toast/Toast.constants.cjs.map +1 -1
- package/dist/components/Toast/Toast.constants.d.cts +5 -0
- package/dist/components/Toast/Toast.constants.d.cts.map +1 -1
- package/dist/components/Toast/Toast.constants.d.mts +5 -0
- package/dist/components/Toast/Toast.constants.d.mts.map +1 -1
- package/dist/components/Toast/Toast.constants.mjs +7 -0
- package/dist/components/Toast/Toast.constants.mjs.map +1 -1
- package/dist/components/Toast/Toast.d.cts +2 -17
- package/dist/components/Toast/Toast.d.cts.map +1 -1
- package/dist/components/Toast/Toast.d.mts +2 -17
- package/dist/components/Toast/Toast.d.mts.map +1 -1
- package/dist/components/Toast/Toast.mjs +40 -30
- package/dist/components/Toast/Toast.mjs.map +1 -1
- package/dist/components/Toast/Toast.types.cjs +9 -14
- package/dist/components/Toast/Toast.types.cjs.map +1 -1
- package/dist/components/Toast/Toast.types.d.cts +29 -91
- package/dist/components/Toast/Toast.types.d.cts.map +1 -1
- package/dist/components/Toast/Toast.types.d.mts +29 -91
- package/dist/components/Toast/Toast.types.d.mts.map +1 -1
- package/dist/components/Toast/Toast.types.mjs +8 -13
- package/dist/components/Toast/Toast.types.mjs.map +1 -1
- package/dist/components/Toast/Toaster.cjs +142 -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 +123 -0
- package/dist/components/Toast/Toaster.mjs.map +1 -0
- package/dist/components/Toast/index.cjs +5 -3
- package/dist/components/Toast/index.cjs.map +1 -1
- package/dist/components/Toast/index.d.cts +3 -2
- package/dist/components/Toast/index.d.cts.map +1 -1
- package/dist/components/Toast/index.d.mts +3 -2
- package/dist/components/Toast/index.d.mts.map +1 -1
- package/dist/components/Toast/index.mjs +2 -1
- package/dist/components/Toast/index.mjs.map +1 -1
- package/dist/components/index.cjs +4 -3
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/components/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/components/Toast/ToastView.cjs +0 -174
- package/dist/components/Toast/ToastView.cjs.map +0 -1
- package/dist/components/Toast/ToastView.d.cts +0 -7
- package/dist/components/Toast/ToastView.d.cts.map +0 -1
- package/dist/components/Toast/ToastView.d.mts +0 -7
- package/dist/components/Toast/ToastView.d.mts.map +0 -1
- package/dist/components/Toast/ToastView.mjs +0 -155
- package/dist/components/Toast/ToastView.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g transform="matrix(0.025 0 0 0.025 0 24)"><path d="M520-520h278q-15-110-91.5-186.5T520-798v278Zm-80 358v-636q-121 15-200.5 105.5T160-480q0 122 79.5 212.5T440-162Zm80 0q110-14 187-91t91-187H520v278Zm-40-318Zm0 400q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 155.5 31.5t127 86q54.5 54.5 86 127T880-480q0 82-31.5 155T763-197.5q-54 54.5-127 86T480-80Z"/></g></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m12 1.75c5.3744 0 9.7498 4.31261 9.75 9.6553 0 2.944-1.3319 5.5763-3.4229 7.3447l.8516 2.1289.5479 1.3711h-15.45316l.54785-1.3711.85059-2.1289c-2.09058-1.7684-3.42188-4.4009-3.42188-7.3447.00023-5.34269 4.37561-9.6553 9.75-9.6553zm-4.77246 18.5h9.54496l-.1993-.5h-9.14644zm4.77246-16.5c-4.2903 0-7.74977 3.43755-7.75 7.6553 0 2.5903 1.30183 4.8843 3.30469 6.2724l.10449.0723h8.68162l.1045-.0723c2.0029-1.3881 3.3047-3.682 3.3047-6.2724-.0002-4.21775-3.4597-7.6553-7.75-7.6553zm3.5 5.25s.2355 1.173.7812 1.7188c.5458.5456 1.7187.7812 1.7188.7812-.0001 0-1.173.2356-1.7188.7812-.5456.5458-.7812 1.7187-.7812 1.7188 0-.0001-.2356-1.173-.7812-1.7188-.5458-.5457-1.7188-.7812-1.7188-.7812s1.173-.2356 1.7188-.7812c.5456-.5458.7812-1.71877.7812-1.7188zm-2.5-3s.1884.93838.625 1.375c.4365.43655 1.3747.62494 1.375.625-.0003.00005-.9385.18844-1.375.625s-.6249 1.37474-.625 1.375c-.0001-.00029-.1885-.93845-.625-1.375-.4366-.43662-1.375-.625-1.375-.625.0001-.00002.9384-.1884 1.375-.625s.625-1.37491.625-1.375z"/></svg>
|
|
@@ -1,61 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
6
|
exports.Toast = void 0;
|
|
27
7
|
// Third party dependencies.
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
8
|
+
const design_system_shared_1 = require("@metamask/design-system-shared");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
// External dependencies.
|
|
11
|
+
const BannerBase_1 = require("../BannerBase/index.cjs");
|
|
12
|
+
const IconAlert_1 = require("../IconAlert/index.cjs");
|
|
13
|
+
// Internal dependencies.
|
|
14
|
+
const Toast_constants_1 = require("./Toast.constants.cjs");
|
|
15
|
+
const Toast_types_1 = require("./Toast.types.cjs");
|
|
16
|
+
const renderSeverityAccessory = ({ iconAlertProps, severity, startAccessory, }) => {
|
|
17
|
+
if (startAccessory !== null && startAccessory !== undefined) {
|
|
18
|
+
return startAccessory;
|
|
34
19
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
(
|
|
40
|
-
showToast: (options) => innerRef.current?.showToast(options),
|
|
41
|
-
closeToast: () => innerRef.current?.closeToast(),
|
|
42
|
-
}), []);
|
|
43
|
-
(0, react_1.useEffect)(() => {
|
|
44
|
-
registeredRef = innerRef;
|
|
45
|
-
return () => {
|
|
46
|
-
if (registeredRef === innerRef) {
|
|
47
|
-
registeredRef = null;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}, []);
|
|
51
|
-
return <ToastView_1.ToastView ref={innerRef} {...props}/>;
|
|
52
|
-
});
|
|
53
|
-
ToastComponent.displayName = 'Toast';
|
|
54
|
-
exports.Toast = ToastComponent;
|
|
55
|
-
exports.Toast.show = (options) => {
|
|
56
|
-
assertRegisteredRef('show').showToast(options);
|
|
20
|
+
if (!severity || severity === Toast_types_1.ToastSeverity.Default) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const iconAlertSeverity = Toast_constants_1.TOAST_SEVERITY_ICON_MAP[severity];
|
|
24
|
+
return (<IconAlert_1.IconAlert severity={iconAlertSeverity} size={design_system_shared_1.IconSize.Lg} {...iconAlertProps}/>);
|
|
57
25
|
};
|
|
58
|
-
|
|
59
|
-
|
|
26
|
+
const Toast = ({ actionButtonLabel, actionButtonOnPress, actionButtonProps, children, childrenWrapperProps, closeButtonProps, description, descriptionProps, onClose, iconAlertProps, severity = Toast_types_1.ToastSeverity.Default, startAccessory, title, titleProps, twClassName, ...props }) => {
|
|
27
|
+
const actionProps = actionButtonLabel && actionButtonOnPress
|
|
28
|
+
? {
|
|
29
|
+
actionButtonLabel,
|
|
30
|
+
actionButtonOnPress,
|
|
31
|
+
actionButtonProps: {
|
|
32
|
+
size: design_system_shared_1.ButtonSize.Sm,
|
|
33
|
+
...actionButtonProps,
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
: {};
|
|
37
|
+
// TODO: Remove this conditional once BannerBase only renders a close button
|
|
38
|
+
// from onClose. At that point Toast can pass closeButtonProps directly.
|
|
39
|
+
const resolvedCloseButtonProps = onClose || closeButtonProps
|
|
40
|
+
? {
|
|
41
|
+
accessibilityLabel: 'Close toast',
|
|
42
|
+
...closeButtonProps,
|
|
43
|
+
}
|
|
44
|
+
: undefined;
|
|
45
|
+
return (<BannerBase_1.BannerBase {...actionProps} {...props} backgroundColor={design_system_shared_1.BoxBackgroundColor.BackgroundSection} borderColor={design_system_shared_1.BoxBorderColor.BorderMuted} borderWidth={1} children={children} childrenWrapperProps={childrenWrapperProps} closeButtonProps={resolvedCloseButtonProps} description={description} descriptionProps={descriptionProps} onClose={onClose} startAccessory={renderSeverityAccessory({
|
|
46
|
+
iconAlertProps,
|
|
47
|
+
severity,
|
|
48
|
+
startAccessory,
|
|
49
|
+
})} title={title} titleProps={titleProps} twClassName={twClassName ? `rounded-xl ${twClassName}` : 'rounded-xl'}/>);
|
|
60
50
|
};
|
|
51
|
+
exports.Toast = Toast;
|
|
61
52
|
//# sourceMappingURL=Toast.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toast.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":";;;;;;AAAA,4BAA4B;AAC5B,yEAKwC;AACxC,kDAA0B;AAE1B,yBAAyB;AACzB,wDAA2C;AAC3C,sDAAyC;AAEzC,yBAAyB;AACzB,2DAA4D;AAC5D,mDAA8C;AAG9C,MAAM,uBAAuB,GAAG,CAAC,EAC/B,cAAc,EACd,QAAQ,EACR,cAAc,GACqD,EAAE,EAAE;IACvE,IAAI,cAAc,KAAK,IAAI,IAAI,cAAc,KAAK,SAAS,EAAE;QAC3D,OAAO,cAAc,CAAC;KACvB;IAED,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,2BAAa,CAAC,OAAO,EAAE;QACnD,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,iBAAiB,GAAG,yCAAuB,CAAC,QAAQ,CAAC,CAAC;IAE5D,OAAO,CACL,CAAC,qBAAS,CACR,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAC5B,IAAI,CAAC,CAAC,+BAAQ,CAAC,EAAE,CAAC,CAClB,IAAI,cAAc,CAAC,EACnB,CACH,CAAC;AACJ,CAAC,CAAC;AAEK,MAAM,KAAK,GAAyB,CAAC,EAC1C,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,QAAQ,GAAG,2BAAa,CAAC,OAAO,EAChC,cAAc,EACd,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,WAAW,GACf,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;IACT,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,wBAAwB,GAC5B,OAAO,IAAI,gBAAgB;QACzB,CAAC,CAAC;YACE,kBAAkB,EAAE,aAAa;YACjC,GAAG,gBAAgB;SACpB;QACH,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,CACL,CAAC,uBAAU,CACT,IAAI,WAAW,CAAC,CAChB,IAAI,KAAK,CAAC,CACV,eAAe,CAAC,CAAC,yCAAkB,CAAC,iBAAiB,CAAC,CACtD,WAAW,CAAC,CAAC,qCAAc,CAAC,WAAW,CAAC,CACxC,WAAW,CAAC,CAAC,CAAC,CAAC,CACf,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,CAC3C,gBAAgB,CAAC,CAAC,wBAAwB,CAAC,CAC3C,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CACnC,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,cAAc,CAAC,CAAC,uBAAuB,CAAC;YACtC,cAAc;YACd,QAAQ;YACR,cAAc;SACf,CAAC,CAAC,CACH,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,WAAW,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,EACtE,CACH,CAAC;AACJ,CAAC,CAAC;AA9DW,QAAA,KAAK,SA8DhB","sourcesContent":["// Third party dependencies.\nimport {\n BoxBackgroundColor,\n BoxBorderColor,\n ButtonSize,\n IconSize,\n} from '@metamask/design-system-shared';\nimport React from 'react';\n\n// External dependencies.\nimport { BannerBase } from '../BannerBase';\nimport { IconAlert } from '../IconAlert';\n\n// Internal dependencies.\nimport { TOAST_SEVERITY_ICON_MAP } from './Toast.constants';\nimport { ToastSeverity } from './Toast.types';\nimport type { ToastProps } from './Toast.types';\n\nconst renderSeverityAccessory = ({\n iconAlertProps,\n severity,\n startAccessory,\n}: Pick<ToastProps, 'iconAlertProps' | 'severity' | 'startAccessory'>) => {\n if (startAccessory !== null && startAccessory !== undefined) {\n return startAccessory;\n }\n\n if (!severity || severity === ToastSeverity.Default) {\n return undefined;\n }\n\n const iconAlertSeverity = TOAST_SEVERITY_ICON_MAP[severity];\n\n return (\n <IconAlert\n severity={iconAlertSeverity}\n size={IconSize.Lg}\n {...iconAlertProps}\n />\n );\n};\n\nexport const Toast: React.FC<ToastProps> = ({\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n children,\n childrenWrapperProps,\n closeButtonProps,\n description,\n descriptionProps,\n onClose,\n iconAlertProps,\n severity = ToastSeverity.Default,\n startAccessory,\n title,\n titleProps,\n twClassName,\n ...props\n}) => {\n const actionProps =\n actionButtonLabel && actionButtonOnPress\n ? {\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps: {\n size: ButtonSize.Sm,\n ...actionButtonProps,\n },\n }\n : {};\n // TODO: Remove this conditional once BannerBase only renders a close button\n // from onClose. At that point Toast can pass closeButtonProps directly.\n const resolvedCloseButtonProps =\n onClose || closeButtonProps\n ? {\n accessibilityLabel: 'Close toast',\n ...closeButtonProps,\n }\n : undefined;\n\n return (\n <BannerBase\n {...actionProps}\n {...props}\n backgroundColor={BoxBackgroundColor.BackgroundSection}\n borderColor={BoxBorderColor.BorderMuted}\n borderWidth={1}\n children={children}\n childrenWrapperProps={childrenWrapperProps}\n closeButtonProps={resolvedCloseButtonProps}\n description={description}\n descriptionProps={descriptionProps}\n onClose={onClose}\n startAccessory={renderSeverityAccessory({\n iconAlertProps,\n severity,\n startAccessory,\n })}\n title={title}\n titleProps={titleProps}\n twClassName={twClassName ? `rounded-xl ${twClassName}` : 'rounded-xl'}\n />\n );\n};\n"]}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TOAST_BOTTOM_PADDING = exports.TOAST_ANIMATION_DURATION = exports.TOAST_VISIBILITY_DURATION = void 0;
|
|
3
|
+
exports.TOAST_SEVERITY_ICON_MAP = exports.TOAST_BOTTOM_PADDING = exports.TOAST_ANIMATION_DURATION = exports.TOAST_VISIBILITY_DURATION = void 0;
|
|
4
4
|
// External dependencies.
|
|
5
|
+
const design_system_shared_1 = require("@metamask/design-system-shared");
|
|
5
6
|
const design_tokens_1 = require("@metamask/design-tokens");
|
|
7
|
+
const Toast_types_1 = require("./Toast.types.cjs");
|
|
6
8
|
/**
|
|
7
9
|
* Animation constants.
|
|
8
10
|
*/
|
|
9
11
|
exports.TOAST_VISIBILITY_DURATION = 2750;
|
|
10
12
|
exports.TOAST_ANIMATION_DURATION = design_tokens_1.AnimationDuration.Regularly;
|
|
11
13
|
exports.TOAST_BOTTOM_PADDING = 36;
|
|
14
|
+
exports.TOAST_SEVERITY_ICON_MAP = {
|
|
15
|
+
[Toast_types_1.ToastSeverity.Success]: design_system_shared_1.IconAlertSeverity.Success,
|
|
16
|
+
[Toast_types_1.ToastSeverity.Warning]: design_system_shared_1.IconAlertSeverity.Warning,
|
|
17
|
+
[Toast_types_1.ToastSeverity.Danger]: design_system_shared_1.IconAlertSeverity.Error,
|
|
18
|
+
};
|
|
12
19
|
//# sourceMappingURL=Toast.constants.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.constants.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,2DAA4D;AAE5D;;GAEG;AACU,QAAA,yBAAyB,GAAG,IAAI,CAAC;AACjC,QAAA,wBAAwB,GAAG,iCAAiB,CAAC,SAAS,CAAC;AACvD,QAAA,oBAAoB,GAAG,EAAE,CAAC","sourcesContent":["// External dependencies.\nimport { AnimationDuration } from '@metamask/design-tokens';\n\n/**\n * Animation constants.\n */\nexport const TOAST_VISIBILITY_DURATION = 2750;\nexport const TOAST_ANIMATION_DURATION = AnimationDuration.Regularly;\nexport const TOAST_BOTTOM_PADDING = 36;\n"]}
|
|
1
|
+
{"version":3,"file":"Toast.constants.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,yEAAmE;AACnE,2DAA4D;AAE5D,mDAA8C;AAE9C;;GAEG;AACU,QAAA,yBAAyB,GAAG,IAAI,CAAC;AACjC,QAAA,wBAAwB,GAAG,iCAAiB,CAAC,SAAS,CAAC;AACvD,QAAA,oBAAoB,GAAG,EAAE,CAAC;AAE1B,QAAA,uBAAuB,GAAG;IACrC,CAAC,2BAAa,CAAC,OAAO,CAAC,EAAE,wCAAiB,CAAC,OAAO;IAClD,CAAC,2BAAa,CAAC,OAAO,CAAC,EAAE,wCAAiB,CAAC,OAAO;IAClD,CAAC,2BAAa,CAAC,MAAM,CAAC,EAAE,wCAAiB,CAAC,KAAK;CACvC,CAAC","sourcesContent":["// External dependencies.\nimport { IconAlertSeverity } from '@metamask/design-system-shared';\nimport { AnimationDuration } from '@metamask/design-tokens';\n\nimport { ToastSeverity } from './Toast.types';\n\n/**\n * Animation constants.\n */\nexport const TOAST_VISIBILITY_DURATION = 2750;\nexport const TOAST_ANIMATION_DURATION = AnimationDuration.Regularly;\nexport const TOAST_BOTTOM_PADDING = 36;\n\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: IconAlertSeverity.Success,\n [ToastSeverity.Warning]: IconAlertSeverity.Warning,\n [ToastSeverity.Danger]: IconAlertSeverity.Error,\n} as const;\n"]}
|
|
@@ -5,4 +5,9 @@ import { AnimationDuration } from "@metamask/design-tokens";
|
|
|
5
5
|
export declare const TOAST_VISIBILITY_DURATION = 2750;
|
|
6
6
|
export declare const TOAST_ANIMATION_DURATION = AnimationDuration.Regularly;
|
|
7
7
|
export declare const TOAST_BOTTOM_PADDING = 36;
|
|
8
|
+
export declare const TOAST_SEVERITY_ICON_MAP: {
|
|
9
|
+
readonly success: "success";
|
|
10
|
+
readonly warning: "warning";
|
|
11
|
+
readonly danger: "error";
|
|
12
|
+
};
|
|
8
13
|
//# sourceMappingURL=Toast.constants.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.constants.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toast.constants.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,gCAAgC;AAI5D;;GAEG;AACH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,wBAAwB,8BAA8B,CAAC;AACpE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
|
|
@@ -5,4 +5,9 @@ import { AnimationDuration } from "@metamask/design-tokens";
|
|
|
5
5
|
export declare const TOAST_VISIBILITY_DURATION = 2750;
|
|
6
6
|
export declare const TOAST_ANIMATION_DURATION = AnimationDuration.Regularly;
|
|
7
7
|
export declare const TOAST_BOTTOM_PADDING = 36;
|
|
8
|
+
export declare const TOAST_SEVERITY_ICON_MAP: {
|
|
9
|
+
readonly success: "success";
|
|
10
|
+
readonly warning: "warning";
|
|
11
|
+
readonly danger: "error";
|
|
12
|
+
};
|
|
8
13
|
//# sourceMappingURL=Toast.constants.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.constants.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toast.constants.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,gCAAgC;AAI5D;;GAEG;AACH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,wBAAwB,8BAA8B,CAAC;AACpE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,uBAAuB;;;;CAI1B,CAAC"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
// External dependencies.
|
|
2
|
+
import { IconAlertSeverity } from "@metamask/design-system-shared";
|
|
2
3
|
import { AnimationDuration } from "@metamask/design-tokens";
|
|
4
|
+
import { ToastSeverity } from "./Toast.types.mjs";
|
|
3
5
|
/**
|
|
4
6
|
* Animation constants.
|
|
5
7
|
*/
|
|
6
8
|
export const TOAST_VISIBILITY_DURATION = 2750;
|
|
7
9
|
export const TOAST_ANIMATION_DURATION = AnimationDuration.Regularly;
|
|
8
10
|
export const TOAST_BOTTOM_PADDING = 36;
|
|
11
|
+
export const TOAST_SEVERITY_ICON_MAP = {
|
|
12
|
+
[ToastSeverity.Success]: IconAlertSeverity.Success,
|
|
13
|
+
[ToastSeverity.Warning]: IconAlertSeverity.Warning,
|
|
14
|
+
[ToastSeverity.Danger]: IconAlertSeverity.Error,
|
|
15
|
+
};
|
|
9
16
|
//# sourceMappingURL=Toast.constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.constants.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,EAAE,iBAAiB,EAAE,gCAAgC;AAE5D;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC","sourcesContent":["// External dependencies.\nimport { AnimationDuration } from '@metamask/design-tokens';\n\n/**\n * Animation constants.\n */\nexport const TOAST_VISIBILITY_DURATION = 2750;\nexport const TOAST_ANIMATION_DURATION = AnimationDuration.Regularly;\nexport const TOAST_BOTTOM_PADDING = 36;\n"]}
|
|
1
|
+
{"version":3,"file":"Toast.constants.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.constants.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,EAAE,iBAAiB,EAAE,uCAAuC;AACnE,OAAO,EAAE,iBAAiB,EAAE,gCAAgC;AAE5D,OAAO,EAAE,aAAa,EAAE,0BAAsB;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,SAAS,CAAC;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEvC,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO;IAClD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC,OAAO;IAClD,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,KAAK;CACvC,CAAC","sourcesContent":["// External dependencies.\nimport { IconAlertSeverity } from '@metamask/design-system-shared';\nimport { AnimationDuration } from '@metamask/design-tokens';\n\nimport { ToastSeverity } from './Toast.types';\n\n/**\n * Animation constants.\n */\nexport const TOAST_VISIBILITY_DURATION = 2750;\nexport const TOAST_ANIMATION_DURATION = AnimationDuration.Regularly;\nexport const TOAST_BOTTOM_PADDING = 36;\n\nexport const TOAST_SEVERITY_ICON_MAP = {\n [ToastSeverity.Success]: IconAlertSeverity.Success,\n [ToastSeverity.Warning]: IconAlertSeverity.Warning,\n [ToastSeverity.Danger]: IconAlertSeverity.Error,\n} as const;\n"]}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
declare const
|
|
4
|
-
twClassName?: string | undefined;
|
|
5
|
-
labelsContainerProps?: Omit<import("react-native").ViewProps, "children" | "style"> | undefined;
|
|
6
|
-
} & Omit<import("react-native").ViewProps, "style"> & React.RefAttributes<ToastRef>>;
|
|
7
|
-
type ToastWithStatics = typeof ToastComponent & {
|
|
8
|
-
/**
|
|
9
|
-
* Show a toast notification. Requires `<Toast />` to be mounted.
|
|
10
|
-
*/
|
|
11
|
-
show: (options: ToastOptions) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Hide the currently visible toast, if any.
|
|
14
|
-
*/
|
|
15
|
-
hide: () => void;
|
|
16
|
-
};
|
|
17
|
-
export declare const Toast: ToastWithStatics;
|
|
18
|
-
export {};
|
|
2
|
+
import type { ToastProps } from "./Toast.types.cjs";
|
|
3
|
+
export declare const Toast: React.FC<ToastProps>;
|
|
19
4
|
//# sourceMappingURL=Toast.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toast.d.cts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,cAAc;AAS1B,OAAO,KAAK,EAAE,UAAU,EAAE,0BAAsB;AA0BhD,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CA8DtC,CAAC"}
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
declare const
|
|
4
|
-
twClassName?: string | undefined;
|
|
5
|
-
labelsContainerProps?: Omit<import("react-native").ViewProps, "children" | "style"> | undefined;
|
|
6
|
-
} & Omit<import("react-native").ViewProps, "style"> & React.RefAttributes<ToastRef>>;
|
|
7
|
-
type ToastWithStatics = typeof ToastComponent & {
|
|
8
|
-
/**
|
|
9
|
-
* Show a toast notification. Requires `<Toast />` to be mounted.
|
|
10
|
-
*/
|
|
11
|
-
show: (options: ToastOptions) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Hide the currently visible toast, if any.
|
|
14
|
-
*/
|
|
15
|
-
hide: () => void;
|
|
16
|
-
};
|
|
17
|
-
export declare const Toast: ToastWithStatics;
|
|
18
|
-
export {};
|
|
2
|
+
import type { ToastProps } from "./Toast.types.mjs";
|
|
3
|
+
export declare const Toast: React.FC<ToastProps>;
|
|
19
4
|
//# sourceMappingURL=Toast.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Toast.d.mts","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,cAAc;AAS1B,OAAO,KAAK,EAAE,UAAU,EAAE,0BAAsB;AA0BhD,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CA8DtC,CAAC"}
|
|
@@ -5,38 +5,48 @@ function $importDefault(module) {
|
|
|
5
5
|
return module;
|
|
6
6
|
}
|
|
7
7
|
// Third party dependencies.
|
|
8
|
-
import
|
|
8
|
+
import { BoxBackgroundColor, BoxBorderColor, ButtonSize, IconSize } from "@metamask/design-system-shared";
|
|
9
|
+
import $React from "react";
|
|
9
10
|
const React = $importDefault($React);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
// External dependencies.
|
|
12
|
+
import { BannerBase } from "../BannerBase/index.mjs";
|
|
13
|
+
import { IconAlert } from "../IconAlert/index.mjs";
|
|
14
|
+
// Internal dependencies.
|
|
15
|
+
import { TOAST_SEVERITY_ICON_MAP } from "./Toast.constants.mjs";
|
|
16
|
+
import { ToastSeverity } from "./Toast.types.mjs";
|
|
17
|
+
const renderSeverityAccessory = ({ iconAlertProps, severity, startAccessory, }) => {
|
|
18
|
+
if (startAccessory !== null && startAccessory !== undefined) {
|
|
19
|
+
return startAccessory;
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
showToast: (options) => innerRef.current?.showToast(options),
|
|
22
|
-
closeToast: () => innerRef.current?.closeToast(),
|
|
23
|
-
}), []);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
registeredRef = innerRef;
|
|
26
|
-
return () => {
|
|
27
|
-
if (registeredRef === innerRef) {
|
|
28
|
-
registeredRef = null;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
32
|
-
return <ToastView ref={innerRef} {...props}/>;
|
|
33
|
-
});
|
|
34
|
-
ToastComponent.displayName = 'Toast';
|
|
35
|
-
export const Toast = ToastComponent;
|
|
36
|
-
Toast.show = (options) => {
|
|
37
|
-
assertRegisteredRef('show').showToast(options);
|
|
21
|
+
if (!severity || severity === ToastSeverity.Default) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const iconAlertSeverity = TOAST_SEVERITY_ICON_MAP[severity];
|
|
25
|
+
return (<IconAlert severity={iconAlertSeverity} size={IconSize.Lg} {...iconAlertProps}/>);
|
|
38
26
|
};
|
|
39
|
-
Toast
|
|
40
|
-
|
|
27
|
+
export const Toast = ({ actionButtonLabel, actionButtonOnPress, actionButtonProps, children, childrenWrapperProps, closeButtonProps, description, descriptionProps, onClose, iconAlertProps, severity = ToastSeverity.Default, startAccessory, title, titleProps, twClassName, ...props }) => {
|
|
28
|
+
const actionProps = actionButtonLabel && actionButtonOnPress
|
|
29
|
+
? {
|
|
30
|
+
actionButtonLabel,
|
|
31
|
+
actionButtonOnPress,
|
|
32
|
+
actionButtonProps: {
|
|
33
|
+
size: ButtonSize.Sm,
|
|
34
|
+
...actionButtonProps,
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
: {};
|
|
38
|
+
// TODO: Remove this conditional once BannerBase only renders a close button
|
|
39
|
+
// from onClose. At that point Toast can pass closeButtonProps directly.
|
|
40
|
+
const resolvedCloseButtonProps = onClose || closeButtonProps
|
|
41
|
+
? {
|
|
42
|
+
accessibilityLabel: 'Close toast',
|
|
43
|
+
...closeButtonProps,
|
|
44
|
+
}
|
|
45
|
+
: undefined;
|
|
46
|
+
return (<BannerBase {...actionProps} {...props} backgroundColor={BoxBackgroundColor.BackgroundSection} borderColor={BoxBorderColor.BorderMuted} borderWidth={1} children={children} childrenWrapperProps={childrenWrapperProps} closeButtonProps={resolvedCloseButtonProps} description={description} descriptionProps={descriptionProps} onClose={onClose} startAccessory={renderSeverityAccessory({
|
|
47
|
+
iconAlertProps,
|
|
48
|
+
severity,
|
|
49
|
+
startAccessory,
|
|
50
|
+
})} title={title} titleProps={titleProps} twClassName={twClassName ? `rounded-xl ${twClassName}` : 'rounded-xl'}/>);
|
|
41
51
|
};
|
|
42
52
|
//# sourceMappingURL=Toast.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":";;;;;;AAAA,4BAA4B;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"Toast.mjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.tsx"],"names":[],"mappings":";;;;;;AAAA,4BAA4B;AAC5B,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,QAAQ,EACT,uCAAuC;AACxC,OAAO,MAAK,cAAc;;AAE1B,yBAAyB;AACzB,OAAO,EAAE,UAAU,EAAE,gCAAsB;AAC3C,OAAO,EAAE,SAAS,EAAE,+BAAqB;AAEzC,yBAAyB;AACzB,OAAO,EAAE,uBAAuB,EAAE,8BAA0B;AAC5D,OAAO,EAAE,aAAa,EAAE,0BAAsB;AAG9C,MAAM,uBAAuB,GAAG,CAAC,EAC/B,cAAc,EACd,QAAQ,EACR,cAAc,GACqD,EAAE,EAAE;IACvE,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,iBAAiB,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAE5D,OAAO,CACL,CAAC,SAAS,CACR,QAAQ,CAAC,CAAC,iBAAiB,CAAC,CAC5B,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClB,IAAI,cAAc,CAAC,EACnB,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAyB,CAAC,EAC1C,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,QAAQ,GAAG,aAAa,CAAC,OAAO,EAChC,cAAc,EACd,KAAK,EACL,UAAU,EACV,WAAW,EACX,GAAG,KAAK,EACT,EAAE,EAAE;IACH,MAAM,WAAW,GACf,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;IACT,4EAA4E;IAC5E,wEAAwE;IACxE,MAAM,wBAAwB,GAC5B,OAAO,IAAI,gBAAgB;QACzB,CAAC,CAAC;YACE,kBAAkB,EAAE,aAAa;YACjC,GAAG,gBAAgB;SACpB;QACH,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO,CACL,CAAC,UAAU,CACT,IAAI,WAAW,CAAC,CAChB,IAAI,KAAK,CAAC,CACV,eAAe,CAAC,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CACtD,WAAW,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,CACxC,WAAW,CAAC,CAAC,CAAC,CAAC,CACf,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,oBAAoB,CAAC,CAAC,oBAAoB,CAAC,CAC3C,gBAAgB,CAAC,CAAC,wBAAwB,CAAC,CAC3C,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,gBAAgB,CAAC,CAAC,gBAAgB,CAAC,CACnC,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,cAAc,CAAC,CAAC,uBAAuB,CAAC;YACtC,cAAc;YACd,QAAQ;YACR,cAAc;SACf,CAAC,CAAC,CACH,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,WAAW,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,WAAW,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,EACtE,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Third party dependencies.\nimport {\n BoxBackgroundColor,\n BoxBorderColor,\n ButtonSize,\n IconSize,\n} from '@metamask/design-system-shared';\nimport React from 'react';\n\n// External dependencies.\nimport { BannerBase } from '../BannerBase';\nimport { IconAlert } from '../IconAlert';\n\n// Internal dependencies.\nimport { TOAST_SEVERITY_ICON_MAP } from './Toast.constants';\nimport { ToastSeverity } from './Toast.types';\nimport type { ToastProps } from './Toast.types';\n\nconst renderSeverityAccessory = ({\n iconAlertProps,\n severity,\n startAccessory,\n}: Pick<ToastProps, 'iconAlertProps' | 'severity' | 'startAccessory'>) => {\n if (startAccessory !== null && startAccessory !== undefined) {\n return startAccessory;\n }\n\n if (!severity || severity === ToastSeverity.Default) {\n return undefined;\n }\n\n const iconAlertSeverity = TOAST_SEVERITY_ICON_MAP[severity];\n\n return (\n <IconAlert\n severity={iconAlertSeverity}\n size={IconSize.Lg}\n {...iconAlertProps}\n />\n );\n};\n\nexport const Toast: React.FC<ToastProps> = ({\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps,\n children,\n childrenWrapperProps,\n closeButtonProps,\n description,\n descriptionProps,\n onClose,\n iconAlertProps,\n severity = ToastSeverity.Default,\n startAccessory,\n title,\n titleProps,\n twClassName,\n ...props\n}) => {\n const actionProps =\n actionButtonLabel && actionButtonOnPress\n ? {\n actionButtonLabel,\n actionButtonOnPress,\n actionButtonProps: {\n size: ButtonSize.Sm,\n ...actionButtonProps,\n },\n }\n : {};\n // TODO: Remove this conditional once BannerBase only renders a close button\n // from onClose. At that point Toast can pass closeButtonProps directly.\n const resolvedCloseButtonProps =\n onClose || closeButtonProps\n ? {\n accessibilityLabel: 'Close toast',\n ...closeButtonProps,\n }\n : undefined;\n\n return (\n <BannerBase\n {...actionProps}\n {...props}\n backgroundColor={BoxBackgroundColor.BackgroundSection}\n borderColor={BoxBorderColor.BorderMuted}\n borderWidth={1}\n children={children}\n childrenWrapperProps={childrenWrapperProps}\n closeButtonProps={resolvedCloseButtonProps}\n description={description}\n descriptionProps={descriptionProps}\n onClose={onClose}\n startAccessory={renderSeverityAccessory({\n iconAlertProps,\n severity,\n startAccessory,\n })}\n title={title}\n titleProps={titleProps}\n twClassName={twClassName ? `rounded-xl ${twClassName}` : 'rounded-xl'}\n />\n );\n};\n"]}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ToastSeverity = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* Toast variants.
|
|
5
|
+
* Toast severity variants.
|
|
6
|
+
* `Default` renders no built-in leading icon.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ToastVariant["Icon"] = "Icon";
|
|
14
|
-
})(ToastVariant || (exports.ToastVariant = ToastVariant = {}));
|
|
15
|
-
var ToastCloseButtonVariant;
|
|
16
|
-
(function (ToastCloseButtonVariant) {
|
|
17
|
-
ToastCloseButtonVariant["Icon"] = "Icon";
|
|
18
|
-
})(ToastCloseButtonVariant || (exports.ToastCloseButtonVariant = ToastCloseButtonVariant = {}));
|
|
8
|
+
exports.ToastSeverity = {
|
|
9
|
+
Default: 'default',
|
|
10
|
+
Success: 'success',
|
|
11
|
+
Warning: 'warning',
|
|
12
|
+
Danger: 'danger',
|
|
13
|
+
};
|
|
19
14
|
//# sourceMappingURL=Toast.types.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toast.types.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Toast.types.cjs","sourceRoot":"","sources":["../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":";;;AAKA;;;GAGG;AACU,QAAA,aAAa,GAAG;IAC3B,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;CACR,CAAC","sourcesContent":["import type { ViewProps } from 'react-native';\n\nimport type { BannerBaseProps } from '../BannerBase';\nimport type { IconProps } from '../Icon/Icon.types';\n\n/**\n * Toast severity variants.\n * `Default` renders no built-in leading icon.\n */\nexport const ToastSeverity = {\n Default: 'default',\n Success: 'success',\n Warning: 'warning',\n Danger: 'danger',\n} as const;\n\nexport type ToastSeverity = (typeof ToastSeverity)[keyof typeof ToastSeverity];\n\n/**\n * Optional props for the leading severity `Icon`.\n */\nexport type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;\n\n/**\n * Shared toast props aligned with BannerBase, plus optional severity/icon props.\n */\nexport type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {\n closeButtonProps?: Omit<\n NonNullable<BannerBaseProps['closeButtonProps']>,\n 'onPress'\n >;\n severity?: ToastSeverity;\n iconAlertProps?: ToastIconProps;\n};\n\n/**\n * Toast options used by the imperative `toast(...)` API.\n */\nexport type ToastOptions = ToastSharedProps & {\n hasNoTimeout?: boolean;\n bottomOffset?: number;\n};\n\n/**\n * Toaster component reference.\n */\nexport type ToasterRef = {\n showToast: (toastOptions: ToastOptions) => void;\n closeToast: () => void;\n};\n\n/**\n * Toast component props intended for direct rendering of a single toast surface.\n */\nexport type ToastProps = ToastSharedProps;\n\n/**\n * Toaster component props.\n * Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.\n */\nexport type ToasterProps = {\n /**\n * Optional Tailwind CSS classes for the toast container.\n */\n twClassName?: string;\n} & Omit<ViewProps, 'style'>;\n"]}
|
|
@@ -1,117 +1,55 @@
|
|
|
1
|
-
import type { AvatarIconSeverity, IconName } from "@metamask/design-system-shared";
|
|
2
|
-
import type { ReactElement } from "react";
|
|
3
1
|
import type { ViewProps } from "react-native/index.js";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type { ButtonIconProps } from "../ButtonIcon/index.cjs";
|
|
7
|
-
import type { ImageOrSvgSrc } from "../temp-components/ImageOrSvg/index.cjs";
|
|
2
|
+
import type { BannerBaseProps } from "../BannerBase/index.cjs";
|
|
3
|
+
import type { IconProps } from "../Icon/Icon.types.cjs";
|
|
8
4
|
/**
|
|
9
|
-
* Toast variants.
|
|
5
|
+
* Toast severity variants.
|
|
6
|
+
* `Default` renders no built-in leading icon.
|
|
10
7
|
*/
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
export declare const ToastSeverity: {
|
|
9
|
+
readonly Default: "default";
|
|
10
|
+
readonly Success: "success";
|
|
11
|
+
readonly Warning: "warning";
|
|
12
|
+
readonly Danger: "danger";
|
|
13
|
+
};
|
|
14
|
+
export type ToastSeverity = (typeof ToastSeverity)[keyof typeof ToastSeverity];
|
|
18
15
|
/**
|
|
19
|
-
*
|
|
16
|
+
* Optional props for the leading severity `Icon`.
|
|
20
17
|
*/
|
|
21
|
-
export type
|
|
22
|
-
label: string;
|
|
23
|
-
isBold?: boolean;
|
|
24
|
-
}[];
|
|
18
|
+
export type ToastIconProps = Omit<IconProps, 'name' | 'size' | 'color'>;
|
|
25
19
|
/**
|
|
26
|
-
*
|
|
20
|
+
* Shared toast props aligned with BannerBase, plus optional severity/icon props.
|
|
27
21
|
*/
|
|
28
|
-
export type
|
|
29
|
-
|
|
22
|
+
export type ToastSharedProps = Omit<BannerBaseProps, 'closeButtonProps'> & {
|
|
23
|
+
closeButtonProps?: Omit<NonNullable<BannerBaseProps['closeButtonProps']>, 'onPress'>;
|
|
24
|
+
severity?: ToastSeverity;
|
|
25
|
+
iconAlertProps?: ToastIconProps;
|
|
30
26
|
};
|
|
31
27
|
/**
|
|
32
|
-
*
|
|
28
|
+
* Toast options used by the imperative `toast(...)` API.
|
|
33
29
|
*/
|
|
34
|
-
export type
|
|
35
|
-
|
|
36
|
-
onPress: () => void;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Common toast option shared between all other options.
|
|
40
|
-
*/
|
|
41
|
-
type BaseToastVariants = {
|
|
42
|
-
hasNoTimeout: boolean;
|
|
43
|
-
labelOptions: ToastLabelOptions;
|
|
44
|
-
descriptionOptions?: ToastDescriptionOptions;
|
|
45
|
-
linkButtonOptions?: ToastLinkButtonOptions;
|
|
46
|
-
closeButtonOptions?: ToastCloseButtonOptions;
|
|
47
|
-
startAccessory?: ReactElement;
|
|
30
|
+
export type ToastOptions = ToastSharedProps & {
|
|
31
|
+
hasNoTimeout?: boolean;
|
|
48
32
|
bottomOffset?: number;
|
|
49
33
|
};
|
|
50
|
-
export type ToastCloseButtonIconOptions = Omit<ButtonIconProps, 'variant'> & {
|
|
51
|
-
variant: ToastCloseButtonVariant;
|
|
52
|
-
};
|
|
53
|
-
export type ToastCloseButtonOptions = ButtonProps | ToastCloseButtonIconOptions;
|
|
54
|
-
export declare enum ToastCloseButtonVariant {
|
|
55
|
-
Icon = "Icon"
|
|
56
|
-
}
|
|
57
34
|
/**
|
|
58
|
-
*
|
|
35
|
+
* Toaster component reference.
|
|
59
36
|
*/
|
|
60
|
-
type
|
|
61
|
-
variant: ToastVariant.Plain;
|
|
62
|
-
} & BaseToastVariants;
|
|
63
|
-
/**
|
|
64
|
-
* Account toast option.
|
|
65
|
-
*/
|
|
66
|
-
type AccountToastOption = {
|
|
67
|
-
variant: ToastVariant.Account;
|
|
68
|
-
accountAddress: string;
|
|
69
|
-
accountAvatarType: AvatarAccountVariant;
|
|
70
|
-
} & BaseToastVariants;
|
|
71
|
-
/**
|
|
72
|
-
* Network toast option.
|
|
73
|
-
*/
|
|
74
|
-
type NetworkToastOption = {
|
|
75
|
-
variant: ToastVariant.Network;
|
|
76
|
-
networkName?: string;
|
|
77
|
-
networkImageSource: ImageOrSvgSrc;
|
|
78
|
-
} & BaseToastVariants;
|
|
79
|
-
/**
|
|
80
|
-
* App toast option.
|
|
81
|
-
*/
|
|
82
|
-
type AppToastOption = {
|
|
83
|
-
variant: ToastVariant.App;
|
|
84
|
-
appIconSource: ImageOrSvgSrc;
|
|
85
|
-
} & BaseToastVariants;
|
|
86
|
-
type IconToastOption = {
|
|
87
|
-
variant: ToastVariant.Icon;
|
|
88
|
-
iconName: IconName;
|
|
89
|
-
severity?: AvatarIconSeverity;
|
|
90
|
-
} & BaseToastVariants;
|
|
91
|
-
/**
|
|
92
|
-
* Different toast options combined in a union type.
|
|
93
|
-
*/
|
|
94
|
-
export type ToastOptions = PlainToastOption | AccountToastOption | NetworkToastOption | AppToastOption | IconToastOption;
|
|
95
|
-
/**
|
|
96
|
-
* Toast component reference.
|
|
97
|
-
*/
|
|
98
|
-
export type ToastRef = {
|
|
37
|
+
export type ToasterRef = {
|
|
99
38
|
showToast: (toastOptions: ToastOptions) => void;
|
|
100
39
|
closeToast: () => void;
|
|
101
40
|
};
|
|
102
41
|
/**
|
|
103
|
-
* Toast component props.
|
|
42
|
+
* Toast component props intended for direct rendering of a single toast surface.
|
|
43
|
+
*/
|
|
44
|
+
export type ToastProps = ToastSharedProps;
|
|
45
|
+
/**
|
|
46
|
+
* Toaster component props.
|
|
104
47
|
* Extends ViewProps to inherit standard React Native props such as testID and accessibilityLabel.
|
|
105
48
|
*/
|
|
106
|
-
export type
|
|
49
|
+
export type ToasterProps = {
|
|
107
50
|
/**
|
|
108
51
|
* Optional Tailwind CSS classes for the toast container.
|
|
109
52
|
*/
|
|
110
53
|
twClassName?: string;
|
|
111
|
-
/**
|
|
112
|
-
* Props spread to the labels container View (e.g., testID for testing).
|
|
113
|
-
*/
|
|
114
|
-
labelsContainerProps?: Omit<ViewProps, 'children' | 'style'>;
|
|
115
54
|
} & Omit<ViewProps, 'style'>;
|
|
116
|
-
export {};
|
|
117
55
|
//# sourceMappingURL=Toast.types.d.cts.map
|