{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rating",
  "title": "Rating",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/rating/Rating.tsx",
      "content": "import * as React from 'react'\nimport { Pressable, View, type ViewProps } from 'react-native'\nimport { Star } from 'lucide-react-native'\nimport { useThemeColors } from '@/lib/theme'\nimport { cn } from '@/lib/utils'\n\nexport interface RatingProps extends Omit<ViewProps, 'children'> {\n  value?: number\n  defaultValue?: number\n  onValueChange?: (value: number) => void\n  max?: number\n  disabled?: boolean\n  readOnly?: boolean\n  className?: string\n  /** Localize the name of each selectable whole-star value. */\n  getValueLabel?: (value: number, max: number) => string\n}\n\nexport const Rating = React.forwardRef<React.ComponentRef<typeof View>, RatingProps>(\n  (\n    {\n      value,\n      defaultValue = 0,\n      onValueChange,\n      max = 5,\n      disabled = false,\n      readOnly = false,\n      className,\n      accessibilityLabel = 'Rating',\n      getValueLabel = (rating, total) => `${rating} of ${total} stars`,\n      ...props\n    },\n    ref,\n  ) => {\n    if (!Number.isInteger(max) || max < 1) throw new RangeError('Rating max must be a positive integer')\n    const [internal, setInternal] = React.useState(defaultValue)\n    const raw = value ?? internal\n    const resolved = Math.max(0, Math.min(max, Number.isFinite(raw) ? raw : 0))\n    const colors = useThemeColors()\n    function star(index: number) {\n      const filled = Math.max(0, Math.min(1, resolved - index))\n      return (\n        <View pointerEvents=\"none\" aria-hidden style={{ width: 24, height: 24 }}>\n          <Star size={24} color={colors.mutedForeground} fill=\"transparent\" aria-hidden />\n          {filled > 0 ? (\n            <View className=\"absolute left-0 top-0 overflow-hidden\" style={{ width: 24 * filled, height: 24 }}>\n              <Star size={24} color={colors.primary} fill={colors.primary} aria-hidden />\n            </View>\n          ) : null}\n        </View>\n      )\n    }\n    return (\n      <View\n        ref={ref}\n        {...props}\n        accessibilityRole={readOnly ? 'image' : 'radiogroup'}\n        accessibilityLabel={accessibilityLabel}\n        // Fabric's numeric accessibility range uses integers; informational fractional ratings use text.\n        accessibilityValue={readOnly ? { text: getValueLabel(resolved, max) } : undefined}\n        className={cn('flex-row flex-wrap items-center gap-[4px]', disabled && 'opacity-50', className)}\n      >\n        {Array.from({ length: max }, (_, index) =>\n          readOnly ? (\n            <View key={index} className=\"p-[4px]\">\n              {star(index)}\n            </View>\n          ) : (\n            <Pressable\n              key={index}\n              accessibilityRole=\"radio\"\n              accessibilityLabel={getValueLabel(index + 1, max)}\n              accessibilityState={{ checked: resolved === index + 1, disabled }}\n              disabled={disabled}\n              className=\"min-h-[48px] min-w-[48px] items-center justify-center rounded-md active:bg-muted\"\n              onPress={() => {\n                const next = index + 1\n                if (disabled || next === resolved) return\n                if (value === undefined) setInternal(next)\n                onValueChange?.(next)\n              }}\n            >\n              {star(index)}\n            </Pressable>\n          ),\n        )}\n      </View>\n    )\n  },\n)\nRating.displayName = 'Rating'\n",
      "type": "registry:ui",
      "target": "~/components/ui/rating/Rating.tsx"
    },
    {
      "path": "packages/registry-native/components/rating/index.ts",
      "content": "export { Rating } from './Rating'\nexport type { RatingProps } from './Rating'\n",
      "type": "registry:ui",
      "target": "~/components/ui/rating/index.ts"
    }
  ],
  "dependencies": [
    "lucide-react-native"
  ],
  "devDependencies": [],
  "registryDependencies": [],
  "description": "Whole-star selection and fractional read-only display with themed icons and controlled or default values.",
  "categories": [
    "control"
  ]
}