{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "faq-section",
  "title": "FAQ Section",
  "description": "Answers before someone has to ask: a short list on one plate, a longer list beside a heading that stays in view, or a filter box with an empty state.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "utils",
    "https://miseui.junsu4621.workers.dev/r/accordion.json",
    "https://miseui.junsu4621.workers.dev/r/button.json",
    "https://miseui.junsu4621.workers.dev/r/empty.json",
    "https://miseui.junsu4621.workers.dev/r/search-field.json"
  ],
  "files": [
    {
      "path": "registry/miseui/blocks/faq-section.tsx",
      "content": "import { cn } from \"@/registry/miseui/lib/utils\"\nimport type { FaqItem } from \"./faq-section-filter\"\nimport { DEFAULT_CONTACT, DEFAULT_COPY, DEFAULT_ITEMS, FaqContactLine, FaqHeading, FaqList, ROOT_CLASS, type FaqContact, type FaqSectionCopyProps } from \"./faq-section-parts\"\nimport { FaqSectionSearch } from \"./faq-section-search\"\n\ntype FaqSectionVariant = \"accordion\" | \"split\" | \"search\"\n\ninterface FaqSectionProps extends FaqSectionCopyProps {\n  /** `accordion` a short list on one plate, `split` a longer list beside a heading that stays in view, `search` a filter box for a list too long to scan. Anything else is `accordion`. */\n  variant?: FaqSectionVariant\n}\n\nfunction FaqSectionAccordion({\n  headline = DEFAULT_COPY.headline,\n  headlineQuiet = DEFAULT_COPY.headlineQuiet,\n  items = DEFAULT_ITEMS,\n  contact = DEFAULT_CONTACT,\n  className,\n  ...props\n}: FaqSectionCopyProps) {\n  return (\n    <section data-slot=\"faq-section\" data-variant=\"accordion\" className={cn(ROOT_CLASS, \"bg-muted dark:bg-background\", className)} {...props}>\n      <div className=\"mx-auto flex w-full max-w-2xl flex-col gap-8 px-4 py-12 @2xl:py-16\">\n        <FaqHeading headline={headline} quiet={headlineQuiet} className=\"@2xl:text-center\" />\n        <FaqList items={items} variant=\"card\" defaultOpen={items[0]?.id} className=\"rounded-2xl bg-background dark:bg-card\" triggerClassName=\"min-h-12 @xl:px-6\" panelClassName=\"@xl:px-6\" />\n        <FaqContactLine contact={contact} className=\"@2xl:text-center\" />\n      </div>\n    </section>\n  )\n}\n\nfunction FaqSectionSplit({\n  headline = DEFAULT_COPY.headline,\n  headlineQuiet = DEFAULT_COPY.headlineQuiet,\n  items = DEFAULT_ITEMS,\n  contact = DEFAULT_CONTACT,\n  className,\n  ...props\n}: FaqSectionCopyProps) {\n  return (\n    <section data-slot=\"faq-section\" data-variant=\"split\" className={cn(ROOT_CLASS, \"bg-background\", className)} {...props}>\n      <div className=\"mx-auto grid w-full max-w-6xl grid-cols-[minmax(0,1fr)] items-start gap-8 px-4 py-12 @2xl:px-8 @2xl:py-16 @4xl:grid-cols-[minmax(0,2fr)_minmax(0,3fr)] @4xl:gap-16\">\n        {/* Stays in view while a long list scrolls past, so the way to support is never far. */}\n        <div data-slot=\"faq-section-aside\" className=\"flex flex-col gap-6 @4xl:sticky @4xl:top-8\">\n          <FaqHeading headline={headline} quiet={headlineQuiet} className=\"text-3xl @2xl:text-3xl\" />\n          <FaqContactLine contact={contact} />\n        </div>\n        <FaqList items={items} variant=\"plain\" defaultOpen={items[0]?.id} className=\"min-w-0 border-t\" triggerClassName=\"min-h-12 py-4\" />\n      </div>\n    </section>\n  )\n}\n\nfunction FaqSection({ variant, ...props }: FaqSectionProps) {\n  switch (variant) {\n    case \"split\":\n      return <FaqSectionSplit {...props} />\n    case \"search\":\n      return <FaqSectionSearch {...props} />\n    default:\n      return <FaqSectionAccordion {...props} />\n  }\n}\n\nexport { FaqSection, type FaqContact, type FaqItem, type FaqSectionProps, type FaqSectionVariant }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/faq-section-parts.tsx",
      "content": "import type * as React from \"react\"\nimport { Accordion, AccordionContent, AccordionItem, AccordionTrigger, type AccordionVariant } from \"@/registry/miseui/ui/accordion\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport type { FaqItem } from \"./faq-section-filter\"\n\ninterface FaqContact {\n  /** Comes before the link, as a question. */\n  prompt: string\n  label: string\n  href: string\n}\n\ninterface FaqSectionCopyProps extends React.ComponentProps<\"section\"> {\n  headline?: string\n  /** Continues the headline in the same size, one tone quieter. */\n  headlineQuiet?: string\n  items?: readonly FaqItem[]\n  /** Where to go when the answer is not here. Null removes the line. */\n  contact?: FaqContact | null\n}\n\nconst DEFAULT_COPY = {\n  headline: \"Questions, answered.\",\n  headlineQuiet: \"The ones people ask before they invite it to a call.\",\n} as const\n\nconst DEFAULT_CONTACT: FaqContact = { prompt: \"Did not find it?\", label: \"Write to support\", href: \"#support\" }\n\nconst DEFAULT_ITEMS: readonly FaqItem[] = [\n  { id: \"join\", question: \"Does it join calls on its own?\", answer: \"Only when you invite it. It stays out of your calendar until you turn that on, and you can turn it on for one calendar at a time.\" },\n  { id: \"access\", question: \"Who can read a summary?\", answer: \"Everyone who was on the call, and anyone they share it with. Nobody else in your workspace sees it by default.\" },\n  { id: \"delete\", question: \"Can I delete a recording?\", answer: \"Yes, one at a time or all at once, from the call or from settings. The summary stays unless you delete that too.\", keywords: \"remove erase privacy\" },\n  { id: \"trial\", question: \"What happens when the trial ends?\", answer: \"Nothing is charged until you pick a plan. Your summaries stay readable, and new calls stop being recorded.\", keywords: \"free billing payment\" },\n  { id: \"export\", question: \"Can I take my data with me?\", answer: \"Export every summary as Markdown or PDF from settings, at any time and on any plan.\", keywords: \"download backup\" },\n  { id: \"languages\", question: \"Which languages does it understand?\", answer: \"It follows the language of the call and writes the summary in the same one. You can ask for a translation afterwards.\", keywords: \"translate korean\" },\n  { id: \"cancel\", question: \"How do I cancel?\", answer: \"From billing settings, with no call and no form. You keep access until the end of the period you paid for.\", keywords: \"refund stop subscription\" },\n]\n\n/** Not centred in a tall frame like the other sections: this one changes height as rows open and results filter, and the row or the box under the pointer would move with it. */\nconst ROOT_CLASS = \"@container flex w-full flex-col justify-start\"\n\n/** The bigger press area on touch comes from a pseudo element, because this link sits inside a sentence. */\nconst CONTACT_LINK_CLASS =\n  \"relative rounded-sm font-medium text-foreground underline underline-offset-4 outline-none hover:text-foreground/70 focus-visible:ring-[3px] focus-visible:ring-ring/50 pointer-coarse:after:absolute pointer-coarse:after:-inset-x-2 pointer-coarse:after:-inset-y-2.5\"\n\nfunction FaqHeading({ headline, quiet, className }: { headline: string; quiet: string; className?: string }) {\n  return (\n    <h2 className={cn(\"text-title text-3xl text-balance @2xl:text-4xl\", className)}>\n      {headline} <span className=\"text-muted-foreground\">{quiet}</span>\n    </h2>\n  )\n}\n\nfunction FaqContactLine({ contact, className }: { contact: FaqContact | null; className?: string }) {\n  if (!contact) return null\n  return (\n    <p className={cn(\"text-sm leading-5 text-muted-foreground\", className)}>\n      {contact.prompt}{\" \"}\n      <a href={contact.href} className={CONTACT_LINK_CLASS}>\n        {contact.label}\n      </a>\n    </p>\n  )\n}\n\ninterface FaqListProps {\n  items: readonly FaqItem[]\n  variant: AccordionVariant\n  /** The question open at first. Showing one answer teaches the row is pressable and how long answers are. */\n  defaultOpen?: string\n  className?: string\n  itemClassName?: string\n  triggerClassName?: string\n  panelClassName?: string\n}\n\nfunction FaqList({ items, variant, defaultOpen, className, itemClassName, triggerClassName, panelClassName }: FaqListProps) {\n  if (items.length === 0) return null\n  return (\n    <Accordion variant={variant} defaultValue={defaultOpen} className={className}>\n      {items.map((item) => (\n        <AccordionItem key={item.id} value={item.id} className={itemClassName}>\n          <AccordionTrigger className={cn(\"min-w-0 text-[15px] leading-snug\", triggerClassName)}>{item.question}</AccordionTrigger>\n          <AccordionContent className={cn(\"text-[15px]/relaxed text-pretty\", panelClassName)}>{item.answer}</AccordionContent>\n        </AccordionItem>\n      ))}\n    </Accordion>\n  )\n}\n\nexport { DEFAULT_CONTACT, DEFAULT_COPY, DEFAULT_ITEMS, FaqContactLine, FaqHeading, FaqList, ROOT_CLASS, type FaqContact, type FaqSectionCopyProps }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/faq-section-search.tsx",
      "content": "import { useRef, useState } from \"react\"\nimport { SearchX } from \"lucide-react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { Button } from \"@/registry/miseui/ui/button\"\nimport { Empty } from \"@/registry/miseui/ui/empty\"\nimport { SearchField } from \"@/registry/miseui/ui/search-field\"\nimport { faqCountLabel, filterFaq } from \"./faq-section-filter\"\nimport { DEFAULT_CONTACT, DEFAULT_COPY, DEFAULT_ITEMS, FaqContactLine, FaqHeading, FaqList, ROOT_CLASS, type FaqContact, type FaqSectionCopyProps } from \"./faq-section-parts\"\n\nfunction NoMatches({ query, contact, onClear }: { query: string; contact: FaqContact | null; onClear: () => void }) {\n  return (\n    <Empty\n      variant=\"dashed\"\n      icon={<SearchX />}\n      title={`No answer for “${query.trim()}”`}\n      description=\"Try a shorter word, or ask us directly.\"\n      className=\"[overflow-wrap:anywhere]\"\n      actions={\n        <>\n          <Button variant=\"outline\" onClick={onClear} className=\"pointer-coarse:h-10\">\n            Clear search\n          </Button>\n          {contact ? (\n            <Button asChild variant=\"ghost\" className=\"pointer-coarse:h-10\">\n              <a href={contact.href}>{contact.label}</a>\n            </Button>\n          ) : null}\n        </>\n      }\n    />\n  )\n}\n\nfunction FaqSectionSearch({\n  headline = DEFAULT_COPY.headline,\n  headlineQuiet = DEFAULT_COPY.headlineQuiet,\n  items = DEFAULT_ITEMS,\n  contact = DEFAULT_CONTACT,\n  className,\n  ...props\n}: FaqSectionCopyProps) {\n  const [query, setQuery] = useState(\"\")\n  const fieldRef = useRef<HTMLInputElement>(null)\n  const matches = filterFaq(items, query)\n  const clear = () => {\n    setQuery(\"\")\n    // The pressed button goes away with the empty state, and focus would fall back to the top of the page with it.\n    fieldRef.current?.focus()\n  }\n  return (\n    <section data-slot=\"faq-section\" data-variant=\"search\" className={cn(ROOT_CLASS, \"bg-muted dark:bg-background\", className)} {...props}>\n      <div className=\"mx-auto flex w-full max-w-2xl flex-col gap-8 px-4 py-12 @2xl:py-16\">\n        <FaqHeading headline={headline} quiet={headlineQuiet} />\n        {items.length > 0 ? (\n          <div className=\"flex flex-col gap-4\">\n            <SearchField ref={fieldRef} variant=\"large\" placeholder=\"Search questions\" value={query} onValueChange={setQuery} />\n            {/* Stays mounted through every result count, so a screen reader hears each change. */}\n            <p role=\"status\" className=\"text-[13px] leading-5 text-muted-foreground tabular-nums\">\n              {faqCountLabel(matches.length, items.length)}\n            </p>\n            {matches.length > 0 ? (\n              <>\n                <FaqList\n                  items={matches}\n                  variant=\"separated\"\n                  className=\"min-w-0\"\n                  itemClassName=\"rounded-2xl bg-background dark:bg-card\"\n                  triggerClassName=\"min-h-12 rounded-2xl\"\n                />\n                <FaqContactLine contact={contact} className=\"mt-2\" />\n              </>\n            ) : (\n              <NoMatches query={query} contact={contact} onClear={clear} />\n            )}\n          </div>\n        ) : null}\n      </div>\n    </section>\n  )\n}\n\nexport { FaqSectionSearch }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/faq-section-filter.ts",
      "content": "import type * as React from \"react\"\n\ninterface FaqItem {\n  id: string\n  question: string\n  answer: React.ReactNode\n  /** Extra words to match on `search`, such as \"refund\" on a question about cancelling. Needed when `answer` is not plain text. */\n  keywords?: string\n}\n\nfunction searchableText(item: FaqItem) {\n  const answer = typeof item.answer === \"string\" ? item.answer : \"\"\n  return `${item.question} ${answer} ${item.keywords ?? \"\"}`.toLocaleLowerCase()\n}\n\n/** Every word has to appear somewhere, in any order: people type \"cancel refund\", not the wording of the question. */\nfunction filterFaq(items: readonly FaqItem[], query: string): readonly FaqItem[] {\n  const words = query.trim().toLocaleLowerCase().split(/\\s+/).filter(Boolean)\n  if (words.length === 0) return items\n  return items.filter((item) => {\n    const text = searchableText(item)\n    return words.every((word) => text.includes(word))\n  })\n}\n\nfunction faqCountLabel(shown: number, total: number) {\n  const noun = total === 1 ? \"question\" : \"questions\"\n  return shown === total ? `${total} ${noun}` : `${shown} of ${total} ${noun}`\n}\n\nexport { faqCountLabel, filterFaq, type FaqItem }\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "blocks"
  ],
  "type": "registry:block"
}