@aleph-alpha/ui-library 1.25.0 → 1.25.2

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 (32) hide show
  1. package/dist/system/components/UiBadge/index.d.ts +1 -1
  2. package/dist/system/components/UiProgress/index.d.ts +1 -1
  3. package/dist/system/components/UiSelect/UiSelect.vue.d.ts +6 -4
  4. package/dist/system/components/UiSelect/UiSelectContent.vue.d.ts +1 -0
  5. package/dist/system/components/UiSelect/UiSelectItem.vue.d.ts +8 -2
  6. package/dist/system/components/UiSelect/UiSelectTrigger.vue.d.ts +1 -0
  7. package/dist/system/components/UiSelect/UiSelectValue.vue.d.ts +3 -0
  8. package/dist/system/components/UiSelect/context.d.ts +28 -0
  9. package/dist/system/components/UiSelect/types.d.ts +32 -8
  10. package/dist/system/lib.js +16142 -15927
  11. package/package.json +4 -3
  12. package/src/components/UiBadge/index.ts +1 -1
  13. package/src/components/UiProgress/index.ts +1 -1
  14. package/src/components/UiSelect/UiSelect.stories.ts +137 -0
  15. package/src/components/UiSelect/UiSelect.vue +161 -6
  16. package/src/components/UiSelect/UiSelectContent.vue +22 -0
  17. package/src/components/UiSelect/UiSelectItem.vue +83 -1
  18. package/src/components/UiSelect/UiSelectTrigger.vue +51 -0
  19. package/src/components/UiSelect/UiSelectValue.vue +37 -1
  20. package/src/components/UiSelect/__tests__/UiSelect.test.ts +564 -0
  21. package/src/components/UiSelect/context.ts +41 -0
  22. package/src/components/UiSelect/types.ts +32 -8
  23. package/src/components/core/navigation-menu/NavigationMenuContent.vue +1 -1
  24. package/src/components/core/navigation-menu/NavigationMenuLink.vue +7 -1
  25. package/src/components/core/navigation-menu/NavigationMenuViewport.vue +1 -1
  26. package/src/components/core/navigation-menu/index.ts +10 -1
  27. package/src/patterns/UiSidebar/UiSidebarChatHistoryItem.vue +6 -1
  28. package/src/patterns/UiSidebar/UiSidebarMenuButton.stories.ts +117 -2
  29. package/src/patterns/UiSidebar/UiSidebarMenuButton.vue +4 -0
  30. package/src/patterns/UiSidebar/UiSidebarMenuItem.stories.ts +119 -1
  31. package/src/patterns/UiSidebar/UiSidebarMenuSubItem.vue +3 -0
  32. package/src/patterns/UiSidebar/UiSidebarPopoverTrigger.vue +2 -2
@@ -17,7 +17,13 @@
17
17
  v-bind="{ ...forwarded, ...$attrs }"
18
18
  :class="
19
19
  cn(
20
- 'data-[active]:focus:bg-accent data-[active]:hover:bg-accent data-[active]:bg-accent/50 data-[active]:text-accent-foreground hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground ring-ring/10 dark:ring-ring/20 dark:outline-ring/40 outline-ring/50 [&_svg:not([class*=\'text-\'])]:text-muted-foreground flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow] focus-visible:ring-4 focus-visible:outline-1 [&_svg:not([class*=\'size-\'])]:size-4',
20
+ // Default: transparent bg + `content-on-surface-primary` text.
21
+ // Hover / data-[active]: use the muted surface bg so open/current
22
+ // links read as pressed without switching to the `accent` palette.
23
+ // Focus-visible: mirrors UiButton's focus recipe (focus-ring border
24
+ // + tinted ring shadow at 3px) so keyboard focus reads consistently
25
+ // across buttons and nav links.
26
+ 'bg-transparent text-content-on-surface-primary border border-transparent flex flex-col gap-1 rounded-sm p-2 text-sm transition-[color,box-shadow,border-color] outline-none hover:bg-background-surface-muted data-[active]:bg-background-surface-muted [&_svg:not([class*=\'text-\'])]:text-muted-foreground focus-visible:border-border-surface-focus-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] [&_svg:not([class*=\'size-\'])]:size-4',
21
27
  $attrs.class ?? '',
22
28
  )
23
29
  "
@@ -17,7 +17,7 @@
17
17
  v-bind="{ ...forwardedProps, ...$attrs }"
18
18
  :class="
19
19
  cn(
20
- 'origin-top-center bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--reka-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border shadow md:w-[var(--reka-navigation-menu-viewport-width)] left-[var(--reka-navigation-menu-viewport-left)]',
20
+ 'origin-top-center bg-background-surface-floating text-content-on-surface-primary data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 relative mt-1.5 h-[var(--reka-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border border-border-surface-default shadow-xs md:w-[var(--reka-navigation-menu-viewport-width)] left-[var(--reka-navigation-menu-viewport-left)]',
21
21
  $attrs.class ?? '',
22
22
  )
23
23
  "
@@ -9,6 +9,15 @@ export { default as NavigationMenuList } from './NavigationMenuList.vue';
9
9
  export { default as NavigationMenuTrigger } from './NavigationMenuTrigger.vue';
10
10
  export { default as NavigationMenuViewport } from './NavigationMenuViewport.vue';
11
11
 
12
+ // Surface-hierarchy-aligned navigation trigger styling:
13
+ // - default: transparent bg, `text-content-on-surface-primary`
14
+ // - hover: bg switches to `background-surface-muted` (the muted
15
+ // "highlighted inner container" surface token)
16
+ // - active: same muted surface bg on `[data-active]` and on
17
+ // `[data-state=open]` so open triggers read as pressed
18
+ // - focus: matches UiButton's focus recipe — focus-ring border +
19
+ // tinted ring shadow, 3px wide (no plain `:focus` bg —
20
+ // pointer hovers and kb focus are decoupled here)
12
21
  export const navigationMenuTriggerStyle = cva(
13
- 'group inline-flex h-9 w-max items-center justify-center rounded-md bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground disabled:pointer-events-none disabled:opacity-50 data-[state=open]:hover:bg-accent data-[state=open]:text-accent-foreground data-[state=open]:focus:bg-accent data-[state=open]:bg-accent/50 data-[active]:bg-accent/50 data-[active]:text-accent-foreground data-[active]:hover:bg-accent data-[active]:focus:bg-accent focus-visible:ring-ring/50 outline-none transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1',
22
+ 'group inline-flex h-9 w-max items-center justify-center rounded-md border border-transparent bg-transparent px-4 py-2 text-sm font-medium text-content-on-surface-primary transition-[color,box-shadow,border-color] outline-none hover:bg-background-surface-muted data-[state=open]:bg-background-surface-muted data-[active]:bg-background-surface-muted disabled:pointer-events-none disabled:opacity-50 focus-visible:border-border-surface-focus-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]',
14
23
  );
@@ -89,6 +89,11 @@
89
89
  // Suppress a second ring on the primary control; the row ring is on the outer container.
90
90
  'focus-visible:ring-0 focus-visible:outline-none',
91
91
  'data-[active=true]:text-content-on-surface-primary',
92
+ // Stretched-link: extend the primary control's hit area to cover the full row
93
+ // container (including its `px-2 py-1.5` padding and the gap before the action
94
+ // column) so clicks anywhere on the row activate the item. The action button
95
+ // stays interactive because it comes later in the DOM and is `relative`.
96
+ 'before:content-[""] before:absolute before:inset-0 before:z-0',
92
97
  attrs.class as string | undefined,
93
98
  ),
94
99
  );
@@ -118,7 +123,7 @@
118
123
  */
119
124
  const actionButtonClass = computed(() =>
120
125
  cn(
121
- 'relative inline-flex size-8 shrink-0 items-center justify-center rounded-sm border border-transparent text-content-on-surface-primary outline-hidden transition-colors',
126
+ 'relative z-10 inline-flex size-8 shrink-0 items-center justify-center rounded-sm border border-transparent text-content-on-surface-primary outline-hidden transition-colors',
122
127
  '[&_svg]:size-4 [&_svg]:shrink-0',
123
128
  'focus-visible:ring-0 focus-visible:outline-none',
124
129
  pointerOnAction.value &&
@@ -1,10 +1,12 @@
1
1
  import type { Component } from 'vue';
2
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';
3
+ import { onMounted, ref } from 'vue';
4
+ import { Bot, Check, ChevronDown, ChevronRight, Folder, Home, Settings } from 'lucide-vue-next';
5
+ import { RouterLink, RouterView, useRouter } from 'vue-router';
5
6
  import UiSidebar from './UiSidebar.vue';
6
7
  import UiSidebarContent from './UiSidebarContent.vue';
7
8
  import UiSidebarHeader from './UiSidebarHeader.vue';
9
+ import UiSidebarInset from './UiSidebarInset.vue';
8
10
  import UiSidebarMenu from './UiSidebarMenu.vue';
9
11
  import UiSidebarMenuButton from './UiSidebarMenuButton.vue';
10
12
  import UiSidebarMenuItem from './UiSidebarMenuItem.vue';
@@ -238,3 +240,116 @@ export const Checkbox: Story = {
238
240
  checkbox: true,
239
241
  }),
240
242
  };
243
+
244
+ /**
245
+ * Drive `UiSidebarMenuButton` from Vue Router using `<RouterLink custom>`:
246
+ *
247
+ * - Render the button as `<a :href="href">` via the `as` + `href` attrs (they
248
+ * forward to the core primitive) so native link semantics (middle click,
249
+ * right-click open in new tab, copy link) work.
250
+ * - Bind `:is-active` to the router's `isActive` to reflect the current route
251
+ * with the active rail treatment.
252
+ * - Call `navigate` from the `@click` handler to delegate navigation.
253
+ *
254
+ * The story uses the Storybook-level router (see `.storybook/preview.ts`) and
255
+ * renders a `<RouterView />` next to the sidebar so route changes are visible.
256
+ */
257
+ export const WithVueRouter: Story = {
258
+ parameters: {
259
+ layout: 'fullscreen',
260
+ docs: {
261
+ description: {
262
+ story:
263
+ 'Composing `UiSidebarMenuButton` with `<RouterLink custom>` to bind `href`, `isActive`, and `navigate`. The button renders as an `<a>` tag and the active state is driven purely by the current route.',
264
+ },
265
+ },
266
+ },
267
+ render: () => ({
268
+ components: {
269
+ Folder,
270
+ Home,
271
+ RouterLink,
272
+ RouterView,
273
+ Settings,
274
+ UiSidebar,
275
+ UiSidebarContent,
276
+ UiSidebarHeader,
277
+ UiSidebarInset,
278
+ UiSidebarMenu,
279
+ UiSidebarMenuButton,
280
+ UiSidebarMenuItem,
281
+ UiSidebarProvider,
282
+ },
283
+ setup() {
284
+ const router = useRouter();
285
+
286
+ const items = [
287
+ { to: '/menu-button-demo/overview', label: 'Overview', icon: Home },
288
+ { to: '/menu-button-demo/projects', label: 'Projects', icon: Folder },
289
+ { to: '/menu-button-demo/settings', label: 'Settings', icon: Settings },
290
+ ];
291
+
292
+ for (const item of items) {
293
+ if (!router.hasRoute(item.to)) {
294
+ router.addRoute({
295
+ path: item.to,
296
+ name: item.to,
297
+ component: {
298
+ setup: () => ({ label: item.label, to: item.to }),
299
+ template: `
300
+ <div class="flex flex-col gap-2 p-6">
301
+ <div class="label-12-regular text-content-on-surface-muted">Route</div>
302
+ <div class="heading-s text-content-on-surface-primary">{{ label }}</div>
303
+ <div class="body-14-regular text-content-on-surface-muted">
304
+ Rendered by <code>&lt;RouterView /&gt;</code> for <code>{{ to }}</code>.
305
+ </div>
306
+ </div>
307
+ `,
308
+ },
309
+ });
310
+ }
311
+ }
312
+
313
+ onMounted(() => {
314
+ router.replace(items[0].to);
315
+ });
316
+
317
+ return { items };
318
+ },
319
+ template: `
320
+ <UiSidebarProvider :default-open="true">
321
+ <UiSidebar collapsible="icon" class="w-72">
322
+ <UiSidebarHeader tooltip="Toggle sidebar">Navigation</UiSidebarHeader>
323
+ <UiSidebarContent class="p-2">
324
+ <UiSidebarMenu class="space-y-1">
325
+ <UiSidebarMenuItem v-for="item in items" :key="item.to">
326
+ <RouterLink
327
+ :to="item.to"
328
+ custom
329
+ v-slot="{ href, isActive, navigate }"
330
+ >
331
+ <UiSidebarMenuButton
332
+ as="a"
333
+ :href="href"
334
+ :tooltip="item.label"
335
+ :is-active="isActive"
336
+ @click="navigate"
337
+ >
338
+ <template #start-icon>
339
+ <component :is="item.icon" :size="16" />
340
+ </template>
341
+ {{ item.label }}
342
+ </UiSidebarMenuButton>
343
+ </RouterLink>
344
+ </UiSidebarMenuItem>
345
+ </UiSidebarMenu>
346
+ </UiSidebarContent>
347
+ </UiSidebar>
348
+
349
+ <UiSidebarInset>
350
+ <RouterView />
351
+ </UiSidebarInset>
352
+ </UiSidebarProvider>
353
+ `,
354
+ }),
355
+ };
@@ -48,6 +48,10 @@
48
48
  '[&>[data-slot=start-icon]]:shrink-0 [&>[data-slot=start-icon]>svg]:size-4',
49
49
  '[&>[data-slot=label]]:min-w-0 [&>[data-slot=label]]:truncate',
50
50
  'focus-visible:ring-0',
51
+ // Stretched-link: extend the button's hit area to cover the full row container
52
+ // (including its `px-2 py-1.5` padding and the gap before the end-icon) so clicks
53
+ // anywhere on the row navigate. The end-icon stays interactive via its own `z-10`.
54
+ 'before:content-[""] before:absolute before:inset-0 before:z-0',
51
55
  attrs.class as string | undefined,
52
56
  ),
53
57
  );
@@ -1,8 +1,11 @@
1
1
  import type { Meta, StoryObj } from '@storybook/vue3-vite';
2
- import { Folder } from 'lucide-vue-next';
2
+ import { onMounted } from 'vue';
3
+ import { Folder, Home, Settings } from 'lucide-vue-next';
4
+ import { RouterLink, RouterView, useRouter } from 'vue-router';
3
5
  import UiSidebar from './UiSidebar.vue';
4
6
  import UiSidebarContent from './UiSidebarContent.vue';
5
7
  import UiSidebarHeader from './UiSidebarHeader.vue';
8
+ import UiSidebarInset from './UiSidebarInset.vue';
6
9
  import UiSidebarMenu from './UiSidebarMenu.vue';
7
10
  import UiSidebarMenuButton from './UiSidebarMenuButton.vue';
8
11
  import UiSidebarMenuItem from './UiSidebarMenuItem.vue';
@@ -71,3 +74,118 @@ export const Default: Story = {
71
74
  `,
72
75
  }),
73
76
  };
77
+
78
+ /**
79
+ * Each `UiSidebarMenuItem` hosts a `RouterLink` (in `custom` mode) that forwards
80
+ * the router's `isActive` and `navigate` helpers to `UiSidebarMenuButton`:
81
+ *
82
+ * - `UiSidebarMenuButton` is rendered as `<a :href="href">` via the `as` + `href`
83
+ * attrs (forwarded to the core primitive), so middle-click and copy-link work.
84
+ * - `@click="navigate"` delegates navigation back to Vue Router.
85
+ * - `:is-active="isActive"` drives the active rail + token treatment from the
86
+ * current route, no manual state needed.
87
+ *
88
+ * The story registers three routes against the Storybook-level router (see
89
+ * `.storybook/preview.ts`) and renders `<RouterView />` in a `UiSidebarInset`
90
+ * panel so route changes are visible.
91
+ */
92
+ export const WithVueRouter: Story = {
93
+ parameters: {
94
+ layout: 'fullscreen',
95
+ docs: {
96
+ description: {
97
+ story:
98
+ 'Wire `UiSidebarMenuItem` + `UiSidebarMenuButton` to Vue Router using `<RouterLink custom>`. The button receives `href`, `isActive`, and `navigate` from the slot props and renders as an `<a>` tag for proper middle-click / open-in-new-tab semantics.',
99
+ },
100
+ },
101
+ },
102
+ render: () => ({
103
+ components: {
104
+ Folder,
105
+ Home,
106
+ RouterLink,
107
+ RouterView,
108
+ Settings,
109
+ UiSidebar,
110
+ UiSidebarContent,
111
+ UiSidebarHeader,
112
+ UiSidebarInset,
113
+ UiSidebarMenu,
114
+ UiSidebarMenuButton,
115
+ UiSidebarMenuItem,
116
+ UiSidebarProvider,
117
+ },
118
+ setup() {
119
+ const router = useRouter();
120
+
121
+ const items = [
122
+ { to: '/sidebar-demo/overview', label: 'Overview', icon: Home },
123
+ { to: '/sidebar-demo/projects', label: 'Projects', icon: Folder },
124
+ { to: '/sidebar-demo/settings', label: 'Settings', icon: Settings },
125
+ ];
126
+
127
+ for (const item of items) {
128
+ if (!router.hasRoute(item.to)) {
129
+ router.addRoute({
130
+ path: item.to,
131
+ name: item.to,
132
+ component: {
133
+ props: ['label'],
134
+ setup: () => ({ label: item.label }),
135
+ template: `
136
+ <div class="flex flex-col gap-2 p-6">
137
+ <div class="label-12-regular text-content-on-surface-muted">Route</div>
138
+ <div class="heading-s text-content-on-surface-primary">{{ label }}</div>
139
+ <div class="body-14-regular text-content-on-surface-muted">
140
+ Rendered by <code>&lt;RouterView /&gt;</code> for <code>${item.to}</code>.
141
+ </div>
142
+ </div>
143
+ `,
144
+ },
145
+ });
146
+ }
147
+ }
148
+
149
+ onMounted(() => {
150
+ router.replace(items[0].to);
151
+ });
152
+
153
+ return { items };
154
+ },
155
+ template: `
156
+ <UiSidebarProvider :default-open="true">
157
+ <UiSidebar collapsible="icon" class="w-72">
158
+ <UiSidebarHeader tooltip="Toggle sidebar">Navigation</UiSidebarHeader>
159
+ <UiSidebarContent class="p-2">
160
+ <UiSidebarMenu class="space-y-1">
161
+ <UiSidebarMenuItem v-for="item in items" :key="item.to">
162
+ <RouterLink
163
+ :to="item.to"
164
+ custom
165
+ v-slot="{ href, isActive, navigate }"
166
+ >
167
+ <UiSidebarMenuButton
168
+ as="a"
169
+ :href="href"
170
+ :tooltip="item.label"
171
+ :is-active="isActive"
172
+ @click="navigate"
173
+ >
174
+ <template #start-icon>
175
+ <component :is="item.icon" :size="16" />
176
+ </template>
177
+ {{ item.label }}
178
+ </UiSidebarMenuButton>
179
+ </RouterLink>
180
+ </UiSidebarMenuItem>
181
+ </UiSidebarMenu>
182
+ </UiSidebarContent>
183
+ </UiSidebar>
184
+
185
+ <UiSidebarInset>
186
+ <RouterView />
187
+ </UiSidebarInset>
188
+ </UiSidebarProvider>
189
+ `,
190
+ }),
191
+ };
@@ -36,6 +36,9 @@
36
36
  'focus-visible:ring-0',
37
37
  'data-[active=true]:!bg-transparent data-[active=true]:!text-content-on-surface-primary data-[active=true]:!font-normal',
38
38
  '[&>[data-slot=label]]:min-w-0 [&>[data-slot=label]]:truncate',
39
+ // Stretched-link: extend the hit area to cover the row's padding so clicks
40
+ // anywhere on the row activate the sub-item.
41
+ 'before:content-[""] before:absolute before:inset-0 before:z-0',
39
42
  attrs.class as string | undefined,
40
43
  ),
41
44
  );
@@ -55,7 +55,7 @@
55
55
  :is-active="props.isActive"
56
56
  :class="cn(rootClass, 'min-w-0 flex-1')"
57
57
  >
58
- <div data-slot="start-icon" class="[&_*svg]:size-4">
58
+ <div data-slot="start-icon" class="[&_svg]:size-4">
59
59
  <slot name="icon">
60
60
  <div
61
61
  class="flex size-6 items-center justify-center rounded-md border border-border-surface-default bg-background-surface-primary text-content-on-surface-primary"
@@ -69,7 +69,7 @@
69
69
  {{ props.label }}
70
70
  </span>
71
71
 
72
- <div class="ml-auto shrink-0 group-data-[collapsible=icon]:hidden [&_*svg]:size-4">
72
+ <div class="ml-auto shrink-0 group-data-[collapsible=icon]:hidden [&_svg]:size-4">
73
73
  <slot name="end-icon">
74
74
  <ChevronDown :size="16" />
75
75
  </slot>