@aleph-alpha/ui-library 7.1.0 → 7.2.1
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 +10 -5
- 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
|
@@ -10,8 +10,6 @@ import UiDataTablePagination from '../UiDataTablePagination.vue';
|
|
|
10
10
|
* @param options.pageIndex
|
|
11
11
|
* @param options.pageSize
|
|
12
12
|
* @param options.pageCount
|
|
13
|
-
* @param options.canPreviousPage
|
|
14
|
-
* @param options.canNextPage
|
|
15
13
|
* @param options.selectedRows
|
|
16
14
|
* @param options.totalRows
|
|
17
15
|
*/
|
|
@@ -20,8 +18,6 @@ function createMockTable(
|
|
|
20
18
|
pageIndex?: number;
|
|
21
19
|
pageSize?: number;
|
|
22
20
|
pageCount?: number;
|
|
23
|
-
canPreviousPage?: boolean;
|
|
24
|
-
canNextPage?: boolean;
|
|
25
21
|
selectedRows?: number;
|
|
26
22
|
totalRows?: number;
|
|
27
23
|
} = {},
|
|
@@ -30,8 +26,6 @@ function createMockTable(
|
|
|
30
26
|
pageIndex = 0,
|
|
31
27
|
pageSize = 10,
|
|
32
28
|
pageCount = 5,
|
|
33
|
-
canPreviousPage = false,
|
|
34
|
-
canNextPage = true,
|
|
35
29
|
selectedRows = 0,
|
|
36
30
|
totalRows = 50,
|
|
37
31
|
} = options;
|
|
@@ -41,12 +35,8 @@ function createMockTable(
|
|
|
41
35
|
pagination: { pageIndex, pageSize },
|
|
42
36
|
})),
|
|
43
37
|
getPageCount: vi.fn(() => pageCount),
|
|
44
|
-
getCanPreviousPage: vi.fn(() => canPreviousPage),
|
|
45
|
-
getCanNextPage: vi.fn(() => canNextPage),
|
|
46
38
|
setPageIndex: vi.fn(),
|
|
47
39
|
setPageSize: vi.fn(),
|
|
48
|
-
previousPage: vi.fn(),
|
|
49
|
-
nextPage: vi.fn(),
|
|
50
40
|
getFilteredSelectedRowModel: vi.fn(() => ({
|
|
51
41
|
rows: Array(selectedRows).fill({}),
|
|
52
42
|
})),
|
|
@@ -69,6 +59,24 @@ describe('UiDataTablePagination', () => {
|
|
|
69
59
|
expect(getByText('Page 3 of 10')).toBeInTheDocument();
|
|
70
60
|
});
|
|
71
61
|
|
|
62
|
+
test.each([0, -1, NaN, Infinity])(
|
|
63
|
+
'falls back to one page when the page count is %s',
|
|
64
|
+
(pageCount) => {
|
|
65
|
+
const table = createMockTable({ pageIndex: 0, pageCount });
|
|
66
|
+
const { getByText, getByRole, queryByRole } = render(
|
|
67
|
+
UiDataTablePagination,
|
|
68
|
+
{ props: { table } },
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
expect(getByText('Page 1 of 1')).toBeInTheDocument();
|
|
72
|
+
expect(getByRole('button', { name: 'Page 1' })).toBeInTheDocument();
|
|
73
|
+
expect(
|
|
74
|
+
queryByRole('button', { name: 'Page 2' }),
|
|
75
|
+
).not.toBeInTheDocument();
|
|
76
|
+
expect(getByRole('button', { name: /next page/i })).toBeDisabled();
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
|
|
72
80
|
test('renders rows per page selector by default', () => {
|
|
73
81
|
const table = createMockTable({ pageSize: 20 });
|
|
74
82
|
const { getByText } = render(UiDataTablePagination, {
|
|
@@ -111,12 +119,11 @@ describe('UiDataTablePagination', () => {
|
|
|
111
119
|
test('shows default page size options', async () => {
|
|
112
120
|
const user = userEvent.setup();
|
|
113
121
|
const table = createMockTable();
|
|
114
|
-
const {
|
|
122
|
+
const { getByRole } = render(UiDataTablePagination, {
|
|
115
123
|
props: { table },
|
|
116
124
|
});
|
|
117
125
|
|
|
118
|
-
|
|
119
|
-
await user.click(getByText('10'));
|
|
126
|
+
await user.click(getByRole('button', { name: 'Rows per page' }));
|
|
120
127
|
|
|
121
128
|
await waitFor(() => {
|
|
122
129
|
expect(getByRole('menuitem', { name: '10' })).toBeInTheDocument();
|
|
@@ -129,11 +136,11 @@ describe('UiDataTablePagination', () => {
|
|
|
129
136
|
test('shows custom page size options when provided', async () => {
|
|
130
137
|
const user = userEvent.setup();
|
|
131
138
|
const table = createMockTable({ pageSize: 5 });
|
|
132
|
-
const { getByRole
|
|
139
|
+
const { getByRole } = render(UiDataTablePagination, {
|
|
133
140
|
props: { table, pageSizeOptions: [5, 15, 25] },
|
|
134
141
|
});
|
|
135
142
|
|
|
136
|
-
await user.click(
|
|
143
|
+
await user.click(getByRole('button', { name: 'Rows per page' }));
|
|
137
144
|
|
|
138
145
|
await waitFor(() => {
|
|
139
146
|
expect(getByRole('menuitem', { name: '5' })).toBeInTheDocument();
|
|
@@ -145,11 +152,11 @@ describe('UiDataTablePagination', () => {
|
|
|
145
152
|
test('changes page size when option is selected', async () => {
|
|
146
153
|
const user = userEvent.setup();
|
|
147
154
|
const table = createMockTable();
|
|
148
|
-
const { getByRole
|
|
155
|
+
const { getByRole } = render(UiDataTablePagination, {
|
|
149
156
|
props: { table },
|
|
150
157
|
});
|
|
151
158
|
|
|
152
|
-
await user.click(
|
|
159
|
+
await user.click(getByRole('button', { name: 'Rows per page' }));
|
|
153
160
|
await waitFor(() => expect(getByRole('menu')).toBeInTheDocument());
|
|
154
161
|
|
|
155
162
|
await user.click(getByRole('menuitem', { name: '20' }));
|
|
@@ -160,7 +167,7 @@ describe('UiDataTablePagination', () => {
|
|
|
160
167
|
|
|
161
168
|
describe('Navigation Buttons', () => {
|
|
162
169
|
test('first and previous buttons are disabled on first page', () => {
|
|
163
|
-
const table = createMockTable({
|
|
170
|
+
const table = createMockTable({ pageIndex: 0 });
|
|
164
171
|
const { getByRole } = render(UiDataTablePagination, {
|
|
165
172
|
props: { table },
|
|
166
173
|
});
|
|
@@ -170,7 +177,7 @@ describe('UiDataTablePagination', () => {
|
|
|
170
177
|
});
|
|
171
178
|
|
|
172
179
|
test('next and last buttons are disabled on last page', () => {
|
|
173
|
-
const table = createMockTable({
|
|
180
|
+
const table = createMockTable({ pageIndex: 4, pageCount: 5 });
|
|
174
181
|
const { getByRole } = render(UiDataTablePagination, {
|
|
175
182
|
props: { table },
|
|
176
183
|
});
|
|
@@ -181,7 +188,7 @@ describe('UiDataTablePagination', () => {
|
|
|
181
188
|
|
|
182
189
|
test('navigates to first page when first button is clicked', async () => {
|
|
183
190
|
const user = userEvent.setup();
|
|
184
|
-
const table = createMockTable({
|
|
191
|
+
const table = createMockTable({ pageIndex: 3 });
|
|
185
192
|
const { getByRole } = render(UiDataTablePagination, {
|
|
186
193
|
props: { table },
|
|
187
194
|
});
|
|
@@ -193,31 +200,31 @@ describe('UiDataTablePagination', () => {
|
|
|
193
200
|
|
|
194
201
|
test('navigates to previous page when previous button is clicked', async () => {
|
|
195
202
|
const user = userEvent.setup();
|
|
196
|
-
const table = createMockTable({
|
|
203
|
+
const table = createMockTable({ pageIndex: 2 });
|
|
197
204
|
const { getByRole } = render(UiDataTablePagination, {
|
|
198
205
|
props: { table },
|
|
199
206
|
});
|
|
200
207
|
|
|
201
208
|
await user.click(getByRole('button', { name: /previous page/i }));
|
|
202
209
|
|
|
203
|
-
expect(table.
|
|
210
|
+
expect(table.setPageIndex).toHaveBeenCalledWith(1);
|
|
204
211
|
});
|
|
205
212
|
|
|
206
213
|
test('navigates to next page when next button is clicked', async () => {
|
|
207
214
|
const user = userEvent.setup();
|
|
208
|
-
const table = createMockTable({
|
|
215
|
+
const table = createMockTable({ pageIndex: 0 });
|
|
209
216
|
const { getByRole } = render(UiDataTablePagination, {
|
|
210
217
|
props: { table },
|
|
211
218
|
});
|
|
212
219
|
|
|
213
220
|
await user.click(getByRole('button', { name: /next page/i }));
|
|
214
221
|
|
|
215
|
-
expect(table.
|
|
222
|
+
expect(table.setPageIndex).toHaveBeenCalledWith(1);
|
|
216
223
|
});
|
|
217
224
|
|
|
218
225
|
test('navigates to last page when last button is clicked', async () => {
|
|
219
226
|
const user = userEvent.setup();
|
|
220
|
-
const table = createMockTable({
|
|
227
|
+
const table = createMockTable({ pageCount: 10 });
|
|
221
228
|
const { getByRole } = render(UiDataTablePagination, {
|
|
222
229
|
props: { table },
|
|
223
230
|
});
|
|
@@ -227,11 +234,25 @@ describe('UiDataTablePagination', () => {
|
|
|
227
234
|
expect(table.setPageIndex).toHaveBeenCalledWith(9);
|
|
228
235
|
});
|
|
229
236
|
|
|
230
|
-
test('
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
237
|
+
test('jumps to a page when its number is clicked', async () => {
|
|
238
|
+
const user = userEvent.setup();
|
|
239
|
+
const table = createMockTable({ pageIndex: 0, pageCount: 5 });
|
|
240
|
+
const { getByRole } = render(UiDataTablePagination, {
|
|
241
|
+
props: { table },
|
|
234
242
|
});
|
|
243
|
+
|
|
244
|
+
expect(getByRole('button', { name: 'Page 1' })).toHaveAttribute(
|
|
245
|
+
'aria-current',
|
|
246
|
+
'page',
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
await user.click(getByRole('button', { name: 'Page 3' }));
|
|
250
|
+
|
|
251
|
+
expect(table.setPageIndex).toHaveBeenCalledWith(2);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
test('all buttons are enabled when on middle page', () => {
|
|
255
|
+
const table = createMockTable({ pageIndex: 2 });
|
|
235
256
|
const { getByRole } = render(UiDataTablePagination, {
|
|
236
257
|
props: { table },
|
|
237
258
|
});
|
|
@@ -277,6 +298,7 @@ describe('UiDataTablePagination', () => {
|
|
|
277
298
|
labels: {
|
|
278
299
|
rowsPerPage: 'Zeilen pro Seite',
|
|
279
300
|
goToFirstPage: 'Zur ersten Seite',
|
|
301
|
+
goToPage: (page: number) => `Seite ${page}`,
|
|
280
302
|
pageOf: (page: number, total: number) =>
|
|
281
303
|
`Seite ${page} von ${total}`,
|
|
282
304
|
rowsSelected: (selected: number, total: number) =>
|
|
@@ -291,6 +313,13 @@ describe('UiDataTablePagination', () => {
|
|
|
291
313
|
expect(
|
|
292
314
|
getByRole('button', { name: 'Zur ersten Seite' }),
|
|
293
315
|
).toBeInTheDocument();
|
|
316
|
+
expect(getByRole('button', { name: 'Seite 2' })).toHaveAttribute(
|
|
317
|
+
'aria-current',
|
|
318
|
+
'page',
|
|
319
|
+
);
|
|
320
|
+
expect(
|
|
321
|
+
getByRole('button', { name: 'Go to previous page' }),
|
|
322
|
+
).toBeInTheDocument();
|
|
294
323
|
});
|
|
295
324
|
});
|
|
296
325
|
});
|
|
@@ -65,6 +65,16 @@ export interface PaginationLabels {
|
|
|
65
65
|
goToNextPage?: string;
|
|
66
66
|
/** Aria label for last page button */
|
|
67
67
|
goToLastPage?: string;
|
|
68
|
+
/** Visible text of the previous button */
|
|
69
|
+
previous?: string;
|
|
70
|
+
/** Visible text of the next button */
|
|
71
|
+
next?: string;
|
|
72
|
+
/** Aria label for a numbered page button */
|
|
73
|
+
goToPage?: (page: number) => string;
|
|
74
|
+
/** Screen-reader text for the ellipsis standing in for skipped pages */
|
|
75
|
+
morePages?: string;
|
|
76
|
+
/** Accessible name of the pagination navigation landmark */
|
|
77
|
+
navigation?: string;
|
|
68
78
|
/** Function to generate page info text */
|
|
69
79
|
pageOf?: (page: number, total: number) => string;
|
|
70
80
|
/** Function to generate selection count text */
|
package/src/patterns/index.ts
CHANGED