platform-bible-utils
    Preparing search index...

    Function evaluateMenu

    • Experimental

      Evaluates all when-expressions in a menu document against the current context key values.

      • Items whose when evaluates falsy are removed.
      • Items with enabledWhen get disabled set to the negated result.
      • Command items with checkedWhen get checked set to the result.
      • Submenu items whose submenus were emptied by that filtering are removed (recursively), and so are groups and columns it emptied. Containers with no items in the document to begin with are left alone, since a surface may fill them at open time.
      • The when/enabledWhen/checkedWhen fields are stripped from the output.

      The input document is not mutated; a deep clone is returned.

      Type Parameters

      Parameters

      • menu: T

        The menu document to evaluate (localized or not)

      • getContextKey: ContextKeyLookup

        Function that looks up the current value of a context key

      • templateVars: Record<string, undefined | string> = {}

        Values for {placeholder} segments in property references

      • onError: WhenExpressionErrorHandler = ...

        Called for each expression that fails to evaluate (rare — expressions are validated at contribution load time). Failed expressions fail safe: when → hidden, enabledWhen → disabled, checkedWhen → unchecked

      Returns T

      A new menu document with expressions applied and stripped This function is unstable and may change or disappear without notice