UNPKG

1.51 kBTypeScriptView Raw
1/// <reference types="react" />
2/**
3 * An object describing a panel in a `PanelStack2`.
4 */
5export interface Panel<P> {
6 /**
7 * The renderer for this panel.
8 */
9 renderPanel: (props: PanelProps<P>) => JSX.Element | null;
10 /**
11 * HTML title to be passed to the <Text> component
12 */
13 htmlTitle?: string;
14 /**
15 * The props passed to the component type when it is rendered. The methods
16 * in `PanelActions` will be injected by `PanelStack2`.
17 */
18 props?: P;
19 /**
20 * The title to be displayed above this panel. It is also used as the text
21 * of the back button for any panel opened by this panel.
22 */
23 title?: React.ReactNode;
24}
25export interface PanelActions {
26 /**
27 * Call this method to programatically close this panel. If this is the only
28 * panel on the stack then this method will do nothing.
29 *
30 * Remember that the panel header always contains a "back" button that
31 * closes this panel on click (unless there is only one panel on the stack).
32 */
33 closePanel(): void;
34 /**
35 * Call this method to open a new panel on the top of the stack.
36 */
37 openPanel<P>(panel: Panel<P>): void;
38}
39/**
40 * Use this interface in your panel component's props type to access these
41 * panel action callbacks which are injected by `PanelStack2`.
42 *
43 * See the code example in the docs website.
44 *
45 * @see https://blueprintjs.com/docs/#core/components/panel-stack2
46 */
47export declare type PanelProps<P> = P & PanelActions;