{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert",
  "title": "Alert",
  "description": "Alerts drop into place out of a blur on a spring while their icon pops into its tile and draws, and when dismissed they fade and fold their height away.",
  "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/alert-core.ts",
      "content": "/* Alert, as a UI SDK primitive. UI SDK ships no alert, so it is defined with its core: the same\n   definition renders in React, Vue, Svelte, Solid and web components.\n\n   An alert is a callout with an icon, a title and a description (shadcn's parts). It is\n   `role=\"alert\"`, named by its title and described by its description when they are there.\n   It arrives with an entrance (`data-starting-style` for its first frame, from `animateIn`), and\n   when `open` turns false it plays its exit (`data-ending-style`, from `animateOut`) before it\n   leaves the page. `AlertClose` dismisses it. */\n\nimport { animateIn, animateOut, createChange, definePrimitive } from \"@ui-sdk/core\"\n\ntype AlertVariant = \"default\" | \"destructive\"\n\ntype AlertOptions = {\n  /** How it reads: `\"default\"` for information, `\"destructive\"` for a problem. @defaultValue \"default\" */\n  variant?: AlertVariant\n  /** Whether the alert is shown. Set it to control the alert yourself. */\n  open?: boolean\n  /** Whether the alert starts shown, when you don't control it. @defaultValue true */\n  defaultOpen?: boolean\n  /** Runs when the alert is dismissed, with `details.reason` `\"close-press\"`. */\n  onOpenChange?: (open: boolean, details: import(\"@ui-sdk/core\").ChangeDetails<\"close-press\">) => void\n}\n\ntype AlertState = {\n  variant: AlertVariant\n  open: boolean\n  /** True while the alert is in the page: from when it opens until its exit has played. */\n  shown: boolean\n  hasTitle: boolean\n  hasDescription: boolean\n}\n\nconst alert = definePrimitive({\n  name: \"alert\",\n  options: { variant: \"string\", open: \"boolean\", defaultOpen: \"boolean\", onOpenChange: \"callback\" },\n  controlled: [\"open\"],\n  state: (options: AlertOptions): AlertState => ({\n    variant: options.variant ?? \"default\",\n    open: options.open ?? options.defaultOpen ?? true,\n    shown: options.open ?? options.defaultOpen ?? true,\n    hasTitle: false,\n    hasDescription: false,\n  }),\n  sync: (options) => ({\n    variant: options.variant ?? \"default\",\n    ...(options.open === undefined ? {} : { open: options.open }),\n  }),\n  api: (context) => {\n    const change = createChange(context)\n    return {\n      /** Dismisses the alert: it plays its exit, then leaves the page. */\n      dismiss(event?: MouseEvent | KeyboardEvent) {\n        change(\"open\", false, { reason: \"close-press\", event })\n      },\n      /** Shows the alert again after it was dismissed. */\n      show() {\n        context.store.set({ open: true })\n      },\n    }\n  },\n  slots: (slot) => ({\n    root: slot<{}, { variant: AlertVariant; open: boolean }>({\n      role: \"alert\",\n      /* `shown` only turns false once the exit has played, so closing never removes it early,\n         whichever way `open` changes (a press, or the app's own state). */\n      present: (state) => state.open || state.shown,\n      state: (state) => ({ variant: state.variant, open: state.open }),\n      attrs: (state, part) => ({\n        \"data-variant\": state.variant,\n        \"aria-labelledby\": state.hasTitle ? `${part.id}-title` : undefined,\n        \"aria-describedby\": state.hasDescription ? `${part.id}-description` : undefined,\n      }),\n      /* Arrive now; leave when `open` turns false, staying present until the exit has played. */\n      bind: (el, part) => {\n        let stop = animateIn(el)\n        if (!part.store.get().shown) part.store.set({ shown: true })\n        let open = part.store.get().open\n        const unsubscribe = part.store.subscribe(() => {\n          const next = part.store.get().open\n          if (next === open) return\n          open = next\n          stop()\n          if (next) {\n            stop = animateIn(el)\n            return\n          }\n          stop = animateOut(el, () => part.store.set({ shown: false }))\n        })\n        return () => {\n          stop()\n          unsubscribe()\n        }\n      },\n    }),\n    title: slot({\n      attrs: (_state, part) => ({ id: `${part.id}-title` }),\n      bind: (_el, part) => {\n        part.store.set({ hasTitle: true })\n        return () => part.store.set({ hasTitle: false })\n      },\n    }),\n    description: slot({\n      attrs: (_state, part) => ({ id: `${part.id}-description` }),\n      bind: (_el, part) => {\n        part.store.set({ hasDescription: true })\n        return () => part.store.set({ hasDescription: false })\n      },\n    }),\n    close: slot({\n      attrs: () => ({ type: \"button\" }),\n      press: ({ api }, event) => api.dismiss(event as MouseEvent | KeyboardEvent | undefined),\n    }),\n  }),\n  /* An agent reads the alert by its title, and may dismiss it. It drops out once dismissed. */\n  agent: { actions: [\"dismiss\"], shown: (state) => state.open },\n})\n\nexport { alert, type AlertOptions, type AlertVariant }\n",
      "type": "registry:component",
      "target": "components/keyframery/core/alert-core.ts"
    },
    {
      "path": "registry/components/keyframery/primitives/alert.tsx",
      "content": "\"use client\"\n\n/* Animated alert, on UI SDK's core. UI SDK ships no alert, so the behaviour is defined in\n   `@/components/core/alert` with `definePrimitive` and rendered here. This file adds motion only.\n   Colours, radii, shadows and spacing stay yours.\n\n   - Arrives: drops 12px into place out of a 6px blur, growing from 0.96, on a spring\n     (`data-starting-style`, set by UI SDK's `animateIn`).\n   - The icon (an `svg` placed directly in the alert) pops in with `ease-pop`, then its strokes draw.\n   - Title and description cascade in after it.\n   - Leaves: fades, blurs and folds its height away (`data-ending-style`, from `animateOut`), so\n     what sits under it closes up instead of jumping. */\n\nimport { createParts } from \"@ui-sdk/react/primitive\"\nimport * as React from \"react\"\n\nimport { alert } from \"@/components/keyframery/core/alert-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 {\n  Root: AlertRoot,\n  Title: AlertTitlePart,\n  Description: AlertDescriptionPart,\n  Close: AlertClosePart,\n} = createParts(alert, { root: \"div\", title: \"div\", description: \"div\", close: \"button\" })\n\n/* Rows rise out of a blur; the icon pops; its strokes draw. Under reduced motion only the fade is left. */\nconst keyframes =\n  \"@keyframes kf-alert-rise{from{opacity:0;translate:0 6px;filter:blur(4px)}}\" +\n  \"@keyframes kf-alert-pop{from{opacity:0;scale:0.4}}\" +\n  \"@keyframes kf-alert-draw{from{stroke-dasharray:80;stroke-dashoffset:80}to{stroke-dasharray:80;stroke-dashoffset:0}}\" +\n  \"@media (prefers-reduced-motion:reduce){@keyframes kf-alert-rise{from{opacity:0}}@keyframes kf-alert-pop{from{opacity:0}}@keyframes kf-alert-draw{from{opacity:1}}}\"\n\nfunction Alert({ className, children, ...props }: React.ComponentProps<typeof AlertRoot>) {\n  return (\n    <>\n      <style href=\"kf-alert\" precedence=\"default\">\n        {keyframes}\n      </style>\n      <AlertRoot\n        className={withClass(className, \"group/alert [interpolate-size:allow-keywords]\",\n          \"transition-[opacity,translate,scale,filter,height,padding-block,margin-block] duration-[calc(520ms*var(--kf-speed,1))] ease-spring\",\n          \"data-starting-style:-translate-y-3 data-starting-style:scale-[0.96] data-starting-style:opacity-0 data-starting-style:blur-[6px]\",\n          \"data-ending-style:h-0 data-ending-style:overflow-hidden data-ending-style:py-0 data-ending-style:my-0\",\n          \"data-ending-style:scale-[0.98] data-ending-style:opacity-0 data-ending-style:blur-[4px]\",\n          \"data-ending-style:duration-[calc(260ms*var(--kf-speed,1))] data-ending-style:ease-house\",\n          /* The icon: pops in, then draws. */\n          \"[&>svg]:origin-center [&>svg]:animate-[kf-alert-pop_calc(460ms*var(--kf-speed,1))_var(--ease-pop)_backwards] [&>svg]:[animation-delay:calc(70ms*var(--kf-speed,1))]\",\n          \"[&>svg_*]:animate-[kf-alert-draw_calc(620ms*var(--kf-speed,1))_var(--ease-house)_backwards] [&>svg_*]:[animation-delay:calc(170ms*var(--kf-speed,1))]\",\n          \"motion-reduce:transition-none! motion-reduce:[&>svg]:animate-none motion-reduce:[&>svg_*]:animate-none\")}\n        {...props}\n      >\n        {children}\n      </AlertRoot>\n    </>\n  )\n}\n\nconst rise = \"animate-[kf-alert-rise_calc(480ms*var(--kf-speed,1))_var(--ease-spring)_backwards] motion-reduce:animate-none\"\n\nfunction AlertTitle({ className, ...props }: React.ComponentProps<typeof AlertTitlePart>) {\n  return <AlertTitlePart className={withClass(className, rise, \"[animation-delay:calc(110ms*var(--kf-speed,1))]\")} {...props} />\n}\n\nfunction AlertDescription({ className, ...props }: React.ComponentProps<typeof AlertDescriptionPart>) {\n  return <AlertDescriptionPart className={withClass(className, rise, \"[animation-delay:calc(170ms*var(--kf-speed,1))]\")} {...props} />\n}\n\n/* Press: dips and pops back. It arrives with the rows. */\nfunction AlertClose({ className, ...props }: React.ComponentProps<typeof AlertClosePart>) {\n  return (\n    <AlertClosePart\n      className={withClass(className, rise,\n        \"[animation-delay:calc(200ms*var(--kf-speed,1))]\",\n        \"transition-[scale] duration-[calc(200ms*var(--kf-speed,1))] ease-pop active:scale-[0.88] motion-reduce:transition-none\")}\n      {...props}\n    />\n  )\n}\n\nexport { Alert, AlertClose, AlertDescription, AlertTitle }\n",
      "type": "registry:component",
      "target": "components/keyframery/primitives/alert.tsx"
    },
    {
      "path": "registry/components/keyframery/alert.tsx",
      "content": "\"use client\"\n\nexport * from \"@/components/keyframery/primitives/alert\"\n\n/* Theming variables (set on a part or ancestor; absent values preserve the theme):\n   --alert-face: Alert surface; default: bg-card.\n   --alert-ink: Alert text; default: text-card-foreground.\n   --alert-muted: Description; default: text-muted-foreground.\n   --alert-radius: Corners; default: rounded-[14px].\n   --alert-font: Body size; default: text-[13px].\n   --alert-gap: Content gap; default: gap-y-1.\n   --alert-inset-x: Side padding; default: px-4.\n   --alert-inset-y: Vertical padding; default: py-3.5.\n*/\n\n/* Styled alert: the animated primitive plus the Keyframery look. A quiet card with a hairline; the\n   icon sits in a small tile of its own, tinted by the variant; the close button is a ghost key in\n   the top corner. */\n\nimport * as React from \"react\"\n\nimport {\n  Alert as AlertPrimitive,\n  AlertClose as AlertClosePrimitive,\n  AlertDescription as AlertDescriptionPrimitive,\n  AlertTitle as AlertTitlePrimitive,\n} from \"@/components/keyframery/primitives/alert\"\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 Alert({ speed, className, ...props }: React.ComponentProps<typeof AlertPrimitive> & SpeedProps) {\n  return (\n    <Speed speed={speed}>\n      <AlertPrimitive\n        className={withClass(className, \"relative grid w-full grid-cols-[0_1fr] items-start gap-y-[var(--alert-gap,0.25rem)] rounded-[var(--alert-radius,14px)] bg-[var(--alert-face,var(--card))] px-[var(--alert-inset-x,1rem)] py-[var(--alert-inset-y,0.875rem)] text-[length:var(--alert-font,13px)] text-[color:var(--alert-ink,var(--card-foreground))]\",\n          \"has-[>svg]:grid-cols-[28px_1fr] has-[>svg]:gap-x-3 has-[>[data-slot=alert-close]]:pr-12\",\n          \"shadow-[0_0_0_1px_rgb(0_0_0/0.07),0_1px_2px_rgb(0_0_0/0.04),0_4px_12px_-6px_rgb(0_0_0/0.08)]\",\n          \"dark:shadow-[0_0_0_1px_rgb(255_255_255/0.08),0_4px_12px_-6px_rgb(0_0_0/0.6)]\",\n          /* The icon tile: the svg itself, padded, with a tinted face. */\n          \"[&>svg]:row-span-2 [&>svg]:box-content [&>svg]:size-4 [&>svg]:rounded-[8px] [&>svg]:bg-muted [&>svg]:p-1.5 [&>svg]:text-foreground\",\n          \"data-[variant=destructive]:[&>svg]:bg-destructive/10 data-[variant=destructive]:[&>svg]:text-destructive\",\n          \"dark:data-[variant=destructive]:[&>svg]:bg-destructive/20\",\n          \"data-[variant=destructive]:shadow-[0_0_0_1px_color-mix(in_oklch,var(--destructive)_22%,transparent),0_1px_2px_rgb(0_0_0/0.04),0_4px_12px_-6px_rgb(0_0_0/0.08)]\",\n          \"dark:data-[variant=destructive]:shadow-[0_0_0_1px_color-mix(in_oklch,var(--destructive)_35%,transparent),0_4px_12px_-6px_rgb(0_0_0/0.6)]\")}\n        {...props}\n      />\n    </Speed>\n  )\n}\n\nfunction AlertTitle({ className, ...props }: React.ComponentProps<typeof AlertTitlePrimitive>) {\n  return (\n    <AlertTitlePrimitive\n      className={withClass(className, \"col-start-2 pt-[5px] text-[13.5px] leading-[18px] font-semibold tracking-tight\",\n        \"group-data-[variant=destructive]/alert:text-destructive\")}\n      {...props}\n    />\n  )\n}\n\nfunction AlertDescription({ className, ...props }: React.ComponentProps<typeof AlertDescriptionPrimitive>) {\n  return (\n    <AlertDescriptionPrimitive\n      className={withClass(className, \"col-start-2 grid justify-items-start gap-1.5 text-[length:var(--alert-font,13px)] leading-[1.5] text-[color:var(--alert-muted,var(--muted-foreground))] [&_p]:leading-[1.5]\")}\n      {...props}\n    />\n  )\n}\n\nfunction AlertClose({ className, children, ...props }: React.ComponentProps<typeof AlertClosePrimitive>) {\n  return (\n    <AlertClosePrimitive\n      aria-label=\"Dismiss\"\n      className={withClass(className, \"absolute top-3 right-3 inline-flex size-7 cursor-pointer items-center justify-center rounded-[8px] text-[color:var(--alert-muted,var(--muted-foreground))] outline-none\",\n        \"hover:bg-foreground/[0.05] hover:text-foreground\",\n        \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card\",\n        \"[&_svg]:size-4\")}\n      {...props}\n    >\n      {children ?? (\n        <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" aria-hidden=\"true\">\n          <path d=\"M4 4l8 8M12 4l-8 8\" />\n        </svg>\n      )}\n    </AlertClosePrimitive>\n  )\n}\n\nexport { Alert, AlertClose, AlertDescription, AlertTitle }\n",
      "type": "registry:component",
      "target": "components/keyframery/alert.tsx"
    }
  ],
  "type": "registry:component"
}