UNPKG

7.01 kBTypeScriptView Raw
1import { ISignal } from '@lumino/signaling';
2import { StackedPanel } from './stackedpanel';
3import { TabBar } from './tabbar';
4import { Widget } from './widget';
5/**
6 * A widget which combines a `TabBar` and a `StackedPanel`.
7 *
8 * #### Notes
9 * This is a simple panel which handles the common case of a tab bar
10 * placed next to a content area. The selected tab controls the widget
11 * which is shown in the content area.
12 *
13 * For use cases which require more control than is provided by this
14 * panel, the `TabBar` widget may be used independently.
15 */
16export declare class TabPanel extends Widget {
17 /**
18 * Construct a new tab panel.
19 *
20 * @param options - The options for initializing the tab panel.
21 */
22 constructor(options?: TabPanel.IOptions);
23 /**
24 * A signal emitted when the current tab is changed.
25 *
26 * #### Notes
27 * This signal is emitted when the currently selected tab is changed
28 * either through user or programmatic interaction.
29 *
30 * Notably, this signal is not emitted when the index of the current
31 * tab changes due to tabs being inserted, removed, or moved. It is
32 * only emitted when the actual current tab node is changed.
33 */
34 readonly currentChanged: ISignal<this, TabPanel.ICurrentChangedArgs>;
35 /**
36 * Get the index of the currently selected tab.
37 *
38 * #### Notes
39 * This will be `-1` if no tab is selected.
40 */
41 /**
42 * Set the index of the currently selected tab.
43 *
44 * #### Notes
45 * If the index is out of range, it will be set to `-1`.
46 */
47 currentIndex: number;
48 /**
49 * Get the currently selected widget.
50 *
51 * #### Notes
52 * This will be `null` if there is no selected tab.
53 */
54 /**
55 * Set the currently selected widget.
56 *
57 * #### Notes
58 * If the widget is not in the panel, it will be set to `null`.
59 */
60 currentWidget: Widget | null;
61 /**
62 * Get the whether the tabs are movable by the user.
63 *
64 * #### Notes
65 * Tabs can always be moved programmatically.
66 */
67 /**
68 * Set the whether the tabs are movable by the user.
69 *
70 * #### Notes
71 * Tabs can always be moved programmatically.
72 */
73 tabsMovable: boolean;
74 /**
75 * Get the whether the add button is enabled.
76 *
77 */
78 /**
79 * Set the whether the add button is enabled.
80 *
81 */
82 addButtonEnabled: boolean;
83 /**
84 * Get the tab placement for the tab panel.
85 *
86 * #### Notes
87 * This controls the position of the tab bar relative to the content.
88 */
89 /**
90 * Set the tab placement for the tab panel.
91 *
92 * #### Notes
93 * This controls the position of the tab bar relative to the content.
94 */
95 tabPlacement: TabPanel.TabPlacement;
96 /**
97 * A signal emitted when the add button on a tab bar is clicked.
98 *
99 */
100 readonly addRequested: ISignal<this, TabBar<Widget>>;
101 /**
102 * The tab bar used by the tab panel.
103 *
104 * #### Notes
105 * Modifying the tab bar directly can lead to undefined behavior.
106 */
107 readonly tabBar: TabBar<Widget>;
108 /**
109 * The stacked panel used by the tab panel.
110 *
111 * #### Notes
112 * Modifying the panel directly can lead to undefined behavior.
113 */
114 readonly stackedPanel: StackedPanel;
115 /**
116 * A read-only array of the widgets in the panel.
117 */
118 readonly widgets: ReadonlyArray<Widget>;
119 /**
120 * Add a widget to the end of the tab panel.
121 *
122 * @param widget - The widget to add to the tab panel.
123 *
124 * #### Notes
125 * If the widget is already contained in the panel, it will be moved.
126 *
127 * The widget's `title` is used to populate the tab.
128 */
129 addWidget(widget: Widget): void;
130 /**
131 * Insert a widget into the tab panel at a specified index.
132 *
133 * @param index - The index at which to insert the widget.
134 *
135 * @param widget - The widget to insert into to the tab panel.
136 *
137 * #### Notes
138 * If the widget is already contained in the panel, it will be moved.
139 *
140 * The widget's `title` is used to populate the tab.
141 */
142 insertWidget(index: number, widget: Widget): void;
143 /**
144 * Handle the `currentChanged` signal from the tab bar.
145 */
146 private _onCurrentChanged;
147 /**
148 * Handle the `tabAddRequested` signal from the tab bar.
149 */
150 private _onTabAddRequested;
151 /**
152 * Handle the `tabActivateRequested` signal from the tab bar.
153 */
154 private _onTabActivateRequested;
155 /**
156 * Handle the `tabCloseRequested` signal from the tab bar.
157 */
158 private _onTabCloseRequested;
159 /**
160 * Handle the `tabMoved` signal from the tab bar.
161 */
162 private _onTabMoved;
163 /**
164 * Handle the `widgetRemoved` signal from the stacked panel.
165 */
166 private _onWidgetRemoved;
167 private _tabPlacement;
168 private _currentChanged;
169 private _addRequested;
170}
171/**
172 * The namespace for the `TabPanel` class statics.
173 */
174export declare namespace TabPanel {
175 /**
176 * A type alias for tab placement in a tab bar.
177 */
178 type TabPlacement = /**
179 * The tabs are placed as a row above the content.
180 */ 'top'
181 /**
182 * The tabs are placed as a column to the left of the content.
183 */
184 | 'left'
185 /**
186 * The tabs are placed as a column to the right of the content.
187 */
188 | 'right'
189 /**
190 * The tabs are placed as a row below the content.
191 */
192 | 'bottom';
193 /**
194 * An options object for initializing a tab panel.
195 */
196 interface IOptions {
197 /**
198 * The document to use with the tab panel.
199 *
200 * The default is the global `document` instance.
201 */
202 document?: Document | ShadowRoot;
203 /**
204 * Whether the tabs are movable by the user.
205 *
206 * The default is `false`.
207 */
208 tabsMovable?: boolean;
209 /**
210 * Whether the button to add new tabs is enabled.
211 *
212 * The default is `false`.
213 */
214 addButtonEnabled?: boolean;
215 /**
216 * The placement of the tab bar relative to the content.
217 *
218 * The default is `'top'`.
219 */
220 tabPlacement?: TabPlacement;
221 /**
222 * The renderer for the panel's tab bar.
223 *
224 * The default is a shared renderer instance.
225 */
226 renderer?: TabBar.IRenderer<Widget>;
227 }
228 /**
229 * The arguments object for the `currentChanged` signal.
230 */
231 interface ICurrentChangedArgs {
232 /**
233 * The previously selected index.
234 */
235 previousIndex: number;
236 /**
237 * The previously selected widget.
238 */
239 previousWidget: Widget | null;
240 /**
241 * The currently selected index.
242 */
243 currentIndex: number;
244 /**
245 * The currently selected widget.
246 */
247 currentWidget: Widget | null;
248 }
249}
250//# sourceMappingURL=tabpanel.d.ts.map
\No newline at end of file