@danielgindi/selectbox 2.0.2 → 2.0.4

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.es6.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 2.0.2
2
+ * @danielgindi/selectbox 2.0.4
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
@@ -680,7 +680,8 @@ class DropList {
680
680
  const p = this._p;
681
681
 
682
682
  if (this.hasFocusedItem() && p.multi) {
683
- let item = p.items[p.focusItemIndex];
683
+ const items = p.filteredItems ?? p.items;
684
+ let item = items[p.focusItemIndex];
684
685
  if (item._nocheck || item._nointeraction) return this;
685
686
 
686
687
  item._checked = !item._checked;
@@ -748,7 +749,7 @@ class DropList {
748
749
  const p = this._p, labelProp = p.labelProp, valueProp = p.valueProp;
749
750
 
750
751
  let isMulti = p.multi;
751
- let items = p.items;
752
+ const items = p.items;
752
753
 
753
754
  if (atIndex == null || atIndex < 0 || atIndex >= p.items.length) {
754
755
  atIndex = -1;
@@ -1258,7 +1259,7 @@ class DropList {
1258
1259
  p.filteredItems = null;
1259
1260
  }
1260
1261
 
1261
- this.needsRefilter = false;
1262
+ p.needsRefilter = false;
1262
1263
 
1263
1264
  const items = p.filteredItems ?? p.items;
1264
1265
  p.hasNoResultsItem = items.length === 0 && !!p.noResultsText;
@@ -1279,11 +1280,17 @@ class DropList {
1279
1280
  return this;
1280
1281
  }
1281
1282
 
1282
- getFilteredItemCount() {
1283
+ rushRefilter() {
1283
1284
  const p = this._p;
1284
-
1285
1285
  if (p.needsRefilter)
1286
1286
  this._refilterItems();
1287
+ return this;
1288
+ }
1289
+
1290
+ getFilteredItemCount() {
1291
+ const p = this._p;
1292
+
1293
+ this.rushRefilter();
1287
1294
 
1288
1295
  if (p.filteredItems)
1289
1296
  return p.filteredItems.length;
@@ -1729,6 +1736,8 @@ class DropList {
1729
1736
  setCheckedValues(values) {
1730
1737
  const p = this._p;
1731
1738
 
1739
+ this.rushRefilter();
1740
+
1732
1741
  let groupIndexes = [];
1733
1742
 
1734
1743
  for (let i = 0, count = p.items.length; i < count; i++) {
@@ -1792,7 +1801,7 @@ class DropList {
1792
1801
 
1793
1802
  excludeGroups = excludeGroups && p.groupCount > 0;
1794
1803
 
1795
- let items = [];
1804
+ const items = [];
1796
1805
 
1797
1806
  for (let i = 0, count = p.items.length; i < count; i++) {
1798
1807
  let item = p.items[i];
@@ -1833,9 +1842,7 @@ class DropList {
1833
1842
  }
1834
1843
  });
1835
1844
 
1836
- if (p.needsRefilter) {
1837
- this._refilterItems();
1838
- }
1845
+ this.rushRefilter();
1839
1846
 
1840
1847
  const el = p.el;
1841
1848
  el.style.position = 'absolute';
@@ -2043,6 +2050,8 @@ class DropList {
2043
2050
  setFocusedItemAtIndex(itemIndex) {
2044
2051
  const p = this._p;
2045
2052
 
2053
+ this.rushRefilter();
2054
+
2046
2055
  if (p.filteredItems) {
2047
2056
  const item = p.items[itemIndex];
2048
2057
  itemIndex = p.items.indexOf(item);
@@ -2240,6 +2249,8 @@ class DropList {
2240
2249
  setSingleSelectedItemAtIndex(itemIndex) {
2241
2250
  const p = this._p;
2242
2251
 
2252
+ this.rushRefilter();
2253
+
2243
2254
  let itemEl = null;
2244
2255
 
2245
2256
  if (itemIndex > -1 && !p.items[itemIndex]._nointeraction) {
@@ -2999,7 +3010,7 @@ class DropList {
2999
3010
  let affectedItems = 0;
3000
3011
 
3001
3012
  if (p.autoCheckGroupChildren) {
3002
- let items = p.filteredItems ?? p.items;
3013
+ const items = p.filteredItems ?? p.items;
3003
3014
  let groupIndex = items.indexOf(item);
3004
3015
 
3005
3016
  for (let i = groupIndex + 1, len = items.length; i < len; i++) {
@@ -3042,7 +3053,7 @@ class DropList {
3042
3053
  affectedItems: affectedItems,
3043
3054
  });
3044
3055
  } else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
3045
- let items = p.filteredItems ?? p.items;
3056
+ const items = p.filteredItems ?? p.items;
3046
3057
  let itemIndex = items.indexOf(item);
3047
3058
  let groupIndex = -1;
3048
3059
 
@@ -3068,7 +3079,7 @@ class DropList {
3068
3079
  if (!(p.multi && p.autoCheckGroupChildren && groupIndex > -1))
3069
3080
  return this;
3070
3081
 
3071
- let items = p.filteredItems ?? p.items;
3082
+ const items = p.filteredItems ?? p.items;
3072
3083
  let groupItem = items[groupIndex];
3073
3084
 
3074
3085
  if (!groupItem || !groupItem._group) return this;
@@ -3194,7 +3205,7 @@ class DropList {
3194
3205
  _determineVirtualMode(targetItemCount) {
3195
3206
  const p = this._p;
3196
3207
 
3197
- let items = p.filteredItems ?? p.items;
3208
+ const items = p.filteredItems ?? p.items;
3198
3209
  if (targetItemCount === undefined) {
3199
3210
  targetItemCount = items.length;
3200
3211
  }
@@ -5568,6 +5579,7 @@ class SelectBox {
5568
5579
  p.splitListCheckedGroups);
5569
5580
  }
5570
5581
  dropList.setItems(items);
5582
+ dropList.invokeRefilter();
5571
5583
  p.itemsChanged = false;
5572
5584
  p.selectionChanged = true;
5573
5585
  p.resortBySelectionNeeded = false;