@gemina/elements 0.13.3 → 0.14.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/README.md +78 -7
- package/dist/chat.cjs +1 -1
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/{chunk-MPBZCA44.js → chunk-FULFYOON.js} +2 -2
- package/dist/{chunk-GWTTD7QH.js → chunk-IZEUK273.js} +2 -2
- package/dist/{chunk-GWTTD7QH.js.map → chunk-IZEUK273.js.map} +1 -1
- package/dist/{chunk-XEWKY2DW.js → chunk-WKPEAD7Q.js} +314 -111
- package/dist/chunk-WKPEAD7Q.js.map +1 -0
- package/dist/index.cjs +313 -110
- 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 +313 -110
- package/dist/verification.cjs.map +1 -1
- package/dist/verification.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-XEWKY2DW.js.map +0 -1
- /package/dist/{chunk-MPBZCA44.js.map → chunk-FULFYOON.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-FULFYOON.js";
|
|
7
7
|
import {
|
|
8
8
|
GeminaVerification
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WKPEAD7Q.js";
|
|
10
10
|
import {
|
|
11
11
|
VERSION
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IZEUK273.js";
|
|
13
13
|
export {
|
|
14
14
|
GeminaChat,
|
|
15
15
|
GeminaTokenManager,
|
package/dist/verification.cjs
CHANGED
|
@@ -819,6 +819,51 @@ function displayColumns(table, classifiedColumns) {
|
|
|
819
819
|
function matchesTablePointer(serverPointer, classifiedPointer) {
|
|
820
820
|
return serverPointer === classifiedPointer || snakeToCamel(serverPointer) === classifiedPointer;
|
|
821
821
|
}
|
|
822
|
+
function columnsForTable(mutable, classifiedColumns) {
|
|
823
|
+
return mutable ? displayColumns(mutable, classifiedColumns) : classifiedColumns;
|
|
824
|
+
}
|
|
825
|
+
function tableColumns(table, rowMutableTables) {
|
|
826
|
+
const mutable = rowMutableTables.find((entry) => matchesTablePointer(entry.pointer, table.pointer));
|
|
827
|
+
return { mutable, columns: columnsForTable(mutable, table.columns) };
|
|
828
|
+
}
|
|
829
|
+
function declaredTableColumns(mutable, classifiedTables) {
|
|
830
|
+
const classified = classifiedTables.find(
|
|
831
|
+
(candidate) => matchesTablePointer(mutable.pointer, candidate.pointer)
|
|
832
|
+
);
|
|
833
|
+
return columnsForTable(mutable, classified?.columns ?? []);
|
|
834
|
+
}
|
|
835
|
+
function tableRows(table, planned) {
|
|
836
|
+
if (planned === void 0) {
|
|
837
|
+
return table.rows.map((row, position) => ({
|
|
838
|
+
row,
|
|
839
|
+
added: false,
|
|
840
|
+
planned: void 0,
|
|
841
|
+
position
|
|
842
|
+
}));
|
|
843
|
+
}
|
|
844
|
+
return planned.map((plannedRow, position) => {
|
|
845
|
+
const { source } = plannedRow.entry;
|
|
846
|
+
return {
|
|
847
|
+
// An added row was never extracted, so it exists only in the plan.
|
|
848
|
+
row: source === null ? void 0 : table.rows[source],
|
|
849
|
+
added: source === null,
|
|
850
|
+
planned: plannedRow,
|
|
851
|
+
position
|
|
852
|
+
};
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
function resolveRowCell(row, column, planned, bindingIndex) {
|
|
856
|
+
const direct = row?.[column];
|
|
857
|
+
const alias = direct === void 0 ? row?.[snakeToCamel(column)] : void 0;
|
|
858
|
+
const fallbackKey = direct === void 0 && alias === void 0 && row !== void 0 ? Object.keys(row).find((key) => snakeToCamel(key) === snakeToCamel(column)) : void 0;
|
|
859
|
+
const classified = direct ?? alias ?? (fallbackKey === void 0 ? void 0 : row?.[fallbackKey]);
|
|
860
|
+
const fromPlan = planned?.cells.find((cell) => cell.column === column);
|
|
861
|
+
if (fromPlan) {
|
|
862
|
+
return { classified, binding: fromPlan.binding, editKey: fromPlan.editKey };
|
|
863
|
+
}
|
|
864
|
+
const binding = classified === void 0 ? void 0 : bindingIndex.get(classified.pointer);
|
|
865
|
+
return { classified, binding, editKey: binding?.key.raw };
|
|
866
|
+
}
|
|
822
867
|
function splitPointer(pointer) {
|
|
823
868
|
const cut = pointer.lastIndexOf("/");
|
|
824
869
|
return cut <= 0 ? null : { row: pointer.slice(0, cut), field: pointer.slice(cut + 1) };
|
|
@@ -901,9 +946,6 @@ function pruneEmptyAddedRows(plannedTables, edits) {
|
|
|
901
946
|
return out;
|
|
902
947
|
}
|
|
903
948
|
|
|
904
|
-
// src/verification/form.tsx
|
|
905
|
-
var import_react3 = __toESM(require("react"), 1);
|
|
906
|
-
|
|
907
949
|
// src/verification/review-filter.ts
|
|
908
950
|
function isHighConfidence(confidence) {
|
|
909
951
|
return (confidence?.level ?? "").toLowerCase() === "high";
|
|
@@ -913,6 +955,14 @@ var NOTHING_HIDDEN = {
|
|
|
913
955
|
rows: /* @__PURE__ */ new Set()
|
|
914
956
|
};
|
|
915
957
|
var unplannedRowKey = (tablePointer, index) => `${tablePointer}/${index}`;
|
|
958
|
+
function planForTable(plannedTables, tablePointer) {
|
|
959
|
+
const exact = plannedTables.get(tablePointer);
|
|
960
|
+
if (exact !== void 0) return exact;
|
|
961
|
+
for (const [serverPointer, planned] of plannedTables) {
|
|
962
|
+
if (matchesTablePointer(serverPointer, tablePointer)) return planned;
|
|
963
|
+
}
|
|
964
|
+
return void 0;
|
|
965
|
+
}
|
|
916
966
|
function forEachFieldUnit(classified, visit) {
|
|
917
967
|
for (const header of classified.headers) visit(header.pointer, header.confidence);
|
|
918
968
|
for (const list of classified.simpleLists) {
|
|
@@ -929,26 +979,12 @@ function forEachRowUnit(tables, plannedTables, visit) {
|
|
|
929
979
|
const meta = row?.[ROW_META_KEY];
|
|
930
980
|
return meta?.confidence ?? null;
|
|
931
981
|
};
|
|
932
|
-
const planFor = (tablePointer) => {
|
|
933
|
-
const exact = plannedTables.get(tablePointer);
|
|
934
|
-
if (exact !== void 0) return exact;
|
|
935
|
-
for (const [serverPointer, planned] of plannedTables) {
|
|
936
|
-
if (matchesTablePointer(serverPointer, tablePointer)) return planned;
|
|
937
|
-
}
|
|
938
|
-
return void 0;
|
|
939
|
-
};
|
|
940
982
|
for (const table of tables) {
|
|
941
|
-
const
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
visit(row.entry.id, source === null ? null : confidenceOf(table.rows[source]), source === null);
|
|
946
|
-
}
|
|
947
|
-
continue;
|
|
983
|
+
for (const ref of tableRows(table, planForTable(plannedTables, table.pointer))) {
|
|
984
|
+
const added = ref.added;
|
|
985
|
+
const rowKey = ref.planned ? ref.planned.entry.id : unplannedRowKey(table.pointer, ref.position);
|
|
986
|
+
visit(rowKey, confidenceOf(ref.row), added);
|
|
948
987
|
}
|
|
949
|
-
table.rows.forEach((row, index) => {
|
|
950
|
-
visit(unplannedRowKey(table.pointer, index), confidenceOf(row), false);
|
|
951
|
-
});
|
|
952
988
|
}
|
|
953
989
|
}
|
|
954
990
|
function computeHidden(input) {
|
|
@@ -1007,6 +1043,60 @@ function hasAnyConfidence(classified, tables, plannedTables) {
|
|
|
1007
1043
|
return found;
|
|
1008
1044
|
}
|
|
1009
1045
|
|
|
1046
|
+
// src/verification/empty-columns.ts
|
|
1047
|
+
var NO_EMPTY_COLUMNS = /* @__PURE__ */ new Map();
|
|
1048
|
+
function qualifies(cell, touchedEver, pairErrors) {
|
|
1049
|
+
const { editKey } = cell;
|
|
1050
|
+
if (editKey !== void 0 && (touchedEver.has(editKey) || pairErrors.has(editKey))) {
|
|
1051
|
+
return false;
|
|
1052
|
+
}
|
|
1053
|
+
const value = cell.binding === void 0 ? cell.classified?.value : cell.binding.extracted;
|
|
1054
|
+
return toInputString(value).trim() === "";
|
|
1055
|
+
}
|
|
1056
|
+
function computeEmptyColumns(input) {
|
|
1057
|
+
const {
|
|
1058
|
+
tables,
|
|
1059
|
+
plannedTables,
|
|
1060
|
+
rowMutableTables,
|
|
1061
|
+
bindingIndex,
|
|
1062
|
+
touchedEver,
|
|
1063
|
+
pairErrors
|
|
1064
|
+
} = input;
|
|
1065
|
+
const empty = /* @__PURE__ */ new Map();
|
|
1066
|
+
for (const table of tables) {
|
|
1067
|
+
const { columns } = tableColumns(table, rowMutableTables);
|
|
1068
|
+
if (columns.length === 0) {
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
const rows = tableRows(table, planForTable(plannedTables, table.pointer));
|
|
1072
|
+
if (!rows.some((row) => !row.added)) {
|
|
1073
|
+
continue;
|
|
1074
|
+
}
|
|
1075
|
+
const hidden = /* @__PURE__ */ new Set();
|
|
1076
|
+
for (const column of columns) {
|
|
1077
|
+
const blankEverywhere = rows.every((row) => qualifies(
|
|
1078
|
+
resolveRowCell(row.row, column, row.planned, bindingIndex),
|
|
1079
|
+
touchedEver,
|
|
1080
|
+
pairErrors
|
|
1081
|
+
));
|
|
1082
|
+
if (blankEverywhere) {
|
|
1083
|
+
hidden.add(column);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
if (hidden.size === 0) {
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
if (hidden.size === columns.length) {
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
empty.set(table.pointer, hidden);
|
|
1093
|
+
}
|
|
1094
|
+
return empty.size === 0 ? NO_EMPTY_COLUMNS : empty;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// src/verification/form.tsx
|
|
1098
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
1099
|
+
|
|
1010
1100
|
// src/verification/tip.tsx
|
|
1011
1101
|
var import_react = require("react");
|
|
1012
1102
|
var import_react_dom = require("react-dom");
|
|
@@ -2135,18 +2225,7 @@ function TableRowView(props) {
|
|
|
2135
2225
|
},
|
|
2136
2226
|
[rects, onFlash]
|
|
2137
2227
|
);
|
|
2138
|
-
const cellFor = (column) =>
|
|
2139
|
-
const direct = row?.[column];
|
|
2140
|
-
const alias = direct === void 0 ? row?.[snakeToCamel(column)] : void 0;
|
|
2141
|
-
const fallbackKey = direct === void 0 && alias === void 0 && row !== void 0 ? Object.keys(row).find((key) => snakeToCamel(key) === snakeToCamel(column)) : void 0;
|
|
2142
|
-
const classified = direct ?? alias ?? (fallbackKey === void 0 ? void 0 : row?.[fallbackKey]);
|
|
2143
|
-
const fromPlan = planned?.cells.find((cell) => cell.column === column);
|
|
2144
|
-
if (fromPlan) {
|
|
2145
|
-
return { classified, binding: fromPlan.binding, editKey: fromPlan.editKey };
|
|
2146
|
-
}
|
|
2147
|
-
const binding = classified === void 0 ? void 0 : bindingIndex.get(classified.pointer);
|
|
2148
|
-
return { classified, binding, editKey: binding?.key.raw };
|
|
2149
|
-
};
|
|
2228
|
+
const cellFor = (column) => resolveRowCell(row, column, planned, bindingIndex);
|
|
2150
2229
|
const firstRect = rects.length > 0 ? rects[0] : null;
|
|
2151
2230
|
const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly && !shared.filterOn;
|
|
2152
2231
|
const rowLevel = (row?.[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
@@ -2249,15 +2328,19 @@ var EMPTY_SUPPRESSED = /* @__PURE__ */ new Set();
|
|
|
2249
2328
|
function TableSection(props) {
|
|
2250
2329
|
const { table, shared } = props;
|
|
2251
2330
|
const label = formatLabel(table.key);
|
|
2252
|
-
const
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
const columns = import_react3.default.useMemo(
|
|
2257
|
-
() => mutable ? displayColumns(mutable, table.columns) : table.columns,
|
|
2258
|
-
[mutable, table.columns]
|
|
2331
|
+
const addLineNoteId = import_react3.default.useId();
|
|
2332
|
+
const { mutable, columns } = import_react3.default.useMemo(
|
|
2333
|
+
() => tableColumns(table, shared.rowMutableTables),
|
|
2334
|
+
[table, shared.rowMutableTables]
|
|
2259
2335
|
);
|
|
2260
2336
|
const planned = mutable ? shared.plannedTables.get(mutable.pointer) : void 0;
|
|
2337
|
+
const hiddenColumns = shared.emptyColumns.get(table.pointer);
|
|
2338
|
+
const mask = columns.map((column) => hiddenColumns?.has(column) ? "1" : "0").join("");
|
|
2339
|
+
const visibleColumns = import_react3.default.useMemo(
|
|
2340
|
+
() => mask.includes("1") ? columns.filter((_column, index) => mask[index] !== "1") : columns,
|
|
2341
|
+
[columns, mask]
|
|
2342
|
+
);
|
|
2343
|
+
const hiddenColumnCount = columns.length - visibleColumns.length;
|
|
2261
2344
|
const hasCoords = import_react3.default.useMemo(
|
|
2262
2345
|
() => table.rows.some(
|
|
2263
2346
|
(row) => Object.entries(row).some(([key, cell]) => key !== ROW_META_KEY && cell.coordinates !== null)
|
|
@@ -2277,7 +2360,8 @@ function TableSection(props) {
|
|
|
2277
2360
|
}
|
|
2278
2361
|
return map;
|
|
2279
2362
|
}, [mutable]);
|
|
2280
|
-
const
|
|
2363
|
+
const rows = import_react3.default.useMemo(() => tableRows(table, planned), [table, planned]);
|
|
2364
|
+
const rowCount = rows.length;
|
|
2281
2365
|
const needsReview = import_react3.default.useMemo(
|
|
2282
2366
|
() => table.rows.filter((row) => {
|
|
2283
2367
|
const level = (row[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
|
|
@@ -2286,10 +2370,11 @@ function TableSection(props) {
|
|
|
2286
2370
|
[table.rows]
|
|
2287
2371
|
);
|
|
2288
2372
|
const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly && !shared.filterOn;
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
const allHidden =
|
|
2373
|
+
const visibleRows = rows.filter(({ planned: plannedRow, position }) => !shared.hidden.rows.has(
|
|
2374
|
+
plannedRow ? plannedRow.entry.id : unplannedRowKey(table.pointer, position)
|
|
2375
|
+
));
|
|
2376
|
+
const allHidden = visibleRows.length === 0 && rowCount > 0;
|
|
2377
|
+
const tablePointer = planned ? mutable.pointer : void 0;
|
|
2293
2378
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
|
|
2294
2379
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__section-header", children: [
|
|
2295
2380
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
@@ -2301,6 +2386,7 @@ function TableSection(props) {
|
|
|
2301
2386
|
")"
|
|
2302
2387
|
] }),
|
|
2303
2388
|
shared.filterOn && mutable !== void 0 && !shared.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__filter-note", children: "Row editing is off while filtering" }) : null,
|
|
2389
|
+
hiddenColumnCount > 0 && !allHidden ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__filter-note", children: `${hiddenColumnCount} ${hiddenColumnCount === 1 ? "column" : "columns"} hidden \u2014 blank in every row` }) : null,
|
|
2304
2390
|
table.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "gemina-verification__overall-confidence", children: [
|
|
2305
2391
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Overall confidence" }),
|
|
2306
2392
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
|
|
@@ -2314,7 +2400,7 @@ function TableSection(props) {
|
|
|
2314
2400
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { children: [
|
|
2315
2401
|
hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Show row on document" }) : null,
|
|
2316
2402
|
hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Row confidence" }) : null,
|
|
2317
|
-
|
|
2403
|
+
visibleColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2318
2404
|
FieldLabel,
|
|
2319
2405
|
{
|
|
2320
2406
|
label: formatLabel(column),
|
|
@@ -2323,43 +2409,35 @@ function TableSection(props) {
|
|
|
2323
2409
|
) }, column)),
|
|
2324
2410
|
showControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("th", { "aria-label": "Row actions" }) : null
|
|
2325
2411
|
] }) }),
|
|
2326
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children:
|
|
2412
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("tbody", { children: visibleRows.map(({ row, planned: plannedRow, position }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2327
2413
|
TableRow,
|
|
2328
2414
|
{
|
|
2329
|
-
row
|
|
2415
|
+
row,
|
|
2330
2416
|
rowIndex: position,
|
|
2331
|
-
columns,
|
|
2417
|
+
columns: visibleColumns,
|
|
2332
2418
|
tableLabel: label,
|
|
2333
2419
|
hasCoords,
|
|
2334
2420
|
hasRowConfidence,
|
|
2335
2421
|
shared,
|
|
2336
2422
|
planned: plannedRow,
|
|
2337
|
-
tablePointer
|
|
2423
|
+
tablePointer
|
|
2338
2424
|
},
|
|
2339
|
-
plannedRow.entry.id
|
|
2340
|
-
)) : visibleRowIndices.map((rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2341
|
-
TableRow,
|
|
2342
|
-
{
|
|
2343
|
-
row: table.rows[rowIndex],
|
|
2344
|
-
rowIndex,
|
|
2345
|
-
columns,
|
|
2346
|
-
tableLabel: label,
|
|
2347
|
-
hasCoords,
|
|
2348
|
-
hasRowConfidence,
|
|
2349
|
-
shared
|
|
2350
|
-
},
|
|
2351
|
-
rowIndex
|
|
2425
|
+
plannedRow ? plannedRow.entry.id : position
|
|
2352
2426
|
)) })
|
|
2353
2427
|
] }) }),
|
|
2354
|
-
showControls ? /* @__PURE__ */ (0, import_jsx_runtime3.
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2428
|
+
showControls ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__table-footer", children: [
|
|
2429
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2430
|
+
"button",
|
|
2431
|
+
{
|
|
2432
|
+
type: "button",
|
|
2433
|
+
className: "gemina-verification__add-row",
|
|
2434
|
+
onClick: () => shared.onAddRow(mutable.pointer, rowCount - 1),
|
|
2435
|
+
"aria-describedby": hiddenColumnCount > 0 ? addLineNoteId : void 0,
|
|
2436
|
+
children: "Add line"
|
|
2437
|
+
}
|
|
2438
|
+
),
|
|
2439
|
+
hiddenColumnCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "gemina-verification__filter-note", id: addLineNoteId, children: "New lines can only fill the visible columns \u2014 turn off \u201CHide empty columns\u201D to reach the rest." }) : null
|
|
2440
|
+
] }) : null
|
|
2363
2441
|
] });
|
|
2364
2442
|
}
|
|
2365
2443
|
var FallbackSection = import_react3.default.memo(function FallbackSection2(props) {
|
|
@@ -2413,7 +2491,8 @@ function VerificationForm(props) {
|
|
|
2413
2491
|
onAddRow,
|
|
2414
2492
|
onRemoveRow,
|
|
2415
2493
|
hidden,
|
|
2416
|
-
filterOn
|
|
2494
|
+
filterOn,
|
|
2495
|
+
emptyColumns
|
|
2417
2496
|
} = props;
|
|
2418
2497
|
const { tables: promotedTables, suppressed } = import_react3.default.useMemo(
|
|
2419
2498
|
() => withEmptyMutableTables(classified, rowMutableTables ?? NO_TABLES),
|
|
@@ -2431,7 +2510,8 @@ function VerificationForm(props) {
|
|
|
2431
2510
|
onAddRow: onAddRow ?? NOOP_ROW,
|
|
2432
2511
|
onRemoveRow: onRemoveRow ?? NOOP_ROW,
|
|
2433
2512
|
hidden: hidden ?? NOTHING_HIDDEN,
|
|
2434
|
-
filterOn: filterOn ?? false
|
|
2513
|
+
filterOn: filterOn ?? false,
|
|
2514
|
+
emptyColumns: emptyColumns ?? NO_EMPTY_COLUMNS
|
|
2435
2515
|
};
|
|
2436
2516
|
return (
|
|
2437
2517
|
// A real, labeled <form> (role "form" landmark): AT users can jump
|
|
@@ -2469,7 +2549,7 @@ function VerificationForm(props) {
|
|
|
2469
2549
|
}
|
|
2470
2550
|
|
|
2471
2551
|
// src/version.ts
|
|
2472
|
-
var VERSION = "0.
|
|
2552
|
+
var VERSION = "0.14.0";
|
|
2473
2553
|
|
|
2474
2554
|
// src/verification/styles.ts
|
|
2475
2555
|
var DARK_VARS = `
|
|
@@ -2751,8 +2831,20 @@ var VERIFICATION_CSS = `
|
|
|
2751
2831
|
}
|
|
2752
2832
|
.gemina-verification__section-header {
|
|
2753
2833
|
display: flex;
|
|
2834
|
+
/* Wraps for the same reason the footer does, and it was measured the same
|
|
2835
|
+
way: with BOTH review filters on this row carries four children \u2014 the
|
|
2836
|
+
label, the confidence filter's "row editing is off" note, the column
|
|
2837
|
+
filter's count, and the overall-confidence readout, which is
|
|
2838
|
+
white-space: nowrap on margin-inline-start: auto. At 320 that readout
|
|
2839
|
+
was pushed 36px (chromium) / 48px (firefox) past the header's edge and
|
|
2840
|
+
clipped, in BOTH directions. Without wrapping, the three text children
|
|
2841
|
+
also squeeze into narrow word-per-line columns from ~420px down, which is
|
|
2842
|
+
the state the screenshots showed before this rule. Row gap is tighter
|
|
2843
|
+
than the column gap: wrapped lines are one meta line continued, not
|
|
2844
|
+
separate blocks. */
|
|
2845
|
+
flex-wrap: wrap;
|
|
2754
2846
|
align-items: center;
|
|
2755
|
-
gap: 8px;
|
|
2847
|
+
gap: 4px 8px;
|
|
2756
2848
|
padding: 8px 12px;
|
|
2757
2849
|
background: var(--gemina-verification-surface);
|
|
2758
2850
|
border-block-end: 1px solid var(--gemina-verification-border);
|
|
@@ -3012,6 +3104,13 @@ var VERIFICATION_CSS = `
|
|
|
3012
3104
|
padding-block-start: 12px;
|
|
3013
3105
|
border-block-start: 1px solid var(--gemina-verification-border);
|
|
3014
3106
|
}
|
|
3107
|
+
/* Programmatic focus landing (tabIndex -1), not an interactive control, and
|
|
3108
|
+
the same treatment the done state gets: no ring. Focus arrives here only
|
|
3109
|
+
when the empty-columns switch deletes itself and Submit is disabled, purely
|
|
3110
|
+
so keyboard/AT users don't drop to <body>; outlining the whole footer row
|
|
3111
|
+
would read as a control the reviewer had somehow activated. */
|
|
3112
|
+
.gemina-verification__footer:focus,
|
|
3113
|
+
.gemina-verification__footer:focus-visible { outline: none; }
|
|
3015
3114
|
.gemina-verification__footer .gemina-verification__submit { margin-inline-start: auto; }
|
|
3016
3115
|
.gemina-verification__submit {
|
|
3017
3116
|
font: inherit;
|
|
@@ -3046,16 +3145,56 @@ var VERIFICATION_CSS = `
|
|
|
3046
3145
|
border-color: var(--gemina-verification-accent);
|
|
3047
3146
|
color: var(--gemina-verification-accent-fg);
|
|
3048
3147
|
}
|
|
3049
|
-
/* Stands in for a table's grid when every row of it scored high. Muted and
|
|
3050
|
-
unemphatic on purpose \u2014 it reports an absence, it is not a finding. */
|
|
3051
3148
|
.gemina-verification__filter-count {
|
|
3052
3149
|
font-size: 12px;
|
|
3053
3150
|
color: var(--gemina-verification-muted);
|
|
3151
|
+
/* "Showing 6 of 11" is untranslated English chrome whose first characters
|
|
3152
|
+
are a digit run, and it sits in a footer that takes the widget's
|
|
3153
|
+
direction. Same fix, same reason as __progress above: base the line's
|
|
3154
|
+
direction on its own first strong character. */
|
|
3155
|
+
unicode-bidi: plaintext;
|
|
3054
3156
|
}
|
|
3157
|
+
/* One class, THREE statements \u2014 two in the section header and one below the
|
|
3158
|
+
grid. The confidence filter's "row editing is off while filtering" (a
|
|
3159
|
+
constraint), the column filter's "N columns hidden" (a report), and the note
|
|
3160
|
+
beside *Add line* saying a new line cannot reach the hidden columns (an
|
|
3161
|
+
instruction). Muted and unemphatic on purpose in all three roles: none of
|
|
3162
|
+
them is a finding about the document, and the instruction is a limit the
|
|
3163
|
+
reviewer meets rarely, not a warning.
|
|
3164
|
+
Explicitly 400 for the two in the header: it sets font-weight: 600 for its
|
|
3165
|
+
LABEL, and without this they inherit it and become the boldest thing in the
|
|
3166
|
+
row after the label itself. The header's three weights are the hierarchy \u2014
|
|
3167
|
+
600 label, 500 confidence readout, 400 notes. (The table footer inherits
|
|
3168
|
+
400 anyway; stating it keeps all three instances identical wherever they
|
|
3169
|
+
are read.) */
|
|
3055
3170
|
.gemina-verification__filter-note {
|
|
3056
3171
|
font-size: 12px;
|
|
3172
|
+
font-weight: 400;
|
|
3057
3173
|
color: var(--gemina-verification-muted);
|
|
3174
|
+
/* Observed at 320 RTL before this rule: "1 empty column hidden" rendered as
|
|
3175
|
+
"empty 1 column hidden" \u2014 the RTL paragraph direction reordered the
|
|
3176
|
+
leading number run. The copy is English chrome either way, so it takes
|
|
3177
|
+
its direction from its own first strong character. */
|
|
3178
|
+
unicode-bidi: plaintext;
|
|
3058
3179
|
}
|
|
3180
|
+
/* Two notes side by side is a reachable state \u2014 the confidence filter's
|
|
3181
|
+
constraint and this filter's count \u2014 and unseparated they read as one
|
|
3182
|
+
sentence ("\u2026while filtering 11 columns hidden"). A hairline rather than the
|
|
3183
|
+
house middot, because a separator CHARACTER cannot land on the right side
|
|
3184
|
+
here: the note carries unicode-bidi: plaintext, so its own content resolves
|
|
3185
|
+
LTR even inside an RTL header, and a ::before then paints at the note's left
|
|
3186
|
+
edge \u2014 the side AWAY from the sibling it is separating from. Measured that
|
|
3187
|
+
way at 780 RTL before this rule. A border-inline-start resolves against the
|
|
3188
|
+
direction property, which plaintext does not touch, so it faces the previous
|
|
3189
|
+
sibling in both directions. It also survives the header wrapping: when the
|
|
3190
|
+
two notes land on different lines the hairline leads the second one, where a
|
|
3191
|
+
rule reads as an indent and a stray middot would have read as a typo. */
|
|
3192
|
+
.gemina-verification__filter-note + .gemina-verification__filter-note {
|
|
3193
|
+
border-inline-start: 1px solid var(--gemina-verification-border);
|
|
3194
|
+
padding-inline-start: 8px;
|
|
3195
|
+
}
|
|
3196
|
+
/* Stands in for a table's grid when every row of it scored high. Muted and
|
|
3197
|
+
unemphatic on purpose \u2014 it reports an absence, it is not a finding. */
|
|
3059
3198
|
.gemina-verification__all-scored {
|
|
3060
3199
|
margin: 0;
|
|
3061
3200
|
padding: 12px;
|
|
@@ -3252,6 +3391,12 @@ var VERIFICATION_CSS = `
|
|
|
3252
3391
|
}
|
|
3253
3392
|
.gemina-verification__table-footer {
|
|
3254
3393
|
display: flex;
|
|
3394
|
+
/* *Add line* sits here alone until the column filter hides something, and
|
|
3395
|
+
then a note joins it \u2014 long enough to need its own line at 390 and below,
|
|
3396
|
+
which is why this row wraps and centres what is on it. */
|
|
3397
|
+
flex-wrap: wrap;
|
|
3398
|
+
align-items: center;
|
|
3399
|
+
gap: 8px;
|
|
3255
3400
|
padding: 8px 10px;
|
|
3256
3401
|
}
|
|
3257
3402
|
.gemina-verification__add-row {
|
|
@@ -3420,7 +3565,9 @@ function GeminaVerification(props) {
|
|
|
3420
3565
|
const [flashRects, setFlashRects] = (0, import_react4.useState)(null);
|
|
3421
3566
|
const [stacked, setStacked] = (0, import_react4.useState)(false);
|
|
3422
3567
|
const [filterOn, setFilterOn] = (0, import_react4.useState)(false);
|
|
3568
|
+
const [hideEmptyColumns, setHideEmptyColumns] = (0, import_react4.useState)(false);
|
|
3423
3569
|
const rootRef = (0, import_react4.useRef)(null);
|
|
3570
|
+
const touchedEverRef = (0, import_react4.useRef)(/* @__PURE__ */ new Set());
|
|
3424
3571
|
const mountedRef = (0, import_react4.useRef)(false);
|
|
3425
3572
|
const loadSeqRef = (0, import_react4.useRef)(0);
|
|
3426
3573
|
const lastImageRefreshRef = (0, import_react4.useRef)(0);
|
|
@@ -3436,6 +3583,7 @@ function GeminaVerification(props) {
|
|
|
3436
3583
|
const cancelButtonRef = (0, import_react4.useRef)(null);
|
|
3437
3584
|
const retrySubmitButtonRef = (0, import_react4.useRef)(null);
|
|
3438
3585
|
const doneStateRef = (0, import_react4.useRef)(null);
|
|
3586
|
+
const footerRef = (0, import_react4.useRef)(null);
|
|
3439
3587
|
const enterUnavailable = (0, import_react4.useCallback)(
|
|
3440
3588
|
(reason, message, canRetry, detail) => {
|
|
3441
3589
|
setPhase({ name: "unavailable", reason, message, canRetry });
|
|
@@ -3497,6 +3645,8 @@ function GeminaVerification(props) {
|
|
|
3497
3645
|
});
|
|
3498
3646
|
setEdits(NO_EDITS);
|
|
3499
3647
|
setFilterOn(false);
|
|
3648
|
+
setHideEmptyColumns(false);
|
|
3649
|
+
touchedEverRef.current = /* @__PURE__ */ new Set();
|
|
3500
3650
|
setRowPlans(seedRowPlans(readRowMutableTables(view.meta.validationFeedback?.rowMutableTables), view.values));
|
|
3501
3651
|
const url = view.document.imageUrl;
|
|
3502
3652
|
setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
|
|
@@ -3625,6 +3775,7 @@ function GeminaVerification(props) {
|
|
|
3625
3775
|
);
|
|
3626
3776
|
const effectiveDir = dir === "auto" ? hasHebrewContent ? "rtl" : "ltr" : dir;
|
|
3627
3777
|
const handleEdit = (0, import_react4.useCallback)((editKey, value, binding) => {
|
|
3778
|
+
touchedEverRef.current.add(editKey);
|
|
3628
3779
|
const pristine = value === toInputString(binding.extracted);
|
|
3629
3780
|
setEdits((prev) => {
|
|
3630
3781
|
if (pristine) {
|
|
@@ -3654,10 +3805,7 @@ function GeminaVerification(props) {
|
|
|
3654
3805
|
if (plan === void 0) {
|
|
3655
3806
|
continue;
|
|
3656
3807
|
}
|
|
3657
|
-
const
|
|
3658
|
-
(candidate) => matchesTablePointer(table.pointer, candidate.pointer)
|
|
3659
|
-
);
|
|
3660
|
-
const columns = displayColumns(table, classifiedTable?.columns ?? []);
|
|
3808
|
+
const columns = declaredTableColumns(table, classified.tables);
|
|
3661
3809
|
out.set(table.pointer, planTableCells(table, plan, columns, bindingsByRawKey));
|
|
3662
3810
|
}
|
|
3663
3811
|
return out;
|
|
@@ -3775,6 +3923,31 @@ function GeminaVerification(props) {
|
|
|
3775
3923
|
);
|
|
3776
3924
|
const visibleUnits = totalUnits - hidden.fields.size - hidden.rows.size;
|
|
3777
3925
|
const allClear = filterOn && totalUnits > 0 && visibleUnits === 0;
|
|
3926
|
+
const emptyColumns = (0, import_react4.useMemo)(
|
|
3927
|
+
() => computeEmptyColumns({
|
|
3928
|
+
// The RENDERED tables, not `classified.tables`: a server-declared
|
|
3929
|
+
// zero-row row-mutable table is promoted into the rendered list and the
|
|
3930
|
+
// rule has to see it (it hides nothing there, by its own row gate).
|
|
3931
|
+
tables: rendered.tables,
|
|
3932
|
+
plannedTables,
|
|
3933
|
+
rowMutableTables: loaded?.rowMutableTables ?? [],
|
|
3934
|
+
bindingIndex,
|
|
3935
|
+
touchedEver: touchedEverRef.current,
|
|
3936
|
+
// §D5: read-only drops the pair-error clause. Nothing renders an error
|
|
3937
|
+
// there and Submit is permanently disabled, so keeping a blank
|
|
3938
|
+
// pair-partner visible would be a rule with no observable reason.
|
|
3939
|
+
// The form's own shared empty map, so "no row errors" has one name on
|
|
3940
|
+
// both sides — nothing compares it by reference (see NO_PAIR_ERRORS).
|
|
3941
|
+
pairErrors: alreadyValidated ? NO_PAIR_ERRORS : pairErrors
|
|
3942
|
+
}),
|
|
3943
|
+
// Spelled out rather than elided, and `edits` STAYS in it although the body
|
|
3944
|
+
// no longer reads it: it is what re-runs this memo as the reviewer types,
|
|
3945
|
+
// which is what keeps a just-touched column from qualifying under their
|
|
3946
|
+
// cursor. This repo has no ESLint — nothing mechanical will tell you if you
|
|
3947
|
+
// drop a dependency here.
|
|
3948
|
+
[rendered, plannedTables, loaded, bindingIndex, edits, pairErrors, alreadyValidated]
|
|
3949
|
+
);
|
|
3950
|
+
const canHideEmptyColumns = emptyColumns.size > 0 || hideEmptyColumns;
|
|
3778
3951
|
const invalidCount = (0, import_react4.useMemo)(() => {
|
|
3779
3952
|
const rowLevel = pairErrors.size;
|
|
3780
3953
|
if (edits.size === 0) {
|
|
@@ -3949,6 +4122,7 @@ function GeminaVerification(props) {
|
|
|
3949
4122
|
rowMutableTables: loaded?.rowMutableTables,
|
|
3950
4123
|
hidden,
|
|
3951
4124
|
filterOn,
|
|
4125
|
+
emptyColumns: hideEmptyColumns ? emptyColumns : NO_EMPTY_COLUMNS,
|
|
3952
4126
|
plannedTables,
|
|
3953
4127
|
onAddRow: handleAddRow,
|
|
3954
4128
|
onRemoveRow: handleRemoveRow
|
|
@@ -3975,34 +4149,63 @@ function GeminaVerification(props) {
|
|
|
3975
4149
|
]
|
|
3976
4150
|
}
|
|
3977
4151
|
),
|
|
3978
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4152
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
4153
|
+
"div",
|
|
4154
|
+
{
|
|
4155
|
+
className: "gemina-verification__footer",
|
|
4156
|
+
ref: footerRef,
|
|
4157
|
+
tabIndex: -1,
|
|
4158
|
+
children: [
|
|
4159
|
+
!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` })),
|
|
4160
|
+
canFilter && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
4161
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4162
|
+
"button",
|
|
4163
|
+
{
|
|
4164
|
+
type: "button",
|
|
4165
|
+
role: "switch",
|
|
4166
|
+
"aria-checked": filterOn,
|
|
4167
|
+
className: "gemina-verification__review-filter",
|
|
4168
|
+
onClick: () => setFilterOn((on) => !on),
|
|
4169
|
+
children: "Hide high-confidence fields"
|
|
4170
|
+
}
|
|
4171
|
+
),
|
|
4172
|
+
filterOn && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__filter-count", "aria-live": "polite", children: `Showing ${visibleUnits} of ${totalUnits}` })
|
|
4173
|
+
] }),
|
|
4174
|
+
canHideEmptyColumns && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4175
|
+
"button",
|
|
4176
|
+
{
|
|
4177
|
+
type: "button",
|
|
4178
|
+
role: "switch",
|
|
4179
|
+
"aria-checked": hideEmptyColumns,
|
|
4180
|
+
className: "gemina-verification__review-filter",
|
|
4181
|
+
onClick: () => {
|
|
4182
|
+
if (hideEmptyColumns && emptyColumns.size === 0) {
|
|
4183
|
+
const submit = submitButtonRef.current;
|
|
4184
|
+
if (submit !== null && !submit.disabled) {
|
|
4185
|
+
submit.focus();
|
|
4186
|
+
} else {
|
|
4187
|
+
footerRef.current?.focus();
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
setHideEmptyColumns((on) => !on);
|
|
4191
|
+
},
|
|
4192
|
+
children: "Hide empty columns"
|
|
4193
|
+
}
|
|
4194
|
+
),
|
|
4195
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4196
|
+
"button",
|
|
4197
|
+
{
|
|
4198
|
+
type: "button",
|
|
4199
|
+
ref: submitButtonRef,
|
|
4200
|
+
className: "gemina-verification__submit",
|
|
4201
|
+
disabled: alreadyValidated || reviewPhase.name !== "review" || invalidCount > 0,
|
|
4202
|
+
onClick: handleSubmitClick,
|
|
4203
|
+
children: "Submit"
|
|
4204
|
+
}
|
|
4205
|
+
)
|
|
4206
|
+
]
|
|
4207
|
+
}
|
|
4208
|
+
),
|
|
4006
4209
|
overlayUp && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
4007
4210
|
"div",
|
|
4008
4211
|
{
|