@aleph-alpha/ui-library 7.0.0 → 7.0.2

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 (118) hide show
  1. package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +1 -1
  2. package/dist/system/icons/story-sidebar-icons.json +74 -17
  3. package/dist/system/lib.js +1167 -1162
  4. package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
  5. package/dist/system/story-sidebar-icons.json +74 -17
  6. package/package.json +8 -3
  7. package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
  8. package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
  9. package/src/components/UiAlert/UiAlert.guidance.md +66 -0
  10. package/src/components/UiAlert/UiAlert.stories.ts +167 -143
  11. package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
  12. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
  13. package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
  14. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
  15. package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
  16. package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
  17. package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
  18. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
  19. package/src/components/UiBadge/UiBadge.guidance.md +65 -0
  20. package/src/components/UiBadge/UiBadge.stories.ts +325 -0
  21. package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
  22. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
  23. package/src/components/UiButton/UiButton.stories.ts +5 -2
  24. package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
  25. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
  26. package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
  27. package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
  28. package/src/components/UiCard/UiCard.guidance.md +65 -0
  29. package/src/components/UiCard/UiCard.stories.ts +393 -0
  30. package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
  31. package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
  32. package/src/components/UiChip/UiChip.guidance.md +64 -0
  33. package/src/components/UiChip/UiChip.stories.ts +162 -138
  34. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
  35. package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
  36. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
  37. package/src/components/UiDialog/UiDialog.guidance.md +66 -0
  38. package/src/components/UiDialog/UiDialog.stories.ts +90 -66
  39. package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
  40. package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
  41. package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
  42. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +332 -85
  43. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +134 -0
  44. package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +23 -2
  45. package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
  46. package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
  47. package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
  48. package/src/components/UiField/UiField.guidance.md +63 -0
  49. package/src/components/UiField/UiField.stories.ts +90 -113
  50. package/src/components/UiFileType/UiFileType.stories.ts +254 -0
  51. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
  52. package/src/components/UiIcon/UiIcon.stories.ts +256 -1
  53. package/src/components/UiInput/UiInput.guidance.md +64 -0
  54. package/src/components/UiInput/UiInput.stories.ts +132 -80
  55. package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
  56. package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
  57. package/src/components/UiItem/UiItem.guidance.md +66 -0
  58. package/src/components/UiItem/UiItem.stories.ts +81 -28
  59. package/src/components/UiKbd/UiKbd.guidance.md +65 -0
  60. package/src/components/UiKbd/UiKbd.stories.ts +373 -3
  61. package/src/components/UiLabel/UiLabel.guidance.md +65 -0
  62. package/src/components/UiLabel/UiLabel.stories.ts +163 -139
  63. package/src/components/UiListbox/UiListbox.stories.ts +197 -195
  64. package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
  65. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
  66. package/src/components/UiPopover/UiPopover.guidance.md +65 -0
  67. package/src/components/UiPopover/UiPopover.stories.ts +115 -91
  68. package/src/components/UiProgress/UiProgress.guidance.md +65 -0
  69. package/src/components/UiProgress/UiProgress.stories.ts +300 -0
  70. package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
  71. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
  72. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
  73. package/src/components/UiResizable/UiResizable.guidance.md +65 -0
  74. package/src/components/UiResizable/UiResizable.stories.ts +176 -152
  75. package/src/components/UiSelect/UiSelect.guidance.md +66 -0
  76. package/src/components/UiSelect/UiSelect.stories.ts +150 -126
  77. package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
  78. package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
  79. package/src/components/UiSheet/UiSheet.guidance.md +66 -0
  80. package/src/components/UiSheet/UiSheet.stories.ts +194 -170
  81. package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
  82. package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
  83. package/src/components/UiSlider/UiSlider.guidance.md +66 -0
  84. package/src/components/UiSlider/UiSlider.stories.ts +150 -126
  85. package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
  86. package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
  87. package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
  88. package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
  89. package/src/components/UiStepper/UiStepper.guidance.md +66 -0
  90. package/src/components/UiStepper/UiStepper.stories.ts +142 -124
  91. package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
  92. package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
  93. package/src/components/UiTable/UiTable.guidance.md +66 -0
  94. package/src/components/UiTable/UiTable.stories.ts +530 -12
  95. package/src/components/UiTabs/UiTabs.guidance.md +66 -0
  96. package/src/components/UiTabs/UiTabs.stories.ts +174 -150
  97. package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
  98. package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
  99. package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
  100. package/src/components/UiToggle/UiToggle.guidance.md +66 -0
  101. package/src/components/UiToggle/UiToggle.stories.ts +183 -159
  102. package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
  103. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
  104. package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
  105. package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
  106. package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
  107. package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
  108. package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
  109. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
  110. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
  111. package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
  112. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
  113. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
  114. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
  115. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
  116. package/src/patterns/UiPlaceholder/types.ts +1 -0
  117. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +74 -72
  118. package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
@@ -36,6 +36,16 @@ import { UiTextarea } from '../UiTextarea';
36
36
  import { UiButton } from '../UiButton';
37
37
  import { ref, watch } from 'vue';
38
38
  import { PlusIcon, TagIcon } from '@/icons/lucide';
39
+ import {
40
+ accessibilityRequirementsTemplate,
41
+ designNotesStory,
42
+ guidanceLinks,
43
+ guidanceSectionClass,
44
+ parseGuidance,
45
+ } from '../../../.storybook/guidance';
46
+ import guidanceMarkdown from './UiField.guidance.md?raw';
47
+
48
+ const guidance = parseGuidance(guidanceMarkdown);
39
49
 
40
50
  /**
41
51
  * Field composes label, description, and error messaging into a consistent form-field layout. Use it to keep spacing, typography, and validation feedback consistent across inputs.
@@ -68,6 +78,9 @@ const meta: Meta<typeof UiField> = {
68
78
  descriptionPlacement: 'under-input',
69
79
  descriptionCheckbox: false,
70
80
  },
81
+ parameters: {
82
+ docs: { links: guidanceLinks(guidance) },
83
+ },
71
84
  };
72
85
 
73
86
  export default meta;
@@ -160,110 +173,11 @@ export const Default: Story = {
160
173
  };
161
174
 
162
175
  /**
163
- * Design guidance for structuring form fields, help text, and validation feedback.
176
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
164
177
  */
165
178
  export const DesignNotes: Story = {
166
- render: () => ({
167
- template: `
168
- <section class="flex flex-col gap-8 p-4 bg-surface-secondary">
169
- <div>
170
- <h2 class="heading-m font-bold text-content-on-surface-primary">Usage</h2>
171
- <div class="body-m-regular mt-2 flex flex-col gap-4 text-content-on-surface-primary">
172
- <p>
173
- The Field component establishes a consistent structure for collecting information from users.
174
- It creates a predictable relationship between inputs, labels, help text, and validation messages,
175
- making forms easier to scan, understand, and complete.
176
- </p>
177
- <p>
178
- The component should be used whenever a user is expected to provide, select, or modify information.
179
- </p>
180
- </div>
181
- </div>
182
-
183
- <div class="grid gap-8 md:grid-cols-1">
184
- <div class="flex flex-col gap-3">
185
- <h3 class="body-m-medium text-content-on-surface-primary">Clarity first</h3>
186
- <p class="body-m-regular text-content-on-surface-primary">
187
- Users should immediately understand:
188
- </p>
189
- <ul class="body-m-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
190
- <li>What information is being requested</li>
191
- <li>Whether the field is required or optional</li>
192
- <li>How to successfully complete the field</li>
193
- <li>What needs to be corrected when errors occur</li>
194
- </ul>
195
- </div>
196
-
197
- <div class="flex flex-col gap-3">
198
- <h3 class="body-m-medium text-content-on-surface-primary">Progressive guidance</h3>
199
- <p class="body-m-regular text-content-on-surface-primary">
200
- Provide information only when it helps the user complete a task:
201
- </p>
202
- <ul class="body-m-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
203
- <li>Label explains what is needed</li>
204
- <li>Description provides additional guidance</li>
205
- <li>Error message appears only when required</li>
206
- </ul>
207
- </div>
208
-
209
- <div class="flex flex-col gap-3">
210
- <h3 class="body-m-medium text-content-on-surface-primary">Consistency</h3>
211
- <p class="body-m-regular text-content-on-surface-primary">
212
- All form controls should follow the same structure regardless of input type:
213
- </p>
214
- <ul class="body-m-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
215
- <li>Text Input</li>
216
- <li>Select</li>
217
- <li>Checkbox</li>
218
- <li>Switch</li>
219
- <li>Radio Group</li>
220
- <li>Text Area</li>
221
- <li>Slider</li>
222
- </ul>
223
- </div>
224
- </div>
225
-
226
- <div class="flex flex-col gap-4">
227
- <h2 class="heading-m font-bold text-content-on-surface-primary">Do's and Don'ts</h2>
228
- <div class="grid gap-8 md:grid-cols-2">
229
- <div class="flex flex-col gap-3">
230
- <h3 class="body-m-medium text-content-on-surface-primary">Do</h3>
231
- <ul class="body-m-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
232
- <li>Use a clear label for every field</li>
233
- <li>Provide helpful descriptions when needed</li>
234
- <li>Group related information together</li>
235
- <li>Write actionable error messages</li>
236
- <li>Use vertical layouts for complex forms</li>
237
- </ul>
238
- </div>
239
-
240
- <div class="flex flex-col gap-3">
241
- <h3 class="body-m-medium text-content-on-surface-primary">Don't</h3>
242
- <ul class="body-m-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
243
- <li>Use placeholders as labels</li>
244
- <li>Display errors before interaction</li>
245
- <li>Overload fields with excessive guidance</li>
246
- <li>Create inconsistent field layouts across screens</li>
247
- <li>Depend solely on color to indicate validation states</li>
248
- </ul>
249
- </div>
250
- </div>
251
- </div>
252
- </section>
253
- `,
254
- }),
179
+ ...designNotesStory(guidance),
255
180
  tags: ['!autodocs'],
256
- parameters: {
257
- a11y: { test: 'off' },
258
- chromatic: {
259
- disableSnapshot: true,
260
- },
261
- docs: {
262
- canvas: {
263
- sourceState: 'none',
264
- },
265
- },
266
- },
267
181
  };
268
182
 
269
183
  /**
@@ -292,7 +206,7 @@ export const Accessibility: Story = {
292
206
  };
293
207
  },
294
208
  template: `
295
- <section class="flex flex-col gap-6 p-4">
209
+ <section class="${guidanceSectionClass}">
296
210
  <div>
297
211
  <h2 class="heading-m font-bold text-content-on-surface-primary">
298
212
  Accessibility
@@ -300,17 +214,7 @@ export const Accessibility: Story = {
300
214
  </div>
301
215
 
302
216
  <div class="flex flex-col gap-6">
303
- <div class="flex flex-col gap-2">
304
- <h3 class="body-m-medium text-content-on-surface-primary">
305
- Requirements
306
- </h3>
307
- <ul class="body-m-regular list-disc pl-5 text-content-on-surface-primary">
308
- <li>Every field has a visible label</li>
309
- <li>Error states are communicated through more than color alone</li>
310
- <li>Descriptions remain readable and associated with the field</li>
311
- <li>Form sections use meaningful group labels</li>
312
- </ul>
313
- </div>
217
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
314
218
 
315
219
  <div class="flex flex-col gap-2">
316
220
  <h3 class="body-m-medium text-content-on-surface-primary">
@@ -395,6 +299,7 @@ export const Accessibility: Story = {
395
299
  }),
396
300
  tags: ['!autodocs'],
397
301
  parameters: {
302
+ surface: 'primary',
398
303
  a11y: { test: 'off' },
399
304
  chromatic: {
400
305
  disableSnapshot: true,
@@ -2993,3 +2898,75 @@ export const MobileBreakpoint: Story = {
2993
2898
  );
2994
2899
  },
2995
2900
  };
2901
+
2902
+ /**
2903
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
2904
+ * try 400% reflow (WCAG 1.4.10). Hidden test-only story.
2905
+ */
2906
+ export const ZoomMagnification: Story = {
2907
+ name: 'test - Zoom Magnification',
2908
+ tags: ['!dev', '!autodocs'],
2909
+ globals: { zoom: '200' },
2910
+ render: () => ({
2911
+ components: {
2912
+ UiField,
2913
+ UiFieldContent,
2914
+ UiFieldDescription,
2915
+ UiFieldLabel,
2916
+ UiInput,
2917
+ },
2918
+ setup() {
2919
+ const value = ref('');
2920
+ return { value };
2921
+ },
2922
+ template: `
2923
+ <UiField class="w-full max-w-sm">
2924
+ <UiFieldLabel for="zoom-field-email">Email</UiFieldLabel>
2925
+ <UiFieldContent>
2926
+ <UiInput id="zoom-field-email" v-model="value" name="email" placeholder="name@company.com" />
2927
+ <UiFieldDescription>We'll never share your email.</UiFieldDescription>
2928
+ </UiFieldContent>
2929
+ </UiField>
2930
+ `,
2931
+ }),
2932
+ parameters: {
2933
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
2934
+ // already covers magnified snapshots, so skip this one.
2935
+ chromatic: { disableSnapshot: true },
2936
+ docs: {
2937
+ description: {
2938
+ story:
2939
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
2940
+ },
2941
+ },
2942
+ },
2943
+ play: async ({ canvasElement, step }) => {
2944
+ // Scenario (UiField): at 200% page zoom the label, input and description
2945
+ // stay readable and wired together, and the input still accepts text.
2946
+ const canvas = within(canvasElement);
2947
+ const input = canvas.getByRole('textbox', { name: 'Email' });
2948
+
2949
+ await step(
2950
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
2951
+ async () => {
2952
+ await expect(document.documentElement.style.zoom).toBe('200%');
2953
+ },
2954
+ );
2955
+
2956
+ await step(
2957
+ 'zoom: label and description stay visible and associated',
2958
+ async () => {
2959
+ await expect(canvas.getByText('Email')).toBeVisible();
2960
+ await expect(
2961
+ canvas.getByText("We'll never share your email."),
2962
+ ).toBeVisible();
2963
+ await expect(input).toHaveAccessibleName('Email');
2964
+ },
2965
+ );
2966
+
2967
+ await step('zoom: typing still updates the value', async () => {
2968
+ await userEvent.type(input, 'ada@company.com');
2969
+ await expect(input).toHaveValue('ada@company.com');
2970
+ });
2971
+ },
2972
+ };
@@ -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 {
3
4
  CodeXmlIcon,
4
5
  FileIcon,
@@ -150,6 +151,256 @@ export const AllTypes: Story = {
150
151
  </div>
151
152
  `,
152
153
  }),
154
+ play: async ({ canvasElement, step }) => {
155
+ // Scenario (UiFileType): each extension picks its preset tone, unknown
156
+ // extensions fall back to default, and the error state is always neutral.
157
+ const badges = getBadges(canvasElement);
158
+
159
+ await step(
160
+ 'interaction: the tone follows the filename extension',
161
+ async () => {
162
+ await expect(badges.map((badge) => badge.dataset.tone)).toEqual([
163
+ 'accent-pink',
164
+ 'accent-soft',
165
+ 'accent-yellow',
166
+ 'accent-orange',
167
+ 'default',
168
+ 'default',
169
+ ]);
170
+ },
171
+ );
172
+ },
173
+ };
174
+
175
+ function getBadges(canvasElement: HTMLElement): HTMLElement[] {
176
+ return [
177
+ ...canvasElement.querySelectorAll<HTMLElement>('[data-slot="file-type"]'),
178
+ ];
179
+ }
180
+
181
+ // The badge is decorative: the filename next to it carries the meaning, the
182
+ // way UiFileItem pairs them.
183
+ const renderTestFileRows = () => ({
184
+ components: { UiFileType },
185
+ template: `
186
+ <ul class="grid w-full max-w-sm gap-3" aria-label="Attachments">
187
+ <li class="flex min-w-0 items-center gap-3">
188
+ <UiFileType filename="quarterly-financial-report-final-version.pdf" />
189
+ <span class="body-s-medium min-w-0 truncate">quarterly-financial-report-final-version.pdf</span>
190
+ <button type="button" class="ml-auto">Remove</button>
191
+ </li>
192
+ <li class="flex min-w-0 items-center gap-3">
193
+ <UiFileType filename="data.csv" :error="true" />
194
+ <span class="body-s-medium">data.csv</span>
195
+ <span class="body-s-regular">Upload failed</span>
196
+ </li>
197
+ </ul>
198
+ `,
199
+ });
200
+
201
+ /**
202
+ * The badge never takes focus, so Tab goes straight to the row's controls.
203
+ * Hidden test-only story.
204
+ */
205
+ export const KeyboardNavigation: Story = {
206
+ name: 'test - Keyboard Navigation',
207
+ tags: ['!dev', '!autodocs'],
208
+ parameters: {
209
+ controls: { disable: true },
210
+ chromatic: { disableSnapshot: true },
211
+ docs: {
212
+ description: {
213
+ story: 'Press `Tab`: focus skips the badge and lands on Remove.',
214
+ },
215
+ },
216
+ },
217
+ render: renderTestFileRows,
218
+ play: async ({ canvasElement, step }) => {
219
+ // Scenario (UiFileType): a keyboard user moving through a file list never
220
+ // stops on the decorative badge.
221
+ const canvas = within(canvasElement);
222
+ const [badge] = getBadges(canvasElement);
223
+
224
+ await step('keyboard: the badge is not focusable', async () => {
225
+ await expect(badge).not.toHaveAttribute('tabindex');
226
+ await expect(badge.querySelector('[tabindex]')).toBeNull();
227
+ });
228
+
229
+ await step(
230
+ 'keyboard: Tab skips the badge and reaches the row action',
231
+ async () => {
232
+ await userEvent.tab();
233
+ await expect(
234
+ canvas.getByRole('button', { name: 'Remove' }),
235
+ ).toHaveFocus();
236
+ },
237
+ );
238
+ },
239
+ };
240
+
241
+ /**
242
+ * What assistive technology reads: the filename and status text, never the
243
+ * decorative badge or its icon (WCAG 1.1.1). Hidden test-only story.
244
+ */
245
+ export const ScreenReader: Story = {
246
+ name: 'test - Screen Reader',
247
+ tags: ['!dev', '!autodocs'],
248
+ parameters: {
249
+ controls: { disable: true },
250
+ chromatic: { disableSnapshot: true },
251
+ docs: {
252
+ description: {
253
+ story:
254
+ 'The badge is hidden from assistive technology; the filename and status text carry the meaning.',
255
+ },
256
+ },
257
+ },
258
+ render: renderTestFileRows,
259
+ play: async ({ canvasElement, step }) => {
260
+ // Scenario (UiFileType): a screen-reader user hears each file's name and
261
+ // status, without an unlabelled image or icon in between.
262
+ const canvas = within(canvasElement);
263
+ const badges = getBadges(canvasElement);
264
+
265
+ await step(
266
+ 'screen-reader: badges are hidden from assistive technology (WCAG 1.1.1)',
267
+ async () => {
268
+ for (const badge of badges) {
269
+ await expect(badge).toHaveAttribute('aria-hidden', 'true');
270
+ }
271
+ await expect(canvas.queryAllByRole('img')).toHaveLength(0);
272
+ },
273
+ );
274
+
275
+ await step(
276
+ 'screen-reader: the filename and status text carry the meaning',
277
+ async () => {
278
+ const [first, second] = within(
279
+ canvas.getByRole('list', { name: 'Attachments' }),
280
+ ).getAllByRole('listitem');
281
+ await expect(first).toHaveTextContent(
282
+ 'quarterly-financial-report-final-version.pdf',
283
+ );
284
+ await expect(second).toHaveTextContent('data.csvUpload failed');
285
+ },
286
+ );
287
+
288
+ await step(
289
+ 'screen-reader: the error state is not conveyed by the icon alone (WCAG 1.4.1)',
290
+ async () => {
291
+ await expect(badges[1]).toHaveAttribute('data-tone', 'default');
292
+ await expect(canvas.getByText('Upload failed')).toBeVisible();
293
+ },
294
+ );
295
+ },
296
+ };
297
+
298
+ /**
299
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
300
+ * try 400% reflow (WCAG 1.4.10). Hidden test-only story.
301
+ */
302
+ export const ZoomMagnification: Story = {
303
+ name: 'test - Zoom Magnification',
304
+ tags: ['!dev', '!autodocs'],
305
+ globals: { zoom: '200' },
306
+ parameters: {
307
+ controls: { disable: true },
308
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
309
+ // already covers magnified snapshots, so skip this one.
310
+ chromatic: { disableSnapshot: true },
311
+ docs: {
312
+ description: {
313
+ story:
314
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
315
+ },
316
+ },
317
+ },
318
+ render: renderTestFileRows,
319
+ play: async ({ canvasElement, step }) => {
320
+ // Scenario (UiFileType): at 200% page zoom the badges and filenames stay
321
+ // visible and the list doesn't scroll the page sideways.
322
+ const canvas = within(canvasElement);
323
+
324
+ await step(
325
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
326
+ async () => {
327
+ await expect(document.documentElement.style.zoom).toBe('200%');
328
+ },
329
+ );
330
+
331
+ await step('zoom: badges and filenames stay visible', async () => {
332
+ for (const badge of getBadges(canvasElement)) {
333
+ await expect(badge).toBeVisible();
334
+ }
335
+ await expect(canvas.getByText('data.csv')).toBeVisible();
336
+ });
337
+
338
+ await step(
339
+ 'zoom: long filenames truncate instead of scrolling the page',
340
+ async () => {
341
+ const { scrollWidth, clientWidth } = document.documentElement;
342
+ await expect(scrollWidth).toBeLessThanOrEqual(clientWidth + 1);
343
+ },
344
+ );
345
+ },
346
+ };
347
+
348
+ /**
349
+ * Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
350
+ * toolbar. Rows reflow without sideways scrolling (WCAG 1.4.10).
351
+ * Hidden test-only story.
352
+ */
353
+ export const MobileBreakpoint: Story = {
354
+ name: 'test - Mobile Breakpoint',
355
+ tags: ['!dev', '!autodocs'],
356
+ globals: { mediaBreakpoint: 'reflow' },
357
+ parameters: {
358
+ controls: { disable: true },
359
+ // Reflow snapshots are already covered by the accessible-reflow mode.
360
+ chromatic: { disableSnapshot: true },
361
+ docs: {
362
+ description: {
363
+ story:
364
+ 'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
365
+ },
366
+ },
367
+ },
368
+ render: renderTestFileRows,
369
+ play: async ({ canvasElement, step }) => {
370
+ // Scenario (UiFileType): at the 320px breakpoint each row fits the
371
+ // viewport and the badge keeps its place next to the filename.
372
+ const canvas = within(canvasElement);
373
+
374
+ await step(
375
+ 'mobile: the story renders at the 320px breakpoint',
376
+ async () => {
377
+ await expect(document.documentElement.dataset.aaMediaBreakpoint).toBe(
378
+ 'reflow',
379
+ );
380
+ },
381
+ );
382
+
383
+ await step(
384
+ 'mobile: rows fit the viewport without sideways scrolling (WCAG 1.4.10)',
385
+ async () => {
386
+ for (const row of canvas.getAllByRole('listitem')) {
387
+ const { right } = row.getBoundingClientRect();
388
+ await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
389
+ }
390
+ },
391
+ );
392
+
393
+ await step(
394
+ 'mobile: the badge stays visible beside the filename',
395
+ async () => {
396
+ const [badge] = getBadges(canvasElement);
397
+ await expect(badge).toBeVisible();
398
+ await expect(
399
+ canvas.getByText('quarterly-financial-report-final-version.pdf'),
400
+ ).toBeInTheDocument();
401
+ },
402
+ );
403
+ },
153
404
  };
154
405
 
155
406
  const toneOverridesTemplateSource = `<script setup lang="ts">
@@ -193,6 +444,9 @@ export const ToneOverrides: Story = {
193
444
  },
194
445
  render: () => ({
195
446
  components: { UiFileType },
447
+ setup() {
448
+ return { CodeXmlIcon, FileIcon, ImagePlayIcon, Table2Icon };
449
+ },
196
450
  template: `
197
451
  <div class="grid gap-3">
198
452
  <div class="flex items-center gap-3">
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
2
  import { expect, fireEvent, fn, userEvent, within } from 'storybook/test';
3
3
  import { ref } from 'vue';
4
4
  import { UiFileUploadBox } from '@/components/UiFileUploadBox';
5
+ import { guidanceSectionClass } from '../../../.storybook/guidance';
5
6
 
6
7
  /**
7
8
  * UiFileUploadBox is an inline drop zone primitive for selecting and uploading files via click or drag-and-drop.
@@ -186,77 +187,6 @@ export const Default: Story = {
186
187
  },
187
188
  };
188
189
 
189
- /** Disabled: the box is skipped by Tab, reports itself as disabled, and ignores clicks and drops. */
190
- export const Disabled: Story = {
191
- args: {
192
- disabled: true,
193
- },
194
- render: (args) => renderWithSpies(args),
195
- parameters: {
196
- docs: {
197
- source: { code: '<UiFileUploadBox disabled />' },
198
- },
199
- },
200
- play: async ({ canvasElement, step }) => {
201
- // Scenario (UiFileUploadBox): while uploads are blocked the box must not
202
- // look operable to any input method.
203
- onPickerOpen.mockClear();
204
- onUpdateFiles.mockClear();
205
- const canvas = within(canvasElement);
206
- const zone = canvas.getByRole('button', { name: /Drop files here/ });
207
-
208
- await step('interaction: the box reports its disabled state', async () => {
209
- await expect(zone).toHaveAttribute('aria-disabled', 'true');
210
- });
211
-
212
- await step('interaction: clicks do not open the picker', async () => {
213
- await userEvent.click(zone);
214
- await expect(onPickerOpen).not.toHaveBeenCalled();
215
- });
216
-
217
- await step('interaction: dropped files are ignored', async () => {
218
- dropFile(zone, new File(['x'], 'a.pdf', { type: 'application/pdf' }));
219
- await expect(onUpdateFiles).not.toHaveBeenCalled();
220
- });
221
- },
222
- };
223
-
224
- /**
225
- * Drag-over: while files are dragged over the box, its border, icon, and title
226
- * change together so the state does not rely on colour alone.
227
- */
228
- export const DragOver: Story = {
229
- render: (args) => renderWithSpies(args),
230
- parameters: {
231
- docs: {
232
- source: { code: '<UiFileUploadBox @update:files="onFiles" />' },
233
- },
234
- },
235
- play: async ({ canvasElement, step }) => {
236
- const canvas = within(canvasElement);
237
- const zone = canvas.getByRole('button', { name: /Drop files here/ });
238
-
239
- await step(
240
- 'interaction: dragging files anywhere over the box shows the drag-over state',
241
- async () => {
242
- await fireEvent.dragEnter(canvas.getByText('Choose files'));
243
- await expect(zone).toHaveAttribute('data-dragging', 'true');
244
- },
245
- );
246
-
247
- await step(
248
- 'interaction: leaving the box clears the drag-over state',
249
- async () => {
250
- await fireEvent.dragLeave(canvas.getByText('Choose files'));
251
- await expect(zone).not.toHaveAttribute('data-dragging');
252
- },
253
- );
254
-
255
- // Re-enter so the snapshot captures the drag-over state.
256
- await fireEvent.dragEnter(zone);
257
- },
258
- };
259
-
260
190
  /**
261
191
  * Accessibility guidance for the box: its name, keyboard use, disabled state,
262
192
  * and what may go in the `choose` slot — shown in the default and accessible themes.
@@ -265,7 +195,7 @@ export const Accessibility: Story = {
265
195
  render: () => ({
266
196
  components: { UiFileUploadBox },
267
197
  template: `
268
- <section class="flex flex-col gap-6 p-4">
198
+ <section class="${guidanceSectionClass}">
269
199
  <h2 class="heading-m font-bold text-content-on-surface-primary">
270
200
  Accessibility
271
201
  </h2>
@@ -330,6 +260,7 @@ export const Accessibility: Story = {
330
260
  }),
331
261
  tags: ['!autodocs'],
332
262
  parameters: {
263
+ surface: 'primary',
333
264
  chromatic: { disableSnapshot: true },
334
265
  docs: {
335
266
  canvas: { sourceState: 'none' },
@@ -337,6 +268,77 @@ export const Accessibility: Story = {
337
268
  },
338
269
  };
339
270
 
271
+ /** Disabled: the box is skipped by Tab, reports itself as disabled, and ignores clicks and drops. */
272
+ export const Disabled: Story = {
273
+ args: {
274
+ disabled: true,
275
+ },
276
+ render: (args) => renderWithSpies(args),
277
+ parameters: {
278
+ docs: {
279
+ source: { code: '<UiFileUploadBox disabled />' },
280
+ },
281
+ },
282
+ play: async ({ canvasElement, step }) => {
283
+ // Scenario (UiFileUploadBox): while uploads are blocked the box must not
284
+ // look operable to any input method.
285
+ onPickerOpen.mockClear();
286
+ onUpdateFiles.mockClear();
287
+ const canvas = within(canvasElement);
288
+ const zone = canvas.getByRole('button', { name: /Drop files here/ });
289
+
290
+ await step('interaction: the box reports its disabled state', async () => {
291
+ await expect(zone).toHaveAttribute('aria-disabled', 'true');
292
+ });
293
+
294
+ await step('interaction: clicks do not open the picker', async () => {
295
+ await userEvent.click(zone);
296
+ await expect(onPickerOpen).not.toHaveBeenCalled();
297
+ });
298
+
299
+ await step('interaction: dropped files are ignored', async () => {
300
+ dropFile(zone, new File(['x'], 'a.pdf', { type: 'application/pdf' }));
301
+ await expect(onUpdateFiles).not.toHaveBeenCalled();
302
+ });
303
+ },
304
+ };
305
+
306
+ /**
307
+ * Drag-over: while files are dragged over the box, its border, icon, and title
308
+ * change together so the state does not rely on colour alone.
309
+ */
310
+ export const DragOver: Story = {
311
+ render: (args) => renderWithSpies(args),
312
+ parameters: {
313
+ docs: {
314
+ source: { code: '<UiFileUploadBox @update:files="onFiles" />' },
315
+ },
316
+ },
317
+ play: async ({ canvasElement, step }) => {
318
+ const canvas = within(canvasElement);
319
+ const zone = canvas.getByRole('button', { name: /Drop files here/ });
320
+
321
+ await step(
322
+ 'interaction: dragging files anywhere over the box shows the drag-over state',
323
+ async () => {
324
+ await fireEvent.dragEnter(canvas.getByText('Choose files'));
325
+ await expect(zone).toHaveAttribute('data-dragging', 'true');
326
+ },
327
+ );
328
+
329
+ await step(
330
+ 'interaction: leaving the box clears the drag-over state',
331
+ async () => {
332
+ await fireEvent.dragLeave(canvas.getByText('Choose files'));
333
+ await expect(zone).not.toHaveAttribute('data-dragging');
334
+ },
335
+ );
336
+
337
+ // Re-enter so the snapshot captures the drag-over state.
338
+ await fireEvent.dragEnter(zone);
339
+ },
340
+ };
341
+
340
342
  /**
341
343
  * Keyboard: the box is a single tab stop that opens the picker with Enter or
342
344
  * Space. Hidden test-only story.