@verdocs/web-sdk 6.5.0-beta.23 → 6.5.0-beta.25

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.
@@ -916,18 +916,25 @@ const VerdocsSign = class {
916
916
  filledFields: recipientFields.filter(f => isFilled(f)).map(f => ({ name: f.name, type: f.type, val: f.value })),
917
917
  });
918
918
  let mode = 'start';
919
- // We only consider the user to have started "signing" if they have filled out at least one *fillable* field.
920
- // Readonly fields do not count.
921
- const anyFieldFilled = requiredRemaining < requiredFields.length || optionalRemaining < optionalFields.length;
919
+ // We need a way to know if the user has started signing. But after trying two
920
+ // obvious ways (has the user adopted a signature? are any fields filled in yet?)
921
+ // they both had flaws (we could be carrying over a sig from a previous session,
922
+ // and things like defaults and auto-filled fields make the filled-field approach
923
+ // tricky to maintain).
924
+ // This is sort of a Hail Mary but it works well for now. We just keep a variable
925
+ // in localStorage that tracks the last 10 envelopes the user has "started".
926
+ // We never get a chance to clean them up but 10 GUIDs is tiny compared to what
927
+ // many apps store in a user's browser.
928
+ const startedEnvelopes = JSON.parse(localStorage.getItem('startedEnvelopes') || '[]');
929
+ const hasStarted = startedEnvelopes.includes(this.envelopeId);
922
930
  if (this.nextSubmits) {
923
931
  mode = 'completed';
924
932
  }
925
- else if (anyFieldFilled) {
933
+ else if (hasStarted) {
926
934
  mode = 'signing';
927
935
  }
928
936
  return (h("verdocs-signing-progress", { mode: mode, current: Math.max(1, currentIndex), total: totalFields, remainingFields: remainingFields, progress: progress, fieldLabel: getFieldLabel(focusedFieldObj), fieldCompleted: focusedFieldObj ? !!isFilled(focusedFieldObj) : false, onStarted: () => {
929
937
  this.adoptingSignature = true;
930
- // this.handleNext();
931
938
  }, onNext: () => this.handleNext(), onPrevious: () => this.handlePrev(), onExit: () => this.handleNext() }));
932
939
  })(), h("div", { class: `document signed-document-container zoom-${this.zoomLevel}` }, (this.envelope.documents || []).map(envelopeDocument => {
933
940
  const pageNumbers = integerSequence(1, envelopeDocument.pages);
@@ -967,6 +974,14 @@ const VerdocsSign = class {
967
974
  this.initialId = initResult.id;
968
975
  this.showSpinner = false;
969
976
  this.adoptingSignature = false;
977
+ const startedEnvelopes = JSON.parse(localStorage.getItem('startedEnvelopes') || '[]');
978
+ if (!startedEnvelopes.includes(this.envelopeId)) {
979
+ startedEnvelopes.push(this.envelopeId);
980
+ while (startedEnvelopes.length > 10) {
981
+ startedEnvelopes.shift();
982
+ }
983
+ localStorage.setItem('startedEnvelopes', JSON.stringify(startedEnvelopes));
984
+ }
970
985
  }, onExit: () => (this.adoptingSignature = false) })), (this.submitting || this.showSpinner) && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null)))), this.showDownloadDialog && (h("verdocs-download-dialog", { hasCertificate: (_b = (_a = this.envelope) === null || _a === void 0 ? void 0 : _a.documents) === null || _b === void 0 ? void 0 : _b.some(d => d.type === 'certificate'), onExit: () => (this.showDownloadDialog = false), onNext: async (e) => {
971
986
  this.showDownloadDialog = false;
972
987
  const { action } = e.detail;