TooltipStyledTransition.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. /* eslint-disable max-len */
  2. /* eslint-disable @typescript-eslint/no-shadow */
  3. import { StyledTransition } from '@douyinfe/semi-animation-react';
  4. import React from 'react';
  5. import { cssClasses } from '@douyinfe/semi-foundation/tooltip/constants';
  6. import getMotionObjFromProps from '@douyinfe/semi-foundation/utils/getMotionObjFromProps';
  7. import { Motion } from '../_base/base';
  8. const enterCls = `${cssClasses.PREFIX}-bounceIn`;
  9. const leaveCls = `${cssClasses.PREFIX}-zoomOut`;
  10. export interface TooltipTransitionProps {
  11. [key: string]: any;
  12. children?: (arg: any) => React.ReactNode;
  13. motion?: Motion<TooltipTransitionProps>;
  14. }
  15. const TooltipTransition: React.FC<TooltipTransitionProps> = (props = {}) => {
  16. const { children } = props;
  17. const motion = getMotionObjFromProps(props);
  18. // add fillMode forwards to fix issue 715, tooltip close will flashing under react 18
  19. return (
  20. <StyledTransition {...props} enter={enterCls} leave={leaveCls} duration={'100ms'} {...motion} fillMode='forwards'>
  21. {typeof children === 'function' ?
  22. ({ animateCls, animateEvents, animateStyle }: any) => children({ animateCls, animateEvents, animateStyle }) :
  23. children}
  24. </StyledTransition>
  25. );
  26. };
  27. export default TooltipTransition;