2026-03-05 11:30:31 +09:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import React, { useState } from "react";
|
|
|
|
|
import { ChevronDown, ChevronRight } from "lucide-react";
|
|
|
|
|
import { ConfigSectionDefinition } from "./ConfigPanelTypes";
|
|
|
|
|
|
|
|
|
|
interface ConfigSectionProps {
|
|
|
|
|
section: ConfigSectionDefinition;
|
|
|
|
|
children: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ConfigSection({ section, children }: ConfigSectionProps) {
|
|
|
|
|
const [isOpen, setIsOpen] = useState(section.defaultOpen ?? true);
|
|
|
|
|
|
|
|
|
|
if (section.collapsible) {
|
|
|
|
|
return (
|
2026-03-11 14:46:07 +09:00
|
|
|
<div className="border-b border-border/40 py-2.5">
|
2026-03-05 11:30:31 +09:00
|
|
|
<button
|
|
|
|
|
onClick={() => setIsOpen(!isOpen)}
|
2026-03-11 14:46:07 +09:00
|
|
|
className="flex w-full items-center justify-between py-0.5 text-left"
|
2026-03-05 11:30:31 +09:00
|
|
|
>
|
2026-03-11 14:46:07 +09:00
|
|
|
<span className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
|
|
|
|
|
{section.title}
|
|
|
|
|
</span>
|
|
|
|
|
<div className="flex items-center gap-1.5">
|
|
|
|
|
{section.description && (
|
|
|
|
|
<span className="text-muted-foreground/60 text-[9px]">
|
|
|
|
|
{section.description}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
{isOpen ? (
|
|
|
|
|
<ChevronDown className="h-3 w-3 shrink-0 text-muted-foreground/50" />
|
|
|
|
|
) : (
|
|
|
|
|
<ChevronRight className="h-3 w-3 shrink-0 text-muted-foreground/50" />
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2026-03-05 11:30:31 +09:00
|
|
|
</button>
|
2026-03-11 14:46:07 +09:00
|
|
|
{isOpen && <div className="mt-1.5 space-y-1">{children}</div>}
|
2026-03-05 11:30:31 +09:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2026-03-11 14:46:07 +09:00
|
|
|
<div className="border-b border-border/40 py-2.5">
|
|
|
|
|
<div className="mb-1.5 flex items-center justify-between">
|
|
|
|
|
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
|
|
|
|
|
{section.title}
|
|
|
|
|
</h4>
|
2026-03-05 11:30:31 +09:00
|
|
|
{section.description && (
|
2026-03-11 14:46:07 +09:00
|
|
|
<span className="text-muted-foreground/60 text-[9px]">
|
2026-03-05 11:30:31 +09:00
|
|
|
{section.description}
|
2026-03-11 14:46:07 +09:00
|
|
|
</span>
|
2026-03-05 11:30:31 +09:00
|
|
|
)}
|
|
|
|
|
</div>
|
2026-03-11 14:46:07 +09:00
|
|
|
<div className="space-y-1">{children}</div>
|
2026-03-05 11:30:31 +09:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|