Skip to content

armgit / ui

Public Imported from GitHub
0
TypeScript

more components and clean up

Andrew Luoc47c7ac06f45
diff --git a/apps/v4/app/(app)/(root)/page.tsx b/apps/v4/app/(app)/(root)/page.tsx
index 05da23f..e2c6255 100644
--- a/apps/v4/app/(app)/(root)/page.tsx
+++ b/apps/v4/app/(app)/(root)/page.tsx
@@ -3,7 +3,7 @@ import Link from "next/link"
import { ArrowRightIcon } from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"
-import { Announcement } from "@/components/announcement"
+import { Button } from "@/components/ui/button"
import {
PageActions,
PageHeader,
@@ -11,7 +11,6 @@ import {
PageHeaderHeading,
} from "@/components/page-header"
import { Badge } from "@/registry/new-york-v4/ui/badge"
-import { Button } from "@/registry/new-york-v4/ui/button"
import {
Card,
CardContent,
@@ -39,7 +38,10 @@ const featuredComponents = [
"File Upload",
"Drag-and-drop intake with validation, progress, queues, and retry states.",
],
- ["Annotation Layer", "Highlights, pins, rectangles, notes, and anchored review comments."],
+ [
+ "Annotation Layer",
+ "Highlights, pins, rectangles, notes, and anchored review comments.",
+ ],
]
export const dynamic = "force-static"
@@ -73,7 +75,6 @@ export default function IndexPage() {
return (
<div className="flex flex-1 flex-col">
<PageHeader>
- <Announcement />
<PageHeaderHeading className="max-w-4xl">{title}</PageHeaderHeading>
<PageHeaderDescription>{description}</PageHeaderDescription>
<PageActions>
diff --git a/apps/v4/app/(app)/blocks/layout.tsx b/apps/v4/app/(app)/blocks/layout.tsx
index 4a81967..d2f7461 100644
--- a/apps/v4/app/(app)/blocks/layout.tsx
+++ b/apps/v4/app/(app)/blocks/layout.tsx
@@ -1,7 +1,7 @@
import { type Metadata } from "next"
import Link from "next/link"
-import { Announcement } from "@/components/announcement"
+import { Button } from "@/components/ui/button"
import { BlocksNav } from "@/components/blocks-nav"
import {
PageActions,
@@ -10,7 +10,6 @@ import {
PageHeaderHeading,
} from "@/components/page-header"
import { PageNav } from "@/components/page-nav"
-import { Button } from "@/registry/new-york-v4/ui/button"
const title = "Document Blocks"
const description =
@@ -48,7 +47,6 @@ export default function BlocksLayout({
return (
<>
<PageHeader>
- <Announcement />
<PageHeaderHeading>{title}</PageHeaderHeading>
<PageHeaderDescription>{description}</PageHeaderDescription>
<PageActions>
diff --git a/apps/v4/app/(app)/docs/[[...slug]]/page.tsx b/apps/v4/app/(app)/docs/[[...slug]]/page.tsx
index 2ddbad2..91168b6 100644
--- a/apps/v4/app/(app)/docs/[[...slug]]/page.tsx
+++ b/apps/v4/app/(app)/docs/[[...slug]]/page.tsx
@@ -7,10 +7,10 @@ import { findNeighbour } from "fumadocs-core/page-tree"
import { source } from "@/lib/source"
import { absoluteUrl } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
import { DocsCopyPage } from "@/components/docs-copy-page"
import { DocsTableOfContents } from "@/components/docs-toc"
import { ExtendDeployCta } from "@/components/extend-deploy-cta"
-import { Button } from "@/registry/new-york-v4/ui/button"
export const revalidate = false
export const dynamic = "force-static"
diff --git a/apps/v4/components/announcement.tsx b/apps/v4/components/announcement.tsx
deleted file mode 100644
index ffe8bc8..0000000
--- a/apps/v4/components/announcement.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import Link from "next/link"
-import { ArrowRightIcon } from "@hugeicons/core-free-icons"
-import { HugeiconsIcon } from "@hugeicons/react"
-
-import { Badge } from "@/registry/new-york-v4/ui/badge"
-
-export function Announcement() {
- return (
- <Badge asChild variant="secondary" className="bg-muted">
- <Link href="/docs/components/document-thumbnail-strip">
- Thumbnail Tab Switcher <HugeiconsIcon icon={ArrowRightIcon} />
- </Link>
- </Badge>
- )
-}
diff --git a/apps/v4/components/citations-docs.tsx b/apps/v4/components/citations-docs.tsx
new file mode 100644
index 0000000..bda6600
--- /dev/null
+++ b/apps/v4/components/citations-docs.tsx
@@ -0,0 +1,876 @@
+"use client"
+
+import * as React from "react"
+import { Loading03Icon } from "@hugeicons/core-free-icons"
+import { HugeiconsIcon } from "@hugeicons/react"
+import type * as ReactPdf from "react-pdf"
+
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+import { HighlightedCodeBlock } from "@/components/highlighted-code-block"
+
+type Point = {
+ x: number
+ y: number
+}
+
+type Citation = {
+ id: string
+ label: string
+ value: string
+ page: number
+ referenceText: string
+ polygon: Point[]
+}
+
+type HighlightArea = {
+ left: number
+ top: number
+ width: number
+ height: number
+}
+
+type ReactPdfModule = typeof ReactPdf
+
+const PDF_URL = "/samples/attention.pdf"
+const PDF_WORKER_URL = new URL(
+ "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
+ import.meta.url
+).toString()
+const PAGE_WIDTH = 792
+const PAGE_HEIGHT = 612
+const RENDERED_PAGE_WIDTH = 430
+const RENDERED_PAGE_HEIGHT = Math.round(
+ RENDERED_PAGE_WIDTH * (PAGE_HEIGHT / PAGE_WIDTH)
+)
+const DEVICE_PIXEL_RATIO_LIMIT = 2
+const PAGE_RENDER_BUFFER = 2
+const CITATION_STYLE = {
+ active:
+ "border-blue-500/60 bg-blue-500/5 shadow-[0_0_0_1px_rgb(59_130_246_/_8%)]",
+ overlay:
+ "border-blue-500/70 bg-blue-500/12 shadow-[0_4px_16px_rgb(59_130_246_/_12%)]",
+}
+
+const CITATIONS: Citation[] = [
+ {
+ id: "title",
+ label: "Title",
+ value: "Attention Is All You Need",
+ page: 1,
+ referenceText: "Attention Is All You Need",
+ polygon: [
+ { x: 246, y: 188 },
+ { x: 566, y: 188 },
+ { x: 566, y: 222 },
+ { x: 246, y: 222 },
+ ],
+ },
+ {
+ id: "authors",
+ label: "Authors",
+ value:
+ "Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser, Polosukhin",
+ page: 1,
+ referenceText: "Ashish Vaswani ... Illia Polosukhin",
+ polygon: [
+ { x: 92, y: 206 },
+ { x: 698, y: 206 },
+ { x: 698, y: 270 },
+ { x: 92, y: 270 },
+ ],
+ },
+ {
+ id: "abstract",
+ label: "Abstract claim",
+ value:
+ "The Transformer relies entirely on attention mechanisms and avoids recurrence and convolutions.",
+ page: 1,
+ referenceText:
+ "The Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.",
+ polygon: [
+ { x: 108, y: 346 },
+ { x: 692, y: 346 },
+ { x: 692, y: 414 },
+ { x: 108, y: 414 },
+ ],
+ },
+ {
+ id: "bleu",
+ label: "Translation quality",
+ value: "28.4 BLEU on WMT 2014 English-to-German",
+ page: 1,
+ referenceText:
+ "our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task",
+ polygon: [
+ { x: 108, y: 412 },
+ { x: 692, y: 412 },
+ { x: 692, y: 458 },
+ { x: 108, y: 458 },
+ ],
+ },
+ {
+ id: "architecture",
+ label: "Background",
+ value:
+ "Self-attention connects positions in a sequence through constant-time operations.",
+ page: 2,
+ referenceText:
+ "Self-attention connects all positions with a constant number of sequentially executed operations.",
+ polygon: [
+ { x: 76, y: 74 },
+ { x: 718, y: 74 },
+ { x: 718, y: 184 },
+ { x: 76, y: 184 },
+ ],
+ },
+]
+
+function convertPolygonToHighlightArea(polygon: Point[]): HighlightArea {
+ const xValues = polygon.map((point) => point.x)
+ const yValues = polygon.map((point) => point.y)
+ const left = Math.min(...xValues)
+ const right = Math.max(...xValues)
+ const top = Math.min(...yValues)
+ const bottom = Math.max(...yValues)
+
+ return {
+ left: (left / PAGE_WIDTH) * 100,
+ top: (top / PAGE_HEIGHT) * 100,
+ width: ((right - left) / PAGE_WIDTH) * 100,
+ height: ((bottom - top) / PAGE_HEIGHT) * 100,
+ }
+}
+
+function CitationHighlight({ citation }: { citation: Citation }) {
+ const highlight = convertPolygonToHighlightArea(citation.polygon)
+
+ return (
+ <div
+ className={cn(
+ "pointer-events-none absolute z-10 rounded-[3px] border",
+ CITATION_STYLE.overlay
+ )}
+ style={{
+ left: `${highlight.left}%`,
+ top: `${highlight.top}%`,
+ width: `${highlight.width}%`,
+ height: `${highlight.height}%`,
+ }}
+ />
+ )
+}
+
+function CitationPage({
+ pageNumber,
+ activeCitation,
+ reactPdf,
+ shouldRenderPage,
+ onFirstPageRender,
+}: {
+ pageNumber: number
+ activeCitation: Citation | null
+ reactPdf: ReactPdfModule
+ shouldRenderPage: boolean
+ onFirstPageRender?: () => void
+}) {
+ const devicePixelRatio =
+ typeof window === "undefined"
+ ? 1
+ : Math.min(DEVICE_PIXEL_RATIO_LIMIT, window.devicePixelRatio || 1)
+
+ return (
+ <div
+ data-citation-page={pageNumber}
+ className="relative"
+ style={{ width: RENDERED_PAGE_WIDTH, height: RENDERED_PAGE_HEIGHT }}
+ >
+ {shouldRenderPage ? (
+ <reactPdf.Page
+ pageNumber={pageNumber}
+ width={RENDERED_PAGE_WIDTH}
+ className="overflow-hidden border bg-background shadow-xs"
+ renderAnnotationLayer={false}
+ renderTextLayer={false}
+ devicePixelRatio={devicePixelRatio}
+ loading={
+ <div
+ className="grid place-items-center"
+ style={{
+ width: RENDERED_PAGE_WIDTH,
+ height: RENDERED_PAGE_HEIGHT,
+ }}
+ >
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ }
+ onRenderSuccess={pageNumber === 1 ? onFirstPageRender : undefined}
+ onRenderError={pageNumber === 1 ? onFirstPageRender : undefined}
+ />
+ ) : (
+ <div className="size-full border bg-muted/30 shadow-xs" />
+ )}
+ {activeCitation?.page === pageNumber ? (
+ <CitationHighlight citation={activeCitation} />
+ ) : null}
+ </div>
+ )
+}
+
+export function Citations() {
+ const [activeCitationId, setActiveCitationId] = React.useState(
+ CITATIONS[0].id
+ )
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null)
+ const [loadError, setLoadError] = React.useState(false)
+ const [isDocumentLoading, setIsDocumentLoading] = React.useState(true)
+ const [isPageRendering, setIsPageRendering] = React.useState(true)
+ const [numPages, setNumPages] = React.useState<number | null>(null)
+ const [currentPage, setCurrentPage] = React.useState(1)
+ const viewportRef = React.useRef<HTMLDivElement>(null)
+ const activeCitation =
+ CITATIONS.find((citation) => citation.id === activeCitationId) ??
+ CITATIONS[0]
+ const pageNumbers = React.useMemo(() => {
+ return Array.from({ length: numPages ?? 0 }, (_, index) => index + 1)
+ }, [numPages])
+ const isViewerLoading = !reactPdf || isDocumentLoading || isPageRendering
+
+ React.useEffect(() => {
+ let mounted = true
+
+ void import("react-pdf")
+ .then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc = PDF_WORKER_URL
+
+ if (mounted) {
+ setReactPdf(module)
+ }
+ })
+ .catch(() => {
+ if (mounted) {
+ setLoadError(true)
+ setIsDocumentLoading(false)
+ setIsPageRendering(false)
+ }
+ })
+
+ return () => {
+ mounted = false
+ }
+ }, [])
+
+ const handleFirstPageRender = React.useCallback(() => {
+ setIsPageRendering(false)
+ }, [])
+
+ const handleDocumentLoadStart = React.useCallback(() => {
+ setIsDocumentLoading(true)
+ setIsPageRendering(true)
+ setLoadError(false)
+ setNumPages(null)
+ setCurrentPage(1)
+ viewportRef.current?.scrollTo({ top: 0, left: 0 })
+ }, [])
+
+ const handleDocumentLoadSuccess = React.useCallback(
+ ({ numPages }: { numPages: number }) => {
+ setNumPages(numPages)
+ setCurrentPage(1)
+ setIsDocumentLoading(false)
+ setIsPageRendering(true)
+ setLoadError(false)
+ viewportRef.current?.scrollTo({ top: 0, left: 0 })
+ },
+ []
+ )
+
+ const handleDocumentLoadError = React.useCallback(() => {
+ setIsDocumentLoading(false)
+ setIsPageRendering(false)
+ setLoadError(true)
+ setNumPages(null)
+ }, [])
+
+ const updateCurrentPageFromViewport = React.useCallback(() => {
+ const viewport = viewportRef.current
+ if (!viewport || !numPages) {
+ return
+ }
+
+ const viewportRect = viewport.getBoundingClientRect()
+ const viewportCenter = viewportRect.top + viewportRect.height / 2
+ let closestPage = 1
+ let closestDistance = Number.POSITIVE_INFINITY
+
+ viewport
+ .querySelectorAll<HTMLElement>("[data-citation-page]")
+ .forEach((page) => {
+ const pageRect = page.getBoundingClientRect()
+ const pageCenter = pageRect.top + pageRect.height / 2
+ const distance = Math.abs(pageCenter - viewportCenter)
+
+ if (distance < closestDistance) {
+ closestDistance = distance
+ closestPage = Number(page.dataset.citationPage || "1")
+ }
+ })
+
+ setCurrentPage((page) => (page === closestPage ? page : closestPage))
+ }, [numPages])
+
+ React.useEffect(() => {
+ const viewport = viewportRef.current
+ if (!viewport || !numPages) {
+ return
+ }
+
+ let frameId = 0
+ const handleScroll = () => {
+ window.cancelAnimationFrame(frameId)
+ frameId = window.requestAnimationFrame(updateCurrentPageFromViewport)
+ }
+
+ frameId = window.requestAnimationFrame(updateCurrentPageFromViewport)
+ viewport.addEventListener("scroll", handleScroll, { passive: true })
+
+ return () => {
+ window.cancelAnimationFrame(frameId)
+ viewport.removeEventListener("scroll", handleScroll)
+ }
+ }, [numPages, updateCurrentPageFromViewport])
+
+ const scrollToCitation = React.useCallback((citation: Citation) => {
+ setActiveCitationId(citation.id)
+ setCurrentPage(citation.page)
+
+ window.requestAnimationFrame(() => {
+ const viewport = viewportRef.current
+ const page = viewport?.querySelector<HTMLElement>(
+ `[data-citation-page="${citation.page}"]`
+ )
+
+ if (!viewport || !page) return
+
+ const highlight = convertPolygonToHighlightArea(citation.polygon)
+ const pageTop =
+ page.getBoundingClientRect().top -
+ viewport.getBoundingClientRect().top +
+ viewport.scrollTop
+ const targetTop =
+ pageTop + (highlight.top / 100) * RENDERED_PAGE_HEIGHT - 96
+
+ viewport.scrollTo({
+ top: Math.max(0, targetTop),
+ behavior: "smooth",
+ })
+ })
+ }, [])
+
+ return (
+ <div className="grid h-[620px] overflow-hidden bg-background lg:grid-cols-[minmax(0,1fr)_20rem]">
+ <div className="flex min-h-0 min-w-0 flex-col border-b lg:border-r lg:border-b-0">
+ <div className="flex min-h-12 items-center justify-between gap-3 border-b px-3">
+ <div className="text-sm whitespace-nowrap text-primary">
+ Page {currentPage} of {numPages ?? "-"}
+ </div>
+ </div>
+ <div className="relative flex h-full min-h-0 w-full flex-1 bg-muted/30">
+ {isViewerLoading && !loadError ? (
+ <div className="absolute inset-0 z-10 grid place-items-center bg-background">
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ ) : null}
+ {loadError ? (
+ <div className="absolute inset-0 z-10 grid place-items-center bg-background p-6 text-sm text-muted-foreground">
+ Unable to load the PDF preview.
+ </div>
+ ) : null}
+ {reactPdf ? (
+ <reactPdf.Document
+ file={PDF_URL}
+ className={cn(
+ "flex h-full min-h-0 w-full flex-1",
+ (isViewerLoading || loadError) && "invisible"
+ )}
+ loading={null}
+ error={null}
+ onLoadStart={handleDocumentLoadStart}
+ onLoadSuccess={handleDocumentLoadSuccess}
+ onLoadError={handleDocumentLoadError}
+ >
+ <div
+ ref={viewportRef}
+ className={cn(
+ "min-h-0 min-w-0 flex-1 overflow-auto",
+ isPageRendering && !loadError && "invisible"
+ )}
+ >
+ <div className="flex min-h-full w-max min-w-full flex-col items-center justify-start gap-6 p-6">
+ {pageNumbers.map((pageNumber) => (
+ <CitationPage
+ key={pageNumber}
+ pageNumber={pageNumber}
+ activeCitation={activeCitation}
+ reactPdf={reactPdf}
+ shouldRenderPage={
+ Math.abs(pageNumber - currentPage) <= PAGE_RENDER_BUFFER
+ }
+ onFirstPageRender={handleFirstPageRender}
+ />
+ ))}
+ </div>
+ </div>
+ </reactPdf.Document>
+ ) : null}
+ </div>
+ </div>
+ <aside className="flex min-h-0 flex-col">
+ <div className="min-h-0 flex-1 overflow-y-auto p-3">
+ <div className="space-y-2">
+ {CITATIONS.map((citation) => {
+ const isActive = citation.id === activeCitation.id
+
+ return (
+ <button
+ key={citation.id}
+ type="button"
+ onClick={() => scrollToCitation(citation)}
+ onFocus={() => scrollToCitation(citation)}
+ onMouseEnter={() => scrollToCitation(citation)}
+ className={cn(
+ "w-full rounded-lg border bg-background p-3 text-left transition-[border-color,background-color,box-shadow] hover:border-blue-500/50 hover:bg-blue-500/5 focus-visible:border-blue-500/60 focus-visible:ring-2 focus-visible:ring-blue-500/20 focus-visible:outline-none",
+ isActive && CITATION_STYLE.active
+ )}
+ >
+ <div className="flex items-center justify-between gap-3">
+ <div className="text-sm font-medium">{citation.label}</div>
+ <div className="shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground">
+ p. {citation.page}
+ </div>
+ </div>
+ <div className="mt-1 text-sm text-foreground/90">
+ {citation.value}
+ </div>
+ <div className="mt-2 line-clamp-2 text-xs text-muted-foreground">
+ {citation.referenceText}
+ </div>
+ </button>
+ )
+ })}
+ </div>
+ </div>
+ </aside>
+ </div>
+ )
+}
+
+export function CitationsDemo() {
+ const [isCodeVisible, setIsCodeVisible] = React.useState(false)
+
+ return (
+ <div
+ data-slot="component-preview"
+ className="group relative mt-4 mb-12 flex flex-col overflow-hidden rounded-xl border"
+ >
+ <Citations />
+ <div
+ data-slot="code"
+ data-mobile-code-visible={isCodeVisible}
+ className="relative overflow-hidden **:data-[slot=copy-button]:right-4 **:data-[slot=copy-button]:hidden data-[mobile-code-visible=true]:**:data-[slot=copy-button]:flex [&_[data-rehype-pretty-code-figure]]:m-0! [&_[data-rehype-pretty-code-figure]]:rounded-t-none [&_[data-rehype-pretty-code-figure]]:border-t [&_pre]:max-h-72"
+ >
+ {isCodeVisible ? (
+ <HighlightedCodeBlock
+ code={citationsUsageCode}
+ className="rounded-none border-x-0 border-b-0"
+ />
+ ) : (
+ <div className="relative">
+ <HighlightedCodeBlock
+ code={citationsUsageCode}
+ className="rounded-none border-x-0 border-b-0"
+ maxHeightClassName="max-h-56"
+ previewLines={10}
+ showCopy={false}
+ />
+ <div className="absolute inset-0 flex items-center justify-center pb-4">
+ <div
+ className="absolute inset-0"
+ style={{
+ background:
+ "linear-gradient(to top, var(--color-code), color-mix(in oklab, var(--color-code) 60%, transparent), transparent)",
+ }}
+ />
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ className="relative z-10 rounded-lg bg-background text-foreground shadow-none hover:bg-muted dark:bg-background dark:text-foreground dark:hover:bg-muted"
+ onClick={() => setIsCodeVisible(true)}
+ >
+ View Code
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
+
+const citationsUsageCode = `"use client";
+
+import * as React from "react";
+import { Loading03Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import type * as ReactPdf from "react-pdf";
+
+import { cn } from "@/lib/utils";
+
+type ReactPdfModule = typeof ReactPdf;
+
+type Point = { x: number; y: number };
+
+type Citation = {
+ id: string;
+ label: string;
+ value: string;
+ page: number;
+ referenceText: string;
+ polygon: Point[];
+};
+
+const PAGE_WIDTH = 792;
+const PAGE_HEIGHT = 612;
+const RENDERED_PAGE_WIDTH = 430;
+const RENDERED_PAGE_HEIGHT = Math.round(RENDERED_PAGE_WIDTH * (PAGE_HEIGHT / PAGE_WIDTH));
+const PAGE_RENDER_BUFFER = 2;
+const CITATION_STYLE = {
+ active:
+ "border-blue-500/60 bg-blue-500/5 shadow-[0_0_0_1px_rgb(59_130_246_/_8%)]",
+ overlay:
+ "border-blue-500/70 bg-blue-500/12 shadow-[0_4px_16px_rgb(59_130_246_/_12%)]",
+};
+const PDF_URL = "/samples/attention.pdf";
+const PDF_WORKER_URL = new URL(
+ "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
+ import.meta.url,
+).toString();
+
+const CITATIONS: Citation[] = [
+ {
+ id: "title",
+ label: "Title",
+ value: "Attention Is All You Need",
+ page: 1,
+ referenceText: "Attention Is All You Need",
+ polygon: [
+ { x: 246, y: 188 },
+ { x: 566, y: 188 },
+ { x: 566, y: 222 },
+ { x: 246, y: 222 },
+ ],
+ },
+ {
+ id: "architecture",
+ label: "Background",
+ value: "Self-attention connects positions in a sequence through constant-time operations.",
+ page: 2,
+ referenceText:
+ "Self-attention connects all positions with a constant number of sequentially executed operations.",
+ polygon: [
+ { x: 76, y: 74 },
+ { x: 718, y: 74 },
+ { x: 718, y: 184 },
+ { x: 76, y: 184 },
+ ],
+ },
+];
+
+function convertPolygonToHighlightArea(polygon: Point[]) {
+ const xValues = polygon.map((point) => point.x);
+ const yValues = polygon.map((point) => point.y);
+ const left = Math.min(...xValues);
+ const right = Math.max(...xValues);
+ const top = Math.min(...yValues);
+ const bottom = Math.max(...yValues);
+
+ return {
+ left: (left / PAGE_WIDTH) * 100,
+ top: (top / PAGE_HEIGHT) * 100,
+ width: ((right - left) / PAGE_WIDTH) * 100,
+ height: ((bottom - top) / PAGE_HEIGHT) * 100,
+ };
+}
+
+function CitationHighlight({ citation }: { citation: Citation }) {
+ const highlight = convertPolygonToHighlightArea(citation.polygon);
+
+ return (
+ <div
+ className={cn(
+ "pointer-events-none absolute z-10 rounded-[3px] border",
+ CITATION_STYLE.overlay,
+ )}
+ style={{
+ left: highlight.left + "%",
+ top: highlight.top + "%",
+ width: highlight.width + "%",
+ height: highlight.height + "%",
+ }}
+ />
+ );
+}
+
+export function Citations() {
+ const [activeCitationId, setActiveCitationId] = React.useState(CITATIONS[0].id);
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null);
+ const [loadError, setLoadError] = React.useState(false);
+ const [isDocumentLoading, setIsDocumentLoading] = React.useState(true);
+ const [isPageRendering, setIsPageRendering] = React.useState(true);
+ const [numPages, setNumPages] = React.useState<number | null>(null);
+ const [currentPage, setCurrentPage] = React.useState(1);
+ const viewportRef = React.useRef<HTMLDivElement>(null);
+ const activeCitation =
+ CITATIONS.find((citation) => citation.id === activeCitationId) ?? CITATIONS[0];
+ const pageNumbers = React.useMemo(
+ () => Array.from({ length: numPages ?? 0 }, (_, index) => index + 1),
+ [numPages],
+ );
+ const isViewerLoading = !reactPdf || isDocumentLoading || isPageRendering;
+
+ React.useEffect(() => {
+ let mounted = true;
+
+ void import("react-pdf")
+ .then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc = PDF_WORKER_URL;
+
+ if (mounted) setReactPdf(module);
+ })
+ .catch(() => {
+ if (mounted) {
+ setLoadError(true);
+ setIsDocumentLoading(false);
+ setIsPageRendering(false);
+ }
+ });
+
+ return () => {
+ mounted = false;
+ };
+ }, []);
+
+ const handleFirstPageRender = React.useCallback(() => {
+ setIsPageRendering(false);
+ }, []);
+
+ const handleDocumentLoadStart = React.useCallback(() => {
+ setIsDocumentLoading(true);
+ setIsPageRendering(true);
+ setLoadError(false);
+ setNumPages(null);
+ setCurrentPage(1);
+ viewportRef.current?.scrollTo({ top: 0, left: 0 });
+ }, []);
+
+ const handleDocumentLoadSuccess = React.useCallback(({ numPages }: { numPages: number }) => {
+ setNumPages(numPages);
+ setCurrentPage(1);
+ setIsDocumentLoading(false);
+ setIsPageRendering(true);
+ setLoadError(false);
+ viewportRef.current?.scrollTo({ top: 0, left: 0 });
+ }, []);
+
+ const handleDocumentLoadError = React.useCallback(() => {
+ setIsDocumentLoading(false);
+ setIsPageRendering(false);
+ setLoadError(true);
+ setNumPages(null);
+ }, []);
+
+ const updateCurrentPageFromViewport = React.useCallback(() => {
+ const viewport = viewportRef.current;
+ if (!viewport || !numPages) return;
+
+ const viewportRect = viewport.getBoundingClientRect();
+ const viewportCenter = viewportRect.top + viewportRect.height / 2;
+ let closestPage = 1;
+ let closestDistance = Number.POSITIVE_INFINITY;
+
+ viewport.querySelectorAll<HTMLElement>("[data-citation-page]").forEach((page) => {
+ const pageRect = page.getBoundingClientRect();
+ const pageCenter = pageRect.top + pageRect.height / 2;
+ const distance = Math.abs(pageCenter - viewportCenter);
+
+ if (distance < closestDistance) {
+ closestDistance = distance;
+ closestPage = Number(page.dataset.citationPage || "1");
+ }
+ });
+
+ setCurrentPage((page) => (page === closestPage ? page : closestPage));
+ }, [numPages]);
+
+ React.useEffect(() => {
+ const viewport = viewportRef.current;
+ if (!viewport || !numPages) return;
+
+ let frameId = window.requestAnimationFrame(updateCurrentPageFromViewport);
+ const handleScroll = () => {
+ window.cancelAnimationFrame(frameId);
+ frameId = window.requestAnimationFrame(updateCurrentPageFromViewport);
+ };
+
+ viewport.addEventListener("scroll", handleScroll, { passive: true });
+ return () => {
+ window.cancelAnimationFrame(frameId);
+ viewport.removeEventListener("scroll", handleScroll);
+ };
+ }, [numPages, updateCurrentPageFromViewport]);
+
+ function scrollToCitation(citation: Citation) {
+ setActiveCitationId(citation.id);
+ setCurrentPage(citation.page);
+
+ window.requestAnimationFrame(() => {
+ const viewport = viewportRef.current;
+ const page = viewport?.querySelector<HTMLElement>(
+ \`[data-citation-page="\${citation.page}"]\`,
+ );
+
+ if (!viewport || !page) return;
+
+ const highlight = convertPolygonToHighlightArea(citation.polygon);
+ const pageTop =
+ page.getBoundingClientRect().top -
+ viewport.getBoundingClientRect().top +
+ viewport.scrollTop;
+
+ viewport.scrollTo({
+ top: Math.max(0, pageTop + (highlight.top / 100) * RENDERED_PAGE_HEIGHT - 96),
+ behavior: "smooth",
+ });
+ });
+ }
+
+ return (
+ <div className="grid h-[620px] overflow-hidden bg-background lg:grid-cols-[minmax(0,1fr)_20rem]">
+ <div className="flex min-h-0 min-w-0 flex-col border-b lg:border-r lg:border-b-0">
+ <div className="flex min-h-12 items-center justify-between gap-3 border-b px-3">
+ <div className="text-sm whitespace-nowrap text-primary">
+ Page {currentPage} of {numPages ?? "-"}
+ </div>
+ </div>
+ <div className="relative flex h-full min-h-0 w-full flex-1 bg-muted/30">
+ {isViewerLoading && !loadError ? (
+ <div className="absolute inset-0 z-10 grid place-items-center bg-background">
+ <HugeiconsIcon icon={Loading03Icon} className="size-4 animate-spin" />
+ </div>
+ ) : null}
+ {loadError ? (
+ <div className="absolute inset-0 z-10 grid place-items-center bg-background p-6 text-sm text-muted-foreground">
+ Unable to load the PDF preview.
+ </div>
+ ) : null}
+ {reactPdf ? (
+ <reactPdf.Document
+ file={PDF_URL}
+ className={cn(
+ "flex h-full min-h-0 w-full flex-1",
+ (isViewerLoading || loadError) && "invisible",
+ )}
+ loading={null}
+ error={null}
+ onLoadStart={handleDocumentLoadStart}
+ onLoadSuccess={handleDocumentLoadSuccess}
+ onLoadError={handleDocumentLoadError}
+ >
+ <div
+ ref={viewportRef}
+ className={cn(
+ "min-h-0 min-w-0 flex-1 overflow-auto",
+ isPageRendering && !loadError && "invisible",
+ )}
+ >
+ <div className="flex min-h-full w-max min-w-full flex-col items-center justify-start gap-6 p-6">
+ {pageNumbers.map((pageNumber) => {
+ const shouldRenderPage =
+ Math.abs(pageNumber - currentPage) <= PAGE_RENDER_BUFFER;
+
+ return (
+ <div
+ key={pageNumber}
+ data-citation-page={pageNumber}
+ className="relative"
+ style={{ width: RENDERED_PAGE_WIDTH, height: RENDERED_PAGE_HEIGHT }}
+ >
+ {shouldRenderPage ? (
+ <reactPdf.Page
+ pageNumber={pageNumber}
+ width={RENDERED_PAGE_WIDTH}
+ className="overflow-hidden border bg-background shadow-xs"
+ renderAnnotationLayer={false}
+ renderTextLayer={false}
+ loading={
+ <div
+ className="grid place-items-center"
+ style={{
+ width: RENDERED_PAGE_WIDTH,
+ height: RENDERED_PAGE_HEIGHT,
+ }}
+ >
+ <HugeiconsIcon icon={Loading03Icon} className="size-4 animate-spin" />
+ </div>
+ }
+ onRenderSuccess={pageNumber === 1 ? handleFirstPageRender : undefined}
+ onRenderError={pageNumber === 1 ? handleFirstPageRender : undefined}
+ />
+ ) : (
+ <div className="size-full border bg-muted/30 shadow-xs" />
+ )}
+ {activeCitation.page === pageNumber ? (
+ <CitationHighlight citation={activeCitation} />
+ ) : null}
+ </div>
+ );
+ })}
+ </div>
+ </div>
+ </reactPdf.Document>
+ ) : null}
+ </div>
+ </div>
+ <aside className="min-h-0 overflow-y-auto p-3">
+ {CITATIONS.map((citation) => (
+ <button
+ key={citation.id}
+ type="button"
+ onClick={() => scrollToCitation(citation)}
+ onMouseEnter={() => scrollToCitation(citation)}
+ onFocus={() => scrollToCitation(citation)}
+ className={cn(
+ "mb-2 w-full rounded-lg border bg-background p-3 text-left text-sm",
+ citation.id === activeCitation.id && CITATION_STYLE.active,
+ )}
+ >
+ <div className="font-medium">{citation.label}</div>
+ <div className="mt-1">{citation.value}</div>
+ <div className="mt-2 text-xs text-muted-foreground">{citation.referenceText}</div>
+ </button>
+ ))}
+ </aside>
+ </div>
+ );
+}`
+
+export function CitationsSource() {
+ return <HighlightedCodeBlock code={citationsUsageCode} />
+}
diff --git a/apps/v4/components/code-block-command.tsx b/apps/v4/components/code-block-command.tsx
index ef071f0..9cb0137 100644
--- a/apps/v4/components/code-block-command.tsx
+++ b/apps/v4/components/code-block-command.tsx
@@ -4,11 +4,11 @@ import * as React from "react"
import { IconTerminal } from "@tabler/icons-react"
import { useConfig } from "@/hooks/use-config"
+import { Button } from "@/components/ui/button"
import {
CopyButtonIcon,
copyToClipboardWithMeta,
} from "@/components/copy-button"
-import { Button } from "@/registry/new-york-v4/ui/button"
import {
Tabs,
TabsContent,
@@ -123,7 +123,7 @@ export function CodeBlockCommand({
disabled={hasCopied}
size="icon"
variant="ghost"
- className="absolute top-2 right-2 z-10 size-7 opacity-70 transition-all duration-200 ease-out active:scale-[0.97] hover:opacity-100 focus-visible:opacity-100 disabled:opacity-100"
+ className="absolute top-2 right-2 z-10 size-7 opacity-70 transition-all duration-200 ease-out hover:opacity-100 focus-visible:opacity-100 active:scale-[0.97] disabled:opacity-100"
onClick={copyCommand}
>
<span className="sr-only">{hasCopied ? "Copied" : "Copy"}</span>
diff --git a/apps/v4/components/code-collapsible-wrapper.tsx b/apps/v4/components/code-collapsible-wrapper.tsx
index 27940b7..2b176c6 100644
--- a/apps/v4/components/code-collapsible-wrapper.tsx
+++ b/apps/v4/components/code-collapsible-wrapper.tsx
@@ -3,7 +3,7 @@
import * as React from "react"
import { cn } from "@/lib/utils"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
import {
Collapsible,
CollapsibleContent,
diff --git a/apps/v4/components/command-menu.tsx b/apps/v4/components/command-menu.tsx
index 535952b..c104440 100644
--- a/apps/v4/components/command-menu.tsx
+++ b/apps/v4/components/command-menu.tsx
@@ -18,8 +18,8 @@ import { type source } from "@/lib/source"
import { cn } from "@/lib/utils"
import { useConfig } from "@/hooks/use-config"
import { useMutationObserver } from "@/hooks/use-mutation-observer"
+import { Button } from "@/components/ui/button"
import { copyToClipboardWithMeta } from "@/components/copy-button"
-import { Button } from "@/registry/new-york-v4/ui/button"
import {
Command,
CommandEmpty,
@@ -29,8 +29,8 @@ import {
CommandList,
} from "@/registry/new-york-v4/ui/command"
import {
- Dialog,
DialogContent as BaseDialogContent,
+ Dialog,
DialogDescription,
DialogHeader,
DialogTitle,
diff --git a/apps/v4/components/copy-button.tsx b/apps/v4/components/copy-button.tsx
index 3066e87..54a5705 100644
--- a/apps/v4/components/copy-button.tsx
+++ b/apps/v4/components/copy-button.tsx
@@ -6,7 +6,7 @@ import { HugeiconsIcon } from "@hugeicons/react"
import { trackEvent, type Event } from "@/lib/events"
import { cn } from "@/lib/utils"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
function legacyCopyToClipboard(value: string) {
const textArea = document.createElement("textarea")
@@ -75,7 +75,10 @@ export function CopyButtonIcon({
return (
<span
aria-hidden="true"
- className={cn("relative inline-flex size-4 items-center justify-center", className)}
+ className={cn(
+ "relative inline-flex size-4 items-center justify-center",
+ className
+ )}
>
<span
className={cn(
@@ -131,7 +134,7 @@ export function CopyButton({
size="icon"
variant={variant}
className={cn(
- "absolute top-3 right-2 z-10 size-7 bg-code transition-all duration-200 ease-out active:scale-[0.97] hover:opacity-100 focus-visible:opacity-100 disabled:opacity-100",
+ "absolute top-3 right-2 z-10 size-7 bg-code transition-all duration-200 ease-out hover:opacity-100 focus-visible:opacity-100 active:scale-[0.97] disabled:opacity-100",
className
)}
onClick={async () => {
diff --git a/apps/v4/components/csv-viewer-docs.tsx b/apps/v4/components/csv-viewer-docs.tsx
index a2f9b5f..bffec34 100644
--- a/apps/v4/components/csv-viewer-docs.tsx
+++ b/apps/v4/components/csv-viewer-docs.tsx
@@ -10,6 +10,7 @@ import type {
Theme,
} from "@glideapps/glide-data-grid"
import {
+ Loading03Icon,
MinusSignCircleIcon,
PlusSignCircleIcon,
TableIcon,
@@ -18,8 +19,8 @@ import {
import { HugeiconsIcon } from "@hugeicons/react"
import Papa from "papaparse"
+import { Button } from "@/components/ui/button"
import { HighlightedCodeBlock } from "@/components/highlighted-code-block"
-import { Button } from "@/registry/new-york-v4/ui/button"
import {
Select,
SelectContent,
@@ -27,6 +28,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/registry/new-york-v4/ui/select"
+import { Separator } from "@/registry/new-york-v4/ui/separator"
import {
Tooltip,
TooltipContent,
@@ -174,7 +176,9 @@ function CsvViewerPreviewClient() {
const [glide, setGlide] = React.useState<GlideDataGridModule | null>(null)
const [fileName, setFileName] = React.useState("invoice-review.csv")
const [zoom, setZoom] = React.useState<(typeof ZOOM_OPTIONS)[number]>(1)
- const [parsed, setParsed] = React.useState(() => parseDelimitedText(SAMPLE_CSV))
+ const [parsed, setParsed] = React.useState(() =>
+ parseDelimitedText(SAMPLE_CSV)
+ )
const [isPending, setIsPending] = React.useState(false)
React.useEffect(() => {
@@ -192,9 +196,10 @@ function CsvViewerPreviewClient() {
}, [])
const columnCount = Math.max(1, parsed.headers.length)
- const scale = React.useCallback((value: number) => Math.round(value * zoom), [
- zoom,
- ])
+ const scale = React.useCallback(
+ (value: number) => Math.round(value * zoom),
+ [zoom]
+ )
const theme = React.useMemo<Partial<Theme>>(
() => ({
@@ -214,8 +219,14 @@ function CsvViewerPreviewClient() {
bgHeaderHovered: isDark ? "#262626" : "#f5f5f5",
borderColor: isDark ? "#262626" : "#e5e5e5",
horizontalBorderColor: isDark ? "#262626" : "#e5e5e5",
- baseFontStyle: `${scale(13)}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,
- headerFontStyle: `600 ${scale(13)}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,
+ cellHorizontalPadding: scale(8),
+ cellVerticalPadding: Math.max(2, scale(3)),
+ headerIconSize: scale(18),
+ baseFontStyle: `${scale(13)}px`,
+ headerFontStyle: `600 ${scale(13)}px`,
+ markerFontStyle: `${scale(11)}px`,
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
+ editorFontSize: `${scale(13)}px`,
}),
[isDark, scale]
)
@@ -339,6 +350,10 @@ function CsvViewerPreviewClient() {
<HugeiconsIcon icon={PlusSignCircleIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<input
ref={inputRef}
type="file"
@@ -366,8 +381,11 @@ function CsvViewerPreviewClient() {
{parsed.error}
</div>
) : !glide ? (
- <div className="flex h-full items-center justify-center text-sm text-muted-foreground">
- Loading grid...
+ <div className="grid h-full place-items-center bg-background">
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
</div>
) : (
<glide.DataEditor
@@ -405,6 +423,7 @@ import type {
Theme,
} from "@glideapps/glide-data-grid";
import {
+ Loading03Icon,
MinusSignCircleIcon,
PlusSignCircleIcon,
TableIcon,
@@ -422,6 +441,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
+import { Separator } from "@/components/ui/separator";
import {
Tooltip,
TooltipContent,
@@ -610,12 +630,14 @@ export function CsvViewer({
bgHeaderHovered: isDark ? "#262626" : "#f5f5f5",
borderColor: isDark ? "#262626" : "#e5e5e5",
horizontalBorderColor: isDark ? "#262626" : "#e5e5e5",
- baseFontStyle:
- scale(13) + 'px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
- headerFontStyle:
- "600 " +
- scale(13) +
- 'px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
+ cellHorizontalPadding: scale(8),
+ cellVerticalPadding: Math.max(2, scale(3)),
+ headerIconSize: scale(18),
+ baseFontStyle: scale(13) + "px",
+ headerFontStyle: "600 " + scale(13) + "px",
+ markerFontStyle: scale(11) + "px",
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',
+ editorFontSize: scale(13) + "px",
}),
[isDark, scale],
);
@@ -744,6 +766,10 @@ export function CsvViewer({
<HugeiconsIcon icon={PlusSignCircleIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<input
ref={inputRef}
type="file"
@@ -771,8 +797,8 @@ export function CsvViewer({
{parsed.error}
</div>
) : !glide ? (
- <div className="flex h-full items-center justify-center text-sm text-muted-foreground">
- Loading grid...
+ <div className="grid h-full place-items-center bg-background">
+ <HugeiconsIcon icon={Loading03Icon} className="size-4 animate-spin" />
</div>
) : (
<glide.DataEditor
diff --git a/apps/v4/components/docs-copy-page.tsx b/apps/v4/components/docs-copy-page.tsx
index 4bc4c8f..8f57351 100644
--- a/apps/v4/components/docs-copy-page.tsx
+++ b/apps/v4/components/docs-copy-page.tsx
@@ -4,9 +4,9 @@ import * as React from "react"
import { ChevronDown } from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"
-import { CopyButtonIcon } from "@/components/copy-button"
import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
+import { CopyButtonIcon } from "@/components/copy-button"
import {
DropdownMenu,
DropdownMenuContent,
diff --git a/apps/v4/components/docs-page-links.tsx b/apps/v4/components/docs-page-links.tsx
index 144c1b1..dfb7ce3 100644
--- a/apps/v4/components/docs-page-links.tsx
+++ b/apps/v4/components/docs-page-links.tsx
@@ -1,8 +1,8 @@
"use client"
-import { CopyButtonIcon } from "@/components/copy-button"
import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
+import { CopyButtonIcon } from "@/components/copy-button"
function getPromptUrl(baseURL: string, url: string) {
return `${baseURL}?q=${encodeURIComponent(
diff --git a/apps/v4/components/docs-sidebar.tsx b/apps/v4/components/docs-sidebar.tsx
index 58a8adc..deafdf9 100644
--- a/apps/v4/components/docs-sidebar.tsx
+++ b/apps/v4/components/docs-sidebar.tsx
@@ -1,11 +1,17 @@
"use client"
+import { Fragment } from "react"
import Link from "next/link"
import { usePathname } from "next/navigation"
import { showMcpDocs } from "@/lib/flags"
-import { getCurrentBase, getPagesFromFolder } from "@/lib/page-tree"
+import {
+ getCurrentBase,
+ getNestedPagesFromFolder,
+ getPagesFromFolder,
+} from "@/lib/page-tree"
import type { source } from "@/lib/source"
+import { cn } from "@/lib/utils"
import {
Sidebar,
SidebarContent,
@@ -26,6 +32,12 @@ const TOP_LEVEL_SECTIONS = [
]
const EXCLUDED_SECTIONS: string[] = []
const EXCLUDED_PAGES = ["/docs"]
+const PDF_VIEWER_URL = "/docs/components/pdf-viewer"
+const PDF_VIEWER_SUBPAGES = [
+ { name: "Citations", url: "/docs/components/pdf-viewer/citations" },
+ { name: "OCR Blocks", url: "/docs/components/pdf-viewer/ocr-blocks" },
+ { name: "E-Signature", url: "/docs/components/pdf-viewer/e-signature" },
+]
export function DocsSidebar({
tree,
@@ -81,6 +93,36 @@ export function DocsSidebar({
return null
}
+ const pages =
+ item.type === "folder"
+ ? getPagesFromFolder(item, currentBase).filter((page) => {
+ if (!showMcpDocs && page.url.includes("/mcp")) {
+ return false
+ }
+
+ return !EXCLUDED_PAGES.includes(page.url)
+ })
+ : []
+
+ if (pages.length === 0) {
+ return null
+ }
+
+ const pdfViewerSubpages =
+ item.type === "folder"
+ ? getNestedPagesFromFolder(item, "pdf-viewer").filter((page) => {
+ if (!showMcpDocs && page.url.includes("/mcp")) {
+ return false
+ }
+
+ return !EXCLUDED_PAGES.includes(page.url)
+ })
+ : []
+ const pdfViewerSidebarSubpages =
+ pdfViewerSubpages.length > 0
+ ? pdfViewerSubpages
+ : PDF_VIEWER_SUBPAGES
+
return (
<SidebarGroup key={item.$id}>
<SidebarGroupLabel className="font-medium text-muted-foreground">
@@ -89,28 +131,53 @@ export function DocsSidebar({
<SidebarGroupContent>
{item.type === "folder" && (
<SidebarMenu className="gap-0.5">
- {getPagesFromFolder(item, currentBase).map((page) => {
- if (!showMcpDocs && page.url.includes("/mcp")) {
- return null
- }
-
- if (EXCLUDED_PAGES.includes(page.url)) {
- return null
- }
+ {pages.map((page) => {
+ const isPdfViewer = page.url === PDF_VIEWER_URL
+ const isPdfSubpage =
+ isPdfViewer && pathname.startsWith(`${page.url}/`)
return (
- <SidebarMenuItem key={page.url}>
- <SidebarMenuButton
- asChild
- isActive={page.url === pathname}
- className="relative h-[30px] w-fit overflow-visible border border-transparent text-[0.8rem] font-medium after:absolute after:inset-x-0 after:-inset-y-1 after:z-0 after:rounded-md data-[active=true]:border-accent data-[active=true]:bg-accent 3xl:fixed:w-full 3xl:fixed:max-w-48"
- >
- <Link href={page.url}>
- <span className="absolute inset-0 flex w-(--sidebar-menu-width) bg-transparent" />
- {page.name}
- </Link>
- </SidebarMenuButton>
- </SidebarMenuItem>
+ <Fragment key={page.url}>
+ <SidebarMenuItem>
+ <SidebarMenuButton
+ asChild
+ isActive={page.url === pathname || isPdfSubpage}
+ className="relative h-[30px] w-fit overflow-visible border border-transparent text-[0.8rem] font-medium after:absolute after:inset-x-0 after:-inset-y-1 after:z-0 after:rounded-md data-[active=true]:border-accent data-[active=true]:bg-accent 3xl:fixed:w-full 3xl:fixed:max-w-48"
+ >
+ <Link href={page.url}>
+ <span className="absolute inset-0 flex w-(--sidebar-menu-width) bg-transparent" />
+ {page.name}
+ </Link>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ {isPdfViewer &&
+ pdfViewerSidebarSubpages.length > 0 ? (
+ <>
+ {pdfViewerSidebarSubpages.map(
+ (subpage, index) => (
+ <SidebarMenuItem
+ key={subpage.url}
+ className={cn(
+ "ml-5 border-l border-border/70",
+ index === 0 && "mt-1"
+ )}
+ >
+ <SidebarMenuButton
+ asChild
+ isActive={subpage.url === pathname}
+ className="relative h-7 w-fit overflow-visible border border-transparent text-[0.78rem] font-medium text-muted-foreground after:absolute after:inset-x-0 after:-inset-y-1 after:z-0 after:rounded-md data-[active=true]:border-accent data-[active=true]:bg-accent data-[active=true]:text-foreground 3xl:fixed:w-full 3xl:fixed:max-w-44"
+ >
+ <Link href={subpage.url}>
+ <span className="absolute inset-0 flex w-[calc(var(--sidebar-menu-width)-1.25rem)] bg-transparent" />
+ {subpage.name}
+ </Link>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ )
+ )}
+ </>
+ ) : null}
+ </Fragment>
)
})}
</SidebarMenu>
diff --git a/apps/v4/components/docs-toc.tsx b/apps/v4/components/docs-toc.tsx
index bd3fcf8..6197fdd 100644
--- a/apps/v4/components/docs-toc.tsx
+++ b/apps/v4/components/docs-toc.tsx
@@ -4,7 +4,7 @@ import * as React from "react"
import { IconMenu3 } from "@tabler/icons-react"
import { cn } from "@/lib/utils"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
diff --git a/apps/v4/components/e-signature-docs.tsx b/apps/v4/components/e-signature-docs.tsx
new file mode 100644
index 0000000..6d053a6
--- /dev/null
+++ b/apps/v4/components/e-signature-docs.tsx
@@ -0,0 +1,1093 @@
+"use client"
+
+import * as React from "react"
+import {
+ BorderFullIcon,
+ Download01Icon,
+ FilePenIcon,
+ Loading03Icon,
+ Pen01Icon,
+} from "@hugeicons/core-free-icons"
+import { HugeiconsIcon } from "@hugeicons/react"
+import type * as ReactPdf from "react-pdf"
+import type SignaturePad from "signature_pad"
+
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+import { HighlightedCodeBlock } from "@/components/highlighted-code-block"
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogPanel,
+ DialogTitle,
+} from "@/registry/new-york-v4/ui/dialog"
+
+type BoundingBox = {
+ x: number
+ y: number
+ width: number
+ height: number
+}
+
+type SignatureField = {
+ id: string
+ label: string
+ page: number
+ bbox: BoundingBox
+ imageDataUrl?: string
+}
+
+type ReactPdfModule = typeof ReactPdf
+
+const PDF_URL = "/samples/attention.pdf"
+const PDF_WORKER_URL = new URL(
+ "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
+ import.meta.url
+).toString()
+const PAGE_WIDTH = 612
+const PAGE_HEIGHT = 792
+const RENDERED_PAGE_WIDTH = 430
+const RENDERED_PAGE_HEIGHT = Math.round(
+ RENDERED_PAGE_WIDTH * (PAGE_HEIGHT / PAGE_WIDTH)
+)
+const DEVICE_PIXEL_RATIO_LIMIT = 2
+const MIN_FIELD_WIDTH = 96
+const MIN_FIELD_HEIGHT = 34
+const SIGNATURE_PAD_PADDING = 8
+const DEFAULT_SIGNATURE_ASPECT_RATIO = 3
+
+const INITIAL_FIELD: SignatureField = {
+ id: "signature-1",
+ label: "Signature1",
+ page: 1,
+ bbox: {
+ x: 300,
+ y: 504,
+ width: 250,
+ height: 58,
+ },
+}
+
+function clamp(value: number, min: number, max: number) {
+ return Math.min(Math.max(value, min), max)
+}
+
+function bboxToStyle(bbox: BoundingBox): React.CSSProperties {
+ return {
+ left: `${(bbox.x / PAGE_WIDTH) * 100}%`,
+ top: `${(bbox.y / PAGE_HEIGHT) * 100}%`,
+ width: `${(bbox.width / PAGE_WIDTH) * 100}%`,
+ height: `${(bbox.height / PAGE_HEIGHT) * 100}%`,
+ }
+}
+
+function normalizeBoundingBox(
+ start: { x: number; y: number },
+ end: { x: number; y: number }
+): BoundingBox {
+ const x = Math.min(start.x, end.x)
+ const y = Math.min(start.y, end.y)
+ const width = Math.abs(end.x - start.x)
+ const height = Math.abs(end.y - start.y)
+
+ return {
+ x: clamp(x, 0, PAGE_WIDTH - MIN_FIELD_WIDTH),
+ y: clamp(y, 0, PAGE_HEIGHT - MIN_FIELD_HEIGHT),
+ width: clamp(width, MIN_FIELD_WIDTH, PAGE_WIDTH - x),
+ height: clamp(height, MIN_FIELD_HEIGHT, PAGE_HEIGHT - y),
+ }
+}
+
+function getPointerPagePoint(
+ event: React.PointerEvent<HTMLElement>,
+ element: HTMLElement
+) {
+ const rect = element.getBoundingClientRect()
+
+ return {
+ x: clamp(
+ ((event.clientX - rect.left) / rect.width) * PAGE_WIDTH,
+ 0,
+ PAGE_WIDTH
+ ),
+ y: clamp(
+ ((event.clientY - rect.top) / rect.height) * PAGE_HEIGHT,
+ 0,
+ PAGE_HEIGHT
+ ),
+ }
+}
+
+function getSignatureAspectRatio(bbox?: BoundingBox): number {
+ if (!bbox || bbox.width <= 0 || bbox.height <= 0) {
+ return DEFAULT_SIGNATURE_ASPECT_RATIO
+ }
+
+ return bbox.width / bbox.height
+}
+
+function getSignatureGuideSize({
+ containerWidth,
+ containerHeight,
+ aspectRatio,
+}: {
+ containerWidth: number
+ containerHeight: number
+ aspectRatio: number
+}): { width: number; height: number } {
+ const maxWidth = Math.max(containerWidth - SIGNATURE_PAD_PADDING * 2, 1)
+ const maxHeight = Math.max(containerHeight - SIGNATURE_PAD_PADDING * 2, 1)
+
+ if (maxWidth / maxHeight > aspectRatio) {
+ const height = maxHeight
+ return {
+ width: height * aspectRatio,
+ height,
+ }
+ }
+
+ const width = maxWidth
+ return {
+ width,
+ height: width / aspectRatio,
+ }
+}
+
+function getCroppedSignatureDataUrl(canvas: HTMLCanvasElement): string {
+ const context = canvas.getContext("2d")
+ if (!context) {
+ return canvas.toDataURL("image/png")
+ }
+
+ const { width, height } = canvas
+ const imageData = context.getImageData(0, 0, width, height)
+ const { data } = imageData
+ let minX = width
+ let minY = height
+ let maxX = -1
+ let maxY = -1
+
+ for (let y = 0; y < height; y += 1) {
+ for (let x = 0; x < width; x += 1) {
+ const alpha = data[(y * width + x) * 4 + 3]
+ if (alpha === 0) continue
+
+ minX = Math.min(minX, x)
+ minY = Math.min(minY, y)
+ maxX = Math.max(maxX, x)
+ maxY = Math.max(maxY, y)
+ }
+ }
+
+ if (maxX < minX || maxY < minY) {
+ return canvas.toDataURL("image/png")
+ }
+
+ const croppedWidth = maxX - minX + 1
+ const croppedHeight = maxY - minY + 1
+ const croppedCanvas = document.createElement("canvas")
+ croppedCanvas.width = croppedWidth
+ croppedCanvas.height = croppedHeight
+
+ const croppedContext = croppedCanvas.getContext("2d")
+ if (!croppedContext) {
+ return canvas.toDataURL("image/png")
+ }
+
+ croppedContext.drawImage(
+ canvas,
+ minX,
+ minY,
+ croppedWidth,
+ croppedHeight,
+ 0,
+ 0,
+ croppedWidth,
+ croppedHeight
+ )
+
+ return croppedCanvas.toDataURL("image/png")
+}
+
+function SignatureDialog({
+ open,
+ fieldBbox,
+ onOpenChange,
+ onConfirm,
+}: {
+ open: boolean
+ fieldBbox: BoundingBox
+ onOpenChange: (open: boolean) => void
+ onConfirm: (value: string) => void
+}) {
+ const canvasContainerRef = React.useRef<HTMLDivElement>(null)
+ const canvasRef = React.useRef<HTMLCanvasElement>(null)
+ const signaturePadRef = React.useRef<SignaturePad | null>(null)
+ const [isReady, setIsReady] = React.useState(false)
+ const [hasSignature, setHasSignature] = React.useState(false)
+ const [guideSize, setGuideSize] = React.useState<{
+ width: number
+ height: number
+ } | null>(null)
+ const signatureAspectRatio = React.useMemo(
+ () => getSignatureAspectRatio(fieldBbox),
+ [fieldBbox]
+ )
+
+ React.useEffect(() => {
+ if (!open) {
+ setGuideSize(null)
+ return
+ }
+
+ let frameId = 0
+ let resizeObserver: ResizeObserver | null = null
+
+ const updateGuideSize = (container?: HTMLDivElement | null) => {
+ const currentContainer = container ?? canvasContainerRef.current
+ if (
+ !currentContainer ||
+ currentContainer.clientWidth <= 0 ||
+ currentContainer.clientHeight <= 0
+ ) {
+ return false
+ }
+
+ const nextSize = getSignatureGuideSize({
+ containerWidth: currentContainer.clientWidth,
+ containerHeight: currentContainer.clientHeight,
+ aspectRatio: signatureAspectRatio,
+ })
+
+ setGuideSize((previousSize) => {
+ if (
+ previousSize &&
+ Math.abs(previousSize.width - nextSize.width) < 0.5 &&
+ Math.abs(previousSize.height - nextSize.height) < 0.5
+ ) {
+ return previousSize
+ }
+
+ return nextSize
+ })
+
+ return true
+ }
+
+ const connect = () => {
+ const container = canvasContainerRef.current
+ if (!updateGuideSize(container)) {
+ frameId = window.requestAnimationFrame(connect)
+ return
+ }
+
+ if (container) {
+ resizeObserver = new ResizeObserver(() => {
+ updateGuideSize(container)
+ })
+ resizeObserver.observe(container)
+ }
+ }
+
+ connect()
+
+ return () => {
+ window.cancelAnimationFrame(frameId)
+ resizeObserver?.disconnect()
+ }
+ }, [open, signatureAspectRatio])
+
+ React.useEffect(() => {
+ if (!open || !guideSize || guideSize.width <= 1 || guideSize.height <= 1) {
+ signaturePadRef.current?.off()
+ signaturePadRef.current = null
+ setIsReady(false)
+ if (!open) {
+ setHasSignature(false)
+ }
+ return
+ }
+
+ let cancelled = false
+ let resizeObserver: ResizeObserver | null = null
+
+ const syncCanvasSize = (canvas: HTMLCanvasElement) => {
+ const width = Math.max(canvas.offsetWidth, 1)
+ const height = Math.max(canvas.offsetHeight, 1)
+ const ratio = Math.max(window.devicePixelRatio || 1, 1)
+
+ canvas.style.width = `${width}px`
+ canvas.style.height = `${height}px`
+ canvas.width = Math.floor(width * ratio)
+ canvas.height = Math.floor(height * ratio)
+ const context = canvas.getContext("2d")
+ context?.setTransform(1, 0, 0, 1, 0, 0)
+ context?.scale(ratio, ratio)
+
+ return { width, height, ratio }
+ }
+
+ const initialize = async () => {
+ const canvas = canvasRef.current
+ if (!canvas) return
+
+ const { default: SignaturePadConstructor } = await import("signature_pad")
+ if (cancelled) return
+
+ const signaturePad = new SignaturePadConstructor(canvas, {
+ minWidth: 1.4,
+ maxWidth: 2.8,
+ penColor: "rgb(15, 23, 42)",
+ })
+
+ signaturePadRef.current = signaturePad
+
+ const loadSignature = async (dataUrl?: string) => {
+ const size = syncCanvasSize(canvas)
+
+ if (dataUrl) {
+ await signaturePad.fromDataURL(dataUrl, size)
+ setHasSignature(true)
+ return
+ }
+
+ signaturePad.clear()
+ setHasSignature(false)
+ }
+
+ await loadSignature()
+ if (cancelled) return
+
+ signaturePad.addEventListener("endStroke", () => {
+ setHasSignature(true)
+ })
+
+ resizeObserver = new ResizeObserver(() => {
+ const currentCanvas = canvasRef.current
+ const currentSignaturePad = signaturePadRef.current
+ if (!currentCanvas || !currentSignaturePad) return
+
+ const previousSignature = currentSignaturePad.isEmpty()
+ ? undefined
+ : currentSignaturePad.toDataURL("image/png")
+ void loadSignature(previousSignature)
+ })
+ resizeObserver.observe(canvas)
+ setIsReady(true)
+ }
+
+ const animationFrame = window.requestAnimationFrame(() => {
+ void initialize()
+ })
+
+ return () => {
+ cancelled = true
+ window.cancelAnimationFrame(animationFrame)
+ resizeObserver?.disconnect()
+ signaturePadRef.current?.off()
+ signaturePadRef.current = null
+ setIsReady(false)
+ }
+ }, [open, guideSize])
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="max-w-xl">
+ <DialogHeader>
+ <DialogTitle>Add signature</DialogTitle>
+ <DialogDescription>
+ Draw a signature to place it into the selected PDF field.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogPanel>
+ <div className="rounded-xl border bg-muted/30 p-3">
+ <div
+ ref={canvasContainerRef}
+ className="flex h-56 w-full items-center justify-center overflow-hidden rounded-lg border bg-muted/40 p-2"
+ >
+ <div
+ className={cn(
+ "relative overflow-hidden rounded-md border border-dashed border-slate-400 bg-white shadow-xs",
+ isReady ? "cursor-crosshair" : "cursor-wait"
+ )}
+ style={{
+ width: guideSize ? `${guideSize.width}px` : undefined,
+ height: guideSize ? `${guideSize.height}px` : undefined,
+ opacity: guideSize ? 1 : 0,
+ }}
+ >
+ <canvas
+ ref={canvasRef}
+ className={cn(
+ "absolute inset-0 size-full touch-none",
+ !isReady && "pointer-events-none"
+ )}
+ style={{ touchAction: "none" }}
+ />
+ </div>
+ </div>
+ </div>
+ </DialogPanel>
+ <DialogFooter className="sm:justify-between">
+ <Button
+ type="button"
+ variant="outline"
+ disabled={!isReady}
+ onClick={() => {
+ signaturePadRef.current?.clear()
+ setHasSignature(false)
+ }}
+ >
+ Clear
+ </Button>
+ <div className="flex flex-col-reverse gap-2 sm:flex-row">
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => onOpenChange(false)}
+ >
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ disabled={!isReady || !hasSignature}
+ onClick={() => {
+ const canvas = canvasRef.current
+ if (!canvas) return
+
+ onConfirm(getCroppedSignatureDataUrl(canvas))
+ onOpenChange(false)
+ }}
+ >
+ Confirm
+ </Button>
+ </div>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
+
+function SignatureFieldOverlay({
+ field,
+ isDrawing,
+ onDragStart,
+}: {
+ field: SignatureField
+ isDrawing: boolean
+ onDragStart: (event: React.PointerEvent<HTMLDivElement>) => void
+}) {
+ return (
+ <div
+ className={cn(
+ "absolute z-20 overflow-hidden rounded-[3px] border border-blue-500/70",
+ field.imageDataUrl ? "bg-transparent shadow-none" : "bg-blue-500/10",
+ isDrawing ? "pointer-events-none" : "cursor-move"
+ )}
+ style={bboxToStyle(field.bbox)}
+ onPointerDown={onDragStart}
+ >
+ {field.imageDataUrl ? (
+ <img
+ src={field.imageDataUrl}
+ alt=""
+ className="size-full object-contain"
+ draggable={false}
+ />
+ ) : (
+ <div className="flex size-full items-center justify-center gap-1.5 px-2 text-[11px] font-medium text-blue-700 dark:text-blue-300">
+ <HugeiconsIcon icon={Pen01Icon} className="size-3.5" />
+ Signature
+ </div>
+ )}
+ </div>
+ )
+}
+
+function ESignaturePage({
+ reactPdf,
+ field,
+ isDrawing,
+ draftBox,
+ onPointerDown,
+ onPointerMove,
+ onPointerUp,
+ onDragStart,
+}: {
+ reactPdf: ReactPdfModule
+ field: SignatureField
+ isDrawing: boolean
+ draftBox: BoundingBox | null
+ onPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void
+ onPointerMove: (event: React.PointerEvent<HTMLDivElement>) => void
+ onPointerUp: (event: React.PointerEvent<HTMLDivElement>) => void
+ onDragStart: (event: React.PointerEvent<HTMLDivElement>) => void
+}) {
+ const devicePixelRatio =
+ typeof window === "undefined"
+ ? 1
+ : Math.min(DEVICE_PIXEL_RATIO_LIMIT, window.devicePixelRatio || 1)
+
+ return (
+ <div
+ data-signature-page={field.page}
+ className={cn(
+ "relative touch-none select-none",
+ isDrawing && "cursor-crosshair"
+ )}
+ style={{ width: RENDERED_PAGE_WIDTH, height: RENDERED_PAGE_HEIGHT }}
+ onPointerMove={onPointerMove}
+ onPointerUp={onPointerUp}
+ onPointerCancel={onPointerUp}
+ >
+ <reactPdf.Page
+ pageNumber={field.page}
+ width={RENDERED_PAGE_WIDTH}
+ className="overflow-hidden border bg-background shadow-xs"
+ renderAnnotationLayer={false}
+ renderTextLayer={false}
+ devicePixelRatio={devicePixelRatio}
+ loading={
+ <div
+ className="grid place-items-center"
+ style={{ width: RENDERED_PAGE_WIDTH, height: RENDERED_PAGE_HEIGHT }}
+ >
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ }
+ />
+ <SignatureFieldOverlay
+ field={field}
+ isDrawing={isDrawing}
+ onDragStart={onDragStart}
+ />
+ {isDrawing ? (
+ <div
+ className="absolute inset-0 z-40 cursor-crosshair touch-none"
+ onPointerDown={(event) => {
+ event.stopPropagation()
+ onPointerDown(event)
+ }}
+ onPointerMove={(event) => {
+ event.stopPropagation()
+ onPointerMove(event)
+ }}
+ onPointerUp={(event) => {
+ event.stopPropagation()
+ onPointerUp(event)
+ }}
+ onPointerCancel={(event) => {
+ event.stopPropagation()
+ onPointerUp(event)
+ }}
+ />
+ ) : null}
+ {draftBox ? (
+ <div
+ className="pointer-events-none absolute z-50 rounded-[3px] border border-dashed border-blue-500/70 bg-blue-500/10"
+ style={bboxToStyle(draftBox)}
+ />
+ ) : null}
+ </div>
+ )
+}
+
+async function downloadSignedPdf(field: SignatureField) {
+ const { PDFDocument } = await import("pdf-lib")
+ const existingPdfBytes = await fetch(PDF_URL).then((response) =>
+ response.arrayBuffer()
+ )
+ const pdfDocument = await PDFDocument.load(existingPdfBytes)
+ const page = pdfDocument.getPage(field.page - 1)
+
+ if (field.imageDataUrl) {
+ const signatureImage = await pdfDocument.embedPng(field.imageDataUrl)
+ const { width: pageWidth, height: pageHeight } = page.getSize()
+ const scaleX = pageWidth / PAGE_WIDTH
+ const scaleY = pageHeight / PAGE_HEIGHT
+ const fieldWidth = field.bbox.width * scaleX
+ const fieldHeight = field.bbox.height * scaleY
+ const imageAspectRatio = signatureImage.width / signatureImage.height
+ const fieldAspectRatio = fieldWidth / fieldHeight
+ const drawWidth =
+ fieldAspectRatio > imageAspectRatio
+ ? fieldHeight * imageAspectRatio
+ : fieldWidth
+ const drawHeight =
+ fieldAspectRatio > imageAspectRatio
+ ? fieldHeight
+ : fieldWidth / imageAspectRatio
+ const fieldX = field.bbox.x * scaleX
+ const fieldY = pageHeight - (field.bbox.y + field.bbox.height) * scaleY
+
+ page.drawImage(signatureImage, {
+ x: fieldX + (fieldWidth - drawWidth) / 2,
+ y: fieldY + (fieldHeight - drawHeight) / 2,
+ width: drawWidth,
+ height: drawHeight,
+ })
+ }
+
+ const bytes = await pdfDocument.save()
+ const blob = new Blob([new Uint8Array(bytes)], { type: "application/pdf" })
+ const url = URL.createObjectURL(blob)
+ const anchor = document.createElement("a")
+ anchor.href = url
+ anchor.download = "signed-attention.pdf"
+ anchor.click()
+ URL.revokeObjectURL(url)
+}
+
+export function ESignature() {
+ const [field, setField] = React.useState<SignatureField>(INITIAL_FIELD)
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null)
+ const [loadError, setLoadError] = React.useState(false)
+ const [isDrawing, setIsDrawing] = React.useState(false)
+ const [drawStart, setDrawStart] = React.useState<{
+ x: number
+ y: number
+ } | null>(null)
+ const [draftBox, setDraftBox] = React.useState<BoundingBox | null>(null)
+ const [dragOffset, setDragOffset] = React.useState<{
+ x: number
+ y: number
+ } | null>(null)
+ const [dialogOpen, setDialogOpen] = React.useState(false)
+ const [isDownloading, setIsDownloading] = React.useState(false)
+
+ React.useEffect(() => {
+ let mounted = true
+
+ void import("react-pdf")
+ .then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc = PDF_WORKER_URL
+
+ if (mounted) {
+ setReactPdf(module)
+ }
+ })
+ .catch(() => {
+ if (mounted) {
+ setLoadError(true)
+ }
+ })
+
+ return () => {
+ mounted = false
+ }
+ }, [])
+
+ const handlePagePointerDown = React.useCallback(
+ (event: React.PointerEvent<HTMLDivElement>) => {
+ if (!isDrawing) return
+
+ const point = getPointerPagePoint(event, event.currentTarget)
+ event.currentTarget.setPointerCapture(event.pointerId)
+ setDrawStart(point)
+ setDraftBox({
+ x: point.x,
+ y: point.y,
+ width: MIN_FIELD_WIDTH,
+ height: MIN_FIELD_HEIGHT,
+ })
+ },
+ [isDrawing]
+ )
+
+ const handlePagePointerMove = React.useCallback(
+ (event: React.PointerEvent<HTMLDivElement>) => {
+ if (drawStart) {
+ const point = getPointerPagePoint(event, event.currentTarget)
+ setDraftBox(normalizeBoundingBox(drawStart, point))
+ return
+ }
+
+ if (dragOffset) {
+ const point = getPointerPagePoint(event, event.currentTarget)
+ setField((previousField) => ({
+ ...previousField,
+ bbox: {
+ ...previousField.bbox,
+ x: clamp(
+ point.x - dragOffset.x,
+ 0,
+ PAGE_WIDTH - previousField.bbox.width
+ ),
+ y: clamp(
+ point.y - dragOffset.y,
+ 0,
+ PAGE_HEIGHT - previousField.bbox.height
+ ),
+ },
+ }))
+ }
+ },
+ [dragOffset, drawStart]
+ )
+
+ const handlePagePointerUp = React.useCallback(
+ (event: React.PointerEvent<HTMLDivElement>) => {
+ if (draftBox) {
+ setField((previousField) => ({
+ ...previousField,
+ bbox: draftBox,
+ }))
+ }
+
+ if (drawStart || dragOffset) {
+ event.currentTarget.releasePointerCapture(event.pointerId)
+ }
+
+ setDrawStart(null)
+ setDraftBox(null)
+ setDragOffset(null)
+ setIsDrawing(false)
+ },
+ [draftBox, dragOffset, drawStart]
+ )
+
+ const handleDragStart = React.useCallback(
+ (event: React.PointerEvent<HTMLDivElement>) => {
+ if (isDrawing) return
+
+ event.stopPropagation()
+ const page = event.currentTarget.closest<HTMLElement>(
+ "[data-signature-page]"
+ )
+ if (!page) return
+
+ const point = getPointerPagePoint(event, page)
+ page.setPointerCapture(event.pointerId)
+ setDragOffset({
+ x: point.x - field.bbox.x,
+ y: point.y - field.bbox.y,
+ })
+ },
+ [field.bbox.x, field.bbox.y, isDrawing]
+ )
+
+ const handleDownload = React.useCallback(async () => {
+ setIsDownloading(true)
+ try {
+ await downloadSignedPdf(field)
+ } finally {
+ setIsDownloading(false)
+ }
+ }, [field])
+
+ return (
+ <div className="grid h-[620px] overflow-hidden bg-background lg:grid-cols-[minmax(0,1fr)_20rem]">
+ <div className="flex min-h-0 min-w-0 flex-col border-b lg:border-r lg:border-b-0">
+ <div className="flex h-12 shrink-0 items-center gap-2 border-b px-3">
+ <div className="mr-auto text-sm font-medium">PDF Viewer</div>
+ <Button
+ type="button"
+ size="sm"
+ variant={isDrawing ? "default" : "outline"}
+ onClick={() => setIsDrawing((value) => !value)}
+ >
+ <HugeiconsIcon icon={BorderFullIcon} className="size-4" />
+ Draw
+ </Button>
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ disabled={!field.imageDataUrl || isDownloading}
+ onClick={handleDownload}
+ >
+ <HugeiconsIcon icon={Download01Icon} className="size-4" />
+ Download
+ </Button>
+ </div>
+ <div className="min-h-0 flex-1 overflow-auto bg-muted/30">
+ {loadError ? (
+ <div className="grid h-full place-items-center p-6 text-sm text-muted-foreground">
+ Unable to load the PDF preview.
+ </div>
+ ) : reactPdf ? (
+ <reactPdf.Document
+ file={PDF_URL}
+ className="flex min-h-full w-max min-w-full flex-col items-center p-6"
+ loading={
+ <div className="grid h-full min-h-80 place-items-center">
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ }
+ error={null}
+ onLoadError={() => setLoadError(true)}
+ >
+ <ESignaturePage
+ reactPdf={reactPdf}
+ field={field}
+ isDrawing={isDrawing}
+ draftBox={draftBox}
+ onPointerDown={handlePagePointerDown}
+ onPointerMove={handlePagePointerMove}
+ onPointerUp={handlePagePointerUp}
+ onDragStart={handleDragStart}
+ />
+ </reactPdf.Document>
+ ) : (
+ <div className="grid h-full min-h-80 place-items-center">
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ )}
+ </div>
+ </div>
+ <aside className="flex min-h-0 flex-col">
+ <div className="border-b px-4 py-3">
+ <div className="text-sm font-medium">Fields</div>
+ <div className="text-xs text-muted-foreground">
+ Draw, drag, sign, then download.
+ </div>
+ </div>
+ <div className="min-h-0 flex-1 overflow-y-auto p-3">
+ <div className="rounded-lg border bg-background p-3">
+ <div className="flex items-start gap-3">
+ <div className="flex size-8 shrink-0 items-center justify-center rounded-md bg-blue-500/10 text-blue-600 dark:text-blue-300">
+ <HugeiconsIcon icon={FilePenIcon} className="size-4" />
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center justify-between gap-2">
+ <div className="text-sm font-medium">{field.label}</div>
+ <div
+ className={cn(
+ "rounded-full px-2 py-0.5 text-xs",
+ field.imageDataUrl
+ ? "bg-emerald-500/10 text-emerald-600 dark:text-emerald-300"
+ : "bg-muted text-muted-foreground"
+ )}
+ >
+ {field.imageDataUrl ? "Signed" : "Unsigned"}
+ </div>
+ </div>
+ <div className="mt-2 text-xs text-muted-foreground">
+ {Math.round(field.bbox.width)} x{" "}
+ {Math.round(field.bbox.height)} on page {field.page}
+ </div>
+ <Button
+ type="button"
+ size="sm"
+ variant={field.imageDataUrl ? "outline" : "default"}
+ className="mt-3 w-full"
+ onClick={() => setDialogOpen(true)}
+ >
+ <HugeiconsIcon icon={Pen01Icon} className="size-4" />
+ {field.imageDataUrl ? "Edit signature" : "Sign"}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </aside>
+ <SignatureDialog
+ open={dialogOpen}
+ fieldBbox={field.bbox}
+ onOpenChange={setDialogOpen}
+ onConfirm={(imageDataUrl) => {
+ setField((previousField) => ({ ...previousField, imageDataUrl }))
+ }}
+ />
+ </div>
+ )
+}
+
+export function ESignatureDemo() {
+ const [isCodeVisible, setIsCodeVisible] = React.useState(false)
+
+ return (
+ <div
+ data-slot="component-preview"
+ className="group relative mt-4 mb-12 flex flex-col overflow-hidden rounded-xl border"
+ >
+ <ESignature />
+ <div
+ data-slot="code"
+ data-mobile-code-visible={isCodeVisible}
+ className="relative overflow-hidden **:data-[slot=copy-button]:right-4 **:data-[slot=copy-button]:hidden data-[mobile-code-visible=true]:**:data-[slot=copy-button]:flex [&_[data-rehype-pretty-code-figure]]:m-0! [&_[data-rehype-pretty-code-figure]]:rounded-t-none [&_[data-rehype-pretty-code-figure]]:border-t [&_pre]:max-h-72"
+ >
+ {isCodeVisible ? (
+ <HighlightedCodeBlock
+ code={eSignatureUsageCode}
+ className="rounded-none border-x-0 border-b-0"
+ />
+ ) : (
+ <div className="relative">
+ <HighlightedCodeBlock
+ code={eSignatureUsageCode}
+ className="rounded-none border-x-0 border-b-0"
+ maxHeightClassName="max-h-56"
+ previewLines={10}
+ showCopy={false}
+ />
+ <div className="absolute inset-0 flex items-center justify-center pb-4">
+ <div
+ className="absolute inset-0"
+ style={{
+ background:
+ "linear-gradient(to top, var(--color-code), color-mix(in oklab, var(--color-code) 60%, transparent), transparent)",
+ }}
+ />
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ className="relative z-10 rounded-lg bg-background text-foreground shadow-none hover:bg-muted dark:bg-background dark:text-foreground dark:hover:bg-muted"
+ onClick={() => setIsCodeVisible(true)}
+ >
+ View Code
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
+
+const eSignatureUsageCode = `"use client";
+
+import * as React from "react";
+import type SignaturePad from "signature_pad";
+import type * as ReactPdf from "react-pdf";
+
+import { Button } from "@/components/ui/button";
+
+const PDF_WORKER_URL = new URL(
+ "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
+ import.meta.url,
+).toString();
+const PDF_URL = "/samples/attention.pdf";
+const PAGE_WIDTH = 612;
+const PAGE_HEIGHT = 792;
+type ReactPdfModule = typeof ReactPdf;
+
+type SignatureField = {
+ page: number;
+ bbox: { x: number; y: number; width: number; height: number };
+ imageDataUrl?: string;
+};
+
+async function downloadSignedPdf(field: SignatureField) {
+ const { PDFDocument } = await import("pdf-lib");
+ const bytes = await fetch(PDF_URL).then((response) => response.arrayBuffer());
+ const pdf = await PDFDocument.load(bytes);
+ const page = pdf.getPage(field.page - 1);
+
+ if (field.imageDataUrl) {
+ const image = await pdf.embedPng(field.imageDataUrl);
+ const { width, height } = page.getSize();
+ const scaleX = width / PAGE_WIDTH;
+ const scaleY = height / PAGE_HEIGHT;
+ const fieldWidth = field.bbox.width * scaleX;
+ const fieldHeight = field.bbox.height * scaleY;
+ const imageAspectRatio = image.width / image.height;
+ const fieldAspectRatio = fieldWidth / fieldHeight;
+ const drawWidth =
+ fieldAspectRatio > imageAspectRatio ? fieldHeight * imageAspectRatio : fieldWidth;
+ const drawHeight =
+ fieldAspectRatio > imageAspectRatio ? fieldHeight : fieldWidth / imageAspectRatio;
+ const fieldX = field.bbox.x * scaleX;
+ const fieldY = height - (field.bbox.y + field.bbox.height) * scaleY;
+
+ page.drawImage(image, {
+ x: fieldX + (fieldWidth - drawWidth) / 2,
+ y: fieldY + (fieldHeight - drawHeight) / 2,
+ width: drawWidth,
+ height: drawHeight,
+ });
+ }
+
+ const signedBytes = await pdf.save();
+ const url = URL.createObjectURL(
+ new Blob([new Uint8Array(signedBytes)], { type: "application/pdf" }),
+ );
+ const anchor = document.createElement("a");
+ anchor.href = url;
+ anchor.download = "signed-document.pdf";
+ anchor.click();
+ URL.revokeObjectURL(url);
+}
+
+export function ESignature() {
+ const [field, setField] = React.useState<SignatureField>({
+ page: 1,
+ bbox: { x: 300, y: 504, width: 250, height: 58 },
+ });
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null);
+ const canvasRef = React.useRef<HTMLCanvasElement>(null);
+ const signaturePadRef = React.useRef<SignaturePad | null>(null);
+
+ React.useEffect(() => {
+ if (!canvasRef.current) return;
+ let mounted = true;
+
+ void import("signature_pad").then(({ default: SignaturePad }) => {
+ if (!mounted || !canvasRef.current) return;
+ signaturePadRef.current = new SignaturePad(canvasRef.current);
+ });
+
+ return () => signaturePadRef.current?.off();
+ }, []);
+
+ React.useEffect(() => {
+ let mounted = true;
+
+ void import("react-pdf").then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc = PDF_WORKER_URL;
+ if (mounted) setReactPdf(module);
+ });
+
+ return () => {
+ mounted = false;
+ };
+ }, []);
+
+ return (
+ <div>
+ <Button variant="outline" onClick={() => downloadSignedPdf(field)}>
+ Download
+ </Button>
+ {reactPdf ? (
+ <reactPdf.Document file={PDF_URL}>
+ <div className="relative w-[430px]">
+ <reactPdf.Page pageNumber={field.page} width={430} renderTextLayer={false} />
+ <div className="absolute border border-blue-500/70" />
+ </div>
+ </reactPdf.Document>
+ ) : null}
+ <div
+ className="relative w-[430px] overflow-hidden rounded-md border border-dashed bg-white"
+ style={{ aspectRatio: field.bbox.width / field.bbox.height }}
+ >
+ <canvas ref={canvasRef} className="absolute inset-0 size-full touch-none" />
+ </div>
+ <Button
+ variant={field.imageDataUrl ? "outline" : "default"}
+ onClick={() => {
+ const value = signaturePadRef.current?.toDataURL("image/png");
+ if (value) setField((current) => ({ ...current, imageDataUrl: value }));
+ }}
+ >
+ {field.imageDataUrl ? "Edit signature" : "Confirm signature"}
+ </Button>
+ </div>
+ );
+}`
+
+export function ESignatureSource() {
+ return <HighlightedCodeBlock code={eSignatureUsageCode} />
+}
diff --git a/apps/v4/components/extend-deploy-cta.tsx b/apps/v4/components/extend-deploy-cta.tsx
index 6f09719..a432114 100644
--- a/apps/v4/components/extend-deploy-cta.tsx
+++ b/apps/v4/components/extend-deploy-cta.tsx
@@ -1,5 +1,5 @@
import { cn } from "@/lib/utils"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
export function ExtendDeployCta({ className }: React.ComponentProps<"div">) {
return (
diff --git a/apps/v4/components/file-thumbnail-docs.tsx b/apps/v4/components/file-thumbnail-docs.tsx
new file mode 100644
index 0000000..461c8fe
--- /dev/null
+++ b/apps/v4/components/file-thumbnail-docs.tsx
@@ -0,0 +1,552 @@
+"use client"
+
+import * as React from "react"
+import { File01Icon, FileImageIcon } from "@hugeicons/core-free-icons"
+import { HugeiconsIcon } from "@hugeicons/react"
+import type * as ReactPdf from "react-pdf"
+
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+import { HighlightedCodeBlock } from "@/components/highlighted-code-block"
+
+type ThumbnailFile = {
+ name: string
+ type: string
+ url: string
+ size?: string
+}
+
+type FileThumbnailProps = {
+ file: ThumbnailFile
+ className?: string
+ showMetadata?: boolean
+ thumbnailWidth?: number
+}
+
+type ReactPdfModule = typeof ReactPdf
+
+const SAMPLE_FILES: ThumbnailFile[] = [
+ {
+ name: "attention.pdf",
+ type: "application/pdf",
+ url: "/samples/attention.pdf",
+ size: "15 pages",
+ },
+ {
+ name: "opengraph-image.png",
+ type: "image/png",
+ url: "/opengraph-image.png",
+ size: "1200 x 630",
+ },
+]
+
+function isPdfFile(file: ThumbnailFile) {
+ return (
+ file.type === "application/pdf" || file.name.toLowerCase().endsWith(".pdf")
+ )
+}
+
+function isImageFile(file: ThumbnailFile) {
+ return file.type.startsWith("image/")
+}
+
+function useLazyRender<TElement extends HTMLElement>() {
+ const ref = React.useRef<TElement | null>(null)
+ const [shouldRender, setShouldRender] = React.useState(false)
+
+ React.useEffect(() => {
+ const element = ref.current
+ if (!element) return
+
+ if (!("IntersectionObserver" in window)) {
+ setShouldRender(true)
+ return
+ }
+
+ const observer = new IntersectionObserver(
+ ([entry]) => {
+ if (entry?.isIntersecting) {
+ setShouldRender(true)
+ observer.disconnect()
+ }
+ },
+ { rootMargin: "200px" }
+ )
+
+ observer.observe(element)
+
+ return () => observer.disconnect()
+ }, [])
+
+ return { ref, shouldRender }
+}
+
+function FileKindIcon({ file }: { file: ThumbnailFile }) {
+ const icon = isImageFile(file) ? FileImageIcon : File01Icon
+
+ return <HugeiconsIcon icon={icon} className="size-4" />
+}
+
+function ThumbnailLoadingOverlay() {
+ return (
+ <div className="absolute inset-0 z-10 overflow-hidden bg-muted">
+ <style>{`
+ @keyframes file-thumbnail-preview-shimmer {
+ 0% { transform: translateX(-100%); }
+ 100% { transform: translateX(100%); }
+ }
+ @media (prefers-reduced-motion: reduce) {
+ .file-thumbnail-preview-shimmer {
+ animation: none !important;
+ transform: translateX(0);
+ opacity: 0.55;
+ }
+ }
+ `}</style>
+ <div className="absolute inset-0 bg-muted" />
+ <div
+ className="file-thumbnail-preview-shimmer absolute inset-y-0 -left-1/2 w-1/2 bg-linear-to-r from-transparent via-background/65 to-transparent"
+ style={{
+ animation:
+ "file-thumbnail-preview-shimmer 1.25s ease-in-out infinite",
+ }}
+ />
+ </div>
+ )
+}
+
+export function FileThumbnail({
+ file,
+ className,
+ showMetadata = true,
+ thumbnailWidth = 260,
+}: FileThumbnailProps) {
+ const isPdf = isPdfFile(file)
+ const isImage = isImageFile(file)
+ const { ref, shouldRender } = useLazyRender<HTMLDivElement>()
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null)
+ const [isLoading, setIsLoading] = React.useState(isPdf || isImage)
+ const [hasError, setHasError] = React.useState(false)
+
+ React.useEffect(() => {
+ setIsLoading(isPdf || isImage)
+ setHasError(false)
+ }, [file.url, isImage, isPdf])
+
+ React.useEffect(() => {
+ if (!isPdf || !shouldRender) return
+
+ let mounted = true
+ setIsLoading(true)
+
+ void import("react-pdf")
+ .then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${module.pdfjs.version}/legacy/build/pdf.worker.min.mjs`
+
+ if (mounted) {
+ setReactPdf(module)
+ }
+ })
+ .catch(() => {
+ if (mounted) {
+ setHasError(true)
+ setIsLoading(false)
+ }
+ })
+
+ return () => {
+ mounted = false
+ }
+ }, [isPdf, shouldRender])
+
+ return (
+ <div
+ ref={ref}
+ className={cn(
+ "group overflow-hidden rounded-lg border bg-background text-foreground",
+ className
+ )}
+ >
+ <div className="relative aspect-square overflow-hidden bg-muted">
+ {isPdf && shouldRender && reactPdf ? (
+ <reactPdf.Document
+ file={file.url}
+ loading={null}
+ error={null}
+ noData={null}
+ onLoadError={() => {
+ setHasError(true)
+ setIsLoading(false)
+ }}
+ >
+ <reactPdf.Thumbnail
+ pageNumber={1}
+ width={thumbnailWidth}
+ loading={null}
+ error={null}
+ onRenderSuccess={() => setIsLoading(false)}
+ onRenderError={() => {
+ setHasError(true)
+ setIsLoading(false)
+ }}
+ className="flex size-full items-center justify-center [&_canvas]:!h-full [&_canvas]:!w-full [&_canvas]:object-cover"
+ />
+ </reactPdf.Document>
+ ) : null}
+ {isImage ? (
+ <img
+ src={file.url}
+ alt=""
+ loading="lazy"
+ decoding="async"
+ className="size-full object-cover"
+ onLoad={() => setIsLoading(false)}
+ onError={() => {
+ setHasError(true)
+ setIsLoading(false)
+ }}
+ />
+ ) : null}
+ {isLoading && !hasError ? <ThumbnailLoadingOverlay /> : null}
+ {hasError || (!isPdf && !isImage) ? (
+ <div className="absolute inset-0 grid place-items-center bg-muted text-muted-foreground">
+ <FileKindIcon file={file} />
+ </div>
+ ) : null}
+ </div>
+ {showMetadata ? (
+ <div className="flex items-center gap-2 border-t px-3 py-2">
+ <div className="flex size-7 shrink-0 items-center justify-center rounded-md border bg-muted text-muted-foreground">
+ <FileKindIcon file={file} />
+ </div>
+ <div className="min-w-0">
+ <div className="truncate text-sm font-medium">{file.name}</div>
+ <div className="truncate text-xs text-muted-foreground">
+ {file.size ?? file.type}
+ </div>
+ </div>
+ </div>
+ ) : null}
+ </div>
+ )
+}
+
+export function FileThumbnailDemo() {
+ const [isCodeVisible, setIsCodeVisible] = React.useState(false)
+
+ return (
+ <div
+ data-slot="component-preview"
+ className="group relative mt-4 mb-12 flex flex-col overflow-hidden rounded-xl border"
+ >
+ <div className="grid gap-6 bg-background p-6 sm:grid-cols-2">
+ {SAMPLE_FILES.map((file) => (
+ <div key={file.url} className="space-y-2">
+ <div className="text-sm font-medium">
+ {isPdfFile(file) ? "PDF" : "Image"}
+ </div>
+ <FileThumbnail file={file} showMetadata={false} />
+ </div>
+ ))}
+ </div>
+ <div
+ data-slot="code"
+ data-mobile-code-visible={isCodeVisible}
+ className="relative overflow-hidden **:data-[slot=copy-button]:right-4 **:data-[slot=copy-button]:hidden data-[mobile-code-visible=true]:**:data-[slot=copy-button]:flex [&_[data-rehype-pretty-code-figure]]:m-0! [&_[data-rehype-pretty-code-figure]]:rounded-t-none [&_[data-rehype-pretty-code-figure]]:border-t [&_pre]:max-h-72"
+ >
+ {isCodeVisible ? (
+ <HighlightedCodeBlock
+ code={fileThumbnailDemoCode}
+ className="rounded-none border-x-0 border-b-0"
+ />
+ ) : (
+ <div className="relative">
+ <HighlightedCodeBlock
+ code={fileThumbnailDemoCode}
+ className="rounded-none border-x-0 border-b-0"
+ maxHeightClassName="max-h-56"
+ previewLines={10}
+ showCopy={false}
+ />
+ <div className="absolute inset-0 flex items-center justify-center pb-4">
+ <div
+ className="absolute inset-0"
+ style={{
+ background:
+ "linear-gradient(to top, var(--color-code), color-mix(in oklab, var(--color-code) 60%, transparent), transparent)",
+ }}
+ />
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ className="relative z-10 rounded-lg bg-background text-foreground shadow-none hover:bg-muted dark:bg-background dark:text-foreground dark:hover:bg-muted"
+ onClick={() => setIsCodeVisible(true)}
+ >
+ View Code
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
+
+const fileThumbnailDemoCode = `import { FileThumbnail } from "@/components/ui/file-thumbnail";
+
+const files = [
+ {
+ label: "PDF",
+ file: {
+ name: "attention.pdf",
+ type: "application/pdf",
+ url: "/samples/attention.pdf",
+ size: "15 pages",
+ },
+ },
+ {
+ label: "Image",
+ file: {
+ name: "opengraph-image.png",
+ type: "image/png",
+ url: "/opengraph-image.png",
+ size: "1200 x 630",
+ },
+ },
+];
+
+export function FileThumbnailExample() {
+ return (
+ <div className="grid gap-6 sm:grid-cols-2">
+ {files.map((item) => (
+ <div key={item.file.url} className="space-y-2">
+ <div className="text-sm font-medium">{item.label}</div>
+ <FileThumbnail file={item.file} showMetadata={false} />
+ </div>
+ ))}
+ </div>
+ );
+}`
+
+const fileThumbnailUsageCode = `"use client";
+
+import * as React from "react";
+import type * as ReactPdf from "react-pdf";
+import { File01Icon, FileImageIcon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+
+import { cn } from "@/lib/utils";
+
+type ThumbnailFile = {
+ name: string;
+ type: string;
+ url: string;
+ size?: string;
+};
+
+type FileThumbnailProps = {
+ file: ThumbnailFile;
+ className?: string;
+ showMetadata?: boolean;
+ thumbnailWidth?: number;
+};
+
+type ReactPdfModule = typeof ReactPdf;
+
+function isPdfFile(file: ThumbnailFile) {
+ return file.type === "application/pdf" || file.name.toLowerCase().endsWith(".pdf");
+}
+
+function isImageFile(file: ThumbnailFile) {
+ return file.type.startsWith("image/");
+}
+
+function useLazyRender<TElement extends HTMLElement>() {
+ const ref = React.useRef<TElement | null>(null);
+ const [shouldRender, setShouldRender] = React.useState(false);
+
+ React.useEffect(() => {
+ const element = ref.current;
+ if (!element) return;
+
+ if (!("IntersectionObserver" in window)) {
+ setShouldRender(true);
+ return;
+ }
+
+ const observer = new IntersectionObserver(
+ ([entry]) => {
+ if (entry?.isIntersecting) {
+ setShouldRender(true);
+ observer.disconnect();
+ }
+ },
+ { rootMargin: "200px" },
+ );
+
+ observer.observe(element);
+
+ return () => observer.disconnect();
+ }, []);
+
+ return { ref, shouldRender };
+}
+
+function FileKindIcon({ file }: { file: ThumbnailFile }) {
+ const icon = isImageFile(file) ? FileImageIcon : File01Icon;
+
+ return <HugeiconsIcon icon={icon} className="size-4" />;
+}
+
+function ThumbnailLoadingOverlay() {
+ return (
+ <div className="absolute inset-0 z-10 overflow-hidden bg-muted">
+ <style>{\`
+ @keyframes file-thumbnail-preview-shimmer {
+ 0% { transform: translateX(-100%); }
+ 100% { transform: translateX(100%); }
+ }
+ @media (prefers-reduced-motion: reduce) {
+ .file-thumbnail-preview-shimmer {
+ animation: none !important;
+ transform: translateX(0);
+ opacity: 0.55;
+ }
+ }
+ \`}</style>
+ <div className="absolute inset-0 bg-muted" />
+ <div
+ className="file-thumbnail-preview-shimmer absolute inset-y-0 -left-1/2 w-1/2 bg-linear-to-r from-transparent via-background/65 to-transparent"
+ style={{
+ animation: "file-thumbnail-preview-shimmer 1.25s ease-in-out infinite",
+ }}
+ />
+ </div>
+ );
+}
+
+export function FileThumbnail({
+ file,
+ className,
+ showMetadata = true,
+ thumbnailWidth = 260,
+}: FileThumbnailProps) {
+ const isPdf = isPdfFile(file);
+ const isImage = isImageFile(file);
+ const { ref, shouldRender } = useLazyRender<HTMLDivElement>();
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null);
+ const [isLoading, setIsLoading] = React.useState(isPdf || isImage);
+ const [hasError, setHasError] = React.useState(false);
+
+ React.useEffect(() => {
+ setIsLoading(isPdf || isImage);
+ setHasError(false);
+ }, [file.url, isImage, isPdf]);
+
+ React.useEffect(() => {
+ if (!isPdf || !shouldRender) return;
+
+ let mounted = true;
+ setIsLoading(true);
+
+ void import("react-pdf")
+ .then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc =
+ "https://unpkg.com/pdfjs-dist@" +
+ module.pdfjs.version +
+ "/legacy/build/pdf.worker.min.mjs";
+
+ if (mounted) {
+ setReactPdf(module);
+ }
+ })
+ .catch(() => {
+ if (mounted) {
+ setHasError(true);
+ setIsLoading(false);
+ }
+ });
+
+ return () => {
+ mounted = false;
+ };
+ }, [isPdf, shouldRender]);
+
+ return (
+ <div
+ ref={ref}
+ className={cn(
+ "group overflow-hidden rounded-lg border bg-background text-foreground",
+ className,
+ )}
+ >
+ <div className="relative aspect-square overflow-hidden bg-muted">
+ {isPdf && shouldRender && reactPdf ? (
+ <reactPdf.Document
+ file={file.url}
+ loading={null}
+ error={null}
+ noData={null}
+ onLoadError={() => {
+ setHasError(true);
+ setIsLoading(false);
+ }}
+ >
+ <reactPdf.Thumbnail
+ pageNumber={1}
+ width={thumbnailWidth}
+ loading={null}
+ error={null}
+ onRenderSuccess={() => setIsLoading(false)}
+ onRenderError={() => {
+ setHasError(true);
+ setIsLoading(false);
+ }}
+ className="flex size-full items-center justify-center [&_canvas]:!h-full [&_canvas]:!w-full [&_canvas]:object-cover"
+ />
+ </reactPdf.Document>
+ ) : null}
+ {isImage ? (
+ <img
+ src={file.url}
+ alt=""
+ loading="lazy"
+ decoding="async"
+ className="size-full object-cover"
+ onLoad={() => setIsLoading(false)}
+ onError={() => {
+ setHasError(true);
+ setIsLoading(false);
+ }}
+ />
+ ) : null}
+ {isLoading && !hasError ? (
+ <ThumbnailLoadingOverlay />
+ ) : null}
+ {hasError || (!isPdf && !isImage) ? (
+ <div className="absolute inset-0 grid place-items-center bg-muted text-muted-foreground">
+ <FileKindIcon file={file} />
+ </div>
+ ) : null}
+ </div>
+ {showMetadata ? (
+ <div className="flex items-center gap-2 border-t px-3 py-2">
+ <div className="flex size-7 shrink-0 items-center justify-center rounded-md border bg-muted text-muted-foreground">
+ <FileKindIcon file={file} />
+ </div>
+ <div className="min-w-0">
+ <div className="truncate text-sm font-medium">{file.name}</div>
+ <div className="truncate text-xs text-muted-foreground">
+ {file.size ?? file.type}
+ </div>
+ </div>
+ </div>
+ ) : null}
+ </div>
+ );
+}`
+
+export function FileThumbnailSource() {
+ return <HighlightedCodeBlock code={fileThumbnailUsageCode} />
+}
diff --git a/apps/v4/components/file-upload-docs.tsx b/apps/v4/components/file-upload-docs.tsx
new file mode 100644
index 0000000..b6b0004
--- /dev/null
+++ b/apps/v4/components/file-upload-docs.tsx
@@ -0,0 +1,538 @@
+"use client"
+
+import * as React from "react"
+import {
+ FileImageIcon,
+ FileSpreadsheetIcon,
+ FileUploadIcon,
+ Upload01Icon,
+} from "@hugeicons/core-free-icons"
+import { HugeiconsIcon } from "@hugeicons/react"
+import { BorderBeam } from "border-beam"
+import { useTheme } from "next-themes"
+
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+import { FileThumbnail } from "@/components/file-thumbnail-docs"
+import { HighlightedCodeBlock } from "@/components/highlighted-code-block"
+import { Card } from "@/registry/new-york-v4/ui/card"
+
+type FileUploadItem = {
+ id: string
+ name: string
+ type: string
+ size: number
+ url: string
+}
+
+type FileUploadProps = {
+ className?: string
+ onFilesChange?: (files: FileUploadItem[]) => void
+}
+
+const ACCEPTED_FILE_TYPES = [
+ { label: "Image", icon: FileImageIcon },
+ { label: "PDF", icon: FileUploadIcon },
+ { label: "Sheet", icon: FileSpreadsheetIcon },
+]
+const ICON_TRANSFORMS = [
+ {
+ idle: "translate(-78%, -50%) rotate(-8deg)",
+ active: "translate(-114%, -50%) rotate(-12deg) scale(1.08)",
+ },
+ {
+ idle: "translate(-50%, -50%) rotate(0deg)",
+ active: "translate(-50%, -50%) rotate(0deg) scale(1.18)",
+ },
+ {
+ idle: "translate(-22%, -50%) rotate(8deg)",
+ active: "translate(14%, -50%) rotate(12deg) scale(1.08)",
+ },
+]
+
+function formatBytes(bytes: number) {
+ if (bytes === 0) return "0 B"
+
+ const units = ["B", "KB", "MB", "GB"]
+ const index = Math.min(
+ Math.floor(Math.log(bytes) / Math.log(1024)),
+ units.length - 1
+ )
+
+ return `${(bytes / 1024 ** index).toFixed(index === 0 ? 0 : 1)} ${
+ units[index]
+ }`
+}
+
+function toUploadItems(files: FileList | File[]): FileUploadItem[] {
+ return Array.from(files).map((file) => ({
+ id: `${file.name}-${file.size}-${file.lastModified}`,
+ name: file.name,
+ type: file.type || "Unknown type",
+ size: file.size,
+ url: URL.createObjectURL(file),
+ }))
+}
+
+function UploadIconCluster({ isDragging }: { isDragging: boolean }) {
+ return (
+ <div className="relative h-14 w-36">
+ {ACCEPTED_FILE_TYPES.map((item, index) => (
+ <Card
+ key={item.label}
+ className={cn(
+ "absolute top-1/2 left-1/2 grid size-12 place-items-center rounded-xl bg-background text-muted-foreground transition-[transform,color,background-color] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] before:rounded-[calc(var(--radius-xl)-1px)]",
+ "motion-reduce:transition-none",
+ index === 1 && "z-10",
+ isDragging && "bg-accent text-foreground"
+ )}
+ style={{
+ transform: isDragging
+ ? ICON_TRANSFORMS[index]?.active
+ : ICON_TRANSFORMS[index]?.idle,
+ }}
+ >
+ <HugeiconsIcon icon={item.icon} className="size-5" />
+ </Card>
+ ))}
+ </div>
+ )
+}
+
+export function FileUpload({ className, onFilesChange }: FileUploadProps) {
+ const dragDepthRef = React.useRef(0)
+ const { resolvedTheme } = useTheme()
+ const [isDragging, setIsDragging] = React.useState(false)
+ const [files, setFiles] = React.useState<FileUploadItem[]>([])
+ const borderBeamTheme: React.ComponentProps<typeof BorderBeam>["theme"] =
+ resolvedTheme === "dark"
+ ? "dark"
+ : resolvedTheme === "light"
+ ? "light"
+ : "auto"
+
+ const commitFiles = React.useCallback(
+ (nextFiles: FileList | File[]) => {
+ const items = toUploadItems(nextFiles)
+ setFiles((previousFiles) => {
+ previousFiles.forEach((file) => URL.revokeObjectURL(file.url))
+ return items
+ })
+ onFilesChange?.(items)
+ },
+ [onFilesChange]
+ )
+
+ React.useEffect(() => {
+ return () => {
+ files.forEach((file) => URL.revokeObjectURL(file.url))
+ }
+ }, [files])
+
+ return (
+ <div className={cn("space-y-3", className)}>
+ <BorderBeam
+ active={isDragging}
+ borderRadius={18}
+ brightness={2.4}
+ className="rounded-[1.125rem]"
+ colorVariant="ocean"
+ duration={2.4}
+ size="md"
+ strength={1}
+ theme={borderBeamTheme}
+ >
+ <label
+ className={cn(
+ "relative flex min-h-64 cursor-pointer flex-col items-center justify-center gap-5 overflow-hidden rounded-[1.125rem] border border-dashed bg-background px-6 py-10 text-center transition-[border-color,background-color] duration-200 ease-out",
+ "motion-reduce:transition-none",
+ isDragging
+ ? "border-foreground/40 bg-accent/35"
+ : "border-border hover:border-foreground/30 hover:bg-muted/35"
+ )}
+ onDragEnter={(event) => {
+ event.preventDefault()
+ dragDepthRef.current += 1
+ setIsDragging(true)
+ }}
+ onDragLeave={(event) => {
+ event.preventDefault()
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1)
+ if (dragDepthRef.current === 0) {
+ setIsDragging(false)
+ }
+ }}
+ onDragOver={(event) => {
+ event.preventDefault()
+ }}
+ onDrop={(event) => {
+ event.preventDefault()
+ dragDepthRef.current = 0
+ setIsDragging(false)
+
+ if (event.dataTransfer.files.length > 0) {
+ commitFiles(event.dataTransfer.files)
+ }
+ }}
+ >
+ <input
+ type="file"
+ multiple
+ className="sr-only"
+ onChange={(event) => {
+ if (event.target.files) {
+ commitFiles(event.target.files)
+ }
+ }}
+ />
+ <UploadIconCluster isDragging={isDragging} />
+ <div className="space-y-1">
+ <div className="text-sm font-medium">
+ Click to upload or drop files
+ </div>
+ <div className="text-xs text-muted-foreground">
+ PDF, DOCX, XLSX, CSV, PNG, or JPG
+ </div>
+ </div>
+ <div className="inline-flex items-center gap-2 rounded-full border bg-background px-3 py-1 text-xs text-muted-foreground">
+ <HugeiconsIcon icon={Upload01Icon} className="size-3.5" />
+ <span>{isDragging ? "Drop to add" : "Browse files"}</span>
+ </div>
+ </label>
+ </BorderBeam>
+ {files.length > 0 ? (
+ <div className="rounded-xl border bg-background">
+ {files.map((file) => (
+ <div
+ key={file.id}
+ className="flex items-center gap-3 border-b px-3 py-2.5 last:border-b-0"
+ >
+ <FileThumbnail
+ file={{
+ name: file.name,
+ type: file.type,
+ url: file.url,
+ size: formatBytes(file.size),
+ }}
+ className="size-10 shrink-0 rounded-lg"
+ showMetadata={false}
+ thumbnailWidth={56}
+ />
+ <div className="min-w-0 flex-1">
+ <div className="truncate text-sm font-medium">{file.name}</div>
+ <div className="truncate text-xs text-muted-foreground">
+ {file.type} - {formatBytes(file.size)}
+ </div>
+ </div>
+ <div className="rounded-full bg-muted px-2 py-1 text-xs text-muted-foreground">
+ Ready
+ </div>
+ </div>
+ ))}
+ </div>
+ ) : null}
+ </div>
+ )
+}
+
+export function FileUploadDemo() {
+ const [isCodeVisible, setIsCodeVisible] = React.useState(false)
+
+ return (
+ <div
+ data-slot="component-preview"
+ className="group relative mt-4 mb-12 flex flex-col overflow-hidden rounded-xl border"
+ >
+ <div className="bg-background p-4">
+ <FileUpload />
+ </div>
+ <div
+ data-slot="code"
+ data-mobile-code-visible={isCodeVisible}
+ className="relative overflow-hidden **:data-[slot=copy-button]:right-4 **:data-[slot=copy-button]:hidden data-[mobile-code-visible=true]:**:data-[slot=copy-button]:flex [&_[data-rehype-pretty-code-figure]]:m-0! [&_[data-rehype-pretty-code-figure]]:rounded-t-none [&_[data-rehype-pretty-code-figure]]:border-t [&_pre]:max-h-72"
+ >
+ {isCodeVisible ? (
+ <HighlightedCodeBlock
+ code={fileUploadDemoCode}
+ className="rounded-none border-x-0 border-b-0"
+ />
+ ) : (
+ <div className="relative">
+ <HighlightedCodeBlock
+ code={fileUploadDemoCode}
+ className="rounded-none border-x-0 border-b-0"
+ maxHeightClassName="max-h-56"
+ previewLines={10}
+ showCopy={false}
+ />
+ <div className="absolute inset-0 flex items-center justify-center pb-4">
+ <div
+ className="absolute inset-0"
+ style={{
+ background:
+ "linear-gradient(to top, var(--color-code), color-mix(in oklab, var(--color-code) 60%, transparent), transparent)",
+ }}
+ />
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ className="relative z-10 rounded-lg bg-background text-foreground shadow-none hover:bg-muted dark:bg-background dark:text-foreground dark:hover:bg-muted"
+ onClick={() => setIsCodeVisible(true)}
+ >
+ View Code
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
+
+const fileUploadDemoCode = `import { FileUpload } from "@/components/ui/file-upload";
+
+export function FileUploadExample() {
+ return (
+ <div className="rounded-xl border bg-background p-4">
+ <FileUpload />
+ </div>
+ );
+}`
+
+const fileUploadUsageCode = `"use client";
+
+import * as React from "react";
+import { useTheme } from "next-themes";
+import { BorderBeam } from "border-beam";
+import {
+ FileImageIcon,
+ FileSpreadsheetIcon,
+ FileUploadIcon,
+ Upload01Icon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+
+import { cn } from "@/lib/utils";
+import { Card } from "@/components/ui/card";
+import { FileThumbnail } from "@/components/ui/file-thumbnail";
+
+type FileUploadItem = {
+ id: string;
+ name: string;
+ type: string;
+ size: number;
+ url: string;
+};
+
+type FileUploadProps = {
+ className?: string;
+ onFilesChange?: (files: FileUploadItem[]) => void;
+};
+
+const ACCEPTED_FILE_TYPES = [
+ { label: "Image", icon: FileImageIcon },
+ { label: "PDF", icon: FileUploadIcon },
+ { label: "Sheet", icon: FileSpreadsheetIcon },
+];
+const ICON_TRANSFORMS = [
+ {
+ idle: "translate(-78%, -50%) rotate(-8deg)",
+ active: "translate(-114%, -50%) rotate(-12deg) scale(1.08)",
+ },
+ {
+ idle: "translate(-50%, -50%) rotate(0deg)",
+ active: "translate(-50%, -50%) rotate(0deg) scale(1.18)",
+ },
+ {
+ idle: "translate(-22%, -50%) rotate(8deg)",
+ active: "translate(14%, -50%) rotate(12deg) scale(1.08)",
+ },
+];
+
+function formatBytes(bytes: number) {
+ if (bytes === 0) return "0 B";
+
+ const units = ["B", "KB", "MB", "GB"];
+ const index = Math.min(
+ Math.floor(Math.log(bytes) / Math.log(1024)),
+ units.length - 1,
+ );
+
+ return \`\${(bytes / 1024 ** index).toFixed(index === 0 ? 0 : 1)} \${units[index]}\`;
+}
+
+function toUploadItems(files: FileList | File[]): FileUploadItem[] {
+ return Array.from(files).map((file) => ({
+ id: \`\${file.name}-\${file.size}-\${file.lastModified}\`,
+ name: file.name,
+ type: file.type || "Unknown type",
+ size: file.size,
+ url: URL.createObjectURL(file),
+ }));
+}
+
+function UploadIconCluster({ isDragging }: { isDragging: boolean }) {
+ return (
+ <div className="relative h-14 w-36">
+ {ACCEPTED_FILE_TYPES.map((item, index) => (
+ <Card
+ key={item.label}
+ className={cn(
+ "absolute top-1/2 left-1/2 grid size-12 place-items-center rounded-xl bg-background text-muted-foreground transition-[transform,color,background-color] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] before:rounded-[calc(var(--radius-xl)-1px)]",
+ "motion-reduce:transition-none",
+ index === 1 && "z-10",
+ isDragging && "bg-accent text-foreground",
+ )}
+ style={{
+ transform: isDragging
+ ? ICON_TRANSFORMS[index]?.active
+ : ICON_TRANSFORMS[index]?.idle,
+ }}
+ >
+ <HugeiconsIcon icon={item.icon} className="size-5" />
+ </Card>
+ ))}
+ </div>
+ );
+}
+
+export function FileUpload({ className, onFilesChange }: FileUploadProps) {
+ const dragDepthRef = React.useRef(0);
+ const { resolvedTheme } = useTheme();
+ const [isDragging, setIsDragging] = React.useState(false);
+ const [files, setFiles] = React.useState<FileUploadItem[]>([]);
+ const borderBeamTheme: React.ComponentProps<typeof BorderBeam>["theme"] =
+ resolvedTheme === "dark"
+ ? "dark"
+ : resolvedTheme === "light"
+ ? "light"
+ : "auto";
+
+ const commitFiles = React.useCallback(
+ (nextFiles: FileList | File[]) => {
+ const items = toUploadItems(nextFiles);
+ setFiles((previousFiles) => {
+ previousFiles.forEach((file) => URL.revokeObjectURL(file.url));
+ return items;
+ });
+ onFilesChange?.(items);
+ },
+ [onFilesChange],
+ );
+
+ React.useEffect(() => {
+ return () => {
+ files.forEach((file) => URL.revokeObjectURL(file.url));
+ };
+ }, [files]);
+
+ return (
+ <div className={cn("space-y-3", className)}>
+ <BorderBeam
+ active={isDragging}
+ borderRadius={18}
+ brightness={2.4}
+ className="rounded-[1.125rem]"
+ colorVariant="ocean"
+ duration={2.4}
+ size="md"
+ strength={1}
+ theme={borderBeamTheme}
+ >
+ <label
+ className={cn(
+ "relative flex min-h-64 cursor-pointer flex-col items-center justify-center gap-5 overflow-hidden rounded-[1.125rem] border border-dashed bg-background px-6 py-10 text-center transition-[border-color,background-color] duration-200 ease-out",
+ "motion-reduce:transition-none",
+ isDragging
+ ? "border-foreground/40 bg-accent/35"
+ : "border-border hover:border-foreground/30 hover:bg-muted/35",
+ )}
+ onDragEnter={(event) => {
+ event.preventDefault();
+ dragDepthRef.current += 1;
+ setIsDragging(true);
+ }}
+ onDragLeave={(event) => {
+ event.preventDefault();
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);
+ if (dragDepthRef.current === 0) {
+ setIsDragging(false);
+ }
+ }}
+ onDragOver={(event) => {
+ event.preventDefault();
+ }}
+ onDrop={(event) => {
+ event.preventDefault();
+ dragDepthRef.current = 0;
+ setIsDragging(false);
+
+ if (event.dataTransfer.files.length > 0) {
+ commitFiles(event.dataTransfer.files);
+ }
+ }}
+ >
+ <input
+ type="file"
+ multiple
+ className="sr-only"
+ onChange={(event) => {
+ if (event.target.files) {
+ commitFiles(event.target.files);
+ }
+ }}
+ />
+ <UploadIconCluster isDragging={isDragging} />
+ <div className="space-y-1">
+ <div className="text-sm font-medium">
+ Click to upload or drop files
+ </div>
+ <div className="text-xs text-muted-foreground">
+ PDF, DOCX, XLSX, CSV, PNG, or JPG
+ </div>
+ </div>
+ <div className="inline-flex items-center gap-2 rounded-full border bg-background px-3 py-1 text-xs text-muted-foreground">
+ <HugeiconsIcon icon={Upload01Icon} className="size-3.5" />
+ <span>{isDragging ? "Drop to add" : "Browse files"}</span>
+ </div>
+ </label>
+ </BorderBeam>
+ {files.length > 0 ? (
+ <div className="rounded-xl border bg-background">
+ {files.map((file) => (
+ <div
+ key={file.id}
+ className="flex items-center gap-3 border-b px-3 py-2.5 last:border-b-0"
+ >
+ <FileThumbnail
+ file={{
+ name: file.name,
+ type: file.type,
+ url: file.url,
+ size: formatBytes(file.size),
+ }}
+ className="size-10 shrink-0 rounded-lg"
+ showMetadata={false}
+ thumbnailWidth={56}
+ />
+ <div className="min-w-0 flex-1">
+ <div className="truncate text-sm font-medium">{file.name}</div>
+ <div className="truncate text-xs text-muted-foreground">
+ {file.type} - {formatBytes(file.size)}
+ </div>
+ </div>
+ <div className="rounded-full bg-muted px-2 py-1 text-xs text-muted-foreground">
+ Ready
+ </div>
+ </div>
+ ))}
+ </div>
+ ) : null}
+ </div>
+ );
+}`
+
+export function FileUploadSource() {
+ return <HighlightedCodeBlock code={fileUploadUsageCode} />
+}
diff --git a/apps/v4/components/github-link.tsx b/apps/v4/components/github-link.tsx
index 8aefdcf..1b1c3a4 100644
--- a/apps/v4/components/github-link.tsx
+++ b/apps/v4/components/github-link.tsx
@@ -1,8 +1,8 @@
import Link from "next/link"
import { siteConfig } from "@/lib/config"
+import { Button } from "@/components/ui/button"
import { Icons } from "@/components/icons"
-import { Button } from "@/registry/new-york-v4/ui/button"
export function GitHubLink() {
return (
diff --git a/apps/v4/components/highlighted-code-block.tsx b/apps/v4/components/highlighted-code-block.tsx
index 695b1d2..6fa8c5a 100644
--- a/apps/v4/components/highlighted-code-block.tsx
+++ b/apps/v4/components/highlighted-code-block.tsx
@@ -44,7 +44,7 @@ export function HighlightedCodeBlock({
node.properties["data-language"] = "tsx"
node.properties["style"] = ""
node.properties["class"] = cn(
- "no-scrollbar min-w-0 overflow-x-auto overflow-y-auto overscroll-x-contain overscroll-y-auto px-4 py-3.5 outline-none has-[[data-line-numbers]]:px-0 !bg-transparent",
+ "no-scrollbar min-w-0 overflow-x-auto overflow-y-auto overscroll-x-contain overscroll-y-auto !bg-transparent px-4 py-3.5 outline-none has-[[data-line-numbers]]:px-0",
showCopy && "pr-20",
maxHeightClassName
)
diff --git a/apps/v4/components/main-nav.tsx b/apps/v4/components/main-nav.tsx
index a06f9f6..677dbae 100644
--- a/apps/v4/components/main-nav.tsx
+++ b/apps/v4/components/main-nav.tsx
@@ -4,7 +4,7 @@ import Link from "next/link"
import { usePathname } from "next/navigation"
import { cn } from "@/lib/utils"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
export function MainNav({
items,
diff --git a/apps/v4/components/mobile-nav.tsx b/apps/v4/components/mobile-nav.tsx
index 9f6c12b..42f5c10 100644
--- a/apps/v4/components/mobile-nav.tsx
+++ b/apps/v4/components/mobile-nav.tsx
@@ -8,7 +8,7 @@ import { showMcpDocs } from "@/lib/flags"
import { getCurrentBase, getPagesFromFolder } from "@/lib/page-tree"
import { type source } from "@/lib/source"
import { cn } from "@/lib/utils"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
import {
Popover,
PopoverContent,
diff --git a/apps/v4/components/mode-switcher.tsx b/apps/v4/components/mode-switcher.tsx
index 5858dec..2c7e261 100644
--- a/apps/v4/components/mode-switcher.tsx
+++ b/apps/v4/components/mode-switcher.tsx
@@ -6,7 +6,7 @@ import { useTheme } from "next-themes"
import { cn } from "@/lib/utils"
import { useMetaColor } from "@/hooks/use-meta-color"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
export const DARK_MODE_FORWARD_TYPE = "dark-mode-forward"
diff --git a/apps/v4/components/ocr-blocks-docs.tsx b/apps/v4/components/ocr-blocks-docs.tsx
new file mode 100644
index 0000000..920e0f7
--- /dev/null
+++ b/apps/v4/components/ocr-blocks-docs.tsx
@@ -0,0 +1,785 @@
+"use client"
+
+import * as React from "react"
+import {
+ Heading01Icon,
+ Image01Icon,
+ LeftToRightListBulletIcon,
+ Loading03Icon,
+ ParagraphIcon,
+ Table01Icon,
+} from "@hugeicons/core-free-icons"
+import { HugeiconsIcon } from "@hugeicons/react"
+import type * as ReactPdf from "react-pdf"
+
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+import { HighlightedCodeBlock } from "@/components/highlighted-code-block"
+
+type Point = {
+ x: number
+ y: number
+}
+
+type OcrBlockType = "heading" | "paragraph" | "list" | "table" | "image"
+
+type OcrBlock = {
+ id: string
+ type: OcrBlockType
+ label: string
+ text: string
+ page: number
+ confidence: number
+ polygon: Point[]
+}
+
+type HighlightArea = {
+ left: number
+ top: number
+ width: number
+ height: number
+}
+
+type ReactPdfModule = typeof ReactPdf
+
+const PDF_URL = "/samples/attention.pdf"
+const PDF_WORKER_URL = new URL(
+ "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
+ import.meta.url
+).toString()
+const PAGE_WIDTH = 792
+const PAGE_HEIGHT = 612
+const RENDERED_PAGE_WIDTH = 430
+const RENDERED_PAGE_HEIGHT = Math.round(
+ RENDERED_PAGE_WIDTH * (PAGE_HEIGHT / PAGE_WIDTH)
+)
+const DEVICE_PIXEL_RATIO_LIMIT = 2
+const PREVIEW_PAGES = [1, 2, 3, 6]
+
+const BLOCK_STYLES: Record<
+ OcrBlockType,
+ {
+ label: string
+ icon: typeof Heading01Icon
+ overlay: string
+ mutedOverlay: string
+ ring: string
+ soft: string
+ text: string
+ }
+> = {
+ heading: {
+ label: "Heading",
+ icon: Heading01Icon,
+ overlay:
+ "border-violet-500/70 bg-violet-500/10 shadow-[0_4px_16px_rgb(139_92_246_/_12%)]",
+ mutedOverlay: "border-violet-500/35 bg-violet-500/5",
+ ring: "border-violet-500/60 bg-violet-500/5",
+ soft: "bg-violet-500/10 text-violet-600 dark:text-violet-300",
+ text: "text-violet-600 dark:text-violet-300",
+ },
+ paragraph: {
+ label: "Paragraph",
+ icon: ParagraphIcon,
+ overlay:
+ "border-blue-500/70 bg-blue-500/10 shadow-[0_4px_16px_rgb(59_130_246_/_12%)]",
+ mutedOverlay: "border-blue-500/35 bg-blue-500/5",
+ ring: "border-blue-500/60 bg-blue-500/5",
+ soft: "bg-blue-500/10 text-blue-600 dark:text-blue-300",
+ text: "text-blue-600 dark:text-blue-300",
+ },
+ list: {
+ label: "List",
+ icon: LeftToRightListBulletIcon,
+ overlay:
+ "border-emerald-500/70 bg-emerald-500/10 shadow-[0_4px_16px_rgb(16_185_129_/_12%)]",
+ mutedOverlay: "border-emerald-500/35 bg-emerald-500/5",
+ ring: "border-emerald-500/60 bg-emerald-500/5",
+ soft: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-300",
+ text: "text-emerald-600 dark:text-emerald-300",
+ },
+ table: {
+ label: "Table",
+ icon: Table01Icon,
+ overlay:
+ "border-amber-500/70 bg-amber-500/10 shadow-[0_4px_16px_rgb(245_158_11_/_12%)]",
+ mutedOverlay: "border-amber-500/35 bg-amber-500/5",
+ ring: "border-amber-500/60 bg-amber-500/5",
+ soft: "bg-amber-500/10 text-amber-700 dark:text-amber-300",
+ text: "text-amber-700 dark:text-amber-300",
+ },
+ image: {
+ label: "Image",
+ icon: Image01Icon,
+ overlay:
+ "border-rose-500/70 bg-rose-500/10 shadow-[0_4px_16px_rgb(244_63_94_/_12%)]",
+ mutedOverlay: "border-rose-500/35 bg-rose-500/5",
+ ring: "border-rose-500/60 bg-rose-500/5",
+ soft: "bg-rose-500/10 text-rose-600 dark:text-rose-300",
+ text: "text-rose-600 dark:text-rose-300",
+ },
+}
+
+const OCR_BLOCKS: OcrBlock[] = [
+ {
+ id: "title",
+ type: "heading",
+ label: "Paper title",
+ text: "Attention Is All You Need",
+ page: 1,
+ confidence: 0.99,
+ polygon: [
+ { x: 246, y: 188 },
+ { x: 566, y: 188 },
+ { x: 566, y: 222 },
+ { x: 246, y: 222 },
+ ],
+ },
+ {
+ id: "author-grid",
+ type: "paragraph",
+ label: "Authors",
+ text: "Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit...",
+ page: 1,
+ confidence: 0.96,
+ polygon: [
+ { x: 92, y: 206 },
+ { x: 698, y: 206 },
+ { x: 698, y: 270 },
+ { x: 92, y: 270 },
+ ],
+ },
+ {
+ id: "abstract-heading",
+ type: "heading",
+ label: "Section heading",
+ text: "Abstract",
+ page: 1,
+ confidence: 0.98,
+ polygon: [
+ { x: 360, y: 330 },
+ { x: 434, y: 330 },
+ { x: 434, y: 350 },
+ { x: 360, y: 350 },
+ ],
+ },
+ {
+ id: "abstract-body",
+ type: "paragraph",
+ label: "Abstract body",
+ text: "The dominant sequence transduction models are based on complex recurrent or convolutional neural networks...",
+ page: 1,
+ confidence: 0.94,
+ polygon: [
+ { x: 108, y: 346 },
+ { x: 692, y: 346 },
+ { x: 692, y: 458 },
+ { x: 108, y: 458 },
+ ],
+ },
+ {
+ id: "background-body",
+ type: "paragraph",
+ label: "Background text",
+ text: "Recurrent neural networks, long short-term memory and gated recurrent neural networks...",
+ page: 2,
+ confidence: 0.92,
+ polygon: [
+ { x: 76, y: 74 },
+ { x: 718, y: 74 },
+ { x: 718, y: 184 },
+ { x: 76, y: 184 },
+ ],
+ },
+ {
+ id: "attention-diagram",
+ type: "image",
+ label: "Architecture figure",
+ text: "Transformer architecture diagram",
+ page: 2,
+ confidence: 0.89,
+ polygon: [
+ { x: 462, y: 250 },
+ { x: 720, y: 250 },
+ { x: 720, y: 602 },
+ { x: 462, y: 602 },
+ ],
+ },
+ {
+ id: "comparison-table",
+ type: "table",
+ label: "Complexity table",
+ text: "Layer type, complexity per layer, sequential operations, maximum path length",
+ page: 6,
+ confidence: 0.91,
+ polygon: [
+ { x: 52, y: 58 },
+ { x: 740, y: 58 },
+ { x: 740, y: 190 },
+ { x: 52, y: 190 },
+ ],
+ },
+ {
+ id: "layer-list",
+ type: "list",
+ label: "Comparison criteria",
+ text: "Total computational complexity, parallelizable computation, and maximum path length",
+ page: 6,
+ confidence: 0.88,
+ polygon: [
+ { x: 56, y: 440 },
+ { x: 735, y: 440 },
+ { x: 735, y: 548 },
+ { x: 56, y: 548 },
+ ],
+ },
+]
+
+function convertPolygonToHighlightArea(polygon: Point[]): HighlightArea {
+ const xValues = polygon.map((point) => point.x)
+ const yValues = polygon.map((point) => point.y)
+ const left = Math.min(...xValues)
+ const right = Math.max(...xValues)
+ const top = Math.min(...yValues)
+ const bottom = Math.max(...yValues)
+
+ return {
+ left: (left / PAGE_WIDTH) * 100,
+ top: (top / PAGE_HEIGHT) * 100,
+ width: ((right - left) / PAGE_WIDTH) * 100,
+ height: ((bottom - top) / PAGE_HEIGHT) * 100,
+ }
+}
+
+function BlockOverlay({
+ block,
+ isActive,
+}: {
+ block: OcrBlock
+ isActive: boolean
+}) {
+ const highlight = convertPolygonToHighlightArea(block.polygon)
+ const style = BLOCK_STYLES[block.type]
+
+ return (
+ <div
+ className={cn(
+ "pointer-events-none absolute z-10 rounded-[3px] border transition-[opacity,box-shadow]",
+ isActive
+ ? cn("opacity-100", style.overlay)
+ : cn("opacity-55", style.mutedOverlay)
+ )}
+ style={{
+ left: `${highlight.left}%`,
+ top: `${highlight.top}%`,
+ width: `${highlight.width}%`,
+ height: `${highlight.height}%`,
+ }}
+ />
+ )
+}
+
+function OcrPage({
+ pageNumber,
+ activeBlock,
+ reactPdf,
+}: {
+ pageNumber: number
+ activeBlock: OcrBlock | null
+ reactPdf: ReactPdfModule
+}) {
+ const devicePixelRatio =
+ typeof window === "undefined"
+ ? 1
+ : Math.min(DEVICE_PIXEL_RATIO_LIMIT, window.devicePixelRatio || 1)
+ const pageBlocks = OCR_BLOCKS.filter((block) => block.page === pageNumber)
+
+ return (
+ <div
+ data-ocr-page={pageNumber}
+ className="relative"
+ style={{ width: RENDERED_PAGE_WIDTH, height: RENDERED_PAGE_HEIGHT }}
+ >
+ <reactPdf.Page
+ pageNumber={pageNumber}
+ width={RENDERED_PAGE_WIDTH}
+ className="overflow-hidden border bg-background shadow-xs"
+ renderAnnotationLayer={false}
+ renderTextLayer={false}
+ devicePixelRatio={devicePixelRatio}
+ loading={
+ <div
+ className="grid place-items-center"
+ style={{ width: RENDERED_PAGE_WIDTH, height: RENDERED_PAGE_HEIGHT }}
+ >
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ }
+ />
+ {pageBlocks.map((block) => (
+ <BlockOverlay
+ key={block.id}
+ block={block}
+ isActive={activeBlock?.id === block.id}
+ />
+ ))}
+ </div>
+ )
+}
+
+export function OcrBlocks() {
+ const [activeBlockId, setActiveBlockId] = React.useState(OCR_BLOCKS[0].id)
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null)
+ const [loadError, setLoadError] = React.useState(false)
+ const viewportRef = React.useRef<HTMLDivElement>(null)
+ const activeBlock =
+ OCR_BLOCKS.find((block) => block.id === activeBlockId) ?? OCR_BLOCKS[0]
+
+ React.useEffect(() => {
+ let mounted = true
+
+ void import("react-pdf")
+ .then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc = PDF_WORKER_URL
+
+ if (mounted) {
+ setReactPdf(module)
+ }
+ })
+ .catch(() => {
+ if (mounted) {
+ setLoadError(true)
+ }
+ })
+
+ return () => {
+ mounted = false
+ }
+ }, [])
+
+ const focusBlock = React.useCallback((block: OcrBlock) => {
+ setActiveBlockId(block.id)
+
+ window.requestAnimationFrame(() => {
+ const viewport = viewportRef.current
+ const page = viewport?.querySelector<HTMLElement>(
+ `[data-ocr-page="${block.page}"]`
+ )
+
+ if (!viewport || !page) return
+
+ const highlight = convertPolygonToHighlightArea(block.polygon)
+ const pageTop =
+ page.getBoundingClientRect().top -
+ viewport.getBoundingClientRect().top +
+ viewport.scrollTop
+ const targetTop =
+ pageTop + (highlight.top / 100) * RENDERED_PAGE_HEIGHT - 96
+
+ viewport.scrollTo({
+ top: Math.max(0, targetTop),
+ behavior: "smooth",
+ })
+ })
+ }, [])
+
+ return (
+ <div className="grid h-[620px] overflow-hidden bg-background lg:grid-cols-[minmax(0,1fr)_20rem]">
+ <div className="flex min-h-0 min-w-0 flex-col border-b lg:border-r lg:border-b-0">
+ <div className="flex h-12 shrink-0 items-center justify-between border-b px-4">
+ <div className="text-sm font-medium">PDF Viewer</div>
+ <div className="text-xs text-muted-foreground">
+ Page {activeBlock.page}
+ </div>
+ </div>
+ <div
+ ref={viewportRef}
+ className="min-h-0 flex-1 overflow-auto bg-muted/30"
+ >
+ {loadError ? (
+ <div className="grid h-full place-items-center p-6 text-sm text-muted-foreground">
+ Unable to load the PDF preview.
+ </div>
+ ) : reactPdf ? (
+ <reactPdf.Document
+ file={PDF_URL}
+ className="flex min-h-full w-max min-w-full flex-col items-center gap-6 p-6"
+ loading={
+ <div className="grid h-full min-h-80 place-items-center">
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ }
+ error={null}
+ onLoadError={() => setLoadError(true)}
+ >
+ {PREVIEW_PAGES.map((pageNumber) => (
+ <OcrPage
+ key={pageNumber}
+ pageNumber={pageNumber}
+ activeBlock={activeBlock}
+ reactPdf={reactPdf}
+ />
+ ))}
+ </reactPdf.Document>
+ ) : (
+ <div className="grid h-full min-h-80 place-items-center">
+ <HugeiconsIcon
+ icon={Loading03Icon}
+ className="size-4 animate-spin"
+ />
+ </div>
+ )}
+ </div>
+ </div>
+ <aside className="flex min-h-0 flex-col">
+ <div className="border-b px-4 py-3">
+ <div className="text-sm font-medium">OCR Blocks</div>
+ <div className="text-xs text-muted-foreground">
+ Hover a block to inspect its extracted region.
+ </div>
+ </div>
+ <div className="min-h-0 flex-1 overflow-y-auto p-3">
+ <div className="space-y-2">
+ {OCR_BLOCKS.map((block) => {
+ const isActive = block.id === activeBlock.id
+ const style = BLOCK_STYLES[block.type]
+
+ return (
+ <button
+ key={block.id}
+ type="button"
+ onClick={() => focusBlock(block)}
+ onFocus={() => focusBlock(block)}
+ onMouseEnter={() => focusBlock(block)}
+ className={cn(
+ "w-full rounded-lg border bg-background p-3 text-left transition-[border-color,background-color,box-shadow] hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
+ isActive &&
+ cn("shadow-[0_0_0_1px_rgb(0_0_0_/_4%)]", style.ring)
+ )}
+ >
+ <div className="flex items-start gap-3">
+ <div
+ className={cn(
+ "mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md",
+ style.soft
+ )}
+ >
+ <HugeiconsIcon icon={style.icon} className="size-4" />
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="flex items-center justify-between gap-2">
+ <div className="truncate text-sm font-medium">
+ {block.label}
+ </div>
+ <div className="shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground">
+ p. {block.page}
+ </div>
+ </div>
+ <div
+ className={cn("mt-0.5 text-xs font-medium", style.text)}
+ >
+ {style.label} · {Math.round(block.confidence * 100)}%
+ </div>
+ <div className="mt-2 line-clamp-3 text-sm text-foreground/90">
+ {block.text}
+ </div>
+ </div>
+ </div>
+ </button>
+ )
+ })}
+ </div>
+ </div>
+ </aside>
+ </div>
+ )
+}
+
+export function OcrBlocksDemo() {
+ const [isCodeVisible, setIsCodeVisible] = React.useState(false)
+
+ return (
+ <div
+ data-slot="component-preview"
+ className="group relative mt-4 mb-12 flex flex-col overflow-hidden rounded-xl border"
+ >
+ <OcrBlocks />
+ <div
+ data-slot="code"
+ data-mobile-code-visible={isCodeVisible}
+ className="relative overflow-hidden **:data-[slot=copy-button]:right-4 **:data-[slot=copy-button]:hidden data-[mobile-code-visible=true]:**:data-[slot=copy-button]:flex [&_[data-rehype-pretty-code-figure]]:m-0! [&_[data-rehype-pretty-code-figure]]:rounded-t-none [&_[data-rehype-pretty-code-figure]]:border-t [&_pre]:max-h-72"
+ >
+ {isCodeVisible ? (
+ <HighlightedCodeBlock
+ code={ocrBlocksUsageCode}
+ className="rounded-none border-x-0 border-b-0"
+ />
+ ) : (
+ <div className="relative">
+ <HighlightedCodeBlock
+ code={ocrBlocksUsageCode}
+ className="rounded-none border-x-0 border-b-0"
+ maxHeightClassName="max-h-56"
+ previewLines={10}
+ showCopy={false}
+ />
+ <div className="absolute inset-0 flex items-center justify-center pb-4">
+ <div
+ className="absolute inset-0"
+ style={{
+ background:
+ "linear-gradient(to top, var(--color-code), color-mix(in oklab, var(--color-code) 60%, transparent), transparent)",
+ }}
+ />
+ <Button
+ type="button"
+ size="sm"
+ variant="outline"
+ className="relative z-10 rounded-lg bg-background text-foreground shadow-none hover:bg-muted dark:bg-background dark:text-foreground dark:hover:bg-muted"
+ onClick={() => setIsCodeVisible(true)}
+ >
+ View Code
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
+
+const ocrBlocksUsageCode = `"use client";
+
+import * as React from "react";
+import {
+ Heading01Icon,
+ Image01Icon,
+ LeftToRightListBulletIcon,
+ Loading03Icon,
+ ParagraphIcon,
+ Table01Icon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import type * as ReactPdf from "react-pdf";
+
+import { cn } from "@/lib/utils";
+
+type ReactPdfModule = typeof ReactPdf;
+type Point = { x: number; y: number };
+type OcrBlockType = "heading" | "paragraph" | "list" | "table" | "image";
+
+type OcrBlock = {
+ id: string;
+ type: OcrBlockType;
+ label: string;
+ text: string;
+ page: number;
+ confidence: number;
+ polygon: Point[];
+};
+
+const PDF_URL = "/samples/attention.pdf";
+const PDF_WORKER_URL = new URL(
+ "pdfjs-dist/legacy/build/pdf.worker.min.mjs",
+ import.meta.url,
+).toString();
+const PAGE_WIDTH = 792;
+const PAGE_HEIGHT = 612;
+const RENDERED_PAGE_WIDTH = 430;
+const RENDERED_PAGE_HEIGHT = Math.round(RENDERED_PAGE_WIDTH * (PAGE_HEIGHT / PAGE_WIDTH));
+
+const OCR_BLOCKS: OcrBlock[] = [
+ {
+ id: "title",
+ type: "heading",
+ label: "Paper title",
+ text: "Attention Is All You Need",
+ page: 1,
+ confidence: 0.99,
+ polygon: [
+ { x: 246, y: 188 },
+ { x: 566, y: 188 },
+ { x: 566, y: 222 },
+ { x: 246, y: 222 },
+ ],
+ },
+ {
+ id: "abstract-body",
+ type: "paragraph",
+ label: "Abstract body",
+ text: "The dominant sequence transduction models are based on complex recurrent or convolutional neural networks...",
+ page: 1,
+ confidence: 0.94,
+ polygon: [
+ { x: 108, y: 346 },
+ { x: 692, y: 346 },
+ { x: 692, y: 458 },
+ { x: 108, y: 458 },
+ ],
+ },
+];
+
+const BLOCK_STYLES = {
+ heading: {
+ icon: Heading01Icon,
+ active: "border-violet-500/70 bg-violet-500/10 shadow-[0_4px_16px_rgb(139_92_246_/_12%)]",
+ muted: "border-violet-500/35 bg-violet-500/5",
+ },
+ paragraph: {
+ icon: ParagraphIcon,
+ active: "border-blue-500/70 bg-blue-500/10 shadow-[0_4px_16px_rgb(59_130_246_/_12%)]",
+ muted: "border-blue-500/35 bg-blue-500/5",
+ },
+ list: {
+ icon: LeftToRightListBulletIcon,
+ active: "border-emerald-500/70 bg-emerald-500/10 shadow-[0_4px_16px_rgb(16_185_129_/_12%)]",
+ muted: "border-emerald-500/35 bg-emerald-500/5",
+ },
+ table: {
+ icon: Table01Icon,
+ active: "border-amber-500/70 bg-amber-500/10 shadow-[0_4px_16px_rgb(245_158_11_/_12%)]",
+ muted: "border-amber-500/35 bg-amber-500/5",
+ },
+ image: {
+ icon: Image01Icon,
+ active: "border-rose-500/70 bg-rose-500/10 shadow-[0_4px_16px_rgb(244_63_94_/_12%)]",
+ muted: "border-rose-500/35 bg-rose-500/5",
+ },
+};
+
+function toHighlight(polygon: Point[]) {
+ const xs = polygon.map((point) => point.x);
+ const ys = polygon.map((point) => point.y);
+ const left = Math.min(...xs);
+ const right = Math.max(...xs);
+ const top = Math.min(...ys);
+ const bottom = Math.max(...ys);
+
+ return {
+ left: (left / PAGE_WIDTH) * 100,
+ top: (top / PAGE_HEIGHT) * 100,
+ width: ((right - left) / PAGE_WIDTH) * 100,
+ height: ((bottom - top) / PAGE_HEIGHT) * 100,
+ };
+}
+
+export function OcrBlocks() {
+ const [reactPdf, setReactPdf] = React.useState<ReactPdfModule | null>(null);
+ const [activeBlockId, setActiveBlockId] = React.useState(OCR_BLOCKS[0].id);
+ const viewportRef = React.useRef<HTMLDivElement>(null);
+ const activeBlock =
+ OCR_BLOCKS.find((block) => block.id === activeBlockId) ?? OCR_BLOCKS[0];
+
+ React.useEffect(() => {
+ let mounted = true;
+
+ void import("react-pdf").then((module) => {
+ module.pdfjs.GlobalWorkerOptions.workerSrc = PDF_WORKER_URL;
+ if (mounted) setReactPdf(module);
+ });
+
+ return () => {
+ mounted = false;
+ };
+ }, []);
+
+ function focusBlock(block: OcrBlock) {
+ setActiveBlockId(block.id);
+ window.requestAnimationFrame(() => {
+ const page = viewportRef.current?.querySelector<HTMLElement>(
+ \`[data-ocr-page="\${block.page}"]\`,
+ );
+ if (!viewportRef.current || !page) return;
+
+ const highlight = toHighlight(block.polygon);
+ const pageTop =
+ page.getBoundingClientRect().top -
+ viewportRef.current.getBoundingClientRect().top +
+ viewportRef.current.scrollTop;
+
+ viewportRef.current.scrollTo({
+ top: Math.max(0, pageTop + (highlight.top / 100) * RENDERED_PAGE_HEIGHT - 96),
+ behavior: "smooth",
+ });
+ });
+ }
+
+ return (
+ <div className="grid h-[620px] overflow-hidden bg-background lg:grid-cols-[minmax(0,1fr)_20rem]">
+ <div ref={viewportRef} className="min-h-0 overflow-auto bg-muted/30 p-6">
+ {reactPdf ? (
+ <reactPdf.Document file={PDF_URL}>
+ {[1, 2, 3].map((pageNumber) => (
+ <div
+ key={pageNumber}
+ data-ocr-page={pageNumber}
+ className="relative mx-auto mb-6"
+ style={{ width: RENDERED_PAGE_WIDTH, height: RENDERED_PAGE_HEIGHT }}
+ >
+ <reactPdf.Page
+ pageNumber={pageNumber}
+ width={RENDERED_PAGE_WIDTH}
+ renderAnnotationLayer={false}
+ renderTextLayer={false}
+ loading={<HugeiconsIcon icon={Loading03Icon} className="size-4 animate-spin" />}
+ />
+ {OCR_BLOCKS.filter((block) => block.page === pageNumber).map((block) => {
+ const area = toHighlight(block.polygon);
+ const style = BLOCK_STYLES[block.type];
+
+ return (
+ <div
+ key={block.id}
+ className={cn(
+ "pointer-events-none absolute z-10 rounded-[3px] border",
+ block.id === activeBlock.id ? style.active : cn("opacity-55", style.muted),
+ )}
+ style={{
+ left: area.left + "%",
+ top: area.top + "%",
+ width: area.width + "%",
+ height: area.height + "%",
+ }}
+ />
+ );
+ })}
+ </div>
+ ))}
+ </reactPdf.Document>
+ ) : (
+ <HugeiconsIcon icon={Loading03Icon} className="size-4 animate-spin" />
+ )}
+ </div>
+ <aside className="min-h-0 overflow-y-auto p-3">
+ {OCR_BLOCKS.map((block) => {
+ const style = BLOCK_STYLES[block.type];
+
+ return (
+ <button
+ key={block.id}
+ type="button"
+ onClick={() => focusBlock(block)}
+ onMouseEnter={() => focusBlock(block)}
+ onFocus={() => focusBlock(block)}
+ className="mb-2 w-full rounded-lg border bg-background p-3 text-left text-sm"
+ >
+ <HugeiconsIcon icon={style.icon} className="size-4" />
+ <div className="mt-2 font-medium">{block.label}</div>
+ <div className="mt-1">{block.text}</div>
+ </button>
+ );
+ })}
+ </aside>
+ </div>
+ );
+}`
+
+export function OcrBlocksSource() {
+ return <HighlightedCodeBlock code={ocrBlocksUsageCode} />
+}
diff --git a/apps/v4/components/pdf-viewer-docs.tsx b/apps/v4/components/pdf-viewer-docs.tsx
index 08ff06a..4e0210c 100644
--- a/apps/v4/components/pdf-viewer-docs.tsx
+++ b/apps/v4/components/pdf-viewer-docs.tsx
@@ -13,13 +13,14 @@ import {
} from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"
+import { Button } from "@/components/ui/button"
import { HighlightedCodeBlock } from "@/components/highlighted-code-block"
-import { Button } from "@/registry/new-york-v4/ui/button"
import {
Select,
SelectTrigger,
SelectValue,
} from "@/registry/new-york-v4/ui/select"
+import { Separator } from "@/registry/new-york-v4/ui/separator"
import {
Tooltip,
TooltipContent,
@@ -94,6 +95,10 @@ function PdfViewerLoadingShell() {
<HugeiconsIcon icon={RotateClockwiseIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<ToolbarTooltip label="Zoom out">
<Button
variant="ghost"
@@ -121,6 +126,10 @@ function PdfViewerLoadingShell() {
<HugeiconsIcon icon={PlusSignCircleIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<ToolbarTooltip label="Search text">
<Button
variant="ghost"
@@ -178,6 +187,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
+import { Separator } from "@/components/ui/separator";
import {
Tooltip,
TooltipContent,
@@ -441,7 +451,7 @@ const PdfPage = memo(function PdfPage({
<>
<Page
pageNumber={pageNumber}
- className="overflow-hidden rounded-sm border bg-background shadow-xs"
+ className="overflow-hidden border bg-background shadow-xs"
renderAnnotationLayer={false}
renderTextLayer={hasSearchQuery}
devicePixelRatio={devicePixelRatio}
@@ -488,7 +498,7 @@ const PdfPage = memo(function PdfPage({
) : null}
</>
) : (
- <div className="size-full rounded-sm border bg-muted/30 shadow-xs" />
+ <div className="size-full border bg-muted/30 shadow-xs" />
)}
</div>
);
@@ -777,6 +787,10 @@ function Component({ url = DEFAULT_PDF_URL }: { url?: string }) {
<HugeiconsIcon icon={RotateClockwiseIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<ToolbarTooltip label="Zoom out">
<Button
variant="ghost"
@@ -820,6 +834,10 @@ function Component({ url = DEFAULT_PDF_URL }: { url?: string }) {
<HugeiconsIcon icon={PlusSignCircleIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<Popover>
<ToolbarTooltip label="Search text">
<PopoverTrigger asChild>
@@ -902,7 +920,7 @@ function Component({ url = DEFAULT_PDF_URL }: { url?: string }) {
onClick={() => scrollToPage(pageNumber)}
>
<div
- className="shrink-0 overflow-hidden rounded-sm border bg-background shadow-xs"
+ className="shrink-0 overflow-hidden border bg-background shadow-xs"
style={thumbnailSize}
>
<Thumbnail
diff --git a/apps/v4/components/pdf-viewer-preview-client.tsx b/apps/v4/components/pdf-viewer-preview-client.tsx
index 88885ff..5289a5d 100644
--- a/apps/v4/components/pdf-viewer-preview-client.tsx
+++ b/apps/v4/components/pdf-viewer-preview-client.tsx
@@ -14,7 +14,7 @@ import { HugeiconsIcon } from "@hugeicons/react"
import { Document, Page, pdfjs, Thumbnail } from "react-pdf"
import { cn } from "@/lib/utils"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
import { Input } from "@/registry/new-york-v4/ui/input"
import {
Popover,
@@ -28,6 +28,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/registry/new-york-v4/ui/select"
+import { Separator } from "@/registry/new-york-v4/ui/separator"
import {
Tooltip,
TooltipContent,
@@ -263,7 +264,7 @@ const PdfPage = React.memo(function PdfPage({
<>
<Page
pageNumber={pageNumber}
- className="overflow-hidden rounded-sm border bg-background shadow-xs"
+ className="overflow-hidden border bg-background shadow-xs"
renderAnnotationLayer={false}
renderTextLayer={hasSearchQuery}
devicePixelRatio={devicePixelRatio}
@@ -310,7 +311,7 @@ const PdfPage = React.memo(function PdfPage({
) : null}
</>
) : (
- <div className="size-full rounded-sm border bg-muted/30 shadow-xs" />
+ <div className="size-full border bg-muted/30 shadow-xs" />
)}
</div>
)
@@ -605,6 +606,10 @@ export function PdfViewerPreviewClient() {
<HugeiconsIcon icon={RotateClockwiseIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<ToolbarTooltip label="Zoom out">
<Button
variant="ghost"
@@ -648,6 +653,10 @@ export function PdfViewerPreviewClient() {
<HugeiconsIcon icon={PlusSignCircleIcon} className="size-4" />
</Button>
</ToolbarTooltip>
+ <Separator
+ orientation="vertical"
+ className="mx-1 h-4 self-center"
+ />
<Popover>
<ToolbarTooltip label="Search text">
<PopoverTrigger asChild>
@@ -732,7 +741,7 @@ export function PdfViewerPreviewClient() {
onClick={() => scrollToPage(pageNumber)}
>
<div
- className="shrink-0 overflow-hidden rounded-sm border bg-background shadow-xs"
+ className="shrink-0 overflow-hidden border bg-background shadow-xs"
style={thumbnailSize}
>
<Thumbnail
diff --git a/apps/v4/components/site-config.tsx b/apps/v4/components/site-config.tsx
index af0d717..ddcb710 100644
--- a/apps/v4/components/site-config.tsx
+++ b/apps/v4/components/site-config.tsx
@@ -7,7 +7,7 @@ import { HugeiconsIcon } from "@hugeicons/react"
import { trackEvent } from "@/lib/events"
import { cn } from "@/lib/utils"
import { useLayout } from "@/hooks/use-layout"
-import { Button } from "@/registry/new-york-v4/ui/button"
+import { Button } from "@/components/ui/button"
export function SiteConfig({ className }: React.ComponentProps<typeof Button>) {
const { layout, setLayout } = useLayout()
diff --git a/apps/v4/components/site-header.tsx b/apps/v4/components/site-header.tsx
index e28a720..e9cbdef 100644
--- a/apps/v4/components/site-header.tsx
+++ b/apps/v4/components/site-header.tsx
@@ -3,6 +3,7 @@ import Link from "next/link"
import { getColors } from "@/lib/colors"
import { siteConfig } from "@/lib/config"
import { source } from "@/lib/source"
+import { Button } from "@/components/ui/button"
import { CommandMenu } from "@/components/command-menu"
import { GitHubLink } from "@/components/github-link"
import { Icons } from "@/components/icons"
@@ -10,7 +11,6 @@ import { MainNav } from "@/components/main-nav"
import { MobileNav } from "@/components/mobile-nav"
import { ModeSwitcher } from "@/components/mode-switcher"
import { SiteConfig } from "@/components/site-config"
-import { Button } from "@/registry/new-york-v4/ui/button"
import { Separator } from "@/registry/new-york-v4/ui/separator"
export function SiteHeader() {
@@ -46,15 +46,15 @@ export function SiteHeader() {
</div>
<Separator
orientation="vertical"
- className="ml-2 hidden lg:block"
+ className="ml-2 hidden h-4 self-center lg:block"
/>
<GitHubLink />
<Separator
orientation="vertical"
- className="hidden group-has-data-[slot=designer]/layout:hidden 3xl:flex"
+ className="hidden h-4 self-center group-has-data-[slot=designer]/layout:hidden 3xl:flex"
/>
<SiteConfig className="hidden 3xl:flex 3xl:group-has-data-[slot=designer]/layout:hidden" />
- <Separator orientation="vertical" />
+ <Separator orientation="vertical" className="h-4 self-center" />
<ModeSwitcher />
</div>
</div>
diff --git a/apps/v4/components/ui/button.tsx b/apps/v4/components/ui/button.tsx
new file mode 100644
index 0000000..ca96361
--- /dev/null
+++ b/apps/v4/components/ui/button.tsx
@@ -0,0 +1,7 @@
+"use client"
+
+export {
+ Button,
+ buttonVariants,
+ type ButtonProps,
+} from "@/registry/new-york-v4/ui/button"
diff --git a/apps/v4/content/docs/(root)/index.mdx b/apps/v4/content/docs/(root)/index.mdx
index d59cedc..6d0c088 100644
--- a/apps/v4/content/docs/(root)/index.mdx
+++ b/apps/v4/content/docs/(root)/index.mdx
@@ -11,8 +11,8 @@ Extend is built around the work of turning raw PDFs, spreadsheets, scans, and te
- Viewers for the file types document-heavy products need every day.
- Navigation primitives for pages, sheets, sections, images, and extracted text.
-- Review surfaces for annotations, redlines, comparisons, and human-in-the-loop checks.
-- Utility panels for OCR text, metadata, extraction status, and validation context.
+- Review surfaces for annotations, citations, e-signature, and human-in-the-loop checks.
+- Utility panels for OCR blocks, extraction status, and validation context.
## Component set
diff --git a/apps/v4/content/docs/components/csv-tsv-viewer.mdx b/apps/v4/content/docs/components/csv-tsv-viewer.mdx
index a582f97..c8084aa 100644
--- a/apps/v4/content/docs/components/csv-tsv-viewer.mdx
+++ b/apps/v4/content/docs/components/csv-tsv-viewer.mdx
@@ -31,7 +31,7 @@ npx shadcn@latest add csv-viewer
<Step>Install the following dependencies:</Step>
```bash
-npm install @glideapps/[email protected] papaparse marked lodash react-responsive-carousel
+npm install @glideapps/[email protected] papaparse lodash
```
<Step>Copy and paste the following code into your project.</Step>
@@ -61,8 +61,8 @@ import "@glideapps/glide-data-grid/dist/index.css"
## Common slots
-| Slot | Purpose |
-| -------------- | ------------------------------------------------------ |
-| `toolbar` | File summary, zoom controls, and CSV upload actions. |
-| `grid` | Virtualized Glide Data Grid table surface. |
+| Slot | Purpose |
+| ------------- | ------------------------------------------------------ |
+| `toolbar` | File summary, zoom controls, and CSV upload actions. |
+| `grid` | Virtualized Glide Data Grid table surface. |
| `parseErrors` | Malformed rows, encoding issues, and delimiter errors. |
diff --git a/apps/v4/content/docs/components/document-annotation-layer.mdx b/apps/v4/content/docs/components/document-annotation-layer.mdx
deleted file mode 100644
index db19d04..0000000
--- a/apps/v4/content/docs/components/document-annotation-layer.mdx
+++ /dev/null
@@ -1,23 +0,0 @@
----
-title: Annotations
-description: Add highlights, rectangles, pins, freeform notes, and anchored comments over documents and images.
-component: true
-featured: true
----
-
-Annotations provide review markup without coupling the app to one file renderer.
-
-## Useful behaviors
-
-- Anchors by page, bounding box, text range, cell range, or image region.
-- Highlight, rectangle, pin, note, and comment modes.
-- Selection handles, keyboard escape, and collision-aware popovers.
-- Read-only and editable modes for review workflows.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `annotation` | Rendered mark, pin, or region. |
-| `editor` | Comment input, label, color, and status controls. |
-| `selection` | Active region and resize handles. |
diff --git a/apps/v4/content/docs/components/document-comparison-viewer.mdx b/apps/v4/content/docs/components/document-comparison-viewer.mdx
deleted file mode 100644
index a3e40dc..0000000
--- a/apps/v4/content/docs/components/document-comparison-viewer.mdx
+++ /dev/null
@@ -1,23 +0,0 @@
----
-title: Compare Viewer
-description: Compare PDFs, DOCX files, images, spreadsheets, and text exports side-by-side or in overlay mode.
-component: true
-featured: true
----
-
-The Compare Viewer helps users understand what changed between two versions or two related files.
-
-## Useful behaviors
-
-- Side-by-side synchronized scrolling.
-- Overlay mode for scanned pages and images.
-- Difference summary by page, sheet, section, or row.
-- Jump navigation for additions, removals, and modified regions.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `leftViewer` | Original or baseline document. |
-| `rightViewer` | Changed or candidate document. |
-| `diffRail` | Change markers and jump navigation. |
diff --git a/apps/v4/content/docs/components/document-metadata-panel.mdx b/apps/v4/content/docs/components/document-metadata-panel.mdx
deleted file mode 100644
index 4e8cd08..0000000
--- a/apps/v4/content/docs/components/document-metadata-panel.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: Metadata Panel
-description: Show file size, author, dates, page count, word count, sheet count, permissions, and extracted metadata.
-component: true
----
-
-The Metadata Panel gives users the context they need before downloading, approving, or routing a file.
-
-## Useful behaviors
-
-- Normalize metadata across file types.
-- Show source, owner, permissions, timestamps, and extraction status.
-- Support custom fields from your app domain.
-- Distinguish trusted metadata from extracted or inferred metadata.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `summary` | Important file facts and status. |
-| `fieldGroup` | Related metadata fields. |
-| `actions` | Copy, download, open source, or refresh extraction. |
diff --git a/apps/v4/content/docs/components/document-outline-toc.mdx b/apps/v4/content/docs/components/document-outline-toc.mdx
deleted file mode 100644
index 072a810..0000000
--- a/apps/v4/content/docs/components/document-outline-toc.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: Outline
-description: Navigate headings, bookmarks, sheets, sections, attachments, and page anchors across document types.
-component: true
----
-
-The Outline gives every viewer a consistent navigation model even when each file type exposes different structure.
-
-## Useful behaviors
-
-- Heading, bookmark, sheet, and page-anchor navigation.
-- Active section tracking as the viewer scrolls.
-- Collapsible nested sections.
-- Empty and partial-outline states for files with limited structure.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `treeItem` | Heading, bookmark, sheet, or page link. |
-| `toolbar` | Expand all, collapse all, and filter controls. |
-| `emptyState` | No outline available for this document. |
diff --git a/apps/v4/content/docs/components/document-search.mdx b/apps/v4/content/docs/components/document-search.mdx
deleted file mode 100644
index a7181d1..0000000
--- a/apps/v4/content/docs/components/document-search.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: Search
-description: Search extracted text, pages, sheets, comments, OCR layers, and metadata with highlighted matches.
-component: true
----
-
-Search should feel consistent across file types while still respecting each viewer's structure.
-
-## Useful behaviors
-
-- Debounced search with match count and next/previous navigation.
-- Highlighted matches in pages, sheets, text files, and OCR overlays.
-- Search result grouping by page, sheet, comment, or field.
-- Empty, loading, and indexing states.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `input` | Query input and keyboard navigation. |
-| `results` | Grouped result list with snippets. |
-| `highlight` | Inline match rendering inside the active viewer. |
diff --git a/apps/v4/content/docs/components/document-thumbnail-strip.mdx b/apps/v4/content/docs/components/document-thumbnail-strip.mdx
deleted file mode 100644
index 879fcb1..0000000
--- a/apps/v4/content/docs/components/document-thumbnail-strip.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: Thumbnail Tab Switcher
-description: Switch between pages, sheets, and rendered document sections with compact thumbnail tabs.
-component: true
----
-
-The Thumbnail Tab Switcher gives users fast spatial navigation through long or multi-page files.
-
-## Useful behaviors
-
-- Virtualized thumbnail tabs for long documents.
-- Current tab, loaded tab, selected tab, and error states.
-- Drag-to-reorder mode for workflows that edit page order.
-- Works horizontally or vertically.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `thumbnailTab` | Page preview, index, and state markers. |
-| `groupHeader` | Sections, sheets, chapters, or attachment groups. |
-| `dropIndicator` | Reorder and insertion feedback. |
diff --git a/apps/v4/content/docs/components/file-thumbnail.mdx b/apps/v4/content/docs/components/file-thumbnail.mdx
new file mode 100644
index 0000000..9a753bb
--- /dev/null
+++ b/apps/v4/content/docs/components/file-thumbnail.mdx
@@ -0,0 +1,62 @@
+---
+title: File Thumbnail
+description: Render a compact first-page preview for PDFs and direct image previews for image files.
+component: true
+---
+
+File Thumbnail gives document lists, upload queues, and attachment trays a fast visual preview without mounting a full viewer.
+
+<FileThumbnailDemo />
+
+## Installation
+
+<CodeTabs>
+
+<TabsList>
+ <TabsTrigger value="cli">Command</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add file-thumbnail
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps className="mb-0 pt-2">
+
+<Step>Install the following dependencies:</Step>
+
+```bash
+npm install react-pdf
+```
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<FileThumbnailSource />
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</CodeTabs>
+
+## Useful behaviors
+
+- Uses `react-pdf` `Thumbnail` for the first page instead of mounting a full PDF page viewer.
+- Lazily mounts PDF rendering when the thumbnail approaches the viewport.
+- Uses a native `img` tag for image files with browser-level lazy loading and async decoding.
+- Shows a shimmering file-preview state while PDF thumbnails render.
+- Falls back to a compact file icon when the preview cannot render.
+
+## Common slots
+
+| Slot | Purpose |
+| ---------- | ---------------------------------------------------------- |
+| `preview` | First-page PDF thumbnail, image preview, or fallback icon. |
+| `metadata` | File name, type, size, page count, or processing status. |
diff --git a/apps/v4/content/docs/components/file-upload.mdx b/apps/v4/content/docs/components/file-upload.mdx
index 33ca68c..047dfc3 100644
--- a/apps/v4/content/docs/components/file-upload.mdx
+++ b/apps/v4/content/docs/components/file-upload.mdx
@@ -7,6 +7,46 @@ featured: true
File Upload is the starting point for document processing workflows. It should help users get files into the system quickly while making validation, progress, and failure states clear.
+<FileUploadDemo />
+
+## Installation
+
+<CodeTabs>
+
+<TabsList>
+ <TabsTrigger value="cli">Command</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add file-upload
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps className="mb-0 pt-2">
+
+<Step>Install the following dependencies:</Step>
+
+```bash
+npm install border-beam
+```
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<FileUploadSource />
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</CodeTabs>
+
## Useful behaviors
- Drag-and-drop and file picker entrypoints.
@@ -17,9 +57,9 @@ File Upload is the starting point for document processing workflows. It should h
## Common slots
-| Slot | Purpose |
-| --- | --- |
-| `dropzone` | Primary drag-and-drop and browse surface. |
-| `fileItem` | Individual file row with name, type, size, progress, and status. |
-| `validationMessage` | File-level or batch-level errors and warnings. |
-| `actions` | Retry, cancel, remove, or continue controls. |
+| Slot | Purpose |
+| ------------------- | ---------------------------------------------------------------- |
+| `dropzone` | Primary drag-and-drop and browse surface. |
+| `fileItem` | Individual file row with name, type, size, progress, and status. |
+| `validationMessage` | File-level or batch-level errors and warnings. |
+| `actions` | Retry, cancel, remove, or continue controls. |
diff --git a/apps/v4/content/docs/components/meta.json b/apps/v4/content/docs/components/meta.json
index e62c79a..2191d52 100644
--- a/apps/v4/content/docs/components/meta.json
+++ b/apps/v4/content/docs/components/meta.json
@@ -6,14 +6,7 @@
"docx-viewer",
"xlsx-viewer",
"csv-tsv-viewer",
- "file-upload",
- "document-thumbnail-strip",
- "document-outline-toc",
- "document-search",
- "document-annotation-layer",
- "redline-review-panel",
- "document-comparison-viewer",
- "ocr-text-layer-viewer",
- "document-metadata-panel"
+ "file-thumbnail",
+ "file-upload"
]
}
diff --git a/apps/v4/content/docs/components/ocr-text-layer-viewer.mdx b/apps/v4/content/docs/components/ocr-text-layer-viewer.mdx
deleted file mode 100644
index a423c33..0000000
--- a/apps/v4/content/docs/components/ocr-text-layer-viewer.mdx
+++ /dev/null
@@ -1,23 +0,0 @@
----
-title: OCR Layer
-description: Display selectable and searchable OCR text over scanned pages, receipts, forms, and image documents.
-component: true
-featured: true
----
-
-The OCR Layer turns scanned documents into searchable review surfaces while preserving the image underneath.
-
-## Useful behaviors
-
-- Position OCR words, lines, and blocks over image coordinates.
-- Toggle text visibility, confidence colors, and region boundaries.
-- Search and select text from scanned documents.
-- Highlight low-confidence words for correction workflows.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `word` | Selectable OCR token with confidence metadata. |
-| `region` | Paragraph, field, table, or detected block boundary. |
-| `correctionPanel` | Optional OCR review and correction UI. |
diff --git a/apps/v4/content/docs/components/pdf-viewer.mdx b/apps/v4/content/docs/components/pdf-viewer.mdx
index c053194..28e520d 100644
--- a/apps/v4/content/docs/components/pdf-viewer.mdx
+++ b/apps/v4/content/docs/components/pdf-viewer.mdx
@@ -57,13 +57,13 @@ import "react-pdf/dist/Page/TextLayer.css"
- Zoom, fit width, fit page, rotate, and print/download actions.
- Virtualized page rendering for long PDFs.
-- Optional thumbnail tab switcher, outline panel, search highlights, and annotation layer.
+- Optional citation anchors, OCR block overlays, e-signature fields, search highlights, and annotation layer.
- Text layer support for selection, copy, search, and accessibility.
## Common slots
-| Slot | Purpose |
-| --------- | ----------------------------------------------------- |
-| `toolbar` | Page navigation, zoom, rotate, and download controls. |
-| `sidebar` | Thumbnail tabs, outline, search results, or metadata. |
-| `overlay` | Annotations, pins, comments, and OCR alignment. |
+| Slot | Purpose |
+| --------- | -------------------------------------------------------- |
+| `toolbar` | Page navigation, zoom, rotate, and download controls. |
+| `sidebar` | Citations, OCR results, signing status, or search. |
+| `overlay` | Citations, OCR blocks, signing fields, and search marks. |
diff --git a/apps/v4/content/docs/components/pdf-viewer/citations.mdx b/apps/v4/content/docs/components/pdf-viewer/citations.mdx
new file mode 100644
index 0000000..78d7f46
--- /dev/null
+++ b/apps/v4/content/docs/components/pdf-viewer/citations.mdx
@@ -0,0 +1,61 @@
+---
+title: Citations
+description: Link extracted answers, review notes, and model outputs back to exact PDF pages and regions.
+component: true
+---
+
+Citations connect document answers to their source evidence. They should make it easy to jump from an extracted value, comment, or answer back to the PDF page that supports it.
+
+<CitationsDemo />
+
+## Installation
+
+<CodeTabs>
+
+<TabsList>
+ <TabsTrigger value="cli">Command</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add citations
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps className="mb-0 pt-2">
+
+<Step>Install the following dependencies:</Step>
+
+```bash
+npm install react-pdf pdfjs-dist
+```
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<CitationsSource />
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</CodeTabs>
+
+## Useful behaviors
+
+- Page and bounding-box anchors for source evidence.
+- Highlighted citation regions that can be focused from outside the viewer.
+- Citation lists grouped by answer, field, or reviewer note.
+- Empty and unresolved states when the cited page or region is unavailable.
+
+## Common slots
+
+| Slot | Purpose |
+| ---------- | --------------------------------------------- |
+| `citation` | Source page, label, confidence, and snippet. |
+| `anchor` | Page region or text range highlighted in PDF. |
diff --git a/apps/v4/content/docs/components/pdf-viewer/e-signature.mdx b/apps/v4/content/docs/components/pdf-viewer/e-signature.mdx
new file mode 100644
index 0000000..e2665f9
--- /dev/null
+++ b/apps/v4/content/docs/components/pdf-viewer/e-signature.mdx
@@ -0,0 +1,62 @@
+---
+title: E-Signature
+description: Place, review, and complete signature fields on PDF documents.
+component: true
+---
+
+E-Signature extends a PDF viewer with signature, initials, date, and approval fields. It should keep field placement precise while making signing status clear.
+
+<ESignatureDemo />
+
+## Installation
+
+<CodeTabs>
+
+<TabsList>
+ <TabsTrigger value="cli">Command</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add e-signature
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps className="mb-0 pt-2">
+
+<Step>Install the following dependencies:</Step>
+
+```bash
+npm install react-pdf pdfjs-dist signature_pad pdf-lib
+```
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<ESignatureSource />
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</CodeTabs>
+
+## Useful behaviors
+
+- Signature, initials, date, checkbox, and text field placement.
+- Recipient-specific field ownership and completion state.
+- Required-field validation before submit.
+- Audit-friendly signed, pending, and declined states.
+
+## Common slots
+
+| Slot | Purpose |
+| ---------- | -------------------------------------------- |
+| `field` | Signature or form field positioned on a PDF. |
+| `status` | Recipient and completion state. |
+| `controls` | Review, clear, decline, or submit actions. |
diff --git a/apps/v4/content/docs/components/pdf-viewer/meta.json b/apps/v4/content/docs/components/pdf-viewer/meta.json
new file mode 100644
index 0000000..0140b3e
--- /dev/null
+++ b/apps/v4/content/docs/components/pdf-viewer/meta.json
@@ -0,0 +1,4 @@
+{
+ "title": "PDF Viewer",
+ "pages": ["citations", "ocr-blocks", "e-signature"]
+}
diff --git a/apps/v4/content/docs/components/pdf-viewer/ocr-blocks.mdx b/apps/v4/content/docs/components/pdf-viewer/ocr-blocks.mdx
new file mode 100644
index 0000000..4ec60bc
--- /dev/null
+++ b/apps/v4/content/docs/components/pdf-viewer/ocr-blocks.mdx
@@ -0,0 +1,61 @@
+---
+title: OCR Blocks
+description: Inspect OCR text blocks, lines, words, and confidence overlays on top of PDF pages.
+component: true
+---
+
+OCR Blocks help users debug and review the text layer behind scanned or image-heavy PDFs. They should show document structure without replacing the original page image.
+
+<OcrBlocksDemo />
+
+## Installation
+
+<CodeTabs>
+
+<TabsList>
+ <TabsTrigger value="cli">Command</TabsTrigger>
+ <TabsTrigger value="manual">Manual</TabsTrigger>
+</TabsList>
+<TabsContent value="cli">
+
+```bash
+npx shadcn@latest add ocr-blocks
+```
+
+</TabsContent>
+
+<TabsContent value="manual">
+
+<Steps className="mb-0 pt-2">
+
+<Step>Install the following dependencies:</Step>
+
+```bash
+npm install react-pdf pdfjs-dist
+```
+
+<Step>Copy and paste the following code into your project.</Step>
+
+<OcrBlocksSource />
+
+<Step>Update the import paths to match your project setup.</Step>
+
+</Steps>
+
+</TabsContent>
+
+</CodeTabs>
+
+## Useful behaviors
+
+- Toggleable block, line, and word overlays.
+- Confidence coloring for low-quality OCR regions.
+- Hover and selection states that reveal text and geometry.
+- Region navigation from OCR results to the rendered PDF page.
+
+## Common slots
+
+| Slot | Purpose |
+| --------- | -------------------------------------------- |
+| `overlay` | OCR boxes positioned over the rendered page. |
+| `details` | Selected text, confidence, and coordinates. |
diff --git a/apps/v4/content/docs/components/redline-review-panel.mdx b/apps/v4/content/docs/components/redline-review-panel.mdx
deleted file mode 100644
index eebd00d..0000000
--- a/apps/v4/content/docs/components/redline-review-panel.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: Redlines
-description: Review insertions, deletions, formatting changes, comments, and accept or reject workflows.
-component: true
----
-
-Redlines are for document approval flows where users need to inspect changes in context.
-
-## Useful behaviors
-
-- Group changes by author, section, page, date, or status.
-- Accept, reject, resolve, and jump-to-change actions.
-- Inline summaries for inserts, deletes, moves, and formatting changes.
-- Read-only audit mode for finalized documents.
-
-## Common slots
-
-| Slot | Purpose |
-| --- | --- |
-| `changeItem` | A single proposed edit or comment thread. |
-| `actions` | Accept, reject, resolve, and jump controls. |
-| `filters` | Author, change type, and status filters. |
diff --git a/apps/v4/lib/page-tree.ts b/apps/v4/lib/page-tree.ts
index e0ba04e..d7afb5b 100644
--- a/apps/v4/lib/page-tree.ts
+++ b/apps/v4/lib/page-tree.ts
@@ -43,15 +43,43 @@ export function getPagesFromFolder(
}
}
- // Fallback: return all pages from nested folders.
- return getAllPagesFromFolder(folder).filter(
- (page) => !page.url.endsWith("/components")
+ // Fallback: return direct component pages. Nested folders are rendered as
+ // contextual subpages in the sidebar instead of top-level component links.
+ return folder.children.filter(
+ (child): child is PageTreePage =>
+ child.type === "page" && !child.url.endsWith("/components")
)
}
// For other folders, return direct page children.
return folder.children.filter(
- (child): child is PageTreePage => child.type === "page"
+ (child): child is PageTreePage =>
+ child.type === "page" && !child.url.endsWith("/components")
+ )
+}
+
+export function getNestedPagesFromFolder(
+ folder: PageTreeFolder,
+ folderId: string
+): PageTreePage[] {
+ const nestedFolder = folder.children.find(
+ (child): child is PageTreeFolder =>
+ child.type === "folder" &&
+ (child.$id === folderId ||
+ child.$id?.endsWith(`/${folderId}`) ||
+ (typeof child.name === "string" &&
+ child.name.toLowerCase().replaceAll(" ", "-") === folderId) ||
+ getAllPagesFromFolder(child).some((page) =>
+ page.url.includes(`/components/${folderId}/`)
+ ))
+ )
+
+ if (!nestedFolder) {
+ return []
+ }
+
+ return getAllPagesFromFolder(nestedFolder).filter(
+ (page) => !page.url.endsWith("/components")
)
}
diff --git a/apps/v4/mdx-components.tsx b/apps/v4/mdx-components.tsx
index c734955..e375479 100644
--- a/apps/v4/mdx-components.tsx
+++ b/apps/v4/mdx-components.tsx
@@ -6,13 +6,21 @@ import { type PageTreeFolder } from "@/lib/page-tree"
import { source } from "@/lib/source"
import { cn } from "@/lib/utils"
import { Callout } from "@/components/callout"
+import { CitationsDemo, CitationsSource } from "@/components/citations-docs"
import { CodeBlockCommand } from "@/components/code-block-command"
import { CodeCollapsibleWrapper } from "@/components/code-collapsible-wrapper"
import { CodeTabs } from "@/components/code-tabs"
import { ComponentsList } from "@/components/components-list"
import { CopyButton } from "@/components/copy-button"
import { CsvViewerDemo, CsvViewerSource } from "@/components/csv-viewer-docs"
+import { ESignatureDemo, ESignatureSource } from "@/components/e-signature-docs"
+import {
+ FileThumbnailDemo,
+ FileThumbnailSource,
+} from "@/components/file-thumbnail-docs"
+import { FileUploadDemo, FileUploadSource } from "@/components/file-upload-docs"
import { getIconForLanguageExtension } from "@/components/icons"
+import { OcrBlocksDemo, OcrBlocksSource } from "@/components/ocr-blocks-docs"
import { PdfViewerDemo, PdfViewerSource } from "@/components/pdf-viewer-docs"
import {
Accordion,
@@ -353,8 +361,18 @@ export const mdxComponents = {
CodeTabs,
CodeCollapsibleWrapper,
ComponentsList: ComponentsListWrapper,
+ CitationsDemo,
+ CitationsSource,
CsvViewerDemo,
CsvViewerSource,
+ ESignatureDemo,
+ ESignatureSource,
+ FileThumbnailDemo,
+ FileThumbnailSource,
+ FileUploadDemo,
+ FileUploadSource,
+ OcrBlocksDemo,
+ OcrBlocksSource,
PdfViewerDemo,
PdfViewerSource,
Link: ({ className, ...props }: React.ComponentProps<typeof Link>) => (
diff --git a/apps/v4/package.json b/apps/v4/package.json
index 6d1655d..f9e609f 100644
--- a/apps/v4/package.json
+++ b/apps/v4/package.json
@@ -21,6 +21,7 @@
"@hugeicons/core-free-icons": "^4.1.1",
"@hugeicons/react": "^1.1.6",
"@tabler/icons-react": "^3.31.0",
+ "border-beam": "^1.0.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
@@ -34,12 +35,15 @@
"next-themes": "0.4.6",
"nuqs": "^2.8.9",
"papaparse": "^5.5.3",
+ "pdf-lib": "^1.17.1",
+ "pdfjs-dist": "5.4.296",
"react": "19.2.3",
"react-dom": "19.2.3",
"react-pdf": "^10.4.1",
"react-responsive-carousel": "^3.2.23",
"rehype-pretty-code": "^0.14.1",
"shiki": "^1.10.1",
+ "signature_pad": "^5.1.3",
"sonner": "^2.0.0",
"tailwind-merge": "^3.3.1",
"zod": "^3.25.76"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 90d7277..fb1d893 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -33,6 +33,9 @@ importers:
'@tabler/icons-react':
specifier: ^3.31.0
version: 3.34.1([email protected])
+ border-beam:
+ specifier: ^1.0.1
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
@@ -72,6 +75,12 @@ importers:
papaparse:
specifier: ^5.5.3
version: 5.5.3
+ pdf-lib:
+ specifier: ^1.17.1
+ version: 1.17.1
+ pdfjs-dist:
+ specifier: 5.4.296
+ version: 5.4.296
react:
specifier: 19.2.3
version: 19.2.3
@@ -90,6 +99,9 @@ importers:
shiki:
specifier: ^1.10.1
version: 1.29.2
+ signature_pad:
+ specifier: ^5.1.3
+ version: 5.1.3
sonner:
specifier: ^2.0.0
@@ -1043,6 +1055,12 @@ packages:
resolution: {integrity: sha512-scSmQBD8eANlMUOglxHrN1JdSW8tDghsPuS83otqealBiIeMukCQMOf/wc0JJjDXomqwNdEQFLXLGHrU6PGxuA==}
engines: {node: '>= 20.0.0'}
+ '@pdf-lib/[email protected]':
+ resolution: {integrity: sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==}
+
+ '@pdf-lib/[email protected]':
+ resolution: {integrity: sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==}
+
'@radix-ui/[email protected]':
resolution: {integrity: sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==}
@@ -1846,6 +1864,12 @@ packages:
resolution: {integrity: sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-kswSYT8zRmt5en+wZMtJAbM8RjJglqSKwyRuQZWXnMHQsBwJisaznTfhD8SWvWJZKAtGbSkE2q/wY7seiNDmcw==}
+ peerDependencies:
+ react: '>=18.0.0'
+ react-dom: '>=18.0.0'
+
resolution: {integrity: sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==}
@@ -3284,6 +3308,9 @@ packages:
resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==}
engines: {node: '>=10'}
+ resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}
+
resolution: {integrity: sha512-5QvjGxYVjxO59MGU2lHVYpRWBBtKHnlIAcSe1uNFCkkptUh63NFRj0FJQm7nR67puEruUci/ZkjmEFrjCAyP4A==}
@@ -3318,6 +3345,9 @@ packages:
resolution: {integrity: sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==}
+ resolution: {integrity: sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==}
+
resolution: {integrity: sha512-DlOzet0HO7OEnmUmB6wWGJrrdvbyJKftI1bhMitK7O2N8W2gc757yyYBbINy9IDafXAV9wmKr9t7xsTaNKRG5Q==}
engines: {node: '>=20.16.0 || >=22.3.0'}
@@ -3716,6 +3746,9 @@ packages:
resolution: {integrity: sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}
engines: {node: '>= 0.4'}
+ resolution: {integrity: sha512-zyxW5vuJVnQdGcU+kAj9FYl7WaAunY3kA5S7mPg0xJiujL9+sPAWfSQHS5tXaJXDUa4FuZeKhfdCDQ6K3wfkpQ==}
+
resolution: {integrity: sha512-W6ZN4p58k8aDKA4XPcx2hpIQXBRAgyiWVkYhT7CvK6D3iAu7xjvVyhQHg2/iaKJZ1XVJ4r7XuwGL+WGEK37i9w==}
peerDependencies:
@@ -3856,6 +3889,9 @@ packages:
resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==}
+ resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
+
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
@@ -4875,6 +4911,14 @@ snapshots:
'@orama/[email protected]': {}
+ '@pdf-lib/[email protected]':
+ dependencies:
+ pako: 1.0.11
+
+ '@pdf-lib/[email protected]':
+ dependencies:
+ pako: 1.0.11
+
'@radix-ui/[email protected]': {}
@@ -5637,6 +5681,11 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ react: 19.2.3
+ react-dom: 19.2.3([email protected])
+
dependencies:
balanced-match: 1.0.2
@@ -7572,6 +7621,8 @@ snapshots:
dependencies:
p-limit: 3.1.0
+
@@ -7604,6 +7655,13 @@ snapshots:
+ dependencies:
+ '@pdf-lib/standard-fonts': 1.0.0
+ '@pdf-lib/upng': 1.0.1
+ pako: 1.0.11
+ tslib: 1.14.1
+
optionalDependencies:
'@napi-rs/canvas': 0.1.100
@@ -8125,6 +8183,8 @@ snapshots:
side-channel-map: 1.0.1
side-channel-weakmap: 1.0.2
+
dependencies:
react: 19.2.3
@@ -8267,6 +8327,8 @@ snapshots:
minimist: 1.2.8
strip-bom: 3.0.0
+