|
| 1 | +import type { MenuItem, SelectOptions } from "../ui/select.js"; |
| 2 | +import type { SettingsHubActionType } from "./unified-settings-controller.js"; |
| 3 | + |
| 4 | +export async function promptSettingsHubEntry< |
| 5 | + TAction extends { type: SettingsHubActionType }, |
| 6 | +>(params: { |
| 7 | + initialFocus: TAction["type"]; |
| 8 | + promptSettingsHubMenu: ( |
| 9 | + initialFocus: TAction["type"], |
| 10 | + deps: { |
| 11 | + isInteractive: () => boolean; |
| 12 | + getUiRuntimeOptions: () => ReturnType< |
| 13 | + typeof import("../ui/runtime.js").getUiRuntimeOptions |
| 14 | + >; |
| 15 | + buildItems: () => MenuItem<TAction>[]; |
| 16 | + findInitialCursor: ( |
| 17 | + items: MenuItem<TAction>[], |
| 18 | + initialFocus: TAction["type"], |
| 19 | + ) => number | undefined; |
| 20 | + select: <T>( |
| 21 | + items: MenuItem<T>[], |
| 22 | + options: SelectOptions<T>, |
| 23 | + ) => Promise<T | null>; |
| 24 | + copy: { |
| 25 | + title: string; |
| 26 | + subtitle: string; |
| 27 | + help: string; |
| 28 | + }; |
| 29 | + }, |
| 30 | + ) => Promise<TAction | null>; |
| 31 | + isInteractive: () => boolean; |
| 32 | + getUiRuntimeOptions: () => ReturnType< |
| 33 | + typeof import("../ui/runtime.js").getUiRuntimeOptions |
| 34 | + >; |
| 35 | + buildItems: () => MenuItem<TAction>[]; |
| 36 | + findInitialCursor: ( |
| 37 | + items: MenuItem<TAction>[], |
| 38 | + initialFocus: TAction["type"], |
| 39 | + ) => number | undefined; |
| 40 | + select: <T>( |
| 41 | + items: MenuItem<T>[], |
| 42 | + options: SelectOptions<T>, |
| 43 | + ) => Promise<T | null>; |
| 44 | + copy: { |
| 45 | + title: string; |
| 46 | + subtitle: string; |
| 47 | + help: string; |
| 48 | + }; |
| 49 | +}): Promise<TAction | null> { |
| 50 | + return params.promptSettingsHubMenu(params.initialFocus, { |
| 51 | + isInteractive: params.isInteractive, |
| 52 | + getUiRuntimeOptions: params.getUiRuntimeOptions, |
| 53 | + buildItems: params.buildItems, |
| 54 | + findInitialCursor: params.findInitialCursor, |
| 55 | + select: params.select, |
| 56 | + copy: params.copy, |
| 57 | + }); |
| 58 | +} |
0 commit comments