@verdocs/web-sdk 1.4.0 → 1.4.7

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