UNPKG

1.85 kBTypeScriptView Raw
1/// <reference types="react" />
2import { Props } from "../../common";
3import { Panel } from "./panelTypes";
4/**
5 * @template T type union of all possible panels in this stack
6 */
7export interface PanelStack2Props<T extends Panel<object>> extends Props {
8 /**
9 * The initial panel to show on mount. This panel cannot be removed from the
10 * stack and will appear when the stack is empty.
11 * This prop is only used in uncontrolled mode and is thus mutually
12 * exclusive with the `stack` prop.
13 */
14 initialPanel?: T;
15 /**
16 * Callback invoked when the user presses the back button or a panel
17 * closes itself with a `closePanel()` action.
18 */
19 onClose?: (removedPanel: T) => void;
20 /**
21 * Callback invoked when a panel opens a new panel with an `openPanel(panel)`
22 * action.
23 */
24 onOpen?: (addedPanel: T) => void;
25 /**
26 * If false, PanelStack will render all panels in the stack to the DOM, allowing their
27 * React component trees to maintain state as a user navigates through the stack.
28 * Panels other than the currently active one will be invisible.
29 *
30 * @default true
31 */
32 renderActivePanelOnly?: boolean;
33 /**
34 * Whether to show the header with the "back" button in each panel.
35 *
36 * @default true
37 */
38 showPanelHeader?: boolean;
39 /**
40 * The full stack of panels in controlled mode. The last panel in the stack
41 * will be displayed.
42 */
43 stack?: T[];
44}
45interface PanelStack2Component {
46 /**
47 * @template T type union of all possible panels in this stack
48 */
49 <T extends Panel<object>>(props: PanelStack2Props<T>): JSX.Element | null;
50 displayName: string;
51}
52/**
53 * @template T type union of all possible panels in this stack
54 */
55export declare const PanelStack2: PanelStack2Component;
56export {};