@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.
@@ -9612,8 +9612,129 @@ let DropDownTree = class DropDownTree extends Component {
9612
9612
  checkOnClick: true
9613
9613
  });
9614
9614
  this.treeObj.root = this.root ? this.root : this;
9615
+ this.treeObj.filterIndeterminateNodes = [];
9616
+ this.treeObj.filterCheckedNodes = [];
9615
9617
  this.treeObj.appendTo(this.tree);
9616
9618
  }
9619
+ updateIndeterminateNodes() {
9620
+ if (!(this.allowFiltering && this.treeSettings.autoCheck) || (this.isRemoteData || this.treeSettings.loadOnDemand)) {
9621
+ return;
9622
+ }
9623
+ const checkedNodes = Array.isArray(this.value) ? this.value.slice() : [];
9624
+ const checkedSet = {};
9625
+ for (let i = 0; i < checkedNodes.length; i++) {
9626
+ checkedSet[checkedNodes[i]] = true;
9627
+ }
9628
+ const treeData = this.treeObj.element.classList.contains('e-filtering') ? this.treeData : this.treeItems;
9629
+ const valueField = this.fields.value;
9630
+ const parentValueField = this.fields.parentValue;
9631
+ const hasChildrenField = this.fields.hasChildren;
9632
+ const childField = this.fields.child;
9633
+ const indeterminateNodes = [];
9634
+ const childrenMap = {};
9635
+ for (let i = 0; i < treeData.length; i++) {
9636
+ const node = treeData[i];
9637
+ const nodeId = getValue(valueField, node);
9638
+ const nodePid = getValue(parentValueField, node);
9639
+ if (isNullOrUndefined(node) || isNullOrUndefined(nodeId) || isNullOrUndefined(nodePid)) {
9640
+ continue;
9641
+ }
9642
+ const parentId = nodePid.toString();
9643
+ if (!childrenMap[parentId]) {
9644
+ childrenMap[parentId] = [];
9645
+ }
9646
+ childrenMap[parentId].push(nodeId.toString());
9647
+ }
9648
+ const allNodes = treeData.slice();
9649
+ if (!isNullOrUndefined(childField)) {
9650
+ const collectNestedChildren = (nodes, fields) => {
9651
+ if (!nodes) {
9652
+ return;
9653
+ }
9654
+ for (let i = 0; i < nodes.length; i++) {
9655
+ const node = nodes[i];
9656
+ if (isNullOrUndefined(node)) {
9657
+ continue;
9658
+ }
9659
+ const nodeId = getValue(fields.value, node);
9660
+ if (isNullOrUndefined(nodeId)) {
9661
+ continue;
9662
+ }
9663
+ allNodes.push(node);
9664
+ const childMapper = fields.child;
9665
+ let childrenArr;
9666
+ if (typeof childMapper === 'string') {
9667
+ childrenArr = node[childMapper];
9668
+ }
9669
+ else if (!isNullOrUndefined(childMapper)) {
9670
+ childrenArr = node[childMapper.value];
9671
+ }
9672
+ else {
9673
+ childrenArr = null;
9674
+ }
9675
+ if (!isNullOrUndefined(childrenArr) && Array.isArray(childrenArr) && childrenArr.length) {
9676
+ const parentId = nodeId.toString();
9677
+ if (!childrenMap[parentId]) {
9678
+ childrenMap[parentId] = [];
9679
+ }
9680
+ for (let k = 0; k < childrenArr.length; k++) {
9681
+ const childId = getValue(fields.value, childrenArr[k]);
9682
+ if (!isNullOrUndefined(childId) && childrenMap[parentId].indexOf(childId.toString()) === -1) {
9683
+ childrenMap[parentId].push(childId.toString());
9684
+ }
9685
+ }
9686
+ const nextFields = (typeof childMapper !== 'string' && !isNullOrUndefined(childMapper)) ?
9687
+ childMapper : fields;
9688
+ collectNestedChildren(childrenArr, nextFields);
9689
+ }
9690
+ }
9691
+ };
9692
+ collectNestedChildren(treeData, this.fields);
9693
+ }
9694
+ for (let i = 0; i < allNodes.length; i++) {
9695
+ const node = allNodes[i];
9696
+ const nodeId = getValue(valueField, node);
9697
+ if (isNullOrUndefined(node) || isNullOrUndefined(nodeId)) {
9698
+ continue;
9699
+ }
9700
+ const nodeIdStr = nodeId.toString();
9701
+ if (hasChildrenField && getValue(hasChildrenField, node) === false) {
9702
+ continue;
9703
+ }
9704
+ if (checkedSet[nodeIdStr]) {
9705
+ continue;
9706
+ }
9707
+ const descendants = [];
9708
+ const queue = childrenMap[nodeIdStr] ? childrenMap[nodeIdStr].slice() : [];
9709
+ let head = 0;
9710
+ while (head < queue.length) {
9711
+ const current = queue[head];
9712
+ head++;
9713
+ descendants.push(current);
9714
+ const kids = childrenMap[current];
9715
+ if (kids) {
9716
+ for (let j = 0; j < kids.length; j++) {
9717
+ queue.push(kids[j]);
9718
+ }
9719
+ }
9720
+ }
9721
+ if (descendants.length === 0) {
9722
+ continue;
9723
+ }
9724
+ let checkedDescendantCount = 0;
9725
+ for (let j = 0; j < descendants.length; j++) {
9726
+ if (checkedSet[descendants[j]]) {
9727
+ checkedDescendantCount++;
9728
+ }
9729
+ }
9730
+ if (checkedDescendantCount > 0 && checkedDescendantCount < descendants.length &&
9731
+ indeterminateNodes.indexOf(nodeIdStr) === -1) {
9732
+ indeterminateNodes.push(nodeIdStr);
9733
+ }
9734
+ }
9735
+ this.treeObj.filterCheckedNodes = checkedNodes;
9736
+ this.treeObj.filterIndeterminateNodes = indeterminateNodes;
9737
+ }
9617
9738
  /* To render the popup element */
9618
9739
  renderPopup() {
9619
9740
  if (this.isFilteredData) {
@@ -9910,6 +10031,7 @@ let DropDownTree = class DropDownTree extends Component {
9910
10031
  this.isFilterRestore = false;
9911
10032
  }
9912
10033
  }
10034
+ this.updateIndeterminateNodes();
9913
10035
  }
9914
10036
  restoreFilterSelection() {
9915
10037
  if (this.treeObj.checkedNodes) {
@@ -10192,17 +10314,21 @@ let DropDownTree = class DropDownTree extends Component {
10192
10314
  this.triggerChangeEvent(this.keyEventArgs);
10193
10315
  this.isValueChange = false;
10194
10316
  }
10195
- const treeData = this.treeObj.getTreeData();
10196
- if (this.showCheckBox && this.treeSettings.autoCheck && treeData.length > 0 && this.treeData && this.treeData.length > 0) {
10197
- for (let i = 0; i < treeData.length; i++) {
10198
- for (let j = 0; j < this.treeData.length; j++) {
10199
- if (treeData[i].id === this.treeData[j].id) {
10200
- this.treeData[j].selected = treeData[i].selected !== undefined ?
10201
- treeData[i].selected : false;
10317
+ if (!this.isRemoteData && !this.treeSettings.loadOnDemand) {
10318
+ const treeData = this.treeObj.getTreeData();
10319
+ if (this.showCheckBox && this.treeSettings.autoCheck &&
10320
+ treeData.length > 0 && this.treeData && this.treeData.length > 0) {
10321
+ for (let i = 0; i < treeData.length; i++) {
10322
+ for (let j = 0; j < this.treeData.length; j++) {
10323
+ if (treeData[i][this.fields.value] === this.treeData[j][this.fields.value]) {
10324
+ this.treeData[j].selected = treeData[i].selected !== undefined ?
10325
+ treeData[i].selected : false;
10326
+ }
10202
10327
  }
10203
10328
  }
10204
10329
  }
10205
10330
  }
10331
+ this.updateIndeterminateNodes();
10206
10332
  }
10207
10333
  beforeCheck(args) {
10208
10334
  if (args.isInteracted) {
@@ -10680,7 +10806,8 @@ let DropDownTree = class DropDownTree extends Component {
10680
10806
  if (!this.isFilteredData) {
10681
10807
  this.selectedData = [];
10682
10808
  }
10683
- if (this.treeSettings.autoCheck && this.isFilteredData && !isNullOrUndefined(this.value)) {
10809
+ if (!this.isRemoteData && !this.treeSettings.loadOnDemand && this.treeSettings.autoCheck &&
10810
+ this.isFilteredData && !isNullOrUndefined(this.value)) {
10684
10811
  this.updateFilteredAutoCheckValues();
10685
10812
  }
10686
10813
  if (!isNullOrUndefined(this.value)) {
@@ -10757,6 +10884,7 @@ let DropDownTree = class DropDownTree extends Component {
10757
10884
  else {
10758
10885
  this.inputWrapper.setAttribute('aria-label', this.getModuleName());
10759
10886
  }
10887
+ this.updateIndeterminateNodes();
10760
10888
  }
10761
10889
  setChipValues(text, value) {
10762
10890
  if (!this.inputWrapper.contains(this.chipWrapper)) {