@shival99/z-ui 2.0.40 → 2.0.42
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,9 +4685,7 @@ class ZTableComponent {
|
|
|
4685
4685
|
_bulkBarTimer = null;
|
|
4686
4686
|
_activeColumnVisibilityPopover = signal(null, ...(ngDevMode ? [{ debugName: "_activeColumnVisibilityPopover" }] : []));
|
|
4687
4687
|
_hasInitializedColumnPinning = false;
|
|
4688
|
-
_fitColumnScheduleId = 0;
|
|
4689
4688
|
_isFitColumnScheduled = false;
|
|
4690
|
-
_isApplyingFitColumnSizing = false;
|
|
4691
4689
|
// ─── Template-bound State ─────────────────────────────────────────────────
|
|
4692
4690
|
/** Merged loading state from both zLoading input and config.loading */
|
|
4693
4691
|
isLoading = computed(() => this.zConfig().loading ?? this.zLoading(), ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
|
|
@@ -4876,40 +4874,45 @@ class ZTableComponent {
|
|
|
4876
4874
|
}
|
|
4877
4875
|
return !this.hasBodyRowSpan();
|
|
4878
4876
|
}, ...(ngDevMode ? [{ debugName: "isRowDragEnabled" }] : []));
|
|
4879
|
-
actionColumnInfo =
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4877
|
+
actionColumnInfo = linkedSignal({ ...(ngDevMode ? { debugName: "actionColumnInfo" } : {}), source: () => ({
|
|
4878
|
+
columns: this.zConfig().columns ?? [],
|
|
4879
|
+
isPending: this.isLoading() || this.isProcessing(),
|
|
4880
|
+
rows: this._actionColumnRows(),
|
|
4881
|
+
}),
|
|
4882
|
+
computation: ({ columns, isPending, rows }, previous) => {
|
|
4883
|
+
const findActionColumn = (cols) => {
|
|
4884
|
+
for (const col of cols) {
|
|
4885
|
+
if (isBodyConfig(col.body)) {
|
|
4886
|
+
const actionConfig = this._getActionColumnConfig(col.body);
|
|
4887
|
+
if (actionConfig) {
|
|
4888
|
+
return { columnId: col.id, config: actionConfig };
|
|
4889
|
+
}
|
|
4887
4890
|
}
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4891
|
+
if (col.columns?.length) {
|
|
4892
|
+
const found = findActionColumn(col.columns);
|
|
4893
|
+
if (found) {
|
|
4894
|
+
return found;
|
|
4895
|
+
}
|
|
4893
4896
|
}
|
|
4894
4897
|
}
|
|
4898
|
+
return null;
|
|
4899
|
+
};
|
|
4900
|
+
const actionCol = findActionColumn(columns);
|
|
4901
|
+
if (!actionCol) {
|
|
4902
|
+
return null;
|
|
4895
4903
|
}
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
}
|
|
4909
|
-
if (typeof config.actions === 'function') {
|
|
4910
|
-
const data = this._actionColumnRows();
|
|
4911
|
-
for (const row of data) {
|
|
4912
|
-
const visibleActions = config.actions(row).filter(action => {
|
|
4904
|
+
if (isPending && previous?.value?.columnId === actionCol.columnId) {
|
|
4905
|
+
return {
|
|
4906
|
+
...previous.value,
|
|
4907
|
+
config: actionCol.config,
|
|
4908
|
+
};
|
|
4909
|
+
}
|
|
4910
|
+
const { config } = actionCol;
|
|
4911
|
+
const maxVisible = config.maxVisible ?? Z_TABLE_DEFAULT_MAX_VISIBLE_ACTIONS;
|
|
4912
|
+
let buttonCount = 0;
|
|
4913
|
+
for (const row of rows) {
|
|
4914
|
+
const actions = typeof config.actions === 'function' ? config.actions(row) : config.actions;
|
|
4915
|
+
const visibleActions = actions.filter(action => {
|
|
4913
4916
|
if (typeof action.hidden === 'function') {
|
|
4914
4917
|
return !action.hidden(row);
|
|
4915
4918
|
}
|
|
@@ -4921,20 +4924,23 @@ class ZTableComponent {
|
|
|
4921
4924
|
break;
|
|
4922
4925
|
}
|
|
4923
4926
|
}
|
|
4924
|
-
if (
|
|
4927
|
+
if (rows.length === 0 && Array.isArray(config.actions)) {
|
|
4928
|
+
const possibleVisibleCount = config.actions.filter(action => action.hidden !== true).length;
|
|
4929
|
+
buttonCount = possibleVisibleCount > maxVisible ? 1 : possibleVisibleCount;
|
|
4930
|
+
}
|
|
4931
|
+
if (rows.length === 0 && typeof config.actions === 'function') {
|
|
4925
4932
|
buttonCount = maxVisible;
|
|
4926
4933
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
};
|
|
4937
|
-
}, ...(ngDevMode ? [{ debugName: "actionColumnInfo" }] : []));
|
|
4934
|
+
const buttonWidth = Z_TABLE_DEFAULT_ACTION_BUTTON_WIDTH;
|
|
4935
|
+
const gap = 4;
|
|
4936
|
+
const padding = 16;
|
|
4937
|
+
const width = buttonCount * buttonWidth + Math.max(0, buttonCount - 1) * gap + padding;
|
|
4938
|
+
return {
|
|
4939
|
+
columnId: actionCol.columnId,
|
|
4940
|
+
config: actionCol.config,
|
|
4941
|
+
width,
|
|
4942
|
+
};
|
|
4943
|
+
} });
|
|
4938
4944
|
_actionColumnRows = computed(() => {
|
|
4939
4945
|
const data = this._data();
|
|
4940
4946
|
const config = this.zConfig();
|
|
@@ -4945,7 +4951,6 @@ class ZTableComponent {
|
|
|
4945
4951
|
const start = Math.max(0, pageIndex - 1) * pageSize;
|
|
4946
4952
|
return data.slice(start, start + pageSize);
|
|
4947
4953
|
}, ...(ngDevMode ? [{ debugName: "_actionColumnRows" }] : []));
|
|
4948
|
-
hasActionColumn = computed(() => this.actionColumnInfo() !== null, ...(ngDevMode ? [{ debugName: "hasActionColumn" }] : []));
|
|
4949
4954
|
_fixedColumnPinning = computed(() => {
|
|
4950
4955
|
const actionColumnId = this.actionColumnInfo()?.columnId;
|
|
4951
4956
|
const configuredColumnIds = new Set();
|
|
@@ -5061,27 +5066,6 @@ class ZTableComponent {
|
|
|
5061
5066
|
};
|
|
5062
5067
|
return columns.some(c => checkServerFilter(c));
|
|
5063
5068
|
}, ...(ngDevMode ? [{ debugName: "hasServerFiltering" }] : []));
|
|
5064
|
-
hasServerSorting = computed(() => {
|
|
5065
|
-
const config = this.zConfig();
|
|
5066
|
-
if (config.enableColumnSorting === false) {
|
|
5067
|
-
return false;
|
|
5068
|
-
}
|
|
5069
|
-
const columns = config.columns ?? [];
|
|
5070
|
-
const checkServerSorting = (col) => {
|
|
5071
|
-
const sortConfig = typeof col.sort === 'boolean' ? { enabled: col.sort } : col.sort;
|
|
5072
|
-
if (sortConfig?.enabled) {
|
|
5073
|
-
const sortMode = sortConfig.mode ?? 'local';
|
|
5074
|
-
if (sortMode === 'server') {
|
|
5075
|
-
return true;
|
|
5076
|
-
}
|
|
5077
|
-
}
|
|
5078
|
-
if (col.columns?.length) {
|
|
5079
|
-
return col.columns.some(c => checkServerSorting(c));
|
|
5080
|
-
}
|
|
5081
|
-
return false;
|
|
5082
|
-
};
|
|
5083
|
-
return columns.some(c => checkServerSorting(c));
|
|
5084
|
-
}, ...(ngDevMode ? [{ debugName: "hasServerSorting" }] : []));
|
|
5085
5069
|
searchConfig = computed(() => {
|
|
5086
5070
|
const { search } = this.zConfig();
|
|
5087
5071
|
if (!search) {
|
|
@@ -5327,7 +5311,6 @@ class ZTableComponent {
|
|
|
5327
5311
|
return columns.some(c => checkFooter(c));
|
|
5328
5312
|
}, ...(ngDevMode ? [{ debugName: "hasFooter" }] : []));
|
|
5329
5313
|
isEmpty = computed(() => this.table.getRowModel().rows.length === 0, ...(ngDevMode ? [{ debugName: "isEmpty" }] : []));
|
|
5330
|
-
isEmptyData = computed(() => this._data().length === 0, ...(ngDevMode ? [{ debugName: "isEmptyData" }] : []));
|
|
5331
5314
|
isNoSearchResults = computed(() => {
|
|
5332
5315
|
const isServerMode = this.zConfig().mode === 'server';
|
|
5333
5316
|
const hasActiveFilter = this.globalFilter().trim() !== '' || this.columnFilters().length > 0;
|
|
@@ -5461,10 +5444,6 @@ class ZTableComponent {
|
|
|
5461
5444
|
.filter(column => column.getIsVisible() && !this._isSpecialColumnId(column.id) && column.id !== actionColumnId)
|
|
5462
5445
|
.map(column => column.id);
|
|
5463
5446
|
}, ...(ngDevMode ? [{ debugName: "fitColumnIds" }] : []));
|
|
5464
|
-
fillColumnId = computed(() => {
|
|
5465
|
-
const columnIds = this.fitColumnIds();
|
|
5466
|
-
return columnIds[columnIds.length - 1] ?? null;
|
|
5467
|
-
}, ...(ngDevMode ? [{ debugName: "fillColumnId" }] : []));
|
|
5468
5447
|
hideableColumns = computed(() => this.orderedLeafColumns().filter(col => col.getCanHide() && !this._isColumnHiddenFromVisibilityMenu(col.id)), ...(ngDevMode ? [{ debugName: "hideableColumns" }] : []));
|
|
5469
5448
|
orderedHeaderGroups = computed(() => {
|
|
5470
5449
|
void this.columnPinning();
|
|
@@ -5510,21 +5489,10 @@ class ZTableComponent {
|
|
|
5510
5489
|
leftHeaderRow = computed(() => this.table.getLeftHeaderGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "leftHeaderRow" }] : []));
|
|
5511
5490
|
centerHeaderRow = computed(() => this.table.getCenterHeaderGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "centerHeaderRow" }] : []));
|
|
5512
5491
|
rightHeaderRow = computed(() => this.table.getRightHeaderGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "rightHeaderRow" }] : []));
|
|
5513
|
-
leftFooterRow = computed(() => this.table.getLeftFooterGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "leftFooterRow" }] : []));
|
|
5514
|
-
centerFooterRow = computed(() => this.table.getCenterFooterGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "centerFooterRow" }] : []));
|
|
5515
|
-
rightFooterRow = computed(() => this.table.getRightFooterGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "rightFooterRow" }] : []));
|
|
5516
5492
|
virtualCenterHeaderRow = computed(() => {
|
|
5517
5493
|
const visibleColumns = this.virtualCenterColumnVisibilityMap();
|
|
5518
5494
|
return this.centerHeaderRow().filter(header => visibleColumns[header.column.id]);
|
|
5519
5495
|
}, ...(ngDevMode ? [{ debugName: "virtualCenterHeaderRow" }] : []));
|
|
5520
|
-
virtualCenterFooterRow = computed(() => {
|
|
5521
|
-
const visibleColumns = this.virtualCenterColumnVisibilityMap();
|
|
5522
|
-
return this.centerFooterRow().filter(footer => visibleColumns[footer.column.id]);
|
|
5523
|
-
}, ...(ngDevMode ? [{ debugName: "virtualCenterFooterRow" }] : []));
|
|
5524
|
-
totalWidth = computed(() => {
|
|
5525
|
-
const columns = this.table.getAllLeafColumns();
|
|
5526
|
-
return columns.reduce((sum, col) => sum + col.getSize(), 0);
|
|
5527
|
-
}, ...(ngDevMode ? [{ debugName: "totalWidth" }] : []));
|
|
5528
5496
|
shouldHeaderShowShadow = computed(() => this.showHeaderFooterShadow() && this.table.getTopRows().length === 0, ...(ngDevMode ? [{ debugName: "shouldHeaderShowShadow" }] : []));
|
|
5529
5497
|
shouldFooterShowShadow = computed(() => this.showHeaderFooterShadow() && this.table.getBottomRows().length === 0, ...(ngDevMode ? [{ debugName: "shouldFooterShowShadow" }] : []));
|
|
5530
5498
|
tbodyContainerHeight = signal(0, ...(ngDevMode ? [{ debugName: "tbodyContainerHeight" }] : []));
|
|
@@ -5544,14 +5512,6 @@ class ZTableComponent {
|
|
|
5544
5512
|
}
|
|
5545
5513
|
return Math.min(this.pagination().pageSize || 10, 10);
|
|
5546
5514
|
}, ...(ngDevMode ? [{ debugName: "skeletonRowCount" }] : []));
|
|
5547
|
-
actualSkeletonRowHeight = computed(() => {
|
|
5548
|
-
const containerHeight = this.tbodyContainerHeight();
|
|
5549
|
-
const rowCount = this.skeletonRowCount();
|
|
5550
|
-
if (containerHeight > 0 && rowCount > 0) {
|
|
5551
|
-
return containerHeight / rowCount;
|
|
5552
|
-
}
|
|
5553
|
-
return this.skeletonRowHeight();
|
|
5554
|
-
}, ...(ngDevMode ? [{ debugName: "actualSkeletonRowHeight" }] : []));
|
|
5555
5515
|
skeletonRows = computed(() => {
|
|
5556
5516
|
const count = this.skeletonRowCount();
|
|
5557
5517
|
return Array.from({ length: count }, (_, i) => i);
|
|
@@ -6061,7 +6021,6 @@ class ZTableComponent {
|
|
|
6061
6021
|
this._resizeObserver.disconnect();
|
|
6062
6022
|
this._resizeObserver = null;
|
|
6063
6023
|
}
|
|
6064
|
-
this._cancelFitColumnSchedule();
|
|
6065
6024
|
});
|
|
6066
6025
|
}
|
|
6067
6026
|
});
|
|
@@ -6086,21 +6045,19 @@ class ZTableComponent {
|
|
|
6086
6045
|
// }
|
|
6087
6046
|
// });
|
|
6088
6047
|
// });
|
|
6089
|
-
let
|
|
6090
|
-
let lastResetFilters = null;
|
|
6091
|
-
let lastResetSorting = null;
|
|
6048
|
+
let lastResetState = null;
|
|
6092
6049
|
explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting], ([columnFilters, globalFilter, pagination, sorting]) => {
|
|
6093
|
-
const
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6050
|
+
const resetState = JSON.stringify({
|
|
6051
|
+
columnFilters,
|
|
6052
|
+
globalFilter,
|
|
6053
|
+
pageIndex: pagination.pageIndex,
|
|
6054
|
+
pageSize: pagination.pageSize,
|
|
6055
|
+
sorting,
|
|
6056
|
+
});
|
|
6057
|
+
if (lastResetState === resetState) {
|
|
6099
6058
|
return;
|
|
6100
6059
|
}
|
|
6101
|
-
|
|
6102
|
-
lastResetPagination = paginationStr;
|
|
6103
|
-
lastResetSorting = sortingStr;
|
|
6060
|
+
lastResetState = resetState;
|
|
6104
6061
|
if (this.isVirtual()) {
|
|
6105
6062
|
const wrapperEl = this.tbodyWrapper()?.nativeElement;
|
|
6106
6063
|
if (wrapperEl) {
|
|
@@ -6570,14 +6527,10 @@ class ZTableComponent {
|
|
|
6570
6527
|
return;
|
|
6571
6528
|
}
|
|
6572
6529
|
this.columnSizingState.set(next);
|
|
6573
|
-
if (this._isApplyingFitColumnSizing) {
|
|
6574
|
-
return;
|
|
6575
|
-
}
|
|
6576
6530
|
this._columnBaseSizing.set(next);
|
|
6577
6531
|
this._scheduleFitColumnWidths();
|
|
6578
6532
|
}
|
|
6579
6533
|
_syncColumnBaseSizing() {
|
|
6580
|
-
const visibleColumnIds = new Set();
|
|
6581
6534
|
const currentBaseSizing = this._columnBaseSizing();
|
|
6582
6535
|
const currentSizing = this.columnSizingState();
|
|
6583
6536
|
const nextBaseSizing = {};
|
|
@@ -6585,11 +6538,10 @@ class ZTableComponent {
|
|
|
6585
6538
|
if (!column.getIsVisible()) {
|
|
6586
6539
|
continue;
|
|
6587
6540
|
}
|
|
6588
|
-
visibleColumnIds.add(column.id);
|
|
6589
6541
|
nextBaseSizing[column.id] =
|
|
6590
6542
|
currentBaseSizing[column.id] ?? currentSizing[column.id] ?? column.columnDef.size ?? column.getSize();
|
|
6591
6543
|
}
|
|
6592
|
-
if (
|
|
6544
|
+
if (Object.keys(nextBaseSizing).length === 0) {
|
|
6593
6545
|
return;
|
|
6594
6546
|
}
|
|
6595
6547
|
if (this._isSameColumnSizing(currentBaseSizing, nextBaseSizing)) {
|
|
@@ -6602,19 +6554,11 @@ class ZTableComponent {
|
|
|
6602
6554
|
return;
|
|
6603
6555
|
}
|
|
6604
6556
|
this._isFitColumnScheduled = true;
|
|
6605
|
-
const scheduleId = ++this._fitColumnScheduleId;
|
|
6606
6557
|
queueMicrotask(() => {
|
|
6607
|
-
if (scheduleId !== this._fitColumnScheduleId) {
|
|
6608
|
-
return;
|
|
6609
|
-
}
|
|
6610
6558
|
this._isFitColumnScheduled = false;
|
|
6611
6559
|
this._applyFitColumnWidths();
|
|
6612
6560
|
});
|
|
6613
6561
|
}
|
|
6614
|
-
_cancelFitColumnSchedule() {
|
|
6615
|
-
this._fitColumnScheduleId += 1;
|
|
6616
|
-
this._isFitColumnScheduled = false;
|
|
6617
|
-
}
|
|
6618
6562
|
_applyFitColumnWidths() {
|
|
6619
6563
|
this._syncColumnBaseSizing();
|
|
6620
6564
|
const baseSizing = this._columnBaseSizing();
|
|
@@ -6645,9 +6589,7 @@ class ZTableComponent {
|
|
|
6645
6589
|
if (this._isSameColumnSizing(this.columnSizingState(), nextSizing)) {
|
|
6646
6590
|
return;
|
|
6647
6591
|
}
|
|
6648
|
-
this._isApplyingFitColumnSizing = true;
|
|
6649
6592
|
this.columnSizingState.set(nextSizing);
|
|
6650
|
-
this._isApplyingFitColumnSizing = false;
|
|
6651
6593
|
}
|
|
6652
6594
|
_getColumnBaseSize(column, baseSizing) {
|
|
6653
6595
|
return baseSizing[column.id] ?? column.columnDef.size ?? column.getSize();
|