@inbeat/ui 0.11.2 → 0.12.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.12.0](https://github.com/Genoux/ib-toolkit/compare/ui-v0.11.3...ui-v0.12.0) (2026-10-13)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **ui:** make breadcrumb a single adaptive component ([#60](https://github.com/Genoux/ib-toolkit/issues/60))
9
+
10
+ ### Features
11
+
12
+ * **ui:** make breadcrumb a single adaptive component ([#60](https://github.com/Genoux/ib-toolkit/issues/60)) ([502a13b](https://github.com/Genoux/ib-toolkit/commit/502a13baeac34279c88cb77192d3ce824da58d23))
13
+
14
+ ## [0.11.3](https://github.com/Genoux/ib-toolkit/compare/ui-v0.11.2...ui-v0.11.3) (2026-10-13)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **ui:** keep long breadcrumb titles on one line ([#58](https://github.com/Genoux/ib-toolkit/issues/58)) ([31852e3](https://github.com/Genoux/ib-toolkit/commit/31852e3002bc1d5f9b86aec0d4eb35624b013307))
20
+
3
21
  ## [0.11.2](https://github.com/Genoux/ib-toolkit/compare/ui-v0.11.1...ui-v0.11.2) (2026-10-09)
4
22
 
5
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inbeat/ui",
3
- "version": "0.11.2",
3
+ "version": "0.12.0",
4
4
  "description": "inBeat design tokens and primitives (Radix + Tailwind v4), shipped as source",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -64,7 +64,7 @@
64
64
  "@base-ui/react": "^1.2.0",
65
65
  "@fontsource-variable/geist": "^5.3.0",
66
66
  "@fontsource-variable/geist-mono": "^5.3.0",
67
- "@inbeat/config": "^0.11.2",
67
+ "@inbeat/config": "^0.12.0",
68
68
  "@storybook/addon-a11y": "^10.6.0",
69
69
  "@storybook/addon-docs": "^10.6.0",
70
70
  "@storybook/addon-themes": "^10.6.0",
@@ -83,7 +83,7 @@ function AppShell({
83
83
  orientation="vertical"
84
84
  className={cn(headerStyle.separator, "data-[orientation=vertical]:h-4")}
85
85
  />
86
- {header ? <div className="flex w-full items-center justify-between">{header}</div> : null}
86
+ {header ? <div className="flex w-full min-w-0 items-center justify-between">{header}</div> : null}
87
87
  </div>
88
88
  </header>
89
89
  <div className="flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto">{children}</div>
@@ -1,19 +1,40 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
2
4
  import { ChevronRight, MoreHorizontal } from "lucide-react";
3
5
  import { Slot } from "radix-ui";
4
6
 
5
7
  import { cn } from "../lib/utils";
8
+ import {
9
+ DropdownMenu,
10
+ DropdownMenuContent,
11
+ DropdownMenuItem,
12
+ DropdownMenuTrigger,
13
+ } from "./dropdown-menu";
14
+ import { TooltipContent, TooltipRoot, TooltipTrigger } from "./tooltip";
6
15
 
7
- function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
8
- return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />;
9
- }
16
+ type BreadcrumbLinkItem = { label: React.ReactNode; href: string };
17
+
18
+ // The element is rendered through Slot and asChild, so it must forward props and ref.
19
+ type RenderBreadcrumbLink<Link extends BreadcrumbLinkItem> = (
20
+ link: Link,
21
+ content: React.ReactNode,
22
+ ) => React.ReactElement;
10
23
 
11
- function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
24
+ const MAX_INLINE_LINKS = 2;
25
+ // From md the sidebar takes 16rem, which leaves too little header room for inline links until lg.
26
+ const DESKTOP_ONLY = "hidden lg:inline-flex";
27
+
28
+ const renderAnchor: RenderBreadcrumbLink<BreadcrumbLinkItem> = (link, content) => (
29
+ <a href={link.href}>{content}</a>
30
+ );
31
+
32
+ function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
12
33
  return (
13
- <ol
14
- data-slot="breadcrumb-list"
34
+ <li
35
+ data-slot="breadcrumb-item"
15
36
  className={cn(
16
- "text-muted-foreground flex flex-wrap items-center gap-1 text-sm wrap-break-word ",
37
+ "inline-flex shrink-0 items-center gap-1.5",
17
38
  className,
18
39
  )}
19
40
  {...props}
@@ -21,89 +42,151 @@ function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
21
42
  );
22
43
  }
23
44
 
24
- function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
45
+ function BreadcrumbSeparator({ className }: { className?: string }) {
25
46
  return (
26
47
  <li
27
- data-slot="breadcrumb-item"
28
- className={cn("inline-flex items-center gap-1.5", className)}
29
- {...props}
30
- />
48
+ data-slot="breadcrumb-separator"
49
+ role="presentation"
50
+ aria-hidden="true"
51
+ className={cn("[&>svg]:size-3.5", className)}
52
+ >
53
+ <ChevronRight />
54
+ </li>
31
55
  );
32
56
  }
33
57
 
34
- function BreadcrumbLink({
35
- asChild,
36
- className,
37
- ...props
38
- }: React.ComponentProps<"a"> & {
39
- asChild?: boolean;
58
+ function TruncationTooltip({
59
+ content,
60
+ children,
61
+ }: {
62
+ content: React.ReactNode;
63
+ children: React.ReactElement;
40
64
  }) {
41
- const Comp = asChild ? Slot.Root : "a";
65
+ // Radix types the trigger ref as a button; with asChild it lands on the span or anchor child.
66
+ const triggerRef = React.useRef<HTMLButtonElement>(null);
67
+ const [tooltipOpen, setTooltipOpen] = React.useState(false);
42
68
 
43
69
  return (
44
- <Comp
45
- data-slot="breadcrumb-link"
46
- className={cn("py-1 px-1.5 rounded-md hover:text-foreground hover:bg-muted-foreground/5 transition-colors", className)}
47
- {...props}
48
- />
70
+ <TooltipRoot
71
+ open={tooltipOpen}
72
+ onOpenChange={(open) => {
73
+ const trigger = triggerRef.current;
74
+ setTooltipOpen(open && !!trigger && trigger.scrollWidth > trigger.clientWidth);
75
+ }}
76
+ >
77
+ <TooltipTrigger asChild ref={triggerRef}>
78
+ {children}
79
+ </TooltipTrigger>
80
+ <TooltipContent>{content}</TooltipContent>
81
+ </TooltipRoot>
49
82
  );
50
83
  }
51
84
 
52
- function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
85
+ function BreadcrumbPage({ children }: { children: React.ReactNode }) {
53
86
  return (
54
- <span
55
- data-slot="breadcrumb-page"
56
- role="link"
57
- aria-disabled="true"
58
- aria-current="page"
59
- className={cn("py-1 px-1.5 text-foreground font-normal", className)}
60
- {...props}
61
- />
87
+ <TruncationTooltip content={children}>
88
+ <span
89
+ data-slot="breadcrumb-page"
90
+ role="link"
91
+ aria-disabled="true"
92
+ aria-current="page"
93
+ className="block truncate py-1 px-1.5 text-foreground font-normal"
94
+ >
95
+ {children}
96
+ </span>
97
+ </TruncationTooltip>
62
98
  );
63
99
  }
64
100
 
65
- function BreadcrumbSeparator({
66
- children,
101
+ function BreadcrumbMenu<Link extends BreadcrumbLinkItem>({
102
+ links,
103
+ renderLink,
67
104
  className,
68
- ...props
69
- }: React.ComponentProps<"li">) {
105
+ }: {
106
+ links: Link[];
107
+ renderLink: RenderBreadcrumbLink<Link>;
108
+ className: string;
109
+ }) {
70
110
  return (
71
- <li
72
- data-slot="breadcrumb-separator"
73
- role="presentation"
74
- aria-hidden="true"
75
- className={cn("[&>svg]:size-3.5", className)}
76
- {...props}
77
- >
78
- {children ?? <ChevronRight />}
79
- </li>
111
+ <>
112
+ <BreadcrumbItem className={className}>
113
+ <DropdownMenu>
114
+ <DropdownMenuTrigger
115
+ aria-label="Show more breadcrumbs"
116
+ className="flex h-7 items-center rounded-md px-1.5 hover:text-foreground hover:bg-muted-foreground/5 transition-colors"
117
+ >
118
+ <MoreHorizontal className="size-4" />
119
+ </DropdownMenuTrigger>
120
+ <DropdownMenuContent align="start" className="max-w-72">
121
+ {links.map((link) => (
122
+ <DropdownMenuItem key={link.href} asChild>
123
+ {renderLink(link, link.label)}
124
+ </DropdownMenuItem>
125
+ ))}
126
+ </DropdownMenuContent>
127
+ </DropdownMenu>
128
+ </BreadcrumbItem>
129
+ <BreadcrumbSeparator className={className} />
130
+ </>
80
131
  );
81
132
  }
82
133
 
83
- function BreadcrumbEllipsis({
134
+ function Breadcrumb<Link extends BreadcrumbLinkItem>({
135
+ links = [],
136
+ page,
137
+ renderLink = renderAnchor,
84
138
  className,
85
- ...props
86
- }: React.ComponentProps<"span">) {
139
+ }: {
140
+ links?: Link[];
141
+ page: React.ReactNode;
142
+ renderLink?: RenderBreadcrumbLink<Link>;
143
+ className?: string;
144
+ }) {
145
+ const renderInlineLink = (link: Link) => (
146
+ <React.Fragment key={link.href}>
147
+ <BreadcrumbItem className={DESKTOP_ONLY}>
148
+ <TruncationTooltip content={link.label}>
149
+ <Slot.Root
150
+ data-slot="breadcrumb-link"
151
+ className="block max-w-40 truncate py-1 px-1.5 rounded-md hover:text-foreground hover:bg-muted-foreground/5 transition-colors"
152
+ >
153
+ {renderLink(link, link.label)}
154
+ </Slot.Root>
155
+ </TruncationTooltip>
156
+ </BreadcrumbItem>
157
+ <BreadcrumbSeparator className={DESKTOP_ONLY} />
158
+ </React.Fragment>
159
+ );
160
+
87
161
  return (
88
- <span
89
- data-slot="breadcrumb-ellipsis"
90
- role="presentation"
91
- aria-hidden="true"
92
- className={cn("flex size-9 items-center justify-center", className)}
93
- {...props}
94
- >
95
- <MoreHorizontal className="size-4" />
96
- <span className="sr-only">More</span>
97
- </span>
162
+ <nav aria-label="breadcrumb" data-slot="breadcrumb" className={cn("min-w-0", className)}>
163
+ <ol
164
+ data-slot="breadcrumb-list"
165
+ className="text-muted-foreground flex items-center gap-1 text-sm"
166
+ >
167
+ {links.length > 0 && (
168
+ <BreadcrumbMenu links={links} renderLink={renderLink} className="lg:hidden" />
169
+ )}
170
+ {links.length > MAX_INLINE_LINKS ? (
171
+ <>
172
+ {links.slice(0, 1).map(renderInlineLink)}
173
+ <BreadcrumbMenu
174
+ links={links.slice(1, -1)}
175
+ renderLink={renderLink}
176
+ className={DESKTOP_ONLY}
177
+ />
178
+ {links.slice(-1).map(renderInlineLink)}
179
+ </>
180
+ ) : (
181
+ links.map(renderInlineLink)
182
+ )}
183
+ <BreadcrumbItem className="min-w-20 shrink">
184
+ <BreadcrumbPage>{page}</BreadcrumbPage>
185
+ </BreadcrumbItem>
186
+ </ol>
187
+ </nav>
98
188
  );
99
189
  }
100
190
 
101
- export {
102
- Breadcrumb,
103
- BreadcrumbEllipsis,
104
- BreadcrumbItem,
105
- BreadcrumbLink,
106
- BreadcrumbList,
107
- BreadcrumbPage,
108
- BreadcrumbSeparator,
109
- };
191
+ export { Breadcrumb };
192
+ export type { BreadcrumbLinkItem };