@aleph-alpha/ui-library 7.0.1 → 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 (115) hide show
  1. package/dist/system/icons/story-sidebar-icons.json +74 -17
  2. package/dist/system/lib.js +8 -5
  3. package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
  4. package/dist/system/story-sidebar-icons.json +74 -17
  5. package/package.json +8 -3
  6. package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
  7. package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
  8. package/src/components/UiAlert/UiAlert.guidance.md +66 -0
  9. package/src/components/UiAlert/UiAlert.stories.ts +167 -143
  10. package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
  11. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
  12. package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
  13. package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
  14. package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
  15. package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
  16. package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
  17. package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
  18. package/src/components/UiBadge/UiBadge.guidance.md +65 -0
  19. package/src/components/UiBadge/UiBadge.stories.ts +325 -0
  20. package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
  21. package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
  22. package/src/components/UiButton/UiButton.stories.ts +5 -2
  23. package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
  24. package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
  25. package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
  26. package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
  27. package/src/components/UiCard/UiCard.guidance.md +65 -0
  28. package/src/components/UiCard/UiCard.stories.ts +393 -0
  29. package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
  30. package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
  31. package/src/components/UiChip/UiChip.guidance.md +64 -0
  32. package/src/components/UiChip/UiChip.stories.ts +162 -138
  33. package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
  34. package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
  35. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
  36. package/src/components/UiDialog/UiDialog.guidance.md +66 -0
  37. package/src/components/UiDialog/UiDialog.stories.ts +90 -66
  38. package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
  39. package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
  40. package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
  41. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +127 -86
  42. package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
  43. package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
  44. package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
  45. package/src/components/UiField/UiField.guidance.md +63 -0
  46. package/src/components/UiField/UiField.stories.ts +90 -113
  47. package/src/components/UiFileType/UiFileType.stories.ts +254 -0
  48. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
  49. package/src/components/UiIcon/UiIcon.stories.ts +256 -1
  50. package/src/components/UiInput/UiInput.guidance.md +64 -0
  51. package/src/components/UiInput/UiInput.stories.ts +132 -80
  52. package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
  53. package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
  54. package/src/components/UiItem/UiItem.guidance.md +66 -0
  55. package/src/components/UiItem/UiItem.stories.ts +81 -28
  56. package/src/components/UiKbd/UiKbd.guidance.md +65 -0
  57. package/src/components/UiKbd/UiKbd.stories.ts +373 -3
  58. package/src/components/UiLabel/UiLabel.guidance.md +65 -0
  59. package/src/components/UiLabel/UiLabel.stories.ts +163 -139
  60. package/src/components/UiListbox/UiListbox.stories.ts +197 -195
  61. package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
  62. package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
  63. package/src/components/UiPopover/UiPopover.guidance.md +65 -0
  64. package/src/components/UiPopover/UiPopover.stories.ts +115 -91
  65. package/src/components/UiProgress/UiProgress.guidance.md +65 -0
  66. package/src/components/UiProgress/UiProgress.stories.ts +300 -0
  67. package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
  68. package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
  69. package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
  70. package/src/components/UiResizable/UiResizable.guidance.md +65 -0
  71. package/src/components/UiResizable/UiResizable.stories.ts +176 -152
  72. package/src/components/UiSelect/UiSelect.guidance.md +66 -0
  73. package/src/components/UiSelect/UiSelect.stories.ts +150 -126
  74. package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
  75. package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
  76. package/src/components/UiSheet/UiSheet.guidance.md +66 -0
  77. package/src/components/UiSheet/UiSheet.stories.ts +194 -170
  78. package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
  79. package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
  80. package/src/components/UiSlider/UiSlider.guidance.md +66 -0
  81. package/src/components/UiSlider/UiSlider.stories.ts +150 -126
  82. package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
  83. package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
  84. package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
  85. package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
  86. package/src/components/UiStepper/UiStepper.guidance.md +66 -0
  87. package/src/components/UiStepper/UiStepper.stories.ts +142 -124
  88. package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
  89. package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
  90. package/src/components/UiTable/UiTable.guidance.md +66 -0
  91. package/src/components/UiTable/UiTable.stories.ts +530 -12
  92. package/src/components/UiTabs/UiTabs.guidance.md +66 -0
  93. package/src/components/UiTabs/UiTabs.stories.ts +174 -150
  94. package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
  95. package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
  96. package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
  97. package/src/components/UiToggle/UiToggle.guidance.md +66 -0
  98. package/src/components/UiToggle/UiToggle.stories.ts +183 -159
  99. package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
  100. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
  101. package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
  102. package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
  103. package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
  104. package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
  105. package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
  106. package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
  107. package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
  108. package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
  109. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
  110. package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
  111. package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
  112. package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
  113. package/src/patterns/UiPlaceholder/types.ts +1 -0
  114. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +74 -72
  115. package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
@@ -3,6 +3,16 @@ import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
3
3
  import UiTooltip from './UiTooltip.vue';
4
4
  import { UiButton } from '@/components/UiButton';
5
5
  import { UiIcon } from '@/components/UiIcon';
6
+ import {
7
+ accessibilityRequirementsTemplate,
8
+ designNotesStory,
9
+ guidanceLinks,
10
+ guidanceSectionClass,
11
+ parseGuidance,
12
+ } from '../../../.storybook/guidance';
13
+ import guidanceMarkdown from './UiTooltip.guidance.md?raw';
14
+
15
+ const guidance = parseGuidance(guidanceMarkdown);
6
16
 
7
17
  /**
8
18
  * UiTooltip is a non-modal text hint that appears next to its trigger on hover or focus.
@@ -49,6 +59,9 @@ const meta: Meta<typeof UiTooltip> = {
49
59
  delayDuration: 500,
50
60
  disabled: false,
51
61
  },
62
+ parameters: {
63
+ docs: { links: guidanceLinks(guidance) },
64
+ },
52
65
  };
53
66
 
54
67
  export default meta;
@@ -122,6 +135,83 @@ export const Default: Story = {
122
135
  },
123
136
  };
124
137
 
138
+ /**
139
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
140
+ */
141
+ export const DesignNotes: Story = {
142
+ ...designNotesStory(guidance),
143
+ tags: ['!autodocs'],
144
+ };
145
+
146
+ /**
147
+ * Accessibility guidance for labelled triggers, tooltip naming, and contrast.
148
+ */
149
+ export const Accessibility: Story = {
150
+ render: () => ({
151
+ components: { UiTooltip, UiButton },
152
+ template: `
153
+ <section class="${guidanceSectionClass}">
154
+ <div>
155
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
156
+ Accessibility
157
+ </h2>
158
+ </div>
159
+
160
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
161
+
162
+ <div class="flex flex-col gap-6">
163
+ <div class="flex flex-col gap-2">
164
+ <h3 class="body-m-medium text-content-on-surface-primary">
165
+ Enable accessibility theme
166
+ </h3>
167
+ <p class="body-m-regular text-content-on-surface-primary">
168
+ When accessibility is required, enable our accessibility theme. This
169
+ increases contrast and ensures there are no color contrast issues.
170
+ </p>
171
+ </div>
172
+ </div>
173
+
174
+ <div class="grid gap-4 md:grid-cols-2">
175
+ <div class="flex flex-col gap-3">
176
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
177
+ Default
178
+ </h3>
179
+ <div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
180
+ <UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
181
+ <UiButton>Hover me</UiButton>
182
+ </UiTooltip>
183
+ </div>
184
+ </div>
185
+
186
+ <div class="accessible-theme flex flex-col gap-3">
187
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
188
+ Accessible
189
+ </h3>
190
+ <div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
191
+ <UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
192
+ <UiButton>Hover me</UiButton>
193
+ </UiTooltip>
194
+ </div>
195
+ </div>
196
+ </div>
197
+ </section>
198
+ `,
199
+ }),
200
+ tags: ['!autodocs'],
201
+ parameters: {
202
+ surface: 'primary',
203
+ a11y: { test: 'off' },
204
+ chromatic: {
205
+ disableSnapshot: true,
206
+ },
207
+ docs: {
208
+ canvas: {
209
+ sourceState: 'none',
210
+ },
211
+ },
212
+ },
213
+ };
214
+
125
215
  /**
126
216
  * Tooltip with an icon-only `UiButton`.
127
217
  */
@@ -599,72 +689,6 @@ export const CustomOffset: Story = {
599
689
  }),
600
690
  };
601
691
 
602
- /**
603
- * Accessibility guidance for labelled triggers, tooltip naming, and contrast.
604
- */
605
- export const Accessibility: Story = {
606
- render: () => ({
607
- components: { UiTooltip, UiButton },
608
- template: `
609
- <section class="flex flex-col gap-6 p-4">
610
- <div>
611
- <h2 class="heading-m font-bold text-content-on-surface-primary">
612
- Accessibility
613
- </h2>
614
- </div>
615
-
616
- <div class="flex flex-col gap-6">
617
- <div class="flex flex-col gap-2">
618
- <h3 class="body-m-medium text-content-on-surface-primary">
619
- Enable accessibility theme
620
- </h3>
621
- <p class="body-m-regular text-content-on-surface-primary">
622
- When accessibility is required, enable our accessibility theme. This
623
- increases contrast and ensures there are no color contrast issues.
624
- </p>
625
- </div>
626
- </div>
627
-
628
- <div class="grid gap-4 md:grid-cols-2">
629
- <div class="flex flex-col gap-3">
630
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
631
- Default
632
- </h3>
633
- <div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
634
- <UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
635
- <UiButton>Hover me</UiButton>
636
- </UiTooltip>
637
- </div>
638
- </div>
639
-
640
- <div class="accessible-theme flex flex-col gap-3">
641
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
642
- Accessible
643
- </h3>
644
- <div class="flex min-h-32 items-center justify-center border border-border-surface-default p-10">
645
- <UiTooltip content="This is a helpful tooltip" :open="true" :delay-duration="0">
646
- <UiButton>Hover me</UiButton>
647
- </UiTooltip>
648
- </div>
649
- </div>
650
- </div>
651
- </section>
652
- `,
653
- }),
654
- tags: ['!autodocs'],
655
- parameters: {
656
- a11y: { test: 'off' },
657
- chromatic: {
658
- disableSnapshot: true,
659
- },
660
- docs: {
661
- canvas: {
662
- sourceState: 'none',
663
- },
664
- },
665
- },
666
- };
667
-
668
692
  /*
669
693
  * ─────────────────────────────────────────────────────────────────────────────
670
694
  * Interaction & accessibility tests (play functions)
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29194:69848'
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 Data Table component presents a set of rows the user works with — filtering, sorting, choosing columns and acting on selections. The table is the task, not a way of laying out a page.
10
+
11
+ Use it where people come to interrogate data. When the rows only need reading, Table is lighter and quieter.
12
+
13
+ ### The row is the unit
14
+
15
+ Everything is organised around the row:
16
+
17
+ - One row is one record, always
18
+ - Each column holds one kind of value, aligned by type
19
+ - Row actions sit in the same column on every row
20
+ - Selection persists while the user filters
21
+
22
+ ### Controls above, data below
23
+
24
+ The controls belong in a fixed band at the top:
25
+
26
+ 1. Search or filter field, narrowing the rows
27
+ 2. Filters, for the dimensions the data is questioned by
28
+ 3. Column control, for what the user wants to see
29
+ 4. The table itself, unchanged in structure by any of them
30
+
31
+ ### Consistency
32
+
33
+ Every data table is built from the same parts:
34
+
35
+ - Data table, with a header row and body rows
36
+ - Filter field and filter controls
37
+ - Column visibility control
38
+ - Row selection, and a count of what is selected
39
+ - Status and value cells, formatted by type
40
+
41
+ ## Do
42
+
43
+ - Right-align numbers and keep decimal places consistent down a column
44
+ - Keep row actions in the same column on every row
45
+ - Say how many rows match once a filter is applied
46
+ - Keep selection while the user filters, and show the count
47
+ - Put the controls in a fixed band above the table
48
+ - Use a status badge with a word, so state is readable
49
+
50
+ ## Don't
51
+
52
+ - Mix two kinds of value in one column
53
+ - Let column widths shift as the user filters
54
+ - Hide the number of matching rows
55
+ - Put a different set of actions on different rows
56
+ - Use a data table where the rows are only read — use Table
57
+ - Rely on row colour alone to convey status
58
+
59
+ ## Accessibility
60
+
61
+ - Status is carried by a word or icon in the cell, never by row colour alone
62
+ - The header row is clearly distinguishable from the body, by weight and surface
63
+ - Sort direction is shown by an arrow's direction, not by a colour change
64
+ - Row hover and row selection are distinguishable from each other
65
+ - Column widths hold steady as data changes, so the reader's place is not lost
66
+ - Row actions and checkboxes are comfortable targets even at the tightest row height
@@ -43,6 +43,16 @@ import {
43
43
  MoreHorizontalIcon,
44
44
  XIcon,
45
45
  } from '@/icons/lucide';
46
+ import {
47
+ accessibilityRequirementsTemplate,
48
+ designNotesStory,
49
+ guidanceLinks,
50
+ guidanceSectionClass,
51
+ parseGuidance,
52
+ } from '../../../.storybook/guidance';
53
+ import guidanceMarkdown from './UiDataTable.guidance.md?raw';
54
+
55
+ const guidance = parseGuidance(guidanceMarkdown);
46
56
 
47
57
  // Basic columns
48
58
  const basicColumns: ColumnDef<Payment>[] = [
@@ -184,6 +194,7 @@ const meta = {
184
194
  tags: ['autodocs'],
185
195
  parameters: {
186
196
  docs: {
197
+ links: guidanceLinks(guidance),
187
198
  description: {
188
199
  component:
189
200
  'A powerful data table component built with TanStack Table and Vue 3. Supports sorting, pagination, filtering, and row selection. Use `UiDataTable` for the core table, `UiDataTablePagination` for pagination controls, and `UiDataTableToolbar` for search and filters.',
@@ -944,6 +955,172 @@ export const Basic: Story = {
944
955
  }),
945
956
  };
946
957
 
958
+ /**
959
+ * Usage, guidelines, and do's and don'ts from the Figma documentation.
960
+ */
961
+ export const DesignNotes: Story = {
962
+ ...designNotesStory(guidance),
963
+ tags: ['!autodocs'],
964
+ };
965
+
966
+ /**
967
+ * Accessibility guidance for data tables: descriptive headers, labelled sort
968
+ * controls and selection checkboxes, and sufficient contrast.
969
+ */
970
+ export const Accessibility: Story = {
971
+ tags: ['!autodocs'],
972
+ parameters: {
973
+ surface: 'primary',
974
+ a11y: { test: 'off' },
975
+ chromatic: { disableSnapshot: true },
976
+ docs: {
977
+ canvas: {
978
+ sourceState: 'none',
979
+ },
980
+ },
981
+ },
982
+ render: () => ({
983
+ components: { UiDataTable },
984
+ setup() {
985
+ return { columns: basicColumns, data: a11yTestData };
986
+ },
987
+ template: `
988
+ <section class="${guidanceSectionClass}">
989
+ <div>
990
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
991
+ Accessibility
992
+ </h2>
993
+ </div>
994
+
995
+ ${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
996
+
997
+ <div class="flex flex-col gap-6">
998
+ <div class="flex flex-col gap-2">
999
+ <h3 class="body-m-medium text-content-on-surface-primary">
1000
+ Give every column a clear, unique header
1001
+ </h3>
1002
+ <p class="body-m-regular text-content-on-surface-primary">
1003
+ Column headers are exposed as <code>columnheader</code> cells and
1004
+ become the accessible name for the data in that column. Keep them
1005
+ concise and descriptive so screen-reader users can understand the
1006
+ table when navigating cell by cell.
1007
+ </p>
1008
+ </div>
1009
+
1010
+ <div class="flex flex-col gap-2">
1011
+ <h3 class="body-m-medium text-content-on-surface-primary">
1012
+ Label sort controls and selection checkboxes
1013
+ </h3>
1014
+ <p class="body-m-regular text-content-on-surface-primary">
1015
+ Sortable headers use <code>UiDataTableColumnHeader</code>, whose
1016
+ button announces the column and its current sort state (for
1017
+ example, "Status, sorted ascending"). Selection checkboxes need a
1018
+ per-row <code>aria-label</code> such as "Select row" so their
1019
+ purpose is clear out of context.
1020
+ </p>
1021
+ </div>
1022
+
1023
+ <div class="flex flex-col gap-2">
1024
+ <h3 class="body-m-medium text-content-on-surface-primary">
1025
+ Expandable rows
1026
+ </h3>
1027
+ <p class="body-m-regular text-content-on-surface-primary">
1028
+ Give the expand toggle a real button with an
1029
+ <code>aria-expanded</code> state and a label that reflects the
1030
+ action ("Expand row" / "Collapse row"). The expanded content is
1031
+ rendered in its own table row rather than overlaid, so the table
1032
+ structure stays valid for browsers and screen readers.
1033
+ </p>
1034
+ </div>
1035
+
1036
+ <div class="flex flex-col gap-2">
1037
+ <h3 class="body-m-medium text-content-on-surface-primary">
1038
+ Column visibility checklist
1039
+ </h3>
1040
+ <p class="body-m-regular text-content-on-surface-primary">
1041
+ The column menu exposes each column as a checkable menu item so
1042
+ assistive tech announces its checked state and lets users toggle
1043
+ columns from the keyboard. Give the trigger a clear accessible
1044
+ label such as "Toggle columns" since its icon alone is not
1045
+ self-explanatory.
1046
+ </p>
1047
+ </div>
1048
+
1049
+ <div class="flex flex-col gap-2">
1050
+ <h3 class="body-m-medium text-content-on-surface-primary">
1051
+ Row actions and filter menus
1052
+ </h3>
1053
+ <p class="body-m-regular text-content-on-surface-primary">
1054
+ Row action and filter popovers are menus: the trigger needs an
1055
+ accessible name (for example "Open menu" or "Toggle Filters"),
1056
+ opens on Enter/Space, and its items are reachable with the arrow
1057
+ keys and dismissed with Escape. Keep filter fields inside the
1058
+ popover individually labelled so each control makes sense on its
1059
+ own.
1060
+ </p>
1061
+ </div>
1062
+
1063
+ <div class="flex flex-col gap-2">
1064
+ <h3 class="body-m-medium text-content-on-surface-primary">
1065
+ Draggable columns
1066
+ </h3>
1067
+ <p class="body-m-regular text-content-on-surface-primary">
1068
+ Reordering must not rely on a pointer alone. A draggable header is
1069
+ focusable and can be moved with the Arrow Left / Arrow Right keys,
1070
+ and a focus indicator marks the column being moved so keyboard and
1071
+ low-vision users can follow the change.
1072
+ </p>
1073
+ </div>
1074
+
1075
+ <div class="flex flex-col gap-2">
1076
+ <h3 class="body-m-medium text-content-on-surface-primary">
1077
+ Clickable rows and pagination
1078
+ </h3>
1079
+ <p class="body-m-regular text-content-on-surface-primary">
1080
+ When rows are clickable, keep the real action on a focusable
1081
+ control inside the row so it is keyboard operable, and let clicks
1082
+ on nested buttons, links, or checkboxes take priority over the row
1083
+ handler. Pagination controls carry descriptive labels ("Go to
1084
+ next page") and announce the current page and selection count.
1085
+ </p>
1086
+ </div>
1087
+
1088
+ <div class="flex flex-col gap-2">
1089
+ <h3 class="body-m-medium text-content-on-surface-primary">
1090
+ Enable the accessibility theme
1091
+ </h3>
1092
+ <p class="body-m-regular text-content-on-surface-primary">
1093
+ When accessibility is required, enable our accessibility theme. It
1094
+ increases contrast so table text and controls meet color-contrast
1095
+ requirements.
1096
+ </p>
1097
+ </div>
1098
+ </div>
1099
+
1100
+ <div class="grid gap-4 md:grid-cols-2">
1101
+ <div class="flex flex-col gap-3">
1102
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
1103
+ Default
1104
+ </h3>
1105
+ <div class="border border-border-surface-default p-4">
1106
+ <UiDataTable :columns="columns" :data="data" />
1107
+ </div>
1108
+ </div>
1109
+
1110
+ <div class="accessible-theme flex flex-col gap-3">
1111
+ <h3 class="label-m-medium text-center text-content-on-surface-primary">
1112
+ Accessible
1113
+ </h3>
1114
+ <div class="border border-border-surface-default p-4">
1115
+ <UiDataTable :columns="columns" :data="data" />
1116
+ </div>
1117
+ </div>
1118
+ </div>
1119
+ </section>
1120
+ `,
1121
+ }),
1122
+ };
1123
+
947
1124
  /**
948
1125
  * Table with sortable columns using UiDataTableColumnHeader.
949
1126
  *
@@ -2573,161 +2750,6 @@ const a11yTestData: Payment[] = [
2573
2750
  { id: '3', amount: 200, status: 'failed', email: 'bob@example.com' },
2574
2751
  ];
2575
2752
 
2576
- /**
2577
- * Accessibility guidance for data tables: descriptive headers, labelled sort
2578
- * controls and selection checkboxes, and sufficient contrast.
2579
- */
2580
- export const Accessibility: Story = {
2581
- tags: ['!autodocs'],
2582
- parameters: {
2583
- a11y: { test: 'off' },
2584
- chromatic: { disableSnapshot: true },
2585
- docs: {
2586
- canvas: {
2587
- sourceState: 'none',
2588
- },
2589
- },
2590
- },
2591
- render: () => ({
2592
- components: { UiDataTable },
2593
- setup() {
2594
- return { columns: basicColumns, data: a11yTestData };
2595
- },
2596
- template: `
2597
- <section class="flex flex-col gap-6 p-4">
2598
- <div>
2599
- <h2 class="heading-m font-bold text-content-on-surface-primary">
2600
- Accessibility
2601
- </h2>
2602
- </div>
2603
-
2604
- <div class="flex flex-col gap-6">
2605
- <div class="flex flex-col gap-2">
2606
- <h3 class="body-m-medium text-content-on-surface-primary">
2607
- Give every column a clear, unique header
2608
- </h3>
2609
- <p class="body-m-regular text-content-on-surface-primary">
2610
- Column headers are exposed as <code>columnheader</code> cells and
2611
- become the accessible name for the data in that column. Keep them
2612
- concise and descriptive so screen-reader users can understand the
2613
- table when navigating cell by cell.
2614
- </p>
2615
- </div>
2616
-
2617
- <div class="flex flex-col gap-2">
2618
- <h3 class="body-m-medium text-content-on-surface-primary">
2619
- Label sort controls and selection checkboxes
2620
- </h3>
2621
- <p class="body-m-regular text-content-on-surface-primary">
2622
- Sortable headers use <code>UiDataTableColumnHeader</code>, whose
2623
- button announces the column and its current sort state (for
2624
- example, "Status, sorted ascending"). Selection checkboxes need a
2625
- per-row <code>aria-label</code> such as "Select row" so their
2626
- purpose is clear out of context.
2627
- </p>
2628
- </div>
2629
-
2630
- <div class="flex flex-col gap-2">
2631
- <h3 class="body-m-medium text-content-on-surface-primary">
2632
- Expandable rows
2633
- </h3>
2634
- <p class="body-m-regular text-content-on-surface-primary">
2635
- Give the expand toggle a real button with an
2636
- <code>aria-expanded</code> state and a label that reflects the
2637
- action ("Expand row" / "Collapse row"). The expanded content is
2638
- rendered in its own table row rather than overlaid, so the table
2639
- structure stays valid for browsers and screen readers.
2640
- </p>
2641
- </div>
2642
-
2643
- <div class="flex flex-col gap-2">
2644
- <h3 class="body-m-medium text-content-on-surface-primary">
2645
- Column visibility checklist
2646
- </h3>
2647
- <p class="body-m-regular text-content-on-surface-primary">
2648
- The column menu exposes each column as a checkable menu item so
2649
- assistive tech announces its checked state and lets users toggle
2650
- columns from the keyboard. Give the trigger a clear accessible
2651
- label such as "Toggle columns" since its icon alone is not
2652
- self-explanatory.
2653
- </p>
2654
- </div>
2655
-
2656
- <div class="flex flex-col gap-2">
2657
- <h3 class="body-m-medium text-content-on-surface-primary">
2658
- Row actions and filter menus
2659
- </h3>
2660
- <p class="body-m-regular text-content-on-surface-primary">
2661
- Row action and filter popovers are menus: the trigger needs an
2662
- accessible name (for example "Open menu" or "Toggle Filters"),
2663
- opens on Enter/Space, and its items are reachable with the arrow
2664
- keys and dismissed with Escape. Keep filter fields inside the
2665
- popover individually labelled so each control makes sense on its
2666
- own.
2667
- </p>
2668
- </div>
2669
-
2670
- <div class="flex flex-col gap-2">
2671
- <h3 class="body-m-medium text-content-on-surface-primary">
2672
- Draggable columns
2673
- </h3>
2674
- <p class="body-m-regular text-content-on-surface-primary">
2675
- Reordering must not rely on a pointer alone. A draggable header is
2676
- focusable and can be moved with the Arrow Left / Arrow Right keys,
2677
- and a focus indicator marks the column being moved so keyboard and
2678
- low-vision users can follow the change.
2679
- </p>
2680
- </div>
2681
-
2682
- <div class="flex flex-col gap-2">
2683
- <h3 class="body-m-medium text-content-on-surface-primary">
2684
- Clickable rows and pagination
2685
- </h3>
2686
- <p class="body-m-regular text-content-on-surface-primary">
2687
- When rows are clickable, keep the real action on a focusable
2688
- control inside the row so it is keyboard operable, and let clicks
2689
- on nested buttons, links, or checkboxes take priority over the row
2690
- handler. Pagination controls carry descriptive labels ("Go to
2691
- next page") and announce the current page and selection count.
2692
- </p>
2693
- </div>
2694
-
2695
- <div class="flex flex-col gap-2">
2696
- <h3 class="body-m-medium text-content-on-surface-primary">
2697
- Enable the accessibility theme
2698
- </h3>
2699
- <p class="body-m-regular text-content-on-surface-primary">
2700
- When accessibility is required, enable our accessibility theme. It
2701
- increases contrast so table text and controls meet color-contrast
2702
- requirements.
2703
- </p>
2704
- </div>
2705
- </div>
2706
-
2707
- <div class="grid gap-4 md:grid-cols-2">
2708
- <div class="flex flex-col gap-3">
2709
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
2710
- Default
2711
- </h3>
2712
- <div class="border border-border-surface-default p-4">
2713
- <UiDataTable :columns="columns" :data="data" />
2714
- </div>
2715
- </div>
2716
-
2717
- <div class="accessible-theme flex flex-col gap-3">
2718
- <h3 class="label-m-medium text-center text-content-on-surface-primary">
2719
- Accessible
2720
- </h3>
2721
- <div class="border border-border-surface-default p-4">
2722
- <UiDataTable :columns="columns" :data="data" />
2723
- </div>
2724
- </div>
2725
- </div>
2726
- </section>
2727
- `,
2728
- }),
2729
- };
2730
-
2731
2753
  /**
2732
2754
  * The data table is fully keyboard operable: sortable headers are reachable
2733
2755
  * with `Tab` and cycle their sort direction with `Enter`.
@@ -0,0 +1,66 @@
1
+ ---
2
+ figma: '29194:69975'
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 Date Picker component pairs a field with a calendar. The user types the date when they know it, and opens the calendar when they need to see the month.
10
+
11
+ Use it in forms wherever a date is entered. The calendar alone is for choosing by sight; the field alone suits dates the user always knows, such as a birthday.
12
+
13
+ ### Both routes, one value
14
+
15
+ Typing and picking have to agree:
16
+
17
+ - The field shows the chosen date in the format the user types
18
+ - The calendar opens on the month of the current value
19
+ - Choosing a date closes the calendar and fills the field
20
+ - The expected format is shown before the user types, not after they fail
21
+
22
+ ### Show the constraints
23
+
24
+ A date field usually has rules, so make them visible:
25
+
26
+ 1. Unavailable dates are shown as unavailable in the calendar
27
+ 2. The field states the format it expects
28
+ 3. An out-of-range date is explained in words, next to the field
29
+ 4. Presets are offered where the same ranges are picked repeatedly
30
+
31
+ ### Consistency
32
+
33
+ Every date picker is built from the same parts:
34
+
35
+ - Date picker, with the icon at the start, at the end, or with an input
36
+ - Date picker button, opening the calendar
37
+ - Calendar, for choosing by sight
38
+ - Time picker, where a time is needed alongside the date
39
+ - States: default, hover, focus, pressed and disabled
40
+
41
+ ## Do
42
+
43
+ - Let the user type the date as well as pick it
44
+ - Open the calendar on the month of the current value
45
+ - State the expected format before the user types
46
+ - Show unavailable dates in the calendar rather than rejecting them afterwards
47
+ - Offer presets where the same ranges recur
48
+ - Keep the icon on the same side throughout a product
49
+
50
+ ## Don't
51
+
52
+ - Force the user into the calendar to enter a date they know
53
+ - Open the calendar on today when a value is already set
54
+ - Explain the format only in an error
55
+ - Accept an out-of-range date and reject it on submit
56
+ - Move the icon between fields in the same form
57
+ - Use a date picker where only a month or a year is wanted
58
+
59
+ ## Accessibility
60
+
61
+ - The field keeps a visible focus state that is distinct from hover and pressed
62
+ - Opening the calendar does not cover the field, so the current value stays readable
63
+ - Unavailable dates carry a treatment beyond low contrast
64
+ - The expected format sits beside the field as help text, not only inside the placeholder
65
+ - Error text appears next to the field it belongs to and stays legible when it wraps
66
+ - The calendar trigger is a comfortable target, separate from the typing area