{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "primitives-base",
  "title": "Primitives (Base UI)",
  "description": "The second provider behind the ai2 primitive adapter: the same surface as @ai2/primitives, bound to Base UI instead of Radix. A pro block imports the adapter, not the library, so the same block source runs on either one. Anatomy differences are absorbed here (Base UI wraps the slider track in a Control part and calls the filled part Indicator, and it renders a native range input inside the thumb, so focus styling is mirrored from focus-visible to focus-within). Primitives with no Base UI counterpart are deliberately left out rather than silently falling back to Radix.",
  "dependencies": [
    "@base-ui/react@^1.6.0"
  ],
  "files": [
    {
      "path": "registry/ai2/ui/primitives-base.ts",
      "content": "\"use client\"\r\n\r\n/* ai2 primitive adapter - Base UI binding.\r\n\r\n   The Radix binding lives in `primitives.ts` and stays the default for the\r\n   free design system, because that keeps the consumer API shadcn compatible.\r\n   This file is the second provider: a pro block can be delivered against Base\r\n   UI instead, and the block source itself does not change. That promise is\r\n   only worth something if the shapes really match, so the differences are\r\n   absorbed here rather than in the blocks.\r\n\r\n   What differs from Radix, and how it is absorbed:\r\n   - Slider anatomy. Radix is Root > Track > Range, Thumb. Base UI puts an\r\n     interactive `Control` between Root and Track and calls the filled part\r\n     `Indicator`. The `Track` exported here renders Control > Track, so block\r\n     markup written for Radix keeps working, and `Range` aliases `Indicator`.\r\n   - `onValueChange` receives a second argument (event details) in Base UI. A\r\n     handler written for Radix ignores it, so no shim is needed.\r\n   - Composition. Radix uses `asChild`, Base UI uses a `render` prop. Nothing\r\n     in the block layer depends on it yet; when something does, the shim\r\n     belongs here and nowhere else.\r\n\r\n   Deliberately NOT re-exported: primitives Base UI has no counterpart for\r\n   (Slot, HoverCard, Label). Exporting a name that quietly fell back to Radix\r\n   would turn \"one block, two libraries\" into a lie, which is the exact\r\n   failure this adapter exists to prevent.\r\n\r\n   No JSX in this file on purpose: `registry/ai2/ui/*.tsx` is the audited\r\n   component surface (count gate R99), and this is a lib item, not a\r\n   component. The one wrapper below uses `createElement` to stay in `.ts`. */\r\n\r\nimport * as React from \"react\"\r\nimport { Accordion } from \"@base-ui/react/accordion\"\r\nimport { AlertDialog } from \"@base-ui/react/alert-dialog\"\r\nimport { Avatar } from \"@base-ui/react/avatar\"\r\nimport { Checkbox } from \"@base-ui/react/checkbox\"\r\nimport { Collapsible } from \"@base-ui/react/collapsible\"\r\nimport { ContextMenu } from \"@base-ui/react/context-menu\"\r\nimport { Dialog } from \"@base-ui/react/dialog\"\r\nimport { Menu } from \"@base-ui/react/menu\"\r\nimport { Menubar } from \"@base-ui/react/menubar\"\r\nimport { Popover } from \"@base-ui/react/popover\"\r\nimport { Progress } from \"@base-ui/react/progress\"\r\nimport { RadioGroup } from \"@base-ui/react/radio-group\"\r\nimport { ScrollArea } from \"@base-ui/react/scroll-area\"\r\nimport { Select } from \"@base-ui/react/select\"\r\nimport { Separator } from \"@base-ui/react/separator\"\r\nimport { Slider as BaseSlider } from \"@base-ui/react/slider\"\r\nimport { Switch } from \"@base-ui/react/switch\"\r\nimport { Tabs } from \"@base-ui/react/tabs\"\r\nimport { Toggle } from \"@base-ui/react/toggle\"\r\nimport { ToggleGroup } from \"@base-ui/react/toggle-group\"\r\nimport { Tooltip } from \"@base-ui/react/tooltip\"\r\n\r\ntype TrackProps = React.ComponentProps<typeof BaseSlider.Track>\r\n\r\n/* Radix has no Control part, so the wrapper supplies it. `contents` keeps the\r\n   extra element out of the layout: without it the block's track geometry\r\n   would change and the two libraries would not look identical. */\r\nconst SliderTrack = React.forwardRef<HTMLDivElement, TrackProps>(\r\n  function SliderTrack({ children, ...props }, ref) {\r\n    return React.createElement(\r\n      BaseSlider.Control,\r\n      { className: \"contents\" },\r\n      React.createElement(\r\n        BaseSlider.Track,\r\n        { ...props, ref } as TrackProps,\r\n        children\r\n      )\r\n    )\r\n  }\r\n)\r\n\r\n/* FOCUS PARITY - found by measurement, not by assumption.\r\n   The Radix thumb ITSELF carries `role=\"slider\"` and takes focus, so\r\n   `focus-visible:ring-*` works. Base UI instead puts a native\r\n   `input[type=range]` INSIDE the thumb (stronger a11y: aria-valuenow, min and\r\n   max live there) but focus lands on that input, so the `focus-visible:` class\r\n   on the wrapper NEVER matches and the block silently loses its focus ring on\r\n   Base UI.\r\n\r\n   Fix: for every `focus-visible:` utility the consumer writes we also emit its\r\n   `focus-within:` twin. `:focus-within` matches when the inner input is\r\n   focused, and `:focus-visible` already matches on Radix - together they give\r\n   the same ring on both libraries and the block source stays SINGLE. */\r\nfunction mirrorFocusVisible(className?: string): string | undefined {\r\n  if (!className) return className\r\n  const mirrored = className\r\n    .split(/\\s+/)\r\n    .filter((token) => token.includes(\"focus-visible:\"))\r\n    .map((token) => token.replaceAll(\"focus-visible:\", \"focus-within:\"))\r\n  return mirrored.length ? `${className} ${mirrored.join(\" \")}` : className\r\n}\r\n\r\ntype ThumbProps = React.ComponentProps<typeof BaseSlider.Thumb>\r\n\r\nconst SliderThumb = React.forwardRef<HTMLDivElement, ThumbProps>(\r\n  function SliderThumb({ className, ...props }, ref) {\r\n    return React.createElement(BaseSlider.Thumb, {\r\n      ...props,\r\n      ref,\r\n      className: mirrorFocusVisible(className as string | undefined),\r\n    } as ThumbProps)\r\n  }\r\n)\r\n\r\nexport const Slider = {\r\n  Root: BaseSlider.Root,\r\n  Track: SliderTrack,\r\n  /** Radix calls the filled part Range; Base UI calls it Indicator. */\r\n  Range: BaseSlider.Indicator,\r\n  Thumb: SliderThumb,\r\n  /** Base UI only; exposed because hiding a real capability is also a lie. */\r\n  Value: BaseSlider.Value,\r\n}\r\n\r\nexport {\r\n  Accordion,\r\n  AlertDialog,\r\n  Avatar,\r\n  Checkbox,\r\n  Collapsible,\r\n  ContextMenu,\r\n  Dialog,\r\n  /* Base UI ships a single Menu primitive; Radix splits it into DropdownMenu\r\n     and Menu. The alias keeps block code portable across both. */\r\n  Menu as DropdownMenu,\r\n  Menu,\r\n  Menubar,\r\n  Popover,\r\n  Progress,\r\n  RadioGroup,\r\n  ScrollArea,\r\n  Select,\r\n  Separator,\r\n  Switch,\r\n  Tabs,\r\n  Toggle,\r\n  ToggleGroup,\r\n  Tooltip,\r\n}\r\n",
      "type": "registry:lib"
    }
  ],
  "docs": "Install this instead of @ai2/primitives when you want the block to run on Base UI. Nothing else in the block changes.",
  "categories": [
    "utility"
  ],
  "type": "registry:lib"
}