"use client"; import type * as React from "react"; import { useCallback, useRef, useState } from "react"; import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; import { Separator } from "@/components/ui/separator"; import { cn } from "@/lib/utils"; interface NavItem { value: string; label: string; icon: React.ReactNode; } interface SettingsDialogProps { open: boolean; onOpenChange: (open: boolean) => void; title: string; navItems: NavItem[]; activeItem: string; onItemChange: (value: string) => void; children: React.ReactNode; } export function SettingsDialog({ open, onOpenChange, title, navItems, activeItem, onItemChange, children, }: SettingsDialogProps) { const activeRef = useRef(null); const [tabScrollPos, setTabScrollPos] = useState<"start" | "middle" | "end">("start"); const handleTabScroll = useCallback((e: React.UIEvent) => { const el = e.currentTarget; const atStart = el.scrollLeft <= 2; const atEnd = el.scrollWidth - el.scrollLeft - el.clientWidth <= 2; setTabScrollPos(atStart ? "start" : atEnd ? "end" : "middle"); }, []); const handleItemChange = (value: string) => { onItemChange(value); activeRef.current?.scrollIntoView({ inline: "center", block: "nearest", behavior: "smooth" }); }; return ( {title} {/* Desktop: Left sidebar */} {/* Mobile: Top header + horizontal tabs */}

{title}

{navItems.map((item) => ( ))}
{/* Content area */}

{navItems.find((i) => i.value === activeItem)?.label ?? title}

{children}
); }