@gemina/elements 0.12.0 → 0.13.1
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-4HKLI46J.js → chunk-6KHHCUSJ.js} +2 -2
- package/dist/{chunk-I5APRZ3B.js → chunk-A5PZTHDE.js} +218 -22
- package/dist/chunk-A5PZTHDE.js.map +1 -0
- package/dist/{chunk-Z3OLTR2S.js → chunk-X5TSIIUP.js} +2 -2
- package/dist/{chunk-Z3OLTR2S.js.map → chunk-X5TSIIUP.js.map} +1 -1
- package/dist/index.cjs +217 -21
- 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 +217 -21
- 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-6KHHCUSJ.js.map} +0 -0
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
} from "./chunk-CUOHJGPN.js";
|
|
4
4
|
import {
|
|
5
5
|
GeminaChat
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6KHHCUSJ.js";
|
|
7
7
|
import {
|
|
8
8
|
GeminaVerification
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-A5PZTHDE.js";
|
|
10
10
|
import {
|
|
11
11
|
VERSION
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-X5TSIIUP.js";
|
|
13
13
|
export {
|
|
14
14
|
GeminaChat,
|
|
15
15
|
GeminaTokenManager,
|
package/dist/verification.cjs
CHANGED
|
@@ -904,6 +904,101 @@ function pruneEmptyAddedRows(plannedTables, edits) {
|
|
|
904
904
|
// src/verification/form.tsx
|
|
905
905
|
var import_react3 = __toESM(require("react"), 1);
|
|
906
906
|
|
|
907
|
+
// src/verification/review-filter.ts
|
|
908
|
+
function isHighConfidence(confidence) {
|
|
909
|
+
return (confidence?.level ?? "").toLowerCase() === "high";
|
|
910
|
+
}
|
|
911
|
+
var NOTHING_HIDDEN = {
|
|
912
|
+
fields: /* @__PURE__ */ new Set(),
|
|
913
|
+
rows: /* @__PURE__ */ new Set()
|
|
914
|
+
};
|
|
915
|
+
var unplannedRowKey = (tablePointer, index) => `${tablePointer}/${index}`;
|
|
916
|
+
function forEachFieldUnit(classified, visit) {
|
|
917
|
+
for (const header of classified.headers) visit(header.pointer, header.confidence);
|
|
918
|
+
for (const list of classified.simpleLists) {
|
|
919
|
+
for (const item of list.items) visit(item.pointer, item.confidence);
|
|
920
|
+
}
|
|
921
|
+
for (const entity of classified.entities) {
|
|
922
|
+
for (const item of entity.items) {
|
|
923
|
+
for (const cell of Object.values(item)) visit(cell.pointer, cell.confidence);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
function forEachRowUnit(tables, plannedTables, visit) {
|
|
928
|
+
const confidenceOf = (row) => {
|
|
929
|
+
const meta = row?.[ROW_META_KEY];
|
|
930
|
+
return meta?.confidence ?? null;
|
|
931
|
+
};
|
|
932
|
+
for (const table of tables) {
|
|
933
|
+
const planned = plannedTables.get(table.pointer);
|
|
934
|
+
if (planned) {
|
|
935
|
+
for (const row of planned) {
|
|
936
|
+
const { source } = row.entry;
|
|
937
|
+
visit(row.entry.id, source === null ? null : confidenceOf(table.rows[source]), source === null);
|
|
938
|
+
}
|
|
939
|
+
continue;
|
|
940
|
+
}
|
|
941
|
+
table.rows.forEach((row, index) => {
|
|
942
|
+
visit(unplannedRowKey(table.pointer, index), confidenceOf(row), false);
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
function computeHidden(input) {
|
|
947
|
+
const {
|
|
948
|
+
classified,
|
|
949
|
+
tables,
|
|
950
|
+
plannedTables,
|
|
951
|
+
cellViews,
|
|
952
|
+
bindingIndex,
|
|
953
|
+
edits,
|
|
954
|
+
pairErrors,
|
|
955
|
+
suppressed
|
|
956
|
+
} = input;
|
|
957
|
+
const fields = /* @__PURE__ */ new Set();
|
|
958
|
+
const rows = /* @__PURE__ */ new Set();
|
|
959
|
+
const touched = (editKey) => edits.has(editKey) || pairErrors.has(editKey);
|
|
960
|
+
const editKeysByRow = /* @__PURE__ */ new Map();
|
|
961
|
+
for (const view of cellViews) {
|
|
962
|
+
const list = editKeysByRow.get(view.rowKey);
|
|
963
|
+
if (list) list.push(view.editKey);
|
|
964
|
+
else editKeysByRow.set(view.rowKey, [view.editKey]);
|
|
965
|
+
}
|
|
966
|
+
forEachFieldUnit(classified, (pointer, confidence) => {
|
|
967
|
+
if (suppressed.has(pointer) || !isHighConfidence(confidence)) return;
|
|
968
|
+
const editKey = bindingIndex.get(pointer)?.key.raw;
|
|
969
|
+
if (editKey === void 0 || touched(editKey)) return;
|
|
970
|
+
fields.add(pointer);
|
|
971
|
+
});
|
|
972
|
+
forEachRowUnit(tables, plannedTables, (rowKey, confidence, added) => {
|
|
973
|
+
if (added || !isHighConfidence(confidence)) return;
|
|
974
|
+
if ((editKeysByRow.get(rowKey) ?? []).some(touched)) return;
|
|
975
|
+
rows.add(rowKey);
|
|
976
|
+
});
|
|
977
|
+
if (fields.size === 0 && rows.size === 0) return NOTHING_HIDDEN;
|
|
978
|
+
return { fields, rows };
|
|
979
|
+
}
|
|
980
|
+
function countUnits(classified, tables, plannedTables, suppressed) {
|
|
981
|
+
let total = 0;
|
|
982
|
+
forEachFieldUnit(classified, (pointer) => {
|
|
983
|
+
if (!suppressed.has(pointer)) total += 1;
|
|
984
|
+
});
|
|
985
|
+
forEachRowUnit(tables, plannedTables, () => {
|
|
986
|
+
total += 1;
|
|
987
|
+
});
|
|
988
|
+
return total;
|
|
989
|
+
}
|
|
990
|
+
function hasAnyConfidence(classified, tables, plannedTables) {
|
|
991
|
+
let found = false;
|
|
992
|
+
forEachFieldUnit(classified, (_pointer, confidence) => {
|
|
993
|
+
if (confidence?.level) found = true;
|
|
994
|
+
});
|
|
995
|
+
if (found) return true;
|
|
996
|
+
forEachRowUnit(tables, plannedTables, (_rowKey, confidence) => {
|
|
997
|
+
if (confidence?.level) found = true;
|
|
998
|
+
});
|
|
999
|
+
return found;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
907
1002
|
// src/verification/tip.tsx
|
|
908
1003
|
var import_react = require("react");
|
|
909
1004
|
var import_react_dom = require("react-dom");
|
|
@@ -1917,13 +2012,15 @@ function FieldPair(props) {
|
|
|
1917
2012
|
}
|
|
1918
2013
|
function HeaderSection(props) {
|
|
1919
2014
|
const { headers, simpleLists, shared } = props;
|
|
1920
|
-
|
|
2015
|
+
const visibleHeaders = headers.filter((field) => !shared.hidden.fields.has(field.pointer));
|
|
2016
|
+
const visibleLists = simpleLists.map((list) => ({ ...list, items: list.items.filter((item) => !shared.hidden.fields.has(item.pointer)) })).filter((list) => list.items.length > 0);
|
|
2017
|
+
if (visibleHeaders.length === 0 && visibleLists.length === 0) {
|
|
1921
2018
|
return null;
|
|
1922
2019
|
}
|
|
1923
2020
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": "Details", children: [
|
|
1924
2021
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-header", children: "Details" }),
|
|
1925
2022
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dl", { className: "gemina-verification__dl", children: [
|
|
1926
|
-
|
|
2023
|
+
visibleHeaders.map((field) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1927
2024
|
FieldPair,
|
|
1928
2025
|
{
|
|
1929
2026
|
label: formatLabel(field.key),
|
|
@@ -1933,7 +2030,7 @@ function HeaderSection(props) {
|
|
|
1933
2030
|
},
|
|
1934
2031
|
field.pointer
|
|
1935
2032
|
)),
|
|
1936
|
-
|
|
2033
|
+
visibleLists.map((list) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react3.default.Fragment, { children: [
|
|
1937
2034
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { className: "gemina-verification__dt", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: formatLabel(list.key) }) }),
|
|
1938
2035
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { className: "gemina-verification__dd", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "gemina-verification__list", children: list.items.map((item, index) => {
|
|
1939
2036
|
const binding = shared.bindingIndex.get(item.pointer);
|
|
@@ -1969,16 +2066,19 @@ function HeaderSection(props) {
|
|
|
1969
2066
|
}
|
|
1970
2067
|
function EntitySection(props) {
|
|
1971
2068
|
const { entity, shared } = props;
|
|
2069
|
+
const visibleItems = entity.items.map((item) => Object.fromEntries(
|
|
2070
|
+
Object.entries(item).filter(([, cellValue]) => !shared.hidden.fields.has(cellValue.pointer))
|
|
2071
|
+
)).filter((item) => Object.keys(item).length > 0);
|
|
1972
2072
|
const label = formatLabel(entity.key);
|
|
1973
2073
|
const singular = label.replace(/s$/, "");
|
|
1974
2074
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
1975
2075
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
1976
2076
|
label,
|
|
1977
2077
|
" (",
|
|
1978
|
-
|
|
2078
|
+
visibleItems.length,
|
|
1979
2079
|
")"
|
|
1980
2080
|
] }),
|
|
1981
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-body", children:
|
|
2081
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__section-body", children: visibleItems.map((item, itemIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__card", children: [
|
|
1982
2082
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__card-header", children: [
|
|
1983
2083
|
singular,
|
|
1984
2084
|
" ",
|
|
@@ -2033,7 +2133,7 @@ function TableRowView(props) {
|
|
|
2033
2133
|
return { classified, binding, editKey: binding?.key.raw };
|
|
2034
2134
|
};
|
|
2035
2135
|
const firstRect = rects.length > 0 ? rects[0] : null;
|
|
2036
|
-
const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly;
|
|
2136
|
+
const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly && !shared.filterOn;
|
|
2037
2137
|
const rowLevel = (row?.[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
2038
2138
|
const rowClass = rowLevel === "low" || rowLevel === "medium" ? `gemina-verification__row--${rowLevel}` : void 0;
|
|
2039
2139
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { onClick: handleRowClick, className: rowClass, children: [
|
|
@@ -2082,7 +2182,7 @@ function TableRowView(props) {
|
|
|
2082
2182
|
] });
|
|
2083
2183
|
}
|
|
2084
2184
|
function areRowPropsEqual(prev, next) {
|
|
2085
|
-
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) {
|
|
2185
|
+
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) {
|
|
2086
2186
|
return false;
|
|
2087
2187
|
}
|
|
2088
2188
|
if (prev.shared.edits === next.shared.edits) {
|
|
@@ -2170,7 +2270,11 @@ function TableSection(props) {
|
|
|
2170
2270
|
}).length,
|
|
2171
2271
|
[table.rows]
|
|
2172
2272
|
);
|
|
2173
|
-
const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly;
|
|
2273
|
+
const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly && !shared.filterOn;
|
|
2274
|
+
const visiblePlanned = planned?.map((plannedRow, position) => ({ plannedRow, position })).filter(({ plannedRow }) => !shared.hidden.rows.has(plannedRow.entry.id));
|
|
2275
|
+
const visibleRowIndices = planned ? [] : table.rows.map((_row, index) => index).filter((index) => !shared.hidden.rows.has(unplannedRowKey(table.pointer, index)));
|
|
2276
|
+
const visibleCount = visiblePlanned ? visiblePlanned.length : visibleRowIndices.length;
|
|
2277
|
+
const allHidden = visibleCount === 0 && rowCount > 0;
|
|
2174
2278
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
2175
2279
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
2176
2280
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
@@ -2186,7 +2290,11 @@ function TableSection(props) {
|
|
|
2186
2290
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
|
|
2187
2291
|
] }) : null
|
|
2188
2292
|
] }),
|
|
2189
|
-
|
|
2293
|
+
allHidden ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "gemina-verification__all-scored", children: [
|
|
2294
|
+
"All ",
|
|
2295
|
+
rowCount,
|
|
2296
|
+
" rows scored high"
|
|
2297
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "gemina-verification__table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("table", { className: "gemina-verification__table", children: [
|
|
2190
2298
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { children: [
|
|
2191
2299
|
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Show row on document" }) : null,
|
|
2192
2300
|
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Row confidence" }) : null,
|
|
@@ -2199,7 +2307,7 @@ function TableSection(props) {
|
|
|
2199
2307
|
) }, column)),
|
|
2200
2308
|
showControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Row actions" }) : null
|
|
2201
2309
|
] }) }),
|
|
2202
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children:
|
|
2310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: visiblePlanned ? visiblePlanned.map(({ plannedRow, position }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2203
2311
|
TableRow,
|
|
2204
2312
|
{
|
|
2205
2313
|
row: plannedRow.entry.source === null ? void 0 : table.rows[plannedRow.entry.source],
|
|
@@ -2213,10 +2321,10 @@ function TableSection(props) {
|
|
|
2213
2321
|
tablePointer: mutable.pointer
|
|
2214
2322
|
},
|
|
2215
2323
|
plannedRow.entry.id
|
|
2216
|
-
)) :
|
|
2324
|
+
)) : visibleRowIndices.map((rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2217
2325
|
TableRow,
|
|
2218
2326
|
{
|
|
2219
|
-
row,
|
|
2327
|
+
row: table.rows[rowIndex],
|
|
2220
2328
|
rowIndex,
|
|
2221
2329
|
columns,
|
|
2222
2330
|
tableLabel: label,
|
|
@@ -2287,7 +2395,9 @@ function VerificationForm(props) {
|
|
|
2287
2395
|
rowMutableTables,
|
|
2288
2396
|
plannedTables,
|
|
2289
2397
|
onAddRow,
|
|
2290
|
-
onRemoveRow
|
|
2398
|
+
onRemoveRow,
|
|
2399
|
+
hidden,
|
|
2400
|
+
filterOn
|
|
2291
2401
|
} = props;
|
|
2292
2402
|
const { tables: promotedTables, suppressed } = import_react3.default.useMemo(
|
|
2293
2403
|
() => withEmptyMutableTables(classified, rowMutableTables ?? NO_TABLES),
|
|
@@ -2303,7 +2413,9 @@ function VerificationForm(props) {
|
|
|
2303
2413
|
rowMutableTables: rowMutableTables ?? NO_TABLES,
|
|
2304
2414
|
plannedTables: plannedTables ?? NO_PLANNED,
|
|
2305
2415
|
onAddRow: onAddRow ?? NOOP_ROW,
|
|
2306
|
-
onRemoveRow: onRemoveRow ?? NOOP_ROW
|
|
2416
|
+
onRemoveRow: onRemoveRow ?? NOOP_ROW,
|
|
2417
|
+
hidden: hidden ?? NOTHING_HIDDEN,
|
|
2418
|
+
filterOn: filterOn ?? false
|
|
2307
2419
|
};
|
|
2308
2420
|
return (
|
|
2309
2421
|
// A real, labeled <form> (role "form" landmark): AT users can jump
|
|
@@ -2341,7 +2453,7 @@ function VerificationForm(props) {
|
|
|
2341
2453
|
}
|
|
2342
2454
|
|
|
2343
2455
|
// src/version.ts
|
|
2344
|
-
var VERSION = "0.
|
|
2456
|
+
var VERSION = "0.13.1";
|
|
2345
2457
|
|
|
2346
2458
|
// src/verification/styles.ts
|
|
2347
2459
|
var DARK_VARS = `
|
|
@@ -2874,6 +2986,11 @@ var VERIFICATION_CSS = `
|
|
|
2874
2986
|
}
|
|
2875
2987
|
.gemina-verification__footer {
|
|
2876
2988
|
display: flex;
|
|
2989
|
+
/* Wraps because the review filter adds two more items to this row, and at
|
|
2990
|
+
320 the four together overflow: Submit was pushed 28px past the inline
|
|
2991
|
+
start and clipped. Measured RTL, where the overflow runs the other way
|
|
2992
|
+
and a scrollWidth-minus-clientWidth check on the document never sees it. */
|
|
2993
|
+
flex-wrap: wrap;
|
|
2877
2994
|
align-items: center;
|
|
2878
2995
|
gap: 10px;
|
|
2879
2996
|
padding-block-start: 12px;
|
|
@@ -2890,6 +3007,41 @@ var VERIFICATION_CSS = `
|
|
|
2890
3007
|
cursor: pointer;
|
|
2891
3008
|
}
|
|
2892
3009
|
.gemina-verification__submit:disabled { opacity: 0.5; cursor: default; }
|
|
3010
|
+
/* The review filter is a VIEW MODE, not an action, so it stays quiet: an
|
|
3011
|
+
outline control in the muted color, next to the one loud thing in the
|
|
3012
|
+
footer. Turning it on fills it from the same accent token \u2014 the state has
|
|
3013
|
+
to be unmistakable, because the form is hiding content while it is on. */
|
|
3014
|
+
.gemina-verification__review-filter {
|
|
3015
|
+
font: inherit;
|
|
3016
|
+
font-size: 12px;
|
|
3017
|
+
padding: 4px 12px;
|
|
3018
|
+
border-radius: var(--gemina-verification-radius);
|
|
3019
|
+
border: 1px solid var(--gemina-verification-border);
|
|
3020
|
+
background: transparent;
|
|
3021
|
+
color: var(--gemina-verification-muted);
|
|
3022
|
+
cursor: pointer;
|
|
3023
|
+
}
|
|
3024
|
+
.gemina-verification__review-filter:hover {
|
|
3025
|
+
color: var(--gemina-verification-accent);
|
|
3026
|
+
border-color: var(--gemina-verification-accent);
|
|
3027
|
+
}
|
|
3028
|
+
.gemina-verification__review-filter[aria-checked='true'] {
|
|
3029
|
+
background: var(--gemina-verification-accent);
|
|
3030
|
+
border-color: var(--gemina-verification-accent);
|
|
3031
|
+
color: var(--gemina-verification-accent-fg);
|
|
3032
|
+
}
|
|
3033
|
+
/* Stands in for a table's grid when every row of it scored high. Muted and
|
|
3034
|
+
unemphatic on purpose \u2014 it reports an absence, it is not a finding. */
|
|
3035
|
+
.gemina-verification__filter-count {
|
|
3036
|
+
font-size: 12px;
|
|
3037
|
+
color: var(--gemina-verification-muted);
|
|
3038
|
+
}
|
|
3039
|
+
.gemina-verification__all-scored {
|
|
3040
|
+
margin: 0;
|
|
3041
|
+
padding: 12px;
|
|
3042
|
+
color: var(--gemina-verification-muted);
|
|
3043
|
+
font-size: 13px;
|
|
3044
|
+
}
|
|
2893
3045
|
.gemina-verification__retry {
|
|
2894
3046
|
font: inherit;
|
|
2895
3047
|
font-size: 12px;
|
|
@@ -3247,6 +3399,7 @@ function GeminaVerification(props) {
|
|
|
3247
3399
|
const [imageUrl, setImageUrl] = (0, import_react4.useState)(null);
|
|
3248
3400
|
const [flashRects, setFlashRects] = (0, import_react4.useState)(null);
|
|
3249
3401
|
const [stacked, setStacked] = (0, import_react4.useState)(false);
|
|
3402
|
+
const [filterOn, setFilterOn] = (0, import_react4.useState)(false);
|
|
3250
3403
|
const rootRef = (0, import_react4.useRef)(null);
|
|
3251
3404
|
const mountedRef = (0, import_react4.useRef)(false);
|
|
3252
3405
|
const loadSeqRef = (0, import_react4.useRef)(0);
|
|
@@ -3323,6 +3476,7 @@ function GeminaVerification(props) {
|
|
|
3323
3476
|
rowMutableTables: readRowMutableTables(view.meta.validationFeedback?.rowMutableTables)
|
|
3324
3477
|
});
|
|
3325
3478
|
setEdits(NO_EDITS);
|
|
3479
|
+
setFilterOn(false);
|
|
3326
3480
|
setRowPlans(seedRowPlans(readRowMutableTables(view.meta.validationFeedback?.rowMutableTables), view.values));
|
|
3327
3481
|
const url = view.document.imageUrl;
|
|
3328
3482
|
setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
|
|
@@ -3384,19 +3538,19 @@ function GeminaVerification(props) {
|
|
|
3384
3538
|
return map;
|
|
3385
3539
|
}, [bindings]);
|
|
3386
3540
|
const unmatched = (0, import_react4.useMemo)(() => {
|
|
3387
|
-
const
|
|
3541
|
+
const rendered2 = /* @__PURE__ */ new Set();
|
|
3388
3542
|
for (const field of classified.headers) {
|
|
3389
|
-
|
|
3543
|
+
rendered2.add(field.pointer);
|
|
3390
3544
|
}
|
|
3391
3545
|
for (const list of classified.simpleLists) {
|
|
3392
3546
|
for (const item of list.items) {
|
|
3393
|
-
|
|
3547
|
+
rendered2.add(item.pointer);
|
|
3394
3548
|
}
|
|
3395
3549
|
}
|
|
3396
3550
|
for (const entity of classified.entities) {
|
|
3397
3551
|
for (const item of entity.items) {
|
|
3398
3552
|
for (const cell of Object.values(item)) {
|
|
3399
|
-
|
|
3553
|
+
rendered2.add(cell.pointer);
|
|
3400
3554
|
}
|
|
3401
3555
|
}
|
|
3402
3556
|
}
|
|
@@ -3404,12 +3558,12 @@ function GeminaVerification(props) {
|
|
|
3404
3558
|
for (const row of table.rows) {
|
|
3405
3559
|
for (const [key, cell] of Object.entries(row)) {
|
|
3406
3560
|
if (key !== ROW_META_KEY) {
|
|
3407
|
-
|
|
3561
|
+
rendered2.add(cell.pointer);
|
|
3408
3562
|
}
|
|
3409
3563
|
}
|
|
3410
3564
|
}
|
|
3411
3565
|
}
|
|
3412
|
-
return bindings.filter((binding) => !
|
|
3566
|
+
return bindings.filter((binding) => !rendered2.has(binding.fieldPointer));
|
|
3413
3567
|
}, [classified, bindings]);
|
|
3414
3568
|
const overlayRects = (0, import_react4.useMemo)(() => {
|
|
3415
3569
|
const rects = [];
|
|
@@ -3574,6 +3728,32 @@ function GeminaVerification(props) {
|
|
|
3574
3728
|
});
|
|
3575
3729
|
}, []);
|
|
3576
3730
|
const pairErrors = (0, import_react4.useMemo)(() => unitSizePairErrors(cellViews, edits), [cellViews, edits]);
|
|
3731
|
+
const rendered = (0, import_react4.useMemo)(
|
|
3732
|
+
() => withEmptyMutableTables(classified, loaded?.rowMutableTables ?? []),
|
|
3733
|
+
[classified, loaded?.rowMutableTables]
|
|
3734
|
+
);
|
|
3735
|
+
const canFilter = (0, import_react4.useMemo)(
|
|
3736
|
+
() => hasAnyConfidence(classified, rendered.tables, plannedTables),
|
|
3737
|
+
[classified, rendered, plannedTables]
|
|
3738
|
+
);
|
|
3739
|
+
const hidden = (0, import_react4.useMemo)(
|
|
3740
|
+
() => filterOn && canFilter ? computeHidden({
|
|
3741
|
+
classified,
|
|
3742
|
+
tables: rendered.tables,
|
|
3743
|
+
plannedTables,
|
|
3744
|
+
cellViews,
|
|
3745
|
+
bindingIndex,
|
|
3746
|
+
edits,
|
|
3747
|
+
pairErrors,
|
|
3748
|
+
suppressed: rendered.suppressed
|
|
3749
|
+
}) : NOTHING_HIDDEN,
|
|
3750
|
+
[filterOn, canFilter, classified, rendered, plannedTables, cellViews, bindingIndex, edits, pairErrors]
|
|
3751
|
+
);
|
|
3752
|
+
const totalUnits = (0, import_react4.useMemo)(
|
|
3753
|
+
() => countUnits(classified, rendered.tables, plannedTables, rendered.suppressed) + unmatched.length,
|
|
3754
|
+
[classified, rendered, plannedTables, unmatched]
|
|
3755
|
+
);
|
|
3756
|
+
const visibleUnits = totalUnits - hidden.fields.size - hidden.rows.size;
|
|
3577
3757
|
const invalidCount = (0, import_react4.useMemo)(() => {
|
|
3578
3758
|
const rowLevel = pairErrors.size;
|
|
3579
3759
|
if (edits.size === 0) {
|
|
@@ -3746,6 +3926,8 @@ function GeminaVerification(props) {
|
|
|
3746
3926
|
onFlash: handleFlash,
|
|
3747
3927
|
pairErrors,
|
|
3748
3928
|
rowMutableTables: loaded?.rowMutableTables,
|
|
3929
|
+
hidden,
|
|
3930
|
+
filterOn,
|
|
3749
3931
|
plannedTables,
|
|
3750
3932
|
onAddRow: handleAddRow,
|
|
3751
3933
|
onRemoveRow: handleRemoveRow
|
|
@@ -3774,6 +3956,20 @@ function GeminaVerification(props) {
|
|
|
3774
3956
|
),
|
|
3775
3957
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__footer", children: [
|
|
3776
3958
|
!alreadyValidated && (invalidCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__attention", "aria-live": "polite", children: invalidCount === 1 ? "1 field needs attention" : `${invalidCount} fields need attention` }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__progress", "aria-live": "polite", children: `${submission.confirmed} confirmed \xB7 ${submission.corrected} corrected` })),
|
|
3959
|
+
canFilter && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
3960
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3961
|
+
"button",
|
|
3962
|
+
{
|
|
3963
|
+
type: "button",
|
|
3964
|
+
role: "switch",
|
|
3965
|
+
"aria-checked": filterOn,
|
|
3966
|
+
className: "gemina-verification__review-filter",
|
|
3967
|
+
onClick: () => setFilterOn((on) => !on),
|
|
3968
|
+
children: "Hide high-confidence fields"
|
|
3969
|
+
}
|
|
3970
|
+
),
|
|
3971
|
+
filterOn && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__filter-count", "aria-live": "polite", children: `Showing ${visibleUnits} of ${totalUnits}` })
|
|
3972
|
+
] }),
|
|
3777
3973
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
3778
3974
|
"button",
|
|
3779
3975
|
{
|