10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
- import React , { ComponentProps , JSX , JSXElementConstructor , ReactElement } from 'react' ;
14
- import { Transition } from 'react-transition-group' ;
13
+ import React , { JSX , JSXElementConstructor , ReactElement } from 'react' ;
14
+ import { Transition , TransitionProps } from 'react-transition-group' ;
15
15
16
16
const OPEN_STATES = {
17
17
entering : false ,
18
18
entered : true
19
19
} ;
20
20
21
- type TransitionProps = ComponentProps < typeof Transition < HTMLElement > >
22
- interface OpenTransitionProps extends Omit < TransitionProps , 'children' > {
23
- children : any
24
- }
25
-
26
21
/**
27
22
* Timeout issues adding css animations to enter may be related to
28
23
* https://github.com/reactjs/react-transition-group/issues/189 or
@@ -37,16 +32,16 @@ interface OpenTransitionProps extends Omit<TransitionProps, 'children'> {
37
32
*/
38
33
39
34
export function OpenTransition (
40
- props : OpenTransitionProps
41
- ) : JSX . Element | ReactElement < any , string | JSXElementConstructor < any > > [ ] {
35
+ props : TransitionProps
36
+ ) : JSX . Element | ReactElement < any , string | JSXElementConstructor < any > > [ ] {
42
37
// Do not apply any transition if in chromatic.
43
38
if ( process . env . CHROMATIC ) {
44
- return React . Children . map ( props . children , child => child && React . isValidElement ( child ) && React . cloneElement ( child as any , { isOpen : props . in } ) ) ;
39
+ return React . Children . map ( props . children , child => child && React . cloneElement ( child , { isOpen : props . in } ) ) ;
45
40
}
46
41
47
42
return (
48
43
< Transition timeout = { { enter : 0 , exit : 350 } } { ...props } >
49
- { ( state ) => React . Children . map ( props . children , child => child && React . isValidElement ( child ) && React . cloneElement ( child as any , { isOpen : ! ! OPEN_STATES [ state ] } ) ) }
44
+ { ( state ) => React . Children . map ( props . children , child => child && React . cloneElement ( child , { isOpen : ! ! OPEN_STATES [ state ] } ) ) }
50
45
</ Transition >
51
46
) ;
52
47
}
0 commit comments