UNPKG

1.45 kBTypeScriptView Raw
1import * as React from 'react';
2import { Transition } from 'react-transition-group';
3
4export type fn = () => void;
5export interface BaseTransition {
6 /** Whether we are in a transition. */
7 in?: boolean | undefined;
8 /** Function to be called once transition finishes. */
9 onExited?: fn | undefined;
10}
11
12// ==============================
13// Fade Transition
14// ==============================
15
16export type FadeProps = BaseTransition & {
17 component: React.ComponentType<any>;
18 duration: number;
19};
20export const Fade: React.ComponentType<FadeProps>;
21
22// ==============================
23// Collapse Transition
24// ==============================
25
26export const collapseDuration: number;
27
28export type TransitionState = 'exiting' | 'exited';
29export type Width = number | 'auto';
30export interface CollapseProps {
31 children: any;
32 in: boolean;
33}
34export interface CollapseState {
35 width: Width;
36}
37
38// wrap each MultiValue with a collapse transition; decreases width until
39// finally removing from DOM
40export class Collapse extends React.Component<CollapseProps, CollapseState> {
41 duration: number;
42 transition: {
43 exiting: any;
44 exited: any;
45 };
46
47 // width must be calculated; cannot transition from `undefined` to `number`
48 getWidth: (ref: React.Ref<any>) => void;
49
50 // get base styles
51 getStyle: (width: Width) => any;
52
53 // get transition styles
54 getTransition: (state: TransitionState) => any;
55}