/* Copyright 2026 Marimo. All rights reserved. */ import React, { type JSX, type PropsWithChildren } from "react"; import { z } from "zod"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { renderHTML } from "../core/RenderHTML"; import type { IStatelessPlugin, IStatelessPluginProps, } from "../stateless-plugin"; interface Data { /** * The labels for each item; raw HTML. */ labels: string[]; /** * Whether to allow multiple tabs to be open. */ multiple: boolean; } export class AccordionPlugin implements IStatelessPlugin { tagName = "marimo-accordion"; validator = z.object({ labels: z.array(z.string()), multiple: z.boolean(), }); render(props: IStatelessPluginProps): JSX.Element { return ( {props.children} ); } } const AccordionComponent = ({ labels, multiple, children, }: PropsWithChildren): JSX.Element => { const type = multiple ? "multiple" : "single"; return ( {React.Children.map(children, (child, index) => { return ( {renderHTML({ html: labels[index] })} {child} ); })} ); };