@syncfusion/ej2-navigations 34.2.4 → 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.
@@ -3819,6 +3819,7 @@ let Toolbar = class Toolbar extends Component {
3819
3819
  super(options, element);
3820
3820
  this.resizeContext = this.resize.bind(this);
3821
3821
  this.orientationChangeContext = this.orientationChange.bind(this);
3822
+ this.lastObservedWidth = 0;
3822
3823
  /**
3823
3824
  * Contains the keyboard configuration of the Toolbar.
3824
3825
  */
@@ -3850,6 +3851,10 @@ let Toolbar = class Toolbar extends Component {
3850
3851
  }
3851
3852
  });
3852
3853
  this.unwireEvents();
3854
+ this.lastObservedWidth = 0;
3855
+ if (this.resizeObserver && this.element.closest('.e-splitter')) {
3856
+ this.resizeObserver.disconnect();
3857
+ }
3853
3858
  this.tempId.forEach((ele) => {
3854
3859
  if (!isNullOrUndefined(this.element.querySelector(ele))) {
3855
3860
  document.body.appendChild(this.element.querySelector(ele)).style.display = 'none';
@@ -4428,6 +4433,17 @@ let Toolbar = class Toolbar extends Component {
4428
4433
  this.scrollEvent = this.docEvent.bind(this);
4429
4434
  this.renderControl();
4430
4435
  this.wireEvents();
4436
+ if (this.element.closest('.e-splitter')) {
4437
+ this.lastObservedWidth = this.element.offsetWidth;
4438
+ this.resizeObserver = new window.ResizeObserver(() => {
4439
+ if (this.element.offsetWidth === this.lastObservedWidth) {
4440
+ return;
4441
+ }
4442
+ this.lastObservedWidth = this.element.offsetWidth;
4443
+ this.refreshOverflow();
4444
+ });
4445
+ this.resizeObserver.observe(this.element);
4446
+ }
4431
4447
  this.renderComplete();
4432
4448
  if (this.isReact && this.portals && this.portals.length > 0) {
4433
4449
  this.renderReactTemplates(() => {
@@ -10718,6 +10734,8 @@ let TreeView = TreeView_1 = class TreeView extends Component {
10718
10734
  this.virtualTreeDirty = false;
10719
10735
  this.virtualFocusedId = null;
10720
10736
  this.virtualSkipNextScrollRender = false;
10737
+ this.filterCheckedNodes = [];
10738
+ this.filterIndeterminateNodes = [];
10721
10739
  }
10722
10740
  /**
10723
10741
  * Get component name.
@@ -11012,6 +11030,11 @@ let TreeView = TreeView_1 = class TreeView extends Component {
11012
11030
  return false;
11013
11031
  }
11014
11032
  }
11033
+ isRemoteDataLoadOnDemand() {
11034
+ const remoteDataSource = (this.fields.dataSource instanceof DataManager) ||
11035
+ (this.fields.child && this.fields.child.dataSource instanceof DataManager ? true : false);
11036
+ return !remoteDataSource && !this.loadOnDemand;
11037
+ }
11015
11038
  renderItems(isSorted) {
11016
11039
  if (this.enableVirtualization && !isNullOrUndefined(this.height)) {
11017
11040
  this.ulElement = this.createElement('ul', {
@@ -11200,7 +11223,9 @@ let TreeView = TreeView_1 = class TreeView extends Component {
11200
11223
  if (this.checkedNodes.indexOf(childId) !== -1) {
11201
11224
  count++;
11202
11225
  }
11203
- else if (this.element.classList.contains('e-filtering') && OldCheckedNodes.findIndex((e) => e['id'] === childId) !== -1) {
11226
+ else if (this.element.classList.contains('e-filtering') && (this.isRemoteDataLoadOnDemand() ?
11227
+ this.filterCheckedNodes.findIndex((id) => id === childId) !== -1 :
11228
+ OldCheckedNodes.findIndex((e) => e['id'] === childId) !== -1)) {
11204
11229
  count++;
11205
11230
  }
11206
11231
  }
@@ -11513,6 +11538,23 @@ let TreeView = TreeView_1 = class TreeView extends Component {
11513
11538
  }
11514
11539
  });
11515
11540
  let parentNodeChecked = false;
11541
+ if (this.isRemoteDataLoadOnDemand() && this.element.classList.contains('e-filtering') && this.autoCheck) {
11542
+ if (this.filterCheckedNodes.indexOf(dataUid) !== -1) {
11543
+ this.changeState(checkBoxEle, 'check', null, true, true);
11544
+ }
11545
+ else if (this.filterIndeterminateNodes.indexOf(dataUid) !== -1) {
11546
+ this.changeState(checkBoxEle, 'indeterminate', null, true, true);
11547
+ }
11548
+ else {
11549
+ this.changeState(checkBoxEle, 'uncheck', null, true, true);
11550
+ }
11551
+ const parentUL = closest(element, '.' + PARENTITEM);
11552
+ if (!isNullOrUndefined(parentUL)) {
11553
+ const currentParent = closest(parentUL, '.' + LISTITEM);
11554
+ this.ensureParentCheckState(currentParent);
11555
+ }
11556
+ return;
11557
+ }
11516
11558
  if (this.element.classList.contains('e-filtering')) {
11517
11559
  const oldCheckedNodes = new DataManager(this.OldCheckedData).executeLocal(new Query().where('parentID', 'equal', dataUid, true));
11518
11560
  checkedCount = oldCheckedNodes.length;
@@ -11618,7 +11660,7 @@ let TreeView = TreeView_1 = class TreeView extends Component {
11618
11660
  }
11619
11661
  });
11620
11662
  }
11621
- getAllChildNodes(data, parentId) {
11663
+ getAllChildNodes(data, parentId, includeAllDescendants) {
11622
11664
  if (isNullOrUndefined(data) || isNullOrUndefined(parentId)) {
11623
11665
  return [];
11624
11666
  }
@@ -11637,15 +11679,53 @@ let TreeView = TreeView_1 = class TreeView extends Component {
11637
11679
  const parentFieldId = this.fields.id;
11638
11680
  const childField = this.fields.child.toString();
11639
11681
  const target = parentId.toString();
11640
- const node = data.find((n) => {
11641
- const idVal = getValue(parentFieldId, n);
11642
- return !isNullOrUndefined(idVal) && idVal.toString() === target;
11643
- });
11682
+ const findNodeInTree = (nodes, id) => {
11683
+ if (!Array.isArray(nodes)) {
11684
+ return undefined;
11685
+ }
11686
+ for (let i = 0; i < nodes.length; i++) {
11687
+ const n = nodes[parseInt(i.toString(), 10)];
11688
+ const idVal = getValue(parentFieldId, n);
11689
+ if (!isNullOrUndefined(idVal) && idVal.toString() === id) {
11690
+ return n;
11691
+ }
11692
+ const subs = getValue(childField, n);
11693
+ const found = findNodeInTree(subs, id);
11694
+ if (found) {
11695
+ return found;
11696
+ }
11697
+ }
11698
+ return undefined;
11699
+ };
11700
+ const node = findNodeInTree(data, target);
11644
11701
  if (!node) {
11645
11702
  return [];
11646
11703
  }
11647
11704
  const children = getValue(childField, node);
11648
- return Array.isArray(children) ? children : [];
11705
+ if (!Array.isArray(children)) {
11706
+ return [];
11707
+ }
11708
+ if (!includeAllDescendants) {
11709
+ return children;
11710
+ }
11711
+ const result = children.slice();
11712
+ const collectNested = (nodes) => {
11713
+ if (!Array.isArray(nodes)) {
11714
+ return;
11715
+ }
11716
+ for (let i = 0; i < nodes.length; i++) {
11717
+ const n = nodes[parseInt(i.toString(), 10)];
11718
+ const grandChildren = getValue(childField, n);
11719
+ if (Array.isArray(grandChildren) && grandChildren.length) {
11720
+ for (let j = 0; j < grandChildren.length; j++) {
11721
+ result.push(grandChildren[parseInt(j.toString(), 10)]);
11722
+ }
11723
+ collectNested(grandChildren);
11724
+ }
11725
+ }
11726
+ };
11727
+ collectNested(children);
11728
+ return result;
11649
11729
  }
11650
11730
  return [];
11651
11731
  }
@@ -13367,6 +13447,83 @@ let TreeView = TreeView_1 = class TreeView extends Component {
13367
13447
  }
13368
13448
  }
13369
13449
  }
13450
+ if (this.isRemoteDataLoadOnDemand() && this.element.classList.contains('e-filtering') && this.autoCheck) {
13451
+ const nodeUid = li.getAttribute('data-uid');
13452
+ if (isNullOrUndefined(nodeUid)) {
13453
+ return;
13454
+ }
13455
+ const checkedIndex = this.filterCheckedNodes.indexOf(nodeUid);
13456
+ const indeterminateIndex = this.filterIndeterminateNodes.indexOf(nodeUid);
13457
+ const shouldCheck = !isCheck;
13458
+ if (shouldCheck) {
13459
+ if (checkedIndex === -1) {
13460
+ this.filterCheckedNodes.push(nodeUid);
13461
+ }
13462
+ if (indeterminateIndex !== -1) {
13463
+ this.filterIndeterminateNodes.splice(indeterminateIndex, 1);
13464
+ }
13465
+ }
13466
+ else {
13467
+ if (checkedIndex !== -1) {
13468
+ this.filterCheckedNodes.splice(checkedIndex, 1);
13469
+ }
13470
+ }
13471
+ let parentLi = closest(closest(li, '.' + PARENTITEM), '.' + LISTITEM);
13472
+ while (!isNullOrUndefined(parentLi)) {
13473
+ const parentUid = parentLi.getAttribute('data-uid');
13474
+ if (!isNullOrUndefined(parentUid)) {
13475
+ const parentChildren = this.getAllChildNodes(this.DDTTreeData, parentUid, true);
13476
+ if (parentChildren && parentChildren.length > 0) {
13477
+ let firstChildState;
13478
+ let mismatchFound = false;
13479
+ for (let i = 0; i < parentChildren.length; i++) {
13480
+ const childData = parentChildren[parseInt(i.toString(), 10)];
13481
+ const childId = childData && childData[this.fields.id]
13482
+ ? childData[this.fields.id].toString()
13483
+ : null;
13484
+ if (isNullOrUndefined(childId)) {
13485
+ continue;
13486
+ }
13487
+ const childCheckedState = this.filterIndeterminateNodes.indexOf(childId) !== -1
13488
+ ? null
13489
+ : this.filterCheckedNodes.indexOf(childId) !== -1;
13490
+ if (firstChildState === void 0) {
13491
+ firstChildState = childCheckedState;
13492
+ }
13493
+ else if (childCheckedState !== firstChildState) {
13494
+ mismatchFound = true;
13495
+ break;
13496
+ }
13497
+ }
13498
+ if (mismatchFound || firstChildState === null) {
13499
+ if (this.filterIndeterminateNodes.indexOf(parentUid) === -1) {
13500
+ this.filterIndeterminateNodes.push(parentUid);
13501
+ }
13502
+ const parentCheckedIndex = this.filterCheckedNodes.indexOf(parentUid);
13503
+ if (parentCheckedIndex !== -1) {
13504
+ this.filterCheckedNodes.splice(parentCheckedIndex, 1);
13505
+ }
13506
+ }
13507
+ else {
13508
+ const parentIndeterminateIndex = this.filterIndeterminateNodes.indexOf(parentUid);
13509
+ if (parentIndeterminateIndex !== -1) {
13510
+ this.filterIndeterminateNodes.splice(parentIndeterminateIndex, 1);
13511
+ }
13512
+ const parentCheckedIndex = this.filterCheckedNodes.indexOf(parentUid);
13513
+ if (firstChildState === true) {
13514
+ if (parentCheckedIndex === -1) {
13515
+ this.filterCheckedNodes.push(parentUid);
13516
+ }
13517
+ }
13518
+ else if (parentCheckedIndex !== -1) {
13519
+ this.filterCheckedNodes.splice(parentCheckedIndex, 1);
13520
+ }
13521
+ }
13522
+ }
13523
+ }
13524
+ parentLi = closest(closest(parentLi, '.' + PARENTITEM), '.' + LISTITEM);
13525
+ }
13526
+ }
13370
13527
  this.changeState(checkWrap, isCheck ? 'uncheck' : 'check', e, true);
13371
13528
  this.updateActiveClass(li, isCheck);
13372
13529
  if (this.autoCheck) {