@danielgindi/selectbox 2.0.3 → 2.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/dist/lib.cjs.js +33 -18
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +34 -19
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +33 -18
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/lib/DropList.js +27 -15
- package/lib/SelectBox.js +6 -3
- package/package.json +63 -63
package/dist/lib.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @danielgindi/selectbox 2.0.
|
|
2
|
+
* @danielgindi/selectbox 2.0.5
|
|
3
3
|
* git://github.com/danielgindi/selectbox.git
|
|
4
4
|
*/
|
|
5
5
|
'use strict';
|
|
@@ -682,7 +682,8 @@ class DropList {
|
|
|
682
682
|
const p = this._p;
|
|
683
683
|
|
|
684
684
|
if (this.hasFocusedItem() && p.multi) {
|
|
685
|
-
|
|
685
|
+
const items = p.filteredItems ?? p.items;
|
|
686
|
+
let item = items[p.focusItemIndex];
|
|
686
687
|
if (item._nocheck || item._nointeraction) return this;
|
|
687
688
|
|
|
688
689
|
item._checked = !item._checked;
|
|
@@ -750,7 +751,7 @@ class DropList {
|
|
|
750
751
|
const p = this._p,labelProp = p.labelProp,valueProp = p.valueProp;
|
|
751
752
|
|
|
752
753
|
let isMulti = p.multi;
|
|
753
|
-
|
|
754
|
+
const items = p.items;
|
|
754
755
|
|
|
755
756
|
if (atIndex == null || atIndex < 0 || atIndex >= p.items.length) {
|
|
756
757
|
atIndex = -1;
|
|
@@ -1215,11 +1216,10 @@ class DropList {
|
|
|
1215
1216
|
if (!Array.isArray(filteredItems)) {
|
|
1216
1217
|
if (term) {
|
|
1217
1218
|
const matcher = new RegExp(escapeRegex(term), 'i');
|
|
1218
|
-
const labelProp = p.labelProp;
|
|
1219
1219
|
|
|
1220
1220
|
filteredItems = p.items.filter((x) => {
|
|
1221
1221
|
if (!filterGroups && x._group) return true;
|
|
1222
|
-
return matcher.test(x
|
|
1222
|
+
return matcher.test(x.label);
|
|
1223
1223
|
});
|
|
1224
1224
|
} else {
|
|
1225
1225
|
filteredItems = null;
|
|
@@ -1260,7 +1260,7 @@ class DropList {
|
|
|
1260
1260
|
p.filteredItems = null;
|
|
1261
1261
|
}
|
|
1262
1262
|
|
|
1263
|
-
|
|
1263
|
+
p.needsRefilter = false;
|
|
1264
1264
|
|
|
1265
1265
|
const items = p.filteredItems ?? p.items;
|
|
1266
1266
|
p.hasNoResultsItem = items.length === 0 && !!p.noResultsText;
|
|
@@ -1281,11 +1281,17 @@ class DropList {
|
|
|
1281
1281
|
return this;
|
|
1282
1282
|
}
|
|
1283
1283
|
|
|
1284
|
-
|
|
1284
|
+
rushRefilter() {
|
|
1285
1285
|
const p = this._p;
|
|
1286
|
-
|
|
1287
1286
|
if (p.needsRefilter)
|
|
1288
1287
|
this._refilterItems();
|
|
1288
|
+
return this;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
getFilteredItemCount() {
|
|
1292
|
+
const p = this._p;
|
|
1293
|
+
|
|
1294
|
+
this.rushRefilter();
|
|
1289
1295
|
|
|
1290
1296
|
if (p.filteredItems)
|
|
1291
1297
|
return p.filteredItems.length;
|
|
@@ -1487,6 +1493,8 @@ class DropList {
|
|
|
1487
1493
|
|
|
1488
1494
|
// Calculate virtual viewport size
|
|
1489
1495
|
if (p.virtualListHelper.isVirtual()) {
|
|
1496
|
+
// Avoid extremely high size which will cause laying out the whole list
|
|
1497
|
+
menuEl.style.height = Math.min(el.clientHeight, document.body.clientHeight) + 'px';
|
|
1490
1498
|
p.virtualListHelper.render();
|
|
1491
1499
|
}
|
|
1492
1500
|
|
|
@@ -1731,6 +1739,8 @@ class DropList {
|
|
|
1731
1739
|
setCheckedValues(values) {
|
|
1732
1740
|
const p = this._p;
|
|
1733
1741
|
|
|
1742
|
+
this.rushRefilter();
|
|
1743
|
+
|
|
1734
1744
|
let groupIndexes = [];
|
|
1735
1745
|
|
|
1736
1746
|
for (let i = 0, count = p.items.length; i < count; i++) {
|
|
@@ -1794,7 +1804,7 @@ class DropList {
|
|
|
1794
1804
|
|
|
1795
1805
|
excludeGroups = excludeGroups && p.groupCount > 0;
|
|
1796
1806
|
|
|
1797
|
-
|
|
1807
|
+
const items = [];
|
|
1798
1808
|
|
|
1799
1809
|
for (let i = 0, count = p.items.length; i < count; i++) {
|
|
1800
1810
|
let item = p.items[i];
|
|
@@ -1835,9 +1845,7 @@ class DropList {
|
|
|
1835
1845
|
}
|
|
1836
1846
|
});
|
|
1837
1847
|
|
|
1838
|
-
|
|
1839
|
-
this._refilterItems();
|
|
1840
|
-
}
|
|
1848
|
+
this.rushRefilter();
|
|
1841
1849
|
|
|
1842
1850
|
const el = p.el;
|
|
1843
1851
|
el.style.position = 'absolute';
|
|
@@ -2045,6 +2053,8 @@ class DropList {
|
|
|
2045
2053
|
setFocusedItemAtIndex(itemIndex) {
|
|
2046
2054
|
const p = this._p;
|
|
2047
2055
|
|
|
2056
|
+
this.rushRefilter();
|
|
2057
|
+
|
|
2048
2058
|
if (p.filteredItems) {
|
|
2049
2059
|
const item = p.items[itemIndex];
|
|
2050
2060
|
itemIndex = p.items.indexOf(item);
|
|
@@ -2242,6 +2252,8 @@ class DropList {
|
|
|
2242
2252
|
setSingleSelectedItemAtIndex(itemIndex) {
|
|
2243
2253
|
const p = this._p;
|
|
2244
2254
|
|
|
2255
|
+
this.rushRefilter();
|
|
2256
|
+
|
|
2245
2257
|
let itemEl = null;
|
|
2246
2258
|
|
|
2247
2259
|
if (itemIndex > -1 && !p.items[itemIndex]._nointeraction) {
|
|
@@ -3001,7 +3013,7 @@ class DropList {
|
|
|
3001
3013
|
let affectedItems = 0;
|
|
3002
3014
|
|
|
3003
3015
|
if (p.autoCheckGroupChildren) {
|
|
3004
|
-
|
|
3016
|
+
const items = p.filteredItems ?? p.items;
|
|
3005
3017
|
let groupIndex = items.indexOf(item);
|
|
3006
3018
|
|
|
3007
3019
|
for (let i = groupIndex + 1, len = items.length; i < len; i++) {
|
|
@@ -3044,7 +3056,7 @@ class DropList {
|
|
|
3044
3056
|
affectedItems: affectedItems
|
|
3045
3057
|
});
|
|
3046
3058
|
} else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
|
|
3047
|
-
|
|
3059
|
+
const items = p.filteredItems ?? p.items;
|
|
3048
3060
|
let itemIndex = items.indexOf(item);
|
|
3049
3061
|
let groupIndex = -1;
|
|
3050
3062
|
|
|
@@ -3070,7 +3082,7 @@ class DropList {
|
|
|
3070
3082
|
if (!(p.multi && p.autoCheckGroupChildren && groupIndex > -1))
|
|
3071
3083
|
return this;
|
|
3072
3084
|
|
|
3073
|
-
|
|
3085
|
+
const items = p.filteredItems ?? p.items;
|
|
3074
3086
|
let groupItem = items[groupIndex];
|
|
3075
3087
|
|
|
3076
3088
|
if (!groupItem || !groupItem._group) return this;
|
|
@@ -3196,7 +3208,7 @@ class DropList {
|
|
|
3196
3208
|
_determineVirtualMode(targetItemCount) {
|
|
3197
3209
|
const p = this._p;
|
|
3198
3210
|
|
|
3199
|
-
|
|
3211
|
+
const items = p.filteredItems ?? p.items;
|
|
3200
3212
|
if (targetItemCount === undefined) {
|
|
3201
3213
|
targetItemCount = items.length;
|
|
3202
3214
|
}
|
|
@@ -3644,7 +3656,6 @@ class SelectBox {
|
|
|
3644
3656
|
p.resizeObserver.observe(p.el);
|
|
3645
3657
|
}
|
|
3646
3658
|
|
|
3647
|
-
if (o.filterFn)
|
|
3648
3659
|
this.setFilterFn(o.filterFn);
|
|
3649
3660
|
|
|
3650
3661
|
this.setItems(o.items);
|
|
@@ -4438,6 +4449,10 @@ class SelectBox {
|
|
|
4438
4449
|
const p = this._p;
|
|
4439
4450
|
if (p.filterFn === fn)
|
|
4440
4451
|
return this;
|
|
4452
|
+
|
|
4453
|
+
// Do not keep this reference, as far as the user is concerned - he/she did not set a custom filter.
|
|
4454
|
+
p.filterFn = fn;
|
|
4455
|
+
|
|
4441
4456
|
if (!fn) {
|
|
4442
4457
|
// Add search by multi-item label
|
|
4443
4458
|
fn = (items, term) => {
|
|
@@ -4451,7 +4466,6 @@ class SelectBox {
|
|
|
4451
4466
|
});
|
|
4452
4467
|
};
|
|
4453
4468
|
}
|
|
4454
|
-
p.filterFn = fn;
|
|
4455
4469
|
p.dropList?.setFilterFn(fn);
|
|
4456
4470
|
return this;
|
|
4457
4471
|
}
|
|
@@ -5570,6 +5584,7 @@ class SelectBox {
|
|
|
5570
5584
|
p.splitListCheckedGroups);
|
|
5571
5585
|
}
|
|
5572
5586
|
dropList.setItems(items);
|
|
5587
|
+
dropList.invokeRefilter();
|
|
5573
5588
|
p.itemsChanged = false;
|
|
5574
5589
|
p.selectionChanged = true;
|
|
5575
5590
|
p.resortBySelectionNeeded = false;
|