@gemina/elements 0.13.3 → 0.15.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.
@@ -3,7 +3,7 @@ import {
3
3
  getResponseLike,
4
4
  httpStatus,
5
5
  readErrorEnvelope
6
- } from "./chunk-GWTTD7QH.js";
6
+ } from "./chunk-CVL3O5SG.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-MPBZCA44.js.map
659
+ //# sourceMappingURL=chunk-YVDLYEGU.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.13.3";
224
+ var VERSION = "0.15.0";
225
225
 
226
226
  // src/chat.tsx
227
227
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -1610,6 +1610,51 @@ function displayColumns(table, classifiedColumns) {
1610
1610
  function matchesTablePointer(serverPointer, classifiedPointer) {
1611
1611
  return serverPointer === classifiedPointer || snakeToCamel(serverPointer) === classifiedPointer;
1612
1612
  }
1613
+ function columnsForTable(mutable, classifiedColumns) {
1614
+ return mutable ? displayColumns(mutable, classifiedColumns) : classifiedColumns;
1615
+ }
1616
+ function tableColumns(table, rowMutableTables) {
1617
+ const mutable = rowMutableTables.find((entry) => matchesTablePointer(entry.pointer, table.pointer));
1618
+ return { mutable, columns: columnsForTable(mutable, table.columns) };
1619
+ }
1620
+ function declaredTableColumns(mutable, classifiedTables) {
1621
+ const classified = classifiedTables.find(
1622
+ (candidate) => matchesTablePointer(mutable.pointer, candidate.pointer)
1623
+ );
1624
+ return columnsForTable(mutable, classified?.columns ?? []);
1625
+ }
1626
+ function tableRows(table, planned) {
1627
+ if (planned === void 0) {
1628
+ return table.rows.map((row, position) => ({
1629
+ row,
1630
+ added: false,
1631
+ planned: void 0,
1632
+ position
1633
+ }));
1634
+ }
1635
+ return planned.map((plannedRow, position) => {
1636
+ const { source } = plannedRow.entry;
1637
+ return {
1638
+ // An added row was never extracted, so it exists only in the plan.
1639
+ row: source === null ? void 0 : table.rows[source],
1640
+ added: source === null,
1641
+ planned: plannedRow,
1642
+ position
1643
+ };
1644
+ });
1645
+ }
1646
+ function resolveRowCell(row, column, planned, bindingIndex) {
1647
+ const direct = row?.[column];
1648
+ const alias = direct === void 0 ? row?.[snakeToCamel(column)] : void 0;
1649
+ const fallbackKey = direct === void 0 && alias === void 0 && row !== void 0 ? Object.keys(row).find((key) => snakeToCamel(key) === snakeToCamel(column)) : void 0;
1650
+ const classified = direct ?? alias ?? (fallbackKey === void 0 ? void 0 : row?.[fallbackKey]);
1651
+ const fromPlan = planned?.cells.find((cell) => cell.column === column);
1652
+ if (fromPlan) {
1653
+ return { classified, binding: fromPlan.binding, editKey: fromPlan.editKey };
1654
+ }
1655
+ const binding = classified === void 0 ? void 0 : bindingIndex.get(classified.pointer);
1656
+ return { classified, binding, editKey: binding?.key.raw };
1657
+ }
1613
1658
  function splitPointer(pointer) {
1614
1659
  const cut = pointer.lastIndexOf("/");
1615
1660
  return cut <= 0 ? null : { row: pointer.slice(0, cut), field: pointer.slice(cut + 1) };
@@ -1692,9 +1737,6 @@ function pruneEmptyAddedRows(plannedTables, edits) {
1692
1737
  return out;
1693
1738
  }
1694
1739
 
1695
- // src/verification/form.tsx
1696
- var import_react4 = __toESM(require("react"), 1);
1697
-
1698
1740
  // src/verification/review-filter.ts
1699
1741
  function isHighConfidence(confidence) {
1700
1742
  return (confidence?.level ?? "").toLowerCase() === "high";
@@ -1704,6 +1746,14 @@ var NOTHING_HIDDEN = {
1704
1746
  rows: /* @__PURE__ */ new Set()
1705
1747
  };
1706
1748
  var unplannedRowKey = (tablePointer, index) => `${tablePointer}/${index}`;
1749
+ function planForTable(plannedTables, tablePointer) {
1750
+ const exact = plannedTables.get(tablePointer);
1751
+ if (exact !== void 0) return exact;
1752
+ for (const [serverPointer, planned] of plannedTables) {
1753
+ if (matchesTablePointer(serverPointer, tablePointer)) return planned;
1754
+ }
1755
+ return void 0;
1756
+ }
1707
1757
  function forEachFieldUnit(classified, visit) {
1708
1758
  for (const header of classified.headers) visit(header.pointer, header.confidence);
1709
1759
  for (const list of classified.simpleLists) {
@@ -1720,26 +1770,12 @@ function forEachRowUnit(tables, plannedTables, visit) {
1720
1770
  const meta = row?.[ROW_META_KEY];
1721
1771
  return meta?.confidence ?? null;
1722
1772
  };
1723
- const planFor = (tablePointer) => {
1724
- const exact = plannedTables.get(tablePointer);
1725
- if (exact !== void 0) return exact;
1726
- for (const [serverPointer, planned] of plannedTables) {
1727
- if (matchesTablePointer(serverPointer, tablePointer)) return planned;
1728
- }
1729
- return void 0;
1730
- };
1731
1773
  for (const table of tables) {
1732
- const planned = planFor(table.pointer);
1733
- if (planned) {
1734
- for (const row of planned) {
1735
- const { source } = row.entry;
1736
- visit(row.entry.id, source === null ? null : confidenceOf(table.rows[source]), source === null);
1737
- }
1738
- continue;
1774
+ for (const ref of tableRows(table, planForTable(plannedTables, table.pointer))) {
1775
+ const added = ref.added;
1776
+ const rowKey = ref.planned ? ref.planned.entry.id : unplannedRowKey(table.pointer, ref.position);
1777
+ visit(rowKey, confidenceOf(ref.row), added);
1739
1778
  }
1740
- table.rows.forEach((row, index) => {
1741
- visit(unplannedRowKey(table.pointer, index), confidenceOf(row), false);
1742
- });
1743
1779
  }
1744
1780
  }
1745
1781
  function computeHidden(input) {
@@ -1798,6 +1834,60 @@ function hasAnyConfidence(classified, tables, plannedTables) {
1798
1834
  return found;
1799
1835
  }
1800
1836
 
1837
+ // src/verification/empty-columns.ts
1838
+ var NO_EMPTY_COLUMNS = /* @__PURE__ */ new Map();
1839
+ function qualifies(cell, touchedEver, pairErrors) {
1840
+ const { editKey } = cell;
1841
+ if (editKey !== void 0 && (touchedEver.has(editKey) || pairErrors.has(editKey))) {
1842
+ return false;
1843
+ }
1844
+ const value = cell.binding === void 0 ? cell.classified?.value : cell.binding.extracted;
1845
+ return toInputString(value).trim() === "";
1846
+ }
1847
+ function computeEmptyColumns(input) {
1848
+ const {
1849
+ tables,
1850
+ plannedTables,
1851
+ rowMutableTables,
1852
+ bindingIndex,
1853
+ touchedEver,
1854
+ pairErrors
1855
+ } = input;
1856
+ const empty = /* @__PURE__ */ new Map();
1857
+ for (const table of tables) {
1858
+ const { columns } = tableColumns(table, rowMutableTables);
1859
+ if (columns.length === 0) {
1860
+ continue;
1861
+ }
1862
+ const rows = tableRows(table, planForTable(plannedTables, table.pointer));
1863
+ if (!rows.some((row) => !row.added)) {
1864
+ continue;
1865
+ }
1866
+ const hidden = /* @__PURE__ */ new Set();
1867
+ for (const column of columns) {
1868
+ const blankEverywhere = rows.every((row) => qualifies(
1869
+ resolveRowCell(row.row, column, row.planned, bindingIndex),
1870
+ touchedEver,
1871
+ pairErrors
1872
+ ));
1873
+ if (blankEverywhere) {
1874
+ hidden.add(column);
1875
+ }
1876
+ }
1877
+ if (hidden.size === 0) {
1878
+ continue;
1879
+ }
1880
+ if (hidden.size === columns.length) {
1881
+ continue;
1882
+ }
1883
+ empty.set(table.pointer, hidden);
1884
+ }
1885
+ return empty.size === 0 ? NO_EMPTY_COLUMNS : empty;
1886
+ }
1887
+
1888
+ // src/verification/form.tsx
1889
+ var import_react4 = __toESM(require("react"), 1);
1890
+
1801
1891
  // src/verification/tip.tsx
1802
1892
  var import_react2 = require("react");
1803
1893
  var import_react_dom = require("react-dom");
@@ -2926,18 +3016,7 @@ function TableRowView(props) {
2926
3016
  },
2927
3017
  [rects, onFlash]
2928
3018
  );
2929
- const cellFor = (column) => {
2930
- const direct = row?.[column];
2931
- const alias = direct === void 0 ? row?.[snakeToCamel(column)] : void 0;
2932
- const fallbackKey = direct === void 0 && alias === void 0 && row !== void 0 ? Object.keys(row).find((key) => snakeToCamel(key) === snakeToCamel(column)) : void 0;
2933
- const classified = direct ?? alias ?? (fallbackKey === void 0 ? void 0 : row?.[fallbackKey]);
2934
- const fromPlan = planned?.cells.find((cell) => cell.column === column);
2935
- if (fromPlan) {
2936
- return { classified, binding: fromPlan.binding, editKey: fromPlan.editKey };
2937
- }
2938
- const binding = classified === void 0 ? void 0 : bindingIndex.get(classified.pointer);
2939
- return { classified, binding, editKey: binding?.key.raw };
2940
- };
3019
+ const cellFor = (column) => resolveRowCell(row, column, planned, bindingIndex);
2941
3020
  const firstRect = rects.length > 0 ? rects[0] : null;
2942
3021
  const showControls = planned !== void 0 && tablePointer !== void 0 && !readOnly && !shared.filterOn;
2943
3022
  const rowLevel = (row?.[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
@@ -3040,15 +3119,19 @@ var EMPTY_SUPPRESSED = /* @__PURE__ */ new Set();
3040
3119
  function TableSection(props) {
3041
3120
  const { table, shared } = props;
3042
3121
  const label = formatLabel(table.key);
3043
- const mutable = import_react4.default.useMemo(
3044
- () => shared.rowMutableTables.find((entry) => matchesTablePointer(entry.pointer, table.pointer)),
3045
- [shared.rowMutableTables, table.pointer]
3046
- );
3047
- const columns = import_react4.default.useMemo(
3048
- () => mutable ? displayColumns(mutable, table.columns) : table.columns,
3049
- [mutable, table.columns]
3122
+ const addLineNoteId = import_react4.default.useId();
3123
+ const { mutable, columns } = import_react4.default.useMemo(
3124
+ () => tableColumns(table, shared.rowMutableTables),
3125
+ [table, shared.rowMutableTables]
3050
3126
  );
3051
3127
  const planned = mutable ? shared.plannedTables.get(mutable.pointer) : void 0;
3128
+ const hiddenColumns = shared.emptyColumns.get(table.pointer);
3129
+ const mask = columns.map((column) => hiddenColumns?.has(column) ? "1" : "0").join("");
3130
+ const visibleColumns = import_react4.default.useMemo(
3131
+ () => mask.includes("1") ? columns.filter((_column, index) => mask[index] !== "1") : columns,
3132
+ [columns, mask]
3133
+ );
3134
+ const hiddenColumnCount = columns.length - visibleColumns.length;
3052
3135
  const hasCoords = import_react4.default.useMemo(
3053
3136
  () => table.rows.some(
3054
3137
  (row) => Object.entries(row).some(([key, cell]) => key !== ROW_META_KEY && cell.coordinates !== null)
@@ -3068,7 +3151,8 @@ function TableSection(props) {
3068
3151
  }
3069
3152
  return map;
3070
3153
  }, [mutable]);
3071
- const rowCount = planned ? planned.length : table.rows.length;
3154
+ const rows = import_react4.default.useMemo(() => tableRows(table, planned), [table, planned]);
3155
+ const rowCount = rows.length;
3072
3156
  const needsReview = import_react4.default.useMemo(
3073
3157
  () => table.rows.filter((row) => {
3074
3158
  const level = (row[ROW_META_KEY]?.confidence?.level ?? "").toLowerCase();
@@ -3077,10 +3161,11 @@ function TableSection(props) {
3077
3161
  [table.rows]
3078
3162
  );
3079
3163
  const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly && !shared.filterOn;
3080
- const visiblePlanned = planned?.map((plannedRow, position) => ({ plannedRow, position })).filter(({ plannedRow }) => !shared.hidden.rows.has(plannedRow.entry.id));
3081
- const visibleRowIndices = planned ? [] : table.rows.map((_row, index) => index).filter((index) => !shared.hidden.rows.has(unplannedRowKey(table.pointer, index)));
3082
- const visibleCount = visiblePlanned ? visiblePlanned.length : visibleRowIndices.length;
3083
- const allHidden = visibleCount === 0 && rowCount > 0;
3164
+ const visibleRows = rows.filter(({ planned: plannedRow, position }) => !shared.hidden.rows.has(
3165
+ plannedRow ? plannedRow.entry.id : unplannedRowKey(table.pointer, position)
3166
+ ));
3167
+ const allHidden = visibleRows.length === 0 && rowCount > 0;
3168
+ const tablePointer = planned ? mutable.pointer : void 0;
3084
3169
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
3085
3170
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__section-header", children: [
3086
3171
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
@@ -3092,6 +3177,7 @@ function TableSection(props) {
3092
3177
  ")"
3093
3178
  ] }),
3094
3179
  shared.filterOn && mutable !== void 0 && !shared.readOnly ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__filter-note", children: "Row editing is off while filtering" }) : null,
3180
+ hiddenColumnCount > 0 && !allHidden ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "gemina-verification__filter-note", children: `${hiddenColumnCount} ${hiddenColumnCount === 1 ? "column" : "columns"} hidden \u2014 blank in every row` }) : null,
3095
3181
  table.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "gemina-verification__overall-confidence", children: [
3096
3182
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Overall confidence" }),
3097
3183
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
@@ -3105,7 +3191,7 @@ function TableSection(props) {
3105
3191
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("tr", { children: [
3106
3192
  hasCoords ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Show row on document" }) : null,
3107
3193
  hasRowConfidence ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row confidence" }) : null,
3108
- columns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3194
+ visibleColumns.map((column) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3109
3195
  FieldLabel,
3110
3196
  {
3111
3197
  label: formatLabel(column),
@@ -3114,43 +3200,35 @@ function TableSection(props) {
3114
3200
  ) }, column)),
3115
3201
  showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("th", { "aria-label": "Row actions" }) : null
3116
3202
  ] }) }),
3117
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("tbody", { children: visiblePlanned ? visiblePlanned.map(({ plannedRow, position }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3203
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("tbody", { children: visibleRows.map(({ row, planned: plannedRow, position }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3118
3204
  TableRow,
3119
3205
  {
3120
- row: plannedRow.entry.source === null ? void 0 : table.rows[plannedRow.entry.source],
3206
+ row,
3121
3207
  rowIndex: position,
3122
- columns,
3208
+ columns: visibleColumns,
3123
3209
  tableLabel: label,
3124
3210
  hasCoords,
3125
3211
  hasRowConfidence,
3126
3212
  shared,
3127
3213
  planned: plannedRow,
3128
- tablePointer: mutable.pointer
3129
- },
3130
- plannedRow.entry.id
3131
- )) : visibleRowIndices.map((rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3132
- TableRow,
3133
- {
3134
- row: table.rows[rowIndex],
3135
- rowIndex,
3136
- columns,
3137
- tableLabel: label,
3138
- hasCoords,
3139
- hasRowConfidence,
3140
- shared
3214
+ tablePointer
3141
3215
  },
3142
- rowIndex
3216
+ plannedRow ? plannedRow.entry.id : position
3143
3217
  )) })
3144
3218
  ] }) }),
3145
- showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "gemina-verification__table-footer", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3146
- "button",
3147
- {
3148
- type: "button",
3149
- className: "gemina-verification__add-row",
3150
- onClick: () => shared.onAddRow(mutable.pointer, rowCount - 1),
3151
- children: "Add line"
3152
- }
3153
- ) }) : null
3219
+ showControls ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "gemina-verification__table-footer", children: [
3220
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3221
+ "button",
3222
+ {
3223
+ type: "button",
3224
+ className: "gemina-verification__add-row",
3225
+ onClick: () => shared.onAddRow(mutable.pointer, rowCount - 1),
3226
+ "aria-describedby": hiddenColumnCount > 0 ? addLineNoteId : void 0,
3227
+ children: "Add line"
3228
+ }
3229
+ ),
3230
+ hiddenColumnCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.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
3231
+ ] }) : null
3154
3232
  ] });
3155
3233
  }
3156
3234
  var FallbackSection = import_react4.default.memo(function FallbackSection2(props) {
@@ -3204,7 +3282,8 @@ function VerificationForm(props) {
3204
3282
  onAddRow,
3205
3283
  onRemoveRow,
3206
3284
  hidden,
3207
- filterOn
3285
+ filterOn,
3286
+ emptyColumns
3208
3287
  } = props;
3209
3288
  const { tables: promotedTables, suppressed } = import_react4.default.useMemo(
3210
3289
  () => withEmptyMutableTables(classified, rowMutableTables ?? NO_TABLES),
@@ -3222,7 +3301,8 @@ function VerificationForm(props) {
3222
3301
  onAddRow: onAddRow ?? NOOP_ROW,
3223
3302
  onRemoveRow: onRemoveRow ?? NOOP_ROW,
3224
3303
  hidden: hidden ?? NOTHING_HIDDEN,
3225
- filterOn: filterOn ?? false
3304
+ filterOn: filterOn ?? false,
3305
+ emptyColumns: emptyColumns ?? NO_EMPTY_COLUMNS
3226
3306
  };
3227
3307
  return (
3228
3308
  // A real, labeled <form> (role "form" landmark): AT users can jump
@@ -3539,8 +3619,20 @@ var VERIFICATION_CSS = `
3539
3619
  }
3540
3620
  .gemina-verification__section-header {
3541
3621
  display: flex;
3622
+ /* Wraps for the same reason the footer does, and it was measured the same
3623
+ way: with BOTH review filters on this row carries four children \u2014 the
3624
+ label, the confidence filter's "row editing is off" note, the column
3625
+ filter's count, and the overall-confidence readout, which is
3626
+ white-space: nowrap on margin-inline-start: auto. At 320 that readout
3627
+ was pushed 36px (chromium) / 48px (firefox) past the header's edge and
3628
+ clipped, in BOTH directions. Without wrapping, the three text children
3629
+ also squeeze into narrow word-per-line columns from ~420px down, which is
3630
+ the state the screenshots showed before this rule. Row gap is tighter
3631
+ than the column gap: wrapped lines are one meta line continued, not
3632
+ separate blocks. */
3633
+ flex-wrap: wrap;
3542
3634
  align-items: center;
3543
- gap: 8px;
3635
+ gap: 4px 8px;
3544
3636
  padding: 8px 12px;
3545
3637
  background: var(--gemina-verification-surface);
3546
3638
  border-block-end: 1px solid var(--gemina-verification-border);
@@ -3800,6 +3892,13 @@ var VERIFICATION_CSS = `
3800
3892
  padding-block-start: 12px;
3801
3893
  border-block-start: 1px solid var(--gemina-verification-border);
3802
3894
  }
3895
+ /* Programmatic focus landing (tabIndex -1), not an interactive control, and
3896
+ the same treatment the done state gets: no ring. Focus arrives here only
3897
+ when the empty-columns switch deletes itself and Submit is disabled, purely
3898
+ so keyboard/AT users don't drop to <body>; outlining the whole footer row
3899
+ would read as a control the reviewer had somehow activated. */
3900
+ .gemina-verification__footer:focus,
3901
+ .gemina-verification__footer:focus-visible { outline: none; }
3803
3902
  .gemina-verification__footer .gemina-verification__submit { margin-inline-start: auto; }
3804
3903
  .gemina-verification__submit {
3805
3904
  font: inherit;
@@ -3834,16 +3933,56 @@ var VERIFICATION_CSS = `
3834
3933
  border-color: var(--gemina-verification-accent);
3835
3934
  color: var(--gemina-verification-accent-fg);
3836
3935
  }
3837
- /* Stands in for a table's grid when every row of it scored high. Muted and
3838
- unemphatic on purpose \u2014 it reports an absence, it is not a finding. */
3839
3936
  .gemina-verification__filter-count {
3840
3937
  font-size: 12px;
3841
3938
  color: var(--gemina-verification-muted);
3939
+ /* "Showing 6 of 11" is untranslated English chrome whose first characters
3940
+ are a digit run, and it sits in a footer that takes the widget's
3941
+ direction. Same fix, same reason as __progress above: base the line's
3942
+ direction on its own first strong character. */
3943
+ unicode-bidi: plaintext;
3842
3944
  }
3945
+ /* One class, THREE statements \u2014 two in the section header and one below the
3946
+ grid. The confidence filter's "row editing is off while filtering" (a
3947
+ constraint), the column filter's "N columns hidden" (a report), and the note
3948
+ beside *Add line* saying a new line cannot reach the hidden columns (an
3949
+ instruction). Muted and unemphatic on purpose in all three roles: none of
3950
+ them is a finding about the document, and the instruction is a limit the
3951
+ reviewer meets rarely, not a warning.
3952
+ Explicitly 400 for the two in the header: it sets font-weight: 600 for its
3953
+ LABEL, and without this they inherit it and become the boldest thing in the
3954
+ row after the label itself. The header's three weights are the hierarchy \u2014
3955
+ 600 label, 500 confidence readout, 400 notes. (The table footer inherits
3956
+ 400 anyway; stating it keeps all three instances identical wherever they
3957
+ are read.) */
3843
3958
  .gemina-verification__filter-note {
3844
3959
  font-size: 12px;
3960
+ font-weight: 400;
3845
3961
  color: var(--gemina-verification-muted);
3962
+ /* Observed at 320 RTL before this rule: "1 empty column hidden" rendered as
3963
+ "empty 1 column hidden" \u2014 the RTL paragraph direction reordered the
3964
+ leading number run. The copy is English chrome either way, so it takes
3965
+ its direction from its own first strong character. */
3966
+ unicode-bidi: plaintext;
3846
3967
  }
3968
+ /* Two notes side by side is a reachable state \u2014 the confidence filter's
3969
+ constraint and this filter's count \u2014 and unseparated they read as one
3970
+ sentence ("\u2026while filtering 11 columns hidden"). A hairline rather than the
3971
+ house middot, because a separator CHARACTER cannot land on the right side
3972
+ here: the note carries unicode-bidi: plaintext, so its own content resolves
3973
+ LTR even inside an RTL header, and a ::before then paints at the note's left
3974
+ edge \u2014 the side AWAY from the sibling it is separating from. Measured that
3975
+ way at 780 RTL before this rule. A border-inline-start resolves against the
3976
+ direction property, which plaintext does not touch, so it faces the previous
3977
+ sibling in both directions. It also survives the header wrapping: when the
3978
+ two notes land on different lines the hairline leads the second one, where a
3979
+ rule reads as an indent and a stray middot would have read as a typo. */
3980
+ .gemina-verification__filter-note + .gemina-verification__filter-note {
3981
+ border-inline-start: 1px solid var(--gemina-verification-border);
3982
+ padding-inline-start: 8px;
3983
+ }
3984
+ /* Stands in for a table's grid when every row of it scored high. Muted and
3985
+ unemphatic on purpose \u2014 it reports an absence, it is not a finding. */
3847
3986
  .gemina-verification__all-scored {
3848
3987
  margin: 0;
3849
3988
  padding: 12px;
@@ -4040,6 +4179,12 @@ var VERIFICATION_CSS = `
4040
4179
  }
4041
4180
  .gemina-verification__table-footer {
4042
4181
  display: flex;
4182
+ /* *Add line* sits here alone until the column filter hides something, and
4183
+ then a note joins it \u2014 long enough to need its own line at 390 and below,
4184
+ which is why this row wraps and centres what is on it. */
4185
+ flex-wrap: wrap;
4186
+ align-items: center;
4187
+ gap: 8px;
4043
4188
  padding: 8px 10px;
4044
4189
  }
4045
4190
  .gemina-verification__add-row {
@@ -4208,7 +4353,9 @@ function GeminaVerification(props) {
4208
4353
  const [flashRects, setFlashRects] = (0, import_react5.useState)(null);
4209
4354
  const [stacked, setStacked] = (0, import_react5.useState)(false);
4210
4355
  const [filterOn, setFilterOn] = (0, import_react5.useState)(false);
4356
+ const [hideEmptyColumns, setHideEmptyColumns] = (0, import_react5.useState)(false);
4211
4357
  const rootRef = (0, import_react5.useRef)(null);
4358
+ const touchedEverRef = (0, import_react5.useRef)(/* @__PURE__ */ new Set());
4212
4359
  const mountedRef = (0, import_react5.useRef)(false);
4213
4360
  const loadSeqRef = (0, import_react5.useRef)(0);
4214
4361
  const lastImageRefreshRef = (0, import_react5.useRef)(0);
@@ -4224,6 +4371,7 @@ function GeminaVerification(props) {
4224
4371
  const cancelButtonRef = (0, import_react5.useRef)(null);
4225
4372
  const retrySubmitButtonRef = (0, import_react5.useRef)(null);
4226
4373
  const doneStateRef = (0, import_react5.useRef)(null);
4374
+ const footerRef = (0, import_react5.useRef)(null);
4227
4375
  const enterUnavailable = (0, import_react5.useCallback)(
4228
4376
  (reason, message, canRetry, detail) => {
4229
4377
  setPhase({ name: "unavailable", reason, message, canRetry });
@@ -4285,6 +4433,8 @@ function GeminaVerification(props) {
4285
4433
  });
4286
4434
  setEdits(NO_EDITS);
4287
4435
  setFilterOn(false);
4436
+ setHideEmptyColumns(false);
4437
+ touchedEverRef.current = /* @__PURE__ */ new Set();
4288
4438
  setRowPlans(seedRowPlans(readRowMutableTables(view.meta.validationFeedback?.rowMutableTables), view.values));
4289
4439
  const url = view.document.imageUrl;
4290
4440
  setImageUrl(typeof url === "string" && url.length > 0 ? url : null);
@@ -4413,6 +4563,7 @@ function GeminaVerification(props) {
4413
4563
  );
4414
4564
  const effectiveDir = dir === "auto" ? hasHebrewContent ? "rtl" : "ltr" : dir;
4415
4565
  const handleEdit = (0, import_react5.useCallback)((editKey, value, binding) => {
4566
+ touchedEverRef.current.add(editKey);
4416
4567
  const pristine = value === toInputString(binding.extracted);
4417
4568
  setEdits((prev) => {
4418
4569
  if (pristine) {
@@ -4442,10 +4593,7 @@ function GeminaVerification(props) {
4442
4593
  if (plan === void 0) {
4443
4594
  continue;
4444
4595
  }
4445
- const classifiedTable = classified.tables.find(
4446
- (candidate) => matchesTablePointer(table.pointer, candidate.pointer)
4447
- );
4448
- const columns = displayColumns(table, classifiedTable?.columns ?? []);
4596
+ const columns = declaredTableColumns(table, classified.tables);
4449
4597
  out.set(table.pointer, planTableCells(table, plan, columns, bindingsByRawKey));
4450
4598
  }
4451
4599
  return out;
@@ -4563,6 +4711,31 @@ function GeminaVerification(props) {
4563
4711
  );
4564
4712
  const visibleUnits = totalUnits - hidden.fields.size - hidden.rows.size;
4565
4713
  const allClear = filterOn && totalUnits > 0 && visibleUnits === 0;
4714
+ const emptyColumns = (0, import_react5.useMemo)(
4715
+ () => computeEmptyColumns({
4716
+ // The RENDERED tables, not `classified.tables`: a server-declared
4717
+ // zero-row row-mutable table is promoted into the rendered list and the
4718
+ // rule has to see it (it hides nothing there, by its own row gate).
4719
+ tables: rendered.tables,
4720
+ plannedTables,
4721
+ rowMutableTables: loaded?.rowMutableTables ?? [],
4722
+ bindingIndex,
4723
+ touchedEver: touchedEverRef.current,
4724
+ // §D5: read-only drops the pair-error clause. Nothing renders an error
4725
+ // there and Submit is permanently disabled, so keeping a blank
4726
+ // pair-partner visible would be a rule with no observable reason.
4727
+ // The form's own shared empty map, so "no row errors" has one name on
4728
+ // both sides — nothing compares it by reference (see NO_PAIR_ERRORS).
4729
+ pairErrors: alreadyValidated ? NO_PAIR_ERRORS : pairErrors
4730
+ }),
4731
+ // Spelled out rather than elided, and `edits` STAYS in it although the body
4732
+ // no longer reads it: it is what re-runs this memo as the reviewer types,
4733
+ // which is what keeps a just-touched column from qualifying under their
4734
+ // cursor. This repo has no ESLint — nothing mechanical will tell you if you
4735
+ // drop a dependency here.
4736
+ [rendered, plannedTables, loaded, bindingIndex, edits, pairErrors, alreadyValidated]
4737
+ );
4738
+ const canHideEmptyColumns = emptyColumns.size > 0 || hideEmptyColumns;
4566
4739
  const invalidCount = (0, import_react5.useMemo)(() => {
4567
4740
  const rowLevel = pairErrors.size;
4568
4741
  if (edits.size === 0) {
@@ -4737,6 +4910,7 @@ function GeminaVerification(props) {
4737
4910
  rowMutableTables: loaded?.rowMutableTables,
4738
4911
  hidden,
4739
4912
  filterOn,
4913
+ emptyColumns: hideEmptyColumns ? emptyColumns : NO_EMPTY_COLUMNS,
4740
4914
  plannedTables,
4741
4915
  onAddRow: handleAddRow,
4742
4916
  onRemoveRow: handleRemoveRow
@@ -4763,34 +4937,63 @@ function GeminaVerification(props) {
4763
4937
  ]
4764
4938
  }
4765
4939
  ),
4766
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "gemina-verification__footer", children: [
4767
- !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` })),
4768
- canFilter && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
4769
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4770
- "button",
4771
- {
4772
- type: "button",
4773
- role: "switch",
4774
- "aria-checked": filterOn,
4775
- className: "gemina-verification__review-filter",
4776
- onClick: () => setFilterOn((on) => !on),
4777
- children: "Hide high-confidence fields"
4778
- }
4779
- ),
4780
- filterOn && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "gemina-verification__filter-count", "aria-live": "polite", children: `Showing ${visibleUnits} of ${totalUnits}` })
4781
- ] }),
4782
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4783
- "button",
4784
- {
4785
- type: "button",
4786
- ref: submitButtonRef,
4787
- className: "gemina-verification__submit",
4788
- disabled: alreadyValidated || reviewPhase.name !== "review" || invalidCount > 0,
4789
- onClick: handleSubmitClick,
4790
- children: "Submit"
4791
- }
4792
- )
4793
- ] }),
4940
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
4941
+ "div",
4942
+ {
4943
+ className: "gemina-verification__footer",
4944
+ ref: footerRef,
4945
+ tabIndex: -1,
4946
+ children: [
4947
+ !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` })),
4948
+ canFilter && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
4949
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4950
+ "button",
4951
+ {
4952
+ type: "button",
4953
+ role: "switch",
4954
+ "aria-checked": filterOn,
4955
+ className: "gemina-verification__review-filter",
4956
+ onClick: () => setFilterOn((on) => !on),
4957
+ children: "Hide high-confidence fields"
4958
+ }
4959
+ ),
4960
+ filterOn && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "gemina-verification__filter-count", "aria-live": "polite", children: `Showing ${visibleUnits} of ${totalUnits}` })
4961
+ ] }),
4962
+ canHideEmptyColumns && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4963
+ "button",
4964
+ {
4965
+ type: "button",
4966
+ role: "switch",
4967
+ "aria-checked": hideEmptyColumns,
4968
+ className: "gemina-verification__review-filter",
4969
+ onClick: () => {
4970
+ if (hideEmptyColumns && emptyColumns.size === 0) {
4971
+ const submit = submitButtonRef.current;
4972
+ if (submit !== null && !submit.disabled) {
4973
+ submit.focus();
4974
+ } else {
4975
+ footerRef.current?.focus();
4976
+ }
4977
+ }
4978
+ setHideEmptyColumns((on) => !on);
4979
+ },
4980
+ children: "Hide empty columns"
4981
+ }
4982
+ ),
4983
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4984
+ "button",
4985
+ {
4986
+ type: "button",
4987
+ ref: submitButtonRef,
4988
+ className: "gemina-verification__submit",
4989
+ disabled: alreadyValidated || reviewPhase.name !== "review" || invalidCount > 0,
4990
+ onClick: handleSubmitClick,
4991
+ children: "Submit"
4992
+ }
4993
+ )
4994
+ ]
4995
+ }
4996
+ ),
4794
4997
  overlayUp && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
4795
4998
  "div",
4796
4999
  {