import type { IDataContextProvider } from '../DataContext/IDataContextProvider' ; import type { IAction } from './IAction' ; import type { IActionHandler } from './IActionHandler' ; import type { IActionInfo } from './IActionInfo' ; import type { IActionItem } from './IActionItem' ; import type { IKeyBindingHandler } from './KeyBinding/IKeyBindingHandler' ; export class ActionItem implements IActionItem { readonly action : IAction ; readonly handler : IActionHandler ; readonly binding : IKeyBindingHandler | null ; private context : IDataContextProvider ; get actionInfo ( ) : IActionInfo { if ( this . handler . getActionInfo ) { return this . handler . getActionInfo ( this . context , this . action ) ; } return this . action . info ; } constructor ( action , handler , binding , context ) { this . action = action ; this . handler = handler ; this . binding = binding ; this . context = context ; } isChecked ( ) { return this . handler . isChecked ?. ( this . context , this . action ) ?? false ; } isLoading ( ) { return this . handler . isLoading ?. ( this . context , this . action ) ?? false ; } isDisabled ( ) { return this . handler . isDisabled ?. ( this . context , this . action ) ?? false ; } isHidden ( ) { return this . handler . isHidden ?. ( this . context , this . action ) ?? false ; } activate ( binding ? ) { if ( binding ) { this . binding ?. handler ( this . context , this . action ) ; } else { this . handler . handler ( this . context , this . action ) ; } } }