veryfi-lens-wasm 3.4.2 → 3.5.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/README.md CHANGED
@@ -223,7 +223,9 @@ After each accepted capture, the `document`, `anydocs`, and `prescription_label`
223
223
  | `anydocAddPageText` | `string` | `"Add Page"` | _Deprecated:_ alias for `reviewAddPageText` |
224
224
  | `anydocSubmitText` | `string` | `"Submit"` | _Deprecated:_ alias for `reviewSubmitText` |
225
225
  | `anydocShowGuide` | `boolean` | `false` | Show a dismissible on-screen text guide explaining how to capture. Auto-hides after each page capture and reappears when the camera restarts for the next page |
226
- | `anydocGuideText` | `string` | `"Position the document within the frame..."` | Guide text shown for anydocs capture. Use `\n` for line breaks |
226
+ | `anydocGuideText` | `string` | `"Position the document within the frame..."` | Guide text shown for anydocs capture. Separate steps with a blank line (`\n\n`) — each becomes a numbered step |
227
+ | `anydocGuideTitle` | `string` | `"Steps to Capture"` | Heading of the anydocs capture guide panel |
228
+ | `guideShowOnce` | `boolean` | `false` | Show the capture guide only for the first capture of a session instead of re-showing it every time the camera returns for the next capture (multi-capture / QR sessions) |
227
229
 
228
230
  ### Bottle Cap Settings (`caps` flavor)
229
231
 
@@ -252,8 +254,9 @@ After each accepted capture, the `document`, `anydocs`, and `prescription_label`
252
254
  | `prescriptionLabelSquareWidthRatio` | `number` | `0.8` | Square overlay width (0-1 relative to viewport) |
253
255
  | `prescriptionLabelSquareHeightRatio` | `number` | `0.5` | Square overlay height (0-1 relative to viewport) |
254
256
  | `prescriptionLabelShowGuide` | `boolean` | `false` | Show a semi-transparent guide explaining how to record the label. Auto-hides when recording starts and reappears on retake |
255
- | `prescriptionLabelGuideText` | `string` | `"Position the bottle within the outline.\n\nPress the capture button to start recording, slowly rotate the bottle to capture the entire label and press the capture button again to stop recording."` | Guide text shown when the bottle outline overlay is active. Use `\n` for line breaks |
256
- | `prescriptionLabelSquareGuideText` | `string` | `"Position the prescription label within the square.\n\nPress the capture button to take a photo of the label."` | Guide text shown when the box overlay is active. Use `\n` for line breaks |
257
+ | `prescriptionLabelGuideText` | `string` | `"Position the bottle within the outline.\n\nPress the capture button to start recording.\n\nSlowly rotate the bottle to capture the entire label and press the capture button again to stop recording."` | Guide text shown when the bottle outline overlay is active. Separate steps with a blank line (`\n\n`) — each becomes a numbered step |
258
+ | `prescriptionLabelSquareGuideText` | `string` | `"Position the prescription label within the square.\n\nPress the capture button to take a photo of the label."` | Guide text shown when the box overlay is active. Separate steps with a blank line (`\n\n`) — each becomes a numbered step |
259
+ | `prescriptionLabelGuideTitle` | `string` | `"Steps to Capture"` | Heading of the prescription label capture guide panel |
257
260
  | `prescriptionLabelShowOverlayToggle` | `boolean` | `true` | Show a toggle that lets the user switch between the bottle and box overlays during capture. The **bottle** overlay records a video; the **box** overlay captures a still image |
258
261
  | `prescriptionLabelBottleLabel` | `string` | `"Bottle"` | Label for the bottle (video) segment of the overlay toggle |
259
262
  | `prescriptionLabelBoxLabel` | `string` | `"Box"` | Label for the box (image) segment of the overlay toggle |
@@ -1,5 +1,3 @@
1
- import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
2
-
3
1
  export const createCaptureButton = (container, onCapture, onStopStitching) => {
4
2
  const button = document.createElement('button');
5
3
  button.id = 'veryfi-capture-button';
@@ -19,7 +17,9 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
19
17
  outline: 'none',
20
18
  pointerEvents: 'auto',
21
19
  boxSizing: 'border-box',
22
- ...liquidGlassStyles({ border: '3px solid rgba(255, 255, 255, 0.55)' }),
20
+ backgroundColor: '#FFFFFF',
21
+ border: 'none',
22
+ boxShadow: '0 2px 12px rgba(0, 0, 0, 0.25)',
23
23
  };
24
24
 
25
25
  Object.entries(defaultStyles).forEach(([key, value]) => {
@@ -46,11 +46,11 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
46
46
 
47
47
  // Add hover effect
48
48
  button.addEventListener('mouseenter', () => {
49
- button.style.backgroundColor = `var(--capture-button-hover-background-color, ${LIQUID_GLASS.hoverBackgroundColor})`;
49
+ button.style.backgroundColor = 'var(--capture-button-hover-background-color, rgba(255, 255, 255, 0.85))';
50
50
  });
51
51
 
52
52
  button.addEventListener('mouseleave', () => {
53
- button.style.backgroundColor = `var(--capture-button-background-color, ${LIQUID_GLASS.backgroundColor})`;
53
+ button.style.backgroundColor = 'var(--capture-button-background-color, #FFFFFF)';
54
54
  });
55
55
 
56
56
  let isStitching = false;
@@ -36,3 +36,33 @@ export const liquidGlassStyles = (overrides = {}) => ({
36
36
  boxShadow: LIQUID_GLASS.boxShadow,
37
37
  ...overrides,
38
38
  });
39
+
40
+ // Light review-gallery surface (wireframe: pale sage background, white cards,
41
+ // dark icons). Use reviewGalleryStyles() to spread into gallery components.
42
+ 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)',
53
+ 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',
62
+ };
63
+
64
+ export const reviewGalleryStyles = (overrides = {}) => ({
65
+ background: REVIEW_LIGHT.background,
66
+ color: REVIEW_LIGHT.textColor,
67
+ ...overrides,
68
+ });
@@ -1,75 +1,158 @@
1
+ import { LIQUID_GLASS } from './liquid-glass.js';
2
+
3
+ const NS = 'http://www.w3.org/2000/svg';
4
+
5
+ const closeIcon = () => {
6
+ const svg = document.createElementNS(NS, 'svg');
7
+ svg.setAttribute('viewBox', '0 0 24 24');
8
+ svg.setAttribute('width', '20');
9
+ svg.setAttribute('height', '20');
10
+ svg.setAttribute('fill', 'none');
11
+ svg.setAttribute('stroke', 'currentColor');
12
+ svg.setAttribute('stroke-width', '2');
13
+ svg.setAttribute('stroke-linecap', 'round');
14
+ ['M18 6 6 18', 'm6 6 12 12'].forEach((d) => {
15
+ const path = document.createElementNS(NS, 'path');
16
+ path.setAttribute('d', d);
17
+ svg.appendChild(path);
18
+ });
19
+ return svg;
20
+ };
21
+
22
+ // Blank-line-separated paragraphs become the numbered steps.
23
+ const splitSteps = (text) =>
24
+ String(text || '')
25
+ .split(/\n\s*\n/)
26
+ .map((step) => step.trim())
27
+ .filter(Boolean);
28
+
1
29
  export const createPrescriptionLabelGuide = (container, options = {}) => {
2
- const text = options.text || '';
3
30
  const id = options.id || 'veryfi-prescription-label-guide';
31
+ const stepNumberColor = options.stepNumberColor || '#22C55E';
32
+ // When set, the guide is shown once per session: subsequent show() calls (the
33
+ // camera re-entry between captures) leave it hidden.
34
+ const showOnce = options.showOnce === true;
4
35
 
5
36
  const guide = document.createElement('div');
6
37
  guide.id = id;
7
38
 
8
39
  Object.assign(guide.style, {
9
40
  position: 'absolute',
10
- top: 'calc(50% - 120px)',
41
+ top: '50%',
11
42
  left: '50%',
12
- transform: 'translateX(-50%)',
13
- width: '240px',
14
- height: '240px',
15
- padding: '14px 36px 14px 20px',
16
- backgroundColor: 'rgba(0, 0, 0, 0.6)',
43
+ transform: 'translate(-50%, -50%)',
44
+ // The parent overlay has a shrink-to-fit width, so a percentage width here
45
+ // would collapse. Size against the viewport instead.
46
+ width: '300px',
47
+ maxWidth: 'calc(100vw - 48px)',
48
+ maxHeight: 'calc(100vh - 120px)',
49
+ overflowY: 'auto',
50
+ padding: '22px 24px 24px',
51
+ backgroundColor: LIQUID_GLASS.darkPanelBackground,
52
+ backdropFilter: LIQUID_GLASS.blur,
53
+ WebkitBackdropFilter: LIQUID_GLASS.blur,
54
+ border: LIQUID_GLASS.darkBorder,
55
+ boxShadow: LIQUID_GLASS.darkPanelBoxShadow,
17
56
  color: 'white',
18
- borderRadius: '12px',
57
+ borderRadius: '20px',
19
58
  fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
20
59
  fontSize: '14px',
21
- lineHeight: '1.5',
60
+ lineHeight: '1.45',
22
61
  textAlign: 'left',
23
- whiteSpace: 'pre-line',
24
62
  zIndex: '1003',
25
63
  pointerEvents: 'auto',
26
- backdropFilter: 'blur(8px)',
27
- WebkitBackdropFilter: 'blur(8px)',
28
- border: '1px solid rgba(255, 255, 255, 0.2)',
29
64
  boxSizing: 'border-box',
30
65
  });
31
66
 
32
- const textEl = document.createElement('div');
33
- textEl.textContent = text;
34
- guide.appendChild(textEl);
67
+ const header = document.createElement('div');
68
+ Object.assign(header.style, {
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ justifyContent: 'space-between',
72
+ gap: '12px',
73
+ marginBottom: '18px',
74
+ });
75
+
76
+ const titleEl = document.createElement('div');
77
+ titleEl.textContent = options.title || '';
78
+ Object.assign(titleEl.style, {
79
+ fontSize: '17px',
80
+ fontWeight: '700',
81
+ letterSpacing: '0.2px',
82
+ });
35
83
 
36
84
  const closeButton = document.createElement('button');
37
85
  closeButton.id = `${id}-close`;
38
86
  closeButton.setAttribute('aria-label', 'Close guide');
39
- closeButton.textContent = '\u00D7';
40
87
  Object.assign(closeButton.style, {
41
- position: 'absolute',
42
- top: '6px',
43
- right: '6px',
44
- width: '24px',
45
- height: '24px',
88
+ flex: '0 0 auto',
89
+ width: '28px',
90
+ height: '28px',
46
91
  padding: '0',
92
+ display: 'flex',
93
+ alignItems: 'center',
94
+ justifyContent: 'center',
47
95
  border: 'none',
48
96
  background: 'transparent',
49
97
  color: 'white',
50
- fontSize: '20px',
51
- lineHeight: '24px',
52
- fontFamily: 'sans-serif',
53
98
  cursor: 'pointer',
54
- opacity: '0.8',
99
+ opacity: '0.85',
55
100
  pointerEvents: 'auto',
56
101
  outline: 'none',
57
102
  });
58
-
103
+ closeButton.appendChild(closeIcon());
59
104
  closeButton.addEventListener('mouseenter', () => { closeButton.style.opacity = '1'; });
60
- closeButton.addEventListener('mouseleave', () => { closeButton.style.opacity = '0.8'; });
105
+ closeButton.addEventListener('mouseleave', () => { closeButton.style.opacity = '0.85'; });
61
106
  closeButton.addEventListener('click', (e) => {
62
107
  e.stopPropagation();
63
108
  guide.style.display = 'none';
64
109
  });
65
110
 
66
- guide.appendChild(closeButton);
111
+ header.appendChild(titleEl);
112
+ header.appendChild(closeButton);
113
+ guide.appendChild(header);
114
+
115
+ const stepsEl = document.createElement('div');
116
+ Object.assign(stepsEl.style, {
117
+ display: 'flex',
118
+ flexDirection: 'column',
119
+ gap: '14px',
120
+ });
121
+ guide.appendChild(stepsEl);
122
+
123
+ const renderSteps = (text) => {
124
+ stepsEl.innerHTML = '';
125
+ splitSteps(text).forEach((step, index) => {
126
+ const row = document.createElement('div');
127
+ const num = document.createElement('span');
128
+ num.textContent = String(index + 1).padStart(2, '0');
129
+ Object.assign(num.style, {
130
+ color: stepNumberColor,
131
+ fontWeight: '700',
132
+ marginRight: '8px',
133
+ });
134
+ row.appendChild(num);
135
+ row.appendChild(document.createTextNode(step));
136
+ stepsEl.appendChild(row);
137
+ });
138
+ };
139
+ renderSteps(options.text);
140
+
141
+ // The panel is visible on creation, so that already counts as the one showing
142
+ // allowed by showOnce.
143
+ let hasBeenShown = true;
144
+
67
145
  container.appendChild(guide);
68
146
 
69
147
  return {
70
148
  element: guide,
71
- setText: (newText) => { textEl.textContent = newText || ''; },
72
- show: () => { guide.style.display = 'block'; },
149
+ setTitle: (newTitle) => { titleEl.textContent = newTitle || ''; },
150
+ setText: (newText) => { renderSteps(newText); },
151
+ show: () => {
152
+ if (showOnce && hasBeenShown) return;
153
+ hasBeenShown = true;
154
+ guide.style.display = 'block';
155
+ },
73
156
  hide: () => { guide.style.display = 'none'; },
74
157
  remove: () => {
75
158
  if (guide.parentNode) guide.parentNode.removeChild(guide);
@@ -0,0 +1,50 @@
1
+ import { ensureSpinKeyframes } from './shared-styles.js';
2
+
3
+ const SEGMENT_COUNT = 12;
4
+
5
+ /** Radial tick / "leaf" activity indicator (wireframe loading style). */
6
+ export const createRadialSpinner = (options = {}) => {
7
+ const size = options.size ?? 44;
8
+ const color = options.color ?? '#00AA00';
9
+ const duration = options.duration ?? '1s';
10
+
11
+ ensureSpinKeyframes();
12
+
13
+ const root = document.createElement('div');
14
+ if (options.id) root.id = options.id;
15
+ root.setAttribute('role', 'status');
16
+ root.setAttribute('aria-label', options.label ?? 'Loading');
17
+ Object.assign(root.style, {
18
+ position: 'relative',
19
+ width: `${size}px`,
20
+ height: `${size}px`,
21
+ flexShrink: '0',
22
+ });
23
+
24
+ const barW = Math.max(3, Math.round(size * 0.1));
25
+ const barH = Math.round(size * 0.28);
26
+ const offset = Math.round(size * 0.34);
27
+
28
+ for (let i = 0; i < SEGMENT_COUNT; i += 1) {
29
+ const bar = document.createElement('div');
30
+ const angle = (360 / SEGMENT_COUNT) * i;
31
+ Object.assign(bar.style, {
32
+ position: 'absolute',
33
+ left: '50%',
34
+ top: '50%',
35
+ width: `${barW}px`,
36
+ height: `${barH}px`,
37
+ marginLeft: `${-barW / 2}px`,
38
+ marginTop: `${-barH / 2}px`,
39
+ backgroundColor: color,
40
+ borderRadius: `${barW}px`,
41
+ transform: `rotate(${angle}deg) translateY(${-offset}px)`,
42
+ opacity: '0.2',
43
+ animation: `veryfi-radial-fade ${duration} linear infinite`,
44
+ animationDelay: `${-(SEGMENT_COUNT - i) * (parseFloat(duration) / SEGMENT_COUNT)}s`,
45
+ });
46
+ root.appendChild(bar);
47
+ }
48
+
49
+ return root;
50
+ };