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 defaultProps = {
|
10 | in: false,
|
11 | timeout: 300,
|
12 | mountOnEnter: false,
|
13 | unmountOnExit: false,
|
14 | appear: false
|
15 | };
|
16 | const fadeStyles = {
|
17 | [ENTERING]: 'show',
|
18 | [ENTERED]: 'show'
|
19 | };
|
20 | const Fade = React.forwardRef(({
|
21 | className,
|
22 | children,
|
23 | transitionClasses = {},
|
24 | ...props
|
25 | }, ref) => {
|
26 | const handleEnter = useCallback((node, isAppearing) => {
|
27 | triggerBrowserReflow(node);
|
28 | props.onEnter == null ? void 0 : props.onEnter(node, isAppearing);
|
29 | }, [props]);
|
30 | return _jsx(TransitionWrapper, {
|
31 | ref: ref,
|
32 | addEndListener: transitionEndListener,
|
33 | ...props,
|
34 | onEnter: handleEnter,
|
35 | childRef: children.ref,
|
36 | children: (status, innerProps) => React.cloneElement(children, { ...innerProps,
|
37 | className: classNames('fade', className, children.props.className, fadeStyles[status], transitionClasses[status])
|
38 | })
|
39 | });
|
40 | });
|
41 | Fade.defaultProps = defaultProps;
|
42 | Fade.displayName = 'Fade';
|
43 | export default Fade; |
\ | No newline at end of file |