@aleph-alpha/ui-library 1.20.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 (67) hide show
  1. package/dist/system/index.d.ts +1180 -486
  2. package/dist/system/lib.js +16242 -15201
  3. package/package.json +4 -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/UiCodeBlock/UiCodeBlock.stories.ts +352 -0
  10. package/src/components/UiCodeBlock/UiCodeBlock.vue +168 -0
  11. package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +210 -0
  12. package/src/components/UiCodeBlock/index.ts +2 -0
  13. package/src/components/UiCodeBlock/types.ts +60 -0
  14. package/src/components/UiDialog/UiDialog.stories.ts +717 -0
  15. package/src/components/UiDialog/UiDialog.vue +19 -0
  16. package/src/components/UiDialog/UiDialogClose.vue +16 -0
  17. package/src/components/UiDialog/UiDialogContent.vue +108 -0
  18. package/src/components/UiDialog/UiDialogDescription.vue +16 -0
  19. package/src/components/UiDialog/UiDialogFooter.vue +16 -0
  20. package/src/components/UiDialog/UiDialogHeader.vue +16 -0
  21. package/src/components/UiDialog/UiDialogTitle.vue +16 -0
  22. package/src/components/UiDialog/UiDialogTrigger.vue +16 -0
  23. package/src/components/UiDialog/__tests__/UiDialog.test.ts +328 -0
  24. package/src/components/UiDialog/index.ts +13 -0
  25. package/src/components/UiDialog/types.ts +136 -0
  26. package/src/components/UiFileItem/UiFileItem.stories.ts +268 -0
  27. package/src/components/UiFileItem/UiFileItem.vue +119 -0
  28. package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +66 -0
  29. package/src/components/UiFileItem/index.ts +2 -0
  30. package/src/components/UiFileItem/types.ts +27 -0
  31. package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +117 -0
  32. package/src/components/UiFileUploadBox/UiFileUploadBox.vue +230 -0
  33. package/src/components/UiFileUploadBox/__tests__/file-validation.test.ts +46 -0
  34. package/src/components/UiFileUploadBox/file-validation.ts +73 -0
  35. package/src/components/UiFileUploadBox/index.ts +7 -0
  36. package/src/components/UiFileUploadBox/types.ts +96 -0
  37. package/src/components/UiItem/UiItem.vue +7 -1
  38. package/src/components/UiItem/types.ts +7 -0
  39. package/src/components/core/alert-dialog/AlertDialog.vue +1 -1
  40. package/src/components/core/alert-dialog/AlertDialogAction.vue +2 -6
  41. package/src/components/core/alert-dialog/AlertDialogCancel.vue +3 -7
  42. package/src/components/core/alert-dialog/AlertDialogContent.vue +15 -7
  43. package/src/components/core/alert-dialog/AlertDialogDescription.vue +3 -7
  44. package/src/components/core/alert-dialog/AlertDialogFooter.vue +1 -6
  45. package/src/components/core/alert-dialog/AlertDialogHeader.vue +1 -9
  46. package/src/components/core/alert-dialog/AlertDialogTitle.vue +3 -7
  47. package/src/components/core/dialog/Dialog.vue +15 -0
  48. package/src/components/core/dialog/DialogClose.vue +12 -0
  49. package/src/components/core/dialog/DialogContent.vue +48 -0
  50. package/src/components/core/dialog/DialogDescription.vue +17 -0
  51. package/src/components/core/dialog/DialogFooter.vue +12 -0
  52. package/src/components/core/dialog/DialogHeader.vue +9 -0
  53. package/src/components/core/dialog/DialogOverlay.vue +23 -0
  54. package/src/components/core/dialog/DialogTitle.vue +17 -0
  55. package/src/components/core/dialog/DialogTrigger.vue +12 -0
  56. package/src/components/core/dialog/index.ts +9 -0
  57. package/src/components/core/drawer/DrawerContent.vue +1 -1
  58. package/src/components/core/item/Item.vue +7 -4
  59. package/src/components/core/progress/Progress.vue +7 -2
  60. package/src/components/core/sheet/SheetOverlay.vue +1 -1
  61. package/src/components/index.ts +4 -0
  62. package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +768 -0
  63. package/src/patterns/UiFileUpload/UiFileUpload.vue +46 -0
  64. package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +123 -0
  65. package/src/patterns/UiFileUpload/index.ts +8 -0
  66. package/src/patterns/UiFileUpload/types.ts +12 -0
  67. package/src/patterns/index.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/ui-library",
3
- "version": "1.20.0",
3
+ "version": "1.22.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/system/lib.js",
@@ -71,9 +71,9 @@
71
71
  "vitest": "^3.0.0",
72
72
  "vue-tsc": "^2.2.12",
73
73
  "wait-on": "9.0.3",
74
- "@aleph-alpha/eslint-config-frontend": "0.5.0",
75
74
  "@aleph-alpha/prettier-config-frontend": "0.4.0",
76
- "@aleph-alpha/tsconfig-frontend": "0.5.0"
75
+ "@aleph-alpha/tsconfig-frontend": "0.5.0",
76
+ "@aleph-alpha/eslint-config-frontend": "0.5.0"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "@unocss/preset-wind4": ">=66.0.0",
@@ -103,6 +103,7 @@
103
103
  "lucide-vue-next": "^0.556.0",
104
104
  "radix-vue": "^1.9.17",
105
105
  "reka-ui": "^2.7.0",
106
+ "shiki": "^3.0.0",
106
107
  "tailwind-merge": "^3.4.0"
107
108
  },
108
109
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { ref, watch } from 'vue';
2
3
  import {
3
4
  UiAlertDialog,
4
5
  UiAlertDialogAction,
@@ -12,12 +13,23 @@ import {
12
13
  } from './index';
13
14
  import { UiButton } from '../UiButton';
14
15
 
16
+ /**
17
+ * UiAlertDialog is for confirmations that block the page (destructive actions, irreversible steps).
18
+ * Use **`v-model:model`** for controlled mode (not `v-model:open`). Close via **Cancel** / **Action** in the footer (no header dismiss icon).
19
+ */
15
20
  const meta: Meta<typeof UiAlertDialog> = {
16
21
  title: 'Components/UiAlertDialog',
17
22
  component: UiAlertDialog,
18
23
  tags: ['autodocs'],
19
- argTypes: {},
20
- args: {},
24
+ argTypes: {
25
+ model: {
26
+ control: 'boolean',
27
+ description: 'Controlled open state (use `v-model:model`).',
28
+ },
29
+ },
30
+ args: {
31
+ model: false,
32
+ },
21
33
  };
22
34
 
23
35
  export default meta;
@@ -44,7 +56,7 @@ import {
44
56
  <UiAlertDialogTrigger as-child>
45
57
  <UiButton variant="outline">Show Dialog</UiButton>
46
58
  </UiAlertDialogTrigger>
47
- <UiAlertDialogContent>
59
+ <UiAlertDialogContent max-width="max-w-lg">
48
60
  <UiAlertDialogHeader>
49
61
  <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
50
62
  <UiAlertDialogDescription>
@@ -61,11 +73,10 @@ import {
61
73
  </template>`;
62
74
 
63
75
  /**
64
- * Alert dialog with Button trigger using `as-child`.
65
- * This is the recommended pattern from shadcn-vue docs.
76
+ * Recommended pattern: `UiButton` trigger with `as-child`, and `max-width` on content for readable line length.
66
77
  */
67
78
  export const Default: Story = {
68
- render: () => ({
79
+ render: (args) => ({
69
80
  components: {
70
81
  UiAlertDialog,
71
82
  UiAlertDialogAction,
@@ -78,12 +89,22 @@ export const Default: Story = {
78
89
  UiAlertDialogTrigger,
79
90
  UiButton,
80
91
  },
92
+ setup() {
93
+ const dialogModel = ref(args.model);
94
+ watch(
95
+ () => args.model,
96
+ (v) => {
97
+ dialogModel.value = v;
98
+ },
99
+ );
100
+ return { dialogModel };
101
+ },
81
102
  template: `
82
- <UiAlertDialog>
103
+ <UiAlertDialog v-model:model="dialogModel">
83
104
  <UiAlertDialogTrigger as-child>
84
105
  <UiButton variant="outline">Show Dialog</UiButton>
85
106
  </UiAlertDialogTrigger>
86
- <UiAlertDialogContent>
107
+ <UiAlertDialogContent max-width="max-w-lg">
87
108
  <UiAlertDialogHeader>
88
109
  <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
89
110
  <UiAlertDialogDescription>
@@ -125,7 +146,7 @@ import {
125
146
  <template>
126
147
  <UiAlertDialog>
127
148
  <UiAlertDialogTrigger>Open</UiAlertDialogTrigger>
128
- <UiAlertDialogContent>
149
+ <UiAlertDialogContent max-width="max-w-lg">
129
150
  <UiAlertDialogHeader>
130
151
  <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
131
152
  <UiAlertDialogDescription>
@@ -142,10 +163,10 @@ import {
142
163
  </template>`;
143
164
 
144
165
  /**
145
- * Simple alert dialog with plain text trigger.
166
+ * Plain text trigger (renders the default trigger button).
146
167
  */
147
168
  export const Simple: Story = {
148
- render: () => ({
169
+ render: (args) => ({
149
170
  components: {
150
171
  UiAlertDialog,
151
172
  UiAlertDialogAction,
@@ -157,10 +178,20 @@ export const Simple: Story = {
157
178
  UiAlertDialogTitle,
158
179
  UiAlertDialogTrigger,
159
180
  },
181
+ setup() {
182
+ const dialogModel = ref(args.model);
183
+ watch(
184
+ () => args.model,
185
+ (v) => {
186
+ dialogModel.value = v;
187
+ },
188
+ );
189
+ return { dialogModel };
190
+ },
160
191
  template: `
161
- <UiAlertDialog>
192
+ <UiAlertDialog v-model:model="dialogModel">
162
193
  <UiAlertDialogTrigger>Open</UiAlertDialogTrigger>
163
- <UiAlertDialogContent>
194
+ <UiAlertDialogContent max-width="max-w-lg">
164
195
  <UiAlertDialogHeader>
165
196
  <UiAlertDialogTitle>Are you absolutely sure?</UiAlertDialogTitle>
166
197
  <UiAlertDialogDescription>
@@ -184,3 +215,94 @@ export const Simple: Story = {
184
215
  },
185
216
  },
186
217
  };
218
+
219
+ const fullWidthTemplateSource = `<script setup lang="ts">
220
+ import {
221
+ UiAlertDialog,
222
+ UiAlertDialogAction,
223
+ UiAlertDialogCancel,
224
+ UiAlertDialogContent,
225
+ UiAlertDialogDescription,
226
+ UiAlertDialogFooter,
227
+ UiAlertDialogHeader,
228
+ UiAlertDialogTitle,
229
+ UiAlertDialogTrigger,
230
+ UiButton,
231
+ } from '@aleph-alpha/ui-library'
232
+ </script>
233
+
234
+ <template>
235
+ <UiAlertDialog>
236
+ <UiAlertDialogTrigger as-child>
237
+ <UiButton variant="outline">Wide alert</UiButton>
238
+ </UiAlertDialogTrigger>
239
+ <UiAlertDialogContent>
240
+ <UiAlertDialogHeader>
241
+ <UiAlertDialogTitle>Delete all items?</UiAlertDialogTitle>
242
+ <UiAlertDialogDescription>
243
+ Omit <code>max-width</code> on content for full width within page margins (same as default dialog).
244
+ </UiAlertDialogDescription>
245
+ </UiAlertDialogHeader>
246
+ <UiAlertDialogFooter>
247
+ <UiAlertDialogCancel>Cancel</UiAlertDialogCancel>
248
+ <UiAlertDialogAction>Delete</UiAlertDialogAction>
249
+ </UiAlertDialogFooter>
250
+ </UiAlertDialogContent>
251
+ </UiAlertDialog>
252
+ </template>`;
253
+
254
+ /**
255
+ * No `max-width` on content — uses full width within horizontal margins (for wider confirmation copy).
256
+ */
257
+ export const FullWidthContent: Story = {
258
+ render: (args) => ({
259
+ components: {
260
+ UiAlertDialog,
261
+ UiAlertDialogAction,
262
+ UiAlertDialogCancel,
263
+ UiAlertDialogContent,
264
+ UiAlertDialogDescription,
265
+ UiAlertDialogFooter,
266
+ UiAlertDialogHeader,
267
+ UiAlertDialogTitle,
268
+ UiAlertDialogTrigger,
269
+ UiButton,
270
+ },
271
+ setup() {
272
+ const dialogModel = ref(args.model);
273
+ watch(
274
+ () => args.model,
275
+ (v) => {
276
+ dialogModel.value = v;
277
+ },
278
+ );
279
+ return { dialogModel };
280
+ },
281
+ template: `
282
+ <UiAlertDialog v-model:model="dialogModel">
283
+ <UiAlertDialogTrigger as-child>
284
+ <UiButton variant="outline">Wide alert</UiButton>
285
+ </UiAlertDialogTrigger>
286
+ <UiAlertDialogContent>
287
+ <UiAlertDialogHeader>
288
+ <UiAlertDialogTitle>Delete all items?</UiAlertDialogTitle>
289
+ <UiAlertDialogDescription>
290
+ Omit max-width on content for full width within page margins (same as default dialog).
291
+ </UiAlertDialogDescription>
292
+ </UiAlertDialogHeader>
293
+ <UiAlertDialogFooter>
294
+ <UiAlertDialogCancel>Cancel</UiAlertDialogCancel>
295
+ <UiAlertDialogAction>Delete</UiAlertDialogAction>
296
+ </UiAlertDialogFooter>
297
+ </UiAlertDialogContent>
298
+ </UiAlertDialog>
299
+ `,
300
+ }),
301
+ parameters: {
302
+ docs: {
303
+ source: {
304
+ code: fullWidthTemplateSource,
305
+ },
306
+ },
307
+ },
308
+ };
@@ -1,18 +1,19 @@
1
1
  <script setup lang="ts">
2
- import { AlertDialog as ShadcnAlertDialog } from '@/components/core/alert-dialog';
3
- import { ModelRef } from 'vue';
2
+ import { Dialog as ShadcnDialog } from '@/components/core/dialog';
4
3
 
5
4
  defineOptions({
6
5
  name: 'UiAlertDialog',
7
6
  });
8
7
 
9
- const model: ModelRef<boolean> = defineModel<boolean>({
10
- default: false,
11
- });
8
+ /**
9
+ * Public API: **`v-model:model`** / prop **`model`**. Root is core **`Dialog`** (`DialogRoot`) with **`modal`** **`true`**.
10
+ * **`UiAlertDialogContent`** supplies **`role="alertdialog"`** and alert-specific behavior (outside dismiss, cancel focus).
11
+ */
12
+ const model = defineModel<boolean>('model', { default: false });
12
13
  </script>
13
14
 
14
15
  <template>
15
- <ShadcnAlertDialog v-model:open="model">
16
+ <ShadcnDialog v-model:open="model" modal>
16
17
  <slot />
17
- </ShadcnAlertDialog>
18
+ </ShadcnDialog>
18
19
  </template>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { AlertDialogHeader as ShadcnAlertDialogHeader } from '@/components/core/alert-dialog';
3
- import { UiAlertDialogHeaderProps } from './types';
3
+ import type { UiAlertDialogHeaderProps } from './types';
4
4
 
5
5
  defineOptions({
6
6
  name: 'UiAlertDialogHeader',
@@ -13,8 +13,8 @@ import {
13
13
  UiAlertDialogTrigger,
14
14
  } from '../index';
15
15
 
16
- function renderAlertDialog(options: { open?: boolean } = {}) {
17
- const { open } = options;
16
+ function renderAlertDialog(options: { model?: boolean } = {}) {
17
+ const { model } = options;
18
18
 
19
19
  return render({
20
20
  components: {
@@ -29,7 +29,7 @@ function renderAlertDialog(options: { open?: boolean } = {}) {
29
29
  UiAlertDialogTrigger,
30
30
  },
31
31
  template: `
32
- <UiAlertDialog ${open !== undefined ? ':modelValue="open"' : ''}>
32
+ <UiAlertDialog ${model !== undefined ? ':model="model"' : ''}>
33
33
  <UiAlertDialogTrigger>Open</UiAlertDialogTrigger>
34
34
  <UiAlertDialogContent>
35
35
  <UiAlertDialogHeader>
@@ -46,13 +46,13 @@ function renderAlertDialog(options: { open?: boolean } = {}) {
46
46
  </UiAlertDialog>
47
47
  `,
48
48
  setup() {
49
- return { open };
49
+ return { model };
50
50
  },
51
51
  });
52
52
  }
53
53
 
54
54
  function renderAlertDialogWithSpy() {
55
- const onUpdateModelValue = vi.fn();
55
+ const onUpdateModel = vi.fn();
56
56
 
57
57
  const result = render({
58
58
  components: {
@@ -67,7 +67,7 @@ function renderAlertDialogWithSpy() {
67
67
  UiAlertDialogTrigger,
68
68
  },
69
69
  template: `
70
- <UiAlertDialog @update:modelValue="onUpdateModelValue">
70
+ <UiAlertDialog @update:model="onUpdateModel">
71
71
  <UiAlertDialogTrigger>Open</UiAlertDialogTrigger>
72
72
  <UiAlertDialogContent>
73
73
  <UiAlertDialogHeader>
@@ -84,11 +84,11 @@ function renderAlertDialogWithSpy() {
84
84
  </UiAlertDialog>
85
85
  `,
86
86
  setup() {
87
- return { onUpdateModelValue };
87
+ return { onUpdateModel };
88
88
  },
89
89
  });
90
90
 
91
- return { ...result, onUpdateModelValue };
91
+ return { ...result, onUpdateModel };
92
92
  }
93
93
 
94
94
  describe('UiAlertDialog', () => {
@@ -103,8 +103,8 @@ describe('UiAlertDialog', () => {
103
103
  });
104
104
  });
105
105
 
106
- test('is visible when modelValue is true', async () => {
107
- const { getByText } = renderAlertDialog({ open: true });
106
+ test('is visible when model is true', async () => {
107
+ const { getByText } = renderAlertDialog({ model: true });
108
108
 
109
109
  await waitFor(() => {
110
110
  expect(getByText('Are you absolutely sure?')).toBeInTheDocument();
@@ -159,18 +159,18 @@ describe('UiAlertDialog', () => {
159
159
  });
160
160
  });
161
161
 
162
- test('emits update:modelValue when opened', async () => {
162
+ test('emits update:model when opened', async () => {
163
163
  const user = userEvent.setup();
164
- const { getByRole, onUpdateModelValue } = renderAlertDialogWithSpy();
164
+ const { getByRole, onUpdateModel } = renderAlertDialogWithSpy();
165
165
 
166
166
  await user.click(getByRole('button', { name: 'Open' }));
167
167
 
168
- expect(onUpdateModelValue).toHaveBeenCalledWith(true);
168
+ expect(onUpdateModel).toHaveBeenCalledWith(true);
169
169
  });
170
170
 
171
- test('emits update:modelValue when closed via Cancel', async () => {
171
+ test('emits update:model when closed via Cancel', async () => {
172
172
  const user = userEvent.setup();
173
- const { getByRole, onUpdateModelValue } = renderAlertDialogWithSpy();
173
+ const { getByRole, onUpdateModel } = renderAlertDialogWithSpy();
174
174
 
175
175
  await user.click(getByRole('button', { name: 'Open' }));
176
176
  await waitFor(() => {
@@ -179,6 +179,6 @@ describe('UiAlertDialog', () => {
179
179
 
180
180
  await user.click(getByRole('button', { name: 'Cancel' }));
181
181
 
182
- expect(onUpdateModelValue).toHaveBeenCalledWith(false);
182
+ expect(onUpdateModel).toHaveBeenCalledWith(false);
183
183
  });
184
184
  });
@@ -1,3 +1,5 @@
1
+ import type { UiDialogContentMaxWidth } from '../UiDialog/types';
2
+
1
3
  /**
2
4
  * Common prop inside the sub-components.
3
5
  */
@@ -6,6 +8,16 @@ export type UiAlertSubComponentCommonProps = {
6
8
  asChild?: boolean;
7
9
  };
8
10
 
11
+ /**
12
+ * Root alert dialog. Uses core **`Dialog`** (`components/core/dialog/Dialog.vue` → **`DialogRoot`**) with **`modal: true`**
13
+ * Root uses core **`Dialog`** with modal enabled. Subcomponents use **`UiAlertDialog*`** / alert **`DialogContent`** for **`alertdialog`** semantics.
14
+ * Use **`v-model:model`** for controlled mode (unlike **`UiDialog`**, which uses **`v-model:open`**).
15
+ */
16
+ export type UiAlertDialogProps = {
17
+ /** Controlled visibility (`v-model:model`); forwarded to **`DialogRoot`** as **`open`**. */
18
+ model?: boolean;
19
+ };
20
+
9
21
  /**
10
22
  * A modal dialog for confirmations that interrupt the user. Use for
11
23
  * destructive actions, important decisions, or critical confirmations.
@@ -20,6 +32,12 @@ export type UiAlertDialogContentProps = UiAlertSubComponentCommonProps & {
20
32
  * @default false
21
33
  */
22
34
  disableOutsidePointerEvents?: boolean;
35
+
36
+ /**
37
+ * Tailwind max-width utility for the panel (e.g. `max-w-lg` for compact confirmation dialogs).
38
+ * Omit for full width within horizontal margins.
39
+ */
40
+ maxWidth?: UiDialogContentMaxWidth;
23
41
  };
24
42
 
25
43
  /**