@verdocs/web-sdk 4.2.132 → 4.2.134

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;
@@ -451,7 +460,6 @@ const VerdocsSign = class {
451
460
  }
452
461
  });
453
462
  el.addEventListener('attached', async (e) => {
454
- // TODO: Show a spinner and/or progress bar
455
463
  console.log('[SIGN] onAttached', e.detail, e.target.value);
456
464
  this.showSpinner = true;
457
465
  try {
@@ -514,7 +522,6 @@ const VerdocsSign = class {
514
522
  if (field.page !== pageInfo.pageNumber) {
515
523
  return;
516
524
  }
517
- // TODO: Review possible workflow/race conditions vs rendering in -document-page.
518
525
  const el = utils.renderDocumentField(field, pageInfo, { disabled: false, editable: false, draggable: false, done: this.isDone }, tabIndex);
519
526
  if (!el) {
520
527
  return;
@@ -624,7 +631,8 @@ const VerdocsSign = class {
624
631
  e.stopPropagation();
625
632
  // We don't allow this to be hidden
626
633
  // 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))))));
634
+ } })), this.submitting ||
635
+ (this.showSpinner && (index.h("verdocs-portal", null, index.h("div", { class: "spinner-overlay" }, index.h("verdocs-spinner", null)))))));
628
636
  }
629
637
  };
630
638
  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;
@@ -455,7 +464,6 @@ export class VerdocsSign {
455
464
  }
456
465
  });
457
466
  el.addEventListener('attached', async (e) => {
458
- // TODO: Show a spinner and/or progress bar
459
467
  console.log('[SIGN] onAttached', e.detail, e.target.value);
460
468
  this.showSpinner = true;
461
469
  try {
@@ -518,7 +526,6 @@ export class VerdocsSign {
518
526
  if (field.page !== pageInfo.pageNumber) {
519
527
  return;
520
528
  }
521
- // TODO: Review possible workflow/race conditions vs rendering in -document-page.
522
529
  const el = renderDocumentField(field, pageInfo, { disabled: false, editable: false, draggable: false, done: this.isDone }, tabIndex);
523
530
  if (!el) {
524
531
  return;
@@ -628,7 +635,8 @@ export class VerdocsSign {
628
635
  e.stopPropagation();
629
636
  // We don't allow this to be hidden
630
637
  // 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))))));
638
+ } })), this.submitting ||
639
+ (this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null)))))));
632
640
  }
633
641
  static get is() { return "verdocs-sign"; }
634
642
  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;
@@ -454,7 +463,6 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
454
463
  }
455
464
  });
456
465
  el.addEventListener('attached', async (e) => {
457
- // TODO: Show a spinner and/or progress bar
458
466
  console.log('[SIGN] onAttached', e.detail, e.target.value);
459
467
  this.showSpinner = true;
460
468
  try {
@@ -517,7 +525,6 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
517
525
  if (field.page !== pageInfo.pageNumber) {
518
526
  return;
519
527
  }
520
- // TODO: Review possible workflow/race conditions vs rendering in -document-page.
521
528
  const el = renderDocumentField(field, pageInfo, { disabled: false, editable: false, draggable: false, done: this.isDone }, tabIndex);
522
529
  if (!el) {
523
530
  return;
@@ -627,7 +634,8 @@ const VerdocsSign$1 = /*@__PURE__*/ proxyCustomElement(class VerdocsSign extends
627
634
  e.stopPropagation();
628
635
  // We don't allow this to be hidden
629
636
  // 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))))));
637
+ } })), this.submitting ||
638
+ (this.showSpinner && (h("verdocs-portal", null, h("div", { class: "spinner-overlay" }, h("verdocs-spinner", null)))))));
631
639
  }
632
640
  static get style() { return VerdocsSignStyle0; }
633
641
  }, [0, "verdocs-sign", {