1 | import { ISignal } from '@lumino/signaling';
|
2 | import { StackedPanel } from './stackedpanel';
|
3 | import { TabBar } from './tabbar';
|
4 | import { Widget } from './widget';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export declare class TabPanel extends Widget {
|
17 | |
18 |
|
19 |
|
20 |
|
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 | get 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 | get currentIndex(): number;
|
42 | /**
|
43 | * Set the index of the currently selected tab.
|
44 | *
|
45 | * #### Notes
|
46 | * If the index is out of range, it will be set to `-1`.
|
47 | */
|
48 | set currentIndex(value: number);
|
49 | /**
|
50 | * Get the currently selected widget.
|
51 | *
|
52 | * #### Notes
|
53 | * This will be `null` if there is no selected tab.
|
54 | */
|
55 | get currentWidget(): Widget | null;
|
56 | /**
|
57 | * Set the currently selected widget.
|
58 | *
|
59 | * #### Notes
|
60 | * If the widget is not in the panel, it will be set to `null`.
|
61 | */
|
62 | set currentWidget(value: Widget | null);
|
63 | /**
|
64 | * Get the whether the tabs are movable by the user.
|
65 | *
|
66 | * #### Notes
|
67 | * Tabs can always be moved programmatically.
|
68 | */
|
69 | get tabsMovable(): boolean;
|
70 | /**
|
71 | * Set the whether the tabs are movable by the user.
|
72 | *
|
73 | * #### Notes
|
74 | * Tabs can always be moved programmatically.
|
75 | */
|
76 | set tabsMovable(value: boolean);
|
77 | /**
|
78 | * Get the whether the add button is enabled.
|
79 | *
|
80 | */
|
81 | get addButtonEnabled(): boolean;
|
82 | /**
|
83 | * Set the whether the add button is enabled.
|
84 | *
|
85 | */
|
86 | set addButtonEnabled(value: boolean);
|
87 | /**
|
88 | * Get the tab placement for the tab panel.
|
89 | *
|
90 | * #### Notes
|
91 | * This controls the position of the tab bar relative to the content.
|
92 | */
|
93 | get tabPlacement(): TabPanel.TabPlacement;
|
94 | /**
|
95 | * Set the tab placement for the tab panel.
|
96 | *
|
97 | * #### Notes
|
98 | * This controls the position of the tab bar relative to the content.
|
99 | */
|
100 | set tabPlacement(value: TabPanel.TabPlacement);
|
101 | /**
|
102 | * A signal emitted when the add button on a tab bar is clicked.
|
103 | *
|
104 | */
|
105 | get addRequested(): ISignal<this, TabBar<Widget>>;
|
106 | /**
|
107 | * The tab bar used by the tab panel.
|
108 | *
|
109 | * #### Notes
|
110 | * Modifying the tab bar directly can lead to undefined behavior.
|
111 | */
|
112 | readonly tabBar: TabBar<Widget>;
|
113 | /**
|
114 | * The stacked panel used by the tab panel.
|
115 | *
|
116 | * #### Notes
|
117 | * Modifying the panel directly can lead to undefined behavior.
|
118 | */
|
119 | readonly stackedPanel: StackedPanel;
|
120 | /**
|
121 | * A read-only array of the widgets in the panel.
|
122 | */
|
123 | get widgets(): ReadonlyArray<Widget>;
|
124 | /**
|
125 | * Add a widget to the end of the tab panel.
|
126 | *
|
127 | * @param widget - The widget to add to the tab panel.
|
128 | *
|
129 | * #### Notes
|
130 | * If the widget is already contained in the panel, it will be moved.
|
131 | *
|
132 | * The widget's `title` is used to populate the tab.
|
133 | */
|
134 | addWidget(widget: Widget): void;
|
135 | /**
|
136 | * Insert a widget into the tab panel at a specified index.
|
137 | *
|
138 | * @param index - The index at which to insert the widget.
|
139 | *
|
140 | * @param widget - The widget to insert into to the tab panel.
|
141 | *
|
142 | * #### Notes
|
143 | * If the widget is already contained in the panel, it will be moved.
|
144 | *
|
145 | * The widget's `title` is used to populate the tab.
|
146 | */
|
147 | insertWidget(index: number, widget: Widget): void;
|
148 | /**
|
149 | * Handle the `currentChanged` signal from the tab bar.
|
150 | */
|
151 | private _onCurrentChanged;
|
152 | /**
|
153 | * Handle the `tabAddRequested` signal from the tab bar.
|
154 | */
|
155 | private _onTabAddRequested;
|
156 | /**
|
157 | * Handle the `tabActivateRequested` signal from the tab bar.
|
158 | */
|
159 | private _onTabActivateRequested;
|
160 | /**
|
161 | * Handle the `tabCloseRequested` signal from the tab bar.
|
162 | */
|
163 | private _onTabCloseRequested;
|
164 | /**
|
165 | * Handle the `tabMoved` signal from the tab bar.
|
166 | */
|
167 | private _onTabMoved;
|
168 | /**
|
169 | * Handle the `widgetRemoved` signal from the stacked panel.
|
170 | */
|
171 | private _onWidgetRemoved;
|
172 | private _tabPlacement;
|
173 | private _currentChanged;
|
174 | private _addRequested;
|
175 | }
|
176 | /**
|
177 | * The namespace for the `TabPanel` class statics.
|
178 | */
|
179 | export declare namespace TabPanel {
|
180 | |
181 |
|
182 |
|
183 | type TabPlacement = |
184 |
|
185 | 'top'
|
186 | |
187 |
|
188 |
|
189 | | 'left'
|
190 | |
191 |
|
192 |
|
193 | | 'right'
|
194 | |
195 |
|
196 |
|
197 | | 'bottom';
|
198 | |
199 |
|
200 |
|
201 | interface IOptions {
|
202 | |
203 |
|
204 |
|
205 |
|
206 |
|
207 | document?: Document | ShadowRoot;
|
208 | |
209 |
|
210 |
|
211 |
|
212 |
|
213 | tabsMovable?: boolean;
|
214 | |
215 |
|
216 |
|
217 |
|
218 |
|
219 | addButtonEnabled?: boolean;
|
220 | |
221 |
|
222 |
|
223 |
|
224 |
|
225 | tabPlacement?: TabPlacement;
|
226 | |
227 |
|
228 |
|
229 |
|
230 |
|
231 | renderer?: TabBar.IRenderer<Widget>;
|
232 | }
|
233 | |
234 |
|
235 |
|
236 | interface ICurrentChangedArgs {
|
237 | |
238 |
|
239 |
|
240 | previousIndex: number;
|
241 | |
242 |
|
243 |
|
244 | previousWidget: Widget | null;
|
245 | |
246 |
|
247 |
|
248 | currentIndex: number;
|
249 | |
250 |
|
251 |
|
252 | currentWidget: Widget | null;
|
253 | }
|
254 | }
|