slim-select 4.0.7 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/react/index.js +151 -66
- package/dist/react/index.umd.js +1 -1
- package/dist/render.d.ts +18 -1
- package/dist/settings.d.ts +3 -0
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.css +1 -1
- package/dist/slimselect.css.map +1 -1
- package/dist/slimselect.es.js +151 -66
- package/dist/slimselect.es.js.map +1 -1
- package/dist/slimselect.iife.js +1 -1
- package/dist/slimselect.iife.js.map +1 -1
- package/dist/slimselect.js +1 -1
- package/dist/slimselect.js.map +1 -1
- package/dist/vue/index.js +151 -66
- package/dist/vue/index.umd.js +1 -1
- package/package.json +20 -20
- package/src/slim-select/slimselect.scss +89 -51
package/dist/vue/index.js
CHANGED
|
@@ -52,7 +52,7 @@ var s = class {
|
|
|
52
52
|
constructor(e) {
|
|
53
53
|
e ||= {};
|
|
54
54
|
let t = (e = "", t = "") => `${e} ${t}`.trim();
|
|
55
|
-
this.main = t("ss-main", e.main), this.placeholder = t("ss-placeholder", e.placeholder), this.values = t("ss-values", e.values), this.single = t("ss-single", e.single), this.multiString = t("ss-multi-string", e.multiString), this.max = t("ss-max", e.max), this.value = t("ss-value", e.value), this.valueText = t("ss-value-text", e.valueText), this.valueDelete = t("ss-value-delete", e.valueDelete), this.valueOut = t("ss-value-out", e.valueOut), this.deselect = t("ss-deselect", e.deselect), this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = t("ss-arrow", e.arrow), this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = t("ss-content", e.content), this.contentOpen = t("ss-open", e.contentOpen), this.dirAbove = t("ss-dir-above", e.dirAbove), this.dirBelow = t("ss-dir-below", e.dirBelow), this.search = t("ss-search", e.search), this.searchHighlighter = t("ss-search-highlight", e.searchHighlighter), this.searching = t("ss-searching", e.searching), this.status = t("ss-status", e.status), this.addable = t("ss-addable", e.addable), this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = t("ss-list", e.list), this.optgroup = t("ss-optgroup", e.optgroup), this.optgroupLabel = t("ss-optgroup-label", e.optgroupLabel), this.optgroupLabelText = t("ss-optgroup-label-text", e.optgroupLabelText), this.optgroupActions = t("ss-optgroup-actions", e.optgroupActions), this.optgroupSelectAll = t("ss-selectall", e.optgroupSelectAll), this.optgroupSelectAllBox = e.optgroupSelectAllBox || "
|
|
55
|
+
this.main = t("ss-main", e.main), this.placeholder = t("ss-placeholder", e.placeholder), this.values = t("ss-values", e.values), this.single = t("ss-single", e.single), this.multiString = t("ss-multi-string", e.multiString), this.max = t("ss-max", e.max), this.value = t("ss-value", e.value), this.valueText = t("ss-value-text", e.valueText), this.valueDelete = t("ss-value-delete", e.valueDelete), this.valueOut = t("ss-value-out", e.valueOut), this.deselect = t("ss-deselect", e.deselect), this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = t("ss-arrow", e.arrow), this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = t("ss-content", e.content), this.contentOpen = t("ss-open", e.contentOpen), this.dirAbove = t("ss-dir-above", e.dirAbove), this.dirBelow = t("ss-dir-below", e.dirBelow), this.search = t("ss-search", e.search), this.searchHighlighter = t("ss-search-highlight", e.searchHighlighter), this.searching = t("ss-searching", e.searching), this.status = t("ss-status", e.status), this.addable = t("ss-addable", e.addable), this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = t("ss-list", e.list), this.optgroup = t("ss-optgroup", e.optgroup), this.optgroupLabel = t("ss-optgroup-label", e.optgroupLabel), this.optgroupLabelText = t("ss-optgroup-label-text", e.optgroupLabelText), this.optgroupActions = t("ss-optgroup-actions", e.optgroupActions), this.optgroupSelectAll = t("ss-selectall", e.optgroupSelectAll), this.optgroupSelectAllBox = e.optgroupSelectAllBox || "M15,15 L85,15 L85,85 L15,85 Z", this.optgroupSelectAllCheck = e.optgroupSelectAllCheck || "M25,50 L42,68 L75,32", this.optgroupClosable = t("ss-closable", e.optgroupClosable), this.option = t("ss-option", e.option), this.optionDelete = e.optionDelete || "M10,10 L90,90 M10,90 L90,10", this.highlighted = t("ss-highlighted", e.highlighted), this.modalOverlay = t("ss-modal-overlay", e.modalOverlay), this.modalDialog = t("ss-modal-dialog", e.modalDialog), this.modalTitle = t("ss-modal-title", e.modalTitle), this.modalClose = t("ss-modal-close", e.modalClose), this.modalContent = t("ss-modal-content", e.modalContent), this.mainOpen = t("ss-open", e.mainOpen), this.close = t("ss-close", e.close), this.selected = t("ss-selected", e.selected), this.error = t("ss-error", e.error), this.disabled = t("ss-disabled", e.disabled), this.hide = t("ss-hide", e.hide);
|
|
56
56
|
}
|
|
57
57
|
getFirst(e) {
|
|
58
58
|
return this[e].split(" ")[0];
|
|
@@ -146,10 +146,13 @@ var _ = class {
|
|
|
146
146
|
maxValuesShown;
|
|
147
147
|
maxValuesMessage;
|
|
148
148
|
addableText;
|
|
149
|
+
selectAll;
|
|
150
|
+
selectAllText;
|
|
151
|
+
unselectAllText;
|
|
149
152
|
modal;
|
|
150
153
|
modalTitle;
|
|
151
154
|
constructor(e) {
|
|
152
|
-
e ||= {}, this.id = "ss-" + x(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 && e.disabled, this.alwaysOpen = e.alwaysOpen !== void 0 && e.alwaysOpen, this.showSearch = e.showSearch === void 0 || e.showSearch, this.focusSearch = e.focusSearch === void 0 || e.focusSearch, this.keepSearch = e.keepSearch !== void 0 && e.keepSearch, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.resultsText = e.resultsText || "{count} results available", this.deselectText = e.deselectText || "Clear", this.removeText = e.removeText || "Remove", this.searchHighlight = e.searchHighlight !== void 0 && e.searchHighlight, this.closeOnSelect = e.closeOnSelect === void 0 || e.closeOnSelect, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.contentWidth = e.contentWidth || "", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText === void 0 ? "Select Value" : e.placeholderText, this.allowDeselect = e.allowDeselect !== void 0 && e.allowDeselect, this.hideSelected = e.hideSelected !== void 0 && e.hideSelected, this.multiString = e.multiString !== void 0 && e.multiString, this.keepOrder = e.keepOrder !== void 0 && e.keepOrder, this.showOptionTooltips = e.showOptionTooltips !== void 0 && e.showOptionTooltips, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || "Press \"Enter\" to add {value}", this.modal = e.modal || "mobile", this.modalTitle = e.modalTitle || "";
|
|
155
|
+
e ||= {}, this.id = "ss-" + x(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 && e.disabled, this.alwaysOpen = e.alwaysOpen !== void 0 && e.alwaysOpen, this.showSearch = e.showSearch === void 0 || e.showSearch, this.focusSearch = e.focusSearch === void 0 || e.focusSearch, this.keepSearch = e.keepSearch !== void 0 && e.keepSearch, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.resultsText = e.resultsText || "{count} results available", this.deselectText = e.deselectText || "Clear", this.removeText = e.removeText || "Remove", this.searchHighlight = e.searchHighlight !== void 0 && e.searchHighlight, this.closeOnSelect = e.closeOnSelect === void 0 || e.closeOnSelect, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.contentWidth = e.contentWidth || "", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText === void 0 ? "Select Value" : e.placeholderText, this.allowDeselect = e.allowDeselect !== void 0 && e.allowDeselect, this.hideSelected = e.hideSelected !== void 0 && e.hideSelected, this.multiString = e.multiString !== void 0 && e.multiString, this.keepOrder = e.keepOrder !== void 0 && e.keepOrder, this.showOptionTooltips = e.showOptionTooltips !== void 0 && e.showOptionTooltips, this.minSelected = e.minSelected || 0, this.maxSelected = e.maxSelected || 1e3, this.timeoutDelay = e.timeoutDelay || 200, this.maxValuesShown = e.maxValuesShown || 20, this.maxValuesMessage = e.maxValuesMessage || "{number} selected", this.addableText = e.addableText || "Press \"Enter\" to add {value}", this.selectAll = e.selectAll !== void 0 && e.selectAll, this.selectAllText = e.selectAllText || "Select All", this.unselectAllText = e.unselectAllText || "Unselect All", this.modal = e.modal || "mobile", this.modalTitle = e.modalTitle || "";
|
|
153
156
|
}
|
|
154
157
|
};
|
|
155
158
|
//#endregion
|
|
@@ -341,7 +344,7 @@ var P = class {
|
|
|
341
344
|
if (this.state === "closed" || this.state === "closing" || this.handlers.beforeClose && this.handlers.beforeClose(e) === !1) return !1;
|
|
342
345
|
this.cancelPending();
|
|
343
346
|
let t = ++this.generation;
|
|
344
|
-
return this.handlers.onClose && this.handlers.onClose(e), this.state = "closing", await this.waitForPhase("close", t), t === this.generation
|
|
347
|
+
return this.handlers.onClose && this.handlers.onClose(e), this.state = "closing", await this.waitForPhase("close", t), t === this.generation && (this.state = "closed", this.handlers.afterClose && this.handlers.afterClose(), this.handlers.onCloseReady && this.handlers.onCloseReady(), !0);
|
|
345
348
|
}
|
|
346
349
|
cancelPending() {
|
|
347
350
|
this.generation++, this.animationAbort?.abort(), this.animationAbort = null, this.pendingTimer &&= (clearTimeout(this.pendingTimer), null);
|
|
@@ -407,16 +410,18 @@ var P = class {
|
|
|
407
410
|
}
|
|
408
411
|
validateDataArray(e) {
|
|
409
412
|
if (!Array.isArray(e)) return /* @__PURE__ */ Error("Data must be an array");
|
|
410
|
-
for (let t of e) if (t)
|
|
411
|
-
if (
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
413
|
+
for (let t of e) if (t) {
|
|
414
|
+
if (t instanceof L || "label" in t) {
|
|
415
|
+
if (!("label" in t)) return /* @__PURE__ */ Error("Optgroup must have a label");
|
|
416
|
+
if ("options" in t && t.options) for (let e of t.options) {
|
|
417
|
+
let t = this.validateOption(e);
|
|
418
|
+
if (t) return t;
|
|
419
|
+
}
|
|
420
|
+
} else if (t instanceof I || "text" in t) {
|
|
421
|
+
let e = this.validateOption(t);
|
|
422
|
+
if (e) return e;
|
|
423
|
+
} else return /* @__PURE__ */ Error("Data object must be a valid optgroup or option");
|
|
424
|
+
}
|
|
420
425
|
return null;
|
|
421
426
|
}
|
|
422
427
|
validateOption(e) {
|
|
@@ -556,10 +561,12 @@ var P = class {
|
|
|
556
561
|
let a = [];
|
|
557
562
|
if (i.options.forEach((i) => {
|
|
558
563
|
(!e || e(i)) && (t ? a.push(n ? new I(i) : i) : r.push(n ? new I(i) : i));
|
|
559
|
-
}), a.length > 0)
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
564
|
+
}), a.length > 0) {
|
|
565
|
+
if (n) {
|
|
566
|
+
let e = new L(i);
|
|
567
|
+
e.options = a, r.push(e);
|
|
568
|
+
} else r.push(this.createOptgroupView(i, a));
|
|
569
|
+
}
|
|
563
570
|
}
|
|
564
571
|
i instanceof I && (!e || e(i)) && r.push(n ? new I(i) : i);
|
|
565
572
|
}), r;
|
|
@@ -701,7 +708,7 @@ var P = class {
|
|
|
701
708
|
close() {
|
|
702
709
|
this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose);
|
|
703
710
|
let e = this.modalSessionActive === !0;
|
|
704
|
-
this.removeClasses(this.content.main, this.classes.contentOpen), e || (this.removeClasses(this.main.main, this.classes.dirAbove), this.removeClasses(this.main.main, this.classes.dirBelow)), e && this.modalElements && this.removeClasses(this.modalElements.overlay, this.classes.contentOpen), this.modalSessionActive = null, this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant");
|
|
711
|
+
this.removeClasses(this.content.main, this.classes.contentOpen), e || (this.removeClasses(this.main.main, this.classes.dirAbove), this.removeClasses(this.main.main, this.classes.dirBelow)), e && this.modalElements && this.removeClasses(this.modalElements.overlay, this.classes.contentOpen), this.modalSessionActive = null, this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant"), this.clearValueChipHighlight();
|
|
705
712
|
}
|
|
706
713
|
clearDirectionClasses() {
|
|
707
714
|
this.removeClasses(this.main.main, this.classes.dirAbove), this.removeClasses(this.main.main, this.classes.dirBelow), this.removeClasses(this.content.main, this.classes.dirAbove), this.removeClasses(this.content.main, this.classes.dirBelow);
|
|
@@ -808,7 +815,8 @@ var P = class {
|
|
|
808
815
|
if (t.length === 0) {
|
|
809
816
|
this.main.values.innerHTML = this.placeholder().outerHTML;
|
|
810
817
|
return;
|
|
811
|
-
}
|
|
818
|
+
}
|
|
819
|
+
{
|
|
812
820
|
let e = this.main.values.querySelector("." + this.classes.getFirst("placeholder"));
|
|
813
821
|
e && e.remove();
|
|
814
822
|
}
|
|
@@ -823,7 +831,8 @@ var P = class {
|
|
|
823
831
|
let e = document.createElement("div");
|
|
824
832
|
this.addClasses(e, this.classes.max), e.textContent = this.settings.maxValuesMessage.replace("{number}", t.length.toString()), this.main.values.innerHTML = e.outerHTML;
|
|
825
833
|
return;
|
|
826
|
-
}
|
|
834
|
+
}
|
|
835
|
+
{
|
|
827
836
|
let e = this.main.values.querySelector("." + this.classes.getFirst("max"));
|
|
828
837
|
e && e.remove();
|
|
829
838
|
}
|
|
@@ -852,6 +861,38 @@ var P = class {
|
|
|
852
861
|
let e = this.store.getSelectedOptions();
|
|
853
862
|
return this.settings.keepOrder && (e = this.store.selectedOrderOptions(e)), e.slice(0, this.settings.minSelected).map((e) => e.id);
|
|
854
863
|
}
|
|
864
|
+
getValueChips() {
|
|
865
|
+
return !this.settings.isMultiple || this.settings.multiString ? [] : Array.from(this.main.values.querySelectorAll("." + this.classes.getFirst("value"))).filter((e) => {
|
|
866
|
+
if (e.classList.contains(this.classes.getFirst("valueOut"))) return !1;
|
|
867
|
+
let t = e.querySelector("." + this.classes.getFirst("valueDelete"));
|
|
868
|
+
return !!t && !t.classList.contains(this.classes.getFirst("hide"));
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
getHighlightedValueChip() {
|
|
872
|
+
return this.getValueChips().find((e) => e.classList.contains(this.classes.getFirst("highlighted"))) ?? null;
|
|
873
|
+
}
|
|
874
|
+
clearValueChipHighlight() {
|
|
875
|
+
for (let e of Array.from(this.main.values.querySelectorAll("." + this.classes.getFirst("value")))) this.removeClasses(e, this.classes.highlighted);
|
|
876
|
+
}
|
|
877
|
+
highlightValueChip(e) {
|
|
878
|
+
this.clearValueChipHighlight(), e && this.addClasses(e, this.classes.highlighted);
|
|
879
|
+
}
|
|
880
|
+
navigateValueChips(e) {
|
|
881
|
+
let t = this.getValueChips();
|
|
882
|
+
if (t.length === 0) return !1;
|
|
883
|
+
let n = this.getHighlightedValueChip(), r = n ? t.indexOf(n) : -1;
|
|
884
|
+
return e === "left" ? (r === -1 ? this.highlightValueChip(t[t.length - 1]) : r > 0 && this.highlightValueChip(t[r - 1]), !0) : r !== -1 && (r < t.length - 1 ? this.highlightValueChip(t[r + 1]) : this.clearValueChipHighlight(), !0);
|
|
885
|
+
}
|
|
886
|
+
deleteValueChip(e = !1) {
|
|
887
|
+
let t = this.getValueChips();
|
|
888
|
+
if (t.length === 0) return !1;
|
|
889
|
+
let n = this.getHighlightedValueChip();
|
|
890
|
+
if (e && !n) return !1;
|
|
891
|
+
let r = n ?? t[t.length - 1], i = r.querySelector("." + this.classes.getFirst("valueDelete"));
|
|
892
|
+
if (!i) return !1;
|
|
893
|
+
let a = t.indexOf(r), o = n ? t[a - 1] ?? t[a + 1] ?? null : null;
|
|
894
|
+
return i.click(), o && o !== r && this.main.values.contains(o) ? this.highlightValueChip(o) : this.clearValueChipHighlight(), !0;
|
|
895
|
+
}
|
|
855
896
|
updateMultipleValueDeleteVisibility() {
|
|
856
897
|
if (!this.settings.isMultiple || this.settings.multiString) return;
|
|
857
898
|
let e = !this.isAtMinSelected(), t = this.main.values.querySelectorAll("." + this.classes.getFirst("valueDelete"));
|
|
@@ -911,7 +952,8 @@ var P = class {
|
|
|
911
952
|
if (this.settings.openPosition === "down") {
|
|
912
953
|
this.moveContentBelow();
|
|
913
954
|
return;
|
|
914
|
-
}
|
|
955
|
+
}
|
|
956
|
+
if (this.settings.openPosition === "up") {
|
|
915
957
|
this.moveContentAbove();
|
|
916
958
|
return;
|
|
917
959
|
}
|
|
@@ -943,21 +985,33 @@ var P = class {
|
|
|
943
985
|
let r = {
|
|
944
986
|
main: e,
|
|
945
987
|
input: t
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
988
|
+
}, i = this.settings.selectAll && this.settings.isMultiple;
|
|
989
|
+
this.settings.showSearch || (t.readOnly = !0, i ? this.addClasses(t, this.classes.hide) : this.addClasses(e, this.classes.hide)), t.type = "search", t.id = `${this.settings.id}-search`, t.placeholder = this.settings.searchPlaceholder, t.tabIndex = -1, t.setAttribute("aria-label", this.settings.searchPlaceholder), t.setAttribute("aria-autocomplete", "list"), t.setAttribute("autocapitalize", "off"), t.setAttribute("autocomplete", "off"), t.setAttribute("autocorrect", "off"), t.setAttribute("aria-hidden", "true");
|
|
990
|
+
let a = C(() => {
|
|
991
|
+
this.callbacks.search(t.value);
|
|
992
|
+
}, 100);
|
|
993
|
+
if (t.oninput = (e) => {
|
|
994
|
+
e.target.value !== "" && this.clearValueChipHighlight(), a();
|
|
995
|
+
}, t.onkeydown = (e) => {
|
|
950
996
|
switch (e.key) {
|
|
951
997
|
case "ArrowUp":
|
|
952
|
-
case "ArrowDown": return e.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
|
|
998
|
+
case "ArrowDown": return this.clearValueChipHighlight(), e.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
|
|
999
|
+
case "ArrowLeft":
|
|
1000
|
+
case "ArrowRight": return t.value !== "" || !this.navigateValueChips(e.key === "ArrowLeft" ? "left" : "right") || (e.preventDefault(), !1);
|
|
1001
|
+
case "Backspace": return t.value !== "" || !this.deleteValueChip() || (e.preventDefault(), !1);
|
|
1002
|
+
case "Delete": return t.value !== "" || !this.getHighlightedValueChip() || !this.deleteValueChip(!0) || (e.preventDefault(), !1);
|
|
953
1003
|
case "Tab": return this.requestClose("tab"), !0;
|
|
954
1004
|
case "Escape": return this.requestClose("escape"), !1;
|
|
955
1005
|
case "Enter":
|
|
956
|
-
let
|
|
957
|
-
return
|
|
1006
|
+
let r = this.content.list.querySelector("." + this.classes.getFirst("highlighted"));
|
|
1007
|
+
return r ? (r.click(), !1) : !this.callbacks.addable || (n.click(), !1);
|
|
958
1008
|
}
|
|
959
|
-
return !0;
|
|
960
|
-
}, e.appendChild(t),
|
|
1009
|
+
return e.key.length === 1 && this.clearValueChipHighlight(), !0;
|
|
1010
|
+
}, e.appendChild(t), i) {
|
|
1011
|
+
let t = this.createSelectAllControl(() => this.toggleGlobalSelectAll());
|
|
1012
|
+
e.appendChild(t), r.selectAll = t;
|
|
1013
|
+
}
|
|
1014
|
+
if (this.callbacks.addable) {
|
|
961
1015
|
this.addClasses(n, this.classes.addable);
|
|
962
1016
|
let t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
963
1017
|
t.setAttribute("viewBox", "0 0 100 100");
|
|
@@ -982,7 +1036,7 @@ var P = class {
|
|
|
982
1036
|
}, e);
|
|
983
1037
|
}
|
|
984
1038
|
}, r = this.callbacks.addable(t);
|
|
985
|
-
r
|
|
1039
|
+
r !== !1 && r != null && (r instanceof Promise ? r.then((e) => {
|
|
986
1040
|
typeof e == "string" ? n({
|
|
987
1041
|
text: e,
|
|
988
1042
|
value: e
|
|
@@ -1085,34 +1139,24 @@ var P = class {
|
|
|
1085
1139
|
this.addClasses(i, this.classes.optgroupLabelText), i.textContent = n.label, r.appendChild(i);
|
|
1086
1140
|
let a = document.createElement("div");
|
|
1087
1141
|
if (this.addClasses(a, this.classes.optgroupActions), r.appendChild(a), this.settings.isMultiple && n.selectAll) {
|
|
1088
|
-
let e =
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
let r = document.createElement("span");
|
|
1093
|
-
r.textContent = this.optgroupSelectAllLabel(t), e.appendChild(r);
|
|
1094
|
-
let i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1095
|
-
i.setAttribute("viewBox", "0 0 100 100"), e.appendChild(i);
|
|
1096
|
-
let o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1097
|
-
o.setAttribute("d", this.classes.optgroupSelectAllBox), i.appendChild(o);
|
|
1098
|
-
let s = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1099
|
-
s.setAttribute("d", this.classes.optgroupSelectAllCheck), i.appendChild(s), e.addEventListener("click", (e) => {
|
|
1100
|
-
e.preventDefault(), e.stopPropagation();
|
|
1101
|
-
let t = this.store.getSelected();
|
|
1102
|
-
if (this.isOptgroupAllSelected(n.options, new Set(t))) {
|
|
1103
|
-
let e = t.filter((e) => {
|
|
1142
|
+
let e = this.createSelectAllControl(() => {
|
|
1143
|
+
let e = this.store.getSelected();
|
|
1144
|
+
if (this.isOptgroupAllSelected(n.options, new Set(e))) {
|
|
1145
|
+
let t = e.filter((e) => {
|
|
1104
1146
|
for (let t of n.options) if (e === t.id) return !1;
|
|
1105
1147
|
return !0;
|
|
1106
1148
|
});
|
|
1107
|
-
this.callbacks.setSelected(
|
|
1149
|
+
this.callbacks.setSelected(t, !0);
|
|
1108
1150
|
return;
|
|
1109
|
-
}
|
|
1110
|
-
|
|
1151
|
+
}
|
|
1152
|
+
{
|
|
1153
|
+
let t = n.options.map((e) => e.id).filter((e) => e !== void 0), r = e.concat(t);
|
|
1111
1154
|
for (let e of n.options) e.id && !this.store.getOptionByID(e.id) && this.callbacks.addOption(new I(e));
|
|
1112
1155
|
this.callbacks.setSelected(r, !0);
|
|
1113
1156
|
return;
|
|
1114
1157
|
}
|
|
1115
|
-
}
|
|
1158
|
+
}, this.isOptgroupAllSelected(n.options));
|
|
1159
|
+
a.appendChild(e);
|
|
1116
1160
|
}
|
|
1117
1161
|
if (n.closable !== "off") {
|
|
1118
1162
|
let t = document.createElement("div");
|
|
@@ -1129,7 +1173,7 @@ var P = class {
|
|
|
1129
1173
|
}
|
|
1130
1174
|
n instanceof I && t.appendChild(this.option(n));
|
|
1131
1175
|
}
|
|
1132
|
-
this.content.list.appendChild(t), this.setOptionsListFullData(e), this.announce(this.settings.resultsText.replace("{count}", String(this.lastRenderedOptions.length)));
|
|
1176
|
+
this.content.list.appendChild(t), this.setOptionsListFullData(e), this.announce(this.settings.resultsText.replace("{count}", String(this.lastRenderedOptions.length))), this.updateGlobalSelectAllState();
|
|
1133
1177
|
}
|
|
1134
1178
|
canFilterOptionsInPlace() {
|
|
1135
1179
|
return this.optionsListIsFullData ? this.content.list.querySelector("." + this.classes.getFirst("option")) !== null : !1;
|
|
@@ -1150,7 +1194,7 @@ var P = class {
|
|
|
1150
1194
|
let o = a.placeholder || !a.display || a.selected && this.settings.hideSelected, s = t(a, n);
|
|
1151
1195
|
o || !s ? (this.addClasses(e, this.classes.hide), this.removeClasses(e, this.classes.highlighted)) : (this.removeClasses(e, this.classes.hide), this.setOptionElementContent(e, a, n), r.push(a)), a.selected ? (this.addClasses(e, this.classes.selected), e.setAttribute("aria-selected", "true")) : (this.removeClasses(e, this.classes.selected), e.setAttribute("aria-selected", "false"));
|
|
1152
1196
|
}
|
|
1153
|
-
this.lastRenderedOptions = r, this.updateOptgroupVisibilityAfterSearch(n), r.length === 0 ? this.updateSearchResultsMessage(0, n) : (this.removeListSearchMessage(), this.announce(this.settings.resultsText.replace("{count}", String(r.length)))), this.updateOptgroupSelectAllStates();
|
|
1197
|
+
this.lastRenderedOptions = r, this.updateOptgroupVisibilityAfterSearch(n), r.length === 0 ? this.updateSearchResultsMessage(0, n) : (this.removeListSearchMessage(), this.announce(this.settings.resultsText.replace("{count}", String(r.length)))), this.updateOptgroupSelectAllStates(), this.updateGlobalSelectAllState();
|
|
1154
1198
|
}
|
|
1155
1199
|
setOptionsListFullData(e) {
|
|
1156
1200
|
let t = this.store.getDataOptions(!1), n = e.map((e) => e instanceof I ? [e] : e.options.map((e) => new I(e))).flat();
|
|
@@ -1222,7 +1266,48 @@ var P = class {
|
|
|
1222
1266
|
let a = e.has(t);
|
|
1223
1267
|
a ? (this.addClasses(r, this.classes.selected), r.setAttribute("aria-selected", "true"), n = r) : (this.removeClasses(r, this.classes.selected), r.setAttribute("aria-selected", "false")), this.settings.hideSelected && (a ? this.addClasses(r, this.classes.hide) : (this.removeClasses(r, this.classes.hide), i.display || this.addClasses(r, this.classes.hide)));
|
|
1224
1268
|
}
|
|
1225
|
-
!this.settings.isMultiple && n ? this.main.main.setAttribute("aria-activedescendant", n.id) : !this.settings.isMultiple && e.size === 0 && this.main.main.removeAttribute("aria-activedescendant"), this.updateOptgroupSelectAllStates();
|
|
1269
|
+
!this.settings.isMultiple && n ? this.main.main.setAttribute("aria-activedescendant", n.id) : !this.settings.isMultiple && e.size === 0 && this.main.main.removeAttribute("aria-activedescendant"), this.updateOptgroupSelectAllStates(), this.updateGlobalSelectAllState();
|
|
1270
|
+
}
|
|
1271
|
+
createSelectAllControl(e, t = !1) {
|
|
1272
|
+
let n = document.createElement("div");
|
|
1273
|
+
this.addClasses(n, this.classes.optgroupSelectAll), n.setAttribute("role", "checkbox"), n.setAttribute("aria-checked", t ? "true" : "false"), n.setAttribute("aria-label", this.selectAllLabel(t)), n.tabIndex = -1, t && this.addClasses(n, this.classes.selected);
|
|
1274
|
+
let r = document.createElement("span");
|
|
1275
|
+
r.textContent = this.selectAllLabel(t), n.appendChild(r);
|
|
1276
|
+
let i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1277
|
+
i.setAttribute("viewBox", "0 0 100 100"), i.setAttribute("aria-hidden", "true"), n.appendChild(i);
|
|
1278
|
+
let a = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1279
|
+
a.setAttribute("d", this.classes.optgroupSelectAllBox), i.appendChild(a);
|
|
1280
|
+
let o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1281
|
+
return o.setAttribute("d", this.classes.optgroupSelectAllCheck), i.appendChild(o), n.addEventListener("click", (t) => {
|
|
1282
|
+
t.preventDefault(), t.stopPropagation(), e();
|
|
1283
|
+
}), n;
|
|
1284
|
+
}
|
|
1285
|
+
getSelectableOptions() {
|
|
1286
|
+
return this.store.getDataOptions(!1).filter((e) => !e.disabled && !e.placeholder && e.display);
|
|
1287
|
+
}
|
|
1288
|
+
isGlobalAllSelected(e) {
|
|
1289
|
+
let t = this.getSelectableOptions();
|
|
1290
|
+
if (t.length === 0) return !1;
|
|
1291
|
+
let n = e || new Set(this.store.getSelected());
|
|
1292
|
+
for (let e of t) if (!n.has(e.id)) return !1;
|
|
1293
|
+
return !0;
|
|
1294
|
+
}
|
|
1295
|
+
toggleGlobalSelectAll() {
|
|
1296
|
+
let e = this.getSelectableOptions(), t = new Set(this.store.getSelected());
|
|
1297
|
+
if (this.isGlobalAllSelected(t)) {
|
|
1298
|
+
let t = new Set(e.map((e) => e.id)), n = this.store.getSelected().filter((e) => !t.has(e));
|
|
1299
|
+
this.callbacks.setSelected(n, !0);
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
this.callbacks.setSelected(e.map((e) => e.id), !0);
|
|
1303
|
+
}
|
|
1304
|
+
updateGlobalSelectAllState() {
|
|
1305
|
+
let e = this.content.search.selectAll;
|
|
1306
|
+
if (!e || !this.settings.isMultiple || !this.settings.selectAll) return;
|
|
1307
|
+
let t = this.isGlobalAllSelected();
|
|
1308
|
+
t ? this.addClasses(e, this.classes.selected) : this.removeClasses(e, this.classes.selected), e.setAttribute("aria-checked", t ? "true" : "false"), e.setAttribute("aria-label", this.selectAllLabel(t));
|
|
1309
|
+
let n = e.querySelector("span");
|
|
1310
|
+
n && (n.textContent = this.selectAllLabel(t));
|
|
1226
1311
|
}
|
|
1227
1312
|
updateOptgroupSelectAllStates() {
|
|
1228
1313
|
if (!this.settings.isMultiple) return;
|
|
@@ -1238,13 +1323,13 @@ var P = class {
|
|
|
1238
1323
|
break;
|
|
1239
1324
|
}
|
|
1240
1325
|
}
|
|
1241
|
-
i ? this.addClasses(t, this.classes.selected) : this.removeClasses(t, this.classes.selected);
|
|
1326
|
+
i ? this.addClasses(t, this.classes.selected) : this.removeClasses(t, this.classes.selected), t.setAttribute("aria-checked", i ? "true" : "false"), t.setAttribute("aria-label", this.selectAllLabel(i));
|
|
1242
1327
|
let a = t.querySelector("span");
|
|
1243
|
-
a && (a.textContent = this.
|
|
1328
|
+
a && (a.textContent = this.selectAllLabel(i));
|
|
1244
1329
|
}
|
|
1245
1330
|
}
|
|
1246
|
-
|
|
1247
|
-
return e ?
|
|
1331
|
+
selectAllLabel(e) {
|
|
1332
|
+
return e ? this.settings.unselectAllText : this.settings.selectAllText;
|
|
1248
1333
|
}
|
|
1249
1334
|
isOptgroupAllSelected(e, t) {
|
|
1250
1335
|
if (e.length === 0) return !1;
|
|
@@ -1723,9 +1808,7 @@ var W = class {
|
|
|
1723
1808
|
case "selection":
|
|
1724
1809
|
this.applySelection(e.values, e.source, e.runAfterChange !== !1);
|
|
1725
1810
|
break;
|
|
1726
|
-
case "addOption":
|
|
1727
|
-
this.applyAddOption(e.option);
|
|
1728
|
-
break;
|
|
1811
|
+
case "addOption": this.applyAddOption(e.option);
|
|
1729
1812
|
}
|
|
1730
1813
|
}
|
|
1731
1814
|
applyStructure(e, t, n = !1, r = !1) {
|
|
@@ -1776,10 +1859,12 @@ var W = class {
|
|
|
1776
1859
|
}
|
|
1777
1860
|
return !1;
|
|
1778
1861
|
};
|
|
1779
|
-
if (!c(t.getData(!1)))
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1862
|
+
if (!c(t.getData(!1))) {
|
|
1863
|
+
if (o) {
|
|
1864
|
+
let n = t.getCatalogData();
|
|
1865
|
+
c(n) || t.setData([...n, new I(e)], !0), t.snapshotCatalog();
|
|
1866
|
+
} else t.addOption(e), t.snapshotCatalog();
|
|
1867
|
+
}
|
|
1783
1868
|
let l = t.getData(!1);
|
|
1784
1869
|
if (o) {
|
|
1785
1870
|
let e = t.getSelectedOptions();
|
|
@@ -1818,7 +1903,7 @@ var W = class {
|
|
|
1818
1903
|
e.events && e.events.error && e.events.error(/* @__PURE__ */ Error("Element isnt of type select"));
|
|
1819
1904
|
return;
|
|
1820
1905
|
}
|
|
1821
|
-
this.selectEl.dataset.ssid && this.destroy(), this.settings = new _(e.settings), this.cssClasses = new s(e.cssClasses);
|
|
1906
|
+
this.selectEl.dataset.ssid && this.destroy(), this.settings = new _(e.settings), e.settings?.selectAll === void 0 && this.selectEl.dataset.selectall === "true" && (this.settings.selectAll = !0), this.cssClasses = new s(e.cssClasses);
|
|
1822
1907
|
let t = [
|
|
1823
1908
|
"beforeOpen",
|
|
1824
1909
|
"afterOpen",
|