UNPKG

1.36 kBJavaScriptView Raw
1import classNames from 'classnames';
2import * as React from 'react';
3import { useCallback } from 'react';
4import { ENTERED, ENTERING } from 'react-transition-group/Transition';
5import transitionEndListener from './transitionEndListener';
6import triggerBrowserReflow from './triggerBrowserReflow';
7import TransitionWrapper from './TransitionWrapper';
8import { jsx as _jsx } from "react/jsx-runtime";
9const fadeStyles = {
10 [ENTERING]: 'show',
11 [ENTERED]: 'show'
12};
13const Fade = /*#__PURE__*/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 /*#__PURE__*/_jsx(TransitionWrapper, {
33 ref: ref,
34 addEndListener: transitionEndListener,
35 ...props,
36 onEnter: handleEnter,
37 childRef: children.ref,
38 children: (status, innerProps) => /*#__PURE__*/React.cloneElement(children, {
39 ...innerProps,
40 className: classNames('fade', className, children.props.className, fadeStyles[status], transitionClasses[status])
41 })
42 });
43});
44Fade.displayName = 'Fade';
45export default Fade;
\No newline at end of file