{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cell-flash",
  "title": "Cell flash",
  "description": "Wraps a table value and briefly flashes it green when it rises, red when it falls, with a fading ▲/▼, like a trading terminal.",
  "dependencies": [],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json"
  ],
  "files": [
    {
      "path": "registry/components/numbers/cell-flash.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\nimport { GooduiTokens } from \"@/lib/goodui-motion\"\n\nconst CSS = `\n@keyframes pc-cell-flash-bg { 0% { opacity: 1 } 100% { opacity: 0 } }\n@keyframes pc-cell-flash-arrow { 0% { opacity: 0; transform: translateY(var(--pc-cell-flash-from)) } 15%, 70% { opacity: 1; transform: translateY(0) } 100% { opacity: 0; transform: translateY(0) } }\n.pc-cell-flash-bg { animation: pc-cell-flash-bg var(--pc-cell-flash-duration, 900ms) var(--pc-ease-in-out) forwards; }\n.pc-cell-flash-arrow { animation: pc-cell-flash-arrow var(--pc-cell-flash-duration, 900ms) ease-out forwards; }\n@media (prefers-reduced-motion: reduce) {\n  .pc-cell-flash-arrow { animation-name: pc-cell-flash-bg; transform: none }\n}\n`\n\nexport type CellFlashDirection = \"up\" | \"down\" | \"neutral\"\n\nexport type CellFlashProps = Omit<React.ComponentProps<\"span\">, \"children\"> & {\n  /** The value to watch. Numbers flash green when they rise and red when they fall; other values flash neutral. */\n  value: number | string\n  /** Rendered content. Defaults to the value. */\n  children?: React.ReactNode\n  /** Force a direction instead of comparing with the previous value. */\n  direction?: CellFlashDirection\n  /** Flash length in ms. */\n  duration?: number\n  /** Show a small ▲/▼ that fades out with the flash. */\n  indicator?: boolean\n}\n\nconst BG: Record<CellFlashDirection, string> = {\n  up: \"bg-emerald-500/20 dark:bg-emerald-400/20\",\n  down: \"bg-rose-500/20 dark:bg-rose-400/20\",\n  neutral: \"bg-sky-500/20 dark:bg-sky-400/20\",\n}\nconst FG: Record<CellFlashDirection, string> = {\n  up: \"text-emerald-700 dark:text-emerald-400\",\n  down: \"text-rose-700 dark:text-rose-400\",\n  neutral: \"text-sky-700 dark:text-sky-400\",\n}\n\n/** Briefly highlights a value when it changes, green for up and red for down, like a trading terminal. */\nexport function CellFlash({ value, children, direction, duration = 900, indicator = true, className, style, ...props }: CellFlashProps) {\n  // Track changes during render so the flash and the new value paint in the same frame.\n  const [state, setState] = React.useState<{ value: number | string; count: number; dir: CellFlashDirection }>({ value, count: 0, dir: \"neutral\" })\n  if (!Object.is(state.value, value)) {\n    const dir: CellFlashDirection =\n      direction ?? (typeof value === \"number\" && typeof state.value === \"number\" ? (value > state.value ? \"up\" : value < state.value ? \"down\" : \"neutral\") : \"neutral\")\n    setState({ value, count: state.count + 1, dir })\n  }\n  const { count, dir } = state\n  const vars = { [\"--pc-cell-flash-duration\" as string]: `${duration}ms`, [\"--pc-cell-flash-from\" as string]: dir === \"down\" ? \"-3px\" : \"3px\" }\n\n  return (\n    <span\n      data-direction={count > 0 ? dir : undefined}\n      className={cn(\"relative -mx-1.5 inline-flex items-center rounded-md px-1.5 tabular-nums\", className)}\n      style={{ ...vars, ...style }}\n      {...props}\n    >\n      <GooduiTokens />\n      <style href=\"pc-cell-flash\" precedence=\"default\">\n        {CSS}\n      </style>\n      {count > 0 && <span key={count} aria-hidden=\"true\" className={cn(\"pc-cell-flash-bg pointer-events-none absolute inset-0 rounded-[inherit]\", BG[dir])} />}\n      <span className=\"relative\">{children ?? value}</span>\n      {indicator && count > 0 && dir !== \"neutral\" && (\n        // Positioned outside the text box so the arrow never shifts the layout.\n        <span aria-hidden=\"true\" className=\"pointer-events-none absolute inset-y-0 start-full flex items-center\">\n          <span key={count} className={cn(\"pc-cell-flash-arrow text-[0.6em] leading-none opacity-0\", FG[dir])}>\n            {dir === \"up\" ? \"▲\" : \"▼\"}\n          </span>\n        </span>\n      )}\n    </span>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/cell-flash.tsx"
    }
  ],
  "categories": [
    "components",
    "numbers"
  ],
  "type": "registry:component"
}