{
  "$schema": "https://pdfx.akashpise.dev/schema/registry-item.json",
  "name": "badge",
  "type": "registry:ui",
  "title": "Badge",
  "description": "Inline status badge with 7 color variants and 3 sizes",
  "files": [
    {
      "path": "components/pdfx/badge/pdfx-badge.tsx",
      "content": "import { Text as PDFText, StyleSheet, View } from '@react-pdf/renderer';\nimport type { Style } from '@react-pdf/types';\nimport { usePdfxTheme, useSafeMemo } from '../lib/pdfx-theme-context';\ntype PdfxTheme = ReturnType<typeof usePdfxTheme>;\n\nexport type BadgeVariant =\n  | 'default'\n  | 'primary'\n  | 'success'\n  | 'warning'\n  | 'destructive'\n  | 'info'\n  | 'outline';\nexport type BadgeSize = 'sm' | 'md' | 'lg';\n\n/**\n * Inline label for status, tags, or categories.\n *\n * Accepts text via either `label` prop or `children` (string). `label` takes\n * precedence when both are provided. The children pattern (`<Badge>text</Badge>`)\n * is supported for compatibility with common React idioms, but note that\n * `@react-pdf/renderer` doesn't support JSX children the way HTML does — only\n * string children are accepted.\n *\n * Props - `label` | `children` | `variant` | `size` | `background` | `color` | `style`\n * @see {@link BadgeProps}\n */\nexport interface BadgeProps {\n  /** Custom styles to merge with component defaults */\n  style?: Style;\n  /** Text to display. Takes precedence over children when both are provided. */\n  label?: string;\n  /** String children as an alternative to the label prop. */\n  children?: string;\n  /**\n   * @default 'default'\n   */\n  variant?: BadgeVariant;\n  /**\n   * @default 'md'\n   */\n  size?: BadgeSize;\n  background?: string;\n  color?: string;\n}\n\nconst THEME_COLOR_KEYS = ['foreground','muted','mutedForeground','primary','primaryForeground','accent','destructive','success','warning','info'] as const;\nfunction resolveColor(value: string, colors: Record<string, string>): string {\n  return THEME_COLOR_KEYS.includes(value as (typeof THEME_COLOR_KEYS)[number]) ? colors[value] : value;\n}\nfunction createBadgeStyles(t: PdfxTheme) {\n  const { spacing, borderRadius, fontWeights } = t.primitives;\n  const c = t.colors;\n  const textBase = {\n    fontFamily: t.typography.body.fontFamily,\n    fontWeight: fontWeights.semibold,\n    letterSpacing: 0.3,\n  };\n  const variantBox = (borderColor: string, bgColor: string = c.muted) => ({\n    backgroundColor: bgColor,\n    borderWidth: spacing[0.5],\n    borderColor,\n    borderStyle: 'solid' as const,\n  });\n  const sheet = StyleSheet.create({\n    containerBase: {\n      borderRadius: borderRadius.full,\n      alignSelf: 'flex-start' as const,\n      flexDirection: 'row' as const,\n      alignItems: 'center' as const,\n    },\n    variantDefault: variantBox(c.border),\n    variantPrimary: variantBox(c.primary, c.primary),\n    variantSuccess: variantBox(c.success),\n    variantWarning: variantBox(c.warning),\n    variantDestructive: variantBox(c.destructive),\n    variantInfo: variantBox(c.info),\n    variantOutline: variantBox(c.border, c.background),\n    sizeSm: { paddingHorizontal: spacing[2], paddingVertical: spacing[0.5] },\n    sizeMd: { paddingHorizontal: spacing[3], paddingVertical: spacing[1] },\n    sizeLg: { paddingHorizontal: spacing[4], paddingVertical: spacing[2] },\n    textDefault: { ...textBase, color: c.mutedForeground },\n    textPrimary: { ...textBase, color: c.primaryForeground },\n    textSuccess: { ...textBase, color: c.success },\n    textWarning: { ...textBase, color: c.warning },\n    textDestructive: { ...textBase, color: c.destructive },\n    textInfo: { ...textBase, color: c.info },\n    textOutline: { ...textBase, color: c.foreground },\n    textSm: { fontSize: t.primitives.typography.xs - 1 },\n    textMd: { fontSize: t.primitives.typography.xs },\n    textLg: { fontSize: t.primitives.typography.sm },\n  });\n  return {\n    ...sheet,\n    containerVariantMap: {\n      default: sheet.variantDefault,\n      primary: sheet.variantPrimary,\n      success: sheet.variantSuccess,\n      warning: sheet.variantWarning,\n      destructive: sheet.variantDestructive,\n      info: sheet.variantInfo,\n      outline: sheet.variantOutline,\n    } as Record<BadgeVariant, Style>,\n    textVariantMap: {\n      default: sheet.textDefault,\n      primary: sheet.textPrimary,\n      success: sheet.textSuccess,\n      warning: sheet.textWarning,\n      destructive: sheet.textDestructive,\n      info: sheet.textInfo,\n      outline: sheet.textOutline,\n    } as Record<BadgeVariant, Style>,\n    containerSizeMap: { sm: sheet.sizeSm, md: sheet.sizeMd, lg: sheet.sizeLg } as Record<\n      BadgeSize,\n      Style\n    >,\n    textSizeMap: { sm: sheet.textSm, md: sheet.textMd, lg: sheet.textLg } as Record<\n      BadgeSize,\n      Style\n    >,\n  };\n}\n\nexport function Badge({\n  label,\n  children,\n  variant = 'default',\n  size = 'md',\n  background,\n  color,\n  style,\n}: BadgeProps) {\n  const theme = usePdfxTheme();\n  const styles = useSafeMemo(() => createBadgeStyles(theme), [theme]);\n  // `label` takes precedence; fall back to string children for React idiom compatibility\n  const text = label ?? children ?? '';\n  const containerStyles: Style[] = [\n    styles.containerBase,\n    styles.containerVariantMap[variant],\n    styles.containerSizeMap[size],\n    ...(background ? [{ backgroundColor: resolveColor(background, theme.colors) }] : []),\n    ...(style ? [style].flat() : []),\n  ];\n  const textStyles: Style[] = [\n    styles.textVariantMap[variant],\n    styles.textSizeMap[size],\n    ...(color ? [{ color: resolveColor(color, theme.colors) }] : []),\n  ];\n  return (\n    <View style={containerStyles}>\n      <PDFText style={textStyles}>{text}</PDFText>\n    </View>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "dependencies": [
    "@react-pdf/renderer"
  ],
  "registryDependencies": [
    "theme"
  ]
}