@aleph-alpha/ui-library 5.4.0 → 5.6.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 (59) hide show
  1. package/config.d.ts +9 -0
  2. package/config.js +12 -3
  3. package/dist/system/components/UiAutocomplete/UiAutocomplete.vue.d.ts +2 -0
  4. package/dist/system/components/UiButtonGroup/UiButtonGroup.vue.d.ts +20 -0
  5. package/dist/system/components/UiButtonGroup/index.d.ts +2 -0
  6. package/dist/system/components/UiButtonGroup/types.d.ts +20 -0
  7. package/dist/system/components/core/button-group/ButtonGroup.vue.d.ts +23 -0
  8. package/dist/system/components/core/button-group/ButtonGroupSeparator.vue.d.ts +9 -0
  9. package/dist/system/components/core/button-group/ButtonGroupText.vue.d.ts +26 -0
  10. package/dist/system/components/core/button-group/index.d.ts +8 -0
  11. package/dist/system/components/index.d.ts +1 -0
  12. package/dist/system/lib.js +8878 -8692
  13. package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +173 -2
  14. package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +15 -1
  15. package/dist/system/patterns/UiFloatActions/types.d.ts +25 -1
  16. package/dist/system/story-sidebar-icons.json +8 -1
  17. package/package.json +5 -3
  18. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +620 -0
  19. package/src/components/UiAutocomplete/UiAutocomplete.vue +28 -3
  20. package/src/components/UiAutocomplete/__tests__/UiAutocomplete.test.ts +14 -69
  21. package/src/components/UiButton/UiButton.stories.ts +9 -9
  22. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +690 -0
  23. package/src/components/UiButtonGroup/UiButtonGroup.vue +18 -0
  24. package/src/components/UiButtonGroup/__tests__/UiButtonGroup.test.ts +68 -0
  25. package/src/components/UiButtonGroup/index.ts +2 -0
  26. package/src/components/UiButtonGroup/types.ts +21 -0
  27. package/src/components/UiCheckbox/UiCheckbox.stories.ts +253 -0
  28. package/src/components/UiCheckbox/__tests__/UiCheckbox.test.ts +3 -18
  29. package/src/components/UiField/UiField.stories.ts +608 -1
  30. package/src/components/UiField/UiFieldDescription.vue +7 -2
  31. package/src/components/UiInput/UiInput.stories.ts +336 -2
  32. package/src/components/UiInput/__tests__/UiInput.test.ts +20 -28
  33. package/src/components/UiItem/UiItem.stories.ts +236 -1
  34. package/src/components/UiItem/__tests__/UiItem.test.ts +11 -72
  35. package/src/components/UiSelect/UiSelect.stories.ts +769 -0
  36. package/src/components/UiSelect/__tests__/UiSelect.test.ts +4 -73
  37. package/src/components/UiSelect/__tests__/UiSelectItem.test.ts +3 -31
  38. package/src/components/UiSelect/__tests__/UiSelectTrigger.test.ts +14 -5
  39. package/src/components/UiSnackbar/UiSnackbar.stories.ts +6 -6
  40. package/src/components/UiSnackbar/UiSnackbar.vue +4 -4
  41. package/src/components/UiSnackbar/UiSnackbarContent.vue +4 -4
  42. package/src/components/core/button-group/ButtonGroup.vue +24 -0
  43. package/src/components/core/button-group/ButtonGroupSeparator.vue +29 -0
  44. package/src/components/core/button-group/ButtonGroupText.vue +33 -0
  45. package/src/components/core/button-group/index.ts +25 -0
  46. package/src/components/core/checkbox/Checkbox.vue +0 -1
  47. package/src/components/core/select/SelectTrigger.vue +1 -1
  48. package/src/components/core/tabs/TabsTrigger.vue +1 -1
  49. package/src/components/index.ts +1 -0
  50. package/src/patterns/UiDataTable/UiDataTable.stories.ts +495 -8
  51. package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
  52. package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +7 -184
  53. package/src/patterns/UiFloatActions/UiFloatActionItems.vue +138 -11
  54. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +890 -3
  55. package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +46 -24
  56. package/src/patterns/UiFloatActions/floatActionItemContext.ts +16 -1
  57. package/src/patterns/UiFloatActions/types.ts +28 -1
  58. package/src/components/UiField/__tests__/UiFieldError.test.ts +0 -39
  59. package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +0 -152
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { expect, userEvent, within } from 'storybook/test';
2
3
  import type { ColumnDef, Row } from '@aleph-alpha/ui-library';
3
4
  import { computed, h, ref, reactive } from 'vue';
4
5
  import {
@@ -115,14 +116,14 @@ const selectableColumns: ColumnDef<Payment>[] = [
115
116
  (table.getIsSomePageRowsSelected() && 'indeterminate'),
116
117
  'onUpdate:modelValue': (value: boolean) =>
117
118
  table.toggleAllPageRowsSelected(!!value),
118
- ariaLabel: 'Select all',
119
+ 'aria-label': 'Select all',
119
120
  name: 'select-all',
120
121
  }),
121
122
  cell: ({ row }) =>
122
123
  h(UiCheckbox, {
123
124
  modelValue: row.getIsSelected(),
124
125
  'onUpdate:modelValue': (value: boolean) => row.toggleSelected(!!value),
125
- ariaLabel: 'Select row',
126
+ 'aria-label': 'Select row',
126
127
  name: `select-${row.id}`,
127
128
  }),
128
129
  enableSorting: false,
@@ -494,13 +495,13 @@ const columns: ColumnDef<Payment>[] = [
494
495
  header: ({ table }) => h(UiCheckbox, {
495
496
  modelValue: table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && 'indeterminate'),
496
497
  'onUpdate:modelValue': (value: boolean) => table.toggleAllPageRowsSelected(!!value),
497
- ariaLabel: 'Select all',
498
+ 'aria-label': 'Select all',
498
499
  name: 'select-all',
499
500
  }),
500
501
  cell: ({ row }) => h(UiCheckbox, {
501
502
  modelValue: row.getIsSelected(),
502
503
  'onUpdate:modelValue': (value: boolean) => row.toggleSelected(!!value),
503
- ariaLabel: 'Select row',
504
+ 'aria-label': 'Select row',
504
505
  name: \`select-\${row.id}\`,
505
506
  }),
506
507
  enableSorting: false,
@@ -633,13 +634,13 @@ const columns: ColumnDef<Payment>[] = [
633
634
  header: ({ table }) => h(UiCheckbox, {
634
635
  modelValue: table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && 'indeterminate'),
635
636
  'onUpdate:modelValue': (value: boolean) => table.toggleAllPageRowsSelected(!!value),
636
- ariaLabel: 'Select all',
637
+ 'aria-label': 'Select all',
637
638
  name: 'select-all',
638
639
  }),
639
640
  cell: ({ row }) => h(UiCheckbox, {
640
641
  modelValue: row.getIsSelected(),
641
642
  'onUpdate:modelValue': (value: boolean) => row.toggleSelected(!!value),
642
- ariaLabel: 'Select row',
643
+ 'aria-label': 'Select row',
643
644
  name: \`select-\${row.id}\`,
644
645
  }),
645
646
  enableSorting: false,
@@ -2321,7 +2322,7 @@ function removeFilters() {
2321
2322
  <div class="space-y-4">
2322
2323
  <UiDataTableToolbar>
2323
2324
  <UiDataTableFilterMenu v-if="table" v-model:open="filterOpen" :active-count="activeCount">
2324
- <form class="flex flex-col gap-xl" @submit.prevent="applyFilters">
2325
+ <form class="flex flex-col gap-5" @submit.prevent="applyFilters">
2325
2326
  <UiFieldGroup>
2326
2327
  <UiField>
2327
2328
  <UiFieldLabel for="filter-email">Email</UiFieldLabel>
@@ -2487,7 +2488,7 @@ export const WithFilterMenu: Story = {
2487
2488
  v-model:open="filterOpen"
2488
2489
  :active-count="activeCount"
2489
2490
  >
2490
- <form class="flex flex-col gap-xl" @submit.prevent="applyFilters">
2491
+ <form class="flex flex-col gap-5" @submit.prevent="applyFilters">
2491
2492
  <UiFieldGroup>
2492
2493
  <UiField>
2493
2494
  <UiFieldLabel for="filter-email">Email</UiFieldLabel>
@@ -2543,3 +2544,489 @@ export const WithFilterMenu: Story = {
2543
2544
  `,
2544
2545
  }),
2545
2546
  };
2547
+
2548
+ // ---------------------------------------------------------------------------
2549
+ // Accessibility & interaction test scenarios
2550
+ // ---------------------------------------------------------------------------
2551
+ //
2552
+ // The stories below drive the Storybook test-runner. Each labels its checks
2553
+ // with a category-prefixed `step()` so the automated report and the scenario
2554
+ // PDF can group them consistently:
2555
+ //
2556
+ // await step('interaction: ...', async () => { … }); // behaviour + state
2557
+ // await step('keyboard: ...', async () => { … }); // Tab / Enter / Space
2558
+ // await step('screen-reader: ...', async () => { … }); // roles, names, ARIA
2559
+ // await step('zoom: ...', async () => { … }); // 200% resize text
2560
+ // await step('mobile: ...', async () => { … }); // 320px reflow
2561
+ //
2562
+ // Accessibility (axe) is audited automatically for every visited story, so it
2563
+ // is not a labelled category here. The test-only stories are hidden from the
2564
+ // sidebar and docs via the `!dev` / `!autodocs` tags but keep the implicit
2565
+ // `test` tag, so they still run in CI. `name`/`tags` must be literal so
2566
+ // Storybook's static CSF indexer can read them. Focus/sort state mutates during
2567
+ // these plays, so each disables its Chromatic snapshot.
2568
+
2569
+ // Deterministic dataset for the test scenarios: emails and statuses sort into a
2570
+ // predictable order so the plays can assert row ordering without flakiness.
2571
+ const a11yTestData: Payment[] = [
2572
+ { id: '1', amount: 300, status: 'success', email: 'charlie@example.com' },
2573
+ { id: '2', amount: 100, status: 'processing', email: 'alice@example.com' },
2574
+ { id: '3', amount: 200, status: 'failed', email: 'bob@example.com' },
2575
+ ];
2576
+
2577
+ /**
2578
+ * Accessibility guidance for data tables: descriptive headers, labelled sort
2579
+ * controls and selection checkboxes, and sufficient contrast.
2580
+ */
2581
+ export const Accessibility: Story = {
2582
+ tags: ['!autodocs'],
2583
+ parameters: {
2584
+ a11y: { test: 'off' },
2585
+ chromatic: { disableSnapshot: true },
2586
+ docs: {
2587
+ canvas: {
2588
+ sourceState: 'none',
2589
+ },
2590
+ },
2591
+ },
2592
+ render: () => ({
2593
+ components: { UiDataTable },
2594
+ setup() {
2595
+ return { columns: basicColumns, data: a11yTestData };
2596
+ },
2597
+ template: `
2598
+ <section class="flex flex-col gap-6 p-4">
2599
+ <div>
2600
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
2601
+ Accessibility
2602
+ </h2>
2603
+ </div>
2604
+
2605
+ <div class="flex flex-col gap-6">
2606
+ <div class="flex flex-col gap-2">
2607
+ <h3 class="body-16-medium text-content-on-surface-primary">
2608
+ Give every column a clear, unique header
2609
+ </h3>
2610
+ <p class="body-16-regular text-content-on-surface-primary">
2611
+ Column headers are exposed as <code>columnheader</code> cells and
2612
+ become the accessible name for the data in that column. Keep them
2613
+ concise and descriptive so screen-reader users can understand the
2614
+ table when navigating cell by cell.
2615
+ </p>
2616
+ </div>
2617
+
2618
+ <div class="flex flex-col gap-2">
2619
+ <h3 class="body-16-medium text-content-on-surface-primary">
2620
+ Label sort controls and selection checkboxes
2621
+ </h3>
2622
+ <p class="body-16-regular text-content-on-surface-primary">
2623
+ Sortable headers use <code>UiDataTableColumnHeader</code>, whose
2624
+ button announces the column and its current sort state (for
2625
+ example, "Status, sorted ascending"). Selection checkboxes need a
2626
+ per-row <code>aria-label</code> such as "Select row" so their
2627
+ purpose is clear out of context.
2628
+ </p>
2629
+ </div>
2630
+
2631
+ <div class="flex flex-col gap-2">
2632
+ <h3 class="body-16-medium text-content-on-surface-primary">
2633
+ Expandable rows
2634
+ </h3>
2635
+ <p class="body-16-regular text-content-on-surface-primary">
2636
+ Give the expand toggle a real button with an
2637
+ <code>aria-expanded</code> state and a label that reflects the
2638
+ action ("Expand row" / "Collapse row"). The expanded content is
2639
+ rendered in its own table row rather than overlaid, so the table
2640
+ structure stays valid for browsers and screen readers.
2641
+ </p>
2642
+ </div>
2643
+
2644
+ <div class="flex flex-col gap-2">
2645
+ <h3 class="body-16-medium text-content-on-surface-primary">
2646
+ Column visibility checklist
2647
+ </h3>
2648
+ <p class="body-16-regular text-content-on-surface-primary">
2649
+ The column menu exposes each column as a checkable menu item so
2650
+ assistive tech announces its checked state and lets users toggle
2651
+ columns from the keyboard. Give the trigger a clear accessible
2652
+ label such as "Toggle columns" since its icon alone is not
2653
+ self-explanatory.
2654
+ </p>
2655
+ </div>
2656
+
2657
+ <div class="flex flex-col gap-2">
2658
+ <h3 class="body-16-medium text-content-on-surface-primary">
2659
+ Row actions and filter menus
2660
+ </h3>
2661
+ <p class="body-16-regular text-content-on-surface-primary">
2662
+ Row action and filter popovers are menus: the trigger needs an
2663
+ accessible name (for example "Open menu" or "Toggle Filters"),
2664
+ opens on Enter/Space, and its items are reachable with the arrow
2665
+ keys and dismissed with Escape. Keep filter fields inside the
2666
+ popover individually labelled so each control makes sense on its
2667
+ own.
2668
+ </p>
2669
+ </div>
2670
+
2671
+ <div class="flex flex-col gap-2">
2672
+ <h3 class="body-16-medium text-content-on-surface-primary">
2673
+ Draggable columns
2674
+ </h3>
2675
+ <p class="body-16-regular text-content-on-surface-primary">
2676
+ Reordering must not rely on a pointer alone. A draggable header is
2677
+ focusable and can be moved with the Arrow Left / Arrow Right keys,
2678
+ and a focus indicator marks the column being moved so keyboard and
2679
+ low-vision users can follow the change.
2680
+ </p>
2681
+ </div>
2682
+
2683
+ <div class="flex flex-col gap-2">
2684
+ <h3 class="body-16-medium text-content-on-surface-primary">
2685
+ Clickable rows and pagination
2686
+ </h3>
2687
+ <p class="body-16-regular text-content-on-surface-primary">
2688
+ When rows are clickable, keep the real action on a focusable
2689
+ control inside the row so it is keyboard operable, and let clicks
2690
+ on nested buttons, links, or checkboxes take priority over the row
2691
+ handler. Pagination controls carry descriptive labels ("Go to
2692
+ next page") and announce the current page and selection count.
2693
+ </p>
2694
+ </div>
2695
+
2696
+ <div class="flex flex-col gap-2">
2697
+ <h3 class="body-16-medium text-content-on-surface-primary">
2698
+ Enable the accessibility theme
2699
+ </h3>
2700
+ <p class="body-16-regular text-content-on-surface-primary">
2701
+ When accessibility is required, enable our accessibility theme. It
2702
+ increases contrast so table text and controls meet color-contrast
2703
+ requirements.
2704
+ </p>
2705
+ </div>
2706
+ </div>
2707
+
2708
+ <div class="grid gap-4 md:grid-cols-2">
2709
+ <div class="flex flex-col gap-3">
2710
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
2711
+ Default
2712
+ </h3>
2713
+ <div class="border border-border-surface-default p-4">
2714
+ <UiDataTable :columns="columns" :data="data" />
2715
+ </div>
2716
+ </div>
2717
+
2718
+ <div class="accessible-theme flex flex-col gap-3">
2719
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
2720
+ Accessible
2721
+ </h3>
2722
+ <div class="border border-border-surface-default p-4">
2723
+ <UiDataTable :columns="columns" :data="data" />
2724
+ </div>
2725
+ </div>
2726
+ </div>
2727
+ </section>
2728
+ `,
2729
+ }),
2730
+ };
2731
+
2732
+ /**
2733
+ * The data table is fully keyboard operable: sortable headers are reachable
2734
+ * with `Tab` and cycle their sort direction with `Enter`.
2735
+ */
2736
+ export const KeyboardNavigation: Story = {
2737
+ name: 'test - Keyboard Navigation',
2738
+ tags: ['!dev', '!autodocs'],
2739
+ parameters: {
2740
+ // Focus and sort state change during the play; skip the visual snapshot.
2741
+ chromatic: { disableSnapshot: true },
2742
+ docs: {
2743
+ description: {
2744
+ story:
2745
+ 'Press `Tab` to focus a sortable column header, then `Enter` to cycle its sort direction.',
2746
+ },
2747
+ },
2748
+ },
2749
+ render: () => ({
2750
+ components: { UiDataTable },
2751
+ setup() {
2752
+ return { columns: sortableColumns, data: a11yTestData };
2753
+ },
2754
+ template: `<UiDataTable :columns="columns" :data="data" />`,
2755
+ }),
2756
+ play: async ({ canvasElement, step }) => {
2757
+ // Scenario (UiDataTable): a keyboard user Tabs to a sortable column header
2758
+ // and cycles its sort direction with Enter — ascending, descending, then
2759
+ // cleared — reordering the rows on each activation.
2760
+ const canvas = within(canvasElement);
2761
+ const statusSort = canvas.getByRole('button', { name: /^Status/ });
2762
+ const firstCell = () => canvas.getAllByRole('cell')[0];
2763
+
2764
+ await step(
2765
+ 'keyboard: the first sortable header is reachable via Tab (WCAG 2.1.1 Keyboard)',
2766
+ async () => {
2767
+ await userEvent.tab();
2768
+ await expect(statusSort).toHaveFocus();
2769
+ },
2770
+ );
2771
+
2772
+ await step('interaction: Enter sorts the column ascending', async () => {
2773
+ await userEvent.keyboard('{Enter}');
2774
+ await expect(statusSort).toHaveAccessibleName('Status, sorted ascending');
2775
+ await expect(firstCell()).toHaveTextContent('failed');
2776
+ });
2777
+
2778
+ await step(
2779
+ 'keyboard: Enter again toggles to descending (WCAG 2.1.1)',
2780
+ async () => {
2781
+ await userEvent.keyboard('{Enter}');
2782
+ await expect(statusSort).toHaveAccessibleName(
2783
+ 'Status, sorted descending',
2784
+ );
2785
+ await expect(firstCell()).toHaveTextContent('success');
2786
+ },
2787
+ );
2788
+
2789
+ await step('interaction: a third activation clears the sort', async () => {
2790
+ await userEvent.keyboard('{Enter}');
2791
+ await expect(statusSort).toHaveAccessibleName('Status, click to sort');
2792
+ });
2793
+ },
2794
+ };
2795
+
2796
+ /**
2797
+ * Row selection: the header checkbox toggles every row on the page and each
2798
+ * row checkbox toggles independently.
2799
+ */
2800
+ export const RowSelectionInteraction: Story = {
2801
+ name: 'test - Row Selection',
2802
+ tags: ['!dev', '!autodocs'],
2803
+ parameters: {
2804
+ // Selection state changes during the play; skip the visual snapshot.
2805
+ chromatic: { disableSnapshot: true },
2806
+ docs: {
2807
+ description: {
2808
+ story:
2809
+ 'Toggle the header checkbox to select every row, then toggle a single row checkbox.',
2810
+ },
2811
+ },
2812
+ },
2813
+ render: () => ({
2814
+ components: { UiDataTable },
2815
+ setup() {
2816
+ return { columns: selectableColumns, data: a11yTestData };
2817
+ },
2818
+ template: `<UiDataTable :columns="columns" :data="data" />`,
2819
+ }),
2820
+ play: async ({ canvasElement, step }) => {
2821
+ // Scenario (UiDataTable): row checkboxes toggle independently, a partial
2822
+ // selection is announced as mixed on the header checkbox, and the header
2823
+ // checkbox selects then clears every row on the page.
2824
+ const canvas = within(canvasElement);
2825
+ const selectAll = canvas.getByRole('checkbox', { name: 'Select all' });
2826
+ const rowCheckboxes = canvas.getAllByRole('checkbox', {
2827
+ name: 'Select row',
2828
+ });
2829
+
2830
+ await step('interaction: rows start unselected', async () => {
2831
+ await expect(selectAll).toHaveAttribute('aria-checked', 'false');
2832
+ });
2833
+
2834
+ await step('interaction: row checkboxes toggle independently', async () => {
2835
+ await userEvent.click(rowCheckboxes[0]);
2836
+ await userEvent.click(rowCheckboxes[2]);
2837
+ await expect(rowCheckboxes[0]).toHaveAttribute('aria-checked', 'true');
2838
+ await expect(rowCheckboxes[1]).toHaveAttribute('aria-checked', 'false');
2839
+ await expect(rowCheckboxes[2]).toHaveAttribute('aria-checked', 'true');
2840
+ });
2841
+
2842
+ await step(
2843
+ 'screen-reader: a partial selection is announced as mixed (WCAG 4.1.2)',
2844
+ async () => {
2845
+ await expect(selectAll).toHaveAttribute('aria-checked', 'mixed');
2846
+ },
2847
+ );
2848
+
2849
+ await step(
2850
+ 'interaction: the header checkbox selects every row',
2851
+ async () => {
2852
+ await userEvent.click(selectAll);
2853
+ for (const checkbox of rowCheckboxes) {
2854
+ await expect(checkbox).toHaveAttribute('aria-checked', 'true');
2855
+ }
2856
+ },
2857
+ );
2858
+
2859
+ await step(
2860
+ 'interaction: the header checkbox clears the selection',
2861
+ async () => {
2862
+ await userEvent.click(selectAll);
2863
+ for (const checkbox of rowCheckboxes) {
2864
+ await expect(checkbox).toHaveAttribute('aria-checked', 'false');
2865
+ }
2866
+ },
2867
+ );
2868
+ },
2869
+ };
2870
+
2871
+ /**
2872
+ * Screen-reader semantics: the table exposes column headers, sortable headers
2873
+ * announce their sort state, and selection checkboxes carry accessible names.
2874
+ */
2875
+ export const ScreenReader: Story = {
2876
+ name: 'test - Screen Reader',
2877
+ tags: ['!dev', '!autodocs'],
2878
+ parameters: {
2879
+ chromatic: { disableSnapshot: true },
2880
+ docs: {
2881
+ description: {
2882
+ story:
2883
+ 'Verifies the roles, names, and sort state that assistive technology announces.',
2884
+ },
2885
+ },
2886
+ },
2887
+ render: () => ({
2888
+ components: { UiDataTable },
2889
+ setup() {
2890
+ return { columns: selectableColumns, data: a11yTestData };
2891
+ },
2892
+ template: `<UiDataTable :columns="columns" :data="data" />`,
2893
+ }),
2894
+ play: async ({ canvasElement, step }) => {
2895
+ // Scenario (UiDataTable): assistive tech finds a table with labelled column
2896
+ // headers, labelled selection controls, and a sort control that announces
2897
+ // its current state.
2898
+ const canvas = within(canvasElement);
2899
+
2900
+ await step(
2901
+ 'screen-reader: exposes a table with a header for every column',
2902
+ async () => {
2903
+ await expect(canvas.getByRole('table')).toBeVisible();
2904
+ await expect(canvas.getAllByRole('columnheader')).toHaveLength(4);
2905
+ },
2906
+ );
2907
+
2908
+ await step(
2909
+ 'screen-reader: selection controls have accessible names (WCAG 4.1.2)',
2910
+ async () => {
2911
+ await expect(
2912
+ canvas.getByRole('checkbox', { name: 'Select all' }),
2913
+ ).toBeVisible();
2914
+ await expect(
2915
+ canvas.getAllByRole('checkbox', { name: 'Select row' }),
2916
+ ).toHaveLength(3);
2917
+ },
2918
+ );
2919
+
2920
+ await step(
2921
+ 'screen-reader: the sortable header announces its current sort state',
2922
+ async () => {
2923
+ const statusSort = canvas.getByRole('button', {
2924
+ name: 'Status, click to sort',
2925
+ });
2926
+ await expect(statusSort).toHaveAccessibleName('Status, click to sort');
2927
+ },
2928
+ );
2929
+ },
2930
+ };
2931
+
2932
+ /**
2933
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
2934
+ * try 400% reflow (WCAG 1.4.10); the table must stay visible and operable.
2935
+ */
2936
+ export const ZoomMagnification: Story = {
2937
+ name: 'test - Zoom Magnification',
2938
+ tags: ['!dev', '!autodocs'],
2939
+ globals: { zoom: '200' },
2940
+ parameters: {
2941
+ // The accessible-reflow Chromatic mode already covers magnified snapshots.
2942
+ chromatic: { disableSnapshot: true },
2943
+ docs: {
2944
+ description: {
2945
+ story:
2946
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
2947
+ },
2948
+ },
2949
+ },
2950
+ render: () => ({
2951
+ components: { UiDataTable },
2952
+ setup() {
2953
+ return { columns: sortableColumns, data: a11yTestData };
2954
+ },
2955
+ template: `<UiDataTable :columns="columns" :data="data" />`,
2956
+ }),
2957
+ play: async ({ canvasElement, step }) => {
2958
+ // Scenario (UiDataTable): at 200% page zoom the table stays visible and its
2959
+ // sort controls remain operable.
2960
+ const canvas = within(canvasElement);
2961
+
2962
+ await step(
2963
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
2964
+ async () => {
2965
+ await expect(document.documentElement.style.zoom).toBe('200%');
2966
+ },
2967
+ );
2968
+
2969
+ await step('zoom: the table stays visible when magnified', async () => {
2970
+ await expect(canvas.getByRole('table')).toBeVisible();
2971
+ });
2972
+
2973
+ await step('zoom: a sortable header remains operable', async () => {
2974
+ const statusSort = canvas.getByRole('button', { name: /^Status/ });
2975
+ await userEvent.click(statusSort);
2976
+ await expect(statusSort).toHaveAccessibleName('Status, sorted ascending');
2977
+ });
2978
+ },
2979
+ };
2980
+
2981
+ /**
2982
+ * Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
2983
+ * toolbar. The table stays operable and its controls stay keyboard focusable.
2984
+ */
2985
+ export const MobileBreakpoint: Story = {
2986
+ name: 'test - Mobile Breakpoint',
2987
+ tags: ['!dev', '!autodocs'],
2988
+ globals: { mediaBreakpoint: 'reflow' },
2989
+ parameters: {
2990
+ // Reflow snapshots are already covered by the accessible-reflow mode.
2991
+ chromatic: { disableSnapshot: true },
2992
+ docs: {
2993
+ description: {
2994
+ story:
2995
+ 'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
2996
+ },
2997
+ },
2998
+ },
2999
+ render: () => ({
3000
+ components: { UiDataTable },
3001
+ setup() {
3002
+ return { columns: sortableColumns, data: a11yTestData };
3003
+ },
3004
+ template: `<UiDataTable :columns="columns" :data="data" />`,
3005
+ }),
3006
+ play: async ({ canvasElement, step }) => {
3007
+ // Scenario (UiDataTable): at the 320px mobile breakpoint the table reflows
3008
+ // while staying operable by pointer and keyboard.
3009
+ const canvas = within(canvasElement);
3010
+
3011
+ await step(
3012
+ 'mobile: the table renders and stays operable at the 320px breakpoint (WCAG 1.4.10 Reflow)',
3013
+ async () => {
3014
+ await expect(canvas.getByRole('table')).toBeVisible();
3015
+ const statusSort = canvas.getByRole('button', { name: /^Status/ });
3016
+ await userEvent.click(statusSort);
3017
+ await expect(statusSort).toHaveAccessibleName(
3018
+ 'Status, sorted ascending',
3019
+ );
3020
+ },
3021
+ );
3022
+
3023
+ await step(
3024
+ 'mobile: sortable headers stay keyboard focusable when reflowed',
3025
+ async () => {
3026
+ const emailSort = canvas.getByRole('button', { name: /^Email/ });
3027
+ emailSort.focus();
3028
+ await expect(emailSort).toHaveFocus();
3029
+ },
3030
+ );
3031
+ },
3032
+ };
@@ -62,7 +62,7 @@ const triggerAriaLabel = computed(() =>
62
62
  left-icon="list-filter"
63
63
  :aria-label="triggerAriaLabel"
64
64
  >
65
- <span class="inline-flex items-center gap-xs">
65
+ <span class="inline-flex items-center gap-2">
66
66
  {{ labels.filters }}
67
67
  <UiBadge
68
68
  v-if="hasActiveFilters"