UNPKG

5.69 kBTypeScriptView Raw
1import { Message } from '@lumino/messaging';
2import { AccordionLayout } from './accordionlayout';
3import { SplitLayout } from './splitlayout';
4import { SplitPanel } from './splitpanel';
5import { Title } from './title';
6import { Widget } from './widget';
7/**
8 * A panel which arranges its widgets into resizable sections separated by a title widget.
9 *
10 * #### Notes
11 * This class provides a convenience wrapper around [[AccordionLayout]].
12 */
13export declare class AccordionPanel extends SplitPanel {
14 /**
15 * Construct a new accordion panel.
16 *
17 * @param options - The options for initializing the accordion panel.
18 */
19 constructor(options?: AccordionPanel.IOptions);
20 /**
21 * The renderer used by the accordion panel.
22 */
23 readonly renderer: AccordionPanel.IRenderer;
24 /**
25 * The section title space.
26 *
27 * This is the height if the panel is vertical and the width if it is
28 * horizontal.
29 */
30 titleSpace: number;
31 /**
32 * A read-only array of the section titles in the panel.
33 */
34 readonly titles: ReadonlyArray<HTMLElement>;
35 /**
36 * Add a widget to the end of the panel.
37 *
38 * @param widget - The widget to add to the panel.
39 *
40 * #### Notes
41 * If the widget is already contained in the panel, it will be moved.
42 */
43 addWidget(widget: Widget): void;
44 /**
45 * Insert a widget at the specified index.
46 *
47 * @param index - The index at which to insert the widget.
48 *
49 * @param widget - The widget to insert into to the panel.
50 *
51 * #### Notes
52 * If the widget is already contained in the panel, it will be moved.
53 */
54 insertWidget(index: number, widget: Widget): void;
55 /**
56 * Handle the DOM events for the accordion panel.
57 *
58 * @param event - The DOM event sent to the panel.
59 *
60 * #### Notes
61 * This method implements the DOM `EventListener` interface and is
62 * called in response to events on the panel's DOM node. It should
63 * not be called directly by user code.
64 */
65 handleEvent(event: Event): void;
66 /**
67 * A message handler invoked on a `'before-attach'` message.
68 */
69 protected onBeforeAttach(msg: Message): void;
70 /**
71 * A message handler invoked on an `'after-detach'` message.
72 */
73 protected onAfterDetach(msg: Message): void;
74 /**
75 * Handle the `changed` signal of a title object.
76 */
77 private _onTitleChanged;
78 /**
79 * Compute the size of widgets in this panel on the title click event.
80 * On closing, the size of the widget is cached and we will try to expand
81 * the last opened widget.
82 * On opening, we will use the cached size if it is available to restore the
83 * widget.
84 * In both cases, if we can not compute the size of widgets, we will let
85 * `SplitLayout` decide.
86 *
87 * @param index - The index of widget to be opened of closed
88 *
89 * @returns Relative size of widgets in this panel, if this size can
90 * not be computed, return `undefined`
91 */
92 private _computeWidgetSize;
93 /**
94 * Handle the `'click'` event for the accordion panel
95 */
96 private _evtClick;
97 /**
98 * Handle the `'keydown'` event for the accordion panel.
99 */
100 private _eventKeyDown;
101 private _widgetSizesCache;
102}
103/**
104 * The namespace for the `AccordionPanel` class statics.
105 */
106export declare namespace AccordionPanel {
107 /**
108 * A type alias for a accordion panel orientation.
109 */
110 type Orientation = SplitLayout.Orientation;
111 /**
112 * A type alias for a accordion panel alignment.
113 */
114 type Alignment = SplitLayout.Alignment;
115 /**
116 * A type alias for a accordion panel renderer.
117 */
118 type IRenderer = AccordionLayout.IRenderer;
119 /**
120 * An options object for initializing a accordion panel.
121 */
122 interface IOptions extends Partial<AccordionLayout.IOptions> {
123 /**
124 * The accordion layout to use for the accordion panel.
125 *
126 * If this is provided, the other options are ignored.
127 *
128 * The default is a new `AccordionLayout`.
129 */
130 layout?: AccordionLayout;
131 }
132 /**
133 * The default implementation of `IRenderer`.
134 */
135 class Renderer extends SplitPanel.Renderer implements IRenderer {
136 /**
137 * A selector which matches any title node in the accordion.
138 */
139 readonly titleClassName = "lm-AccordionPanel-title";
140 /**
141 * Render the collapse indicator for a section title.
142 *
143 * @param data - The data to use for rendering the section title.
144 *
145 * @returns A element representing the collapse indicator.
146 */
147 createCollapseIcon(data: Title<Widget>): HTMLElement;
148 /**
149 * Render the element for a section title.
150 *
151 * @param data - The data to use for rendering the section title.
152 *
153 * @returns A element representing the section title.
154 */
155 createSectionTitle(data: Title<Widget>): HTMLElement;
156 /**
157 * Create a unique render key for the title.
158 *
159 * @param data - The data to use for the title.
160 *
161 * @returns The unique render key for the title.
162 *
163 * #### Notes
164 * This method caches the key against the section title the first time
165 * the key is generated.
166 */
167 createTitleKey(data: Title<Widget>): string;
168 private _titleID;
169 private _titleKeys;
170 }
171 /**
172 * The default `Renderer` instance.
173 */
174 const defaultRenderer: Renderer;
175}
176//# sourceMappingURL=accordionpanel.d.ts.map
\No newline at end of file