import { h } from "@stencil/core";
export class BceElementInput {
    constructor() {
        this.handleInput = (event) => {
            event.cancelBubble = true;
            const target = event.target;
            this.value = target.value;
            this.el.dispatchEvent(new Event('input', { bubbles: true }));
        };
    }
    render() {
        if (!this.template)
            return null;
        const type = this.template.multiline ? 'textarea' : 'text';
        return [
            h("p", null, this.template.question),
            h("bce-input", { onInput: this.handleInput, validation: this.template.required ? 'required' : '', type: type })
        ];
    }
    static get is() { return "bce-element-input"; }
    static get originalStyleUrls() { return {
        "$": ["bce-element-input.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["bce-element-input.css"]
    }; }
    static get properties() { return {
        "template": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "Block.ElementInput.Template",
                "resolved": "undefined | { readonly answer: string; readonly question: string; readonly required: boolean; readonly multiline: boolean; readonly min: number | null; readonly max: number | null; readonly hasAnswer: boolean; }",
                "references": {
                    "Block": {
                        "location": "import",
                        "path": "../../models/block"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "value": {
            "type": "any",
            "mutable": false,
            "complexType": {
                "original": "any",
                "resolved": "any",
                "references": {}
            },
            "required": true,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "value",
            "reflect": false
        }
    }; }
    static get elementRef() { return "el"; }
}
