@syncfusion/ej2-lists 20.4.42 → 20.4.50

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.
@@ -1462,7 +1462,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1462
1462
  this.currentLiElements = [];
1463
1463
  this.isNestedList = false;
1464
1464
  this.selectedData = [];
1465
- this.selectedId = [];
1465
+ this.selectedId = this.enablePersistence ? this.selectedId : [];
1466
1466
  this.LISTVIEW_TEMPLATE_ID = "" + this.element.id + LISTVIEW_TEMPLATE_PROPERTY;
1467
1467
  this.LISTVIEW_GROUPTEMPLATE_ID = "" + this.element.id + LISTVIEW_GROUPTEMPLATE_PROPERTY;
1468
1468
  this.LISTVIEW_HEADERTEMPLATE_ID = "" + this.element.id + LISTVIEW_HEADERTEMPLATE_PROPERTY;
@@ -1474,12 +1474,13 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1474
1474
  this.curUL = this.ulElement = this.liCollection = this.headerEle = this.contentContainer = undefined;
1475
1475
  };
1476
1476
  ListView.prototype.renderCheckbox = function (args) {
1477
+ var _this = this;
1477
1478
  if (args.item.classList.contains(classNames.hasChild)) {
1478
1479
  this.isNestedList = true;
1479
1480
  }
1480
1481
  if (this.showCheckBox && this.isValidLI(args.item)) {
1481
1482
  var checkboxElement = void 0;
1482
- var fieldData = void 0;
1483
+ var fieldData_1;
1483
1484
  // eslint-disable-next-line prefer-const
1484
1485
  checkboxElement = createCheckBox(this.createElement, false, {
1485
1486
  checked: false, enableRtl: this.enableRtl,
@@ -1490,8 +1491,14 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1490
1491
  args.item.classList.add(classNames.itemCheckList);
1491
1492
  args.item.firstElementChild.classList.add(classNames.checkbox);
1492
1493
  if (typeof this.dataSource[0] !== 'string' && typeof this.dataSource[0] !== 'number') {
1493
- fieldData = getFieldValues(args.curData, this.listBaseOption.fields);
1494
- if (fieldData[this.listBaseOption.fields.isChecked]) {
1494
+ fieldData_1 = getFieldValues(args.curData, this.listBaseOption.fields);
1495
+ if (this.enablePersistence && !isNullOrUndefined(this.selectedId)) {
1496
+ var index = this.selectedId.findIndex(function (e) { return e == fieldData_1[_this.listBaseOption.fields.id].toString(); });
1497
+ if (index != -1) {
1498
+ this.checkInternally(args, checkboxElement);
1499
+ }
1500
+ }
1501
+ else if (fieldData_1[this.listBaseOption.fields.isChecked]) {
1495
1502
  this.checkInternally(args, checkboxElement);
1496
1503
  }
1497
1504
  }
@@ -1556,6 +1563,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1556
1563
  checkboxIcon.parentElement.setAttribute('aria-checked', checked ? 'true' : 'false');
1557
1564
  }
1558
1565
  this.setSelectedItemData(liElement);
1566
+ this.updateSelectedId();
1559
1567
  }
1560
1568
  };
1561
1569
  /**
@@ -1598,6 +1606,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1598
1606
  if (this.enableVirtualization) {
1599
1607
  this.virtualizationModule.checkedItem(checked);
1600
1608
  }
1609
+ this.updateSelectedId();
1601
1610
  }
1602
1611
  };
1603
1612
  ListView.prototype.setCheckbox = function () {
@@ -1713,6 +1722,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1713
1722
  }
1714
1723
  }
1715
1724
  }
1725
+ this.updateSelectedId();
1716
1726
  };
1717
1727
  ListView.prototype.removeElement = function (element) {
1718
1728
  return element && element.parentNode && element.parentNode.removeChild(element);
@@ -1902,6 +1912,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
1902
1912
  var eventArgs = this.selectEventData(li, e);
1903
1913
  merge(eventArgs, { isChecked: checkIcon ? checkIcon.classList.contains(classNames.checked) : false });
1904
1914
  this.trigger('select', eventArgs);
1915
+ this.updateSelectedId();
1905
1916
  }
1906
1917
  };
1907
1918
  ListView.prototype.keyActionHandler = function (e) {
@@ -2373,7 +2384,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2373
2384
  if (this.enableVirtualization) {
2374
2385
  if (Object.keys(this.dataSource).length) {
2375
2386
  if ((this.template || this.groupTemplate) && !this.virtualizationModule.isNgTemplate()) {
2376
- if (this.isReact) {
2387
+ if (this.isReact || this.isVue) {
2377
2388
  if (typeof this.template == "string") {
2378
2389
  this.listBaseOption.template = null;
2379
2390
  }
@@ -2578,6 +2589,16 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
2578
2589
  }
2579
2590
  return parentId;
2580
2591
  };
2592
+ ListView.prototype.updateSelectedId = function () {
2593
+ this.selectedId = [];
2594
+ var liCollection = this.curUL.getElementsByClassName(classNames.selected);
2595
+ for (var i = 0; i < liCollection.length; i++) {
2596
+ var tempData = this.getItemData(liCollection[i]);
2597
+ if (tempData[this.listBaseOption.fields.id]) {
2598
+ this.selectedId.push(tempData[this.listBaseOption.fields.id]);
2599
+ }
2600
+ }
2601
+ };
2581
2602
  /**
2582
2603
  * Gets the details of the currently selected item from the list items.
2583
2604
  *
@@ -3009,7 +3030,7 @@ var ListView = /** @__PURE__ @class */ (function (_super) {
3009
3030
  ListView.prototype.getPersistData = function () {
3010
3031
  return this.addOnPersist(['cssClass', 'enableRtl', 'htmlAttributes',
3011
3032
  'enable', 'fields', 'animation', 'headerTitle',
3012
- 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition']);
3033
+ 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition', 'selectedId']);
3013
3034
  };
3014
3035
  __decorate([
3015
3036
  Property('')
@@ -3104,6 +3125,14 @@ var Virtualization = /** @__PURE__ @class */ (function () {
3104
3125
  Virtualization.prototype.isNgTemplate = function () {
3105
3126
  return !isNullOrUndefined(this.listViewInstance.templateRef) && typeof this.listViewInstance.templateRef !== 'string';
3106
3127
  };
3128
+ /**
3129
+ * Checks if the platform is a Vue and its template property is a function type.
3130
+ *
3131
+ * @returns {boolean} indicating the result of the check
3132
+ */
3133
+ Virtualization.prototype.isVueFunctionTemplate = function () {
3134
+ return this.listViewInstance.isVue && typeof this.listViewInstance.template === 'function';
3135
+ };
3107
3136
  /**
3108
3137
  * For internal use only.
3109
3138
  *
@@ -3896,10 +3925,14 @@ var Virtualization = /** @__PURE__ @class */ (function () {
3896
3925
  this.listViewInstance.template = div.innerHTML;
3897
3926
  }
3898
3927
  }
3928
+ if (this.isVueFunctionTemplate())
3929
+ return;
3899
3930
  template.innerHTML = this.listViewInstance.template;
3900
3931
  this.listViewInstance.template = virtualTemplate;
3901
3932
  }
3902
3933
  else {
3934
+ if (this.isVueFunctionTemplate())
3935
+ return;
3903
3936
  template.innerHTML = this.listViewInstance.template || commonTemplate;
3904
3937
  }
3905
3938
  // eslint-disable-next-line
@@ -4182,7 +4215,7 @@ var Virtualization = /** @__PURE__ @class */ (function () {
4182
4215
  };
4183
4216
  Virtualization.prototype.updateUI = function (element, index, targetElement) {
4184
4217
  // eslint-disable-next-line @typescript-eslint/ban-types
4185
- var onChange = this.isNgTemplate() ? this.onNgChange : this.onChange;
4218
+ var onChange = this.isNgTemplate() ? this.onNgChange : (this.isVueFunctionTemplate()) ? this.onVuechange : this.onChange;
4186
4219
  if (this.listViewInstance.template || this.listViewInstance.groupTemplate) {
4187
4220
  var curViewDS = this.listViewInstance.curViewDS[index];
4188
4221
  // eslint-disable-next-line
@@ -4199,6 +4232,22 @@ var Virtualization = /** @__PURE__ @class */ (function () {
4199
4232
  this.listViewInstance.ulElement.insertBefore(element, targetElement);
4200
4233
  }
4201
4234
  };
4235
+ /**
4236
+ * Handles the UI change in vue for the list view.
4237
+ *
4238
+ * @param {DataSource} newData - The new data source for the list view.
4239
+ * @param {ElementContext} listElement - The HTML element context for the list view.
4240
+ * @param {Virtualization} virtualThis - The virtualization context for the list view.
4241
+ */
4242
+ Virtualization.prototype.onVuechange = function (newData, listElement, virtualThis) {
4243
+ var liItem = ListBase.createListItemFromJson(virtualThis.listViewInstance.createElement,
4244
+ // eslint-disable-next-line
4245
+ [newData], virtualThis.listViewInstance.listBaseOption, null, null, virtualThis.listViewInstance);
4246
+ while (listElement.lastChild) {
4247
+ listElement.removeChild(listElement.lastChild);
4248
+ }
4249
+ listElement.appendChild(liItem[0].firstChild);
4250
+ };
4202
4251
  Virtualization.prototype.onNgChange = function (newData, listElement, virtualThis) {
4203
4252
  // compile given target element with template for new data
4204
4253
  // eslint-disable-next-line
@@ -4450,7 +4499,7 @@ var Sortable = /** @__PURE__ @class */ (function (_super) {
4450
4499
  _this.target = null;
4451
4500
  _this.curTarget = null;
4452
4501
  remove(e.helper);
4453
- getComponent(_this.element, Draggable).intDestroy(e.event);
4502
+ getComponent(_this.element, 'draggable').intDestroy(e.event);
4454
4503
  };
4455
4504
  _this.bind();
4456
4505
  return _this;