@syncfusion/ej2-lists 26.2.11 → 26.2.14

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.
@@ -1725,6 +1725,28 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1725
1725
  this.virtualizationModule.refreshItemHeight();
1726
1726
  }
1727
1727
  };
1728
+ ListView.prototype.handleCheckboxState = function (li, checkIcon, checkboxElement, isCheckedBefore, isFocusedBefore, eventArgs, isSetCheckboxLI, textAreaFocus) {
1729
+ this.trigger('select', eventArgs, function (observedArgs) {
1730
+ if (observedArgs.cancel) {
1731
+ if (isSetCheckboxLI ? isCheckedBefore : !isCheckedBefore) {
1732
+ checkIcon.classList.add(classNames.checked);
1733
+ li.classList.add(classNames.selected);
1734
+ }
1735
+ else {
1736
+ checkIcon.classList.remove(classNames.checked);
1737
+ li.classList.remove(classNames.selected);
1738
+ }
1739
+ checkboxElement.setAttribute('aria-checked', isSetCheckboxLI ? (isCheckedBefore ? 'true' : 'false') : (isCheckedBefore ? 'false' : 'true'));
1740
+ merge(eventArgs, { isChecked: checkIcon.classList.contains(classNames.checked) });
1741
+ if (isFocusedBefore) {
1742
+ li.classList.remove(classNames.focused);
1743
+ if (textAreaFocus) {
1744
+ textAreaFocus.classList.remove('e-focused');
1745
+ }
1746
+ }
1747
+ }
1748
+ });
1749
+ };
1728
1750
  ListView.prototype.clickHandler = function (e) {
1729
1751
  if (Array.isArray(this.dataSource) && this.dataSource.length === 0) {
1730
1752
  return;
@@ -1766,7 +1788,10 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1766
1788
  var eventArgs = this.selectEventData(li, e);
1767
1789
  var checkIcon = li.querySelector('.' + classNames.checkboxIcon);
1768
1790
  merge(eventArgs, { isChecked: checkIcon.classList.contains(classNames.checked) });
1769
- this.trigger('select', eventArgs);
1791
+ var checkboxElement = li.querySelector('.' + classNames.checkboxWrapper);
1792
+ var isCheckedBefore = checkIcon.classList.contains(classNames.checked);
1793
+ var isFocusedBefore = li.classList.contains(classNames.focused);
1794
+ this.handleCheckboxState(li, checkIcon, checkboxElement, isCheckedBefore, isFocusedBefore, eventArgs, false);
1770
1795
  }
1771
1796
  }
1772
1797
  else if (li.classList.contains(classNames.hasChild)) {
@@ -1987,7 +2012,13 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1987
2012
  }
1988
2013
  var eventArgs = this.selectEventData(li, e);
1989
2014
  merge(eventArgs, { isChecked: checkIcon ? checkIcon.classList.contains(classNames.checked) : false });
1990
- this.trigger('select', eventArgs);
2015
+ if (!isNullOrUndefined(li)) {
2016
+ var cbElement = li.querySelector('.' + classNames.checkboxWrapper);
2017
+ var checkboxIcon = li.querySelector('.' + classNames.checkboxIcon);
2018
+ var isCheckedBefore = checkboxIcon.classList.contains(classNames.checked);
2019
+ var isFocusedBefore = li.classList.contains(classNames.focused);
2020
+ this.handleCheckboxState(li, checkboxIcon, cbElement, isCheckedBefore, isFocusedBefore, eventArgs, false);
2021
+ }
1991
2022
  this.updateSelectedId();
1992
2023
  }
1993
2024
  };
@@ -2117,7 +2148,9 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2117
2148
  var checkboxElement = li.querySelector('.' + classNames.checkboxWrapper);
2118
2149
  var checkIcon = checkboxElement.querySelector('.' + classNames.checkboxIcon + '.' + classNames.icon);
2119
2150
  this.removeHover();
2120
- if (!checkIcon.classList.contains(classNames.checked)) {
2151
+ var isCheckedBefore = checkIcon.classList.contains(classNames.checked);
2152
+ var isFocusedBefore = li.classList.contains(classNames.focused);
2153
+ if (!isCheckedBefore) {
2121
2154
  checkIcon.classList.add(classNames.checked);
2122
2155
  li.classList.add(classNames.selected);
2123
2156
  }
@@ -2132,7 +2165,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2132
2165
  if (this.enableVirtualization) {
2133
2166
  this.virtualizationModule.setCheckboxLI(li, e);
2134
2167
  }
2135
- this.trigger('select', eventArgs);
2168
+ this.handleCheckboxState(li, checkIcon, checkboxElement, isCheckedBefore, isFocusedBefore, eventArgs, true, textAreaFocus);
2136
2169
  this.setSelectedItemData(li);
2137
2170
  this.renderSubList(li);
2138
2171
  }
@@ -2201,6 +2234,10 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2201
2234
  _this.selectedLI = li;
2202
2235
  _this.renderSubList(li);
2203
2236
  }
2237
+ else {
2238
+ li.classList.remove(classNames.selected);
2239
+ _this.selectedLI = li;
2240
+ }
2204
2241
  });
2205
2242
  }
2206
2243
  };
@@ -2419,6 +2456,9 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2419
2456
  var ele = this.element.querySelector('[pid=\'' + uID + '\']');
2420
2457
  this.curDSLevel.push(uID);
2421
2458
  this.setViewDataSource(this.getSubDS());
2459
+ if (this.enableVirtualization) {
2460
+ this.virtualizationModule.updateDOMItemCount();
2461
+ }
2422
2462
  if (!ele) {
2423
2463
  var data = this.curViewDS;
2424
2464
  ele = ListBase.createListFromJson(this.createElement, data, this.listBaseOption, this.curDSLevel.length, null, this);
@@ -2527,6 +2567,9 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2527
2567
  }
2528
2568
  this.curDSLevel.pop();
2529
2569
  this.setViewDataSource(this.getSubDS());
2570
+ if (this.enableVirtualization) {
2571
+ this.virtualizationModule.updateDOMItemCount();
2572
+ }
2530
2573
  var toUL = this.element.querySelector('[data-uid=\'' + pID + '\']');
2531
2574
  var fromUL = this.curUL;
2532
2575
  if (!toUL) {
@@ -3233,7 +3276,7 @@ var Virtualization = /** @__PURE__ @class */ (function () {
3233
3276
  this.listViewInstance.contentContainer.appendChild(this.listViewInstance.ulElement);
3234
3277
  this.listItemHeight = this.listViewInstance.ulElement.firstElementChild.getBoundingClientRect().height;
3235
3278
  this.expectedDomItemCount = this.ValidateItemCount(10000);
3236
- this.domItemCount = this.ValidateItemCount(Object.keys(this.listViewInstance.curViewDS).length);
3279
+ this.updateDOMItemCount();
3237
3280
  var lastIndex = isRendered && !isNullOrUndefined(this.uiLastIndex) ? this.uiLastIndex : this.domItemCount - 1;
3238
3281
  this.uiFirstIndex = firstIndex;
3239
3282
  this.uiLastIndex = lastIndex;
@@ -3295,6 +3338,9 @@ var Virtualization = /** @__PURE__ @class */ (function () {
3295
3338
  }
3296
3339
  return itemCount;
3297
3340
  };
3341
+ Virtualization.prototype.updateDOMItemCount = function () {
3342
+ this.domItemCount = this.ValidateItemCount(Object.keys(this.listViewInstance.curViewDS).length);
3343
+ };
3298
3344
  Virtualization.prototype.uiIndicesInitialization = function () {
3299
3345
  this.uiIndices = { 'activeIndices': [], 'disabledItemIndices': [], 'hiddenItemIndices': [] };
3300
3346
  var data = this.listViewInstance.curViewDS;
@@ -3594,18 +3640,19 @@ var Virtualization = /** @__PURE__ @class */ (function () {
3594
3640
  }
3595
3641
  };
3596
3642
  Virtualization.prototype.selectItem = function (obj) {
3643
+ var _this = this;
3597
3644
  var resutJSON = this.findDSAndIndexFromId(this.listViewInstance.curViewDS, obj);
3598
3645
  if (Object.keys(resutJSON).length) {
3599
3646
  var isSelected = this.activeIndex === resutJSON.index;
3600
- var isChecked = void 0;
3647
+ var isChecked_1;
3601
3648
  this.activeIndex = resutJSON.index;
3602
3649
  if (this.listViewInstance.showCheckBox) {
3603
3650
  if (this.uiIndices.activeIndices.indexOf(resutJSON.index) === -1) {
3604
- isChecked = true;
3651
+ isChecked_1 = true;
3605
3652
  this.uiIndices.activeIndices.push(resutJSON.index);
3606
3653
  }
3607
3654
  else {
3608
- isChecked = false;
3655
+ isChecked_1 = false;
3609
3656
  this.uiIndices.activeIndices.splice(this.uiIndices.activeIndices.indexOf(resutJSON.index), 1);
3610
3657
  }
3611
3658
  if (this.listViewInstance.curUL.querySelector('.' + classNames.focused)) {
@@ -3621,10 +3668,10 @@ var Virtualization = /** @__PURE__ @class */ (function () {
3621
3668
  }
3622
3669
  }
3623
3670
  else {
3624
- var eventArgs = void 0;
3671
+ var eventArgs_1;
3625
3672
  if (typeof this.listViewInstance.dataSource[0] === 'string' ||
3626
3673
  typeof this.listViewInstance.dataSource[0] === 'number') {
3627
- eventArgs = {
3674
+ eventArgs_1 = {
3628
3675
  text: this.listViewInstance.curViewDS[this.activeIndex],
3629
3676
  data: this.listViewInstance.curViewDS[this.activeIndex],
3630
3677
  index: this.activeIndex
@@ -3632,19 +3679,33 @@ var Virtualization = /** @__PURE__ @class */ (function () {
3632
3679
  }
3633
3680
  else {
3634
3681
  var curViewDS = this.listViewInstance.curViewDS;
3635
- eventArgs = {
3682
+ eventArgs_1 = {
3636
3683
  text: curViewDS[this.activeIndex][this.listViewInstance.fields.text],
3637
3684
  data: curViewDS[this.activeIndex],
3638
3685
  index: this.activeIndex
3639
3686
  };
3640
3687
  }
3641
3688
  if (this.listViewInstance.showCheckBox) {
3642
- eventArgs.isChecked = isChecked;
3643
- this.listViewInstance.trigger('select', eventArgs);
3689
+ this.listViewInstance.trigger('select', eventArgs_1, function (observedArgs) {
3690
+ if (observedArgs.cancel) {
3691
+ if (!isChecked_1) {
3692
+ eventArgs_1.isChecked = isChecked_1;
3693
+ _this.uiIndices.activeIndices.push(resutJSON.index);
3694
+ }
3695
+ else {
3696
+ eventArgs_1.isChecked = !isChecked_1;
3697
+ _this.uiIndices.activeIndices.splice(_this.uiIndices.activeIndices.indexOf(resutJSON.index), 1);
3698
+ }
3699
+ }
3700
+ });
3644
3701
  }
3645
3702
  else if (!isSelected) {
3646
3703
  this.listViewInstance.removeSelect();
3647
- this.listViewInstance.trigger('select', eventArgs);
3704
+ this.listViewInstance.trigger('select', eventArgs_1, function (observedArgs) {
3705
+ if (observedArgs.cancel) {
3706
+ _this.activeIndex = undefined;
3707
+ }
3708
+ });
3648
3709
  }
3649
3710
  }
3650
3711
  }