"use client"; import { useReducedMotion } from "../motion/Preferences.tsx"; import { createContext, useContext, useState, useId, type ReactNode, } from "react"; import { AnimatePresence, motion } from "motion/react"; import { EASE_EXPO } from "../motion/easings.ts"; type AccordionContextValue = { open: Set; toggle: (value: string) => void; }; const AccordionContext = createContext(null); export function Accordion({ children, allowMultiple = false, className = "", }: { children: ReactNode; allowMultiple?: boolean; className?: string; }) { const [open, setOpen] = useState>(new Set()); const toggle = (value: string) => { setOpen((prev) => { const next = new Set(allowMultiple ? prev : []); if (prev.has(value)) { next.delete(value); } else { next.add(value); } return next; }); }; return (
{children}
); } export function AccordionItem({ value, title, children, className = "", }: { value: string; title: string; children: ReactNode; className?: string; }) { const id = useId(); const reduce = useReducedMotion(); const ctx = useContext(AccordionContext); if (!ctx) throw new Error("AccordionItem must be used within "); const isOpen = ctx.open.has(value); const buttonId = `mizu-acc-${id}-btn`; const panelId = `mizu-acc-${id}-panel`; return (

{isOpen && (
{children}
)}
); }