kmenu
Version:
The perfect ⌘K menu
32 lines (29 loc) • 1.24 kB
text/typescript
export { C as CommandCore, d as CommandCoreConfig, c as CommandEvent, a as CommandOption, b as CommandState, E as EventHandler, F as FilterFunction, U as Unsubscribe, g as createRegexFilter, f as fuzzyFilter, s as simpleFilter, e as startsWithFilter } from './filters-BgDrPCJz.mjs';
/**
* All states for the internal state machine.
*/
type State = "idle" | "open" | "navigating" | "filtering" | "selected";
/**
* A named transition describing allowed `from` state(s) and the resulting `to` state.
*/
interface StateTransition {
from: State | State[];
to: State;
guard?: () => boolean;
}
declare class StateMachine {
private currentState;
private transitions;
private listeners;
constructor(initialState?: State);
/** Register a named transition. */
defineTransition(name: string, transition: StateTransition): void;
/** Attempt a transition by name. Returns `true` if applied. */
transition(name: string): boolean;
/** Get the current state. */
getState(): State;
/** Subscribe to callbacks when a state is entered. */
onStateEnter(state: State, callback: () => void): () => void;
private notifyListeners;
}
export { type State, StateMachine, type StateTransition };