@shival99/z-ui 2.0.41 → 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.
|
@@ -4874,64 +4874,73 @@ class ZTableComponent {
|
|
|
4874
4874
|
}
|
|
4875
4875
|
return !this.hasBodyRowSpan();
|
|
4876
4876
|
}, ...(ngDevMode ? [{ debugName: "isRowDragEnabled" }] : []));
|
|
4877
|
-
actionColumnInfo =
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
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
|
+
}
|
|
4885
4890
|
}
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
+
if (col.columns?.length) {
|
|
4892
|
+
const found = findActionColumn(col.columns);
|
|
4893
|
+
if (found) {
|
|
4894
|
+
return found;
|
|
4895
|
+
}
|
|
4891
4896
|
}
|
|
4892
4897
|
}
|
|
4898
|
+
return null;
|
|
4899
|
+
};
|
|
4900
|
+
const actionCol = findActionColumn(columns);
|
|
4901
|
+
if (!actionCol) {
|
|
4902
|
+
return null;
|
|
4893
4903
|
}
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
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 => {
|
|
4916
|
+
if (typeof action.hidden === 'function') {
|
|
4917
|
+
return !action.hidden(row);
|
|
4918
|
+
}
|
|
4919
|
+
return !action.hidden;
|
|
4920
|
+
});
|
|
4921
|
+
const rowButtonCount = visibleActions.length > maxVisible ? 1 : visibleActions.length;
|
|
4922
|
+
buttonCount = Math.max(buttonCount, rowButtonCount);
|
|
4923
|
+
if (buttonCount === maxVisible) {
|
|
4924
|
+
break;
|
|
4909
4925
|
}
|
|
4910
|
-
return !action.hidden;
|
|
4911
|
-
});
|
|
4912
|
-
const rowButtonCount = visibleActions.length > maxVisible ? 1 : visibleActions.length;
|
|
4913
|
-
buttonCount = Math.max(buttonCount, rowButtonCount);
|
|
4914
|
-
if (buttonCount === maxVisible) {
|
|
4915
|
-
break;
|
|
4916
4926
|
}
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
};
|
|
4934
|
-
}, ...(ngDevMode ? [{ debugName: "actionColumnInfo" }] : []));
|
|
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') {
|
|
4932
|
+
buttonCount = maxVisible;
|
|
4933
|
+
}
|
|
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
|
+
} });
|
|
4935
4944
|
_actionColumnRows = computed(() => {
|
|
4936
4945
|
const data = this._data();
|
|
4937
4946
|
const config = this.zConfig();
|
|
@@ -4942,7 +4951,6 @@ class ZTableComponent {
|
|
|
4942
4951
|
const start = Math.max(0, pageIndex - 1) * pageSize;
|
|
4943
4952
|
return data.slice(start, start + pageSize);
|
|
4944
4953
|
}, ...(ngDevMode ? [{ debugName: "_actionColumnRows" }] : []));
|
|
4945
|
-
hasActionColumn = computed(() => this.actionColumnInfo() !== null, ...(ngDevMode ? [{ debugName: "hasActionColumn" }] : []));
|
|
4946
4954
|
_fixedColumnPinning = computed(() => {
|
|
4947
4955
|
const actionColumnId = this.actionColumnInfo()?.columnId;
|
|
4948
4956
|
const configuredColumnIds = new Set();
|
|
@@ -5058,27 +5066,6 @@ class ZTableComponent {
|
|
|
5058
5066
|
};
|
|
5059
5067
|
return columns.some(c => checkServerFilter(c));
|
|
5060
5068
|
}, ...(ngDevMode ? [{ debugName: "hasServerFiltering" }] : []));
|
|
5061
|
-
hasServerSorting = computed(() => {
|
|
5062
|
-
const config = this.zConfig();
|
|
5063
|
-
if (config.enableColumnSorting === false) {
|
|
5064
|
-
return false;
|
|
5065
|
-
}
|
|
5066
|
-
const columns = config.columns ?? [];
|
|
5067
|
-
const checkServerSorting = (col) => {
|
|
5068
|
-
const sortConfig = typeof col.sort === 'boolean' ? { enabled: col.sort } : col.sort;
|
|
5069
|
-
if (sortConfig?.enabled) {
|
|
5070
|
-
const sortMode = sortConfig.mode ?? 'local';
|
|
5071
|
-
if (sortMode === 'server') {
|
|
5072
|
-
return true;
|
|
5073
|
-
}
|
|
5074
|
-
}
|
|
5075
|
-
if (col.columns?.length) {
|
|
5076
|
-
return col.columns.some(c => checkServerSorting(c));
|
|
5077
|
-
}
|
|
5078
|
-
return false;
|
|
5079
|
-
};
|
|
5080
|
-
return columns.some(c => checkServerSorting(c));
|
|
5081
|
-
}, ...(ngDevMode ? [{ debugName: "hasServerSorting" }] : []));
|
|
5082
5069
|
searchConfig = computed(() => {
|
|
5083
5070
|
const { search } = this.zConfig();
|
|
5084
5071
|
if (!search) {
|
|
@@ -5324,7 +5311,6 @@ class ZTableComponent {
|
|
|
5324
5311
|
return columns.some(c => checkFooter(c));
|
|
5325
5312
|
}, ...(ngDevMode ? [{ debugName: "hasFooter" }] : []));
|
|
5326
5313
|
isEmpty = computed(() => this.table.getRowModel().rows.length === 0, ...(ngDevMode ? [{ debugName: "isEmpty" }] : []));
|
|
5327
|
-
isEmptyData = computed(() => this._data().length === 0, ...(ngDevMode ? [{ debugName: "isEmptyData" }] : []));
|
|
5328
5314
|
isNoSearchResults = computed(() => {
|
|
5329
5315
|
const isServerMode = this.zConfig().mode === 'server';
|
|
5330
5316
|
const hasActiveFilter = this.globalFilter().trim() !== '' || this.columnFilters().length > 0;
|
|
@@ -5458,10 +5444,6 @@ class ZTableComponent {
|
|
|
5458
5444
|
.filter(column => column.getIsVisible() && !this._isSpecialColumnId(column.id) && column.id !== actionColumnId)
|
|
5459
5445
|
.map(column => column.id);
|
|
5460
5446
|
}, ...(ngDevMode ? [{ debugName: "fitColumnIds" }] : []));
|
|
5461
|
-
fillColumnId = computed(() => {
|
|
5462
|
-
const columnIds = this.fitColumnIds();
|
|
5463
|
-
return columnIds[columnIds.length - 1] ?? null;
|
|
5464
|
-
}, ...(ngDevMode ? [{ debugName: "fillColumnId" }] : []));
|
|
5465
5447
|
hideableColumns = computed(() => this.orderedLeafColumns().filter(col => col.getCanHide() && !this._isColumnHiddenFromVisibilityMenu(col.id)), ...(ngDevMode ? [{ debugName: "hideableColumns" }] : []));
|
|
5466
5448
|
orderedHeaderGroups = computed(() => {
|
|
5467
5449
|
void this.columnPinning();
|
|
@@ -5507,21 +5489,10 @@ class ZTableComponent {
|
|
|
5507
5489
|
leftHeaderRow = computed(() => this.table.getLeftHeaderGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "leftHeaderRow" }] : []));
|
|
5508
5490
|
centerHeaderRow = computed(() => this.table.getCenterHeaderGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "centerHeaderRow" }] : []));
|
|
5509
5491
|
rightHeaderRow = computed(() => this.table.getRightHeaderGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "rightHeaderRow" }] : []));
|
|
5510
|
-
leftFooterRow = computed(() => this.table.getLeftFooterGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "leftFooterRow" }] : []));
|
|
5511
|
-
centerFooterRow = computed(() => this.table.getCenterFooterGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "centerFooterRow" }] : []));
|
|
5512
|
-
rightFooterRow = computed(() => this.table.getRightFooterGroups()[0]?.headers ?? [], ...(ngDevMode ? [{ debugName: "rightFooterRow" }] : []));
|
|
5513
5492
|
virtualCenterHeaderRow = computed(() => {
|
|
5514
5493
|
const visibleColumns = this.virtualCenterColumnVisibilityMap();
|
|
5515
5494
|
return this.centerHeaderRow().filter(header => visibleColumns[header.column.id]);
|
|
5516
5495
|
}, ...(ngDevMode ? [{ debugName: "virtualCenterHeaderRow" }] : []));
|
|
5517
|
-
virtualCenterFooterRow = computed(() => {
|
|
5518
|
-
const visibleColumns = this.virtualCenterColumnVisibilityMap();
|
|
5519
|
-
return this.centerFooterRow().filter(footer => visibleColumns[footer.column.id]);
|
|
5520
|
-
}, ...(ngDevMode ? [{ debugName: "virtualCenterFooterRow" }] : []));
|
|
5521
|
-
totalWidth = computed(() => {
|
|
5522
|
-
const columns = this.table.getAllLeafColumns();
|
|
5523
|
-
return columns.reduce((sum, col) => sum + col.getSize(), 0);
|
|
5524
|
-
}, ...(ngDevMode ? [{ debugName: "totalWidth" }] : []));
|
|
5525
5496
|
shouldHeaderShowShadow = computed(() => this.showHeaderFooterShadow() && this.table.getTopRows().length === 0, ...(ngDevMode ? [{ debugName: "shouldHeaderShowShadow" }] : []));
|
|
5526
5497
|
shouldFooterShowShadow = computed(() => this.showHeaderFooterShadow() && this.table.getBottomRows().length === 0, ...(ngDevMode ? [{ debugName: "shouldFooterShowShadow" }] : []));
|
|
5527
5498
|
tbodyContainerHeight = signal(0, ...(ngDevMode ? [{ debugName: "tbodyContainerHeight" }] : []));
|
|
@@ -5541,14 +5512,6 @@ class ZTableComponent {
|
|
|
5541
5512
|
}
|
|
5542
5513
|
return Math.min(this.pagination().pageSize || 10, 10);
|
|
5543
5514
|
}, ...(ngDevMode ? [{ debugName: "skeletonRowCount" }] : []));
|
|
5544
|
-
actualSkeletonRowHeight = computed(() => {
|
|
5545
|
-
const containerHeight = this.tbodyContainerHeight();
|
|
5546
|
-
const rowCount = this.skeletonRowCount();
|
|
5547
|
-
if (containerHeight > 0 && rowCount > 0) {
|
|
5548
|
-
return containerHeight / rowCount;
|
|
5549
|
-
}
|
|
5550
|
-
return this.skeletonRowHeight();
|
|
5551
|
-
}, ...(ngDevMode ? [{ debugName: "actualSkeletonRowHeight" }] : []));
|
|
5552
5515
|
skeletonRows = computed(() => {
|
|
5553
5516
|
const count = this.skeletonRowCount();
|
|
5554
5517
|
return Array.from({ length: count }, (_, i) => i);
|
|
@@ -6082,21 +6045,19 @@ class ZTableComponent {
|
|
|
6082
6045
|
// }
|
|
6083
6046
|
// });
|
|
6084
6047
|
// });
|
|
6085
|
-
let
|
|
6086
|
-
let lastResetFilters = null;
|
|
6087
|
-
let lastResetSorting = null;
|
|
6048
|
+
let lastResetState = null;
|
|
6088
6049
|
explicitEffect([this.columnFilters, this.globalFilter, this.pagination, this.sorting], ([columnFilters, globalFilter, pagination, sorting]) => {
|
|
6089
|
-
const
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6050
|
+
const resetState = JSON.stringify({
|
|
6051
|
+
columnFilters,
|
|
6052
|
+
globalFilter,
|
|
6053
|
+
pageIndex: pagination.pageIndex,
|
|
6054
|
+
pageSize: pagination.pageSize,
|
|
6055
|
+
sorting,
|
|
6056
|
+
});
|
|
6057
|
+
if (lastResetState === resetState) {
|
|
6095
6058
|
return;
|
|
6096
6059
|
}
|
|
6097
|
-
|
|
6098
|
-
lastResetPagination = paginationStr;
|
|
6099
|
-
lastResetSorting = sortingStr;
|
|
6060
|
+
lastResetState = resetState;
|
|
6100
6061
|
if (this.isVirtual()) {
|
|
6101
6062
|
const wrapperEl = this.tbodyWrapper()?.nativeElement;
|
|
6102
6063
|
if (wrapperEl) {
|
|
@@ -6570,7 +6531,6 @@ class ZTableComponent {
|
|
|
6570
6531
|
this._scheduleFitColumnWidths();
|
|
6571
6532
|
}
|
|
6572
6533
|
_syncColumnBaseSizing() {
|
|
6573
|
-
const visibleColumnIds = new Set();
|
|
6574
6534
|
const currentBaseSizing = this._columnBaseSizing();
|
|
6575
6535
|
const currentSizing = this.columnSizingState();
|
|
6576
6536
|
const nextBaseSizing = {};
|
|
@@ -6578,11 +6538,10 @@ class ZTableComponent {
|
|
|
6578
6538
|
if (!column.getIsVisible()) {
|
|
6579
6539
|
continue;
|
|
6580
6540
|
}
|
|
6581
|
-
visibleColumnIds.add(column.id);
|
|
6582
6541
|
nextBaseSizing[column.id] =
|
|
6583
6542
|
currentBaseSizing[column.id] ?? currentSizing[column.id] ?? column.columnDef.size ?? column.getSize();
|
|
6584
6543
|
}
|
|
6585
|
-
if (
|
|
6544
|
+
if (Object.keys(nextBaseSizing).length === 0) {
|
|
6586
6545
|
return;
|
|
6587
6546
|
}
|
|
6588
6547
|
if (this._isSameColumnSizing(currentBaseSizing, nextBaseSizing)) {
|