// Copyright (c) Meta Platforms, Inc. and affiliates. 'use client'; /** * @file TopNav.tsx * @input Uses React, ReactNode * @output Exports TopNav component and TopNavProps * @position Core implementation; consumed by index.ts * * SYNC: When modified, update these files to stay in sync: * - /packages/core/src/TopNav/TopNav.doc.mjs * - /packages/core/src/TopNav/TopNav.test.tsx * - /packages/core/src/TopNav/index.ts * - /apps/storybook/stories/TopNav.stories.tsx * - /packages/cli/assets/templates/blocks/components/TopNav/ (showcase blocks) */ import type { ReactNode } from 'react'; import type { BaseProps } from "../BaseProps.js"; import * as stylex from "../style-runtime.js"; import "../theme/tokens.stylex.js"; import { spacingVars } from "../theme/tokens.stylex.js"; import { mergeProps } from "../utils/index.js"; import { useTranslator } from "../i18n/index.js"; import { TopNavSlotContext } from "./TopNavContext.js"; import { useTopNavRenderMode } from "./TopNavRenderContext.js"; import { useTopNavMobileContent } from "./TopNavMobileContentContext.js"; import { Divider } from "../Divider/Divider.js"; import { MobileNav } from "../MobileNav/MobileNav.js"; import { MobileNavToggle } from "../MobileNav/MobileNavToggle.js"; import { useAppShellMobile } from "../AppShell/AppShellMobileContext.js"; import { themeProps } from "../utils/themeProps.js"; /** * Base TopNav styles */ const styles = { base: { kGNEyG: "x6s0dn4", kzqmXN: "xh8yej3", kmVPX3: "xlsj2fj", kB7OPa: "x9f619", $$css: true as const }, baseFlex: { k1xSpc: "x78zum5", $$css: true as const }, baseGrid: { k1xSpc: "xrvj5dj", kumcoG: "x134kloy", $$css: true as const }, mobileBar: { k1xSpc: "x78zum5", kGNEyG: "x6s0dn4", kzqmXN: "xh8yej3", kmVPX3: "xlsj2fj", kB7OPa: "x9f619", $$css: true as const }, drawerDivider: { kqGvvJ: "x1g06x3t", $$css: true as const } }; export interface TopNavProps extends BaseProps { /** Ref forwarded to the root element */ ref?: React.Ref; /** * Heading slot content — typically TopNavHeading with logo and text. * Positioned at the left edge of the nav bar. */ heading?: ReactNode; /** * Start content slot - typically navigation items or breadcrumbs. * Positioned after the title, left-aligned. */ startContent?: ReactNode; /** * Alias for startContent. Prefer startContent when composing with other slots. * * This keeps the common React children pattern from silently dropping * navigation items. If both children and startContent are provided, * startContent takes precedence and children are ignored. */ children?: ReactNode; /** * Center content slot - typically tabs, search bar, or primary navigation. * Positioned at the horizontal center of the nav bar. * When provided, the layout switches to a three-column CSS grid to ensure * true centering regardless of start/end content widths. */ centerContent?: ReactNode; /** * End content slot - typically search, icons, user profile, utility menus. * Positioned at the right edge of the nav bar. */ endContent?: ReactNode; /** * Accessible label for the navigation landmark. * Helps screen readers identify the navigation area. * @default 'Top navigation' */ label?: string; } /** * Top navigation bar for application headers. * * Slot-based layout with `heading`, `startContent`, `centerContent`, and * `endContent`. `children` are accepted as an alias for `startContent` * so navigation items do not silently disappear when using the common * React children pattern. When `centerContent` is provided, the layout switches * to a three-column CSS grid to keep center content horizontally centered. * * @example * ``` * } * startContent={} * endContent={