{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "aspect-ratio",
  "title": "Aspect Ratio",
  "description": "Frames that hold their shape and reshape on a spring when the ratio changes, with photos that fade up out of a blur once they have loaded.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.9",
    "@ui-sdk/react@0.1.0-beta.9"
  ],
  "registryDependencies": [
    "@keyframery/motion"
  ],
  "files": [
    {
      "path": "registry/components/keyframery/core/aspect-ratio-core.ts",
      "content": "/* Aspect ratio, as a UI SDK primitive. UI SDK ships no aspect ratio, so it is defined with its core:\n   the same definition renders in React, Vue, Svelte, Solid and web components.\n\n   The root keeps its content at a width-to-height ratio, like 16 / 9 for a video or 1 for a\n   square. The ratio goes out as `--aspect-ratio` and the root's `aspect-ratio` reads it, so the\n   right box is in the server's HTML before anything loads. (The image inside, with its loading\n   state, is UI SDK's avatar primitive, composed in the React file.) */\n\nimport { css, definePrimitive } from \"@ui-sdk/core\"\n\ntype AspectRatioOptions = {\n  /** Width divided by height, like `16 / 9`. @defaultValue 1 */\n  ratio?: number\n}\n\nconst ratioOf = (options: AspectRatioOptions) => (options.ratio && options.ratio > 0 ? options.ratio : 1)\n\nconst aspectRatio = definePrimitive({\n  name: \"aspect-ratio\",\n  options: { ratio: \"number\" },\n  state: (options: AspectRatioOptions) => ({ ratio: ratioOf(options) }),\n  sync: (options) => ({ ratio: ratioOf(options) }),\n  controlled: [\"ratio\"],\n  api: () => ({}),\n  slots: (slot) => ({\n    root: slot<{}, { ratio: number }>({\n      state: (state) => ({ ratio: state.ratio }),\n      attrs: (state) => ({\n        \"data-orientation\": state.ratio > 1 ? \"landscape\" : state.ratio < 1 ? \"portrait\" : \"square\",\n        style: css({ \"--aspect-ratio\": String(state.ratio), \"aspect-ratio\": \"var(--aspect-ratio)\" }),\n      }),\n    }),\n  }),\n  /* Agents can read the frame ratio; its content owns any actions. */\n  agent: { actions: [] },\n})\n\nexport { aspectRatio, type AspectRatioOptions }\n",
      "type": "registry:component",
      "target": "components/keyframery/core/aspect-ratio-core.ts"
    },
    {
      "path": "registry/components/keyframery/primitives/aspect-ratio.tsx",
      "content": "\"use client\"\n\n/* Animated aspect ratio, on UI SDK's core. UI SDK ships no aspect ratio, so the frame is defined\n   in `@/components/core/aspect-ratio` with `definePrimitive` and rendered here. The image inside\n   is UI SDK's own avatar primitive (`@ui-sdk/react/avatar`), which already knows when an image\n   has loaded or failed, under a name that fits a photo. This file adds motion only. Colours,\n   radii and shadows stay yours.\n\n   - A new `ratio` is reached on a spring: the frame reshapes instead of snapping.\n   - `AspectRatioImage` fades up out of an 18px blur and a 1.08 zoom once it has loaded, so a\n     photo never paints in strips. A new `src` plays it again. Until then, its children (a\n     placeholder) show. */\n\nimport { Avatar, AvatarFallback, AvatarImage } from \"@ui-sdk/react/avatar\"\nimport { createParts } from \"@ui-sdk/react/primitive\"\nimport * as React from \"react\"\n\nimport { aspectRatio } from \"@/components/keyframery/core/aspect-ratio-core\"\nimport { cn } from \"@/lib/utils\"\n\n/* `className` may be a string or a function of the part's state: keep both working. */\nfunction withClass<C>(className: C, ...base: string[]): C {\n  return (typeof className === \"function\"\n    ? (state: unknown) => cn(...base, (className as (state: unknown) => string | undefined)(state))\n    : cn(...base, className as string | undefined)) as C\n}\n\nconst { Root: AspectRatioRoot } = createParts(aspectRatio, { root: \"div\" })\n\nfunction AspectRatio({ className, ...props }: React.ComponentProps<typeof AspectRatioRoot>) {\n  return (\n    <AspectRatioRoot\n      className={withClass(className, \"relative transition-[aspect-ratio] duration-[calc(620ms*var(--kf-speed,1))] ease-spring motion-reduce:transition-none\")}\n      {...props}\n    />\n  )\n}\n\ntype AvatarProps = React.ComponentProps<typeof Avatar>\n\nfunction AspectRatioImage({\n  src,\n  alt = \"\",\n  className,\n  children,\n  onLoadingStatusChange,\n  ...props\n}: Omit<React.ComponentProps<typeof AvatarImage>, \"children\"> & {\n  /** Shown until the image has loaded, and if it fails: a colour, a blurred thumbnail, a caption. */\n  children?: React.ReactNode\n  /** Runs when the image starts loading, loads or fails. */\n  onLoadingStatusChange?: AvatarProps[\"onLoadingStatusChange\"]\n}) {\n  return (\n    /* Keyed by the source, so each new photo gets its own entrance. The frame is the image for\n       screen readers and agents: it carries the description, and is hidden when there is none. */\n    <Avatar\n      key={typeof src === \"string\" ? src : undefined}\n      onLoadingStatusChange={onLoadingStatusChange}\n      role={alt ? \"img\" : undefined}\n      aria-label={alt || undefined}\n      aria-hidden={alt ? undefined : true}\n      className=\"absolute inset-0 block overflow-hidden\"\n    >\n      <AvatarImage\n        src={src}\n        alt={alt}\n        className={withClass(className, \"absolute inset-0 size-full object-cover\",\n          \"[transition:opacity_calc(460ms*var(--kf-speed,1))_var(--ease-house),filter_calc(760ms*var(--kf-speed,1))_var(--ease-house),scale_calc(900ms*var(--kf-speed,1))_var(--ease-spring),translate_calc(900ms*var(--kf-speed,1))_var(--ease-spring)]\",\n          \"not-data-[loading-status=loaded]:translate-y-2 not-data-[loading-status=loaded]:scale-[1.08] not-data-[loading-status=loaded]:opacity-0 not-data-[loading-status=loaded]:blur-[18px]\",\n          \"starting:translate-y-2 starting:scale-[1.08] starting:opacity-0 starting:blur-[18px]\",\n          \"motion-reduce:transition-none!\")}\n        {...props}\n      />\n      {children !== undefined && <AvatarFallback className=\"absolute inset-0 block\">{children}</AvatarFallback>}\n    </Avatar>\n  )\n}\n\nexport { AspectRatio, AspectRatioImage }\n",
      "type": "registry:component",
      "target": "components/keyframery/primitives/aspect-ratio.tsx"
    },
    {
      "path": "registry/components/keyframery/aspect-ratio.tsx",
      "content": "\"use client\"\n\nexport * from \"@/components/keyframery/primitives/aspect-ratio\"\n\n/* Theming (unset variables keep the original appearance):\n   --aspect-ratio-face: Frame surface (default: --muted).\n   --aspect-ratio-radius: Frame corners (default: 14px).\n   --aspect-ratio-fit: Image fit (default: cover).\n   --aspect-ratio-position-x: Horizontal crop (default: 50%).\n   --aspect-ratio-position-y: Vertical crop (default: 50%).\n   --aspect-ratio-saturation: Saturation (default: 1).\n   --aspect-ratio-contrast: Contrast (default: 1).\n   --aspect-ratio-brightness: Brightness (default: 1).\n*/\n\n/* Styled aspect ratio: the animated primitive plus the Keyframery look. The frame is a soft well\n   (`bg-muted`) with a hairline drawn inside it, so a photo with a white edge still has a border,\n   and it rounds and clips whatever it holds. */\n\nimport * as React from \"react\"\n\nimport {\n  AspectRatio as AspectRatioPrimitive,\n  AspectRatioImage as AspectRatioImagePrimitive,\n} from \"@/components/keyframery/primitives/aspect-ratio\"\nimport { Speed, type SpeedProps } from \"@/lib/keyframery\"\nimport { cn } from \"@/lib/utils\"\n\n/* `className` may be a string or a function of the part's state: keep both working. */\nfunction withClass<C>(className: C, ...base: string[]): C {\n  return (typeof className === \"function\"\n    ? (state: unknown) => cn(...base, (className as (state: unknown) => string | undefined)(state))\n    : cn(...base, className as string | undefined)) as C\n}\n\nfunction AspectRatio({ speed, className, ...props }: React.ComponentProps<typeof AspectRatioPrimitive> & SpeedProps) {\n  return (\n    <Speed speed={speed}>\n      <AspectRatioPrimitive\n        className={withClass(className, \"w-full overflow-hidden rounded-[var(--aspect-ratio-radius,14px)] bg-[var(--aspect-ratio-face,var(--muted))]\",\n          \"after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:shadow-[inset_0_0_0_1px_rgb(0_0_0/0.07)] dark:after:shadow-[inset_0_0_0_1px_rgb(255_255_255/0.08)]\")}\n        {...props}\n      />\n    </Speed>\n  )\n}\n\nfunction AspectRatioImage({ className, ...props }: React.ComponentProps<typeof AspectRatioImagePrimitive>) {\n  return (\n    <AspectRatioImagePrimitive\n      className={withClass(className,\n        \"[object-fit:var(--aspect-ratio-fit,cover)] [object-position:var(--aspect-ratio-position-x,50%)_var(--aspect-ratio-position-y,50%)]\",\n        \"saturate-[var(--aspect-ratio-saturation,1)] contrast-[var(--aspect-ratio-contrast,1)] brightness-[var(--aspect-ratio-brightness,1)]\")}\n      {...props}\n    />\n  )\n}\n\nexport { AspectRatio, AspectRatioImage }\n",
      "type": "registry:component",
      "target": "components/keyframery/aspect-ratio.tsx"
    }
  ],
  "type": "registry:component"
}