@syncfusion/ej2-dropdowns 34.1.29 → 34.1.30

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.
@@ -310,6 +310,7 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod
310
310
  var VirtualScroll = /** @__PURE__ @class */ (function () {
311
311
  function VirtualScroll(parent) {
312
312
  var _this = this;
313
+ this.previousScrollTop = 0;
313
314
  this.sentinelInfo = {
314
315
  'up': {
315
316
  check: function (rect, info) {
@@ -370,9 +371,14 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
370
371
  VirtualScroll.prototype.getModuleName = function () {
371
372
  return 'VirtualScroll';
372
373
  };
374
+ VirtualScroll.prototype.isFilterScrollScenario = function () {
375
+ return this.component === 'dropdownlist' && this.parent.allowFiltering;
376
+ };
373
377
  VirtualScroll.prototype.popupScrollHandler = function () {
374
378
  this.parent.isMouseScrollAction = true;
375
- this.parent.isPreventScrollAction = false;
379
+ if (!(this.isFilterScrollScenario() && this.parent.isVirtualScrolling)) {
380
+ this.parent.isPreventScrollAction = false;
381
+ }
376
382
  };
377
383
  VirtualScroll.prototype.getPageQuery = function (query, virtualStartIndex, virtualEndIndex) {
378
384
  if (virtualEndIndex !== 0 && !this.parent.allowFiltering && this.component !== 'autocomplete') {
@@ -742,7 +748,8 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
742
748
  };
743
749
  VirtualScroll.prototype.scrollListener = function (scrollArgs) {
744
750
  var _this = this;
745
- if (!this.parent.isPreventScrollAction && !this.parent.isVirtualTrackHeight) {
751
+ var preventReentrant = this.isFilterScrollScenario() && this.parent.isVirtualScrolling;
752
+ if (!this.parent.isPreventScrollAction && !this.parent.isVirtualTrackHeight && !preventReentrant) {
746
753
  this.parent.preventSetCurrentData = false;
747
754
  var info = scrollArgs.sentinel;
748
755
  var pStartIndex = this.parent.previousStartIndex;
@@ -754,6 +761,8 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
754
761
  this.parent.virtualListInfo = __assign({}, this.parent.viewPortInfo);
755
762
  this.parent.isPreventKeyAction = true;
756
763
  this.parent.isVirtualScrolling = true;
764
+ var savedScrollTop_1 = this.parent.popupContentElement ?
765
+ this.parent.popupContentElement.scrollTop : 0;
757
766
  setTimeout(function () {
758
767
  _this.parent.pageCount = _this.parent.getPageCount();
759
768
  _this.parent.isRequesting = false;
@@ -763,9 +772,16 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
763
772
  _this.parent.updateSelectionList();
764
773
  _this.parent.liCollections = _this.parent.getItems();
765
774
  }
775
+ if (_this.isFilterScrollScenario()) {
776
+ var scrollContainer = _this.parent.popupContentElement || _this.parent.list;
777
+ if (scrollContainer && scrollContainer.scrollTop < savedScrollTop_1) {
778
+ scrollContainer.scrollTop = savedScrollTop_1;
779
+ }
780
+ _this.previousScrollTop = scrollContainer ? scrollContainer.scrollTop : savedScrollTop_1;
781
+ }
766
782
  _this.parent.isKeyBoardAction = false;
767
- _this.parent.isVirtualScrolling = false;
768
783
  _this.parent.isPreventKeyAction = false;
784
+ _this.parent.isVirtualScrolling = false;
769
785
  });
770
786
  }, 5);
771
787
  }
@@ -839,14 +855,17 @@ var VirtualScroll = /** @__PURE__ @class */ (function () {
839
855
  VirtualScroll.prototype.virtualScrollHandler = function (callback) {
840
856
  var _this = this;
841
857
  var delay = Browser.info.name === 'chrome' ? 200 : 100;
842
- var prevTop = 0;
843
858
  var debounced100 = debounce(callback, delay);
844
859
  var debounced50 = debounce(callback, 50);
845
860
  return function (e) {
846
861
  var top = e.target.scrollTop;
847
862
  var left = e.target.scrollLeft;
848
- var direction = prevTop < top && !_this.parent.isUpwardScrolling ? 'down' : 'up';
849
- prevTop = top;
863
+ if (_this.isFilterScrollScenario() && (_this.parent.isVirtualScrolling || _this.parent.isPreventScrollAction)) {
864
+ _this.previousScrollTop = top;
865
+ return;
866
+ }
867
+ var direction = _this.previousScrollTop < top && !_this.parent.isUpwardScrolling ? 'down' : 'up';
868
+ _this.previousScrollTop = top;
850
869
  var current = _this.sentinelInfo[direction];
851
870
  var pstartIndex = _this.parent.scrollPreStartIndex;
852
871
  var scrollOffsetargs = {
@@ -4836,7 +4855,7 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
4836
4855
  }
4837
4856
  };
4838
4857
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
4839
- DropDownList.prototype.setValue = function (e) {
4858
+ DropDownList.prototype.setValue = function (e, autofill) {
4840
4859
  var dataItem = this.getItemData();
4841
4860
  this.isTouched = !isNullOrUndefined(e);
4842
4861
  if (dataItem.value === null) {
@@ -4868,7 +4887,7 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
4868
4887
  (this.previousValue != null && this.isObjectInArray(this.previousValue, [this.allowCustom &&
4869
4888
  this.isObjectCustomValue ? this.value ? this.value : dataItem : dataItem.value ?
4870
4889
  this.getDataByValue(dataItem.value) : dataItem])))) {
4871
- if (this.getModuleName() === 'combobox' && this.autoFill && e && (e.type === 'click' || e.action === 'enter')) {
4890
+ if (this.getModuleName() === 'combobox' && autofill && e && (e.type === 'click' || e.action === 'enter')) {
4872
4891
  return false;
4873
4892
  }
4874
4893
  this.isSelected = false;
@@ -12235,7 +12254,7 @@ var ComboBox = /** @__PURE__ @class */ (function (_super) {
12235
12254
  return false;
12236
12255
  }
12237
12256
  else {
12238
- return _super.prototype.setValue.call(this, e);
12257
+ return _super.prototype.setValue.call(this, e, this.autofill);
12239
12258
  }
12240
12259
  };
12241
12260
  ComboBox.prototype.checkCustomValue = function () {
@@ -14128,49 +14147,154 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
14128
14147
  MultiSelect.prototype.getForQuery = function (valuecheck, isCheckbox) {
14129
14148
  var predicate;
14130
14149
  var field = this.isPrimitiveData ? '' : this.fields.value;
14131
- if (this.enableVirtualization && valuecheck) {
14132
- if (isCheckbox) {
14133
- var startindex = this.viewPortInfo.startIndex;
14134
- var endindex = (((startindex + this.viewPortInfo.endIndex) <= (valuecheck.length)) &&
14135
- valuecheck[(startindex + this.viewPortInfo.endIndex)]) &&
14136
- (this.dataSource instanceof DataManager && this.totalItemCount !== 0 && this.totalItemCount > (this.itemCount * 2))
14137
- ? (startindex + this.viewPortInfo.endIndex)
14138
- : (valuecheck.length);
14139
- for (var i = startindex; i < endindex; i++) {
14140
- var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14141
- this.fields.value : '', valuecheck[i]) : valuecheck[i];
14142
- if (i === startindex) {
14143
- predicate = new Predicate(field, 'equal', (value));
14150
+ if (valuecheck && valuecheck.length >= 3000) {
14151
+ // Batch size to prevent stack overflow with large preselected values (EJ2-Fix-MaxCallStack)
14152
+ var BATCH_SIZE = 100;
14153
+ if (this.enableVirtualization) {
14154
+ if (isCheckbox) {
14155
+ var startindex = this.viewPortInfo.startIndex;
14156
+ var endindex = (((startindex + this.viewPortInfo.endIndex) <= (valuecheck.length)) &&
14157
+ valuecheck[(startindex + this.viewPortInfo.endIndex)]) &&
14158
+ (this.dataSource instanceof DataManager && this.totalItemCount !== 0 && this.totalItemCount > (this.itemCount * 2))
14159
+ ? (startindex + this.viewPortInfo.endIndex)
14160
+ : (valuecheck.length);
14161
+ // Build predicates in batches to prevent stack overflow
14162
+ var predicateBatches = [];
14163
+ for (var batchStart = startindex; batchStart < endindex; batchStart += BATCH_SIZE) {
14164
+ var batchPredicate = void 0;
14165
+ var batchEnd = Math.min(batchStart + BATCH_SIZE, endindex);
14166
+ for (var i = batchStart; i < batchEnd; i++) {
14167
+ var itemAtIndex = valuecheck[i];
14168
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14169
+ this.fields.value : '', itemAtIndex) : itemAtIndex;
14170
+ if (i === batchStart) {
14171
+ batchPredicate = new Predicate(field, 'equal', (value));
14172
+ }
14173
+ else {
14174
+ batchPredicate = batchPredicate.or(field, 'equal', (value));
14175
+ }
14176
+ }
14177
+ predicateBatches.push(batchPredicate);
14144
14178
  }
14145
- else {
14146
- predicate = predicate.or(field, 'equal', (value));
14179
+ // Combine all batch predicates
14180
+ predicate = predicateBatches[0];
14181
+ for (var i = 1; i < predicateBatches.length; i++) {
14182
+ predicate = predicate.or(predicateBatches[i]);
14183
+ }
14184
+ return new Query().where(predicate);
14185
+ }
14186
+ else {
14187
+ // Build predicates in batches to prevent stack overflow
14188
+ var predicateBatches = [];
14189
+ var isAddNonPresentItems = this.isaddNonPresentItems;
14190
+ for (var batchStart = 0; batchStart < valuecheck.length; batchStart += BATCH_SIZE) {
14191
+ var batchPredicate = void 0;
14192
+ var batchEnd = Math.min(batchStart + BATCH_SIZE, valuecheck.length);
14193
+ for (var i = batchStart; i < batchEnd; i++) {
14194
+ var itemAtIndex = valuecheck[i];
14195
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14196
+ this.fields.value : '', itemAtIndex) : itemAtIndex;
14197
+ if (i === batchStart) {
14198
+ if (isAddNonPresentItems) {
14199
+ batchPredicate = new Predicate(field, 'equal', itemAtIndex);
14200
+ }
14201
+ else {
14202
+ batchPredicate = new Predicate(field, 'notequal', (value));
14203
+ }
14204
+ }
14205
+ else {
14206
+ if (isAddNonPresentItems) {
14207
+ batchPredicate = batchPredicate.or(field, 'equal', itemAtIndex);
14208
+ }
14209
+ else {
14210
+ batchPredicate = batchPredicate.and(field, 'notequal', (value));
14211
+ }
14212
+ }
14213
+ }
14214
+ predicateBatches.push(batchPredicate);
14215
+ }
14216
+ // Combine batch predicates
14217
+ predicate = predicateBatches[0];
14218
+ for (var i = 1; i < predicateBatches.length; i++) {
14219
+ if (isAddNonPresentItems) {
14220
+ predicate = predicate.or(predicateBatches[i]);
14221
+ }
14222
+ else {
14223
+ predicate = predicate.and(predicateBatches[i]);
14224
+ }
14147
14225
  }
14226
+ return new Query().where(predicate);
14148
14227
  }
14149
- return new Query().where(predicate);
14150
14228
  }
14151
14229
  else {
14152
- for (var i = 0; i < valuecheck.length; i++) {
14153
- var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14154
- this.fields.value : '', valuecheck[i]) : valuecheck[i];
14155
- if (this.isaddNonPresentItems) {
14156
- predicate = i === 0 ? new Predicate(field, 'equal', valuecheck[i])
14157
- : predicate.or(field, 'equal', valuecheck[i]);
14158
- }
14159
- else {
14160
- predicate = i === 0 ? predicate = new Predicate(field, 'notequal', (value))
14161
- : predicate.and(field, 'notequal', (value));
14230
+ // Build predicates in batches to prevent stack overflow with large preselected values
14231
+ var predicateBatches = [];
14232
+ for (var batchStart = 0; batchStart < valuecheck.length; batchStart += BATCH_SIZE) {
14233
+ var batchPredicate = void 0;
14234
+ var batchEnd = Math.min(batchStart + BATCH_SIZE, valuecheck.length);
14235
+ for (var i = batchStart; i < batchEnd; i++) {
14236
+ var itemAtIndex = valuecheck[i];
14237
+ if (i === batchStart) {
14238
+ batchPredicate = new Predicate(field, 'equal', itemAtIndex);
14239
+ }
14240
+ else {
14241
+ batchPredicate = batchPredicate.or(field, 'equal', itemAtIndex);
14242
+ }
14162
14243
  }
14244
+ predicateBatches.push(batchPredicate);
14245
+ }
14246
+ // Combine all batch predicates
14247
+ predicate = predicateBatches[0];
14248
+ for (var i = 1; i < predicateBatches.length; i++) {
14249
+ predicate = predicate.or(predicateBatches[i]);
14163
14250
  }
14164
- return new Query().where(predicate);
14165
14251
  }
14166
14252
  }
14167
14253
  else {
14168
- for (var i = 0; i < valuecheck.length; i++) {
14169
- if (i === 0) {
14170
- predicate = new Predicate(field, 'equal', valuecheck[i]);
14254
+ if (this.enableVirtualization && valuecheck) {
14255
+ if (isCheckbox) {
14256
+ var startindex = this.viewPortInfo.startIndex;
14257
+ var endindex = (((startindex + this.viewPortInfo.endIndex) <= (valuecheck.length)) &&
14258
+ valuecheck[(startindex + this.viewPortInfo.endIndex)]) &&
14259
+ (this.dataSource instanceof DataManager && this.totalItemCount !== 0 && this.totalItemCount > (this.itemCount * 2))
14260
+ ? (startindex + this.viewPortInfo.endIndex)
14261
+ : (valuecheck.length);
14262
+ for (var i = startindex; i < endindex; i++) {
14263
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14264
+ this.fields.value : '', valuecheck[i]) : valuecheck[i];
14265
+ if (i === startindex) {
14266
+ predicate = new Predicate(field, 'equal', (value));
14267
+ }
14268
+ else {
14269
+ predicate = predicate.or(field, 'equal', (value));
14270
+ }
14271
+ }
14272
+ return new Query().where(predicate);
14171
14273
  }
14172
14274
  else {
14173
- predicate = predicate.or(field, 'equal', valuecheck[i]);
14275
+ for (var i = 0; i < valuecheck.length; i++) {
14276
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14277
+ this.fields.value : '', valuecheck[i]) : valuecheck[i];
14278
+ if (this.isaddNonPresentItems) {
14279
+ predicate = i === 0 ? new Predicate(field, 'equal', valuecheck[i])
14280
+ : predicate.or(field, 'equal', valuecheck[i]);
14281
+ }
14282
+ else {
14283
+ predicate = i === 0 ? predicate = new Predicate(field, 'notequal', (value))
14284
+ : predicate.and(field, 'notequal', (value));
14285
+ }
14286
+ }
14287
+ return new Query().where(predicate);
14288
+ }
14289
+ }
14290
+ else {
14291
+ for (var i = 0; i < valuecheck.length; i++) {
14292
+ if (i === 0) {
14293
+ predicate = new Predicate(field, 'equal', valuecheck[i]);
14294
+ }
14295
+ else {
14296
+ predicate = predicate.or(field, 'equal', valuecheck[i]);
14297
+ }
14174
14298
  }
14175
14299
  }
14176
14300
  }
@@ -16441,6 +16565,9 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16441
16565
  }
16442
16566
  }
16443
16567
  };
16568
+ MultiSelect.prototype.isFilteringWithRemoteData = function () {
16569
+ return !isNullOrUndefined(this.mainData) && this.mainData.length > 0 && this.allowFiltering;
16570
+ };
16444
16571
  MultiSelect.prototype.removeChip = function (value, isClearAll) {
16445
16572
  if (this.chipCollectionWrapper) {
16446
16573
  if (!(this.enableVirtualization && isClearAll)) {
@@ -17655,6 +17782,9 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17655
17782
  getValue(((this.fields.value) ? this.fields.value : ''), this.value[index]) :
17656
17783
  this.value[index];
17657
17784
  element = this.findListElement(this.hideSelectedItem ? this.ulElement : this.list, 'li', 'data-value', value_2);
17785
+ if (!element && !isNullOrUndefined(this.mainList) && this.isFilteringWithRemoteData()) {
17786
+ element = this.findListElement(this.mainList, 'li', 'data-value', value_2);
17787
+ }
17658
17788
  var isCustomData = false;
17659
17789
  if (this.enableVirtualization) {
17660
17790
  text = null;
@@ -17701,6 +17831,12 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17701
17831
  }
17702
17832
  else {
17703
17833
  text = this.getTextByValue(value_2);
17834
+ if (text === value_2 && this.isFilteringWithRemoteData()) {
17835
+ var savedListData = this.listData;
17836
+ this.listData = this.mainData;
17837
+ text = this.getTextByValue(value_2);
17838
+ this.listData = savedListData;
17839
+ }
17704
17840
  }
17705
17841
  if (((element && (element.getAttribute('aria-selected') !== 'true')) ||
17706
17842
  (element && (element.getAttribute('aria-selected') === 'true' && this.hideSelectedItem) &&
@@ -19983,6 +20119,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
19983
20119
  this.chipCollectionWrapper = this.createElement('span', {
19984
20120
  className: CHIP_WRAPPER$1
19985
20121
  });
20122
+ this.chipCollectionWrapper.setAttribute('role', 'listbox');
20123
+ this.chipCollectionWrapper.setAttribute('aria-label', 'multiselect');
19986
20124
  this.chipCollectionWrapper.style.display = 'none';
19987
20125
  if (this.mode === 'Default') {
19988
20126
  this.chipCollectionWrapper.setAttribute('id', getUniqueID('chip_default'));