{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "accordion",
  "title": "Accordion",
  "description": "A stack of titles that each open their own content, for FAQs and long settings pages.",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-css-panel",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/accordion/accordion-styles.ts",
      "content": "export { headerClass, headingLevels, iconClass, itemClass, ownLook, panelContentClass, rootClass, triggerClass };\nexport type { AccordionHeadingLevel };\n\n// Class strings and value lists for Accordion, apart from the component so its file exports\n// only components (React Fast Refresh). Class strings are literal so the app's Tailwind finds\n// them when it compiles.\n\n/**\n * The heading levels an item's title can take.\n *\n * @internal\n */\nconst headingLevels = [2, 3, 4, 5, 6] as const;\n\n/**\n * The outline level of each item's title: `<h2>` to `<h6>`.\n *\n * @claim \"The outline level of each item's\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > sets the heading level with headingLevel)\n * @claim \"The outline level of each item's\" registry/ouro/components/ouro/accordion/accordion.test-d.ts verify:fileLine(registry/ouro/components/ouro/accordion/accordion.test-d.ts, /\\{\\sitems:\\sItems;\\sheadingLevel:\\s1\\s\\}>\\(\\)\\.not\\.toExtend<AccordionProps>/)\n */\ntype AccordionHeadingLevel = (typeof headingLevels)[number];\n\n/**\n * The `Fix:` for an appearance class: the accordion draws its own look.\n *\n * @internal\n */\nfunction ownLook(component: string): (token: string) => string {\n  return (token) => `remove \"${token}\"; ${component} sets its own look`;\n}\n\n/** @internal */\nconst rootClass = \"box-border w-full min-w-0 text-foreground\";\n\n/**\n * An item: a hairline under each one.\n *\n * @internal\n * @claim \"An item: a hairline under each\" registry/ouro/components/ouro/accordion/accordion-styles.ts verify:fileLine(registry/ouro/components/ouro/accordion/accordion-styles.ts, /const\\sitemClass\\s=\\s\"border-0\\sborder-b\\sborder-solid\\sborder-border\"/)\n */\nconst itemClass = \"border-0 border-b border-solid border-border\";\n\n/** @internal */\nconst headerClass = \"m-0 p-0 text-base font-medium\";\n\n/**\n * The title button: the whole row, at least 44px tall on a coarse pointer and 40px with a\n * fine one. A full-width row does not scale when pressed; it dims instead.\n *\n * @internal\n * @claim \"The title button: the whole row\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > gives every trigger at least a 44px row on a coarse pointer, or 40px otherwise)\n */\nconst triggerClass =\n  \"group/trigger press relative m-0 box-border flex w-full cursor-pointer items-center justify-between gap-4 \" +\n  \"min-h-11 sm:pointer-fine:min-h-10 px-0 py-3 rounded-ouro-md border-0 bg-transparent text-start \" +\n  \"font-[inherit] text-base font-medium text-foreground sm:pointer-fine:text-sm \" +\n  \"select-none touch-manipulation [-webkit-tap-highlight-color:transparent] \" +\n  \"underline-offset-4 not-data-disabled:pointer-fine:hover:underline not-data-disabled:active:opacity-70 \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid \" +\n  \"data-disabled:cursor-not-allowed data-disabled:opacity-50\";\n\n/**\n * The chevron: it turns over while the item is open.\n *\n * @internal\n */\nconst iconClass =\n  \"size-4 shrink-0 text-muted-foreground transition-[rotate] duration-(--ouro-duration-base) ease-(--ouro-ease-out) \" +\n  \"group-data-panel-open/trigger:rotate-180 motion-reduce:transition-none\";\n\n/** @internal */\nconst panelContentClass = \"pb-4 text-base sm:pointer-fine:text-sm\";\n",
      "type": "registry:ui",
      "target": "@components/ouro/accordion/accordion-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/accordion/accordion.tsx",
      "content": "\"use client\";\n\nimport { Accordion as BaseAccordion } from \"@base-ui/react/accordion\";\nimport { useId, useRef, type JSX, type ReactNode, type Ref } from \"react\";\nimport { CssPanel } from \"@/registry/ouro/lib/ouro/css-panel\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport {\n  headerClass,\n  headingLevels,\n  iconClass,\n  itemClass,\n  ownLook,\n  panelContentClass,\n  rootClass,\n  triggerClass,\n  type AccordionHeadingLevel,\n} from \"@/registry/ouro/components/ouro/accordion/accordion-styles\";\n\nexport type { AccordionHeadingLevel } from \"@/registry/ouro/components/ouro/accordion/accordion-styles\";\n\n/** One item: a title that opens and closes its content. */\nexport interface AccordionItem {\n  /**\n   * Identifies the item: `value`, `defaultValue` and `onValueChange` use it. Unique within the\n   * accordion. @default the item's index, as a string (\"0\", \"1\", …)\n   */\n  value?: string | undefined;\n  /**\n   * The title, always visible. It is the button that opens the item, inside a heading.\n   *\n   * @claim \"The title, always visible\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > renders each title as a button inside an h3, all closed)\n   */\n  title: ReactNode;\n  /** What shows while the item is open. */\n  content: ReactNode;\n  /** Shows the item but keeps it from opening or closing. */\n  disabled?: boolean | undefined;\n}\n\n/**\n * Props every Accordion takes.\n *\n * @claim \"Props every Accordion takes\" registry/ouro/components/ouro/accordion/accordion.tsx verify:fileLine(registry/ouro/components/ouro/accordion/accordion.tsx, /export function Accordion\\(props: AccordionProps\\)/)\n */\nexport interface AccordionBaseProps {\n  /** The items, in order. */\n  items: readonly AccordionItem[];\n  /**\n   * The outline level of each title, so the items sit in the page's heading structure:\n   * `headingLevel={2}` renders `<h2>`. @default 3\n   * @claim \"The outline level of each title\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > sets the heading level with headingLevel)\n   * @claim \"The outline level of each title\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > renders each title as a button inside an h3, all closed)\n   */\n  headingLevel?: AccordionHeadingLevel | (number & { 'Use 2, 3, 4, 5 or 6': never }) | undefined;\n  /**\n   * Keeps every item from opening or closing.\n   *\n   * @claim \"Keeps every item from opening or\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > keeps every item from opening or closing when disabled)\n   * @claim \"Keeps every item from opening or\" https://base-ui.com/react/components/accordion verify:urlOk(https://base-ui.com/react/components/accordion)\n   */\n  disabled?: boolean | undefined;\n  /** Layout only: margins, width, grid placement (`mt-6`). Appearance classes warn in development. */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. One item opens at a time by default; for several, pass `multiple`: `<Accordion multiple>`. */\n  type?: { 'Use <Accordion multiple> for several open items; one at a time is the default': never };\n  /**\n   * Not a prop. An open item always closes when its title is pressed again.\n   *\n   * @claim \"An open item always closes when\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > opens one item at a time by default, and closes the open one when pressed again)\n   */\n  collapsible?: { 'Remove it: an open item always closes when pressed': never };\n  /** Not a prop. Ouro UI uses `onValueChange`: `<Accordion onValueChange={(value) => …}>`. */\n  onChange?: { 'Use <Accordion onValueChange={(value) => ...}>': never };\n}\n\n/**\n * One item open at a time (the default). The value is the open item's, or `null` when all are closed.\n *\n * @claim \"The value is the open item's\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > closes every item with a controlled null)\n */\nexport type AccordionSingleProps = AccordionBaseProps & {\n  /** Lets several items be open at once, and makes the value a list. */\n  multiple?: false | undefined;\n  /**\n   * The open item's value, or `null` for none, when you control it. Pair it with `onValueChange`.\n   *\n   * @claim \"The open item's value, or `null`\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > follows a controlled value)\n   */\n  value?: string | null | undefined;\n  /** The item open first, when the component keeps its own state. @default none */\n  defaultValue?: string | null | undefined;\n  /** Called with the open item's value, or `null` when the person closes it. */\n  onValueChange?: ((value: string | null) => void) | undefined;\n};\n\n/** Several items open at once. The value is the list of open items. */\nexport type AccordionMultipleProps = AccordionBaseProps & {\n  /** Lets several items be open at once, and makes the value a list. */\n  multiple: true;\n  /** The open items' values, when you control them. Pair it with `onValueChange`. */\n  value?: readonly string[] | undefined;\n  /** The items open first, when the component keeps its own state. @default [] */\n  defaultValue?: readonly string[] | undefined;\n  /** Called with the open items' values whenever one opens or closes. */\n  onValueChange?: ((value: string[]) => void) | undefined;\n};\n\n/** Props for {@link Accordion}. `multiple` switches the value from one string to a list. */\nexport type AccordionProps = AccordionSingleProps | AccordionMultipleProps;\n\n/** A value in either mode, as Base UI's list. */\nfunction toList(value: string | null | readonly string[] | undefined): string[] | undefined {\n  if (value === undefined) return undefined;\n  if (value === null) return [];\n  return typeof value === \"string\" ? [value] : [...value];\n}\n\n/** One item's title and panel. The panel is Ouro's own CSS panel. */\nfunction Row({ item, Heading, open }: { item: AccordionItem; Heading: `h${AccordionHeadingLevel}`; open: boolean }): JSX.Element {\n  const triggerId = useId();\n  const panelId = useId();\n  const triggerRef = useRef<HTMLButtonElement>(null);\n  return (\n    <>\n      <BaseAccordion.Header render={<Heading />} className={headerClass}>\n        <BaseAccordion.Trigger\n          ref={triggerRef}\n          id={triggerId}\n          aria-controls={open ? panelId : undefined}\n          data-ouro-control=\"accordion\"\n          data-ouro-part=\"trigger\"\n          className={triggerClass}\n        >\n          {item.title}\n          <Chevron />\n        </BaseAccordion.Trigger>\n      </BaseAccordion.Header>\n      <CssPanel\n        id={panelId}\n        role=\"region\"\n        aria-labelledby={triggerId}\n        open={open}\n        // Stryker disable next-line OptionalChaining: the trigger is mounted whenever its panel can be found.\n        onFound={() => triggerRef.current?.click()}\n        contentClassName={panelContentClass}\n      >\n        {item.content}\n      </CssPanel>\n    </>\n  );\n}\n\nfunction Chevron(): JSX.Element {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 16 16\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"1.5\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      className={iconClass}\n    >\n      <path d=\"m4 6 4 4 4-4\" />\n    </svg>\n  );\n}\n\n/**\n * A stack of titles that each open their own content, for FAQs and long settings pages. One\n * item opens at a time unless you pass `multiple`. Panels grow to their content height with\n * CSS, titles sit inside headings, closed content is in the server HTML and found by the\n * page search of browsers that support `hidden=\"until-found\"`, and rows are 44px tall on touch screens.\n *\n * Use `Collapsible` instead for a single section that opens and closes. Use `Tabs` instead\n * when exactly one section always shows and the titles fit in a row.\n *\n * @group Lists\n * @see https://ui.ouroboros.bot/docs/accordion\n *\n * @example\n * <Accordion\n *   items={[\n *     { value: \"storage\", title: \"How long does it keep?\", content: \"Three days in the fridge.\" },\n *     { value: \"freeze\", title: \"Can I freeze it?\", content: \"Yes, for up to a month.\" },\n *   ]}\n * />\n * <Accordion multiple defaultValue={[\"storage\"]} items={items} />\n * @claim \"Panels grow to their content height\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > lets the browser's page search find and open a closed item, and hides it plainly where until-found is unsupported)\n * @claim \"Panels grow to their content height\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > animates the panel to its measured height)\n * @claim \"Panels grow to their content height\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > gives every trigger at least a 44px row on a coarse pointer, or 40px otherwise)\n * @claim \"Panels grow to their content height\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > links each trigger and panel in server HTML and hydrates without a mismatch)\n * @claim \"A stack of titles that each\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > opens one item at a time by default, and closes the open one when pressed again)\n * @claim \"A stack of titles that each\" registry/ouro/components/ouro/accordion/accordion.test.tsx verify:testExists(registry/ouro/components/ouro/accordion/accordion.test.tsx::Accordion > keeps several items open with multiple)\n */\nexport function Accordion(props: AccordionProps): JSX.Element {\n  const {\n    items,\n    multiple,\n    value,\n    defaultValue,\n    onValueChange,\n    headingLevel: levelProp = 3,\n    disabled,\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    type,\n    collapsible,\n    onChange,\n  } = props;\n  // A level that is not one of Ouro UI's (a type error) warns and renders h3.\n  const level = headingLevels.includes(levelProp as AccordionHeadingLevel) ? (levelProp as AccordionHeadingLevel) : 3;\n  const values = items.map((item, index) => item.value ?? String(index));\n  const duplicate = values.find((candidate, index) => values.indexOf(candidate) !== index);\n  if (duplicate !== undefined) {\n    // Two items with one value would open and close together.\n    devThrow(\n      \"Accordion\",\n      `two items have the value \"${duplicate}\"`,\n      process.env.NODE_ENV !== \"production\" ? \"give each item its own value\" : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n  useAppearanceClassNameCheck(\n    \"Accordion\",\n    className,\n    process.env.NODE_ENV !== \"production\" ? ownLook(\"Accordion\") : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Accordion\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => {\n          const typeValue = type as unknown;\n          return [\n            typeValue !== undefined && [\n              `type=\"${String(typeValue)}\" is not a prop`,\n              typeValue === \"multiple\" ? \"<Accordion multiple>\" : \"<Accordion> (one item opens at a time by default)\",\n            ],\n            collapsible !== undefined && [\"collapsible is not a prop; an open item always closes when pressed\", \"<Accordion>\"],\n            onChange !== undefined && [\"onChange is not a prop\", \"<Accordion onValueChange={(value) => …}>\"],\n            level !== levelProp && [\n              `headingLevel={${String(levelProp)}} is not a heading level; use ${headingLevels.join(\", \")}`,\n              \"<Accordion headingLevel={3}>\",\n            ],\n            multiple === true &&\n              typeof defaultValue === \"string\" && [\n                \"with multiple, defaultValue is a list\",\n                `<Accordion multiple defaultValue={[\"${defaultValue}\"]}>`,\n              ],\n            multiple !== true &&\n              Array.isArray(value) && [\"value is a list, which needs multiple\", `<Accordion multiple value={${JSON.stringify(value)}}>`],\n          ];\n        }\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  const Heading = `h${level}` as const;\n  return (\n    <BaseAccordion.Root\n      ref={ref}\n      multiple={multiple === true}\n      value={toList(value)}\n      defaultValue={toList(defaultValue)}\n      onValueChange={\n        onValueChange\n          ? (next: string[]) => {\n              if (multiple === true) (onValueChange as (value: string[]) => void)(next);\n              else (onValueChange as (value: string | null) => void)(next[0] ?? null);\n            }\n          : undefined\n      }\n      disabled={disabled}\n      data-ouro=\"accordion\"\n      className={cn(rootClass, className)}\n    >\n      {items.map((item, index) => (\n        <BaseAccordion.Item\n          key={values[index]}\n          value={values[index]}\n          disabled={item.disabled === true}\n          className={itemClass}\n          render={(props, state) => (\n            <div {...props}>\n              <Row item={item} Heading={Heading} open={state.open} />\n            </div>\n          )}\n        />\n      ))}\n    </BaseAccordion.Root>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/accordion/accordion.tsx"
    }
  ],
  "docs": "A stack of titles that each open their own content, for FAQs and long settings pages. Import: import { Accordion } from \"@/components/ouro/accordion/accordion\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: the helpers it imports in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/accordion.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}