veryfi-lens-wasm 3.5.1 → 3.5.3

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 CHANGED
@@ -110,6 +110,7 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
110
110
  |---|---|---|---|
111
111
  | `lensFlavor` | `string` | — | **Required.** Capture mode (see [Supported Flavors](#supported-flavors)) |
112
112
  | `container` | `string` | — | ID of an HTML element to render into. If omitted, creates a fullscreen overlay |
113
+ | `theme` | `"light"\|"dark"\|"system"` | `"system"` | UI color theme. `"system"` follows OS changes while the lens is open |
113
114
  | `enableSubmit` | `boolean` | `true` | Show submit button after capture |
114
115
  | `enableFullScreen` | `boolean` | `false` | Enable fullscreen mode |
115
116
  | `debug_mode` | `boolean` | `false` | Enable console logging |
@@ -199,6 +200,8 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
199
200
 
200
201
  After each accepted capture, the `document`, `anydocs`, and `prescription_label` flavors show a unified **review gallery** where the user can review, retake, delete, add pages/documents, and submit. For single-document/single-page captures it collapses to a simple Retake / Submit preview. On submit, one package (a zip of its pages) is uploaded per document via `/api/document`, then `finishBatch()` runs.
201
202
 
203
+ When `multiSubmission` is set or `maxDocuments` is not `1`, `init()` asks the backend for a reusable session so every document in the batch can be posted with it; `finishBatch()` then releases that session once the last document is submitted.
204
+
202
205
  | Option | Type | Default | Description |
203
206
  |---|---|---|---|
204
207
  | `maxPagesPerDocument` | `number\|null` | flavor-specific | Max pages per document (`null` = unlimited). `1` hides "Add Page". Defaults: document `1`, anydocs `null`, prescription boxes = box max sides |
@@ -210,6 +213,9 @@ After each accepted capture, the `document`, `anydocs`, and `prescription_label`
210
213
  | `reviewDoneText` | `string` | `"Done"` | Done action text |
211
214
  | `reviewRetakeText` | `string` | `"Retake"` | Retake action text |
212
215
  | `reviewDeleteText` | `string` | `"Delete"` | Delete action text |
216
+ | `reviewShowQualityBadges` | `boolean` | `true` | Badge pages that failed a quality check. Applies to multi-document frames, which are committed with the failing pages flagged instead of blocked |
217
+ | `reviewIssueBlurText` | `string` | `"Blurry"` | Badge text for a blurry page |
218
+ | `reviewIssueLcdText` | `string` | `"Screen"` | Badge text for a screen/LCD page |
213
219
  | `reviewSubmitButtonColor` | `string` | `"#00AA00"` | Submit button color (also used as the crop editor accent) |
214
220
  | `reviewSubmitButtonTextColor` | `string` | `"#FFFFFF"` | Submit button text color (also the crop editor Apply button) |
215
221
 
@@ -1,4 +1,5 @@
1
1
  import { ensureSpinKeyframes, releaseSpinKeyframes } from './shared-styles.js';
2
+ import { LIQUID_GLASS } from './liquid-glass.js';
2
3
 
3
4
  export const createBlueprintsModal = (container, onSelect, onClose, options = {}) => {
4
5
  const modal = document.createElement('div');
@@ -19,14 +20,14 @@ export const createBlueprintsModal = (container, onSelect, onClose, options = {}
19
20
  };
20
21
 
21
22
  const contentStyles = {
22
- backgroundColor: 'white',
23
+ backgroundColor: LIQUID_GLASS.panelBackground,
23
24
  borderRadius: '16px',
24
25
  padding: '24px 28px',
25
26
  maxWidth: '400px',
26
27
  width: '90%',
27
28
  maxHeight: '80vh',
28
29
  overflow: 'auto',
29
- textColor: '#1e293b',
30
+ textColor: LIQUID_GLASS.panelText,
30
31
  textFontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
31
32
  textFontSize: '17px',
32
33
  buttonPadding: '14px 24px',
@@ -36,12 +37,12 @@ export const createBlueprintsModal = (container, onSelect, onClose, options = {}
36
37
  buttonFontWeight: '700',
37
38
  primaryButtonBackground: '#00AA00',
38
39
  primaryButtonColor: 'white',
39
- secondaryButtonBackground: 'transparent',
40
- secondaryButtonBorder: '1px solid #333',
41
- secondaryButtonColor: '#333',
42
- itemBackground: '#f8f9fa',
43
- itemHoverBackground: '#e9ecef',
44
- itemSelectedBackground: '#d4edda',
40
+ secondaryButtonBackground: LIQUID_GLASS.secondaryBackground,
41
+ secondaryButtonBorder: LIQUID_GLASS.secondaryBorder,
42
+ secondaryButtonColor: LIQUID_GLASS.panelText,
43
+ itemBackground: 'var(--veryfi-blueprint-item-background, #f8f9fa)',
44
+ itemHoverBackground: 'var(--veryfi-blueprint-item-hover, #e9ecef)',
45
+ itemSelectedBackground: 'var(--veryfi-blueprint-item-selected, #d4edda)',
45
46
  itemBorderRadius: '6px',
46
47
  };
47
48
 
@@ -82,7 +83,7 @@ export const createBlueprintsModal = (container, onSelect, onClose, options = {}
82
83
  <div style="
83
84
  width: 40px;
84
85
  height: 40px;
85
- border: 3px solid #f3f3f3;
86
+ border: 3px solid var(--veryfi-review-border, #f3f3f3);
86
87
  border-top: 3px solid ${contentStyles.primaryButtonBackground};
87
88
  border-radius: 50%;
88
89
  margin: 20px auto;
@@ -1,3 +1,4 @@
1
+ export const CAPTURE_BUTTON_BACKGROUND = 'var(--capture-button-background-color, #FFFFFF)';
1
2
  export const createCaptureButton = (container, onCapture, onStopStitching) => {
2
3
  const button = document.createElement('button');
3
4
  button.id = 'veryfi-capture-button';
@@ -50,7 +51,7 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
50
51
  });
51
52
 
52
53
  button.addEventListener('mouseleave', () => {
53
- button.style.backgroundColor = 'var(--capture-button-background-color, #FFFFFF)';
54
+ button.style.backgroundColor = CAPTURE_BUTTON_BACKGROUND;
54
55
  });
55
56
 
56
57
  let isStitching = false;
@@ -14,8 +14,8 @@ export const createCheckOverlay = (container, options = {}) => {
14
14
  const tipFontFamily = options.tipFontFamily || "Arial, sans-serif";
15
15
  const tipFontSize = options.tipFontSize || "16px";
16
16
  const tipFontWeight = options.tipFontWeight || "bold";
17
- const tipColor = options.tipColor || "white";
18
- const tipTextShadow = options.tipTextShadow || "0 1px 2px rgba(0,0,0,0.8)";
17
+ const tipColor = options.tipColor || "var(--veryfi-panel-text, #1e293b)";
18
+ const tipTextShadow = options.tipTextShadow || "none";
19
19
  const tipOffset = options.tipOffset || "35%";
20
20
 
21
21
  const rectHole = document.createElement("div");
@@ -116,11 +116,9 @@ export const createCheckOverlay = (container, options = {}) => {
116
116
  zIndex: "1004",
117
117
  textShadow: tipTextShadow,
118
118
  whiteSpace: "nowrap",
119
- backgroundColor: "rgba(255, 255, 255, 0.85)",
120
- color: "#333",
119
+ backgroundColor: "var(--veryfi-panel-background, rgba(255, 255, 255, 0.85))",
121
120
  padding: "6px 14px",
122
121
  borderRadius: "20px",
123
- textShadow: "none",
124
122
  });
125
123
 
126
124
  switch (tipPosition) {
@@ -26,10 +26,10 @@ export function createFileUpload(container, captureUploaded, onSubmit, options =
26
26
  uploadZoneWidth: '500px',
27
27
  uploadZoneMaxWidth: '500px',
28
28
  uploadZoneHeight: '100px',
29
- uploadZoneBorder: '2px dashed #ccc',
29
+ uploadZoneBorder: '2px dashed var(--veryfi-upload-zone-border, #ccc)',
30
30
  uploadZoneBorderRadius: '5px',
31
- uploadZoneBackgroundColor: 'rgba(255, 255, 255, 0.8)',
32
- uploadZoneColor: 'black',
31
+ uploadZoneBackgroundColor: 'var(--veryfi-upload-zone-background, rgba(255, 255, 255, 0.8))',
32
+ uploadZoneColor: 'var(--veryfi-upload-zone-text, black)',
33
33
  uploadZoneFontFamily: 'sans-serif',
34
34
  buttonPadding: '10px 20px',
35
35
  buttonBackgroundColor: '#4CAF50',
@@ -1,4 +1,5 @@
1
1
  import { LIQUID_GLASS } from './liquid-glass.js';
2
+ import { registerThemedElement } from '../core/theme.js';
2
3
 
3
4
  const WIDE_VIEWPORT_THRESHOLD = 900;
4
5
  const MODAL_ID = 'veryfi-desktop-mode-modal';
@@ -66,7 +67,7 @@ const ensureStyles = () => {
66
67
  background: ${LIQUID_GLASS.darkPanelBackground};
67
68
  backdrop-filter: ${LIQUID_GLASS.blur};
68
69
  -webkit-backdrop-filter: ${LIQUID_GLASS.blur};
69
- color: #ffffff;
70
+ color: ${LIQUID_GLASS.panelText};
70
71
  border-radius: 20px;
71
72
  border: ${LIQUID_GLASS.darkBorder};
72
73
  box-shadow: ${LIQUID_GLASS.darkPanelBoxShadow};
@@ -85,7 +86,7 @@ const ensureStyles = () => {
85
86
  border-radius: 999px;
86
87
  border: none;
87
88
  background: transparent;
88
- color: #94a3b8;
89
+ color: ${LIQUID_GLASS.panelMutedText};
89
90
  cursor: pointer;
90
91
  padding: 0;
91
92
  transition: background-color 0.15s, color 0.15s;
@@ -116,7 +117,7 @@ const ensureStyles = () => {
116
117
  #${MODAL_ID} .veryfi-dm-body {
117
118
  font-size: 14px;
118
119
  line-height: 1.5;
119
- color: #cbd5e1;
120
+ color: ${LIQUID_GLASS.panelMutedText};
120
121
  margin: 0 0 20px 0;
121
122
  }
122
123
  #${MODAL_ID} .veryfi-dm-reload {
@@ -175,6 +176,7 @@ const ensureStyles = () => {
175
176
  const createModalNode = () => {
176
177
  const root = document.createElement('div');
177
178
  root.id = MODAL_ID;
179
+ registerThemedElement(root);
178
180
  root.setAttribute('role', 'dialog');
179
181
  root.setAttribute('aria-modal', 'true');
180
182
  root.innerHTML = `
@@ -4,25 +4,26 @@
4
4
 
5
5
  export const LIQUID_GLASS = {
6
6
  // Translucent fill for dark-on-camera controls (idle / hover / active).
7
- backgroundColor: 'rgba(255, 255, 255, 0.12)',
8
- hoverBackgroundColor: 'rgba(255, 255, 255, 0.24)',
9
- activeBackgroundColor: 'rgba(255, 255, 255, 0.34)',
10
- // Frosted panel fill for light modals (dark content sits on top).
11
- panelBackground: 'rgba(250, 250, 252, 0.72)',
12
- // Dark frosted panel fill for warning / system modals.
13
- darkPanelBackground: 'rgba(30, 41, 59, 0.72)',
7
+ backgroundColor: 'var(--veryfi-control-background, rgba(255, 255, 255, 0.12))',
8
+ hoverBackgroundColor: 'var(--veryfi-control-hover-background, rgba(255, 255, 255, 0.24))',
9
+ activeBackgroundColor: 'var(--veryfi-control-active-background, rgba(255, 255, 255, 0.34))',
10
+ // Theme-aware frosted panel colors.
11
+ panelBackground: 'var(--veryfi-panel-background, rgba(250, 250, 252, 0.88))',
12
+ darkPanelBackground: 'var(--veryfi-panel-background, rgba(30, 41, 59, 0.88))',
13
+ panelText: 'var(--veryfi-panel-text, #1e293b)',
14
+ panelMutedText: 'var(--veryfi-panel-muted-text, #475569)',
15
+ secondaryBackground: 'var(--veryfi-panel-secondary-background, rgba(255, 255, 255, 0.45))',
16
+ secondaryBorder: 'var(--veryfi-panel-secondary-border, 1px solid rgba(0, 0, 0, 0.12))',
14
17
  // Heavy blur + saturation is what produces the "liquid" refraction.
15
18
  blur: 'blur(18px) saturate(180%)',
16
19
  // Bright hairline edge.
17
- border: '1px solid rgba(255, 255, 255, 0.5)',
18
- darkBorder: '1px solid rgba(255, 255, 255, 0.14)',
20
+ border: 'var(--veryfi-panel-border, 1px solid rgba(255, 255, 255, 0.5))',
21
+ darkBorder: 'var(--veryfi-panel-border, 1px solid rgba(255, 255, 255, 0.14))',
19
22
  // Outer float shadow + inner specular highlights (bright top, soft bottom).
20
23
  boxShadow:
21
24
  '0 8px 32px rgba(0, 0, 0, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.65), inset 0 -2px 6px rgba(255, 255, 255, 0.12)',
22
- panelBoxShadow:
23
- '0 16px 48px rgba(0, 0, 0, 0.28), inset 0 1px 1px rgba(255, 255, 255, 0.85), inset 0 -2px 8px rgba(255, 255, 255, 0.22)',
24
- darkPanelBoxShadow:
25
- '0 16px 48px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.22), inset 0 -2px 8px rgba(0, 0, 0, 0.25)',
25
+ panelBoxShadow: 'var(--veryfi-panel-shadow, 0 16px 48px rgba(0, 0, 0, 0.28))',
26
+ darkPanelBoxShadow: 'var(--veryfi-panel-shadow, 0 16px 48px rgba(0, 0, 0, 0.45))',
26
27
  };
27
28
 
28
29
  // Inline-style fragment for on-camera glass controls (buttons, toggles).
@@ -40,25 +41,27 @@ export const liquidGlassStyles = (overrides = {}) => ({
40
41
  // Light review-gallery surface (wireframe: pale sage background, white cards,
41
42
  // dark icons). Use reviewGalleryStyles() to spread into gallery components.
42
43
  export const REVIEW_LIGHT = {
43
- background: '#E8EBE6',
44
- cardBackground: '#FFFFFF',
45
- textColor: '#1A1A1A',
46
- iconColor: '#1A1A1A',
47
- mutedText: 'rgba(26, 26, 26, 0.55)',
48
- border: '1px solid rgba(0, 0, 0, 0.08)',
49
- tileBorder: '2px solid #FFFFFF',
50
- addTileBorder: '2px dashed rgba(0, 0, 0, 0.25)',
51
- addTileBackground: 'rgba(255, 255, 255, 0.6)',
52
- stripBorder: '1px solid rgba(0, 0, 0, 0.08)',
44
+ background: 'var(--veryfi-review-background, #E8EBE6)',
45
+ chromeBackground: 'var(--veryfi-review-chrome-background, #E8EBE6)',
46
+ cardBackground: 'var(--veryfi-review-card-background, #FFFFFF)',
47
+ textColor: 'var(--veryfi-review-text, #1A1A1A)',
48
+ iconColor: 'var(--veryfi-review-text, #1A1A1A)',
49
+ mutedText: 'var(--veryfi-review-muted-text, rgba(26, 26, 26, 0.55))',
50
+ border: '1px solid var(--veryfi-review-border, rgba(0, 0, 0, 0.08))',
51
+ tileBorder: '2px solid var(--veryfi-review-tile-border, #FFFFFF)',
52
+ addTileBorder: '2px dashed var(--veryfi-review-add-border, rgba(0, 0, 0, 0.25))',
53
+ addTileBackground: 'var(--veryfi-review-add-background, rgba(255, 255, 255, 0.6))',
54
+ stripBorder: 'var(--veryfi-review-border, rgba(0, 0, 0, 0.08))',
53
55
  toolbarButtonBackground: 'transparent',
54
- toolbarButtonColor: '#1A1A1A',
55
- cropBackground: '#E8EBE6',
56
- cropCancelColor: '#8B2942',
57
- cropCancelBorder: '1px solid #8B2942',
58
- cropApplyBackground: '#1A2332',
59
- cropApplyColor: '#FFFFFF',
60
- loadingOverlay: 'rgba(232, 235, 230, 0.72)',
61
- loadingText: '#1A1A1A',
56
+ toolbarButtonColor: 'var(--veryfi-review-text, #1A1A1A)',
57
+ cropBackground: 'var(--veryfi-review-background, #E8EBE6)',
58
+ cropBarBackground: 'var(--veryfi-review-crop-bar-background, #FFFFFF)',
59
+ cropCancelColor: 'var(--veryfi-review-crop-cancel, #8B2942)',
60
+ cropCancelBorder: '1px solid var(--veryfi-review-crop-cancel, #8B2942)',
61
+ cropApplyBackground: 'var(--veryfi-review-crop-apply-background, #1A2332)',
62
+ cropApplyColor: 'var(--veryfi-review-crop-apply-text, #FFFFFF)',
63
+ loadingOverlay: 'var(--veryfi-review-loading-background, rgba(232, 235, 230, 0.72))',
64
+ loadingText: 'var(--veryfi-review-text, #1A1A1A)',
62
65
  };
63
66
 
64
67
  export const reviewGalleryStyles = (overrides = {}) => ({
@@ -12,7 +12,7 @@ const DEFAULT_STYLES = {
12
12
  borderRadius: '20px',
13
13
  padding: '24px 28px',
14
14
  maxWidth: '300px',
15
- textColor: '#1e293b',
15
+ textColor: LIQUID_GLASS.panelText,
16
16
  textFontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
17
17
  textFontSize: '17px',
18
18
  buttonWidth: '100%',
@@ -24,11 +24,11 @@ const DEFAULT_STYLES = {
24
24
  primaryButtonBackground: '#00AA00',
25
25
  primaryButtonColor: 'white',
26
26
  primaryButtonBoxShadow: LIQUID_GLASS.boxShadow,
27
- secondaryButtonBackground: 'rgba(255, 255, 255, 0.45)',
28
- secondaryButtonBorder: '1px solid rgba(0, 0, 0, 0.12)',
29
- secondaryButtonColor: '#1e293b',
27
+ secondaryButtonBackground: LIQUID_GLASS.secondaryBackground,
28
+ secondaryButtonBorder: LIQUID_GLASS.secondaryBorder,
29
+ secondaryButtonColor: LIQUID_GLASS.panelText,
30
30
  panelBackdropFilter: LIQUID_GLASS.blur,
31
- panelBorder: '1px solid rgba(255, 255, 255, 0.6)',
31
+ panelBorder: LIQUID_GLASS.darkBorder,
32
32
  panelBoxShadow: LIQUID_GLASS.panelBoxShadow,
33
33
  };
34
34
 
@@ -53,7 +53,7 @@ export const createPrescriptionLabelGuide = (container, options = {}) => {
53
53
  WebkitBackdropFilter: LIQUID_GLASS.blur,
54
54
  border: LIQUID_GLASS.darkBorder,
55
55
  boxShadow: LIQUID_GLASS.darkPanelBoxShadow,
56
- color: 'white',
56
+ color: LIQUID_GLASS.panelText,
57
57
  borderRadius: '20px',
58
58
  fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
59
59
  fontSize: '14px',
@@ -94,7 +94,7 @@ export const createPrescriptionLabelGuide = (container, options = {}) => {
94
94
  justifyContent: 'center',
95
95
  border: 'none',
96
96
  background: 'transparent',
97
- color: 'white',
97
+ color: LIQUID_GLASS.panelText,
98
98
  cursor: 'pointer',
99
99
  opacity: '0.85',
100
100
  pointerEvents: 'auto',
@@ -99,6 +99,8 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
99
99
  pageLabels: Array.isArray(options.pageLabels) ? options.pageLabels : null,
100
100
  allowAddPage: options.allowAddPage !== false,
101
101
  allowAddDocument: options.allowAddDocument !== false,
102
+ showQualityBadges: options.showQualityBadges !== false,
103
+ issueLabels: options.issueLabels || { blur: 'Blurry', lcd: 'Screen' },
102
104
  showDocumentStrip: options.showDocumentStrip !== false,
103
105
  showClose: options.showClose !== false,
104
106
  ...options,
@@ -138,11 +140,14 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
138
140
 
139
141
  // Field-detection visuals for a focused image page (receipt flow): the scanning
140
142
  // animation runs while OCR is in flight, then vendor/date/total boxes are drawn
141
- // over the image. Tracked by page id so a superseded scan doesn't paint a stale
142
- // result. detailImgEl/detailPage point at the currently rendered detail image.
143
- let fieldScan = { active: false, result: null, pageId: null };
143
+ // over the image. Results live on the page itself (page.fieldDetection), so a
144
+ // multi-document frame can have one per page and switching pages shows the
145
+ // right boxes; this set only tracks which pages are still scanning.
146
+ const scanningPageIds = new Set();
144
147
  let detailImgEl = null;
145
148
  let detailPage = null;
149
+ // The quality badge drawn over the detail image, kept so a resize can re-pin it.
150
+ let detailIssueBadge = null;
146
151
  let submitting = false;
147
152
  let loadingOverlayEl = null;
148
153
  let loadingMessageEl = null;
@@ -152,21 +157,20 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
152
157
  hideFieldDetectionOverlay();
153
158
  };
154
159
 
155
- // Paint the current field-scan state (scan animation or result boxes) onto the
156
- // detail image once it is laid out. No-op unless the detail image matches the
157
- // tracked page.
160
+ // Paint the field-detection state of the focused page (scan animation or result
161
+ // boxes) onto the detail image once it is laid out.
158
162
  const applyFieldDetectionToDetail = () => {
159
163
  clearFieldOverlays();
160
164
  const imgEl = detailImgEl;
161
165
  const page = detailPage;
162
166
  if (!imgEl || !page || page.kind === 'video') return;
163
- if (!fieldScan.active && !fieldScan.result) return;
164
- if (fieldScan.pageId && page.id !== fieldScan.pageId) return;
167
+ const scanning = scanningPageIds.has(page.id);
168
+ if (!scanning && !page.fieldDetection) return;
165
169
  const run = () => {
166
170
  if (imgEl !== detailImgEl) return;
167
- if (fieldScan.result) {
168
- showFieldDetectionOverlay(imgEl, fieldScan.result);
169
- } else if (fieldScan.active) {
171
+ if (page.fieldDetection) {
172
+ showFieldDetectionOverlay(imgEl, page.fieldDetection);
173
+ } else if (scanning) {
170
174
  showFieldDetectionScanOverlay(
171
175
  imgEl,
172
176
  `data:image/jpeg;base64,${page.data}`,
@@ -189,7 +193,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
189
193
  display: 'none',
190
194
  flexDirection: 'column',
191
195
  zIndex: 'var(--review-gallery-z-index, 1200)',
192
- background: 'var(--review-gallery-background, #E8EBE6)',
196
+ background: `var(--review-gallery-background, ${REVIEW_LIGHT.background})`,
193
197
  pointerEvents: 'auto',
194
198
  fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
195
199
  color: REVIEW_LIGHT.textColor,
@@ -216,7 +220,12 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
216
220
  };
217
221
 
218
222
  applyGalleryLayout();
219
- const onResize = () => applyGalleryLayout();
223
+ const onResize = () => {
224
+ applyGalleryLayout();
225
+ if (detailIssueBadge) {
226
+ placeIssueBadgeOverImage(detailIssueBadge.el, detailIssueBadge.imgEl);
227
+ }
228
+ };
220
229
  window.addEventListener('resize', onResize);
221
230
 
222
231
  // Top bar: back on the left, page actions on the right.
@@ -229,6 +238,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
229
238
  // Clear the status bar / notch on mobile.
230
239
  padding: 'calc(14px + env(safe-area-inset-top, 0px)) 16px 14px',
231
240
  color: REVIEW_LIGHT.textColor,
241
+ background: REVIEW_LIGHT.chromeBackground,
232
242
  flex: '0 0 auto',
233
243
  });
234
244
 
@@ -288,6 +298,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
288
298
  justifyContent: 'stretch',
289
299
  alignItems: 'center',
290
300
  padding: '12px 16px calc(12px + env(safe-area-inset-bottom, 0px))',
301
+ background: REVIEW_LIGHT.chromeBackground,
291
302
  flex: '0 0 auto',
292
303
  });
293
304
 
@@ -443,7 +454,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
443
454
  display: 'flex',
444
455
  alignItems: 'center',
445
456
  justifyContent: 'center',
446
- color: danger ? '#C62828' : REVIEW_LIGHT.toolbarButtonColor,
457
+ color: danger ? 'var(--veryfi-danger-color, #C62828)' : REVIEW_LIGHT.toolbarButtonColor,
447
458
  borderRadius: '50%',
448
459
  cursor: 'pointer',
449
460
  border: 'none',
@@ -567,7 +578,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
567
578
  justifyContent: 'center',
568
579
  padding: '12px 16px calc(12px + env(safe-area-inset-bottom, 0px))',
569
580
  flex: '0 0 auto',
570
- background: '#FFFFFF',
581
+ background: REVIEW_LIGHT.cropBarBackground,
571
582
  });
572
583
  const cancelBtn = document.createElement('button');
573
584
  cancelBtn.textContent = 'CANCEL';
@@ -575,7 +586,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
575
586
  flex: '1 1 0',
576
587
  padding: '14px 24px',
577
588
  borderRadius: '28px',
578
- background: '#FFFFFF',
589
+ background: REVIEW_LIGHT.cropBarBackground,
579
590
  color: REVIEW_LIGHT.cropCancelColor,
580
591
  border: REVIEW_LIGHT.cropCancelBorder,
581
592
  fontWeight: '700',
@@ -889,6 +900,26 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
889
900
  detailPage = page;
890
901
  applyFieldDetectionToDetail();
891
902
 
903
+ const issueBadge = buildIssueBadge(page, { large: true });
904
+ if (issueBadge) {
905
+ // Hidden until measured so it never flashes in the wrong spot.
906
+ issueBadge.style.visibility = 'hidden';
907
+ media.appendChild(issueBadge);
908
+ const place = () => {
909
+ placeIssueBadgeOverImage(issueBadge, thumb);
910
+ issueBadge.style.visibility = 'visible';
911
+ };
912
+ if (thumb.tagName !== 'VIDEO' && thumb.complete && thumb.naturalWidth > 0) {
913
+ requestAnimationFrame(place);
914
+ } else {
915
+ thumb.addEventListener('load', () => requestAnimationFrame(place), { once: true });
916
+ thumb.addEventListener('loadedmetadata', () => requestAnimationFrame(place), {
917
+ once: true,
918
+ });
919
+ }
920
+ detailIssueBadge = { el: issueBadge, imgEl: thumb };
921
+ }
922
+
892
923
  return cell;
893
924
  };
894
925
 
@@ -896,6 +927,56 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
896
927
  // 1-based page number.
897
928
  const pageLabelFor = (index) => (o.pageLabels && o.pageLabels[index]) || String(index + 1);
898
929
 
930
+ // Badge marking a page the quality checks flagged. Multi-document frames
931
+ // commit every crop and flag the bad ones here rather than blocking the whole
932
+ // capture, so the user can retake just the page that needs it.
933
+ const buildIssueBadge = (page, { large = false } = {}) => {
934
+ if (!o.showQualityBadges) return null;
935
+ const labels = (page?.issues || [])
936
+ .map((issue) => o.issueLabels[issue])
937
+ .filter(Boolean);
938
+ if (!labels.length) return null;
939
+
940
+ const badge = document.createElement('span');
941
+ badge.textContent = labels.join(' · ');
942
+ Object.assign(badge.style, {
943
+ position: 'absolute',
944
+ background: 'var(--veryfi-danger-color, #C62828)',
945
+ color: 'white',
946
+ whiteSpace: 'nowrap',
947
+ pointerEvents: 'none',
948
+ ...(large
949
+ ? {
950
+ padding: '7px 16px',
951
+ borderRadius: '16px',
952
+ fontSize: '16px',
953
+ fontWeight: '700',
954
+ // Sits over the capture, which can be light or busy.
955
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.35)',
956
+ }
957
+ : {
958
+ right: '6px',
959
+ top: '6px',
960
+ padding: '2px 8px',
961
+ borderRadius: '10px',
962
+ fontSize: '11px',
963
+ fontWeight: '600',
964
+ }),
965
+ });
966
+ return badge;
967
+ };
968
+
969
+ // Pin the detail badge to the top of the rendered image rather than the corner
970
+ // of the surrounding area: the capture is centered and rarely fills the region,
971
+ // so a corner-anchored badge floats off the document.
972
+ const placeIssueBadgeOverImage = (badge, imgEl) => {
973
+ const rect = getPreviewLayoutRect(imgEl);
974
+ if (!rect?.width) return;
975
+ badge.style.left = `${rect.centerX}px`;
976
+ badge.style.top = `${rect.top + 12}px`;
977
+ badge.style.transform = 'translateX(-50%)';
978
+ };
979
+
899
980
  // Grid tile for the multi-page overview: tapping it opens the page detail.
900
981
  const buildGridTile = (page, pageIndex) => {
901
982
  const cell = document.createElement('div');
@@ -936,6 +1017,9 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
936
1017
  });
937
1018
  cell.appendChild(num);
938
1019
 
1020
+ const issueBadge = buildIssueBadge(page);
1021
+ if (issueBadge) cell.appendChild(issueBadge);
1022
+
939
1023
  // Quick retake / delete without opening the detail view. The buttons stop
940
1024
  // propagation so the rest of the tile still opens the detail on tap.
941
1025
  const controls = document.createElement('div');
@@ -1015,6 +1099,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
1015
1099
  clearFieldOverlays();
1016
1100
  detailImgEl = null;
1017
1101
  detailPage = null;
1102
+ detailIssueBadge = null;
1018
1103
  gridEl.innerHTML = '';
1019
1104
  const activeDoc = docs[activeIndex];
1020
1105
  const pages = activeDoc?.pages || [];
@@ -1126,7 +1211,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
1126
1211
  submitButton.disabled = submitting;
1127
1212
  if (submitting) {
1128
1213
  clearFieldOverlays();
1129
- } else if (fieldScan.result) {
1214
+ } else {
1130
1215
  applyFieldDetectionToDetail();
1131
1216
  }
1132
1217
  if (loadingOverlayEl) {
@@ -1145,23 +1230,20 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
1145
1230
  // Start the field-detection scanning animation over the focused image of the
1146
1231
  // given page while OCR runs.
1147
1232
  startFieldScan: (pageId) => {
1148
- fieldScan = { active: true, result: null, pageId: pageId ?? null };
1233
+ if (!pageId) return;
1234
+ scanningPageIds.add(pageId);
1149
1235
  applyFieldDetectionToDetail();
1150
1236
  },
1151
- // Finish the scan for the given page: draw the vendor/date/total boxes when a
1152
- // result is provided, otherwise just clear the animation. Ignored if a newer
1153
- // scan (different page) has superseded this one.
1154
- finishFieldScan: (pageId, result) => {
1155
- if (fieldScan.pageId && pageId !== fieldScan.pageId) return;
1156
- fieldScan = {
1157
- active: false,
1158
- result: result || null,
1159
- pageId: result ? fieldScan.pageId : null,
1160
- };
1161
- if (result) applyFieldDetectionToDetail();
1162
- else clearFieldOverlays();
1237
+ // Finish the scan for the given page. The result has already been stored on
1238
+ // the page, so this just stops the animation and repaints — drawing the
1239
+ // vendor/date/total boxes when that page is the one in view.
1240
+ finishFieldScan: (pageId) => {
1241
+ if (!pageId) return;
1242
+ scanningPageIds.delete(pageId);
1243
+ applyFieldDetectionToDetail();
1163
1244
  },
1164
1245
  remove: () => {
1246
+ scanningPageIds.clear();
1165
1247
  clearFieldOverlays();
1166
1248
  document.removeEventListener('keydown', onKeyDown);
1167
1249
  window.removeEventListener('resize', onResize);
@@ -29,16 +29,16 @@ export const createUploadDropZone = (parentElement, styles, options = {}) => {
29
29
 
30
30
  uploadZone.addEventListener('dragover', (e) => {
31
31
  e.preventDefault();
32
- uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color-active, #000)';
32
+ uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color-active, var(--veryfi-panel-text, #000))';
33
33
  });
34
34
 
35
35
  uploadZone.addEventListener('dragleave', () => {
36
- uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, #ccc)';
36
+ uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, var(--veryfi-upload-zone-border, #ccc))';
37
37
  });
38
38
 
39
39
  uploadZone.addEventListener('drop', (e) => {
40
40
  e.preventDefault();
41
- uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, #ccc)';
41
+ uploadZone.style.borderColor = 'var(--file-upload-upload-zone-border-color, var(--veryfi-upload-zone-border, #ccc))';
42
42
  if (e.dataTransfer.files.length && onFileSelected) {
43
43
  onFileSelected(e.dataTransfer.files[0]);
44
44
  }