@aleph-alpha/ui-library 7.0.2 → 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 (64) 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/UiSlider/step-marks.d.ts +45 -0
  6. package/dist/system/components/UiSlider/types.d.ts +28 -0
  7. package/dist/system/components/core/pagination/Pagination.vue.d.ts +29 -0
  8. package/dist/system/components/core/pagination/PaginationContent.vue.d.ts +29 -0
  9. package/dist/system/components/core/pagination/PaginationEllipsis.vue.d.ts +22 -0
  10. package/dist/system/components/core/pagination/PaginationFirst.vue.d.ts +22 -0
  11. package/dist/system/components/core/pagination/PaginationItem.vue.d.ts +26 -0
  12. package/dist/system/components/core/pagination/PaginationLast.vue.d.ts +22 -0
  13. package/dist/system/components/core/pagination/PaginationNext.vue.d.ts +22 -0
  14. package/dist/system/components/core/pagination/PaginationPrevious.vue.d.ts +22 -0
  15. package/dist/system/components/core/pagination/index.d.ts +8 -0
  16. package/dist/system/components/core/slider/Slider.vue.d.ts +21 -1
  17. package/dist/system/components/index.d.ts +1 -0
  18. package/dist/system/icons/story-sidebar-icons.json +4 -0
  19. package/dist/system/lib.js +11762 -10952
  20. package/dist/system/patterns/UiBulkAction/UiBulkAction.vue.d.ts +43 -0
  21. package/dist/system/patterns/UiBulkAction/index.d.ts +3 -0
  22. package/dist/system/patterns/UiBulkAction/types.d.ts +109 -0
  23. package/dist/system/patterns/UiBulkAction/useBulkAction.d.ts +7 -0
  24. package/dist/system/patterns/UiDataTable/constants.d.ts +10 -0
  25. package/dist/system/patterns/index.d.ts +1 -0
  26. package/dist/system/story-sidebar-icons.json +4 -0
  27. package/package.json +8 -8
  28. package/src/components/UiPagination/UiPagination.guidance.md +60 -0
  29. package/src/components/UiPagination/UiPagination.stories.ts +1070 -0
  30. package/src/components/UiPagination/UiPagination.vue +109 -0
  31. package/src/components/UiPagination/__tests__/UiPagination.test.ts +203 -0
  32. package/src/components/UiPagination/constants.ts +17 -0
  33. package/src/components/UiPagination/index.ts +3 -0
  34. package/src/components/UiPagination/types.ts +82 -0
  35. package/src/components/UiSlider/UiSlider.stories.ts +710 -2
  36. package/src/components/UiSlider/UiSlider.vue +109 -1
  37. package/src/components/UiSlider/__tests__/UiSliderValueAndSteps.test.ts +210 -0
  38. package/src/components/UiSlider/__tests__/step-marks.test.ts +94 -0
  39. package/src/components/UiSlider/step-marks.ts +96 -0
  40. package/src/components/UiSlider/types.ts +32 -0
  41. package/src/components/core/pagination/Pagination.vue +26 -0
  42. package/src/components/core/pagination/PaginationContent.vue +24 -0
  43. package/src/components/core/pagination/PaginationEllipsis.vue +30 -0
  44. package/src/components/core/pagination/PaginationFirst.vue +30 -0
  45. package/src/components/core/pagination/PaginationItem.vue +39 -0
  46. package/src/components/core/pagination/PaginationLast.vue +30 -0
  47. package/src/components/core/pagination/PaginationNext.vue +35 -0
  48. package/src/components/core/pagination/PaginationPrevious.vue +35 -0
  49. package/src/components/core/pagination/index.ts +8 -0
  50. package/src/components/core/slider/Slider.vue +16 -6
  51. package/src/components/index.ts +1 -0
  52. package/src/patterns/UiBulkAction/UiBulkAction.guidance.md +59 -0
  53. package/src/patterns/UiBulkAction/UiBulkAction.stories.ts +2238 -0
  54. package/src/patterns/UiBulkAction/UiBulkAction.vue +62 -0
  55. package/src/patterns/UiBulkAction/__tests__/useBulkAction.test.ts +78 -0
  56. package/src/patterns/UiBulkAction/index.ts +3 -0
  57. package/src/patterns/UiBulkAction/types.ts +126 -0
  58. package/src/patterns/UiBulkAction/useBulkAction.ts +50 -0
  59. package/src/patterns/UiDataTable/UiDataTable.stories.ts +375 -1
  60. package/src/patterns/UiDataTable/UiDataTablePagination.vue +43 -60
  61. package/src/patterns/UiDataTable/__tests__/UiDataTablePagination.test.ts +58 -29
  62. package/src/patterns/UiDataTable/constants.ts +10 -0
  63. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +12 -12
  64. 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 { getByText, getByRole } = render(UiDataTablePagination, {
122
+ const { getByRole } = render(UiDataTablePagination, {
115
123
  props: { table },
116
124
  });
117
125
 
118
- // Click the page size button (displays current page size)
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, getByText } = render(UiDataTablePagination, {
139
+ const { getByRole } = render(UiDataTablePagination, {
133
140
  props: { table, pageSizeOptions: [5, 15, 25] },
134
141
  });
135
142
 
136
- await user.click(getByText('5'));
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, getByText } = render(UiDataTablePagination, {
155
+ const { getByRole } = render(UiDataTablePagination, {
149
156
  props: { table },
150
157
  });
151
158
 
152
- await user.click(getByText('10'));
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({ canPreviousPage: false });
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({ canNextPage: false });
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({ canPreviousPage: true, pageIndex: 3 });
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({ canPreviousPage: true });
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.previousPage).toHaveBeenCalled();
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({ canNextPage: true });
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.nextPage).toHaveBeenCalled();
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({ canNextPage: true, pageCount: 10 });
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('all buttons are enabled when on middle page', () => {
231
- const table = createMockTable({
232
- canPreviousPage: true,
233
- canNextPage: true,
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 */
@@ -174,18 +174,18 @@ export const Default: Story = {
174
174
  await step(
175
175
  'screen-reader: every link is a named menu item (WCAG 4.1.2)',
176
176
  async () => {
177
- await expect(
178
- body.getByRole('menuitem', { name: 'Account settings' }),
179
- ).toBeVisible();
180
- await expect(
181
- body.getByRole('menuitem', { name: 'Privacy policy' }),
182
- ).toBeVisible();
183
- await expect(
184
- body.getByRole('menuitem', { name: 'Terms and conditions' }),
185
- ).toBeVisible();
186
- await expect(
187
- body.getByRole('menuitem', { name: 'Sign out' }),
188
- ).toBeVisible();
177
+ // Items can still be hidden for a frame after the menu itself is
178
+ // visible while the card opens.
179
+ for (const name of [
180
+ 'Account settings',
181
+ 'Privacy policy',
182
+ 'Terms and conditions',
183
+ 'Sign out',
184
+ ]) {
185
+ await waitFor(async () => {
186
+ await expect(body.getByRole('menuitem', { name })).toBeVisible();
187
+ });
188
+ }
189
189
  },
190
190
  );
191
191
 
@@ -2,6 +2,7 @@
2
2
  * This file is auto-generated by prepare-build.js script
3
3
  * Do not edit this file manually
4
4
  */
5
+ export * from './UiBulkAction';
5
6
  export * from './UiDataTable';
6
7
  export * from './UiDatePicker';
7
8
  export * from './UiFileUpload';