@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.
- package/dist/system/index.d.ts +1520 -674
- package/dist/system/lib.js +21142 -19505
- package/package.json +3 -3
- package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +135 -13
- package/src/components/UiAlertDialog/UiAlertDialog.vue +8 -7
- package/src/components/UiAlertDialog/UiAlertDialogHeader.vue +1 -1
- package/src/components/UiAlertDialog/__tests__/UiAlertDialog.test.ts +16 -16
- package/src/components/UiAlertDialog/types.ts +18 -0
- package/src/components/UiDialog/UiDialog.stories.ts +717 -0
- package/src/components/UiDialog/UiDialog.vue +19 -0
- package/src/components/UiDialog/UiDialogClose.vue +16 -0
- package/src/components/UiDialog/UiDialogContent.vue +108 -0
- package/src/components/UiDialog/UiDialogDescription.vue +16 -0
- package/src/components/UiDialog/UiDialogFooter.vue +16 -0
- package/src/components/UiDialog/UiDialogHeader.vue +16 -0
- package/src/components/UiDialog/UiDialogTitle.vue +16 -0
- package/src/components/UiDialog/UiDialogTrigger.vue +16 -0
- package/src/components/UiDialog/__tests__/UiDialog.test.ts +328 -0
- package/src/components/UiDialog/index.ts +13 -0
- package/src/components/UiDialog/types.ts +136 -0
- package/src/components/UiFileItem/UiFileItem.stories.ts +268 -0
- package/src/components/UiFileItem/UiFileItem.vue +119 -0
- package/src/components/UiFileItem/__tests__/UiFileItem.test.ts +66 -0
- package/src/components/UiFileItem/index.ts +2 -0
- package/src/components/UiFileItem/types.ts +27 -0
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +117 -0
- package/src/components/UiFileUploadBox/UiFileUploadBox.vue +230 -0
- package/src/components/UiFileUploadBox/__tests__/file-validation.test.ts +46 -0
- package/src/components/UiFileUploadBox/file-validation.ts +73 -0
- package/src/components/UiFileUploadBox/index.ts +7 -0
- package/src/components/UiFileUploadBox/types.ts +96 -0
- package/src/components/UiIconButton/UiIconButton.vue +5 -1
- package/src/components/UiIconButton/types.ts +1 -1
- package/src/components/UiItem/UiItem.vue +7 -1
- package/src/components/UiItem/types.ts +7 -0
- package/src/components/core/alert-dialog/AlertDialog.vue +1 -1
- package/src/components/core/alert-dialog/AlertDialogAction.vue +2 -6
- package/src/components/core/alert-dialog/AlertDialogCancel.vue +3 -7
- package/src/components/core/alert-dialog/AlertDialogContent.vue +15 -7
- package/src/components/core/alert-dialog/AlertDialogDescription.vue +3 -7
- package/src/components/core/alert-dialog/AlertDialogFooter.vue +1 -6
- package/src/components/core/alert-dialog/AlertDialogHeader.vue +1 -9
- package/src/components/core/alert-dialog/AlertDialogTitle.vue +3 -7
- package/src/components/core/button/index.ts +6 -4
- package/src/components/core/dialog/Dialog.vue +15 -0
- package/src/components/core/dialog/DialogClose.vue +12 -0
- package/src/components/core/dialog/DialogContent.vue +48 -0
- package/src/components/core/dialog/DialogDescription.vue +17 -0
- package/src/components/core/dialog/DialogFooter.vue +12 -0
- package/src/components/core/dialog/DialogHeader.vue +9 -0
- package/src/components/core/dialog/DialogOverlay.vue +23 -0
- package/src/components/core/dialog/DialogTitle.vue +17 -0
- package/src/components/core/dialog/DialogTrigger.vue +12 -0
- package/src/components/core/dialog/index.ts +9 -0
- package/src/components/core/drawer/DrawerContent.vue +1 -1
- package/src/components/core/item/Item.vue +7 -4
- package/src/components/core/progress/Progress.vue +7 -2
- package/src/components/core/sheet/SheetOverlay.vue +1 -1
- package/src/components/core/sidebar/SidebarContent.vue +11 -3
- package/src/components/core/sidebar/SidebarFooter.vue +10 -2
- package/src/components/core/sidebar/SidebarGroup.vue +10 -2
- package/src/components/core/sidebar/SidebarGroupLabel.vue +1 -1
- package/src/components/core/sidebar/SidebarHeader.vue +10 -2
- package/src/components/core/sidebar/SidebarMenu.vue +12 -2
- package/src/components/core/sidebar/SidebarMenuButton.vue +2 -2
- package/src/components/core/sidebar/SidebarSeparator.vue +10 -2
- package/src/components/core/sidebar/SidebarTrigger.vue +2 -2
- package/src/components/core/sidebar/index.ts +1 -1
- package/src/components/core/sidebar/utils.ts +11 -2
- package/src/components/index.ts +3 -1
- package/src/directives/index.ts +1 -0
- package/src/directives/vOverlay.ts +94 -0
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +768 -0
- package/src/patterns/UiFileUpload/UiFileUpload.vue +46 -0
- package/src/patterns/UiFileUpload/__tests__/UiFileUpload.test.ts +123 -0
- package/src/patterns/UiFileUpload/index.ts +8 -0
- package/src/patterns/UiFileUpload/types.ts +12 -0
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +346 -0
- package/src/{components → patterns}/UiSidebar/UiSidebar.vue +9 -3
- package/src/patterns/UiSidebar/UiSidebarChatHistory.stories.ts +77 -0
- package/src/patterns/UiSidebar/UiSidebarChatHistory.vue +35 -0
- package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.stories.ts +85 -0
- package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.vue +139 -0
- package/src/patterns/UiSidebar/UiSidebarContent.vue +11 -0
- package/src/patterns/UiSidebar/UiSidebarFooter.vue +11 -0
- package/src/patterns/UiSidebar/UiSidebarGroup.stories.ts +91 -0
- package/src/patterns/UiSidebar/UiSidebarGroup.vue +42 -0
- package/src/patterns/UiSidebar/UiSidebarGroupContent.vue +15 -0
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.stories.ts +163 -0
- package/src/patterns/UiSidebar/UiSidebarGroupLabel.vue +131 -0
- package/src/patterns/UiSidebar/UiSidebarHeader.vue +48 -0
- package/src/patterns/UiSidebar/UiSidebarInset.vue +11 -0
- package/src/patterns/UiSidebar/UiSidebarMenu.vue +11 -0
- package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +205 -0
- package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +121 -0
- package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +67 -0
- package/src/patterns/UiSidebar/UiSidebarMenuItem.vue +11 -0
- package/src/patterns/UiSidebar/UiSidebarMenuSub.vue +38 -0
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.stories.ts +66 -0
- package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +67 -0
- package/src/patterns/UiSidebar/UiSidebarPopover.vue +43 -0
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.stories.ts +56 -0
- package/src/patterns/UiSidebar/UiSidebarPopoverMenu.vue +56 -0
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.stories.ts +42 -0
- package/src/patterns/UiSidebar/UiSidebarPopoverMenuItem.vue +79 -0
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.stories.ts +61 -0
- package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +81 -0
- package/src/patterns/UiSidebar/UiSidebarProvider.vue +11 -0
- package/src/patterns/UiSidebar/UiSidebarRail.vue +9 -0
- package/src/patterns/UiSidebar/UiSidebarTrigger.vue +35 -0
- package/src/patterns/UiSidebar/groupContext.ts +9 -0
- package/src/patterns/UiSidebar/index.ts +42 -0
- package/src/patterns/UiSidebar/types.ts +375 -0
- package/src/patterns/index.ts +2 -0
- package/src/components/UiSidebar/UiSidebar.stories.ts +0 -1188
- package/src/components/UiSidebar/UiSidebarGroupAction.vue +0 -18
- package/src/components/UiSidebar/UiSidebarGroupLabel.vue +0 -18
- package/src/components/UiSidebar/UiSidebarHeaderTrigger.vue +0 -53
- package/src/components/UiSidebar/UiSidebarInput.vue +0 -14
- package/src/components/UiSidebar/UiSidebarMenuAction.vue +0 -19
- package/src/components/UiSidebar/UiSidebarMenuButton.vue +0 -27
- package/src/components/UiSidebar/UiSidebarMenuSkeleton.vue +0 -16
- package/src/components/UiSidebar/UiSidebarMenuSubButton.vue +0 -24
- package/src/components/UiSidebar/UiSidebarProvider.vue +0 -16
- package/src/components/UiSidebar/UiSidebarSeparator.vue +0 -13
- package/src/components/UiSidebar/__tests__/UiSidebar.test.ts +0 -221
- package/src/components/UiSidebar/index.ts +0 -34
- package/src/components/UiSidebar/types.ts +0 -165
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { UiFileUploadBox } from '@/components/UiFileUploadBox';
|
|
3
|
+
import type { UiFileUploadBoxEmits } from '@/components/UiFileUploadBox/types';
|
|
4
|
+
import type { UiFileUploadProps } from './types';
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
name: 'UiFileUpload',
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const props = withDefaults(defineProps<UiFileUploadProps>(), {
|
|
11
|
+
accept: undefined,
|
|
12
|
+
multiple: true,
|
|
13
|
+
maxFileSizeBytes: undefined,
|
|
14
|
+
disabled: false,
|
|
15
|
+
supportedTypesLabel: '',
|
|
16
|
+
maxSizeLabel: '',
|
|
17
|
+
dropLabel: 'Drop files here',
|
|
18
|
+
chooseLabel: 'Choose files',
|
|
19
|
+
ariaLabel: 'File upload',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const emit = defineEmits<UiFileUploadBoxEmits>();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<UiFileUploadBox
|
|
27
|
+
v-bind="props"
|
|
28
|
+
@update:files="emit('update:files', $event)"
|
|
29
|
+
@error="emit('error', $event)"
|
|
30
|
+
@dragenter="emit('dragenter', $event)"
|
|
31
|
+
@dragleave="emit('dragleave', $event)"
|
|
32
|
+
@dragover="emit('dragover', $event)"
|
|
33
|
+
@drop="emit('drop', $event)"
|
|
34
|
+
@click="emit('click', $event)"
|
|
35
|
+
@keydown="emit('keydown', $event)"
|
|
36
|
+
@focus="emit('focus', $event)"
|
|
37
|
+
@blur="emit('blur', $event)"
|
|
38
|
+
@change="emit('change', $event)"
|
|
39
|
+
@picker-open="emit('pickerOpen')"
|
|
40
|
+
>
|
|
41
|
+
<template #title><slot name="title" /></template>
|
|
42
|
+
<template #icon><slot name="icon" /></template>
|
|
43
|
+
<template #choose><slot name="choose" /></template>
|
|
44
|
+
<template #footer><slot name="footer" /></template>
|
|
45
|
+
</UiFileUploadBox>
|
|
46
|
+
</template>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import { describe, expect, test } from 'vitest';
|
|
3
|
+
import UiFileUpload from '../UiFileUpload.vue';
|
|
4
|
+
|
|
5
|
+
describe('UiFileUpload', () => {
|
|
6
|
+
test('renders drop label and choose button', () => {
|
|
7
|
+
const { getByRole, getByText } = render(UiFileUpload, {
|
|
8
|
+
props: {
|
|
9
|
+
dropLabel: 'Drop files here',
|
|
10
|
+
chooseLabel: 'Choose files',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
expect(getByText('Drop files here')).toBeInTheDocument();
|
|
14
|
+
expect(getByRole('button', { name: 'Choose files' })).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('emits dragenter and drop with DragEvent', async () => {
|
|
18
|
+
const { getByRole, emitted } = render(UiFileUpload);
|
|
19
|
+
const zone = getByRole('button', { name: 'File upload' });
|
|
20
|
+
const file = new File(['x'], 'a.txt', { type: 'text/plain' });
|
|
21
|
+
const files = {
|
|
22
|
+
length: 1,
|
|
23
|
+
item: (i: number) => (i === 0 ? file : null),
|
|
24
|
+
*[Symbol.iterator]() {
|
|
25
|
+
yield file;
|
|
26
|
+
},
|
|
27
|
+
} as unknown as FileList;
|
|
28
|
+
const dataTransfer = { files } as unknown as DataTransfer;
|
|
29
|
+
|
|
30
|
+
zone.dispatchEvent(new Event('dragenter', { bubbles: true, cancelable: true }));
|
|
31
|
+
expect(emitted('dragenter')).toHaveLength(1);
|
|
32
|
+
|
|
33
|
+
const dropEv = new Event('drop', { bubbles: true, cancelable: true });
|
|
34
|
+
Object.defineProperty(dropEv, 'dataTransfer', {
|
|
35
|
+
value: dataTransfer,
|
|
36
|
+
configurable: true,
|
|
37
|
+
});
|
|
38
|
+
zone.dispatchEvent(dropEv);
|
|
39
|
+
expect(emitted('drop')).toHaveLength(1);
|
|
40
|
+
expect(emitted('update:files')).toBeTruthy();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('with multiple=false, drop emits only the first valid file', async () => {
|
|
44
|
+
const { getByRole, emitted } = render(UiFileUpload, {
|
|
45
|
+
props: {
|
|
46
|
+
multiple: false,
|
|
47
|
+
accept: '.txt,text/plain',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const zone = getByRole('button', { name: 'File upload' });
|
|
51
|
+
const first = new File(['a'], 'a.txt', { type: 'text/plain' });
|
|
52
|
+
const second = new File(['b'], 'b.txt', { type: 'text/plain' });
|
|
53
|
+
const list = [first, second];
|
|
54
|
+
const files = {
|
|
55
|
+
length: list.length,
|
|
56
|
+
item: (i: number) => list[i] ?? null,
|
|
57
|
+
*[Symbol.iterator]() {
|
|
58
|
+
yield* list;
|
|
59
|
+
},
|
|
60
|
+
} as unknown as FileList;
|
|
61
|
+
const dataTransfer = { files } as unknown as DataTransfer;
|
|
62
|
+
const dropEv = new Event('drop', { bubbles: true, cancelable: true });
|
|
63
|
+
Object.defineProperty(dropEv, 'dataTransfer', {
|
|
64
|
+
value: dataTransfer,
|
|
65
|
+
configurable: true,
|
|
66
|
+
});
|
|
67
|
+
zone.dispatchEvent(dropEv);
|
|
68
|
+
expect(emitted('update:files')).toHaveLength(1);
|
|
69
|
+
const payload = emitted('update:files')?.[0]?.[0] as File[];
|
|
70
|
+
expect(payload).toHaveLength(1);
|
|
71
|
+
expect(payload[0].name).toBe('a.txt');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('footer shows custom maxSizeLabel when set', () => {
|
|
75
|
+
const { getByText } = render(UiFileUpload, {
|
|
76
|
+
props: {
|
|
77
|
+
maxSizeLabel: 'Per file: 2 MB maximum',
|
|
78
|
+
maxFileSizeBytes: 500 * 1024 * 1024,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
expect(getByText('Per file: 2 MB maximum')).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('footer shows auto max size when maxSizeLabel is blank', () => {
|
|
85
|
+
const { getByText } = render(UiFileUpload, {
|
|
86
|
+
props: {
|
|
87
|
+
maxSizeLabel: '',
|
|
88
|
+
maxFileSizeBytes: 1024 * 1024,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
expect(getByText('Max size: 1.0 MB')).toBeInTheDocument();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('when disabled, drop zone is not in tab order', () => {
|
|
95
|
+
const { container } = render(UiFileUpload, {
|
|
96
|
+
props: { disabled: true, ariaLabel: 'Attachment upload' },
|
|
97
|
+
});
|
|
98
|
+
const zone = container.querySelector('[aria-label="Attachment upload"]') as HTMLElement;
|
|
99
|
+
expect(zone).toBeTruthy();
|
|
100
|
+
expect(zone.getAttribute('tabindex')).toBe('-1');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('emits error for file failing accept', async () => {
|
|
104
|
+
const { container, emitted } = render(UiFileUpload, {
|
|
105
|
+
props: {
|
|
106
|
+
accept: '.pdf',
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
const input = container.querySelector('input[type="file"]') as HTMLInputElement;
|
|
110
|
+
const bad = new File(['x'], 'x.exe', { type: 'application/octet-stream' });
|
|
111
|
+
const fileList = {
|
|
112
|
+
length: 1,
|
|
113
|
+
item: (i: number) => (i === 0 ? bad : null),
|
|
114
|
+
*[Symbol.iterator]() {
|
|
115
|
+
yield bad;
|
|
116
|
+
},
|
|
117
|
+
} as unknown as FileList;
|
|
118
|
+
Object.defineProperty(input, 'files', { value: fileList, configurable: true });
|
|
119
|
+
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
120
|
+
expect(emitted('error')).toBeTruthy();
|
|
121
|
+
expect(emitted('error')?.[0]?.[0]).toMatchObject({ message: 'Unsupported file type' });
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UiFileUploadBoxProps } from '@/components/UiFileUploadBox/types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Composition-friendly file upload (same API as {@link UiFileUploadBoxProps}).
|
|
5
|
+
* Implementation delegates to {@link UiFileUploadBox}.
|
|
6
|
+
*
|
|
7
|
+
* @category Patterns
|
|
8
|
+
* @useCases file upload dialog, drag and drop attachments
|
|
9
|
+
* @keywords file, upload, drag, drop, attachment
|
|
10
|
+
* @related UiFileItem, UiDialog, UiFileUploadBox
|
|
11
|
+
*/
|
|
12
|
+
export type UiFileUploadProps = UiFileUploadBoxProps;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import { Bot, FileText, Folder, Home, Languages, MessageSquare, Mic } from 'lucide-vue-next';
|
|
4
|
+
import Popover from '../../components/core/popover/Popover.vue';
|
|
5
|
+
import PopoverContent from '../../components/core/popover/PopoverContent.vue';
|
|
6
|
+
import PopoverTrigger from '../../components/core/popover/PopoverTrigger.vue';
|
|
7
|
+
import UiSidebar from './UiSidebar.vue';
|
|
8
|
+
import UiSidebarChatHistory from './UiSidebarChatHistory.vue';
|
|
9
|
+
import UiSidebarChatHistoryItem from './UiSidebarChatHistoryItem.vue';
|
|
10
|
+
import UiSidebarContent from './UiSidebarContent.vue';
|
|
11
|
+
import UiSidebarFooter from './UiSidebarFooter.vue';
|
|
12
|
+
import UiSidebarGroup from './UiSidebarGroup.vue';
|
|
13
|
+
import UiSidebarGroupContent from './UiSidebarGroupContent.vue';
|
|
14
|
+
import UiSidebarGroupLabel from './UiSidebarGroupLabel.vue';
|
|
15
|
+
import UiSidebarHeader from './UiSidebarHeader.vue';
|
|
16
|
+
import UiSidebarInset from './UiSidebarInset.vue';
|
|
17
|
+
import UiSidebarMenu from './UiSidebarMenu.vue';
|
|
18
|
+
import UiSidebarMenuButton from './UiSidebarMenuButton.vue';
|
|
19
|
+
import UiSidebarMenuItem from './UiSidebarMenuItem.vue';
|
|
20
|
+
import UiSidebarPopoverMenu from './UiSidebarPopoverMenu.vue';
|
|
21
|
+
import UiSidebarProvider from './UiSidebarProvider.vue';
|
|
22
|
+
import UiSidebarRail from './UiSidebarRail.vue';
|
|
23
|
+
|
|
24
|
+
const meta: Meta<typeof UiSidebar> = {
|
|
25
|
+
title: 'Patterns/UiSidebar/UiSidebar',
|
|
26
|
+
component: UiSidebar,
|
|
27
|
+
tags: ['autodocs'],
|
|
28
|
+
args: {
|
|
29
|
+
side: 'left',
|
|
30
|
+
variant: 'sidebar',
|
|
31
|
+
collapsible: 'icon',
|
|
32
|
+
},
|
|
33
|
+
parameters: {
|
|
34
|
+
layout: 'fullscreen',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
|
|
40
|
+
type Story = StoryObj<typeof UiSidebar>;
|
|
41
|
+
|
|
42
|
+
const renderStory = (args: Story['args']) => ({
|
|
43
|
+
components: {
|
|
44
|
+
Bot,
|
|
45
|
+
FileText,
|
|
46
|
+
Folder,
|
|
47
|
+
Home,
|
|
48
|
+
Languages,
|
|
49
|
+
MessageSquare,
|
|
50
|
+
Mic,
|
|
51
|
+
Popover,
|
|
52
|
+
PopoverContent,
|
|
53
|
+
PopoverTrigger,
|
|
54
|
+
UiSidebar,
|
|
55
|
+
UiSidebarChatHistory,
|
|
56
|
+
UiSidebarChatHistoryItem,
|
|
57
|
+
UiSidebarContent,
|
|
58
|
+
UiSidebarFooter,
|
|
59
|
+
UiSidebarGroup,
|
|
60
|
+
UiSidebarGroupContent,
|
|
61
|
+
UiSidebarGroupLabel,
|
|
62
|
+
UiSidebarHeader,
|
|
63
|
+
UiSidebarInset,
|
|
64
|
+
UiSidebarMenu,
|
|
65
|
+
UiSidebarMenuButton,
|
|
66
|
+
UiSidebarMenuItem,
|
|
67
|
+
UiSidebarPopoverMenu,
|
|
68
|
+
UiSidebarProvider,
|
|
69
|
+
UiSidebarRail,
|
|
70
|
+
},
|
|
71
|
+
setup() {
|
|
72
|
+
const primaryItems = [
|
|
73
|
+
{ title: 'Home', icon: Home },
|
|
74
|
+
{ title: 'Collections', icon: Folder },
|
|
75
|
+
{ title: 'Chat', icon: MessageSquare, isActive: true },
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
const agentItems = ref([
|
|
79
|
+
{ title: 'Design engineering', icon: Bot },
|
|
80
|
+
{ title: 'Invoice generator', icon: FileText },
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
const appItems = ref([
|
|
84
|
+
{ title: 'Translation', icon: Languages },
|
|
85
|
+
{ title: 'Transcription', icon: Mic },
|
|
86
|
+
]);
|
|
87
|
+
|
|
88
|
+
const historyItems = ref([
|
|
89
|
+
{ title: 'Project proposal overview', metaStart: 'Today', metaEnd: 'Innsbruck' },
|
|
90
|
+
{ title: 'Lorem ipsum dolor sit amet', metaStart: 'Yesterday', metaEnd: 'Berlin' },
|
|
91
|
+
{ title: 'Project proposal overview', metaStart: '2 days ago', metaEnd: 'Innsbruck' },
|
|
92
|
+
{ title: 'Lorem ipsum dolor sit amet', metaStart: '3 days ago', metaEnd: 'Berlin' },
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
function addAgentItem() {
|
|
96
|
+
const next = agentItems.value.length + 1;
|
|
97
|
+
agentItems.value.push({
|
|
98
|
+
title: 'Agent ' + next,
|
|
99
|
+
icon: Bot,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function addAppItem() {
|
|
104
|
+
const next = appItems.value.length + 1;
|
|
105
|
+
appItems.value.push({
|
|
106
|
+
title: 'App ' + next,
|
|
107
|
+
icon: Folder,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function addHistoryItem() {
|
|
112
|
+
const next = historyItems.value.length + 1;
|
|
113
|
+
historyItems.value.unshift({
|
|
114
|
+
title: 'New conversation ' + next,
|
|
115
|
+
metaStart: 'Just now',
|
|
116
|
+
metaEnd: 'Assistant',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
addAgentItem,
|
|
122
|
+
addAppItem,
|
|
123
|
+
addHistoryItem,
|
|
124
|
+
agentItems,
|
|
125
|
+
appItems,
|
|
126
|
+
args,
|
|
127
|
+
historyItems,
|
|
128
|
+
primaryItems,
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
template: `
|
|
132
|
+
<UiSidebarProvider :default-open="true">
|
|
133
|
+
<UiSidebar :side="args.side" :variant="args.variant" :collapsible="args.collapsible">
|
|
134
|
+
<UiSidebarHeader tooltip="Assistant" aria-label="Assistant sidebar trigger">
|
|
135
|
+
<template #logo>
|
|
136
|
+
<svg
|
|
137
|
+
class="w-6"
|
|
138
|
+
viewBox="0 0 20 20"
|
|
139
|
+
fill="none"
|
|
140
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
141
|
+
aria-hidden="true"
|
|
142
|
+
>
|
|
143
|
+
<path d="M5.51166 16.0373L7.01104 17.9999C7.76073 17.4953 8.41178 16.8598 9.00364 16.1869L7.01104 14.6915C6.55728 15.1962 6.06406 15.6448 5.51166 16.0373Z" fill="#1D1D1B"/>
|
|
144
|
+
<path d="M14.5278 3.96262L13.0284 2C12.2787 2.50467 11.6277 3.14019 11.0358 3.81308L13.0284 5.30841C13.4822 4.80374 13.9557 4.35514 14.5278 3.96262Z" fill="#1D1D1B"/>
|
|
145
|
+
<path d="M11.2725 9.98131C11.2725 6.84112 9.65475 3.86916 6.97164 2L5.4328 3.96262C7.50432 5.38318 8.7275 7.64486 8.7275 10.0187C8.7275 13.1589 10.3453 16.1308 13.0284 18L14.5672 16.0374C12.5154 14.5981 11.2725 12.3551 11.2725 9.98131Z" fill="#1D1D1B"/>
|
|
146
|
+
<path d="M3.04562 4.80371L2 7.00932C3.20345 7.53268 4.05179 8.67287 4.05179 9.99997C4.05179 11.3271 3.20345 12.486 2 12.9906L3.04562 15.1962C5.13687 14.299 6.59679 12.3177 6.59679 9.99997C6.59679 7.68222 5.13687 5.68222 3.04562 4.80371Z" fill="#1D1D1B"/>
|
|
147
|
+
<path d="M15.9482 9.99997C15.9482 8.65418 16.7965 7.51399 18 7.00932L16.9544 4.80371C14.8631 5.70091 13.4032 7.70091 13.4032 9.99997C13.4032 12.3177 14.8631 14.299 16.9544 15.1962L18 12.9906C16.7768 12.486 15.9482 11.3271 15.9482 9.99997Z" fill="#1D1D1B"/>
|
|
148
|
+
</svg>
|
|
149
|
+
</template>
|
|
150
|
+
Assistant
|
|
151
|
+
</UiSidebarHeader>
|
|
152
|
+
|
|
153
|
+
<UiSidebarContent>
|
|
154
|
+
<UiSidebarMenu class="px-2 pt-1">
|
|
155
|
+
<UiSidebarMenuItem v-for="item in primaryItems" :key="item.title">
|
|
156
|
+
<UiSidebarMenuButton :tooltip="item.title" :is-active="item.isActive">
|
|
157
|
+
<template #start-icon>
|
|
158
|
+
<component :is="item.icon" :size="16" />
|
|
159
|
+
</template>
|
|
160
|
+
{{ item.title }}
|
|
161
|
+
</UiSidebarMenuButton>
|
|
162
|
+
</UiSidebarMenuItem>
|
|
163
|
+
</UiSidebarMenu>
|
|
164
|
+
|
|
165
|
+
<UiSidebarGroup :default-open="true">
|
|
166
|
+
<UiSidebarGroupLabel
|
|
167
|
+
size="xs"
|
|
168
|
+
collapse-tooltip="Toggle agents"
|
|
169
|
+
action-tooltip="Add agent"
|
|
170
|
+
@action-click="addAgentItem"
|
|
171
|
+
>
|
|
172
|
+
Agents
|
|
173
|
+
</UiSidebarGroupLabel>
|
|
174
|
+
<UiSidebarGroupContent>
|
|
175
|
+
<UiSidebarMenu>
|
|
176
|
+
<UiSidebarMenuItem v-for="item in agentItems" :key="item.title">
|
|
177
|
+
<UiSidebarMenuButton :tooltip="item.title">
|
|
178
|
+
<template #start-icon>
|
|
179
|
+
<component :is="item.icon" :size="16" />
|
|
180
|
+
</template>
|
|
181
|
+
{{ item.title }}
|
|
182
|
+
</UiSidebarMenuButton>
|
|
183
|
+
</UiSidebarMenuItem>
|
|
184
|
+
</UiSidebarMenu>
|
|
185
|
+
</UiSidebarGroupContent>
|
|
186
|
+
</UiSidebarGroup>
|
|
187
|
+
|
|
188
|
+
<UiSidebarGroup :default-open="true">
|
|
189
|
+
<UiSidebarGroupLabel
|
|
190
|
+
size="xs"
|
|
191
|
+
collapse-tooltip="Toggle apps"
|
|
192
|
+
action-tooltip="Add app"
|
|
193
|
+
@action-click="addAppItem"
|
|
194
|
+
>
|
|
195
|
+
Apps
|
|
196
|
+
</UiSidebarGroupLabel>
|
|
197
|
+
<UiSidebarGroupContent>
|
|
198
|
+
<UiSidebarMenu>
|
|
199
|
+
<UiSidebarMenuItem v-for="item in appItems" :key="item.title">
|
|
200
|
+
<UiSidebarMenuButton :tooltip="item.title">
|
|
201
|
+
<template #start-icon>
|
|
202
|
+
<component :is="item.icon" :size="16" />
|
|
203
|
+
</template>
|
|
204
|
+
{{ item.title }}
|
|
205
|
+
</UiSidebarMenuButton>
|
|
206
|
+
</UiSidebarMenuItem>
|
|
207
|
+
</UiSidebarMenu>
|
|
208
|
+
</UiSidebarGroupContent>
|
|
209
|
+
</UiSidebarGroup>
|
|
210
|
+
|
|
211
|
+
<UiSidebarGroup :default-open="true">
|
|
212
|
+
<UiSidebarGroupLabel
|
|
213
|
+
size="xs"
|
|
214
|
+
collapse-tooltip="Toggle chat history"
|
|
215
|
+
action-tooltip="Add conversation"
|
|
216
|
+
@action-click="addHistoryItem"
|
|
217
|
+
>
|
|
218
|
+
Chat history
|
|
219
|
+
</UiSidebarGroupLabel>
|
|
220
|
+
<UiSidebarGroupContent>
|
|
221
|
+
<UiSidebarChatHistory class="px-0 py-0">
|
|
222
|
+
<UiSidebarChatHistoryItem
|
|
223
|
+
v-for="(item, index) in historyItems"
|
|
224
|
+
:key="item.title + '-' + index"
|
|
225
|
+
:title="item.title"
|
|
226
|
+
:meta-start="item.metaStart"
|
|
227
|
+
:meta-end="item.metaEnd"
|
|
228
|
+
:is-active="index === 0"
|
|
229
|
+
action-tooltip="More actions"
|
|
230
|
+
/>
|
|
231
|
+
</UiSidebarChatHistory>
|
|
232
|
+
</UiSidebarGroupContent>
|
|
233
|
+
</UiSidebarGroup>
|
|
234
|
+
</UiSidebarContent>
|
|
235
|
+
|
|
236
|
+
<UiSidebarFooter>
|
|
237
|
+
<Popover>
|
|
238
|
+
<PopoverTrigger as-child>
|
|
239
|
+
<UiSidebarMenuButton tooltip="Profile menu">
|
|
240
|
+
<template #start-icon>
|
|
241
|
+
<div
|
|
242
|
+
class="flex size-8 items-center justify-center overflow-hidden rounded-md bg-background-surface-muted body-14-normal font-normal text-content-on-surface-primary"
|
|
243
|
+
>
|
|
244
|
+
U
|
|
245
|
+
</div>
|
|
246
|
+
</template>
|
|
247
|
+
user
|
|
248
|
+
<template #subtitle>
|
|
249
|
+
descriptipn
|
|
250
|
+
</template>
|
|
251
|
+
</UiSidebarMenuButton>
|
|
252
|
+
</PopoverTrigger>
|
|
253
|
+
|
|
254
|
+
<PopoverContent side="top" align="start" :side-offset="8" class="w-[22rem] rounded-md p-0 shadow-md">
|
|
255
|
+
<UiSidebarPopoverMenu :show-footer-separator="false">
|
|
256
|
+
<div class="flex items-center gap-3 px-2 py-2">
|
|
257
|
+
<div
|
|
258
|
+
class="flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-md bg-background-surface-muted body-14-normal font-normal text-content-on-surface-primary"
|
|
259
|
+
>
|
|
260
|
+
U
|
|
261
|
+
</div>
|
|
262
|
+
<div class="min-w-0">
|
|
263
|
+
<div class="truncate body-14-normal font-medium text-content-on-surface-primary">
|
|
264
|
+
user
|
|
265
|
+
</div>
|
|
266
|
+
<div class="truncate body-14-normal font-normal text-content-on-surface-muted">
|
|
267
|
+
descriptipn
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
<div class="mx-2 border-t border-border-surface-default"></div>
|
|
273
|
+
|
|
274
|
+
<button
|
|
275
|
+
type="button"
|
|
276
|
+
class="flex h-10 w-full items-center rounded-md px-2 text-left body-14-normal font-normal text-content-on-surface-primary"
|
|
277
|
+
>
|
|
278
|
+
Upgrade to Pro
|
|
279
|
+
</button>
|
|
280
|
+
<button
|
|
281
|
+
type="button"
|
|
282
|
+
class="flex h-10 w-full items-center rounded-md px-2 text-left body-14-normal font-normal text-content-on-surface-primary"
|
|
283
|
+
>
|
|
284
|
+
Account
|
|
285
|
+
</button>
|
|
286
|
+
<button
|
|
287
|
+
type="button"
|
|
288
|
+
class="flex h-10 w-full items-center rounded-md px-2 text-left body-14-normal font-normal text-content-on-surface-primary"
|
|
289
|
+
>
|
|
290
|
+
Billing
|
|
291
|
+
</button>
|
|
292
|
+
<button
|
|
293
|
+
type="button"
|
|
294
|
+
class="flex h-10 w-full items-center rounded-md px-2 text-left body-14-normal font-normal text-content-on-surface-primary"
|
|
295
|
+
>
|
|
296
|
+
Notifications
|
|
297
|
+
</button>
|
|
298
|
+
|
|
299
|
+
<div class="mx-2 border-t border-border-surface-default"></div>
|
|
300
|
+
|
|
301
|
+
<button
|
|
302
|
+
type="button"
|
|
303
|
+
class="flex h-10 w-full items-center rounded-md px-2 text-left body-14-normal font-normal text-content-on-surface-primary"
|
|
304
|
+
>
|
|
305
|
+
Log out
|
|
306
|
+
</button>
|
|
307
|
+
</UiSidebarPopoverMenu>
|
|
308
|
+
</PopoverContent>
|
|
309
|
+
</Popover>
|
|
310
|
+
</UiSidebarFooter>
|
|
311
|
+
|
|
312
|
+
<UiSidebarRail />
|
|
313
|
+
</UiSidebar>
|
|
314
|
+
|
|
315
|
+
<UiSidebarInset>
|
|
316
|
+
<header class="flex h-14 items-center gap-2 border-b border-border-surface-default px-4">
|
|
317
|
+
<span class="body-14-normal font-normal text-content-on-surface-primary">Chat</span>
|
|
318
|
+
</header>
|
|
319
|
+
<div class="flex min-h-[320px] flex-1 p-4">
|
|
320
|
+
<div class="min-h-[540px] w-full rounded-md border border-border-surface-default bg-background-surface-primary" />
|
|
321
|
+
</div>
|
|
322
|
+
</UiSidebarInset>
|
|
323
|
+
</UiSidebarProvider>
|
|
324
|
+
`,
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
export const Default: Story = {
|
|
328
|
+
render: renderStory,
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export const Inset: Story = {
|
|
332
|
+
args: {
|
|
333
|
+
variant: 'inset',
|
|
334
|
+
collapsible: 'icon',
|
|
335
|
+
},
|
|
336
|
+
render: renderStory,
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export const RightSide: Story = {
|
|
340
|
+
args: {
|
|
341
|
+
side: 'right',
|
|
342
|
+
variant: 'sidebar',
|
|
343
|
+
collapsible: 'offcanvas',
|
|
344
|
+
},
|
|
345
|
+
render: renderStory,
|
|
346
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { Sidebar
|
|
2
|
+
import { Sidebar } from '@/components/core/sidebar';
|
|
3
3
|
import type { UiSidebarProps } from './types';
|
|
4
4
|
|
|
5
5
|
defineOptions({
|
|
6
6
|
name: 'UiSidebar',
|
|
7
|
+
inheritAttrs: false,
|
|
7
8
|
});
|
|
8
9
|
|
|
9
10
|
const props = withDefaults(defineProps<UiSidebarProps>(), {
|
|
@@ -14,7 +15,12 @@
|
|
|
14
15
|
</script>
|
|
15
16
|
|
|
16
17
|
<template>
|
|
17
|
-
<
|
|
18
|
+
<Sidebar
|
|
19
|
+
:side="props.side"
|
|
20
|
+
:variant="props.variant"
|
|
21
|
+
:collapsible="props.collapsible"
|
|
22
|
+
v-bind="$attrs"
|
|
23
|
+
>
|
|
18
24
|
<slot />
|
|
19
|
-
</
|
|
25
|
+
</Sidebar>
|
|
20
26
|
</template>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import UiSidebar from './UiSidebar.vue';
|
|
4
|
+
import UiSidebarChatHistory from './UiSidebarChatHistory.vue';
|
|
5
|
+
import UiSidebarChatHistoryItem from './UiSidebarChatHistoryItem.vue';
|
|
6
|
+
import UiSidebarContent from './UiSidebarContent.vue';
|
|
7
|
+
import UiSidebarHeader from './UiSidebarHeader.vue';
|
|
8
|
+
import UiSidebarProvider from './UiSidebarProvider.vue';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof UiSidebarChatHistory> = {
|
|
11
|
+
title: 'Patterns/UiSidebar/UiSidebarChatHistory',
|
|
12
|
+
component: UiSidebarChatHistory,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
type Story = StoryObj<typeof UiSidebarChatHistory>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => ({
|
|
22
|
+
components: {
|
|
23
|
+
UiSidebar,
|
|
24
|
+
UiSidebarChatHistory,
|
|
25
|
+
UiSidebarChatHistoryItem,
|
|
26
|
+
UiSidebarContent,
|
|
27
|
+
UiSidebarHeader,
|
|
28
|
+
UiSidebarProvider,
|
|
29
|
+
},
|
|
30
|
+
setup() {
|
|
31
|
+
const actionCount = ref(0);
|
|
32
|
+
const items = [
|
|
33
|
+
{ title: 'Project Proposal Overview', metaStart: 'Today', metaEnd: 'Innsbruck' },
|
|
34
|
+
{
|
|
35
|
+
title: 'Project Proposal Overview',
|
|
36
|
+
metaStart: 'Today',
|
|
37
|
+
metaEnd: 'Innsbruck',
|
|
38
|
+
isActive: true,
|
|
39
|
+
},
|
|
40
|
+
{ title: 'Project Proposal Overview', metaStart: 'Today', metaEnd: 'Innsbruck' },
|
|
41
|
+
{ title: 'Project Proposal Overview', metaStart: 'Today', metaEnd: 'Innsbruck' },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
function handleActionClick() {
|
|
45
|
+
actionCount.value += 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { actionCount, handleActionClick, items };
|
|
49
|
+
},
|
|
50
|
+
template: `
|
|
51
|
+
<UiSidebarProvider :default-open="true">
|
|
52
|
+
<div class="bg-background-surface-primary p-4">
|
|
53
|
+
<UiSidebar class="w-[22rem]" collapsible="icon">
|
|
54
|
+
<UiSidebarHeader tooltip="Toggle sidebar">Preview</UiSidebarHeader>
|
|
55
|
+
<UiSidebarContent class="p-0">
|
|
56
|
+
<UiSidebarChatHistory>
|
|
57
|
+
<UiSidebarChatHistoryItem
|
|
58
|
+
v-for="(item, index) in items"
|
|
59
|
+
:key="index"
|
|
60
|
+
:title="item.title"
|
|
61
|
+
:meta-start="item.metaStart"
|
|
62
|
+
:meta-end="item.metaEnd"
|
|
63
|
+
:is-active="item.isActive"
|
|
64
|
+
action-tooltip="More actions"
|
|
65
|
+
@action-click="handleActionClick"
|
|
66
|
+
/>
|
|
67
|
+
</UiSidebarChatHistory>
|
|
68
|
+
</UiSidebarContent>
|
|
69
|
+
</UiSidebar>
|
|
70
|
+
<p class="mt-3 text-xs text-content-on-surface-muted">
|
|
71
|
+
Action clicks: {{ actionCount }}
|
|
72
|
+
</p>
|
|
73
|
+
</div>
|
|
74
|
+
</UiSidebarProvider>
|
|
75
|
+
`,
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useAttrs } from 'vue';
|
|
3
|
+
import { cn } from '@/lib/utils';
|
|
4
|
+
import type { UiSidebarChatHistoryProps } from './types';
|
|
5
|
+
|
|
6
|
+
defineOptions({
|
|
7
|
+
name: 'UiSidebarChatHistory',
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<UiSidebarChatHistoryProps>(), {
|
|
12
|
+
withGap: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const attrs = useAttrs();
|
|
16
|
+
|
|
17
|
+
const historyClass = computed(() =>
|
|
18
|
+
cn(
|
|
19
|
+
'flex w-full min-w-0 flex-col p-2 group-data-[collapsible=icon]:hidden',
|
|
20
|
+
props.withGap && 'gap-1',
|
|
21
|
+
attrs.class as string | undefined,
|
|
22
|
+
),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const passthroughAttrs = computed(() => {
|
|
26
|
+
const { class: _class, ...rest } = attrs as Record<string, unknown>;
|
|
27
|
+
return rest;
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<div v-bind="passthroughAttrs" data-slot="sidebar-chat-history" :class="historyClass">
|
|
33
|
+
<slot />
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|