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.
@@ -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 = "display:flex;flex-direction:column;align-items:center;gap:24px;padding:24px 20px;max-width:100%;";
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 header = document.createElement("div");
5670
- header.style.cssText = "display:flex;flex-direction:column;align-items:center;gap:16px;text-align:center;";
5671
- const iconContainer = document.createElement("div");
5672
- iconContainer.style.cssText = `
5673
- width:120px;height:120px;border-radius:24px;
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
- background:linear-gradient(135deg, ${theme.primary}15, ${theme.primary}05);
5676
- border:3px solid ${theme.primary}30;
5677
- position:relative;overflow:hidden;
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
- const icon = document.createElement("div");
5681
- icon.style.cssText = "font-size:48px;animation:float 3s ease-in-out infinite;";
5682
- icon.textContent = "\u{1FAAA}";
5683
- iconContainer.appendChild(icon);
5684
- if (!document.head.querySelector("style[data-float-animation]")) {
5685
- const style2 = document.createElement("style");
5686
- style2.setAttribute("data-float-animation", "true");
5687
- style2.textContent = `
5688
- @keyframes float {
5689
- 0%, 100% { transform: translateY(0px); }
5690
- 50% { transform: translateY(-10px); }
5691
- }
5692
- `;
5693
- document.head.appendChild(style2);
5694
- }
5695
- header.appendChild(iconContainer);
5696
- const title = document.createElement("div");
5697
- title.style.cssText = `color:${theme.text};font-size:20px;font-weight:700;text-align:center;line-height:1.4;`;
5698
- let labelText = `Capture your ${docLabel}`;
5699
- if (requiresBack) {
5700
- labelText += ` (${isCapturingFront ? "Front Side" : "Back Side"})`;
5701
- }
5702
- title.textContent = labelText;
5703
- header.appendChild(title);
5704
- const subtitle = document.createElement("div");
5705
- subtitle.style.cssText = `color:${theme.textSecondary};font-size:14px;text-align:center;line-height:1.5;max-width:280px;`;
5706
- subtitle.textContent = "Choose how you'd like to provide your document";
5707
- header.appendChild(subtitle);
5708
- this.root.appendChild(header);
5709
- if (requiresBack) {
5710
- const progress = document.createElement("div");
5711
- progress.style.cssText = `
5712
- display:flex;flex-direction:column;align-items:center;gap:12px;
5713
- padding:16px 20px;background:${theme.primary}08;border-radius:16px;
5714
- border:1px solid ${theme.primary}20;width:100%;max-width:320px;
5715
- `;
5716
- progress.innerHTML = `
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
- setTimeout(() => {
5738
- this.renderCameraView(this.root, theme, documentType);
5739
- }, 500);
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
- actionsContainer.appendChild(uploadBtn);
5752
- this.root.appendChild(actionsContainer);
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
- width:100%;padding:16px 20px;border-radius:16px;
5756
- background:${theme.shimmer};border:1px solid ${theme.border};
5757
- margin-top:8px;
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 tipsTitle = document.createElement("div");
5760
- tipsTitle.style.cssText = `font-weight:700;color:${theme.text};margin-bottom:12px;font-size:14px;display:flex;align-items:center;gap:8px;`;
5761
- tipsTitle.innerHTML = `\u{1F4A1} Tips for best results`;
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
- tips.appendChild(tipsList);
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 validationError = this.validateFile(file);
5794
- if (validationError) {
5795
- this.showError(validationError);
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((compressed) => this.handleFileUploadComplete(compressed, container, theme, documentType)).catch(() => this.handleFileUploadComplete(file, container, theme, documentType));
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;";