'use client' import { ChevronDownIcon, ChevronsUpDownIcon, ChevronUpIcon } from 'lucide-react' import { Fragment, type PointerEvent, type ReactElement, type ReactNode, type Ref } from 'react' import { CampaignTransitionAnchor } from '@/components/campaign/shared/CampaignListPending' import { TableHead } from '@/components/ui/Table' import { cn } from '@/lib/utils' type CampaignSortableHeadProps = { active: boolean align?: 'left' | 'center' | 'right' children: ReactNode className?: string dir: 'asc' | 'desc' filter?: ReactNode href: string nextDir: 'asc' | 'desc' sortLabel: string wrapSortControl?: ( control: ReactElement<{ onPointerUp?: (event: PointerEvent) => void ref?: Ref }>, ) => ReactNode } export const CampaignSortableHead = ({ active, align = 'left', children, className, dir, filter, href, nextDir, sortLabel, wrapSortControl, }: CampaignSortableHeadProps) => { const sortControl = ( {children} {active ? ( dir === 'asc' ? ( ) const labeledSort = wrapSortControl ? wrapSortControl(sortControl) : sortControl return ( {filter ? (
{/* Keyed slots (Issue #1042): `filter` is created by a server component (e.g. LeadershipSortableHead) and arrives without a validated key, so reconciling this array warned "unique key" in the dev build and failed the e2e console guard. Keying both slots covers the array; the Fragments add no DOM. */} {labeledSort} {filter}
) : ( labeledSort )}
) }