@aleph-alpha/ui-library 1.21.0 → 1.22.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 (62) hide show
  1. package/dist/system/index.d.ts +1118 -488
  2. package/dist/system/lib.js +16219 -15367
  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/UiItem/UiItem.vue +7 -1
  33. package/src/components/UiItem/types.ts +7 -0
  34. package/src/components/core/alert-dialog/AlertDialog.vue +1 -1
  35. package/src/components/core/alert-dialog/AlertDialogAction.vue +2 -6
  36. package/src/components/core/alert-dialog/AlertDialogCancel.vue +3 -7
  37. package/src/components/core/alert-dialog/AlertDialogContent.vue +15 -7
  38. package/src/components/core/alert-dialog/AlertDialogDescription.vue +3 -7
  39. package/src/components/core/alert-dialog/AlertDialogFooter.vue +1 -6
  40. package/src/components/core/alert-dialog/AlertDialogHeader.vue +1 -9
  41. package/src/components/core/alert-dialog/AlertDialogTitle.vue +3 -7
  42. package/src/components/core/dialog/Dialog.vue +15 -0
  43. package/src/components/core/dialog/DialogClose.vue +12 -0
  44. package/src/components/core/dialog/DialogContent.vue +48 -0
  45. package/src/components/core/dialog/DialogDescription.vue +17 -0
  46. package/src/components/core/dialog/DialogFooter.vue +12 -0
  47. package/src/components/core/dialog/DialogHeader.vue +9 -0
  48. package/src/components/core/dialog/DialogOverlay.vue +23 -0
  49. package/src/components/core/dialog/DialogTitle.vue +17 -0
  50. package/src/components/core/dialog/DialogTrigger.vue +12 -0
  51. package/src/components/core/dialog/index.ts +9 -0
  52. package/src/components/core/drawer/DrawerContent.vue +1 -1
  53. package/src/components/core/item/Item.vue +7 -4
  54. package/src/components/core/progress/Progress.vue +7 -2
  55. package/src/components/core/sheet/SheetOverlay.vue +1 -1
  56. package/src/components/index.ts +3 -0
  57. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +768 -0
  58. package/src/patterns/UiFileUpload/UiFileUpload.vue +46 -0
  59. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +123 -0
  60. package/src/patterns/UiFileUpload/index.ts +8 -0
  61. package/src/patterns/UiFileUpload/types.ts +12 -0
  62. package/src/patterns/index.ts +1 -0
@@ -0,0 +1,717 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { computed, ref, watch } from 'vue';
3
+ import {
4
+ UiDialog,
5
+ UiDialogClose,
6
+ UiDialogContent,
7
+ UiDialogDescription,
8
+ UiDialogHeader,
9
+ UiDialogTitle,
10
+ UiDialogTrigger,
11
+ } from './index';
12
+ import { UiButton } from '../UiButton';
13
+ import { UiField, UiFieldContent, UiFieldLabel } from '../UiField';
14
+ import { UiIcon } from '../UiIcon';
15
+ import { UiInput } from '../UiInput';
16
+
17
+ /**
18
+ * Modal dialog (reka-ui + design tokens). **`UiDialogContent`** defaults to **`max-w-[50vw]`**; use **`maxWidth`** with a preset (`max-w-sm` … `max-w-2xl`, `max-w-none`, etc.) to override. Built-in title/description headers include a dismiss control unless **`show-close-button`** is false or you use the **`#header`** slot (then add your own **`UiDialogClose`**).
19
+ * @category Components
20
+ * @useCases forms, confirmations, settings, multi-step flows
21
+ */
22
+ const meta: Meta<typeof UiDialog> = {
23
+ title: 'Components/UiDialog',
24
+ component: UiDialog,
25
+ tags: ['autodocs'],
26
+ argTypes: {
27
+ open: {
28
+ control: 'boolean',
29
+ description: 'Controlled open state (use `v-model:open`).',
30
+ },
31
+ modal: {
32
+ control: 'boolean',
33
+ description: 'If true, traps focus and blocks interaction with the page while open.',
34
+ },
35
+ },
36
+ args: {
37
+ open: false,
38
+ modal: true,
39
+ },
40
+ };
41
+
42
+ export default meta;
43
+ type Story = StoryObj<typeof UiDialog>;
44
+
45
+ function useUiDialogStoryArgs(args: { open?: boolean; modal?: boolean }) {
46
+ const open = ref(args.open ?? false);
47
+ watch(
48
+ () => args.open,
49
+ (v) => {
50
+ open.value = v ?? false;
51
+ },
52
+ );
53
+ const modal = computed(() => args.modal ?? true);
54
+ return { open, modal };
55
+ }
56
+
57
+ const defaultTemplateSource = `<script setup lang="ts">
58
+ import {
59
+ UiDialog,
60
+ UiDialogTrigger,
61
+ UiDialogContent,
62
+ UiDialogClose,
63
+ UiButton,
64
+ } from '@aleph-alpha/ui-library'
65
+ </script>
66
+
67
+ <template>
68
+ <UiDialog>
69
+ <UiDialogTrigger as-child>
70
+ <UiButton variant="outline">Open dialog</UiButton>
71
+ </UiDialogTrigger>
72
+ <UiDialogContent
73
+ max-width="max-w-[50vw]"
74
+ title="Edit profile"
75
+ description="Make changes to your profile here. Click save when done."
76
+ >
77
+ <p class="text-sm text-content-on-surface-secondary">
78
+ Dialog body content goes in the default slot.
79
+ </p>
80
+ <template #actions>
81
+ <UiDialogClose as-child>
82
+ <UiButton variant="outline">Cancel</UiButton>
83
+ </UiDialogClose>
84
+ <UiButton>Save changes</UiButton>
85
+ </template>
86
+ </UiDialogContent>
87
+ </UiDialog>
88
+ </template>`;
89
+
90
+ /**
91
+ * Typical dialog: trigger, `title` / `description` props, body slot, and optional `#actions` for buttons.
92
+ */
93
+ export const Default: Story = {
94
+ args: {
95
+ open: false,
96
+ },
97
+
98
+ render: (args) => ({
99
+ components: {
100
+ UiDialog,
101
+ UiDialogClose,
102
+ UiDialogContent,
103
+ UiDialogTrigger,
104
+ UiButton,
105
+ },
106
+ setup() {
107
+ return useUiDialogStoryArgs(args);
108
+ },
109
+ template: `
110
+ <UiDialog v-model:open="open" :modal="modal">
111
+ <UiDialogTrigger as-child>
112
+ <UiButton variant="outline">Open dialog</UiButton>
113
+ </UiDialogTrigger>
114
+ <UiDialogContent
115
+ max-width="max-w-[50vw]"
116
+ title="Edit profile"
117
+ description="Make changes to your profile here. Click save when done."
118
+ >
119
+ <p class="text-sm text-content-on-surface-secondary">
120
+ Dialog body content goes in the default slot. The header includes a close control; Cancel in actions also closes.
121
+ </p>
122
+ <template #actions>
123
+ <UiDialogClose as-child>
124
+ <UiButton variant="outline">Cancel</UiButton>
125
+ </UiDialogClose>
126
+ <UiButton>Save changes</UiButton>
127
+ </template>
128
+ </UiDialogContent>
129
+ </UiDialog>
130
+ `,
131
+ }),
132
+
133
+ parameters: {
134
+ docs: {
135
+ source: {
136
+ code: defaultTemplateSource,
137
+ },
138
+ },
139
+ },
140
+ };
141
+
142
+ const contentStoryTemplateSource = `<script setup lang="ts">
143
+ import {
144
+ UiDialog,
145
+ UiDialogTrigger,
146
+ UiDialogContent,
147
+ UiDialogClose,
148
+ UiButton,
149
+ } from '@aleph-alpha/ui-library'
150
+ </script>
151
+
152
+ <template>
153
+ <UiDialog>
154
+ <UiDialogTrigger as-child>
155
+ <UiButton variant="outline">Open content dialog</UiButton>
156
+ </UiDialogTrigger>
157
+ <UiDialogContent
158
+ max-width="max-w-lg"
159
+ title="Dialog title"
160
+ description="This is a dialog description."
161
+ >
162
+ <div class="flex max-h-[min(60vh,22rem)] flex-col gap-4 overflow-y-auto pr-1 text-sm text-content-on-surface-secondary">
163
+ <p class="shrink-0 font-medium text-content-on-surface-primary">Lorem ipsum</p>
164
+ <p>
165
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus interdum hendrerit ex vitae sodales. Donec id leo ipsum. Phasellus volutpat aliquet mauris, et blandit nulla laoreet vitae. Quisque ante dui, porta eu felis nec, scelerisque pharetra turpis.
166
+ </p>
167
+ <p>
168
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus interdum hendrerit ex vitae sodales. Donec id leo ipsum. Phasellus volutpat aliquet mauris, et blandit nulla laoreet vitae. Quisque ante dui, porta eu felis nec, scelerisque pharetra turpis.
169
+ </p>
170
+ <p>
171
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus interdum hendrerit ex vitae sodales. Donec id leo ipsum. Phasellus volutpat aliquet mauris, et blandit nulla laoreet vitae. Quisque ante dui, porta eu felis nec, scelerisque pharetra turpis.
172
+ </p>
173
+ </div>
174
+ <template #actions>
175
+ <UiDialogClose as-child>
176
+ <UiButton type="button" variant="outline">Cancel</UiButton>
177
+ </UiDialogClose>
178
+ </template>
179
+ </UiDialogContent>
180
+ </UiDialog>
181
+ </template>`;
182
+
183
+ /**
184
+ * Long body copy in the default slot: title, description, stacked paragraphs, single Cancel in `#actions`.
185
+ */
186
+ export const Content: Story = {
187
+ render: (args) => ({
188
+ components: {
189
+ UiDialog,
190
+ UiDialogClose,
191
+ UiDialogContent,
192
+ UiDialogTrigger,
193
+ UiButton,
194
+ },
195
+ setup() {
196
+ return useUiDialogStoryArgs(args);
197
+ },
198
+ template: `
199
+ <UiDialog v-model:open="open" :modal="modal">
200
+ <UiDialogTrigger as-child>
201
+ <UiButton variant="outline">Open content dialog</UiButton>
202
+ </UiDialogTrigger>
203
+ <UiDialogContent
204
+ max-width="max-w-lg"
205
+ title="Dialog title"
206
+ description="This is a dialog description."
207
+ >
208
+ <div class="flex max-h-[min(60vh,22rem)] flex-col gap-4 overflow-y-auto pr-1 text-sm text-content-on-surface-secondary">
209
+ <p class="shrink-0 font-medium text-content-on-surface-primary">Lorem ipsum</p>
210
+ <p>
211
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus interdum hendrerit ex vitae sodales. Donec id leo ipsum. Phasellus volutpat aliquet mauris, et blandit nulla laoreet vitae. Quisque ante dui, porta eu felis nec, scelerisque pharetra turpis.
212
+ </p>
213
+ <p>
214
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus interdum hendrerit ex vitae sodales. Donec id leo ipsum. Phasellus volutpat aliquet mauris, et blandit nulla laoreet vitae. Quisque ante dui, porta eu felis nec, scelerisque pharetra turpis.
215
+ </p>
216
+ <p>
217
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus interdum hendrerit ex vitae sodales. Donec id leo ipsum. Phasellus volutpat aliquet mauris, et blandit nulla laoreet vitae. Quisque ante dui, porta eu felis nec, scelerisque pharetra turpis.
218
+ </p>
219
+ </div>
220
+ <template #actions>
221
+ <UiDialogClose as-child>
222
+ <UiButton type="button" variant="outline">Cancel</UiButton>
223
+ </UiDialogClose>
224
+ </template>
225
+ </UiDialogContent>
226
+ </UiDialog>
227
+ `,
228
+ }),
229
+ parameters: {
230
+ docs: {
231
+ source: {
232
+ code: contentStoryTemplateSource,
233
+ },
234
+ },
235
+ },
236
+ };
237
+
238
+ const actionsSlotTemplateSource = `<script setup lang="ts">
239
+ import {
240
+ UiDialog,
241
+ UiDialogTrigger,
242
+ UiDialogContent,
243
+ UiDialogClose,
244
+ UiButton,
245
+ } from '@aleph-alpha/ui-library'
246
+ </script>
247
+
248
+ <template>
249
+ <UiDialog>
250
+ <UiDialogTrigger as-child>
251
+ <UiButton variant="outline">Open with actions slot</UiButton>
252
+ </UiDialogTrigger>
253
+ <UiDialogContent
254
+ max-width="max-w-lg"
255
+ title="Share document"
256
+ description="Anyone with the link can view this file."
257
+ >
258
+ <p class="text-sm text-content-on-surface-secondary">
259
+ Body content uses the default slot. Put buttons in <code>#actions</code>; they render in the
260
+ dialog footer row.
261
+ </p>
262
+ <template #actions>
263
+ <UiButton type="button" variant="ghost">Discard</UiButton>
264
+ <UiDialogClose as-child>
265
+ <UiButton type="button" variant="outline">Cancel</UiButton>
266
+ </UiDialogClose>
267
+ <UiButton type="button">Copy link</UiButton>
268
+ </template>
269
+ </UiDialogContent>
270
+ </UiDialog>
271
+ </template>`;
272
+
273
+ /**
274
+ * **`#actions` slot** — place all footer buttons here (wrapped in `DialogFooter` for alignment).
275
+ * Use `UiDialogClose` with `as-child` around buttons that should close the dialog.
276
+ */
277
+ export const WithActionsSlot: Story = {
278
+ render: (args) => ({
279
+ components: {
280
+ UiDialog,
281
+ UiDialogClose,
282
+ UiDialogContent,
283
+ UiDialogTrigger,
284
+ UiButton,
285
+ },
286
+ setup() {
287
+ return useUiDialogStoryArgs(args);
288
+ },
289
+ template: `
290
+ <UiDialog v-model:open="open" :modal="modal">
291
+ <UiDialogTrigger as-child>
292
+ <UiButton variant="outline">Open with actions slot</UiButton>
293
+ </UiDialogTrigger>
294
+ <UiDialogContent
295
+ max-width="max-w-lg"
296
+ title="Share document"
297
+ description="Anyone with the link can view this file."
298
+ >
299
+ <p class="text-sm text-content-on-surface-secondary">
300
+ Body content uses the default slot. Put buttons in <code class="rounded bg-background-surface-muted px-1 py-0.5 text-xs">#actions</code>; they render in the dialog footer row.
301
+ </p>
302
+ <template #actions>
303
+ <UiButton type="button" variant="ghost">Discard</UiButton>
304
+ <UiDialogClose as-child>
305
+ <UiButton type="button" variant="outline">Cancel</UiButton>
306
+ </UiDialogClose>
307
+ <UiButton type="button">Copy link</UiButton>
308
+ </template>
309
+ </UiDialogContent>
310
+ </UiDialog>
311
+ `,
312
+ }),
313
+ parameters: {
314
+ docs: {
315
+ source: {
316
+ code: actionsSlotTemplateSource,
317
+ },
318
+ },
319
+ },
320
+ };
321
+
322
+ const titleOnlyTemplateSource = `<script setup lang="ts">
323
+ import {
324
+ UiDialog,
325
+ UiDialogTrigger,
326
+ UiDialogContent,
327
+ UiButton,
328
+ } from '@aleph-alpha/ui-library'
329
+ </script>
330
+
331
+ <template>
332
+ <UiDialog>
333
+ <UiDialogTrigger as-child>
334
+ <UiButton variant="outline">Open</UiButton>
335
+ </UiDialogTrigger>
336
+ <UiDialogContent title="Notifications" max-width="max-w-md">
337
+ <p class="text-sm text-content-on-surface-secondary">
338
+ No description or footer actions — header still includes a close control (and Escape / overlay click).
339
+ </p>
340
+ </UiDialogContent>
341
+ </UiDialog>
342
+ </template>`;
343
+
344
+ /**
345
+ * Title only: no `description`, no `#actions` slot; header close is still shown by default.
346
+ */
347
+ export const TitleOnly: Story = {
348
+ render: (args) => ({
349
+ components: {
350
+ UiDialog,
351
+ UiDialogContent,
352
+ UiDialogTrigger,
353
+ UiButton,
354
+ },
355
+ setup() {
356
+ return useUiDialogStoryArgs(args);
357
+ },
358
+ template: `
359
+ <UiDialog v-model:open="open" :modal="modal">
360
+ <UiDialogTrigger as-child>
361
+ <UiButton variant="outline">Open</UiButton>
362
+ </UiDialogTrigger>
363
+ <UiDialogContent title="Notifications" max-width="max-w-md">
364
+ <p class="text-sm text-content-on-surface-secondary">
365
+ No description or footer actions — header still includes a close control (and Escape / overlay click).
366
+ </p>
367
+ </UiDialogContent>
368
+ </UiDialog>
369
+ `,
370
+ }),
371
+ parameters: {
372
+ docs: {
373
+ source: {
374
+ code: titleOnlyTemplateSource,
375
+ },
376
+ },
377
+ },
378
+ };
379
+
380
+ const maxWidthTemplateSource = `<script setup lang="ts">
381
+ import {
382
+ UiDialog,
383
+ UiDialogTrigger,
384
+ UiDialogContent,
385
+ UiDialogClose,
386
+ UiButton,
387
+ } from '@aleph-alpha/ui-library'
388
+ </script>
389
+
390
+ <template>
391
+ <UiDialog>
392
+ <UiDialogTrigger as-child>
393
+ <UiButton variant="outline">Narrow dialog</UiButton>
394
+ </UiDialogTrigger>
395
+ <UiDialogContent
396
+ max-width="max-w-lg"
397
+ title="Confirm"
398
+ description="This dialog uses max-width to stay readable on large screens."
399
+ >
400
+ <template #actions>
401
+ <UiDialogClose as-child>
402
+ <UiButton variant="outline">Close</UiButton>
403
+ </UiDialogClose>
404
+ </template>
405
+ </UiDialogContent>
406
+ </UiDialog>
407
+ </template>`;
408
+
409
+ /**
410
+ * Narrower than the default **`max-w-[50vw]`** by setting **`max-width="max-w-lg"`** (or another preset).
411
+ */
412
+ export const WithMaxWidth: Story = {
413
+ render: (args) => ({
414
+ components: {
415
+ UiDialog,
416
+ UiDialogClose,
417
+ UiDialogContent,
418
+ UiDialogTrigger,
419
+ UiButton,
420
+ },
421
+ setup() {
422
+ return useUiDialogStoryArgs(args);
423
+ },
424
+ template: `
425
+ <UiDialog v-model:open="open" :modal="modal">
426
+ <UiDialogTrigger as-child>
427
+ <UiButton variant="outline">Narrow dialog</UiButton>
428
+ </UiDialogTrigger>
429
+ <UiDialogContent
430
+ max-width="max-w-lg"
431
+ title="Confirm"
432
+ description="This dialog uses max-width to stay readable on large screens."
433
+ >
434
+ <template #actions>
435
+ <UiDialogClose as-child>
436
+ <UiButton variant="outline">Close</UiButton>
437
+ </UiDialogClose>
438
+ </template>
439
+ </UiDialogContent>
440
+ </UiDialog>
441
+ `,
442
+ }),
443
+ parameters: {
444
+ docs: {
445
+ source: {
446
+ code: maxWidthTemplateSource,
447
+ },
448
+ },
449
+ },
450
+ };
451
+
452
+ const customHeaderTemplateSource = `<script setup lang="ts">
453
+ import {
454
+ UiDialog,
455
+ UiDialogTrigger,
456
+ UiDialogContent,
457
+ UiDialogHeader,
458
+ UiDialogTitle,
459
+ UiDialogDescription,
460
+ UiDialogClose,
461
+ UiButton,
462
+ UiIcon,
463
+ } from '@aleph-alpha/ui-library'
464
+ </script>
465
+
466
+ <template>
467
+ <UiDialog>
468
+ <UiDialogTrigger as-child>
469
+ <UiButton variant="outline">Custom header</UiButton>
470
+ </UiDialogTrigger>
471
+ <UiDialogContent :show-close-button="false">
472
+ <template #header>
473
+ <div class="flex items-start justify-between gap-4">
474
+ <UiDialogHeader class="min-w-0 flex-1">
475
+ <UiDialogTitle>Custom header slot</UiDialogTitle>
476
+ <UiDialogDescription>
477
+ Use the header slot when you need full control; add your own close control here.
478
+ </UiDialogDescription>
479
+ </UiDialogHeader>
480
+ <UiDialogClose as-child>
481
+ <UiButton variant="ghost" class="size-9 shrink-0 p-0" aria-label="Close dialog">
482
+ <UiIcon name="x" :size="20" />
483
+ </UiButton>
484
+ </UiDialogClose>
485
+ </div>
486
+ </template>
487
+ <p class="text-sm text-content-on-surface-secondary">Main content.</p>
488
+ <template #actions>
489
+ <UiDialogClose as-child>
490
+ <UiButton variant="outline">Cancel</UiButton>
491
+ </UiDialogClose>
492
+ <UiButton>OK</UiButton>
493
+ </template>
494
+ </UiDialogContent>
495
+ </UiDialog>
496
+ </template>`;
497
+
498
+ /**
499
+ * Custom `#header` slot — supply layout yourself; set **`show-close-button`** to false to avoid a duplicate, then place **`UiDialogClose`** in the header row.
500
+ */
501
+ export const CustomHeaderSlot: Story = {
502
+ render: (args) => ({
503
+ components: {
504
+ UiDialog,
505
+ UiDialogClose,
506
+ UiDialogContent,
507
+ UiDialogDescription,
508
+ UiDialogHeader,
509
+ UiDialogTitle,
510
+ UiDialogTrigger,
511
+ UiButton,
512
+ UiIcon,
513
+ },
514
+ setup() {
515
+ return useUiDialogStoryArgs(args);
516
+ },
517
+ template: `
518
+ <UiDialog v-model:open="open" :modal="modal">
519
+ <UiDialogTrigger as-child>
520
+ <UiButton variant="outline">Custom header</UiButton>
521
+ </UiDialogTrigger>
522
+ <UiDialogContent :show-close-button="false">
523
+ <template #header>
524
+ <div class="flex items-start justify-between gap-4">
525
+ <UiDialogHeader class="min-w-0 flex-1">
526
+ <UiDialogTitle>Custom header slot</UiDialogTitle>
527
+ <UiDialogDescription>
528
+ Use the header slot when you need full control; add your own close control here.
529
+ </UiDialogDescription>
530
+ </UiDialogHeader>
531
+ <UiDialogClose as-child>
532
+ <UiButton variant="ghost" class="size-9 shrink-0 p-0" aria-label="Close dialog">
533
+ <UiIcon name="x" :size="20" />
534
+ </UiButton>
535
+ </UiDialogClose>
536
+ </div>
537
+ </template>
538
+ <p class="text-sm text-content-on-surface-secondary">Main content.</p>
539
+ <template #actions>
540
+ <UiDialogClose as-child>
541
+ <UiButton variant="outline">Cancel</UiButton>
542
+ </UiDialogClose>
543
+ <UiButton>OK</UiButton>
544
+ </template>
545
+ </UiDialogContent>
546
+ </UiDialog>
547
+ `,
548
+ }),
549
+ parameters: {
550
+ docs: {
551
+ source: {
552
+ code: customHeaderTemplateSource,
553
+ },
554
+ },
555
+ },
556
+ };
557
+
558
+ const formTemplateSource = `<script setup lang="ts">
559
+ import { ref } from 'vue'
560
+ import {
561
+ UiDialog,
562
+ UiDialogTrigger,
563
+ UiDialogContent,
564
+ UiDialogClose,
565
+ UiButton,
566
+ UiField,
567
+ UiFieldLabel,
568
+ UiFieldContent,
569
+ UiInput,
570
+ } from '@aleph-alpha/ui-library'
571
+
572
+ const name = ref('')
573
+ const email = ref('')
574
+
575
+ function onSubmit() {
576
+ // handle save (e.g. API call), then close dialog
577
+ }
578
+ </script>
579
+
580
+ <template>
581
+ <UiDialog>
582
+ <UiDialogTrigger as-child>
583
+ <UiButton variant="outline">New project</UiButton>
584
+ </UiDialogTrigger>
585
+ <UiDialogContent
586
+ max-width="max-w-lg"
587
+ title="Create project"
588
+ description="Add a name and contact email. You can change these later."
589
+ >
590
+ <form
591
+ id="dialog-create-project-form"
592
+ class="flex flex-col gap-4"
593
+ @submit.prevent="onSubmit"
594
+ >
595
+ <UiField>
596
+ <UiFieldLabel for="dialog-project-name">Project name</UiFieldLabel>
597
+ <UiFieldContent>
598
+ <UiInput
599
+ id="dialog-project-name"
600
+ v-model="name"
601
+ name="projectName"
602
+ placeholder="My project"
603
+ autocomplete="off"
604
+ />
605
+ </UiFieldContent>
606
+ </UiField>
607
+ <UiField>
608
+ <UiFieldLabel for="dialog-project-email">Email</UiFieldLabel>
609
+ <UiFieldContent>
610
+ <UiInput
611
+ id="dialog-project-email"
612
+ v-model="email"
613
+ type="email"
614
+ name="email"
615
+ placeholder="you@company.com"
616
+ autocomplete="email"
617
+ />
618
+ </UiFieldContent>
619
+ </UiField>
620
+ </form>
621
+ <template #actions>
622
+ <UiDialogClose as-child>
623
+ <UiButton type="button" variant="outline">Cancel</UiButton>
624
+ </UiDialogClose>
625
+ <UiButton type="submit" form="dialog-create-project-form">Create</UiButton>
626
+ </template>
627
+ </UiDialogContent>
628
+ </UiDialog>
629
+ </template>`;
630
+
631
+ /**
632
+ * Form in the default slot: use a `<form>`, `UiField` + `UiInput`, and wire primary submit to the action button via `form` + `id` when actions sit outside the form.
633
+ */
634
+ export const WithForm: Story = {
635
+ render: (args) => ({
636
+ components: {
637
+ UiDialog,
638
+ UiDialogClose,
639
+ UiDialogContent,
640
+ UiDialogTrigger,
641
+ UiButton,
642
+ UiField,
643
+ UiFieldContent,
644
+ UiFieldLabel,
645
+ UiInput,
646
+ },
647
+ setup() {
648
+ const { open, modal } = useUiDialogStoryArgs(args);
649
+ const name = ref('');
650
+ const email = ref('');
651
+
652
+ function onSubmit() {
653
+ name.value = '';
654
+ email.value = '';
655
+ }
656
+
657
+ return { open, modal, name, email, onSubmit };
658
+ },
659
+ template: `
660
+ <UiDialog v-model:open="open" :modal="modal">
661
+ <UiDialogTrigger as-child>
662
+ <UiButton variant="outline">New project</UiButton>
663
+ </UiDialogTrigger>
664
+ <UiDialogContent
665
+ max-width="max-w-lg"
666
+ title="Create project"
667
+ description="Add a name and contact email. You can change these later."
668
+ >
669
+ <form
670
+ id="dialog-create-project-form"
671
+ class="flex flex-col gap-4"
672
+ @submit.prevent="onSubmit"
673
+ >
674
+ <UiField>
675
+ <UiFieldLabel for="dialog-project-name">Project name</UiFieldLabel>
676
+ <UiFieldContent>
677
+ <UiInput
678
+ id="dialog-project-name"
679
+ v-model="name"
680
+ name="projectName"
681
+ placeholder="My project"
682
+ autocomplete="off"
683
+ />
684
+ </UiFieldContent>
685
+ </UiField>
686
+ <UiField>
687
+ <UiFieldLabel for="dialog-project-email">Email</UiFieldLabel>
688
+ <UiFieldContent>
689
+ <UiInput
690
+ id="dialog-project-email"
691
+ v-model="email"
692
+ type="email"
693
+ name="email"
694
+ placeholder="you@company.com"
695
+ autocomplete="email"
696
+ />
697
+ </UiFieldContent>
698
+ </UiField>
699
+ </form>
700
+ <template #actions>
701
+ <UiDialogClose as-child>
702
+ <UiButton type="button" variant="outline">Cancel</UiButton>
703
+ </UiDialogClose>
704
+ <UiButton type="submit" form="dialog-create-project-form">Create</UiButton>
705
+ </template>
706
+ </UiDialogContent>
707
+ </UiDialog>
708
+ `,
709
+ }),
710
+ parameters: {
711
+ docs: {
712
+ source: {
713
+ code: formTemplateSource,
714
+ },
715
+ },
716
+ },
717
+ };