@inbeat/ui 0.11.3 → 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 +11 -0
- package/package.json +2 -2
- package/src/components/breadcrumb.tsx +142 -89
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## [0.11.3](https://github.com/Genoux/ib-toolkit/compare/ui-v0.11.2...ui-v0.11.3) (2026-10-13)
|
|
4
15
|
|
|
5
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inbeat/ui",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
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",
|
|
@@ -5,38 +5,36 @@ import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
|
5
5
|
import { Slot } from "radix-ui";
|
|
6
6
|
|
|
7
7
|
import { cn } from "../lib/utils";
|
|
8
|
+
import {
|
|
9
|
+
DropdownMenu,
|
|
10
|
+
DropdownMenuContent,
|
|
11
|
+
DropdownMenuItem,
|
|
12
|
+
DropdownMenuTrigger,
|
|
13
|
+
} from "./dropdown-menu";
|
|
8
14
|
import { TooltipContent, TooltipRoot, TooltipTrigger } from "./tooltip";
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<nav
|
|
13
|
-
aria-label="breadcrumb"
|
|
14
|
-
data-slot="breadcrumb"
|
|
15
|
-
className={cn("min-w-0", className)}
|
|
16
|
-
{...props}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
16
|
+
type BreadcrumbLinkItem = { label: React.ReactNode; href: string };
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
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;
|
|
23
|
+
|
|
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
|
+
);
|
|
33
31
|
|
|
34
32
|
function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
35
33
|
return (
|
|
36
34
|
<li
|
|
37
35
|
data-slot="breadcrumb-item"
|
|
38
36
|
className={cn(
|
|
39
|
-
"inline-flex shrink-0 items-center gap-1.5
|
|
37
|
+
"inline-flex shrink-0 items-center gap-1.5",
|
|
40
38
|
className,
|
|
41
39
|
)}
|
|
42
40
|
{...props}
|
|
@@ -44,96 +42,151 @@ function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
|
|
|
44
42
|
);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
function
|
|
48
|
-
asChild,
|
|
49
|
-
className,
|
|
50
|
-
...props
|
|
51
|
-
}: React.ComponentProps<"a"> & {
|
|
52
|
-
asChild?: boolean;
|
|
53
|
-
}) {
|
|
54
|
-
const Comp = asChild ? Slot.Root : "a";
|
|
55
|
-
|
|
45
|
+
function BreadcrumbSeparator({ className }: { className?: string }) {
|
|
56
46
|
return (
|
|
57
|
-
<
|
|
58
|
-
data-slot="breadcrumb-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
<li
|
|
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>
|
|
62
55
|
);
|
|
63
56
|
}
|
|
64
57
|
|
|
65
|
-
function
|
|
66
|
-
|
|
58
|
+
function TruncationTooltip({
|
|
59
|
+
content,
|
|
60
|
+
children,
|
|
61
|
+
}: {
|
|
62
|
+
content: React.ReactNode;
|
|
63
|
+
children: React.ReactElement;
|
|
64
|
+
}) {
|
|
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
67
|
const [tooltipOpen, setTooltipOpen] = React.useState(false);
|
|
68
68
|
|
|
69
69
|
return (
|
|
70
70
|
<TooltipRoot
|
|
71
71
|
open={tooltipOpen}
|
|
72
72
|
onOpenChange={(open) => {
|
|
73
|
-
const
|
|
74
|
-
setTooltipOpen(open && !!
|
|
73
|
+
const trigger = triggerRef.current;
|
|
74
|
+
setTooltipOpen(open && !!trigger && trigger.scrollWidth > trigger.clientWidth);
|
|
75
75
|
}}
|
|
76
76
|
>
|
|
77
|
-
<TooltipTrigger asChild>
|
|
78
|
-
|
|
79
|
-
data-slot="breadcrumb-page"
|
|
80
|
-
role="link"
|
|
81
|
-
aria-disabled="true"
|
|
82
|
-
aria-current="page"
|
|
83
|
-
className={cn("block truncate py-1 px-1.5 text-foreground font-normal", className)}
|
|
84
|
-
{...props}
|
|
85
|
-
ref={pageRef}
|
|
86
|
-
>
|
|
87
|
-
{children}
|
|
88
|
-
</span>
|
|
77
|
+
<TooltipTrigger asChild ref={triggerRef}>
|
|
78
|
+
{children}
|
|
89
79
|
</TooltipTrigger>
|
|
90
|
-
<TooltipContent>{
|
|
80
|
+
<TooltipContent>{content}</TooltipContent>
|
|
91
81
|
</TooltipRoot>
|
|
92
82
|
);
|
|
93
83
|
}
|
|
94
84
|
|
|
95
|
-
function
|
|
96
|
-
|
|
85
|
+
function BreadcrumbPage({ children }: { children: React.ReactNode }) {
|
|
86
|
+
return (
|
|
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>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function BreadcrumbMenu<Link extends BreadcrumbLinkItem>({
|
|
102
|
+
links,
|
|
103
|
+
renderLink,
|
|
97
104
|
className,
|
|
98
|
-
|
|
99
|
-
|
|
105
|
+
}: {
|
|
106
|
+
links: Link[];
|
|
107
|
+
renderLink: RenderBreadcrumbLink<Link>;
|
|
108
|
+
className: string;
|
|
109
|
+
}) {
|
|
100
110
|
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
+
</>
|
|
110
131
|
);
|
|
111
132
|
}
|
|
112
133
|
|
|
113
|
-
function
|
|
134
|
+
function Breadcrumb<Link extends BreadcrumbLinkItem>({
|
|
135
|
+
links = [],
|
|
136
|
+
page,
|
|
137
|
+
renderLink = renderAnchor,
|
|
114
138
|
className,
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
|
|
117
161
|
return (
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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>
|
|
128
188
|
);
|
|
129
189
|
}
|
|
130
190
|
|
|
131
|
-
export {
|
|
132
|
-
|
|
133
|
-
BreadcrumbEllipsis,
|
|
134
|
-
BreadcrumbItem,
|
|
135
|
-
BreadcrumbLink,
|
|
136
|
-
BreadcrumbList,
|
|
137
|
-
BreadcrumbPage,
|
|
138
|
-
BreadcrumbSeparator,
|
|
139
|
-
};
|
|
191
|
+
export { Breadcrumb };
|
|
192
|
+
export type { BreadcrumbLinkItem };
|