import { MicroEditorBase } from "../../../Views/editor/MicroEditorBase.js";
export class ListEditorBase extends MicroEditorBase {
    get items() {
        return this.listId == "list" ?
            this.source.state.get(this.listId) :
            this.source.feature.initializers[this.listId];
    }
    get listId() {
        return this.source.state.get("listId", "list");
    }
}
export class ListEditor extends ListEditorBase {
    get selectNode() {
        return this.node.find("select");
    }
    template() {
        return `<div><select style="box-sizing:border-box;width: 100%; height: 25px;border:0 solid transparent;box-shadow:none;"></select></div>`;
    }
    onActivate(e) {
        super.onActivate(e);
        this.items.forEach(item => {
            this.selectNode.append(`<option value="${item.value}">${item.name}</option>`);
        });
        this.selectNode.val(this.source.getFeaturePrimaryValue());
        this.selectNode.on(Jade.BrowserEvent.CHANGE, (e) => {
            this.source.setFeaturePrimaryValue(this.selectNode.val());
        });
        this.selectNode.on(Jade.BrowserEvent.FOCUS, () => { this.focus(); });
    }
    focus() {
        this.node.find("select").focus();
    }
}
