{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popover",
  "title": "Popover",
  "description": "Accessible popover with focus restoration and outside dismissal.",
  "dependencies": [
    "solid-js@^1.9.15",
    "@kobalte/core@https://github.com/jhomra21/kobalte/releases/download/kobalte-solid1-audiocn-e0e3bf095f05c7e61230a251b79181c6d834d408/kobalte-core-0.13.14-audiocn.0.e0e3bf09.tgz"
  ],
  "registryDependencies": [
    "@audiocn-solid/core",
    "@audiocn-solid/button"
  ],
  "files": [
    {
      "path": "components/ui/popover.tsx",
      "content": "import * as PopoverPrimitive from \"@kobalte/core/popover\";\nimport type {\n  PopoverContentOptions,\n  PopoverContentCommonProps,\n  PopoverRootProps,\n} from \"@kobalte/core/popover\";\n\nimport { Button } from \"@/components/ui/button\";\nimport type { ButtonProps } from \"@/components/ui/button\";\nimport { createCompatEffect } from \"@/lib/solid/effect\";\nimport type {\n  DivDOMProps,\n  HeadingDOMProps,\n  ParagraphDOMProps,\n} from \"@/lib/solid/jsx-types\";\nimport { omitProps } from \"@/lib/solid/props\";\nimport { setRefValue } from \"@/lib/solid/ref\";\nimport { cn } from \"@/lib/utils\";\n\n/** Kobalte owns placement on the root: use `placement`, `gutter`, and `shift`. */\nexport const Popover = (props: PopoverRootProps) => (\n  <PopoverPrimitive.Root {...props} />\n);\n\nexport interface PopoverTriggerClickEvent extends MouseEvent {\n  preventBaseUIHandler: () => void;\n  readonly baseUIHandlerPrevented: boolean;\n}\n\nexport const PopoverTrigger = (\n  props: Omit<ButtonProps, \"onClick\"> & {\n    onClick?: (event: PopoverTriggerClickEvent) => void;\n  }\n) => {\n  const context = PopoverPrimitive.usePopoverContext();\n  const rest = omitProps(props, [\"ref\", \"onClick\"]);\n\n  // Kobalte's trigger cancels pointerdown, suppressing native touch clicks in\n  // WebKit. Keep native button activation; Kobalte still owns open state/focus.\n  return (\n    <Button\n      aria-haspopup=\"dialog\"\n      aria-expanded={context.isOpen() ? \"true\" : \"false\"}\n      aria-controls={context.isOpen() ? context.contentId() : undefined}\n      data-slot=\"popover-trigger\"\n      {...context.dataset()}\n      {...rest}\n      ref={(node) => {\n        if (node) context.setTriggerRef(node);\n        setRefValue(props.ref, node);\n      }}\n      onClick={(event) => {\n        let prevented = false;\n        // SAFETY: these additions are installed before calling the consumer.\n        const baseEvent = event as PopoverTriggerClickEvent;\n        Object.defineProperties(baseEvent, {\n          baseUIHandlerPrevented: { configurable: true, get: () => prevented },\n          preventBaseUIHandler: {\n            configurable: true,\n            value: () => {\n              prevented = true;\n            },\n          },\n        });\n        props.onClick?.(baseEvent);\n\n        if (!prevented) context.toggle();\n      }}\n    />\n  );\n};\n\nexport interface PopoverContentProps\n  extends Omit<DivDOMProps, \"id\" | \"style\">, PopoverContentOptions {\n  id?: string;\n  style?: PopoverContentCommonProps[\"style\"];\n  className?: string;\n}\n\nexport const PopoverContent = (props: PopoverContentProps) => {\n  const context = PopoverPrimitive.usePopoverContext();\n  const rest = omitProps(props, [\"class\", \"className\", \"onEscapeKeyDown\"]);\n  let restoreAfterEscape = false;\n\n  createCompatEffect(\n    () => context.isOpen(),\n    (open) => {\n      if (open || !restoreAfterEscape) return;\n      restoreAfterEscape = false;\n      const trigger = context.triggerRef();\n      queueMicrotask(() => {\n        if (!context.isOpen()) trigger?.focus({ preventScroll: true });\n      });\n    }\n  );\n\n  const escape = (event: KeyboardEvent) => {\n    props.onEscapeKeyDown?.(event);\n\n    if (event.defaultPrevented) return;\n    // Kobalte 2 alpha restores focus only for modal traps. Use its public\n    // trigger accessor after Escape dismissal without replacing any callbacks.\n    restoreAfterEscape = true;\n  };\n\n  return (\n    <PopoverPrimitive.Portal>\n      <PopoverPrimitive.Content\n        data-slot=\"popover-content\"\n        class={cn(\n          \"bg-popover text-popover-foreground ring-foreground/5 dark:ring-foreground/10 data-expanded:animate-in data-expanded:fade-in-0 data-expanded:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 flex w-72 origin-(--kb-popover-content-transform-origin) flex-col gap-4 rounded-3xl p-4 text-sm shadow-lg ring-1 outline-hidden duration-100\",\n          props.class,\n          props.className\n        )}\n        {...rest}\n        onEscapeKeyDown={escape}\n      />\n    </PopoverPrimitive.Portal>\n  );\n};\n\nexport const PopoverHeader = (props: DivDOMProps & { className?: string }) => (\n  <div\n    data-slot=\"popover-header\"\n    {...omitProps(props, [\"class\", \"className\"])}\n    class={cn(\"flex flex-col gap-1 text-sm\", props.class, props.className)}\n  />\n);\n\nexport const PopoverTitle = (\n  props: Omit<HeadingDOMProps, \"id\"> & { id?: string; className?: string }\n) => (\n  <PopoverPrimitive.Title\n    data-slot=\"popover-title\"\n    {...omitProps(props, [\"class\", \"className\"])}\n    class={cn(\"text-base font-medium\", props.class, props.className)}\n  />\n);\n\nexport const PopoverDescription = (\n  props: Omit<ParagraphDOMProps, \"id\"> & { id?: string; className?: string }\n) => (\n  <PopoverPrimitive.Description\n    data-slot=\"popover-description\"\n    {...omitProps(props, [\"class\", \"className\"])}\n    class={cn(\"text-muted-foreground\", props.class, props.className)}\n  />\n);\n",
      "type": "registry:ui"
    },
    {
      "path": "lib/audiocn-license.txt",
      "content": "Audio component source adapted from https://github.com/audiocn/ui.\nMIT License — Copyright (c) 2026 OrcDev\n\nRegular SVG icon geometry adapted from @phosphor-icons/react 2.1.10.\nMIT License — Copyright (c) 2020 Phosphor Icons\n\nThe following permission and warranty terms apply to both notices.\nRetain this file with copies or substantial portions of the source.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
      "type": "registry:file",
      "target": "@lib/audiocn-license.txt"
    }
  ],
  "type": "registry:ui"
}
