@aleph-alpha/ui-library 7.1.0 → 7.2.0

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.
Files changed (53) hide show
  1. package/dist/system/components/UiPagination/UiPagination.vue.d.ts +19 -0
  2. package/dist/system/components/UiPagination/constants.d.ts +6 -0
  3. package/dist/system/components/UiPagination/index.d.ts +3 -0
  4. package/dist/system/components/UiPagination/types.d.ts +81 -0
  5. package/dist/system/components/core/pagination/Pagination.vue.d.ts +29 -0
  6. package/dist/system/components/core/pagination/PaginationContent.vue.d.ts +29 -0
  7. package/dist/system/components/core/pagination/PaginationEllipsis.vue.d.ts +22 -0
  8. package/dist/system/components/core/pagination/PaginationFirst.vue.d.ts +22 -0
  9. package/dist/system/components/core/pagination/PaginationItem.vue.d.ts +26 -0
  10. package/dist/system/components/core/pagination/PaginationLast.vue.d.ts +22 -0
  11. package/dist/system/components/core/pagination/PaginationNext.vue.d.ts +22 -0
  12. package/dist/system/components/core/pagination/PaginationPrevious.vue.d.ts +22 -0
  13. package/dist/system/components/core/pagination/index.d.ts +8 -0
  14. package/dist/system/components/index.d.ts +1 -0
  15. package/dist/system/icons/story-sidebar-icons.json +4 -0
  16. package/dist/system/lib.js +11605 -10906
  17. package/dist/system/patterns/UiBulkAction/UiBulkAction.vue.d.ts +43 -0
  18. package/dist/system/patterns/UiBulkAction/index.d.ts +3 -0
  19. package/dist/system/patterns/UiBulkAction/types.d.ts +109 -0
  20. package/dist/system/patterns/UiBulkAction/useBulkAction.d.ts +7 -0
  21. package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
  22. package/dist/system/patterns/index.d.ts +1 -0
  23. package/dist/system/story-sidebar-icons.json +4 -0
  24. package/package.json +1 -1
  25. package/src/components/UiPagination/UiPagination.guidance.md +60 -0
  26. package/src/components/UiPagination/UiPagination.stories.ts +1070 -0
  27. package/src/components/UiPagination/UiPagination.vue +109 -0
  28. package/src/components/UiPagination/__tests__/UiPagination.test.ts +203 -0
  29. package/src/components/UiPagination/constants.ts +17 -0
  30. package/src/components/UiPagination/index.ts +3 -0
  31. package/src/components/UiPagination/types.ts +82 -0
  32. package/src/components/core/pagination/Pagination.vue +26 -0
  33. package/src/components/core/pagination/PaginationContent.vue +24 -0
  34. package/src/components/core/pagination/PaginationEllipsis.vue +30 -0
  35. package/src/components/core/pagination/PaginationFirst.vue +30 -0
  36. package/src/components/core/pagination/PaginationItem.vue +39 -0
  37. package/src/components/core/pagination/PaginationLast.vue +30 -0
  38. package/src/components/core/pagination/PaginationNext.vue +35 -0
  39. package/src/components/core/pagination/PaginationPrevious.vue +35 -0
  40. package/src/components/core/pagination/index.ts +8 -0
  41. package/src/components/index.ts +1 -0
  42. package/src/patterns/UiBulkAction/UiBulkAction.guidance.md +59 -0
  43. package/src/patterns/UiBulkAction/UiBulkAction.stories.ts +2238 -0
  44. package/src/patterns/UiBulkAction/UiBulkAction.vue +62 -0
  45. package/src/patterns/UiBulkAction/__tests__/useBulkAction.test.ts +78 -0
  46. package/src/patterns/UiBulkAction/index.ts +3 -0
  47. package/src/patterns/UiBulkAction/types.ts +126 -0
  48. package/src/patterns/UiBulkAction/useBulkAction.ts +50 -0
  49. package/src/patterns/UiDataTable/UiDataTable.stories.ts +375 -1
  50. package/src/patterns/UiDataTable/UiDataTablePagination.vue +43 -60
  51. package/src/patterns/UiDataTable/__tests__/UiDataTablePagination.test.ts +58 -29
  52. package/src/patterns/UiDataTable/constants.ts +10 -0
  53. package/src/patterns/index.ts +1 -0
@@ -1155,7 +1155,7 @@ export const WithSorting: Story = {
1155
1155
  * Table with pagination controls.
1156
1156
  *
1157
1157
  * Use `UiDataTablePagination` when displaying more than 10 rows.
1158
- * Shows navigation buttons (first, prev, next, last), page info, and rows per page selector.
1158
+ * Shows `UiPagination` (first, previous, numbered pages, next, last), page info, and rows per page selector.
1159
1159
  *
1160
1160
  * The `tableMinHeight` prop prevents layout shifts during pagination by ensuring
1161
1161
  * the table container maintains a minimum height. The last row has a visible
@@ -3051,3 +3051,377 @@ export const MobileBreakpoint: Story = {
3051
3051
  );
3052
3052
  },
3053
3053
  };
3054
+
3055
+ // Pagination footer scenarios: 120 rows at the default page size of 10 give 12
3056
+ // pages, enough for the footer to collapse a range into an ellipsis. Emails are
3057
+ // numbered so each page's first and last row are predictable.
3058
+ const paginationTestData: Payment[] = Array.from({ length: 120 }, (_, i) => ({
3059
+ id: String(i + 1),
3060
+ amount: (i + 1) * 10,
3061
+ status: 'success',
3062
+ email: `user${String(i + 1).padStart(3, '0')}@example.com`,
3063
+ }));
3064
+
3065
+ const createPaginationFooterRender = (columns: ColumnDef<Payment>[]) => () => ({
3066
+ components: { UiDataTable, UiDataTablePagination },
3067
+ setup() {
3068
+ const tableRef = ref<InstanceType<typeof UiDataTable>>();
3069
+ const table = computed(() => tableRef.value?.table);
3070
+ return {
3071
+ tableRef,
3072
+ table,
3073
+ columns,
3074
+ data: paginationTestData,
3075
+ };
3076
+ },
3077
+ // Block layout on purpose: the lazy CSS scan in the browser test run does not
3078
+ // generate wrapper utilities like `flex-col`, which would put the footer
3079
+ // beside the table and break the mobile geometry checks.
3080
+ template: `
3081
+ <div>
3082
+ <UiDataTable ref="tableRef" :columns="columns" :data="data" />
3083
+ <UiDataTablePagination v-if="table" :table="table" :show-selection="false" />
3084
+ </div>
3085
+ `,
3086
+ });
3087
+
3088
+ // Plain headers keep the footer first in the Tab order for the keyboard play.
3089
+ const paginationFooterRender = createPaginationFooterRender(basicColumns);
3090
+
3091
+ /**
3092
+ * The pagination footer pages the table: Next, Previous, page numbers, and the
3093
+ * first/last controls each swap the visible rows and update the page info.
3094
+ */
3095
+ export const PaginationInteraction: Story = {
3096
+ name: 'test - Pagination Interaction',
3097
+ tags: ['!dev', '!autodocs'],
3098
+ parameters: {
3099
+ // Page state changes during the play; skip the visual snapshot.
3100
+ chromatic: { disableSnapshot: true },
3101
+ docs: {
3102
+ description: {
3103
+ story:
3104
+ 'Page through the table with Next, Previous, page numbers, and the first/last controls.',
3105
+ },
3106
+ },
3107
+ },
3108
+ render: paginationFooterRender,
3109
+ play: async ({ canvasElement, step }) => {
3110
+ // Scenario (UiDataTablePagination): a user pages forward and back, jumps to
3111
+ // a numbered page, and uses the edge controls; the rows and the page info
3112
+ // follow every change and the end controls disable at the ends.
3113
+ const canvas = within(canvasElement);
3114
+ const button = (name: string | RegExp) =>
3115
+ canvas.getByRole('button', { name });
3116
+
3117
+ await step('interaction: starts on the first page', async () => {
3118
+ await expect(canvas.getByText('Page 1 of 12')).toBeInTheDocument();
3119
+ await expect(canvas.getByText('user001@example.com')).toBeInTheDocument();
3120
+ await expect(button('Go to first page')).toBeDisabled();
3121
+ await expect(button('Go to previous page')).toBeDisabled();
3122
+ });
3123
+
3124
+ await step('interaction: next shows the following rows', async () => {
3125
+ await userEvent.click(button('Go to next page'));
3126
+ await expect(canvas.getByText('Page 2 of 12')).toBeInTheDocument();
3127
+ await expect(canvas.getByText('user011@example.com')).toBeInTheDocument();
3128
+ await expect(
3129
+ canvas.queryByText('user001@example.com'),
3130
+ ).not.toBeInTheDocument();
3131
+ });
3132
+
3133
+ await step('interaction: a page number jumps to that page', async () => {
3134
+ await userEvent.click(button('Page 5'));
3135
+ await expect(canvas.getByText('Page 5 of 12')).toBeInTheDocument();
3136
+ await expect(canvas.getByText('user041@example.com')).toBeInTheDocument();
3137
+ await expect(button('Page 5')).toHaveAttribute('aria-current', 'page');
3138
+ });
3139
+
3140
+ await step('interaction: previous steps back one page', async () => {
3141
+ await userEvent.click(button('Go to previous page'));
3142
+ await expect(canvas.getByText('Page 4 of 12')).toBeInTheDocument();
3143
+ });
3144
+
3145
+ await step(
3146
+ 'interaction: last jumps to the end and disables next/last',
3147
+ async () => {
3148
+ await userEvent.click(button('Go to last page'));
3149
+ await expect(canvas.getByText('Page 12 of 12')).toBeInTheDocument();
3150
+ await expect(
3151
+ canvas.getByText('user120@example.com'),
3152
+ ).toBeInTheDocument();
3153
+ await expect(button('Go to next page')).toBeDisabled();
3154
+ await expect(button('Go to last page')).toBeDisabled();
3155
+ },
3156
+ );
3157
+
3158
+ await step('interaction: first returns to the start', async () => {
3159
+ await userEvent.click(button('Go to first page'));
3160
+ await expect(canvas.getByText('Page 1 of 12')).toBeInTheDocument();
3161
+ });
3162
+ },
3163
+ };
3164
+
3165
+ /**
3166
+ * The footer is keyboard operable: `Tab` reaches the rows-per-page menu and
3167
+ * the page controls in visual order, skipping disabled ones, and `Enter` or
3168
+ * `Space` changes page.
3169
+ */
3170
+ export const PaginationKeyboard: Story = {
3171
+ name: 'test - Pagination Keyboard',
3172
+ tags: ['!dev', '!autodocs'],
3173
+ parameters: {
3174
+ // Focus moves during the play; skip the visual snapshot.
3175
+ chromatic: { disableSnapshot: true },
3176
+ docs: {
3177
+ description: {
3178
+ story:
3179
+ 'Press `Tab` to move through the footer controls, then `Enter` or `Space` to change page.',
3180
+ },
3181
+ },
3182
+ },
3183
+ render: paginationFooterRender,
3184
+ play: async ({ canvasElement, step }) => {
3185
+ // Scenario (UiDataTablePagination): a keyboard user tabs through the footer,
3186
+ // skips the disabled first/previous controls, and pages with Enter/Space.
3187
+ const canvas = within(canvasElement);
3188
+ const button = (name: string | RegExp) =>
3189
+ canvas.getByRole('button', { name });
3190
+
3191
+ await step(
3192
+ 'keyboard: Tab reaches the rows-per-page menu first (WCAG 2.4.3)',
3193
+ async () => {
3194
+ await userEvent.tab();
3195
+ await expect(button('Rows per page')).toHaveFocus();
3196
+ },
3197
+ );
3198
+
3199
+ await step(
3200
+ 'keyboard: Tab skips disabled first/previous and lands on page 1',
3201
+ async () => {
3202
+ await userEvent.tab();
3203
+ await expect(button('Page 1')).toHaveFocus();
3204
+ },
3205
+ );
3206
+
3207
+ await step('keyboard: Enter activates the focused page', async () => {
3208
+ await userEvent.tab();
3209
+ await expect(button('Page 2')).toHaveFocus();
3210
+ await userEvent.keyboard('{Enter}');
3211
+ await expect(canvas.getByText('Page 2 of 12')).toBeInTheDocument();
3212
+ await expect(button('Page 2')).toHaveAttribute('aria-current', 'page');
3213
+ });
3214
+
3215
+ await step('keyboard: Space activates the focused page', async () => {
3216
+ await userEvent.tab();
3217
+ await expect(button('Page 3')).toHaveFocus();
3218
+ await userEvent.keyboard(' ');
3219
+ await expect(canvas.getByText('Page 3 of 12')).toBeInTheDocument();
3220
+ });
3221
+
3222
+ await step(
3223
+ 'keyboard: first/previous join the tab order once enabled',
3224
+ async () => {
3225
+ await expect(button('Go to first page')).toBeEnabled();
3226
+ button('Rows per page').focus();
3227
+ await userEvent.tab();
3228
+ await expect(button('Go to first page')).toHaveFocus();
3229
+ await userEvent.tab();
3230
+ await expect(button('Go to previous page')).toHaveFocus();
3231
+ },
3232
+ );
3233
+ },
3234
+ };
3235
+
3236
+ /**
3237
+ * Screen-reader semantics for the footer: a named navigation landmark, labelled
3238
+ * page controls, `aria-current` on the active page, and an announced ellipsis.
3239
+ */
3240
+ export const PaginationScreenReader: Story = {
3241
+ name: 'test - Pagination Screen Reader',
3242
+ tags: ['!dev', '!autodocs'],
3243
+ parameters: {
3244
+ // The current page changes during the play.
3245
+ chromatic: { disableSnapshot: true },
3246
+ docs: {
3247
+ description: {
3248
+ story:
3249
+ 'Verifies the landmark, names, and state that assistive technology announces for the footer.',
3250
+ },
3251
+ },
3252
+ },
3253
+ render: paginationFooterRender,
3254
+ play: async ({ canvasElement, step }) => {
3255
+ // Scenario (UiDataTablePagination): assistive tech finds the pagination
3256
+ // landmark, hears every control's purpose, which page is current, and that
3257
+ // a range of pages was skipped.
3258
+ const canvas = within(canvasElement);
3259
+ const button = (name: string | RegExp) =>
3260
+ canvas.getByRole('button', { name });
3261
+
3262
+ await step(
3263
+ 'screen-reader: exposes a navigation landmark named "Pagination"',
3264
+ async () => {
3265
+ await expect(
3266
+ canvas.getByRole('navigation', { name: 'Pagination' }),
3267
+ ).toBeInTheDocument();
3268
+ },
3269
+ );
3270
+
3271
+ await step(
3272
+ 'screen-reader: edge and step controls have descriptive names (WCAG 4.1.2)',
3273
+ async () => {
3274
+ for (const name of [
3275
+ 'Go to first page',
3276
+ 'Go to previous page',
3277
+ 'Go to next page',
3278
+ 'Go to last page',
3279
+ ]) {
3280
+ await expect(button(name)).toBeInTheDocument();
3281
+ }
3282
+ },
3283
+ );
3284
+
3285
+ await step(
3286
+ 'screen-reader: the rows-per-page menu is named by its visible label',
3287
+ async () => {
3288
+ await expect(button('Rows per page')).toHaveAccessibleName(
3289
+ 'Rows per page',
3290
+ );
3291
+ },
3292
+ );
3293
+
3294
+ await step(
3295
+ 'screen-reader: the current page is announced via aria-current',
3296
+ async () => {
3297
+ await expect(button('Page 1')).toHaveAttribute('aria-current', 'page');
3298
+ await expect(button('Page 2')).not.toHaveAttribute('aria-current');
3299
+ },
3300
+ );
3301
+
3302
+ await step(
3303
+ 'screen-reader: the ellipsis announces skipped pages',
3304
+ async () => {
3305
+ await expect(canvas.getByText('More pages')).toBeInTheDocument();
3306
+ },
3307
+ );
3308
+
3309
+ await step(
3310
+ 'screen-reader: aria-current follows the page change',
3311
+ async () => {
3312
+ await userEvent.click(button('Page 2'));
3313
+ await expect(button('Page 2')).toHaveAttribute('aria-current', 'page');
3314
+ await expect(button('Page 1')).not.toHaveAttribute('aria-current');
3315
+ },
3316
+ );
3317
+ },
3318
+ };
3319
+
3320
+ /**
3321
+ * The footer rendered at 200% page zoom (WCAG 1.4.4 Resize Text): every
3322
+ * control stays visible and operable.
3323
+ */
3324
+ export const PaginationZoom: Story = {
3325
+ name: 'test - Pagination Zoom',
3326
+ tags: ['!dev', '!autodocs'],
3327
+ globals: { zoom: '200' },
3328
+ parameters: {
3329
+ // The accessible-reflow Chromatic mode already covers magnified snapshots.
3330
+ chromatic: { disableSnapshot: true },
3331
+ docs: {
3332
+ description: {
3333
+ story:
3334
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the footer.',
3335
+ },
3336
+ },
3337
+ },
3338
+ render: paginationFooterRender,
3339
+ play: async ({ canvasElement, step }) => {
3340
+ // Scenario (UiDataTablePagination): at 200% zoom the footer controls stay
3341
+ // visible and still page the table.
3342
+ const canvas = within(canvasElement);
3343
+ const nav = canvas.getByRole('navigation', { name: 'Pagination' });
3344
+
3345
+ await step(
3346
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
3347
+ async () => {
3348
+ await expect(document.documentElement.style.zoom).toBe('200%');
3349
+ },
3350
+ );
3351
+
3352
+ await step('zoom: every page control stays visible', async () => {
3353
+ for (const control of within(nav).getAllByRole('button')) {
3354
+ await expect(control).toBeVisible();
3355
+ }
3356
+ await expect(canvas.getByText('Page 1 of 12')).toBeVisible();
3357
+ });
3358
+
3359
+ await step('zoom: the footer remains operable when magnified', async () => {
3360
+ await userEvent.click(
3361
+ canvas.getByRole('button', { name: 'Go to next page' }),
3362
+ );
3363
+ await expect(canvas.getByText('Page 2 of 12')).toBeInTheDocument();
3364
+ });
3365
+ },
3366
+ };
3367
+
3368
+ /**
3369
+ * The footer at the mobile (320px reflow) breakpoint: controls wrap inside the
3370
+ * viewport, keep a 24px touch target, and still page the table.
3371
+ */
3372
+ export const PaginationMobile: Story = {
3373
+ name: 'test - Pagination Mobile',
3374
+ tags: ['!dev', '!autodocs'],
3375
+ globals: { mediaBreakpoint: 'reflow' },
3376
+ parameters: {
3377
+ // Reflow snapshots are already covered by the accessible-reflow mode.
3378
+ chromatic: { disableSnapshot: true },
3379
+ docs: {
3380
+ description: {
3381
+ story:
3382
+ 'Switch the Media breakpoint toolbar to Mobile to preview the footer at 320px.',
3383
+ },
3384
+ },
3385
+ },
3386
+ // At 320px the table scrolls horizontally; sortable headers give that region
3387
+ // focusable content so keyboard users can scroll it (axe
3388
+ // scrollable-region-focusable), matching `test - Mobile Breakpoint`.
3389
+ render: createPaginationFooterRender(sortableColumns),
3390
+ play: async ({ canvasElement, step }) => {
3391
+ // Scenario (UiDataTablePagination): at 320px the footer wraps rather than
3392
+ // overflowing, every control is a comfortable target, and paging works.
3393
+ const canvas = within(canvasElement);
3394
+ const controls = within(
3395
+ canvas.getByRole('navigation', { name: 'Pagination' }),
3396
+ ).getAllByRole('button');
3397
+
3398
+ await step(
3399
+ 'mobile: no page control overflows the 320px viewport (WCAG 1.4.10)',
3400
+ async () => {
3401
+ for (const control of controls) {
3402
+ const { left, right } = control.getBoundingClientRect();
3403
+ await expect(left).toBeGreaterThanOrEqual(0);
3404
+ await expect(right).toBeLessThanOrEqual(window.innerWidth);
3405
+ }
3406
+ },
3407
+ );
3408
+
3409
+ await step(
3410
+ 'mobile: every page control meets the minimum touch-target size (WCAG 2.5.8)',
3411
+ async () => {
3412
+ for (const control of controls) {
3413
+ const { width, height } = control.getBoundingClientRect();
3414
+ await expect(width).toBeGreaterThanOrEqual(24);
3415
+ await expect(height).toBeGreaterThanOrEqual(24);
3416
+ }
3417
+ },
3418
+ );
3419
+
3420
+ await step('mobile: stays operable at the 320px breakpoint', async () => {
3421
+ await userEvent.click(
3422
+ canvas.getByRole('button', { name: 'Go to next page' }),
3423
+ );
3424
+ await expect(canvas.getByText('Page 2 of 12')).toBeInTheDocument();
3425
+ });
3426
+ },
3427
+ };
@@ -1,21 +1,15 @@
1
1
  <script setup lang="ts" generic="TData">
2
2
  import { UiButton } from '@/components/UiButton';
3
- import { UiIcon } from '@/components/UiIcon';
4
3
  import {
5
4
  UiDropdownMenu,
6
5
  UiDropdownMenuContent,
7
6
  UiDropdownMenuItem,
8
7
  UiDropdownMenuTrigger,
9
8
  } from '@/components/UiDropdownMenu';
9
+ import { UiPagination } from '@/components/UiPagination';
10
10
  import { DATA_TABLE_LABELS } from './constants';
11
11
  import type { UiDataTablePaginationProps } from './types';
12
12
  import { computed } from 'vue';
13
- import {
14
- ChevronLeftIcon,
15
- ChevronRightIcon,
16
- ChevronsLeftIcon,
17
- ChevronsRightIcon,
18
- } from '@/icons/lucide';
19
13
 
20
14
  defineOptions({
21
15
  name: 'UiDataTablePagination',
@@ -38,10 +32,35 @@ const labels = computed(() => ({
38
32
  pageOf: props.labels?.pageOf ?? DATA_TABLE_LABELS.pageOf,
39
33
  rowsSelected: props.labels?.rowsSelected ?? DATA_TABLE_LABELS.rowsSelected,
40
34
  }));
35
+
36
+ const paginationLabels = computed(() => ({
37
+ firstPage: labels.value.goToFirstPage,
38
+ previousPage: labels.value.goToPreviousPage,
39
+ nextPage: labels.value.goToNextPage,
40
+ lastPage: labels.value.goToLastPage,
41
+ previous: props.labels?.previous ?? props.labels?.goToPreviousPage,
42
+ next: props.labels?.next ?? props.labels?.goToNextPage,
43
+ page: props.labels?.goToPage,
44
+ morePages: props.labels?.morePages,
45
+ navigation: props.labels?.navigation,
46
+ }));
47
+
48
+ const pageSize = computed(() => props.table.getState().pagination.pageSize);
49
+ // The table reports -1 when a manual page count is unknown, and NaN or
50
+ // Infinity can come from a bad `pageCount`/`rowCount` option.
51
+ const pageCount = computed(() => {
52
+ const count = props.table.getPageCount();
53
+ return Number.isFinite(count) && count > 0 ? Math.floor(count) : 1;
54
+ });
55
+ const page = computed(() => props.table.getState().pagination.pageIndex + 1);
56
+
57
+ function onPageChange(value: number | undefined) {
58
+ if (value !== undefined) props.table.setPageIndex(value - 1);
59
+ }
41
60
  </script>
42
61
 
43
62
  <template>
44
- <div class="flex items-center gap-2 justify-between px-2">
63
+ <div class="flex flex-wrap items-center gap-2 justify-between px-2">
45
64
  <div
46
65
  v-if="showSelection"
47
66
  class="flex-1 body-s-regular text-content-on-surface-muted"
@@ -54,7 +73,7 @@ const labels = computed(() => ({
54
73
  }}
55
74
  </div>
56
75
  <div v-else class="flex-1" />
57
- <div class="flex items-center gap-x-6 lg:gap-x-8">
76
+ <div class="flex flex-wrap items-center gap-x-6 gap-y-2 lg:gap-x-8">
58
77
  <div v-if="showPageSize" class="flex items-center gap-x-2">
59
78
  <p id="rows-per-page-label" class="body-s-medium">
60
79
  {{ labels.rowsPerPage }}
@@ -63,11 +82,10 @@ const labels = computed(() => ({
63
82
  <UiDropdownMenuTrigger as-child>
64
83
  <UiButton
65
84
  variant="outline"
66
- size="sm"
67
85
  class="h-8 w-[70px]"
68
86
  aria-labelledby="rows-per-page-label"
69
87
  >
70
- {{ table.getState().pagination.pageSize }}
88
+ {{ pageSize }}
71
89
  </UiButton>
72
90
  </UiDropdownMenuTrigger>
73
91
  <UiDropdownMenuContent align="end">
@@ -81,56 +99,21 @@ const labels = computed(() => ({
81
99
  </UiDropdownMenuContent>
82
100
  </UiDropdownMenu>
83
101
  </div>
84
- <div class="flex w-[100px] items-center justify-center body-s-medium">
85
- {{
86
- labels.pageOf(
87
- table.getState().pagination.pageIndex + 1,
88
- table.getPageCount(),
89
- )
90
- }}
91
- </div>
92
- <div class="flex items-center gap-x-2">
93
- <UiButton
94
- variant="outline"
95
- size="sm"
96
- class="hidden h-8 w-8 p-0 lg:flex"
97
- :disabled="!table.getCanPreviousPage()"
98
- @click="table.setPageIndex(0)"
99
- >
100
- <span class="sr-only">{{ labels.goToFirstPage }}</span>
101
- <UiIcon :name="ChevronsLeftIcon" :size="16" aria-hidden="true" />
102
- </UiButton>
103
- <UiButton
104
- variant="outline"
105
- size="sm"
106
- class="h-8 w-8 p-0"
107
- :disabled="!table.getCanPreviousPage()"
108
- @click="table.previousPage()"
109
- >
110
- <span class="sr-only">{{ labels.goToPreviousPage }}</span>
111
- <UiIcon :name="ChevronLeftIcon" :size="16" aria-hidden="true" />
112
- </UiButton>
113
- <UiButton
114
- variant="outline"
115
- size="sm"
116
- class="h-8 w-8 p-0"
117
- :disabled="!table.getCanNextPage()"
118
- @click="table.nextPage()"
119
- >
120
- <span class="sr-only">{{ labels.goToNextPage }}</span>
121
- <UiIcon :name="ChevronRightIcon" :size="16" aria-hidden="true" />
122
- </UiButton>
123
- <UiButton
124
- variant="outline"
125
- size="sm"
126
- class="hidden h-8 w-8 p-0 lg:flex"
127
- :disabled="!table.getCanNextPage()"
128
- @click="table.setPageIndex(table.getPageCount() - 1)"
129
- >
130
- <span class="sr-only">{{ labels.goToLastPage }}</span>
131
- <UiIcon :name="ChevronsRightIcon" :size="16" aria-hidden="true" />
132
- </UiButton>
102
+ <div class="flex items-center justify-center body-s-medium">
103
+ {{ labels.pageOf(page, pageCount) }}
133
104
  </div>
105
+ <!-- `total` is derived from the page count rather than the row count so
106
+ server-side (manual) pagination, where only the current page's rows
107
+ are loaded, still renders the full page range. -->
108
+ <UiPagination
109
+ class="mx-0 w-auto"
110
+ show-first-last
111
+ :page="page"
112
+ :total="pageCount * pageSize"
113
+ :items-per-page="pageSize"
114
+ :labels="paginationLabels"
115
+ @update:page="onPageChange"
116
+ />
134
117
  </div>
135
118
  </div>
136
119
  </template>