@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,117 @@
1
+ import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
+ import { ref } from 'vue';
3
+ import { UiFileUploadBox } from '@/components/UiFileUploadBox';
4
+
5
+ const meta: Meta<typeof UiFileUploadBox> = {
6
+ title: 'Components/UiFileUploadBox',
7
+ component: UiFileUploadBox,
8
+ tags: ['autodocs'],
9
+ decorators: [
10
+ () => ({
11
+ template: '<div class="w-full max-w-lg p-4"><story /></div>',
12
+ }),
13
+ ],
14
+ args: {
15
+ accept: '.pdf,.docx,.txt,application/pdf',
16
+ multiple: true,
17
+ maxFileSizeBytes: 500 * 1024 * 1024,
18
+ disabled: false,
19
+ supportedTypesLabel: 'Supported file types: PDF, DOCX, TXT',
20
+ maxSizeLabel: '',
21
+ dropLabel: 'Drop files here',
22
+ chooseLabel: 'Choose files',
23
+ ariaLabel: 'File upload',
24
+ },
25
+ argTypes: {
26
+ accept: { control: 'text' },
27
+ multiple: { control: 'boolean' },
28
+ maxFileSizeBytes: {
29
+ control: 'number',
30
+ description:
31
+ 'Max file size in bytes (validation). When **maxSizeLabel** is blank, the footer shows `Max size: …` from this value.',
32
+ },
33
+ disabled: { control: 'boolean' },
34
+ supportedTypesLabel: {
35
+ control: 'text',
36
+ description: 'Footer left: supported-types hint. Clear to hide. Edit in Controls.',
37
+ },
38
+ maxSizeLabel: {
39
+ control: 'text',
40
+ description:
41
+ 'Footer right: max-size line. Leave blank for auto `Max size: …` from **maxFileSizeBytes**; type any text to override.',
42
+ },
43
+ dropLabel: { control: 'text' },
44
+ chooseLabel: { control: 'text' },
45
+ ariaLabel: { control: 'text' },
46
+ },
47
+ };
48
+
49
+ export default meta;
50
+ type Story = StoryObj<typeof UiFileUploadBox>;
51
+
52
+ const defaultTemplateSource = `<script setup lang="ts">
53
+ import { ref } from 'vue'
54
+ import { UiFileUploadBox } from '@aleph-alpha/ui-library'
55
+
56
+ const names = ref<string[]>([])
57
+ const lastError = ref('')
58
+
59
+ function onFiles(files: File[]) {
60
+ lastError.value = ''
61
+ names.value = files.map((f) => f.name)
62
+ }
63
+
64
+ function onError(e: { message: string }) {
65
+ lastError.value = e.message
66
+ }
67
+ </script>
68
+
69
+ <template>
70
+ <div class="max-w-md space-y-2">
71
+ <UiFileUploadBox
72
+ accept=".pdf,.docx,.txt,application/pdf"
73
+ :multiple="true"
74
+ :max-file-size-bytes="524288000"
75
+ supported-types-label="Supported file types: PDF, DOCX, TXT"
76
+ max-size-label="Max attachment size: 500 MB per file"
77
+ @update:files="onFiles"
78
+ @error="onError"
79
+ />
80
+ <p v-if="lastError" class="text-destructive text-sm">{{ lastError }}</p>
81
+ <p v-if="names.length" class="text-muted-foreground text-sm">Selected: {{ names.join(', ') }}</p>
82
+ </div>
83
+ </template>`;
84
+
85
+ /**
86
+ * Inline drop zone; use **Controls** to adjust props. Footer lines: **supportedTypesLabel** (left), **maxSizeLabel** (right; blank = auto from **maxFileSizeBytes**).
87
+ * Handle `update:files` and `error` in your app. For dialog + file list, see **Patterns / UiFileUpload**.
88
+ */
89
+ export const Default: Story = {
90
+ render: (args) => ({
91
+ components: { UiFileUploadBox },
92
+ setup() {
93
+ const names = ref<string[]>([]);
94
+ const lastError = ref('');
95
+ function onFiles(files: File[]) {
96
+ lastError.value = '';
97
+ names.value = files.map((x) => x.name);
98
+ }
99
+ function onError(e: { message: string }) {
100
+ lastError.value = e.message;
101
+ }
102
+ return { args, names, lastError, onFiles, onError };
103
+ },
104
+ template: `
105
+ <div class="max-w-md space-y-2">
106
+ <UiFileUploadBox v-bind="args" @update:files="onFiles" @error="onError" />
107
+ <p v-if="lastError" class="text-destructive text-sm">{{ lastError }}</p>
108
+ <p v-if="names.length" class="text-muted-foreground text-sm">Selected: {{ names.join(', ') }}</p>
109
+ </div>
110
+ `,
111
+ }),
112
+ parameters: {
113
+ docs: {
114
+ source: { code: defaultTemplateSource },
115
+ },
116
+ },
117
+ };
@@ -0,0 +1,230 @@
1
+ <script setup lang="ts">
2
+ import { UiButton } from '@/components/UiButton';
3
+ import { UiIcon } from '@/components/UiIcon';
4
+ import { cn } from '@/lib/utils';
5
+ import { computed, ref } from 'vue';
6
+ import { formatFileSize, validateFiles } from './file-validation';
7
+ import type { UiFileUploadBoxEmits, UiFileUploadBoxProps } from './types';
8
+
9
+ defineOptions({
10
+ name: 'UiFileUploadBox',
11
+ });
12
+
13
+ const props = withDefaults(defineProps<UiFileUploadBoxProps>(), {
14
+ accept: undefined,
15
+ multiple: true,
16
+ maxFileSizeBytes: undefined,
17
+ disabled: false,
18
+ supportedTypesLabel: '',
19
+ maxSizeLabel: '',
20
+ dropLabel: 'Drop files here',
21
+ chooseLabel: 'Choose files',
22
+ ariaLabel: 'File upload',
23
+ });
24
+
25
+ const emit = defineEmits<UiFileUploadBoxEmits>();
26
+
27
+ const inputRef = ref<HTMLInputElement | null>(null);
28
+ const isDragging = ref(false);
29
+ let dragDepth = 0;
30
+
31
+ const maxSizeLine = computed(() => {
32
+ const custom = props.maxSizeLabel?.trim();
33
+ if (custom) return custom;
34
+ if (props.maxFileSizeBytes != null) {
35
+ return `Max size: ${formatFileSize(props.maxFileSizeBytes)}`;
36
+ }
37
+ return '';
38
+ });
39
+
40
+ const showFooter = computed(() => !!(props.supportedTypesLabel?.trim() || maxSizeLine.value));
41
+
42
+ function openPicker() {
43
+ if (props.disabled) return;
44
+ emit('pickerOpen');
45
+ inputRef.value?.click();
46
+ }
47
+
48
+ function onZoneClick(e: MouseEvent) {
49
+ if (props.disabled) return;
50
+ emit('click', e);
51
+ const t = e.target as HTMLElement | null;
52
+ if (t?.closest?.('button')) return;
53
+ openPicker();
54
+ }
55
+
56
+ function onZoneKeydown(e: KeyboardEvent) {
57
+ if (props.disabled) return;
58
+ emit('keydown', e);
59
+ if (e.key === 'Enter' || e.key === ' ') {
60
+ e.preventDefault();
61
+ openPicker();
62
+ }
63
+ }
64
+
65
+ function onDragEnter(e: DragEvent) {
66
+ e.preventDefault();
67
+ e.stopPropagation();
68
+ emit('dragenter', e);
69
+ if (props.disabled) return;
70
+ dragDepth += 1;
71
+ isDragging.value = true;
72
+ }
73
+
74
+ function onDragLeave(e: DragEvent) {
75
+ e.preventDefault();
76
+ e.stopPropagation();
77
+ emit('dragleave', e);
78
+ if (props.disabled) return;
79
+ dragDepth -= 1;
80
+ if (dragDepth <= 0) {
81
+ dragDepth = 0;
82
+ isDragging.value = false;
83
+ }
84
+ }
85
+
86
+ function onDragOver(e: DragEvent) {
87
+ e.preventDefault();
88
+ e.stopPropagation();
89
+ emit('dragover', e);
90
+ if (e.dataTransfer) {
91
+ e.dataTransfer.dropEffect = props.disabled ? 'none' : 'copy';
92
+ }
93
+ }
94
+
95
+ function onDrop(e: DragEvent) {
96
+ e.preventDefault();
97
+ e.stopPropagation();
98
+ emit('drop', e);
99
+ dragDepth = 0;
100
+ isDragging.value = false;
101
+ if (props.disabled) return;
102
+ const dt = e.dataTransfer;
103
+ if (!dt?.files?.length) return;
104
+ processFileList(dt.files);
105
+ }
106
+
107
+ function onInputChange(e: Event) {
108
+ emit('change', e);
109
+ const input = e.target as HTMLInputElement;
110
+ if (!input.files?.length) return;
111
+ processFileList(input.files);
112
+ input.value = '';
113
+ }
114
+
115
+ function processFileList(fileList: FileList) {
116
+ const files = Array.from(fileList);
117
+ const { valid, errors } = validateFiles(files, {
118
+ accept: props.accept,
119
+ maxBytes: props.maxFileSizeBytes,
120
+ });
121
+ for (const { file, message } of errors) {
122
+ emit('error', { message, file });
123
+ }
124
+ // `multiple` on the hidden input only limits the OS picker; drag-and-drop can still
125
+ // deliver many files — honor single-file mode here too (first valid file wins).
126
+ if (!props.multiple) {
127
+ if (valid.length > 0) emit('update:files', [valid[0]]);
128
+ return;
129
+ }
130
+ if (valid.length) emit('update:files', valid);
131
+ }
132
+ </script>
133
+
134
+ <template>
135
+ <div class="flex flex-col gap-3">
136
+ <!-- Drop zone: tabindex -1 when disabled removes it from tab order (aria-disabled). -->
137
+ <!-- eslint-disable-next-line vuejs-accessibility/interactive-supports-focus -- intentional: disabled state is not keyboard-focusable -->
138
+ <div
139
+ role="button"
140
+ :tabindex="disabled ? -1 : 0"
141
+ :class="
142
+ cn(
143
+ 'border-border-surface-default bg-background-surface-modal focus-visible:ring-ring relative flex cursor-pointer flex-col items-center justify-center gap-4 rounded-lg border border-dashed p-8 text-center transition-colors outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
144
+ isDragging && 'border-1 border-border-surface-focus-ring',
145
+ disabled && 'cursor-not-allowed opacity-50',
146
+ )
147
+ "
148
+ :aria-disabled="disabled ? true : undefined"
149
+ :aria-label="ariaLabel"
150
+ @click="onZoneClick"
151
+ @keydown="onZoneKeydown"
152
+ @focus="emit('focus', $event)"
153
+ @blur="emit('blur', $event)"
154
+ @dragenter="onDragEnter"
155
+ @dragleave="onDragLeave"
156
+ @dragover="onDragOver"
157
+ @drop="onDrop"
158
+ >
159
+ <input
160
+ ref="inputRef"
161
+ type="file"
162
+ class="sr-only"
163
+ :accept="accept"
164
+ :multiple="multiple"
165
+ :disabled="disabled"
166
+ :aria-hidden="true"
167
+ tabindex="-1"
168
+ @change="onInputChange"
169
+ />
170
+
171
+ <div
172
+ :class="
173
+ cn(
174
+ 'text-base leading-6 text-content-on-surface-primary',
175
+ isDragging ? 'font-semibold' : 'font-medium',
176
+ )
177
+ "
178
+ >
179
+ <slot name="title">{{ dropLabel }}</slot>
180
+ </div>
181
+
182
+ <!-- Fixed 80×80 slot so inner circle can go 72 → 80 on drag without shifting the drop zone. -->
183
+ <div class="flex size-20 shrink-0 items-center justify-center" aria-hidden="true">
184
+ <div
185
+ :class="
186
+ cn(
187
+ 'flex items-center justify-center rounded-full transition-all duration-50 ease-out',
188
+ isDragging
189
+ ? 'size-20 bg-background-accent-soft'
190
+ : 'size-18 bg-background-surface-muted',
191
+ )
192
+ "
193
+ >
194
+ <slot name="icon">
195
+ <UiIcon
196
+ name="cloud-upload"
197
+ :size="32"
198
+ :class="
199
+ cn(isDragging ? 'text-content-on-surface-link' : 'text-content-on-surface-muted')
200
+ "
201
+ aria-hidden="true"
202
+ />
203
+ </slot>
204
+ </div>
205
+ </div>
206
+
207
+ <slot name="choose">
208
+ <UiButton
209
+ type="button"
210
+ variant="secondary"
211
+ size="sm"
212
+ :disabled="disabled"
213
+ @click.stop="openPicker"
214
+ >
215
+ {{ chooseLabel }}
216
+ </UiButton>
217
+ </slot>
218
+ </div>
219
+
220
+ <slot name="footer">
221
+ <div
222
+ v-if="showFooter"
223
+ class="text-muted-foreground flex flex-wrap items-center justify-between gap-2 text-xs"
224
+ >
225
+ <span v-if="supportedTypesLabel?.trim()">{{ supportedTypesLabel }}</span>
226
+ <span v-if="maxSizeLine" class="ml-auto">{{ maxSizeLine }}</span>
227
+ </div>
228
+ </slot>
229
+ </div>
230
+ </template>
@@ -0,0 +1,46 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { fileMatchesAccept, formatFileSize, validateFile, validateFiles } from '../file-validation';
3
+
4
+ describe('formatFileSize', () => {
5
+ test('formats bytes', () => {
6
+ expect(formatFileSize(0)).toBe('0 B');
7
+ expect(formatFileSize(1024)).toBe('1.0 KB');
8
+ expect(formatFileSize(500 * 1024 * 1024)).toMatch(/MB/);
9
+ });
10
+ });
11
+
12
+ describe('fileMatchesAccept', () => {
13
+ test('matches extension', () => {
14
+ const f = new File([''], 'x.PDF', { type: 'application/pdf' });
15
+ expect(fileMatchesAccept(f, '.pdf')).toBe(true);
16
+ expect(fileMatchesAccept(f, '.docx')).toBe(false);
17
+ });
18
+
19
+ test('matches mime wildcard', () => {
20
+ const f = new File([''], 'x.png', { type: 'image/png' });
21
+ expect(fileMatchesAccept(f, 'image/*')).toBe(true);
22
+ expect(fileMatchesAccept(f, 'application/pdf')).toBe(false);
23
+ });
24
+ });
25
+
26
+ describe('validateFile', () => {
27
+ test('rejects oversize', () => {
28
+ const f = new File(['xx'], 'a.txt', { type: 'text/plain' });
29
+ expect(validateFile(f, { maxBytes: 1 })).toMatch(/maximum size/i);
30
+ });
31
+
32
+ test('rejects wrong type', () => {
33
+ const f = new File(['x'], 'a.exe', { type: 'application/octet-stream' });
34
+ expect(validateFile(f, { accept: '.pdf' })).toBe('Unsupported file type');
35
+ });
36
+ });
37
+
38
+ describe('validateFiles', () => {
39
+ test('splits valid and errors', () => {
40
+ const good = new File([''], 'a.pdf', { type: 'application/pdf' });
41
+ const bad = new File([''], 'a.exe', { type: 'application/octet-stream' });
42
+ const { valid, errors } = validateFiles([good, bad], { accept: '.pdf' });
43
+ expect(valid).toHaveLength(1);
44
+ expect(errors).toHaveLength(1);
45
+ });
46
+ });
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Human-readable file size (binary units).
3
+ * @param bytes
4
+ */
5
+ export function formatFileSize(bytes: number): string {
6
+ if (bytes === 0) return '0 B';
7
+ const units = ['B', 'KB', 'MB', 'GB', 'TB'] as const;
8
+ const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
9
+ const n = bytes / 1024 ** i;
10
+ return `${n < 10 && i > 0 ? n.toFixed(1) : Math.round(n)} ${units[i]}`;
11
+ }
12
+
13
+ function normalizeMime(mime: string): boolean {
14
+ return mime.includes('/');
15
+ }
16
+
17
+ /**
18
+ * Whether a file satisfies an HTML-like `accept` string (extensions and/or MIME, comma-separated).
19
+ * @param file
20
+ * @param accept
21
+ */
22
+ export function fileMatchesAccept(file: File, accept: string): boolean {
23
+ const tokens = accept
24
+ .split(',')
25
+ .map((t) => t.trim())
26
+ .filter(Boolean);
27
+ if (tokens.length === 0) return true;
28
+
29
+ const name = file.name.toLowerCase();
30
+ const type = file.type.toLowerCase();
31
+
32
+ return tokens.some((token) => {
33
+ const t = token.toLowerCase();
34
+ if (t.startsWith('.')) {
35
+ return name.endsWith(t);
36
+ }
37
+ if (normalizeMime(t)) {
38
+ if (t.endsWith('/*')) {
39
+ const prefix = t.slice(0, -1);
40
+ return type.startsWith(prefix);
41
+ }
42
+ return type === t;
43
+ }
44
+ return false;
45
+ });
46
+ }
47
+
48
+ export function validateFile(
49
+ file: File,
50
+ options: { accept?: string; maxBytes?: number },
51
+ ): string | null {
52
+ if (options.maxBytes != null && file.size > options.maxBytes) {
53
+ return `File exceeds maximum size of ${formatFileSize(options.maxBytes)}`;
54
+ }
55
+ if (options.accept && options.accept.trim() !== '' && !fileMatchesAccept(file, options.accept)) {
56
+ return 'Unsupported file type';
57
+ }
58
+ return null;
59
+ }
60
+
61
+ export function validateFiles(
62
+ files: File[],
63
+ options: { accept?: string; maxBytes?: number },
64
+ ): { valid: File[]; errors: { file: File; message: string }[] } {
65
+ const valid: File[] = [];
66
+ const errors: { file: File; message: string }[] = [];
67
+ for (const file of files) {
68
+ const msg = validateFile(file, options);
69
+ if (msg) errors.push({ file, message: msg });
70
+ else valid.push(file);
71
+ }
72
+ return { valid, errors };
73
+ }
@@ -0,0 +1,7 @@
1
+ export { default as UiFileUploadBox } from './UiFileUploadBox.vue';
2
+ export type {
3
+ UiFileUploadBoxEmits,
4
+ UiFileUploadBoxErrorPayload,
5
+ UiFileUploadBoxProps,
6
+ } from './types';
7
+ export { formatFileSize, fileMatchesAccept, validateFile, validateFiles } from './file-validation';
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Drop zone + file picker for selecting files with optional type/size validation.
3
+ *
4
+ * **Emits:** see {@link UiFileUploadBoxEmits}.
5
+ *
6
+ * @category Components
7
+ * @useCases file upload area, drag and drop attachments
8
+ * @keywords file, upload, drag, drop, attachment
9
+ * @related UiFileItem, UiButton
10
+ */
11
+ export interface UiFileUploadBoxProps {
12
+ /** HTML `accept` string (MIME and/or extensions). */
13
+ accept?: string;
14
+ /** Allow multiple files in the picker and from drop. */
15
+ multiple?: boolean;
16
+ /** Reject files larger than this (bytes). */
17
+ maxFileSizeBytes?: number;
18
+ /** Disables the drop zone, file picker, and drag feedback. */
19
+ disabled?: boolean;
20
+ /**
21
+ * Footer left line (e.g. supported types). Clear or omit to hide.
22
+ * Override the default footer with the **`footer`** slot for fully custom markup.
23
+ */
24
+ supportedTypesLabel?: string;
25
+ /**
26
+ * Footer right line (max size hint). If blank/whitespace-only and `maxFileSizeBytes` is set,
27
+ * shows `Max size: …` from that limit. Set any non-empty string to replace that auto text (editable in Storybook Controls).
28
+ */
29
+ maxSizeLabel?: string;
30
+ /** Heading inside the drop zone. */
31
+ dropLabel?: string;
32
+ /** Label for the secondary button. */
33
+ chooseLabel?: string;
34
+ /** Accessible name for the drop region. */
35
+ ariaLabel?: string;
36
+ }
37
+
38
+ /**
39
+ * Payload for the **error** emit when a file fails `accept` or size validation.
40
+ */
41
+ export interface UiFileUploadBoxErrorPayload {
42
+ /** Human-readable reason (for example unsupported type or oversize). */
43
+ message: string;
44
+ /** The file that failed validation, when available. */
45
+ file?: File;
46
+ }
47
+
48
+ /**
49
+ * Event map for {@link UiFileUploadBoxProps}. Use with `defineEmits<UiFileUploadBoxEmits>()`.
50
+ */
51
+ export interface UiFileUploadBoxEmits {
52
+ /**
53
+ * Emitted with files that passed validation after pick or drop.
54
+ * In single-file mode, the array contains at most one item.
55
+ */
56
+ 'update:files': [files: File[]];
57
+
58
+ /**
59
+ * Emitted once per file that fails validation (wrong type or over max size).
60
+ * Valid files in the same batch still emit **update:files** separately.
61
+ */
62
+ error: [payload: UiFileUploadBoxErrorPayload];
63
+
64
+ /** Re-emitted from the drop zone when a drag gesture enters its bounds. */
65
+ dragenter: [event: DragEvent];
66
+
67
+ /** Re-emitted from the drop zone when a drag gesture leaves its bounds. */
68
+ dragleave: [event: DragEvent];
69
+
70
+ /** Re-emitted while dragging over the drop zone (use to customize `dropEffect`). */
71
+ dragover: [event: DragEvent];
72
+
73
+ /** Re-emitted when files are dropped; processing runs after this emit. */
74
+ drop: [event: DragEvent];
75
+
76
+ /** Emitted for clicks on the drop zone (before opening the picker unless the target is the choose button). */
77
+ click: [event: MouseEvent];
78
+
79
+ /** Emitted for keydown on the drop zone (Enter/Space opens the picker when enabled). */
80
+ keydown: [event: KeyboardEvent];
81
+
82
+ /** Emitted when the drop zone receives focus. */
83
+ focus: [event: FocusEvent];
84
+
85
+ /** Emitted when the drop zone loses focus. */
86
+ blur: [event: FocusEvent];
87
+
88
+ /** Emitted from the hidden file input after the user picks files (before validation). */
89
+ change: [event: Event];
90
+
91
+ /**
92
+ * Emitted immediately before the native file picker opens (zone click, choose button, or keyboard).
93
+ * Useful for analytics or closing overlays.
94
+ */
95
+ pickerOpen: [];
96
+ }
@@ -10,11 +10,17 @@
10
10
  variant: 'default',
11
11
  size: 'default',
12
12
  asChild: false,
13
+ withListSemantics: true,
13
14
  });
14
15
  </script>
15
16
 
16
17
  <template>
17
- <Item :variant="props.variant" :size="props.size" :as-child="props.asChild">
18
+ <Item
19
+ :variant="props.variant"
20
+ :size="props.size"
21
+ :as-child="props.asChild"
22
+ :with-list-semantics="props.withListSemantics"
23
+ >
18
24
  <slot />
19
25
  </Item>
20
26
  </template>
@@ -48,6 +48,13 @@ export interface UiItemProps {
48
48
  * @default false
49
49
  */
50
50
  asChild?: boolean;
51
+
52
+ /**
53
+ * When true (default), sets `role="listitem"` for use inside lists.
54
+ * Set false when the parent already provides list semantics (e.g. inside `<li>`).
55
+ * @default true
56
+ */
57
+ withListSemantics?: boolean;
51
58
  }
52
59
 
53
60
  /**
@@ -9,7 +9,7 @@
9
9
  </script>
10
10
 
11
11
  <template>
12
- <AlertDialogRoot #default="slotProps" data-slot="alert-dialog" v-bind="forwarded">
12
+ <AlertDialogRoot v-slot="slotProps" data-slot="alert-dialog" v-bind="forwarded">
13
13
  <slot v-bind="slotProps" />
14
14
  </AlertDialogRoot>
15
15
  </template>
@@ -1,18 +1,14 @@
1
1
  <script setup lang="ts">
2
2
  import type { AlertDialogActionProps } from 'reka-ui';
3
- import type { HTMLAttributes } from 'vue';
4
- import { reactiveOmit } from '@vueuse/core';
5
3
  import { AlertDialogAction } from 'reka-ui';
6
4
  import { cn } from '@/lib/utils';
7
5
  import { buttonVariants } from '@/components/core/button';
8
6
 
9
- const props = defineProps<AlertDialogActionProps & { class?: HTMLAttributes['class'] }>();
10
-
11
- const delegatedProps = reactiveOmit(props, 'class');
7
+ const props = defineProps<AlertDialogActionProps>();
12
8
  </script>
13
9
 
14
10
  <template>
15
- <AlertDialogAction v-bind="delegatedProps" :class="cn(buttonVariants(), props.class)">
11
+ <AlertDialogAction v-bind="props" :class="cn(buttonVariants())">
16
12
  <slot />
17
13
  </AlertDialogAction>
18
14
  </template>
@@ -1,20 +1,16 @@
1
1
  <script setup lang="ts">
2
2
  import type { AlertDialogCancelProps } from 'reka-ui';
3
- import type { HTMLAttributes } from 'vue';
4
- import { reactiveOmit } from '@vueuse/core';
5
3
  import { AlertDialogCancel } from 'reka-ui';
6
4
  import { cn } from '@/lib/utils';
7
5
  import { buttonVariants } from '@/components/core/button';
8
6
 
9
- const props = defineProps<AlertDialogCancelProps & { class?: HTMLAttributes['class'] }>();
10
-
11
- const delegatedProps = reactiveOmit(props, 'class');
7
+ const props = defineProps<AlertDialogCancelProps>();
12
8
  </script>
13
9
 
14
10
  <template>
15
11
  <AlertDialogCancel
16
- v-bind="delegatedProps"
17
- :class="cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', props.class)"
12
+ v-bind="props"
13
+ :class="cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0')"
18
14
  >
19
15
  <slot />
20
16
  </AlertDialogCancel>