@instructure/ui-motion 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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 CHANGED
@@ -3,6 +3,19 @@
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
+ ## [11.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
7
+
8
+ ### Build System
9
+
10
+ * **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * **many:** `@instructure/ui-babel-preset` and
15
+ `@instructure/browserslist-config-instui` are removed and will no longer be
16
+ published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
17
+
18
+
6
19
  ## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
7
20
 
8
21
  **Note:** Version bump only for package @instructure/ui-motion
@@ -1,322 +1,269 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
1
  import { Component } from 'react';
26
2
  import { getClassList, findDOMNode } from '@instructure/ui-dom-utils';
27
3
  import { ensureSingleChild, safeCloneElement } from '@instructure/ui-react-utils';
28
4
  import { createChainedFunction } from '@instructure/ui-utils';
29
5
  import { allowedProps } from './props.js';
30
6
  const STATES = {
31
- EXITED: -2,
32
- EXITING: -1,
33
- ENTERING: 1,
34
- ENTERED: 2
7
+ EXITED: -2,
8
+ EXITING: -1,
9
+ ENTERING: 1,
10
+ ENTERED: 2
35
11
  };
36
-
37
- /**
38
- ---
39
- private: true
40
- ---
41
- Note: this is forked from https://github.com/react-bootstrap/react-overlays/blob/master/src/Transition.js
42
- so that it works with css modules. The internals are pretty different now, but it has roughly the same api.
43
- **/
44
12
  class BaseTransition extends Component {
45
- static displayName = 'BaseTransition';
46
- static allowedProps = allowedProps;
47
- static defaultProps = {
48
- in: false,
49
- unmountOnExit: false,
50
- transitionOnMount: false,
51
- transitionEnter: true,
52
- transitionExit: true,
53
- enterDelay: 300,
54
- exitDelay: 300
55
- };
56
- static states = STATES;
57
- _timeouts = [];
58
- _unmounted = false;
59
- state = {
60
- transitioning: false
61
- };
62
- ref = null;
63
- handleRef = el => {
64
- const {
65
- elementRef
66
- } = this.props;
67
- this.ref = el;
68
- if (typeof elementRef === 'function') {
69
- elementRef(el);
13
+ static{
14
+ this.displayName = 'BaseTransition';
70
15
  }
71
- };
72
- componentDidMount() {
73
- this.startTransition(this.props.in, this.props.transitionOnMount);
74
- this._unmounted = false;
75
- }
76
- getSnapshotBeforeUpdate(prevProps, prevState) {
77
- if (this.props.in !== prevProps.in && prevState.transitioning) {
78
- // direction changed before previous transition finished
79
- return true;
16
+ static{
17
+ this.allowedProps = allowedProps;
80
18
  }
81
- return null;
82
- }
83
- componentDidUpdate(prevProps, _prevState, cancelPrematurely) {
84
- if (cancelPrematurely) {
85
- this.clearTransition(prevProps.transitionClassName);
86
- }
87
- if (this.props.transitionClassName !== prevProps.transitionClassName) {
88
- this.clearTransition(prevProps.transitionClassName);
89
- }
90
- if (prevProps.in !== this.props.in) {
91
- if (_prevState.transitioning) {
92
- this.clearTransition(prevProps.transitionClassName);
93
- clearTimeout(this._timeouts.pop());
94
- this.setState({
95
- transitioning: false
96
- }, () => this.startTransition(this.props.in, true));
97
- } else this.startTransition(this.props.in, true);
98
- }
99
- }
100
- componentWillUnmount() {
101
- this._timeouts.forEach(timeout => {
102
- clearTimeout(timeout);
103
- });
104
- this._unmounted = true;
105
- }
106
- startTransition = (transitionIn, transitionOnStart) => {
107
- const {
108
- transitionEnter,
109
- transitionExit
110
- } = this.props;
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 = (toState, fromState, transitionCallback, transitionDuration = 0) => {
118
- if (this._unmounted) return;
119
- const {
120
- onTransition
121
- } = this.props;
122
- const classList = getClassList(this.ref);
123
- const transitionClassName = this.getTransitionClassName(toState);
124
- const prevTransitionClassName = this.getTransitionClassName(fromState);
125
- const baseTransitionClassName = this.props.transitionClassName;
126
- if (fromState && transitionDuration && this.transitionEnabled(toState)) {
127
- baseTransitionClassName && classList.add(baseTransitionClassName);
128
- } else {
129
- baseTransitionClassName && classList.remove(baseTransitionClassName);
130
- }
131
- if (prevTransitionClassName) {
132
- classList.remove(prevTransitionClassName);
19
+ static{
20
+ this.defaultProps = {
21
+ in: false,
22
+ unmountOnExit: false,
23
+ transitionOnMount: false,
24
+ transitionEnter: true,
25
+ transitionExit: true,
26
+ enterDelay: 300,
27
+ exitDelay: 300
28
+ };
133
29
  }
134
- if (transitionClassName) {
135
- classList.add(transitionClassName);
30
+ static{
31
+ this.states = STATES;
136
32
  }
137
- if (toState && fromState && typeof onTransition === 'function') {
138
- onTransition(toState, fromState);
33
+ componentDidMount() {
34
+ this.startTransition(this.props.in, this.props.transitionOnMount);
35
+ this._unmounted = false;
139
36
  }
140
- this._timeouts.push(setTimeout(() => {
141
- if (this._unmounted) return;
142
- if (typeof transitionCallback === 'function') {
143
- transitionCallback();
144
- }
145
- }, transitionDuration));
146
- };
147
- clearTransition(transitionClassName) {
148
- if (this._unmounted) return;
149
- this.setState({
150
- transitioning: false
151
- }, () => {
152
- if (this._unmounted) return;
153
- const classList = getClassList(this.ref);
154
- Object.values(STATES).forEach(state => {
155
- const className = this.getTransitionClassName(state);
156
- if (className) {
157
- classList.remove(className);
37
+ getSnapshotBeforeUpdate(prevProps, prevState) {
38
+ if (this.props.in !== prevProps.in && prevState.transitioning) {
39
+ return true;
158
40
  }
159
- });
160
- classList.remove(transitionClassName);
161
- });
162
- }
163
- enter = initialState => {
164
- if (this.state.transitioning || this._unmounted) return;
165
- const {
166
- props
167
- } = this;
168
- if (typeof props.onEnter === 'function') {
169
- props.onEnter();
41
+ return null;
170
42
  }
171
- if (props.transitionEnter) {
172
- this.setState({
173
- transitioning: true
174
- }, () => {
175
- const enter = () => {
176
- if (typeof props.onEntering === 'function') {
177
- props.onEntering();
178
- }
179
- this.transition(STATES.ENTERED, STATES.ENTERING, () => {
180
- this.setState({
181
- transitioning: false
182
- }, () => {
183
- if (typeof props.onEntered === 'function') {
184
- props.onEntered();
185
- }
186
- });
187
- });
188
- };
189
- if (initialState) {
190
- this.transition(initialState, null, () => {
191
- this.transition(STATES.ENTERING, initialState, enter, props.enterDelay);
192
- });
193
- } else {
194
- enter();
43
+ componentDidUpdate(prevProps, _prevState, cancelPrematurely) {
44
+ if (cancelPrematurely) {
45
+ this.clearTransition(prevProps.transitionClassName);
46
+ }
47
+ if (this.props.transitionClassName !== prevProps.transitionClassName) {
48
+ this.clearTransition(prevProps.transitionClassName);
195
49
  }
196
- });
197
- } else {
198
- this.setState({
199
- transitioning: false
200
- }, () => {
201
- this.transition(STATES.ENTERED, STATES.EXITED);
202
- if (typeof props.onEntered === 'function') {
203
- props.onEntered();
50
+ if (prevProps.in !== this.props.in) {
51
+ if (_prevState.transitioning) {
52
+ this.clearTransition(prevProps.transitionClassName);
53
+ clearTimeout(this._timeouts.pop());
54
+ this.setState({
55
+ transitioning: false
56
+ }, ()=>this.startTransition(this.props.in, true));
57
+ } else this.startTransition(this.props.in, true);
204
58
  }
205
- });
206
59
  }
207
- };
208
- exit = initialState => {
209
- if (this.state.transitioning) return;
210
- const {
211
- props
212
- } = this;
213
- if (typeof props.onExit === 'function') {
214
- props.onExit();
60
+ componentWillUnmount() {
61
+ this._timeouts.forEach((timeout)=>{
62
+ clearTimeout(timeout);
63
+ });
64
+ this._unmounted = true;
215
65
  }
216
- if (props.transitionExit) {
217
- this.setState({
218
- transitioning: true
219
- }, () => {
220
- const exit = () => {
221
- if (typeof props.onExiting === 'function') {
222
- props.onExiting();
223
- }
224
- this.transition(STATES.EXITED, STATES.EXITING, () => {
225
- this.setState({
226
- transitioning: false
227
- }, () => {
228
- if (typeof props.onExited === 'function') {
229
- props.onExited();
230
- }
66
+ clearTransition(transitionClassName) {
67
+ if (this._unmounted) return;
68
+ this.setState({
69
+ transitioning: false
70
+ }, ()=>{
71
+ if (this._unmounted) return;
72
+ const classList = getClassList(this.ref);
73
+ Object.values(STATES).forEach((state)=>{
74
+ const className = this.getTransitionClassName(state);
75
+ if (className) {
76
+ classList.remove(className);
77
+ }
231
78
  });
232
- });
233
- };
234
- if (initialState) {
235
- this.transition(initialState, null, () => {
236
- this.transition(STATES.EXITING, initialState, exit, props.exitDelay);
237
- });
238
- } else {
239
- exit();
240
- }
241
- });
242
- } else {
243
- this.setState({
244
- transitioning: false
245
- }, () => {
246
- this.transition(STATES.EXITED, STATES.ENTERED);
247
- if (typeof props.onExited === 'function') {
248
- props.onExited();
249
- }
250
- });
79
+ classList.remove(transitionClassName);
80
+ });
251
81
  }
252
- };
253
- transitionEnabled(toState) {
254
- const {
255
- props
256
- } = this;
257
- switch (toState) {
258
- case STATES.EXITED:
259
- case STATES.EXITING:
260
- return props.transitionExit;
261
- case STATES.ENTERED:
262
- case STATES.ENTERING:
263
- return props.transitionEnter;
264
- default:
265
- return false;
82
+ transitionEnabled(toState) {
83
+ const { props } = this;
84
+ switch(toState){
85
+ case STATES.EXITED:
86
+ case STATES.EXITING:
87
+ return props.transitionExit;
88
+ case STATES.ENTERED:
89
+ case STATES.ENTERING:
90
+ return props.transitionEnter;
91
+ default:
92
+ return false;
93
+ }
266
94
  }
267
- }
268
- getTransitionClassName(transitionState) {
269
- const {
270
- props
271
- } = this;
272
- switch (transitionState) {
273
- case STATES.EXITED:
274
- return props.exitedClassName;
275
- case STATES.ENTERING:
276
- return props.enteringClassName;
277
- case STATES.ENTERED:
278
- return props.enteredClassName;
279
- case STATES.EXITING:
280
- return props.exitingClassName;
281
- default:
282
- return undefined;
95
+ getTransitionClassName(transitionState) {
96
+ const { props } = this;
97
+ switch(transitionState){
98
+ case STATES.EXITED:
99
+ return props.exitedClassName;
100
+ case STATES.ENTERING:
101
+ return props.enteringClassName;
102
+ case STATES.ENTERED:
103
+ return props.enteredClassName;
104
+ case STATES.EXITING:
105
+ return props.exitingClassName;
106
+ default:
107
+ return undefined;
108
+ }
283
109
  }
284
- }
285
- renderChildren() {
286
- if (!this.props.children) {
287
- return null;
110
+ renderChildren() {
111
+ if (!this.props.children) {
112
+ return null;
113
+ }
114
+ const child = ensureSingleChild(this.props.children);
115
+ const acceptsElementRef = child.type?.allowedProps?.includes('elementRef');
116
+ const refProps = acceptsElementRef ? {
117
+ elementRef: createChainedFunction(child.props?.elementRef, this.handleRef),
118
+ ref: (el)=>{
119
+ if (el instanceof Element) {
120
+ this.handleRef(el);
121
+ }
122
+ }
123
+ } : {
124
+ ref: (el)=>this.handleRef(el instanceof Element ? el : findDOMNode(el) ?? null)
125
+ };
126
+ return safeCloneElement(child, {
127
+ 'aria-hidden': !this.props.in ? true : undefined,
128
+ ...refProps
129
+ });
288
130
  }
289
- const child = ensureSingleChild(this.props.children);
290
-
291
- // Pass elementRef only to children that declare it. Emotion's wrapper
292
- // around `<div css={...}>` accepts any prop and forwards it to the DOM
293
- // node, so it must take the plain `ref` path.
294
- const acceptsElementRef = child.type?.allowedProps?.includes('elementRef');
295
- const refProps = acceptsElementRef ? {
296
- // chain so the child's own elementRef still fires instead of being overwritten
297
- elementRef: createChainedFunction(child.props?.elementRef, this.handleRef),
298
- // fallback for forwardRef children that expose their node via `ref`, not elementRef
299
- ref: el => {
300
- if (el instanceof Element) {
301
- this.handleRef(el);
131
+ render() {
132
+ if (!this.props.in && this.props.unmountOnExit && !this.state.transitioning) {
133
+ return null;
134
+ } else {
135
+ return this.renderChildren();
302
136
  }
303
- }
304
- } : {
305
- // host el / plain class|fn: findDOMNode is the fallback
306
- ref: el => this.handleRef(el instanceof Element ? el : findDOMNode(el) ?? null)
307
- };
308
- return safeCloneElement(child, {
309
- 'aria-hidden': !this.props.in ? true : undefined,
310
- ...refProps
311
- });
312
- }
313
- render() {
314
- if (!this.props.in && this.props.unmountOnExit && !this.state.transitioning) {
315
- return null;
316
- } else {
317
- return this.renderChildren();
318
137
  }
319
- }
138
+ constructor(...args){
139
+ super(...args), this._timeouts = [], this._unmounted = false, this.state = {
140
+ transitioning: false
141
+ }, this.ref = null, this.handleRef = (el)=>{
142
+ const { elementRef } = this.props;
143
+ this.ref = el;
144
+ if (typeof elementRef === 'function') {
145
+ elementRef(el);
146
+ }
147
+ }, this.startTransition = (transitionIn, transitionOnStart)=>{
148
+ const { transitionEnter, transitionExit } = this.props;
149
+ if (transitionIn) {
150
+ this.enter(transitionEnter && transitionOnStart ? STATES.EXITED : null);
151
+ } else {
152
+ this.exit(transitionExit && transitionOnStart ? STATES.ENTERED : null);
153
+ }
154
+ }, this.transition = (toState, fromState, transitionCallback, transitionDuration = 0)=>{
155
+ if (this._unmounted) return;
156
+ const { onTransition } = this.props;
157
+ const classList = getClassList(this.ref);
158
+ const transitionClassName = this.getTransitionClassName(toState);
159
+ const prevTransitionClassName = this.getTransitionClassName(fromState);
160
+ const baseTransitionClassName = this.props.transitionClassName;
161
+ if (fromState && transitionDuration && this.transitionEnabled(toState)) {
162
+ baseTransitionClassName && classList.add(baseTransitionClassName);
163
+ } else {
164
+ baseTransitionClassName && classList.remove(baseTransitionClassName);
165
+ }
166
+ if (prevTransitionClassName) {
167
+ classList.remove(prevTransitionClassName);
168
+ }
169
+ if (transitionClassName) {
170
+ classList.add(transitionClassName);
171
+ }
172
+ if (toState && fromState && typeof onTransition === 'function') {
173
+ onTransition(toState, fromState);
174
+ }
175
+ this._timeouts.push(setTimeout(()=>{
176
+ if (this._unmounted) return;
177
+ if (typeof transitionCallback === 'function') {
178
+ transitionCallback();
179
+ }
180
+ }, transitionDuration));
181
+ }, this.enter = (initialState)=>{
182
+ if (this.state.transitioning || this._unmounted) return;
183
+ const { props } = this;
184
+ if (typeof props.onEnter === 'function') {
185
+ props.onEnter();
186
+ }
187
+ if (props.transitionEnter) {
188
+ this.setState({
189
+ transitioning: true
190
+ }, ()=>{
191
+ const enter = ()=>{
192
+ if (typeof props.onEntering === 'function') {
193
+ props.onEntering();
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
+ if (initialState) {
206
+ this.transition(initialState, null, ()=>{
207
+ this.transition(STATES.ENTERING, initialState, enter, props.enterDelay);
208
+ });
209
+ } else {
210
+ enter();
211
+ }
212
+ });
213
+ } else {
214
+ this.setState({
215
+ transitioning: false
216
+ }, ()=>{
217
+ this.transition(STATES.ENTERED, STATES.EXITED);
218
+ if (typeof props.onEntered === 'function') {
219
+ props.onEntered();
220
+ }
221
+ });
222
+ }
223
+ }, this.exit = (initialState)=>{
224
+ if (this.state.transitioning) return;
225
+ const { props } = this;
226
+ if (typeof props.onExit === 'function') {
227
+ props.onExit();
228
+ }
229
+ if (props.transitionExit) {
230
+ this.setState({
231
+ transitioning: true
232
+ }, ()=>{
233
+ const exit = ()=>{
234
+ if (typeof props.onExiting === 'function') {
235
+ props.onExiting();
236
+ }
237
+ this.transition(STATES.EXITED, STATES.EXITING, ()=>{
238
+ this.setState({
239
+ transitioning: false
240
+ }, ()=>{
241
+ if (typeof props.onExited === 'function') {
242
+ props.onExited();
243
+ }
244
+ });
245
+ });
246
+ };
247
+ if (initialState) {
248
+ this.transition(initialState, null, ()=>{
249
+ this.transition(STATES.EXITING, initialState, exit, props.exitDelay);
250
+ });
251
+ } else {
252
+ exit();
253
+ }
254
+ });
255
+ } else {
256
+ this.setState({
257
+ transitioning: false
258
+ }, ()=>{
259
+ this.transition(STATES.EXITED, STATES.ENTERED);
260
+ if (typeof props.onExited === 'function') {
261
+ props.onExited();
262
+ }
263
+ });
264
+ }
265
+ };
266
+ }
320
267
  }
321
268
  export default BaseTransition;
322
- export { BaseTransition };
269
+ export { BaseTransition };
@@ -1,33 +1,25 @@
1
- /*
2
- * The MIT License (MIT)
3
- *
4
- * Copyright (c) 2015 - present Instructure, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
-
25
- // These props get passed from Transition
26
-
27
- // This intersection is needed for calculating allowedProps
28
-
29
- // this is getting exported, might be extended later,
30
- // that's why it is separated from BaseTransitionOwnProps
31
-
32
- const allowedProps = ['in', 'unmountOnExit', 'transitionOnMount', 'transitionEnter', 'transitionExit', 'enterDelay', 'exitDelay', 'transitionClassName', 'exitedClassName', 'exitingClassName', 'enteredClassName', 'enteringClassName', 'onTransition', 'onEnter', 'onEntering', 'onEntered', 'onExit', 'onExiting', 'onExited', 'children', 'className', 'elementRef'];
33
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'in',
3
+ 'unmountOnExit',
4
+ 'transitionOnMount',
5
+ 'transitionEnter',
6
+ 'transitionExit',
7
+ 'enterDelay',
8
+ 'exitDelay',
9
+ 'transitionClassName',
10
+ 'exitedClassName',
11
+ 'exitingClassName',
12
+ 'enteredClassName',
13
+ 'enteringClassName',
14
+ 'onTransition',
15
+ 'onEnter',
16
+ 'onEntering',
17
+ 'onEntered',
18
+ 'onExit',
19
+ 'onExiting',
20
+ 'onExited',
21
+ 'children',
22
+ 'className',
23
+ 'elementRef'
24
+ ];
25
+ export { allowedProps };