veryfi-lens-wasm 3.4.0 → 3.4.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/components/reviewGallery.js +99 -38
- package/core/constants.js +1 -1
- package/package.json +1 -1
|
@@ -108,17 +108,18 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
108
108
|
|
|
109
109
|
topBar.appendChild(titleEl);
|
|
110
110
|
|
|
111
|
-
// Document strip (horizontal): one tile per document.
|
|
111
|
+
// Document strip (horizontal): one tile per document, plus an "add" tile.
|
|
112
112
|
const stripEl = document.createElement('div');
|
|
113
113
|
stripEl.id = 'veryfi-review-doc-strip';
|
|
114
114
|
Object.assign(stripEl.style, {
|
|
115
115
|
display: 'none',
|
|
116
116
|
gap: '8px',
|
|
117
|
-
padding: '
|
|
117
|
+
padding: '10px 16px',
|
|
118
118
|
overflowX: 'auto',
|
|
119
119
|
WebkitOverflowScrolling: 'touch',
|
|
120
120
|
overscrollBehavior: 'contain',
|
|
121
121
|
flex: '0 0 auto',
|
|
122
|
+
borderTop: '1px solid rgba(255, 255, 255, 0.12)',
|
|
122
123
|
});
|
|
123
124
|
|
|
124
125
|
// Main scrollable page grid for the active document.
|
|
@@ -160,34 +161,26 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
160
161
|
...liquidGlassStyles(bg ? { backgroundColor: bg } : {}),
|
|
161
162
|
});
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
addPageButton.textContent = o.addPageText;
|
|
166
|
-
Object.assign(addPageButton.style, pillStyle());
|
|
167
|
-
addPageButton.addEventListener('click', () => callbacks.onAddPage?.());
|
|
168
|
-
|
|
169
|
-
const addDocButton = document.createElement('button');
|
|
170
|
-
addDocButton.id = 'veryfi-review-add-doc';
|
|
171
|
-
addDocButton.textContent = o.addDocumentText;
|
|
172
|
-
Object.assign(addDocButton.style, pillStyle());
|
|
173
|
-
addDocButton.addEventListener('click', () => callbacks.onAddDocument?.());
|
|
174
|
-
|
|
164
|
+
// Single, prominent primary action. Add Page / Add Document are inline "+"
|
|
165
|
+
// tiles in the grid / document strip, so the action bar stays uncluttered.
|
|
175
166
|
const submitButton = document.createElement('button');
|
|
176
167
|
submitButton.id = 'veryfi-review-submit';
|
|
177
168
|
submitButton.textContent = o.submitText;
|
|
178
|
-
Object.assign(submitButton.style, pillStyle('#00AA00')
|
|
169
|
+
Object.assign(submitButton.style, pillStyle('#00AA00'), {
|
|
170
|
+
flex: '1 1 auto',
|
|
171
|
+
maxWidth: '420px',
|
|
172
|
+
textAlign: 'center',
|
|
173
|
+
fontSize: '16px',
|
|
174
|
+
padding: '10px 24px',
|
|
175
|
+
});
|
|
179
176
|
submitButton.addEventListener('click', async () => {
|
|
180
177
|
if (submitButton.disabled) return;
|
|
181
178
|
submitButton.disabled = true;
|
|
182
|
-
addPageButton.disabled = true;
|
|
183
|
-
addDocButton.disabled = true;
|
|
184
179
|
try {
|
|
185
180
|
await callbacks.onSubmit?.();
|
|
186
181
|
} catch (error) {
|
|
187
182
|
console.error('Review gallery submit failed:', error);
|
|
188
183
|
submitButton.disabled = false;
|
|
189
|
-
addPageButton.disabled = false;
|
|
190
|
-
addDocButton.disabled = false;
|
|
191
184
|
}
|
|
192
185
|
});
|
|
193
186
|
|
|
@@ -202,11 +195,10 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
202
195
|
display: o.showClose ? 'flex' : 'none',
|
|
203
196
|
alignItems: 'center',
|
|
204
197
|
justifyContent: 'center',
|
|
198
|
+
flex: '0 0 auto',
|
|
205
199
|
});
|
|
206
200
|
exitButton.addEventListener('click', () => callbacks.onClose?.());
|
|
207
201
|
|
|
208
|
-
actionsEl.appendChild(addPageButton);
|
|
209
|
-
actionsEl.appendChild(addDocButton);
|
|
210
202
|
actionsEl.appendChild(submitButton);
|
|
211
203
|
actionsEl.appendChild(exitButton);
|
|
212
204
|
|
|
@@ -220,8 +212,9 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
220
212
|
document.addEventListener('keydown', onKeyDown);
|
|
221
213
|
|
|
222
214
|
root.appendChild(topBar);
|
|
223
|
-
root.appendChild(stripEl);
|
|
224
215
|
root.appendChild(gridEl);
|
|
216
|
+
// Document thumbnails row lives at the bottom, just above the primary action.
|
|
217
|
+
root.appendChild(stripEl);
|
|
225
218
|
root.appendChild(actionsEl);
|
|
226
219
|
container.appendChild(root);
|
|
227
220
|
|
|
@@ -541,6 +534,44 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
541
534
|
return img;
|
|
542
535
|
};
|
|
543
536
|
|
|
537
|
+
// Dashed "+" tile used to add a document (strip) or a page (grid).
|
|
538
|
+
const buildAddTile = (label, onClick, sizeStyle = {}) => {
|
|
539
|
+
const tile = document.createElement('button');
|
|
540
|
+
Object.assign(tile.style, {
|
|
541
|
+
flex: '0 0 auto',
|
|
542
|
+
display: 'flex',
|
|
543
|
+
flexDirection: 'column',
|
|
544
|
+
alignItems: 'center',
|
|
545
|
+
justifyContent: 'center',
|
|
546
|
+
gap: '4px',
|
|
547
|
+
borderRadius: '10px',
|
|
548
|
+
cursor: 'pointer',
|
|
549
|
+
color: 'white',
|
|
550
|
+
background: 'rgba(255, 255, 255, 0.06)',
|
|
551
|
+
border: '2px dashed rgba(255, 255, 255, 0.45)',
|
|
552
|
+
padding: '4px',
|
|
553
|
+
...sizeStyle,
|
|
554
|
+
});
|
|
555
|
+
const plus = document.createElement('span');
|
|
556
|
+
plus.textContent = '+';
|
|
557
|
+
Object.assign(plus.style, { fontSize: '26px', lineHeight: '1', fontWeight: '400' });
|
|
558
|
+
const lbl = document.createElement('span');
|
|
559
|
+
lbl.textContent = label;
|
|
560
|
+
Object.assign(lbl.style, {
|
|
561
|
+
fontSize: '11px',
|
|
562
|
+
fontWeight: '600',
|
|
563
|
+
textAlign: 'center',
|
|
564
|
+
lineHeight: '1.1',
|
|
565
|
+
});
|
|
566
|
+
tile.appendChild(plus);
|
|
567
|
+
tile.appendChild(lbl);
|
|
568
|
+
tile.addEventListener('click', (e) => {
|
|
569
|
+
e.stopPropagation();
|
|
570
|
+
onClick();
|
|
571
|
+
});
|
|
572
|
+
return tile;
|
|
573
|
+
};
|
|
574
|
+
|
|
544
575
|
const renderStrip = () => {
|
|
545
576
|
const multiDoc = o.showDocumentStrip && (docs.length > 1 || o.allowAddDocument);
|
|
546
577
|
stripEl.style.display = multiDoc ? 'flex' : 'none';
|
|
@@ -553,8 +584,8 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
553
584
|
Object.assign(tile.style, {
|
|
554
585
|
position: 'relative',
|
|
555
586
|
flex: '0 0 auto',
|
|
556
|
-
width: '
|
|
557
|
-
height: '
|
|
587
|
+
width: '65px',
|
|
588
|
+
height: '60px',
|
|
558
589
|
borderRadius: '10px',
|
|
559
590
|
overflow: 'hidden',
|
|
560
591
|
cursor: 'pointer',
|
|
@@ -591,6 +622,15 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
591
622
|
});
|
|
592
623
|
stripEl.appendChild(tile);
|
|
593
624
|
});
|
|
625
|
+
|
|
626
|
+
if (o.allowAddDocument && canAddDocument) {
|
|
627
|
+
stripEl.appendChild(
|
|
628
|
+
buildAddTile(o.addDocumentText, () => callbacks.onAddDocument?.(), {
|
|
629
|
+
width: '65px',
|
|
630
|
+
height: '60px',
|
|
631
|
+
})
|
|
632
|
+
);
|
|
633
|
+
}
|
|
594
634
|
};
|
|
595
635
|
|
|
596
636
|
// Single detail view (with the action toolbar) for one page. Used both for a
|
|
@@ -602,7 +642,9 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
602
642
|
display: 'flex',
|
|
603
643
|
flexDirection: 'column',
|
|
604
644
|
alignItems: 'center',
|
|
645
|
+
justifyContent: 'center',
|
|
605
646
|
gap: '12px',
|
|
647
|
+
minHeight: '100%',
|
|
606
648
|
});
|
|
607
649
|
|
|
608
650
|
// Toolbar sits above the image (not overlapping it): optional back, then
|
|
@@ -617,6 +659,8 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
617
659
|
flexWrap: 'wrap',
|
|
618
660
|
flex: '0 0 auto',
|
|
619
661
|
});
|
|
662
|
+
// Don't dismiss when interacting with the toolbar area.
|
|
663
|
+
toolbar.addEventListener('click', (e) => e.stopPropagation());
|
|
620
664
|
if (showBack) {
|
|
621
665
|
toolbar.appendChild(
|
|
622
666
|
toolButton('arrow-left', o.backText, () => {
|
|
@@ -668,6 +712,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
668
712
|
thumb.style.maxHeight = '62vh';
|
|
669
713
|
thumb.style.maxHeight = '62dvh';
|
|
670
714
|
if (thumb.tagName === 'VIDEO') thumb.controls = true;
|
|
715
|
+
thumb.addEventListener('click', (e) => e.stopPropagation());
|
|
671
716
|
media.appendChild(thumb);
|
|
672
717
|
cell.appendChild(media);
|
|
673
718
|
|
|
@@ -680,6 +725,7 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
680
725
|
Object.assign(cell.style, {
|
|
681
726
|
position: 'relative',
|
|
682
727
|
borderRadius: '10px',
|
|
728
|
+
border: '2px solid white',
|
|
683
729
|
overflow: 'hidden',
|
|
684
730
|
background: '#000',
|
|
685
731
|
aspectRatio: '3 / 4',
|
|
@@ -692,7 +738,8 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
692
738
|
thumb.style.pointerEvents = 'none';
|
|
693
739
|
if (thumb.tagName === 'VIDEO') thumb.controls = false;
|
|
694
740
|
cell.appendChild(thumb);
|
|
695
|
-
cell.addEventListener('click', () => {
|
|
741
|
+
cell.addEventListener('click', (e) => {
|
|
742
|
+
e.stopPropagation();
|
|
696
743
|
focusedIndex = pageIndex;
|
|
697
744
|
renderGrid();
|
|
698
745
|
});
|
|
@@ -743,33 +790,49 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
743
790
|
if (focusedIndex !== null && (focusedIndex < 0 || focusedIndex >= pages.length)) {
|
|
744
791
|
focusedIndex = null;
|
|
745
792
|
}
|
|
746
|
-
const
|
|
747
|
-
//
|
|
748
|
-
//
|
|
749
|
-
const
|
|
793
|
+
const allowAddPageNow = o.allowAddPage && canAddPage;
|
|
794
|
+
// Show the overview grid when there are multiple pages or the user can add
|
|
795
|
+
// pages (so the "+" tile is reachable); otherwise show the lone page detail.
|
|
796
|
+
const showGrid = pages.length > 1 || allowAddPageNow;
|
|
797
|
+
|
|
798
|
+
// Detail view: an explicitly focused page, or the single page when there's
|
|
799
|
+
// no grid to show.
|
|
800
|
+
let detailIndex = focusedIndex;
|
|
801
|
+
if (detailIndex === null && !showGrid && pages.length === 1) {
|
|
802
|
+
detailIndex = 0;
|
|
803
|
+
}
|
|
750
804
|
|
|
751
805
|
if (detailIndex !== null) {
|
|
752
806
|
gridEl.style.gridTemplateColumns = '1fr';
|
|
807
|
+
// Clicking the backdrop (anywhere in the grid area that isn't the toolbar
|
|
808
|
+
// or the image — including below the image) returns to the gallery grid.
|
|
809
|
+
// Only when there is a grid to go back to.
|
|
810
|
+
gridEl.onclick = showGrid
|
|
811
|
+
? () => {
|
|
812
|
+
focusedIndex = null;
|
|
813
|
+
renderGrid();
|
|
814
|
+
}
|
|
815
|
+
: null;
|
|
753
816
|
gridEl.appendChild(
|
|
754
|
-
buildDetailCell(pages[detailIndex], activeIndex, detailIndex, { showBack:
|
|
817
|
+
buildDetailCell(pages[detailIndex], activeIndex, detailIndex, { showBack: showGrid })
|
|
755
818
|
);
|
|
756
819
|
return;
|
|
757
820
|
}
|
|
821
|
+
gridEl.onclick = null;
|
|
758
822
|
|
|
759
|
-
// Larger previews: ~2 columns on phones (roughly 6 tiles visible per view)
|
|
760
|
-
// instead of the previous denser 120px grid.
|
|
761
823
|
gridEl.style.gridTemplateColumns = 'repeat(auto-fill, minmax(150px, 1fr))';
|
|
762
824
|
pages.forEach((page, pageIndex) => {
|
|
763
825
|
gridEl.appendChild(buildGridTile(page, pageIndex));
|
|
764
826
|
});
|
|
827
|
+
if (allowAddPageNow) {
|
|
828
|
+
gridEl.appendChild(
|
|
829
|
+
buildAddTile(o.addPageText, () => callbacks.onAddPage?.(), { aspectRatio: '3 / 4' })
|
|
830
|
+
);
|
|
831
|
+
}
|
|
765
832
|
};
|
|
766
833
|
|
|
767
834
|
const renderActions = () => {
|
|
768
|
-
addPageButton.disabled = false;
|
|
769
|
-
addDocButton.disabled = false;
|
|
770
835
|
submitButton.disabled = false;
|
|
771
|
-
addPageButton.style.display = o.allowAddPage && canAddPage ? 'inline-block' : 'none';
|
|
772
|
-
addDocButton.style.display = o.allowAddDocument && canAddDocument ? 'inline-block' : 'none';
|
|
773
836
|
submitButton.textContent = o.submitText;
|
|
774
837
|
};
|
|
775
838
|
|
|
@@ -802,8 +865,6 @@ export const createReviewGallery = (container, callbacks = {}, options = {}) =>
|
|
|
802
865
|
},
|
|
803
866
|
setSubmitting: (submitting) => {
|
|
804
867
|
submitButton.disabled = submitting;
|
|
805
|
-
addPageButton.disabled = submitting;
|
|
806
|
-
addDocButton.disabled = submitting;
|
|
807
868
|
},
|
|
808
869
|
remove: () => {
|
|
809
870
|
document.removeEventListener('keydown', onKeyDown);
|
package/core/constants.js
CHANGED