import { h } from "@stencil/core";
import { ElementQuestionBase } from '../../utils/element-question-base';
import { linker } from '../../utils/input-linker';
export class BceElementMatrixTemplate {
    constructor() {
        this.optionIcon = 'fas:columns';
        this.question = '';
        this.required = false;
        this.columns = [];
        this.rows = [];
        this.labelQuestion = 'Formulate your question';
        this.labelRequired = 'Required';
        this.labelOCAddButton = 'Add';
        this.labelOCRemoveButton = 'Delete';
        this.labelOCOther = 'Other';
        this.labelOCImage = 'Image';
        this.labelRows = 'Rows';
        this.labelColumns = 'Columns';
        this.placeholderRows = 'Row';
        this.placeholderColumns = 'Column';
        this._link = linker(this, this.handleInput);
        this._question = this._link('question');
        this._required = this._link('required');
        this._columns = this._link('columns');
        this._rows = this._link('rows');
    }
    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 = {
            question: this.question,
            required: this.required,
            columns: this.columns,
            rows: this.rows
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        const rows = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._rows);
        const columns = Object.assign({ icon: this.optionIcon, labelOCAddButton: this.labelOCAddButton, labelOCRemoveButton: this.labelOCRemoveButton, labelOCOther: this.labelOCOther, labelOCImage: this.labelOCImage }, this._columns);
        return (h(ElementQuestionBase, { question: this._question, required: this._required },
            h("div", null,
                h("bce-option-creator", Object.assign({}, rows)),
                h("bce-option-creator", Object.assign({}, columns)))));
    }
    static get is() { return "bce-element-matrix-template"; }
    static get originalStyleUrls() { return {
        "$": ["bce-element-matrix-template.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["bce-element-matrix-template.css"]
    }; }
    static get properties() { return {
        "value": {
            "type": "unknown",
            "mutable": true,
            "complexType": {
                "original": "MatrixTemplate",
                "resolved": "undefined | { readonly question: string; readonly required: boolean; readonly rows: SelectElementOption[]; readonly columns: SelectElementOption[]; }",
                "references": {
                    "MatrixTemplate": {
                        "location": "local"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "optionIcon": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "option-icon",
            "reflect": false,
            "defaultValue": "'fas:columns'"
        },
        "question": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "question",
            "reflect": false,
            "defaultValue": "''"
        },
        "required": {
            "type": "boolean",
            "mutable": true,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "required",
            "reflect": false,
            "defaultValue": "false"
        },
        "columns": {
            "type": "unknown",
            "mutable": true,
            "complexType": {
                "original": "MatrixTemplate['columns']",
                "resolved": "SelectElementOption[]",
                "references": {
                    "MatrixTemplate": {
                        "location": "local"
                    }
                }
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "defaultValue": "[]"
        },
        "rows": {
            "type": "unknown",
            "mutable": true,
            "complexType": {
                "original": "MatrixTemplate['rows']",
                "resolved": "SelectElementOption[]",
                "references": {
                    "MatrixTemplate": {
                        "location": "local"
                    }
                }
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "defaultValue": "[]"
        },
        "labelQuestion": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-question",
            "reflect": false,
            "defaultValue": "'Formulate your question'"
        },
        "labelRequired": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-required",
            "reflect": false,
            "defaultValue": "'Required'"
        },
        "labelOCAddButton": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-o-c-add-button",
            "reflect": false,
            "defaultValue": "'Add'"
        },
        "labelOCRemoveButton": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-o-c-remove-button",
            "reflect": false,
            "defaultValue": "'Delete'"
        },
        "labelOCOther": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-o-c-other",
            "reflect": false,
            "defaultValue": "'Other'"
        },
        "labelOCImage": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-o-c-image",
            "reflect": false,
            "defaultValue": "'Image'"
        },
        "labelRows": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-rows",
            "reflect": false,
            "defaultValue": "'Rows'"
        },
        "labelColumns": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-columns",
            "reflect": false,
            "defaultValue": "'Columns'"
        },
        "placeholderRows": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "placeholder-rows",
            "reflect": false,
            "defaultValue": "'Row'"
        },
        "placeholderColumns": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "placeholder-columns",
            "reflect": false,
            "defaultValue": "'Column'"
        }
    }; }
    static get elementRef() { return "el"; }
}
