@verdocs/web-sdk 4.2.132 → 4.2.135

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.
@@ -8,8 +8,8 @@ const TemplateFieldStore = require('./TemplateFieldStore-836d8bf5.js');
8
8
  const TemplateRoleStore = require('./TemplateRoleStore-fe871897.js');
9
9
  const TemplateStore = require('./TemplateStore-d11d62c0.js');
10
10
  const errors = require('./errors-017fb835.js');
11
- const Icons = require('./Icons-9a6f2f7c.js');
12
11
  const Toast = require('./Toast-d84d7bd3.js');
12
+ const Icons = require('./Icons-9a6f2f7c.js');
13
13
  const format = require('./format-dc0f3757.js');
14
14
  const interact_min = require('./interact.min-e6956f8b.js');
15
15
  const utils = require('./utils-5accd019.js');
@@ -262,7 +262,7 @@ const VerdocsSend = class {
262
262
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: true });
263
263
  const details = {
264
264
  template_id: this.templateId,
265
- name: (_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name,
265
+ name: ((_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name) || '',
266
266
  environment: this.environment,
267
267
  // TODO: Make optional in the SDK
268
268
  initial_reminder: 0,
@@ -274,19 +274,19 @@ const VerdocsSend = class {
274
274
  console.log('[SEND] Creating envelope', details);
275
275
  jsSdk.createEnvelope(this.endpoint, details)
276
276
  .then(r => {
277
- var _a, _b;
277
+ var _a, _b, _c, _d;
278
278
  console.log('[SEND] Send envelope', r);
279
279
  this.reset().catch((e) => console.log('Unknown Error', e));
280
280
  this.sending = false;
281
281
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
282
- (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, envelope_id: r.id, envelope: r });
282
+ (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, name: ((_d = (_c = this.templateStore) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.name) || 'New Envelope', envelope_id: r.id, envelope: r });
283
283
  })
284
284
  .catch(e => {
285
- var _a;
285
+ var _a, _b, _c;
286
286
  console.log('Send error', e);
287
- // toast.error(e.response?.data?.message || 'Unknown error creating envelope');
287
+ Toast.VerdocsToast(((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || 'Error creating envelope, please try again later.');
288
288
  this.sending = false;
289
- (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
289
+ (_c = this.sendingEnvelope) === null || _c === void 0 ? void 0 : _c.emit({ sending: false });
290
290
  });
291
291
  }
292
292
  handleCancel(e) {
@@ -265,11 +265,17 @@ const VerdocsSign = class {
265
265
  if (!e.detail) {
266
266
  return;
267
267
  }
268
+ this.showSpinner = true;
268
269
  const initialsBlob = await (await fetch(e.detail)).blob();
269
270
  return jsSdk.createInitials(this.endpoint, 'initial', initialsBlob) //
270
271
  .then(async (newInitials) => {
271
272
  const updateResult = await jsSdk.updateEnvelopeFieldInitials(this.endpoint, this.envelopeId, field.name, newInitials.id);
272
273
  this.updateRecipientFieldValue(field.name, updateResult);
274
+ this.showSpinner = false;
275
+ })
276
+ .catch(e => {
277
+ console.log('Error updating initials', e);
278
+ this.showSpinner = false;
273
279
  });
274
280
  case 'signature':
275
281
  // This can be caused by a focus-out event if the user clicks the field
@@ -278,15 +284,18 @@ const VerdocsSign = class {
278
284
  if (!e.detail) {
279
285
  return;
280
286
  }
287
+ this.showSpinner = true;
281
288
  const signatureBlob = await (await fetch(e.detail)).blob();
282
289
  return jsSdk.createSignature(this.endpoint, 'signature', signatureBlob) //
283
290
  .then(async (newSignature) => {
284
291
  console.log('Signature update result', newSignature);
285
292
  const updateResult = await jsSdk.updateEnvelopeFieldSignature(this.endpoint, this.envelopeId, field.name, newSignature.id);
286
293
  this.updateRecipientFieldValue(field.name, updateResult);
294
+ this.showSpinner = false;
287
295
  })
288
296
  .catch(e => {
289
297
  console.warn('[SIGN] Error updating signature', e);
298
+ this.showSpinner = false;
290
299
  });
291
300
  case 'date':
292
301
  const { formattedDate } = e.detail;
@@ -366,16 +375,17 @@ const VerdocsSign = class {
366
375
  this.envelope = envelope;
367
376
  // The show-done dialog does this
368
377
  // this.isDone = true;
378
+ this.submitting = false;
369
379
  })
370
380
  .catch(e => {
371
381
  // this.isDone = true;
372
382
  console.log('[SIGN] Error reloading envelope', e);
383
+ this.submitting = false;
373
384
  });
374
385
  }
375
386
  catch (e) {
376
387
  console.log('[SIGN] Error submitting', e);
377
388
  }
378
- this.submitting = false;
379
389
  return;
380
390
  }
381
391
  // Find and focus the next incomplete field (that is fillable)
@@ -451,7 +461,6 @@ const VerdocsSign = class {
451
461
  }
452
462
  });
453
463
  el.addEventListener('attached', async (e) => {
454
- // TODO: Show a spinner and/or progress bar
455
464
  console.log('[SIGN] onAttached', e.detail, e.target.value);
456
465
  this.showSpinner = true;
457
466
  try {
@@ -514,7 +523,6 @@ const VerdocsSign = class {
514
523
  if (field.page !== pageInfo.pageNumber) {
515
524
  return;
516
525
  }
517
- // TODO: Review possible workflow/race conditions vs rendering in -document-page.
518
526
  const el = utils.renderDocumentField(field, pageInfo, { disabled: false, editable: false, draggable: false, done: this.isDone }, tabIndex);
519
527
  if (!el) {
520
528
  return;
@@ -624,7 +632,8 @@ const VerdocsSign = class {
624
632
  e.stopPropagation();
625
633
  // We don't allow this to be hidden
626
634
  // this.showDeclined = false;
627
- } })), this.submitting && (index.h("div", { class: "loading-indicator" }, index.h("verdocs-loader", null))), this.showSpinner && (index.h("verdocs-portal", null, index.h("div", { class: "spinner-overlay" }, index.h("verdocs-spinner", null))))));
635
+ } })), this.submitting ||
636
+ (this.showSpinner && (index.h("verdocs-portal", null, index.h("div", { class: "spinner-overlay" }, index.h("verdocs-spinner", null)))))));
628
637
  }
629
638
  };
630
639
  VerdocsSign.style = VerdocsSignStyle0;
@@ -3,6 +3,7 @@ import { createEnvelope, getOrganizationContacts, getRGBA, isValidEmail, isValid
3
3
  import { getRoleIndex, getRoleNames, getTemplateRoleStore } from "../../../utils/TemplateRoleStore";
4
4
  import { getTemplateStore } from "../../../utils/TemplateStore";
5
5
  import { SDKError } from "../../../utils/errors";
6
+ import { VerdocsToast } from "../../../utils/Toast";
6
7
  const editIcon = '<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path></svg>';
7
8
  const startIcon = '<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M2 12C2 6.48 6.48 2 12 2s10 4.48 10 10-4.48 10-10 10S2 17.52 2 12zm10 6c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6z"></path></svg>';
8
9
  const stepIcon = '<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" tabindex="-1"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></svg>';
@@ -174,7 +175,7 @@ export class VerdocsSend {
174
175
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: true });
175
176
  const details = {
176
177
  template_id: this.templateId,
177
- name: (_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name,
178
+ name: ((_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name) || '',
178
179
  environment: this.environment,
179
180
  // TODO: Make optional in the SDK
180
181
  initial_reminder: 0,
@@ -186,19 +187,19 @@ export class VerdocsSend {
186
187
  console.log('[SEND] Creating envelope', details);
187
188
  createEnvelope(this.endpoint, details)
188
189
  .then(r => {
189
- var _a, _b;
190
+ var _a, _b, _c, _d;
190
191
  console.log('[SEND] Send envelope', r);
191
192
  this.reset().catch((e) => console.log('Unknown Error', e));
192
193
  this.sending = false;
193
194
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
194
- (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, envelope_id: r.id, envelope: r });
195
+ (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, name: ((_d = (_c = this.templateStore) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.name) || 'New Envelope', envelope_id: r.id, envelope: r });
195
196
  })
196
197
  .catch(e => {
197
- var _a;
198
+ var _a, _b, _c;
198
199
  console.log('Send error', e);
199
- // toast.error(e.response?.data?.message || 'Unknown error creating envelope');
200
+ VerdocsToast(((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || 'Error creating envelope, please try again later.');
200
201
  this.sending = false;
201
- (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
202
+ (_c = this.sendingEnvelope) === null || _c === void 0 ? void 0 : _c.emit({ sending: false });
202
203
  });
203
204
  }
204
205
  handleCancel(e) {
@@ -269,11 +269,17 @@ export class VerdocsSign {
269
269
  if (!e.detail) {
270
270
  return;
271
271
  }
272
+ this.showSpinner = true;
272
273
  const initialsBlob = await (await fetch(e.detail)).blob();
273
274
  return createInitials(this.endpoint, 'initial', initialsBlob) //
274
275
  .then(async (newInitials) => {
275
276
  const updateResult = await updateEnvelopeFieldInitials(this.endpoint, this.envelopeId, field.name, newInitials.id);
276
277
  this.updateRecipientFieldValue(field.name, updateResult);
278
+ this.showSpinner = false;
279
+ })
280
+ .catch(e => {
281
+ console.log('Error updating initials', e);
282
+ this.showSpinner = false;
277
283
  });
278
284
  case 'signature':
279
285
  // This can be caused by a focus-out event if the user clicks the field
@@ -282,15 +288,18 @@ export class VerdocsSign {
282
288
  if (!e.detail) {
283
289
  return;
284
290
  }
291
+ this.showSpinner = true;
285
292
  const signatureBlob = await (await fetch(e.detail)).blob();
286
293
  return createSignature(this.endpoint, 'signature', signatureBlob) //
287
294
  .then(async (newSignature) => {
288
295
  console.log('Signature update result', newSignature);
289
296
  const updateResult = await updateEnvelopeFieldSignature(this.endpoint, this.envelopeId, field.name, newSignature.id);
290
297
  this.updateRecipientFieldValue(field.name, updateResult);
298
+ this.showSpinner = false;
291
299
  })
292
300
  .catch(e => {
293
301
  console.warn('[SIGN] Error updating signature', e);
302
+ this.showSpinner = false;
294
303
  });
295
304
  case 'date':
296
305
  const { formattedDate } = e.detail;
@@ -370,16 +379,17 @@ export class VerdocsSign {
370
379
  this.envelope = envelope;
371
380
  // The show-done dialog does this
372
381
  // this.isDone = true;
382
+ this.submitting = false;
373
383
  })
374
384
  .catch(e => {
375
385
  // this.isDone = true;
376
386
  console.log('[SIGN] Error reloading envelope', e);
387
+ this.submitting = false;
377
388
  });
378
389
  }
379
390
  catch (e) {
380
391
  console.log('[SIGN] Error submitting', e);
381
392
  }
382
- this.submitting = false;
383
393
  return;
384
394
  }
385
395
  // Find and focus the next incomplete field (that is fillable)
@@ -455,7 +465,6 @@ export class VerdocsSign {
455
465
  }
456
466
  });
457
467
  el.addEventListener('attached', async (e) => {
458
- // TODO: Show a spinner and/or progress bar
459
468
  console.log('[SIGN] onAttached', e.detail, e.target.value);
460
469
  this.showSpinner = true;
461
470
  try {
@@ -518,7 +527,6 @@ export class VerdocsSign {
518
527
  if (field.page !== pageInfo.pageNumber) {
519
528
  return;
520
529
  }
521
- // TODO: Review possible workflow/race conditions vs rendering in -document-page.
522
530
  const el = renderDocumentField(field, pageInfo, { disabled: false, editable: false, draggable: false, done: this.isDone }, tabIndex);
523
531
  if (!el) {
524
532
  return;
@@ -628,7 +636,8 @@ export class VerdocsSign {
628
636
  e.stopPropagation();
629
637
  // We don't allow this to be hidden
630
638
  // this.showDeclined = false;
631
- } })), this.submitting && (h("div", { class: "loading-indicator" }, h("verdocs-loader", null))), this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null))))));
639
+ } })), this.submitting ||
640
+ (this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null)))))));
632
641
  }
633
642
  static get is() { return "verdocs-sign"; }
634
643
  static get originalStyleUrls() {
@@ -3,6 +3,7 @@ import { VerdocsEndpoint, getOrganizationContacts, createEnvelope, isValidEmail,
3
3
  import { g as getTemplateRoleStore, b as getRoleNames, a as getRoleIndex } from './TemplateRoleStore.js';
4
4
  import { g as getTemplateStore } from './TemplateStore.js';
5
5
  import { S as SDKError } from './errors.js';
6
+ import { V as VerdocsToast } from './Toast.js';
6
7
  import { d as defineCustomElement$8 } from './verdocs-button2.js';
7
8
  import { d as defineCustomElement$7 } from './verdocs-component-error2.js';
8
9
  import { d as defineCustomElement$6 } from './verdocs-contact-picker2.js';
@@ -176,7 +177,7 @@ const VerdocsSend = /*@__PURE__*/ proxyCustomElement(class VerdocsSend extends H
176
177
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: true });
177
178
  const details = {
178
179
  template_id: this.templateId,
179
- name: (_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name,
180
+ name: ((_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name) || '',
180
181
  environment: this.environment,
181
182
  // TODO: Make optional in the SDK
182
183
  initial_reminder: 0,
@@ -188,19 +189,19 @@ const VerdocsSend = /*@__PURE__*/ proxyCustomElement(class VerdocsSend extends H
188
189
  console.log('[SEND] Creating envelope', details);
189
190
  createEnvelope(this.endpoint, details)
190
191
  .then(r => {
191
- var _a, _b;
192
+ var _a, _b, _c, _d;
192
193
  console.log('[SEND] Send envelope', r);
193
194
  this.reset().catch((e) => console.log('Unknown Error', e));
194
195
  this.sending = false;
195
196
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
196
- (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, envelope_id: r.id, envelope: r });
197
+ (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, name: ((_d = (_c = this.templateStore) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.name) || 'New Envelope', envelope_id: r.id, envelope: r });
197
198
  })
198
199
  .catch(e => {
199
- var _a;
200
+ var _a, _b, _c;
200
201
  console.log('Send error', e);
201
- // toast.error(e.response?.data?.message || 'Unknown error creating envelope');
202
+ VerdocsToast(((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || 'Error creating envelope, please try again later.');
202
203
  this.sending = false;
203
- (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
204
+ (_c = this.sendingEnvelope) === null || _c === void 0 ? void 0 : _c.emit({ sending: false });
204
205
  });
205
206
  }
206
207
  handleCancel(e) {
@@ -268,11 +268,17 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
268
268
  if (!e.detail) {
269
269
  return;
270
270
  }
271
+ this.showSpinner = true;
271
272
  const initialsBlob = await (await fetch(e.detail)).blob();
272
273
  return createInitials(this.endpoint, 'initial', initialsBlob) //
273
274
  .then(async (newInitials) => {
274
275
  const updateResult = await updateEnvelopeFieldInitials(this.endpoint, this.envelopeId, field.name, newInitials.id);
275
276
  this.updateRecipientFieldValue(field.name, updateResult);
277
+ this.showSpinner = false;
278
+ })
279
+ .catch(e => {
280
+ console.log('Error updating initials', e);
281
+ this.showSpinner = false;
276
282
  });
277
283
  case 'signature':
278
284
  // This can be caused by a focus-out event if the user clicks the field
@@ -281,15 +287,18 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
281
287
  if (!e.detail) {
282
288
  return;
283
289
  }
290
+ this.showSpinner = true;
284
291
  const signatureBlob = await (await fetch(e.detail)).blob();
285
292
  return createSignature(this.endpoint, 'signature', signatureBlob) //
286
293
  .then(async (newSignature) => {
287
294
  console.log('Signature update result', newSignature);
288
295
  const updateResult = await updateEnvelopeFieldSignature(this.endpoint, this.envelopeId, field.name, newSignature.id);
289
296
  this.updateRecipientFieldValue(field.name, updateResult);
297
+ this.showSpinner = false;
290
298
  })
291
299
  .catch(e => {
292
300
  console.warn('[SIGN] Error updating signature', e);
301
+ this.showSpinner = false;
293
302
  });
294
303
  case 'date':
295
304
  const { formattedDate } = e.detail;
@@ -369,16 +378,17 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
369
378
  this.envelope = envelope;
370
379
  // The show-done dialog does this
371
380
  // this.isDone = true;
381
+ this.submitting = false;
372
382
  })
373
383
  .catch(e => {
374
384
  // this.isDone = true;
375
385
  console.log('[SIGN] Error reloading envelope', e);
386
+ this.submitting = false;
376
387
  });
377
388
  }
378
389
  catch (e) {
379
390
  console.log('[SIGN] Error submitting', e);
380
391
  }
381
- this.submitting = false;
382
392
  return;
383
393
  }
384
394
  // Find and focus the next incomplete field (that is fillable)
@@ -454,7 +464,6 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
454
464
  }
455
465
  });
456
466
  el.addEventListener('attached', async (e) => {
457
- // TODO: Show a spinner and/or progress bar
458
467
  console.log('[SIGN] onAttached', e.detail, e.target.value);
459
468
  this.showSpinner = true;
460
469
  try {
@@ -517,7 +526,6 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
517
526
  if (field.page !== pageInfo.pageNumber) {
518
527
  return;
519
528
  }
520
- // TODO: Review possible workflow/race conditions vs rendering in -document-page.
521
529
  const el = renderDocumentField(field, pageInfo, { disabled: false, editable: false, draggable: false, done: this.isDone }, tabIndex);
522
530
  if (!el) {
523
531
  return;
@@ -627,7 +635,8 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
627
635
  e.stopPropagation();
628
636
  // We don't allow this to be hidden
629
637
  // this.showDeclined = false;
630
- } })), this.submitting && (h("div", { class: "loading-indicator" }, h("verdocs-loader", null))), this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null))))));
638
+ } })), this.submitting ||
639
+ (this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null)))))));
631
640
  }
632
641
  static get style() { return VerdocsSignStyle0; }
633
642
  }, [0, "verdocs-sign", {
@@ -4,8 +4,8 @@ import { g as getTemplateFieldStore, u as updateStoreField } from './TemplateFie
4
4
  import { g as getTemplateRoleStore, b as getRoleNames, a as getRoleIndex, u as updateStoreRole } from './TemplateRoleStore-6d1bec83.js';
5
5
  import { g as getTemplateStore } from './TemplateStore-41799d0a.js';
6
6
  import { S as SDKError } from './errors-887f1e88.js';
7
- import { D as DocIcon, P as PngIcon, J as JpgIcon, a as PdfIcon, F as FileIcon$1, b as PageCountIcon, T as TrashIcon } from './Icons-faf0377f.js';
8
7
  import { V as VerdocsToast } from './Toast-c4843828.js';
8
+ import { D as DocIcon, P as PngIcon, J as JpgIcon, a as PdfIcon, F as FileIcon$1, b as PageCountIcon, T as TrashIcon } from './Icons-faf0377f.js';
9
9
  import { f as format } from './format-b8602175.js';
10
10
  import { i as interact } from './interact.min-a71beb3d.js';
11
11
  import { b as updateCssTransform, c as removeCssTransform, g as getFieldId, d as defaultWidth, e as defaultHeight } from './utils-6ecd6558.js';
@@ -258,7 +258,7 @@ const VerdocsSend = class {
258
258
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: true });
259
259
  const details = {
260
260
  template_id: this.templateId,
261
- name: (_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name,
261
+ name: ((_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name) || '',
262
262
  environment: this.environment,
263
263
  // TODO: Make optional in the SDK
264
264
  initial_reminder: 0,
@@ -270,19 +270,19 @@ const VerdocsSend = class {
270
270
  console.log('[SEND] Creating envelope', details);
271
271
  createEnvelope(this.endpoint, details)
272
272
  .then(r => {
273
- var _a, _b;
273
+ var _a, _b, _c, _d;
274
274
  console.log('[SEND] Send envelope', r);
275
275
  this.reset().catch((e) => console.log('Unknown Error', e));
276
276
  this.sending = false;
277
277
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
278
- (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, envelope_id: r.id, envelope: r });
278
+ (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, name: ((_d = (_c = this.templateStore) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.name) || 'New Envelope', envelope_id: r.id, envelope: r });
279
279
  })
280
280
  .catch(e => {
281
- var _a;
281
+ var _a, _b, _c;
282
282
  console.log('Send error', e);
283
- // toast.error(e.response?.data?.message || 'Unknown error creating envelope');
283
+ VerdocsToast(((_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || 'Error creating envelope, please try again later.');
284
284
  this.sending = false;
285
- (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
285
+ (_c = this.sendingEnvelope) === null || _c === void 0 ? void 0 : _c.emit({ sending: false });
286
286
  });
287
287
  }
288
288
  handleCancel(e) {
@@ -261,11 +261,17 @@ const VerdocsSign = class {
261
261
  if (!e.detail) {
262
262
  return;
263
263
  }
264
+ this.showSpinner = true;
264
265
  const initialsBlob = await (await fetch(e.detail)).blob();
265
266
  return createInitials(this.endpoint, 'initial', initialsBlob) //
266
267
  .then(async (newInitials) => {
267
268
  const updateResult = await updateEnvelopeFieldInitials(this.endpoint, this.envelopeId, field.name, newInitials.id);
268
269
  this.updateRecipientFieldValue(field.name, updateResult);
270
+ this.showSpinner = false;
271
+ })
272
+ .catch(e => {
273
+ console.log('Error updating initials', e);
274
+ this.showSpinner = false;
269
275
  });
270
276
  case 'signature':
271
277
  // This can be caused by a focus-out event if the user clicks the field
@@ -274,15 +280,18 @@ const VerdocsSign = class {
274
280
  if (!e.detail) {
275
281
  return;
276
282
  }
283
+ this.showSpinner = true;
277
284
  const signatureBlob = await (await fetch(e.detail)).blob();
278
285
  return createSignature(this.endpoint, 'signature', signatureBlob) //
279
286
  .then(async (newSignature) => {
280
287
  console.log('Signature update result', newSignature);
281
288
  const updateResult = await updateEnvelopeFieldSignature(this.endpoint, this.envelopeId, field.name, newSignature.id);
282
289
  this.updateRecipientFieldValue(field.name, updateResult);
290
+ this.showSpinner = false;
283
291
  })
284
292
  .catch(e => {
285
293
  console.warn('[SIGN] Error updating signature', e);
294
+ this.showSpinner = false;
286
295
  });
287
296
  case 'date':
288
297
  const { formattedDate } = e.detail;
@@ -362,16 +371,17 @@ const VerdocsSign = class {
362
371
  this.envelope = envelope;
363
372
  // The show-done dialog does this
364
373
  // this.isDone = true;
374
+ this.submitting = false;
365
375
  })
366
376
  .catch(e => {
367
377
  // this.isDone = true;
368
378
  console.log('[SIGN] Error reloading envelope', e);
379
+ this.submitting = false;
369
380
  });
370
381
  }
371
382
  catch (e) {
372
383
  console.log('[SIGN] Error submitting', e);
373
384
  }
374
- this.submitting = false;
375
385
  return;
376
386
  }
377
387
  // Find and focus the next incomplete field (that is fillable)
@@ -447,7 +457,6 @@ const VerdocsSign = class {
447
457
  }
448
458
  });
449
459
  el.addEventListener('attached', async (e) => {
450
- // TODO: Show a spinner and/or progress bar
451
460
  console.log('[SIGN] onAttached', e.detail, e.target.value);
452
461
  this.showSpinner = true;
453
462
  try {
@@ -510,7 +519,6 @@ const VerdocsSign = class {
510
519
  if (field.page !== pageInfo.pageNumber) {
511
520
  return;
512
521
  }
513
- // TODO: Review possible workflow/race conditions vs rendering in -document-page.
514
522
  const el = renderDocumentField(field, pageInfo, { disabled: false, editable: false, draggable: false, done: this.isDone }, tabIndex);
515
523
  if (!el) {
516
524
  return;
@@ -620,7 +628,8 @@ const VerdocsSign = class {
620
628
  e.stopPropagation();
621
629
  // We don't allow this to be hidden
622
630
  // this.showDeclined = false;
623
- } })), this.submitting && (h("div", { class: "loading-indicator" }, h("verdocs-loader", null))), this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null))))));
631
+ } })), this.submitting ||
632
+ (this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null)))))));
624
633
  }
625
634
  };
626
635
  VerdocsSign.style = VerdocsSignStyle0;