@one-paragon/angular-utilities 2.4.2 → 2.4.3

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.
@@ -4509,7 +4509,11 @@ class GenericTableComponent {
4509
4509
  const trackBy = this.$trackBy();
4510
4510
  if (!trackBy)
4511
4511
  return (index, item) => isGroupHeader(item) ? `${item.level}-${item[initIndexSymbol]}` : item[initIndexSymbol];
4512
- return ((index, item) => isGroupHeader(item) ? `${item.level}-${item[initIndexSymbol]}` : item[trackBy]);
4512
+ return ((index, item) => {
4513
+ if (isGroupHeader(item))
4514
+ return `${item.level}-${item[initIndexSymbol]}`;
4515
+ return typeof trackBy === 'function' ? trackBy(item) : item[trackBy];
4516
+ });
4513
4517
  });
4514
4518
  this.$hasFooterMeta = computed(() => this.state.$metaDataArray().some(md => !!md.additional?.footer));
4515
4519
  this.$hasCustomFooter = computed(() => this.$columnInfos()?.some(ci => !!ci.customCell?.columnDef?.footerCell));
@@ -4603,7 +4607,8 @@ class GenericTableComponent {
4603
4607
  this.$selection = computed(() => {
4604
4608
  const trackBy = this.$trackBy();
4605
4609
  if (trackBy) {
4606
- return new SelectionModel(true, [], true, (a, b) => a[trackBy] === b[trackBy]);
4610
+ const trackByFn = typeof trackBy === 'function' ? trackBy : (item) => item[trackBy];
4611
+ return new SelectionModel(true, [], true, (a, b) => trackByFn(a) === trackByFn(b));
4607
4612
  }
4608
4613
  return new SelectionModel(true, []);
4609
4614
  });
@@ -4662,7 +4667,12 @@ class GenericTableComponent {
4662
4667
  if (!selected.length)
4663
4668
  return;
4664
4669
  const trackBy = this.$trackBy();
4665
- const trackByFunc = trackBy ? (s) => selectableData.every(d => d[trackBy] !== s[trackBy]) : s => !selectableData.includes(s);
4670
+ const trackByFunc = trackBy ?
4671
+ (s) => {
4672
+ const trackByFn = typeof trackBy === 'function' ? trackBy : (item) => item[trackBy];
4673
+ return selectableData.every(d => trackByFn(d) !== trackByFn(s));
4674
+ }
4675
+ : s => !selectableData.includes(s);
4666
4676
  const removed = selected.filter(trackByFunc);
4667
4677
  this.$selection().deselect(...removed);
4668
4678
  });