@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
@@ -0,0 +1,68 @@
1
+ ---
2
+ figma: '29176:16323'
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 Dropdown Menu component presents a set of actions in a temporary surface that opens from a trigger. It keeps secondary and contextual commands out of the way until a user needs them, without taking the user away from the current view.
10
+
11
+ Use it for actions a user performs on an object or in a context. It is not a form control: choosing a value that will be submitted belongs to Select or Combobox.
12
+
13
+ ### Actions, not values
14
+
15
+ A dropdown menu triggers behaviour, it never holds a value:
16
+
17
+ - Dropdown Menu for commands such as Edit, Duplicate, Move or Delete
18
+ - Select for choosing one value in a form
19
+ - Combobox when the list is long enough to need filtering
20
+ - Popover when the surface holds rich content instead of a list of items
21
+
22
+ ### Progressive disclosure
23
+
24
+ Reveal one layer at a time, and only where it helps the user act:
25
+
26
+ 1. Trigger names what the menu will act on
27
+ 2. Menu lists the actions available right now
28
+ 3. Submenu holds variations of a single action, never a second topic
29
+ 4. Separators and labels appear only when a grouping carries meaning
30
+
31
+ ### Consistency
32
+
33
+ Every menu is composed from the same parts, whatever opens it:
34
+
35
+ - Trigger (button, icon button, avatar)
36
+ - Menu surface
37
+ - Item (default, checkbox, radio, icon)
38
+ - Item label (level 1, level 2)
39
+ - Separator
40
+ - Sub-trigger and submenu
41
+ - User item
42
+
43
+ ## Do
44
+
45
+ - Order items by how often they are used, most frequent first
46
+ - Start item labels with a verb and keep them to a few words
47
+ - Group related items with a separator, and add a label when the group needs naming
48
+ - Place destructive actions last, separated from the rest
49
+ - Limit menus to a single level of submenu
50
+ - Close the menu as soon as an action is chosen
51
+
52
+ ## Don't
53
+
54
+ - Use a dropdown menu to select a value in a form
55
+ - Open or close the menu on hover alone
56
+ - Nest submenus more than one level deep
57
+ - Put more than roughly ten items in a menu without grouping them
58
+ - Mix unrelated actions into a single submenu
59
+ - Leave an icon-only trigger without an accessible name
60
+
61
+ ## Accessibility
62
+
63
+ - The trigger is a button with aria-haspopup="menu" and aria-expanded reflecting the open state
64
+ - The surface uses role="menu"; items use menuitem, menuitemcheckbox or menuitemradio
65
+ - Enter or Space opens the menu and moves focus to the first item; Escape closes it and returns focus to the trigger
66
+ - Arrow keys move between items, Home and End jump to first and last, Right and Left open and close a submenu
67
+ - Checkbox and radio items expose aria-checked, so state never rests on the check icon alone
68
+ - Unavailable items are marked aria-disabled and explained, never silently removed
@@ -30,6 +30,16 @@ import {
30
30
  GlobeIcon,
31
31
  MessageSquareIcon,
32
32
  } from '@/icons/lucide';
33
+ import {
34
+ accessibilityRequirementsTemplate,
35
+ designNotesStory,
36
+ guidanceLinks,
37
+ guidanceSectionClass,
38
+ parseGuidance,
39
+ } from '../../../.storybook/guidance';
40
+ import guidanceMarkdown from './UiDropdownMenu.guidance.md?raw';
41
+
42
+ const guidance = parseGuidance(guidanceMarkdown);
33
43
 
34
44
  /**
35
45
  * UiDropdownMenu is a floating menu of actions or settings anchored to a trigger element, with support for submenus, checkboxes, and radio groups.
@@ -55,6 +65,7 @@ const meta: Meta<typeof UiDropdownMenu> = {
55
65
  modal: true,
56
66
  },
57
67
  parameters: {
68
+ docs: { links: guidanceLinks(guidance) },
58
69
  a11y: {
59
70
  options: {
60
71
  rules: {
@@ -161,6 +172,102 @@ export const Default: Story = {
161
172
  },
162
173
  };
163
174
 
175
+ /**
176
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
177
+ */
178
+ export const DesignNotes: Story = {
179
+ ...designNotesStory(guidance),
180
+ tags: ['!autodocs'],
181
+ };
182
+
183
+ /**
184
+ * How the menu behaves for keyboard and screen-reader users.
185
+ */
186
+ export const Accessibility: Story = {
187
+ tags: ['!autodocs'],
188
+ parameters: {
189
+ surface: 'primary',
190
+ a11y: { test: 'off' },
191
+ chromatic: { disableSnapshot: true },
192
+ docs: { canvas: { sourceState: 'none' } },
193
+ },
194
+ render: () => ({
195
+ components: {
196
+ UiDropdownMenu,
197
+ UiDropdownMenuTrigger,
198
+ UiDropdownMenuContent,
199
+ UiDropdownMenuItem,
200
+ UiDropdownMenuLabel,
201
+ UiDropdownMenuSeparator,
202
+ UiDropdownMenuCheckboxItem,
203
+ UiDropdownMenuSub,
204
+ UiDropdownMenuSubTrigger,
205
+ UiDropdownMenuSubContent,
206
+ UiButton,
207
+ },
208
+ setup() {
209
+ const open = ref(true);
210
+ return { open, stayOpen };
211
+ },
212
+ template: `
213
+ <section class="${guidanceSectionClass}">
214
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
215
+ Accessibility
216
+ </h2>
217
+
218
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
219
+
220
+ <div class="flex flex-col gap-2">
221
+ <h3 class="body-m-medium text-content-on-surface-primary">
222
+ In code
223
+ </h3>
224
+ <ul class="body-m-regular list-disc pl-5 text-content-on-surface-primary">
225
+ <li>The trigger needs a name of its own: give an icon-only trigger an <code class="label-s-regular">aria-label</code>, since the icon is not read out.</li>
226
+ <li>The trigger tells assistive technology that it opens a menu, and whether that menu is currently open.</li>
227
+ <li>Every row is announced as a menu item, named by the text you can see; icons in an item are decoration and add nothing to that name.</li>
228
+ <li>A label groups the items below it and is not a choice — it cannot be focused or activated.</li>
229
+ <li>A disabled item says it is disabled and is skipped by the arrow keys, so it is never a dead end.</li>
230
+ <li>Checkbox and radio items report checked and selected, so the state is spoken and not carried by the tick alone.</li>
231
+ <li>An item that leads to a second level says so, and opens with the right arrow key as well as on hover.</li>
232
+ <li>Enter or Space opens the menu, the arrow keys walk it, Home and End jump to its ends, and Escape closes it and puts focus back on the trigger.</li>
233
+ <li>A modal menu hides the rest of the page from assistive technology. Pass <code class="label-s-regular">:modal="false"</code> when what is behind the menu should stay available.</li>
234
+ <li>Triggers need a touch target of at least 24px; every row is 36px tall, so it meets that on its own.</li>
235
+ <li>On a phone only five rows are in view and the rest scroll under a fade. The fade is decoration: the rows behind it are still in the tree, the arrow keys still reach them, and the list scrolls to keep the focused row visible.</li>
236
+ <li>On a phone a second level opens stacked 8px above or below its row, as wide as the menu, and dims the rest of the menu. It is still a menu named by its row: the row says it is expanded, the right arrow key opens it and moves focus into it, and the left arrow key closes it and puts focus back on the row.</li>
237
+ <li>Put the checked state on the row, not on a control inside it: a switch or checkbox inside a menu item is nested interactive content. Give the row <code class="label-s-regular">role="menuitemcheckbox"</code> and <code class="label-s-regular">aria-checked</code>, and mark the visual control <code class="label-s-regular">inert</code>.</li>
238
+ </ul>
239
+ </div>
240
+
241
+ <div class="flex flex-col gap-2">
242
+ <h3 class="body-m-medium text-content-on-surface-primary">
243
+ Enable accessibility theme
244
+ </h3>
245
+ <p class="body-m-regular text-content-on-surface-primary">
246
+ When accessibility is required, enable our accessibility theme. This
247
+ increases contrast and ensures there are no color contrast issues.
248
+ </p>
249
+ </div>
250
+
251
+ <div class="flex flex-wrap gap-12">
252
+ <div class="flex w-64 flex-col gap-3">
253
+ <h3 class="label-m-medium text-content-on-surface-primary">
254
+ Default
255
+ </h3>
256
+ <div class="min-h-72">${themedMenu()}</div>
257
+ </div>
258
+
259
+ <div class="flex w-64 flex-col gap-3">
260
+ <h3 class="label-m-medium text-content-on-surface-primary">
261
+ Accessible
262
+ </h3>
263
+ <div class="min-h-72">${themedMenu('accessible-theme')}</div>
264
+ </div>
265
+ </div>
266
+ </section>
267
+ `,
268
+ }),
269
+ };
270
+
164
271
  const withLabelsTemplateSource = `<script setup lang="ts">
165
272
  import { ref } from 'vue'
166
273
  import {
@@ -1952,91 +2059,6 @@ const themedMenu = (themeClass = '') => `
1952
2059
  </UiDropdownMenu>
1953
2060
  `;
1954
2061
 
1955
- /**
1956
- * How the menu behaves for keyboard and screen-reader users.
1957
- */
1958
- export const Accessibility: Story = {
1959
- tags: ['!autodocs'],
1960
- parameters: {
1961
- a11y: { test: 'off' },
1962
- chromatic: { disableSnapshot: true },
1963
- docs: { canvas: { sourceState: 'none' } },
1964
- },
1965
- render: () => ({
1966
- components: {
1967
- UiDropdownMenu,
1968
- UiDropdownMenuTrigger,
1969
- UiDropdownMenuContent,
1970
- UiDropdownMenuItem,
1971
- UiDropdownMenuLabel,
1972
- UiDropdownMenuSeparator,
1973
- UiDropdownMenuCheckboxItem,
1974
- UiDropdownMenuSub,
1975
- UiDropdownMenuSubTrigger,
1976
- UiDropdownMenuSubContent,
1977
- UiButton,
1978
- },
1979
- setup() {
1980
- const open = ref(true);
1981
- return { open, stayOpen };
1982
- },
1983
- template: `
1984
- <section class="flex flex-col gap-6 p-4">
1985
- <h2 class="heading-m font-bold text-content-on-surface-primary">
1986
- Accessibility
1987
- </h2>
1988
-
1989
- <div class="flex flex-col gap-2">
1990
- <h3 class="body-m-medium text-content-on-surface-primary">
1991
- Requirements
1992
- </h3>
1993
- <ul class="body-m-regular list-disc pl-5 text-content-on-surface-primary">
1994
- <li>The trigger needs a name of its own: give an icon-only trigger an <code class="label-s-regular">aria-label</code>, since the icon is not read out.</li>
1995
- <li>The trigger tells assistive technology that it opens a menu, and whether that menu is currently open.</li>
1996
- <li>Every row is announced as a menu item, named by the text you can see; icons in an item are decoration and add nothing to that name.</li>
1997
- <li>A label groups the items below it and is not a choice — it cannot be focused or activated.</li>
1998
- <li>A disabled item says it is disabled and is skipped by the arrow keys, so it is never a dead end.</li>
1999
- <li>Checkbox and radio items report checked and selected, so the state is spoken and not carried by the tick alone.</li>
2000
- <li>An item that leads to a second level says so, and opens with the right arrow key as well as on hover.</li>
2001
- <li>Enter or Space opens the menu, the arrow keys walk it, Home and End jump to its ends, and Escape closes it and puts focus back on the trigger.</li>
2002
- <li>A modal menu hides the rest of the page from assistive technology. Pass <code class="label-s-regular">:modal="false"</code> when what is behind the menu should stay available.</li>
2003
- <li>Triggers need a touch target of at least 24px; every row is 36px tall, so it meets that on its own.</li>
2004
- <li>On a phone only five rows are in view and the rest scroll under a fade. The fade is decoration: the rows behind it are still in the tree, the arrow keys still reach them, and the list scrolls to keep the focused row visible.</li>
2005
- <li>On a phone a second level opens stacked 8px above or below its row, as wide as the menu, and dims the rest of the menu. It is still a menu named by its row: the row says it is expanded, the right arrow key opens it and moves focus into it, and the left arrow key closes it and puts focus back on the row.</li>
2006
- <li>Put the checked state on the row, not on a control inside it: a switch or checkbox inside a menu item is nested interactive content. Give the row <code class="label-s-regular">role="menuitemcheckbox"</code> and <code class="label-s-regular">aria-checked</code>, and mark the visual control <code class="label-s-regular">inert</code>.</li>
2007
- </ul>
2008
- </div>
2009
-
2010
- <div class="flex flex-col gap-2">
2011
- <h3 class="body-m-medium text-content-on-surface-primary">
2012
- Enable accessibility theme
2013
- </h3>
2014
- <p class="body-m-regular text-content-on-surface-primary">
2015
- When accessibility is required, enable our accessibility theme. This
2016
- increases contrast and ensures there are no color contrast issues.
2017
- </p>
2018
- </div>
2019
-
2020
- <div class="flex flex-wrap gap-12">
2021
- <div class="flex w-64 flex-col gap-3">
2022
- <h3 class="label-m-medium text-content-on-surface-primary">
2023
- Default
2024
- </h3>
2025
- <div class="min-h-72">${themedMenu()}</div>
2026
- </div>
2027
-
2028
- <div class="flex w-64 flex-col gap-3">
2029
- <h3 class="label-m-medium text-content-on-surface-primary">
2030
- Accessible
2031
- </h3>
2032
- <div class="min-h-72">${themedMenu('accessible-theme')}</div>
2033
- </div>
2034
- </div>
2035
- </section>
2036
- `,
2037
- }),
2038
- };
2039
-
2040
2062
  /*
2041
2063
  * ─────────────────────────────────────────────────────────────────────────────
2042
2064
  * Interaction & accessibility tests (play functions)
@@ -2746,6 +2768,21 @@ function settle() {
2746
2768
  });
2747
2769
  }
2748
2770
 
2771
+ /**
2772
+ * Waits for an element's CSS animations to finish so its geometry is stable.
2773
+ * `finished` rejects when an animation is cancelled, which is not a failure
2774
+ * here — it just means the element settled another way.
2775
+ * @param element Element whose animations should settle.
2776
+ */
2777
+ async function settleAnimations(element: HTMLElement) {
2778
+ if (typeof element.getAnimations !== 'function') return;
2779
+ await Promise.all(
2780
+ element
2781
+ .getAnimations()
2782
+ .map((animation) => animation.finished.catch(() => undefined)),
2783
+ );
2784
+ }
2785
+
2749
2786
  /**
2750
2787
  * Waits until `row` sits fully inside the visible part of `scroll`.
2751
2788
  * @param row A menu row.
@@ -2826,7 +2863,10 @@ export const MobileCappedSubmenu: Story = {
2826
2863
  await userEvent.click(
2827
2864
  canvas.getByRole('button', { name: 'Open Menu' }),
2828
2865
  );
2829
- await expectOpenMenu(body);
2866
+ // The menu slides in from 8px higher. Measured mid-animation, the row
2867
+ // still moves once the slide ends, and placing the submenu again for
2868
+ // that shrinks its cap after the list has been scrolled to its end.
2869
+ await settleAnimations(await expectOpenMenu(body));
2830
2870
  const row = body.getByRole('menuitem', { name: 'Move to' });
2831
2871
  // 120px under the row and less above it: neither side holds five rows.
2832
2872
  const height = Math.round(row.getBoundingClientRect().bottom + 120);
@@ -2847,6 +2887,7 @@ export const MobileCappedSubmenu: Story = {
2847
2887
  await expect(rect.top).toBeGreaterThanOrEqual(0);
2848
2888
  await expect(rect.bottom).toBeLessThanOrEqual(height + 1);
2849
2889
  });
2890
+ await settleAnimations(submenu);
2850
2891
  },
2851
2892
  );
2852
2893
 
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29197:70337'
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 Empty component fills a space that has nothing in it yet and turns that absence into a next step. An empty state is not an error: it is the beginning of something, or a filter that matched nothing.
10
+
11
+ Use it wherever a list, table, panel or search result can legitimately be empty. Every such place deserves one, because a blank area reads as broken.
12
+
13
+ ### Say why, then say what next
14
+
15
+ An empty state answers two questions, in order:
16
+
17
+ - The title names the situation in plain words
18
+ - The description explains why the space is empty
19
+ - The action is the thing that would fill it
20
+ - Nothing here implies the user has done something wrong
21
+
22
+ ### Match the state to its cause
23
+
24
+ Different kinds of empty need different words:
25
+
26
+ 1. Nothing created yet, so offer the action that creates the first one
27
+ 2. Nothing matched, so offer a way to widen or clear the filter
28
+ 3. Nothing to do, so say so plainly and offer nothing
29
+ 4. Something failed, so explain it and offer a retry
30
+
31
+ ### Consistency
32
+
33
+ Every empty state is built from the same parts:
34
+
35
+ - Empty surface, centred in the space it fills
36
+ - Media: an icon, an avatar, or an avatar group
37
+ - Title, naming the situation
38
+ - Description, explaining it
39
+ - Content: one, two or three buttons, or an input with a description
40
+
41
+ ## Do
42
+
43
+ - Give every list, table and result set an empty state
44
+ - Name the situation in the title, and explain it in the description
45
+ - Offer the action that would fill the space
46
+ - Use a filter-specific message when a filter is what emptied it
47
+ - Keep the empty state centred in the space it replaces
48
+ - Use an icon that describes the content type, not a generic mark
49
+
50
+ ## Don't
51
+
52
+ - Leave a blank area with no explanation
53
+ - Blame the user for an empty state
54
+ - Offer three actions where one would do
55
+ - Use the same message for nothing-yet and nothing-matched
56
+ - Make the empty state taller than the space it fills
57
+ - Use decorative illustration in place of a clear next step
58
+
59
+ ## Accessibility
60
+
61
+ - Title and description carry the meaning, so the illustration is never the only explanation
62
+ - Text holds its contrast against the surface behind it, including on tinted backgrounds
63
+ - The action is a comfortable target and keeps a visible focus state
64
+ - Media, title, description and action follow one another in reading order
65
+ - The state stays legible when the panel it fills is narrow
66
+ - Nothing relies on colour to separate a neutral empty state from a failure