"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
const classNames = require("classnames");
const mobx_react_1 = require("mobx-react");
const React = require("react");
const PiLogging_1 = require("../../../util/PiLogging");
const Rendering_1 = require("../Rendering");
const Styles_1 = require("../styles/Styles");
let ListComponent = class ListComponent extends React.Component {
    constructor() {
        super(...arguments);
        this.element = null;
        this.setElement = (element) => {
            this.element = element;
        };
        this.setFocus = () => {
            PiLogging_1.EVENT_LOG.info(this, "FOPCUS");
            if (this.element) {
                this.element.focus();
            }
        };
        this.oops = () => {
            PiLogging_1.EVENT_LOG.info(this, "click-grid-cell");
        };
    }
    componentDidMount() {
        PiLogging_1.RENDER_LOG.info(this, "componentDidMount");
        this.props.box.setFocus = this.setFocus;
    }
    render() {
        PiLogging_1.RENDER_LOG.info(this, "");
        const children = this.props.box.children;
        const styleClasses = classNames(this.props.box.kind === "HorizontalListBox" ? Styles_1.STYLES.horizontalList : Styles_1.STYLES.verticalList, this.props.box.style);
        const gridStyle = this.props.box.kind === "HorizontalListBox"
            ? {
                gridTemplateColumns: "repeat(" + children.length + ", auto)"
            }
            : {
                gridTemplateRows: "repeat(" + children.length + ", auto)"
            };
        if (this.props.box.kind === "HorizontalListBox") {
            return (React.createElement("div", { id: this.props.box.id, className: styleClasses, onClick: this.oops, ref: this.setElement, tabIndex: 0 }, children.map((ch, index) => (React.createElement(Rendering_1.RenderBox, { key: ch.id + index, box: ch, editor: this.props.editor })))));
        }
        else {
            return (React.createElement("div", { id: this.props.box.id, className: styleClasses, onClick: this.oops, style: gridStyle, ref: this.setElement, tabIndex: 0 }, children.map((ch, index) => (React.createElement(Rendering_1.RenderBox, { key: ch.id + index, box: ch, editor: this.props.editor })))));
        }
    }
};
ListComponent = __decorate([
    mobx_react_1.observer
], ListComponent);
exports.ListComponent = ListComponent;
//# sourceMappingURL=ListComponent.js.map