@aleph-alpha/ui-library 6.3.4 → 6.5.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 (78) hide show
  1. package/config.js +2 -1
  2. package/dist/system/components/UiDropdownMenu/UiDropdownMenuSubContent.vue.d.ts +102 -2
  3. package/dist/system/components/UiDropdownMenu/UiDropdownMenuViewport.vue.d.ts +23 -0
  4. package/dist/system/components/UiDropdownMenu/menu-metrics.d.ts +4 -0
  5. package/dist/system/components/UiDropdownMenu/placeMobileSubmenu.d.ts +55 -0
  6. package/dist/system/components/UiDropdownMenu/types.d.ts +3 -0
  7. package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +18 -0
  8. package/dist/system/components/UiFileItem/UiFileItem.vue.d.ts +10 -1
  9. package/dist/system/components/UiFileItem/index.d.ts +1 -1
  10. package/dist/system/components/UiFileItem/types.d.ts +81 -5
  11. package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +2 -2
  12. package/dist/system/components/UiPopover/UiPopoverContent.vue.d.ts +1 -0
  13. package/dist/system/components/UiPopover/types.d.ts +6 -0
  14. package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +2 -2
  15. package/dist/system/components/UiToggle/UiToggle.vue.d.ts +2 -1
  16. package/dist/system/components/UiToggle/types.d.ts +10 -2
  17. package/dist/system/components/UiToggleGroup/UiToggleGroupItem.vue.d.ts +5 -1
  18. package/dist/system/components/UiToggleGroup/types.d.ts +12 -2
  19. package/dist/system/components/core/dropdown-menu/DropdownMenuSubContent.vue.d.ts +2 -6
  20. package/dist/system/components/core/popover/PopoverContent.vue.d.ts +1 -0
  21. package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +2 -2
  22. package/dist/system/components/core/toggle/Toggle.vue.d.ts +3 -1
  23. package/dist/system/components/core/toggle/index.d.ts +47 -2
  24. package/dist/system/components/core/toggle-group/ToggleGroup.vue.d.ts +3 -1
  25. package/dist/system/components/core/toggle-group/ToggleGroupItem.vue.d.ts +11 -1
  26. package/dist/system/components/core/toggle-group/context.d.ts +1 -0
  27. package/dist/system/components/core/toggle-group/index.d.ts +10 -2
  28. package/dist/system/lib.js +10646 -10369
  29. package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +2 -2
  30. package/dist/system/patterns/UiLayout/layout-shell.d.ts +171 -12
  31. package/dist/system/patterns/UiProfileCard/profile-card.d.ts +51 -1
  32. package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +9 -4
  33. package/package.json +2 -2
  34. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +819 -31
  35. package/src/components/UiDropdownMenu/UiDropdownMenuContent.vue +4 -1
  36. package/src/components/UiDropdownMenu/UiDropdownMenuSubContent.vue +142 -1
  37. package/src/components/UiDropdownMenu/UiDropdownMenuSubTrigger.vue +28 -0
  38. package/src/components/UiDropdownMenu/UiDropdownMenuViewport.vue +171 -0
  39. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +326 -0
  40. package/src/components/UiDropdownMenu/__tests__/placeMobileSubmenu.test.ts +128 -0
  41. package/src/components/UiDropdownMenu/menu-metrics.ts +5 -0
  42. package/src/components/UiDropdownMenu/placeMobileSubmenu.ts +96 -0
  43. package/src/components/UiDropdownMenu/types.ts +3 -0
  44. package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +163 -0
  45. package/src/components/UiFileItem/UiFileItem.vue +111 -6
  46. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +52 -0
  47. package/src/components/UiFileItem/index.ts +1 -0
  48. package/src/components/UiFileItem/types.ts +82 -5
  49. package/src/components/UiPopover/UiPopover.stories.ts +141 -0
  50. package/src/components/UiPopover/UiPopoverContent.vue +2 -0
  51. package/src/components/UiPopover/__tests__/UiPopover.test.ts +48 -0
  52. package/src/components/UiPopover/types.ts +7 -0
  53. package/src/components/UiSnackbar/UiSnackbar.stories.ts +104 -32
  54. package/src/components/UiToggle/UiToggle.stories.ts +386 -261
  55. package/src/components/UiToggle/UiToggle.vue +2 -0
  56. package/src/components/UiToggle/__tests__/UiToggle.test.ts +63 -10
  57. package/src/components/UiToggle/types.ts +10 -2
  58. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +765 -30
  59. package/src/components/UiToggleGroup/UiToggleGroup.vue +2 -0
  60. package/src/components/UiToggleGroup/UiToggleGroupItem.vue +10 -1
  61. package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +83 -4
  62. package/src/components/UiToggleGroup/types.ts +12 -2
  63. package/src/components/core/dropdown-menu/DropdownMenuContent.vue +1 -1
  64. package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
  65. package/src/components/core/dropdown-menu/DropdownMenuSubContent.vue +31 -20
  66. package/src/components/core/popover/PopoverContent.vue +9 -3
  67. package/src/components/core/toggle/Toggle.vue +12 -5
  68. package/src/components/core/toggle/index.ts +47 -19
  69. package/src/components/core/toggle-group/ToggleGroup.vue +20 -4
  70. package/src/components/core/toggle-group/ToggleGroupItem.vue +36 -8
  71. package/src/components/core/toggle-group/context.ts +1 -0
  72. package/src/components/core/toggle-group/index.ts +10 -24
  73. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
  74. package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
  75. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +808 -22
  76. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +188 -6
  77. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +13 -6
  78. package/src/patterns/UiTopBar/accessory-dropdown.ts +5 -3
@@ -842,16 +842,18 @@ export const Accessibility: Story = {
842
842
  survives without colour
843
843
  </li>
844
844
  <li>
845
- Progress, success and error are each distinguishable by icon
846
- and text, never by colour alone
845
+ Progress, processing, success and error are each distinguishable
846
+ by icon and text, never by colour alone. Processing keeps the
847
+ neutral badge and says so in text
847
848
  </li>
848
849
  <li>
849
850
  Error text sits in the row it belongs to and stays legible at
850
851
  the small size
851
852
  </li>
852
853
  <li>
853
- Remove and menu controls stay comfortable targets for touch as
854
- well as pointer
854
+ Remove and the multi-file chevron stay comfortable targets for
855
+ touch as well as pointer. The chevron opens a list where each
856
+ file keeps the icon for its type
855
857
  </li>
856
858
  <li>
857
859
  Focus is clearly visible on the picker, on each file row and on
@@ -877,12 +879,29 @@ export const Accessibility: Story = {
877
879
  <h3 class="label-16-medium text-center text-content-on-surface-primary">
878
880
  Default
879
881
  </h3>
880
- <div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
882
+ <div class="flex min-h-20 flex-col justify-center gap-3 border border-border-surface-default p-6">
883
+ <UiFileItem
884
+ filename="Filename.pdf"
885
+ type-label="PDF"
886
+ processing
887
+ processing-label="Processing…"
888
+ remove-label="Remove Filename.pdf"
889
+ />
881
890
  <UiFileItem
882
891
  filename="Filename"
883
892
  error="Upload failed"
884
893
  remove-label="Remove Filename"
885
894
  />
895
+ <UiFileItem
896
+ filename="Attached documents"
897
+ type-label="2 files"
898
+ expand-label="Show attached documents"
899
+ :removable="false"
900
+ :items="[
901
+ { filename: 'Plan.pdf', typeLabel: 'PDF', sizeLabel: '12 MB' },
902
+ { filename: 'Notes.md', typeLabel: 'MD', sizeLabel: '12 KB' },
903
+ ]"
904
+ />
886
905
  </div>
887
906
  </div>
888
907
 
@@ -890,12 +909,29 @@ export const Accessibility: Story = {
890
909
  <h3 class="label-16-medium text-center text-content-on-surface-primary">
891
910
  Accessible
892
911
  </h3>
893
- <div class="flex min-h-20 flex-col justify-center border border-border-surface-default p-6">
912
+ <div class="flex min-h-20 flex-col justify-center gap-3 border border-border-surface-default p-6">
913
+ <UiFileItem
914
+ filename="Filename.pdf"
915
+ type-label="PDF"
916
+ processing
917
+ processing-label="Processing…"
918
+ remove-label="Remove Filename.pdf"
919
+ />
894
920
  <UiFileItem
895
921
  filename="Filename"
896
922
  error="Upload failed"
897
923
  remove-label="Remove Filename"
898
924
  />
925
+ <UiFileItem
926
+ filename="Attached documents"
927
+ type-label="2 files"
928
+ expand-label="Show attached documents"
929
+ :removable="false"
930
+ :items="[
931
+ { filename: 'Plan.pdf', typeLabel: 'PDF', sizeLabel: '12 MB' },
932
+ { filename: 'Notes.md', typeLabel: 'MD', sizeLabel: '12 KB' },
933
+ ]"
934
+ />
899
935
  </div>
900
936
  </div>
901
937
  </div>
@@ -1343,3 +1379,149 @@ export const DialogIntegration: Story = {
1343
1379
  );
1344
1380
  },
1345
1381
  };
1382
+
1383
+ const patternFiles = [
1384
+ {
1385
+ id: 'plan',
1386
+ filename: '26_Business_Plan_2026.pdf',
1387
+ typeLabel: 'PDF',
1388
+ sizeLabel: '12 MB',
1389
+ removeLabel: 'Remove 26_Business_Plan_2026.pdf',
1390
+ },
1391
+ {
1392
+ id: 'notes',
1393
+ filename: 'Last_weeks_memory.md',
1394
+ typeLabel: 'MD',
1395
+ sizeLabel: '12 KB',
1396
+ removeLabel: 'Remove Last_weeks_memory.md',
1397
+ },
1398
+ {
1399
+ id: 'sheet',
1400
+ filename: 'Tabular_analysis.csv',
1401
+ typeLabel: 'CSV',
1402
+ sizeLabel: '12 MB',
1403
+ removeLabel: 'Remove Tabular_analysis.csv',
1404
+ },
1405
+ ];
1406
+
1407
+ /**
1408
+ * File rows the pattern renders after a pick: a processing file, and a multi
1409
+ * row whose chevron lists each file with the icon for its type. Hidden
1410
+ * test-only story.
1411
+ */
1412
+ export const FileListStates: Story = {
1413
+ name: 'test - File List States',
1414
+ tags: ['!dev', '!autodocs'],
1415
+ parameters: {
1416
+ chromatic: { disableSnapshot: true },
1417
+ controls: { disable: true },
1418
+ docs: {
1419
+ description: {
1420
+ story:
1421
+ 'Processing status and the multi-file disclosure used beside the uploader.',
1422
+ },
1423
+ },
1424
+ },
1425
+ render: () => ({
1426
+ components: { UiFileItem },
1427
+ setup() {
1428
+ return { files: patternFiles };
1429
+ },
1430
+ template: `
1431
+ <ul class="flex flex-col gap-2" aria-label="Selected files">
1432
+ <li>
1433
+ <UiFileItem
1434
+ filename="Quarterly report.pdf"
1435
+ type-label="PDF"
1436
+ processing
1437
+ processing-label="Processing…"
1438
+ remove-label="Remove Quarterly report.pdf"
1439
+ />
1440
+ </li>
1441
+ <li>
1442
+ <UiFileItem
1443
+ filename="Attached documents"
1444
+ type-label="3 files"
1445
+ expand-label="Show attached documents"
1446
+ list-label="Attached files"
1447
+ :items="files"
1448
+ :removable="false"
1449
+ />
1450
+ </li>
1451
+ </ul>
1452
+ `,
1453
+ }),
1454
+ play: async ({ canvasElement, step }) => {
1455
+ // Scenario (UiFileUpload): the list beside the drop zone includes a file
1456
+ // that is still processing and a group of mixed types. Assistive tech hears
1457
+ // the processing status, and opening the group shows each file's own icon.
1458
+ const canvas = within(canvasElement);
1459
+ const body = within(document.body);
1460
+
1461
+ await step(
1462
+ 'screen-reader: a processing file is a status named with the file and the label (WCAG 4.1.3)',
1463
+ async () => {
1464
+ await expect(canvas.getByRole('status')).toHaveAccessibleName(
1465
+ 'Quarterly report.pdf, PDF, Processing…',
1466
+ );
1467
+ await expect(canvas.queryByRole('progressbar')).not.toBeInTheDocument();
1468
+ },
1469
+ );
1470
+
1471
+ await step(
1472
+ 'keyboard: Tab reaches the group chevron and Enter opens it (WCAG 2.1.1)',
1473
+ async () => {
1474
+ const chevron = canvas.getByRole('button', {
1475
+ name: 'Show attached documents',
1476
+ });
1477
+ await userEvent.tab();
1478
+ await userEvent.tab();
1479
+ await expect(chevron).toHaveFocus();
1480
+ await userEvent.keyboard('{Enter}');
1481
+ await expect(chevron).toHaveAttribute('aria-expanded', 'true');
1482
+ },
1483
+ );
1484
+
1485
+ await step(
1486
+ 'interaction: the list groups each file under the icon for its type',
1487
+ async () => {
1488
+ const list = await body.findByRole('list', { name: 'Attached files' });
1489
+ // The panel fades and zooms in, so the type labels are in the DOM a
1490
+ // frame before they are visible.
1491
+ await waitFor(async () => {
1492
+ await expect(list).toBeVisible();
1493
+ });
1494
+ const tones = Array.from(
1495
+ list.querySelectorAll('[data-slot="file-type"]'),
1496
+ ).map((badge) => badge.getAttribute('data-tone'));
1497
+ await expect(tones).toEqual([
1498
+ 'accent-pink',
1499
+ 'accent-soft',
1500
+ 'accent-yellow',
1501
+ ]);
1502
+ for (const label of ['PDF', 'MD', 'CSV']) {
1503
+ await waitFor(async () => {
1504
+ await expect(within(list).getByText(label)).toBeVisible();
1505
+ });
1506
+ }
1507
+ },
1508
+ );
1509
+
1510
+ await step(
1511
+ 'screen-reader: each file in the group exposes its filename (WCAG 4.1.2)',
1512
+ async () => {
1513
+ const list = body.getByRole('list', { name: 'Attached files' });
1514
+ await expect(
1515
+ within(list).getByLabelText('Last_weeks_memory.md'),
1516
+ ).toHaveTextContent('Last_weeks_memory');
1517
+ },
1518
+ );
1519
+
1520
+ await step('keyboard: Escape closes the file list', async () => {
1521
+ await userEvent.keyboard('{Escape}');
1522
+ await expect(
1523
+ canvas.getByRole('button', { name: 'Show attached documents' }),
1524
+ ).toHaveAttribute('aria-expanded', 'false');
1525
+ });
1526
+ },
1527
+ };
@@ -51,6 +51,13 @@ const stayOpen = {
51
51
  onInteractOutside: (event: Event) => event.preventDefault(),
52
52
  };
53
53
 
54
+ /**
55
+ * A card pinned open with `:avoid-collisions="false"` ignores the viewport,
56
+ * so it must ignore the height reka-ui found free beside its trigger too:
57
+ * low on the page that is less than the card, which would otherwise scroll.
58
+ */
59
+ const PINNED = 'max-h-none';
60
+
54
61
  /**
55
62
  * Keeps the open state in sync with the `open` control while still letting the
56
63
  * avatar toggle the card.
@@ -129,7 +136,7 @@ export const Default: Story = {
129
136
  ${HIDDEN_TRIGGER}
130
137
  <UiDropdownMenuContent
131
138
  v-bind="stayOpen"
132
- class="${CARD}"
139
+ class="${CARD} ${PINNED}"
133
140
  align="start"
134
141
  :avoid-collisions="false"
135
142
  >
@@ -237,7 +244,7 @@ export const WithItemIcons: Story = {
237
244
  ${HIDDEN_TRIGGER}
238
245
  <UiDropdownMenuContent
239
246
  v-bind="stayOpen"
240
- class="${CARD}"
247
+ class="${CARD} ${PINNED}"
241
248
  align="start"
242
249
  :avoid-collisions="false"
243
250
  >
@@ -336,7 +343,7 @@ export const WithSubmenus: Story = {
336
343
  ${HIDDEN_TRIGGER}
337
344
  <UiDropdownMenuContent
338
345
  v-bind="stayOpen"
339
- class="${CARD}"
346
+ class="${CARD} ${PINNED}"
340
347
  align="start"
341
348
  :avoid-collisions="false"
342
349
  >
@@ -421,7 +428,7 @@ export const LanguagePicker: Story = {
421
428
  ${HIDDEN_TRIGGER}
422
429
  <UiDropdownMenuContent
423
430
  v-bind="stayOpen"
424
- class="${CARD}"
431
+ class="${CARD} ${PINNED}"
425
432
  align="start"
426
433
  :avoid-collisions="false"
427
434
  >
@@ -474,7 +481,7 @@ const themedCard = (themeClass = '') => `
474
481
  ${HIDDEN_TRIGGER}
475
482
  <UiDropdownMenuContent
476
483
  v-bind="stayOpen"
477
- class="${CARD} ${themeClass}"
484
+ class="${CARD} ${PINNED} ${themeClass}"
478
485
  align="start"
479
486
  :avoid-collisions="false"
480
487
  >
@@ -595,7 +602,7 @@ export const WithAvatarTrigger: Story = {
595
602
  ${AVATAR_TRIGGER}
596
603
  <UiDropdownMenuContent
597
604
  v-bind="stayOpen"
598
- class="${CARD}"
605
+ class="${CARD} ${PINNED}"
599
606
  align="start"
600
607
  :avoid-collisions="false"
601
608
  >
@@ -48,12 +48,14 @@ export function accessoryDropdownState() {
48
48
  /**
49
49
  * The accessibility toggle and the menu it opens. The trigger is a `UiToggle`
50
50
  * bound to the same state as the menu, so the pressed look and the menu never
51
- * disagree, and the chevron is a second signal rather than the only one.
51
+ * disagree, and the chevron is a second signal rather than the only one. It is
52
+ * `soft`, the fill meant for menu triggers: while the menu is open the trigger
53
+ * reads as lit up rather than as a second filled button beside it.
52
54
  */
53
55
  export const ACCESSORY_DROPDOWN = `
54
56
  <UiDropdownMenu v-model:open="accessoryOpen">
55
57
  <UiDropdownMenuTrigger as-child>
56
- <UiToggle v-model="accessoryOpen" aria-label="${ACCESSORY_TRIGGER_NAME}">
58
+ <UiToggle v-model="accessoryOpen" soft aria-label="${ACCESSORY_TRIGGER_NAME}">
57
59
  <UiIcon size="s" name="PersonStanding" />
58
60
  ${ACCESSORY_TRIGGER_NAME}
59
61
  <UiIcon :name="accessoryOpen ? 'chevron-up' : 'chevron-down'" size="s" />
@@ -70,7 +72,7 @@ export const ACCESSORY_DROPDOWN = `
70
72
  const SOURCE_LINES = [
71
73
  `<UiDropdownMenu v-model:open="accessoryOpen">`,
72
74
  ` <UiDropdownMenuTrigger as-child>`,
73
- ` <UiToggle v-model="accessoryOpen" aria-label="${ACCESSORY_TRIGGER_NAME}">`,
75
+ ` <UiToggle v-model="accessoryOpen" soft aria-label="${ACCESSORY_TRIGGER_NAME}">`,
74
76
  ` <UiIcon size="s" name="PersonStanding" />`,
75
77
  ` ${ACCESSORY_TRIGGER_NAME}`,
76
78
  ` <UiIcon :name="accessoryOpen ? 'chevron-up' : 'chevron-down'" size="s" />`,