@shival99/z-ui 2.0.38 → 2.0.39
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.
|
@@ -4685,7 +4685,8 @@ class ZTableComponent {
|
|
|
4685
4685
|
_bulkBarTimer = null;
|
|
4686
4686
|
_activeColumnVisibilityPopover = signal(null, ...(ngDevMode ? [{ debugName: "_activeColumnVisibilityPopover" }] : []));
|
|
4687
4687
|
_hasInitializedColumnPinning = false;
|
|
4688
|
-
|
|
4688
|
+
_fitColumnScheduleId = 0;
|
|
4689
|
+
_isFitColumnScheduled = false;
|
|
4689
4690
|
_isApplyingFitColumnSizing = false;
|
|
4690
4691
|
// ─── Template-bound State ─────────────────────────────────────────────────
|
|
4691
4692
|
/** Merged loading state from both zLoading input and config.loading */
|
|
@@ -4711,36 +4712,12 @@ class ZTableComponent {
|
|
|
4711
4712
|
rowPinning = signal({ top: [], bottom: [] }, ...(ngDevMode ? [{ debugName: "rowPinning" }] : []));
|
|
4712
4713
|
columnFilters = signal([], ...(ngDevMode ? [{ debugName: "columnFilters" }] : []));
|
|
4713
4714
|
globalFilter = signal('', ...(ngDevMode ? [{ debugName: "globalFilter" }] : []));
|
|
4714
|
-
//
|
|
4715
|
-
// Use previous state to check if column structure has changed, avoiding sizing resets on reload.
|
|
4715
|
+
// Giữ kích thước cột đã ổn định khi config được tạo lại trong lúc tải dữ liệu.
|
|
4716
4716
|
columnSizingState = linkedSignal({ ...(ngDevMode ? { debugName: "columnSizingState" } : {}), source: () => this._columns(),
|
|
4717
|
-
computation: (cols, previous) =>
|
|
4718
|
-
|
|
4719
|
-
return previous.value;
|
|
4720
|
-
}
|
|
4721
|
-
const initialSizing = {};
|
|
4722
|
-
for (const col of cols) {
|
|
4723
|
-
if (col.id) {
|
|
4724
|
-
initialSizing[col.id] = col.size ?? Math.max(col.minSize ?? 100, 150);
|
|
4725
|
-
}
|
|
4726
|
-
}
|
|
4727
|
-
return initialSizing;
|
|
4728
|
-
} });
|
|
4729
|
-
// Synchronize initial base sizing for column distribution or stretching.
|
|
4730
|
-
// Use previous state to check for changes similar to columnSizingState to prevent resets.
|
|
4717
|
+
computation: (cols, previous) => this._reconcileColumnSizing(cols, previous) });
|
|
4718
|
+
// Tách kích thước gốc khỏi phần chiều rộng được phân bổ thêm theo container.
|
|
4731
4719
|
_columnBaseSizing = linkedSignal({ ...(ngDevMode ? { debugName: "_columnBaseSizing" } : {}), source: () => this._columns(),
|
|
4732
|
-
computation: (cols, previous) =>
|
|
4733
|
-
if (previous && this._areColumnsEquivalent(previous.source, cols)) {
|
|
4734
|
-
return previous.value;
|
|
4735
|
-
}
|
|
4736
|
-
const initialSizing = {};
|
|
4737
|
-
for (const col of cols) {
|
|
4738
|
-
if (col.id) {
|
|
4739
|
-
initialSizing[col.id] = col.size ?? Math.max(col.minSize ?? 100, 150);
|
|
4740
|
-
}
|
|
4741
|
-
}
|
|
4742
|
-
return initialSizing;
|
|
4743
|
-
} });
|
|
4720
|
+
computation: (cols, previous) => this._reconcileColumnSizing(cols, previous) });
|
|
4744
4721
|
/** Note: pageIndex is 1-based here; converted to 0-based for TanStack via _tanstackPagination */
|
|
4745
4722
|
pagination = signal({ pageIndex: 1, pageSize: 10 }, ...(ngDevMode ? [{ debugName: "pagination" }] : []));
|
|
4746
4723
|
sorting = signal([], ...(ngDevMode ? [{ debugName: "sorting" }] : []));
|
|
@@ -6079,7 +6056,7 @@ class ZTableComponent {
|
|
|
6079
6056
|
this._resizeObserver.disconnect();
|
|
6080
6057
|
this._resizeObserver = null;
|
|
6081
6058
|
}
|
|
6082
|
-
this.
|
|
6059
|
+
this._cancelFitColumnSchedule();
|
|
6083
6060
|
});
|
|
6084
6061
|
}
|
|
6085
6062
|
});
|
|
@@ -6616,30 +6593,22 @@ class ZTableComponent {
|
|
|
6616
6593
|
this._columnBaseSizing.set(nextBaseSizing);
|
|
6617
6594
|
}
|
|
6618
6595
|
_scheduleFitColumnWidths() {
|
|
6619
|
-
if (this.
|
|
6596
|
+
if (this._isFitColumnScheduled) {
|
|
6620
6597
|
return;
|
|
6621
6598
|
}
|
|
6622
|
-
|
|
6623
|
-
|
|
6599
|
+
this._isFitColumnScheduled = true;
|
|
6600
|
+
const scheduleId = ++this._fitColumnScheduleId;
|
|
6601
|
+
queueMicrotask(() => {
|
|
6602
|
+
if (scheduleId !== this._fitColumnScheduleId) {
|
|
6603
|
+
return;
|
|
6604
|
+
}
|
|
6605
|
+
this._isFitColumnScheduled = false;
|
|
6624
6606
|
this._applyFitColumnWidths();
|
|
6625
|
-
};
|
|
6626
|
-
if (typeof requestAnimationFrame === 'function') {
|
|
6627
|
-
this._fitColumnFrame = requestAnimationFrame(run);
|
|
6628
|
-
return;
|
|
6629
|
-
}
|
|
6630
|
-
this._fitColumnFrame = setTimeout(run, 0);
|
|
6607
|
+
});
|
|
6631
6608
|
}
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
}
|
|
6636
|
-
if (typeof cancelAnimationFrame === 'function' && typeof this._fitColumnFrame === 'number') {
|
|
6637
|
-
cancelAnimationFrame(this._fitColumnFrame);
|
|
6638
|
-
this._fitColumnFrame = null;
|
|
6639
|
-
return;
|
|
6640
|
-
}
|
|
6641
|
-
clearTimeout(this._fitColumnFrame);
|
|
6642
|
-
this._fitColumnFrame = null;
|
|
6609
|
+
_cancelFitColumnSchedule() {
|
|
6610
|
+
this._fitColumnScheduleId += 1;
|
|
6611
|
+
this._isFitColumnScheduled = false;
|
|
6643
6612
|
}
|
|
6644
6613
|
_applyFitColumnWidths() {
|
|
6645
6614
|
this._syncColumnBaseSizing();
|
|
@@ -6686,19 +6655,25 @@ class ZTableComponent {
|
|
|
6686
6655
|
}
|
|
6687
6656
|
return leftKeys.every(key => left[key] === right[key]);
|
|
6688
6657
|
}
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
const o = oldCols[i];
|
|
6696
|
-
const n = newCols[i];
|
|
6697
|
-
if (o.id !== n.id || o.size !== n.size || o.minSize !== n.minSize || o.maxSize !== n.maxSize) {
|
|
6698
|
-
return false;
|
|
6658
|
+
_reconcileColumnSizing(columns, previous) {
|
|
6659
|
+
const previousColumns = new Map(previous?.source.map(column => [column.id, column]));
|
|
6660
|
+
const nextSizing = {};
|
|
6661
|
+
for (const column of columns) {
|
|
6662
|
+
if (!column.id) {
|
|
6663
|
+
continue;
|
|
6699
6664
|
}
|
|
6665
|
+
const previousColumn = previousColumns.get(column.id);
|
|
6666
|
+
const canKeepPreviousSize = previousColumn &&
|
|
6667
|
+
previousColumn.size === column.size &&
|
|
6668
|
+
previousColumn.minSize === column.minSize &&
|
|
6669
|
+
previousColumn.maxSize === column.maxSize;
|
|
6670
|
+
if (canKeepPreviousSize && previous?.value[column.id] !== undefined) {
|
|
6671
|
+
nextSizing[column.id] = previous.value[column.id];
|
|
6672
|
+
continue;
|
|
6673
|
+
}
|
|
6674
|
+
nextSizing[column.id] = column.size ?? Math.max(column.minSize ?? Z_DEFAULT_COLUMN_MIN_SIZE, 150);
|
|
6700
6675
|
}
|
|
6701
|
-
return
|
|
6676
|
+
return nextSizing;
|
|
6702
6677
|
}
|
|
6703
6678
|
_checkHorizontalScroll() {
|
|
6704
6679
|
const containerEl = this.tbodyContainer()?.nativeElement;
|