Files
supabase/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx
Gildas Garcia 7f4b02f2a7 chore: update radix (#45111)
## Problem

In order to update to react 19, we need to update several dependencies

## Solution

- migrate to the `radix` umbrella package to ease upgrade
- update some dependencies


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Consolidated Radix UI usage to a single unified package across apps
and packages, updated package manifests and workspace catalog entries.
No user-facing behavior, visuals, or public APIs changed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-04-27 11:03:28 +02:00

105 lines
3.2 KiB
TypeScript

'use client'
import { usePathname } from 'next/navigation'
import { Accordion } from 'radix-ui'
import { PropsWithChildren } from 'react'
import { type NavMenuSection } from '../Navigation.types'
import { MenuId } from './NavigationMenu'
import * as NavItems from './NavigationMenu.constants'
import NavigationMenuGuideListItems from './NavigationMenuGuideListItems'
const NavigationMenuGuideList = ({
id,
additionalNavItems,
}: {
id: string
additionalNavItems?: Record<string, Partial<NavMenuSection>[]>
}) => {
const pathname = usePathname()
const firstLevelRoute = pathname?.split('/')?.slice(0, 4)?.join('/')
// eslint-disable-next-line import/namespace -- dynamic access, can't lint properly
let menu = NavItems[id]
if (id === MenuId.Integrations && additionalNavItems?.integrations) {
const integrationsListIndex = menu.items.findIndex((item) => item.name === 'Integrations')
if (integrationsListIndex !== -1) {
menu = {
...menu,
items: [
...menu.items.slice(0, integrationsListIndex),
{
...menu.items[integrationsListIndex],
items: [...menu.items[integrationsListIndex].items, ...additionalNavItems.integrations],
},
...menu.items.slice(integrationsListIndex + 1),
],
}
}
}
// Inject federated prompts into the 'AI Tools > Prompts' section
if (id === MenuId.GettingStarted && additionalNavItems?.prompts) {
const aiToolsSectionIndex = menu.items.findIndex((item) => item.name === 'AI Tools')
if (aiToolsSectionIndex !== -1) {
const beforeAITools = menu.items.slice(0, aiToolsSectionIndex)
const afterAITools = menu.items.slice(aiToolsSectionIndex + 1)
const aiToolsSection = menu.items[aiToolsSectionIndex]
const promptsSectionIndex = aiToolsSection.items.findIndex((item) => item.name === 'Prompts')
if (promptsSectionIndex !== -1) {
const beforePrompts = aiToolsSection.items.slice(0, promptsSectionIndex)
const afterPrompts = aiToolsSection.items.slice(promptsSectionIndex + 1)
const promptsSection = aiToolsSection.items[promptsSectionIndex]
const modifiedPromptsSection = {
...promptsSection,
items: additionalNavItems.prompts,
}
const modifiedAIToolsSection = {
...aiToolsSection,
items: [...beforePrompts, modifiedPromptsSection, ...afterPrompts],
}
menu = {
...menu,
items: [...beforeAITools, modifiedAIToolsSection, ...afterAITools],
}
}
}
}
return (
<NavigationMenuGuideListWrapper id={id} firstLevelRoute={firstLevelRoute}>
<NavigationMenuGuideListItems menu={menu} id={id} />
</NavigationMenuGuideListWrapper>
)
}
export function NavigationMenuGuideListWrapper({
id,
firstLevelRoute,
children,
}: PropsWithChildren<{
id: string
firstLevelRoute?: string
}>) {
return (
<Accordion.Root
collapsible={true}
key={id}
type="single"
value={firstLevelRoute}
className="transition-all duration-150 ease-out opacity-100 ml-0 delay-150 w-full"
>
{children}
</Accordion.Root>
)
}
export default NavigationMenuGuideList