import "./Collapsible.css"; import clsx from "clsx"; import { ComponentChildren, HTMLAttributes } from "preact"; import { useRef, useState } from "preact/hooks"; import { useElementSize, useUniqueName } from "./hooks"; import Icon from "./Icon"; interface CollapsibleProps extends Pick, "className"> { title: string; children: ComponentChildren; initiallyExpanded?: boolean; } export default function Collapsible({ initiallyExpanded, ...restProps }: CollapsibleProps) { const [ expanded, setExpanded ] = useState(initiallyExpanded); return ; } export function ExternallyControlledCollapsible({ title, children, className, expanded, setExpanded }: Omit & { expanded: boolean | undefined; setExpanded: (expanded: boolean) => void }) { const bodyRef = useRef(null); const innerRef = useRef(null); const { height } = useElementSize(innerRef) ?? {}; const contentId = useUniqueName(); return (
{children}
); }