Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-simple-toasts

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-toasts - npm Package Compare versions

Comparing version 3.5.1 to 3.5.2

3

dist/index.d.ts

@@ -12,3 +12,3 @@ import { ReactNode, SyntheticEvent } from 'react';

type ClickHandler = (e: SyntheticEvent<HTMLDivElement>) => void | Promise<void>;
type Position = typeof ToastPosition[keyof typeof ToastPosition];
type Position = (typeof ToastPosition)[keyof typeof ToastPosition];
export interface ToastOptions {

@@ -42,4 +42,5 @@ /**

export declare const toastConfig: (options: ConfigArgs) => void;
export declare const clearToasts: () => void;
declare function toast(message: ReactNode, duration?: number): Toast;
declare function toast(message: ReactNode, options?: ToastOptions): Toast;
export default toast;

@@ -189,9 +189,9 @@ import React, { Fragment, cloneElement, useRef, useState, useLayoutEffect } from 'react';

toastsByPosition = _a[1];
return React.createElement("div", {
return /*#__PURE__*/React.createElement("div", {
key: position,
className: "".concat(styles['toast-list'], " ").concat(styles[position])
}, toastsByPosition.map(function (t) {
return React.createElement(Fragment, {
return /*#__PURE__*/React.createElement(Fragment, {
key: t.id
}, cloneElement(t.component, {
}, /*#__PURE__*/cloneElement(t.component, {
isExit: t.isExit

@@ -201,4 +201,10 @@ }));

});
render(React.createElement(React.Fragment, null, toastListComponent), toastContainer);
render( /*#__PURE__*/React.createElement(React.Fragment, null, toastListComponent), toastContainer);
};
var clearToasts = function () {
toastComponentList.forEach(function (toast) {
return toast.isExit = true;
});
renderDOM();
};
var Toast = function (_a) {

@@ -238,6 +244,6 @@ var message = _a.message,

};
return React.createElement("div", {
return /*#__PURE__*/React.createElement("div", {
ref: messageDOM,
className: "".concat(styles['toast-message'], " ").concat(isEnter ? 'toast-enter-active' : '', " ").concat(isExit ? 'toast-exit-active' : '', " ").concat(className)
}, render ? render(message) : React.createElement("div", __assign({
}, render ? render(message) : /*#__PURE__*/React.createElement("div", __assign({
className: contentClassNames

@@ -324,3 +330,3 @@ }, clickable && clickableProps), message));

position: position,
component: React.createElement(Toast, {
component: /*#__PURE__*/React.createElement(Toast, {
message: message,

@@ -352,3 +358,2 @@ className: className,

closeTimer = window.setTimeout(function () {
console.log('close');
closeToast(id, closeOptions);

@@ -374,3 +379,3 @@ }, duration);

toastComponentList[index].message = newMessage;
toastComponentList[index].component = React.createElement(Toast, {
toastComponentList[index].component = /*#__PURE__*/React.createElement(Toast, {
message: newMessage,

@@ -392,3 +397,3 @@ className: className,

export { ToastPosition, toast as default, toastConfig };
export { ToastPosition, clearToasts, toast as default, toastConfig };
//# sourceMappingURL=index.es.js.map

@@ -212,9 +212,9 @@ 'use strict';

toastsByPosition = _a[1];
return React.createElement("div", {
return /*#__PURE__*/React.createElement("div", {
key: position,
className: "".concat(styles['toast-list'], " ").concat(styles[position])
}, toastsByPosition.map(function (t) {
return React.createElement(React.Fragment, {
return /*#__PURE__*/React.createElement(React.Fragment, {
key: t.id
}, React.cloneElement(t.component, {
}, /*#__PURE__*/React.cloneElement(t.component, {
isExit: t.isExit

@@ -224,4 +224,10 @@ }));

});
render(React.createElement(React.Fragment, null, toastListComponent), toastContainer);
render( /*#__PURE__*/React.createElement(React.Fragment, null, toastListComponent), toastContainer);
};
var clearToasts = function () {
toastComponentList.forEach(function (toast) {
return toast.isExit = true;
});
renderDOM();
};
var Toast = function (_a) {

@@ -261,6 +267,6 @@ var message = _a.message,

};
return React.createElement("div", {
return /*#__PURE__*/React.createElement("div", {
ref: messageDOM,
className: "".concat(styles['toast-message'], " ").concat(isEnter ? 'toast-enter-active' : '', " ").concat(isExit ? 'toast-exit-active' : '', " ").concat(className)
}, render ? render(message) : React.createElement("div", __assign({
}, render ? render(message) : /*#__PURE__*/React.createElement("div", __assign({
className: contentClassNames

@@ -347,3 +353,3 @@ }, clickable && clickableProps), message));

position: position,
component: React.createElement(Toast, {
component: /*#__PURE__*/React.createElement(Toast, {
message: message,

@@ -375,3 +381,2 @@ className: className,

closeTimer = window.setTimeout(function () {
console.log('close');
closeToast(id, closeOptions);

@@ -397,3 +402,3 @@ }, duration);

toastComponentList[index].message = newMessage;
toastComponentList[index].component = React.createElement(Toast, {
toastComponentList[index].component = /*#__PURE__*/React.createElement(Toast, {
message: newMessage,

@@ -416,4 +421,5 @@ className: className,

exports.ToastPosition = ToastPosition;
exports.clearToasts = clearToasts;
exports.default = toast;
exports.toastConfig = toastConfig;
//# sourceMappingURL=index.js.map
{
"name": "react-simple-toasts",
"version": "3.5.1",
"version": "3.5.2",
"description": "React Simple Toasts is a simple and easy-to-use toast message popup for React.",

@@ -12,7 +12,7 @@ "author": "almond-bongbong",

"scripts": {
"test": "cross-env CI=1 react-scripts-ts test --env=jsdom",
"test:watch": "react-scripts-ts test --env=jsdom",
"test": "jest",
"test:watch": "jest --watch",
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "npm run build",
"prepare": "npm run test",
"predeploy": "cd example && npm install && npm run build",

@@ -26,11 +26,22 @@ "deploy": "gh-pages -d example/build"

"devDependencies": {
"@babel/core": "^7.21.5",
"@babel/preset-env": "^7.21.5",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.21.5",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.2",
"@types/jest": "^23.1.5",
"@types/react": "^18.0.20",
"@types/react-dom": "^18.0.6",
"@types/react-transition-group": "^4.2.2",
"babel-jest": "^29.5.0",
"cross-env": "^5.1.4",
"gh-pages": "^4.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"postcss": "^8.4.23",
"prettier": "^2.8.8",
"react": "^16.8.0",

@@ -37,0 +48,0 @@ "react-dom": "^16.8.0",

@@ -147,3 +147,20 @@ # React Simple Toasts 🍞

### clearToasts()
Removes all currently displayed toast messages.
This function provides a convenient way to remove all active toast messages at once. It can be useful in situations where you need to clear all toasts, such as when a user logs out or navigates away from a page.
```jsx
import { clearToasts } from 'react-simple-toasts';
function ClearAllToastsButton() {
return (
<button onClick={() => clearToasts()}>
Clear All Toast Messages
</button>
);
}
```
## Contributing

@@ -150,0 +167,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc