import { __decorate } from "tslib";
import { property } from "lit/decorators.js";
import { UiElement } from "../UiElement.js";
import { isDisabled, setDisabled } from "../lib/disabled.js";
/**
 * A base class that defines a button element.
 */
export class Button extends UiElement {
    get disabled() {
        return isDisabled(this);
    }
    /**
     * When set, the button is a disabled state.
     * @attribute
     */
    set disabled(value) {
        const old = isDisabled(this);
        setDisabled(this, value);
        this.requestUpdate('disabled', old);
    }
    constructor() {
        super();
        this.actionController.cancelKeyboardEvents = true;
        this.addEventListener('keydown', this.handleKeyDown.bind(this));
        this.addEventListener('keyup', this.handleKeyUp.bind(this));
        this.addEventListener('click', this.handleClick.bind(this));
        this.addEventListener('pointerdown', this.handlePointerDown.bind(this));
        this.addEventListener('pointerup', this.handlePointerUp.bind(this));
        this.addEventListener('pointercancel', this.handlePointerCancel.bind(this));
        this.addEventListener('pointerleave', this.handlePointerLeave.bind(this));
        this.addEventListener('contextmenu', this.handleContextMenu.bind(this));
    }
    connectedCallback() {
        super.connectedCallback();
        if (!this.hasAttribute('role')) {
            this.setAttribute('role', 'button');
        }
        if (!this.hasAttribute('tabindex') && !this.disabled) {
            this.setAttribute('tabindex', '0');
        }
    }
}
__decorate([
    property({ reflect: true, type: Boolean })
], Button.prototype, "disabled", null);
//# sourceMappingURL=Button.js.map