UNPKG

@web-atoms/core

Version:
86 lines (85 loc) 2.99 kB
System.register(["tslib", "../../App", "../../di/Inject", "./AtomControl", "./AtomItemsControl"], function (_export, _context) { "use strict"; var __decorate, __metadata, __param, App, Inject, AtomControl, AtomItemsControl, AtomComboBoxItemTemplate, AtomComboBox; return { setters: [function (_tslib) { __decorate = _tslib.__decorate; __metadata = _tslib.__metadata; __param = _tslib.__param; }, function (_App) { App = _App.App; }, function (_diInject) { Inject = _diInject.Inject; }, function (_AtomControl) { AtomControl = _AtomControl.AtomControl; }, function (_AtomItemsControl) { AtomItemsControl = _AtomItemsControl.AtomItemsControl; }], execute: function () { _export("AtomComboBox", AtomComboBox = class AtomComboBox extends AtomItemsControl { constructor(app, e) { super(app, e || document.createElement("select")); this.allowMultipleSelection = false; } onCollectionChanged(key, index, item) { super.onCollectionChanged(key, index, item); try { this.isChanging = true; const se = this.element; se.selectedIndex = this.selectedIndex; } finally { this.isChanging = false; } } updateSelectionBindings() { super.updateSelectionBindings(); try { if (this.isChanging) { return; } this.isChanging = true; const se = this.element; se.selectedIndex = this.selectedIndex; } finally { this.isChanging = false; } } preCreate() { super.preCreate(); this.itemTemplate = AtomComboBoxItemTemplate; this.runAfterInit(() => { this.bindEvent(this.element, "change", s => { if (this.isChanging) { return; } try { this.isChanging = true; const index = this.element.selectedIndex; if (index === -1) { this.selectedItems.clear(); return; } this.selectedItem = this.items[index]; } finally { this.isChanging = false; } }); }); } }); _export("AtomComboBox", AtomComboBox = __decorate([__param(0, Inject), __metadata("design:paramtypes", [App, HTMLElement])], AtomComboBox)); AtomComboBoxItemTemplate = class AtomComboBoxItemTemplate extends AtomControl { constructor(app, e) { super(app, e || document.createElement("option")); } create() { this.bind(this.element, "text", [["data"]], false, v => { const ip = this.element._templateParent; return v[ip.labelPath]; }); } }; } }; }); //# sourceMappingURL=AtomComboBox.js.map