@instructure/ui-motion 8.25.1-snapshot-10 → 8.25.1-snapshot-15
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 +176 -171
- package/es/Transition/index.js +42 -47
- package/lib/Transition/BaseTransition/index.js +176 -171
- package/lib/Transition/index.js +42 -47
- package/package.json +11 -11
- package/src/index.ts +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
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-15](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-15) (2022-06-23)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-motion
|
|
9
9
|
|
|
@@ -40,84 +40,40 @@ private: true
|
|
|
40
40
|
**/
|
|
41
41
|
|
|
42
42
|
class BaseTransition extends React.Component {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
};
|
|
70
|
-
|
|
71
|
-
componentDidMount() {
|
|
72
|
-
this.startTransition(this.props.in, this.props.transitionOnMount);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
getSnapshotBeforeUpdate(prevProps, prevState) {
|
|
76
|
-
if (this.props.in !== prevProps.in && prevState.transitioning) {
|
|
77
|
-
// direction changed before previous transition finished
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
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
|
-
}
|
|
43
|
+
constructor() {
|
|
44
|
+
var _this;
|
|
45
|
+
|
|
46
|
+
super(...arguments);
|
|
47
|
+
_this = this;
|
|
48
|
+
this._timeouts = [];
|
|
49
|
+
this._unmounted = false;
|
|
50
|
+
this.state = {
|
|
51
|
+
transitioning: false
|
|
52
|
+
};
|
|
53
|
+
this.ref = null;
|
|
97
54
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
55
|
+
this.handleRef = el => {
|
|
56
|
+
const elementRef = this.props.elementRef;
|
|
57
|
+
this.ref = el;
|
|
102
58
|
|
|
103
|
-
|
|
104
|
-
|
|
59
|
+
if (typeof elementRef === 'function') {
|
|
60
|
+
elementRef(el);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
105
63
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
64
|
+
this.startTransition = (transitionIn, transitionOnStart) => {
|
|
65
|
+
const _this$props = this.props,
|
|
66
|
+
transitionEnter = _this$props.transitionEnter,
|
|
67
|
+
transitionExit = _this$props.transitionExit;
|
|
110
68
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
transition = (() => {
|
|
118
|
-
var _this = this;
|
|
69
|
+
if (transitionIn) {
|
|
70
|
+
this.enter(transitionEnter && transitionOnStart ? STATES.EXITED : null);
|
|
71
|
+
} else {
|
|
72
|
+
this.exit(transitionExit && transitionOnStart ? STATES.ENTERED : null);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
119
75
|
|
|
120
|
-
|
|
76
|
+
this.transition = function (toState, fromState, transitionCallback) {
|
|
121
77
|
let transitionDuration = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0;
|
|
122
78
|
if (_this._unmounted) return;
|
|
123
79
|
const onTransition = _this.props.onTransition;
|
|
@@ -155,7 +111,140 @@ class BaseTransition extends React.Component {
|
|
|
155
111
|
}
|
|
156
112
|
}, transitionDuration));
|
|
157
113
|
};
|
|
158
|
-
|
|
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
|
+
}
|
|
159
248
|
|
|
160
249
|
clearTransition(transitionClassName) {
|
|
161
250
|
if (this._unmounted) return;
|
|
@@ -175,103 +264,6 @@ class BaseTransition extends React.Component {
|
|
|
175
264
|
});
|
|
176
265
|
}
|
|
177
266
|
|
|
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
|
-
|
|
275
267
|
transitionEnabled(toState) {
|
|
276
268
|
const props = this.props;
|
|
277
269
|
|
|
@@ -330,5 +322,18 @@ class BaseTransition extends React.Component {
|
|
|
330
322
|
|
|
331
323
|
}
|
|
332
324
|
|
|
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;
|
|
333
338
|
export default BaseTransition;
|
|
334
339
|
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, _class2;
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* The MIT License (MIT)
|
|
@@ -48,29 +48,39 @@ 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 = class Transition extends Component {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
51
|
+
let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class Transition extends Component {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
this.ref = null;
|
|
55
|
+
|
|
56
|
+
this.handleRef = el => {
|
|
57
|
+
const elementRef = this.props.elementRef;
|
|
58
|
+
this.ref = el;
|
|
59
|
+
|
|
60
|
+
if (typeof elementRef === 'function') {
|
|
61
|
+
elementRef(el);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
this.handleExited = () => {
|
|
66
|
+
if (typeof this.props.onExited === 'function') {
|
|
67
|
+
this.props.onExited(this.props.type);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
this.handleEntered = () => {
|
|
72
|
+
if (typeof this.props.onEntered === 'function') {
|
|
73
|
+
this.props.onEntered(this.props.type);
|
|
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
|
+
}
|
|
74
84
|
|
|
75
85
|
componentDidMount() {
|
|
76
86
|
var _this$props$makeStyle, _this$props;
|
|
@@ -84,28 +94,6 @@ let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
84
94
|
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
|
|
85
95
|
}
|
|
86
96
|
|
|
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
|
-
|
|
109
97
|
render() {
|
|
110
98
|
const _this$props3 = this.props,
|
|
111
99
|
type = _this$props3.type,
|
|
@@ -128,6 +116,13 @@ let Transition = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
128
116
|
}), children));
|
|
129
117
|
}
|
|
130
118
|
|
|
131
|
-
}
|
|
119
|
+
}, _class2.displayName = "Transition", _class2.componentId = 'Transition', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
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);
|
|
132
127
|
export default Transition;
|
|
133
128
|
export { Transition };
|