@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.umd.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
  (function (global, factory) {
@@ -678,7 +678,8 @@
678
678
  const p = this._p;
679
679
 
680
680
  if (this.hasFocusedItem() && p.multi) {
681
- let item = p.items[p.focusItemIndex];
681
+ const items = p.filteredItems ?? p.items;
682
+ let item = items[p.focusItemIndex];
682
683
  if (item._nocheck || item._nointeraction) return this;
683
684
 
684
685
  item._checked = !item._checked;
@@ -746,7 +747,7 @@
746
747
  const p = this._p,labelProp = p.labelProp,valueProp = p.valueProp;
747
748
 
748
749
  let isMulti = p.multi;
749
- let items = p.items;
750
+ const items = p.items;
750
751
 
751
752
  if (atIndex == null || atIndex < 0 || atIndex >= p.items.length) {
752
753
  atIndex = -1;
@@ -1256,7 +1257,7 @@
1256
1257
  p.filteredItems = null;
1257
1258
  }
1258
1259
 
1259
- this.needsRefilter = false;
1260
+ p.needsRefilter = false;
1260
1261
 
1261
1262
  const items = p.filteredItems ?? p.items;
1262
1263
  p.hasNoResultsItem = items.length === 0 && !!p.noResultsText;
@@ -1277,11 +1278,17 @@
1277
1278
  return this;
1278
1279
  }
1279
1280
 
1280
- getFilteredItemCount() {
1281
+ rushRefilter() {
1281
1282
  const p = this._p;
1282
-
1283
1283
  if (p.needsRefilter)
1284
1284
  this._refilterItems();
1285
+ return this;
1286
+ }
1287
+
1288
+ getFilteredItemCount() {
1289
+ const p = this._p;
1290
+
1291
+ this.rushRefilter();
1285
1292
 
1286
1293
  if (p.filteredItems)
1287
1294
  return p.filteredItems.length;
@@ -1727,6 +1734,8 @@
1727
1734
  setCheckedValues(values) {
1728
1735
  const p = this._p;
1729
1736
 
1737
+ this.rushRefilter();
1738
+
1730
1739
  let groupIndexes = [];
1731
1740
 
1732
1741
  for (let i = 0, count = p.items.length; i < count; i++) {
@@ -1790,7 +1799,7 @@
1790
1799
 
1791
1800
  excludeGroups = excludeGroups && p.groupCount > 0;
1792
1801
 
1793
- let items = [];
1802
+ const items = [];
1794
1803
 
1795
1804
  for (let i = 0, count = p.items.length; i < count; i++) {
1796
1805
  let item = p.items[i];
@@ -1831,9 +1840,7 @@
1831
1840
  }
1832
1841
  });
1833
1842
 
1834
- if (p.needsRefilter) {
1835
- this._refilterItems();
1836
- }
1843
+ this.rushRefilter();
1837
1844
 
1838
1845
  const el = p.el;
1839
1846
  el.style.position = 'absolute';
@@ -2041,6 +2048,8 @@
2041
2048
  setFocusedItemAtIndex(itemIndex) {
2042
2049
  const p = this._p;
2043
2050
 
2051
+ this.rushRefilter();
2052
+
2044
2053
  if (p.filteredItems) {
2045
2054
  const item = p.items[itemIndex];
2046
2055
  itemIndex = p.items.indexOf(item);
@@ -2238,6 +2247,8 @@
2238
2247
  setSingleSelectedItemAtIndex(itemIndex) {
2239
2248
  const p = this._p;
2240
2249
 
2250
+ this.rushRefilter();
2251
+
2241
2252
  let itemEl = null;
2242
2253
 
2243
2254
  if (itemIndex > -1 && !p.items[itemIndex]._nointeraction) {
@@ -2997,7 +3008,7 @@
2997
3008
  let affectedItems = 0;
2998
3009
 
2999
3010
  if (p.autoCheckGroupChildren) {
3000
- let items = p.filteredItems ?? p.items;
3011
+ const items = p.filteredItems ?? p.items;
3001
3012
  let groupIndex = items.indexOf(item);
3002
3013
 
3003
3014
  for (let i = groupIndex + 1, len = items.length; i < len; i++) {
@@ -3040,7 +3051,7 @@
3040
3051
  affectedItems: affectedItems
3041
3052
  });
3042
3053
  } else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
3043
- let items = p.filteredItems ?? p.items;
3054
+ const items = p.filteredItems ?? p.items;
3044
3055
  let itemIndex = items.indexOf(item);
3045
3056
  let groupIndex = -1;
3046
3057
 
@@ -3066,7 +3077,7 @@
3066
3077
  if (!(p.multi && p.autoCheckGroupChildren && groupIndex > -1))
3067
3078
  return this;
3068
3079
 
3069
- let items = p.filteredItems ?? p.items;
3080
+ const items = p.filteredItems ?? p.items;
3070
3081
  let groupItem = items[groupIndex];
3071
3082
 
3072
3083
  if (!groupItem || !groupItem._group) return this;
@@ -3192,7 +3203,7 @@
3192
3203
  _determineVirtualMode(targetItemCount) {
3193
3204
  const p = this._p;
3194
3205
 
3195
- let items = p.filteredItems ?? p.items;
3206
+ const items = p.filteredItems ?? p.items;
3196
3207
  if (targetItemCount === undefined) {
3197
3208
  targetItemCount = items.length;
3198
3209
  }
@@ -5566,6 +5577,7 @@
5566
5577
  p.splitListCheckedGroups);
5567
5578
  }
5568
5579
  dropList.setItems(items);
5580
+ dropList.invokeRefilter();
5569
5581
  p.itemsChanged = false;
5570
5582
  p.selectionChanged = true;
5571
5583
  p.resortBySelectionNeeded = false;