@gemina/elements 0.9.0 → 0.11.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-DU6BUHR5.js → chunk-7XA4RNXK.js} +2 -2
- package/dist/{chunk-MITACKUW.js → chunk-L2B4OV3P.js} +156 -19
- package/dist/chunk-L2B4OV3P.js.map +1 -0
- package/dist/{chunk-S4KBJRIP.js → chunk-XII4IQNS.js} +2 -2
- package/dist/{chunk-S4KBJRIP.js.map → chunk-XII4IQNS.js.map} +1 -1
- package/dist/index.cjs +155 -18
- 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 +155 -18
- 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-7XA4RNXK.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-7XA4RNXK.js";
|
|
7
7
|
import {
|
|
8
8
|
GeminaVerification
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-L2B4OV3P.js";
|
|
10
10
|
import {
|
|
11
11
|
VERSION
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XII4IQNS.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.11.0";
|
|
2295
2345
|
|
|
2296
2346
|
// src/verification/styles.ts
|
|
2297
2347
|
var DARK_VARS = `
|
|
@@ -2348,6 +2398,27 @@ var VERIFICATION_CSS = `
|
|
|
2348
2398
|
.gemina-verification--auto { ${DARK_VARS} }
|
|
2349
2399
|
}
|
|
2350
2400
|
.gemina-verification--rtl { direction: rtl; }
|
|
2401
|
+
/* Content is not chrome: the document pane never mirrors (industry rule \u2014
|
|
2402
|
+
images/players/clocks keep their physical position under RTL), and dir="auto"
|
|
2403
|
+
flips per DOCUMENT, so mirroring would make the image jump side per row.
|
|
2404
|
+
Forcing the grid container LTR pins physical order (image inline-left, form
|
|
2405
|
+
right, every language); the form pane alone restores RTL so Hebrew labels
|
|
2406
|
+
and values keep their natural direction (per-input dir="auto" still handles
|
|
2407
|
+
mixed-language values). The viewer subtree deliberately stays LTR: it is
|
|
2408
|
+
pure geometry (scroll math, loupe projection, absolute positioning) and none
|
|
2409
|
+
of that math may be direction-dependent.
|
|
2410
|
+
|
|
2411
|
+
That last point is not theoretical \u2014 it IS the magnifier bug. The loupe's
|
|
2412
|
+
magnified inner layer is absolutely positioned with no inset (viewer.tsx
|
|
2413
|
+
gives it only a transform), so its static position is wherever the inherited
|
|
2414
|
+
direction puts the inline start. Under RTL that flips to the right edge and
|
|
2415
|
+
the layer lands (layerWidth - loupeWidth) away \u2014 measured as a constant
|
|
2416
|
+
-704px skew in BOTH chromium and firefox, at every pointer position, leaving
|
|
2417
|
+
the user an empty circle rather than a shifted one. Pinning this subtree LTR
|
|
2418
|
+
restores the skew to (0, 0), matching the LTR baseline exactly. Do not
|
|
2419
|
+
"simplify" this by mirroring the panes again. */
|
|
2420
|
+
.gemina-verification--rtl .gemina-verification__panes { direction: ltr; }
|
|
2421
|
+
.gemina-verification--rtl .gemina-verification__form { direction: rtl; }
|
|
2351
2422
|
|
|
2352
2423
|
/* --- Two-pane layout ------------------------------------------------------ */
|
|
2353
2424
|
.gemina-verification__panes {
|
|
@@ -2393,9 +2464,15 @@ var VERIFICATION_CSS = `
|
|
|
2393
2464
|
background: var(--gemina-verification-bg);
|
|
2394
2465
|
border: 1px solid var(--gemina-verification-border);
|
|
2395
2466
|
border-radius: var(--gemina-verification-radius);
|
|
2396
|
-
overflow
|
|
2467
|
+
/* overflow hidden creates a scroll container and prevents the toolbar's sticky
|
|
2468
|
+
positioning from following the host modal's scrollport. Clip keeps the
|
|
2469
|
+
rounded frame without stealing sticky containment. */
|
|
2470
|
+
overflow: clip;
|
|
2397
2471
|
}
|
|
2398
2472
|
.gemina-verification__toolbar {
|
|
2473
|
+
position: sticky;
|
|
2474
|
+
top: 0;
|
|
2475
|
+
z-index: 5;
|
|
2399
2476
|
display: flex;
|
|
2400
2477
|
/* Narrow roots (~<330px) can't fit all 7 buttons on one line: wrap to a
|
|
2401
2478
|
second row instead of clipping past the canvas edge. The gap shorthand
|
|
@@ -2405,6 +2482,7 @@ var VERIFICATION_CSS = `
|
|
|
2405
2482
|
gap: 6px;
|
|
2406
2483
|
flex: 0 0 auto;
|
|
2407
2484
|
padding: 8px 10px;
|
|
2485
|
+
background: var(--gemina-verification-bg);
|
|
2408
2486
|
border-block-end: 1px solid var(--gemina-verification-border);
|
|
2409
2487
|
}
|
|
2410
2488
|
.gemina-verification__toolbar-btn {
|
|
@@ -2514,6 +2592,28 @@ var VERIFICATION_CSS = `
|
|
|
2514
2592
|
gap: 12px;
|
|
2515
2593
|
min-width: 0;
|
|
2516
2594
|
margin: 0;
|
|
2595
|
+
/* Every z-index inside the form is form-internal business, and nothing in
|
|
2596
|
+
here may ever paint over the document. Without a stacking context of its
|
|
2597
|
+
own, the form's descendants resolve against the SAME context as the
|
|
2598
|
+
stacked-mode viewer (position: sticky, z-index: 2) \u2014 so the sticky header
|
|
2599
|
+
row (z-index: 3) painted straight over the document image as the form
|
|
2600
|
+
scrolled under the floating viewer. Confirmed in chromium and firefox
|
|
2601
|
+
before this line existed. Isolating caps the whole subtree beneath the
|
|
2602
|
+
viewer no matter what numbers it uses later. */
|
|
2603
|
+
isolation: isolate;
|
|
2604
|
+
}
|
|
2605
|
+
.gemina-verification__confidence-summary {
|
|
2606
|
+
display: flex;
|
|
2607
|
+
align-items: center;
|
|
2608
|
+
justify-content: space-between;
|
|
2609
|
+
gap: 12px;
|
|
2610
|
+
padding: 9px 12px;
|
|
2611
|
+
background: var(--gemina-verification-surface);
|
|
2612
|
+
border: 1px solid var(--gemina-verification-border);
|
|
2613
|
+
border-radius: var(--gemina-verification-radius);
|
|
2614
|
+
color: var(--gemina-verification-muted);
|
|
2615
|
+
font-size: 12px;
|
|
2616
|
+
font-weight: 600;
|
|
2517
2617
|
}
|
|
2518
2618
|
.gemina-verification__section {
|
|
2519
2619
|
background: var(--gemina-verification-bg);
|
|
@@ -2531,6 +2631,16 @@ var VERIFICATION_CSS = `
|
|
|
2531
2631
|
font-size: 13px;
|
|
2532
2632
|
font-weight: 600;
|
|
2533
2633
|
}
|
|
2634
|
+
.gemina-verification__overall-confidence {
|
|
2635
|
+
display: inline-flex;
|
|
2636
|
+
align-items: center;
|
|
2637
|
+
gap: 6px;
|
|
2638
|
+
margin-inline-start: auto;
|
|
2639
|
+
color: var(--gemina-verification-muted);
|
|
2640
|
+
font-size: 11px;
|
|
2641
|
+
font-weight: 500;
|
|
2642
|
+
white-space: nowrap;
|
|
2643
|
+
}
|
|
2534
2644
|
.gemina-verification__dl {
|
|
2535
2645
|
display: grid;
|
|
2536
2646
|
grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
|
|
@@ -2573,6 +2683,15 @@ var VERIFICATION_CSS = `
|
|
|
2573
2683
|
border-radius: calc(var(--gemina-verification-radius) - 4px);
|
|
2574
2684
|
padding: 5px 8px;
|
|
2575
2685
|
}
|
|
2686
|
+
/* FieldInput is a fragment. Let its control take the remaining row width
|
|
2687
|
+
instead of forcing width:100%, so a coordinate eye can sit beside it rather
|
|
2688
|
+
than wrapping onto a visually disconnected second line. */
|
|
2689
|
+
.gemina-verification__dd > .gemina-verification__input,
|
|
2690
|
+
.gemina-verification__cell > .gemina-verification__input {
|
|
2691
|
+
flex: 1 1 8ch;
|
|
2692
|
+
width: auto;
|
|
2693
|
+
min-width: 0;
|
|
2694
|
+
}
|
|
2576
2695
|
.gemina-verification__input--dirty { border-color: var(--gemina-verification-dirty); }
|
|
2577
2696
|
.gemina-verification__input--missed {
|
|
2578
2697
|
border-color: var(--gemina-verification-error);
|
|
@@ -2644,14 +2763,32 @@ var VERIFICATION_CSS = `
|
|
|
2644
2763
|
padding: 0;
|
|
2645
2764
|
list-style: none;
|
|
2646
2765
|
}
|
|
2647
|
-
.gemina-verification__table-wrap {
|
|
2766
|
+
.gemina-verification__table-wrap {
|
|
2767
|
+
overflow-x: auto;
|
|
2768
|
+
/* Sticky binds to the nearest scrollport, and in an embedded widget that
|
|
2769
|
+
must be THIS wrapper (no per-host offset math). Bounding the block size
|
|
2770
|
+
turns it into a vertical scrollport too: long tables scroll internally
|
|
2771
|
+
with the header row pinned; short tables never reach the cap and are
|
|
2772
|
+
unchanged. */
|
|
2773
|
+
overflow-y: auto;
|
|
2774
|
+
max-block-size: min(56vh, 520px);
|
|
2775
|
+
}
|
|
2648
2776
|
.gemina-verification__table {
|
|
2649
2777
|
width: 100%;
|
|
2650
|
-
|
|
2778
|
+
/* separate, not collapse: collapsed borders belong to the row grid, so a
|
|
2779
|
+
stuck header sheds its underline mid-scroll. With separate borders the
|
|
2780
|
+
border-block-end travels with the th. */
|
|
2781
|
+
border-collapse: separate;
|
|
2782
|
+
border-spacing: 0;
|
|
2651
2783
|
font-size: 13px;
|
|
2652
2784
|
font-variant-numeric: tabular-nums;
|
|
2653
2785
|
}
|
|
2654
2786
|
.gemina-verification__table th {
|
|
2787
|
+
position: sticky;
|
|
2788
|
+
inset-block-start: 0;
|
|
2789
|
+
/* Above cell content and focus rings; below the viewer toolbar (5) and the
|
|
2790
|
+
confirm scrim. */
|
|
2791
|
+
z-index: 3;
|
|
2655
2792
|
text-align: start;
|
|
2656
2793
|
padding: 6px 10px;
|
|
2657
2794
|
font-size: 12px;
|
|
@@ -2943,7 +3080,7 @@ var VERIFICATION_CSS = `
|
|
|
2943
3080
|
}
|
|
2944
3081
|
.gemina-verification__table-footer {
|
|
2945
3082
|
display: flex;
|
|
2946
|
-
padding: 8px 10px
|
|
3083
|
+
padding: 8px 10px;
|
|
2947
3084
|
}
|
|
2948
3085
|
.gemina-verification__add-row {
|
|
2949
3086
|
font: inherit;
|