@dowel-ui/react 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +9 -5
  2. package/dist/components/ai-extraction-review/ai-extraction-review.d.ts +52 -0
  3. package/dist/components/ai-extraction-review/ai-extraction-review.d.ts.map +1 -0
  4. package/dist/components/ai-extraction-review/ai-extraction-review.js +249 -0
  5. package/dist/components/ai-extraction-review/ai-extraction-review.js.map +1 -0
  6. package/dist/components/ai-extraction-review/extraction-model.d.ts +94 -0
  7. package/dist/components/ai-extraction-review/extraction-model.d.ts.map +1 -0
  8. package/dist/components/ai-extraction-review/extraction-model.js +91 -0
  9. package/dist/components/ai-extraction-review/extraction-model.js.map +1 -0
  10. package/dist/components/ai-extraction-review/index.d.ts +3 -0
  11. package/dist/components/ai-extraction-review/index.js +3 -0
  12. package/dist/components/ai-extraction-review/meta.js +17 -0
  13. package/dist/components/ai-extraction-review/meta.js.map +1 -0
  14. package/dist/components/ai-suggested-value/ai-suggested-value.d.ts +72 -0
  15. package/dist/components/ai-suggested-value/ai-suggested-value.d.ts.map +1 -0
  16. package/dist/components/ai-suggested-value/ai-suggested-value.js +126 -0
  17. package/dist/components/ai-suggested-value/ai-suggested-value.js.map +1 -0
  18. package/dist/components/ai-suggested-value/index.d.ts +2 -0
  19. package/dist/components/ai-suggested-value/index.js +2 -0
  20. package/dist/components/ai-suggested-value/meta.js +17 -0
  21. package/dist/components/ai-suggested-value/meta.js.map +1 -0
  22. package/dist/components/alert/alert.d.ts +1 -1
  23. package/dist/components/avatar/avatar.d.ts +1 -1
  24. package/dist/components/badge/badge.d.ts +1 -1
  25. package/dist/components/button/button.d.ts +1 -1
  26. package/dist/components/confirm-typed/confirm-typed.d.ts +47 -0
  27. package/dist/components/confirm-typed/confirm-typed.d.ts.map +1 -0
  28. package/dist/components/confirm-typed/confirm-typed.js +106 -0
  29. package/dist/components/confirm-typed/confirm-typed.js.map +1 -0
  30. package/dist/components/confirm-typed/index.d.ts +2 -0
  31. package/dist/components/confirm-typed/index.js +2 -0
  32. package/dist/components/confirm-typed/meta.js +17 -0
  33. package/dist/components/confirm-typed/meta.js.map +1 -0
  34. package/dist/components/cron-editor/cron-editor.d.ts +36 -0
  35. package/dist/components/cron-editor/cron-editor.d.ts.map +1 -0
  36. package/dist/components/cron-editor/cron-editor.js +493 -0
  37. package/dist/components/cron-editor/cron-editor.js.map +1 -0
  38. package/dist/components/cron-editor/cron-expression.d.ts +82 -0
  39. package/dist/components/cron-editor/cron-expression.d.ts.map +1 -0
  40. package/dist/components/cron-editor/cron-expression.js +352 -0
  41. package/dist/components/cron-editor/cron-expression.js.map +1 -0
  42. package/dist/components/cron-editor/index.d.ts +3 -0
  43. package/dist/components/cron-editor/index.js +3 -0
  44. package/dist/components/cron-editor/meta.js +17 -0
  45. package/dist/components/cron-editor/meta.js.map +1 -0
  46. package/dist/components/dns-record/dns-record.d.ts +61 -0
  47. package/dist/components/dns-record/dns-record.d.ts.map +1 -0
  48. package/dist/components/dns-record/dns-record.js +227 -0
  49. package/dist/components/dns-record/dns-record.js.map +1 -0
  50. package/dist/components/dns-record/index.d.ts +2 -0
  51. package/dist/components/dns-record/index.js +2 -0
  52. package/dist/components/dns-record/meta.js +17 -0
  53. package/dist/components/dns-record/meta.js.map +1 -0
  54. package/dist/components/permission-matrix/index.d.ts +3 -0
  55. package/dist/components/permission-matrix/index.js +3 -0
  56. package/dist/components/permission-matrix/meta.js +17 -0
  57. package/dist/components/permission-matrix/meta.js.map +1 -0
  58. package/dist/components/permission-matrix/permission-matrix.d.ts +46 -0
  59. package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
  60. package/dist/components/permission-matrix/permission-matrix.js +199 -0
  61. package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
  62. package/dist/components/permission-matrix/permission-model.d.ts +53 -0
  63. package/dist/components/permission-matrix/permission-model.d.ts.map +1 -0
  64. package/dist/components/permission-matrix/permission-model.js +64 -0
  65. package/dist/components/permission-matrix/permission-model.js.map +1 -0
  66. package/dist/components/progress/progress.d.ts +1 -1
  67. package/dist/components/secret-field/index.d.ts +2 -0
  68. package/dist/components/secret-field/index.js +2 -0
  69. package/dist/components/secret-field/meta.js +17 -0
  70. package/dist/components/secret-field/meta.js.map +1 -0
  71. package/dist/components/secret-field/secret-field.d.ts +58 -0
  72. package/dist/components/secret-field/secret-field.d.ts.map +1 -0
  73. package/dist/components/secret-field/secret-field.js +168 -0
  74. package/dist/components/secret-field/secret-field.js.map +1 -0
  75. package/dist/components/session-expiry/index.d.ts +2 -0
  76. package/dist/components/session-expiry/index.js +2 -0
  77. package/dist/components/session-expiry/meta.js +17 -0
  78. package/dist/components/session-expiry/meta.js.map +1 -0
  79. package/dist/components/session-expiry/session-expiry.d.ts +64 -0
  80. package/dist/components/session-expiry/session-expiry.d.ts.map +1 -0
  81. package/dist/components/session-expiry/session-expiry.js +185 -0
  82. package/dist/components/session-expiry/session-expiry.js.map +1 -0
  83. package/dist/components/shortcut-recorder/index.d.ts +3 -0
  84. package/dist/components/shortcut-recorder/index.js +3 -0
  85. package/dist/components/shortcut-recorder/meta.js +17 -0
  86. package/dist/components/shortcut-recorder/meta.js.map +1 -0
  87. package/dist/components/shortcut-recorder/shortcut-model.d.ts +67 -0
  88. package/dist/components/shortcut-recorder/shortcut-model.d.ts.map +1 -0
  89. package/dist/components/shortcut-recorder/shortcut-model.js +168 -0
  90. package/dist/components/shortcut-recorder/shortcut-model.js.map +1 -0
  91. package/dist/components/shortcut-recorder/shortcut-recorder.d.ts +47 -0
  92. package/dist/components/shortcut-recorder/shortcut-recorder.d.ts.map +1 -0
  93. package/dist/components/shortcut-recorder/shortcut-recorder.js +212 -0
  94. package/dist/components/shortcut-recorder/shortcut-recorder.js.map +1 -0
  95. package/dist/components/spinner/spinner.d.ts +1 -1
  96. package/dist/components/sync-status/index.d.ts +2 -0
  97. package/dist/components/sync-status/index.js +2 -0
  98. package/dist/components/sync-status/meta.js +17 -0
  99. package/dist/components/sync-status/meta.js.map +1 -0
  100. package/dist/components/sync-status/sync-status.d.ts +65 -0
  101. package/dist/components/sync-status/sync-status.d.ts.map +1 -0
  102. package/dist/components/sync-status/sync-status.js +103 -0
  103. package/dist/components/sync-status/sync-status.js.map +1 -0
  104. package/dist/components/toast/toast.d.ts +1 -1
  105. package/dist/index.d.ts +25 -1
  106. package/dist/index.js +16 -2
  107. package/dist/registry/components.d.ts.map +1 -1
  108. package/dist/registry/components.js +73 -53
  109. package/dist/registry/components.js.map +1 -1
  110. package/package.json +4 -4
  111. package/src/components/ai-extraction-review/ai-extraction-review.tsx +492 -0
  112. package/src/components/ai-extraction-review/extraction-model.ts +159 -0
  113. package/src/components/ai-extraction-review/index.ts +13 -0
  114. package/src/components/ai-extraction-review/meta.ts +24 -0
  115. package/src/components/ai-suggested-value/ai-suggested-value.tsx +295 -0
  116. package/src/components/ai-suggested-value/index.ts +6 -0
  117. package/src/components/ai-suggested-value/meta.ts +24 -0
  118. package/src/components/confirm-typed/confirm-typed.tsx +191 -0
  119. package/src/components/confirm-typed/index.ts +1 -0
  120. package/src/components/confirm-typed/meta.ts +22 -0
  121. package/src/components/cron-editor/cron-editor.tsx +676 -0
  122. package/src/components/cron-editor/cron-expression.ts +552 -0
  123. package/src/components/cron-editor/index.ts +23 -0
  124. package/src/components/cron-editor/meta.ts +23 -0
  125. package/src/components/dns-record/dns-record.tsx +315 -0
  126. package/src/components/dns-record/index.ts +7 -0
  127. package/src/components/dns-record/meta.ts +21 -0
  128. package/src/components/permission-matrix/index.ts +14 -0
  129. package/src/components/permission-matrix/meta.ts +23 -0
  130. package/src/components/permission-matrix/permission-matrix.tsx +368 -0
  131. package/src/components/permission-matrix/permission-model.ts +120 -0
  132. package/src/components/secret-field/index.ts +6 -0
  133. package/src/components/secret-field/meta.ts +21 -0
  134. package/src/components/secret-field/secret-field.tsx +284 -0
  135. package/src/components/session-expiry/index.ts +9 -0
  136. package/src/components/session-expiry/meta.ts +23 -0
  137. package/src/components/session-expiry/session-expiry.tsx +321 -0
  138. package/src/components/shortcut-recorder/index.ts +19 -0
  139. package/src/components/shortcut-recorder/meta.ts +22 -0
  140. package/src/components/shortcut-recorder/shortcut-model.ts +204 -0
  141. package/src/components/shortcut-recorder/shortcut-recorder.tsx +336 -0
  142. package/src/components/sync-status/index.ts +9 -0
  143. package/src/components/sync-status/meta.ts +21 -0
  144. package/src/components/sync-status/sync-status.tsx +217 -0
  145. package/src/index.ts +10 -0
  146. package/src/registry/components.ts +20 -0
package/README.md CHANGED
@@ -54,29 +54,33 @@ they want to change something.
54
54
 
55
55
  ## What is in it
56
56
 
57
- **60 components** and **8 blocks**, every one keyboard-operable and audited for
57
+ **70 components** and **8 blocks**, every one keyboard-operable and audited for
58
58
  contrast.
59
59
 
60
60
  **AI** — the reason this library exists
61
61
  Conversation · Message · Response · Prompt Input · Tool Call · Reasoning ·
62
62
  Sources · Model Selector · Token Usage · Agent Status · Agent Plan ·
63
63
  Approval Request · Action Ledger · Structured Output · Inline Completion ·
64
- **Disclosure**
64
+ Disclosure · **Extraction Review** ·
65
+ **Suggested Value**
65
66
 
66
67
  **Forms**
67
68
  Input · Label · Checkbox · Radio Group · Switch · Slider · Select · Combobox ·
68
69
  Form · Calendar · Date Picker · Tags Input · File Upload ·
69
- **Time Range Picker**
70
+ **Time Range Picker** · **Cron Editor** · **Secret Field** ·
71
+ **Confirm Typed** · **Shortcut Recorder**
70
72
 
71
73
  **Overlays**
72
74
  Dialog · Sheet · Drawer · Popover · Tooltip · Dropdown Menu
73
75
 
74
76
  **Data**
75
77
  Table · Data Table · Accordion · Activity Feed · Code Block · Metric Delta ·
76
- Record Diff · **Log Viewer** · **Diff Viewer**
78
+ Record Diff · **Log Viewer** · **Diff Viewer** · **Permission Matrix** ·
79
+ **DNS Record**
77
80
 
78
81
  **Feedback**
79
- Alert · Toast · Progress · Meter · Skeleton · Spinner · Empty State
82
+ Alert · Toast · Progress · Meter · Skeleton · Spinner · Empty State ·
83
+ **Sync Status** · **Session Expiry**
80
84
 
81
85
  **Navigation & layout**
82
86
  Tabs · Command · Pagination · Card · Badge · Avatar · Button · Separator
@@ -0,0 +1,52 @@
1
+ import { ExtractionField, FieldDecision } from "./extraction-model.js";
2
+ import { ComponentPropsWithRef, ReactNode } from "react";
3
+ //#region src/components/ai-extraction-review/ai-extraction-review.d.ts
4
+ /**
5
+ * The check after extraction: the document on one side, what the model read
6
+ * out of it on the other, and a decision about every field.
7
+ *
8
+ * Every extraction demo shows the filled object and stops. The products that
9
+ * run extraction for a living — invoice capture, KYC onboarding, claims intake —
10
+ * all have this screen, each built from scratch, because a value that cannot
11
+ * be checked can only be trusted, and nobody who is paying an invoice trusts a
12
+ * model that far. No component library ships it.
13
+ *
14
+ * The link is the component. Each field carries where in the source it was
15
+ * read from, quoted in text under the value as well as highlighted in the
16
+ * document, so a reviewer who cannot see the highlight still has the evidence.
17
+ * And a value with no evidence is said outright — "the model supplied this
18
+ * without evidence" — because that is the case a review exists to catch, and
19
+ * the one every filled-object view renders identically to a good value.
20
+ *
21
+ * Evidence is a text offset, not a bounding box. A language model reads text,
22
+ * and a text layer with offsets is what every OCR pipeline already yields.
23
+ * Boxes over a rendered page need page rendering, zoom and geometry, and are a
24
+ * different component; this one does not pretend at them.
25
+ *
26
+ * Decisions are controlled and the component writes nothing. It reports that
27
+ * a field was accepted as proposed, corrected from what was proposed, or
28
+ * rejected — a richer record than a form's submitted values, and the one an
29
+ * audit later needs — and leaves what to do with it to the application.
30
+ */
31
+ interface ExtractionReviewProps extends Omit<ComponentPropsWithRef<"section">, "children"> {
32
+ /** What the model read. Every span indexes into it. */
33
+ source: string;
34
+ /** Names the source — "Invoice 4471.pdf, page 1". */
35
+ sourceLabel?: string;
36
+ /** What is being reviewed, as the heading. */
37
+ heading: string;
38
+ fields: ExtractionField[];
39
+ /** Per-field decisions, keyed by field name. Controlled. */
40
+ decisions?: Record<string, FieldDecision>;
41
+ /** Omit to render the review as a record rather than something to operate. */
42
+ onDecision?: (name: string, decision: FieldDecision) => void;
43
+ /** True while fields are still arriving. Missing values wait instead of reading as not found. */
44
+ streaming?: boolean;
45
+ /** Confidence below this is called low, in words. */
46
+ lowConfidenceBelow?: number;
47
+ children?: ReactNode;
48
+ }
49
+ declare function ExtractionReview({ className, source, sourceLabel, heading, fields, decisions, onDecision, streaming, lowConfidenceBelow, children, ...props }: ExtractionReviewProps): import("react").JSX.Element;
50
+ //#endregion
51
+ export { ExtractionReview, ExtractionReviewProps };
52
+ //# sourceMappingURL=ai-extraction-review.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-extraction-review.d.ts","names":[],"sources":["../../../src/components/ai-extraction-review/ai-extraction-review.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAsDiB,8BAA8B,KAC7C;;EAIA;;EAEA;;EAEA;EACA,QAAQ;;EAER,YAAY,eAAe;;EAE3B,cAAc,cAAc,UAAU;;EAEtC;;EAEA;EACA,WAAW;;iBAGG,mBACd,WACA,QACA,aACA,SACA,QACA,WACA,YACA,WACA,oBACA,aACG,SACF,wCAAqB,IAAA"}
@@ -0,0 +1,249 @@
1
+ "use client";
2
+ import { disabledStyles, focusRing } from "../../lib/styles.js";
3
+ import { cn } from "../../lib/utils.js";
4
+ import { evidenceOf, isSourced, segmentSource, summarizeReview } from "./extraction-model.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { useEffect, useId, useMemo, useRef, useState } from "react";
7
+ //#region src/components/ai-extraction-review/ai-extraction-review.tsx
8
+ function ExtractionReview({ className, source, sourceLabel = "Source", heading, fields, decisions = {}, onDecision, streaming = false, lowConfidenceBelow = .7, children, ...props }) {
9
+ const headingId = useId();
10
+ const [activeField, setActiveField] = useState(null);
11
+ const runs = useMemo(() => segmentSource(source, fields), [source, fields]);
12
+ const summary = useMemo(() => summarizeReview(source, fields, decisions), [
13
+ source,
14
+ fields,
15
+ decisions
16
+ ]);
17
+ return /* @__PURE__ */ jsxs("section", {
18
+ "data-slot": "extraction-review",
19
+ "data-complete": summary.complete || void 0,
20
+ "aria-labelledby": headingId,
21
+ "aria-busy": streaming || void 0,
22
+ className: cn("flex flex-col gap-3", className),
23
+ ...props,
24
+ children: [
25
+ /* @__PURE__ */ jsxs("div", {
26
+ className: "flex flex-wrap items-baseline justify-between gap-2",
27
+ children: [/* @__PURE__ */ jsx("h3", {
28
+ id: headingId,
29
+ className: "text-sm font-medium",
30
+ children: heading
31
+ }), /* @__PURE__ */ jsxs("p", {
32
+ "data-slot": "extraction-review-summary",
33
+ "aria-live": "polite",
34
+ className: "text-xs text-muted-foreground",
35
+ children: [streaming ? "Fields are still arriving" : `${String(summary.reviewed)} of ${String(summary.total)} reviewed`, summary.unsourced.length > 0 ? ` · ${String(summary.unsourced.length)} without evidence` : null]
36
+ })]
37
+ }),
38
+ children,
39
+ /* @__PURE__ */ jsxs("div", {
40
+ className: "grid gap-4 md:grid-cols-2",
41
+ children: [/* @__PURE__ */ jsx(SourcePanel, {
42
+ label: sourceLabel,
43
+ runs,
44
+ active: activeField,
45
+ decisions
46
+ }), /* @__PURE__ */ jsx("ol", {
47
+ "data-slot": "extraction-fields",
48
+ className: "m-0 flex list-none flex-col gap-3 p-0",
49
+ children: fields.map((field) => /* @__PURE__ */ jsx(ReviewField, {
50
+ field,
51
+ source,
52
+ decision: decisions[field.name],
53
+ streaming,
54
+ lowConfidenceBelow,
55
+ active: activeField === field.name,
56
+ onActivate: () => {
57
+ setActiveField(field.name);
58
+ },
59
+ onDecision
60
+ }, field.name))
61
+ })]
62
+ })
63
+ ]
64
+ });
65
+ }
66
+ function SourcePanel({ label, runs, active, decisions }) {
67
+ const ref = useRef(null);
68
+ useEffect(() => {
69
+ if (!active || !ref.current) return;
70
+ ref.current.querySelector(`mark[data-active]`)?.scrollIntoView({ block: "nearest" });
71
+ }, [active]);
72
+ return /* @__PURE__ */ jsx("div", {
73
+ ref,
74
+ "data-slot": "extraction-source",
75
+ role: "region",
76
+ "aria-label": label,
77
+ tabIndex: 0,
78
+ className: cn("max-h-96 overflow-auto rounded-lg border border-border bg-muted/30 p-3 md:sticky md:top-0 md:self-start", focusRing),
79
+ children: runs.length === 0 ? /* @__PURE__ */ jsx("p", {
80
+ className: "text-xs text-muted-foreground",
81
+ children: "No source text."
82
+ }) : /* @__PURE__ */ jsx("pre", {
83
+ className: "m-0 font-sans text-sm leading-relaxed break-words whitespace-pre-wrap",
84
+ children: runs.map((run, index) => run.fields.length === 0 ? /* @__PURE__ */ jsx("span", { children: run.text }, index) : /* @__PURE__ */ jsx("mark", {
85
+ "data-fields": run.fields.join(" "),
86
+ "data-active": active !== null && run.fields.includes(active) ? "" : void 0,
87
+ className: cn("rounded-[2px] text-inherit", run.fields.every((name) => decisions[name]?.kind === "rejected") ? "bg-muted line-through decoration-muted-foreground" : "bg-primary/15", active !== null && run.fields.includes(active) && "bg-primary/30 ring-1 ring-primary ring-inset"),
88
+ children: run.text
89
+ }, index))
90
+ })
91
+ });
92
+ }
93
+ /** Whitespace collapsed and cut short, for quoting evidence under a field. */
94
+ function quote(text, limit = 80) {
95
+ const collapsed = text.replace(/\s+/g, " ").trim();
96
+ return collapsed.length > limit ? `${collapsed.slice(0, limit - 1)}…` : collapsed;
97
+ }
98
+ function ReviewField({ field, source, decision, streaming, lowConfidenceBelow, active, onActivate, onDecision }) {
99
+ const inputId = useId();
100
+ const evidenceId = useId();
101
+ const statusId = useId();
102
+ const confidenceId = useId();
103
+ const [draft, setDraft] = useState(null);
104
+ const proposed = field.value ?? "";
105
+ const decided = decision && decision.kind !== "rejected" ? decision.value : void 0;
106
+ const current = draft ?? decided ?? proposed;
107
+ const edited = current !== proposed;
108
+ const changedSince = decided !== void 0 && current !== decided;
109
+ const arriving = streaming && field.value === void 0;
110
+ const sourced = isSourced(source, field);
111
+ const evidence = sourced ? evidenceOf(source, field.span) : "";
112
+ const unsourced = !arriving && field.value !== void 0 && !sourced;
113
+ const accept = () => {
114
+ onDecision?.(field.name, edited ? {
115
+ kind: "corrected",
116
+ value: current,
117
+ proposed
118
+ } : {
119
+ kind: "accepted",
120
+ value: current
121
+ });
122
+ };
123
+ const onKeyDown = (event) => {
124
+ if (event.key !== "Enter") return;
125
+ if (event.nativeEvent.isComposing) return;
126
+ if (field.multiline && !(event.ctrlKey || event.metaKey)) return;
127
+ event.preventDefault();
128
+ accept();
129
+ };
130
+ const status = arriving ? "Arriving" : !decision ? "Not reviewed" : decision.kind === "rejected" ? "Rejected" : changedSince ? `Changed since it was ${decision.kind}` : decision.kind === "accepted" ? "Accepted" : decision.proposed ? `Corrected from “${quote(decision.proposed, 40)}”` : "Supplied by the reviewer";
131
+ const low = field.confidence !== void 0 && field.confidence < lowConfidenceBelow;
132
+ const percent = field.confidence === void 0 ? null : new Intl.NumberFormat(void 0, {
133
+ style: "percent",
134
+ maximumFractionDigits: 0
135
+ }).format(field.confidence);
136
+ const describedBy = [
137
+ evidenceId,
138
+ statusId,
139
+ percent !== null ? confidenceId : null
140
+ ].filter(Boolean).join(" ");
141
+ const controlClass = cn("w-full rounded-md border border-input bg-background px-2 py-1.5 text-sm", edited && "border-warning", focusRing);
142
+ return /* @__PURE__ */ jsxs("li", {
143
+ "data-slot": "extraction-field",
144
+ "data-field": field.name,
145
+ "data-state": arriving ? "arriving" : decision?.kind ?? "undecided",
146
+ "data-active": active || void 0,
147
+ "data-unsourced": unsourced || void 0,
148
+ onFocus: onActivate,
149
+ className: cn("flex flex-col gap-1 rounded-lg border p-3", active ? "border-primary" : "border-border", decision?.kind === "rejected" && "bg-muted/40"),
150
+ children: [
151
+ /* @__PURE__ */ jsxs("div", {
152
+ className: "flex flex-wrap items-baseline justify-between gap-2",
153
+ children: [onDecision && !arriving ? /* @__PURE__ */ jsx("label", {
154
+ htmlFor: inputId,
155
+ className: "text-xs font-medium text-muted-foreground",
156
+ children: field.label
157
+ }) : /* @__PURE__ */ jsx("span", {
158
+ className: "text-xs font-medium text-muted-foreground",
159
+ children: field.label
160
+ }), /* @__PURE__ */ jsx("span", {
161
+ id: statusId,
162
+ "data-slot": "extraction-field-status",
163
+ className: cn("text-xs", decision?.kind === "rejected" ? "text-destructive" : "text-muted-foreground", changedSince && "text-warning"),
164
+ children: status
165
+ })]
166
+ }),
167
+ arriving ? /* @__PURE__ */ jsx("span", {
168
+ "aria-hidden": "true",
169
+ className: "block h-8 w-full animate-pulse-soft rounded-md bg-muted"
170
+ }) : !onDecision ? /* @__PURE__ */ jsx("p", {
171
+ className: "rounded-md bg-muted px-2 py-1.5 text-sm break-words",
172
+ children: current || /* @__PURE__ */ jsx("span", {
173
+ className: "text-muted-foreground",
174
+ children: "Empty"
175
+ })
176
+ }) : field.multiline ? /* @__PURE__ */ jsx("textarea", {
177
+ id: inputId,
178
+ rows: 3,
179
+ value: current,
180
+ "aria-describedby": describedBy,
181
+ onChange: (event) => {
182
+ setDraft(event.target.value);
183
+ },
184
+ onKeyDown,
185
+ className: cn(controlClass, "resize-none")
186
+ }) : /* @__PURE__ */ jsx("input", {
187
+ id: inputId,
188
+ type: "text",
189
+ value: current,
190
+ "aria-describedby": describedBy,
191
+ onChange: (event) => {
192
+ setDraft(event.target.value);
193
+ },
194
+ onKeyDown,
195
+ className: controlClass
196
+ }),
197
+ /* @__PURE__ */ jsx("p", {
198
+ id: evidenceId,
199
+ "data-slot": "extraction-field-evidence",
200
+ className: cn("text-xs", unsourced ? "text-warning" : "text-muted-foreground"),
201
+ children: arriving ? "Waiting for the model" : sourced ? `In the source: “${quote(evidence)}”` : field.value === void 0 ? "The model found nothing for this field." : "Not in the source — the model supplied this without evidence."
202
+ }),
203
+ percent !== null ? /* @__PURE__ */ jsx("p", {
204
+ id: confidenceId,
205
+ "data-slot": "extraction-field-confidence",
206
+ "data-low": low || void 0,
207
+ className: cn("text-xs", low ? "text-warning" : "text-muted-foreground"),
208
+ children: low ? `Low confidence, ${percent} — worth checking` : `${percent} confidence`
209
+ }) : null,
210
+ onDecision && !arriving ? /* @__PURE__ */ jsxs("div", {
211
+ className: "mt-1 flex flex-wrap items-center gap-2",
212
+ children: [
213
+ /* @__PURE__ */ jsx(FieldButton, {
214
+ variant: "primary",
215
+ "aria-label": `${edited ? "Accept correction" : "Accept"} — ${field.label}`,
216
+ "aria-pressed": decision !== void 0 && decision.kind !== "rejected" && !changedSince,
217
+ onClick: accept,
218
+ children: edited ? "Accept correction" : "Accept"
219
+ }),
220
+ /* @__PURE__ */ jsx(FieldButton, {
221
+ "aria-label": `Reject — ${field.label}`,
222
+ "aria-pressed": decision?.kind === "rejected",
223
+ onClick: () => {
224
+ onDecision(field.name, { kind: "rejected" });
225
+ },
226
+ children: "Reject"
227
+ }),
228
+ sourced ? /* @__PURE__ */ jsx(FieldButton, {
229
+ "aria-label": `Show in source — ${field.label}`,
230
+ className: "ml-auto",
231
+ onClick: onActivate,
232
+ children: "Show in source"
233
+ }) : null
234
+ ]
235
+ }) : null
236
+ ]
237
+ });
238
+ }
239
+ function FieldButton({ className, variant = "default", ...props }) {
240
+ return /* @__PURE__ */ jsx("button", {
241
+ type: "button",
242
+ className: cn("rounded-md border px-2.5 py-1 text-xs font-medium transition-colors", variant === "primary" && "border-primary bg-primary text-primary-foreground hover:bg-primary-hover aria-pressed:bg-primary-active", variant === "default" && "border-input bg-background hover:bg-accent hover:text-accent-foreground aria-pressed:bg-secondary aria-pressed:text-secondary-foreground", focusRing, disabledStyles, className),
243
+ ...props
244
+ });
245
+ }
246
+ //#endregion
247
+ export { ExtractionReview };
248
+
249
+ //# sourceMappingURL=ai-extraction-review.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai-extraction-review.js","names":[],"sources":["../../../src/components/ai-extraction-review/ai-extraction-review.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n type ComponentPropsWithRef,\n type KeyboardEvent,\n type ReactNode,\n} from \"react\";\n\nimport { disabledStyles, focusRing } from \"@/lib/styles\";\nimport { cn } from \"@/lib/utils\";\n\nimport {\n evidenceOf,\n isSourced,\n segmentSource,\n summarizeReview,\n type ExtractionField,\n type FieldDecision,\n type SourceRun,\n} from \"./extraction-model\";\n\n/**\n * The check after extraction: the document on one side, what the model read\n * out of it on the other, and a decision about every field.\n *\n * Every extraction demo shows the filled object and stops. The products that\n * run extraction for a living — invoice capture, KYC onboarding, claims intake —\n * all have this screen, each built from scratch, because a value that cannot\n * be checked can only be trusted, and nobody who is paying an invoice trusts a\n * model that far. No component library ships it.\n *\n * The link is the component. Each field carries where in the source it was\n * read from, quoted in text under the value as well as highlighted in the\n * document, so a reviewer who cannot see the highlight still has the evidence.\n * And a value with no evidence is said outright — \"the model supplied this\n * without evidence\" — because that is the case a review exists to catch, and\n * the one every filled-object view renders identically to a good value.\n *\n * Evidence is a text offset, not a bounding box. A language model reads text,\n * and a text layer with offsets is what every OCR pipeline already yields.\n * Boxes over a rendered page need page rendering, zoom and geometry, and are a\n * different component; this one does not pretend at them.\n *\n * Decisions are controlled and the component writes nothing. It reports that\n * a field was accepted as proposed, corrected from what was proposed, or\n * rejected — a richer record than a form's submitted values, and the one an\n * audit later needs — and leaves what to do with it to the application.\n */\n\nexport interface ExtractionReviewProps extends Omit<\n ComponentPropsWithRef<\"section\">,\n \"children\"\n> {\n /** What the model read. Every span indexes into it. */\n source: string;\n /** Names the source — \"Invoice 4471.pdf, page 1\". */\n sourceLabel?: string;\n /** What is being reviewed, as the heading. */\n heading: string;\n fields: ExtractionField[];\n /** Per-field decisions, keyed by field name. Controlled. */\n decisions?: Record<string, FieldDecision>;\n /** Omit to render the review as a record rather than something to operate. */\n onDecision?: (name: string, decision: FieldDecision) => void;\n /** True while fields are still arriving. Missing values wait instead of reading as not found. */\n streaming?: boolean;\n /** Confidence below this is called low, in words. */\n lowConfidenceBelow?: number;\n children?: ReactNode;\n}\n\nexport function ExtractionReview({\n className,\n source,\n sourceLabel = \"Source\",\n heading,\n fields,\n decisions = {},\n onDecision,\n streaming = false,\n lowConfidenceBelow = 0.7,\n children,\n ...props\n}: ExtractionReviewProps) {\n const headingId = useId();\n const [activeField, setActiveField] = useState<string | null>(null);\n\n const runs = useMemo(() => segmentSource(source, fields), [source, fields]);\n const summary = useMemo(\n () => summarizeReview(source, fields, decisions),\n [source, fields, decisions],\n );\n\n return (\n <section\n data-slot=\"extraction-review\"\n data-complete={summary.complete || undefined}\n aria-labelledby={headingId}\n aria-busy={streaming || undefined}\n className={cn(\"flex flex-col gap-3\", className)}\n {...props}\n >\n <div className=\"flex flex-wrap items-baseline justify-between gap-2\">\n <h3 id={headingId} className=\"text-sm font-medium\">\n {heading}\n </h3>\n {/* Live from the start and short, so each decision is followed by\n where the review stands rather than by silence. Evidence gaps are\n counted here too: they are the reason to read carefully, and worth\n knowing before starting rather than discovering on field six. */}\n <p\n data-slot=\"extraction-review-summary\"\n aria-live=\"polite\"\n className=\"text-xs text-muted-foreground\"\n >\n {streaming\n ? \"Fields are still arriving\"\n : `${String(summary.reviewed)} of ${String(summary.total)} reviewed`}\n {summary.unsourced.length > 0\n ? ` · ${String(summary.unsourced.length)} without evidence`\n : null}\n </p>\n </div>\n\n {children}\n\n <div className=\"grid gap-4 md:grid-cols-2\">\n <SourcePanel\n label={sourceLabel}\n runs={runs}\n active={activeField}\n decisions={decisions}\n />\n\n <ol data-slot=\"extraction-fields\" className=\"m-0 flex list-none flex-col gap-3 p-0\">\n {fields.map((field) => (\n <ReviewField\n key={field.name}\n field={field}\n source={source}\n decision={decisions[field.name]}\n streaming={streaming}\n lowConfidenceBelow={lowConfidenceBelow}\n active={activeField === field.name}\n onActivate={() => {\n setActiveField(field.name);\n }}\n onDecision={onDecision}\n />\n ))}\n </ol>\n </div>\n </section>\n );\n}\n\nfunction SourcePanel({\n label,\n runs,\n active,\n decisions,\n}: {\n label: string;\n runs: SourceRun[];\n active: string | null;\n decisions: Record<string, FieldDecision>;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n\n // Bring the active field's evidence into view. Focus stays where it is —\n // in the field — so a keyboard user is shown the source without being\n // moved into it.\n useEffect(() => {\n if (!active || !ref.current) return;\n const mark = ref.current.querySelector(`mark[data-active]`);\n mark?.scrollIntoView({ block: \"nearest\" });\n }, [active]);\n\n return (\n <div\n ref={ref}\n data-slot=\"extraction-source\"\n // A scrolling box has to be focusable to be scrolled by keyboard, and a\n // focusable box needs a name.\n role=\"region\"\n aria-label={label}\n tabIndex={0}\n // Sticks beside the fields on a wide screen, so the evidence for field\n // nine is still in view when the reviewer reaches it.\n className={cn(\n \"max-h-96 overflow-auto rounded-lg border border-border bg-muted/30 p-3 md:sticky md:top-0 md:self-start\",\n focusRing,\n )}\n >\n {runs.length === 0 ? (\n <p className=\"text-xs text-muted-foreground\">No source text.</p>\n ) : (\n <pre className=\"m-0 font-sans text-sm leading-relaxed break-words whitespace-pre-wrap\">\n {runs.map((run, index) =>\n run.fields.length === 0 ? (\n <span key={index}>{run.text}</span>\n ) : (\n // A mark element, so the evidence survives as structure rather\n // than only as a tint. No label is inserted into the text: a\n // document read aloud with field names spliced into it is not\n // the document, and the field already quotes its evidence.\n <mark\n key={index}\n data-fields={run.fields.join(\" \")}\n data-active={active !== null && run.fields.includes(active) ? \"\" : undefined}\n className={cn(\n \"rounded-[2px] text-inherit\",\n run.fields.every((name) => decisions[name]?.kind === \"rejected\")\n ? \"bg-muted line-through decoration-muted-foreground\"\n : \"bg-primary/15\",\n active !== null &&\n run.fields.includes(active) &&\n \"bg-primary/30 ring-1 ring-primary ring-inset\",\n )}\n >\n {run.text}\n </mark>\n ),\n )}\n </pre>\n )}\n </div>\n );\n}\n\n/** Whitespace collapsed and cut short, for quoting evidence under a field. */\nfunction quote(text: string, limit = 80): string {\n const collapsed = text.replace(/\\s+/g, \" \").trim();\n return collapsed.length > limit ? `${collapsed.slice(0, limit - 1)}…` : collapsed;\n}\n\nfunction ReviewField({\n field,\n source,\n decision,\n streaming,\n lowConfidenceBelow,\n active,\n onActivate,\n onDecision,\n}: {\n field: ExtractionField;\n source: string;\n decision?: FieldDecision;\n streaming: boolean;\n lowConfidenceBelow: number;\n active: boolean;\n onActivate: () => void;\n onDecision?: (name: string, decision: FieldDecision) => void;\n}) {\n const inputId = useId();\n const evidenceId = useId();\n const statusId = useId();\n const confidenceId = useId();\n\n // The reviewer's typing, kept apart from the model's value so the decision\n // can say which is which.\n const [draft, setDraft] = useState<string | null>(null);\n\n const proposed = field.value ?? \"\";\n const decided = decision && decision.kind !== \"rejected\" ? decision.value : undefined;\n const current = draft ?? decided ?? proposed;\n const edited = current !== proposed;\n const changedSince = decided !== undefined && current !== decided;\n\n const arriving = streaming && field.value === undefined;\n const sourced = isSourced(source, field);\n const evidence = sourced ? evidenceOf(source, field.span) : \"\";\n const unsourced = !arriving && field.value !== undefined && !sourced;\n\n const accept = () => {\n onDecision?.(\n field.name,\n edited\n ? { kind: \"corrected\", value: current, proposed }\n : { kind: \"accepted\", value: current },\n );\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n if (event.key !== \"Enter\") return;\n // Enter confirms an IME candidate before it means anything else. Without\n // this, a reviewer typing a Japanese correction accepts a fragment of it.\n if (event.nativeEvent.isComposing) return;\n if (field.multiline && !(event.ctrlKey || event.metaKey)) return;\n event.preventDefault();\n accept();\n };\n\n const status = arriving\n ? \"Arriving\"\n : !decision\n ? \"Not reviewed\"\n : decision.kind === \"rejected\"\n ? \"Rejected\"\n : changedSince\n ? `Changed since it was ${decision.kind}`\n : decision.kind === \"accepted\"\n ? \"Accepted\"\n : decision.proposed\n ? `Corrected from “${quote(decision.proposed, 40)}”`\n : \"Supplied by the reviewer\";\n\n const low = field.confidence !== undefined && field.confidence < lowConfidenceBelow;\n const percent =\n field.confidence === undefined\n ? null\n : new Intl.NumberFormat(undefined, { style: \"percent\", maximumFractionDigits: 0 }).format(\n field.confidence,\n );\n\n const describedBy = [evidenceId, statusId, percent !== null ? confidenceId : null]\n .filter(Boolean)\n .join(\" \");\n\n const controlClass = cn(\n \"w-full rounded-md border border-input bg-background px-2 py-1.5 text-sm\",\n edited && \"border-warning\",\n focusRing,\n );\n\n return (\n <li\n data-slot=\"extraction-field\"\n data-field={field.name}\n data-state={arriving ? \"arriving\" : (decision?.kind ?? \"undecided\")}\n data-active={active || undefined}\n data-unsourced={unsourced || undefined}\n // Focus anywhere in the field — value, either button — is the reviewer\n // looking at it, so the source follows without a separate step.\n onFocus={onActivate}\n className={cn(\n \"flex flex-col gap-1 rounded-lg border p-3\",\n active ? \"border-primary\" : \"border-border\",\n decision?.kind === \"rejected\" && \"bg-muted/40\",\n )}\n >\n <div className=\"flex flex-wrap items-baseline justify-between gap-2\">\n {onDecision && !arriving ? (\n <label htmlFor={inputId} className=\"text-xs font-medium text-muted-foreground\">\n {field.label}\n </label>\n ) : (\n <span className=\"text-xs font-medium text-muted-foreground\">{field.label}</span>\n )}\n {/* Status as a word, outside the label so editing never renames the\n control under a screen reader user. */}\n <span\n id={statusId}\n data-slot=\"extraction-field-status\"\n className={cn(\n \"text-xs\",\n decision?.kind === \"rejected\" ? \"text-destructive\" : \"text-muted-foreground\",\n changedSince && \"text-warning\",\n )}\n >\n {status}\n </span>\n </div>\n\n {arriving ? (\n <span\n aria-hidden=\"true\"\n className=\"block h-8 w-full animate-pulse-soft rounded-md bg-muted\"\n />\n ) : !onDecision ? (\n <p className=\"rounded-md bg-muted px-2 py-1.5 text-sm break-words\">\n {current || <span className=\"text-muted-foreground\">Empty</span>}\n </p>\n ) : field.multiline ? (\n <textarea\n id={inputId}\n rows={3}\n value={current}\n aria-describedby={describedBy}\n onChange={(event) => {\n setDraft(event.target.value);\n }}\n onKeyDown={onKeyDown}\n className={cn(controlClass, \"resize-none\")}\n />\n ) : (\n <input\n id={inputId}\n type=\"text\"\n value={current}\n aria-describedby={describedBy}\n onChange={(event) => {\n setDraft(event.target.value);\n }}\n onKeyDown={onKeyDown}\n className={controlClass}\n />\n )}\n\n {/* The evidence in text. This is the accessible path to the source, and\n for a sighted reviewer it is the comparison itself — \"1 March 2026\"\n beside \"2026-03-01\" is a normalisation, not an error, and only reads\n that way with both in view. */}\n <p\n id={evidenceId}\n data-slot=\"extraction-field-evidence\"\n className={cn(\"text-xs\", unsourced ? \"text-warning\" : \"text-muted-foreground\")}\n >\n {arriving\n ? \"Waiting for the model\"\n : sourced\n ? `In the source: “${quote(evidence)}”`\n : field.value === undefined\n ? \"The model found nothing for this field.\"\n : \"Not in the source — the model supplied this without evidence.\"}\n </p>\n\n {percent !== null ? (\n <p\n id={confidenceId}\n data-slot=\"extraction-field-confidence\"\n data-low={low || undefined}\n className={cn(\"text-xs\", low ? \"text-warning\" : \"text-muted-foreground\")}\n >\n {low ? `Low confidence, ${percent} — worth checking` : `${percent} confidence`}\n </p>\n ) : null}\n\n {onDecision && !arriving ? (\n <div className=\"mt-1 flex flex-wrap items-center gap-2\">\n <FieldButton\n variant=\"primary\"\n aria-label={`${edited ? \"Accept correction\" : \"Accept\"} — ${field.label}`}\n aria-pressed={\n decision !== undefined && decision.kind !== \"rejected\" && !changedSince\n }\n onClick={accept}\n >\n {edited ? \"Accept correction\" : \"Accept\"}\n </FieldButton>\n <FieldButton\n aria-label={`Reject — ${field.label}`}\n aria-pressed={decision?.kind === \"rejected\"}\n onClick={() => {\n onDecision(field.name, { kind: \"rejected\" });\n }}\n >\n Reject\n </FieldButton>\n {sourced ? (\n <FieldButton\n aria-label={`Show in source — ${field.label}`}\n className=\"ml-auto\"\n onClick={onActivate}\n >\n Show in source\n </FieldButton>\n ) : null}\n </div>\n ) : null}\n </li>\n );\n}\n\nfunction FieldButton({\n className,\n variant = \"default\",\n ...props\n}: ComponentPropsWithRef<\"button\"> & { variant?: \"default\" | \"primary\" }) {\n return (\n <button\n type=\"button\"\n className={cn(\n \"rounded-md border px-2.5 py-1 text-xs font-medium transition-colors\",\n variant === \"primary\" &&\n \"border-primary bg-primary text-primary-foreground hover:bg-primary-hover aria-pressed:bg-primary-active\",\n variant === \"default\" &&\n \"border-input bg-background hover:bg-accent hover:text-accent-foreground aria-pressed:bg-secondary aria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W;GACZ,CAAA;GAOH,oBAAC,KAAD;IACE,IAAI;IACJ,aAAU;IACV,WAAW,GAAG,WAAW,YAAY,iBAAiB,uBAAuB;IAE5E,UAAA,WACG,0BACA,UACE,mBAAmB,MAAM,QAAQ,EAAE,KACnC,MAAM,UAAU,KAAA,IACd,4CACA;GACP,CAAA;GAEF,YAAY,OACX,oBAAC,KAAD;IACE,IAAI;IACJ,aAAU;IACV,YAAU,OAAO,KAAA;IACjB,WAAW,GAAG,WAAW,MAAM,iBAAiB,uBAAuB;IAEtE,UAAA,MAAM,mBAAmB,QAAQ,qBAAqB,GAAG,QAAQ;GACjE,CAAA,IACD;GAEH,cAAc,CAAC,WACd,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACE,oBAAC,aAAD;MACE,SAAQ;MACR,cAAY,GAAG,SAAS,sBAAsB,SAAS,KAAK,MAAM;MAClE,gBACE,aAAa,KAAA,KAAa,SAAS,SAAS,cAAc,CAAC;MAE7D,SAAS;MAER,UAAA,SAAS,sBAAsB;KACrB,CAAA;KACb,oBAAC,aAAD;MACE,cAAY,YAAY,MAAM;MAC9B,gBAAc,UAAU,SAAS;MACjC,eAAe;OACb,WAAW,MAAM,MAAM,EAAE,MAAM,WAAW,CAAC;MAC7C;MACD,UAAA;KAEY,CAAA;KACZ,UACC,oBAAC,aAAD;MACE,cAAY,oBAAoB,MAAM;MACtC,WAAU;MACV,SAAS;MACV,UAAA;KAEY,CAAA,IACX;IACD;GACH,CAAA,IAAA;EACF;;AAER;AAEA,SAAS,YAAY,EACnB,WACA,UAAU,WACV,GAAG,SACqE;CACxE,OACE,oBAAC,UAAD;EACE,MAAK;EACL,WAAW,GACT,uEACA,YAAY,aACV,2GACF,YAAY,aACV,4IACF,WACA,gBACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
@@ -0,0 +1,94 @@
1
+ //#region src/components/ai-extraction-review/extraction-model.d.ts
2
+ /**
3
+ * The model behind a review of extracted fields: where each value was read
4
+ * from, what the reviewer decided about it, and how far through the review
5
+ * they are.
6
+ *
7
+ * Pure, so overlap handling and the completion rule are tested without
8
+ * rendering anything — and so an application can answer "is this review
9
+ * finished" on the server from the same decisions the component reports,
10
+ * rather than trusting a flag the client sent.
11
+ */
12
+ interface SourceSpan {
13
+ /** Offset into the source text in UTF-16 code units. Inclusive. */
14
+ start: number;
15
+ /** Exclusive. */
16
+ end: number;
17
+ }
18
+ interface ExtractionField {
19
+ /** Key in the extracted object. */
20
+ name: string;
21
+ label: string;
22
+ /**
23
+ * What the model extracted. Absent while streaming means it has not arrived;
24
+ * absent once streaming has ended means the model found nothing.
25
+ */
26
+ value?: string;
27
+ /**
28
+ * Where in the source the value was read from. Absent means the model
29
+ * supplied the value without evidence, which the review says outright.
30
+ */
31
+ span?: SourceSpan;
32
+ /** 0 to 1. Shown as a number, never only as a colour. */
33
+ confidence?: number;
34
+ /** A textarea instead of a single line. For addresses and descriptions. */
35
+ multiline?: boolean;
36
+ }
37
+ type FieldDecision =
38
+ /** The model's value, taken as it was. */
39
+ {
40
+ kind: "accepted";
41
+ value: string;
42
+ } |
43
+ /** The reviewer's value, with the model's kept so a record can tell them apart. */
44
+ {
45
+ kind: "corrected";
46
+ value: string;
47
+ proposed: string;
48
+ } |
49
+ /** Wrong and not corrected — the field does not apply, or cannot be known. */
50
+ {
51
+ kind: "rejected";
52
+ };
53
+ /** A run of source text and the fields whose evidence covers it. */
54
+ interface SourceRun {
55
+ text: string;
56
+ /** Field names, in declaration order. Empty for text nobody cites. */
57
+ fields: string[];
58
+ }
59
+ /**
60
+ * A span brought within the source, or null if nothing of it is.
61
+ *
62
+ * Offsets come from a model or an OCR layer and are wrong often enough that
63
+ * refusing to render on a bad one would leave the whole review blank. A span
64
+ * past the end is clamped; an inverted or empty one is treated as no evidence,
65
+ * which is what it is.
66
+ */
67
+ declare function clampSpan(span: SourceSpan, length: number): SourceSpan | null;
68
+ /** The text a span points at, or an empty string if it points at nothing. */
69
+ declare function evidenceOf(source: string, span: SourceSpan | undefined): string;
70
+ /** Whether a field's value can be checked against the source at all. */
71
+ declare function isSourced(source: string, field: ExtractionField): boolean;
72
+ /**
73
+ * Cuts the source into runs at every span boundary, so overlapping evidence —
74
+ * a total that sits inside the line that contains it — renders as nested
75
+ * coverage rather than as two marks fighting over the same characters.
76
+ */
77
+ declare function segmentSource(source: string, fields: ExtractionField[]): SourceRun[];
78
+ interface ReviewSummary {
79
+ total: number;
80
+ reviewed: number;
81
+ accepted: number;
82
+ corrected: number;
83
+ rejected: number;
84
+ /** Fields with a value the model could not point to in the source. */
85
+ unsourced: string[];
86
+ /** Fields still awaiting a decision. */
87
+ remaining: string[];
88
+ /** Every field has a decision. The only completion signal worth trusting. */
89
+ complete: boolean;
90
+ }
91
+ declare function summarizeReview(source: string, fields: ExtractionField[], decisions?: Record<string, FieldDecision>): ReviewSummary;
92
+ //#endregion
93
+ export { ExtractionField, FieldDecision, ReviewSummary, SourceRun, SourceSpan, clampSpan, evidenceOf, isSourced, segmentSource, summarizeReview };
94
+ //# sourceMappingURL=extraction-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extraction-model.d.ts","names":[],"sources":["../../../src/components/ai-extraction-review/extraction-model.ts"],"mappings":";;;;;;;;;;;UAWiB;;EAEf;;EAEA;;UAGe;;EAEf;EACA;;;;;EAKA;;;;;EAKA,OAAO;;EAEP;;EAEA;;KAGU;;;EAEN;EAAkB;;;;EAElB;EAAmB;EAAe;;;;EAElC;;;UAGW;EACf;;EAEA;;;;;;;;;;iBAWc,UAAU,MAAM,YAAY,iBAAiB;;iBAO7C,WAAW,gBAAgB,MAAM;;iBAOjC,UAAU,gBAAgB,OAAO;;;;;;iBASjC,cAAc,gBAAgB,QAAQ,oBAAoB;UA6BzD;EACf;EACA;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;iBAGc,gBACd,gBACA,QAAQ,mBACR,YAAW,eAAe,iBACzB"}
@@ -0,0 +1,91 @@
1
+ //#region src/components/ai-extraction-review/extraction-model.ts
2
+ /**
3
+ * A span brought within the source, or null if nothing of it is.
4
+ *
5
+ * Offsets come from a model or an OCR layer and are wrong often enough that
6
+ * refusing to render on a bad one would leave the whole review blank. A span
7
+ * past the end is clamped; an inverted or empty one is treated as no evidence,
8
+ * which is what it is.
9
+ */
10
+ function clampSpan(span, length) {
11
+ const start = Math.max(0, Math.min(span.start, length));
12
+ const end = Math.max(0, Math.min(span.end, length));
13
+ return end > start ? {
14
+ start,
15
+ end
16
+ } : null;
17
+ }
18
+ /** The text a span points at, or an empty string if it points at nothing. */
19
+ function evidenceOf(source, span) {
20
+ if (!span) return "";
21
+ const clamped = clampSpan(span, source.length);
22
+ return clamped ? source.slice(clamped.start, clamped.end) : "";
23
+ }
24
+ /** Whether a field's value can be checked against the source at all. */
25
+ function isSourced(source, field) {
26
+ return field.span !== void 0 && clampSpan(field.span, source.length) !== null;
27
+ }
28
+ /**
29
+ * Cuts the source into runs at every span boundary, so overlapping evidence —
30
+ * a total that sits inside the line that contains it — renders as nested
31
+ * coverage rather than as two marks fighting over the same characters.
32
+ */
33
+ function segmentSource(source, fields) {
34
+ const spans = fields.flatMap((field) => {
35
+ const clamped = field.span ? clampSpan(field.span, source.length) : null;
36
+ return clamped ? [{
37
+ name: field.name,
38
+ ...clamped
39
+ }] : [];
40
+ });
41
+ if (source.length === 0) return [];
42
+ if (spans.length === 0) return [{
43
+ text: source,
44
+ fields: []
45
+ }];
46
+ const cuts = /* @__PURE__ */ new Set([0, source.length]);
47
+ for (const span of spans) {
48
+ cuts.add(span.start);
49
+ cuts.add(span.end);
50
+ }
51
+ const points = [...cuts].sort((a, b) => a - b);
52
+ const runs = [];
53
+ for (let index = 0; index < points.length - 1; index += 1) {
54
+ const start = points[index] ?? 0;
55
+ const end = points[index + 1] ?? start;
56
+ if (end <= start) continue;
57
+ runs.push({
58
+ text: source.slice(start, end),
59
+ fields: spans.filter((span) => span.start <= start && span.end >= end).map((s) => s.name)
60
+ });
61
+ }
62
+ return runs;
63
+ }
64
+ function summarizeReview(source, fields, decisions = {}) {
65
+ const summary = {
66
+ total: fields.length,
67
+ reviewed: 0,
68
+ accepted: 0,
69
+ corrected: 0,
70
+ rejected: 0,
71
+ unsourced: [],
72
+ remaining: [],
73
+ complete: false
74
+ };
75
+ for (const field of fields) {
76
+ if (field.value !== void 0 && !isSourced(source, field)) summary.unsourced.push(field.name);
77
+ const decision = decisions[field.name];
78
+ if (!decision) {
79
+ summary.remaining.push(field.name);
80
+ continue;
81
+ }
82
+ summary.reviewed += 1;
83
+ summary[decision.kind] += 1;
84
+ }
85
+ summary.complete = fields.length > 0 && summary.remaining.length === 0;
86
+ return summary;
87
+ }
88
+ //#endregion
89
+ export { clampSpan, evidenceOf, isSourced, segmentSource, summarizeReview };
90
+
91
+ //# sourceMappingURL=extraction-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extraction-model.js","names":[],"sources":["../../../src/components/ai-extraction-review/extraction-model.ts"],"sourcesContent":["/**\n * The model behind a review of extracted fields: where each value was read\n * from, what the reviewer decided about it, and how far through the review\n * they are.\n *\n * Pure, so overlap handling and the completion rule are tested without\n * rendering anything — and so an application can answer \"is this review\n * finished\" on the server from the same decisions the component reports,\n * rather than trusting a flag the client sent.\n */\n\nexport interface SourceSpan {\n /** Offset into the source text in UTF-16 code units. Inclusive. */\n start: number;\n /** Exclusive. */\n end: number;\n}\n\nexport interface ExtractionField {\n /** Key in the extracted object. */\n name: string;\n label: string;\n /**\n * What the model extracted. Absent while streaming means it has not arrived;\n * absent once streaming has ended means the model found nothing.\n */\n value?: string;\n /**\n * Where in the source the value was read from. Absent means the model\n * supplied the value without evidence, which the review says outright.\n */\n span?: SourceSpan;\n /** 0 to 1. Shown as a number, never only as a colour. */\n confidence?: number;\n /** A textarea instead of a single line. For addresses and descriptions. */\n multiline?: boolean;\n}\n\nexport type FieldDecision =\n /** The model's value, taken as it was. */\n | { kind: \"accepted\"; value: string }\n /** The reviewer's value, with the model's kept so a record can tell them apart. */\n | { kind: \"corrected\"; value: string; proposed: string }\n /** Wrong and not corrected — the field does not apply, or cannot be known. */\n | { kind: \"rejected\" };\n\n/** A run of source text and the fields whose evidence covers it. */\nexport interface SourceRun {\n text: string;\n /** Field names, in declaration order. Empty for text nobody cites. */\n fields: string[];\n}\n\n/**\n * A span brought within the source, or null if nothing of it is.\n *\n * Offsets come from a model or an OCR layer and are wrong often enough that\n * refusing to render on a bad one would leave the whole review blank. A span\n * past the end is clamped; an inverted or empty one is treated as no evidence,\n * which is what it is.\n */\nexport function clampSpan(span: SourceSpan, length: number): SourceSpan | null {\n const start = Math.max(0, Math.min(span.start, length));\n const end = Math.max(0, Math.min(span.end, length));\n return end > start ? { start, end } : null;\n}\n\n/** The text a span points at, or an empty string if it points at nothing. */\nexport function evidenceOf(source: string, span: SourceSpan | undefined): string {\n if (!span) return \"\";\n const clamped = clampSpan(span, source.length);\n return clamped ? source.slice(clamped.start, clamped.end) : \"\";\n}\n\n/** Whether a field's value can be checked against the source at all. */\nexport function isSourced(source: string, field: ExtractionField): boolean {\n return field.span !== undefined && clampSpan(field.span, source.length) !== null;\n}\n\n/**\n * Cuts the source into runs at every span boundary, so overlapping evidence —\n * a total that sits inside the line that contains it — renders as nested\n * coverage rather than as two marks fighting over the same characters.\n */\nexport function segmentSource(source: string, fields: ExtractionField[]): SourceRun[] {\n const spans = fields.flatMap((field) => {\n const clamped = field.span ? clampSpan(field.span, source.length) : null;\n return clamped ? [{ name: field.name, ...clamped }] : [];\n });\n\n if (source.length === 0) return [];\n if (spans.length === 0) return [{ text: source, fields: [] }];\n\n const cuts = new Set<number>([0, source.length]);\n for (const span of spans) {\n cuts.add(span.start);\n cuts.add(span.end);\n }\n const points = [...cuts].sort((a, b) => a - b);\n\n const runs: SourceRun[] = [];\n for (let index = 0; index < points.length - 1; index += 1) {\n const start = points[index] ?? 0;\n const end = points[index + 1] ?? start;\n if (end <= start) continue;\n runs.push({\n text: source.slice(start, end),\n fields: spans.filter((span) => span.start <= start && span.end >= end).map((s) => s.name),\n });\n }\n return runs;\n}\n\nexport interface ReviewSummary {\n total: number;\n reviewed: number;\n accepted: number;\n corrected: number;\n rejected: number;\n /** Fields with a value the model could not point to in the source. */\n unsourced: string[];\n /** Fields still awaiting a decision. */\n remaining: string[];\n /** Every field has a decision. The only completion signal worth trusting. */\n complete: boolean;\n}\n\nexport function summarizeReview(\n source: string,\n fields: ExtractionField[],\n decisions: Record<string, FieldDecision> = {},\n): ReviewSummary {\n const summary: ReviewSummary = {\n total: fields.length,\n reviewed: 0,\n accepted: 0,\n corrected: 0,\n rejected: 0,\n unsourced: [],\n remaining: [],\n complete: false,\n };\n\n for (const field of fields) {\n if (field.value !== undefined && !isSourced(source, field)) {\n summary.unsourced.push(field.name);\n }\n const decision = decisions[field.name];\n if (!decision) {\n summary.remaining.push(field.name);\n continue;\n }\n summary.reviewed += 1;\n summary[decision.kind] += 1;\n }\n\n summary.complete = fields.length > 0 && summary.remaining.length === 0;\n return summary;\n}\n"],"mappings":";;;;;;;;;AA6DA,SAAgB,UAAU,MAAkB,QAAmC;CAC7E,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,OAAO,MAAM,CAAC;CACtD,MAAM,MAAM,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC;CAClD,OAAO,MAAM,QAAQ;EAAE;EAAO;CAAI,IAAI;AACxC;;AAGA,SAAgB,WAAW,QAAgB,MAAsC;CAC/E,IAAI,CAAC,MAAM,OAAO;CAClB,MAAM,UAAU,UAAU,MAAM,OAAO,MAAM;CAC7C,OAAO,UAAU,OAAO,MAAM,QAAQ,OAAO,QAAQ,GAAG,IAAI;AAC9D;;AAGA,SAAgB,UAAU,QAAgB,OAAiC;CACzE,OAAO,MAAM,SAAS,KAAA,KAAa,UAAU,MAAM,MAAM,OAAO,MAAM,MAAM;AAC9E;;;;;;AAOA,SAAgB,cAAc,QAAgB,QAAwC;CACpF,MAAM,QAAQ,OAAO,SAAS,UAAU;EACtC,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W,UAAU,MAAM;EACjC,IAAI,CAAC,UAAU;GACb,QAAQ,UAAU,KAAK,MAAM,IAAI;GACjC;EACF;EACA,QAAQ,YAAY;EACpB,QAAQ,SAAS,SAAS;CAC5B;CAEA,QAAQ,WAAW,OAAO,SAAS,KAAK,QAAQ,UAAU,WAAW;CACrE,OAAO;AACT"}
@@ -0,0 +1,3 @@
1
+ import { ExtractionField, FieldDecision, ReviewSummary, SourceRun, SourceSpan, clampSpan, evidenceOf, isSourced, segmentSource, summarizeReview } from "./extraction-model.js";
2
+ import { ExtractionReview, ExtractionReviewProps } from "./ai-extraction-review.js";
3
+ export { type ExtractionField, ExtractionReview, type ExtractionReviewProps, type FieldDecision, type ReviewSummary, type SourceRun, type SourceSpan, clampSpan, evidenceOf, isSourced, segmentSource, summarizeReview };
@@ -0,0 +1,3 @@
1
+ import { clampSpan, evidenceOf, isSourced, segmentSource, summarizeReview } from "./extraction-model.js";
2
+ import { ExtractionReview } from "./ai-extraction-review.js";
3
+ export { ExtractionReview, clampSpan, evidenceOf, isSourced, segmentSource, summarizeReview };
@@ -0,0 +1,17 @@
1
+ import { defineMeta } from "../../registry/schema.js";
2
+ //#region src/components/ai-extraction-review/meta.ts
3
+ const meta = defineMeta({
4
+ name: "ai-extraction-review",
5
+ title: "AI Extraction Review",
6
+ description: "Check extracted fields against the document they came from, and decide each one.",
7
+ category: "ai",
8
+ status: "stable",
9
+ dependencies: [],
10
+ registryDependencies: [],
11
+ files: ["extraction-model.ts", "ai-extraction-review.tsx"],
12
+ a11y: "Every field quotes its evidence in text under the value, so a reviewer who cannot see the highlight in the source still has what the model read. A value with no evidence is said in words — never left to look like a good one. The source is a focusable named region because it scrolls, and its highlights are mark elements with nothing spliced into the text, since a document read aloud with field names inserted is no longer the document. Focus anywhere in a field brings its evidence into view without moving focus, so a keyboard user is shown the source rather than sent into it. Each control's name carries the field it belongs to, so ten Accept buttons are ten different buttons. Status is a word, outside the label so editing never renames the control, and the running count is a polite live region present from the start. Enter accepts, except while an IME is composing."
13
+ });
14
+ //#endregion
15
+ export { meta };
16
+
17
+ //# sourceMappingURL=meta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.js","names":[],"sources":["../../../src/components/ai-extraction-review/meta.ts"],"sourcesContent":["import { defineMeta } from \"@/registry/schema\";\n\nexport const meta = defineMeta({\n name: \"ai-extraction-review\",\n title: \"AI Extraction Review\",\n description:\n \"Check extracted fields against the document they came from, and decide each one.\",\n category: \"ai\",\n status: \"stable\",\n dependencies: [],\n registryDependencies: [],\n files: [\"extraction-model.ts\", \"ai-extraction-review.tsx\"],\n a11y:\n \"Every field quotes its evidence in text under the value, so a reviewer who cannot see the \" +\n \"highlight in the source still has what the model read. A value with no evidence is said in \" +\n \"words — never left to look like a good one. The source is a focusable named region because \" +\n \"it scrolls, and its highlights are mark elements with nothing spliced into the text, since a \" +\n \"document read aloud with field names inserted is no longer the document. Focus anywhere in a \" +\n \"field brings its evidence into view without moving focus, so a keyboard user is shown the \" +\n \"source rather than sent into it. Each control's name carries the field it belongs to, so \" +\n \"ten Accept buttons are ten different buttons. Status is a word, outside the label so editing \" +\n \"never renames the control, and the running count is a polite live region present from the \" +\n \"start. Enter accepts, except while an IME is composing.\",\n});\n"],"mappings":";;AAEA,MAAa,OAAO,WAAW;CAC7B,MAAM;CACN,OAAO;CACP,aACE;CACF,UAAU;CACV,QAAQ;CACR,cAAc,CAAC;CACf,sBAAsB,CAAC;CACvB,OAAO,CAAC,uBAAuB,0BAA0B;CACzD,MACE;AAUJ,CAAC"}