import { SingletonLayout , Widget , LayoutItem } from '@phosphor/widgets' ; import { Message } from '@phosphor/messaging' ; export class SingletonPanel extends Widget { onResize ( _ ) { if ( this . _item ) { this . _fitCurrentWidget ( ) ; } } onActivateRequest ( ) { const widget = this . layout . widget ; if ( widget ) { if ( ! widget . node . contains ( document . activeElement ) ) { widget . node . focus ( ) ; } widget . activate ( ) ; } } set widget ( widget ) { if ( ! this . isDisposed ) { this . layout . widget = widget ; this . _item = new LayoutItem ( this . layout . widget ) ; this . _fitCurrentWidget ( ) ; } } private _fitCurrentWidget ( ) { this . _item . update ( 0 , 0 , this . node . offsetWidth , this . node . offsetHeight ) ; } readonly layout : SingletonLayout | null = new SingletonLayout ( ) ; private _item : LayoutItem ; }