@nylas/web-elements 1.1.0-canary.7 → 1.1.0-canary.8

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 (289) hide show
  1. package/dist/cjs/add-circle-icon_22.cjs.entry.js +22 -11
  2. package/dist/cjs/add-circle-icon_22.cjs.entry.js.map +1 -1
  3. package/dist/cjs/forward-icon_6.cjs.entry.js +2 -2
  4. package/dist/cjs/google-logo-icon_4.cjs.entry.js +2 -2
  5. package/dist/cjs/index-7af03e3f.js +158 -1
  6. package/dist/cjs/index-c14ea8f5.js +362 -1
  7. package/dist/cjs/index.cjs.js +2 -2
  8. package/dist/cjs/{index.es-b12b7df1.js → index.es-4a7d8d3f.js} +2 -2
  9. package/dist/cjs/{index.es-b12b7df1.js.map → index.es-4a7d8d3f.js.map} +1 -1
  10. package/dist/cjs/{index.es-0a0f2d87.js → index.es-b2cce060.js} +2 -2
  11. package/dist/cjs/{index.es-0a0f2d87.js.map → index.es-b2cce060.js.map} +1 -1
  12. package/dist/cjs/{mailbox-store-05fa3bec.js → mailbox-store-a2f858b7.js} +3 -3
  13. package/dist/cjs/{mailbox-store-05fa3bec.js.map → mailbox-store-a2f858b7.js.map} +1 -1
  14. package/dist/cjs/{mailbox-store-14531fd4.js → mailbox-store-ecceb918.js} +3 -3
  15. package/dist/cjs/{mailbox-store-14531fd4.js.map → mailbox-store-ecceb918.js.map} +1 -1
  16. package/dist/cjs/multi-select-dropdown.cjs.entry.js +1 -1
  17. package/dist/cjs/nylas-additional-participants.cjs.entry.js +2 -2
  18. package/dist/cjs/{nylas-api-request-27c25287.js → nylas-api-request-28b4576a.js} +2 -2
  19. package/dist/cjs/{nylas-api-request-27c25287.js.map → nylas-api-request-28b4576a.js.map} +1 -1
  20. package/dist/cjs/{nylas-api-request-abdb8dd8.js → nylas-api-request-c9e0e347.js} +2 -2
  21. package/dist/cjs/{nylas-api-request-abdb8dd8.js.map → nylas-api-request-c9e0e347.js.map} +1 -1
  22. package/dist/cjs/nylas-availability-picker.cjs.entry.js +2 -2
  23. package/dist/cjs/nylas-booked-event-card.cjs.entry.js +2 -2
  24. package/dist/cjs/nylas-booked-event-card_10.cjs.entry.js +2 -2
  25. package/dist/cjs/nylas-booking-calendar-picker.cjs.entry.js +2 -2
  26. package/dist/cjs/nylas-booking-form.cjs.entry.js +2 -2
  27. package/dist/cjs/nylas-buffer-time.cjs.entry.js +2 -2
  28. package/dist/cjs/nylas-calendar-picker.cjs.entry.js +2 -2
  29. package/dist/cjs/nylas-cancel-booking-form.cjs.entry.js +2 -2
  30. package/dist/cjs/nylas-cancelled-event-card.cjs.entry.js +2 -2
  31. package/dist/cjs/nylas-composer.cjs.entry.js +1 -1
  32. package/dist/cjs/nylas-custom-booking-flow.cjs.entry.js +2 -2
  33. package/dist/cjs/nylas-date-picker.cjs.entry.js +2 -2
  34. package/dist/cjs/nylas-editor-tabs.cjs.entry.js +2 -2
  35. package/dist/cjs/nylas-event-description.cjs.entry.js +2 -2
  36. package/dist/cjs/nylas-event-duration.cjs.entry.js +2 -2
  37. package/dist/cjs/nylas-event-info.cjs.entry.js +2 -2
  38. package/dist/cjs/nylas-event-limits.cjs.entry.js +2 -2
  39. package/dist/cjs/nylas-event-title.cjs.entry.js +22 -11
  40. package/dist/cjs/nylas-event-title.cjs.entry.js.map +1 -1
  41. package/dist/cjs/nylas-form-card.cjs.entry.js +2 -2
  42. package/dist/cjs/nylas-if-state.cjs.entry.js +2 -2
  43. package/dist/cjs/nylas-limit-future-bookings.cjs.entry.js +2 -2
  44. package/dist/cjs/nylas-list-configurations.cjs.entry.js +2 -2
  45. package/dist/cjs/nylas-list-folders.cjs.entry.js +2 -2
  46. package/dist/cjs/nylas-list-threads.cjs.entry.js +2 -2
  47. package/dist/cjs/nylas-locale-switch.cjs.entry.js +2 -2
  48. package/dist/cjs/nylas-location-component.cjs.entry.js +2 -2
  49. package/dist/cjs/nylas-login.cjs.entry.js +2 -2
  50. package/dist/cjs/nylas-mailbox-pagination.cjs.entry.js +2 -2
  51. package/dist/cjs/nylas-mailbox-toolbar-button.cjs.entry.js +2 -2
  52. package/dist/cjs/nylas-mailbox.cjs.entry.js +3 -3
  53. package/dist/cjs/nylas-min-cancellation-notice.cjs.entry.js +2 -2
  54. package/dist/cjs/nylas-notification.cjs.entry.js +1 -1
  55. package/dist/cjs/nylas-provider.cjs.entry.js +4 -4
  56. package/dist/cjs/nylas-scheduler-editor.cjs.entry.js +3 -3
  57. package/dist/cjs/nylas-scheduling.cjs.entry.js +3 -3
  58. package/dist/cjs/nylas-selected-event-card.cjs.entry.js +2 -2
  59. package/dist/cjs/nylas-summarize-message-button.cjs.entry.js +2 -2
  60. package/dist/cjs/nylas-threads-refresh.cjs.entry.js +2 -2
  61. package/dist/cjs/nylas-threads-search.cjs.entry.js +2 -2
  62. package/dist/cjs/nylas-time-window-picker.cjs.entry.js +1 -1
  63. package/dist/cjs/nylas-timeslot-picker.cjs.entry.js +2 -2
  64. package/dist/cjs/nylas-view-email.cjs.entry.js +1 -1
  65. package/dist/cjs/nylas-view-thread.cjs.entry.js +2 -2
  66. package/dist/cjs/{register-component-c8b6e907.js → register-component-7ecacf90.js} +2 -2
  67. package/dist/cjs/{register-component-09ebdf31.js.map → register-component-7ecacf90.js.map} +1 -1
  68. package/dist/cjs/{register-component-09ebdf31.js → register-component-98ab6f54.js} +2 -2
  69. package/dist/cjs/{register-component-c8b6e907.js.map → register-component-98ab6f54.js.map} +1 -1
  70. package/dist/cjs/{scheduler-store-67dc1986.js → scheduler-store-22103c86.js} +2 -2
  71. package/dist/cjs/{scheduler-store-0081970d.js.map → scheduler-store-22103c86.js.map} +1 -1
  72. package/dist/cjs/{scheduler-store-0081970d.js → scheduler-store-fad9ed7a.js} +2 -2
  73. package/dist/cjs/{scheduler-store-67dc1986.js.map → scheduler-store-fad9ed7a.js.map} +1 -1
  74. package/dist/cjs/time-period-selector.cjs.entry.js +1 -1
  75. package/dist/cjs/{utils-20663d54.js → utils-9fc33c77.js} +46 -1
  76. package/dist/cjs/utils-9fc33c77.js.map +1 -0
  77. package/dist/cjs/{utils-2c7f0895.js → utils-d8cfc3be.js} +46 -1
  78. package/dist/cjs/{utils-2c7f0895.js.map → utils-d8cfc3be.js.map} +1 -1
  79. package/dist/collection/components/scheduler-editor/nylas-event-title/nylas-event-title.js +21 -10
  80. package/dist/collection/components/scheduler-editor/nylas-event-title/nylas-event-title.js.map +1 -1
  81. package/dist/collection/utils/utils.js +44 -0
  82. package/dist/collection/utils/utils.js.map +1 -1
  83. package/dist/components/index.es.js +1 -1
  84. package/dist/components/nylas-event-title2.js +21 -10
  85. package/dist/components/nylas-event-title2.js.map +1 -1
  86. package/dist/components/nylas-list-folders.js +1 -1
  87. package/dist/components/nylas-list-threads.js +1 -1
  88. package/dist/components/nylas-summarize-message-button2.js +1 -1
  89. package/dist/components/nylas-view-email2.js +1 -1
  90. package/dist/components/nylas-view-thread.js +1 -1
  91. package/dist/components/utils.js +45 -1
  92. package/dist/components/utils.js.map +1 -1
  93. package/dist/esm/add-circle-icon_22.entry.js +22 -11
  94. package/dist/esm/add-circle-icon_22.entry.js.map +1 -1
  95. package/dist/esm/forward-icon_6.entry.js +2 -2
  96. package/dist/esm/google-logo-icon_4.entry.js +2 -2
  97. package/dist/esm/index-7cb0dd3d.js +158 -1
  98. package/dist/esm/index-8362ce5c.js +362 -1
  99. package/dist/esm/{index.es-f57e612a.js → index.es-df564f87.js} +2 -2
  100. package/dist/esm/{index.es-f57e612a.js.map → index.es-df564f87.js.map} +1 -1
  101. package/dist/{nylas-web-elements/index.es-2842f8c8.js → esm/index.es-e4f027a2.js} +2 -2
  102. package/dist/esm/{index.es-2842f8c8.js.map → index.es-e4f027a2.js.map} +1 -1
  103. package/dist/esm/index.js +2 -2
  104. package/dist/{nylas-web-elements/mailbox-store-d48269de.js → esm/mailbox-store-5075f820.js} +3 -3
  105. package/dist/{nylas-web-elements/mailbox-store-d48269de.js.map → esm/mailbox-store-5075f820.js.map} +1 -1
  106. package/dist/esm/{mailbox-store-47fc8a1a.js → mailbox-store-69c5c5f6.js} +3 -3
  107. package/dist/esm/{mailbox-store-47fc8a1a.js.map → mailbox-store-69c5c5f6.js.map} +1 -1
  108. package/dist/esm/multi-select-dropdown.entry.js +1 -1
  109. package/dist/esm/nylas-additional-participants.entry.js +2 -2
  110. package/dist/{nylas-web-elements/nylas-api-request-b085294d.js → esm/nylas-api-request-6a19db25.js} +2 -2
  111. package/dist/esm/{nylas-api-request-b085294d.js.map → nylas-api-request-6a19db25.js.map} +1 -1
  112. package/dist/esm/{nylas-api-request-8932547a.js → nylas-api-request-b49b1da6.js} +2 -2
  113. package/dist/esm/{nylas-api-request-8932547a.js.map → nylas-api-request-b49b1da6.js.map} +1 -1
  114. package/dist/esm/nylas-availability-picker.entry.js +2 -2
  115. package/dist/esm/nylas-booked-event-card.entry.js +2 -2
  116. package/dist/esm/nylas-booked-event-card_10.entry.js +2 -2
  117. package/dist/esm/nylas-booking-calendar-picker.entry.js +2 -2
  118. package/dist/esm/nylas-booking-form.entry.js +2 -2
  119. package/dist/esm/nylas-buffer-time.entry.js +2 -2
  120. package/dist/esm/nylas-calendar-picker.entry.js +2 -2
  121. package/dist/esm/nylas-cancel-booking-form.entry.js +2 -2
  122. package/dist/esm/nylas-cancelled-event-card.entry.js +2 -2
  123. package/dist/esm/nylas-composer.entry.js +1 -1
  124. package/dist/esm/nylas-custom-booking-flow.entry.js +2 -2
  125. package/dist/esm/nylas-date-picker.entry.js +2 -2
  126. package/dist/esm/nylas-editor-tabs.entry.js +2 -2
  127. package/dist/esm/nylas-event-description.entry.js +2 -2
  128. package/dist/esm/nylas-event-duration.entry.js +2 -2
  129. package/dist/esm/nylas-event-info.entry.js +2 -2
  130. package/dist/esm/nylas-event-limits.entry.js +2 -2
  131. package/dist/esm/nylas-event-title.entry.js +22 -11
  132. package/dist/esm/nylas-event-title.entry.js.map +1 -1
  133. package/dist/esm/nylas-form-card.entry.js +2 -2
  134. package/dist/esm/nylas-if-state.entry.js +2 -2
  135. package/dist/esm/nylas-limit-future-bookings.entry.js +2 -2
  136. package/dist/esm/nylas-list-configurations.entry.js +2 -2
  137. package/dist/esm/nylas-list-folders.entry.js +2 -2
  138. package/dist/esm/nylas-list-threads.entry.js +2 -2
  139. package/dist/esm/nylas-locale-switch.entry.js +2 -2
  140. package/dist/esm/nylas-location-component.entry.js +2 -2
  141. package/dist/esm/nylas-login.entry.js +2 -2
  142. package/dist/esm/nylas-mailbox-pagination.entry.js +2 -2
  143. package/dist/esm/nylas-mailbox-toolbar-button.entry.js +2 -2
  144. package/dist/esm/nylas-mailbox.entry.js +3 -3
  145. package/dist/esm/nylas-min-cancellation-notice.entry.js +2 -2
  146. package/dist/esm/nylas-notification.entry.js +1 -1
  147. package/dist/esm/nylas-provider.entry.js +4 -4
  148. package/dist/esm/nylas-scheduler-editor.entry.js +3 -3
  149. package/dist/esm/nylas-scheduling.entry.js +3 -3
  150. package/dist/esm/nylas-selected-event-card.entry.js +2 -2
  151. package/dist/esm/nylas-summarize-message-button.entry.js +2 -2
  152. package/dist/esm/nylas-threads-refresh.entry.js +2 -2
  153. package/dist/esm/nylas-threads-search.entry.js +2 -2
  154. package/dist/esm/nylas-time-window-picker.entry.js +1 -1
  155. package/dist/esm/nylas-timeslot-picker.entry.js +2 -2
  156. package/dist/esm/nylas-view-email.entry.js +1 -1
  157. package/dist/esm/nylas-view-thread.entry.js +2 -2
  158. package/dist/esm/{register-component-cf5c8420.js → register-component-b9cfcbaf.js} +2 -2
  159. package/dist/esm/{register-component-cf5c8420.js.map → register-component-b9cfcbaf.js.map} +1 -1
  160. package/dist/{nylas-web-elements/register-component-e5afe237.js → esm/register-component-ff6f5df4.js} +2 -2
  161. package/dist/esm/{register-component-e5afe237.js.map → register-component-ff6f5df4.js.map} +1 -1
  162. package/dist/esm/{scheduler-store-a175fc3e.js → scheduler-store-24fd0e91.js} +2 -2
  163. package/dist/{nylas-web-elements/scheduler-store-66c2168c.js.map → esm/scheduler-store-24fd0e91.js.map} +1 -1
  164. package/dist/esm/{scheduler-store-66c2168c.js → scheduler-store-e62b2146.js} +2 -2
  165. package/dist/esm/{scheduler-store-66c2168c.js.map → scheduler-store-e62b2146.js.map} +1 -1
  166. package/dist/esm/time-period-selector.entry.js +1 -1
  167. package/dist/{nylas-web-elements/utils-73d8a928.js → esm/utils-3e18e0b2.js} +46 -2
  168. package/dist/esm/{utils-73d8a928.js.map → utils-3e18e0b2.js.map} +1 -1
  169. package/dist/esm/{utils-d6204242.js → utils-db11d29c.js} +46 -2
  170. package/dist/esm/utils-db11d29c.js.map +1 -0
  171. package/dist/{esm/index.es-2842f8c8.js → nylas-web-elements/index.es-e4f027a2.js} +2 -2
  172. package/dist/nylas-web-elements/{index.es-2842f8c8.js.map → index.es-e4f027a2.js.map} +1 -1
  173. package/dist/nylas-web-elements/index.esm.js +2 -2
  174. package/dist/{esm/mailbox-store-d48269de.js → nylas-web-elements/mailbox-store-5075f820.js} +3 -3
  175. package/dist/{esm/mailbox-store-d48269de.js.map → nylas-web-elements/mailbox-store-5075f820.js.map} +1 -1
  176. package/dist/nylas-web-elements/multi-select-dropdown.entry.js +1 -1
  177. package/dist/nylas-web-elements/nylas-additional-participants.entry.js +2 -2
  178. package/dist/{esm/nylas-api-request-b085294d.js → nylas-web-elements/nylas-api-request-6a19db25.js} +2 -2
  179. package/dist/nylas-web-elements/{nylas-api-request-b085294d.js.map → nylas-api-request-6a19db25.js.map} +1 -1
  180. package/dist/nylas-web-elements/nylas-availability-picker.entry.js +2 -2
  181. package/dist/nylas-web-elements/nylas-booked-event-card.entry.js +2 -2
  182. package/dist/nylas-web-elements/nylas-booking-calendar-picker.entry.js +2 -2
  183. package/dist/nylas-web-elements/nylas-booking-form.entry.js +2 -2
  184. package/dist/nylas-web-elements/nylas-buffer-time.entry.js +2 -2
  185. package/dist/nylas-web-elements/nylas-calendar-picker.entry.js +2 -2
  186. package/dist/nylas-web-elements/nylas-cancel-booking-form.entry.js +2 -2
  187. package/dist/nylas-web-elements/nylas-cancelled-event-card.entry.js +2 -2
  188. package/dist/nylas-web-elements/nylas-composer.entry.js +1 -1
  189. package/dist/nylas-web-elements/nylas-custom-booking-flow.entry.js +2 -2
  190. package/dist/nylas-web-elements/nylas-date-picker.entry.js +2 -2
  191. package/dist/nylas-web-elements/nylas-editor-tabs.entry.js +2 -2
  192. package/dist/nylas-web-elements/nylas-event-description.entry.js +2 -2
  193. package/dist/nylas-web-elements/nylas-event-duration.entry.js +2 -2
  194. package/dist/nylas-web-elements/nylas-event-info.entry.js +2 -2
  195. package/dist/nylas-web-elements/nylas-event-limits.entry.js +2 -2
  196. package/dist/nylas-web-elements/nylas-event-title.entry.js +22 -11
  197. package/dist/nylas-web-elements/nylas-event-title.entry.js.map +1 -1
  198. package/dist/nylas-web-elements/nylas-form-card.entry.js +2 -2
  199. package/dist/nylas-web-elements/nylas-if-state.entry.js +2 -2
  200. package/dist/nylas-web-elements/nylas-limit-future-bookings.entry.js +2 -2
  201. package/dist/nylas-web-elements/nylas-list-configurations.entry.js +2 -2
  202. package/dist/nylas-web-elements/nylas-list-folders.entry.js +2 -2
  203. package/dist/nylas-web-elements/nylas-list-threads.entry.js +2 -2
  204. package/dist/nylas-web-elements/nylas-locale-switch.entry.js +2 -2
  205. package/dist/nylas-web-elements/nylas-location-component.entry.js +2 -2
  206. package/dist/nylas-web-elements/nylas-login.entry.js +2 -2
  207. package/dist/nylas-web-elements/nylas-mailbox-pagination.entry.js +2 -2
  208. package/dist/nylas-web-elements/nylas-mailbox-toolbar-button.entry.js +2 -2
  209. package/dist/nylas-web-elements/nylas-mailbox.entry.js +3 -3
  210. package/dist/nylas-web-elements/nylas-min-cancellation-notice.entry.js +2 -2
  211. package/dist/nylas-web-elements/nylas-notification.entry.js +1 -1
  212. package/dist/nylas-web-elements/nylas-provider.entry.js +4 -4
  213. package/dist/nylas-web-elements/nylas-scheduler-editor.entry.js +3 -3
  214. package/dist/nylas-web-elements/nylas-scheduling.entry.js +3 -3
  215. package/dist/nylas-web-elements/nylas-selected-event-card.entry.js +2 -2
  216. package/dist/nylas-web-elements/nylas-summarize-message-button.entry.js +2 -2
  217. package/dist/nylas-web-elements/nylas-threads-refresh.entry.js +2 -2
  218. package/dist/nylas-web-elements/nylas-threads-search.entry.js +2 -2
  219. package/dist/nylas-web-elements/nylas-time-window-picker.entry.js +1 -1
  220. package/dist/nylas-web-elements/nylas-timeslot-picker.entry.js +2 -2
  221. package/dist/nylas-web-elements/nylas-view-email.entry.js +1 -1
  222. package/dist/nylas-web-elements/nylas-view-thread.entry.js +2 -2
  223. package/dist/nylas-web-elements/{p-30784693.entry.js → p-074919b0.entry.js} +2 -2
  224. package/dist/nylas-web-elements/{p-f154a362.entry.js → p-21c3dcad.entry.js} +2 -2
  225. package/dist/nylas-web-elements/{p-42791515.entry.js → p-22531c3d.entry.js} +2 -2
  226. package/dist/nylas-web-elements/{p-7c55dfa0.entry.js → p-2d151de9.entry.js} +2 -2
  227. package/dist/nylas-web-elements/{p-3909ec3f.entry.js → p-349f07e3.entry.js} +2 -2
  228. package/dist/nylas-web-elements/{p-e03b2592.entry.js → p-4154e97e.entry.js} +2 -2
  229. package/dist/nylas-web-elements/{p-bbf9aff2.entry.js → p-434fcde2.entry.js} +2 -2
  230. package/dist/nylas-web-elements/{p-e22aa0b0.js → p-47b99cf5.js} +2 -2
  231. package/dist/nylas-web-elements/{p-22e5436c.js → p-4c12e1e9.js} +2 -2
  232. package/dist/nylas-web-elements/{p-80d6175c.entry.js → p-5caa0f36.entry.js} +2 -2
  233. package/dist/nylas-web-elements/{p-df6d54c7.entry.js → p-7614e31e.entry.js} +2 -2
  234. package/dist/nylas-web-elements/{p-1d25ca06.entry.js → p-7687925d.entry.js} +2 -2
  235. package/dist/nylas-web-elements/{p-75a8d077.entry.js → p-828165d3.entry.js} +2 -2
  236. package/dist/nylas-web-elements/{p-cc674b3b.entry.js → p-980c32d9.entry.js} +2 -2
  237. package/dist/nylas-web-elements/{p-ad64c2b8.entry.js → p-a17f542c.entry.js} +2 -2
  238. package/dist/nylas-web-elements/{p-a628eaeb.js → p-a3b1a98c.js} +2 -2
  239. package/dist/nylas-web-elements/{p-41dc0d93.js → p-ad7cf473.js} +2 -2
  240. package/dist/nylas-web-elements/p-ad7cf473.js.map +1 -0
  241. package/dist/nylas-web-elements/{p-343b8684.entry.js → p-bb89e973.entry.js} +2 -2
  242. package/dist/nylas-web-elements/{p-1a91cce5.entry.js → p-c529dced.entry.js} +2 -2
  243. package/dist/nylas-web-elements/{p-33b940fb.entry.js → p-d5375409.entry.js} +2 -2
  244. package/dist/nylas-web-elements/p-da74ec1c.entry.js +2 -0
  245. package/dist/nylas-web-elements/p-da74ec1c.entry.js.map +1 -0
  246. package/dist/nylas-web-elements/{p-9ea458c3.js → p-f0250b7d.js} +2 -2
  247. package/dist/nylas-web-elements/{p-eaa9151b.js → p-f0f3f350.js} +2 -2
  248. package/dist/nylas-web-elements/{p-6110351b.entry.js → p-f3974e14.entry.js} +2 -2
  249. package/dist/nylas-web-elements/{p-f1f8f745.entry.js → p-f47163ac.entry.js} +2 -2
  250. package/dist/nylas-web-elements/{p-665ef10b.entry.js → p-f5d17746.entry.js} +2 -2
  251. package/dist/{esm/register-component-e5afe237.js → nylas-web-elements/register-component-ff6f5df4.js} +2 -2
  252. package/dist/nylas-web-elements/{register-component-e5afe237.js.map → register-component-ff6f5df4.js.map} +1 -1
  253. package/dist/nylas-web-elements/{scheduler-store-66c2168c.js → scheduler-store-e62b2146.js} +2 -2
  254. package/dist/{esm/scheduler-store-a175fc3e.js.map → nylas-web-elements/scheduler-store-e62b2146.js.map} +1 -1
  255. package/dist/nylas-web-elements/time-period-selector.entry.js +1 -1
  256. package/dist/{esm/utils-73d8a928.js → nylas-web-elements/utils-3e18e0b2.js} +46 -2
  257. package/dist/nylas-web-elements/{utils-73d8a928.js.map → utils-3e18e0b2.js.map} +1 -1
  258. package/dist/types/components/scheduler-editor/nylas-event-title/nylas-event-title.d.ts +1 -0
  259. package/dist/types/utils/utils.d.ts +1 -0
  260. package/package.json +1 -1
  261. package/dist/cjs/utils-20663d54.js.map +0 -1
  262. package/dist/esm/utils-d6204242.js.map +0 -1
  263. package/dist/nylas-web-elements/p-2b636359.entry.js +0 -2
  264. package/dist/nylas-web-elements/p-2b636359.entry.js.map +0 -1
  265. package/dist/nylas-web-elements/p-41dc0d93.js.map +0 -1
  266. /package/dist/nylas-web-elements/{p-30784693.entry.js.map → p-074919b0.entry.js.map} +0 -0
  267. /package/dist/nylas-web-elements/{p-f154a362.entry.js.map → p-21c3dcad.entry.js.map} +0 -0
  268. /package/dist/nylas-web-elements/{p-42791515.entry.js.map → p-22531c3d.entry.js.map} +0 -0
  269. /package/dist/nylas-web-elements/{p-7c55dfa0.entry.js.map → p-2d151de9.entry.js.map} +0 -0
  270. /package/dist/nylas-web-elements/{p-3909ec3f.entry.js.map → p-349f07e3.entry.js.map} +0 -0
  271. /package/dist/nylas-web-elements/{p-e03b2592.entry.js.map → p-4154e97e.entry.js.map} +0 -0
  272. /package/dist/nylas-web-elements/{p-bbf9aff2.entry.js.map → p-434fcde2.entry.js.map} +0 -0
  273. /package/dist/nylas-web-elements/{p-e22aa0b0.js.map → p-47b99cf5.js.map} +0 -0
  274. /package/dist/nylas-web-elements/{p-22e5436c.js.map → p-4c12e1e9.js.map} +0 -0
  275. /package/dist/nylas-web-elements/{p-80d6175c.entry.js.map → p-5caa0f36.entry.js.map} +0 -0
  276. /package/dist/nylas-web-elements/{p-df6d54c7.entry.js.map → p-7614e31e.entry.js.map} +0 -0
  277. /package/dist/nylas-web-elements/{p-1d25ca06.entry.js.map → p-7687925d.entry.js.map} +0 -0
  278. /package/dist/nylas-web-elements/{p-75a8d077.entry.js.map → p-828165d3.entry.js.map} +0 -0
  279. /package/dist/nylas-web-elements/{p-cc674b3b.entry.js.map → p-980c32d9.entry.js.map} +0 -0
  280. /package/dist/nylas-web-elements/{p-ad64c2b8.entry.js.map → p-a17f542c.entry.js.map} +0 -0
  281. /package/dist/nylas-web-elements/{p-a628eaeb.js.map → p-a3b1a98c.js.map} +0 -0
  282. /package/dist/nylas-web-elements/{p-343b8684.entry.js.map → p-bb89e973.entry.js.map} +0 -0
  283. /package/dist/nylas-web-elements/{p-1a91cce5.entry.js.map → p-c529dced.entry.js.map} +0 -0
  284. /package/dist/nylas-web-elements/{p-33b940fb.entry.js.map → p-d5375409.entry.js.map} +0 -0
  285. /package/dist/nylas-web-elements/{p-9ea458c3.js.map → p-f0250b7d.js.map} +0 -0
  286. /package/dist/nylas-web-elements/{p-eaa9151b.js.map → p-f0f3f350.js.map} +0 -0
  287. /package/dist/nylas-web-elements/{p-6110351b.entry.js.map → p-f3974e14.entry.js.map} +0 -0
  288. /package/dist/nylas-web-elements/{p-f1f8f745.entry.js.map → p-f47163ac.entry.js.map} +0 -0
  289. /package/dist/nylas-web-elements/{p-665ef10b.entry.js.map → p-f5d17746.entry.js.map} +0 -0
@@ -13,7 +13,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
13
13
  return Reflect.metadata(k, v);
14
14
  };
15
15
  import { RegisterComponent } from "../../../common/register-component";
16
- import { debug, getBrowser } from "../../../utils/utils";
16
+ import { debug, getBrowser, isNonPrintableKey } from "../../../utils/utils";
17
17
  import { Host, h } from "@stencil/core";
18
18
  import { EVENT_TITLE_TOKENS as eventTitleTokens } from "../../../common/constants";
19
19
  export class NylasEventTitle {
@@ -101,7 +101,7 @@ export class NylasEventTitle {
101
101
  return outputHtml;
102
102
  }
103
103
  getCurrentSelectionForBrowser() {
104
- const getSelectionTextData = (nodeValue, offset, node) => {
104
+ const getSelectionTextData = (nodeValue, offset, node, allSelected) => {
105
105
  const text = nodeValue.replace(/[\u200B-\u200D\uFEFF]/g, '');
106
106
  const dollarIndex = text.lastIndexOf('$');
107
107
  const lastWord = text.substring(dollarIndex).split(' ')[0];
@@ -111,24 +111,29 @@ export class NylasEventTitle {
111
111
  lastWord,
112
112
  currentText: text,
113
113
  node,
114
+ allSelected,
114
115
  };
115
116
  };
117
+ const isAllSelected = (selection) => selection.anchorOffset === 0 && selection.focusOffset === selection.focusNode?.nodeValue?.length;
116
118
  const currentBrowser = getBrowser();
117
119
  switch (currentBrowser) {
118
120
  case 'Chrome':
119
121
  const shadowRootSelection = this.host.shadowRoot?.getSelection();
120
122
  const focusNode = shadowRootSelection?.focusNode;
121
123
  const focusNodeValue = focusNode?.nodeValue || '';
122
- return getSelectionTextData(focusNodeValue, shadowRootSelection?.focusOffset || -1, focusNode);
124
+ const allSelected = shadowRootSelection && isAllSelected(shadowRootSelection);
125
+ return getSelectionTextData(focusNodeValue, shadowRootSelection?.focusOffset || -1, focusNode, allSelected);
123
126
  case 'Firefox':
124
127
  const selection = document.getSelection();
125
128
  const anchorNodeValue = selection?.anchorNode?.nodeValue || '';
126
- return getSelectionTextData(anchorNodeValue, selection?.focusOffset || -1, selection?.anchorNode);
129
+ const allSelectedFirefox = selection && isAllSelected(selection);
130
+ return getSelectionTextData(anchorNodeValue, selection?.focusOffset || -1, selection?.anchorNode, allSelectedFirefox);
127
131
  case 'Safari':
128
132
  const windowSelection = window.getSelection();
129
133
  const anchorNode = windowSelection?.getComposedRanges(this.host.shadowRoot)[0];
130
134
  const currentText = anchorNode?.startContainer?.nodeValue || '';
131
- return getSelectionTextData(currentText, anchorNode?.endOffset || -1, anchorNode?.startContainer);
135
+ const allSelectedSafari = windowSelection && isAllSelected(windowSelection);
136
+ return getSelectionTextData(currentText, anchorNode?.endOffset || -1, anchorNode?.startContainer, allSelectedSafari);
132
137
  default:
133
138
  console.warn('Browser not supported');
134
139
  return null;
@@ -164,6 +169,10 @@ export class NylasEventTitle {
164
169
  this.updateEventTitle(textContent);
165
170
  }
166
171
  handleInputKeyDown(event) {
172
+ const selection = this.getCurrentSelectionForBrowser();
173
+ if (selection?.allSelected && !isNonPrintableKey(event)) {
174
+ this.titleRef.innerHTML = '';
175
+ }
167
176
  if (event.key === 'Enter') {
168
177
  event.preventDefault();
169
178
  const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);
@@ -209,10 +218,12 @@ export class NylasEventTitle {
209
218
  this.resetDropdown();
210
219
  }
211
220
  else if (event.key === 'Backspace' || event.key === 'Delete') {
212
- const selection = this.getCurrentSelectionForBrowser();
213
221
  if (selection?.currentText.startsWith('${')) {
214
222
  selection?.node?.parentNode && selection.node.parentNode.removeChild(selection.node);
215
223
  }
224
+ if (this.titleRef.textContent === '' || selection?.currentText === '' || selection?.allSelected) {
225
+ this.titleRef.innerHTML = '';
226
+ }
216
227
  }
217
228
  }
218
229
  selectOption(e, option) {
@@ -247,12 +258,12 @@ export class NylasEventTitle {
247
258
  const newTextNodeAfter = document.createTextNode(textAfter);
248
259
  if (textAfter !== '') {
249
260
  textNode.replaceWith(newTextNode, tagSpan, newTextNodeAfter);
250
- newRange.setStart(newTextNodeAfter, 0);
261
+ newRange.setStart(newTextNodeAfter, 1);
251
262
  }
252
263
  else {
253
264
  const afterNode = document.createTextNode('\u200B');
254
265
  textNode.replaceWith(newTextNode, tagSpan, afterNode);
255
- newRange.setStart(afterNode, 0);
266
+ newRange.setStart(afterNode, 1);
256
267
  }
257
268
  this.resetDropdown();
258
269
  this.titleRef.focus();
@@ -291,10 +302,10 @@ export class NylasEventTitle {
291
302
  return (h("div", { class: "token-label" }, h("span", { class: "token" }, token.token), h("span", { class: "description" }, token.description)));
292
303
  }
293
304
  render() {
294
- return (h(Host, { key: '9287b1b2cb59f9cd83d585807070b8aaa4821a6c' }, h("div", { key: '02ca37b1b68691faf69c6cdd062475f10a87653c', class: "nylas-event-title", part: "net" }, h("label", { key: 'ceeda06d9da67727cdb5fce90b182a28cc3408e1', htmlFor: "title" }, "Event title", h("span", { key: 'd0e6b3387661a7f23a4796611f4854cf64b3bd9f', class: "required" }, "*"), h("span", { key: '84d0dd45f6a21504849aabf195676af2dacc40b2', class: "label-icon" }, h("tooltip-component", { key: 'bc8d5fbbd455a5d983ebb037e3d93e6dc2619cbd' }, h("info-icon", { key: '5c16591baceb37a8739c70b6fa505de08813ff0f', slot: "tooltip-icon" }), h("span", { key: '8214ecaad02beb8da5e0595aa13ff7057a0e60cc', slot: "tooltip-content" }, "Enter a title for your event.")))), h("div", { key: '98e9885cb4acd028908d7fb1b2a028cffd0dc7d4', class: {
305
+ return (h(Host, { key: 'e0ddf6c13a5a0c0d2e0db9188365418fb7484dcf' }, h("div", { key: 'a3b8e594c8d9632709e777891f04df0aaaf7c5c3', class: "nylas-event-title", part: "net" }, h("label", { key: 'e5794d2cd8be0b1666bfa67c3ea657da5dc8d45d', htmlFor: "title" }, "Event title", h("span", { key: '1210caceb7bf824f01559460e1c5e572cb2dad92', class: "required" }, "*"), h("span", { key: '4280ec285221e6db76ca08723fe3888a1d2643e3', class: "label-icon" }, h("tooltip-component", { key: 'd6c05fb79cf39656af7589a2e9de9ef832d7a2f8' }, h("info-icon", { key: 'a4659d97d60d00dfcc2c993e70da5cfd05904f78', slot: "tooltip-icon" }), h("span", { key: '738bfa669eec42b417be02fbad0584af34044c83', slot: "tooltip-content" }, "Enter a title for your event.")))), h("div", { key: 'df102dc899f8de91154689d9cdaae28465380622', class: {
295
306
  title: true,
296
307
  error: this.validationError !== '',
297
- }, part: "net__title", ref: el => (this.titleRef = el), contentEditable: "true", onInput: e => this.handleChange(e), onKeyDown: event => this.handleInputKeyDown(event) }), this.showTokens && this.filteredTokens?.length > 0 && (h("div", { class: "token-options", part: "net__dropdown-content" }, h("ul", { tabindex: "-1", role: "listbox", "aria-label": this.name, "aria-activedescendant": this.ariaActivedescendant }, this.filteredTokens.map(option => (h("li", { tabindex: "0", key: option.label, id: option.label, class: { active: this.ariaActivedescendant === option.label }, onClick: e => this.selectOption(e, option), role: "option" }, this.getLabelHTML(option.labelHTML))))))), h("span", { key: 'a2a15145119acf95335728589c24138386032188', class: "help-text" }, "Create a dynamic templated event title by typing $. Learn more"), this.validationError != '' && h("span", { class: "error-message" }, this.validationError))));
308
+ }, part: "net__title", ref: el => (this.titleRef = el), contentEditable: "true", onInput: e => this.handleChange(e), onKeyDown: event => this.handleInputKeyDown(event) }), this.showTokens && this.filteredTokens?.length > 0 && (h("div", { class: "token-options", part: "net__dropdown-content" }, h("ul", { tabindex: "-1", role: "listbox", "aria-label": this.name, "aria-activedescendant": this.ariaActivedescendant }, this.filteredTokens.map(option => (h("li", { tabindex: "0", key: option.label, id: option.label, class: { active: this.ariaActivedescendant === option.label }, onClick: e => this.selectOption(e, option), role: "option" }, this.getLabelHTML(option.labelHTML))))))), h("span", { key: 'ec769eea7e2e3ff6d64bef0f5099540c93ba80ab', class: "help-text" }, "Create a dynamic templated event title by typing $. Learn more"), this.validationError != '' && h("span", { class: "error-message" }, this.validationError))));
298
309
  }
299
310
  static get is() { return "nylas-event-title"; }
300
311
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"nylas-event-title.js","sourceRoot":"","sources":["../../../../src/components/scheduler-editor/nylas-event-title/nylas-event-title.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AAE9H,OAAO,EAAE,kBAAkB,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAyB5E,MAAM,OAAO,eAAe;;;0BAYI,IAAI,CAAC,qBAAqB,EAAE,aAAa,EAAE,KAAK;oBAIvD,OAAO;0BAMC,KAAK;+BAI6C,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC9G,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,KAAK;SACjB,CAA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SchedulerConfigConnector } from '@/connector/nylas-scheduler-config-connector';\nimport { debug, getBrowser } from '@/utils/utils';\nimport { AttachInternals, Component, Host, State, h, Element, Prop, Watch, Event, EventEmitter, Listen } from '@stencil/core';\nimport { NylasSchedulerEditor } from '../nylas-scheduler-editor/nylas-scheduler-editor';\nimport { EVENT_TITLE_TOKENS as eventTitleTokens } from '@/common/constants';\nimport { Configuration } from '@nylas/core';\n\ninterface CustomShadowRoot extends ShadowRoot {\n getSelection: () => Selection | null;\n}\n\ntype Token = {\n token: string;\n value: string;\n description: string;\n};\n\n/**\n * The `nylas-event-title` component is a form input for the title of an event.\n * @part net - The event title container\n * @part net__title - The event title input\n * @part net__dropdown-content - The token options container\n */\n@Component({\n tag: 'nylas-event-title',\n styleUrl: 'nylas-event-title.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class NylasEventTitle {\n @Element() host!: HTMLElement;\n @AttachInternals() internals!: ElementInternals;\n\n // Properties\n /**\n * The selected config\n */\n @Prop() selectedConfiguration?: Configuration;\n /**\n * The title of the event from the cofiguration.\n */\n @Prop() eventTitle?: string = this.selectedConfiguration?.event_booking?.title;\n /**\n * The name attribute of this component.\n */\n @Prop() name: string = 'title';\n\n // State variables\n /**\n * Whether to show the tokens dropdown.\n */\n @State() showTokens: boolean = false;\n /**\n * The available token options for the dropdown.\n */\n @State() availableTokens: { label: string; value: string; labelHTML: Token }[] = eventTitleTokens.map(token => ({\n label: token.token,\n value: token.value,\n labelHTML: token,\n }));\n /**\n * The filtered token options for the dropdown based on the current query.\n */\n @State() filteredTokens: { label: string; value: string; labelHTML: Token }[] = this.availableTokens;\n /**\n * The aria-activedescendant attribute value. This is used to indicate the\n * currently active descendant in the tokens dropdown.\n */\n @State() ariaActivedescendant: string = '';\n /**\n * Stores the reference to the current word being typed.\n * This is used to update the event title with the selected token tag when\n * an option is selected from the dropdown by clicking on it.\n */\n @State() currentWord: {\n $value: string;\n fullText: string;\n index: number;\n focusOffset: number;\n } = { $value: '', fullText: '', index: -1, focusOffset: -1 };\n\n @State() validationError: string = '';\n\n // Reference to the title div element\n private titleRef!: HTMLDivElement;\n\n /**\n * When a name prop is passed, stencil does not automatically set the name attribute on the host element.\n * Since this component is form-associated, the name attribute is required for form submission.\n * This is a workaround to ensure that the name attribute is set on the host element.\n */\n @Watch('name')\n elementNameChangedHandler(newValue: string) {\n debug('nylas-event-title', 'elementNameChangedHandler', newValue);\n this.host.setAttribute('name', newValue);\n }\n\n @Watch('ariaActivedescendant')\n ariaActivedescendantChangedHandler(newValue: string) {\n debug('nylas-event-title', 'ariaActivedescendantChangedHandler', newValue);\n if (newValue !== '') {\n const activeOption = this.host.shadowRoot?.getElementById(newValue);\n activeOption?.classList.add('active');\n } else {\n const options = this.host.shadowRoot?.querySelectorAll('.token-options li.active');\n options?.forEach(option => option.classList.remove('active'));\n }\n }\n\n @Watch('selectedConfiguration')\n configChangedHandler(newVal) {\n const title = newVal?.event_booking?.title;\n if (title) {\n this.updateEventTitleFromProp(title);\n }\n }\n\n // Events\n /**\n * This event is fired when the value of the event title changes.\n */\n @Event() valueChanged!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n // Lifecycle methods\n connectedCallback() {\n debug('nylas-event-title', 'connectedCallback');\n }\n\n componentWillLoad() {\n debug('nylas-event-title', 'componentWillLoad');\n this.host.setAttribute('name', this.name);\n }\n\n componentDidLoad() {\n debug('nylas-event-title', 'componentDidLoad');\n this.updateEventTitleFromProp(this.eventTitle || '');\n }\n\n disconnectedCallback() {\n debug('nylas-event-title', 'disconnectedCallback');\n }\n\n @Listen('formSubmitted', { target: 'window' })\n formSubmittedHandler(event: CustomEvent) {\n debug('nylas-event-title', 'formSubmittedHandler', event);\n if (!this.internals?.validity?.valid) {\n this.validationError = 'Event title is required';\n } else {\n this.validationError = '';\n }\n }\n\n updateEventTitleFromProp(newValue: string) {\n debug('nylas-event-title', 'eventTitleChangedHandler', newValue);\n if (this.titleRef) {\n this.titleRef.innerHTML = this.highlightTokens(newValue);\n this.titleRef.focus();\n if (typeof this.internals.setValidity === 'function') {\n if (newValue === '') {\n this.internals?.setValidity({ customError: true }, `Event title is required`, this.titleRef);\n } else {\n this.internals?.setValidity({ customError: false });\n }\n }\n }\n }\n\n highlightTokens(title: string) {\n let outputHtml = title;\n\n eventTitleTokens.forEach(tokenObj => {\n const token = tokenObj.value;\n // Create a regular expression that matches the token as a whole word\n const regex = new RegExp(`(\\\\${token})(?!\\\\w)`, 'g');\n // Replace the token with a span element\n outputHtml = outputHtml.replace(regex, '<span class=\"highlighted-tag\">$1</span>');\n });\n return outputHtml;\n }\n\n getCurrentSelectionForBrowser() {\n const getSelectionTextData = (nodeValue, offset, node) => {\n // Remove zero-width space characters from the text, because they are not visible and cause issues with the selection\n const text = nodeValue.replace(/[\\u200B-\\u200D\\uFEFF]/g, '');\n const dollarIndex = text.lastIndexOf('$');\n const lastWord = text.substring(dollarIndex).split(' ')[0];\n return {\n focusOffset: offset,\n dollarIndex,\n lastWord,\n currentText: text,\n node,\n };\n };\n\n const currentBrowser = getBrowser();\n switch (currentBrowser) {\n case 'Chrome':\n const shadowRootSelection = (this.host.shadowRoot as CustomShadowRoot)?.getSelection();\n const focusNode = shadowRootSelection?.focusNode;\n const focusNodeValue = focusNode?.nodeValue || '';\n return getSelectionTextData(focusNodeValue, shadowRootSelection?.focusOffset || -1, focusNode);\n case 'Firefox':\n const selection = document.getSelection();\n const anchorNodeValue = selection?.anchorNode?.nodeValue || '';\n return getSelectionTextData(anchorNodeValue, selection?.focusOffset || -1, selection?.anchorNode);\n case 'Safari':\n const windowSelection = window.getSelection();\n const anchorNode = (windowSelection as any)?.getComposedRanges(this.host.shadowRoot as CustomShadowRoot)[0];\n const currentText = anchorNode?.startContainer?.nodeValue || '';\n return getSelectionTextData(currentText, anchorNode?.endOffset || -1, anchorNode?.startContainer);\n default:\n console.warn('Browser not supported');\n return null;\n }\n }\n\n handleChange(event: Event) {\n const textContent = (event.target as HTMLDivElement).textContent || '';\n // All browsers handle Selection within Shadow DOM differently, so get the current selection based on the browser\n const currentSelection = this.getCurrentSelectionForBrowser();\n if (!currentSelection) {\n this.updateEventTitle(textContent);\n this.resetDropdown();\n return;\n }\n const { focusOffset, dollarIndex, lastWord, currentText } = currentSelection;\n\n if (dollarIndex === -1 || focusOffset < dollarIndex) {\n this.updateEventTitle(textContent);\n this.resetDropdown();\n return;\n }\n if (lastWord.startsWith('$')) {\n this.showTokens = true;\n // Update the current word being typed, we need this reference to update the event title with the selected token\n // because the user can select an option from the dropdown by clicking on it, which will not trigger the input event.\n this.currentWord = {\n $value: lastWord,\n fullText: currentText,\n index: dollarIndex,\n focusOffset,\n };\n this.populateSuggestionsDropdown(lastWord);\n } else {\n this.resetDropdown();\n }\n this.updateEventTitle(textContent);\n }\n\n handleInputKeyDown(event) {\n if (event.key === 'Enter') {\n event.preventDefault();\n const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);\n if (activeOption) {\n activeOption.click();\n this.ariaActivedescendant = '';\n }\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);\n if (activeOption) {\n const nextOption = activeOption.nextElementSibling;\n if (nextOption) {\n this.ariaActivedescendant = nextOption.id;\n } else {\n this.ariaActivedescendant = this.filteredTokens[0].label;\n }\n } else {\n this.ariaActivedescendant = this.filteredTokens[0].label;\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);\n if (activeOption) {\n const prevOption = activeOption.previousElementSibling;\n if (prevOption) {\n this.ariaActivedescendant = prevOption.id;\n } else {\n this.ariaActivedescendant = this.filteredTokens[this.filteredTokens.length - 1].label;\n }\n } else {\n this.ariaActivedescendant = this.filteredTokens[this.filteredTokens.length - 1].label;\n }\n } else if (event.key === 'Escape') {\n event.preventDefault();\n this.resetDropdown();\n } else if (event.key === 'Backspace' || event.key === 'Delete') {\n const selection = this.getCurrentSelectionForBrowser();\n if (selection?.currentText.startsWith('${')) {\n selection?.node?.parentNode && selection.node.parentNode.removeChild(selection.node);\n }\n }\n }\n\n selectOption(e: Event, option: { label: string; value: string; labelHTML: Token }) {\n e.preventDefault();\n const word = this.currentWord.fullText;\n const dollarWord = this.currentWord.$value;\n\n // Traverse the DOM to find the text node that contains the current word fullText\n let currentNode = this.titleRef.firstChild;\n let textNode: ChildNode | null = null;\n\n while (currentNode) {\n if (currentNode.nodeType === 3) {\n const currentNodeText = currentNode.textContent?.replace(/[\\u200B-\\u200D\\uFEFF]/g, '') || '';\n const wordText = word.replace(/[\\u200B-\\u200D\\uFEFF]/g, '');\n if (currentNodeText.includes(wordText)) {\n textNode = currentNode;\n break;\n }\n }\n currentNode = currentNode.nextSibling;\n }\n\n if (!textNode) {\n return;\n }\n // Split the text node into three parts: text before the token, the token, and text after the token\n const text = textNode.textContent || '';\n const index = text.indexOf(dollarWord);\n const textBefore = text.substring(0, index);\n const textAfter = text.substring(index + dollarWord.length);\n const newTextNode = document.createTextNode(textBefore);\n const newRange = document.createRange();\n\n // Create a new span element to replace the text node\n const tagSpan = document.createElement('span');\n tagSpan.classList.add('highlighted-tag');\n tagSpan.textContent = `${option.value}`;\n const newTextNodeAfter = document.createTextNode(textAfter);\n\n if (textAfter !== '') {\n // If there is text after the token, add it to the new span element\n textNode.replaceWith(newTextNode, tagSpan, newTextNodeAfter);\n newRange.setStart(newTextNodeAfter, 0);\n } else {\n // If there is no text after the token, add a zero-width space character (Without this, the cursor will not move outside the highlighted span element)\n const afterNode = document.createTextNode('\\u200B');\n textNode.replaceWith(newTextNode, tagSpan, afterNode);\n newRange.setStart(afterNode, 0);\n }\n\n // Hide the dropdown\n this.resetDropdown();\n this.titleRef.focus();\n\n // Set the focus to the new span element\n const sel = window.getSelection();\n newRange.collapse(true);\n sel?.removeAllRanges();\n sel?.addRange(newRange);\n\n // Update the event title with the selected token\n this.updateEventTitle(this.titleRef.textContent || '');\n }\n\n populateSuggestionsDropdown(query: string = '') {\n this.filteredTokens = this.availableTokens.filter(obj => {\n return obj.label.startsWith(query.toString()) || obj.value.startsWith(query.toString());\n });\n\n // Set the first option as the active descendant\n if (this.filteredTokens.length > 0) {\n this.ariaActivedescendant = this.filteredTokens[0].label;\n }\n }\n\n updateEventTitle(text: string) {\n const value = text.replace(/ +/g, ' ');\n if (value === '') {\n this.internals?.setValidity({ customError: true }, `Event title is required`, this.titleRef);\n this.validationError = 'Event title is required';\n } else {\n this.internals?.setValidity({ customError: false });\n this.validationError = '';\n }\n this.internals?.setFormValue(value, this.name);\n this.valueChanged.emit({ value: value, name: this.name });\n }\n\n resetDropdown() {\n this.showTokens = false;\n this.ariaActivedescendant = '';\n }\n\n getLabelHTML(token: { token: string; description: string }) {\n return (\n <div class=\"token-label\">\n <span class=\"token\">{token.token}</span>\n <span class=\"description\">{token.description}</span>\n </div>\n );\n }\n\n @RegisterComponent<NylasEventTitle, NylasSchedulerConfigConnector, Exclude<NylasSchedulerEditor['stores'], undefined>>({\n name: 'nylas-event-title',\n stateToProps: new Map([['schedulerConfig.selectedConfiguration', 'selectedConfiguration']]),\n eventToProps: {},\n fireRegisterEvent: true,\n })\n render() {\n return (\n <Host>\n <div class=\"nylas-event-title\" part=\"net\">\n <label htmlFor=\"title\">\n Event title<span class=\"required\">*</span>\n <span class=\"label-icon\">\n <tooltip-component>\n <info-icon slot=\"tooltip-icon\" />\n <span slot=\"tooltip-content\">Enter a title for your event.</span>\n </tooltip-component>\n </span>\n </label>\n <div\n class={{\n title: true,\n error: this.validationError !== '',\n }}\n part=\"net__title\"\n ref={el => (this.titleRef = el as HTMLDivElement)}\n contentEditable=\"true\"\n onInput={e => this.handleChange(e)}\n onKeyDown={event => this.handleInputKeyDown(event)}\n ></div>\n {this.showTokens && this.filteredTokens?.length > 0 && (\n <div class=\"token-options\" part=\"net__dropdown-content\">\n <ul tabindex=\"-1\" role=\"listbox\" aria-label={this.name} aria-activedescendant={this.ariaActivedescendant}>\n {this.filteredTokens.map(option => (\n <li\n tabindex=\"0\"\n key={option.label}\n id={option.label}\n class={{ active: this.ariaActivedescendant === option.label }}\n onClick={e => this.selectOption(e, option)}\n role=\"option\"\n >\n {this.getLabelHTML(option.labelHTML)}\n </li>\n ))}\n </ul>\n </div>\n )}\n <span class=\"help-text\">Create a dynamic templated event title by typing $. Learn more</span>\n {this.validationError != '' && <span class=\"error-message\">{this.validationError}</span>}\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"nylas-event-title.js","sourceRoot":"","sources":["../../../../src/components/scheduler-editor/nylas-event-title/nylas-event-title.tsx"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAgB,MAAM,EAAE,MAAM,eAAe,CAAC;AAE9H,OAAO,EAAE,kBAAkB,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAyB5E,MAAM,OAAO,eAAe;;;0BAYI,IAAI,CAAC,qBAAqB,EAAE,aAAa,EAAE,KAAK;oBAIvD,OAAO;0BAMC,KAAK;+BAI6C,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC9G,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;8BAI6E,IAAI,CAAC,eAAe;oCAK5D,EAAE;2BAWtC,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE;+BAEzB,EAAE;;IAWrC,yBAAyB,CAAC,QAAg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CACP;gBACD,6DAAM,KAAK,EAAC,WAAW,qEAAsE;gBAC5F,IAAI,CAAC,eAAe,IAAI,EAAE,IAAI,YAAM,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,eAAe,CAAQ,CACpF,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF;AAhDC;IANC,iBAAiB,CAAqG;QACrH,IAAI,EAAE,mBAAmB;QACzB,YAAY,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,uCAAuC,EAAE,uBAAuB,CAAC,CAAC,CAAC;QAC3F,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,IAAI;KACxB,CAAC;;;;6CAgDD","sourcesContent":["import { RegisterComponent } from '@/common/register-component';\nimport { NylasSchedulerConfigConnector } from '@/connector/nylas-scheduler-config-connector';\nimport { debug, getBrowser, isNonPrintableKey } from '@/utils/utils';\nimport { AttachInternals, Component, Host, State, h, Element, Prop, Watch, Event, EventEmitter, Listen } from '@stencil/core';\nimport { NylasSchedulerEditor } from '../nylas-scheduler-editor/nylas-scheduler-editor';\nimport { EVENT_TITLE_TOKENS as eventTitleTokens } from '@/common/constants';\nimport { Configuration } from '@nylas/core';\n\ninterface CustomShadowRoot extends ShadowRoot {\n getSelection: () => Selection | null;\n}\n\ntype Token = {\n token: string;\n value: string;\n description: string;\n};\n\n/**\n * The `nylas-event-title` component is a form input for the title of an event.\n * @part net - The event title container\n * @part net__title - The event title input\n * @part net__dropdown-content - The token options container\n */\n@Component({\n tag: 'nylas-event-title',\n styleUrl: 'nylas-event-title.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class NylasEventTitle {\n @Element() host!: HTMLElement;\n @AttachInternals() internals!: ElementInternals;\n\n // Properties\n /**\n * The selected config\n */\n @Prop() selectedConfiguration?: Configuration;\n /**\n * The title of the event from the cofiguration.\n */\n @Prop() eventTitle?: string = this.selectedConfiguration?.event_booking?.title;\n /**\n * The name attribute of this component.\n */\n @Prop() name: string = 'title';\n\n // State variables\n /**\n * Whether to show the tokens dropdown.\n */\n @State() showTokens: boolean = false;\n /**\n * The available token options for the dropdown.\n */\n @State() availableTokens: { label: string; value: string; labelHTML: Token }[] = eventTitleTokens.map(token => ({\n label: token.token,\n value: token.value,\n labelHTML: token,\n }));\n /**\n * The filtered token options for the dropdown based on the current query.\n */\n @State() filteredTokens: { label: string; value: string; labelHTML: Token }[] = this.availableTokens;\n /**\n * The aria-activedescendant attribute value. This is used to indicate the\n * currently active descendant in the tokens dropdown.\n */\n @State() ariaActivedescendant: string = '';\n /**\n * Stores the reference to the current word being typed.\n * This is used to update the event title with the selected token tag when\n * an option is selected from the dropdown by clicking on it.\n */\n @State() currentWord: {\n $value: string;\n fullText: string;\n index: number;\n focusOffset: number;\n } = { $value: '', fullText: '', index: -1, focusOffset: -1 };\n\n @State() validationError: string = '';\n\n // Reference to the title div element\n private titleRef!: HTMLDivElement;\n\n /**\n * When a name prop is passed, stencil does not automatically set the name attribute on the host element.\n * Since this component is form-associated, the name attribute is required for form submission.\n * This is a workaround to ensure that the name attribute is set on the host element.\n */\n @Watch('name')\n elementNameChangedHandler(newValue: string) {\n debug('nylas-event-title', 'elementNameChangedHandler', newValue);\n this.host.setAttribute('name', newValue);\n }\n\n @Watch('ariaActivedescendant')\n ariaActivedescendantChangedHandler(newValue: string) {\n debug('nylas-event-title', 'ariaActivedescendantChangedHandler', newValue);\n if (newValue !== '') {\n const activeOption = this.host.shadowRoot?.getElementById(newValue);\n activeOption?.classList.add('active');\n } else {\n const options = this.host.shadowRoot?.querySelectorAll('.token-options li.active');\n options?.forEach(option => option.classList.remove('active'));\n }\n }\n\n @Watch('selectedConfiguration')\n configChangedHandler(newVal) {\n const title = newVal?.event_booking?.title;\n if (title) {\n this.updateEventTitleFromProp(title);\n }\n }\n\n // Events\n /**\n * This event is fired when the value of the event title changes.\n */\n @Event() valueChanged!: EventEmitter<{\n value: string;\n name: string;\n }>;\n\n // Lifecycle methods\n connectedCallback() {\n debug('nylas-event-title', 'connectedCallback');\n }\n\n componentWillLoad() {\n debug('nylas-event-title', 'componentWillLoad');\n this.host.setAttribute('name', this.name);\n }\n\n componentDidLoad() {\n debug('nylas-event-title', 'componentDidLoad');\n this.updateEventTitleFromProp(this.eventTitle || '');\n }\n\n disconnectedCallback() {\n debug('nylas-event-title', 'disconnectedCallback');\n }\n\n @Listen('formSubmitted', { target: 'window' })\n formSubmittedHandler(event: CustomEvent) {\n debug('nylas-event-title', 'formSubmittedHandler', event);\n if (!this.internals?.validity?.valid) {\n this.validationError = 'Event title is required';\n } else {\n this.validationError = '';\n }\n }\n\n updateEventTitleFromProp(newValue: string) {\n debug('nylas-event-title', 'eventTitleChangedHandler', newValue);\n if (this.titleRef) {\n this.titleRef.innerHTML = this.highlightTokens(newValue);\n this.titleRef.focus();\n if (typeof this.internals.setValidity === 'function') {\n if (newValue === '') {\n this.internals?.setValidity({ customError: true }, `Event title is required`, this.titleRef);\n } else {\n this.internals?.setValidity({ customError: false });\n }\n }\n }\n }\n\n highlightTokens(title: string) {\n let outputHtml = title;\n\n eventTitleTokens.forEach(tokenObj => {\n const token = tokenObj.value;\n // Create a regular expression that matches the token as a whole word\n const regex = new RegExp(`(\\\\${token})(?!\\\\w)`, 'g');\n // Replace the token with a span element\n outputHtml = outputHtml.replace(regex, '<span class=\"highlighted-tag\">$1</span>');\n });\n return outputHtml;\n }\n\n getCurrentSelectionForBrowser() {\n const getSelectionTextData = (nodeValue, offset, node, allSelected) => {\n // Remove zero-width space characters from the text, because they are not visible and cause issues with the selection\n const text = nodeValue.replace(/[\\u200B-\\u200D\\uFEFF]/g, '');\n const dollarIndex = text.lastIndexOf('$');\n const lastWord = text.substring(dollarIndex).split(' ')[0];\n return {\n focusOffset: offset,\n dollarIndex,\n lastWord,\n currentText: text,\n node,\n allSelected,\n };\n };\n\n // Check if the selection has selected all the text in the node, we need this to handle the case where the user selects all the text and then types or deletes\n const isAllSelected = (selection: Selection) => selection.anchorOffset === 0 && selection.focusOffset === selection.focusNode?.nodeValue?.length;\n\n const currentBrowser = getBrowser();\n switch (currentBrowser) {\n case 'Chrome':\n const shadowRootSelection = (this.host.shadowRoot as CustomShadowRoot)?.getSelection();\n const focusNode = shadowRootSelection?.focusNode;\n const focusNodeValue = focusNode?.nodeValue || '';\n const allSelected = shadowRootSelection && isAllSelected(shadowRootSelection);\n return getSelectionTextData(focusNodeValue, shadowRootSelection?.focusOffset || -1, focusNode, allSelected);\n case 'Firefox':\n const selection = document.getSelection();\n const anchorNodeValue = selection?.anchorNode?.nodeValue || '';\n const allSelectedFirefox = selection && isAllSelected(selection);\n return getSelectionTextData(anchorNodeValue, selection?.focusOffset || -1, selection?.anchorNode, allSelectedFirefox);\n case 'Safari':\n const windowSelection = window.getSelection();\n const anchorNode = (windowSelection as any)?.getComposedRanges(this.host.shadowRoot as CustomShadowRoot)[0];\n const currentText = anchorNode?.startContainer?.nodeValue || '';\n const allSelectedSafari = windowSelection && isAllSelected(windowSelection);\n return getSelectionTextData(currentText, anchorNode?.endOffset || -1, anchorNode?.startContainer, allSelectedSafari);\n default:\n console.warn('Browser not supported');\n return null;\n }\n }\n\n handleChange(event: Event) {\n const textContent = (event.target as HTMLDivElement).textContent || '';\n // All browsers handle Selection within Shadow DOM differently, so get the current selection based on the browser\n const currentSelection = this.getCurrentSelectionForBrowser();\n if (!currentSelection) {\n this.updateEventTitle(textContent);\n this.resetDropdown();\n return;\n }\n const { focusOffset, dollarIndex, lastWord, currentText } = currentSelection;\n\n if (dollarIndex === -1 || focusOffset < dollarIndex) {\n this.updateEventTitle(textContent);\n this.resetDropdown();\n return;\n }\n if (lastWord.startsWith('$')) {\n this.showTokens = true;\n // Update the current word being typed, we need this reference to update the event title with the selected token\n // because the user can select an option from the dropdown by clicking on it, which will not trigger the input event.\n this.currentWord = {\n $value: lastWord,\n fullText: currentText,\n index: dollarIndex,\n focusOffset,\n };\n this.populateSuggestionsDropdown(lastWord);\n } else {\n this.resetDropdown();\n }\n this.updateEventTitle(textContent);\n }\n\n handleInputKeyDown(event) {\n const selection = this.getCurrentSelectionForBrowser();\n\n // If no text is remaining in the title, reset the title to an empty string\n if (selection?.allSelected && !isNonPrintableKey(event)) {\n this.titleRef.innerHTML = '';\n }\n\n if (event.key === 'Enter') {\n event.preventDefault();\n const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);\n if (activeOption) {\n activeOption.click();\n this.ariaActivedescendant = '';\n }\n } else if (event.key === 'ArrowDown') {\n event.preventDefault();\n const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);\n if (activeOption) {\n const nextOption = activeOption.nextElementSibling;\n if (nextOption) {\n this.ariaActivedescendant = nextOption.id;\n } else {\n this.ariaActivedescendant = this.filteredTokens[0].label;\n }\n } else {\n this.ariaActivedescendant = this.filteredTokens[0].label;\n }\n } else if (event.key === 'ArrowUp') {\n event.preventDefault();\n const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);\n if (activeOption) {\n const prevOption = activeOption.previousElementSibling;\n if (prevOption) {\n this.ariaActivedescendant = prevOption.id;\n } else {\n this.ariaActivedescendant = this.filteredTokens[this.filteredTokens.length - 1].label;\n }\n } else {\n this.ariaActivedescendant = this.filteredTokens[this.filteredTokens.length - 1].label;\n }\n } else if (event.key === 'Escape') {\n event.preventDefault();\n this.resetDropdown();\n } else if (event.key === 'Backspace' || event.key === 'Delete') {\n if (selection?.currentText.startsWith('${')) {\n selection?.node?.parentNode && selection.node.parentNode.removeChild(selection.node);\n }\n if (this.titleRef.textContent === '' || selection?.currentText === '' || selection?.allSelected) {\n this.titleRef.innerHTML = '';\n }\n }\n }\n\n selectOption(e: Event, option: { label: string; value: string; labelHTML: Token }) {\n e.preventDefault();\n const word = this.currentWord.fullText;\n const dollarWord = this.currentWord.$value;\n\n // Traverse the DOM to find the text node that contains the current word fullText\n let currentNode = this.titleRef.firstChild;\n let textNode: ChildNode | null = null;\n\n while (currentNode) {\n if (currentNode.nodeType === 3) {\n const currentNodeText = currentNode.textContent?.replace(/[\\u200B-\\u200D\\uFEFF]/g, '') || '';\n const wordText = word.replace(/[\\u200B-\\u200D\\uFEFF]/g, '');\n if (currentNodeText.includes(wordText)) {\n textNode = currentNode;\n break;\n }\n }\n currentNode = currentNode.nextSibling;\n }\n\n if (!textNode) {\n return;\n }\n // Split the text node into three parts: text before the token, the token, and text after the token\n const text = textNode.textContent || '';\n const index = text.indexOf(dollarWord);\n const textBefore = text.substring(0, index);\n const textAfter = text.substring(index + dollarWord.length);\n const newTextNode = document.createTextNode(textBefore);\n const newRange = document.createRange();\n\n // Create a new span element to replace the text node\n const tagSpan = document.createElement('span');\n tagSpan.classList.add('highlighted-tag');\n tagSpan.textContent = `${option.value}`;\n const newTextNodeAfter = document.createTextNode(textAfter);\n\n if (textAfter !== '') {\n // If there is text after the token, add it to the new span element\n textNode.replaceWith(newTextNode, tagSpan, newTextNodeAfter);\n newRange.setStart(newTextNodeAfter, 1);\n } else {\n // If there is no text after the token, add a zero-width space character (Without this, the cursor will not move outside the highlighted span element)\n const afterNode = document.createTextNode('\\u200B');\n textNode.replaceWith(newTextNode, tagSpan, afterNode);\n newRange.setStart(afterNode, 1);\n }\n\n // Hide the dropdown\n this.resetDropdown();\n this.titleRef.focus();\n\n // Set the focus to the new span element\n const sel = window.getSelection();\n newRange.collapse(true);\n sel?.removeAllRanges();\n sel?.addRange(newRange);\n\n // Update the event title with the selected token\n this.updateEventTitle(this.titleRef.textContent || '');\n }\n\n populateSuggestionsDropdown(query: string = '') {\n this.filteredTokens = this.availableTokens.filter(obj => {\n return obj.label.startsWith(query.toString()) || obj.value.startsWith(query.toString());\n });\n\n // Set the first option as the active descendant\n if (this.filteredTokens.length > 0) {\n this.ariaActivedescendant = this.filteredTokens[0].label;\n }\n }\n\n updateEventTitle(text: string) {\n const value = text.replace(/ +/g, ' ');\n if (value === '') {\n this.internals?.setValidity({ customError: true }, `Event title is required`, this.titleRef);\n this.validationError = 'Event title is required';\n } else {\n this.internals?.setValidity({ customError: false });\n this.validationError = '';\n }\n this.internals?.setFormValue(value, this.name);\n this.valueChanged.emit({ value: value, name: this.name });\n }\n\n resetDropdown() {\n this.showTokens = false;\n this.ariaActivedescendant = '';\n }\n\n getLabelHTML(token: { token: string; description: string }) {\n return (\n <div class=\"token-label\">\n <span class=\"token\">{token.token}</span>\n <span class=\"description\">{token.description}</span>\n </div>\n );\n }\n\n @RegisterComponent<NylasEventTitle, NylasSchedulerConfigConnector, Exclude<NylasSchedulerEditor['stores'], undefined>>({\n name: 'nylas-event-title',\n stateToProps: new Map([['schedulerConfig.selectedConfiguration', 'selectedConfiguration']]),\n eventToProps: {},\n fireRegisterEvent: true,\n })\n render() {\n return (\n <Host>\n <div class=\"nylas-event-title\" part=\"net\">\n <label htmlFor=\"title\">\n Event title<span class=\"required\">*</span>\n <span class=\"label-icon\">\n <tooltip-component>\n <info-icon slot=\"tooltip-icon\" />\n <span slot=\"tooltip-content\">Enter a title for your event.</span>\n </tooltip-component>\n </span>\n </label>\n <div\n class={{\n title: true,\n error: this.validationError !== '',\n }}\n part=\"net__title\"\n ref={el => (this.titleRef = el as HTMLDivElement)}\n contentEditable=\"true\"\n onInput={e => this.handleChange(e)}\n onKeyDown={event => this.handleInputKeyDown(event)}\n ></div>\n {this.showTokens && this.filteredTokens?.length > 0 && (\n <div class=\"token-options\" part=\"net__dropdown-content\">\n <ul tabindex=\"-1\" role=\"listbox\" aria-label={this.name} aria-activedescendant={this.ariaActivedescendant}>\n {this.filteredTokens.map(option => (\n <li\n tabindex=\"0\"\n key={option.label}\n id={option.label}\n class={{ active: this.ariaActivedescendant === option.label }}\n onClick={e => this.selectOption(e, option)}\n role=\"option\"\n >\n {this.getLabelHTML(option.labelHTML)}\n </li>\n ))}\n </ul>\n </div>\n )}\n <span class=\"help-text\">Create a dynamic templated event title by typing $. Learn more</span>\n {this.validationError != '' && <span class=\"error-message\">{this.validationError}</span>}\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -305,4 +305,48 @@ export function parsePreviewLink(link, config) {
305
305
  });
306
306
  return link;
307
307
  }
308
+ export function isNonPrintableKey(event) {
309
+ if (event.keyCode < 48 ||
310
+ (event.keyCode > 90 && event.keyCode < 96) ||
311
+ (event.keyCode > 111 && event.keyCode < 186) ||
312
+ event.keyCode > 222 ||
313
+ event.keyCode === 32 ||
314
+ event.keyCode === 91 ||
315
+ event.keyCode === 92 ||
316
+ event.keyCode === 93 ||
317
+ (event.keyCode >= 112 && event.keyCode <= 123) ||
318
+ (event.keyCode >= 37 && event.keyCode <= 40)) {
319
+ return true;
320
+ }
321
+ if (event.ctrlKey || event.altKey || event.metaKey) {
322
+ return true;
323
+ }
324
+ const shiftSpecialChars = [
325
+ 48,
326
+ 49,
327
+ 50,
328
+ 51,
329
+ 52,
330
+ 53,
331
+ 54,
332
+ 55,
333
+ 56,
334
+ 57,
335
+ 186,
336
+ 187,
337
+ 188,
338
+ 189,
339
+ 190,
340
+ 191,
341
+ 192,
342
+ 219,
343
+ 220,
344
+ 221,
345
+ 222,
346
+ ];
347
+ if (event.shiftKey && shiftSpecialChars.includes(event.keyCode)) {
348
+ return false;
349
+ }
350
+ return false;
351
+ }
308
352
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,MAAc,EAAE,IAAY;IAChE,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,I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AI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QACtC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { DataResponseError, DataResponseReturnType } from '@/common/types';\nimport { Configuration, EmailName, Message } from '@nylas/core';\nimport dayjs from 'dayjs';\nimport { RRule } from 'rrule';\n\nexport function format(first: string, middle: string, last: string): string {\n return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n\n// Utility function to remove undefined values from an object\nexport function removeUndefined(obj: any) {\n return Object.keys(obj).reduce((acc: { [key: string]: any }, key) => {\n if (obj[key] !== undefined) {\n acc[key] = obj[key];\n }\n return acc;\n }, {});\n}\n\nexport function debug(...args: any[]) {\n if (window && window.localStorage && window.localStorage.getItem('debug')) {\n console.debug(...args);\n }\n}\n\nexport function error(...args: any[]) {\n console.error(...args);\n}\n\nexport function uniqueID() {\n return Math.random().toString(36).substr(2, 9);\n}\n\nexport function formatEventName(propKey: string) {\n return propKey.toString().replace(/^on/, '');\n}\n\n// Utility function to format a date as a time if it is today, or a short\n// date format if it is not toda, using the new Intl API. For example:\n// If the date is today, it will return \"12:00 PM\"\n// If the date is not today, it will return \"Jan 4, 23\"\nexport function formatDateTime(dateTimestamp: number) {\n const date = new Date(dateTimestamp * 1000);\n const now = new Date();\n const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n if (date >= today) {\n // If the day is not today, we return the month and day (e.g. Jan 4)\n const formatter = new Intl.DateTimeFormat('default', {\n hour: 'numeric',\n minute: 'numeric',\n hour12: true,\n });\n return formatter.format(date);\n } else {\n // If the day is today, we only return the time (e.g. 12:00 PM) without\n // the month and day\n const formatter = new Intl.DateTimeFormat('default', {\n month: 'short',\n day: 'numeric',\n });\n return formatter.format(date);\n }\n}\n\nexport function formatRecipient(recipient: EmailName) {\n return recipient.name ? `${recipient.name} - ${recipient.email}` : recipient.email;\n}\n\n// Formats the particpants of a thread into a string\nexport function formatParticipants(participants: EmailName[], meEmail: string = '', messageCount: number = 1, max: number = 3) {\n const me = participants.find(p => p.email?.toLowerCase() === meEmail.toLowerCase());\n const others = participants.filter(p => p.email?.toLowerCase() !== meEmail.toLowerCase());\n const othersCount = others.length;\n const othersString = others\n .slice(0, max)\n .map(r => r.name || r.email)\n .join(', ');\n if (othersCount === 0) {\n return me ? 'me' : '';\n } else if (othersCount === 1) {\n return me && messageCount > 1 ? `me, ${othersString}` : othersString;\n } else if (othersCount === 2) {\n return me ? `me, ${othersString}` : `${othersString}`;\n } else {\n return me ? `me, ${othersString}, +${othersCount - max}` : `${othersString}, +${othersCount - max}`;\n }\n}\n\n// https://blog.webdevsimplified.com/2020-07/relative-time-format/\nconst DIVISIONS: Array<{\n amount: number;\n name: Intl.RelativeTimeFormatUnit;\n}> = [\n { amount: 60, name: 'seconds' },\n { amount: 60, name: 'minutes' },\n { amount: 24, name: 'hours' },\n { amount: 7, name: 'days' },\n { amount: 4.34524, name: 'weeks' },\n { amount: 12, name: 'months' },\n { amount: Number.POSITIVE_INFINITY, name: 'years' },\n];\n\nexport const formatTimeAgo = (date: Date) => {\n const formatter = new Intl.RelativeTimeFormat(undefined, {\n numeric: 'auto',\n });\n const now = new Date();\n let duration = (date.getTime() - now.getTime()) / 1000;\n\n for (let i = 0; i <= DIVISIONS.length; i++) {\n const division = DIVISIONS[i];\n if (Math.abs(duration) < division.amount) {\n return formatter.format(Math.round(duration), division.name);\n }\n duration /= division.amount;\n }\n};\n\nexport function getLastDayOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0);\n}\n\nexport function getFirstDayOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), 1);\n}\n\nexport function getFirstHourOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0);\n}\n\nexport function isSameDay(date1: Date, date2: Date) {\n return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();\n}\n\nexport function isSameMonth(date1: Date, date2: Date) {\n return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth();\n}\n\nexport function toTitleCase(str: string) {\n return str.replace(/\\w\\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());\n}\n\nexport function formatFolderName(folderName: string) {\n return folderName.replace('CATEGORY_', '').replace(/_/g, ' ');\n}\n\nexport function detectHTMLOrPlainText(html: string) {\n const regex = /<[^>]*>/g;\n return regex.test(html) ? 'html' : 'plain';\n}\n\nexport function detectIfMessageIsHTML(message: Message) {\n const headers = message.headers;\n const contentType = (headers && headers.find(h => h.name === 'Content-Type')?.value) || '';\n const contentDisposition = (headers && headers.find(h => h.name === 'Content-Disposition')?.value) || '';\n\n // If the content type is HTML, then we know it's HTML\n if (contentType.includes('text/html')) {\n return true;\n }\n\n // If the content disposition is inline, then we know it's HTML\n if (contentDisposition.includes('inline')) {\n return true;\n }\n\n // If the body is HTML, then we know it's HTML\n if (message.body && detectHTMLOrPlainText(message.body) === 'html') {\n return true;\n }\n\n // Otherwise, we assume it's plain text\n return false;\n}\n\nexport function parsePlainTextToHTML(text: string) {\n const paragraphs = text.split('\\n').filter(line => line.trim().length > 0);\n const wrappedParagraphs = paragraphs.map(paragraph => `<p>${paragraph}</p>`);\n let body = wrappedParagraphs.join('');\n\n // Replace links with anchor tags\n const regex = /((?:https?|ftp):\\/\\/[^\\s]+)/g;\n body = body.replace(regex, '<a href=\"$1\">$1</a>');\n\n return body;\n}\n\nexport function htmlToPlainText(html: string) {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n return doc.body.textContent || '';\n}\n\nexport function getStartHourOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0);\n}\n\nexport function getEndHourOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23);\n}\n\n// Zero pad a number to two digits\nexport function get24HourTime(date: Date) {\n return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;\n}\n\nexport function getUserTimezone() {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport const getEventRecurrence = (recurrence: any): string | null => {\n if (recurrence.includes('RRULE:')) {\n recurrence = recurrence.replace('RRULE:', '');\n return RRule.fromString(recurrence).toText();\n }\n return RRule.fromString(recurrence).toText();\n};\n\n// Validate time format part\nexport const validateTimeFormatInput = text => {\n if (text === '') {\n return true;\n }\n const regexPattern = /^(0[0-9]|1[0-2]|^[0-9])(:[0-5][0-9][ap]m?|:[0-5][0-9]|:[0-5]|:)?$/i;\n return regexPattern.test(text);\n};\n// Validate exact time format\nexport const validateExactTimeFormat = input => {\n const regex = /^(0[1-9]|1[0-2]):([0-5][0-9])(am|pm)$/i;\n return regex.test(input);\n};\n\nexport function roundToNearest15Minutes(time: dayjs.Dayjs | null = null) {\n let currentTime = dayjs(); // Get the current time\n if (time) {\n currentTime = time;\n }\n\n // Calculate the remainder when dividing the minutes by 15\n const minuteRemainder = currentTime.minute() % 15;\n\n let roundedTime;\n\n if (minuteRemainder !== 0) {\n // Round up to the next 15-minute interval\n roundedTime = currentTime.add(15 - minuteRemainder, 'minute');\n } else {\n // Keep the current time as it is\n roundedTime = currentTime;\n }\n\n return roundedTime;\n}\n\nexport function autocompleteTimeFormat(input) {\n const currentTime = dayjs(); // Get the current time\n\n let completedTime = '';\n\n // Extract the hour and minute components\n const [inputHour, inputMinuteWithAmPm] = input.split(':');\n // Autocomplete the hour component\n if (inputHour.length === 1) {\n completedTime += '0' + inputHour;\n } else if (inputHour.length === 2) {\n completedTime += inputHour;\n }\n\n completedTime += ':';\n\n // Autocomplete the minute component\n if (inputMinuteWithAmPm === undefined || inputMinuteWithAmPm == '') {\n completedTime += '00';\n } else {\n if (inputMinuteWithAmPm.length === 1) {\n completedTime += inputMinuteWithAmPm + '0';\n } else {\n completedTime += inputMinuteWithAmPm;\n }\n }\n\n // Set the am/pm indicator based on the provided input\n const amPmIndicator = completedTime.slice(-1); // Extract the am/pm indicator from input\n\n if (amPmIndicator === 'a') {\n completedTime += 'm';\n }\n if (amPmIndicator === 'p') {\n completedTime += 'm';\n }\n\n // Set the am/pm indicator based on the current time if no indecator present inside input\n if (completedTime.slice(-1) !== 'm') {\n if (completedTime.split(':')[0] == '00') {\n completedTime += 'am';\n } else {\n completedTime += currentTime.format('a');\n }\n }\n\n return completedTime;\n}\n\nexport function formatTime(time: string) {\n return dayjs(time, 'hh:mma');\n}\n\nexport function convertTo12HourFormat(timeStr: string) {\n // Split the time into hours and minutes\n const [hoursInitial, minutes] = timeStr.split(':').map(num => parseInt(num, 10));\n let hours = hoursInitial;\n\n // Determine AM or PM\n const ampm = hours >= 12 ? 'pm' : 'am';\n\n // Convert hours from 24-hour to 12-hour format\n hours = hours % 12;\n hours = hours ? hours : 12; // the hour '0' should be '12'\n\n // Format hours and minutes to ensure two digits\n const formattedHours = hours.toString().padStart(2, '0');\n const formattedMinutes = minutes.toString().padStart(2, '0');\n\n // Construct the 12-hour format time string\n return `${formattedHours}:${formattedMinutes}${ampm}`;\n}\n\nexport function convertTo24HourFormat(timeStr: string) {\n const [time, modifier] = timeStr.split(/(am|pm)/i);\n const [hoursInitial, minutes] = time.split(':').map(num => parseInt(num, 10));\n let hours = hoursInitial;\n\n if (modifier.toLowerCase() === 'pm' && hours < 12) {\n hours += 12;\n } else if (modifier.toLowerCase() === 'am' && hours === 12) {\n hours = 0;\n }\n\n return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;\n}\n\nexport function timeToMinutes(time) {\n const [hours, minutesPart] = time.match(/(\\d+):(\\d+)(am|pm)/).slice(1);\n let minutes = parseInt(hours, 10) * 60 + parseInt(minutesPart, 10);\n if (time.includes('pm') && parseInt(hours, 10) < 12) minutes += 12 * 60;\n if (time.includes('am') && parseInt(hours, 10) === 12) minutes -= 12 * 60;\n return minutes;\n}\n\nexport function minutesToTime(minutes) {\n const h = Math.floor(minutes / 60);\n const m = minutes % 60;\n return `${h}:${m < 10 ? '0' : ''}${m}`;\n}\n\nexport function getBrowser() {\n const ua = navigator.userAgent;\n\n // Check for Chrome (also in Edge and Opera)\n const isChrome = /Chrome/.test(ua) && /Google Inc/.test(navigator.vendor);\n\n // Check for Safari (also in Chrome and Opera)\n const isSafari = /Safari/.test(ua) && /Apple Computer/.test(navigator.vendor);\n\n // Check for Firefox\n const isFirefox = /Firefox/.test(ua);\n\n // Check for Internet Explorer\n const isIE = /Trident/.test(ua);\n\n // Check for Edge (the legacy version)\n const isEdgeLegacy = /Edge/.test(ua);\n\n // Check for Edge (the Chromium-based version)\n const isEdgeChromium = isChrome && /Edg/.test(ua);\n\n if (isEdgeChromium) return 'Edge (Chromium)';\n if (isChrome) return 'Chrome';\n if (isSafari) return 'Safari';\n if (isFirefox) return 'Firefox';\n if (isIE) return 'Internet Explorer';\n if (isEdgeLegacy) return 'Edge (Legacy)';\n\n return 'Unknown';\n}\n\n/**\n * Utility function to create a response object with data and error.\n * @param data any The data to return.\n * @param error DataResponseError The error to return.\n */\nexport function dataResponse<T = any>(data: T, error: DataResponseError | null = null): DataResponseReturnType<T> {\n if (error) {\n return [null, error];\n }\n return [data, null];\n}\n\n/**\n * Utility function to parse a preview link with placeholders.\n * @param link string A preview link with placeholders.\n * @param config Partial<Configuration> The configuration object to use to replace the placeholders.\n * @returns string The preview link with the placeholders replaced.\n */\nexport function parsePreviewLink(link: string, config?: Partial<Configuration>) {\n // Replacements\n const replacements = {\n 'config.id': config?.id,\n 'id': config?.id,\n };\n\n // Replace the placeholders with the actual values\n Object.keys(replacements).forEach(key => {\n link = link.replace(`{${key}}`, replacements[key]);\n });\n\n return link;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;A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C;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,MAAM,iBAAiB,GAAG;QACxB,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,EAAE;QACF,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;KACJ,CAAC;IAEF,IAAI,KAAK,CAAC,QAAQ,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IAGD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { DataResponseError, DataResponseReturnType } from '@/common/types';\nimport { Configuration, EmailName, Message } from '@nylas/core';\nimport dayjs from 'dayjs';\nimport { RRule } from 'rrule';\n\nexport function format(first: string, middle: string, last: string): string {\n return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n\n// Utility function to remove undefined values from an object\nexport function removeUndefined(obj: any) {\n return Object.keys(obj).reduce((acc: { [key: string]: any }, key) => {\n if (obj[key] !== undefined) {\n acc[key] = obj[key];\n }\n return acc;\n }, {});\n}\n\nexport function debug(...args: any[]) {\n if (window && window.localStorage && window.localStorage.getItem('debug')) {\n console.debug(...args);\n }\n}\n\nexport function error(...args: any[]) {\n console.error(...args);\n}\n\nexport function uniqueID() {\n return Math.random().toString(36).substr(2, 9);\n}\n\nexport function formatEventName(propKey: string) {\n return propKey.toString().replace(/^on/, '');\n}\n\n// Utility function to format a date as a time if it is today, or a short\n// date format if it is not toda, using the new Intl API. For example:\n// If the date is today, it will return \"12:00 PM\"\n// If the date is not today, it will return \"Jan 4, 23\"\nexport function formatDateTime(dateTimestamp: number) {\n const date = new Date(dateTimestamp * 1000);\n const now = new Date();\n const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n if (date >= today) {\n // If the day is not today, we return the month and day (e.g. Jan 4)\n const formatter = new Intl.DateTimeFormat('default', {\n hour: 'numeric',\n minute: 'numeric',\n hour12: true,\n });\n return formatter.format(date);\n } else {\n // If the day is today, we only return the time (e.g. 12:00 PM) without\n // the month and day\n const formatter = new Intl.DateTimeFormat('default', {\n month: 'short',\n day: 'numeric',\n });\n return formatter.format(date);\n }\n}\n\nexport function formatRecipient(recipient: EmailName) {\n return recipient.name ? `${recipient.name} - ${recipient.email}` : recipient.email;\n}\n\n// Formats the particpants of a thread into a string\nexport function formatParticipants(participants: EmailName[], meEmail: string = '', messageCount: number = 1, max: number = 3) {\n const me = participants.find(p => p.email?.toLowerCase() === meEmail.toLowerCase());\n const others = participants.filter(p => p.email?.toLowerCase() !== meEmail.toLowerCase());\n const othersCount = others.length;\n const othersString = others\n .slice(0, max)\n .map(r => r.name || r.email)\n .join(', ');\n if (othersCount === 0) {\n return me ? 'me' : '';\n } else if (othersCount === 1) {\n return me && messageCount > 1 ? `me, ${othersString}` : othersString;\n } else if (othersCount === 2) {\n return me ? `me, ${othersString}` : `${othersString}`;\n } else {\n return me ? `me, ${othersString}, +${othersCount - max}` : `${othersString}, +${othersCount - max}`;\n }\n}\n\n// https://blog.webdevsimplified.com/2020-07/relative-time-format/\nconst DIVISIONS: Array<{\n amount: number;\n name: Intl.RelativeTimeFormatUnit;\n}> = [\n { amount: 60, name: 'seconds' },\n { amount: 60, name: 'minutes' },\n { amount: 24, name: 'hours' },\n { amount: 7, name: 'days' },\n { amount: 4.34524, name: 'weeks' },\n { amount: 12, name: 'months' },\n { amount: Number.POSITIVE_INFINITY, name: 'years' },\n];\n\nexport const formatTimeAgo = (date: Date) => {\n const formatter = new Intl.RelativeTimeFormat(undefined, {\n numeric: 'auto',\n });\n const now = new Date();\n let duration = (date.getTime() - now.getTime()) / 1000;\n\n for (let i = 0; i <= DIVISIONS.length; i++) {\n const division = DIVISIONS[i];\n if (Math.abs(duration) < division.amount) {\n return formatter.format(Math.round(duration), division.name);\n }\n duration /= division.amount;\n }\n};\n\nexport function getLastDayOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth() + 1, 0);\n}\n\nexport function getFirstDayOfMonth(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), 1);\n}\n\nexport function getFirstHourOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0);\n}\n\nexport function isSameDay(date1: Date, date2: Date) {\n return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate();\n}\n\nexport function isSameMonth(date1: Date, date2: Date) {\n return date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth();\n}\n\nexport function toTitleCase(str: string) {\n return str.replace(/\\w\\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());\n}\n\nexport function formatFolderName(folderName: string) {\n return folderName.replace('CATEGORY_', '').replace(/_/g, ' ');\n}\n\nexport function detectHTMLOrPlainText(html: string) {\n const regex = /<[^>]*>/g;\n return regex.test(html) ? 'html' : 'plain';\n}\n\nexport function detectIfMessageIsHTML(message: Message) {\n const headers = message.headers;\n const contentType = (headers && headers.find(h => h.name === 'Content-Type')?.value) || '';\n const contentDisposition = (headers && headers.find(h => h.name === 'Content-Disposition')?.value) || '';\n\n // If the content type is HTML, then we know it's HTML\n if (contentType.includes('text/html')) {\n return true;\n }\n\n // If the content disposition is inline, then we know it's HTML\n if (contentDisposition.includes('inline')) {\n return true;\n }\n\n // If the body is HTML, then we know it's HTML\n if (message.body && detectHTMLOrPlainText(message.body) === 'html') {\n return true;\n }\n\n // Otherwise, we assume it's plain text\n return false;\n}\n\nexport function parsePlainTextToHTML(text: string) {\n const paragraphs = text.split('\\n').filter(line => line.trim().length > 0);\n const wrappedParagraphs = paragraphs.map(paragraph => `<p>${paragraph}</p>`);\n let body = wrappedParagraphs.join('');\n\n // Replace links with anchor tags\n const regex = /((?:https?|ftp):\\/\\/[^\\s]+)/g;\n body = body.replace(regex, '<a href=\"$1\">$1</a>');\n\n return body;\n}\n\nexport function htmlToPlainText(html: string) {\n const doc = new DOMParser().parseFromString(html, 'text/html');\n return doc.body.textContent || '';\n}\n\nexport function getStartHourOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0);\n}\n\nexport function getEndHourOfDay(date: Date) {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23);\n}\n\n// Zero pad a number to two digits\nexport function get24HourTime(date: Date) {\n return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;\n}\n\nexport function getUserTimezone() {\n return Intl.DateTimeFormat().resolvedOptions().timeZone;\n}\n\nexport const getEventRecurrence = (recurrence: any): string | null => {\n if (recurrence.includes('RRULE:')) {\n recurrence = recurrence.replace('RRULE:', '');\n return RRule.fromString(recurrence).toText();\n }\n return RRule.fromString(recurrence).toText();\n};\n\n// Validate time format part\nexport const validateTimeFormatInput = text => {\n if (text === '') {\n return true;\n }\n const regexPattern = /^(0[0-9]|1[0-2]|^[0-9])(:[0-5][0-9][ap]m?|:[0-5][0-9]|:[0-5]|:)?$/i;\n return regexPattern.test(text);\n};\n// Validate exact time format\nexport const validateExactTimeFormat = input => {\n const regex = /^(0[1-9]|1[0-2]):([0-5][0-9])(am|pm)$/i;\n return regex.test(input);\n};\n\nexport function roundToNearest15Minutes(time: dayjs.Dayjs | null = null) {\n let currentTime = dayjs(); // Get the current time\n if (time) {\n currentTime = time;\n }\n\n // Calculate the remainder when dividing the minutes by 15\n const minuteRemainder = currentTime.minute() % 15;\n\n let roundedTime;\n\n if (minuteRemainder !== 0) {\n // Round up to the next 15-minute interval\n roundedTime = currentTime.add(15 - minuteRemainder, 'minute');\n } else {\n // Keep the current time as it is\n roundedTime = currentTime;\n }\n\n return roundedTime;\n}\n\nexport function autocompleteTimeFormat(input) {\n const currentTime = dayjs(); // Get the current time\n\n let completedTime = '';\n\n // Extract the hour and minute components\n const [inputHour, inputMinuteWithAmPm] = input.split(':');\n // Autocomplete the hour component\n if (inputHour.length === 1) {\n completedTime += '0' + inputHour;\n } else if (inputHour.length === 2) {\n completedTime += inputHour;\n }\n\n completedTime += ':';\n\n // Autocomplete the minute component\n if (inputMinuteWithAmPm === undefined || inputMinuteWithAmPm == '') {\n completedTime += '00';\n } else {\n if (inputMinuteWithAmPm.length === 1) {\n completedTime += inputMinuteWithAmPm + '0';\n } else {\n completedTime += inputMinuteWithAmPm;\n }\n }\n\n // Set the am/pm indicator based on the provided input\n const amPmIndicator = completedTime.slice(-1); // Extract the am/pm indicator from input\n\n if (amPmIndicator === 'a') {\n completedTime += 'm';\n }\n if (amPmIndicator === 'p') {\n completedTime += 'm';\n }\n\n // Set the am/pm indicator based on the current time if no indecator present inside input\n if (completedTime.slice(-1) !== 'm') {\n if (completedTime.split(':')[0] == '00') {\n completedTime += 'am';\n } else {\n completedTime += currentTime.format('a');\n }\n }\n\n return completedTime;\n}\n\nexport function formatTime(time: string) {\n return dayjs(time, 'hh:mma');\n}\n\nexport function convertTo12HourFormat(timeStr: string) {\n // Split the time into hours and minutes\n const [hoursInitial, minutes] = timeStr.split(':').map(num => parseInt(num, 10));\n let hours = hoursInitial;\n\n // Determine AM or PM\n const ampm = hours >= 12 ? 'pm' : 'am';\n\n // Convert hours from 24-hour to 12-hour format\n hours = hours % 12;\n hours = hours ? hours : 12; // the hour '0' should be '12'\n\n // Format hours and minutes to ensure two digits\n const formattedHours = hours.toString().padStart(2, '0');\n const formattedMinutes = minutes.toString().padStart(2, '0');\n\n // Construct the 12-hour format time string\n return `${formattedHours}:${formattedMinutes}${ampm}`;\n}\n\nexport function convertTo24HourFormat(timeStr: string) {\n const [time, modifier] = timeStr.split(/(am|pm)/i);\n const [hoursInitial, minutes] = time.split(':').map(num => parseInt(num, 10));\n let hours = hoursInitial;\n\n if (modifier.toLowerCase() === 'pm' && hours < 12) {\n hours += 12;\n } else if (modifier.toLowerCase() === 'am' && hours === 12) {\n hours = 0;\n }\n\n return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;\n}\n\nexport function timeToMinutes(time) {\n const [hours, minutesPart] = time.match(/(\\d+):(\\d+)(am|pm)/).slice(1);\n let minutes = parseInt(hours, 10) * 60 + parseInt(minutesPart, 10);\n if (time.includes('pm') && parseInt(hours, 10) < 12) minutes += 12 * 60;\n if (time.includes('am') && parseInt(hours, 10) === 12) minutes -= 12 * 60;\n return minutes;\n}\n\nexport function minutesToTime(minutes) {\n const h = Math.floor(minutes / 60);\n const m = minutes % 60;\n return `${h}:${m < 10 ? '0' : ''}${m}`;\n}\n\nexport function getBrowser() {\n const ua = navigator.userAgent;\n\n // Check for Chrome (also in Edge and Opera)\n const isChrome = /Chrome/.test(ua) && /Google Inc/.test(navigator.vendor);\n\n // Check for Safari (also in Chrome and Opera)\n const isSafari = /Safari/.test(ua) && /Apple Computer/.test(navigator.vendor);\n\n // Check for Firefox\n const isFirefox = /Firefox/.test(ua);\n\n // Check for Internet Explorer\n const isIE = /Trident/.test(ua);\n\n // Check for Edge (the legacy version)\n const isEdgeLegacy = /Edge/.test(ua);\n\n // Check for Edge (the Chromium-based version)\n const isEdgeChromium = isChrome && /Edg/.test(ua);\n\n if (isEdgeChromium) return 'Edge (Chromium)';\n if (isChrome) return 'Chrome';\n if (isSafari) return 'Safari';\n if (isFirefox) return 'Firefox';\n if (isIE) return 'Internet Explorer';\n if (isEdgeLegacy) return 'Edge (Legacy)';\n\n return 'Unknown';\n}\n\n/**\n * Utility function to create a response object with data and error.\n * @param data any The data to return.\n * @param error DataResponseError The error to return.\n */\nexport function dataResponse<T = any>(data: T, error: DataResponseError | null = null): DataResponseReturnType<T> {\n if (error) {\n return [null, error];\n }\n return [data, null];\n}\n\n/**\n * Utility function to parse a preview link with placeholders.\n * @param link string A preview link with placeholders.\n * @param config Partial<Configuration> The configuration object to use to replace the placeholders.\n * @returns string The preview link with the placeholders replaced.\n */\nexport function parsePreviewLink(link: string, config?: Partial<Configuration>) {\n // Replacements\n const replacements = {\n 'config.id': config?.id,\n 'id': config?.id,\n };\n\n // Replace the placeholders with the actual values\n Object.keys(replacements).forEach(key => {\n link = link.replace(`{${key}}`, replacements[key]);\n });\n\n return link;\n}\n\nexport function isNonPrintableKey(event) {\n // Check for special keys like backspace, enter, escape, arrow keys, function keys, etc.\n if (\n event.keyCode < 48 || // Before 0\n (event.keyCode > 90 && event.keyCode < 96) || // Between Z and numpad 0\n (event.keyCode > 111 && event.keyCode < 186) || // Between numpad 9 and semi-colon (;)\n event.keyCode > 222 || // After single quote (')\n event.keyCode === 32 || // Spacebar\n event.keyCode === 91 || // Left Window key or left ⌘ key\n event.keyCode === 92 || // Right Window key or right ⌘ key\n event.keyCode === 93 || // Select key / Menu key or right ⌘ key\n (event.keyCode >= 112 && event.keyCode <= 123) || // Function (F1-F12) keys\n (event.keyCode >= 37 && event.keyCode <= 40) // Arrow keys\n ) {\n return true;\n }\n\n // Check for Ctrl, Alt, Shift, CapsLock, etc., by ignoring if any of these are pressed\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return true;\n }\n\n // Check if Shift is combined with a number or special character\n const shiftSpecialChars = [\n 48,\n 49,\n 50,\n 51,\n 52,\n 53,\n 54,\n 55,\n 56,\n 57, // Numbers (0-9)\n 186,\n 187,\n 188,\n 189,\n 190,\n 191,\n 192,\n 219,\n 220,\n 221,\n 222, // Special characters (;=,-./` and []\\')\n ];\n\n if (event.shiftKey && shiftSpecialChars.includes(event.keyCode)) {\n return false;\n }\n\n // If none of the above, it's a character, number, or special character typed without shift\n return false;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { a as debug, y as uniqueID, z as formatEventName } from './utils.js';
1
+ import { a as debug, z as uniqueID, A as formatEventName } from './utils.js';
2
2
 
3
3
  class NylasAbstractProvider {
4
4
  constructor(host, stores, automaticComponentRegistration = true, eventOverrides) {
@@ -1,6 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
2
  import { R as RegisterComponent } from './register-component.js';
3
- import { a as debug, q as getBrowser } from './utils.js';
3
+ import { a as debug, q as getBrowser, s as isNonPrintableKey } from './utils.js';
4
4
  import { E as EVENT_TITLE_TOKENS } from './constants.js';
5
5
  import { d as defineCustomElement$2 } from './info.js';
6
6
  import { d as defineCustomElement$1 } from './toolitp-component.js';
@@ -111,7 +111,7 @@ const NylasEventTitle = proxyCustomElement(class NylasEventTitle extends HTMLEle
111
111
  return outputHtml;
112
112
  }
113
113
  getCurrentSelectionForBrowser() {
114
- const getSelectionTextData = (nodeValue, offset, node) => {
114
+ const getSelectionTextData = (nodeValue, offset, node, allSelected) => {
115
115
  const text = nodeValue.replace(/[\u200B-\u200D\uFEFF]/g, '');
116
116
  const dollarIndex = text.lastIndexOf('$');
117
117
  const lastWord = text.substring(dollarIndex).split(' ')[0];
@@ -121,24 +121,29 @@ const NylasEventTitle = proxyCustomElement(class NylasEventTitle extends HTMLEle
121
121
  lastWord,
122
122
  currentText: text,
123
123
  node,
124
+ allSelected,
124
125
  };
125
126
  };
127
+ const isAllSelected = (selection) => selection.anchorOffset === 0 && selection.focusOffset === selection.focusNode?.nodeValue?.length;
126
128
  const currentBrowser = getBrowser();
127
129
  switch (currentBrowser) {
128
130
  case 'Chrome':
129
131
  const shadowRootSelection = this.host.shadowRoot?.getSelection();
130
132
  const focusNode = shadowRootSelection?.focusNode;
131
133
  const focusNodeValue = focusNode?.nodeValue || '';
132
- return getSelectionTextData(focusNodeValue, shadowRootSelection?.focusOffset || -1, focusNode);
134
+ const allSelected = shadowRootSelection && isAllSelected(shadowRootSelection);
135
+ return getSelectionTextData(focusNodeValue, shadowRootSelection?.focusOffset || -1, focusNode, allSelected);
133
136
  case 'Firefox':
134
137
  const selection = document.getSelection();
135
138
  const anchorNodeValue = selection?.anchorNode?.nodeValue || '';
136
- return getSelectionTextData(anchorNodeValue, selection?.focusOffset || -1, selection?.anchorNode);
139
+ const allSelectedFirefox = selection && isAllSelected(selection);
140
+ return getSelectionTextData(anchorNodeValue, selection?.focusOffset || -1, selection?.anchorNode, allSelectedFirefox);
137
141
  case 'Safari':
138
142
  const windowSelection = window.getSelection();
139
143
  const anchorNode = windowSelection?.getComposedRanges(this.host.shadowRoot)[0];
140
144
  const currentText = anchorNode?.startContainer?.nodeValue || '';
141
- return getSelectionTextData(currentText, anchorNode?.endOffset || -1, anchorNode?.startContainer);
145
+ const allSelectedSafari = windowSelection && isAllSelected(windowSelection);
146
+ return getSelectionTextData(currentText, anchorNode?.endOffset || -1, anchorNode?.startContainer, allSelectedSafari);
142
147
  default:
143
148
  console.warn('Browser not supported');
144
149
  return null;
@@ -174,6 +179,10 @@ const NylasEventTitle = proxyCustomElement(class NylasEventTitle extends HTMLEle
174
179
  this.updateEventTitle(textContent);
175
180
  }
176
181
  handleInputKeyDown(event) {
182
+ const selection = this.getCurrentSelectionForBrowser();
183
+ if (selection?.allSelected && !isNonPrintableKey(event)) {
184
+ this.titleRef.innerHTML = '';
185
+ }
177
186
  if (event.key === 'Enter') {
178
187
  event.preventDefault();
179
188
  const activeOption = this.host.shadowRoot?.getElementById(this.ariaActivedescendant);
@@ -219,10 +228,12 @@ const NylasEventTitle = proxyCustomElement(class NylasEventTitle extends HTMLEle
219
228
  this.resetDropdown();
220
229
  }
221
230
  else if (event.key === 'Backspace' || event.key === 'Delete') {
222
- const selection = this.getCurrentSelectionForBrowser();
223
231
  if (selection?.currentText.startsWith('${')) {
224
232
  selection?.node?.parentNode && selection.node.parentNode.removeChild(selection.node);
225
233
  }
234
+ if (this.titleRef.textContent === '' || selection?.currentText === '' || selection?.allSelected) {
235
+ this.titleRef.innerHTML = '';
236
+ }
226
237
  }
227
238
  }
228
239
  selectOption(e, option) {
@@ -257,12 +268,12 @@ const NylasEventTitle = proxyCustomElement(class NylasEventTitle extends HTMLEle
257
268
  const newTextNodeAfter = document.createTextNode(textAfter);
258
269
  if (textAfter !== '') {
259
270
  textNode.replaceWith(newTextNode, tagSpan, newTextNodeAfter);
260
- newRange.setStart(newTextNodeAfter, 0);
271
+ newRange.setStart(newTextNodeAfter, 1);
261
272
  }
262
273
  else {
263
274
  const afterNode = document.createTextNode('\u200B');
264
275
  textNode.replaceWith(newTextNode, tagSpan, afterNode);
265
- newRange.setStart(afterNode, 0);
276
+ newRange.setStart(afterNode, 1);
266
277
  }
267
278
  this.resetDropdown();
268
279
  this.titleRef.focus();
@@ -301,10 +312,10 @@ const NylasEventTitle = proxyCustomElement(class NylasEventTitle extends HTMLEle
301
312
  return (h("div", { class: "token-label" }, h("span", { class: "token" }, token.token), h("span", { class: "description" }, token.description)));
302
313
  }
303
314
  render() {
304
- return (h(Host, { key: '9287b1b2cb59f9cd83d585807070b8aaa4821a6c' }, h("div", { key: '02ca37b1b68691faf69c6cdd062475f10a87653c', class: "nylas-event-title", part: "net" }, h("label", { key: 'ceeda06d9da67727cdb5fce90b182a28cc3408e1', htmlFor: "title" }, "Event title", h("span", { key: 'd0e6b3387661a7f23a4796611f4854cf64b3bd9f', class: "required" }, "*"), h("span", { key: '84d0dd45f6a21504849aabf195676af2dacc40b2', class: "label-icon" }, h("tooltip-component", { key: 'bc8d5fbbd455a5d983ebb037e3d93e6dc2619cbd' }, h("info-icon", { key: '5c16591baceb37a8739c70b6fa505de08813ff0f', slot: "tooltip-icon" }), h("span", { key: '8214ecaad02beb8da5e0595aa13ff7057a0e60cc', slot: "tooltip-content" }, "Enter a title for your event.")))), h("div", { key: '98e9885cb4acd028908d7fb1b2a028cffd0dc7d4', class: {
315
+ return (h(Host, { key: 'e0ddf6c13a5a0c0d2e0db9188365418fb7484dcf' }, h("div", { key: 'a3b8e594c8d9632709e777891f04df0aaaf7c5c3', class: "nylas-event-title", part: "net" }, h("label", { key: 'e5794d2cd8be0b1666bfa67c3ea657da5dc8d45d', htmlFor: "title" }, "Event title", h("span", { key: '1210caceb7bf824f01559460e1c5e572cb2dad92', class: "required" }, "*"), h("span", { key: '4280ec285221e6db76ca08723fe3888a1d2643e3', class: "label-icon" }, h("tooltip-component", { key: 'd6c05fb79cf39656af7589a2e9de9ef832d7a2f8' }, h("info-icon", { key: 'a4659d97d60d00dfcc2c993e70da5cfd05904f78', slot: "tooltip-icon" }), h("span", { key: '738bfa669eec42b417be02fbad0584af34044c83', slot: "tooltip-content" }, "Enter a title for your event.")))), h("div", { key: 'df102dc899f8de91154689d9cdaae28465380622', class: {
305
316
  title: true,
306
317
  error: this.validationError !== '',
307
- }, part: "net__title", ref: el => (this.titleRef = el), contentEditable: "true", onInput: e => this.handleChange(e), onKeyDown: event => this.handleInputKeyDown(event) }), this.showTokens && this.filteredTokens?.length > 0 && (h("div", { class: "token-options", part: "net__dropdown-content" }, h("ul", { tabindex: "-1", role: "listbox", "aria-label": this.name, "aria-activedescendant": this.ariaActivedescendant }, this.filteredTokens.map(option => (h("li", { tabindex: "0", key: option.label, id: option.label, class: { active: this.ariaActivedescendant === option.label }, onClick: e => this.selectOption(e, option), role: "option" }, this.getLabelHTML(option.labelHTML))))))), h("span", { key: 'a2a15145119acf95335728589c24138386032188', class: "help-text" }, "Create a dynamic templated event title by typing $. Learn more"), this.validationError != '' && h("span", { class: "error-message" }, this.validationError))));
318
+ }, part: "net__title", ref: el => (this.titleRef = el), contentEditable: "true", onInput: e => this.handleChange(e), onKeyDown: event => this.handleInputKeyDown(event) }), this.showTokens && this.filteredTokens?.length > 0 && (h("div", { class: "token-options", part: "net__dropdown-content" }, h("ul", { tabindex: "-1", role: "listbox", "aria-label": this.name, "aria-activedescendant": this.ariaActivedescendant }, this.filteredTokens.map(option => (h("li", { tabindex: "0", key: option.label, id: option.label, class: { active: this.ariaActivedescendant === option.label }, onClick: e => this.selectOption(e, option), role: "option" }, this.getLabelHTML(option.labelHTML))))))), h("span", { key: 'ec769eea7e2e3ff6d64bef0f5099540c93ba80ab', class: "help-text" }, "Create a dynamic templated event title by typing $. Learn more"), this.validationError != '' && h("span", { class: "error-message" }, this.validationError))));
308
319
  }
309
320
  static get formAssociated() { return true; }
310
321
  get host() { return this; }