@shival99/z-ui 1.2.28 → 1.2.29

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
- _initialStateApplied = false;
2354
2353
  pinnedColumnIds = computed(() => {
2355
2354
  this._columnPinVersion();
2356
2355
  return this.columnOrder().filter(id => {
@@ -3053,93 +3052,80 @@ class ZTableComponent {
3053
3052
  }
3054
3053
  }, ...(ngDevMode ? [{ debugName: "_measureVirtualItems" }] : []));
3055
3054
  constructor() {
3056
- effect(() => {
3057
- const lang = this._zTranslate.currentLang();
3058
- untracked(() => {
3059
- void lang;
3060
- this._dataForceUpdate.update(v => v + 1);
3061
- });
3055
+ explicitEffect([this._zTranslate.currentLang], () => {
3056
+ this._dataForceUpdate.update(v => v + 1);
3057
+ });
3058
+ explicitEffect([this.zKey], ([key]) => {
3059
+ this._loadConfigCache();
3062
3060
  });
3063
- effect(() => {
3064
- const cfg = this.zConfig();
3061
+ explicitEffect([this.zConfig], ([cfg]) => {
3065
3062
  const initial = cfg.initialState;
3066
- const cols = cfg.columns ?? [];
3067
- untracked(() => {
3068
- // Only apply initial state once on first run
3069
- // This prevents overwriting cached settings when zConfig changes (e.g., data loads)
3070
- if (this._initialStateApplied) {
3071
- return;
3063
+ if (initial) {
3064
+ if (initial.columnPinning) {
3065
+ this.columnPinning.set(initial.columnPinning);
3072
3066
  }
3073
- this._initialStateApplied = true;
3074
- if (initial) {
3075
- if (initial.columnPinning) {
3076
- this.columnPinning.set(initial.columnPinning);
3077
- }
3078
- if (initial.columnVisibility) {
3079
- this.columnVisibility.set(initial.columnVisibility);
3080
- }
3081
- if (initial.sorting) {
3082
- this.sorting.set(initial.sorting);
3083
- }
3084
- if (initial.columnFilters) {
3085
- this.columnFilters.set(initial.columnFilters);
3086
- }
3087
- if (initial.globalFilter) {
3088
- this.globalFilter.set(initial.globalFilter);
3089
- }
3090
- if (initial.expanded) {
3091
- this.expanded.set(initial.expanded);
3092
- }
3093
- if (initial.rowSelection) {
3094
- this.rowSelection.set(initial.rowSelection);
3095
- }
3096
- if (initial.rowPinning) {
3097
- this.rowPinning.set(initial.rowPinning);
3067
+ if (initial.columnVisibility) {
3068
+ this.columnVisibility.set(initial.columnVisibility);
3069
+ }
3070
+ if (initial.sorting) {
3071
+ this.sorting.set(initial.sorting);
3072
+ }
3073
+ if (initial.columnFilters) {
3074
+ this.columnFilters.set(initial.columnFilters);
3075
+ }
3076
+ if (initial.globalFilter) {
3077
+ this.globalFilter.set(initial.globalFilter);
3078
+ }
3079
+ if (initial.expanded) {
3080
+ this.expanded.set(initial.expanded);
3081
+ }
3082
+ if (initial.rowSelection) {
3083
+ this.rowSelection.set(initial.rowSelection);
3084
+ }
3085
+ if (initial.rowPinning) {
3086
+ this.rowPinning.set(initial.rowPinning);
3087
+ }
3088
+ if (initial.pagination) {
3089
+ this.pagination.set(initial.pagination);
3090
+ }
3091
+ }
3092
+ this.showHeaderFooterShadow.set(cfg.showHeaderShadow ?? cfg.showFooterShadow ?? true);
3093
+ const cols = cfg.columns ?? [];
3094
+ const leftPinned = [...(initial?.columnPinning?.left ?? [])];
3095
+ const rightPinned = [...(initial?.columnPinning?.right ?? [])];
3096
+ const collectPinnedColumns = (columns) => {
3097
+ for (const col of columns) {
3098
+ if (col.pinned === 'left' && !leftPinned.includes(col.id)) {
3099
+ leftPinned.push(col.id);
3098
3100
  }
3099
- if (initial.pagination) {
3100
- this.pagination.set(initial.pagination);
3101
+ if (col.pinned === 'right' && !rightPinned.includes(col.id)) {
3102
+ rightPinned.push(col.id);
3101
3103
  }
3102
- }
3103
- this.showHeaderFooterShadow.set(cfg.showHeaderShadow ?? cfg.showFooterShadow ?? true);
3104
- const leftPinned = [...(initial?.columnPinning?.left ?? [])];
3105
- const rightPinned = [...(initial?.columnPinning?.right ?? [])];
3106
- const collectPinnedColumns = (columns) => {
3107
- for (const col of columns) {
3108
- if (col.pinned === 'left' && !leftPinned.includes(col.id)) {
3109
- leftPinned.push(col.id);
3110
- }
3111
- if (col.pinned === 'right' && !rightPinned.includes(col.id)) {
3112
- rightPinned.push(col.id);
3113
- }
3114
- if (col.columns) {
3115
- collectPinnedColumns(col.columns);
3116
- }
3104
+ if (col.columns) {
3105
+ collectPinnedColumns(col.columns);
3117
3106
  }
3118
- };
3119
- collectPinnedColumns(cols);
3120
- if (leftPinned.length > 0 || rightPinned.length > 0) {
3121
- this.columnPinning.set({ left: leftPinned, right: rightPinned });
3122
3107
  }
3123
- });
3108
+ };
3109
+ collectPinnedColumns(cols);
3110
+ if (leftPinned.length > 0 || rightPinned.length > 0) {
3111
+ this.columnPinning.set({ left: leftPinned, right: rightPinned });
3112
+ }
3124
3113
  });
3125
- effect(() => {
3126
- const cfg = this.zConfig();
3114
+ explicitEffect([this.zConfig], ([cfg]) => {
3127
3115
  if (cfg.enableRowPinning && !this.hasBodyRowSpan()) {
3128
3116
  const cols = cfg.columns ?? [];
3129
3117
  const hasSelect = cols.some(c => c.id === 'select');
3130
3118
  const hasExpand = cols.some(c => c.id === 'expand');
3131
- untracked(() => {
3132
- const currentPinning = this.columnPinning();
3133
- const leftPinned = [...(currentPinning.left || [])];
3134
- if (hasSelect && !leftPinned.includes('select')) {
3135
- leftPinned.unshift('select');
3136
- this.columnPinning.set({ ...currentPinning, left: leftPinned });
3137
- }
3138
- if (!hasSelect && !hasExpand && !leftPinned.includes('actions')) {
3139
- leftPinned.unshift('actions');
3140
- this.columnPinning.set({ ...currentPinning, left: leftPinned });
3141
- }
3142
- });
3119
+ const currentPinning = this.columnPinning();
3120
+ const leftPinned = [...(currentPinning.left || [])];
3121
+ if (hasSelect && !leftPinned.includes('select')) {
3122
+ leftPinned.unshift('select');
3123
+ this.columnPinning.set({ ...currentPinning, left: leftPinned });
3124
+ }
3125
+ if (!hasSelect && !hasExpand && !leftPinned.includes('actions')) {
3126
+ leftPinned.unshift('actions');
3127
+ this.columnPinning.set({ ...currentPinning, left: leftPinned });
3128
+ }
3143
3129
  }
3144
3130
  });
3145
3131
  afterNextRender(() => {
@@ -3189,6 +3175,7 @@ class ZTableComponent {
3189
3175
  wrapperEl.scrollTop = 0;
3190
3176
  wrapperEl.scrollLeft = this._savedScrollLeft();
3191
3177
  }
3178
+ this._checkScrollState();
3192
3179
  });
3193
3180
  });
3194
3181
  explicitEffect([
@@ -3204,11 +3191,7 @@ class ZTableComponent {
3204
3191
  }, { defer: true });
3205
3192
  }
3206
3193
  ngAfterViewInit() {
3207
- this._loadConfig();
3208
- setTimeout(() => {
3209
- this._checkVerticalScroll();
3210
- this._checkHorizontalScroll();
3211
- }, 100);
3194
+ queueMicrotask(() => this._checkScrollState());
3212
3195
  this.zControl.emit({
3213
3196
  updateConfig: (config) => {
3214
3197
  const current = this.zConfig();
@@ -3306,6 +3289,10 @@ class ZTableComponent {
3306
3289
  });
3307
3290
  }, 300);
3308
3291
  }
3292
+ _checkScrollState() {
3293
+ this._checkVerticalScroll();
3294
+ this._checkHorizontalScroll();
3295
+ }
3309
3296
  _checkVerticalScroll() {
3310
3297
  const tbodyWrapperEl = this.tbodyWrapper()?.nativeElement;
3311
3298
  if (tbodyWrapperEl) {
@@ -3654,7 +3641,7 @@ class ZTableComponent {
3654
3641
  collect(columns);
3655
3642
  return result;
3656
3643
  }
3657
- _loadConfig() {
3644
+ _loadConfigCache() {
3658
3645
  const key = this.zKey();
3659
3646
  if (!key) {
3660
3647
  return;
@@ -3672,9 +3659,6 @@ class ZTableComponent {
3672
3659
  if (config.columnOrder && config.columnOrder.length > 0) {
3673
3660
  this.columnOrder.set(config.columnOrder);
3674
3661
  }
3675
- if (config.columnSizing) {
3676
- this.table.setColumnSizing(config.columnSizing);
3677
- }
3678
3662
  if (config.columnPinning) {
3679
3663
  this.columnPinning.set(config.columnPinning);
3680
3664
  }
@@ -3690,6 +3674,9 @@ class ZTableComponent {
3690
3674
  if (typeof config.showVerticalBorder === 'boolean') {
3691
3675
  this.showVerticalBorder.set(config.showVerticalBorder);
3692
3676
  }
3677
+ if (config.columnSizing) {
3678
+ this.table.setColumnSizing(config.columnSizing);
3679
+ }
3693
3680
  }
3694
3681
  catch (error) {
3695
3682
  console.error('Failed to load table config:', error);