@gemina/elements 0.13.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/index.d.cts CHANGED
@@ -5,6 +5,6 @@ import 'react';
5
5
  import '@gemina/sdk';
6
6
 
7
7
  /** Package version. Keep in sync with package.json. */
8
- declare const VERSION = "0.13.0";
8
+ declare const VERSION = "0.13.1";
9
9
 
10
10
  export { VERSION };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,6 @@ import 'react';
5
5
  import '@gemina/sdk';
6
6
 
7
7
  /** Package version. Keep in sync with package.json. */
8
- declare const VERSION = "0.13.0";
8
+ declare const VERSION = "0.13.1";
9
9
 
10
10
  export { VERSION };
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-XFE7C6IS.js";
6
+ } from "./chunk-6KHHCUSJ.js";
7
7
  import {
8
8
  GeminaVerification
9
- } from "./chunk-5X7CGCOV.js";
9
+ } from "./chunk-A5PZTHDE.js";
10
10
  import {
11
11
  VERSION
12
- } from "./chunk-7FT4EJTY.js";
12
+ } from "./chunk-X5TSIIUP.js";
13
13
  export {
14
14
  GeminaChat,
15
15
  GeminaTokenManager,
@@ -913,87 +913,90 @@ var NOTHING_HIDDEN = {
913
913
  rows: /* @__PURE__ */ new Set()
914
914
  };
915
915
  var unplannedRowKey = (tablePointer, index) => `${tablePointer}/${index}`;
916
- function computeHidden(input) {
917
- const { classified, plannedTables, cellViews, bindingIndex, edits, pairErrors, suppressed } = input;
918
- const fields = /* @__PURE__ */ new Set();
919
- const rows = /* @__PURE__ */ new Set();
920
- const touched = (editKey) => editKey !== void 0 && (edits.has(editKey) || pairErrors.has(editKey));
921
- const editKeysByRow = /* @__PURE__ */ new Map();
922
- for (const view of cellViews) {
923
- const list = editKeysByRow.get(view.rowKey);
924
- if (list) list.push(view.editKey);
925
- else editKeysByRow.set(view.rowKey, [view.editKey]);
926
- }
927
- const considerField = (pointer, confidence) => {
928
- if (suppressed.has(pointer)) return;
929
- if (!isHighConfidence(confidence)) return;
930
- const editKey = bindingIndex.get(pointer)?.key.raw;
931
- if (editKey === void 0 || touched(editKey)) return;
932
- fields.add(pointer);
933
- };
934
- for (const header of classified.headers) {
935
- considerField(header.pointer, header.confidence);
936
- }
916
+ function forEachFieldUnit(classified, visit) {
917
+ for (const header of classified.headers) visit(header.pointer, header.confidence);
937
918
  for (const list of classified.simpleLists) {
938
- for (const item of list.items) considerField(item.pointer, item.confidence);
919
+ for (const item of list.items) visit(item.pointer, item.confidence);
939
920
  }
940
921
  for (const entity of classified.entities) {
941
922
  for (const item of entity.items) {
942
- for (const entityCell of Object.values(item)) considerField(entityCell.pointer, entityCell.confidence);
923
+ for (const cell of Object.values(item)) visit(cell.pointer, cell.confidence);
943
924
  }
944
925
  }
945
- const rowConfidence = (row) => {
926
+ }
927
+ function forEachRowUnit(tables, plannedTables, visit) {
928
+ const confidenceOf = (row) => {
946
929
  const meta = row?.[ROW_META_KEY];
947
930
  return meta?.confidence ?? null;
948
931
  };
949
- const rowIsHidable = (rowKey) => !(editKeysByRow.get(rowKey) ?? []).some((editKey) => touched(editKey));
950
- for (const table of classified.tables) {
932
+ for (const table of tables) {
951
933
  const planned = plannedTables.get(table.pointer);
952
934
  if (planned) {
953
- for (const plannedRow of planned) {
954
- if (plannedRow.entry.source === null) continue;
955
- if (!isHighConfidence(rowConfidence(table.rows[plannedRow.entry.source]))) continue;
956
- if (!rowIsHidable(plannedRow.entry.id)) continue;
957
- rows.add(plannedRow.entry.id);
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);
958
938
  }
959
939
  continue;
960
940
  }
961
941
  table.rows.forEach((row, index) => {
962
- if (!isHighConfidence(rowConfidence(row))) return;
963
- const key = unplannedRowKey(table.pointer, index);
964
- if (!rowIsHidable(key)) return;
965
- rows.add(key);
942
+ visit(unplannedRowKey(table.pointer, index), confidenceOf(row), false);
966
943
  });
967
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
+ });
968
977
  if (fields.size === 0 && rows.size === 0) return NOTHING_HIDDEN;
969
978
  return { fields, rows };
970
979
  }
971
- function countUnits(classified, plannedTables, suppressed) {
980
+ function countUnits(classified, tables, plannedTables, suppressed) {
972
981
  let total = 0;
973
- total += classified.headers.filter((header) => !suppressed.has(header.pointer)).length;
974
- for (const list of classified.simpleLists) {
975
- total += list.items.filter((item) => !suppressed.has(item.pointer)).length;
976
- }
977
- for (const entity of classified.entities) {
978
- for (const item of entity.items) {
979
- total += Object.values(item).filter((entityCell) => !suppressed.has(entityCell.pointer)).length;
980
- }
981
- }
982
- for (const table of classified.tables) {
983
- total += plannedTables.get(table.pointer)?.length ?? table.rows.length;
984
- }
982
+ forEachFieldUnit(classified, (pointer) => {
983
+ if (!suppressed.has(pointer)) total += 1;
984
+ });
985
+ forEachRowUnit(tables, plannedTables, () => {
986
+ total += 1;
987
+ });
985
988
  return total;
986
989
  }
987
- function hasAnyConfidence(classified) {
988
- if (classified.headers.some((header) => header.confidence?.level)) return true;
989
- if (classified.simpleLists.some((list) => list.items.some((item) => item.confidence?.level))) return true;
990
- if (classified.entities.some((entity) => entity.items.some(
991
- (item) => Object.values(item).some((entityCell) => entityCell.confidence?.level)
992
- ))) return true;
993
- return classified.tables.some((table) => table.rows.some((row) => {
994
- const meta = row[ROW_META_KEY];
995
- return Boolean(meta?.confidence?.level);
996
- }));
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;
997
1000
  }
998
1001
 
999
1002
  // src/verification/tip.tsx
@@ -2269,7 +2272,7 @@ function TableSection(props) {
2269
2272
  );
2270
2273
  const showControls = planned !== void 0 && mutable !== void 0 && !shared.readOnly && !shared.filterOn;
2271
2274
  const visiblePlanned = planned?.map((plannedRow, position) => ({ plannedRow, position })).filter(({ plannedRow }) => !shared.hidden.rows.has(plannedRow.entry.id));
2272
- const visibleRowIndices = planned ? null : table.rows.map((_row, index) => index).filter((index) => !shared.hidden.rows.has(unplannedRowKey(table.pointer, index)));
2275
+ const visibleRowIndices = planned ? [] : table.rows.map((_row, index) => index).filter((index) => !shared.hidden.rows.has(unplannedRowKey(table.pointer, index)));
2273
2276
  const visibleCount = visiblePlanned ? visiblePlanned.length : visibleRowIndices.length;
2274
2277
  const allHidden = visibleCount === 0 && rowCount > 0;
2275
2278
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: "gemina-verification__section", "aria-label": label, children: [
@@ -2450,7 +2453,7 @@ function VerificationForm(props) {
2450
2453
  }
2451
2454
 
2452
2455
  // src/version.ts
2453
- var VERSION = "0.13.0";
2456
+ var VERSION = "0.13.1";
2454
2457
 
2455
2458
  // src/verification/styles.ts
2456
2459
  var DARK_VARS = `
@@ -3535,19 +3538,19 @@ function GeminaVerification(props) {
3535
3538
  return map;
3536
3539
  }, [bindings]);
3537
3540
  const unmatched = (0, import_react4.useMemo)(() => {
3538
- const rendered = /* @__PURE__ */ new Set();
3541
+ const rendered2 = /* @__PURE__ */ new Set();
3539
3542
  for (const field of classified.headers) {
3540
- rendered.add(field.pointer);
3543
+ rendered2.add(field.pointer);
3541
3544
  }
3542
3545
  for (const list of classified.simpleLists) {
3543
3546
  for (const item of list.items) {
3544
- rendered.add(item.pointer);
3547
+ rendered2.add(item.pointer);
3545
3548
  }
3546
3549
  }
3547
3550
  for (const entity of classified.entities) {
3548
3551
  for (const item of entity.items) {
3549
3552
  for (const cell of Object.values(item)) {
3550
- rendered.add(cell.pointer);
3553
+ rendered2.add(cell.pointer);
3551
3554
  }
3552
3555
  }
3553
3556
  }
@@ -3555,12 +3558,12 @@ function GeminaVerification(props) {
3555
3558
  for (const row of table.rows) {
3556
3559
  for (const [key, cell] of Object.entries(row)) {
3557
3560
  if (key !== ROW_META_KEY) {
3558
- rendered.add(cell.pointer);
3561
+ rendered2.add(cell.pointer);
3559
3562
  }
3560
3563
  }
3561
3564
  }
3562
3565
  }
3563
- return bindings.filter((binding) => !rendered.has(binding.fieldPointer));
3566
+ return bindings.filter((binding) => !rendered2.has(binding.fieldPointer));
3564
3567
  }, [classified, bindings]);
3565
3568
  const overlayRects = (0, import_react4.useMemo)(() => {
3566
3569
  const rects = [];
@@ -3725,26 +3728,30 @@ function GeminaVerification(props) {
3725
3728
  });
3726
3729
  }, []);
3727
3730
  const pairErrors = (0, import_react4.useMemo)(() => unitSizePairErrors(cellViews, edits), [cellViews, edits]);
3728
- const suppressed = (0, import_react4.useMemo)(
3729
- () => withEmptyMutableTables(classified, loaded?.rowMutableTables ?? []).suppressed,
3731
+ const rendered = (0, import_react4.useMemo)(
3732
+ () => withEmptyMutableTables(classified, loaded?.rowMutableTables ?? []),
3730
3733
  [classified, loaded?.rowMutableTables]
3731
3734
  );
3732
- const canFilter = (0, import_react4.useMemo)(() => hasAnyConfidence(classified), [classified]);
3735
+ const canFilter = (0, import_react4.useMemo)(
3736
+ () => hasAnyConfidence(classified, rendered.tables, plannedTables),
3737
+ [classified, rendered, plannedTables]
3738
+ );
3733
3739
  const hidden = (0, import_react4.useMemo)(
3734
3740
  () => filterOn && canFilter ? computeHidden({
3735
3741
  classified,
3742
+ tables: rendered.tables,
3736
3743
  plannedTables,
3737
3744
  cellViews,
3738
3745
  bindingIndex,
3739
3746
  edits,
3740
3747
  pairErrors,
3741
- suppressed
3748
+ suppressed: rendered.suppressed
3742
3749
  }) : NOTHING_HIDDEN,
3743
- [filterOn, canFilter, classified, plannedTables, cellViews, bindingIndex, edits, pairErrors, suppressed]
3750
+ [filterOn, canFilter, classified, rendered, plannedTables, cellViews, bindingIndex, edits, pairErrors]
3744
3751
  );
3745
3752
  const totalUnits = (0, import_react4.useMemo)(
3746
- () => countUnits(classified, plannedTables, suppressed) + unmatched.length,
3747
- [classified, plannedTables, suppressed, unmatched]
3753
+ () => countUnits(classified, rendered.tables, plannedTables, rendered.suppressed) + unmatched.length,
3754
+ [classified, rendered, plannedTables, unmatched]
3748
3755
  );
3749
3756
  const visibleUnits = totalUnits - hidden.fields.size - hidden.rows.size;
3750
3757
  const invalidCount = (0, import_react4.useMemo)(() => {