@shival99/z-ui 1.7.12 → 1.7.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.
@@ -3166,6 +3166,14 @@ class ZTableComponent {
3166
3166
  overscan: virtual.overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3167
3167
  groupSize: virtual.groupSize ?? Z_DEFAULT_GROUP_SIZE,
3168
3168
  dynamicSize: virtual.dynamicSize ?? false,
3169
+ // TanStack Virtual options
3170
+ initialOffset: virtual.initialOffset,
3171
+ scrollMargin: virtual.scrollMargin,
3172
+ gap: virtual.gap,
3173
+ isScrollingResetDelay: virtual.isScrollingResetDelay,
3174
+ useScrollendEvent: virtual.useScrollendEvent,
3175
+ getItemKey: virtual.getItemKey,
3176
+ rangeExtractor: virtual.rangeExtractor,
3169
3177
  };
3170
3178
  }, ...(ngDevMode ? [{ debugName: "_virtualConfig" }] : []));
3171
3179
  virtualRowHeight = computed(() => this._virtualConfig().size ?? Z_DEFAULT_ROW_HEIGHT, ...(ngDevMode ? [{ debugName: "virtualRowHeight" }] : []));
@@ -3547,11 +3555,14 @@ class ZTableComponent {
3547
3555
  const totalRows = untracked(() => this.table.getRowModel().rows.length);
3548
3556
  return Math.ceil(totalRows / this.groupSize());
3549
3557
  }, ...(ngDevMode ? [{ debugName: "_virtualGroupCount" }] : []));
3558
+ _virtualResetVersion = signal(0, ...(ngDevMode ? [{ debugName: "_virtualResetVersion" }] : []));
3550
3559
  virtualizer = injectVirtualizer(() => {
3560
+ this._virtualResetVersion();
3551
3561
  const groups = this.dynamicGroups();
3552
3562
  const rowHeight = this.virtualRowHeight();
3553
3563
  const groupSize = this.groupSize();
3554
3564
  const scrollElement = this.tbodyWrapper()?.nativeElement;
3565
+ const virtualConfig = this._virtualConfig();
3555
3566
  return {
3556
3567
  scrollElement,
3557
3568
  count: groups.length > 0 ? groups.length : this._virtualGroupCount(),
@@ -3566,7 +3577,16 @@ class ZTableComponent {
3566
3577
  return groupSize * rowHeight;
3567
3578
  },
3568
3579
  measureElement: (element) => element.getBoundingClientRect().height,
3569
- overscan: this._virtualConfig().overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3580
+ overscan: virtualConfig.overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3581
+ initialOffset: virtualConfig.initialOffset ?? 0,
3582
+ ...(virtualConfig.scrollMargin !== undefined && { scrollMargin: virtualConfig.scrollMargin }),
3583
+ ...(virtualConfig.gap !== undefined && { gap: virtualConfig.gap }),
3584
+ ...(virtualConfig.isScrollingResetDelay !== undefined && {
3585
+ isScrollingResetDelay: virtualConfig.isScrollingResetDelay,
3586
+ }),
3587
+ ...(virtualConfig.useScrollendEvent !== undefined && { useScrollendEvent: virtualConfig.useScrollendEvent }),
3588
+ ...(virtualConfig.getItemKey !== undefined && { getItemKey: virtualConfig.getItemKey }),
3589
+ ...(virtualConfig.rangeExtractor !== undefined && { rangeExtractor: virtualConfig.rangeExtractor }),
3570
3590
  };
3571
3591
  });
3572
3592
  _measureVirtualItems = effect(() => {
@@ -3706,6 +3726,8 @@ class ZTableComponent {
3706
3726
  this.virtualizer.scrollToOffset(0);
3707
3727
  // Force recalculate dynamic groups immediately
3708
3728
  this._dynamicGroupsVersion.update(v => v + 1);
3729
+ // Force virtualizer to reset with initialOffset: 0
3730
+ this._virtualResetVersion.update(v => v + 1);
3709
3731
  }
3710
3732
  queueMicrotask(() => {
3711
3733
  this._checkVerticalScroll();
@@ -3741,6 +3763,7 @@ class ZTableComponent {
3741
3763
  if (this.isVirtual()) {
3742
3764
  this.virtualizer.scrollToOffset(0);
3743
3765
  this._dynamicGroupsVersion.update(v => v + 1);
3766
+ this._virtualResetVersion.update(v => v + 1);
3744
3767
  }
3745
3768
  this._checkScrollState();
3746
3769
  });