Skip to content

armgit / ui

Public Imported from GitHub
0
TypeScript

Reorder README examples and add concrete props

Andrew Luo2542d874c314
diff --git a/README.md b/README.md
index 6a63d13..202e00e 100644
--- a/README.md
+++ b/README.md
@@ -59,34 +59,42 @@ new components are generated closer to your app structure.
## Examples
-### File System
+### Layout Blocks
-A Finder-style file browser for object-store manifests. It supports icon, list,
-column, and gallery views, and opens PDF, DOCX, XLSX, and image files in viewer
-dialogs.
+Inspect OCR and layout output with selectable blocks, confidence, markdown text,
+and PDF overlays that stay connected to the rendered page.
-![File System Finder component](apps/v4/public/readme/file-system-finder.png)
+![Layout Blocks component](apps/v4/public/readme/layout-blocks.png)
```bash
-npx shadcn@latest add @extend/file-system-block
+npx shadcn@latest add @extend/layout-blocks-block
```
```tsx
-import type { FileSystemItem } from "@/components/ui/file-system"
-import { FileSystemBlock } from "@/components/blocks/file-system-block"
+import type { ParsedOcrOutput } from "@/components/ui/layout-blocks"
+import { OcrBlocksBlock } from "@/components/blocks/layout-blocks-block"
-const items: FileSystemItem[] = [
- {
- kind: "file",
- path: "bank-statement.pdf",
- contentType: "application/pdf",
- url: "/documents/bank-statement.pdf",
- previewImageUrl: "/documents/bank-statement-preview.png",
- },
-]
+const output: ParsedOcrOutput = {
+ chunks: [
+ {
+ blocks: [
+ {
+ id: "title",
+ type: "heading",
+ content: "Statement of Work",
+ metadata: {
+ page: { number: 1, width: 612, height: 792 },
+ avgOcrConfidence: 0.99,
+ },
+ boundingBox: { left: 72, top: 96, right: 360, bottom: 124 },
+ },
+ ],
+ },
+ ],
+}
export default function Page() {
- return <FileSystemBlock items={items} className="h-[720px]" />
+ return <OcrBlocksBlock file="/documents/statement.pdf" output={output} />
}
```
@@ -102,29 +110,86 @@ npx shadcn@latest add @extend/bounding-box-citations-block
```
```tsx
+import type { ReviewField } from "@/components/ui/bounding-box-citations"
import { HumanReviewBlock } from "@/components/blocks/bounding-box-citations-block"
+const fields: ReviewField[] = [
+ {
+ key: "invoice_total",
+ schema: {
+ type: "number",
+ title: "Invoice total",
+ description: "Total amount due on the invoice.",
+ },
+ actual: 1280.5,
+ expected: 1280.5,
+ location: {
+ page: 1,
+ area: { left: 62, top: 82, width: 22, height: 4 },
+ },
+ },
+]
+
export default function Page() {
- return <HumanReviewBlock className="h-[720px]" />
+ return (
+ <HumanReviewBlock
+ file="/documents/invoice.pdf"
+ fields={fields}
+ className="h-[720px]"
+ />
+ )
}
```
-### Layout Blocks
+### File System
-Inspect OCR and layout output with selectable blocks, confidence, markdown text,
-and PDF overlays that stay connected to the rendered page.
+A Finder-style file browser for object-store manifests. It supports icon, list,
+column, and gallery views, and opens PDF, DOCX, XLSX, and image files in viewer
+dialogs.
-![Layout Blocks component](apps/v4/public/readme/layout-blocks.png)
+![File System Finder component](apps/v4/public/readme/file-system-finder.png)
```bash
-npx shadcn@latest add @extend/layout-blocks-block
+npx shadcn@latest add @extend/file-system-block
```
```tsx
-import { OcrBlocksBlock } from "@/components/blocks/layout-blocks-block"
+import type { FileSystemItem } from "@/components/ui/file-system"
+import { FileSystemBlock } from "@/components/blocks/file-system-block"
+
+const items: FileSystemItem[] = [
+ {
+ kind: "folder",
+ path: "reports/",
+ hasChildren: true,
+ },
+ {
+ kind: "file",
+ path: "bank-statement.pdf",
+ contentType: "application/pdf",
+ url: "/documents/bank-statement.pdf",
+ previewImageUrl: "/documents/bank-statement-preview.png",
+ },
+]
export default function Page() {
- return <OcrBlocksBlock />
+ return (
+ <FileSystemBlock
+ items={items}
+ title="Documents"
+ defaultView="icons"
+ className="h-[720px]"
+ getFileUrl={(file) =>
+ `/api/files/sign?path=${encodeURIComponent(file.path)}`
+ }
+ loadChildren={async ({ path }) => {
+ const response = await fetch(
+ `/api/files?prefix=${encodeURIComponent(path)}`
+ )
+ return response.json()
+ }}
+ />
+ )
}
```