1 | import classNames from 'classnames';
|
2 | import * as React from 'react';
|
3 | import { useCallback } from 'react';
|
4 | import { ENTERED, ENTERING } from 'react-transition-group/Transition';
|
5 | import transitionEndListener from './transitionEndListener';
|
6 | import triggerBrowserReflow from './triggerBrowserReflow';
|
7 | import TransitionWrapper from './TransitionWrapper';
|
8 | import { jsx as _jsx } from "react/jsx-runtime";
|
9 | const fadeStyles = {
|
10 | [ENTERING]: 'show',
|
11 | [ENTERED]: 'show'
|
12 | };
|
13 | const Fade = React.forwardRef(({
|
14 | className,
|
15 | children,
|
16 | transitionClasses = {},
|
17 | onEnter,
|
18 | ...rest
|
19 | }, ref) => {
|
20 | const props = {
|
21 | in: false,
|
22 | timeout: 300,
|
23 | mountOnEnter: false,
|
24 | unmountOnExit: false,
|
25 | appear: false,
|
26 | ...rest
|
27 | };
|
28 | const handleEnter = useCallback((node, isAppearing) => {
|
29 | triggerBrowserReflow(node);
|
30 | onEnter == null ? void 0 : onEnter(node, isAppearing);
|
31 | }, [onEnter]);
|
32 | return _jsx(TransitionWrapper, {
|
33 | ref: ref,
|
34 | addEndListener: transitionEndListener,
|
35 | ...props,
|
36 | onEnter: handleEnter,
|
37 | childRef: children.ref,
|
38 | children: (status, innerProps) => React.cloneElement(children, {
|
39 | ...innerProps,
|
40 | className: classNames('fade', className, children.props.className, fadeStyles[status], transitionClasses[status])
|
41 | })
|
42 | });
|
43 | });
|
44 | Fade.displayName = 'Fade';
|
45 | export default Fade; |
\ | No newline at end of file |