@instructure/ui-motion 8.8.1-snapshot.3 → 8.9.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/es/Transition/{BaseTransition.js → BaseTransition/index.js} +7 -120
  3. package/{src/Transition/types.ts → es/Transition/BaseTransition/props.js} +26 -26
  4. package/es/Transition/index.js +15 -83
  5. package/es/Transition/props.js +95 -0
  6. package/lib/Transition/{BaseTransition.js → BaseTransition/index.js} +8 -121
  7. package/lib/Transition/BaseTransition/props.js +60 -0
  8. package/lib/Transition/index.js +16 -84
  9. package/lib/Transition/props.js +106 -0
  10. package/package.json +12 -13
  11. package/src/Transition/{BaseTransition.ts → BaseTransition/index.ts} +12 -136
  12. package/src/Transition/BaseTransition/props.ts +187 -0
  13. package/src/Transition/index.tsx +15 -77
  14. package/src/Transition/props.ts +144 -0
  15. package/src/Transition/styles.ts +1 -1
  16. package/src/index.ts +1 -1
  17. package/types/Transition/BaseTransition/index.d.ts +101 -0
  18. package/types/Transition/BaseTransition/index.d.ts.map +1 -0
  19. package/types/Transition/BaseTransition/props.d.ts +102 -0
  20. package/types/Transition/BaseTransition/props.d.ts.map +1 -0
  21. package/types/Transition/index.d.ts +35 -62
  22. package/types/Transition/index.d.ts.map +1 -1
  23. package/types/Transition/props.d.ts +28 -0
  24. package/types/Transition/props.d.ts.map +1 -0
  25. package/types/Transition/styles.d.ts +1 -1
  26. package/types/index.d.ts +1 -1
  27. package/LICENSE.md +0 -27
  28. package/es/Transition/types.js +0 -1
  29. package/lib/Transition/types.js +0 -1
  30. package/types/Transition/BaseTransition.d.ts +0 -152
  31. package/types/Transition/BaseTransition.d.ts.map +0 -1
  32. package/types/Transition/types.d.ts +0 -19
  33. package/types/Transition/types.d.ts.map +0 -1
@@ -27,7 +27,6 @@
27
27
  // test is breaking without importing React here
28
28
  // eslint-disable-next-line no-unused-vars
29
29
  import React, { Component } from 'react'
30
- import PropTypes from 'prop-types'
31
30
 
32
31
  import { ms } from '@instructure/ui-utils'
33
32
  import { testable } from '@instructure/ui-testable'
@@ -38,7 +37,9 @@ import generateStyle from './styles'
38
37
  import generateComponentTheme from './theme'
39
38
 
40
39
  import { BaseTransition } from './BaseTransition'
41
- import { TransitionProps } from './types'
40
+
41
+ import { allowedProps, propTypes } from './props'
42
+ import type { TransitionProps } from './props'
42
43
 
43
44
  /**
44
45
  ---
@@ -51,73 +52,8 @@ category: components/utilities
51
52
  class Transition extends Component<TransitionProps> {
52
53
  static readonly componentId = 'Transition'
53
54
 
54
- static propTypes = {
55
- // eslint-disable-next-line react/require-default-props
56
- makeStyles: PropTypes.func,
57
- // eslint-disable-next-line react/require-default-props
58
- styles: PropTypes.object,
59
- type: PropTypes.oneOf([
60
- 'fade',
61
- 'scale',
62
- 'slide-down',
63
- 'slide-up',
64
- 'slide-left',
65
- 'slide-right'
66
- ]),
67
- /**
68
- * A single element to animate in and out
69
- */
70
- children: PropTypes.element,
71
- /**
72
- * Show the component; triggers the enter or exit animation
73
- */
74
- in: PropTypes.bool,
75
- /**
76
- * Unmount the component (remove it from the DOM) when it is not shown
77
- */
78
- unmountOnExit: PropTypes.bool,
79
- /**
80
- * Run the enter animation when the component mounts, if it is initially
81
- * shown
82
- */
83
- transitionOnMount: PropTypes.bool,
84
- /**
85
- * Run the enter animation
86
- */
87
- transitionEnter: PropTypes.bool,
88
- /**
89
- * Run the exit animation
90
- */
91
- transitionExit: PropTypes.bool,
92
- /**
93
- * Callback fired when transitioning to the next state
94
- */
95
- onTransition: PropTypes.func,
96
- /**
97
- * Callback fired before the "entering" classes are applied
98
- */
99
- onEnter: PropTypes.func,
100
- /**
101
- * Callback fired after the "entering" classes are applied
102
- */
103
- onEntering: PropTypes.func,
104
- /**
105
- * Callback fired after the "enter" classes are applied
106
- */
107
- onEntered: PropTypes.func,
108
- /**
109
- * Callback fired before the "exiting" classes are applied
110
- */
111
- onExit: PropTypes.func,
112
- /**
113
- * Callback fired after the "exiting" classes are applied
114
- */
115
- onExiting: PropTypes.func,
116
- /**
117
- * Callback fired after the "exited" classes are applied
118
- */
119
- onExited: PropTypes.func
120
- }
55
+ static allowedProps = allowedProps
56
+ static propTypes = propTypes
121
57
 
122
58
  static defaultProps = {
123
59
  type: 'fade',
@@ -141,14 +77,11 @@ class Transition extends Component<TransitionProps> {
141
77
  static states = BaseTransition.states
142
78
 
143
79
  componentDidMount() {
144
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
145
- this.props.makeStyles()
80
+ this.props.makeStyles?.()
146
81
  }
147
82
 
148
- // @ts-expect-error ts-migrate(6133) FIXME: 'prevProps' is declared but its value is never rea... Remove this comment to see the full error message
149
- componentDidUpdate(prevProps, prevState, snapshot) {
150
- // @ts-expect-error ts-migrate(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message
151
- this.props.makeStyles()
83
+ componentDidUpdate() {
84
+ this.props.makeStyles?.()
152
85
  }
153
86
 
154
87
  handleExited = () => {
@@ -174,13 +107,13 @@ class Transition extends Component<TransitionProps> {
174
107
  renderTransitionHelper = () => {
175
108
  const { styles } = this.props
176
109
 
177
- return <Global styles={styles.globalStyles} />
110
+ return <Global styles={styles?.globalStyles} />
178
111
  }
179
112
 
180
113
  render() {
181
114
  const { type, children, styles, ...props } = this.props
182
115
 
183
- const duration = ms(styles?.duration)
116
+ const duration = ms(styles?.duration as number)
184
117
 
185
118
  return (
186
119
  <>
@@ -189,10 +122,15 @@ class Transition extends Component<TransitionProps> {
189
122
  {...props}
190
123
  enterDelay={duration}
191
124
  exitDelay={duration}
125
+ //@ts-expect-error TODO:
192
126
  transitionClassName={styles?.classNames?.transitioning}
127
+ //@ts-expect-error TODO:
193
128
  exitedClassName={styles?.classNames?.exited}
129
+ //@ts-expect-error TODO:
194
130
  exitingClassName={styles?.classNames?.exiting}
131
+ //@ts-expect-error TODO:
195
132
  enteredClassName={styles?.classNames?.entered}
133
+ //@ts-expect-error TODO:
196
134
  enteringClassName={styles?.classNames?.entering}
197
135
  onEntered={this.handleEntered}
198
136
  onExited={this.handleExited}
@@ -0,0 +1,144 @@
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
+ import React from 'react'
25
+ import PropTypes from 'prop-types'
26
+
27
+ import type { PropValidators } from '@instructure/shared-types'
28
+ import type { WithStyleProps } from '@instructure/emotion'
29
+
30
+ type TransitionType =
31
+ | 'fade'
32
+ | 'scale'
33
+ | 'slide-down'
34
+ | 'slide-up'
35
+ | 'slide-left'
36
+ | 'slide-right'
37
+
38
+ // TODO: use common props from BaseTransition
39
+ type TransitionOwnProps = {
40
+ type?: TransitionType
41
+ in?: boolean
42
+ unmountOnExit?: boolean
43
+ transitionOnMount?: boolean
44
+ transitionEnter?: boolean
45
+ transitionExit?: boolean
46
+ onTransition?: (...args: any[]) => any
47
+ onEnter?: (...args: any[]) => any
48
+ onEntering?: (...args: any[]) => any
49
+ onEntered?: (...args: any[]) => any
50
+ onExit?: (...args: any[]) => any
51
+ onExiting?: (...args: any[]) => any
52
+ onExited?: (...args: any[]) => any
53
+ children?: React.ReactNode
54
+ }
55
+
56
+ type PropKeys = keyof TransitionOwnProps
57
+
58
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
59
+
60
+ type TransitionProps = TransitionOwnProps & WithStyleProps
61
+
62
+ const propTypes: PropValidators<PropKeys> = {
63
+ type: PropTypes.oneOf([
64
+ 'fade',
65
+ 'scale',
66
+ 'slide-down',
67
+ 'slide-up',
68
+ 'slide-left',
69
+ 'slide-right'
70
+ ]),
71
+ /**
72
+ * A single element to animate in and out
73
+ */
74
+ children: PropTypes.element,
75
+ /**
76
+ * Show the component; triggers the enter or exit animation
77
+ */
78
+ in: PropTypes.bool,
79
+ /**
80
+ * Unmount the component (remove it from the DOM) when it is not shown
81
+ */
82
+ unmountOnExit: PropTypes.bool,
83
+ /**
84
+ * Run the enter animation when the component mounts, if it is initially
85
+ * shown
86
+ */
87
+ transitionOnMount: PropTypes.bool,
88
+ /**
89
+ * Run the enter animation
90
+ */
91
+ transitionEnter: PropTypes.bool,
92
+ /**
93
+ * Run the exit animation
94
+ */
95
+ transitionExit: PropTypes.bool,
96
+ /**
97
+ * Callback fired when transitioning to the next state
98
+ */
99
+ onTransition: PropTypes.func,
100
+ /**
101
+ * Callback fired before the "entering" classes are applied
102
+ */
103
+ onEnter: PropTypes.func,
104
+ /**
105
+ * Callback fired after the "entering" classes are applied
106
+ */
107
+ onEntering: PropTypes.func,
108
+ /**
109
+ * Callback fired after the "enter" classes are applied
110
+ */
111
+ onEntered: PropTypes.func,
112
+ /**
113
+ * Callback fired before the "exiting" classes are applied
114
+ */
115
+ onExit: PropTypes.func,
116
+ /**
117
+ * Callback fired after the "exiting" classes are applied
118
+ */
119
+ onExiting: PropTypes.func,
120
+ /**
121
+ * Callback fired after the "exited" classes are applied
122
+ */
123
+ onExited: PropTypes.func
124
+ }
125
+
126
+ const allowedProps: AllowedPropKeys = [
127
+ 'type',
128
+ 'children',
129
+ 'in',
130
+ 'unmountOnExit',
131
+ 'transitionOnMount',
132
+ 'transitionEnter',
133
+ 'transitionExit',
134
+ 'onTransition',
135
+ 'onEnter',
136
+ 'onEntering',
137
+ 'onEntered',
138
+ 'onExit',
139
+ 'onExiting',
140
+ 'onExited'
141
+ ]
142
+
143
+ export type { TransitionProps, TransitionType }
144
+ export { propTypes, allowedProps }
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  import { TransitionTheme } from '@instructure/shared-types'
26
- import { TransitionProps } from './types'
26
+ import { TransitionProps } from './props'
27
27
 
28
28
  /**
29
29
  * ---
package/src/index.ts CHANGED
@@ -22,4 +22,4 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
  export { Transition } from './Transition'
25
- export type { TransitionProps, TransitionType } from './Transition/types'
25
+ export type { TransitionProps, TransitionType } from './Transition/props'
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import type { BaseTransitionProps } from './props';
3
+ /**
4
+ ---
5
+ private: true
6
+ ---
7
+ Note: this is forked from https://github.com/react-bootstrap/react-overlays/blob/master/src/Transition.js
8
+ so that it works with css modules. The internals are pretty different now, but it has roughly the same api.
9
+ **/
10
+ declare class BaseTransition extends React.Component<BaseTransitionProps> {
11
+ static propTypes: import("@instructure/shared-types/types/UtilityTypes").PropValidators<keyof {
12
+ in?: boolean | undefined;
13
+ unmountOnExit?: boolean | undefined;
14
+ transitionOnMount?: boolean | undefined;
15
+ transitionEnter?: boolean | undefined;
16
+ transitionExit?: boolean | undefined;
17
+ enterDelay?: number | undefined;
18
+ exitDelay?: number | undefined;
19
+ transitionClassName?: string | undefined;
20
+ exitedClassName?: string | undefined;
21
+ exitingClassName?: string | undefined;
22
+ enteredClassName?: string | undefined;
23
+ enteringClassName?: string | undefined;
24
+ onTransition?: ((toState: number, fromState: number) => void) | undefined;
25
+ onEnter?: (() => void) | undefined;
26
+ onEntering?: (() => void) | undefined;
27
+ onEntered?: (() => void) | undefined;
28
+ onExit?: (() => void) | undefined;
29
+ onExiting?: (() => void) | undefined;
30
+ onExited?: (() => void) | undefined;
31
+ children?: React.ReactNode;
32
+ className?: string | undefined;
33
+ }>;
34
+ static allowedProps: readonly (keyof {
35
+ in?: boolean | undefined;
36
+ unmountOnExit?: boolean | undefined;
37
+ transitionOnMount?: boolean | undefined;
38
+ transitionEnter?: boolean | undefined;
39
+ transitionExit?: boolean | undefined;
40
+ enterDelay?: number | undefined;
41
+ exitDelay?: number | undefined;
42
+ transitionClassName?: string | undefined;
43
+ exitedClassName?: string | undefined;
44
+ exitingClassName?: string | undefined;
45
+ enteredClassName?: string | undefined;
46
+ enteringClassName?: string | undefined;
47
+ onTransition?: ((toState: number, fromState: number) => void) | undefined;
48
+ onEnter?: (() => void) | undefined;
49
+ onEntering?: (() => void) | undefined;
50
+ onEntered?: (() => void) | undefined;
51
+ onExit?: (() => void) | undefined;
52
+ onExiting?: (() => void) | undefined;
53
+ onExited?: (() => void) | undefined;
54
+ children?: React.ReactNode;
55
+ className?: string | undefined;
56
+ })[];
57
+ static defaultProps: {
58
+ in: boolean;
59
+ component: string;
60
+ unmountOnExit: boolean;
61
+ transitionOnMount: boolean;
62
+ transitionEnter: boolean;
63
+ transitionExit: boolean;
64
+ enterDelay: number;
65
+ exitDelay: number;
66
+ onEnter: () => void;
67
+ onEntering: () => void;
68
+ onEntered: () => void;
69
+ onExit: () => void;
70
+ onExiting: () => void;
71
+ onExited: () => void;
72
+ onTransition: () => void;
73
+ children: null;
74
+ };
75
+ static states: {
76
+ EXITED: number;
77
+ EXITING: number;
78
+ ENTERING: number;
79
+ ENTERED: number;
80
+ };
81
+ _timeouts: never[];
82
+ state: {
83
+ transitioning: boolean;
84
+ };
85
+ componentDidMount(): void;
86
+ getSnapshotBeforeUpdate(prevProps: any, prevState: any): true | null;
87
+ componentDidUpdate(prevProps: any, prevState: any, cancelPrematurely: any): void;
88
+ componentWillUnmount(): void;
89
+ startTransition: (transitionIn: any, transitionOnStart: any) => void;
90
+ transition: (toState: any, fromState: any, transitionCallback: any, transitionDuration?: number) => void;
91
+ clearTransition(transitionClassName: any): void;
92
+ enter: (initialState: any) => void;
93
+ exit: (initialState: any) => void;
94
+ transitionEnabled(toState: any): boolean | undefined;
95
+ getTransitionClassName(transitionState: any): string | null | undefined;
96
+ renderChildren(): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
97
+ render(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
98
+ }
99
+ export default BaseTransition;
100
+ export { BaseTransition };
101
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Transition/BaseTransition/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,MAAM,OAAO,CAAA;AASzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AASlD;;;;;;GAMG;AACH,cAAM,cAAe,SAAQ,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC;IAC/D,MAAM,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;OAAY;IAC5B,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;SAAe;IAClC,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;MAqBlB;IAED,MAAM,CAAC,MAAM;;;;;MAAS;IAEtB,SAAS,UAAK;IAEd,KAAK;;MAEJ;IAED,iBAAiB;IAKjB,uBAAuB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA;IAS5C,kBAAkB,CAAC,SAAS,KAAA,EAAE,SAAS,KAAA,EAAE,iBAAiB,KAAA;IAc1D,oBAAoB;IASpB,eAAe,sDAOd;IAED,UAAU,+FAgDT;IAGD,eAAe,CAAC,mBAAmB,KAAA;IAoBnC,KAAK,8BAyCJ;IAGD,IAAI,8BAmCH;IAGD,iBAAiB,CAAC,OAAO,KAAA;IAgBzB,sBAAsB,CAAC,eAAe,KAAA;IAgBtC,cAAc;IAMd,MAAM;CAWP;AAED,eAAe,cAAc,CAAA;AAC7B,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,102 @@
1
+ import React from 'react';
2
+ import type { PropValidators } from '@instructure/shared-types';
3
+ import type { WithStyleProps } from '@instructure/emotion';
4
+ declare type BaseTransitionOwnProps = {
5
+ /**
6
+ * Show the component? Triggers the enter or exit animation.
7
+ */
8
+ in?: boolean;
9
+ /**
10
+ * Unmount the component (remove it from the DOM) when it is not shown.
11
+ */
12
+ unmountOnExit?: boolean;
13
+ /**
14
+ * Run the enter animation when the component mounts, if it is initially
15
+ * shown
16
+ */
17
+ transitionOnMount?: boolean;
18
+ /**
19
+ * Run the enter animation
20
+ */
21
+ transitionEnter?: boolean;
22
+ /**
23
+ * Run the exit animation
24
+ */
25
+ transitionExit?: boolean;
26
+ /**
27
+ * A Timeout for the animation, in milliseconds, to ensure that a node doesn't
28
+ * transition indefinately if the browser transitionEnd events are
29
+ * canceled or interrupted.
30
+ *
31
+ * By default this is set to a high number (5 seconds) as a failsafe. You should consider
32
+ * setting this to the duration of your animation (or a bit above it).
33
+ */
34
+ enterDelay?: number;
35
+ /**
36
+ * A Timeout for the animation, in milliseconds, to ensure that a node doesn't
37
+ * transition indefinately if the browser transitionEnd events are
38
+ * canceled or interrupted.
39
+ *
40
+ * By default this is set to a high number (5 seconds) as a failsafe. You should consider
41
+ * setting this to the duration of your animation (or a bit above it).
42
+ */
43
+ exitDelay?: number;
44
+ /**
45
+ * the base CSS class for the transition (transitions go here)
46
+ */
47
+ transitionClassName?: string;
48
+ /**
49
+ * CSS class or classes applied when the component is exited
50
+ */
51
+ exitedClassName?: string;
52
+ /**
53
+ * CSS class or classes applied while the component is exiting
54
+ */
55
+ exitingClassName?: string;
56
+ /**
57
+ * CSS class or classes applied when the component is entered
58
+ */
59
+ enteredClassName?: string;
60
+ /**
61
+ * CSS class or classes applied while the component is entering
62
+ */
63
+ enteringClassName?: string;
64
+ /**
65
+ * Callback fired when transitioning to the next state
66
+ */
67
+ onTransition?: (toState: number, fromState: number) => void;
68
+ /**
69
+ * Callback fired before the "entering" classes are applied
70
+ */
71
+ onEnter?: () => void;
72
+ /**
73
+ * Callback fired after the "entering" classes are applied
74
+ */
75
+ onEntering?: () => void;
76
+ /**
77
+ * Callback fired after the "enter" classes are applied
78
+ */
79
+ onEntered?: () => void;
80
+ /**
81
+ * Callback fired before the "exiting" classes are applied
82
+ */
83
+ onExit?: () => void;
84
+ /**
85
+ * Callback fired after the "exiting" classes are applied
86
+ */
87
+ onExiting?: () => void;
88
+ /**
89
+ * Callback fired after the "exited" classes are applied
90
+ */
91
+ onExited?: () => void;
92
+ children?: React.ReactNode;
93
+ className?: string;
94
+ };
95
+ declare type PropKeys = keyof BaseTransitionOwnProps;
96
+ declare type AllowedPropKeys = Readonly<Array<PropKeys>>;
97
+ declare type BaseTransitionProps = BaseTransitionOwnProps & WithStyleProps;
98
+ declare const propTypes: PropValidators<PropKeys>;
99
+ declare const allowedProps: AllowedPropKeys;
100
+ export type { BaseTransitionProps };
101
+ export { propTypes, allowedProps };
102
+ //# sourceMappingURL=props.d.ts.map