import { h, Host } from "@stencil/core";
import { scrollToFirstInvalidField } from "../../utils/form";
import { waitAfterFramePaint, waitAfterIdleCallback } from "../../utils/helpers";
export class Form {
    constructor() {
        /**
         * If `true` a native form element is added as a wrapper of the slot.
         */
        this.native = false;
        /**
         * If `true` it adds the novalidate attribute to the native form element.
         */
        this.novalidate = false;
        /**
         * The css class for the inner form element
         */
        this.formClass = '';
    }
    /**
     * Scrolls to the first invalid field inside this form component.
     */
    async scrollToFirstInvalidField() {
        await waitAfterIdleCallback();
        await waitAfterFramePaint();
        scrollToFirstInvalidField({ formEl: this.el });
    }
    render() {
        const NativeEl = this.native ? 'form' : 'div';
        let attrs = {};
        if (this.native) {
            attrs = {
                novalidate: this.novalidate,
            };
        }
        return (h(Host, { key: '1598e29d7763c06aeebe9ae70e4ad27695c9796d' }, h(NativeEl, Object.assign({ key: '140fa29ca7900623d52da99ffc5f9bd6db72cd97' }, attrs, { class: this.formClass }), h("slot", { key: '1797bdbc8f4f70b50c5d193acea0569e977d8a81' }))));
    }
    static get is() { return "bal-form"; }
    static get originalStyleUrls() {
        return {
            "$": ["bal-form.sass"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bal-form.css"]
        };
    }
    static get properties() {
        return {
            "native": {
                "type": "boolean",
                "attribute": "native",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "If `true` a native form element is added as a wrapper of the slot."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "novalidate": {
                "type": "boolean",
                "attribute": "novalidate",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "If `true` it adds the novalidate attribute to the native form element."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "formClass": {
                "type": "string",
                "attribute": "form-class",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The css class for the inner form element"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "''"
            }
        };
    }
    static get methods() {
        return {
            "scrollToFirstInvalidField": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "Scrolls to the first invalid field inside this form component.",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
