@shival99/z-ui 1.7.15 → 1.7.17

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.
@@ -825,6 +825,12 @@ const resolveConfigValue = (config, row, defaultValue) => {
825
825
  }
826
826
  return typeof config === 'function' ? config(row) : config;
827
827
  };
828
+ const pickDefined = (obj, keys) => keys.reduce((acc, key) => {
829
+ if (obj[key] !== undefined) {
830
+ acc[key] = obj[key];
831
+ }
832
+ return acc;
833
+ }, {});
828
834
 
829
835
  class ZTableEditCellComponent {
830
836
  _destroyRef = inject(DestroyRef);
@@ -3166,6 +3172,13 @@ class ZTableComponent {
3166
3172
  overscan: virtual.overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3167
3173
  groupSize: virtual.groupSize ?? Z_DEFAULT_GROUP_SIZE,
3168
3174
  dynamicSize: virtual.dynamicSize ?? false,
3175
+ initialOffset: virtual.initialOffset,
3176
+ scrollMargin: virtual.scrollMargin,
3177
+ gap: virtual.gap,
3178
+ isScrollingResetDelay: virtual.isScrollingResetDelay,
3179
+ useScrollendEvent: virtual.useScrollendEvent,
3180
+ getItemKey: virtual.getItemKey,
3181
+ rangeExtractor: virtual.rangeExtractor,
3169
3182
  };
3170
3183
  }, ...(ngDevMode ? [{ debugName: "_virtualConfig" }] : []));
3171
3184
  virtualRowHeight = computed(() => this._virtualConfig().size ?? Z_DEFAULT_ROW_HEIGHT, ...(ngDevMode ? [{ debugName: "virtualRowHeight" }] : []));
@@ -3547,14 +3560,12 @@ class ZTableComponent {
3547
3560
  const totalRows = untracked(() => this.table.getRowModel().rows.length);
3548
3561
  return Math.ceil(totalRows / this.groupSize());
3549
3562
  }, ...(ngDevMode ? [{ debugName: "_virtualGroupCount" }] : []));
3550
- _virtualResetVersion = signal(0, ...(ngDevMode ? [{ debugName: "_virtualResetVersion" }] : []));
3551
3563
  virtualizer = injectVirtualizer(() => {
3552
- // Track reset version to force virtualizer re-initialization
3553
- this._virtualResetVersion();
3554
3564
  const groups = this.dynamicGroups();
3555
3565
  const rowHeight = this.virtualRowHeight();
3556
3566
  const groupSize = this.groupSize();
3557
3567
  const scrollElement = this.tbodyWrapper()?.nativeElement;
3568
+ const virtualConfig = this._virtualConfig();
3558
3569
  return {
3559
3570
  scrollElement,
3560
3571
  count: groups.length > 0 ? groups.length : this._virtualGroupCount(),
@@ -3569,8 +3580,16 @@ class ZTableComponent {
3569
3580
  return groupSize * rowHeight;
3570
3581
  },
3571
3582
  measureElement: (element) => element.getBoundingClientRect().height,
3572
- overscan: this._virtualConfig().overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3573
- initialOffset: 0,
3583
+ overscan: virtualConfig.overscan ?? Z_DEFAULT_VIRTUAL_OVERSCAN,
3584
+ initialOffset: virtualConfig.initialOffset ?? 0,
3585
+ ...pickDefined(virtualConfig, [
3586
+ 'scrollMargin',
3587
+ 'gap',
3588
+ 'isScrollingResetDelay',
3589
+ 'useScrollendEvent',
3590
+ 'getItemKey',
3591
+ 'rangeExtractor',
3592
+ ]),
3574
3593
  };
3575
3594
  });
3576
3595
  _measureVirtualItems = effect(() => {
@@ -3697,25 +3716,18 @@ class ZTableComponent {
3697
3716
  });
3698
3717
  explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting, this._data], () => {
3699
3718
  if (this.isVirtual()) {
3700
- // Reset scroll position synchronously
3701
3719
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3702
3720
  if (wrapperEl) {
3703
3721
  wrapperEl.scrollTop = 0;
3704
3722
  }
3705
- const scrollbar = this.tbodyScrollbar();
3706
- if (scrollbar) {
3707
- void scrollbar.scrollTo({ top: 0, duration: 0 });
3708
- }
3709
- // Reset virtualizer to offset 0
3710
3723
  this.virtualizer.scrollToOffset(0);
3711
- // Force recalculate dynamic groups immediately
3712
- this._dynamicGroupsVersion.update(v => v + 1);
3713
- // Force virtualizer to reset with initialOffset: 0
3714
- this._virtualResetVersion.update(v => v + 1);
3715
3724
  }
3716
3725
  queueMicrotask(() => {
3717
3726
  this._checkVerticalScroll();
3718
3727
  this._checkHorizontalScroll();
3728
+ if (this.isVirtual()) {
3729
+ this._dynamicGroupsVersion.update(v => v + 1);
3730
+ }
3719
3731
  });
3720
3732
  });
3721
3733
  explicitEffect([this.virtualizer.getVirtualItems], () => {
@@ -3733,21 +3745,27 @@ class ZTableComponent {
3733
3745
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3734
3746
  if (wrapperEl) {
3735
3747
  this._savedScrollLeft.set(wrapperEl.scrollLeft);
3748
+ wrapperEl.scrollTop = 0;
3749
+ }
3750
+ const scrollbar = this.tbodyScrollbar();
3751
+ if (scrollbar) {
3752
+ void scrollbar.scrollTo({ top: 0, left: this._savedScrollLeft(), duration: 0 });
3736
3753
  }
3737
3754
  return;
3738
3755
  }
3739
- // Loading finished - reset scroll positions
3740
3756
  queueMicrotask(() => {
3741
3757
  const wrapperEl = this.tbodyWrapper()?.nativeElement;
3742
3758
  if (wrapperEl) {
3743
3759
  wrapperEl.scrollTop = 0;
3744
3760
  wrapperEl.scrollLeft = this._savedScrollLeft();
3745
3761
  }
3746
- // Critical: Reset virtualizer when loading finishes in server mode
3747
3762
  if (this.isVirtual()) {
3763
+ const scrollbar = this.tbodyScrollbar();
3764
+ if (scrollbar) {
3765
+ void scrollbar.scrollTo({ top: 0, left: this._savedScrollLeft(), duration: 0 });
3766
+ }
3748
3767
  this.virtualizer.scrollToOffset(0);
3749
3768
  this._dynamicGroupsVersion.update(v => v + 1);
3750
- this._virtualResetVersion.update(v => v + 1);
3751
3769
  }
3752
3770
  this._checkScrollState();
3753
3771
  });