slim-select 3.4.1 → 3.4.3
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 +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +189 -182
- 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 +30 -23
- 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 -1
- package/dist/vue/index.js +94 -87
- package/dist/vue/index.umd.js +1 -1
- package/package.json +9 -9
- package/src/slim-select/index.test.ts +32 -0
- package/src/slim-select/render.test.ts +50 -0
- package/src/slim-select/render.ts +7 -1
- package/src/slim-select/store.test.ts +17 -0
- package/src/slim-select/store.ts +20 -6
package/dist/vue/index.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ declare class Render {
|
|
|
131
131
|
store: Store;
|
|
132
132
|
callbacks: Callbacks;
|
|
133
133
|
private lastSelectedOption;
|
|
134
|
+
private lastRenderedOptions;
|
|
134
135
|
private closeAnimationTimeout;
|
|
135
136
|
main: Main;
|
|
136
137
|
content: Content;
|
|
@@ -300,7 +301,7 @@ declare class Store {
|
|
|
300
301
|
getData(): Option_2[] | Optgroup[];
|
|
301
302
|
getDataOptions(): Option_2[];
|
|
302
303
|
addOption(option: Partial<Option_2>, addToStart?: boolean): void;
|
|
303
|
-
setSelectedBy(selectedType: 'id' | 'value', selectedValues: string[]): void;
|
|
304
|
+
setSelectedBy(selectedType: 'id' | 'value', selectedValues: string[], allowEmptySelection?: boolean): void;
|
|
304
305
|
getSelected(): string[];
|
|
305
306
|
getSelectedValues(): string[];
|
|
306
307
|
getSelectedOptions(): Option_2[];
|
package/dist/vue/index.js
CHANGED
|
@@ -71,7 +71,7 @@ class M {
|
|
|
71
71
|
function O() {
|
|
72
72
|
return Math.random().toString(36).substring(2, 10);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function E(c, e) {
|
|
75
75
|
function t(i, l) {
|
|
76
76
|
return l && i && i.classList && i.classList.contains(l) || l && i && i.dataset && i.dataset.id && i.dataset.id === e ? i : null;
|
|
77
77
|
}
|
|
@@ -178,8 +178,10 @@ class F {
|
|
|
178
178
|
}
|
|
179
179
|
setData(e, t = !1) {
|
|
180
180
|
const s = this.partialToFullData(e);
|
|
181
|
+
let i = [];
|
|
181
182
|
if (t) {
|
|
182
|
-
|
|
183
|
+
i = this.getSelectedOptions();
|
|
184
|
+
const l = [];
|
|
183
185
|
i.forEach((n) => {
|
|
184
186
|
let a = !1;
|
|
185
187
|
for (const o of s) {
|
|
@@ -188,8 +190,8 @@ class F {
|
|
|
188
190
|
break;
|
|
189
191
|
}
|
|
190
192
|
if (o instanceof m) {
|
|
191
|
-
for (const
|
|
192
|
-
if (
|
|
193
|
+
for (const r of o.options)
|
|
194
|
+
if (r.id === n.id) {
|
|
193
195
|
a = !0;
|
|
194
196
|
break;
|
|
195
197
|
}
|
|
@@ -199,7 +201,10 @@ class F {
|
|
|
199
201
|
}), this.data = [...l, ...s];
|
|
200
202
|
} else
|
|
201
203
|
this.data = s;
|
|
202
|
-
this.selectType === "single"
|
|
204
|
+
if (this.selectType === "single") {
|
|
205
|
+
const l = t && i.length === 0;
|
|
206
|
+
this.setSelectedBy("id", this.getSelected(), l);
|
|
207
|
+
}
|
|
203
208
|
}
|
|
204
209
|
// Get data will return all the data
|
|
205
210
|
getData() {
|
|
@@ -220,21 +225,22 @@ class F {
|
|
|
220
225
|
// Pass in an array of id that will loop through
|
|
221
226
|
// each option and set the selected property to true
|
|
222
227
|
// but also clean selected by determining selectType
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
// When allowEmptySelection is true (e.g. after search with no prior selection), single select will not auto-select the first option
|
|
229
|
+
setSelectedBy(e, t, s = !1) {
|
|
230
|
+
let i = null, l = !1;
|
|
231
|
+
const n = [];
|
|
232
|
+
for (let o of this.data) {
|
|
233
|
+
if (o instanceof m)
|
|
234
|
+
for (let r of o.options) {
|
|
235
|
+
i || (i = r);
|
|
236
|
+
let h = r[e] || "";
|
|
237
|
+
r.selected = l ? !1 : t.includes(h), r.selected && (n.push(r), this.selectType === "single" && (l = !0));
|
|
232
238
|
}
|
|
233
|
-
|
|
239
|
+
o instanceof p && (i || (i = o), o.selected = l ? !1 : t.includes(o[e]), o.selected && (n.push(o), this.selectType === "single" && (l = !0)));
|
|
234
240
|
}
|
|
235
|
-
this.selectType === "single" &&
|
|
236
|
-
const
|
|
237
|
-
this.selectedOrder =
|
|
241
|
+
this.selectType === "single" && i && !l && !s && (i.selected = !0, n.push(i));
|
|
242
|
+
const a = t.map((o) => n.find((r) => r[e] === o)?.id || "");
|
|
243
|
+
this.selectedOrder = a;
|
|
238
244
|
}
|
|
239
245
|
getSelected() {
|
|
240
246
|
return this.getSelectedOptions().map((e) => e.id);
|
|
@@ -309,6 +315,7 @@ class V {
|
|
|
309
315
|
callbacks;
|
|
310
316
|
// Used to compute the range selection
|
|
311
317
|
lastSelectedOption;
|
|
318
|
+
lastRenderedOptions;
|
|
312
319
|
// Timeout tracking for cleanup
|
|
313
320
|
closeAnimationTimeout = null;
|
|
314
321
|
// Elements
|
|
@@ -317,7 +324,7 @@ class V {
|
|
|
317
324
|
// Classes
|
|
318
325
|
classes;
|
|
319
326
|
constructor(e, t, s, i) {
|
|
320
|
-
this.store = s, this.settings = e, this.classes = t, this.callbacks = i, this.lastSelectedOption = null, 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);
|
|
327
|
+
this.store = s, this.settings = e, this.classes = t, this.callbacks = i, 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);
|
|
321
328
|
}
|
|
322
329
|
// Helper method to add classes that may contain spaces
|
|
323
330
|
// Splits by spaces and adds each class individually to avoid DOMException
|
|
@@ -383,26 +390,26 @@ class V {
|
|
|
383
390
|
}
|
|
384
391
|
mainDiv() {
|
|
385
392
|
const e = document.createElement("div");
|
|
386
|
-
e.dataset.id = this.settings.id, e.setAttribute("aria-label", this.settings.ariaLabel), e.tabIndex = 0, e.onkeydown = (
|
|
387
|
-
switch (
|
|
393
|
+
e.dataset.id = this.settings.id, e.setAttribute("aria-label", this.settings.ariaLabel), e.tabIndex = 0, e.onkeydown = (r) => {
|
|
394
|
+
switch (r.key) {
|
|
388
395
|
case "ArrowUp":
|
|
389
396
|
case "ArrowDown":
|
|
390
|
-
return this.callbacks.open(),
|
|
397
|
+
return this.callbacks.open(), r.key === "ArrowDown" ? this.highlight("down") : this.highlight("up"), !1;
|
|
391
398
|
case "Tab":
|
|
392
399
|
return this.callbacks.close(), !0;
|
|
393
400
|
// Continue doing normal tabbing
|
|
394
401
|
case "Enter":
|
|
395
402
|
case " ":
|
|
396
403
|
this.callbacks.open();
|
|
397
|
-
const
|
|
404
|
+
const h = this.content.list.querySelector(
|
|
398
405
|
"." + this.classes.getFirst("highlighted")
|
|
399
406
|
);
|
|
400
|
-
return
|
|
407
|
+
return h && h.click(), !1;
|
|
401
408
|
case "Escape":
|
|
402
409
|
return this.callbacks.close(), !1;
|
|
403
410
|
}
|
|
404
|
-
return
|
|
405
|
-
}, e.onclick = (
|
|
411
|
+
return r.key.length === 1 && this.callbacks.open(), !0;
|
|
412
|
+
}, e.onclick = (r) => {
|
|
406
413
|
this.settings.disabled || (this.settings.isOpen ? this.callbacks.close() : this.callbacks.open());
|
|
407
414
|
};
|
|
408
415
|
const t = document.createElement("div");
|
|
@@ -410,12 +417,12 @@ class V {
|
|
|
410
417
|
const s = document.createElement("div");
|
|
411
418
|
this.addClasses(s, this.classes.deselect);
|
|
412
419
|
const i = this.store?.getSelectedOptions();
|
|
413
|
-
!this.settings.allowDeselect || this.settings.isMultiple && i && i.length <= 0 ? this.addClasses(s, this.classes.hide) : this.removeClasses(s, this.classes.hide), s.onclick = (
|
|
414
|
-
if (
|
|
420
|
+
!this.settings.allowDeselect || this.settings.isMultiple && i && i.length <= 0 ? this.addClasses(s, this.classes.hide) : this.removeClasses(s, this.classes.hide), s.onclick = (r) => {
|
|
421
|
+
if (r.stopPropagation(), this.settings.disabled)
|
|
415
422
|
return;
|
|
416
|
-
let
|
|
423
|
+
let h = !0;
|
|
417
424
|
const d = this.store.getSelectedOptions(), f = [];
|
|
418
|
-
if (this.callbacks.beforeChange && (
|
|
425
|
+
if (this.callbacks.beforeChange && (h = this.callbacks.beforeChange(f, d) === !0), h) {
|
|
419
426
|
if (this.settings.isMultiple)
|
|
420
427
|
this.callbacks.setSelected([], !1), this.updateDeselectAll();
|
|
421
428
|
else {
|
|
@@ -520,16 +527,16 @@ class V {
|
|
|
520
527
|
if (a.preventDefault(), a.stopPropagation(), this.settings.disabled)
|
|
521
528
|
return;
|
|
522
529
|
let o = !0;
|
|
523
|
-
const
|
|
524
|
-
if (!(this.settings.minSelected &&
|
|
530
|
+
const r = this.store.getSelectedOptions(), h = r.filter((d) => d.selected && d.id !== e.id, !0);
|
|
531
|
+
if (!(this.settings.minSelected && h.length < this.settings.minSelected) && (this.callbacks.beforeChange && (o = this.callbacks.beforeChange(h, r) === !0), o)) {
|
|
525
532
|
let d = [];
|
|
526
|
-
for (const f of
|
|
533
|
+
for (const f of h) {
|
|
527
534
|
if (f instanceof m)
|
|
528
535
|
for (const u of f.options)
|
|
529
536
|
u.id && d.push(u.id);
|
|
530
537
|
f instanceof p && d.push(f.id);
|
|
531
538
|
}
|
|
532
|
-
this.callbacks.setSelected(d, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(
|
|
539
|
+
this.callbacks.setSelected(d, !1), this.settings.closeOnSelect && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(h), this.updateDeselectAll();
|
|
533
540
|
}
|
|
534
541
|
};
|
|
535
542
|
const l = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
@@ -611,7 +618,7 @@ class V {
|
|
|
611
618
|
this.content.search.input.focus();
|
|
612
619
|
return;
|
|
613
620
|
}
|
|
614
|
-
const
|
|
621
|
+
const r = (d) => {
|
|
615
622
|
let f = new p(d);
|
|
616
623
|
if (this.callbacks.addOption(f), this.settings.isMultiple) {
|
|
617
624
|
let u = this.store.getSelected();
|
|
@@ -621,16 +628,16 @@ class V {
|
|
|
621
628
|
this.callbacks.search(""), this.settings.closeOnSelect && setTimeout(() => {
|
|
622
629
|
this.callbacks.close();
|
|
623
630
|
}, 100);
|
|
624
|
-
},
|
|
625
|
-
|
|
626
|
-
typeof d == "string" ?
|
|
631
|
+
}, h = this.callbacks.addable(o);
|
|
632
|
+
h === !1 || h === void 0 || h === null || (h instanceof Promise ? h.then((d) => {
|
|
633
|
+
typeof d == "string" ? r({
|
|
627
634
|
text: d,
|
|
628
635
|
value: d
|
|
629
|
-
}) :
|
|
630
|
-
}) : typeof
|
|
631
|
-
text:
|
|
632
|
-
value:
|
|
633
|
-
}) :
|
|
636
|
+
}) : h instanceof Error ? this.renderError(h.message) : r(d);
|
|
637
|
+
}) : typeof h == "string" ? r({
|
|
638
|
+
text: h,
|
|
639
|
+
value: h
|
|
640
|
+
}) : h instanceof Error ? this.renderError(h.message) : r(h));
|
|
634
641
|
}, e.appendChild(s), i.addable = {
|
|
635
642
|
main: s,
|
|
636
643
|
svg: l,
|
|
@@ -671,17 +678,17 @@ class V {
|
|
|
671
678
|
this.removeClasses(n, this.classes.highlighted);
|
|
672
679
|
const a = n.parentElement;
|
|
673
680
|
if (a && a.classList.contains(this.classes.getFirst("mainOpen"))) {
|
|
674
|
-
const
|
|
675
|
-
|
|
681
|
+
const h = a.querySelector("." + this.classes.getFirst("optgroupLabel"));
|
|
682
|
+
h && h.click();
|
|
676
683
|
}
|
|
677
684
|
let o = t[e === "down" ? l + 1 < t.length ? l + 1 : 0 : l - 1 >= 0 ? l - 1 : t.length - 1];
|
|
678
685
|
this.addClasses(o, this.classes.highlighted), this.ensureElementInView(this.content.list, o), o.id && this.main.main.setAttribute("aria-activedescendant", o.id);
|
|
679
|
-
const
|
|
680
|
-
if (
|
|
681
|
-
const
|
|
686
|
+
const r = o.parentElement;
|
|
687
|
+
if (r && r.classList.contains(this.classes.getFirst("close"))) {
|
|
688
|
+
const h = r.querySelector(
|
|
682
689
|
"." + this.classes.getFirst("optgroupLabel")
|
|
683
690
|
);
|
|
684
|
-
|
|
691
|
+
h && h.click();
|
|
685
692
|
}
|
|
686
693
|
return;
|
|
687
694
|
}
|
|
@@ -707,7 +714,7 @@ class V {
|
|
|
707
714
|
}
|
|
708
715
|
// Take in data and add options to
|
|
709
716
|
renderOptions(e) {
|
|
710
|
-
if (this.content.list.innerHTML = "", e.length === 0) {
|
|
717
|
+
if (this.lastRenderedOptions = e.map((s) => s instanceof p ? [s] : s.options.map((i) => new p(i))).flat(), this.content.list.innerHTML = "", e.length === 0) {
|
|
711
718
|
const s = document.createElement("div");
|
|
712
719
|
this.addClasses(s, this.classes.search), this.callbacks.addable ? s.innerHTML = this.settings.addableText.replace("{value}", this.content.search.input.value) : s.innerHTML = this.settings.searchText, this.content.list.appendChild(s);
|
|
713
720
|
return;
|
|
@@ -734,15 +741,15 @@ class V {
|
|
|
734
741
|
if (this.addClasses(a, this.classes.optgroupActions), l.appendChild(a), this.settings.isMultiple && s.selectAll) {
|
|
735
742
|
const o = document.createElement("div");
|
|
736
743
|
this.addClasses(o, this.classes.optgroupSelectAll);
|
|
737
|
-
let
|
|
744
|
+
let r = !0;
|
|
738
745
|
for (const g of s.options)
|
|
739
746
|
if (!g.selected) {
|
|
740
|
-
|
|
747
|
+
r = !1;
|
|
741
748
|
break;
|
|
742
749
|
}
|
|
743
|
-
|
|
744
|
-
const
|
|
745
|
-
|
|
750
|
+
r && this.addClasses(o, this.classes.selected);
|
|
751
|
+
const h = document.createElement("span");
|
|
752
|
+
h.textContent = s.selectAllText, o.appendChild(h);
|
|
746
753
|
const d = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
747
754
|
d.setAttribute("viewBox", "0 0 100 100"), o.appendChild(d);
|
|
748
755
|
const f = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
@@ -751,7 +758,7 @@ class V {
|
|
|
751
758
|
u.setAttribute("d", this.classes.optgroupSelectAllCheck), d.appendChild(u), o.addEventListener("click", (g) => {
|
|
752
759
|
g.preventDefault(), g.stopPropagation();
|
|
753
760
|
const v = this.store.getSelected();
|
|
754
|
-
if (
|
|
761
|
+
if (r) {
|
|
755
762
|
const C = v.filter((w) => {
|
|
756
763
|
for (const b of s.options)
|
|
757
764
|
if (w === b.id)
|
|
@@ -773,11 +780,11 @@ class V {
|
|
|
773
780
|
if (s.closable !== "off") {
|
|
774
781
|
const o = document.createElement("div");
|
|
775
782
|
this.addClasses(o, this.classes.optgroupClosable);
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.getFirst("close")) ? (this.removeClasses(i, this.classes.close), this.addClasses(i, this.classes.mainOpen),
|
|
783
|
+
const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
784
|
+
r.setAttribute("viewBox", "0 0 100 100"), this.addClasses(r, this.classes.arrow), o.appendChild(r);
|
|
785
|
+
const h = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
786
|
+
r.appendChild(h), s.options.some((d) => d.selected) || this.content.search.input.value.trim() !== "" ? (this.addClasses(o, this.classes.mainOpen), h.setAttribute("d", this.classes.arrowOpen)) : s.closable === "open" ? (this.addClasses(i, this.classes.mainOpen), h.setAttribute("d", this.classes.arrowOpen)) : s.closable === "close" && (this.addClasses(i, this.classes.close), h.setAttribute("d", this.classes.arrowClose)), l.addEventListener("click", (d) => {
|
|
787
|
+
d.preventDefault(), d.stopPropagation(), i.classList.contains(this.classes.getFirst("close")) ? (this.removeClasses(i, this.classes.close), this.addClasses(i, this.classes.mainOpen), h.setAttribute("d", this.classes.arrowOpen)) : (this.removeClasses(i, this.classes.mainOpen), this.addClasses(i, this.classes.close), h.setAttribute("d", this.classes.arrowClose));
|
|
781
788
|
}), a.appendChild(o);
|
|
782
789
|
}
|
|
783
790
|
i.appendChild(l);
|
|
@@ -807,26 +814,26 @@ class V {
|
|
|
807
814
|
if (e.disabled || !this.settings.isMultiple && e.selected && !this.settings.allowDeselect || e.selected && e.mandatory || this.settings.isMultiple && this.settings.maxSelected <= i.length && !e.selected || this.settings.isMultiple && this.settings.minSelected >= i.length && e.selected && !a)
|
|
808
815
|
return;
|
|
809
816
|
let o = !1;
|
|
810
|
-
const
|
|
811
|
-
let
|
|
817
|
+
const r = this.store.getSelectedOptions();
|
|
818
|
+
let h = [];
|
|
812
819
|
if (this.settings.isMultiple) {
|
|
813
|
-
const d =
|
|
820
|
+
const d = r.some((u) => u.id === n);
|
|
814
821
|
if (s.shiftKey && this.lastSelectedOption) {
|
|
815
|
-
const u = this.
|
|
822
|
+
const u = this.lastRenderedOptions, g = u.findIndex((C) => C.id === this.lastSelectedOption.id), v = u.findIndex((C) => C.id === e.id);
|
|
816
823
|
if (g >= 0 && v >= 0) {
|
|
817
|
-
const C = Math.min(g, v), w = Math.max(g, v), A = u.slice(C, w + 1).filter((
|
|
818
|
-
|
|
824
|
+
const C = Math.min(g, v), w = Math.max(g, v), A = u.slice(C, w + 1).filter((x) => !r.find((T) => T.id === x.id));
|
|
825
|
+
r.length + A.length <= this.settings.maxSelected ? h = r.concat(A) : h = r;
|
|
819
826
|
} else
|
|
820
|
-
|
|
821
|
-
} else a ? (d ?
|
|
827
|
+
h = r;
|
|
828
|
+
} else a ? (d ? h = r.filter((u) => u.id !== n) : h = r.concat(e), this.lastSelectedOption = e) : (d ? h = r.filter((u) => u.id !== n) : h = r.concat(e), this.lastSelectedOption = e);
|
|
822
829
|
}
|
|
823
|
-
if (this.settings.isMultiple || (e.selected ?
|
|
830
|
+
if (this.settings.isMultiple || (e.selected ? h = [] : h = [e]), this.callbacks.beforeChange || (o = !0), this.callbacks.beforeChange && (this.callbacks.beforeChange(h, r) === !1 ? o = !1 : o = !0), o) {
|
|
824
831
|
this.store.getOptionByID(n) || this.callbacks.addOption(e), this.callbacks.setSelected(
|
|
825
|
-
|
|
832
|
+
h.map((u) => u.id),
|
|
826
833
|
!1
|
|
827
834
|
);
|
|
828
835
|
const d = s.ctrlKey || s.metaKey || s.shiftKey;
|
|
829
|
-
this.settings.closeOnSelect && !(this.settings.isMultiple && d) && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(
|
|
836
|
+
this.settings.closeOnSelect && !(this.settings.isMultiple && d) && this.callbacks.close(), this.callbacks.afterChange && this.callbacks.afterChange(h);
|
|
830
837
|
}
|
|
831
838
|
}), t;
|
|
832
839
|
}
|
|
@@ -841,17 +848,17 @@ class V {
|
|
|
841
848
|
n.innerHTML = e;
|
|
842
849
|
const a = (o) => {
|
|
843
850
|
if (o.nodeType === Node.TEXT_NODE) {
|
|
844
|
-
const
|
|
845
|
-
if (
|
|
851
|
+
const r = o.textContent || "", h = new RegExp("(" + l + ")", "i");
|
|
852
|
+
if (h.test(r)) {
|
|
846
853
|
const d = document.createElement("span");
|
|
847
|
-
|
|
848
|
-
if (u &&
|
|
854
|
+
r.split(h).forEach((u, g) => {
|
|
855
|
+
if (u && h.test(u)) {
|
|
849
856
|
const v = document.createElement("mark");
|
|
850
857
|
v.className = s, v.textContent = u, d.appendChild(v);
|
|
851
858
|
} else u && d.appendChild(document.createTextNode(u));
|
|
852
859
|
}), o.parentNode?.replaceChild(d, o);
|
|
853
860
|
}
|
|
854
|
-
} else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((
|
|
861
|
+
} else o.nodeType === Node.ELEMENT_NODE && Array.from(o.childNodes).forEach((r) => a(r));
|
|
855
862
|
};
|
|
856
863
|
return Array.from(n.childNodes).forEach((o) => a(o)), n.innerHTML;
|
|
857
864
|
}
|
|
@@ -872,14 +879,14 @@ class V {
|
|
|
872
879
|
const i = this.settings.contentWidth;
|
|
873
880
|
this.content.main.style.width = "", this.content.main.style.minWidth = "", this.content.main.style.maxWidth = "", i ? i.startsWith(">") ? this.content.main.style.minWidth = i.slice(1) : i.startsWith("<") ? this.content.main.style.maxWidth = i.slice(1) : this.content.main.style.width = i : this.content.main.style.width = e.width + "px";
|
|
874
881
|
const l = 20, n = window.innerWidth - l, a = () => {
|
|
875
|
-
const
|
|
876
|
-
if (
|
|
877
|
-
const
|
|
882
|
+
const r = this.content.main.getBoundingClientRect().right;
|
|
883
|
+
if (r <= n) return;
|
|
884
|
+
const h = r - n, d = parseFloat(this.content.main.style.left) || 0;
|
|
878
885
|
if (this.settings.contentPosition === "fixed") {
|
|
879
|
-
const f = Math.max(l, d -
|
|
886
|
+
const f = Math.max(l, d - h);
|
|
880
887
|
this.content.main.style.left = f + "px";
|
|
881
888
|
} else {
|
|
882
|
-
const f = Math.max(window.scrollX + l, d -
|
|
889
|
+
const f = Math.max(window.scrollX + l, d - h);
|
|
883
890
|
this.content.main.style.left = f + "px";
|
|
884
891
|
}
|
|
885
892
|
};
|
|
@@ -1144,8 +1151,8 @@ class B {
|
|
|
1144
1151
|
if (l.__slimSelectLabelHandler)
|
|
1145
1152
|
return;
|
|
1146
1153
|
const n = (a) => {
|
|
1147
|
-
const o = a.target,
|
|
1148
|
-
a.preventDefault(), !
|
|
1154
|
+
const o = a.target, r = E(o, this.select.dataset.id);
|
|
1155
|
+
a.preventDefault(), !r && this.onLabelClick && this.onLabelClick();
|
|
1149
1156
|
};
|
|
1150
1157
|
l.__slimSelectLabelHandler = n, l.addEventListener("click", n, { capture: !0, passive: !1 });
|
|
1151
1158
|
});
|
|
@@ -1312,7 +1319,7 @@ let H = class {
|
|
|
1312
1319
|
l.push(a);
|
|
1313
1320
|
continue;
|
|
1314
1321
|
}
|
|
1315
|
-
for (const o of i.filter((
|
|
1322
|
+
for (const o of i.filter((r) => r.value == a))
|
|
1316
1323
|
l.push(o.id);
|
|
1317
1324
|
}
|
|
1318
1325
|
this.store.setSelectedBy("id", l);
|
|
@@ -1369,7 +1376,7 @@ let H = class {
|
|
|
1369
1376
|
});
|
|
1370
1377
|
// Event listener for document click
|
|
1371
1378
|
documentClick = (e) => {
|
|
1372
|
-
this.settings.isOpen && e.target && !
|
|
1379
|
+
this.settings.isOpen && e.target && !E(e.target, this.settings.id) && this.close(e.type);
|
|
1373
1380
|
};
|
|
1374
1381
|
// Event Listener for window visibility change
|
|
1375
1382
|
windowVisibilityChange = () => {
|
|
@@ -1458,7 +1465,7 @@ const R = L({
|
|
|
1458
1465
|
},
|
|
1459
1466
|
handleAfterChange(c, e) {
|
|
1460
1467
|
if (!this.slim) return;
|
|
1461
|
-
const t = this.multiple ? c.map((o) => o.value) : c.length > 0 ? c[0].value : "", s = this.getCleanValue(this.$props.modelValue), i = this.slim.store.getDataOptions(), l = Array.isArray(s) ? s.length > 0 && s.every((o) => i.some((
|
|
1468
|
+
const t = this.multiple ? c.map((o) => o.value) : c.length > 0 ? c[0].value : "", s = this.getCleanValue(this.$props.modelValue), i = this.slim.store.getDataOptions(), l = Array.isArray(s) ? s.length > 0 && s.every((o) => i.some((r) => r.value === o)) : s !== "" && i.some((o) => o.value === s), n = Array.isArray(t) ? t.length > 0 && t.every((o) => i.some((r) => r.value === o)) : t !== "" && i.some((o) => o.value === t);
|
|
1462
1469
|
(Array.isArray(t) && Array.isArray(this.value) ? JSON.stringify(t.sort()) !== JSON.stringify(this.value.sort()) : this.value !== t) && (l || n) && (this.value = t), e && e(c);
|
|
1463
1470
|
},
|
|
1464
1471
|
getCleanValue(c) {
|