@syncfusion/ej2-dropdowns 34.2.5 → 34.2.7

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