@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.
@@ -1698,6 +1698,28 @@ let ListView = class ListView extends Component {
1698
1698
  this.virtualizationModule.refreshItemHeight();
1699
1699
  }
1700
1700
  }
1701
+ handleCheckboxState(li, checkIcon, checkboxElement, isCheckedBefore, isFocusedBefore, eventArgs, isSetCheckboxLI, textAreaFocus) {
1702
+ this.trigger('select', eventArgs, (observedArgs) => {
1703
+ if (observedArgs.cancel) {
1704
+ if (isSetCheckboxLI ? isCheckedBefore : !isCheckedBefore) {
1705
+ checkIcon.classList.add(classNames.checked);
1706
+ li.classList.add(classNames.selected);
1707
+ }
1708
+ else {
1709
+ checkIcon.classList.remove(classNames.checked);
1710
+ li.classList.remove(classNames.selected);
1711
+ }
1712
+ checkboxElement.setAttribute('aria-checked', isSetCheckboxLI ? (isCheckedBefore ? 'true' : 'false') : (isCheckedBefore ? 'false' : 'true'));
1713
+ merge(eventArgs, { isChecked: checkIcon.classList.contains(classNames.checked) });
1714
+ if (isFocusedBefore) {
1715
+ li.classList.remove(classNames.focused);
1716
+ if (textAreaFocus) {
1717
+ textAreaFocus.classList.remove('e-focused');
1718
+ }
1719
+ }
1720
+ }
1721
+ });
1722
+ }
1701
1723
  clickHandler(e) {
1702
1724
  if (Array.isArray(this.dataSource) && this.dataSource.length === 0) {
1703
1725
  return;
@@ -1739,7 +1761,10 @@ let ListView = class ListView extends Component {
1739
1761
  const eventArgs = this.selectEventData(li, e);
1740
1762
  const checkIcon = li.querySelector('.' + classNames.checkboxIcon);
1741
1763
  merge(eventArgs, { isChecked: checkIcon.classList.contains(classNames.checked) });
1742
- this.trigger('select', eventArgs);
1764
+ const checkboxElement = li.querySelector('.' + classNames.checkboxWrapper);
1765
+ const isCheckedBefore = checkIcon.classList.contains(classNames.checked);
1766
+ const isFocusedBefore = li.classList.contains(classNames.focused);
1767
+ this.handleCheckboxState(li, checkIcon, checkboxElement, isCheckedBefore, isFocusedBefore, eventArgs, false);
1743
1768
  }
1744
1769
  }
1745
1770
  else if (li.classList.contains(classNames.hasChild)) {
@@ -1959,7 +1984,13 @@ let ListView = class ListView extends Component {
1959
1984
  }
1960
1985
  const eventArgs = this.selectEventData(li, e);
1961
1986
  merge(eventArgs, { isChecked: checkIcon ? checkIcon.classList.contains(classNames.checked) : false });
1962
- this.trigger('select', eventArgs);
1987
+ if (!isNullOrUndefined(li)) {
1988
+ const cbElement = li.querySelector('.' + classNames.checkboxWrapper);
1989
+ const checkboxIcon = li.querySelector('.' + classNames.checkboxIcon);
1990
+ const isCheckedBefore = checkboxIcon.classList.contains(classNames.checked);
1991
+ const isFocusedBefore = li.classList.contains(classNames.focused);
1992
+ this.handleCheckboxState(li, checkboxIcon, cbElement, isCheckedBefore, isFocusedBefore, eventArgs, false);
1993
+ }
1963
1994
  this.updateSelectedId();
1964
1995
  }
1965
1996
  }
@@ -2087,7 +2118,9 @@ let ListView = class ListView extends Component {
2087
2118
  const checkboxElement = li.querySelector('.' + classNames.checkboxWrapper);
2088
2119
  const checkIcon = checkboxElement.querySelector('.' + classNames.checkboxIcon + '.' + classNames.icon);
2089
2120
  this.removeHover();
2090
- if (!checkIcon.classList.contains(classNames.checked)) {
2121
+ const isCheckedBefore = checkIcon.classList.contains(classNames.checked);
2122
+ const isFocusedBefore = li.classList.contains(classNames.focused);
2123
+ if (!isCheckedBefore) {
2091
2124
  checkIcon.classList.add(classNames.checked);
2092
2125
  li.classList.add(classNames.selected);
2093
2126
  }
@@ -2102,7 +2135,7 @@ let ListView = class ListView extends Component {
2102
2135
  if (this.enableVirtualization) {
2103
2136
  this.virtualizationModule.setCheckboxLI(li, e);
2104
2137
  }
2105
- this.trigger('select', eventArgs);
2138
+ this.handleCheckboxState(li, checkIcon, checkboxElement, isCheckedBefore, isFocusedBefore, eventArgs, true, textAreaFocus);
2106
2139
  this.setSelectedItemData(li);
2107
2140
  this.renderSubList(li);
2108
2141
  }
@@ -2170,6 +2203,10 @@ let ListView = class ListView extends Component {
2170
2203
  this.selectedLI = li;
2171
2204
  this.renderSubList(li);
2172
2205
  }
2206
+ else {
2207
+ li.classList.remove(classNames.selected);
2208
+ this.selectedLI = li;
2209
+ }
2173
2210
  });
2174
2211
  }
2175
2212
  }
@@ -2383,6 +2420,9 @@ let ListView = class ListView extends Component {
2383
2420
  let ele = this.element.querySelector('[pid=\'' + uID + '\']');
2384
2421
  this.curDSLevel.push(uID);
2385
2422
  this.setViewDataSource(this.getSubDS());
2423
+ if (this.enableVirtualization) {
2424
+ this.virtualizationModule.updateDOMItemCount();
2425
+ }
2386
2426
  if (!ele) {
2387
2427
  const data = this.curViewDS;
2388
2428
  ele = ListBase.createListFromJson(this.createElement, data, this.listBaseOption, this.curDSLevel.length, null, this);
@@ -2491,6 +2531,9 @@ let ListView = class ListView extends Component {
2491
2531
  }
2492
2532
  this.curDSLevel.pop();
2493
2533
  this.setViewDataSource(this.getSubDS());
2534
+ if (this.enableVirtualization) {
2535
+ this.virtualizationModule.updateDOMItemCount();
2536
+ }
2494
2537
  let toUL = this.element.querySelector('[data-uid=\'' + pID + '\']');
2495
2538
  const fromUL = this.curUL;
2496
2539
  if (!toUL) {
@@ -3194,7 +3237,7 @@ class Virtualization {
3194
3237
  this.listViewInstance.contentContainer.appendChild(this.listViewInstance.ulElement);
3195
3238
  this.listItemHeight = this.listViewInstance.ulElement.firstElementChild.getBoundingClientRect().height;
3196
3239
  this.expectedDomItemCount = this.ValidateItemCount(10000);
3197
- this.domItemCount = this.ValidateItemCount(Object.keys(this.listViewInstance.curViewDS).length);
3240
+ this.updateDOMItemCount();
3198
3241
  const lastIndex = isRendered && !isNullOrUndefined(this.uiLastIndex) ? this.uiLastIndex : this.domItemCount - 1;
3199
3242
  this.uiFirstIndex = firstIndex;
3200
3243
  this.uiLastIndex = lastIndex;
@@ -3256,6 +3299,9 @@ class Virtualization {
3256
3299
  }
3257
3300
  return itemCount;
3258
3301
  }
3302
+ updateDOMItemCount() {
3303
+ this.domItemCount = this.ValidateItemCount(Object.keys(this.listViewInstance.curViewDS).length);
3304
+ }
3259
3305
  uiIndicesInitialization() {
3260
3306
  this.uiIndices = { 'activeIndices': [], 'disabledItemIndices': [], 'hiddenItemIndices': [] };
3261
3307
  const data = this.listViewInstance.curViewDS;
@@ -3593,12 +3639,26 @@ class Virtualization {
3593
3639
  };
3594
3640
  }
3595
3641
  if (this.listViewInstance.showCheckBox) {
3596
- eventArgs.isChecked = isChecked;
3597
- this.listViewInstance.trigger('select', eventArgs);
3642
+ this.listViewInstance.trigger('select', eventArgs, (observedArgs) => {
3643
+ if (observedArgs.cancel) {
3644
+ if (!isChecked) {
3645
+ eventArgs.isChecked = isChecked;
3646
+ this.uiIndices.activeIndices.push(resutJSON.index);
3647
+ }
3648
+ else {
3649
+ eventArgs.isChecked = !isChecked;
3650
+ this.uiIndices.activeIndices.splice(this.uiIndices.activeIndices.indexOf(resutJSON.index), 1);
3651
+ }
3652
+ }
3653
+ });
3598
3654
  }
3599
3655
  else if (!isSelected) {
3600
3656
  this.listViewInstance.removeSelect();
3601
- this.listViewInstance.trigger('select', eventArgs);
3657
+ this.listViewInstance.trigger('select', eventArgs, (observedArgs) => {
3658
+ if (observedArgs.cancel) {
3659
+ this.activeIndex = undefined;
3660
+ }
3661
+ });
3602
3662
  }
3603
3663
  }
3604
3664
  }