UNPKG

3.74 kBTypeScriptView Raw
1import * as React from "react";
2import { AbstractPureComponent2 } from "../../common";
3import { Props } from "../../common/props";
4export declare type CollapseProps = ICollapseProps;
5/** @deprecated use CollapseProps */
6export interface ICollapseProps extends Props {
7 /**
8 * Component to render as the root element.
9 * Useful when rendering a `Collapse` inside a `<table>`, for instance.
10 *
11 * @default "div"
12 */
13 component?: React.ElementType;
14 /**
15 * Whether the component is open or closed.
16 *
17 * @default false
18 */
19 isOpen?: boolean;
20 /**
21 * Whether the child components will remain mounted when the `Collapse` is closed.
22 * Setting to true may improve performance by avoiding re-mounting children.
23 *
24 * @default false
25 */
26 keepChildrenMounted?: boolean;
27 /**
28 * The length of time the transition takes, in milliseconds. This must match
29 * the duration of the animation in CSS. Only set this prop if you override
30 * Blueprint's default transitions with new transitions of a different
31 * length.
32 *
33 * @default 200
34 */
35 transitionDuration?: number;
36}
37export interface ICollapseState {
38 /** The state the element is currently in. */
39 animationState: AnimationStates;
40 /** The height that should be used for the content animations. This is a CSS value, not just a number. */
41 height: string | undefined;
42 /**
43 * The most recent non-zero height (once a height has been measured upon first open; it is undefined until then)
44 */
45 heightWhenOpen: number | undefined;
46}
47/**
48 * `Collapse` can be in one of six states, enumerated here.
49 * When changing the `isOpen` prop, the following happens to the states:
50 * isOpen={true} : CLOSED -> OPEN_START -> OPENING -> OPEN
51 * isOpen={false} : OPEN -> CLOSING_START -> CLOSING -> CLOSED
52 */
53export declare enum AnimationStates {
54 /**
55 * The body is re-rendered, height is set to the measured body height and
56 * the body Y is set to 0.
57 */
58 OPEN_START = 0,
59 /**
60 * Animation begins, height is set to auto. This is all animated, and on
61 * complete, the state changes to OPEN.
62 */
63 OPENING = 1,
64 /**
65 * The collapse height is set to auto, and the body Y is set to 0 (so the
66 * element can be seen as normal).
67 */
68 OPEN = 2,
69 /**
70 * Height has been changed from auto to the measured height of the body to
71 * prepare for the closing animation in CLOSING.
72 */
73 CLOSING_START = 3,
74 /**
75 * Height is set to 0 and the body Y is at -height. Both of these properties
76 * are transformed, and then after the animation is complete, the state
77 * changes to CLOSED.
78 */
79 CLOSING = 4,
80 /**
81 * The contents of the collapse is not rendered, the collapse height is 0,
82 * and the body Y is at -height (so that the bottom of the body is at Y=0).
83 */
84 CLOSED = 5
85}
86export declare class Collapse extends AbstractPureComponent2<CollapseProps, ICollapseState> {
87 static displayName: string;
88 static defaultProps: CollapseProps;
89 static getDerivedStateFromProps(props: CollapseProps, state: ICollapseState): {
90 animationState: AnimationStates;
91 height?: undefined;
92 } | {
93 animationState: AnimationStates;
94 height: string;
95 } | null;
96 state: ICollapseState;
97 private contents;
98 render(): React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)> | null) | (new (props: any) => React.Component<any, any, any>)>;
99 componentDidMount(): void;
100 componentDidUpdate(): void;
101 private contentsRefHandler;
102 private onDelayedStateChange;
103}
104
\No newline at end of file