"use strict";
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const classNames = require("classnames");
const mobx_react_1 = require("mobx-react");
const React = require("react");
const styles = require("../styles/grid.scss");
let GridComponent = class GridComponent extends React.Component {
    constructor(props) {
        super(props);
        this.onClick = (e) => {
            e.preventDefault();
            e.stopPropagation();
        };
        this.onCellClick = (e) => {
            e.preventDefault();
            e.stopPropagation();
        };
        this.renderCell = (cell) => {
            const className = classNames(cell.style, styles.gridcell);
            return (React.createElement("div", { id: this.props.box.id + "-c:" + cell.column + "-r:" + cell.row, className: className, key: this.props.box.id + "-r:" + cell.row + "-c:" + cell.column, style: { gridRow: this.row(cell), gridColumn: this.column(cell) }, onClick: this.onCellClick }, this.props.renderBoxCallback(cell.box, this.props.editor)));
        };
        this.row = (cell) => {
            return cell.row + (cell.rowSpan ? " / span " + cell.rowSpan : "");
        };
        this.column = (cell) => {
            return cell.column + (cell.columnSpan ? " / span " + cell.columnSpan : "");
        };
    }
    render() {
        const columns = "repeat(" + this.props.box.numberOfColumns() + ", auto)";
        const rows = "repeat(" + this.props.box.numberOfRows() + ", auto)";
        const className = classNames(this.props.box.style, styles.maingrid);
        return (React.createElement("div", { id: this.props.box.id, className: className, onClick: this.onClick, style: { gridTemplateColumns: columns, gridTemplateRows: rows } }, this.props.box.cells.map(this.renderCell)));
    }
};
GridComponent = __decorate([
    mobx_react_1.observer,
    __metadata("design:paramtypes", [Object])
], GridComponent);
exports.GridComponent = GridComponent;
//# sourceMappingURL=GridComponent.js.map