react-redux-toastr
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -0,1 +1,3 @@ | ||
#2.1.1 | ||
Fix [issue](https://github.com/diegoddox/react-redux-toastr/issues/11#issuecomment-192171920) | ||
#2.1.0 | ||
@@ -2,0 +4,0 @@ change ReduxToastr props name from `confirm` to `confirmOptions` |
@@ -8,4 +8,2 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
@@ -23,2 +21,4 @@ | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -28,3 +28,3 @@ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } | ||
@@ -37,3 +37,3 @@ var Button = function (_Component) { | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Button).call(this, props)); | ||
var _this = _possibleConstructorReturn(this, _Component.call(this, props)); | ||
@@ -59,25 +59,22 @@ _this.handleClick = function (e) { | ||
_createClass(Button, [{ | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
Button.prototype.render = function render() { | ||
var _this2 = this; | ||
return _react2.default.createElement( | ||
'button', | ||
{ | ||
ref: function ref(_ref) { | ||
return _this2.toastrButton = _ref; | ||
}, | ||
type: 'button', | ||
onClick: function onClick(e) { | ||
return _this2.handleClick(e); | ||
} }, | ||
_react2.default.createElement( | ||
'p', | ||
null, | ||
this.props.children | ||
) | ||
); | ||
} | ||
}]); | ||
return _react2.default.createElement( | ||
'button', | ||
{ | ||
ref: function ref(_ref) { | ||
return _this2.toastrButton = _ref; | ||
}, | ||
type: 'button', | ||
onClick: function onClick(e) { | ||
return _this2.handleClick(e); | ||
} }, | ||
_react2.default.createElement( | ||
'p', | ||
null, | ||
this.props.children | ||
) | ||
); | ||
}; | ||
@@ -84,0 +81,0 @@ return Button; |
'use strict'; | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,4 +12,2 @@ value: true | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _dec, _class; | ||
@@ -51,3 +51,3 @@ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } | ||
@@ -64,3 +64,3 @@ var ReduxToastr = (_dec = (0, _reactRedux.connect)(function (state) { | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ReduxToastr).call(this, props)); | ||
var _this = _possibleConstructorReturn(this, _Component.call(this, props)); | ||
@@ -72,43 +72,38 @@ _config2.default.set('timeOut', _this.props.timeOut); | ||
_createClass(ReduxToastr, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var _props = this.props; | ||
var addToastrAction = _props.addToastrAction; | ||
var showConfirm = _props.showConfirm; | ||
var clean = _props.clean; | ||
ReduxToastr.prototype.componentDidMount = function componentDidMount() { | ||
var _props = this.props; | ||
var addToastrAction = _props.addToastrAction; | ||
var showConfirm = _props.showConfirm; | ||
var clean = _props.clean; | ||
_toastrEmitter.EE.on('toastr/confirm', showConfirm); | ||
_toastrEmitter.EE.on('add/toastr', addToastrAction); | ||
_toastrEmitter.EE.on('clean/toastr', clean); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
_toastrEmitter.EE.removeListener('toastr/confirm'); | ||
_toastrEmitter.EE.removeListener('add/toastr'); | ||
_toastrEmitter.EE.removeListener('clean/toastr'); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
_toastrEmitter.EE.on('toastr/confirm', showConfirm); | ||
_toastrEmitter.EE.on('add/toastr', addToastrAction); | ||
_toastrEmitter.EE.on('clean/toastr', clean); | ||
}; | ||
var classes = (0, _classnames2.default)('redux-toastr', this.props.position); | ||
var _props$toastr = this.props.toastr; | ||
var confirm = _props$toastr.confirm; | ||
var toastrs = _props$toastr.toastrs; | ||
ReduxToastr.prototype.componentWillUnmount = function componentWillUnmount() { | ||
_toastrEmitter.EE.removeListener('toastr/confirm'); | ||
_toastrEmitter.EE.removeListener('add/toastr'); | ||
_toastrEmitter.EE.removeListener('clean/toastr'); | ||
}; | ||
ReduxToastr.prototype.render = function render() { | ||
var _this2 = this; | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: classes }, | ||
_react2.default.createElement(_ToastrConfirm2.default, _extends({ confirm: confirm }, this.props)), | ||
toastrs.map(function (item) { | ||
return _react2.default.createElement(_ToastrBox2.default, _extends({ key: item.id, item: item }, _this2.props)); | ||
}) | ||
); | ||
} | ||
}]); | ||
var classes = (0, _classnames2.default)('redux-toastr', this.props.position); | ||
var _props$toastr = this.props.toastr; | ||
var confirm = _props$toastr.confirm; | ||
var toastrs = _props$toastr.toastrs; | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: classes }, | ||
_react2.default.createElement(_ToastrConfirm2.default, _extends({ confirm: confirm }, this.props)), | ||
toastrs.map(function (item) { | ||
return _react2.default.createElement(_ToastrBox2.default, _extends({ key: item.id, item: item }, _this2.props)); | ||
}) | ||
); | ||
}; | ||
return ReduxToastr; | ||
@@ -115,0 +110,0 @@ }(_react.Component)) || _class); |
@@ -8,4 +8,2 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _CSSCore = require('fbjs/lib/CSSCore'); | ||
@@ -31,2 +29,4 @@ | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -36,3 +36,3 @@ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // eslint-disable-line no-unused-vars | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } // eslint-disable-line no-unused-vars | ||
@@ -46,3 +46,3 @@ | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ToastrBox).call(this, props)); | ||
var _this = _possibleConstructorReturn(this, _Component.call(this, props)); | ||
@@ -135,70 +135,65 @@ _this.handleClick = function () { | ||
_createClass(ToastrBox, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
var item = this.props.item; | ||
var timeOut = item.options.timeOut; | ||
ToastrBox.prototype.componentDidMount = function componentDidMount() { | ||
var item = this.props.item; | ||
var timeOut = item.options.timeOut; | ||
if (typeof timeOut === 'undefined' && item.type !== 'message') { | ||
timeOut = _config2.default.get('timeOut'); | ||
} | ||
if (typeof timeOut === 'undefined' && item.type !== 'message') { | ||
timeOut = _config2.default.get('timeOut'); | ||
} | ||
if (timeOut) { | ||
this._setIntervalId(setTimeout(this._removeToastr, timeOut)); | ||
} | ||
if (timeOut) { | ||
this._setIntervalId(setTimeout(this._removeToastr, timeOut)); | ||
} | ||
this._setTransition(); | ||
(0, _utils.onCSSTransitionEnd)(this.toastrBox, this._onAnimationComplite); | ||
this._setTransition(); | ||
(0, _utils.onCSSTransitionEnd)(this.toastrBox, this._onAnimationComplite); | ||
}; | ||
ToastrBox.prototype.componentWillUnmount = function componentWillUnmount() { | ||
if (this.intervalId) { | ||
clearTimeout(this.intervalId); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
if (this.intervalId) { | ||
clearTimeout(this.intervalId); | ||
} | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
}; | ||
var _props$item = this.props.item; | ||
var title = _props$item.title; | ||
var type = _props$item.type; | ||
var options = _props$item.options; | ||
ToastrBox.prototype.render = function render() { | ||
var _this2 = this; | ||
var classes = (0, _classnames2.default)('toastr', 'animated', type, options.icon); | ||
return _react2.default.createElement( | ||
var _props$item = this.props.item; | ||
var title = _props$item.title; | ||
var type = _props$item.type; | ||
var options = _props$item.options; | ||
var classes = (0, _classnames2.default)('toastr', 'animated', type, options.icon); | ||
return _react2.default.createElement( | ||
'div', | ||
{ | ||
className: classes, | ||
onMouseEnter: function onMouseEnter() { | ||
return _this2.mouseEnter(); | ||
}, | ||
onMouseLeave: function onMouseLeave() { | ||
return _this2.mouseLeave(); | ||
}, | ||
onClick: function onClick() { | ||
return _this2.handleClick(); | ||
}, | ||
ref: function ref(_ref) { | ||
return _this2.toastrBox = _ref; | ||
} }, | ||
_react2.default.createElement( | ||
'div', | ||
{ | ||
className: classes, | ||
onMouseEnter: function onMouseEnter() { | ||
return _this2.mouseEnter(); | ||
}, | ||
onMouseLeave: function onMouseLeave() { | ||
return _this2.mouseLeave(); | ||
}, | ||
onClick: function onClick() { | ||
return _this2.handleClick(); | ||
}, | ||
ref: function ref(_ref) { | ||
return _this2.toastrBox = _ref; | ||
} }, | ||
{ className: 'message-holder' }, | ||
title && _react2.default.createElement( | ||
'div', | ||
{ className: 'title' }, | ||
title | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'message-holder' }, | ||
title && _react2.default.createElement( | ||
'div', | ||
{ className: 'title' }, | ||
title | ||
), | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'message' }, | ||
this.renderMessage() | ||
) | ||
{ className: 'message' }, | ||
this.renderMessage() | ||
) | ||
); | ||
} | ||
}]); | ||
) | ||
); | ||
}; | ||
@@ -205,0 +200,0 @@ return ToastrBox; |
@@ -8,4 +8,2 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _react = require('react'); | ||
@@ -31,2 +29,4 @@ | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -36,3 +36,3 @@ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } | ||
@@ -45,22 +45,4 @@ var ToastrConfirm = function (_Component) { | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ToastrConfirm).call(this, props)); | ||
var _this = _possibleConstructorReturn(this, _Component.call(this, props)); | ||
_this.handleConfirmClick = function () { | ||
var options = _this.props.confirm.options; | ||
if (options.onOk) { | ||
options.onOk(); | ||
} | ||
_this._setTransition(); | ||
}; | ||
_this.handleCancelClick = function () { | ||
var options = _this.props.confirm.options; | ||
if (options.onCancel) { | ||
options.onCancel(); | ||
} | ||
_this._setTransition(); | ||
}; | ||
_this._setTransition = function (add) { | ||
@@ -70,21 +52,15 @@ var body = document.querySelector('body'); | ||
if (add) { | ||
_this.isHiding = false; | ||
_CSSCore2.default.addClass(body, 'toastr-confirm-active'); | ||
_CSSCore2.default.addClass(_this.confirm, 'bounceInDown'); | ||
_this.isHiding = false; | ||
} else { | ||
_CSSCore2.default.addClass(_this.confirm, 'bounceOutUp'); | ||
_this.isHiding = true; | ||
return; | ||
} | ||
(0, _utils.onCSSTransitionEnd)(_this.confirm, _this._onConfirmAnimationComplete); | ||
_this.isHiding = true; | ||
_CSSCore2.default.addClass(_this.confirm, 'bounceOutUp'); | ||
}; | ||
_this._onConfirmAnimationComplete = function () { | ||
if (_this.isHiding) { | ||
_this._removeConfirm(); | ||
} | ||
}; | ||
_this._removeConfirm = function () { | ||
_this.isHiding = false; | ||
_this.props.hideConfirm(); | ||
var body = document.querySelector('body'); | ||
@@ -94,3 +70,2 @@ _CSSCore2.default.removeClass(_this.confirm, 'bounceOutUp'); | ||
_CSSCore2.default.removeClass(body, 'toastr-confirm-active'); | ||
_this.props.hideConfirm(); | ||
}; | ||
@@ -101,59 +76,73 @@ | ||
_createClass(ToastrConfirm, [{ | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this.isHiding = false; | ||
ToastrConfirm.prototype.componentDidUpdate = function componentDidUpdate() { | ||
this.isHiding = false; | ||
if (this.props.confirm.show) { | ||
this._setTransition(true); | ||
} | ||
if (this.props.confirm.show) { | ||
this._setTransition(true); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
}; | ||
var _props$confirmOptions = this.props.confirmOptions; | ||
var okText = _props$confirmOptions.okText; | ||
var cancelText = _props$confirmOptions.cancelText; | ||
ToastrConfirm.prototype.handleConfirmClick = function handleConfirmClick() { | ||
var _this2 = this; | ||
var classes = (0, _classnames2.default)('confirm-holder', { active: this.props.confirm.show }); | ||
return _react2.default.createElement( | ||
var options = this.props.confirm.options; | ||
var onAnimationEnd = function onAnimationEnd() { | ||
_this2._removeConfirm(); | ||
if (options.onOk) { | ||
options.onOk(); | ||
} | ||
}; | ||
this._setTransition(); | ||
(0, _utils.onCSSTransitionEnd)(this.confirm, onAnimationEnd); | ||
}; | ||
ToastrConfirm.prototype.handleCancelClick = function handleCancelClick() { | ||
var _this3 = this; | ||
var options = this.props.confirm.options; | ||
var onAnimationEnd = function onAnimationEnd() { | ||
_this3._removeConfirm(); | ||
if (options.onCancel) { | ||
options.onCancel(); | ||
} | ||
}; | ||
this._setTransition(); | ||
(0, _utils.onCSSTransitionEnd)(this.confirm, onAnimationEnd); | ||
}; | ||
ToastrConfirm.prototype.render = function render() { | ||
var _this4 = this; | ||
var classes = (0, _classnames2.default)('confirm-holder', { active: this.props.confirm.show }); | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: classes }, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: classes }, | ||
{ className: 'confirm animated', ref: function ref(_ref) { | ||
return _this4.confirm = _ref; | ||
} }, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'confirm animated', ref: function ref(_ref) { | ||
return _this2.confirm = _ref; | ||
} }, | ||
_react2.default.createElement( | ||
'div', | ||
{ className: 'message' }, | ||
this.props.confirm.message | ||
), | ||
_react2.default.createElement( | ||
_Button2.default, | ||
{ | ||
className: 'ok', | ||
onClick: function onClick(e) { | ||
return _this2.handleConfirmClick(e); | ||
} }, | ||
okText | ||
), | ||
_react2.default.createElement( | ||
_Button2.default, | ||
{ | ||
className: 'cancel', | ||
onClick: function onClick(e) { | ||
return _this2.handleCancelClick(e); | ||
} }, | ||
cancelText | ||
) | ||
{ className: 'message' }, | ||
this.props.confirm.message | ||
), | ||
_react2.default.createElement('div', { className: 'shadow animated', ref: function ref(_ref2) { | ||
return _this2.confirmShadow = _ref2; | ||
} }) | ||
); | ||
} | ||
}]); | ||
_react2.default.createElement( | ||
_Button2.default, | ||
{ onClick: this.handleConfirmClick.bind(this) }, | ||
this.props.confirmOptions.okText | ||
), | ||
_react2.default.createElement( | ||
_Button2.default, | ||
{ onClick: this.handleCancelClick.bind(this) }, | ||
this.props.confirmOptions.cancelText | ||
) | ||
), | ||
_react2.default.createElement('div', { className: 'shadow' }) | ||
); | ||
}; | ||
@@ -166,5 +155,4 @@ return ToastrConfirm; | ||
confirm: _react.PropTypes.object.isRequired, | ||
okText: _react.PropTypes.string, | ||
cancelText: _react.PropTypes.string | ||
confirmOptions: _react.PropTypes.object | ||
}; | ||
exports.default = ToastrConfirm; |
{ | ||
"name": "react-redux-toastr", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "react-redux-toastr is a React toastr message implemented with Redux", | ||
@@ -85,2 +85,4 @@ "main": "lib/index.js", | ||
"babel-plugin-transform-es2015-block-scoping": "^6.3.13", | ||
"babel-plugin-transform-es2015-classes": "^6.5.2", | ||
"babel-plugin-transform-proto-to-assign": "^6.5.0", | ||
"babel-preset-es2015": "^6.1.18", | ||
@@ -87,0 +89,0 @@ "babel-preset-react": "^6.1.18", |
@@ -12,4 +12,3 @@ import React, {Component, PropTypes} from 'react'; | ||
confirm: PropTypes.object.isRequired, | ||
okText: PropTypes.string, | ||
cancelText: PropTypes.string | ||
confirmOptions: PropTypes.object | ||
}; | ||
@@ -29,17 +28,27 @@ | ||
handleConfirmClick = () => { | ||
handleConfirmClick() { | ||
const {options} = this.props.confirm; | ||
if (options.onOk) { | ||
options.onOk(); | ||
} | ||
const onAnimationEnd = () => { | ||
this._removeConfirm(); | ||
if (options.onOk) { | ||
options.onOk(); | ||
} | ||
}; | ||
this._setTransition(); | ||
}; | ||
onCSSTransitionEnd(this.confirm, onAnimationEnd); | ||
} | ||
handleCancelClick = () => { | ||
handleCancelClick() { | ||
const {options} = this.props.confirm; | ||
if (options.onCancel) { | ||
options.onCancel(); | ||
} | ||
const onAnimationEnd = () => { | ||
this._removeConfirm(); | ||
if (options.onCancel) { | ||
options.onCancel(); | ||
} | ||
}; | ||
this._setTransition(); | ||
}; | ||
onCSSTransitionEnd(this.confirm, onAnimationEnd); | ||
} | ||
@@ -50,21 +59,15 @@ _setTransition = (add) => { | ||
if (add) { | ||
this.isHiding = false; | ||
CSSCore.addClass(body, 'toastr-confirm-active'); | ||
CSSCore.addClass(this.confirm, 'bounceInDown'); | ||
this.isHiding = false; | ||
} else { | ||
CSSCore.addClass(this.confirm, 'bounceOutUp'); | ||
this.isHiding = true; | ||
return; | ||
} | ||
onCSSTransitionEnd(this.confirm, this._onConfirmAnimationComplete); | ||
this.isHiding = true; | ||
CSSCore.addClass(this.confirm, 'bounceOutUp'); | ||
}; | ||
_onConfirmAnimationComplete = () => { | ||
if (this.isHiding) { | ||
this._removeConfirm(); | ||
} | ||
}; | ||
_removeConfirm = () => { | ||
this.isHiding = false; | ||
this.props.hideConfirm(); | ||
const body = document.querySelector('body'); | ||
@@ -74,20 +77,18 @@ CSSCore.removeClass(this.confirm, 'bounceOutUp'); | ||
CSSCore.removeClass(body, 'toastr-confirm-active'); | ||
this.props.hideConfirm(); | ||
}; | ||
render() { | ||
const {okText, cancelText} = this.props.confirmOptions; | ||
const classes = cn('confirm-holder', {active: this.props.confirm.show}); | ||
return ( | ||
<div className={classes}> | ||
<div className="confirm animated" ref={(ref) => this.confirm = ref}> | ||
<div className="confirm animated" ref={ref => this.confirm = ref}> | ||
<div className="message">{this.props.confirm.message}</div> | ||
<Button | ||
className="ok" | ||
onClick={e => this.handleConfirmClick(e)}>{okText}</Button> | ||
<Button | ||
className="cancel" | ||
onClick={e => this.handleCancelClick(e)}>{cancelText}</Button> | ||
<Button onClick={this.handleConfirmClick.bind(this)}> | ||
{this.props.confirmOptions.okText} | ||
</Button> | ||
<Button onClick={this.handleCancelClick.bind(this)}> | ||
{this.props.confirmOptions.cancelText} | ||
</Button> | ||
</div> | ||
<div className="shadow animated" ref={(ref) => this.confirmShadow = ref}></div> | ||
<div className="shadow"></div> | ||
</div> | ||
@@ -94,0 +95,0 @@ ); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94885
39
24
1756