@synerise/ds-toast 1.3.1 → 1.4.1
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 +14 -0
- package/README.md +1 -0
- package/dist/Toast.d.ts +1 -1
- package/dist/Toast.js +23 -4
- package/dist/Toast.types.d.ts +9 -1
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.4.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-toast@1.4.0...@synerise/ds-toast@1.4.1) (2026-02-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-toast
|
|
9
|
+
|
|
10
|
+
# [1.4.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-toast@1.3.1...@synerise/ds-toast@1.4.0) (2026-01-29)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **toast:** wire up dismiss ([094da31](https://github.com/Synerise/synerise-design/commit/094da318d43f99fb8dd64262efce6ee1c95b46a1))
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- **toast:** adds onDismiss prop ([613bc09](https://github.com/Synerise/synerise-design/commit/613bc099cdb2639df3cc0c93d59bff275f5b897c))
|
|
19
|
+
|
|
6
20
|
## [1.3.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-toast@1.3.0...@synerise/ds-toast@1.3.1) (2026-01-22)
|
|
7
21
|
|
|
8
22
|
**Note:** Version bump only for package @synerise/ds-toast
|
package/README.md
CHANGED
|
@@ -41,6 +41,7 @@ import Button from '@synerise/ds-button';
|
|
|
41
41
|
| expanded | toggles rendering expanded content | boolean | - |
|
|
42
42
|
| withClose | renders X icon to manually dismiss toast | boolean | - |
|
|
43
43
|
| onCloseClick | triggered on click of close icon | () => void | - |
|
|
44
|
+
| onDismiss | triggered when toast is dismissed | () => void | - |
|
|
44
45
|
| button | button element to render below message content | ReactNode | - |
|
|
45
46
|
|
|
46
47
|
## Static methods
|
package/dist/Toast.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type ShowToastProps, type ToastCustomisationOptions, type ToastProps, type ToastType } from './Toast.types';
|
|
3
3
|
export declare const Toast: {
|
|
4
|
-
({ type, message, description, expander, expandedContent, withClose, customIcon, expanded, onExpand, onCloseClick, button, ...htmlAttributes }: ToastProps): React.JSX.Element;
|
|
4
|
+
({ type, message, description, expander, expandedContent, withClose, customIcon, expanded, onExpand, onCloseClick, onDismiss, button, toastId, ...htmlAttributes }: ToastProps): React.JSX.Element;
|
|
5
5
|
success(props: ShowToastProps, options?: ToastCustomisationOptions): string;
|
|
6
6
|
error(props: ShowToastProps, options?: ToastCustomisationOptions): string;
|
|
7
7
|
info(props: ShowToastProps, options?: ToastCustomisationOptions): string;
|
package/dist/Toast.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
var _excluded = ["type", "message", "description", "expander", "expandedContent", "withClose", "customIcon", "expanded", "onExpand", "onCloseClick", "button"];
|
|
1
|
+
var _excluded = ["type", "message", "description", "expander", "expandedContent", "withClose", "customIcon", "expanded", "onExpand", "onCloseClick", "onDismiss", "button", "toastId"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import React, { useCallback, useMemo } from 'react';
|
|
4
|
+
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
5
5
|
import toast from 'react-hot-toast';
|
|
6
|
+
import { v4 as uuid } from 'uuid';
|
|
6
7
|
import Icon, { AngleDownS, CloseM } from '@synerise/ds-icon';
|
|
7
8
|
import * as S from './Toast.styles';
|
|
8
9
|
import { ICONS } from './constants';
|
|
10
|
+
import { removeToast } from './utils';
|
|
9
11
|
export var Toast = function Toast(_ref) {
|
|
10
12
|
var type = _ref.type,
|
|
11
13
|
message = _ref.message,
|
|
@@ -17,7 +19,9 @@ export var Toast = function Toast(_ref) {
|
|
|
17
19
|
expanded = _ref.expanded,
|
|
18
20
|
onExpand = _ref.onExpand,
|
|
19
21
|
onCloseClick = _ref.onCloseClick,
|
|
22
|
+
onDismiss = _ref.onDismiss,
|
|
20
23
|
button = _ref.button,
|
|
24
|
+
toastId = _ref.toastId,
|
|
21
25
|
htmlAttributes = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
26
|
var hasToastContent = button || description || expandedContent;
|
|
23
27
|
var toastContent = hasToastContent && /*#__PURE__*/React.createElement(S.AlertContent, {
|
|
@@ -35,6 +39,17 @@ export var Toast = function Toast(_ref) {
|
|
|
35
39
|
var expandContent = useCallback(function () {
|
|
36
40
|
onExpand && onExpand(!expanded);
|
|
37
41
|
}, [onExpand, expanded]);
|
|
42
|
+
var handleCloseClick = function handleCloseClick() {
|
|
43
|
+
onCloseClick == null || onCloseClick();
|
|
44
|
+
if (toastId) {
|
|
45
|
+
removeToast(toastId);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
return function () {
|
|
50
|
+
onDismiss == null || onDismiss();
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
38
53
|
return /*#__PURE__*/React.createElement(S.Container, _extends({
|
|
39
54
|
toastType: type,
|
|
40
55
|
"data-toastType": type
|
|
@@ -51,15 +66,19 @@ export var Toast = function Toast(_ref) {
|
|
|
51
66
|
component: /*#__PURE__*/React.createElement(AngleDownS, null),
|
|
52
67
|
size: 24
|
|
53
68
|
})), withClose && /*#__PURE__*/React.createElement(S.IconCloseWrapper, {
|
|
54
|
-
onClick:
|
|
69
|
+
onClick: handleCloseClick
|
|
55
70
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
56
71
|
component: /*#__PURE__*/React.createElement(CloseM, null)
|
|
57
72
|
}))), toastContent));
|
|
58
73
|
};
|
|
59
74
|
export var showToast = function showToast(type, props, options) {
|
|
75
|
+
var toastId = props.toastId || "toast-" + uuid();
|
|
60
76
|
return toast.custom(/*#__PURE__*/React.createElement(Toast, _extends({}, props, {
|
|
77
|
+
toastId: toastId,
|
|
61
78
|
type: type
|
|
62
|
-
})), options
|
|
79
|
+
})), _extends({}, options, {
|
|
80
|
+
id: toastId
|
|
81
|
+
}));
|
|
63
82
|
};
|
|
64
83
|
Toast.success = function (props, options) {
|
|
65
84
|
return showToast('success', props, options);
|
package/dist/Toast.types.d.ts
CHANGED
|
@@ -9,11 +9,19 @@ export type ToastProps = WithHTMLAttributes<HTMLDivElement, {
|
|
|
9
9
|
customIcon?: ReactElement;
|
|
10
10
|
expander?: boolean;
|
|
11
11
|
expandedContent?: ReactNode;
|
|
12
|
-
withClose?:
|
|
12
|
+
withClose?: boolean;
|
|
13
13
|
button?: ReactNode;
|
|
14
14
|
expanded?: boolean;
|
|
15
15
|
onExpand?: (isExpanded: boolean) => void;
|
|
16
|
+
/**
|
|
17
|
+
* fired when user manually dismisses the toast by clicking the X button
|
|
18
|
+
*/
|
|
16
19
|
onCloseClick?: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* fired when toast is dismissed (both manually or after timeout)
|
|
22
|
+
*/
|
|
23
|
+
onDismiss?: () => void;
|
|
24
|
+
toastId?: string;
|
|
17
25
|
}>;
|
|
18
26
|
export type ToastCustomisationOptions = Pick<ToastOptions, 'duration' | 'position' | 'id' | 'removeDelay' | 'className' | 'style'>;
|
|
19
27
|
export type ShowToastProps = Omit<ToastProps, 'type'>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-toast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Toast UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "pnpm run build:js && pnpm run build:css && pnpm run defs",
|
|
20
20
|
"build:css": "node ../../../scripts/style/less.js",
|
|
21
21
|
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
22
|
-
"build:watch": "
|
|
22
|
+
"build:watch": "pnpm run build:js -- --watch",
|
|
23
23
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
24
|
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
25
|
-
"prepublish": "
|
|
25
|
+
"prepublish": "pnpm run build",
|
|
26
26
|
"test": "jest",
|
|
27
|
-
"test:watch": "
|
|
27
|
+
"test:watch": "pnpm run test -- --watchAll",
|
|
28
28
|
"types": "tsc --noEmit",
|
|
29
29
|
"check:circular-dependencies": "madge --circular --extensions ts,tsx,js,jsx --ts-config tsconfig.json src/ --exclude '/dist/'",
|
|
30
30
|
"upgrade:ds": "ncu -f \"@synerise/ds-*\" -u"
|
|
@@ -35,14 +35,15 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-icon": "^1.
|
|
39
|
-
"@synerise/ds-unordered-list": "^1.1.
|
|
40
|
-
"@synerise/ds-utils": "^1.5.
|
|
41
|
-
"react-hot-toast": "^2.5.2"
|
|
38
|
+
"@synerise/ds-icon": "^1.11.0",
|
|
39
|
+
"@synerise/ds-unordered-list": "^1.1.29",
|
|
40
|
+
"@synerise/ds-utils": "^1.5.4",
|
|
41
|
+
"react-hot-toast": "^2.5.2",
|
|
42
|
+
"uuid": "^8.3.2"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@synerise/ds-core": "*",
|
|
45
46
|
"react": ">=16.9.0 <= 18.3.1"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "6a3a82f8bc80e10eeb818795035e05393550e82e"
|
|
48
49
|
}
|