import {
Card,
CardAction,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@suphark/ui/components/ui/card";
import { cn } from "@suphark/ui/lib/utils";
import type { ReactNode } from "react";
import { type CollapsibleProps, CollapsibleSectionCard } from "./collapsible-section";
/**
* Card ที่มีหัว (title/description/actions) แบบสั้น ๆ สำหรับหน้า console —
* ประกอบจาก Card ของ shadcn (ไม่แก้ต้นฉบับ); ถ้าต้องการ layout อื่นใช้ Card* ตรง ๆ ได้
* `collapsible` = หัวเป็นปุ่มหุบ/ขยาย (`initialOpen`, `open`/`onOpenChange`, `storageKey` จำสถานะ, `summary` ตอนหุบ)
*
* …
*/
export function SectionCard({
title,
description,
actions,
children,
className,
contentClassName,
collapsible = false,
summary,
initialOpen,
open,
onOpenChange,
storageKey,
headingAs: Heading = "h2",
}: CollapsibleProps & {
/**
* แท็กของหัวการ์ด (แบบไม่หุบ) — ค่าเริ่มต้น h2 ให้โปรแกรมอ่านจอกระโดดหาหัวข้อได้ (เดิมเป็น div)
* การ์ดซ้อนใต้หัวข้อ h2 อีกชั้นใช้ "h3" · "div" = แบบเดิม
*/
headingAs?: "h2" | "h3" | "h4" | "div";
/** หัวเป็นปุ่มหุบ/ขยาย (ต้องมี `title`) */
collapsible?: boolean;
/** สรุปท้ายหัวตอนหุบ เช่น "4 ไฟล์ · 2.1 MB" */
summary?: ReactNode;
title?: ReactNode;
description?: ReactNode;
actions?: ReactNode;
children: ReactNode;
className?: string;
/** ตารางเต็มความกว้างใช้ "p-0" */
contentClassName?: string;
}) {
if (collapsible) {
return (
{children}
);
}
return (
{(title || description || actions) && (
{title && (
{title}
)}
{description && {description}}
{actions && {actions}}
)}
{children}
);
}