{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "aspect-ratio",
  "title": "AspectRatio",
  "description": "A frame that keeps an image, video or map at a fixed shape while its width follows the layout, so the page does not jump when the media loads.",
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/aspect-ratio/aspect-ratio.tsx",
      "content": "\"use client\";\n\nimport type { HTMLAttributes, JSX, ReactNode, Ref } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** The props AspectRatio adds to the HTML attributes it passes through. */\nexport interface AspectRatioOwnProps {\n  /**\n   * Width divided by height, as a number: `16 / 9` for video, `4 / 3` for a photo, `1` for\n   * a square. The frame is as wide as its container and this much shorter.\n   */\n  ratio: number | (string & { \"Use a number: ratio={16 / 9}\": never });\n  /**\n   * How an image or video fills the frame: `cover` crops it to fill, `contain` shows all of\n   * it with bars.\n   * @default \"cover\"\n   * @claim \"How an image or video fills\" registry/ouro/components/ouro/aspect-ratio/aspect-ratio.test.tsx verify:testExists(registry/ouro/components/ouro/aspect-ratio/aspect-ratio.test.tsx::AspectRatio > fills the frame with its media, cropped to cover)\n   * @claim \"How an image or video fills\" registry/ouro/components/ouro/aspect-ratio/aspect-ratio.test.tsx verify:testExists(registry/ouro/components/ouro/aspect-ratio/aspect-ratio.test.tsx::AspectRatio > letterboxes with fit=contain)\n   */\n  fit?: \"cover\" | \"contain\" | (string & { 'Use \"cover\" or \"contain\"': never }) | undefined;\n  /**\n   * The media: one `<img>`, `<video>`, `<iframe>` or element, which fills the frame. Give an\n   * image `alt` text, or `alt=\"\"` when it is decoration.\n   */\n  children: ReactNode;\n  /**\n   * Layout only: width, margins, grid placement (`w-40`). Appearance classes warn in\n   * development; put the frame in a `Card` for rounded corners.\n   */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. Ouro UI uses `ratio`: `<AspectRatio ratio={16 / 9}>`. */\n  aspectRatio?: { \"Use <AspectRatio ratio={16 / 9}>\": never };\n}\n\n/** Props for {@link AspectRatio}: its own props and the div attributes it passes through. */\nexport type AspectRatioProps = Omit<HTMLAttributes<HTMLDivElement>, keyof AspectRatioOwnProps> & AspectRatioOwnProps;\n\nconst fits = { cover: \"*:object-cover\", contain: \"*:object-contain\" } as const;\n\n/** `\"16:9\"` or `\"16/9\"` to `16 / 9`, for the fix; anything else to the video ratio. */\nfunction ratioFix(ratio: string): string {\n  const match = /^\\s*(\\d+(?:\\.\\d+)?)\\s*[:/x]\\s*(\\d+(?:\\.\\d+)?)\\s*$/.exec(ratio);\n  return match ? `${match[1]} / ${match[2]}` : \"16 / 9\";\n}\n\n/**\n * A frame that keeps an image, video or map at a fixed shape while its width follows the\n * layout, so the page does not jump when the media loads. The media fills it and is\n * cropped to fit.\n *\n * Use `Card` with `media` instead for a photo at the top of a card (put the AspectRatio in\n * `media`), and `Item` with `media` for a thumbnail beside a row's title.\n *\n * @group Layout\n * @see https://ui.ouroboros.bot/docs/aspect-ratio\n *\n * @example\n * <AspectRatio ratio={16 / 9}>\n *   <img src={recipe.coverUrl} alt={recipe.title} />\n * </AspectRatio>\n */\nexport function AspectRatio(props: AspectRatioProps): JSX.Element {\n  const { ratio: ratioProp, fit: fitProp = \"cover\", children, className, style, aspectRatio, ...rest } = props;\n  const valid = typeof ratioProp === \"number\" && ratioProp > 0 && Number.isFinite(ratioProp);\n  const ratio = valid ? ratioProp : 1;\n  const fit = Object.hasOwn(fits, fitProp) ? (fitProp as keyof typeof fits) : \"cover\";\n  useAppearanceClassNameCheck(\n    \"AspectRatio\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? \"put the AspectRatio in a <Card media={…}>, which rounds it, or wrap it in an element of your own\"\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"AspectRatio\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !valid &&\n            (typeof ratioProp === \"string\"\n              ? [`ratio=\"${ratioProp}\" is not a number`, `<AspectRatio ratio={${ratioFix(ratioProp)}}>`]\n              : [`ratio={${String(ratioProp)}} is not a positive number`, \"<AspectRatio ratio={16 / 9}>\"]),\n          fit !== fitProp && [`fit=\"${String(fitProp)}\" is not a fit; use \"cover\", \"contain\"`, '<AspectRatio fit=\"cover\">'],\n          aspectRatio !== undefined && [\"aspectRatio is not a prop\", `<AspectRatio ratio={${String(aspectRatio)}}>`],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  return (\n    <div\n      {...rest}\n      data-ouro=\"aspect-ratio\"\n      style={{ ...style, aspectRatio: ratio }}\n      className={cn(\"relative w-full overflow-hidden *:absolute *:inset-0 *:size-full\", fits[fit], className)}\n    >\n      {children}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/aspect-ratio/aspect-ratio.tsx"
    }
  ],
  "docs": "A frame that keeps an image, video or map at a fixed shape while its width follows the layout, so the page does not jump when the media loads. Import: import { AspectRatio } from \"@/components/ouro/aspect-ratio/aspect-ratio\", 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/aspect-ratio.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}