@gemina/elements 0.12.0 → 0.13.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.
- package/dist/chat.cjs +1 -1
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/{chunk-I5APRZ3B.js → chunk-5X7CGCOV.js} +205 -16
- package/dist/chunk-5X7CGCOV.js.map +1 -0
- package/dist/{chunk-Z3OLTR2S.js → chunk-7FT4EJTY.js} +2 -2
- package/dist/{chunk-Z3OLTR2S.js.map → chunk-7FT4EJTY.js.map} +1 -1
- package/dist/{chunk-4HKLI46J.js → chunk-XFE7C6IS.js} +2 -2
- package/dist/index.cjs +204 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/verification.cjs +204 -15
- package/dist/verification.cjs.map +1 -1
- package/dist/verification.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-I5APRZ3B.js.map +0 -1
- /package/dist/{chunk-4HKLI46J.js.map → chunk-XFE7C6IS.js.map} +0 -0
|
@@ -45,7 +45,7 @@ async function readErrorEnvelope(error) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// src/version.ts
|
|
48
|
-
var VERSION = "0.
|
|
48
|
+
var VERSION = "0.13.0";
|
|
49
49
|
|
|
50
50
|
export {
|
|
51
51
|
getResponseLike,
|
|
@@ -53,4 +53,4 @@ export {
|
|
|
53
53
|
readErrorEnvelope,
|
|
54
54
|
VERSION
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=chunk-
|
|
56
|
+
//# sourceMappingURL=chunk-7FT4EJTY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/response-like.ts","../src/version.ts"],"sourcesContent":["/**\n * Shared transport-error helpers for the widgets (chat + verification).\n *\n * Extracted verbatim from chat.tsx so both components read thrown SDK errors\n * the same way. Pure and dependency-free: no React, no DOM.\n */\n\n/**\n * The response-like object carried by a thrown transport error. We pull it off\n * by shape rather than `instanceof ResponseError` — robust against duplicated\n * `@gemina/sdk` copies in a bundle (class identity is not shared across\n * copies). On the fetch transport this is the raw `Response`, so `status`,\n * `headers`, and the JSON body are all reachable from here.\n */\nexport interface ResponseLike {\n status?: number;\n headers?: { get?: (name: string) => string | null };\n json?: () => Promise<unknown>;\n clone?: () => ResponseLike;\n}\n\nexport function getResponseLike(error: unknown): ResponseLike | undefined {\n if (error !== null && typeof error === 'object' && 'response' in error) {\n const response = (error as { response?: unknown }).response;\n if (response !== null && typeof response === 'object') {\n return response as ResponseLike;\n }\n }\n return undefined;\n}\n\n/** Extract an HTTP status from a thrown value, or `undefined`. */\nexport function httpStatus(error: unknown): number | undefined {\n const status = getResponseLike(error)?.status;\n return typeof status === 'number' ? status : undefined;\n}\n\n/** What the standard backend error envelope reliably carries. */\nexport interface ErrorEnvelope {\n status: number | undefined;\n /** Stable backend `errors[0].error_code`. */\n errorCode: string | undefined;\n /** Human-readable server fallback (`errors[0].description`). */\n description: string | undefined;\n}\n\n/**\n * Read what the backend actually sent on an error. Only the HTTP status and\n * the stable `errors[0].error_code` / `description` are reliable across\n * environments — production strips `errors[0].detail`, so we never touch it.\n * The fetch body can be read once, so we clone defensively; if that fails\n * (non-JSON, empty, or already consumed) the status still stands.\n */\nexport async function readErrorEnvelope(error: unknown): Promise<ErrorEnvelope> {\n const response = getResponseLike(error);\n const info: ErrorEnvelope = {\n status: typeof response?.status === 'number' ? response.status : undefined,\n errorCode: undefined,\n description: undefined,\n };\n if (response === undefined) {\n return info;\n }\n\n let body: unknown;\n try {\n const source = typeof response.clone === 'function' ? response.clone() : response;\n body = typeof source.json === 'function' ? await source.json() : undefined;\n } catch {\n body = undefined;\n }\n if (body !== null && typeof body === 'object') {\n const errors = (body as { errors?: unknown }).errors;\n if (\n Array.isArray(errors) &&\n errors.length > 0 &&\n errors[0] !== null &&\n typeof errors[0] === 'object'\n ) {\n const first = errors[0] as { error_code?: unknown; description?: unknown };\n if (typeof first.error_code === 'string') {\n info.errorCode = first.error_code;\n }\n if (typeof first.description === 'string') {\n info.description = first.description;\n }\n }\n }\n return info;\n}\n","/** Package version. Keep in sync with package.json. */\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"sources":["../src/internal/response-like.ts","../src/version.ts"],"sourcesContent":["/**\n * Shared transport-error helpers for the widgets (chat + verification).\n *\n * Extracted verbatim from chat.tsx so both components read thrown SDK errors\n * the same way. Pure and dependency-free: no React, no DOM.\n */\n\n/**\n * The response-like object carried by a thrown transport error. We pull it off\n * by shape rather than `instanceof ResponseError` — robust against duplicated\n * `@gemina/sdk` copies in a bundle (class identity is not shared across\n * copies). On the fetch transport this is the raw `Response`, so `status`,\n * `headers`, and the JSON body are all reachable from here.\n */\nexport interface ResponseLike {\n status?: number;\n headers?: { get?: (name: string) => string | null };\n json?: () => Promise<unknown>;\n clone?: () => ResponseLike;\n}\n\nexport function getResponseLike(error: unknown): ResponseLike | undefined {\n if (error !== null && typeof error === 'object' && 'response' in error) {\n const response = (error as { response?: unknown }).response;\n if (response !== null && typeof response === 'object') {\n return response as ResponseLike;\n }\n }\n return undefined;\n}\n\n/** Extract an HTTP status from a thrown value, or `undefined`. */\nexport function httpStatus(error: unknown): number | undefined {\n const status = getResponseLike(error)?.status;\n return typeof status === 'number' ? status : undefined;\n}\n\n/** What the standard backend error envelope reliably carries. */\nexport interface ErrorEnvelope {\n status: number | undefined;\n /** Stable backend `errors[0].error_code`. */\n errorCode: string | undefined;\n /** Human-readable server fallback (`errors[0].description`). */\n description: string | undefined;\n}\n\n/**\n * Read what the backend actually sent on an error. Only the HTTP status and\n * the stable `errors[0].error_code` / `description` are reliable across\n * environments — production strips `errors[0].detail`, so we never touch it.\n * The fetch body can be read once, so we clone defensively; if that fails\n * (non-JSON, empty, or already consumed) the status still stands.\n */\nexport async function readErrorEnvelope(error: unknown): Promise<ErrorEnvelope> {\n const response = getResponseLike(error);\n const info: ErrorEnvelope = {\n status: typeof response?.status === 'number' ? response.status : undefined,\n errorCode: undefined,\n description: undefined,\n };\n if (response === undefined) {\n return info;\n }\n\n let body: unknown;\n try {\n const source = typeof response.clone === 'function' ? response.clone() : response;\n body = typeof source.json === 'function' ? await source.json() : undefined;\n } catch {\n body = undefined;\n }\n if (body !== null && typeof body === 'object') {\n const errors = (body as { errors?: unknown }).errors;\n if (\n Array.isArray(errors) &&\n errors.length > 0 &&\n errors[0] !== null &&\n typeof errors[0] === 'object'\n ) {\n const first = errors[0] as { error_code?: unknown; description?: unknown };\n if (typeof first.error_code === 'string') {\n info.errorCode = first.error_code;\n }\n if (typeof first.description === 'string') {\n info.description = first.description;\n }\n }\n }\n return info;\n}\n","/** Package version. Keep in sync with package.json. */\nexport const VERSION = '0.13.0';\n"],"mappings":";AAqBO,SAAS,gBAAgB,OAA0C;AACxE,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,cAAc,OAAO;AACtE,UAAM,WAAY,MAAiC;AACnD,QAAI,aAAa,QAAQ,OAAO,aAAa,UAAU;AACrD,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,WAAW,OAAoC;AAC7D,QAAM,SAAS,gBAAgB,KAAK,GAAG;AACvC,SAAO,OAAO,WAAW,WAAW,SAAS;AAC/C;AAkBA,eAAsB,kBAAkB,OAAwC;AAC9E,QAAM,WAAW,gBAAgB,KAAK;AACtC,QAAM,OAAsB;AAAA,IAC1B,QAAQ,OAAO,UAAU,WAAW,WAAW,SAAS,SAAS;AAAA,IACjE,WAAW;AAAA,IACX,aAAa;AAAA,EACf;AACA,MAAI,aAAa,QAAW;AAC1B,WAAO;AAAA,EACT;AAEA,MAAI;AACJ,MAAI;AACF,UAAM,SAAS,OAAO,SAAS,UAAU,aAAa,SAAS,MAAM,IAAI;AACzE,WAAO,OAAO,OAAO,SAAS,aAAa,MAAM,OAAO,KAAK,IAAI;AAAA,EACnE,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,SAAS,QAAQ,OAAO,SAAS,UAAU;AAC7C,UAAM,SAAU,KAA8B;AAC9C,QACE,MAAM,QAAQ,MAAM,KACpB,OAAO,SAAS,KAChB,OAAO,CAAC,MAAM,QACd,OAAO,OAAO,CAAC,MAAM,UACrB;AACA,YAAM,QAAQ,OAAO,CAAC;AACtB,UAAI,OAAO,MAAM,eAAe,UAAU;AACxC,aAAK,YAAY,MAAM;AAAA,MACzB;AACA,UAAI,OAAO,MAAM,gBAAgB,UAAU;AACzC,aAAK,cAAc,MAAM;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ACxFO,IAAM,UAAU;","names":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getResponseLike,
|
|
4
4
|
httpStatus,
|
|
5
5
|
readErrorEnvelope
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7FT4EJTY.js";
|
|
7
7
|
|
|
8
8
|
// src/chat.tsx
|
|
9
9
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -656,4 +656,4 @@ function GeminaChat(props) {
|
|
|
656
656
|
export {
|
|
657
657
|
GeminaChat
|
|
658
658
|
};
|
|
659
|
-
//# sourceMappingURL=chunk-
|
|
659
|
+
//# sourceMappingURL=chunk-XFE7C6IS.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -221,7 +221,7 @@ async function readErrorEnvelope(error) {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
// src/version.ts
|
|
224
|
-
var VERSION = "0.
|
|
224
|
+
var VERSION = "0.13.0";
|
|
225
225
|
|
|
226
226
|
// src/chat.tsx
|
|
227
227
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -1695,6 +1695,98 @@ function pruneEmptyAddedRows(plannedTables, edits) {
|
|
|
1695
1695
|
// src/verification/form.tsx
|
|
1696
1696
|
var import_react4 = __toESM(require("react"), 1);
|
|
1697
1697
|
|
|
1698
|
+
// src/verification/review-filter.ts
|
|
1699
|
+
function isHighConfidence(confidence) {
|
|
1700
|
+
return (confidence?.level ?? "").toLowerCase() === "high";
|
|
1701
|
+
}
|
|
1702
|
+
var NOTHING_HIDDEN = {
|
|
1703
|
+
fields: /* @__PURE__ */ new Set(),
|
|
1704
|
+
rows: /* @__PURE__ */ new Set()
|
|
1705
|
+
};
|
|
1706
|
+
var unplannedRowKey = (tablePointer, index) => `${tablePointer}/${index}`;
|
|
1707
|
+
function computeHidden(input) {
|
|
1708
|
+
const { classified, plannedTables, cellViews, bindingIndex, edits, pairErrors, suppressed } = input;
|
|
1709
|
+
const fields = /* @__PURE__ */ new Set();
|
|
1710
|
+
const rows = /* @__PURE__ */ new Set();
|
|
1711
|
+
const touched = (editKey) => editKey !== void 0 && (edits.has(editKey) || pairErrors.has(editKey));
|
|
1712
|
+
const editKeysByRow = /* @__PURE__ */ new Map();
|
|
1713
|
+
for (const view of cellViews) {
|
|
1714
|
+
const list = editKeysByRow.get(view.rowKey);
|
|
1715
|
+
if (list) list.push(view.editKey);
|
|
1716
|
+
else editKeysByRow.set(view.rowKey, [view.editKey]);
|
|
1717
|
+
}
|
|
1718
|
+
const considerField = (pointer, confidence) => {
|
|
1719
|
+
if (suppressed.has(pointer)) return;
|
|
1720
|
+
if (!isHighConfidence(confidence)) return;
|
|
1721
|
+
const editKey = bindingIndex.get(pointer)?.key.raw;
|
|
1722
|
+
if (editKey === void 0 || touched(editKey)) return;
|
|
1723
|
+
fields.add(pointer);
|
|
1724
|
+
};
|
|
1725
|
+
for (const header of classified.headers) {
|
|
1726
|
+
considerField(header.pointer, header.confidence);
|
|
1727
|
+
}
|
|
1728
|
+
for (const list of classified.simpleLists) {
|
|
1729
|
+
for (const item of list.items) considerField(item.pointer, item.confidence);
|
|
1730
|
+
}
|
|
1731
|
+
for (const entity of classified.entities) {
|
|
1732
|
+
for (const item of entity.items) {
|
|
1733
|
+
for (const entityCell of Object.values(item)) considerField(entityCell.pointer, entityCell.confidence);
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
const rowConfidence = (row) => {
|
|
1737
|
+
const meta = row?.[ROW_META_KEY];
|
|
1738
|
+
return meta?.confidence ?? null;
|
|
1739
|
+
};
|
|
1740
|
+
const rowIsHidable = (rowKey) => !(editKeysByRow.get(rowKey) ?? []).some((editKey) => touched(editKey));
|
|
1741
|
+
for (const table of classified.tables) {
|
|
1742
|
+
const planned = plannedTables.get(table.pointer);
|
|
1743
|
+
if (planned) {
|
|
1744
|
+
for (const plannedRow of planned) {
|
|
1745
|
+
if (plannedRow.entry.source === null) continue;
|
|
1746
|
+
if (!isHighConfidence(rowConfidence(table.rows[plannedRow.entry.source]))) continue;
|
|
1747
|
+
if (!rowIsHidable(plannedRow.entry.id)) continue;
|
|
1748
|
+
rows.add(plannedRow.entry.id);
|
|
1749
|
+
}
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
table.rows.forEach((row, index) => {
|
|
1753
|
+
if (!isHighConfidence(rowConfidence(row))) return;
|
|
1754
|
+
const key = unplannedRowKey(table.pointer, index);
|
|
1755
|
+
if (!rowIsHidable(key)) return;
|
|
1756
|
+
rows.add(key);
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
if (fields.size === 0 && rows.size === 0) return NOTHING_HIDDEN;
|
|
1760
|
+
return { fields, rows };
|
|
1761
|
+
}
|
|
1762
|
+
function countUnits(classified, plannedTables, suppressed) {
|
|
1763
|
+
let total = 0;
|
|
1764
|
+
total += classified.headers.filter((header) => !suppressed.has(header.pointer)).length;
|
|
1765
|
+
for (const list of classified.simpleLists) {
|
|
1766
|
+
total += list.items.filter((item) => !suppressed.has(item.pointer)).length;
|
|
1767
|
+
}
|
|
1768
|
+
for (const entity of classified.entities) {
|
|
1769
|
+
for (const item of entity.items) {
|
|
1770
|
+
total += Object.values(item).filter((entityCell) => !suppressed.has(entityCell.pointer)).length;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
for (const table of classified.tables) {
|
|
1774
|
+
total += plannedTables.get(table.pointer)?.length ?? table.rows.length;
|
|
1775
|
+
}
|
|
1776
|
+
return total;
|
|
1777
|
+
}
|
|
1778
|
+
function hasAnyConfidence(classified) {
|
|
1779
|
+
if (classified.headers.some((header) => header.confidence?.level)) return true;
|
|
1780
|
+
if (classified.simpleLists.some((list) => list.items.some((item) => item.confidence?.level))) return true;
|
|
1781
|
+
if (classified.entities.some((entity) => entity.items.some(
|
|
1782
|
+
(item) => Object.values(item).some((entityCell) => entityCell.confidence?.level)
|
|
1783
|
+
))) return true;
|
|
1784
|
+
return classified.tables.some((table) => table.rows.some((row) => {
|
|
1785
|
+
const meta = row[ROW_META_KEY];
|
|
1786
|
+
return Boolean(meta?.confidence?.level);
|
|
1787
|
+
}));
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1698
1790
|
// src/verification/tip.tsx
|
|
1699
1791
|
var import_react2 = require("react");
|
|
1700
1792
|
var import_react_dom = require("react-dom");
|
|
@@ -2708,13 +2800,15 @@ function FieldPair(props) {
|
|
|
2708
2800
|
}
|
|
2709
2801
|
function HeaderSection(props) {
|
|
2710
2802
|
const { headers, simpleLists, shared } = props;
|
|
2711
|
-
|
|
2803
|
+
const visibleHeaders = headers.filter((field) => !shared.hidden.fields.has(field.pointer));
|
|
2804
|
+
const visibleLists = simpleLists.map((list) => ({ ...list, items: list.items.filter((item) => !shared.hidden.fields.has(item.pointer)) })).filter((list) => list.items.length > 0);
|
|
2805
|
+
if (visibleHeaders.length === 0 && visibleLists.length === 0) {
|
|
2712
2806
|
return null;
|
|
2713
2807
|
}
|
|
2714
2808
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Details", children: [
|
|
2715
2809
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-header", children: "Details" }),
|
|
2716
2810
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("dl", { className: "gemina-verification__dl", children: [
|
|
2717
|
-
|
|
2811
|
+
visibleHeaders.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2718
2812
|
FieldPair,
|
|
2719
2813
|
{
|
|
2720
2814
|
label: formatLabel(field.key),
|
|
@@ -2724,7 +2818,7 @@ function HeaderSection(props) {
|
|
|
2724
2818
|
},
|
|
2725
2819
|
field.pointer
|
|
2726
2820
|
)),
|
|
2727
|
-
|
|
2821
|
+
visibleLists.map((list) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.default.Fragment, { children: [
|
|
2728
2822
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: formatLabel(list.key) }) }),
|
|
2729
2823
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "gemina-verification__list", children: list.items.map((item, index) => {
|
|
2730
2824
|
const binding = shared.bindingIndex.get(item.pointer);
|
|
@@ -2760,16 +2854,19 @@ function HeaderSection(props) {
|
|
|
2760
2854
|
}
|
|
2761
2855
|
function EntitySection(props) {
|
|
2762
2856
|
const { entity, shared } = props;
|
|
2857
|
+
const visibleItems = entity.items.map((item) => Object.fromEntries(
|
|
2858
|
+
Object.entries(item).filter(([, cellValue]) => !shared.hidden.fields.has(cellValue.pointer))
|
|
2859
|
+
)).filter((item) => Object.keys(item).length > 0);
|
|
2763
2860
|
const label = formatLabel(entity.key);
|
|
2764
2861
|
const singular = label.replace(/s$/, "");
|
|
2765
2862
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
2766
2863
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
2767
2864
|
label,
|
|
2768
2865
|
" (",
|
|
2769
|
-
|
|
2866
|
+
visibleItems.length,
|
|
2770
2867
|
")"
|
|
2771
2868
|
] }),
|
|
2772
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-body", children:
|
|
2869
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__section-body", children: visibleItems.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__card", children: [
|
|
2773
2870
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__card-header", children: [
|
|
2774
2871
|
singular,
|
|
2775
2872
|
" ",
|
|
@@ -2824,7 +2921,7 @@ function TableRowView(props) {
|
|
|
2824
2921
|
return { classified, binding, editKey: binding?.key.raw };
|
|
2825
2922
|
};
|
|
2826
2923
|
const firstRect = rects.length > 0 ? rects[0] : null;
|
|
2827
|
-
const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly;
|
|
2924
|
+
const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly && !shared.filterOn;
|
|
2828
2925
|
const rowLevel = (row?.[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
2829
2926
|
const rowClass = rowLevel === "low" || rowLevel === "medium" ? `gemina-verification__row--${rowLevel}` : void 0;
|
|
2830
2927
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { onClick: handleRowClick, className: rowClass, children: [
|
|
@@ -2873,7 +2970,7 @@ function TableRowView(props) {
|
|
|
2873
2970
|
] });
|
|
2874
2971
|
}
|
|
2875
2972
|
function areRowPropsEqual(prev, next) {
|
|
2876
|
-
if (prev.row !== next.row || prev.rowIndex !== next.rowIndex || prev.columns !== next.columns || prev.tableLabel !== next.tableLabel || prev.hasCoords !== next.hasCoords || prev.hasRowConfidence !== next.hasRowConfidence || prev.planned !== next.planned || prev.tablePointer !== next.tablePointer || prev.shared.bindingIndex !== next.shared.bindingIndex || prev.shared.onEdit !== next.shared.onEdit || prev.shared.onFlash !== next.shared.onFlash || prev.shared.readOnly !== next.shared.readOnly) {
|
|
2973
|
+
if (prev.row !== next.row || prev.rowIndex !== next.rowIndex || prev.columns !== next.columns || prev.tableLabel !== next.tableLabel || prev.hasCoords !== next.hasCoords || prev.hasRowConfidence !== next.hasRowConfidence || prev.planned !== next.planned || prev.tablePointer !== next.tablePointer || prev.shared.bindingIndex !== next.shared.bindingIndex || prev.shared.onEdit !== next.shared.onEdit || prev.shared.onFlash !== next.shared.onFlash || prev.shared.readOnly !== next.shared.readOnly || prev.shared.filterOn !== next.shared.filterOn) {
|
|
2877
2974
|
return false;
|
|
2878
2975
|
}
|
|
2879
2976
|
if (prev.shared.edits === next.shared.edits) {
|
|
@@ -2961,7 +3058,11 @@ function TableSection(props) {
|
|
|
2961
3058
|
}).length,
|
|
2962
3059
|
[table.rows]
|
|
2963
3060
|
);
|
|
2964
|
-
const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly;
|
|
3061
|
+
const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly && !shared.filterOn;
|
|
3062
|
+
const visiblePlanned = planned?.map((plannedRow, position) => ({ plannedRow, position })).filter(({ plannedRow }) => !shared.hidden.rows.has(plannedRow.entry.id));
|
|
3063
|
+
const visibleRowIndices = planned ? null : table.rows.map((_row, index) => index).filter((index) => !shared.hidden.rows.has(unplannedRowKey(table.pointer, index)));
|
|
3064
|
+
const visibleCount = visiblePlanned ? visiblePlanned.length : visibleRowIndices.length;
|
|
3065
|
+
const allHidden = visibleCount === 0 && rowCount > 0;
|
|
2965
3066
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
2966
3067
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
2967
3068
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
@@ -2977,7 +3078,11 @@ function TableSection(props) {
|
|
|
2977
3078
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
|
|
2978
3079
|
] }) : null
|
|
2979
3080
|
] }),
|
|
2980
|
-
|
|
3081
|
+
allHidden ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "gemina-verification__all-scored", children: [
|
|
3082
|
+
"All ",
|
|
3083
|
+
rowCount,
|
|
3084
|
+
" rows scored high"
|
|
3085
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("table", { className: "gemina-verification__table", children: [
|
|
2981
3086
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { children: [
|
|
2982
3087
|
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Show row on document" }) : null,
|
|
2983
3088
|
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row confidence" }) : null,
|
|
@@ -2990,7 +3095,7 @@ function TableSection(props) {
|
|
|
2990
3095
|
) }, column)),
|
|
2991
3096
|
showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row actions" }) : null
|
|
2992
3097
|
] }) }),
|
|
2993
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("tbody", { children:
|
|
3098
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("tbody", { children: visiblePlanned ? visiblePlanned.map(({ plannedRow, position }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2994
3099
|
TableRow,
|
|
2995
3100
|
{
|
|
2996
3101
|
row: plannedRow.entry.source === null ? void 0 : table.rows[plannedRow.entry.source],
|
|
@@ -3004,10 +3109,10 @@ function TableSection(props) {
|
|
|
3004
3109
|
tablePointer: mutable.pointer
|
|
3005
3110
|
},
|
|
3006
3111
|
plannedRow.entry.id
|
|
3007
|
-
)) :
|
|
3112
|
+
)) : visibleRowIndices.map((rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3008
3113
|
TableRow,
|
|
3009
3114
|
{
|
|
3010
|
-
row,
|
|
3115
|
+
row: table.rows[rowIndex],
|
|
3011
3116
|
rowIndex,
|
|
3012
3117
|
columns,
|
|
3013
3118
|
tableLabel: label,
|
|
@@ -3078,7 +3183,9 @@ function VerificationForm(props) {
|
|
|
3078
3183
|
rowMutableTables,
|
|
3079
3184
|
plannedTables,
|
|
3080
3185
|
onAddRow,
|
|
3081
|
-
onRemoveRow
|
|
3186
|
+
onRemoveRow,
|
|
3187
|
+
hidden,
|
|
3188
|
+
filterOn
|
|
3082
3189
|
} = props;
|
|
3083
3190
|
const { tables: promotedTables, suppressed } = import_react4.default.useMemo(
|
|
3084
3191
|
() => withEmptyMutableTables(classified, rowMutableTables ?? NO_TABLES),
|
|
@@ -3094,7 +3201,9 @@ function VerificationForm(props) {
|
|
|
3094
3201
|
rowMutableTables: rowMutableTables ?? NO_TABLES,
|
|
3095
3202
|
plannedTables: plannedTables ?? NO_PLANNED,
|
|
3096
3203
|
onAddRow: onAddRow ?? NOOP_ROW,
|
|
3097
|
-
onRemoveRow: onRemoveRow ?? NOOP_ROW
|
|
3204
|
+
onRemoveRow: onRemoveRow ?? NOOP_ROW,
|
|
3205
|
+
hidden: hidden ?? NOTHING_HIDDEN,
|
|
3206
|
+
filterOn: filterOn ?? false
|
|
3098
3207
|
};
|
|
3099
3208
|
return (
|
|
3100
3209
|
// A real, labeled <form> (role "form" landmark): AT users can jump
|
|
@@ -3662,6 +3771,11 @@ var VERIFICATION_CSS = `
|
|
|
3662
3771
|
}
|
|
3663
3772
|
.gemina-verification__footer {
|
|
3664
3773
|
display: flex;
|
|
3774
|
+
/* Wraps because the review filter adds two more items to this row, and at
|
|
3775
|
+
320 the four together overflow: Submit was pushed 28px past the inline
|
|
3776
|
+
start and clipped. Measured RTL, where the overflow runs the other way
|
|
3777
|
+
and a scrollWidth-minus-clientWidth check on the document never sees it. */
|
|
3778
|
+
flex-wrap: wrap;
|
|
3665
3779
|
align-items: center;
|
|
3666
3780
|
gap: 10px;
|
|
3667
3781
|
padding-block-start: 12px;
|
|
@@ -3678,6 +3792,41 @@ var VERIFICATION_CSS = `
|
|
|
3678
3792
|
cursor: pointer;
|
|
3679
3793
|
}
|
|
3680
3794
|
.gemina-verification__submit:disabled { opacity: 0.5; cursor: default; }
|
|
3795
|
+
/* The review filter is a VIEW MODE, not an action, so it stays quiet: an
|
|
3796
|
+
outline control in the muted color, next to the one loud thing in the
|
|
3797
|
+
footer. Turning it on fills it from the same accent token \u2014 the state has
|
|
3798
|
+
to be unmistakable, because the form is hiding content while it is on. */
|
|
3799
|
+
.gemina-verification__review-filter {
|
|
3800
|
+
font: inherit;
|
|
3801
|
+
font-size: 12px;
|
|
3802
|
+
padding: 4px 12px;
|
|
3803
|
+
border-radius: var(--gemina-verification-radius);
|
|
3804
|
+
border: 1px solid var(--gemina-verification-border);
|
|
3805
|
+
background: transparent;
|
|
3806
|
+
color: var(--gemina-verification-muted);
|
|
3807
|
+
cursor: pointer;
|
|
3808
|
+
}
|
|
3809
|
+
.gemina-verification__review-filter:hover {
|
|
3810
|
+
color: var(--gemina-verification-accent);
|
|
3811
|
+
border-color: var(--gemina-verification-accent);
|
|
3812
|
+
}
|
|
3813
|
+
.gemina-verification__review-filter[aria-checked='true'] {
|
|
3814
|
+
background: var(--gemina-verification-accent);
|
|
3815
|
+
border-color: var(--gemina-verification-accent);
|
|
3816
|
+
color: var(--gemina-verification-accent-fg);
|
|
3817
|
+
}
|
|
3818
|
+
/* Stands in for a table's grid when every row of it scored high. Muted and
|
|
3819
|
+
unemphatic on purpose \u2014 it reports an absence, it is not a finding. */
|
|
3820
|
+
.gemina-verification__filter-count {
|
|
3821
|
+
font-size: 12px;
|
|
3822
|
+
color: var(--gemina-verification-muted);
|
|
3823
|
+
}
|
|
3824
|
+
.gemina-verification__all-scored {
|
|
3825
|
+
margin: 0;
|
|
3826
|
+
padding: 12px;
|
|
3827
|
+
color: var(--gemina-verification-muted);
|
|
3828
|
+
font-size: 13px;
|
|
3829
|
+
}
|
|
3681
3830
|
.gemina-verification__retry {
|
|
3682
3831
|
font: inherit;
|
|
3683
3832
|
font-size: 12px;
|
|
@@ -4035,6 +4184,7 @@ function GeminaVerification(props) {
|
|
|
4035
4184
|
const [imageUrl, setImageUrl] = (0, import_react5.useState)(null);
|
|
4036
4185
|
const [flashRects, setFlashRects] = (0, import_react5.useState)(null);
|
|
4037
4186
|
const [stacked, setStacked] = (0, import_react5.useState)(false);
|
|
4187
|
+
const [filterOn, setFilterOn] = (0, import_react5.useState)(false);
|
|
4038
4188
|
const rootRef = (0, import_react5.useRef)(null);
|
|
4039
4189
|
const mountedRef = (0, import_react5.useRef)(false);
|
|
4040
4190
|
const loadSeqRef = (0, import_react5.useRef)(0);
|
|
@@ -4111,6 +4261,7 @@ function GeminaVerification(props) {
|
|
|
4111
4261
|
rowMutableTables: readRowMutableTables(view.meta.validationFeedback?.rowMutableTables)
|
|
4112
4262
|
});
|
|
4113
4263
|
setEdits(NO_EDITS);
|
|
4264
|
+
setFilterOn(false);
|
|
4114
4265
|
setRowPlans(seedRowPlans(readRowMutableTables(view.meta.validationFeedback?.rowMutableTables), view.values));
|
|
4115
4266
|
const url = view.document.imageUrl;
|
|
4116
4267
|
setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
|
|
@@ -4362,6 +4513,28 @@ function GeminaVerification(props) {
|
|
|
4362
4513
|
});
|
|
4363
4514
|
}, []);
|
|
4364
4515
|
const pairErrors = (0, import_react5.useMemo)(() => unitSizePairErrors(cellViews, edits), [cellViews, edits]);
|
|
4516
|
+
const suppressed = (0, import_react5.useMemo)(
|
|
4517
|
+
() => withEmptyMutableTables(classified, loaded?.rowMutableTables ?? []).suppressed,
|
|
4518
|
+
[classified, loaded?.rowMutableTables]
|
|
4519
|
+
);
|
|
4520
|
+
const canFilter = (0, import_react5.useMemo)(() => hasAnyConfidence(classified), [classified]);
|
|
4521
|
+
const hidden = (0, import_react5.useMemo)(
|
|
4522
|
+
() => filterOn && canFilter ? computeHidden({
|
|
4523
|
+
classified,
|
|
4524
|
+
plannedTables,
|
|
4525
|
+
cellViews,
|
|
4526
|
+
bindingIndex,
|
|
4527
|
+
edits,
|
|
4528
|
+
pairErrors,
|
|
4529
|
+
suppressed
|
|
4530
|
+
}) : NOTHING_HIDDEN,
|
|
4531
|
+
[filterOn, canFilter, classified, plannedTables, cellViews, bindingIndex, edits, pairErrors, suppressed]
|
|
4532
|
+
);
|
|
4533
|
+
const totalUnits = (0, import_react5.useMemo)(
|
|
4534
|
+
() => countUnits(classified, plannedTables, suppressed) + unmatched.length,
|
|
4535
|
+
[classified, plannedTables, suppressed, unmatched]
|
|
4536
|
+
);
|
|
4537
|
+
const visibleUnits = totalUnits - hidden.fields.size - hidden.rows.size;
|
|
4365
4538
|
const invalidCount = (0, import_react5.useMemo)(() => {
|
|
4366
4539
|
const rowLevel = pairErrors.size;
|
|
4367
4540
|
if (edits.size === 0) {
|
|
@@ -4534,6 +4707,8 @@ function GeminaVerification(props) {
|
|
|
4534
4707
|
onFlash: handleFlash,
|
|
4535
4708
|
pairErrors,
|
|
4536
4709
|
rowMutableTables: loaded?.rowMutableTables,
|
|
4710
|
+
hidden,
|
|
4711
|
+
filterOn,
|
|
4537
4712
|
plannedTables,
|
|
4538
4713
|
onAddRow: handleAddRow,
|
|
4539
4714
|
onRemoveRow: handleRemoveRow
|
|
@@ -4562,6 +4737,20 @@ function GeminaVerification(props) {
|
|
|
4562
4737
|
),
|
|
4563
4738
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "gemina-verification__footer", children: [
|
|
4564
4739
|
!alreadyValidated && (invalidCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__attention", "aria-live": "polite", children: invalidCount === 1 ? "1 field needs attention" : `${invalidCount} fields need attention` }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "gemina-verification__progress", "aria-live": "polite", children: `${submission.confirmed} confirmed \xB7 ${submission.corrected} corrected` })),
|
|
4740
|
+
canFilter && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
4741
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4742
|
+
"button",
|
|
4743
|
+
{
|
|
4744
|
+
type: "button",
|
|
4745
|
+
role: "switch",
|
|
4746
|
+
"aria-checked": filterOn,
|
|
4747
|
+
className: "gemina-verification__review-filter",
|
|
4748
|
+
onClick: () => setFilterOn((on) => !on),
|
|
4749
|
+
children: "Hide high-confidence fields"
|
|
4750
|
+
}
|
|
4751
|
+
),
|
|
4752
|
+
filterOn && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "gemina-verification__filter-count", "aria-live": "polite", children: `Showing ${visibleUnits} of ${totalUnits}` })
|
|
4753
|
+
] }),
|
|
4565
4754
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
4566
4755
|
"button",
|
|
4567
4756
|
{
|