{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rolling-text",
  "title": "Rolling Text",
  "description": "Text that rolls up to its next value: the old text slides out the top as the new one slides in, and it swaps in place under reduced motion.",
  "files": [
    {
      "path": "registry/components/dashboardblocks/rolling-text.tsx",
      "content": "'use client'\n\nimport { type ComponentProps, useEffect, useRef, useState } from 'react'\n\nimport { cn } from '@/lib/utils'\n\ninterface RollingTextProps extends ComponentProps<'span'> {\n  /**\n   * Rolls to each new value. Turn it off while the value changes faster than a roll can play,\n   * such as during a drag, and it swaps in place.\n   * @default true\n   */\n  roll?: boolean\n  text: string\n  /** Wraps onto more lines instead of cutting the text short, and grows or shrinks with the text. */\n  wrap?: boolean\n}\n\n/** Text that rolls up to its next value. */\nfunction RollingText({\n  className,\n  roll = true,\n  style,\n  text,\n  wrap = false,\n  ...props\n}: RollingTextProps) {\n  const [shown, setShown] = useState({\n    previous: null as string | null,\n    roll: true,\n    text,\n  })\n\n  if (shown.text !== text) setShown({ previous: roll ? shown.text : null, roll, text })\n\n  const content = useRef<HTMLSpanElement>(null)\n  const [height, setHeight] = useState<number | null>(null)\n\n  useEffect(() => {\n    const node = content.current\n    if (!wrap || !node) return\n    const observer = new ResizeObserver(() => setHeight(node.offsetHeight))\n    observer.observe(node)\n    return () => observer.disconnect()\n  }, [wrap])\n\n  useEffect(() => {\n    if (shown.previous === null) return\n    const timer = setTimeout(\n      () => setShown((current) => ({ ...current, previous: null })),\n      300,\n    )\n    return () => clearTimeout(timer)\n  }, [shown])\n\n  return (\n    <span\n      data-slot='rolling-text'\n      className={cn(\n        'relative block overflow-hidden',\n        wrap &&\n          shown.roll &&\n          'transition-[height] duration-300 ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none',\n        className,\n      )}\n      style={wrap && height !== null ? { ...style, height } : style}\n      {...props}\n    >\n      {shown.previous !== null && (\n        <span\n          aria-hidden\n          className={cn(\n            'motion-safe:animate-out motion-safe:fade-out motion-safe:slide-out-to-top-3 absolute inset-x-0 top-0 duration-300 fill-mode-forwards motion-reduce:hidden',\n            wrap ? 'text-pretty' : 'truncate',\n          )}\n        >\n          {shown.previous}\n        </span>\n      )}\n      <span ref={content} className='block'>\n        <span\n          key={text}\n          className={cn(\n            'block',\n            shown.roll &&\n              'motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-3 duration-300',\n            wrap ? 'text-pretty break-words' : 'truncate',\n          )}\n        >\n          {text}\n        </span>\n      </span>\n    </span>\n  )\n}\n\nexport { RollingText }\nexport type { RollingTextProps }\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/rolling-text.tsx"
    }
  ],
  "type": "registry:component"
}
