@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,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useAttrs } from 'vue';
|
|
3
|
+
import { PanelLeft } from 'lucide-vue-next';
|
|
4
|
+
import { SidebarHeader } from '@/components/core/sidebar';
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
import UiSidebarTrigger from './UiSidebarTrigger.vue';
|
|
7
|
+
import type { UiSidebarHeaderProps } from './types';
|
|
8
|
+
|
|
9
|
+
defineOptions({
|
|
10
|
+
name: 'UiSidebarHeader',
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<UiSidebarHeaderProps>(), {
|
|
15
|
+
tooltip: '',
|
|
16
|
+
ariaLabel: 'Toggle sidebar',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const attrs = useAttrs();
|
|
20
|
+
|
|
21
|
+
const headerClass = computed(() => cn(attrs.class as string | undefined));
|
|
22
|
+
|
|
23
|
+
const passthroughAttrs = computed(() => {
|
|
24
|
+
const { class: _class, ...rest } = attrs as Record<string, unknown>;
|
|
25
|
+
return rest;
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<SidebarHeader v-bind="passthroughAttrs" :class="headerClass">
|
|
31
|
+
<div
|
|
32
|
+
class="flex w-full items-center rounded-sm p-2 text-content-on-surface-primary group-data-[collapsible=icon]:justify-center"
|
|
33
|
+
>
|
|
34
|
+
<div class="flex shrink-0 grow items-center gap-2 group-data-[collapsible=icon]:hidden">
|
|
35
|
+
<slot name="logo"> </slot>
|
|
36
|
+
<span v-if="$slots.default" class="min-w-0 truncate text-base leading-normal font-semibold">
|
|
37
|
+
<slot />
|
|
38
|
+
</span>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<UiSidebarTrigger
|
|
42
|
+
class="ml-auto group-data-[collapsible=icon]:ml-0"
|
|
43
|
+
:tooltip="props.tooltip"
|
|
44
|
+
:aria-label="props.ariaLabel"
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
</SidebarHeader>
|
|
48
|
+
</template>
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
3
|
+
import { ref } from 'vue';
|
|
4
|
+
import { Bot, Check, ChevronDown, ChevronRight, Folder } from 'lucide-vue-next';
|
|
5
|
+
import UiSidebar from './UiSidebar.vue';
|
|
6
|
+
import UiSidebarContent from './UiSidebarContent.vue';
|
|
7
|
+
import UiSidebarHeader from './UiSidebarHeader.vue';
|
|
8
|
+
import UiSidebarMenu from './UiSidebarMenu.vue';
|
|
9
|
+
import UiSidebarMenuButton from './UiSidebarMenuButton.vue';
|
|
10
|
+
import UiSidebarMenuItem from './UiSidebarMenuItem.vue';
|
|
11
|
+
import UiSidebarProvider from './UiSidebarProvider.vue';
|
|
12
|
+
|
|
13
|
+
type MenuButtonStoryConfig = {
|
|
14
|
+
label: string;
|
|
15
|
+
subtitle?: string;
|
|
16
|
+
startIcon?: Component;
|
|
17
|
+
endIcon?: Component;
|
|
18
|
+
badge?: string;
|
|
19
|
+
bigIcon?: boolean;
|
|
20
|
+
checkbox?: boolean;
|
|
21
|
+
endIconClickable?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const meta: Meta<typeof UiSidebarMenuButton> = {
|
|
25
|
+
title: 'Patterns/UiSidebar/UiSidebarMenuButton',
|
|
26
|
+
component: UiSidebarMenuButton,
|
|
27
|
+
tags: ['autodocs'],
|
|
28
|
+
parameters: {
|
|
29
|
+
layout: 'padded',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default meta;
|
|
34
|
+
|
|
35
|
+
type Story = StoryObj<typeof UiSidebarMenuButton>;
|
|
36
|
+
|
|
37
|
+
const renderMode = (mode: MenuButtonStoryConfig) => ({
|
|
38
|
+
components: {
|
|
39
|
+
Bot,
|
|
40
|
+
Check,
|
|
41
|
+
ChevronDown,
|
|
42
|
+
ChevronRight,
|
|
43
|
+
Folder,
|
|
44
|
+
UiSidebar,
|
|
45
|
+
UiSidebarContent,
|
|
46
|
+
UiSidebarHeader,
|
|
47
|
+
UiSidebarMenu,
|
|
48
|
+
UiSidebarMenuButton,
|
|
49
|
+
UiSidebarMenuItem,
|
|
50
|
+
UiSidebarProvider,
|
|
51
|
+
},
|
|
52
|
+
setup() {
|
|
53
|
+
const actionCount = ref(0);
|
|
54
|
+
|
|
55
|
+
function handleEndIconClick() {
|
|
56
|
+
actionCount.value += 1;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return { actionCount, handleEndIconClick, mode };
|
|
60
|
+
},
|
|
61
|
+
template: `
|
|
62
|
+
<div class="bg-background-surface-primary p-4">
|
|
63
|
+
<UiSidebarProvider :default-open="true">
|
|
64
|
+
<UiSidebar collapsible="icon" class="w-72">
|
|
65
|
+
<UiSidebarHeader tooltip="Toggle sidebar">Preview</UiSidebarHeader>
|
|
66
|
+
<UiSidebarContent class="p-0">
|
|
67
|
+
<UiSidebarMenu class="space-y-1 p-2">
|
|
68
|
+
<UiSidebarMenuItem>
|
|
69
|
+
<UiSidebarMenuButton
|
|
70
|
+
:tooltip="mode.label"
|
|
71
|
+
:end-icon-clickable="mode.endIconClickable"
|
|
72
|
+
@end-icon-click="handleEndIconClick"
|
|
73
|
+
>
|
|
74
|
+
<template #start-icon>
|
|
75
|
+
<span
|
|
76
|
+
v-if="mode.checkbox"
|
|
77
|
+
class="flex size-4 items-center justify-center rounded-[4px] bg-background-accent-default text-content-on-accent-default"
|
|
78
|
+
>
|
|
79
|
+
<Check :size="16" class="size-4" />
|
|
80
|
+
</span>
|
|
81
|
+
<span
|
|
82
|
+
v-else-if="mode.bigIcon"
|
|
83
|
+
class="flex size-8 items-center justify-center rounded-full bg-background-surface-muted text-content-on-surface-primary"
|
|
84
|
+
>
|
|
85
|
+
<Bot :size="16" class="size-4" />
|
|
86
|
+
</span>
|
|
87
|
+
<component :is="mode.startIcon ?? Folder" :size="16" v-else />
|
|
88
|
+
</template>
|
|
89
|
+
{{ mode.label }}
|
|
90
|
+
<template v-if="mode.subtitle" #subtitle>
|
|
91
|
+
{{ mode.subtitle }}
|
|
92
|
+
</template>
|
|
93
|
+
<template v-if="mode.endIcon || mode.badge" #end-icon>
|
|
94
|
+
<span
|
|
95
|
+
v-if="mode.badge"
|
|
96
|
+
class="min-w-6 rounded-sm bg-background-surface-muted px-1.5 py-0.5 text-center text-xs text-content-on-surface-primary"
|
|
97
|
+
>
|
|
98
|
+
{{ mode.badge }}
|
|
99
|
+
</span>
|
|
100
|
+
<component :is="mode.endIcon" :size="16" v-else />
|
|
101
|
+
</template>
|
|
102
|
+
</UiSidebarMenuButton>
|
|
103
|
+
</UiSidebarMenuItem>
|
|
104
|
+
|
|
105
|
+
<UiSidebarMenuItem>
|
|
106
|
+
<UiSidebarMenuButton
|
|
107
|
+
:tooltip="mode.label"
|
|
108
|
+
:end-icon-clickable="mode.endIconClickable"
|
|
109
|
+
is-active
|
|
110
|
+
@end-icon-click="handleEndIconClick"
|
|
111
|
+
>
|
|
112
|
+
<template #start-icon>
|
|
113
|
+
<span
|
|
114
|
+
v-if="mode.checkbox"
|
|
115
|
+
class="flex size-4 items-center justify-center rounded-[4px] bg-background-accent-default text-content-on-accent-default"
|
|
116
|
+
>
|
|
117
|
+
<Check :size="16" class="size-4" />
|
|
118
|
+
</span>
|
|
119
|
+
<span
|
|
120
|
+
v-else-if="mode.bigIcon"
|
|
121
|
+
class="flex size-8 items-center justify-center rounded-full bg-background-surface-muted text-content-on-surface-primary"
|
|
122
|
+
>
|
|
123
|
+
<Bot :size="16" class="size-4" />
|
|
124
|
+
</span>
|
|
125
|
+
<component :is="mode.startIcon ?? Folder" :size="16" v-else />
|
|
126
|
+
</template>
|
|
127
|
+
{{ mode.label }}
|
|
128
|
+
<template v-if="mode.subtitle" #subtitle>
|
|
129
|
+
{{ mode.subtitle }}
|
|
130
|
+
</template>
|
|
131
|
+
<template v-if="mode.endIcon || mode.badge" #end-icon>
|
|
132
|
+
<span
|
|
133
|
+
v-if="mode.badge"
|
|
134
|
+
class="min-w-6 rounded-sm bg-background-surface-muted px-1.5 py-0.5 text-center text-xs text-content-on-surface-primary"
|
|
135
|
+
>
|
|
136
|
+
{{ mode.badge }}
|
|
137
|
+
</span>
|
|
138
|
+
<component :is="mode.endIcon" :size="16" v-else />
|
|
139
|
+
</template>
|
|
140
|
+
</UiSidebarMenuButton>
|
|
141
|
+
</UiSidebarMenuItem>
|
|
142
|
+
</UiSidebarMenu>
|
|
143
|
+
</UiSidebarContent>
|
|
144
|
+
</UiSidebar>
|
|
145
|
+
</UiSidebarProvider>
|
|
146
|
+
<p v-if="mode.endIconClickable" class="mt-3 text-xs text-content-on-surface-muted">
|
|
147
|
+
End icon clicks: {{ actionCount }}
|
|
148
|
+
</p>
|
|
149
|
+
</div>
|
|
150
|
+
`,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
export const Simple: Story = {
|
|
154
|
+
render: () =>
|
|
155
|
+
renderMode({
|
|
156
|
+
label: 'Menu Item',
|
|
157
|
+
startIcon: Folder,
|
|
158
|
+
}),
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const Dropdown: Story = {
|
|
162
|
+
render: () =>
|
|
163
|
+
renderMode({
|
|
164
|
+
label: 'Menu Item',
|
|
165
|
+
startIcon: Folder,
|
|
166
|
+
endIcon: ChevronDown,
|
|
167
|
+
endIconClickable: true,
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const Tree: Story = {
|
|
172
|
+
render: () =>
|
|
173
|
+
renderMode({
|
|
174
|
+
label: 'Menu Item',
|
|
175
|
+
startIcon: Folder,
|
|
176
|
+
endIcon: ChevronRight,
|
|
177
|
+
endIconClickable: true,
|
|
178
|
+
}),
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export const Badge: Story = {
|
|
182
|
+
render: () =>
|
|
183
|
+
renderMode({
|
|
184
|
+
label: 'Menu Item',
|
|
185
|
+
startIcon: Folder,
|
|
186
|
+
badge: '23',
|
|
187
|
+
}),
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export const BigIcon: Story = {
|
|
191
|
+
render: () =>
|
|
192
|
+
renderMode({
|
|
193
|
+
label: 'Menu Item',
|
|
194
|
+
subtitle: 'Enterprise',
|
|
195
|
+
bigIcon: true,
|
|
196
|
+
}),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const Checkbox: Story = {
|
|
200
|
+
render: () =>
|
|
201
|
+
renderMode({
|
|
202
|
+
label: 'Menu Item',
|
|
203
|
+
checkbox: true,
|
|
204
|
+
}),
|
|
205
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useAttrs, useSlots } from 'vue';
|
|
3
|
+
import { SidebarMenuButton } from '@/components/core/sidebar';
|
|
4
|
+
import { vOverlay } from '@/directives';
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
import type { UiSidebarMenuButtonEmits, UiSidebarMenuButtonProps } from './types';
|
|
7
|
+
|
|
8
|
+
defineOptions({
|
|
9
|
+
name: 'UiSidebarMenuButton',
|
|
10
|
+
inheritAttrs: false,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const emit = defineEmits<UiSidebarMenuButtonEmits>();
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<UiSidebarMenuButtonProps>(), {
|
|
16
|
+
tooltip: undefined,
|
|
17
|
+
variant: 'default',
|
|
18
|
+
size: 'default',
|
|
19
|
+
isActive: false,
|
|
20
|
+
endIconClickable: false,
|
|
21
|
+
endIconAriaLabel: 'Menu action',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const attrs = useAttrs();
|
|
25
|
+
const slots = useSlots();
|
|
26
|
+
const hasSubtitle = computed(() => Boolean(slots.subtitle));
|
|
27
|
+
|
|
28
|
+
const containerClass = computed(() =>
|
|
29
|
+
cn(
|
|
30
|
+
'relative flex w-full min-w-0 items-center gap-2 rounded-md border border-transparent px-2 py-1.5',
|
|
31
|
+
hasSubtitle.value ? 'h-[54px]' : 'h-8',
|
|
32
|
+
'group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 group-data-[collapsible=icon]:p-0',
|
|
33
|
+
'focus-within:border-border-surface-focus-ring focus-within:ring-[3px] focus-within:ring-ring/50',
|
|
34
|
+
'data-[active=true]:before:absolute data-[active=true]:before:z-10 data-[active=true]:before:top-1/2 data-[active=true]:before:left-0 data-[active=true]:before:h-4 data-[active=true]:before:w-0.5 data-[active=true]:before:-translate-y-1/2 data-[active=true]:before:rounded-full data-[active=true]:before:bg-background-accent-default data-[active=true]:before:content-[""]',
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const rootClass = computed(() =>
|
|
39
|
+
cn(
|
|
40
|
+
'!h-full !rounded-none !p-0 body-14-normal font-normal text-content-on-surface-primary',
|
|
41
|
+
'!hover:bg-transparent !active:bg-transparent',
|
|
42
|
+
'data-[active=true]:!bg-transparent data-[active=true]:!text-content-on-surface-primary data-[active=true]:font-normal',
|
|
43
|
+
'[&>[data-slot=start-icon]]:shrink-0 [&>[data-slot=start-icon]>svg]:size-4',
|
|
44
|
+
'[&>[data-slot=label]]:min-w-0 [&>[data-slot=label]]:truncate',
|
|
45
|
+
'focus-visible:ring-0',
|
|
46
|
+
attrs.class as string | undefined,
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const endIconClass = computed(() =>
|
|
51
|
+
cn(
|
|
52
|
+
'ml-auto shrink-0 group-data-[collapsible=icon]:hidden',
|
|
53
|
+
'relative z-10 flex size-4 items-center justify-center rounded-sm text-content-on-surface-primary outline-hidden',
|
|
54
|
+
'focus-visible:ring-0',
|
|
55
|
+
'[&>svg]:size-4',
|
|
56
|
+
),
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const passthroughAttrs = computed(() => {
|
|
60
|
+
const { class: _class, ...rest } = attrs as Record<string, unknown>;
|
|
61
|
+
return rest;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
function onEndIconClick(event: MouseEvent) {
|
|
65
|
+
event.stopPropagation();
|
|
66
|
+
emit('end-icon-click', event);
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<div
|
|
72
|
+
v-overlay="{ variant: 'default', active: props.isActive, hover: true }"
|
|
73
|
+
:data-active="props.isActive"
|
|
74
|
+
:class="containerClass"
|
|
75
|
+
>
|
|
76
|
+
<SidebarMenuButton
|
|
77
|
+
v-bind="passthroughAttrs"
|
|
78
|
+
:tooltip="props.tooltip"
|
|
79
|
+
:variant="props.variant"
|
|
80
|
+
:size="props.size"
|
|
81
|
+
:is-active="props.isActive"
|
|
82
|
+
:class="cn(rootClass, 'min-w-0 flex-1 group-data-[collapsible=icon]:flex-none')"
|
|
83
|
+
>
|
|
84
|
+
<div v-if="$slots['start-icon']" data-slot="start-icon">
|
|
85
|
+
<slot name="start-icon" />
|
|
86
|
+
</div>
|
|
87
|
+
<div v-if="$slots.default" data-slot="label" class="min-w-0">
|
|
88
|
+
<div
|
|
89
|
+
:class="
|
|
90
|
+
cn(
|
|
91
|
+
'truncate body-14-normal text-content-on-surface-primary',
|
|
92
|
+
hasSubtitle ? 'font-bold' : 'font-normal',
|
|
93
|
+
)
|
|
94
|
+
"
|
|
95
|
+
>
|
|
96
|
+
<slot />
|
|
97
|
+
</div>
|
|
98
|
+
<div
|
|
99
|
+
v-if="$slots.subtitle"
|
|
100
|
+
class="truncate text-sm font-normal text-content-on-surface-muted"
|
|
101
|
+
>
|
|
102
|
+
<slot name="subtitle" />
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</SidebarMenuButton>
|
|
106
|
+
|
|
107
|
+
<button
|
|
108
|
+
v-if="$slots['end-icon'] && props.endIconClickable"
|
|
109
|
+
type="button"
|
|
110
|
+
:ariaLabel="props.endIconAriaLabel"
|
|
111
|
+
:class="endIconClass"
|
|
112
|
+
@click="onEndIconClick"
|
|
113
|
+
>
|
|
114
|
+
<slot name="end-icon" />
|
|
115
|
+
</button>
|
|
116
|
+
|
|
117
|
+
<div v-else-if="$slots['end-icon']" :class="endIconClass">
|
|
118
|
+
<slot name="end-icon" />
|
|
119
|
+
</div>
|
|
120
|
+
</div>
|
|
121
|
+
</template>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { Folder } from 'lucide-vue-next';
|
|
3
|
+
import UiSidebar from './UiSidebar.vue';
|
|
4
|
+
import UiSidebarContent from './UiSidebarContent.vue';
|
|
5
|
+
import UiSidebarHeader from './UiSidebarHeader.vue';
|
|
6
|
+
import UiSidebarMenu from './UiSidebarMenu.vue';
|
|
7
|
+
import UiSidebarMenuButton from './UiSidebarMenuButton.vue';
|
|
8
|
+
import UiSidebarMenuItem from './UiSidebarMenuItem.vue';
|
|
9
|
+
import UiSidebarProvider from './UiSidebarProvider.vue';
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof UiSidebarMenuItem> = {
|
|
12
|
+
title: 'Patterns/UiSidebar/UiSidebarMenuItem',
|
|
13
|
+
component: UiSidebarMenuItem,
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
parameters: {
|
|
16
|
+
layout: 'padded',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default meta;
|
|
21
|
+
|
|
22
|
+
type Story = StoryObj<typeof UiSidebarMenuItem>;
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {
|
|
25
|
+
render: () => ({
|
|
26
|
+
components: {
|
|
27
|
+
Folder,
|
|
28
|
+
UiSidebar,
|
|
29
|
+
UiSidebarContent,
|
|
30
|
+
UiSidebarHeader,
|
|
31
|
+
UiSidebarMenu,
|
|
32
|
+
UiSidebarMenuButton,
|
|
33
|
+
UiSidebarMenuItem,
|
|
34
|
+
UiSidebarProvider,
|
|
35
|
+
},
|
|
36
|
+
template: `
|
|
37
|
+
<div class="bg-background-surface-primary p-4">
|
|
38
|
+
<UiSidebarProvider :default-open="true">
|
|
39
|
+
<UiSidebar collapsible="icon" class="w-72">
|
|
40
|
+
<UiSidebarHeader tooltip="Toggle sidebar">Preview</UiSidebarHeader>
|
|
41
|
+
<UiSidebarContent class="p-2">
|
|
42
|
+
<UiSidebarMenu class="space-y-1">
|
|
43
|
+
<UiSidebarMenuItem>
|
|
44
|
+
<UiSidebarMenuButton tooltip="Overview">
|
|
45
|
+
<template #start-icon>
|
|
46
|
+
<Folder :size="16" />
|
|
47
|
+
</template>
|
|
48
|
+
Overview
|
|
49
|
+
</UiSidebarMenuButton>
|
|
50
|
+
</UiSidebarMenuItem>
|
|
51
|
+
|
|
52
|
+
<UiSidebarMenuItem>
|
|
53
|
+
<UiSidebarMenuButton tooltip="Settings" is-active>
|
|
54
|
+
<template #start-icon>
|
|
55
|
+
<Folder :size="16" />
|
|
56
|
+
</template>
|
|
57
|
+
Settings
|
|
58
|
+
</UiSidebarMenuButton>
|
|
59
|
+
</UiSidebarMenuItem>
|
|
60
|
+
</UiSidebarMenu>
|
|
61
|
+
</UiSidebarContent>
|
|
62
|
+
</UiSidebar>
|
|
63
|
+
</UiSidebarProvider>
|
|
64
|
+
</div>
|
|
65
|
+
`,
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useAttrs } from 'vue';
|
|
3
|
+
import { SidebarMenuSub } from '@/components/core/sidebar';
|
|
4
|
+
import { cn } from '@/lib/utils';
|
|
5
|
+
import type { UiSidebarMenuSubProps } from './types';
|
|
6
|
+
|
|
7
|
+
defineOptions({
|
|
8
|
+
name: 'UiSidebarMenuSub',
|
|
9
|
+
inheritAttrs: false,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<UiSidebarMenuSubProps>(), {
|
|
13
|
+
mode: 'default',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const attrs = useAttrs();
|
|
17
|
+
|
|
18
|
+
const subClass = computed(() =>
|
|
19
|
+
cn(
|
|
20
|
+
props.mode === 'border' &&
|
|
21
|
+
'!mx-3.5 !translate-x-px !gap-1 !border-l !border-border-surface-default !px-2.5 !py-0.5',
|
|
22
|
+
props.mode === 'default' && '!mx-3.5 !translate-x-px !gap-1 !border-l-0 !px-2.5 !py-0.5',
|
|
23
|
+
props.mode === 'indent' && '!mx-0 !translate-x-0 !gap-1 !border-l-0 !pl-4 !pr-0 !py-0',
|
|
24
|
+
attrs.class as string | undefined,
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const passthroughAttrs = computed(() => {
|
|
29
|
+
const { class: _class, ...rest } = attrs as Record<string, unknown>;
|
|
30
|
+
return rest;
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<SidebarMenuSub v-bind="passthroughAttrs" :class="subClass">
|
|
36
|
+
<slot />
|
|
37
|
+
</SidebarMenuSub>
|
|
38
|
+
</template>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import UiSidebar from './UiSidebar.vue';
|
|
3
|
+
import UiSidebarContent from './UiSidebarContent.vue';
|
|
4
|
+
import UiSidebarGroup from './UiSidebarGroup.vue';
|
|
5
|
+
import UiSidebarGroupContent from './UiSidebarGroupContent.vue';
|
|
6
|
+
import UiSidebarGroupLabel from './UiSidebarGroupLabel.vue';
|
|
7
|
+
import UiSidebarHeader from './UiSidebarHeader.vue';
|
|
8
|
+
import UiSidebarMenuSub from './UiSidebarMenuSub.vue';
|
|
9
|
+
import UiSidebarMenuSubItem from './UiSidebarMenuSubItem.vue';
|
|
10
|
+
import UiSidebarProvider from './UiSidebarProvider.vue';
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof UiSidebarMenuSubItem> = {
|
|
13
|
+
title: 'Patterns/UiSidebar/UiSidebarMenuSubItem',
|
|
14
|
+
component: UiSidebarMenuSubItem,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: 'padded',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default meta;
|
|
22
|
+
|
|
23
|
+
type Story = StoryObj<typeof UiSidebarMenuSubItem>;
|
|
24
|
+
|
|
25
|
+
export const Default: Story = {
|
|
26
|
+
render: () => ({
|
|
27
|
+
components: {
|
|
28
|
+
UiSidebar,
|
|
29
|
+
UiSidebarContent,
|
|
30
|
+
UiSidebarGroup,
|
|
31
|
+
UiSidebarGroupContent,
|
|
32
|
+
UiSidebarGroupLabel,
|
|
33
|
+
UiSidebarHeader,
|
|
34
|
+
UiSidebarMenuSub,
|
|
35
|
+
UiSidebarMenuSubItem,
|
|
36
|
+
UiSidebarProvider,
|
|
37
|
+
},
|
|
38
|
+
template: `
|
|
39
|
+
<div class="bg-background-surface-primary p-4">
|
|
40
|
+
<UiSidebarProvider :default-open="true">
|
|
41
|
+
<UiSidebar collapsible="icon" class="w-72">
|
|
42
|
+
<UiSidebarHeader tooltip="Toggle sidebar">Preview</UiSidebarHeader>
|
|
43
|
+
<UiSidebarContent class="p-2">
|
|
44
|
+
<UiSidebarGroup :default-open="true">
|
|
45
|
+
<UiSidebarGroupLabel
|
|
46
|
+
size="xs"
|
|
47
|
+
collapse-tooltip="Toggle section"
|
|
48
|
+
:show-action="false"
|
|
49
|
+
>
|
|
50
|
+
Section
|
|
51
|
+
</UiSidebarGroupLabel>
|
|
52
|
+
<UiSidebarGroupContent>
|
|
53
|
+
<UiSidebarMenuSub mode="default">
|
|
54
|
+
<UiSidebarMenuSubItem>Overview</UiSidebarMenuSubItem>
|
|
55
|
+
<UiSidebarMenuSubItem>Usage</UiSidebarMenuSubItem>
|
|
56
|
+
<UiSidebarMenuSubItem is-active>Settings</UiSidebarMenuSubItem>
|
|
57
|
+
</UiSidebarMenuSub>
|
|
58
|
+
</UiSidebarGroupContent>
|
|
59
|
+
</UiSidebarGroup>
|
|
60
|
+
</UiSidebarContent>
|
|
61
|
+
</UiSidebar>
|
|
62
|
+
</UiSidebarProvider>
|
|
63
|
+
</div>
|
|
64
|
+
`,
|
|
65
|
+
}),
|
|
66
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, useAttrs } from 'vue';
|
|
3
|
+
import { Primitive } from 'reka-ui';
|
|
4
|
+
import { SidebarMenuSubItem as UiSidebarMenuItem } from '@/components/core/sidebar';
|
|
5
|
+
import { vOverlay } from '@/directives';
|
|
6
|
+
import { cn } from '@/lib/utils';
|
|
7
|
+
import type { UiSidebarMenuSubItemProps } from './types';
|
|
8
|
+
|
|
9
|
+
defineOptions({
|
|
10
|
+
name: 'UiSidebarMenuSubItem',
|
|
11
|
+
inheritAttrs: false,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const props = withDefaults(defineProps<UiSidebarMenuSubItemProps>(), {
|
|
15
|
+
as: 'button',
|
|
16
|
+
isActive: false,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const attrs = useAttrs();
|
|
20
|
+
|
|
21
|
+
const containerClass = computed(() =>
|
|
22
|
+
cn(
|
|
23
|
+
'relative flex h-8 w-full min-w-0 items-center gap-2 rounded-md border border-transparent bg-transparent px-2 py-1.5',
|
|
24
|
+
'focus-within:border-border-surface-focus-ring focus-within:ring-[3px] focus-within:ring-ring/50',
|
|
25
|
+
'data-[active=true]:before:absolute data-[active=true]:before:z-10 data-[active=true]:before:top-1/2 data-[active=true]:before:left-0 data-[active=true]:before:h-4 data-[active=true]:before:w-0.5 data-[active=true]:before:-translate-y-1/2 data-[active=true]:before:rounded-full data-[active=true]:before:bg-background-accent-default data-[active=true]:before:content-[""]',
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const itemClass = computed(() =>
|
|
30
|
+
cn(
|
|
31
|
+
'!h-full min-w-0 flex-1 rounded-none bg-transparent px-0 py-0 text-left outline-hidden transition-colors',
|
|
32
|
+
'body-14-normal font-normal text-content-on-surface-primary',
|
|
33
|
+
'!hover:bg-transparent !active:bg-transparent',
|
|
34
|
+
'focus-visible:ring-0',
|
|
35
|
+
'data-[active=true]:!bg-transparent data-[active=true]:!text-content-on-surface-primary data-[active=true]:font-normal',
|
|
36
|
+
'[&>[data-slot=label]]:min-w-0 [&>[data-slot=label]]:truncate',
|
|
37
|
+
attrs.class as string | undefined,
|
|
38
|
+
),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const passthroughAttrs = computed(() => {
|
|
42
|
+
const { class: _class, ...rest } = attrs as Record<string, unknown>;
|
|
43
|
+
return rest;
|
|
44
|
+
});
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<template>
|
|
48
|
+
<UiSidebarMenuItem>
|
|
49
|
+
<div
|
|
50
|
+
v-overlay="{ variant: 'subtle', active: props.isActive, hover: true }"
|
|
51
|
+
:data-active="props.isActive"
|
|
52
|
+
:class="containerClass"
|
|
53
|
+
>
|
|
54
|
+
<Primitive
|
|
55
|
+
v-bind="passthroughAttrs"
|
|
56
|
+
:as="props.as"
|
|
57
|
+
:as-child="props.asChild"
|
|
58
|
+
:data-active="props.isActive"
|
|
59
|
+
:class="itemClass"
|
|
60
|
+
>
|
|
61
|
+
<span v-if="$slots.default" data-slot="label">
|
|
62
|
+
<slot />
|
|
63
|
+
</span>
|
|
64
|
+
</Primitive>
|
|
65
|
+
</div>
|
|
66
|
+
</UiSidebarMenuItem>
|
|
67
|
+
</template>
|