"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var Grid_1 = require("../../../../components/Grid");
var Markdown_1 = require("../../../../extra/Markdown");
var theme_1 = require("../../../../theme");
var LabelElement_1 = require("../LabelElement");
var WarningField_1 = require("../WarningField");
var REQUIRED_FIELD_SYMBOL = '*';
var Label = function (props) {
    var label = props.label, required = props.required, id = props.id;
    if (!label) {
        return null;
    }
    return (React.createElement(LabelElement_1.LabelElement, { className: "control-label", htmlFor: id },
        label,
        required && React.createElement("span", { className: "required" }, REQUIRED_FIELD_SYMBOL)));
};
var FieldTemplate = function (props) {
    var id = props.id, classNames = props.classNames, label = props.label, children = props.children, errors = props.errors, rawHelp = props.rawHelp, description = props.description, _a = props.hidden, hidden = _a === void 0 ? false : _a, _b = props.required, required = _b === void 0 ? false : _b, _c = props.displayLabel, displayLabel = _c === void 0 ? true : _c, uiSchema = props.uiSchema;
    if (hidden) {
        return children;
    }
    var warning = uiSchema['ui:warning'];
    return (React.createElement(Grid_1.Box, { mb: 2, className: (classNames || '') + " rendition-form__field--" + id },
        displayLabel && React.createElement(Label, { label: label, required: required, id: id }),
        displayLabel && !!warning && React.createElement(WarningField_1.WarningField, { warning: warning }),
        displayLabel && description ? description : null,
        children,
        errors,
        rawHelp && (React.createElement(Markdown_1.Markdown, { mt: 1, className: "rendition-form-help", color: theme_1.default.colors.text.light }, rawHelp))));
};
exports.default = FieldTemplate;
