slim-select 3.0.6 → 3.1.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/dist/index.d.ts +6 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +176 -123
- package/dist/react/index.umd.js +4 -4
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.es.js +108 -55
- 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.d.ts +6 -0
- package/dist/vue/index.js +99 -46
- package/dist/vue/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/slim-select/index.ts +13 -0
- package/src/slim-select/select.ts +151 -0
package/dist/vue/index.d.ts
CHANGED
|
@@ -183,8 +183,12 @@ declare class Select {
|
|
|
183
183
|
onClassChange?: (classes: string[]) => void;
|
|
184
184
|
onDisabledChange?: (disabled: boolean) => void;
|
|
185
185
|
onOptionsChange?: (data: (Option_2 | Optgroup)[]) => void;
|
|
186
|
+
onLabelClick?: () => void;
|
|
186
187
|
private listen;
|
|
187
188
|
private observer;
|
|
189
|
+
private preventNativeSelect;
|
|
190
|
+
private preventNativeSelectMousedown;
|
|
191
|
+
private preventNativeSelectFocus;
|
|
188
192
|
constructor(select: HTMLSelectElement);
|
|
189
193
|
enable(): void;
|
|
190
194
|
disable(): void;
|
|
@@ -204,6 +208,8 @@ declare class Select {
|
|
|
204
208
|
updateOptions(data: (Option_2 | Optgroup)[]): void;
|
|
205
209
|
createOptgroup(optgroup: Optgroup): HTMLOptGroupElement;
|
|
206
210
|
createOption(info: Option_2): HTMLOptionElement;
|
|
211
|
+
setupLabelHandlers(): void;
|
|
212
|
+
removeLabelHandlers(): void;
|
|
207
213
|
destroy(): void;
|
|
208
214
|
}
|
|
209
215
|
|
package/dist/vue/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as A, createElementBlock as T, openBlock as D, renderSlot as k } from "vue";
|
|
2
2
|
class N {
|
|
3
3
|
main;
|
|
4
4
|
// Placeholder
|
|
@@ -63,7 +63,7 @@ class N {
|
|
|
63
63
|
e || (e = {}), this.main = e.main || "ss-main", this.placeholder = e.placeholder || "ss-placeholder", this.values = e.values || "ss-values", this.single = e.single || "ss-single", this.max = e.max || "ss-max", this.value = e.value || "ss-value", this.valueText = e.valueText || "ss-value-text", this.valueDelete = e.valueDelete || "ss-value-delete", this.valueOut = e.valueOut || "ss-value-out", this.deselect = e.deselect || "ss-deselect", this.deselectPath = e.deselectPath || "M10,10 L90,90 M10,90 L90,10", this.arrow = e.arrow || "ss-arrow", this.arrowClose = e.arrowClose || "M10,30 L50,70 L90,30", this.arrowOpen = e.arrowOpen || "M10,70 L50,30 L90,70", this.content = e.content || "ss-content", this.contentOpen = e.contentOpen || "ss-open", this.dirAbove = e.dirAbove || "ss-dir-above", this.dirBelow = e.dirBelow || "ss-dir-below", this.search = e.search || "ss-search", this.searchHighlighter = e.searchHighlighter || "ss-search-highlight", this.searching = e.searching || "ss-searching", this.addable = e.addable || "ss-addable", this.addablePath = e.addablePath || "M50,10 L50,90 M10,50 L90,50", this.list = e.list || "ss-list", this.optgroup = e.optgroup || "ss-optgroup", this.optgroupLabel = e.optgroupLabel || "ss-optgroup-label", this.optgroupLabelText = e.optgroupLabelText || "ss-optgroup-label-text", this.optgroupActions = e.optgroupActions || "ss-optgroup-actions", this.optgroupSelectAll = e.optgroupSelectAll || "ss-selectall", this.optgroupSelectAllBox = e.optgroupSelectAllBox || "M60,10 L10,10 L10,90 L90,90 L90,50", this.optgroupSelectAllCheck = e.optgroupSelectAllCheck || "M30,45 L50,70 L90,10", this.optgroupClosable = e.optgroupClosable || "ss-closable", this.option = e.option || "ss-option", this.optionDelete = e.optionDelete || "M10,10 L90,90 M10,90 L90,10", this.highlighted = e.highlighted || "ss-highlighted", this.mainOpen = e.mainOpen || "ss-open", this.close = e.close || "ss-close", this.selected = e.selected || "ss-selected", this.error = e.error || "ss-error", this.disabled = e.disabled || "ss-disabled", this.hide = e.hide || "ss-hide";
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function C() {
|
|
67
67
|
return Math.random().toString(36).substring(2, 10);
|
|
68
68
|
}
|
|
69
69
|
function M(h, e) {
|
|
@@ -75,7 +75,7 @@ function M(h, e) {
|
|
|
75
75
|
}
|
|
76
76
|
return t(h, e) || s(h, e);
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function O(h, e = 50, t = !1) {
|
|
79
79
|
let s;
|
|
80
80
|
return function(...i) {
|
|
81
81
|
const l = self, a = () => {
|
|
@@ -84,7 +84,7 @@ function S(h, e = 50, t = !1) {
|
|
|
84
84
|
clearTimeout(s), s = setTimeout(a, e), n && h.apply(l, i);
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function L(h, e) {
|
|
88
88
|
return JSON.stringify(h) === JSON.stringify(e);
|
|
89
89
|
}
|
|
90
90
|
function P(h) {
|
|
@@ -106,7 +106,7 @@ class p {
|
|
|
106
106
|
data;
|
|
107
107
|
mandatory;
|
|
108
108
|
constructor(e) {
|
|
109
|
-
this.id = !e.id || e.id === "" ?
|
|
109
|
+
this.id = !e.id || e.id === "" ? C() : 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 : !1, this.selected = e.selected !== void 0 ? e.selected : !1, this.display = e.display !== void 0 ? e.display : !0, this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.mandatory = e.mandatory !== void 0 ? e.mandatory : !1, this.placeholder = e.placeholder !== void 0 ? e.placeholder : !1, this.class = e.class || "", this.style = e.style || "", this.data = e.data || {};
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
class m {
|
|
@@ -117,7 +117,7 @@ class m {
|
|
|
117
117
|
closable;
|
|
118
118
|
options;
|
|
119
119
|
constructor(e) {
|
|
120
|
-
if (this.id = !e.id || e.id === "" ?
|
|
120
|
+
if (this.id = !e.id || e.id === "" ? C() : e.id, this.label = e.label || "", this.selectAll = e.selectAll === void 0 ? !1 : e.selectAll, this.selectAllText = e.selectAllText || "Select All", this.closable = e.closable || "off", this.options = [], e.options)
|
|
121
121
|
for (const t of e.options)
|
|
122
122
|
this.options.push(new p(t));
|
|
123
123
|
}
|
|
@@ -298,7 +298,7 @@ class B {
|
|
|
298
298
|
}), t;
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
class
|
|
301
|
+
class I {
|
|
302
302
|
settings;
|
|
303
303
|
store;
|
|
304
304
|
callbacks;
|
|
@@ -536,7 +536,7 @@ class V {
|
|
|
536
536
|
main: e,
|
|
537
537
|
input: t
|
|
538
538
|
};
|
|
539
|
-
if (this.settings.showSearch || (e.classList.add(this.classes.hide), t.readOnly = !0), t.type = "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"), t.oninput =
|
|
539
|
+
if (this.settings.showSearch || (e.classList.add(this.classes.hide), t.readOnly = !0), t.type = "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"), t.oninput = O((l) => {
|
|
540
540
|
this.callbacks.search(l.target.value);
|
|
541
541
|
}, 100), t.onkeydown = (l) => {
|
|
542
542
|
switch (l.key) {
|
|
@@ -706,22 +706,22 @@ class V {
|
|
|
706
706
|
const u = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
707
707
|
u.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(u), o.addEventListener("click", (g) => {
|
|
708
708
|
g.preventDefault(), g.stopPropagation();
|
|
709
|
-
const
|
|
709
|
+
const v = this.store.getSelected();
|
|
710
710
|
if (c) {
|
|
711
|
-
const w =
|
|
712
|
-
for (const
|
|
713
|
-
if (
|
|
711
|
+
const w = v.filter((S) => {
|
|
712
|
+
for (const b of s.options)
|
|
713
|
+
if (S === b.id)
|
|
714
714
|
return !1;
|
|
715
715
|
return !0;
|
|
716
716
|
});
|
|
717
717
|
this.callbacks.setSelected(w, !0);
|
|
718
718
|
return;
|
|
719
719
|
} else {
|
|
720
|
-
let w = s.options.map((
|
|
721
|
-
const
|
|
722
|
-
for (const
|
|
723
|
-
|
|
724
|
-
this.callbacks.setSelected(
|
|
720
|
+
let w = s.options.map((b) => b.id).filter((b) => b !== void 0);
|
|
721
|
+
const S = v.concat(w);
|
|
722
|
+
for (const b of s.options)
|
|
723
|
+
b.id && !this.store.getOptionByID(b.id) && this.callbacks.addOption(new p(b));
|
|
724
|
+
this.callbacks.setSelected(S, !0);
|
|
725
725
|
return;
|
|
726
726
|
}
|
|
727
727
|
}), n.appendChild(o);
|
|
@@ -768,10 +768,10 @@ class V {
|
|
|
768
768
|
if (this.settings.isMultiple) {
|
|
769
769
|
const d = c.some((u) => u.id === a);
|
|
770
770
|
if (s.shiftKey && this.lastSelectedOption) {
|
|
771
|
-
const u = this.store.getDataOptions(), g = u.findIndex((w) => w.id === this.lastSelectedOption.id),
|
|
772
|
-
if (g >= 0 &&
|
|
773
|
-
const w = Math.min(g,
|
|
774
|
-
c.length +
|
|
771
|
+
const u = this.store.getDataOptions(), g = u.findIndex((w) => w.id === this.lastSelectedOption.id), v = u.findIndex((w) => w.id === e.id);
|
|
772
|
+
if (g >= 0 && v >= 0) {
|
|
773
|
+
const w = Math.min(g, v), S = Math.max(g, v), y = u.slice(w, S + 1).filter((E) => !c.find((x) => x.id === E.id));
|
|
774
|
+
c.length + y.length <= this.settings.maxSelected ? r = c.concat(y) : r = c;
|
|
775
775
|
} else
|
|
776
776
|
r = c;
|
|
777
777
|
} else n ? (d ? r = c.filter((u) => u.id !== a) : r = c.concat(e), this.lastSelectedOption = e) : (d ? r = c.filter((u) => u.id !== a) : r = c.concat(e), this.lastSelectedOption = e);
|
|
@@ -802,8 +802,8 @@ class V {
|
|
|
802
802
|
const d = document.createElement("span");
|
|
803
803
|
c.split(r).forEach((u, g) => {
|
|
804
804
|
if (u && r.test(u)) {
|
|
805
|
-
const
|
|
806
|
-
|
|
805
|
+
const v = document.createElement("mark");
|
|
806
|
+
v.className = s, v.textContent = u, d.appendChild(v);
|
|
807
807
|
} else u && d.appendChild(document.createTextNode(u));
|
|
808
808
|
}), o.parentNode?.replaceChild(d, o);
|
|
809
809
|
}
|
|
@@ -838,16 +838,21 @@ class V {
|
|
|
838
838
|
i && !(s && !t) ? l.classList.remove(a) : l.classList.add(a);
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
|
-
class
|
|
841
|
+
class H {
|
|
842
842
|
select;
|
|
843
843
|
// Mutation observer fields
|
|
844
844
|
onValueChange;
|
|
845
845
|
onClassChange;
|
|
846
846
|
onDisabledChange;
|
|
847
847
|
onOptionsChange;
|
|
848
|
+
onLabelClick;
|
|
848
849
|
// Change observers
|
|
849
850
|
listen = !1;
|
|
850
851
|
observer = null;
|
|
852
|
+
// Event handlers for preventing native select behavior (especially on iOS Safari)
|
|
853
|
+
preventNativeSelect = null;
|
|
854
|
+
preventNativeSelectMousedown = null;
|
|
855
|
+
preventNativeSelectFocus = null;
|
|
851
856
|
constructor(e) {
|
|
852
857
|
this.select = e, this.valueChange = this.valueChange.bind(this), this.select.addEventListener("change", this.valueChange, {
|
|
853
858
|
// allow bubbling of event
|
|
@@ -861,10 +866,16 @@ class I {
|
|
|
861
866
|
this.select.disabled = !0;
|
|
862
867
|
}
|
|
863
868
|
hideUI() {
|
|
864
|
-
this.select.tabIndex = -1, this.select.style.position = "absolute", this.select.style.width = "1px", this.select.style.height = "1px", this.select.style.opacity = "0", this.select.style.overflow = "hidden", this.select.style.pointerEvents = "none", this.select.style.margin = "0", this.select.style.padding = "0", this.select.style.borderWidth = "0", this.select.style.clip = "rect(0 0 0 0)", this.select.setAttribute("aria-hidden", "true")
|
|
869
|
+
this.select.tabIndex = -1, this.select.style.position = "absolute", this.select.style.width = "1px", this.select.style.height = "1px", this.select.style.opacity = "0", this.select.style.overflow = "hidden", this.select.style.pointerEvents = "none", this.select.style.margin = "0", this.select.style.padding = "0", this.select.style.borderWidth = "0", this.select.style.clip = "rect(0 0 0 0)", this.select.setAttribute("aria-hidden", "true"), this.preventNativeSelect || (this.preventNativeSelect = (e) => {
|
|
870
|
+
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
871
|
+
}, this.preventNativeSelectMousedown = (e) => {
|
|
872
|
+
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
873
|
+
}, this.preventNativeSelectFocus = (e) => {
|
|
874
|
+
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
875
|
+
}, this.select.addEventListener("click", this.preventNativeSelect, { capture: !0, passive: !1 }), this.select.addEventListener("mousedown", this.preventNativeSelectMousedown, { capture: !0, passive: !1 }), this.select.addEventListener("focus", this.preventNativeSelectFocus, { capture: !0, passive: !1 }));
|
|
865
876
|
}
|
|
866
877
|
showUI() {
|
|
867
|
-
this.select.removeAttribute("tabindex"), this.select.style.position = "", this.select.style.width = "", this.select.style.height = "", this.select.style.opacity = "", this.select.style.overflow = "", this.select.style.pointerEvents = "", this.select.style.margin = "", this.select.style.padding = "", this.select.style.borderWidth = "", this.select.style.clip = "", this.select.removeAttribute("aria-hidden");
|
|
878
|
+
this.select.removeAttribute("tabindex"), this.select.style.position = "", this.select.style.width = "", this.select.style.height = "", this.select.style.opacity = "", this.select.style.overflow = "", this.select.style.pointerEvents = "", this.select.style.margin = "", this.select.style.padding = "", this.select.style.borderWidth = "", this.select.style.clip = "", this.select.removeAttribute("aria-hidden"), this.preventNativeSelect && (this.select.removeEventListener("click", this.preventNativeSelect, { capture: !0 }), this.preventNativeSelect = null), this.preventNativeSelectMousedown && (this.select.removeEventListener("mousedown", this.preventNativeSelectMousedown, { capture: !0 }), this.preventNativeSelectMousedown = null), this.preventNativeSelectFocus && (this.select.removeEventListener("focus", this.preventNativeSelectFocus, { capture: !0 }), this.preventNativeSelectFocus = null);
|
|
868
879
|
}
|
|
869
880
|
changeListen(e) {
|
|
870
881
|
this.listen = e, e && this.observer && this.observer.observe(this.select, {
|
|
@@ -1028,11 +1039,51 @@ class I {
|
|
|
1028
1039
|
t.setAttribute("data-" + P(s), e.data[s]);
|
|
1029
1040
|
}), t;
|
|
1030
1041
|
}
|
|
1042
|
+
// Find and handle labels associated with this select
|
|
1043
|
+
setupLabelHandlers() {
|
|
1044
|
+
const e = [], t = this.select.id;
|
|
1045
|
+
t && document.querySelectorAll(`label[for="${t}"]`).forEach((a) => e.push(a));
|
|
1046
|
+
let s = this.select.parentElement;
|
|
1047
|
+
for (; s && s !== document.body; ) {
|
|
1048
|
+
if (s.tagName === "LABEL") {
|
|
1049
|
+
e.push(s);
|
|
1050
|
+
break;
|
|
1051
|
+
}
|
|
1052
|
+
s = s.parentElement;
|
|
1053
|
+
}
|
|
1054
|
+
Array.from(new Set(e)).forEach((l) => {
|
|
1055
|
+
if (l.__slimSelectLabelHandler)
|
|
1056
|
+
return;
|
|
1057
|
+
const a = (n) => {
|
|
1058
|
+
n.preventDefault(), n.stopPropagation(), this.onLabelClick && setTimeout(() => {
|
|
1059
|
+
this.onLabelClick();
|
|
1060
|
+
}, 0);
|
|
1061
|
+
};
|
|
1062
|
+
l.__slimSelectLabelHandler = a, l.addEventListener("click", a, { capture: !0, passive: !1 });
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
// Remove label handlers
|
|
1066
|
+
removeLabelHandlers() {
|
|
1067
|
+
const e = [], t = this.select.id;
|
|
1068
|
+
t && document.querySelectorAll(`label[for="${t}"]`).forEach((a) => e.push(a));
|
|
1069
|
+
let s = this.select.parentElement;
|
|
1070
|
+
for (; s && s !== document.body; ) {
|
|
1071
|
+
if (s.tagName === "LABEL") {
|
|
1072
|
+
e.push(s);
|
|
1073
|
+
break;
|
|
1074
|
+
}
|
|
1075
|
+
s = s.parentElement;
|
|
1076
|
+
}
|
|
1077
|
+
Array.from(new Set(e)).forEach((l) => {
|
|
1078
|
+
const a = l.__slimSelectLabelHandler;
|
|
1079
|
+
a && (l.removeEventListener("click", a, { capture: !0 }), delete l.__slimSelectLabelHandler);
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1031
1082
|
destroy() {
|
|
1032
|
-
this.changeListen(!1), this.select.removeEventListener("change", this.valueChange), this.observer && (this.observer.disconnect(), this.observer = null), delete this.select.dataset.id, this.showUI();
|
|
1083
|
+
this.changeListen(!1), this.select.removeEventListener("change", this.valueChange), this.preventNativeSelect && (this.select.removeEventListener("click", this.preventNativeSelect, { capture: !0 }), this.preventNativeSelect = null), this.preventNativeSelectMousedown && (this.select.removeEventListener("mousedown", this.preventNativeSelectMousedown, { capture: !0 }), this.preventNativeSelectMousedown = null), this.preventNativeSelectFocus && (this.select.removeEventListener("focus", this.preventNativeSelectFocus, { capture: !0 }), this.preventNativeSelectFocus = null), this.observer && (this.observer.disconnect(), this.observer = null), this.removeLabelHandlers(), delete this.select.dataset.id, this.showUI();
|
|
1033
1084
|
}
|
|
1034
1085
|
}
|
|
1035
|
-
class
|
|
1086
|
+
class V {
|
|
1036
1087
|
id = "";
|
|
1037
1088
|
// Primary ID for the select
|
|
1038
1089
|
style = "";
|
|
@@ -1070,7 +1121,7 @@ class H {
|
|
|
1070
1121
|
maxValuesMessage;
|
|
1071
1122
|
addableText;
|
|
1072
1123
|
constructor(e) {
|
|
1073
|
-
e || (e = {}), this.id = "ss-" +
|
|
1124
|
+
e || (e = {}), this.id = "ss-" + C(), this.style = e.style || "", this.class = e.class || [], this.disabled = e.disabled !== void 0 ? e.disabled : !1, this.alwaysOpen = e.alwaysOpen !== void 0 ? e.alwaysOpen : !1, this.showSearch = e.showSearch !== void 0 ? e.showSearch : !0, this.focusSearch = e.focusSearch !== void 0 ? e.focusSearch : !0, this.ariaLabel = e.ariaLabel || "Combobox", this.searchPlaceholder = e.searchPlaceholder || "Search...", this.searchText = e.searchText || "No Results", this.searchingText = e.searchingText || "Searching...", this.searchHighlight = e.searchHighlight !== void 0 ? e.searchHighlight : !1, this.closeOnSelect = e.closeOnSelect !== void 0 ? e.closeOnSelect : !0, this.contentLocation = e.contentLocation || document.body, this.contentPosition = e.contentPosition || "absolute", this.openPosition = e.openPosition || "auto", this.placeholderText = e.placeholderText !== void 0 ? e.placeholderText : "Select Value", this.allowDeselect = e.allowDeselect !== void 0 ? e.allowDeselect : !1, this.hideSelected = e.hideSelected !== void 0 ? e.hideSelected : !1, this.keepOrder = e.keepOrder !== void 0 ? e.keepOrder : !1, this.showOptionTooltips = e.showOptionTooltips !== void 0 ? e.showOptionTooltips : !1, 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}';
|
|
1074
1125
|
}
|
|
1075
1126
|
}
|
|
1076
1127
|
let F = class {
|
|
@@ -1105,11 +1156,11 @@ let F = class {
|
|
|
1105
1156
|
e.events && e.events.error && e.events.error(new Error("Element isnt of type select"));
|
|
1106
1157
|
return;
|
|
1107
1158
|
}
|
|
1108
|
-
this.selectEl.dataset.ssid && this.destroy(), this.settings = new
|
|
1159
|
+
this.selectEl.dataset.ssid && this.destroy(), this.settings = new V(e.settings), this.cssClasses = new N(e.cssClasses);
|
|
1109
1160
|
const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
|
|
1110
1161
|
for (const n in e.events)
|
|
1111
|
-
e.events.hasOwnProperty(n) && (t.indexOf(n) !== -1 ? this.events[n] =
|
|
1112
|
-
this.settings.disabled = e.settings?.disabled ? e.settings.disabled : this.selectEl.disabled, this.settings.isMultiple = this.selectEl.multiple, this.settings.style = this.selectEl.style.cssText, this.settings.class = this.selectEl.className.split(" "), this.select = new
|
|
1162
|
+
e.events.hasOwnProperty(n) && (t.indexOf(n) !== -1 ? this.events[n] = O(e.events[n], 100) : this.events[n] = e.events[n]);
|
|
1163
|
+
this.settings.disabled = e.settings?.disabled ? e.settings.disabled : this.selectEl.disabled, this.settings.isMultiple = this.selectEl.multiple, this.settings.style = this.selectEl.style.cssText, this.settings.class = this.selectEl.className.split(" "), this.select = new H(this.selectEl), this.selectEl.id || (this.selectEl.id = this.settings.id), this.select.updateSelect(this.settings.id, this.settings.style, this.settings.class), this.select.hideUI(), this.select.onValueChange = (n) => {
|
|
1113
1164
|
this.setSelected(n.map((o) => o.id));
|
|
1114
1165
|
}, this.select.onClassChange = (n) => {
|
|
1115
1166
|
this.settings.class = n, this.render.updateClassStyles();
|
|
@@ -1117,6 +1168,8 @@ let F = class {
|
|
|
1117
1168
|
n ? this.disable() : this.enable();
|
|
1118
1169
|
}, this.select.onOptionsChange = (n) => {
|
|
1119
1170
|
this.setData(n);
|
|
1171
|
+
}, this.select.onLabelClick = () => {
|
|
1172
|
+
this.settings.disabled || this.open();
|
|
1120
1173
|
};
|
|
1121
1174
|
const s = e.data ? e.data : this.select.getData();
|
|
1122
1175
|
this.store = new B(this.settings.isMultiple ? "multiple" : "single", s), e.data && this.select.updateOptions(this.store.getData());
|
|
@@ -1130,9 +1183,9 @@ let F = class {
|
|
|
1130
1183
|
beforeChange: this.events.beforeChange,
|
|
1131
1184
|
afterChange: this.events.afterChange
|
|
1132
1185
|
};
|
|
1133
|
-
this.render = new
|
|
1186
|
+
this.render = new I(this.settings, this.cssClasses, this.store, i), this.render.renderValues(), this.render.renderOptions(this.store.getData());
|
|
1134
1187
|
const l = this.selectEl.getAttribute("aria-label"), a = this.selectEl.getAttribute("aria-labelledby");
|
|
1135
|
-
l ? this.render.main.main.setAttribute("aria-label", l) : a && this.render.main.main.setAttribute("aria-labelledby", a), this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), window.addEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.addEventListener("scroll", this.windowScroll, !1), document.addEventListener("visibilitychange", this.windowVisibilityChange), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.selectEl.slim = this;
|
|
1188
|
+
l ? this.render.main.main.setAttribute("aria-label", l) : a && this.render.main.main.setAttribute("aria-labelledby", a), this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), window.addEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.addEventListener("scroll", this.windowScroll, !1), document.addEventListener("visibilitychange", this.windowVisibilityChange), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.select.setupLabelHandlers(), this.selectEl.slim = this;
|
|
1136
1189
|
}
|
|
1137
1190
|
// Set to enabled and remove disabled classes
|
|
1138
1191
|
enable() {
|
|
@@ -1153,7 +1206,7 @@ let F = class {
|
|
|
1153
1206
|
}
|
|
1154
1207
|
this.store.setData(e);
|
|
1155
1208
|
const i = this.store.getData();
|
|
1156
|
-
this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !
|
|
1209
|
+
this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !L(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1157
1210
|
}
|
|
1158
1211
|
getSelected() {
|
|
1159
1212
|
let e = this.store.getSelectedOptions();
|
|
@@ -1174,13 +1227,13 @@ let F = class {
|
|
|
1174
1227
|
}
|
|
1175
1228
|
this.store.setSelectedBy("id", l);
|
|
1176
1229
|
const a = this.store.getData();
|
|
1177
|
-
this.select.updateOptions(a), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(a), t && this.events.afterChange && !
|
|
1230
|
+
this.select.updateOptions(a), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(a), t && this.events.afterChange && !L(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1178
1231
|
}
|
|
1179
1232
|
addOption(e) {
|
|
1180
1233
|
const t = this.store.getSelected();
|
|
1181
1234
|
this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
|
|
1182
1235
|
const s = this.store.getData();
|
|
1183
|
-
this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !
|
|
1236
|
+
this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !L(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1184
1237
|
}
|
|
1185
1238
|
open() {
|
|
1186
1239
|
this.settings.disabled || this.settings.isOpen || (this.events.beforeOpen && this.events.beforeOpen(), this.render.open(), this.settings.showSearch && this.settings.focusSearch && this.render.searchFocus(), this.settings.isOpen = !0, this.openTimeout = setTimeout(() => {
|
|
@@ -1217,11 +1270,11 @@ let F = class {
|
|
|
1217
1270
|
destroy() {
|
|
1218
1271
|
this.openTimeout && (clearTimeout(this.openTimeout), this.openTimeout = null), this.closeTimeout && (clearTimeout(this.closeTimeout), this.closeTimeout = null), this.settings.intervalMove && (clearInterval(this.settings.intervalMove), this.settings.intervalMove = null), document.removeEventListener("click", this.documentClick), window.removeEventListener("resize", this.windowResize, !1), this.settings.openPosition === "auto" && window.removeEventListener("scroll", this.windowScroll, !1), document.removeEventListener("visibilitychange", this.windowVisibilityChange), this.store.setData([]), this.render.destroy(), this.select.destroy();
|
|
1219
1272
|
}
|
|
1220
|
-
windowResize =
|
|
1273
|
+
windowResize = O(() => {
|
|
1221
1274
|
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1222
1275
|
});
|
|
1223
1276
|
// Event listener for window scrolling
|
|
1224
|
-
windowScroll =
|
|
1277
|
+
windowScroll = O(() => {
|
|
1225
1278
|
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1226
1279
|
});
|
|
1227
1280
|
// Event listener for document click
|
|
@@ -1233,7 +1286,7 @@ let F = class {
|
|
|
1233
1286
|
document.hidden && this.close();
|
|
1234
1287
|
};
|
|
1235
1288
|
};
|
|
1236
|
-
const R =
|
|
1289
|
+
const R = A({
|
|
1237
1290
|
name: "SlimSelect",
|
|
1238
1291
|
props: {
|
|
1239
1292
|
modelValue: {
|
|
@@ -1321,24 +1374,24 @@ const R = E({
|
|
|
1321
1374
|
return typeof h == "string" ? e ? [h] : h : Array.isArray(h) ? e ? h : h[0] : e ? [] : "";
|
|
1322
1375
|
}
|
|
1323
1376
|
}
|
|
1324
|
-
}),
|
|
1377
|
+
}), _ = (h, e) => {
|
|
1325
1378
|
const t = h.__vccOpts || h;
|
|
1326
1379
|
for (const [s, i] of e)
|
|
1327
1380
|
t[s] = i;
|
|
1328
1381
|
return t;
|
|
1329
|
-
},
|
|
1330
|
-
function
|
|
1382
|
+
}, q = ["multiple"];
|
|
1383
|
+
function $(h, e, t, s, i, l) {
|
|
1331
1384
|
return D(), T("select", {
|
|
1332
1385
|
multiple: h.multiple,
|
|
1333
1386
|
ref: "slim"
|
|
1334
1387
|
}, [
|
|
1335
1388
|
k(h.$slots, "default")
|
|
1336
|
-
], 8,
|
|
1389
|
+
], 8, q);
|
|
1337
1390
|
}
|
|
1338
|
-
const z = /* @__PURE__ */
|
|
1391
|
+
const z = /* @__PURE__ */ _(R, [["render", $]]);
|
|
1339
1392
|
export {
|
|
1340
1393
|
m as Optgroup,
|
|
1341
1394
|
p as Option,
|
|
1342
|
-
|
|
1395
|
+
V as Settings,
|
|
1343
1396
|
z as default
|
|
1344
1397
|
};
|