@verdocs/web-sdk 1.4.0 → 1.4.2

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 (354) hide show
  1. package/dist/cjs/Auth-adc80bd4.js +68 -0
  2. package/dist/cjs/{Token-b86e5335.js → Token-1ec62bd3.js} +2 -135
  3. package/dist/{verdocs-web-sdk/buffer-es6-5cef4368.js → cjs/buffer-es6-bc8199b1.js} +47 -14
  4. package/dist/cjs/index-589f3be8.js +1356 -0
  5. package/dist/cjs/loader.cjs.js +3 -19
  6. package/dist/cjs/{index-9c6e5f50.js → popper-71bf3058.js} +0 -186
  7. package/dist/cjs/verdocs-auth.cjs.entry.js +7 -199
  8. package/dist/cjs/verdocs-button_2.cjs.entry.js +105 -0
  9. package/dist/cjs/{verdocs-view.cjs.entry.js → verdocs-dropdown_12.cjs.entry.js} +3313 -50
  10. package/dist/cjs/verdocs-initial-dialog.cjs.entry.js +1 -1
  11. package/dist/cjs/verdocs-kba-dialog.cjs.entry.js +2 -2
  12. package/dist/cjs/verdocs-loader.cjs.entry.js +1 -1
  13. package/dist/cjs/verdocs-ok-dialog.cjs.entry.js +2 -2
  14. package/dist/cjs/verdocs-organization-card.cjs.entry.js +1 -1
  15. package/dist/cjs/verdocs-quick-functions.cjs.entry.js +2 -2
  16. package/dist/cjs/verdocs-search-activity_2.cjs.entry.js +228 -0
  17. package/dist/cjs/verdocs-search-tabs.cjs.entry.js +2 -2
  18. package/dist/cjs/verdocs-search.cjs.entry.js +1 -1
  19. package/dist/cjs/verdocs-sign.cjs.entry.js +3 -1511
  20. package/dist/cjs/verdocs-signature-dialog.cjs.entry.js +2 -2
  21. package/dist/cjs/verdocs-status-indicator.cjs.entry.js +4 -90
  22. package/dist/cjs/verdocs-template-card.cjs.entry.js +1 -1
  23. package/dist/cjs/verdocs-template-tags.cjs.entry.js +1 -1
  24. package/dist/cjs/verdocs-toggle.cjs.entry.js +1 -1
  25. package/dist/cjs/verdocs-upload-dialog.cjs.entry.js +2 -2
  26. package/dist/cjs/verdocs-web-sdk.cjs.js +5 -117
  27. package/dist/collection/collection-manifest.json +1 -1
  28. package/dist/collection/components/controls/verdocs-button/verdocs-button.css +1 -1
  29. package/dist/collection/components/dialogs/verdocs-kba-dialog/verdocs-kba-dialog.css +1 -1
  30. package/dist/collection/components/dialogs/verdocs-ok-dialog/verdocs-ok-dialog.css +2 -2
  31. package/dist/collection/components/dialogs/verdocs-signature-dialog/verdocs-signature-dialog.css +4 -4
  32. package/dist/collection/components/dialogs/verdocs-upload-dialog/verdocs-upload-dialog.css +2 -2
  33. package/dist/collection/components/elements/verdocs-field-attachment/verdocs-field-attachment.css +2 -4
  34. package/dist/collection/components/elements/verdocs-field-checkbox-group/verdocs-field-checkbox.css +1 -3
  35. package/dist/collection/components/elements/verdocs-field-date/verdocs-field-date.css +1 -3
  36. package/dist/collection/components/elements/verdocs-field-dropdown/verdocs-field-dropdown.css +1 -3
  37. package/dist/collection/components/elements/verdocs-field-initial/verdocs-field-initial.css +1 -3
  38. package/dist/collection/components/elements/verdocs-field-payment/verdocs-field-payment.css +1 -3
  39. package/dist/collection/components/elements/verdocs-field-radio-button-group/verdocs-field-radio-button.css +1 -3
  40. package/dist/collection/components/elements/verdocs-field-signature/verdocs-field-signature.css +1 -3
  41. package/dist/collection/components/elements/verdocs-field-textarea/verdocs-field-textarea.css +1 -3
  42. package/dist/collection/components/elements/verdocs-field-textbox/verdocs-field-textbox.css +1 -3
  43. package/dist/collection/components/elements/verdocs-quick-functions/verdocs-quick-functions.css +1 -3
  44. package/dist/collection/components/elements/verdocs-search-activity/verdocs-search-activity.css +1 -3
  45. package/dist/collection/components/elements/verdocs-search-box/verdocs-search-box.css +1 -3
  46. package/dist/collection/components/elements/verdocs-search-tabs/verdocs-search-tabs.css +1 -0
  47. package/dist/components/Auth.js +0 -93
  48. package/dist/components/Token.js +1 -134
  49. package/dist/components/buffer-es6.js +39 -14
  50. package/dist/components/index.js +0 -4
  51. package/dist/components/{index3.js → popper.js} +0 -186
  52. package/dist/components/verdocs-auth.js +2 -193
  53. package/dist/components/verdocs-button2.js +2 -2
  54. package/dist/components/verdocs-dropdown2.js +2 -2
  55. package/dist/components/verdocs-field-attachment2.js +2 -2
  56. package/dist/components/verdocs-field-checkbox2.js +2 -2
  57. package/dist/components/verdocs-field-date2.js +2 -214
  58. package/dist/components/verdocs-field-dropdown2.js +2 -2
  59. package/dist/components/verdocs-field-initial2.js +2 -2
  60. package/dist/components/verdocs-field-payment2.js +2 -2
  61. package/dist/components/verdocs-field-radio-button2.js +2 -2
  62. package/dist/components/verdocs-field-signature2.js +2 -2
  63. package/dist/components/verdocs-field-textarea2.js +2 -2
  64. package/dist/components/verdocs-field-textbox2.js +2 -2
  65. package/dist/components/verdocs-initial-dialog2.js +1 -1
  66. package/dist/components/verdocs-kba-dialog.js +2 -2
  67. package/dist/components/verdocs-loader2.js +1 -1
  68. package/dist/components/verdocs-ok-dialog2.js +2 -2
  69. package/dist/components/verdocs-organization-card.js +1 -1
  70. package/dist/components/verdocs-quick-functions.js +2 -2
  71. package/dist/components/verdocs-search-activity2.js +16 -104
  72. package/dist/components/verdocs-search-box2.js +2 -2
  73. package/dist/components/verdocs-search-tabs.js +2 -2
  74. package/dist/components/verdocs-search.js +1 -1
  75. package/dist/components/verdocs-sign.js +1 -1508
  76. package/dist/components/verdocs-signature-dialog2.js +2 -2
  77. package/dist/components/verdocs-status-indicator.js +3 -88
  78. package/dist/components/verdocs-template-card.js +1 -1
  79. package/dist/components/verdocs-template-tags.js +1 -1
  80. package/dist/components/verdocs-text-input2.js +1 -1
  81. package/dist/components/verdocs-toggle.js +1 -1
  82. package/dist/components/verdocs-upload-dialog2.js +2 -2
  83. package/dist/components/verdocs-view2.js +6 -33
  84. package/dist/docs.json +2 -2
  85. package/dist/esm/Auth-ff6040be.js +64 -0
  86. package/dist/{verdocs-web-sdk/Token-29eea56d.js → esm/Token-a587e3ad.js} +1 -134
  87. package/dist/{cjs/buffer-es6-b2c1c885.js → esm/buffer-es6-136673c8.js} +38 -15
  88. package/dist/esm/index-859bc689.js +1327 -0
  89. package/dist/esm/loader.js +3 -19
  90. package/dist/esm/{index-432c65a6.js → popper-93ecb064.js} +0 -186
  91. package/dist/esm/verdocs-auth.entry.js +4 -196
  92. package/dist/esm/verdocs-button_2.entry.js +100 -0
  93. package/dist/esm/{verdocs-view.entry.js → verdocs-dropdown_12.entry.js} +3286 -34
  94. package/dist/esm/verdocs-initial-dialog.entry.js +1 -1
  95. package/dist/esm/verdocs-kba-dialog.entry.js +2 -2
  96. package/dist/esm/verdocs-loader.entry.js +1 -1
  97. package/dist/esm/verdocs-ok-dialog.entry.js +2 -2
  98. package/dist/esm/verdocs-organization-card.entry.js +1 -1
  99. package/dist/esm/verdocs-quick-functions.entry.js +2 -2
  100. package/dist/esm/verdocs-search-activity_2.entry.js +223 -0
  101. package/dist/esm/verdocs-search-tabs.entry.js +2 -2
  102. package/dist/esm/verdocs-search.entry.js +1 -1
  103. package/dist/esm/verdocs-sign.entry.js +3 -1511
  104. package/dist/esm/verdocs-signature-dialog.entry.js +2 -2
  105. package/dist/esm/verdocs-status-indicator.entry.js +3 -89
  106. package/dist/esm/verdocs-template-card.entry.js +1 -1
  107. package/dist/esm/verdocs-template-tags.entry.js +1 -1
  108. package/dist/esm/verdocs-toggle.entry.js +1 -1
  109. package/dist/esm/verdocs-upload-dialog.entry.js +2 -2
  110. package/dist/esm/verdocs-web-sdk.js +5 -117
  111. package/dist/esm-es5/Auth-ff6040be.js +1 -0
  112. package/dist/esm-es5/Token-a587e3ad.js +1 -0
  113. package/dist/esm-es5/buffer-es6-136673c8.js +7 -0
  114. package/dist/esm-es5/index-859bc689.js +2 -0
  115. package/dist/esm-es5/loader.js +1 -1
  116. package/dist/esm-es5/popper-93ecb064.js +1 -0
  117. package/dist/esm-es5/verdocs-auth.entry.js +1 -1
  118. package/dist/esm-es5/verdocs-button_2.entry.js +1 -0
  119. package/dist/esm-es5/verdocs-dropdown_12.entry.js +23 -0
  120. package/dist/esm-es5/verdocs-initial-dialog.entry.js +1 -1
  121. package/dist/esm-es5/verdocs-kba-dialog.entry.js +1 -1
  122. package/dist/esm-es5/verdocs-loader.entry.js +1 -1
  123. package/dist/esm-es5/verdocs-ok-dialog.entry.js +1 -1
  124. package/dist/esm-es5/verdocs-organization-card.entry.js +1 -1
  125. package/dist/esm-es5/verdocs-quick-functions.entry.js +1 -1
  126. package/dist/esm-es5/verdocs-search-activity_2.entry.js +1 -0
  127. package/dist/esm-es5/verdocs-search-tabs.entry.js +1 -1
  128. package/dist/esm-es5/verdocs-search.entry.js +1 -1
  129. package/dist/esm-es5/verdocs-sign.entry.js +1 -1
  130. package/dist/esm-es5/verdocs-signature-dialog.entry.js +1 -1
  131. package/dist/esm-es5/verdocs-status-indicator.entry.js +1 -11
  132. package/dist/esm-es5/verdocs-template-card.entry.js +1 -1
  133. package/dist/esm-es5/verdocs-template-tags.entry.js +1 -1
  134. package/dist/esm-es5/verdocs-toggle.entry.js +1 -1
  135. package/dist/esm-es5/verdocs-upload-dialog.entry.js +1 -1
  136. package/dist/esm-es5/verdocs-web-sdk.js +1 -1
  137. package/dist/verdocs-web-sdk/index.esm.js +0 -1
  138. package/dist/verdocs-web-sdk/p-0353c423.entry.js +1 -0
  139. package/dist/verdocs-web-sdk/p-11bc03a5.js +1 -0
  140. package/dist/verdocs-web-sdk/p-144e0842.system.entry.js +1 -0
  141. package/dist/verdocs-web-sdk/p-15b7ed4d.entry.js +1 -0
  142. package/dist/verdocs-web-sdk/p-1f55d8ac.system.entry.js +1 -0
  143. package/dist/verdocs-web-sdk/p-2bc58746.js +2 -0
  144. package/dist/verdocs-web-sdk/p-34bb9854.system.entry.js +1 -0
  145. package/dist/verdocs-web-sdk/p-3d1eb63d.system.entry.js +1 -0
  146. package/dist/verdocs-web-sdk/p-3f437456.system.entry.js +1 -0
  147. package/dist/verdocs-web-sdk/p-432c3151.system.entry.js +1 -0
  148. package/dist/verdocs-web-sdk/p-466cf9bf.system.entry.js +1 -0
  149. package/dist/verdocs-web-sdk/p-4c66f794.js +1 -0
  150. package/dist/verdocs-web-sdk/{index.system.js → p-50ea2036.system.js} +0 -0
  151. package/dist/verdocs-web-sdk/p-5dfd73f9.system.js +7 -0
  152. package/dist/verdocs-web-sdk/p-6348272c.js +1 -0
  153. package/dist/verdocs-web-sdk/p-6393b2b4.entry.js +1 -0
  154. package/dist/verdocs-web-sdk/p-66b19637.entry.js +1 -0
  155. package/dist/verdocs-web-sdk/p-6802ef91.system.entry.js +1 -0
  156. package/dist/verdocs-web-sdk/p-6ac9e6f8.entry.js +1 -0
  157. package/dist/verdocs-web-sdk/p-6d65d54e.system.entry.js +1 -0
  158. package/dist/verdocs-web-sdk/p-6fa6fb3c.entry.js +1 -0
  159. package/dist/verdocs-web-sdk/p-829b235c.entry.js +1 -0
  160. package/dist/verdocs-web-sdk/p-8795dbe8.entry.js +1 -0
  161. package/dist/verdocs-web-sdk/p-88a300c5.system.js +1 -0
  162. package/dist/verdocs-web-sdk/p-8c6db319.entry.js +1 -0
  163. package/dist/verdocs-web-sdk/p-8c6e29a5.entry.js +1 -0
  164. package/dist/verdocs-web-sdk/p-92632d8e.system.entry.js +1 -0
  165. package/dist/verdocs-web-sdk/p-96c0bf40.system.js +1 -0
  166. package/dist/verdocs-web-sdk/p-98d72550.system.entry.js +23 -0
  167. package/dist/verdocs-web-sdk/p-9b34c794.entry.js +1 -0
  168. package/dist/verdocs-web-sdk/p-9fbb3fc2.entry.js +1 -0
  169. package/dist/verdocs-web-sdk/p-a1fcf0c4.entry.js +23 -0
  170. package/dist/verdocs-web-sdk/p-b1cd24f7.entry.js +1 -0
  171. package/dist/verdocs-web-sdk/p-bf2620cb.entry.js +1 -0
  172. package/dist/verdocs-web-sdk/p-c2f97ef9.system.entry.js +1 -0
  173. package/dist/verdocs-web-sdk/p-caed7818.system.js +2 -0
  174. package/dist/verdocs-web-sdk/p-cc127684.system.entry.js +1 -0
  175. package/dist/verdocs-web-sdk/p-cd6d1fe5.system.entry.js +1 -0
  176. package/dist/verdocs-web-sdk/p-d6206c17.system.entry.js +1 -0
  177. package/dist/verdocs-web-sdk/p-da667373.entry.js +1 -0
  178. package/dist/verdocs-web-sdk/p-e2e643c5.system.entry.js +1 -0
  179. package/dist/verdocs-web-sdk/p-e3659c64.system.js +1 -0
  180. package/dist/verdocs-web-sdk/p-e609b2ee.system.js +1 -0
  181. package/dist/verdocs-web-sdk/p-e719f9ca.system.entry.js +1 -0
  182. package/dist/verdocs-web-sdk/p-ed5baeb4.entry.js +1 -0
  183. package/dist/verdocs-web-sdk/p-ef932a87.js +1 -0
  184. package/dist/verdocs-web-sdk/p-f0d0f959.system.entry.js +1 -0
  185. package/dist/verdocs-web-sdk/p-f7e26fbd.entry.js +1 -0
  186. package/dist/verdocs-web-sdk/p-f814d5cc.system.entry.js +1 -0
  187. package/dist/verdocs-web-sdk/p-f9d431ef.entry.js +1 -0
  188. package/dist/verdocs-web-sdk/verdocs-web-sdk.css +1 -57
  189. package/dist/verdocs-web-sdk/verdocs-web-sdk.esm.js +1 -129
  190. package/dist/verdocs-web-sdk/verdocs-web-sdk.js +2 -1
  191. package/package.json +4 -4
  192. package/dist/cjs/Auth-0146ddd8.js +0 -161
  193. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  194. package/dist/cjs/css-shim-e9231523.js +0 -6
  195. package/dist/cjs/dom-7fb93981.js +0 -75
  196. package/dist/cjs/index-a24f3b6a.js +0 -3096
  197. package/dist/cjs/index-b5a86b04.js +0 -4
  198. package/dist/cjs/index-c4be37e1.js +0 -54
  199. package/dist/cjs/shadow-css-abc19485.js +0 -389
  200. package/dist/cjs/verdocs-button.cjs.entry.js +0 -49
  201. package/dist/cjs/verdocs-dropdown.cjs.entry.js +0 -80
  202. package/dist/cjs/verdocs-field-attachment.cjs.entry.js +0 -59
  203. package/dist/cjs/verdocs-field-checkbox.cjs.entry.js +0 -39
  204. package/dist/cjs/verdocs-field-date.cjs.entry.js +0 -2968
  205. package/dist/cjs/verdocs-field-dropdown.cjs.entry.js +0 -59
  206. package/dist/cjs/verdocs-field-initial.cjs.entry.js +0 -52
  207. package/dist/cjs/verdocs-field-payment.cjs.entry.js +0 -86
  208. package/dist/cjs/verdocs-field-radio-button.cjs.entry.js +0 -48
  209. package/dist/cjs/verdocs-field-signature.cjs.entry.js +0 -52
  210. package/dist/cjs/verdocs-field-textarea.cjs.entry.js +0 -63
  211. package/dist/cjs/verdocs-field-textbox.cjs.entry.js +0 -63
  212. package/dist/cjs/verdocs-search-activity.cjs.entry.js +0 -263
  213. package/dist/cjs/verdocs-search-box.cjs.entry.js +0 -60
  214. package/dist/cjs/verdocs-text-input.cjs.entry.js +0 -62
  215. package/dist/components/index2.js +0 -1
  216. package/dist/components/index4.js +0 -47
  217. package/dist/custom-elements.json +0 -830
  218. package/dist/esm/Auth-4b21fced.js +0 -157
  219. package/dist/esm/Token-29eea56d.js +0 -2458
  220. package/dist/esm/app-globals-0f993ce5.js +0 -3
  221. package/dist/esm/buffer-es6-5cef4368.js +0 -1985
  222. package/dist/esm/css-shim-60f618b9.js +0 -4
  223. package/dist/esm/dom-4eeb3fee.js +0 -73
  224. package/dist/esm/index-97ec070b.js +0 -47
  225. package/dist/esm/index-ddbd60b5.js +0 -3059
  226. package/dist/esm/index-ef172650.js +0 -1
  227. package/dist/esm/shadow-css-02866686.js +0 -387
  228. package/dist/esm/verdocs-button.entry.js +0 -45
  229. package/dist/esm/verdocs-dropdown.entry.js +0 -76
  230. package/dist/esm/verdocs-field-attachment.entry.js +0 -55
  231. package/dist/esm/verdocs-field-checkbox.entry.js +0 -35
  232. package/dist/esm/verdocs-field-date.entry.js +0 -2964
  233. package/dist/esm/verdocs-field-dropdown.entry.js +0 -55
  234. package/dist/esm/verdocs-field-initial.entry.js +0 -48
  235. package/dist/esm/verdocs-field-payment.entry.js +0 -82
  236. package/dist/esm/verdocs-field-radio-button.entry.js +0 -44
  237. package/dist/esm/verdocs-field-signature.entry.js +0 -48
  238. package/dist/esm/verdocs-field-textarea.entry.js +0 -59
  239. package/dist/esm/verdocs-field-textbox.entry.js +0 -59
  240. package/dist/esm/verdocs-search-activity.entry.js +0 -259
  241. package/dist/esm/verdocs-search-box.entry.js +0 -56
  242. package/dist/esm/verdocs-text-input.entry.js +0 -58
  243. package/dist/esm-es5/Auth-4b21fced.js +0 -1
  244. package/dist/esm-es5/Token-29eea56d.js +0 -1
  245. package/dist/esm-es5/app-globals-0f993ce5.js +0 -1
  246. package/dist/esm-es5/buffer-es6-5cef4368.js +0 -7
  247. package/dist/esm-es5/css-shim-60f618b9.js +0 -1
  248. package/dist/esm-es5/dom-4eeb3fee.js +0 -21
  249. package/dist/esm-es5/index-432c65a6.js +0 -1
  250. package/dist/esm-es5/index-97ec070b.js +0 -1
  251. package/dist/esm-es5/index-ddbd60b5.js +0 -2
  252. package/dist/esm-es5/index-ef172650.js +0 -1
  253. package/dist/esm-es5/shadow-css-02866686.js +0 -12
  254. package/dist/esm-es5/verdocs-button.entry.js +0 -1
  255. package/dist/esm-es5/verdocs-dropdown.entry.js +0 -1
  256. package/dist/esm-es5/verdocs-field-attachment.entry.js +0 -1
  257. package/dist/esm-es5/verdocs-field-checkbox.entry.js +0 -1
  258. package/dist/esm-es5/verdocs-field-date.entry.js +0 -1
  259. package/dist/esm-es5/verdocs-field-dropdown.entry.js +0 -1
  260. package/dist/esm-es5/verdocs-field-initial.entry.js +0 -1
  261. package/dist/esm-es5/verdocs-field-payment.entry.js +0 -1
  262. package/dist/esm-es5/verdocs-field-radio-button.entry.js +0 -1
  263. package/dist/esm-es5/verdocs-field-signature.entry.js +0 -1
  264. package/dist/esm-es5/verdocs-field-textarea.entry.js +0 -1
  265. package/dist/esm-es5/verdocs-field-textbox.entry.js +0 -1
  266. package/dist/esm-es5/verdocs-search-activity.entry.js +0 -1
  267. package/dist/esm-es5/verdocs-search-box.entry.js +0 -1
  268. package/dist/esm-es5/verdocs-text-input.entry.js +0 -1
  269. package/dist/esm-es5/verdocs-view.entry.js +0 -23
  270. package/dist/verdocs-web-sdk/Auth-4b21fced.js +0 -157
  271. package/dist/verdocs-web-sdk/Auth-82e38539.system.js +0 -1
  272. package/dist/verdocs-web-sdk/Token-c1cf309e.system.js +0 -1
  273. package/dist/verdocs-web-sdk/app-globals-0f993ce5.js +0 -3
  274. package/dist/verdocs-web-sdk/app-globals-497eb362.system.js +0 -1
  275. package/dist/verdocs-web-sdk/buffer-es6-aa11181b.system.js +0 -7
  276. package/dist/verdocs-web-sdk/css-shim-60f618b9.js +0 -4
  277. package/dist/verdocs-web-sdk/css-shim-e41ceccc.system.js +0 -1
  278. package/dist/verdocs-web-sdk/dom-4eeb3fee.js +0 -73
  279. package/dist/verdocs-web-sdk/dom-89b5deb7.system.js +0 -21
  280. package/dist/verdocs-web-sdk/index-027b383e.system.js +0 -1
  281. package/dist/verdocs-web-sdk/index-06e036a1.system.js +0 -1
  282. package/dist/verdocs-web-sdk/index-432c65a6.js +0 -1974
  283. package/dist/verdocs-web-sdk/index-5d49316f.system.js +0 -1
  284. package/dist/verdocs-web-sdk/index-6465280a.system.js +0 -2
  285. package/dist/verdocs-web-sdk/index-97ec070b.js +0 -47
  286. package/dist/verdocs-web-sdk/index-ddbd60b5.js +0 -3059
  287. package/dist/verdocs-web-sdk/index-ef172650.js +0 -1
  288. package/dist/verdocs-web-sdk/shadow-css-02866686.js +0 -387
  289. package/dist/verdocs-web-sdk/shadow-css-6207e159.system.js +0 -13
  290. package/dist/verdocs-web-sdk/verdocs-auth.entry.js +0 -302
  291. package/dist/verdocs-web-sdk/verdocs-auth.system.entry.js +0 -1
  292. package/dist/verdocs-web-sdk/verdocs-button.entry.js +0 -45
  293. package/dist/verdocs-web-sdk/verdocs-button.system.entry.js +0 -1
  294. package/dist/verdocs-web-sdk/verdocs-dropdown.entry.js +0 -76
  295. package/dist/verdocs-web-sdk/verdocs-dropdown.system.entry.js +0 -1
  296. package/dist/verdocs-web-sdk/verdocs-field-attachment.entry.js +0 -55
  297. package/dist/verdocs-web-sdk/verdocs-field-attachment.system.entry.js +0 -1
  298. package/dist/verdocs-web-sdk/verdocs-field-checkbox.entry.js +0 -35
  299. package/dist/verdocs-web-sdk/verdocs-field-checkbox.system.entry.js +0 -1
  300. package/dist/verdocs-web-sdk/verdocs-field-date.entry.js +0 -2964
  301. package/dist/verdocs-web-sdk/verdocs-field-date.system.entry.js +0 -1
  302. package/dist/verdocs-web-sdk/verdocs-field-dropdown.entry.js +0 -55
  303. package/dist/verdocs-web-sdk/verdocs-field-dropdown.system.entry.js +0 -1
  304. package/dist/verdocs-web-sdk/verdocs-field-initial.entry.js +0 -48
  305. package/dist/verdocs-web-sdk/verdocs-field-initial.system.entry.js +0 -1
  306. package/dist/verdocs-web-sdk/verdocs-field-payment.entry.js +0 -82
  307. package/dist/verdocs-web-sdk/verdocs-field-payment.system.entry.js +0 -1
  308. package/dist/verdocs-web-sdk/verdocs-field-radio-button.entry.js +0 -44
  309. package/dist/verdocs-web-sdk/verdocs-field-radio-button.system.entry.js +0 -1
  310. package/dist/verdocs-web-sdk/verdocs-field-signature.entry.js +0 -48
  311. package/dist/verdocs-web-sdk/verdocs-field-signature.system.entry.js +0 -1
  312. package/dist/verdocs-web-sdk/verdocs-field-textarea.entry.js +0 -59
  313. package/dist/verdocs-web-sdk/verdocs-field-textarea.system.entry.js +0 -1
  314. package/dist/verdocs-web-sdk/verdocs-field-textbox.entry.js +0 -59
  315. package/dist/verdocs-web-sdk/verdocs-field-textbox.system.entry.js +0 -1
  316. package/dist/verdocs-web-sdk/verdocs-initial-dialog.entry.js +0 -239
  317. package/dist/verdocs-web-sdk/verdocs-initial-dialog.system.entry.js +0 -1
  318. package/dist/verdocs-web-sdk/verdocs-kba-dialog.entry.js +0 -77
  319. package/dist/verdocs-web-sdk/verdocs-kba-dialog.system.entry.js +0 -1
  320. package/dist/verdocs-web-sdk/verdocs-loader.entry.js +0 -15
  321. package/dist/verdocs-web-sdk/verdocs-loader.system.entry.js +0 -1
  322. package/dist/verdocs-web-sdk/verdocs-ok-dialog.entry.js +0 -44
  323. package/dist/verdocs-web-sdk/verdocs-ok-dialog.system.entry.js +0 -1
  324. package/dist/verdocs-web-sdk/verdocs-organization-card.entry.js +0 -18
  325. package/dist/verdocs-web-sdk/verdocs-organization-card.system.entry.js +0 -1
  326. package/dist/verdocs-web-sdk/verdocs-quick-functions.entry.js +0 -27
  327. package/dist/verdocs-web-sdk/verdocs-quick-functions.system.entry.js +0 -1
  328. package/dist/verdocs-web-sdk/verdocs-search-activity.entry.js +0 -259
  329. package/dist/verdocs-web-sdk/verdocs-search-activity.system.entry.js +0 -1
  330. package/dist/verdocs-web-sdk/verdocs-search-box.entry.js +0 -56
  331. package/dist/verdocs-web-sdk/verdocs-search-box.system.entry.js +0 -1
  332. package/dist/verdocs-web-sdk/verdocs-search-tabs.entry.js +0 -16
  333. package/dist/verdocs-web-sdk/verdocs-search-tabs.system.entry.js +0 -1
  334. package/dist/verdocs-web-sdk/verdocs-search.entry.js +0 -15
  335. package/dist/verdocs-web-sdk/verdocs-search.system.entry.js +0 -1
  336. package/dist/verdocs-web-sdk/verdocs-sign.entry.js +0 -1995
  337. package/dist/verdocs-web-sdk/verdocs-sign.system.entry.js +0 -1
  338. package/dist/verdocs-web-sdk/verdocs-signature-dialog.entry.js +0 -235
  339. package/dist/verdocs-web-sdk/verdocs-signature-dialog.system.entry.js +0 -1
  340. package/dist/verdocs-web-sdk/verdocs-status-indicator.entry.js +0 -7611
  341. package/dist/verdocs-web-sdk/verdocs-status-indicator.system.entry.js +0 -1
  342. package/dist/verdocs-web-sdk/verdocs-template-card.entry.js +0 -34
  343. package/dist/verdocs-web-sdk/verdocs-template-card.system.entry.js +0 -1
  344. package/dist/verdocs-web-sdk/verdocs-template-tags.entry.js +0 -16
  345. package/dist/verdocs-web-sdk/verdocs-template-tags.system.entry.js +0 -1
  346. package/dist/verdocs-web-sdk/verdocs-text-input.entry.js +0 -58
  347. package/dist/verdocs-web-sdk/verdocs-text-input.system.entry.js +0 -1
  348. package/dist/verdocs-web-sdk/verdocs-toggle.entry.js +0 -32
  349. package/dist/verdocs-web-sdk/verdocs-toggle.system.entry.js +0 -1
  350. package/dist/verdocs-web-sdk/verdocs-upload-dialog.entry.js +0 -119
  351. package/dist/verdocs-web-sdk/verdocs-upload-dialog.system.entry.js +0 -1
  352. package/dist/verdocs-web-sdk/verdocs-view.entry.js +0 -16118
  353. package/dist/verdocs-web-sdk/verdocs-view.system.entry.js +0 -23
  354. package/dist/verdocs-web-sdk/verdocs-web-sdk.system.js +0 -1
@@ -1,6 +1,3284 @@
1
- import { r as registerInstance, e as createEvent, h, g as getElement } from './index-ddbd60b5.js';
2
- import { g as getAugmentedNamespace, c as createCommonjsModule, a as commonjsGlobal, p as process_1, b as commonjsRequire, d as getDefaultExportFromCjs } from './index-97ec070b.js';
3
- import { B as Buffer } from './buffer-es6-5cef4368.js';
1
+ import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-859bc689.js';
2
+ import { c as createPopper } from './popper-93ecb064.js';
3
+ import { g as getAugmentedNamespace, c as createCommonjsModule, a as getDefaultExportFromCjs, b as commonjsGlobal, B as Buffer, d as commonjsRequire, p as process_1 } from './buffer-es6-136673c8.js';
4
+
5
+ const SortDown = `<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#50BE80"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M7 10l5 5 5-5H7z"/></svg>
6
+ `;
7
+
8
+ const verdocsDropdownCss = "verdocs-dropdown{font-family:\"Barlow\", sans-serif;display:block}verdocs-dropdown .arrow{width:32px;height:26px;background:#fff;cursor:pointer;border-radius:4px;-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;border:1px solid #cccccc;-ms-flex-pack:center;justify-content:center}verdocs-dropdown .arrow svg{fill:#55bc81;-webkit-transition:0.3s;transition:0.3s}verdocs-dropdown .items{width:200px;display:none;z-index:10000;border-radius:5px;background:#33354c;border:1px solid #654dcb}verdocs-dropdown .items[data-show]{display:block}verdocs-dropdown .option{width:100%;color:#fff;border:none;display:block;text-align:left;background:none;padding:10px 20px}verdocs-dropdown .option:hover{cursor:pointer;background:#55bc81}verdocs-dropdown .option[disabled]{color:#aaaaaa}verdocs-dropdown .option[disabled]:hover{color:#aaaaaa;cursor:inherit;background:transparent}verdocs-dropdown.open .items{display:block}verdocs-dropdown.open .arrow{background:#4c56cb;border:1px solid #707ae5}verdocs-dropdown.open .arrow svg{-webkit-transform:scaleY(-1);transform:scaleY(-1);fill:#fff}";
9
+
10
+ const VerdocsDropdown = class {
11
+ constructor(hostRef) {
12
+ registerInstance(this, hostRef);
13
+ this.optionSelected = createEvent(this, "optionSelected", 7);
14
+ /**
15
+ * The menu options to display.
16
+ */
17
+ this.options = [];
18
+ }
19
+ componentWillLoad() {
20
+ this.isOpen = !!this.open;
21
+ }
22
+ componentDidLoad() {
23
+ this.popper = createPopper(this.dropdownButton, this.dropdownMenu, { placement: 'bottom-start', modifiers: [{ name: 'offset', options: { offset: [0, 6] } }] });
24
+ }
25
+ handleSelectOption(option) {
26
+ this.isOpen = false;
27
+ this.optionSelected.emit(option);
28
+ this.hide();
29
+ }
30
+ // See https://popper.js.org/docs/v2/tutorial/
31
+ // What we're doing here is clearing event listeners when they aren't needed, to increase performance in lists
32
+ showDropdown() {
33
+ var _a, _b;
34
+ this.isOpen = true;
35
+ this.dropdownMenu.setAttribute('data-show', '');
36
+ this.dropdownMenu.removeAttribute('aria-hidden');
37
+ (_a = this.popper) === null || _a === void 0 ? void 0 : _a.setOptions(options => ({
38
+ ...options,
39
+ modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }],
40
+ }));
41
+ (_b = this.popper) === null || _b === void 0 ? void 0 : _b.update();
42
+ }
43
+ handleHideDropdown(e) {
44
+ var _a, _b;
45
+ if (((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.localName) === 'button' && ((_b = e === null || e === void 0 ? void 0 : e.target) === null || _b === void 0 ? void 0 : _b.className) === 'arrow') {
46
+ // This event is fired when a menu element is clicked because the button "loses focus" then too
47
+ return;
48
+ }
49
+ this.hide();
50
+ }
51
+ toggleDropdown() {
52
+ if (this.isOpen) {
53
+ this.hide();
54
+ }
55
+ else {
56
+ this.showDropdown();
57
+ }
58
+ }
59
+ hide() {
60
+ var _a;
61
+ this.isOpen = false;
62
+ this.dropdownMenu.removeAttribute('data-show');
63
+ this.dropdownMenu.setAttribute('aria-hidden', 'true');
64
+ (_a = this.popper) === null || _a === void 0 ? void 0 : _a.setOptions(options => ({
65
+ ...options,
66
+ modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }],
67
+ }));
68
+ }
69
+ render() {
70
+ var _a;
71
+ return (h(Host, { class: { storybook: !!(window === null || window === void 0 ? void 0 : window['STORYBOOK_ENV']), open: !!this.isOpen } }, h("button", { class: "arrow", innerHTML: SortDown, "aria-label": "Open Menu", onClick: () => this.toggleDropdown(), onBlur: e => this.handleHideDropdown(e), ref: el => (this.dropdownButton = el) }), h("div", { class: "items", "aria-hidden": !this.open, ref: el => (this.dropdownMenu = el) }, (_a = this.options) === null || _a === void 0 ? void 0 : _a.map(option => (h("button", { onClick: () => this.handleSelectOption(option), class: "option", disabled: option.disabled }, option.label))))));
72
+ }
73
+ };
74
+ VerdocsDropdown.style = verdocsDropdownCss;
75
+
76
+ const Paperclip = `<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
77
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13" />
78
+ </svg>
79
+ `;
80
+
81
+ const verdocsFieldAttachmentCss = "verdocs-field-attachment{font-family:\"Barlow\", sans-serif;width:24px;height:24px;display:block;font-size:11px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-attachment span{width:20px;cursor:pointer}verdocs-field-attachment.required span{border:1px solid #cc0000}verdocs-field-attachment.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
82
+
83
+ const VerdocsFieldAttachment = class {
84
+ constructor(hostRef) {
85
+ registerInstance(this, hostRef);
86
+ this.fieldChange = createEvent(this, "fieldChange", 7);
87
+ /**
88
+ * Sets the tabIndex of the input element.
89
+ */
90
+ this.order = 1;
91
+ /**
92
+ * Sets the value of the input element.
93
+ */
94
+ this.value = '';
95
+ /**
96
+ * If true, the field will be marked required.
97
+ */
98
+ this.required = false;
99
+ /**
100
+ * Sets the disabled attribute of the input element.
101
+ */
102
+ this.disabled = false;
103
+ }
104
+ async focusField() {
105
+ this.handleShow();
106
+ }
107
+ handleShow() {
108
+ this.dialog = document.createElement('verdocs-upload-dialog');
109
+ this.dialog.open = true;
110
+ this.dialog.addEventListener('cancel', () => {
111
+ var _a;
112
+ console.log('cancel');
113
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
114
+ });
115
+ document.addEventListener('done', e => {
116
+ var _a;
117
+ console.log('done', e);
118
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
119
+ });
120
+ document.body.append(this.dialog);
121
+ }
122
+ render() {
123
+ return (h(Host, { class: { required: this.required } }, h("span", { innerHTML: Paperclip, onClick: () => this.handleShow() })));
124
+ }
125
+ };
126
+ VerdocsFieldAttachment.style = verdocsFieldAttachmentCss;
127
+
128
+ const verdocsFieldCheckboxCss = "@charset \"UTF-8\";verdocs-field-checkbox{font-family:\"Barlow\", sans-serif;font-size:11px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-checkbox label>input[type=checkbox]{display:none}verdocs-field-checkbox label>input[type=checkbox]+*::before{content:\"\";display:block;vertical-align:bottom;width:14px;height:14px;border-radius:2px;border:1px solid rgba(0, 0, 0, 0.2);-ms-flex-negative:0;flex-shrink:0}verdocs-field-checkbox label>input[type=checkbox]:checked+*{color:var(--verdocs-primary-color)}verdocs-field-checkbox label>input[type=checkbox]:checked+*::before{content:\"✓\";color:white;text-align:center;background:var(--verdocs-primary-color);border-color:var(--verdocs-primary-color)}verdocs-field-checkbox.required label>input[type=checkbox]+*::before{border:1px solid var(--verdocs-required-color)}verdocs-field-checkbox.hide{display:none}verdocs-field-checkbox.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
129
+
130
+ const VerdocsFieldCheckbox = class {
131
+ constructor(hostRef) {
132
+ registerInstance(this, hostRef);
133
+ this.fieldChange = createEvent(this, "fieldChange", 7);
134
+ /**
135
+ * Sets the tabIndex of the input element.
136
+ */
137
+ this.order = 1;
138
+ /**
139
+ * Sets the value of the input element.
140
+ */
141
+ this.value = false;
142
+ /**
143
+ * If true, the field will be marked required.
144
+ */
145
+ this.required = false;
146
+ /**
147
+ * Sets the disabled attribute of the input element.
148
+ */
149
+ this.disabled = false;
150
+ }
151
+ handleChange(e) {
152
+ this.fieldChange.emit(e.target.checked);
153
+ }
154
+ render() {
155
+ return (h(Host, { class: { required: this.required } }, h("label", null, h("input", { type: "checkbox", tabIndex: this.order, checked: this.value, disabled: this.disabled, required: this.required, onChange: e => this.handleChange(e) }), h("span", null))));
156
+ }
157
+ };
158
+ VerdocsFieldCheckbox.style = verdocsFieldCheckboxCss;
159
+
160
+ function hasProperty(obj, prop) {
161
+ return Object.prototype.hasOwnProperty.call(obj, prop);
162
+ }
163
+
164
+ function lastItemOf(arr) {
165
+ return arr[arr.length - 1];
166
+ }
167
+
168
+ // push only the items not included in the array
169
+ function pushUnique(arr, ...items) {
170
+ items.forEach((item) => {
171
+ if (arr.includes(item)) {
172
+ return;
173
+ }
174
+ arr.push(item);
175
+ });
176
+ return arr;
177
+ }
178
+
179
+ function stringToArray(str, separator) {
180
+ // convert empty string to an empty array
181
+ return str ? str.split(separator) : [];
182
+ }
183
+
184
+ function isInRange(testVal, min, max) {
185
+ const minOK = min === undefined || testVal >= min;
186
+ const maxOK = max === undefined || testVal <= max;
187
+ return minOK && maxOK;
188
+ }
189
+
190
+ function limitToRange(val, min, max) {
191
+ if (val < min) {
192
+ return min;
193
+ }
194
+ if (val > max) {
195
+ return max;
196
+ }
197
+ return val;
198
+ }
199
+
200
+ function createTagRepeat(tagName, repeat, attributes = {}, index = 0, html = '') {
201
+ const openTagSrc = Object.keys(attributes).reduce((src, attr) => {
202
+ let val = attributes[attr];
203
+ if (typeof val === 'function') {
204
+ val = val(index);
205
+ }
206
+ return `${src} ${attr}="${val}"`;
207
+ }, tagName);
208
+ html += `<${openTagSrc}></${tagName}>`;
209
+
210
+ const next = index + 1;
211
+ return next < repeat
212
+ ? createTagRepeat(tagName, repeat, attributes, next, html)
213
+ : html;
214
+ }
215
+
216
+ // Remove the spacing surrounding tags for HTML parser not to create text nodes
217
+ // before/after elements
218
+ function optimizeTemplateHTML(html) {
219
+ return html.replace(/>\s+/g, '>').replace(/\s+</, '<');
220
+ }
221
+
222
+ function stripTime(timeValue) {
223
+ return new Date(timeValue).setHours(0, 0, 0, 0);
224
+ }
225
+
226
+ function today() {
227
+ return new Date().setHours(0, 0, 0, 0);
228
+ }
229
+
230
+ // Get the time value of the start of given date or year, month and day
231
+ function dateValue(...args) {
232
+ switch (args.length) {
233
+ case 0:
234
+ return today();
235
+ case 1:
236
+ return stripTime(args[0]);
237
+ }
238
+
239
+ // use setFullYear() to keep 2-digit year from being mapped to 1900-1999
240
+ const newDate = new Date(0);
241
+ newDate.setFullYear(...args);
242
+ return newDate.setHours(0, 0, 0, 0);
243
+ }
244
+
245
+ function addDays(date, amount) {
246
+ const newDate = new Date(date);
247
+ return newDate.setDate(newDate.getDate() + amount);
248
+ }
249
+
250
+ function addWeeks(date, amount) {
251
+ return addDays(date, amount * 7);
252
+ }
253
+
254
+ function addMonths(date, amount) {
255
+ // If the day of the date is not in the new month, the last day of the new
256
+ // month will be returned. e.g. Jan 31 + 1 month → Feb 28 (not Mar 03)
257
+ const newDate = new Date(date);
258
+ const monthsToSet = newDate.getMonth() + amount;
259
+ let expectedMonth = monthsToSet % 12;
260
+ if (expectedMonth < 0) {
261
+ expectedMonth += 12;
262
+ }
263
+
264
+ const time = newDate.setMonth(monthsToSet);
265
+ return newDate.getMonth() !== expectedMonth ? newDate.setDate(0) : time;
266
+ }
267
+
268
+ function addYears(date, amount) {
269
+ // If the date is Feb 29 and the new year is not a leap year, Feb 28 of the
270
+ // new year will be returned.
271
+ const newDate = new Date(date);
272
+ const expectedMonth = newDate.getMonth();
273
+ const time = newDate.setFullYear(newDate.getFullYear() + amount);
274
+ return expectedMonth === 1 && newDate.getMonth() === 2 ? newDate.setDate(0) : time;
275
+ }
276
+
277
+ // Calculate the distance bettwen 2 days of the week
278
+ function dayDiff(day, from) {
279
+ return (day - from + 7) % 7;
280
+ }
281
+
282
+ // Get the date of the specified day of the week of given base date
283
+ function dayOfTheWeekOf(baseDate, dayOfWeek, weekStart = 0) {
284
+ const baseDay = new Date(baseDate).getDay();
285
+ return addDays(baseDate, dayDiff(dayOfWeek, weekStart) - dayDiff(baseDay, weekStart));
286
+ }
287
+
288
+ // Get the ISO week of a date
289
+ function getWeek(date) {
290
+ // start of ISO week is Monday
291
+ const thuOfTheWeek = dayOfTheWeekOf(date, 4, 1);
292
+ // 1st week == the week where the 4th of January is in
293
+ const firstThu = dayOfTheWeekOf(new Date(thuOfTheWeek).setMonth(0, 4), 4, 1);
294
+ return Math.round((thuOfTheWeek - firstThu) / 604800000) + 1;
295
+ }
296
+
297
+ // Get the start year of the period of years that includes given date
298
+ // years: length of the year period
299
+ function startOfYearPeriod(date, years) {
300
+ /* @see https://en.wikipedia.org/wiki/Year_zero#ISO_8601 */
301
+ const year = new Date(date).getFullYear();
302
+ return Math.floor(year / years) * years;
303
+ }
304
+
305
+ // Convert date to the first/last date of the month/year of the date
306
+ function regularizeDate(date, timeSpan, useLastDate) {
307
+ if (timeSpan !== 1 && timeSpan !== 2) {
308
+ return date;
309
+ }
310
+ const newDate = new Date(date);
311
+ if (timeSpan === 1) {
312
+ useLastDate
313
+ ? newDate.setMonth(newDate.getMonth() + 1, 0)
314
+ : newDate.setDate(1);
315
+ } else {
316
+ useLastDate
317
+ ? newDate.setFullYear(newDate.getFullYear() + 1, 0, 0)
318
+ : newDate.setMonth(0, 1);
319
+ }
320
+ return newDate.setHours(0, 0, 0, 0);
321
+ }
322
+
323
+ // pattern for format parts
324
+ const reFormatTokens = /dd?|DD?|mm?|MM?|yy?(?:yy)?/;
325
+ // pattern for non date parts
326
+ const reNonDateParts = /[\s!-/:-@[-`{-~年月日]+/;
327
+ // cache for persed formats
328
+ let knownFormats = {};
329
+ // parse funtions for date parts
330
+ const parseFns = {
331
+ y(date, year) {
332
+ return new Date(date).setFullYear(parseInt(year, 10));
333
+ },
334
+ m(date, month, locale) {
335
+ const newDate = new Date(date);
336
+ let monthIndex = parseInt(month, 10) - 1;
337
+
338
+ if (isNaN(monthIndex)) {
339
+ if (!month) {
340
+ return NaN;
341
+ }
342
+
343
+ const monthName = month.toLowerCase();
344
+ const compareNames = name => name.toLowerCase().startsWith(monthName);
345
+ // compare with both short and full names because some locales have periods
346
+ // in the short names (not equal to the first X letters of the full names)
347
+ monthIndex = locale.monthsShort.findIndex(compareNames);
348
+ if (monthIndex < 0) {
349
+ monthIndex = locale.months.findIndex(compareNames);
350
+ }
351
+ if (monthIndex < 0) {
352
+ return NaN;
353
+ }
354
+ }
355
+
356
+ newDate.setMonth(monthIndex);
357
+ return newDate.getMonth() !== normalizeMonth(monthIndex)
358
+ ? newDate.setDate(0)
359
+ : newDate.getTime();
360
+ },
361
+ d(date, day) {
362
+ return new Date(date).setDate(parseInt(day, 10));
363
+ },
364
+ };
365
+ // format functions for date parts
366
+ const formatFns = {
367
+ d(date) {
368
+ return date.getDate();
369
+ },
370
+ dd(date) {
371
+ return padZero(date.getDate(), 2);
372
+ },
373
+ D(date, locale) {
374
+ return locale.daysShort[date.getDay()];
375
+ },
376
+ DD(date, locale) {
377
+ return locale.days[date.getDay()];
378
+ },
379
+ m(date) {
380
+ return date.getMonth() + 1;
381
+ },
382
+ mm(date) {
383
+ return padZero(date.getMonth() + 1, 2);
384
+ },
385
+ M(date, locale) {
386
+ return locale.monthsShort[date.getMonth()];
387
+ },
388
+ MM(date, locale) {
389
+ return locale.months[date.getMonth()];
390
+ },
391
+ y(date) {
392
+ return date.getFullYear();
393
+ },
394
+ yy(date) {
395
+ return padZero(date.getFullYear(), 2).slice(-2);
396
+ },
397
+ yyyy(date) {
398
+ return padZero(date.getFullYear(), 4);
399
+ },
400
+ };
401
+
402
+ // get month index in normal range (0 - 11) from any number
403
+ function normalizeMonth(monthIndex) {
404
+ return monthIndex > -1 ? monthIndex % 12 : normalizeMonth(monthIndex + 12);
405
+ }
406
+
407
+ function padZero(num, length) {
408
+ return num.toString().padStart(length, '0');
409
+ }
410
+
411
+ function parseFormatString(format) {
412
+ if (typeof format !== 'string') {
413
+ throw new Error("Invalid date format.");
414
+ }
415
+ if (format in knownFormats) {
416
+ return knownFormats[format];
417
+ }
418
+
419
+ // sprit the format string into parts and seprators
420
+ const separators = format.split(reFormatTokens);
421
+ const parts = format.match(new RegExp(reFormatTokens, 'g'));
422
+ if (separators.length === 0 || !parts) {
423
+ throw new Error("Invalid date format.");
424
+ }
425
+
426
+ // collect format functions used in the format
427
+ const partFormatters = parts.map(token => formatFns[token]);
428
+
429
+ // collect parse function keys used in the format
430
+ // iterate over parseFns' keys in order to keep the order of the keys.
431
+ const partParserKeys = Object.keys(parseFns).reduce((keys, key) => {
432
+ const token = parts.find(part => part[0] !== 'D' && part[0].toLowerCase() === key);
433
+ if (token) {
434
+ keys.push(key);
435
+ }
436
+ return keys;
437
+ }, []);
438
+
439
+ return knownFormats[format] = {
440
+ parser(dateStr, locale) {
441
+ const dateParts = dateStr.split(reNonDateParts).reduce((dtParts, part, index) => {
442
+ if (part.length > 0 && parts[index]) {
443
+ const token = parts[index][0];
444
+ if (token === 'M') {
445
+ dtParts.m = part;
446
+ } else if (token !== 'D') {
447
+ dtParts[token] = part;
448
+ }
449
+ }
450
+ return dtParts;
451
+ }, {});
452
+
453
+ // iterate over partParserkeys so that the parsing is made in the oder
454
+ // of year, month and day to prevent the day parser from correcting last
455
+ // day of month wrongly
456
+ return partParserKeys.reduce((origDate, key) => {
457
+ const newDate = parseFns[key](origDate, dateParts[key], locale);
458
+ // ingnore the part failed to parse
459
+ return isNaN(newDate) ? origDate : newDate;
460
+ }, today());
461
+ },
462
+ formatter(date, locale) {
463
+ let dateStr = partFormatters.reduce((str, fn, index) => {
464
+ return str += `${separators[index]}${fn(date, locale)}`;
465
+ }, '');
466
+ // separators' length is always parts' length + 1,
467
+ return dateStr += lastItemOf(separators);
468
+ },
469
+ };
470
+ }
471
+
472
+ function parseDate(dateStr, format, locale) {
473
+ if (dateStr instanceof Date || typeof dateStr === 'number') {
474
+ const date = stripTime(dateStr);
475
+ return isNaN(date) ? undefined : date;
476
+ }
477
+ if (!dateStr) {
478
+ return undefined;
479
+ }
480
+ if (dateStr === 'today') {
481
+ return today();
482
+ }
483
+
484
+ if (format && format.toValue) {
485
+ const date = format.toValue(dateStr, format, locale);
486
+ return isNaN(date) ? undefined : stripTime(date);
487
+ }
488
+
489
+ return parseFormatString(format).parser(dateStr, locale);
490
+ }
491
+
492
+ function formatDate(date, format, locale) {
493
+ if (isNaN(date) || (!date && date !== 0)) {
494
+ return '';
495
+ }
496
+
497
+ const dateObj = typeof date === 'number' ? new Date(date) : date;
498
+
499
+ if (format.toDisplay) {
500
+ return format.toDisplay(dateObj, format, locale);
501
+ }
502
+
503
+ return parseFormatString(format).formatter(dateObj, locale);
504
+ }
505
+
506
+ const range = document.createRange();
507
+
508
+ function parseHTML(html) {
509
+ return range.createContextualFragment(html);
510
+ }
511
+
512
+ function getParent(el) {
513
+ return el.parentElement
514
+ || (el.parentNode instanceof ShadowRoot ? el.parentNode.host : undefined);
515
+ }
516
+
517
+ function isActiveElement(el) {
518
+ return el.getRootNode().activeElement === el;
519
+ }
520
+
521
+ function hideElement(el) {
522
+ if (el.style.display === 'none') {
523
+ return;
524
+ }
525
+ // back up the existing display setting in data-style-display
526
+ if (el.style.display) {
527
+ el.dataset.styleDisplay = el.style.display;
528
+ }
529
+ el.style.display = 'none';
530
+ }
531
+
532
+ function showElement(el) {
533
+ if (el.style.display !== 'none') {
534
+ return;
535
+ }
536
+ if (el.dataset.styleDisplay) {
537
+ // restore backed-up dispay property
538
+ el.style.display = el.dataset.styleDisplay;
539
+ delete el.dataset.styleDisplay;
540
+ } else {
541
+ el.style.display = '';
542
+ }
543
+ }
544
+
545
+ function emptyChildNodes(el) {
546
+ if (el.firstChild) {
547
+ el.removeChild(el.firstChild);
548
+ emptyChildNodes(el);
549
+ }
550
+ }
551
+
552
+ function replaceChildNodes(el, newChildNodes) {
553
+ emptyChildNodes(el);
554
+ if (newChildNodes instanceof DocumentFragment) {
555
+ el.appendChild(newChildNodes);
556
+ } else if (typeof newChildNodes === 'string') {
557
+ el.appendChild(parseHTML(newChildNodes));
558
+ } else if (typeof newChildNodes.forEach === 'function') {
559
+ newChildNodes.forEach((node) => {
560
+ el.appendChild(node);
561
+ });
562
+ }
563
+ }
564
+
565
+ const listenerRegistry = new WeakMap();
566
+ const {addEventListener, removeEventListener} = EventTarget.prototype;
567
+
568
+ // Register event listeners to a key object
569
+ // listeners: array of listener definitions;
570
+ // - each definition must be a flat array of event target and the arguments
571
+ // used to call addEventListener() on the target
572
+ function registerListeners(keyObj, listeners) {
573
+ let registered = listenerRegistry.get(keyObj);
574
+ if (!registered) {
575
+ registered = [];
576
+ listenerRegistry.set(keyObj, registered);
577
+ }
578
+ listeners.forEach((listener) => {
579
+ addEventListener.call(...listener);
580
+ registered.push(listener);
581
+ });
582
+ }
583
+
584
+ function unregisterListeners(keyObj) {
585
+ let listeners = listenerRegistry.get(keyObj);
586
+ if (!listeners) {
587
+ return;
588
+ }
589
+ listeners.forEach((listener) => {
590
+ removeEventListener.call(...listener);
591
+ });
592
+ listenerRegistry.delete(keyObj);
593
+ }
594
+
595
+ // Event.composedPath() polyfill for Edge
596
+ // based on https://gist.github.com/kleinfreund/e9787d73776c0e3750dcfcdc89f100ec
597
+ if (!Event.prototype.composedPath) {
598
+ const getComposedPath = (node, path = []) => {
599
+ path.push(node);
600
+
601
+ let parent;
602
+ if (node.parentNode) {
603
+ parent = node.parentNode;
604
+ } else if (node.host) { // ShadowRoot
605
+ parent = node.host;
606
+ } else if (node.defaultView) { // Document
607
+ parent = node.defaultView;
608
+ }
609
+ return parent ? getComposedPath(parent, path) : path;
610
+ };
611
+
612
+ Event.prototype.composedPath = function () {
613
+ return getComposedPath(this.target);
614
+ };
615
+ }
616
+
617
+ function findFromPath(path, criteria, currentTarget) {
618
+ const [node, ...rest] = path;
619
+ if (criteria(node)) {
620
+ return node;
621
+ }
622
+ if (node === currentTarget || node.tagName === 'HTML' || rest.length === 0) {
623
+ // stop when reaching currentTarget or <html>
624
+ return;
625
+ }
626
+ return findFromPath(rest, criteria, currentTarget);
627
+ }
628
+
629
+ // Search for the actual target of a delegated event
630
+ function findElementInEventPath(ev, selector) {
631
+ const criteria = typeof selector === 'function'
632
+ ? selector
633
+ : el => el instanceof Element && el.matches(selector);
634
+ return findFromPath(ev.composedPath(), criteria, ev.currentTarget);
635
+ }
636
+
637
+ // default locales
638
+ const locales = {
639
+ en: {
640
+ days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
641
+ daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
642
+ daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
643
+ months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
644
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
645
+ today: "Today",
646
+ clear: "Clear",
647
+ titleFormat: "MM y"
648
+ }
649
+ };
650
+
651
+ // config options updatable by setOptions() and their default values
652
+ const defaultOptions = {
653
+ autohide: false,
654
+ beforeShowDay: null,
655
+ beforeShowDecade: null,
656
+ beforeShowMonth: null,
657
+ beforeShowYear: null,
658
+ calendarWeeks: false,
659
+ clearBtn: false,
660
+ dateDelimiter: ',',
661
+ datesDisabled: [],
662
+ daysOfWeekDisabled: [],
663
+ daysOfWeekHighlighted: [],
664
+ defaultViewDate: undefined, // placeholder, defaults to today() by the program
665
+ disableTouchKeyboard: false,
666
+ format: 'mm/dd/yyyy',
667
+ language: 'en',
668
+ maxDate: null,
669
+ maxNumberOfDates: 1,
670
+ maxView: 3,
671
+ minDate: null,
672
+ nextArrow: '»',
673
+ orientation: 'auto',
674
+ pickLevel: 0,
675
+ prevArrow: '«',
676
+ showDaysOfWeek: true,
677
+ showOnClick: true,
678
+ showOnFocus: true,
679
+ startView: 0,
680
+ title: '',
681
+ todayBtn: false,
682
+ todayBtnMode: 0,
683
+ todayHighlight: false,
684
+ updateOnBlur: true,
685
+ weekStart: 0,
686
+ };
687
+
688
+ const {
689
+ language: defaultLang,
690
+ format: defaultFormat,
691
+ weekStart: defaultWeekStart,
692
+ } = defaultOptions;
693
+
694
+ // Reducer function to filter out invalid day-of-week from the input
695
+ function sanitizeDOW(dow, day) {
696
+ return dow.length < 6 && day >= 0 && day < 7
697
+ ? pushUnique(dow, day)
698
+ : dow;
699
+ }
700
+
701
+ function calcEndOfWeek(startOfWeek) {
702
+ return (startOfWeek + 6) % 7;
703
+ }
704
+
705
+ // validate input date. if invalid, fallback to the original value
706
+ function validateDate(value, format, locale, origValue) {
707
+ const date = parseDate(value, format, locale);
708
+ return date !== undefined ? date : origValue;
709
+ }
710
+
711
+ // Validate viewId. if invalid, fallback to the original value
712
+ function validateViewId(value, origValue, max = 3) {
713
+ const viewId = parseInt(value, 10);
714
+ return viewId >= 0 && viewId <= max ? viewId : origValue;
715
+ }
716
+
717
+ // Create Datepicker configuration to set
718
+ function processOptions(options, datepicker) {
719
+ const inOpts = Object.assign({}, options);
720
+ const config = {};
721
+ const locales = datepicker.constructor.locales;
722
+ const rangeSideIndex = datepicker.rangeSideIndex;
723
+ let {
724
+ format,
725
+ language,
726
+ locale,
727
+ maxDate,
728
+ maxView,
729
+ minDate,
730
+ pickLevel,
731
+ startView,
732
+ weekStart,
733
+ } = datepicker.config || {};
734
+
735
+ if (inOpts.language) {
736
+ let lang;
737
+ if (inOpts.language !== language) {
738
+ if (locales[inOpts.language]) {
739
+ lang = inOpts.language;
740
+ } else {
741
+ // Check if langauge + region tag can fallback to the one without
742
+ // region (e.g. fr-CA → fr)
743
+ lang = inOpts.language.split('-')[0];
744
+ if (locales[lang] === undefined) {
745
+ lang = false;
746
+ }
747
+ }
748
+ }
749
+ delete inOpts.language;
750
+ if (lang) {
751
+ language = config.language = lang;
752
+
753
+ // update locale as well when updating language
754
+ const origLocale = locale || locales[defaultLang];
755
+ // use default language's properties for the fallback
756
+ locale = Object.assign({
757
+ format: defaultFormat,
758
+ weekStart: defaultWeekStart
759
+ }, locales[defaultLang]);
760
+ if (language !== defaultLang) {
761
+ Object.assign(locale, locales[language]);
762
+ }
763
+ config.locale = locale;
764
+ // if format and/or weekStart are the same as old locale's defaults,
765
+ // update them to new locale's defaults
766
+ if (format === origLocale.format) {
767
+ format = config.format = locale.format;
768
+ }
769
+ if (weekStart === origLocale.weekStart) {
770
+ weekStart = config.weekStart = locale.weekStart;
771
+ config.weekEnd = calcEndOfWeek(locale.weekStart);
772
+ }
773
+ }
774
+ }
775
+
776
+ if (inOpts.format) {
777
+ const hasToDisplay = typeof inOpts.format.toDisplay === 'function';
778
+ const hasToValue = typeof inOpts.format.toValue === 'function';
779
+ const validFormatString = reFormatTokens.test(inOpts.format);
780
+ if ((hasToDisplay && hasToValue) || validFormatString) {
781
+ format = config.format = inOpts.format;
782
+ }
783
+ delete inOpts.format;
784
+ }
785
+
786
+ //*** pick level ***//
787
+ let newPickLevel = pickLevel;
788
+ if (inOpts.pickLevel !== undefined) {
789
+ newPickLevel = validateViewId(inOpts.pickLevel, 2);
790
+ delete inOpts.pickLevel;
791
+ }
792
+ if (newPickLevel !== pickLevel) {
793
+ if (newPickLevel > pickLevel) {
794
+ // complement current minDate/madDate so that the existing range will be
795
+ // expanded to fit the new level later
796
+ if (inOpts.minDate === undefined) {
797
+ inOpts.minDate = minDate;
798
+ }
799
+ if (inOpts.maxDate === undefined) {
800
+ inOpts.maxDate = maxDate;
801
+ }
802
+ }
803
+ // complement datesDisabled so that it will be reset later
804
+ if (!inOpts.datesDisabled) {
805
+ inOpts.datesDisabled = [];
806
+ }
807
+ pickLevel = config.pickLevel = newPickLevel;
808
+ }
809
+
810
+ //*** dates ***//
811
+ // while min and maxDate for "no limit" in the options are better to be null
812
+ // (especially when updating), the ones in the config have to be undefined
813
+ // because null is treated as 0 (= unix epoch) when comparing with time value
814
+ let minDt = minDate;
815
+ let maxDt = maxDate;
816
+ if (inOpts.minDate !== undefined) {
817
+ const defaultMinDt = dateValue(0, 0, 1);
818
+ minDt = inOpts.minDate === null
819
+ ? defaultMinDt // set 0000-01-01 to prevent negative values for year
820
+ : validateDate(inOpts.minDate, format, locale, minDt);
821
+ if (minDt !== defaultMinDt) {
822
+ minDt = regularizeDate(minDt, pickLevel, false);
823
+ }
824
+ delete inOpts.minDate;
825
+ }
826
+ if (inOpts.maxDate !== undefined) {
827
+ maxDt = inOpts.maxDate === null
828
+ ? undefined
829
+ : validateDate(inOpts.maxDate, format, locale, maxDt);
830
+ if (maxDt !== undefined) {
831
+ maxDt = regularizeDate(maxDt, pickLevel, true);
832
+ }
833
+ delete inOpts.maxDate;
834
+ }
835
+ if (maxDt < minDt) {
836
+ minDate = config.minDate = maxDt;
837
+ maxDate = config.maxDate = minDt;
838
+ } else {
839
+ if (minDate !== minDt) {
840
+ minDate = config.minDate = minDt;
841
+ }
842
+ if (maxDate !== maxDt) {
843
+ maxDate = config.maxDate = maxDt;
844
+ }
845
+ }
846
+
847
+ if (inOpts.datesDisabled) {
848
+ config.datesDisabled = inOpts.datesDisabled.reduce((dates, dt) => {
849
+ const date = parseDate(dt, format, locale);
850
+ return date !== undefined
851
+ ? pushUnique(dates, regularizeDate(date, pickLevel, rangeSideIndex))
852
+ : dates;
853
+ }, []);
854
+ delete inOpts.datesDisabled;
855
+ }
856
+ if (inOpts.defaultViewDate !== undefined) {
857
+ const viewDate = parseDate(inOpts.defaultViewDate, format, locale);
858
+ if (viewDate !== undefined) {
859
+ config.defaultViewDate = viewDate;
860
+ }
861
+ delete inOpts.defaultViewDate;
862
+ }
863
+
864
+ //*** days of week ***//
865
+ if (inOpts.weekStart !== undefined) {
866
+ const wkStart = Number(inOpts.weekStart) % 7;
867
+ if (!isNaN(wkStart)) {
868
+ weekStart = config.weekStart = wkStart;
869
+ config.weekEnd = calcEndOfWeek(wkStart);
870
+ }
871
+ delete inOpts.weekStart;
872
+ }
873
+ if (inOpts.daysOfWeekDisabled) {
874
+ config.daysOfWeekDisabled = inOpts.daysOfWeekDisabled.reduce(sanitizeDOW, []);
875
+ delete inOpts.daysOfWeekDisabled;
876
+ }
877
+ if (inOpts.daysOfWeekHighlighted) {
878
+ config.daysOfWeekHighlighted = inOpts.daysOfWeekHighlighted.reduce(sanitizeDOW, []);
879
+ delete inOpts.daysOfWeekHighlighted;
880
+ }
881
+
882
+ //*** multi date ***//
883
+ if (inOpts.maxNumberOfDates !== undefined) {
884
+ const maxNumberOfDates = parseInt(inOpts.maxNumberOfDates, 10);
885
+ if (maxNumberOfDates >= 0) {
886
+ config.maxNumberOfDates = maxNumberOfDates;
887
+ config.multidate = maxNumberOfDates !== 1;
888
+ }
889
+ delete inOpts.maxNumberOfDates;
890
+ }
891
+ if (inOpts.dateDelimiter) {
892
+ config.dateDelimiter = String(inOpts.dateDelimiter);
893
+ delete inOpts.dateDelimiter;
894
+ }
895
+
896
+ //*** view ***//
897
+ let newMaxView = maxView;
898
+ if (inOpts.maxView !== undefined) {
899
+ newMaxView = validateViewId(inOpts.maxView, maxView);
900
+ delete inOpts.maxView;
901
+ }
902
+ // ensure max view >= pick level
903
+ newMaxView = pickLevel > newMaxView ? pickLevel : newMaxView;
904
+ if (newMaxView !== maxView) {
905
+ maxView = config.maxView = newMaxView;
906
+ }
907
+
908
+ let newStartView = startView;
909
+ if (inOpts.startView !== undefined) {
910
+ newStartView = validateViewId(inOpts.startView, newStartView);
911
+ delete inOpts.startView;
912
+ }
913
+ // ensure pick level <= start view <= max view
914
+ if (newStartView < pickLevel) {
915
+ newStartView = pickLevel;
916
+ } else if (newStartView > maxView) {
917
+ newStartView = maxView;
918
+ }
919
+ if (newStartView !== startView) {
920
+ config.startView = newStartView;
921
+ }
922
+
923
+ //*** template ***//
924
+ if (inOpts.prevArrow) {
925
+ const prevArrow = parseHTML(inOpts.prevArrow);
926
+ if (prevArrow.childNodes.length > 0) {
927
+ config.prevArrow = prevArrow.childNodes;
928
+ }
929
+ delete inOpts.prevArrow;
930
+ }
931
+ if (inOpts.nextArrow) {
932
+ const nextArrow = parseHTML(inOpts.nextArrow);
933
+ if (nextArrow.childNodes.length > 0) {
934
+ config.nextArrow = nextArrow.childNodes;
935
+ }
936
+ delete inOpts.nextArrow;
937
+ }
938
+
939
+ //*** misc ***//
940
+ if (inOpts.disableTouchKeyboard !== undefined) {
941
+ config.disableTouchKeyboard = 'ontouchstart' in document && !!inOpts.disableTouchKeyboard;
942
+ delete inOpts.disableTouchKeyboard;
943
+ }
944
+ if (inOpts.orientation) {
945
+ const orientation = inOpts.orientation.toLowerCase().split(/\s+/g);
946
+ config.orientation = {
947
+ x: orientation.find(x => (x === 'left' || x === 'right')) || 'auto',
948
+ y: orientation.find(y => (y === 'top' || y === 'bottom')) || 'auto',
949
+ };
950
+ delete inOpts.orientation;
951
+ }
952
+ if (inOpts.todayBtnMode !== undefined) {
953
+ switch(inOpts.todayBtnMode) {
954
+ case 0:
955
+ case 1:
956
+ config.todayBtnMode = inOpts.todayBtnMode;
957
+ }
958
+ delete inOpts.todayBtnMode;
959
+ }
960
+
961
+ //*** copy the rest ***//
962
+ Object.keys(inOpts).forEach((key) => {
963
+ if (inOpts[key] !== undefined && hasProperty(defaultOptions, key)) {
964
+ config[key] = inOpts[key];
965
+ }
966
+ });
967
+
968
+ return config;
969
+ }
970
+
971
+ const pickerTemplate = optimizeTemplateHTML(`<div class="datepicker">
972
+ <div class="datepicker-picker">
973
+ <div class="datepicker-header">
974
+ <div class="datepicker-title"></div>
975
+ <div class="datepicker-controls">
976
+ <button type="button" class="%buttonClass% prev-btn"></button>
977
+ <button type="button" class="%buttonClass% view-switch"></button>
978
+ <button type="button" class="%buttonClass% next-btn"></button>
979
+ </div>
980
+ </div>
981
+ <div class="datepicker-main"></div>
982
+ <div class="datepicker-footer">
983
+ <div class="datepicker-controls">
984
+ <button type="button" class="%buttonClass% today-btn"></button>
985
+ <button type="button" class="%buttonClass% clear-btn"></button>
986
+ </div>
987
+ </div>
988
+ </div>
989
+ </div>`);
990
+
991
+ const daysTemplate = optimizeTemplateHTML(`<div class="days">
992
+ <div class="days-of-week">${createTagRepeat('span', 7, {class: 'dow'})}</div>
993
+ <div class="datepicker-grid">${createTagRepeat('span', 42)}</div>
994
+ </div>`);
995
+
996
+ const calendarWeeksTemplate = optimizeTemplateHTML(`<div class="calendar-weeks">
997
+ <div class="days-of-week"><span class="dow"></span></div>
998
+ <div class="weeks">${createTagRepeat('span', 6, {class: 'week'})}</div>
999
+ </div>`);
1000
+
1001
+ // Base class of the view classes
1002
+ class View {
1003
+ constructor(picker, config) {
1004
+ Object.assign(this, config, {
1005
+ picker,
1006
+ element: parseHTML(`<div class="datepicker-view"></div>`).firstChild,
1007
+ selected: [],
1008
+ });
1009
+ this.init(this.picker.datepicker.config);
1010
+ }
1011
+
1012
+ init(options) {
1013
+ if (options.pickLevel !== undefined) {
1014
+ this.isMinView = this.id === options.pickLevel;
1015
+ }
1016
+ this.setOptions(options);
1017
+ this.updateFocus();
1018
+ this.updateSelection();
1019
+ }
1020
+
1021
+ // Execute beforeShow() callback and apply the result to the element
1022
+ // args:
1023
+ // - current - current value on the iteration on view rendering
1024
+ // - timeValue - time value of the date to pass to beforeShow()
1025
+ performBeforeHook(el, current, timeValue) {
1026
+ let result = this.beforeShow(new Date(timeValue));
1027
+ switch (typeof result) {
1028
+ case 'boolean':
1029
+ result = {enabled: result};
1030
+ break;
1031
+ case 'string':
1032
+ result = {classes: result};
1033
+ }
1034
+
1035
+ if (result) {
1036
+ if (result.enabled === false) {
1037
+ el.classList.add('disabled');
1038
+ pushUnique(this.disabled, current);
1039
+ }
1040
+ if (result.classes) {
1041
+ const extraClasses = result.classes.split(/\s+/);
1042
+ el.classList.add(...extraClasses);
1043
+ if (extraClasses.includes('disabled')) {
1044
+ pushUnique(this.disabled, current);
1045
+ }
1046
+ }
1047
+ if (result.content) {
1048
+ replaceChildNodes(el, result.content);
1049
+ }
1050
+ }
1051
+ }
1052
+ }
1053
+
1054
+ class DaysView extends View {
1055
+ constructor(picker) {
1056
+ super(picker, {
1057
+ id: 0,
1058
+ name: 'days',
1059
+ cellClass: 'day',
1060
+ });
1061
+ }
1062
+
1063
+ init(options, onConstruction = true) {
1064
+ if (onConstruction) {
1065
+ const inner = parseHTML(daysTemplate).firstChild;
1066
+ this.dow = inner.firstChild;
1067
+ this.grid = inner.lastChild;
1068
+ this.element.appendChild(inner);
1069
+ }
1070
+ super.init(options);
1071
+ }
1072
+
1073
+ setOptions(options) {
1074
+ let updateDOW;
1075
+
1076
+ if (hasProperty(options, 'minDate')) {
1077
+ this.minDate = options.minDate;
1078
+ }
1079
+ if (hasProperty(options, 'maxDate')) {
1080
+ this.maxDate = options.maxDate;
1081
+ }
1082
+ if (options.datesDisabled) {
1083
+ this.datesDisabled = options.datesDisabled;
1084
+ }
1085
+ if (options.daysOfWeekDisabled) {
1086
+ this.daysOfWeekDisabled = options.daysOfWeekDisabled;
1087
+ updateDOW = true;
1088
+ }
1089
+ if (options.daysOfWeekHighlighted) {
1090
+ this.daysOfWeekHighlighted = options.daysOfWeekHighlighted;
1091
+ }
1092
+ if (options.todayHighlight !== undefined) {
1093
+ this.todayHighlight = options.todayHighlight;
1094
+ }
1095
+ if (options.weekStart !== undefined) {
1096
+ this.weekStart = options.weekStart;
1097
+ this.weekEnd = options.weekEnd;
1098
+ updateDOW = true;
1099
+ }
1100
+ if (options.locale) {
1101
+ const locale = this.locale = options.locale;
1102
+ this.dayNames = locale.daysMin;
1103
+ this.switchLabelFormat = locale.titleFormat;
1104
+ updateDOW = true;
1105
+ }
1106
+ if (options.beforeShowDay !== undefined) {
1107
+ this.beforeShow = typeof options.beforeShowDay === 'function'
1108
+ ? options.beforeShowDay
1109
+ : undefined;
1110
+ }
1111
+
1112
+ if (options.calendarWeeks !== undefined) {
1113
+ if (options.calendarWeeks && !this.calendarWeeks) {
1114
+ const weeksElem = parseHTML(calendarWeeksTemplate).firstChild;
1115
+ this.calendarWeeks = {
1116
+ element: weeksElem,
1117
+ dow: weeksElem.firstChild,
1118
+ weeks: weeksElem.lastChild,
1119
+ };
1120
+ this.element.insertBefore(weeksElem, this.element.firstChild);
1121
+ } else if (this.calendarWeeks && !options.calendarWeeks) {
1122
+ this.element.removeChild(this.calendarWeeks.element);
1123
+ this.calendarWeeks = null;
1124
+ }
1125
+ }
1126
+ if (options.showDaysOfWeek !== undefined) {
1127
+ if (options.showDaysOfWeek) {
1128
+ showElement(this.dow);
1129
+ if (this.calendarWeeks) {
1130
+ showElement(this.calendarWeeks.dow);
1131
+ }
1132
+ } else {
1133
+ hideElement(this.dow);
1134
+ if (this.calendarWeeks) {
1135
+ hideElement(this.calendarWeeks.dow);
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+ // update days-of-week when locale, daysOfweekDisabled or weekStart is changed
1141
+ if (updateDOW) {
1142
+ Array.from(this.dow.children).forEach((el, index) => {
1143
+ const dow = (this.weekStart + index) % 7;
1144
+ el.textContent = this.dayNames[dow];
1145
+ el.className = this.daysOfWeekDisabled.includes(dow) ? 'dow disabled' : 'dow';
1146
+ });
1147
+ }
1148
+ }
1149
+
1150
+ // Apply update on the focused date to view's settings
1151
+ updateFocus() {
1152
+ const viewDate = new Date(this.picker.viewDate);
1153
+ const viewYear = viewDate.getFullYear();
1154
+ const viewMonth = viewDate.getMonth();
1155
+ const firstOfMonth = dateValue(viewYear, viewMonth, 1);
1156
+ const start = dayOfTheWeekOf(firstOfMonth, this.weekStart, this.weekStart);
1157
+
1158
+ this.first = firstOfMonth;
1159
+ this.last = dateValue(viewYear, viewMonth + 1, 0);
1160
+ this.start = start;
1161
+ this.focused = this.picker.viewDate;
1162
+ }
1163
+
1164
+ // Apply update on the selected dates to view's settings
1165
+ updateSelection() {
1166
+ const {dates, rangepicker} = this.picker.datepicker;
1167
+ this.selected = dates;
1168
+ if (rangepicker) {
1169
+ this.range = rangepicker.dates;
1170
+ }
1171
+ }
1172
+
1173
+ // Update the entire view UI
1174
+ render() {
1175
+ // update today marker on ever render
1176
+ this.today = this.todayHighlight ? today() : undefined;
1177
+ // refresh disabled dates on every render in order to clear the ones added
1178
+ // by beforeShow hook at previous render
1179
+ this.disabled = [...this.datesDisabled];
1180
+
1181
+ const switchLabel = formatDate(this.focused, this.switchLabelFormat, this.locale);
1182
+ this.picker.setViewSwitchLabel(switchLabel);
1183
+ this.picker.setPrevBtnDisabled(this.first <= this.minDate);
1184
+ this.picker.setNextBtnDisabled(this.last >= this.maxDate);
1185
+
1186
+ if (this.calendarWeeks) {
1187
+ // start of the UTC week (Monday) of the 1st of the month
1188
+ const startOfWeek = dayOfTheWeekOf(this.first, 1, 1);
1189
+ Array.from(this.calendarWeeks.weeks.children).forEach((el, index) => {
1190
+ el.textContent = getWeek(addWeeks(startOfWeek, index));
1191
+ });
1192
+ }
1193
+ Array.from(this.grid.children).forEach((el, index) => {
1194
+ const classList = el.classList;
1195
+ const current = addDays(this.start, index);
1196
+ const date = new Date(current);
1197
+ const day = date.getDay();
1198
+
1199
+ el.className = `datepicker-cell ${this.cellClass}`;
1200
+ el.dataset.date = current;
1201
+ el.textContent = date.getDate();
1202
+
1203
+ if (current < this.first) {
1204
+ classList.add('prev');
1205
+ } else if (current > this.last) {
1206
+ classList.add('next');
1207
+ }
1208
+ if (this.today === current) {
1209
+ classList.add('today');
1210
+ }
1211
+ if (current < this.minDate || current > this.maxDate || this.disabled.includes(current)) {
1212
+ classList.add('disabled');
1213
+ }
1214
+ if (this.daysOfWeekDisabled.includes(day)) {
1215
+ classList.add('disabled');
1216
+ pushUnique(this.disabled, current);
1217
+ }
1218
+ if (this.daysOfWeekHighlighted.includes(day)) {
1219
+ classList.add('highlighted');
1220
+ }
1221
+ if (this.range) {
1222
+ const [rangeStart, rangeEnd] = this.range;
1223
+ if (current > rangeStart && current < rangeEnd) {
1224
+ classList.add('range');
1225
+ }
1226
+ if (current === rangeStart) {
1227
+ classList.add('range-start');
1228
+ }
1229
+ if (current === rangeEnd) {
1230
+ classList.add('range-end');
1231
+ }
1232
+ }
1233
+ if (this.selected.includes(current)) {
1234
+ classList.add('selected');
1235
+ }
1236
+ if (current === this.focused) {
1237
+ classList.add('focused');
1238
+ }
1239
+
1240
+ if (this.beforeShow) {
1241
+ this.performBeforeHook(el, current, current);
1242
+ }
1243
+ });
1244
+ }
1245
+
1246
+ // Update the view UI by applying the changes of selected and focused items
1247
+ refresh() {
1248
+ const [rangeStart, rangeEnd] = this.range || [];
1249
+ this.grid
1250
+ .querySelectorAll('.range, .range-start, .range-end, .selected, .focused')
1251
+ .forEach((el) => {
1252
+ el.classList.remove('range', 'range-start', 'range-end', 'selected', 'focused');
1253
+ });
1254
+ Array.from(this.grid.children).forEach((el) => {
1255
+ const current = Number(el.dataset.date);
1256
+ const classList = el.classList;
1257
+ if (current > rangeStart && current < rangeEnd) {
1258
+ classList.add('range');
1259
+ }
1260
+ if (current === rangeStart) {
1261
+ classList.add('range-start');
1262
+ }
1263
+ if (current === rangeEnd) {
1264
+ classList.add('range-end');
1265
+ }
1266
+ if (this.selected.includes(current)) {
1267
+ classList.add('selected');
1268
+ }
1269
+ if (current === this.focused) {
1270
+ classList.add('focused');
1271
+ }
1272
+ });
1273
+ }
1274
+
1275
+ // Update the view UI by applying the change of focused item
1276
+ refreshFocus() {
1277
+ const index = Math.round((this.focused - this.start) / 86400000);
1278
+ this.grid.querySelectorAll('.focused').forEach((el) => {
1279
+ el.classList.remove('focused');
1280
+ });
1281
+ this.grid.children[index].classList.add('focused');
1282
+ }
1283
+ }
1284
+
1285
+ function computeMonthRange(range, thisYear) {
1286
+ if (!range || !range[0] || !range[1]) {
1287
+ return;
1288
+ }
1289
+
1290
+ const [[startY, startM], [endY, endM]] = range;
1291
+ if (startY > thisYear || endY < thisYear) {
1292
+ return;
1293
+ }
1294
+ return [
1295
+ startY === thisYear ? startM : -1,
1296
+ endY === thisYear ? endM : 12,
1297
+ ];
1298
+ }
1299
+
1300
+ class MonthsView extends View {
1301
+ constructor(picker) {
1302
+ super(picker, {
1303
+ id: 1,
1304
+ name: 'months',
1305
+ cellClass: 'month',
1306
+ });
1307
+ }
1308
+
1309
+ init(options, onConstruction = true) {
1310
+ if (onConstruction) {
1311
+ this.grid = this.element;
1312
+ this.element.classList.add('months', 'datepicker-grid');
1313
+ this.grid.appendChild(parseHTML(createTagRepeat('span', 12, {'data-month': ix => ix})));
1314
+ }
1315
+ super.init(options);
1316
+ }
1317
+
1318
+ setOptions(options) {
1319
+ if (options.locale) {
1320
+ this.monthNames = options.locale.monthsShort;
1321
+ }
1322
+ if (hasProperty(options, 'minDate')) {
1323
+ if (options.minDate === undefined) {
1324
+ this.minYear = this.minMonth = this.minDate = undefined;
1325
+ } else {
1326
+ const minDateObj = new Date(options.minDate);
1327
+ this.minYear = minDateObj.getFullYear();
1328
+ this.minMonth = minDateObj.getMonth();
1329
+ this.minDate = minDateObj.setDate(1);
1330
+ }
1331
+ }
1332
+ if (hasProperty(options, 'maxDate')) {
1333
+ if (options.maxDate === undefined) {
1334
+ this.maxYear = this.maxMonth = this.maxDate = undefined;
1335
+ } else {
1336
+ const maxDateObj = new Date(options.maxDate);
1337
+ this.maxYear = maxDateObj.getFullYear();
1338
+ this.maxMonth = maxDateObj.getMonth();
1339
+ this.maxDate = dateValue(this.maxYear, this.maxMonth + 1, 0);
1340
+ }
1341
+ }
1342
+ if (this.isMinView) {
1343
+ if (options.datesDisabled) {
1344
+ this.datesDisabled = options.datesDisabled;
1345
+ }
1346
+ } else {
1347
+ this.datesDisabled = [];
1348
+ }
1349
+ if (options.beforeShowMonth !== undefined) {
1350
+ this.beforeShow = typeof options.beforeShowMonth === 'function'
1351
+ ? options.beforeShowMonth
1352
+ : undefined;
1353
+ }
1354
+ }
1355
+
1356
+ // Update view's settings to reflect the viewDate set on the picker
1357
+ updateFocus() {
1358
+ const viewDate = new Date(this.picker.viewDate);
1359
+ this.year = viewDate.getFullYear();
1360
+ this.focused = viewDate.getMonth();
1361
+ }
1362
+
1363
+ // Update view's settings to reflect the selected dates
1364
+ updateSelection() {
1365
+ const {dates, rangepicker} = this.picker.datepicker;
1366
+ this.selected = dates.reduce((selected, timeValue) => {
1367
+ const date = new Date(timeValue);
1368
+ const year = date.getFullYear();
1369
+ const month = date.getMonth();
1370
+ if (selected[year] === undefined) {
1371
+ selected[year] = [month];
1372
+ } else {
1373
+ pushUnique(selected[year], month);
1374
+ }
1375
+ return selected;
1376
+ }, {});
1377
+ if (rangepicker && rangepicker.dates) {
1378
+ this.range = rangepicker.dates.map(timeValue => {
1379
+ const date = new Date(timeValue);
1380
+ return isNaN(date) ? undefined : [date.getFullYear(), date.getMonth()];
1381
+ });
1382
+ }
1383
+ }
1384
+
1385
+ // Update the entire view UI
1386
+ render() {
1387
+ // refresh disabled months on every render in order to clear the ones added
1388
+ // by beforeShow hook at previous render
1389
+ // this.disabled = [...this.datesDisabled];
1390
+ this.disabled = this.datesDisabled.reduce((arr, disabled) => {
1391
+ const dt = new Date(disabled);
1392
+ if (this.year === dt.getFullYear()) {
1393
+ arr.push(dt.getMonth());
1394
+ }
1395
+ return arr;
1396
+ }, []);
1397
+
1398
+ this.picker.setViewSwitchLabel(this.year);
1399
+ this.picker.setPrevBtnDisabled(this.year <= this.minYear);
1400
+ this.picker.setNextBtnDisabled(this.year >= this.maxYear);
1401
+
1402
+ const selected = this.selected[this.year] || [];
1403
+ const yrOutOfRange = this.year < this.minYear || this.year > this.maxYear;
1404
+ const isMinYear = this.year === this.minYear;
1405
+ const isMaxYear = this.year === this.maxYear;
1406
+ const range = computeMonthRange(this.range, this.year);
1407
+
1408
+ Array.from(this.grid.children).forEach((el, index) => {
1409
+ const classList = el.classList;
1410
+ const date = dateValue(this.year, index, 1);
1411
+
1412
+ el.className = `datepicker-cell ${this.cellClass}`;
1413
+ if (this.isMinView) {
1414
+ el.dataset.date = date;
1415
+ }
1416
+ // reset text on every render to clear the custom content set
1417
+ // by beforeShow hook at previous render
1418
+ el.textContent = this.monthNames[index];
1419
+
1420
+ if (
1421
+ yrOutOfRange
1422
+ || isMinYear && index < this.minMonth
1423
+ || isMaxYear && index > this.maxMonth
1424
+ || this.disabled.includes(index)
1425
+ ) {
1426
+ classList.add('disabled');
1427
+ }
1428
+ if (range) {
1429
+ const [rangeStart, rangeEnd] = range;
1430
+ if (index > rangeStart && index < rangeEnd) {
1431
+ classList.add('range');
1432
+ }
1433
+ if (index === rangeStart) {
1434
+ classList.add('range-start');
1435
+ }
1436
+ if (index === rangeEnd) {
1437
+ classList.add('range-end');
1438
+ }
1439
+ }
1440
+ if (selected.includes(index)) {
1441
+ classList.add('selected');
1442
+ }
1443
+ if (index === this.focused) {
1444
+ classList.add('focused');
1445
+ }
1446
+
1447
+ if (this.beforeShow) {
1448
+ this.performBeforeHook(el, index, date);
1449
+ }
1450
+ });
1451
+ }
1452
+
1453
+ // Update the view UI by applying the changes of selected and focused items
1454
+ refresh() {
1455
+ const selected = this.selected[this.year] || [];
1456
+ const [rangeStart, rangeEnd] = computeMonthRange(this.range, this.year) || [];
1457
+ this.grid
1458
+ .querySelectorAll('.range, .range-start, .range-end, .selected, .focused')
1459
+ .forEach((el) => {
1460
+ el.classList.remove('range', 'range-start', 'range-end', 'selected', 'focused');
1461
+ });
1462
+ Array.from(this.grid.children).forEach((el, index) => {
1463
+ const classList = el.classList;
1464
+ if (index > rangeStart && index < rangeEnd) {
1465
+ classList.add('range');
1466
+ }
1467
+ if (index === rangeStart) {
1468
+ classList.add('range-start');
1469
+ }
1470
+ if (index === rangeEnd) {
1471
+ classList.add('range-end');
1472
+ }
1473
+ if (selected.includes(index)) {
1474
+ classList.add('selected');
1475
+ }
1476
+ if (index === this.focused) {
1477
+ classList.add('focused');
1478
+ }
1479
+ });
1480
+ }
1481
+
1482
+ // Update the view UI by applying the change of focused item
1483
+ refreshFocus() {
1484
+ this.grid.querySelectorAll('.focused').forEach((el) => {
1485
+ el.classList.remove('focused');
1486
+ });
1487
+ this.grid.children[this.focused].classList.add('focused');
1488
+ }
1489
+ }
1490
+
1491
+ function toTitleCase(word) {
1492
+ return [...word].reduce((str, ch, ix) => str += ix ? ch : ch.toUpperCase(), '');
1493
+ }
1494
+
1495
+ // Class representing the years and decades view elements
1496
+ class YearsView extends View {
1497
+ constructor(picker, config) {
1498
+ super(picker, config);
1499
+ }
1500
+
1501
+ init(options, onConstruction = true) {
1502
+ if (onConstruction) {
1503
+ this.navStep = this.step * 10;
1504
+ this.beforeShowOption = `beforeShow${toTitleCase(this.cellClass)}`;
1505
+ this.grid = this.element;
1506
+ this.element.classList.add(this.name, 'datepicker-grid');
1507
+ this.grid.appendChild(parseHTML(createTagRepeat('span', 12)));
1508
+ }
1509
+ super.init(options);
1510
+ }
1511
+
1512
+ setOptions(options) {
1513
+ if (hasProperty(options, 'minDate')) {
1514
+ if (options.minDate === undefined) {
1515
+ this.minYear = this.minDate = undefined;
1516
+ } else {
1517
+ this.minYear = startOfYearPeriod(options.minDate, this.step);
1518
+ this.minDate = dateValue(this.minYear, 0, 1);
1519
+ }
1520
+ }
1521
+ if (hasProperty(options, 'maxDate')) {
1522
+ if (options.maxDate === undefined) {
1523
+ this.maxYear = this.maxDate = undefined;
1524
+ } else {
1525
+ this.maxYear = startOfYearPeriod(options.maxDate, this.step);
1526
+ this.maxDate = dateValue(this.maxYear, 11, 31);
1527
+ }
1528
+ }
1529
+ if (this.isMinView) {
1530
+ if (options.datesDisabled) {
1531
+ this.datesDisabled = options.datesDisabled;
1532
+ }
1533
+ } else {
1534
+ this.datesDisabled = [];
1535
+ }
1536
+ if (options[this.beforeShowOption] !== undefined) {
1537
+ const beforeShow = options[this.beforeShowOption];
1538
+ this.beforeShow = typeof beforeShow === 'function' ? beforeShow : undefined;
1539
+ }
1540
+ }
1541
+
1542
+ // Update view's settings to reflect the viewDate set on the picker
1543
+ updateFocus() {
1544
+ const viewDate = new Date(this.picker.viewDate);
1545
+ const first = startOfYearPeriod(viewDate, this.navStep);
1546
+ const last = first + 9 * this.step;
1547
+
1548
+ this.first = first;
1549
+ this.last = last;
1550
+ this.start = first - this.step;
1551
+ this.focused = startOfYearPeriod(viewDate, this.step);
1552
+ }
1553
+
1554
+ // Update view's settings to reflect the selected dates
1555
+ updateSelection() {
1556
+ const {dates, rangepicker} = this.picker.datepicker;
1557
+ this.selected = dates.reduce((years, timeValue) => {
1558
+ return pushUnique(years, startOfYearPeriod(timeValue, this.step));
1559
+ }, []);
1560
+ if (rangepicker && rangepicker.dates) {
1561
+ this.range = rangepicker.dates.map(timeValue => {
1562
+ if (timeValue !== undefined) {
1563
+ return startOfYearPeriod(timeValue, this.step);
1564
+ }
1565
+ });
1566
+ }
1567
+ }
1568
+
1569
+ // Update the entire view UI
1570
+ render() {
1571
+ // refresh disabled years on every render in order to clear the ones added
1572
+ // by beforeShow hook at previous render
1573
+ // this.disabled = [...this.datesDisabled];
1574
+ this.disabled = this.datesDisabled.map(disabled => new Date(disabled).getFullYear());
1575
+
1576
+ this.picker.setViewSwitchLabel(`${this.first}-${this.last}`);
1577
+ this.picker.setPrevBtnDisabled(this.first <= this.minYear);
1578
+ this.picker.setNextBtnDisabled(this.last >= this.maxYear);
1579
+
1580
+ Array.from(this.grid.children).forEach((el, index) => {
1581
+ const classList = el.classList;
1582
+ const current = this.start + (index * this.step);
1583
+ const date = dateValue(current, 0, 1);
1584
+
1585
+ el.className = `datepicker-cell ${this.cellClass}`;
1586
+ if (this.isMinView) {
1587
+ el.dataset.date = date;
1588
+ }
1589
+ el.textContent = el.dataset.year = current;
1590
+
1591
+ if (index === 0) {
1592
+ classList.add('prev');
1593
+ } else if (index === 11) {
1594
+ classList.add('next');
1595
+ }
1596
+ if (current < this.minYear || current > this.maxYear || this.disabled.includes(current)) {
1597
+ classList.add('disabled');
1598
+ }
1599
+ if (this.range) {
1600
+ const [rangeStart, rangeEnd] = this.range;
1601
+ if (current > rangeStart && current < rangeEnd) {
1602
+ classList.add('range');
1603
+ }
1604
+ if (current === rangeStart) {
1605
+ classList.add('range-start');
1606
+ }
1607
+ if (current === rangeEnd) {
1608
+ classList.add('range-end');
1609
+ }
1610
+ }
1611
+ if (this.selected.includes(current)) {
1612
+ classList.add('selected');
1613
+ }
1614
+ if (current === this.focused) {
1615
+ classList.add('focused');
1616
+ }
1617
+
1618
+ if (this.beforeShow) {
1619
+ this.performBeforeHook(el, current, date);
1620
+ }
1621
+ });
1622
+ }
1623
+
1624
+ // Update the view UI by applying the changes of selected and focused items
1625
+ refresh() {
1626
+ const [rangeStart, rangeEnd] = this.range || [];
1627
+ this.grid
1628
+ .querySelectorAll('.range, .range-start, .range-end, .selected, .focused')
1629
+ .forEach((el) => {
1630
+ el.classList.remove('range', 'range-start', 'range-end', 'selected', 'focused');
1631
+ });
1632
+ Array.from(this.grid.children).forEach((el) => {
1633
+ const current = Number(el.textContent);
1634
+ const classList = el.classList;
1635
+ if (current > rangeStart && current < rangeEnd) {
1636
+ classList.add('range');
1637
+ }
1638
+ if (current === rangeStart) {
1639
+ classList.add('range-start');
1640
+ }
1641
+ if (current === rangeEnd) {
1642
+ classList.add('range-end');
1643
+ }
1644
+ if (this.selected.includes(current)) {
1645
+ classList.add('selected');
1646
+ }
1647
+ if (current === this.focused) {
1648
+ classList.add('focused');
1649
+ }
1650
+ });
1651
+ }
1652
+
1653
+ // Update the view UI by applying the change of focused item
1654
+ refreshFocus() {
1655
+ const index = Math.round((this.focused - this.start) / this.step);
1656
+ this.grid.querySelectorAll('.focused').forEach((el) => {
1657
+ el.classList.remove('focused');
1658
+ });
1659
+ this.grid.children[index].classList.add('focused');
1660
+ }
1661
+ }
1662
+
1663
+ function triggerDatepickerEvent(datepicker, type) {
1664
+ const detail = {
1665
+ date: datepicker.getDate(),
1666
+ viewDate: new Date(datepicker.picker.viewDate),
1667
+ viewId: datepicker.picker.currentView.id,
1668
+ datepicker,
1669
+ };
1670
+ datepicker.element.dispatchEvent(new CustomEvent(type, {detail}));
1671
+ }
1672
+
1673
+ // direction: -1 (to previous), 1 (to next)
1674
+ function goToPrevOrNext(datepicker, direction) {
1675
+ const {minDate, maxDate} = datepicker.config;
1676
+ const {currentView, viewDate} = datepicker.picker;
1677
+ let newViewDate;
1678
+ switch (currentView.id) {
1679
+ case 0:
1680
+ newViewDate = addMonths(viewDate, direction);
1681
+ break;
1682
+ case 1:
1683
+ newViewDate = addYears(viewDate, direction);
1684
+ break;
1685
+ default:
1686
+ newViewDate = addYears(viewDate, direction * currentView.navStep);
1687
+ }
1688
+ newViewDate = limitToRange(newViewDate, minDate, maxDate);
1689
+ datepicker.picker.changeFocus(newViewDate).render();
1690
+ }
1691
+
1692
+ function switchView(datepicker) {
1693
+ const viewId = datepicker.picker.currentView.id;
1694
+ if (viewId === datepicker.config.maxView) {
1695
+ return;
1696
+ }
1697
+ datepicker.picker.changeView(viewId + 1).render();
1698
+ }
1699
+
1700
+ function unfocus(datepicker) {
1701
+ if (datepicker.config.updateOnBlur) {
1702
+ datepicker.update({revert: true});
1703
+ } else {
1704
+ datepicker.refresh('input');
1705
+ }
1706
+ datepicker.hide();
1707
+ }
1708
+
1709
+ function goToSelectedMonthOrYear(datepicker, selection) {
1710
+ const picker = datepicker.picker;
1711
+ const viewDate = new Date(picker.viewDate);
1712
+ const viewId = picker.currentView.id;
1713
+ const newDate = viewId === 1
1714
+ ? addMonths(viewDate, selection - viewDate.getMonth())
1715
+ : addYears(viewDate, selection - viewDate.getFullYear());
1716
+
1717
+ picker.changeFocus(newDate).changeView(viewId - 1).render();
1718
+ }
1719
+
1720
+ function onClickTodayBtn(datepicker) {
1721
+ const picker = datepicker.picker;
1722
+ const currentDate = today();
1723
+ if (datepicker.config.todayBtnMode === 1) {
1724
+ if (datepicker.config.autohide) {
1725
+ datepicker.setDate(currentDate);
1726
+ return;
1727
+ }
1728
+ datepicker.setDate(currentDate, {render: false});
1729
+ picker.update();
1730
+ }
1731
+ if (picker.viewDate !== currentDate) {
1732
+ picker.changeFocus(currentDate);
1733
+ }
1734
+ picker.changeView(0).render();
1735
+ }
1736
+
1737
+ function onClickClearBtn(datepicker) {
1738
+ datepicker.setDate({clear: true});
1739
+ }
1740
+
1741
+ function onClickViewSwitch(datepicker) {
1742
+ switchView(datepicker);
1743
+ }
1744
+
1745
+ function onClickPrevBtn(datepicker) {
1746
+ goToPrevOrNext(datepicker, -1);
1747
+ }
1748
+
1749
+ function onClickNextBtn(datepicker) {
1750
+ goToPrevOrNext(datepicker, 1);
1751
+ }
1752
+
1753
+ // For the picker's main block to delegete the events from `datepicker-cell`s
1754
+ function onClickView(datepicker, ev) {
1755
+ const target = findElementInEventPath(ev, '.datepicker-cell');
1756
+ if (!target || target.classList.contains('disabled')) {
1757
+ return;
1758
+ }
1759
+
1760
+ const {id, isMinView} = datepicker.picker.currentView;
1761
+ if (isMinView) {
1762
+ datepicker.setDate(Number(target.dataset.date));
1763
+ } else if (id === 1) {
1764
+ goToSelectedMonthOrYear(datepicker, Number(target.dataset.month));
1765
+ } else {
1766
+ goToSelectedMonthOrYear(datepicker, Number(target.dataset.year));
1767
+ }
1768
+ }
1769
+
1770
+ function onMousedownPicker(ev) {
1771
+ ev.preventDefault();
1772
+ }
1773
+
1774
+ const orientClasses = ['left', 'top', 'right', 'bottom'].reduce((obj, key) => {
1775
+ obj[key] = `datepicker-orient-${key}`;
1776
+ return obj;
1777
+ }, {});
1778
+ const toPx = num => num ? `${num}px` : num;
1779
+
1780
+ function processPickerOptions(picker, options) {
1781
+ if (options.title !== undefined) {
1782
+ if (options.title) {
1783
+ picker.controls.title.textContent = options.title;
1784
+ showElement(picker.controls.title);
1785
+ } else {
1786
+ picker.controls.title.textContent = '';
1787
+ hideElement(picker.controls.title);
1788
+ }
1789
+ }
1790
+ if (options.prevArrow) {
1791
+ const prevBtn = picker.controls.prevBtn;
1792
+ emptyChildNodes(prevBtn);
1793
+ options.prevArrow.forEach((node) => {
1794
+ prevBtn.appendChild(node.cloneNode(true));
1795
+ });
1796
+ }
1797
+ if (options.nextArrow) {
1798
+ const nextBtn = picker.controls.nextBtn;
1799
+ emptyChildNodes(nextBtn);
1800
+ options.nextArrow.forEach((node) => {
1801
+ nextBtn.appendChild(node.cloneNode(true));
1802
+ });
1803
+ }
1804
+ if (options.locale) {
1805
+ picker.controls.todayBtn.textContent = options.locale.today;
1806
+ picker.controls.clearBtn.textContent = options.locale.clear;
1807
+ }
1808
+ if (options.todayBtn !== undefined) {
1809
+ if (options.todayBtn) {
1810
+ showElement(picker.controls.todayBtn);
1811
+ } else {
1812
+ hideElement(picker.controls.todayBtn);
1813
+ }
1814
+ }
1815
+ if (hasProperty(options, 'minDate') || hasProperty(options, 'maxDate')) {
1816
+ const {minDate, maxDate} = picker.datepicker.config;
1817
+ picker.controls.todayBtn.disabled = !isInRange(today(), minDate, maxDate);
1818
+ }
1819
+ if (options.clearBtn !== undefined) {
1820
+ if (options.clearBtn) {
1821
+ showElement(picker.controls.clearBtn);
1822
+ } else {
1823
+ hideElement(picker.controls.clearBtn);
1824
+ }
1825
+ }
1826
+ }
1827
+
1828
+ // Compute view date to reset, which will be...
1829
+ // - the last item of the selected dates or defaultViewDate if no selection
1830
+ // - limitted to minDate or maxDate if it exceeds the range
1831
+ function computeResetViewDate(datepicker) {
1832
+ const {dates, config} = datepicker;
1833
+ const viewDate = dates.length > 0 ? lastItemOf(dates) : config.defaultViewDate;
1834
+ return limitToRange(viewDate, config.minDate, config.maxDate);
1835
+ }
1836
+
1837
+ // Change current view's view date
1838
+ function setViewDate(picker, newDate) {
1839
+ const oldViewDate = new Date(picker.viewDate);
1840
+ const newViewDate = new Date(newDate);
1841
+ const {id, year, first, last} = picker.currentView;
1842
+ const viewYear = newViewDate.getFullYear();
1843
+
1844
+ picker.viewDate = newDate;
1845
+ if (viewYear !== oldViewDate.getFullYear()) {
1846
+ triggerDatepickerEvent(picker.datepicker, 'changeYear');
1847
+ }
1848
+ if (newViewDate.getMonth() !== oldViewDate.getMonth()) {
1849
+ triggerDatepickerEvent(picker.datepicker, 'changeMonth');
1850
+ }
1851
+
1852
+ // return whether the new date is in different period on time from the one
1853
+ // displayed in the current view
1854
+ // when true, the view needs to be re-rendered on the next UI refresh.
1855
+ switch (id) {
1856
+ case 0:
1857
+ return newDate < first || newDate > last;
1858
+ case 1:
1859
+ return viewYear !== year;
1860
+ default:
1861
+ return viewYear < first || viewYear > last;
1862
+ }
1863
+ }
1864
+
1865
+ function getTextDirection(el) {
1866
+ return window.getComputedStyle(el).direction;
1867
+ }
1868
+
1869
+ // find the closet scrollable ancestor elemnt under the body
1870
+ function findScrollParents(el) {
1871
+ const parent = getParent(el);
1872
+ if (parent === document.body || !parent) {
1873
+ return;
1874
+ }
1875
+
1876
+ // checking overflow only is enough because computed overflow cannot be
1877
+ // visible or a combination of visible and other when either axis is set
1878
+ // to other than visible.
1879
+ // (Setting one axis to other than 'visible' while the other is 'visible'
1880
+ // results in the other axis turning to 'auto')
1881
+ return window.getComputedStyle(parent).overflow !== 'visible'
1882
+ ? parent
1883
+ : findScrollParents(parent);
1884
+ }
1885
+
1886
+ // Class representing the picker UI
1887
+ class Picker {
1888
+ constructor(datepicker) {
1889
+ const {config} = this.datepicker = datepicker;
1890
+
1891
+ const template = pickerTemplate.replace(/%buttonClass%/g, config.buttonClass);
1892
+ const element = this.element = parseHTML(template).firstChild;
1893
+ const [header, main, footer] = element.firstChild.children;
1894
+ const title = header.firstElementChild;
1895
+ const [prevBtn, viewSwitch, nextBtn] = header.lastElementChild.children;
1896
+ const [todayBtn, clearBtn] = footer.firstChild.children;
1897
+ const controls = {
1898
+ title,
1899
+ prevBtn,
1900
+ viewSwitch,
1901
+ nextBtn,
1902
+ todayBtn,
1903
+ clearBtn,
1904
+ };
1905
+ this.main = main;
1906
+ this.controls = controls;
1907
+
1908
+ const elementClass = datepicker.inline ? 'inline' : 'dropdown';
1909
+ element.classList.add(`datepicker-${elementClass}`);
1910
+
1911
+ processPickerOptions(this, config);
1912
+ this.viewDate = computeResetViewDate(datepicker);
1913
+
1914
+ // set up event listeners
1915
+ registerListeners(datepicker, [
1916
+ [element, 'mousedown', onMousedownPicker],
1917
+ [main, 'click', onClickView.bind(null, datepicker)],
1918
+ [controls.viewSwitch, 'click', onClickViewSwitch.bind(null, datepicker)],
1919
+ [controls.prevBtn, 'click', onClickPrevBtn.bind(null, datepicker)],
1920
+ [controls.nextBtn, 'click', onClickNextBtn.bind(null, datepicker)],
1921
+ [controls.todayBtn, 'click', onClickTodayBtn.bind(null, datepicker)],
1922
+ [controls.clearBtn, 'click', onClickClearBtn.bind(null, datepicker)],
1923
+ ]);
1924
+
1925
+ // set up views
1926
+ this.views = [
1927
+ new DaysView(this),
1928
+ new MonthsView(this),
1929
+ new YearsView(this, {id: 2, name: 'years', cellClass: 'year', step: 1}),
1930
+ new YearsView(this, {id: 3, name: 'decades', cellClass: 'decade', step: 10}),
1931
+ ];
1932
+ this.currentView = this.views[config.startView];
1933
+
1934
+ this.currentView.render();
1935
+ this.main.appendChild(this.currentView.element);
1936
+ if (config.container) {
1937
+ config.container.appendChild(this.element);
1938
+ } else {
1939
+ datepicker.inputField.after(this.element);
1940
+ }
1941
+ }
1942
+
1943
+ setOptions(options) {
1944
+ processPickerOptions(this, options);
1945
+ this.views.forEach((view) => {
1946
+ view.init(options, false);
1947
+ });
1948
+ this.currentView.render();
1949
+ }
1950
+
1951
+ detach() {
1952
+ this.element.remove();
1953
+ }
1954
+
1955
+ show() {
1956
+ if (this.active) {
1957
+ return;
1958
+ }
1959
+
1960
+ const {datepicker, element} = this;
1961
+ if (datepicker.inline) {
1962
+ element.classList.add('active');
1963
+ } else {
1964
+ // ensure picker's direction matches input's
1965
+ const inputDirection = getTextDirection(datepicker.inputField);
1966
+ if (inputDirection !== getTextDirection(getParent(element))) {
1967
+ element.dir = inputDirection;
1968
+ } else if (element.dir) {
1969
+ element.removeAttribute('dir');
1970
+ }
1971
+
1972
+ element.style.visiblity = 'hidden';
1973
+ element.classList.add('active');
1974
+ this.place();
1975
+ element.style.visiblity = '';
1976
+
1977
+ if (datepicker.config.disableTouchKeyboard) {
1978
+ datepicker.inputField.blur();
1979
+ }
1980
+ }
1981
+ this.active = true;
1982
+ triggerDatepickerEvent(datepicker, 'show');
1983
+ }
1984
+
1985
+ hide() {
1986
+ if (!this.active) {
1987
+ return;
1988
+ }
1989
+ this.datepicker.exitEditMode();
1990
+ this.element.classList.remove('active');
1991
+ this.active = false;
1992
+ triggerDatepickerEvent(this.datepicker, 'hide');
1993
+ }
1994
+
1995
+ place() {
1996
+ const {classList, offsetParent, style} = this.element;
1997
+ const {config, inputField} = this.datepicker;
1998
+ const {
1999
+ width: calendarWidth,
2000
+ height: calendarHeight,
2001
+ } = this.element.getBoundingClientRect();
2002
+ const {
2003
+ left: inputLeft,
2004
+ top: inputTop,
2005
+ right: inputRight,
2006
+ bottom: inputBottom,
2007
+ width: inputWidth,
2008
+ height: inputHeight
2009
+ } = inputField.getBoundingClientRect();
2010
+ let {x: orientX, y: orientY} = config.orientation;
2011
+ let left = inputLeft;
2012
+ let top = inputTop;
2013
+
2014
+ // caliculate offsetLeft/Top of inputField
2015
+ if (offsetParent === document.body || !offsetParent) {
2016
+ left += window.scrollX;
2017
+ top += window.scrollY;
2018
+ } else {
2019
+ const offsetParentRect = offsetParent.getBoundingClientRect();
2020
+ left -= offsetParentRect.left - offsetParent.scrollLeft;
2021
+ top -= offsetParentRect.top - offsetParent.scrollTop;
2022
+ }
2023
+
2024
+ // caliculate the boundaries of the visible area that contains inputField
2025
+ const scrollParent = findScrollParents(inputField);
2026
+ let scrollAreaLeft = 0;
2027
+ let scrollAreaTop = 0;
2028
+ let {
2029
+ clientWidth: scrollAreaRight,
2030
+ clientHeight: scrollAreaBottom,
2031
+ } = document.documentElement;
2032
+
2033
+ if (scrollParent) {
2034
+ const scrollParentRect = scrollParent.getBoundingClientRect();
2035
+ if (scrollParentRect.top > 0) {
2036
+ scrollAreaTop = scrollParentRect.top;
2037
+ }
2038
+ if (scrollParentRect.left > 0) {
2039
+ scrollAreaLeft = scrollParentRect.left;
2040
+ }
2041
+ if (scrollParentRect.right < scrollAreaRight) {
2042
+ scrollAreaRight = scrollParentRect.right;
2043
+ }
2044
+ if (scrollParentRect.bottom < scrollAreaBottom) {
2045
+ scrollAreaBottom = scrollParentRect.bottom;
2046
+ }
2047
+ }
2048
+
2049
+ // determine the horizontal orientation and left position
2050
+ let adjustment = 0;
2051
+ if (orientX === 'auto') {
2052
+ if (inputLeft < scrollAreaLeft) {
2053
+ orientX = 'left';
2054
+ adjustment = scrollAreaLeft - inputLeft;
2055
+ } else if (inputLeft + calendarWidth > scrollAreaRight) {
2056
+ orientX = 'right';
2057
+ if (scrollAreaRight < inputRight) {
2058
+ adjustment = scrollAreaRight - inputRight;
2059
+ }
2060
+ } else if (getTextDirection(inputField) === 'rtl') {
2061
+ orientX = inputRight - calendarWidth < scrollAreaLeft ? 'left' : 'right';
2062
+ } else {
2063
+ orientX = 'left';
2064
+ }
2065
+ }
2066
+ if (orientX === 'right') {
2067
+ left += inputWidth - calendarWidth;
2068
+ }
2069
+ left += adjustment;
2070
+
2071
+ // determine the vertical orientation and top position
2072
+ if (orientY === 'auto') {
2073
+ if (inputTop - calendarHeight > scrollAreaTop) {
2074
+ orientY = inputBottom + calendarHeight > scrollAreaBottom ? 'top' : 'bottom';
2075
+ } else {
2076
+ orientY = 'bottom';
2077
+ }
2078
+ }
2079
+ if (orientY === 'top') {
2080
+ top -= calendarHeight;
2081
+ } else {
2082
+ top += inputHeight;
2083
+ }
2084
+
2085
+ classList.remove(...Object.values(orientClasses));
2086
+ classList.add(orientClasses[orientX], orientClasses[orientY]);
2087
+
2088
+ style.left = toPx(left);
2089
+ style.top = toPx(top);
2090
+ }
2091
+
2092
+ setViewSwitchLabel(labelText) {
2093
+ this.controls.viewSwitch.textContent = labelText;
2094
+ }
2095
+
2096
+ setPrevBtnDisabled(disabled) {
2097
+ this.controls.prevBtn.disabled = disabled;
2098
+ }
2099
+
2100
+ setNextBtnDisabled(disabled) {
2101
+ this.controls.nextBtn.disabled = disabled;
2102
+ }
2103
+
2104
+ changeView(viewId) {
2105
+ const oldView = this.currentView;
2106
+ const newView = this.views[viewId];
2107
+ if (newView.id !== oldView.id) {
2108
+ this.currentView = newView;
2109
+ this._renderMethod = 'render';
2110
+ triggerDatepickerEvent(this.datepicker, 'changeView');
2111
+ this.main.replaceChild(newView.element, oldView.element);
2112
+ }
2113
+ return this;
2114
+ }
2115
+
2116
+ // Change the focused date (view date)
2117
+ changeFocus(newViewDate) {
2118
+ this._renderMethod = setViewDate(this, newViewDate) ? 'render' : 'refreshFocus';
2119
+ this.views.forEach((view) => {
2120
+ view.updateFocus();
2121
+ });
2122
+ return this;
2123
+ }
2124
+
2125
+ // Apply the change of the selected dates
2126
+ update() {
2127
+ const newViewDate = computeResetViewDate(this.datepicker);
2128
+ this._renderMethod = setViewDate(this, newViewDate) ? 'render' : 'refresh';
2129
+ this.views.forEach((view) => {
2130
+ view.updateFocus();
2131
+ view.updateSelection();
2132
+ });
2133
+ return this;
2134
+ }
2135
+
2136
+ // Refresh the picker UI
2137
+ render(quickRender = true) {
2138
+ const renderMethod = (quickRender && this._renderMethod) || 'render';
2139
+ delete this._renderMethod;
2140
+
2141
+ this.currentView[renderMethod]();
2142
+ }
2143
+ }
2144
+
2145
+ // Find the closest date that doesn't meet the condition for unavailable date
2146
+ // Returns undefined if no available date is found
2147
+ // addFn: function to calculate the next date
2148
+ // - args: time value, amount
2149
+ // increase: amount to pass to addFn
2150
+ // testFn: function to test the unavailablity of the date
2151
+ // - args: time value; retun: true if unavailable
2152
+ function findNextAvailableOne(date, addFn, increase, testFn, min, max) {
2153
+ if (!isInRange(date, min, max)) {
2154
+ return;
2155
+ }
2156
+ if (testFn(date)) {
2157
+ const newDate = addFn(date, increase);
2158
+ return findNextAvailableOne(newDate, addFn, increase, testFn, min, max);
2159
+ }
2160
+ return date;
2161
+ }
2162
+
2163
+ // direction: -1 (left/up), 1 (right/down)
2164
+ // vertical: true for up/down, false for left/right
2165
+ function moveByArrowKey(datepicker, ev, direction, vertical) {
2166
+ const picker = datepicker.picker;
2167
+ const currentView = picker.currentView;
2168
+ const step = currentView.step || 1;
2169
+ let viewDate = picker.viewDate;
2170
+ let addFn;
2171
+ let testFn;
2172
+ switch (currentView.id) {
2173
+ case 0:
2174
+ if (vertical) {
2175
+ viewDate = addDays(viewDate, direction * 7);
2176
+ } else if (ev.ctrlKey || ev.metaKey) {
2177
+ viewDate = addYears(viewDate, direction);
2178
+ } else {
2179
+ viewDate = addDays(viewDate, direction);
2180
+ }
2181
+ addFn = addDays;
2182
+ testFn = (date) => currentView.disabled.includes(date);
2183
+ break;
2184
+ case 1:
2185
+ viewDate = addMonths(viewDate, vertical ? direction * 4 : direction);
2186
+ addFn = addMonths;
2187
+ testFn = (date) => {
2188
+ const dt = new Date(date);
2189
+ const {year, disabled} = currentView;
2190
+ return dt.getFullYear() === year && disabled.includes(dt.getMonth());
2191
+ };
2192
+ break;
2193
+ default:
2194
+ viewDate = addYears(viewDate, direction * (vertical ? 4 : 1) * step);
2195
+ addFn = addYears;
2196
+ testFn = date => currentView.disabled.includes(startOfYearPeriod(date, step));
2197
+ }
2198
+ viewDate = findNextAvailableOne(
2199
+ viewDate,
2200
+ addFn,
2201
+ direction < 0 ? -step : step,
2202
+ testFn,
2203
+ currentView.minDate,
2204
+ currentView.maxDate
2205
+ );
2206
+ if (viewDate !== undefined) {
2207
+ picker.changeFocus(viewDate).render();
2208
+ }
2209
+ }
2210
+
2211
+ function onKeydown(datepicker, ev) {
2212
+ const key = ev.key;
2213
+ if (key === 'Tab') {
2214
+ unfocus(datepicker);
2215
+ return;
2216
+ }
2217
+
2218
+ const picker = datepicker.picker;
2219
+ const {id, isMinView} = picker.currentView;
2220
+ if (!picker.active) {
2221
+ if (key === 'ArrowDown') {
2222
+ picker.show();
2223
+ } else {
2224
+ if (key === 'Enter') {
2225
+ datepicker.update();
2226
+ } else if (key === 'Escape') {
2227
+ picker.show();
2228
+ }
2229
+ return;
2230
+ }
2231
+ } else if (datepicker.editMode) {
2232
+ if (key === 'Enter') {
2233
+ datepicker.exitEditMode({update: true, autohide: datepicker.config.autohide});
2234
+ } else if (key === 'Escape') {
2235
+ picker.hide();
2236
+ }
2237
+ return;
2238
+ } else {
2239
+ if (key === 'ArrowLeft') {
2240
+ if (ev.ctrlKey || ev.metaKey) {
2241
+ goToPrevOrNext(datepicker, -1);
2242
+ } else if (ev.shiftKey) {
2243
+ datepicker.enterEditMode();
2244
+ return;
2245
+ } else {
2246
+ moveByArrowKey(datepicker, ev, -1, false);
2247
+ }
2248
+ } else if (key === 'ArrowRight') {
2249
+ if (ev.ctrlKey || ev.metaKey) {
2250
+ goToPrevOrNext(datepicker, 1);
2251
+ } else if (ev.shiftKey) {
2252
+ datepicker.enterEditMode();
2253
+ return;
2254
+ } else {
2255
+ moveByArrowKey(datepicker, ev, 1, false);
2256
+ }
2257
+ } else if (key === 'ArrowUp') {
2258
+ if (ev.ctrlKey || ev.metaKey) {
2259
+ switchView(datepicker);
2260
+ } else if (ev.shiftKey) {
2261
+ datepicker.enterEditMode();
2262
+ return;
2263
+ } else {
2264
+ moveByArrowKey(datepicker, ev, -1, true);
2265
+ }
2266
+ } else if (key === 'ArrowDown') {
2267
+ if (ev.shiftKey && !ev.ctrlKey && !ev.metaKey) {
2268
+ datepicker.enterEditMode();
2269
+ return;
2270
+ }
2271
+ moveByArrowKey(datepicker, ev, 1, true);
2272
+ } else if (key === 'Enter') {
2273
+ if (isMinView) {
2274
+ datepicker.setDate(picker.viewDate);
2275
+ return;
2276
+ }
2277
+ picker.changeView(id - 1).render();
2278
+ } else {
2279
+ if (key === 'Escape') {
2280
+ picker.hide();
2281
+ } else if (
2282
+ key === 'Backspace'
2283
+ || key === 'Delete'
2284
+ || (key.length === 1 && !ev.ctrlKey && !ev.metaKey)
2285
+ ) {
2286
+ datepicker.enterEditMode();
2287
+ }
2288
+ return;
2289
+ }
2290
+ }
2291
+ ev.preventDefault();
2292
+ }
2293
+
2294
+ function onFocus(datepicker) {
2295
+ if (datepicker.config.showOnFocus && !datepicker._showing) {
2296
+ datepicker.show();
2297
+ }
2298
+ }
2299
+
2300
+ // for the prevention for entering edit mode while getting focus on click
2301
+ function onMousedown(datepicker, ev) {
2302
+ const el = ev.target;
2303
+ if (datepicker.picker.active || datepicker.config.showOnClick) {
2304
+ el._active = isActiveElement(el);
2305
+ el._clicking = setTimeout(() => {
2306
+ delete el._active;
2307
+ delete el._clicking;
2308
+ }, 2000);
2309
+ }
2310
+ }
2311
+
2312
+ function onClickInput(datepicker, ev) {
2313
+ const el = ev.target;
2314
+ if (!el._clicking) {
2315
+ return;
2316
+ }
2317
+ clearTimeout(el._clicking);
2318
+ delete el._clicking;
2319
+
2320
+ if (el._active) {
2321
+ datepicker.enterEditMode();
2322
+ }
2323
+ delete el._active;
2324
+
2325
+ if (datepicker.config.showOnClick) {
2326
+ datepicker.show();
2327
+ }
2328
+ }
2329
+
2330
+ function onPaste(datepicker, ev) {
2331
+ if (ev.clipboardData.types.includes('text/plain')) {
2332
+ datepicker.enterEditMode();
2333
+ }
2334
+ }
2335
+
2336
+ // for the `document` to delegate the events from outside the picker/input field
2337
+ function onClickOutside(datepicker, ev) {
2338
+ const {element, picker} = datepicker;
2339
+ // check both picker's and input's activeness to make updateOnBlur work in
2340
+ // the cases where...
2341
+ // - picker is hidden by ESC key press → input stays focused
2342
+ // - input is unfocused by closing mobile keyboard → piker is kept shown
2343
+ if (!picker.active && !isActiveElement(element)) {
2344
+ return;
2345
+ }
2346
+ const pickerElem = picker.element;
2347
+ if (findElementInEventPath(ev, el => el === element || el === pickerElem)) {
2348
+ return;
2349
+ }
2350
+ unfocus(datepicker);
2351
+ }
2352
+
2353
+ function stringifyDates(dates, config) {
2354
+ return dates
2355
+ .map(dt => formatDate(dt, config.format, config.locale))
2356
+ .join(config.dateDelimiter);
2357
+ }
2358
+
2359
+ // parse input dates and create an array of time values for selection
2360
+ // returns undefined if there are no valid dates in inputDates
2361
+ // when origDates (current selection) is passed, the function works to mix
2362
+ // the input dates into the current selection
2363
+ function processInputDates(datepicker, inputDates, clear = false) {
2364
+ // const {config, dates: origDates, rangepicker} = datepicker;
2365
+ const {config, dates: origDates, rangeSideIndex} = datepicker;
2366
+ if (inputDates.length === 0) {
2367
+ // empty input is considered valid unless origiDates is passed
2368
+ return clear ? [] : undefined;
2369
+ }
2370
+
2371
+ // const rangeEnd = rangepicker && datepicker === rangepicker.datepickers[1];
2372
+ let newDates = inputDates.reduce((dates, dt) => {
2373
+ let date = parseDate(dt, config.format, config.locale);
2374
+ if (date === undefined) {
2375
+ return dates;
2376
+ }
2377
+ // adjust to 1st of the month/Jan 1st of the year
2378
+ // or to the last day of the monh/Dec 31st of the year if the datepicker
2379
+ // is the range-end picker of a rangepicker
2380
+ date = regularizeDate(date, config.pickLevel, rangeSideIndex);
2381
+ if (
2382
+ isInRange(date, config.minDate, config.maxDate)
2383
+ && !dates.includes(date)
2384
+ && !config.datesDisabled.includes(date)
2385
+ && (config.pickLevel > 0 || !config.daysOfWeekDisabled.includes(new Date(date).getDay()))
2386
+ ) {
2387
+ dates.push(date);
2388
+ }
2389
+ return dates;
2390
+ }, []);
2391
+ if (newDates.length === 0) {
2392
+ return;
2393
+ }
2394
+ if (config.multidate && !clear) {
2395
+ // get the synmetric difference between origDates and newDates
2396
+ newDates = newDates.reduce((dates, date) => {
2397
+ if (!origDates.includes(date)) {
2398
+ dates.push(date);
2399
+ }
2400
+ return dates;
2401
+ }, origDates.filter(date => !newDates.includes(date)));
2402
+ }
2403
+ // do length check always because user can input multiple dates regardless of the mode
2404
+ return config.maxNumberOfDates && newDates.length > config.maxNumberOfDates
2405
+ ? newDates.slice(config.maxNumberOfDates * -1)
2406
+ : newDates;
2407
+ }
2408
+
2409
+ // refresh the UI elements
2410
+ // modes: 1: input only, 2, picker only, 3 both
2411
+ function refreshUI(datepicker, mode = 3, quickRender = true) {
2412
+ const {config, picker, inputField} = datepicker;
2413
+ if (mode & 2) {
2414
+ const newView = picker.active ? config.pickLevel : config.startView;
2415
+ picker.update().changeView(newView).render(quickRender);
2416
+ }
2417
+ if (mode & 1 && inputField) {
2418
+ inputField.value = stringifyDates(datepicker.dates, config);
2419
+ }
2420
+ }
2421
+
2422
+ function setDate(datepicker, inputDates, options) {
2423
+ let {clear, render, autohide, revert} = options;
2424
+ if (render === undefined) {
2425
+ render = true;
2426
+ }
2427
+ if (!render) {
2428
+ autohide = false;
2429
+ } else if (autohide === undefined) {
2430
+ autohide = datepicker.config.autohide;
2431
+ }
2432
+
2433
+ const newDates = processInputDates(datepicker, inputDates, clear);
2434
+ if (!newDates && !revert) {
2435
+ return;
2436
+ }
2437
+ if (newDates && newDates.toString() !== datepicker.dates.toString()) {
2438
+ datepicker.dates = newDates;
2439
+ refreshUI(datepicker, render ? 3 : 1);
2440
+ triggerDatepickerEvent(datepicker, 'changeDate');
2441
+ } else {
2442
+ refreshUI(datepicker, 1);
2443
+ }
2444
+
2445
+ if (autohide) {
2446
+ datepicker.hide();
2447
+ }
2448
+ }
2449
+
2450
+ /**
2451
+ * Class representing a date picker
2452
+ */
2453
+ class Datepicker {
2454
+ /**
2455
+ * Create a date picker
2456
+ * @param {Element} element - element to bind a date picker
2457
+ * @param {Object} [options] - config options
2458
+ * @param {DateRangePicker} [rangepicker] - DateRangePicker instance the
2459
+ * date picker belongs to. Use this only when creating date picker as a part
2460
+ * of date range picker
2461
+ */
2462
+ constructor(element, options = {}, rangepicker = undefined) {
2463
+ element.datepicker = this;
2464
+ this.element = element;
2465
+
2466
+ const config = this.config = Object.assign({
2467
+ buttonClass: (options.buttonClass && String(options.buttonClass)) || 'button',
2468
+ container: null,
2469
+ defaultViewDate: today(),
2470
+ maxDate: undefined,
2471
+ minDate: undefined,
2472
+ }, processOptions(defaultOptions, this));
2473
+ // configure by type
2474
+ const inline = this.inline = element.tagName !== 'INPUT';
2475
+ let inputField;
2476
+ if (inline) {
2477
+ config.container = element;
2478
+ } else {
2479
+ if (options.container) {
2480
+ // omit string type check because it doesn't guarantee to avoid errors
2481
+ // (invalid selector string causes abend with sytax error)
2482
+ config.container = options.container instanceof HTMLElement
2483
+ ? options.container
2484
+ : document.querySelector(options.container);
2485
+ }
2486
+ inputField = this.inputField = element;
2487
+ inputField.classList.add('datepicker-input');
2488
+ }
2489
+ if (rangepicker) {
2490
+ // check validiry
2491
+ const index = rangepicker.inputs.indexOf(inputField);
2492
+ const datepickers = rangepicker.datepickers;
2493
+ if (index < 0 || index > 1 || !Array.isArray(datepickers)) {
2494
+ throw Error('Invalid rangepicker object.');
2495
+ }
2496
+ // attach itaelf to the rangepicker here so that processInputDates() can
2497
+ // determine if this is the range-end picker of the rangepicker while
2498
+ // setting inital values when pickLevel > 0
2499
+ datepickers[index] = this;
2500
+ // add getter for rangepicker
2501
+ Object.defineProperty(this, 'rangepicker', {
2502
+ get() {
2503
+ return rangepicker;
2504
+ },
2505
+ });
2506
+ Object.defineProperty(this, 'rangeSideIndex', {
2507
+ get() {
2508
+ return index;
2509
+ },
2510
+ });
2511
+ }
2512
+
2513
+ // set up config
2514
+ this._options = options;
2515
+ Object.assign(config, processOptions(options, this));
2516
+
2517
+ // set initial dates
2518
+ let initialDates;
2519
+ if (inline) {
2520
+ initialDates = stringToArray(element.dataset.date, config.dateDelimiter);
2521
+ delete element.dataset.date;
2522
+ } else {
2523
+ initialDates = stringToArray(inputField.value, config.dateDelimiter);
2524
+ }
2525
+ this.dates = [];
2526
+ // process initial value
2527
+ const inputDateValues = processInputDates(this, initialDates);
2528
+ if (inputDateValues && inputDateValues.length > 0) {
2529
+ this.dates = inputDateValues;
2530
+ }
2531
+ if (inputField) {
2532
+ inputField.value = stringifyDates(this.dates, config);
2533
+ }
2534
+
2535
+ const picker = this.picker = new Picker(this);
2536
+
2537
+ if (inline) {
2538
+ this.show();
2539
+ } else {
2540
+ // set up event listeners in other modes
2541
+ const onMousedownDocument = onClickOutside.bind(null, this);
2542
+ const listeners = [
2543
+ [inputField, 'keydown', onKeydown.bind(null, this)],
2544
+ [inputField, 'focus', onFocus.bind(null, this)],
2545
+ [inputField, 'mousedown', onMousedown.bind(null, this)],
2546
+ [inputField, 'click', onClickInput.bind(null, this)],
2547
+ [inputField, 'paste', onPaste.bind(null, this)],
2548
+ [document, 'mousedown', onMousedownDocument],
2549
+ [document, 'touchstart', onMousedownDocument],
2550
+ [window, 'resize', picker.place.bind(picker)]
2551
+ ];
2552
+ registerListeners(this, listeners);
2553
+ }
2554
+ }
2555
+
2556
+ /**
2557
+ * Format Date object or time value in given format and language
2558
+ * @param {Date|Number} date - date or time value to format
2559
+ * @param {String|Object} format - format string or object that contains
2560
+ * toDisplay() custom formatter, whose signature is
2561
+ * - args:
2562
+ * - date: {Date} - Date instance of the date passed to the method
2563
+ * - format: {Object} - the format object passed to the method
2564
+ * - locale: {Object} - locale for the language specified by `lang`
2565
+ * - return:
2566
+ * {String} formatted date
2567
+ * @param {String} [lang=en] - language code for the locale to use
2568
+ * @return {String} formatted date
2569
+ */
2570
+ static formatDate(date, format, lang) {
2571
+ return formatDate(date, format, lang && locales[lang] || locales.en);
2572
+ }
2573
+
2574
+ /**
2575
+ * Parse date string
2576
+ * @param {String|Date|Number} dateStr - date string, Date object or time
2577
+ * value to parse
2578
+ * @param {String|Object} format - format string or object that contains
2579
+ * toValue() custom parser, whose signature is
2580
+ * - args:
2581
+ * - dateStr: {String|Date|Number} - the dateStr passed to the method
2582
+ * - format: {Object} - the format object passed to the method
2583
+ * - locale: {Object} - locale for the language specified by `lang`
2584
+ * - return:
2585
+ * {Date|Number} parsed date or its time value
2586
+ * @param {String} [lang=en] - language code for the locale to use
2587
+ * @return {Number} time value of parsed date
2588
+ */
2589
+ static parseDate(dateStr, format, lang) {
2590
+ return parseDate(dateStr, format, lang && locales[lang] || locales.en);
2591
+ }
2592
+
2593
+ /**
2594
+ * @type {Object} - Installed locales in `[languageCode]: localeObject` format
2595
+ * en`:_English (US)_ is pre-installed.
2596
+ */
2597
+ static get locales() {
2598
+ return locales;
2599
+ }
2600
+
2601
+ /**
2602
+ * @type {Boolean} - Whether the picker element is shown. `true` whne shown
2603
+ */
2604
+ get active() {
2605
+ return !!(this.picker && this.picker.active);
2606
+ }
2607
+
2608
+ /**
2609
+ * @type {HTMLDivElement} - DOM object of picker element
2610
+ */
2611
+ get pickerElement() {
2612
+ return this.picker ? this.picker.element : undefined;
2613
+ }
2614
+
2615
+ /**
2616
+ * Set new values to the config options
2617
+ * @param {Object} options - config options to update
2618
+ */
2619
+ setOptions(options) {
2620
+ const picker = this.picker;
2621
+ const newOptions = processOptions(options, this);
2622
+ Object.assign(this._options, options);
2623
+ Object.assign(this.config, newOptions);
2624
+ picker.setOptions(newOptions);
2625
+
2626
+ refreshUI(this, 3);
2627
+ }
2628
+
2629
+ /**
2630
+ * Show the picker element
2631
+ */
2632
+ show() {
2633
+ if (this.inputField) {
2634
+ if (this.inputField.disabled) {
2635
+ return;
2636
+ }
2637
+ if (!isActiveElement(this.inputField) && !this.config.disableTouchKeyboard) {
2638
+ this._showing = true;
2639
+ this.inputField.focus();
2640
+ delete this._showing;
2641
+ }
2642
+ }
2643
+ this.picker.show();
2644
+ }
2645
+
2646
+ /**
2647
+ * Hide the picker element
2648
+ * Not available on inline picker
2649
+ */
2650
+ hide() {
2651
+ if (this.inline) {
2652
+ return;
2653
+ }
2654
+ this.picker.hide();
2655
+ this.picker.update().changeView(this.config.startView).render();
2656
+ }
2657
+
2658
+ /**
2659
+ * Destroy the Datepicker instance
2660
+ * @return {Detepicker} - the instance destroyed
2661
+ */
2662
+ destroy() {
2663
+ this.hide();
2664
+ unregisterListeners(this);
2665
+ this.picker.detach();
2666
+ if (!this.inline) {
2667
+ this.inputField.classList.remove('datepicker-input');
2668
+ }
2669
+ delete this.element.datepicker;
2670
+ return this;
2671
+ }
2672
+
2673
+ /**
2674
+ * Get the selected date(s)
2675
+ *
2676
+ * The method returns a Date object of selected date by default, and returns
2677
+ * an array of selected dates in multidate mode. If format string is passed,
2678
+ * it returns date string(s) formatted in given format.
2679
+ *
2680
+ * @param {String} [format] - Format string to stringify the date(s)
2681
+ * @return {Date|String|Date[]|String[]} - selected date(s), or if none is
2682
+ * selected, empty array in multidate mode and untitled in sigledate mode
2683
+ */
2684
+ getDate(format = undefined) {
2685
+ const callback = format
2686
+ ? date => formatDate(date, format, this.config.locale)
2687
+ : date => new Date(date);
2688
+
2689
+ if (this.config.multidate) {
2690
+ return this.dates.map(callback);
2691
+ }
2692
+ if (this.dates.length > 0) {
2693
+ return callback(this.dates[0]);
2694
+ }
2695
+ }
2696
+
2697
+ /**
2698
+ * Set selected date(s)
2699
+ *
2700
+ * In multidate mode, you can pass multiple dates as a series of arguments
2701
+ * or an array. (Since each date is parsed individually, the type of the
2702
+ * dates doesn't have to be the same.)
2703
+ * The given dates are used to toggle the select status of each date. The
2704
+ * number of selected dates is kept from exceeding the length set to
2705
+ * maxNumberOfDates.
2706
+ *
2707
+ * With clear: true option, the method can be used to clear the selection
2708
+ * and to replace the selection instead of toggling in multidate mode.
2709
+ * If the option is passed with no date arguments or an empty dates array,
2710
+ * it works as "clear" (clear the selection then set nothing), and if the
2711
+ * option is passed with new dates to select, it works as "replace" (clear
2712
+ * the selection then set the given dates)
2713
+ *
2714
+ * When render: false option is used, the method omits re-rendering the
2715
+ * picker element. In this case, you need to call refresh() method later in
2716
+ * order for the picker element to reflect the changes. The input field is
2717
+ * refreshed always regardless of this option.
2718
+ *
2719
+ * When invalid (unparsable, repeated, disabled or out-of-range) dates are
2720
+ * passed, the method ignores them and applies only valid ones. In the case
2721
+ * that all the given dates are invalid, which is distinguished from passing
2722
+ * no dates, the method considers it as an error and leaves the selection
2723
+ * untouched. (The input field also remains untouched unless revert: true
2724
+ * option is used.)
2725
+ *
2726
+ * @param {...(Date|Number|String)|Array} [dates] - Date strings, Date
2727
+ * objects, time values or mix of those for new selection
2728
+ * @param {Object} [options] - function options
2729
+ * - clear: {boolean} - Whether to clear the existing selection
2730
+ * defualt: false
2731
+ * - render: {boolean} - Whether to re-render the picker element
2732
+ * default: true
2733
+ * - autohide: {boolean} - Whether to hide the picker element after re-render
2734
+ * Ignored when used with render: false
2735
+ * default: config.autohide
2736
+ * - revert: {boolean} - Whether to refresh the input field when all the
2737
+ * passed dates are invalid
2738
+ * default: false
2739
+ */
2740
+ setDate(...args) {
2741
+ const dates = [...args];
2742
+ const opts = {};
2743
+ const lastArg = lastItemOf(args);
2744
+ if (
2745
+ typeof lastArg === 'object'
2746
+ && !Array.isArray(lastArg)
2747
+ && !(lastArg instanceof Date)
2748
+ && lastArg
2749
+ ) {
2750
+ Object.assign(opts, dates.pop());
2751
+ }
2752
+
2753
+ const inputDates = Array.isArray(dates[0]) ? dates[0] : dates;
2754
+ setDate(this, inputDates, opts);
2755
+ }
2756
+
2757
+ /**
2758
+ * Update the selected date(s) with input field's value
2759
+ * Not available on inline picker
2760
+ *
2761
+ * The input field will be refreshed with properly formatted date string.
2762
+ *
2763
+ * In the case that all the entered dates are invalid (unparsable, repeated,
2764
+ * disabled or out-of-range), whixh is distinguished from empty input field,
2765
+ * the method leaves the input field untouched as well as the selection by
2766
+ * default. If revert: true option is used in this case, the input field is
2767
+ * refreshed with the existing selection.
2768
+ *
2769
+ * @param {Object} [options] - function options
2770
+ * - autohide: {boolean} - whether to hide the picker element after refresh
2771
+ * default: false
2772
+ * - revert: {boolean} - Whether to refresh the input field when all the
2773
+ * passed dates are invalid
2774
+ * default: false
2775
+ */
2776
+ update(options = undefined) {
2777
+ if (this.inline) {
2778
+ return;
2779
+ }
2780
+
2781
+ const opts = Object.assign(options || {}, {clear: true, render: true});
2782
+ const inputDates = stringToArray(this.inputField.value, this.config.dateDelimiter);
2783
+ setDate(this, inputDates, opts);
2784
+ }
2785
+
2786
+ /**
2787
+ * Refresh the picker element and the associated input field
2788
+ * @param {String} [target] - target item when refreshing one item only
2789
+ * 'picker' or 'input'
2790
+ * @param {Boolean} [forceRender] - whether to re-render the picker element
2791
+ * regardless of its state instead of optimized refresh
2792
+ */
2793
+ refresh(target = undefined, forceRender = false) {
2794
+ if (target && typeof target !== 'string') {
2795
+ forceRender = target;
2796
+ target = undefined;
2797
+ }
2798
+
2799
+ let mode;
2800
+ if (target === 'picker') {
2801
+ mode = 2;
2802
+ } else if (target === 'input') {
2803
+ mode = 1;
2804
+ } else {
2805
+ mode = 3;
2806
+ }
2807
+ refreshUI(this, mode, !forceRender);
2808
+ }
2809
+
2810
+ /**
2811
+ * Enter edit mode
2812
+ * Not available on inline picker or when the picker element is hidden
2813
+ */
2814
+ enterEditMode() {
2815
+ if (this.inline || !this.picker.active || this.editMode) {
2816
+ return;
2817
+ }
2818
+ this.editMode = true;
2819
+ this.inputField.classList.add('in-edit');
2820
+ }
2821
+
2822
+ /**
2823
+ * Exit from edit mode
2824
+ * Not available on inline picker
2825
+ * @param {Object} [options] - function options
2826
+ * - update: {boolean} - whether to call update() after exiting
2827
+ * If false, input field is revert to the existing selection
2828
+ * default: false
2829
+ */
2830
+ exitEditMode(options = undefined) {
2831
+ if (this.inline || !this.editMode) {
2832
+ return;
2833
+ }
2834
+ const opts = Object.assign({update: false}, options);
2835
+ delete this.editMode;
2836
+ this.inputField.classList.remove('in-edit');
2837
+ if (opts.update) {
2838
+ this.update(opts);
2839
+ }
2840
+ }
2841
+ }
2842
+
2843
+ const verdocsFieldDateCss = ".datepicker{display:none}.datepicker.active{display:block}.datepicker-dropdown{position:absolute;top:0;left:0;z-index:20;padding-top:4px}.datepicker-dropdown.datepicker-orient-top{padding-top:0;padding-bottom:4px}.datepicker-picker{display:inline-block;border-radius:4px;background-color:white}.datepicker-dropdown .datepicker-picker{-webkit-box-shadow:0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);box-shadow:0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1)}.datepicker-picker span{display:block;-ms-flex:1;flex:1;border:0;border-radius:4px;cursor:default;text-align:center;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.datepicker-main{padding:2px}.datepicker-footer{-webkit-box-shadow:inset 0 1px 1px rgba(10, 10, 10, 0.1);box-shadow:inset 0 1px 1px rgba(10, 10, 10, 0.1);background-color:whitesmoke}.datepicker-grid,.datepicker-view .days-of-week,.datepicker-view,.datepicker-controls{display:-ms-flexbox;display:flex}.datepicker-grid{-ms-flex-wrap:wrap;flex-wrap:wrap}.datepicker-view .days .datepicker-cell,.datepicker-view .dow{-ms-flex-preferred-size:14.2857142857%;flex-basis:14.2857142857%}.datepicker-view.datepicker-grid .datepicker-cell{-ms-flex-preferred-size:25%;flex-basis:25%}.datepicker-cell,.datepicker-view .week{height:2.25rem;line-height:2.25rem}.datepicker-title{-webkit-box-shadow:inset 0 -1px 1px rgba(10, 10, 10, 0.1);box-shadow:inset 0 -1px 1px rgba(10, 10, 10, 0.1);background-color:whitesmoke;padding:0.375rem 0.75rem;text-align:center;font-weight:700}.datepicker-header .datepicker-controls{padding:2px 2px 0}.datepicker-controls .button{display:-ms-inline-flexbox;display:inline-flex;position:relative;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;margin:0;border:1px solid #dbdbdb;border-radius:4px;-webkit-box-shadow:none;box-shadow:none;background-color:white;cursor:pointer;padding:calc(0.375em - 1px) 0.75em;height:2.25em;vertical-align:top;text-align:center;line-height:1.5;white-space:nowrap;color:#363636;font-size:1rem}.datepicker-controls .button:focus,.datepicker-controls .button:active{outline:none}.datepicker-controls .button:hover{border-color:#b5b5b5;color:#363636}.datepicker-controls .button:focus{border-color:#3273dc;color:#363636}.datepicker-controls .button:focus:not(:active){-webkit-box-shadow:0 0 0 0.125em rgba(50, 115, 220, 0.25);box-shadow:0 0 0 0.125em rgba(50, 115, 220, 0.25)}.datepicker-controls .button:active{border-color:#4a4a4a;color:#363636}.datepicker-controls .button[disabled]{cursor:not-allowed}.datepicker-header .datepicker-controls .button{border-color:transparent;font-weight:bold}.datepicker-header .datepicker-controls .button:hover{background-color:#f9f9f9}.datepicker-header .datepicker-controls .button:focus:not(:active){-webkit-box-shadow:0 0 0 0.125em rgba(255, 255, 255, 0.25);box-shadow:0 0 0 0.125em rgba(255, 255, 255, 0.25)}.datepicker-header .datepicker-controls .button:active{background-color:#f2f2f2}.datepicker-header .datepicker-controls .button[disabled]{-webkit-box-shadow:none;box-shadow:none}.datepicker-footer .datepicker-controls .button{margin:calc(0.375rem - 1px) 0.375rem;border-radius:2px;width:100%;font-size:0.75rem}.datepicker-controls .view-switch{-ms-flex:auto;flex:auto}.datepicker-controls .prev-btn,.datepicker-controls .next-btn{padding-right:0.375rem;padding-left:0.375rem;width:2.25rem}.datepicker-controls .prev-btn.disabled,.datepicker-controls .next-btn.disabled{visibility:hidden}.datepicker-view .dow{height:1.5rem;line-height:1.5rem;font-size:0.875rem;font-weight:700}.datepicker-view .week{width:2.25rem;color:#b5b5b5;font-size:0.75rem}@media (max-width: 22.5rem){.datepicker-view .week{width:1.96875rem}}.datepicker-grid{width:15.75rem}@media (max-width: 22.5rem){.calendar-weeks+.days .datepicker-grid{width:13.78125rem}}.datepicker-cell:not(.disabled):hover{background-color:#f9f9f9;cursor:pointer}.datepicker-cell.focused:not(.selected){background-color:#e8e8e8}.datepicker-cell.selected,.datepicker-cell.selected:hover{background-color:#3273dc;color:#fff;font-weight:600}.datepicker-cell.disabled{color:#dbdbdb}.datepicker-cell.prev:not(.disabled),.datepicker-cell.next:not(.disabled){color:#7a7a7a}.datepicker-cell.prev.selected,.datepicker-cell.next.selected{color:#e6e6e6}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today){border-radius:0;background-color:whitesmoke}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today):not(.disabled):hover{background-color:#eeeeee}.datepicker-cell.highlighted:not(.selected):not(.range):not(.today).focused{background-color:#e8e8e8}.datepicker-cell.today:not(.selected){background-color:#00d1b2}.datepicker-cell.today:not(.selected):not(.disabled){color:#fff}.datepicker-cell.today.focused:not(.selected){background-color:#00c4a7}.datepicker-cell.range-end:not(.selected),.datepicker-cell.range-start:not(.selected){background-color:#b5b5b5;color:#fff}.datepicker-cell.range-end.focused:not(.selected),.datepicker-cell.range-start.focused:not(.selected){background-color:#afafaf}.datepicker-cell.range-start{border-radius:4px 0 0 4px}.datepicker-cell.range-end{border-radius:0 4px 4px 0}.datepicker-cell.range{border-radius:0;background-color:#dbdbdb}.datepicker-cell.range:not(.disabled):not(.focused):not(.today):hover{background-color:#d5d5d5}.datepicker-cell.range.disabled{color:#c2c2c2}.datepicker-cell.range.focused{background-color:#cfcfcf}.datepicker-view.datepicker-grid .datepicker-cell{height:4.5rem;line-height:4.5rem}.datepicker-input.in-edit{border-color:#2366d1}.datepicker-input.in-edit:focus,.datepicker-input.in-edit:active{-webkit-box-shadow:0 0 0.25em 0.25em rgba(35, 102, 209, 0.2);box-shadow:0 0 0.25em 0.25em rgba(35, 102, 209, 0.2)}verdocs-field-date{font-family:\"Barlow\", sans-serif;width:64px;height:15px;display:block;font-size:11px;position:relative;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-date input{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid #ccc;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-date input.hide{display:none}verdocs-field-date.required input{border:1px solid var(--verdocs-required-color)}verdocs-field-date.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
2844
+
2845
+ const VerdocsFieldDate = class {
2846
+ constructor(hostRef) {
2847
+ registerInstance(this, hostRef);
2848
+ this.fieldFocus = createEvent(this, "fieldFocus", 7);
2849
+ this.fieldBlur = createEvent(this, "fieldBlur", 7);
2850
+ this.fieldChange = createEvent(this, "fieldChange", 7);
2851
+ this.fieldInput = createEvent(this, "fieldInput", 7);
2852
+ /**
2853
+ * A placeholder to assist the user in completing the field.
2854
+ */
2855
+ this.placeholder = 'Select Date';
2856
+ /**
2857
+ * Sets the tabIndex of the input element.
2858
+ */
2859
+ this.order = 1;
2860
+ /**
2861
+ * Sets the value of the input element.
2862
+ */
2863
+ this.value = '';
2864
+ /**
2865
+ * If true, the field will be marked required.
2866
+ */
2867
+ this.required = false;
2868
+ /**
2869
+ * Sets the disabled attribute of the input element.
2870
+ */
2871
+ this.disabled = false;
2872
+ this.focused = false;
2873
+ }
2874
+ async focusField() {
2875
+ this.focused = true;
2876
+ this.el.focus();
2877
+ this.fieldFocus.emit(true);
2878
+ }
2879
+ componentDidLoad() {
2880
+ new Datepicker(this.el, {
2881
+ autohide: true,
2882
+ todayHighlight: true,
2883
+ });
2884
+ this.el.addEventListener('changeDate', (e) => {
2885
+ console.log('changeDate', e.detail.date.toISOString());
2886
+ });
2887
+ }
2888
+ handleBlur() {
2889
+ this.focused = false;
2890
+ this.fieldBlur.emit(true);
2891
+ }
2892
+ handleFocus() {
2893
+ this.focused = true;
2894
+ this.fieldFocus.emit(true);
2895
+ }
2896
+ handleChange(e) {
2897
+ this.fieldChange.emit(e.target.value);
2898
+ }
2899
+ handleInput(e) {
2900
+ this.fieldInput.emit(e.target.value);
2901
+ }
2902
+ // NOTE: We don't use a "date" field here because browsers vary widely in their formatting of it.
2903
+ render() {
2904
+ return (h(Host, { class: { focused: this.focused, required: this.required, storybook: !!(window === null || window === void 0 ? void 0 : window['STORYBOOK_ENV']) } }, h("input", { type: "text", value: "", placeholder: this.placeholder, required: this.required, ref: el => (this.el = el), onBlur: () => this.handleBlur(), onFocus: () => this.handleFocus(), onChange: e => this.handleChange(e), onInput: e => this.handleInput(e) })));
2905
+ }
2906
+ };
2907
+ VerdocsFieldDate.style = verdocsFieldDateCss;
2908
+
2909
+ const verdocsFieldDropdownCss = "verdocs-field-dropdown{font-family:\"Barlow\", sans-serif;width:85px;height:20px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-dropdown select{position:absolute;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-dropdown select:focus{outline:none}verdocs-field-dropdown select.hide{display:none}verdocs-field-dropdown.required select{border:1px solid var(--verdocs-required-color)}verdocs-field-dropdown.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
2910
+
2911
+ const VerdocsFieldDropdown = class {
2912
+ constructor(hostRef) {
2913
+ registerInstance(this, hostRef);
2914
+ this.fieldFocus = createEvent(this, "fieldFocus", 7);
2915
+ this.fieldBlur = createEvent(this, "fieldBlur", 7);
2916
+ this.fieldChange = createEvent(this, "fieldChange", 7);
2917
+ /**
2918
+ * The optoins to choose from.
2919
+ */
2920
+ this.options = [];
2921
+ /**
2922
+ * If true, the field will be marked required.
2923
+ */
2924
+ this.required = false;
2925
+ /**
2926
+ * Sets the tabIndex of the input element.
2927
+ */
2928
+ this.order = 1;
2929
+ /**
2930
+ * Sets the disabled attribute of the input element.
2931
+ */
2932
+ this.disabled = false;
2933
+ /**
2934
+ * The currently selected value.
2935
+ */
2936
+ this.value = '';
2937
+ this.focused = false;
2938
+ }
2939
+ async focusField() {
2940
+ this.focused = true;
2941
+ this.el.focus();
2942
+ this.fieldFocus.emit(true);
2943
+ }
2944
+ handleBlur() {
2945
+ this.focused = false;
2946
+ this.fieldBlur.emit(true);
2947
+ }
2948
+ handleFocus() {
2949
+ this.focused = true;
2950
+ this.fieldFocus.emit(true);
2951
+ }
2952
+ handleChange(e) {
2953
+ this.fieldChange.emit(e.target.value);
2954
+ }
2955
+ render() {
2956
+ return (h(Host, { class: { focused: this.focused, required: this.required } }, h("select", { tabIndex: this.order, disabled: this.disabled, ref: el => (this.el = el), onChange: e => this.handleChange(e), onBlur: () => this.handleBlur(), onFocus: () => this.handleFocus() }, h("option", { value: "" }, "Select..."), this.options.map(option => (h("option", { value: option.id, selected: option.value === this.value }, option.value))))));
2957
+ }
2958
+ };
2959
+ VerdocsFieldDropdown.style = verdocsFieldDropdownCss;
2960
+
2961
+ const verdocsFieldInitialCss = "verdocs-field-initial{font-family:\"Barlow\", sans-serif;width:83px;height:36px;display:block;font-size:11px;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-initial img{display:block;max-width:100%;max-height:100%}verdocs-field-initial button{-webkit-box-sizing:border-box;box-sizing:border-box;border:none;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-initial button.hide{display:none}verdocs-field-initial.required{border:1px solid var(--verdocs-required-color)}verdocs-field-initial.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
2962
+
2963
+ const VerdocsFieldInitial = class {
2964
+ constructor(hostRef) {
2965
+ registerInstance(this, hostRef);
2966
+ this.adopt = createEvent(this, "adopt", 7);
2967
+ this.cancel = createEvent(this, "cancel", 7);
2968
+ /**
2969
+ * Whether the field is required.
2970
+ */
2971
+ this.required = false;
2972
+ /**
2973
+ * The user's full name.
2974
+ */
2975
+ this.fullName = '';
2976
+ /**
2977
+ * The base64 signature value.
2978
+ */
2979
+ this.value = '';
2980
+ }
2981
+ async focusField() {
2982
+ this.handleShow();
2983
+ }
2984
+ handleShow() {
2985
+ this.dialog = document.createElement('verdocs-initial-dialog');
2986
+ this.dialog.open = true;
2987
+ this.dialog.fullName = this.fullName;
2988
+ this.dialog.addEventListener('cancel', () => {
2989
+ var _a;
2990
+ console.log('cancel');
2991
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
2992
+ });
2993
+ document.addEventListener('adopt', e => {
2994
+ var _a;
2995
+ console.log('adopt', e);
2996
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
2997
+ });
2998
+ document.body.append(this.dialog);
2999
+ }
3000
+ render() {
3001
+ return (h(Host, { class: { required: this.required } }, this.value !== '' ? (h("img", { src: this.value, alt: "Initials" })) : (h("button", { class: {}, onClick: () => this.handleShow() }, "Initial"))));
3002
+ }
3003
+ };
3004
+ VerdocsFieldInitial.style = verdocsFieldInitialCss;
3005
+
3006
+ const verdocsFieldPaymentCss = "verdocs-field-payment{font-family:\"Barlow\", sans-serif;width:24px;height:24px;display:block;font-size:11px;position:relative;border:1px solid #cfa;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-payment button,verdocs-field-payment div{-webkit-box-sizing:border-box;box-sizing:border-box}verdocs-field-payment button{color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-payment button.hide{display:none}verdocs-field-payment input{float:left;font-family:Arial, sans-serif}verdocs-field-payment select{position:absolute;font-family:Arial, sans-serif;background:linear-gradient(55deg, transparent 50%, #333 50%), linear-gradient(125deg, #333 50%, transparent 50%), linear-gradient(to right, transparent, transparent);background-position:calc(100% - 7px) 4px, calc(100% - 3px) 4px, 100% 0;background-size:5px 5px, 5px 5px, 2.5em 2.5em;background-repeat:no-repeat;-webkit-appearance:none;-moz-appearance:none;appearance:none}verdocs-field-payment .frame{width:100%;height:100%;background-size:contain;text-align:left}verdocs-field-payment .frame img{position:absolute;height:auto;width:100%}verdocs-field-payment.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
3007
+
3008
+ const VerdocsFieldPayment = class {
3009
+ constructor(hostRef) {
3010
+ registerInstance(this, hostRef);
3011
+ this.signatureComplete = createEvent(this, "signatureComplete", 7);
3012
+ this.initialComplete = createEvent(this, "initialComplete", 7);
3013
+ this.focused = false;
3014
+ this.signed = false;
3015
+ this.signatureUrl = '';
3016
+ this._fields = [];
3017
+ // envelopeFieldsFormGroup: FormGroup;
3018
+ this.signatureFile = null;
3019
+ this.initialFile = null;
3020
+ this.focusOrderNumber = -1;
3021
+ this.focusFieldName = '';
3022
+ this.activeElement = null;
3023
+ this.showError = {
3024
+ pageNum: -1,
3025
+ fieldIndex: -1,
3026
+ type: null,
3027
+ };
3028
+ this.dialogOpened = false;
3029
+ this.closeAllErrors = false;
3030
+ this.fieldsMap = {};
3031
+ this.fieldsForCurrentSigner = [];
3032
+ this.fontSize = 11;
3033
+ this.averageFontWidth = 5;
3034
+ this.requiredFields = [];
3035
+ }
3036
+ componentWillLoad() {
3037
+ // Load validators
3038
+ // Load fields
3039
+ // Get role names
3040
+ console.log('sign field', this.field);
3041
+ if (this.recipients && this.recipients.length > 0) {
3042
+ const preparer = this.recipients.find(r => r.type === 'preparer');
3043
+ console.log('Found preparer', preparer);
3044
+ if (preparer) {
3045
+ this.preparedMessage = `Prepared by ${preparer['full_name']}`;
3046
+ }
3047
+ }
3048
+ }
3049
+ // [tabIndex]="field.role !== roleName ? -1 : 1"
3050
+ // [ngStyle]="field.element_style"
3051
+ // [value]="field.value"
3052
+ // (click)="initiateSign(field)"
3053
+ // (blur)="validateChanges(field)"
3054
+ // [disabled]="field.role!==roleName"
3055
+ // [id]="field.key"
3056
+ // <button _ngcontent-app-root-c342="" class="envelope__field" tabindex="1" ng-reflect-ng-style="[object Object]"
3057
+ // ng-reflect-ng-class="[object Object]" value="" id="signatureP5-1"
3058
+ // style="height: 100%; width: 100%; background: none; font-size: 11px; border: 1px solid rgb(204, 0, 0);"> Signature </button>
3059
+ // bottom: 229.333
3060
+ // px
3061
+ // ;
3062
+ // left: 169.333
3063
+ // px
3064
+ // ;
3065
+ // height: 41
3066
+ // px
3067
+ // ;
3068
+ // width: 82
3069
+ // px
3070
+ // ;
3071
+ // background-color: rgba(156, 39, 176, 0.4);
3072
+ // transform: scale(1.33333, 1.33333);
3073
+ // }
3074
+ // <style>
3075
+ // .envelope__item[_ngcontent-app-root-c342] {
3076
+ // position: absolute;
3077
+ // transform-origin: bottom left;
3078
+ // opacity: 1;
3079
+ render() {
3080
+ return (h(Host, { class: { focused: this.focused, storybook: !!(window === null || window === void 0 ? void 0 : window['STORYBOOK_ENV']) } }, h("button", { class: { hide: this.signed } }, "Payment"), this.signed ? h("div", { class: "frame" }) : h("div", { style: { display: 'none' } }), h("img", { width: "100%", height: "100%", src: this.signatureUrl })));
3081
+ }
3082
+ };
3083
+ VerdocsFieldPayment.style = verdocsFieldPaymentCss;
3084
+
3085
+ const verdocsFieldRadioButtonCss = "verdocs-field-radio-button{font-family:\"Barlow\", sans-serif;width:14px;height:14px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border-radius:100%}verdocs-field-radio-button input[type=radio]{position:absolute;opacity:0}verdocs-field-radio-button input[type=radio]+label:before{content:\"\";background:#f4f4f4;border-radius:100%;border:1px solid rgba(0, 0, 0, 0.2);display:inline-block;width:13px;height:13px;position:relative;top:2px;margin-right:2px;vertical-align:top;cursor:pointer;text-align:center;-webkit-transition:all 250ms ease;transition:all 250ms ease}verdocs-field-radio-button input[type=radio]:checked+label:before{background-color:#55bc81;-webkit-box-shadow:inset 0 0 0 2px #f4f4f4;box-shadow:inset 0 0 0 2px #f4f4f4}verdocs-field-radio-button input[type=radio]:focus+label:before{outline:none;border-color:#55bc81}verdocs-field-radio-button input[type=radio]:disabled+label:before{-webkit-box-shadow:inset 0 0 0 4px #f4f4f4;box-shadow:inset 0 0 0 4px #f4f4f4;border-color:#b4b4b4;background:#b4b4b4}verdocs-field-radio-button input[type=radio]+label:empty:before{margin-right:0}verdocs-field-radio-button.required input[type=radio]+label:before{border:1px solid var(--verdocs-required-color)}verdocs-field-radio-button.hide{display:none}verdocs-field-radio-button.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
3086
+
3087
+ const VerdocsFieldRadioButton = class {
3088
+ constructor(hostRef) {
3089
+ registerInstance(this, hostRef);
3090
+ this.fieldChange = createEvent(this, "fieldChange", 7);
3091
+ /**
3092
+ * Sets the tabIndex of the input element.
3093
+ */
3094
+ this.order = 1;
3095
+ /**
3096
+ * Sets the value of the input element.
3097
+ */
3098
+ this.checked = false;
3099
+ /**
3100
+ * Sets the value of the input element.
3101
+ */
3102
+ this.value = '';
3103
+ /**
3104
+ * Sets the name of the input element.
3105
+ */
3106
+ this.name = '';
3107
+ /**
3108
+ * If true, the field will be marked required.
3109
+ */
3110
+ this.required = false;
3111
+ /**
3112
+ * Sets the disabled attribute of the input element.
3113
+ */
3114
+ this.disabled = false;
3115
+ }
3116
+ handleChange(e) {
3117
+ console.log('changed', e);
3118
+ this.fieldChange.emit(e.target.checked);
3119
+ }
3120
+ render() {
3121
+ return (h(Host, { class: { required: this.required, storybook: !!(window === null || window === void 0 ? void 0 : window['STORYBOOK_ENV']) } }, h("input", { type: "radio", tabIndex: this.order, value: this.value, name: this.name, id: `${this.name}=${this.value}`, checked: this.checked, disabled: this.disabled, required: this.required, onChange: e => this.handleChange(e) }), h("label", { htmlFor: `${this.name}=${this.value}` })));
3122
+ }
3123
+ };
3124
+ VerdocsFieldRadioButton.style = verdocsFieldRadioButtonCss;
3125
+
3126
+ const verdocsFieldSignatureCss = "verdocs-field-signature{font-family:\"Barlow\", sans-serif;width:83px;height:36px;display:block;font-size:11px;position:relative;letter-spacing:0.3px;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-signature img{display:block;max-width:100%;max-height:100%}verdocs-field-signature button{-webkit-box-sizing:border-box;box-sizing:border-box;border:none;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px}verdocs-field-signature button.hide{display:none}verdocs-field-signature.required{border:1px solid var(--verdocs-required-color)}verdocs-field-signature.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
3127
+
3128
+ const VerdocsFieldSignature = class {
3129
+ constructor(hostRef) {
3130
+ registerInstance(this, hostRef);
3131
+ this.adopt = createEvent(this, "adopt", 7);
3132
+ this.cancel = createEvent(this, "cancel", 7);
3133
+ /**
3134
+ * Whether the field is required.
3135
+ */
3136
+ this.required = false;
3137
+ /**
3138
+ * The user's full name.
3139
+ */
3140
+ this.fullName = '';
3141
+ /**
3142
+ * The base64 signature value.
3143
+ */
3144
+ this.value = '';
3145
+ }
3146
+ async focusField() {
3147
+ this.handleShow();
3148
+ }
3149
+ handleShow() {
3150
+ this.dialog = document.createElement('verdocs-signature-dialog');
3151
+ this.dialog.open = true;
3152
+ this.dialog.fullName = this.fullName;
3153
+ this.dialog.addEventListener('cancel', () => {
3154
+ var _a;
3155
+ console.log('cancel');
3156
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
3157
+ });
3158
+ document.addEventListener('adopt', e => {
3159
+ var _a;
3160
+ console.log('adopt', e);
3161
+ (_a = this.dialog) === null || _a === void 0 ? void 0 : _a.remove();
3162
+ });
3163
+ document.body.append(this.dialog);
3164
+ }
3165
+ render() {
3166
+ return (h(Host, { class: { required: this.required } }, this.value !== '' ? (h("img", { src: this.value, alt: "Signature" })) : (h("button", { class: {}, onClick: () => this.handleShow() }, "Signature"))));
3167
+ }
3168
+ };
3169
+ VerdocsFieldSignature.style = verdocsFieldSignatureCss;
3170
+
3171
+ const verdocsFieldTextareaCss = "verdocs-field-textarea{font-family:\"Barlow\", sans-serif;width:150px;height:15px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-textarea textarea{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-textarea textarea.hide{display:none}verdocs-field-textarea.required{border:1px solid var(--verdocs-required-color)}verdocs-field-textarea.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
3172
+
3173
+ const VerdocsFieldTextarea = class {
3174
+ constructor(hostRef) {
3175
+ registerInstance(this, hostRef);
3176
+ this.fieldFocus = createEvent(this, "fieldFocus", 7);
3177
+ this.fieldBlur = createEvent(this, "fieldBlur", 7);
3178
+ this.fieldChange = createEvent(this, "fieldChange", 7);
3179
+ this.fieldInput = createEvent(this, "fieldInput", 7);
3180
+ /**
3181
+ * A placeholder to assist the user in completing the field.
3182
+ */
3183
+ this.placeholder = '';
3184
+ /**
3185
+ * Sets the tabIndex of the input element.
3186
+ */
3187
+ this.order = 1;
3188
+ /**
3189
+ * Sets the value of the input element.
3190
+ */
3191
+ this.value = '';
3192
+ /**
3193
+ * If true, the field will be marked required.
3194
+ */
3195
+ this.required = false;
3196
+ /**
3197
+ * Sets the disabled attribute of the input element.
3198
+ */
3199
+ this.disabled = false;
3200
+ this.focused = false;
3201
+ }
3202
+ async focusField() {
3203
+ this.focused = true;
3204
+ this.el.focus();
3205
+ this.fieldFocus.emit(true);
3206
+ }
3207
+ handleBlur() {
3208
+ this.focused = false;
3209
+ this.fieldBlur.emit(true);
3210
+ }
3211
+ handleFocus() {
3212
+ this.focused = true;
3213
+ this.fieldFocus.emit(true);
3214
+ }
3215
+ handleChange(e) {
3216
+ this.fieldChange.emit(e.target.value);
3217
+ }
3218
+ handleInput(e) {
3219
+ this.fieldInput.emit(e.target.value);
3220
+ }
3221
+ render() {
3222
+ return (h(Host, { class: { focused: this.focused, required: this.required, storybook: !!(window === null || window === void 0 ? void 0 : window['STORYBOOK_ENV']) } }, h("textarea", { placeholder: this.placeholder || '', tabIndex: this.order, value: this.value, disabled: this.disabled, required: this.required, ref: el => (this.el = el), onBlur: () => this.handleBlur(), onFocus: () => this.handleFocus(), onChange: e => this.handleChange(e), onInput: e => this.handleInput(e) })));
3223
+ }
3224
+ };
3225
+ VerdocsFieldTextarea.style = verdocsFieldTextareaCss;
3226
+
3227
+ const verdocsFieldTextboxCss = "verdocs-field-textbox{font-family:\"Barlow\", sans-serif;width:150px;height:15px;display:block;font-size:11px;position:relative;background-color:transparent;-webkit-transform-origin:bottom left;transform-origin:bottom left}verdocs-field-textbox input{-webkit-box-sizing:border-box;box-sizing:border-box;color:rgba(0, 0, 0, 0.87);font-weight:500;-webkit-transform-origin:0 0;transform-origin:0 0;height:100%;width:100%;background:none;font-size:11px;border:1px solid rgba(0, 0, 0, 0.2)}verdocs-field-textbox input.hide{display:none}verdocs-field-textbox.required{border:1px solid var(--verdocs-required-color)}verdocs-field-textbox.focused{-webkit-animation:verdocs-field-pulse 0.75s 2;animation:verdocs-field-pulse 0.75s 2}";
3228
+
3229
+ const VerdocsFieldTextbox = class {
3230
+ constructor(hostRef) {
3231
+ registerInstance(this, hostRef);
3232
+ this.fieldFocus = createEvent(this, "fieldFocus", 7);
3233
+ this.fieldBlur = createEvent(this, "fieldBlur", 7);
3234
+ this.fieldChange = createEvent(this, "fieldChange", 7);
3235
+ this.fieldInput = createEvent(this, "fieldInput", 7);
3236
+ /**
3237
+ * A placeholder to assist the user in completing the field.
3238
+ */
3239
+ this.placeholder = '';
3240
+ /**
3241
+ * Sets the tabIndex of the input element.
3242
+ */
3243
+ this.order = 1;
3244
+ /**
3245
+ * Sets the value of the input element.
3246
+ */
3247
+ this.value = '';
3248
+ /**
3249
+ * If true, the field will be marked required.
3250
+ */
3251
+ this.required = false;
3252
+ /**
3253
+ * Sets the disabled attribute of the input element.
3254
+ */
3255
+ this.disabled = false;
3256
+ this.focused = false;
3257
+ }
3258
+ async focusField() {
3259
+ this.focused = true;
3260
+ this.el.focus();
3261
+ this.fieldFocus.emit(true);
3262
+ }
3263
+ handleBlur() {
3264
+ this.focused = false;
3265
+ this.fieldBlur.emit(true);
3266
+ }
3267
+ handleFocus() {
3268
+ this.focused = true;
3269
+ this.fieldFocus.emit(true);
3270
+ }
3271
+ handleChange(e) {
3272
+ this.fieldChange.emit(e.target.value);
3273
+ }
3274
+ handleInput(e) {
3275
+ this.fieldInput.emit(e.target.value);
3276
+ }
3277
+ render() {
3278
+ return (h(Host, { class: { focused: this.focused, required: this.required } }, h("input", { type: "text", placeholder: this.placeholder || '', tabIndex: this.order, value: this.value, disabled: this.disabled, required: this.required, ref: el => (this.el = el), onBlur: () => this.handleBlur(), onFocus: () => this.handleFocus(), onChange: e => this.handleChange(e), onInput: e => this.handleInput(e) })));
3279
+ }
3280
+ };
3281
+ VerdocsFieldTextbox.style = verdocsFieldTextboxCss;
4
3282
 
5
3283
  const _nodeResolve_empty = {};
6
3284
 
@@ -35,17 +3313,9 @@ var pdf = createCommonjsModule(function (module, exports) {
35
3313
  */
36
3314
 
37
3315
  (function webpackUniversalModuleDefinition(root, factory) {
38
- if('object' === 'object' && 'object' === 'object')
39
- module.exports = factory();
40
- else if(typeof undefined === 'function' && undefined.amd)
41
- undefined("pdfjs-dist/build/pdf", [], factory);
42
- else if('object' === 'object')
43
- exports["pdfjs-dist/build/pdf"] = factory();
44
- else
45
- root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory();
3316
+ module.exports = factory();
46
3317
  })(commonjsGlobal, function() {
47
3318
  return /******/ (() => { // webpackBootstrap
48
- /******/ "use strict";
49
3319
  /******/ var __webpack_modules__ = ([
50
3320
  /* 0 */,
51
3321
  /* 1 */
@@ -1603,9 +4873,7 @@ function createObjectURL(data, contentType = "", forceDataSchema = false) {
1603
4873
 
1604
4874
 
1605
4875
 
1606
- var _is_node = __w_pdfjs_require__(4);
1607
-
1608
- ;
4876
+ __w_pdfjs_require__(4);
1609
4877
 
1610
4878
  /***/ }),
1611
4879
  /* 4 */
@@ -4846,7 +8114,6 @@ const MAX_FONT_SIZE = 100;
4846
8114
  const MAX_GROUP_SIZE = 4096;
4847
8115
  const EXECUTION_TIME = 15;
4848
8116
  const EXECUTION_STEPS = 10;
4849
- const COMPILE_TYPE3_GLYPHS = true;
4850
8117
  const MAX_SIZE_TO_COMPILE = 1000;
4851
8118
  const FULL_CHUNK_HEIGHT = 16;
4852
8119
  const LINEWIDTH_SCALE_FACTOR = 1.000001;
@@ -7189,7 +10456,7 @@ class CanvasGraphics {
7189
10456
  height = img.height;
7190
10457
  const glyph = this.processingType3;
7191
10458
 
7192
- if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
10459
+ if (glyph && glyph.compiled === undefined) {
7193
10460
  if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
7194
10461
  glyph.compiled = compileType3Glyph({
7195
10462
  data: img.data,
@@ -9458,9 +12725,6 @@ class AnnotationElement {
9458
12725
  case _util.AnnotationBorderStyleType.UNDERLINE:
9459
12726
  container.style.borderBottomStyle = "solid";
9460
12727
  break;
9461
-
9462
- default:
9463
- break;
9464
12728
  }
9465
12729
 
9466
12730
  const borderColor = data.borderColor || data.color || null;
@@ -13324,7 +16588,7 @@ exports.SVGGraphics = SVGGraphics;
13324
16588
  }
13325
16589
 
13326
16590
  current.tspan.textContent += character;
13327
- } else {}
16591
+ }
13328
16592
 
13329
16593
  let charWidth;
13330
16594
 
@@ -14096,8 +17360,6 @@ var _util = __w_pdfjs_require__(2);
14096
17360
 
14097
17361
  var _network_utils = __w_pdfjs_require__(24);
14098
17362
 
14099
- ;
14100
-
14101
17363
  const fs = require$$5;
14102
17364
 
14103
17365
  const http = require$$5;
@@ -14841,8 +18103,6 @@ exports.PDFNetworkStream = void 0;
14841
18103
  var _util = __w_pdfjs_require__(2);
14842
18104
 
14843
18105
  var _network_utils = __w_pdfjs_require__(24);
14844
-
14845
- ;
14846
18106
  const OK_RESPONSE = 200;
14847
18107
  const PARTIAL_CONTENT_RESPONSE = 206;
14848
18108
 
@@ -15383,8 +18643,6 @@ var _util = __w_pdfjs_require__(2);
15383
18643
 
15384
18644
  var _network_utils = __w_pdfjs_require__(24);
15385
18645
 
15386
- ;
15387
-
15388
18646
  function createFetchOptions(headers, withCredentials, abortController) {
15389
18647
  return {
15390
18648
  method: "GET",
@@ -15930,9 +19188,6 @@ var _text_layer = __w_pdfjs_require__(21);
15930
19188
  var _svg = __w_pdfjs_require__(22);
15931
19189
 
15932
19190
  var _xfa_layer = __w_pdfjs_require__(20);
15933
-
15934
- const pdfjsVersion = '2.12.313';
15935
- const pdfjsBuild = 'a2ae56f39';
15936
19191
  {
15937
19192
  if (_is_node.isNodeJS) {
15938
19193
  const {
@@ -15971,9 +19226,6 @@ const pdfjsBuild = 'a2ae56f39';
15971
19226
 
15972
19227
  const pdf$1 = /*@__PURE__*/getDefaultExportFromCjs(pdf);
15973
19228
 
15974
- function format(first, middle, last) {
15975
- return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
15976
- }
15977
19229
  const integerSequence = (start, count) => Array(count)
15978
19230
  .fill(1)
15979
19231
  .map((_, index) => index + start);
@@ -16115,4 +19367,4 @@ const VerdocsView = class {
16115
19367
  };
16116
19368
  VerdocsView.style = verdocsViewCss;
16117
19369
 
16118
- export { VerdocsView as verdocs_view };
19370
+ export { VerdocsDropdown as verdocs_dropdown, VerdocsFieldAttachment as verdocs_field_attachment, VerdocsFieldCheckbox as verdocs_field_checkbox, VerdocsFieldDate as verdocs_field_date, VerdocsFieldDropdown as verdocs_field_dropdown, VerdocsFieldInitial as verdocs_field_initial, VerdocsFieldPayment as verdocs_field_payment, VerdocsFieldRadioButton as verdocs_field_radio_button, VerdocsFieldSignature as verdocs_field_signature, VerdocsFieldTextarea as verdocs_field_textarea, VerdocsFieldTextbox as verdocs_field_textbox, VerdocsView as verdocs_view };