@shival99/z-ui 1.2.36 → 1.2.38

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.
@@ -2350,7 +2350,6 @@ class ZTableComponent {
2350
2350
  _dataForceUpdate = signal(0, ...(ngDevMode ? [{ debugName: "_dataForceUpdate" }] : []));
2351
2351
  _columnConfigCache = new Map();
2352
2352
  _lastColumnsRef = null;
2353
- _configCacheLoaded = false;
2354
2353
  pinnedColumnIds = computed(() => {
2355
2354
  this._columnPinVersion();
2356
2355
  return this.columnOrder().filter(id => {
@@ -3056,22 +3055,20 @@ class ZTableComponent {
3056
3055
  explicitEffect([this._zTranslate.currentLang], () => {
3057
3056
  this._dataForceUpdate.update(v => v + 1);
3058
3057
  });
3059
- explicitEffect([this.zKey, this.zConfig], ([key, config]) => {
3060
- console.log('🚀 ~ key:', key);
3061
- if (key && config.columns && config.columns.length > 0) {
3062
- console.log('🚀 ~ key:', key);
3063
- this._loadConfigCache();
3058
+ explicitEffect([this.zKey, this.zConfig], ([key, cfg]) => {
3059
+ if (!cfg.columns || cfg.columns.length === 0) {
3060
+ return;
3064
3061
  }
3065
- }, { defer: true });
3066
- explicitEffect([this.zConfig], ([cfg]) => {
3062
+ const cacheLoaded = key ? this._loadConfigCache(key) : false;
3067
3063
  const initial = cfg.initialState;
3068
- console.log('🚀 ~ initial:', initial);
3069
3064
  if (initial) {
3070
- if (initial.columnPinning) {
3071
- this.columnPinning.set(initial.columnPinning);
3072
- }
3073
- if (initial.columnVisibility) {
3074
- this.columnVisibility.set(initial.columnVisibility);
3065
+ if (!cacheLoaded) {
3066
+ if (initial.columnPinning) {
3067
+ this.columnPinning.set(initial.columnPinning);
3068
+ }
3069
+ if (initial.columnVisibility) {
3070
+ this.columnVisibility.set(initial.columnVisibility);
3071
+ }
3075
3072
  }
3076
3073
  if (initial.sorting) {
3077
3074
  this.sorting.set(initial.sorting);
@@ -3095,7 +3092,9 @@ class ZTableComponent {
3095
3092
  this.pagination.set(initial.pagination);
3096
3093
  }
3097
3094
  }
3098
- this.showHeaderFooterShadow.set(cfg.showHeaderShadow ?? cfg.showFooterShadow ?? true);
3095
+ if (!cacheLoaded) {
3096
+ this.showHeaderFooterShadow.set(cfg.showHeaderShadow ?? cfg.showFooterShadow ?? true);
3097
+ }
3099
3098
  const cols = cfg.columns ?? [];
3100
3099
  const leftPinned = [...(initial?.columnPinning?.left ?? [])];
3101
3100
  const rightPinned = [...(initial?.columnPinning?.right ?? [])];
@@ -3113,10 +3112,9 @@ class ZTableComponent {
3113
3112
  }
3114
3113
  };
3115
3114
  collectPinnedColumns(cols);
3116
- if (leftPinned.length > 0 || rightPinned.length > 0) {
3115
+ if (!cacheLoaded && (leftPinned.length > 0 || rightPinned.length > 0)) {
3117
3116
  this.columnPinning.set({ left: leftPinned, right: rightPinned });
3118
3117
  }
3119
- console.log('🚀 ~ this.columnPinning:', this.columnPinning);
3120
3118
  });
3121
3119
  explicitEffect([this.zConfig], ([cfg]) => {
3122
3120
  if (cfg.enableRowPinning && !this.hasBodyRowSpan()) {
@@ -3160,10 +3158,21 @@ class ZTableComponent {
3160
3158
  this.pagination.set(configPagination);
3161
3159
  }
3162
3160
  });
3163
- explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting], () => {
3161
+ explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting, this._data], () => {
3164
3162
  queueMicrotask(() => {
3165
3163
  this._checkVerticalScroll();
3166
3164
  this._checkHorizontalScroll();
3165
+ if (this.isVirtual()) {
3166
+ this._dynamicGroupsVersion.update(v => v + 1);
3167
+ }
3168
+ });
3169
+ });
3170
+ explicitEffect([this.virtualizer.getVirtualItems], () => {
3171
+ if (!this.isVirtual()) {
3172
+ return;
3173
+ }
3174
+ queueMicrotask(() => {
3175
+ this._checkLastRowTouchesBottom();
3167
3176
  });
3168
3177
  });
3169
3178
  explicitEffect([this.zLoading, this.isProcessing], () => {
@@ -3318,6 +3327,29 @@ class ZTableComponent {
3318
3327
  this.lastRowTouchesBottom.set(true);
3319
3328
  return;
3320
3329
  }
3330
+ if (this.isVirtual()) {
3331
+ const virtualScrollInner = tbodyWrapperEl.querySelector('.z-virtual-scroll-inner');
3332
+ if (!virtualScrollInner) {
3333
+ this.lastRowTouchesBottom.set(true);
3334
+ return;
3335
+ }
3336
+ const virtualRows = virtualScrollInner.querySelectorAll('.z-virtual-row');
3337
+ if (virtualRows.length === 0) {
3338
+ this.lastRowTouchesBottom.set(true);
3339
+ return;
3340
+ }
3341
+ const lastVirtualRow = virtualRows[virtualRows.length - 1];
3342
+ const lastTr = lastVirtualRow.querySelector('tbody tr:last-child');
3343
+ if (!lastTr) {
3344
+ this.lastRowTouchesBottom.set(true);
3345
+ return;
3346
+ }
3347
+ const wrapperRect = tbodyWrapperEl.getBoundingClientRect();
3348
+ const rowRect = lastTr.getBoundingClientRect();
3349
+ const gap = wrapperRect.bottom - rowRect.bottom;
3350
+ this.lastRowTouchesBottom.set(gap <= 2);
3351
+ return;
3352
+ }
3321
3353
  const tbody = tbodyWrapperEl.querySelector('tbody');
3322
3354
  if (!tbody) {
3323
3355
  this.lastRowTouchesBottom.set(true);
@@ -3648,21 +3680,18 @@ class ZTableComponent {
3648
3680
  collect(columns);
3649
3681
  return result;
3650
3682
  }
3651
- _loadConfigCache() {
3652
- const key = this.zKey();
3683
+ _loadConfigCache(key) {
3653
3684
  if (!key) {
3654
- return;
3685
+ return false;
3655
3686
  }
3656
3687
  try {
3657
3688
  const config = ZCacheService.get(`table-config-${key}`);
3658
- console.log('🚀 ~ config:', config);
3659
3689
  if (!config) {
3660
- return;
3690
+ return false;
3661
3691
  }
3662
3692
  if (!this._isColumnConfigValid(config.columnInfo)) {
3663
- console.warn('Saved table config is invalid or outdated. Ignoring saved config.');
3664
3693
  ZCacheService.delete(`table-config-${key}`);
3665
- return;
3694
+ return false;
3666
3695
  }
3667
3696
  if (config.columnOrder && config.columnOrder.length > 0) {
3668
3697
  this.columnOrder.set(config.columnOrder);
@@ -3685,10 +3714,11 @@ class ZTableComponent {
3685
3714
  if (config.columnSizing) {
3686
3715
  this.table.setColumnSizing(config.columnSizing);
3687
3716
  }
3688
- console.log('zzz🚀 ~ config:', config);
3717
+ return true;
3689
3718
  }
3690
3719
  catch (error) {
3691
3720
  console.error('Failed to load table config:', error);
3721
+ return false;
3692
3722
  }
3693
3723
  }
3694
3724
  _isColumnConfigValid(cachedColumnInfo) {