@verdocs/web-sdk 1.16.1 → 1.16.3

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.
Files changed (146) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/{utils-b3cadea0.js → utils-1bbf48c2.js} +22 -0
  3. package/dist/cjs/verdocs-auth.cjs.entry.js +25 -1
  4. package/dist/cjs/verdocs-button-panel_3.cjs.entry.js +1 -1
  5. package/dist/cjs/verdocs-contact-picker.cjs.entry.js +8 -1
  6. package/dist/cjs/verdocs-envelope-document-page.cjs.entry.js +1 -1
  7. package/dist/cjs/verdocs-envelopes-list.cjs.entry.js +1 -1
  8. package/dist/cjs/verdocs-field-checkbox.cjs.entry.js +1 -1
  9. package/dist/cjs/verdocs-field-date.cjs.entry.js +1 -1
  10. package/dist/cjs/verdocs-field-dropdown.cjs.entry.js +1 -1
  11. package/dist/cjs/verdocs-field-initial.cjs.entry.js +1 -1
  12. package/dist/cjs/verdocs-field-payment.cjs.entry.js +1 -1
  13. package/dist/cjs/verdocs-field-radio-button.cjs.entry.js +1 -1
  14. package/dist/cjs/verdocs-field-signature.cjs.entry.js +1 -1
  15. package/dist/cjs/verdocs-field-textarea.cjs.entry.js +1 -1
  16. package/dist/cjs/verdocs-field-textbox.cjs.entry.js +1 -1
  17. package/dist/cjs/verdocs-field-timestamp.cjs.entry.js +1 -1
  18. package/dist/cjs/verdocs-pagination_3.cjs.entry.js +1 -1
  19. package/dist/cjs/verdocs-preview.cjs.entry.js +1 -1
  20. package/dist/cjs/verdocs-send.cjs.entry.js +1 -1
  21. package/dist/cjs/verdocs-sign.cjs.entry.js +1 -1
  22. package/dist/cjs/verdocs-template-document-page_2.cjs.entry.js +1 -1
  23. package/dist/cjs/verdocs-template-fields_4.cjs.entry.js +1 -1
  24. package/dist/cjs/verdocs-view.cjs.entry.js +1 -1
  25. package/dist/cjs/verdocs-web-sdk.cjs.js +1 -1
  26. package/dist/collection/collection-manifest.json +2 -2
  27. package/dist/collection/components/controls/verdocs-select-input/verdocs-select-input.css +1 -1
  28. package/dist/collection/components/embeds/verdocs-auth/verdocs-auth.js +28 -1
  29. package/dist/collection/components/envelopes/verdocs-contact-picker/verdocs-contact-picker.js +2 -1
  30. package/dist/collection/utils/utils.js +21 -0
  31. package/dist/components/utils.js +22 -1
  32. package/dist/components/verdocs-auth.js +28 -1
  33. package/dist/components/verdocs-contact-picker2.js +2 -1
  34. package/dist/components/verdocs-quick-filter2.js +1 -1
  35. package/dist/components/verdocs-select-input2.js +1 -1
  36. package/dist/components/verdocs-template-fields2.js +1 -1
  37. package/dist/components/verdocs-view2.js +1 -1
  38. package/dist/custom-elements.json +1890 -0
  39. package/dist/docs.json +1 -1
  40. package/dist/esm/loader.js +1 -1
  41. package/dist/esm/{utils-44eaf473.js → utils-ae5a050a.js} +22 -1
  42. package/dist/esm/verdocs-auth.entry.js +25 -1
  43. package/dist/esm/verdocs-button-panel_3.entry.js +1 -1
  44. package/dist/esm/verdocs-contact-picker.entry.js +8 -1
  45. package/dist/esm/verdocs-envelope-document-page.entry.js +1 -1
  46. package/dist/esm/verdocs-envelopes-list.entry.js +1 -1
  47. package/dist/esm/verdocs-field-checkbox.entry.js +1 -1
  48. package/dist/esm/verdocs-field-date.entry.js +1 -1
  49. package/dist/esm/verdocs-field-dropdown.entry.js +1 -1
  50. package/dist/esm/verdocs-field-initial.entry.js +1 -1
  51. package/dist/esm/verdocs-field-payment.entry.js +1 -1
  52. package/dist/esm/verdocs-field-radio-button.entry.js +1 -1
  53. package/dist/esm/verdocs-field-signature.entry.js +1 -1
  54. package/dist/esm/verdocs-field-textarea.entry.js +1 -1
  55. package/dist/esm/verdocs-field-textbox.entry.js +1 -1
  56. package/dist/esm/verdocs-field-timestamp.entry.js +1 -1
  57. package/dist/esm/verdocs-pagination_3.entry.js +1 -1
  58. package/dist/esm/verdocs-preview.entry.js +1 -1
  59. package/dist/esm/verdocs-send.entry.js +1 -1
  60. package/dist/esm/verdocs-sign.entry.js +1 -1
  61. package/dist/esm/verdocs-template-document-page_2.entry.js +1 -1
  62. package/dist/esm/verdocs-template-fields_4.entry.js +1 -1
  63. package/dist/esm/verdocs-view.entry.js +1 -1
  64. package/dist/esm/verdocs-web-sdk.js +1 -1
  65. package/dist/esm-es5/loader.js +1 -1
  66. package/dist/esm-es5/{utils-44eaf473.js → utils-ae5a050a.js} +1 -1
  67. package/dist/esm-es5/verdocs-auth.entry.js +1 -1
  68. package/dist/esm-es5/verdocs-button-panel_3.entry.js +1 -1
  69. package/dist/esm-es5/verdocs-contact-picker.entry.js +1 -1
  70. package/dist/esm-es5/verdocs-envelope-document-page.entry.js +1 -1
  71. package/dist/esm-es5/verdocs-envelopes-list.entry.js +1 -1
  72. package/dist/esm-es5/verdocs-field-checkbox.entry.js +1 -1
  73. package/dist/esm-es5/verdocs-field-date.entry.js +1 -1
  74. package/dist/esm-es5/verdocs-field-dropdown.entry.js +1 -1
  75. package/dist/esm-es5/verdocs-field-initial.entry.js +1 -1
  76. package/dist/esm-es5/verdocs-field-payment.entry.js +1 -1
  77. package/dist/esm-es5/verdocs-field-radio-button.entry.js +1 -1
  78. package/dist/esm-es5/verdocs-field-signature.entry.js +1 -1
  79. package/dist/esm-es5/verdocs-field-textarea.entry.js +1 -1
  80. package/dist/esm-es5/verdocs-field-textbox.entry.js +1 -1
  81. package/dist/esm-es5/verdocs-field-timestamp.entry.js +1 -1
  82. package/dist/esm-es5/verdocs-pagination_3.entry.js +1 -1
  83. package/dist/esm-es5/verdocs-preview.entry.js +1 -1
  84. package/dist/esm-es5/verdocs-send.entry.js +1 -1
  85. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  86. package/dist/esm-es5/verdocs-template-document-page_2.entry.js +1 -1
  87. package/dist/esm-es5/verdocs-template-fields_4.entry.js +1 -1
  88. package/dist/esm-es5/verdocs-view.entry.js +1 -1
  89. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  90. package/dist/types/components/embeds/verdocs-auth/verdocs-auth.d.ts +4 -0
  91. package/dist/types/components/fields/verdocs-field-timestamp/verdocs-field-timestamp.d.ts +1 -1
  92. package/dist/types/utils/utils.d.ts +2 -1
  93. package/dist/typings.d.ts +4 -0
  94. package/dist/verdocs-web-sdk/{p-a8e50d37.entry.js → p-01923f32.entry.js} +1 -1
  95. package/dist/verdocs-web-sdk/{p-718e8461.entry.js → p-1328971a.entry.js} +1 -1
  96. package/dist/verdocs-web-sdk/{p-2422d17f.entry.js → p-1a859044.entry.js} +1 -1
  97. package/dist/verdocs-web-sdk/{p-ef8556ab.entry.js → p-1a95da40.entry.js} +1 -1
  98. package/dist/verdocs-web-sdk/p-1c1f677c.system.entry.js +1 -0
  99. package/dist/verdocs-web-sdk/{p-e4828532.system.entry.js → p-1cff4451.system.entry.js} +1 -1
  100. package/dist/verdocs-web-sdk/{p-658acf14.system.entry.js → p-1e5810c6.system.entry.js} +1 -1
  101. package/dist/verdocs-web-sdk/{p-45819703.system.entry.js → p-1f0f8952.system.entry.js} +1 -1
  102. package/dist/verdocs-web-sdk/{p-b9115b28.system.entry.js → p-21b46e22.system.entry.js} +1 -1
  103. package/dist/verdocs-web-sdk/{p-45982430.entry.js → p-29c0a0ac.entry.js} +1 -1
  104. package/dist/verdocs-web-sdk/{p-d80cb095.system.entry.js → p-2b0f47c3.system.entry.js} +1 -1
  105. package/dist/verdocs-web-sdk/p-2c657b17.entry.js +1 -0
  106. package/dist/verdocs-web-sdk/{p-bc967cf3.system.entry.js → p-3413b5df.system.entry.js} +1 -1
  107. package/dist/verdocs-web-sdk/{p-44bfb4be.system.entry.js → p-357e8437.system.entry.js} +1 -1
  108. package/dist/verdocs-web-sdk/{p-2168ed5d.system.entry.js → p-39d7ac16.system.entry.js} +1 -1
  109. package/dist/verdocs-web-sdk/{p-ba5999c5.system.entry.js → p-433ce546.system.entry.js} +1 -1
  110. package/dist/verdocs-web-sdk/{p-ae3f2ed0.system.entry.js → p-43bd6bca.system.entry.js} +1 -1
  111. package/dist/verdocs-web-sdk/{p-7eba89c4.entry.js → p-46113362.entry.js} +1 -1
  112. package/dist/verdocs-web-sdk/{p-b0614acb.entry.js → p-467e2c5d.entry.js} +1 -1
  113. package/dist/verdocs-web-sdk/{p-714cfb31.entry.js → p-4c49ad8a.entry.js} +1 -1
  114. package/dist/verdocs-web-sdk/{p-94143c1d.entry.js → p-51bb5f0f.entry.js} +1 -1
  115. package/dist/verdocs-web-sdk/{p-a5cb89cf.entry.js → p-5215744e.entry.js} +1 -1
  116. package/dist/verdocs-web-sdk/{p-c3dcb67b.entry.js → p-5de9866d.entry.js} +1 -1
  117. package/dist/verdocs-web-sdk/p-647cdb84.system.js +1 -1
  118. package/dist/verdocs-web-sdk/{p-b30e7c10.system.entry.js → p-698c0f03.system.entry.js} +1 -1
  119. package/dist/verdocs-web-sdk/{p-50e6a54b.entry.js → p-6a0cceab.entry.js} +1 -1
  120. package/dist/verdocs-web-sdk/{p-2a827527.js → p-6ab0539d.js} +1 -1
  121. package/dist/verdocs-web-sdk/{p-3642864b.entry.js → p-7b503f72.entry.js} +1 -1
  122. package/dist/verdocs-web-sdk/p-82430214.system.entry.js +1 -0
  123. package/dist/verdocs-web-sdk/{p-f859f4ac.system.entry.js → p-86c866f9.system.entry.js} +1 -1
  124. package/dist/verdocs-web-sdk/{p-72886895.entry.js → p-884d4302.entry.js} +1 -1
  125. package/dist/verdocs-web-sdk/{p-99d8646d.system.entry.js → p-96375cc8.system.entry.js} +1 -1
  126. package/dist/verdocs-web-sdk/{p-f1cab0fd.system.entry.js → p-9764c57e.system.entry.js} +1 -1
  127. package/dist/verdocs-web-sdk/{p-0756cb7e.system.entry.js → p-9e7ab094.system.entry.js} +1 -1
  128. package/dist/verdocs-web-sdk/{p-752c572b.entry.js → p-a9ecf297.entry.js} +1 -1
  129. package/dist/verdocs-web-sdk/{p-d542ebe7.system.entry.js → p-bc3f9d16.system.entry.js} +1 -1
  130. package/dist/verdocs-web-sdk/{p-e20c39bd.system.entry.js → p-beb29c88.system.entry.js} +1 -1
  131. package/dist/verdocs-web-sdk/{p-34d0ded4.entry.js → p-c16dd5ef.entry.js} +1 -1
  132. package/dist/verdocs-web-sdk/{p-9e7daf20.entry.js → p-c3fc7975.entry.js} +1 -1
  133. package/dist/verdocs-web-sdk/{p-42eae58f.system.entry.js → p-c460e8c3.system.entry.js} +1 -1
  134. package/dist/verdocs-web-sdk/{p-78ceb9ca.entry.js → p-d1236f08.entry.js} +1 -1
  135. package/dist/verdocs-web-sdk/{p-89bf76a9.entry.js → p-d3d0bc3d.entry.js} +1 -1
  136. package/dist/verdocs-web-sdk/p-d6cef406.entry.js +1 -0
  137. package/dist/verdocs-web-sdk/{p-135c06d1.system.entry.js → p-e202ce0e.system.entry.js} +1 -1
  138. package/dist/verdocs-web-sdk/{p-0d127275.system.entry.js → p-e4f9b152.system.entry.js} +1 -1
  139. package/dist/verdocs-web-sdk/{p-2aac69bc.system.js → p-f30de95e.system.js} +1 -1
  140. package/dist/verdocs-web-sdk/{p-3e06f938.entry.js → p-f7ef018a.entry.js} +1 -1
  141. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  142. package/package.json +2 -2
  143. package/dist/verdocs-web-sdk/p-192c703c.system.entry.js +0 -1
  144. package/dist/verdocs-web-sdk/p-263d3dc4.entry.js +0 -1
  145. package/dist/verdocs-web-sdk/p-35fc3d37.entry.js +0 -1
  146. package/dist/verdocs-web-sdk/p-f43e1fad.system.entry.js +0 -1
@@ -39,6 +39,9 @@ export class VerdocsAuth {
39
39
  this.logo = 'https://verdocs.com/assets/blue-logo.svg';
40
40
  this.isAuthenticated = false;
41
41
  this.displayMode = 'login';
42
+ this.orgname = '';
43
+ this.first = '';
44
+ this.last = '';
42
45
  this.username = '';
43
46
  this.password = '';
44
47
  this.loggingIn = false;
@@ -58,6 +61,27 @@ export class VerdocsAuth {
58
61
  (_b = this.authenticated) === null || _b === void 0 ? void 0 : _b.emit({ authenticated: false, session: null });
59
62
  }
60
63
  }
64
+ handleSignup() {
65
+ this.loggingIn = true;
66
+ Auth.authenticateUser(this.endpoint, { username: this.username, password: this.password })
67
+ .then(r => {
68
+ var _a;
69
+ this.loggingIn = false;
70
+ this.endpoint.setToken(r.accessToken);
71
+ this.activeSession = this.endpoint.session;
72
+ this.isAuthenticated = true;
73
+ (_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: true, session: this.endpoint.session });
74
+ })
75
+ .catch(e => {
76
+ var _a, _b, _c, _d;
77
+ console.log('[AUTH] Authentication error', e.response, JSON.stringify(e));
78
+ this.loggingIn = false;
79
+ this.activeSession = null;
80
+ (_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: false, session: null });
81
+ (_b = this.sdkError) === null || _b === void 0 ? void 0 : _b.emit(new SDKError(e.message, (_c = e.response) === null || _c === void 0 ? void 0 : _c.status, (_d = e.response) === null || _d === void 0 ? void 0 : _d.data));
82
+ VerdocsToast('Login failed. Please check your username and password and try again.', { style: 'error' });
83
+ });
84
+ }
61
85
  handleLogin() {
62
86
  this.loggingIn = true;
63
87
  Auth.authenticateUser(this.endpoint, { username: this.username, password: this.password })
@@ -93,7 +117,7 @@ export class VerdocsAuth {
93
117
  return (h("verdocs-button", { label: "Sign Out", disabled: this.loggingIn, onClick: () => this.handleLogout(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }));
94
118
  }
95
119
  if (this.displayMode === 'signup') {
96
- return (h("div", { class: "signup-form" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" }), h("h3", null, "Sign up for an account"), h("h4", null, "Already have an account?", h("verdocs-button", { label: "Log In", variant: "text", onClick: () => (this.displayMode = 'login'), disabled: this.loggingIn })), h("form", { onSubmit: () => this.handleLogin() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.loggingIn }), h("verdocs-button", { label: "Signup", disabled: this.loggingIn, onClick: () => this.handleLogin(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))));
120
+ return (h("div", { class: "signup-form" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" }), h("h3", null, "Sign up for an account"), h("h4", null, "Already have an account?", h("verdocs-button", { label: "Log In", variant: "text", onClick: () => (this.displayMode = 'login'), disabled: this.loggingIn })), h("form", { onSubmit: () => this.handleSignup() }, h("verdocs-text-input", { label: "Organization Name", autocomplete: "org", value: this.orgname, onInput: (e) => (this.orgname = e.target.value), disabled: this.loggingIn }), h("div", { style: { display: 'flex', flexDirection: 'row', columnGap: '20px' } }, h("verdocs-text-input", { label: "First Name", autocomplete: "first", value: this.first, onInput: (e) => (this.first = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Last Name", autocomplete: "last", value: this.last, onInput: (e) => (this.last = e.target.value), disabled: this.loggingIn })), h("verdocs-text-input", { label: "Email", autocomplete: "email", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.loggingIn }), h("verdocs-button", { label: "Create Account", disabled: this.loggingIn, onClick: () => this.handleSignup(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))));
97
121
  }
98
122
  return (h("div", { class: "login-form" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" }), h("h3", null, "Log in to your account"), h("h4", null, "Don't have an account?", h("verdocs-button", { label: "Sign Up", variant: "text", onClick: () => (this.displayMode = 'signup'), disabled: this.loggingIn })), h("form", { onSubmit: () => this.handleLogin() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.loggingIn }), h("verdocs-button", { label: "Forgot Your Password?", variant: "text", onClick: () => (this.displayMode = 'signup'), disabled: this.loggingIn, style: { display: 'flex', justifyContent: 'center', margin: '10px auto 20px' } }), h("verdocs-button", { label: "Login", disabled: this.loggingIn, onClick: () => this.handleLogin(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }))));
99
123
  }
@@ -173,6 +197,9 @@ export class VerdocsAuth {
173
197
  return {
174
198
  "isAuthenticated": {},
175
199
  "displayMode": {},
200
+ "orgname": {},
201
+ "first": {},
202
+ "last": {},
176
203
  "username": {},
177
204
  "password": {},
178
205
  "loggingIn": {},
@@ -1,5 +1,6 @@
1
1
  import { VerdocsEndpoint } from '@verdocs/js-sdk';
2
2
  import { h } from '@stencil/core';
3
+ import { convertToE164 } from '../../../utils/utils';
3
4
  const messageIcon = '<svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiBox-root css-1om0hkc" focusable="false" aria-hidden="true" viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z"></path></svg>';
4
5
  const delegateIcon = '<svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiSvgIcon-root MuiSvgIcon-fontSizeLarge css-zjt8k" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="AssignmentIndIcon" tabindex="-1" title="AssignmentInd"><path d="M19 3h-4.18C14.4 1.84 13.3 1 12 1c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm0 4c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm6 12H6v-1.4c0-2 4-3.1 6-3.1s6 1.1 6 3.1V19z"></path></svg>';
5
6
  const placeholderIcon = '<svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiSvgIcon-root MuiSvgIcon-fontSizeLarge css-zjt8k" focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="AccountCircleIcon" tabindex="-1" title="AccountCircle"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 4c1.93 0 3.5 1.57 3.5 3.5S13.93 13 12 13s-3.5-1.57-3.5-3.5S10.07 6 12 6zm0 14c-2.03 0-4.43-.82-6.14-2.88C7.55 15.8 9.68 15 12 15s4.45.8 6.14 2.12C16.43 19.18 14.03 20 12 20z"></path></svg>';
@@ -47,7 +48,7 @@ export class VerdocsContactPicker {
47
48
  this.email = e.target.value;
48
49
  }
49
50
  handlePhoneChange(e) {
50
- this.phone = e.target.value;
51
+ this.phone = convertToE164(e.target.value);
51
52
  }
52
53
  handleMessageChange(e) {
53
54
  this.message = e.target.value;
@@ -350,3 +350,24 @@ export const renderedTextWidth = (text, font = '16px Arial') => {
350
350
  ctx.font = font;
351
351
  return ctx.measureText(text).width;
352
352
  };
353
+ // "(212) 555-1212" => +12125551212
354
+ // "+46766861004" => "+46766861004"
355
+ // "212-555-1212" => +12125551212
356
+ // "212.555.1212" => +12125551212
357
+ // "212 555 1212" => +12125551212
358
+ // @see https://46elks.com/kb/e164
359
+ export const convertToE164 = (input) => {
360
+ let temp = (input || '').trim();
361
+ // If we are already prefixed, assume the user did it deliberately and attempt to use what they entered. We also short-circuit blanks.
362
+ if (!temp || temp.startsWith('+')) {
363
+ return temp;
364
+ }
365
+ // Remove any spaces, parenthesis or other punctuation.
366
+ temp = temp.replace(/[^0-9]/g, '');
367
+ // If the number begins with a zero, remove the leading zero. Do not combine this with the previous step because it needs to be removed
368
+ // whether it's the actual first character e.g. `0(5)` or just the first digit e.g. `(05`.
369
+ temp = temp.replace(/^0/g, '');
370
+ // Prepend the country code and +. We're assuming US in this case given the target demographic. Users in other countries would/should be
371
+ // already entering a prefix so they'd shortcut out of this routine via the + prefix check.
372
+ return `+1${temp}`;
373
+ };
@@ -362,5 +362,26 @@ const renderedTextWidth = (text, font = '16px Arial') => {
362
362
  ctx.font = font;
363
363
  return ctx.measureText(text).width;
364
364
  };
365
+ // "(212) 555-1212" => +12125551212
366
+ // "+46766861004" => "+46766861004"
367
+ // "212-555-1212" => +12125551212
368
+ // "212.555.1212" => +12125551212
369
+ // "212 555 1212" => +12125551212
370
+ // @see https://46elks.com/kb/e164
371
+ const convertToE164 = (input) => {
372
+ let temp = (input || '').trim();
373
+ // If we are already prefixed, assume the user did it deliberately and attempt to use what they entered. We also short-circuit blanks.
374
+ if (!temp || temp.startsWith('+')) {
375
+ return temp;
376
+ }
377
+ // Remove any spaces, parenthesis or other punctuation.
378
+ temp = temp.replace(/[^0-9]/g, '');
379
+ // If the number begins with a zero, remove the leading zero. Do not combine this with the previous step because it needs to be removed
380
+ // whether it's the actual first character e.g. `0(5)` or just the first digit e.g. `(05`.
381
+ temp = temp.replace(/^0/g, '');
382
+ // Prepend the country code and +. We're assuming US in this case given the target demographic. Users in other countries would/should be
383
+ // already entering a prefix so they'd shortcut out of this routine via the + prefix check.
384
+ return `+1${temp}`;
385
+ };
365
386
 
366
- export { getRoleIndex as a, saveAttachment as b, getFieldId as c, renderedTextWidth as d, updateCssTransform as e, defaultWidth as f, getFieldSettings as g, defaultHeight as h, saveCertificate as i, renderDocumentField as r, saveEnvelopesAsZip as s, throttle as t, updateDocumentFieldValue as u };
387
+ export { getRoleIndex as a, saveAttachment as b, getFieldId as c, convertToE164 as d, renderedTextWidth as e, updateCssTransform as f, getFieldSettings as g, defaultWidth as h, defaultHeight as i, saveCertificate as j, renderDocumentField as r, saveEnvelopesAsZip as s, throttle as t, updateDocumentFieldValue as u };
@@ -37,6 +37,9 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
37
37
  this.logo = 'https://verdocs.com/assets/blue-logo.svg';
38
38
  this.isAuthenticated = false;
39
39
  this.displayMode = 'login';
40
+ this.orgname = '';
41
+ this.first = '';
42
+ this.last = '';
40
43
  this.username = '';
41
44
  this.password = '';
42
45
  this.loggingIn = false;
@@ -56,6 +59,27 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
56
59
  (_b = this.authenticated) === null || _b === void 0 ? void 0 : _b.emit({ authenticated: false, session: null });
57
60
  }
58
61
  }
62
+ handleSignup() {
63
+ this.loggingIn = true;
64
+ authenticateUser(this.endpoint, { username: this.username, password: this.password })
65
+ .then(r => {
66
+ var _a;
67
+ this.loggingIn = false;
68
+ this.endpoint.setToken(r.accessToken);
69
+ this.activeSession = this.endpoint.session;
70
+ this.isAuthenticated = true;
71
+ (_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: true, session: this.endpoint.session });
72
+ })
73
+ .catch(e => {
74
+ var _a, _b, _c, _d;
75
+ console.log('[AUTH] Authentication error', e.response, JSON.stringify(e));
76
+ this.loggingIn = false;
77
+ this.activeSession = null;
78
+ (_a = this.authenticated) === null || _a === void 0 ? void 0 : _a.emit({ authenticated: false, session: null });
79
+ (_b = this.sdkError) === null || _b === void 0 ? void 0 : _b.emit(new SDKError(e.message, (_c = e.response) === null || _c === void 0 ? void 0 : _c.status, (_d = e.response) === null || _d === void 0 ? void 0 : _d.data));
80
+ VerdocsToast('Login failed. Please check your username and password and try again.', { style: 'error' });
81
+ });
82
+ }
59
83
  handleLogin() {
60
84
  this.loggingIn = true;
61
85
  authenticateUser(this.endpoint, { username: this.username, password: this.password })
@@ -91,7 +115,7 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
91
115
  return (h("verdocs-button", { label: "Sign Out", disabled: this.loggingIn, onClick: () => this.handleLogout(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }));
92
116
  }
93
117
  if (this.displayMode === 'signup') {
94
- return (h("div", { class: "signup-form" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" }), h("h3", null, "Sign up for an account"), h("h4", null, "Already have an account?", h("verdocs-button", { label: "Log In", variant: "text", onClick: () => (this.displayMode = 'login'), disabled: this.loggingIn })), h("form", { onSubmit: () => this.handleLogin() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.loggingIn }), h("verdocs-button", { label: "Signup", disabled: this.loggingIn, onClick: () => this.handleLogin(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))));
118
+ return (h("div", { class: "signup-form" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" }), h("h3", null, "Sign up for an account"), h("h4", null, "Already have an account?", h("verdocs-button", { label: "Log In", variant: "text", onClick: () => (this.displayMode = 'login'), disabled: this.loggingIn })), h("form", { onSubmit: () => this.handleSignup() }, h("verdocs-text-input", { label: "Organization Name", autocomplete: "org", value: this.orgname, onInput: (e) => (this.orgname = e.target.value), disabled: this.loggingIn }), h("div", { style: { display: 'flex', flexDirection: 'row', columnGap: '20px' } }, h("verdocs-text-input", { label: "First Name", autocomplete: "first", value: this.first, onInput: (e) => (this.first = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Last Name", autocomplete: "last", value: this.last, onInput: (e) => (this.last = e.target.value), disabled: this.loggingIn })), h("verdocs-text-input", { label: "Email", autocomplete: "email", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.loggingIn }), h("verdocs-button", { label: "Create Account", disabled: this.loggingIn, onClick: () => this.handleSignup(), style: { display: 'flex', justifyContent: 'center', margin: '30px auto 0' } }))));
95
119
  }
96
120
  return (h("div", { class: "login-form" }, h("img", { src: this.logo, alt: "Verdocs Logo", class: "logo" }), h("h3", null, "Log in to your account"), h("h4", null, "Don't have an account?", h("verdocs-button", { label: "Sign Up", variant: "text", onClick: () => (this.displayMode = 'signup'), disabled: this.loggingIn })), h("form", { onSubmit: () => this.handleLogin() }, h("verdocs-text-input", { label: "Email", autocomplete: "username", value: this.username, onInput: (e) => (this.username = e.target.value), disabled: this.loggingIn }), h("verdocs-text-input", { label: "Password", type: "password", autocomplete: "current-password", value: this.password, onInput: (e) => (this.password = e.target.value), disabled: this.loggingIn }), h("verdocs-button", { label: "Forgot Your Password?", variant: "text", onClick: () => (this.displayMode = 'signup'), disabled: this.loggingIn, style: { display: 'flex', justifyContent: 'center', margin: '10px auto 20px' } }), h("verdocs-button", { label: "Login", disabled: this.loggingIn, onClick: () => this.handleLogin(), style: { display: 'flex', justifyContent: 'center', margin: '10px auto 0' } }))));
97
121
  }
@@ -102,6 +126,9 @@ const VerdocsAuth$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
102
126
  "logo": [1],
103
127
  "isAuthenticated": [32],
104
128
  "displayMode": [32],
129
+ "orgname": [32],
130
+ "first": [32],
131
+ "last": [32],
105
132
  "username": [32],
106
133
  "password": [32],
107
134
  "loggingIn": [32],
@@ -1,6 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import './Types.js';
3
3
  import { V as VerdocsEndpoint } from './VerdocsEndpoint.js';
4
+ import { d as convertToE164 } from './utils.js';
4
5
  import { d as defineCustomElement$2 } from './verdocs-button2.js';
5
6
  import { d as defineCustomElement$1 } from './verdocs-toggle-button2.js';
6
7
 
@@ -49,7 +50,7 @@ const VerdocsContactPicker = /*@__PURE__*/ proxyCustomElement(class extends HTML
49
50
  this.email = e.target.value;
50
51
  }
51
52
  handlePhoneChange(e) {
52
- this.phone = e.target.value;
53
+ this.phone = convertToE164(e.target.value);
53
54
  }
54
55
  handleMessageChange(e) {
55
56
  this.message = e.target.value;
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { d as renderedTextWidth } from './utils.js';
2
+ import { e as renderedTextWidth } from './utils.js';
3
3
  import { c as createPopper } from './popper.js';
4
4
 
5
5
  const verdocsQuickFilterCss = "verdocs-quick-filter{position:relative;font-family:\"Inter\", \"Barlow\", sans-serif}verdocs-quick-filter .control{outline:0;height:34px;display:-ms-flexbox;display:flex;cursor:pointer;border-radius:4px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-webkit-box-sizing:border-box;box-sizing:border-box;background:#ffffff;-webkit-transition:all 100ms ease 0s;transition:all 100ms ease 0s;border:1px solid #cccccc}verdocs-quick-filter .title{padding:0 8px;font-size:14px;max-width:100%;overflow:hidden;color:#33364b;white-space:nowrap;-webkit-box-sizing:border-box;box-sizing:border-box;text-overflow:ellipsis}verdocs-quick-filter .title .prefix{display:inline;font-weight:700;margin:0 7px 0 0;color:#4c56cb}verdocs-quick-filter .arrow{width:32px;height:32px;border:none;outline:none;cursor:pointer;-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:center;justify-content:center;background:#ffffff;-webkit-transition:color 150ms ease 0s;transition:color 150ms ease 0s}verdocs-quick-filter .arrow svg{-webkit-transition:0.3s;transition:0.3s;fill:#cccccc}verdocs-quick-filter .separator{width:1px;display:block;margin-top:8px;margin-bottom:8px;-ms-flex-item-align:stretch;align-self:stretch;-webkit-box-sizing:border-box;box-sizing:border-box;background-color:#cccccc}verdocs-quick-filter .items{display:none;z-index:10000;position:absolute;border-radius:4px;background:#ffffff;-webkit-box-shadow:rgba(0, 0, 0, 0.1) 0 0 0 1px, rgba(0, 0, 0, 0.1) 0 4px 11px;box-shadow:rgba(0, 0, 0, 0.1) 0 0 0 1px, rgba(0, 0, 0, 0.1) 0 4px 11px}verdocs-quick-filter .items[data-show]{display:block}verdocs-quick-filter .option{width:100%;border:none;display:block;font-size:14px;text-align:left;background:none;padding:10px 20px;color:#1e2031}verdocs-quick-filter .option:hover{cursor:pointer;background:#4c56cb3f}verdocs-quick-filter .option[disabled]{color:#aaaaaa}verdocs-quick-filter .option[disabled]:hover{cursor:inherit;background:transparent;color:#aaaaaa}verdocs-quick-filter.open .items{display:block}verdocs-quick-filter.open .arrow svg{-webkit-transform:scaleY(-1);transform:scaleY(-1)}";
@@ -1,6 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
2
 
3
- const verdocsSelectInputCss = "verdocs-select-input{font-family:\"Inter\", \"Barlow\", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 0 10px 0;display:block}verdocs-select-input .input-element{-webkit-box-sizing:border-box;box-sizing:border-box;background:#ffffff;border:1px solid #cccccc;border-radius:4px;background:#ffffff;color:#092c4c;width:100%;font-size:16px;height:28px;padding:4px 8px}verdocs-select-input .input-element::-webkit-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-moz-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element:-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0}";
3
+ const verdocsSelectInputCss = "verdocs-select-input{font-family:\"Inter\", \"Barlow\", sans-serif;-webkit-box-sizing:border-box;box-sizing:border-box;margin:0 0 10px 0;display:block}verdocs-select-input .input-element{-webkit-box-sizing:border-box;box-sizing:border-box;background:#ffffff;border:1px solid #cccccc;border-radius:4px;background:#ffffff;color:#092c4c;width:100%;font-size:16px;height:28px;padding:2px 8px}verdocs-select-input .input-element::-webkit-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-moz-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element:-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::-ms-input-placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-element::placeholder{color:#aaaaaa;opacity:1}verdocs-select-input .input-label{display:block;color:#555570;font-weight:700;font-size:14px;margin:0 0 4px 0}";
4
4
 
5
5
  const VerdocsSelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6
6
  constructor() {
@@ -4,7 +4,7 @@ import './Types.js';
4
4
  import { V as VerdocsEndpoint } from './VerdocsEndpoint.js';
5
5
  import { u as updateField, c as createField } from './Fields.js';
6
6
  import { i as integerSequence } from './Primitives.js';
7
- import { a as getRoleIndex, r as renderDocumentField, e as updateCssTransform, f as defaultWidth, h as defaultHeight } from './utils.js';
7
+ import { a as getRoleIndex, r as renderDocumentField, f as updateCssTransform, h as defaultWidth, i as defaultHeight } from './utils.js';
8
8
  import { g as getTemplateStore, a as getRoleNames } from './TemplateStore.js';
9
9
  import { S as SDKError } from './errors.js';
10
10
  import { d as defineCustomElement$7 } from './verdocs-button2.js';
@@ -4,7 +4,7 @@ import { b as userCanCancelEnvelope } from './Permissions.js';
4
4
  import './Types.js';
5
5
  import { V as VerdocsEndpoint } from './VerdocsEndpoint.js';
6
6
  import { i as integerSequence } from './Primitives.js';
7
- import { s as saveEnvelopesAsZip, i as saveCertificate, b as saveAttachment } from './utils.js';
7
+ import { s as saveEnvelopesAsZip, j as saveCertificate, b as saveAttachment } from './utils.js';
8
8
  import { S as SDKError } from './errors.js';
9
9
  import { d as defineCustomElement$5 } from './verdocs-button2.js';
10
10
  import { d as defineCustomElement$4 } from './verdocs-dropdown2.js';