@shival99/z-ui 1.7.15 → 1.7.16

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,13 @@ 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
+ initialOffset: virtual.initialOffset,
3170
+ scrollMargin: virtual.scrollMargin,
3171
+ gap: virtual.gap,
3172
+ isScrollingResetDelay: virtual.isScrollingResetDelay,
3173
+ useScrollendEvent: virtual.useScrollendEvent,
3174
+ getItemKey: virtual.getItemKey,
3175
+ rangeExtractor: virtual.rangeExtractor,
3169
3176
  };
3170
3177
  }, ...(ngDevMode ? [{ debugName: "_virtualConfig" }] : []));
3171
3178
  virtualRowHeight = computed(() => this._virtualConfig().size ?? Z_DEFAULT_ROW_HEIGHT, ...(ngDevMode ? [{ debugName: "virtualRowHeight" }] : []));
@@ -3547,14 +3554,12 @@ class ZTableComponent {
3547
3554
  const totalRows = untracked(() => this.table.getRowModel().rows.length);
3548
3555
  return Math.ceil(totalRows / this.groupSize());
3549
3556
  }, ...(ngDevMode ? [{ debugName: "_virtualGroupCount" }] : []));
3550
- _virtualResetVersion = signal(0, ...(ngDevMode ? [{ debugName: "_virtualResetVersion" }] : []));
3551
3557
  virtualizer = injectVirtualizer(() => {
3552
- // Track reset version to force virtualizer re-initialization
3553
- this._virtualResetVersion();
3554
3558
  const groups = this.dynamicGroups();
3555
3559
  const rowHeight = this.virtualRowHeight();
3556
3560
  const groupSize = this.groupSize();
3557
3561
  const scrollElement = this.tbodyWrapper()?.nativeElement;
3562
+ const virtualConfig = this._virtualConfig();
3558
3563
  return {
3559
3564
  scrollElement,
3560
3565
  count: groups.length > 0 ? groups.length : this._virtualGroupCount(),
@@ -3569,8 +3574,16 @@ class ZTableComponent {
3569
3574
  return groupSize * rowHeight;
3570
3575
  },
3571
3576
  measureElement: (element) => element.getBoundingClientRect().height,
3572
- overscan: this._virtualConfig().overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3573
- initialOffset: 0,
3577
+ overscan: virtualConfig.overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3578
+ initialOffset: virtualConfig.initialOffset ?? 0,
3579
+ ...(virtualConfig.scrollMargin !== undefined && { scrollMargin: virtualConfig.scrollMargin }),
3580
+ ...(virtualConfig.gap !== undefined && { gap: virtualConfig.gap }),
3581
+ ...(virtualConfig.isScrollingResetDelay !== undefined && {
3582
+ isScrollingResetDelay: virtualConfig.isScrollingResetDelay,
3583
+ }),
3584
+ ...(virtualConfig.useScrollendEvent !== undefined && { useScrollendEvent: virtualConfig.useScrollendEvent }),
3585
+ ...(virtualConfig.getItemKey !== undefined && { getItemKey: virtualConfig.getItemKey }),
3586
+ ...(virtualConfig.rangeExtractor !== undefined && { rangeExtractor: virtualConfig.rangeExtractor }),
3574
3587
  };
3575
3588
  });
3576
3589
  _measureVirtualItems = effect(() => {
@@ -3697,7 +3710,6 @@ class ZTableComponent {
3697
3710
  });
3698
3711
  explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting, this._data], () => {
3699
3712
  if (this.isVirtual()) {
3700
- // Reset scroll position synchronously
3701
3713
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3702
3714
  if (wrapperEl) {
3703
3715
  wrapperEl.scrollTop = 0;
@@ -3706,12 +3718,8 @@ class ZTableComponent {
3706
3718
  if (scrollbar) {
3707
3719
  void scrollbar.scrollTo({ top: 0, duration: 0 });
3708
3720
  }
3709
- // Reset virtualizer to offset 0
3710
3721
  this.virtualizer.scrollToOffset(0);
3711
- // Force recalculate dynamic groups immediately
3712
3722
  this._dynamicGroupsVersion.update(v => v + 1);
3713
- // Force virtualizer to reset with initialOffset: 0
3714
- this._virtualResetVersion.update(v => v + 1);
3715
3723
  }
3716
3724
  queueMicrotask(() => {
3717
3725
  this._checkVerticalScroll();
@@ -3733,21 +3741,27 @@ class ZTableComponent {
3733
3741
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3734
3742
  if (wrapperEl) {
3735
3743
  this._savedScrollLeft.set(wrapperEl.scrollLeft);
3744
+ wrapperEl.scrollTop = 0;
3745
+ }
3746
+ const scrollbar = this.tbodyScrollbar();
3747
+ if (scrollbar) {
3748
+ void scrollbar.scrollTo({ top: 0, duration: 0 });
3736
3749
  }
3737
3750
  return;
3738
3751
  }
3739
- // Loading finished - reset scroll positions
3740
3752
  queueMicrotask(() => {
3741
3753
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3742
3754
  if (wrapperEl) {
3743
3755
  wrapperEl.scrollTop = 0;
3744
3756
  wrapperEl.scrollLeft = this._savedScrollLeft();
3745
3757
  }
3746
- // Critical: Reset virtualizer when loading finishes in server mode
3747
3758
  if (this.isVirtual()) {
3759
+ const scrollbar = this.tbodyScrollbar();
3760
+ if (scrollbar) {
3761
+ void scrollbar.scrollTo({ top: 0, duration: 0 });
3762
+ }
3748
3763
  this.virtualizer.scrollToOffset(0);
3749
3764
  this._dynamicGroupsVersion.update(v => v + 1);
3750
- this._virtualResetVersion.update(v => v + 1);
3751
3765
  }
3752
3766
  this._checkScrollState();
3753
3767
  });