"use client" import * as React from "react" import { ChevronDownIcon } from "lucide-react" import { Collapsible as CollapsiblePrimitive } from "radix-ui" import { cn } from "../../lib/utils" /** * `Panel` and `PanelBody` replace `@wordpress/components`' `Panel` / `PanelBody` - **1 import**, * four usages in `QuestionnairePage`. * * BUILT ON COLLAPSIBLE RATHER THAN `ui/accordion`, AND THE DIFFERENCE IS BEHAVIOURAL. An accordion * item needs a `value` and a Root that decides how many can be open at once. WordPress's PanelBody * owns its own open state - several can be open together, and each starts from its own * `initialOpen`. One Collapsible per body is that, exactly, and it keeps the swap mechanical: the * call sites already pass `key`, `title` and `initialOpen` and nothing else. * * `Panel` is the bordered box around them, with WP's optional `header`. */ export interface PanelProps extends React.ComponentProps<"div"> { header?: React.ReactNode } function Panel({ header, className, children, ...props }: PanelProps) { return (
{header && (

{header}

)} {children}
) } export interface PanelBodyProps extends Omit, "title"> { title?: React.ReactNode /** WP's default is open. Both call sites pass `false`. */ initialOpen?: boolean } function PanelBody({ title, initialOpen = true, className, children, ...props }: PanelBodyProps) { // No title means no toggle in WordPress either - the body is simply always shown. if (!title) { return (
{children}
) } return ( {title}
{children}
) } export { Panel, PanelBody }