@prof-dev/improved-select
Advanced tools
Comparing version 1.0.10 to 1.1.0
@@ -24,2 +24,3 @@ import { EventEmitter } from "@prof-dev/event-emitter"; | ||
private linkedOptions; | ||
private selectLabel; | ||
private selectedValueElements; | ||
@@ -26,0 +27,0 @@ private initialSelection; |
@@ -97,3 +97,3 @@ "use strict"; | ||
var _this = this; | ||
var _a; | ||
var _a, _b; | ||
_this = _super.call(this) || this; | ||
@@ -107,2 +107,3 @@ _this.element = element; | ||
_this.linkedOptions = []; | ||
_this.selectLabel = undefined; | ||
_this.selectedValueElements = []; | ||
@@ -167,2 +168,3 @@ _this.initialSelection = []; | ||
_this.selectedValueElements = Array.from(_this.element.querySelectorAll("[data-select-value]")); | ||
_this.selectLabel = (_a = _this.selectedValueElements[0]) === null || _a === void 0 ? void 0 : _a.innerHTML; | ||
_this.selectBody = _this.element.querySelector("[data-select-body]"); | ||
@@ -178,3 +180,3 @@ _this.searchInput = _this.element.querySelector("[data-select-search]"); | ||
_this.element.setAttribute("data-improved-select", "initialized"); | ||
_this.element.classList.toggle("is-multiple", ((_a = _this.select) === null || _a === void 0 ? void 0 : _a.multiple) === true); | ||
_this.element.classList.toggle("is-multiple", ((_b = _this.select) === null || _b === void 0 ? void 0 : _b.multiple) === true); | ||
improvedSelectElementsMap.set(element, _this); | ||
@@ -293,2 +295,3 @@ return _this; | ||
var _this = this; | ||
var _a; | ||
if (this.select) { | ||
@@ -302,3 +305,3 @@ var selectedOptions_1 = Array.from(this.select.selectedOptions); | ||
: selectedOptions_1.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); | ||
@@ -305,0 +308,0 @@ this.selectedValueElements.forEach(function (selectedValueElement) { |
{ | ||
"name": "@prof-dev/improved-select", | ||
"version": "1.0.10", | ||
"version": "1.1.0", | ||
"description": "Helper for live clicks events management", | ||
@@ -5,0 +5,0 @@ "main": "lib/ImprovedSelect.js", |
@@ -22,3 +22,3 @@ import { EventEmitter } from "@prof-dev/event-emitter"; | ||
class Select extends EventEmitter<SelectEventType, ImprovedSelect> {} | ||
class Select extends EventEmitter<SelectEventType, ImprovedSelect> { } | ||
@@ -36,2 +36,3 @@ export class ImprovedSelect extends Select { | ||
private linkedOptions: HTMLElement[] = []; | ||
private selectLabel: string | undefined = undefined; | ||
private selectedValueElements: HTMLElement[] = []; | ||
@@ -60,2 +61,3 @@ private initialSelection: number[] = []; | ||
); | ||
this.selectLabel = this.selectedValueElements[0]?.innerHTML; | ||
this.selectBody = this.element.querySelector("[data-select-body]"); | ||
@@ -187,6 +189,6 @@ this.searchInput = this.element.querySelector("[data-select-search]"); | ||
? selectedOptions | ||
.map((option) => this.linkedOptions[option.index]?.innerHTML) | ||
.join(", ") | ||
.map((option) => this.linkedOptions[option.index]?.innerHTML) | ||
.join(", ") | ||
: selectedOptions.map((option) => option.innerHTML).join(", ") | ||
: ""; | ||
: this.selectLabel ?? ""; | ||
@@ -251,4 +253,4 @@ this.isSelected = this.element.classList.toggle( | ||
searchValue.length > 0 && | ||
valueMatch !== true && | ||
textMatch !== true, | ||
valueMatch !== true && | ||
textMatch !== true, | ||
); | ||
@@ -255,0 +257,0 @@ } |
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
84333
1470