@prof-dev/improved-select
Advanced tools
Comparing version 1.1.10 to 1.1.11
@@ -48,2 +48,3 @@ import { EventEmitter } from "@prof-dev/event-emitter"; | ||
private initResetBehavior; | ||
private updateSelectedValues; | ||
private updateActiveState; | ||
@@ -63,2 +64,3 @@ private updateSearchState; | ||
getSelectedOptions(): HTMLOptionElement[]; | ||
disable(force?: boolean): void; | ||
static create(element: HTMLElement, options?: SelectOptions): ImprovedSelect; | ||
@@ -65,0 +67,0 @@ static initAllAvailableOnPage(options?: SelectOptions): void; |
@@ -322,18 +322,25 @@ "use strict"; | ||
}; | ||
ImprovedSelect.prototype.updateActiveState = function () { | ||
ImprovedSelect.prototype.updateSelectedValues = function () { | ||
var _this = this; | ||
var _a; | ||
if (this.select) { | ||
var selectedOptions_1 = Array.from(this.select.selectedOptions); | ||
var selectedValuesText_1 = selectedOptions_1.length > 0 | ||
var selectedOptions = this.getSelectedOptions(); | ||
var selectedValuesText_1 = selectedOptions.length > 0 | ||
? this.isHtmlValue | ||
? selectedOptions_1 | ||
? selectedOptions | ||
.map(function (option) { var _a; return (_a = _this.linkedOptions[option.index]) === null || _a === void 0 ? void 0 : _a.innerHTML; }) | ||
.join(", ") | ||
: selectedOptions_1.map(function (option) { return option.innerHTML; }).join(", ") | ||
: selectedOptions.map(function (option) { return option.innerHTML; }).join(", ") | ||
: (_a = this.selectLabel) !== null && _a !== void 0 ? _a : ""; | ||
this.isSelected = this.element.classList.toggle("is-selected", selectedOptions_1.length > 0); | ||
this.selectedValueElements.forEach(function (selectedValueElement) { | ||
selectedValueElement.innerHTML = selectedValuesText_1; | ||
}); | ||
} | ||
}; | ||
ImprovedSelect.prototype.updateActiveState = function () { | ||
var _this = this; | ||
if (this.select) { | ||
var selectedOptions_1 = this.getSelectedOptions(); | ||
this.updateSelectedValues(); | ||
this.isSelected = this.element.classList.toggle("is-selected", selectedOptions_1.length > 0); | ||
this.linkedOptions.forEach(function (linkedOption, index) { | ||
@@ -386,2 +393,3 @@ if (_this.select) { | ||
this.initLinkedOptions(); | ||
this.updateSelectedValues(); | ||
}; | ||
@@ -447,2 +455,8 @@ ImprovedSelect.prototype.info = function () { | ||
}; | ||
ImprovedSelect.prototype.disable = function (force) { | ||
if (this.select) { | ||
this.select.disabled = force !== null && force !== void 0 ? force : true; | ||
this.onSelectAttributesChange(); | ||
} | ||
}; | ||
ImprovedSelect.create = function (element, options) { | ||
@@ -449,0 +463,0 @@ if (options === void 0) { options = {}; } |
{ | ||
"name": "@prof-dev/improved-select", | ||
"version": "1.1.10", | ||
"version": "1.1.11", | ||
"description": "Helper for live clicks events management", | ||
@@ -5,0 +5,0 @@ "main": "lib/ImprovedSelect.js", |
@@ -220,5 +220,5 @@ import { EventEmitter } from "@prof-dev/event-emitter"; | ||
private updateActiveState() { | ||
private updateSelectedValues() { | ||
if (this.select) { | ||
const selectedOptions = Array.from(this.select.selectedOptions); | ||
const selectedOptions = this.getSelectedOptions(); | ||
@@ -234,2 +234,14 @@ const selectedValuesText = | ||
this.selectedValueElements.forEach((selectedValueElement) => { | ||
selectedValueElement.innerHTML = selectedValuesText; | ||
}); | ||
} | ||
} | ||
private updateActiveState() { | ||
if (this.select) { | ||
const selectedOptions = this.getSelectedOptions(); | ||
this.updateSelectedValues(); | ||
this.isSelected = this.element.classList.toggle( | ||
@@ -240,6 +252,2 @@ "is-selected", | ||
this.selectedValueElements.forEach((selectedValueElement) => { | ||
selectedValueElement.innerHTML = selectedValuesText; | ||
}); | ||
this.linkedOptions.forEach((linkedOption, index) => { | ||
@@ -323,2 +331,4 @@ if (this.select) { | ||
this.initLinkedOptions(); | ||
this.updateSelectedValues(); | ||
} | ||
@@ -443,2 +453,10 @@ | ||
public disable(force?: boolean) { | ||
if (this.select) { | ||
this.select.disabled = force ?? true; | ||
this.onSelectAttributesChange(); | ||
} | ||
} | ||
static create( | ||
@@ -445,0 +463,0 @@ element: HTMLElement, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89652
1583