"use client"; import React from "react"; import { useRouter } from "next/navigation"; import { Check, ChevronDown } from "lucide-react"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; /** * SegmentDropdown * * A small dropdown trigger used next to breadcrumb segments to switch between * existing years/months/days. * * IMPORTANT: * - This component MUST be declared at module scope (not inside another component render), * otherwise React will treat it as a new component type on each render and warn/error. * * UX rule: * - All visible text is provided by the parent in German. * * @param {{ * items: Array<{ value: string, label: string, href: string }>, * currentValue: string|null, * menuLabel: string, * triggerAriaLabel: string * }} props */ export default function SegmentDropdown({ items, currentValue, menuLabel, triggerAriaLabel, }) { const router = useRouter(); if (!Array.isArray(items) || items.length === 0) return null; return ( {menuLabel} {items.map((it) => { const isActive = currentValue && String(it.value) === String(currentValue); return ( { // Radix fires onSelect for click + keyboard. Prevent default for consistent behavior. e.preventDefault(); router.push(it.href); }} > {isActive ? ( ); })} ); }