@jupyterlab/ui-components 4.0.0-alpha.27 → 4.0.0-alpha.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/components/button.js +2 -13
  2. package/lib/components/button.js.map +1 -1
  3. package/lib/components/htmlselect.js +10 -15
  4. package/lib/components/htmlselect.js.map +1 -1
  5. package/lib/components/iframe.d.ts +1 -1
  6. package/lib/components/iframe.js +1 -1
  7. package/lib/components/index.d.ts +2 -2
  8. package/lib/components/index.js +2 -2
  9. package/lib/components/index.js.map +1 -1
  10. package/lib/components/inputgroup.d.ts +4 -0
  11. package/lib/components/inputgroup.js +2 -13
  12. package/lib/components/inputgroup.js.map +1 -1
  13. package/lib/components/menu.js +1 -1
  14. package/lib/components/menu.js.map +1 -1
  15. package/lib/components/search.d.ts +21 -12
  16. package/lib/components/search.js +1 -1
  17. package/lib/components/search.js.map +1 -1
  18. package/lib/components/sidepanel.js +4 -1
  19. package/lib/components/sidepanel.js.map +1 -1
  20. package/lib/components/toolbar.d.ts +1 -2
  21. package/lib/components/toolbar.js +6 -9
  22. package/lib/components/toolbar.js.map +1 -1
  23. package/lib/components/windowedlist.d.ts +533 -0
  24. package/lib/components/windowedlist.js +957 -0
  25. package/lib/components/windowedlist.js.map +1 -0
  26. package/lib/hoverbox.d.ts +20 -2
  27. package/lib/hoverbox.js +146 -11
  28. package/lib/hoverbox.js.map +1 -1
  29. package/lib/icon/iconimports.d.ts +1 -1
  30. package/lib/icon/iconimports.js +2 -2
  31. package/lib/icon/iconimports.js.map +1 -1
  32. package/lib/icon/labicon.js +25 -31
  33. package/lib/icon/labicon.js.map +1 -1
  34. package/lib/icon/widgets/commandpalettesvg.js +1 -13
  35. package/lib/icon/widgets/commandpalettesvg.js.map +1 -1
  36. package/lib/icon/widgets/menusvg.js +1 -12
  37. package/lib/icon/widgets/menusvg.js.map +1 -1
  38. package/lib/icon/widgets/tabbarsvg.d.ts +7 -15
  39. package/lib/icon/widgets/tabbarsvg.js +12 -6
  40. package/lib/icon/widgets/tabbarsvg.js.map +1 -1
  41. package/lib/style/icon.js +16 -15
  42. package/lib/style/icon.js.map +1 -1
  43. package/package.json +16 -15
  44. package/style/base.css +1 -0
  45. package/style/deprecated.css +5 -5
  46. package/style/icons/filetype/python.svg +3 -5
  47. package/style/icons/{listings/listings-info.svg → info.svg} +4 -4
  48. package/style/iframe.css +1 -1
  49. package/style/sidepanel.css +4 -0
  50. package/style/windowedlist.css +20 -0
  51. package/lib/components/collapse.d.ts +0 -19
  52. package/lib/components/collapse.js +0 -28
  53. package/lib/components/collapse.js.map +0 -1
@@ -0,0 +1,533 @@
1
+ import { IChangedArgs } from '@jupyterlab/coreutils';
2
+ import { IObservableList } from '@jupyterlab/observables';
3
+ import { IDisposable } from '@lumino/disposable';
4
+ import { Message } from '@lumino/messaging';
5
+ import { ISignal, Signal } from '@lumino/signaling';
6
+ import { PanelLayout, Widget } from '@lumino/widgets';
7
+ /**
8
+ * Windowed list abstract model.
9
+ */
10
+ export declare abstract class WindowedListModel implements WindowedList.IModel {
11
+ /**
12
+ * Constructor
13
+ *
14
+ * @param options Constructor options
15
+ */
16
+ constructor(options?: WindowedList.IModelOptions);
17
+ /**
18
+ * Provide a best guess for the widget size at position index
19
+ *
20
+ * #### Notes
21
+ *
22
+ * This function should be very light to compute especially when
23
+ * returning the default size.
24
+ * The default value should be constant (i.e. two calls with `null` should
25
+ * return the same value). But it can change for a given `index`.
26
+ *
27
+ * @param index Widget position
28
+ * @returns Estimated widget size
29
+ */
30
+ abstract estimateWidgetSize: (index: number) => number;
31
+ /**
32
+ * Widget factory for the list items.
33
+ *
34
+ * Caching the resulting widgets should be done by the callee.
35
+ *
36
+ * @param index List index
37
+ * @returns The widget at the given position
38
+ */
39
+ abstract widgetRenderer: (index: number) => Widget;
40
+ /**
41
+ * List widget height
42
+ */
43
+ get height(): number;
44
+ set height(h: number);
45
+ /**
46
+ * Test whether the model is disposed.
47
+ */
48
+ get isDisposed(): boolean;
49
+ /**
50
+ * Items list to be rendered
51
+ */
52
+ get itemsList(): IObservableList<any> | null;
53
+ set itemsList(v: IObservableList<any> | null);
54
+ /**
55
+ * Number of widgets to render in addition to those
56
+ * visible in the viewport.
57
+ */
58
+ get overscanCount(): number;
59
+ set overscanCount(newValue: number);
60
+ /**
61
+ * Viewport scroll offset.
62
+ */
63
+ get scrollOffset(): number;
64
+ set scrollOffset(offset: number);
65
+ /**
66
+ * Total number of widgets in the list
67
+ */
68
+ get widgetCount(): number;
69
+ set widgetCount(newValue: number);
70
+ /**
71
+ * Whether windowing is active or not.
72
+ *
73
+ * This is true by default.
74
+ */
75
+ get windowingActive(): boolean;
76
+ set windowingActive(newValue: boolean);
77
+ /**
78
+ * A signal emitted when any model state changes.
79
+ */
80
+ get stateChanged(): ISignal<WindowedListModel, IChangedArgs<any, any, 'count' | 'index' | 'list' | 'overscanCount' | 'windowingActive'>>;
81
+ /**
82
+ * Dispose the model.
83
+ */
84
+ dispose(): void;
85
+ /**
86
+ * Get the total list size.
87
+ *
88
+ * @returns Total estimated size
89
+ */
90
+ getEstimatedTotalSize(): number;
91
+ /**
92
+ * Get the scroll offset to display an item in the viewport.
93
+ *
94
+ * @param index Item index
95
+ * @param align Where to align the item in the viewport
96
+ * @returns The needed scroll offset
97
+ */
98
+ getOffsetForIndexAndAlignment(index: number, align?: WindowedList.ScrollToAlign): number;
99
+ /**
100
+ * Compute the items range to display.
101
+ *
102
+ * It returns ``null`` if the range does not need to be updated.
103
+ *
104
+ * @returns The current items range to display
105
+ */
106
+ getRangeToRender(): WindowedList.WindowIndex | null;
107
+ /**
108
+ * Return the viewport top position and height for range spanning from
109
+ * ``startIndex`` to ``stopIndex``.
110
+ *
111
+ * @param startIndex First item in viewport index
112
+ * @param stopIndex Last item in viewport index
113
+ * @returns The viewport top position and its height
114
+ */
115
+ getSpan(startIndex: number, stopIndex: number): [number, number];
116
+ /**
117
+ * WindowedListModel caches offsets and measurements for each index for performance purposes.
118
+ * This method clears that cached data for all items after (and including) the specified index.
119
+ *
120
+ * The list will automatically re-render after the index is reset.
121
+ *
122
+ * @param index
123
+ */
124
+ resetAfterIndex(index: number): void;
125
+ /**
126
+ * Update item sizes.
127
+ *
128
+ * This should be called when the real item sizes has been
129
+ * measured.
130
+ *
131
+ * @param sizes New sizes per item index
132
+ * @returns Whether some sizes changed or not
133
+ */
134
+ setWidgetSize(sizes: {
135
+ index: number;
136
+ size: number;
137
+ }[]): boolean;
138
+ /**
139
+ * Callback on list changes
140
+ *
141
+ * @param list List items
142
+ * @param changes List change
143
+ */
144
+ protected onListChanged(list: IObservableList<Widget>, changes: IObservableList.IChangedArgs<Widget>): void;
145
+ private _getItemMetadata;
146
+ private _findNearestItem;
147
+ private _findNearestItemBinarySearch;
148
+ private _findNearestItemExponentialSearch;
149
+ private _getRangeToRender;
150
+ private _getStartIndexForOffset;
151
+ private _getStopIndexForStartIndex;
152
+ /**
153
+ * Default widget size estimation
154
+ */
155
+ protected _estimatedWidgetSize: number;
156
+ protected _stateChanged: Signal<WindowedListModel, IChangedArgs<any, any, "list" | "count" | "index" | "overscanCount" | "windowingActive">>;
157
+ private _currentWindow;
158
+ private _height;
159
+ private _isDisposed;
160
+ private _itemsList;
161
+ private _lastMeasuredIndex;
162
+ private _overscanCount;
163
+ private _scrollOffset;
164
+ private _widgetCount;
165
+ private _widgetSizers;
166
+ private _windowingActive;
167
+ }
168
+ /**
169
+ * Windowed list widget
170
+ */
171
+ export declare class WindowedList<T extends WindowedList.IModel = WindowedList.IModel> extends Widget {
172
+ /**
173
+ * Default widget size
174
+ */
175
+ static readonly DEFAULT_WIDGET_SIZE = 50;
176
+ /**
177
+ * Constructor
178
+ *
179
+ * @param options Constructor options
180
+ */
181
+ constructor(options: WindowedList.IOptions<T>);
182
+ /**
183
+ * Widget layout
184
+ */
185
+ get layout(): WindowedLayout;
186
+ /**
187
+ * Viewport
188
+ */
189
+ get viewportNode(): HTMLDivElement;
190
+ /**
191
+ * Windowed list view model
192
+ */
193
+ protected get viewModel(): T;
194
+ /**
195
+ * Callback on event.
196
+ *
197
+ * @param event Event
198
+ */
199
+ handleEvent(event: Event): void;
200
+ /**
201
+ * Scroll to the specified offset `scrollTop`.
202
+ *
203
+ * @param scrollOffset Offset to scroll
204
+ *
205
+ * @deprecated This is an internal helper. Prefer calling `scrollToItem`.
206
+ */
207
+ scrollTo(scrollOffset: number): void;
208
+ /**
209
+ * Scroll to the specified item.
210
+ *
211
+ * By default, the List will scroll as little as possible to ensure the item is visible. You can control the alignment of the item though by specifying a second alignment parameter. Acceptable values are:
212
+ *
213
+ * auto (default) - Scroll as little as possible to ensure the item is visible. (If the item is already visible, it won't scroll at all.)
214
+ * smart - If the item is already visible, don't scroll at all. If it is less than one viewport away, scroll as little as possible so that it becomes visible. If it is more than one viewport away, scroll so that it is centered within the list.
215
+ * center - Center align the item within the list.
216
+ * end - Align the item to the end of the list
217
+ * start - Align the item to the beginning of the list
218
+ *
219
+ * @param index Item index to scroll to
220
+ * @param align Type of alignment
221
+ */
222
+ scrollToItem(index: number, align?: WindowedList.ScrollToAlign): Promise<void>;
223
+ /**
224
+ * A message handler invoked on an `'after-attach'` message.
225
+ */
226
+ protected onAfterAttach(msg: Message): void;
227
+ /**
228
+ * A message handler invoked on an `'before-detach'` message.
229
+ */
230
+ protected onBeforeDetach(msg: Message): void;
231
+ /**
232
+ * Callback on scroll event
233
+ *
234
+ * @param event Scroll event
235
+ */
236
+ protected onScroll(event: Event): void;
237
+ /**
238
+ * A message handler invoked on an `'resize-request'` message.
239
+ */
240
+ protected onResize(msg: Widget.ResizeMessage): void;
241
+ /**
242
+ * Callback on view model change
243
+ *
244
+ * @param model Windowed list model
245
+ * @param changes Change
246
+ */
247
+ protected onStateChanged(model: WindowedList.IModel, changes: IChangedArgs<number | boolean, number | boolean, string>): void;
248
+ /**
249
+ * A message handler invoked on an `'update-request'` message.
250
+ *
251
+ * #### Notes
252
+ * The default implementation of this handler is a no-op.
253
+ */
254
+ protected onUpdateRequest(msg: Message): void;
255
+ private _addListeners;
256
+ private _removeListeners;
257
+ private _update;
258
+ private _onWidgetResize;
259
+ private _resetScrollToItem;
260
+ protected _viewModel: T;
261
+ private _innerElement;
262
+ private _isScrolling;
263
+ private _windowElement;
264
+ private _resetScrollToItemTimeout;
265
+ private _resizeObserver;
266
+ private _scrollRepaint;
267
+ private _scrollToItem;
268
+ private _scrollUpdateWasRequested;
269
+ }
270
+ /**
271
+ * Customized layout for windowed list container.
272
+ */
273
+ export declare class WindowedLayout extends PanelLayout {
274
+ /**
275
+ * Constructor
276
+ */
277
+ constructor();
278
+ /**
279
+ * Specialized parent type definition
280
+ */
281
+ get parent(): WindowedList | null;
282
+ set parent(value: WindowedList | null);
283
+ /**
284
+ * Attach a widget to the parent's DOM node.
285
+ *
286
+ * @param index - The current index of the widget in the layout.
287
+ *
288
+ * @param widget - The widget to attach to the parent.
289
+ *
290
+ * #### Notes
291
+ * This method is called automatically by the panel layout at the
292
+ * appropriate time. It should not be called directly by user code.
293
+ *
294
+ * The default implementation adds the widgets's node to the parent's
295
+ * node at the proper location, and sends the appropriate attach
296
+ * messages to the widget if the parent is attached to the DOM.
297
+ *
298
+ * Subclasses may reimplement this method to control how the widget's
299
+ * node is added to the parent's node.
300
+ */
301
+ protected attachWidget(index: number, widget: Widget): void;
302
+ /**
303
+ * Detach a widget from the parent's DOM node.
304
+ *
305
+ * @param index - The previous index of the widget in the layout.
306
+ *
307
+ * @param widget - The widget to detach from the parent.
308
+ *
309
+ * #### Notes
310
+ * This method is called automatically by the panel layout at the
311
+ * appropriate time. It should not be called directly by user code.
312
+ *
313
+ * The default implementation removes the widget's node from the
314
+ * parent's node, and sends the appropriate detach messages to the
315
+ * widget if the parent is attached to the DOM.
316
+ *
317
+ * Subclasses may reimplement this method to control how the widget's
318
+ * node is removed from the parent's node.
319
+ */
320
+ protected detachWidget(index: number, widget: Widget): void;
321
+ /**
322
+ * Move a widget in the parent's DOM node.
323
+ *
324
+ * @param fromIndex - The previous index of the widget in the layout.
325
+ *
326
+ * @param toIndex - The current index of the widget in the layout.
327
+ *
328
+ * @param widget - The widget to move in the parent.
329
+ *
330
+ * #### Notes
331
+ * This method is called automatically by the panel layout at the
332
+ * appropriate time. It should not be called directly by user code.
333
+ *
334
+ * The default implementation moves the widget's node to the proper
335
+ * location in the parent's node and sends the appropriate attach and
336
+ * detach messages to the widget if the parent is attached to the DOM.
337
+ *
338
+ * Subclasses may reimplement this method to control how the widget's
339
+ * node is moved in the parent's node.
340
+ */
341
+ protected moveWidget(fromIndex: number, toIndex: number, widget: Widget): void;
342
+ /**
343
+ * A message handler invoked on an `'update-request'` message.
344
+ *
345
+ * #### Notes
346
+ * This is a reimplementation of the base class method,
347
+ * and is a no-op.
348
+ */
349
+ protected onUpdateRequest(msg: Message): void;
350
+ }
351
+ /**
352
+ * A namespace for windowed list
353
+ */
354
+ export declare namespace WindowedList {
355
+ /**
356
+ * Windowed list model interface
357
+ */
358
+ interface IModel extends IDisposable {
359
+ /**
360
+ * Provide a best guess for the widget size at position index
361
+ *
362
+ * #### Notes
363
+ *
364
+ * This function should be very light to compute especially when
365
+ * returning the default size.
366
+ * The default value should be constant (i.e. two calls with `null` should
367
+ * return the same value). But it can change for a given `index`.
368
+ *
369
+ * @param index Widget position
370
+ * @returns Estimated widget size
371
+ */
372
+ estimateWidgetSize: (index: number) => number;
373
+ /**
374
+ * Get the total list size.
375
+ *
376
+ * @returns Total estimated size
377
+ */
378
+ getEstimatedTotalSize(): number;
379
+ /**
380
+ * Get the scroll offset to display an item in the viewport.
381
+ *
382
+ * @param index Item index
383
+ * @param align Where to align the item in the viewport
384
+ * @returns The needed scroll offset
385
+ */
386
+ getOffsetForIndexAndAlignment(index: number, align: ScrollToAlign): number;
387
+ /**
388
+ * Compute the items range to display.
389
+ *
390
+ * It returns ``null`` if the range does not need to be updated.
391
+ *
392
+ * @returns The current items range to display
393
+ */
394
+ getRangeToRender(): WindowIndex | null;
395
+ /**
396
+ * Return the viewport top position and height for range spanning from
397
+ * ``startIndex`` to ``stopIndex``.
398
+ *
399
+ * @param start First item in viewport index
400
+ * @param stop Last item in viewport index
401
+ * @returns The viewport top position and its height
402
+ */
403
+ getSpan(start: number, stop: number): [number, number];
404
+ /**
405
+ * List widget height
406
+ */
407
+ height: number;
408
+ /**
409
+ * Items list to be rendered
410
+ */
411
+ itemsList: {
412
+ length: number;
413
+ changed: ISignal<any, IObservableList.IChangedArgs<any>>;
414
+ } | null;
415
+ /**
416
+ * Number of widgets to render in addition to those
417
+ * visible in the viewport.
418
+ */
419
+ overscanCount: number;
420
+ /**
421
+ * WindowedListModel caches offsets and measurements for each index for performance purposes.
422
+ * This method clears that cached data for all items after (and including) the specified index.
423
+ *
424
+ * The list will automatically re-render after the index is reset.
425
+ *
426
+ * @param index
427
+ */
428
+ resetAfterIndex(index: number): void;
429
+ /**
430
+ * Viewport scroll offset.
431
+ */
432
+ scrollOffset: number;
433
+ /**
434
+ * Update item sizes.
435
+ *
436
+ * This should be called when the real item sizes has been
437
+ * measured.
438
+ *
439
+ * @param sizes New sizes per item index
440
+ * @returns Whether some sizes changed or not
441
+ */
442
+ setWidgetSize(sizes: {
443
+ index: number;
444
+ size: number;
445
+ }[]): boolean;
446
+ /**
447
+ * A signal emitted when any model state changes.
448
+ */
449
+ readonly stateChanged: ISignal<IModel, IChangedArgs<any, any, 'count' | 'index' | 'list' | 'overscanCount' | 'windowingActive'>>;
450
+ /**
451
+ * Total number of widgets in the list
452
+ */
453
+ widgetCount: number;
454
+ /**
455
+ * Whether windowing is active or not.
456
+ */
457
+ windowingActive: boolean;
458
+ /**
459
+ * Widget factory for the list items.
460
+ *
461
+ * Caching the resulting widgets should be done by the callee.
462
+ *
463
+ * @param index List index
464
+ * @returns The widget at the given position
465
+ */
466
+ widgetRenderer: (index: number) => Widget;
467
+ }
468
+ /**
469
+ * Windowed list model constructor options
470
+ */
471
+ interface IModelOptions {
472
+ /**
473
+ * Total number of widgets in the list.
474
+ *
475
+ * #### Notes
476
+ * If an observable list is provided this will be ignored.
477
+ */
478
+ count?: number;
479
+ /**
480
+ * Dynamic list of items
481
+ */
482
+ itemsList?: IObservableList<any>;
483
+ /**
484
+ * Number of widgets to render in addition to those
485
+ * visible in the viewport.
486
+ */
487
+ overscanCount?: number;
488
+ /**
489
+ * Whether windowing is active or not.
490
+ *
491
+ * This is true by default.
492
+ */
493
+ windowingActive?: boolean;
494
+ }
495
+ /**
496
+ * Windowed list view constructor options
497
+ */
498
+ interface IOptions<T extends WindowedList.IModel = WindowedList.IModel> {
499
+ /**
500
+ * Windowed list model to display
501
+ */
502
+ model: T;
503
+ /**
504
+ * Windowed list layout
505
+ */
506
+ layout?: WindowedLayout;
507
+ }
508
+ /**
509
+ * Item list metadata
510
+ */
511
+ type ItemMetadata = {
512
+ /**
513
+ * Item vertical offset in the container
514
+ */
515
+ offset: number;
516
+ /**
517
+ * Item height
518
+ */
519
+ size: number;
520
+ /**
521
+ * Whether the size is an estimation or a measurement.
522
+ */
523
+ measured?: boolean;
524
+ };
525
+ /**
526
+ * Type of scroll
527
+ */
528
+ type ScrollToAlign = 'auto' | 'smart' | 'center' | 'start' | 'end';
529
+ /**
530
+ * Widget range in view port
531
+ */
532
+ type WindowIndex = [number, number, number, number];
533
+ }