Skip to content

armgit / ui

Public Imported from GitHub
0
TypeScript
4.2 KB
Raw Blame
---
title: Bounding Box Citations
description: Review extracted values against source bounding box citations with form fields and JSON diffing.
component: true
---

Bounding Box Citations provides field-level cards for comparing extracted values with source PDF bounding boxes. Use it when reviewers need to inspect citations, correct values, and optionally compare against expected output.

See it composed with the PDF Viewer in the [Bounding Box Citations block](/blocks#bounding-box-citations).

<HumanReviewDemo />

## Installation

Glide Data Grid renders overlay editors into a root portal. Add this element as
the last child of your app's `<body>` before using the component:

```tsx
<div id="portal" className="fixed top-0 left-0 z-40" />
```

<Callout variant="info" title="Next.js SSR">
Glide Data Grid uses browser-only APIs. If you see SSR errors, render Bounding
Box Citations through `next/dynamic` with `ssr: false`.

<DocsMdxCodeBlock
  language="tsx"
  code={`"use client"

import dynamic from "next/dynamic"

const HumanReviewPanel = dynamic(
() =>
import("@/components/extend/bounding-box-citations").then((mod) => mod.HumanReviewPanel),
{ ssr: false }
)`}
/>

</Callout>

<CodeTabs>

<TabsList>
  <TabsTrigger value="cli">Command</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

```bash
npx shadcn@latest add @extend/bounding-box-citations
```

</TabsContent>

<TabsContent value="manual">

<Steps className="mb-0 pt-2">

<Step>Install the following dependencies:</Step>

```bash
npm install @glideapps/[email protected] @pierre/diffs@^1.1.22
```

<Step>Install the icon library configured in your `components.json`:</Step>

The component source references icons through the shadcn CLI's
`IconPlaceholder`, which supports every `iconLibrary` the CLI does: `lucide`,
`tabler`, `hugeicons`, `phosphor`, and `remixicon`. Installing with the CLI
replaces each placeholder with the matching icon from your configured library,
so make sure that library's package is installed. When copying the source
manually, replace each `IconPlaceholder` element with the icon named by the
prop for your library.

<Step>Copy and paste the following code into your project.</Step>

<HumanReviewSource />

<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</CodeTabs>

## Useful behaviors

- Actual and expected values displayed side by side for each schema field when `showExpected` is enabled.
- Array values rendered with Glide Data Grid, including drill-down for nested arrays and objects.
- Input controls selected from the JSON schema property type.
- Object schema properties rendered as nested cards in the scrollable form.
- Per-field undo and Set to NULL actions when `showExpected` is enabled.
- Form and JSON diff views for the same reviewed output state when `showExpected` is enabled.

## API Reference

### HumanReviewPanel

The HumanReviewPanel component renders editable review fields and a JSON diff for the same extraction output.

| Prop             | Type                           | Default       | Required |
| ---------------- | ------------------------------ | ------------- | -------- |
| `fields`         | `ReviewField[]`                | sample fields | No       |
| `activeFieldKey` | `string`                       | `-`           | No       |
| `className`      | `string`                       | `-`           | No       |
| `onFieldFocus`   | `(field: ReviewField) => void` | `-`           | No       |
| `showExpected`   | `boolean`                      | `true`        | No       |
| `theme`          | `"light" \| "dark"`            | `"light"`     | No       |

### ReviewField

| Prop       | Type                                    | Default | Required |
| ---------- | --------------------------------------- | ------- | -------- |
| `key`      | `string`                                | `-`     | Yes      |
| `schema`   | `ReviewFieldSchema`                     | `-`     | Yes      |
| `actual`   | `JsonValue`                             | `-`     | Yes      |
| `expected` | `JsonValue`                             | `-`     | Yes      |
| `location` | `{ page: number; area: HighlightArea }` | `-`     | No       |