slim-select 4.3.0 → 4.5.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 +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/mutations.d.ts +2 -0
- package/dist/react/index.js +22 -14
- package/dist/react/index.umd.js +1 -1
- package/dist/render.d.ts +9 -0
- package/dist/select.d.ts +1 -0
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.es.js +22 -14
- 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 +22 -14
- package/dist/vue/index.umd.js +1 -1
- package/package.json +7 -7
package/dist/slimselect.es.js
CHANGED
|
@@ -717,6 +717,9 @@ var O = class {
|
|
|
717
717
|
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()));
|
|
718
718
|
(this.settings.contentPosition === "relative" || this.settings.contentPosition === "fixed") && this.content.main.classList.add("ss-" + this.settings.contentPosition);
|
|
719
719
|
}
|
|
720
|
+
updateTitle(e) {
|
|
721
|
+
e ? this.main.main.setAttribute("title", e) : this.main.main.removeAttribute("title");
|
|
722
|
+
}
|
|
720
723
|
updateAriaAttributes() {
|
|
721
724
|
let e = this.content.list.id;
|
|
722
725
|
this.main.main.role = "combobox", this.main.main.setAttribute("aria-haspopup", "listbox"), this.main.main.setAttribute("aria-controls", e), this.main.main.setAttribute("aria-expanded", "false"), this.content.list.setAttribute("role", "listbox"), this.content.list.setAttribute("aria-label", this.settings.ariaLabel + " listbox"), this.settings.isMultiple && this.content.list.setAttribute("aria-multiselectable", "true"), this.content.search.input.setAttribute("aria-controls", e);
|
|
@@ -1038,7 +1041,7 @@ var O = class {
|
|
|
1038
1041
|
let e = this.store.getSelected();
|
|
1039
1042
|
e.push(t.id), this.callbacks.setSelected(e, !0);
|
|
1040
1043
|
} else this.callbacks.setSelected([t.id], !0);
|
|
1041
|
-
if (this.callbacks.
|
|
1044
|
+
if (this.callbacks.clearSearch(), this.settings.closeOnSelect) {
|
|
1042
1045
|
let e = i(this.content.main);
|
|
1043
1046
|
setTimeout(() => {
|
|
1044
1047
|
this.requestClose("select", { selectionChanged: !0 });
|
|
@@ -1497,12 +1500,13 @@ var O = class {
|
|
|
1497
1500
|
function P(e, t) {
|
|
1498
1501
|
let n = {
|
|
1499
1502
|
classChanged: !1,
|
|
1503
|
+
titleChanged: !1,
|
|
1500
1504
|
disabledChanged: !1,
|
|
1501
1505
|
optgroupOptionChanged: !1,
|
|
1502
1506
|
selectionChanged: !1
|
|
1503
1507
|
};
|
|
1504
1508
|
for (let r of e) {
|
|
1505
|
-
if (r.target === t && (r.attributeName === "disabled" && (n.disabledChanged = !0), r.attributeName === "class" && (n.classChanged = !0), r.type === "childList")) {
|
|
1509
|
+
if (r.target === t && (r.attributeName === "disabled" && (n.disabledChanged = !0), r.attributeName === "class" && (n.classChanged = !0), r.attributeName === "title" && (n.titleChanged = !0), r.type === "childList")) {
|
|
1506
1510
|
for (let e of Array.from(r.addedNodes)) if (e.nodeName === "OPTION" && e.value === t.value) {
|
|
1507
1511
|
n.selectionChanged = !0;
|
|
1508
1512
|
break;
|
|
@@ -1519,6 +1523,7 @@ var F = class {
|
|
|
1519
1523
|
select;
|
|
1520
1524
|
onValueChange;
|
|
1521
1525
|
onClassChange;
|
|
1526
|
+
onTitleChange;
|
|
1522
1527
|
onDisabledChange;
|
|
1523
1528
|
onOptionsChange;
|
|
1524
1529
|
onLabelClick;
|
|
@@ -1577,19 +1582,19 @@ var F = class {
|
|
|
1577
1582
|
}
|
|
1578
1583
|
observeCall(e) {
|
|
1579
1584
|
if (!this.listen) return;
|
|
1580
|
-
let { classChanged: t,
|
|
1581
|
-
if (t && this.onClassChange && this.onClassChange(this.select.className.split(" ")), n && this.onDisabledChange && (this.changeListen(!1), this.onDisabledChange(this.select.disabled), this.changeListen(!0)),
|
|
1585
|
+
let { classChanged: t, titleChanged: n, disabledChanged: r, optgroupOptionChanged: i, selectionChanged: a } = P(e, this.select), o = a;
|
|
1586
|
+
if (t && this.onClassChange && this.onClassChange(this.select.className.split(" ")), n && this.onTitleChange && this.onTitleChange(this.select.getAttribute("title") || ""), r && this.onDisabledChange && (this.changeListen(!1), this.onDisabledChange(this.select.disabled), this.changeListen(!0)), i && this.clearLeftoverHiddenDisplay(e), i && this.onOptionsChange) {
|
|
1582
1587
|
if (this.isUpdating) {
|
|
1583
1588
|
if (this.select.options.length > 0) {
|
|
1584
1589
|
let e = this.getData();
|
|
1585
1590
|
e.length > 0 && (this.pendingOptionsChange = e);
|
|
1586
1591
|
}
|
|
1587
|
-
|
|
1592
|
+
o && this.select.dispatchEvent(new Event("change"));
|
|
1588
1593
|
return;
|
|
1589
1594
|
}
|
|
1590
|
-
this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0),
|
|
1595
|
+
this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0), o = !1;
|
|
1591
1596
|
}
|
|
1592
|
-
|
|
1597
|
+
o && this.select.dispatchEvent(new Event("change"));
|
|
1593
1598
|
}
|
|
1594
1599
|
getData() {
|
|
1595
1600
|
let e = [], t = this.select.childNodes;
|
|
@@ -1929,6 +1934,8 @@ var R = class {
|
|
|
1929
1934
|
for (let e in t.events) t.events.hasOwnProperty(e) && (n.indexOf(e) === -1 ? this.events[e] = t.events[e] : this.events[e] = _(t.events[e], 100));
|
|
1930
1935
|
this.settings.disabled = t.settings?.disabled ? t.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 F(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.onClassChange = (e) => {
|
|
1931
1936
|
this.settings.class = e, this.render.updateClassStyles();
|
|
1937
|
+
}, this.select.onTitleChange = (e) => {
|
|
1938
|
+
this.render.updateTitle(e);
|
|
1932
1939
|
}, this.select.onDisabledChange = (e) => {
|
|
1933
1940
|
e ? this.disable() : this.enable();
|
|
1934
1941
|
}, this.select.onLabelClick = () => {
|
|
@@ -1959,6 +1966,7 @@ var R = class {
|
|
|
1959
1966
|
});
|
|
1960
1967
|
},
|
|
1961
1968
|
search: this.search.bind(this),
|
|
1969
|
+
clearSearch: this.clearSearch.bind(this),
|
|
1962
1970
|
beforeChange: this.events.beforeChange,
|
|
1963
1971
|
afterChange: this.events.afterChange
|
|
1964
1972
|
};
|
|
@@ -2015,7 +2023,7 @@ var R = class {
|
|
|
2015
2023
|
let e = Array.from(this.selectEl.labels).map((e, t) => (e.id ||= `${this.settings.id}-label-${t}`, e.id));
|
|
2016
2024
|
this.render.main.main.removeAttribute("aria-label"), this.render.main.main.setAttribute("aria-labelledby", e.join(" "));
|
|
2017
2025
|
}
|
|
2018
|
-
this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), this.globalEvents.attach({ listenScroll: this.settings.openPosition === "auto" }), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.select.setupLabelHandlers(), this.selectEl.slim = this;
|
|
2026
|
+
this.render.updateTitle(this.selectEl.getAttribute("title")), this.selectEl.parentNode && this.selectEl.parentNode.insertBefore(this.render.main.main, this.selectEl.nextSibling), this.globalEvents.attach({ listenScroll: this.settings.openPosition === "auto" }), this.settings.disabled && this.disable(), this.settings.alwaysOpen && this.open(), this.select.setupLabelHandlers(), this.selectEl.slim = this;
|
|
2019
2027
|
}
|
|
2020
2028
|
enable() {
|
|
2021
2029
|
this.settings.disabled = !1, this.select.enable(), this.render.enable();
|
|
@@ -2069,24 +2077,24 @@ var R = class {
|
|
|
2069
2077
|
});
|
|
2070
2078
|
}
|
|
2071
2079
|
applyClose(e) {
|
|
2072
|
-
this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && (this.sync.flush(), this.
|
|
2080
|
+
this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && (this.sync.flush(), this.clearSearch());
|
|
2073
2081
|
let t = e.source === "outside" || e.source === "toggle";
|
|
2074
2082
|
this.render.mainFocus(t ? "click" : null), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.render.stopPositionTracking();
|
|
2075
2083
|
}
|
|
2076
2084
|
search(e) {
|
|
2077
2085
|
let t = e.trim();
|
|
2078
|
-
if (t === "") {
|
|
2079
|
-
this.
|
|
2086
|
+
if (t === "" ? this.render.content.search.input.value = "" : this.render.content.search.input.value !== e && (this.render.content.search.input.value = e), this.events.search) {
|
|
2087
|
+
this.runApiSearch(t);
|
|
2080
2088
|
return;
|
|
2081
2089
|
}
|
|
2082
|
-
if (
|
|
2083
|
-
this.
|
|
2090
|
+
if (t === "") {
|
|
2091
|
+
this.clearSearch();
|
|
2084
2092
|
return;
|
|
2085
2093
|
}
|
|
2086
2094
|
this.runLocalSearch(t);
|
|
2087
2095
|
}
|
|
2088
2096
|
clearSearch() {
|
|
2089
|
-
if (this.searchGeneration++, !this.events.search && this.render.canFilterOptionsInPlace()) {
|
|
2097
|
+
if (this.render.content.search.input.value = "", this.searchGeneration++, !this.events.search && this.render.canFilterOptionsInPlace()) {
|
|
2090
2098
|
this.render.filterOptionsInPlace("", this.events.searchFilter), this.render.resetSearchFilterState();
|
|
2091
2099
|
return;
|
|
2092
2100
|
}
|