@aleph-alpha/ui-library 7.0.1 → 7.1.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 (124) hide show
  1. package/dist/system/components/UiSlider/step-marks.d.ts +45 -0
  2. package/dist/system/components/UiSlider/types.d.ts +28 -0
  3. package/dist/system/components/core/slider/Slider.vue.d.ts +21 -1
  4. package/dist/system/icons/story-sidebar-icons.json +74 -17
  5. package/dist/system/lib.js +2026 -1912
  6. package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
  7. package/dist/system/story-sidebar-icons.json +74 -17
  8. package/package.json +15 -10
  9. package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
  10. package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
  11. package/src/components/UiAlert/UiAlert.guidance.md +66 -0
  12. package/src/components/UiAlert/UiAlert.stories.ts +167 -143
  13. package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
  14. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
  15. package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
  16. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
  17. package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
  18. package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
  19. package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
  20. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
  21. package/src/components/UiBadge/UiBadge.guidance.md +65 -0
  22. package/src/components/UiBadge/UiBadge.stories.ts +325 -0
  23. package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
  24. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
  25. package/src/components/UiButton/UiButton.stories.ts +5 -2
  26. package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
  27. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
  28. package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
  29. package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
  30. package/src/components/UiCard/UiCard.guidance.md +65 -0
  31. package/src/components/UiCard/UiCard.stories.ts +393 -0
  32. package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
  33. package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
  34. package/src/components/UiChip/UiChip.guidance.md +64 -0
  35. package/src/components/UiChip/UiChip.stories.ts +162 -138
  36. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
  37. package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
  38. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
  39. package/src/components/UiDialog/UiDialog.guidance.md +66 -0
  40. package/src/components/UiDialog/UiDialog.stories.ts +90 -66
  41. package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
  42. package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
  43. package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
  44. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +127 -86
  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 +885 -153
  85. package/src/components/UiSlider/UiSlider.vue +109 -1
  86. package/src/components/UiSlider/__tests__/UiSliderValueAndSteps.test.ts +210 -0
  87. package/src/components/UiSlider/__tests__/step-marks.test.ts +94 -0
  88. package/src/components/UiSlider/step-marks.ts +96 -0
  89. package/src/components/UiSlider/types.ts +32 -0
  90. package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
  91. package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
  92. package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
  93. package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
  94. package/src/components/UiStepper/UiStepper.guidance.md +66 -0
  95. package/src/components/UiStepper/UiStepper.stories.ts +142 -124
  96. package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
  97. package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
  98. package/src/components/UiTable/UiTable.guidance.md +66 -0
  99. package/src/components/UiTable/UiTable.stories.ts +530 -12
  100. package/src/components/UiTabs/UiTabs.guidance.md +66 -0
  101. package/src/components/UiTabs/UiTabs.stories.ts +174 -150
  102. package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
  103. package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
  104. package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
  105. package/src/components/UiToggle/UiToggle.guidance.md +66 -0
  106. package/src/components/UiToggle/UiToggle.stories.ts +183 -159
  107. package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
  108. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
  109. package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
  110. package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
  111. package/src/components/core/slider/Slider.vue +16 -6
  112. package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
  113. package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
  114. package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
  115. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
  116. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
  117. package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
  118. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
  119. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
  120. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
  121. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
  122. package/src/patterns/UiPlaceholder/types.ts +1 -0
  123. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +86 -84
  124. package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
@@ -1,5 +1,15 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { expect, userEvent, within } from 'storybook/test';
2
3
  import UiSkeleton from './UiSkeleton.vue';
4
+ import {
5
+ accessibilityStory,
6
+ designNotesStory,
7
+ guidanceLinks,
8
+ parseGuidance,
9
+ } from '../../../.storybook/guidance';
10
+ import guidanceMarkdown from './UiSkeleton.guidance.md?raw';
11
+
12
+ const guidance = parseGuidance(guidanceMarkdown);
3
13
 
4
14
  /**
5
15
  * UiSkeleton is a neutral placeholder shape that mimics the size of incoming content while it is loading.
@@ -26,6 +36,9 @@ const meta: Meta<typeof UiSkeleton> = {
26
36
  args: {
27
37
  rounded: false,
28
38
  },
39
+ parameters: {
40
+ docs: { links: guidanceLinks(guidance) },
41
+ },
29
42
  };
30
43
 
31
44
  export default meta;
@@ -70,6 +83,58 @@ export const Default: Story = {
70
83
  },
71
84
  },
72
85
  },
86
+ play: async ({ canvasElement, step }) => {
87
+ // Scenario (UiSkeleton): the placeholders hold the layout while loading
88
+ // but carry no content, role, or focus of their own.
89
+ const skeletons = canvasElement.querySelectorAll<HTMLElement>(
90
+ '[data-slot="skeleton"]',
91
+ );
92
+
93
+ await step('interaction: renders one placeholder per block', async () => {
94
+ await expect(skeletons).toHaveLength(3);
95
+ });
96
+
97
+ await step(
98
+ 'interaction: placeholders are empty and not focusable',
99
+ async () => {
100
+ for (const skeleton of skeletons) {
101
+ await expect(skeleton).toBeEmptyDOMElement();
102
+ await expect(skeleton).not.toHaveAttribute('tabindex');
103
+ }
104
+ },
105
+ );
106
+ },
107
+ };
108
+
109
+ /**
110
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
111
+ */
112
+ export const DesignNotes: Story = {
113
+ ...designNotesStory(guidance),
114
+ tags: ['!autodocs'],
115
+ };
116
+
117
+ /**
118
+ * Accessibility guidance from the Figma documentation, with the component in
119
+ * the default and accessible themes.
120
+ */
121
+ export const Accessibility: Story = {
122
+ ...accessibilityStory({
123
+ requirements: guidance.accessibility,
124
+ example: {
125
+ components: { UiSkeleton },
126
+ template: `
127
+ <div class="flex items-center gap-3">
128
+ <UiSkeleton class="h-10 w-10 rounded-full" />
129
+ <div class="flex flex-col gap-2">
130
+ <UiSkeleton class="h-4 w-32" />
131
+ <UiSkeleton class="h-4 w-24" />
132
+ </div>
133
+ </div>
134
+ `,
135
+ },
136
+ }),
137
+ tags: ['!autodocs'],
73
138
  };
74
139
 
75
140
  const cardTemplateSource = `<script setup lang="ts">
@@ -249,3 +314,191 @@ export const Table: Story = {
249
314
  },
250
315
  },
251
316
  };
317
+
318
+ const renderTestSkeleton = () => ({
319
+ components: { UiSkeleton },
320
+ template: `
321
+ <div role="status" aria-busy="true" class="flex w-full max-w-sm items-center gap-x-4">
322
+ <span class="sr-only">Loading profile</span>
323
+ <UiSkeleton class="h-12 w-12 shrink-0" rounded />
324
+ <div class="flex min-w-0 flex-1 flex-col gap-y-2">
325
+ <UiSkeleton class="h-4 w-full" />
326
+ <UiSkeleton class="h-4 w-3/4" />
327
+ </div>
328
+ </div>
329
+ `,
330
+ });
331
+
332
+ const getSkeletons = (canvasElement: HTMLElement) =>
333
+ canvasElement.querySelectorAll<HTMLElement>('[data-slot="skeleton"]');
334
+
335
+ /**
336
+ * Skeletons are decorative placeholders, so there is nothing to focus: the
337
+ * keyboard check asserts they stay out of the tab order. Hidden test-only
338
+ * story.
339
+ */
340
+ export const KeyboardNavigation: Story = {
341
+ name: 'test - Keyboard Navigation',
342
+ tags: ['!dev', '!autodocs'],
343
+ parameters: {
344
+ // Focus moves during the play function.
345
+ chromatic: { disableSnapshot: true },
346
+ docs: {
347
+ description: {
348
+ story: 'Press `Tab`: focus skips the skeleton, which is decorative.',
349
+ },
350
+ },
351
+ },
352
+ render: renderTestSkeleton,
353
+ play: async ({ canvasElement, step }) => {
354
+ // Scenario (UiSkeleton): a keyboard user tabs through a loading page and
355
+ // never lands on a placeholder.
356
+ await step('keyboard: skeletons have no focusable target', async () => {
357
+ await userEvent.tab();
358
+ await expect(canvasElement.contains(document.activeElement)).toBe(false);
359
+ });
360
+
361
+ await step('keyboard: no skeleton carries a tabindex', async () => {
362
+ for (const skeleton of getSkeletons(canvasElement)) {
363
+ await expect(skeleton).not.toHaveAttribute('tabindex');
364
+ }
365
+ });
366
+ },
367
+ };
368
+
369
+ /**
370
+ * Skeletons are silent; the loading state is announced by a status message
371
+ * instead. Hidden test-only story.
372
+ */
373
+ export const ScreenReader: Story = {
374
+ name: 'test - Screen Reader',
375
+ tags: ['!dev', '!autodocs'],
376
+ parameters: {
377
+ docs: {
378
+ description: {
379
+ story:
380
+ 'Verifies that the skeletons are not announced as content and the wait is announced in text.',
381
+ },
382
+ },
383
+ },
384
+ render: renderTestSkeleton,
385
+ play: async ({ canvasElement, step }) => {
386
+ // Scenario (UiSkeleton): a screen-reader user hears "Loading profile",
387
+ // not a run of empty blocks mistaken for real content.
388
+ const canvas = within(canvasElement);
389
+
390
+ await step(
391
+ 'screen-reader: skeletons are not announced as real content',
392
+ async () => {
393
+ for (const skeleton of getSkeletons(canvasElement)) {
394
+ await expect(skeleton).toBeEmptyDOMElement();
395
+ await expect(skeleton).not.toHaveAttribute('role');
396
+ await expect(skeleton).not.toHaveAttribute('aria-label');
397
+ await expect(skeleton).toHaveAccessibleName('');
398
+ }
399
+ },
400
+ );
401
+
402
+ await step(
403
+ 'screen-reader: the wait is announced in text by a status region',
404
+ async () => {
405
+ const status = canvas.getByRole('status');
406
+ await expect(status).toHaveAttribute('aria-busy', 'true');
407
+ await expect(status).toHaveTextContent('Loading profile');
408
+ },
409
+ );
410
+ },
411
+ };
412
+
413
+ /**
414
+ * Rendered at 200% page zoom (WCAG 1.4.4 Resize Text). Use the Zoom toolbar to
415
+ * try 400% reflow (WCAG 1.4.10). Hidden test-only story.
416
+ */
417
+ export const ZoomMagnification: Story = {
418
+ name: 'test - Zoom Magnification',
419
+ tags: ['!dev', '!autodocs'],
420
+ globals: { zoom: '200' },
421
+ parameters: {
422
+ // Zoom changes the layout scale; the accessible-reflow Chromatic mode
423
+ // already covers magnified snapshots, so skip this one.
424
+ chromatic: { disableSnapshot: true },
425
+ docs: {
426
+ description: {
427
+ story:
428
+ 'Use the Zoom toolbar (200% resize text, 400% reflow) to magnify the preview.',
429
+ },
430
+ },
431
+ },
432
+ render: renderTestSkeleton,
433
+ play: async ({ canvasElement, step }) => {
434
+ // Scenario (UiSkeleton): at 200% page zoom the placeholders stay inside
435
+ // the viewport, so the page doesn't scroll sideways while loading.
436
+ await step(
437
+ 'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
438
+ async () => {
439
+ await expect(document.documentElement.style.zoom).toBe('200%');
440
+ },
441
+ );
442
+
443
+ await step('zoom: skeletons stay inside the viewport', async () => {
444
+ const skeletons = getSkeletons(canvasElement);
445
+ await expect(skeletons.length).toBeGreaterThan(0);
446
+ for (const skeleton of skeletons) {
447
+ const { left, right } = skeleton.getBoundingClientRect();
448
+ await expect(left).toBeGreaterThanOrEqual(0);
449
+ await expect(right).toBeLessThanOrEqual(window.innerWidth + 1);
450
+ }
451
+ });
452
+ },
453
+ };
454
+
455
+ /**
456
+ * Rendered at the mobile (320px reflow) breakpoint via the Media breakpoint
457
+ * toolbar. Hidden test-only story.
458
+ */
459
+ export const MobileBreakpoint: Story = {
460
+ name: 'test - Mobile Breakpoint',
461
+ tags: ['!dev', '!autodocs'],
462
+ globals: { mediaBreakpoint: 'reflow' },
463
+ parameters: {
464
+ // Reflow snapshots are already covered by the accessible-reflow mode.
465
+ chromatic: { disableSnapshot: true },
466
+ docs: {
467
+ description: {
468
+ story:
469
+ 'Switch the Media breakpoint toolbar to Mobile to preview the 320px layout.',
470
+ },
471
+ },
472
+ },
473
+ render: renderTestSkeleton,
474
+ play: async ({ canvasElement, step }) => {
475
+ // Scenario (UiSkeleton): at the 320px mobile breakpoint the placeholders
476
+ // fit without sideways scrolling.
477
+ const canvas = within(canvasElement);
478
+
479
+ await step(
480
+ 'mobile: the loading state renders at the 320px breakpoint',
481
+ async () => {
482
+ await expect(canvas.getByRole('status')).toBeInTheDocument();
483
+ await expect(getSkeletons(canvasElement)).toHaveLength(3);
484
+ },
485
+ );
486
+
487
+ await step(
488
+ 'mobile: the layout fits without sideways scrolling (WCAG 1.4.10 Reflow)',
489
+ async () => {
490
+ const { scrollWidth, clientWidth } = document.documentElement;
491
+ await expect(scrollWidth).toBeLessThanOrEqual(clientWidth + 1);
492
+ },
493
+ );
494
+
495
+ await step(
496
+ 'mobile: skeletons add no touch targets of their own',
497
+ async () => {
498
+ // Placeholders take no input, so 2.5.8 doesn't apply to them.
499
+ await expect(canvas.queryAllByRole('button')).toHaveLength(0);
500
+ await expect(canvas.queryAllByRole('link')).toHaveLength(0);
501
+ },
502
+ );
503
+ },
504
+ };
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29207:71402'
3
+ ---
4
+
5
+ <!-- Synced from Figma by scripts/sync-figma-docs.mjs. Edit the copy in Figma: changes made here are overwritten. -->
6
+
7
+ ## Usage
8
+
9
+ The Slider component sets a value by position within a range. The user gains a sense of where the value sits relative to the whole, and loses precision — which is the right trade only sometimes.
10
+
11
+ Use it when the approximate value matters more than the exact one: volume, brightness, a price band. When the user has an exact number in mind, an input is faster and kinder.
12
+
13
+ ### Position has to be readable
14
+
15
+ A slider is read before it is dragged:
16
+
17
+ - The filled portion shows how far along the value is
18
+ - The handle is clearly the part that moves
19
+ - The current value is shown in text wherever precision matters at all
20
+ - The ends of the range are labelled where their meaning is not obvious
21
+
22
+ ### Ranges need two handles
23
+
24
+ A range is one value made of two, so treat it as one:
25
+
26
+ 1. Both handles are visibly the same kind of control
27
+ 2. The span between them is filled, showing what is selected
28
+ 3. Handles cannot cross, and stop rather than swapping
29
+ 4. Both ends of the range are shown in text together
30
+
31
+ ### Consistency
32
+
33
+ Every slider is built from the same parts:
34
+
35
+ - Slider, single value or range
36
+ - Track, with a filled portion
37
+ - Handle, with default, hover and focus states
38
+ - A value in text, where precision matters
39
+ - One track height and handle size per context
40
+
41
+ ## Do
42
+
43
+ - Show the current value in text wherever precision matters at all
44
+ - Label the ends of the range where their meaning is not obvious
45
+ - Fill the track up to the value, so position reads at a glance
46
+ - Keep both handles identical in a range slider
47
+ - Stop handles at each other rather than letting them swap
48
+ - Offer an input alongside where the user may know the exact number
49
+
50
+ ## Don't
51
+
52
+ - Use a slider where an exact value is required
53
+ - Hide the current value entirely
54
+ - Make the handle smaller than it can comfortably be grabbed
55
+ - Let range handles cross each other
56
+ - Use a slider for a range with only a few possible values
57
+ - Rely on the fill colour alone to distinguish the filled track from the rest
58
+
59
+ ## Accessibility
60
+
61
+ - Filled and unfilled track differ in more than colour, so the value reads in greyscale
62
+ - The handle is a comfortable target on touch as well as pointer, larger than the track is tall
63
+ - The handle carries a visible focus state, distinct from hover
64
+ - The current value appears in text, so position is not the only way to read it
65
+ - In a range slider the two handles stay distinguishable at the ends of the track
66
+ - The track is tall enough that a value near either end is still visible