{"name":"accordion","type":"registry:ui","files":[{"path":"accordion.tsx","type":"registry:ui","content":"\"use client\"\n\nimport { Accordion as AccordionPrimitive } from \"@base-ui-components/react/accordion\"\nimport { ChevronDown as ChevronDownIcon } from \"honestui/icons\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype AccordionValue = NonNullable<AccordionPrimitive.Root.Props[\"value\"]>\ntype AccordionChangeDetails = AccordionPrimitive.Root.ChangeEventDetails\n\ntype AccordionNativeProps = AccordionPrimitive.Root.Props & {\n  collapsible?: boolean\n  type?: undefined\n}\n\ntype AccordionSingleProps = Omit<\n  AccordionPrimitive.Root.Props,\n  \"defaultValue\" | \"multiple\" | \"onValueChange\" | \"value\"\n> & {\n  type: \"single\"\n  collapsible?: boolean\n  defaultValue?: string\n  multiple?: false\n  onValueChange?: (value: string, eventDetails: AccordionChangeDetails) => void\n  value?: string\n}\n\ntype AccordionMultipleProps = Omit<\n  AccordionPrimitive.Root.Props,\n  \"defaultValue\" | \"multiple\" | \"onValueChange\" | \"value\"\n> & {\n  type: \"multiple\"\n  collapsible?: boolean\n  defaultValue?: AccordionValue\n  multiple?: true\n  onValueChange?: AccordionPrimitive.Root.Props[\"onValueChange\"]\n  value?: AccordionValue\n}\n\ntype AccordionProps =\n  | AccordionNativeProps\n  | AccordionSingleProps\n  | AccordionMultipleProps\n\nfunction Accordion({\n  collapsible,\n  defaultValue,\n  multiple,\n  onValueChange,\n  type,\n  value,\n  ...props\n}: AccordionProps) {\n  const isSingle = type === \"single\"\n  const resolvedMultiple = type ? type === \"multiple\" : multiple\n  const normalizedDefaultValue: AccordionValue | undefined =\n    isSingle && typeof defaultValue === \"string\"\n      ? [defaultValue]\n      : Array.isArray(defaultValue)\n        ? defaultValue\n        : undefined\n  const normalizedValue: AccordionValue | undefined =\n    isSingle && typeof value === \"string\"\n      ? [value]\n      : Array.isArray(value)\n        ? value\n        : undefined\n\n  return (\n    <AccordionPrimitive.Root\n      data-slot=\"accordion\"\n      defaultValue={normalizedDefaultValue}\n      multiple={resolvedMultiple}\n      onValueChange={(nextValue, eventDetails) => {\n        if (isSingle) {\n          if (!collapsible && nextValue.length === 0) {\n            eventDetails.cancel()\n            return\n          }\n\n          onValueChange?.(nextValue[0] ?? \"\", eventDetails)\n        } else {\n          onValueChange?.(nextValue, eventDetails)\n        }\n      }}\n      value={normalizedValue}\n      {...props}\n    />\n  )\n}\n\nfunction AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) {\n  return (\n    <AccordionPrimitive.Item\n      data-slot=\"accordion-item\"\n      className={cn(\"border-b last:border-b-0\", className)}\n      {...props}\n    />\n  )\n}\n\nfunction AccordionTrigger({\n  className,\n  children,\n  ...props\n}: AccordionPrimitive.Trigger.Props) {\n  return (\n    <AccordionPrimitive.Header className=\"flex\">\n      <AccordionPrimitive.Trigger\n        data-slot=\"accordion-trigger\"\n        className={cn(\n          \"flex flex-1 cursor-pointer items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none focus-visible:ring-[3px] focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-64 [&[data-panel-open]>svg]:rotate-180\",\n          className\n        )}\n        {...props}\n      >\n        {children}\n        <ChevronDownIcon className=\"pointer-events-none size-4 shrink-0 translate-y-0.5 opacity-72 transition-transform duration-200 ease-in-out\" />\n      </AccordionPrimitive.Trigger>\n    </AccordionPrimitive.Header>\n  )\n}\n\nfunction AccordionPanel({\n  className,\n  children,\n  ...props\n}: AccordionPrimitive.Panel.Props) {\n  return (\n    <AccordionPrimitive.Panel\n      data-slot=\"accordion-panel\"\n      className=\"h-(--accordion-panel-height) overflow-hidden text-sm text-muted-foreground transition-[height] duration-200 ease-in-out data-ending-style:h-0 data-starting-style:h-0\"\n      {...props}\n    >\n      <div className={cn(\"pt-0 pb-4\", className)}>{children}</div>\n    </AccordionPrimitive.Panel>\n  )\n}\n\nexport {\n  Accordion,\n  AccordionItem,\n  AccordionTrigger,\n  AccordionPanel,\n  AccordionPanel as AccordionContent,\n}\n","target":"components/ui/accordion.tsx"}],"dependencies":["@base-ui-components/react","honestui"]}