@aleph-alpha/ui-library 2.11.0 → 2.12.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 (150) hide show
  1. package/config.d.ts +8 -2
  2. package/config.js +85 -73
  3. package/dist/system/components/UiAutocomplete/types.d.ts +0 -1
  4. package/dist/system/components/UiDialog/UiDialogDescription.vue.d.ts +2 -1
  5. package/dist/system/components/UiDialog/UiDialogFooter.vue.d.ts +1 -2
  6. package/dist/system/components/UiDialog/UiDialogHeader.vue.d.ts +1 -2
  7. package/dist/system/components/UiDialog/UiDialogTitle.vue.d.ts +2 -1
  8. package/dist/system/components/UiDialog/types.d.ts +10 -4
  9. package/dist/system/components/UiDropdownMenu/UiDropdownMenuSub.vue.d.ts +3 -1
  10. package/dist/system/components/UiField/UiFieldError.vue.d.ts +8 -1
  11. package/dist/system/components/UiInput/UiInput.vue.d.ts +16 -1
  12. package/dist/system/components/UiStepper/UiStepperDescription.vue.d.ts +3 -1
  13. package/dist/system/components/UiStepper/UiStepperIndicator.vue.d.ts +3 -1
  14. package/dist/system/components/UiStepper/UiStepperItem.vue.d.ts +3 -1
  15. package/dist/system/components/UiTagsInput/types.d.ts +1 -2
  16. package/dist/system/components/core/accordion/AccordionItem.vue.d.ts +3 -1
  17. package/dist/system/components/core/calendar/CalendarHeading.vue.d.ts +2 -2
  18. package/dist/system/components/core/dropdown-menu/DropdownMenuSub.vue.d.ts +3 -1
  19. package/dist/system/components/core/range-calendar/RangeCalendarHeading.vue.d.ts +2 -2
  20. package/dist/system/components/core/stepper/StepperDescription.vue.d.ts +3 -1
  21. package/dist/system/components/core/stepper/StepperIndicator.vue.d.ts +3 -1
  22. package/dist/system/components/core/stepper/StepperItem.vue.d.ts +3 -1
  23. package/dist/system/index.d.ts +2 -1
  24. package/dist/system/lib/utils.d.ts +6 -0
  25. package/dist/system/lib.js +15498 -15548
  26. package/dist/system/patterns/UiSidebar/UiSidebarContent.vue.d.ts +1 -2
  27. package/dist/system/patterns/UiSidebar/UiSidebarFooter.vue.d.ts +1 -2
  28. package/dist/system/patterns/UiSidebar/UiSidebarGroupContent.vue.d.ts +1 -2
  29. package/dist/system/patterns/UiSidebar/UiSidebarInset.vue.d.ts +1 -2
  30. package/dist/system/patterns/UiSidebar/UiSidebarMenu.vue.d.ts +1 -2
  31. package/dist/system/patterns/UiSidebar/UiSidebarMenuItem.vue.d.ts +1 -2
  32. package/dist/system/patterns/UiSidebar/UiSidebarProvider.vue.d.ts +1 -2
  33. package/dist/system/patterns/UiSidebar/UiSidebarRail.vue.d.ts +1 -2
  34. package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +9 -9
  35. package/dist/system/patterns/UiSidebar/types.d.ts +8 -16
  36. package/dist/system/story-sidebar-icons.json +10 -0
  37. package/package.json +5 -2
  38. package/src/@types/shims-vue.d.ts +1 -1
  39. package/src/__tests__/test-utils.ts +1 -1
  40. package/src/components/UiAlertDialog/UiAlertDialogAction.vue +1 -1
  41. package/src/components/UiAlertDialog/UiAlertDialogCancel.vue +1 -1
  42. package/src/components/UiAlertDialog/UiAlertDialogContent.vue +4 -1
  43. package/src/components/UiAlertDialog/UiAlertDialogDescription.vue +1 -1
  44. package/src/components/UiAlertDialog/UiAlertDialogTitle.vue +1 -1
  45. package/src/components/UiAlertDialog/UiAlertDialogTrigger.vue +1 -1
  46. package/src/components/UiAutocomplete/types.ts +0 -1
  47. package/src/components/UiBadge/UiBadge.vue +1 -1
  48. package/src/components/UiBadge/constants.ts +1 -1
  49. package/src/components/UiBadge/types.ts +1 -1
  50. package/src/components/UiButton/UiButton.stories.ts +286 -198
  51. package/src/components/UiButton/mcp-docs.json +49 -0
  52. package/src/components/UiCalendar/UiCalendar.vue +2 -5
  53. package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +4 -2
  54. package/src/components/UiCheckbox/UiCheckbox.stories.ts +176 -2
  55. package/src/components/UiCheckbox/mcp-docs.json +36 -0
  56. package/src/components/UiChip/types.ts +1 -1
  57. package/src/components/UiDialog/UiDialogFooter.vue +0 -3
  58. package/src/components/UiDialog/UiDialogHeader.vue +0 -3
  59. package/src/components/UiDialog/types.ts +10 -4
  60. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +1 -1
  61. package/src/components/UiField/UiField.stories.ts +265 -3
  62. package/src/components/UiField/UiField.vue +9 -2
  63. package/src/components/UiField/UiFieldError.vue +3 -3
  64. package/src/components/UiField/mcp-docs.json +72 -0
  65. package/src/components/UiFileItem/UiFileItem.stories.ts +11 -11
  66. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +1 -1
  67. package/src/components/UiIcon/UiIcon.vue +3 -2
  68. package/src/components/UiInput/UiInput.vue +19 -3
  69. package/src/components/UiInput/mcp-docs.json +51 -0
  70. package/src/components/UiItem/UiItem.stories.ts +118 -2
  71. package/src/components/UiItem/__tests__/UiItem.test.ts +3 -5
  72. package/src/components/UiItem/mcp-docs.json +25 -0
  73. package/src/components/UiLabel/UiLabel.vue +1 -1
  74. package/src/components/UiListbox/UiListbox.vue +3 -6
  75. package/src/components/UiListbox/UiListboxFilter.vue +1 -1
  76. package/src/components/UiListbox/UiListboxItem.vue +1 -1
  77. package/src/components/UiProgress/UiProgress.vue +1 -1
  78. package/src/components/UiRadioGroup/UiRadioGroup.vue +1 -1
  79. package/src/components/UiRadioGroup/UiRadioGroupItem.vue +2 -2
  80. package/src/components/UiRadioGroup/__tests__/UiRadioGroup.test.ts +2 -2
  81. package/src/components/UiRangeCalendar/UiRangeCalendar.vue +2 -5
  82. package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +9 -6
  83. package/src/components/UiSelect/UiSelectContent.vue +2 -4
  84. package/src/components/UiSwitch/UiSwitch.vue +1 -1
  85. package/src/components/UiTagsInput/UiTagsInput.vue +1 -1
  86. package/src/components/UiTagsInput/UiTagsInputInput.vue +1 -1
  87. package/src/components/UiTagsInput/UiTagsInputItem.vue +1 -1
  88. package/src/components/UiTagsInput/types.ts +1 -4
  89. package/src/components/UiTooltip/UiTooltip.stories.ts +0 -8
  90. package/src/components/core/accordion/AccordionItem.vue +1 -1
  91. package/src/components/core/alert-dialog/AlertDialogContent.vue +1 -1
  92. package/src/components/core/badge/Badge.vue +2 -5
  93. package/src/components/core/calendar/CalendarHeading.vue +1 -1
  94. package/src/components/core/dropdown-menu/DropdownMenuSub.vue +1 -1
  95. package/src/components/core/item/index.ts +1 -1
  96. package/src/components/core/listbox/Listbox.vue +2 -5
  97. package/src/components/core/listbox/ListboxContent.vue +2 -5
  98. package/src/components/core/listbox/ListboxFilter.vue +2 -5
  99. package/src/components/core/listbox/ListboxGroup.vue +2 -5
  100. package/src/components/core/listbox/ListboxGroupLabel.vue +2 -5
  101. package/src/components/core/listbox/ListboxItem.vue +2 -5
  102. package/src/components/core/listbox/ListboxItemIndicator.vue +2 -5
  103. package/src/components/core/range-calendar/RangeCalendarHeading.vue +1 -1
  104. package/src/components/core/sidebar/SidebarContent.vue +4 -5
  105. package/src/components/core/sidebar/SidebarFooter.vue +4 -5
  106. package/src/components/core/sidebar/SidebarGroup.vue +4 -5
  107. package/src/components/core/sidebar/SidebarHeader.vue +4 -5
  108. package/src/components/core/sidebar/SidebarMenu.vue +4 -5
  109. package/src/components/core/sidebar/SidebarMenuAction.vue +1 -1
  110. package/src/components/core/sidebar/SidebarMenuButtonChild.vue +1 -1
  111. package/src/components/core/sidebar/SidebarMenuSkeleton.vue +1 -1
  112. package/src/components/core/sidebar/SidebarMenuSubButton.vue +1 -1
  113. package/src/components/core/sidebar/SidebarSeparator.vue +4 -5
  114. package/src/components/core/stepper/StepperDescription.vue +1 -1
  115. package/src/components/core/stepper/StepperIndicator.vue +1 -1
  116. package/src/components/core/stepper/StepperItem.vue +1 -1
  117. package/src/components/core/tags-input/TagsInput.vue +2 -5
  118. package/src/components/core/tags-input/TagsInputInput.vue +2 -5
  119. package/src/components/core/tags-input/TagsInputItem.vue +2 -5
  120. package/src/components/core/tags-input/TagsInputItemDelete.vue +2 -5
  121. package/src/components/core/tags-input/TagsInputItemText.vue +2 -5
  122. package/src/components/core/toggle/Toggle.vue +1 -1
  123. package/src/index.ts +30 -5
  124. package/src/lib/useDrag.ts +1 -0
  125. package/src/lib/utils.ts +12 -0
  126. package/src/patterns/UiDataTable/UiDataTable.mock.ts +13 -4
  127. package/src/patterns/UiDataTable/UiDataTable.vue +1 -0
  128. package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +11 -2
  129. package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +28 -39
  130. package/src/patterns/UiSidebar/UiSidebarContent.vue +0 -3
  131. package/src/patterns/UiSidebar/UiSidebarFooter.vue +0 -3
  132. package/src/patterns/UiSidebar/UiSidebarGroup.vue +4 -5
  133. package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +0 -3
  134. package/src/patterns/UiSidebar/UiSidebarHeader.vue +4 -5
  135. package/src/patterns/UiSidebar/UiSidebarInset.vue +0 -3
  136. package/src/patterns/UiSidebar/UiSidebarMenu.vue +0 -3
  137. package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -5
  138. package/src/patterns/UiSidebar/UiSidebarMenuItem.vue +0 -3
  139. package/src/patterns/UiSidebar/UiSidebarMenuSub.vue +4 -5
  140. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +4 -5
  141. package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +4 -5
  142. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +4 -5
  143. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +4 -5
  144. package/src/patterns/UiSidebar/UiSidebarProvider.vue +0 -3
  145. package/src/patterns/UiSidebar/UiSidebarRail.vue +0 -3
  146. package/src/patterns/UiSidebar/UiSidebarSub.vue +4 -5
  147. package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +21 -17
  148. package/src/patterns/UiSidebar/__tests__/UiSidebarMenuButton.test.ts +12 -10
  149. package/src/patterns/UiSidebar/types.ts +8 -8
  150. package/src/theme/Typography.stories.ts +3 -2
@@ -2,9 +2,12 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
2
  import UiCheckbox from './UiCheckbox.vue';
3
3
  import { ref } from 'vue';
4
4
 
5
+ const designStoryLink = '/?path=/docs/components-uicheckbox--design-notes';
6
+ const accessibilityStoryLink =
7
+ '/?path=/docs/components-uicheckbox--accessibility';
8
+
5
9
  /**
6
- * UiCheckbox is a binary form control that the user can toggle on or off, with an indeterminate intermediate state.
7
- * Use it for multi-select choices in forms, lists, and bulk actions; for instantly-applied preferences, prefer `UiSwitch`.
10
+ * A control that allows the user to toggle between checked and not checked.
8
11
  */
9
12
  const meta: Meta<typeof UiCheckbox> = {
10
13
  title: 'Components/UiCheckbox',
@@ -25,6 +28,22 @@ const meta: Meta<typeof UiCheckbox> = {
25
28
  disabled: false,
26
29
  required: false,
27
30
  },
31
+ parameters: {
32
+ docs: {
33
+ links: [
34
+ {
35
+ label: 'Designer docs',
36
+ href: designStoryLink,
37
+ icon: 'palette',
38
+ },
39
+ {
40
+ label: 'Accessibility',
41
+ href: accessibilityStoryLink,
42
+ icon: 'accessibility',
43
+ },
44
+ ],
45
+ },
46
+ },
28
47
  };
29
48
 
30
49
  export default meta;
@@ -73,6 +92,161 @@ export const Default: Story = {
73
92
  },
74
93
  };
75
94
 
95
+ /**
96
+ * Design guidance for choosing checkbox patterns and writing clear option labels.
97
+ */
98
+ export const DesignNotes: Story = {
99
+ render: () => ({
100
+ template: `
101
+ <section class="flex flex-col gap-8 p-4 bg-surface-secondary">
102
+ <div>
103
+ <h2 class="heading-m font-bold text-content-on-surface-primary">Do's and Don'ts</h2>
104
+ </div>
105
+
106
+ <div class="grid gap-8 md:grid-cols-2">
107
+ <div class="flex flex-col gap-3">
108
+ <h3 class="body-16-medium text-content-on-surface-primary">Do</h3>
109
+ <ul class="body-16-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
110
+ <li>Use checkboxes for independent choices</li>
111
+ <li>Allow multiple selections when appropriate</li>
112
+ <li>Write descriptive labels</li>
113
+ <li>Group related options together</li>
114
+ <li>Provide supporting descriptions when needed</li>
115
+ <li>Use indeterminate states for partial selection patterns</li>
116
+ </ul>
117
+ </div>
118
+
119
+ <div class="flex flex-col gap-3">
120
+ <h3 class="body-16-medium text-content-on-surface-primary">Don't</h3>
121
+ <ul class="body-16-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
122
+ <li>Use checkboxes when only one choice is allowed (use radio instead)</li>
123
+ <li>Present unrelated options in the same group</li>
124
+ <li>Use vague labels like "Enable" or "Yes"</li>
125
+ <li>Depend solely on color to communicate state</li>
126
+ </ul>
127
+ </div>
128
+ </div>
129
+ </section>
130
+ `,
131
+ }),
132
+ parameters: {
133
+ chromatic: {
134
+ disableSnapshot: true,
135
+ },
136
+ docs: {
137
+ canvas: {
138
+ sourceState: 'none',
139
+ },
140
+ },
141
+ },
142
+ };
143
+
144
+ /**
145
+ * Accessibility guidance for checkbox labels, descriptions, keyboard focus, and contrast.
146
+ */
147
+ export const Accessibility: Story = {
148
+ render: () => ({
149
+ components: { UiCheckbox },
150
+ setup() {
151
+ const defaultChecked = ref(true);
152
+ const accessibleChecked = ref(true);
153
+ return { defaultChecked, accessibleChecked };
154
+ },
155
+ template: `
156
+ <section class="flex flex-col gap-6 p-4">
157
+ <div>
158
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
159
+ Accessibility
160
+ </h2>
161
+ </div>
162
+
163
+ <div class="flex flex-col gap-6">
164
+ <div class="flex flex-col gap-2">
165
+ <h3 class="body-16-medium text-content-on-surface-primary">
166
+ Requirements
167
+ </h3>
168
+ <ul class="body-16-regular list-disc pl-5 text-content-on-surface-primary">
169
+ <li>Every checkbox has a visible label</li>
170
+ <li>Descriptions remain readable and associated with the field</li>
171
+ <li>Keyboard focus is correct in a checkbox group</li>
172
+ </ul>
173
+ </div>
174
+
175
+ <div class="flex flex-col gap-2">
176
+ <h3 class="body-16-medium text-content-on-surface-primary">
177
+ Enable accessibility theme
178
+ </h3>
179
+ <p class="body-16-regular text-content-on-surface-primary">
180
+ When accessibility is required, enable our accessibility theme. This
181
+ increases contrast and ensures there are no color contrast issues.
182
+ </p>
183
+ </div>
184
+ </div>
185
+
186
+ <div class="grid gap-4 md:grid-cols-2">
187
+ <div class="flex flex-col gap-3">
188
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
189
+ Default
190
+ </h3>
191
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
192
+ <div class="flex items-start gap-3">
193
+ <UiCheckbox
194
+ id="checkbox-accessibility-default"
195
+ v-model="defaultChecked"
196
+ name="checkbox-accessibility-default"
197
+ aria-describedby="checkbox-accessibility-default-description"
198
+ />
199
+ <div class="grid gap-1">
200
+ <label for="checkbox-accessibility-default" class="body-14-medium text-content-on-surface-primary">
201
+ Checkbox Text
202
+ </label>
203
+ <p id="checkbox-accessibility-default-description" class="body-14-regular text-content-on-surface-secondary">
204
+ This is a checkbox description.
205
+ </p>
206
+ </div>
207
+ </div>
208
+ </div>
209
+ </div>
210
+
211
+ <div class="accessible-theme flex flex-col gap-3">
212
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
213
+ Accessible
214
+ </h3>
215
+ <div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
216
+ <div class="flex items-start gap-3">
217
+ <UiCheckbox
218
+ id="checkbox-accessibility-accessible"
219
+ v-model="accessibleChecked"
220
+ name="checkbox-accessibility-accessible"
221
+ aria-describedby="checkbox-accessibility-accessible-description"
222
+ />
223
+ <div class="grid gap-1">
224
+ <label for="checkbox-accessibility-accessible" class="body-14-medium text-content-on-surface-primary">
225
+ Checkbox Text
226
+ </label>
227
+ <p id="checkbox-accessibility-accessible-description" class="body-14-regular text-content-on-surface-secondary">
228
+ This is a checkbox description.
229
+ </p>
230
+ </div>
231
+ </div>
232
+ </div>
233
+ </div>
234
+ </div>
235
+ </section>
236
+ `,
237
+ }),
238
+ parameters: {
239
+ chromatic: {
240
+ disableSnapshot: true,
241
+ },
242
+ docs: {
243
+ canvas: {
244
+ sourceState: 'none',
245
+ },
246
+ },
247
+ },
248
+ };
249
+
76
250
  const withDescriptionTemplateSource = `<script setup lang="ts">
77
251
  import { ref } from 'vue'
78
252
  import { UiCheckbox } from '@aleph-alpha/ui-library'
@@ -0,0 +1,36 @@
1
+ {
2
+ "designNotes": {
3
+ "title": "Do's and Don'ts",
4
+ "do": [
5
+ "Use checkboxes for independent choices",
6
+ "Allow multiple selections when appropriate",
7
+ "Write descriptive labels",
8
+ "Group related options together",
9
+ "Provide supporting descriptions when needed",
10
+ "Use indeterminate states for partial selection patterns"
11
+ ],
12
+ "dont": [
13
+ "Use checkboxes when only one choice is allowed (use radio instead)",
14
+ "Present unrelated options in the same group",
15
+ "Use vague labels like Enable or Yes",
16
+ "Depend solely on color to communicate state"
17
+ ]
18
+ },
19
+ "accessibility": {
20
+ "title": "Accessibility",
21
+ "sections": [
22
+ {
23
+ "title": "Requirements",
24
+ "items": [
25
+ "Every checkbox has a visible label",
26
+ "Descriptions remain readable and associated with the field",
27
+ "Keyboard focus is correct in a checkbox group"
28
+ ]
29
+ },
30
+ {
31
+ "title": "Enable accessibility theme",
32
+ "content": "When accessibility is required, enable the accessibility theme. This increases contrast and ensures there are no color contrast issues."
33
+ }
34
+ ]
35
+ }
36
+ }
@@ -1,4 +1,4 @@
1
- import { Component } from 'vue';
1
+ import { type Component } from 'vue';
2
2
 
3
3
  export type UiChipVariant = 'static' | 'selectable' | 'removable';
4
4
 
@@ -1,12 +1,9 @@
1
1
  <script setup lang="ts">
2
2
  import { DialogFooter as ShadcnDialogFooter } from '@/components/core/dialog';
3
- import type { UiDialogFooterProps } from './types';
4
3
 
5
4
  defineOptions({
6
5
  name: 'UiDialogFooter',
7
6
  });
8
-
9
- defineProps<UiDialogFooterProps>();
10
7
  </script>
11
8
 
12
9
  <template>
@@ -1,12 +1,9 @@
1
1
  <script setup lang="ts">
2
2
  import { DialogHeader as ShadcnDialogHeader } from '@/components/core/dialog';
3
- import type { UiDialogHeaderProps } from './types';
4
3
 
5
4
  defineOptions({
6
5
  name: 'UiDialogHeader',
7
6
  });
8
-
9
- defineProps<UiDialogHeaderProps>();
10
7
  </script>
11
8
 
12
9
  <template>
@@ -112,25 +112,31 @@ export type UiDialogContentEmits = DialogContentEmits;
112
112
  * @category Overlays
113
113
  * @useCases grouping title and description in a custom `#header` slot
114
114
  */
115
- export type UiDialogHeaderProps = {};
115
+ export type UiDialogHeaderProps = Record<string, never>;
116
116
 
117
117
  /**
118
118
  * Props for UiDialogFooter.
119
119
  * @category Overlays
120
120
  * @useCases action button rows in `#actions` or manual footer composition
121
121
  */
122
- export type UiDialogFooterProps = {};
122
+ export type UiDialogFooterProps = Record<string, never>;
123
123
 
124
124
  /**
125
125
  * Props for UiDialogTitle.
126
126
  * @category Overlays
127
127
  * @useCases accessible dialog titles in custom headers
128
128
  */
129
- export type UiDialogTitleProps = UiDialogSubComponentCommonProps & {};
129
+ export type UiDialogTitleProps = {
130
+ /** Render as a child element instead of wrapping. */
131
+ asChild?: UiDialogSubComponentCommonProps['asChild'];
132
+ };
130
133
 
131
134
  /**
132
135
  * Props for UiDialogDescription.
133
136
  * @category Overlays
134
137
  * @useCases supplementary copy under the title
135
138
  */
136
- export type UiDialogDescriptionProps = UiDialogSubComponentCommonProps & {};
139
+ export type UiDialogDescriptionProps = {
140
+ /** Render as a child element instead of wrapping. */
141
+ asChild?: UiDialogSubComponentCommonProps['asChild'];
142
+ };
@@ -376,7 +376,7 @@ describe('Keyboard Navigation', () => {
376
376
 
377
377
  describe('UiDropdownMenu controlled state', () => {
378
378
  test('respects controlled open prop', async () => {
379
- const { getByRole, rerender } = render({
379
+ const { getByRole } = render({
380
380
  components: {
381
381
  UiDropdownMenu,
382
382
  UiDropdownMenuTrigger,
@@ -15,6 +15,7 @@ import { UiCheckbox } from '../UiCheckbox';
15
15
  import { UiChip } from '../UiChip';
16
16
  import { UiIcon } from '../UiIcon';
17
17
  import { UiInput } from '../UiInput';
18
+ import { UiKbd } from '../UiKbd';
18
19
  import { UiRadioGroup, UiRadioGroupItem } from '../UiRadioGroup';
19
20
  import {
20
21
  UiSelect,
@@ -28,10 +29,11 @@ import { UiTextarea } from '../UiTextarea';
28
29
  import { UiButton } from '../UiButton';
29
30
  import { ref } from 'vue';
30
31
 
32
+ const designStoryLink = '/?path=/docs/components-uifield--design-notes';
33
+ const accessibilityStoryLink = '/?path=/docs/components-uifield--accessibility';
34
+
31
35
  /**
32
- * UiField composes label, description, and error messaging into a consistent form-field layout.
33
- * Use it to keep spacing, typography, and validation feedback consistent across inputs.
34
- * @slot default - Content of the field (typically UiFieldLabel and UiFieldContent).
36
+ * Field composes label, description, and error messaging into a consistent form-field layout. Use it to keep spacing, typography, and validation feedback consistent across inputs.
35
37
  */
36
38
  const meta: Meta<typeof UiField> = {
37
39
  title: 'Components/UiField',
@@ -61,6 +63,22 @@ const meta: Meta<typeof UiField> = {
61
63
  descriptionPlacement: 'under-input',
62
64
  descriptionCheckbox: false,
63
65
  },
66
+ parameters: {
67
+ docs: {
68
+ links: [
69
+ {
70
+ label: 'Designer docs',
71
+ href: designStoryLink,
72
+ icon: 'palette',
73
+ },
74
+ {
75
+ label: 'Accessibility',
76
+ href: accessibilityStoryLink,
77
+ icon: 'accessibility',
78
+ },
79
+ ],
80
+ },
81
+ },
64
82
  };
65
83
 
66
84
  export default meta;
@@ -131,6 +149,250 @@ export const Default: Story = {
131
149
  },
132
150
  };
133
151
 
152
+ /**
153
+ * Design guidance for structuring form fields, help text, and validation feedback.
154
+ */
155
+ export const DesignNotes: Story = {
156
+ render: () => ({
157
+ template: `
158
+ <section class="flex flex-col gap-8 p-4 bg-surface-secondary">
159
+ <div>
160
+ <h2 class="heading-m font-bold text-content-on-surface-primary">Usage</h2>
161
+ <div class="body-16-regular mt-2 flex flex-col gap-4 text-content-on-surface-primary">
162
+ <p>
163
+ The Field component establishes a consistent structure for collecting information from users.
164
+ It creates a predictable relationship between inputs, labels, help text, and validation messages,
165
+ making forms easier to scan, understand, and complete.
166
+ </p>
167
+ <p>
168
+ The component should be used whenever a user is expected to provide, select, or modify information.
169
+ </p>
170
+ </div>
171
+ </div>
172
+
173
+ <div class="grid gap-8 md:grid-cols-1">
174
+ <div class="flex flex-col gap-3">
175
+ <h3 class="body-16-medium text-content-on-surface-primary">Clarity first</h3>
176
+ <p class="body-16-regular text-content-on-surface-primary">
177
+ Users should immediately understand:
178
+ </p>
179
+ <ul class="body-16-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
180
+ <li>What information is being requested</li>
181
+ <li>Whether the field is required or optional</li>
182
+ <li>How to successfully complete the field</li>
183
+ <li>What needs to be corrected when errors occur</li>
184
+ </ul>
185
+ </div>
186
+
187
+ <div class="flex flex-col gap-3">
188
+ <h3 class="body-16-medium text-content-on-surface-primary">Progressive guidance</h3>
189
+ <p class="body-16-regular text-content-on-surface-primary">
190
+ Provide information only when it helps the user complete a task:
191
+ </p>
192
+ <ul class="body-16-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
193
+ <li>Label explains what is needed</li>
194
+ <li>Description provides additional guidance</li>
195
+ <li>Error message appears only when required</li>
196
+ </ul>
197
+ </div>
198
+
199
+ <div class="flex flex-col gap-3">
200
+ <h3 class="body-16-medium text-content-on-surface-primary">Consistency</h3>
201
+ <p class="body-16-regular text-content-on-surface-primary">
202
+ All form controls should follow the same structure regardless of input type:
203
+ </p>
204
+ <ul class="body-16-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
205
+ <li>Text Input</li>
206
+ <li>Select</li>
207
+ <li>Checkbox</li>
208
+ <li>Switch</li>
209
+ <li>Radio Group</li>
210
+ <li>Text Area</li>
211
+ <li>Slider</li>
212
+ </ul>
213
+ </div>
214
+ </div>
215
+
216
+ <div class="flex flex-col gap-4">
217
+ <h2 class="heading-m font-bold text-content-on-surface-primary">Do's and Don'ts</h2>
218
+ <div class="grid gap-8 md:grid-cols-2">
219
+ <div class="flex flex-col gap-3">
220
+ <h3 class="body-16-medium text-content-on-surface-primary">Do</h3>
221
+ <ul class="body-16-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
222
+ <li>Use a clear label for every field</li>
223
+ <li>Provide helpful descriptions when needed</li>
224
+ <li>Group related information together</li>
225
+ <li>Write actionable error messages</li>
226
+ <li>Use vertical layouts for complex forms</li>
227
+ </ul>
228
+ </div>
229
+
230
+ <div class="flex flex-col gap-3">
231
+ <h3 class="body-16-medium text-content-on-surface-primary">Don't</h3>
232
+ <ul class="body-16-regular list-disc space-y-2 pl-5 text-content-on-surface-primary">
233
+ <li>Use placeholders as labels</li>
234
+ <li>Display errors before interaction</li>
235
+ <li>Overload fields with excessive guidance</li>
236
+ <li>Create inconsistent field layouts across screens</li>
237
+ <li>Depend solely on color to indicate validation states</li>
238
+ </ul>
239
+ </div>
240
+ </div>
241
+ </div>
242
+ </section>
243
+ `,
244
+ }),
245
+ parameters: {
246
+ chromatic: {
247
+ disableSnapshot: true,
248
+ },
249
+ docs: {
250
+ canvas: {
251
+ sourceState: 'none',
252
+ },
253
+ },
254
+ },
255
+ };
256
+
257
+ /**
258
+ * Accessibility guidance for field labels, errors, descriptions, groups, and contrast.
259
+ */
260
+ export const Accessibility: Story = {
261
+ render: () => ({
262
+ components: {
263
+ UiField,
264
+ UiFieldContent,
265
+ UiFieldDescription,
266
+ UiFieldLabel,
267
+ UiInput,
268
+ UiKbd,
269
+ },
270
+ setup() {
271
+ const defaultValue = ref('');
272
+ const accessibleValue = ref('');
273
+ const defaultDescriptionChecked = ref(true);
274
+ const accessibleDescriptionChecked = ref(true);
275
+ return {
276
+ defaultValue,
277
+ accessibleValue,
278
+ defaultDescriptionChecked,
279
+ accessibleDescriptionChecked,
280
+ };
281
+ },
282
+ template: `
283
+ <section class="flex flex-col gap-6 p-4">
284
+ <div>
285
+ <h2 class="heading-m font-bold text-content-on-surface-primary">
286
+ Accessibility
287
+ </h2>
288
+ </div>
289
+
290
+ <div class="flex flex-col gap-6">
291
+ <div class="flex flex-col gap-2">
292
+ <h3 class="body-16-medium text-content-on-surface-primary">
293
+ Requirements
294
+ </h3>
295
+ <ul class="body-16-regular list-disc pl-5 text-content-on-surface-primary">
296
+ <li>Every field has a visible label</li>
297
+ <li>Error states are communicated through more than color alone</li>
298
+ <li>Descriptions remain readable and associated with the field</li>
299
+ <li>Form sections use meaningful group labels</li>
300
+ </ul>
301
+ </div>
302
+
303
+ <div class="flex flex-col gap-2">
304
+ <h3 class="body-16-medium text-content-on-surface-primary">
305
+ Enable accessibility theme
306
+ </h3>
307
+ <p class="body-16-regular text-content-on-surface-primary">
308
+ When accessibility is required, enable our accessibility theme. This
309
+ increases contrast and ensures there are no color contrast issues.
310
+ </p>
311
+ </div>
312
+ </div>
313
+
314
+ <div class="grid gap-4 md:grid-cols-2">
315
+ <div class="flex flex-col gap-3">
316
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
317
+ Default
318
+ </h3>
319
+ <div class="flex min-h-28 items-center justify-center border border-border-surface-default p-6">
320
+ <UiField class="w-full max-w-72">
321
+ <UiFieldLabel for="field-accessibility-default" tooltip="Helpful context for this field.">
322
+ Label
323
+ </UiFieldLabel>
324
+ <UiFieldContent>
325
+ <UiInput
326
+ id="field-accessibility-default"
327
+ v-model="defaultValue"
328
+ name="field-accessibility-default"
329
+ placeholder="Placeholder"
330
+ >
331
+ <template #end>
332
+ <UiKbd size="lg">⌘F</UiKbd>
333
+ </template>
334
+ </UiInput>
335
+ <UiFieldDescription
336
+ id="field-accessibility-default-description"
337
+ v-model="defaultDescriptionChecked"
338
+ variant="input"
339
+ name="field-accessibility-default-description"
340
+ >
341
+ This is an input description.
342
+ </UiFieldDescription>
343
+ </UiFieldContent>
344
+ </UiField>
345
+ </div>
346
+ </div>
347
+
348
+ <div class="accessible-theme flex flex-col gap-3">
349
+ <h3 class="label-16-medium text-center text-content-on-surface-primary">
350
+ Accessible
351
+ </h3>
352
+ <div class="flex min-h-28 items-center justify-center border border-border-surface-default p-6">
353
+ <UiField class="w-full max-w-72">
354
+ <UiFieldLabel for="field-accessibility-accessible" tooltip="Helpful context for this field.">
355
+ Label
356
+ </UiFieldLabel>
357
+ <UiFieldContent>
358
+ <UiInput
359
+ id="field-accessibility-accessible"
360
+ v-model="accessibleValue"
361
+ name="field-accessibility-accessible"
362
+ placeholder="Placeholder"
363
+ >
364
+ <template #end>
365
+ <UiKbd size="lg">⌘F</UiKbd>
366
+ </template>
367
+ </UiInput>
368
+ <UiFieldDescription
369
+ id="field-accessibility-accessible-description"
370
+ v-model="accessibleDescriptionChecked"
371
+ variant="input"
372
+ name="field-accessibility-accessible-description"
373
+ >
374
+ This is an input description.
375
+ </UiFieldDescription>
376
+ </UiFieldContent>
377
+ </UiField>
378
+ </div>
379
+ </div>
380
+ </div>
381
+ </section>
382
+ `,
383
+ }),
384
+ parameters: {
385
+ chromatic: {
386
+ disableSnapshot: true,
387
+ },
388
+ docs: {
389
+ canvas: {
390
+ sourceState: 'none',
391
+ },
392
+ },
393
+ },
394
+ };
395
+
134
396
  const descriptionWithCheckboxTemplateSource = `<script setup lang="ts">
135
397
  import { ref } from 'vue'
136
398
  import {
@@ -1,5 +1,12 @@
1
1
  <script setup lang="ts">
2
- import { computed, provide, toRef, useSlots, type VNode } from 'vue';
2
+ import {
3
+ computed,
4
+ provide,
5
+ toRef,
6
+ useSlots,
7
+ type Slots,
8
+ type VNode,
9
+ } from 'vue';
3
10
  import { Field as ShadcnField } from '@/components/core/field';
4
11
  import type { UiFieldProps } from './types';
5
12
  import { FIELD_DESCRIPTION_CHECKBOX_KEY } from './keys';
@@ -16,7 +23,7 @@ const props = withDefaults(defineProps<UiFieldProps>(), {
16
23
 
17
24
  provide(FIELD_DESCRIPTION_CHECKBOX_KEY, toRef(props, 'descriptionCheckbox'));
18
25
 
19
- const slots = useSlots();
26
+ const slots: Slots = useSlots();
20
27
 
21
28
  const isResponsive = computed(() => props.orientation === 'responsive');
22
29
 
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { FieldError as ShadcnFieldError } from '@/components/core/field';
3
- import { computed, useSlots } from 'vue';
3
+ import { computed, useSlots, type Slots } from 'vue';
4
4
  import type { UiFieldErrorProps } from './types';
5
5
 
6
6
  defineOptions({
@@ -9,8 +9,8 @@ defineOptions({
9
9
 
10
10
  const props = defineProps<UiFieldErrorProps>();
11
11
 
12
- const slots = useSlots();
13
- const hasDefaultSlotContent = computed(
12
+ const slots: Slots = useSlots();
13
+ const hasDefaultSlotContent = computed<boolean>(
14
14
  () => (slots.default?.({}).length ?? 0) > 0,
15
15
  );
16
16
  </script>