slim-select 3.1.3 → 3.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 +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +50 -36
- package/dist/react/index.umd.js +2 -2
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.es.js +42 -28
- 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 +2 -0
- package/dist/vue/index.js +138 -124
- package/dist/vue/index.umd.js +1 -1
- package/package.json +10 -10
- package/src/slim-select/index.test.ts +253 -0
- package/src/slim-select/index.ts +5 -4
- package/src/slim-select/render.ts +20 -2
- package/src/slim-select/select.ts +17 -9
- package/src/slim-select/settings.test.ts +1 -0
- package/src/slim-select/settings.ts +2 -0
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ new SlimSelect({
|
|
|
140
140
|
alwaysOpen: false, // Keep dropdown always open
|
|
141
141
|
showSearch: true, // Show search input
|
|
142
142
|
focusSearch: true, // Auto focus search on open
|
|
143
|
+
keepSearch: false, // Keep search input value when dropdown closes
|
|
143
144
|
ariaLabel: 'Combobox', // ARIA label for accessibility
|
|
144
145
|
searchPlaceholder: 'Search', // Search input placeholder
|
|
145
146
|
searchText: 'No Results', // Text when no results found
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,7 @@ declare class Render {
|
|
|
138
138
|
disable(): void;
|
|
139
139
|
open(): void;
|
|
140
140
|
close(): void;
|
|
141
|
+
private getAnimationTiming;
|
|
141
142
|
updateClassStyles(): void;
|
|
142
143
|
updateAriaAttributes(): void;
|
|
143
144
|
mainDiv(): Main;
|
|
@@ -227,6 +228,7 @@ export declare class Settings {
|
|
|
227
228
|
alwaysOpen: boolean;
|
|
228
229
|
showSearch: boolean;
|
|
229
230
|
focusSearch: boolean;
|
|
231
|
+
keepSearch: boolean;
|
|
230
232
|
ariaLabel: string;
|
|
231
233
|
searchPlaceholder: string;
|
|
232
234
|
searchText: string;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -138,6 +138,7 @@ declare class Render {
|
|
|
138
138
|
disable(): void;
|
|
139
139
|
open(): void;
|
|
140
140
|
close(): void;
|
|
141
|
+
private getAnimationTiming;
|
|
141
142
|
updateClassStyles(): void;
|
|
142
143
|
updateAriaAttributes(): void;
|
|
143
144
|
mainDiv(): Main;
|
|
@@ -227,6 +228,7 @@ export declare class Settings {
|
|
|
227
228
|
alwaysOpen: boolean;
|
|
228
229
|
showSearch: boolean;
|
|
229
230
|
focusSearch: boolean;
|
|
231
|
+
keepSearch: boolean;
|
|
230
232
|
ariaLabel: string;
|
|
231
233
|
searchPlaceholder: string;
|
|
232
234
|
searchText: string;
|
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ae, { forwardRef as re, useRef as V, useImperativeHandle as oe, useEffect as $ } from "react";
|
|
2
|
-
var
|
|
2
|
+
var F = { exports: {} }, R = {};
|
|
3
3
|
var ee;
|
|
4
4
|
function ce() {
|
|
5
5
|
if (ee) return R;
|
|
@@ -58,7 +58,7 @@ function he() {
|
|
|
58
58
|
case b:
|
|
59
59
|
var u = l.render;
|
|
60
60
|
return l = l.displayName, l || (l = u.displayName || u.name || "", l = l !== "" ? "ForwardRef(" + l + ")" : "ForwardRef"), l;
|
|
61
|
-
case
|
|
61
|
+
case H:
|
|
62
62
|
return u = l.displayName || null, u !== null ? u : f(l.type) || "Memo";
|
|
63
63
|
case A:
|
|
64
64
|
u = l._payload, l = l._init;
|
|
@@ -219,7 +219,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
219
219
|
function g(l) {
|
|
220
220
|
return typeof l == "object" && l !== null && l.$$typeof === C;
|
|
221
221
|
}
|
|
222
|
-
var p = ae, C = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), k = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), P = Symbol.for("react.suspense_list"),
|
|
222
|
+
var p = ae, C = Symbol.for("react.transitional.element"), m = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), O = Symbol.for("react.strict_mode"), v = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), k = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), P = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), ie = Symbol.for("react.client.reference"), j = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, ne = Array.isArray, U = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
225
|
p = {
|
|
@@ -256,7 +256,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
256
256
|
}
|
|
257
257
|
var se;
|
|
258
258
|
function de() {
|
|
259
|
-
return se || (se = 1, process.env.NODE_ENV === "production" ?
|
|
259
|
+
return se || (se = 1, process.env.NODE_ENV === "production" ? F.exports = ce() : F.exports = he()), F.exports;
|
|
260
260
|
}
|
|
261
261
|
var ue = de();
|
|
262
262
|
class pe {
|
|
@@ -323,7 +323,7 @@ class pe {
|
|
|
323
323
|
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";
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function z() {
|
|
327
327
|
return Math.random().toString(36).substring(2, 10);
|
|
328
328
|
}
|
|
329
329
|
function fe(f, e) {
|
|
@@ -335,7 +335,7 @@ function fe(f, e) {
|
|
|
335
335
|
}
|
|
336
336
|
return t(f, e) || s(f, e);
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function B(f, e = 50, t = !1) {
|
|
339
339
|
let s;
|
|
340
340
|
return function(...i) {
|
|
341
341
|
const n = self, r = () => {
|
|
@@ -344,7 +344,7 @@ function H(f, e = 50, t = !1) {
|
|
|
344
344
|
clearTimeout(s), s = setTimeout(r, e), a && f.apply(n, i);
|
|
345
345
|
};
|
|
346
346
|
}
|
|
347
|
-
function
|
|
347
|
+
function W(f, e) {
|
|
348
348
|
return JSON.stringify(f) === JSON.stringify(e);
|
|
349
349
|
}
|
|
350
350
|
function me(f) {
|
|
@@ -366,7 +366,7 @@ class S {
|
|
|
366
366
|
data;
|
|
367
367
|
mandatory;
|
|
368
368
|
constructor(e) {
|
|
369
|
-
this.id = !e.id || e.id === "" ?
|
|
369
|
+
this.id = !e.id || e.id === "" ? z() : 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 || {};
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
class x {
|
|
@@ -377,7 +377,7 @@ class x {
|
|
|
377
377
|
closable;
|
|
378
378
|
options;
|
|
379
379
|
constructor(e) {
|
|
380
|
-
if (this.id = !e.id || e.id === "" ?
|
|
380
|
+
if (this.id = !e.id || e.id === "" ? z() : 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)
|
|
381
381
|
for (const t of e.options)
|
|
382
382
|
this.options.push(new S(t));
|
|
383
383
|
}
|
|
@@ -591,9 +591,21 @@ class ve {
|
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
593
|
close() {
|
|
594
|
-
this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose), this.content.main.classList.remove(this.classes.contentOpen), this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant")
|
|
594
|
+
this.main.main.setAttribute("aria-expanded", "false"), this.main.arrow.path.setAttribute("d", this.classes.arrowClose), this.content.main.classList.remove(this.classes.contentOpen), this.content.search.input.setAttribute("aria-hidden", "true"), this.main.main.removeAttribute("aria-activedescendant");
|
|
595
|
+
const e = this.getAnimationTiming();
|
|
596
|
+
setTimeout(() => {
|
|
595
597
|
this.main.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow), this.content.main.classList.remove(this.classes.dirAbove, this.classes.dirBelow);
|
|
596
|
-
},
|
|
598
|
+
}, e);
|
|
599
|
+
}
|
|
600
|
+
getAnimationTiming() {
|
|
601
|
+
const t = getComputedStyle(this.content.main).getPropertyValue("--ss-animation-timing").trim();
|
|
602
|
+
if (t) {
|
|
603
|
+
if (t.endsWith("ms"))
|
|
604
|
+
return parseFloat(t);
|
|
605
|
+
if (t.endsWith("s"))
|
|
606
|
+
return parseFloat(t) * 1e3;
|
|
607
|
+
}
|
|
608
|
+
return 200;
|
|
597
609
|
}
|
|
598
610
|
updateClassStyles() {
|
|
599
611
|
if (this.main.main.className = "", this.main.main.removeAttribute("style"), this.content.main.className = "", this.content.main.removeAttribute("style"), this.main.main.classList.add(this.classes.main), this.content.main.classList.add(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)
|
|
@@ -796,7 +808,7 @@ class ve {
|
|
|
796
808
|
main: e,
|
|
797
809
|
input: t
|
|
798
810
|
};
|
|
799
|
-
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 =
|
|
811
|
+
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 = B((n) => {
|
|
800
812
|
this.callbacks.search(n.target.value);
|
|
801
813
|
}, 100), t.onkeydown = (n) => {
|
|
802
814
|
switch (n.key) {
|
|
@@ -858,7 +870,7 @@ class ve {
|
|
|
858
870
|
return i;
|
|
859
871
|
}
|
|
860
872
|
searchFocus() {
|
|
861
|
-
this.content.search.input.focus();
|
|
873
|
+
this.content.search.input.focus({ preventScroll: !0 });
|
|
862
874
|
}
|
|
863
875
|
getOptions(e = !1, t = !1, s = !1) {
|
|
864
876
|
let i = "." + this.classes.option;
|
|
@@ -1157,28 +1169,30 @@ class be {
|
|
|
1157
1169
|
observeCall(e) {
|
|
1158
1170
|
if (!this.listen)
|
|
1159
1171
|
return;
|
|
1160
|
-
let t = !1, s = !1, i = !1;
|
|
1161
|
-
for (const
|
|
1162
|
-
if (
|
|
1163
|
-
for (const
|
|
1164
|
-
if (
|
|
1165
|
-
|
|
1172
|
+
let t = !1, s = !1, i = !1, n = !1;
|
|
1173
|
+
for (const r of e) {
|
|
1174
|
+
if (r.target === this.select && (r.attributeName === "disabled" && (s = !0), r.attributeName === "class" && (t = !0), r.type === "childList")) {
|
|
1175
|
+
for (const a of Array.from(r.addedNodes))
|
|
1176
|
+
if (a.nodeName === "OPTION" && a.value === this.select.value) {
|
|
1177
|
+
n = !0;
|
|
1166
1178
|
break;
|
|
1167
1179
|
}
|
|
1168
1180
|
i = !0;
|
|
1169
1181
|
}
|
|
1170
|
-
(
|
|
1182
|
+
(r.target.nodeName === "OPTGROUP" || r.target.nodeName === "OPTION") && (i = !0);
|
|
1171
1183
|
}
|
|
1172
1184
|
if (t && this.onClassChange && this.onClassChange(this.select.className.split(" ")), s && this.onDisabledChange && (this.changeListen(!1), this.onDisabledChange(this.select.disabled), this.changeListen(!0)), i && this.onOptionsChange) {
|
|
1173
1185
|
if (this.isUpdating) {
|
|
1174
1186
|
if (this.select.options.length > 0) {
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1187
|
+
const r = this.getData();
|
|
1188
|
+
r.length > 0 && (this.pendingOptionsChange = r);
|
|
1177
1189
|
}
|
|
1190
|
+
n && this.select.dispatchEvent(new Event("change"));
|
|
1178
1191
|
return;
|
|
1179
1192
|
}
|
|
1180
1193
|
this.changeListen(!1), this.onOptionsChange(this.getData()), this.changeListen(!0);
|
|
1181
1194
|
}
|
|
1195
|
+
n && this.select.dispatchEvent(new Event("change"));
|
|
1182
1196
|
}
|
|
1183
1197
|
// From the select element pull optgroup and options into data
|
|
1184
1198
|
getData() {
|
|
@@ -1331,9 +1345,8 @@ class be {
|
|
|
1331
1345
|
if (n.__slimSelectLabelHandler)
|
|
1332
1346
|
return;
|
|
1333
1347
|
const r = (a) => {
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
}, 0);
|
|
1348
|
+
const c = a.target;
|
|
1349
|
+
a.preventDefault(), c === n && this.onLabelClick && this.onLabelClick();
|
|
1337
1350
|
};
|
|
1338
1351
|
n.__slimSelectLabelHandler = r, n.addEventListener("click", r, { capture: !0, passive: !1 });
|
|
1339
1352
|
});
|
|
@@ -1376,6 +1389,7 @@ class we {
|
|
|
1376
1389
|
alwaysOpen;
|
|
1377
1390
|
showSearch;
|
|
1378
1391
|
focusSearch;
|
|
1392
|
+
keepSearch;
|
|
1379
1393
|
ariaLabel;
|
|
1380
1394
|
searchPlaceholder;
|
|
1381
1395
|
searchText;
|
|
@@ -1397,7 +1411,7 @@ class we {
|
|
|
1397
1411
|
maxValuesMessage;
|
|
1398
1412
|
addableText;
|
|
1399
1413
|
constructor(e) {
|
|
1400
|
-
e || (e = {}), this.id = "ss-" +
|
|
1414
|
+
e || (e = {}), this.id = "ss-" + z(), 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.keepSearch = e.keepSearch !== void 0 ? e.keepSearch : !1, 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}';
|
|
1401
1415
|
}
|
|
1402
1416
|
}
|
|
1403
1417
|
let Se = class {
|
|
@@ -1435,7 +1449,7 @@ let Se = class {
|
|
|
1435
1449
|
this.selectEl.dataset.ssid && this.destroy(), this.settings = new we(e.settings), this.cssClasses = new pe(e.cssClasses);
|
|
1436
1450
|
const t = ["beforeOpen", "afterOpen", "beforeClose", "afterClose"];
|
|
1437
1451
|
for (const a in e.events)
|
|
1438
|
-
e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] =
|
|
1452
|
+
e.events.hasOwnProperty(a) && (t.indexOf(a) !== -1 ? this.events[a] = B(e.events[a], 100) : this.events[a] = e.events[a]);
|
|
1439
1453
|
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 be(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 = (a) => {
|
|
1440
1454
|
this.setSelected(a.map((c) => c.id));
|
|
1441
1455
|
}, this.select.onClassChange = (a) => {
|
|
@@ -1445,7 +1459,7 @@ let Se = class {
|
|
|
1445
1459
|
}, this.select.onOptionsChange = (a) => {
|
|
1446
1460
|
this.setData(a || []);
|
|
1447
1461
|
}, this.select.onLabelClick = () => {
|
|
1448
|
-
this.settings.disabled || this.open();
|
|
1462
|
+
this.settings.disabled || (this.settings.isOpen ? this.close() : this.open());
|
|
1449
1463
|
};
|
|
1450
1464
|
const s = e.data ? e.data : this.select.getData();
|
|
1451
1465
|
this.store = new ge(this.settings.isMultiple ? "multiple" : "single", s), e.data && this.select.updateOptions(this.store.getData());
|
|
@@ -1482,7 +1496,7 @@ let Se = class {
|
|
|
1482
1496
|
}
|
|
1483
1497
|
this.store.setData(e);
|
|
1484
1498
|
const i = this.store.getData();
|
|
1485
|
-
this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !
|
|
1499
|
+
this.select.updateOptions(i), this.render.renderValues(), this.render.renderOptions(i), this.events.afterChange && !W(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1486
1500
|
}
|
|
1487
1501
|
getSelected() {
|
|
1488
1502
|
let e = this.store.getSelectedOptions();
|
|
@@ -1503,13 +1517,13 @@ let Se = class {
|
|
|
1503
1517
|
}
|
|
1504
1518
|
this.store.setSelectedBy("id", n);
|
|
1505
1519
|
const r = this.store.getData();
|
|
1506
|
-
this.select.updateOptions(r), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(r), t && this.events.afterChange && !
|
|
1520
|
+
this.select.updateOptions(r), this.render.renderValues(), this.render.content.search.input.value !== "" ? this.search(this.render.content.search.input.value) : this.render.renderOptions(r), t && this.events.afterChange && !W(s, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1507
1521
|
}
|
|
1508
1522
|
addOption(e) {
|
|
1509
1523
|
const t = this.store.getSelected();
|
|
1510
1524
|
this.store.getDataOptions().some((i) => i.value === (e.value ?? e.text)) || this.store.addOption(e);
|
|
1511
1525
|
const s = this.store.getData();
|
|
1512
|
-
this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !
|
|
1526
|
+
this.select.updateOptions(s), this.render.renderValues(), this.render.renderOptions(s), this.events.afterChange && !W(t, this.store.getSelected()) && this.events.afterChange(this.store.getSelectedOptions());
|
|
1513
1527
|
}
|
|
1514
1528
|
open() {
|
|
1515
1529
|
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(() => {
|
|
@@ -1517,7 +1531,7 @@ let Se = class {
|
|
|
1517
1531
|
}, this.settings.timeoutDelay), this.settings.contentPosition === "absolute" && (this.settings.intervalMove && clearInterval(this.settings.intervalMove), this.settings.intervalMove = setInterval(this.render.moveContent.bind(this.render), 500)));
|
|
1518
1532
|
}
|
|
1519
1533
|
close(e = null) {
|
|
1520
|
-
!this.settings.isOpen || this.settings.alwaysOpen || (this.events.beforeClose && this.events.beforeClose(), this.render.close(), this.render.content.search.input.value !== "" && this.search(""), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
|
|
1534
|
+
!this.settings.isOpen || this.settings.alwaysOpen || (this.events.beforeClose && this.events.beforeClose(), this.render.close(), !this.settings.keepSearch && this.render.content.search.input.value !== "" && this.search(""), this.render.mainFocus(e), this.settings.isOpen = !1, this.settings.isFullOpen = !1, this.closeTimeout = setTimeout(() => {
|
|
1521
1535
|
this.events.afterClose && this.events.afterClose(), document.removeEventListener("click", this.documentClick);
|
|
1522
1536
|
}, this.settings.timeoutDelay), this.settings.intervalMove && clearInterval(this.settings.intervalMove));
|
|
1523
1537
|
}
|
|
@@ -1546,11 +1560,11 @@ let Se = class {
|
|
|
1546
1560
|
destroy() {
|
|
1547
1561
|
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();
|
|
1548
1562
|
}
|
|
1549
|
-
windowResize =
|
|
1563
|
+
windowResize = B(() => {
|
|
1550
1564
|
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1551
1565
|
});
|
|
1552
1566
|
// Event listener for window scrolling
|
|
1553
|
-
windowScroll =
|
|
1567
|
+
windowScroll = B(() => {
|
|
1554
1568
|
!this.settings.isOpen && !this.settings.isFullOpen || this.render.moveContent();
|
|
1555
1569
|
});
|
|
1556
1570
|
// Event listener for document click
|
|
@@ -1595,8 +1609,8 @@ const Oe = re(
|
|
|
1595
1609
|
if (!o.current) return;
|
|
1596
1610
|
const v = a ? O.map((A) => A.value) : O[0]?.value ?? "", k = o.current.getData().flatMap(
|
|
1597
1611
|
(A) => "label" in A ? A.options : [A]
|
|
1598
|
-
), b = g.current, D = b === void 0 ? !1 : Array.isArray(b) ? b.length > 0 && b.every((A) => k.some((M) => M.value === A)) : b !== "" && k.some((A) => A.value === b), P = Array.isArray(v) ? v.length > 0 && v.every((A) => k.some((M) => M.value === A)) : v !== "" && k.some((A) => A.value === v),
|
|
1599
|
-
n &&
|
|
1612
|
+
), b = g.current, D = b === void 0 ? !1 : Array.isArray(b) ? b.length > 0 && b.every((A) => k.some((M) => M.value === A)) : b !== "" && k.some((A) => A.value === b), P = Array.isArray(v) ? v.length > 0 && v.every((A) => k.some((M) => M.value === A)) : v !== "" && k.some((A) => A.value === v), H = Array.isArray(v) && Array.isArray(b) ? JSON.stringify(v.sort()) !== JSON.stringify(b.sort()) : b !== v;
|
|
1613
|
+
n && H && (D || P) && (n(v), g.current = v), L && L(O);
|
|
1600
1614
|
}
|
|
1601
1615
|
}, o.current = new Se(m), i !== void 0 && C(i, !1), () => {
|
|
1602
1616
|
o.current && (o.current.destroy(), o.current = null);
|