SheetXL - v0.8.0-beta.9+sites.210.e2d420901
    Preparing search index...

    Interface ICommandDefinition<STATE, CONTEXT, ARGS>

    A contributed, partial command definition — the authoring side of the command system. Scopes/providers contribute these; the registry reduces all contributions for a given key (along the active scope chain) per-property into a derived, read-only ResolvedCommand. Authors never build or mutate a resolved instance directly (no more instance.updateCallback(...)); they contribute/merge definitions via the provider.

    Every field except key is optional and merged per-property (see MERGE_STRATEGY). Canonical example — copy:

    • a root scope contributes { key, icon, label } (stable chrome),
    • the focused component contributes { callback } (what's actually copied),
    • an intermediate scope contributes { disabledReason: 'Sheet is protected' }.

    Reuses the shared sub-types from ICommand (DynamicValue, Callback, DynamicContext, ITarget) so the resolved read surface stays byte-compatible with the existing command/ package during the port. See design/COMMAND-DESIGN.md.

    interface ICommandDefinition<STATE = any, CONTEXT = any, ARGS = void> {
        callback?: CommandCallback<STATE, CONTEXT, ARGS>;
        context?: DynamicContext<CONTEXT>;
        description?: DynamicValue<string, CONTEXT>;
        disabledReasons?: string[];
        groupDescriptions?: Record<string, DynamicValue<string, CONTEXT>>;
        groupIcons?: Record<
            string,
            DynamicValue<
                string
                | ReactElement<unknown, string | JSXElementConstructor<any>>,
                CONTEXT,
            >,
        >;
        groupLabels?: Record<string, DynamicValue<string, CONTEXT>>;
        hidden?: DynamicValue<boolean, CONTEXT>;
        icon?: DynamicValue<
            string
            | ReactElement<unknown, (string | JSXElementConstructor<any>)>,
            CONTEXT,
        >;
        key: string;
        label?: DynamicValue<string, CONTEXT>;
        params?: Record<string, unknown>;
        shortcut?: DynamicValue<IKeyStroke | IKeyStroke[] | null, CONTEXT>;
        state?: STATE;
        tags?: string[];
        target?: ITarget | (() => ITarget);
    }

    Type Parameters

    • STATE = any
    • CONTEXT = any
    • ARGS = void
    Index

    The action (delegates to the SDK / an ephemeral UI store). Strategy: override. Takes the per-invocation input ARGS — distinct from state (the value the command reflects). See CommandCallback and design/COMMAND-DESIGN.md "arg vs state".

    View-specific context. Strategy: override.

    description?: DynamicValue<string, CONTEXT>
    disabledReasons?: string[]

    Reasons the command is unavailable. Array-valued ⇒ accumulates (concat, most-specific first): every contributing scope may add reasons, and the command is disabled if ANY reason is present (resolved disabled() derives from this for read-compat). Dynamic reasons are expressed by re-contributing (the contributor re-runs when its inputs change) rather than storing a function — that's the definitions model. Note: a child scope cannot yet clear a parent's reason (a "fancier type" later — see design/COMMAND-DESIGN.md).

    groupDescriptions?: Record<string, DynamicValue<string, CONTEXT>>

    Per-surface description overrides keyed by groupKey — the description twin of groupLabels (a compact tooltip in a dense menu vs. the full ribbon text). Falls back to description when the surface has no entry.

    groupIcons?: Record<
        string,
        DynamicValue<
            string
            | ReactElement<unknown, string | JSXElementConstructor<any>>,
            CONTEXT,
        >,
    >

    Per-surface icon overrides keyed by groupKey — the icon twin of groupLabels (e.g. a glyph in a toolbar, a check mark in a menu). Falls back to icon.

    groupLabels?: Record<string, DynamicValue<string, CONTEXT>>

    Per-surface label overrides (e.g. "Rename Sheet" → "Rename" in a context menu).

    hidden?: DynamicValue<boolean, CONTEXT>

    Hidden from surfaces entirely (e.g. macro recording). Scalar ⇒ overrides.

    icon?: DynamicValue<
        string
        | ReactElement<unknown, (string | JSXElementConstructor<any>)>,
        CONTEXT,
    >
    key: string

    Immutable identity. Every contribution for the same command shares this key.

    label?: DynamicValue<string, CONTEXT>
    params?: Record<string, unknown>

    Message parameters for ICU-subset label/groupLabels/description messages (formatMessage — {count, plural, …} / {mode, select, …}). The catalog authors the localized MESSAGE (with the parameter defaults — ChromeRecord.params); a dynamic contributor keeps the live values current (e.g. the sheet's selection reducer contributes { count, mode } for the insert/delete/hide labels). Strategy: override — contribute the COMPLETE parameter set for the command's messages, not a delta.

    shortcut?: DynamicValue<IKeyStroke | IKeyStroke[] | null, CONTEXT>
    state?: STATE

    Model state. Strategy: override.

    tags?: string[]

    Accumulated metadata (like disabledReasons): scopes' tags concatenate. Cross-cutting rules keyed on a tag (e.g. "mutator commands disable when the sheet is protected") are contributor logic, not a registry feature — see design/COMMAND-DESIGN.md.

    target?: ITarget | (() => ITarget)

    Focus/contains target (commands refocus this after execute). Strategy: override.