{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "middle-truncate",
  "title": "MiddleTruncate",
  "description": "Shortens the middle of a path or ID and keeps both ends.",
  "registryDependencies": [
    "https://creance.pages.dev/r/creance-base.json"
  ],
  "files": [
    {
      "path": "middle-truncate/MiddleTruncate.css",
      "content": ".cr-middle-truncate {\n  white-space: nowrap;\n}\n\n.cr-middle-truncate[data-mono] {\n  font-family: var(--cr-font-family-mono);\n  font-size: 0.93em;\n}\n",
      "type": "registry:file",
      "target": "@components/creance/middle-truncate/MiddleTruncate.css"
    },
    {
      "path": "middle-truncate/MiddleTruncate.tsx",
      "content": "import type { HTMLAttributes } from 'react';\nimport { cx } from '@/lib/creance/cx';\nimport './MiddleTruncate.css';\n\nexport interface MiddleTruncateProps extends HTMLAttributes<HTMLSpanElement> {\n  text: string;\n  /** Characters kept at the start. Default 14. */\n  start?: number;\n  /** Characters kept at the end. Default 16. */\n  end?: number;\n  /** Monospace, for IDs and paths. Default true. */\n  mono?: boolean;\n}\n\n/** Shortens the middle, where paths and IDs are alike, and keeps the start and end, where they differ. */\nexport function MiddleTruncate({ text, start = 14, end = 16, mono = true, className, ...props }: MiddleTruncateProps) {\n  const short = text.length > start + end + 1 ? `${text.slice(0, start)}…${text.slice(-end)}` : text;\n  return (\n    <span className={cx('cr-middle-truncate', className)} data-mono={mono || undefined} title={text} {...props}>\n      {short === text ? (\n        text\n      ) : (\n        <>\n          <span aria-hidden=\"true\">{short}</span>\n          <span className=\"cr-visually-hidden\">{text}</span>\n        </>\n      )}\n    </span>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/creance/middle-truncate/MiddleTruncate.tsx"
    }
  ],
  "categories": [
    "atom",
    "data-display"
  ],
  "type": "registry:ui"
}