@papernote/ui 1.7.0 → 1.7.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@papernote/ui",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "type": "module",
5
5
  "description": "A modern React component library with a paper notebook aesthetic - minimal, professional, and expressive",
6
6
  "main": "dist/index.js",
@@ -5,6 +5,7 @@ import { ChevronRight, Home } from 'lucide-react';
5
5
  export interface BreadcrumbItem {
6
6
  label: string;
7
7
  href?: string;
8
+ onClick?: () => void;
8
9
  icon?: React.ReactNode;
9
10
  }
10
11
 
@@ -32,33 +33,63 @@ export default function Breadcrumbs({ items, showHome = true }: BreadcrumbsProps
32
33
  {items.map((item, index) => {
33
34
  const isLast = index === items.length - 1;
34
35
  const isActive = isLast;
36
+ const content = (
37
+ <>
38
+ {item.icon && <span className="flex-shrink-0">{item.icon}</span>}
39
+ <span>{item.label}</span>
40
+ </>
41
+ );
35
42
 
36
- return (
37
- <React.Fragment key={index}>
38
- {item.href && !isActive ? (
43
+ const renderBreadcrumb = () => {
44
+ // Active item (last item) - always render as non-clickable span
45
+ if (isActive) {
46
+ return (
47
+ <span
48
+ className="flex items-center gap-2 px-2 py-1 rounded-md bg-accent-50 text-accent-900 font-semibold transition-colors"
49
+ aria-current="page"
50
+ >
51
+ {content}
52
+ </span>
53
+ );
54
+ }
55
+
56
+ // Has href - render as Link, also call onClick if provided
57
+ if (item.href) {
58
+ return (
39
59
  <Link
40
60
  to={item.href}
61
+ onClick={item.onClick}
41
62
  className="flex items-center gap-2 text-ink-500 hover:text-ink-900 hover:underline transition-colors"
42
63
  >
43
- {item.icon && <span className="flex-shrink-0">{item.icon}</span>}
44
- <span>{item.label}</span>
64
+ {content}
45
65
  </Link>
46
- ) : (
47
- <span
48
- className={`
49
- flex items-center gap-2 px-2 py-1 rounded-md transition-colors
50
- ${isActive
51
- ? 'bg-accent-50 text-accent-900 font-semibold'
52
- : 'text-ink-700 font-medium'
53
- }
54
- `}
55
- aria-current={isActive ? 'page' : undefined}
66
+ );
67
+ }
68
+
69
+ // Only onClick (no href) - render as button
70
+ if (item.onClick) {
71
+ return (
72
+ <button
73
+ type="button"
74
+ onClick={item.onClick}
75
+ className="flex items-center gap-2 text-ink-500 hover:text-ink-900 hover:underline transition-colors bg-transparent border-none cursor-pointer p-0"
56
76
  >
57
- {item.icon && <span className="flex-shrink-0">{item.icon}</span>}
58
- <span>{item.label}</span>
59
- </span>
60
- )}
77
+ {content}
78
+ </button>
79
+ );
80
+ }
61
81
 
82
+ // Neither href nor onClick - render as non-clickable span
83
+ return (
84
+ <span className="flex items-center gap-2 text-ink-700 font-medium">
85
+ {content}
86
+ </span>
87
+ );
88
+ };
89
+
90
+ return (
91
+ <React.Fragment key={index}>
92
+ {renderBreadcrumb()}
62
93
  {!isLast && <ChevronRight className="h-4 w-4 text-ink-400" />}
63
94
  </React.Fragment>
64
95
  );