Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

Merge remote-tracking branch 'origin/main' into feat/keyboard-nav-polish

aashu829c979b9004
diff --cc apps/erp/app/components/Layout/Navigation/PrimaryNavigation.tsx
index dcdb5c303a,ff3e7d70dd..eb6f8bc9e2
--- a/apps/erp/app/components/Layout/Navigation/PrimaryNavigation.tsx
+++ b/apps/erp/app/components/Layout/Navigation/PrimaryNavigation.tsx
@@@ -1,10 -1,11 +1,12 @@@
import {
+ cn,
+ NavRail,
+ NavRailItem,
+ NavRailLink,
ShortcutKey,
- useDisclosure,
useShortcutKeys,
useShortcutSequence,
- VStack
+ useSidebar
} from "@carbon/react";
import {
closestCenter,
@@@ -100,209 -109,107 +110,140 @@@ const PrimaryNavigation = () =>
useSensor(KeyboardSensor)
);
- useEffect(() => {
- if (!editMode.isEditing) return;
- const onKeyDown = (e: KeyboardEvent) => {
- if (e.key === "Escape") editMode.cancelEditMode();
- };
- document.addEventListener("keydown", onKeyDown);
- return () => document.removeEventListener("keydown", onKeyDown);
- }, [editMode.isEditing, editMode.cancelEditMode]);
- const renderLink = (link: Authenticated<NavItem>, isActive: boolean) => (
- <NavRailLink
- key={link.name}
- to={link.to}
- icon={<link.icon />}
- label={link.name}
- tag={link.tag}
- external={link.external}
- isActive={isActive}
- />
- );
++ // Only modules have a g-then-letter key; pass it for those.
++ const renderLink = (
++ link: Authenticated<NavItem>,
++ isActive: boolean,
++ goToKey?: string
++ ) => {
++ return (
++ <NavRailLink
++ key={link.name}
++ to={link.to}
++ icon={<link.icon />}
++ label={link.name}
++ tag={link.tag}
++ external={link.external}
++ isActive={isActive}
++ trailing={goToKey ? <GoToHint goToKey={goToKey} /> : undefined}
++ />
++ );
++ };
- const isOpen = navigationPanel.isOpen || editMode.isEditing;
+ const footer = (
+ <>
+ {settingsModule && !editMode.isEditing
- ? renderLink(settingsModule, isModuleActive(settingsModule.to))
++ ? renderLink(
++ settingsModule,
++ isModuleActive(settingsModule.to),
++ MODULE_GO_TO[settingsModule.key]
++ )
+ : null}
- return (
- // The wrapper (not just the inner nav) grows on expand, so the rail pushes
- // the rest of the layout right instead of floating over it. The inner nav is
- // `w-full` and follows the wrapper's animated width.
- <div
- data-state={isOpen ? "expanded" : "collapsed"}
- className={cn(
- "h-full flex-col z-50 hidden md:flex shrink-0",
- "w-14 data-[state=expanded]:w-[13rem]",
- "transition-[width] duration-200"
+ {editMode.isEditing ? (
+ <NavigationEditBar
+ isSaving={editMode.isSaving}
+ isDirty={editMode.isDirty}
+ onSave={editMode.save}
+ onCancel={editMode.cancelEditMode}
+ />
+ ) : isMobile ? null : (
+ <NavRailItem
+ icon={<LuSettings2 />}
+ label={t`Customize`}
+ onClick={editMode.enterEditMode}
+ className={ACTION_HOVER}
+ />
)}
- >
- <nav
- data-state={isOpen ? "expanded" : "collapsed"}
- className={cn(
- "bg-background py-2 group z-10 h-full w-full",
- "flex flex-col justify-between",
- "hide-scrollbar overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"
- )}
- onMouseEnter={
- editMode.isEditing || isSearchModalOpen
- ? undefined
- : navigationPanel.onOpen
- }
- onMouseLeave={editMode.isEditing ? undefined : navigationPanel.onClose}
- >
- <VStack
- spacing={1}
- className="flex flex-col justify-between h-full px-2"
- >
- <VStack spacing={1}>
- {permissions.is("employee") && (
- <NavigationSearchButton isOpen={isOpen} />
- )}
- {!editMode.isEditing && implementationNav ? (
- <NavigationIconLink
- link={implementationNav}
- isActive={currentModule === "get-started"}
- isOpen={isOpen}
- onClick={navigationPanel.onClose}
- />
- ) : null}
- {editMode.isEditing ? (
- <DndContext
- sensors={sensors}
- collisionDetection={closestCenter}
- onDragEnd={editMode.handleDragEnd}
- >
- <SortableContext
- items={editMode.visibleDraft.map((m) => m.key)}
- strategy={verticalListSortingStrategy}
- >
- {editMode.visibleDraft.map((module) => (
- <SortableNavItem
- key={module.key}
- module={module}
- isOpen={isOpen}
- onToggleHidden={editMode.toggleHidden}
- />
- ))}
- </SortableContext>
- </DndContext>
- ) : (
- links.map((link) => {
- const m = getModule(link.to);
- const moduleMatches = matchedModules.has(m);
- const isActive = currentModule === m || moduleMatches;
- return (
- <NavigationIconLink
- key={link.name}
- link={link}
- goToKey={MODULE_GO_TO[link.key]}
- isActive={isActive}
- isOpen={isOpen}
- onClick={navigationPanel.onClose}
- />
- );
- })
- )}
+ </>
+ );
- {editMode.isEditing && (
- <HiddenModulesPopover
- hiddenModules={editMode.hiddenDraft}
- onToggleHidden={editMode.toggleHidden}
- />
- )}
- </VStack>
+ const canSearch = permissions.is("employee");
- <VStack spacing={1}>
- {settingsModule &&
- !editMode.isEditing &&
- (() => {
- const m = getModule(settingsModule.to);
- const moduleMatches = matchedModules.has(m);
- const isActive = currentModule === m || moduleMatches;
- return (
- <NavigationIconLink
- link={settingsModule}
- goToKey={MODULE_GO_TO[settingsModule.key]}
- isActive={isActive}
- isOpen={isOpen}
- onClick={navigationPanel.onClose}
- />
- );
- })()}
+ return (
+ <>
+ <NavRail
+ forceExpanded={editMode.isEditing}
+ disableHover={editMode.isEditing || isSearchModalOpen}
+ footer={footer}
+ >
+ {canSearch && <NavigationSearchButton />}
+ {!editMode.isEditing && implementationNav
+ ? renderLink(implementationNav, currentModule === "get-started")
+ : null}
+ {editMode.isEditing ? (
+ <DndContext
+ sensors={sensors}
+ collisionDetection={closestCenter}
+ onDragEnd={editMode.handleDragEnd}
+ >
+ <SortableContext
+ items={editMode.visibleDraft.map((m) => m.key)}
+ strategy={verticalListSortingStrategy}
+ >
+ {editMode.visibleDraft.map((module) => (
+ <SortableNavItem
+ key={module.key}
+ module={module}
+ onToggleHidden={editMode.toggleHidden}
+ />
+ ))}
+ </SortableContext>
+ </DndContext>
+ ) : (
- links.map((link) => renderLink(link, isModuleActive(link.to)))
++ links.map((link) =>
++ renderLink(link, isModuleActive(link.to), MODULE_GO_TO[link.key])
++ )
+ )}
- {editMode.isEditing ? (
- <NavigationEditBar
- isSaving={editMode.isSaving}
- isDirty={editMode.isDirty}
- onSave={editMode.save}
- onCancel={editMode.cancelEditMode}
- />
- ) : (
- <button
- type="button"
- onClick={editMode.enterEditMode}
- className={cn(
- "relative",
- "h-10 w-10 group-data-[state=expanded]:w-full",
- "flex items-center rounded-md",
- "group-data-[state=collapsed]:justify-center",
- "group-data-[state=expanded]:-space-x-2",
- "font-medium shrink-0 inline-flex select-none",
- "hover:bg-accent hover:text-accent-foreground",
- "transition-[background-color,color,width] duration-100 ease-out",
- "focus:!outline-none focus:!ring-0 active:!outline-none active:!ring-0",
- "after:pointer-events-none after:absolute after:-inset-[3px] after:rounded-lg after:border after:border-blue-500 after:opacity-0 after:ring-2 after:ring-blue-500/20 after:transition-opacity focus-visible:after:opacity-100 active:after:opacity-0",
- "group/item"
- )}
- >
- <LuSettings2 className="absolute left-3 top-3 flex items-center justify-center" />
- <span
- className={cn(
- "min-w-[128px] text-sm text-left",
- "absolute left-7 group-data-[state=expanded]:left-12",
- "opacity-0 group-data-[state=expanded]:opacity-100"
- )}
- >
- <Trans>Customize</Trans>
- </span>
- </button>
- )}
- </VStack>
- </VStack>
- </nav>
- </div>
+ {editMode.isEditing && (
+ <HiddenModulesPopover
+ hiddenModules={editMode.hiddenDraft}
+ onToggleHidden={editMode.toggleHidden}
+ />
+ )}
+ </NavRail>
+ {/* Outside the rail: on phones the rail is a drawer that unmounts when
+ closed, and ⌘K plus the modal must outlive it. */}
+ {canSearch && <GlobalSearch />}
+ </>
);
};
- const NavigationSearchButton = ({ isOpen = false }: { isOpen?: boolean }) => {
- const { t } = useLingui();
- const { openSearchModal } = useUIStore();
++// Hovering is what expands the rail, so the g-then-letter hint shows on the
++// hovered/focused row only.
++const GoToHint = ({ goToKey }: { goToKey: string }) => (
++ <span
++ aria-hidden
++ className={cn(
++ "flex items-center gap-0.5 opacity-0 transition-opacity duration-100",
++ "group-hover/item:opacity-100 group-focus-visible/item:opacity-100"
++ )}
++ >
++ <ShortcutKey
++ shortcut={MODULE_GO_TO_PREFIX}
++ variant="small"
++ className="mx-0"
++ />
++ <ShortcutKey shortcut={goToKey} variant="small" className="mx-0" />
++ </span>
++);
+
- useShortcutKeys({
- shortcut: searchShortcut,
- action: openSearchModal
- });
+ const NavigationSearchButton = () => {
+ const { t } = useLingui();
+ const openSearchModal = useUIStore((s) => s.openSearchModal);
+ const { setOpenMobile } = useSidebar();
return (
- <>
- <button
- type="button"
- aria-label={t`Search`}
- onClick={openSearchModal}
- className={cn(
- "relative",
- "h-10 w-10 group-data-[state=expanded]:w-full",
- "flex items-center rounded-md",
- "group-data-[state=collapsed]:justify-center",
- "group-data-[state=expanded]:-space-x-2",
- "font-medium shrink-0 inline-flex select-none",
- "hover:bg-accent hover:text-accent-foreground",
- "transition-[background-color,color,width] duration-100 ease-out",
- "focus:!outline-none focus:!ring-0 active:!outline-none active:!ring-0",
- "after:pointer-events-none after:absolute after:-inset-[3px] after:rounded-lg after:border after:border-blue-500 after:opacity-0 after:ring-2 after:ring-blue-500/20 after:transition-opacity focus-visible:after:opacity-100 active:after:opacity-0",
- "group/item"
- )}
- >
- <LuSearch className="absolute left-3 top-3 flex items-center justify-center" />
- <span
- aria-hidden={isOpen || undefined}
- className={cn(
- "min-w-[128px] text-sm text-left",
- "absolute left-7 group-data-[state=expanded]:left-12",
- "opacity-0 group-data-[state=expanded]:opacity-100"
- )}
- >
- <Trans>Search</Trans>
- </span>
- {/* ⌘K hint — only meaningful when expanded (the shortcut itself is wired
- via useShortcutKeys above, same as the old topbar search). */}
+ <NavRailItem
+ icon={<LuSearch />}
+ label={t`Search`}
+ onClick={() => {
+ setOpenMobile(false);
+ openSearchModal();
+ }}
+ className={ACTION_HOVER}
+ trailing={
<ShortcutKey
shortcut={searchShortcut}
variant="small"
diff --cc packages/jobs/manifests/schema.json
index 715b1a7a61,715b1a7a61..36043804ad
--- a/packages/jobs/manifests/schema.json
+++ b/packages/jobs/manifests/schema.json
@@@ -1,11 -1,11 +1,11 @@@
{
"kind": "carbon-company-backup",
"version": 1,
-- "schemaVersion": "20260928023448",
++ "schemaVersion": "20260929221847",
"sourceCompanyId": "schema-baseline",
"sourceCompanyGroupId": null,
"sourceCompanyName": null,
-- "exportedAt": "2026-09-28T20:45:32.712Z",
++ "exportedAt": "2026-09-30T13:56:22.760Z",
"exportedBy": "schema-baseline",
"label": "schema baseline",
"includeStorage": "none",
@@@ -428,6 -428,6 +428,7 @@@
"accountsReceivableEmail",
"defaultSupplierCc",
"assetTaxRate",
++ "showBomExplorerReadableId",
"rfqReadyNotificationGroup",
"operationsDispatchNotificationGroup",
"kanbanOutput",
@@@ -1824,6 -1824,6 +1825,7 @@@
"validTo",
"amountType",
"minQuantity",
++ "configurationPrices",
"itemIds",
"customerIds",
"id",
@@@ -4216,6 -4216,6 +4218,7 @@@
"createdBy",
"exchangeRate",
"accountId",
++ "configuration",
"promisedDate",
"description",
"modelUploadId",
diff --cc packages/react/src/NavRail.tsx
index 0000000000,9b7d96cfca..53432fb9f9
mode 000000,100644..100644
--- a/packages/react/src/NavRail.tsx
+++ b/packages/react/src/NavRail.tsx
@@@ -1,0 -1,396 +1,399 @@@
+ "use client";
+
+ import { Trans } from "@lingui/react/macro";
+ import { Slot, Slottable } from "@radix-ui/react-slot";
+ import type { ButtonHTMLAttributes, ReactNode } from "react";
+ import {
+ createContext,
+ forwardRef,
+ useCallback,
+ useContext,
+ useEffect,
+ useRef,
+ useState
+ } from "react";
+ import type { LinkProps } from "react-router";
+ import { Link, useLocation } from "react-router";
+ import { Drawer, DrawerContent, DrawerTitle } from "./Drawer";
+ import { Separator } from "./Separator";
+ import { useSidebar } from "./Sidebar";
+ import { cn } from "./utils/cn";
+ import { VStack } from "./VStack";
+
+ const focusRingClasses = [
+ "focus:!outline-none focus:!ring-0 active:!outline-none active:!ring-0",
+ "after:pointer-events-none after:absolute after:-inset-[3px] after:rounded-lg after:border after:border-blue-500 after:opacity-0 after:ring-2 after:ring-blue-500/20 after:transition-opacity focus-visible:after:opacity-100 active:after:opacity-0"
+ ];
+
+ export const navRailItemClasses = [
+ "relative text-foreground/70 hover:text-foreground",
+ "h-10 w-10 group-data-[state=expanded]:w-full",
+ "flex items-center rounded-md",
+ "group-data-[state=collapsed]:justify-center",
+ "group-data-[state=expanded]:-space-x-2",
+ "font-medium shrink-0 inline-flex items-center justify-center select-none",
+ "disabled:opacity-50",
+ "transition-[background-color,color,width] duration-100 ease-out",
+ focusRingClasses,
+ "group/item"
+ ];
+
+ /**
+ * The primary left navigation shared by the ERP and MES app shells: a 56px
+ * icon rail that grows to 208px while a mouse hovers it or while it is pinned
+ * open (⌘B / a `SidebarTrigger`), and a left drawer below `md`. Open state
+ * comes from `SidebarProvider`, so it must be rendered inside one.
+ */
+ // A pointer only passing over the rail (on its way to the page) shouldn't open it.
+ const HOVER_OPEN_DELAY_MS = 150;
+
+ // Lets an item freeze the rail as it is (open or collapsed) while a menu or
+ // popover it triggered is open, so a tap on a collapsed rail never opens it.
+ const NavRailHoldContext = createContext<(() => () => void) | null>(null);
+
+ export function NavRail({
+ children,
+ header,
+ footer,
+ forceExpanded = false,
+ disableHover = false
+ }: {
+ children: ReactNode;
+ header?: ReactNode;
+ footer?: ReactNode;
+ /** Hold the rail open regardless of hover or pin (e.g. while rearranging). */
+ forceExpanded?: boolean;
+ /** Ignore hover, e.g. while a modal owns the pointer. */
+ disableHover?: boolean;
+ }) {
+ const { open, isMobile, openMobile, setOpenMobile } = useSidebar();
+ const { pathname } = useLocation();
+ const [hovered, setHovered] = useState(false);
+ const navRef = useRef<HTMLElement>(null);
+ const lastPointerType = useRef<string>();
+ const openTimer = useRef<ReturnType<typeof setTimeout>>();
+ const cancelHoverOpen = useCallback(() => {
+ clearTimeout(openTimer.current);
+ openTimer.current = undefined;
+ }, []);
+ useEffect(() => cancelHoverOpen, [cancelHoverOpen]);
+ const [holds, setHolds] = useState(0);
+ const hold = useCallback(() => {
+ setHolds((n) => n + 1);
+ return () => setHolds((n) => n - 1);
+ }, []);
+
+ // Links, go-to shortcuts and redirects all land here: whatever navigated,
+ // the phone drawer must not stay over the destination.
+ // biome-ignore lint/correctness/useExhaustiveDependencies: runs per navigation
+ useEffect(() => {
+ setOpenMobile(false);
+ }, [pathname, setOpenMobile]);
+
+ // A Radix dialog or menu sets pointer-events: none on document.body while
+ // open, which fires a leave on the rail as it opens and a phantom enter as
+ // it closes, so pointer events are ignored while blocked. A modal (search)
+ // collapses the rail; a menu opened from the rail keeps it as it was. When
+ // the block lifts, hover is re-read from where the pointer really is.
+ const hoverBlocked = disableHover || holds > 0;
+ useEffect(() => {
+ if (disableHover) setHovered(false);
+ }, [disableHover]);
+ useEffect(() => {
+ cancelHoverOpen();
+ if (hoverBlocked) return;
+ // Touch browsers leave `:hover` stuck on the last tapped element, so only
+ // a mouse's `:hover` counts.
+ const raf = requestAnimationFrame(() =>
+ setHovered(
+ lastPointerType.current === "mouse" &&
+ (navRef.current?.matches(":hover") ?? false)
+ )
+ );
+ return () => cancelAnimationFrame(raf);
+ }, [hoverBlocked, cancelHoverOpen]);
+
+ const content = (
+ <NavRailHoldContext.Provider value={hold}>
+ <VStack spacing={1} className="flex flex-col justify-between h-full px-2">
+ <VStack spacing={1}>
+ {header ? <div className="w-full pb-2">{header}</div> : null}
+ {children}
+ </VStack>
+ {footer ? <VStack spacing={1}>{footer}</VStack> : null}
+ </VStack>
+ </NavRailHoldContext.Provider>
+ );
+
+ if (isMobile) {
+ return (
+ <Drawer open={openMobile} onOpenChange={setOpenMobile}>
+ <DrawerContent
+ position="left"
+ size="content"
+ className="w-[17rem] max-w-[85vw] p-0"
+ >
+ <DrawerTitle className="px-6 py-4">
+ <Trans>Navigation</Trans>
+ </DrawerTitle>
+ <nav
+ data-state="expanded"
+ className="group flex-1 overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent pb-4"
+ >
+ {content}
+ </nav>
+ </DrawerContent>
+ </Drawer>
+ );
+ }
+
+ const state = forceExpanded || open || hovered ? "expanded" : "collapsed";
+
+ return (
+ // The wrapper (not just the inner nav) grows on expand, so the rail pushes
+ // the rest of the layout right instead of floating over it. Sticky so it
+ // stays in view in shells whose page scrolls as a whole.
+ <div
+ data-state={state}
+ className={cn(
+ "sticky top-0 h-svh flex-col z-50 hidden md:flex shrink-0",
+ "w-14 data-[state=expanded]:w-[13rem]",
+ "transition-[width] duration-200"
+ )}
+ >
+ <nav
+ ref={navRef}
+ data-state={state}
+ className={cn(
+ "bg-background py-2 group z-10 h-full w-full",
+ "flex flex-col justify-between",
+ "hide-scrollbar overflow-y-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-accent"
+ )}
+ onPointerDown={(event) => {
+ lastPointerType.current = event.pointerType;
+ }}
+ // Mouse only: a tap on a touch tablet must not expand the rail.
+ onPointerMove={(event) => {
+ lastPointerType.current = event.pointerType;
+ if (hoverBlocked || hovered || openTimer.current) return;
+ if (event.pointerType !== "mouse") return;
+ openTimer.current = setTimeout(() => {
+ openTimer.current = undefined;
+ setHovered(true);
+ }, HOVER_OPEN_DELAY_MS);
+ }}
+ onPointerLeave={(event) => {
+ if (hoverBlocked || event.pointerType !== "mouse") return;
+ // The leave a Radix layer causes by disabling body pointer-events
+ // can arrive before this render knows about the hold.
+ if (document.body.style.pointerEvents === "none") return;
+ cancelHoverOpen();
+ setHovered(false);
+ }}
+ >
+ {content}
+ </nav>
+ </div>
+ );
+ }
+
+ type NavRailItemProps = Omit<
+ ButtonHTMLAttributes<HTMLButtonElement>,
+ "children"
+ > & {
+ icon: ReactNode;
+ /** Also the accessible name; the visible label span is aria-hidden. */
+ label: string;
+ isActive?: boolean;
+ tag?: ReactNode;
+ /** Shown at the right edge only while expanded (e.g. a shortcut hint). */
+ trailing?: ReactNode;
+ asChild?: boolean;
+ children?: ReactNode;
+ };
+
+ /**
+ * One rail entry. A `<button>` by default; with `asChild` the child element
+ * becomes the item, so a `Link` or a Radix trigger keeps its own semantics.
+ */
+ export const NavRailItem = forwardRef<HTMLButtonElement, NavRailItemProps>(
+ (
+ {
+ icon,
+ label,
+ isActive = false,
+ tag,
+ trailing,
+ asChild = false,
+ className,
+ children,
+ ...props
+ },
+ ref
+ ) => {
+ const Comp = asChild ? Slot : "button";
+
+ // Radix triggers (menus, popovers) pass their open state as `data-state`.
+ const isTriggerOpen =
+ (props as Record<string, unknown>)["data-state"] === "open";
+ const hold = useContext(NavRailHoldContext);
+ useEffect(() => {
+ if (isTriggerOpen && hold) return hold();
+ }, [isTriggerOpen, hold]);
+
+ return (
+ <Comp
+ ref={ref}
+ type={asChild ? undefined : "button"}
+ aria-label={label}
+ {...props}
+ className={cn(
+ navRailItemClasses,
+ isActive
+ ? "bg-active text-active-foreground dark:shadow-button-base"
+ : "hover:bg-active/60 hover:text-active-foreground",
+ className
+ )}
+ >
+ {/* A 16px icon centred in this 24px box sits where a `left-3 top-3`
+ icon would; the box also fits an `Avatar size="xs"`. */}
+ <span className="absolute left-2 top-2 flex size-6 items-center justify-center [&>svg]:size-4">
+ {icon}
+ </span>
+ {tag ? (
+ <span className="absolute top-1 right-1 min-w-4 h-4 px-1 rounded-full bg-primary text-primary-foreground text-[10px] font-medium leading-4 text-center tabular-nums">
+ {tag}
+ </span>
+ ) : null}
+ {/* Label and trailing share one row so a long label truncates
+ before the trailing content instead of running under it. */}
+ <span
+ className={cn(
+ "absolute left-7 right-3 min-w-32 group-data-[state=expanded]:left-12",
+ "flex items-center gap-2",
+ "opacity-0 group-data-[state=expanded]:opacity-100"
+ )}
+ >
+ <span
+ aria-hidden
+ className="min-w-0 flex-1 truncate text-sm text-left"
+ >
+ {label}
+ </span>
+ {trailing ? (
+ <span className="pointer-events-none flex shrink-0 items-center">
+ {trailing}
+ </span>
+ ) : null}
+ </span>
+ <Slottable>{children}</Slottable>
+ </Comp>
+ );
+ }
+ );
+ NavRailItem.displayName = "NavRailItem";
+
+ export function NavRailLink({
+ to,
+ icon,
+ label,
+ isActive = false,
+ tag,
++ trailing,
+ external = false,
+ target,
+ rel
+ }: {
+ to: string;
+ icon: ReactNode;
+ label: string;
+ isActive?: boolean;
+ tag?: ReactNode;
++ trailing?: ReactNode;
+ external?: boolean;
+ target?: LinkProps["target"];
+ rel?: string;
+ }) {
+ return (
+ <NavRailItem
+ asChild
+ icon={icon}
+ label={label}
+ isActive={isActive}
+ tag={tag}
++ trailing={trailing}
+ >
+ <Link
+ to={to}
+ target={target}
+ rel={rel}
+ aria-current={isActive ? "page" : undefined}
+ prefetch={external ? "none" : "intent"}
+ />
+ </NavRailItem>
+ );
+ }
+
+ /** For `header`: the logo sits in the icon column, the name has equal margins. */
+ export function NavRailBrand({
+ href,
+ logo,
+ label
+ }: {
+ href: string;
+ logo: ReactNode;
+ label: string;
+ }) {
+ return (
+ <a
+ href={href}
+ aria-label={label}
+ className={cn(
+ "relative flex h-10 w-full items-center gap-2 rounded-md px-2",
+ "text-sm font-medium text-foreground select-none",
+ "transition-[background-color] duration-100 ease-out hover:bg-active/60",
+ focusRingClasses
+ )}
+ >
+ <span className="flex size-6 shrink-0 items-center justify-center [&>svg]:size-4">
+ {logo}
+ </span>
+ <span
+ aria-hidden
+ className="min-w-0 flex-1 truncate opacity-0 transition-opacity duration-200 group-data-[state=expanded]:opacity-100"
+ >
+ {label}
+ </span>
+ </a>
+ );
+ }
+
+ /** A titled section; collapsed, its title turns into a divider. */
+ export function NavRailGroup({
+ label,
+ children
+ }: {
+ label: string;
+ children: ReactNode;
+ }) {
+ return (
+ <VStack spacing={1}>
+ <div className="relative h-7 w-full shrink-0">
+ <span
+ aria-hidden
+ className="absolute inset-x-0 top-1/2 mx-auto h-px w-6 bg-border opacity-100 transition-opacity duration-200 group-data-[state=expanded]:opacity-0"
+ />
+ <span className="absolute inset-0 flex items-center px-2 text-[11px] font-medium uppercase tracking-wider text-foreground/50 whitespace-nowrap opacity-0 transition-opacity duration-200 group-data-[state=expanded]:opacity-100">
+ {label}
+ </span>
+ </div>
+ {children}
+ </VStack>
+ );
+ }
+
+ export function NavRailDivider() {
+ return (
+ <Separator className="my-1 mx-auto w-6 group-data-[state=expanded]:w-full transition-[width] duration-200" />
+ );
+ }