From a351d288b0475270844f047628661c61f67e54a0 Mon Sep 17 00:00:00 2001 From: blouflashdb <45914736+blouflashdb@users.noreply.github.com> Date: Fri, 15 Nov 2024 20:03:41 +0100 Subject: [PATCH 1/5] feat(Table): add pagination --- src/runtime/components/Table.vue | 44 +++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/runtime/components/Table.vue b/src/runtime/components/Table.vue index 67ba35efc1..ccc93466d8 100644 --- a/src/runtime/components/Table.vue +++ b/src/runtime/components/Table.vue @@ -19,9 +19,11 @@ import type { ExpandedOptions, SortingOptions, RowSelectionOptions, + PaginationOptions, Updater, CellContext, - HeaderContext + HeaderContext, + PaginationState } from '@tanstack/vue-table' import _appConfig from '#build/app.config' import theme from '#build/ui/table' @@ -86,6 +88,11 @@ export interface TableProps { * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection) */ rowSelectionOptions?: Omit, 'onRowSelectionChange'> + /** + * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#table-options) + * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination) + */ + paginationOptions?: Omit class?: any ui?: Partial } @@ -102,17 +109,19 @@ export type TableSlots = { @@ -278,8 +279,10 @@ defineExpose({ -
- -
+ +
+ +
+
From 4b4d629d6c9f8072bda53208b23c299741fca67f Mon Sep 17 00:00:00 2001 From: blouflashdb <45914736+blouflashdb@users.noreply.github.com> Date: Thu, 28 Nov 2024 20:56:52 +0100 Subject: [PATCH 5/5] feat(Table): remove Pagination component from Table template --- playground/app/pages/components/table.vue | 7 +++++++ src/runtime/components/Table.vue | 14 +------------- src/theme/table.ts | 3 +-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/playground/app/pages/components/table.vue b/playground/app/pages/components/table.vue index b41dc0ed44..16aee0ae92 100644 --- a/playground/app/pages/components/table.vue +++ b/playground/app/pages/components/table.vue @@ -264,6 +264,12 @@ const columnPinning = ref({ right: ['actions'] }) +const page = ref(1) + +watch(page, () => { + tableApi.setPageIndex(page.value - 1) +}) + function randomize() { data.value = [...data.value].sort(() => Math.random() - 0.5) } @@ -325,6 +331,7 @@ onMounted(() => {
{{ row.original }}
+
diff --git a/src/runtime/components/Table.vue b/src/runtime/components/Table.vue index 822b6663d4..97b52fedd2 100644 --- a/src/runtime/components/Table.vue +++ b/src/runtime/components/Table.vue @@ -110,7 +110,7 @@ export type TableSlots = {