@verdocs/web-sdk 4.2.157 → 5.0.0

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 (514) hide show
  1. package/dist/cjs/Datastore-b1742da2.js +1783 -0
  2. package/dist/cjs/Icons-02a47df1.js +7 -0
  3. package/dist/cjs/{index-2589e4d1.js → index-ccac8641.js} +19 -31
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/{utils-5accd019.js → utils-ba1e95e0.js} +4 -2
  6. package/dist/cjs/verdocs-auth.cjs.entry.js +1 -1
  7. package/dist/cjs/verdocs-build.cjs.entry.js +22 -13
  8. package/dist/cjs/verdocs-button-panel_2.cjs.entry.js +1 -1
  9. package/dist/cjs/{verdocs-button_3.cjs.entry.js → verdocs-button_2.cjs.entry.js} +1 -56
  10. package/dist/cjs/{verdocs-checkbox_4.cjs.entry.js → verdocs-checkbox_6.cjs.entry.js} +115 -24
  11. package/dist/cjs/verdocs-contact-picker_2.cjs.entry.js +2 -2
  12. package/dist/cjs/verdocs-dialog.cjs.entry.js +1 -1
  13. package/dist/cjs/verdocs-dropdown.cjs.entry.js +1 -1
  14. package/dist/cjs/verdocs-envelope-document-page.cjs.entry.js +2 -2
  15. package/dist/cjs/verdocs-envelope-recipient-link_2.cjs.entry.js +30 -15
  16. package/dist/cjs/verdocs-envelope-recipient-summary.cjs.entry.js +32 -17
  17. package/dist/cjs/verdocs-envelope-sidebar.cjs.entry.js +64 -45
  18. package/dist/cjs/verdocs-envelopes-list.cjs.entry.js +2 -2
  19. package/dist/cjs/verdocs-field-attachment_13.cjs.entry.js +105 -156
  20. package/dist/cjs/verdocs-field-payment.cjs.entry.js +38 -25
  21. package/dist/cjs/{verdocs-file-chooser_2.cjs.entry.js → verdocs-file-chooser.cjs.entry.js} +2 -21
  22. package/dist/cjs/verdocs-kba-dialog_2.cjs.entry.js +27 -5
  23. package/dist/cjs/verdocs-ok-dialog.cjs.entry.js +1 -1
  24. package/dist/cjs/verdocs-organization-card_2.cjs.entry.js +1 -1
  25. package/dist/cjs/verdocs-pagination_2.cjs.entry.js +2 -2
  26. package/dist/cjs/{verdocs-preview_9.cjs.entry.js → verdocs-preview_5.cjs.entry.js} +220 -593
  27. package/dist/cjs/verdocs-progress-bar.cjs.entry.js +25 -0
  28. package/dist/cjs/verdocs-quick-functions.cjs.entry.js +1 -1
  29. package/dist/cjs/verdocs-radio-button.cjs.entry.js +1 -1
  30. package/dist/cjs/verdocs-search-box.cjs.entry.js +1 -1
  31. package/dist/cjs/verdocs-search-tabs.cjs.entry.js +1 -1
  32. package/dist/cjs/verdocs-sign.cjs.entry.js +11 -12
  33. package/dist/cjs/verdocs-spinner.cjs.entry.js +1 -1
  34. package/dist/cjs/verdocs-status-indicator.cjs.entry.js +1 -1
  35. package/dist/cjs/verdocs-table.cjs.entry.js +1 -1
  36. package/dist/cjs/verdocs-template-card.cjs.entry.js +1 -1
  37. package/dist/cjs/verdocs-template-create.cjs.entry.js +108 -0
  38. package/dist/cjs/verdocs-template-document-page_2.cjs.entry.js +78 -63
  39. package/dist/cjs/verdocs-template-role-properties.cjs.entry.js +58 -37
  40. package/dist/cjs/verdocs-template-star.cjs.entry.js +2 -2
  41. package/dist/cjs/verdocs-template-tags.cjs.entry.js +2 -2
  42. package/dist/cjs/verdocs-templates-list.cjs.entry.js +1 -1
  43. package/dist/cjs/verdocs-toggle.cjs.entry.js +1 -1
  44. package/dist/cjs/verdocs-web-sdk.cjs.js +3 -3
  45. package/dist/collection/collection-manifest.json +2 -5
  46. package/dist/collection/components/controls/verdocs-text-input/verdocs-text-input.js +5 -21
  47. package/dist/collection/components/embeds/verdocs-build/verdocs-build.js +27 -40
  48. package/dist/collection/components/embeds/verdocs-preview/verdocs-preview.js +27 -28
  49. package/dist/collection/components/embeds/verdocs-send/verdocs-send.js +45 -44
  50. package/dist/collection/components/embeds/verdocs-sign/verdocs-sign.js +12 -11
  51. package/dist/collection/components/embeds/verdocs-view/verdocs-view.js +28 -28
  52. package/dist/collection/components/envelopes/verdocs-envelope-recipient-link/verdocs-envelope-recipient-link.js +34 -15
  53. package/dist/collection/components/envelopes/verdocs-envelope-recipient-summary/verdocs-envelope-recipient-summary.js +35 -17
  54. package/dist/collection/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.js +67 -45
  55. package/dist/collection/components/fields/verdocs-field-attachment/verdocs-field-attachment.js +29 -18
  56. package/dist/collection/components/fields/verdocs-field-checkbox/verdocs-field-checkbox.js +30 -20
  57. package/dist/collection/components/fields/verdocs-field-date/verdocs-field-date.js +30 -22
  58. package/dist/collection/components/fields/verdocs-field-dropdown/verdocs-field-dropdown.js +29 -17
  59. package/dist/collection/components/fields/verdocs-field-initial/verdocs-field-initial.js +30 -18
  60. package/dist/collection/components/fields/verdocs-field-payment/verdocs-field-payment.js +192 -139
  61. package/dist/collection/components/fields/verdocs-field-radio/verdocs-field-radio.js +30 -20
  62. package/dist/collection/components/fields/verdocs-field-signature/verdocs-field-signature.js +30 -18
  63. package/dist/collection/components/fields/verdocs-field-textarea/verdocs-field-textarea.js +31 -19
  64. package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.css +31 -0
  65. package/dist/collection/components/fields/verdocs-field-textbox/verdocs-field-textbox.js +44 -44
  66. package/dist/collection/components/fields/verdocs-field-timestamp/verdocs-field-timestamp.js +29 -17
  67. package/dist/collection/components/templates/verdocs-template-build-tabs/verdocs-template-build-tabs.js +37 -32
  68. package/dist/collection/components/templates/verdocs-template-create/verdocs-template-create.js +7 -15
  69. package/dist/collection/components/templates/verdocs-template-document-page/verdocs-template-document-page.css +6 -0
  70. package/dist/collection/components/templates/verdocs-template-document-page/verdocs-template-document-page.js +79 -61
  71. package/dist/collection/components/templates/verdocs-template-field-properties/verdocs-template-field-properties.js +48 -24
  72. package/dist/collection/components/templates/verdocs-template-fields/verdocs-template-fields.js +65 -64
  73. package/dist/collection/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.js +61 -36
  74. package/dist/collection/components/templates/verdocs-template-roles/verdocs-template-roles.js +63 -46
  75. package/dist/collection/components/templates/verdocs-template-star/verdocs-template-star.js +1 -1
  76. package/dist/collection/components/templates/verdocs-template-tags/verdocs-template-tags.js +1 -1
  77. package/dist/collection/utils/Datastore.js +141 -0
  78. package/dist/collection/utils/Templates.js +2 -0
  79. package/dist/collection/utils/utils.js +3 -2
  80. package/dist/components/index.js +1 -7
  81. package/dist/components/{p-3044c9cb.js → p-070bebd7.js} +1 -1
  82. package/dist/components/{p-69881420.js → p-0ca7012b.js} +1 -1
  83. package/dist/components/{p-b2bf338f.js → p-0d063bf9.js} +65 -35
  84. package/dist/components/{p-ac7578f6.js → p-0e332769.js} +1 -1
  85. package/dist/components/{p-12594438.js → p-1030e0b1.js} +32 -32
  86. package/dist/components/{p-b11eb119.js → p-15d530b8.js} +6 -6
  87. package/dist/components/{p-71dd305b.js → p-18999830.js} +2 -2
  88. package/dist/components/{p-90540412.js → p-1ae5d7e0.js} +1 -1
  89. package/dist/components/{p-4d2f2954.js → p-1e2e8b1c.js} +1 -1
  90. package/dist/components/{p-c7a21595.js → p-1e67ebdf.js} +67 -42
  91. package/dist/components/{p-72e959a7.js → p-1fc15f94.js} +31 -32
  92. package/dist/components/{p-85ef4d07.js → p-2548f3f0.js} +49 -38
  93. package/dist/components/{p-9a85b700.js → p-258c3c53.js} +125 -101
  94. package/dist/components/{p-263dc67d.js → p-315d6592.js} +1 -1
  95. package/dist/components/{p-4dc4418a.js → p-3201d529.js} +1 -1
  96. package/dist/components/{p-7786799a.js → p-324ed895.js} +8 -4
  97. package/dist/components/{p-4c8548d4.js → p-4bc5ac82.js} +4 -3
  98. package/dist/components/{p-ffe8b41d.js → p-4dd750e9.js} +1 -1
  99. package/dist/components/{p-b679d760.js → p-4e08dcdd.js} +33 -32
  100. package/dist/components/{p-82fb3284.js → p-58c2bd5d.js} +1 -1
  101. package/dist/components/{p-d3170dcd.js → p-5a9cea40.js} +4 -4
  102. package/dist/components/{p-76282bf0.js → p-5d1dec61.js} +52 -53
  103. package/dist/components/{p-8b27ce22.js → p-5d4bbcd0.js} +1 -1
  104. package/dist/components/{p-8cd2e08d.js → p-5d82a9f3.js} +64 -57
  105. package/dist/components/{p-877eaf65.js → p-5eb45a4f.js} +1 -1
  106. package/dist/components/{p-cbb20d7a.js → p-6400f542.js} +36 -14
  107. package/dist/components/{p-6e8c00bc.js → p-642af221.js} +32 -31
  108. package/dist/components/{p-03660739.js → p-649a2ae7.js} +31 -32
  109. package/dist/components/{p-e4ac6259.js → p-6fcd99d1.js} +2 -2
  110. package/dist/components/p-7e9c499e.js +4 -0
  111. package/dist/components/{p-cdf871dd.js → p-81794664.js} +30 -29
  112. package/dist/components/{p-1b60debe.js → p-82a3f92e.js} +30 -29
  113. package/dist/components/{p-921297ba.js → p-84ae0283.js} +1 -1
  114. package/dist/components/{p-fbc69665.js → p-8d3c0b4c.js} +2 -2
  115. package/dist/components/{p-83a2fa2f.js → p-8fbc64e9.js} +72 -55
  116. package/dist/components/{p-761eefa9.js → p-94065def.js} +91 -90
  117. package/dist/components/{p-0e64ccc3.js → p-9bb47a5a.js} +1 -1
  118. package/dist/components/{p-df4ac086.js → p-a3e12c74.js} +2 -2
  119. package/dist/components/{p-6b369b14.js → p-b16c202a.js} +1 -1
  120. package/dist/components/{p-3518350d.js → p-b9034018.js} +4 -4
  121. package/dist/components/{p-b8cd75c0.js → p-b9a18099.js} +56 -46
  122. package/dist/components/{p-8f942993.js → p-bdc03b91.js} +32 -31
  123. package/dist/components/{p-4535a9fd.js → p-c7b00ce6.js} +36 -17
  124. package/dist/components/{p-e4a852b5.js → p-c8fedb4e.js} +7 -6
  125. package/dist/components/{p-0162bdd3.js → p-caa41754.js} +31 -34
  126. package/dist/components/{p-83245875.js → p-cf6ea837.js} +2 -2
  127. package/dist/components/p-da4d4eed.js +1781 -0
  128. package/dist/components/p-ea5954bd.js +4 -0
  129. package/dist/components/{p-1e63fb14.js → p-ec894daf.js} +2 -2
  130. package/dist/components/{p-556596e4.js → p-f72b9c45.js} +1 -1
  131. package/dist/components/{p-a7bbe96b.js → p-f990140a.js} +3 -3
  132. package/dist/components/{p-db4a15fd.js → p-fcad60f5.js} +1 -1
  133. package/dist/components/verdocs-auth.js +4 -4
  134. package/dist/components/verdocs-build.js +93 -115
  135. package/dist/components/verdocs-button-panel.js +1 -1
  136. package/dist/components/verdocs-button.js +1 -1
  137. package/dist/components/verdocs-checkbox.js +1 -1
  138. package/dist/components/verdocs-component-error.js +1 -1
  139. package/dist/components/verdocs-contact-picker.js +1 -1
  140. package/dist/components/verdocs-dialog.js +1 -1
  141. package/dist/components/verdocs-dropdown.js +1 -1
  142. package/dist/components/verdocs-envelope-document-page.js +1 -1
  143. package/dist/components/verdocs-envelope-recipient-link.js +1 -1
  144. package/dist/components/verdocs-envelope-recipient-summary.js +37 -19
  145. package/dist/components/verdocs-envelope-sidebar.js +76 -54
  146. package/dist/components/verdocs-envelopes-list.js +12 -12
  147. package/dist/components/verdocs-field-attachment.js +1 -1
  148. package/dist/components/verdocs-field-checkbox.js +1 -1
  149. package/dist/components/verdocs-field-date.js +1 -1
  150. package/dist/components/verdocs-field-dropdown.js +1 -1
  151. package/dist/components/verdocs-field-initial.js +1 -1
  152. package/dist/components/verdocs-field-payment.js +106 -33
  153. package/dist/components/verdocs-field-radio.js +1 -1
  154. package/dist/components/verdocs-field-signature.js +1 -1
  155. package/dist/components/verdocs-field-textarea.js +1 -1
  156. package/dist/components/verdocs-field-textbox.js +1 -1
  157. package/dist/components/verdocs-field-timestamp.js +1 -1
  158. package/dist/components/verdocs-file-chooser.js +56 -1
  159. package/dist/components/verdocs-help-icon.js +1 -1
  160. package/dist/components/verdocs-initial-dialog.js +1 -1
  161. package/dist/components/verdocs-kba-dialog.js +1 -1
  162. package/dist/components/verdocs-loader.js +1 -1
  163. package/dist/components/verdocs-ok-dialog.js +1 -1
  164. package/dist/components/verdocs-organization-card.js +2 -2
  165. package/dist/components/verdocs-pagination.js +1 -1
  166. package/dist/components/verdocs-portal.js +1 -1
  167. package/dist/components/verdocs-preview.js +1 -1
  168. package/dist/components/verdocs-progress-bar.js +1 -1
  169. package/dist/components/verdocs-quick-filter.js +1 -1
  170. package/dist/components/verdocs-quick-functions.js +1 -1
  171. package/dist/components/verdocs-radio-button.js +1 -1
  172. package/dist/components/verdocs-search-box.js +1 -1
  173. package/dist/components/verdocs-search-tabs.js +1 -1
  174. package/dist/components/verdocs-select-input.js +1 -1
  175. package/dist/components/verdocs-send.js +1 -1
  176. package/dist/components/verdocs-sign.js +24 -23
  177. package/dist/components/verdocs-signature-dialog.js +1 -1
  178. package/dist/components/verdocs-spinner.js +1 -1
  179. package/dist/components/verdocs-status-indicator.js +1 -1
  180. package/dist/components/verdocs-switch.js +1 -1
  181. package/dist/components/verdocs-table.js +1 -1
  182. package/dist/components/verdocs-tabs.js +1 -1
  183. package/dist/components/verdocs-template-build-tabs.js +1 -1
  184. package/dist/components/verdocs-template-card.js +1 -1
  185. package/dist/components/verdocs-template-create.js +148 -1
  186. package/dist/components/verdocs-template-document-page.js +1 -1
  187. package/dist/components/verdocs-template-field-properties.js +1 -1
  188. package/dist/components/verdocs-template-fields.js +1 -1
  189. package/dist/components/verdocs-template-role-properties.js +1 -1
  190. package/dist/components/verdocs-template-roles.js +1 -1
  191. package/dist/components/verdocs-template-star.js +1 -1
  192. package/dist/components/verdocs-template-tags.js +2 -2
  193. package/dist/components/verdocs-templates-list.js +11 -11
  194. package/dist/components/verdocs-text-input.js +1 -1
  195. package/dist/components/verdocs-toggle-button.js +1 -1
  196. package/dist/components/verdocs-toggle.js +1 -1
  197. package/dist/components/verdocs-toolbar-icon.js +1 -1
  198. package/dist/components/verdocs-upload-dialog.js +1 -1
  199. package/dist/components/verdocs-view.js +1 -1
  200. package/dist/custom-elements.json +2114 -0
  201. package/dist/esm/Datastore-52fcbac6.js +1781 -0
  202. package/dist/esm/Icons-190fd11d.js +4 -0
  203. package/dist/esm/{index-c8587076.js → index-272d51a4.js} +20 -30
  204. package/dist/esm/loader.js +3 -3
  205. package/dist/esm/{utils-6ecd6558.js → utils-47de6f79.js} +4 -3
  206. package/dist/esm/verdocs-auth.entry.js +1 -1
  207. package/dist/esm/verdocs-build.entry.js +23 -14
  208. package/dist/esm/verdocs-button-panel_2.entry.js +1 -1
  209. package/dist/esm/{verdocs-button_3.entry.js → verdocs-button_2.entry.js} +2 -56
  210. package/dist/esm/{verdocs-checkbox_4.entry.js → verdocs-checkbox_6.entry.js} +115 -26
  211. package/dist/esm/verdocs-contact-picker_2.entry.js +2 -2
  212. package/dist/esm/verdocs-dialog.entry.js +1 -1
  213. package/dist/esm/verdocs-dropdown.entry.js +1 -1
  214. package/dist/esm/verdocs-envelope-document-page.entry.js +2 -2
  215. package/dist/esm/verdocs-envelope-recipient-link_2.entry.js +31 -16
  216. package/dist/esm/verdocs-envelope-recipient-summary.entry.js +33 -18
  217. package/dist/esm/verdocs-envelope-sidebar.entry.js +65 -46
  218. package/dist/esm/verdocs-envelopes-list.entry.js +2 -2
  219. package/dist/esm/verdocs-field-attachment_13.entry.js +105 -156
  220. package/dist/esm/verdocs-field-payment.entry.js +38 -25
  221. package/dist/{components/p-fe2dca8c.js → esm/verdocs-file-chooser.entry.js} +8 -31
  222. package/dist/esm/verdocs-kba-dialog_2.entry.js +27 -5
  223. package/dist/esm/verdocs-ok-dialog.entry.js +1 -1
  224. package/dist/esm/verdocs-organization-card_2.entry.js +1 -1
  225. package/dist/esm/verdocs-pagination_2.entry.js +2 -2
  226. package/dist/esm/{verdocs-preview_9.entry.js → verdocs-preview_5.entry.js} +222 -591
  227. package/dist/esm/verdocs-progress-bar.entry.js +21 -0
  228. package/dist/esm/verdocs-quick-functions.entry.js +1 -1
  229. package/dist/esm/verdocs-radio-button.entry.js +1 -1
  230. package/dist/esm/verdocs-search-box.entry.js +1 -1
  231. package/dist/esm/verdocs-search-tabs.entry.js +1 -1
  232. package/dist/esm/verdocs-sign.entry.js +11 -12
  233. package/dist/esm/verdocs-spinner.entry.js +1 -1
  234. package/dist/esm/verdocs-status-indicator.entry.js +1 -1
  235. package/dist/esm/verdocs-table.entry.js +1 -1
  236. package/dist/esm/verdocs-template-card.entry.js +1 -1
  237. package/dist/{components/p-f9cc62a7.js → esm/verdocs-template-create.entry.js} +15 -69
  238. package/dist/esm/verdocs-template-document-page_2.entry.js +79 -64
  239. package/dist/esm/verdocs-template-role-properties.entry.js +59 -38
  240. package/dist/esm/verdocs-template-star.entry.js +2 -2
  241. package/dist/esm/verdocs-template-tags.entry.js +2 -2
  242. package/dist/esm/verdocs-templates-list.entry.js +1 -1
  243. package/dist/esm/verdocs-toggle.entry.js +1 -1
  244. package/dist/esm/verdocs-web-sdk.js +4 -4
  245. package/dist/esm-es5/Datastore-52fcbac6.js +1 -0
  246. package/dist/esm-es5/Icons-190fd11d.js +1 -0
  247. package/dist/esm-es5/index-272d51a4.js +1 -0
  248. package/dist/esm-es5/loader.js +1 -1
  249. package/dist/esm-es5/{utils-6ecd6558.js → utils-47de6f79.js} +1 -1
  250. package/dist/esm-es5/verdocs-auth.entry.js +1 -1
  251. package/dist/esm-es5/verdocs-build.entry.js +1 -1
  252. package/dist/esm-es5/verdocs-button-panel_2.entry.js +1 -1
  253. package/dist/esm-es5/verdocs-button_2.entry.js +1 -0
  254. package/dist/esm-es5/verdocs-checkbox_6.entry.js +1 -0
  255. package/dist/esm-es5/verdocs-contact-picker_2.entry.js +1 -1
  256. package/dist/esm-es5/verdocs-dialog.entry.js +1 -1
  257. package/dist/esm-es5/verdocs-dropdown.entry.js +1 -1
  258. package/dist/esm-es5/verdocs-envelope-document-page.entry.js +1 -1
  259. package/dist/esm-es5/verdocs-envelope-recipient-link_2.entry.js +1 -1
  260. package/dist/esm-es5/verdocs-envelope-recipient-summary.entry.js +1 -1
  261. package/dist/esm-es5/verdocs-envelope-sidebar.entry.js +1 -1
  262. package/dist/esm-es5/verdocs-envelopes-list.entry.js +1 -1
  263. package/dist/esm-es5/verdocs-field-attachment_13.entry.js +1 -1
  264. package/dist/esm-es5/verdocs-field-payment.entry.js +1 -1
  265. package/dist/esm-es5/verdocs-file-chooser.entry.js +1 -0
  266. package/dist/esm-es5/verdocs-kba-dialog_2.entry.js +1 -1
  267. package/dist/esm-es5/verdocs-ok-dialog.entry.js +1 -1
  268. package/dist/esm-es5/verdocs-organization-card_2.entry.js +1 -1
  269. package/dist/esm-es5/verdocs-pagination_2.entry.js +1 -1
  270. package/dist/esm-es5/verdocs-preview_5.entry.js +1 -0
  271. package/dist/esm-es5/verdocs-progress-bar.entry.js +1 -0
  272. package/dist/esm-es5/verdocs-quick-functions.entry.js +1 -1
  273. package/dist/esm-es5/verdocs-radio-button.entry.js +1 -1
  274. package/dist/esm-es5/verdocs-search-box.entry.js +1 -1
  275. package/dist/esm-es5/verdocs-search-tabs.entry.js +1 -1
  276. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  277. package/dist/esm-es5/verdocs-spinner.entry.js +1 -1
  278. package/dist/esm-es5/verdocs-status-indicator.entry.js +1 -1
  279. package/dist/esm-es5/verdocs-table.entry.js +1 -1
  280. package/dist/esm-es5/verdocs-template-card.entry.js +1 -1
  281. package/dist/esm-es5/verdocs-template-create.entry.js +1 -0
  282. package/dist/esm-es5/verdocs-template-document-page_2.entry.js +1 -1
  283. package/dist/esm-es5/verdocs-template-role-properties.entry.js +1 -1
  284. package/dist/esm-es5/verdocs-template-star.entry.js +1 -1
  285. package/dist/esm-es5/verdocs-template-tags.entry.js +1 -1
  286. package/dist/esm-es5/verdocs-templates-list.entry.js +1 -1
  287. package/dist/esm-es5/verdocs-toggle.entry.js +1 -1
  288. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  289. package/dist/types/components/controls/verdocs-text-input/verdocs-text-input.d.ts +0 -2
  290. package/dist/types/components/embeds/verdocs-build/verdocs-build.d.ts +8 -32
  291. package/dist/types/components/embeds/verdocs-preview/verdocs-preview.d.ts +6 -8
  292. package/dist/types/components/embeds/verdocs-send/verdocs-send.d.ts +7 -6
  293. package/dist/types/components/embeds/verdocs-sign/verdocs-sign.d.ts +3 -3
  294. package/dist/types/components/embeds/verdocs-view/verdocs-view.d.ts +6 -5
  295. package/dist/types/components/envelopes/verdocs-envelope-recipient-link/verdocs-envelope-recipient-link.d.ts +6 -3
  296. package/dist/types/components/envelopes/verdocs-envelope-recipient-summary/verdocs-envelope-recipient-summary.d.ts +6 -3
  297. package/dist/types/components/envelopes/verdocs-envelope-sidebar/verdocs-envelope-sidebar.d.ts +8 -4
  298. package/dist/types/components/fields/verdocs-field-attachment/verdocs-field-attachment.d.ts +6 -7
  299. package/dist/types/components/fields/verdocs-field-checkbox/verdocs-field-checkbox.d.ts +6 -7
  300. package/dist/types/components/fields/verdocs-field-date/verdocs-field-date.d.ts +6 -7
  301. package/dist/types/components/fields/verdocs-field-dropdown/verdocs-field-dropdown.d.ts +6 -7
  302. package/dist/types/components/fields/verdocs-field-initial/verdocs-field-initial.d.ts +6 -7
  303. package/dist/types/components/fields/verdocs-field-payment/verdocs-field-payment.d.ts +44 -30
  304. package/dist/types/components/fields/verdocs-field-radio/verdocs-field-radio.d.ts +6 -7
  305. package/dist/types/components/fields/verdocs-field-signature/verdocs-field-signature.d.ts +6 -7
  306. package/dist/types/components/fields/verdocs-field-textarea/verdocs-field-textarea.d.ts +6 -7
  307. package/dist/types/components/fields/verdocs-field-textbox/verdocs-field-textbox.d.ts +5 -12
  308. package/dist/types/components/fields/verdocs-field-timestamp/verdocs-field-timestamp.d.ts +6 -7
  309. package/dist/types/components/templates/verdocs-template-build-tabs/verdocs-template-build-tabs.d.ts +7 -4
  310. package/dist/types/components/templates/verdocs-template-document-page/verdocs-template-document-page.d.ts +7 -4
  311. package/dist/types/components/templates/verdocs-template-field-properties/verdocs-template-field-properties.d.ts +7 -8
  312. package/dist/types/components/templates/verdocs-template-fields/verdocs-template-fields.d.ts +6 -8
  313. package/dist/types/components/templates/verdocs-template-role-properties/verdocs-template-role-properties.d.ts +7 -7
  314. package/dist/types/components/templates/verdocs-template-roles/verdocs-template-roles.d.ts +7 -6
  315. package/dist/types/components.d.ts +176 -409
  316. package/dist/types/utils/Datastore.d.ts +24 -0
  317. package/dist/types/utils/Templates.d.ts +3 -0
  318. package/dist/types/utils/utils.d.ts +1 -1
  319. package/dist/verdocs-web-sdk/{p-efcbb3cf.entry.js → p-0ca1e87c.entry.js} +1 -1
  320. package/dist/verdocs-web-sdk/{p-dc271457.entry.js → p-167e3d7e.entry.js} +1 -1
  321. package/dist/verdocs-web-sdk/p-1efce6e0.entry.js +1 -0
  322. package/dist/verdocs-web-sdk/{p-7bd37bca.entry.js → p-2a1287ec.entry.js} +1 -1
  323. package/dist/verdocs-web-sdk/{p-5381847c.system.js → p-2be751c4.system.js} +1 -1
  324. package/dist/verdocs-web-sdk/{p-cb30f11e.entry.js → p-2f73c9de.entry.js} +1 -1
  325. package/dist/verdocs-web-sdk/p-3364cc13.system.entry.js +1 -0
  326. package/dist/verdocs-web-sdk/{p-03d40eb5.system.entry.js → p-37d747fb.system.entry.js} +1 -1
  327. package/dist/verdocs-web-sdk/p-386d789c.system.entry.js +1 -0
  328. package/dist/verdocs-web-sdk/p-3a1fa556.system.entry.js +1 -0
  329. package/dist/verdocs-web-sdk/{p-0fd57194.entry.js → p-41cbf650.entry.js} +1 -1
  330. package/dist/verdocs-web-sdk/{p-26715b8b.entry.js → p-4b36ca30.entry.js} +1 -1
  331. package/dist/verdocs-web-sdk/{p-98501408.system.entry.js → p-4e9e154f.system.entry.js} +1 -1
  332. package/dist/verdocs-web-sdk/{p-a3778013.system.entry.js → p-511a4ecc.system.entry.js} +1 -1
  333. package/dist/verdocs-web-sdk/{p-65a4e01e.entry.js → p-524f37a0.entry.js} +1 -1
  334. package/dist/verdocs-web-sdk/{p-13fe8650.system.entry.js → p-53f4c7c3.system.entry.js} +1 -1
  335. package/dist/verdocs-web-sdk/p-54f085d1.entry.js +1 -0
  336. package/dist/verdocs-web-sdk/{p-d1e64207.entry.js → p-584113d1.entry.js} +1 -1
  337. package/dist/verdocs-web-sdk/{p-f8cad58e.entry.js → p-5f1a000c.entry.js} +1 -1
  338. package/dist/verdocs-web-sdk/{p-256f07fd.system.entry.js → p-62f15675.system.entry.js} +1 -1
  339. package/dist/verdocs-web-sdk/{p-fae63f89.js → p-650697bd.js} +1 -1
  340. package/dist/verdocs-web-sdk/{p-c06d2604.entry.js → p-65c5398e.entry.js} +1 -1
  341. package/dist/verdocs-web-sdk/p-6a95ce12.system.entry.js +1 -0
  342. package/dist/verdocs-web-sdk/{p-0446030b.entry.js → p-6ced37ed.entry.js} +1 -1
  343. package/dist/verdocs-web-sdk/{p-16619383.entry.js → p-7464b84f.entry.js} +1 -1
  344. package/dist/verdocs-web-sdk/{p-6e3fa0c4.system.entry.js → p-761f6656.system.entry.js} +1 -1
  345. package/dist/verdocs-web-sdk/{p-30bc5986.entry.js → p-76cc40fe.entry.js} +1 -1
  346. package/dist/verdocs-web-sdk/{p-c45dc777.entry.js → p-771c2f92.entry.js} +1 -1
  347. package/dist/verdocs-web-sdk/p-78191329.system.entry.js +1 -0
  348. package/dist/verdocs-web-sdk/p-79f842b4.system.entry.js +1 -0
  349. package/dist/verdocs-web-sdk/{p-f3c995d8.system.entry.js → p-7c8938e7.system.entry.js} +1 -1
  350. package/dist/verdocs-web-sdk/p-7e9c499e.js +1 -0
  351. package/dist/verdocs-web-sdk/p-8221a48f.entry.js +1 -0
  352. package/dist/verdocs-web-sdk/p-860b9f94.system.entry.js +1 -0
  353. package/dist/verdocs-web-sdk/p-89cdecac.system.entry.js +1 -0
  354. package/dist/verdocs-web-sdk/p-8a2ff048.entry.js +1 -0
  355. package/dist/verdocs-web-sdk/{p-921b56fd.system.entry.js → p-914e131c.system.entry.js} +1 -1
  356. package/dist/verdocs-web-sdk/{p-5737f0ae.system.js → p-9186f42e.system.js} +1 -1
  357. package/dist/verdocs-web-sdk/{p-8e233a6b.system.entry.js → p-9227d400.system.entry.js} +1 -1
  358. package/dist/verdocs-web-sdk/p-92ce6180.entry.js +1 -0
  359. package/dist/verdocs-web-sdk/p-9567cb7d.system.entry.js +1 -0
  360. package/dist/verdocs-web-sdk/p-9812e99d.system.entry.js +1 -0
  361. package/dist/verdocs-web-sdk/{p-4b4801ad.system.entry.js → p-982f1b36.system.entry.js} +1 -1
  362. package/dist/verdocs-web-sdk/{p-ed6a5478.system.entry.js → p-9d0b0e36.system.entry.js} +1 -1
  363. package/dist/verdocs-web-sdk/{p-4266e717.system.entry.js → p-a08886c1.system.entry.js} +1 -1
  364. package/dist/verdocs-web-sdk/{p-e25e1dcf.entry.js → p-a165607e.entry.js} +1 -1
  365. package/dist/verdocs-web-sdk/p-a242aa80.system.entry.js +1 -0
  366. package/dist/verdocs-web-sdk/p-a7db9f1f.system.entry.js +1 -0
  367. package/dist/verdocs-web-sdk/{p-5d6a2fda.system.entry.js → p-a9635106.system.entry.js} +1 -1
  368. package/dist/verdocs-web-sdk/p-aebb0cd9.system.entry.js +1 -0
  369. package/dist/verdocs-web-sdk/p-b00ef194.system.entry.js +1 -0
  370. package/dist/verdocs-web-sdk/p-b0b958a0.entry.js +1 -0
  371. package/dist/verdocs-web-sdk/p-b8737f7b.entry.js +1 -0
  372. package/dist/verdocs-web-sdk/{p-49988769.js → p-b9654a5e.js} +2 -2
  373. package/dist/verdocs-web-sdk/p-bb0effe1.entry.js +1 -0
  374. package/dist/verdocs-web-sdk/p-bcc23811.entry.js +1 -0
  375. package/dist/verdocs-web-sdk/{p-281e63e5.entry.js → p-bd7406ae.entry.js} +1 -1
  376. package/dist/verdocs-web-sdk/{p-e8d91957.entry.js → p-bdd7b3d3.entry.js} +1 -1
  377. package/dist/verdocs-web-sdk/{p-c5818330.entry.js → p-c1728f5c.entry.js} +1 -1
  378. package/dist/verdocs-web-sdk/p-c18c718f.system.js +1 -0
  379. package/dist/verdocs-web-sdk/{p-731066de.system.entry.js → p-c6fd3e53.system.entry.js} +1 -1
  380. package/dist/verdocs-web-sdk/p-c7cd6843.entry.js +1 -0
  381. package/dist/verdocs-web-sdk/{p-4f7c72f9.system.entry.js → p-c9f40726.system.entry.js} +1 -1
  382. package/dist/verdocs-web-sdk/p-ca712f40.system.entry.js +1 -0
  383. package/dist/verdocs-web-sdk/p-cbb75c5e.system.entry.js +1 -0
  384. package/dist/verdocs-web-sdk/{p-751b0280.entry.js → p-d475fff3.entry.js} +1 -1
  385. package/dist/verdocs-web-sdk/{p-91c4298b.system.entry.js → p-d5870e33.system.entry.js} +1 -1
  386. package/dist/verdocs-web-sdk/{p-e5126f26.system.entry.js → p-d8dae4e9.system.entry.js} +1 -1
  387. package/dist/verdocs-web-sdk/p-d93c7661.entry.js +1 -0
  388. package/dist/verdocs-web-sdk/{p-93093a7a.system.entry.js → p-d98cbd0f.system.entry.js} +1 -1
  389. package/dist/verdocs-web-sdk/p-da4d4eed.js +1 -0
  390. package/dist/verdocs-web-sdk/{p-2298c22e.entry.js → p-ddb17b3e.entry.js} +1 -1
  391. package/dist/verdocs-web-sdk/p-df04f0ca.entry.js +1 -0
  392. package/dist/verdocs-web-sdk/p-e2b70dfb.system.js +1 -0
  393. package/dist/verdocs-web-sdk/{p-2aea0c7b.system.entry.js → p-e438bd02.system.entry.js} +1 -1
  394. package/dist/verdocs-web-sdk/p-e5044463.entry.js +1 -0
  395. package/dist/verdocs-web-sdk/{p-b066c4f2.system.entry.js → p-e5d291f3.system.entry.js} +1 -1
  396. package/dist/verdocs-web-sdk/{p-7f1e0c5e.entry.js → p-e6dbb0f7.entry.js} +1 -1
  397. package/dist/verdocs-web-sdk/{p-c4d61c66.entry.js → p-e83cd333.entry.js} +1 -1
  398. package/dist/verdocs-web-sdk/p-efd8149f.system.js +1 -0
  399. package/dist/verdocs-web-sdk/p-f4fcf7a5.entry.js +1 -0
  400. package/dist/verdocs-web-sdk/{p-97b951e6.system.entry.js → p-f5d01982.system.entry.js} +1 -1
  401. package/dist/verdocs-web-sdk/p-f65a9b03.entry.js +1 -0
  402. package/dist/verdocs-web-sdk/p-f7abe6e2.entry.js +1 -0
  403. package/dist/verdocs-web-sdk/{p-6e55af26.system.entry.js → p-f9b37af2.system.entry.js} +1 -1
  404. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -1
  405. package/dist/verdocs-web-sdk/verdocs-web-sdk.js +1 -1
  406. package/package.json +3 -3
  407. package/dist/cjs/EnvelopeStore-f1cd9bd3.js +0 -96
  408. package/dist/cjs/Icons-9a6f2f7c.js +0 -86
  409. package/dist/cjs/TemplateFieldStore-7bcc0f7a.js +0 -44
  410. package/dist/cjs/TemplateRoleStore-e8bb00ec.js +0 -51
  411. package/dist/cjs/TemplateStore-db21be4d.js +0 -99
  412. package/dist/cjs/index-2a189d85.js +0 -3721
  413. package/dist/cjs/index-76d03a35.js +0 -196
  414. package/dist/cjs/verdocs-loader.cjs.entry.js +0 -20
  415. package/dist/collection/components/templates/verdocs-template-attachments/verdocs-template-attachments.css +0 -120
  416. package/dist/collection/components/templates/verdocs-template-attachments/verdocs-template-attachments.js +0 -284
  417. package/dist/collection/components/templates/verdocs-template-name/verdocs-template-name.css +0 -0
  418. package/dist/collection/components/templates/verdocs-template-name/verdocs-template-name.js +0 -196
  419. package/dist/collection/components/templates/verdocs-template-visibillity/verdocs-template-visibility.css +0 -86
  420. package/dist/collection/components/templates/verdocs-template-visibillity/verdocs-template-visibility.js +0 -203
  421. package/dist/collection/utils/EnvelopeStore.js +0 -90
  422. package/dist/collection/utils/TemplateFieldStore.js +0 -36
  423. package/dist/collection/utils/TemplateRoleStore.js +0 -41
  424. package/dist/collection/utils/TemplateStore.js +0 -94
  425. package/dist/components/p-00d39dca.js +0 -39
  426. package/dist/components/p-0933fb2d.js +0 -127
  427. package/dist/components/p-09d28afd.js +0 -97
  428. package/dist/components/p-3555cef1.js +0 -122
  429. package/dist/components/p-474b6663.js +0 -1314
  430. package/dist/components/p-821f2345.js +0 -93
  431. package/dist/components/p-9b5a4f9e.js +0 -44
  432. package/dist/components/p-a706bac9.js +0 -3719
  433. package/dist/components/p-b0766439.js +0 -76
  434. package/dist/components/p-ed9a1a21.js +0 -200
  435. package/dist/components/verdocs-template-attachments.d.ts +0 -11
  436. package/dist/components/verdocs-template-attachments.js +0 -6
  437. package/dist/components/verdocs-template-name.d.ts +0 -11
  438. package/dist/components/verdocs-template-name.js +0 -6
  439. package/dist/components/verdocs-template-visibility.d.ts +0 -11
  440. package/dist/components/verdocs-template-visibility.js +0 -6
  441. package/dist/esm/EnvelopeStore-4599b7d3.js +0 -93
  442. package/dist/esm/Icons-faf0377f.js +0 -76
  443. package/dist/esm/TemplateFieldStore-909147d8.js +0 -39
  444. package/dist/esm/TemplateRoleStore-2fef1fdb.js +0 -44
  445. package/dist/esm/TemplateStore-ace14a8b.js +0 -97
  446. package/dist/esm/index-24d8ae6a.js +0 -194
  447. package/dist/esm/index-7588a071.js +0 -3719
  448. package/dist/esm/verdocs-file-chooser_2.entry.js +0 -53
  449. package/dist/esm/verdocs-loader.entry.js +0 -16
  450. package/dist/esm-es5/EnvelopeStore-4599b7d3.js +0 -1
  451. package/dist/esm-es5/Icons-faf0377f.js +0 -1
  452. package/dist/esm-es5/TemplateFieldStore-909147d8.js +0 -1
  453. package/dist/esm-es5/TemplateRoleStore-2fef1fdb.js +0 -1
  454. package/dist/esm-es5/TemplateStore-ace14a8b.js +0 -1
  455. package/dist/esm-es5/index-24d8ae6a.js +0 -1
  456. package/dist/esm-es5/index-7588a071.js +0 -1
  457. package/dist/esm-es5/index-c8587076.js +0 -1
  458. package/dist/esm-es5/verdocs-button_3.entry.js +0 -1
  459. package/dist/esm-es5/verdocs-checkbox_4.entry.js +0 -1
  460. package/dist/esm-es5/verdocs-file-chooser_2.entry.js +0 -1
  461. package/dist/esm-es5/verdocs-loader.entry.js +0 -1
  462. package/dist/esm-es5/verdocs-preview_9.entry.js +0 -1
  463. package/dist/types/components/templates/verdocs-template-attachments/verdocs-template-attachments.d.ts +0 -56
  464. package/dist/types/components/templates/verdocs-template-name/verdocs-template-name.d.ts +0 -41
  465. package/dist/types/components/templates/verdocs-template-visibillity/verdocs-template-visibility.d.ts +0 -42
  466. package/dist/types/utils/EnvelopeStore.d.ts +0 -12
  467. package/dist/types/utils/TemplateFieldStore.d.ts +0 -9
  468. package/dist/types/utils/TemplateRoleStore.d.ts +0 -11
  469. package/dist/types/utils/TemplateStore.d.ts +0 -16
  470. package/dist/verdocs-web-sdk/p-0c51c5be.entry.js +0 -1
  471. package/dist/verdocs-web-sdk/p-194f9f4d.entry.js +0 -1
  472. package/dist/verdocs-web-sdk/p-1ce2f724.system.entry.js +0 -1
  473. package/dist/verdocs-web-sdk/p-2211234d.system.js +0 -1
  474. package/dist/verdocs-web-sdk/p-2305c1e8.system.entry.js +0 -1
  475. package/dist/verdocs-web-sdk/p-261d5b4a.system.entry.js +0 -1
  476. package/dist/verdocs-web-sdk/p-341d540f.system.entry.js +0 -1
  477. package/dist/verdocs-web-sdk/p-368a36ea.system.js +0 -1
  478. package/dist/verdocs-web-sdk/p-36b5d46e.entry.js +0 -1
  479. package/dist/verdocs-web-sdk/p-569434fb.system.js +0 -1
  480. package/dist/verdocs-web-sdk/p-56c1ebd6.entry.js +0 -1
  481. package/dist/verdocs-web-sdk/p-5bf2910c.system.entry.js +0 -1
  482. package/dist/verdocs-web-sdk/p-6bc1b9f4.entry.js +0 -1
  483. package/dist/verdocs-web-sdk/p-6fda3817.js +0 -1
  484. package/dist/verdocs-web-sdk/p-77ec43a3.system.entry.js +0 -1
  485. package/dist/verdocs-web-sdk/p-79e222f8.entry.js +0 -1
  486. package/dist/verdocs-web-sdk/p-7a5b80f8.entry.js +0 -1
  487. package/dist/verdocs-web-sdk/p-7d18cb23.system.entry.js +0 -1
  488. package/dist/verdocs-web-sdk/p-7d593603.system.js +0 -1
  489. package/dist/verdocs-web-sdk/p-9fabdbb1.system.entry.js +0 -1
  490. package/dist/verdocs-web-sdk/p-9ff1be63.entry.js +0 -1
  491. package/dist/verdocs-web-sdk/p-a04aac80.entry.js +0 -1
  492. package/dist/verdocs-web-sdk/p-a1a2c13b.entry.js +0 -1
  493. package/dist/verdocs-web-sdk/p-a706bac9.js +0 -1
  494. package/dist/verdocs-web-sdk/p-b0766439.js +0 -1
  495. package/dist/verdocs-web-sdk/p-b0bc8c15.system.entry.js +0 -1
  496. package/dist/verdocs-web-sdk/p-b17843d9.system.js +0 -1
  497. package/dist/verdocs-web-sdk/p-b1fcc883.entry.js +0 -1
  498. package/dist/verdocs-web-sdk/p-b56793c4.entry.js +0 -1
  499. package/dist/verdocs-web-sdk/p-b84d1a25.system.entry.js +0 -1
  500. package/dist/verdocs-web-sdk/p-bb253149.js +0 -1
  501. package/dist/verdocs-web-sdk/p-bd642df2.js +0 -1
  502. package/dist/verdocs-web-sdk/p-c7115b35.system.entry.js +0 -1
  503. package/dist/verdocs-web-sdk/p-cd546dbe.system.js +0 -1
  504. package/dist/verdocs-web-sdk/p-cde4c155.js +0 -1
  505. package/dist/verdocs-web-sdk/p-d3ddc7c8.system.entry.js +0 -1
  506. package/dist/verdocs-web-sdk/p-d86c8c1a.entry.js +0 -1
  507. package/dist/verdocs-web-sdk/p-dbddb752.system.entry.js +0 -1
  508. package/dist/verdocs-web-sdk/p-dcd3eb1b.js +0 -1
  509. package/dist/verdocs-web-sdk/p-e123f19c.entry.js +0 -1
  510. package/dist/verdocs-web-sdk/p-e294b6c2.system.entry.js +0 -1
  511. package/dist/verdocs-web-sdk/p-e48b387d.system.entry.js +0 -1
  512. package/dist/verdocs-web-sdk/p-e83a163d.entry.js +0 -1
  513. package/dist/verdocs-web-sdk/p-f5064e0c.system.js +0 -1
  514. package/dist/verdocs-web-sdk/p-f79b8537.system.js +0 -1
@@ -2,19 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-2589e4d1.js');
5
+ const index = require('./index-ccac8641.js');
6
6
  const jsSdk = require('@verdocs/js-sdk');
7
- const TemplateFieldStore = require('./TemplateFieldStore-7bcc0f7a.js');
8
- const TemplateRoleStore = require('./TemplateRoleStore-e8bb00ec.js');
9
- const TemplateStore = require('./TemplateStore-db21be4d.js');
10
7
  const errors = require('./errors-017fb835.js');
8
+ const Datastore = require('./Datastore-b1742da2.js');
11
9
  const Toast = require('./Toast-d84d7bd3.js');
12
- const Icons = require('./Icons-9a6f2f7c.js');
13
10
  const format = require('./format-dc0f3757.js');
14
11
  const interact_min = require('./interact.min-e6956f8b.js');
15
- const utils = require('./utils-5accd019.js');
16
- require('./index-76d03a35.js');
17
- require('./index-2a189d85.js');
12
+ const utils = require('./utils-ba1e95e0.js');
18
13
  require('./_commonjsHelpers-e6ff1d6e.js');
19
14
  require('./Types-7a726ff3.js');
20
15
 
@@ -25,16 +20,31 @@ const VerdocsPreview = class {
25
20
  constructor(hostRef) {
26
21
  index.registerInstance(this, hostRef);
27
22
  this.sdkError = index.createEvent(this, "sdkError", 7);
28
- this.templateStore = null;
29
- this.fieldStore = null;
30
- this.roleStore = null;
23
+ this.templateListenerId = null;
31
24
  this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
32
25
  this.templateId = null;
33
26
  this.loading = true;
27
+ this.template = null;
28
+ }
29
+ disconnectedCallback() {
30
+ this.unlistenToTemplate();
31
+ }
32
+ async listenToTemplate() {
33
+ this.unlistenToTemplate();
34
+ Datastore.Store.subscribe('templates', this.templateId, () => jsSdk.getTemplate(this.endpoint, this.templateId), false, (template) => {
35
+ this.template = template;
36
+ this.loading = false;
37
+ });
38
+ }
39
+ unlistenToTemplate() {
40
+ if (this.templateListenerId) {
41
+ Datastore.Store.store.delListener(this.templateListenerId);
42
+ this.templateListenerId = null;
43
+ }
34
44
  }
35
45
  onTemplateIdChanged(newTemplateId) {
36
46
  console.log('[PREVIEW] Template ID changed', newTemplateId);
37
- this.loadTemplate(newTemplateId).catch((e) => console.log('Unknown Error', e));
47
+ this.listenToTemplate();
38
48
  }
39
49
  async componentWillLoad() {
40
50
  var _a, _b, _c;
@@ -48,40 +58,25 @@ const VerdocsPreview = class {
48
58
  console.log(`[PREVIEW] Missing required template ID ${this.templateId}`);
49
59
  return;
50
60
  }
51
- return this.loadTemplate(this.templateId);
61
+ this.listenToTemplate();
52
62
  }
53
63
  catch (e) {
54
64
  console.log('[PREVIEW] Error with preview session', e);
55
65
  (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
56
66
  }
57
67
  }
58
- async loadTemplate(templateId) {
59
- if (templateId) {
60
- TemplateStore.getTemplateStore(this.endpoint, templateId, false)
61
- .then(ts => {
62
- this.templateStore = ts;
63
- this.fieldStore = TemplateFieldStore.getTemplateFieldStore(this.templateId);
64
- this.roleStore = TemplateRoleStore.getTemplateRoleStore(this.templateId);
65
- this.loading = false;
66
- })
67
- .catch(e => {
68
- console.log('Unable to load template', e);
69
- throw e;
70
- });
71
- }
72
- }
73
68
  handlePageRendered(_e) {
74
69
  // const pageInfo = e.detail as IDocumentPageInfo;
75
- // const fields = this.templateStore?.state?.fields.filter(field => field.page === pageInfo.pageNumber);
70
+ // const fields = (this.template?.fields || []).filter(field => field.page === pageInfo.pageNumber);
76
71
  // console.log('[PREVIEW] Page rendered', pageInfo, fields);
77
72
  // fields.forEach(field => renderDocumentField(field, pageInfo, {disabled: true, editable: false, draggable: false}));
78
73
  }
79
74
  render() {
80
- var _a, _b;
75
+ var _a;
81
76
  if (this.loading) {
82
77
  return (index.h(index.Host, null, index.h("verdocs-loader", null)));
83
78
  }
84
- return (index.h(index.Host, null, (((_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.documents) || []).map(document => {
79
+ return (index.h(index.Host, null, (((_a = this.template) === null || _a === void 0 ? void 0 : _a.documents) || []).map(document => {
85
80
  const pageNumbers = jsSdk.integerSequence(1, document.pages);
86
81
  return (index.h(index.Fragment, null, pageNumbers.map(pageNumber => {
87
82
  var _a;
@@ -99,6 +94,9 @@ const VerdocsPreview = class {
99
94
  };
100
95
  VerdocsPreview.style = VerdocsPreviewStyle0;
101
96
 
97
+ const getRoleNames = (template) => ((template === null || template === void 0 ? void 0 : template.roles) || []).map(role => role.name);
98
+ const getRoleIndex = (template, role_name) => Math.max(getRoleNames(template).findIndex(name => name === role_name), 0);
99
+
102
100
  const verdocsSendCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-send{padding:10px;position:relative;background:#ffffff;-ms-flex-direction:column;flex-direction:column;font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-send.sendable{display:-ms-flexbox;display:flex}verdocs-send .recipients{position:relative}verdocs-send .left-line{top:32px;left:20px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-send .level{display:-ms-flexbox;display:flex;-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;margin-left:50px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:8px 0 4px 0;border-bottom:1px solid rgba(151, 151, 151, 0.2666666667)}verdocs-send .level .level-icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-send .level .level-icon svg{fill:rgba(0, 0, 0, 0.537254902)}verdocs-send .level .recipient{height:30px;display:-ms-flexbox;display:flex;-ms-flex:0 0 30px;flex:0 0 30px;color:#000000;cursor:pointer;font-size:14px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;background:#dddddd;white-space:nowrap;border:2px solid #dddddd;padding:2px 10px 2px 14px}verdocs-send .level .recipient .icon{width:22px;height:22px;-ms-flex:0 0 22px;flex:0 0 22px;margin:0 0 0 10px}verdocs-send .level .recipient .icon svg{width:22px;height:22px;fill:#333333;outline:none}verdocs-send .level .complete{-ms-flex:1;flex:1;height:30px;display:-ms-flexbox;display:flex;color:#000000;font-size:14px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:3px 10px 3px 2px}verdocs-send .buttons{display:-ms-flexbox;display:flex;margin-top:10px;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-direction:row;flex-direction:row}verdocs-send verdocs-contact-picker{left:0;top:41px;z-index:10;position:absolute;border:1px solid #dddddd;-webkit-box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1);box-shadow:0 0 6px 3px rgba(0, 0, 0, 0.1)}";
103
101
  const VerdocsSendStyle0 = verdocsSendCss;
104
102
 
@@ -114,6 +112,7 @@ const VerdocsSend = class {
114
112
  this.exit = index.createEvent(this, "exit", 7);
115
113
  this.sdkError = index.createEvent(this, "sdkError", 7);
116
114
  this.searchContacts = index.createEvent(this, "searchContacts", 7);
115
+ this.templateListenerId = null;
117
116
  this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
118
117
  this.templateId = null;
119
118
  this.environment = '';
@@ -122,15 +121,33 @@ const VerdocsSend = class {
122
121
  this.sessionContacts = [];
123
122
  this.sending = false;
124
123
  this.rolesCompleted = {};
125
- this.templateStore = null;
126
- this.roleStore = null;
124
+ this.loading = true;
125
+ this.template = null;
126
+ }
127
+ disconnectedCallback() {
128
+ this.unlistenToTemplate();
129
+ }
130
+ async listenToTemplate() {
131
+ console.log('[SEND] Loading template', this.templateId);
132
+ this.unlistenToTemplate();
133
+ Datastore.Store.subscribe('templates', this.templateId, () => jsSdk.getTemplate(this.endpoint, this.templateId), false, (template) => {
134
+ this.template = template;
135
+ this.loading = false;
136
+ this.rolesCompleted = {};
137
+ });
138
+ }
139
+ unlistenToTemplate() {
140
+ if (this.templateListenerId) {
141
+ Datastore.Store.store.delListener(this.templateListenerId);
142
+ this.templateListenerId = null;
143
+ }
127
144
  }
128
145
  async reset() {
129
146
  this.rolesCompleted = {};
130
147
  }
131
148
  onTemplateIdChanged(newTemplateId) {
132
149
  console.log('[SEND] Template ID changed', newTemplateId);
133
- this.loadTemplate(newTemplateId).catch((e) => console.log('Unknown Error', e));
150
+ this.listenToTemplate();
134
151
  }
135
152
  async componentWillLoad() {
136
153
  var _a, _b, _c;
@@ -167,37 +184,18 @@ const VerdocsSend = class {
167
184
  console.log(`[SEND] Missing required template ID ${this.templateId}`);
168
185
  return;
169
186
  }
170
- return this.loadTemplate(this.templateId);
187
+ this.listenToTemplate();
171
188
  }
172
189
  catch (e) {
173
190
  console.log('[SEND] Error with send session', e);
174
191
  (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
175
192
  }
176
193
  }
177
- async loadTemplate(templateId) {
178
- var _a, _b, _c, _d, _e;
179
- if (!templateId) {
180
- return;
181
- }
182
- try {
183
- this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, templateId, false);
184
- this.roleStore = TemplateRoleStore.getTemplateRoleStore(templateId);
185
- this.recomputeRolesCompleted();
186
- if (!((_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.is_sendable)) {
187
- console.warn(`[SEND] Template is not sendable`, templateId);
188
- }
189
- }
190
- catch (e) {
191
- console.log('[SEND] Error with preview session', e);
192
- (_c = this.sdkError) === null || _c === void 0 ? void 0 : _c.emit(new errors.SDKError(e.message, (_d = e.response) === null || _d === void 0 ? void 0 : _d.status, (_e = e.response) === null || _e === void 0 ? void 0 : _e.data));
193
- }
194
- }
195
194
  recomputeRolesCompleted() {
196
195
  var _a;
197
- const roles = ((_a = this.roleStore) === null || _a === void 0 ? void 0 : _a.get('roles')) || [];
198
- const rolesAtLevel = {};
199
196
  this.rolesCompleted = {};
200
- roles.forEach(role => {
197
+ const rolesAtLevel = {};
198
+ (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).forEach(role => {
201
199
  const level = role.sequence - 1;
202
200
  rolesAtLevel[level] || (rolesAtLevel[level] = []);
203
201
  const id = `r-${level}-${rolesAtLevel[level].length}`;
@@ -211,15 +209,13 @@ const VerdocsSend = class {
211
209
  }
212
210
  getLevels() {
213
211
  var _a;
214
- const roles = ((_a = this.roleStore) === null || _a === void 0 ? void 0 : _a.get('roles')) || [];
215
- const levels = [...new Set(roles.map(role => role.sequence - 1))];
212
+ const levels = [...new Set((((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).map(role => role.sequence - 1))];
216
213
  levels.sort((a, b) => a - b);
217
214
  return levels;
218
215
  }
219
216
  getRolesAtLevel(level) {
220
217
  var _a;
221
- const roles = ((_a = this.roleStore) === null || _a === void 0 ? void 0 : _a.get('roles')) || [];
222
- const rolesAtLevel = roles
218
+ const rolesAtLevel = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || [])
223
219
  .filter(role => role.sequence - 1 === level)
224
220
  .map((role, index) => ({
225
221
  ...role,
@@ -252,7 +248,7 @@ const VerdocsSend = class {
252
248
  this.showPickerForId = role.id;
253
249
  }
254
250
  handleSend(e) {
255
- var _a, _b, _c;
251
+ var _a, _b;
256
252
  if (this.sending) {
257
253
  console.log('[SEND] Skipping duplicate send', e);
258
254
  return;
@@ -264,7 +260,7 @@ const VerdocsSend = class {
264
260
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: true });
265
261
  const details = {
266
262
  template_id: this.templateId,
267
- name: ((_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.name) || '',
263
+ name: ((_b = this.template) === null || _b === void 0 ? void 0 : _b.name) || 'New Envelope',
268
264
  environment: this.environment,
269
265
  initial_reminder: 0,
270
266
  followup_reminders: 0,
@@ -275,12 +271,12 @@ const VerdocsSend = class {
275
271
  console.log('[SEND] Creating envelope', details);
276
272
  jsSdk.createEnvelope(this.endpoint, details)
277
273
  .then(r => {
278
- var _a, _b, _c, _d;
274
+ var _a, _b;
279
275
  console.log('[SEND] Send envelope', r);
280
276
  this.reset().catch((e) => console.log('Unknown Error', e));
281
277
  this.sending = false;
282
278
  (_a = this.sendingEnvelope) === null || _a === void 0 ? void 0 : _a.emit({ sending: false });
283
- (_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
+ (_b = this.send) === null || _b === void 0 ? void 0 : _b.emit({ ...details, name: details.name, envelope_id: r.id, envelope: r });
284
280
  })
285
281
  .catch(e => {
286
282
  var _a, _b, _c;
@@ -296,22 +292,25 @@ const VerdocsSend = class {
296
292
  (_a = this.exit) === null || _a === void 0 ? void 0 : _a.emit();
297
293
  }
298
294
  render() {
299
- var _a, _b;
295
+ var _a;
296
+ if (this.loading) {
297
+ return (index.h(index.Host, null, index.h("verdocs-loader", null)));
298
+ }
300
299
  if (!this.endpoint.session) {
301
300
  return (index.h(index.Host, { style: { display: 'flex' } }, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
302
301
  }
303
302
  const levels = this.getLevels();
304
- const roleNames = TemplateRoleStore.getRoleNames(this.roleStore);
305
303
  const rolesAssigned = Object.values(this.rolesCompleted).filter(recipient => jsSdk.isValidEmail(recipient.email));
306
304
  // TODO: Reactivate once SMS is re-enabled
307
305
  // const rolesAssigned = Object.values(this.rolesCompleted).filter(recipient => isValidEmail(recipient.email) || isValidPhone(recipient.phone));
308
- const allRolesAssigned = rolesAssigned.length >= roleNames.length;
309
- // console.log('[SEND] Roles completed', this.rolesCompleted);
310
- return (index.h(index.Host, { class: { sendable: (_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.is_sendable } }, index.h("div", { class: "recipients" }, index.h("div", { class: "left-line" }), index.h("div", { class: `level level-start` }, this.getLevelIcon(-1), index.h("div", { class: "complete" }, "Send Envelope")), levels.map(level => (index.h("div", { class: `level level-${level}` }, this.getLevelIcon(level), this.getRolesAtLevel(level).map(role => {
306
+ const allRolesAssigned = rolesAssigned.length >= getRoleNames(this.template).length;
307
+ return (index.h(index.Host, { class: { sendable: (_a = this.template) === null || _a === void 0 ? void 0 : _a.is_sendable } }, index.h("div", { class: "recipients" }, index.h("div", { class: "left-line" }), index.h("div", { class: `level level-start` }, this.getLevelIcon(-1), index.h("div", { class: "complete" }, "Send Envelope")), levels.map(level => (index.h("div", { class: `level level-${level}` }, this.getLevelIcon(level), this.getRolesAtLevel(level).map(role => {
311
308
  var _a, _b, _c, _d;
312
309
  const unknown = !role.email;
313
310
  const elId = `verdocs-send-recipient-${role.role_name}`;
314
- return unknown ? (index.h("div", { class: "recipient", "data-ri": TemplateRoleStore.getRoleIndex(this.roleStore, role.role_name), "data-rn": role.role_name, style: { backgroundColor: jsSdk.getRGBA(TemplateRoleStore.getRoleIndex(this.roleStore, role.role_name)) }, onClick: e => this.handleClickRole(e, role), id: elId }, ((_a = this.rolesCompleted[role.id]) === null || _a === void 0 ? void 0 : _a.first_name) ? jsSdk.formatFullName(this.rolesCompleted[role.id]) : role.role_name, index.h("div", { class: "icon", innerHTML: editIcon }), this.showPickerForId === role.id && (index.h("verdocs-portal", { anchor: elId, onClickAway: () => (this.showPickerForId = '') }, index.h("verdocs-contact-picker", { onExit: () => (this.showPickerForId = ''), onNext: e => this.handleSelectContact(e, role), contactSuggestions: this.sessionContacts, templateRole: (_b = this.rolesCompleted[role.id]) !== null && _b !== void 0 ? _b : role, onSearchContacts: e => { var _a; return (_a = this.searchContacts) === null || _a === void 0 ? void 0 : _a.emit(e.detail); } }))))) : (index.h("div", { class: "recipient", style: { borderColor: jsSdk.getRGBA(TemplateRoleStore.getRoleIndex(this.roleStore, role.role_name)) }, onClick: e => this.handleClickRole(e, role), id: elId }, ((_c = this.rolesCompleted[role.id]) === null || _c === void 0 ? void 0 : _c.first_name) ? jsSdk.formatFullName(this.rolesCompleted[role.id]) : role.role_name, index.h("div", { class: "icon", innerHTML: editIcon }), this.showPickerForId === role.id && (index.h("verdocs-portal", { anchor: elId, onClickAway: () => (this.showPickerForId = '') }, index.h("verdocs-contact-picker", { onExit: () => (this.showPickerForId = ''), onNext: e => this.handleSelectContact(e, role), contactSuggestions: this.sessionContacts, templateRole: ((_d = this.rolesCompleted[role.id]) !== null && _d !== void 0 ? _d : role), onSearchContacts: e => { var _a; return (_a = this.searchContacts) === null || _a === void 0 ? void 0 : _a.emit(e.detail); } })))));
311
+ const roleIndex = getRoleIndex(this.template, role.role_name);
312
+ const rgba = jsSdk.getRGBA(roleIndex);
313
+ return unknown ? (index.h("div", { class: "recipient", "data-ri": roleIndex, "data-rn": role.role_name, style: { backgroundColor: rgba }, onClick: e => this.handleClickRole(e, role), id: elId }, ((_a = this.rolesCompleted[role.id]) === null || _a === void 0 ? void 0 : _a.first_name) ? jsSdk.formatFullName(this.rolesCompleted[role.id]) : role.role_name, index.h("div", { class: "icon", innerHTML: editIcon }), this.showPickerForId === role.id && (index.h("verdocs-portal", { anchor: elId, onClickAway: () => (this.showPickerForId = '') }, index.h("verdocs-contact-picker", { onExit: () => (this.showPickerForId = ''), onNext: e => this.handleSelectContact(e, role), contactSuggestions: this.sessionContacts, templateRole: (_b = this.rolesCompleted[role.id]) !== null && _b !== void 0 ? _b : role, onSearchContacts: e => { var _a; return (_a = this.searchContacts) === null || _a === void 0 ? void 0 : _a.emit(e.detail); } }))))) : (index.h("div", { class: "recipient", style: { borderColor: rgba }, onClick: e => this.handleClickRole(e, role), id: elId }, ((_c = this.rolesCompleted[role.id]) === null || _c === void 0 ? void 0 : _c.first_name) ? jsSdk.formatFullName(this.rolesCompleted[role.id]) : role.role_name, index.h("div", { class: "icon", innerHTML: editIcon }), this.showPickerForId === role.id && (index.h("verdocs-portal", { anchor: elId, onClickAway: () => (this.showPickerForId = '') }, index.h("verdocs-contact-picker", { onExit: () => (this.showPickerForId = ''), onNext: e => this.handleSelectContact(e, role), contactSuggestions: this.sessionContacts, templateRole: ((_d = this.rolesCompleted[role.id]) !== null && _d !== void 0 ? _d : role), onSearchContacts: e => { var _a; return (_a = this.searchContacts) === null || _a === void 0 ? void 0 : _a.emit(e.detail); } })))));
315
314
  })))), index.h("div", { class: `level level-done` }, this.getLevelIcon(levels.length), index.h("div", { class: "complete" }, "Signing Complete"))), index.h("div", { class: "buttons" }, index.h("verdocs-button", { label: "Cancel", size: "small", variant: "outline", onClick: e => this.handleCancel(e), disabled: this.sending }), index.h("verdocs-button", { label: "Send", size: "small", disabled: !allRolesAssigned || this.sending, onClick: e => this.handleSend(e) }), this.sending && index.h("verdocs-spinner", null))));
316
315
  }
317
316
  static get watchers() { return {
@@ -320,140 +319,6 @@ const VerdocsSend = class {
320
319
  };
321
320
  VerdocsSend.style = VerdocsSendStyle0;
322
321
 
323
- const verdocsTemplateAttachmentsCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-attachments{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-attachments h5{font-size:16px;font-weight:bold;margin:0 0 10px 0;color:#46497d}verdocs-template-attachments .attachments{margin:0 0 40px 0}verdocs-template-attachments .attachment{display:-ms-flexbox;display:flex;padding:5px 0;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#33364b}verdocs-template-attachments .attachment:hover .trash-icon{display:-ms-flexbox;display:flex}verdocs-template-attachments .attachment:hover .pages{display:none}verdocs-template-attachments svg{width:28px;height:28px;fill:#5c6575;margin:2px 0 0 0}verdocs-template-attachments .file-icon{-ms-flex:0;flex:0}verdocs-template-attachments .pages{width:24px;height:24px;-ms-flex:0 0 24px;flex:0 0 24px;padding-left:4px;position:relative;margin:-10px 0 0 0}verdocs-template-attachments .pages .pages-icon{top:0;left:0;width:24px;height:24px;position:absolute}verdocs-template-attachments .pages .count{top:11px;left:7px;z-index:1;width:18px;font-size:12px;font-weight:500;position:absolute;text-align:center;letter-spacing:-2px}verdocs-template-attachments .filename{-ms-flex:1;flex:1;display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;border-bottom:1px dotted #cccccc}verdocs-template-attachments .trash-icon{-ms-flex:0;flex:0;display:none}verdocs-template-attachments .trash-icon:hover{cursor:pointer}verdocs-template-attachments verdocs-file-chooser{margin:10px 0;border:2px dashed #979797}verdocs-template-attachments .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .progress-wrapper{padding:20px}verdocs-template-attachments .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-attachments .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-attachments ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-moz-placeholder{color:#aaaaaa}verdocs-template-attachments :-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-attachments ::placeholder{color:#aaaaaa}";
324
- const VerdocsTemplateAttachmentsStyle0 = verdocsTemplateAttachmentsCss;
325
-
326
- const VerdocsTemplateAttachments = class {
327
- constructor(hostRef) {
328
- index.registerInstance(this, hostRef);
329
- this.exit = index.createEvent(this, "exit", 7);
330
- this.next = index.createEvent(this, "next", 7);
331
- this.templateUpdated = index.createEvent(this, "templateUpdated", 7);
332
- this.sdkError = index.createEvent(this, "sdkError", 7);
333
- this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
334
- this.templateId = '';
335
- this.uploading = false;
336
- this.progressLabel = 'Uploading...';
337
- this.progressPercent = 0;
338
- this.showDeleteError = false;
339
- this.confirmDeleteDocument = null;
340
- this.store = null;
341
- }
342
- async componentWillLoad() {
343
- var _a, _b, _c;
344
- try {
345
- this.endpoint.loadSession();
346
- if (!this.templateId) {
347
- console.log(`[ROLES] Missing required template ID ${this.templateId}`);
348
- return;
349
- }
350
- if (!this.endpoint.session) {
351
- console.log('[ROLES] Unable to start builder session, must be authenticated');
352
- return;
353
- }
354
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
355
- }
356
- catch (e) {
357
- console.log('[TEMPLATE ATTACHMENTS] Error loading template', e);
358
- (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
359
- }
360
- }
361
- handleCancel(e) {
362
- e.stopPropagation();
363
- this.exit.emit();
364
- }
365
- handleUploadProgress(percent) {
366
- if (percent >= 99) {
367
- this.progressPercent = 100;
368
- this.progressLabel = 'Processing...';
369
- }
370
- else {
371
- this.progressPercent = percent;
372
- }
373
- }
374
- async handleUpload(e) {
375
- var _a, _b, _c, _d;
376
- e.stopPropagation();
377
- const file = e.detail.file;
378
- if (!file) {
379
- return;
380
- }
381
- console.log('[ATTACHMENTS] Uploading...', file);
382
- this.uploading = true;
383
- this.progressLabel = 'Uploading...';
384
- try {
385
- const template = await jsSdk.createTemplateDocument(this.endpoint, this.templateId, file, this.handleUploadProgress.bind(this));
386
- console.log('[ATTACHMENTS] Created attachment', template);
387
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
388
- console.log('[ATTACHMENTS] Updated template', this.store.state);
389
- (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: this.store.state, event: 'attachments' });
390
- this.uploading = false;
391
- this.progressLabel = '';
392
- this.progressPercent = 0;
393
- }
394
- catch (e) {
395
- console.log('[ATTACHMENTS] Error creating template', e);
396
- (_b = this.sdkError) === null || _b === void 0 ? void 0 : _b.emit(new errors.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));
397
- this.uploading = false;
398
- }
399
- }
400
- handleNext(e) {
401
- var _a;
402
- e.stopPropagation();
403
- this.uploading = false;
404
- this.progressLabel = '';
405
- this.progressPercent = 0;
406
- (_a = this.next) === null || _a === void 0 ? void 0 : _a.emit({ template: this.store.state });
407
- }
408
- async confirmDelete() {
409
- await jsSdk.deleteTemplateDocument(this.endpoint, this.templateId, this.confirmDeleteDocument.id);
410
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
411
- console.log('[ATTACHMENTS] New template', this.store.state);
412
- this.confirmDeleteDocument = null;
413
- }
414
- async handleDelete(document) {
415
- var _a;
416
- if (((_a = this.store.state) === null || _a === void 0 ? void 0 : _a.documents.length) > 1) {
417
- this.confirmDeleteDocument = document;
418
- }
419
- else {
420
- this.showDeleteError = true;
421
- }
422
- }
423
- getFileIcon(document) {
424
- switch (document.mime) {
425
- case 'application/pdf':
426
- return Icons.PdfIcon;
427
- case 'image/jpeg':
428
- return Icons.JpgIcon;
429
- case 'image/png':
430
- return Icons.PngIcon;
431
- case 'application/msword':
432
- case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
433
- return Icons.DocIcon;
434
- }
435
- return Icons.FileIcon;
436
- }
437
- render() {
438
- var _a, _b, _c;
439
- if (!this.endpoint.session) {
440
- return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
441
- }
442
- const templateState = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state;
443
- if (!templateState.isLoaded) {
444
- return (index.h(index.Host, { class: "loading" }, index.h("verdocs-loader", null)));
445
- }
446
- // This is meant to be a companion for larger visual experiences so we just go blank on errors for now.
447
- if (!this.endpoint.session || !templateState.profile_id) {
448
- return index.h(index.Host, { class: "empty" });
449
- }
450
- return (index.h(index.Host, null, index.h("h5", null, "Existing Attachments"), index.h("div", { class: "attachments" }, (_b = this.store) === null || _b === void 0 ? void 0 : _b.state.documents.map(document => (index.h("div", { class: "attachment" }, index.h("div", { class: "file-icon", innerHTML: this.getFileIcon(document) }), index.h("div", { class: "filename", title: document.name }, document.name), index.h("div", { class: "pages" }, index.h("div", { class: "count" }, document.pages), index.h("div", { class: "pages-icon", innerHTML: Icons.PageCountIcon })), index.h("div", { class: "trash-icon", innerHTML: Icons.TrashIcon, onClick: () => this.handleDelete(document) }))))), index.h("h5", null, "Attach a New Document"), this.uploading ? (index.h("div", { class: "loader-wrapper" }, index.h("verdocs-loader", null), this.progressLabel && (index.h("div", { class: "progress-wrapper" }, index.h("verdocs-progress-bar", { showPercent: true, percent: this.progressPercent, label: this.progressLabel }))))) : (index.h("verdocs-file-chooser", { onFileSelected: e => this.handleUpload(e) })), index.h("div", { class: "buttons" }, index.h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: e => this.handleCancel(e), disabled: this.uploading }), index.h("verdocs-button", { label: "Next", size: "small", onClick: e => this.handleNext(e), disabled: !((_c = this.store) === null || _c === void 0 ? void 0 : _c.state.documents.length) || this.uploading })), this.showDeleteError && (index.h("verdocs-ok-dialog", { heading: "Unable to Delete Attachment", message: "Templates must contain at least one attachment.", onNext: () => (this.showDeleteError = false) })), this.confirmDeleteDocument && (index.h("verdocs-ok-dialog", { heading: "Delete this Attachment?", message: "This operation cannot be undone. All fields placed<br />on the deleted attachment will also be removed.", onNext: () => this.confirmDelete(), showCancel: true, onExit: () => {
451
- this.confirmDeleteDocument = null;
452
- } }))));
453
- }
454
- };
455
- VerdocsTemplateAttachments.style = VerdocsTemplateAttachmentsStyle0;
456
-
457
322
  const verdocsTemplateBuildTabsCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-build-tabs{-ms-flex:1;flex:1;gap:15px;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-build-tabs verdocs-button-panel svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-build-tabs verdocs-template-attachments,verdocs-template-build-tabs verdocs-template-roles{margin:20px}verdocs-template-build-tabs verdocs-template-fields{border-top:1px solid #777777}verdocs-template-build-tabs verdocs-template-attachments{padding:20px;background:#ffffff}verdocs-template-build-tabs verdocs-template-fields{width:100%}verdocs-template-build-tabs verdocs-preview{-ms-flex:1;flex:1}.template-details-panel .row{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:8px;margin:10px 0}.template-details-panel label{-ms-flex:0 0 70px;flex:0 0 70px}.template-details-panel .value{-ms-flex:1;flex:1;font-weight:300;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.template-details-panel .icon-button{cursor:pointer;opacity:0.8;-ms-flex:0;flex:0;width:18px;height:18px}.template-details-panel .icon-button svg{stroke:#000000;width:18px;height:18px}.template-details-panel .icon-button:hover{opacity:1}";
458
323
  const VerdocsTemplateBuildTabsStyle0 = verdocsTemplateBuildTabsCss;
459
324
 
@@ -465,21 +330,38 @@ const VerdocsTemplateBuildTabs = class {
465
330
  index.registerInstance(this, hostRef);
466
331
  this.sdkError = index.createEvent(this, "sdkError", 7);
467
332
  this.stepChanged = index.createEvent(this, "stepChanged", 7);
333
+ this.templateListenerId = null;
468
334
  this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
469
335
  this.templateId = null;
470
336
  this.step = 'preview';
471
- this.templateStore = null;
337
+ this.loading = true;
338
+ this.template = null;
339
+ }
340
+ disconnectedCallback() {
341
+ this.unlistenToTemplate();
342
+ }
343
+ async listenToTemplate() {
344
+ this.unlistenToTemplate();
345
+ Datastore.Store.subscribe('templates', this.templateId, () => jsSdk.getTemplate(this.endpoint, this.templateId), false, (template) => {
346
+ this.template = template;
347
+ this.loading = false;
348
+ });
349
+ }
350
+ unlistenToTemplate() {
351
+ if (this.templateListenerId) {
352
+ Datastore.Store.store.delListener(this.templateListenerId);
353
+ this.templateListenerId = null;
354
+ }
472
355
  }
473
356
  onTemplateIdChanged(newTemplateId) {
474
357
  console.log('[BUILD_TABS] Template ID changed', newTemplateId);
475
- this.loadTemplate(newTemplateId).catch((e) => console.log('Unknown Error', e));
358
+ this.listenToTemplate();
476
359
  }
477
360
  onStepChanged(newStep) {
478
361
  console.log('[BUILD_TABS] Step changed', newStep);
479
- this.loadTemplate(this.templateId).catch((e) => console.log('Unknown Error', e));
480
362
  }
481
363
  async componentWillLoad() {
482
- var _a, _b, _c, _d, _e, _f;
364
+ var _a, _b, _c;
483
365
  try {
484
366
  this.endpoint.loadSession();
485
367
  if (!this.endpoint.session) {
@@ -491,27 +373,16 @@ const VerdocsTemplateBuildTabs = class {
491
373
  console.log('[BUILD_TABS] Missing required template ID, forcing view to attachments');
492
374
  return;
493
375
  }
494
- try {
495
- this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
496
- }
497
- catch (e) {
498
- console.log('[BUILD_TABS] Error loading template', e);
499
- (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
500
- }
376
+ this.listenToTemplate();
501
377
  }
502
378
  catch (e) {
503
379
  console.log('[BUILD_TABS] Error loading template', e);
504
- (_d = this.sdkError) === null || _d === void 0 ? void 0 : _d.emit(new errors.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));
505
- }
506
- }
507
- async loadTemplate(templateId) {
508
- if (templateId) {
509
- this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, templateId, false);
380
+ (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
510
381
  }
511
382
  }
512
383
  setStep(e) {
513
384
  var _a;
514
- console.log('Selected step', e.detail.tab.id);
385
+ console.log('[BUILD_TABS] Selected step', e.detail.tab.id);
515
386
  e.stopPropagation();
516
387
  e.preventDefault();
517
388
  this.step = e.detail.tab.id;
@@ -530,18 +401,16 @@ const VerdocsTemplateBuildTabs = class {
530
401
  });
531
402
  }
532
403
  render() {
533
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
404
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
405
+ if (this.loading) {
406
+ return (index.h(index.Host, null, index.h("verdocs-loader", null)));
407
+ }
534
408
  if (!this.endpoint.session) {
535
409
  return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
536
410
  }
537
- let canPreview = false;
538
- let canEditFields = false;
539
- let canEditRoles = false;
540
- if (this.templateId && this.templateStore && this.templateStore.state) {
541
- canEditRoles = ((_c = (_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.documents) === null || _c === void 0 ? void 0 : _c.length) > 0;
542
- canEditFields = canEditRoles && ((_f = (_e = (_d = this.templateStore) === null || _d === void 0 ? void 0 : _d.state) === null || _e === void 0 ? void 0 : _e.roles) === null || _f === void 0 ? void 0 : _f.length) > 0;
543
- canPreview = canEditFields && ((_j = (_h = (_g = this.templateStore) === null || _g === void 0 ? void 0 : _g.state) === null || _h === void 0 ? void 0 : _h.fields) === null || _j === void 0 ? void 0 : _j.length) > 0;
544
- }
411
+ const canEditRoles = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.documents) || []).length > 0;
412
+ let canEditFields = canEditRoles && (((_b = this.template) === null || _b === void 0 ? void 0 : _b.roles) || []).length > 0;
413
+ const canPreview = canEditFields && (((_c = this.template) === null || _c === void 0 ? void 0 : _c.fields) || []).length > 0;
545
414
  let selectedStepIndex = Math.max(STEPS.indexOf(this.step), 0);
546
415
  if (!canPreview && selectedStepIndex >= 4) {
547
416
  selectedStepIndex = 3;
@@ -558,8 +427,8 @@ const VerdocsTemplateBuildTabs = class {
558
427
  { id: 'settings', disabled: !canEditFields, label: 'Settings' },
559
428
  { id: 'fields', disabled: !canEditFields, label: 'Fields' },
560
429
  { id: 'preview', disabled: !canPreview, label: 'Preview/Send' },
561
- ] }), this.templateId && (index.h("div", { class: "info" }, index.h("verdocs-button-panel", { icon: HelpIcon }, index.h("div", { class: "template-details-panel" }, index.h("h6", null, "Template Details"), index.h("div", { class: "row" }, index.h("label", null, "ID:"), index.h("div", { class: "value" }, this.templateId), index.h("div", { class: "icon-button", innerHTML: CopyIcon, onClick: () => this.copyTemplateId() })), index.h("div", { class: "row" }, index.h("label", null, "Name:"), index.h("div", { class: "value" }, (_l = (_k = this.templateStore) === null || _k === void 0 ? void 0 : _k.state) === null || _l === void 0 ? void 0 : _l.name)), index.h("div", { class: "row" }, index.h("label", null, "Visibility:"), index.h("div", { class: "value" }, ((_o = (_m = this.templateStore) === null || _m === void 0 ? void 0 : _m.state) === null || _o === void 0 ? void 0 : _o.is_public) ? 'Public' : ((_q = (_p = this.templateStore) === null || _p === void 0 ? void 0 : _p.state) === null || _q === void 0 ? void 0 : _q.is_personal) ? 'Private' : 'Shared')), index.h("div", { class: "row" }, index.h("label", null, "Created:"), index.h("div", { class: "value" }, ((_s = (_r = this.templateStore) === null || _r === void 0 ? void 0 : _r.state) === null || _s === void 0 ? void 0 : _s.counter) ? format.format(new Date((_u = (_t = this.templateStore) === null || _t === void 0 ? void 0 : _t.state) === null || _u === void 0 ? void 0 : _u.created_at), 'P p') : '')), index.h("div", { class: "row" }, index.h("label", null, "Used:"), index.h("div", { class: "value" }, (_w = (_v = this.templateStore) === null || _v === void 0 ? void 0 : _v.state) === null || _w === void 0 ? void 0 :
562
- _w.counter, " time(s)"))))))));
430
+ ] }), this.templateId && (index.h("div", { class: "info" }, index.h("verdocs-button-panel", { icon: HelpIcon }, index.h("div", { class: "template-details-panel" }, index.h("h6", null, "Template Details"), index.h("div", { class: "row" }, index.h("label", null, "ID:"), index.h("div", { class: "value" }, this.templateId), index.h("div", { class: "icon-button", innerHTML: CopyIcon, onClick: () => this.copyTemplateId() })), index.h("div", { class: "row" }, index.h("label", null, "Name:"), index.h("div", { class: "value" }, (_d = this.template) === null || _d === void 0 ? void 0 : _d.name)), index.h("div", { class: "row" }, index.h("label", null, "Visibility:"), index.h("div", { class: "value" }, ((_e = this.template) === null || _e === void 0 ? void 0 : _e.is_public) ? 'Public' : ((_f = this.template) === null || _f === void 0 ? void 0 : _f.is_personal) ? 'Private' : 'Shared')), index.h("div", { class: "row" }, index.h("label", null, "Created:"), index.h("div", { class: "value" }, ((_g = this.template) === null || _g === void 0 ? void 0 : _g.counter) ? format.format(new Date((_h = this.template) === null || _h === void 0 ? void 0 : _h.created_at), 'P p') : '')), index.h("div", { class: "row" }, index.h("label", null, "Used:"), index.h("div", { class: "value" }, (_j = this.template) === null || _j === void 0 ? void 0 :
431
+ _j.counter, " time(s)"))))))));
563
432
  }
564
433
  static get watchers() { return {
565
434
  "templateId": ["onTemplateIdChanged"],
@@ -568,112 +437,6 @@ const VerdocsTemplateBuildTabs = class {
568
437
  };
569
438
  VerdocsTemplateBuildTabs.style = VerdocsTemplateBuildTabsStyle0;
570
439
 
571
- const verdocsTemplateCreateCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-create{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-create form{background-color:#ffffff;padding:12px;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-create form .upload-box{-webkit-box-sizing:border-box;box-sizing:border-box;width:320px;text-align:center;padding:44px 18px 66px;border:2px dashed #979797;color:rgba(0, 0, 0, 0.54)}verdocs-template-create form .upload-box.drag-over{border:2px solid #4c56cb}verdocs-template-create form .upload-box svg{width:64px;fill:#5c6575}verdocs-template-create p{color:#33364b;margin-top:20px;font-size:18px;font-weight:500;overflow-wrap:anywhere}verdocs-template-create p.subscript{color:#5c6575;font-size:14px;margin:20px}verdocs-template-create .loader-wrapper{background-color:#ffffff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:320px;height:320px;text-align:center;border:2px dashed #979797;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .progress-wrapper{padding:20px}verdocs-template-create .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;-ms-flex-pack:end;justify-content:flex-end}verdocs-template-create .buttons .flex-fill{-ms-flex:1;flex:1}verdocs-template-create ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-create ::-moz-placeholder{color:#aaaaaa}verdocs-template-create :-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-create ::placeholder{color:#aaaaaa}verdocs-template-create .error{margin:20px 0;color:#cc0000}";
572
- const VerdocsTemplateCreateStyle0 = verdocsTemplateCreateCss;
573
-
574
- const FileIcon = '<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24"><path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"></path></svg>';
575
- const VerdocsTemplateCreate = class {
576
- constructor(hostRef) {
577
- index.registerInstance(this, hostRef);
578
- this.exit = index.createEvent(this, "exit", 7);
579
- this.next = index.createEvent(this, "next", 7);
580
- this.sdkError = index.createEvent(this, "sdkError", 7);
581
- this.templateCreated = index.createEvent(this, "templateCreated", 7);
582
- this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
583
- this.maxSize = 20.5 * 1024 * 1024;
584
- this.file = undefined;
585
- this.creating = false;
586
- this.progressLabel = 'Uploading...';
587
- this.progressPercent = 0;
588
- this.errorMessage = '';
589
- }
590
- componentWillLoad() {
591
- this.endpoint.setTimeout(30000);
592
- this.endpoint.loadSession();
593
- }
594
- handleFileChanged(e) {
595
- var _a;
596
- this.errorMessage = '';
597
- this.file = ((_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0]) || null;
598
- console.log('[CREATE] Selected file', this.file);
599
- const totalSize = this.file.size;
600
- if (totalSize > this.maxSize) {
601
- this.errorMessage = 'Total file size must not exceed 20MB.';
602
- }
603
- }
604
- handleUpload(e) {
605
- e.stopPropagation();
606
- const fileElem = document.getElementById('verdocs-template-create-file');
607
- fileElem.click();
608
- }
609
- handleCancel(e) {
610
- e.stopPropagation();
611
- this.exit.emit();
612
- }
613
- async handleSubmit(e) {
614
- var _a, _b, _c;
615
- e.stopPropagation();
616
- // Should be true if we're here because onClick is only enabled then. We're just guarding this for Typescript.
617
- if (!this.file) {
618
- return;
619
- }
620
- this.creating = true;
621
- this.progressLabel = 'Uploading...';
622
- try {
623
- const template = await jsSdk.createTemplate(this.endpoint, {
624
- name: this.file.name,
625
- // TODO: Make optional in the SDK
626
- initial_reminder: 0,
627
- followup_reminders: 0,
628
- documents: [this.file],
629
- }, percent => {
630
- if (percent >= 99) {
631
- this.progressLabel = 'Processing...';
632
- this.progressPercent = 100;
633
- }
634
- else {
635
- this.progressPercent = percent;
636
- }
637
- });
638
- console.log('[CREATE] Created template', template);
639
- TemplateStore.getTemplateStore(this.endpoint, template.id, true)
640
- .then(() => {
641
- var _a, _b;
642
- (_a = this.templateCreated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template, templateId: template.id });
643
- (_b = this.next) === null || _b === void 0 ? void 0 : _b.emit(template);
644
- this.creating = false;
645
- this.progressLabel = '';
646
- this.progressPercent = 0;
647
- })
648
- .catch(e => {
649
- console.log(e);
650
- });
651
- }
652
- catch (e) {
653
- console.log('[CREATE] Error creating template', e);
654
- (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
655
- this.creating = false;
656
- }
657
- }
658
- render() {
659
- if (!this.endpoint.session) {
660
- return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
661
- }
662
- return (index.h(index.Host, null, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("input", { type: "file", id: "verdocs-template-create-file", multiple: true, accept: ".pdf,application/pdf,.doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", style: { display: 'none' }, onChange: e => this.handleFileChanged(e) }), this.creating ? (index.h("div", { class: "loader-wrapper" }, index.h("verdocs-loader", null), this.progressLabel && (index.h("div", { class: "progress-wrapper" }, index.h("verdocs-progress-bar", { showPercent: true, percent: this.progressPercent, label: this.progressLabel }))))) : (index.h("div", { class: "upload-box", onDrop: (e) => {
663
- e.preventDefault();
664
- e.target.classList.remove('drag-over');
665
- this.file = e.dataTransfer.files[0];
666
- if (this.file.size > this.maxSize) {
667
- this.errorMessage = 'Total file size must not exceed 20MB.';
668
- }
669
- }, onDragOver: (e) => {
670
- e.preventDefault();
671
- e.dataTransfer.dropEffect = 'copy';
672
- }, onDragEnter: (e) => e.target.classList.add('drag-over'), onDragLeave: (e) => e.target.classList.remove('drag-over') }, index.h("span", { innerHTML: FileIcon, style: { display: 'flex', justifyContent: 'center' } }), index.h("p", null, this.file ? this.file.name : 'Drag and drop your files here'), index.h("p", { class: "subscript" }, "Supported files: PDF, Word"), index.h("verdocs-button", { label: this.file ? 'Select a different file' : 'Select a file from your computer', size: "small", onClick: e => this.handleUpload(e) }))), !!this.errorMessage && index.h("div", { class: "error" }, this.errorMessage), index.h("div", { class: "buttons" }, index.h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: e => this.handleCancel(e), disabled: this.creating }), index.h("verdocs-button", { label: "Next", size: "small", onClick: e => this.handleSubmit(e), disabled: !this.file || this.creating || !!this.errorMessage })))));
673
- }
674
- };
675
- VerdocsTemplateCreate.style = VerdocsTemplateCreateStyle0;
676
-
677
440
  const verdocsTemplateFieldsCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-fields{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif;position:relative;display:block;min-height:600px}verdocs-template-fields .page-0{padding:65px 15px 0 15px;-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields .page-0 .user-placed-fields{height:100px;position:relative;background:#ffffff;-webkit-box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294);box-shadow:0 0 10px 5px rgba(0, 0, 0, 0.0588235294)}verdocs-template-fields .page-0 .user-placed-fields .title{top:0;left:0;color:#ffffff;font-size:12px;padding:3px 6px;font-weight:bold;position:absolute;background:#46497d}verdocs-template-fields .pages{display:-ms-flexbox;display:flex;padding:15px;row-gap:15px;min-height:200px;position:relative;-ms-flex-align:center;align-items:center;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-direction:column;flex-direction:column}verdocs-template-fields .pages div,verdocs-template-fields .pages canvas{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-template-fields #verdocs-template-fields-toolbar{height:50px;display:-ms-flexbox;display:flex;-webkit-column-gap:15px;-moz-column-gap:15px;column-gap:15px;font-weight:700;padding:0 20px 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;color:#f5f5fa;-ms-flex-pack:center;justify-content:center;background:#46497d}verdocs-template-fields #verdocs-template-fields-toolbar>verdocs-select-input{margin:0}verdocs-template-fields #verdocs-template-fields-toolbar svg{width:24px;height:24px}verdocs-template-fields #verdocs-template-fields-toolbar .add-for{margin:0;font-weight:500;color:#f5f5fa}verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{margin:0 20px 0 0}@media all and (max-width: 1000px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;padding:0 10px 0 0}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.8);transform:scale(0.8)}verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}@media all and (max-width: 600px){verdocs-template-fields #verdocs-template-fields-toolbar{-webkit-column-gap:6px;-moz-column-gap:6px;column-gap:6px}verdocs-template-fields #verdocs-template-fields-toolbar svg{-webkit-transform:scale(0.6);transform:scale(0.6)}verdocs-template-fields #verdocs-template-fields-toolbar .separator,verdocs-template-fields #verdocs-template-fields-toolbar .add-for,verdocs-template-fields #verdocs-template-fields-toolbar verdocs-select-input{display:none}}verdocs-template-fields.placing-attachment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-checkbox{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-date{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath fill='%23000000' d='M7.6 13.925q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375Zm4.4 0q-.55 0-.925-.375t-.375-.925q0-.55.375-.937.375-.388.925-.388t.925.388q.375.387.375.937t-.375.925q-.375.375-.925.375ZM5.3 22.85q-1.325 0-2.238-.912-.912-.913-.912-2.238V6.3q0-1.325.912-2.238.913-.912 2.238-.912H6v-2h2.575v2h6.85v-2H18v2h.7q1.325 0 2.238.912.912.913.912 2.238v13.4q0 1.325-.912 2.238-.913.912-2.238.912Zm0-3.15h13.4V10H5.3v9.7ZM5.3 8h13.4V6.3H5.3Zm0 0V6.3 8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-dropdown{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24' stroke-width='1.5' stroke='currentColor'%3E%3Cpath stroke='%23000000' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25' /%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-initial{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M6.225 20.775V7h-5V3.225H15V7h-5v13.775Zm9.775 0v-8h-3V9h9.775v3.775h-3v8Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-payment{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m10.55 16.55 7.275-7.275L16.05 7.5l-5.5 5.45-2.675-2.65L6.1 12.075Zm-5.375 4.925q-1.125 0-1.887-.763-.763-.762-.763-1.887V5.175q0-1.125.763-1.888.762-.762 1.887-.762h13.65q1.125 0 1.888.762.762.763.762 1.888v13.65q0 1.125-.762 1.887-.763.763-1.888.763Zm0-2.65h13.65V5.175H5.175v13.65Zm0-13.65v13.65-13.65Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-radio{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M12 17q2.075 0 3.538-1.463Q17 14.075 17 12t-1.462-3.538Q14.075 7 12 7 9.925 7 8.463 8.462 7 9.925 7 12q0 2.075 1.463 3.537Q9.925 17 12 17Zm0 5.85q-2.275 0-4.25-.85t-3.438-2.312Q2.85 18.225 2 16.25q-.85-1.975-.85-4.25T2 7.75q.85-1.975 2.312-3.438Q5.775 2.85 7.75 2q1.975-.85 4.25-.85t4.25.85q1.975.85 3.438 2.312Q21.15 5.775 22 7.75q.85 1.975.85 4.25T22 16.25q-.85 1.975-2.312 3.438Q18.225 21.15 16.25 22q-1.975.85-4.25.85Zm0-3.15q3.25 0 5.475-2.225Q19.7 15.25 19.7 12q0-3.25-2.225-5.475Q15.25 4.3 12 4.3q-3.25 0-5.475 2.225Q4.3 8.75 4.3 12q0 3.25 2.225 5.475Q8.75 19.7 12 19.7Zm0-7.7Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-signature{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='m9.225 21.225 4.65-4.65h8.45v4.65Zm-5.35-2.2H5.05l8.5-8.5-1.175-1.175-8.5 8.5Zm14.25-9.95L13.8 4.8l1.325-1.325q.625-.65 1.525-.663.9-.012 1.6.663l1.225 1.175q.675.675.663 1.562-.013.888-.663 1.513ZM16.7 10.55 6 21.225H1.675V16.9L12.35 6.225Zm-3.725-.625-.6-.575 1.175 1.175Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textarea{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath d='M3.225 20.725v-3.15h11.55v3.15Zm0-4.775V12.8h17.55v3.15Zm0-4.75V8.05h17.55v3.15Zm0-4.775v-3.15h17.55v3.15Z'/%3E%3C/svg%3E\") 16 16, pointer}verdocs-template-fields.placing-textbox{cursor:url(\"data:image/svg+xml,%3Csvg width='32' height='15' viewBox='0 0 32 15' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cmask id='path-1-inside-1_1401_24' fill='white'%3E%3Cpath d='M0 0H32V15H0V0Z'/%3E%3C/mask%3E%3Cpath d='M0 0H32V15H0V0Z' fill='%234C56CB' fill-opacity='0.1'/%3E%3Cpath d='M0 0V-1H-1V0H0ZM0 15H-1V16H0V15ZM0 1H32V-1H0V1ZM32 14H0V16H32V14ZM1 15V0H-1V15H1Z' fill='%234C56CB' mask='url(%23path-1-inside-1_1401_24)'/%3E%3Cpath d='M3 11.8V8.65H14.15V11.8H3ZM3 6.65V3.5H20.15V6.65H3Z' fill='%234C56CB'/%3E%3Cline x1='31.5' y1='1' x2='31.5' y2='14' stroke='%234C56CB' stroke-opacity='0.32' stroke-dasharray='1 1'/%3E%3C/svg%3E%0A\") 0 14, pointer}verdocs-template-fields.placing-timestamp{cursor:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' width='24'%3E%3Cpath fill='%23000000' d='M9 1h6v2H9zm10.03 6.39 1.42-1.42c-.43-.51-.9-.99-1.41-1.41l-1.42 1.42C16.07 4.74 14.12 4 12 4c-4.97 0-9 4.03-9 9s4.02 9 9 9 9-4.03 9-9c0-2.12-.74-4.07-1.97-5.61zM13 14h-2V8h2v6z'%3E%3C/path%3E%3C/svg%3E\") 16 16, pointer}";
678
441
  const VerdocsTemplateFieldsStyle0 = verdocsTemplateFieldsCss;
679
442
 
@@ -708,10 +471,8 @@ const VerdocsTemplateFields = class {
708
471
  this.sdkError = index.createEvent(this, "sdkError", 7);
709
472
  this.templateUpdated = index.createEvent(this, "templateUpdated", 7);
710
473
  this.fieldsUpdated = index.createEvent(this, "fieldsUpdated", 7);
474
+ this.templateListenerId = null;
711
475
  this.pageHeights = {};
712
- this.templateStore = null;
713
- this.fieldStore = null;
714
- this.roleStore = null;
715
476
  this.cachedPageInfo = {};
716
477
  this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
717
478
  this.templateId = null;
@@ -720,9 +481,10 @@ const VerdocsTemplateFields = class {
720
481
  this.showMustSelectRole = false;
721
482
  this.selectedRoleName = '';
722
483
  this.loading = true;
484
+ this.template = null;
723
485
  }
724
- onTemplateIdChanged(newTemplateId) {
725
- this.loadTemplate(newTemplateId).catch((e) => console.log('Unknown Error', e));
486
+ onTemplateIdChanged() {
487
+ this.listenToTemplate();
726
488
  }
727
489
  // Stop field-placement mode if ESC is pressed
728
490
  handleKeyDown(ev) {
@@ -731,7 +493,7 @@ const VerdocsTemplateFields = class {
731
493
  }
732
494
  }
733
495
  async componentWillLoad() {
734
- var _a, _b, _c, _d, _e, _f;
496
+ var _a, _b, _c;
735
497
  try {
736
498
  this.endpoint.loadSession();
737
499
  if (!this.templateId) {
@@ -742,17 +504,11 @@ const VerdocsTemplateFields = class {
742
504
  console.log('[FIELDS] Unable to start builder session, must be authenticated');
743
505
  return;
744
506
  }
745
- try {
746
- this.loadTemplate(this.templateId).catch(e => console.log('[BUILD] Unable to load template', e));
747
- }
748
- catch (e) {
749
- console.log('[FIELDS] Error loading template', e);
750
- (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
751
- }
507
+ this.listenToTemplate();
752
508
  }
753
509
  catch (e) {
754
510
  console.log('[FIELDS] Error with fields session', e);
755
- (_d = this.sdkError) === null || _d === void 0 ? void 0 : _d.emit(new errors.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));
511
+ (_a = this.sdkError) === null || _a === void 0 ? void 0 : _a.emit(new errors.SDKError(e.message, (_b = e.response) === null || _b === void 0 ? void 0 : _b.status, (_c = e.response) === null || _c === void 0 ? void 0 : _c.data));
756
512
  }
757
513
  }
758
514
  componentDidRender() {
@@ -768,35 +524,40 @@ const VerdocsTemplateFields = class {
768
524
  componentWillUpdate() {
769
525
  var _a, _b;
770
526
  // If a new role was added and there were none yet so far, or the "selected" role was deleted, reset our selection
771
- const roles = ((_a = this.roleStore) === null || _a === void 0 ? void 0 : _a.get('roles')) || [];
527
+ const roles = ((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || [];
772
528
  if (!this.selectedRoleName || !roles.find(role => role && role.name === this.selectedRoleName)) {
773
529
  this.selectedRoleName = ((_b = roles[0]) === null || _b === void 0 ? void 0 : _b.name) || '';
774
530
  console.log('[FIELDS] Selected new role', this.selectedRoleName);
775
531
  }
776
532
  }
777
- async loadTemplate(templateId) {
778
- var _a, _b;
779
- if (templateId) {
780
- this.loading = true;
781
- this.templateStore = await TemplateStore.getTemplateStore(this.endpoint, templateId, false);
782
- this.roleStore = TemplateRoleStore.getTemplateRoleStore(this.templateId);
783
- this.fieldStore = TemplateFieldStore.getTemplateFieldStore(this.templateId);
784
- this.selectedRoleName = ((_b = (_a = this.roleStore.get('roles')) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) || '';
533
+ disconnectedCallback() {
534
+ this.unlistenToTemplate();
535
+ }
536
+ async listenToTemplate() {
537
+ this.unlistenToTemplate();
538
+ Datastore.Store.subscribe('templates', this.templateId, () => jsSdk.getTemplate(this.endpoint, this.templateId), false, (template) => {
539
+ var _a, _b;
540
+ this.template = template;
785
541
  this.loading = false;
786
- // TODO: Necessary?
787
- // this.fieldsUpdated?.emit({event: 'updated', endpoint: this.endpoint, templateId: this.templateId, fields});
542
+ this.selectedRoleName = ((_b = (_a = template.roles) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.name) || '';
543
+ });
544
+ }
545
+ unlistenToTemplate() {
546
+ if (this.templateListenerId) {
547
+ Datastore.Store.store.delListener(this.templateListenerId);
548
+ this.templateListenerId = null;
788
549
  }
789
550
  }
790
551
  attachFieldAttributes(pageInfo, field, el) {
791
552
  // el.addEventListener('input', e => this.handleFieldChange(field, e));
792
553
  el.addEventListener('settingsChanged', () => {
793
- var _a, _b;
794
- (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state, event: 'added-field' });
554
+ var _a;
555
+ (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: this.template, event: 'added-field' });
795
556
  });
796
557
  el.addEventListener('deleted', () => {
797
- var _a, _b;
558
+ var _a;
798
559
  el.remove();
799
- (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state, event: 'updated-field' });
560
+ (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: this.template, event: 'updated-field' });
800
561
  });
801
562
  el.setAttribute('templateid', this.templateId);
802
563
  el.setAttribute('fieldname', field.name);
@@ -806,12 +567,12 @@ const VerdocsTemplateFields = class {
806
567
  el.setAttribute('name', field.name);
807
568
  }
808
569
  handlePageRendered(e) {
570
+ var _a;
809
571
  const pageInfo = e.detail;
810
572
  // console.log('[FIELDS] Page rendered', pageInfo.pageNumber, pageInfo.xScale, pageInfo.yScale);
811
573
  this.cachedPageInfo[pageInfo.pageNumber] = pageInfo;
812
574
  this.pageHeights[pageInfo.pageNumber] = pageInfo.naturalHeight;
813
- this.fieldStore
814
- .get('fields')
575
+ (((_a = this.template) === null || _a === void 0 ? void 0 : _a.fields) || [])
815
576
  .filter(field => field && field.page === pageInfo.pageNumber)
816
577
  .forEach(field => {
817
578
  const id = utils.getFieldId(field);
@@ -843,10 +604,9 @@ const VerdocsTemplateFields = class {
843
604
  utils.updateCssTransform(event.target, 'translate', `${newX}px, ${newY}px`);
844
605
  }
845
606
  async handleMoveEnd(event) {
846
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
607
+ var _a, _b, _c, _d, _e, _f, _g, _h;
847
608
  const name = event.target.getAttribute('fieldname');
848
- const option = +(event.target.getAttribute('option') || '0');
849
- const field = this.fieldStore.get('fields').find(field => field.name === name);
609
+ const field = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.fields) || []).find(field => field.name === name);
850
610
  if (!field) {
851
611
  console.log('[FIELDS] Unable to find field', name, event.target);
852
612
  return;
@@ -862,10 +622,9 @@ const VerdocsTemplateFields = class {
862
622
  // (positive displacement) while bottom measures "up" from the bottom (negative displacement).
863
623
  const newX = Math.max(clientRect.left - parentRect.left, 0);
864
624
  let newY = Math.max(renderedHeight - (parentRect.bottom - clientRect.bottom), 0);
865
- console.log('drop', { pageNumber, newX, newY });
866
625
  let newPageNumber = parseInt(pageNumber);
867
626
  if (newY > renderedHeight) {
868
- newPageNumber = Math.min(newPageNumber + 1, ((_d = (_c = (_b = (_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.documents) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.pages) || 1);
627
+ newPageNumber = Math.min(newPageNumber + 1, ((_d = (_c = (((_b = this.template) === null || _b === void 0 ? void 0 : _b.documents) || [])) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.pages) || 1);
869
628
  newY -= renderedHeight;
870
629
  renderedHeight = this.cachedPageInfo[newPageNumber].renderedHeight;
871
630
  console.log('Next page', { newPageNumber, newY, renderedHeight });
@@ -874,39 +633,43 @@ const VerdocsTemplateFields = class {
874
633
  newPageNumber = Math.max(newPageNumber - 1, 1);
875
634
  renderedHeight = this.cachedPageInfo[newPageNumber].renderedHeight;
876
635
  newY += renderedHeight;
877
- console.log('Next page', { newPageNumber, newY, renderedHeight });
636
+ console.log('[FIELDS] Next page', { newPageNumber, newY, renderedHeight });
878
637
  }
879
638
  const { x, y } = this.viewCoordinatesToPageCoordinates(newX, newY, pageNumber, naturalWidth - width, naturalHeight - height);
880
639
  try {
881
640
  const params = { x, y, page: newPageNumber };
882
- console.log('[FIELDS] Will update', name, y, option, params);
883
- const newFieldData = await jsSdk.updateField(this.endpoint, this.templateId, name, params);
884
- console.log('[FIELDS] Updated', newFieldData);
885
- TemplateFieldStore.updateStoreField(this.fieldStore, name, newFieldData);
886
- console.log('a');
641
+ const updatedField = await jsSdk.updateField(this.endpoint, this.templateId, name, params);
642
+ console.log('[FIELDS] Updated', updatedField);
643
+ const newTemplate = JSON.parse(JSON.stringify(this.template));
644
+ const fieldIndex = newTemplate.fields.findIndex(field => field.name === name);
645
+ if (fieldIndex > -1) {
646
+ newTemplate.fields[fieldIndex] = updatedField;
647
+ }
648
+ Datastore.Store.updateTemplate(this.templateId, newTemplate);
887
649
  event.target.removeAttribute('posX');
888
650
  event.target.removeAttribute('posY');
889
651
  utils.removeCssTransform(event.target);
890
- console.log('b');
891
- (_e = this.templateUpdated) === null || _e === void 0 ? void 0 : _e.emit({ endpoint: this.endpoint, template: (_f = this.templateStore) === null || _f === void 0 ? void 0 : _f.state, event: 'updated-field' });
892
- console.log('c');
652
+ const { xScale = 1, yScale = 1 } = this.cachedPageInfo[pageNumber];
653
+ utils.setControlStyles(event.target, updatedField, xScale, yScale);
654
+ (_e = this.templateUpdated) === null || _e === void 0 ? void 0 : _e.emit({ endpoint: this.endpoint, template: newTemplate, event: 'updated-field' });
893
655
  }
894
656
  catch (e) {
895
657
  Toast.VerdocsToast('Error updating field, please try again later', { style: 'error' });
896
658
  console.log('[FIELDS] Error updating field', e);
897
- (_g = this.sdkError) === null || _g === void 0 ? void 0 : _g.emit(new errors.SDKError(e.message, (_h = e.response) === null || _h === void 0 ? void 0 : _h.status, (_j = e.response) === null || _j === void 0 ? void 0 : _j.data));
659
+ (_f = this.sdkError) === null || _f === void 0 ? void 0 : _f.emit(new errors.SDKError(e.message, (_g = e.response) === null || _g === void 0 ? void 0 : _g.status, (_h = e.response) === null || _h === void 0 ? void 0 : _h.data));
898
660
  event.target.removeAttribute('posX');
899
661
  event.target.removeAttribute('posY');
900
662
  utils.removeCssTransform(event.target);
901
663
  }
902
664
  }
903
665
  generateFieldName(type, pageNumber) {
666
+ var _a;
904
667
  let i = 1;
905
668
  let fieldName;
906
669
  do {
907
670
  fieldName = `${type}P${pageNumber}-${i}`;
908
671
  i++;
909
- } while (this.fieldStore.get('fields').some(field => field && field.name === fieldName));
672
+ } while ((((_a = this.template) === null || _a === void 0 ? void 0 : _a.fields) || []).some(field => field && field.name === fieldName));
910
673
  return fieldName;
911
674
  }
912
675
  // Scale the X,Y clicks to the virtual page dimensions. Also ensure the field doesn't go off the page.
@@ -917,7 +680,7 @@ const VerdocsTemplateFields = class {
917
680
  return { x, y };
918
681
  }
919
682
  async handleClickPage(e, pageNumber) {
920
- var _a, _b;
683
+ var _a;
921
684
  if (this.placing) {
922
685
  const clickedX = e.offsetX;
923
686
  const clickedY = e.offsetY;
@@ -950,22 +713,24 @@ const VerdocsTemplateFields = class {
950
713
  options: this.placing === 'radio' ? [{ id: 'option-1', label: 'Option 1' }] : [],
951
714
  };
952
715
  console.log('[FIELDS] Will save new field', field);
953
- const saved = await jsSdk.createField(this.endpoint, this.templateId, field);
954
- console.log('[FIELDS] Saved field', saved);
955
- this.fieldStore.set('fields', [...this.fieldStore.get('fields'), saved]);
716
+ const newField = await jsSdk.createField(this.endpoint, this.templateId, field);
717
+ console.log('[FIELDS] Saved field', newField);
718
+ const newTemplate = JSON.parse(JSON.stringify(this.template));
719
+ newTemplate.fields.push(newField);
720
+ Datastore.Store.updateTemplate(this.templateId, newTemplate);
721
+ (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: newTemplate, event: 'added-field' });
956
722
  this.placing = null;
957
- (_a = this.templateUpdated) === null || _a === void 0 ? void 0 : _a.emit({ endpoint: this.endpoint, template: (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state, event: 'added-field' });
958
723
  }
959
724
  }
960
725
  render() {
961
726
  var _a, _b, _c;
727
+ if (this.loading) {
728
+ return (index.h(index.Host, null, index.h("verdocs-loader", null)));
729
+ }
962
730
  if (!this.endpoint.session) {
963
731
  return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
964
732
  }
965
- if (this.loading || !((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
966
- return (index.h(index.Host, null, index.h("verdocs-loader", null)));
967
- }
968
- const selectableRoles = this.roleStore.get('roles').map(role => ({ value: role.name, label: role.full_name ? `${role.name}: ${role.full_name}` : role.name }));
733
+ const selectableRoles = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).map(role => ({ value: role.name, label: role.full_name ? `${role.name}: ${role.full_name}` : role.name }));
969
734
  return (index.h(index.Host, { class: this.placing ? { [`placing-${this.placing}`]: true } : {}, onSubmit: () => { } }, index.h("div", { id: "verdocs-template-fields-toolbar" }, index.h("div", { class: "add-for" }, "Add field:"), index.h("verdocs-select-input", { value: this.selectedRoleName, options: selectableRoles, onInput: (e) => (this.selectedRoleName = e.target.value) }), menuOptions.map(option => (index.h("verdocs-toolbar-icon", { text: option.tooltip, icon: option.icon, class: option.class, onClick: () => {
970
735
  // We ignore empty-tooltip entries because they're separators
971
736
  if (option.tooltip) {
@@ -977,7 +742,7 @@ const VerdocsTemplateFields = class {
977
742
  this.showMustSelectRole = true;
978
743
  }
979
744
  }
980
- } })))), index.h("div", { class: "pages" }, (((_c = (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.documents) || []).map(document => {
745
+ } })))), index.h("div", { class: "pages" }, (((_b = this.template) === null || _b === void 0 ? void 0 : _b.documents) || []).map(document => {
981
746
  const pageNumbers = jsSdk.integerSequence(1, document.pages);
982
747
  return pageNumbers.map(page => {
983
748
  const pageSize = document.page_sizes[page];
@@ -986,7 +751,7 @@ const VerdocsTemplateFields = class {
986
751
  { name: 'controls', type: 'div' },
987
752
  ] }));
988
753
  });
989
- })), this.showMustSelectRole && (index.h("verdocs-ok-dialog", { heading: "Unable to add field", message: this.roleStore.get('roles').length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
754
+ })), this.showMustSelectRole && (index.h("verdocs-ok-dialog", { heading: "Unable to add field", message: (((_c = this.template) === null || _c === void 0 ? void 0 : _c.roles) || []).length > 0 ? 'Please select a role before adding fields.' : 'Please add at least one role before adding fields.', onNext: () => (this.showMustSelectRole = false) }))));
990
755
  }
991
756
  static get watchers() { return {
992
757
  "templateId": ["onTemplateIdChanged"]
@@ -994,85 +759,13 @@ const VerdocsTemplateFields = class {
994
759
  };
995
760
  VerdocsTemplateFields.style = VerdocsTemplateFieldsStyle0;
996
761
 
997
- const verdocsTemplateNameCss = "";
998
- const VerdocsTemplateNameStyle0 = verdocsTemplateNameCss;
999
-
1000
- const VerdocsTemplateName = class {
1001
- constructor(hostRef) {
1002
- index.registerInstance(this, hostRef);
1003
- this.close = index.createEvent(this, "close", 7);
1004
- this.sdkError = index.createEvent(this, "sdkError", 7);
1005
- this.templateUpdated = index.createEvent(this, "templateUpdated", 7);
1006
- this.store = null;
1007
- this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
1008
- this.templateId = '';
1009
- this.name = '';
1010
- this.dirty = false;
1011
- }
1012
- async componentWillLoad() {
1013
- var _a, _b, _c, _d, _e;
1014
- try {
1015
- this.endpoint.loadSession();
1016
- if (!this.templateId) {
1017
- console.log(`[ROLES] Missing required template ID ${this.templateId}`);
1018
- return;
1019
- }
1020
- if (!this.endpoint.session) {
1021
- console.log('[ROLES] Unable to start builder session, must be authenticated');
1022
- return;
1023
- }
1024
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
1025
- this.name = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.name;
1026
- this.dirty = false;
1027
- }
1028
- catch (e) {
1029
- console.log('[TEMPLATE NAME] Error loading template', e);
1030
- (_c = this.sdkError) === null || _c === void 0 ? void 0 : _c.emit(new errors.SDKError(e.message, (_d = e.response) === null || _d === void 0 ? void 0 : _d.status, (_e = e.response) === null || _e === void 0 ? void 0 : _e.data));
1031
- }
1032
- }
1033
- handleCancel(e) {
1034
- var _a, _b, _c;
1035
- e.stopPropagation();
1036
- this.name = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.name;
1037
- this.dirty = false;
1038
- console.log('Closing');
1039
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
1040
- }
1041
- async handleSave(e) {
1042
- var _a, _b, _c;
1043
- e.stopPropagation();
1044
- await jsSdk.updateTemplate(this.endpoint, this.templateId, { name: this.name });
1045
- if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state) {
1046
- this.store.state.name = this.name;
1047
- }
1048
- this.dirty = false;
1049
- (_b = this.templateUpdated) === null || _b === void 0 ? void 0 : _b.emit({ endpoint: this.endpoint, template: this.store.state, event: 'name' });
1050
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
1051
- }
1052
- render() {
1053
- var _a, _b;
1054
- if (!this.endpoint.session) {
1055
- return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
1056
- }
1057
- if ((_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.isLoading) {
1058
- return (index.h(index.Host, { class: "loading" }, index.h("verdocs-loader", null)));
1059
- }
1060
- return (index.h(index.Host, null, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("label", { htmlFor: "verdocs-template-name" }, "Template Name"), index.h("verdocs-text-input", { id: "verdocs-template-name", value: this.name, autocomplete: "off", placeholder: "Template Name...", onInput: (e) => {
1061
- var _a, _b;
1062
- this.name = e.target.value;
1063
- this.dirty = this.name !== ((_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.name);
1064
- } }), index.h("div", { class: "buttons" }, index.h("verdocs-button", { size: "small", variant: "outline", label: "Cancel", disabled: !this.dirty, onClick: e => this.handleCancel(e) }), index.h("verdocs-button", { size: "small", label: "Save", disabled: !this.dirty, onClick: e => this.handleSave(e) })))));
1065
- }
1066
- };
1067
- VerdocsTemplateName.style = VerdocsTemplateNameStyle0;
1068
-
1069
762
  const verdocsTemplateRolesCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-roles{display:block;min-width:400px;font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-roles>form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;background-color:#ffffff;padding:12px}verdocs-template-roles>form h5{font-size:16px;font-weight:bold;color:#46497d;margin:0 0 10px 0}verdocs-template-roles>form .participants{position:relative}verdocs-template-roles>form .left-line{top:32px;left:11px;z-index:1;width:12px;bottom:30px;position:absolute;background:#ffffff;border-left:3px dotted #9b9b9b}verdocs-template-roles>form .row{display:-ms-flexbox;display:flex;-webkit-column-gap:0;-moz-column-gap:0;column-gap:0;min-height:35px;margin-top:0;margin-left:40px;position:relative;-ms-flex-direction:row;flex-direction:row;padding:6px 0 4px 0}verdocs-template-roles>form .row .row-roles{-ms-flex:1;flex:1;gap:10px;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-direction:row;flex-direction:row}verdocs-template-roles>form .row .icon{top:14px;z-index:2;left:-40px;width:24px;height:24px;position:absolute;background:#ffffff}verdocs-template-roles>form .row .sender{height:30px;display:-ms-flexbox;display:flex;font-size:14px;line-height:30px;-ms-flex-align:center;align-items:center;border-radius:30px;-ms-flex-direction:row;flex-direction:row;padding:0 15px 0 15px;border:1px solid #c6c9cc;background-color:#f5f5fa}verdocs-template-roles>form .row .complete{height:30px;display:-ms-flexbox;display:flex;font-size:14px;padding:0 15px;line-height:30px;-ms-flex-direction:row;flex-direction:row;border-radius:30px;background-color:#f5f5fa;border:1px solid #aeb4bf}verdocs-template-roles>form .row .label{font-weight:bold;margin-right:6px;color:#33364b}verdocs-template-roles>form .row .settings-button{display:-ms-flexbox;display:flex;cursor:pointer;margin:0 0 0 9px}verdocs-template-roles>form .row .recipient{height:30px;display:-ms-flexbox;display:flex;font-size:14px;border-radius:30px;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row;padding:0 5px 0 6px;white-space:nowrap;border:2px solid #aeb4bf}verdocs-template-roles>form .row .recipient .type-icon{width:24px;height:24px;-webkit-transform:scale(0.8);transform:scale(0.8);opacity:0.6;margin:0 12px 0 0}verdocs-template-roles>form .row .recipient.dragging{position:absolute}verdocs-template-roles>form .row .recipient.dragging+.dropzone{display:none !important}verdocs-template-roles>form .row .dropzone{width:14px;height:30px;display:none}verdocs-template-roles>form .row .dropzone svg{fill:#cccccc}verdocs-template-roles>form .row .dropzone.visible{margin:0 7px;display:-ms-flexbox;display:flex;-ms-flex:0 0 14px;flex:0 0 14px}verdocs-template-roles>form .row .dropzone.active{-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;background:rgba(101, 77, 203, 0.4980392157);border:1px dashed #654dcb}verdocs-template-roles>form label{display:block;font-size:14px;font-weight:500;margin:0 0 4px 0;color:#5c6575}verdocs-template-roles>form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-roles>form input:focus{outline:none}verdocs-template-roles .row.add-sequence{display:none}verdocs-template-roles .add-role{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-roles .add-role:hover{opacity:1}verdocs-template-roles .add-role svg{width:32px;height:32px}verdocs-template-roles .add-step{margin:0;padding:0;border:none;opacity:0.5;cursor:pointer;background:none}verdocs-template-roles .add-step:hover{opacity:1}verdocs-template-roles .add-step svg{width:32px;height:32px}verdocs-template-roles.dragging .add-role{display:none}verdocs-template-roles.dragging form .row .recipient+.dropzone{display:-ms-flexbox;display:flex}verdocs-template-roles.dragging .row.add-sequence{display:-ms-flexbox;display:flex}verdocs-template-roles.dragging .row.add-sequence .dropzone{opacity:0.5;-ms-flex:0 0 120px;flex:0 0 120px;border-radius:30px;-ms-flex-align:center;align-items:center;background:rgba(101, 77, 203, 0.4980392157);-ms-flex-pack:center;justify-content:center;border:1px dashed #654dcb}verdocs-template-roles.dragging .row.add-sequence .dropzone.active{opacity:1}verdocs-template-roles .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:16px;-ms-flex-direction:row;flex-direction:row}verdocs-template-roles .empty{font-size:13px;margin-top:15px;margin-bottom:5px}verdocs-template-roles .empty svg{width:16px;height:16px;stroke:#666666;margin-bottom:2px;display:inline-block}verdocs-template-roles ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-roles ::-moz-placeholder{color:#aaaaaa}verdocs-template-roles :-ms-input-placeholder{color:#aaaaaa}verdocs-template-roles ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-roles ::placeholder{color:#aaaaaa}";
1070
763
  const VerdocsTemplateRolesStyle0 = verdocsTemplateRolesCss;
1071
764
 
1072
- const senderLabels = {
1073
- template_owner: 'Template Owner',
1074
- envelope_creator: 'Envelope Creator',
1075
- };
765
+ // const senderLabels: Record<TTemplateSender, string> = {
766
+ // template_owner: 'Template Owner',
767
+ // envelope_creator: 'Envelope Creator',
768
+ // };
1076
769
  const settingsIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="20" width="20" fill="#00000089"><path d="m8.021 17.917-.313-2.5q-.27-.125-.625-.334-.354-.208-.625-.395l-2.312.979-1.979-3.438 1.979-1.5q-.021-.167-.031-.364-.011-.198-.011-.365 0-.146.011-.344.01-.198.031-.385l-1.979-1.5 1.979-3.417 2.312.958q.271-.187.615-.385t.635-.344l.313-2.5h3.958l.313 2.5q.312.167.625.344.312.177.604.385l2.333-.958 1.979 3.417-1.979 1.521q.021.187.021.364V10q0 .146-.01.333-.011.188-.011.396l1.958 1.5-1.979 3.438-2.312-.979q-.292.208-.615.395-.323.188-.614.334l-.313 2.5Zm1.937-5.355q1.063 0 1.813-.75t.75-1.812q0-1.062-.75-1.812t-1.813-.75q-1.041 0-1.802.75-.76.75-.76 1.812t.76 1.812q.761.75 1.802.75Zm0-1.333q-.5 0-.864-.364-.365-.365-.365-.865t.365-.865q.364-.364.864-.364t.865.364q.365.365.365.865t-.365.865q-.365.364-.865.364ZM10.021 10Zm-.854 6.583h1.666l.25-2.187q.605-.167 1.136-.49.531-.323 1.031-.802l2.021.875.854-1.375-1.792-1.354q.105-.333.136-.635.031-.303.031-.615 0-.292-.031-.573-.031-.281-.115-.635l1.792-1.396-.834-1.375-2.062.875q-.438-.438-1.021-.781-.583-.344-1.125-.49l-.271-2.208H9.167l-.271 2.208q-.584.146-1.125.458-.542.313-1.042.792l-2.021-.854-.833 1.375 1.75 1.354q-.083.333-.125.646-.042.312-.042.604t.042.594q.042.302.125.635l-1.75 1.375.833 1.375 2.021-.854q.479.458 1.021.771.542.312 1.146.479Z"/></svg>';
1077
770
  const startIcon = '<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><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>';
1078
771
  const stepIcon = '<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" fill="#00000089"><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>';
@@ -1088,13 +781,31 @@ const VerdocsTemplateRoles = class {
1088
781
  this.exit = index.createEvent(this, "exit", 7);
1089
782
  this.sdkError = index.createEvent(this, "sdkError", 7);
1090
783
  this.rolesUpdated = index.createEvent(this, "rolesUpdated", 7);
1091
- this.templateStore = null;
1092
- this.roleStore = null;
784
+ this.templateListenerId = null;
1093
785
  this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
1094
786
  this.templateId = '';
1095
787
  this.showingRoleDialog = null;
1096
788
  this.sender = null;
1097
789
  this.loading = true;
790
+ this.template = null;
791
+ }
792
+ disconnectedCallback() {
793
+ this.unlistenToTemplate();
794
+ }
795
+ async listenToTemplate() {
796
+ console.log('[ROLES] Loading template', this.templateId);
797
+ this.unlistenToTemplate();
798
+ Datastore.Store.subscribe('templates', this.templateId, () => jsSdk.getTemplate(this.endpoint, this.templateId), false, (template) => {
799
+ console.log('[BUILD] Template Updated', template);
800
+ this.template = template;
801
+ this.loading = false;
802
+ });
803
+ }
804
+ unlistenToTemplate() {
805
+ if (this.templateListenerId) {
806
+ Datastore.Store.store.delListener(this.templateListenerId);
807
+ this.templateListenerId = null;
808
+ }
1098
809
  }
1099
810
  async componentWillLoad() {
1100
811
  var _a, _b, _c;
@@ -1108,18 +819,7 @@ const VerdocsTemplateRoles = class {
1108
819
  console.log('[ROLES] Unable to start builder session, must be authenticated');
1109
820
  return;
1110
821
  }
1111
- await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false)
1112
- .then(ts => {
1113
- this.templateStore = ts;
1114
- this.roleStore = TemplateRoleStore.getTemplateRoleStore(this.templateId);
1115
- this.loading = false;
1116
- this.roleStore.onChange('roles', roles => {
1117
- var _a;
1118
- console.log('[ROLES] Roles changed', { roles });
1119
- (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'updated', endpoint: this.endpoint, templateId: this.templateId, roles });
1120
- });
1121
- })
1122
- .catch(e => console.warn(e));
822
+ this.listenToTemplate();
1123
823
  }
1124
824
  catch (e) {
1125
825
  console.log('[FIELDS] Error with preview session', e);
@@ -1163,12 +863,8 @@ const VerdocsTemplateRoles = class {
1163
863
  overlap: 0.05,
1164
864
  ondrop: async function onDrop(event) {
1165
865
  var _a;
1166
- console.log('dropped', event.target.classList);
1167
866
  event.target.classList.remove('active');
1168
- const roleName = event.relatedTarget.dataset.rolename;
1169
- const targetSequence = +event.target.dataset.sequence;
1170
- const targetOrder = +event.target.dataset.order;
1171
- TemplateRoleStore.updateStoreRole(this.roleStore, roleName, { sequence: targetSequence, order: targetOrder });
867
+ // This will re-sort the roles and renumbers them via server calls if necessary
1172
868
  await this.renumberTemplateRoles();
1173
869
  console.log('[ROLES] Updated roles', this.getSortedRoles());
1174
870
  (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'updated', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
@@ -1196,7 +892,10 @@ const VerdocsTemplateRoles = class {
1196
892
  (_a = this.next) === null || _a === void 0 ? void 0 : _a.emit();
1197
893
  }
1198
894
  getSortedRoles() {
1199
- return this.roleStore.state.roles.sort((a, b) => {
895
+ var _a;
896
+ // NOTE: This mutates the source array but that's OK because everything that touches
897
+ // it will want the same thing done.
898
+ return (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).sort((a, b) => {
1200
899
  return a.sequence === b.sequence ? a.order - b.order : a.sequence - b.sequence;
1201
900
  });
1202
901
  }
@@ -1214,14 +913,15 @@ const VerdocsTemplateRoles = class {
1214
913
  return roles.map(role => role.name);
1215
914
  }
1216
915
  getRolesAtSequence(sequence) {
916
+ var _a;
1217
917
  // Entries can be undefined when deleted because Stencil has no remove() operator yet for stores.
1218
918
  // See https://github.com/ionic-team/stencil-store/issues/23
1219
- return this.roleStore.state.roles.filter(role => role && role.sequence === sequence);
919
+ return (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).filter(role => role && role.sequence === sequence);
1220
920
  }
1221
921
  // When the user drags a role around, we handle placement "between" items by assigning it a half-order number
1222
922
  // e.g. 1.5 to place it between items 1 and 2, 0.5 to place it at the beginning, or last+0.5 to place it at the end.
1223
923
  // Then we re-sort the list of roles and renumber them.
1224
- renumberTemplateRoles() {
924
+ async renumberTemplateRoles() {
1225
925
  // console.log('Renumbering roles', this.getSequenceNumbers(), JSON.stringify(this.roleStore.state));
1226
926
  // Avoid dupe renumber attempts
1227
927
  const renumbered = [];
@@ -1234,24 +934,30 @@ const VerdocsTemplateRoles = class {
1234
934
  role.sequence = newSequenceIndex + 1;
1235
935
  role.order = newOrderIndex + 1;
1236
936
  renumbered.push(role.name);
1237
- renumberRequests.push(jsSdk.updateTemplateRole(this.endpoint, this.templateId, role.name, {
1238
- sequence: role.sequence,
1239
- order: role.order,
1240
- }));
937
+ renumberRequests.push(jsSdk.updateTemplateRole(this.endpoint, this.templateId, role.name, { sequence: role.sequence, order: role.order }));
1241
938
  }
1242
939
  }
1243
940
  });
1244
941
  });
1245
- return Promise.all(renumberRequests);
942
+ if (renumberRequests.length > 0) {
943
+ console.log(`[ROLES] Submitting ${renumberRequests.length} renumber requests`);
944
+ return Promise.all(renumberRequests).then(async () => {
945
+ // When renumbering, we don't try to update the store for every individual item
946
+ // changing. We just do it once at the end.
947
+ this.template = await Datastore.Store.getTemplate(this.endpoint, this.templateId, true);
948
+ });
949
+ }
950
+ return true;
1246
951
  }
1247
952
  // Look for name conflicts, because they're UGC and can be anything, regardless of order.
1248
953
  getNextRoleName() {
954
+ var _a, _b;
1249
955
  let name = '';
1250
- let nextNumber = Object.keys(this.roleStore.state).length - 1;
956
+ let nextNumber = (((_a = this.template) === null || _a === void 0 ? void 0 : _a.roles) || []).length;
1251
957
  do {
1252
958
  nextNumber++;
1253
959
  name = `Recipient ${nextNumber}`;
1254
- } while (!name || this.roleStore.state.roles.some(role => role && role.name === name));
960
+ } while (!name || (((_b = this.template) === null || _b === void 0 ? void 0 : _b.roles) || []).some(role => role && role.name === name));
1255
961
  return name;
1256
962
  }
1257
963
  callCreateRole(name, sequence, order) {
@@ -1271,10 +977,15 @@ const VerdocsTemplateRoles = class {
1271
977
  delegator: false,
1272
978
  kba_method: null,
1273
979
  })
1274
- .then(async (r) => {
980
+ .then(async (role) => {
1275
981
  var _a;
1276
- console.log('[ROLES] Created role', r);
1277
- this.roleStore.set('roles', [...this.roleStore.state.roles, r]);
982
+ console.log('[ROLES] Created role', role);
983
+ const newTemplate = JSON.parse(JSON.stringify(this.template));
984
+ newTemplate.roles.push(role);
985
+ // TODO: Verify this immediately triggers a self-update
986
+ console.log('Updating template in data store');
987
+ Datastore.Store.updateTemplate(this.templateId, newTemplate);
988
+ // This will re-sort the roles and renumbers them via server calls if necessary
1278
989
  await this.renumberTemplateRoles();
1279
990
  (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'added', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
1280
991
  })
@@ -1295,25 +1006,23 @@ const VerdocsTemplateRoles = class {
1295
1006
  this.callCreateRole(name, sequence, order);
1296
1007
  }
1297
1008
  render() {
1298
- var _a, _b, _c, _d;
1299
1009
  if (!this.endpoint.session) {
1300
1010
  return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
1301
1011
  }
1302
- if (this.loading || !((_a = this.templateStore) === null || _a === void 0 ? void 0 : _a.state.isLoaded)) {
1303
- console.log('Loading', this.loading, (_b = this.templateStore) === null || _b === void 0 ? void 0 : _b.state.isLoaded);
1012
+ if (this.loading || !this.template) {
1304
1013
  return (index.h(index.Host, { class: "loading" }, index.h("verdocs-loader", null)));
1305
1014
  }
1306
1015
  const roleNames = this.getRoleNames();
1307
1016
  const sequences = this.getSequenceNumbers();
1308
- return (index.h(index.Host, null, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("h5", null, "Roles and Workflow"), index.h("div", { class: "participants" }, index.h("div", { class: "left-line" }), index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: startIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "sender" }, index.h("span", { class: "label" }, "Owner:"), " ", senderLabels[(_d = (_c = this.templateStore) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.sender], ' '))), index.h("div", { class: "row add-sequence", "data-sequence": 0 }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "dropzone", "data-sequence": 0, "data-order": 1 }, "Add Step"))), sequences.map(sequence => (index.h(index.Fragment, null, index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: stepIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "dropzone", "data-order": 0.5, "data-sequence": sequence }), this.getRolesAtSequence(sequence).map(role => {
1017
+ return (index.h(index.Host, null, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("h5", null, "Roles and Workflow"), index.h("div", { class: "participants" }, index.h("div", { class: "left-line" }), index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: startIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "sender" }, index.h("span", { class: "label" }, "Send Envelope")))), index.h("div", { class: "row add-sequence", "data-sequence": 0 }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "dropzone", "data-sequence": 0, "data-order": 1 }, "Add Step"))), sequences.map(sequence => (index.h(index.Fragment, null, index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: stepIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "dropzone", "data-order": 0.5, "data-sequence": sequence }), this.getRolesAtSequence(sequence).map(role => {
1309
1018
  const unknown = !role.email;
1310
- console.log('ras', sequence, role);
1311
- return unknown ? (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { backgroundColor: jsSdk.getRGBA(TemplateRoleStore.getRoleIndex(this.roleStore, role.name)) }, "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.name, " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence }))) : (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { borderColor: jsSdk.getRGBA(TemplateRoleStore.getRoleIndex(this.roleStore, role.name)) }, "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), jsSdk.formatFullName(role), " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence })));
1019
+ return unknown ? (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { backgroundColor: jsSdk.getRGBA(getRoleIndex(this.template, role.name)) }, "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), role.name, " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence }))) : (index.h(index.Fragment, null, index.h("div", { class: "recipient", style: { borderColor: jsSdk.getRGBA(getRoleIndex(this.template, role.name)) }, "data-rolename": role.name, "data-sequence": sequence, "data-order": role.order }, index.h("span", { class: "type-icon", innerHTML: role.type === 'signer' ? iconSigner : role.type === 'cc' ? iconCC : iconApprover }), jsSdk.formatFullName(role), " ", index.h("div", { class: "settings-button", innerHTML: settingsIcon, onClick: () => (this.showingRoleDialog = role.name), "aria-role": "button" })), index.h("div", { class: "dropzone", "data-order": role.order + 0.5, "data-sequence": sequence })));
1312
1020
  }), index.h("button", { class: "add-role", innerHTML: plusIcon, onClick: e => this.handleAddRole(e, sequence) }))), sequences.length > 0 && (index.h("div", { class: "row add-sequence", "data-sequence": sequence }, index.h("div", { class: "row-roles" }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("div", { class: "dropzone", "data-sequence": sequence + 1, "data-order": 1 }, "Add Step"))))))), index.h("div", { class: "row", "data-sequence": sequences.length + 1 }, index.h("div", { class: "row-roles" }, index.h("div", { class: "icon", innerHTML: plusIcon }), index.h("button", { class: "add-step", innerHTML: plusIcon, onClick: e => this.handleAddStep(e, sequences.length + 1) }))), index.h("div", { class: "row" }, index.h("div", { class: "icon", innerHTML: doneIcon }), index.h("div", { class: "row-roles" }, index.h("div", { class: "complete" }, "Document Complete")))), roleNames.length < 1 && (index.h("div", { class: "empty" }, "You must add at least one Role before proceeding.", index.h("br", null), " Click the ", index.h("span", { innerHTML: plusIcon }), " Add button above to get started.")), index.h("div", { class: "buttons" }, index.h("div", { class: "flex-fill" }), index.h("verdocs-button", { variant: "outline", label: "Cancel", size: "small", onClick: () => this.handleCancel() }), index.h("verdocs-button", { label: "OK", size: "small", onClick: () => this.handleSubmit(), disabled: roleNames.length < 1 }))), this.showingRoleDialog && (index.h("verdocs-template-role-properties", { endpoint: this.endpoint, templateId: this.templateId, roleName: this.showingRoleDialog, onClose: () => {
1313
1021
  this.showingRoleDialog = null;
1314
1022
  }, onDelete: async () => {
1315
1023
  var _a;
1316
1024
  this.showingRoleDialog = null;
1025
+ // This will re-sort the roles and renumbers them via server calls if necessary
1317
1026
  await this.renumberTemplateRoles();
1318
1027
  (_a = this.rolesUpdated) === null || _a === void 0 ? void 0 : _a.emit({ event: 'deleted', endpoint: this.endpoint, templateId: this.templateId, roles: this.getSortedRoles() });
1319
1028
  } }))));
@@ -1322,90 +1031,8 @@ const VerdocsTemplateRoles = class {
1322
1031
  };
1323
1032
  VerdocsTemplateRoles.style = VerdocsTemplateRolesStyle0;
1324
1033
 
1325
- const verdocsTemplateVisibilityCss = "@-webkit-keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}@keyframes verdocs-field-pulse{0%{background-color:rgba(0, 0, 0, 0.35)}50%{background-color:rgba(0, 0, 0, 0)}100%{background-color:rgba(0, 0, 0, 0.35)}}verdocs-template-visibility{font-family:\"Inter\", -apple-system, \"Segoe UI\", \"Roboto\", \"Helvetica Neue\", sans-serif}verdocs-template-visibility.loading{min-height:300px;position:relative;display:block}verdocs-template-visibility.empty{display:none}verdocs-template-visibility form{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column}verdocs-template-visibility form .description{font-size:14px;text-align:justify;color:#5c6575}verdocs-template-visibility form h5{font-size:16px;font-weight:bold;color:#4c56cb;margin:0}verdocs-template-visibility form label{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;font-size:16px;font-weight:500;margin:0 0 4px 0;color:#33364b}verdocs-template-visibility form input{border:none;font-size:18px;padding:3px 6px 3px 0;background:transparent;border-bottom:1px solid #33364b}verdocs-template-visibility form input:focus{outline:none}verdocs-template-visibility form .input-row{display:-ms-flexbox;display:flex;margin:20px 0 0 0;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}verdocs-template-visibility form .input-row verdocs-text-input{margin:0;display:-ms-flexbox;display:flex;-ms-flex:0 0 40px;flex:0 0 40px}verdocs-template-visibility form .input-row verdocs-text-input input{text-align:center}verdocs-template-visibility form .input-row verdocs-checkbox{-ms-flex:0;flex:0;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center}verdocs-template-visibility form .input-row verdocs-checkbox label>input[type=checkbox]+*::before{margin-right:0}verdocs-template-visibility .buttons{display:-ms-flexbox;display:flex;-webkit-column-gap:8px;-moz-column-gap:8px;column-gap:8px;margin-top:25px;-ms-flex-direction:row;flex-direction:row}verdocs-template-visibility ::-webkit-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::-moz-placeholder{color:#aaaaaa}verdocs-template-visibility :-ms-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::-ms-input-placeholder{color:#aaaaaa}verdocs-template-visibility ::placeholder{color:#aaaaaa}";
1326
- const VerdocsTemplateVisibilityStyle0 = verdocsTemplateVisibilityCss;
1327
-
1328
- const VerdocsTemplateVisibility = class {
1329
- constructor(hostRef) {
1330
- index.registerInstance(this, hostRef);
1331
- this.close = index.createEvent(this, "close", 7);
1332
- this.sdkError = index.createEvent(this, "sdkError", 7);
1333
- this.templateUpdated = index.createEvent(this, "templateUpdated", 7);
1334
- this.store = null;
1335
- this.endpoint = jsSdk.VerdocsEndpoint.getDefault();
1336
- this.templateId = '';
1337
- this.dirty = false;
1338
- this.personal = false;
1339
- this.public = false;
1340
- }
1341
- async componentWillLoad() {
1342
- var _a, _b, _c, _d, _e, _f, _g;
1343
- try {
1344
- this.endpoint.loadSession();
1345
- if (!this.templateId) {
1346
- console.log(`[VISIBILITY] Missing required template ID ${this.templateId}`);
1347
- return;
1348
- }
1349
- if (!this.endpoint.session) {
1350
- console.log('[VISIBILITY] Unable to start builder session, must be authenticated');
1351
- return;
1352
- }
1353
- this.store = await TemplateStore.getTemplateStore(this.endpoint, this.templateId, false);
1354
- this.personal = ((_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.is_personal) || true;
1355
- this.public = ((_d = (_c = this.store) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.is_public) || false;
1356
- this.dirty = false;
1357
- }
1358
- catch (e) {
1359
- console.log('[TEMPLATE VISIBILITY] Error loading template', e);
1360
- (_e = this.sdkError) === null || _e === void 0 ? void 0 : _e.emit(new errors.SDKError(e.message, (_f = e.response) === null || _f === void 0 ? void 0 : _f.status, (_g = e.response) === null || _g === void 0 ? void 0 : _g.data));
1361
- }
1362
- }
1363
- handleCancel(e) {
1364
- var _a, _b, _c, _d, _e;
1365
- e.stopPropagation();
1366
- this.personal = (_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.is_personal;
1367
- this.public = (_d = (_c = this.store) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.is_public;
1368
- this.dirty = false;
1369
- (_e = this.close) === null || _e === void 0 ? void 0 : _e.emit();
1370
- }
1371
- async handleSave(e) {
1372
- var _a, _b, _c;
1373
- e.stopPropagation();
1374
- await jsSdk.updateTemplate(this.endpoint, this.templateId, { is_personal: this.personal, is_public: this.public });
1375
- if ((_a = this.store) === null || _a === void 0 ? void 0 : _a.state) {
1376
- this.store.state.is_personal = this.personal;
1377
- this.store.state.is_public = this.public;
1378
- }
1379
- this.dirty = false;
1380
- (_b = this.templateUpdated) === null || _b === void 0 ? void 0 : _b.emit({ endpoint: this.endpoint, template: this.store.state, event: 'visibility' });
1381
- (_c = this.close) === null || _c === void 0 ? void 0 : _c.emit();
1382
- }
1383
- render() {
1384
- var _a, _b;
1385
- if (!this.endpoint.session) {
1386
- return (index.h(index.Host, null, index.h("verdocs-component-error", { message: "You must be authenticated to use this module." })));
1387
- }
1388
- // This is meant to be a companion for larger visual experiences so we just go blank on errors for now.
1389
- if (!this.endpoint.session || !((_b = (_a = this.store) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.isLoaded)) {
1390
- return index.h(index.Host, { class: "empty" });
1391
- }
1392
- return (index.h(index.Host, null, index.h("form", { onSubmit: e => e.preventDefault(), onClick: e => e.stopPropagation(), autocomplete: "off" }, index.h("h5", null, "Visibility"), index.h("div", { class: "input-row" }, index.h("label", { htmlFor: "verdocs-is-shared" }, "Shared"), index.h("verdocs-checkbox", { id: "verdocs-is-shared", name: "is-shared", checked: !this.personal, value: "on", onInput: (e) => {
1393
- this.personal = !e.target.checked;
1394
- this.dirty = true;
1395
- } })), index.h("div", { class: "description" }, "Shared templates are visible to other members of your Organization (if any)."), index.h("div", { class: "input-row" }, index.h("label", { htmlFor: "verdocs-is-public" }, "Public"), index.h("verdocs-checkbox", { id: "verdocs-is-public", name: "is-public", checked: this.public, value: "on", onInput: (e) => {
1396
- this.public = e.target.checked;
1397
- this.dirty = true;
1398
- } })), index.h("div", { class: "description" }, "Public templates may appear in results when any other user searches for templates. Note that a template may be both Personal and Public, which may be useful if you want your template to be found via search but not otherwise displayed to other members of your Organization (if any)."), index.h("div", { class: "buttons" }, index.h("verdocs-button", { size: "small", variant: "outline", label: "Cancel", disabled: !this.dirty, onClick: e => this.handleCancel(e) }), index.h("verdocs-button", { size: "small", label: "Save", disabled: !this.dirty, onClick: e => this.handleSave(e) })))));
1399
- }
1400
- };
1401
- VerdocsTemplateVisibility.style = VerdocsTemplateVisibilityStyle0;
1402
-
1403
1034
  exports.verdocs_preview = VerdocsPreview;
1404
1035
  exports.verdocs_send = VerdocsSend;
1405
- exports.verdocs_template_attachments = VerdocsTemplateAttachments;
1406
1036
  exports.verdocs_template_build_tabs = VerdocsTemplateBuildTabs;
1407
- exports.verdocs_template_create = VerdocsTemplateCreate;
1408
1037
  exports.verdocs_template_fields = VerdocsTemplateFields;
1409
- exports.verdocs_template_name = VerdocsTemplateName;
1410
1038
  exports.verdocs_template_roles = VerdocsTemplateRoles;
1411
- exports.verdocs_template_visibility = VerdocsTemplateVisibility;