{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert",
  "title": "Alert",
  "description": "Inline message card with a semantic icon disc, title, body and an optional dismiss or action cluster.",
  "dependencies": [
    "class-variance-authority@^0.7.1",
    "lucide-react@^1.27.0"
  ],
  "registryDependencies": [
    "@pestoui/style",
    "@pestoui/utils"
  ],
  "files": [
    {
      "path": "pestoui/ui/alert.tsx",
      "content": "import * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\nimport { Check, X } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/* Alert — a white card with a filled semantic icon disc, a title, an optional\n   body, and either a dismiss (×) or an action cluster on the right. The variant\n   drives only the icon disc; the card and copy stay neutral so a column of mixed\n   alerts reads calmly. Alignment flips to top when a description is present.\n\n   That rule makes the disc the ONLY carrier of severity on screen, and the disc\n   is aria-hidden decoration — so severity would reach a screen reader as\n   nothing at all (WCAG 1.4.1, use of colour). `severityLabel` closes that: one\n   visually-hidden word, read before the title, changing no pixel. */\nconst alertVariants = cva(\n  \"group/alert relative flex w-full items-center gap-3 rounded-lg border border-border/70 bg-card px-4 py-3.5 text-left shadow-xs has-data-[slot=alert-description]:items-start\",\n)\n\n/* The disc and the copy share a row of their own so the disc can be aligned to\n   the TITLE rather than to the card. Two things fall out of that:\n\n   - `items-start` here is what makes the disc track the first line of a title\n     that wraps. The card's own centring still applies to this row as a whole,\n     so an action cluster taller than the copy keeps centring both together —\n     which is why this cannot be done by flipping the card to `items-start`.\n   - The row is the flex item the card sizes and grows, so `flex-1 min-w-0`\n     moves here from the content column; `gap-3` is the card's own gap repeated,\n     leaving every horizontal measurement on the card unchanged. */\nconst alertLead = \"flex min-w-0 flex-1 items-start gap-3\"\n\n/* The title's type size, declared ONCE because two elements have to agree on\n   it: AlertTitle sets the type, and the icon line below sizes its `1lh` box\n   from it. As two separate literals they could drift apart with nothing to\n   catch it — the disc would quietly stop landing on the title's first line and\n   no test, type or build would notice. One constant makes that impossible.\n\n   The size-only Tier-1 token (15px, no line-height companion). It merges as a\n   font size only because typeScaleMergeConfig in lib/utils.ts registers it:\n   unregistered, tailwind-merge reads a bare `text-body` as a text COLOUR, so\n   `cn(\"text-body\", \"text-muted-foreground\")` would resolve to\n   `text-muted-foreground` alone and the font size would vanish. AlertTitle\n   merges a caller's className, so that is a live path. */\nconst alertTitleType = \"text-body\"\n\n/* One line tall, in the title's own type, with the 20px disc centred in it —\n   which is the definition of \"on the first line of the title\". The line box is\n   15px × the inherited 1.5 = 22.5px, so the offset is (22.5 − 20) / 2 =\n   1.25px, a value no spacing step can express; the `mt-0.5` it replaces was a\n   2px approximation of it that only applied when a description was present,\n   and the two paths were 0.75px apart as a result.\n\n   `1lh` is the line box rather than a repeat of it, so the leading can be\n   retuned without touching this. */\nconst alertIconLine = `flex h-[1lh] shrink-0 items-center ${alertTitleType}`\n\n/* An alert is an announcement — it has arrived, so it should read as arriving\n   rather than as having always been there. Panel spring because the card has\n   real area; the blur is the enter-only materialise cue, held at the small end\n   of the range because this is an inline block inside content, not chrome. */\nconst alertAppear =\n  \"animate-in fade-in-0 slide-in-from-bottom-2 blur-in-4 anim-spring-panel ease-spring-panel\"\n\nconst alertIconVariants = cva(\n  \"flex size-5 shrink-0 items-center justify-center rounded-full [&_svg]:size-3 [&_svg]:stroke-[3]\",\n  {\n    variants: {\n      variant: {\n        default: \"bg-foreground text-card\",\n        info: \"bg-info text-info-foreground\",\n        success: \"bg-success text-success-foreground\",\n        warning: \"bg-warning text-warning-foreground\",\n        destructive: \"bg-destructive text-white\",\n      },\n    },\n    defaultVariants: {\n      variant: \"default\",\n    },\n  },\n)\n\ntype AlertVariant = NonNullable<VariantProps<typeof alertIconVariants>[\"variant\"]>\n\n/* Bare glyphs live inside the coloured disc — lucide has no bare \"i\"/\"!\", so\n   those two are text, while success/error use real marks. */\nconst DEFAULT_ICON: Record<AlertVariant, React.ReactNode> = {\n  default: <span className=\"text-micro font-bold\">i</span>,\n  info: <span className=\"text-micro font-bold\">i</span>,\n  success: <Check />,\n  warning: <span className=\"text-xs font-bold\">!</span>,\n  destructive: <X />,\n}\n\n/* The word a screen reader hears in place of the disc's colour. `default` is\n   the absence of a severity rather than one of them — its disc is plain ink,\n   the same colour as the copy — so it announces nothing; `info` must, because\n   it is `default` with a different fill and the same bare \"i\" glyph, and colour\n   is otherwise the only thing separating the two. */\nconst DEFAULT_SEVERITY_LABEL: Record<AlertVariant, string | null> = {\n  default: null,\n  info: \"Information\",\n  success: \"Success\",\n  warning: \"Warning\",\n  destructive: \"Error\",\n}\n\ntype AlertProps = React.ComponentProps<\"div\"> &\n  VariantProps<typeof alertIconVariants> & {\n    /** Override the auto icon inside the disc. Pass null to hide the disc. */\n    icon?: React.ReactNode\n    /** Renders a dismiss (×) button and fires this on click. */\n    onDismiss?: () => void\n    /** Right-aligned action cluster — usually one or two <Button>s. */\n    action?: React.ReactNode\n    /**\n     * The severity word announced before the title, visible to assistive tech\n     * only. Defaults to the variant's own (\"Error\", \"Warning\", \"Success\",\n     * \"Information\"; `default` announces nothing). Pass a string to translate\n     * or reword it, or `null` to announce nothing at all.\n     */\n    severityLabel?: string | null\n  }\n\nfunction Alert({\n  className,\n  variant = \"default\",\n  icon,\n  onDismiss,\n  action,\n  severityLabel,\n  children,\n  ...props\n}: AlertProps) {\n  const resolvedIcon = icon === undefined ? DEFAULT_ICON[variant ?? \"default\"] : icon\n  /* Keyed off the variant, never off the disc: `icon={null}` is a rendering\n     choice, and letting it drop the announcement would silently take severity\n     away from the one audience that cannot see the disc either way. Callers who\n     want the quiet form say so with `severityLabel={null}`. */\n  const severity =\n    severityLabel === undefined\n      ? DEFAULT_SEVERITY_LABEL[variant ?? \"default\"]\n      : severityLabel\n\n  return (\n    <div\n      data-slot=\"alert\"\n      data-variant={variant}\n      role=\"alert\"\n      className={cn(alertVariants(), alertAppear, className)}\n      {...props}\n    >\n      {/* First in the DOM, and out of flow, so it is read before the title and\n          measures nothing. A flex container's absolutely-positioned child is\n          not a flex item, so it takes no `gap` either. */}\n      {severity != null && severity !== \"\" && (\n        <span data-slot=\"alert-severity\" className=\"sr-only\">\n          {`${severity}: `}\n        </span>\n      )}\n\n      <div data-slot=\"alert-lead\" className={alertLead}>\n        {resolvedIcon != null && (\n          <span aria-hidden=\"true\" className={alertIconLine}>\n            <span data-slot=\"alert-icon\" className={cn(alertIconVariants({ variant }))}>\n              {resolvedIcon}\n            </span>\n          </span>\n        )}\n\n        <div data-slot=\"alert-content\" className=\"flex min-w-0 flex-1 flex-col gap-0.5\">\n          {children}\n        </div>\n      </div>\n\n      {action != null && (\n        <div\n          data-slot=\"alert-action\"\n          className=\"flex shrink-0 items-center gap-2 self-center\"\n        >\n          {action}\n        </div>\n      )}\n\n      {onDismiss && (\n        <button\n          type=\"button\"\n          onClick={onDismiss}\n          aria-label=\"Dismiss\"\n          className=\"-mt-0.5 -mr-1 flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-all duration-fast ease-out-expo outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 active:scale-90 active:duration-spring-press active:ease-spring-press [&_svg]:size-4\"\n        >\n          <X />\n        </button>\n      )}\n    </div>\n  )\n}\n\nfunction AlertTitle({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"alert-title\"\n      className={cn(\n        alertTitleType,\n        \"font-semibold tracking-snug text-foreground [&_a]:underline [&_a]:underline-offset-3\",\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nfunction AlertDescription({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"alert-description\"\n      className={cn(\n        \"text-sm leading-normal text-muted-foreground [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground\",\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Alert, AlertTitle, AlertDescription, alertIconVariants }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}