Skip to content

Commit 7f932f6

Browse files
committed
Merge branch 'master' into switch-transition
2 parents 92b7a0f + b7a1a0f commit 7f932f6

15 files changed

+1883
-1074
lines changed

.eslintrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ parser: babel-eslint
33
extends:
44
- jason/react
55
- plugin:jsx-a11y/recommended
6+
settings:
7+
react:
8+
version: detect
69
env:
710
node: true
811
browser: true

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
# [4.0.0](https://github.com/reactjs/react-transition-group/compare/v3.0.0...v4.0.0) (2019-04-16)
2+
3+
4+
### Features
5+
6+
* support esm via package.json routes ([#488](https://github.com/reactjs/react-transition-group/issues/488)) ([6337bf5](https://github.com/reactjs/react-transition-group/commit/6337bf5)), closes [#77](https://github.com/reactjs/react-transition-group/issues/77)
7+
8+
9+
### BREAKING CHANGES
10+
11+
* in environments where esm is supported importing from commonjs requires explicitly adding the `.default` after `require()` when resolving to the esm build
12+
13+
# [3.0.0](https://github.com/reactjs/react-transition-group/compare/v2.9.0...v3.0.0) (2019-04-15)
14+
15+
16+
### Features
17+
18+
* use stable context API ([#471](https://github.com/reactjs/react-transition-group/issues/471)) ([aee4901](https://github.com/reactjs/react-transition-group/commit/aee4901)), closes [#429](https://github.com/reactjs/react-transition-group/issues/429)
19+
20+
21+
### BREAKING CHANGES
22+
23+
* use new style react context
24+
25+
```diff
26+
// package.json
27+
-"react": "^15.0.0",
28+
+"react": "^16.6.0",
29+
-"react-dom": "^15.0.0",
30+
+"react-dom": "^16.6.0",
31+
```
32+
33+
# [2.9.0](https://github.com/reactjs/react-transition-group/compare/v2.8.0...v2.9.0) (2019-04-06)
34+
35+
36+
### Features
37+
38+
* **CSSTransition:** add "done" class for appear ([fe3c156](https://github.com/reactjs/react-transition-group/commit/fe3c156)), closes [#383](https://github.com/reactjs/react-transition-group/issues/383) [#327](https://github.com/reactjs/react-transition-group/issues/327) [#327](https://github.com/reactjs/react-transition-group/issues/327)
39+
40+
41+
### Reverts
42+
43+
* bump semantic release dependencies ([1bdcaec](https://github.com/reactjs/react-transition-group/commit/1bdcaec))
44+
145
# [2.8.0](https://github.com/reactjs/react-transition-group/compare/v2.7.1...v2.8.0) (2019-04-02)
246

347

package.json

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
{
22
"name": "react-transition-group",
3-
"version": "2.8.0",
3+
"version": "4.0.0",
44
"description": "A react component toolset for managing animations",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"scripts": {
78
"test": "npm run lint && npm run testonly",
89
"testonly": "jest --verbose",
910
"tdd": "jest --watch",
10-
"build": "babel src --out-dir lib --delete-dir-on-start && npm run build:dist && cp README.md LICENSE ./lib",
11+
"build": "rimraf lib && yarn build:cjs && yarn build:esm && yarn build:pick && yarn build:dist && cp README.md LICENSE ./lib",
1112
"build:docs": "npm -C www run build",
12-
"build:dist": "cross-env BABEL_ENV=esm yarn rollup -c",
13+
"build:cjs": "babel src --out-dir lib/cjs",
14+
"build:esm": "cross-env BABEL_ENV=esm babel src --out-dir lib/esm",
15+
"build:pick": "cherry-pick --name=react-transition-group --cwd=lib --input-dir=../src --cjs-dir=cjs --esm-dir=esm",
16+
"build:dist": "cross-env BABEL_ENV=esm rollup -c",
1317
"bootstrap": "yarn && yarn --cwd www",
1418
"lint": "eslint src test",
1519
"release": "release",
@@ -50,57 +54,55 @@
5054
]
5155
},
5256
"peerDependencies": {
53-
"react": ">=15.0.0",
54-
"react-dom": ">=15.0.0"
57+
"react": ">=16.6.0",
58+
"react-dom": ">=16.6.0"
5559
},
5660
"dependencies": {
57-
"dom-helpers": "^3.3.1",
61+
"dom-helpers": "^3.4.0",
5862
"loose-envify": "^1.4.0",
59-
"prop-types": "^15.6.2",
60-
"react-lifecycles-compat": "^3.0.4"
63+
"prop-types": "^15.6.2"
6164
},
6265
"devDependencies": {
63-
"@babel/cli": "^7.1.0",
64-
"@babel/core": "^7.1.0",
66+
"@babel/cli": "^7.4.3",
67+
"@babel/core": "^7.4.3",
6568
"@semantic-release/changelog": "^3.0.0",
6669
"@semantic-release/git": "^7.0.4",
6770
"@semantic-release/github": "^5.0.5",
6871
"@semantic-release/npm": "^5.0.4",
6972
"@storybook/addon-actions": "^4.1.4",
7073
"@storybook/react": "^4.1.4",
7174
"babel-core": "^7.0.0-bridge.0",
72-
"babel-eslint": "^9.0.0",
73-
"babel-jest": "^23.6.0",
74-
"babel-loader": "^8.0.2",
75-
"babel-plugin-transform-react-remove-prop-types": "^0.4.18",
75+
"babel-eslint": "^10.0.1",
76+
"babel-loader": "^8.0.5",
77+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
7678
"babel-preset-jason": "^6.0.1",
79+
"cherry-pick": "^0.3.0",
7780
"cross-env": "^5.2.0",
78-
"enzyme": "^3.6.0",
79-
"enzyme-adapter-react-16": "^1.5.0",
80-
"eslint": "^5.6.0",
81-
"eslint-config-jason": "^4.1.0",
82-
"eslint-config-prettier": "^3.1.0",
83-
"eslint-plugin-import": "^2.14.0",
84-
"eslint-plugin-jsx-a11y": "^6.1.1",
85-
"eslint-plugin-prettier": "^2.6.2",
86-
"eslint-plugin-react": "^7.11.1",
87-
"husky": "^1.0.0-rc.15",
88-
"jest": "^23.6.0",
89-
"prettier": "^1.14.3",
90-
"react": "^16.5.2",
91-
"react-dom": "^16.5.2",
92-
"react-test-renderer": "^16.5.2",
81+
"enzyme": "^3.9.0",
82+
"enzyme-adapter-react-16": "^1.12.0",
83+
"eslint": "^5.16.0",
84+
"eslint-config-jason": "^5.0.0",
85+
"eslint-config-prettier": "^4.1.0",
86+
"eslint-plugin-import": "^2.16.0",
87+
"eslint-plugin-jsx-a11y": "^6.2.1",
88+
"eslint-plugin-prettier": "^3.0.1",
89+
"eslint-plugin-react": "^7.12.4",
90+
"husky": "^1.3.1",
91+
"jest": "^24.7.1",
92+
"prettier": "^1.16.4",
93+
"react": "~16.6.3",
94+
"react-dom": "~16.6.3",
9395
"release-script": "^1.0.2",
94-
"rimraf": "^2.6.1",
95-
"rollup": "^1.1.0",
96-
"rollup-plugin-babel": "^4.3.0",
97-
"rollup-plugin-commonjs": "^9.2.0",
98-
"rollup-plugin-node-resolve": "^4.0.0",
99-
"rollup-plugin-replace": "^2.1.0",
96+
"rimraf": "^2.6.3",
97+
"rollup": "^1.9.0",
98+
"rollup-plugin-babel": "^4.3.2",
99+
"rollup-plugin-commonjs": "^9.3.4",
100+
"rollup-plugin-node-resolve": "^4.2.0",
101+
"rollup-plugin-replace": "^2.1.1",
100102
"rollup-plugin-size-snapshot": "^0.8.0",
101103
"rollup-plugin-terser": "^4.0.2",
102104
"semantic-release": "^15.9.16",
103-
"semantic-release-alt-publish-dir": "^2.1.1",
105+
"semantic-release-alt-publish-dir": "^3.0.0",
104106
"travis-deploy-once": "^5.0.8"
105107
},
106108
"release": {

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import replace from 'rollup-plugin-replace';
55
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
66
import { terser } from 'rollup-plugin-terser';
77

8-
const input = './src/umd.js';
8+
const input = './src/index.js';
99
const name = 'ReactTransitionGroup';
1010
const globals = {
1111
react: 'React',

src/CSSTransition.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const removeClass = (node, classes) => node && classes && classes.split(' ').for
6464
* }
6565
* .my-node-exit-active {
6666
* opacity: 0;
67-
* transition: opacity: 200ms;
67+
* transition: opacity 200ms;
6868
* }
6969
* ```
7070
*
@@ -98,7 +98,11 @@ class CSSTransition extends React.Component {
9898
}
9999

100100
onEntered = (node, appearing) => {
101-
const { doneClassName } = this.getClassNames('enter');
101+
const appearClassName = this.getClassNames('appear').doneClassName;
102+
const enterClassName = this.getClassNames('enter').doneClassName;
103+
const doneClassName = appearing
104+
? `${appearClassName} ${enterClassName}`
105+
: enterClassName;
102106

103107
this.removeClasses(node, appearing ? 'appear' : 'enter');
104108
addClass(node, doneClassName);
@@ -203,17 +207,29 @@ CSSTransition.propTypes = {
203207
...Transition.propTypes,
204208

205209
/**
206-
* The animation classNames applied to the component as it enters, exits or has finished the transition.
207-
* A single name can be provided and it will be suffixed for each stage: e.g.
210+
* The animation classNames applied to the component as it enters, exits or
211+
* has finished the transition. A single name can be provided and it will be
212+
* suffixed for each stage: e.g.
213+
*
214+
* `classNames="fade"` applies `fade-enter`, `fade-enter-active`,
215+
* `fade-enter-done`, `fade-exit`, `fade-exit-active`, `fade-exit-done`,
216+
* `fade-appear`, `fade-appear-active`, and `fade-appear-done`.
217+
*
218+
* **Note**: `fade-appear-done` and `fade-enter-done` will _both_ be applied.
219+
* This allows you to define different behavior for when appearing is done and
220+
* when regular entering is done, using selectors like
221+
* `.fade-enter-done:not(.fade-appear-done)`. For example, you could apply an
222+
* epic entrance animation when element first appears in the DOM using
223+
* [Animate.css](https://daneden.github.io/animate.css/). Otherwise you can
224+
* simply use `fade-enter-done` for defining both cases.
208225
*
209-
* `classNames="fade"` applies `fade-enter`, `fade-enter-active`, `fade-enter-done`,
210-
* `fade-exit`, `fade-exit-active`, `fade-exit-done`, `fade-appear`, and `fade-appear-active`.
211226
* Each individual classNames can also be specified independently like:
212227
*
213228
* ```js
214229
* classNames={{
215230
* appear: 'my-appear',
216231
* appearActive: 'my-active-appear',
232+
* appearDone: 'my-done-appear',
217233
* enter: 'my-enter',
218234
* enterActive: 'my-active-enter',
219235
* enterDone: 'my-done-enter',
@@ -229,8 +245,8 @@ CSSTransition.propTypes = {
229245
* import styles from './styles.css';
230246
* ```
231247
*
232-
* you might want to use camelCase in your CSS file, that way could simply spread
233-
* them instead of listing them one by one:
248+
* you might want to use camelCase in your CSS file, that way could simply
249+
* spread them instead of listing them one by one:
234250
*
235251
* ```js
236252
* classNames={{ ...styles }}
@@ -239,6 +255,7 @@ CSSTransition.propTypes = {
239255
* @type {string | {
240256
* appear?: string,
241257
* appearActive?: string,
258+
* appearDone?: string,
242259
* enter?: string,
243260
* enterActive?: string,
244261
* enterDone?: string,
@@ -273,7 +290,6 @@ CSSTransition.propTypes = {
273290
*/
274291
onEntered: PropTypes.func,
275292

276-
277293
/**
278294
* A `<Transition>` callback fired immediately after the 'exit' class is
279295
* applied.

src/Transition.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as PropTypes from 'prop-types'
22
import React from 'react'
33
import ReactDOM from 'react-dom'
4-
import { polyfill } from 'react-lifecycles-compat'
54

65
import { timeoutsShape } from './utils/PropTypes'
6+
import TransitionGroupContext from './TransitionGroupContext'
77

88
export const UNMOUNTED = 'unmounted'
99
export const EXITED = 'exited'
@@ -44,8 +44,10 @@ export const EXITING = 'exiting'
4444
* }
4545
*
4646
* const transitionStyles = {
47-
* entering: { opacity: 0 },
47+
* entering: { opacity: 1 },
4848
* entered: { opacity: 1 },
49+
* exiting: { opacity: 0 },
50+
* exited: { opacity: 0 },
4951
* };
5052
*
5153
* const Fade = ({ in: inProp }) => (
@@ -101,17 +103,12 @@ export const EXITING = 'exiting'
101103
* `'exiting'` to `'exited'`.
102104
*/
103105
class Transition extends React.Component {
104-
static contextTypes = {
105-
transitionGroup: PropTypes.object,
106-
}
107-
static childContextTypes = {
108-
transitionGroup: () => {},
109-
}
106+
static contextType = TransitionGroupContext
110107

111108
constructor(props, context) {
112109
super(props, context)
113110

114-
let parentGroup = context.transitionGroup
111+
let parentGroup = context
115112
// In the context of a TransitionGroup all enters are really appears
116113
let appear =
117114
parentGroup && !parentGroup.isMounting ? props.enter : props.appear
@@ -140,10 +137,6 @@ class Transition extends React.Component {
140137
this.nextCallback = null
141138
}
142139

143-
getChildContext() {
144-
return { transitionGroup: null } // allows for nested Transitions
145-
}
146-
147140
static getDerivedStateFromProps({ in: nextIn }, prevState) {
148141
if (nextIn && prevState.status === UNMOUNTED) {
149142
return { status: EXITED }
@@ -230,8 +223,8 @@ class Transition extends React.Component {
230223

231224
performEnter(node, mounting) {
232225
const { enter } = this.props
233-
const appearing = this.context.transitionGroup
234-
? this.context.transitionGroup.isMounting
226+
const appearing = this.context
227+
? this.context.isMounting
235228
: mounting
236229

237230
const timeouts = this.getTimeouts()
@@ -358,11 +351,21 @@ class Transition extends React.Component {
358351
delete childProps.onExited
359352

360353
if (typeof children === 'function') {
361-
return children(status, childProps)
354+
// allows for nested Transitions
355+
return (
356+
<TransitionGroupContext.Provider value={null}>
357+
{children(status, childProps)}
358+
</TransitionGroupContext.Provider>
359+
)
362360
}
363361

364362
const child = React.Children.only(children)
365-
return React.cloneElement(child, childProps)
363+
return (
364+
// allows for nested Transitions
365+
<TransitionGroupContext.Provider value={null}>
366+
{React.cloneElement(child, childProps)}
367+
</TransitionGroupContext.Provider>
368+
)
366369
}
367370
}
368371

@@ -542,4 +545,4 @@ Transition.ENTERING = 2
542545
Transition.ENTERED = 3
543546
Transition.EXITING = 4
544547

545-
export default polyfill(Transition)
548+
export default Transition

0 commit comments

Comments
 (0)