import React, { useId, useState } from 'react'; import { Tone, Surface, cn, surfaceClasses, useEffectiveSurface, ChevronDownIcon, } from '../common'; import { PixelButton } from '../actions'; /* ───────────────────────────────────────────────────────────────────────── PixelCollapsible — toggleable details block with a chevron header. ───────────────────────────────────────────────────────────────────────── */ export interface PixelCollapsibleProps { /** Trigger label. */ label: string; /** Body content rendered when open. */ children: React.ReactNode; /** Initial open state. Defaults to `false`. */ defaultOpen?: boolean; /** Tone tint for the trigger button. Defaults to `'neutral'`. */ tone?: Tone; /** Visual surface override. */ surface?: Surface; /** Render with surface-aware border + radius chrome. Defaults to false (no chrome). */ bordered?: boolean; } export function PixelCollapsible({ label, children, defaultOpen = false, tone = 'neutral', surface: surfaceProp, bordered = false, }: PixelCollapsibleProps) { const surface = useEffectiveSurface(surfaceProp); const s = surfaceClasses(surface); const [open, setOpen] = useState(defaultOpen); /* Stable trigger/content ids for the disclosure aria wiring — same pattern as PixelAccordion (aria-expanded + aria-controls on the trigger, aria-labelledby back-reference on the content region). */ const baseId = useId(); const triggerId = `${baseId}-trigger`; const contentId = `${baseId}-content`; return (