@syncfusion/ej2-dropdowns 34.1.29 → 34.1.32

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 = {
@@ -3363,6 +3382,7 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
3363
3382
  this.initialRemoteRender = false;
3364
3383
  this.isNotSearchList = false;
3365
3384
  this.isTyped = false;
3385
+ this.isProgrammaticValueUpdate = false;
3366
3386
  this.isSelected = false;
3367
3387
  this.preventFocus = false;
3368
3388
  this.preventAutoFill = false;
@@ -4836,7 +4856,7 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
4836
4856
  }
4837
4857
  };
4838
4858
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
4839
- DropDownList.prototype.setValue = function (e) {
4859
+ DropDownList.prototype.setValue = function (e, autofill) {
4840
4860
  var dataItem = this.getItemData();
4841
4861
  this.isTouched = !isNullOrUndefined(e);
4842
4862
  if (dataItem.value === null) {
@@ -4868,7 +4888,7 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
4868
4888
  (this.previousValue != null && this.isObjectInArray(this.previousValue, [this.allowCustom &&
4869
4889
  this.isObjectCustomValue ? this.value ? this.value : dataItem : dataItem.value ?
4870
4890
  this.getDataByValue(dataItem.value) : dataItem])))) {
4871
- if (this.getModuleName() === 'combobox' && this.autoFill && e && (e.type === 'click' || e.action === 'enter')) {
4891
+ if (this.getModuleName() === 'combobox' && autofill && e && (e.type === 'click' || e.action === 'enter')) {
4872
4892
  return false;
4873
4893
  }
4874
4894
  this.isSelected = false;
@@ -5659,6 +5679,9 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
5659
5679
  }
5660
5680
  this.initial = false;
5661
5681
  }
5682
+ if (this.isProgrammaticValueUpdate && !isNullOrUndefined(this.value) && this.getModuleName() === 'combobox') {
5683
+ this.detachChangeEvent(null);
5684
+ }
5662
5685
  else if (this.getModuleName() === 'autocomplete' && this.value) {
5663
5686
  this.setInputValue();
5664
5687
  }
@@ -5765,10 +5788,13 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
5765
5788
  var _this = this;
5766
5789
  if (isOffline === void 0) { isOffline = false; }
5767
5790
  var fieldValue = this.fields.value.split('.');
5768
- var checkVal = list.some(function (x) {
5769
- return isNullOrUndefined(x[checkField]) && fieldValue.length > 1 ?
5770
- _this.checkFieldValue(x, fieldValue) === value : x[checkField] === value;
5771
- });
5791
+ var checkVal = false;
5792
+ if (!isNullOrUndefined(list) && list.length > 0) {
5793
+ checkVal = list.some(function (x) {
5794
+ return isNullOrUndefined(x[checkField]) && fieldValue.length > 1 ?
5795
+ _this.checkFieldValue(x, fieldValue) === value : x[checkField] === value;
5796
+ });
5797
+ }
5772
5798
  if (this.enableVirtualization && this.virtualGroupDataSource) {
5773
5799
  checkVal = this.virtualGroupDataSource.some(function (x) {
5774
5800
  return isNullOrUndefined(x[checkField]) && fieldValue.length > 1 ?
@@ -7305,6 +7331,9 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
7305
7331
  this_1.isObjectInArray(newProp.value, [oldProp.value])) {
7306
7332
  return { value: void 0 };
7307
7333
  }
7334
+ if (!this_1.initial && this_1.dataSource instanceof DataManager) {
7335
+ this_1.isProgrammaticValueUpdate = true;
7336
+ }
7308
7337
  if (this_1.enableVirtualization) {
7309
7338
  var isOfflineMode = this_1.dataSource instanceof DataManager &&
7310
7339
  this_1.dataSource.dataSource.offline === true;
@@ -12235,7 +12264,7 @@ var ComboBox = /** @__PURE__ @class */ (function (_super) {
12235
12264
  return false;
12236
12265
  }
12237
12266
  else {
12238
- return _super.prototype.setValue.call(this, e);
12267
+ return _super.prototype.setValue.call(this, e, this.autofill);
12239
12268
  }
12240
12269
  };
12241
12270
  ComboBox.prototype.checkCustomValue = function () {
@@ -14128,49 +14157,154 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
14128
14157
  MultiSelect.prototype.getForQuery = function (valuecheck, isCheckbox) {
14129
14158
  var predicate;
14130
14159
  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));
14160
+ if (valuecheck && valuecheck.length >= 3000) {
14161
+ // Batch size to prevent stack overflow with large preselected values (EJ2-Fix-MaxCallStack)
14162
+ var BATCH_SIZE = 100;
14163
+ if (this.enableVirtualization) {
14164
+ if (isCheckbox) {
14165
+ var startindex = this.viewPortInfo.startIndex;
14166
+ var endindex = (((startindex + this.viewPortInfo.endIndex) <= (valuecheck.length)) &&
14167
+ valuecheck[(startindex + this.viewPortInfo.endIndex)]) &&
14168
+ (this.dataSource instanceof DataManager && this.totalItemCount !== 0 && this.totalItemCount > (this.itemCount * 2))
14169
+ ? (startindex + this.viewPortInfo.endIndex)
14170
+ : (valuecheck.length);
14171
+ // Build predicates in batches to prevent stack overflow
14172
+ var predicateBatches = [];
14173
+ for (var batchStart = startindex; batchStart < endindex; batchStart += BATCH_SIZE) {
14174
+ var batchPredicate = void 0;
14175
+ var batchEnd = Math.min(batchStart + BATCH_SIZE, endindex);
14176
+ for (var i = batchStart; i < batchEnd; i++) {
14177
+ var itemAtIndex = valuecheck[i];
14178
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14179
+ this.fields.value : '', itemAtIndex) : itemAtIndex;
14180
+ if (i === batchStart) {
14181
+ batchPredicate = new Predicate(field, 'equal', (value));
14182
+ }
14183
+ else {
14184
+ batchPredicate = batchPredicate.or(field, 'equal', (value));
14185
+ }
14186
+ }
14187
+ predicateBatches.push(batchPredicate);
14144
14188
  }
14145
- else {
14146
- predicate = predicate.or(field, 'equal', (value));
14189
+ // Combine all batch predicates
14190
+ predicate = predicateBatches[0];
14191
+ for (var i = 1; i < predicateBatches.length; i++) {
14192
+ predicate = predicate.or(predicateBatches[i]);
14147
14193
  }
14194
+ return new Query().where(predicate);
14195
+ }
14196
+ else {
14197
+ // Build predicates in batches to prevent stack overflow
14198
+ var predicateBatches = [];
14199
+ var isAddNonPresentItems = this.isaddNonPresentItems;
14200
+ for (var batchStart = 0; batchStart < valuecheck.length; batchStart += BATCH_SIZE) {
14201
+ var batchPredicate = void 0;
14202
+ var batchEnd = Math.min(batchStart + BATCH_SIZE, valuecheck.length);
14203
+ for (var i = batchStart; i < batchEnd; i++) {
14204
+ var itemAtIndex = valuecheck[i];
14205
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14206
+ this.fields.value : '', itemAtIndex) : itemAtIndex;
14207
+ if (i === batchStart) {
14208
+ if (isAddNonPresentItems) {
14209
+ batchPredicate = new Predicate(field, 'equal', itemAtIndex);
14210
+ }
14211
+ else {
14212
+ batchPredicate = new Predicate(field, 'notequal', (value));
14213
+ }
14214
+ }
14215
+ else {
14216
+ if (isAddNonPresentItems) {
14217
+ batchPredicate = batchPredicate.or(field, 'equal', itemAtIndex);
14218
+ }
14219
+ else {
14220
+ batchPredicate = batchPredicate.and(field, 'notequal', (value));
14221
+ }
14222
+ }
14223
+ }
14224
+ predicateBatches.push(batchPredicate);
14225
+ }
14226
+ // Combine batch predicates
14227
+ predicate = predicateBatches[0];
14228
+ for (var i = 1; i < predicateBatches.length; i++) {
14229
+ if (isAddNonPresentItems) {
14230
+ predicate = predicate.or(predicateBatches[i]);
14231
+ }
14232
+ else {
14233
+ predicate = predicate.and(predicateBatches[i]);
14234
+ }
14235
+ }
14236
+ return new Query().where(predicate);
14148
14237
  }
14149
- return new Query().where(predicate);
14150
14238
  }
14151
14239
  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));
14240
+ // Build predicates in batches to prevent stack overflow with large preselected values
14241
+ var predicateBatches = [];
14242
+ for (var batchStart = 0; batchStart < valuecheck.length; batchStart += BATCH_SIZE) {
14243
+ var batchPredicate = void 0;
14244
+ var batchEnd = Math.min(batchStart + BATCH_SIZE, valuecheck.length);
14245
+ for (var i = batchStart; i < batchEnd; i++) {
14246
+ var itemAtIndex = valuecheck[i];
14247
+ if (i === batchStart) {
14248
+ batchPredicate = new Predicate(field, 'equal', itemAtIndex);
14249
+ }
14250
+ else {
14251
+ batchPredicate = batchPredicate.or(field, 'equal', itemAtIndex);
14252
+ }
14162
14253
  }
14254
+ predicateBatches.push(batchPredicate);
14255
+ }
14256
+ // Combine all batch predicates
14257
+ predicate = predicateBatches[0];
14258
+ for (var i = 1; i < predicateBatches.length; i++) {
14259
+ predicate = predicate.or(predicateBatches[i]);
14163
14260
  }
14164
- return new Query().where(predicate);
14165
14261
  }
14166
14262
  }
14167
14263
  else {
14168
- for (var i = 0; i < valuecheck.length; i++) {
14169
- if (i === 0) {
14170
- predicate = new Predicate(field, 'equal', valuecheck[i]);
14264
+ if (this.enableVirtualization && valuecheck) {
14265
+ if (isCheckbox) {
14266
+ var startindex = this.viewPortInfo.startIndex;
14267
+ var endindex = (((startindex + this.viewPortInfo.endIndex) <= (valuecheck.length)) &&
14268
+ valuecheck[(startindex + this.viewPortInfo.endIndex)]) &&
14269
+ (this.dataSource instanceof DataManager && this.totalItemCount !== 0 && this.totalItemCount > (this.itemCount * 2))
14270
+ ? (startindex + this.viewPortInfo.endIndex)
14271
+ : (valuecheck.length);
14272
+ for (var i = startindex; i < endindex; i++) {
14273
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14274
+ this.fields.value : '', valuecheck[i]) : valuecheck[i];
14275
+ if (i === startindex) {
14276
+ predicate = new Predicate(field, 'equal', (value));
14277
+ }
14278
+ else {
14279
+ predicate = predicate.or(field, 'equal', (value));
14280
+ }
14281
+ }
14282
+ return new Query().where(predicate);
14171
14283
  }
14172
14284
  else {
14173
- predicate = predicate.or(field, 'equal', valuecheck[i]);
14285
+ for (var i = 0; i < valuecheck.length; i++) {
14286
+ var value = this.allowObjectBinding ? getValue((this.fields.value) ?
14287
+ this.fields.value : '', valuecheck[i]) : valuecheck[i];
14288
+ if (this.isaddNonPresentItems) {
14289
+ predicate = i === 0 ? new Predicate(field, 'equal', valuecheck[i])
14290
+ : predicate.or(field, 'equal', valuecheck[i]);
14291
+ }
14292
+ else {
14293
+ predicate = i === 0 ? predicate = new Predicate(field, 'notequal', (value))
14294
+ : predicate.and(field, 'notequal', (value));
14295
+ }
14296
+ }
14297
+ return new Query().where(predicate);
14298
+ }
14299
+ }
14300
+ else {
14301
+ for (var i = 0; i < valuecheck.length; i++) {
14302
+ if (i === 0) {
14303
+ predicate = new Predicate(field, 'equal', valuecheck[i]);
14304
+ }
14305
+ else {
14306
+ predicate = predicate.or(field, 'equal', valuecheck[i]);
14307
+ }
14174
14308
  }
14175
14309
  }
14176
14310
  }
@@ -16441,6 +16575,9 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
16441
16575
  }
16442
16576
  }
16443
16577
  };
16578
+ MultiSelect.prototype.isFilteringWithRemoteData = function () {
16579
+ return !isNullOrUndefined(this.mainData) && this.mainData.length > 0 && this.allowFiltering;
16580
+ };
16444
16581
  MultiSelect.prototype.removeChip = function (value, isClearAll) {
16445
16582
  if (this.chipCollectionWrapper) {
16446
16583
  if (!(this.enableVirtualization && isClearAll)) {
@@ -17655,6 +17792,9 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17655
17792
  getValue(((this.fields.value) ? this.fields.value : ''), this.value[index]) :
17656
17793
  this.value[index];
17657
17794
  element = this.findListElement(this.hideSelectedItem ? this.ulElement : this.list, 'li', 'data-value', value_2);
17795
+ if (!element && !isNullOrUndefined(this.mainList) && this.isFilteringWithRemoteData()) {
17796
+ element = this.findListElement(this.mainList, 'li', 'data-value', value_2);
17797
+ }
17658
17798
  var isCustomData = false;
17659
17799
  if (this.enableVirtualization) {
17660
17800
  text = null;
@@ -17701,6 +17841,12 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17701
17841
  }
17702
17842
  else {
17703
17843
  text = this.getTextByValue(value_2);
17844
+ if (text === value_2 && this.isFilteringWithRemoteData()) {
17845
+ var savedListData = this.listData;
17846
+ this.listData = this.mainData;
17847
+ text = this.getTextByValue(value_2);
17848
+ this.listData = savedListData;
17849
+ }
17704
17850
  }
17705
17851
  if (((element && (element.getAttribute('aria-selected') !== 'true')) ||
17706
17852
  (element && (element.getAttribute('aria-selected') === 'true' && this.hideSelectedItem) &&
@@ -19983,6 +20129,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
19983
20129
  this.chipCollectionWrapper = this.createElement('span', {
19984
20130
  className: CHIP_WRAPPER$1
19985
20131
  });
20132
+ this.chipCollectionWrapper.setAttribute('role', 'listbox');
20133
+ this.chipCollectionWrapper.setAttribute('aria-label', 'multiselect');
19986
20134
  this.chipCollectionWrapper.style.display = 'none';
19987
20135
  if (this.mode === 'Default') {
19988
20136
  this.chipCollectionWrapper.setAttribute('id', getUniqueID('chip_default'));