/** * Rich URL & media rendering primitives. * * A URL is never shown raw. Depending on what it points at we render: * - an IMAGE (jpg/png/gif/webp/… or a `link.asteby.com/storage/media/` path) * → an inline clickable THUMBNAIL that opens the full image in a new tab, * - a FILE (pdf/zip/docx/…) → a chip with a file icon and the file name, * - anything else → a compact link CHIP: an external-link glyph plus a short * smart label (hostname, e.g. "github.com", or the last path segment for a * file-like URL), with the full URL in a native tooltip. * * These live here (not inline in the table/dialog) so the dynamic TABLE cell * (`dynamic-columns.tsx`) and the read-only DETAIL DIALOG (`dynamic-record.tsx`) * share the EXACT same rendering. Ecosystem rule: shared primitives, zero copy. * * No external requests are made to render a link (no favicon service — CSP / * privacy): the icon is a local lucide glyph. */ import React from 'react'; export type UrlKind = 'image' | 'file' | 'link'; /** `true` when the string looks like an image URL/path. */ export declare function isImageUrl(url: string): boolean; /** `true` when the string looks like a non-image downloadable file. */ export declare function isFileUrl(url: string): boolean; /** Classify a URL so the right primitive (thumbnail / file chip / link) renders. */ export declare function classifyUrl(url: string): UrlKind; /** * Ensure a URL is safe to drop into `` / `new URL(..., base)`. * * Three shapes pass through unchanged: fully qualified (`http(s)://…`), * protocol-relative (`//…`), and — the platform's own convention for every * locally-served asset (uploads, hub-generated images, printable documents: * see handlers.UploadFile, hub_image_provider_bridge.go, …) — ROOT-RELATIVE * (`/storage/…`). A root-relative path already resolves correctly against * the current origin; treating it as a bare host (the old behavior) produced * "https:///storage/…" (scheme + empty host), a broken link. Anything else * (`github.com/foo`) is assumed to be a bare host missing its scheme. */ export declare function ensureHref(url: string): string; /** * A short, human label for a URL. For a file-like URL (last segment carries an * extension) the file name wins ("report.pdf"); otherwise the bare hostname * ("github.com"), so a 120-char issue URL never shows raw. Falls back to the * input when it can't be parsed. */ export declare function smartUrlLabel(url: string): string; /** Last path segment (decoded) — the file name for a file/image URL. */ export declare function fileNameFromUrl(url: string): string; /** * Compact link chip: external-link glyph + smart label, full URL in the * tooltip, opens in a new tab. The canonical render for a plain (non-media) * URL, matching the table's `url`/`link` cell. */ export declare const UrlChip: React.FC<{ url: string; label?: string; icon?: string; /** Smaller label cap for a table/kanban cell. */ maxLabelWidth?: number; className?: string; }>; /** * Chip for a downloadable non-image file: file-text glyph + the file name, * opens the file in a new tab. */ export declare const FileChip: React.FC<{ url: string; maxLabelWidth?: number; className?: string; }>; /** * Inline image thumbnail — rounded, bordered, `object-cover` — that opens a * full-size PREVIEW (a lightbox dialog, not a new tab). On load error it * degrades to a normal link chip so a dead image URL is still reachable (and * never a broken-image icon). `maxHeight` keeps a cell thumbnail small * (~h-8) while the dialog shows a larger preview. */ export declare const ImageThumbnail: React.FC<{ url: string; getImageUrl?: (path: string) => string; /** Max rendered height in px. */ maxHeight?: number; className?: string; }>; /** * One URL value → the right primitive (thumbnail / file chip / link chip). * Single entry point used by both the table cell and the detail dialog so a URL * renders identically everywhere. */ export declare const MediaValue: React.FC<{ url: string; getImageUrl?: (path: string) => string; /** Explicit label for the link chip (from a `label_field`). */ label?: string; /** Explicit icon for the link chip. */ icon?: string; /** Thumbnail max height (small in a cell, larger in the dialog). */ thumbHeight?: number; /** Link/file label truncation cap. */ maxLabelWidth?: number; className?: string; }>; /** * Peel trailing punctuation a URL shouldn't swallow (sentence period, closing * bracket, quote). A closing paren is kept only when the URL itself opened one * (Wikipedia-style `(…)` paths), so `(see https://x.com/a)` links `https://x.com/a` * but `https://en.wikipedia.org/wiki/Foo_(bar)` keeps its paren. */ export declare function splitTrailingPunct(match: string): [string, string]; export interface LinkifyOptions { getImageUrl?: (path: string) => string; /** Max height for an inline image found in the text. */ imageHeight?: number; } /** * Turn free text into React nodes, replacing every URL (bare or markdown * `[label](url)`) with the matching rich primitive: an inline thumbnail for an * image URL, a file chip for a file, otherwise a link chip. Plain text between * matches is preserved verbatim (caller keeps `whitespace-pre-wrap`). */ export declare function linkifyText(text: string, opts?: LinkifyOptions): React.ReactNode[]; /** * Linkified free text. Renders the raw string with every URL turned into a rich * chip/thumbnail — the read view for a long-text / textarea / body field. */ export declare const RichText: React.FC<{ text: string; getImageUrl?: (path: string) => string; imageHeight?: number; }>; //# sourceMappingURL=rich-url.d.ts.map