@@ -26,7 +26,7 @@ function clamp(value: number, min: number, max: number): number {
26
26
/**
27
27
* Remove children from an HTMLElement
28
28
*/
29
- function removeChildren ( el : HTMLElement ) {
29
+ function removeChildren ( el : HTMLElement ) : void {
30
30
while ( el . firstChild ) {
31
31
el . removeChild ( el . firstChild ) ;
32
32
}
@@ -92,7 +92,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
92
92
/**
93
93
* Called when view is rendered.
94
94
*/
95
- render ( ) {
95
+ render ( ) : void {
96
96
super . render ( ) ;
97
97
98
98
this . el . classList . add ( 'jupyter-widgets' ) ;
@@ -120,11 +120,11 @@ abstract class TagsInputBaseView extends DOMWidgetView {
120
120
this . taginputWrapper . appendChild ( this . autocompleteList ) ;
121
121
122
122
this . el . onclick = this . focus . bind ( this ) ;
123
- this . el . ondrop = ( event : DragEvent ) => {
123
+ this . el . ondrop = ( event : DragEvent ) : void => {
124
124
// Put the tag at the end of the list if there is no currently hovered tag
125
125
const index =
126
126
this . hoveredTagIndex == null ? this . tags . length : this . hoveredTagIndex ;
127
- this . ondrop ( event , index ) ;
127
+ return this . ondrop ( event , index ) ;
128
128
} ;
129
129
this . el . ondragover = this . ondragover . bind ( this ) ;
130
130
@@ -148,7 +148,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
148
148
* Called when the model is changed. The model may have been
149
149
* changed by another view or by a state update from the back-end.
150
150
*/
151
- update ( ) {
151
+ update ( ) : void {
152
152
// Prevent hiding the input element and clearing the selection when updating everything
153
153
this . preventLoosingFocus = true ;
154
154
@@ -168,7 +168,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
168
168
// Drag and drop
169
169
tag . draggable = true ;
170
170
tag . ondragstart = ( ( index : number , value : any ) => {
171
- return ( event : DragEvent ) => {
171
+ return ( event : DragEvent ) : void => {
172
172
this . ondragstart ( event , index , value , this . model . model_id ) ;
173
173
} ;
174
174
} ) ( index , value [ index ] ) ;
@@ -202,7 +202,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
202
202
/**
203
203
* Update the auto-completion list
204
204
*/
205
- updateAutocomplete ( ) {
205
+ updateAutocomplete ( ) : void {
206
206
removeChildren ( this . autocompleteList ) ;
207
207
208
208
const allowedTags = this . model . get ( 'allowed_tags' ) ;
@@ -217,7 +217,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
217
217
/**
218
218
* Update the tags, called when the selection has changed and we need to update the tags CSS
219
219
*/
220
- updateTags ( ) {
220
+ updateTags ( ) : void {
221
221
const value : Array < any > = this . model . get ( 'value' ) ;
222
222
223
223
for ( const idx in this . tags ) {
@@ -235,7 +235,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
235
235
/**
236
236
* Handle a new value is added from the input element
237
237
*/
238
- handleValueAdded ( event : Event ) {
238
+ handleValueAdded ( event : Event ) : void {
239
239
const newTagValue = trim ( this . taginput . value ) ;
240
240
const tagIndex = this . inputIndex ;
241
241
@@ -296,15 +296,15 @@ abstract class TagsInputBaseView extends DOMWidgetView {
296
296
/**
297
297
* Resize the input element
298
298
*/
299
- resizeInput ( ) {
299
+ resizeInput ( ) : void {
300
300
const size = this . taginput . value . length + 1 ;
301
301
this . taginput . setAttribute ( 'size' , String ( size ) ) ;
302
302
}
303
303
304
304
/**
305
305
* Handle key events on the input element
306
306
*/
307
- handleKeyEvent ( event : KeyboardEvent ) {
307
+ handleKeyEvent ( event : KeyboardEvent ) : void {
308
308
const valueLength = this . model . get ( 'value' ) . length ;
309
309
310
310
// Do nothing if the user is typing something
@@ -376,7 +376,12 @@ abstract class TagsInputBaseView extends DOMWidgetView {
376
376
/**
377
377
* Function that gets called when a tag with a given `value` is being dragged.
378
378
*/
379
- ondragstart ( event : DragEvent , index : number , tagValue : any , origin : string ) {
379
+ ondragstart (
380
+ event : DragEvent ,
381
+ index : number ,
382
+ tagValue : any ,
383
+ origin : string
384
+ ) : void {
380
385
if ( event . dataTransfer == null ) {
381
386
return ;
382
387
}
@@ -388,7 +393,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
388
393
/**
389
394
* Function that gets called when a tag has been dragged on the tag at the `index` position.
390
395
*/
391
- ondrop ( event : DragEvent , index : number ) {
396
+ ondrop ( event : DragEvent , index : number ) : void {
392
397
if ( event . dataTransfer == null ) {
393
398
return ;
394
399
}
@@ -432,12 +437,12 @@ abstract class TagsInputBaseView extends DOMWidgetView {
432
437
this . addTag ( index , draggedTagValue ) ;
433
438
}
434
439
435
- ondragover ( event : DragEvent ) {
440
+ ondragover ( event : DragEvent ) : void {
436
441
// This is needed for the drag and drop to work
437
442
event . preventDefault ( ) ;
438
443
}
439
444
440
- ondragenter ( event : DragEvent , index : number ) {
445
+ ondragenter ( event : DragEvent , index : number ) : void {
441
446
if ( this . hoveredTag != null && this . hoveredTag != this . tags [ index ] ) {
442
447
this . hoveredTag . style . marginLeft = '1px' ;
443
448
}
@@ -447,7 +452,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
447
452
this . hoveredTag . style . marginLeft = '30px' ;
448
453
}
449
454
450
- ondragend ( ) {
455
+ ondragend ( ) : void {
451
456
if ( this . hoveredTag != null ) {
452
457
this . hoveredTag . style . marginLeft = '1px' ;
453
458
}
@@ -458,7 +463,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
458
463
/**
459
464
* Select tags from `start` to `start + dx` not included.
460
465
*/
461
- select ( start : number , dx : number ) {
466
+ select ( start : number , dx : number ) : void {
462
467
const valueLength = this . model . get ( 'value' ) . length ;
463
468
464
469
if ( ! this . selection ) {
@@ -471,7 +476,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
471
476
/**
472
477
* Remove all the selected tags.
473
478
*/
474
- removeSelectedTags ( ) {
479
+ removeSelectedTags ( ) : void {
475
480
const value : Array < string > = [ ...this . model . get ( 'value' ) ] ;
476
481
const valueLength = value . length ;
477
482
@@ -494,7 +499,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
494
499
/**
495
500
* Remove a tag given its index in the list
496
501
*/
497
- removeTag ( tagIndex : number ) {
502
+ removeTag ( tagIndex : number ) : void {
498
503
const value : Array < string > = [ ...this . model . get ( 'value' ) ] ;
499
504
500
505
value . splice ( tagIndex , 1 ) ;
@@ -511,15 +516,15 @@ abstract class TagsInputBaseView extends DOMWidgetView {
511
516
/**
512
517
* Focus on the input element
513
518
*/
514
- focus ( ) {
519
+ focus ( ) : void {
515
520
this . taginputWrapper . style . display = 'inline-block' ;
516
521
this . taginput . focus ( ) ;
517
522
}
518
523
519
524
/**
520
525
* Lose focus on the input element
521
526
*/
522
- loseFocus ( ) {
527
+ loseFocus ( ) : void {
523
528
if ( this . preventLoosingFocus ) {
524
529
return ;
525
530
}
@@ -539,7 +544,7 @@ abstract class TagsInputBaseView extends DOMWidgetView {
539
544
* #### Notes
540
545
* This is a read-only attribute.
541
546
*/
542
- get tagName ( ) {
547
+ get tagName ( ) : string {
543
548
// We can't make this an attribute with a default value
544
549
// since it would be set after it is needed in the
545
550
// constructor.
@@ -624,7 +629,7 @@ export class TagsInputView extends TagsInputBaseView {
624
629
/**
625
630
* Returns the text that should be displayed in the tag element
626
631
*/
627
- getTagText ( value : string ) {
632
+ getTagText ( value : string ) : string {
628
633
return value ;
629
634
}
630
635
@@ -753,7 +758,7 @@ abstract class NumbersInputModel extends TagsInputModel {
753
758
}
754
759
755
760
abstract class NumbersInputView extends TagsInputView {
756
- render ( ) {
761
+ render ( ) : void {
757
762
// Initialize text formatter
758
763
this . model . on ( 'change:format' , ( ) => {
759
764
this . formatter = d3Format . format ( this . model . get ( 'format' ) ) ;
@@ -767,7 +772,7 @@ abstract class NumbersInputView extends TagsInputView {
767
772
/**
768
773
* Returns the text that should be displayed in the tag element
769
774
*/
770
- getTagText ( value : string ) {
775
+ getTagText ( value : string ) : string {
771
776
return this . formatter ( this . parseNumber ( value ) ) ;
772
777
}
773
778
0 commit comments