17
17
18
18
import { Widget } from '@lumino/widgets'
19
19
import { eventBus } from '@/services/eventBus'
20
+ import { type Message } from '@lumino/messaging'
20
21
21
22
/**
22
23
* This is a valid Lumino widget, that contains only a dummy div
@@ -31,33 +32,33 @@ import { eventBus } from '@/services/eventBus'
31
32
export default class LuminoWidget extends Widget {
32
33
/**
33
34
* Create a LuminoWidget object.
34
- * @param {string } id - unique ID of the widget
35
- * @param {string } name - text displayed in the widget tab
36
- * @param {boolean } closable - flag that controls whether the tab can be
37
- * closed or not
35
+ * @param id - unique ID of the widget
36
+ * @param name - text displayed in the widget tab
37
+ * @param closable - flag that controls whether the tab can be closed or not
38
38
*/
39
- constructor ( id , name , closable = true ) {
39
+ constructor (
40
+ id : string ,
41
+ public name : string ,
42
+ public readonly closable : boolean = true
43
+ ) {
40
44
super ( { node : LuminoWidget . createNode ( id ) } )
41
45
this . id = id
42
- this . name = name
43
- this . closable = closable
44
46
// classes and flags
45
47
this . setFlag ( Widget . Flag . DisallowLayout )
46
48
this . addClass ( 'content' )
47
49
}
48
50
49
51
/**
50
52
* Return a dummy div to be used as parent for the Vue component element.
51
- * @param {string } id - widget id
52
- * @return {HTMLElement }
53
+ * @param id - widget id
53
54
*/
54
- static createNode ( id ) {
55
+ static createNode ( id : string ) : HTMLElement {
55
56
const div = document . createElement ( 'div' )
56
57
div . setAttribute ( 'id' , id )
57
58
return div
58
59
}
59
60
60
- onBeforeAttach ( msg ) {
61
+ onBeforeAttach ( msg : Message ) {
61
62
// Set tab title as this is not handled automatically for some reason.
62
63
// NOTE: We do this in the onBeforeAttach hook rather than in the constructor
63
64
// because the constructor does not get called when we restore layout to the
@@ -76,13 +77,13 @@ export default class LuminoWidget extends Widget {
76
77
// super.onActivateRequest(msg)
77
78
// }
78
79
79
- onCloseRequest ( msg ) {
80
+ onCloseRequest ( msg : Message ) {
80
81
// Emit an event so that the Vue component knows that it needs to be removed too
81
82
eventBus . emit ( 'lumino:deleted' , this . id )
82
83
super . onCloseRequest ( msg )
83
84
}
84
85
85
- onAfterShow ( msg ) {
86
+ onAfterShow ( msg : Message ) {
86
87
// Emit an event so that the Vue component knows that this widget is visible again
87
88
eventBus . emit ( `lumino:show:${ this . id } ` )
88
89
super . onAfterShow ( msg )
0 commit comments