@hubsync/esign-web-sdk 6.9.12 → 6.9.13

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.
@@ -432,11 +432,9 @@ const VerdocsSign = class {
432
432
  }
433
433
  focusNextFieldAfter(field) {
434
434
  setTimeout(() => {
435
- const fields = this.getSortedFillableFields();
436
- const currentIndex = fields.findIndex(f => f.name === field.name);
437
- if (currentIndex >= 0 && currentIndex < fields.length - 1) {
438
- this.focusFieldElement(fields[currentIndex + 1]);
439
- }
435
+ const next = this.getNextUnfilledField(field);
436
+ if (next)
437
+ this.focusFieldElement(next);
440
438
  }, 100);
441
439
  }
442
440
  focusFieldElement(field) {
@@ -451,11 +449,6 @@ const VerdocsSign = class {
451
449
  handleStartSigning() {
452
450
  this.markEnvelopeStarted();
453
451
  this.signingProgressMode = 'signing';
454
- const fields = this.getSortedFillableFields();
455
- const startField = fields.find(field => !this.isFieldActuallyFilled(field)) || fields[0];
456
- if (startField) {
457
- this.focusFieldElement(startField);
458
- }
459
452
  this.adoptingSignature = true;
460
453
  }
461
454
  async handleFieldChange(field, e) {
@@ -616,12 +609,10 @@ const VerdocsSign = class {
616
609
  }
617
610
  return;
618
611
  }
619
- // Find all unfilled fields and move to the next one in sequence
620
- const allUnfilled = this.getSortedFillableFields().filter(f => !this.isFieldActuallyFilled(f));
621
- const nextUnfilled = this.getNextFieldFromList(allUnfilled);
622
- if (nextUnfilled) {
623
- this.focusFieldElement(nextUnfilled);
624
- }
612
+ const currentField = this.getSortedFillableFields().find(f => f.name === this.focusedField);
613
+ const next = this.getNextUnfilledField(currentField);
614
+ if (next)
615
+ this.focusFieldElement(next);
625
616
  }
626
617
  handleNextOptional() {
627
618
  const unfilledOptional = this.getSortedFillableFields().filter(f => !f.required && !this.isFieldActuallyFilled(f));
@@ -645,8 +636,10 @@ const VerdocsSign = class {
645
636
  }
646
637
  // See if everything that "needs to be" filled in is, and all "fillable fields" are valid
647
638
  checkRecipientFields() {
648
- const invalidFields = this.getRecipientFields().filter(field => !isFieldValid(field, this.getRecipientFields()));
649
- if (invalidFields.length < 1) {
639
+ const allFields = this.getSortedFillableFields();
640
+ const requiredIncomplete = allFields.some(f => f.required && !this.isFieldActuallyFilled(f));
641
+ const invalidFilled = allFields.some(f => this.isFieldActuallyFilled(f) && !isFieldValid(f, this.getRecipientFields()));
642
+ if (!requiredIncomplete && !invalidFilled) {
650
643
  this.nextButtonLabel = 'Finish';
651
644
  if (!this.nextSubmits) {
652
645
  this.nextSubmits = true;
@@ -690,20 +683,15 @@ const VerdocsSign = class {
690
683
  (field.type !== 'radio' || field.value === 'true') &&
691
684
  (field.type !== 'checkbox' || field.value === 'true'));
692
685
  }
693
- getNextRequiredField() {
694
- // Find and focus the next incomplete field (that is fillable)
695
- const emptyFields = this.getSortedFillableFields().filter(field => field.required && !this.isFieldActuallyFilled(field));
696
- sortFields(emptyFields);
697
- if (emptyFields.length === 0) {
698
- const allUnfilled = this.getSortedFillableFields().filter(field => !this.isFieldActuallyFilled(field));
699
- sortFields(allUnfilled);
700
- if (allUnfilled.length > 0) {
701
- // If we are here, there are no required fields left, but there are optional ones.
702
- return this.getNextFieldFromList(allUnfilled);
703
- }
704
- return null;
705
- }
706
- return this.getNextFieldFromList(emptyFields);
686
+ getNextUnfilledField(after) {
687
+ const allFields = this.getSortedFillableFields();
688
+ const startIndex = after ? allFields.findIndex(f => f.name === after.name) + 1 : 0;
689
+ // Look forward from current position first
690
+ const nextAfter = allFields.slice(startIndex).find(f => !this.isFieldActuallyFilled(f));
691
+ if (nextAfter)
692
+ return nextAfter;
693
+ // Wrap to beginning if nothing unfilled ahead
694
+ return allFields.slice(0, startIndex).find(f => !this.isFieldActuallyFilled(f)) || null;
707
695
  }
708
696
  getNextFieldFromList(fields) {
709
697
  const focusedIndex = fields.findIndex(field => field.name === this.focusedField);
@@ -736,14 +724,16 @@ const VerdocsSign = class {
736
724
  // Remove existing flags
737
725
  const existingFlags = controlsDiv.querySelectorAll('.verdocs-flag-instance');
738
726
  existingFlags.forEach(el => el.remove());
739
- let nextField = this.getNextRequiredField();
740
727
  const focusedFieldObj = this.getRecipientFields().find(f => f.name === this.focusedField);
741
- // If the currently focused field is unfilled, we should point the flag to IT, not the next one.
742
- // getNextRequiredField() is designed for the "Next" button (skipping current), but the visual flag
743
- // should guide the user to the current task if it's incomplete.
728
+ // If the currently focused field is unfilled, point the flag to it.
729
+ // Otherwise find the next unfilled field forward from the current position.
730
+ let nextField;
744
731
  if (focusedFieldObj && !this.isFieldActuallyFilled(focusedFieldObj)) {
745
732
  nextField = focusedFieldObj;
746
733
  }
734
+ else {
735
+ nextField = this.getNextUnfilledField(focusedFieldObj);
736
+ }
747
737
  if (nextField && nextField.page === pageInfo.pageNumber && nextField.document_id === pageInfo.documentId) {
748
738
  const variant = 'fill';
749
739
  let label = 'FILL';
@@ -1080,7 +1070,7 @@ const VerdocsSign = class {
1080
1070
  return (h("span", { class: "remaining-count" }, remaining, " required field", remaining === 1 ? '' : 's', " left"));
1081
1071
  }
1082
1072
  return (h("span", { class: "remaining-count" }, h("span", { class: "check-icon", innerHTML: CheckCircleIcon }), "All required fields complete", optionalLeft > 0 && h("span", { class: "separator" }, "|"), optionalLeft > 0 && (h("span", { class: "review-optional", onClick: () => this.handleNextOptional() }, "Review ", optionalLeft, " optional"))));
1083
- })(), !this.finishLater && (h("verdocs-button", { size: "xsmall", label: this.nextButtonLabel === 'Next' ? 'Next Required' : this.nextButtonLabel, disabled: !this.agreed || this.submitting, onClick: () => this.handleNext() })), h("div", { class: { 'icon-button': true, 'minus': true, 'disabled': this.zoomLevel === 'normal' }, innerHTML: ToolbarMinusIcon, onClick: () => this.handleZoomOut() }), h("div", { class: { 'icon-button': true, 'plus': true, 'disabled': this.zoomLevel === 'zoom2' }, innerHTML: ToolbarPlusIcon, onClick: () => this.handleZoomIn() }), h("verdocs-dropdown", { options: !this.isDone && !this.finishLater ? inProgressMenuOptions : doneMenuOptions, onOptionSelected: e => this.handleOptionSelected(e) })))), this.toolbarStyle === 'controls' && (h("div", { class: "controls-toolbar" }, h("div", { class: "left-controls" }, h("div", { class: "title" }, this.envelope.name)), h("div", { class: "center-controls", style: { display: 'none' } }, h("span", { class: "label" }, "Page"), h("div", { class: "select-wrapper" }, h("verdocs-select-input", { options: pageOptions, value: this.pageNumber.toString(), onInput: e => this.handlePageSelect(e) })), h("span", { class: "count" }, "of ", totalPages)), h("div", { class: "right-controls" }, h("verdocs-button", { class: "mobile-next-button", label: this.nextButtonLabel, size: "xsmall", disabled: !this.agreed || this.submitting, onClick: () => this.handleNext() }), h("div", { class: { 'icon-button': true, 'minus': true, 'disabled': this.zoomLevel === 'normal' }, innerHTML: ToolbarMinusIcon, onClick: () => this.handleZoomOut() }), h("div", { class: { 'icon-button': true, 'plus': true, 'disabled': this.zoomLevel === 'zoom2' }, innerHTML: ToolbarPlusIcon, onClick: () => this.handleZoomIn() }), h("div", { class: "icon-button download", innerHTML: ToolbarDownloadIcon, onClick: () => this.handleOptionSelected({ detail: { id: 'download' } }) }), h("div", { class: "icon-button print", innerHTML: ToolbarPrintIcon, onClick: () => this.handleOptionSelected({ detail: { id: 'print' } }) })))), h("verdocs-signing-progress", { mode: this.signingProgressMode, focusedField: this.focusedField, fields: this.getSortedFillableFields(), recipientFields: this.getRecipientFields(), onStarted: () => {
1073
+ })(), !this.finishLater && (h("verdocs-button", { size: "xsmall", label: this.nextButtonLabel, disabled: !this.agreed || this.submitting, onClick: () => this.handleNext() })), h("div", { class: { 'icon-button': true, 'minus': true, 'disabled': this.zoomLevel === 'normal' }, innerHTML: ToolbarMinusIcon, onClick: () => this.handleZoomOut() }), h("div", { class: { 'icon-button': true, 'plus': true, 'disabled': this.zoomLevel === 'zoom2' }, innerHTML: ToolbarPlusIcon, onClick: () => this.handleZoomIn() }), h("verdocs-dropdown", { options: !this.isDone && !this.finishLater ? inProgressMenuOptions : doneMenuOptions, onOptionSelected: e => this.handleOptionSelected(e) })))), this.toolbarStyle === 'controls' && (h("div", { class: "controls-toolbar" }, h("div", { class: "left-controls" }, h("div", { class: "title" }, this.envelope.name)), h("div", { class: "center-controls", style: { display: 'none' } }, h("span", { class: "label" }, "Page"), h("div", { class: "select-wrapper" }, h("verdocs-select-input", { options: pageOptions, value: this.pageNumber.toString(), onInput: e => this.handlePageSelect(e) })), h("span", { class: "count" }, "of ", totalPages)), h("div", { class: "right-controls" }, h("verdocs-button", { class: "mobile-next-button", label: this.nextButtonLabel, size: "xsmall", disabled: !this.agreed || this.submitting, onClick: () => this.handleNext() }), h("div", { class: { 'icon-button': true, 'minus': true, 'disabled': this.zoomLevel === 'normal' }, innerHTML: ToolbarMinusIcon, onClick: () => this.handleZoomOut() }), h("div", { class: { 'icon-button': true, 'plus': true, 'disabled': this.zoomLevel === 'zoom2' }, innerHTML: ToolbarPlusIcon, onClick: () => this.handleZoomIn() }), h("div", { class: "icon-button download", innerHTML: ToolbarDownloadIcon, onClick: () => this.handleOptionSelected({ detail: { id: 'download' } }) }), h("div", { class: "icon-button print", innerHTML: ToolbarPrintIcon, onClick: () => this.handleOptionSelected({ detail: { id: 'print' } }) })))), h("verdocs-signing-progress", { mode: this.signingProgressMode, focusedField: this.focusedField, fields: this.getSortedFillableFields(), recipientFields: this.getRecipientFields(), onStarted: () => {
1084
1074
  this.handleStartSigning();
1085
1075
  }, onNext: () => this.handleNext(), onPrevious: () => this.handlePrev(), onExit: () => this.handleNext() }), h("div", { class: `document signed-document-container zoom-${this.zoomLevel}` }, (this.envelope.documents || []).map(envelopeDocument => {
1086
1076
  const pageNumbers = integerSequence(1, envelopeDocument.pages);
@@ -1121,7 +1111,10 @@ const VerdocsSign = class {
1121
1111
  this.showSpinner = false;
1122
1112
  this.adoptingSignature = false;
1123
1113
  this.markEnvelopeStarted();
1124
- // Apply the new signature/initials to the field that triggered the dialog.
1114
+ // Apply the new signature/initials to the field that triggered the dialog (e.g. user
1115
+ // clicked an existing sig/initial field). Track which field was applied so we can
1116
+ // advance forward from it rather than jumping back to the start of the document.
1117
+ let appliedToField = null;
1125
1118
  if (this.focusedField) {
1126
1119
  const fieldObj = this.getRecipientFields().find(f => f.name === this.focusedField);
1127
1120
  if (fieldObj) {
@@ -1129,10 +1122,16 @@ const VerdocsSign = class {
1129
1122
  if (id) {
1130
1123
  const updateResult = await updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, fieldObj.name, id, false);
1131
1124
  this.updateRecipientFieldValue(fieldObj.name, updateResult);
1125
+ appliedToField = fieldObj;
1132
1126
  }
1133
1127
  }
1134
1128
  this.focusedField = '';
1135
1129
  }
1130
+ // Navigate to the next unfilled field: forward from where we applied (or from the
1131
+ // beginning when adopting at session start with no pre-focused field).
1132
+ const nextField = this.getNextUnfilledField(appliedToField !== null && appliedToField !== void 0 ? appliedToField : undefined);
1133
+ if (nextField)
1134
+ this.focusFieldElement(nextField);
1136
1135
  // Update any existing field elements in the DOM with the new IDs. This prevents them from
1137
1136
  // needing to show the adoption dialog again if they are clicked.
1138
1137
  const sigFields = this.el.querySelectorAll('verdocs-field-signature');