smartcomply-web-sdk 1.0.34 → 1.0.35
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/esm/flow/DocumentCapture.d.ts +2 -0
- package/dist/esm/flow/DocumentCapture.d.ts.map +1 -1
- package/dist/esm/flow/DocumentCapture.js +122 -113
- package/dist/esm/flow/DocumentCapture.js.map +1 -1
- package/dist/flow/DocumentCapture.d.ts +2 -0
- package/dist/flow/DocumentCapture.d.ts.map +1 -1
- package/dist/flow/DocumentCapture.js +122 -113
- package/dist/flow/DocumentCapture.js.map +1 -1
- package/dist/smartcomply.browser.js +118 -108
- package/dist/smartcomply.browser.js.map +3 -3
- package/package.json +1 -1
|
@@ -5662,126 +5662,128 @@ var SmartComplySDK = (() => {
|
|
|
5662
5662
|
}
|
|
5663
5663
|
renderChoiceScreen(container, theme, documentType) {
|
|
5664
5664
|
this.root = document.createElement("div");
|
|
5665
|
-
this.root.style.cssText =
|
|
5665
|
+
this.root.style.cssText = `
|
|
5666
|
+
display:flex;flex-direction:column;gap:0;padding:0;width:100%;
|
|
5667
|
+
font-family:system-ui,-apple-system,sans-serif;
|
|
5668
|
+
`;
|
|
5666
5669
|
const docLabel = this.getDocumentLabel(documentType);
|
|
5667
5670
|
const requiresBack = this.shouldCaptureBackSide(documentType);
|
|
5668
5671
|
const isCapturingFront = this.currentSide === "front";
|
|
5669
|
-
const
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5672
|
+
const sideLabel = requiresBack ? isCapturingFront ? " \u2014 Front side" : " \u2014 Back side" : "";
|
|
5673
|
+
const headerRow = document.createElement("div");
|
|
5674
|
+
headerRow.style.cssText = `
|
|
5675
|
+
display:flex;align-items:center;gap:14px;
|
|
5676
|
+
padding:16px 20px 14px;
|
|
5677
|
+
`;
|
|
5678
|
+
const iconBox = document.createElement("div");
|
|
5679
|
+
iconBox.style.cssText = `
|
|
5680
|
+
width:48px;height:48px;border-radius:14px;flex-shrink:0;
|
|
5674
5681
|
display:flex;align-items:center;justify-content:center;
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
box-shadow:0 8px 32px ${theme.primary}20;
|
|
5682
|
+
font-size:24px;
|
|
5683
|
+
background:${theme.primary}15;
|
|
5684
|
+
border:1.5px solid ${theme.primary}30;
|
|
5679
5685
|
`;
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
<div style="display:flex;gap:8px;align-items:center;">
|
|
5718
|
-
<div style="width:12px;height:12px;border-radius:50%;background:${isCapturingFront ? theme.primary : theme.border};transition:all 0.3s ease;"></div>
|
|
5719
|
-
<div style="width:32px;height:2px;background:${theme.border};border-radius:1px;"></div>
|
|
5720
|
-
<div style="width:12px;height:12px;border-radius:50%;background:${!isCapturingFront ? theme.primary : theme.border};transition:all 0.3s ease;"></div>
|
|
5721
|
-
</div>
|
|
5722
|
-
<span style="color:${theme.text};font-size:13px;font-weight:600;">${isCapturingFront ? "Step 1 of 2" : "Step 2 of 2"}</span>
|
|
5723
|
-
`;
|
|
5724
|
-
this.root.appendChild(progress);
|
|
5725
|
-
}
|
|
5726
|
-
const actionsContainer = document.createElement("div");
|
|
5727
|
-
actionsContainer.style.cssText = "display:flex;flex-direction:column;gap:16px;width:100%;max-width:320px;";
|
|
5728
|
-
const cameraBtn = this.createEnhancedButton(
|
|
5729
|
-
"\u{1F4F7} Take Photo with Camera",
|
|
5730
|
-
theme,
|
|
5731
|
-
true,
|
|
5732
|
-
"Open camera to capture document"
|
|
5733
|
-
);
|
|
5686
|
+
iconBox.textContent = this._docIcon(documentType);
|
|
5687
|
+
const titleBlock = document.createElement("div");
|
|
5688
|
+
const titleEl = document.createElement("div");
|
|
5689
|
+
titleEl.style.cssText = `color:${theme.text};font-size:16px;font-weight:700;line-height:1.3;`;
|
|
5690
|
+
titleEl.textContent = `Capture your ${docLabel}`;
|
|
5691
|
+
const subEl = document.createElement("div");
|
|
5692
|
+
subEl.style.cssText = `color:${theme.textSecondary};font-size:12px;margin-top:2px;`;
|
|
5693
|
+
subEl.textContent = requiresBack ? isCapturingFront ? "Step 1 of 2 \u2014 front side" : "Step 2 of 2 \u2014 back side" : "Choose how to provide your document";
|
|
5694
|
+
titleBlock.appendChild(titleEl);
|
|
5695
|
+
titleBlock.appendChild(subEl);
|
|
5696
|
+
headerRow.appendChild(iconBox);
|
|
5697
|
+
headerRow.appendChild(titleBlock);
|
|
5698
|
+
this.root.appendChild(headerRow);
|
|
5699
|
+
const btnRow = document.createElement("div");
|
|
5700
|
+
btnRow.style.cssText = `
|
|
5701
|
+
display:grid;grid-template-columns:1fr 1fr;gap:10px;
|
|
5702
|
+
padding:0 20px 14px;
|
|
5703
|
+
`;
|
|
5704
|
+
const cameraBtn = document.createElement("button");
|
|
5705
|
+
cameraBtn.style.cssText = `
|
|
5706
|
+
display:flex;flex-direction:column;align-items:center;justify-content:center;
|
|
5707
|
+
gap:8px;padding:16px 12px;
|
|
5708
|
+
background:${theme.primary};color:#fff;
|
|
5709
|
+
border:none;border-radius:14px;cursor:pointer;
|
|
5710
|
+
font-size:13px;font-weight:600;font-family:inherit;
|
|
5711
|
+
transition:all 0.15s ease;min-height:80px;
|
|
5712
|
+
box-shadow:0 4px 14px ${theme.primary}30;
|
|
5713
|
+
`;
|
|
5714
|
+
cameraBtn.innerHTML = `<span style="font-size:26px;">\u{1F4F7}</span><span>Take Photo</span><span style="font-size:10px;opacity:0.8;font-weight:500;">Use camera</span>`;
|
|
5715
|
+
cameraBtn.addEventListener("mouseenter", () => {
|
|
5716
|
+
cameraBtn.style.opacity = "0.9";
|
|
5717
|
+
cameraBtn.style.transform = "translateY(-1px)";
|
|
5718
|
+
});
|
|
5719
|
+
cameraBtn.addEventListener("mouseleave", () => {
|
|
5720
|
+
cameraBtn.style.opacity = "1";
|
|
5721
|
+
cameraBtn.style.transform = "none";
|
|
5722
|
+
});
|
|
5734
5723
|
cameraBtn.addEventListener("click", () => {
|
|
5735
|
-
this.showLoadingState("Opening camera...", theme);
|
|
5736
5724
|
this.root.innerHTML = "";
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5725
|
+
this.renderCameraView(this.root, theme, documentType);
|
|
5726
|
+
});
|
|
5727
|
+
const uploadBtn = document.createElement("button");
|
|
5728
|
+
uploadBtn.style.cssText = `
|
|
5729
|
+
display:flex;flex-direction:column;align-items:center;justify-content:center;
|
|
5730
|
+
gap:8px;padding:16px 12px;
|
|
5731
|
+
background:${theme.cardBg || theme.inputBg};color:${theme.text};
|
|
5732
|
+
border:2px solid ${theme.border};border-radius:14px;cursor:pointer;
|
|
5733
|
+
font-size:13px;font-weight:600;font-family:inherit;
|
|
5734
|
+
transition:all 0.15s ease;min-height:80px;
|
|
5735
|
+
`;
|
|
5736
|
+
uploadBtn.innerHTML = `<span style="font-size:26px;">\u{1F5BC}\uFE0F</span><span>From Gallery</span><span style="font-size:10px;color:${theme.textMuted || theme.textSecondary};font-weight:500;">Upload file</span>`;
|
|
5737
|
+
uploadBtn.addEventListener("mouseenter", () => {
|
|
5738
|
+
uploadBtn.style.borderColor = theme.primary;
|
|
5739
|
+
uploadBtn.style.transform = "translateY(-1px)";
|
|
5740
|
+
});
|
|
5741
|
+
uploadBtn.addEventListener("mouseleave", () => {
|
|
5742
|
+
uploadBtn.style.borderColor = theme.border;
|
|
5743
|
+
uploadBtn.style.transform = "none";
|
|
5740
5744
|
});
|
|
5741
|
-
actionsContainer.appendChild(cameraBtn);
|
|
5742
|
-
const uploadBtn = this.createEnhancedButton(
|
|
5743
|
-
"\u{1F4C1} Choose from Gallery",
|
|
5744
|
-
theme,
|
|
5745
|
-
false,
|
|
5746
|
-
"Upload document image from device"
|
|
5747
|
-
);
|
|
5748
5745
|
uploadBtn.addEventListener("click", () => {
|
|
5749
5746
|
this.handleFileUpload(container, theme);
|
|
5750
5747
|
});
|
|
5751
|
-
|
|
5752
|
-
|
|
5748
|
+
btnRow.appendChild(cameraBtn);
|
|
5749
|
+
btnRow.appendChild(uploadBtn);
|
|
5750
|
+
this.root.appendChild(btnRow);
|
|
5753
5751
|
const tips = document.createElement("div");
|
|
5754
5752
|
tips.style.cssText = `
|
|
5755
|
-
|
|
5756
|
-
background:${theme.shimmer
|
|
5757
|
-
|
|
5753
|
+
margin:0 20px 16px;padding:12px 14px;
|
|
5754
|
+
background:${theme.shimmer || theme.cardBg};
|
|
5755
|
+
border:1px solid ${theme.border};border-radius:12px;
|
|
5758
5756
|
`;
|
|
5759
|
-
const
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
tips.appendChild(tipsTitle);
|
|
5763
|
-
const tipsList = document.createElement("div");
|
|
5764
|
-
tipsList.style.cssText = `display:grid;gap:8px;font-size:13px;color:${theme.textSecondary};line-height:1.6;`;
|
|
5765
|
-
tipsList.innerHTML = `
|
|
5766
|
-
<div style="display:flex;gap:8px;align-items:flex-start;">
|
|
5767
|
-
<span style="color:${theme.primary};font-weight:bold;">\u2713</span>
|
|
5768
|
-
<span>Lay document flat on a solid surface</span>
|
|
5769
|
-
</div>
|
|
5770
|
-
<div style="display:flex;gap:8px;align-items:flex-start;">
|
|
5771
|
-
<span style="color:${theme.primary};font-weight:bold;">\u2713</span>
|
|
5772
|
-
<span>Ensure all four corners are visible</span>
|
|
5773
|
-
</div>
|
|
5774
|
-
<div style="display:flex;gap:8px;align-items:flex-start;">
|
|
5775
|
-
<span style="color:${theme.primary};font-weight:bold;">\u2713</span>
|
|
5776
|
-
<span>Use good lighting, avoid glare</span>
|
|
5777
|
-
</div>
|
|
5778
|
-
<div style="display:flex;gap:8px;align-items:flex-start;">
|
|
5779
|
-
<span style="color:${theme.primary};font-weight:bold;">\u2713</span>
|
|
5780
|
-
<span>Make sure all text is clearly readable</span>
|
|
5781
|
-
</div>
|
|
5757
|
+
const tipsGrid = document.createElement("div");
|
|
5758
|
+
tipsGrid.style.cssText = `
|
|
5759
|
+
display:grid;grid-template-columns:1fr 1fr;gap:6px 12px;
|
|
5782
5760
|
`;
|
|
5783
|
-
|
|
5761
|
+
const tipItems = [
|
|
5762
|
+
"Lay document flat",
|
|
5763
|
+
"All 4 corners visible",
|
|
5764
|
+
"Good lighting, no glare",
|
|
5765
|
+
"All text clearly readable"
|
|
5766
|
+
];
|
|
5767
|
+
tipItems.forEach((t2) => {
|
|
5768
|
+
const row = document.createElement("div");
|
|
5769
|
+
row.style.cssText = `display:flex;align-items:center;gap:5px;font-size:11px;color:${theme.textSecondary};`;
|
|
5770
|
+
row.innerHTML = `<span style="color:${theme.primary};font-weight:700;flex-shrink:0;">\u2713</span><span>${t2}</span>`;
|
|
5771
|
+
tipsGrid.appendChild(row);
|
|
5772
|
+
});
|
|
5773
|
+
tips.appendChild(tipsGrid);
|
|
5784
5774
|
this.root.appendChild(tips);
|
|
5775
|
+
if (requiresBack && isCapturingFront) {
|
|
5776
|
+
const notice = document.createElement("div");
|
|
5777
|
+
notice.style.cssText = `
|
|
5778
|
+
margin:0 20px 16px;padding:10px 14px;
|
|
5779
|
+
background:${theme.primary}0D;
|
|
5780
|
+
border:1px solid ${theme.primary}25;border-radius:10px;
|
|
5781
|
+
display:flex;align-items:center;gap:8px;
|
|
5782
|
+
font-size:12px;color:${theme.textSecondary};line-height:1.5;
|
|
5783
|
+
`;
|
|
5784
|
+
notice.innerHTML = `<span style="font-size:16px;flex-shrink:0;">\u2139\uFE0F</span><span>You'll capture both the <strong style="color:${theme.text}">front</strong> and <strong style="color:${theme.text}">back</strong> of this document.</span>`;
|
|
5785
|
+
this.root.appendChild(notice);
|
|
5786
|
+
}
|
|
5785
5787
|
const fileInput = document.createElement("input");
|
|
5786
5788
|
fileInput.type = "file";
|
|
5787
5789
|
fileInput.accept = "image/jpeg,image/png";
|
|
@@ -5790,18 +5792,26 @@ var SmartComplySDK = (() => {
|
|
|
5790
5792
|
fileInput.addEventListener("change", (e2) => {
|
|
5791
5793
|
const file = e2.target.files?.[0];
|
|
5792
5794
|
if (file) {
|
|
5793
|
-
const
|
|
5794
|
-
if (
|
|
5795
|
-
this.showError(
|
|
5795
|
+
const err = this.validateFile(file);
|
|
5796
|
+
if (err) {
|
|
5797
|
+
this.showError(err);
|
|
5796
5798
|
return;
|
|
5797
5799
|
}
|
|
5798
5800
|
this.showLoadingState("Processing image...", theme);
|
|
5799
|
-
this.compressImage(file, 1280, 960, 0.85).then((
|
|
5801
|
+
this.compressImage(file, 1280, 960, 0.85).then((c2) => this.handleFileUploadComplete(c2, container, theme, documentType)).catch(() => this.handleFileUploadComplete(file, container, theme, documentType));
|
|
5800
5802
|
}
|
|
5801
5803
|
});
|
|
5802
5804
|
this.root.appendChild(fileInput);
|
|
5803
5805
|
container.appendChild(this.root);
|
|
5804
5806
|
}
|
|
5807
|
+
/** Returns an appropriate emoji icon for the document type. */
|
|
5808
|
+
_docIcon(documentType) {
|
|
5809
|
+
const t2 = documentType.toLowerCase();
|
|
5810
|
+
if (t2.includes("passport")) return "\u{1F4D8}";
|
|
5811
|
+
if (t2.includes("driver") || t2.includes("licen")) return "\u{1F697}";
|
|
5812
|
+
if (t2.includes("voter") || t2.includes("pvc")) return "\u{1F5F3}\uFE0F";
|
|
5813
|
+
return "\u{1FAAA}";
|
|
5814
|
+
}
|
|
5805
5815
|
renderCameraView(container, theme, documentType) {
|
|
5806
5816
|
const wrapper = document.createElement("div");
|
|
5807
5817
|
wrapper.style.cssText = "position:relative;width:100%;border-radius:12px;overflow:hidden;background:#000;";
|