import React from "react";
import { isObjectType } from "../schema";
export const FieldTemplate = (props) => {
    let classNames = props.classNames;
    const colSpan = getColSpan(props.schema);
    const rowSpan = getRowSpan(props.schema);
    let style;
    if (colSpan) {
        classNames += ` limel-form-layout-colspan--${colSpan}`;
    }
    if (rowSpan) {
        style = {
            gridRow: `span ${rowSpan}`,
            minHeight: `calc(var(--min-height-of-one-row) * ${rowSpan})`,
        };
    }
    return React.createElement('div', {
        className: classNames,
        style: style,
    }, props.children);
};
function getColSpan(schema) {
    var _a;
    const layout = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.layout;
    const colSpan = layout === null || layout === void 0 ? void 0 : layout.colSpan;
    if (!colSpan && isObjectType(schema)) {
        return 'all';
    }
    return colSpan;
}
function getRowSpan(schema) {
    var _a;
    const layout = (_a = schema.lime) === null || _a === void 0 ? void 0 : _a.layout;
    return layout === null || layout === void 0 ? void 0 : layout.rowSpan;
}
