feat(hooks): add scrollX computation for total table width in useNaiveTable

This commit is contained in:
Cell 2025-08-04 18:15:18 +08:00 committed by Soybean
parent 9ea56c9b82
commit 358e129765

View File

@ -38,6 +38,13 @@ export function useNaiveTable<ResponseData, ApiData>(options: UseNaiveTableOptio
getColumns getColumns
}); });
// calculate the total width of the table this is used for horizontal scrolling
const scrollX = computed(() => {
return result.columns.value.reduce((acc, column) => {
return acc + Number(column.width ?? column.minWidth ?? 120);
}, 0);
});
scope.run(() => { scope.run(() => {
watch( watch(
() => appStore.locale, () => appStore.locale,
@ -51,7 +58,10 @@ export function useNaiveTable<ResponseData, ApiData>(options: UseNaiveTableOptio
scope.stop(); scope.stop();
}); });
return result; return {
...result,
scrollX
};
} }
type PaginationParams = Pick<PaginationProps, 'page' | 'pageSize'>; type PaginationParams = Pick<PaginationProps, 'page' | 'pageSize'>;