UNPKG

6.25 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 * Collapse the widget at position `index`.
46 *
47 * #### Notes
48 * If no widget is found for `index`, this will bail.
49 *
50 * @param index Widget index
51 */
52 collapse(index: number): void;
53 /**
54 * Expand the widget at position `index`.
55 *
56 * #### Notes
57 * If no widget is found for `index`, this will bail.
58 *
59 * @param index Widget index
60 */
61 expand(index: number): void;
62 /**
63 * Insert a widget at the specified index.
64 *
65 * @param index - The index at which to insert the widget.
66 *
67 * @param widget - The widget to insert into to the panel.
68 *
69 * #### Notes
70 * If the widget is already contained in the panel, it will be moved.
71 */
72 insertWidget(index: number, widget: Widget): void;
73 /**
74 * Handle the DOM events for the accordion panel.
75 *
76 * @param event - The DOM event sent to the panel.
77 *
78 * #### Notes
79 * This method implements the DOM `EventListener` interface and is
80 * called in response to events on the panel's DOM node. It should
81 * not be called directly by user code.
82 */
83 handleEvent(event: Event): void;
84 /**
85 * A message handler invoked on a `'before-attach'` message.
86 */
87 protected onBeforeAttach(msg: Message): void;
88 /**
89 * A message handler invoked on an `'after-detach'` message.
90 */
91 protected onAfterDetach(msg: Message): void;
92 /**
93 * Handle the `changed` signal of a title object.
94 */
95 private _onTitleChanged;
96 /**
97 * Compute the size of widgets in this panel on the title click event.
98 * On closing, the size of the widget is cached and we will try to expand
99 * the last opened widget.
100 * On opening, we will use the cached size if it is available to restore the
101 * widget.
102 * In both cases, if we can not compute the size of widgets, we will let
103 * `SplitLayout` decide.
104 *
105 * @param index - The index of widget to be opened of closed
106 *
107 * @returns Relative size of widgets in this panel, if this size can
108 * not be computed, return `undefined`
109 */
110 private _computeWidgetSize;
111 /**
112 * Handle the `'click'` event for the accordion panel
113 */
114 private _evtClick;
115 /**
116 * Handle the `'keydown'` event for the accordion panel.
117 */
118 private _eventKeyDown;
119 private _toggleExpansion;
120 private _widgetSizesCache;
121}
122/**
123 * The namespace for the `AccordionPanel` class statics.
124 */
125export declare namespace AccordionPanel {
126 /**
127 * A type alias for a accordion panel orientation.
128 */
129 type Orientation = SplitLayout.Orientation;
130 /**
131 * A type alias for a accordion panel alignment.
132 */
133 type Alignment = SplitLayout.Alignment;
134 /**
135 * A type alias for a accordion panel renderer.
136 */
137 type IRenderer = AccordionLayout.IRenderer;
138 /**
139 * An options object for initializing a accordion panel.
140 */
141 interface IOptions extends Partial<AccordionLayout.IOptions> {
142 /**
143 * The accordion layout to use for the accordion panel.
144 *
145 * If this is provided, the other options are ignored.
146 *
147 * The default is a new `AccordionLayout`.
148 */
149 layout?: AccordionLayout;
150 }
151 /**
152 * The default implementation of `IRenderer`.
153 */
154 class Renderer extends SplitPanel.Renderer implements IRenderer {
155 constructor();
156 /**
157 * A selector which matches any title node in the accordion.
158 */
159 readonly titleClassName = "lm-AccordionPanel-title";
160 /**
161 * Render the collapse indicator for a section title.
162 *
163 * @param data - The data to use for rendering the section title.
164 *
165 * @returns A element representing the collapse indicator.
166 */
167 createCollapseIcon(data: Title<Widget>): HTMLElement;
168 /**
169 * Render the element for a section title.
170 *
171 * @param data - The data to use for rendering the section title.
172 *
173 * @returns A element representing the section title.
174 */
175 createSectionTitle(data: Title<Widget>): HTMLElement;
176 /**
177 * Create a unique render key for the title.
178 *
179 * @param data - The data to use for the title.
180 *
181 * @returns The unique render key for the title.
182 *
183 * #### Notes
184 * This method caches the key against the section title the first time
185 * the key is generated.
186 */
187 createTitleKey(data: Title<Widget>): string;
188 private static _nInstance;
189 private readonly _uuid;
190 private _titleID;
191 private _titleKeys;
192 }
193 /**
194 * The default `Renderer` instance.
195 */
196 const defaultRenderer: Renderer;
197}
198//# sourceMappingURL=accordionpanel.d.ts.map
\No newline at end of file