@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.
- package/dist/system/components/UiPagination/UiPagination.vue.d.ts +19 -0
- package/dist/system/components/UiPagination/constants.d.ts +6 -0
- package/dist/system/components/UiPagination/index.d.ts +3 -0
- package/dist/system/components/UiPagination/types.d.ts +81 -0
- package/dist/system/components/core/pagination/Pagination.vue.d.ts +29 -0
- package/dist/system/components/core/pagination/PaginationContent.vue.d.ts +29 -0
- package/dist/system/components/core/pagination/PaginationEllipsis.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationFirst.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationItem.vue.d.ts +26 -0
- package/dist/system/components/core/pagination/PaginationLast.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationNext.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/PaginationPrevious.vue.d.ts +22 -0
- package/dist/system/components/core/pagination/index.d.ts +8 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/icons/story-sidebar-icons.json +4 -0
- package/dist/system/lib.js +11605 -10906
- package/dist/system/patterns/UiBulkAction/UiBulkAction.vue.d.ts +43 -0
- package/dist/system/patterns/UiBulkAction/index.d.ts +3 -0
- package/dist/system/patterns/UiBulkAction/types.d.ts +109 -0
- package/dist/system/patterns/UiBulkAction/useBulkAction.d.ts +7 -0
- package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
- package/dist/system/patterns/index.d.ts +1 -0
- package/dist/system/story-sidebar-icons.json +4 -0
- package/package.json +1 -1
- package/src/components/UiPagination/UiPagination.guidance.md +60 -0
- package/src/components/UiPagination/UiPagination.stories.ts +1070 -0
- package/src/components/UiPagination/UiPagination.vue +109 -0
- package/src/components/UiPagination/__tests__/UiPagination.test.ts +203 -0
- package/src/components/UiPagination/constants.ts +17 -0
- package/src/components/UiPagination/index.ts +3 -0
- package/src/components/UiPagination/types.ts +82 -0
- package/src/components/core/pagination/Pagination.vue +26 -0
- package/src/components/core/pagination/PaginationContent.vue +24 -0
- package/src/components/core/pagination/PaginationEllipsis.vue +30 -0
- package/src/components/core/pagination/PaginationFirst.vue +30 -0
- package/src/components/core/pagination/PaginationItem.vue +39 -0
- package/src/components/core/pagination/PaginationLast.vue +30 -0
- package/src/components/core/pagination/PaginationNext.vue +35 -0
- package/src/components/core/pagination/PaginationPrevious.vue +35 -0
- package/src/components/core/pagination/index.ts +8 -0
- package/src/components/index.ts +1 -0
- package/src/patterns/UiBulkAction/UiBulkAction.guidance.md +59 -0
- package/src/patterns/UiBulkAction/UiBulkAction.stories.ts +2238 -0
- package/src/patterns/UiBulkAction/UiBulkAction.vue +62 -0
- package/src/patterns/UiBulkAction/__tests__/useBulkAction.test.ts +78 -0
- package/src/patterns/UiBulkAction/index.ts +3 -0
- package/src/patterns/UiBulkAction/types.ts +126 -0
- package/src/patterns/UiBulkAction/useBulkAction.ts +50 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +375 -1
- package/src/patterns/UiDataTable/UiDataTablePagination.vue +43 -60
- package/src/patterns/UiDataTable/__tests__/UiDataTablePagination.test.ts +58 -29
- package/src/patterns/UiDataTable/constants.ts +10 -0
- package/src/patterns/index.ts +1 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import {
|
|
4
|
+
Pagination,
|
|
5
|
+
PaginationContent,
|
|
6
|
+
PaginationEllipsis,
|
|
7
|
+
PaginationFirst,
|
|
8
|
+
PaginationItem,
|
|
9
|
+
PaginationLast,
|
|
10
|
+
PaginationNext,
|
|
11
|
+
PaginationPrevious,
|
|
12
|
+
} from '@/components/core/pagination';
|
|
13
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
14
|
+
import {
|
|
15
|
+
ChevronLeftIcon,
|
|
16
|
+
ChevronRightIcon,
|
|
17
|
+
EllipsisIcon,
|
|
18
|
+
} from '@/icons/lucide';
|
|
19
|
+
import { cn } from '@/lib/utils';
|
|
20
|
+
import { UI_PAGINATION_LABELS } from './constants';
|
|
21
|
+
import type { UiPaginationProps } from './types';
|
|
22
|
+
|
|
23
|
+
defineOptions({
|
|
24
|
+
name: 'UiPagination',
|
|
25
|
+
inheritAttrs: false,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const props = withDefaults(defineProps<UiPaginationProps>(), {
|
|
29
|
+
defaultPage: 1,
|
|
30
|
+
itemsPerPage: 10,
|
|
31
|
+
siblingCount: 1,
|
|
32
|
+
showEdges: true,
|
|
33
|
+
showFirstLast: false,
|
|
34
|
+
disabled: false,
|
|
35
|
+
labels: undefined,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const page = defineModel<number>('page');
|
|
39
|
+
|
|
40
|
+
const labels = computed(() => ({
|
|
41
|
+
...UI_PAGINATION_LABELS,
|
|
42
|
+
...Object.fromEntries(
|
|
43
|
+
Object.entries(props.labels ?? {}).filter(([, v]) => v !== undefined),
|
|
44
|
+
),
|
|
45
|
+
}));
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<Pagination
|
|
50
|
+
v-slot="{ page: currentPage }"
|
|
51
|
+
v-model:page="page"
|
|
52
|
+
:default-page="props.defaultPage"
|
|
53
|
+
:total="props.total"
|
|
54
|
+
:items-per-page="props.itemsPerPage"
|
|
55
|
+
:sibling-count="props.siblingCount"
|
|
56
|
+
:show-edges="props.showEdges"
|
|
57
|
+
:disabled="props.disabled"
|
|
58
|
+
:aria-label="labels.navigation"
|
|
59
|
+
v-bind="$attrs"
|
|
60
|
+
:class="cn($attrs.class ?? '')"
|
|
61
|
+
>
|
|
62
|
+
<!-- Wrapping instead of overflowing keeps every page reachable at the
|
|
63
|
+
320px reflow width (WCAG 1.4.10). -->
|
|
64
|
+
<PaginationContent
|
|
65
|
+
v-slot="{ items }"
|
|
66
|
+
as="ul"
|
|
67
|
+
class="flex-wrap justify-center"
|
|
68
|
+
>
|
|
69
|
+
<li v-if="props.showFirstLast">
|
|
70
|
+
<PaginationFirst :aria-label="labels.firstPage" />
|
|
71
|
+
</li>
|
|
72
|
+
<li>
|
|
73
|
+
<PaginationPrevious :aria-label="labels.previousPage">
|
|
74
|
+
<UiIcon :name="ChevronLeftIcon" size="s" />
|
|
75
|
+
<span class="hidden sm:inline">{{ labels.previous }}</span>
|
|
76
|
+
</PaginationPrevious>
|
|
77
|
+
</li>
|
|
78
|
+
<template
|
|
79
|
+
v-for="(item, index) in items"
|
|
80
|
+
:key="item.type === 'page' ? `page-${item.value}` : `ellipsis-${index}`"
|
|
81
|
+
>
|
|
82
|
+
<li v-if="item.type === 'page'">
|
|
83
|
+
<PaginationItem
|
|
84
|
+
:value="item.value"
|
|
85
|
+
:is-active="item.value === currentPage"
|
|
86
|
+
:aria-label="labels.page(item.value)"
|
|
87
|
+
>
|
|
88
|
+
{{ item.value }}
|
|
89
|
+
</PaginationItem>
|
|
90
|
+
</li>
|
|
91
|
+
<li v-else>
|
|
92
|
+
<PaginationEllipsis>
|
|
93
|
+
<UiIcon :name="EllipsisIcon" size="s" />
|
|
94
|
+
<span class="sr-only">{{ labels.morePages }}</span>
|
|
95
|
+
</PaginationEllipsis>
|
|
96
|
+
</li>
|
|
97
|
+
</template>
|
|
98
|
+
<li>
|
|
99
|
+
<PaginationNext :aria-label="labels.nextPage">
|
|
100
|
+
<span class="hidden sm:inline">{{ labels.next }}</span>
|
|
101
|
+
<UiIcon :name="ChevronRightIcon" size="s" />
|
|
102
|
+
</PaginationNext>
|
|
103
|
+
</li>
|
|
104
|
+
<li v-if="props.showFirstLast">
|
|
105
|
+
<PaginationLast :aria-label="labels.lastPage" />
|
|
106
|
+
</li>
|
|
107
|
+
</PaginationContent>
|
|
108
|
+
</Pagination>
|
|
109
|
+
</template>
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { describe, expect, test } from 'vitest';
|
|
4
|
+
import { defineComponent, nextTick, ref } from 'vue';
|
|
5
|
+
import UiPagination from '../UiPagination.vue';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Builds a host component that binds `v-model:page` to the given ref.
|
|
9
|
+
* @param page Ref holding the current page.
|
|
10
|
+
* @param attrs Extra attributes for `UiPagination`.
|
|
11
|
+
* @returns A component ready to pass to `render`.
|
|
12
|
+
*/
|
|
13
|
+
function createControlled(page: ReturnType<typeof ref<number>>, attrs = '') {
|
|
14
|
+
return defineComponent({
|
|
15
|
+
components: { UiPagination },
|
|
16
|
+
setup() {
|
|
17
|
+
return { page };
|
|
18
|
+
},
|
|
19
|
+
template: `<UiPagination v-model:page="page" ${attrs} />`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe('UiPagination', () => {
|
|
24
|
+
test('renders a labelled nav landmark and marks the current page', () => {
|
|
25
|
+
const { getByRole } = render(UiPagination, {
|
|
26
|
+
props: { total: 50, page: 2 },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect(getByRole('navigation', { name: 'Pagination' })).toBeInTheDocument();
|
|
30
|
+
expect(getByRole('button', { name: 'Page 2' })).toHaveAttribute(
|
|
31
|
+
'aria-current',
|
|
32
|
+
'page',
|
|
33
|
+
);
|
|
34
|
+
expect(getByRole('button', { name: 'Page 1' })).not.toHaveAttribute(
|
|
35
|
+
'aria-current',
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('derives the page count from total and itemsPerPage', () => {
|
|
40
|
+
const { getAllByRole, getByRole } = render(UiPagination, {
|
|
41
|
+
props: { total: 45, itemsPerPage: 15 },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
expect(getByRole('button', { name: 'Page 3' })).toBeInTheDocument();
|
|
45
|
+
expect(
|
|
46
|
+
getAllByRole('button').filter((b) => b.dataset.type === 'page'),
|
|
47
|
+
).toHaveLength(3);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('defaults to 10 items per page', () => {
|
|
51
|
+
const { getByRole, queryByRole } = render(UiPagination, {
|
|
52
|
+
props: { total: 30 },
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
expect(getByRole('button', { name: 'Page 3' })).toBeInTheDocument();
|
|
56
|
+
expect(queryByRole('button', { name: 'Page 4' })).not.toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('updates v-model when a page is clicked', async () => {
|
|
60
|
+
const user = userEvent.setup();
|
|
61
|
+
const page = ref(1);
|
|
62
|
+
const { getByRole } = render(createControlled(page, ':total="50"'));
|
|
63
|
+
|
|
64
|
+
await user.click(getByRole('button', { name: 'Page 3' }));
|
|
65
|
+
await nextTick();
|
|
66
|
+
|
|
67
|
+
expect(page.value).toBe(3);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('previous and next step the page by one', async () => {
|
|
71
|
+
const user = userEvent.setup();
|
|
72
|
+
const page = ref(3);
|
|
73
|
+
const { getByRole } = render(createControlled(page, ':total="50"'));
|
|
74
|
+
|
|
75
|
+
await user.click(getByRole('button', { name: 'Next page' }));
|
|
76
|
+
expect(page.value).toBe(4);
|
|
77
|
+
|
|
78
|
+
await user.click(getByRole('button', { name: 'Previous page' }));
|
|
79
|
+
await user.click(getByRole('button', { name: 'Previous page' }));
|
|
80
|
+
expect(page.value).toBe(2);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('disables previous on the first page and next on the last page', async () => {
|
|
84
|
+
const page = ref(1);
|
|
85
|
+
const { getByRole } = render(createControlled(page, ':total="30"'));
|
|
86
|
+
|
|
87
|
+
expect(getByRole('button', { name: 'Previous page' })).toBeDisabled();
|
|
88
|
+
expect(getByRole('button', { name: 'Next page' })).toBeEnabled();
|
|
89
|
+
|
|
90
|
+
page.value = 3;
|
|
91
|
+
await nextTick();
|
|
92
|
+
|
|
93
|
+
expect(getByRole('button', { name: 'Previous page' })).toBeEnabled();
|
|
94
|
+
expect(getByRole('button', { name: 'Next page' })).toBeDisabled();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('works uncontrolled from defaultPage and emits update:page', async () => {
|
|
98
|
+
const user = userEvent.setup();
|
|
99
|
+
const { getByRole, emitted } = render(UiPagination, {
|
|
100
|
+
props: { total: 50, defaultPage: 4 },
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
expect(getByRole('button', { name: 'Page 4' })).toHaveAttribute(
|
|
104
|
+
'aria-current',
|
|
105
|
+
'page',
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
await user.click(getByRole('button', { name: 'Next page' }));
|
|
109
|
+
|
|
110
|
+
expect(emitted('update:page')?.[0]).toEqual([5]);
|
|
111
|
+
expect(getByRole('button', { name: 'Page 5' })).toHaveAttribute(
|
|
112
|
+
'aria-current',
|
|
113
|
+
'page',
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('collapses distant pages into an ellipsis and keeps the edges', () => {
|
|
118
|
+
const { getByRole, getAllByText, queryByRole } = render(UiPagination, {
|
|
119
|
+
props: { total: 200, page: 10 },
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(getByRole('button', { name: 'Page 1' })).toBeInTheDocument();
|
|
123
|
+
expect(getByRole('button', { name: 'Page 9' })).toBeInTheDocument();
|
|
124
|
+
expect(getByRole('button', { name: 'Page 11' })).toBeInTheDocument();
|
|
125
|
+
expect(getByRole('button', { name: 'Page 20' })).toBeInTheDocument();
|
|
126
|
+
expect(queryByRole('button', { name: 'Page 5' })).not.toBeInTheDocument();
|
|
127
|
+
expect(getAllByText('More pages')).toHaveLength(2);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('siblingCount widens the window around the current page', () => {
|
|
131
|
+
const { getByRole } = render(UiPagination, {
|
|
132
|
+
props: { total: 200, page: 10, siblingCount: 2 },
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
expect(getByRole('button', { name: 'Page 8' })).toBeInTheDocument();
|
|
136
|
+
expect(getByRole('button', { name: 'Page 12' })).toBeInTheDocument();
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('showFirstLast adds controls that jump to the edges', async () => {
|
|
140
|
+
const user = userEvent.setup();
|
|
141
|
+
const page = ref(5);
|
|
142
|
+
const { getByRole } = render(
|
|
143
|
+
createControlled(page, ':total="200" show-first-last'),
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
await user.click(getByRole('button', { name: 'Last page' }));
|
|
147
|
+
expect(page.value).toBe(20);
|
|
148
|
+
|
|
149
|
+
await user.click(getByRole('button', { name: 'First page' }));
|
|
150
|
+
expect(page.value).toBe(1);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('hides first and last controls by default', () => {
|
|
154
|
+
const { queryByRole } = render(UiPagination, { props: { total: 200 } });
|
|
155
|
+
|
|
156
|
+
expect(
|
|
157
|
+
queryByRole('button', { name: 'First page' }),
|
|
158
|
+
).not.toBeInTheDocument();
|
|
159
|
+
expect(
|
|
160
|
+
queryByRole('button', { name: 'Last page' }),
|
|
161
|
+
).not.toBeInTheDocument();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('disabled blocks every control', async () => {
|
|
165
|
+
const user = userEvent.setup();
|
|
166
|
+
const page = ref(2);
|
|
167
|
+
const { getAllByRole, getByRole } = render(
|
|
168
|
+
createControlled(page, ':total="50" disabled'),
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
for (const button of getAllByRole('button')) {
|
|
172
|
+
expect(button).toBeDisabled();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
await user.click(getByRole('button', { name: 'Page 3' }), {
|
|
176
|
+
pointerEventsCheck: 0,
|
|
177
|
+
});
|
|
178
|
+
expect(page.value).toBe(2);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test('labels override the default text and keep unset defaults', () => {
|
|
182
|
+
const { getByRole, getByText } = render(UiPagination, {
|
|
183
|
+
props: {
|
|
184
|
+
total: 50,
|
|
185
|
+
page: 1,
|
|
186
|
+
labels: {
|
|
187
|
+
navigation: 'Seitennavigation',
|
|
188
|
+
nextPage: 'Nächste Seite',
|
|
189
|
+
next: 'Weiter',
|
|
190
|
+
page: (n: number) => `Seite ${n}`,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
expect(
|
|
196
|
+
getByRole('navigation', { name: 'Seitennavigation' }),
|
|
197
|
+
).toBeInTheDocument();
|
|
198
|
+
expect(getByRole('button', { name: 'Nächste Seite' })).toBeInTheDocument();
|
|
199
|
+
expect(getByText('Weiter')).toBeInTheDocument();
|
|
200
|
+
expect(getByRole('button', { name: 'Seite 2' })).toBeInTheDocument();
|
|
201
|
+
expect(getByRole('button', { name: 'Previous page' })).toBeInTheDocument();
|
|
202
|
+
});
|
|
203
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UiPaginationLabels } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default labels for UiPagination.
|
|
5
|
+
* Override any of them through the `labels` prop, e.g. for translations.
|
|
6
|
+
*/
|
|
7
|
+
export const UI_PAGINATION_LABELS: UiPaginationLabels = {
|
|
8
|
+
navigation: 'Pagination',
|
|
9
|
+
previous: 'Previous',
|
|
10
|
+
next: 'Next',
|
|
11
|
+
previousPage: 'Previous page',
|
|
12
|
+
nextPage: 'Next page',
|
|
13
|
+
firstPage: 'First page',
|
|
14
|
+
lastPage: 'Last page',
|
|
15
|
+
morePages: 'More pages',
|
|
16
|
+
page: (page: number) => `Page ${page}`,
|
|
17
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text used for the visible and screen-reader labels.
|
|
3
|
+
*/
|
|
4
|
+
export interface UiPaginationLabels {
|
|
5
|
+
/** Accessible name of the `nav` landmark. */
|
|
6
|
+
navigation: string;
|
|
7
|
+
/** Visible text of the previous button (shown from the `sm` breakpoint up). */
|
|
8
|
+
previous: string;
|
|
9
|
+
/** Visible text of the next button (shown from the `sm` breakpoint up). */
|
|
10
|
+
next: string;
|
|
11
|
+
/** Accessible name of the previous button. Should contain `previous`. */
|
|
12
|
+
previousPage: string;
|
|
13
|
+
/** Accessible name of the next button. Should contain `next`. */
|
|
14
|
+
nextPage: string;
|
|
15
|
+
/** Accessible name of the first-page button. */
|
|
16
|
+
firstPage: string;
|
|
17
|
+
/** Accessible name of the last-page button. */
|
|
18
|
+
lastPage: string;
|
|
19
|
+
/** Screen-reader text for the ellipsis that stands in for skipped pages. */
|
|
20
|
+
morePages: string;
|
|
21
|
+
/** Accessible name of a page button. */
|
|
22
|
+
page: (page: number) => string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Lets users move through content split across multiple pages, such as
|
|
27
|
+
* search results, lists, or tables. Renders a labelled `nav` landmark with
|
|
28
|
+
* previous/next controls, page numbers, and ellipses for skipped ranges.
|
|
29
|
+
* @category Navigation
|
|
30
|
+
* @useCases paginated list, search results, table paging, page navigation, browse records
|
|
31
|
+
* @keywords pagination, pager, pages, next, previous, page numbers, paging
|
|
32
|
+
* @related UiDataTable, UiButton, UiBreadcrumb
|
|
33
|
+
*/
|
|
34
|
+
export interface UiPaginationProps {
|
|
35
|
+
/**
|
|
36
|
+
* The controlled current page (1-based).
|
|
37
|
+
* - Omit for uncontrolled mode
|
|
38
|
+
* - Use `v-model:page` for controlled mode
|
|
39
|
+
*/
|
|
40
|
+
page?: number;
|
|
41
|
+
/**
|
|
42
|
+
* The page selected on first render when uncontrolled.
|
|
43
|
+
* @default 1
|
|
44
|
+
*/
|
|
45
|
+
defaultPage?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Total number of items across all pages. The page count is derived from
|
|
48
|
+
* `total` and `itemsPerPage`.
|
|
49
|
+
*/
|
|
50
|
+
total: number;
|
|
51
|
+
/**
|
|
52
|
+
* Number of items shown per page.
|
|
53
|
+
* @default 10
|
|
54
|
+
*/
|
|
55
|
+
itemsPerPage?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Number of page buttons shown on each side of the current page.
|
|
58
|
+
* @default 1
|
|
59
|
+
*/
|
|
60
|
+
siblingCount?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Always show the first and last page numbers, collapsing the gaps with an
|
|
63
|
+
* ellipsis.
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
showEdges?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Show icon-only buttons that jump to the first and last page.
|
|
69
|
+
* @default false
|
|
70
|
+
*/
|
|
71
|
+
showFirstLast?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Disables every control.
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Overrides for the visible and screen-reader labels. Unset keys fall back
|
|
79
|
+
* to the English defaults.
|
|
80
|
+
*/
|
|
81
|
+
labels?: Partial<UiPaginationLabels>;
|
|
82
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationRootEmits, PaginationRootProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationRoot, useForwardPropsEmits } from 'reka-ui';
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
const props = defineProps<
|
|
9
|
+
PaginationRootProps & { class?: HTMLAttributes['class'] }
|
|
10
|
+
>();
|
|
11
|
+
const emits = defineEmits<PaginationRootEmits>();
|
|
12
|
+
|
|
13
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
14
|
+
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<PaginationRoot
|
|
19
|
+
v-slot="slotProps"
|
|
20
|
+
data-slot="pagination"
|
|
21
|
+
v-bind="forwarded"
|
|
22
|
+
:class="cn('mx-auto flex w-full justify-center', props.class)"
|
|
23
|
+
>
|
|
24
|
+
<slot v-bind="slotProps" />
|
|
25
|
+
</PaginationRoot>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationListProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationList } from 'reka-ui';
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
|
|
8
|
+
const props = defineProps<
|
|
9
|
+
PaginationListProps & { class?: HTMLAttributes['class'] }
|
|
10
|
+
>();
|
|
11
|
+
|
|
12
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<template>
|
|
16
|
+
<PaginationList
|
|
17
|
+
v-slot="slotProps"
|
|
18
|
+
data-slot="pagination-content"
|
|
19
|
+
v-bind="delegatedProps"
|
|
20
|
+
:class="cn('flex flex-row items-center gap-1', props.class)"
|
|
21
|
+
>
|
|
22
|
+
<slot v-bind="slotProps" />
|
|
23
|
+
</PaginationList>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationEllipsisProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationEllipsis } from 'reka-ui';
|
|
6
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
7
|
+
import { EllipsisIcon } from '@/icons/lucide';
|
|
8
|
+
import { cn } from '@/lib/utils';
|
|
9
|
+
|
|
10
|
+
const props = defineProps<
|
|
11
|
+
PaginationEllipsisProps & { class?: HTMLAttributes['class'] }
|
|
12
|
+
>();
|
|
13
|
+
|
|
14
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<PaginationEllipsis
|
|
19
|
+
data-slot="pagination-ellipsis"
|
|
20
|
+
v-bind="delegatedProps"
|
|
21
|
+
:class="
|
|
22
|
+
cn('flex size-9 items-center justify-center text-foreground', props.class)
|
|
23
|
+
"
|
|
24
|
+
>
|
|
25
|
+
<slot>
|
|
26
|
+
<UiIcon :name="EllipsisIcon" size="s" />
|
|
27
|
+
<span class="sr-only">More pages</span>
|
|
28
|
+
</slot>
|
|
29
|
+
</PaginationEllipsis>
|
|
30
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationFirstProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationFirst } from 'reka-ui';
|
|
6
|
+
import { buttonVariants } from '@/components/core/button';
|
|
7
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
8
|
+
import { ChevronsLeftIcon } from '@/icons/lucide';
|
|
9
|
+
import { cn } from '@/lib/utils';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<
|
|
12
|
+
PaginationFirstProps & { class?: HTMLAttributes['class'] }
|
|
13
|
+
>();
|
|
14
|
+
|
|
15
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<PaginationFirst
|
|
20
|
+
data-slot="pagination-first"
|
|
21
|
+
v-bind="delegatedProps"
|
|
22
|
+
:class="
|
|
23
|
+
cn(buttonVariants({ variant: 'ghost' }), 'min-w-9 px-2', props.class)
|
|
24
|
+
"
|
|
25
|
+
>
|
|
26
|
+
<slot>
|
|
27
|
+
<UiIcon :name="ChevronsLeftIcon" size="s" />
|
|
28
|
+
</slot>
|
|
29
|
+
</PaginationFirst>
|
|
30
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationListItemProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationListItem } from 'reka-ui';
|
|
6
|
+
import { buttonVariants } from '@/components/core/button';
|
|
7
|
+
import { cn } from '@/lib/utils';
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(
|
|
10
|
+
defineProps<
|
|
11
|
+
PaginationListItemProps & {
|
|
12
|
+
isActive?: boolean;
|
|
13
|
+
class?: HTMLAttributes['class'];
|
|
14
|
+
}
|
|
15
|
+
>(),
|
|
16
|
+
{
|
|
17
|
+
isActive: false,
|
|
18
|
+
class: undefined,
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const delegatedProps = reactiveOmit(props, 'class', 'isActive');
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<PaginationListItem
|
|
27
|
+
data-slot="pagination-item"
|
|
28
|
+
v-bind="delegatedProps"
|
|
29
|
+
:class="
|
|
30
|
+
cn(
|
|
31
|
+
buttonVariants({ variant: props.isActive ? 'outline' : 'ghost' }),
|
|
32
|
+
'min-w-9 px-2 tabular-nums',
|
|
33
|
+
props.class,
|
|
34
|
+
)
|
|
35
|
+
"
|
|
36
|
+
>
|
|
37
|
+
<slot />
|
|
38
|
+
</PaginationListItem>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationLastProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationLast } from 'reka-ui';
|
|
6
|
+
import { buttonVariants } from '@/components/core/button';
|
|
7
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
8
|
+
import { ChevronsRightIcon } from '@/icons/lucide';
|
|
9
|
+
import { cn } from '@/lib/utils';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<
|
|
12
|
+
PaginationLastProps & { class?: HTMLAttributes['class'] }
|
|
13
|
+
>();
|
|
14
|
+
|
|
15
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<PaginationLast
|
|
20
|
+
data-slot="pagination-last"
|
|
21
|
+
v-bind="delegatedProps"
|
|
22
|
+
:class="
|
|
23
|
+
cn(buttonVariants({ variant: 'ghost' }), 'min-w-9 px-2', props.class)
|
|
24
|
+
"
|
|
25
|
+
>
|
|
26
|
+
<slot>
|
|
27
|
+
<UiIcon :name="ChevronsRightIcon" size="s" />
|
|
28
|
+
</slot>
|
|
29
|
+
</PaginationLast>
|
|
30
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationNextProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationNext } from 'reka-ui';
|
|
6
|
+
import { buttonVariants } from '@/components/core/button';
|
|
7
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
8
|
+
import { ChevronRightIcon } from '@/icons/lucide';
|
|
9
|
+
import { cn } from '@/lib/utils';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<
|
|
12
|
+
PaginationNextProps & { class?: HTMLAttributes['class'] }
|
|
13
|
+
>();
|
|
14
|
+
|
|
15
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<PaginationNext
|
|
20
|
+
data-slot="pagination-next"
|
|
21
|
+
v-bind="delegatedProps"
|
|
22
|
+
:class="
|
|
23
|
+
cn(
|
|
24
|
+
buttonVariants({ variant: 'ghost' }),
|
|
25
|
+
'min-w-9 px-2 sm:pl-3',
|
|
26
|
+
props.class,
|
|
27
|
+
)
|
|
28
|
+
"
|
|
29
|
+
>
|
|
30
|
+
<slot>
|
|
31
|
+
<span class="hidden sm:inline">Next</span>
|
|
32
|
+
<UiIcon :name="ChevronRightIcon" size="s" />
|
|
33
|
+
</slot>
|
|
34
|
+
</PaginationNext>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { PaginationPrevProps } from 'reka-ui';
|
|
3
|
+
import type { HTMLAttributes } from 'vue';
|
|
4
|
+
import { reactiveOmit } from '@vueuse/core';
|
|
5
|
+
import { PaginationPrev } from 'reka-ui';
|
|
6
|
+
import { buttonVariants } from '@/components/core/button';
|
|
7
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
8
|
+
import { ChevronLeftIcon } from '@/icons/lucide';
|
|
9
|
+
import { cn } from '@/lib/utils';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<
|
|
12
|
+
PaginationPrevProps & { class?: HTMLAttributes['class'] }
|
|
13
|
+
>();
|
|
14
|
+
|
|
15
|
+
const delegatedProps = reactiveOmit(props, 'class');
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<PaginationPrev
|
|
20
|
+
data-slot="pagination-previous"
|
|
21
|
+
v-bind="delegatedProps"
|
|
22
|
+
:class="
|
|
23
|
+
cn(
|
|
24
|
+
buttonVariants({ variant: 'ghost' }),
|
|
25
|
+
'min-w-9 px-2 sm:pr-3',
|
|
26
|
+
props.class,
|
|
27
|
+
)
|
|
28
|
+
"
|
|
29
|
+
>
|
|
30
|
+
<slot>
|
|
31
|
+
<UiIcon :name="ChevronLeftIcon" size="s" />
|
|
32
|
+
<span class="hidden sm:inline">Previous</span>
|
|
33
|
+
</slot>
|
|
34
|
+
</PaginationPrev>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Pagination } from './Pagination.vue';
|
|
2
|
+
export { default as PaginationContent } from './PaginationContent.vue';
|
|
3
|
+
export { default as PaginationEllipsis } from './PaginationEllipsis.vue';
|
|
4
|
+
export { default as PaginationFirst } from './PaginationFirst.vue';
|
|
5
|
+
export { default as PaginationItem } from './PaginationItem.vue';
|
|
6
|
+
export { default as PaginationLast } from './PaginationLast.vue';
|
|
7
|
+
export { default as PaginationNext } from './PaginationNext.vue';
|
|
8
|
+
export { default as PaginationPrevious } from './PaginationPrevious.vue';
|