{ "name": "day-range", "type": "registry:ui", "registryDependencies": [], "dependencies": [ "motion" ], "devDependencies": [], "tailwind": {}, "cssVars": { "light": {}, "dark": {} }, "files": [ { "path": "day-range.tsx", "content": "'use client';\n\nimport * as React from 'react';\nimport { motion } from 'motion/react';\nimport { cn } from '@/lib/utils';\n\nexport interface DayRangeProps extends React.HTMLAttributes {\n low: number;\n high: number;\n current: number;\n currencySymbol?: string;\n lowLabel?: string;\n highLabel?: string;\n formatValue?: (value: number) => string;\n}\n\nexport const DayRange = React.forwardRef(\n (\n {\n low,\n high,\n current,\n currencySymbol = '₹',\n lowLabel = \"Today's low\",\n highLabel = \"Today's high\",\n formatValue,\n className,\n ...props\n },\n ref\n ) => {\n // Ensure current is clamped between low and high\n const clampedCurrent = Math.max(low, Math.min(high, current));\n\n // Calculate percentage (0 to 100)\n const percentage =\n high === low ? 0 : ((clampedCurrent - low) / (high - low)) * 100;\n\n const defaultFormat = (val: number) =>\n new Intl.NumberFormat('en-IN', {\n maximumFractionDigits: 2,\n }).format(val);\n\n const formatter = formatValue || defaultFormat;\n\n return (\n \n {/* Top Labels */}\n
\n
\n {lowLabel}\n \n {currencySymbol}\n {formatter(low)}\n \n
\n
\n \n {highLabel}\n \n \n {currencySymbol}\n {formatter(high)}\n \n
\n
\n\n {/* Range Bar */}\n
\n {/* Filled part */}\n \n\n {/* Current Value Tooltip/Indicator */}\n \n {/* Tooltip triangle */}\n
\n
\n {currencySymbol}\n {formatter(current)}\n
\n \n
\n
\n );\n }\n);\nDayRange.displayName = 'DayRange';\n", "type": "registry:ui" } ] }