@aleph-alpha/ui-library 5.1.0 → 5.3.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 (29) hide show
  1. package/README.md +2 -0
  2. package/dist/system/components/core/sidebar/SidebarInset.vue.d.ts +14 -1
  3. package/dist/system/index.d.ts +1 -0
  4. package/dist/system/lib/useAnchorFloat.d.ts +143 -0
  5. package/dist/system/lib.js +19421 -18919
  6. package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +35 -0
  7. package/dist/system/patterns/UiFloatActions/UiFloatActions.vue.d.ts +43 -0
  8. package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +16 -0
  9. package/dist/system/patterns/UiFloatActions/index.d.ts +3 -0
  10. package/dist/system/patterns/UiFloatActions/types.d.ts +127 -0
  11. package/dist/system/patterns/index.d.ts +1 -0
  12. package/package.json +12 -3
  13. package/src/components/UiButton/UiButton.stories.ts +526 -38
  14. package/src/components/core/sidebar/SidebarInset.vue +19 -2
  15. package/src/index.ts +1 -0
  16. package/src/lib/useAnchorFloat.test.ts +166 -0
  17. package/src/lib/useAnchorFloat.ts +437 -0
  18. package/src/patterns/UiFloatActions/UiFloatActionItems.vue +321 -0
  19. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +767 -0
  20. package/src/patterns/UiFloatActions/UiFloatActions.vue +220 -0
  21. package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +104 -0
  22. package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +152 -0
  23. package/src/patterns/UiFloatActions/__tests__/UiFloatActions.test.ts +86 -0
  24. package/src/patterns/UiFloatActions/floatActionItemContext.ts +20 -0
  25. package/src/patterns/UiFloatActions/index.ts +3 -0
  26. package/src/patterns/UiFloatActions/types.ts +155 -0
  27. package/src/patterns/UiSidebar/UiSidebarInset.stories.ts +259 -0
  28. package/src/patterns/UiSidebar/__tests__/UiSidebarInset.test.ts +20 -0
  29. package/src/patterns/index.ts +1 -0
@@ -1,4 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { expect, fn, userEvent, within } from 'storybook/test';
3
+ import { ref } from 'vue';
2
4
  import UiButton from './UiButton.vue';
3
5
  import { UiIcon } from '../UiIcon';
4
6
 
@@ -17,6 +19,11 @@ const MailIcon = {
17
19
  template: '<UiIcon name="mail" :size="16" />',
18
20
  };
19
21
 
22
+ // `UiButton` emits a native click (it declares no `onClick` prop), so play
23
+ // functions assert against this module-level spy bound via `@click` rather
24
+ // than through `args`. Each `play` clears it first, so the shared spy is safe.
25
+ const onClick = fn();
26
+
20
27
  /**
21
28
  * Buttons are used to initiate actions within an application. Their labels clearly describe the action they trigger.
22
29
  */
@@ -81,6 +88,12 @@ export default meta;
81
88
 
82
89
  type Story = StoryObj<typeof UiButton>;
83
90
 
91
+ // Test-only stories drive the test-runner (interactive/a11y checks) but are
92
+ // hidden from the Storybook sidebar and docs via the `!dev` / `!autodocs`
93
+ // tags. They keep the implicit `test` tag, so they still run in CI and appear
94
+ // in the automated report under their `test - …` name. `name`/`tags` must be
95
+ // literal properties so Storybook's static CSF indexer can read them.
96
+
84
97
  const defaultTemplateSource = `<script setup lang="ts">
85
98
  import { UiButton } from '@aleph-alpha/ui-library'
86
99
  </script>
@@ -291,6 +304,386 @@ export const Accessibility: Story = {
291
304
  },
292
305
  };
293
306
 
307
+ const keyboardNavigationTemplateSource = `<script setup lang="ts">
308
+ import { UiButton } from '@aleph-alpha/ui-library'
309
+
310
+ function handleSubmit() {
311
+ // …
312
+ }
313
+ </script>
314
+
315
+ <template>
316
+ <UiButton @click="handleSubmit">Submit</UiButton>
317
+ </template>`;
318
+
319
+ /**
320
+ * `UiButton` is fully keyboard operable: it focuses with `Tab` and activates
321
+ * with `Enter`, `Space`, and pointer clicks.
322
+ */
323
+ export const KeyboardNavigation: Story = {
324
+ name: 'test - Keyboard Navigation',
325
+ tags: ['!dev', '!autodocs'],
326
+ render: () => ({
327
+ components: { UiButton },
328
+ setup() {
329
+ return { onClick };
330
+ },
331
+ template: `<UiButton @click="onClick">Submit</UiButton>`,
332
+ }),
333
+ parameters: {
334
+ // Focus moves during the play function; skip the visual snapshot so the
335
+ // focus ring doesn't register as a Chromatic diff.
336
+ chromatic: { disableSnapshot: true },
337
+ docs: {
338
+ description: {
339
+ story:
340
+ 'Press `Tab` to focus the button, then `Enter` or `Space` to activate it.',
341
+ },
342
+ source: {
343
+ code: keyboardNavigationTemplateSource,
344
+ },
345
+ },
346
+ },
347
+ play: async ({ canvasElement, step }) => {
348
+ // Scenario: a keyboard user tabs to the button and activates it with Enter,
349
+ // Space, and a pointer click.
350
+ const canvas = within(canvasElement);
351
+ const button = canvas.getByRole('button', { name: 'Submit' });
352
+
353
+ await step(
354
+ 'interaction: exposes a button role with an accessible name',
355
+ async () => {
356
+ await expect(button).toHaveAccessibleName('Submit');
357
+ },
358
+ );
359
+
360
+ await step(
361
+ 'keyboard: reachable via Tab (WCAG 2.1.1 Keyboard)',
362
+ async () => {
363
+ onClick.mockClear();
364
+ await userEvent.tab();
365
+ await expect(button).toHaveFocus();
366
+ },
367
+ );
368
+
369
+ await step('interaction: activates with Enter', async () => {
370
+ await userEvent.keyboard('{Enter}');
371
+ await expect(onClick).toHaveBeenCalledTimes(1);
372
+ });
373
+
374
+ await step('interaction: activates with Space', async () => {
375
+ await userEvent.keyboard(' ');
376
+ await expect(onClick).toHaveBeenCalledTimes(2);
377
+ });
378
+
379
+ await step('interaction: activates on pointer click', async () => {
380
+ onClick.mockClear();
381
+ await userEvent.click(button);
382
+ await expect(onClick).toHaveBeenCalledTimes(1);
383
+ });
384
+ },
385
+ };
386
+
387
+ const keyboardGroupTemplateSource = `<script setup lang="ts">
388
+ import { UiButton } from '@aleph-alpha/ui-library'
389
+ </script>
390
+
391
+ <template>
392
+ <div role="group" aria-label="Playback controls" class="flex gap-2">
393
+ <UiButton variant="outline">Previous</UiButton>
394
+ <UiButton>Play</UiButton>
395
+ <UiButton variant="outline">Next</UiButton>
396
+ </div>
397
+ </template>`;
398
+
399
+ /**
400
+ * A toolbar-style group of buttons: Tab moves focus between each control in DOM
401
+ * order and Space activates the focused one (WCAG 2.1.1, 2.4.3).
402
+ */
403
+ export const KeyboardGroupNavigation: Story = {
404
+ name: 'test - Keyboard Group Navigation',
405
+ tags: ['!dev', '!autodocs'],
406
+ parameters: {
407
+ // Focus moves during the play function; skip the visual snapshot.
408
+ chromatic: { disableSnapshot: true },
409
+ docs: {
410
+ description: {
411
+ story:
412
+ 'Tab between the buttons, then press Space to activate the focused one.',
413
+ },
414
+ source: {
415
+ code: keyboardGroupTemplateSource,
416
+ },
417
+ },
418
+ },
419
+ render: () => ({
420
+ components: { UiButton },
421
+ setup() {
422
+ return { onClick };
423
+ },
424
+ template: `
425
+ <div role="group" aria-label="Playback controls" class="flex gap-2">
426
+ <UiButton variant="outline" @click="onClick">Previous</UiButton>
427
+ <UiButton @click="onClick">Play</UiButton>
428
+ <UiButton variant="outline" @click="onClick">Next</UiButton>
429
+ </div>
430
+ `,
431
+ }),
432
+ play: async ({ canvasElement, step }) => {
433
+ // Scenario: a keyboard user tabs across the button group in DOM order and
434
+ // activates the focused control with Space.
435
+ onClick.mockClear();
436
+ const canvas = within(canvasElement);
437
+ const previous = canvas.getByRole('button', { name: 'Previous' });
438
+ const play = canvas.getByRole('button', { name: 'Play' });
439
+ const next = canvas.getByRole('button', { name: 'Next' });
440
+
441
+ await step(
442
+ 'keyboard: Tab enters the group and focuses the first control',
443
+ async () => {
444
+ await userEvent.tab();
445
+ await expect(previous).toHaveFocus();
446
+ },
447
+ );
448
+
449
+ await step(
450
+ 'keyboard: Tab moves focus through the group in order (WCAG 2.4.3)',
451
+ async () => {
452
+ await userEvent.tab();
453
+ await expect(play).toHaveFocus();
454
+ await userEvent.tab();
455
+ await expect(next).toHaveFocus();
456
+ },
457
+ );
458
+
459
+ await step(
460
+ 'keyboard: Space activates the focused control (WCAG 2.1.1)',
461
+ async () => {
462
+ await userEvent.keyboard(' ');
463
+ await expect(onClick).toHaveBeenCalledTimes(1);
464
+ },
465
+ );
466
+ },
467
+ };
468
+
469
+ const zoomMagnificationTemplateSource = `<script setup lang="ts">
470
+ import { UiButton } from '@aleph-alpha/ui-library'
471
+ </script>
472
+
473
+ <template>
474
+ <UiButton>Save changes</UiButton>
475
+ </template>`;
476
+
477
+ /**
478
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
479
+ * try 400% reflow (WCAG 1.4.10); content must stay visible and operable.
480
+ */
481
+ export const ZoomMagnification: Story = {
482
+ name: 'test - Zoom Magnification',
483
+ tags: ['!dev', '!autodocs'],
484
+ globals: { zoom: '200' },
485
+ parameters: {
486
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
487
+ // already covers magnified snapshots, so skip this one.
488
+ chromatic: { disableSnapshot: true },
489
+ docs: {
490
+ description: {
491
+ story:
492
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
493
+ },
494
+ source: {
495
+ code: zoomMagnificationTemplateSource,
496
+ },
497
+ },
498
+ },
499
+ render: () => ({
500
+ components: { UiButton },
501
+ setup() {
502
+ return { onClick };
503
+ },
504
+ template: `<UiButton @click="onClick">Save changes</UiButton>`,
505
+ }),
506
+ play: async ({ canvasElement, step }) => {
507
+ // Scenario: at 200% page zoom the button stays visible, keeps its
508
+ // accessible name, and remains clickable.
509
+ onClick.mockClear();
510
+ const canvas = within(canvasElement);
511
+ const button = canvas.getByRole('button', { name: 'Save changes' });
512
+
513
+ await step(
514
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
515
+ async () => {
516
+ await expect(document.documentElement.style.zoom).toBe('200%');
517
+ },
518
+ );
519
+
520
+ await step(
521
+ 'zoom: button stays visible with its accessible name',
522
+ async () => {
523
+ await expect(button).toBeVisible();
524
+ await expect(button).toHaveAccessibleName('Save changes');
525
+ },
526
+ );
527
+
528
+ await step('zoom: remains operable when magnified', async () => {
529
+ await userEvent.click(button);
530
+ await expect(onClick).toHaveBeenCalledTimes(1);
531
+ });
532
+ },
533
+ };
534
+
535
+ const screenReaderTemplateSource = `<script setup lang="ts">
536
+ import { ref } from 'vue'
537
+ import { UiButton, UiIcon } from '@aleph-alpha/ui-library'
538
+
539
+ const muted = ref(false)
540
+ </script>
541
+
542
+ <template>
543
+ <div class="flex gap-2">
544
+ <UiButton aria-label="Search" size="icon-sm">
545
+ <UiIcon name="chevron-right" :size="16" />
546
+ </UiButton>
547
+ <UiButton :aria-pressed="muted ? 'true' : 'false'" @click="muted = !muted">
548
+ Mute
549
+ </UiButton>
550
+ </div>
551
+ </template>`;
552
+
553
+ /**
554
+ * Screen-reader semantics: every control exposes a role and name, icon-only
555
+ * buttons carry a non-visual label, and toggle state is announced via
556
+ * aria-pressed (WCAG 4.1.2).
557
+ */
558
+ export const ScreenReader: Story = {
559
+ name: 'test - Screen Reader',
560
+ tags: ['!dev', '!autodocs'],
561
+ parameters: {
562
+ // The toggle changes aria-pressed during the play function.
563
+ chromatic: { disableSnapshot: true },
564
+ docs: {
565
+ description: {
566
+ story:
567
+ 'Verifies the roles, names, and state that assistive technology announces.',
568
+ },
569
+ source: {
570
+ code: screenReaderTemplateSource,
571
+ },
572
+ },
573
+ },
574
+ render: () => ({
575
+ components: { UiButton, UiIcon },
576
+ setup() {
577
+ const muted = ref(false);
578
+ const toggle = () => {
579
+ muted.value = !muted.value;
580
+ };
581
+ return { muted, toggle };
582
+ },
583
+ template: `
584
+ <div class="flex gap-2">
585
+ <UiButton aria-label="Search" size="icon-sm">
586
+ <UiIcon name="chevron-right" :size="16" />
587
+ </UiButton>
588
+ <UiButton :aria-pressed="muted ? 'true' : 'false'" @click="toggle">Mute</UiButton>
589
+ </div>
590
+ `,
591
+ }),
592
+ play: async ({ canvasElement, step }) => {
593
+ // Scenario: assistive tech reads each control's role and name, and hears the
594
+ // toggle's pressed state change via aria-pressed.
595
+ const canvas = within(canvasElement);
596
+ const toggle = canvas.getByRole('button', { name: 'Mute' });
597
+
598
+ await step(
599
+ 'screen-reader: exposes a button role with an accessible name',
600
+ async () => {
601
+ await expect(toggle).toHaveAccessibleName('Mute');
602
+ },
603
+ );
604
+
605
+ await step(
606
+ 'screen-reader: icon-only control is labelled via aria-label',
607
+ async () => {
608
+ const iconButton = canvas.getByRole('button', { name: 'Search' });
609
+ await expect(iconButton).toHaveAccessibleName('Search');
610
+ },
611
+ );
612
+
613
+ await step(
614
+ 'screen-reader: toggle state is announced via aria-pressed (WCAG 4.1.2)',
615
+ async () => {
616
+ await expect(toggle).toHaveAttribute('aria-pressed', 'false');
617
+ await userEvent.click(toggle);
618
+ await expect(toggle).toHaveAttribute('aria-pressed', 'true');
619
+ },
620
+ );
621
+ },
622
+ };
623
+
624
+ const mobileBreakpointTemplateSource = `<script setup lang="ts">
625
+ import { UiButton } from '@aleph-alpha/ui-library'
626
+ </script>
627
+
628
+ <template>
629
+ <UiButton>Continue</UiButton>
630
+ </template>`;
631
+
632
+ /**
633
+ * Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
634
+ * toolbar. Stays operable and meets the minimum touch-target size (WCAG 2.5.8).
635
+ */
636
+ export const MobileBreakpoint: Story = {
637
+ name: 'test - Mobile Breakpoint',
638
+ tags: ['!dev', '!autodocs'],
639
+ globals: { mediaBreakpoint: 'reflow' },
640
+ parameters: {
641
+ // Reflow snapshots are already covered by the accessible-reflow mode.
642
+ chromatic: { disableSnapshot: true },
643
+ docs: {
644
+ description: {
645
+ story:
646
+ 'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
647
+ },
648
+ source: {
649
+ code: mobileBreakpointTemplateSource,
650
+ },
651
+ },
652
+ },
653
+ render: () => ({
654
+ components: { UiButton },
655
+ setup() {
656
+ return { onClick };
657
+ },
658
+ template: `<UiButton @click="onClick">Continue</UiButton>`,
659
+ }),
660
+ play: async ({ canvasElement, step }) => {
661
+ // Scenario: at the 320px mobile breakpoint the button stays operable and
662
+ // meets the minimum touch-target size.
663
+ onClick.mockClear();
664
+ const canvas = within(canvasElement);
665
+ const button = canvas.getByRole('button', { name: 'Continue' });
666
+
667
+ await step(
668
+ 'mobile: renders and stays operable at the 320px breakpoint',
669
+ async () => {
670
+ await expect(button).toBeVisible();
671
+ await userEvent.click(button);
672
+ await expect(onClick).toHaveBeenCalledTimes(1);
673
+ },
674
+ );
675
+
676
+ await step(
677
+ 'mobile: meets the minimum touch-target size (WCAG 2.5.8)',
678
+ async () => {
679
+ const { width, height } = button.getBoundingClientRect();
680
+ await expect(width).toBeGreaterThanOrEqual(24);
681
+ await expect(height).toBeGreaterThanOrEqual(24);
682
+ },
683
+ );
684
+ },
685
+ };
686
+
294
687
  const outlineTemplateSource = `<script setup lang="ts">
295
688
  import { UiButton } from '@aleph-alpha/ui-library'
296
689
  </script>
@@ -508,7 +901,7 @@ export const IconUsage: Story = {
508
901
  render: () => ({
509
902
  components: { UiButton, UiIcon },
510
903
  setup() {
511
- return { ChevronLeftIcon, ChevronRightIcon };
904
+ return { ChevronLeftIcon, ChevronRightIcon, onClick };
512
905
  },
513
906
  template: `
514
907
  <section class="flex flex-col gap-6 rounded-lg bg-background-surface-primary p-4">
@@ -541,7 +934,7 @@ export const IconUsage: Story = {
541
934
  <div class="flex flex-col gap-3">
542
935
  <h3 class="label-14-medium text-center text-content-on-surface-primary">Icon only</h3>
543
936
  <div class="flex min-h-20 items-center justify-center rounded-sm bg-background-surface-muted-subtle p-6">
544
- <UiButton size="icon-sm" aria-label="Go back">
937
+ <UiButton size="icon-sm" aria-label="Go back" @click="onClick">
545
938
  <UiIcon name="chevron-left" :size="16" />
546
939
  </UiButton>
547
940
  </div>
@@ -557,6 +950,25 @@ export const IconUsage: Story = {
557
950
  },
558
951
  },
559
952
  },
953
+ play: async ({ canvasElement, step }) => {
954
+ // Scenario: an icon-only button exposes an accessible name via aria-label
955
+ // and still responds to clicks.
956
+ onClick.mockClear();
957
+ const canvas = within(canvasElement);
958
+ const button = canvas.getByRole('button', { name: 'Go back' });
959
+
960
+ await step(
961
+ 'interaction: icon-only button exposes an accessible name via aria-label (WCAG 1.1.1 / 4.1.2)',
962
+ async () => {
963
+ await expect(button).toHaveAccessibleName('Go back');
964
+ },
965
+ );
966
+
967
+ await step('interaction: remains an operable button on click', async () => {
968
+ await userEvent.click(button);
969
+ await expect(onClick).toHaveBeenCalledTimes(1);
970
+ });
971
+ },
560
972
  };
561
973
 
562
974
  const loadingTemplateSource = `<script setup lang="ts">
@@ -579,9 +991,9 @@ export const Loading: Story = {
579
991
  render: () => ({
580
992
  components: { UiButton },
581
993
  setup() {
582
- return { MailIcon };
994
+ return { MailIcon, onClick };
583
995
  },
584
- template: `<UiButton :loading="true" :start-icon="MailIcon">Please wait</UiButton>`,
996
+ template: `<UiButton :loading="true" :start-icon="MailIcon" @click="onClick">Please wait</UiButton>`,
585
997
  }),
586
998
  parameters: {
587
999
  docs: {
@@ -590,6 +1002,39 @@ export const Loading: Story = {
590
1002
  },
591
1003
  },
592
1004
  },
1005
+ play: async ({ canvasElement, step }) => {
1006
+ // Scenario: while loading, the button announces aria-busy, shows a labelled
1007
+ // spinner, drops out of the tab order, and ignores forced clicks.
1008
+ onClick.mockClear();
1009
+ const canvas = within(canvasElement);
1010
+ const button = canvas.getByRole('button');
1011
+
1012
+ await step(
1013
+ 'interaction: announces the busy state via aria-busy',
1014
+ async () => {
1015
+ await expect(button).toHaveAttribute('aria-busy', 'true');
1016
+ },
1017
+ );
1018
+
1019
+ await step('interaction: spinner exposes an accessible name', async () => {
1020
+ await expect(canvas.getByLabelText('Loading')).toBeInTheDocument();
1021
+ });
1022
+
1023
+ await step(
1024
+ 'interaction: stays disabled and out of the tab order (WCAG 4.1.2)',
1025
+ async () => {
1026
+ await expect(button).toBeDisabled();
1027
+ await expect(button).not.toHaveFocus();
1028
+ await userEvent.tab();
1029
+ await expect(button).not.toHaveFocus();
1030
+ },
1031
+ );
1032
+
1033
+ await step('interaction: ignores forced clicks while loading', async () => {
1034
+ await userEvent.click(button, { pointerEventsCheck: 0 });
1035
+ await expect(onClick).not.toHaveBeenCalled();
1036
+ });
1037
+ },
593
1038
  };
594
1039
 
595
1040
  const loadingWithBothIconsTemplateSource = `<script setup lang="ts">
@@ -662,6 +1107,33 @@ export const AsChild: Story = {
662
1107
  },
663
1108
  },
664
1109
  },
1110
+ play: async ({ canvasElement, step }) => {
1111
+ // Scenario: rendered as a link via asChild, it exposes the link role and
1112
+ // href and does not expose a redundant button role.
1113
+ const canvas = within(canvasElement);
1114
+ const link = canvas.getByRole('link', { name: 'Login' });
1115
+
1116
+ await step(
1117
+ 'interaction: exposes a link role with the child accessible name (WCAG 4.1.2)',
1118
+ async () => {
1119
+ await expect(link).toHaveAccessibleName('Login');
1120
+ },
1121
+ );
1122
+
1123
+ await step(
1124
+ 'interaction: preserves the link destination (href)',
1125
+ async () => {
1126
+ await expect(link).toHaveAttribute('href', '/login');
1127
+ },
1128
+ );
1129
+
1130
+ await step(
1131
+ 'interaction: does not expose a redundant button role',
1132
+ async () => {
1133
+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();
1134
+ },
1135
+ );
1136
+ },
665
1137
  };
666
1138
 
667
1139
  const allVariantsTemplateSource = `<script setup lang="ts">
@@ -705,50 +1177,39 @@ export const AllVariants: Story = {
705
1177
  },
706
1178
  };
707
1179
 
708
- const disabledHoverBleedTemplateSource = `<script setup lang="ts">
1180
+ const disabledTemplateSource = `<script setup lang="ts">
709
1181
  import { UiButton } from '@aleph-alpha/ui-library'
710
1182
  </script>
711
1183
 
712
1184
  <template>
713
- <div class="flex flex-col gap-6">
714
- <p class="body-14-regular text-muted-foreground max-w-xl">
715
- Hover or move quickly over the disabled buttons. Any hover layer should
716
- stay within the visual button bounds.
717
- </p>
718
- <div class="w-96 border border-dashed border-border-surface-default p-6">
719
- <UiButton disabled>Disabled default</UiButton>
720
- </div>
721
- <div class="w-96 border border-dashed border-border-surface-default p-6">
722
- <UiButton variant="secondary" disabled>Disabled secondary</UiButton>
723
- </div>
724
- <div class="w-96 border border-dashed border-border-surface-default p-6">
725
- <UiButton variant="destructive" disabled>Disabled destructive</UiButton>
726
- </div>
1185
+ <div class="flex flex-wrap gap-2">
1186
+ <UiButton disabled>Default</UiButton>
1187
+ <UiButton variant="secondary" disabled>Secondary</UiButton>
1188
+ <UiButton variant="destructive" disabled>Destructive</UiButton>
1189
+ <UiButton variant="outline" disabled>Outline</UiButton>
1190
+ <UiButton variant="ghost" disabled>Ghost</UiButton>
1191
+ <UiButton variant="link" disabled>Link</UiButton>
727
1192
  </div>
728
1193
  </template>`;
729
1194
 
730
1195
  /**
731
- * Reproduction story for disabled-button hover layers bleeding outside the
732
- * visual button bounds.
1196
+ * Disabled buttons across every variant. A disabled button is non-interactive:
1197
+ * it is removed from the tab order and never fires its click handler.
733
1198
  */
734
- export const DisabledHoverBleed: Story = {
1199
+ export const Disabled: Story = {
735
1200
  render: () => ({
736
1201
  components: { UiButton },
1202
+ setup() {
1203
+ return { onClick };
1204
+ },
737
1205
  template: `
738
- <div class="flex flex-col gap-6">
739
- <p class="body-14-regular text-muted-foreground max-w-xl">
740
- Hover or move quickly over the disabled buttons. Any hover layer should
741
- stay within the visual button bounds.
742
- </p>
743
- <div class="w-96 border border-dashed border-border-surface-default p-6">
744
- <UiButton disabled>Disabled default</UiButton>
745
- </div>
746
- <div class="w-96 border border-dashed border-border-surface-default p-6">
747
- <UiButton variant="secondary" disabled>Disabled secondary</UiButton>
748
- </div>
749
- <div class="w-96 border border-dashed border-border-surface-default p-6">
750
- <UiButton variant="destructive" disabled>Disabled destructive</UiButton>
751
- </div>
1206
+ <div class="flex flex-wrap gap-2">
1207
+ <UiButton disabled @click="onClick">Default</UiButton>
1208
+ <UiButton variant="secondary" disabled>Secondary</UiButton>
1209
+ <UiButton variant="destructive" disabled>Destructive</UiButton>
1210
+ <UiButton variant="outline" disabled>Outline</UiButton>
1211
+ <UiButton variant="ghost" disabled>Ghost</UiButton>
1212
+ <UiButton variant="link" disabled>Link</UiButton>
752
1213
  </div>
753
1214
  `,
754
1215
  }),
@@ -756,13 +1217,40 @@ export const DisabledHoverBleed: Story = {
756
1217
  docs: {
757
1218
  description: {
758
1219
  story:
759
- 'Use this story to reproduce hover-layer bleed on disabled buttons. The dashed containers make any misplaced absolute hover layer visible.',
1220
+ 'Disabled state shown across all variants. Disabled buttons are skipped by keyboard navigation and do not respond to clicks.',
760
1221
  },
761
1222
  source: {
762
- code: disabledHoverBleedTemplateSource,
1223
+ code: disabledTemplateSource,
763
1224
  },
764
1225
  },
765
1226
  },
1227
+ play: async ({ canvasElement, step }) => {
1228
+ // Scenario: a disabled button reports its disabled state, is skipped by Tab,
1229
+ // and ignores forced clicks.
1230
+ onClick.mockClear();
1231
+ const canvas = within(canvasElement);
1232
+ const button = canvas.getByRole('button', { name: 'Default' });
1233
+
1234
+ await step(
1235
+ 'interaction: exposes the disabled state (WCAG 4.1.2)',
1236
+ async () => {
1237
+ await expect(button).toBeDisabled();
1238
+ },
1239
+ );
1240
+
1241
+ await step(
1242
+ 'keyboard: removed from the tab order — not reachable via Tab (WCAG 2.1.1)',
1243
+ async () => {
1244
+ await userEvent.tab();
1245
+ await expect(button).not.toHaveFocus();
1246
+ },
1247
+ );
1248
+
1249
+ await step('interaction: ignores forced clicks', async () => {
1250
+ await userEvent.click(button, { pointerEventsCheck: 0 });
1251
+ await expect(onClick).not.toHaveBeenCalled();
1252
+ });
1253
+ },
766
1254
  };
767
1255
 
768
1256
  type MatrixVariant =
@@ -1,11 +1,28 @@
1
1
  <script setup lang="ts">
2
+ import type { Component } from 'vue';
2
3
  import { cn } from '@/lib/utils';
3
4
 
5
+ type Tag = keyof HTMLElementTagNameMap | (string & {}) | Component;
6
+
4
7
  defineOptions({ inheritAttrs: false });
8
+
9
+ withDefaults(
10
+ defineProps<{
11
+ /**
12
+ * The tag or component to render as the root element.
13
+ * Defaults to `main`. Use a different tag (e.g. `div` or `section`) when
14
+ * rendering multiple insets on a single page to avoid duplicate `main`
15
+ * landmarks.
16
+ */
17
+ as?: Tag;
18
+ }>(),
19
+ { as: 'main' },
20
+ );
5
21
  </script>
6
22
 
7
23
  <template>
8
- <main
24
+ <component
25
+ :is="as"
9
26
  v-bind="$attrs"
10
27
  data-slot="sidebar-inset"
11
28
  :class="
@@ -17,7 +34,7 @@ defineOptions({ inheritAttrs: false });
17
34
  "
18
35
  >
19
36
  <slot />
20
- </main>
37
+ </component>
21
38
  </template>
22
39
 
23
40
  <style scoped>