"use strict";
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Item
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionButtonItemDef = void 0;
const core_react_1 = require("@itwin/core-react");
const ItemDefBase_1 = require("./ItemDefBase");
/* eslint-disable deprecation/deprecation */
/** Abstract base class that is used by classes to execute an action when pressed.
 * @public
 * @deprecated in 4.15.0. Use type specific utilities for creating items instead, i.e. {@link ToolbarItemUtilities.createActionItem}.
 */
class ActionButtonItemDef extends ItemDefBase_1.ItemDefBase {
    constructor(itemProps, onItemExecuted) {
        super(itemProps);
        /** Called when the size of the action button is initialized and the size is known */
        this.handleSizeKnown = (size) => {
            this.size = size;
        };
        this.execute = this.execute.bind(this);
        this._onItemExecuted = onItemExecuted;
    }
    /** Called when the action button is invoked by a click or touch */
    execute() {
        if (this._commandHandler && this._commandHandler.execute) {
            if (this._commandHandler.getCommandArgs)
                this._commandHandler.execute(this._commandHandler.getCommandArgs());
            else
                this._commandHandler.execute(this._commandHandler.parameters);
        }
        if (this._onItemExecuted)
            this._onItemExecuted(this);
    }
    /** Determines the dimension in a given orientation */
    getDimension(orientation) {
        let dimension = ActionButtonItemDef.defaultButtonSize;
        if (this.size)
            dimension =
                orientation === core_react_1.Orientation.Horizontal
                    ? this.size.width
                    : this.size.height;
        return dimension;
    }
}
exports.ActionButtonItemDef = ActionButtonItemDef;
/** The default button size for all action buttons */
ActionButtonItemDef.defaultButtonSize = 42;
//# sourceMappingURL=ActionButtonItemDef.js.map