@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.
- package/config.d.ts +8 -2
- package/config.js +85 -73
- package/dist/system/components/UiAutocomplete/types.d.ts +0 -1
- package/dist/system/components/UiDialog/UiDialogDescription.vue.d.ts +2 -1
- package/dist/system/components/UiDialog/UiDialogFooter.vue.d.ts +1 -2
- package/dist/system/components/UiDialog/UiDialogHeader.vue.d.ts +1 -2
- package/dist/system/components/UiDialog/UiDialogTitle.vue.d.ts +2 -1
- package/dist/system/components/UiDialog/types.d.ts +10 -4
- package/dist/system/components/UiDropdownMenu/UiDropdownMenuSub.vue.d.ts +3 -1
- package/dist/system/components/UiField/UiFieldError.vue.d.ts +8 -1
- package/dist/system/components/UiInput/UiInput.vue.d.ts +16 -1
- package/dist/system/components/UiStepper/UiStepperDescription.vue.d.ts +3 -1
- package/dist/system/components/UiStepper/UiStepperIndicator.vue.d.ts +3 -1
- package/dist/system/components/UiStepper/UiStepperItem.vue.d.ts +3 -1
- package/dist/system/components/UiTagsInput/types.d.ts +1 -2
- package/dist/system/components/core/accordion/AccordionItem.vue.d.ts +3 -1
- package/dist/system/components/core/calendar/CalendarHeading.vue.d.ts +2 -2
- package/dist/system/components/core/dropdown-menu/DropdownMenuSub.vue.d.ts +3 -1
- package/dist/system/components/core/range-calendar/RangeCalendarHeading.vue.d.ts +2 -2
- package/dist/system/components/core/stepper/StepperDescription.vue.d.ts +3 -1
- package/dist/system/components/core/stepper/StepperIndicator.vue.d.ts +3 -1
- package/dist/system/components/core/stepper/StepperItem.vue.d.ts +3 -1
- package/dist/system/index.d.ts +2 -1
- package/dist/system/lib/utils.d.ts +6 -0
- package/dist/system/lib.js +15498 -15548
- package/dist/system/patterns/UiSidebar/UiSidebarContent.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarFooter.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarGroupContent.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarInset.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarMenu.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarMenuItem.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarProvider.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/UiSidebarRail.vue.d.ts +1 -2
- package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +9 -9
- package/dist/system/patterns/UiSidebar/types.d.ts +8 -16
- package/dist/system/story-sidebar-icons.json +10 -0
- package/package.json +5 -2
- package/src/@types/shims-vue.d.ts +1 -1
- package/src/__tests__/test-utils.ts +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogAction.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogCancel.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogContent.vue +4 -1
- package/src/components/UiAlertDialog/UiAlertDialogDescription.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogTitle.vue +1 -1
- package/src/components/UiAlertDialog/UiAlertDialogTrigger.vue +1 -1
- package/src/components/UiAutocomplete/types.ts +0 -1
- package/src/components/UiBadge/UiBadge.vue +1 -1
- package/src/components/UiBadge/constants.ts +1 -1
- package/src/components/UiBadge/types.ts +1 -1
- package/src/components/UiButton/UiButton.stories.ts +286 -198
- package/src/components/UiButton/mcp-docs.json +49 -0
- package/src/components/UiCalendar/UiCalendar.vue +2 -5
- package/src/components/UiCalendar/__tests__/UiCalendar.test.ts +4 -2
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +176 -2
- package/src/components/UiCheckbox/mcp-docs.json +36 -0
- package/src/components/UiChip/types.ts +1 -1
- package/src/components/UiDialog/UiDialogFooter.vue +0 -3
- package/src/components/UiDialog/UiDialogHeader.vue +0 -3
- package/src/components/UiDialog/types.ts +10 -4
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +1 -1
- package/src/components/UiField/UiField.stories.ts +265 -3
- package/src/components/UiField/UiField.vue +9 -2
- package/src/components/UiField/UiFieldError.vue +3 -3
- package/src/components/UiField/mcp-docs.json +72 -0
- package/src/components/UiFileItem/UiFileItem.stories.ts +11 -11
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +1 -1
- package/src/components/UiIcon/UiIcon.vue +3 -2
- package/src/components/UiInput/UiInput.vue +19 -3
- package/src/components/UiInput/mcp-docs.json +51 -0
- package/src/components/UiItem/UiItem.stories.ts +118 -2
- package/src/components/UiItem/__tests__/UiItem.test.ts +3 -5
- package/src/components/UiItem/mcp-docs.json +25 -0
- package/src/components/UiLabel/UiLabel.vue +1 -1
- package/src/components/UiListbox/UiListbox.vue +3 -6
- package/src/components/UiListbox/UiListboxFilter.vue +1 -1
- package/src/components/UiListbox/UiListboxItem.vue +1 -1
- package/src/components/UiProgress/UiProgress.vue +1 -1
- package/src/components/UiRadioGroup/UiRadioGroup.vue +1 -1
- package/src/components/UiRadioGroup/UiRadioGroupItem.vue +2 -2
- package/src/components/UiRadioGroup/__tests__/UiRadioGroup.test.ts +2 -2
- package/src/components/UiRangeCalendar/UiRangeCalendar.vue +2 -5
- package/src/components/UiRangeCalendar/__tests__/UiRangeCalendar.test.ts +9 -6
- package/src/components/UiSelect/UiSelectContent.vue +2 -4
- package/src/components/UiSwitch/UiSwitch.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInput.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInputInput.vue +1 -1
- package/src/components/UiTagsInput/UiTagsInputItem.vue +1 -1
- package/src/components/UiTagsInput/types.ts +1 -4
- package/src/components/UiTooltip/UiTooltip.stories.ts +0 -8
- package/src/components/core/accordion/AccordionItem.vue +1 -1
- package/src/components/core/alert-dialog/AlertDialogContent.vue +1 -1
- package/src/components/core/badge/Badge.vue +2 -5
- package/src/components/core/calendar/CalendarHeading.vue +1 -1
- package/src/components/core/dropdown-menu/DropdownMenuSub.vue +1 -1
- package/src/components/core/item/index.ts +1 -1
- package/src/components/core/listbox/Listbox.vue +2 -5
- package/src/components/core/listbox/ListboxContent.vue +2 -5
- package/src/components/core/listbox/ListboxFilter.vue +2 -5
- package/src/components/core/listbox/ListboxGroup.vue +2 -5
- package/src/components/core/listbox/ListboxGroupLabel.vue +2 -5
- package/src/components/core/listbox/ListboxItem.vue +2 -5
- package/src/components/core/listbox/ListboxItemIndicator.vue +2 -5
- package/src/components/core/range-calendar/RangeCalendarHeading.vue +1 -1
- package/src/components/core/sidebar/SidebarContent.vue +4 -5
- package/src/components/core/sidebar/SidebarFooter.vue +4 -5
- package/src/components/core/sidebar/SidebarGroup.vue +4 -5
- package/src/components/core/sidebar/SidebarHeader.vue +4 -5
- package/src/components/core/sidebar/SidebarMenu.vue +4 -5
- package/src/components/core/sidebar/SidebarMenuAction.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuButtonChild.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSkeleton.vue +1 -1
- package/src/components/core/sidebar/SidebarMenuSubButton.vue +1 -1
- package/src/components/core/sidebar/SidebarSeparator.vue +4 -5
- package/src/components/core/stepper/StepperDescription.vue +1 -1
- package/src/components/core/stepper/StepperIndicator.vue +1 -1
- package/src/components/core/stepper/StepperItem.vue +1 -1
- package/src/components/core/tags-input/TagsInput.vue +2 -5
- package/src/components/core/tags-input/TagsInputInput.vue +2 -5
- package/src/components/core/tags-input/TagsInputItem.vue +2 -5
- package/src/components/core/tags-input/TagsInputItemDelete.vue +2 -5
- package/src/components/core/tags-input/TagsInputItemText.vue +2 -5
- package/src/components/core/toggle/Toggle.vue +1 -1
- package/src/index.ts +30 -5
- package/src/lib/useDrag.ts +1 -0
- package/src/lib/utils.ts +12 -0
- package/src/patterns/UiDataTable/UiDataTable.mock.ts +13 -4
- package/src/patterns/UiDataTable/UiDataTable.vue +1 -0
- package/src/patterns/UiDataTable/__tests__/UiDataTable.test.ts +11 -2
- package/src/patterns/UiDatePicker/__tests__/UiDatePicker.test.ts +28 -39
- package/src/patterns/UiSidebar/UiSidebarContent.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarFooter.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarGroup.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarHeader.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarInset.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenu.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarMenuItem.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarMenuSub.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +4 -5
- package/src/patterns/UiSidebar/UiSidebarProvider.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarRail.vue +0 -3
- package/src/patterns/UiSidebar/UiSidebarSub.vue +4 -5
- package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +21 -17
- package/src/patterns/UiSidebar/__tests__/UiSidebarMenuButton.test.ts +12 -10
- package/src/patterns/UiSidebar/types.ts +8 -8
- package/src/theme/Typography.stories.ts +3 -2
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"designNotes": {
|
|
3
|
+
"title": "Usage",
|
|
4
|
+
"summary": "The Field component establishes a consistent structure for collecting information from users. It creates a predictable relationship between inputs, labels, help text, and validation messages, making forms easier to scan, understand, and complete. The component should be used whenever a user is expected to provide, select, or modify information.",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "Clarity first",
|
|
8
|
+
"content": "Users should immediately understand:",
|
|
9
|
+
"items": [
|
|
10
|
+
"What information is being requested",
|
|
11
|
+
"Whether the field is required or optional",
|
|
12
|
+
"How to successfully complete the field",
|
|
13
|
+
"What needs to be corrected when errors occur"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"title": "Progressive guidance",
|
|
18
|
+
"content": "Provide information only when it helps the user complete a task:",
|
|
19
|
+
"items": [
|
|
20
|
+
"Label explains what is needed",
|
|
21
|
+
"Description provides additional guidance",
|
|
22
|
+
"Error message appears only when required"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"title": "Consistency",
|
|
27
|
+
"content": "All form controls should follow the same structure regardless of input type:",
|
|
28
|
+
"items": [
|
|
29
|
+
"Text Input",
|
|
30
|
+
"Select",
|
|
31
|
+
"Checkbox",
|
|
32
|
+
"Switch",
|
|
33
|
+
"Radio Group",
|
|
34
|
+
"Text Area",
|
|
35
|
+
"Slider"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"do": [
|
|
40
|
+
"Use a clear label for every field",
|
|
41
|
+
"Provide helpful descriptions when needed",
|
|
42
|
+
"Group related information together",
|
|
43
|
+
"Write actionable error messages",
|
|
44
|
+
"Use vertical layouts for complex forms"
|
|
45
|
+
],
|
|
46
|
+
"dont": [
|
|
47
|
+
"Use placeholders as labels",
|
|
48
|
+
"Display errors before interaction",
|
|
49
|
+
"Overload fields with excessive guidance",
|
|
50
|
+
"Create inconsistent field layouts across screens",
|
|
51
|
+
"Depend solely on color to indicate validation states"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"accessibility": {
|
|
55
|
+
"title": "Accessibility",
|
|
56
|
+
"sections": [
|
|
57
|
+
{
|
|
58
|
+
"title": "Requirements",
|
|
59
|
+
"items": [
|
|
60
|
+
"Every field has a visible label",
|
|
61
|
+
"Error states are communicated through more than color alone",
|
|
62
|
+
"Descriptions remain readable and associated with the field",
|
|
63
|
+
"Form sections use meaningful group labels"
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"title": "Enable accessibility theme",
|
|
68
|
+
"content": "When accessibility is required, enable the accessibility theme. This increases contrast and ensures there are no color contrast issues."
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -73,7 +73,7 @@ type Story = StoryObj<typeof UiFileItem>;
|
|
|
73
73
|
const renderArgs = (args: Story['args']) => ({
|
|
74
74
|
components: { UiFileItem },
|
|
75
75
|
setup() {
|
|
76
|
-
|
|
76
|
+
const onRemove = () => undefined;
|
|
77
77
|
const normalized = {
|
|
78
78
|
...args,
|
|
79
79
|
mediaIcon: args?.mediaIcon || undefined,
|
|
@@ -87,7 +87,7 @@ const renderArgs = (args: Story['args']) => ({
|
|
|
87
87
|
const defaultTemplateSource = `<script setup lang="ts">
|
|
88
88
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
const onRemove = () => undefined;
|
|
91
91
|
</script>
|
|
92
92
|
|
|
93
93
|
<template>
|
|
@@ -110,7 +110,7 @@ export const Default: Story = {
|
|
|
110
110
|
const defaultWithProgressTemplateSource = `<script setup lang="ts">
|
|
111
111
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
const onRemove = () => undefined;
|
|
114
114
|
</script>
|
|
115
115
|
|
|
116
116
|
<template>
|
|
@@ -140,7 +140,7 @@ export const DefaultWithProgress: Story = {
|
|
|
140
140
|
const defaultSuccessTemplateSource = `<script setup lang="ts">
|
|
141
141
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
const onRemove = () => undefined;
|
|
144
144
|
</script>
|
|
145
145
|
|
|
146
146
|
<template>
|
|
@@ -174,7 +174,7 @@ export const DefaultSuccess: Story = {
|
|
|
174
174
|
const defaultErrorTemplateSource = `<script setup lang="ts">
|
|
175
175
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
const onRemove = () => undefined;
|
|
178
178
|
</script>
|
|
179
179
|
|
|
180
180
|
<template>
|
|
@@ -204,7 +204,7 @@ export const DefaultError: Story = {
|
|
|
204
204
|
const smallWithProgressTemplateSource = `<script setup lang="ts">
|
|
205
205
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
const onRemove = () => undefined;
|
|
208
208
|
</script>
|
|
209
209
|
|
|
210
210
|
<template>
|
|
@@ -235,7 +235,7 @@ export const SmallWithProgress: Story = {
|
|
|
235
235
|
const smallSuccessTemplateSource = `<script setup lang="ts">
|
|
236
236
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
const onRemove = () => undefined;
|
|
239
239
|
</script>
|
|
240
240
|
|
|
241
241
|
<template>
|
|
@@ -270,7 +270,7 @@ export const SmallSuccess: Story = {
|
|
|
270
270
|
const smallErrorTemplateSource = `<script setup lang="ts">
|
|
271
271
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
272
272
|
|
|
273
|
-
|
|
273
|
+
const onRemove = () => undefined;
|
|
274
274
|
</script>
|
|
275
275
|
|
|
276
276
|
<template>
|
|
@@ -331,7 +331,7 @@ export const NonRemovable: Story = {
|
|
|
331
331
|
const disabledTemplateSource = `<script setup lang="ts">
|
|
332
332
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
333
333
|
|
|
334
|
-
|
|
334
|
+
const onRemove = () => undefined;
|
|
335
335
|
</script>
|
|
336
336
|
|
|
337
337
|
<template>
|
|
@@ -363,7 +363,7 @@ export const Disabled: Story = {
|
|
|
363
363
|
const allVariantsTemplateSource = `<script setup lang="ts">
|
|
364
364
|
import { UiFileItem } from '@aleph-alpha/ui-library'
|
|
365
365
|
|
|
366
|
-
|
|
366
|
+
const onRemove = () => undefined;
|
|
367
367
|
</script>
|
|
368
368
|
|
|
369
369
|
<template>
|
|
@@ -408,7 +408,7 @@ export const AllVariants: Story = {
|
|
|
408
408
|
render: () => ({
|
|
409
409
|
components: { UiFileItem },
|
|
410
410
|
setup() {
|
|
411
|
-
|
|
411
|
+
const onRemove = () => undefined;
|
|
412
412
|
return { onRemove };
|
|
413
413
|
},
|
|
414
414
|
template: `
|
|
@@ -126,7 +126,7 @@ function processFileList(fileList: FileList) {
|
|
|
126
126
|
// `multiple` on the hidden input only limits the OS picker; drag-and-drop can still
|
|
127
127
|
// deliver many files — honor single-file mode here too (first valid file wins).
|
|
128
128
|
if (!props.multiple) {
|
|
129
|
-
if (valid
|
|
129
|
+
if (valid[0]) emit('update:files', [valid[0]]);
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
if (valid.length) emit('update:files', valid);
|
|
@@ -44,7 +44,7 @@ const iconLookup = lucideIcons as unknown as Record<string, Component>;
|
|
|
44
44
|
*/
|
|
45
45
|
function toPascalCase(str: string): string {
|
|
46
46
|
// If already PascalCase (starts with uppercase, no hyphens), return as-is
|
|
47
|
-
if (!str.includes('-') && str
|
|
47
|
+
if (!str.includes('-') && str.charAt(0) === str.charAt(0).toUpperCase()) {
|
|
48
48
|
return str;
|
|
49
49
|
}
|
|
50
50
|
return str
|
|
@@ -66,7 +66,8 @@ const computedRole = computed(() => {
|
|
|
66
66
|
|
|
67
67
|
// Filter out role from attrs since we handle it explicitly
|
|
68
68
|
const filteredAttrs = computed(() => {
|
|
69
|
-
const {
|
|
69
|
+
const rest = { ...attrs };
|
|
70
|
+
delete rest.role;
|
|
70
71
|
return rest;
|
|
71
72
|
});
|
|
72
73
|
</script>
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { Input as ShadcnInput } from '@/components/core/input';
|
|
3
3
|
import { UiButton } from '@/components/UiButton';
|
|
4
4
|
import { UiIcon } from '@/components/UiIcon';
|
|
5
|
-
import { computed, ref } from 'vue';
|
|
5
|
+
import { computed, ref, useAttrs } from 'vue';
|
|
6
6
|
import type { UiInputProps } from './types';
|
|
7
7
|
|
|
8
8
|
defineOptions({
|
|
9
9
|
name: 'UiInput',
|
|
10
|
+
inheritAttrs: false,
|
|
10
11
|
});
|
|
11
12
|
|
|
12
13
|
const props = withDefaults(defineProps<UiInputProps>(), {
|
|
@@ -26,6 +27,7 @@ const emit = defineEmits<{
|
|
|
26
27
|
|
|
27
28
|
const model = defineModel<string>();
|
|
28
29
|
|
|
30
|
+
const attrs = useAttrs();
|
|
29
31
|
const isFile = computed(() => props.type === 'file');
|
|
30
32
|
|
|
31
33
|
const selectedFiles = ref<File[]>([]);
|
|
@@ -34,7 +36,8 @@ const filePlaceholder = computed(() => props.placeholder ?? 'No file chosen');
|
|
|
34
36
|
|
|
35
37
|
const fileDisplayValue = computed(() => {
|
|
36
38
|
if (selectedFiles.value.length === 0) return '';
|
|
37
|
-
if (selectedFiles.value.length === 1)
|
|
39
|
+
if (selectedFiles.value.length === 1)
|
|
40
|
+
return selectedFiles.value[0]?.name ?? '';
|
|
38
41
|
return `${selectedFiles.value.length} files selected`;
|
|
39
42
|
});
|
|
40
43
|
|
|
@@ -57,6 +60,7 @@ function handleFilesChange(e: Event) {
|
|
|
57
60
|
-->
|
|
58
61
|
<div
|
|
59
62
|
v-if="isFile"
|
|
63
|
+
v-bind="attrs"
|
|
60
64
|
class="flex h-9 w-full min-w-0 items-center gap-2 rounded-md border border-input bg-background-input-default px-1 transition-[color] outline-none focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive"
|
|
61
65
|
:class="{
|
|
62
66
|
'pointer-events-none cursor-not-allowed opacity-50': props.disabled,
|
|
@@ -87,5 +91,17 @@ function handleFilesChange(e: Event) {
|
|
|
87
91
|
{{ fileDisplayValue || filePlaceholder }}
|
|
88
92
|
</span>
|
|
89
93
|
</div>
|
|
90
|
-
<
|
|
94
|
+
<div v-else-if="$slots.end" class="relative">
|
|
95
|
+
<ShadcnInput
|
|
96
|
+
v-model="model"
|
|
97
|
+
v-bind="{ ...attrs, ...props }"
|
|
98
|
+
class="pr-14"
|
|
99
|
+
/>
|
|
100
|
+
<div
|
|
101
|
+
class="pointer-events-none absolute inset-y-0 right-2 flex items-center"
|
|
102
|
+
>
|
|
103
|
+
<slot name="end" />
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
<ShadcnInput v-else v-model="model" v-bind="{ ...attrs, ...props }" />
|
|
91
107
|
</template>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"designNotes": {
|
|
3
|
+
"title": "Usage",
|
|
4
|
+
"summary": "Use inputs for short, single-line values such as names, email addresses, search terms, and numeric values. Pair inputs with UiField when a label, description, validation message, or other form guidance is needed.",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "Labels and placeholders",
|
|
8
|
+
"content": "Use a visible label to identify the requested value. Placeholder text can provide an example format, but it should not replace the label."
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"title": "Supporting content",
|
|
12
|
+
"content": "Use descriptions to explain constraints, examples, or consequences. Use the end slot for compact, non-interactive hints such as keyboard shortcuts."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"title": "Input type",
|
|
16
|
+
"content": "Choose the native type that matches the expected value, such as email, search, number, password, or file."
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"do": [
|
|
20
|
+
"Use a clear visible label with every input",
|
|
21
|
+
"Use placeholder text only as an example or hint",
|
|
22
|
+
"Pair with UiField for descriptions and validation feedback",
|
|
23
|
+
"Use the end slot for compact supporting hints like keyboard shortcuts",
|
|
24
|
+
"Choose the correct native input type"
|
|
25
|
+
],
|
|
26
|
+
"dont": [
|
|
27
|
+
"Use placeholders as labels",
|
|
28
|
+
"Put long instructions inside the input",
|
|
29
|
+
"Use an input when users need to enter multi-line content",
|
|
30
|
+
"Depend solely on color to communicate validation state"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"accessibility": {
|
|
34
|
+
"title": "Accessibility",
|
|
35
|
+
"sections": [
|
|
36
|
+
{
|
|
37
|
+
"title": "Requirements",
|
|
38
|
+
"items": [
|
|
39
|
+
"Every input has a visible label",
|
|
40
|
+
"Descriptions remain readable and associated with the field",
|
|
41
|
+
"Validation states are communicated through more than color alone",
|
|
42
|
+
"Keyboard hints do not block typing or focus"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"title": "Enable accessibility theme",
|
|
47
|
+
"content": "When accessibility is required, enable the accessibility theme. This increases contrast and ensures there are no color contrast issues."
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -20,9 +20,11 @@ import {
|
|
|
20
20
|
UiAvatarImage,
|
|
21
21
|
} from '../UiAvatar';
|
|
22
22
|
|
|
23
|
+
const designStoryLink = '/?path=/docs/components-uiitem--design-notes';
|
|
24
|
+
const accessibilityStoryLink = '/?path=/docs/components-uiitem--accessibility';
|
|
25
|
+
|
|
23
26
|
/**
|
|
24
|
-
*
|
|
25
|
-
* Use it as the building block for lists, settings rows, navigation entries, and option pickers — wherever you need a consistently styled item.
|
|
27
|
+
* A versatile component that you can use to display any content.
|
|
26
28
|
*/
|
|
27
29
|
const meta: Meta<typeof UiItem> = {
|
|
28
30
|
title: 'Components/UiItem',
|
|
@@ -82,6 +84,22 @@ const meta: Meta<typeof UiItem> = {
|
|
|
82
84
|
asChild: false,
|
|
83
85
|
withListSemantics: false,
|
|
84
86
|
},
|
|
87
|
+
parameters: {
|
|
88
|
+
docs: {
|
|
89
|
+
links: [
|
|
90
|
+
{
|
|
91
|
+
label: 'Designer docs',
|
|
92
|
+
href: designStoryLink,
|
|
93
|
+
icon: 'palette',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: 'Accessibility',
|
|
97
|
+
href: accessibilityStoryLink,
|
|
98
|
+
icon: 'accessibility',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
85
103
|
};
|
|
86
104
|
|
|
87
105
|
export default meta;
|
|
@@ -454,6 +472,104 @@ export const Basic: Story = {
|
|
|
454
472
|
},
|
|
455
473
|
};
|
|
456
474
|
|
|
475
|
+
/**
|
|
476
|
+
* Design guidance for choosing item variants, density, and composition.
|
|
477
|
+
*/
|
|
478
|
+
export const DesignNotes: Story = {
|
|
479
|
+
render: () => ({
|
|
480
|
+
components: { UiButton },
|
|
481
|
+
template: `
|
|
482
|
+
<section class="flex flex-col gap-8 p-4 bg-surface-secondary">
|
|
483
|
+
<div>
|
|
484
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">Usage</h2>
|
|
485
|
+
<p class="body-16-regular mt-2 text-content-on-surface-primary">
|
|
486
|
+
The Item component can house nearly any type of content. Use it to display a title,
|
|
487
|
+
description, and actions. Group it with the ItemGroup component to create a list of items.
|
|
488
|
+
Please refer to the stories for examples of different configurations.
|
|
489
|
+
</p>
|
|
490
|
+
</div>
|
|
491
|
+
</section>
|
|
492
|
+
`,
|
|
493
|
+
}),
|
|
494
|
+
parameters: {
|
|
495
|
+
chromatic: {
|
|
496
|
+
disableSnapshot: true,
|
|
497
|
+
},
|
|
498
|
+
docs: {
|
|
499
|
+
canvas: {
|
|
500
|
+
sourceState: 'none',
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Accessibility guidance for item contrast and accessible theme usage.
|
|
508
|
+
*/
|
|
509
|
+
export const Accessibility: Story = {
|
|
510
|
+
render: () => ({
|
|
511
|
+
components: { UiItem, UiIcon },
|
|
512
|
+
template: `
|
|
513
|
+
<section class="flex flex-col gap-6 p-4">
|
|
514
|
+
<div>
|
|
515
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
516
|
+
Accessibility
|
|
517
|
+
</h2>
|
|
518
|
+
</div>
|
|
519
|
+
|
|
520
|
+
<div class="flex flex-col gap-6">
|
|
521
|
+
<div class="flex flex-col gap-2">
|
|
522
|
+
<h3 class="body-16-medium text-content-on-surface-primary">
|
|
523
|
+
Enable accessibility theme
|
|
524
|
+
</h3>
|
|
525
|
+
<p class="body-16-regular text-content-on-surface-primary">
|
|
526
|
+
When accessibility is required, enable our accessibility theme. This increases contrast and makes sure there are no color contrast issues.
|
|
527
|
+
</p>
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
532
|
+
<div class="flex flex-col gap-3">
|
|
533
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
534
|
+
Default
|
|
535
|
+
</h3>
|
|
536
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
537
|
+
<UiItem variant="outline" title="Item title" description="Item description goes here">
|
|
538
|
+
<template #icon>
|
|
539
|
+
<UiIcon name="folder-open" size="s" />
|
|
540
|
+
</template>
|
|
541
|
+
</UiItem>
|
|
542
|
+
</div>
|
|
543
|
+
</div>
|
|
544
|
+
|
|
545
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
546
|
+
<h3 class="label-16-medium text-center text-content-on-surface-primary">
|
|
547
|
+
Accessible
|
|
548
|
+
</h3>
|
|
549
|
+
<div class="flex min-h-20 items-center justify-center border border-border-surface-default p-6">
|
|
550
|
+
<UiItem variant="outline" title="Item title" description="Item description goes here">
|
|
551
|
+
<template #icon>
|
|
552
|
+
<UiIcon name="folder-open" size="s" />
|
|
553
|
+
</template>
|
|
554
|
+
</UiItem>
|
|
555
|
+
</div>
|
|
556
|
+
</div>
|
|
557
|
+
</div>
|
|
558
|
+
</section>
|
|
559
|
+
`,
|
|
560
|
+
}),
|
|
561
|
+
parameters: {
|
|
562
|
+
chromatic: {
|
|
563
|
+
disableSnapshot: true,
|
|
564
|
+
},
|
|
565
|
+
docs: {
|
|
566
|
+
canvas: {
|
|
567
|
+
sourceState: 'none',
|
|
568
|
+
},
|
|
569
|
+
},
|
|
570
|
+
},
|
|
571
|
+
};
|
|
572
|
+
|
|
457
573
|
/**
|
|
458
574
|
* Shows each visual variant and when to choose it. Use this to compare static,
|
|
459
575
|
* current, outlined, row-hover, and separate action-hover rows.
|
|
@@ -91,10 +91,8 @@ describe('UiItem', () => {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
const element = container.querySelector('[data-slot="item"]');
|
|
94
|
-
expect(element).toHaveClass('
|
|
95
|
-
expect(element).toHaveClass('
|
|
96
|
-
expect(element).toHaveClass('ring-border-surface-default');
|
|
97
|
-
expect(element).not.toHaveClass('border');
|
|
94
|
+
expect(element).toHaveClass('border');
|
|
95
|
+
expect(element).toHaveClass('border-border-surface-default');
|
|
98
96
|
});
|
|
99
97
|
|
|
100
98
|
test('applies hover variant classes', () => {
|
|
@@ -389,7 +387,7 @@ describe('UiItem', () => {
|
|
|
389
387
|
expect(element).toHaveClass('items-center');
|
|
390
388
|
expect(element).toHaveClass('rounded-md');
|
|
391
389
|
// Check variant classes are applied
|
|
392
|
-
expect(element).toHaveClass('
|
|
390
|
+
expect(element).toHaveClass('border-border-surface-default');
|
|
393
391
|
// Check size classes are applied
|
|
394
392
|
expect(element).toHaveClass('p-2');
|
|
395
393
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"designNotes": {
|
|
3
|
+
"title": "Usage",
|
|
4
|
+
"summary": "The Item component can house nearly any type of content. Use it to display a title, description, and actions. Group it with the ItemGroup component to create a list of items. Please refer to the stories for examples of different configurations.",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "Variant, density, and composition",
|
|
8
|
+
"content": "Choose item variants, density, and composition based on the role of the row and the surrounding layout."
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"accessibility": {
|
|
13
|
+
"title": "Accessibility",
|
|
14
|
+
"sections": [
|
|
15
|
+
{
|
|
16
|
+
"title": "Enable accessibility theme",
|
|
17
|
+
"content": "When accessibility is required, enable the accessibility theme. This increases contrast and makes sure there are no color contrast issues."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"title": "Preview guidance",
|
|
21
|
+
"content": "Use clear item titles, supporting descriptions, and recognizable leading icons or media where they help scanning. Make interactive item actions reachable by keyboard and provide accessible labels for icon-only actions."
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import type { AcceptableValue } from 'reka-ui';
|
|
3
3
|
import { computed, useAttrs } from 'vue';
|
|
4
4
|
import { Listbox as ShadcnListbox } from '@/components/core/listbox';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { type UiListboxProps } from './types';
|
|
6
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
7
7
|
|
|
8
8
|
defineOptions({
|
|
9
9
|
name: 'UiListbox',
|
|
@@ -19,10 +19,7 @@ const props = withDefaults(defineProps<UiListboxProps>(), {
|
|
|
19
19
|
const model = defineModel<AcceptableValue | AcceptableValue[]>();
|
|
20
20
|
|
|
21
21
|
const attrs = useAttrs();
|
|
22
|
-
const forwardedAttrs = computed(() =>
|
|
23
|
-
const { class: _class, ...rest } = attrs;
|
|
24
|
-
return rest;
|
|
25
|
-
});
|
|
22
|
+
const forwardedAttrs = computed(() => omitClass(attrs));
|
|
26
23
|
</script>
|
|
27
24
|
|
|
28
25
|
<template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from 'vue';
|
|
3
3
|
import { Progress as ShadcnProgress } from '@/components/core/progress';
|
|
4
|
-
import { UiProgressProps } from './types';
|
|
4
|
+
import { type UiProgressProps } from './types';
|
|
5
5
|
|
|
6
6
|
defineOptions({
|
|
7
7
|
name: 'UiProgress',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { computed } from 'vue';
|
|
3
3
|
import { cn } from '@/lib/utils';
|
|
4
4
|
import { RadioGroup as ShadcnRadioGroup } from '@/components/core/radio-group';
|
|
5
|
-
import { UiRadioGroupProps } from './types';
|
|
5
|
+
import { type UiRadioGroupProps } from './types';
|
|
6
6
|
|
|
7
7
|
defineOptions({
|
|
8
8
|
name: 'UiRadioGroup',
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { RadioGroupItem as ShadcnRadioGroupItem } from '@/components/core/radio-group';
|
|
3
|
-
import { UiRadioGroupItemProps } from './types';
|
|
3
|
+
import { type UiRadioGroupItemProps } from './types';
|
|
4
4
|
|
|
5
5
|
defineOptions({
|
|
6
6
|
name: 'UiRadioGroupItem',
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
withDefaults(defineProps<UiRadioGroupItemProps>(), {
|
|
10
10
|
asChild: false,
|
|
11
11
|
disabled: false,
|
|
12
12
|
required: false,
|
|
@@ -142,7 +142,7 @@ describe('UiRadioGroup', () => {
|
|
|
142
142
|
|
|
143
143
|
describe('keyboard navigation', () => {
|
|
144
144
|
test('arrow down moves focus to next item', async () => {
|
|
145
|
-
const {
|
|
145
|
+
const { getByLabelText } = render(UiRadioGroup, {
|
|
146
146
|
props: {
|
|
147
147
|
name: 'radio-group',
|
|
148
148
|
modelValue: firstItemValue,
|
|
@@ -180,7 +180,7 @@ describe('UiRadioGroup', () => {
|
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
test('loops from last to first when loop is enabled (default)', async () => {
|
|
183
|
-
const {
|
|
183
|
+
const { getByLabelText } = render(UiRadioGroup, {
|
|
184
184
|
props: {
|
|
185
185
|
name: 'radio-group',
|
|
186
186
|
modelValue: thirdItemValue,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, useAttrs } from 'vue';
|
|
3
3
|
import { RangeCalendar as ShadcnRangeCalendar } from '@/components/core/range-calendar';
|
|
4
|
-
import { cn } from '@/lib/utils';
|
|
4
|
+
import { cn, omitClass } from '@/lib/utils';
|
|
5
5
|
import type { UiRangeCalendarProps } from './types';
|
|
6
6
|
|
|
7
7
|
defineOptions({
|
|
@@ -27,10 +27,7 @@ const placeholder =
|
|
|
27
27
|
defineModel<UiRangeCalendarProps['placeholder']>('placeholder');
|
|
28
28
|
|
|
29
29
|
const attrs = useAttrs();
|
|
30
|
-
const forwardedAttrs = computed(() =>
|
|
31
|
-
const { class: _class, ...rest } = attrs;
|
|
32
|
-
return rest;
|
|
33
|
-
});
|
|
30
|
+
const forwardedAttrs = computed(() => omitClass(attrs));
|
|
34
31
|
</script>
|
|
35
32
|
|
|
36
33
|
<template>
|
|
@@ -19,16 +19,19 @@ describe('UiRangeCalendar', () => {
|
|
|
19
19
|
const firstButton = clickableCells[0]?.querySelector('button');
|
|
20
20
|
const secondButton = clickableCells[5]?.querySelector('button');
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
if (!firstButton || !secondButton) {
|
|
23
|
+
throw new Error('Expected two enabled date buttons');
|
|
24
|
+
}
|
|
24
25
|
|
|
25
|
-
await userEvent.click(firstButton
|
|
26
|
-
await userEvent.click(secondButton
|
|
26
|
+
await userEvent.click(firstButton);
|
|
27
|
+
await userEvent.click(secondButton);
|
|
27
28
|
|
|
28
29
|
const emissions = emitted('update:modelValue');
|
|
29
|
-
|
|
30
|
+
if (!emissions) {
|
|
31
|
+
throw new Error('Expected update:modelValue to be emitted');
|
|
32
|
+
}
|
|
30
33
|
|
|
31
|
-
const lastEmission = emissions
|
|
34
|
+
const lastEmission = emissions[emissions.length - 1][0];
|
|
32
35
|
expect(lastEmission).toHaveProperty('start');
|
|
33
36
|
expect(lastEmission).toHaveProperty('end');
|
|
34
37
|
});
|