import { h } from "@stencil/core";
import { linker } from '../../utils/input-linker';
export class BceElementTextTemplate {
    constructor() {
        this.text = '';
        this.placeholderText = '';
        this._link = linker(this, this.handleInput);
        this._text = this._link('text');
    }
    handleInput(name, event) {
        const input = event.target;
        if (!input)
            return;
        event.cancelBubble = true;
        this[name] = input.value;
        this.value = this.updateValue({ [name]: input.value });
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    updateValue(part = {}) {
        const current = { text: this.text };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = { text: this.text };
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        return h("bce-input", Object.assign({ type: "textarea" }, this._text));
    }
    static get is() { return "bce-element-text-template"; }
    static get properties() { return {
        "value": {
            "type": "unknown",
            "mutable": true,
            "complexType": {
                "original": "TextTemplate",
                "resolved": "undefined | { readonly text: string; }",
                "references": {
                    "TextTemplate": {
                        "location": "local"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "text": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "text",
            "reflect": false,
            "defaultValue": "''"
        },
        "placeholderText": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "placeholder-text",
            "reflect": false,
            "defaultValue": "''"
        }
    }; }
    static get elementRef() { return "el"; }
}
