'use client' import React, { useState, useId } from 'react' import type { FDFaqBlock as FDFaqBlockProps } from '@/payload-types' import RichText from '@/components/RichText' export const FDFaqBlockComponent: React.FC = ({ heading, items, theme = 'gray', anchorId, }) => { const [openIndex, setOpenIndex] = useState(null) /* Generate a stable unique prefix for this block instance */ const blockId = useId() // dark theme = always navy. gray/white adapt via dark: OS preference const bgClass = theme === 'dark' ? 'bg-fd-navy' : theme === 'gray' ? 'bg-fd-gray-light dark:bg-fd-navy' : 'bg-white dark:bg-fd-navy' const headingColor = theme === 'dark' ? 'text-fd-yellow' : 'text-fd-navy dark:text-fd-yellow' const textColor = theme === 'dark' ? 'text-white' : 'text-fd-navy dark:text-white' const borderColor = theme === 'dark' ? 'border-white/20' : 'border-fd-navy/10 dark:border-white/20' const proseColor = theme === 'dark' ? 'text-white/80' : 'text-fd-navy/80 dark:text-white/80' return (

{heading}

{items?.map((item, index) => { const isOpen = openIndex === index /* Accessibility: unique IDs for aria-controls ↔ id linkage */ const triggerId = `${blockId}-faq-trigger-${index}` const panelId = `${blockId}-faq-panel-${index}` return (
) })}
) }