react-transition-group
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -8,3 +8,3 @@ "use strict"; | ||
var _addClass = _interopRequireDefault(require("dom-helpers/class/addClass")); | ||
var _addClass2 = _interopRequireDefault(require("dom-helpers/class/addClass")); | ||
@@ -25,7 +25,9 @@ var _removeClass = _interopRequireDefault(require("dom-helpers/class/removeClass")); | ||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } | ||
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } | ||
var addClass = function addClass(node, classes) { | ||
var _addClass = function addClass(node, classes) { | ||
return node && classes && classes.split(' ').forEach(function (c) { | ||
return (0, _addClass.default)(node, c); | ||
return (0, _addClass2.default)(node, c); | ||
}); | ||
@@ -114,10 +116,12 @@ }; | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_this.appliedClasses = { | ||
appear: {}, | ||
enter: {}, | ||
exit: {} | ||
}; | ||
_this.onEnter = function (node, appearing) { | ||
var _this$getClassNames = _this.getClassNames(appearing ? 'appear' : 'enter'), | ||
className = _this$getClassNames.className; | ||
_this.removeClasses(node, 'exit'); | ||
addClass(node, className); | ||
_this.addClass(node, appearing ? 'appear' : 'enter', 'base'); | ||
@@ -130,6 +134,5 @@ if (_this.props.onEnter) { | ||
_this.onEntering = function (node, appearing) { | ||
var _this$getClassNames2 = _this.getClassNames(appearing ? 'appear' : 'enter'), | ||
activeClassName = _this$getClassNames2.activeClassName; | ||
var type = appearing ? 'appear' : 'enter'; | ||
_this.reflowAndAddClass(node, activeClassName); | ||
_this.addClass(node, type, 'active'); | ||
@@ -142,12 +145,8 @@ if (_this.props.onEntering) { | ||
_this.onEntered = function (node, appearing) { | ||
var appearClassName = _this.getClassNames('appear').doneClassName; | ||
var type = appearing ? 'appear' : 'enter'; | ||
var enterClassName = _this.getClassNames('enter').doneClassName; | ||
_this.removeClasses(node, type); | ||
var doneClassName = appearing ? appearClassName + " " + enterClassName : enterClassName; | ||
_this.addClass(node, type, 'done'); | ||
_this.removeClasses(node, appearing ? 'appear' : 'enter'); | ||
addClass(node, doneClassName); | ||
if (_this.props.onEntered) { | ||
@@ -159,5 +158,2 @@ _this.props.onEntered(node, appearing); | ||
_this.onExit = function (node) { | ||
var _this$getClassNames3 = _this.getClassNames('exit'), | ||
className = _this$getClassNames3.className; | ||
_this.removeClasses(node, 'appear'); | ||
@@ -167,3 +163,3 @@ | ||
addClass(node, className); | ||
_this.addClass(node, 'exit', 'base'); | ||
@@ -176,7 +172,4 @@ if (_this.props.onExit) { | ||
_this.onExiting = function (node) { | ||
var _this$getClassNames4 = _this.getClassNames('exit'), | ||
activeClassName = _this$getClassNames4.activeClassName; | ||
_this.addClass(node, 'exit', 'active'); | ||
_this.reflowAndAddClass(node, activeClassName); | ||
if (_this.props.onExiting) { | ||
@@ -188,8 +181,5 @@ _this.props.onExiting(node); | ||
_this.onExited = function (node) { | ||
var _this$getClassNames5 = _this.getClassNames('exit'), | ||
doneClassName = _this$getClassNames5.doneClassName; | ||
_this.removeClasses(node, 'exit'); | ||
addClass(node, doneClassName); | ||
_this.addClass(node, 'exit', 'done'); | ||
@@ -204,8 +194,8 @@ if (_this.props.onExited) { | ||
var isStringClassNames = typeof classNames === 'string'; | ||
var prefix = isStringClassNames && classNames ? classNames + '-' : ''; | ||
var className = isStringClassNames ? prefix + type : classNames[type]; | ||
var activeClassName = isStringClassNames ? className + '-active' : classNames[type + 'Active']; | ||
var doneClassName = isStringClassNames ? className + '-done' : classNames[type + 'Done']; | ||
var prefix = isStringClassNames && classNames ? classNames + "-" : ''; | ||
var baseClassName = isStringClassNames ? "" + prefix + type : classNames[type]; | ||
var activeClassName = isStringClassNames ? baseClassName + "-active" : classNames[type + "Active"]; | ||
var doneClassName = isStringClassNames ? baseClassName + "-done" : classNames[type + "Done"]; | ||
return { | ||
className: className, | ||
baseClassName: baseClassName, | ||
activeClassName: activeClassName, | ||
@@ -221,29 +211,46 @@ doneClassName: doneClassName | ||
_proto.removeClasses = function removeClasses(node, type) { | ||
var _this$getClassNames6 = this.getClassNames(type), | ||
className = _this$getClassNames6.className, | ||
activeClassName = _this$getClassNames6.activeClassName, | ||
doneClassName = _this$getClassNames6.doneClassName; | ||
_proto.addClass = function addClass(node, type, phase) { | ||
var className = this.getClassNames(type)[phase + "ClassName"]; | ||
className && removeClass(node, className); | ||
activeClassName && removeClass(node, activeClassName); | ||
doneClassName && removeClass(node, doneClassName); | ||
}; | ||
if (type === 'appear' && phase === 'done') { | ||
className += " " + this.getClassNames('enter').doneClassName; | ||
} // This is for to force a repaint, | ||
// which is necessary in order to transition styles when adding a class name. | ||
_proto.reflowAndAddClass = function reflowAndAddClass(node, className) { | ||
// This is for to force a repaint, | ||
// which is necessary in order to transition styles when adding a class name. | ||
if (className) { | ||
if (phase === 'active') { | ||
/* eslint-disable no-unused-expressions */ | ||
node && node.scrollTop; | ||
/* eslint-enable no-unused-expressions */ | ||
} | ||
addClass(node, className); | ||
this.appliedClasses[type][phase] = className; | ||
_addClass(node, className); | ||
}; | ||
_proto.removeClasses = function removeClasses(node, type) { | ||
var _this$appliedClasses$ = this.appliedClasses[type], | ||
baseClassName = _this$appliedClasses$.base, | ||
activeClassName = _this$appliedClasses$.active, | ||
doneClassName = _this$appliedClasses$.done; | ||
this.appliedClasses[type] = {}; | ||
if (baseClassName) { | ||
removeClass(node, baseClassName); | ||
} | ||
if (activeClassName) { | ||
removeClass(node, activeClassName); | ||
} | ||
if (doneClassName) { | ||
removeClass(node, doneClassName); | ||
} | ||
}; | ||
_proto.render = function render() { | ||
var props = _extends({}, this.props); | ||
var _this$props = this.props, | ||
_ = _this$props.classNames, | ||
props = _objectWithoutPropertiesLoose(_this$props, ["classNames"]); | ||
delete props.classNames; | ||
return _react.default.createElement(_Transition.default, _extends({}, props, { | ||
@@ -250,0 +257,0 @@ onEnter: this.onEnter, |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e=e||self).ReactTransitionGroup={},e.React,e.ReactDOM)}(this,function(e,t,n){"use strict";var r="default"in t?t.default:t,i="default"in n?n.default:n;function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e,t){return e(t={exports:{}},t.exports),t.exports}var c=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}})()&&Object.assign;var d="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";function f(){}var h=l(function(e){e.exports=function(){function e(e,t,n,r,i,o){if(o!==d){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=f,n.PropTypes=n,n}()}),E=(h.object,h.oneOfType,h.element,h.bool,h.func,l(function(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}}}));s(E);var m=l(function(e,t){t.__esModule=!0,t.default=function(e,t){return e.classList?!!t&&e.classList.contains(t):-1!==(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")},e.exports=t.default});s(m);var x=s(l(function(e,t){t.__esModule=!0,t.default=function(e,t){e.classList?e.classList.add(t):(0,n.default)(e,t)||("string"==typeof e.className?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))};var n=E(m);e.exports=t.default}));function v(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function y(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}var g=r.createContext(null),b="unmounted",C="exited",N="entering",O="entered",S=function(e){function t(t,n){var r;r=e.call(this,t,n)||this;var i,o=n&&!n.isMounting?t.enter:t.appear;return r.appearStatus=null,t.in?o?(i=C,r.appearStatus=N):i=O:i=t.unmountOnExit||t.mountOnEnter?b:C,r.state={status:i},r.nextCallback=null,r}a(t,e),t.getDerivedStateFromProps=function(e,t){return e.in&&t.status===b?{status:C}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==N&&n!==O&&(t=N):n!==N&&n!==O||(t="exiting")}this.updateStatus(!1,t)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var e,t,n,r=this.props.timeout;return e=t=n=r,null!=r&&"number"!=typeof r&&(e=r.exit,t=r.enter,n=void 0!==r.appear?r.appear:t),{exit:e,enter:t,appear:n}},n.updateStatus=function(e,t){if(void 0===e&&(e=!1),null!==t){this.cancelNextCallback();var n=i.findDOMNode(this);t===N?this.performEnter(n,e):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===C&&this.setState({status:b})},n.performEnter=function(e,t){var n=this,r=this.props.enter,i=this.context?this.context.isMounting:t,o=this.getTimeouts(),a=i?o.appear:o.enter;t||r?(this.props.onEnter(e,i),this.safeSetState({status:N},function(){n.props.onEntering(e,i),n.onTransitionEnd(e,a,function(){n.safeSetState({status:O},function(){n.props.onEntered(e,i)})})})):this.safeSetState({status:O},function(){n.props.onEntered(e)})},n.performExit=function(e){var t=this,n=this.props.exit,r=this.getTimeouts();n?(this.props.onExit(e),this.safeSetState({status:"exiting"},function(){t.props.onExiting(e),t.onTransitionEnd(e,r.exit,function(){t.safeSetState({status:C},function(){t.props.onExited(e)})})})):this.safeSetState({status:C},function(){t.props.onExited(e)})},n.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},n.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},n.onTransitionEnd=function(e,t,n){this.setNextCallback(n);var r=null==t&&!this.props.addEndListener;e&&!r?(this.props.addEndListener&&this.props.addEndListener(e,this.nextCallback),null!=t&&setTimeout(this.nextCallback,t)):setTimeout(this.nextCallback,0)},n.render=function(){var e=this.state.status;if(e===b)return null;var t=this.props,n=t.children,i=y(t,["children"]);if(delete i.in,delete i.mountOnEnter,delete i.unmountOnExit,delete i.appear,delete i.enter,delete i.exit,delete i.timeout,delete i.addEndListener,delete i.onEnter,delete i.onEntering,delete i.onEntered,delete i.onExit,delete i.onExiting,delete i.onExited,"function"==typeof n)return r.createElement(g.Provider,{value:null},n(e,i));var o=r.Children.only(n);return r.createElement(g.Provider,{value:null},r.cloneElement(o,i))},t}(r.Component);function T(){}S.contextType=g,S.propTypes={},S.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:T,onEntering:T,onEntered:T,onExit:T,onExiting:T,onExited:T},S.UNMOUNTED=0,S.EXITED=1,S.ENTERING=2,S.ENTERED=3,S.EXITING=4;var k=function(e,t){return e&&t&&t.split(" ").forEach(function(t){return x(e,t)})},j=function(e,t){return e&&t&&t.split(" ").forEach(function(t){return r=t,void((n=e).classList?n.classList.remove(r):"string"==typeof n.className?n.className=v(n.className,r):n.setAttribute("class",v(n.className&&n.className.baseVal||"",r)));var n,r})},_=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).onEnter=function(e,n){var r=t.getClassNames(n?"appear":"enter").className;t.removeClasses(e,"exit"),k(e,r),t.props.onEnter&&t.props.onEnter(e,n)},t.onEntering=function(e,n){var r=t.getClassNames(n?"appear":"enter").activeClassName;t.reflowAndAddClass(e,r),t.props.onEntering&&t.props.onEntering(e,n)},t.onEntered=function(e,n){var r=t.getClassNames("appear").doneClassName,i=t.getClassNames("enter").doneClassName,o=n?r+" "+i:i;t.removeClasses(e,n?"appear":"enter"),k(e,o),t.props.onEntered&&t.props.onEntered(e,n)},t.onExit=function(e){var n=t.getClassNames("exit").className;t.removeClasses(e,"appear"),t.removeClasses(e,"enter"),k(e,n),t.props.onExit&&t.props.onExit(e)},t.onExiting=function(e){var n=t.getClassNames("exit").activeClassName;t.reflowAndAddClass(e,n),t.props.onExiting&&t.props.onExiting(e)},t.onExited=function(e){var n=t.getClassNames("exit").doneClassName;t.removeClasses(e,"exit"),k(e,n),t.props.onExited&&t.props.onExited(e)},t.getClassNames=function(e){var n=t.props.classNames,r="string"==typeof n,i=r?(r&&n?n+"-":"")+e:n[e];return{className:i,activeClassName:r?i+"-active":n[e+"Active"],doneClassName:r?i+"-done":n[e+"Done"]}},t}a(t,e);var n=t.prototype;return n.removeClasses=function(e,t){var n=this.getClassNames(t),r=n.className,i=n.activeClassName,o=n.doneClassName;r&&j(e,r),i&&j(e,i),o&&j(e,o)},n.reflowAndAddClass=function(e,t){t&&(e&&e.scrollTop,k(e,t))},n.render=function(){var e=o({},this.props);return delete e.classNames,r.createElement(S,o({},e,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},t}(r.Component);function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function P(e,n){var r=Object.create(null);return e&&t.Children.map(e,function(e){return e}).forEach(function(e){r[e.key]=function(e){return n&&t.isValidElement(e)?n(e):e}(e)}),r}function A(e,t,n){return null!=n[t]?n[t]:e.props[t]}function L(e,n,r){var i=P(e.children),o=function(e,t){function n(n){return n in t?t[n]:e[n]}e=e||{},t=t||{};var r,i=Object.create(null),o=[];for(var a in e)a in t?o.length&&(i[a]=o,o=[]):o.push(a);var s={};for(var l in t){if(i[l])for(r=0;r<i[l].length;r++){var c=i[l][r];s[i[l][r]]=n(c)}s[l]=n(l)}for(r=0;r<o.length;r++)s[o[r]]=n(o[r]);return s}(n,i);return Object.keys(o).forEach(function(a){var s=o[a];if(t.isValidElement(s)){var l=a in n,c=a in i,u=n[a],p=t.isValidElement(u)&&!u.props.in;!c||l&&!p?c||!l||p?c&&l&&t.isValidElement(u)&&(o[a]=t.cloneElement(s,{onExited:r.bind(null,s),in:u.props.in,exit:A(s,"exit",e),enter:A(s,"enter",e)})):o[a]=t.cloneElement(s,{in:!1}):o[a]=t.cloneElement(s,{onExited:r.bind(null,s),in:!0,exit:A(s,"exit",e),enter:A(s,"enter",e)})}}),o}_.defaultProps={classNames:""},_.propTypes={};var R=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},M=function(e){function n(t,n){var r,i=(r=e.call(this,t,n)||this).handleExited.bind(w(w(r)));return r.state={contextValue:{isMounting:!0},handleExited:i,firstRender:!0},r}a(n,e);var i=n.prototype;return i.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},i.componentWillUnmount=function(){this.mounted=!1},n.getDerivedStateFromProps=function(e,n){var r,i,o=n.children,a=n.handleExited;return{children:n.firstRender?(r=e,i=a,P(r.children,function(e){return t.cloneElement(e,{onExited:i.bind(null,e),in:!0,appear:A(e,"appear",r),enter:A(e,"enter",r),exit:A(e,"exit",r)})})):L(e,o,a),firstRender:!1}},i.handleExited=function(e,t){var n=P(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState(function(t){var n=o({},t.children);return delete n[e.key],{children:n}}))},i.render=function(){var e=this.props,t=e.component,n=e.childFactory,i=y(e,["component","childFactory"]),o=this.state.contextValue,a=R(this.state.children).map(n);return delete i.appear,delete i.enter,delete i.exit,null===t?r.createElement(g.Provider,{value:o},a):r.createElement(g.Provider,{value:o},r.createElement(t,i,a))},n}(r.Component);M.propTypes={},M.defaultProps={component:"div",childFactory:function(e){return e}};var D=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).handleEnter=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onEnter",0,n)},t.handleEntering=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onEntering",0,n)},t.handleEntered=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onEntered",0,n)},t.handleExit=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onExit",1,n)},t.handleExiting=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onExiting",1,n)},t.handleExited=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onExited",1,n)},t}a(t,e);var i=t.prototype;return i.handleLifecycle=function(e,t,i){var o,a=this.props.children,s=r.Children.toArray(a)[t];s.props[e]&&(o=s.props)[e].apply(o,i),this.props[e]&&this.props[e](n.findDOMNode(this))},i.render=function(){var e=this.props,t=e.children,n=e.in,i=y(e,["children","in"]),o=r.Children.toArray(t),a=o[0],s=o[1];return delete i.onEnter,delete i.onEntering,delete i.onEntered,delete i.onExit,delete i.onExiting,delete i.onExited,r.createElement(M,i,n?r.cloneElement(a,{key:"first",onEnter:this.handleEnter,onEntering:this.handleEntering,onEntered:this.handleEntered}):r.cloneElement(s,{key:"second",onEnter:this.handleExit,onEntering:this.handleExiting,onEntered:this.handleExited}))},t}(r.Component);D.propTypes={},e.CSSTransition=_,e.ReplaceTransition=D,e.Transition=S,e.TransitionGroup=M,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e=e||self).ReactTransitionGroup={},e.React,e.ReactDOM)}(this,function(e,t,n){"use strict";var r="default"in t?t.default:t,i="default"in n?n.default:n;function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}function s(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function c(e,t){return e(t={exports:{}},t.exports),t.exports}var u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable;(function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}})()&&Object.assign;var f="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";function h(){}var E=c(function(e){e.exports=function(){function e(e,t,n,r,i,o){if(o!==f){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=h,n.PropTypes=n,n}()}),x=(E.object,E.oneOfType,E.element,E.bool,E.func,c(function(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}}}));l(x);var m=c(function(e,t){t.__esModule=!0,t.default=function(e,t){return e.classList?!!t&&e.classList.contains(t):-1!==(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")},e.exports=t.default});l(m);var v=l(c(function(e,t){t.__esModule=!0,t.default=function(e,t){e.classList?e.classList.add(t):(0,n.default)(e,t)||("string"==typeof e.className?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))};var n=x(m);e.exports=t.default}));function y(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}var g=r.createContext(null),b="unmounted",C="exited",O="entering",N="entered",S=function(e){function t(t,n){var r;r=e.call(this,t,n)||this;var i,o=n&&!n.isMounting?t.enter:t.appear;return r.appearStatus=null,t.in?o?(i=C,r.appearStatus=O):i=N:i=t.unmountOnExit||t.mountOnEnter?b:C,r.state={status:i},r.nextCallback=null,r}s(t,e),t.getDerivedStateFromProps=function(e,t){return e.in&&t.status===b?{status:C}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==O&&n!==N&&(t=O):n!==O&&n!==N||(t="exiting")}this.updateStatus(!1,t)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var e,t,n,r=this.props.timeout;return e=t=n=r,null!=r&&"number"!=typeof r&&(e=r.exit,t=r.enter,n=void 0!==r.appear?r.appear:t),{exit:e,enter:t,appear:n}},n.updateStatus=function(e,t){if(void 0===e&&(e=!1),null!==t){this.cancelNextCallback();var n=i.findDOMNode(this);t===O?this.performEnter(n,e):this.performExit(n)}else this.props.unmountOnExit&&this.state.status===C&&this.setState({status:b})},n.performEnter=function(e,t){var n=this,r=this.props.enter,i=this.context?this.context.isMounting:t,o=this.getTimeouts(),a=i?o.appear:o.enter;t||r?(this.props.onEnter(e,i),this.safeSetState({status:O},function(){n.props.onEntering(e,i),n.onTransitionEnd(e,a,function(){n.safeSetState({status:N},function(){n.props.onEntered(e,i)})})})):this.safeSetState({status:N},function(){n.props.onEntered(e)})},n.performExit=function(e){var t=this,n=this.props.exit,r=this.getTimeouts();n?(this.props.onExit(e),this.safeSetState({status:"exiting"},function(){t.props.onExiting(e),t.onTransitionEnd(e,r.exit,function(){t.safeSetState({status:C},function(){t.props.onExited(e)})})})):this.safeSetState({status:C},function(){t.props.onExited(e)})},n.cancelNextCallback=function(){null!==this.nextCallback&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},n.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},n.onTransitionEnd=function(e,t,n){this.setNextCallback(n);var r=null==t&&!this.props.addEndListener;e&&!r?(this.props.addEndListener&&this.props.addEndListener(e,this.nextCallback),null!=t&&setTimeout(this.nextCallback,t)):setTimeout(this.nextCallback,0)},n.render=function(){var e=this.state.status;if(e===b)return null;var t=this.props,n=t.children,i=a(t,["children"]);if(delete i.in,delete i.mountOnEnter,delete i.unmountOnExit,delete i.appear,delete i.enter,delete i.exit,delete i.timeout,delete i.addEndListener,delete i.onEnter,delete i.onEntering,delete i.onEntered,delete i.onExit,delete i.onExiting,delete i.onExited,"function"==typeof n)return r.createElement(g.Provider,{value:null},n(e,i));var o=r.Children.only(n);return r.createElement(g.Provider,{value:null},r.cloneElement(o,i))},t}(r.Component);function T(){}S.contextType=g,S.propTypes={},S.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:T,onEntering:T,onEntered:T,onExit:T,onExiting:T,onExited:T},S.UNMOUNTED=0,S.EXITED=1,S.ENTERING=2,S.ENTERED=3,S.EXITING=4;var k=function(e,t){return e&&t&&t.split(" ").forEach(function(t){return r=t,void((n=e).classList?n.classList.remove(r):"string"==typeof n.className?n.className=y(n.className,r):n.setAttribute("class",y(n.className&&n.className.baseVal||"",r)));var n,r})},j=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).appliedClasses={appear:{},enter:{},exit:{}},t.onEnter=function(e,n){t.removeClasses(e,"exit"),t.addClass(e,n?"appear":"enter","base"),t.props.onEnter&&t.props.onEnter(e,n)},t.onEntering=function(e,n){var r=n?"appear":"enter";t.addClass(e,r,"active"),t.props.onEntering&&t.props.onEntering(e,n)},t.onEntered=function(e,n){var r=n?"appear":"enter";t.removeClasses(e,r),t.addClass(e,r,"done"),t.props.onEntered&&t.props.onEntered(e,n)},t.onExit=function(e){t.removeClasses(e,"appear"),t.removeClasses(e,"enter"),t.addClass(e,"exit","base"),t.props.onExit&&t.props.onExit(e)},t.onExiting=function(e){t.addClass(e,"exit","active"),t.props.onExiting&&t.props.onExiting(e)},t.onExited=function(e){t.removeClasses(e,"exit"),t.addClass(e,"exit","done"),t.props.onExited&&t.props.onExited(e)},t.getClassNames=function(e){var n=t.props.classNames,r="string"==typeof n,i=r?""+(r&&n?n+"-":"")+e:n[e];return{baseClassName:i,activeClassName:r?i+"-active":n[e+"Active"],doneClassName:r?i+"-done":n[e+"Done"]}},t}s(t,e);var n=t.prototype;return n.addClass=function(e,t,n){var r=this.getClassNames(t)[n+"ClassName"];"appear"===t&&"done"===n&&(r+=" "+this.getClassNames("enter").doneClassName),"active"===n&&e&&e.scrollTop,this.appliedClasses[t][n]=r,function(e,t){e&&t&&t.split(" ").forEach(function(t){return v(e,t)})}(e,r)},n.removeClasses=function(e,t){var n=this.appliedClasses[t],r=n.base,i=n.active,o=n.done;this.appliedClasses[t]={},r&&k(e,r),i&&k(e,i),o&&k(e,o)},n.render=function(){var e=this.props,t=(e.classNames,a(e,["classNames"]));return r.createElement(S,o({},t,{onEnter:this.onEnter,onEntered:this.onEntered,onEntering:this.onEntering,onExit:this.onExit,onExiting:this.onExiting,onExited:this.onExited}))},t}(r.Component);function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function P(e,n){var r=Object.create(null);return e&&t.Children.map(e,function(e){return e}).forEach(function(e){r[e.key]=function(e){return n&&t.isValidElement(e)?n(e):e}(e)}),r}function w(e,t,n){return null!=n[t]?n[t]:e.props[t]}function L(e,n,r){var i=P(e.children),o=function(e,t){function n(n){return n in t?t[n]:e[n]}e=e||{},t=t||{};var r,i=Object.create(null),o=[];for(var a in e)a in t?o.length&&(i[a]=o,o=[]):o.push(a);var s={};for(var l in t){if(i[l])for(r=0;r<i[l].length;r++){var c=i[l][r];s[i[l][r]]=n(c)}s[l]=n(l)}for(r=0;r<o.length;r++)s[o[r]]=n(o[r]);return s}(n,i);return Object.keys(o).forEach(function(a){var s=o[a];if(t.isValidElement(s)){var l=a in n,c=a in i,u=n[a],p=t.isValidElement(u)&&!u.props.in;!c||l&&!p?c||!l||p?c&&l&&t.isValidElement(u)&&(o[a]=t.cloneElement(s,{onExited:r.bind(null,s),in:u.props.in,exit:w(s,"exit",e),enter:w(s,"enter",e)})):o[a]=t.cloneElement(s,{in:!1}):o[a]=t.cloneElement(s,{onExited:r.bind(null,s),in:!0,exit:w(s,"exit",e),enter:w(s,"enter",e)})}}),o}j.defaultProps={classNames:""},j.propTypes={};var R=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},M=function(e){function n(t,n){var r,i=(r=e.call(this,t,n)||this).handleExited.bind(_(_(r)));return r.state={contextValue:{isMounting:!0},handleExited:i,firstRender:!0},r}s(n,e);var i=n.prototype;return i.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},i.componentWillUnmount=function(){this.mounted=!1},n.getDerivedStateFromProps=function(e,n){var r,i,o=n.children,a=n.handleExited;return{children:n.firstRender?(r=e,i=a,P(r.children,function(e){return t.cloneElement(e,{onExited:i.bind(null,e),in:!0,appear:w(e,"appear",r),enter:w(e,"enter",r),exit:w(e,"exit",r)})})):L(e,o,a),firstRender:!1}},i.handleExited=function(e,t){var n=P(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState(function(t){var n=o({},t.children);return delete n[e.key],{children:n}}))},i.render=function(){var e=this.props,t=e.component,n=e.childFactory,i=a(e,["component","childFactory"]),o=this.state.contextValue,s=R(this.state.children).map(n);return delete i.appear,delete i.enter,delete i.exit,null===t?r.createElement(g.Provider,{value:o},s):r.createElement(g.Provider,{value:o},r.createElement(t,i,s))},n}(r.Component);M.propTypes={},M.defaultProps={component:"div",childFactory:function(e){return e}};var A=function(e){function t(){for(var t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return(t=e.call.apply(e,[this].concat(r))||this).handleEnter=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onEnter",0,n)},t.handleEntering=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onEntering",0,n)},t.handleEntered=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onEntered",0,n)},t.handleExit=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onExit",1,n)},t.handleExiting=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onExiting",1,n)},t.handleExited=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.handleLifecycle("onExited",1,n)},t}s(t,e);var i=t.prototype;return i.handleLifecycle=function(e,t,i){var o,a=this.props.children,s=r.Children.toArray(a)[t];s.props[e]&&(o=s.props)[e].apply(o,i),this.props[e]&&this.props[e](n.findDOMNode(this))},i.render=function(){var e=this.props,t=e.children,n=e.in,i=a(e,["children","in"]),o=r.Children.toArray(t),s=o[0],l=o[1];return delete i.onEnter,delete i.onEntering,delete i.onEntered,delete i.onExit,delete i.onExiting,delete i.onExited,r.createElement(M,i,n?r.cloneElement(s,{key:"first",onEnter:this.handleEnter,onEntering:this.handleEntering,onEntered:this.handleEntered}):r.cloneElement(l,{key:"second",onEnter:this.handleExit,onEntering:this.handleExiting,onEntered:this.handleExited}))},t}(r.Component);A.propTypes={},e.CSSTransition=j,e.ReplaceTransition=A,e.Transition=S,e.TransitionGroup=M,Object.defineProperty(e,"__esModule",{value:!0})}); |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose"; | ||
@@ -10,3 +11,3 @@ import * as PropTypes from 'prop-types'; | ||
var addClass = function addClass(node, classes) { | ||
var _addClass = function addClass(node, classes) { | ||
return node && classes && classes.split(' ').forEach(function (c) { | ||
@@ -97,10 +98,12 @@ return addOneClass(node, c); | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_this.appliedClasses = { | ||
appear: {}, | ||
enter: {}, | ||
exit: {} | ||
}; | ||
_this.onEnter = function (node, appearing) { | ||
var _this$getClassNames = _this.getClassNames(appearing ? 'appear' : 'enter'), | ||
className = _this$getClassNames.className; | ||
_this.removeClasses(node, 'exit'); | ||
addClass(node, className); | ||
_this.addClass(node, appearing ? 'appear' : 'enter', 'base'); | ||
@@ -113,6 +116,5 @@ if (_this.props.onEnter) { | ||
_this.onEntering = function (node, appearing) { | ||
var _this$getClassNames2 = _this.getClassNames(appearing ? 'appear' : 'enter'), | ||
activeClassName = _this$getClassNames2.activeClassName; | ||
var type = appearing ? 'appear' : 'enter'; | ||
_this.reflowAndAddClass(node, activeClassName); | ||
_this.addClass(node, type, 'active'); | ||
@@ -125,12 +127,8 @@ if (_this.props.onEntering) { | ||
_this.onEntered = function (node, appearing) { | ||
var appearClassName = _this.getClassNames('appear').doneClassName; | ||
var type = appearing ? 'appear' : 'enter'; | ||
var enterClassName = _this.getClassNames('enter').doneClassName; | ||
_this.removeClasses(node, type); | ||
var doneClassName = appearing ? appearClassName + " " + enterClassName : enterClassName; | ||
_this.addClass(node, type, 'done'); | ||
_this.removeClasses(node, appearing ? 'appear' : 'enter'); | ||
addClass(node, doneClassName); | ||
if (_this.props.onEntered) { | ||
@@ -142,5 +140,2 @@ _this.props.onEntered(node, appearing); | ||
_this.onExit = function (node) { | ||
var _this$getClassNames3 = _this.getClassNames('exit'), | ||
className = _this$getClassNames3.className; | ||
_this.removeClasses(node, 'appear'); | ||
@@ -150,3 +145,3 @@ | ||
addClass(node, className); | ||
_this.addClass(node, 'exit', 'base'); | ||
@@ -159,7 +154,4 @@ if (_this.props.onExit) { | ||
_this.onExiting = function (node) { | ||
var _this$getClassNames4 = _this.getClassNames('exit'), | ||
activeClassName = _this$getClassNames4.activeClassName; | ||
_this.addClass(node, 'exit', 'active'); | ||
_this.reflowAndAddClass(node, activeClassName); | ||
if (_this.props.onExiting) { | ||
@@ -171,8 +163,5 @@ _this.props.onExiting(node); | ||
_this.onExited = function (node) { | ||
var _this$getClassNames5 = _this.getClassNames('exit'), | ||
doneClassName = _this$getClassNames5.doneClassName; | ||
_this.removeClasses(node, 'exit'); | ||
addClass(node, doneClassName); | ||
_this.addClass(node, 'exit', 'done'); | ||
@@ -187,8 +176,8 @@ if (_this.props.onExited) { | ||
var isStringClassNames = typeof classNames === 'string'; | ||
var prefix = isStringClassNames && classNames ? classNames + '-' : ''; | ||
var className = isStringClassNames ? prefix + type : classNames[type]; | ||
var activeClassName = isStringClassNames ? className + '-active' : classNames[type + 'Active']; | ||
var doneClassName = isStringClassNames ? className + '-done' : classNames[type + 'Done']; | ||
var prefix = isStringClassNames && classNames ? classNames + "-" : ''; | ||
var baseClassName = isStringClassNames ? "" + prefix + type : classNames[type]; | ||
var activeClassName = isStringClassNames ? baseClassName + "-active" : classNames[type + "Active"]; | ||
var doneClassName = isStringClassNames ? baseClassName + "-done" : classNames[type + "Done"]; | ||
return { | ||
className: className, | ||
baseClassName: baseClassName, | ||
activeClassName: activeClassName, | ||
@@ -204,29 +193,46 @@ doneClassName: doneClassName | ||
_proto.removeClasses = function removeClasses(node, type) { | ||
var _this$getClassNames6 = this.getClassNames(type), | ||
className = _this$getClassNames6.className, | ||
activeClassName = _this$getClassNames6.activeClassName, | ||
doneClassName = _this$getClassNames6.doneClassName; | ||
_proto.addClass = function addClass(node, type, phase) { | ||
var className = this.getClassNames(type)[phase + "ClassName"]; | ||
className && removeClass(node, className); | ||
activeClassName && removeClass(node, activeClassName); | ||
doneClassName && removeClass(node, doneClassName); | ||
}; | ||
if (type === 'appear' && phase === 'done') { | ||
className += " " + this.getClassNames('enter').doneClassName; | ||
} // This is for to force a repaint, | ||
// which is necessary in order to transition styles when adding a class name. | ||
_proto.reflowAndAddClass = function reflowAndAddClass(node, className) { | ||
// This is for to force a repaint, | ||
// which is necessary in order to transition styles when adding a class name. | ||
if (className) { | ||
if (phase === 'active') { | ||
/* eslint-disable no-unused-expressions */ | ||
node && node.scrollTop; | ||
/* eslint-enable no-unused-expressions */ | ||
} | ||
addClass(node, className); | ||
this.appliedClasses[type][phase] = className; | ||
_addClass(node, className); | ||
}; | ||
_proto.removeClasses = function removeClasses(node, type) { | ||
var _this$appliedClasses$ = this.appliedClasses[type], | ||
baseClassName = _this$appliedClasses$.base, | ||
activeClassName = _this$appliedClasses$.active, | ||
doneClassName = _this$appliedClasses$.done; | ||
this.appliedClasses[type] = {}; | ||
if (baseClassName) { | ||
removeClass(node, baseClassName); | ||
} | ||
if (activeClassName) { | ||
removeClass(node, activeClassName); | ||
} | ||
if (doneClassName) { | ||
removeClass(node, doneClassName); | ||
} | ||
}; | ||
_proto.render = function render() { | ||
var props = _extends({}, this.props); | ||
var _this$props = this.props, | ||
_ = _this$props.classNames, | ||
props = _objectWithoutPropertiesLoose(_this$props, ["classNames"]); | ||
delete props.classNames; | ||
return React.createElement(Transition, _extends({}, props, { | ||
@@ -233,0 +239,0 @@ onEnter: this.onEnter, |
{ | ||
"name": "react-transition-group", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "A react component toolset for managing animations", | ||
@@ -5,0 +5,0 @@ "main": "cjs/index.js", |
# react-transition-group [![npm][npm-badge]][npm] | ||
> **ATTENTION!** To address many issues that have come up over the years, the API in v2 is not backwards compatible with the original [`React addon (v1-stable)`](https://github.com/reactjs/react-transition-group/tree/v1-stable). | ||
> **ATTENTION!** To address many issues that have come up over the years, the API in v2 and above is not backwards compatible with the original [`React addon (v1-stable)`](https://github.com/reactjs/react-transition-group/tree/v1-stable). | ||
> | ||
> **For a drop-in replacement for `react-addons-transition-group` and `react-addons-css-transition-group`, use the v1 release. Documentation and code for that release are available on the [`v1-stable`](https://github.com/reactjs/react-transition-group/tree/v1-stable) branch.** | ||
> | ||
> We are no longer updating the v1 codebase, please upgrade to v2 when possible | ||
> We are no longer updating the v1 codebase, please upgrade to the latest version when possible | ||
@@ -9,0 +9,0 @@ A set of components for managing component states (including mounting and unmounting) over time, specifically designed with animation in mind. |
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
4571
0
187794