@gemina/elements 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat.cjs +1 -1
- package/dist/chat.cjs.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/{chunk-MITACKUW.js → chunk-ILX5CY6H.js} +106 -17
- package/dist/chunk-ILX5CY6H.js.map +1 -0
- package/dist/{chunk-S4KBJRIP.js → chunk-TSOUHYYB.js} +2 -2
- package/dist/{chunk-S4KBJRIP.js.map → chunk-TSOUHYYB.js.map} +1 -1
- package/dist/{chunk-DU6BUHR5.js → chunk-YVJI4TFI.js} +2 -2
- package/dist/index.cjs +105 -16
- 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 +105 -16
- package/dist/verification.cjs.map +1 -1
- package/dist/verification.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-MITACKUW.js.map +0 -1
- /package/dist/{chunk-DU6BUHR5.js.map → chunk-YVJI4TFI.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-YVJI4TFI.js";
|
|
7
7
|
import {
|
|
8
8
|
GeminaVerification
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ILX5CY6H.js";
|
|
10
10
|
import {
|
|
11
11
|
VERSION
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-TSOUHYYB.js";
|
|
13
13
|
export {
|
|
14
14
|
GeminaChat,
|
|
15
15
|
GeminaTokenManager,
|
package/dist/verification.cjs
CHANGED
|
@@ -365,6 +365,7 @@ function escapeSegment(segment) {
|
|
|
365
365
|
var ROW_META_KEY = "_rowMeta";
|
|
366
366
|
function classifyData(data) {
|
|
367
367
|
const result = {
|
|
368
|
+
overallConfidence: null,
|
|
368
369
|
headers: [],
|
|
369
370
|
simpleLists: [],
|
|
370
371
|
entities: [],
|
|
@@ -375,6 +376,7 @@ function classifyData(data) {
|
|
|
375
376
|
return result;
|
|
376
377
|
}
|
|
377
378
|
let rootData = data;
|
|
379
|
+
result.overallConfidence = readOverallConfidence(rootData);
|
|
378
380
|
let basePointer = "";
|
|
379
381
|
if ("data" in rootData && typeof rootData.data === "object" && rootData.data !== null && !Array.isArray(rootData.data)) {
|
|
380
382
|
for (const [key, value] of Object.entries(rootData)) {
|
|
@@ -382,6 +384,7 @@ function classifyData(data) {
|
|
|
382
384
|
processField(key, value, result, rootData, "");
|
|
383
385
|
}
|
|
384
386
|
rootData = rootData.data;
|
|
387
|
+
result.overallConfidence ?? (result.overallConfidence = readOverallConfidence(rootData));
|
|
385
388
|
basePointer = "/data";
|
|
386
389
|
}
|
|
387
390
|
for (const [key, value] of Object.entries(rootData)) {
|
|
@@ -389,8 +392,23 @@ function classifyData(data) {
|
|
|
389
392
|
}
|
|
390
393
|
return result;
|
|
391
394
|
}
|
|
395
|
+
function readOverallConfidence(source) {
|
|
396
|
+
const rawLevel = source.overall_confidence ?? source.overallConfidence;
|
|
397
|
+
const value = extractValue(rawLevel);
|
|
398
|
+
if (typeof value !== "string" || value.length === 0) return null;
|
|
399
|
+
const rawReasons = source.confidence_reasons ?? source.confidenceReasons;
|
|
400
|
+
const reasons = Array.isArray(rawReasons) ? rawReasons.filter((reason) => typeof reason === "string") : [];
|
|
401
|
+
return { level: value, reasons };
|
|
402
|
+
}
|
|
392
403
|
function processField(key, value, result, parentObj, basePointer) {
|
|
393
|
-
if ([
|
|
404
|
+
if ([
|
|
405
|
+
"confidence",
|
|
406
|
+
"confidence_reasons",
|
|
407
|
+
"confidenceReasons",
|
|
408
|
+
"coordinates",
|
|
409
|
+
"overall_confidence",
|
|
410
|
+
"overallConfidence"
|
|
411
|
+
].includes(key)) {
|
|
394
412
|
return;
|
|
395
413
|
}
|
|
396
414
|
const pointer = `${basePointer}/${escapeSegment(key)}`;
|
|
@@ -464,11 +482,6 @@ function processField(key, value, result, parentObj, basePointer) {
|
|
|
464
482
|
level: parentObj[confidenceKey],
|
|
465
483
|
reasons: parentObj[reasonsKey] || []
|
|
466
484
|
};
|
|
467
|
-
} else if (parentObj["overall_confidence"]) {
|
|
468
|
-
overallConfidence = {
|
|
469
|
-
level: parentObj["overall_confidence"],
|
|
470
|
-
reasons: parentObj["confidence_reasons"] || []
|
|
471
|
-
};
|
|
472
485
|
}
|
|
473
486
|
}
|
|
474
487
|
result.tables.push({
|
|
@@ -797,8 +810,11 @@ function planTableCells(table, plan, columns, bindingsByRawKey) {
|
|
|
797
810
|
}
|
|
798
811
|
function displayColumns(table, classifiedColumns) {
|
|
799
812
|
const declared = table.columns.map((column) => column.key).filter((name) => typeof name === "string");
|
|
800
|
-
const
|
|
801
|
-
return [
|
|
813
|
+
const declaredAliases = new Set(declared.map(snakeToCamel));
|
|
814
|
+
return [
|
|
815
|
+
...declared,
|
|
816
|
+
...classifiedColumns.filter((name) => !declaredAliases.has(snakeToCamel(name)))
|
|
817
|
+
];
|
|
802
818
|
}
|
|
803
819
|
function matchesTablePointer(serverPointer, classifiedPointer) {
|
|
804
820
|
return serverPointer === classifiedPointer || snakeToCamel(serverPointer) === classifiedPointer;
|
|
@@ -1242,6 +1258,7 @@ function VerificationViewer(props) {
|
|
|
1242
1258
|
const [magnifierOn, setMagnifierOn] = (0, import_react2.useState)(false);
|
|
1243
1259
|
const [showMag, setShowMag] = (0, import_react2.useState)(false);
|
|
1244
1260
|
const [mousePos, setMousePos] = (0, import_react2.useState)({ x: 0, y: 0 });
|
|
1261
|
+
const lastMouseClientRef = (0, import_react2.useRef)(null);
|
|
1245
1262
|
const [isPanning, setIsPanning] = (0, import_react2.useState)(false);
|
|
1246
1263
|
const panStart = (0, import_react2.useRef)(null);
|
|
1247
1264
|
const [flashOpacity, setFlashOpacity] = (0, import_react2.useState)(0);
|
|
@@ -1426,15 +1443,38 @@ function VerificationViewer(props) {
|
|
|
1426
1443
|
const handleTouchEnd = (0, import_react2.useCallback)((e) => {
|
|
1427
1444
|
if (e.touches.length === 0) touchState.current = null;
|
|
1428
1445
|
}, []);
|
|
1429
|
-
const
|
|
1446
|
+
const syncMagnifierToClientPoint = (0, import_react2.useCallback)((clientX, clientY, assumeInside = false) => {
|
|
1430
1447
|
const rect = canvasRef.current?.getBoundingClientRect();
|
|
1431
1448
|
if (!rect) return;
|
|
1432
|
-
|
|
1433
|
-
|
|
1449
|
+
const x = clientX - rect.left;
|
|
1450
|
+
const y = clientY - rect.top;
|
|
1451
|
+
const inside = assumeInside || x >= 0 && y >= 0 && x <= rect.width && y <= rect.height;
|
|
1452
|
+
setShowMag(inside);
|
|
1453
|
+
if (inside) {
|
|
1454
|
+
setMousePos({ x, y });
|
|
1455
|
+
}
|
|
1434
1456
|
}, []);
|
|
1457
|
+
const handleCanvasMouseMove = (0, import_react2.useCallback)((e) => {
|
|
1458
|
+
lastMouseClientRef.current = { x: e.clientX, y: e.clientY };
|
|
1459
|
+
syncMagnifierToClientPoint(e.clientX, e.clientY, true);
|
|
1460
|
+
}, [syncMagnifierToClientPoint]);
|
|
1435
1461
|
const handleCanvasMouseLeave = (0, import_react2.useCallback)(() => {
|
|
1462
|
+
lastMouseClientRef.current = null;
|
|
1436
1463
|
setShowMag(false);
|
|
1437
1464
|
}, []);
|
|
1465
|
+
(0, import_react2.useEffect)(() => {
|
|
1466
|
+
if (!magnifierOn || !showMag) return;
|
|
1467
|
+
const sync = () => {
|
|
1468
|
+
const point = lastMouseClientRef.current;
|
|
1469
|
+
if (point) syncMagnifierToClientPoint(point.x, point.y);
|
|
1470
|
+
};
|
|
1471
|
+
document.addEventListener("scroll", sync, true);
|
|
1472
|
+
window.addEventListener("resize", sync);
|
|
1473
|
+
return () => {
|
|
1474
|
+
document.removeEventListener("scroll", sync, true);
|
|
1475
|
+
window.removeEventListener("resize", sync);
|
|
1476
|
+
};
|
|
1477
|
+
}, [magnifierOn, showMag, syncMagnifierToClientPoint]);
|
|
1438
1478
|
const handleDoubleClick = (0, import_react2.useCallback)(
|
|
1439
1479
|
(e) => {
|
|
1440
1480
|
cancelFlashTravel();
|
|
@@ -1981,7 +2021,10 @@ function TableRowView(props) {
|
|
|
1981
2021
|
[rects, onFlash]
|
|
1982
2022
|
);
|
|
1983
2023
|
const cellFor = (column) => {
|
|
1984
|
-
const
|
|
2024
|
+
const direct = row?.[column];
|
|
2025
|
+
const alias = direct === void 0 ? row?.[snakeToCamel(column)] : void 0;
|
|
2026
|
+
const fallbackKey = direct === void 0 && alias === void 0 && row !== void 0 ? Object.keys(row).find((key) => snakeToCamel(key) === snakeToCamel(column)) : void 0;
|
|
2027
|
+
const classified = direct ?? alias ?? (fallbackKey === void 0 ? void 0 : row?.[fallbackKey]);
|
|
1985
2028
|
const fromPlan = planned?.cells.find((cell) => cell.column === column);
|
|
1986
2029
|
if (fromPlan) {
|
|
1987
2030
|
return { classified, binding: fromPlan.binding, editKey: fromPlan.editKey };
|
|
@@ -2138,7 +2181,10 @@ function TableSection(props) {
|
|
|
2138
2181
|
needsReview > 0 ? ` \xB7 ${needsReview} need review` : "",
|
|
2139
2182
|
")"
|
|
2140
2183
|
] }),
|
|
2141
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.
|
|
2184
|
+
table.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "gemina-verification__overall-confidence", children: [
|
|
2185
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Overall confidence" }),
|
|
2186
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: table.overallConfidence })
|
|
2187
|
+
] }) : null
|
|
2142
2188
|
] }),
|
|
2143
2189
|
/* @__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: [
|
|
2144
2190
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("tr", { children: [
|
|
@@ -2272,6 +2318,10 @@ function VerificationForm(props) {
|
|
|
2272
2318
|
"aria-label": "Extraction fields",
|
|
2273
2319
|
onSubmit: (event) => event.preventDefault(),
|
|
2274
2320
|
children: [
|
|
2321
|
+
classified.overallConfidence ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "gemina-verification__confidence-summary", children: [
|
|
2322
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Overall confidence" }),
|
|
2323
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ConfidenceDot, { confidence: classified.overallConfidence })
|
|
2324
|
+
] }) : null,
|
|
2275
2325
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2276
2326
|
HeaderSection,
|
|
2277
2327
|
{
|
|
@@ -2291,7 +2341,7 @@ function VerificationForm(props) {
|
|
|
2291
2341
|
}
|
|
2292
2342
|
|
|
2293
2343
|
// src/version.ts
|
|
2294
|
-
var VERSION = "0.
|
|
2344
|
+
var VERSION = "0.10.0";
|
|
2295
2345
|
|
|
2296
2346
|
// src/verification/styles.ts
|
|
2297
2347
|
var DARK_VARS = `
|
|
@@ -2393,9 +2443,15 @@ var VERIFICATION_CSS = `
|
|
|
2393
2443
|
background: var(--gemina-verification-bg);
|
|
2394
2444
|
border: 1px solid var(--gemina-verification-border);
|
|
2395
2445
|
border-radius: var(--gemina-verification-radius);
|
|
2396
|
-
overflow
|
|
2446
|
+
/* overflow hidden creates a scroll container and prevents the toolbar's sticky
|
|
2447
|
+
positioning from following the host modal's scrollport. Clip keeps the
|
|
2448
|
+
rounded frame without stealing sticky containment. */
|
|
2449
|
+
overflow: clip;
|
|
2397
2450
|
}
|
|
2398
2451
|
.gemina-verification__toolbar {
|
|
2452
|
+
position: sticky;
|
|
2453
|
+
top: 0;
|
|
2454
|
+
z-index: 5;
|
|
2399
2455
|
display: flex;
|
|
2400
2456
|
/* Narrow roots (~<330px) can't fit all 7 buttons on one line: wrap to a
|
|
2401
2457
|
second row instead of clipping past the canvas edge. The gap shorthand
|
|
@@ -2405,6 +2461,7 @@ var VERIFICATION_CSS = `
|
|
|
2405
2461
|
gap: 6px;
|
|
2406
2462
|
flex: 0 0 auto;
|
|
2407
2463
|
padding: 8px 10px;
|
|
2464
|
+
background: var(--gemina-verification-bg);
|
|
2408
2465
|
border-block-end: 1px solid var(--gemina-verification-border);
|
|
2409
2466
|
}
|
|
2410
2467
|
.gemina-verification__toolbar-btn {
|
|
@@ -2515,6 +2572,19 @@ var VERIFICATION_CSS = `
|
|
|
2515
2572
|
min-width: 0;
|
|
2516
2573
|
margin: 0;
|
|
2517
2574
|
}
|
|
2575
|
+
.gemina-verification__confidence-summary {
|
|
2576
|
+
display: flex;
|
|
2577
|
+
align-items: center;
|
|
2578
|
+
justify-content: space-between;
|
|
2579
|
+
gap: 12px;
|
|
2580
|
+
padding: 9px 12px;
|
|
2581
|
+
background: var(--gemina-verification-surface);
|
|
2582
|
+
border: 1px solid var(--gemina-verification-border);
|
|
2583
|
+
border-radius: var(--gemina-verification-radius);
|
|
2584
|
+
color: var(--gemina-verification-muted);
|
|
2585
|
+
font-size: 12px;
|
|
2586
|
+
font-weight: 600;
|
|
2587
|
+
}
|
|
2518
2588
|
.gemina-verification__section {
|
|
2519
2589
|
background: var(--gemina-verification-bg);
|
|
2520
2590
|
border: 1px solid var(--gemina-verification-border);
|
|
@@ -2531,6 +2601,16 @@ var VERIFICATION_CSS = `
|
|
|
2531
2601
|
font-size: 13px;
|
|
2532
2602
|
font-weight: 600;
|
|
2533
2603
|
}
|
|
2604
|
+
.gemina-verification__overall-confidence {
|
|
2605
|
+
display: inline-flex;
|
|
2606
|
+
align-items: center;
|
|
2607
|
+
gap: 6px;
|
|
2608
|
+
margin-inline-start: auto;
|
|
2609
|
+
color: var(--gemina-verification-muted);
|
|
2610
|
+
font-size: 11px;
|
|
2611
|
+
font-weight: 500;
|
|
2612
|
+
white-space: nowrap;
|
|
2613
|
+
}
|
|
2534
2614
|
.gemina-verification__dl {
|
|
2535
2615
|
display: grid;
|
|
2536
2616
|
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
|
@@ -2573,6 +2653,15 @@ var VERIFICATION_CSS = `
|
|
|
2573
2653
|
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
2574
2654
|
padding: 5px 8px;
|
|
2575
2655
|
}
|
|
2656
|
+
/* FieldInput is a fragment. Let its control take the remaining row width
|
|
2657
|
+
instead of forcing width:100%, so a coordinate eye can sit beside it rather
|
|
2658
|
+
than wrapping onto a visually disconnected second line. */
|
|
2659
|
+
.gemina-verification__dd > .gemina-verification__input,
|
|
2660
|
+
.gemina-verification__cell > .gemina-verification__input {
|
|
2661
|
+
flex: 1 1 8ch;
|
|
2662
|
+
width: auto;
|
|
2663
|
+
min-width: 0;
|
|
2664
|
+
}
|
|
2576
2665
|
.gemina-verification__input--dirty { border-color: var(--gemina-verification-dirty); }
|
|
2577
2666
|
.gemina-verification__input--missed {
|
|
2578
2667
|
border-color: var(--gemina-verification-error);
|
|
@@ -2943,7 +3032,7 @@ var VERIFICATION_CSS = `
|
|
|
2943
3032
|
}
|
|
2944
3033
|
.gemina-verification__table-footer {
|
|
2945
3034
|
display: flex;
|
|
2946
|
-
padding: 8px 10px
|
|
3035
|
+
padding: 8px 10px;
|
|
2947
3036
|
}
|
|
2948
3037
|
.gemina-verification__add-row {
|
|
2949
3038
|
font: inherit;
|