@hubsync/esign-web-sdk 6.5.15 → 6.5.17

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.
@@ -382,10 +382,10 @@ export class VerdocsSign {
382
382
  // logic to the fields.
383
383
  const field = this.getRecipientFields().find(field => field.name === fieldName);
384
384
  if (field === null || field === void 0 ? void 0 : field.readonly) {
385
- return;
385
+ return Promise.resolve();
386
386
  }
387
387
  console.log('[SIGN] saveFieldChange', fieldName, { value, prepared });
388
- updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, fieldName, value, prepared)
388
+ return updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, fieldName, value, prepared)
389
389
  .then(updateResult => this.updateRecipientFieldValue(fieldName, updateResult))
390
390
  .catch(e => {
391
391
  var _a, _b, _c, _d, _e, _f;
@@ -399,6 +399,7 @@ export class VerdocsSign {
399
399
  VerdocsToast('Unable to save change, please try again later', { style: 'error' });
400
400
  }
401
401
  (_d = this.sdkError) === null || _d === void 0 ? void 0 : _d.emit(new SDKError(e.message, (_e = e.response) === null || _e === void 0 ? void 0 : _e.status, (_f = e.response) === null || _f === void 0 ? void 0 : _f.data));
402
+ throw e;
402
403
  });
403
404
  }
404
405
  async handleFieldChange(field, e) {
@@ -439,14 +440,40 @@ export class VerdocsSign {
439
440
  if (this.initialId) {
440
441
  console.log('[SIGN] Reusing initial', this.initialId);
441
442
  const updateResult = await updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, field.name, this.initialId, false);
442
- return this.updateRecipientFieldValue(field.name, updateResult);
443
+ this.updateRecipientFieldValue(field.name, updateResult);
444
+ // Auto-focus next field after filling initial (only if not the last field)
445
+ setTimeout(() => {
446
+ const fields = this.getSortedFillableFields();
447
+ const currentIndex = fields.findIndex(f => f.name === field.name);
448
+ // Only focus next field if current field is not the last one
449
+ if (currentIndex >= 0 && currentIndex < fields.length - 1) {
450
+ const nextField = this.getNextFieldFromList(fields);
451
+ if (nextField && fields.findIndex(f => f.name === nextField.name) > currentIndex) {
452
+ this.focusField(nextField);
453
+ }
454
+ }
455
+ }, 100);
456
+ return;
443
457
  }
444
458
  // If it's a UUID, it's an existing initial ID we can just reuse
445
459
  if (typeof e.detail === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e.detail)) {
446
460
  console.log('[SIGN] Reusing initial', e.detail);
447
461
  const updateResult = await updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, field.name, e.detail, false);
448
462
  this.initialId = e.detail;
449
- return this.updateRecipientFieldValue(field.name, updateResult);
463
+ this.updateRecipientFieldValue(field.name, updateResult);
464
+ // Auto-focus next field after filling initial (only if not the last field)
465
+ setTimeout(() => {
466
+ const fields = this.getSortedFillableFields();
467
+ const currentIndex = fields.findIndex(f => f.name === field.name);
468
+ // Only focus next field if current field is not the last one
469
+ if (currentIndex >= 0 && currentIndex < fields.length - 1) {
470
+ const nextField = this.getNextFieldFromList(fields);
471
+ if (nextField && fields.findIndex(f => f.name === nextField.name) > currentIndex) {
472
+ this.focusField(nextField);
473
+ }
474
+ }
475
+ }, 100);
476
+ return;
450
477
  }
451
478
  this.showSpinner = true;
452
479
  const initialsBlob = await (await fetch(e.detail)).blob();
@@ -456,6 +483,14 @@ export class VerdocsSign {
456
483
  this.updateRecipientFieldValue(field.name, updateResult);
457
484
  this.initialId = newInitials.id;
458
485
  this.showSpinner = false;
486
+ // Auto-focus next field after filling initial
487
+ setTimeout(() => {
488
+ const fields = this.getSortedFillableFields();
489
+ const nextField = this.getNextFieldFromList(fields);
490
+ if (nextField) {
491
+ this.focusField(nextField);
492
+ }
493
+ }, 100);
459
494
  })
460
495
  .catch(e => {
461
496
  console.log('Error updating initials', e);
@@ -481,14 +516,40 @@ export class VerdocsSign {
481
516
  if (this.signatureId) {
482
517
  console.log('[SIGN] Reusing signature', this.signatureId);
483
518
  const updateResult = await updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, field.name, this.signatureId, false);
484
- return this.updateRecipientFieldValue(field.name, updateResult);
519
+ this.updateRecipientFieldValue(field.name, updateResult);
520
+ // Auto-focus next field after filling signature (only if not the last field)
521
+ setTimeout(() => {
522
+ const fields = this.getSortedFillableFields();
523
+ const currentIndex = fields.findIndex(f => f.name === field.name);
524
+ // Only focus next field if current field is not the last one
525
+ if (currentIndex >= 0 && currentIndex < fields.length - 1) {
526
+ const nextField = this.getNextFieldFromList(fields);
527
+ if (nextField && fields.findIndex(f => f.name === nextField.name) > currentIndex) {
528
+ this.focusField(nextField);
529
+ }
530
+ }
531
+ }, 100);
532
+ return;
485
533
  }
486
534
  // If it's a UUID, it's an existing signature ID we can just reuse
487
535
  if (typeof e.detail === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e.detail)) {
488
536
  console.log('[SIGN] Reusing signature', e.detail);
489
537
  const updateResult = await updateEnvelopeField(this.endpoint, this.envelopeId, this.roleId, field.name, e.detail, false);
490
538
  this.signatureId = e.detail;
491
- return this.updateRecipientFieldValue(field.name, updateResult);
539
+ this.updateRecipientFieldValue(field.name, updateResult);
540
+ // Auto-focus next field after filling signature (only if not the last field)
541
+ setTimeout(() => {
542
+ const fields = this.getSortedFillableFields();
543
+ const currentIndex = fields.findIndex(f => f.name === field.name);
544
+ // Only focus next field if current field is not the last one
545
+ if (currentIndex >= 0 && currentIndex < fields.length - 1) {
546
+ const nextField = this.getNextFieldFromList(fields);
547
+ if (nextField && fields.findIndex(f => f.name === nextField.name) > currentIndex) {
548
+ this.focusField(nextField);
549
+ }
550
+ }
551
+ }, 100);
552
+ return;
492
553
  }
493
554
  this.showSpinner = true;
494
555
  const signatureBlob = await (await fetch(e.detail)).blob();
@@ -500,6 +561,14 @@ export class VerdocsSign {
500
561
  this.updateRecipientFieldValue(field.name, updateResult);
501
562
  this.signatureId = newSignature.id;
502
563
  this.showSpinner = false;
564
+ // Auto-focus next field after filling signature
565
+ setTimeout(() => {
566
+ const fields = this.getSortedFillableFields();
567
+ const nextField = this.getNextFieldFromList(fields);
568
+ if (nextField) {
569
+ this.focusField(nextField);
570
+ }
571
+ }, 100);
503
572
  })
504
573
  .catch(e => {
505
574
  console.warn('[SIGN] Error updating signature', e);
@@ -509,7 +578,20 @@ export class VerdocsSign {
509
578
  case 'date':
510
579
  const { formattedDate } = e.detail;
511
580
  if (formattedDate) {
512
- return this.saveFieldChange(field.name, formattedDate, false);
581
+ return this.saveFieldChange(field.name, formattedDate, false).then(() => {
582
+ // Auto-focus next field after filling date (only if not the last field)
583
+ setTimeout(() => {
584
+ const fields = this.getSortedFillableFields();
585
+ const currentIndex = fields.findIndex(f => f.name === field.name);
586
+ // Only focus next field if current field is not the last one
587
+ if (currentIndex >= 0 && currentIndex < fields.length - 1) {
588
+ const nextField = this.getNextFieldFromList(fields);
589
+ if (nextField && fields.findIndex(f => f.name === nextField.name) > currentIndex) {
590
+ this.focusField(nextField);
591
+ }
592
+ }
593
+ }, 100);
594
+ });
513
595
  }
514
596
  break;
515
597
  case 'timestamp':