@aleph-alpha/ui-library 1.21.0 → 1.23.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 (128) hide show
  1. package/dist/system/index.d.ts +1520 -674
  2. package/dist/system/lib.js +21142 -19505
  3. package/package.json +3 -3
  4. package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +135 -13
  5. package/src/components/UiAlertDialog/UiAlertDialog.vue +8 -7
  6. package/src/components/UiAlertDialog/UiAlertDialogHeader.vue +1 -1
  7. package/src/components/UiAlertDialog/__tests__/UiAlertDialog.test.ts +16 -16
  8. package/src/components/UiAlertDialog/types.ts +18 -0
  9. package/src/components/UiDialog/UiDialog.stories.ts +717 -0
  10. package/src/components/UiDialog/UiDialog.vue +19 -0
  11. package/src/components/UiDialog/UiDialogClose.vue +16 -0
  12. package/src/components/UiDialog/UiDialogContent.vue +108 -0
  13. package/src/components/UiDialog/UiDialogDescription.vue +16 -0
  14. package/src/components/UiDialog/UiDialogFooter.vue +16 -0
  15. package/src/components/UiDialog/UiDialogHeader.vue +16 -0
  16. package/src/components/UiDialog/UiDialogTitle.vue +16 -0
  17. package/src/components/UiDialog/UiDialogTrigger.vue +16 -0
  18. package/src/components/UiDialog/__tests__/UiDialog.test.ts +328 -0
  19. package/src/components/UiDialog/index.ts +13 -0
  20. package/src/components/UiDialog/types.ts +136 -0
  21. package/src/components/UiFileItem/UiFileItem.stories.ts +268 -0
  22. package/src/components/UiFileItem/UiFileItem.vue +119 -0
  23. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +66 -0
  24. package/src/components/UiFileItem/index.ts +2 -0
  25. package/src/components/UiFileItem/types.ts +27 -0
  26. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +117 -0
  27. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +230 -0
  28. package/src/components/UiFileUploadBox/__tests__/file-validation.test.ts +46 -0
  29. package/src/components/UiFileUploadBox/file-validation.ts +73 -0
  30. package/src/components/UiFileUploadBox/index.ts +7 -0
  31. package/src/components/UiFileUploadBox/types.ts +96 -0
  32. package/src/components/UiIconButton/UiIconButton.vue +5 -1
  33. package/src/components/UiIconButton/types.ts +1 -1
  34. package/src/components/UiItem/UiItem.vue +7 -1
  35. package/src/components/UiItem/types.ts +7 -0
  36. package/src/components/core/alert-dialog/AlertDialog.vue +1 -1
  37. package/src/components/core/alert-dialog/AlertDialogAction.vue +2 -6
  38. package/src/components/core/alert-dialog/AlertDialogCancel.vue +3 -7
  39. package/src/components/core/alert-dialog/AlertDialogContent.vue +15 -7
  40. package/src/components/core/alert-dialog/AlertDialogDescription.vue +3 -7
  41. package/src/components/core/alert-dialog/AlertDialogFooter.vue +1 -6
  42. package/src/components/core/alert-dialog/AlertDialogHeader.vue +1 -9
  43. package/src/components/core/alert-dialog/AlertDialogTitle.vue +3 -7
  44. package/src/components/core/button/index.ts +6 -4
  45. package/src/components/core/dialog/Dialog.vue +15 -0
  46. package/src/components/core/dialog/DialogClose.vue +12 -0
  47. package/src/components/core/dialog/DialogContent.vue +48 -0
  48. package/src/components/core/dialog/DialogDescription.vue +17 -0
  49. package/src/components/core/dialog/DialogFooter.vue +12 -0
  50. package/src/components/core/dialog/DialogHeader.vue +9 -0
  51. package/src/components/core/dialog/DialogOverlay.vue +23 -0
  52. package/src/components/core/dialog/DialogTitle.vue +17 -0
  53. package/src/components/core/dialog/DialogTrigger.vue +12 -0
  54. package/src/components/core/dialog/index.ts +9 -0
  55. package/src/components/core/drawer/DrawerContent.vue +1 -1
  56. package/src/components/core/item/Item.vue +7 -4
  57. package/src/components/core/progress/Progress.vue +7 -2
  58. package/src/components/core/sheet/SheetOverlay.vue +1 -1
  59. package/src/components/core/sidebar/SidebarContent.vue +11 -3
  60. package/src/components/core/sidebar/SidebarFooter.vue +10 -2
  61. package/src/components/core/sidebar/SidebarGroup.vue +10 -2
  62. package/src/components/core/sidebar/SidebarGroupLabel.vue +1 -1
  63. package/src/components/core/sidebar/SidebarHeader.vue +10 -2
  64. package/src/components/core/sidebar/SidebarMenu.vue +12 -2
  65. package/src/components/core/sidebar/SidebarMenuButton.vue +2 -2
  66. package/src/components/core/sidebar/SidebarSeparator.vue +10 -2
  67. package/src/components/core/sidebar/SidebarTrigger.vue +2 -2
  68. package/src/components/core/sidebar/index.ts +1 -1
  69. package/src/components/core/sidebar/utils.ts +11 -2
  70. package/src/components/index.ts +3 -1
  71. package/src/directives/index.ts +1 -0
  72. package/src/directives/vOverlay.ts +94 -0
  73. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +768 -0
  74. package/src/patterns/UiFileUpload/UiFileUpload.vue +46 -0
  75. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +123 -0
  76. package/src/patterns/UiFileUpload/index.ts +8 -0
  77. package/src/patterns/UiFileUpload/types.ts +12 -0
  78. package/src/patterns/UiSidebar/UiSidebar.stories.ts +346 -0
  79. package/src/{components → patterns}/UiSidebar/UiSidebar.vue +9 -3
  80. package/src/patterns/UiSidebar/UiSidebarChatHistory.stories.ts +77 -0
  81. package/src/patterns/UiSidebar/UiSidebarChatHistory.vue +35 -0
  82. package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.stories.ts +85 -0
  83. package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.vue +139 -0
  84. package/src/patterns/UiSidebar/UiSidebarContent.vue +11 -0
  85. package/src/patterns/UiSidebar/UiSidebarFooter.vue +11 -0
  86. package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +91 -0
  87. package/src/patterns/UiSidebar/UiSidebarGroup.vue +42 -0
  88. package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +15 -0
  89. package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +163 -0
  90. package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +131 -0
  91. package/src/patterns/UiSidebar/UiSidebarHeader.vue +48 -0
  92. package/src/patterns/UiSidebar/UiSidebarInset.vue +11 -0
  93. package/src/patterns/UiSidebar/UiSidebarMenu.vue +11 -0
  94. package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +205 -0
  95. package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +121 -0
  96. package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +67 -0
  97. package/src/patterns/UiSidebar/UiSidebarMenuItem.vue +11 -0
  98. package/src/patterns/UiSidebar/UiSidebarMenuSub.vue +38 -0
  99. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.stories.ts +66 -0
  100. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +67 -0
  101. package/src/patterns/UiSidebar/UiSidebarPopover.vue +43 -0
  102. package/src/patterns/UiSidebar/UiSidebarPopoverMenu.stories.ts +56 -0
  103. package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +56 -0
  104. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.stories.ts +42 -0
  105. package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +79 -0
  106. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +61 -0
  107. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +81 -0
  108. package/src/patterns/UiSidebar/UiSidebarProvider.vue +11 -0
  109. package/src/patterns/UiSidebar/UiSidebarRail.vue +9 -0
  110. package/src/patterns/UiSidebar/UiSidebarTrigger.vue +35 -0
  111. package/src/patterns/UiSidebar/groupContext.ts +9 -0
  112. package/src/patterns/UiSidebar/index.ts +42 -0
  113. package/src/patterns/UiSidebar/types.ts +375 -0
  114. package/src/patterns/index.ts +2 -0
  115. package/src/components/UiSidebar/UiSidebar.stories.ts +0 -1188
  116. package/src/components/UiSidebar/UiSidebarGroupAction.vue +0 -18
  117. package/src/components/UiSidebar/UiSidebarGroupLabel.vue +0 -18
  118. package/src/components/UiSidebar/UiSidebarHeaderTrigger.vue +0 -53
  119. package/src/components/UiSidebar/UiSidebarInput.vue +0 -14
  120. package/src/components/UiSidebar/UiSidebarMenuAction.vue +0 -19
  121. package/src/components/UiSidebar/UiSidebarMenuButton.vue +0 -27
  122. package/src/components/UiSidebar/UiSidebarMenuSkeleton.vue +0 -16
  123. package/src/components/UiSidebar/UiSidebarMenuSubButton.vue +0 -24
  124. package/src/components/UiSidebar/UiSidebarProvider.vue +0 -16
  125. package/src/components/UiSidebar/UiSidebarSeparator.vue +0 -13
  126. package/src/components/UiSidebar/__tests__/UiSidebar.test.ts +0 -221
  127. package/src/components/UiSidebar/index.ts +0 -34
  128. package/src/components/UiSidebar/types.ts +0 -165
@@ -0,0 +1,19 @@
1
+ <script setup lang="ts">
2
+ import { Dialog as ShadcnDialog } from '@/components/core/dialog';
3
+ import type { UiDialogProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiDialog',
7
+ });
8
+
9
+ const props = withDefaults(defineProps<UiDialogProps>(), {
10
+ modal: true,
11
+ });
12
+ const open = defineModel<boolean>('open');
13
+ </script>
14
+
15
+ <template>
16
+ <ShadcnDialog v-model:open="open" :modal="props.modal">
17
+ <slot />
18
+ </ShadcnDialog>
19
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { DialogClose as ShadcnDialogClose } from '@/components/core/dialog';
3
+ import type { UiDialogCloseProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiDialogClose',
7
+ });
8
+
9
+ const props = defineProps<UiDialogCloseProps>();
10
+ </script>
11
+
12
+ <template>
13
+ <ShadcnDialogClose v-bind="props">
14
+ <slot />
15
+ </ShadcnDialogClose>
16
+ </template>
@@ -0,0 +1,108 @@
1
+ <script setup lang="ts">
2
+ import {
3
+ DialogContent as ShadcnDialogContent,
4
+ DialogDescription,
5
+ DialogFooter,
6
+ DialogHeader,
7
+ DialogTitle,
8
+ } from '@/components/core/dialog';
9
+ import { UiButton } from '@/components/UiButton';
10
+ import { UiIcon } from '@/components/UiIcon';
11
+ import UiDialogClose from './UiDialogClose.vue';
12
+ import type { DialogContentEmits } from 'reka-ui';
13
+ import { computed, mergeProps, toValue, useAttrs, useSlots } from 'vue';
14
+ import { reactiveOmit } from '@vueuse/core';
15
+ import { useForwardPropsEmits } from 'reka-ui';
16
+ import { cn } from '@/lib/utils';
17
+ import type { UiDialogContentProps } from './types';
18
+
19
+ defineOptions({
20
+ name: 'UiDialogContent',
21
+ inheritAttrs: false,
22
+ });
23
+
24
+ const props = withDefaults(defineProps<UiDialogContentProps>(), {
25
+ ariaTitle: 'Dialog',
26
+ ariaLabelCloseDialog: 'Close dialog',
27
+ maxWidth: 'max-w-[50vw]',
28
+ showCloseButton: true,
29
+ });
30
+
31
+ const emit = defineEmits<DialogContentEmits>();
32
+ const attrs = useAttrs();
33
+ const slots = useSlots();
34
+
35
+ const delegatedProps = reactiveOmit(
36
+ props,
37
+ 'title',
38
+ 'description',
39
+ 'ariaTitle',
40
+ 'ariaLabelCloseDialog',
41
+ 'maxWidth',
42
+ 'showCloseButton',
43
+ );
44
+ const forwarded = useForwardPropsEmits(delegatedProps, emit);
45
+
46
+ /** Align with other Ui* wrappers: merge forwarded reka props with fallthrough attrs. */
47
+ const rootBindings = computed(() => mergeProps(toValue(forwarded), attrs));
48
+
49
+ const showHeaderSlot = computed(() => typeof slots.header === 'function');
50
+ const showTitleBlock = computed(() => props.title !== undefined && props.title !== '');
51
+ const showDescription = computed(
52
+ () => props.description !== undefined && props.description !== '',
53
+ );
54
+ const showActions = computed(() => typeof slots.actions === 'function');
55
+ const showBuiltInHeaderChrome = computed(
56
+ () => !showHeaderSlot.value && (showTitleBlock.value || showDescription.value),
57
+ );
58
+ </script>
59
+
60
+ <template>
61
+ <ShadcnDialogContent v-bind="rootBindings" :max-width="maxWidth" :class="cn('gap-4')">
62
+ <template v-if="showHeaderSlot">
63
+ <slot name="header" />
64
+ </template>
65
+ <template v-else-if="showBuiltInHeaderChrome">
66
+ <div class="flex items-start justify-between gap-4">
67
+ <DialogHeader class="min-w-0 flex-1 gap-2 text-left">
68
+ <DialogTitle v-if="showTitleBlock">{{ title }}</DialogTitle>
69
+ <DialogTitle v-else class="sr-only">{{ ariaTitle }}</DialogTitle>
70
+ <DialogDescription v-if="showDescription">{{ description }}</DialogDescription>
71
+ </DialogHeader>
72
+ <UiDialogClose v-if="showCloseButton" as-child>
73
+ <UiButton
74
+ type="button"
75
+ variant="ghost"
76
+ class="size-9 shrink-0 p-0"
77
+ :aria-label="ariaLabelCloseDialog"
78
+ >
79
+ <UiIcon name="x" :size="20" aria-hidden="true" />
80
+ </UiButton>
81
+ </UiDialogClose>
82
+ </div>
83
+ </template>
84
+ <template v-else>
85
+ <div class="flex items-start justify-between gap-4">
86
+ <DialogTitle class="sr-only">{{ ariaTitle }}</DialogTitle>
87
+ <UiDialogClose v-if="showCloseButton" as-child>
88
+ <UiButton
89
+ type="button"
90
+ variant="ghost"
91
+ class="ms-auto size-9 shrink-0 p-0"
92
+ :aria-label="ariaLabelCloseDialog"
93
+ >
94
+ <UiIcon name="x" :size="20" aria-hidden="true" />
95
+ </UiButton>
96
+ </UiDialogClose>
97
+ </div>
98
+ </template>
99
+
100
+ <div class="min-h-0 flex-1">
101
+ <slot />
102
+ </div>
103
+
104
+ <DialogFooter v-if="showActions">
105
+ <slot name="actions" />
106
+ </DialogFooter>
107
+ </ShadcnDialogContent>
108
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { DialogDescription as ShadcnDialogDescription } from '@/components/core/dialog';
3
+ import type { UiDialogDescriptionProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiDialogDescription',
7
+ });
8
+
9
+ const props = defineProps<UiDialogDescriptionProps>();
10
+ </script>
11
+
12
+ <template>
13
+ <ShadcnDialogDescription v-bind="props">
14
+ <slot />
15
+ </ShadcnDialogDescription>
16
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { DialogFooter as ShadcnDialogFooter } from '@/components/core/dialog';
3
+ import type { UiDialogFooterProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiDialogFooter',
7
+ });
8
+
9
+ defineProps<UiDialogFooterProps>();
10
+ </script>
11
+
12
+ <template>
13
+ <ShadcnDialogFooter>
14
+ <slot />
15
+ </ShadcnDialogFooter>
16
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { DialogHeader as ShadcnDialogHeader } from '@/components/core/dialog';
3
+ import type { UiDialogHeaderProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiDialogHeader',
7
+ });
8
+
9
+ defineProps<UiDialogHeaderProps>();
10
+ </script>
11
+
12
+ <template>
13
+ <ShadcnDialogHeader>
14
+ <slot />
15
+ </ShadcnDialogHeader>
16
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { DialogTitle as ShadcnDialogTitle } from '@/components/core/dialog';
3
+ import type { UiDialogTitleProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiDialogTitle',
7
+ });
8
+
9
+ const props = defineProps<UiDialogTitleProps>();
10
+ </script>
11
+
12
+ <template>
13
+ <ShadcnDialogTitle v-bind="props">
14
+ <slot />
15
+ </ShadcnDialogTitle>
16
+ </template>
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import { DialogTrigger as ShadcnDialogTrigger } from '@/components/core/dialog';
3
+ import type { UiDialogTriggerProps } from './types';
4
+
5
+ defineOptions({
6
+ name: 'UiDialogTrigger',
7
+ });
8
+
9
+ const props = defineProps<UiDialogTriggerProps>();
10
+ </script>
11
+
12
+ <template>
13
+ <ShadcnDialogTrigger v-bind="props">
14
+ <slot />
15
+ </ShadcnDialogTrigger>
16
+ </template>
@@ -0,0 +1,328 @@
1
+ import { render, waitFor } from '@testing-library/vue';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { describe, expect, test, vi } from 'vitest';
4
+ import {
5
+ UiDialog,
6
+ UiDialogClose,
7
+ UiDialogContent,
8
+ UiDialogDescription,
9
+ UiDialogHeader,
10
+ UiDialogTitle,
11
+ UiDialogTrigger,
12
+ } from '../index';
13
+ import type { RenderResult } from '@testing-library/vue';
14
+ import { UiButton } from '../../UiButton';
15
+
16
+ /**
17
+ * Renders a minimal dialog for tests (trigger + content with title/description/actions).
18
+ * @param {object} [options] - Options.
19
+ * @param {boolean} [options.open] - When set, the dialog starts open.
20
+ * @returns {RenderResult} Testing Library render result.
21
+ */
22
+ function renderDialog(options: { open?: boolean } = {}): RenderResult {
23
+ const { open } = options;
24
+
25
+ return render({
26
+ components: {
27
+ UiDialog,
28
+ UiDialogClose,
29
+ UiDialogContent,
30
+ UiDialogTrigger,
31
+ UiButton,
32
+ },
33
+ template: `
34
+ <UiDialog ${open !== undefined ? ':open="open"' : ''}>
35
+ <UiDialogTrigger>Open</UiDialogTrigger>
36
+ <UiDialogContent title="Dialog title" description="Dialog description">
37
+ <p>Body</p>
38
+ <template #actions>
39
+ <UiDialogClose as-child>
40
+ <UiButton type="button" variant="outline">Cancel</UiButton>
41
+ </UiDialogClose>
42
+ </template>
43
+ </UiDialogContent>
44
+ </UiDialog>
45
+ `,
46
+ setup() {
47
+ return { open };
48
+ },
49
+ });
50
+ }
51
+
52
+ /**
53
+ * Renders dialog with `update:open` spy for controlled-mode assertions.
54
+ * @returns {RenderResult & { onUpdateOpen: ReturnType<typeof vi.fn> }} Render result and spy.
55
+ */
56
+ function renderDialogWithSpy() {
57
+ const onUpdateOpen = vi.fn();
58
+
59
+ const result = render({
60
+ components: {
61
+ UiDialog,
62
+ UiDialogClose,
63
+ UiDialogContent,
64
+ UiDialogTrigger,
65
+ UiButton,
66
+ },
67
+ template: `
68
+ <UiDialog @update:open="onUpdateOpen">
69
+ <UiDialogTrigger>Open</UiDialogTrigger>
70
+ <UiDialogContent title="Dialog title" description="Dialog description">
71
+ <p>Body</p>
72
+ <template #actions>
73
+ <UiDialogClose as-child>
74
+ <UiButton type="button" variant="outline">Cancel</UiButton>
75
+ </UiDialogClose>
76
+ </template>
77
+ </UiDialogContent>
78
+ </UiDialog>
79
+ `,
80
+ setup() {
81
+ return { onUpdateOpen };
82
+ },
83
+ });
84
+
85
+ return { ...result, onUpdateOpen };
86
+ }
87
+
88
+ describe('UiDialog', () => {
89
+ test('opens when trigger is clicked', async () => {
90
+ const user = userEvent.setup();
91
+ const { getByRole, getByText } = renderDialog();
92
+
93
+ await user.click(getByRole('button', { name: 'Open' }));
94
+
95
+ await waitFor(() => {
96
+ expect(getByText('Dialog title')).toBeInTheDocument();
97
+ expect(getByText('Dialog description')).toBeInTheDocument();
98
+ });
99
+ });
100
+
101
+ test('is visible when open is true', async () => {
102
+ const { getByText } = renderDialog({ open: true });
103
+
104
+ await waitFor(() => {
105
+ expect(getByText('Dialog title')).toBeInTheDocument();
106
+ });
107
+ });
108
+
109
+ test('renders dialog role when open', async () => {
110
+ const user = userEvent.setup();
111
+ const { getByRole } = renderDialog();
112
+
113
+ await user.click(getByRole('button', { name: 'Open' }));
114
+
115
+ await waitFor(() => {
116
+ expect(getByRole('dialog')).toBeInTheDocument();
117
+ });
118
+ });
119
+
120
+ test('closes when Cancel is clicked', async () => {
121
+ const user = userEvent.setup();
122
+ const { getByRole, queryByText } = renderDialog();
123
+
124
+ await user.click(getByRole('button', { name: 'Open' }));
125
+ await waitFor(() => {
126
+ expect(getByRole('dialog')).toBeInTheDocument();
127
+ });
128
+
129
+ await user.click(getByRole('button', { name: 'Cancel' }));
130
+
131
+ await waitFor(() => {
132
+ expect(queryByText('Dialog title')).not.toBeInTheDocument();
133
+ });
134
+ });
135
+
136
+ test('closes when header close control is clicked', async () => {
137
+ const user = userEvent.setup();
138
+ const { getByRole, queryByText } = renderDialog();
139
+
140
+ await user.click(getByRole('button', { name: 'Open' }));
141
+ await waitFor(() => {
142
+ expect(getByRole('button', { name: 'Close dialog' })).toBeInTheDocument();
143
+ });
144
+
145
+ await user.click(getByRole('button', { name: 'Close dialog' }));
146
+
147
+ await waitFor(() => {
148
+ expect(queryByText('Dialog title')).not.toBeInTheDocument();
149
+ });
150
+ });
151
+
152
+ test('closes on Escape key press', async () => {
153
+ const user = userEvent.setup();
154
+ const { getByRole, queryByText } = renderDialog();
155
+
156
+ await user.click(getByRole('button', { name: 'Open' }));
157
+ await waitFor(() => {
158
+ expect(getByRole('dialog')).toBeInTheDocument();
159
+ });
160
+
161
+ await user.keyboard('{Escape}');
162
+
163
+ await waitFor(() => {
164
+ expect(queryByText('Dialog title')).not.toBeInTheDocument();
165
+ });
166
+ });
167
+
168
+ test('emits update:open when opened', async () => {
169
+ const user = userEvent.setup();
170
+ const { getByRole, onUpdateOpen } = renderDialogWithSpy();
171
+
172
+ await user.click(getByRole('button', { name: 'Open' }));
173
+
174
+ expect(onUpdateOpen).toHaveBeenCalledWith(true);
175
+ });
176
+
177
+ test('emits update:open when closed via Cancel', async () => {
178
+ const user = userEvent.setup();
179
+ const { getByRole, onUpdateOpen } = renderDialogWithSpy();
180
+
181
+ await user.click(getByRole('button', { name: 'Open' }));
182
+ await waitFor(() => {
183
+ expect(getByRole('dialog')).toBeInTheDocument();
184
+ });
185
+
186
+ await user.click(getByRole('button', { name: 'Cancel' }));
187
+
188
+ expect(onUpdateOpen).toHaveBeenCalledWith(false);
189
+ });
190
+
191
+ test('works with trigger as-child and UiButton', async () => {
192
+ const user = userEvent.setup();
193
+ const onUpdateOpen = vi.fn();
194
+
195
+ const { getByRole, getByText } = render({
196
+ components: {
197
+ UiDialog,
198
+ UiDialogClose,
199
+ UiDialogContent,
200
+ UiDialogTrigger,
201
+ UiButton,
202
+ },
203
+ setup() {
204
+ return { onUpdateOpen };
205
+ },
206
+ template: `
207
+ <UiDialog @update:open="onUpdateOpen">
208
+ <UiDialogTrigger as-child>
209
+ <UiButton type="button" variant="outline">Open dialog</UiButton>
210
+ </UiDialogTrigger>
211
+ <UiDialogContent title="T" description="D">
212
+ <p>Content</p>
213
+ <template #actions>
214
+ <UiDialogClose as-child>
215
+ <UiButton type="button" variant="outline">Close</UiButton>
216
+ </UiDialogClose>
217
+ </template>
218
+ </UiDialogContent>
219
+ </UiDialog>
220
+ `,
221
+ });
222
+
223
+ await user.click(getByRole('button', { name: 'Open dialog' }));
224
+ expect(onUpdateOpen).toHaveBeenCalledWith(true);
225
+ await waitFor(() => {
226
+ expect(getByText('T')).toBeInTheDocument();
227
+ });
228
+ });
229
+ });
230
+
231
+ describe('UiDialogContent', () => {
232
+ test('renders custom header slot instead of title props', async () => {
233
+ const user = userEvent.setup();
234
+ const { getByRole, getByText } = render({
235
+ components: {
236
+ UiDialog,
237
+ UiDialogClose,
238
+ UiDialogContent,
239
+ UiDialogDescription,
240
+ UiDialogHeader,
241
+ UiDialogTitle,
242
+ UiDialogTrigger,
243
+ UiButton,
244
+ },
245
+ template: `
246
+ <UiDialog>
247
+ <UiDialogTrigger>Open</UiDialogTrigger>
248
+ <UiDialogContent>
249
+ <template #header>
250
+ <UiDialogHeader>
251
+ <UiDialogTitle>Custom title</UiDialogTitle>
252
+ <UiDialogDescription>Custom description</UiDialogDescription>
253
+ </UiDialogHeader>
254
+ </template>
255
+ <p>Main</p>
256
+ <template #actions>
257
+ <UiDialogClose as-child>
258
+ <UiButton type="button" variant="outline">OK</UiButton>
259
+ </UiDialogClose>
260
+ </template>
261
+ </UiDialogContent>
262
+ </UiDialog>
263
+ `,
264
+ });
265
+
266
+ await user.click(getByRole('button', { name: 'Open' }));
267
+ await waitFor(() => {
268
+ expect(getByText('Custom title')).toBeInTheDocument();
269
+ expect(getByText('Custom description')).toBeInTheDocument();
270
+ });
271
+ });
272
+
273
+ test('renders without actions slot', async () => {
274
+ const user = userEvent.setup();
275
+ const { getByRole, getByText, queryByRole } = render({
276
+ components: {
277
+ UiDialog,
278
+ UiDialogContent,
279
+ UiDialogTrigger,
280
+ },
281
+ template: `
282
+ <UiDialog>
283
+ <UiDialogTrigger>Open</UiDialogTrigger>
284
+ <UiDialogContent title="Only title" description="Only description">
285
+ <p>No footer actions</p>
286
+ </UiDialogContent>
287
+ </UiDialog>
288
+ `,
289
+ });
290
+
291
+ await user.click(getByRole('button', { name: 'Open' }));
292
+ await waitFor(() => {
293
+ expect(getByText('Only title')).toBeInTheDocument();
294
+ });
295
+ expect(getByText('No footer actions')).toBeInTheDocument();
296
+ expect(queryByRole('button', { name: 'Cancel' })).not.toBeInTheDocument();
297
+ expect(getByRole('button', { name: 'Close dialog' })).toBeInTheDocument();
298
+ });
299
+
300
+ test('uses custom ariaLabelCloseDialog for the header close button', async () => {
301
+ const user = userEvent.setup();
302
+ const { getByRole, queryByRole } = render({
303
+ components: {
304
+ UiDialog,
305
+ UiDialogContent,
306
+ UiDialogTrigger,
307
+ },
308
+ template: `
309
+ <UiDialog>
310
+ <UiDialogTrigger>Open</UiDialogTrigger>
311
+ <UiDialogContent
312
+ title="Titled"
313
+ description="Described"
314
+ aria-label-close-dialog="Dismiss dialog"
315
+ >
316
+ <p>Body</p>
317
+ </UiDialogContent>
318
+ </UiDialog>
319
+ `,
320
+ });
321
+
322
+ await user.click(getByRole('button', { name: 'Open' }));
323
+ await waitFor(() => {
324
+ expect(getByRole('button', { name: 'Dismiss dialog' })).toBeInTheDocument();
325
+ });
326
+ expect(queryByRole('button', { name: 'Close dialog' })).not.toBeInTheDocument();
327
+ });
328
+ });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Dialog building blocks. Subcomponents such as **`UiDialogClose`** / **`UiDialogTitle`** are thin wrappers
3
+ * over `components/core/dialog` with shared **`UiDialog*Props`** types; import from here for a stable public API.
4
+ */
5
+ export { default as UiDialog } from './UiDialog.vue';
6
+ export { default as UiDialogClose } from './UiDialogClose.vue';
7
+ export { default as UiDialogContent } from './UiDialogContent.vue';
8
+ export { default as UiDialogDescription } from './UiDialogDescription.vue';
9
+ export { default as UiDialogFooter } from './UiDialogFooter.vue';
10
+ export { default as UiDialogHeader } from './UiDialogHeader.vue';
11
+ export { default as UiDialogTitle } from './UiDialogTitle.vue';
12
+ export { default as UiDialogTrigger } from './UiDialogTrigger.vue';
13
+ export type * from './types';