@shival99/z-ui 1.2.27 → 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.
@@ -3052,87 +3052,80 @@ class ZTableComponent {
3052
3052
  }
3053
3053
  }, ...(ngDevMode ? [{ debugName: "_measureVirtualItems" }] : []));
3054
3054
  constructor() {
3055
- effect(() => {
3056
- const lang = this._zTranslate.currentLang();
3057
- untracked(() => {
3058
- void lang;
3059
- this._dataForceUpdate.update(v => v + 1);
3060
- });
3055
+ explicitEffect([this._zTranslate.currentLang], () => {
3056
+ this._dataForceUpdate.update(v => v + 1);
3057
+ });
3058
+ explicitEffect([this.zKey], ([key]) => {
3059
+ this._loadConfigCache();
3061
3060
  });
3062
- effect(() => {
3063
- const cfg = this.zConfig();
3061
+ explicitEffect([this.zConfig], ([cfg]) => {
3064
3062
  const initial = cfg.initialState;
3065
- untracked(() => {
3066
- if (initial) {
3067
- if (initial.columnPinning) {
3068
- this.columnPinning.set(initial.columnPinning);
3069
- }
3070
- if (initial.columnVisibility) {
3071
- this.columnVisibility.set(initial.columnVisibility);
3072
- }
3073
- if (initial.sorting) {
3074
- this.sorting.set(initial.sorting);
3075
- }
3076
- if (initial.columnFilters) {
3077
- this.columnFilters.set(initial.columnFilters);
3078
- }
3079
- if (initial.globalFilter) {
3080
- this.globalFilter.set(initial.globalFilter);
3081
- }
3082
- if (initial.expanded) {
3083
- this.expanded.set(initial.expanded);
3084
- }
3085
- if (initial.rowSelection) {
3086
- this.rowSelection.set(initial.rowSelection);
3087
- }
3088
- if (initial.rowPinning) {
3089
- this.rowPinning.set(initial.rowPinning);
3063
+ if (initial) {
3064
+ if (initial.columnPinning) {
3065
+ this.columnPinning.set(initial.columnPinning);
3066
+ }
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);
3090
3100
  }
3091
- if (initial.pagination) {
3092
- this.pagination.set(initial.pagination);
3101
+ if (col.pinned === 'right' && !rightPinned.includes(col.id)) {
3102
+ rightPinned.push(col.id);
3093
3103
  }
3094
- }
3095
- this.showHeaderFooterShadow.set(cfg.showHeaderShadow ?? cfg.showFooterShadow ?? true);
3096
- const cols = cfg.columns ?? [];
3097
- const leftPinned = [...(initial?.columnPinning?.left ?? [])];
3098
- const rightPinned = [...(initial?.columnPinning?.right ?? [])];
3099
- const collectPinnedColumns = (columns) => {
3100
- for (const col of columns) {
3101
- if (col.pinned === 'left' && !leftPinned.includes(col.id)) {
3102
- leftPinned.push(col.id);
3103
- }
3104
- if (col.pinned === 'right' && !rightPinned.includes(col.id)) {
3105
- rightPinned.push(col.id);
3106
- }
3107
- if (col.columns) {
3108
- collectPinnedColumns(col.columns);
3109
- }
3104
+ if (col.columns) {
3105
+ collectPinnedColumns(col.columns);
3110
3106
  }
3111
- };
3112
- collectPinnedColumns(cols);
3113
- if (leftPinned.length > 0 || rightPinned.length > 0) {
3114
- this.columnPinning.set({ left: leftPinned, right: rightPinned });
3115
3107
  }
3116
- });
3108
+ };
3109
+ collectPinnedColumns(cols);
3110
+ if (leftPinned.length > 0 || rightPinned.length > 0) {
3111
+ this.columnPinning.set({ left: leftPinned, right: rightPinned });
3112
+ }
3117
3113
  });
3118
- effect(() => {
3119
- const cfg = this.zConfig();
3114
+ explicitEffect([this.zConfig], ([cfg]) => {
3120
3115
  if (cfg.enableRowPinning && !this.hasBodyRowSpan()) {
3121
3116
  const cols = cfg.columns ?? [];
3122
3117
  const hasSelect = cols.some(c => c.id === 'select');
3123
3118
  const hasExpand = cols.some(c => c.id === 'expand');
3124
- untracked(() => {
3125
- const currentPinning = this.columnPinning();
3126
- const leftPinned = [...(currentPinning.left || [])];
3127
- if (hasSelect && !leftPinned.includes('select')) {
3128
- leftPinned.unshift('select');
3129
- this.columnPinning.set({ ...currentPinning, left: leftPinned });
3130
- }
3131
- if (!hasSelect && !hasExpand && !leftPinned.includes('actions')) {
3132
- leftPinned.unshift('actions');
3133
- this.columnPinning.set({ ...currentPinning, left: leftPinned });
3134
- }
3135
- });
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
+ }
3136
3129
  }
3137
3130
  });
3138
3131
  afterNextRender(() => {
@@ -3182,6 +3175,7 @@ class ZTableComponent {
3182
3175
  wrapperEl.scrollTop = 0;
3183
3176
  wrapperEl.scrollLeft = this._savedScrollLeft();
3184
3177
  }
3178
+ this._checkScrollState();
3185
3179
  });
3186
3180
  });
3187
3181
  explicitEffect([
@@ -3197,11 +3191,7 @@ class ZTableComponent {
3197
3191
  }, { defer: true });
3198
3192
  }
3199
3193
  ngAfterViewInit() {
3200
- this._loadConfig();
3201
- setTimeout(() => {
3202
- this._checkVerticalScroll();
3203
- this._checkHorizontalScroll();
3204
- }, 100);
3194
+ queueMicrotask(() => this._checkScrollState());
3205
3195
  this.zControl.emit({
3206
3196
  updateConfig: (config) => {
3207
3197
  const current = this.zConfig();
@@ -3299,6 +3289,10 @@ class ZTableComponent {
3299
3289
  });
3300
3290
  }, 300);
3301
3291
  }
3292
+ _checkScrollState() {
3293
+ this._checkVerticalScroll();
3294
+ this._checkHorizontalScroll();
3295
+ }
3302
3296
  _checkVerticalScroll() {
3303
3297
  const tbodyWrapperEl = this.tbodyWrapper()?.nativeElement;
3304
3298
  if (tbodyWrapperEl) {
@@ -3647,28 +3641,24 @@ class ZTableComponent {
3647
3641
  collect(columns);
3648
3642
  return result;
3649
3643
  }
3650
- _loadConfig() {
3644
+ _loadConfigCache() {
3651
3645
  const key = this.zKey();
3652
3646
  if (!key) {
3653
3647
  return;
3654
3648
  }
3655
3649
  try {
3656
3650
  const config = ZCacheService.get(`table-config-${key}`);
3657
- console.log('🚀 ~ config:', config);
3658
3651
  if (!config) {
3659
3652
  return;
3660
3653
  }
3661
3654
  if (!this._isColumnConfigValid(config.columnInfo)) {
3662
- console.warn('Saved table config is invalid due to column changes. Ignoring saved config.');
3655
+ console.warn('Saved table config is invalid or outdated. Ignoring saved config.');
3663
3656
  ZCacheService.delete(`table-config-${key}`);
3664
3657
  return;
3665
3658
  }
3666
3659
  if (config.columnOrder && config.columnOrder.length > 0) {
3667
3660
  this.columnOrder.set(config.columnOrder);
3668
3661
  }
3669
- if (config.columnSizing) {
3670
- this.table.setColumnSizing(config.columnSizing);
3671
- }
3672
3662
  if (config.columnPinning) {
3673
3663
  this.columnPinning.set(config.columnPinning);
3674
3664
  }
@@ -3684,6 +3674,9 @@ class ZTableComponent {
3684
3674
  if (typeof config.showVerticalBorder === 'boolean') {
3685
3675
  this.showVerticalBorder.set(config.showVerticalBorder);
3686
3676
  }
3677
+ if (config.columnSizing) {
3678
+ this.table.setColumnSizing(config.columnSizing);
3679
+ }
3687
3680
  }
3688
3681
  catch (error) {
3689
3682
  console.error('Failed to load table config:', error);