@syncfusion/ej2-lists 24.2.4 → 25.1.35

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.
@@ -301,7 +301,7 @@ var ListBase;
301
301
  if (fieldData.hasOwnProperty(fields.htmlAttributes) && fieldData[fields.htmlAttributes]) {
302
302
  const htmlAttributes = fieldData[fields.htmlAttributes];
303
303
  // Check if 'class' attribute is present and not an empty string
304
- if (htmlAttributes.hasOwnProperty('class') && typeof htmlAttributes['class'] === 'string' && htmlAttributes['class'].trim() === '') {
304
+ if ('class' in htmlAttributes && typeof htmlAttributes['class'] === 'string' && htmlAttributes['class'].trim() === '') {
305
305
  delete htmlAttributes['class'];
306
306
  }
307
307
  setAttribute(li, htmlAttributes);
@@ -1475,7 +1475,7 @@ let ListView = class ListView extends Component {
1475
1475
  if (typeof this.dataSource[0] !== 'string' && typeof this.dataSource[0] !== 'number') {
1476
1476
  fieldData = getFieldValues(args.curData, this.listBaseOption.fields);
1477
1477
  if (this.enablePersistence && !isNullOrUndefined(this.selectedId)) {
1478
- const index = this.selectedId.findIndex(e => e === fieldData[this.listBaseOption.fields.id].toString());
1478
+ const index = this.selectedId.findIndex((e) => e === fieldData[this.listBaseOption.fields.id].toString());
1479
1479
  if (index !== -1) {
1480
1480
  this.checkInternally(args, checkboxElement);
1481
1481
  }
@@ -1960,11 +1960,13 @@ let ListView = class ListView extends Component {
1960
1960
  }
1961
1961
  }
1962
1962
  unWireEvents() {
1963
+ EventHandler.remove(this.element, 'keydown', this.keyActionHandler);
1963
1964
  EventHandler.remove(this.element, 'click', this.clickHandler);
1964
1965
  EventHandler.remove(this.element, 'mouseover', this.hoverHandler);
1965
1966
  EventHandler.remove(this.element, 'mouseout', this.leaveHandler);
1966
1967
  EventHandler.remove(this.element, 'mouseover', this.hoverHandler);
1967
1968
  EventHandler.remove(this.element, 'mouseout', this.leaveHandler);
1969
+ EventHandler.remove(this.element, 'focusout', this.focusout);
1968
1970
  if (!isNullOrUndefined(this.scroll)) {
1969
1971
  EventHandler.remove(this.element, 'scroll', this.onListScroll);
1970
1972
  }
@@ -2058,7 +2060,12 @@ let ListView = class ListView extends Component {
2058
2060
  const eventArgs = {};
2059
2061
  merge(eventArgs, selectedItem);
2060
2062
  if (e) {
2061
- merge(eventArgs, { isInteracted: true, event: e, cancel: false, index: this.curUL && Array.prototype.indexOf.call(this.curUL.children, li) });
2063
+ merge(eventArgs, {
2064
+ isInteracted: true,
2065
+ event: e,
2066
+ cancel: false,
2067
+ index: this.curUL && Array.prototype.indexOf.call(this.curUL.children, li)
2068
+ });
2062
2069
  }
2063
2070
  return eventArgs;
2064
2071
  }
@@ -2488,6 +2495,22 @@ let ListView = class ListView extends Component {
2488
2495
  }
2489
2496
  }
2490
2497
  }
2498
+ /**
2499
+ * This method allows for deselecting a list item within the ListView. The item to be deselected can be specified by passing the element or field object.
2500
+ *
2501
+ * @param {Fields | HTMLElement | Element} item - We can pass an element Object or Fields as an Object with ID and Text fields.
2502
+ */
2503
+ unselectItem(item) {
2504
+ if (isNullOrUndefined(item)) {
2505
+ this.removeSelect();
2506
+ }
2507
+ else {
2508
+ const li = this.getLiFromObjOrElement(item);
2509
+ if (!isNullOrUndefined(li)) {
2510
+ this.removeSelect(li);
2511
+ }
2512
+ }
2513
+ }
2491
2514
  getLiFromObjOrElement(obj) {
2492
2515
  let li;
2493
2516
  const dataSource = this.dataSource instanceof DataManager ?
@@ -2981,7 +3004,7 @@ let ListView = class ListView extends Component {
2981
3004
  requiredModules() {
2982
3005
  const modules = [];
2983
3006
  if (this.enableVirtualization) {
2984
- modules.push({ args: [this], member: 'virtualization' });
3007
+ modules.push({ args: [this], member: 'virtualization', name: 'Virtualization' });
2985
3008
  }
2986
3009
  return modules;
2987
3010
  }
@@ -3052,7 +3075,7 @@ __decorate([
3052
3075
  Property(false)
3053
3076
  ], ListView.prototype, "showHeader", void 0);
3054
3077
  __decorate([
3055
- Property(false)
3078
+ Property(true)
3056
3079
  ], ListView.prototype, "enableHtmlSanitizer", void 0);
3057
3080
  __decorate([
3058
3081
  Property('')
@@ -3343,9 +3366,10 @@ class Virtualization {
3343
3366
  }
3344
3367
  if (this.listViewInstance.curViewDS[index][this.listViewInstance.fields.iconCss]) {
3345
3368
  const textContent = element.querySelector('.' + classNames.textContent);
3369
+ const curViewDS = this.listViewInstance.curViewDS[index];
3370
+ const iconCss = curViewDS[this.listViewInstance.fields.iconCss].toString();
3346
3371
  const target = this.listViewInstance.createElement('div', {
3347
- className: classNames.listIcon + ' ' +
3348
- this.listViewInstance.curViewDS[index][this.listViewInstance.fields.iconCss]
3372
+ className: classNames.listIcon + ' ' + iconCss
3349
3373
  });
3350
3374
  textContent.insertBefore(target, element.querySelector('.' + classNames.listItemText));
3351
3375
  }
@@ -3856,7 +3880,9 @@ class Virtualization {
3856
3880
  target = this.listViewInstance.getLiFromObjOrElement(this.listViewInstance.curViewDS[index + 1]) ||
3857
3881
  this.listViewInstance.getLiFromObjOrElement(this.listViewInstance.curViewDS[index + 2]);
3858
3882
  }
3859
- if (this.listViewInstance.fields.groupBy && this.listViewInstance.curViewDS[index + 1] && this.listViewInstance.curViewDS[index + 1].isHeader) {
3883
+ if (this.listViewInstance.fields.groupBy
3884
+ && this.listViewInstance.curViewDS[index + 1]
3885
+ && this.listViewInstance.curViewDS[index + 1].isHeader) {
3860
3886
  const targetEle = this.listViewInstance.getLiFromObjOrElement(this.listViewInstance.curViewDS[index - 1]);
3861
3887
  if (targetEle) {
3862
3888
  target = targetEle.nextElementSibling;
@@ -3909,7 +3935,7 @@ class Virtualization {
3909
3935
  while (args.item.lastChild) {
3910
3936
  args.item.removeChild(args.item.lastChild);
3911
3937
  }
3912
- [].slice.call(div.children).forEach(function (ele) {
3938
+ [].slice.call(div.children).forEach((ele) => {
3913
3939
  args.item.appendChild(ele);
3914
3940
  });
3915
3941
  }
@@ -3953,6 +3979,7 @@ class Virtualization {
3953
3979
  * @param {DataSource} newData - The new data source for the list view.
3954
3980
  * @param {ElementContext} listElement - The HTML element context for the list view.
3955
3981
  * @param {Virtualization} virtualThis - The virtualization context for the list view.
3982
+ * @returns {void}
3956
3983
  */
3957
3984
  onChange(newData, listElement, virtualThis) {
3958
3985
  const liItem = ListBase.createListItemFromJson(virtualThis.listViewInstance.createElement,
@@ -3964,7 +3991,7 @@ class Virtualization {
3964
3991
  while (listElement.lastChild) {
3965
3992
  listElement.removeChild(listElement.lastChild);
3966
3993
  }
3967
- [].slice.call(liItem[0].children).forEach(function (ele) {
3994
+ [].slice.call(liItem[0].children).forEach((ele) => {
3968
3995
  listElement.appendChild(ele);
3969
3996
  });
3970
3997
  }
@@ -4048,7 +4075,7 @@ let Sortable = Sortable_1 = class Sortable extends Base {
4048
4075
  this.trigger('drag', { event: e.event, element: this.element, target: e.target });
4049
4076
  let newInst = this.getSortableInstance(e.target);
4050
4077
  let target = this.getSortableElement(e.target, newInst);
4051
- if ((this.isValidTarget(target, newInst) || e.target.className.indexOf('e-list-group-item') > -1) && (this.curTarget !== target ||
4078
+ if ((this.isValidTarget(target, newInst) || (e.target && typeof e.target.className === 'string' && e.target.className.indexOf('e-list-group-item') > -1)) && (this.curTarget !== target ||
4052
4079
  !isNullOrUndefined(newInst.placeHolder)) && (newInst.placeHolderElement ? newInst.placeHolderElement !== e.target : true)) {
4053
4080
  if (e.target.classList.contains('e-list-group-item')) {
4054
4081
  target = e.target;
@@ -4189,7 +4216,7 @@ let Sortable = Sortable_1 = class Sortable extends Base {
4189
4216
  target: e.target, droppedElement: this.target, helper: e.helper, cancel: false
4190
4217
  };
4191
4218
  this.trigger('beforeDrop', beforeDropArgs, (observedArgs) => {
4192
- if ((dropInst.element === e.target || e.target.className.indexOf('e-list-nrt') > -1 || e.target.className.indexOf('e-list-nr-template') > -1
4219
+ if ((dropInst.element === e.target || (typeof e.target.className === 'string' && e.target.className.indexOf('e-list-nrt') > -1) || (typeof e.target.className === 'string' && e.target.className.indexOf('e-list-nr-template') > -1)
4193
4220
  || e.target.closest('.e-list-nr-template')) && !observedArgs.cancel) {
4194
4221
  this.updateItemClass(dropInst);
4195
4222
  dropInst.element.appendChild(this.target);