UNPKG

4.41 kBTypeScriptView Raw
1import { SplitLayout } from './splitlayout';
2import { Title } from './title';
3import { Widget } from './widget';
4/**
5 * A layout which arranges its widgets into collapsible resizable sections.
6 */
7export declare class AccordionLayout extends SplitLayout {
8 /**
9 * Construct a new accordion layout.
10 *
11 * @param options - The options for initializing the layout.
12 *
13 * #### Notes
14 * The default orientation will be vertical.
15 *
16 * Titles must be rotated for horizontal accordion panel using CSS: see accordionpanel.css
17 */
18 constructor(options: AccordionLayout.IOptions);
19 /**
20 * The section title height or width depending on the orientation.
21 */
22 get titleSpace(): number;
23 set titleSpace(value: number);
24 /**
25 * A read-only array of the section titles in the panel.
26 */
27 get titles(): ReadonlyArray<HTMLElement>;
28 /**
29 * Dispose of the resources held by the layout.
30 */
31 dispose(): void;
32 /**
33 * The renderer used by the accordion layout.
34 */
35 readonly renderer: AccordionLayout.IRenderer;
36 updateTitle(index: number, widget: Widget): void;
37 /**
38 * Insert a widget into the layout at the specified index.
39 *
40 * @param index - The index at which to insert the widget.
41 *
42 * @param widget - The widget to insert into the layout.
43 *
44 * #### Notes
45 * The index will be clamped to the bounds of the widgets.
46 *
47 * If the widget is already added to the layout, it will be moved.
48 *
49 * #### Undefined Behavior
50 * An `index` which is non-integral.
51 */
52 insertWidget(index: number, widget: Widget): void;
53 /**
54 * Attach a widget to the parent's DOM node.
55 *
56 * @param index - The current index of the widget in the layout.
57 *
58 * @param widget - The widget to attach to the parent.
59 */
60 protected attachWidget(index: number, widget: Widget): void;
61 /**
62 * Move a widget in the parent's DOM node.
63 *
64 * @param fromIndex - The previous index of the widget in the layout.
65 *
66 * @param toIndex - The current index of the widget in the layout.
67 *
68 * @param widget - The widget to move in the parent.
69 */
70 protected moveWidget(fromIndex: number, toIndex: number, widget: Widget): void;
71 /**
72 * Detach a widget from the parent's DOM node.
73 *
74 * @param index - The previous index of the widget in the layout.
75 *
76 * @param widget - The widget to detach from the parent.
77 *
78 * #### Notes
79 * This is a reimplementation of the superclass method.
80 */
81 protected detachWidget(index: number, widget: Widget): void;
82 /**
83 * Update the item position.
84 *
85 * @param i Item index
86 * @param isHorizontal Whether the layout is horizontal or not
87 * @param left Left position in pixels
88 * @param top Top position in pixels
89 * @param height Item height
90 * @param width Item width
91 * @param size Item size
92 */
93 protected updateItemPosition(i: number, isHorizontal: boolean, left: number, top: number, height: number, width: number, size: number): void;
94 private _titles;
95}
96export declare namespace AccordionLayout {
97 /**
98 * A type alias for a accordion layout orientation.
99 */
100 type Orientation = SplitLayout.Orientation;
101 /**
102 * A type alias for a accordion layout alignment.
103 */
104 type Alignment = SplitLayout.Alignment;
105 /**
106 * An options object for initializing a accordion layout.
107 */
108 interface IOptions extends SplitLayout.IOptions {
109 /**
110 * The renderer to use for the accordion layout.
111 */
112 renderer: IRenderer;
113 /**
114 * The section title height or width depending on the orientation.
115 *
116 * The default is `22`.
117 */
118 titleSpace?: number;
119 }
120 /**
121 * A renderer for use with an accordion layout.
122 */
123 interface IRenderer extends SplitLayout.IRenderer {
124 /**
125 * Common class name for all accordion titles.
126 */
127 readonly titleClassName: string;
128 /**
129 * Render the element for a section title.
130 *
131 * @param data - The data to use for rendering the section title.
132 *
133 * @returns A element representing the section title.
134 */
135 createSectionTitle(title: Title<Widget>): HTMLElement;
136 }
137}