react-redux-toastr
Advanced tools
Comparing version 7.1.6 to 7.2.0
@@ -74,3 +74,4 @@ 'use strict'; | ||
clean = _props.clean, | ||
removeByType = _props.removeByType; | ||
removeByType = _props.removeByType, | ||
remove = _props.remove; | ||
@@ -81,2 +82,3 @@ _toastrEmitter.EE.on('toastr/confirm', showConfirm); | ||
_toastrEmitter.EE.on('removeByType/toastr', removeByType); | ||
_toastrEmitter.EE.on('remove/toastr', remove); | ||
}; | ||
@@ -89,2 +91,3 @@ | ||
_toastrEmitter.EE.removeListener('removeByType/toastr'); | ||
_toastrEmitter.EE.removeListener('remove/toastr'); | ||
this.toastrFired = {}; | ||
@@ -125,5 +128,11 @@ }; | ||
}, _this2.props)), | ||
item.options && item.options.attention && _react2.default.createElement('div', { onClick: function onClick() { | ||
return _this2.props.remove(item.id); | ||
}, className: 'toastr-attention' }) | ||
item.options && item.options.attention && _react2.default.createElement('div', { | ||
onClick: function onClick() { | ||
if (typeof item.options.onAttentionClick === 'function') { | ||
item.options.onAttentionClick(item.id); | ||
} else { | ||
_this2.props.remove(item.id); | ||
} | ||
}, | ||
className: 'toastr-attention' }) | ||
); | ||
@@ -130,0 +139,0 @@ }); |
@@ -45,2 +45,6 @@ 'use strict'; | ||
actions.remove = function (id) { | ||
return emitter.emit('remove/toastr', id); | ||
}; | ||
actions.confirm = function () { | ||
@@ -47,0 +51,0 @@ emitter.emit('toastr/confirm', { |
{ | ||
"name": "react-redux-toastr", | ||
"version": "7.1.6", | ||
"version": "7.2.0", | ||
"description": "react-redux-toastr is a React toastr message implemented with Redux", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -126,2 +126,3 @@ ## `react-redux-toastr` [demo](http://diegoddox.github.io/react-redux-toastr/) | ||
attention: true, // This will add a shadow like the confirm method. | ||
onAttentionClick: (id) => {}, //override default behavior of 'attention' background click. | ||
message: 'message', | ||
@@ -136,7 +137,7 @@ options: {} | ||
# Toastr methods | ||
Toastr accepts the following methods: `success` `info` `warning` `light` `error` `confirm` `message` and `removeByType` | ||
Toastr accepts the following methods: `success` `info` `warning` `light` `error` `confirm` `message`, `remove` and `removeByType` | ||
##### Toastr: `success` `info` `warning` `light` `error` and `removeByType` | ||
##### Toastr: `success` `info` `warning` `light` `error` `remove` and `removeByType` | ||
Each of these methods can take up to three arguments the `title` a `message` and `options`. | ||
In `options` you can specify `timeOut` `icon` `onShowComplete` `onHideComplete` `className` `component` `removeOnHover`, `showCloseButton`, `onCloseButtonClick`, `progressBar`, `transitionIn`, `position`, `attention` and `transitionOut`. | ||
In `options` you can specify `timeOut` `icon` `onShowComplete` `onHideComplete` `className` `component` `removeOnHover`, `showCloseButton`, `onCloseButtonClick`, `progressBar`, `transitionIn`, `position`, `attention`, `onAttentionClick` and `transitionOut`. | ||
@@ -165,2 +166,3 @@ ``` javascript | ||
toastr.removeByType('error') // Remove all toastrs with the type error. | ||
toastr.remove('123') // Removes toastr with id '123' | ||
``` | ||
@@ -167,0 +169,0 @@ |
@@ -58,3 +58,3 @@ import React from 'react'; | ||
componentDidMount() { | ||
const {add, showConfirm, clean, removeByType} = this.props; | ||
const {add, showConfirm, clean, removeByType, remove} = this.props; | ||
EE.on('toastr/confirm', showConfirm); | ||
@@ -64,2 +64,3 @@ EE.on('add/toastr', add); | ||
EE.on('removeByType/toastr', removeByType); | ||
EE.on('remove/toastr', remove); | ||
} | ||
@@ -72,2 +73,3 @@ | ||
EE.removeListener('removeByType/toastr'); | ||
EE.removeListener('remove/toastr'); | ||
this.toastrFired = {}; | ||
@@ -106,3 +108,11 @@ } | ||
{item.options && item.options.attention && | ||
<div onClick={() => this.props.remove(item.id)} className="toastr-attention" /> | ||
<div | ||
onClick={() => { | ||
if (typeof item.options.onAttentionClick === 'function') { | ||
item.options.onAttentionClick(item.id); | ||
} else { | ||
this.props.remove(item.id); | ||
} | ||
}} | ||
className="toastr-attention"/> | ||
} | ||
@@ -109,0 +119,0 @@ </span> |
@@ -20,2 +20,4 @@ import {mapToToastrMessage} from './utils.js'; | ||
actions.remove = (id) => emitter.emit('remove/toastr', id); | ||
actions.confirm = (...args) => { | ||
@@ -22,0 +24,0 @@ emitter.emit('toastr/confirm', { |
130110
2188
318