Skip to content

Commit

Permalink
fix(src): Revert breaking changes commits for v2.2.1. Closes #42
Browse files Browse the repository at this point in the history
This reverts the following commits:

- 97e046b
- 96aa073
- dce1279
- 69dbd7e
- 69c23db
- e0ff62b
- e7d032a
- db9fee6
  • Loading branch information
tomchentw committed Nov 2, 2015
1 parent fe882dc commit 988112e
Show file tree
Hide file tree
Showing 19 changed files with 143 additions and 691 deletions.
42 changes: 14 additions & 28 deletions lib/ToastContainer.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var _react = require("react");

var _react2 = _interopRequireDefault(_react);

var _reactAddonsUpdate = require("react-addons-update");
var React = require("react");
var update = require('react-addons-update');

var _reactAddonsUpdate2 = _interopRequireDefault(_reactAddonsUpdate);

var _ToastMessage = require("./ToastMessage");

var _ToastMessage2 = _interopRequireDefault(_ToastMessage);
var ToastMessage = React.createFactory(require("./ToastMessage"));

function noop() {}

exports["default"] = _react2["default"].createClass({
module.exports = React.createClass({
displayName: "ToastContainer",

error: function error(message, title, optionsOverride) {
Expand Down Expand Up @@ -58,7 +45,7 @@ exports["default"] = _react2["default"].createClass({
warning: "warning"
},
id: "toast-container",
toastMessageFactory: _react2["default"].createFactory(_ToastMessage2["default"]),
toastMessageFactory: ToastMessage,
preventDuplicates: false,
newestOnTop: true,
onClick: noop
Expand Down Expand Up @@ -88,22 +75,22 @@ exports["default"] = _react2["default"].createClass({
}
var key = state.toastId++;
var toastId = key;
var newToast = (0, _reactAddonsUpdate2["default"])(optionsOverride || {}, {
var newToast = update(optionsOverride || {}, {
$merge: {
toastId: toastId,
toastType: type,
type: type,
title: title,
message: message,
toastId: toastId,
key: key,
ref: "toasts__" + key,
onClick: this._handle_toast_on_click,
onRemove: this._handle_toast_remove
handleOnClick: this._handle_toast_on_click,
handleRemove: this._handle_toast_remove
}
});
var toastOperation = {};
toastOperation["" + (props.newestOnTop ? "$unshift" : "$push")] = [newToast];

var newState = (0, _reactAddonsUpdate2["default"])(state, {
var newState = update(state, {
toasts: toastOperation,
previousMessage: { $set: message }
});
Expand All @@ -128,21 +115,20 @@ exports["default"] = _react2["default"].createClass({
if (found || toast.toastId !== toastId) {
return false;
}
_this.setState((0, _reactAddonsUpdate2["default"])(state, {
_this.setState(update(state, {
toasts: { $splice: [[index, 1]] }
}));
return true;
}, false);
},

_render: function _render(props, state) {
return _react2["default"].createElement(
return React.createElement(
"div",
_extends({}, props, { "aria-live": "polite", role: "alert" }),
state.toasts.map(function (toast) {
return props.toastMessageFactory(toast);
})
);
}
});
module.exports = exports["default"];
});
73 changes: 25 additions & 48 deletions lib/ToastMessage/animationMixin.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var _fbjsLibCSSCore = require("fbjs/lib/CSSCore");

var _fbjsLibCSSCore2 = _interopRequireDefault(_fbjsLibCSSCore);

var _reactLibReactTransitionEvents = require("react/lib/ReactTransitionEvents");

var _reactLibReactTransitionEvents2 = _interopRequireDefault(_reactLibReactTransitionEvents);

var _reactDom = require("react-dom");

var _reactDom2 = _interopRequireDefault(_reactDom);

var _reactAddonsUpdate = require("react-addons-update");

var _reactAddonsUpdate2 = _interopRequireDefault(_reactAddonsUpdate);

var _classnames = require("classnames");

var _classnames2 = _interopRequireDefault(_classnames);

var CSSCore = require("fbjs/lib/CSSCore");
var ReactTransitionEvents = require("react/lib/ReactTransitionEvents");
var ReactDOM = require('react-dom');
var TICK = 17;
var toString = Object.prototype.toString;
exports["default"] = {

module.exports = {
getDefaultProps: function getDefaultProps() {
return {
transition: null, //some examples defined in index.scss (scale, fadeInOut, rotate)
Expand All @@ -55,13 +33,13 @@ exports["default"] = {
var onHideComplete = function onHideComplete() {
if (_this.isHiding) {
_this._set_is_hiding(false);
_reactLibReactTransitionEvents2["default"].removeEndEventListener(node, onHideComplete);
ReactTransitionEvents.removeEndEventListener(node, onHideComplete);
_this._handle_remove();
}
};

var node = _reactDom2["default"].findDOMNode(this);
_reactLibReactTransitionEvents2["default"].addEndEventListener(node, onHideComplete);
var node = ReactDOM.findDOMNode(this);
ReactTransitionEvents.addEndEventListener(node, onHideComplete);

if (0 < props.timeOut) {
this._set_interval_id(setTimeout(this.hideToast, props.timeOut));
Expand All @@ -74,7 +52,7 @@ exports["default"] = {
},
_set_transition: function _set_transition(hide) {
var animationType = hide ? "leave" : "enter";
var node = _reactDom2["default"].findDOMNode(this);
var node = ReactDOM.findDOMNode(this);
var className = this.props.transition + "-" + animationType;
var activeClassName = className + "-active";

Expand All @@ -83,49 +61,49 @@ exports["default"] = {
return;
}

_fbjsLibCSSCore2["default"].removeClass(node, className);
_fbjsLibCSSCore2["default"].removeClass(node, activeClassName);
CSSCore.removeClass(node, className);
CSSCore.removeClass(node, activeClassName);

_reactLibReactTransitionEvents2["default"].removeEndEventListener(node, endListener);
ReactTransitionEvents.removeEndEventListener(node, endListener);
};

_reactLibReactTransitionEvents2["default"].addEndEventListener(node, endListener);
ReactTransitionEvents.addEndEventListener(node, endListener);

_fbjsLibCSSCore2["default"].addClass(node, className);
CSSCore.addClass(node, className);

// Need to do this to actually trigger a transition.
this._queue_class(activeClassName);
},

_clear_transition: function _clear_transition(hide) {
var node = _reactDom2["default"].findDOMNode(this);
var node = ReactDOM.findDOMNode(this);
var animationType = hide ? "leave" : "enter";
var className = this.props.transition + "-" + animationType;
var activeClassName = className + "-active";

_fbjsLibCSSCore2["default"].removeClass(node, className);
_fbjsLibCSSCore2["default"].removeClass(node, activeClassName);
CSSCore.removeClass(node, className);
CSSCore.removeClass(node, activeClassName);
},

_set_animation: function _set_animation(hide) {
var node = _reactDom2["default"].findDOMNode(this);
var node = ReactDOM.findDOMNode(this);
var animations = this._get_animation_classes(hide);
var endListener = function endListener(e) {
if (e && e.target !== node) {
return;
}

animations.forEach(function (anim) {
_fbjsLibCSSCore2["default"].removeClass(node, anim);
CSSCore.removeClass(node, anim);
});

_reactLibReactTransitionEvents2["default"].removeEndEventListener(node, endListener);
ReactTransitionEvents.removeEndEventListener(node, endListener);
};

_reactLibReactTransitionEvents2["default"].addEndEventListener(node, endListener);
ReactTransitionEvents.addEndEventListener(node, endListener);

animations.forEach(function (anim) {
_fbjsLibCSSCore2["default"].addClass(node, anim);
CSSCore.addClass(node, anim);
});
},

Expand All @@ -145,7 +123,7 @@ exports["default"] = {

var animations = this._get_animation_classes(hide);
animations.forEach(function (animation) {
_fbjsLibCSSCore2["default"].removeClass(_reactDom2["default"].findDOMNode(_this2), animation);
CSSCore.removeClass(_this2.getDOMNode(), animation);
});
},

Expand All @@ -159,7 +137,7 @@ exports["default"] = {

_flush_class_name_queue: function _flush_class_name_queue() {
if (this.isMounted()) {
this.classNameQueue.forEach(_fbjsLibCSSCore2["default"].addClass.bind(_fbjsLibCSSCore2["default"], _reactDom2["default"].findDOMNode(this)));
this.classNameQueue.forEach(CSSCore.addClass.bind(CSSCore, this.getDOMNode()));
}
this.classNameQueue.length = 0;
this.timeout = null;
Expand Down Expand Up @@ -223,5 +201,4 @@ exports["default"] = {
_set_is_hiding: function _set_is_hiding(isHiding) {
this.isHiding = isHiding;
}
};
module.exports = exports["default"];
};
Loading

0 comments on commit 988112e

Please sign in to comment.