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