slim-select 4.0.3 → 4.0.5
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 +6 -2
- package/dist/index.d.ts +6 -4
- package/dist/lifecycle.d.ts +6 -15
- package/dist/react/index.js +93 -43
- package/dist/react/index.umd.js +1 -1
- package/dist/render.d.ts +10 -1
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.es.js +93 -43
- 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 +93 -43
- package/dist/vue/index.umd.js +1 -1
- package/package.json +6 -6
package/dist/vue/index.js
CHANGED
|
@@ -149,7 +149,7 @@ var _ = class {
|
|
|
149
149
|
modal;
|
|
150
150
|
modalTitle;
|
|
151
151
|
constructor(e) {
|
|
152
|
-
e ||= {}, this.id = "ss-" + x(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled
|
|
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 || "";
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
155
|
//#endregion
|
|
@@ -276,7 +276,7 @@ function M(e) {
|
|
|
276
276
|
return e[0] === e[0].toUpperCase() ? t.substring(1) : t;
|
|
277
277
|
}
|
|
278
278
|
function N(e, t = typeof window < "u" ? window.innerWidth : 768) {
|
|
279
|
-
return e === "on"
|
|
279
|
+
return e === "on" || e === "mobile" && t < 768;
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/slim-select/events.ts
|
|
@@ -334,11 +334,14 @@ var P = class {
|
|
|
334
334
|
}
|
|
335
335
|
this.state = "open", this.handlers.afterOpen && this.handlers.afterOpen(), this.handlers.onOpenReady && this.handlers.onOpenReady();
|
|
336
336
|
}
|
|
337
|
-
async requestClose(
|
|
338
|
-
|
|
337
|
+
async requestClose(e = {
|
|
338
|
+
source: "api",
|
|
339
|
+
selectionChanged: !1
|
|
340
|
+
}) {
|
|
341
|
+
if (this.state === "closed" || this.state === "closing" || this.handlers.beforeClose && this.handlers.beforeClose(e) === !1) return !1;
|
|
339
342
|
this.cancelPending();
|
|
340
|
-
let
|
|
341
|
-
this.handlers.
|
|
343
|
+
let t = ++this.generation;
|
|
344
|
+
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) : !1;
|
|
342
345
|
}
|
|
343
346
|
cancelPending() {
|
|
344
347
|
this.generation++, this.animationAbort?.abort(), this.animationAbort = null, this.pendingTimer &&= (clearTimeout(this.pendingTimer), null);
|
|
@@ -383,7 +386,7 @@ var P = class {
|
|
|
383
386
|
data;
|
|
384
387
|
mandatory;
|
|
385
388
|
constructor(e) {
|
|
386
|
-
this.id = !e.id || e.id === "" ? x() : e.id, this.value = e.value === void 0 ? e.text || "" : e.value || "", this.text = e.text || "", this.html = e.html || "", this.defaultSelected = e.defaultSelected
|
|
389
|
+
this.id = !e.id || e.id === "" ? x() : e.id, this.value = e.value === void 0 ? e.text || "" : e.value || "", this.text = e.text || "", this.html = e.html || "", this.defaultSelected = e.defaultSelected !== void 0 && e.defaultSelected, this.selected = e.selected !== void 0 && e.selected, this.display = e.display === void 0 || e.display, this.disabled = e.disabled !== void 0 && e.disabled, this.mandatory = e.mandatory !== void 0 && e.mandatory, this.placeholder = e.placeholder !== void 0 && e.placeholder, this.class = e.class || "", this.style = e.style || "", this.data = v(e.data);
|
|
387
390
|
}
|
|
388
391
|
}, L = class {
|
|
389
392
|
id;
|
|
@@ -392,7 +395,7 @@ var P = class {
|
|
|
392
395
|
closable;
|
|
393
396
|
options;
|
|
394
397
|
constructor(e) {
|
|
395
|
-
if (this.id = !e.id || e.id === "" ? x() : e.id, this.label = e.label || "", this.selectAll = e.selectAll
|
|
398
|
+
if (this.id = !e.id || e.id === "" ? x() : e.id, this.label = e.label || "", this.selectAll = e.selectAll !== void 0 && e.selectAll, this.closable = e.closable || "off", this.options = [], e.options) for (let t of e.options) this.options.push(new I(t));
|
|
396
399
|
}
|
|
397
400
|
}, R = class {
|
|
398
401
|
selectType = "single";
|
|
@@ -449,7 +452,7 @@ var P = class {
|
|
|
449
452
|
}) : new I({ ...e }));
|
|
450
453
|
}
|
|
451
454
|
optionMatchesSelected(e, t) {
|
|
452
|
-
return e.id === t.id
|
|
455
|
+
return e.id === t.id || t.value !== "" && e.value !== "" && e.value === t.value;
|
|
453
456
|
}
|
|
454
457
|
findOptionInData(e, t) {
|
|
455
458
|
for (let n of e) {
|
|
@@ -495,9 +498,9 @@ var P = class {
|
|
|
495
498
|
if (n instanceof L) for (let o of n.options) {
|
|
496
499
|
r ||= o;
|
|
497
500
|
let n = o[e] || "";
|
|
498
|
-
o.selected = i
|
|
501
|
+
o.selected = !i && t.includes(n), o.selected && (a.push(o), this.selectType === "single" && (i = !0));
|
|
499
502
|
}
|
|
500
|
-
n instanceof I && (r ||= n, n.selected = i
|
|
503
|
+
n instanceof I && (r ||= n, n.selected = !i && t.includes(n[e]), n.selected && (a.push(n), this.selectType === "single" && (i = !0)));
|
|
501
504
|
}
|
|
502
505
|
this.selectType === "single" && r && !i && !n && (r.selected = !0, a.push(r));
|
|
503
506
|
let o = t.map((t) => a.find((n) => n[e] === t)?.id || "");
|
|
@@ -597,6 +600,24 @@ var P = class {
|
|
|
597
600
|
constructor(e, t, n, r) {
|
|
598
601
|
this.store = n, this.settings = e, this.classes = t, this.callbacks = r, this.lastSelectedOption = null, this.lastRenderedOptions = [], this.main = this.mainDiv(), this.content = this.contentDiv(), this.updateClassStyles(), this.updateAriaAttributes(), this.settings.contentPosition !== "relative" && (this.content.main.style.top = "-9999px", this.content.main.style.left = "-9999px", this.content.main.style.margin = "0", this.content.main.style.width = "auto"), this.settings.contentLocation && this.settings.contentLocation.appendChild(this.content.main), this.settings.modal !== "off" && !this.settings.alwaysOpen && (this.modalElements = this.createModalElements(), document.body.appendChild(this.modalElements.overlay));
|
|
599
602
|
}
|
|
603
|
+
requestClose(e, t) {
|
|
604
|
+
this.callbacks.close({
|
|
605
|
+
source: e,
|
|
606
|
+
option: t?.option,
|
|
607
|
+
selectionChanged: t?.selectionChanged ?? !1
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
selectionChanged(e, t) {
|
|
611
|
+
if (e.length !== t.length) return !0;
|
|
612
|
+
let n = e.map((e) => e.id).sort(), r = t.map((e) => e.id).sort();
|
|
613
|
+
return n.some((e, t) => e !== r[t]);
|
|
614
|
+
}
|
|
615
|
+
closeOnSingleSelectReclick(e) {
|
|
616
|
+
this.settings.closeOnSelect && this.requestClose("select", {
|
|
617
|
+
option: e,
|
|
618
|
+
selectionChanged: !1
|
|
619
|
+
});
|
|
620
|
+
}
|
|
600
621
|
addClasses(e, t) {
|
|
601
622
|
if (!t || t.trim() === "") return;
|
|
602
623
|
let n = t.split(" ").filter((e) => e.trim() !== "");
|
|
@@ -642,13 +663,13 @@ var P = class {
|
|
|
642
663
|
this.settings.modalTitle ? (n = document.createElement("div"), this.addClasses(n, this.classes.modalTitle), n.id = `${this.settings.id}-modal-title`, n.textContent = this.settings.modalTitle, t.setAttribute("aria-labelledby", n.id)) : t.setAttribute("aria-label", this.settings.ariaLabel);
|
|
643
664
|
let r = document.createElement("button");
|
|
644
665
|
r.type = "button", this.addClasses(r, this.classes.modalClose), r.setAttribute("aria-label", "Close"), r.onclick = (e) => {
|
|
645
|
-
e.stopPropagation(), this.
|
|
666
|
+
e.stopPropagation(), this.requestClose("modal");
|
|
646
667
|
};
|
|
647
668
|
let i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
648
669
|
i.setAttribute("viewBox", "0 0 100 100");
|
|
649
670
|
let a = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
650
671
|
return a.setAttribute("d", this.classes.deselectPath), i.appendChild(a), r.appendChild(i), e.onclick = (t) => {
|
|
651
|
-
t.target === e && this.
|
|
672
|
+
t.target === e && this.requestClose("modal");
|
|
652
673
|
}, n && t.appendChild(n), e.appendChild(t), {
|
|
653
674
|
overlay: e,
|
|
654
675
|
dialog: t,
|
|
@@ -686,7 +707,7 @@ var P = class {
|
|
|
686
707
|
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);
|
|
687
708
|
}
|
|
688
709
|
updateClassStyles() {
|
|
689
|
-
if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.addClasses(this.main.main, this.classes.main), this.addClasses(this.content.main, this.classes.content), this.settings.style !== "" && (this.main.main.style.cssText = this.settings.style, this.content.main.style.cssText = this.settings.style), this.settings.class.length) for (let e of this.settings.class) e.trim() !== "" && this.main.main.classList.add(e.trim());
|
|
710
|
+
if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.addClasses(this.main.main, this.classes.main), this.addClasses(this.content.main, this.classes.content), this.settings.style !== "" && (this.main.main.style.cssText = this.settings.style, this.content.main.style.cssText = this.settings.style), this.settings.class.length) for (let e of this.settings.class) e.trim() !== "" && (this.main.main.classList.add(e.trim()), this.content.main.classList.add(e.trim()));
|
|
690
711
|
(this.settings.contentPosition === "relative" || this.settings.contentPosition === "fixed") && this.content.main.classList.add("ss-" + this.settings.contentPosition);
|
|
691
712
|
}
|
|
692
713
|
updateAriaAttributes() {
|
|
@@ -699,17 +720,17 @@ var P = class {
|
|
|
699
720
|
switch (e.key) {
|
|
700
721
|
case "ArrowUp":
|
|
701
722
|
case "ArrowDown": return this.callbacks.open(), e.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
|
|
702
|
-
case "Tab": return this.
|
|
723
|
+
case "Tab": return this.requestClose("tab"), !0;
|
|
703
724
|
case "Enter":
|
|
704
725
|
case " ":
|
|
705
726
|
this.callbacks.open();
|
|
706
727
|
let t = this.content.list.querySelector("." + this.classes.getFirst("highlighted"));
|
|
707
728
|
return t && t.click(), !1;
|
|
708
|
-
case "Escape": return this.
|
|
729
|
+
case "Escape": return this.requestClose("escape"), !1;
|
|
709
730
|
}
|
|
710
731
|
return e.key.length === 1 && this.callbacks.open(), !0;
|
|
711
732
|
}, e.onclick = (e) => {
|
|
712
|
-
this.settings.disabled || (this.settings.isOpen ? this.
|
|
733
|
+
this.settings.disabled || (this.settings.isOpen ? this.requestClose("toggle") : this.callbacks.open());
|
|
713
734
|
};
|
|
714
735
|
let t = document.createElement("div");
|
|
715
736
|
this.addClasses(t, this.classes.values), e.appendChild(t);
|
|
@@ -731,7 +752,7 @@ var P = class {
|
|
|
731
752
|
let e = this.store.getFirstOption(), t = e ? e.id : "";
|
|
732
753
|
this.callbacks.setSelected(t, !1);
|
|
733
754
|
}
|
|
734
|
-
this.settings.closeOnSelect && this.
|
|
755
|
+
this.settings.closeOnSelect && this.requestClose("deselect", { selectionChanged: !0 }), this.callbacks.afterChange && this.callbacks.afterChange(this.store.getSelectedOptions());
|
|
735
756
|
}
|
|
736
757
|
}, n.onkeydown = (e) => {
|
|
737
758
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), n.click());
|
|
@@ -851,7 +872,7 @@ var P = class {
|
|
|
851
872
|
if (t instanceof L) for (let n of t.options) n.id && e.push(n.id);
|
|
852
873
|
t instanceof I && e.push(t.id);
|
|
853
874
|
}
|
|
854
|
-
this.callbacks.setSelected(e, !1), this.settings.closeOnSelect && this.
|
|
875
|
+
this.callbacks.setSelected(e, !1), this.settings.closeOnSelect && this.requestClose("deselect", { selectionChanged: !0 }), this.callbacks.afterChange && this.callbacks.afterChange(i), this.updateDeselectAll(), this.updateMultipleValueDeleteVisibility();
|
|
855
876
|
}
|
|
856
877
|
};
|
|
857
878
|
let r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
@@ -929,8 +950,8 @@ var P = class {
|
|
|
929
950
|
switch (e.key) {
|
|
930
951
|
case "ArrowUp":
|
|
931
952
|
case "ArrowDown": return e.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
|
|
932
|
-
case "Tab": return this.
|
|
933
|
-
case "Escape": return this.
|
|
953
|
+
case "Tab": return this.requestClose("tab"), !0;
|
|
954
|
+
case "Escape": return this.requestClose("escape"), !1;
|
|
934
955
|
case "Enter":
|
|
935
956
|
let t = this.content.list.querySelector("." + this.classes.getFirst("highlighted"));
|
|
936
957
|
return t ? (t.click(), !1) : this.callbacks.addable ? (n.click(), !1) : !0;
|
|
@@ -957,7 +978,7 @@ var P = class {
|
|
|
957
978
|
if (this.callbacks.search(""), this.settings.closeOnSelect) {
|
|
958
979
|
let e = d(this.content.main);
|
|
959
980
|
setTimeout(() => {
|
|
960
|
-
this.
|
|
981
|
+
this.requestClose("select", { selectionChanged: !0 });
|
|
961
982
|
}, e);
|
|
962
983
|
}
|
|
963
984
|
}, r = this.callbacks.addable(t);
|
|
@@ -1189,7 +1210,7 @@ var P = class {
|
|
|
1189
1210
|
return this.content.list.querySelector("." + this.classes.getFirst("option")) !== null;
|
|
1190
1211
|
}
|
|
1191
1212
|
canUpdateOptionSelectionInPlace() {
|
|
1192
|
-
return this.content.search.input.value.trim() === ""
|
|
1213
|
+
return this.content.search.input.value.trim() === "" && this.hasRenderedOptions();
|
|
1193
1214
|
}
|
|
1194
1215
|
updateOptionSelection() {
|
|
1195
1216
|
let e = new Set(this.store.getSelected()), t = this.content.list.querySelectorAll("." + this.classes.getFirst("option")), n = null;
|
|
@@ -1240,23 +1261,35 @@ var P = class {
|
|
|
1240
1261
|
t.classList.add(e);
|
|
1241
1262
|
}), e.style && (t.style.cssText = e.style), this.setOptionElementContent(t, e, this.content.search.input.value), e.display || this.addClasses(t, this.classes.hide), e.disabled && this.addClasses(t, this.classes.disabled), e.selected && this.settings.hideSelected && this.addClasses(t, this.classes.hide), e.selected ? (this.addClasses(t, this.classes.selected), t.setAttribute("aria-selected", "true"), this.main.main.setAttribute("aria-activedescendant", t.id)) : (this.removeClasses(t, this.classes.selected), t.setAttribute("aria-selected", "false")), t.addEventListener("click", (t) => {
|
|
1242
1263
|
t.preventDefault(), t.stopPropagation();
|
|
1243
|
-
let n = this.store.getSelected(), r = t.currentTarget, i = String(r.dataset.id), a = t.ctrlKey || t.metaKey;
|
|
1244
|
-
if (e.disabled
|
|
1245
|
-
|
|
1264
|
+
let n = this.store.getSelected(), r = t.currentTarget, i = String(r.dataset.id), a = this.store.getOptionByID(i) ?? e, o = n.includes(i), s = t.ctrlKey || t.metaKey;
|
|
1265
|
+
if (e.disabled) return;
|
|
1266
|
+
if (!this.settings.isMultiple && o && !this.settings.allowDeselect) {
|
|
1267
|
+
this.closeOnSingleSelectReclick(a);
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
if (o && a.mandatory) {
|
|
1271
|
+
this.closeOnSingleSelectReclick(a);
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
if (this.settings.isMultiple && this.settings.maxSelected <= n.length && !o || this.settings.isMultiple && this.settings.minSelected >= n.length && o && !s) return;
|
|
1275
|
+
let c = !1, l = this.store.getSelectedOptions(), u = [];
|
|
1246
1276
|
if (this.settings.isMultiple) {
|
|
1247
|
-
let n =
|
|
1277
|
+
let n = l.some((e) => e.id === i);
|
|
1248
1278
|
if (t.shiftKey && this.lastSelectedOption) {
|
|
1249
1279
|
let t = this.lastRenderedOptions, n = t.findIndex((e) => e.id === this.lastSelectedOption.id), r = t.findIndex((t) => t.id === e.id);
|
|
1250
1280
|
if (n >= 0 && r >= 0) {
|
|
1251
|
-
let e = Math.min(n, r), i = Math.max(n, r), a = t.slice(e, i + 1).filter((e) => !
|
|
1252
|
-
|
|
1253
|
-
} else
|
|
1254
|
-
} else
|
|
1281
|
+
let e = Math.min(n, r), i = Math.max(n, r), a = t.slice(e, i + 1).filter((e) => !l.find((t) => t.id === e.id));
|
|
1282
|
+
u = l.length + a.length <= this.settings.maxSelected ? l.concat(a) : l;
|
|
1283
|
+
} else u = l;
|
|
1284
|
+
} else u = n ? l.filter((e) => e.id !== i) : l.concat(a), this.lastSelectedOption = a;
|
|
1255
1285
|
}
|
|
1256
|
-
if (this.settings.isMultiple || (
|
|
1257
|
-
this.store.getOptionByID(i) || this.callbacks.addOption(e), this.callbacks.setSelected(
|
|
1286
|
+
if (this.settings.isMultiple || (u = o ? [] : [a]), this.callbacks.beforeChange || (c = !0), this.callbacks.beforeChange && (c = this.callbacks.beforeChange(u, l) !== !1), c) {
|
|
1287
|
+
this.store.getOptionByID(i) || this.callbacks.addOption(e), this.callbacks.setSelected(u.map((e) => e.id), !1);
|
|
1258
1288
|
let n = t.ctrlKey || t.metaKey || t.shiftKey;
|
|
1259
|
-
this.settings.closeOnSelect && !(this.settings.isMultiple && n) && this.
|
|
1289
|
+
this.settings.closeOnSelect && !(this.settings.isMultiple && n) && this.requestClose("select", {
|
|
1290
|
+
option: a,
|
|
1291
|
+
selectionChanged: this.selectionChanged(l, u)
|
|
1292
|
+
}), this.callbacks.afterChange && this.callbacks.afterChange(u);
|
|
1260
1293
|
}
|
|
1261
1294
|
}), t;
|
|
1262
1295
|
}
|
|
@@ -1761,7 +1794,6 @@ var W = class {
|
|
|
1761
1794
|
let t = [
|
|
1762
1795
|
"beforeOpen",
|
|
1763
1796
|
"afterOpen",
|
|
1764
|
-
"beforeClose",
|
|
1765
1797
|
"afterClose"
|
|
1766
1798
|
];
|
|
1767
1799
|
for (let n in e.events) e.events.hasOwnProperty(n) && (t.indexOf(n) === -1 ? this.events[n] = e.events[n] : this.events[n] = C(e.events[n], 100));
|
|
@@ -1770,7 +1802,10 @@ var W = class {
|
|
|
1770
1802
|
}, this.select.onDisabledChange = (e) => {
|
|
1771
1803
|
e ? this.disable() : this.enable();
|
|
1772
1804
|
}, this.select.onLabelClick = () => {
|
|
1773
|
-
this.settings.disabled || (this.settings.isOpen ? this.close(
|
|
1805
|
+
this.settings.disabled || (this.settings.isOpen ? this.close({
|
|
1806
|
+
source: "toggle",
|
|
1807
|
+
selectionChanged: !1
|
|
1808
|
+
}) : this.open());
|
|
1774
1809
|
};
|
|
1775
1810
|
let n = e.data ? e.data : this.select.getData();
|
|
1776
1811
|
this.store = new R(this.settings.isMultiple ? "multiple" : "single", n), e.data && this.select.updateOptions(this.store.getData());
|
|
@@ -1818,7 +1853,8 @@ var W = class {
|
|
|
1818
1853
|
}, this.lifecycle = new F({
|
|
1819
1854
|
beforeOpen: this.events.beforeOpen,
|
|
1820
1855
|
afterOpen: this.events.afterOpen,
|
|
1821
|
-
beforeClose: this.events.beforeClose,
|
|
1856
|
+
beforeClose: (e) => this.events.beforeClose?.(e),
|
|
1857
|
+
onClose: (e) => this.applyClose(e),
|
|
1822
1858
|
afterClose: () => {
|
|
1823
1859
|
this.render.clearDirectionClasses(), this.render.finalizeModalClose(), this.events.afterClose && this.events.afterClose();
|
|
1824
1860
|
},
|
|
@@ -1836,7 +1872,10 @@ var W = class {
|
|
|
1836
1872
|
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1837
1873
|
},
|
|
1838
1874
|
onVisibilityChange: () => {
|
|
1839
|
-
document.hidden && this.close(
|
|
1875
|
+
document.hidden && this.close({
|
|
1876
|
+
source: "api",
|
|
1877
|
+
selectionChanged: !1
|
|
1878
|
+
});
|
|
1840
1879
|
}
|
|
1841
1880
|
}), this.render.renderValues(), this.render.renderOptions(this.store.getData(!1));
|
|
1842
1881
|
let i = this.selectEl.getAttribute("aria-label"), a = this.selectEl.getAttribute("aria-labelledby");
|
|
@@ -1891,10 +1930,18 @@ var W = class {
|
|
|
1891
1930
|
let e = this.render.content.search.input.value.trim();
|
|
1892
1931
|
e !== "" && this.search(e);
|
|
1893
1932
|
}
|
|
1894
|
-
close(e =
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1933
|
+
close(e = {
|
|
1934
|
+
source: "api",
|
|
1935
|
+
selectionChanged: !1
|
|
1936
|
+
}) {
|
|
1937
|
+
!this.settings.isOpen || this.settings.alwaysOpen || this.lifecycle.requestClose(e).then((e) => {
|
|
1938
|
+
e && (this.settings.isOpen || (this.settings.isOpen = this.lifecycle.isOpen, this.settings.isFullOpen = this.lifecycle.isFullOpen));
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
applyClose(e) {
|
|
1942
|
+
this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && (this.sync.flush(), this.search(""));
|
|
1943
|
+
let t = e.source === "outside" || e.source === "toggle";
|
|
1944
|
+
this.render.mainFocus(t ? "click" : null), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.render.stopPositionTracking();
|
|
1898
1945
|
}
|
|
1899
1946
|
search(e) {
|
|
1900
1947
|
let t = e.trim();
|
|
@@ -1956,7 +2003,10 @@ var W = class {
|
|
|
1956
2003
|
this.lifecycle.destroy(), this.render.stopPositionTracking(), this.globalEvents.detach({ listenScroll: this.settings.openPosition === "auto" }), this.store.setData([]), this.render.destroy(), this.select.destroy(), delete this.selectEl.slim;
|
|
1957
2004
|
}
|
|
1958
2005
|
documentClick(e) {
|
|
1959
|
-
this.settings.isOpen && e.target && !S(e.target, this.settings.id) && this.close(
|
|
2006
|
+
this.settings.isOpen && e.target && !S(e.target, this.settings.id) && this.close({
|
|
2007
|
+
source: "outside",
|
|
2008
|
+
selectionChanged: !1
|
|
2009
|
+
});
|
|
1960
2010
|
}
|
|
1961
2011
|
};
|
|
1962
2012
|
//#endregion
|