import { Timestamp } from '../timestamp';
import Renderables from '../Renderables';
import node from "../../support/node";
import { Specification } from "../../support/Specification";
/**
 * Implementation of the 'form' markup element.
 * A form HTML element is created and the class
 * lto-form is added to allow CSS manipulations.
 *
 * @see {@link IRenderable}
 * @see {@link IStackeable}
 * @see {@link Submit}
 */
var Form = /** @class */ (function () {
    function Form(message) {
        this.spec = message;
    }
    /**
     * @inheritDoc
     */
    Form.prototype.render = function (renderer, isNested) {
        var _this = this;
        var form = node("form");
        new Specification(this.spec).initNode(form, "lto-form");
        form.setAriaLabel(this.spec.ariaLabel);
        // this prevents a page reload when pressing "enter" and thus submitting the form
        form.unwrap().onsubmit = function () { return false; };
        form.unwrap().appendChild(Timestamp.render());
        var elements = (this.spec.elements || []).map(function (e) { return renderer.render(e, _this); });
        elements.forEach(function (e) { return e.forEach(function (x) { return form.unwrap().appendChild(x); }); });
        isNested && form.addClasses('lto-nested');
        return form.unwrap();
    };
    return Form;
}());
export { Form };
Renderables.register("form", Form);
//# sourceMappingURL=index.js.map