@orsetra/shared-ui 1.5.4 → 1.5.6
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.
|
@@ -29,6 +29,7 @@ export interface MainMenuItem {
|
|
|
29
29
|
id: string
|
|
30
30
|
label: string
|
|
31
31
|
icon: LucideIcon
|
|
32
|
+
href?: string
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export interface SubMenuItem {
|
|
@@ -58,6 +59,7 @@ export interface ApiMainMenuItem {
|
|
|
58
59
|
id: string
|
|
59
60
|
label: string
|
|
60
61
|
icon: string
|
|
62
|
+
href?: string
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
export interface ApiSubMenuItem {
|
|
@@ -195,6 +195,12 @@ function Sidebar({ currentMenu, onMainMenuToggle, sidebarMenus = {}, main_base_u
|
|
|
195
195
|
|
|
196
196
|
const isCollapsed = state === "collapsed"
|
|
197
197
|
|
|
198
|
+
const filteredMainItems = React.useMemo(() => {
|
|
199
|
+
if (!isCollapsed || mainMenuItems.length === 0) return []
|
|
200
|
+
const navIds = new Set(currentNavigation.map((n) => n.id))
|
|
201
|
+
return mainMenuItems.filter((item) => !navIds.has(item.id))
|
|
202
|
+
}, [isCollapsed, mainMenuItems, currentNavigation])
|
|
203
|
+
|
|
198
204
|
return (
|
|
199
205
|
<div
|
|
200
206
|
className="h-screen sticky top-0 flex flex-col bg-gray-50 min-w-[var(--sidebar-width-icon)] transition-[width] duration-200 overflow-visible"
|
|
@@ -239,24 +245,28 @@ function Sidebar({ currentMenu, onMainMenuToggle, sidebarMenus = {}, main_base_u
|
|
|
239
245
|
"flex-1 overflow-y-auto",
|
|
240
246
|
isCollapsed ? "px-1 py-3 space-y-0.5" : "px-3 py-4 space-y-1"
|
|
241
247
|
)}>
|
|
242
|
-
{/* Main menu items — only
|
|
243
|
-
{
|
|
248
|
+
{/* Main menu items — only in collapsed mode, above secondary items */}
|
|
249
|
+
{filteredMainItems.length > 0 && (
|
|
244
250
|
<>
|
|
245
|
-
{
|
|
246
|
-
const
|
|
251
|
+
{filteredMainItems.map((item) => {
|
|
252
|
+
const rawHref = item.href || `${main_base_url}/${item.id}`
|
|
253
|
+
const href = rawHref.startsWith('http') ? new URL(rawHref).pathname : rawHref
|
|
247
254
|
const isActive = currentMenu === item.id
|
|
248
255
|
const linkEl = (
|
|
249
256
|
<Link
|
|
250
257
|
key={item.id}
|
|
251
|
-
href={href
|
|
258
|
+
href={href}
|
|
252
259
|
className={cn(
|
|
253
260
|
"flex items-center justify-center p-2 transition-colors border-l-4",
|
|
254
261
|
isActive
|
|
255
|
-
? "bg-interactive/10
|
|
256
|
-
: "
|
|
262
|
+
? "bg-interactive/10 border-interactive"
|
|
263
|
+
: "hover:bg-ui-background border-transparent"
|
|
257
264
|
)}
|
|
258
265
|
>
|
|
259
|
-
<item.icon
|
|
266
|
+
<item.icon
|
|
267
|
+
className="h-4 w-4 flex-shrink-0"
|
|
268
|
+
style={{ color: isActive ? '#0f62fe' : '#8d8d8d' }}
|
|
269
|
+
/>
|
|
260
270
|
</Link>
|
|
261
271
|
)
|
|
262
272
|
return (
|
|
@@ -266,7 +276,7 @@ function Sidebar({ currentMenu, onMainMenuToggle, sidebarMenus = {}, main_base_u
|
|
|
266
276
|
</Tooltip>
|
|
267
277
|
)
|
|
268
278
|
})}
|
|
269
|
-
<div className="border-t border-ui-border mx-1 my-
|
|
279
|
+
<div className="border-t border-ui-border mx-1 my-2" />
|
|
270
280
|
</>
|
|
271
281
|
)}
|
|
272
282
|
|
|
@@ -297,7 +307,10 @@ function Sidebar({ currentMenu, onMainMenuToggle, sidebarMenus = {}, main_base_u
|
|
|
297
307
|
: "text-text-secondary hover:bg-ui-background hover:text-text-primary border-transparent"
|
|
298
308
|
)}
|
|
299
309
|
>
|
|
300
|
-
<item.icon
|
|
310
|
+
<item.icon
|
|
311
|
+
className="h-4 w-4 flex-shrink-0"
|
|
312
|
+
style={{ color: isActive ? '#0f62fe' : '#4589ff' }}
|
|
313
|
+
/>
|
|
301
314
|
{!isCollapsed && item.name}
|
|
302
315
|
</Link>
|
|
303
316
|
)
|