{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "notice",
  "title": "Notice",
  "description": "What a Toast and an Alert share: the icon for each kind of message, which rolls into the next when the kind changes, and the type of the title and description beside it.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/icon-tile.json",
    "https://kinoui.com/r/spinner.json",
    "https://kinoui.com/r/swap.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/lib/notice.tsx",
      "content": "'use client'\n\nimport { IconTile } from '@/registry/components/kino/icon-tile'\nimport { Spinner } from '@/registry/components/kino/spinner'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { Swap } from '@/registry/lib/swap'\nimport type { ComponentProps, ReactNode } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * What a Toast and an Alert share: the icon for each kind of message, which\n * rolls into the next when the kind changes, and the type of the title and\n * description beside it.\n */\n\ntype NoticeType = 'info' | 'success' | 'warning' | 'error' | 'loading'\n\n/** Each kind's icon where it stands alone in a line of text or a control: a sign in its status colour, so it reads without a tile. */\nconst NOTICE_INLINE_ICONS: Record<NoticeType, ReactNode> = {\n  loading: <Spinner key='loading' className='text-muted-foreground' />,\n  success: (\n    <IconPlaceholder\n      key='success'\n      lucide='CircleCheckIcon'\n      tabler='IconCircleCheck'\n      hugeicons='CheckmarkCircle02Icon'\n      phosphor='CheckCircleIcon'\n      remixicon='RiCheckboxCircleLine'\n      className='text-success'\n      aria-hidden\n    />\n  ),\n  error: (\n    <IconPlaceholder\n      key='error'\n      lucide='CircleAlertIcon'\n      tabler='IconAlertCircle'\n      hugeicons='AlertCircleIcon'\n      phosphor='WarningCircleIcon'\n      remixicon='RiErrorWarningLine'\n      className='text-destructive'\n      aria-hidden\n    />\n  ),\n  warning: (\n    <IconPlaceholder\n      key='warning'\n      lucide='TriangleAlertIcon'\n      tabler='IconAlertTriangle'\n      hugeicons='Alert02Icon'\n      phosphor='WarningIcon'\n      remixicon='RiAlertLine'\n      className='text-warning-foreground'\n      aria-hidden\n    />\n  ),\n  info: (\n    <IconPlaceholder\n      key='info'\n      lucide='InfoIcon'\n      tabler='IconInfoCircle'\n      hugeicons='InformationCircleIcon'\n      phosphor='InfoIcon'\n      remixicon='RiInformationLine'\n      className='text-muted-foreground'\n      aria-hidden\n    />\n  ),\n}\n\n/** Each kind's icon inside its Icon tile, which gives it its shape and colour: a bare sign. An error is a cross in an octagon, never a bare cross, which reads as the close button beside it. */\nconst NOTICE_ICONS: Record<NoticeType, ReactNode> = {\n  loading: <Spinner key='loading' />,\n  success: (\n    <IconPlaceholder\n      key='success'\n      lucide='CheckIcon'\n      tabler='IconCheck'\n      hugeicons='Tick02Icon'\n      phosphor='CheckIcon'\n      remixicon='RiCheckLine'\n      aria-hidden\n    />\n  ),\n  error: (\n    <IconPlaceholder\n      key='error'\n      lucide='OctagonXIcon'\n      tabler='IconCircleX'\n      hugeicons='OctagonXIcon'\n      phosphor='XCircleIcon'\n      remixicon='RiSpam3Line'\n      aria-hidden\n    />\n  ),\n  warning: (\n    <IconPlaceholder\n      key='warning'\n      lucide='TriangleAlertIcon'\n      tabler='IconAlertTriangle'\n      hugeicons='Alert02Icon'\n      phosphor='WarningIcon'\n      remixicon='RiAlertLine'\n      aria-hidden\n    />\n  ),\n  info: (\n    <IconPlaceholder\n      key='info'\n      lucide='InfoIcon'\n      tabler='IconInfoCircle'\n      hugeicons='InformationCircleIcon'\n      phosphor='InfoIcon'\n      remixicon='RiInformationLine'\n      aria-hidden\n    />\n  ),\n}\n\n/** Each kind's Icon tile tone: its status colour, and neutral for news and waiting. */\nconst NOTICE_TONES = {\n  loading: 'neutral',\n  info: 'neutral',\n  success: 'success',\n  warning: 'warning',\n  error: 'destructive',\n} as const satisfies Record<NoticeType, 'neutral' | 'success' | 'warning' | 'destructive'>\n\nfunction isNoticeType(type: string | undefined): type is NoticeType {\n  return type !== undefined && Object.hasOwn(NOTICE_ICONS, type)\n}\n\n/** The icon to show in a line of text or a control, in its status colour: `icon` when it is given, even as `null` for none, or else `type`'s own. */\nfunction noticeIcon(type: string | undefined, icon: ReactNode): ReactNode {\n  if (icon !== undefined) return icon\n  return isNoticeType(type) ? NOTICE_INLINE_ICONS[type] : undefined\n}\n\n/**\n * The icon for a kind of message where it stands alone in a line, as a sign\n * in its status colour with no tile, level with the line: `type`'s own, or\n * `icon` in its place. The icon that leaves rolls out as the next rolls in.\n */\nfunction NoticeGlyph({\n  type,\n  icon,\n  className,\n  ...props\n}: ComponentProps<'span'> & { type?: string; icon?: ReactNode }) {\n  const shown = noticeIcon(type, icon)\n  if (shown === undefined || shown === null || shown === false) return null\n  return (\n    <span\n      aria-hidden\n      className={cn(\n        \"flex h-5 shrink-0 items-center [&_svg:not([class*='size-'])]:size-4\",\n        className,\n      )}\n      {...props}\n    >\n      <Swap roll>{shown}</Swap>\n    </span>\n  )\n}\n\n/**\n * The icon for a kind of message in an Icon tile of its tone, level with the\n * title's first line: `type`'s own, or `icon` in its place. The icon that leaves rolls out as the next\n * rolls in, so the loading spinner turns into the result.\n */\nfunction NoticeIcon({\n  type,\n  icon,\n  className,\n  ...props\n}: ComponentProps<'span'> & { type?: string; icon?: ReactNode }) {\n  const shown =\n    icon !== undefined ? icon : isNoticeType(type) ? NOTICE_ICONS[type] : undefined\n  if (shown === undefined || shown === null || shown === false) return null\n  return (\n    // Level with the title's first line, the tile's extra height shared above and below it.\n    <span\n      aria-hidden\n      className={cn('flex h-5 shrink-0 items-center', className)}\n      {...props}\n    >\n      <IconTile size='xs' tone={isNoticeType(type) ? NOTICE_TONES[type] : 'neutral'}>\n        <Swap roll>{shown}</Swap>\n      </IconTile>\n    </span>\n  )\n}\n\n/** The column beside the icon: the title, the description and the actions. */\nconst noticeTextClassName = 'flex min-w-0 flex-1 flex-col gap-0.5 py-px'\n\nconst noticeTitleClassName = 'text-sm leading-5 font-medium wrap-break-word'\n\nconst noticeDescriptionClassName =\n  'text-muted-foreground text-sm leading-5 wrap-break-word'\n\n/** The row of actions under the description. */\nconst noticeActionsClassName = 'mt-2 flex flex-wrap gap-2'\n\nexport {\n  isNoticeType,\n  NoticeGlyph,\n  NoticeIcon,\n  noticeIcon,\n  noticeActionsClassName,\n  noticeDescriptionClassName,\n  noticeTextClassName,\n  noticeTitleClassName,\n  type NoticeType,\n}\n",
      "type": "registry:lib",
      "target": "@lib/notice.tsx"
    }
  ],
  "type": "registry:lib"
}