@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
@@ -4,6 +4,16 @@ import { ref } from 'vue';
4
4
  import UiLabel from './UiLabel.vue';
5
5
  import { UiInput } from '../UiInput';
6
6
  import { UiCheckbox } from '../UiCheckbox';
7
+ import {
8
+ accessibilityRequirementsTemplate,
9
+ designNotesStory,
10
+ guidanceLinks,
11
+ guidanceSectionClass,
12
+ parseGuidance,
13
+ } from '../../../.storybook/guidance';
14
+ import guidanceMarkdown from './UiLabel.guidance.md?raw';
15
+
16
+ const guidance = parseGuidance(guidanceMarkdown);
7
17
 
8
18
  /**
9
19
  * UiLabel provides accessible text labels for form elements. Use to identify
@@ -19,6 +29,9 @@ const meta: Meta<typeof UiLabel> = {
19
29
  description: 'The id of the form element this label is associated with',
20
30
  },
21
31
  },
32
+ parameters: {
33
+ docs: { links: guidanceLinks(guidance) },
34
+ },
22
35
  };
23
36
 
24
37
  export default meta;
@@ -88,6 +101,156 @@ export const Default: Story = {
88
101
  },
89
102
  };
90
103
 
104
+ /**
105
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
106
+ */
107
+ export const DesignNotes: Story = {
108
+ ...designNotesStory(guidance),
109
+ tags: ['!autodocs'],
110
+ };
111
+
112
+ /**
113
+ * Accessibility guidance for associating a label with its control, marking
114
+ * required fields, disabled styling, and contrast.
115
+ */
116
+ export const Accessibility: Story = {
117
+ render: () => ({
118
+ components: { UiLabel, UiInput, UiCheckbox },
119
+ setup() {
120
+ const accepted = ref(false);
121
+ const accessibleAccepted = ref(false);
122
+ return { accepted, accessibleAccepted };
123
+ },
124
+ template: `
125
+ <section class="${guidanceSectionClass}">
126
+ <div>
127
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
128
+ Accessibility
129
+ </h2>
130
+ </div>
131
+
132
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
133
+
134
+ <div class="flex flex-col gap-6">
135
+ <div class="flex flex-col gap-2">
136
+ <h3 class="body-m-medium text-content-on-surface-primary">
137
+ Point <code>for</code> at a real control
138
+ </h3>
139
+ <p class="body-m-regular text-content-on-surface-primary">
140
+ The <code>for</code> attribute must match the <code>id</code> of
141
+ an existing form element. That association is what gives the
142
+ control its accessible name and what makes clicking the label
143
+ focus it. A <code>for</code> that resolves to nothing looks
144
+ identical on screen while labelling nothing at all.
145
+ </p>
146
+ </div>
147
+
148
+ <div class="flex flex-col gap-2">
149
+ <h3 class="body-m-medium text-content-on-surface-primary">
150
+ Mark required on the control
151
+ </h3>
152
+ <p class="body-m-regular text-content-on-surface-primary">
153
+ Put <code>required</code> on the input so the state is announced,
154
+ and mark any asterisk <code>aria-hidden="true"</code>. A red
155
+ <code>*</code> on its own is colour-dependent (WCAG 1.4.1), and
156
+ an unhidden one turns the accessible name into
157
+ "Username star".
158
+ </p>
159
+ </div>
160
+
161
+ <div class="flex flex-col gap-2">
162
+ <h3 class="body-m-medium text-content-on-surface-primary">
163
+ Don't put controls inside the label
164
+ </h3>
165
+ <p class="body-m-regular text-content-on-surface-primary">
166
+ Keep the label to text. Nesting a button or link inside it
167
+ creates a control whose activation is ambiguous and can swallow
168
+ clicks meant for the field. Place related actions as siblings
169
+ instead.
170
+ </p>
171
+ </div>
172
+
173
+ <div class="flex flex-col gap-2">
174
+ <h3 class="body-m-medium text-content-on-surface-primary">
175
+ Disabled needs the <code>group</code> class
176
+ </h3>
177
+ <p class="body-m-regular text-content-on-surface-primary">
178
+ The label dims itself through
179
+ <code>group-data-[disabled=true]</code>, which only matches an
180
+ ancestor carrying the <code>group</code> class. Set
181
+ <code>group</code> alongside <code>data-disabled="true"</code>,
182
+ and always disable the control itself — the dimmed label is a
183
+ visual cue, not something assistive tech reports.
184
+ </p>
185
+ </div>
186
+
187
+ <div class="flex flex-col gap-2">
188
+ <h3 class="body-m-medium text-content-on-surface-primary">
189
+ Enable accessibility theme
190
+ </h3>
191
+ <p class="body-m-regular text-content-on-surface-primary">
192
+ When accessibility is required, enable our accessibility theme.
193
+ This increases contrast and makes sure there are no color
194
+ contrast issues.
195
+ </p>
196
+ </div>
197
+ </div>
198
+
199
+ <div class="grid gap-4 md:grid-cols-2">
200
+ <div class="flex flex-col gap-3">
201
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
202
+ Default
203
+ </h3>
204
+ <div class="flex flex-col gap-4 border border-border-surface-default p-6">
205
+ <div class="grid items-center gap-1.5">
206
+ <UiLabel for="a11y-email">Email</UiLabel>
207
+ <UiInput id="a11y-email" name="a11y-email" type="email" />
208
+ </div>
209
+ <div class="flex items-center gap-x-2">
210
+ <UiCheckbox id="a11y-terms" name="a11y-terms" v-model="accepted" />
211
+ <UiLabel for="a11y-terms">Accept terms</UiLabel>
212
+ </div>
213
+ </div>
214
+ </div>
215
+
216
+ <div class="accessible-theme flex flex-col gap-3">
217
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
218
+ Accessible
219
+ </h3>
220
+ <div class="flex flex-col gap-4 border border-border-surface-default p-6">
221
+ <div class="grid items-center gap-1.5">
222
+ <UiLabel for="a11y-email-accessible">Email</UiLabel>
223
+ <UiInput id="a11y-email-accessible" name="a11y-email-accessible" type="email" />
224
+ </div>
225
+ <div class="flex items-center gap-x-2">
226
+ <UiCheckbox
227
+ id="a11y-terms-accessible"
228
+ name="a11y-terms-accessible"
229
+ v-model="accessibleAccepted"
230
+ />
231
+ <UiLabel for="a11y-terms-accessible">Accept terms</UiLabel>
232
+ </div>
233
+ </div>
234
+ </div>
235
+ </div>
236
+ </section>
237
+ `,
238
+ }),
239
+ tags: ['!autodocs'],
240
+ parameters: {
241
+ surface: 'primary',
242
+ a11y: { test: 'off' },
243
+ chromatic: {
244
+ disableSnapshot: true,
245
+ },
246
+ docs: {
247
+ canvas: {
248
+ sourceState: 'none',
249
+ },
250
+ },
251
+ },
252
+ };
253
+
91
254
  const withInputTemplateSource = `<script setup lang="ts">
92
255
  import { UiLabel, UiInput } from '@aleph-alpha/ui-library'
93
256
  </script>
@@ -351,145 +514,6 @@ export const RequiredField: Story = {
351
514
  },
352
515
  };
353
516
 
354
- /**
355
- * Accessibility guidance for associating a label with its control, marking
356
- * required fields, disabled styling, and contrast.
357
- */
358
- export const Accessibility: Story = {
359
- render: () => ({
360
- components: { UiLabel, UiInput, UiCheckbox },
361
- setup() {
362
- const accepted = ref(false);
363
- const accessibleAccepted = ref(false);
364
- return { accepted, accessibleAccepted };
365
- },
366
- template: `
367
- <section class="flex flex-col gap-6 p-4">
368
- <div>
369
- <h2 class="heading-m font-bold text-content-on-surface-primary">
370
- Accessibility
371
- </h2>
372
- </div>
373
-
374
- <div class="flex flex-col gap-6">
375
- <div class="flex flex-col gap-2">
376
- <h3 class="body-m-medium text-content-on-surface-primary">
377
- Point <code>for</code> at a real control
378
- </h3>
379
- <p class="body-m-regular text-content-on-surface-primary">
380
- The <code>for</code> attribute must match the <code>id</code> of
381
- an existing form element. That association is what gives the
382
- control its accessible name and what makes clicking the label
383
- focus it. A <code>for</code> that resolves to nothing looks
384
- identical on screen while labelling nothing at all.
385
- </p>
386
- </div>
387
-
388
- <div class="flex flex-col gap-2">
389
- <h3 class="body-m-medium text-content-on-surface-primary">
390
- Mark required on the control
391
- </h3>
392
- <p class="body-m-regular text-content-on-surface-primary">
393
- Put <code>required</code> on the input so the state is announced,
394
- and mark any asterisk <code>aria-hidden="true"</code>. A red
395
- <code>*</code> on its own is colour-dependent (WCAG 1.4.1), and
396
- an unhidden one turns the accessible name into
397
- "Username star".
398
- </p>
399
- </div>
400
-
401
- <div class="flex flex-col gap-2">
402
- <h3 class="body-m-medium text-content-on-surface-primary">
403
- Don't put controls inside the label
404
- </h3>
405
- <p class="body-m-regular text-content-on-surface-primary">
406
- Keep the label to text. Nesting a button or link inside it
407
- creates a control whose activation is ambiguous and can swallow
408
- clicks meant for the field. Place related actions as siblings
409
- instead.
410
- </p>
411
- </div>
412
-
413
- <div class="flex flex-col gap-2">
414
- <h3 class="body-m-medium text-content-on-surface-primary">
415
- Disabled needs the <code>group</code> class
416
- </h3>
417
- <p class="body-m-regular text-content-on-surface-primary">
418
- The label dims itself through
419
- <code>group-data-[disabled=true]</code>, which only matches an
420
- ancestor carrying the <code>group</code> class. Set
421
- <code>group</code> alongside <code>data-disabled="true"</code>,
422
- and always disable the control itself — the dimmed label is a
423
- visual cue, not something assistive tech reports.
424
- </p>
425
- </div>
426
-
427
- <div class="flex flex-col gap-2">
428
- <h3 class="body-m-medium text-content-on-surface-primary">
429
- Enable accessibility theme
430
- </h3>
431
- <p class="body-m-regular text-content-on-surface-primary">
432
- When accessibility is required, enable our accessibility theme.
433
- This increases contrast and makes sure there are no color
434
- contrast issues.
435
- </p>
436
- </div>
437
- </div>
438
-
439
- <div class="grid gap-4 md:grid-cols-2">
440
- <div class="flex flex-col gap-3">
441
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
442
- Default
443
- </h3>
444
- <div class="flex flex-col gap-4 border border-border-surface-default p-6">
445
- <div class="grid items-center gap-1.5">
446
- <UiLabel for="a11y-email">Email</UiLabel>
447
- <UiInput id="a11y-email" name="a11y-email" type="email" />
448
- </div>
449
- <div class="flex items-center gap-x-2">
450
- <UiCheckbox id="a11y-terms" name="a11y-terms" v-model="accepted" />
451
- <UiLabel for="a11y-terms">Accept terms</UiLabel>
452
- </div>
453
- </div>
454
- </div>
455
-
456
- <div class="accessible-theme flex flex-col gap-3">
457
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
458
- Accessible
459
- </h3>
460
- <div class="flex flex-col gap-4 border border-border-surface-default p-6">
461
- <div class="grid items-center gap-1.5">
462
- <UiLabel for="a11y-email-accessible">Email</UiLabel>
463
- <UiInput id="a11y-email-accessible" name="a11y-email-accessible" type="email" />
464
- </div>
465
- <div class="flex items-center gap-x-2">
466
- <UiCheckbox
467
- id="a11y-terms-accessible"
468
- name="a11y-terms-accessible"
469
- v-model="accessibleAccepted"
470
- />
471
- <UiLabel for="a11y-terms-accessible">Accept terms</UiLabel>
472
- </div>
473
- </div>
474
- </div>
475
- </div>
476
- </section>
477
- `,
478
- }),
479
- tags: ['!autodocs'],
480
- parameters: {
481
- a11y: { test: 'off' },
482
- chromatic: {
483
- disableSnapshot: true,
484
- },
485
- docs: {
486
- canvas: {
487
- sourceState: 'none',
488
- },
489
- },
490
- },
491
- };
492
-
493
517
  /*
494
518
  * ─────────────────────────────────────────────────────────────────────────────
495
519
  * Interaction & accessibility tests (play functions)