@termun/core - v0.0.0
    Preparing search index...

    Class MenuChoice

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new choice menu with optional pre-configured options and callbacks.

      Parameters

      • data: MenuChoiceJson

        Menu JSON including name, type, optional values array/function, and choice-specific configs.

      Returns MenuChoice

    Methods

    • Sorts option values for display: global items last, then by index, then by type (actions before menus), then alphabetically.

      Returns MenuFieldOption[]

    • Applies cascading style resolution: option → menu → Utility defaults. Global items do not inherit menu styles.

      Parameters

      Returns void

    • Resolves runtime values to a concrete map.

      Returns MenuChoiceValuesMap

    • Returns the current option values.

      Parameters

      • map: true

        When true, returns a MenuChoiceValuesMap keyed by option name. When false (default), returns a flat MenuFieldOption[].

      Returns MenuChoiceValuesMap

    • Returns the current option values.

      Parameters

      • Optionalmap: false

        When true, returns a MenuChoiceValuesMap keyed by option name. When false (default), returns a flat MenuFieldOption[].

      Returns MenuFieldOption[]

    • Returns all option values as a map keyed by option name.

      Returns MenuChoiceValuesMap

    • Returns the option list, optionally sorted for display.

      Parameters

      • sorted: boolean = false

        When true, applies the display-order sorting algorithm.

      Returns MenuFieldOption[]

    • Returns the option matching the given name, or undefined.

      Parameters

      • name: string

        Option value/name to look up.

      Returns MenuFieldOption | undefined

    • Replaces or inserts a named option.

      Parameters

      • name: string

        Option key.

      • value: MenuFieldOption

        Replacement MenuFieldOption.

      Returns this

    • Adds an option from a Menu, Action, MenuFieldOption, or raw JSON value. Styles are resolved and applied automatically.

      Parameters

      Returns this

    • Adds an option from a Menu, Action, MenuFieldOption, or raw JSON value. Styles are resolved and applied automatically.

      Parameters

      • value: Menu

        The option to add.

      Returns this

    • Adds an option from a Menu, Action, MenuFieldOption, or raw JSON value. Styles are resolved and applied automatically.

      Parameters

      • value: Action

        The option to add.

      Returns this

    • Adds an option from a Menu, Action, MenuFieldOption, or raw JSON value. Styles are resolved and applied automatically.

      Parameters

      Returns this

    • Adds an option from a Menu, Action, MenuFieldOption, or raw JSON value. Styles are resolved and applied automatically.

      Parameters

      Returns this

    • Adds an option from a Menu, Action, MenuFieldOption, or raw JSON value. Styles are resolved and applied automatically.

      Parameters

      Returns this

    • Returns true when at least one option is registered.

      Returns boolean

    • Returns the currently selected values.

      Returns string[]

    • Replaces the selected values list.

      Parameters

      • v: string[]

        New array of selected option names.

      Returns this

    • Adds a value to the selected values list if not already present.

      Parameters

      • v: string

        Option name to select.

      Returns this

    • Removes a value from the selected values list.

      Parameters

      • v: string

        Option name to deselect.

      Returns this

    • Returns true when the given value is in the selected list.

      Parameters

      • v: string

        Option name to check.

      Returns boolean

    • Renders and runs the interactive choice prompt.

      Parameters

      • Optionallanguage: string

        Optional language override for label translation.

      Returns Promise<string | string[]>

    • Returns the menu's unique name.

      Returns string

    • Returns the menu type: "choice", "input", "field", or "editor".

      Returns "input" | "field" | "choice" | "editor"

    • Returns the plugin namespace this menu belongs to, or undefined for the default plugin.

      Returns string | undefined

    • Sets the plugin namespace for this menu.

      Parameters

      • plugin: string | undefined

        Plugin name string.

      Returns this

    • Returns the display order index, or undefined if not set.

      Returns number | undefined

    • Sets the display order index.

      Parameters

      • index: number | undefined

        Numeric sort position.

      Returns this

    • Returns all registered parent names as a flat array.

      Returns string[]

    • Returns the parent entry matching the given name, or undefined.

      Parameters

      • name: string

        Parent name to look up.

      Returns string | undefined

    • Registers a parent menu name.

      Parameters

      • name: string

        Parent name to add.

      Returns this

    • Returns true when this menu is accessible from every context.

      Returns boolean

    • Returns true when this menu is the anchor point of a wizard/flow. Global actions that target this menu will be hidden in this menu and in all its descendants, resolved through the regular parents chain.

      Returns boolean

    • Sets the styles for this menu from an instance or a plain JSON object.

      Parameters

      • styles: MenuStyles

        MenuStyles instance or compatible JSON.

      Returns this

    • Sets the styles for this menu from an instance or a plain JSON object.

      Parameters

      Returns this

    • Sets the labels for this menu from an instance or a plain JSON object.

      Parameters

      • labels: MenuLabels

        MenuLabels instance or compatible JSON.

      Returns this

    • Sets the labels for this menu from an instance or a plain JSON object.

      Parameters

      Returns this

    Properties

    type: "input" | "field" | "choice" | "editor" = "choice"
    values: MenuChoiceValuesMap | MenuChoiceValuesResolvedFn = {}
    selectedValues: string[] = []
    configs: MenuChoiceConfigs = ...
    name: string
    plugin?: string
    parents: Record<string, Exclude<MenuJson["parents"], undefined>[number]> = {}
    index: number | undefined
    global: boolean
    anchorGlobal: boolean
    styles: MenuStyles
    labels: MenuLabels