@syncfusion/ej2-dropdowns 34.2.3 → 34.2.5

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.
@@ -9800,8 +9800,129 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
9800
9800
  checkOnClick: true
9801
9801
  });
9802
9802
  this.treeObj.root = this.root ? this.root : this;
9803
+ this.treeObj.filterIndeterminateNodes = [];
9804
+ this.treeObj.filterCheckedNodes = [];
9803
9805
  this.treeObj.appendTo(this.tree);
9804
9806
  };
9807
+ DropDownTree.prototype.updateIndeterminateNodes = function () {
9808
+ if (!(this.allowFiltering && this.treeSettings.autoCheck) || (this.isRemoteData || this.treeSettings.loadOnDemand)) {
9809
+ return;
9810
+ }
9811
+ var checkedNodes = Array.isArray(this.value) ? this.value.slice() : [];
9812
+ var checkedSet = {};
9813
+ for (var i = 0; i < checkedNodes.length; i++) {
9814
+ checkedSet[checkedNodes[i]] = true;
9815
+ }
9816
+ var treeData = this.treeObj.element.classList.contains('e-filtering') ? this.treeData : this.treeItems;
9817
+ var valueField = this.fields.value;
9818
+ var parentValueField = this.fields.parentValue;
9819
+ var hasChildrenField = this.fields.hasChildren;
9820
+ var childField = this.fields.child;
9821
+ var indeterminateNodes = [];
9822
+ var childrenMap = {};
9823
+ for (var i = 0; i < treeData.length; i++) {
9824
+ var node = treeData[i];
9825
+ var nodeId = getValue(valueField, node);
9826
+ var nodePid = getValue(parentValueField, node);
9827
+ if (isNullOrUndefined(node) || isNullOrUndefined(nodeId) || isNullOrUndefined(nodePid)) {
9828
+ continue;
9829
+ }
9830
+ var parentId = nodePid.toString();
9831
+ if (!childrenMap[parentId]) {
9832
+ childrenMap[parentId] = [];
9833
+ }
9834
+ childrenMap[parentId].push(nodeId.toString());
9835
+ }
9836
+ var allNodes = treeData.slice();
9837
+ if (!isNullOrUndefined(childField)) {
9838
+ var collectNestedChildren_1 = function (nodes, fields) {
9839
+ if (!nodes) {
9840
+ return;
9841
+ }
9842
+ for (var i = 0; i < nodes.length; i++) {
9843
+ var node = nodes[i];
9844
+ if (isNullOrUndefined(node)) {
9845
+ continue;
9846
+ }
9847
+ var nodeId = getValue(fields.value, node);
9848
+ if (isNullOrUndefined(nodeId)) {
9849
+ continue;
9850
+ }
9851
+ allNodes.push(node);
9852
+ var childMapper = fields.child;
9853
+ var childrenArr = void 0;
9854
+ if (typeof childMapper === 'string') {
9855
+ childrenArr = node[childMapper];
9856
+ }
9857
+ else if (!isNullOrUndefined(childMapper)) {
9858
+ childrenArr = node[childMapper.value];
9859
+ }
9860
+ else {
9861
+ childrenArr = null;
9862
+ }
9863
+ if (!isNullOrUndefined(childrenArr) && Array.isArray(childrenArr) && childrenArr.length) {
9864
+ var parentId = nodeId.toString();
9865
+ if (!childrenMap[parentId]) {
9866
+ childrenMap[parentId] = [];
9867
+ }
9868
+ for (var k = 0; k < childrenArr.length; k++) {
9869
+ var childId = getValue(fields.value, childrenArr[k]);
9870
+ if (!isNullOrUndefined(childId) && childrenMap[parentId].indexOf(childId.toString()) === -1) {
9871
+ childrenMap[parentId].push(childId.toString());
9872
+ }
9873
+ }
9874
+ var nextFields = (typeof childMapper !== 'string' && !isNullOrUndefined(childMapper)) ?
9875
+ childMapper : fields;
9876
+ collectNestedChildren_1(childrenArr, nextFields);
9877
+ }
9878
+ }
9879
+ };
9880
+ collectNestedChildren_1(treeData, this.fields);
9881
+ }
9882
+ for (var i = 0; i < allNodes.length; i++) {
9883
+ var node = allNodes[i];
9884
+ var nodeId = getValue(valueField, node);
9885
+ if (isNullOrUndefined(node) || isNullOrUndefined(nodeId)) {
9886
+ continue;
9887
+ }
9888
+ var nodeIdStr = nodeId.toString();
9889
+ if (hasChildrenField && getValue(hasChildrenField, node) === false) {
9890
+ continue;
9891
+ }
9892
+ if (checkedSet[nodeIdStr]) {
9893
+ continue;
9894
+ }
9895
+ var descendants = [];
9896
+ var queue = childrenMap[nodeIdStr] ? childrenMap[nodeIdStr].slice() : [];
9897
+ var head = 0;
9898
+ while (head < queue.length) {
9899
+ var current = queue[head];
9900
+ head++;
9901
+ descendants.push(current);
9902
+ var kids = childrenMap[current];
9903
+ if (kids) {
9904
+ for (var j = 0; j < kids.length; j++) {
9905
+ queue.push(kids[j]);
9906
+ }
9907
+ }
9908
+ }
9909
+ if (descendants.length === 0) {
9910
+ continue;
9911
+ }
9912
+ var checkedDescendantCount = 0;
9913
+ for (var j = 0; j < descendants.length; j++) {
9914
+ if (checkedSet[descendants[j]]) {
9915
+ checkedDescendantCount++;
9916
+ }
9917
+ }
9918
+ if (checkedDescendantCount > 0 && checkedDescendantCount < descendants.length &&
9919
+ indeterminateNodes.indexOf(nodeIdStr) === -1) {
9920
+ indeterminateNodes.push(nodeIdStr);
9921
+ }
9922
+ }
9923
+ this.treeObj.filterCheckedNodes = checkedNodes;
9924
+ this.treeObj.filterIndeterminateNodes = indeterminateNodes;
9925
+ };
9805
9926
  /* To render the popup element */
9806
9927
  DropDownTree.prototype.renderPopup = function () {
9807
9928
  var _this = this;
@@ -10102,6 +10223,7 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10102
10223
  this.isFilterRestore = false;
10103
10224
  }
10104
10225
  }
10226
+ this.updateIndeterminateNodes();
10105
10227
  };
10106
10228
  DropDownTree.prototype.restoreFilterSelection = function () {
10107
10229
  if (this.treeObj.checkedNodes) {
@@ -10384,6 +10506,21 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10384
10506
  this.triggerChangeEvent(this.keyEventArgs);
10385
10507
  this.isValueChange = false;
10386
10508
  }
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
+ this.updateIndeterminateNodes();
10387
10524
  };
10388
10525
  DropDownTree.prototype.beforeCheck = function (args) {
10389
10526
  if (args.isInteracted) {
@@ -10700,9 +10837,35 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10700
10837
  })
10701
10838
  .map(function (childNode) { return childNode.id.toString(); });
10702
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
+ });
10862
+ };
10703
10863
  DropDownTree.prototype.updateFilteredAutoCheckValues = function () {
10704
10864
  var _this = this;
10705
10865
  var treeData = this.getFilteredTreeData();
10866
+ if (!this.isNodeChecked && Array.isArray(this.value) && this.value.length > 0 && this.showCheckBox) {
10867
+ this.restoreRootParentValues();
10868
+ }
10706
10869
  var currentValues = Array.isArray(this.value) ? this.value.map(function (item) { return item.toString(); }) : [];
10707
10870
  var removeParent = function (parentId) {
10708
10871
  _this.value = _this.value.filter(function (value) { return value.toString() !== parentId; });
@@ -10793,26 +10956,44 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10793
10956
  this.value = this.value.filter(function (value) { return removeValues.indexOf(value.toString()) === -1; });
10794
10957
  currentValues = this.value.map(function (item) { return item.toString(); });
10795
10958
  }
10796
- treeData.forEach(function (node) {
10797
- if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10798
- return;
10799
- }
10800
- if (!node.haschild) {
10801
- return;
10802
- }
10803
- var parentId = node.id.toString();
10804
- if (currentValues.indexOf(parentId) === -1) {
10805
- return;
10806
- }
10807
- var hasDirectChild = treeData.some(function (childNode) {
10808
- return !isNullOrUndefined(childNode) && !isNullOrUndefined(childNode.pid) && !isNullOrUndefined(childNode.id) && childNode.pid.toString() === parentId &&
10809
- currentValues.indexOf(childNode.id.toString()) !== -1;
10959
+ var stabilized = false;
10960
+ var valueBeforeReconciliation = this.value.slice();
10961
+ var iterationCount = 0;
10962
+ var maxIterations = treeData.length + 1;
10963
+ while (!stabilized && iterationCount < maxIterations) {
10964
+ stabilized = true;
10965
+ iterationCount++;
10966
+ treeData.forEach(function (node) {
10967
+ if (isNullOrUndefined(node) || isNullOrUndefined(node.id)) {
10968
+ return;
10969
+ }
10970
+ if (!node.haschild) {
10971
+ return;
10972
+ }
10973
+ var parentId = node.id.toString();
10974
+ var directChildren = _this.getDirectChildren(parentId);
10975
+ if (!directChildren.length) {
10976
+ return;
10977
+ }
10978
+ var allDirectChildrenChecked = directChildren.every(function (childId) { return currentValues.indexOf(childId) !== -1; });
10979
+ if (allDirectChildrenChecked) {
10980
+ if (currentValues.indexOf(parentId) === -1) {
10981
+ _this.value.push(parentId);
10982
+ currentValues = _this.value.map(function (item) { return item.toString(); });
10983
+ stabilized = false;
10984
+ }
10985
+ }
10986
+ else if (currentValues.indexOf(parentId) !== -1) {
10987
+ removeParent(parentId);
10988
+ currentValues = _this.value.map(function (item) { return item.toString(); });
10989
+ stabilized = false;
10990
+ }
10810
10991
  });
10811
- if (!hasDirectChild) {
10812
- removeParent(parentId);
10813
- currentValues = _this.value.map(function (item) { return item.toString(); });
10814
- }
10815
- });
10992
+ }
10993
+ if ((valueBeforeReconciliation.length > 0 && this.value.length === 0) ||
10994
+ iterationCount >= maxIterations) {
10995
+ this.value = valueBeforeReconciliation;
10996
+ }
10816
10997
  };
10817
10998
  DropDownTree.prototype.updateSelectedValues = function () {
10818
10999
  var _this = this;
@@ -10829,7 +11010,8 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10829
11010
  if (!this.isFilteredData) {
10830
11011
  this.selectedData = [];
10831
11012
  }
10832
- if (this.treeSettings.autoCheck && this.isFilteredData && !isNullOrUndefined(this.value)) {
11013
+ if (!this.isRemoteData && !this.treeSettings.loadOnDemand && this.treeSettings.autoCheck &&
11014
+ this.isFilteredData && !isNullOrUndefined(this.value)) {
10833
11015
  this.updateFilteredAutoCheckValues();
10834
11016
  }
10835
11017
  if (!isNullOrUndefined(this.value)) {
@@ -10908,6 +11090,7 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10908
11090
  else {
10909
11091
  this.inputWrapper.setAttribute('aria-label', this.getModuleName());
10910
11092
  }
11093
+ this.updateIndeterminateNodes();
10911
11094
  };
10912
11095
  DropDownTree.prototype.setChipValues = function (text, value) {
10913
11096
  if (!this.inputWrapper.contains(this.chipWrapper)) {
@@ -23901,7 +24084,7 @@ var ListBox = /** @__PURE__ @class */ (function (_super) {
23901
24084
  };
23902
24085
  ListBox.prototype.KeyUp = function (e) {
23903
24086
  var _this = this;
23904
- if (this.allowFiltering && e.ctrlKey && e.keyCode === 65) {
24087
+ if (this.allowFiltering && ((e.ctrlKey && e.keyCode === 65) || e.keyCode === 16)) {
23905
24088
  e.preventDefault();
23906
24089
  return;
23907
24090
  }
@@ -23909,7 +24092,7 @@ var ListBox = /** @__PURE__ @class */ (function (_super) {
23909
24092
  var isBracketKey = e.keyCode === 219 || e.keyCode === 220 || e.keyCode === 221 || e.keyCode === 222;
23910
24093
  var isNumericKeyPadSpecialKey = e.keyCode === 107 || e.keyCode === 109 || e.keyCode === 111;
23911
24094
  var isWordCharacter = e.key && e.key.match(/\w/);
23912
- var isWordAccentCharacter = e.key && e.key.match(/[A-Za-z0-9\u00C0-\u024F ,>/:;\-+=[\]\\ ']/);
24095
+ var isWordAccentCharacter = e.key && e.key.match(/[A-Za-z0-9\u00C0-\u024F ,>/:;\-+=[\]\\ '@!#$%^&*()]/);
23913
24096
  if (!isNullOrUndefined(isWordCharacter) || !isNullOrUndefined(isWordAccentCharacter)
23914
24097
  || isSpecialKey || isBracketKey || isNumericKeyPadSpecialKey) {
23915
24098
  this.isValidKey = true;