@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.
@@ -1436,7 +1436,7 @@ let ListView = class ListView extends Component {
1436
1436
  this.currentLiElements = [];
1437
1437
  this.isNestedList = false;
1438
1438
  this.selectedData = [];
1439
- this.selectedId = [];
1439
+ this.selectedId = this.enablePersistence ? this.selectedId : [];
1440
1440
  this.LISTVIEW_TEMPLATE_ID = `${this.element.id}${LISTVIEW_TEMPLATE_PROPERTY}`;
1441
1441
  this.LISTVIEW_GROUPTEMPLATE_ID = `${this.element.id}${LISTVIEW_GROUPTEMPLATE_PROPERTY}`;
1442
1442
  this.LISTVIEW_HEADERTEMPLATE_ID = `${this.element.id}${LISTVIEW_HEADERTEMPLATE_PROPERTY}`;
@@ -1465,7 +1465,13 @@ let ListView = class ListView extends Component {
1465
1465
  args.item.firstElementChild.classList.add(classNames.checkbox);
1466
1466
  if (typeof this.dataSource[0] !== 'string' && typeof this.dataSource[0] !== 'number') {
1467
1467
  fieldData = getFieldValues(args.curData, this.listBaseOption.fields);
1468
- if (fieldData[this.listBaseOption.fields.isChecked]) {
1468
+ if (this.enablePersistence && !isNullOrUndefined(this.selectedId)) {
1469
+ let index = this.selectedId.findIndex(e => e == fieldData[this.listBaseOption.fields.id].toString());
1470
+ if (index != -1) {
1471
+ this.checkInternally(args, checkboxElement);
1472
+ }
1473
+ }
1474
+ else if (fieldData[this.listBaseOption.fields.isChecked]) {
1469
1475
  this.checkInternally(args, checkboxElement);
1470
1476
  }
1471
1477
  }
@@ -1530,6 +1536,7 @@ let ListView = class ListView extends Component {
1530
1536
  checkboxIcon.parentElement.setAttribute('aria-checked', checked ? 'true' : 'false');
1531
1537
  }
1532
1538
  this.setSelectedItemData(liElement);
1539
+ this.updateSelectedId();
1533
1540
  }
1534
1541
  }
1535
1542
  /**
@@ -1572,6 +1579,7 @@ let ListView = class ListView extends Component {
1572
1579
  if (this.enableVirtualization) {
1573
1580
  this.virtualizationModule.checkedItem(checked);
1574
1581
  }
1582
+ this.updateSelectedId();
1575
1583
  }
1576
1584
  }
1577
1585
  setCheckbox() {
@@ -1687,6 +1695,7 @@ let ListView = class ListView extends Component {
1687
1695
  }
1688
1696
  }
1689
1697
  }
1698
+ this.updateSelectedId();
1690
1699
  }
1691
1700
  removeElement(element) {
1692
1701
  return element && element.parentNode && element.parentNode.removeChild(element);
@@ -1875,6 +1884,7 @@ let ListView = class ListView extends Component {
1875
1884
  const eventArgs = this.selectEventData(li, e);
1876
1885
  merge(eventArgs, { isChecked: checkIcon ? checkIcon.classList.contains(classNames.checked) : false });
1877
1886
  this.trigger('select', eventArgs);
1887
+ this.updateSelectedId();
1878
1888
  }
1879
1889
  }
1880
1890
  keyActionHandler(e) {
@@ -2338,7 +2348,7 @@ let ListView = class ListView extends Component {
2338
2348
  if (this.enableVirtualization) {
2339
2349
  if (Object.keys(this.dataSource).length) {
2340
2350
  if ((this.template || this.groupTemplate) && !this.virtualizationModule.isNgTemplate()) {
2341
- if (this.isReact) {
2351
+ if (this.isReact || this.isVue) {
2342
2352
  if (typeof this.template == "string") {
2343
2353
  this.listBaseOption.template = null;
2344
2354
  }
@@ -2543,6 +2553,16 @@ let ListView = class ListView extends Component {
2543
2553
  }
2544
2554
  return parentId;
2545
2555
  }
2556
+ updateSelectedId() {
2557
+ this.selectedId = [];
2558
+ const liCollection = this.curUL.getElementsByClassName(classNames.selected);
2559
+ for (let i = 0; i < liCollection.length; i++) {
2560
+ const tempData = this.getItemData(liCollection[i]);
2561
+ if (tempData[this.listBaseOption.fields.id]) {
2562
+ this.selectedId.push(tempData[this.listBaseOption.fields.id]);
2563
+ }
2564
+ }
2565
+ }
2546
2566
  /**
2547
2567
  * Gets the details of the currently selected item from the list items.
2548
2568
  *
@@ -2972,7 +2992,7 @@ let ListView = class ListView extends Component {
2972
2992
  getPersistData() {
2973
2993
  return this.addOnPersist(['cssClass', 'enableRtl', 'htmlAttributes',
2974
2994
  'enable', 'fields', 'animation', 'headerTitle',
2975
- 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition']);
2995
+ 'sortOrder', 'showIcon', 'height', 'width', 'showCheckBox', 'checkBoxPosition', 'selectedId']);
2976
2996
  }
2977
2997
  };
2978
2998
  __decorate([
@@ -3066,6 +3086,14 @@ class Virtualization {
3066
3086
  isNgTemplate() {
3067
3087
  return !isNullOrUndefined(this.listViewInstance.templateRef) && typeof this.listViewInstance.templateRef !== 'string';
3068
3088
  }
3089
+ /**
3090
+ * Checks if the platform is a Vue and its template property is a function type.
3091
+ *
3092
+ * @returns {boolean} indicating the result of the check
3093
+ */
3094
+ isVueFunctionTemplate() {
3095
+ return this.listViewInstance.isVue && typeof this.listViewInstance.template === 'function';
3096
+ }
3069
3097
  /**
3070
3098
  * For internal use only.
3071
3099
  *
@@ -3851,10 +3879,14 @@ class Virtualization {
3851
3879
  this.listViewInstance.template = div.innerHTML;
3852
3880
  }
3853
3881
  }
3882
+ if (this.isVueFunctionTemplate())
3883
+ return;
3854
3884
  template.innerHTML = this.listViewInstance.template;
3855
3885
  this.listViewInstance.template = virtualTemplate;
3856
3886
  }
3857
3887
  else {
3888
+ if (this.isVueFunctionTemplate())
3889
+ return;
3858
3890
  template.innerHTML = this.listViewInstance.template || commonTemplate;
3859
3891
  }
3860
3892
  // eslint-disable-next-line
@@ -4125,7 +4157,7 @@ class Virtualization {
4125
4157
  }
4126
4158
  updateUI(element, index, targetElement) {
4127
4159
  // eslint-disable-next-line @typescript-eslint/ban-types
4128
- const onChange = this.isNgTemplate() ? this.onNgChange : this.onChange;
4160
+ const onChange = this.isNgTemplate() ? this.onNgChange : (this.isVueFunctionTemplate()) ? this.onVuechange : this.onChange;
4129
4161
  if (this.listViewInstance.template || this.listViewInstance.groupTemplate) {
4130
4162
  const curViewDS = this.listViewInstance.curViewDS[index];
4131
4163
  // eslint-disable-next-line
@@ -4142,6 +4174,22 @@ class Virtualization {
4142
4174
  this.listViewInstance.ulElement.insertBefore(element, targetElement);
4143
4175
  }
4144
4176
  }
4177
+ /**
4178
+ * Handles the UI change in vue for the list view.
4179
+ *
4180
+ * @param {DataSource} newData - The new data source for the list view.
4181
+ * @param {ElementContext} listElement - The HTML element context for the list view.
4182
+ * @param {Virtualization} virtualThis - The virtualization context for the list view.
4183
+ */
4184
+ onVuechange(newData, listElement, virtualThis) {
4185
+ let liItem = ListBase.createListItemFromJson(virtualThis.listViewInstance.createElement,
4186
+ // eslint-disable-next-line
4187
+ [newData], virtualThis.listViewInstance.listBaseOption, null, null, virtualThis.listViewInstance);
4188
+ while (listElement.lastChild) {
4189
+ listElement.removeChild(listElement.lastChild);
4190
+ }
4191
+ listElement.appendChild(liItem[0].firstChild);
4192
+ }
4145
4193
  onNgChange(newData, listElement, virtualThis) {
4146
4194
  // compile given target element with template for new data
4147
4195
  // eslint-disable-next-line
@@ -4379,7 +4427,7 @@ let Sortable = Sortable_1 = class Sortable extends Base {
4379
4427
  this.target = null;
4380
4428
  this.curTarget = null;
4381
4429
  remove(e.helper);
4382
- getComponent(this.element, Draggable).intDestroy(e.event);
4430
+ getComponent(this.element, 'draggable').intDestroy(e.event);
4383
4431
  };
4384
4432
  this.bind();
4385
4433
  }