@syncfusion/ej2-dropdowns 34.2.4 → 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,17 +10506,21 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10384
10506
  this.triggerChangeEvent(this.keyEventArgs);
10385
10507
  this.isValueChange = false;
10386
10508
  }
10387
- var treeData = this.treeObj.getTreeData();
10388
- if (this.showCheckBox && this.treeSettings.autoCheck && treeData.length > 0 && this.treeData && this.treeData.length > 0) {
10389
- for (var i = 0; i < treeData.length; i++) {
10390
- for (var j = 0; j < this.treeData.length; j++) {
10391
- if (treeData[i].id === this.treeData[j].id) {
10392
- this.treeData[j].selected = treeData[i].selected !== undefined ?
10393
- treeData[i].selected : false;
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
+ }
10394
10519
  }
10395
10520
  }
10396
10521
  }
10397
10522
  }
10523
+ this.updateIndeterminateNodes();
10398
10524
  };
10399
10525
  DropDownTree.prototype.beforeCheck = function (args) {
10400
10526
  if (args.isInteracted) {
@@ -10884,7 +11010,8 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10884
11010
  if (!this.isFilteredData) {
10885
11011
  this.selectedData = [];
10886
11012
  }
10887
- 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)) {
10888
11015
  this.updateFilteredAutoCheckValues();
10889
11016
  }
10890
11017
  if (!isNullOrUndefined(this.value)) {
@@ -10963,6 +11090,7 @@ var DropDownTree = /** @__PURE__ @class */ (function (_super) {
10963
11090
  else {
10964
11091
  this.inputWrapper.setAttribute('aria-label', this.getModuleName());
10965
11092
  }
11093
+ this.updateIndeterminateNodes();
10966
11094
  };
10967
11095
  DropDownTree.prototype.setChipValues = function (text, value) {
10968
11096
  if (!this.inputWrapper.contains(this.chipWrapper)) {