@shival99/z-ui 1.2.28 → 1.2.30
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.
- package/fesm2022/shival99-z-ui-components-z-table.mjs +79 -85
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-utils.mjs +13 -6
- package/fesm2022/shival99-z-ui-utils.mjs.map +1 -1
- package/package.json +1 -1
- package/types/shival99-z-ui-components-z-modal.d.ts +1 -1
- package/types/shival99-z-ui-components-z-table.d.ts +3 -2
- package/types/shival99-z-ui-utils.d.ts +6 -2
|
@@ -20,6 +20,7 @@ import { ZSafeHtmlPipe } from '@shival99/z-ui/pipes';
|
|
|
20
20
|
import { ZTranslateService, ZCacheService } from '@shival99/z-ui/services';
|
|
21
21
|
import { createAngularTable, getFacetedMinMaxValues, getFacetedUniqueValues, getFacetedRowModel, getPaginationRowModel, getSortedRowModel, getFilteredRowModel, getExpandedRowModel, getCoreRowModel, FlexRenderDirective } from '@tanstack/angular-table';
|
|
22
22
|
import { NgScrollbar } from 'ngx-scrollbar';
|
|
23
|
+
import { effectOnceIf } from 'ngxtension/effect-once-if';
|
|
23
24
|
import { explicitEffect } from 'ngxtension/explicit-effect';
|
|
24
25
|
import { injectDestroy } from 'ngxtension/inject-destroy';
|
|
25
26
|
import { ZDropdownMenuComponent } from '@shival99/z-ui/components/z-dropdown-menu';
|
|
@@ -2350,7 +2351,7 @@ class ZTableComponent {
|
|
|
2350
2351
|
_dataForceUpdate = signal(0, ...(ngDevMode ? [{ debugName: "_dataForceUpdate" }] : []));
|
|
2351
2352
|
_columnConfigCache = new Map();
|
|
2352
2353
|
_lastColumnsRef = null;
|
|
2353
|
-
|
|
2354
|
+
_configCacheLoaded = false;
|
|
2354
2355
|
pinnedColumnIds = computed(() => {
|
|
2355
2356
|
this._columnPinVersion();
|
|
2356
2357
|
return this.columnOrder().filter(id => {
|
|
@@ -3053,93 +3054,85 @@ class ZTableComponent {
|
|
|
3053
3054
|
}
|
|
3054
3055
|
}, ...(ngDevMode ? [{ debugName: "_measureVirtualItems" }] : []));
|
|
3055
3056
|
constructor() {
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3057
|
+
explicitEffect([this._zTranslate.currentLang], () => {
|
|
3058
|
+
this._dataForceUpdate.update(v => v + 1);
|
|
3059
|
+
});
|
|
3060
|
+
effectOnceIf(computed(() => {
|
|
3061
|
+
const key = this.zKey();
|
|
3062
|
+
const config = this.zConfig();
|
|
3063
|
+
return !!key && !!config.columns && config.columns.length > 0 && !this._configCacheLoaded;
|
|
3064
|
+
}), () => {
|
|
3065
|
+
this._loadConfigCache();
|
|
3066
|
+
this._configCacheLoaded = true;
|
|
3062
3067
|
});
|
|
3063
|
-
|
|
3064
|
-
const cfg = this.zConfig();
|
|
3068
|
+
explicitEffect([this.zConfig], ([cfg]) => {
|
|
3065
3069
|
const initial = cfg.initialState;
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
// This prevents overwriting cached settings when zConfig changes (e.g., data loads)
|
|
3070
|
-
if (this._initialStateApplied) {
|
|
3071
|
-
return;
|
|
3070
|
+
if (initial) {
|
|
3071
|
+
if (initial.columnPinning) {
|
|
3072
|
+
this.columnPinning.set(initial.columnPinning);
|
|
3072
3073
|
}
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3074
|
+
if (initial.columnVisibility) {
|
|
3075
|
+
this.columnVisibility.set(initial.columnVisibility);
|
|
3076
|
+
}
|
|
3077
|
+
if (initial.sorting) {
|
|
3078
|
+
this.sorting.set(initial.sorting);
|
|
3079
|
+
}
|
|
3080
|
+
if (initial.columnFilters) {
|
|
3081
|
+
this.columnFilters.set(initial.columnFilters);
|
|
3082
|
+
}
|
|
3083
|
+
if (initial.globalFilter) {
|
|
3084
|
+
this.globalFilter.set(initial.globalFilter);
|
|
3085
|
+
}
|
|
3086
|
+
if (initial.expanded) {
|
|
3087
|
+
this.expanded.set(initial.expanded);
|
|
3088
|
+
}
|
|
3089
|
+
if (initial.rowSelection) {
|
|
3090
|
+
this.rowSelection.set(initial.rowSelection);
|
|
3091
|
+
}
|
|
3092
|
+
if (initial.rowPinning) {
|
|
3093
|
+
this.rowPinning.set(initial.rowPinning);
|
|
3094
|
+
}
|
|
3095
|
+
if (initial.pagination) {
|
|
3096
|
+
this.pagination.set(initial.pagination);
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
this.showHeaderFooterShadow.set(cfg.showHeaderShadow ?? cfg.showFooterShadow ?? true);
|
|
3100
|
+
const cols = cfg.columns ?? [];
|
|
3101
|
+
const leftPinned = [...(initial?.columnPinning?.left ?? [])];
|
|
3102
|
+
const rightPinned = [...(initial?.columnPinning?.right ?? [])];
|
|
3103
|
+
const collectPinnedColumns = (columns) => {
|
|
3104
|
+
for (const col of columns) {
|
|
3105
|
+
if (col.pinned === 'left' && !leftPinned.includes(col.id)) {
|
|
3106
|
+
leftPinned.push(col.id);
|
|
3098
3107
|
}
|
|
3099
|
-
if (
|
|
3100
|
-
|
|
3108
|
+
if (col.pinned === 'right' && !rightPinned.includes(col.id)) {
|
|
3109
|
+
rightPinned.push(col.id);
|
|
3101
3110
|
}
|
|
3102
|
-
|
|
3103
|
-
|
|
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
|
-
}
|
|
3111
|
+
if (col.columns) {
|
|
3112
|
+
collectPinnedColumns(col.columns);
|
|
3117
3113
|
}
|
|
3118
|
-
};
|
|
3119
|
-
collectPinnedColumns(cols);
|
|
3120
|
-
if (leftPinned.length > 0 || rightPinned.length > 0) {
|
|
3121
|
-
this.columnPinning.set({ left: leftPinned, right: rightPinned });
|
|
3122
3114
|
}
|
|
3123
|
-
}
|
|
3115
|
+
};
|
|
3116
|
+
collectPinnedColumns(cols);
|
|
3117
|
+
if (leftPinned.length > 0 || rightPinned.length > 0) {
|
|
3118
|
+
this.columnPinning.set({ left: leftPinned, right: rightPinned });
|
|
3119
|
+
}
|
|
3124
3120
|
});
|
|
3125
|
-
|
|
3126
|
-
const cfg = this.zConfig();
|
|
3121
|
+
explicitEffect([this.zConfig], ([cfg]) => {
|
|
3127
3122
|
if (cfg.enableRowPinning && !this.hasBodyRowSpan()) {
|
|
3128
3123
|
const cols = cfg.columns ?? [];
|
|
3129
3124
|
const hasSelect = cols.some(c => c.id === 'select');
|
|
3130
3125
|
const hasExpand = cols.some(c => c.id === 'expand');
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
}
|
|
3142
|
-
});
|
|
3126
|
+
const currentPinning = this.columnPinning();
|
|
3127
|
+
const leftPinned = [...(currentPinning.left || [])];
|
|
3128
|
+
if (hasSelect && !leftPinned.includes('select')) {
|
|
3129
|
+
leftPinned.unshift('select');
|
|
3130
|
+
this.columnPinning.set({ ...currentPinning, left: leftPinned });
|
|
3131
|
+
}
|
|
3132
|
+
if (!hasSelect && !hasExpand && !leftPinned.includes('actions')) {
|
|
3133
|
+
leftPinned.unshift('actions');
|
|
3134
|
+
this.columnPinning.set({ ...currentPinning, left: leftPinned });
|
|
3135
|
+
}
|
|
3143
3136
|
}
|
|
3144
3137
|
});
|
|
3145
3138
|
afterNextRender(() => {
|
|
@@ -3189,6 +3182,7 @@ class ZTableComponent {
|
|
|
3189
3182
|
wrapperEl.scrollTop = 0;
|
|
3190
3183
|
wrapperEl.scrollLeft = this._savedScrollLeft();
|
|
3191
3184
|
}
|
|
3185
|
+
this._checkScrollState();
|
|
3192
3186
|
});
|
|
3193
3187
|
});
|
|
3194
3188
|
explicitEffect([
|
|
@@ -3204,11 +3198,7 @@ class ZTableComponent {
|
|
|
3204
3198
|
}, { defer: true });
|
|
3205
3199
|
}
|
|
3206
3200
|
ngAfterViewInit() {
|
|
3207
|
-
this.
|
|
3208
|
-
setTimeout(() => {
|
|
3209
|
-
this._checkVerticalScroll();
|
|
3210
|
-
this._checkHorizontalScroll();
|
|
3211
|
-
}, 100);
|
|
3201
|
+
queueMicrotask(() => this._checkScrollState());
|
|
3212
3202
|
this.zControl.emit({
|
|
3213
3203
|
updateConfig: (config) => {
|
|
3214
3204
|
const current = this.zConfig();
|
|
@@ -3306,6 +3296,10 @@ class ZTableComponent {
|
|
|
3306
3296
|
});
|
|
3307
3297
|
}, 300);
|
|
3308
3298
|
}
|
|
3299
|
+
_checkScrollState() {
|
|
3300
|
+
this._checkVerticalScroll();
|
|
3301
|
+
this._checkHorizontalScroll();
|
|
3302
|
+
}
|
|
3309
3303
|
_checkVerticalScroll() {
|
|
3310
3304
|
const tbodyWrapperEl = this.tbodyWrapper()?.nativeElement;
|
|
3311
3305
|
if (tbodyWrapperEl) {
|
|
@@ -3654,7 +3648,7 @@ class ZTableComponent {
|
|
|
3654
3648
|
collect(columns);
|
|
3655
3649
|
return result;
|
|
3656
3650
|
}
|
|
3657
|
-
|
|
3651
|
+
_loadConfigCache() {
|
|
3658
3652
|
const key = this.zKey();
|
|
3659
3653
|
if (!key) {
|
|
3660
3654
|
return;
|
|
@@ -3672,9 +3666,6 @@ class ZTableComponent {
|
|
|
3672
3666
|
if (config.columnOrder && config.columnOrder.length > 0) {
|
|
3673
3667
|
this.columnOrder.set(config.columnOrder);
|
|
3674
3668
|
}
|
|
3675
|
-
if (config.columnSizing) {
|
|
3676
|
-
this.table.setColumnSizing(config.columnSizing);
|
|
3677
|
-
}
|
|
3678
3669
|
if (config.columnPinning) {
|
|
3679
3670
|
this.columnPinning.set(config.columnPinning);
|
|
3680
3671
|
}
|
|
@@ -3690,6 +3681,9 @@ class ZTableComponent {
|
|
|
3690
3681
|
if (typeof config.showVerticalBorder === 'boolean') {
|
|
3691
3682
|
this.showVerticalBorder.set(config.showVerticalBorder);
|
|
3692
3683
|
}
|
|
3684
|
+
if (config.columnSizing) {
|
|
3685
|
+
this.table.setColumnSizing(config.columnSizing);
|
|
3686
|
+
}
|
|
3693
3687
|
}
|
|
3694
3688
|
catch (error) {
|
|
3695
3689
|
console.error('Failed to load table config:', error);
|