{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "activity-heatmap",
  "type": "registry:component",
  "title": "Activity calendar",
  "description": "Reveal working-day patterns and quieter weeks across a year of activity.",
  "categories": [
    "charts"
  ],
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/activity-heatmap.tsx",
      "type": "registry:component",
      "target": "components/overtrue/activity-heatmap.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { formatNumber } from \"./metric-format\";\n\nexport interface ActivityDatum {\n  /** ISO date, YYYY-MM-DD. */\n  date: string;\n  value: number;\n}\n\nexport interface ActivityHeatmapProps extends React.ComponentProps<\"div\"> {\n  data: ActivityDatum[];\n  /** Last day shown. Defaults to today. */\n  endDate?: Date;\n  /** Number of week columns. Ignored when `startDate` is set. */\n  weeks?: number;\n  /** First day shown. Overrides `weeks`. */\n  startDate?: Date;\n  /** Any CSS color. Levels are mixed from this and the card surface. Defaults to chart-1. */\n  color?: string;\n  /**\n   * Explicit color per level, from empty to most active.\n   * Overrides `color`. Length sets the number of levels.\n   */\n  colors?: string[];\n  /** How values map to levels. `sqrt` spreads out small values. */\n  scale?: \"linear\" | \"sqrt\";\n  /** Cell size in px. */\n  cellSize?: number;\n  /** Gap between cells in px. */\n  gap?: number;\n  valueFormatter?: (value: number) => string;\n  /** Label for the value in the tooltip, e.g. \"events\". */\n  unit?: string;\n  showMonthLabels?: boolean;\n  /** Which weekday labels to show along the left edge. */\n  weekdayLabels?: \"mwf\" | \"all\" | \"none\";\n  showLegend?: boolean;\n  /** Show the total and the number of active days beside the legend. Follows `showLegend` by default. */\n  showSummary?: boolean;\n  /** Scroll to the most recent weeks when the grid overflows. */\n  scrollToEnd?: boolean;\n  /** Replace the tooltip body. Return `null` to hide it for that cell. */\n  renderTooltip?: (datum: { date: Date; value: number }) => React.ReactNode;\n  onCellClick?: (datum: { date: Date; value: number }) => void;\n}\n\nconst WEEKDAYS = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\nconst EMPTY_FILL = \"color-mix(in oklab, var(--color-muted) 72%, transparent)\";\n\nconst useIsomorphicLayoutEffect =\n  typeof window === \"undefined\" ? React.useEffect : React.useLayoutEffect;\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (onChange) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", onChange);\n      return () => query.removeEventListener(\"change\", onChange);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction toKey(date: Date) {\n  const y = date.getFullYear();\n  const m = String(date.getMonth() + 1).padStart(2, \"0\");\n  const d = String(date.getDate()).padStart(2, \"0\");\n  return `${y}-${m}-${d}`;\n}\n\nfunction startOfDay(date: Date) {\n  return new Date(date.getFullYear(), date.getMonth(), date.getDate());\n}\n\nfunction addDays(date: Date, days: number) {\n  // Calendar days can be 23 or 25 hours across daylight-saving transitions.\n  return new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);\n}\n\nfunction levelFor(\n  value: number,\n  max: number,\n  levels: number,\n  scale: \"linear\" | \"sqrt\",\n) {\n  if (value <= 0 || max <= 0) return 0;\n  let t = value / max;\n  if (scale === \"sqrt\") t = Math.sqrt(t);\n  return Math.min(levels - 1, Math.max(1, Math.ceil(t * (levels - 1))));\n}\n\n/** The smallest value that lands in each level, so the legend can name its range. */\nfunction levelFloor(\n  level: number,\n  max: number,\n  levels: number,\n  scale: \"linear\" | \"sqrt\",\n) {\n  if (level <= 0) return 0;\n  const t = (level - 1) / (levels - 1);\n  return scale === \"sqrt\" ? t * t * max : t * max;\n}\n\n/** An OKLab ramp from the card surface to the accent, one step per level. */\nfunction mixedColors(color: string, levels: number) {\n  return Array.from({ length: levels }, (_, level) => {\n    if (level === 0) return EMPTY_FILL;\n    const pct = Math.round(22 + ((level - 1) / Math.max(1, levels - 2)) * 78);\n    return `color-mix(in oklab, ${color} ${pct}%, var(--color-card))`;\n  });\n}\n\n/**\n * A calendar heatmap with a column per week and a row per weekday. Hover or focus a\n * day to outline it and read its value; arrow keys move by day and by week.\n */\nfunction ActivityHeatmap({\n  data,\n  endDate,\n  weeks = 52,\n  startDate,\n  color = \"var(--color-chart-1)\",\n  colors,\n  scale = \"linear\",\n  cellSize = 12,\n  gap = 3,\n  valueFormatter = (value) => formatNumber(value),\n  unit = \"events\",\n  showMonthLabels = true,\n  weekdayLabels = \"mwf\",\n  showLegend = true,\n  showSummary = showLegend,\n  scrollToEnd = true,\n  renderTooltip,\n  onCellClick,\n  className,\n  ...props\n}: ActivityHeatmapProps) {\n  const reduced = useReducedMotion();\n  const endTime = startOfDay(endDate ?? new Date()).getTime();\n  const startTime = startDate\n    ? startOfDay(startDate).getTime()\n    : addDays(new Date(endTime), -(weeks * 7 - 1)).getTime();\n\n  const values = React.useMemo(\n    () => new Map(data.map((d) => [d.date, d.value])),\n    [data],\n  );\n\n  // Columns are full weeks, Sunday first. Days before `start` in the first\n  // week and after `end` in the last are left empty rather than filled in.\n  const columns = React.useMemo(() => {\n    const start = new Date(startTime);\n    const end = new Date(endTime);\n    const result: (Date | null)[][] = [];\n    let cursor = addDays(start, -start.getDay());\n    while (cursor <= end) {\n      const week: (Date | null)[] = [];\n      for (let i = 0; i < 7; i++) {\n        const day = addDays(cursor, i);\n        week.push(day < start || day > end ? null : day);\n      }\n      result.push(week);\n      cursor = addDays(cursor, 7);\n    }\n    return result;\n  }, [startTime, endTime]);\n\n  const max = React.useMemo(\n    () => data.reduce((acc, d) => Math.max(acc, d.value), 0),\n    [data],\n  );\n\n  // Totals cover the days on screen, not every datum passed in.\n  const stats = React.useMemo(() => {\n    let total = 0;\n    let activeDays = 0;\n    let busiest: Date | null = null;\n    let busiestValue = 0;\n    for (const week of columns)\n      for (const day of week) {\n        if (!day) continue;\n        const value = values.get(toKey(day)) ?? 0;\n        if (value > 0) {\n          total += value;\n          activeDays += 1;\n        }\n        if (value > busiestValue) {\n          busiestValue = value;\n          busiest = day;\n        }\n      }\n    return { total, activeDays, busiest: busiest as Date | null };\n  }, [columns, values]);\n\n  // Month labels span the weeks whose first shown day falls in that month.\n  const months = React.useMemo(() => {\n    const groups: { label: string; from: number; to: number }[] = [];\n    const formatter = new Intl.DateTimeFormat(\"en-US\", { month: \"short\" });\n    columns.forEach((week, index) => {\n      const first = week.find((d): d is Date => d !== null);\n      if (!first) return;\n      const key = `${first.getFullYear()}-${first.getMonth()}`;\n      const last = groups[groups.length - 1];\n      if (last && last.label === key) {\n        last.to = index;\n      } else {\n        groups.push({ label: key, from: index, to: index });\n      }\n    });\n    return groups\n      .filter((g) => g.to - g.from >= 1)\n      .map((g) => ({\n        ...g,\n        label: formatter.format(columns[g.from]!.find(Boolean) as Date),\n      }));\n  }, [columns]);\n\n  const palette = colors && colors.length > 1 ? colors : mixedColors(color, 5);\n  const levels = palette.length;\n\n  const dateFormatter = new Intl.DateTimeFormat(\"en-US\", {\n    weekday: \"short\",\n    month: \"short\",\n    day: \"numeric\",\n    year: \"numeric\",\n  });\n\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const scrollRef = React.useRef<HTMLDivElement>(null);\n  const gridRef = React.useRef<HTMLDivElement>(null);\n  const tipRef = React.useRef<HTMLDivElement>(null);\n  const [active, setActive] = React.useState<string | null>(null);\n  const [tabStop, setTabStop] = React.useState<string | null>(null);\n  // Which edges have more weeks hidden behind them, so they can fade out.\n  const [edges, setEdges] = React.useState({ start: false, end: false });\n  const [anchor, setAnchor] = React.useState<{\n    x: number;\n    top: number;\n    bottom: number;\n  } | null>(null);\n\n  const updateEdges = React.useCallback(() => {\n    const node = scrollRef.current;\n    if (!node) return;\n    const start = node.scrollLeft > 1;\n    const end = node.scrollLeft < node.scrollWidth - node.clientWidth - 1;\n    setEdges((current) =>\n      current.start === start && current.end === end ? current : { start, end },\n    );\n  }, []);\n\n  React.useLayoutEffect(() => {\n    const node = scrollRef.current;\n    if (!node) return;\n    if (scrollToEnd) node.scrollLeft = node.scrollWidth;\n    updateEdges();\n    const observer = new ResizeObserver(updateEdges);\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, [scrollToEnd, columns.length, cellSize, gap, updateEdges]);\n\n  const measure = React.useCallback(() => {\n    const root = rootRef.current;\n    const cell = active\n      ? gridRef.current?.querySelector<HTMLElement>(`[data-date=\"${active}\"]`)\n      : null;\n    if (!root || !cell) {\n      setAnchor(null);\n      return;\n    }\n    const box = root.getBoundingClientRect();\n    const rect = cell.getBoundingClientRect();\n    setAnchor({\n      x: rect.left + rect.width / 2 - box.left,\n      top: rect.top - box.top,\n      bottom: rect.bottom - box.top,\n    });\n  }, [active]);\n\n  useIsomorphicLayoutEffect(measure, [measure, columns]);\n\n  useIsomorphicLayoutEffect(() => {\n    const tip = tipRef.current;\n    const root = rootRef.current;\n    if (!tip || !root || !anchor) return;\n    const width = tip.offsetWidth;\n    const height = tip.offsetHeight;\n    const left = Math.min(\n      Math.max(anchor.x - width / 2, 0),\n      Math.max(0, root.clientWidth - width),\n    );\n    const below = anchor.top - height - 8 < -4;\n    const y = below ? anchor.bottom + 8 : anchor.top - height - 8;\n    tip.style.transform = `translate3d(${Math.round(left)}px, ${Math.round(y)}px, 0)`;\n  });\n\n  // The roving tab stop defaults to the most recent day on screen.\n  const lastKey = React.useMemo(() => {\n    for (let w = columns.length - 1; w >= 0; w--)\n      for (let d = 6; d >= 0; d--) {\n        const day = columns[w]![d];\n        if (day) return toKey(day);\n      }\n    return null;\n  }, [columns]);\n  const stopKey =\n    tabStop &&\n    columns.some((week) => week.some((day) => day && toKey(day) === tabStop))\n      ? tabStop\n      : lastKey;\n\n  const onKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n    const target = event.target as HTMLElement;\n    const key = target.dataset.date;\n    if (!key) return;\n    const [y, m, d] = key.split(\"-\").map(Number);\n    const day = new Date(y!, m! - 1, d!);\n    const offsets: Record<string, number> = {\n      ArrowRight: 7,\n      ArrowLeft: -7,\n      ArrowDown: 1,\n      ArrowUp: -1,\n    };\n    const offset = offsets[event.key];\n    if (offset === undefined) return;\n    event.preventDefault();\n    const next = gridRef.current?.querySelector<HTMLElement>(\n      `[data-date=\"${toKey(addDays(day, offset))}\"]`,\n    );\n    next?.focus();\n  };\n\n  const hasHeader = showMonthLabels;\n  const hasWeekdays = weekdayLabels !== \"none\";\n  const fontSize = Math.max(10, Math.min(11, cellSize));\n  const radius = Math.max(2, Math.round(cellSize / 4));\n  const stagger = Math.min(9, 520 / Math.max(1, columns.length + 7));\n\n  const activeDate = active\n    ? (() => {\n        const [y, m, d] = active.split(\"-\").map(Number);\n        return new Date(y!, m! - 1, d!);\n      })()\n    : null;\n  const activeValue = active ? (values.get(active) ?? 0) : 0;\n  const activeLevel = active ? levelFor(activeValue, max, levels, scale) : null;\n  const activeWeek = active\n    ? columns.findIndex((week) =>\n        week.some((day) => day != null && toKey(day) === active),\n      )\n    : -1;\n\n  const tooltipBody = activeDate ? (\n    renderTooltip ? (\n      renderTooltip({ date: activeDate, value: activeValue })\n    ) : (\n      <div className=\"grid min-w-44 gap-1\">\n        <div className=\"flex items-center gap-2\">\n          <span\n            aria-hidden=\"true\"\n            className=\"size-2.5 shrink-0 rounded-[3px] inset-ring inset-ring-foreground/10\"\n            style={{ backgroundColor: palette[activeLevel ?? 0] }}\n          />\n          <span className=\"font-medium text-foreground\">\n            {dateFormatter.format(activeDate)}\n          </span>\n          <span className=\"ml-auto pl-4 font-semibold text-foreground tabular-nums\">\n            {valueFormatter(activeValue)}\n            <span className=\"ml-1 font-normal text-muted-foreground\">\n              {unit}\n            </span>\n          </span>\n        </div>\n        {stats.busiest && toKey(stats.busiest) === active ? (\n          <div className=\"pl-[18px] text-[11px] text-muted-foreground\">\n            Busiest day in view\n          </div>\n        ) : null}\n      </div>\n    )\n  ) : null;\n\n  return (\n    <div\n      ref={rootRef}\n      data-slot=\"activity-heatmap\"\n      className={cn(\"relative flex min-w-0 flex-col gap-3 text-xs\", className)}\n      {...props}\n    >\n      <style href=\"overtrue-activity-heatmap\" precedence=\"default\">\n        {`@keyframes activity-heatmap-in{from{opacity:0;transform:scale(.4)}}`}\n      </style>\n      <div className=\"flex min-w-0\">\n        {hasWeekdays ? (\n          <div\n            aria-hidden\n            className=\"grid shrink-0 pt-1 pr-1.5\"\n            style={{\n              gap,\n              gridTemplateRows: `${hasHeader ? `${fontSize}px` : \"0px\"} repeat(7, ${cellSize}px)`,\n            }}\n          >\n            <div />\n            {WEEKDAYS.map((day, index) => (\n              <div\n                key={day}\n                data-active={activeDate?.getDay() === index || undefined}\n                className=\"flex items-center leading-none whitespace-nowrap text-muted-foreground transition-colors duration-150 data-[active]:text-foreground motion-reduce:transition-none\"\n                style={{ fontSize }}\n              >\n                {weekdayLabels === \"all\" ||\n                index % 2 === 1 ||\n                activeDate?.getDay() === index\n                  ? day\n                  : \"\"}\n              </div>\n            ))}\n          </div>\n        ) : null}\n        <div\n          ref={scrollRef}\n          onScroll={() => {\n            measure();\n            updateEdges();\n          }}\n          style={{\n            maskImage:\n              edges.start || edges.end\n                ? `linear-gradient(to right, ${edges.start ? \"transparent, #000 28px\" : \"#000\"}, ${edges.end ? \"#000 calc(100% - 28px), transparent\" : \"#000\"})`\n                : undefined,\n          }}\n          className=\"min-w-0 flex-1 overflow-x-auto overscroll-x-contain p-1 [scrollbar-color:color-mix(in_oklab,var(--color-foreground)_20%,transparent)_transparent] [scrollbar-width:thin]\"\n        >\n          <div\n            ref={gridRef}\n            role=\"group\"\n            aria-label=\"Activity heatmap\"\n            className=\"grid w-max\"\n            style={{\n              gap,\n              gridTemplateColumns: `repeat(${columns.length}, ${cellSize}px)`,\n              gridTemplateRows: `${hasHeader ? `${fontSize}px` : \"0px\"} repeat(7, ${cellSize}px)`,\n            }}\n            onPointerOver={(event) => {\n              const key = (event.target as HTMLElement).dataset?.date;\n              setActive(key ?? null);\n            }}\n            onPointerLeave={() => setActive(null)}\n            onKeyDown={onKeyDown}\n            onBlur={(event) => {\n              if (!event.currentTarget.contains(event.relatedTarget as Node))\n                setActive(null);\n            }}\n          >\n            {hasHeader\n              ? months.map((month) => (\n                  <div\n                    key={`${month.from}-${month.label}`}\n                    data-active={\n                      (activeWeek >= month.from && activeWeek <= month.to) ||\n                      undefined\n                    }\n                    className=\"self-end leading-none whitespace-nowrap text-muted-foreground transition-colors duration-150 data-[active]:text-foreground motion-reduce:transition-none\"\n                    style={{\n                      gridRow: 1,\n                      gridColumn: `${month.from + 1} / ${month.to + 2}`,\n                      fontSize,\n                    }}\n                  >\n                    {month.label}\n                  </div>\n                ))\n              : null}\n\n            {columns.map((week, weekIndex) =>\n              week.map((day, dayIndex) => {\n                const style: React.CSSProperties = {\n                  gridColumn: weekIndex + 1,\n                  gridRow: dayIndex + 2,\n                };\n                if (!day) {\n                  return <div key={dayIndex} aria-hidden style={style} />;\n                }\n                const key = toKey(day);\n                const value = values.get(key) ?? 0;\n                const level = levelFor(value, max, levels, scale);\n                const datum = { date: day, value };\n                const label = `${valueFormatter(value)} ${unit} on ${dateFormatter.format(day)}`;\n\n                return (\n                  <button\n                    key={dayIndex}\n                    type=\"button\"\n                    aria-label={label}\n                    data-slot=\"activity-heatmap-cell\"\n                    data-level={level}\n                    data-date={key}\n                    data-active={active === key || undefined}\n                    tabIndex={key === stopKey ? 0 : -1}\n                    onFocus={() => {\n                      setTabStop(key);\n                      setActive(key);\n                    }}\n                    onClick={onCellClick ? () => onCellClick(datum) : undefined}\n                    className={cn(\n                      \"relative inset-ring inset-ring-foreground/6 outline-0 outline-offset-1 outline-transparent\",\n                      \"transition-[background-color,outline-color] [transition-duration:450ms,150ms] [transition-timing-function:cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none\",\n                      \"data-[active]:z-10 data-[active]:outline-2 data-[active]:outline-foreground/85\",\n                      \"focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-ring\",\n                      \"dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.05)]\",\n                      !reduced &&\n                        \"motion-safe:animate-[activity-heatmap-in_600ms_cubic-bezier(0.22,1,0.36,1)_backwards]\",\n                      onCellClick ? \"cursor-pointer\" : \"cursor-default\",\n                    )}\n                    style={{\n                      ...style,\n                      borderRadius: radius,\n                      backgroundColor: palette[level],\n                      animationDelay: reduced\n                        ? undefined\n                        : `${Math.round((weekIndex + dayIndex) * stagger)}ms`,\n                    }}\n                  />\n                );\n              }),\n            )}\n          </div>\n        </div>\n      </div>\n\n      {anchor && tooltipBody !== null && tooltipBody !== undefined ? (\n        <div\n          ref={tipRef}\n          aria-hidden=\"true\"\n          data-slot=\"activity-heatmap-tooltip\"\n          className={cn(\n            \"pointer-events-none absolute top-0 left-0 z-20 w-max max-w-72 rounded-xl border border-border/70 bg-popover/90 px-3 py-2 text-xs text-popover-foreground shadow-xl backdrop-blur-md\",\n            !reduced &&\n              \"transition-transform duration-150 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none\",\n          )}\n        >\n          {tooltipBody}\n        </div>\n      ) : null}\n\n      {showLegend || showSummary ? (\n        <div className=\"flex flex-wrap items-center justify-between gap-x-6 gap-y-2\">\n          {showSummary ? (\n            <p\n              data-slot=\"activity-heatmap-summary\"\n              className=\"m-0 flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-muted-foreground\"\n            >\n              <span>\n                <span className=\"font-medium text-foreground tabular-nums\">\n                  {valueFormatter(stats.total)}\n                </span>{\" \"}\n                {unit}\n              </span>\n              <span aria-hidden=\"true\" className=\"text-border\">\n                /\n              </span>\n              <span>\n                <span className=\"font-medium text-foreground tabular-nums\">\n                  {stats.activeDays.toLocaleString(\"en-US\")}\n                </span>{\" \"}\n                active {stats.activeDays === 1 ? \"day\" : \"days\"}\n              </span>\n            </p>\n          ) : (\n            <span />\n          )}\n          {showLegend ? (\n            <div\n              data-slot=\"activity-heatmap-legend\"\n              className=\"ml-auto flex items-center gap-1 text-muted-foreground\"\n              style={{ fontSize }}\n            >\n              <span className=\"mr-1\">Less</span>\n              {palette.map((fill, level) => {\n                const from = levelFloor(level, max, levels, scale);\n                const to = levelFloor(level + 1, max, levels, scale);\n                const range =\n                  level === 0\n                    ? `No ${unit}`\n                    : level === 1\n                      ? `Up to ${valueFormatter(to)} ${unit}`\n                      : `${valueFormatter(from)}–${valueFormatter(to)} ${unit}`;\n                return (\n                  <span\n                    key={level}\n                    title={range}\n                    data-active={activeLevel === level || undefined}\n                    className=\"inset-ring inset-ring-foreground/6 outline-0 outline-offset-1 outline-transparent transition-[outline-color] duration-150 data-[active]:outline-2 data-[active]:outline-foreground/85 motion-reduce:transition-none\"\n                    style={{\n                      width: cellSize,\n                      height: cellSize,\n                      borderRadius: radius,\n                      backgroundColor: fill,\n                    }}\n                  />\n                );\n              })}\n              <span className=\"ml-1\">More</span>\n            </div>\n          ) : null}\n        </div>\n      ) : null}\n    </div>\n  );\n}\n\nexport { ActivityHeatmap };\n"
    },
    {
      "path": "src/registry/overtrue/metric-format.tsx",
      "type": "registry:component",
      "target": "components/overtrue/metric-format.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\nexport type NumberFormat = \"number\" | \"compact\" | \"currency\" | \"percent\";\n\nexport interface FormatNumberOptions {\n  format?: NumberFormat;\n  /** ISO 4217 code, used when format is \"currency\". Defaults to USD. */\n  currency?: string;\n  locale?: string;\n  maximumFractionDigits?: number;\n  /** Abbreviate large values, e.g. \"$158K\" instead of \"$158,143\". */\n  compact?: boolean;\n}\n\nconst formatterCache = new Map<string, Intl.NumberFormat>();\n\nfunction getFormatter(locale: string, options: Intl.NumberFormatOptions) {\n  const key = locale + JSON.stringify(options);\n  let formatter = formatterCache.get(key);\n  if (!formatter) {\n    formatter = new Intl.NumberFormat(locale, options);\n    formatterCache.set(key, formatter);\n  }\n  return formatter;\n}\n\n/**\n * Format a metric value for display.\n *\n * formatNumber(1234567)                          -> \"1,234,567\"\n * formatNumber(1234567, { format: \"compact\" })   -> \"1.2M\"\n * formatNumber(48.2, { format: \"currency\" })     -> \"$48.20\"\n * formatNumber(158143, { format: \"currency\", compact: true }) -> \"$158K\"\n * formatNumber(0.124, { format: \"percent\" })     -> \"12.4%\"\n */\nexport function formatNumber(\n  value: number,\n  {\n    format = \"number\",\n    currency = \"USD\",\n    locale = \"en-US\",\n    maximumFractionDigits,\n    compact = false,\n  }: FormatNumberOptions = {},\n): string {\n  if (!Number.isFinite(value)) return \"—\";\n\n  // Compact values keep three significant digits: $158K, $1.23M, 41.2K.\n  const compactOptions: Intl.NumberFormatOptions = compact\n    ? maximumFractionDigits === undefined\n      ? { notation: \"compact\", maximumSignificantDigits: 3 }\n      : { notation: \"compact\", maximumFractionDigits }\n    : {};\n  switch (format) {\n    case \"compact\":\n      return getFormatter(locale, {\n        notation: \"compact\",\n        maximumFractionDigits: maximumFractionDigits ?? 1,\n      }).format(value);\n    case \"currency\":\n      return getFormatter(locale, {\n        style: \"currency\",\n        currency,\n        maximumFractionDigits: maximumFractionDigits ?? 2,\n        ...compactOptions,\n      }).format(value);\n    case \"percent\":\n      return getFormatter(locale, {\n        style: \"percent\",\n        maximumFractionDigits: maximumFractionDigits ?? 1,\n      }).format(value);\n    default:\n      return getFormatter(locale, {\n        maximumFractionDigits: maximumFractionDigits ?? 0,\n        ...compactOptions,\n      }).format(value);\n  }\n}\n\n/**\n * Format a fractional change as a signed percentage.\n *\n * formatDelta(0.124)  -> \"+12.4%\"\n * formatDelta(-0.03)  -> \"-3.0%\"\n * formatDelta(0)      -> \"0.0%\"\n */\nexport function formatDelta(delta: number, locale = \"en-US\"): string {\n  if (!Number.isFinite(delta)) return \"—\";\n  return getFormatter(locale, {\n    style: \"percent\",\n    signDisplay: \"exceptZero\",\n    maximumFractionDigits: 1,\n    minimumFractionDigits: 1,\n  }).format(delta);\n}\n\n/**\n * Fractional change between two values. Returns 0 when there is no baseline.\n */\nexport function computeDelta(current: number, previous: number): number {\n  if (!previous) return 0;\n  return (current - previous) / Math.abs(previous);\n}\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/activity-heatmap. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
