@syncfusion/ej2-dropdowns 34.2.5 → 34.2.6

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.
@@ -3885,6 +3885,7 @@ var DropDownList = /** @__PURE__ @class */ (function (_super) {
3885
3885
  this.bindClearEvent();
3886
3886
  };
3887
3887
  DropDownList.prototype.windowResize = function () {
3888
+ this.updateFloatLabelOverflowWidth();
3888
3889
  if (this.isPopupOpen) {
3889
3890
  this.popupObj.refreshPosition(this.inputWrapper.container);
3890
3891
  }
@@ -8316,6 +8317,7 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
8316
8317
  _this.isNodeChecked = false;
8317
8318
  _this.isFromFilterChange = false;
8318
8319
  _this.fallbackValue = [];
8320
+ _this.uncheckedNodeId = null;
8319
8321
  return _this;
8320
8322
  }
8321
8323
  /**
@@ -10474,6 +10476,8 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10474
10476
  var eventArgs = this.getEventArgs(args);
10475
10477
  this.trigger('select', eventArgs);
10476
10478
  this.isNodeChecked = args.action === 'check';
10479
+ this.uncheckedNodeId = args.action === 'uncheck' && !isNullOrUndefined(args.data[0]) ?
10480
+ getValue('id', args.data[0]).toString() : null;
10477
10481
  if (this.isFilteredData && args.action === 'uncheck') {
10478
10482
  var id = getValue('id', args.data[0]).toString();
10479
10483
  this.removeSelectedData(id, true);
@@ -10506,21 +10510,8 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10506
10510
  this.triggerChangeEvent(this.keyEventArgs);
10507
10511
  this.isValueChange = false;
10508
10512
  }
10509
- if (!this.isRemoteData && !this.treeSettings.loadOnDemand) {
10510
- var treeData = this.treeObj.getTreeData();
10511
- if (this.showCheckBox && this.treeSettings.autoCheck &&
10512
- treeData.length > 0 && this.treeData && this.treeData.length > 0) {
10513
- for (var i = 0; i < treeData.length; i++) {
10514
- for (var j = 0; j < this.treeData.length; j++) {
10515
- if (treeData[i][this.fields.value] === this.treeData[j][this.fields.value]) {
10516
- this.treeData[j].selected = treeData[i].selected !== undefined ?
10517
- treeData[i].selected : false;
10518
- }
10519
- }
10520
- }
10521
- }
10522
- }
10523
10513
  this.updateIndeterminateNodes();
10514
+ this.uncheckedNodeId = null;
10524
10515
  };
10525
10516
  DropDownTree.prototype.beforeCheck = function (args) {
10526
10517
  if (args.isInteracted) {
@@ -10814,15 +10805,13 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10814
10805
  }
10815
10806
  }
10816
10807
  };
10817
- DropDownTree.prototype.getFilteredTreeData = function () {
10818
- return this.treeData;
10819
- };
10820
10808
  DropDownTree.prototype.getChildren = function (parentId, result) {
10821
10809
  var _this = this;
10822
- var treeData = this.getFilteredTreeData();
10823
- treeData.forEach(function (item) {
10824
- if (!isNullOrUndefined(item) && !isNullOrUndefined(item.pid) && !isNullOrUndefined(item.id) && item.pid.toString() === parentId.toString()) {
10825
- var childId = item.id.toString();
10810
+ this.treeData.forEach(function (item) {
10811
+ var itemId = !isNullOrUndefined(item) ? getValue(_this.fields.value, item) : null;
10812
+ var itemPid = !isNullOrUndefined(item) ? getValue(_this.fields.parentValue, item) : null;
10813
+ if (!isNullOrUndefined(itemId) && !isNullOrUndefined(itemPid) && itemPid.toString() === parentId.toString()) {
10814
+ var childId = itemId.toString();
10826
10815
  if (result.indexOf(childId) === -1) {
10827
10816
  result.push(childId);
10828
10817
  _this.getChildren(childId, result);
@@ -10831,41 +10820,17 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10831
10820
  });
10832
10821
  };
10833
10822
  DropDownTree.prototype.getDirectChildren = function (parentId) {
10834
- return this.getFilteredTreeData()
10823
+ var _this = this;
10824
+ return this.treeData
10835
10825
  .filter(function (childNode) {
10836
- return !isNullOrUndefined(childNode) && !isNullOrUndefined(childNode.pid) && !isNullOrUndefined(childNode.id) && childNode.pid.toString() === parentId;
10826
+ var childId = !isNullOrUndefined(childNode) ? getValue(_this.fields.value, childNode) : null;
10827
+ var childPid = !isNullOrUndefined(childNode) ? getValue(_this.fields.parentValue, childNode) : null;
10828
+ return !isNullOrUndefined(childId) && !isNullOrUndefined(childPid) && childPid.toString() === parentId;
10837
10829
  })
10838
- .map(function (childNode) { return childNode.id.toString(); });
10839
- };
10840
- DropDownTree.prototype.restoreRootParentValues = function () {
10841
- var _this = this;
10842
- var treeData = this.getFilteredTreeData();
10843
- treeData.forEach(function (node) {
10844
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10845
- return;
10846
- }
10847
- if (isNullOrUndefined(node.pid)) {
10848
- var rootId = node.id.toString();
10849
- var currentValues_1 = _this.value.map(function (item) {
10850
- return item.toString();
10851
- });
10852
- if (currentValues_1.indexOf(rootId) === -1) {
10853
- var childValues = [];
10854
- _this.getChildren(rootId, childValues);
10855
- var hasSelectedChild = childValues.some(function (childId) { return currentValues_1.indexOf(childId) !== -1; });
10856
- if (hasSelectedChild) {
10857
- _this.value.push(rootId);
10858
- }
10859
- }
10860
- }
10861
- });
10830
+ .map(function (childNode) { return getValue(_this.fields.value, childNode).toString(); });
10862
10831
  };
10863
10832
  DropDownTree.prototype.updateFilteredAutoCheckValues = function () {
10864
10833
  var _this = this;
10865
- var treeData = this.getFilteredTreeData();
10866
- if (!this.isNodeChecked && Array.isArray(this.value) && this.value.length > 0 && this.showCheckBox) {
10867
- this.restoreRootParentValues();
10868
- }
10869
10834
  var currentValues = Array.isArray(this.value) ? this.value.map(function (item) { return item.toString(); }) : [];
10870
10835
  var removeParent = function (parentId) {
10871
10836
  _this.value = _this.value.filter(function (value) { return value.toString() !== parentId; });
@@ -10876,12 +10841,14 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10876
10841
  _this.value.push(value);
10877
10842
  }
10878
10843
  });
10879
- treeData.forEach(function (node) {
10880
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10844
+ this.treeData.forEach(function (node) {
10845
+ var nodeId = isNullOrUndefined(node) ? null : getValue(_this.fields.value, node);
10846
+ var nodeHasChild = !isNullOrUndefined(node) && !!_this.fields.hasChildren && getValue(_this.fields.hasChildren, node) === true;
10847
+ if (isNullOrUndefined(nodeId)) {
10881
10848
  return;
10882
10849
  }
10883
- var parentId = node.id.toString();
10884
- if (node.haschild && _this.value.indexOf(parentId) !== -1) {
10850
+ var parentId = nodeId.toString();
10851
+ if (nodeHasChild && _this.value.indexOf(parentId) !== -1) {
10885
10852
  var childValues = [];
10886
10853
  _this.getChildren(parentId, childValues);
10887
10854
  if (_this.value.indexOf(parentId) === -1) {
@@ -10895,14 +10862,16 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10895
10862
  }
10896
10863
  currentValues = _this.value.map(function (item) { return item.toString(); });
10897
10864
  });
10898
- treeData.forEach(function (node) {
10899
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10865
+ this.treeData.forEach(function (node) {
10866
+ var nodeId = isNullOrUndefined(node) ? null : getValue(_this.fields.value, node);
10867
+ var nodeHasChild = !isNullOrUndefined(node) && !!_this.fields.hasChildren && getValue(_this.fields.hasChildren, node) === true;
10868
+ if (isNullOrUndefined(nodeId)) {
10900
10869
  return;
10901
10870
  }
10902
- if (!node.haschild) {
10871
+ if (!nodeHasChild) {
10903
10872
  return;
10904
10873
  }
10905
- var parentId = node.id.toString();
10874
+ var parentId = nodeId.toString();
10906
10875
  var directChildren = _this.getDirectChildren(parentId);
10907
10876
  if (!directChildren.length) {
10908
10877
  return;
@@ -10936,14 +10905,19 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10936
10905
  return;
10937
10906
  }
10938
10907
  var removeValues = [];
10939
- treeData.forEach(function (node) {
10940
- if (isNullOrUndefined(node.id)) {
10908
+ this.treeData.forEach(function (node) {
10909
+ var nodeId = isNullOrUndefined(node) ? null : getValue(_this.fields.value, node);
10910
+ var nodeHasChild = !isNullOrUndefined(node) && !!_this.fields.hasChildren && getValue(_this.fields.hasChildren, node) === true;
10911
+ if (isNullOrUndefined(nodeId)) {
10941
10912
  return;
10942
10913
  }
10943
- if (!node.haschild) {
10914
+ if (!nodeHasChild) {
10915
+ return;
10916
+ }
10917
+ var parentId = nodeId.toString();
10918
+ if (parentId !== _this.uncheckedNodeId) {
10944
10919
  return;
10945
10920
  }
10946
- var parentId = node.id.toString();
10947
10921
  if (currentValues.indexOf(parentId) === -1) {
10948
10922
  var childValues = [];
10949
10923
  _this.getChildren(parentId, childValues);
@@ -10959,18 +10933,20 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10959
10933
  var stabilized = false;
10960
10934
  var valueBeforeReconciliation = this.value.slice();
10961
10935
  var iterationCount = 0;
10962
- var maxIterations = treeData.length + 1;
10936
+ var maxIterations = this.treeData.length + 1;
10963
10937
  while (!stabilized && iterationCount < maxIterations) {
10964
10938
  stabilized = true;
10965
10939
  iterationCount++;
10966
- treeData.forEach(function (node) {
10967
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10940
+ this.treeData.forEach(function (node) {
10941
+ var nodeId = isNullOrUndefined(node) ? null : getValue(_this.fields.value, node);
10942
+ var nodeHasChild = !isNullOrUndefined(node) && !!_this.fields.hasChildren && getValue(_this.fields.hasChildren, node) === true;
10943
+ if (isNullOrUndefined(nodeId)) {
10968
10944
  return;
10969
10945
  }
10970
- if (!node.haschild) {
10946
+ if (!nodeHasChild) {
10971
10947
  return;
10972
10948
  }
10973
- var parentId = node.id.toString();
10949
+ var parentId = nodeId.toString();
10974
10950
  var directChildren = _this.getDirectChildren(parentId);
10975
10951
  if (!directChildren.length) {
10976
10952
  return;
@@ -14185,6 +14161,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
14185
14161
  };
14186
14162
  MultiSelect.prototype.onPopupShown = function (e) {
14187
14163
  var _this = this;
14164
+ this.sanitizeData();
14188
14165
  if (Browser.isDevice && (this.mode === 'CheckBox' && this.allowFiltering)) {
14189
14166
  // eslint-disable-next-line @typescript-eslint/no-this-alias
14190
14167
  var proxy_1 = this;
@@ -15809,7 +15786,10 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
15809
15786
  }
15810
15787
  }
15811
15788
  this.UpdateSkeleton();
15812
- var scrollEle = this.ulElement.querySelectorAll('li.' + dropDownBaseClasses.li
15789
+ var hasOnlyVirtualItems = this.ulElement && this.ulElement.querySelector('li.e-virtual-list') &&
15790
+ this.ulElement.querySelectorAll('li:not(.e-virtual-list)').length === 0;
15791
+ var targetElement = hasOnlyVirtualItems ? this.list : this.ulElement;
15792
+ var scrollEle = targetElement.querySelectorAll('li.' + dropDownBaseClasses.li
15813
15793
  + ':not(.' + HIDE_LIST + ')' + ':not(.e-reorder-hide)');
15814
15794
  if (scrollEle.length > 0) {
15815
15795
  var element = scrollEle[(isHome) ? 0 : (scrollEle.length - 1)];
@@ -17703,6 +17683,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17703
17683
  };
17704
17684
  MultiSelect.prototype.windowResize = function () {
17705
17685
  this.refreshPopup();
17686
+ this.calculateWidth();
17687
+ this.updateFloatLabelOverflowWidth();
17706
17688
  if ((!this.inputFocus || this.mode === 'CheckBox') && this.viewWrapper && this.viewWrapper.parentElement) {
17707
17689
  this.updateDelimView();
17708
17690
  }
@@ -17932,6 +17914,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17932
17914
  }
17933
17915
  this.preventSetCurrentData = false;
17934
17916
  this.initializeData();
17917
+ this.sanitizeData();
17935
17918
  this.updateDataAttribute(this.htmlAttributes);
17936
17919
  _super.prototype.preRender.call(this);
17937
17920
  };
@@ -17962,6 +17945,56 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
17962
17945
  endIndex: this.itemCount
17963
17946
  };
17964
17947
  };
17948
+ MultiSelect.prototype.sanitizeData = function () {
17949
+ if (this.enableVirtualization && this.mode === 'CheckBox') {
17950
+ if (this.dataSource && Array.isArray(this.dataSource) && !(this.dataSource instanceof DataManager)) {
17951
+ var cleanedDataSource = [];
17952
+ for (var i = 0; i < this.dataSource.length; i++) {
17953
+ var item = this.dataSource[i];
17954
+ if (item !== null && item !== undefined && item !== '') {
17955
+ if (typeof item === 'object') {
17956
+ var itemValue = getValue((this.fields.value ? this.fields.value : 'value'), item);
17957
+ if (this.fields.value !== null) {
17958
+ if (itemValue !== null && itemValue !== undefined && itemValue !== '') {
17959
+ cleanedDataSource.push(item);
17960
+ }
17961
+ }
17962
+ else {
17963
+ cleanedDataSource.push(item);
17964
+ }
17965
+ }
17966
+ else if (typeof item === 'string') {
17967
+ if (item !== null && item !== undefined && item.trim() !== '') {
17968
+ cleanedDataSource.push(item);
17969
+ }
17970
+ }
17971
+ else {
17972
+ cleanedDataSource.push(item);
17973
+ }
17974
+ }
17975
+ }
17976
+ if (cleanedDataSource.length !== this.dataSource.length) {
17977
+ this.setProperties({ dataSource: cleanedDataSource }, true);
17978
+ }
17979
+ }
17980
+ if (this.value && Array.isArray(this.value) && this.value.length > 0) {
17981
+ var cleanedValue = [];
17982
+ for (var i = 0; i < this.value.length; i++) {
17983
+ var val = this.value[i];
17984
+ if (val !== null && val !== undefined && val !== '') {
17985
+ cleanedValue.push(val);
17986
+ }
17987
+ }
17988
+ if (cleanedValue.length !== this.value.length) {
17989
+ this.setProperties({ value: cleanedValue }, true);
17990
+ }
17991
+ }
17992
+ return true;
17993
+ }
17994
+ else {
17995
+ return false;
17996
+ }
17997
+ };
17965
17998
  MultiSelect.prototype.updateData = function (delimiterChar, e, isInitialVirtualData) {
17966
17999
  var data = '';
17967
18000
  var delim = this.mode === 'Delimiter' || this.mode === 'CheckBox';
@@ -18112,6 +18145,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
18112
18145
  || this.list.querySelector('.e-ul') && this.list.querySelector('.e-ul').childElementCount === 0)) {
18113
18146
  isEmptyData = true;
18114
18147
  }
18148
+ this.sanitizeData();
18115
18149
  _super.prototype.render.call(this, null, isEmptyData);
18116
18150
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18117
18151
  this.totalItemCount = this.dataSource && this.dataSource.length ? this.dataSource.length : 0;
@@ -19850,6 +19884,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
19850
19884
  switch (prop) {
19851
19885
  case 'query':
19852
19886
  case 'dataSource':
19887
+ this.sanitizeData();
19853
19888
  if (this.mode === 'CheckBox' && this.showSelectAll) {
19854
19889
  if (!isNullOrUndefined(this.popupObj)) {
19855
19890
  this.popupObj.destroy();
@@ -19872,6 +19907,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
19872
19907
  this.updateVal(this.value, this.value, 'text');
19873
19908
  break;
19874
19909
  case 'value':
19910
+ this.sanitizeData();
19875
19911
  if (this.fields.disabled) {
19876
19912
  this.removeDisabledItemsValue(this.value);
19877
19913
  }
@@ -20308,6 +20344,8 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
20308
20344
  }
20309
20345
  this.firstItem = this.dataSource && this.dataSource.length > 0 ? this.dataSource[0] : null;
20310
20346
  var args = { cancel: false };
20347
+ var oldValue = extend([], this.value, [], true);
20348
+ var oldData = extend([], this.dataSource, [], true);
20311
20349
  this.trigger('beforeOpen', args, function (args) {
20312
20350
  if (!args.cancel) {
20313
20351
  if (!_this.ulElement) {
@@ -20319,6 +20357,50 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
20319
20357
  if (_this.inputElement && _this.mode !== 'CheckBox') {
20320
20358
  _this.focusIn();
20321
20359
  }
20360
+ if (_this.enableVirtualization && _this.mode === 'CheckBox') {
20361
+ if (JSON.stringify(oldData) !== JSON.stringify(_this.dataSource) && _this.sanitizeData() && _this.showSelectAll) {
20362
+ _this.renderPopup();
20363
+ }
20364
+ if (!isNullOrUndefined(oldValue) && !isNullOrUndefined(_this.value) &&
20365
+ JSON.stringify(oldValue) !== JSON.stringify(_this.value) && _this.sanitizeData()) {
20366
+ if (_this.fields.disabled) {
20367
+ _this.removeDisabledItemsValue(_this.value);
20368
+ }
20369
+ if (!_this.validateValues(_this.value, oldValue)) {
20370
+ return;
20371
+ }
20372
+ if (_this.isVue && !_this.changeOnBlur && !_this.validateValues(_this.value, oldValue)) {
20373
+ return;
20374
+ }
20375
+ _this.updateVal(_this.value, oldValue, 'value', _this.enableVirtualization);
20376
+ _this.addValidInputClass();
20377
+ if (_this.showSelectAll) {
20378
+ _this.renderPopup();
20379
+ var totalCount = _this.dataSource instanceof DataManager ? 0 :
20380
+ _this.dataSource.length;
20381
+ var selectedCount = _this.value ? _this.value.length : 0;
20382
+ if (selectedCount === totalCount) {
20383
+ var frame = null;
20384
+ if (_this.popupObj) {
20385
+ frame = _this.popupObj.element.querySelector('.e-selectall-parent .e-frame');
20386
+ }
20387
+ if (frame) {
20388
+ frame.classList.add('e-check');
20389
+ frame.classList.remove('e-uncheck');
20390
+ frame.classList.remove('e-stop');
20391
+ }
20392
+ }
20393
+ }
20394
+ if (!_this.closePopupOnSelect && _this.isPopupOpen()) {
20395
+ _this.refreshPopup();
20396
+ }
20397
+ if (_this.isPopupOpen() && _this.list && _this.list.querySelector('.e-active.e-disable')) {
20398
+ var activeItems = _this.list.querySelectorAll('li.' + dropDownBaseClasses.li + '.e-active' + '.e-disable');
20399
+ removeClass(activeItems, 'e-disable');
20400
+ }
20401
+ _this.preventChange = _this.isAngular && _this.preventChange ? !_this.preventChange : _this.preventChange;
20402
+ }
20403
+ }
20322
20404
  return;
20323
20405
  }
20324
20406
  if (_this.mode === 'CheckBox' && Browser.isDevice && _this.allowFiltering && _this.isDeviceFullScreen) {
@@ -20475,6 +20557,7 @@ var MultiSelect = /** @__PURE__ @class */ (function (_super) {
20475
20557
  // eslint-disable-next-line
20476
20558
  this.value = this.value.slice();
20477
20559
  }
20560
+ this.sanitizeData();
20478
20561
  this.setDynValue = this.initStatus = false;
20479
20562
  this.isSelectAll = false;
20480
20563
  this.selectAllEventEle = [];
@@ -25184,7 +25267,7 @@ var Mention = /** @__PURE__ @class */ (function (_super) {
25184
25267
  ? lastWordRange.substring(lastWordRange.lastIndexOf(this.mentionChar) + 1).trim()
25185
25268
  : lastWordRange.replace(this.mentionChar, '');
25186
25269
  }
25187
- if (this.queryString !== '' && e.keyCode === 8 && lastWordRange.includes(this.mentionChar) && !this.isPopupOpen &&
25270
+ if (this.queryString !== '' && e.keyCode === 8 && lastWordRange.includes(this.mentionChar) && !this.isPopupOpen && !isNullOrUndefined(this.displayTemplate) &&
25188
25271
  ((typeof this.displayTemplate === 'function' ? this.displayTemplate() : this.displayTemplate)).includes(this.mentionChar)) {
25189
25272
  this.queryString = '';
25190
25273
  }