'use client'; /** * `` — a compact, presentational chip for a LOCAL file path * (Cursor / VSCode / Finder style): the extension-correct file icon + * a smart middle-ellipsized label, monospace, with the full path on hover. * * Standalone by design — it imports only the pure detector helpers and the * shared `FileIcon`, so it can render a known path in a chat message, * a file list, etc., entirely outside the TipTap editor. * * Presentational only: it never mutates or links anything. Inside the * editor the SAME visual is reproduced by the `editorChip` atom NODE * (see `../chip/ChipNode.ts`, `kind: 'path'`) — this component is the * React/standalone counterpart, still useful for rendering a known path * outside the editor (chat messages, file lists). */ import { cn } from '@djangocfg/ui-core/lib'; import { FileIcon } from '../../../visual/design/FileIcon'; import { splitPath, truncatePathLabel } from './detect'; export interface FilePathChipProps { /** The full, raw file path (Unix / macOS / Windows / UNC / `file://`). */ path: string; /** * Approximate max characters for the truncated label. The basename is * always preserved; only the middle collapses. Default 40. */ maxChars?: number; /** Icon size in px. Default 14 (matches inline text). */ iconSize?: 12 | 14 | 16; className?: string; } /** * Render a path as an inline chip. Uses the folder icon when the path * resolves to a directory (no file extension / trailing separator). */ export function FilePathChip({ path, maxChars = 40, iconSize = 14, className, }: FilePathChipProps) { const { base, isDir } = splitPath(path); const label = truncatePathLabel(path, { maxChars }); return ( {label} ); } export default FilePathChip;