@instructure/ui-motion 8.11.2-snapshot.7 → 8.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/es/Transition/BaseTransition/index.js +46 -27
- package/es/Transition/BaseTransition/props.js +12 -10
- package/es/Transition/index.js +8 -17
- package/es/Transition/props.js +4 -67
- package/es/Transition/styles.js +11 -8
- package/es/package.json +1 -0
- package/lib/Transition/BaseTransition/index.js +46 -27
- package/lib/Transition/BaseTransition/props.js +13 -10
- package/lib/Transition/index.js +8 -17
- package/lib/Transition/props.js +6 -67
- package/lib/Transition/styles.js +14 -9
- package/package.json +12 -13
- package/src/Transition/BaseTransition/index.ts +88 -79
- package/src/Transition/BaseTransition/props.ts +93 -51
- package/src/Transition/README.md +44 -47
- package/src/Transition/index.tsx +15 -32
- package/src/Transition/props.ts +32 -88
- package/src/Transition/styles.ts +10 -9
- package/types/Transition/BaseTransition/index.d.ts +27 -66
- package/types/Transition/BaseTransition/index.d.ts.map +1 -1
- package/types/Transition/BaseTransition/props.d.ts +52 -38
- package/types/Transition/BaseTransition/props.d.ts.map +1 -1
- package/types/Transition/index.d.ts +5 -55
- package/types/Transition/index.d.ts.map +1 -1
- package/types/Transition/props.d.ts +14 -18
- package/types/Transition/props.d.ts.map +1 -1
- package/types/Transition/styles.d.ts +8 -0
- package/types/Transition/styles.d.ts.map +1 -1
- package/LICENSE.md +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.12.0](https://github.com/instructure/instructure-ui/compare/v8.11.1...v8.12.0) (2021-11-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **ui-motion:** fix interrupted transition not removing transition classes ([db3fd4f](https://github.com/instructure/instructure-ui/commit/db3fd4f6ad76471dce61cc91f8267c1eb3094020))
|
|
11
|
+
|
|
6
12
|
## [8.11.1](https://github.com/instructure/instructure-ui/compare/v8.11.0...v8.11.1) (2021-10-19)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @instructure/ui-motion
|
|
@@ -43,6 +43,7 @@ class BaseTransition extends React.Component {
|
|
|
43
43
|
constructor(...args) {
|
|
44
44
|
super(...args);
|
|
45
45
|
this._timeouts = [];
|
|
46
|
+
this._unmounted = false;
|
|
46
47
|
this.state = {
|
|
47
48
|
transitioning: false
|
|
48
49
|
};
|
|
@@ -61,6 +62,7 @@ class BaseTransition extends React.Component {
|
|
|
61
62
|
|
|
62
63
|
this.transition = (toState, fromState, transitionCallback, transitionDuration = 0) => {
|
|
63
64
|
if (this._unmounted) return;
|
|
65
|
+
const onTransition = this.props.onTransition;
|
|
64
66
|
const classList = getClassList(this);
|
|
65
67
|
const transitionClassName = this.getTransitionClassName(toState);
|
|
66
68
|
const prevTransitionClassName = this.getTransitionClassName(fromState);
|
|
@@ -80,8 +82,8 @@ class BaseTransition extends React.Component {
|
|
|
80
82
|
classList.add(transitionClassName);
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
if (toState && fromState) {
|
|
84
|
-
|
|
85
|
+
if (toState && fromState && typeof onTransition === 'function') {
|
|
86
|
+
onTransition(toState, fromState);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
this._timeouts.push(setTimeout(() => {
|
|
@@ -96,19 +98,27 @@ class BaseTransition extends React.Component {
|
|
|
96
98
|
this.enter = initialState => {
|
|
97
99
|
if (this.state.transitioning || this._unmounted) return;
|
|
98
100
|
const props = this.props;
|
|
99
|
-
|
|
101
|
+
|
|
102
|
+
if (typeof props.onEnter === 'function') {
|
|
103
|
+
props.onEnter();
|
|
104
|
+
}
|
|
100
105
|
|
|
101
106
|
if (props.transitionEnter) {
|
|
102
107
|
this.setState({
|
|
103
108
|
transitioning: true
|
|
104
109
|
}, () => {
|
|
105
110
|
const enter = () => {
|
|
106
|
-
props.onEntering
|
|
111
|
+
if (typeof props.onEntering === 'function') {
|
|
112
|
+
props.onEntering();
|
|
113
|
+
}
|
|
114
|
+
|
|
107
115
|
this.transition(STATES.ENTERED, STATES.ENTERING, () => {
|
|
108
116
|
this.setState({
|
|
109
117
|
transitioning: false
|
|
110
118
|
}, () => {
|
|
111
|
-
props.onEntered
|
|
119
|
+
if (typeof props.onEntered === 'function') {
|
|
120
|
+
props.onEntered();
|
|
121
|
+
}
|
|
112
122
|
});
|
|
113
123
|
});
|
|
114
124
|
};
|
|
@@ -126,7 +136,10 @@ class BaseTransition extends React.Component {
|
|
|
126
136
|
transitioning: false
|
|
127
137
|
}, () => {
|
|
128
138
|
this.transition(STATES.ENTERED, STATES.EXITED);
|
|
129
|
-
|
|
139
|
+
|
|
140
|
+
if (typeof props.onEntered === 'function') {
|
|
141
|
+
props.onEntered();
|
|
142
|
+
}
|
|
130
143
|
});
|
|
131
144
|
}
|
|
132
145
|
};
|
|
@@ -134,19 +147,27 @@ class BaseTransition extends React.Component {
|
|
|
134
147
|
this.exit = initialState => {
|
|
135
148
|
if (this.state.transitioning) return;
|
|
136
149
|
const props = this.props;
|
|
137
|
-
|
|
150
|
+
|
|
151
|
+
if (typeof props.onExit === 'function') {
|
|
152
|
+
props.onExit();
|
|
153
|
+
}
|
|
138
154
|
|
|
139
155
|
if (props.transitionExit) {
|
|
140
156
|
this.setState({
|
|
141
157
|
transitioning: true
|
|
142
158
|
}, () => {
|
|
143
159
|
const exit = () => {
|
|
144
|
-
props.onExiting
|
|
160
|
+
if (typeof props.onExiting === 'function') {
|
|
161
|
+
props.onExiting();
|
|
162
|
+
}
|
|
163
|
+
|
|
145
164
|
this.transition(STATES.EXITED, STATES.EXITING, () => {
|
|
146
165
|
this.setState({
|
|
147
166
|
transitioning: false
|
|
148
167
|
}, () => {
|
|
149
|
-
props.onExited
|
|
168
|
+
if (typeof props.onExited === 'function') {
|
|
169
|
+
props.onExited();
|
|
170
|
+
}
|
|
150
171
|
});
|
|
151
172
|
});
|
|
152
173
|
};
|
|
@@ -164,7 +185,10 @@ class BaseTransition extends React.Component {
|
|
|
164
185
|
transitioning: false
|
|
165
186
|
}, () => {
|
|
166
187
|
this.transition(STATES.EXITED, STATES.ENTERED);
|
|
167
|
-
|
|
188
|
+
|
|
189
|
+
if (typeof props.onExited === 'function') {
|
|
190
|
+
props.onExited();
|
|
191
|
+
}
|
|
168
192
|
});
|
|
169
193
|
}
|
|
170
194
|
};
|
|
@@ -185,7 +209,7 @@ class BaseTransition extends React.Component {
|
|
|
185
209
|
return null;
|
|
186
210
|
}
|
|
187
211
|
|
|
188
|
-
componentDidUpdate(prevProps,
|
|
212
|
+
componentDidUpdate(prevProps, _prevState, cancelPrematurely) {
|
|
189
213
|
if (cancelPrematurely) {
|
|
190
214
|
this.clearTransition(prevProps.transitionClassName);
|
|
191
215
|
}
|
|
@@ -214,8 +238,12 @@ class BaseTransition extends React.Component {
|
|
|
214
238
|
}, () => {
|
|
215
239
|
if (this._unmounted) return;
|
|
216
240
|
const classList = getClassList(this);
|
|
217
|
-
Object.
|
|
218
|
-
|
|
241
|
+
Object.values(STATES).forEach(state => {
|
|
242
|
+
const className = this.getTransitionClassName(state);
|
|
243
|
+
|
|
244
|
+
if (className) {
|
|
245
|
+
classList.remove(className);
|
|
246
|
+
}
|
|
219
247
|
});
|
|
220
248
|
classList.remove(transitionClassName);
|
|
221
249
|
});
|
|
@@ -255,15 +283,15 @@ class BaseTransition extends React.Component {
|
|
|
255
283
|
return props.exitingClassName;
|
|
256
284
|
|
|
257
285
|
default:
|
|
258
|
-
return
|
|
286
|
+
return void 0;
|
|
259
287
|
}
|
|
260
288
|
}
|
|
261
289
|
|
|
262
290
|
renderChildren() {
|
|
263
|
-
return safeCloneElement(ensureSingleChild(this.props.children), {
|
|
264
|
-
'aria-hidden': !this.props.in ? true :
|
|
291
|
+
return this.props.children ? safeCloneElement(ensureSingleChild(this.props.children), {
|
|
292
|
+
'aria-hidden': !this.props.in ? true : void 0,
|
|
265
293
|
ref: this.ref
|
|
266
|
-
});
|
|
294
|
+
}) : null;
|
|
267
295
|
}
|
|
268
296
|
|
|
269
297
|
render() {
|
|
@@ -281,21 +309,12 @@ BaseTransition.propTypes = propTypes;
|
|
|
281
309
|
BaseTransition.allowedProps = allowedProps;
|
|
282
310
|
BaseTransition.defaultProps = {
|
|
283
311
|
in: false,
|
|
284
|
-
component: 'div',
|
|
285
312
|
unmountOnExit: false,
|
|
286
313
|
transitionOnMount: false,
|
|
287
314
|
transitionEnter: true,
|
|
288
315
|
transitionExit: true,
|
|
289
316
|
enterDelay: 300,
|
|
290
|
-
exitDelay: 300
|
|
291
|
-
onEnter: function () {},
|
|
292
|
-
onEntering: function () {},
|
|
293
|
-
onEntered: function () {},
|
|
294
|
-
onExit: function () {},
|
|
295
|
-
onExiting: function () {},
|
|
296
|
-
onExited: function () {},
|
|
297
|
-
onTransition: function () {},
|
|
298
|
-
children: null
|
|
317
|
+
exitDelay: 300
|
|
299
318
|
};
|
|
300
319
|
BaseTransition.states = STATES;
|
|
301
320
|
export default BaseTransition;
|
|
@@ -22,19 +22,12 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
|
-
const
|
|
25
|
+
const transitionCommonPropTypes = {
|
|
26
26
|
in: PropTypes.bool,
|
|
27
27
|
unmountOnExit: PropTypes.bool,
|
|
28
28
|
transitionOnMount: PropTypes.bool,
|
|
29
29
|
transitionEnter: PropTypes.bool,
|
|
30
30
|
transitionExit: PropTypes.bool,
|
|
31
|
-
enterDelay: PropTypes.number,
|
|
32
|
-
exitDelay: PropTypes.number,
|
|
33
|
-
transitionClassName: PropTypes.string,
|
|
34
|
-
exitedClassName: PropTypes.string,
|
|
35
|
-
exitingClassName: PropTypes.string,
|
|
36
|
-
enteredClassName: PropTypes.string,
|
|
37
|
-
enteringClassName: PropTypes.string,
|
|
38
31
|
onTransition: PropTypes.func,
|
|
39
32
|
onEnter: PropTypes.func,
|
|
40
33
|
onEntering: PropTypes.func,
|
|
@@ -42,8 +35,17 @@ const propTypes = {
|
|
|
42
35
|
onExit: PropTypes.func,
|
|
43
36
|
onExiting: PropTypes.func,
|
|
44
37
|
onExited: PropTypes.func,
|
|
45
|
-
children: PropTypes.node
|
|
38
|
+
children: PropTypes.node
|
|
39
|
+
};
|
|
40
|
+
const propTypes = { ...transitionCommonPropTypes,
|
|
41
|
+
enterDelay: PropTypes.number,
|
|
42
|
+
exitDelay: PropTypes.number,
|
|
43
|
+
transitionClassName: PropTypes.string.isRequired,
|
|
44
|
+
exitedClassName: PropTypes.string.isRequired,
|
|
45
|
+
exitingClassName: PropTypes.string.isRequired,
|
|
46
|
+
enteredClassName: PropTypes.string.isRequired,
|
|
47
|
+
enteringClassName: PropTypes.string.isRequired,
|
|
46
48
|
className: PropTypes.string
|
|
47
49
|
};
|
|
48
50
|
const allowedProps = ['in', 'unmountOnExit', 'transitionOnMount', 'transitionEnter', 'transitionExit', 'enterDelay', 'exitDelay', 'transitionClassName', 'exitedClassName', 'exitingClassName', 'enteredClassName', 'enteringClassName', 'onTransition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'children', 'className'];
|
|
49
|
-
export { propTypes, allowedProps };
|
|
51
|
+
export { propTypes, allowedProps, transitionCommonPropTypes };
|
package/es/Transition/index.js
CHANGED
|
@@ -46,6 +46,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
46
46
|
category: components/utilities
|
|
47
47
|
---
|
|
48
48
|
@module Transition
|
|
49
|
+
@tsProps
|
|
49
50
|
**/
|
|
50
51
|
let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_temp = _class2 = class Transition extends Component {
|
|
51
52
|
constructor(...args) {
|
|
@@ -84,23 +85,21 @@ let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
render() {
|
|
87
|
-
var _styles$classNames, _styles$classNames2, _styles$classNames3, _styles$classNames4, _styles$classNames5;
|
|
88
|
-
|
|
89
88
|
const _this$props3 = this.props,
|
|
90
89
|
type = _this$props3.type,
|
|
91
90
|
children = _this$props3.children,
|
|
92
91
|
styles = _this$props3.styles,
|
|
93
92
|
props = _objectWithoutProperties(_this$props3, _excluded);
|
|
94
93
|
|
|
95
|
-
const duration = ms(styles
|
|
94
|
+
const duration = ms(styles.duration);
|
|
96
95
|
return jsx(React.Fragment, null, this.renderTransitionHelper(), jsx(BaseTransition, Object.assign({}, props, {
|
|
97
96
|
enterDelay: duration,
|
|
98
97
|
exitDelay: duration,
|
|
99
|
-
transitionClassName: styles
|
|
100
|
-
exitedClassName: styles
|
|
101
|
-
exitingClassName: styles
|
|
102
|
-
enteredClassName: styles
|
|
103
|
-
enteringClassName: styles
|
|
98
|
+
transitionClassName: styles.classNames.transitioning,
|
|
99
|
+
exitedClassName: styles.classNames.exited,
|
|
100
|
+
exitingClassName: styles.classNames.exiting,
|
|
101
|
+
enteredClassName: styles.classNames.entered,
|
|
102
|
+
enteringClassName: styles.classNames.entering,
|
|
104
103
|
onEntered: this.handleEntered,
|
|
105
104
|
onExited: this.handleExited
|
|
106
105
|
}), children));
|
|
@@ -112,15 +111,7 @@ let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
112
111
|
unmountOnExit: false,
|
|
113
112
|
transitionOnMount: false,
|
|
114
113
|
transitionEnter: true,
|
|
115
|
-
transitionExit: true
|
|
116
|
-
onEnter: function () {},
|
|
117
|
-
onEntering: function () {},
|
|
118
|
-
onEntered: function () {},
|
|
119
|
-
onExit: function () {},
|
|
120
|
-
onExiting: function () {},
|
|
121
|
-
onExited: function () {},
|
|
122
|
-
onTransition: function (toState, fromState) {},
|
|
123
|
-
children: null
|
|
114
|
+
transitionExit: true
|
|
124
115
|
}, _class2.states = BaseTransition.states, _temp)) || _class) || _class);
|
|
125
116
|
export default Transition;
|
|
126
117
|
export { Transition };
|
package/es/Transition/props.js
CHANGED
|
@@ -22,75 +22,12 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
|
-
|
|
25
|
+
import { transitionCommonPropTypes } from './BaseTransition/props';
|
|
26
|
+
const transitionTypes = ['fade', 'scale', 'slide-down', 'slide-up', 'slide-left', 'slide-right'];
|
|
27
|
+
const transitionTypePropType = PropTypes.oneOf(transitionTypes);
|
|
26
28
|
const propTypes = {
|
|
27
29
|
type: transitionTypePropType,
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* A single element to animate in and out
|
|
31
|
-
*/
|
|
32
|
-
children: PropTypes.element,
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Show the component; triggers the enter or exit animation
|
|
36
|
-
*/
|
|
37
|
-
in: PropTypes.bool,
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Unmount the component (remove it from the DOM) when it is not shown
|
|
41
|
-
*/
|
|
42
|
-
unmountOnExit: PropTypes.bool,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Run the enter animation when the component mounts, if it is initially
|
|
46
|
-
* shown
|
|
47
|
-
*/
|
|
48
|
-
transitionOnMount: PropTypes.bool,
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Run the enter animation
|
|
52
|
-
*/
|
|
53
|
-
transitionEnter: PropTypes.bool,
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Run the exit animation
|
|
57
|
-
*/
|
|
58
|
-
transitionExit: PropTypes.bool,
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Callback fired when transitioning to the next state
|
|
62
|
-
*/
|
|
63
|
-
onTransition: PropTypes.func,
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Callback fired before the "entering" classes are applied
|
|
67
|
-
*/
|
|
68
|
-
onEnter: PropTypes.func,
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Callback fired after the "entering" classes are applied
|
|
72
|
-
*/
|
|
73
|
-
onEntering: PropTypes.func,
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Callback fired after the "enter" classes are applied
|
|
77
|
-
*/
|
|
78
|
-
onEntered: PropTypes.func,
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Callback fired before the "exiting" classes are applied
|
|
82
|
-
*/
|
|
83
|
-
onExit: PropTypes.func,
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Callback fired after the "exiting" classes are applied
|
|
87
|
-
*/
|
|
88
|
-
onExiting: PropTypes.func,
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Callback fired after the "exited" classes are applied
|
|
92
|
-
*/
|
|
93
|
-
onExited: PropTypes.func
|
|
30
|
+
...transitionCommonPropTypes
|
|
94
31
|
};
|
|
95
32
|
const allowedProps = ['type', 'children', 'in', 'unmountOnExit', 'transitionOnMount', 'transitionEnter', 'transitionExit', 'onTransition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited'];
|
|
96
33
|
export { propTypes, allowedProps, transitionTypePropType };
|
package/es/Transition/styles.js
CHANGED
|
@@ -21,7 +21,13 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
const getClassNames = type => ({
|
|
25
|
+
transitioning: `transition--${type}-transitioning`,
|
|
26
|
+
exited: `transition--${type}-exited`,
|
|
27
|
+
exiting: `transition--${type}-exiting`,
|
|
28
|
+
entered: `transition--${type}-entered`,
|
|
29
|
+
entering: `transition--${type}-entering`
|
|
30
|
+
});
|
|
25
31
|
/**
|
|
26
32
|
* ---
|
|
27
33
|
* private: true
|
|
@@ -32,6 +38,8 @@
|
|
|
32
38
|
* @param {Object} state the state of the component, the style is applied to
|
|
33
39
|
* @return {Object} The final style object, which will be used in the component
|
|
34
40
|
*/
|
|
41
|
+
|
|
42
|
+
|
|
35
43
|
const generateStyle = (componentTheme, props) => {
|
|
36
44
|
const type = props.type;
|
|
37
45
|
/**
|
|
@@ -130,13 +138,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
130
138
|
};
|
|
131
139
|
return {
|
|
132
140
|
duration: componentTheme.duration,
|
|
133
|
-
classNames: type
|
|
134
|
-
transitioning: `transition--${type}-transitioning`,
|
|
135
|
-
exited: `transition--${type}-exited`,
|
|
136
|
-
exiting: `transition--${type}-exiting`,
|
|
137
|
-
entered: `transition--${type}-entered`,
|
|
138
|
-
entering: `transition--${type}-entering`
|
|
139
|
-
} : {},
|
|
141
|
+
classNames: getClassNames(type),
|
|
140
142
|
globalStyles: { ...fadeAnimation,
|
|
141
143
|
...scaleAnimation,
|
|
142
144
|
...slideAnimation
|
|
@@ -144,4 +146,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
144
146
|
};
|
|
145
147
|
};
|
|
146
148
|
|
|
149
|
+
export { generateStyle, getClassNames };
|
|
147
150
|
export default generateStyle;
|
package/es/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -58,6 +58,7 @@ class BaseTransition extends _react.default.Component {
|
|
|
58
58
|
constructor(...args) {
|
|
59
59
|
super(...args);
|
|
60
60
|
this._timeouts = [];
|
|
61
|
+
this._unmounted = false;
|
|
61
62
|
this.state = {
|
|
62
63
|
transitioning: false
|
|
63
64
|
};
|
|
@@ -76,6 +77,7 @@ class BaseTransition extends _react.default.Component {
|
|
|
76
77
|
|
|
77
78
|
this.transition = (toState, fromState, transitionCallback, transitionDuration = 0) => {
|
|
78
79
|
if (this._unmounted) return;
|
|
80
|
+
const onTransition = this.props.onTransition;
|
|
79
81
|
const classList = (0, _getClassList.getClassList)(this);
|
|
80
82
|
const transitionClassName = this.getTransitionClassName(toState);
|
|
81
83
|
const prevTransitionClassName = this.getTransitionClassName(fromState);
|
|
@@ -95,8 +97,8 @@ class BaseTransition extends _react.default.Component {
|
|
|
95
97
|
classList.add(transitionClassName);
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
if (toState && fromState) {
|
|
99
|
-
|
|
100
|
+
if (toState && fromState && typeof onTransition === 'function') {
|
|
101
|
+
onTransition(toState, fromState);
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
this._timeouts.push(setTimeout(() => {
|
|
@@ -111,19 +113,27 @@ class BaseTransition extends _react.default.Component {
|
|
|
111
113
|
this.enter = initialState => {
|
|
112
114
|
if (this.state.transitioning || this._unmounted) return;
|
|
113
115
|
const props = this.props;
|
|
114
|
-
|
|
116
|
+
|
|
117
|
+
if (typeof props.onEnter === 'function') {
|
|
118
|
+
props.onEnter();
|
|
119
|
+
}
|
|
115
120
|
|
|
116
121
|
if (props.transitionEnter) {
|
|
117
122
|
this.setState({
|
|
118
123
|
transitioning: true
|
|
119
124
|
}, () => {
|
|
120
125
|
const enter = () => {
|
|
121
|
-
props.onEntering
|
|
126
|
+
if (typeof props.onEntering === 'function') {
|
|
127
|
+
props.onEntering();
|
|
128
|
+
}
|
|
129
|
+
|
|
122
130
|
this.transition(STATES.ENTERED, STATES.ENTERING, () => {
|
|
123
131
|
this.setState({
|
|
124
132
|
transitioning: false
|
|
125
133
|
}, () => {
|
|
126
|
-
props.onEntered
|
|
134
|
+
if (typeof props.onEntered === 'function') {
|
|
135
|
+
props.onEntered();
|
|
136
|
+
}
|
|
127
137
|
});
|
|
128
138
|
});
|
|
129
139
|
};
|
|
@@ -141,7 +151,10 @@ class BaseTransition extends _react.default.Component {
|
|
|
141
151
|
transitioning: false
|
|
142
152
|
}, () => {
|
|
143
153
|
this.transition(STATES.ENTERED, STATES.EXITED);
|
|
144
|
-
|
|
154
|
+
|
|
155
|
+
if (typeof props.onEntered === 'function') {
|
|
156
|
+
props.onEntered();
|
|
157
|
+
}
|
|
145
158
|
});
|
|
146
159
|
}
|
|
147
160
|
};
|
|
@@ -149,19 +162,27 @@ class BaseTransition extends _react.default.Component {
|
|
|
149
162
|
this.exit = initialState => {
|
|
150
163
|
if (this.state.transitioning) return;
|
|
151
164
|
const props = this.props;
|
|
152
|
-
|
|
165
|
+
|
|
166
|
+
if (typeof props.onExit === 'function') {
|
|
167
|
+
props.onExit();
|
|
168
|
+
}
|
|
153
169
|
|
|
154
170
|
if (props.transitionExit) {
|
|
155
171
|
this.setState({
|
|
156
172
|
transitioning: true
|
|
157
173
|
}, () => {
|
|
158
174
|
const exit = () => {
|
|
159
|
-
props.onExiting
|
|
175
|
+
if (typeof props.onExiting === 'function') {
|
|
176
|
+
props.onExiting();
|
|
177
|
+
}
|
|
178
|
+
|
|
160
179
|
this.transition(STATES.EXITED, STATES.EXITING, () => {
|
|
161
180
|
this.setState({
|
|
162
181
|
transitioning: false
|
|
163
182
|
}, () => {
|
|
164
|
-
props.onExited
|
|
183
|
+
if (typeof props.onExited === 'function') {
|
|
184
|
+
props.onExited();
|
|
185
|
+
}
|
|
165
186
|
});
|
|
166
187
|
});
|
|
167
188
|
};
|
|
@@ -179,7 +200,10 @@ class BaseTransition extends _react.default.Component {
|
|
|
179
200
|
transitioning: false
|
|
180
201
|
}, () => {
|
|
181
202
|
this.transition(STATES.EXITED, STATES.ENTERED);
|
|
182
|
-
|
|
203
|
+
|
|
204
|
+
if (typeof props.onExited === 'function') {
|
|
205
|
+
props.onExited();
|
|
206
|
+
}
|
|
183
207
|
});
|
|
184
208
|
}
|
|
185
209
|
};
|
|
@@ -200,7 +224,7 @@ class BaseTransition extends _react.default.Component {
|
|
|
200
224
|
return null;
|
|
201
225
|
}
|
|
202
226
|
|
|
203
|
-
componentDidUpdate(prevProps,
|
|
227
|
+
componentDidUpdate(prevProps, _prevState, cancelPrematurely) {
|
|
204
228
|
if (cancelPrematurely) {
|
|
205
229
|
this.clearTransition(prevProps.transitionClassName);
|
|
206
230
|
}
|
|
@@ -229,8 +253,12 @@ class BaseTransition extends _react.default.Component {
|
|
|
229
253
|
}, () => {
|
|
230
254
|
if (this._unmounted) return;
|
|
231
255
|
const classList = (0, _getClassList.getClassList)(this);
|
|
232
|
-
Object.
|
|
233
|
-
|
|
256
|
+
Object.values(STATES).forEach(state => {
|
|
257
|
+
const className = this.getTransitionClassName(state);
|
|
258
|
+
|
|
259
|
+
if (className) {
|
|
260
|
+
classList.remove(className);
|
|
261
|
+
}
|
|
234
262
|
});
|
|
235
263
|
classList.remove(transitionClassName);
|
|
236
264
|
});
|
|
@@ -270,15 +298,15 @@ class BaseTransition extends _react.default.Component {
|
|
|
270
298
|
return props.exitingClassName;
|
|
271
299
|
|
|
272
300
|
default:
|
|
273
|
-
return
|
|
301
|
+
return void 0;
|
|
274
302
|
}
|
|
275
303
|
}
|
|
276
304
|
|
|
277
305
|
renderChildren() {
|
|
278
|
-
return (0, _safeCloneElement.safeCloneElement)((0, _ensureSingleChild.ensureSingleChild)(this.props.children), {
|
|
279
|
-
'aria-hidden': !this.props.in ? true :
|
|
306
|
+
return this.props.children ? (0, _safeCloneElement.safeCloneElement)((0, _ensureSingleChild.ensureSingleChild)(this.props.children), {
|
|
307
|
+
'aria-hidden': !this.props.in ? true : void 0,
|
|
280
308
|
ref: this.ref
|
|
281
|
-
});
|
|
309
|
+
}) : null;
|
|
282
310
|
}
|
|
283
311
|
|
|
284
312
|
render() {
|
|
@@ -297,21 +325,12 @@ BaseTransition.propTypes = _props.propTypes;
|
|
|
297
325
|
BaseTransition.allowedProps = _props.allowedProps;
|
|
298
326
|
BaseTransition.defaultProps = {
|
|
299
327
|
in: false,
|
|
300
|
-
component: 'div',
|
|
301
328
|
unmountOnExit: false,
|
|
302
329
|
transitionOnMount: false,
|
|
303
330
|
transitionEnter: true,
|
|
304
331
|
transitionExit: true,
|
|
305
332
|
enterDelay: 300,
|
|
306
|
-
exitDelay: 300
|
|
307
|
-
onEnter: function () {},
|
|
308
|
-
onEntering: function () {},
|
|
309
|
-
onEntered: function () {},
|
|
310
|
-
onExit: function () {},
|
|
311
|
-
onExiting: function () {},
|
|
312
|
-
onExited: function () {},
|
|
313
|
-
onTransition: function () {},
|
|
314
|
-
children: null
|
|
333
|
+
exitDelay: 300
|
|
315
334
|
};
|
|
316
335
|
BaseTransition.states = STATES;
|
|
317
336
|
var _default = BaseTransition;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.allowedProps = exports.propTypes = void 0;
|
|
8
|
+
exports.transitionCommonPropTypes = exports.allowedProps = exports.propTypes = void 0;
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
@@ -32,19 +32,12 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
32
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
33
|
* SOFTWARE.
|
|
34
34
|
*/
|
|
35
|
-
const
|
|
35
|
+
const transitionCommonPropTypes = {
|
|
36
36
|
in: _propTypes.default.bool,
|
|
37
37
|
unmountOnExit: _propTypes.default.bool,
|
|
38
38
|
transitionOnMount: _propTypes.default.bool,
|
|
39
39
|
transitionEnter: _propTypes.default.bool,
|
|
40
40
|
transitionExit: _propTypes.default.bool,
|
|
41
|
-
enterDelay: _propTypes.default.number,
|
|
42
|
-
exitDelay: _propTypes.default.number,
|
|
43
|
-
transitionClassName: _propTypes.default.string,
|
|
44
|
-
exitedClassName: _propTypes.default.string,
|
|
45
|
-
exitingClassName: _propTypes.default.string,
|
|
46
|
-
enteredClassName: _propTypes.default.string,
|
|
47
|
-
enteringClassName: _propTypes.default.string,
|
|
48
41
|
onTransition: _propTypes.default.func,
|
|
49
42
|
onEnter: _propTypes.default.func,
|
|
50
43
|
onEntering: _propTypes.default.func,
|
|
@@ -52,7 +45,17 @@ const propTypes = {
|
|
|
52
45
|
onExit: _propTypes.default.func,
|
|
53
46
|
onExiting: _propTypes.default.func,
|
|
54
47
|
onExited: _propTypes.default.func,
|
|
55
|
-
children: _propTypes.default.node
|
|
48
|
+
children: _propTypes.default.node
|
|
49
|
+
};
|
|
50
|
+
exports.transitionCommonPropTypes = transitionCommonPropTypes;
|
|
51
|
+
const propTypes = { ...transitionCommonPropTypes,
|
|
52
|
+
enterDelay: _propTypes.default.number,
|
|
53
|
+
exitDelay: _propTypes.default.number,
|
|
54
|
+
transitionClassName: _propTypes.default.string.isRequired,
|
|
55
|
+
exitedClassName: _propTypes.default.string.isRequired,
|
|
56
|
+
exitingClassName: _propTypes.default.string.isRequired,
|
|
57
|
+
enteredClassName: _propTypes.default.string.isRequired,
|
|
58
|
+
enteringClassName: _propTypes.default.string.isRequired,
|
|
56
59
|
className: _propTypes.default.string
|
|
57
60
|
};
|
|
58
61
|
exports.propTypes = propTypes;
|