CSSMotion.d.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import * as React from 'react';
  2. import type { MotionEndEventHandler, MotionEventHandler, MotionPrepareEventHandler, MotionStatus } from './interface';
  3. export type CSSMotionConfig = boolean | {
  4. transitionSupport?: boolean;
  5. /** @deprecated, no need this anymore since `rc-motion` only support latest react */
  6. forwardRef?: boolean;
  7. };
  8. export type MotionName = string | {
  9. appear?: string;
  10. enter?: string;
  11. leave?: string;
  12. appearActive?: string;
  13. enterActive?: string;
  14. leaveActive?: string;
  15. };
  16. export interface CSSMotionProps {
  17. motionName?: MotionName;
  18. visible?: boolean;
  19. motionAppear?: boolean;
  20. motionEnter?: boolean;
  21. motionLeave?: boolean;
  22. motionLeaveImmediately?: boolean;
  23. motionDeadline?: number;
  24. /**
  25. * Create element in view even the element is invisible.
  26. * Will patch `display: none` style on it.
  27. */
  28. forceRender?: boolean;
  29. /**
  30. * Remove element when motion end. This will not work when `forceRender` is set.
  31. */
  32. removeOnLeave?: boolean;
  33. leavedClassName?: string;
  34. /** @private Used by CSSMotionList. Do not use in your production. */
  35. eventProps?: object;
  36. /** Prepare phase is used for measure element info. It will always trigger even motion is off */
  37. onAppearPrepare?: MotionPrepareEventHandler;
  38. /** Prepare phase is used for measure element info. It will always trigger even motion is off */
  39. onEnterPrepare?: MotionPrepareEventHandler;
  40. /** Prepare phase is used for measure element info. It will always trigger even motion is off */
  41. onLeavePrepare?: MotionPrepareEventHandler;
  42. onAppearStart?: MotionEventHandler;
  43. onEnterStart?: MotionEventHandler;
  44. onLeaveStart?: MotionEventHandler;
  45. onAppearActive?: MotionEventHandler;
  46. onEnterActive?: MotionEventHandler;
  47. onLeaveActive?: MotionEventHandler;
  48. onAppearEnd?: MotionEndEventHandler;
  49. onEnterEnd?: MotionEndEventHandler;
  50. onLeaveEnd?: MotionEndEventHandler;
  51. /** This will always trigger after final visible changed. Even if no motion configured. */
  52. onVisibleChanged?: (visible: boolean) => void;
  53. internalRef?: React.Ref<any>;
  54. children?: (props: {
  55. visible?: boolean;
  56. className?: string;
  57. style?: React.CSSProperties;
  58. [key: string]: any;
  59. }, ref: (node: any) => void) => React.ReactElement;
  60. }
  61. export interface CSSMotionState {
  62. status?: MotionStatus;
  63. statusActive?: boolean;
  64. newStatus?: boolean;
  65. statusStyle?: React.CSSProperties;
  66. prevProps?: CSSMotionProps;
  67. }
  68. /**
  69. * `transitionSupport` is used for none transition test case.
  70. * Default we use browser transition event support check.
  71. */
  72. export declare function genCSSMotion(config: CSSMotionConfig): React.ForwardRefExoticComponent<CSSMotionProps & React.RefAttributes<any>>;
  73. declare const _default: React.ForwardRefExoticComponent<CSSMotionProps & React.RefAttributes<any>>;
  74. export default _default;