Debian Codegraph @

jupyter-widgets-controls/lib/lumino/currentselection.d.ts

raw
1 import { ISignal } from '@lumino/signaling';
2 export declare class Selection<T> {
3 constructor(sequence: ReadonlyArray<T>, options?: Selection.IOptions);
4 /**
5 * A signal emitted when the current item is changed.
6 *
7 * #### Notes
8 * This signal is emitted when the currently selected item is changed either
9 * through user or programmatic interaction.
10 *
11 * Notably, this signal is not emitted when the index of the current item
12 * changes due to other items being inserted, removed, or moved, but the
13 * current item remains the same. It is only emitted when the actual current
14 * item is changed.
15 */
16 get selectionChanged(): ISignal<Selection<T>, Selection.ISelectionChangedArgs<T>>;
17 /**
18 * Adjust for setting an item.
19 *
20 * This should be called *after* the set.
21 *
22 * @param index - The index set.
23 * @param oldValue - The old value at the index.
24 */
25 adjustSelectionForSet(index: number): void;
26 /**
27 * Get the currently selected item.
28 *
29 * #### Notes
30 * This will be `null` if no item is selected.
31 */
32 get value(): T | null;
33 /**
34 * Set the currently selected item.
35 *
36 * #### Notes
37 * If the item does not exist in the vector, the currentValue will be set to
38 * `null`. This selects the first entry equal to the desired item.
39 */
40 set value(value: T | null);
41 /**
42 * Get the index of the currently selected item.
43 *
44 * #### Notes
45 * This will be `null` if no item is selected.
46 */
47 get index(): number | null;
48 /**
49 * Set the index of the currently selected tab.
50 *
51 * @param index - The index to select.
52 *
53 * #### Notes
54 * If the value is out of range, the index will be set to `null`, which
55 * indicates no item is selected.
56 */
57 set index(index: number | null);
58 /**
59 * Get the selection behavior when inserting a tab.
60 */
61 get insertBehavior(): Selection.InsertBehavior;
62 /**
63 * Set the selection behavior when inserting a tab.
64 */
65 set insertBehavior(value: Selection.InsertBehavior);
66 /**
67 * Get the selection behavior when removing a tab.
68 */
69 get removeBehavior(): Selection.RemoveBehavior;
70 /**
71 * Set the selection behavior when removing a tab.
72 */
73 set removeBehavior(value: Selection.RemoveBehavior);
74 /**
75 * Adjust the current index for a tab insert operation.
76 *
77 * @param i - The new index of the inserted item.
78 * @param j - The inserted item.
79 *
80 * #### Notes
81 * This method accounts for the tab bar's insertion behavior when adjusting
82 * the current index and emitting the changed signal. This should be called
83 * after the insertion.
84 */
85 adjustSelectionForInsert(i: number, item: T): void;
86 /**
87 * Clear the selection and history.
88 */
89 clearSelection(): void;
90 /**
91 * Adjust the current index for an item remove operation.
92 *
93 * @param i - The former index of the removed item.
94 * @param item - The removed item.
95 *
96 * #### Notes
97 * This method accounts for the remove behavior when adjusting the current
98 * index and emitting the changed signal. It should be called after the item
99 * is removed.
100 */
101 adjustSelectionForRemove(i: number, item: T | null): void;
102 /**
103 * Set the current value based on the current index.
104 */
105 private _updateSelectedValue;
106 private _array;
107 private _index;
108 private _value;
109 private _previousValue;
110 private _insertBehavior;
111 private _removeBehavior;
112 private _selectionChanged;
113 }
114 export declare namespace Selection {
115 /**
116 * An options object for creating a tab bar.
117 */
118 interface IOptions {
119 /**
120 * The selection behavior when inserting a tab.
121 *
122 * The default is `'select-tab-if-needed'`.
123 */
124 insertBehavior?: Selection.InsertBehavior;
125 /**
126 * The selection behavior when removing a tab.
127 *
128 * The default is `'select-tab-after'`.
129 */
130 removeBehavior?: Selection.RemoveBehavior;
131 }
132 /**
133 * The arguments object for the `currentChanged` signal.
134 */
135 interface ISelectionChangedArgs<T> {
136 /**
137 * The previously selected index.
138 */
139 previousIndex: number | null;
140 /**
141 * The previous selected item.
142 */
143 previousValue: T | null;
144 /**
145 * The currently selected index.
146 */
147 currentIndex: number | null;
148 /**
149 * The currently selected item.
150 */
151 currentValue: T | null;
152 }
153 /**
154 * A type alias for the selection behavior on item insert.
155 */
156 type InsertBehavior =
157 /**
158 * The selected item will not be changed.
159 */
160 'none'
161 /**
162 * The inserted item will be selected.
163 */
164 | 'select-item'
165 /**
166 * The inserted item will be selected if the current item is null.
167 */
168 | 'select-item-if-needed';
169 /**
170 * A type alias for the selection behavior on item remove.
171 */
172 type RemoveBehavior =
173 /**
174 * No item will be selected.
175 */
176 'none'
177 /**
178 * The item after the removed item will be selected if possible.
179 */
180 | 'select-item-after'
181 /**
182 * The item before the removed item will be selected if possible.
183 */
184 | 'select-item-before'
185 /**
186 * The previously selected item will be selected if possible.
187 */
188 | 'select-previous-item';
189 }
190 //# sourceMappingURL=currentselection.d.ts.map