var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { ShadowlessElement, WithDisposable } from '@blockeditor/lit';
import { property } from 'lit/decorators.js';
export class BaseCellRenderer extends WithDisposable(ShadowlessElement) {
    get readonly() {
        return this.column.readonly;
    }
    get value() {
        return this.column.getValue(this.rowId);
    }
    onChange(value) {
        this.column.setValue(this.rowId, value);
    }
    beforeEnterEditMode() {
        return true;
    }
    onEnterEditMode() {
        // do nothing
    }
    onExitEditMode() {
        // do nothing
    }
    focusCell() {
        return true;
    }
    blurCell() {
        return true;
    }
    connectedCallback() {
        super.connectedCallback();
        this.style.width = '100%';
        this._disposables.addFromEvent(this, 'click', e => {
            if (this.isEditing) {
                e.stopPropagation();
            }
        });
        const type = this.column.type;
        this._disposables.add(this.column.onCellUpdate(this.rowId, () => {
            if (this.column.type === type) {
                this.requestUpdate();
            }
        }));
        this._disposables.addFromEvent(this, 'copy', e => {
            if (!this.isEditing)
                return;
            e.stopPropagation();
            this.onCopy(e);
        });
        this._disposables.addFromEvent(this, 'cut', e => {
            if (!this.isEditing)
                return;
            e.stopPropagation();
            this.onCut(e);
        });
        this._disposables.addFromEvent(this, 'paste', e => {
            if (!this.isEditing)
                return;
            e.stopPropagation();
            this.onPaste(e);
        });
    }
    forceUpdate() {
        this.requestUpdate();
    }
    onCopy(_e) { }
    onCut(_e) { }
    onPaste(_e) { }
}
__decorate([
    property({ attribute: false })
], BaseCellRenderer.prototype, "view", void 0);
__decorate([
    property({ attribute: false })
], BaseCellRenderer.prototype, "column", void 0);
__decorate([
    property()
], BaseCellRenderer.prototype, "rowId", void 0);
__decorate([
    property({ attribute: false })
], BaseCellRenderer.prototype, "isEditing", void 0);
__decorate([
    property({ attribute: false })
], BaseCellRenderer.prototype, "selectCurrentCell", void 0);
//# sourceMappingURL=base-cell.js.map