@instructure/ui-motion 8.25.1-snapshot-7 → 8.25.1-snapshot-10
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 +1 -1
- package/es/Transition/BaseTransition/index.js +171 -176
- package/es/Transition/index.js +47 -42
- package/lib/Transition/BaseTransition/index.js +171 -176
- package/lib/Transition/index.js +47 -42
- package/package.json +11 -11
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Transition/BaseTransition/index.d.ts +1 -1
- package/types/Transition/BaseTransition/index.d.ts.map +1 -1
- package/types/Transition/TransitionLocator.d.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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.25.1-snapshot-
|
|
6
|
+
## [8.25.1-snapshot-10](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-10) (2022-06-20)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-motion
|
|
9
9
|
|
|
@@ -40,40 +40,84 @@ private: true
|
|
|
40
40
|
**/
|
|
41
41
|
|
|
42
42
|
class BaseTransition extends React.Component {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
static displayName = "BaseTransition";
|
|
44
|
+
static propTypes = propTypes;
|
|
45
|
+
static allowedProps = allowedProps;
|
|
46
|
+
static defaultProps = {
|
|
47
|
+
in: false,
|
|
48
|
+
unmountOnExit: false,
|
|
49
|
+
transitionOnMount: false,
|
|
50
|
+
transitionEnter: true,
|
|
51
|
+
transitionExit: true,
|
|
52
|
+
enterDelay: 300,
|
|
53
|
+
exitDelay: 300
|
|
54
|
+
};
|
|
55
|
+
static states = STATES;
|
|
56
|
+
_timeouts = [];
|
|
57
|
+
_unmounted = false;
|
|
58
|
+
state = {
|
|
59
|
+
transitioning: false
|
|
60
|
+
};
|
|
61
|
+
ref = null;
|
|
62
|
+
handleRef = el => {
|
|
63
|
+
const elementRef = this.props.elementRef;
|
|
64
|
+
this.ref = el;
|
|
65
|
+
|
|
66
|
+
if (typeof elementRef === 'function') {
|
|
67
|
+
elementRef(el);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
54
70
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
componentDidMount() {
|
|
72
|
+
this.startTransition(this.props.in, this.props.transitionOnMount);
|
|
73
|
+
}
|
|
58
74
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
75
|
+
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
76
|
+
if (this.props.in !== prevProps.in && prevState.transitioning) {
|
|
77
|
+
// direction changed before previous transition finished
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
63
80
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
transitionEnter = _this$props.transitionEnter,
|
|
67
|
-
transitionExit = _this$props.transitionExit;
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
68
83
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
componentDidUpdate(prevProps, _prevState, cancelPrematurely) {
|
|
85
|
+
if (cancelPrematurely) {
|
|
86
|
+
this.clearTransition(prevProps.transitionClassName);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.props.transitionClassName !== prevProps.transitionClassName) {
|
|
90
|
+
this.clearTransition(prevProps.transitionClassName);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (prevProps.in !== this.props.in) {
|
|
94
|
+
this.startTransition(this.props.in, true);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
componentWillUnmount() {
|
|
99
|
+
this._timeouts.forEach(timeout => {
|
|
100
|
+
clearTimeout(timeout);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
this._unmounted = true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
startTransition = (transitionIn, transitionOnStart) => {
|
|
107
|
+
const _this$props = this.props,
|
|
108
|
+
transitionEnter = _this$props.transitionEnter,
|
|
109
|
+
transitionExit = _this$props.transitionExit;
|
|
110
|
+
|
|
111
|
+
if (transitionIn) {
|
|
112
|
+
this.enter(transitionEnter && transitionOnStart ? STATES.EXITED : null);
|
|
113
|
+
} else {
|
|
114
|
+
this.exit(transitionExit && transitionOnStart ? STATES.ENTERED : null);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
transition = (() => {
|
|
118
|
+
var _this = this;
|
|
75
119
|
|
|
76
|
-
|
|
120
|
+
return function (toState, fromState, transitionCallback) {
|
|
77
121
|
let transitionDuration = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
|
|
78
122
|
if (_this._unmounted) return;
|
|
79
123
|
const onTransition = _this.props.onTransition;
|
|
@@ -111,140 +155,7 @@ class BaseTransition extends React.Component {
|
|
|
111
155
|
}
|
|
112
156
|
}, transitionDuration));
|
|
113
157
|
};
|
|
114
|
-
|
|
115
|
-
this.enter = initialState => {
|
|
116
|
-
if (this.state.transitioning || this._unmounted) return;
|
|
117
|
-
const props = this.props;
|
|
118
|
-
|
|
119
|
-
if (typeof props.onEnter === 'function') {
|
|
120
|
-
props.onEnter();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (props.transitionEnter) {
|
|
124
|
-
this.setState({
|
|
125
|
-
transitioning: true
|
|
126
|
-
}, () => {
|
|
127
|
-
const enter = () => {
|
|
128
|
-
if (typeof props.onEntering === 'function') {
|
|
129
|
-
props.onEntering();
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
this.transition(STATES.ENTERED, STATES.ENTERING, () => {
|
|
133
|
-
this.setState({
|
|
134
|
-
transitioning: false
|
|
135
|
-
}, () => {
|
|
136
|
-
if (typeof props.onEntered === 'function') {
|
|
137
|
-
props.onEntered();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
if (initialState) {
|
|
144
|
-
this.transition(initialState, null, () => {
|
|
145
|
-
this.transition(STATES.ENTERING, initialState, enter, props.enterDelay);
|
|
146
|
-
});
|
|
147
|
-
} else {
|
|
148
|
-
enter();
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
this.setState({
|
|
153
|
-
transitioning: false
|
|
154
|
-
}, () => {
|
|
155
|
-
this.transition(STATES.ENTERED, STATES.EXITED);
|
|
156
|
-
|
|
157
|
-
if (typeof props.onEntered === 'function') {
|
|
158
|
-
props.onEntered();
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
this.exit = initialState => {
|
|
165
|
-
if (this.state.transitioning) return;
|
|
166
|
-
const props = this.props;
|
|
167
|
-
|
|
168
|
-
if (typeof props.onExit === 'function') {
|
|
169
|
-
props.onExit();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (props.transitionExit) {
|
|
173
|
-
this.setState({
|
|
174
|
-
transitioning: true
|
|
175
|
-
}, () => {
|
|
176
|
-
const exit = () => {
|
|
177
|
-
if (typeof props.onExiting === 'function') {
|
|
178
|
-
props.onExiting();
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
this.transition(STATES.EXITED, STATES.EXITING, () => {
|
|
182
|
-
this.setState({
|
|
183
|
-
transitioning: false
|
|
184
|
-
}, () => {
|
|
185
|
-
if (typeof props.onExited === 'function') {
|
|
186
|
-
props.onExited();
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
if (initialState) {
|
|
193
|
-
this.transition(initialState, null, () => {
|
|
194
|
-
this.transition(STATES.EXITING, initialState, exit, props.exitDelay);
|
|
195
|
-
});
|
|
196
|
-
} else {
|
|
197
|
-
exit();
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
} else {
|
|
201
|
-
this.setState({
|
|
202
|
-
transitioning: false
|
|
203
|
-
}, () => {
|
|
204
|
-
this.transition(STATES.EXITED, STATES.ENTERED);
|
|
205
|
-
|
|
206
|
-
if (typeof props.onExited === 'function') {
|
|
207
|
-
props.onExited();
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
componentDidMount() {
|
|
215
|
-
this.startTransition(this.props.in, this.props.transitionOnMount);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
219
|
-
if (this.props.in !== prevProps.in && prevState.transitioning) {
|
|
220
|
-
// direction changed before previous transition finished
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
componentDidUpdate(prevProps, _prevState, cancelPrematurely) {
|
|
228
|
-
if (cancelPrematurely) {
|
|
229
|
-
this.clearTransition(prevProps.transitionClassName);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (this.props.transitionClassName !== prevProps.transitionClassName) {
|
|
233
|
-
this.clearTransition(prevProps.transitionClassName);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (prevProps.in !== this.props.in) {
|
|
237
|
-
this.startTransition(this.props.in, true);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
componentWillUnmount() {
|
|
242
|
-
this._timeouts.forEach(timeout => {
|
|
243
|
-
clearTimeout(timeout);
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
this._unmounted = true;
|
|
247
|
-
}
|
|
158
|
+
})();
|
|
248
159
|
|
|
249
160
|
clearTransition(transitionClassName) {
|
|
250
161
|
if (this._unmounted) return;
|
|
@@ -264,6 +175,103 @@ class BaseTransition extends React.Component {
|
|
|
264
175
|
});
|
|
265
176
|
}
|
|
266
177
|
|
|
178
|
+
enter = initialState => {
|
|
179
|
+
if (this.state.transitioning || this._unmounted) return;
|
|
180
|
+
const props = this.props;
|
|
181
|
+
|
|
182
|
+
if (typeof props.onEnter === 'function') {
|
|
183
|
+
props.onEnter();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (props.transitionEnter) {
|
|
187
|
+
this.setState({
|
|
188
|
+
transitioning: true
|
|
189
|
+
}, () => {
|
|
190
|
+
const enter = () => {
|
|
191
|
+
if (typeof props.onEntering === 'function') {
|
|
192
|
+
props.onEntering();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
this.transition(STATES.ENTERED, STATES.ENTERING, () => {
|
|
196
|
+
this.setState({
|
|
197
|
+
transitioning: false
|
|
198
|
+
}, () => {
|
|
199
|
+
if (typeof props.onEntered === 'function') {
|
|
200
|
+
props.onEntered();
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
if (initialState) {
|
|
207
|
+
this.transition(initialState, null, () => {
|
|
208
|
+
this.transition(STATES.ENTERING, initialState, enter, props.enterDelay);
|
|
209
|
+
});
|
|
210
|
+
} else {
|
|
211
|
+
enter();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
} else {
|
|
215
|
+
this.setState({
|
|
216
|
+
transitioning: false
|
|
217
|
+
}, () => {
|
|
218
|
+
this.transition(STATES.ENTERED, STATES.EXITED);
|
|
219
|
+
|
|
220
|
+
if (typeof props.onEntered === 'function') {
|
|
221
|
+
props.onEntered();
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
exit = initialState => {
|
|
227
|
+
if (this.state.transitioning) return;
|
|
228
|
+
const props = this.props;
|
|
229
|
+
|
|
230
|
+
if (typeof props.onExit === 'function') {
|
|
231
|
+
props.onExit();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (props.transitionExit) {
|
|
235
|
+
this.setState({
|
|
236
|
+
transitioning: true
|
|
237
|
+
}, () => {
|
|
238
|
+
const exit = () => {
|
|
239
|
+
if (typeof props.onExiting === 'function') {
|
|
240
|
+
props.onExiting();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this.transition(STATES.EXITED, STATES.EXITING, () => {
|
|
244
|
+
this.setState({
|
|
245
|
+
transitioning: false
|
|
246
|
+
}, () => {
|
|
247
|
+
if (typeof props.onExited === 'function') {
|
|
248
|
+
props.onExited();
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
if (initialState) {
|
|
255
|
+
this.transition(initialState, null, () => {
|
|
256
|
+
this.transition(STATES.EXITING, initialState, exit, props.exitDelay);
|
|
257
|
+
});
|
|
258
|
+
} else {
|
|
259
|
+
exit();
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
} else {
|
|
263
|
+
this.setState({
|
|
264
|
+
transitioning: false
|
|
265
|
+
}, () => {
|
|
266
|
+
this.transition(STATES.EXITED, STATES.ENTERED);
|
|
267
|
+
|
|
268
|
+
if (typeof props.onExited === 'function') {
|
|
269
|
+
props.onExited();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
267
275
|
transitionEnabled(toState) {
|
|
268
276
|
const props = this.props;
|
|
269
277
|
|
|
@@ -322,18 +330,5 @@ class BaseTransition extends React.Component {
|
|
|
322
330
|
|
|
323
331
|
}
|
|
324
332
|
|
|
325
|
-
BaseTransition.displayName = "BaseTransition";
|
|
326
|
-
BaseTransition.propTypes = propTypes;
|
|
327
|
-
BaseTransition.allowedProps = allowedProps;
|
|
328
|
-
BaseTransition.defaultProps = {
|
|
329
|
-
in: false,
|
|
330
|
-
unmountOnExit: false,
|
|
331
|
-
transitionOnMount: false,
|
|
332
|
-
transitionEnter: true,
|
|
333
|
-
transitionExit: true,
|
|
334
|
-
enterDelay: 300,
|
|
335
|
-
exitDelay: 300
|
|
336
|
-
};
|
|
337
|
-
BaseTransition.states = STATES;
|
|
338
333
|
export default BaseTransition;
|
|
339
334
|
export { BaseTransition };
|
package/es/Transition/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
const _excluded = ["type", "children", "styles"];
|
|
3
3
|
|
|
4
|
-
var _dec, _dec2, _class
|
|
4
|
+
var _dec, _dec2, _class;
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* The MIT License (MIT)
|
|
@@ -48,39 +48,29 @@ category: components/utilities
|
|
|
48
48
|
@module Transition
|
|
49
49
|
@tsProps
|
|
50
50
|
**/
|
|
51
|
-
let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
this.renderTransitionHelper = () => {
|
|
78
|
-
const styles = this.props.styles;
|
|
79
|
-
return jsx(Global, {
|
|
80
|
-
styles: styles === null || styles === void 0 ? void 0 : styles.globalStyles
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
}
|
|
51
|
+
let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = class Transition extends Component {
|
|
52
|
+
static displayName = "Transition";
|
|
53
|
+
static componentId = 'Transition';
|
|
54
|
+
static allowedProps = allowedProps;
|
|
55
|
+
static propTypes = propTypes;
|
|
56
|
+
static defaultProps = {
|
|
57
|
+
type: 'fade',
|
|
58
|
+
in: false,
|
|
59
|
+
unmountOnExit: false,
|
|
60
|
+
transitionOnMount: false,
|
|
61
|
+
transitionEnter: true,
|
|
62
|
+
transitionExit: true
|
|
63
|
+
};
|
|
64
|
+
static states = BaseTransition.states;
|
|
65
|
+
ref = null;
|
|
66
|
+
handleRef = el => {
|
|
67
|
+
const elementRef = this.props.elementRef;
|
|
68
|
+
this.ref = el;
|
|
69
|
+
|
|
70
|
+
if (typeof elementRef === 'function') {
|
|
71
|
+
elementRef(el);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
84
74
|
|
|
85
75
|
componentDidMount() {
|
|
86
76
|
var _this$props$makeStyle, _this$props;
|
|
@@ -94,6 +84,28 @@ let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
94
84
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
95
85
|
}
|
|
96
86
|
|
|
87
|
+
handleExited = () => {
|
|
88
|
+
if (typeof this.props.onExited === 'function') {
|
|
89
|
+
this.props.onExited(this.props.type);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
handleEntered = () => {
|
|
93
|
+
if (typeof this.props.onEntered === 'function') {
|
|
94
|
+
this.props.onEntered(this.props.type);
|
|
95
|
+
}
|
|
96
|
+
}; // Transition helper:
|
|
97
|
+
// After emotion migration the only way to keep
|
|
98
|
+
// the old BaseTransition functionality with adding and removing
|
|
99
|
+
// classes was to add the `Global` helper of `emotion`
|
|
100
|
+
// Todo: try to refactor or replace Transition/BaseTransition component in v9.0.0. so that it is not class based
|
|
101
|
+
|
|
102
|
+
renderTransitionHelper = () => {
|
|
103
|
+
const styles = this.props.styles;
|
|
104
|
+
return jsx(Global, {
|
|
105
|
+
styles: styles === null || styles === void 0 ? void 0 : styles.globalStyles
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
97
109
|
render() {
|
|
98
110
|
const _this$props3 = this.props,
|
|
99
111
|
type = _this$props3.type,
|
|
@@ -116,13 +128,6 @@ let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
116
128
|
}), children));
|
|
117
129
|
}
|
|
118
130
|
|
|
119
|
-
}
|
|
120
|
-
type: 'fade',
|
|
121
|
-
in: false,
|
|
122
|
-
unmountOnExit: false,
|
|
123
|
-
transitionOnMount: false,
|
|
124
|
-
transitionEnter: true,
|
|
125
|
-
transitionExit: true
|
|
126
|
-
}, _class2.states = BaseTransition.states, _class2)) || _class) || _class);
|
|
131
|
+
}) || _class) || _class);
|
|
127
132
|
export default Transition;
|
|
128
133
|
export { Transition };
|